Files
Filip Skokan 5d1cff6065 test(types): cover public type regressions
Add regression coverage for JWK interoperability, open JOSE
identifiers, resolver signatures and result inference, error
discrimination, and conditional key result helpers.

Compile a second target without DOM or Node ambient types to exercise
the structural CryptoKey fallback and ensure it cannot degrade to any.

Signed-off-by: Filip Skokan <[email protected]>
2026-07-29 18:50:54 +02:00

23 lines
854 B
TypeScript

// Selects the CryptoKey structural fallback by compiling without DOM or Node ambient types.
import type * as jose from 'jose'
declare global {
interface AbortSignal {}
interface Headers {}
interface Response {}
interface URL {}
}
type Equals<A, B> = [A] extends [B] ? ([B] extends [A] ? true : never) : never
type KeyUsage =
'decrypt' | 'deriveBits' | 'deriveKey' | 'encrypt' | 'sign' | 'unwrapKey' | 'verify' | 'wrapKey'
const _algorithm: Equals<jose.CryptoKey['algorithm'], { name: string }> = true
const _extractable: Equals<jose.CryptoKey['extractable'], boolean> = true
const _type: Equals<jose.CryptoKey['type'], 'private' | 'public' | 'secret'> = true
const _usages: Equals<jose.CryptoKey['usages'], KeyUsage[]> = true
// @ts-expect-error the fallback must not degrade to any
const _notAny: jose.CryptoKey = 'definitely not a key'