@wix/cli-app 1.1.34 → 1.1.35
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.
- package/build/CreateVersionCommand-FGFXCQ6O.js +4 -0
- package/build/{CreateVersionCommand-3ECZI65A.js.map → CreateVersionCommand-FGFXCQ6O.js.map} +1 -1
- package/build/DevCommand-5DVDWGBY.js +4 -0
- package/build/DevCommand-5DVDWGBY.js.map +1 -0
- package/build/{GenerateCommand-CIO77YCS.js → GenerateCommand-5MXGDU5D.js} +3 -3
- package/build/GenerateCommand-5MXGDU5D.js.map +1 -0
- package/build/LogsCommand-GT4C6W63.js +4 -0
- package/build/LogsCommand-GT4C6W63.js.map +1 -0
- package/build/PreviewCommand-TYTUHLCK.js +4 -0
- package/build/{ServeCommand-AEELDVFH.js → ServeCommand-3XS2PRLZ.js} +2 -2
- package/build/ServeCommand-3XS2PRLZ.js.map +1 -0
- package/build/build-D3GVJS75.js +5 -0
- package/build/build-D3GVJS75.js.map +1 -0
- package/build/{build-JVHXDZDD.js → build-R2V6VPAY.js} +2 -2
- package/build/{build-JVHXDZDD.js.map → build-R2V6VPAY.js.map} +1 -1
- package/build/{chunk-MB65UVFQ.js → chunk-2JOP4YNL.js} +5 -5
- package/build/chunk-2JOP4YNL.js.map +1 -0
- package/build/chunk-3T3H3UJF.js +11 -0
- package/build/chunk-3T3H3UJF.js.map +1 -0
- package/build/chunk-5JYQ2Z7Y.js +116 -0
- package/build/chunk-5JYQ2Z7Y.js.map +1 -0
- package/build/chunk-5YLHD2SK.js +4 -0
- package/build/{chunk-F4LXYTO3.js → chunk-A3KHJIN7.js} +2 -2
- package/build/chunk-A7TURNR5.js +4 -0
- package/build/chunk-A7TURNR5.js.map +1 -0
- package/build/chunk-CBDNKNAV.js +4 -0
- package/build/chunk-CBDNKNAV.js.map +1 -0
- package/build/chunk-F6WBFD2I.js +11 -0
- package/build/chunk-F6WBFD2I.js.map +1 -0
- package/build/{chunk-QTYWYBN3.js → chunk-J2KSZ5LE.js} +2 -2
- package/build/{chunk-QTYWYBN3.js.map → chunk-J2KSZ5LE.js.map} +1 -1
- package/build/{chunk-MKVAJTCF.js → chunk-KRQ3H7GR.js} +2 -2
- package/build/{chunk-MKVAJTCF.js.map → chunk-KRQ3H7GR.js.map} +1 -1
- package/build/chunk-MI2F3EIB.js +4 -0
- package/build/chunk-MI2F3EIB.js.map +1 -0
- package/build/{chunk-MON4UIEH.js → chunk-NNF6JCN7.js} +2 -2
- package/build/chunk-NNF6JCN7.js.map +1 -0
- package/build/{chunk-HTY6QIPX.js → chunk-OWEB37KH.js} +2 -2
- package/build/{chunk-FBYP5GID.js → chunk-PWHZSGUV.js} +2 -2
- package/build/chunk-PWHZSGUV.js.map +1 -0
- package/build/{chunk-JKG4PFVP.js → chunk-QEH4HZND.js} +2 -2
- package/build/chunk-R4ZQYYZR.js +4 -0
- package/build/chunk-R4ZQYYZR.js.map +1 -0
- package/build/{chunk-ROZV4SHP.js → chunk-RXT5UM7Q.js} +54 -46
- package/build/chunk-RXT5UM7Q.js.map +1 -0
- package/build/{chunk-COIDN4V4.js → chunk-VRNTLFVH.js} +2 -2
- package/build/chunk-VRNTLFVH.js.map +1 -0
- package/build/{chunk-XUF2HJAT.js → chunk-YT6VEJPK.js} +2 -2
- package/build/chunk-YT6VEJPK.js.map +1 -0
- package/build/{chunk-2KPKOJPE.js → chunk-ZORLYW6M.js} +2 -2
- package/build/esm-HBMYQBEO.js +466 -0
- package/build/esm-HBMYQBEO.js.map +1 -0
- package/build/index.js +2 -2
- package/build/platform-sdk/chunk-RFBBAUMM.js +2 -0
- package/build/platform-sdk/chunk-RFBBAUMM.js.map +1 -0
- package/build/platform-sdk/dashboard.js +2 -0
- package/build/platform-sdk/dashboard.js.map +1 -0
- package/build/platform-sdk/esm-IUMNLA6B.js +2 -0
- package/build/platform-sdk/esm-IUMNLA6B.js.map +1 -0
- package/build/preview-5HAC2VHN.js +4 -0
- package/build/{preview-L5LDZK2L.js.map → preview-5HAC2VHN.js.map} +1 -1
- package/build/render-command-OPJNFJRC.js +4 -0
- package/build/{render-command-IA3LLA3F.js.map → render-command-OPJNFJRC.js.map} +1 -1
- package/internal/component-hmr-wrapper.tsx +4 -8
- package/package.json +10 -9
- package/schemas/custom-element.json +1 -1
- package/schemas/dashboard-menu-plugin.json +1 -1
- package/schemas/dashboard-modal.json +1 -1
- package/schemas/embedded-script.json +1 -1
- package/build/CreateVersionCommand-3ECZI65A.js +0 -4
- package/build/DevCommand-B7WYY2UQ.js +0 -4
- package/build/DevCommand-B7WYY2UQ.js.map +0 -1
- package/build/GenerateCommand-CIO77YCS.js.map +0 -1
- package/build/LogsCommand-VJ64MYDN.js +0 -4
- package/build/LogsCommand-VJ64MYDN.js.map +0 -1
- package/build/PreviewCommand-BZY2XOZN.js +0 -4
- package/build/ServeCommand-AEELDVFH.js.map +0 -1
- package/build/chunk-35SQ77PW.js +0 -4
- package/build/chunk-35SQ77PW.js.map +0 -1
- package/build/chunk-COIDN4V4.js.map +0 -1
- package/build/chunk-E6MYDYCH.js +0 -4
- package/build/chunk-E6MYDYCH.js.map +0 -1
- package/build/chunk-F4YTZ6XA.js +0 -116
- package/build/chunk-F4YTZ6XA.js.map +0 -1
- package/build/chunk-F55KYUXJ.js +0 -4
- package/build/chunk-F55KYUXJ.js.map +0 -1
- package/build/chunk-FBYP5GID.js.map +0 -1
- package/build/chunk-HTO6ALNX.js +0 -4
- package/build/chunk-HTO6ALNX.js.map +0 -1
- package/build/chunk-JAY5356K.js +0 -11
- package/build/chunk-JAY5356K.js.map +0 -1
- package/build/chunk-KQOYEWON.js +0 -11
- package/build/chunk-KQOYEWON.js.map +0 -1
- package/build/chunk-MB65UVFQ.js.map +0 -1
- package/build/chunk-MON4UIEH.js.map +0 -1
- package/build/chunk-ROZV4SHP.js.map +0 -1
- package/build/chunk-X62VPDUS.js +0 -4
- package/build/chunk-XUF2HJAT.js.map +0 -1
- package/build/esm-Z5T56VLV.js +0 -365
- package/build/esm-Z5T56VLV.js.map +0 -1
- package/build/preview-L5LDZK2L.js +0 -4
- package/build/render-command-IA3LLA3F.js +0 -4
- /package/build/{PreviewCommand-BZY2XOZN.js.map → PreviewCommand-TYTUHLCK.js.map} +0 -0
- /package/build/{chunk-X62VPDUS.js.map → chunk-5YLHD2SK.js.map} +0 -0
- /package/build/{chunk-F4LXYTO3.js.map → chunk-A3KHJIN7.js.map} +0 -0
- /package/build/{chunk-HTY6QIPX.js.map → chunk-OWEB37KH.js.map} +0 -0
- /package/build/{chunk-JKG4PFVP.js.map → chunk-QEH4HZND.js.map} +0 -0
- /package/build/{chunk-2KPKOJPE.js.map → chunk-ZORLYW6M.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../node_modules/jose/dist/node/esm/runtime/base64url.js","../../../../node_modules/jose/dist/node/esm/runtime/digest.js","../../../../node_modules/jose/dist/node/esm/lib/buffer_utils.js","../../../../node_modules/jose/dist/node/esm/runtime/decrypt.js","../../../../node_modules/jose/dist/node/esm/util/errors.js","../../../../node_modules/jose/dist/node/esm/runtime/random.js","../../../../node_modules/jose/dist/node/esm/lib/iv.js","../../../../node_modules/jose/dist/node/esm/lib/check_iv_length.js","../../../../node_modules/jose/dist/node/esm/runtime/is_key_object.js","../../../../node_modules/jose/dist/node/esm/runtime/check_cek_length.js","../../../../node_modules/jose/dist/node/esm/runtime/timing_safe_equal.js","../../../../node_modules/jose/dist/node/esm/runtime/cbc_tag.js","../../../../node_modules/jose/dist/node/esm/runtime/webcrypto.js","../../../../node_modules/jose/dist/node/esm/lib/crypto_key.js","../../../../node_modules/jose/dist/node/esm/lib/invalid_key_input.js","../../../../node_modules/jose/dist/node/esm/runtime/ciphers.js","../../../../node_modules/jose/dist/node/esm/runtime/is_key_like.js","../../../../node_modules/jose/dist/node/esm/lib/is_disjoint.js","../../../../node_modules/jose/dist/node/esm/lib/is_object.js","../../../../node_modules/jose/dist/node/esm/runtime/aeskw.js","../../../../node_modules/jose/dist/node/esm/runtime/ecdhes.js","../../../../node_modules/jose/dist/node/esm/runtime/get_named_curve.js","../../../../node_modules/jose/dist/node/esm/runtime/pbes2kw.js","../../../../node_modules/jose/dist/node/esm/lib/check_p2s.js","../../../../node_modules/jose/dist/node/esm/runtime/rsaes.js","../../../../node_modules/jose/dist/node/esm/runtime/check_key_length.js","../../../../node_modules/jose/dist/node/esm/lib/cek.js","../../../../node_modules/jose/dist/node/esm/runtime/asn1.js","../../../../node_modules/jose/dist/node/esm/runtime/jwk_to_key.js","../../../../node_modules/jose/dist/node/esm/key/import.js","../../../../node_modules/jose/dist/node/esm/lib/check_key_type.js","../../../../node_modules/jose/dist/node/esm/runtime/encrypt.js","../../../../node_modules/jose/dist/node/esm/lib/aesgcmkw.js","../../../../node_modules/jose/dist/node/esm/lib/decrypt_key_management.js","../../../../node_modules/jose/dist/node/esm/lib/validate_crit.js","../../../../node_modules/jose/dist/node/esm/lib/validate_algorithms.js","../../../../node_modules/jose/dist/node/esm/jwe/flattened/decrypt.js","../../../../node_modules/jose/dist/node/esm/jwe/compact/decrypt.js","../../../../node_modules/jose/dist/node/esm/jwe/general/decrypt.js","../../../../node_modules/jose/dist/node/esm/runtime/key_to_jwk.js","../../../../node_modules/jose/dist/node/esm/key/export.js","../../../../node_modules/jose/dist/node/esm/lib/encrypt_key_management.js","../../../../node_modules/jose/dist/node/esm/jwe/flattened/encrypt.js","../../../../node_modules/jose/dist/node/esm/jwe/general/encrypt.js","../../../../node_modules/jose/dist/node/esm/runtime/verify.js","../../../../node_modules/jose/dist/node/esm/runtime/dsa_digest.js","../../../../node_modules/jose/dist/node/esm/runtime/node_key.js","../../../../node_modules/jose/dist/node/esm/runtime/sign.js","../../../../node_modules/jose/dist/node/esm/runtime/hmac_digest.js","../../../../node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js","../../../../node_modules/jose/dist/node/esm/jws/flattened/verify.js","../../../../node_modules/jose/dist/node/esm/jws/compact/verify.js","../../../../node_modules/jose/dist/node/esm/jws/general/verify.js","../../../../node_modules/jose/dist/node/esm/lib/epoch.js","../../../../node_modules/jose/dist/node/esm/lib/secs.js","../../../../node_modules/jose/dist/node/esm/lib/jwt_claims_set.js","../../../../node_modules/jose/dist/node/esm/jwt/verify.js","../../../../node_modules/jose/dist/node/esm/jwt/decrypt.js","../../../../node_modules/jose/dist/node/esm/jwe/compact/encrypt.js","../../../../node_modules/jose/dist/node/esm/jws/flattened/sign.js","../../../../node_modules/jose/dist/node/esm/jws/compact/sign.js","../../../../node_modules/jose/dist/node/esm/jws/general/sign.js","../../../../node_modules/jose/dist/node/esm/jwt/produce.js","../../../../node_modules/jose/dist/node/esm/jwt/sign.js","../../../../node_modules/jose/dist/node/esm/jwt/encrypt.js","../../../../node_modules/jose/dist/node/esm/jwk/thumbprint.js","../../../../node_modules/jose/dist/node/esm/jwk/embedded.js","../../../../node_modules/jose/dist/node/esm/jwks/local.js","../../../../node_modules/jose/dist/node/esm/runtime/fetch_jwks.js","../../../../node_modules/jose/dist/node/esm/jwks/remote.js","../../../../node_modules/jose/dist/node/esm/jwt/unsecured.js","../../../../node_modules/jose/dist/node/esm/util/base64url.js","../../../../node_modules/jose/dist/node/esm/util/decode_protected_header.js","../../../../node_modules/jose/dist/node/esm/util/decode_jwt.js","../../../../node_modules/jose/dist/node/esm/runtime/generate.js","../../../../node_modules/jose/dist/node/esm/key/generate_key_pair.js","../../../../node_modules/jose/dist/node/esm/key/generate_secret.js","../../../../node_modules/jose/dist/node/esm/runtime/runtime.js","../../../../node_modules/jose/dist/node/esm/util/runtime.js"],"sourcesContent":["import { Buffer } from 'node:buffer';\nimport { decoder } from '../lib/buffer_utils.js';\nfunction normalize(input) {\n let encoded = input;\n if (encoded instanceof Uint8Array) {\n encoded = decoder.decode(encoded);\n }\n return encoded;\n}\nconst encode = (input) => Buffer.from(input).toString('base64url');\nexport const decodeBase64 = (input) => new Uint8Array(Buffer.from(input, 'base64'));\nexport const encodeBase64 = (input) => Buffer.from(input).toString('base64');\nexport { encode };\nexport const decode = (input) => new Uint8Array(Buffer.from(normalize(input), 'base64'));\n","import { createHash } from 'node:crypto';\nconst digest = (algorithm, data) => createHash(algorithm).update(data).digest();\nexport default digest;\n","import digest from '../runtime/digest.js';\nexport 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}\nexport function p2s(alg, p2sInput) {\n return concat(encoder.encode(alg), new Uint8Array([0]), p2sInput);\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 lengthAndInput(input) {\n return concat(uint32be(input.length), input);\n}\nexport async function concatKdf(secret, bits, value) {\n const iterations = Math.ceil((bits >> 3) / 32);\n const res = new Uint8Array(iterations * 32);\n for (let iter = 0; iter < iterations; iter++) {\n const buf = new Uint8Array(4 + secret.length + value.length);\n buf.set(uint32be(iter + 1));\n buf.set(secret, 4);\n buf.set(value, 4 + secret.length);\n res.set(await digest('sha256', buf), iter * 32);\n }\n return res.slice(0, bits >> 3);\n}\n","import { createDecipheriv, KeyObject } from 'node:crypto';\nimport checkIvLength from '../lib/check_iv_length.js';\nimport checkCekLength from './check_cek_length.js';\nimport { concat } from '../lib/buffer_utils.js';\nimport { JOSENotSupported, JWEDecryptionFailed, JWEInvalid } from '../util/errors.js';\nimport timingSafeEqual from './timing_safe_equal.js';\nimport cbcTag from './cbc_tag.js';\nimport { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport isKeyObject from './is_key_object.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport supported from './ciphers.js';\nimport { types } from './is_key_like.js';\nfunction cbcDecrypt(enc, cek, ciphertext, iv, tag, aad) {\n const keySize = parseInt(enc.slice(1, 4), 10);\n if (isKeyObject(cek)) {\n cek = cek.export();\n }\n const encKey = cek.subarray(keySize >> 3);\n const macKey = cek.subarray(0, keySize >> 3);\n const macSize = parseInt(enc.slice(-3), 10);\n const algorithm = `aes-${keySize}-cbc`;\n if (!supported(algorithm)) {\n throw new JOSENotSupported(`alg ${enc} is not supported by your javascript runtime`);\n }\n const expectedTag = cbcTag(aad, iv, ciphertext, macSize, macKey, keySize);\n let macCheckPassed;\n try {\n macCheckPassed = timingSafeEqual(tag, expectedTag);\n }\n catch {\n }\n if (!macCheckPassed) {\n throw new JWEDecryptionFailed();\n }\n let plaintext;\n try {\n const decipher = createDecipheriv(algorithm, encKey, iv);\n plaintext = concat(decipher.update(ciphertext), decipher.final());\n }\n catch {\n }\n if (!plaintext) {\n throw new JWEDecryptionFailed();\n }\n return plaintext;\n}\nfunction gcmDecrypt(enc, cek, ciphertext, iv, tag, aad) {\n const keySize = parseInt(enc.slice(1, 4), 10);\n const algorithm = `aes-${keySize}-gcm`;\n if (!supported(algorithm)) {\n throw new JOSENotSupported(`alg ${enc} is not supported by your javascript runtime`);\n }\n try {\n const decipher = createDecipheriv(algorithm, cek, iv, { authTagLength: 16 });\n decipher.setAuthTag(tag);\n if (aad.byteLength) {\n decipher.setAAD(aad, { plaintextLength: ciphertext.length });\n }\n const plaintext = decipher.update(ciphertext);\n decipher.final();\n return plaintext;\n }\n catch {\n throw new JWEDecryptionFailed();\n }\n}\nconst decrypt = (enc, cek, ciphertext, iv, tag, aad) => {\n let key;\n if (isCryptoKey(cek)) {\n checkEncCryptoKey(cek, enc, 'decrypt');\n key = KeyObject.from(cek);\n }\n else if (cek instanceof Uint8Array || isKeyObject(cek)) {\n key = cek;\n }\n else {\n throw new TypeError(invalidKeyInput(cek, ...types, 'Uint8Array'));\n }\n if (!iv) {\n throw new JWEInvalid('JWE Initialization Vector missing');\n }\n if (!tag) {\n throw new JWEInvalid('JWE Authentication Tag missing');\n }\n checkCekLength(enc, key);\n checkIvLength(enc, iv);\n switch (enc) {\n case 'A128CBC-HS256':\n case 'A192CBC-HS384':\n case 'A256CBC-HS512':\n return cbcDecrypt(enc, key, ciphertext, iv, tag, aad);\n case 'A128GCM':\n case 'A192GCM':\n case 'A256GCM':\n return gcmDecrypt(enc, key, ciphertext, iv, tag, aad);\n default:\n throw new JOSENotSupported('Unsupported JWE Content Encryption Algorithm');\n }\n};\nexport default decrypt;\n","export class JOSEError extends Error {\n static get code() {\n return 'ERR_JOSE_GENERIC';\n }\n code = 'ERR_JOSE_GENERIC';\n constructor(message) {\n super(message);\n this.name = this.constructor.name;\n Error.captureStackTrace?.(this, this.constructor);\n }\n}\nexport class JWTClaimValidationFailed extends JOSEError {\n static get code() {\n return 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n }\n code = 'ERR_JWT_CLAIM_VALIDATION_FAILED';\n claim;\n reason;\n constructor(message, claim = 'unspecified', reason = 'unspecified') {\n super(message);\n this.claim = claim;\n this.reason = reason;\n }\n}\nexport class JWTExpired extends JOSEError {\n static get code() {\n return 'ERR_JWT_EXPIRED';\n }\n code = 'ERR_JWT_EXPIRED';\n claim;\n reason;\n constructor(message, claim = 'unspecified', reason = 'unspecified') {\n super(message);\n this.claim = claim;\n this.reason = reason;\n }\n}\nexport class JOSEAlgNotAllowed extends JOSEError {\n static get code() {\n return 'ERR_JOSE_ALG_NOT_ALLOWED';\n }\n code = 'ERR_JOSE_ALG_NOT_ALLOWED';\n}\nexport class JOSENotSupported extends JOSEError {\n static get code() {\n return 'ERR_JOSE_NOT_SUPPORTED';\n }\n code = 'ERR_JOSE_NOT_SUPPORTED';\n}\nexport class JWEDecryptionFailed extends JOSEError {\n static get code() {\n return 'ERR_JWE_DECRYPTION_FAILED';\n }\n code = 'ERR_JWE_DECRYPTION_FAILED';\n message = 'decryption operation failed';\n}\nexport class JWEInvalid extends JOSEError {\n static get code() {\n return 'ERR_JWE_INVALID';\n }\n code = 'ERR_JWE_INVALID';\n}\nexport class JWSInvalid extends JOSEError {\n static get code() {\n return 'ERR_JWS_INVALID';\n }\n code = 'ERR_JWS_INVALID';\n}\nexport class JWTInvalid extends JOSEError {\n static get code() {\n return 'ERR_JWT_INVALID';\n }\n code = 'ERR_JWT_INVALID';\n}\nexport class JWKInvalid extends JOSEError {\n static get code() {\n return 'ERR_JWK_INVALID';\n }\n code = 'ERR_JWK_INVALID';\n}\nexport class JWKSInvalid extends JOSEError {\n static get code() {\n return 'ERR_JWKS_INVALID';\n }\n code = 'ERR_JWKS_INVALID';\n}\nexport class JWKSNoMatchingKey extends JOSEError {\n static get code() {\n return 'ERR_JWKS_NO_MATCHING_KEY';\n }\n code = 'ERR_JWKS_NO_MATCHING_KEY';\n message = 'no applicable key found in the JSON Web Key Set';\n}\nexport class JWKSMultipleMatchingKeys extends JOSEError {\n [Symbol.asyncIterator];\n static get code() {\n return 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n }\n code = 'ERR_JWKS_MULTIPLE_MATCHING_KEYS';\n message = 'multiple matching keys found in the JSON Web Key Set';\n}\nexport class JWKSTimeout extends JOSEError {\n static get code() {\n return 'ERR_JWKS_TIMEOUT';\n }\n code = 'ERR_JWKS_TIMEOUT';\n message = 'request timed out';\n}\nexport class JWSSignatureVerificationFailed extends JOSEError {\n static get code() {\n return 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n }\n code = 'ERR_JWS_SIGNATURE_VERIFICATION_FAILED';\n message = 'signature verification failed';\n}\n","export { randomFillSync as default } from 'node:crypto';\n","import { JOSENotSupported } from '../util/errors.js';\nimport random from '../runtime/random.js';\nexport function bitLength(alg) {\n switch (alg) {\n case 'A128GCM':\n case 'A128GCMKW':\n case 'A192GCM':\n case 'A192GCMKW':\n case 'A256GCM':\n case 'A256GCMKW':\n return 96;\n case 'A128CBC-HS256':\n case 'A192CBC-HS384':\n case 'A256CBC-HS512':\n return 128;\n default:\n throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);\n }\n}\nexport default (alg) => random(new Uint8Array(bitLength(alg) >> 3));\n","import { JWEInvalid } from '../util/errors.js';\nimport { bitLength } from './iv.js';\nconst checkIvLength = (enc, iv) => {\n if (iv.length << 3 !== bitLength(enc)) {\n throw new JWEInvalid('Invalid Initialization Vector length');\n }\n};\nexport default checkIvLength;\n","import * as util from 'node:util';\nexport default (obj) => util.types.isKeyObject(obj);\n","import { JWEInvalid, JOSENotSupported } from '../util/errors.js';\nimport isKeyObject from './is_key_object.js';\nconst checkCekLength = (enc, cek) => {\n let expected;\n switch (enc) {\n case 'A128CBC-HS256':\n case 'A192CBC-HS384':\n case 'A256CBC-HS512':\n expected = parseInt(enc.slice(-3), 10);\n break;\n case 'A128GCM':\n case 'A192GCM':\n case 'A256GCM':\n expected = parseInt(enc.slice(1, 4), 10);\n break;\n default:\n throw new JOSENotSupported(`Content Encryption Algorithm ${enc} is not supported either by JOSE or your javascript runtime`);\n }\n if (cek instanceof Uint8Array) {\n const actual = cek.byteLength << 3;\n if (actual !== expected) {\n throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);\n }\n return;\n }\n if (isKeyObject(cek) && cek.type === 'secret') {\n const actual = cek.symmetricKeySize << 3;\n if (actual !== expected) {\n throw new JWEInvalid(`Invalid Content Encryption Key length. Expected ${expected} bits, got ${actual} bits`);\n }\n return;\n }\n throw new TypeError('Invalid Content Encryption Key type');\n};\nexport default checkCekLength;\n","import { timingSafeEqual as impl } from 'node:crypto';\nconst timingSafeEqual = impl;\nexport default timingSafeEqual;\n","import { createHmac } from 'node:crypto';\nimport { concat, uint64be } from '../lib/buffer_utils.js';\nexport default function cbcTag(aad, iv, ciphertext, macSize, macKey, keySize) {\n const macData = concat(aad, iv, ciphertext, uint64be(aad.length << 3));\n const hmac = createHmac(`sha${macSize}`, macKey);\n hmac.update(macData);\n return hmac.digest().slice(0, keySize >> 3);\n}\n","import * as crypto from 'node:crypto';\nimport * as util from 'node:util';\nconst webcrypto = crypto.webcrypto;\nexport default webcrypto;\nexport const isCryptoKey = (key) => util.types.isCryptoKey(key);\n","function unusable(name, prop = 'algorithm.name') {\n return new TypeError(`CryptoKey does not support this operation, its ${prop} must be ${name}`);\n}\nfunction isAlgorithm(algorithm, name) {\n return algorithm.name === name;\n}\nfunction getHashLength(hash) {\n return parseInt(hash.name.slice(4), 10);\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, usages) {\n if (usages.length && !usages.some((expected) => key.usages.includes(expected))) {\n let msg = 'CryptoKey does not support this operation, its usages must include ';\n if (usages.length > 2) {\n const last = usages.pop();\n msg += `one of ${usages.join(', ')}, or ${last}.`;\n }\n else if (usages.length === 2) {\n msg += `one of ${usages[0]} or ${usages[1]}.`;\n }\n else {\n msg += `${usages[0]}.`;\n }\n throw new TypeError(msg);\n }\n}\nexport function checkSigCryptoKey(key, alg, ...usages) {\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512': {\n if (!isAlgorithm(key.algorithm, 'HMAC'))\n throw unusable('HMAC');\n const expected = parseInt(alg.slice(2), 10);\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\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 const expected = parseInt(alg.slice(2), 10);\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\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 const expected = parseInt(alg.slice(2), 10);\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n case 'EdDSA': {\n if (key.algorithm.name !== 'Ed25519' && key.algorithm.name !== 'Ed448') {\n throw unusable('Ed25519 or Ed448');\n }\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, usages);\n}\nexport function checkEncCryptoKey(key, alg, ...usages) {\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 case 'X448':\n break;\n default:\n throw unusable('ECDH, X25519, or X448');\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 const expected = parseInt(alg.slice(9), 10) || 1;\n const actual = getHashLength(key.algorithm.hash);\n if (actual !== expected)\n throw unusable(`SHA-${expected}`, 'algorithm.hash');\n break;\n }\n default:\n throw new TypeError('CryptoKey does not support this operation');\n }\n checkUsage(key, usages);\n}\n","function message(msg, actual, ...types) {\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 default (actual, ...types) => {\n return message('Key must be ', actual, ...types);\n};\nexport function withAlg(alg, actual, ...types) {\n return message(`Key for the ${alg} algorithm must be `, actual, ...types);\n}\n","import { getCiphers } from 'node:crypto';\nlet ciphers;\nexport default (algorithm) => {\n ciphers ||= new Set(getCiphers());\n return ciphers.has(algorithm);\n};\n","import webcrypto, { isCryptoKey } from './webcrypto.js';\nimport isKeyObject from './is_key_object.js';\nexport default (key) => isKeyObject(key) || isCryptoKey(key);\nconst types = ['KeyObject'];\nif (globalThis.CryptoKey || webcrypto?.CryptoKey) {\n types.push('CryptoKey');\n}\nexport { types };\n","const 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 default isDisjoint;\n","function isObjectLike(value) {\n return typeof value === 'object' && value !== null;\n}\nexport default 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}\n","import { Buffer } from 'node:buffer';\nimport { KeyObject, createDecipheriv, createCipheriv, createSecretKey } from 'node:crypto';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { concat } from '../lib/buffer_utils.js';\nimport { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport isKeyObject from './is_key_object.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport supported from './ciphers.js';\nimport { types } from './is_key_like.js';\nfunction checkKeySize(key, alg) {\n if (key.symmetricKeySize << 3 !== parseInt(alg.slice(1, 4), 10)) {\n throw new TypeError(`Invalid key size for alg: ${alg}`);\n }\n}\nfunction ensureKeyObject(key, alg, usage) {\n if (isKeyObject(key)) {\n return key;\n }\n if (key instanceof Uint8Array) {\n return createSecretKey(key);\n }\n if (isCryptoKey(key)) {\n checkEncCryptoKey(key, alg, usage);\n return KeyObject.from(key);\n }\n throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));\n}\nexport const wrap = (alg, key, cek) => {\n const size = parseInt(alg.slice(1, 4), 10);\n const algorithm = `aes${size}-wrap`;\n if (!supported(algorithm)) {\n throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n }\n const keyObject = ensureKeyObject(key, alg, 'wrapKey');\n checkKeySize(keyObject, alg);\n const cipher = createCipheriv(algorithm, keyObject, Buffer.alloc(8, 0xa6));\n return concat(cipher.update(cek), cipher.final());\n};\nexport const unwrap = (alg, key, encryptedKey) => {\n const size = parseInt(alg.slice(1, 4), 10);\n const algorithm = `aes${size}-wrap`;\n if (!supported(algorithm)) {\n throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n }\n const keyObject = ensureKeyObject(key, alg, 'unwrapKey');\n checkKeySize(keyObject, alg);\n const cipher = createDecipheriv(algorithm, keyObject, Buffer.alloc(8, 0xa6));\n return concat(cipher.update(encryptedKey), cipher.final());\n};\n","import { diffieHellman, generateKeyPair as generateKeyPairCb, KeyObject } from 'node:crypto';\nimport { promisify } from 'node:util';\nimport getNamedCurve from './get_named_curve.js';\nimport { encoder, concat, uint32be, lengthAndInput, concatKdf } from '../lib/buffer_utils.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport isKeyObject from './is_key_object.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nconst generateKeyPair = promisify(generateKeyPairCb);\nexport async function deriveKey(publicKee, privateKee, algorithm, keyLength, apu = new Uint8Array(0), apv = new Uint8Array(0)) {\n let publicKey;\n if (isCryptoKey(publicKee)) {\n checkEncCryptoKey(publicKee, 'ECDH');\n publicKey = KeyObject.from(publicKee);\n }\n else if (isKeyObject(publicKee)) {\n publicKey = publicKee;\n }\n else {\n throw new TypeError(invalidKeyInput(publicKee, ...types));\n }\n let privateKey;\n if (isCryptoKey(privateKee)) {\n checkEncCryptoKey(privateKee, 'ECDH', 'deriveBits');\n privateKey = KeyObject.from(privateKee);\n }\n else if (isKeyObject(privateKee)) {\n privateKey = privateKee;\n }\n else {\n throw new TypeError(invalidKeyInput(privateKee, ...types));\n }\n const value = concat(lengthAndInput(encoder.encode(algorithm)), lengthAndInput(apu), lengthAndInput(apv), uint32be(keyLength));\n const sharedSecret = diffieHellman({ privateKey, publicKey });\n return concatKdf(sharedSecret, keyLength, value);\n}\nexport async function generateEpk(kee) {\n let key;\n if (isCryptoKey(kee)) {\n key = KeyObject.from(kee);\n }\n else if (isKeyObject(kee)) {\n key = kee;\n }\n else {\n throw new TypeError(invalidKeyInput(kee, ...types));\n }\n switch (key.asymmetricKeyType) {\n case 'x25519':\n return generateKeyPair('x25519');\n case 'x448': {\n return generateKeyPair('x448');\n }\n case 'ec': {\n const namedCurve = getNamedCurve(key);\n return generateKeyPair('ec', { namedCurve });\n }\n default:\n throw new JOSENotSupported('Invalid or unsupported EPK');\n }\n}\nexport const ecdhAllowed = (key) => ['P-256', 'P-384', 'P-521', 'X25519', 'X448'].includes(getNamedCurve(key));\n","import { KeyObject } from 'node:crypto';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { isCryptoKey } from './webcrypto.js';\nimport isKeyObject from './is_key_object.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nexport const weakMap = new WeakMap();\nconst namedCurveToJOSE = (namedCurve) => {\n switch (namedCurve) {\n case 'prime256v1':\n return 'P-256';\n case 'secp384r1':\n return 'P-384';\n case 'secp521r1':\n return 'P-521';\n case 'secp256k1':\n return 'secp256k1';\n default:\n throw new JOSENotSupported('Unsupported key curve for this operation');\n }\n};\nconst getNamedCurve = (kee, raw) => {\n let key;\n if (isCryptoKey(kee)) {\n key = KeyObject.from(kee);\n }\n else if (isKeyObject(kee)) {\n key = kee;\n }\n else {\n throw new TypeError(invalidKeyInput(kee, ...types));\n }\n if (key.type === 'secret') {\n throw new TypeError('only \"private\" or \"public\" type keys can be used for this operation');\n }\n switch (key.asymmetricKeyType) {\n case 'ed25519':\n case 'ed448':\n return `Ed${key.asymmetricKeyType.slice(2)}`;\n case 'x25519':\n case 'x448':\n return `X${key.asymmetricKeyType.slice(1)}`;\n case 'ec': {\n const namedCurve = key.asymmetricKeyDetails.namedCurve;\n if (raw) {\n return namedCurve;\n }\n return namedCurveToJOSE(namedCurve);\n }\n default:\n throw new TypeError('Invalid asymmetric key type for this operation');\n }\n};\nexport default getNamedCurve;\n","import { promisify } from 'node:util';\nimport { KeyObject, pbkdf2 as pbkdf2cb } from 'node:crypto';\nimport random from './random.js';\nimport { p2s as concatSalt } from '../lib/buffer_utils.js';\nimport { encode as base64url } from './base64url.js';\nimport { wrap, unwrap } from './aeskw.js';\nimport checkP2s from '../lib/check_p2s.js';\nimport { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport isKeyObject from './is_key_object.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nconst pbkdf2 = promisify(pbkdf2cb);\nfunction getPassword(key, alg) {\n if (isKeyObject(key)) {\n return key.export();\n }\n if (key instanceof Uint8Array) {\n return key;\n }\n if (isCryptoKey(key)) {\n checkEncCryptoKey(key, alg, 'deriveBits', 'deriveKey');\n return KeyObject.from(key).export();\n }\n throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));\n}\nexport const encrypt = async (alg, key, cek, p2c = 2048, p2s = random(new Uint8Array(16))) => {\n checkP2s(p2s);\n const salt = concatSalt(alg, p2s);\n const keylen = parseInt(alg.slice(13, 16), 10) >> 3;\n const password = getPassword(key, alg);\n const derivedKey = await pbkdf2(password, salt, p2c, keylen, `sha${alg.slice(8, 11)}`);\n const encryptedKey = await wrap(alg.slice(-6), derivedKey, cek);\n return { encryptedKey, p2c, p2s: base64url(p2s) };\n};\nexport const decrypt = async (alg, key, encryptedKey, p2c, p2s) => {\n checkP2s(p2s);\n const salt = concatSalt(alg, p2s);\n const keylen = parseInt(alg.slice(13, 16), 10) >> 3;\n const password = getPassword(key, alg);\n const derivedKey = await pbkdf2(password, salt, p2c, keylen, `sha${alg.slice(8, 11)}`);\n return unwrap(alg.slice(-6), derivedKey, encryptedKey);\n};\n","import { JWEInvalid } from '../util/errors.js';\nexport default function checkP2s(p2s) {\n if (!(p2s instanceof Uint8Array) || p2s.length < 8) {\n throw new JWEInvalid('PBES2 Salt Input must be 8 or more octets');\n }\n}\n","import { KeyObject, publicEncrypt, constants, privateDecrypt } from 'node:crypto';\nimport { deprecate } from 'node:util';\nimport checkKeyLength from './check_key_length.js';\nimport { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport isKeyObject from './is_key_object.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nconst checkKey = (key, alg) => {\n if (key.asymmetricKeyType !== 'rsa') {\n throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be rsa');\n }\n checkKeyLength(key, alg);\n};\nconst RSA1_5 = deprecate(() => constants.RSA_PKCS1_PADDING, 'The RSA1_5 \"alg\" (JWE Algorithm) is deprecated and will be removed in the next major revision.');\nconst resolvePadding = (alg) => {\n switch (alg) {\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512':\n return constants.RSA_PKCS1_OAEP_PADDING;\n case 'RSA1_5':\n return RSA1_5();\n default:\n return undefined;\n }\n};\nconst resolveOaepHash = (alg) => {\n switch (alg) {\n case 'RSA-OAEP':\n return 'sha1';\n case 'RSA-OAEP-256':\n return 'sha256';\n case 'RSA-OAEP-384':\n return 'sha384';\n case 'RSA-OAEP-512':\n return 'sha512';\n default:\n return undefined;\n }\n};\nfunction ensureKeyObject(key, alg, ...usages) {\n if (isKeyObject(key)) {\n return key;\n }\n if (isCryptoKey(key)) {\n checkEncCryptoKey(key, alg, ...usages);\n return KeyObject.from(key);\n }\n throw new TypeError(invalidKeyInput(key, ...types));\n}\nexport const encrypt = (alg, key, cek) => {\n const padding = resolvePadding(alg);\n const oaepHash = resolveOaepHash(alg);\n const keyObject = ensureKeyObject(key, alg, 'wrapKey', 'encrypt');\n checkKey(keyObject, alg);\n return publicEncrypt({ key: keyObject, oaepHash, padding }, cek);\n};\nexport const decrypt = (alg, key, encryptedKey) => {\n const padding = resolvePadding(alg);\n const oaepHash = resolveOaepHash(alg);\n const keyObject = ensureKeyObject(key, alg, 'unwrapKey', 'decrypt');\n checkKey(keyObject, alg);\n return privateDecrypt({ key: keyObject, oaepHash, padding }, encryptedKey);\n};\n","export default (key, alg) => {\n const { modulusLength } = key.asymmetricKeyDetails;\n if (typeof modulusLength !== 'number' || modulusLength < 2048) {\n throw new TypeError(`${alg} requires key modulusLength to be 2048 bits or larger`);\n }\n};\n","import { JOSENotSupported } from '../util/errors.js';\nimport random from '../runtime/random.js';\nexport function bitLength(alg) {\n switch (alg) {\n case 'A128GCM':\n return 128;\n case 'A192GCM':\n return 192;\n case 'A256GCM':\n case 'A128CBC-HS256':\n return 256;\n case 'A192CBC-HS384':\n return 384;\n case 'A256CBC-HS512':\n return 512;\n default:\n throw new JOSENotSupported(`Unsupported JWE Algorithm: ${alg}`);\n }\n}\nexport default (alg) => random(new Uint8Array(bitLength(alg) >> 3));\n","import { createPrivateKey, createPublicKey, KeyObject } from 'node:crypto';\nimport { Buffer } from 'node:buffer';\nimport { isCryptoKey } from './webcrypto.js';\nimport isKeyObject from './is_key_object.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nconst genericExport = (keyType, keyFormat, key) => {\n let keyObject;\n if (isCryptoKey(key)) {\n if (!key.extractable) {\n throw new TypeError('CryptoKey is not extractable');\n }\n keyObject = KeyObject.from(key);\n }\n else if (isKeyObject(key)) {\n keyObject = key;\n }\n else {\n throw new TypeError(invalidKeyInput(key, ...types));\n }\n if (keyObject.type !== keyType) {\n throw new TypeError(`key is not a ${keyType} key`);\n }\n return keyObject.export({ format: 'pem', type: keyFormat });\n};\nexport const toSPKI = (key) => {\n return genericExport('public', 'spki', key);\n};\nexport const toPKCS8 = (key) => {\n return genericExport('private', 'pkcs8', key);\n};\nexport const fromPKCS8 = (pem) => createPrivateKey({\n key: Buffer.from(pem.replace(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\\s)/g, ''), 'base64'),\n type: 'pkcs8',\n format: 'der',\n});\nexport const fromSPKI = (pem) => createPublicKey({\n key: Buffer.from(pem.replace(/(?:-----(?:BEGIN|END) PUBLIC KEY-----|\\s)/g, ''), 'base64'),\n type: 'spki',\n format: 'der',\n});\nexport const fromX509 = (pem) => createPublicKey({\n key: pem,\n type: 'spki',\n format: 'pem',\n});\n","import { createPrivateKey, createPublicKey } from 'node:crypto';\nconst parse = (jwk) => {\n return (jwk.d ? createPrivateKey : createPublicKey)({ format: 'jwk', key: jwk });\n};\nexport default parse;\n","import { decode as decodeBase64URL } from '../runtime/base64url.js';\nimport { fromSPKI, fromPKCS8, fromX509 } from '../runtime/asn1.js';\nimport asKeyObject from '../runtime/jwk_to_key.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport isObject from '../lib/is_object.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) {\n if (!isObject(jwk)) {\n throw new TypeError('JWK must be an object');\n }\n alg ||= jwk.alg;\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 (jwk.oth !== undefined) {\n throw new JOSENotSupported('RSA JWK \"oth\" (Other Primes Info) Parameter value is not supported');\n }\n case 'EC':\n case 'OKP':\n return asKeyObject({ ...jwk, alg });\n default:\n throw new JOSENotSupported('Unsupported \"kty\" (Key Type) Parameter value');\n }\n}\n","import { withAlg as invalidKeyInput } from './invalid_key_input.js';\nimport isKeyLike, { types } from '../runtime/is_key_like.js';\nconst symmetricTypeCheck = (alg, key) => {\n if (key instanceof Uint8Array)\n return;\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, ...types, 'Uint8Array'));\n }\n if (key.type !== 'secret') {\n throw new TypeError(`${types.join(' or ')} instances for symmetric algorithms must be of type \"secret\"`);\n }\n};\nconst asymmetricTypeCheck = (alg, key, usage) => {\n if (!isKeyLike(key)) {\n throw new TypeError(invalidKeyInput(alg, key, ...types));\n }\n if (key.type === 'secret') {\n throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithms must not be of type \"secret\"`);\n }\n if (usage === 'sign' && key.type === 'public') {\n throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm signing must be of type \"private\"`);\n }\n if (usage === 'decrypt' && key.type === 'public') {\n throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm decryption must be of type \"private\"`);\n }\n if (key.algorithm && usage === 'verify' && key.type === 'private') {\n throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm verifying must be of type \"public\"`);\n }\n if (key.algorithm && usage === 'encrypt' && key.type === 'private') {\n throw new TypeError(`${types.join(' or ')} instances for asymmetric algorithm encryption must be of type \"public\"`);\n }\n};\nconst checkKeyType = (alg, key, usage) => {\n const symmetric = alg.startsWith('HS') ||\n alg === 'dir' ||\n alg.startsWith('PBES2') ||\n /^A\\d{3}(?:GCM)?KW$/.test(alg);\n if (symmetric) {\n symmetricTypeCheck(alg, key);\n }\n else {\n asymmetricTypeCheck(alg, key, usage);\n }\n};\nexport default checkKeyType;\n","import { createCipheriv, KeyObject } from 'node:crypto';\nimport checkIvLength from '../lib/check_iv_length.js';\nimport checkCekLength from './check_cek_length.js';\nimport { concat } from '../lib/buffer_utils.js';\nimport cbcTag from './cbc_tag.js';\nimport { isCryptoKey } from './webcrypto.js';\nimport { checkEncCryptoKey } from '../lib/crypto_key.js';\nimport isKeyObject from './is_key_object.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport generateIv from '../lib/iv.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport supported from './ciphers.js';\nimport { types } from './is_key_like.js';\nfunction cbcEncrypt(enc, plaintext, cek, iv, aad) {\n const keySize = parseInt(enc.slice(1, 4), 10);\n if (isKeyObject(cek)) {\n cek = cek.export();\n }\n const encKey = cek.subarray(keySize >> 3);\n const macKey = cek.subarray(0, keySize >> 3);\n const algorithm = `aes-${keySize}-cbc`;\n if (!supported(algorithm)) {\n throw new JOSENotSupported(`alg ${enc} is not supported by your javascript runtime`);\n }\n const cipher = createCipheriv(algorithm, encKey, iv);\n const ciphertext = concat(cipher.update(plaintext), cipher.final());\n const macSize = parseInt(enc.slice(-3), 10);\n const tag = cbcTag(aad, iv, ciphertext, macSize, macKey, keySize);\n return { ciphertext, tag, iv };\n}\nfunction gcmEncrypt(enc, plaintext, cek, iv, aad) {\n const keySize = parseInt(enc.slice(1, 4), 10);\n const algorithm = `aes-${keySize}-gcm`;\n if (!supported(algorithm)) {\n throw new JOSENotSupported(`alg ${enc} is not supported by your javascript runtime`);\n }\n const cipher = createCipheriv(algorithm, cek, iv, { authTagLength: 16 });\n if (aad.byteLength) {\n cipher.setAAD(aad, { plaintextLength: plaintext.length });\n }\n const ciphertext = cipher.update(plaintext);\n cipher.final();\n const tag = cipher.getAuthTag();\n return { ciphertext, tag, iv };\n}\nconst encrypt = (enc, plaintext, cek, iv, aad) => {\n let key;\n if (isCryptoKey(cek)) {\n checkEncCryptoKey(cek, enc, 'encrypt');\n key = KeyObject.from(cek);\n }\n else if (cek instanceof Uint8Array || isKeyObject(cek)) {\n key = cek;\n }\n else {\n throw new TypeError(invalidKeyInput(cek, ...types, 'Uint8Array'));\n }\n checkCekLength(enc, key);\n if (iv) {\n checkIvLength(enc, iv);\n }\n else {\n iv = generateIv(enc);\n }\n switch (enc) {\n case 'A128CBC-HS256':\n case 'A192CBC-HS384':\n case 'A256CBC-HS512':\n return cbcEncrypt(enc, plaintext, key, iv, aad);\n case 'A128GCM':\n case 'A192GCM':\n case 'A256GCM':\n return gcmEncrypt(enc, plaintext, key, iv, aad);\n default:\n throw new JOSENotSupported('Unsupported JWE Content Encryption Algorithm');\n }\n};\nexport default encrypt;\n","import encrypt from '../runtime/encrypt.js';\nimport decrypt from '../runtime/decrypt.js';\nimport { encode as base64url } from '../runtime/base64url.js';\nexport async function wrap(alg, key, cek, iv) {\n const jweAlgorithm = alg.slice(0, 7);\n const wrapped = await encrypt(jweAlgorithm, cek, key, iv, new Uint8Array(0));\n return {\n encryptedKey: wrapped.ciphertext,\n iv: base64url(wrapped.iv),\n tag: base64url(wrapped.tag),\n };\n}\nexport async function unwrap(alg, key, encryptedKey, iv, tag) {\n const jweAlgorithm = alg.slice(0, 7);\n return decrypt(jweAlgorithm, key, encryptedKey, iv, tag, new Uint8Array(0));\n}\n","import { unwrap as aesKw } from '../runtime/aeskw.js';\nimport * as ECDH from '../runtime/ecdhes.js';\nimport { decrypt as pbes2Kw } from '../runtime/pbes2kw.js';\nimport { decrypt as rsaEs } from '../runtime/rsaes.js';\nimport { decode as base64url } from '../runtime/base64url.js';\nimport { JOSENotSupported, JWEInvalid } from '../util/errors.js';\nimport { bitLength as cekLength } from '../lib/cek.js';\nimport { importJWK } from '../key/import.js';\nimport checkKeyType from './check_key_type.js';\nimport isObject from './is_object.js';\nimport { unwrap as aesGcmKw } from './aesgcmkw.js';\nasync function decryptKeyManagement(alg, key, encryptedKey, joseHeader, options) {\n checkKeyType(alg, key, 'decrypt');\n switch (alg) {\n case 'dir': {\n if (encryptedKey !== undefined)\n throw new JWEInvalid('Encountered unexpected JWE Encrypted Key');\n return key;\n }\n case 'ECDH-ES':\n if (encryptedKey !== undefined)\n throw new JWEInvalid('Encountered unexpected JWE Encrypted Key');\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW': {\n if (!isObject(joseHeader.epk))\n throw new JWEInvalid(`JOSE Header \"epk\" (Ephemeral Public Key) missing or invalid`);\n if (!ECDH.ecdhAllowed(key))\n throw new JOSENotSupported('ECDH with the provided key is not allowed or not supported by your javascript runtime');\n const epk = await importJWK(joseHeader.epk, alg);\n let partyUInfo;\n let partyVInfo;\n if (joseHeader.apu !== undefined) {\n if (typeof joseHeader.apu !== 'string')\n throw new JWEInvalid(`JOSE Header \"apu\" (Agreement PartyUInfo) invalid`);\n try {\n partyUInfo = base64url(joseHeader.apu);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the apu');\n }\n }\n if (joseHeader.apv !== undefined) {\n if (typeof joseHeader.apv !== 'string')\n throw new JWEInvalid(`JOSE Header \"apv\" (Agreement PartyVInfo) invalid`);\n try {\n partyVInfo = base64url(joseHeader.apv);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the apv');\n }\n }\n const sharedSecret = await ECDH.deriveKey(epk, key, alg === 'ECDH-ES' ? joseHeader.enc : alg, alg === 'ECDH-ES' ? cekLength(joseHeader.enc) : parseInt(alg.slice(-5, -2), 10), partyUInfo, partyVInfo);\n if (alg === 'ECDH-ES')\n return sharedSecret;\n if (encryptedKey === undefined)\n throw new JWEInvalid('JWE Encrypted Key missing');\n return aesKw(alg.slice(-6), sharedSecret, encryptedKey);\n }\n case 'RSA1_5':\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512': {\n if (encryptedKey === undefined)\n throw new JWEInvalid('JWE Encrypted Key missing');\n return rsaEs(alg, key, encryptedKey);\n }\n case 'PBES2-HS256+A128KW':\n case 'PBES2-HS384+A192KW':\n case 'PBES2-HS512+A256KW': {\n if (encryptedKey === undefined)\n throw new JWEInvalid('JWE Encrypted Key missing');\n if (typeof joseHeader.p2c !== 'number')\n throw new JWEInvalid(`JOSE Header \"p2c\" (PBES2 Count) missing or invalid`);\n const p2cLimit = options?.maxPBES2Count || 10000;\n if (joseHeader.p2c > p2cLimit)\n throw new JWEInvalid(`JOSE Header \"p2c\" (PBES2 Count) out is of acceptable bounds`);\n if (typeof joseHeader.p2s !== 'string')\n throw new JWEInvalid(`JOSE Header \"p2s\" (PBES2 Salt) missing or invalid`);\n let p2s;\n try {\n p2s = base64url(joseHeader.p2s);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the p2s');\n }\n return pbes2Kw(alg, key, encryptedKey, joseHeader.p2c, p2s);\n }\n case 'A128KW':\n case 'A192KW':\n case 'A256KW': {\n if (encryptedKey === undefined)\n throw new JWEInvalid('JWE Encrypted Key missing');\n return aesKw(alg, key, encryptedKey);\n }\n case 'A128GCMKW':\n case 'A192GCMKW':\n case 'A256GCMKW': {\n if (encryptedKey === undefined)\n throw new JWEInvalid('JWE Encrypted Key missing');\n if (typeof joseHeader.iv !== 'string')\n throw new JWEInvalid(`JOSE Header \"iv\" (Initialization Vector) missing or invalid`);\n if (typeof joseHeader.tag !== 'string')\n throw new JWEInvalid(`JOSE Header \"tag\" (Authentication Tag) missing or invalid`);\n let iv;\n try {\n iv = base64url(joseHeader.iv);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the iv');\n }\n let tag;\n try {\n tag = base64url(joseHeader.tag);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the tag');\n }\n return aesGcmKw(alg, key, encryptedKey, iv, tag);\n }\n default: {\n throw new JOSENotSupported('Invalid or unsupported \"alg\" (JWE Algorithm) header value');\n }\n }\n}\nexport default decryptKeyManagement;\n","import { JOSENotSupported } from '../util/errors.js';\nfunction 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}\nexport default validateCrit;\n","const 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};\nexport default validateAlgorithms;\n","import { decode as base64url } from '../../runtime/base64url.js';\nimport decrypt from '../../runtime/decrypt.js';\nimport { JOSEAlgNotAllowed, JOSENotSupported, JWEInvalid } from '../../util/errors.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport isObject from '../../lib/is_object.js';\nimport decryptKeyManagement from '../../lib/decrypt_key_management.js';\nimport { encoder, decoder, concat } from '../../lib/buffer_utils.js';\nimport generateCek from '../../lib/cek.js';\nimport validateCrit from '../../lib/validate_crit.js';\nimport validateAlgorithms from '../../lib/validate_algorithms.js';\nexport async function flattenedDecrypt(jwe, key, options) {\n if (!isObject(jwe)) {\n throw new JWEInvalid('Flattened JWE must be an object');\n }\n if (jwe.protected === undefined && jwe.header === undefined && jwe.unprotected === undefined) {\n throw new JWEInvalid('JOSE Header missing');\n }\n if (jwe.iv !== undefined && typeof jwe.iv !== 'string') {\n throw new JWEInvalid('JWE Initialization Vector incorrect type');\n }\n if (typeof jwe.ciphertext !== 'string') {\n throw new JWEInvalid('JWE Ciphertext missing or incorrect type');\n }\n if (jwe.tag !== undefined && typeof jwe.tag !== 'string') {\n throw new JWEInvalid('JWE Authentication Tag incorrect type');\n }\n if (jwe.protected !== undefined && typeof jwe.protected !== 'string') {\n throw new JWEInvalid('JWE Protected Header incorrect type');\n }\n if (jwe.encrypted_key !== undefined && typeof jwe.encrypted_key !== 'string') {\n throw new JWEInvalid('JWE Encrypted Key incorrect type');\n }\n if (jwe.aad !== undefined && typeof jwe.aad !== 'string') {\n throw new JWEInvalid('JWE AAD incorrect type');\n }\n if (jwe.header !== undefined && !isObject(jwe.header)) {\n throw new JWEInvalid('JWE Shared Unprotected Header incorrect type');\n }\n if (jwe.unprotected !== undefined && !isObject(jwe.unprotected)) {\n throw new JWEInvalid('JWE Per-Recipient Unprotected Header incorrect type');\n }\n let parsedProt;\n if (jwe.protected) {\n try {\n const protectedHeader = base64url(jwe.protected);\n parsedProt = JSON.parse(decoder.decode(protectedHeader));\n }\n catch {\n throw new JWEInvalid('JWE Protected Header is invalid');\n }\n }\n if (!isDisjoint(parsedProt, jwe.header, jwe.unprotected)) {\n throw new JWEInvalid('JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint');\n }\n const joseHeader = {\n ...parsedProt,\n ...jwe.header,\n ...jwe.unprotected,\n };\n validateCrit(JWEInvalid, new Map(), options?.crit, parsedProt, joseHeader);\n if (joseHeader.zip !== undefined) {\n throw new JOSENotSupported('JWE \"zip\" (Compression Algorithm) Header Parameter is not supported.');\n }\n const { alg, enc } = joseHeader;\n if (typeof alg !== 'string' || !alg) {\n throw new JWEInvalid('missing JWE Algorithm (alg) in JWE Header');\n }\n if (typeof enc !== 'string' || !enc) {\n throw new JWEInvalid('missing JWE Encryption Algorithm (enc) in JWE Header');\n }\n const keyManagementAlgorithms = options && validateAlgorithms('keyManagementAlgorithms', options.keyManagementAlgorithms);\n const contentEncryptionAlgorithms = options &&\n validateAlgorithms('contentEncryptionAlgorithms', options.contentEncryptionAlgorithms);\n if ((keyManagementAlgorithms && !keyManagementAlgorithms.has(alg)) ||\n (!keyManagementAlgorithms && alg.startsWith('PBES2'))) {\n throw new JOSEAlgNotAllowed('\"alg\" (Algorithm) Header Parameter value not allowed');\n }\n if (contentEncryptionAlgorithms && !contentEncryptionAlgorithms.has(enc)) {\n throw new JOSEAlgNotAllowed('\"enc\" (Encryption Algorithm) Header Parameter value not allowed');\n }\n let encryptedKey;\n if (jwe.encrypted_key !== undefined) {\n try {\n encryptedKey = base64url(jwe.encrypted_key);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the encrypted_key');\n }\n }\n let resolvedKey = false;\n if (typeof key === 'function') {\n key = await key(parsedProt, jwe);\n resolvedKey = true;\n }\n let cek;\n try {\n cek = await decryptKeyManagement(alg, key, encryptedKey, joseHeader, options);\n }\n catch (err) {\n if (err instanceof TypeError || err instanceof JWEInvalid || err instanceof JOSENotSupported) {\n throw err;\n }\n cek = generateCek(enc);\n }\n let iv;\n let tag;\n if (jwe.iv !== undefined) {\n try {\n iv = base64url(jwe.iv);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the iv');\n }\n }\n if (jwe.tag !== undefined) {\n try {\n tag = base64url(jwe.tag);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the tag');\n }\n }\n const protectedHeader = encoder.encode(jwe.protected ?? '');\n let additionalData;\n if (jwe.aad !== undefined) {\n additionalData = concat(protectedHeader, encoder.encode('.'), encoder.encode(jwe.aad));\n }\n else {\n additionalData = protectedHeader;\n }\n let ciphertext;\n try {\n ciphertext = base64url(jwe.ciphertext);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the ciphertext');\n }\n const plaintext = await decrypt(enc, cek, ciphertext, iv, tag, additionalData);\n const result = { plaintext };\n if (jwe.protected !== undefined) {\n result.protectedHeader = parsedProt;\n }\n if (jwe.aad !== undefined) {\n try {\n result.additionalAuthenticatedData = base64url(jwe.aad);\n }\n catch {\n throw new JWEInvalid('Failed to base64url decode the aad');\n }\n }\n if (jwe.unprotected !== undefined) {\n result.sharedUnprotectedHeader = jwe.unprotected;\n }\n if (jwe.header !== undefined) {\n result.unprotectedHeader = jwe.header;\n }\n if (resolvedKey) {\n return { ...result, key };\n }\n return result;\n}\n","import { flattenedDecrypt } from '../flattened/decrypt.js';\nimport { JWEInvalid } from '../../util/errors.js';\nimport { decoder } from '../../lib/buffer_utils.js';\nexport async function compactDecrypt(jwe, key, options) {\n if (jwe instanceof Uint8Array) {\n jwe = decoder.decode(jwe);\n }\n if (typeof jwe !== 'string') {\n throw new JWEInvalid('Compact JWE must be a string or Uint8Array');\n }\n const { 0: protectedHeader, 1: encryptedKey, 2: iv, 3: ciphertext, 4: tag, length, } = jwe.split('.');\n if (length !== 5) {\n throw new JWEInvalid('Invalid Compact JWE');\n }\n const decrypted = await flattenedDecrypt({\n ciphertext,\n iv: iv || undefined,\n protected: protectedHeader,\n tag: tag || undefined,\n encrypted_key: encryptedKey || undefined,\n }, key, options);\n const result = { plaintext: decrypted.plaintext, protectedHeader: decrypted.protectedHeader };\n if (typeof key === 'function') {\n return { ...result, key: decrypted.key };\n }\n return result;\n}\n","import { flattenedDecrypt } from '../flattened/decrypt.js';\nimport { JWEDecryptionFailed, JWEInvalid } from '../../util/errors.js';\nimport isObject from '../../lib/is_object.js';\nexport async function generalDecrypt(jwe, key, options) {\n if (!isObject(jwe)) {\n throw new JWEInvalid('General JWE must be an object');\n }\n if (!Array.isArray(jwe.recipients) || !jwe.recipients.every(isObject)) {\n throw new JWEInvalid('JWE Recipients missing or incorrect type');\n }\n if (!jwe.recipients.length) {\n throw new JWEInvalid('JWE Recipients has no members');\n }\n for (const recipient of jwe.recipients) {\n try {\n return await flattenedDecrypt({\n aad: jwe.aad,\n ciphertext: jwe.ciphertext,\n encrypted_key: recipient.encrypted_key,\n header: recipient.header,\n iv: jwe.iv,\n protected: jwe.protected,\n tag: jwe.tag,\n unprotected: jwe.unprotected,\n }, key, options);\n }\n catch {\n }\n }\n throw new JWEDecryptionFailed();\n}\n","import { KeyObject } from 'node:crypto';\nimport { encode as base64url } from './base64url.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { isCryptoKey } from './webcrypto.js';\nimport isKeyObject from './is_key_object.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nconst keyToJWK = (key) => {\n let keyObject;\n if (isCryptoKey(key)) {\n if (!key.extractable) {\n throw new TypeError('CryptoKey is not extractable');\n }\n keyObject = KeyObject.from(key);\n }\n else if (isKeyObject(key)) {\n keyObject = key;\n }\n else if (key instanceof Uint8Array) {\n return {\n kty: 'oct',\n k: base64url(key),\n };\n }\n else {\n throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));\n }\n if (keyObject.type !== 'secret' &&\n !['rsa', 'ec', 'ed25519', 'x25519', 'ed448', 'x448'].includes(keyObject.asymmetricKeyType)) {\n throw new JOSENotSupported('Unsupported key asymmetricKeyType');\n }\n return keyObject.export({ format: 'jwk' });\n};\nexport default keyToJWK;\n","import { toSPKI as exportPublic } from '../runtime/asn1.js';\nimport { toPKCS8 as exportPrivate } from '../runtime/asn1.js';\nimport keyToJWK from '../runtime/key_to_jwk.js';\nexport async function exportSPKI(key) {\n return exportPublic(key);\n}\nexport async function exportPKCS8(key) {\n return exportPrivate(key);\n}\nexport async function exportJWK(key) {\n return keyToJWK(key);\n}\n","import { wrap as aesKw } from '../runtime/aeskw.js';\nimport * as ECDH from '../runtime/ecdhes.js';\nimport { encrypt as pbes2Kw } from '../runtime/pbes2kw.js';\nimport { encrypt as rsaEs } from '../runtime/rsaes.js';\nimport { encode as base64url } from '../runtime/base64url.js';\nimport generateCek, { bitLength as cekLength } from '../lib/cek.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport { exportJWK } from '../key/export.js';\nimport checkKeyType from './check_key_type.js';\nimport { wrap as aesGcmKw } from './aesgcmkw.js';\nasync function encryptKeyManagement(alg, enc, key, providedCek, providedParameters = {}) {\n let encryptedKey;\n let parameters;\n let cek;\n checkKeyType(alg, key, 'encrypt');\n switch (alg) {\n case 'dir': {\n cek = key;\n break;\n }\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW': {\n if (!ECDH.ecdhAllowed(key)) {\n throw new JOSENotSupported('ECDH with the provided key is not allowed or not supported by your javascript runtime');\n }\n const { apu, apv } = providedParameters;\n let { epk: ephemeralKey } = providedParameters;\n ephemeralKey ||= (await ECDH.generateEpk(key)).privateKey;\n const { x, y, crv, kty } = await exportJWK(ephemeralKey);\n const sharedSecret = await ECDH.deriveKey(key, ephemeralKey, alg === 'ECDH-ES' ? enc : alg, alg === 'ECDH-ES' ? cekLength(enc) : parseInt(alg.slice(-5, -2), 10), apu, apv);\n parameters = { epk: { x, crv, kty } };\n if (kty === 'EC')\n parameters.epk.y = y;\n if (apu)\n parameters.apu = base64url(apu);\n if (apv)\n parameters.apv = base64url(apv);\n if (alg === 'ECDH-ES') {\n cek = sharedSecret;\n break;\n }\n cek = providedCek || generateCek(enc);\n const kwAlg = alg.slice(-6);\n encryptedKey = await aesKw(kwAlg, sharedSecret, cek);\n break;\n }\n case 'RSA1_5':\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512': {\n cek = providedCek || generateCek(enc);\n encryptedKey = await rsaEs(alg, key, cek);\n break;\n }\n case 'PBES2-HS256+A128KW':\n case 'PBES2-HS384+A192KW':\n case 'PBES2-HS512+A256KW': {\n cek = providedCek || generateCek(enc);\n const { p2c, p2s } = providedParameters;\n ({ encryptedKey, ...parameters } = await pbes2Kw(alg, key, cek, p2c, p2s));\n break;\n }\n case 'A128KW':\n case 'A192KW':\n case 'A256KW': {\n cek = providedCek || generateCek(enc);\n encryptedKey = await aesKw(alg, key, cek);\n break;\n }\n case 'A128GCMKW':\n case 'A192GCMKW':\n case 'A256GCMKW': {\n cek = providedCek || generateCek(enc);\n const { iv } = providedParameters;\n ({ encryptedKey, ...parameters } = await aesGcmKw(alg, key, cek, iv));\n break;\n }\n default: {\n throw new JOSENotSupported('Invalid or unsupported \"alg\" (JWE Algorithm) header value');\n }\n }\n return { cek, encryptedKey, parameters };\n}\nexport default encryptKeyManagement;\n","import { encode as base64url } from '../../runtime/base64url.js';\nimport encrypt from '../../runtime/encrypt.js';\nimport encryptKeyManagement from '../../lib/encrypt_key_management.js';\nimport { JOSENotSupported, JWEInvalid } from '../../util/errors.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport { encoder, decoder, concat } from '../../lib/buffer_utils.js';\nimport validateCrit from '../../lib/validate_crit.js';\nexport const unprotected = Symbol();\nexport class FlattenedEncrypt {\n _plaintext;\n _protectedHeader;\n _sharedUnprotectedHeader;\n _unprotectedHeader;\n _aad;\n _cek;\n _iv;\n _keyManagementParameters;\n constructor(plaintext) {\n if (!(plaintext instanceof Uint8Array)) {\n throw new TypeError('plaintext must be an instance of Uint8Array');\n }\n this._plaintext = plaintext;\n }\n setKeyManagementParameters(parameters) {\n if (this._keyManagementParameters) {\n throw new TypeError('setKeyManagementParameters can only be called once');\n }\n this._keyManagementParameters = parameters;\n return this;\n }\n setProtectedHeader(protectedHeader) {\n if (this._protectedHeader) {\n throw new TypeError('setProtectedHeader can only be called once');\n }\n this._protectedHeader = protectedHeader;\n return this;\n }\n setSharedUnprotectedHeader(sharedUnprotectedHeader) {\n if (this._sharedUnprotectedHeader) {\n throw new TypeError('setSharedUnprotectedHeader can only be called once');\n }\n this._sharedUnprotectedHeader = sharedUnprotectedHeader;\n return this;\n }\n setUnprotectedHeader(unprotectedHeader) {\n if (this._unprotectedHeader) {\n throw new TypeError('setUnprotectedHeader can only be called once');\n }\n this._unprotectedHeader = unprotectedHeader;\n return this;\n }\n setAdditionalAuthenticatedData(aad) {\n this._aad = aad;\n return this;\n }\n setContentEncryptionKey(cek) {\n if (this._cek) {\n throw new TypeError('setContentEncryptionKey can only be called once');\n }\n this._cek = cek;\n return this;\n }\n setInitializationVector(iv) {\n if (this._iv) {\n throw new TypeError('setInitializationVector can only be called once');\n }\n this._iv = iv;\n return this;\n }\n async encrypt(key, options) {\n if (!this._protectedHeader && !this._unprotectedHeader && !this._sharedUnprotectedHeader) {\n throw new JWEInvalid('either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()');\n }\n if (!isDisjoint(this._protectedHeader, this._unprotectedHeader, this._sharedUnprotectedHeader)) {\n throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');\n }\n const joseHeader = {\n ...this._protectedHeader,\n ...this._unprotectedHeader,\n ...this._sharedUnprotectedHeader,\n };\n validateCrit(JWEInvalid, new Map(), options?.crit, this._protectedHeader, joseHeader);\n if (joseHeader.zip !== undefined) {\n throw new JOSENotSupported('JWE \"zip\" (Compression Algorithm) Header Parameter is not supported.');\n }\n const { alg, enc } = joseHeader;\n if (typeof alg !== 'string' || !alg) {\n throw new JWEInvalid('JWE \"alg\" (Algorithm) Header Parameter missing or invalid');\n }\n if (typeof enc !== 'string' || !enc) {\n throw new JWEInvalid('JWE \"enc\" (Encryption Algorithm) Header Parameter missing or invalid');\n }\n let encryptedKey;\n if (this._cek && (alg === 'dir' || alg === 'ECDH-ES')) {\n throw new TypeError(`setContentEncryptionKey cannot be called with JWE \"alg\" (Algorithm) Header ${alg}`);\n }\n let cek;\n {\n let parameters;\n ({ cek, encryptedKey, parameters } = await encryptKeyManagement(alg, enc, key, this._cek, this._keyManagementParameters));\n if (parameters) {\n if (options && unprotected in options) {\n if (!this._unprotectedHeader) {\n this.setUnprotectedHeader(parameters);\n }\n else {\n this._unprotectedHeader = { ...this._unprotectedHeader, ...parameters };\n }\n }\n else {\n if (!this._protectedHeader) {\n this.setProtectedHeader(parameters);\n }\n else {\n this._protectedHeader = { ...this._protectedHeader, ...parameters };\n }\n }\n }\n }\n let additionalData;\n let protectedHeader;\n let aadMember;\n if (this._protectedHeader) {\n protectedHeader = encoder.encode(base64url(JSON.stringify(this._protectedHeader)));\n }\n else {\n protectedHeader = encoder.encode('');\n }\n if (this._aad) {\n aadMember = base64url(this._aad);\n additionalData = concat(protectedHeader, encoder.encode('.'), encoder.encode(aadMember));\n }\n else {\n additionalData = protectedHeader;\n }\n const { ciphertext, tag, iv } = await encrypt(enc, this._plaintext, cek, this._iv, additionalData);\n const jwe = {\n ciphertext: base64url(ciphertext),\n };\n if (iv) {\n jwe.iv = base64url(iv);\n }\n if (tag) {\n jwe.tag = base64url(tag);\n }\n if (encryptedKey) {\n jwe.encrypted_key = base64url(encryptedKey);\n }\n if (aadMember) {\n jwe.aad = aadMember;\n }\n if (this._protectedHeader) {\n jwe.protected = decoder.decode(protectedHeader);\n }\n if (this._sharedUnprotectedHeader) {\n jwe.unprotected = this._sharedUnprotectedHeader;\n }\n if (this._unprotectedHeader) {\n jwe.header = this._unprotectedHeader;\n }\n return jwe;\n }\n}\n","import { FlattenedEncrypt, unprotected } from '../flattened/encrypt.js';\nimport { JOSENotSupported, JWEInvalid } from '../../util/errors.js';\nimport generateCek from '../../lib/cek.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport encryptKeyManagement from '../../lib/encrypt_key_management.js';\nimport { encode as base64url } from '../../runtime/base64url.js';\nimport validateCrit from '../../lib/validate_crit.js';\nclass IndividualRecipient {\n parent;\n unprotectedHeader;\n key;\n options;\n constructor(enc, key, options) {\n this.parent = enc;\n this.key = key;\n this.options = options;\n }\n setUnprotectedHeader(unprotectedHeader) {\n if (this.unprotectedHeader) {\n throw new TypeError('setUnprotectedHeader can only be called once');\n }\n this.unprotectedHeader = unprotectedHeader;\n return this;\n }\n addRecipient(...args) {\n return this.parent.addRecipient(...args);\n }\n encrypt(...args) {\n return this.parent.encrypt(...args);\n }\n done() {\n return this.parent;\n }\n}\nexport class GeneralEncrypt {\n _plaintext;\n _recipients = [];\n _protectedHeader;\n _unprotectedHeader;\n _aad;\n constructor(plaintext) {\n this._plaintext = plaintext;\n }\n addRecipient(key, options) {\n const recipient = new IndividualRecipient(this, key, { crit: options?.crit });\n this._recipients.push(recipient);\n return recipient;\n }\n setProtectedHeader(protectedHeader) {\n if (this._protectedHeader) {\n throw new TypeError('setProtectedHeader can only be called once');\n }\n this._protectedHeader = protectedHeader;\n return this;\n }\n setSharedUnprotectedHeader(sharedUnprotectedHeader) {\n if (this._unprotectedHeader) {\n throw new TypeError('setSharedUnprotectedHeader can only be called once');\n }\n this._unprotectedHeader = sharedUnprotectedHeader;\n return this;\n }\n setAdditionalAuthenticatedData(aad) {\n this._aad = aad;\n return this;\n }\n async encrypt() {\n if (!this._recipients.length) {\n throw new JWEInvalid('at least one recipient must be added');\n }\n if (this._recipients.length === 1) {\n const [recipient] = this._recipients;\n const flattened = await new FlattenedEncrypt(this._plaintext)\n .setAdditionalAuthenticatedData(this._aad)\n .setProtectedHeader(this._protectedHeader)\n .setSharedUnprotectedHeader(this._unprotectedHeader)\n .setUnprotectedHeader(recipient.unprotectedHeader)\n .encrypt(recipient.key, { ...recipient.options });\n const jwe = {\n ciphertext: flattened.ciphertext,\n iv: flattened.iv,\n recipients: [{}],\n tag: flattened.tag,\n };\n if (flattened.aad)\n jwe.aad = flattened.aad;\n if (flattened.protected)\n jwe.protected = flattened.protected;\n if (flattened.unprotected)\n jwe.unprotected = flattened.unprotected;\n if (flattened.encrypted_key)\n jwe.recipients[0].encrypted_key = flattened.encrypted_key;\n if (flattened.header)\n jwe.recipients[0].header = flattened.header;\n return jwe;\n }\n let enc;\n for (let i = 0; i < this._recipients.length; i++) {\n const recipient = this._recipients[i];\n if (!isDisjoint(this._protectedHeader, this._unprotectedHeader, recipient.unprotectedHeader)) {\n throw new JWEInvalid('JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint');\n }\n const joseHeader = {\n ...this._protectedHeader,\n ...this._unprotectedHeader,\n ...recipient.unprotectedHeader,\n };\n const { alg } = joseHeader;\n if (typeof alg !== 'string' || !alg) {\n throw new JWEInvalid('JWE \"alg\" (Algorithm) Header Parameter missing or invalid');\n }\n if (alg === 'dir' || alg === 'ECDH-ES') {\n throw new JWEInvalid('\"dir\" and \"ECDH-ES\" alg may only be used with a single recipient');\n }\n if (typeof joseHeader.enc !== 'string' || !joseHeader.enc) {\n throw new JWEInvalid('JWE \"enc\" (Encryption Algorithm) Header Parameter missing or invalid');\n }\n if (!enc) {\n enc = joseHeader.enc;\n }\n else if (enc !== joseHeader.enc) {\n throw new JWEInvalid('JWE \"enc\" (Encryption Algorithm) Header Parameter must be the same for all recipients');\n }\n validateCrit(JWEInvalid, new Map(), recipient.options.crit, this._protectedHeader, joseHeader);\n if (joseHeader.zip !== undefined) {\n throw new JOSENotSupported('JWE \"zip\" (Compression Algorithm) Header Parameter is not supported.');\n }\n }\n const cek = generateCek(enc);\n const jwe = {\n ciphertext: '',\n iv: '',\n recipients: [],\n tag: '',\n };\n for (let i = 0; i < this._recipients.length; i++) {\n const recipient = this._recipients[i];\n const target = {};\n jwe.recipients.push(target);\n const joseHeader = {\n ...this._protectedHeader,\n ...this._unprotectedHeader,\n ...recipient.unprotectedHeader,\n };\n const p2c = joseHeader.alg.startsWith('PBES2') ? 2048 + i : undefined;\n if (i === 0) {\n const flattened = await new FlattenedEncrypt(this._plaintext)\n .setAdditionalAuthenticatedData(this._aad)\n .setContentEncryptionKey(cek)\n .setProtectedHeader(this._protectedHeader)\n .setSharedUnprotectedHeader(this._unprotectedHeader)\n .setUnprotectedHeader(recipient.unprotectedHeader)\n .setKeyManagementParameters({ p2c })\n .encrypt(recipient.key, {\n ...recipient.options,\n [unprotected]: true,\n });\n jwe.ciphertext = flattened.ciphertext;\n jwe.iv = flattened.iv;\n jwe.tag = flattened.tag;\n if (flattened.aad)\n jwe.aad = flattened.aad;\n if (flattened.protected)\n jwe.protected = flattened.protected;\n if (flattened.unprotected)\n jwe.unprotected = flattened.unprotected;\n target.encrypted_key = flattened.encrypted_key;\n if (flattened.header)\n target.header = flattened.header;\n continue;\n }\n const { encryptedKey, parameters } = await encryptKeyManagement(recipient.unprotectedHeader?.alg ||\n this._protectedHeader?.alg ||\n this._unprotectedHeader?.alg, enc, recipient.key, cek, { p2c });\n target.encrypted_key = base64url(encryptedKey);\n if (recipient.unprotectedHeader || parameters)\n target.header = { ...recipient.unprotectedHeader, ...parameters };\n }\n return jwe;\n }\n}\n","import * as crypto from 'node:crypto';\nimport { promisify } from 'node:util';\nimport nodeDigest from './dsa_digest.js';\nimport nodeKey from './node_key.js';\nimport sign from './sign.js';\nimport getVerifyKey from './get_sign_verify_key.js';\nconst oneShotVerify = promisify(crypto.verify);\nconst verify = async (alg, key, signature, data) => {\n const keyObject = getVerifyKey(alg, key, 'verify');\n if (alg.startsWith('HS')) {\n const expected = await sign(alg, keyObject, data);\n const actual = signature;\n try {\n return crypto.timingSafeEqual(actual, expected);\n }\n catch {\n return false;\n }\n }\n const algorithm = nodeDigest(alg);\n const keyInput = nodeKey(alg, keyObject);\n try {\n return await oneShotVerify(algorithm, data, keyInput, signature);\n }\n catch {\n return false;\n }\n};\nexport default verify;\n","import { JOSENotSupported } from '../util/errors.js';\nexport default function dsaDigest(alg) {\n switch (alg) {\n case 'PS256':\n case 'RS256':\n case 'ES256':\n case 'ES256K':\n return 'sha256';\n case 'PS384':\n case 'RS384':\n case 'ES384':\n return 'sha384';\n case 'PS512':\n case 'RS512':\n case 'ES512':\n return 'sha512';\n case 'EdDSA':\n return undefined;\n default:\n throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n }\n}\n","import { constants } from 'node:crypto';\nimport getNamedCurve from './get_named_curve.js';\nimport { JOSENotSupported } from '../util/errors.js';\nimport checkKeyLength from './check_key_length.js';\nconst PSS = {\n padding: constants.RSA_PKCS1_PSS_PADDING,\n saltLength: constants.RSA_PSS_SALTLEN_DIGEST,\n};\nconst ecCurveAlgMap = new Map([\n ['ES256', 'P-256'],\n ['ES256K', 'secp256k1'],\n ['ES384', 'P-384'],\n ['ES512', 'P-521'],\n]);\nexport default function keyForCrypto(alg, key) {\n switch (alg) {\n case 'EdDSA':\n if (!['ed25519', 'ed448'].includes(key.asymmetricKeyType)) {\n throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be ed25519 or ed448');\n }\n return key;\n case 'RS256':\n case 'RS384':\n case 'RS512':\n if (key.asymmetricKeyType !== 'rsa') {\n throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be rsa');\n }\n checkKeyLength(key, alg);\n return key;\n case 'PS256':\n case 'PS384':\n case 'PS512':\n if (key.asymmetricKeyType === 'rsa-pss') {\n const { hashAlgorithm, mgf1HashAlgorithm, saltLength } = key.asymmetricKeyDetails;\n const length = parseInt(alg.slice(-3), 10);\n if (hashAlgorithm !== undefined &&\n (hashAlgorithm !== `sha${length}` || mgf1HashAlgorithm !== hashAlgorithm)) {\n throw new TypeError(`Invalid key for this operation, its RSA-PSS parameters do not meet the requirements of \"alg\" ${alg}`);\n }\n if (saltLength !== undefined && saltLength > length >> 3) {\n throw new TypeError(`Invalid key for this operation, its RSA-PSS parameter saltLength does not meet the requirements of \"alg\" ${alg}`);\n }\n }\n else if (key.asymmetricKeyType !== 'rsa') {\n throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be rsa or rsa-pss');\n }\n checkKeyLength(key, alg);\n return { key, ...PSS };\n case 'ES256':\n case 'ES256K':\n case 'ES384':\n case 'ES512': {\n if (key.asymmetricKeyType !== 'ec') {\n throw new TypeError('Invalid key for this operation, its asymmetricKeyType must be ec');\n }\n const actual = getNamedCurve(key);\n const expected = ecCurveAlgMap.get(alg);\n if (actual !== expected) {\n throw new TypeError(`Invalid key curve for the algorithm, its curve must be ${expected}, got ${actual}`);\n }\n return { dsaEncoding: 'ieee-p1363', key };\n }\n default:\n throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n }\n}\n","import * as crypto from 'node:crypto';\nimport { promisify } from 'node:util';\nimport nodeDigest from './dsa_digest.js';\nimport hmacDigest from './hmac_digest.js';\nimport nodeKey from './node_key.js';\nimport getSignKey from './get_sign_verify_key.js';\nconst oneShotSign = promisify(crypto.sign);\nconst sign = async (alg, key, data) => {\n const keyObject = getSignKey(alg, key, 'sign');\n if (alg.startsWith('HS')) {\n const hmac = crypto.createHmac(hmacDigest(alg), keyObject);\n hmac.update(data);\n return hmac.digest();\n }\n return oneShotSign(nodeDigest(alg), data, nodeKey(alg, keyObject));\n};\nexport default sign;\n","import { JOSENotSupported } from '../util/errors.js';\nexport default function hmacDigest(alg) {\n switch (alg) {\n case 'HS256':\n return 'sha256';\n case 'HS384':\n return 'sha384';\n case 'HS512':\n return 'sha512';\n default:\n throw new JOSENotSupported(`alg ${alg} is not supported either by JOSE or your javascript runtime`);\n }\n}\n","import { KeyObject, createSecretKey } from 'node:crypto';\nimport { isCryptoKey } from './webcrypto.js';\nimport { checkSigCryptoKey } from '../lib/crypto_key.js';\nimport invalidKeyInput from '../lib/invalid_key_input.js';\nimport { types } from './is_key_like.js';\nexport default function getSignVerifyKey(alg, key, usage) {\n if (key instanceof Uint8Array) {\n if (!alg.startsWith('HS')) {\n throw new TypeError(invalidKeyInput(key, ...types));\n }\n return createSecretKey(key);\n }\n if (key instanceof KeyObject) {\n return key;\n }\n if (isCryptoKey(key)) {\n checkSigCryptoKey(key, alg, usage);\n return KeyObject.from(key);\n }\n throw new TypeError(invalidKeyInput(key, ...types, 'Uint8Array'));\n}\n","import { decode as base64url } from '../../runtime/base64url.js';\nimport verify from '../../runtime/verify.js';\nimport { JOSEAlgNotAllowed, JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';\nimport { concat, encoder, decoder } from '../../lib/buffer_utils.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport isObject from '../../lib/is_object.js';\nimport checkKeyType from '../../lib/check_key_type.js';\nimport validateCrit from '../../lib/validate_crit.js';\nimport validateAlgorithms from '../../lib/validate_algorithms.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 = base64url(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(encoder.encode(jws.protected ?? ''), encoder.encode('.'), typeof jws.payload === 'string' ? encoder.encode(jws.payload) : jws.payload);\n let signature;\n try {\n signature = base64url(jws.signature);\n }\n catch {\n throw new JWSInvalid('Failed to base64url decode the signature');\n }\n const verified = await verify(alg, key, signature, data);\n if (!verified) {\n throw new JWSSignatureVerificationFailed();\n }\n let payload;\n if (b64) {\n try {\n payload = base64url(jws.payload);\n }\n catch {\n throw new JWSInvalid('Failed to base64url decode the payload');\n }\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 };\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 { flattenedVerify } from '../flattened/verify.js';\nimport { JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';\nimport isObject from '../../lib/is_object.js';\nexport async function generalVerify(jws, key, options) {\n if (!isObject(jws)) {\n throw new JWSInvalid('General JWS must be an object');\n }\n if (!Array.isArray(jws.signatures) || !jws.signatures.every(isObject)) {\n throw new JWSInvalid('JWS Signatures missing or incorrect type');\n }\n for (const signature of jws.signatures) {\n try {\n return await flattenedVerify({\n header: signature.header,\n payload: jws.payload,\n protected: signature.protected,\n signature: signature.signature,\n }, key, options);\n }\n catch {\n }\n }\n throw new JWSSignatureVerificationFailed();\n}\n","export default (date) => Math.floor(date.getTime() / 1000);\n","const 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 default (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};\n","import { JWTClaimValidationFailed, JWTExpired, JWTInvalid } from '../util/errors.js';\nimport { decoder } from './buffer_utils.js';\nimport epoch from './epoch.js';\nimport secs from './secs.js';\nimport isObject from './is_object.js';\nconst normalizeTyp = (value) => value.toLowerCase().replace(/^application\\//, '');\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 default (protectedHeader, encodedPayload, options = {}) => {\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', 'typ', 'check_failed');\n }\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 { 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`, claim, 'missing');\n }\n }\n if (issuer && !(Array.isArray(issuer) ? issuer : [issuer]).includes(payload.iss)) {\n throw new JWTClaimValidationFailed('unexpected \"iss\" claim value', 'iss', 'check_failed');\n }\n if (subject && payload.sub !== subject) {\n throw new JWTClaimValidationFailed('unexpected \"sub\" claim value', 'sub', 'check_failed');\n }\n if (audience &&\n !checkAudiencePresence(payload.aud, typeof audience === 'string' ? [audience] : audience)) {\n throw new JWTClaimValidationFailed('unexpected \"aud\" claim value', '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', 'iat', 'invalid');\n }\n if (payload.nbf !== undefined) {\n if (typeof payload.nbf !== 'number') {\n throw new JWTClaimValidationFailed('\"nbf\" claim must be a number', 'nbf', 'invalid');\n }\n if (payload.nbf > now + tolerance) {\n throw new JWTClaimValidationFailed('\"nbf\" claim timestamp check failed', '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', 'exp', 'invalid');\n }\n if (payload.exp <= now - tolerance) {\n throw new JWTExpired('\"exp\" claim timestamp check failed', '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)', 'iat', 'check_failed');\n }\n if (age < 0 - tolerance) {\n throw new JWTClaimValidationFailed('\"iat\" claim timestamp check failed (it should be in the past)', 'iat', 'check_failed');\n }\n }\n return payload;\n};\n","import { compactVerify } from '../jws/compact/verify.js';\nimport jwtPayload 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 = jwtPayload(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 { compactDecrypt } from '../jwe/compact/decrypt.js';\nimport jwtPayload from '../lib/jwt_claims_set.js';\nimport { JWTClaimValidationFailed } from '../util/errors.js';\nexport async function jwtDecrypt(jwt, key, options) {\n const decrypted = await compactDecrypt(jwt, key, options);\n const payload = jwtPayload(decrypted.protectedHeader, decrypted.plaintext, options);\n const { protectedHeader } = decrypted;\n if (protectedHeader.iss !== undefined && protectedHeader.iss !== payload.iss) {\n throw new JWTClaimValidationFailed('replicated \"iss\" claim header parameter mismatch', 'iss', 'mismatch');\n }\n if (protectedHeader.sub !== undefined && protectedHeader.sub !== payload.sub) {\n throw new JWTClaimValidationFailed('replicated \"sub\" claim header parameter mismatch', 'sub', 'mismatch');\n }\n if (protectedHeader.aud !== undefined &&\n JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud)) {\n throw new JWTClaimValidationFailed('replicated \"aud\" claim header parameter mismatch', 'aud', 'mismatch');\n }\n const result = { payload, protectedHeader };\n if (typeof key === 'function') {\n return { ...result, key: decrypted.key };\n }\n return result;\n}\n","import { FlattenedEncrypt } from '../flattened/encrypt.js';\nexport class CompactEncrypt {\n _flattened;\n constructor(plaintext) {\n this._flattened = new FlattenedEncrypt(plaintext);\n }\n setContentEncryptionKey(cek) {\n this._flattened.setContentEncryptionKey(cek);\n return this;\n }\n setInitializationVector(iv) {\n this._flattened.setInitializationVector(iv);\n return this;\n }\n setProtectedHeader(protectedHeader) {\n this._flattened.setProtectedHeader(protectedHeader);\n return this;\n }\n setKeyManagementParameters(parameters) {\n this._flattened.setKeyManagementParameters(parameters);\n return this;\n }\n async encrypt(key, options) {\n const jwe = await this._flattened.encrypt(key, options);\n return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.');\n }\n}\n","import { encode as base64url } from '../../runtime/base64url.js';\nimport sign from '../../runtime/sign.js';\nimport isDisjoint from '../../lib/is_disjoint.js';\nimport { JWSInvalid } from '../../util/errors.js';\nimport { encoder, decoder, concat } from '../../lib/buffer_utils.js';\nimport checkKeyType from '../../lib/check_key_type.js';\nimport validateCrit from '../../lib/validate_crit.js';\nexport class FlattenedSign {\n _payload;\n _protectedHeader;\n _unprotectedHeader;\n constructor(payload) {\n if (!(payload instanceof Uint8Array)) {\n throw new TypeError('payload must be an instance of Uint8Array');\n }\n this._payload = payload;\n }\n setProtectedHeader(protectedHeader) {\n if (this._protectedHeader) {\n throw new TypeError('setProtectedHeader can only be called once');\n }\n this._protectedHeader = protectedHeader;\n return this;\n }\n setUnprotectedHeader(unprotectedHeader) {\n if (this._unprotectedHeader) {\n throw new TypeError('setUnprotectedHeader can only be called once');\n }\n this._unprotectedHeader = unprotectedHeader;\n return this;\n }\n async sign(key, options) {\n if (!this._protectedHeader && !this._unprotectedHeader) {\n throw new JWSInvalid('either setProtectedHeader or setUnprotectedHeader must be called before #sign()');\n }\n if (!isDisjoint(this._protectedHeader, this._unprotectedHeader)) {\n throw new JWSInvalid('JWS Protected and JWS Unprotected Header Parameter names must be disjoint');\n }\n const joseHeader = {\n ...this._protectedHeader,\n ...this._unprotectedHeader,\n };\n const extensions = validateCrit(JWSInvalid, new Map([['b64', true]]), options?.crit, this._protectedHeader, joseHeader);\n let b64 = true;\n if (extensions.has('b64')) {\n b64 = this._protectedHeader.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 checkKeyType(alg, key, 'sign');\n let payload = this._payload;\n if (b64) {\n payload = encoder.encode(base64url(payload));\n }\n let protectedHeader;\n if (this._protectedHeader) {\n protectedHeader = encoder.encode(base64url(JSON.stringify(this._protectedHeader)));\n }\n else {\n protectedHeader = encoder.encode('');\n }\n const data = concat(protectedHeader, encoder.encode('.'), payload);\n const signature = await sign(alg, key, data);\n const jws = {\n signature: base64url(signature),\n payload: '',\n };\n if (b64) {\n jws.payload = decoder.decode(payload);\n }\n if (this._unprotectedHeader) {\n jws.header = this._unprotectedHeader;\n }\n if (this._protectedHeader) {\n jws.protected = decoder.decode(protectedHeader);\n }\n return jws;\n }\n}\n","import { FlattenedSign } from '../flattened/sign.js';\nexport class CompactSign {\n _flattened;\n constructor(payload) {\n this._flattened = new FlattenedSign(payload);\n }\n setProtectedHeader(protectedHeader) {\n this._flattened.setProtectedHeader(protectedHeader);\n return this;\n }\n async sign(key, options) {\n const jws = await this._flattened.sign(key, options);\n if (jws.payload === undefined) {\n throw new TypeError('use the flattened module for creating JWS with b64: false');\n }\n return `${jws.protected}.${jws.payload}.${jws.signature}`;\n }\n}\n","import { FlattenedSign } from '../flattened/sign.js';\nimport { JWSInvalid } from '../../util/errors.js';\nclass IndividualSignature {\n parent;\n protectedHeader;\n unprotectedHeader;\n options;\n key;\n constructor(sig, key, options) {\n this.parent = sig;\n this.key = key;\n this.options = options;\n }\n setProtectedHeader(protectedHeader) {\n if (this.protectedHeader) {\n throw new TypeError('setProtectedHeader can only be called once');\n }\n this.protectedHeader = protectedHeader;\n return this;\n }\n setUnprotectedHeader(unprotectedHeader) {\n if (this.unprotectedHeader) {\n throw new TypeError('setUnprotectedHeader can only be called once');\n }\n this.unprotectedHeader = unprotectedHeader;\n return this;\n }\n addSignature(...args) {\n return this.parent.addSignature(...args);\n }\n sign(...args) {\n return this.parent.sign(...args);\n }\n done() {\n return this.parent;\n }\n}\nexport class GeneralSign {\n _payload;\n _signatures = [];\n constructor(payload) {\n this._payload = payload;\n }\n addSignature(key, options) {\n const signature = new IndividualSignature(this, key, options);\n this._signatures.push(signature);\n return signature;\n }\n async sign() {\n if (!this._signatures.length) {\n throw new JWSInvalid('at least one signature must be added');\n }\n const jws = {\n signatures: [],\n payload: '',\n };\n for (let i = 0; i < this._signatures.length; i++) {\n const signature = this._signatures[i];\n const flattened = new FlattenedSign(this._payload);\n flattened.setProtectedHeader(signature.protectedHeader);\n flattened.setUnprotectedHeader(signature.unprotectedHeader);\n const { payload, ...rest } = await flattened.sign(signature.key, signature.options);\n if (i === 0) {\n jws.payload = payload;\n }\n else if (jws.payload !== payload) {\n throw new JWSInvalid('inconsistent use of JWS Unencoded Payload (RFC7797)');\n }\n jws.signatures.push(rest);\n }\n return jws;\n }\n}\n","import epoch from '../lib/epoch.js';\nimport isObject from '../lib/is_object.js';\nimport secs from '../lib/secs.js';\nfunction validateInput(label, input) {\n if (!Number.isFinite(input)) {\n throw new TypeError(`Invalid ${label} input`);\n }\n return input;\n}\nexport class ProduceJWT {\n _payload;\n constructor(payload = {}) {\n if (!isObject(payload)) {\n throw new TypeError('JWT Claims Set MUST be an object');\n }\n this._payload = payload;\n }\n setIssuer(issuer) {\n this._payload = { ...this._payload, iss: issuer };\n return this;\n }\n setSubject(subject) {\n this._payload = { ...this._payload, sub: subject };\n return this;\n }\n setAudience(audience) {\n this._payload = { ...this._payload, aud: audience };\n return this;\n }\n setJti(jwtId) {\n this._payload = { ...this._payload, jti: jwtId };\n return this;\n }\n setNotBefore(input) {\n if (typeof input === 'number') {\n this._payload = { ...this._payload, nbf: validateInput('setNotBefore', input) };\n }\n else if (input instanceof Date) {\n this._payload = { ...this._payload, nbf: validateInput('setNotBefore', epoch(input)) };\n }\n else {\n this._payload = { ...this._payload, nbf: epoch(new Date()) + secs(input) };\n }\n return this;\n }\n setExpirationTime(input) {\n if (typeof input === 'number') {\n this._payload = { ...this._payload, exp: validateInput('setExpirationTime', input) };\n }\n else if (input instanceof Date) {\n this._payload = { ...this._payload, exp: validateInput('setExpirationTime', epoch(input)) };\n }\n else {\n this._payload = { ...this._payload, exp: epoch(new Date()) + secs(input) };\n }\n return this;\n }\n setIssuedAt(input) {\n if (typeof input === 'undefined') {\n this._payload = { ...this._payload, iat: epoch(new Date()) };\n }\n else if (input instanceof Date) {\n this._payload = { ...this._payload, iat: validateInput('setIssuedAt', epoch(input)) };\n }\n else if (typeof input === 'string') {\n this._payload = {\n ...this._payload,\n iat: validateInput('setIssuedAt', epoch(new Date()) + secs(input)),\n };\n }\n else {\n this._payload = { ...this._payload, iat: validateInput('setIssuedAt', input) };\n }\n return this;\n }\n}\n","import { CompactSign } from '../jws/compact/sign.js';\nimport { JWTInvalid } from '../util/errors.js';\nimport { encoder } from '../lib/buffer_utils.js';\nimport { ProduceJWT } from './produce.js';\nexport class SignJWT extends ProduceJWT {\n _protectedHeader;\n setProtectedHeader(protectedHeader) {\n this._protectedHeader = protectedHeader;\n return this;\n }\n async sign(key, options) {\n const sig = new CompactSign(encoder.encode(JSON.stringify(this._payload)));\n sig.setProtectedHeader(this._protectedHeader);\n if (Array.isArray(this._protectedHeader?.crit) &&\n this._protectedHeader.crit.includes('b64') &&\n this._protectedHeader.b64 === false) {\n throw new JWTInvalid('JWTs MUST NOT use unencoded payload');\n }\n return sig.sign(key, options);\n }\n}\n","import { CompactEncrypt } from '../jwe/compact/encrypt.js';\nimport { encoder } from '../lib/buffer_utils.js';\nimport { ProduceJWT } from './produce.js';\nexport class EncryptJWT extends ProduceJWT {\n _cek;\n _iv;\n _keyManagementParameters;\n _protectedHeader;\n _replicateIssuerAsHeader;\n _replicateSubjectAsHeader;\n _replicateAudienceAsHeader;\n setProtectedHeader(protectedHeader) {\n if (this._protectedHeader) {\n throw new TypeError('setProtectedHeader can only be called once');\n }\n this._protectedHeader = protectedHeader;\n return this;\n }\n setKeyManagementParameters(parameters) {\n if (this._keyManagementParameters) {\n throw new TypeError('setKeyManagementParameters can only be called once');\n }\n this._keyManagementParameters = parameters;\n return this;\n }\n setContentEncryptionKey(cek) {\n if (this._cek) {\n throw new TypeError('setContentEncryptionKey can only be called once');\n }\n this._cek = cek;\n return this;\n }\n setInitializationVector(iv) {\n if (this._iv) {\n throw new TypeError('setInitializationVector can only be called once');\n }\n this._iv = iv;\n return this;\n }\n replicateIssuerAsHeader() {\n this._replicateIssuerAsHeader = true;\n return this;\n }\n replicateSubjectAsHeader() {\n this._replicateSubjectAsHeader = true;\n return this;\n }\n replicateAudienceAsHeader() {\n this._replicateAudienceAsHeader = true;\n return this;\n }\n async encrypt(key, options) {\n const enc = new CompactEncrypt(encoder.encode(JSON.stringify(this._payload)));\n if (this._replicateIssuerAsHeader) {\n this._protectedHeader = { ...this._protectedHeader, iss: this._payload.iss };\n }\n if (this._replicateSubjectAsHeader) {\n this._protectedHeader = { ...this._protectedHeader, sub: this._payload.sub };\n }\n if (this._replicateAudienceAsHeader) {\n this._protectedHeader = { ...this._protectedHeader, aud: this._payload.aud };\n }\n enc.setProtectedHeader(this._protectedHeader);\n if (this._iv) {\n enc.setInitializationVector(this._iv);\n }\n if (this._cek) {\n enc.setContentEncryptionKey(this._cek);\n }\n if (this._keyManagementParameters) {\n enc.setKeyManagementParameters(this._keyManagementParameters);\n }\n return enc.encrypt(key, options);\n }\n}\n","import digest from '../runtime/digest.js';\nimport { encode as base64url } from '../runtime/base64url.js';\nimport { JOSENotSupported, JWKInvalid } from '../util/errors.js';\nimport { encoder } from '../lib/buffer_utils.js';\nimport isObject from '../lib/is_object.js';\nconst check = (value, description) => {\n if (typeof value !== 'string' || !value) {\n throw new JWKInvalid(`${description} missing or invalid`);\n }\n};\nexport async function calculateJwkThumbprint(jwk, digestAlgorithm) {\n if (!isObject(jwk)) {\n throw new TypeError('JWK must be an object');\n }\n digestAlgorithm ??= 'sha256';\n if (digestAlgorithm !== 'sha256' &&\n digestAlgorithm !== 'sha384' &&\n digestAlgorithm !== 'sha512') {\n throw new TypeError('digestAlgorithm must one of \"sha256\", \"sha384\", or \"sha512\"');\n }\n let components;\n switch (jwk.kty) {\n case 'EC':\n check(jwk.crv, '\"crv\" (Curve) Parameter');\n check(jwk.x, '\"x\" (X Coordinate) Parameter');\n check(jwk.y, '\"y\" (Y Coordinate) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y };\n break;\n case 'OKP':\n check(jwk.crv, '\"crv\" (Subtype of Key Pair) Parameter');\n check(jwk.x, '\"x\" (Public Key) Parameter');\n components = { crv: jwk.crv, kty: jwk.kty, x: jwk.x };\n break;\n case 'RSA':\n check(jwk.e, '\"e\" (Exponent) Parameter');\n check(jwk.n, '\"n\" (Modulus) Parameter');\n components = { e: jwk.e, kty: jwk.kty, n: jwk.n };\n break;\n case 'oct':\n check(jwk.k, '\"k\" (Key Value) Parameter');\n components = { k: jwk.k, kty: jwk.kty };\n break;\n default:\n throw new JOSENotSupported('\"kty\" (Key Type) Parameter missing or unsupported');\n }\n const data = encoder.encode(JSON.stringify(components));\n return base64url(await digest(digestAlgorithm, data));\n}\nexport async function calculateJwkThumbprintUri(jwk, digestAlgorithm) {\n digestAlgorithm ??= 'sha256';\n const thumbprint = await calculateJwkThumbprint(jwk, digestAlgorithm);\n return `urn:ietf:params:oauth:jwk-thumbprint:sha-${digestAlgorithm.slice(-3)}:${thumbprint}`;\n}\n","import { importJWK } from '../key/import.js';\nimport isObject from '../lib/is_object.js';\nimport { JWSInvalid } from '../util/errors.js';\nexport async function EmbeddedJWK(protectedHeader, token) {\n const joseHeader = {\n ...protectedHeader,\n ...token?.header,\n };\n if (!isObject(joseHeader.jwk)) {\n throw new JWSInvalid('\"jwk\" (JSON Web Key) Header Parameter must be a JSON object');\n }\n const key = await importJWK({ ...joseHeader.jwk, ext: true }, joseHeader.alg);\n if (key instanceof Uint8Array || key.type !== 'public') {\n throw new JWSInvalid('\"jwk\" (JSON Web Key) Header Parameter must be a public key');\n }\n return key;\n}\n","import { importJWK } from '../key/import.js';\nimport { JWKSInvalid, JOSENotSupported, JWKSNoMatchingKey, JWKSMultipleMatchingKeys, } from '../util/errors.js';\nimport isObject from '../lib/is_object.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 default:\n throw new JOSENotSupported('Unsupported \"alg\" value for a JSON Web Key Set');\n }\n}\nexport function 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}\nfunction clone(obj) {\n if (typeof structuredClone === 'function') {\n return structuredClone(obj);\n }\n return JSON.parse(JSON.stringify(obj));\n}\nexport class 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 = clone(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') {\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 && alg === 'EdDSA') {\n candidate = jwk.crv === 'Ed25519' || jwk.crv === 'Ed448';\n }\n if (candidate) {\n switch (alg) {\n case 'ES256':\n candidate = jwk.crv === 'P-256';\n break;\n case 'ES256K':\n candidate = jwk.crv === 'secp256k1';\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 }\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;\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 return async (protectedHeader, token) => set.getKey(protectedHeader, token);\n}\n","import * as http from 'node:http';\nimport * as https from 'node:https';\nimport { once } from 'node:events';\nimport { JOSEError, JWKSTimeout } from '../util/errors.js';\nimport { concat, decoder } from '../lib/buffer_utils.js';\nconst fetchJwks = async (url, timeout, options) => {\n let get;\n switch (url.protocol) {\n case 'https:':\n get = https.get;\n break;\n case 'http:':\n get = http.get;\n break;\n default:\n throw new TypeError('Unsupported URL protocol.');\n }\n const { agent, headers } = options;\n const req = get(url.href, {\n agent,\n timeout,\n headers,\n });\n const [response] = (await Promise.race([once(req, 'response'), once(req, 'timeout')]));\n if (!response) {\n req.destroy();\n throw new JWKSTimeout();\n }\n if (response.statusCode !== 200) {\n throw new JOSEError('Expected 200 OK from the JSON Web Key Set HTTP response');\n }\n const parts = [];\n for await (const part of response) {\n parts.push(part);\n }\n try {\n return JSON.parse(decoder.decode(concat(...parts)));\n }\n catch {\n throw new JOSEError('Failed to parse the JSON Web Key Set HTTP response as JSON');\n }\n};\nexport default fetchJwks;\n","import fetchJwks from '../runtime/fetch_jwks.js';\nimport { JWKSInvalid, JWKSNoMatchingKey } from '../util/errors.js';\nimport { isJWKSLike, LocalJWKSet } from './local.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 = 'v5.2.3';\n USER_AGENT = `${NAME}/${VERSION}`;\n}\nclass RemoteJWKSet extends LocalJWKSet {\n _url;\n _timeoutDuration;\n _cooldownDuration;\n _cacheMaxAge;\n _jwksTimestamp;\n _pendingFetch;\n _options;\n constructor(url, options) {\n super({ keys: [] });\n this._jwks = undefined;\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._options = { agent: options?.agent, headers: options?.headers };\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 }\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 async getKey(protectedHeader, token) {\n if (!this._jwks || !this.fresh()) {\n await this.reload();\n }\n try {\n return await super.getKey(protectedHeader, token);\n }\n catch (err) {\n if (err instanceof JWKSNoMatchingKey) {\n if (this.coolingDown() === false) {\n await this.reload();\n return super.getKey(protectedHeader, token);\n }\n }\n throw err;\n }\n }\n async reload() {\n if (this._pendingFetch && isCloudflareWorkers()) {\n this._pendingFetch = undefined;\n }\n const headers = new Headers(this._options.headers);\n if (USER_AGENT && !headers.has('User-Agent')) {\n headers.set('User-Agent', USER_AGENT);\n this._options.headers = Object.fromEntries(headers.entries());\n }\n this._pendingFetch ||= fetchJwks(this._url, this._timeoutDuration, this._options)\n .then((json) => {\n if (!isJWKSLike(json)) {\n throw new JWKSInvalid('JSON Web Key Set malformed');\n }\n this._jwks = { keys: json.keys };\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 return async (protectedHeader, token) => set.getKey(protectedHeader, token);\n}\n","import * as base64url from '../runtime/base64url.js';\nimport { decoder } from '../lib/buffer_utils.js';\nimport { JWTInvalid } from '../util/errors.js';\nimport jwtPayload from '../lib/jwt_claims_set.js';\nimport { ProduceJWT } from './produce.js';\nexport class UnsecuredJWT extends ProduceJWT {\n encode() {\n const header = base64url.encode(JSON.stringify({ alg: 'none' }));\n const payload = base64url.encode(JSON.stringify(this._payload));\n return `${header}.${payload}.`;\n }\n static decode(jwt, options) {\n if (typeof jwt !== 'string') {\n throw new JWTInvalid('Unsecured JWT must be a string');\n }\n const { 0: encodedHeader, 1: encodedPayload, 2: signature, length } = jwt.split('.');\n if (length !== 3 || signature !== '') {\n throw new JWTInvalid('Invalid Unsecured JWT');\n }\n let header;\n try {\n header = JSON.parse(decoder.decode(base64url.decode(encodedHeader)));\n if (header.alg !== 'none')\n throw new Error();\n }\n catch {\n throw new JWTInvalid('Invalid Unsecured JWT');\n }\n const payload = jwtPayload(header, base64url.decode(encodedPayload), options);\n return { payload, header };\n }\n}\n","import * as base64url from '../runtime/base64url.js';\nexport const encode = base64url.encode;\nexport const decode = base64url.decode;\n","import { decode as base64url } from './base64url.js';\nimport { decoder } from '../lib/buffer_utils.js';\nimport isObject from '../lib/is_object.js';\nexport function decodeProtectedHeader(token) {\n let protectedB64u;\n if (typeof token === 'string') {\n const parts = token.split('.');\n if (parts.length === 3 || parts.length === 5) {\n ;\n [protectedB64u] = parts;\n }\n }\n else if (typeof token === 'object' && token) {\n if ('protected' in token) {\n protectedB64u = token.protected;\n }\n else {\n throw new TypeError('Token does not contain a Protected Header');\n }\n }\n try {\n if (typeof protectedB64u !== 'string' || !protectedB64u) {\n throw new Error();\n }\n const result = JSON.parse(decoder.decode(base64url(protectedB64u)));\n if (!isObject(result)) {\n throw new Error();\n }\n return result;\n }\n catch {\n throw new TypeError('Invalid Token or Protected Header formatting');\n }\n}\n","import { decode as base64url } from './base64url.js';\nimport { decoder } from '../lib/buffer_utils.js';\nimport isObject from '../lib/is_object.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 = base64url(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","import { createSecretKey, generateKeyPair as generateKeyPairCb } from 'node:crypto';\nimport { promisify } from 'node:util';\nimport random from './random.js';\nimport { JOSENotSupported } from '../util/errors.js';\nconst generate = promisify(generateKeyPairCb);\nexport async function generateSecret(alg, options) {\n let length;\n switch (alg) {\n case 'HS256':\n case 'HS384':\n case 'HS512':\n case 'A128CBC-HS256':\n case 'A192CBC-HS384':\n case 'A256CBC-HS512':\n length = parseInt(alg.slice(-3), 10);\n break;\n case 'A128KW':\n case 'A192KW':\n case 'A256KW':\n case 'A128GCMKW':\n case 'A192GCMKW':\n case 'A256GCMKW':\n case 'A128GCM':\n case 'A192GCM':\n case 'A256GCM':\n length = parseInt(alg.slice(1, 4), 10);\n break;\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n return createSecretKey(random(new Uint8Array(length >> 3)));\n}\nexport async function generateKeyPair(alg, options) {\n switch (alg) {\n case 'RS256':\n case 'RS384':\n case 'RS512':\n case 'PS256':\n case 'PS384':\n case 'PS512':\n case 'RSA-OAEP':\n case 'RSA-OAEP-256':\n case 'RSA-OAEP-384':\n case 'RSA-OAEP-512':\n case 'RSA1_5': {\n const modulusLength = options?.modulusLength ?? 2048;\n if (typeof modulusLength !== 'number' || modulusLength < 2048) {\n throw new JOSENotSupported('Invalid or unsupported modulusLength option provided, 2048 bits or larger keys must be used');\n }\n const keypair = await generate('rsa', {\n modulusLength,\n publicExponent: 0x10001,\n });\n return keypair;\n }\n case 'ES256':\n return generate('ec', { namedCurve: 'P-256' });\n case 'ES256K':\n return generate('ec', { namedCurve: 'secp256k1' });\n case 'ES384':\n return generate('ec', { namedCurve: 'P-384' });\n case 'ES512':\n return generate('ec', { namedCurve: 'P-521' });\n case 'EdDSA': {\n switch (options?.crv) {\n case undefined:\n case 'Ed25519':\n return generate('ed25519');\n case 'Ed448':\n return generate('ed448');\n default:\n throw new JOSENotSupported('Invalid or unsupported crv option provided, supported values are Ed25519 and Ed448');\n }\n }\n case 'ECDH-ES':\n case 'ECDH-ES+A128KW':\n case 'ECDH-ES+A192KW':\n case 'ECDH-ES+A256KW': {\n const crv = options?.crv ?? 'P-256';\n switch (crv) {\n case undefined:\n case 'P-256':\n case 'P-384':\n case 'P-521':\n return generate('ec', { namedCurve: crv });\n case 'X25519':\n return generate('x25519');\n case 'X448':\n return generate('x448');\n default:\n throw new JOSENotSupported('Invalid or unsupported crv option provided, supported values are P-256, P-384, P-521, X25519, and X448');\n }\n }\n default:\n throw new JOSENotSupported('Invalid or unsupported JWK \"alg\" (Algorithm) Parameter value');\n }\n}\n","import { generateKeyPair as generate } from '../runtime/generate.js';\nexport async function generateKeyPair(alg, options) {\n return generate(alg, options);\n}\n","import { generateSecret as generate } from '../runtime/generate.js';\nexport async function generateSecret(alg, options) {\n return generate(alg, options);\n}\n","export default 'node:crypto';\n","import value from '../runtime/runtime.js';\nexport default value;\n"],"mappings":"yCAAA,OAAS,UAAAA,OAAc,cCAvB,OAAS,cAAAC,OAAkB,cAC3B,IAAMC,GAAS,CAACC,EAAWC,IAASH,GAAWE,CAAS,EAAE,OAAOC,CAAI,EAAE,OAAO,EACvEC,GAAQH,GCDR,IAAMI,EAAU,IAAI,YACdC,EAAU,IAAI,YACrBC,GAAY,GAAK,GAChB,SAASC,KAAUC,EAAS,CAC/B,IAAMC,EAAOD,EAAQ,OAAO,CAACE,EAAK,CAAE,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OL,EAAS,SAAS,EAC7B,IAAK,QACD,OAAOA,EAAS,OAAO,EAC3B,QACI,MAAM,IAAIO,EAAiB,oFAAoF,CACvH,CAEJ,IAAK,UACL,IAAK,iBACL,IAAK,iBACL,IAAK,iBAAkB,CACnB,IAAMK,EAAMP,GAAS,KAAO,QAC5B,OAAQO,EAAK,CACT,KAAK,OACL,IAAK,QACL,IAAK,QACL,IAAK,QACD,OAAOZ,EAAS,KAAM,CAAE,WAAYY,CAAI,CAAC,EAC7C,IAAK,SACD,OAAOZ,EAAS,QAAQ,EAC5B,IAAK,OACD,OAAOA,EAAS,MAAM,EAC1B,QACI,MAAM,IAAIO,EAAiB,wGAAwG,CAC3I,CACJ,CACA,QACI,MAAM,IAAIA,EAAiB,8DAA8D,CACjG,CACJ,CC/FA,eAAsBM,GAAgBC,EAAKC,EAAS,CAChD,OAAOF,GAASC,EAAKC,CAAO,CAChC,CCFA,eAAsBC,GAAeC,EAAKC,EAAS,CAC/C,OAAOF,GAASC,EAAKC,CAAO,CAChC,CCHA,IAAOC,GAAQ,cCCf,IAAOC,GAAQA","names":["Buffer","createHash","digest","algorithm","data","digest_default","encoder","decoder","MAX_INT32","concat","buffers","size","acc","length","buf","i","buffer","p2s","alg","p2sInput","writeUInt32BE","value","offset","uint64be","high","low","uint32be","lengthAndInput","input","concatKdf","secret","bits","iterations","res","iter","digest_default","normalize","input","encoded","decoder","encode","Buffer","decode","input","Buffer","normalize","createDecipheriv","KeyObject","errors_exports","__export","JOSEAlgNotAllowed","JOSEError","JOSENotSupported","JWEDecryptionFailed","JWEInvalid","JWKInvalid","JWKSInvalid","JWKSMultipleMatchingKeys","JWKSNoMatchingKey","JWKSTimeout","JWSInvalid","JWSSignatureVerificationFailed","JWTClaimValidationFailed","JWTExpired","JWTInvalid","message","claim","reason","randomFillSync","bitLength","alg","JOSENotSupported","iv_default","randomFillSync","checkIvLength","enc","iv","bitLength","JWEInvalid","check_iv_length_default","util","is_key_object_default","obj","checkCekLength","enc","cek","expected","JOSENotSupported","actual","JWEInvalid","is_key_object_default","check_cek_length_default","impl","timingSafeEqual","timing_safe_equal_default","createHmac","cbcTag","aad","iv","ciphertext","macSize","macKey","keySize","macData","concat","uint64be","hmac","createHmac","crypto","util","webcrypto","webcrypto_default","isCryptoKey","key","unusable","name","prop","isAlgorithm","algorithm","getHashLength","hash","getNamedCurve","alg","checkUsage","key","usages","expected","msg","last","checkSigCryptoKey","checkEncCryptoKey","message","msg","actual","types","last","invalid_key_input_default","withAlg","alg","getCiphers","ciphers","ciphers_default","algorithm","is_key_like_default","key","is_key_object_default","isCryptoKey","types","webcrypto_default","cbcDecrypt","enc","cek","ciphertext","iv","tag","aad","keySize","is_key_object_default","encKey","macKey","macSize","algorithm","ciphers_default","JOSENotSupported","expectedTag","cbcTag","macCheckPassed","timing_safe_equal_default","JWEDecryptionFailed","plaintext","decipher","createDecipheriv","concat","gcmDecrypt","decrypt","key","isCryptoKey","checkEncCryptoKey","KeyObject","invalid_key_input_default","types","JWEInvalid","check_cek_length_default","check_iv_length_default","decrypt_default","isDisjoint","headers","sources","acc","header","parameters","parameter","is_disjoint_default","isObjectLike","value","isObject","input","proto","Buffer","KeyObject","createDecipheriv","createCipheriv","createSecretKey","checkKeySize","key","alg","ensureKeyObject","usage","is_key_object_default","createSecretKey","isCryptoKey","checkEncCryptoKey","KeyObject","invalid_key_input_default","types","wrap","cek","algorithm","ciphers_default","JOSENotSupported","keyObject","cipher","createCipheriv","Buffer","concat","unwrap","encryptedKey","createDecipheriv","diffieHellman","generateKeyPairCb","KeyObject","promisify","KeyObject","namedCurveToJOSE","namedCurve","JOSENotSupported","getNamedCurve","kee","raw","key","isCryptoKey","KeyObject","is_key_object_default","invalid_key_input_default","types","get_named_curve_default","generateKeyPair","promisify","generateKeyPairCb","deriveKey","publicKee","privateKee","algorithm","keyLength","apu","apv","publicKey","isCryptoKey","checkEncCryptoKey","KeyObject","is_key_object_default","invalid_key_input_default","types","privateKey","value","concat","lengthAndInput","encoder","uint32be","sharedSecret","diffieHellman","concatKdf","generateEpk","kee","key","namedCurve","get_named_curve_default","JOSENotSupported","ecdhAllowed","promisify","KeyObject","pbkdf2cb","checkP2s","p2s","JWEInvalid","pbkdf2","promisify","pbkdf2cb","getPassword","key","alg","is_key_object_default","isCryptoKey","checkEncCryptoKey","KeyObject","invalid_key_input_default","types","encrypt","cek","p2c","p2s","randomFillSync","checkP2s","salt","keylen","password","derivedKey","wrap","encode","decrypt","encryptedKey","unwrap","KeyObject","publicEncrypt","constants","privateDecrypt","deprecate","check_key_length_default","key","alg","modulusLength","checkKey","key","alg","check_key_length_default","RSA1_5","deprecate","constants","resolvePadding","resolveOaepHash","ensureKeyObject","usages","is_key_object_default","isCryptoKey","checkEncCryptoKey","KeyObject","invalid_key_input_default","types","encrypt","cek","padding","oaepHash","keyObject","publicEncrypt","decrypt","encryptedKey","privateDecrypt","bitLength","alg","JOSENotSupported","cek_default","randomFillSync","createPrivateKey","createPublicKey","KeyObject","Buffer","genericExport","keyType","keyFormat","key","keyObject","isCryptoKey","KeyObject","is_key_object_default","invalid_key_input_default","types","toSPKI","toPKCS8","fromPKCS8","pem","createPrivateKey","Buffer","fromSPKI","createPublicKey","fromX509","createPrivateKey","createPublicKey","parse","jwk","jwk_to_key_default","importSPKI","spki","alg","options","fromSPKI","importX509","x509","fromX509","importPKCS8","pkcs8","fromPKCS8","importJWK","jwk","isObject","decode","JOSENotSupported","jwk_to_key_default","symmetricTypeCheck","alg","key","is_key_like_default","withAlg","types","asymmetricTypeCheck","usage","checkKeyType","check_key_type_default","createCipheriv","KeyObject","cbcEncrypt","enc","plaintext","cek","iv","aad","keySize","is_key_object_default","encKey","macKey","algorithm","ciphers_default","JOSENotSupported","cipher","createCipheriv","ciphertext","concat","macSize","tag","cbcTag","gcmEncrypt","encrypt","key","isCryptoKey","checkEncCryptoKey","KeyObject","invalid_key_input_default","types","check_cek_length_default","check_iv_length_default","iv_default","encrypt_default","wrap","alg","key","cek","iv","jweAlgorithm","wrapped","encrypt_default","encode","unwrap","encryptedKey","tag","decrypt_default","decryptKeyManagement","alg","key","encryptedKey","joseHeader","options","check_key_type_default","JWEInvalid","isObject","ecdhAllowed","JOSENotSupported","epk","importJWK","partyUInfo","partyVInfo","decode","sharedSecret","deriveKey","bitLength","unwrap","decrypt","p2cLimit","p2s","iv","tag","decrypt_key_management_default","validateCrit","Err","recognizedDefault","recognizedOption","protectedHeader","joseHeader","input","recognized","parameter","JOSENotSupported","validate_crit_default","validateAlgorithms","option","algorithms","s","validate_algorithms_default","flattenedDecrypt","jwe","key","options","isObject","JWEInvalid","parsedProt","protectedHeader","decode","decoder","is_disjoint_default","joseHeader","validate_crit_default","JOSENotSupported","alg","enc","keyManagementAlgorithms","validate_algorithms_default","contentEncryptionAlgorithms","JOSEAlgNotAllowed","encryptedKey","resolvedKey","cek","decrypt_key_management_default","err","cek_default","iv","tag","encoder","additionalData","concat","ciphertext","result","decrypt_default","compactDecrypt","jwe","key","options","decoder","JWEInvalid","protectedHeader","encryptedKey","iv","ciphertext","tag","length","decrypted","flattenedDecrypt","result","generalDecrypt","jwe","key","options","isObject","JWEInvalid","recipient","flattenedDecrypt","JWEDecryptionFailed","KeyObject","keyToJWK","key","keyObject","isCryptoKey","KeyObject","is_key_object_default","encode","invalid_key_input_default","types","JOSENotSupported","key_to_jwk_default","exportSPKI","key","toSPKI","exportPKCS8","toPKCS8","exportJWK","key_to_jwk_default","encryptKeyManagement","alg","enc","key","providedCek","providedParameters","encryptedKey","parameters","cek","check_key_type_default","ecdhAllowed","JOSENotSupported","apu","apv","ephemeralKey","generateEpk","x","y","crv","kty","exportJWK","sharedSecret","deriveKey","bitLength","encode","cek_default","kwAlg","wrap","encrypt","p2c","p2s","iv","encrypt_key_management_default","unprotected","FlattenedEncrypt","plaintext","parameters","protectedHeader","sharedUnprotectedHeader","unprotectedHeader","aad","cek","iv","key","options","JWEInvalid","is_disjoint_default","joseHeader","validate_crit_default","JOSENotSupported","alg","enc","encryptedKey","encrypt_key_management_default","additionalData","aadMember","encoder","encode","concat","ciphertext","tag","encrypt_default","jwe","decoder","IndividualRecipient","enc","key","options","unprotectedHeader","args","GeneralEncrypt","plaintext","recipient","protectedHeader","sharedUnprotectedHeader","aad","JWEInvalid","flattened","FlattenedEncrypt","jwe","i","is_disjoint_default","joseHeader","alg","validate_crit_default","JOSENotSupported","cek","cek_default","target","p2c","unprotected","encryptedKey","parameters","encrypt_key_management_default","encode","crypto","promisify","dsaDigest","alg","JOSENotSupported","constants","PSS","constants","ecCurveAlgMap","keyForCrypto","alg","key","check_key_length_default","hashAlgorithm","mgf1HashAlgorithm","saltLength","length","actual","get_named_curve_default","expected","JOSENotSupported","crypto","promisify","hmacDigest","alg","JOSENotSupported","KeyObject","createSecretKey","getSignVerifyKey","alg","key","usage","invalid_key_input_default","types","createSecretKey","KeyObject","isCryptoKey","checkSigCryptoKey","oneShotSign","promisify","sign","alg","key","data","keyObject","getSignVerifyKey","hmac","hmacDigest","dsaDigest","keyForCrypto","sign_default","oneShotVerify","promisify","verify","alg","key","signature","data","keyObject","getSignVerifyKey","expected","sign_default","actual","algorithm","dsaDigest","keyInput","keyForCrypto","verify_default","flattenedVerify","jws","key","options","isObject","JWSInvalid","parsedProt","protectedHeader","decode","decoder","is_disjoint_default","joseHeader","extensions","validate_crit_default","b64","alg","algorithms","validate_algorithms_default","JOSEAlgNotAllowed","resolvedKey","check_key_type_default","data","concat","encoder","signature","verify_default","JWSSignatureVerificationFailed","payload","result","compactVerify","jws","key","options","decoder","JWSInvalid","protectedHeader","payload","signature","length","verified","flattenedVerify","result","generalVerify","jws","key","options","isObject","JWSInvalid","signature","flattenedVerify","JWSSignatureVerificationFailed","epoch_default","date","REGEX","secs_default","str","matched","value","unit","numericDate","normalizeTyp","value","checkAudiencePresence","audPayload","audOption","jwt_claims_set_default","protectedHeader","encodedPayload","options","typ","JWTClaimValidationFailed","payload","decoder","isObject","JWTInvalid","requiredClaims","issuer","subject","audience","maxTokenAge","presenceCheck","claim","tolerance","secs_default","currentDate","now","epoch_default","JWTExpired","age","max","jwtVerify","jwt","key","options","verified","compactVerify","JWTInvalid","result","jwt_claims_set_default","jwtDecrypt","jwt","key","options","decrypted","compactDecrypt","payload","jwt_claims_set_default","protectedHeader","JWTClaimValidationFailed","result","CompactEncrypt","plaintext","FlattenedEncrypt","cek","iv","protectedHeader","parameters","key","options","jwe","FlattenedSign","payload","protectedHeader","unprotectedHeader","key","options","JWSInvalid","is_disjoint_default","joseHeader","extensions","validate_crit_default","b64","alg","check_key_type_default","encoder","encode","data","concat","signature","sign_default","jws","decoder","CompactSign","payload","FlattenedSign","protectedHeader","key","options","jws","IndividualSignature","sig","key","options","protectedHeader","unprotectedHeader","args","GeneralSign","payload","signature","JWSInvalid","jws","i","flattened","FlattenedSign","rest","validateInput","label","input","ProduceJWT","payload","isObject","issuer","subject","audience","jwtId","epoch_default","secs_default","SignJWT","ProduceJWT","protectedHeader","key","options","sig","CompactSign","encoder","JWTInvalid","EncryptJWT","ProduceJWT","protectedHeader","parameters","cek","iv","key","options","enc","CompactEncrypt","encoder","check","value","description","JWKInvalid","calculateJwkThumbprint","jwk","digestAlgorithm","isObject","components","JOSENotSupported","data","encoder","encode","digest_default","calculateJwkThumbprintUri","thumbprint","EmbeddedJWK","protectedHeader","token","joseHeader","isObject","JWSInvalid","key","importJWK","getKtyFromAlg","alg","JOSENotSupported","isJWKSLike","jwks","isJWKLike","key","isObject","clone","obj","LocalJWKSet","JWKSInvalid","protectedHeader","token","kid","kty","candidates","jwk","candidate","length","JWKSNoMatchingKey","error","JWKSMultipleMatchingKeys","_cached","importWithAlgCache","cache","cached","importJWK","createLocalJWKSet","set","http","https","once","fetchJwks","url","timeout","options","get","agent","headers","req","response","once","JWKSTimeout","JOSEError","parts","part","decoder","concat","fetch_jwks_default","isCloudflareWorkers","USER_AGENT","RemoteJWKSet","LocalJWKSet","url","options","protectedHeader","token","err","JWKSNoMatchingKey","headers","fetch_jwks_default","json","isJWKSLike","JWKSInvalid","createRemoteJWKSet","set","UnsecuredJWT","ProduceJWT","header","encode","payload","jwt","options","JWTInvalid","encodedHeader","encodedPayload","signature","length","decoder","decode","jwt_claims_set_default","base64url_exports","__export","decode","encode","encode","decode","decodeProtectedHeader","token","protectedB64u","parts","result","decoder","decode","isObject","decodeJwt","jwt","JWTInvalid","payload","length","decoded","decode","result","decoder","isObject","createSecretKey","generateKeyPairCb","promisify","generate","promisify","generateKeyPairCb","generateSecret","alg","options","length","JOSENotSupported","createSecretKey","randomFillSync","generateKeyPair","modulusLength","crv","generateKeyPair","alg","options","generateSecret","alg","options","runtime_default","runtime_default"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire as _createRequire } from 'node:module';
|
|
2
|
+
const require = _createRequire(import.meta.url);
|
|
3
|
+
import{a as D}from"./chunk-ZORLYW6M.js";import{a as b}from"./chunk-OWEB37KH.js";import"./chunk-A3KHJIN7.js";import{a as S,e as y,f as I,m as x,n as j}from"./chunk-J2KSZ5LE.js";import"./chunk-A7TURNR5.js";import{D as v,Ua as P,fb as U,g as w,ha as h,ra as n}from"./chunk-5JYQ2Z7Y.js";import{b as C,d as a,e as s}from"./chunk-2JOP4YNL.js";import{e as u,h as r}from"./chunk-V4TR6DCM.js";r();r();import{cwd as N}from"node:process";var c=u(C(),1);r();var T=u(C(),1);async function A(e,m,o){let t=new S(m),i=await y({siteId:o,projectFolder:e.projectFolder,siteListClient:t});return(0,T.match)(i,{NotConfigured:()=>{throw new a({code:s.SiteConfiguredRequired()})},NotFound:()=>{throw new a({code:s.SiteConfiguredRequired()})},Resolved:({site:f})=>f})}r();var d=u(C(),1);var E=({model:e,site:m,tag:o})=>{let t=e.components.filter((0,d.isType)(n.DashboardPage)||(0,d.isType)(n.DashboardPlugin)||(0,d.isType)(n.DashboardMenuPlugin)),i={appId:e.config.appId,site:m,tag:o};return t[0]?j({envConfig:i,extension:t[0]}):x({envConfig:i,platformType:h.Dashboard()})};r();function M(e){console.log(e)}async function z(e,m){let o=await U(N()),t=await v();if(!t)throw new a({code:s.AuthenticationRequired()});m.errorReporter.setUser({id:t.userInfo.userId}),b(m.biLogger,t.userInfo.userId);let i=w({type:"backoffice",getAppToken:()=>t.getAccessToken()}),f=await A(o,i,e.siteId),k=o.components.filter(g=>(0,c.isType)(g,n.Api)||(0,c.isType)(g,n.Event)||(0,c.isType)(g,n.ServicePlugin)),{serveUrl:R,backendServerUrl:F}=e.baseUrl?{serveUrl:e.baseUrl,backendServerUrl:void 0}:await P(o.config.appId,o.projectFolder,m.biLogger,i,k.length>0),L=new I(i),q=await D({model:o,arm:L,serveUrl:R,backendServerUrl:F}),H=E({site:f,model:o,tag:q});M(H)}export{z as nonInteractivePreview};
|
|
4
|
+
//# sourceMappingURL=preview-5HAC2VHN.js.map
|