@happyvertical/auth 0.80.0 → 0.80.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/chunks/cognito-thQmKf7L.js +124 -0
  2. package/dist/chunks/cognito-thQmKf7L.js.map +1 -0
  3. package/dist/chunks/decode_jwt-BvtACpi_.js +1183 -0
  4. package/dist/chunks/decode_jwt-BvtACpi_.js.map +1 -0
  5. package/dist/chunks/errors-RgVH84_1.js +343 -0
  6. package/dist/chunks/errors-RgVH84_1.js.map +1 -0
  7. package/dist/chunks/github-uNnnVjFZ.js +311 -0
  8. package/dist/chunks/github-uNnnVjFZ.js.map +1 -0
  9. package/dist/chunks/google-C_p8rExJ.js +374 -0
  10. package/dist/chunks/google-C_p8rExJ.js.map +1 -0
  11. package/dist/chunks/kanidm-DTcc6ufi.js +567 -0
  12. package/dist/chunks/kanidm-DTcc6ufi.js.map +1 -0
  13. package/dist/chunks/keycloak-CzPHgI2z.js +632 -0
  14. package/dist/chunks/keycloak-CzPHgI2z.js.map +1 -0
  15. package/dist/chunks/nostr-zrMaYMU-.js +141 -0
  16. package/dist/chunks/nostr-zrMaYMU-.js.map +1 -0
  17. package/dist/cli/claude-context.js +17 -17
  18. package/dist/cli/claude-context.js.map +1 -1
  19. package/dist/index.js +204 -486
  20. package/dist/index.js.map +1 -1
  21. package/package.json +5 -5
  22. package/dist/chunks/cognito-dmypylFX.js +0 -128
  23. package/dist/chunks/cognito-dmypylFX.js.map +0 -1
  24. package/dist/chunks/decode_jwt-D2OK1b8a.js +0 -1395
  25. package/dist/chunks/decode_jwt-D2OK1b8a.js.map +0 -1
  26. package/dist/chunks/github-NSZp5tVm.js +0 -413
  27. package/dist/chunks/github-NSZp5tVm.js.map +0 -1
  28. package/dist/chunks/google-HXk2ctYR.js +0 -483
  29. package/dist/chunks/google-HXk2ctYR.js.map +0 -1
  30. package/dist/chunks/index-BpsMhFXS.js +0 -151
  31. package/dist/chunks/index-BpsMhFXS.js.map +0 -1
  32. package/dist/chunks/kanidm-hkw-YPVF.js +0 -747
  33. package/dist/chunks/kanidm-hkw-YPVF.js.map +0 -1
  34. package/dist/chunks/keycloak-t6JEUeOz.js +0 -871
  35. package/dist/chunks/keycloak-t6JEUeOz.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decode_jwt-BvtACpi_.js","names":["decodeBase64URL","jwk.isJWK","jwk.isSecretJWK","invalidKeyInput","jwk.isPrivateJWK","jwk.isPublicJWK","b64u","#jwks","#cached","#url","#timeoutDuration","#cooldownDuration","#cacheMaxAge","#headers","#customFetch","#cache","#jwksTimestamp","#local","#pendingFetch","b64u"],"sources":["../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/buffer_utils.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/base64.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/util/base64url.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/crypto_key.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/invalid_key_input.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/util/errors.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/is_key_like.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/helpers.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/type_checks.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/signing.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/jwk_to_key.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/normalize_key.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/key/import.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/validate_crit.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/validate_algorithms.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/check_key_type.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/jws/flattened/verify.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/jws/compact/verify.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/lib/jwt_claims_set.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/jwt/verify.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/jwks/local.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/jwks/remote.js","../../../../node_modules/.pnpm/jose@6.2.2/node_modules/jose/dist/webapi/util/decode_jwt.js"],"sourcesContent":["export const encoder = new TextEncoder();\nexport const decoder = new TextDecoder();\nconst MAX_INT32 = 2 ** 32;\nexport function concat(...buffers) {\n const size = buffers.reduce((acc, { length }) => acc + length, 0);\n const buf = new Uint8Array(size);\n let i = 0;\n for (const buffer of buffers) {\n buf.set(buffer, i);\n i += buffer.length;\n }\n return buf;\n}\nfunction writeUInt32BE(buf, value, offset) {\n if (value < 0 || value >= MAX_INT32) {\n throw new RangeError(`value must be >= 0 and <= ${MAX_INT32 - 1}. Received ${value}`);\n }\n buf.set([value >>> 24, value >>> 16, value >>> 8, value & 0xff], offset);\n}\nexport function uint64be(value) {\n const high = Math.floor(value / MAX_INT32);\n const low = value % MAX_INT32;\n const buf = new Uint8Array(8);\n writeUInt32BE(buf, high, 0);\n writeUInt32BE(buf, low, 4);\n return buf;\n}\nexport function uint32be(value) {\n const buf = new Uint8Array(4);\n writeUInt32BE(buf, value);\n return buf;\n}\nexport function encode(string) {\n const bytes = new Uint8Array(string.length);\n for (let i = 0; i < string.length; i++) {\n const code = string.charCodeAt(i);\n if (code > 127) {\n throw new TypeError('non-ASCII string encountered in encode()');\n }\n bytes[i] = code;\n }\n return bytes;\n}\n","export function encodeBase64(input) {\n if (Uint8Array.prototype.toBase64) {\n return input.toBase64();\n }\n const CHUNK_SIZE = 0x8000;\n const arr = [];\n for (let i = 0; i < input.length; i += CHUNK_SIZE) {\n arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));\n }\n return btoa(arr.join(''));\n}\nexport function decodeBase64(encoded) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(encoded);\n }\n const binary = atob(encoded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n}\n","import { encoder, decoder } from '../lib/buffer_utils.js';\nimport { encodeBase64, decodeBase64 } from '../lib/base64.js';\nexport function decode(input) {\n if (Uint8Array.fromBase64) {\n return Uint8Array.fromBase64(typeof input === 'string' ? input : decoder.decode(input), {\n alphabet: 'base64url',\n });\n }\n let encoded = input;\n if (encoded instanceof Uint8Array) {\n encoded = decoder.decode(encoded);\n }\n encoded = encoded.replace(/-/g, '+').replace(/_/g, '/');\n try {\n return decodeBase64(encoded);\n }\n catch {\n throw new TypeError('The input to be decoded is not correctly encoded.');\n }\n}\nexport function encode(input) {\n let unencoded = input;\n if (typeof unencoded === 'string') {\n unencoded = encoder.encode(unencoded);\n }\n if (Uint8Array.prototype.toBase64) {\n return unencoded.toBase64({ alphabet: 'base64url', omitPadding: true });\n }\n return encodeBase64(unencoded).replace(/=/g, '').replace(/\\+/g, '-').replace(/\\//g, '_');\n}\n","const unusable = (name, prop = 'algorithm.name') => new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);\nconst isAlgorithm = (algorithm, name) => algorithm.name === name;\nfunction getHashLength(hash) {\n return parseInt(hash.name.slice(4), 10);\n}\nfunction checkHashLength(algorithm, expected) {\n const actual = getHashLength(algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n}\nfunction getNamedCurve(alg) {\n switch (alg) {\n case 'ES256':\n return 'P-256';\n case 'ES384':\n return 'P-384';\n case 'ES512':\n return 'P-521';\n default:\n throw new Error('unreachable');\n }\n}\nfunction checkUsage(key, usage) {\n if (usage && !key.usages.includes(usage)) {\n throw new TypeError(`CryptoKey does not support this operation, its usages must include ${usage}.`);\n }\n}\nexport function checkSigCryptoKey(key, alg, usage) {\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512': {\n if (!isAlgorithm(key.algorithm, 'HMAC'))\n throw unusable('HMAC');\n checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));\n break;\n }\n case 'RS256':\n case 'RS384':\n case 'RS512': {\n if (!isAlgorithm(key.algorithm, 'RSASSA-PKCS1-v1_5'))\n throw unusable('RSASSA-PKCS1-v1_5');\n checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));\n break;\n }\n case 'PS256':\n case 'PS384':\n case 'PS512': {\n if (!isAlgorithm(key.algorithm, 'RSA-PSS'))\n throw unusable('RSA-PSS');\n checkHashLength(key.algorithm, parseInt(alg.slice(2), 10));\n break;\n }\n case 'Ed25519':\n case 'EdDSA': {\n if (!isAlgorithm(key.algorithm, 'Ed25519'))\n throw unusable('Ed25519');\n break;\n }\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87': {\n if (!isAlgorithm(key.algorithm, alg))\n throw unusable(alg);\n break;\n }\n case 'ES256':\n case 'ES384':\n case 'ES512': {\n if (!isAlgorithm(key.algorithm, 'ECDSA'))\n throw unusable('ECDSA');\n const expected = getNamedCurve(alg);\n const actual = key.algorithm.namedCurve;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.namedCurve');\n break;\n }\n default:\n throw new TypeError('CryptoKey does not support this operation');\n }\n checkUsage(key, usage);\n}\nexport function checkEncCryptoKey(key, alg, usage) {\n switch (alg) {\n case 'A128GCM':\n case 'A192GCM':\n case 'A256GCM': {\n if (!isAlgorithm(key.algorithm, 'AES-GCM'))\n throw unusable('AES-GCM');\n const expected = parseInt(alg.slice(1, 4), 10);\n const actual = key.algorithm.length;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.length');\n break;\n }\n case 'A128KW':\n case 'A192KW':\n case 'A256KW': {\n if (!isAlgorithm(key.algorithm, 'AES-KW'))\n throw unusable('AES-KW');\n const expected = parseInt(alg.slice(1, 4), 10);\n const actual = key.algorithm.length;\n if (actual !== expected)\n throw unusable(expected, 'algorithm.length');\n break;\n }\n case 'ECDH': {\n switch (key.algorithm.name) {\n case 'ECDH':\n case 'X25519':\n break;\n default:\n throw unusable('ECDH or X25519');\n }\n break;\n }\n case 'PBES2-HS256+A128KW':\n case 'PBES2-HS384+A192KW':\n case 'PBES2-HS512+A256KW':\n if (!isAlgorithm(key.algorithm, 'PBKDF2'))\n throw unusable('PBKDF2');\n break;\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512': {\n if (!isAlgorithm(key.algorithm, 'RSA-OAEP'))\n throw unusable('RSA-OAEP');\n checkHashLength(key.algorithm, parseInt(alg.slice(9), 10) || 1);\n break;\n }\n default:\n throw new TypeError('CryptoKey does not support this operation');\n }\n checkUsage(key, usage);\n}\n","function message(msg, actual, ...types) {\n types = types.filter(Boolean);\n if (types.length > 2) {\n const last = types.pop();\n msg += `one of type ${types.join(', ')}, or ${last}.`;\n }\n else if (types.length === 2) {\n msg += `one of type ${types[0]} or ${types[1]}.`;\n }\n else {\n msg += `of type ${types[0]}.`;\n }\n if (actual == null) {\n msg += ` Received ${actual}`;\n }\n else if (typeof actual === 'function' && actual.name) {\n msg += ` Received function ${actual.name}`;\n }\n else if (typeof actual === 'object' && actual != null) {\n if (actual.constructor?.name) {\n msg += ` Received an instance of ${actual.constructor.name}`;\n }\n }\n return msg;\n}\nexport const invalidKeyInput = (actual, ...types) => message('Key must be ', actual, ...types);\nexport const withAlg = (alg, actual, ...types) => message(`Key for the ${alg} algorithm must be `, actual, ...types);\n","export class JOSEError extends Error {\n static code = 'ERR_JOSE_GENERIC';\n code = 'ERR_JOSE_GENERIC';\n constructor(message, options) {\n super(message, options);\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\nexport class JWTClaimValidationFailed extends JOSEError {\n static code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JWTExpired extends JOSEError {\n static code = 'ERR_JWT_EXPIRED';\n code = 'ERR_JWT_EXPIRED';\n claim;\n reason;\n payload;\n constructor(message, payload, claim = 'unspecified', reason = 'unspecified') {\n super(message, { cause: { claim, reason, payload } });\n this.claim = claim;\n this.reason = reason;\n this.payload = payload;\n }\n}\nexport class JOSEAlgNotAllowed extends JOSEError {\n static code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n}\nexport class JOSENotSupported extends JOSEError {\n static code = 'ERR_JOSE_NOT_SUPPORTED';\n code = 'ERR_JOSE_NOT_SUPPORTED';\n}\nexport class JWEDecryptionFailed extends JOSEError {\n static code = 'ERR_JWE_DECRYPTION_FAILED';\n code = 'ERR_JWE_DECRYPTION_FAILED';\n constructor(message = 'decryption operation failed', options) {\n super(message, options);\n }\n}\nexport class JWEInvalid extends JOSEError {\n static code = 'ERR_JWE_INVALID';\n code = 'ERR_JWE_INVALID';\n}\nexport class JWSInvalid extends JOSEError {\n static code = 'ERR_JWS_INVALID';\n code = 'ERR_JWS_INVALID';\n}\nexport class JWTInvalid extends JOSEError {\n static code = 'ERR_JWT_INVALID';\n code = 'ERR_JWT_INVALID';\n}\nexport class JWKInvalid extends JOSEError {\n static code = 'ERR_JWK_INVALID';\n code = 'ERR_JWK_INVALID';\n}\nexport class JWKSInvalid extends JOSEError {\n static code = 'ERR_JWKS_INVALID';\n code = 'ERR_JWKS_INVALID';\n}\nexport class JWKSNoMatchingKey extends JOSEError {\n static code = 'ERR_JWKS_NO_MATCHING_KEY';\n code = 'ERR_JWKS_NO_MATCHING_KEY';\n constructor(message = 'no applicable key found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSMultipleMatchingKeys extends JOSEError {\n [Symbol.asyncIterator];\n static code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n constructor(message = 'multiple matching keys found in the JSON Web Key Set', options) {\n super(message, options);\n }\n}\nexport class JWKSTimeout extends JOSEError {\n static code = 'ERR_JWKS_TIMEOUT';\n code = 'ERR_JWKS_TIMEOUT';\n constructor(message = 'request timed out', options) {\n super(message, options);\n }\n}\nexport class JWSSignatureVerificationFailed extends JOSEError {\n static code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n constructor(message = 'signature verification failed', options) {\n super(message, options);\n }\n}\n","export function assertCryptoKey(key) {\n if (!isCryptoKey(key)) {\n throw new Error('CryptoKey instance expected');\n }\n}\nexport const isCryptoKey = (key) => {\n if (key?.[Symbol.toStringTag] === 'CryptoKey')\n return true;\n try {\n return key instanceof CryptoKey;\n }\n catch {\n return false;\n }\n};\nexport const isKeyObject = (key) => key?.[Symbol.toStringTag] === 'KeyObject';\nexport const isKeyLike = (key) => isCryptoKey(key) || isKeyObject(key);\n","import { decode } from '../util/base64url.js';\nexport const unprotected = Symbol();\nexport function assertNotSet(value, name) {\n if (value) {\n throw new TypeError(`${name} can only be called once`);\n }\n}\nexport function decodeBase64url(value, label, ErrorClass) {\n try {\n return decode(value);\n }\n catch {\n throw new ErrorClass(`Failed to base64url decode the ${label}`);\n }\n}\nexport async function digest(algorithm, data) {\n const subtleDigest = `SHA-${algorithm.slice(-3)}`;\n return new Uint8Array(await crypto.subtle.digest(subtleDigest, data));\n}\n","const isObjectLike = (value) => typeof value === 'object' && value !== null;\nexport function isObject(input) {\n if (!isObjectLike(input) || Object.prototype.toString.call(input) !== '[object Object]') {\n return false;\n }\n if (Object.getPrototypeOf(input) === null) {\n return true;\n }\n let proto = input;\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n return Object.getPrototypeOf(input) === proto;\n}\nexport function isDisjoint(...headers) {\n const sources = headers.filter(Boolean);\n if (sources.length === 0 || sources.length === 1) {\n return true;\n }\n let acc;\n for (const header of sources) {\n const parameters = Object.keys(header);\n if (!acc || acc.size === 0) {\n acc = new Set(parameters);\n continue;\n }\n for (const parameter of parameters) {\n if (acc.has(parameter)) {\n return false;\n }\n acc.add(parameter);\n }\n }\n return true;\n}\nexport const isJWK = (key) => isObject(key) && typeof key.kty === 'string';\nexport const isPrivateJWK = (key) => key.kty !== 'oct' &&\n ((key.kty === 'AKP' && typeof key.priv === 'string') || typeof key.d === 'string');\nexport const isPublicJWK = (key) => key.kty !== 'oct' && key.d === undefined && key.priv === undefined;\nexport const isSecretJWK = (key) => key.kty === 'oct' && typeof key.k === 'string';\n","import { JOSENotSupported } from '../util/errors.js';\nimport { checkSigCryptoKey } from './crypto_key.js';\nimport { invalidKeyInput } from './invalid_key_input.js';\nexport function checkKeyLength(alg, key) {\n if (alg.startsWith('RS') || alg.startsWith('PS')) {\n const { modulusLength } = key.algorithm;\n if (typeof modulusLength !== 'number' || modulusLength < 2048) {\n throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);\n }\n }\n}\nfunction subtleAlgorithm(alg, algorithm) {\n const hash = `SHA-${alg.slice(-3)}`;\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512':\n return { hash, name: 'HMAC' };\n case 'PS256':\n case 'PS384':\n case 'PS512':\n return { hash, name: 'RSA-PSS', saltLength: parseInt(alg.slice(-3), 10) >> 3 };\n case 'RS256':\n case 'RS384':\n case 'RS512':\n return { hash, name: 'RSASSA-PKCS1-v1_5' };\n case 'ES256':\n case 'ES384':\n case 'ES512':\n return { hash, name: 'ECDSA', namedCurve: algorithm.namedCurve };\n case 'Ed25519':\n case 'EdDSA':\n return { name: 'Ed25519' };\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87':\n return { name: alg };\n default:\n throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n }\n}\nasync function getSigKey(alg, key, usage) {\n if (key instanceof Uint8Array) {\n if (!alg.startsWith('HS')) {\n throw new TypeError(invalidKeyInput(key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));\n }\n return crypto.subtle.importKey('raw', key, { hash: `SHA-${alg.slice(-3)}`, name: 'HMAC' }, false, [usage]);\n }\n checkSigCryptoKey(key, alg, usage);\n return key;\n}\nexport async function sign(alg, key, data) {\n const cryptoKey = await getSigKey(alg, key, 'sign');\n checkKeyLength(alg, cryptoKey);\n const signature = await crypto.subtle.sign(subtleAlgorithm(alg, cryptoKey.algorithm), cryptoKey, data);\n return new Uint8Array(signature);\n}\nexport async function verify(alg, key, signature, data) {\n const cryptoKey = await getSigKey(alg, key, 'verify');\n checkKeyLength(alg, cryptoKey);\n const algorithm = subtleAlgorithm(alg, cryptoKey.algorithm);\n try {\n return await crypto.subtle.verify(algorithm, cryptoKey, signature, data);\n }\n catch {\n return false;\n }\n}\n","import { JOSENotSupported } from '../util/errors.js';\nconst unsupportedAlg = 'Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value';\nfunction subtleMapping(jwk) {\n let algorithm;\n let keyUsages;\n switch (jwk.kty) {\n case 'AKP': {\n switch (jwk.alg) {\n case 'ML-DSA-44':\n case 'ML-DSA-65':\n case 'ML-DSA-87':\n algorithm = { name: jwk.alg };\n keyUsages = jwk.priv ? ['sign'] : ['verify'];\n break;\n default:\n throw new JOSENotSupported(unsupportedAlg);\n }\n break;\n }\n case 'RSA': {\n switch (jwk.alg) {\n case 'PS256':\n case 'PS384':\n case 'PS512':\n algorithm = { name: 'RSA-PSS', hash: `SHA-${jwk.alg.slice(-3)}` };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'RS256':\n case 'RS384':\n case 'RS512':\n algorithm = { name: 'RSASSA-PKCS1-v1_5', hash: `SHA-${jwk.alg.slice(-3)}` };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512':\n algorithm = {\n name: 'RSA-OAEP',\n hash: `SHA-${parseInt(jwk.alg.slice(-3), 10) || 1}`,\n };\n keyUsages = jwk.d ? ['decrypt', 'unwrapKey'] : ['encrypt', 'wrapKey'];\n break;\n default:\n throw new JOSENotSupported(unsupportedAlg);\n }\n break;\n }\n case 'EC': {\n switch (jwk.alg) {\n case 'ES256':\n case 'ES384':\n case 'ES512':\n algorithm = {\n name: 'ECDSA',\n namedCurve: { ES256: 'P-256', ES384: 'P-384', ES512: 'P-521' }[jwk.alg],\n };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n algorithm = { name: 'ECDH', namedCurve: jwk.crv };\n keyUsages = jwk.d ? ['deriveBits'] : [];\n break;\n default:\n throw new JOSENotSupported(unsupportedAlg);\n }\n break;\n }\n case 'OKP': {\n switch (jwk.alg) {\n case 'Ed25519':\n case 'EdDSA':\n algorithm = { name: 'Ed25519' };\n keyUsages = jwk.d ? ['sign'] : ['verify'];\n break;\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n algorithm = { name: jwk.crv };\n keyUsages = jwk.d ? ['deriveBits'] : [];\n break;\n default:\n throw new JOSENotSupported(unsupportedAlg);\n }\n break;\n }\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"kty\" (Key Type) Parameter value');\n }\n return { algorithm, keyUsages };\n}\nexport async function jwkToKey(jwk) {\n if (!jwk.alg) {\n throw new TypeError('\"alg\" argument is required when \"jwk.alg\" is not present');\n }\n const { algorithm, keyUsages } = subtleMapping(jwk);\n const keyData = { ...jwk };\n if (keyData.kty !== 'AKP') {\n delete keyData.alg;\n }\n delete keyData.use;\n return crypto.subtle.importKey('jwk', keyData, algorithm, jwk.ext ?? (jwk.d || jwk.priv ? false : true), jwk.key_ops ?? keyUsages);\n}\n","import { isJWK } from './type_checks.js';\nimport { decode } from '../util/base64url.js';\nimport { jwkToKey } from './jwk_to_key.js';\nimport { isCryptoKey, isKeyObject } from './is_key_like.js';\nconst unusableForAlg = 'given KeyObject instance cannot be used for this algorithm';\nlet cache;\nconst handleJWK = async (key, jwk, alg, freeze = false) => {\n cache ||= new WeakMap();\n let cached = cache.get(key);\n if (cached?.[alg]) {\n return cached[alg];\n }\n const cryptoKey = await jwkToKey({ ...jwk, alg });\n if (freeze)\n Object.freeze(key);\n if (!cached) {\n cache.set(key, { [alg]: cryptoKey });\n }\n else {\n cached[alg] = cryptoKey;\n }\n return cryptoKey;\n};\nconst handleKeyObject = (keyObject, alg) => {\n cache ||= new WeakMap();\n let cached = cache.get(keyObject);\n if (cached?.[alg]) {\n return cached[alg];\n }\n const isPublic = keyObject.type === 'public';\n const extractable = isPublic ? true : false;\n let cryptoKey;\n if (keyObject.asymmetricKeyType === 'x25519') {\n switch (alg) {\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW':\n break;\n default:\n throw new TypeError(unusableForAlg);\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, isPublic ? [] : ['deriveBits']);\n }\n if (keyObject.asymmetricKeyType === 'ed25519') {\n if (alg !== 'EdDSA' && alg !== 'Ed25519') {\n throw new TypeError(unusableForAlg);\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [\n isPublic ? 'verify' : 'sign',\n ]);\n }\n switch (keyObject.asymmetricKeyType) {\n case 'ml-dsa-44':\n case 'ml-dsa-65':\n case 'ml-dsa-87': {\n if (alg !== keyObject.asymmetricKeyType.toUpperCase()) {\n throw new TypeError(unusableForAlg);\n }\n cryptoKey = keyObject.toCryptoKey(keyObject.asymmetricKeyType, extractable, [\n isPublic ? 'verify' : 'sign',\n ]);\n }\n }\n if (keyObject.asymmetricKeyType === 'rsa') {\n let hash;\n switch (alg) {\n case 'RSA-OAEP':\n hash = 'SHA-1';\n break;\n case 'RS256':\n case 'PS256':\n case 'RSA-OAEP-256':\n hash = 'SHA-256';\n break;\n case 'RS384':\n case 'PS384':\n case 'RSA-OAEP-384':\n hash = 'SHA-384';\n break;\n case 'RS512':\n case 'PS512':\n case 'RSA-OAEP-512':\n hash = 'SHA-512';\n break;\n default:\n throw new TypeError(unusableForAlg);\n }\n if (alg.startsWith('RSA-OAEP')) {\n return keyObject.toCryptoKey({\n name: 'RSA-OAEP',\n hash,\n }, extractable, isPublic ? ['encrypt'] : ['decrypt']);\n }\n cryptoKey = keyObject.toCryptoKey({\n name: alg.startsWith('PS') ? 'RSA-PSS' : 'RSASSA-PKCS1-v1_5',\n hash,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (keyObject.asymmetricKeyType === 'ec') {\n const nist = new Map([\n ['prime256v1', 'P-256'],\n ['secp384r1', 'P-384'],\n ['secp521r1', 'P-521'],\n ]);\n const namedCurve = nist.get(keyObject.asymmetricKeyDetails?.namedCurve);\n if (!namedCurve) {\n throw new TypeError(unusableForAlg);\n }\n const expectedCurve = { ES256: 'P-256', ES384: 'P-384', ES512: 'P-521' };\n if (expectedCurve[alg] && namedCurve === expectedCurve[alg]) {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDSA',\n namedCurve,\n }, extractable, [isPublic ? 'verify' : 'sign']);\n }\n if (alg.startsWith('ECDH-ES')) {\n cryptoKey = keyObject.toCryptoKey({\n name: 'ECDH',\n namedCurve,\n }, extractable, isPublic ? [] : ['deriveBits']);\n }\n }\n if (!cryptoKey) {\n throw new TypeError(unusableForAlg);\n }\n if (!cached) {\n cache.set(keyObject, { [alg]: cryptoKey });\n }\n else {\n cached[alg] = cryptoKey;\n }\n return cryptoKey;\n};\nexport async function normalizeKey(key, alg) {\n if (key instanceof Uint8Array) {\n return key;\n }\n if (isCryptoKey(key)) {\n return key;\n }\n if (isKeyObject(key)) {\n if (key.type === 'secret') {\n return key.export();\n }\n if ('toCryptoKey' in key && typeof key.toCryptoKey === 'function') {\n try {\n return handleKeyObject(key, alg);\n }\n catch (err) {\n if (err instanceof TypeError) {\n throw err;\n }\n }\n }\n let jwk = key.export({ format: 'jwk' });\n return handleJWK(key, jwk, alg);\n }\n if (isJWK(key)) {\n if (key.k) {\n return decode(key.k);\n }\n return handleJWK(key, key, alg, true);\n }\n throw new Error('unreachable');\n}\n","import { decode as decodeBase64URL } from '../util/base64url.js';\nimport { fromSPKI, fromPKCS8, fromX509 } from '../lib/asn1.js';\nimport { jwkToKey } from '../lib/jwk_to_key.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { isObject } from '../lib/type_checks.js';\nexport async function importSPKI(spki, alg, options) {\n if (typeof spki !== 'string' || spki.indexOf('-----BEGIN PUBLIC KEY-----') !== 0) {\n throw new TypeError('\"spki\" must be SPKI formatted string');\n }\n return fromSPKI(spki, alg, options);\n}\nexport async function importX509(x509, alg, options) {\n if (typeof x509 !== 'string' || x509.indexOf('-----BEGIN CERTIFICATE-----') !== 0) {\n throw new TypeError('\"x509\" must be X.509 formatted string');\n }\n return fromX509(x509, alg, options);\n}\nexport async function importPKCS8(pkcs8, alg, options) {\n if (typeof pkcs8 !== 'string' || pkcs8.indexOf('-----BEGIN PRIVATE KEY-----') !== 0) {\n throw new TypeError('\"pkcs8\" must be PKCS#8 formatted string');\n }\n return fromPKCS8(pkcs8, alg, options);\n}\nexport async function importJWK(jwk, alg, options) {\n if (!isObject(jwk)) {\n throw new TypeError('JWK must be an object');\n }\n let ext;\n alg ??= jwk.alg;\n ext ??= options?.extractable ?? jwk.ext;\n switch (jwk.kty) {\n case 'oct':\n if (typeof jwk.k !== 'string' || !jwk.k) {\n throw new TypeError('missing \"k\" (Key Value) Parameter value');\n }\n return decodeBase64URL(jwk.k);\n case 'RSA':\n if ('oth' in jwk && jwk.oth !== undefined) {\n throw new JOSENotSupported('RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported');\n }\n return jwkToKey({ ...jwk, alg, ext });\n case 'AKP': {\n if (typeof jwk.alg !== 'string' || !jwk.alg) {\n throw new TypeError('missing \"alg\" (Algorithm) Parameter value');\n }\n if (alg !== undefined && alg !== jwk.alg) {\n throw new TypeError('JWK alg and alg option value mismatch');\n }\n return jwkToKey({ ...jwk, ext });\n }\n case 'EC':\n case 'OKP':\n return jwkToKey({ ...jwk, alg, ext });\n default:\n throw new JOSENotSupported('Unsupported \"kty\" (Key Type) Parameter value');\n }\n}\n","import { JOSENotSupported, JWEInvalid, JWSInvalid } from '../util/errors.js';\nexport function validateCrit(Err, recognizedDefault, recognizedOption, protectedHeader, joseHeader) {\n if (joseHeader.crit !== undefined && protectedHeader?.crit === undefined) {\n throw new Err('\"crit\" (Critical) Header Parameter MUST be integrity protected');\n }\n if (!protectedHeader || protectedHeader.crit === undefined) {\n return new Set();\n }\n if (!Array.isArray(protectedHeader.crit) ||\n protectedHeader.crit.length === 0 ||\n protectedHeader.crit.some((input) => typeof input !== 'string' || input.length === 0)) {\n throw new Err('\"crit\" (Critical) Header Parameter MUST be an array of non-empty strings when present');\n }\n let recognized;\n if (recognizedOption !== undefined) {\n recognized = new Map([...Object.entries(recognizedOption), ...recognizedDefault.entries()]);\n }\n else {\n recognized = recognizedDefault;\n }\n for (const parameter of protectedHeader.crit) {\n if (!recognized.has(parameter)) {\n throw new JOSENotSupported(`Extension Header Parameter \"${parameter}\" is not recognized`);\n }\n if (joseHeader[parameter] === undefined) {\n throw new Err(`Extension Header Parameter \"${parameter}\" is missing`);\n }\n if (recognized.get(parameter) && protectedHeader[parameter] === undefined) {\n throw new Err(`Extension Header Parameter \"${parameter}\" MUST be integrity protected`);\n }\n }\n return new Set(protectedHeader.crit);\n}\n","export function validateAlgorithms(option, algorithms) {\n if (algorithms !== undefined &&\n (!Array.isArray(algorithms) || algorithms.some((s) => typeof s !== 'string'))) {\n throw new TypeError(`\"${option}\" option must be an array of strings`);\n }\n if (!algorithms) {\n return undefined;\n }\n return new Set(algorithms);\n}\n","import { withAlg as invalidKeyInput } from './invalid_key_input.js';\nimport { isKeyLike } from './is_key_like.js';\nimport * as jwk from './type_checks.js';\nconst tag = (key) => key?.[Symbol.toStringTag];\nconst jwkMatchesOp = (alg, key, usage) => {\n if (key.use !== undefined) {\n let expected;\n switch (usage) {\n case 'sign':\n case 'verify':\n expected = 'sig';\n break;\n case 'encrypt':\n case 'decrypt':\n expected = 'enc';\n break;\n }\n if (key.use !== expected) {\n throw new TypeError(`Invalid key for this operation, its \"use\" must be \"${expected}\" when present`);\n }\n }\n if (key.alg !== undefined && key.alg !== alg) {\n throw new TypeError(`Invalid key for this operation, its \"alg\" must be \"${alg}\" when present`);\n }\n if (Array.isArray(key.key_ops)) {\n let expectedKeyOp;\n switch (true) {\n case usage === 'sign' || usage === 'verify':\n case alg === 'dir':\n case alg.includes('CBC-HS'):\n expectedKeyOp = usage;\n break;\n case alg.startsWith('PBES2'):\n expectedKeyOp = 'deriveBits';\n break;\n case /^A\\d{3}(?:GCM)?(?:KW)?$/.test(alg):\n if (!alg.includes('GCM') && alg.endsWith('KW')) {\n expectedKeyOp = usage === 'encrypt' ? 'wrapKey' : 'unwrapKey';\n }\n else {\n expectedKeyOp = usage;\n }\n break;\n case usage === 'encrypt' && alg.startsWith('RSA'):\n expectedKeyOp = 'wrapKey';\n break;\n case usage === 'decrypt':\n expectedKeyOp = alg.startsWith('RSA') ? 'unwrapKey' : 'deriveBits';\n break;\n }\n if (expectedKeyOp && key.key_ops?.includes?.(expectedKeyOp) === false) {\n throw new TypeError(`Invalid key for this operation, its \"key_ops\" must include \"${expectedKeyOp}\" when present`);\n }\n }\n return true;\n};\nconst symmetricTypeCheck = (alg, key, usage) => {\n if (key instanceof Uint8Array)\n return;\n if (jwk.isJWK(key)) {\n if (jwk.isSecretJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for symmetric algorithms must have JWK \"kty\" (Key Type) equal to \"oct\" and the JWK \"k\" (Key Value) present`);\n }\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key', 'Uint8Array'));\n }\n if (key.type !== 'secret') {\n throw new TypeError(`${tag(key)} instances for symmetric algorithms must be of type \"secret\"`);\n }\n};\nconst asymmetricTypeCheck = (alg, key, usage) => {\n if (jwk.isJWK(key)) {\n switch (usage) {\n case 'decrypt':\n case 'sign':\n if (jwk.isPrivateJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for this operation must be a private JWK`);\n case 'encrypt':\n case 'verify':\n if (jwk.isPublicJWK(key) && jwkMatchesOp(alg, key, usage))\n return;\n throw new TypeError(`JSON Web Key for this operation must be a public JWK`);\n }\n }\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));\n }\n if (key.type === 'secret') {\n throw new TypeError(`${tag(key)} instances for asymmetric algorithms must not be of type \"secret\"`);\n }\n if (key.type === 'public') {\n switch (usage) {\n case 'sign':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm signing must be of type \"private\"`);\n case 'decrypt':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm decryption must be of type \"private\"`);\n }\n }\n if (key.type === 'private') {\n switch (usage) {\n case 'verify':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm verifying must be of type \"public\"`);\n case 'encrypt':\n throw new TypeError(`${tag(key)} instances for asymmetric algorithm encryption must be of type \"public\"`);\n }\n }\n};\nexport function checkKeyType(alg, key, usage) {\n switch (alg.substring(0, 2)) {\n case 'A1':\n case 'A2':\n case 'di':\n case 'HS':\n case 'PB':\n symmetricTypeCheck(alg, key, usage);\n break;\n default:\n asymmetricTypeCheck(alg, key, usage);\n }\n}\n","import { decode as b64u } from '../../util/base64url.js';\nimport { verify } from '../../lib/signing.js';\nimport { JOSEAlgNotAllowed, JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';\nimport { concat, encoder, decoder, encode } from '../../lib/buffer_utils.js';\nimport { decodeBase64url } from '../../lib/helpers.js';\nimport { isDisjoint } from '../../lib/type_checks.js';\nimport { isObject } from '../../lib/type_checks.js';\nimport { checkKeyType } from '../../lib/check_key_type.js';\nimport { validateCrit } from '../../lib/validate_crit.js';\nimport { validateAlgorithms } from '../../lib/validate_algorithms.js';\nimport { normalizeKey } from '../../lib/normalize_key.js';\nexport async function flattenedVerify(jws, key, options) {\n if (!isObject(jws)) {\n throw new JWSInvalid('Flattened JWS must be an object');\n }\n if (jws.protected === undefined && jws.header === undefined) {\n throw new JWSInvalid('Flattened JWS must have either of the \"protected\" or \"header\" members');\n }\n if (jws.protected !== undefined && typeof jws.protected !== 'string') {\n throw new JWSInvalid('JWS Protected Header incorrect type');\n }\n if (jws.payload === undefined) {\n throw new JWSInvalid('JWS Payload missing');\n }\n if (typeof jws.signature !== 'string') {\n throw new JWSInvalid('JWS Signature missing or incorrect type');\n }\n if (jws.header !== undefined && !isObject(jws.header)) {\n throw new JWSInvalid('JWS Unprotected Header incorrect type');\n }\n let parsedProt = {};\n if (jws.protected) {\n try {\n const protectedHeader = b64u(jws.protected);\n parsedProt = JSON.parse(decoder.decode(protectedHeader));\n }\n catch {\n throw new JWSInvalid('JWS Protected Header is invalid');\n }\n }\n if (!isDisjoint(parsedProt, jws.header)) {\n throw new JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');\n }\n const joseHeader = {\n ...parsedProt,\n ...jws.header,\n };\n const extensions = validateCrit(JWSInvalid, new Map([['b64', true]]), options?.crit, parsedProt, joseHeader);\n let b64 = true;\n if (extensions.has('b64')) {\n b64 = parsedProt.b64;\n if (typeof b64 !== 'boolean') {\n throw new JWSInvalid('The \"b64\" (base64url-encode payload) Header Parameter must be a boolean');\n }\n }\n const { alg } = joseHeader;\n if (typeof alg !== 'string' || !alg) {\n throw new JWSInvalid('JWS \"alg\" (Algorithm) Header Parameter missing or invalid');\n }\n const algorithms = options && validateAlgorithms('algorithms', options.algorithms);\n if (algorithms && !algorithms.has(alg)) {\n throw new JOSEAlgNotAllowed('\"alg\" (Algorithm) Header Parameter value not allowed');\n }\n if (b64) {\n if (typeof jws.payload !== 'string') {\n throw new JWSInvalid('JWS Payload must be a string');\n }\n }\n else if (typeof jws.payload !== 'string' && !(jws.payload instanceof Uint8Array)) {\n throw new JWSInvalid('JWS Payload must be a string or an Uint8Array instance');\n }\n let resolvedKey = false;\n if (typeof key === 'function') {\n key = await key(parsedProt, jws);\n resolvedKey = true;\n }\n checkKeyType(alg, key, 'verify');\n const data = concat(jws.protected !== undefined ? encode(jws.protected) : new Uint8Array(), encode('.'), typeof jws.payload === 'string'\n ? b64\n ? encode(jws.payload)\n : encoder.encode(jws.payload)\n : jws.payload);\n const signature = decodeBase64url(jws.signature, 'signature', JWSInvalid);\n const k = await normalizeKey(key, alg);\n const verified = await verify(alg, k, signature, data);\n if (!verified) {\n throw new JWSSignatureVerificationFailed();\n }\n let payload;\n if (b64) {\n payload = decodeBase64url(jws.payload, 'payload', JWSInvalid);\n }\n else if (typeof jws.payload === 'string') {\n payload = encoder.encode(jws.payload);\n }\n else {\n payload = jws.payload;\n }\n const result = { payload };\n if (jws.protected !== undefined) {\n result.protectedHeader = parsedProt;\n }\n if (jws.header !== undefined) {\n result.unprotectedHeader = jws.header;\n }\n if (resolvedKey) {\n return { ...result, key: k };\n }\n return result;\n}\n","import { flattenedVerify } from '../flattened/verify.js';\nimport { JWSInvalid } from '../../util/errors.js';\nimport { decoder } from '../../lib/buffer_utils.js';\nexport async function compactVerify(jws, key, options) {\n if (jws instanceof Uint8Array) {\n jws = decoder.decode(jws);\n }\n if (typeof jws !== 'string') {\n throw new JWSInvalid('Compact JWS must be a string or Uint8Array');\n }\n const { 0: protectedHeader, 1: payload, 2: signature, length } = jws.split('.');\n if (length !== 3) {\n throw new JWSInvalid('Invalid Compact JWS');\n }\n const verified = await flattenedVerify({ payload, protected: protectedHeader, signature }, key, options);\n const result = { payload: verified.payload, protectedHeader: verified.protectedHeader };\n if (typeof key === 'function') {\n return { ...result, key: verified.key };\n }\n return result;\n}\n","import { JWTClaimValidationFailed, JWTExpired, JWTInvalid } from '../util/errors.js';\nimport { encoder, decoder } from './buffer_utils.js';\nimport { isObject } from './type_checks.js';\nconst epoch = (date) => Math.floor(date.getTime() / 1000);\nconst minute = 60;\nconst hour = minute * 60;\nconst day = hour * 24;\nconst week = day * 7;\nconst year = day * 365.25;\nconst REGEX = /^(\\+|\\-)? ?(\\d+|\\d+\\.\\d+) ?(seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)(?: (ago|from now))?$/i;\nexport function secs(str) {\n const matched = REGEX.exec(str);\n if (!matched || (matched[4] && matched[1])) {\n throw new TypeError('Invalid time period format');\n }\n const value = parseFloat(matched[2]);\n const unit = matched[3].toLowerCase();\n let numericDate;\n switch (unit) {\n case 'sec':\n case 'secs':\n case 'second':\n case 'seconds':\n case 's':\n numericDate = Math.round(value);\n break;\n case 'minute':\n case 'minutes':\n case 'min':\n case 'mins':\n case 'm':\n numericDate = Math.round(value * minute);\n break;\n case 'hour':\n case 'hours':\n case 'hr':\n case 'hrs':\n case 'h':\n numericDate = Math.round(value * hour);\n break;\n case 'day':\n case 'days':\n case 'd':\n numericDate = Math.round(value * day);\n break;\n case 'week':\n case 'weeks':\n case 'w':\n numericDate = Math.round(value * week);\n break;\n default:\n numericDate = Math.round(value * year);\n break;\n }\n if (matched[1] === '-' || matched[4] === 'ago') {\n return -numericDate;\n }\n return numericDate;\n}\nfunction validateInput(label, input) {\n if (!Number.isFinite(input)) {\n throw new TypeError(`Invalid ${label} input`);\n }\n return input;\n}\nconst normalizeTyp = (value) => {\n if (value.includes('/')) {\n return value.toLowerCase();\n }\n return `application/${value.toLowerCase()}`;\n};\nconst checkAudiencePresence = (audPayload, audOption) => {\n if (typeof audPayload === 'string') {\n return audOption.includes(audPayload);\n }\n if (Array.isArray(audPayload)) {\n return audOption.some(Set.prototype.has.bind(new Set(audPayload)));\n }\n return false;\n};\nexport function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {\n let payload;\n try {\n payload = JSON.parse(decoder.decode(encodedPayload));\n }\n catch {\n }\n if (!isObject(payload)) {\n throw new JWTInvalid('JWT Claims Set must be a top-level JSON object');\n }\n const { typ } = options;\n if (typ &&\n (typeof protectedHeader.typ !== 'string' ||\n normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ))) {\n throw new JWTClaimValidationFailed('unexpected \"typ\" JWT header value', payload, 'typ', 'check_failed');\n }\n const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options;\n const presenceCheck = [...requiredClaims];\n if (maxTokenAge !== undefined)\n presenceCheck.push('iat');\n if (audience !== undefined)\n presenceCheck.push('aud');\n if (subject !== undefined)\n presenceCheck.push('sub');\n if (issuer !== undefined)\n presenceCheck.push('iss');\n for (const claim of new Set(presenceCheck.reverse())) {\n if (!(claim in payload)) {\n throw new JWTClaimValidationFailed(`missing required \"${claim}\" claim`, payload, claim, 'missing');\n }\n }\n if (issuer &&\n !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) {\n throw new JWTClaimValidationFailed('unexpected \"iss\" claim value', payload, 'iss', 'check_failed');\n }\n if (subject && payload.sub !== subject) {\n throw new JWTClaimValidationFailed('unexpected \"sub\" claim value', payload, 'sub', 'check_failed');\n }\n if (audience &&\n !checkAudiencePresence(payload.aud, typeof audience === 'string' ? [audience] : audience)) {\n throw new JWTClaimValidationFailed('unexpected \"aud\" claim value', payload, 'aud', 'check_failed');\n }\n let tolerance;\n switch (typeof options.clockTolerance) {\n case 'string':\n tolerance = secs(options.clockTolerance);\n break;\n case 'number':\n tolerance = options.clockTolerance;\n break;\n case 'undefined':\n tolerance = 0;\n break;\n default:\n throw new TypeError('Invalid clockTolerance option type');\n }\n const { currentDate } = options;\n const now = epoch(currentDate || new Date());\n if ((payload.iat !== undefined || maxTokenAge) && typeof payload.iat !== 'number') {\n throw new JWTClaimValidationFailed('\"iat\" claim must be a number', payload, 'iat', 'invalid');\n }\n if (payload.nbf !== undefined) {\n if (typeof payload.nbf !== 'number') {\n throw new JWTClaimValidationFailed('\"nbf\" claim must be a number', payload, 'nbf', 'invalid');\n }\n if (payload.nbf > now + tolerance) {\n throw new JWTClaimValidationFailed('\"nbf\" claim timestamp check failed', payload, 'nbf', 'check_failed');\n }\n }\n if (payload.exp !== undefined) {\n if (typeof payload.exp !== 'number') {\n throw new JWTClaimValidationFailed('\"exp\" claim must be a number', payload, 'exp', 'invalid');\n }\n if (payload.exp <= now - tolerance) {\n throw new JWTExpired('\"exp\" claim timestamp check failed', payload, 'exp', 'check_failed');\n }\n }\n if (maxTokenAge) {\n const age = now - payload.iat;\n const max = typeof maxTokenAge === 'number' ? maxTokenAge : secs(maxTokenAge);\n if (age - tolerance > max) {\n throw new JWTExpired('\"iat\" claim timestamp check failed (too far in the past)', payload, 'iat', 'check_failed');\n }\n if (age < 0 - tolerance) {\n throw new JWTClaimValidationFailed('\"iat\" claim timestamp check failed (it should be in the past)', payload, 'iat', 'check_failed');\n }\n }\n return payload;\n}\nexport class JWTClaimsBuilder {\n #payload;\n constructor(payload) {\n if (!isObject(payload)) {\n throw new TypeError('JWT Claims Set MUST be an object');\n }\n this.#payload = structuredClone(payload);\n }\n data() {\n return encoder.encode(JSON.stringify(this.#payload));\n }\n get iss() {\n return this.#payload.iss;\n }\n set iss(value) {\n this.#payload.iss = value;\n }\n get sub() {\n return this.#payload.sub;\n }\n set sub(value) {\n this.#payload.sub = value;\n }\n get aud() {\n return this.#payload.aud;\n }\n set aud(value) {\n this.#payload.aud = value;\n }\n set jti(value) {\n this.#payload.jti = value;\n }\n set nbf(value) {\n if (typeof value === 'number') {\n this.#payload.nbf = validateInput('setNotBefore', value);\n }\n else if (value instanceof Date) {\n this.#payload.nbf = validateInput('setNotBefore', epoch(value));\n }\n else {\n this.#payload.nbf = epoch(new Date()) + secs(value);\n }\n }\n set exp(value) {\n if (typeof value === 'number') {\n this.#payload.exp = validateInput('setExpirationTime', value);\n }\n else if (value instanceof Date) {\n this.#payload.exp = validateInput('setExpirationTime', epoch(value));\n }\n else {\n this.#payload.exp = epoch(new Date()) + secs(value);\n }\n }\n set iat(value) {\n if (value === undefined) {\n this.#payload.iat = epoch(new Date());\n }\n else if (value instanceof Date) {\n this.#payload.iat = validateInput('setIssuedAt', epoch(value));\n }\n else if (typeof value === 'string') {\n this.#payload.iat = validateInput('setIssuedAt', epoch(new Date()) + secs(value));\n }\n else {\n this.#payload.iat = validateInput('setIssuedAt', value);\n }\n }\n}\n","import { compactVerify } from '../jws/compact/verify.js';\nimport { validateClaimsSet } from '../lib/jwt_claims_set.js';\nimport { JWTInvalid } from '../util/errors.js';\nexport async function jwtVerify(jwt, key, options) {\n const verified = await compactVerify(jwt, key, options);\n if (verified.protectedHeader.crit?.includes('b64') && verified.protectedHeader.b64 === false) {\n throw new JWTInvalid('JWTs MUST NOT use unencoded payload');\n }\n const payload = validateClaimsSet(verified.protectedHeader, verified.payload, options);\n const result = { payload, protectedHeader: verified.protectedHeader };\n if (typeof key === 'function') {\n return { ...result, key: verified.key };\n }\n return result;\n}\n","import { importJWK } from '../key/import.js';\nimport { JWKSInvalid, JOSENotSupported, JWKSNoMatchingKey, JWKSMultipleMatchingKeys, } from '../util/errors.js';\nimport { isObject } from '../lib/type_checks.js';\nfunction getKtyFromAlg(alg) {\n switch (typeof alg === 'string' && alg.slice(0, 2)) {\n case 'RS':\n case 'PS':\n return 'RSA';\n case 'ES':\n return 'EC';\n case 'Ed':\n return 'OKP';\n case 'ML':\n return 'AKP';\n default:\n throw new JOSENotSupported('Unsupported \"alg\" value for a JSON Web Key Set');\n }\n}\nfunction isJWKSLike(jwks) {\n return (jwks &&\n typeof jwks === 'object' &&\n Array.isArray(jwks.keys) &&\n jwks.keys.every(isJWKLike));\n}\nfunction isJWKLike(key) {\n return isObject(key);\n}\nclass LocalJWKSet {\n #jwks;\n #cached = new WeakMap();\n constructor(jwks) {\n if (!isJWKSLike(jwks)) {\n throw new JWKSInvalid('JSON Web Key Set malformed');\n }\n this.#jwks = structuredClone(jwks);\n }\n jwks() {\n return this.#jwks;\n }\n async getKey(protectedHeader, token) {\n const { alg, kid } = { ...protectedHeader, ...token?.header };\n const kty = getKtyFromAlg(alg);\n const candidates = this.#jwks.keys.filter((jwk) => {\n let candidate = kty === jwk.kty;\n if (candidate && typeof kid === 'string') {\n candidate = kid === jwk.kid;\n }\n if (candidate && (typeof jwk.alg === 'string' || kty === 'AKP')) {\n candidate = alg === jwk.alg;\n }\n if (candidate && typeof jwk.use === 'string') {\n candidate = jwk.use === 'sig';\n }\n if (candidate && Array.isArray(jwk.key_ops)) {\n candidate = jwk.key_ops.includes('verify');\n }\n if (candidate) {\n switch (alg) {\n case 'ES256':\n candidate = jwk.crv === 'P-256';\n break;\n case 'ES384':\n candidate = jwk.crv === 'P-384';\n break;\n case 'ES512':\n candidate = jwk.crv === 'P-521';\n break;\n case 'Ed25519':\n case 'EdDSA':\n candidate = jwk.crv === 'Ed25519';\n break;\n }\n }\n return candidate;\n });\n const { 0: jwk, length } = candidates;\n if (length === 0) {\n throw new JWKSNoMatchingKey();\n }\n if (length !== 1) {\n const error = new JWKSMultipleMatchingKeys();\n const _cached = this.#cached;\n error[Symbol.asyncIterator] = async function* () {\n for (const jwk of candidates) {\n try {\n yield await importWithAlgCache(_cached, jwk, alg);\n }\n catch { }\n }\n };\n throw error;\n }\n return importWithAlgCache(this.#cached, jwk, alg);\n }\n}\nasync function importWithAlgCache(cache, jwk, alg) {\n const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);\n if (cached[alg] === undefined) {\n const key = await importJWK({ ...jwk, ext: true }, alg);\n if (key instanceof Uint8Array || key.type !== 'public') {\n throw new JWKSInvalid('JSON Web Key Set members must be public keys');\n }\n cached[alg] = key;\n }\n return cached[alg];\n}\nexport function createLocalJWKSet(jwks) {\n const set = new LocalJWKSet(jwks);\n const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);\n Object.defineProperties(localJWKSet, {\n jwks: {\n value: () => structuredClone(set.jwks()),\n enumerable: false,\n configurable: false,\n writable: false,\n },\n });\n return localJWKSet;\n}\n","import { JOSEError, JWKSNoMatchingKey, JWKSTimeout } from '../util/errors.js';\nimport { createLocalJWKSet } from './local.js';\nimport { isObject } from '../lib/type_checks.js';\nfunction isCloudflareWorkers() {\n return (typeof WebSocketPair !== 'undefined' ||\n (typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||\n (typeof EdgeRuntime !== 'undefined' && EdgeRuntime === 'vercel'));\n}\nlet USER_AGENT;\nif (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {\n const NAME = 'jose';\n const VERSION = 'v6.2.2';\n USER_AGENT = `${NAME}/${VERSION}`;\n}\nexport const customFetch = Symbol();\nasync function fetchJwks(url, headers, signal, fetchImpl = fetch) {\n const response = await fetchImpl(url, {\n method: 'GET',\n signal,\n redirect: 'manual',\n headers,\n }).catch((err) => {\n if (err.name === 'TimeoutError') {\n throw new JWKSTimeout();\n }\n throw err;\n });\n if (response.status !== 200) {\n throw new JOSEError('Expected 200 OK from the JSON Web Key Set HTTP response');\n }\n try {\n return await response.json();\n }\n catch {\n throw new JOSEError('Failed to parse the JSON Web Key Set HTTP response as JSON');\n }\n}\nexport const jwksCache = Symbol();\nfunction isFreshJwksCache(input, cacheMaxAge) {\n if (typeof input !== 'object' || input === null) {\n return false;\n }\n if (!('uat' in input) || typeof input.uat !== 'number' || Date.now() - input.uat >= cacheMaxAge) {\n return false;\n }\n if (!('jwks' in input) ||\n !isObject(input.jwks) ||\n !Array.isArray(input.jwks.keys) ||\n !Array.prototype.every.call(input.jwks.keys, isObject)) {\n return false;\n }\n return true;\n}\nclass RemoteJWKSet {\n #url;\n #timeoutDuration;\n #cooldownDuration;\n #cacheMaxAge;\n #jwksTimestamp;\n #pendingFetch;\n #headers;\n #customFetch;\n #local;\n #cache;\n constructor(url, options) {\n if (!(url instanceof URL)) {\n throw new TypeError('url must be an instance of URL');\n }\n this.#url = new URL(url.href);\n this.#timeoutDuration =\n typeof options?.timeoutDuration === 'number' ? options?.timeoutDuration : 5000;\n this.#cooldownDuration =\n typeof options?.cooldownDuration === 'number' ? options?.cooldownDuration : 30000;\n this.#cacheMaxAge = typeof options?.cacheMaxAge === 'number' ? options?.cacheMaxAge : 600000;\n this.#headers = new Headers(options?.headers);\n if (USER_AGENT && !this.#headers.has('User-Agent')) {\n this.#headers.set('User-Agent', USER_AGENT);\n }\n if (!this.#headers.has('accept')) {\n this.#headers.set('accept', 'application/json');\n this.#headers.append('accept', 'application/jwk-set+json');\n }\n this.#customFetch = options?.[customFetch];\n if (options?.[jwksCache] !== undefined) {\n this.#cache = options?.[jwksCache];\n if (isFreshJwksCache(options?.[jwksCache], this.#cacheMaxAge)) {\n this.#jwksTimestamp = this.#cache.uat;\n this.#local = createLocalJWKSet(this.#cache.jwks);\n }\n }\n }\n pendingFetch() {\n return !!this.#pendingFetch;\n }\n coolingDown() {\n return typeof this.#jwksTimestamp === 'number'\n ? Date.now() < this.#jwksTimestamp + this.#cooldownDuration\n : false;\n }\n fresh() {\n return typeof this.#jwksTimestamp === 'number'\n ? Date.now() < this.#jwksTimestamp + this.#cacheMaxAge\n : false;\n }\n jwks() {\n return this.#local?.jwks();\n }\n async getKey(protectedHeader, token) {\n if (!this.#local || !this.fresh()) {\n await this.reload();\n }\n try {\n return await this.#local(protectedHeader, token);\n }\n catch (err) {\n if (err instanceof JWKSNoMatchingKey) {\n if (this.coolingDown() === false) {\n await this.reload();\n return this.#local(protectedHeader, token);\n }\n }\n throw err;\n }\n }\n async reload() {\n if (this.#pendingFetch && isCloudflareWorkers()) {\n this.#pendingFetch = undefined;\n }\n this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch)\n .then((json) => {\n this.#local = createLocalJWKSet(json);\n if (this.#cache) {\n this.#cache.uat = Date.now();\n this.#cache.jwks = json;\n }\n this.#jwksTimestamp = Date.now();\n this.#pendingFetch = undefined;\n })\n .catch((err) => {\n this.#pendingFetch = undefined;\n throw err;\n });\n await this.#pendingFetch;\n }\n}\nexport function createRemoteJWKSet(url, options) {\n const set = new RemoteJWKSet(url, options);\n const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);\n Object.defineProperties(remoteJWKSet, {\n coolingDown: {\n get: () => set.coolingDown(),\n enumerable: true,\n configurable: false,\n },\n fresh: {\n get: () => set.fresh(),\n enumerable: true,\n configurable: false,\n },\n reload: {\n value: () => set.reload(),\n enumerable: true,\n configurable: false,\n writable: false,\n },\n reloading: {\n get: () => set.pendingFetch(),\n enumerable: true,\n configurable: false,\n },\n jwks: {\n value: () => set.jwks(),\n enumerable: true,\n configurable: false,\n writable: false,\n },\n });\n return remoteJWKSet;\n}\n","import { decode as b64u } from './base64url.js';\nimport { decoder } from '../lib/buffer_utils.js';\nimport { isObject } from '../lib/type_checks.js';\nimport { JWTInvalid } from './errors.js';\nexport function decodeJwt(jwt) {\n if (typeof jwt !== 'string')\n throw new JWTInvalid('JWTs must use Compact JWS serialization, JWT must be a string');\n const { 1: payload, length } = jwt.split('.');\n if (length === 5)\n throw new JWTInvalid('Only JWTs using Compact JWS serialization can be decoded');\n if (length !== 3)\n throw new JWTInvalid('Invalid JWT');\n if (!payload)\n throw new JWTInvalid('JWTs must contain a payload');\n let decoded;\n try {\n decoded = b64u(payload);\n }\n catch {\n throw new JWTInvalid('Failed to base64url decode the payload');\n }\n let result;\n try {\n result = JSON.parse(decoder.decode(decoded));\n }\n catch {\n throw new JWTInvalid('Failed to parse the decoded payload as JSON');\n }\n if (!isObject(result))\n throw new JWTInvalid('Invalid JWT Claims Set');\n return result;\n}\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22],"mappings":";AAAA,IAAa,UAAU,IAAI,YAAY;AACvC,IAAa,UAAU,IAAI,YAAY;AAEvC,SAAgB,OAAO,GAAG,SAAS;CAC/B,MAAM,OAAO,QAAQ,QAAQ,KAAK,EAAE,aAAa,MAAM,QAAQ,CAAC;CAChE,MAAM,MAAM,IAAI,WAAW,IAAI;CAC/B,IAAI,IAAI;CACR,KAAK,MAAM,UAAU,SAAS;EAC1B,IAAI,IAAI,QAAQ,CAAC;EACjB,KAAK,OAAO;CAChB;CACA,OAAO;AACX;AAoBA,SAAgB,OAAO,QAAQ;CAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,MAAM;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACpC,MAAM,OAAO,OAAO,WAAW,CAAC;EAChC,IAAI,OAAO,KACP,MAAM,IAAI,UAAU,0CAA0C;EAElE,MAAM,KAAK;CACf;CACA,OAAO;AACX;;;AC/BA,SAAgB,aAAa,SAAS;CAClC,IAAI,WAAW,YACX,OAAO,WAAW,WAAW,OAAO;CAExC,MAAM,SAAS,KAAK,OAAO;CAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,MAAM;CAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAC/B,MAAM,KAAK,OAAO,WAAW,CAAC;CAElC,OAAO;AACX;;;ACnBA,SAAgB,OAAO,OAAO;CAC1B,IAAI,WAAW,YACX,OAAO,WAAW,WAAW,OAAO,UAAU,WAAW,QAAQ,QAAQ,OAAO,KAAK,GAAG,EACpF,UAAU,YACd,CAAC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AAI,OAAO,QAAQ,UACf,MAAM,IAAI,WAAW,+DAA+D;CACxF,MAAM,EAAE,GAAG,SAAS,WAAW,IAAI,MAAM,GAAG;CAC5C,IAAI,WAAW,GACX,MAAM,IAAI,WAAW,0DAA0D;CACnF,IAAI,WAAW,GACX,MAAM,IAAI,WAAW,aAAa;CACtC,IAAI,CAAC,SACD,MAAM,IAAI,WAAW,6BAA6B;CACtD,IAAI;CACJ,IAAI;EACA,UAAUC,OAAK,OAAO;CAC1B,QACM;EACF,MAAM,IAAI,WAAW,wCAAwC;CACjE;CACA,IAAI;CACJ,IAAI;EACA,SAAS,KAAK,MAAM,QAAQ,OAAO,OAAO,CAAC;CAC/C,QACM;EACF,MAAM,IAAI,WAAW,6CAA6C;CACtE;CACA,IAAI,CAAC,SAAS,MAAM,GAChB,MAAM,IAAI,WAAW,wBAAwB;CACjD,OAAO;AACX"}
@@ -0,0 +1,343 @@
1
+ //#region src/shared/errors.ts
2
+ /**
3
+ * @happyvertical/auth - Error Classes
4
+ *
5
+ * Standardized authentication error types for consistent error handling
6
+ * across all providers (Keycloak, Cognito, Nostr).
7
+ */
8
+ /**
9
+ * Authentication error codes.
10
+ */
11
+ var AuthErrorCode = /* @__PURE__ */ function(AuthErrorCode) {
12
+ AuthErrorCode["INVALID_CREDENTIALS"] = "INVALID_CREDENTIALS";
13
+ AuthErrorCode["INVALID_TOKEN"] = "INVALID_TOKEN";
14
+ AuthErrorCode["TOKEN_EXPIRED"] = "TOKEN_EXPIRED";
15
+ AuthErrorCode["INVALID_REFRESH_TOKEN"] = "INVALID_REFRESH_TOKEN";
16
+ AuthErrorCode["SESSION_EXPIRED"] = "SESSION_EXPIRED";
17
+ AuthErrorCode["MFA_REQUIRED"] = "MFA_REQUIRED";
18
+ AuthErrorCode["INVALID_MFA_CODE"] = "INVALID_MFA_CODE";
19
+ AuthErrorCode["ACCESS_DENIED"] = "ACCESS_DENIED";
20
+ AuthErrorCode["INSUFFICIENT_SCOPE"] = "INSUFFICIENT_SCOPE";
21
+ AuthErrorCode["INVALID_ROLE"] = "INVALID_ROLE";
22
+ AuthErrorCode["USER_NOT_FOUND"] = "USER_NOT_FOUND";
23
+ AuthErrorCode["USER_ALREADY_EXISTS"] = "USER_ALREADY_EXISTS";
24
+ AuthErrorCode["USER_DISABLED"] = "USER_DISABLED";
25
+ AuthErrorCode["PROVIDER_ERROR"] = "PROVIDER_ERROR";
26
+ AuthErrorCode["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
27
+ AuthErrorCode["NETWORK_ERROR"] = "NETWORK_ERROR";
28
+ AuthErrorCode["INVALID_STATE"] = "INVALID_STATE";
29
+ AuthErrorCode["INVALID_NONCE"] = "INVALID_NONCE";
30
+ AuthErrorCode["INVALID_GRANT"] = "INVALID_GRANT";
31
+ AuthErrorCode["INVALID_CLIENT"] = "INVALID_CLIENT";
32
+ AuthErrorCode["INVALID_REDIRECT_URI"] = "INVALID_REDIRECT_URI";
33
+ AuthErrorCode["INVALID_SIGNATURE"] = "INVALID_SIGNATURE";
34
+ AuthErrorCode["RELAY_ERROR"] = "RELAY_ERROR";
35
+ AuthErrorCode["CHALLENGE_EXPIRED"] = "CHALLENGE_EXPIRED";
36
+ AuthErrorCode["EXTENSION_NOT_FOUND"] = "EXTENSION_NOT_FOUND";
37
+ AuthErrorCode["INVALID_KEY"] = "INVALID_KEY";
38
+ AuthErrorCode["NOT_IMPLEMENTED"] = "NOT_IMPLEMENTED";
39
+ AuthErrorCode["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
40
+ return AuthErrorCode;
41
+ }({});
42
+ /**
43
+ * Base authentication error class.
44
+ */
45
+ var AuthError = class AuthError extends Error {
46
+ code;
47
+ provider;
48
+ context;
49
+ constructor(message, code, provider, context) {
50
+ super(message);
51
+ this.name = "AuthError";
52
+ this.code = code;
53
+ this.provider = provider;
54
+ this.context = context;
55
+ if (Error.captureStackTrace) Error.captureStackTrace(this, AuthError);
56
+ }
57
+ /**
58
+ * Convert error to JSON for logging/serialization.
59
+ */
60
+ toJSON() {
61
+ return {
62
+ name: this.name,
63
+ message: this.message,
64
+ code: this.code,
65
+ provider: this.provider,
66
+ context: this.context,
67
+ stack: this.stack
68
+ };
69
+ }
70
+ };
71
+ /**
72
+ * Invalid credentials error.
73
+ */
74
+ var InvalidCredentialsError = class extends AuthError {
75
+ constructor(provider, context) {
76
+ super("Invalid credentials", "INVALID_CREDENTIALS", provider, context);
77
+ this.name = "InvalidCredentialsError";
78
+ }
79
+ };
80
+ /**
81
+ * Invalid token error.
82
+ */
83
+ var InvalidTokenError = class extends AuthError {
84
+ constructor(message, provider, context) {
85
+ super(message || "Invalid token", "INVALID_TOKEN", provider, context);
86
+ this.name = "InvalidTokenError";
87
+ }
88
+ };
89
+ /**
90
+ * Token expired error.
91
+ */
92
+ var TokenExpiredError = class extends AuthError {
93
+ expiredAt;
94
+ constructor(provider, expiredAt, context) {
95
+ super("Token has expired", "TOKEN_EXPIRED", provider, context);
96
+ this.name = "TokenExpiredError";
97
+ this.expiredAt = expiredAt;
98
+ }
99
+ };
100
+ /**
101
+ * Invalid refresh token error.
102
+ */
103
+ var InvalidRefreshTokenError = class extends AuthError {
104
+ constructor(provider, context) {
105
+ super("Invalid or expired refresh token", "INVALID_REFRESH_TOKEN", provider, context);
106
+ this.name = "InvalidRefreshTokenError";
107
+ }
108
+ };
109
+ /**
110
+ * Session expired error.
111
+ */
112
+ var SessionExpiredError = class extends AuthError {
113
+ constructor(provider, context) {
114
+ super("Session has expired", "SESSION_EXPIRED", provider, context);
115
+ this.name = "SessionExpiredError";
116
+ }
117
+ };
118
+ /**
119
+ * MFA required error.
120
+ */
121
+ var MfaRequiredError = class extends AuthError {
122
+ mfaMethods;
123
+ constructor(provider, mfaMethods, context) {
124
+ super("Multi-factor authentication required", "MFA_REQUIRED", provider, context);
125
+ this.name = "MfaRequiredError";
126
+ this.mfaMethods = mfaMethods;
127
+ }
128
+ };
129
+ /**
130
+ * Invalid MFA code error.
131
+ */
132
+ var InvalidMfaCodeError = class extends AuthError {
133
+ constructor(provider, context) {
134
+ super("Invalid MFA code", "INVALID_MFA_CODE", provider, context);
135
+ this.name = "InvalidMfaCodeError";
136
+ }
137
+ };
138
+ /**
139
+ * Access denied error.
140
+ */
141
+ var AccessDeniedError = class extends AuthError {
142
+ constructor(message, provider, context) {
143
+ super(message || "Access denied", "ACCESS_DENIED", provider, context);
144
+ this.name = "AccessDeniedError";
145
+ }
146
+ };
147
+ /**
148
+ * Insufficient scope error.
149
+ */
150
+ var InsufficientScopeError = class extends AuthError {
151
+ requiredScopes;
152
+ grantedScopes;
153
+ constructor(requiredScopes, grantedScopes, provider, context) {
154
+ super(`Insufficient scope. Required: ${requiredScopes?.join(", ") || "unknown"}`, "INSUFFICIENT_SCOPE", provider, context);
155
+ this.name = "InsufficientScopeError";
156
+ this.requiredScopes = requiredScopes;
157
+ this.grantedScopes = grantedScopes;
158
+ }
159
+ };
160
+ /**
161
+ * User not found error.
162
+ */
163
+ var UserNotFoundError = class extends AuthError {
164
+ userId;
165
+ constructor(userId, provider, context) {
166
+ super(userId ? `User not found: ${userId}` : "User not found", "USER_NOT_FOUND", provider, context);
167
+ this.name = "UserNotFoundError";
168
+ this.userId = userId;
169
+ }
170
+ };
171
+ /**
172
+ * User already exists error.
173
+ */
174
+ var UserAlreadyExistsError = class extends AuthError {
175
+ constructor(identifier, provider, context) {
176
+ super(identifier ? `User already exists: ${identifier}` : "User already exists", "USER_ALREADY_EXISTS", provider, context);
177
+ this.name = "UserAlreadyExistsError";
178
+ }
179
+ };
180
+ /**
181
+ * User disabled error.
182
+ */
183
+ var UserDisabledError = class extends AuthError {
184
+ constructor(userId, provider, context) {
185
+ super(userId ? `User is disabled: ${userId}` : "User is disabled", "USER_DISABLED", provider, context);
186
+ this.name = "UserDisabledError";
187
+ }
188
+ };
189
+ /**
190
+ * Provider error.
191
+ */
192
+ var ProviderError = class extends AuthError {
193
+ originalError;
194
+ constructor(message, provider, originalError, context) {
195
+ super(message, "PROVIDER_ERROR", provider, context);
196
+ this.name = "ProviderError";
197
+ this.originalError = originalError;
198
+ }
199
+ };
200
+ /**
201
+ * Configuration error.
202
+ */
203
+ var ConfigurationError = class extends AuthError {
204
+ constructor(message, provider, context) {
205
+ super(message, "CONFIGURATION_ERROR", provider, context);
206
+ this.name = "ConfigurationError";
207
+ }
208
+ };
209
+ /**
210
+ * Network error.
211
+ */
212
+ var NetworkError = class extends AuthError {
213
+ originalError;
214
+ constructor(message, provider, originalError, context) {
215
+ super(message || "Network error", "NETWORK_ERROR", provider, context);
216
+ this.name = "NetworkError";
217
+ this.originalError = originalError;
218
+ }
219
+ };
220
+ /**
221
+ * Invalid state error.
222
+ */
223
+ var InvalidStateError = class extends AuthError {
224
+ constructor(provider, context) {
225
+ super("Invalid or mismatched state parameter", "INVALID_STATE", provider, context);
226
+ this.name = "InvalidStateError";
227
+ }
228
+ };
229
+ /**
230
+ * Invalid nonce error.
231
+ */
232
+ var InvalidNonceError = class extends AuthError {
233
+ constructor(provider, context) {
234
+ super("Invalid or mismatched nonce", "INVALID_NONCE", provider, context);
235
+ this.name = "InvalidNonceError";
236
+ }
237
+ };
238
+ /**
239
+ * Invalid grant error.
240
+ */
241
+ var InvalidGrantError = class extends AuthError {
242
+ constructor(message, provider, context) {
243
+ super(message || "Invalid grant", "INVALID_GRANT", provider, context);
244
+ this.name = "InvalidGrantError";
245
+ }
246
+ };
247
+ /**
248
+ * Invalid client error.
249
+ */
250
+ var InvalidClientError = class extends AuthError {
251
+ constructor(provider, context) {
252
+ super("Invalid client credentials", "INVALID_CLIENT", provider, context);
253
+ this.name = "InvalidClientError";
254
+ }
255
+ };
256
+ /**
257
+ * Invalid redirect URI error.
258
+ */
259
+ var InvalidRedirectUriError = class extends AuthError {
260
+ constructor(provider, context) {
261
+ super("Invalid or mismatched redirect URI", "INVALID_REDIRECT_URI", provider, context);
262
+ this.name = "InvalidRedirectUriError";
263
+ }
264
+ };
265
+ /**
266
+ * Invalid signature error.
267
+ */
268
+ var InvalidSignatureError = class extends AuthError {
269
+ constructor(message, context) {
270
+ super(message || "Invalid event signature", "INVALID_SIGNATURE", "nostr", context);
271
+ this.name = "InvalidSignatureError";
272
+ }
273
+ };
274
+ /**
275
+ * Relay error.
276
+ */
277
+ var RelayError = class extends AuthError {
278
+ relayUrl;
279
+ originalError;
280
+ constructor(message, relayUrl, originalError, context) {
281
+ super(message, "RELAY_ERROR", "nostr", {
282
+ ...context,
283
+ relayUrl
284
+ });
285
+ this.name = "RelayError";
286
+ this.relayUrl = relayUrl;
287
+ this.originalError = originalError;
288
+ }
289
+ };
290
+ /**
291
+ * Challenge expired error.
292
+ */
293
+ var ChallengeExpiredError = class extends AuthError {
294
+ constructor(context) {
295
+ super("Authentication challenge has expired", "CHALLENGE_EXPIRED", "nostr", context);
296
+ this.name = "ChallengeExpiredError";
297
+ }
298
+ };
299
+ /**
300
+ * NIP-07 extension not found error.
301
+ */
302
+ var ExtensionNotFoundError = class extends AuthError {
303
+ constructor(context) {
304
+ super("NIP-07 browser extension not found. Install nos2x, Alby, or similar.", "EXTENSION_NOT_FOUND", "nostr", context);
305
+ this.name = "ExtensionNotFoundError";
306
+ }
307
+ };
308
+ /**
309
+ * Invalid key error.
310
+ */
311
+ var InvalidKeyError = class extends AuthError {
312
+ constructor(message, context) {
313
+ super(message || "Invalid key format", "INVALID_KEY", "nostr", context);
314
+ this.name = "InvalidKeyError";
315
+ }
316
+ };
317
+ /**
318
+ * Not implemented error.
319
+ */
320
+ var NotImplementedError = class extends AuthError {
321
+ operation;
322
+ constructor(operation, provider, context) {
323
+ super(`Operation '${operation}' is not supported by this provider`, "NOT_IMPLEMENTED", provider, context);
324
+ this.name = "NotImplementedError";
325
+ this.operation = operation;
326
+ }
327
+ };
328
+ /**
329
+ * Check if an error is an AuthError.
330
+ */
331
+ function isAuthError(error) {
332
+ return error instanceof AuthError;
333
+ }
334
+ /**
335
+ * Check if an error has a specific error code.
336
+ */
337
+ function hasErrorCode(error, code) {
338
+ return isAuthError(error) && error.code === code;
339
+ }
340
+ //#endregion
341
+ export { isAuthError as A, RelayError as C, UserDisabledError as D, UserAlreadyExistsError as E, UserNotFoundError as O, ProviderError as S, TokenExpiredError as T, InvalidStateError as _, ConfigurationError as a, NetworkError as b, InvalidClientError as c, InvalidKeyError as d, InvalidMfaCodeError as f, InvalidSignatureError as g, InvalidRefreshTokenError as h, ChallengeExpiredError as i, hasErrorCode as k, InvalidCredentialsError as l, InvalidRedirectUriError as m, AuthError as n, ExtensionNotFoundError as o, InvalidNonceError as p, AuthErrorCode as r, InsufficientScopeError as s, AccessDeniedError as t, InvalidGrantError as u, InvalidTokenError as v, SessionExpiredError as w, NotImplementedError as x, MfaRequiredError as y };
342
+
343
+ //# sourceMappingURL=errors-RgVH84_1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-RgVH84_1.js","names":[],"sources":["../../src/shared/errors.ts"],"sourcesContent":["/**\n * @happyvertical/auth - Error Classes\n *\n * Standardized authentication error types for consistent error handling\n * across all providers (Keycloak, Cognito, Nostr).\n */\n\n/**\n * Authentication error codes.\n */\nexport enum AuthErrorCode {\n // Authentication errors\n INVALID_CREDENTIALS = 'INVALID_CREDENTIALS',\n INVALID_TOKEN = 'INVALID_TOKEN',\n TOKEN_EXPIRED = 'TOKEN_EXPIRED',\n INVALID_REFRESH_TOKEN = 'INVALID_REFRESH_TOKEN',\n SESSION_EXPIRED = 'SESSION_EXPIRED',\n MFA_REQUIRED = 'MFA_REQUIRED',\n INVALID_MFA_CODE = 'INVALID_MFA_CODE',\n\n // Authorization errors\n ACCESS_DENIED = 'ACCESS_DENIED',\n INSUFFICIENT_SCOPE = 'INSUFFICIENT_SCOPE',\n INVALID_ROLE = 'INVALID_ROLE',\n\n // User management errors\n USER_NOT_FOUND = 'USER_NOT_FOUND',\n USER_ALREADY_EXISTS = 'USER_ALREADY_EXISTS',\n USER_DISABLED = 'USER_DISABLED',\n\n // Provider errors\n PROVIDER_ERROR = 'PROVIDER_ERROR',\n CONFIGURATION_ERROR = 'CONFIGURATION_ERROR',\n NETWORK_ERROR = 'NETWORK_ERROR',\n\n // OAuth/OIDC errors\n INVALID_STATE = 'INVALID_STATE',\n INVALID_NONCE = 'INVALID_NONCE',\n INVALID_GRANT = 'INVALID_GRANT',\n INVALID_CLIENT = 'INVALID_CLIENT',\n INVALID_REDIRECT_URI = 'INVALID_REDIRECT_URI',\n\n // Nostr-specific errors\n INVALID_SIGNATURE = 'INVALID_SIGNATURE',\n RELAY_ERROR = 'RELAY_ERROR',\n CHALLENGE_EXPIRED = 'CHALLENGE_EXPIRED',\n EXTENSION_NOT_FOUND = 'EXTENSION_NOT_FOUND',\n INVALID_KEY = 'INVALID_KEY',\n\n // General\n NOT_IMPLEMENTED = 'NOT_IMPLEMENTED',\n UNKNOWN_ERROR = 'UNKNOWN_ERROR',\n}\n\n/**\n * Base authentication error class.\n */\nexport class AuthError extends Error {\n public readonly code: AuthErrorCode;\n public readonly provider?: string;\n public readonly context?: Record<string, unknown>;\n\n constructor(\n message: string,\n code: AuthErrorCode,\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(message);\n this.name = 'AuthError';\n this.code = code;\n this.provider = provider;\n this.context = context;\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, AuthError);\n }\n }\n\n /**\n * Convert error to JSON for logging/serialization.\n */\n toJSON(): Record<string, unknown> {\n return {\n name: this.name,\n message: this.message,\n code: this.code,\n provider: this.provider,\n context: this.context,\n stack: this.stack,\n };\n }\n}\n\n// =============================================================================\n// AUTHENTICATION ERRORS\n// =============================================================================\n\n/**\n * Invalid credentials error.\n */\nexport class InvalidCredentialsError extends AuthError {\n constructor(provider?: string, context?: Record<string, unknown>) {\n super(\n 'Invalid credentials',\n AuthErrorCode.INVALID_CREDENTIALS,\n provider,\n context,\n );\n this.name = 'InvalidCredentialsError';\n }\n}\n\n/**\n * Invalid token error.\n */\nexport class InvalidTokenError extends AuthError {\n constructor(\n message?: string,\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(\n message || 'Invalid token',\n AuthErrorCode.INVALID_TOKEN,\n provider,\n context,\n );\n this.name = 'InvalidTokenError';\n }\n}\n\n/**\n * Token expired error.\n */\nexport class TokenExpiredError extends AuthError {\n public readonly expiredAt?: Date;\n\n constructor(\n provider?: string,\n expiredAt?: Date,\n context?: Record<string, unknown>,\n ) {\n super('Token has expired', AuthErrorCode.TOKEN_EXPIRED, provider, context);\n this.name = 'TokenExpiredError';\n this.expiredAt = expiredAt;\n }\n}\n\n/**\n * Invalid refresh token error.\n */\nexport class InvalidRefreshTokenError extends AuthError {\n constructor(provider?: string, context?: Record<string, unknown>) {\n super(\n 'Invalid or expired refresh token',\n AuthErrorCode.INVALID_REFRESH_TOKEN,\n provider,\n context,\n );\n this.name = 'InvalidRefreshTokenError';\n }\n}\n\n/**\n * Session expired error.\n */\nexport class SessionExpiredError extends AuthError {\n constructor(provider?: string, context?: Record<string, unknown>) {\n super(\n 'Session has expired',\n AuthErrorCode.SESSION_EXPIRED,\n provider,\n context,\n );\n this.name = 'SessionExpiredError';\n }\n}\n\n/**\n * MFA required error.\n */\nexport class MfaRequiredError extends AuthError {\n public readonly mfaMethods?: string[];\n\n constructor(\n provider?: string,\n mfaMethods?: string[],\n context?: Record<string, unknown>,\n ) {\n super(\n 'Multi-factor authentication required',\n AuthErrorCode.MFA_REQUIRED,\n provider,\n context,\n );\n this.name = 'MfaRequiredError';\n this.mfaMethods = mfaMethods;\n }\n}\n\n/**\n * Invalid MFA code error.\n */\nexport class InvalidMfaCodeError extends AuthError {\n constructor(provider?: string, context?: Record<string, unknown>) {\n super(\n 'Invalid MFA code',\n AuthErrorCode.INVALID_MFA_CODE,\n provider,\n context,\n );\n this.name = 'InvalidMfaCodeError';\n }\n}\n\n// =============================================================================\n// AUTHORIZATION ERRORS\n// =============================================================================\n\n/**\n * Access denied error.\n */\nexport class AccessDeniedError extends AuthError {\n constructor(\n message?: string,\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(\n message || 'Access denied',\n AuthErrorCode.ACCESS_DENIED,\n provider,\n context,\n );\n this.name = 'AccessDeniedError';\n }\n}\n\n/**\n * Insufficient scope error.\n */\nexport class InsufficientScopeError extends AuthError {\n public readonly requiredScopes?: string[];\n public readonly grantedScopes?: string[];\n\n constructor(\n requiredScopes?: string[],\n grantedScopes?: string[],\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(\n `Insufficient scope. Required: ${requiredScopes?.join(', ') || 'unknown'}`,\n AuthErrorCode.INSUFFICIENT_SCOPE,\n provider,\n context,\n );\n this.name = 'InsufficientScopeError';\n this.requiredScopes = requiredScopes;\n this.grantedScopes = grantedScopes;\n }\n}\n\n// =============================================================================\n// USER MANAGEMENT ERRORS\n// =============================================================================\n\n/**\n * User not found error.\n */\nexport class UserNotFoundError extends AuthError {\n public readonly userId?: string;\n\n constructor(\n userId?: string,\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(\n userId ? `User not found: ${userId}` : 'User not found',\n AuthErrorCode.USER_NOT_FOUND,\n provider,\n context,\n );\n this.name = 'UserNotFoundError';\n this.userId = userId;\n }\n}\n\n/**\n * User already exists error.\n */\nexport class UserAlreadyExistsError extends AuthError {\n constructor(\n identifier?: string,\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(\n identifier ? `User already exists: ${identifier}` : 'User already exists',\n AuthErrorCode.USER_ALREADY_EXISTS,\n provider,\n context,\n );\n this.name = 'UserAlreadyExistsError';\n }\n}\n\n/**\n * User disabled error.\n */\nexport class UserDisabledError extends AuthError {\n constructor(\n userId?: string,\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(\n userId ? `User is disabled: ${userId}` : 'User is disabled',\n AuthErrorCode.USER_DISABLED,\n provider,\n context,\n );\n this.name = 'UserDisabledError';\n }\n}\n\n// =============================================================================\n// PROVIDER ERRORS\n// =============================================================================\n\n/**\n * Provider error.\n */\nexport class ProviderError extends AuthError {\n public readonly originalError?: Error;\n\n constructor(\n message: string,\n provider?: string,\n originalError?: Error,\n context?: Record<string, unknown>,\n ) {\n super(message, AuthErrorCode.PROVIDER_ERROR, provider, context);\n this.name = 'ProviderError';\n this.originalError = originalError;\n }\n}\n\n/**\n * Configuration error.\n */\nexport class ConfigurationError extends AuthError {\n constructor(\n message: string,\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(message, AuthErrorCode.CONFIGURATION_ERROR, provider, context);\n this.name = 'ConfigurationError';\n }\n}\n\n/**\n * Network error.\n */\nexport class NetworkError extends AuthError {\n public readonly originalError?: Error;\n\n constructor(\n message?: string,\n provider?: string,\n originalError?: Error,\n context?: Record<string, unknown>,\n ) {\n super(\n message || 'Network error',\n AuthErrorCode.NETWORK_ERROR,\n provider,\n context,\n );\n this.name = 'NetworkError';\n this.originalError = originalError;\n }\n}\n\n// =============================================================================\n// OAUTH/OIDC ERRORS\n// =============================================================================\n\n/**\n * Invalid state error.\n */\nexport class InvalidStateError extends AuthError {\n constructor(provider?: string, context?: Record<string, unknown>) {\n super(\n 'Invalid or mismatched state parameter',\n AuthErrorCode.INVALID_STATE,\n provider,\n context,\n );\n this.name = 'InvalidStateError';\n }\n}\n\n/**\n * Invalid nonce error.\n */\nexport class InvalidNonceError extends AuthError {\n constructor(provider?: string, context?: Record<string, unknown>) {\n super(\n 'Invalid or mismatched nonce',\n AuthErrorCode.INVALID_NONCE,\n provider,\n context,\n );\n this.name = 'InvalidNonceError';\n }\n}\n\n/**\n * Invalid grant error.\n */\nexport class InvalidGrantError extends AuthError {\n constructor(\n message?: string,\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(\n message || 'Invalid grant',\n AuthErrorCode.INVALID_GRANT,\n provider,\n context,\n );\n this.name = 'InvalidGrantError';\n }\n}\n\n/**\n * Invalid client error.\n */\nexport class InvalidClientError extends AuthError {\n constructor(provider?: string, context?: Record<string, unknown>) {\n super(\n 'Invalid client credentials',\n AuthErrorCode.INVALID_CLIENT,\n provider,\n context,\n );\n this.name = 'InvalidClientError';\n }\n}\n\n/**\n * Invalid redirect URI error.\n */\nexport class InvalidRedirectUriError extends AuthError {\n constructor(provider?: string, context?: Record<string, unknown>) {\n super(\n 'Invalid or mismatched redirect URI',\n AuthErrorCode.INVALID_REDIRECT_URI,\n provider,\n context,\n );\n this.name = 'InvalidRedirectUriError';\n }\n}\n\n// =============================================================================\n// NOSTR-SPECIFIC ERRORS\n// =============================================================================\n\n/**\n * Invalid signature error.\n */\nexport class InvalidSignatureError extends AuthError {\n constructor(message?: string, context?: Record<string, unknown>) {\n super(\n message || 'Invalid event signature',\n AuthErrorCode.INVALID_SIGNATURE,\n 'nostr',\n context,\n );\n this.name = 'InvalidSignatureError';\n }\n}\n\n/**\n * Relay error.\n */\nexport class RelayError extends AuthError {\n public readonly relayUrl?: string;\n public readonly originalError?: Error;\n\n constructor(\n message: string,\n relayUrl?: string,\n originalError?: Error,\n context?: Record<string, unknown>,\n ) {\n super(message, AuthErrorCode.RELAY_ERROR, 'nostr', {\n ...context,\n relayUrl,\n });\n this.name = 'RelayError';\n this.relayUrl = relayUrl;\n this.originalError = originalError;\n }\n}\n\n/**\n * Challenge expired error.\n */\nexport class ChallengeExpiredError extends AuthError {\n constructor(context?: Record<string, unknown>) {\n super(\n 'Authentication challenge has expired',\n AuthErrorCode.CHALLENGE_EXPIRED,\n 'nostr',\n context,\n );\n this.name = 'ChallengeExpiredError';\n }\n}\n\n/**\n * NIP-07 extension not found error.\n */\nexport class ExtensionNotFoundError extends AuthError {\n constructor(context?: Record<string, unknown>) {\n super(\n 'NIP-07 browser extension not found. Install nos2x, Alby, or similar.',\n AuthErrorCode.EXTENSION_NOT_FOUND,\n 'nostr',\n context,\n );\n this.name = 'ExtensionNotFoundError';\n }\n}\n\n/**\n * Invalid key error.\n */\nexport class InvalidKeyError extends AuthError {\n constructor(message?: string, context?: Record<string, unknown>) {\n super(\n message || 'Invalid key format',\n AuthErrorCode.INVALID_KEY,\n 'nostr',\n context,\n );\n this.name = 'InvalidKeyError';\n }\n}\n\n// =============================================================================\n// GENERAL ERRORS\n// =============================================================================\n\n/**\n * Not implemented error.\n */\nexport class NotImplementedError extends AuthError {\n public readonly operation: string;\n\n constructor(\n operation: string,\n provider?: string,\n context?: Record<string, unknown>,\n ) {\n super(\n `Operation '${operation}' is not supported by this provider`,\n AuthErrorCode.NOT_IMPLEMENTED,\n provider,\n context,\n );\n this.name = 'NotImplementedError';\n this.operation = operation;\n }\n}\n\n/**\n * Check if an error is an AuthError.\n */\nexport function isAuthError(error: unknown): error is AuthError {\n return error instanceof AuthError;\n}\n\n/**\n * Check if an error has a specific error code.\n */\nexport function hasErrorCode(error: unknown, code: AuthErrorCode): boolean {\n return isAuthError(error) && error.code === code;\n}\n"],"mappings":";;;;;;;;;;AAUA,IAAY,gBAAL,yBAAA,eAAA;CAEL,cAAA,yBAAA;CACA,cAAA,mBAAA;CACA,cAAA,mBAAA;CACA,cAAA,2BAAA;CACA,cAAA,qBAAA;CACA,cAAA,kBAAA;CACA,cAAA,sBAAA;CAGA,cAAA,mBAAA;CACA,cAAA,wBAAA;CACA,cAAA,kBAAA;CAGA,cAAA,oBAAA;CACA,cAAA,yBAAA;CACA,cAAA,mBAAA;CAGA,cAAA,oBAAA;CACA,cAAA,yBAAA;CACA,cAAA,mBAAA;CAGA,cAAA,mBAAA;CACA,cAAA,mBAAA;CACA,cAAA,mBAAA;CACA,cAAA,oBAAA;CACA,cAAA,0BAAA;CAGA,cAAA,uBAAA;CACA,cAAA,iBAAA;CACA,cAAA,uBAAA;CACA,cAAA,yBAAA;CACA,cAAA,iBAAA;CAGA,cAAA,qBAAA;CACA,cAAA,mBAAA;;AACF,EAAA,CAAA,CAAA;;;;AAKA,IAAa,YAAb,MAAa,kBAAkB,MAAM;CACnC;CACA;CACA;CAEA,YACE,SACA,MACA,UACA,SACA;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;EACZ,KAAK,WAAW;EAChB,KAAK,UAAU;EAGf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