diff --git a/.gitattributes b/.gitattributes index ee453ae8b3683b334cb3056043a13ad96f6d18ca..6acf8f3d112a4cc18ceda860d3801dfd3988a6ef 100644 --- a/.gitattributes +++ b/.gitattributes @@ -58,3 +58,6 @@ node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node node_modules/@rolldown/binding-linux-x64-musl/rolldown-binding.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text node_modules/@rollup/rollup-linux-x64-gnu/rollup.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text node_modules/@rollup/rollup-linux-x64-musl/rollup.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text +node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node filter=lfs diff=lfs merge=lfs -text +node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node filter=lfs diff=lfs merge=lfs -text +node_modules/@trivago/prettier-plugin-sort-imports/.yarn/install-state.gz filter=lfs diff=lfs merge=lfs -text diff --git a/node_modules/@simplewebauthn/server/script/helpers/decodeCredentialPublicKey.js b/node_modules/@simplewebauthn/server/script/helpers/decodeCredentialPublicKey.js new file mode 100644 index 0000000000000000000000000000000000000000..c45eee32b08e1262fb3e376b11d4fe2577afc529 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/decodeCredentialPublicKey.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports._decodeCredentialPublicKeyInternals = void 0; +exports.decodeCredentialPublicKey = decodeCredentialPublicKey; +const index_js_1 = require("./iso/index.js"); +function decodeCredentialPublicKey(publicKey) { + return exports._decodeCredentialPublicKeyInternals.stubThis(index_js_1.isoCBOR.decodeFirst(publicKey)); +} +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +exports._decodeCredentialPublicKeyInternals = { + stubThis: (value) => value, +}; diff --git a/node_modules/@simplewebauthn/server/script/helpers/fetch.d.ts b/node_modules/@simplewebauthn/server/script/helpers/fetch.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee4f94663f07066ca34023cda92eee4b07c1bd06 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/fetch.d.ts @@ -0,0 +1,13 @@ +/** + * A simple method for requesting data via standard `fetch`. Should work + * across multiple runtimes. + */ +export declare function fetch(url: string): Promise; +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +export declare const _fetchInternals: { + stubThis: (url: string) => Promise; +}; +//# sourceMappingURL=fetch.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/fetch.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/fetch.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f5494bb75fd427704476426d34b9770f4602020c --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/fetch.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/helpers/fetch.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAEpD;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe;oBACV,MAAM;CACvB,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/fetch.js b/node_modules/@simplewebauthn/server/script/helpers/fetch.js new file mode 100644 index 0000000000000000000000000000000000000000..a753c0d038db4d59f4a4b66e197094515e010a5a --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/fetch.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports._fetchInternals = void 0; +exports.fetch = fetch; +/** + * A simple method for requesting data via standard `fetch`. Should work + * across multiple runtimes. + */ +function fetch(url) { + return exports._fetchInternals.stubThis(url); +} +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +exports._fetchInternals = { + stubThis: (url) => globalThis.fetch(url), +}; diff --git a/node_modules/@simplewebauthn/server/script/helpers/generateChallenge.d.ts b/node_modules/@simplewebauthn/server/script/helpers/generateChallenge.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0b37847f71d8875f069908ab7bc46d89466071a9 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/generateChallenge.d.ts @@ -0,0 +1,13 @@ +import type { Uint8Array_ } from '../types/index.js'; +/** + * Generate a suitably random value to be used as an attestation or assertion challenge + */ +export declare function generateChallenge(): Promise; +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +export declare const _generateChallengeInternals: { + stubThis: (value: Uint8Array_) => Uint8Array; +}; +//# sourceMappingURL=generateChallenge.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/generateChallenge.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/generateChallenge.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..9eb5fda80c53a60bf9299df0794ecfd0e069a737 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/generateChallenge.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"generateChallenge.d.ts","sourceRoot":"","sources":["../../src/helpers/generateChallenge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,WAAW,CAAC,CAc9D;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B;sBACpB,WAAW;CAC9B,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/generateChallenge.js b/node_modules/@simplewebauthn/server/script/helpers/generateChallenge.js new file mode 100644 index 0000000000000000000000000000000000000000..68043f33fe31fcc0ead6b96943185bbbb3abb608 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/generateChallenge.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports._generateChallengeInternals = void 0; +exports.generateChallenge = generateChallenge; +const index_js_1 = require("./iso/index.js"); +/** + * Generate a suitably random value to be used as an attestation or assertion challenge + */ +async function generateChallenge() { + /** + * WebAuthn spec says that 16 bytes is a good minimum: + * + * "In order to prevent replay attacks, the challenges MUST contain enough entropy to make + * guessing them infeasible. Challenges SHOULD therefore be at least 16 bytes long." + * + * Just in case, let's double it + */ + const challenge = new Uint8Array(32); + await index_js_1.isoCrypto.getRandomValues(challenge); + return exports._generateChallengeInternals.stubThis(challenge); +} +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +exports._generateChallengeInternals = { + stubThis: (value) => value, +}; diff --git a/node_modules/@simplewebauthn/server/script/helpers/generateUserID.d.ts b/node_modules/@simplewebauthn/server/script/helpers/generateUserID.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b3350933ef9abb223e9ba7904a1fae8081eb3eb --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/generateUserID.d.ts @@ -0,0 +1,13 @@ +import type { Uint8Array_ } from '../types/index.js'; +/** + * Generate a suitably random value to be used as user ID + */ +export declare function generateUserID(): Promise; +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +export declare const _generateUserIDInternals: { + stubThis: (value: Uint8Array_) => Uint8Array; +}; +//# sourceMappingURL=generateUserID.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/generateUserID.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/generateUserID.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..777c1664afc447bf0f4d408f56a7acac08ab5b4c --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/generateUserID.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"generateUserID.d.ts","sourceRoot":"","sources":["../../src/helpers/generateUserID.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC,CAU3D;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB;sBACjB,WAAW;CAC9B,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/generateUserID.js b/node_modules/@simplewebauthn/server/script/helpers/generateUserID.js new file mode 100644 index 0000000000000000000000000000000000000000..d3a24e06faacbbf2b0ff1978d93840619f651771 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/generateUserID.js @@ -0,0 +1,24 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports._generateUserIDInternals = void 0; +exports.generateUserID = generateUserID; +const index_js_1 = require("./iso/index.js"); +/** + * Generate a suitably random value to be used as user ID + */ +async function generateUserID() { + /** + * WebAuthn spec says user.id has a max length of 64 bytes. I prefer how 32 random bytes look + * after they're base64url-encoded so I'm choosing to go with that here. + */ + const newUserID = new Uint8Array(32); + await index_js_1.isoCrypto.getRandomValues(newUserID); + return exports._generateUserIDInternals.stubThis(newUserID); +} +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +exports._generateUserIDInternals = { + stubThis: (value) => value, +}; diff --git a/node_modules/@simplewebauthn/server/script/helpers/getCertificateInfo.d.ts b/node_modules/@simplewebauthn/server/script/helpers/getCertificateInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..480bcba6b464d50d313867236c66622f4395b91e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/getCertificateInfo.d.ts @@ -0,0 +1,33 @@ +import { Certificate } from '@peculiar/asn1-x509'; +import type { Uint8Array_ } from '../types/index.js'; +export type CertificateInfo = { + issuer: Issuer; + subject: Subject; + version: number; + basicConstraintsCA: boolean; + notBefore: Date; + notAfter: Date; + parsedCertificate: Certificate; +}; +type Issuer = { + C?: string; + O?: string; + OU?: string; + CN?: string; + combined: string; +}; +type Subject = { + C?: string; + O?: string; + OU?: string; + CN?: string; + combined: string; +}; +/** + * Extract PEM certificate info + * + * @param pemCertificate Result from call to `convertASN1toPEM(x5c[0])` + */ +export declare function getCertificateInfo(leafCertBuffer: Uint8Array_): CertificateInfo; +export {}; +//# sourceMappingURL=getCertificateInfo.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/getCertificateInfo.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/getCertificateInfo.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..23fde1cb810ceefba3c6f99de760654bd7bc858e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/getCertificateInfo.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"getCertificateInfo.d.ts","sourceRoot":"","sources":["../../src/helpers/getCertificateInfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,WAAW,EAA0B,MAAM,qBAAqB,CAAC;AAE5F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,SAAS,EAAE,IAAI,CAAC;IAChB,QAAQ,EAAE,IAAI,CAAC;IACf,iBAAiB,EAAE,WAAW,CAAC;CAChC,CAAC;AAEF,KAAK,MAAM,GAAG;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,OAAO,GAAG;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AASF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,cAAc,EAAE,WAAW,GAC1B,eAAe,CA+CjB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/getCertificateInfo.js b/node_modules/@simplewebauthn/server/script/helpers/getCertificateInfo.js new file mode 100644 index 0000000000000000000000000000000000000000..72d9d40a7f738a3f65ee8c116d27473f935c6066 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/getCertificateInfo.js @@ -0,0 +1,80 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getCertificateInfo = getCertificateInfo; +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const issuerSubjectIDKey = { + '2.5.4.6': 'C', + '2.5.4.10': 'O', + '2.5.4.11': 'OU', + '2.5.4.3': 'CN', +}; +/** + * Extract PEM certificate info + * + * @param pemCertificate Result from call to `convertASN1toPEM(x5c[0])` + */ +function getCertificateInfo(leafCertBuffer) { + const x509 = asn1_schema_1.AsnParser.parse(leafCertBuffer, asn1_x509_1.Certificate); + const parsedCert = x509.tbsCertificate; + // Issuer + const issuer = { combined: '' }; + parsedCert.issuer.forEach(([iss]) => { + const key = issuerSubjectIDKey[iss.type]; + if (key) { + issuer[key] = iss.value.toString(); + } + }); + issuer.combined = issuerSubjectToString(issuer); + // Subject + const subject = { combined: '' }; + parsedCert.subject.forEach(([iss]) => { + const key = issuerSubjectIDKey[iss.type]; + if (key) { + subject[key] = iss.value.toString(); + } + }); + subject.combined = issuerSubjectToString(subject); + let basicConstraintsCA = false; + if (parsedCert.extensions) { + // console.log(parsedCert.extensions); + for (const ext of parsedCert.extensions) { + if (ext.extnID === asn1_x509_1.id_ce_basicConstraints) { + const basicConstraints = asn1_schema_1.AsnParser.parse(ext.extnValue, asn1_x509_1.BasicConstraints); + basicConstraintsCA = basicConstraints.cA; + } + } + } + return { + issuer, + subject, + version: parsedCert.version, + basicConstraintsCA, + notBefore: parsedCert.validity.notBefore.getTime(), + notAfter: parsedCert.validity.notAfter.getTime(), + parsedCertificate: x509, + }; +} +/** + * Stringify the parts of Issuer or Subject info for easier comparison of subject issuers with + * issuer subjects. + * + * The order might seem arbitrary, because it is. It should be enough that the two are stringified + * in the same order. + */ +function issuerSubjectToString(input) { + const parts = []; + if (input.C) { + parts.push(input.C); + } + if (input.O) { + parts.push(input.O); + } + if (input.OU) { + parts.push(input.OU); + } + if (input.CN) { + parts.push(input.CN); + } + return parts.join(' : '); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/index.d.ts b/node_modules/@simplewebauthn/server/script/helpers/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1297a5259ce1f6fa685a4ee32fdc810a349b94be --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/index.d.ts @@ -0,0 +1,18 @@ +export * from './convertAAGUIDToString.js'; +export * from './convertCertBufferToPEM.js'; +export * from './convertCOSEtoPKCS.js'; +export * from './decodeAttestationObject.js'; +export * from './decodeClientDataJSON.js'; +export * from './decodeCredentialPublicKey.js'; +export * from './generateChallenge.js'; +export * from './generateUserID.js'; +export * from './getCertificateInfo.js'; +export * from './isCertRevoked.js'; +export * from './parseAuthenticatorData.js'; +export * from './toHash.js'; +export * from './validateCertificatePath.js'; +export * from './verifySignature.js'; +export * from './iso/index.js'; +export * from '../metadata/verifyMDSBlob.js'; +export * as cose from './cose.js'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/index.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..ae168084e7148bb1d994565d156ff1aafd9c110e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,8BAA8B,CAAC;AAC7C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/index.js b/node_modules/@simplewebauthn/server/script/helpers/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e547a466283f8ce8eabef70b1f2b85e266e31d15 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/index.js @@ -0,0 +1,46 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.cose = void 0; +__exportStar(require("./convertAAGUIDToString.js"), exports); +__exportStar(require("./convertCertBufferToPEM.js"), exports); +__exportStar(require("./convertCOSEtoPKCS.js"), exports); +__exportStar(require("./decodeAttestationObject.js"), exports); +__exportStar(require("./decodeClientDataJSON.js"), exports); +__exportStar(require("./decodeCredentialPublicKey.js"), exports); +__exportStar(require("./generateChallenge.js"), exports); +__exportStar(require("./generateUserID.js"), exports); +__exportStar(require("./getCertificateInfo.js"), exports); +__exportStar(require("./isCertRevoked.js"), exports); +__exportStar(require("./parseAuthenticatorData.js"), exports); +__exportStar(require("./toHash.js"), exports); +__exportStar(require("./validateCertificatePath.js"), exports); +__exportStar(require("./verifySignature.js"), exports); +__exportStar(require("./iso/index.js"), exports); +__exportStar(require("../metadata/verifyMDSBlob.js"), exports); +exports.cose = __importStar(require("./cose.js")); diff --git a/node_modules/@simplewebauthn/server/script/helpers/isCertRevoked.d.ts b/node_modules/@simplewebauthn/server/script/helpers/isCertRevoked.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2d1c2bf3957acba59c9f0332d0d65e00ab4e7d9e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/isCertRevoked.d.ts @@ -0,0 +1,9 @@ +import { type X509Certificate } from '@peculiar/x509'; +/** + * A method to pull a CRL from a certificate and compare its serial number to the list of revoked + * certificate serial numbers within the CRL. + * + * CRL certificate structure referenced from https://tools.ietf.org/html/rfc5280#page-117 + */ +export declare function isCertRevoked(cert: X509Certificate): Promise; +//# sourceMappingURL=isCertRevoked.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/isCertRevoked.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/isCertRevoked.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..74516b92258e14ee6c4e82287f559a13ed28e28d --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/isCertRevoked.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"isCertRevoked.d.ts","sourceRoot":"","sources":["../../src/helpers/isCertRevoked.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAexB;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAkG3E"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/isCertRevoked.js b/node_modules/@simplewebauthn/server/script/helpers/isCertRevoked.js new file mode 100644 index 0000000000000000000000000000000000000000..e7d59fd1dc642fb7dcda4782e65c37b6f1db5bd5 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/isCertRevoked.js @@ -0,0 +1,99 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isCertRevoked = isCertRevoked; +const x509_1 = require("@peculiar/x509"); +const fetch_js_1 = require("./fetch.js"); +const cacheRevokedCerts = {}; +/** + * A method to pull a CRL from a certificate and compare its serial number to the list of revoked + * certificate serial numbers within the CRL. + * + * CRL certificate structure referenced from https://tools.ietf.org/html/rfc5280#page-117 + */ +async function isCertRevoked(cert) { + const { extensions } = cert; + if (!extensions) { + return false; + } + let extAuthorityKeyID; + let extSubjectKeyID; + let extCRLDistributionPoints; + extensions.forEach((ext) => { + if (ext instanceof x509_1.AuthorityKeyIdentifierExtension) { + extAuthorityKeyID = ext; + } + else if (ext instanceof x509_1.SubjectKeyIdentifierExtension) { + extSubjectKeyID = ext; + } + else if (ext instanceof x509_1.CRLDistributionPointsExtension) { + extCRLDistributionPoints = ext; + } + }); + // Check to see if we've got cached info for the cert's CA + let keyIdentifier = undefined; + if (extAuthorityKeyID && extAuthorityKeyID.keyId) { + keyIdentifier = extAuthorityKeyID.keyId; + } + else if (extSubjectKeyID) { + /** + * We might be dealing with a self-signed root certificate. Check the + * Subject key Identifier extension next. + */ + keyIdentifier = extSubjectKeyID.keyId; + } + if (keyIdentifier) { + const cached = cacheRevokedCerts[keyIdentifier]; + if (cached) { + const now = new Date(); + // If there's a nextUpdate then make sure we're before it + if (!cached.nextUpdate || cached.nextUpdate > now) { + return cached.revokedCerts.indexOf(cert.serialNumber) >= 0; + } + } + } + const crlURL = extCRLDistributionPoints?.distributionPoints?.[0].distributionPoint?.fullName?.[0] + .uniformResourceIdentifier; + // If no URL is provided then we have nothing to check + if (!crlURL) { + return false; + } + // Download and read the CRL + let certListBytes; + try { + const respCRL = await (0, fetch_js_1.fetch)(crlURL); + certListBytes = await respCRL.arrayBuffer(); + } + catch (_err) { + return false; + } + let data; + try { + data = new x509_1.X509Crl(certListBytes); + } + catch (_err) { + // Something was malformed with the CRL, so pass + return false; + } + const newCached = { + revokedCerts: [], + nextUpdate: undefined, + }; + // nextUpdate + if (data.nextUpdate) { + newCached.nextUpdate = data.nextUpdate; + } + // revokedCertificates + const revokedCerts = data.entries; + if (revokedCerts) { + for (const cert of revokedCerts) { + const revokedHex = cert.serialNumber; + newCached.revokedCerts.push(revokedHex); + } + // Cache the results + if (keyIdentifier) { + cacheRevokedCerts[keyIdentifier] = newCached; + } + return newCached.revokedCerts.indexOf(cert.serialNumber) >= 0; + } + return false; +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/index.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7ad61a1bb28ab04559b8d90857737160dc7afc97 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/index.d.ts @@ -0,0 +1,12 @@ +/** + * A collection of methods for isomorphic manipulation of trickier data types + * + * The goal with these is to make it easier to replace dependencies later that might not play well + * with specific server-like runtimes that expose global Web APIs (CloudFlare Workers, Deno, Bun, + * etc...), while also supporting execution in Node. + */ +export * as isoBase64URL from './isoBase64URL.js'; +export * as isoCBOR from './isoCBOR.js'; +export * as isoCrypto from './isoCrypto/index.js'; +export * as isoUint8Array from './isoUint8Array.js'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/index.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..ee4f18b17cac403b5127964d1acb48e582cfefe5 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/iso/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/index.js b/node_modules/@simplewebauthn/server/script/helpers/iso/index.js new file mode 100644 index 0000000000000000000000000000000000000000..bd0039ab8e30175f8d04168c03e1e1ec31acc148 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/index.js @@ -0,0 +1,37 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.isoUint8Array = exports.isoCrypto = exports.isoCBOR = exports.isoBase64URL = void 0; +/** + * A collection of methods for isomorphic manipulation of trickier data types + * + * The goal with these is to make it easier to replace dependencies later that might not play well + * with specific server-like runtimes that expose global Web APIs (CloudFlare Workers, Deno, Bun, + * etc...), while also supporting execution in Node. + */ +exports.isoBase64URL = __importStar(require("./isoBase64URL.js")); +exports.isoCBOR = __importStar(require("./isoCBOR.js")); +exports.isoCrypto = __importStar(require("./isoCrypto/index.js")); +exports.isoUint8Array = __importStar(require("./isoUint8Array.js")); diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoBase64URL.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoBase64URL.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..085e34cdfb075883f4e14f6e4d07087b161f1313 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoBase64URL.d.ts @@ -0,0 +1,43 @@ +import type { Base64URLString, Uint8Array_ } from '../../types/index.js'; +/** + * Decode from a Base64URL-encoded string to an ArrayBuffer. Best used when converting a + * credential ID from a JSON string to an ArrayBuffer, like in allowCredentials or + * excludeCredentials. + * + * @param buffer Value to decode from base64 + * @param to (optional) The decoding to use, in case it's desirable to decode from base64 instead + */ +export declare function toBuffer(base64urlString: string, from?: 'base64' | 'base64url'): Uint8Array_; +/** + * Encode the given array buffer into a Base64URL-encoded string. Ideal for converting various + * credential response ArrayBuffers to string for sending back to the server as JSON. + * + * @param buffer Value to encode to base64 + * @param to (optional) The encoding to use, in case it's desirable to encode to base64 instead + */ +export declare function fromBuffer(buffer: Uint8Array_, to?: 'base64' | 'base64url'): string; +/** + * Convert a base64url string into base64 + */ +export declare function toBase64(base64urlString: string): string; +/** + * Encode a UTF-8 string to base64url + */ +export declare function fromUTF8String(utf8String: string): string; +/** + * Decode a base64url string into its original UTF-8 string + */ +export declare function toUTF8String(base64urlString: string): string; +/** + * Confirm that the string is encoded into base64 + */ +export declare function isBase64(input: string): boolean; +/** + * Confirm that the string is encoded into base64url, with support for optional padding + */ +export declare function isBase64URL(input: string): boolean; +/** + * Remove optional padding from a base64url-encoded string + */ +export declare function trimPadding(input: Base64URLString): Base64URLString; +//# sourceMappingURL=isoBase64URL.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoBase64URL.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoBase64URL.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8636ef644c3a50676c43901b45dd775940aceca1 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoBase64URL.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"isoBase64URL.d.ts","sourceRoot":"","sources":["../../../src/helpers/iso/isoBase64URL.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEzE;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,eAAe,EAAE,MAAM,EACvB,IAAI,GAAE,QAAQ,GAAG,WAAyB,GACzC,WAAW,CAGb;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,WAAW,EACnB,EAAE,GAAE,QAAQ,GAAG,WAAyB,GACvC,MAAM,CAOR;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAIxD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,eAAe,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAIlD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,eAAe,CAEnE"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoBase64URL.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoBase64URL.js new file mode 100644 index 0000000000000000000000000000000000000000..bce4ffef7464072807f731ebf51ba04b965cf00b --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoBase64URL.js @@ -0,0 +1,85 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toBuffer = toBuffer; +exports.fromBuffer = fromBuffer; +exports.toBase64 = toBase64; +exports.fromUTF8String = fromUTF8String; +exports.toUTF8String = toUTF8String; +exports.isBase64 = isBase64; +exports.isBase64URL = isBase64URL; +exports.trimPadding = trimPadding; +/** + * A runtime-agnostic collection of methods for working with Base64URL encoding + * @module + */ +const base64_1 = __importDefault(require("@hexagon/base64")); +/** + * Decode from a Base64URL-encoded string to an ArrayBuffer. Best used when converting a + * credential ID from a JSON string to an ArrayBuffer, like in allowCredentials or + * excludeCredentials. + * + * @param buffer Value to decode from base64 + * @param to (optional) The decoding to use, in case it's desirable to decode from base64 instead + */ +function toBuffer(base64urlString, from = 'base64url') { + const _buffer = base64_1.default.toArrayBuffer(base64urlString, from === 'base64url'); + return new Uint8Array(_buffer); +} +/** + * Encode the given array buffer into a Base64URL-encoded string. Ideal for converting various + * credential response ArrayBuffers to string for sending back to the server as JSON. + * + * @param buffer Value to encode to base64 + * @param to (optional) The encoding to use, in case it's desirable to encode to base64 instead + */ +function fromBuffer(buffer, to = 'base64url') { + /** + * Gracefully handle Uint8Array subclass types, like Node's Buffer, that can have a large + * ArrayBuffer backing it. + */ + const _normalized = new Uint8Array(buffer); + return base64_1.default.fromArrayBuffer(_normalized.buffer, to === 'base64url'); +} +/** + * Convert a base64url string into base64 + */ +function toBase64(base64urlString) { + const fromBase64Url = base64_1.default.toArrayBuffer(base64urlString, true); + const toBase64 = base64_1.default.fromArrayBuffer(fromBase64Url); + return toBase64; +} +/** + * Encode a UTF-8 string to base64url + */ +function fromUTF8String(utf8String) { + return base64_1.default.fromString(utf8String, true); +} +/** + * Decode a base64url string into its original UTF-8 string + */ +function toUTF8String(base64urlString) { + return base64_1.default.toString(base64urlString, true); +} +/** + * Confirm that the string is encoded into base64 + */ +function isBase64(input) { + return base64_1.default.validate(input, false); +} +/** + * Confirm that the string is encoded into base64url, with support for optional padding + */ +function isBase64URL(input) { + // Trim padding characters from the string if present + input = trimPadding(input); + return base64_1.default.validate(input, true); +} +/** + * Remove optional padding from a base64url-encoded string + */ +function trimPadding(input) { + return input.replace(/=/g, ''); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCBOR.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCBOR.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b9441fb7626adc29cda5a206ff5c480ef177fdb7 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCBOR.d.ts @@ -0,0 +1,29 @@ +/** + * A runtime-agnostic collection of methods for working with CBOR encoding + * @module + */ +import * as tinyCbor from '@levischuck/tiny-cbor'; +import type { Uint8Array_ } from '../../types/index.js'; +/** + * Whatever CBOR encoder is used should keep CBOR data the same length when data is re-encoded + * + * MOST CRITICALLY, this means the following needs to be true of whatever CBOR library we use: + * - CBOR Map type values MUST decode to JavaScript Maps + * - CBOR tag 64 (uint8 Typed Array) MUST NOT be used when encoding Uint8Arrays back to CBOR + * + * So long as these requirements are maintained, then CBOR sequences can be encoded and decoded + * freely while maintaining their lengths for the most accurate pointer movement across them. + */ +/** + * Decode and return the first item in a sequence of CBOR-encoded values + * + * @param input The CBOR data to decode + * @param asObject (optional) Whether to convert any CBOR Maps into JavaScript Objects. Defaults to + * `false` + */ +export declare function decodeFirst(input: Uint8Array_): Type; +/** + * Encode data to CBOR + */ +export declare function encode(input: tinyCbor.CBORType): Uint8Array_; +//# sourceMappingURL=isoCBOR.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCBOR.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCBOR.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..0aad3bc552672c5fe63b2b52a7189e28aa1cb2c2 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCBOR.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"isoCBOR.d.ts","sourceRoot":"","sources":["../../../src/helpers/iso/isoCBOR.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAC;AAElD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;;;;;GASG;AAEH;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAQ1D;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,GAAG,WAAW,CAE5D"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCBOR.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCBOR.js new file mode 100644 index 0000000000000000000000000000000000000000..0828832f45eec8ab8c805edd6ef0f325704a3119 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCBOR.js @@ -0,0 +1,62 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.decodeFirst = decodeFirst; +exports.encode = encode; +/** + * A runtime-agnostic collection of methods for working with CBOR encoding + * @module + */ +const tinyCbor = __importStar(require("@levischuck/tiny-cbor")); +/** + * Whatever CBOR encoder is used should keep CBOR data the same length when data is re-encoded + * + * MOST CRITICALLY, this means the following needs to be true of whatever CBOR library we use: + * - CBOR Map type values MUST decode to JavaScript Maps + * - CBOR tag 64 (uint8 Typed Array) MUST NOT be used when encoding Uint8Arrays back to CBOR + * + * So long as these requirements are maintained, then CBOR sequences can be encoded and decoded + * freely while maintaining their lengths for the most accurate pointer movement across them. + */ +/** + * Decode and return the first item in a sequence of CBOR-encoded values + * + * @param input The CBOR data to decode + * @param asObject (optional) Whether to convert any CBOR Maps into JavaScript Objects. Defaults to + * `false` + */ +function decodeFirst(input) { + // Make a copy so we don't mutate the original + const _input = new Uint8Array(input); + const decoded = tinyCbor.decodePartialCBOR(_input, 0); + const [first] = decoded; + return first; +} +/** + * Encode data to CBOR + */ +function encode(input) { + return tinyCbor.encodeCBOR(input); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/digest.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/digest.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7dab1d51c0f683dc6795ac3e0b8b56d2221d21e7 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/digest.d.ts @@ -0,0 +1,10 @@ +import type { COSEALG } from '../../cose.js'; +import type { Uint8Array_ } from '../../../types/index.js'; +/** + * Generate a digest of the provided data. + * + * @param data The data to generate a digest of + * @param algorithm A COSE algorithm ID that maps to a desired SHA algorithm + */ +export declare function digest(data: Uint8Array_, algorithm: COSEALG): Promise; +//# sourceMappingURL=digest.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/digest.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/digest.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..49f3ef3607c1c9e1cbd8880d083c4e76fa71b10b --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/digest.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"digest.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/digest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;GAKG;AACH,wBAAsB,MAAM,CAC1B,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,OAAO,GACjB,OAAO,CAAC,WAAW,CAAC,CAQtB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/digest.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/digest.js new file mode 100644 index 0000000000000000000000000000000000000000..c8e9ee9b712410d8df32cc58680cbe0ed4301b18 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/digest.js @@ -0,0 +1,17 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.digest = digest; +const mapCoseAlgToWebCryptoAlg_js_1 = require("./mapCoseAlgToWebCryptoAlg.js"); +const getWebCrypto_js_1 = require("./getWebCrypto.js"); +/** + * Generate a digest of the provided data. + * + * @param data The data to generate a digest of + * @param algorithm A COSE algorithm ID that maps to a desired SHA algorithm + */ +async function digest(data, algorithm) { + const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)(); + const subtleAlgorithm = (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(algorithm); + const hashed = await WebCrypto.subtle.digest(subtleAlgorithm, data); + return new Uint8Array(hashed); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getRandomValues.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getRandomValues.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a7c210d427ab142a9bba342dd11def0e2961f018 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getRandomValues.d.ts @@ -0,0 +1,8 @@ +import type { Uint8Array_ } from '../../../types/index.js'; +/** + * Fill up the provided bytes array with random bytes equal to its length. + * + * @returns the same bytes array passed into the method + */ +export declare function getRandomValues(array: Uint8Array_): Promise; +//# sourceMappingURL=getRandomValues.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getRandomValues.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getRandomValues.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..fdb5d206a33313b41cf772b9e8c8c57a1ffed46b --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getRandomValues.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"getRandomValues.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/getRandomValues.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAM9E"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getRandomValues.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getRandomValues.js new file mode 100644 index 0000000000000000000000000000000000000000..030cf4ac5043b648c904811f6b18525a6d730e47 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getRandomValues.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getRandomValues = getRandomValues; +const getWebCrypto_js_1 = require("./getWebCrypto.js"); +/** + * Fill up the provided bytes array with random bytes equal to its length. + * + * @returns the same bytes array passed into the method + */ +async function getRandomValues(array) { + const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)(); + WebCrypto.getRandomValues(array); + return array; +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getWebCrypto.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getWebCrypto.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ccbb6326d1068ab5e7bb5cfacb51a6f8766bb46 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getWebCrypto.d.ts @@ -0,0 +1,14 @@ +import type { Crypto } from '../../../types/index.js'; +/** + * Try to get an instance of the Crypto API from the current runtime. Should support Node, + * as well as others, like Deno, that implement Web APIs. + */ +export declare function getWebCrypto(): Promise; +export declare class MissingWebCrypto extends Error { + constructor(); +} +export declare const _getWebCryptoInternals: { + stubThisGlobalThisCrypto: () => import("crypto").webcrypto.Crypto; + setCachedCrypto: (newCrypto: Crypto | undefined) => void; +}; +//# sourceMappingURL=getWebCrypto.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getWebCrypto.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getWebCrypto.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..b1a4a797bf67d97c4bbe72723114641cca2acf95 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getWebCrypto.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"getWebCrypto.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/getWebCrypto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAItD;;;GAGG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC,CAgC9C;AAED,qBAAa,gBAAiB,SAAQ,KAAK;;CAM1C;AAGD,eAAO,MAAM,sBAAsB;;iCAGJ,MAAM,GAAG,SAAS;CAGhD,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getWebCrypto.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getWebCrypto.js new file mode 100644 index 0000000000000000000000000000000000000000..bcc17cb95535800e93b249f1f7eccb450ef5f324 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/getWebCrypto.js @@ -0,0 +1,54 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports._getWebCryptoInternals = exports.MissingWebCrypto = void 0; +exports.getWebCrypto = getWebCrypto; +let webCrypto = undefined; +/** + * Try to get an instance of the Crypto API from the current runtime. Should support Node, + * as well as others, like Deno, that implement Web APIs. + */ +function getWebCrypto() { + /** + * Hello there! If you came here wondering why this method is asynchronous when use of + * `globalThis.crypto` is not, it's to minimize a bunch of refactor related to making this + * synchronous. For example, `generateRegistrationOptions()` and `generateAuthenticationOptions()` + * become synchronous if we make this synchronous (since nothing else in that method is async) + * which represents a breaking API change in this library's core API. + * + * TODO: If it's after February 2025 when you read this then consider whether it still makes sense + * to keep this method asynchronous. + */ + const toResolve = new Promise((resolve, reject) => { + if (webCrypto) { + return resolve(webCrypto); + } + /** + * Naively attempt to access Crypto as a global object, which popular ESM-centric run-times + * support (and Node v20+) + */ + const _globalThisCrypto = exports._getWebCryptoInternals.stubThisGlobalThisCrypto(); + if (_globalThisCrypto) { + webCrypto = _globalThisCrypto; + return resolve(webCrypto); + } + // We tried to access it both in Node and globally, so bail out + return reject(new MissingWebCrypto()); + }); + return toResolve; +} +class MissingWebCrypto extends Error { + constructor() { + const message = 'An instance of the Crypto API could not be located'; + super(message); + this.name = 'MissingWebCrypto'; + } +} +exports.MissingWebCrypto = MissingWebCrypto; +// Make it possible to stub return values during testing +exports._getWebCryptoInternals = { + stubThisGlobalThisCrypto: () => globalThis.crypto, + // Make it possible to reset the `webCrypto` at the top of the file + setCachedCrypto: (newCrypto) => { + webCrypto = newCrypto; + }, +}; diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/importKey.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/importKey.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2401d44dd4f9b51493a4e9180e1fb1233c4ff00c --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/importKey.d.ts @@ -0,0 +1,5 @@ +export declare function importKey(opts: { + keyData: JsonWebKey; + algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams; +}): Promise; +//# sourceMappingURL=importKey.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/importKey.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/importKey.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..40f49973aca9c347123c82ea636d5ad9eb28e9c4 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/importKey.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"importKey.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/importKey.ts"],"names":[],"mappings":"AAEA,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,iBAAiB,CAAC;CAC5E,GAAG,OAAO,CAAC,SAAS,CAAC,CAQrB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/importKey.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/importKey.js new file mode 100644 index 0000000000000000000000000000000000000000..6d5276b7634f20f90cfc93d6654ea3187a86b199 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/importKey.js @@ -0,0 +1,11 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.importKey = importKey; +const getWebCrypto_js_1 = require("./getWebCrypto.js"); +async function importKey(opts) { + const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)(); + const { keyData, algorithm } = opts; + return WebCrypto.subtle.importKey('jwk', keyData, algorithm, false, [ + 'verify', + ]); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/index.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e74dd3ff86829fa0e807c71b9c55e8ea85abf65 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/index.d.ts @@ -0,0 +1,8 @@ +/** + * A runtime-agnostic collection of methods for working with the WebCrypto API + * @module + */ +export { digest } from './digest.js'; +export { getRandomValues } from './getRandomValues.js'; +export { verify } from './verify.js'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/index.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..e7c72dfb0bd00dfe7b0a879035d6b699d629fe05 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/index.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/index.js new file mode 100644 index 0000000000000000000000000000000000000000..0a814c74ae14b876014706a807e91266cb98ba4b --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/index.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verify = exports.getRandomValues = exports.digest = void 0; +/** + * A runtime-agnostic collection of methods for working with the WebCrypto API + * @module + */ +var digest_js_1 = require("./digest.js"); +Object.defineProperty(exports, "digest", { enumerable: true, get: function () { return digest_js_1.digest; } }); +var getRandomValues_js_1 = require("./getRandomValues.js"); +Object.defineProperty(exports, "getRandomValues", { enumerable: true, get: function () { return getRandomValues_js_1.getRandomValues; } }); +var verify_js_1 = require("./verify.js"); +Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return verify_js_1.verify; } }); diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..65188c61f11461aca38dd74eecfa9e3a6a9d50a7 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts @@ -0,0 +1,7 @@ +import { SubtleCryptoAlg } from './structs.js'; +import { COSEALG } from '../../cose.js'; +/** + * Convert a COSE alg ID into a corresponding string value that WebCrypto APIs expect + */ +export declare function mapCoseAlgToWebCryptoAlg(alg: COSEALG): SubtleCryptoAlg; +//# sourceMappingURL=mapCoseAlgToWebCryptoAlg.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..eb97769be85130aebe3d5c127f463e739198a8e1 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"mapCoseAlgToWebCryptoAlg.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAetE"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js new file mode 100644 index 0000000000000000000000000000000000000000..b383bd9e455dc5bc556b391e02d0992b7c5ea495 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js @@ -0,0 +1,23 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mapCoseAlgToWebCryptoAlg = mapCoseAlgToWebCryptoAlg; +const cose_js_1 = require("../../cose.js"); +/** + * Convert a COSE alg ID into a corresponding string value that WebCrypto APIs expect + */ +function mapCoseAlgToWebCryptoAlg(alg) { + if ([cose_js_1.COSEALG.RS1].indexOf(alg) >= 0) { + return 'SHA-1'; + } + else if ([cose_js_1.COSEALG.ES256, cose_js_1.COSEALG.PS256, cose_js_1.COSEALG.RS256].indexOf(alg) >= 0) { + return 'SHA-256'; + } + else if ([cose_js_1.COSEALG.ES384, cose_js_1.COSEALG.PS384, cose_js_1.COSEALG.RS384].indexOf(alg) >= 0) { + return 'SHA-384'; + } + else if ([cose_js_1.COSEALG.ES512, cose_js_1.COSEALG.PS512, cose_js_1.COSEALG.RS512, cose_js_1.COSEALG.EdDSA].indexOf(alg) >= + 0) { + return 'SHA-512'; + } + throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto alg`); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..aff93860b716d39969c5a862d2964bb36626fc79 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts @@ -0,0 +1,7 @@ +import { COSEALG } from '../../cose.js'; +import { SubtleCryptoKeyAlgName } from './structs.js'; +/** + * Convert a COSE alg ID into a corresponding key algorithm string value that WebCrypto APIs expect + */ +export declare function mapCoseAlgToWebCryptoKeyAlgName(alg: COSEALG): SubtleCryptoKeyAlgName; +//# sourceMappingURL=mapCoseAlgToWebCryptoKeyAlgName.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..376b94bb48c955d08c1fe2bfc974ddbc30af8e64 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"mapCoseAlgToWebCryptoKeyAlgName.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,OAAO,GACX,sBAAsB,CAoBxB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js new file mode 100644 index 0000000000000000000000000000000000000000..e41484302f9de4465bbe2e95bd7e775320d08eaf --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js @@ -0,0 +1,22 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mapCoseAlgToWebCryptoKeyAlgName = mapCoseAlgToWebCryptoKeyAlgName; +const cose_js_1 = require("../../cose.js"); +/** + * Convert a COSE alg ID into a corresponding key algorithm string value that WebCrypto APIs expect + */ +function mapCoseAlgToWebCryptoKeyAlgName(alg) { + if ([cose_js_1.COSEALG.EdDSA].indexOf(alg) >= 0) { + return 'Ed25519'; + } + else if ([cose_js_1.COSEALG.ES256, cose_js_1.COSEALG.ES384, cose_js_1.COSEALG.ES512, cose_js_1.COSEALG.ES256K].indexOf(alg) >= 0) { + return 'ECDSA'; + } + else if ([cose_js_1.COSEALG.RS256, cose_js_1.COSEALG.RS384, cose_js_1.COSEALG.RS512, cose_js_1.COSEALG.RS1].indexOf(alg) >= 0) { + return 'RSASSA-PKCS1-v1_5'; + } + else if ([cose_js_1.COSEALG.PS256, cose_js_1.COSEALG.PS384, cose_js_1.COSEALG.PS512].indexOf(alg) >= 0) { + return 'RSA-PSS'; + } + throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto key alg name`); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/structs.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/structs.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4e68064dc26ee67de25625692b81d8b988d154c0 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/structs.d.ts @@ -0,0 +1,4 @@ +export type SubtleCryptoAlg = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512'; +export type SubtleCryptoCrv = 'P-256' | 'P-384' | 'P-521' | 'Ed25519'; +export type SubtleCryptoKeyAlgName = 'ECDSA' | 'Ed25519' | 'RSASSA-PKCS1-v1_5' | 'RSA-PSS'; +//# sourceMappingURL=structs.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/structs.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/structs.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..2ec1f4e30f80fbf1cb2f9be459370a5a6e3641c2 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/structs.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"structs.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/structs.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAC1E,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS,CAAC;AACtE,MAAM,MAAM,sBAAsB,GAC9B,OAAO,GACP,SAAS,GACT,mBAAmB,GACnB,SAAS,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/structs.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/structs.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/structs.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..58b63a1baf8d74f713d46d6919c504296fc1c288 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts @@ -0,0 +1,9 @@ +import { COSECRV } from '../../cose.js'; +import type { Uint8Array_ } from '../../../types/index.js'; +/** + * In WebAuthn, EC2 signatures are wrapped in ASN.1 structure so we need to peel r and s apart. + * + * See https://www.w3.org/TR/webauthn-2/#sctn-signature-attestation-types + */ +export declare function unwrapEC2Signature(signature: Uint8Array_, crv: COSECRV): Uint8Array_; +//# sourceMappingURL=unwrapEC2Signature.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4ab842a51b1a1d8d5d19a81a7b5f7f704c2f7ad0 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"unwrapEC2Signature.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/unwrapEC2Signature.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,OAAO,GAAG,WAAW,CAepF"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/unwrapEC2Signature.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/unwrapEC2Signature.js new file mode 100644 index 0000000000000000000000000000000000000000..dfd5af73a71d1740974242cb8becfd7a6ff7207b --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/unwrapEC2Signature.js @@ -0,0 +1,76 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.unwrapEC2Signature = unwrapEC2Signature; +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_ecc_1 = require("@peculiar/asn1-ecc"); +const cose_js_1 = require("../../cose.js"); +const index_js_1 = require("../index.js"); +/** + * In WebAuthn, EC2 signatures are wrapped in ASN.1 structure so we need to peel r and s apart. + * + * See https://www.w3.org/TR/webauthn-2/#sctn-signature-attestation-types + */ +function unwrapEC2Signature(signature, crv) { + const parsedSignature = asn1_schema_1.AsnParser.parse(signature, asn1_ecc_1.ECDSASigValue); + const rBytes = new Uint8Array(parsedSignature.r); + const sBytes = new Uint8Array(parsedSignature.s); + const componentLength = getSignatureComponentLength(crv); + const rNormalizedBytes = toNormalizedBytes(rBytes, componentLength); + const sNormalizedBytes = toNormalizedBytes(sBytes, componentLength); + const finalSignature = index_js_1.isoUint8Array.concat([ + rNormalizedBytes, + sNormalizedBytes, + ]); + return finalSignature; +} +/** + * The SubtleCrypto Web Crypto API expects ECDSA signatures with `r` and `s` values to be encoded + * to a specific length depending on the order of the curve. This function returns the expected + * byte-length for each of the `r` and `s` signature components. + * + * See + */ +function getSignatureComponentLength(crv) { + switch (crv) { + case cose_js_1.COSECRV.P256: + return 32; + case cose_js_1.COSECRV.P384: + return 48; + case cose_js_1.COSECRV.P521: + return 66; + default: + throw new Error(`Unexpected COSE crv value of ${crv} (EC2)`); + } +} +/** + * Converts the ASN.1 integer representation to bytes of a specific length `n`. + * + * DER encodes integers as big-endian byte arrays, with as small as possible representation and + * requires a leading `0` byte to disambiguate between negative and positive numbers. This means + * that `r` and `s` can potentially not be the expected byte-length that is needed by the + * SubtleCrypto Web Crypto API: if there are leading `0`s it can be shorter than expected, and if + * it has a leading `1` bit, it can be one byte longer. + * + * See + * See + */ +function toNormalizedBytes(bytes, componentLength) { + let normalizedBytes; + if (bytes.length < componentLength) { + // In case the bytes are shorter than expected, we need to pad it with leading `0`s. + normalizedBytes = new Uint8Array(componentLength); + normalizedBytes.set(bytes, componentLength - bytes.length); + } + else if (bytes.length === componentLength) { + normalizedBytes = bytes; + } + else if (bytes.length === componentLength + 1 && bytes[0] === 0 && (bytes[1] & 0x80) === 0x80) { + // The bytes contain a leading `0` to encode that the integer is positive. This leading `0` + // needs to be removed for compatibility with the SubtleCrypto Web Crypto API. + normalizedBytes = bytes.subarray(1); + } + else { + throw new Error(`Invalid signature component length ${bytes.length}, expected ${componentLength}`); + } + return normalizedBytes; +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verify.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verify.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f64e05ea6054631ec5c79cb3d51f781a41970fb6 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verify.d.ts @@ -0,0 +1,12 @@ +import { type COSEALG, type COSEPublicKey } from '../../cose.js'; +import type { Uint8Array_ } from '../../../types/index.js'; +/** + * Verify signatures with their public key. Supports EC2 and RSA public keys. + */ +export declare function verify(opts: { + cosePublicKey: COSEPublicKey; + signature: Uint8Array_; + data: Uint8Array_; + shaHashOverride?: COSEALG; +}): Promise; +//# sourceMappingURL=verify.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verify.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verify.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..65c9d7d6980da2c06ec7ca668d41992ff917e5d7 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verify.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAEZ,KAAK,aAAa,EAKnB,MAAM,eAAe,CAAC;AAKvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CAyBnB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verify.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verify.js new file mode 100644 index 0000000000000000000000000000000000000000..f660001e526a7819a3c2e30f1878d7f9536a1f45 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verify.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verify = verify; +const cose_js_1 = require("../../cose.js"); +const verifyEC2_js_1 = require("./verifyEC2.js"); +const verifyRSA_js_1 = require("./verifyRSA.js"); +const verifyOKP_js_1 = require("./verifyOKP.js"); +const unwrapEC2Signature_js_1 = require("./unwrapEC2Signature.js"); +/** + * Verify signatures with their public key. Supports EC2 and RSA public keys. + */ +function verify(opts) { + const { cosePublicKey, signature, data, shaHashOverride } = opts; + if ((0, cose_js_1.isCOSEPublicKeyEC2)(cosePublicKey)) { + const crv = cosePublicKey.get(cose_js_1.COSEKEYS.crv); + if (!(0, cose_js_1.isCOSECrv)(crv)) { + throw new Error(`unknown COSE curve ${crv}`); + } + const unwrappedSignature = (0, unwrapEC2Signature_js_1.unwrapEC2Signature)(signature, crv); + return (0, verifyEC2_js_1.verifyEC2)({ + cosePublicKey, + signature: unwrappedSignature, + data, + shaHashOverride, + }); + } + else if ((0, cose_js_1.isCOSEPublicKeyRSA)(cosePublicKey)) { + return (0, verifyRSA_js_1.verifyRSA)({ cosePublicKey, signature, data, shaHashOverride }); + } + else if ((0, cose_js_1.isCOSEPublicKeyOKP)(cosePublicKey)) { + return (0, verifyOKP_js_1.verifyOKP)({ cosePublicKey, signature, data }); + } + const kty = cosePublicKey.get(cose_js_1.COSEKEYS.kty); + throw new Error(`Signature verification with public key of kty ${kty} is not supported by this method`); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyEC2.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyEC2.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d6643412470a00b52ea5f787d66fb97a3af14c6 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyEC2.d.ts @@ -0,0 +1,12 @@ +import { type COSEALG, type COSEPublicKeyEC2 } from '../../cose.js'; +import type { Uint8Array_ } from '../../../types/index.js'; +/** + * Verify a signature using an EC2 public key + */ +export declare function verifyEC2(opts: { + cosePublicKey: COSEPublicKeyEC2; + signature: Uint8Array_; + data: Uint8Array_; + shaHashOverride?: COSEALG; +}): Promise; +//# sourceMappingURL=verifyEC2.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyEC2.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyEC2.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..c80307d915017aaf30947b07cdb8430a85c7cfa9 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyEC2.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyEC2.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyEC2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAMvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CA0EnB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyEC2.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyEC2.js new file mode 100644 index 0000000000000000000000000000000000000000..4eff623d5e978f296920433e0f446d24216edf7e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyEC2.js @@ -0,0 +1,76 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyEC2 = verifyEC2; +const cose_js_1 = require("../../cose.js"); +const mapCoseAlgToWebCryptoAlg_js_1 = require("./mapCoseAlgToWebCryptoAlg.js"); +const importKey_js_1 = require("./importKey.js"); +const index_js_1 = require("../index.js"); +const getWebCrypto_js_1 = require("./getWebCrypto.js"); +/** + * Verify a signature using an EC2 public key + */ +async function verifyEC2(opts) { + const { cosePublicKey, signature, data, shaHashOverride } = opts; + const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)(); + // Import the public key + const alg = cosePublicKey.get(cose_js_1.COSEKEYS.alg); + const crv = cosePublicKey.get(cose_js_1.COSEKEYS.crv); + const x = cosePublicKey.get(cose_js_1.COSEKEYS.x); + const y = cosePublicKey.get(cose_js_1.COSEKEYS.y); + if (!alg) { + throw new Error('Public key was missing alg (EC2)'); + } + if (!crv) { + throw new Error('Public key was missing crv (EC2)'); + } + if (!x) { + throw new Error('Public key was missing x (EC2)'); + } + if (!y) { + throw new Error('Public key was missing y (EC2)'); + } + let _crv; + if (crv === cose_js_1.COSECRV.P256) { + _crv = 'P-256'; + } + else if (crv === cose_js_1.COSECRV.P384) { + _crv = 'P-384'; + } + else if (crv === cose_js_1.COSECRV.P521) { + _crv = 'P-521'; + } + else { + throw new Error(`Unexpected COSE crv value of ${crv} (EC2)`); + } + const keyData = { + kty: 'EC', + crv: _crv, + x: index_js_1.isoBase64URL.fromBuffer(x), + y: index_js_1.isoBase64URL.fromBuffer(y), + ext: false, + }; + const keyAlgorithm = { + /** + * Note to future self: you can't use `mapCoseAlgToWebCryptoKeyAlgName()` here because some + * leaf certs from actual devices specified an RSA SHA value for `alg` (e.g. `-257`) which + * would then map here to `'RSASSA-PKCS1-v1_5'`. We always want `'ECDSA'` here so we'll + * hard-code this. + */ + name: 'ECDSA', + namedCurve: _crv, + }; + const key = await (0, importKey_js_1.importKey)({ + keyData, + algorithm: keyAlgorithm, + }); + // Determine which SHA algorithm to use for signature verification + let subtleAlg = (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(alg); + if (shaHashOverride) { + subtleAlg = (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(shaHashOverride); + } + const verifyAlgorithm = { + name: 'ECDSA', + hash: { name: subtleAlg }, + }; + return WebCrypto.subtle.verify(verifyAlgorithm, key, signature, data); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyOKP.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyOKP.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c7663f81170b8c07c0041cdb509d3a8838ba909 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyOKP.d.ts @@ -0,0 +1,8 @@ +import { type COSEPublicKeyOKP } from '../../cose.js'; +import type { Uint8Array_ } from '../../../types/index.js'; +export declare function verifyOKP(opts: { + cosePublicKey: COSEPublicKeyOKP; + signature: Uint8Array_; + data: Uint8Array_; +}): Promise; +//# sourceMappingURL=verifyOKP.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyOKP.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyOKP.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..fe778027ac68f06aa58514f9f5529a698b5b1da9 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyOKP.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyOKP.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyOKP.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAKpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;CACnB,GAAG,OAAO,CAAC,OAAO,CAAC,CAyDnB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyOKP.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyOKP.js new file mode 100644 index 0000000000000000000000000000000000000000..cc958034c90b82d1a2d7e02c695fb3de2f275b2d --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyOKP.js @@ -0,0 +1,54 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyOKP = verifyOKP; +const cose_js_1 = require("../../cose.js"); +const index_js_1 = require("../../index.js"); +const importKey_js_1 = require("./importKey.js"); +const getWebCrypto_js_1 = require("./getWebCrypto.js"); +async function verifyOKP(opts) { + const { cosePublicKey, signature, data } = opts; + const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)(); + const alg = cosePublicKey.get(cose_js_1.COSEKEYS.alg); + const crv = cosePublicKey.get(cose_js_1.COSEKEYS.crv); + const x = cosePublicKey.get(cose_js_1.COSEKEYS.x); + if (!alg) { + throw new Error('Public key was missing alg (OKP)'); + } + if (!(0, cose_js_1.isCOSEAlg)(alg)) { + throw new Error(`Public key had invalid alg ${alg} (OKP)`); + } + if (!crv) { + throw new Error('Public key was missing crv (OKP)'); + } + if (!x) { + throw new Error('Public key was missing x (OKP)'); + } + // Pulled key import steps from here: + // https://wicg.github.io/webcrypto-secure-curves/#ed25519-operations + let _crv; + if (crv === cose_js_1.COSECRV.ED25519) { + _crv = 'Ed25519'; + } + else { + throw new Error(`Unexpected COSE crv value of ${crv} (OKP)`); + } + const keyData = { + kty: 'OKP', + crv: _crv, + alg: 'EdDSA', + x: index_js_1.isoBase64URL.fromBuffer(x), + ext: false, + }; + const keyAlgorithm = { + name: _crv, + namedCurve: _crv, + }; + const key = await (0, importKey_js_1.importKey)({ + keyData, + algorithm: keyAlgorithm, + }); + const verifyAlgorithm = { + name: _crv, + }; + return WebCrypto.subtle.verify(verifyAlgorithm, key, signature, data); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyRSA.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyRSA.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..67ba29c2240f9ddea5744b6c0d8bed8e4b368c23 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyRSA.d.ts @@ -0,0 +1,12 @@ +import { type COSEALG, type COSEPublicKeyRSA } from '../../cose.js'; +import type { Uint8Array_ } from '../../../types/index.js'; +/** + * Verify a signature using an RSA public key + */ +export declare function verifyRSA(opts: { + cosePublicKey: COSEPublicKeyRSA; + signature: Uint8Array_; + data: Uint8Array_; + shaHashOverride?: COSEALG; +}): Promise; +//# sourceMappingURL=verifyRSA.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyRSA.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyRSA.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..5b78feaf25468fae03ce3ce02db26205366dcbc2 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyRSA.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyRSA.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/verifyRSA.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAY,KAAK,gBAAgB,EAAa,MAAM,eAAe,CAAC;AAMzF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE;IACpC,aAAa,EAAE,gBAAgB,CAAC;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,OAAO,CAAC,OAAO,CAAC,CA2FnB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyRSA.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyRSA.js new file mode 100644 index 0000000000000000000000000000000000000000..251a9e4b8b059d2c648d3b9585048eb1eb9b24c3 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoCrypto/verifyRSA.js @@ -0,0 +1,94 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyRSA = verifyRSA; +const cose_js_1 = require("../../cose.js"); +const mapCoseAlgToWebCryptoAlg_js_1 = require("./mapCoseAlgToWebCryptoAlg.js"); +const importKey_js_1 = require("./importKey.js"); +const index_js_1 = require("../index.js"); +const mapCoseAlgToWebCryptoKeyAlgName_js_1 = require("./mapCoseAlgToWebCryptoKeyAlgName.js"); +const getWebCrypto_js_1 = require("./getWebCrypto.js"); +/** + * Verify a signature using an RSA public key + */ +async function verifyRSA(opts) { + const { cosePublicKey, signature, data, shaHashOverride } = opts; + const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)(); + const alg = cosePublicKey.get(cose_js_1.COSEKEYS.alg); + const n = cosePublicKey.get(cose_js_1.COSEKEYS.n); + const e = cosePublicKey.get(cose_js_1.COSEKEYS.e); + if (!alg) { + throw new Error('Public key was missing alg (RSA)'); + } + if (!(0, cose_js_1.isCOSEAlg)(alg)) { + throw new Error(`Public key had invalid alg ${alg} (RSA)`); + } + if (!n) { + throw new Error('Public key was missing n (RSA)'); + } + if (!e) { + throw new Error('Public key was missing e (RSA)'); + } + const keyData = { + kty: 'RSA', + alg: '', + n: index_js_1.isoBase64URL.fromBuffer(n), + e: index_js_1.isoBase64URL.fromBuffer(e), + ext: false, + }; + const keyAlgorithm = { + name: (0, mapCoseAlgToWebCryptoKeyAlgName_js_1.mapCoseAlgToWebCryptoKeyAlgName)(alg), + hash: { name: (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(alg) }, + }; + const verifyAlgorithm = { + name: (0, mapCoseAlgToWebCryptoKeyAlgName_js_1.mapCoseAlgToWebCryptoKeyAlgName)(alg), + }; + if (shaHashOverride) { + keyAlgorithm.hash.name = (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(shaHashOverride); + } + if (keyAlgorithm.name === 'RSASSA-PKCS1-v1_5') { + if (keyAlgorithm.hash.name === 'SHA-256') { + keyData.alg = 'RS256'; + } + else if (keyAlgorithm.hash.name === 'SHA-384') { + keyData.alg = 'RS384'; + } + else if (keyAlgorithm.hash.name === 'SHA-512') { + keyData.alg = 'RS512'; + } + else if (keyAlgorithm.hash.name === 'SHA-1') { + keyData.alg = 'RS1'; + } + } + else if (keyAlgorithm.name === 'RSA-PSS') { + /** + * salt length. The default value is 20 but the convention is to use hLen, the length of the + * output of the hash function in bytes. A salt length of zero is permitted and will result in + * a deterministic signature value. The actual salt length used can be determined from the + * signature value. + * + * From https://www.cryptosys.net/pki/manpki/pki_rsaschemes.html + */ + let saltLength = 0; + if (keyAlgorithm.hash.name === 'SHA-256') { + keyData.alg = 'PS256'; + saltLength = 32; // 256 bits => 32 bytes + } + else if (keyAlgorithm.hash.name === 'SHA-384') { + keyData.alg = 'PS384'; + saltLength = 48; // 384 bits => 48 bytes + } + else if (keyAlgorithm.hash.name === 'SHA-512') { + keyData.alg = 'PS512'; + saltLength = 64; // 512 bits => 64 bytes + } + verifyAlgorithm.saltLength = saltLength; + } + else { + throw new Error(`Unexpected RSA key algorithm ${alg} (${keyAlgorithm.name})`); + } + const key = await (0, importKey_js_1.importKey)({ + keyData, + algorithm: keyAlgorithm, + }); + return WebCrypto.subtle.verify(verifyAlgorithm, key, signature, data); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoUint8Array.d.ts b/node_modules/@simplewebauthn/server/script/helpers/iso/isoUint8Array.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0edbf7984fc2d1ff577c0a93fdd3cbf34d2eb1ea --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoUint8Array.d.ts @@ -0,0 +1,42 @@ +import type { Uint8Array_ } from '../../types/index.js'; +/** + * A runtime-agnostic collection of methods for working with Uint8Arrays + * @module + */ +/** + * Make sure two Uint8Arrays are deeply equivalent + */ +export declare function areEqual(array1: Uint8Array_, array2: Uint8Array_): boolean; +/** + * Convert a Uint8Array to Hexadecimal. + * + * A replacement for `Buffer.toString('hex')` + */ +export declare function toHex(array: Uint8Array_): string; +/** + * Convert a hexadecimal string to isoUint8Array. + * + * A replacement for `Buffer.from('...', 'hex')` + */ +export declare function fromHex(hex: string): Uint8Array_; +/** + * Combine multiple Uint8Arrays into a single Uint8Array + */ +export declare function concat(arrays: Uint8Array_[]): Uint8Array_; +/** + * Convert bytes into a UTF-8 string + */ +export declare function toUTF8String(array: Uint8Array_): string; +/** + * Convert a UTF-8 string back into bytes + */ +export declare function fromUTF8String(utf8String: string): Uint8Array_; +/** + * Convert an ASCII string to Uint8Array + */ +export declare function fromASCIIString(value: string): Uint8Array_; +/** + * Prepare a DataView we can slice our way around in as we parse the bytes in a Uint8Array + */ +export declare function toDataView(array: Uint8Array_): DataView; +//# sourceMappingURL=isoUint8Array.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoUint8Array.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/iso/isoUint8Array.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..9d5e4a024648949967589ec48a82a30bf910068c --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoUint8Array.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"isoUint8Array.d.ts","sourceRoot":"","sources":["../../../src/helpers/iso/isoUint8Array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;GAGG;AAEH;;GAEG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAM1E;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAKhD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAehD;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,CAYzD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,CAGvD;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,CAG9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAE1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,WAAW,GAAG,QAAQ,CAEvD"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/iso/isoUint8Array.js b/node_modules/@simplewebauthn/server/script/helpers/iso/isoUint8Array.js new file mode 100644 index 0000000000000000000000000000000000000000..f68abe0e40d3a8e9fa56b5df07a95eb7ad1f4986 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/iso/isoUint8Array.js @@ -0,0 +1,89 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.areEqual = areEqual; +exports.toHex = toHex; +exports.fromHex = fromHex; +exports.concat = concat; +exports.toUTF8String = toUTF8String; +exports.fromUTF8String = fromUTF8String; +exports.fromASCIIString = fromASCIIString; +exports.toDataView = toDataView; +/** + * A runtime-agnostic collection of methods for working with Uint8Arrays + * @module + */ +/** + * Make sure two Uint8Arrays are deeply equivalent + */ +function areEqual(array1, array2) { + if (array1.length != array2.length) { + return false; + } + return array1.every((val, i) => val === array2[i]); +} +/** + * Convert a Uint8Array to Hexadecimal. + * + * A replacement for `Buffer.toString('hex')` + */ +function toHex(array) { + const hexParts = Array.from(array, (i) => i.toString(16).padStart(2, '0')); + // adce000235bcc60a648b0b25f1f05503 + return hexParts.join(''); +} +/** + * Convert a hexadecimal string to isoUint8Array. + * + * A replacement for `Buffer.from('...', 'hex')` + */ +function fromHex(hex) { + if (!hex) { + return Uint8Array.from([]); + } + const isValid = hex.length !== 0 && hex.length % 2 === 0 && + !/[^a-fA-F0-9]/u.test(hex); + if (!isValid) { + throw new Error('Invalid hex string'); + } + const byteStrings = hex.match(/.{1,2}/g) ?? []; + return Uint8Array.from(byteStrings.map((byte) => parseInt(byte, 16))); +} +/** + * Combine multiple Uint8Arrays into a single Uint8Array + */ +function concat(arrays) { + let pointer = 0; + const totalLength = arrays.reduce((prev, curr) => prev + curr.length, 0); + const toReturn = new Uint8Array(totalLength); + arrays.forEach((arr) => { + toReturn.set(arr, pointer); + pointer += arr.length; + }); + return toReturn; +} +/** + * Convert bytes into a UTF-8 string + */ +function toUTF8String(array) { + const decoder = new globalThis.TextDecoder('utf-8'); + return decoder.decode(array); +} +/** + * Convert a UTF-8 string back into bytes + */ +function fromUTF8String(utf8String) { + const encoder = new globalThis.TextEncoder(); + return encoder.encode(utf8String); +} +/** + * Convert an ASCII string to Uint8Array + */ +function fromASCIIString(value) { + return Uint8Array.from(value.split('').map((x) => x.charCodeAt(0))); +} +/** + * Prepare a DataView we can slice our way around in as we parse the bytes in a Uint8Array + */ +function toDataView(array) { + return new DataView(array.buffer, array.byteOffset, array.length); +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/logging.d.ts b/node_modules/@simplewebauthn/server/script/helpers/logging.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5a721ebc799b5172764667900babe9eecd499170 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/logging.d.ts @@ -0,0 +1,16 @@ +/** + * Generate an instance of a `debug` logger that extends off of the "simplewebauthn" namespace for + * consistent naming. + * + * See https://www.npmjs.com/package/debug for information on how to control logging output when + * using @simplewebauthn/server + * + * Example: + * + * ``` + * const log = getLogger('mds'); + * log('hello'); // simplewebauthn:mds hello +0ms + * ``` + */ +export declare function getLogger(_name: string): (message: string, ..._rest: unknown[]) => void; +//# sourceMappingURL=logging.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/logging.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/logging.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..91e9b378e760b821386683d4f643c2bc7c7c2033 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/logging.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/helpers/logging.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,OAAO,EAAE,KAAK,IAAI,CAGvF"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/logging.js b/node_modules/@simplewebauthn/server/script/helpers/logging.js new file mode 100644 index 0000000000000000000000000000000000000000..a9b701d2182470110c2b6e2e805fdce651e72850 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/logging.js @@ -0,0 +1,22 @@ +"use strict"; +// const defaultLogger = debug('SimpleWebAuthn'); +Object.defineProperty(exports, "__esModule", { value: true }); +exports.getLogger = getLogger; +/** + * Generate an instance of a `debug` logger that extends off of the "simplewebauthn" namespace for + * consistent naming. + * + * See https://www.npmjs.com/package/debug for information on how to control logging output when + * using @simplewebauthn/server + * + * Example: + * + * ``` + * const log = getLogger('mds'); + * log('hello'); // simplewebauthn:mds hello +0ms + * ``` + */ +function getLogger(_name) { + // This is a noop for now while I search for a better debug logger technique + return (_message, ..._rest) => { }; +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts b/node_modules/@simplewebauthn/server/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ca5bea7849c9c3b505be00920ae2b79308f4db5 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts @@ -0,0 +1,9 @@ +import { COSEALG } from './cose.js'; +/** + * Map X.509 signature algorithm OIDs to COSE algorithm IDs + * + * - EC2 OIDs: https://oidref.com/1.2.840.10045.4.3 + * - RSA OIDs: https://oidref.com/1.2.840.113549.1.1 + */ +export declare function mapX509SignatureAlgToCOSEAlg(signatureAlgorithm: string): COSEALG; +//# sourceMappingURL=mapX509SignatureAlgToCOSEAlg.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..41bdd730e05c8b3956f3addfbda8539c39334c0e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"mapX509SignatureAlgToCOSEAlg.d.ts","sourceRoot":"","sources":["../../src/helpers/mapX509SignatureAlgToCOSEAlg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC1C,kBAAkB,EAAE,MAAM,GACzB,OAAO,CAwBT"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/mapX509SignatureAlgToCOSEAlg.js b/node_modules/@simplewebauthn/server/script/helpers/mapX509SignatureAlgToCOSEAlg.js new file mode 100644 index 0000000000000000000000000000000000000000..baaaebeae346aa4e84fc57261ec4e0ea06944e94 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/mapX509SignatureAlgToCOSEAlg.js @@ -0,0 +1,38 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mapX509SignatureAlgToCOSEAlg = mapX509SignatureAlgToCOSEAlg; +const cose_js_1 = require("./cose.js"); +/** + * Map X.509 signature algorithm OIDs to COSE algorithm IDs + * + * - EC2 OIDs: https://oidref.com/1.2.840.10045.4.3 + * - RSA OIDs: https://oidref.com/1.2.840.113549.1.1 + */ +function mapX509SignatureAlgToCOSEAlg(signatureAlgorithm) { + let alg; + if (signatureAlgorithm === '1.2.840.10045.4.3.2') { + alg = cose_js_1.COSEALG.ES256; + } + else if (signatureAlgorithm === '1.2.840.10045.4.3.3') { + alg = cose_js_1.COSEALG.ES384; + } + else if (signatureAlgorithm === '1.2.840.10045.4.3.4') { + alg = cose_js_1.COSEALG.ES512; + } + else if (signatureAlgorithm === '1.2.840.113549.1.1.11') { + alg = cose_js_1.COSEALG.RS256; + } + else if (signatureAlgorithm === '1.2.840.113549.1.1.12') { + alg = cose_js_1.COSEALG.RS384; + } + else if (signatureAlgorithm === '1.2.840.113549.1.1.13') { + alg = cose_js_1.COSEALG.RS512; + } + else if (signatureAlgorithm === '1.2.840.113549.1.1.5') { + alg = cose_js_1.COSEALG.RS1; + } + else { + throw new Error(`Unable to map X.509 signature algorithm ${signatureAlgorithm} to a COSE algorithm`); + } + return alg; +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/matchExpectedRPID.d.ts b/node_modules/@simplewebauthn/server/script/helpers/matchExpectedRPID.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..df407c80f6dd7359fb52ab9316c201f29bf02441 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/matchExpectedRPID.d.ts @@ -0,0 +1,9 @@ +import type { Uint8Array_ } from '../types/index.js'; +/** + * Go through each expected RP ID and try to find one that matches. Returns the unhashed RP ID + * that matched the hash in the response. + * + * Raises an `UnexpectedRPIDHash` error if no match is found + */ +export declare function matchExpectedRPID(rpIDHash: Uint8Array_, expectedRPIDs: string[]): Promise; +//# sourceMappingURL=matchExpectedRPID.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/matchExpectedRPID.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/matchExpectedRPID.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..0b1634c16426bf2f357ad746b66cbc0ee5fd439a --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/matchExpectedRPID.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"matchExpectedRPID.d.ts","sourceRoot":"","sources":["../../src/helpers/matchExpectedRPID.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,WAAW,EACrB,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC,CA8BjB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/matchExpectedRPID.js b/node_modules/@simplewebauthn/server/script/helpers/matchExpectedRPID.js new file mode 100644 index 0000000000000000000000000000000000000000..691ef57d906aee48f242980857c2b1bc702b58e1 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/matchExpectedRPID.js @@ -0,0 +1,44 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.matchExpectedRPID = matchExpectedRPID; +const toHash_js_1 = require("./toHash.js"); +const index_js_1 = require("./iso/index.js"); +/** + * Go through each expected RP ID and try to find one that matches. Returns the unhashed RP ID + * that matched the hash in the response. + * + * Raises an `UnexpectedRPIDHash` error if no match is found + */ +async function matchExpectedRPID(rpIDHash, expectedRPIDs) { + try { + const matchedRPID = await Promise.any(expectedRPIDs.map((expected) => { + return new Promise((resolve, reject) => { + (0, toHash_js_1.toHash)(index_js_1.isoUint8Array.fromASCIIString(expected)).then((expectedRPIDHash) => { + if (index_js_1.isoUint8Array.areEqual(rpIDHash, expectedRPIDHash)) { + resolve(expected); + } + else { + reject(); + } + }); + }); + })); + return matchedRPID; + } + catch (err) { + const _err = err; + // This means no matches were found + if (_err.name === 'AggregateError') { + throw new UnexpectedRPIDHash(); + } + // An unexpected error occurred + throw err; + } +} +class UnexpectedRPIDHash extends Error { + constructor() { + const message = 'Unexpected RP ID hash'; + super(message); + this.name = 'UnexpectedRPIDHash'; + } +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/parseAuthenticatorData.d.ts b/node_modules/@simplewebauthn/server/script/helpers/parseAuthenticatorData.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..9a9c5898fb2ddafbdd1379061225f14339a5d7df --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/parseAuthenticatorData.d.ts @@ -0,0 +1,34 @@ +import { type AuthenticationExtensionsAuthenticatorOutputs } from './decodeAuthenticatorExtensions.js'; +import type { Uint8Array_ } from '../types/index.js'; +/** + * Make sense of the authData buffer contained in an Attestation + */ +export declare function parseAuthenticatorData(authData: Uint8Array_): ParsedAuthenticatorData; +export type ParsedAuthenticatorData = { + rpIdHash: Uint8Array_; + flagsBuf: Uint8Array_; + flags: { + up: boolean; + uv: boolean; + be: boolean; + bs: boolean; + at: boolean; + ed: boolean; + flagsInt: number; + }; + counter: number; + counterBuf: Uint8Array_; + aaguid?: Uint8Array_; + credentialID?: Uint8Array_; + credentialPublicKey?: Uint8Array_; + extensionsData?: AuthenticationExtensionsAuthenticatorOutputs; + extensionsDataBuffer?: Uint8Array_; +}; +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +export declare const _parseAuthenticatorDataInternals: { + stubThis: (value: ParsedAuthenticatorData) => ParsedAuthenticatorData; +}; +//# sourceMappingURL=parseAuthenticatorData.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/parseAuthenticatorData.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/parseAuthenticatorData.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..2ae207592c6cdaef56824eb5277dcaa67401db60 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/parseAuthenticatorData.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parseAuthenticatorData.d.ts","sourceRoot":"","sources":["../../src/helpers/parseAuthenticatorData.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,4CAA4C,EAElD,MAAM,oCAAoC,CAAC;AAG5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,WAAW,GACpB,uBAAuB,CAwHzB;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,WAAW,CAAC;IACtB,QAAQ,EAAE,WAAW,CAAC;IACtB,KAAK,EAAE;QACL,EAAE,EAAE,OAAO,CAAC;QACZ,EAAE,EAAE,OAAO,CAAC;QACZ,EAAE,EAAE,OAAO,CAAC;QACZ,EAAE,EAAE,OAAO,CAAC;QACZ,EAAE,EAAE,OAAO,CAAC;QACZ,EAAE,EAAE,OAAO,CAAC;QACZ,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,WAAW,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,YAAY,CAAC,EAAE,WAAW,CAAC;IAC3B,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC,cAAc,CAAC,EAAE,4CAA4C,CAAC;IAC9D,oBAAoB,CAAC,EAAE,WAAW,CAAC;CACpC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gCAAgC;sBACzB,uBAAuB;CAC1C,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/parseAuthenticatorData.js b/node_modules/@simplewebauthn/server/script/helpers/parseAuthenticatorData.js new file mode 100644 index 0000000000000000000000000000000000000000..9d50150e5abcd134cecfc1da0a6f6b6f1c2618b8 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/parseAuthenticatorData.js @@ -0,0 +1,110 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports._parseAuthenticatorDataInternals = void 0; +exports.parseAuthenticatorData = parseAuthenticatorData; +const decodeAuthenticatorExtensions_js_1 = require("./decodeAuthenticatorExtensions.js"); +const index_js_1 = require("./iso/index.js"); +/** + * Make sense of the authData buffer contained in an Attestation + */ +function parseAuthenticatorData(authData) { + if (authData.byteLength < 37) { + throw new Error(`Authenticator data was ${authData.byteLength} bytes, expected at least 37 bytes`); + } + let pointer = 0; + const dataView = index_js_1.isoUint8Array.toDataView(authData); + const rpIdHash = authData.slice(pointer, pointer += 32); + const flagsBuf = authData.slice(pointer, pointer += 1); + const flagsInt = flagsBuf[0]; + // Bit positions can be referenced here: + // https://www.w3.org/TR/webauthn-2/#flags + const flags = { + up: !!(flagsInt & (1 << 0)), // User Presence + uv: !!(flagsInt & (1 << 2)), // User Verified + be: !!(flagsInt & (1 << 3)), // Backup Eligibility + bs: !!(flagsInt & (1 << 4)), // Backup State + at: !!(flagsInt & (1 << 6)), // Attested Credential Data Present + ed: !!(flagsInt & (1 << 7)), // Extension Data Present + flagsInt, + }; + const counterBuf = authData.slice(pointer, pointer + 4); + const counter = dataView.getUint32(pointer, false); + pointer += 4; + let aaguid = undefined; + let credentialID = undefined; + let credentialPublicKey = undefined; + if (flags.at) { + aaguid = authData.slice(pointer, pointer += 16); + const credIDLen = dataView.getUint16(pointer); + pointer += 2; + credentialID = authData.slice(pointer, pointer += credIDLen); + /** + * Firefox 117 incorrectly CBOR-encodes authData when EdDSA (-8) is used for the public key. + * A CBOR "Map of 3 items" (0xa3) should be "Map of 4 items" (0xa4), and if we manually adjust + * the single byte there's a good chance the authData can be correctly parsed. + * + * This browser release also incorrectly uses the string labels "OKP" and "Ed25519" instead of + * their integer representations for kty and crv respectively. That's why the COSE public key + * in the hex below looks so odd. + */ + // Bytes decode to `{ 1: "OKP", 3: -8, -1: "Ed25519" }` (it's missing key -2 a.k.a. COSEKEYS.x) + const badEdDSACBOR = index_js_1.isoUint8Array.fromHex('a301634f4b500327206745643235353139'); + const bytesAtCurrentPosition = authData.slice(pointer, pointer + badEdDSACBOR.byteLength); + let foundBadCBOR = false; + if (index_js_1.isoUint8Array.areEqual(badEdDSACBOR, bytesAtCurrentPosition)) { + // Change the bad CBOR 0xa3 to 0xa4 so that the credential public key can be recognized + foundBadCBOR = true; + authData[pointer] = 0xa4; + } + // Decode the next CBOR item in the buffer, then re-encode it back to a Buffer + const firstDecoded = index_js_1.isoCBOR.decodeFirst(authData.slice(pointer)); + const firstEncoded = Uint8Array.from( + /** + * Casting to `Map` via `as unknown` here because TS doesn't make it possible to define Maps + * with discrete keys and properties with known types per pair, and CBOR libs typically parse + * CBOR Major Type 5 to `Map` because you can have numbers for keys. A `COSEPublicKey` can be + * generalized as "a Map with numbers for keys and either numbers or bytes for values" though. + * If this presumption falls apart then other parts of verification later on will fail so we + * should be safe doing this here. + */ + index_js_1.isoCBOR.encode(firstDecoded)); + if (foundBadCBOR) { + // Restore the bit we changed so that `authData` is the same as it came in and won't break + // signature verification. + authData[pointer] = 0xa3; + } + credentialPublicKey = firstEncoded; + pointer += firstEncoded.byteLength; + } + let extensionsData = undefined; + let extensionsDataBuffer = undefined; + if (flags.ed) { + const firstDecoded = index_js_1.isoCBOR.decodeFirst(authData.slice(pointer)); + extensionsDataBuffer = Uint8Array.from(index_js_1.isoCBOR.encode(firstDecoded)); + extensionsData = (0, decodeAuthenticatorExtensions_js_1.decodeAuthenticatorExtensions)(extensionsDataBuffer); + pointer += extensionsDataBuffer.byteLength; + } + // Pointer should be at the end of the authenticator data, otherwise too much data was sent + if (authData.byteLength > pointer) { + throw new Error('Leftover bytes detected while parsing authenticator data'); + } + return exports._parseAuthenticatorDataInternals.stubThis({ + rpIdHash, + flagsBuf, + flags, + counter, + counterBuf, + aaguid, + credentialID, + credentialPublicKey, + extensionsData, + extensionsDataBuffer, + }); +} +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +exports._parseAuthenticatorDataInternals = { + stubThis: (value) => value, +}; diff --git a/node_modules/@simplewebauthn/server/script/helpers/parseBackupFlags.d.ts b/node_modules/@simplewebauthn/server/script/helpers/parseBackupFlags.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..284a6cc5c7c059e83458feb249b81dfa97f85879 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/parseBackupFlags.d.ts @@ -0,0 +1,20 @@ +import type { CredentialDeviceType } from '../types/index.js'; +/** + * Make sense of Bits 3 and 4 in authenticator indicating: + * + * - Whether the credential can be used on multiple devices + * - Whether the credential is backed up or not + * + * Invalid configurations will raise an `Error` + */ +export declare function parseBackupFlags({ be, bs }: { + be: boolean; + bs: boolean; +}): { + credentialDeviceType: CredentialDeviceType; + credentialBackedUp: boolean; +}; +export declare class InvalidBackupFlags extends Error { + constructor(message: string); +} +//# sourceMappingURL=parseBackupFlags.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/parseBackupFlags.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/parseBackupFlags.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..69ed26edd983b1a7270994a6d0e28cf7ec31588f --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/parseBackupFlags.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parseBackupFlags.d.ts","sourceRoot":"","sources":["../../src/helpers/parseBackupFlags.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,GAAG;IAC1E,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C,kBAAkB,EAAE,OAAO,CAAC;CAC7B,CAeA;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,EAAE,MAAM;CAI5B"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/parseBackupFlags.js b/node_modules/@simplewebauthn/server/script/helpers/parseBackupFlags.js new file mode 100644 index 0000000000000000000000000000000000000000..61385c5b269003d96320dc158460094bdc65728d --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/parseBackupFlags.js @@ -0,0 +1,30 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.InvalidBackupFlags = void 0; +exports.parseBackupFlags = parseBackupFlags; +/** + * Make sense of Bits 3 and 4 in authenticator indicating: + * + * - Whether the credential can be used on multiple devices + * - Whether the credential is backed up or not + * + * Invalid configurations will raise an `Error` + */ +function parseBackupFlags({ be, bs }) { + const credentialBackedUp = bs; + let credentialDeviceType = 'singleDevice'; + if (be) { + credentialDeviceType = 'multiDevice'; + } + if (credentialDeviceType === 'singleDevice' && credentialBackedUp) { + throw new InvalidBackupFlags('Single-device credential indicated that it was backed up, which should be impossible.'); + } + return { credentialDeviceType, credentialBackedUp }; +} +class InvalidBackupFlags extends Error { + constructor(message) { + super(message); + this.name = 'InvalidBackupFlags'; + } +} +exports.InvalidBackupFlags = InvalidBackupFlags; diff --git a/node_modules/@simplewebauthn/server/script/helpers/toHash.d.ts b/node_modules/@simplewebauthn/server/script/helpers/toHash.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..1a0039fe5ad1d77b9481d4136c1a04c30f08c56e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/toHash.d.ts @@ -0,0 +1,8 @@ +import type { COSEALG } from './cose.js'; +import type { Uint8Array_ } from '../types/index.js'; +/** + * Returns hash digest of the given data, using the given algorithm when provided. Defaults to using + * SHA-256. + */ +export declare function toHash(data: Uint8Array_ | string, algorithm?: COSEALG): Promise; +//# sourceMappingURL=toHash.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/toHash.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/toHash.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..00c9c61d7804638b195470509d29b0002b9f2b74 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/toHash.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"toHash.d.ts","sourceRoot":"","sources":["../../src/helpers/toHash.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,WAAW,GAAG,MAAM,EAC1B,SAAS,GAAE,OAAY,GACtB,OAAO,CAAC,WAAW,CAAC,CAQtB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/toHash.js b/node_modules/@simplewebauthn/server/script/helpers/toHash.js new file mode 100644 index 0000000000000000000000000000000000000000..50cb936e00badd849a667011f5c6cd186313e4ba --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/toHash.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.toHash = toHash; +const index_js_1 = require("./iso/index.js"); +/** + * Returns hash digest of the given data, using the given algorithm when provided. Defaults to using + * SHA-256. + */ +function toHash(data, algorithm = -7) { + if (typeof data === 'string') { + data = index_js_1.isoUint8Array.fromUTF8String(data); + } + const digest = index_js_1.isoCrypto.digest(data, algorithm); + return digest; +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/validateCertificatePath.d.ts b/node_modules/@simplewebauthn/server/script/helpers/validateCertificatePath.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9bcf6a9d38ff8cd44463f6f617a26682f5dd9df --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/validateCertificatePath.d.ts @@ -0,0 +1,7 @@ +/** + * Traverse an array of PEM certificates and ensure they form a proper chain + * @param x5cCertsPEM Typically the result of `x5c.map(convertASN1toPEM)` + * @param trustAnchorsPEM PEM-formatted certs that an attestation statement x5c may chain back to + */ +export declare function validateCertificatePath(x5cCertsPEM: string[], trustAnchorsPEM?: string[]): Promise; +//# sourceMappingURL=validateCertificatePath.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/validateCertificatePath.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/validateCertificatePath.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..9063cfd1f4652f5cac699e04c1fe42d1492ce1e4 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/validateCertificatePath.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"validateCertificatePath.d.ts","sourceRoot":"","sources":["../../src/helpers/validateCertificatePath.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EAAE,EACrB,eAAe,GAAE,MAAM,EAAO,GAC7B,OAAO,CAAC,OAAO,CAAC,CA6HlB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/validateCertificatePath.js b/node_modules/@simplewebauthn/server/script/helpers/validateCertificatePath.js new file mode 100644 index 0000000000000000000000000000000000000000..8efa190ecadc0132f00ec4bec79cef4a00108e3a --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/validateCertificatePath.js @@ -0,0 +1,143 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validateCertificatePath = validateCertificatePath; +const x509_1 = require("@peculiar/x509"); +const isCertRevoked_js_1 = require("./isCertRevoked.js"); +const getWebCrypto_js_1 = require("./iso/isoCrypto/getWebCrypto.js"); +/** + * Traverse an array of PEM certificates and ensure they form a proper chain + * @param x5cCertsPEM Typically the result of `x5c.map(convertASN1toPEM)` + * @param trustAnchorsPEM PEM-formatted certs that an attestation statement x5c may chain back to + */ +async function validateCertificatePath(x5cCertsPEM, trustAnchorsPEM = []) { + if (trustAnchorsPEM.length === 0) { + // We have no trust anchors to chain back to, so skip path validation + return true; + } + const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)(); + // Prepare to work with x5c certs + const x5cCertsParsed = x5cCertsPEM.map((certPEM) => new x509_1.X509Certificate(certPEM)); + // Check for any expired or temporally invalid certs in x5c + for (let i = 0; i < x5cCertsParsed.length; i++) { + const cert = x5cCertsParsed[i]; + const certPEM = x5cCertsPEM[i]; + try { + await assertCertNotRevoked(cert); + } + catch (_err) { + throw new Error(`Found revoked certificate in x5c:\n${certPEM}`); + } + try { + assertCertIsWithinValidTimeWindow(cert.notBefore, cert.notAfter); + } + catch (_err) { + throw new Error(`Found certificate out of validity period in x5c:\n${certPEM}`); + } + } + // Prepare to work with trust anchor certs + const trustAnchorsParsed = trustAnchorsPEM.map((certPEM) => { + try { + return new x509_1.X509Certificate(certPEM); + } + catch (err) { + const _err = err; + throw new Error(`Could not parse trust anchor certificate:\n${certPEM}`, { cause: _err }); + } + }); + // Filter out any expired or temporally invalid trust anchors certs + const validTrustAnchors = []; + for (let i = 0; i < trustAnchorsParsed.length; i++) { + const cert = trustAnchorsParsed[i]; + try { + await assertCertNotRevoked(cert); + } + catch (_err) { + // Continue processing the other certs + continue; + } + try { + assertCertIsWithinValidTimeWindow(cert.notBefore, cert.notAfter); + } + catch (_err) { + // Continue processing the other certs + continue; + } + validTrustAnchors.push(cert); + } + if (validTrustAnchors.length === 0) { + throw new Error('No specified trust anchor was valid for verifying x5c'); + } + // Try to verify x5c with each trust anchor + let invalidSubjectAndIssuerError = false; + for (const anchor of trustAnchorsParsed) { + try { + const x5cWithTrustAnchor = x5cCertsParsed.concat([anchor]); + if (new Set(x5cWithTrustAnchor).size !== x5cWithTrustAnchor.length) { + throw new Error('Invalid certificate path: found duplicate certificates'); + } + // Check signatures, and notBefore and notAfter + for (let i = 0; i < x5cWithTrustAnchor.length - 1; i++) { + const subject = x5cWithTrustAnchor[i]; + const issuer = x5cWithTrustAnchor[i + 1]; + // Leaf or intermediate cert, make sure the next cert in the chain signed it + const issuerSignedSubject = await subject.verify({ publicKey: issuer.publicKey, signatureOnly: true }, WebCrypto); + if (!issuerSignedSubject) { + throw new InvalidSubjectAndIssuer(); + } + if (issuer.subject === issuer.issuer) { + // Root cert detected, make sure it signed itself + const issuerSignedIssuer = await issuer.verify({ publicKey: issuer.publicKey, signatureOnly: true }, WebCrypto); + if (!issuerSignedIssuer) { + throw new InvalidSubjectAndIssuer(); + } + // Don't process anything else after a root cert + break; + } + } + // If we successfully validated a path then there's no need to continue. Reset any existing + // errors that were thrown by earlier trust anchors + invalidSubjectAndIssuerError = false; + break; + } + catch (err) { + if (err instanceof InvalidSubjectAndIssuer) { + invalidSubjectAndIssuerError = true; + } + else { + throw new Error('Unexpected error while validating certificate path', { cause: err }); + } + } + } + // We tried multiple trust anchors and none of them worked + if (invalidSubjectAndIssuerError) { + throw new InvalidSubjectAndIssuer(); + } + return true; +} +/** + * Check if the certificate is revoked or not. If it is, raise an error + */ +async function assertCertNotRevoked(certificate) { + // Check for certificate revocation + const subjectCertRevoked = await (0, isCertRevoked_js_1.isCertRevoked)(certificate); + if (subjectCertRevoked) { + throw new Error('Found revoked certificate in certificate path'); + } +} +/** + * Require the cert to be within its notBefore and notAfter time window + */ +function assertCertIsWithinValidTimeWindow(certNotBefore, certNotAfter) { + const now = new Date(Date.now()); + if (certNotBefore > now || certNotAfter < now) { + throw new Error('Certificate is not yet valid or expired'); + } +} +// Custom errors to help pass on certain errors +class InvalidSubjectAndIssuer extends Error { + constructor() { + const message = 'Subject issuer did not match issuer subject'; + super(message); + this.name = 'InvalidSubjectAndIssuer'; + } +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/validateExtFIDOGenCEAAGUID.d.ts b/node_modules/@simplewebauthn/server/script/helpers/validateExtFIDOGenCEAAGUID.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b8264e9695b8c41285e38d8f434451ff1812d782 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/validateExtFIDOGenCEAAGUID.d.ts @@ -0,0 +1,8 @@ +import type { Extensions } from '@peculiar/asn1-x509'; +import type { Uint8Array_ } from '../types/index.js'; +/** + * Look for the id-fido-gen-ce-aaguid certificate extension. If it's present then check it against + * the attestation statement AAGUID. + */ +export declare function validateExtFIDOGenCEAAGUID(certExtensions: Extensions | undefined, aaguid: Uint8Array_): boolean; +//# sourceMappingURL=validateExtFIDOGenCEAAGUID.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/validateExtFIDOGenCEAAGUID.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/validateExtFIDOGenCEAAGUID.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..99ab7e7a81943da5e2a47a28979cdd23b4b251e0 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/validateExtFIDOGenCEAAGUID.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"validateExtFIDOGenCEAAGUID.d.ts","sourceRoot":"","sources":["../../src/helpers/validateExtFIDOGenCEAAGUID.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AASrD;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,cAAc,EAAE,UAAU,GAAG,SAAS,EACtC,MAAM,EAAE,WAAW,GAClB,OAAO,CA6BT"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/validateExtFIDOGenCEAAGUID.js b/node_modules/@simplewebauthn/server/script/helpers/validateExtFIDOGenCEAAGUID.js new file mode 100644 index 0000000000000000000000000000000000000000..25928b13f0fe3ec47d4ac502662e68d79a122642 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/validateExtFIDOGenCEAAGUID.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.validateExtFIDOGenCEAAGUID = validateExtFIDOGenCEAAGUID; +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const index_js_1 = require("./iso/index.js"); +/** + * Attestation Certificate Extension OID: `id-fido-gen-ce-aaguid` + * + * Sourced from https://fidoalliance.org/specs/fido-v2.0-ps-20150904/fido-key-attestation-v2.0-ps-20150904.html#verifying-an-attestation-statement + */ +const id_fido_gen_ce_aaguid = '1.3.6.1.4.1.45724.1.1.4'; +/** + * Look for the id-fido-gen-ce-aaguid certificate extension. If it's present then check it against + * the attestation statement AAGUID. + */ +function validateExtFIDOGenCEAAGUID(certExtensions, aaguid) { + // The certificate had no extensions so there's nothing to validate + if (!certExtensions) { + return true; + } + const extFIDOGenCEAAGUID = certExtensions.find((ext) => ext.extnID === id_fido_gen_ce_aaguid); + // The extension isn't present so there's nothing to validate + if (!extFIDOGenCEAAGUID) { + return true; + } + // Parse the extension value + const parsedExtFIDOGenCEAAGUID = asn1_schema_1.AsnParser.parse(extFIDOGenCEAAGUID.extnValue, asn1_schema_1.OctetString); + const extValue = new Uint8Array(parsedExtFIDOGenCEAAGUID.buffer); + // Compare the two values + const aaguidAndExtAreEqual = index_js_1.isoUint8Array.areEqual(aaguid, extValue); + if (!aaguidAndExtAreEqual) { + const _debugExtHex = index_js_1.isoUint8Array.toHex(extValue); + const _debugAAGUIDHex = index_js_1.isoUint8Array.toHex(aaguid); + throw new Error(`Certificate extension id-fido-gen-ce-aaguid (${id_fido_gen_ce_aaguid}) value of "${_debugExtHex}" was present but not equal to attestation statement AAGUID value of "${_debugAAGUIDHex}"`); + } + return true; +} diff --git a/node_modules/@simplewebauthn/server/script/helpers/verifySignature.d.ts b/node_modules/@simplewebauthn/server/script/helpers/verifySignature.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2faaff74731ee8d903997c8a3995b79adc8b4f00 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/verifySignature.d.ts @@ -0,0 +1,20 @@ +import { COSEALG } from './cose.js'; +import type { Uint8Array_ } from '../types/index.js'; +/** + * Verify an authenticator's signature + */ +export declare function verifySignature(opts: { + signature: Uint8Array_; + data: Uint8Array_; + credentialPublicKey?: Uint8Array_; + x509Certificate?: Uint8Array_; + hashAlgorithm?: COSEALG; +}): Promise; +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +export declare const _verifySignatureInternals: { + stubThis: (value: Promise) => Promise; +}; +//# sourceMappingURL=verifySignature.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/verifySignature.d.ts.map b/node_modules/@simplewebauthn/server/script/helpers/verifySignature.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..8afaec9be99caa443c9a7d6feedc9796960c1974 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/verifySignature.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifySignature.d.ts","sourceRoot":"","sources":["../../src/helpers/verifySignature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiB,MAAM,WAAW,CAAC;AAInD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,WAAW,CAAC;IAClB,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAClC,eAAe,CAAC,EAAE,WAAW,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,OAAO,CAAC,OAAO,CAAC,CAmCnB;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB;sBAClB,OAAO,CAAC,OAAO,CAAC;CACnC,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/helpers/verifySignature.js b/node_modules/@simplewebauthn/server/script/helpers/verifySignature.js new file mode 100644 index 0000000000000000000000000000000000000000..6a855f76489848eeb3f5dcdce537ef6a45b30038 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/helpers/verifySignature.js @@ -0,0 +1,39 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports._verifySignatureInternals = void 0; +exports.verifySignature = verifySignature; +const index_js_1 = require("./iso/index.js"); +const decodeCredentialPublicKey_js_1 = require("./decodeCredentialPublicKey.js"); +const convertX509PublicKeyToCOSE_js_1 = require("./convertX509PublicKeyToCOSE.js"); +/** + * Verify an authenticator's signature + */ +function verifySignature(opts) { + const { signature, data, credentialPublicKey, x509Certificate, hashAlgorithm, } = opts; + if (!x509Certificate && !credentialPublicKey) { + throw new Error('Must declare either "leafCert" or "credentialPublicKey"'); + } + if (x509Certificate && credentialPublicKey) { + throw new Error('Must not declare both "leafCert" and "credentialPublicKey"'); + } + let cosePublicKey = new Map(); + if (credentialPublicKey) { + cosePublicKey = (0, decodeCredentialPublicKey_js_1.decodeCredentialPublicKey)(credentialPublicKey); + } + else if (x509Certificate) { + cosePublicKey = (0, convertX509PublicKeyToCOSE_js_1.convertX509PublicKeyToCOSE)(x509Certificate); + } + return exports._verifySignatureInternals.stubThis(index_js_1.isoCrypto.verify({ + cosePublicKey, + signature, + data, + shaHashOverride: hashAlgorithm, + })); +} +/** + * Make it possible to stub the return value during testing + * @ignore Don't include this in docs output + */ +exports._verifySignatureInternals = { + stubThis: (value) => value, +}; diff --git a/node_modules/@simplewebauthn/server/script/index.d.ts b/node_modules/@simplewebauthn/server/script/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cdfb603bf10902e0443d7157fde5b324ef784444 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/index.d.ts @@ -0,0 +1,9 @@ +export * from './registration/generateRegistrationOptions.js'; +export * from './registration/verifyRegistrationResponse.js'; +export * from './authentication/generateAuthenticationOptions.js'; +export * from './authentication/verifyAuthenticationResponse.js'; +export * from './services/metadataService.js'; +export * from './services/settingsService.js'; +export * from './metadata/mdsTypes.js'; +export * from './types/index.js'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/index.d.ts.map b/node_modules/@simplewebauthn/server/script/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f2eeb61d453eb91dd1a93f6c21aa825d7b76057f --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+CAA+C,CAAC;AAC9D,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mDAAmD,CAAC;AAClE,cAAc,kDAAkD,CAAC;AACjE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/index.js b/node_modules/@simplewebauthn/server/script/index.js new file mode 100644 index 0000000000000000000000000000000000000000..54290d52862be8245b95fddd9652c0fa3ba038e1 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/index.js @@ -0,0 +1,24 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +__exportStar(require("./registration/generateRegistrationOptions.js"), exports); +__exportStar(require("./registration/verifyRegistrationResponse.js"), exports); +__exportStar(require("./authentication/generateAuthenticationOptions.js"), exports); +__exportStar(require("./authentication/verifyAuthenticationResponse.js"), exports); +__exportStar(require("./services/metadataService.js"), exports); +__exportStar(require("./services/settingsService.js"), exports); +__exportStar(require("./metadata/mdsTypes.js"), exports); +__exportStar(require("./types/index.js"), exports); diff --git a/node_modules/@simplewebauthn/server/script/metadata/mdsTypes.d.ts b/node_modules/@simplewebauthn/server/script/metadata/mdsTypes.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..45557a4317f70fd3e055bdf3dbe66614337c5f1e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/mdsTypes.d.ts @@ -0,0 +1,221 @@ +import type { Base64URLString } from '../types/index.js'; +/** + * Metadata Service structures + * https://fidoalliance.org/specs/mds/fido-metadata-service-v3.0-ps-20210518.html + */ +/** */ +export type MDSJWTHeader = { + alg: string; + typ: string; + x5c: Base64URLString[]; +}; +export type MDSJWTPayload = { + legalHeader: string; + no: number; + nextUpdate: string; + entries: MetadataBLOBPayloadEntry[]; +}; +export type MetadataBLOBPayloadEntry = { + aaid?: string; + aaguid?: string; + attestationCertificateKeyIdentifiers?: string[]; + metadataStatement?: MetadataStatement; + biometricStatusReports?: BiometricStatusReport[]; + statusReports: StatusReport[]; + timeOfLastStatusChange: string; + rogueListURL?: string; + rogueListHash?: string; +}; +export type BiometricStatusReport = { + certLevel: number; + modality: UserVerify; + effectiveDate?: string; + certificationDescriptor?: string; + certificateNumber?: string; + certificationPolicyVersion?: string; + certificationRequirementsVersion?: string; +}; +export type StatusReport = { + status: AuthenticatorStatus; + effectiveDate?: string; + authenticatorVersion?: number; + certificate?: string; + url?: string; + certificationDescriptor?: string; + certificateNumber?: string; + certificationPolicyVersion?: string; + certificationRequirementsVersion?: string; +}; +export type AuthenticatorStatus = 'NOT_FIDO_CERTIFIED' | 'FIDO_CERTIFIED' | 'USER_VERIFICATION_BYPASS' | 'ATTESTATION_KEY_COMPROMISE' | 'USER_KEY_REMOTE_COMPROMISE' | 'USER_KEY_PHYSICAL_COMPROMISE' | 'UPDATE_AVAILABLE' | 'REVOKED' | 'SELF_ASSERTION_SUBMITTED' | 'FIDO_CERTIFIED_L1' | 'FIDO_CERTIFIED_L1plus' | 'FIDO_CERTIFIED_L2' | 'FIDO_CERTIFIED_L2plus' | 'FIDO_CERTIFIED_L3' | 'FIDO_CERTIFIED_L3plus'; +/** + * Types defined in the FIDO Metadata Statement spec + * + * See https://fidoalliance.org/specs/mds/fido-metadata-statement-v3.0-ps-20210518.html + */ +export type CodeAccuracyDescriptor = { + base: number; + minLength: number; + maxRetries?: number; + blockSlowdown?: number; +}; +export type BiometricAccuracyDescriptor = { + selfAttestedFRR?: number; + selfAttestedFAR?: number; + maxTemplates?: number; + maxRetries?: number; + blockSlowdown?: number; +}; +export type PatternAccuracyDescriptor = { + minComplexity: number; + maxRetries?: number; + blockSlowdown?: number; +}; +export type VerificationMethodDescriptor = { + userVerificationMethod: UserVerify; + caDesc?: CodeAccuracyDescriptor; + baDesc?: BiometricAccuracyDescriptor; + paDesc?: PatternAccuracyDescriptor; +}; +export type VerificationMethodANDCombinations = VerificationMethodDescriptor[]; +export type rgbPaletteEntry = { + r: number; + g: number; + b: number; +}; +export type DisplayPNGCharacteristicsDescriptor = { + width: number; + height: number; + bitDepth: number; + colorType: number; + compression: number; + filter: number; + interlace: number; + plte?: rgbPaletteEntry[]; +}; +export type EcdaaTrustAnchor = { + X: string; + Y: string; + c: string; + sx: string; + sy: string; + G1Curve: string; +}; +export type ExtensionDescriptor = { + id: string; + tag?: number; + data?: string; + fail_if_unknown: boolean; +}; +/** + * langCode -> "en-US", "ja-JP", etc... + */ +export type AlternativeDescriptions = { + [langCode: string]: string; +}; +export type MetadataStatement = { + legalHeader?: string; + aaid?: string; + aaguid?: string; + attestationCertificateKeyIdentifiers?: string[]; + description: string; + alternativeDescriptions?: AlternativeDescriptions; + authenticatorVersion: number; + protocolFamily: string; + schema: number; + upv: Version[]; + authenticationAlgorithms: AlgSign[]; + publicKeyAlgAndEncodings: AlgKey[]; + attestationTypes: Attestation[]; + userVerificationDetails: VerificationMethodANDCombinations[]; + keyProtection: KeyProtection[]; + isKeyRestricted?: boolean; + isFreshUserVerificationRequired?: boolean; + matcherProtection: MatcherProtection[]; + cryptoStrength?: number; + attachmentHint?: AttachmentHint[]; + tcDisplay: TransactionConfirmationDisplay[]; + tcDisplayContentType?: string; + tcDisplayPNGCharacteristics?: DisplayPNGCharacteristicsDescriptor[]; + attestationRootCertificates: string[]; + ecdaaTrustAnchors?: EcdaaTrustAnchor[]; + icon?: string; + supportedExtensions?: ExtensionDescriptor[]; + authenticatorGetInfo?: AuthenticatorGetInfo; +}; +/** + * Types declared in other specs + */ +/** + * USER_VERIFY + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#user-verification-methods + */ +export type UserVerify = 'presence_internal' | 'fingerprint_internal' | 'passcode_internal' | 'voiceprint_internal' | 'faceprint_internal' | 'location_internal' | 'eyeprint_internal' | 'pattern_internal' | 'handprint_internal' | 'passcode_external' | 'pattern_external' | 'none' | 'all'; +/** + * ALG_SIGN + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#authentication-algorithms + * + * Using this helpful TS pattern here so that we can strongly enforce the existence of COSE info + * mappings in `algSignToCOSEInfoMap` in verifyAttestationWithMetadata.ts + */ +export type AlgSign = typeof AlgSign[number]; +declare const AlgSign: readonly ["secp256r1_ecdsa_sha256_raw", "secp256r1_ecdsa_sha256_der", "rsassa_pss_sha256_raw", "rsassa_pss_sha256_der", "secp256k1_ecdsa_sha256_raw", "secp256k1_ecdsa_sha256_der", "rsassa_pss_sha384_raw", "rsassa_pkcsv15_sha256_raw", "rsassa_pkcsv15_sha384_raw", "rsassa_pkcsv15_sha512_raw", "rsassa_pkcsv15_sha1_raw", "secp384r1_ecdsa_sha384_raw", "secp512r1_ecdsa_sha256_raw", "ed25519_eddsa_sha512_raw"]; +/** + * ALG_KEY + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#public-key-representation-formats + */ +export type AlgKey = 'ecc_x962_raw' | 'ecc_x962_der' | 'rsa_2048_raw' | 'rsa_2048_der' | 'cose'; +/** + * ATTESTATION + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#authenticator-attestation-types + */ +export type Attestation = 'basic_full' | 'basic_surrogate' | 'ecdaa' | 'attca' | 'anonca' | 'none'; +/** + * KEY_PROTECTION + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#key-protection-types + */ +export type KeyProtection = 'software' | 'hardware' | 'tee' | 'secure_element' | 'remote_handle'; +/** + * MATCHER_PROTECTION + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#matcher-protection-types + */ +export type MatcherProtection = 'software' | 'tee' | 'on_chip'; +/** + * ATTACHMENT_HINT + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#authenticator-attachment-hints + */ +export type AttachmentHint = 'internal' | 'external' | 'wired' | 'wireless' | 'nfc' | 'bluetooth' | 'network' | 'ready' | 'wifi_direct'; +/** + * TRANSACTION_CONFIRMATION_DISPLAY + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#transaction-confirmation-display-types + */ +export type TransactionConfirmationDisplay = 'any' | 'privileged_software' | 'tee' | 'hardware' | 'remote'; +/** + * https://fidoalliance.org/specs/fido-uaf-v1.2-ps-20201020/fido-uaf-protocol-v1.2-ps-20201020.html#version-interface + */ +export type Version = { + major: number; + minor: number; +}; +/** + * https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#authenticatorGetInfoz + */ +export type AuthenticatorGetInfo = { + versions: ('FIDO_2_0' | 'U2F_V2')[]; + extensions?: string[]; + aaguid: string; + options?: { + plat?: boolean; + rk?: boolean; + clientPin?: boolean; + up?: boolean; + uv?: boolean; + }; + maxMsgSize?: number; + pinProtocols?: number[]; + algorithms?: { + type: 'public-key'; + alg: number; + }[]; +}; +export {}; +//# sourceMappingURL=mdsTypes.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/mdsTypes.d.ts.map b/node_modules/@simplewebauthn/server/script/metadata/mdsTypes.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..0266a6c871f93e078e3481eca1daf9f4b6ea464e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/mdsTypes.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"mdsTypes.d.ts","sourceRoot":"","sources":["../../src/metadata/mdsTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD;;;GAGG;AAEH,MAAM;AACN,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE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ACP,QAAQ,GACR,MAAM,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,aAAa,GACrB,UAAU,GACV,UAAU,GACV,KAAK,GACL,gBAAgB,GAChB,eAAe,CAAC;AAEpB;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG,KAAK,GAAG,SAAS,CAAC;AAE/D;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB,UAAU,GACV,UAAU,GACV,OAAO,GACP,UAAU,GACV,KAAK,GACL,WAAW,GACX,SAAS,GACT,OAAO,GACP,aAAa,CAAC;AAElB;;;GAGG;AACH,MAAM,MAAM,8BAA8B,GACtC,KAAK,GACL,qBAAqB,GACrB,KAAK,GACL,UAAU,GACV,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,QAAQ,EAAE,CAAC,UAAU,GAAG,QAAQ,CAAC,EAAE,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,EAAE,CAAC,EAAE,OAAO,CAAC;QACb,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,EAAE,CAAC,EAAE,OAAO,CAAC;QACb,EAAE,CAAC,EAAE,OAAO,CAAC;KACd,CAAC;IACF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACpD,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/mdsTypes.js b/node_modules/@simplewebauthn/server/script/metadata/mdsTypes.js new file mode 100644 index 0000000000000000000000000000000000000000..029942c0efc197bb3af888419b13ea55e4e6cf04 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/mdsTypes.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const AlgSign = [ + 'secp256r1_ecdsa_sha256_raw', + 'secp256r1_ecdsa_sha256_der', + 'rsassa_pss_sha256_raw', + 'rsassa_pss_sha256_der', + 'secp256k1_ecdsa_sha256_raw', + 'secp256k1_ecdsa_sha256_der', + 'rsassa_pss_sha384_raw', + 'rsassa_pkcsv15_sha256_raw', + 'rsassa_pkcsv15_sha384_raw', + 'rsassa_pkcsv15_sha512_raw', + 'rsassa_pkcsv15_sha1_raw', + 'secp384r1_ecdsa_sha384_raw', + 'secp512r1_ecdsa_sha256_raw', + 'ed25519_eddsa_sha512_raw', +]; diff --git a/node_modules/@simplewebauthn/server/script/metadata/parseJWT.d.ts b/node_modules/@simplewebauthn/server/script/metadata/parseJWT.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3ac50e66ebde295218e166a364e1d97a8598c1b9 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/parseJWT.d.ts @@ -0,0 +1,5 @@ +/** + * Process a JWT into Javascript-friendly data structures + */ +export declare function parseJWT(jwt: string): [T1, T2, string]; +//# sourceMappingURL=parseJWT.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/parseJWT.d.ts.map b/node_modules/@simplewebauthn/server/script/metadata/parseJWT.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..3b1dbe4fd009e39f2812227d2629b04d22776855 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/parseJWT.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parseJWT.d.ts","sourceRoot":"","sources":["../../src/metadata/parseJWT.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,CAO9D"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/parseJWT.js b/node_modules/@simplewebauthn/server/script/metadata/parseJWT.js new file mode 100644 index 0000000000000000000000000000000000000000..cadf3e3c4bdba3050d5cba95a0b53ca982812c17 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/parseJWT.js @@ -0,0 +1,15 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parseJWT = parseJWT; +const index_js_1 = require("../helpers/iso/index.js"); +/** + * Process a JWT into Javascript-friendly data structures + */ +function parseJWT(jwt) { + const parts = jwt.split('.'); + return [ + JSON.parse(index_js_1.isoBase64URL.toUTF8String(parts[0])), + JSON.parse(index_js_1.isoBase64URL.toUTF8String(parts[1])), + parts[2], + ]; +} diff --git a/node_modules/@simplewebauthn/server/script/metadata/verifyAttestationWithMetadata.d.ts b/node_modules/@simplewebauthn/server/script/metadata/verifyAttestationWithMetadata.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6589ef440f9231a13400535297a7305e5f9cedd --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/verifyAttestationWithMetadata.d.ts @@ -0,0 +1,31 @@ +import type { Base64URLString } from '../types/index.js'; +import type { AlgSign, MetadataStatement } from './mdsTypes.js'; +import { type COSEALG, type COSECRV, COSEKTY } from '../helpers/cose.js'; +import type { Uint8Array_ } from '../types/index.js'; +/** + * Match properties of the authenticator's attestation statement against expected values as + * registered with the FIDO Alliance Metadata Service + */ +export declare function verifyAttestationWithMetadata({ statement, credentialPublicKey, x5c, attestationStatementAlg, }: { + statement: MetadataStatement; + credentialPublicKey: Uint8Array_; + x5c: Uint8Array_[] | Base64URLString[]; + attestationStatementAlg?: number; +}): Promise; +type COSEInfo = { + kty: COSEKTY; + alg: COSEALG; + crv?: COSECRV; +}; +/** + * Convert ALG_SIGN values to COSE info + * + * Values pulled from `ALG_KEY_COSE` definitions in the FIDO Registry of Predefined Values + * + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#authentication-algorithms + */ +export declare const algSignToCOSEInfoMap: { + [key in AlgSign]: COSEInfo; +}; +export {}; +//# sourceMappingURL=verifyAttestationWithMetadata.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/verifyAttestationWithMetadata.d.ts.map b/node_modules/@simplewebauthn/server/script/metadata/verifyAttestationWithMetadata.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..eab452ed068f6ee6f58ac9c9910109e3aa600a4b --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/verifyAttestationWithMetadata.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyAttestationWithMetadata.d.ts","sourceRoot":"","sources":["../../src/metadata/verifyAttestationWithMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIhE,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EAEZ,OAAO,EAER,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;GAGG;AACH,wBAAsB,6BAA6B,CAAC,EAClD,SAAS,EACT,mBAAmB,EACnB,GAAG,EACH,uBAAuB,GACxB,EAAE;IACD,SAAS,EAAE,iBAAiB,CAAC;IAC7B,mBAAmB,EAAE,WAAW,CAAC;IACjC,GAAG,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,CAAC;IACvC,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAClC,GAAG,OAAO,CAAC,OAAO,CAAC,CAoJnB;AAED,KAAK,QAAQ,GAAG;IACd,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE;KAAG,GAAG,IAAI,OAAO,GAAG,QAAQ;CAe9D,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/verifyAttestationWithMetadata.js b/node_modules/@simplewebauthn/server/script/metadata/verifyAttestationWithMetadata.js new file mode 100644 index 0000000000000000000000000000000000000000..1306c286adf2dbfc82fb1a572ee5b632bc86ae3f --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/verifyAttestationWithMetadata.js @@ -0,0 +1,163 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.algSignToCOSEInfoMap = void 0; +exports.verifyAttestationWithMetadata = verifyAttestationWithMetadata; +const convertCertBufferToPEM_js_1 = require("../helpers/convertCertBufferToPEM.js"); +const validateCertificatePath_js_1 = require("../helpers/validateCertificatePath.js"); +const decodeCredentialPublicKey_js_1 = require("../helpers/decodeCredentialPublicKey.js"); +const cose_js_1 = require("../helpers/cose.js"); +/** + * Match properties of the authenticator's attestation statement against expected values as + * registered with the FIDO Alliance Metadata Service + */ +async function verifyAttestationWithMetadata({ statement, credentialPublicKey, x5c, attestationStatementAlg, }) { + const { authenticationAlgorithms, authenticatorGetInfo, attestationRootCertificates, } = statement; + // Make sure the alg in the attestation statement matches one of the ones specified in metadata + const keypairCOSEAlgs = new Set(); + authenticationAlgorithms.forEach((algSign) => { + // Map algSign string to { kty, alg, crv } + const algSignCOSEINFO = exports.algSignToCOSEInfoMap[algSign]; + // Keeping this statement here just in case MDS returns something unexpected + if (algSignCOSEINFO) { + keypairCOSEAlgs.add(algSignCOSEINFO); + } + }); + // Extract the public key's COSE info for comparison + const decodedPublicKey = (0, decodeCredentialPublicKey_js_1.decodeCredentialPublicKey)(credentialPublicKey); + const kty = decodedPublicKey.get(cose_js_1.COSEKEYS.kty); + const alg = decodedPublicKey.get(cose_js_1.COSEKEYS.alg); + if (!kty) { + throw new Error('Credential public key was missing kty'); + } + if (!alg) { + throw new Error('Credential public key was missing alg'); + } + if (!kty) { + throw new Error('Credential public key was missing kty'); + } + // Assume everything is a number because these values should be + const publicKeyCOSEInfo = { kty, alg }; + if ((0, cose_js_1.isCOSEPublicKeyEC2)(decodedPublicKey)) { + const crv = decodedPublicKey.get(cose_js_1.COSEKEYS.crv); + publicKeyCOSEInfo.crv = crv; + } + /** + * Attempt to match the credential public key's algorithm to one specified in the device's + * metadata + */ + let foundMatch = false; + for (const keypairAlg of keypairCOSEAlgs) { + // Make sure algorithm and key type match + if (keypairAlg.alg === publicKeyCOSEInfo.alg && + keypairAlg.kty === publicKeyCOSEInfo.kty) { + // If not an RSA keypair then make sure curve numbers match too + if ((keypairAlg.kty === cose_js_1.COSEKTY.EC2 || keypairAlg.kty === cose_js_1.COSEKTY.OKP) && + keypairAlg.crv === publicKeyCOSEInfo.crv) { + foundMatch = true; + } + else { + // We've matched an RSA public key's properties + foundMatch = true; + } + } + if (foundMatch) { + break; + } + } + // Make sure the public key is one of the allowed algorithms + if (!foundMatch) { + /** + * Craft some useful error output from the MDS algorithms + * + * Example: + * + * ``` + * [ + * 'rsassa_pss_sha256_raw' (COSE info: { kty: 3, alg: -37 }), + * 'secp256k1_ecdsa_sha256_raw' (COSE info: { kty: 2, alg: -47, crv: 8 }) + * ] + * ``` + */ + const debugMDSAlgs = authenticationAlgorithms.map((algSign) => `'${algSign}' (COSE info: ${stringifyCOSEInfo(exports.algSignToCOSEInfoMap[algSign])})`); + const strMDSAlgs = JSON.stringify(debugMDSAlgs, null, 2).replace(/"/g, ''); + /** + * Construct useful error output about the public key + */ + const strPubKeyAlg = stringifyCOSEInfo(publicKeyCOSEInfo); + throw new Error(`Public key parameters ${strPubKeyAlg} did not match any of the following metadata algorithms:\n${strMDSAlgs}`); + } + /** + * Confirm the attestation statement's algorithm is one supported according to metadata + */ + if (attestationStatementAlg !== undefined && + authenticatorGetInfo?.algorithms !== undefined) { + const getInfoAlgs = authenticatorGetInfo.algorithms.map((_alg) => _alg.alg); + if (getInfoAlgs.indexOf(attestationStatementAlg) < 0) { + throw new Error(`Attestation statement alg ${attestationStatementAlg} did not match one of ${getInfoAlgs}`); + } + } + // Prepare to check the certificate chain + const authenticatorCerts = x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM); + const statementRootCerts = attestationRootCertificates.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM); + /** + * If an authenticator returns exactly one certificate in its x5c, and that cert is found in the + * metadata statement then the authenticator is "self-referencing". In this case we forego + * certificate chain validation. + */ + let authenticatorIsSelfReferencing = false; + if (authenticatorCerts.length === 1 && + statementRootCerts.indexOf(authenticatorCerts[0]) >= 0) { + authenticatorIsSelfReferencing = true; + } + if (!authenticatorIsSelfReferencing) { + try { + await (0, validateCertificatePath_js_1.validateCertificatePath)(authenticatorCerts, statementRootCerts); + } + catch (err) { + const _err = err; + throw new Error(`Could not validate certificate path with any metadata root certificates: ${_err.message}`); + } + } + return true; +} +/** + * Convert ALG_SIGN values to COSE info + * + * Values pulled from `ALG_KEY_COSE` definitions in the FIDO Registry of Predefined Values + * + * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#authentication-algorithms + */ +exports.algSignToCOSEInfoMap = { + secp256r1_ecdsa_sha256_raw: { kty: 2, alg: -7, crv: 1 }, + secp256r1_ecdsa_sha256_der: { kty: 2, alg: -7, crv: 1 }, + rsassa_pss_sha256_raw: { kty: 3, alg: -37 }, + rsassa_pss_sha256_der: { kty: 3, alg: -37 }, + secp256k1_ecdsa_sha256_raw: { kty: 2, alg: -47, crv: 8 }, + secp256k1_ecdsa_sha256_der: { kty: 2, alg: -47, crv: 8 }, + rsassa_pss_sha384_raw: { kty: 3, alg: -38 }, + rsassa_pkcsv15_sha256_raw: { kty: 3, alg: -257 }, + rsassa_pkcsv15_sha384_raw: { kty: 3, alg: -258 }, + rsassa_pkcsv15_sha512_raw: { kty: 3, alg: -259 }, + rsassa_pkcsv15_sha1_raw: { kty: 3, alg: -65535 }, + secp384r1_ecdsa_sha384_raw: { kty: 2, alg: -35, crv: 2 }, + secp512r1_ecdsa_sha256_raw: { kty: 2, alg: -36, crv: 3 }, + ed25519_eddsa_sha512_raw: { kty: 1, alg: -8, crv: 6 }, +}; +/** + * A helper to format COSEInfo a little nicer than we can achieve with JSON.stringify() + * + * Input: `{ "kty": 3, "alg": -257 }` + * + * Output: `"{ kty: 3, alg: -257 }"` + */ +function stringifyCOSEInfo(info) { + const { kty, alg, crv } = info; + let toReturn = ''; + if (kty !== cose_js_1.COSEKTY.RSA) { + toReturn = `{ kty: ${kty}, alg: ${alg}, crv: ${crv} }`; + } + else { + toReturn = `{ kty: ${kty}, alg: ${alg} }`; + } + return toReturn; +} diff --git a/node_modules/@simplewebauthn/server/script/metadata/verifyJWT.d.ts b/node_modules/@simplewebauthn/server/script/metadata/verifyJWT.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8f76dcba0448e85b7aadd02fe8cfd3285da2c281 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/verifyJWT.d.ts @@ -0,0 +1,12 @@ +import type { Uint8Array_ } from '../types/index.js'; +/** + * Lightweight verification for FIDO MDS JWTs. Supports use of EC2 and RSA. + * + * If this ever needs to support more JWS algorithms, here's the list of them: + * + * https://www.rfc-editor.org/rfc/rfc7518.html#section-3.1 + * + * (Pulled from https://www.rfc-editor.org/rfc/rfc7515#section-4.1.1) + */ +export declare function verifyJWT(jwt: string, leafCert: Uint8Array_): Promise; +//# sourceMappingURL=verifyJWT.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/verifyJWT.d.ts.map b/node_modules/@simplewebauthn/server/script/metadata/verifyJWT.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..b5e2644c2a37cb941d707d2e6271a09c0ace081f --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/verifyJWT.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyJWT.d.ts","sourceRoot":"","sources":["../../src/metadata/verifyJWT.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CA0B9E"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/verifyJWT.js b/node_modules/@simplewebauthn/server/script/metadata/verifyJWT.js new file mode 100644 index 0000000000000000000000000000000000000000..3625a9b72badf420ad3c87b5810f3334249c8a05 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/verifyJWT.js @@ -0,0 +1,40 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyJWT = verifyJWT; +const convertX509PublicKeyToCOSE_js_1 = require("../helpers/convertX509PublicKeyToCOSE.js"); +const index_js_1 = require("../helpers/iso/index.js"); +const cose_js_1 = require("../helpers/cose.js"); +const verifyEC2_js_1 = require("../helpers/iso/isoCrypto/verifyEC2.js"); +const verifyRSA_js_1 = require("../helpers/iso/isoCrypto/verifyRSA.js"); +/** + * Lightweight verification for FIDO MDS JWTs. Supports use of EC2 and RSA. + * + * If this ever needs to support more JWS algorithms, here's the list of them: + * + * https://www.rfc-editor.org/rfc/rfc7518.html#section-3.1 + * + * (Pulled from https://www.rfc-editor.org/rfc/rfc7515#section-4.1.1) + */ +function verifyJWT(jwt, leafCert) { + const [header, payload, signature] = jwt.split('.'); + const certCOSE = (0, convertX509PublicKeyToCOSE_js_1.convertX509PublicKeyToCOSE)(leafCert); + const data = index_js_1.isoUint8Array.fromUTF8String(`${header}.${payload}`); + const signatureBytes = index_js_1.isoBase64URL.toBuffer(signature); + if ((0, cose_js_1.isCOSEPublicKeyEC2)(certCOSE)) { + return (0, verifyEC2_js_1.verifyEC2)({ + data, + signature: signatureBytes, + cosePublicKey: certCOSE, + shaHashOverride: cose_js_1.COSEALG.ES256, + }); + } + else if ((0, cose_js_1.isCOSEPublicKeyRSA)(certCOSE)) { + return (0, verifyRSA_js_1.verifyRSA)({ + data, + signature: signatureBytes, + cosePublicKey: certCOSE, + }); + } + const kty = certCOSE.get(cose_js_1.COSEKEYS.kty); + throw new Error(`JWT verification with public key of kty ${kty} is not supported by this method`); +} diff --git a/node_modules/@simplewebauthn/server/script/metadata/verifyMDSBlob.d.ts b/node_modules/@simplewebauthn/server/script/metadata/verifyMDSBlob.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..11f42802ae7a15720ca0176f11fc5b5baa3536aa --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/verifyMDSBlob.d.ts @@ -0,0 +1,18 @@ +import type { MDSJWTPayload, MetadataStatement } from './mdsTypes.js'; +/** + * Perform authenticity and integrity verification of a + * [FIDO Metadata Service (MDS)](https://fidoalliance.org/metadata/)-compatible blob, and then + * extract the FIDO2 metadata statements included within. This method will make network requests + * for things like CRL checks. + * + * @param blob - A JWT downloaded from an MDS server (e.g. https://mds3.fidoalliance.org) + */ +export declare function verifyMDSBlob(blob: string): Promise<{ + /** MetadataStatement entries within the verified blob */ + statements: MetadataStatement[]; + /** A JS `Date` instance of the verified blob's `payload.nextUpdate` string */ + parsedNextUpdate: Date; + /** The verified blob's `payload` value */ + payload: MDSJWTPayload; +}>; +//# sourceMappingURL=verifyMDSBlob.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/verifyMDSBlob.d.ts.map b/node_modules/@simplewebauthn/server/script/metadata/verifyMDSBlob.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..a8a61cfa3b2f21883c1c1fbed23b6a41cd7f42fa --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/verifyMDSBlob.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyMDSBlob.d.ts","sourceRoot":"","sources":["../../src/metadata/verifyMDSBlob.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAQpF;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IACzD,yDAAyD;IACzD,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,8EAA8E;IAC9E,gBAAgB,EAAE,IAAI,CAAC;IACvB,0CAA0C;IAC1C,OAAO,EAAE,aAAa,CAAC;CACxB,CAAC,CAuDD"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/metadata/verifyMDSBlob.js b/node_modules/@simplewebauthn/server/script/metadata/verifyMDSBlob.js new file mode 100644 index 0000000000000000000000000000000000000000..282e52d3a3eb29a68be421e516eb5e2bb2f4ad94 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/metadata/verifyMDSBlob.js @@ -0,0 +1,62 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyMDSBlob = verifyMDSBlob; +const parseJWT_js_1 = require("./parseJWT.js"); +const verifyJWT_js_1 = require("./verifyJWT.js"); +const validateCertificatePath_js_1 = require("../helpers/validateCertificatePath.js"); +const convertCertBufferToPEM_js_1 = require("../helpers/convertCertBufferToPEM.js"); +const convertPEMToBytes_js_1 = require("../helpers/convertPEMToBytes.js"); +const settingsService_js_1 = require("../services/settingsService.js"); +/** + * Perform authenticity and integrity verification of a + * [FIDO Metadata Service (MDS)](https://fidoalliance.org/metadata/)-compatible blob, and then + * extract the FIDO2 metadata statements included within. This method will make network requests + * for things like CRL checks. + * + * @param blob - A JWT downloaded from an MDS server (e.g. https://mds3.fidoalliance.org) + */ +async function verifyMDSBlob(blob) { + // Parse the JWT + const parsedJWT = (0, parseJWT_js_1.parseJWT)(blob); + const header = parsedJWT[0]; + const payload = parsedJWT[1]; + const headerCertsPEM = header.x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM); + try { + // Validate the certificate chain + const rootCerts = settingsService_js_1.SettingsService.getRootCertificates({ + identifier: 'mds', + }); + await (0, validateCertificatePath_js_1.validateCertificatePath)(headerCertsPEM, rootCerts); + } + catch (error) { + const _error = error; + // From FIDO MDS docs: "ignore the file if the chain cannot be verified or if one of the + // chain certificates is revoked" + throw new Error('BLOB certificate path could not be validated', { cause: _error }); + } + // Verify the BLOB JWT signature + const leafCert = headerCertsPEM[0]; + const verified = await (0, verifyJWT_js_1.verifyJWT)(blob, (0, convertPEMToBytes_js_1.convertPEMToBytes)(leafCert)); + if (!verified) { + // From FIDO MDS docs: "The FIDO Server SHOULD ignore the file if the signature is invalid." + throw new Error('BLOB signature could not be verified'); + } + // Cache statements for FIDO2 devices + const statements = []; + for (const entry of payload.entries) { + // Only cache entries with an `aaguid` + if (entry.aaguid && entry.metadataStatement) { + statements.push(entry.metadataStatement); + } + } + // Convert the nextUpdate property into a Date so we can determine when to re-download + const [year, month, day] = payload.nextUpdate.split('-'); + const parsedNextUpdate = new Date(parseInt(year, 10), + // Months need to be zero-indexed + parseInt(month, 10) - 1, parseInt(day, 10)); + return { + statements, + parsedNextUpdate, + payload, + }; +} diff --git a/node_modules/@simplewebauthn/server/script/package.json b/node_modules/@simplewebauthn/server/script/package.json new file mode 100644 index 0000000000000000000000000000000000000000..5bbefffbabee392d1855491b84dc0a716b6a3bf2 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/package.json @@ -0,0 +1,3 @@ +{ + "type": "commonjs" +} diff --git a/node_modules/@simplewebauthn/server/script/registration/generateRegistrationOptions.d.ts b/node_modules/@simplewebauthn/server/script/registration/generateRegistrationOptions.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..93bd66d57d3e18ca4ef1a8043bd81c37ab9ced4a --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/generateRegistrationOptions.d.ts @@ -0,0 +1,46 @@ +import type { AuthenticationExtensionsClientInputs, AuthenticatorSelectionCriteria, AuthenticatorTransportFuture, Base64URLString, COSEAlgorithmIdentifier, PublicKeyCredentialCreationOptionsJSON, Uint8Array_ } from '../types/index.js'; +export type GenerateRegistrationOptionsOpts = Parameters[0]; +/** + * Supported crypto algo identifiers + * See https://w3c.github.io/webauthn/#sctn-alg-identifier + * and https://www.iana.org/assignments/cose/cose.xhtml#algorithms + */ +export declare const supportedCOSEAlgorithmIdentifiers: COSEAlgorithmIdentifier[]; +/** + * Prepare a value to pass into navigator.credentials.create(...) for authenticator registration + * + * **Options:** + * + * @param rpName - User-visible, "friendly" website/service name + * @param rpID - Valid domain name (after `https://`) + * @param userName - User's website-specific username (email, etc...) + * @param userID **(Optional)** - User's website-specific unique ID. Defaults to generating a random identifier + * @param challenge **(Optional)** - Random value the authenticator needs to sign and pass back. Defaults to generating a random value + * @param userDisplayName **(Optional)** - User's actual name. Defaults to `""` + * @param timeout **(Optional)** - How long (in ms) the user can take to complete attestation. Defaults to `60000` + * @param attestationType **(Optional)** - Specific attestation statement. Defaults to `"none"` + * @param excludeCredentials **(Optional)** - Authenticators registered by the user so the user can't register the same credential multiple times. Defaults to `[]` + * @param authenticatorSelection **(Optional)** - Advanced criteria for restricting the types of authenticators that may be used. Defaults to `{ residentKey: 'preferred', userVerification: 'preferred' }` + * @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during attestation + * @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported for attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms. Defaults to `[-8, -7, -257]` + * @param preferredAuthenticatorType **(Optional)** - Encourage the browser to prompt the user to register a specific type of authenticator + */ +export declare function generateRegistrationOptions(options: { + rpName: string; + rpID: string; + userName: string; + userID?: Uint8Array_; + challenge?: string | Uint8Array_; + userDisplayName?: string; + timeout?: number; + attestationType?: 'direct' | 'enterprise' | 'none'; + excludeCredentials?: { + id: Base64URLString; + transports?: AuthenticatorTransportFuture[]; + }[]; + authenticatorSelection?: AuthenticatorSelectionCriteria; + extensions?: AuthenticationExtensionsClientInputs; + supportedAlgorithmIDs?: COSEAlgorithmIdentifier[]; + preferredAuthenticatorType?: 'securityKey' | 'localDevice' | 'remoteDevice'; +}): Promise; +//# sourceMappingURL=generateRegistrationOptions.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/generateRegistrationOptions.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/generateRegistrationOptions.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..7dc79d36ef561c85629019cf7b6c8c84d90c9414 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/generateRegistrationOptions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"generateRegistrationOptions.d.ts","sourceRoot":"","sources":["../../src/registration/generateRegistrationOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,8BAA8B,EAC9B,4BAA4B,EAC5B,eAAe,EACf,uBAAuB,EACvB,sCAAsC,EAGtC,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAK3B,MAAM,MAAM,+BAA+B,GAAG,UAAU,CAAC,OAAO,2BAA2B,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhG;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,EAAE,uBAAuB,EAqBtE,CAAC;AAsBF;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE;IACP,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACjC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,QAAQ,GAAG,YAAY,GAAG,MAAM,CAAC;IACnD,kBAAkB,CAAC,EAAE;QACnB,EAAE,EAAE,eAAe,CAAC;QACpB,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;KAC7C,EAAE,CAAC;IACJ,sBAAsB,CAAC,EAAE,8BAA8B,CAAC;IACxD,UAAU,CAAC,EAAE,oCAAoC,CAAC;IAClD,qBAAqB,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAClD,0BAA0B,CAAC,EAAE,aAAa,GAAG,aAAa,GAAG,cAAc,CAAC;CAC7E,GACA,OAAO,CAAC,sCAAsC,CAAC,CAqIjD"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/generateRegistrationOptions.js b/node_modules/@simplewebauthn/server/script/registration/generateRegistrationOptions.js new file mode 100644 index 0000000000000000000000000000000000000000..53663df5bbcf7f477c0dcba1168c6f83ce931d3f --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/generateRegistrationOptions.js @@ -0,0 +1,185 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.supportedCOSEAlgorithmIdentifiers = void 0; +exports.generateRegistrationOptions = generateRegistrationOptions; +const generateChallenge_js_1 = require("../helpers/generateChallenge.js"); +const generateUserID_js_1 = require("../helpers/generateUserID.js"); +const index_js_1 = require("../helpers/iso/index.js"); +/** + * Supported crypto algo identifiers + * See https://w3c.github.io/webauthn/#sctn-alg-identifier + * and https://www.iana.org/assignments/cose/cose.xhtml#algorithms + */ +exports.supportedCOSEAlgorithmIdentifiers = [ + // EdDSA (In first position to encourage authenticators to use this over ES256) + -8, + // ECDSA w/ SHA-256 + -7, + // ECDSA w/ SHA-512 + -36, + // RSASSA-PSS w/ SHA-256 + -37, + // RSASSA-PSS w/ SHA-384 + -38, + // RSASSA-PSS w/ SHA-512 + -39, + // RSASSA-PKCS1-v1_5 w/ SHA-256 + -257, + // RSASSA-PKCS1-v1_5 w/ SHA-384 + -258, + // RSASSA-PKCS1-v1_5 w/ SHA-512 + -259, + // RSASSA-PKCS1-v1_5 w/ SHA-1 (Deprecated; here for legacy support) + -65535, +]; +/** + * Set up some default authenticator selection options as per the latest spec: + * https://www.w3.org/TR/webauthn-2/#dictdef-authenticatorselectioncriteria + * + * Helps with some older platforms (e.g. Android 7.0 Nougat) that may not be aware of these + * defaults. + */ +const defaultAuthenticatorSelection = { + residentKey: 'preferred', + userVerification: 'preferred', +}; +/** + * Use the most commonly-supported algorithms + * See the following: + * - https://www.iana.org/assignments/cose/cose.xhtml#algorithms + * - https://w3c.github.io/webauthn/#dom-publickeycredentialcreationoptions-pubkeycredparams + */ +const defaultSupportedAlgorithmIDs = [-8, -7, -257]; +/** + * Prepare a value to pass into navigator.credentials.create(...) for authenticator registration + * + * **Options:** + * + * @param rpName - User-visible, "friendly" website/service name + * @param rpID - Valid domain name (after `https://`) + * @param userName - User's website-specific username (email, etc...) + * @param userID **(Optional)** - User's website-specific unique ID. Defaults to generating a random identifier + * @param challenge **(Optional)** - Random value the authenticator needs to sign and pass back. Defaults to generating a random value + * @param userDisplayName **(Optional)** - User's actual name. Defaults to `""` + * @param timeout **(Optional)** - How long (in ms) the user can take to complete attestation. Defaults to `60000` + * @param attestationType **(Optional)** - Specific attestation statement. Defaults to `"none"` + * @param excludeCredentials **(Optional)** - Authenticators registered by the user so the user can't register the same credential multiple times. Defaults to `[]` + * @param authenticatorSelection **(Optional)** - Advanced criteria for restricting the types of authenticators that may be used. Defaults to `{ residentKey: 'preferred', userVerification: 'preferred' }` + * @param extensions **(Optional)** - Additional plugins the authenticator or browser should use during attestation + * @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported for attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms. Defaults to `[-8, -7, -257]` + * @param preferredAuthenticatorType **(Optional)** - Encourage the browser to prompt the user to register a specific type of authenticator + */ +async function generateRegistrationOptions(options) { + const { rpName, rpID, userName, userID, challenge = await (0, generateChallenge_js_1.generateChallenge)(), userDisplayName = '', timeout = 60000, attestationType = 'none', excludeCredentials = [], authenticatorSelection = defaultAuthenticatorSelection, extensions, supportedAlgorithmIDs = defaultSupportedAlgorithmIDs, preferredAuthenticatorType, } = options; + /** + * Prepare pubKeyCredParams from the array of algorithm ID's + */ + const pubKeyCredParams = supportedAlgorithmIDs.map((id) => ({ + alg: id, + type: 'public-key', + })); + /** + * Capture some of the nuances of how `residentKey` and `requireResidentKey` how either is set + * depending on when either is defined in the options + */ + if (authenticatorSelection.residentKey === undefined) { + /** + * `residentKey`: "If no value is given then the effective value is `required` if + * requireResidentKey is true or `discouraged` if it is false or absent." + * + * See https://www.w3.org/TR/webauthn-2/#dom-authenticatorselectioncriteria-residentkey + */ + if (authenticatorSelection.requireResidentKey) { + authenticatorSelection.residentKey = 'required'; + } + else { + /** + * FIDO Conformance v1.7.2 fails the first test if we do this, even though this is + * technically compatible with the WebAuthn L2 spec... + */ + // authenticatorSelection.residentKey = 'discouraged'; + } + } + else { + /** + * `requireResidentKey`: "Relying Parties SHOULD set it to true if, and only if, residentKey is + * set to "required"" + * + * Spec says this property defaults to `false` so we should still be okay to assign `false` too + * + * See https://www.w3.org/TR/webauthn-2/#dom-authenticatorselectioncriteria-requireresidentkey + */ + authenticatorSelection.requireResidentKey = authenticatorSelection.residentKey === 'required'; + } + /** + * Preserve ability to specify `string` values for challenges + */ + let _challenge = challenge; + if (typeof _challenge === 'string') { + _challenge = index_js_1.isoUint8Array.fromUTF8String(_challenge); + } + /** + * Explicitly disallow use of strings for userID anymore because `isoBase64URL.fromBuffer()` below + * will return an empty string if one gets through! + */ + if (typeof userID === 'string') { + throw new Error(`String values for \`userID\` are no longer supported. See https://simplewebauthn.dev/docs/advanced/server/custom-user-ids`); + } + /** + * Generate a user ID if one is not provided + */ + let _userID = userID; + if (!_userID) { + _userID = await (0, generateUserID_js_1.generateUserID)(); + } + /** + * Map authenticator preference to hints. Map to authenticatorAttachment as well for + * backwards-compatibility. + */ + const hints = []; + if (preferredAuthenticatorType) { + if (preferredAuthenticatorType === 'securityKey') { + hints.push('security-key'); + authenticatorSelection.authenticatorAttachment = 'cross-platform'; + } + else if (preferredAuthenticatorType === 'localDevice') { + hints.push('client-device'); + authenticatorSelection.authenticatorAttachment = 'platform'; + } + else if (preferredAuthenticatorType === 'remoteDevice') { + hints.push('hybrid'); + authenticatorSelection.authenticatorAttachment = 'cross-platform'; + } + } + return { + challenge: index_js_1.isoBase64URL.fromBuffer(_challenge), + rp: { + name: rpName, + id: rpID, + }, + user: { + id: index_js_1.isoBase64URL.fromBuffer(_userID), + name: userName, + displayName: userDisplayName, + }, + pubKeyCredParams, + timeout, + attestation: attestationType, + excludeCredentials: excludeCredentials.map((cred) => { + if (!index_js_1.isoBase64URL.isBase64URL(cred.id)) { + throw new Error(`excludeCredential id "${cred.id}" is not a valid base64url string`); + } + return { + ...cred, + id: index_js_1.isoBase64URL.trimPadding(cred.id), + type: 'public-key', + }; + }), + authenticatorSelection, + extensions: { + ...extensions, + credProps: true, + }, + hints, + }; +} diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/constants.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/constants.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..64d31c7ca8adfe2e6e1754a8a213876a09cc10ce --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/constants.d.ts @@ -0,0 +1,48 @@ +/** + * A whole lotta domain knowledge is captured here, with hazy connections to source + * documents. Good places to start searching for more info on these values are the + * following Trusted Computing Group TPM Library docs linked in the WebAuthn API: + * + * - https://www.trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-1-Architecture-01.38.pdf + * - https://www.trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf + * - https://www.trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-3-Commands-01.38.pdf + */ +/** + * 6.9 TPM_ST (Structure Tags) + */ +export declare const TPM_ST: { + [key: number]: string; +}; +/** + * 6.3 TPM_ALG_ID + */ +export declare const TPM_ALG: { + [key: number]: string; +}; +/** + * 6.4 TPM_ECC_CURVE + */ +export declare const TPM_ECC_CURVE: { + [key: number]: string; +}; +type ManufacturerInfo = { + name: string; + id: string; +}; +/** + * Sourced from https://trustedcomputinggroup.org/resource/vendor-id-registry/ + * + * Latest version: + * https://trustedcomputinggroup.org/wp-content/uploads/TCG-TPM-Vendor-ID-Registry-Version-1.02-Revision-1.00.pdf + */ +export declare const TPM_MANUFACTURERS: { + [key: string]: ManufacturerInfo; +}; +/** + * Match TPM public area curve ID's to `crv` numbers used in COSE public keys + */ +export declare const TPM_ECC_CURVE_COSE_CRV_MAP: { + [key: string]: number; +}; +export {}; +//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/constants.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/constants.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4e0d35bb70f2499c83f7abd42a7f43d4e267dbb2 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/constants.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/registration/verifications/tpm/constants.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAkB3C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAsC5C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAUlD,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAgChE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAM/D,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/constants.js b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/constants.js new file mode 100644 index 0000000000000000000000000000000000000000..fde16c6fbd4f3a9cbf9ce0b4e71c7e07ef57b33f --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/constants.js @@ -0,0 +1,140 @@ +"use strict"; +// deno-lint-ignore-file no-dupe-keys +/** + * A whole lotta domain knowledge is captured here, with hazy connections to source + * documents. Good places to start searching for more info on these values are the + * following Trusted Computing Group TPM Library docs linked in the WebAuthn API: + * + * - https://www.trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-1-Architecture-01.38.pdf + * - https://www.trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf + * - https://www.trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-3-Commands-01.38.pdf + */ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.TPM_ECC_CURVE_COSE_CRV_MAP = exports.TPM_MANUFACTURERS = exports.TPM_ECC_CURVE = exports.TPM_ALG = exports.TPM_ST = void 0; +/** + * 6.9 TPM_ST (Structure Tags) + */ +exports.TPM_ST = { + 0x00c4: 'TPM_ST_RSP_COMMAND', + 0x8000: 'TPM_ST_NULL', + 0x8001: 'TPM_ST_NO_SESSIONS', + 0x8002: 'TPM_ST_SESSIONS', + 0x8014: 'TPM_ST_ATTEST_NV', + 0x8015: 'TPM_ST_ATTEST_COMMAND_AUDIT', + 0x8016: 'TPM_ST_ATTEST_SESSION_AUDIT', + 0x8017: 'TPM_ST_ATTEST_CERTIFY', + 0x8018: 'TPM_ST_ATTEST_QUOTE', + 0x8019: 'TPM_ST_ATTEST_TIME', + 0x801a: 'TPM_ST_ATTEST_CREATION', + 0x8021: 'TPM_ST_CREATION', + 0x8022: 'TPM_ST_VERIFIED', + 0x8023: 'TPM_ST_AUTH_SECRET', + 0x8024: 'TPM_ST_HASHCHECK', + 0x8025: 'TPM_ST_AUTH_SIGNED', + 0x8029: 'TPM_ST_FU_MANIFEST', +}; +/** + * 6.3 TPM_ALG_ID + */ +exports.TPM_ALG = { + 0x0000: 'TPM_ALG_ERROR', + 0x0001: 'TPM_ALG_RSA', + 0x0004: 'TPM_ALG_SHA', + // @ts-ignore 2300 + 0x0004: 'TPM_ALG_SHA1', + 0x0005: 'TPM_ALG_HMAC', + 0x0006: 'TPM_ALG_AES', + 0x0007: 'TPM_ALG_MGF1', + 0x0008: 'TPM_ALG_KEYEDHASH', + 0x000a: 'TPM_ALG_XOR', + 0x000b: 'TPM_ALG_SHA256', + 0x000c: 'TPM_ALG_SHA384', + 0x000d: 'TPM_ALG_SHA512', + 0x0010: 'TPM_ALG_NULL', + 0x0012: 'TPM_ALG_SM3_256', + 0x0013: 'TPM_ALG_SM4', + 0x0014: 'TPM_ALG_RSASSA', + 0x0015: 'TPM_ALG_RSAES', + 0x0016: 'TPM_ALG_RSAPSS', + 0x0017: 'TPM_ALG_OAEP', + 0x0018: 'TPM_ALG_ECDSA', + 0x0019: 'TPM_ALG_ECDH', + 0x001a: 'TPM_ALG_ECDAA', + 0x001b: 'TPM_ALG_SM2', + 0x001c: 'TPM_ALG_ECSCHNORR', + 0x001d: 'TPM_ALG_ECMQV', + 0x0020: 'TPM_ALG_KDF1_SP800_56A', + 0x0021: 'TPM_ALG_KDF2', + 0x0022: 'TPM_ALG_KDF1_SP800_108', + 0x0023: 'TPM_ALG_ECC', + 0x0025: 'TPM_ALG_SYMCIPHER', + 0x0026: 'TPM_ALG_CAMELLIA', + 0x0040: 'TPM_ALG_CTR', + 0x0041: 'TPM_ALG_OFB', + 0x0042: 'TPM_ALG_CBC', + 0x0043: 'TPM_ALG_CFB', + 0x0044: 'TPM_ALG_ECB', +}; +/** + * 6.4 TPM_ECC_CURVE + */ +exports.TPM_ECC_CURVE = { + 0x0000: 'TPM_ECC_NONE', + 0x0001: 'TPM_ECC_NIST_P192', + 0x0002: 'TPM_ECC_NIST_P224', + 0x0003: 'TPM_ECC_NIST_P256', + 0x0004: 'TPM_ECC_NIST_P384', + 0x0005: 'TPM_ECC_NIST_P521', + 0x0010: 'TPM_ECC_BN_P256', + 0x0011: 'TPM_ECC_BN_P638', + 0x0020: 'TPM_ECC_SM2_P256', +}; +/** + * Sourced from https://trustedcomputinggroup.org/resource/vendor-id-registry/ + * + * Latest version: + * https://trustedcomputinggroup.org/wp-content/uploads/TCG-TPM-Vendor-ID-Registry-Version-1.02-Revision-1.00.pdf + */ +exports.TPM_MANUFACTURERS = { + 'id:414D4400': { name: 'AMD', id: 'AMD' }, + 'id:414E5400': { name: 'Ant Group', id: 'ANT' }, + 'id:41544D4C': { name: 'Atmel', id: 'ATML' }, + 'id:4252434D': { name: 'Broadcom', id: 'BRCM' }, + 'id:4353434F': { name: 'Cisco', id: 'CSCO' }, + 'id:464C5953': { name: 'Flyslice Technologies', id: 'FLYS' }, + 'id:524F4343': { name: 'Fuzhou Rockchip', id: 'ROCC' }, + 'id:474F4F47': { name: 'Google', id: 'GOOG' }, + 'id:48504900': { name: 'HPI', id: 'HPI' }, + 'id:48504500': { name: 'HPE', id: 'HPE' }, + 'id:48495349': { name: 'Huawei', id: 'HISI' }, + 'id:49424d00': { name: 'IBM', id: 'IBM' }, + 'id:49424D00': { name: 'IBM', id: 'IBM' }, // Same ID for IBM as above, except the "D" is capitalized as per TPM spec + 'id:49465800': { name: 'Infineon', id: 'IFX' }, + 'id:494E5443': { name: 'Intel', id: 'INTC' }, + 'id:4C454E00': { name: 'Lenovo', id: 'LEN' }, + 'id:4D534654': { name: 'Microsoft', id: 'MSFT' }, + 'id:4E534D20': { name: 'National Semiconductor', id: 'NSM' }, + 'id:4E545A00': { name: 'Nationz', id: 'NTZ' }, + 'id:4E534700': { name: 'NSING', id: 'NSG' }, + 'id:4E544300': { name: 'Nuvoton Technology', id: 'NTC' }, + 'id:51434F4D': { name: 'Qualcomm', id: 'QCOM' }, + 'id:534D534E': { name: 'Samsung', id: 'SMSN' }, + 'id:53454345': { name: 'SecEdge', id: 'SECE' }, + 'id:534E5300': { name: 'Sinosun', id: 'SNS' }, + 'id:534D5343': { name: 'SMSC', id: 'SMSC' }, + 'id:53544D20': { name: 'STMicroelectronics', id: 'STM' }, + 'id:54584E00': { name: 'Texas Instruments', id: 'TXN' }, + 'id:57454300': { name: 'Winbond', id: 'WEC' }, + 'id:5345414C': { name: 'Wisekey', id: 'SEAL' }, + 'id:FFFFF1D0': { name: 'FIDO Alliance', id: 'FIDO' }, // FIDO Conformance +}; +/** + * Match TPM public area curve ID's to `crv` numbers used in COSE public keys + */ +exports.TPM_ECC_CURVE_COSE_CRV_MAP = { + TPM_ECC_NIST_P256: 1, // p256 + TPM_ECC_NIST_P384: 2, // p384 + TPM_ECC_NIST_P521: 3, // p521 + TPM_ECC_BN_P256: 1, // p256 + TPM_ECC_SM2_P256: 1, // p256 +}; diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parseCertInfo.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parseCertInfo.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf8588a4c4b4f9c9ef11320b0febb1f01d6450d1 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parseCertInfo.d.ts @@ -0,0 +1,26 @@ +import type { Uint8Array_ } from '../../../types/index.js'; +/** + * Cut up a TPM attestation's certInfo into intelligible chunks + */ +export declare function parseCertInfo(certInfo: Uint8Array_): ParsedCertInfo; +type ParsedCertInfo = { + magic: number; + type: string; + qualifiedSigner: Uint8Array_; + extraData: Uint8Array_; + clockInfo: { + clock: Uint8Array_; + resetCount: number; + restartCount: number; + safe: boolean; + }; + firmwareVersion: Uint8Array_; + attested: { + nameAlg: string; + nameAlgBuffer: Uint8Array_; + name: Uint8Array_; + qualifiedName: Uint8Array_; + }; +}; +export {}; +//# sourceMappingURL=parseCertInfo.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parseCertInfo.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parseCertInfo.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..725ef5b78d933e156d59a38da50fec7095351428 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parseCertInfo.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parseCertInfo.d.ts","sourceRoot":"","sources":["../../../../src/registration/verifications/tpm/parseCertInfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,WAAW,GAAG,cAAc,CAkEnE;AAED,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,WAAW,CAAC;IAC7B,SAAS,EAAE,WAAW,CAAC;IACvB,SAAS,EAAE;QACT,KAAK,EAAE,WAAW,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,OAAO,CAAC;KACf,CAAC;IACF,eAAe,EAAE,WAAW,CAAC;IAC7B,QAAQ,EAAE;QACR,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,WAAW,CAAC;QAC3B,IAAI,EAAE,WAAW,CAAC;QAClB,aAAa,EAAE,WAAW,CAAC;KAC5B,CAAC;CACH,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parseCertInfo.js b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parseCertInfo.js new file mode 100644 index 0000000000000000000000000000000000000000..3289639bea26bf61af4d30392622a97441e5db37 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parseCertInfo.js @@ -0,0 +1,61 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parseCertInfo = parseCertInfo; +const constants_js_1 = require("./constants.js"); +const index_js_1 = require("../../../helpers/iso/index.js"); +/** + * Cut up a TPM attestation's certInfo into intelligible chunks + */ +function parseCertInfo(certInfo) { + let pointer = 0; + const dataView = index_js_1.isoUint8Array.toDataView(certInfo); + // Get a magic constant + const magic = dataView.getUint32(pointer); + pointer += 4; + // Determine the algorithm used for attestation + const typeBuffer = dataView.getUint16(pointer); + pointer += 2; + const type = constants_js_1.TPM_ST[typeBuffer]; + // The name of a parent entity, can be ignored + const qualifiedSignerLength = dataView.getUint16(pointer); + pointer += 2; + const qualifiedSigner = certInfo.slice(pointer, pointer += qualifiedSignerLength); + // Get the expected hash of `attsToBeSigned` + const extraDataLength = dataView.getUint16(pointer); + pointer += 2; + const extraData = certInfo.slice(pointer, pointer += extraDataLength); + // Information about the TPM device's internal clock, can be ignored + const clock = certInfo.slice(pointer, pointer += 8); + const resetCount = dataView.getUint32(pointer); + pointer += 4; + const restartCount = dataView.getUint32(pointer); + pointer += 4; + const safe = !!certInfo.slice(pointer, pointer += 1); + const clockInfo = { clock, resetCount, restartCount, safe }; + // TPM device firmware version + const firmwareVersion = certInfo.slice(pointer, pointer += 8); + // Attested Name + const attestedNameLength = dataView.getUint16(pointer); + pointer += 2; + const attestedName = certInfo.slice(pointer, pointer += attestedNameLength); + const attestedNameDataView = index_js_1.isoUint8Array.toDataView(attestedName); + // Attested qualified name, can be ignored + const qualifiedNameLength = dataView.getUint16(pointer); + pointer += 2; + const qualifiedName = certInfo.slice(pointer, pointer += qualifiedNameLength); + const attested = { + nameAlg: constants_js_1.TPM_ALG[attestedNameDataView.getUint16(0)], + nameAlgBuffer: attestedName.slice(0, 2), + name: attestedName, + qualifiedName, + }; + return { + magic, + type, + qualifiedSigner, + extraData, + clockInfo, + firmwareVersion, + attested, + }; +} diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parsePubArea.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parsePubArea.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..b42264a8bb734d13e9248f70b3c427e614b829cf --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parsePubArea.d.ts @@ -0,0 +1,45 @@ +import type { Uint8Array_ } from '../../../types/index.js'; +/** + * Break apart a TPM attestation's pubArea buffer + * + * See 12.2.4 TPMT_PUBLIC here: + * https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-00.96-130315.pdf + */ +export declare function parsePubArea(pubArea: Uint8Array_): ParsedPubArea; +type ParsedPubArea = { + type: 'TPM_ALG_RSA' | 'TPM_ALG_ECC'; + nameAlg: string; + objectAttributes: { + fixedTPM: boolean; + stClear: boolean; + fixedParent: boolean; + sensitiveDataOrigin: boolean; + userWithAuth: boolean; + adminWithPolicy: boolean; + noDA: boolean; + encryptedDuplication: boolean; + restricted: boolean; + decrypt: boolean; + signOrEncrypt: boolean; + }; + authPolicy: Uint8Array_; + parameters: { + rsa?: RSAParameters; + ecc?: ECCParameters; + }; + unique: Uint8Array_; +}; +type RSAParameters = { + symmetric: string; + scheme: string; + keyBits: number; + exponent: number; +}; +type ECCParameters = { + symmetric: string; + scheme: string; + curveID: string; + kdf: string; +}; +export {}; +//# sourceMappingURL=parsePubArea.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parsePubArea.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parsePubArea.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..7136c7106fce2398adce5eb6b4f3f2f60daa4f83 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parsePubArea.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"parsePubArea.d.ts","sourceRoot":"","sources":["../../../../src/registration/verifications/tpm/parsePubArea.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,aAAa,CAyGhE;AAED,KAAK,aAAa,GAAG;IACnB,IAAI,EAAE,aAAa,GAAG,aAAa,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE;QAChB,QAAQ,EAAE,OAAO,CAAC;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,EAAE,OAAO,CAAC;QACrB,mBAAmB,EAAE,OAAO,CAAC;QAC7B,YAAY,EAAE,OAAO,CAAC;QACtB,eAAe,EAAE,OAAO,CAAC;QACzB,IAAI,EAAE,OAAO,CAAC;QACd,oBAAoB,EAAE,OAAO,CAAC;QAC9B,UAAU,EAAE,OAAO,CAAC;QACpB,OAAO,EAAE,OAAO,CAAC;QACjB,aAAa,EAAE,OAAO,CAAC;KACxB,CAAC;IACF,UAAU,EAAE,WAAW,CAAC;IACxB,UAAU,EAAE;QACV,GAAG,CAAC,EAAE,aAAa,CAAC;QACpB,GAAG,CAAC,EAAE,aAAa,CAAC;KACrB,CAAC;IACF,MAAM,EAAE,WAAW,CAAC;CACrB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parsePubArea.js b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parsePubArea.js new file mode 100644 index 0000000000000000000000000000000000000000..6fc704aad1e78803290f177bff961f9c9e17127d --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/parsePubArea.js @@ -0,0 +1,97 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.parsePubArea = parsePubArea; +const constants_js_1 = require("./constants.js"); +const index_js_1 = require("../../../helpers/iso/index.js"); +/** + * Break apart a TPM attestation's pubArea buffer + * + * See 12.2.4 TPMT_PUBLIC here: + * https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-00.96-130315.pdf + */ +function parsePubArea(pubArea) { + let pointer = 0; + const dataView = index_js_1.isoUint8Array.toDataView(pubArea); + const type = constants_js_1.TPM_ALG[dataView.getUint16(pointer)]; + pointer += 2; + const nameAlg = constants_js_1.TPM_ALG[dataView.getUint16(pointer)]; + pointer += 2; + // Get some authenticator attributes(?) + // const objectAttributesInt = pubArea.slice(pointer, (pointer += 4)).readUInt32BE(0); + const objectAttributesInt = dataView.getUint32(pointer); + pointer += 4; + const objectAttributes = { + fixedTPM: !!(objectAttributesInt & 1), + stClear: !!(objectAttributesInt & 2), + fixedParent: !!(objectAttributesInt & 8), + sensitiveDataOrigin: !!(objectAttributesInt & 16), + userWithAuth: !!(objectAttributesInt & 32), + adminWithPolicy: !!(objectAttributesInt & 64), + noDA: !!(objectAttributesInt & 512), + encryptedDuplication: !!(objectAttributesInt & 1024), + restricted: !!(objectAttributesInt & 32768), + decrypt: !!(objectAttributesInt & 65536), + signOrEncrypt: !!(objectAttributesInt & 131072), + }; + // Slice out the authPolicy of dynamic length + const authPolicyLength = dataView.getUint16(pointer); + pointer += 2; + const authPolicy = pubArea.slice(pointer, pointer += authPolicyLength); + // Extract additional curve params according to type + const parameters = {}; + let unique = Uint8Array.from([]); + if (type === 'TPM_ALG_RSA') { + const symmetric = constants_js_1.TPM_ALG[dataView.getUint16(pointer)]; + pointer += 2; + const scheme = constants_js_1.TPM_ALG[dataView.getUint16(pointer)]; + pointer += 2; + const keyBits = dataView.getUint16(pointer); + pointer += 2; + const exponent = dataView.getUint32(pointer); + pointer += 4; + parameters.rsa = { symmetric, scheme, keyBits, exponent }; + /** + * See 11.2.4.5 TPM2B_PUBLIC_KEY_RSA here: + * https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-00.96-130315.pdf + */ + // const uniqueLength = pubArea.slice(pointer, (pointer += 2)).readUInt16BE(0); + const uniqueLength = dataView.getUint16(pointer); + pointer += 2; + unique = pubArea.slice(pointer, pointer += uniqueLength); + } + else if (type === 'TPM_ALG_ECC') { + const symmetric = constants_js_1.TPM_ALG[dataView.getUint16(pointer)]; + pointer += 2; + const scheme = constants_js_1.TPM_ALG[dataView.getUint16(pointer)]; + pointer += 2; + const curveID = constants_js_1.TPM_ECC_CURVE[dataView.getUint16(pointer)]; + pointer += 2; + const kdf = constants_js_1.TPM_ALG[dataView.getUint16(pointer)]; + pointer += 2; + parameters.ecc = { symmetric, scheme, curveID, kdf }; + /** + * See 11.2.5.1 TPM2B_ECC_PARAMETER here: + * https://trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-00.96-130315.pdf + */ + // Retrieve X + const uniqueXLength = dataView.getUint16(pointer); + pointer += 2; + const uniqueX = pubArea.slice(pointer, pointer += uniqueXLength); + // Retrieve Y + const uniqueYLength = dataView.getUint16(pointer); + pointer += 2; + const uniqueY = pubArea.slice(pointer, pointer += uniqueYLength); + unique = index_js_1.isoUint8Array.concat([uniqueX, uniqueY]); + } + else { + throw new Error(`Unexpected type "${type}" (TPM)`); + } + return { + type, + nameAlg, + objectAttributes, + authPolicy, + parameters, + unique, + }; +} diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/verifyAttestationTPM.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/verifyAttestationTPM.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..87ad07f4cefc1d3d2d7eec64993482a62dfea53e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/verifyAttestationTPM.d.ts @@ -0,0 +1,3 @@ +import type { AttestationFormatVerifierOpts } from '../../verifyRegistrationResponse.js'; +export declare function verifyAttestationTPM(options: AttestationFormatVerifierOpts): Promise; +//# sourceMappingURL=verifyAttestationTPM.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/verifyAttestationTPM.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/verifyAttestationTPM.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..3859702eadda6049c6e6d3c6bccf47e45190e3e5 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/verifyAttestationTPM.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyAttestationTPM.d.ts","sourceRoot":"","sources":["../../../../src/registration/verifications/tpm/verifyAttestationTPM.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AAwBzF,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CA+VlB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/verifyAttestationTPM.js b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/verifyAttestationTPM.js new file mode 100644 index 0000000000000000000000000000000000000000..8379a30e056dffb9e786d163cdf67502f76010ee --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/tpm/verifyAttestationTPM.js @@ -0,0 +1,334 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyAttestationTPM = verifyAttestationTPM; +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const decodeCredentialPublicKey_js_1 = require("../../../helpers/decodeCredentialPublicKey.js"); +const cose_js_1 = require("../../../helpers/cose.js"); +const toHash_js_1 = require("../../../helpers/toHash.js"); +const convertCertBufferToPEM_js_1 = require("../../../helpers/convertCertBufferToPEM.js"); +const validateCertificatePath_js_1 = require("../../../helpers/validateCertificatePath.js"); +const getCertificateInfo_js_1 = require("../../../helpers/getCertificateInfo.js"); +const verifySignature_js_1 = require("../../../helpers/verifySignature.js"); +const index_js_1 = require("../../../helpers/iso/index.js"); +const validateExtFIDOGenCEAAGUID_js_1 = require("../../../helpers/validateExtFIDOGenCEAAGUID.js"); +const metadataService_js_1 = require("../../../services/metadataService.js"); +const verifyAttestationWithMetadata_js_1 = require("../../../metadata/verifyAttestationWithMetadata.js"); +const constants_js_1 = require("./constants.js"); +const parseCertInfo_js_1 = require("./parseCertInfo.js"); +const parsePubArea_js_1 = require("./parsePubArea.js"); +async function verifyAttestationTPM(options) { + const { aaguid, attStmt, authData, credentialPublicKey, clientDataHash, rootCertificates, } = options; + const ver = attStmt.get('ver'); + const sig = attStmt.get('sig'); + const alg = attStmt.get('alg'); + const x5c = attStmt.get('x5c'); + const pubArea = attStmt.get('pubArea'); + const certInfo = attStmt.get('certInfo'); + /** + * Verify structures + */ + if (ver !== '2.0') { + throw new Error(`Unexpected ver "${ver}", expected "2.0" (TPM)`); + } + if (!sig) { + throw new Error('No attestation signature provided in attestation statement (TPM)'); + } + if (!alg) { + throw new Error(`Attestation statement did not contain alg (TPM)`); + } + if (!(0, cose_js_1.isCOSEAlg)(alg)) { + throw new Error(`Attestation statement contained invalid alg ${alg} (TPM)`); + } + if (!x5c) { + throw new Error('No attestation certificate provided in attestation statement (TPM)'); + } + if (!pubArea) { + throw new Error('Attestation statement did not contain pubArea (TPM)'); + } + if (!certInfo) { + throw new Error('Attestation statement did not contain certInfo (TPM)'); + } + const parsedPubArea = (0, parsePubArea_js_1.parsePubArea)(pubArea); + const { unique, type: pubType, parameters } = parsedPubArea; + // Verify that the public key specified by the parameters and unique fields of pubArea is + // identical to the credentialPublicKey in the attestedCredentialData in authenticatorData. + const cosePublicKey = (0, decodeCredentialPublicKey_js_1.decodeCredentialPublicKey)(credentialPublicKey); + if (pubType === 'TPM_ALG_RSA') { + if (!(0, cose_js_1.isCOSEPublicKeyRSA)(cosePublicKey)) { + throw new Error(`Credential public key with kty ${cosePublicKey.get(cose_js_1.COSEKEYS.kty)} did not match ${pubType}`); + } + const n = cosePublicKey.get(cose_js_1.COSEKEYS.n); + const e = cosePublicKey.get(cose_js_1.COSEKEYS.e); + if (!n) { + throw new Error('COSE public key missing n (TPM|RSA)'); + } + if (!e) { + throw new Error('COSE public key missing e (TPM|RSA)'); + } + if (!index_js_1.isoUint8Array.areEqual(unique, n)) { + throw new Error('PubArea unique is not same as credentialPublicKey (TPM|RSA)'); + } + if (!parameters.rsa) { + throw new Error(`Parsed pubArea type is RSA, but missing parameters.rsa (TPM|RSA)`); + } + const eBuffer = e; + // If `exponent` is equal to 0x00, then exponent is the default RSA exponent of 2^16+1 (65537) + const pubAreaExponent = parameters.rsa.exponent || 65537; + // Do some bit shifting to get to an integer + const eSum = eBuffer[0] + (eBuffer[1] << 8) + (eBuffer[2] << 16); + if (pubAreaExponent !== eSum) { + throw new Error(`Unexpected public key exp ${eSum}, expected ${pubAreaExponent} (TPM|RSA)`); + } + } + else if (pubType === 'TPM_ALG_ECC') { + if (!(0, cose_js_1.isCOSEPublicKeyEC2)(cosePublicKey)) { + throw new Error(`Credential public key with kty ${cosePublicKey.get(cose_js_1.COSEKEYS.kty)} did not match ${pubType}`); + } + const crv = cosePublicKey.get(cose_js_1.COSEKEYS.crv); + const x = cosePublicKey.get(cose_js_1.COSEKEYS.x); + const y = cosePublicKey.get(cose_js_1.COSEKEYS.y); + if (!crv) { + throw new Error('COSE public key missing crv (TPM|ECC)'); + } + if (!x) { + throw new Error('COSE public key missing x (TPM|ECC)'); + } + if (!y) { + throw new Error('COSE public key missing y (TPM|ECC)'); + } + if (!index_js_1.isoUint8Array.areEqual(unique, index_js_1.isoUint8Array.concat([x, y]))) { + throw new Error('PubArea unique is not same as public key x and y (TPM|ECC)'); + } + if (!parameters.ecc) { + throw new Error(`Parsed pubArea type is ECC, but missing parameters.ecc (TPM|ECC)`); + } + const pubAreaCurveID = parameters.ecc.curveID; + const pubAreaCurveIDMapToCOSECRV = constants_js_1.TPM_ECC_CURVE_COSE_CRV_MAP[pubAreaCurveID]; + if (pubAreaCurveIDMapToCOSECRV !== crv) { + throw new Error(`Public area key curve ID "${pubAreaCurveID}" mapped to "${pubAreaCurveIDMapToCOSECRV}" which did not match public key crv of "${crv}" (TPM|ECC)`); + } + } + else { + throw new Error(`Unsupported pubArea.type "${pubType}"`); + } + const parsedCertInfo = (0, parseCertInfo_js_1.parseCertInfo)(certInfo); + const { magic, type: certType, attested, extraData } = parsedCertInfo; + if (magic !== 0xff544347) { + throw new Error(`Unexpected magic value "${magic}", expected "0xff544347" (TPM)`); + } + if (certType !== 'TPM_ST_ATTEST_CERTIFY') { + throw new Error(`Unexpected type "${certType}", expected "TPM_ST_ATTEST_CERTIFY" (TPM)`); + } + // Hash pubArea to create pubAreaHash using the nameAlg in attested + const pubAreaHash = await (0, toHash_js_1.toHash)(pubArea, attestedNameAlgToCOSEAlg(attested.nameAlg)); + // Concatenate attested.nameAlg and pubAreaHash to create attestedName. + const attestedName = index_js_1.isoUint8Array.concat([ + attested.nameAlgBuffer, + pubAreaHash, + ]); + // Check that certInfo.attested.name is equals to attestedName. + if (!index_js_1.isoUint8Array.areEqual(attested.name, attestedName)) { + throw new Error(`Attested name comparison failed (TPM)`); + } + // Concatenate authData with clientDataHash to create attToBeSigned + const attToBeSigned = index_js_1.isoUint8Array.concat([authData, clientDataHash]); + // Hash attToBeSigned using the algorithm specified in attStmt.alg to create attToBeSignedHash + const attToBeSignedHash = await (0, toHash_js_1.toHash)(attToBeSigned, alg); + // Check that certInfo.extraData is equals to attToBeSignedHash. + if (!index_js_1.isoUint8Array.areEqual(extraData, attToBeSignedHash)) { + throw new Error('CertInfo extra data did not equal hashed attestation (TPM)'); + } + /** + * Verify signature + */ + if (x5c.length < 1) { + throw new Error('No certificates present in x5c array (TPM)'); + } + // Pick a leaf AIK certificate of the x5c array and parse it. + const leafCertInfo = (0, getCertificateInfo_js_1.getCertificateInfo)(x5c[0]); + const { basicConstraintsCA, version, subject, notAfter, notBefore } = leafCertInfo; + if (basicConstraintsCA) { + throw new Error('Certificate basic constraints CA was not `false` (TPM)'); + } + // Check that certificate is of version 3 (value must be set to 2). + if (version !== 2) { + throw new Error('Certificate version was not `3` (ASN.1 value of 2) (TPM)'); + } + // Check that Subject sequence is empty. + if (subject.combined.length > 0) { + throw new Error('Certificate subject was not empty (TPM)'); + } + // Check that certificate is currently valid + let now = new Date(); + if (notBefore > now) { + throw new Error(`Certificate not good before "${notBefore.toString()}" (TPM)`); + } + // Check that certificate has not expired + now = new Date(); + if (notAfter < now) { + throw new Error(`Certificate not good after "${notAfter.toString()}" (TPM)`); + } + /** + * Plumb the depths of the certificate's ASN.1-formatted data for some values we need to verify + */ + const parsedCert = asn1_schema_1.AsnParser.parse(x5c[0], asn1_x509_1.Certificate); + if (!parsedCert.tbsCertificate.extensions) { + throw new Error('Certificate was missing extensions (TPM)'); + } + let subjectAltNamePresent; + let extKeyUsage; + parsedCert.tbsCertificate.extensions.forEach((ext) => { + if (ext.extnID === asn1_x509_1.id_ce_subjectAltName) { + subjectAltNamePresent = asn1_schema_1.AsnParser.parse(ext.extnValue, asn1_x509_1.SubjectAlternativeName); + } + else if (ext.extnID === asn1_x509_1.id_ce_extKeyUsage) { + extKeyUsage = asn1_schema_1.AsnParser.parse(ext.extnValue, asn1_x509_1.ExtendedKeyUsage); + } + }); + // Check that certificate contains subjectAltName (2.5.29.17) extension, + if (!subjectAltNamePresent) { + throw new Error('Certificate did not contain subjectAltName extension (TPM)'); + } + // TPM-specific values are buried within `directoryName`, so first make sure there are values + // there. + if (!subjectAltNamePresent[0].directoryName?.[0].length) { + throw new Error('Certificate subjectAltName extension directoryName was empty (TPM)'); + } + const { tcgAtTpmManufacturer, tcgAtTpmModel, tcgAtTpmVersion } = getTcgAtTpmValues(subjectAltNamePresent[0].directoryName); + if (!tcgAtTpmManufacturer || !tcgAtTpmModel || !tcgAtTpmVersion) { + throw new Error('Certificate contained incomplete subjectAltName data (TPM)'); + } + if (!extKeyUsage) { + throw new Error('Certificate did not contain ExtendedKeyUsage extension (TPM)'); + } + // Check that tcpaTpmManufacturer (2.23.133.2.1) field is set to a valid manufacturer ID. + if (!constants_js_1.TPM_MANUFACTURERS[tcgAtTpmManufacturer]) { + throw new Error(`Could not match TPM manufacturer "${tcgAtTpmManufacturer}" (TPM)`); + } + // Check that certificate contains extKeyUsage (2.5.29.37) extension and it must contain + // tcg-kp-AIKCertificate (2.23.133.8.3) OID. + if (extKeyUsage[0] !== '2.23.133.8.3') { + throw new Error(`Unexpected extKeyUsage "${extKeyUsage[0]}", expected "2.23.133.8.3" (TPM)`); + } + // Validate attestation statement AAGUID against leaf cert AAGUID + try { + await (0, validateExtFIDOGenCEAAGUID_js_1.validateExtFIDOGenCEAAGUID)(parsedCert.tbsCertificate.extensions, aaguid); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (TPM)`); + } + // Run some metadata checks if a statement exists for this authenticator + const statement = await metadataService_js_1.MetadataService.getStatement(aaguid); + if (statement) { + try { + await (0, verifyAttestationWithMetadata_js_1.verifyAttestationWithMetadata)({ + statement, + credentialPublicKey, + x5c, + attestationStatementAlg: alg, + }); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (TPM)`); + } + } + else { + try { + // Try validating the certificate path using the root certificates set via SettingsService + await (0, validateCertificatePath_js_1.validateCertificatePath)(x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM), rootCertificates); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (TPM)`); + } + } + // Verify signature over certInfo with the public key extracted from AIK certificate. + // In the wise words of Yuriy Ackermann: "Get Martini friend, you are done!" + return (0, verifySignature_js_1.verifySignature)({ + signature: sig, + data: certInfo, + x509Certificate: x5c[0], + hashAlgorithm: alg, + }); +} +/** + * Contain logic for pulling TPM-specific values out of subjectAlternativeName extension + */ +function getTcgAtTpmValues(root) { + const oidManufacturer = '2.23.133.2.1'; + const oidModel = '2.23.133.2.2'; + const oidVersion = '2.23.133.2.3'; + let tcgAtTpmManufacturer; + let tcgAtTpmModel; + let tcgAtTpmVersion; + /** + * Iterate through the following potential structures: + * + * (Good, follows the spec) + * https://trustedcomputinggroup.org/wp-content/uploads/TCG_IWG_EKCredentialProfile_v2p3_r2_pub.pdf (page 33) + * Name [ + * RelativeDistinguishedName [ + * AttributeTypeAndValue { type, value } + * ] + * RelativeDistinguishedName [ + * AttributeTypeAndValue { type, value } + * ] + * RelativeDistinguishedName [ + * AttributeTypeAndValue { type, value } + * ] + * ] + * + * (Bad, does not follow the spec) + * Name [ + * RelativeDistinguishedName [ + * AttributeTypeAndValue { type, value } + * AttributeTypeAndValue { type, value } + * AttributeTypeAndValue { type, value } + * ] + * ] + * + * Both structures have been seen in the wild and need to be supported + */ + root.forEach((relName) => { + relName.forEach((attr) => { + if (attr.type === oidManufacturer) { + tcgAtTpmManufacturer = attr.value.toString(); + } + else if (attr.type === oidModel) { + tcgAtTpmModel = attr.value.toString(); + } + else if (attr.type === oidVersion) { + tcgAtTpmVersion = attr.value.toString(); + } + }); + }); + return { + tcgAtTpmManufacturer, + tcgAtTpmModel, + tcgAtTpmVersion, + }; +} +/** + * Convert TPM-specific SHA algorithm ID's with COSE-specific equivalents. Note that the choice to + * use ECDSA SHA IDs is arbitrary; any such COSEALG that would map to SHA-256 in + * `mapCoseAlgToWebCryptoAlg()` + * + * SHA IDs referenced from here: + * + * https://trustedcomputinggroup.org/wp-content/uploads/TCG_TPM2_r1p59_Part2_Structures_pub.pdf + */ +function attestedNameAlgToCOSEAlg(alg) { + if (alg === 'TPM_ALG_SHA256') { + return cose_js_1.COSEALG.ES256; + } + else if (alg === 'TPM_ALG_SHA384') { + return cose_js_1.COSEALG.ES384; + } + else if (alg === 'TPM_ALG_SHA512') { + return cose_js_1.COSEALG.ES512; + } + throw new Error(`Unexpected TPM attested name alg ${alg}`); +} diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidKey.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidKey.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3c3566a3f1b81c58e9422e4b14ce6946b9280cae --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidKey.d.ts @@ -0,0 +1,6 @@ +import type { AttestationFormatVerifierOpts } from '../verifyRegistrationResponse.js'; +/** + * Verify an attestation response with fmt 'android-key' + */ +export declare function verifyAttestationAndroidKey(options: AttestationFormatVerifierOpts): Promise; +//# sourceMappingURL=verifyAttestationAndroidKey.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidKey.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidKey.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..4bd3129e9e10f9587ae93cb5cb0eb4ed339a1457 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidKey.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyAttestationAndroidKey.d.ts","sourceRoot":"","sources":["../../../src/registration/verifications/verifyAttestationAndroidKey.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAUtF;;GAEG;AACH,wBAAsB,2BAA2B,CAC/C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CA0JlB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidKey.js b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidKey.js new file mode 100644 index 0000000000000000000000000000000000000000..8d5447ccad87fcba6797b0252676041a860ba92f --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidKey.js @@ -0,0 +1,123 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyAttestationAndroidKey = verifyAttestationAndroidKey; +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const asn1_android_1 = require("@peculiar/asn1-android"); +const convertCertBufferToPEM_js_1 = require("../../helpers/convertCertBufferToPEM.js"); +const validateCertificatePath_js_1 = require("../../helpers/validateCertificatePath.js"); +const verifySignature_js_1 = require("../../helpers/verifySignature.js"); +const convertCOSEtoPKCS_js_1 = require("../../helpers/convertCOSEtoPKCS.js"); +const cose_js_1 = require("../../helpers/cose.js"); +const index_js_1 = require("../../helpers/iso/index.js"); +const metadataService_js_1 = require("../../services/metadataService.js"); +const verifyAttestationWithMetadata_js_1 = require("../../metadata/verifyAttestationWithMetadata.js"); +/** + * Verify an attestation response with fmt 'android-key' + */ +async function verifyAttestationAndroidKey(options) { + const { authData, clientDataHash, attStmt, credentialPublicKey, aaguid, rootCertificates, } = options; + const x5c = attStmt.get('x5c'); + const sig = attStmt.get('sig'); + const alg = attStmt.get('alg'); + if (!x5c) { + throw new Error('No attestation certificate provided in attestation statement (Android Key)'); + } + if (!sig) { + throw new Error('No attestation signature provided in attestation statement (Android Key)'); + } + if (!alg) { + throw new Error(`Attestation statement did not contain alg (Android Key)`); + } + if (!(0, cose_js_1.isCOSEAlg)(alg)) { + throw new Error(`Attestation statement contained invalid alg ${alg} (Android Key)`); + } + /** + * Verify that the public key in the first certificate in x5c matches the credentialPublicKey in + * the attestedCredentialData in authenticatorData. + */ + // Find the public cert in the certificate as PKCS + const parsedCert = asn1_schema_1.AsnParser.parse(x5c[0], asn1_x509_1.Certificate); + const parsedCertPubKey = new Uint8Array(parsedCert.tbsCertificate.subjectPublicKeyInfo.subjectPublicKey); + // Convert the credentialPublicKey to PKCS + const credPubKeyPKCS = (0, convertCOSEtoPKCS_js_1.convertCOSEtoPKCS)(credentialPublicKey); + if (!index_js_1.isoUint8Array.areEqual(credPubKeyPKCS, parsedCertPubKey)) { + throw new Error('Credential public key does not equal leaf cert public key (Android Key)'); + } + /** + * Verify that the attestationChallenge field in the attestation certificate extension data is + * identical to clientDataHash. + */ + // Find Android KeyStore Extension in certificate extensions + const extKeyStore = parsedCert.tbsCertificate.extensions?.find((ext) => ext.extnID === asn1_android_1.id_ce_keyDescription); + if (!extKeyStore) { + throw new Error('Certificate did not contain extKeyStore (Android Key)'); + } + const parsedExtKeyStore = asn1_schema_1.AsnParser.parse(extKeyStore.extnValue, asn1_android_1.KeyDescription); + // Verify extKeyStore values + const { attestationChallenge, teeEnforced, softwareEnforced } = parsedExtKeyStore; + if (!index_js_1.isoUint8Array.areEqual(new Uint8Array(attestationChallenge.buffer), clientDataHash)) { + throw new Error('Attestation challenge was not equal to client data hash (Android Key)'); + } + /** + * The AuthorizationList.allApplications field is not present on either authorization list + * (softwareEnforced nor teeEnforced), since PublicKeyCredential MUST be scoped to the RP ID. + * + * (i.e. These shouldn't contain the [600] tag) + */ + if (teeEnforced.allApplications !== undefined) { + throw new Error('teeEnforced contained "allApplications [600]" tag (Android Key)'); + } + if (softwareEnforced.allApplications !== undefined) { + throw new Error('teeEnforced contained "allApplications [600]" tag (Android Key)'); + } + const statement = await metadataService_js_1.MetadataService.getStatement(aaguid); + if (statement) { + try { + await (0, verifyAttestationWithMetadata_js_1.verifyAttestationWithMetadata)({ + statement, + credentialPublicKey, + x5c, + attestationStatementAlg: alg, + }); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (Android Key)`, { cause: _err }); + } + } + else { + /** + * Verify that x5c contains a full certificate path. + */ + const x5cNoRootPEM = x5c.slice(0, -1).map(convertCertBufferToPEM_js_1.convertCertBufferToPEM); + const x5cRootPEM = x5c.slice(-1).map(convertCertBufferToPEM_js_1.convertCertBufferToPEM); + try { + await (0, validateCertificatePath_js_1.validateCertificatePath)(x5cNoRootPEM, x5cRootPEM); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (Android Key)`, { cause: _err }); + } + /** + * Make sure the root certificate is one of the Google Hardware Attestation Root certificates + * + * https://developer.android.com/privacy-and-security/security-key-attestation#root_certificate + */ + if (rootCertificates.length > 0 && rootCertificates.indexOf(x5cRootPEM[0]) < 0) { + throw new Error('x5c root certificate was not a known root certificate (Android Key)'); + } + } + /** + * Verify that sig is a valid signature over the concatenation of authenticatorData and + * clientDataHash using the public key in the first certificate in x5c with the algorithm + * specified in alg. + */ + const signatureBase = index_js_1.isoUint8Array.concat([authData, clientDataHash]); + return (0, verifySignature_js_1.verifySignature)({ + signature: sig, + data: signatureBase, + x509Certificate: x5c[0], + hashAlgorithm: alg, + }); +} diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..411eda1f30e60817636d6421e535125cde5d1b47 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts @@ -0,0 +1,6 @@ +import type { AttestationFormatVerifierOpts } from '../verifyRegistrationResponse.js'; +/** + * Verify an attestation response with fmt 'android-safetynet' + */ +export declare function verifyAttestationAndroidSafetyNet(options: AttestationFormatVerifierOpts): Promise; +//# sourceMappingURL=verifyAttestationAndroidSafetyNet.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..a22ee0a90b8ed88451aa6c5ec5b9d0f231f4d82a --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyAttestationAndroidSafetyNet.d.ts","sourceRoot":"","sources":["../../../src/registration/verifications/verifyAttestationAndroidSafetyNet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAWtF;;GAEG;AACH,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CA6IlB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidSafetyNet.js b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidSafetyNet.js new file mode 100644 index 0000000000000000000000000000000000000000..efcab22dbddb4aedb482ad88e8f7ef04c3f79061 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationAndroidSafetyNet.js @@ -0,0 +1,116 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyAttestationAndroidSafetyNet = verifyAttestationAndroidSafetyNet; +const toHash_js_1 = require("../../helpers/toHash.js"); +const verifySignature_js_1 = require("../../helpers/verifySignature.js"); +const getCertificateInfo_js_1 = require("../../helpers/getCertificateInfo.js"); +const validateCertificatePath_js_1 = require("../../helpers/validateCertificatePath.js"); +const convertCertBufferToPEM_js_1 = require("../../helpers/convertCertBufferToPEM.js"); +const index_js_1 = require("../../helpers/iso/index.js"); +const metadataService_js_1 = require("../../services/metadataService.js"); +const verifyAttestationWithMetadata_js_1 = require("../../metadata/verifyAttestationWithMetadata.js"); +/** + * Verify an attestation response with fmt 'android-safetynet' + */ +async function verifyAttestationAndroidSafetyNet(options) { + const { attStmt, clientDataHash, authData, aaguid, rootCertificates, verifyTimestampMS = true, credentialPublicKey, attestationSafetyNetEnforceCTSCheck, } = options; + const alg = attStmt.get('alg'); + const response = attStmt.get('response'); + const ver = attStmt.get('ver'); + if (!ver) { + throw new Error('No ver value in attestation (SafetyNet)'); + } + if (!response) { + throw new Error('No response was included in attStmt by authenticator (SafetyNet)'); + } + // Prepare to verify a JWT + const jwt = index_js_1.isoUint8Array.toUTF8String(response); + const jwtParts = jwt.split('.'); + const HEADER = JSON.parse(index_js_1.isoBase64URL.toUTF8String(jwtParts[0])); + const PAYLOAD = JSON.parse(index_js_1.isoBase64URL.toUTF8String(jwtParts[1])); + const SIGNATURE = jwtParts[2]; + /** + * START Verify PAYLOAD + */ + const { nonce, ctsProfileMatch, timestampMs } = PAYLOAD; + if (verifyTimestampMS) { + // Make sure timestamp is in the past + let now = Date.now(); + if (timestampMs > Date.now()) { + throw new Error(`Payload timestamp "${timestampMs}" was later than "${now}" (SafetyNet)`); + } + // Consider a SafetyNet attestation valid within a minute of it being performed + const timestampPlusDelay = timestampMs + 60 * 1000; + now = Date.now(); + if (timestampPlusDelay < now) { + throw new Error(`Payload timestamp "${timestampPlusDelay}" has expired (SafetyNet)`); + } + } + const nonceBase = index_js_1.isoUint8Array.concat([authData, clientDataHash]); + const nonceBuffer = await (0, toHash_js_1.toHash)(nonceBase); + const expectedNonce = index_js_1.isoBase64URL.fromBuffer(nonceBuffer, 'base64'); + if (nonce !== expectedNonce) { + throw new Error('Could not verify payload nonce (SafetyNet)'); + } + if (attestationSafetyNetEnforceCTSCheck && !ctsProfileMatch) { + throw new Error('Could not verify device integrity (SafetyNet)'); + } + /** + * END Verify PAYLOAD + */ + /** + * START Verify Header + */ + // `HEADER.x5c[0]` is definitely a base64 string + const leafCertBuffer = index_js_1.isoBase64URL.toBuffer(HEADER.x5c[0], 'base64'); + const leafCertInfo = (0, getCertificateInfo_js_1.getCertificateInfo)(leafCertBuffer); + const { subject } = leafCertInfo; + // Ensure the certificate was issued to this hostname + // See https://developer.android.com/training/safetynet/attestation#verify-attestation-response + if (subject.CN !== 'attest.android.com') { + throw new Error('Certificate common name was not "attest.android.com" (SafetyNet)'); + } + const statement = await metadataService_js_1.MetadataService.getStatement(aaguid); + if (statement) { + try { + await (0, verifyAttestationWithMetadata_js_1.verifyAttestationWithMetadata)({ + statement, + credentialPublicKey, + x5c: HEADER.x5c, + attestationStatementAlg: alg, + }); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (SafetyNet)`); + } + } + else { + try { + // Try validating the certificate path using the root certificates set via SettingsService + await (0, validateCertificatePath_js_1.validateCertificatePath)(HEADER.x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM), rootCertificates); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (SafetyNet)`); + } + } + /** + * END Verify Header + */ + /** + * START Verify Signature + */ + const signatureBaseBuffer = index_js_1.isoUint8Array.fromUTF8String(`${jwtParts[0]}.${jwtParts[1]}`); + const signatureBuffer = index_js_1.isoBase64URL.toBuffer(SIGNATURE); + const verified = await (0, verifySignature_js_1.verifySignature)({ + signature: signatureBuffer, + data: signatureBaseBuffer, + x509Certificate: leafCertBuffer, + hashAlgorithm: alg, + }); + /** + * END Verify Signature + */ + return verified; +} diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationApple.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationApple.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c998a454a2e6d012ac90f7627cdcd91f4f9b64df --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationApple.d.ts @@ -0,0 +1,3 @@ +import type { AttestationFormatVerifierOpts } from '../verifyRegistrationResponse.js'; +export declare function verifyAttestationApple(options: AttestationFormatVerifierOpts): Promise; +//# sourceMappingURL=verifyAttestationApple.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationApple.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationApple.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..c88e16194919abae68de2c5fc8b62e3ccb27ffeb --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationApple.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyAttestationApple.d.ts","sourceRoot":"","sources":["../../../src/registration/verifications/verifyAttestationApple.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAOtF,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CA6ElB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationApple.js b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationApple.js new file mode 100644 index 0000000000000000000000000000000000000000..4af578849934de5259776eb3cc231315358063cb --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationApple.js @@ -0,0 +1,61 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyAttestationApple = verifyAttestationApple; +const asn1_schema_1 = require("@peculiar/asn1-schema"); +const asn1_x509_1 = require("@peculiar/asn1-x509"); +const validateCertificatePath_js_1 = require("../../helpers/validateCertificatePath.js"); +const convertCertBufferToPEM_js_1 = require("../../helpers/convertCertBufferToPEM.js"); +const toHash_js_1 = require("../../helpers/toHash.js"); +const convertCOSEtoPKCS_js_1 = require("../../helpers/convertCOSEtoPKCS.js"); +const index_js_1 = require("../../helpers/iso/index.js"); +async function verifyAttestationApple(options) { + const { attStmt, authData, clientDataHash, credentialPublicKey, rootCertificates, } = options; + const x5c = attStmt.get('x5c'); + if (!x5c) { + throw new Error('No attestation certificate provided in attestation statement (Apple)'); + } + /** + * Verify certificate path + */ + try { + await (0, validateCertificatePath_js_1.validateCertificatePath)(x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM), rootCertificates); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (Apple)`); + } + /** + * Compare nonce in certificate extension to computed nonce + */ + const parsedCredCert = asn1_schema_1.AsnParser.parse(x5c[0], asn1_x509_1.Certificate); + const { extensions, subjectPublicKeyInfo } = parsedCredCert.tbsCertificate; + if (!extensions) { + throw new Error('credCert missing extensions (Apple)'); + } + const extCertNonce = extensions.find((ext) => ext.extnID === '1.2.840.113635.100.8.2'); + if (!extCertNonce) { + throw new Error('credCert missing "1.2.840.113635.100.8.2" extension (Apple)'); + } + const nonceToHash = index_js_1.isoUint8Array.concat([authData, clientDataHash]); + const nonce = await (0, toHash_js_1.toHash)(nonceToHash); + /** + * Ignore the first six ASN.1 structure bytes that define the nonce as an OCTET STRING. Should + * trim off + * + * TODO: Try and get @peculiar (GitHub) to add a schema for "1.2.840.113635.100.8.2" when we + * find out where it's defined (doesn't seem to be publicly documented at the moment...) + */ + const extNonce = new Uint8Array(extCertNonce.extnValue.buffer).slice(6); + if (!index_js_1.isoUint8Array.areEqual(nonce, extNonce)) { + throw new Error(`credCert nonce was not expected value (Apple)`); + } + /** + * Verify credential public key matches the Subject Public Key of credCert + */ + const credPubKeyPKCS = (0, convertCOSEtoPKCS_js_1.convertCOSEtoPKCS)(credentialPublicKey); + const credCertSubjectPublicKey = new Uint8Array(subjectPublicKeyInfo.subjectPublicKey); + if (!index_js_1.isoUint8Array.areEqual(credPubKeyPKCS, credCertSubjectPublicKey)) { + throw new Error('Credential public key does not equal credCert public key (Apple)'); + } + return true; +} diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationFIDOU2F.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationFIDOU2F.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..4c8818418974391300bdf7a08fe2a1204844f266 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationFIDOU2F.d.ts @@ -0,0 +1,6 @@ +import type { AttestationFormatVerifierOpts } from '../verifyRegistrationResponse.js'; +/** + * Verify an attestation response with fmt 'fido-u2f' + */ +export declare function verifyAttestationFIDOU2F(options: AttestationFormatVerifierOpts): Promise; +//# sourceMappingURL=verifyAttestationFIDOU2F.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationFIDOU2F.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationFIDOU2F.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f665a87f0dfec6f31a6f19b521eae041ae420913 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationFIDOU2F.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyAttestationFIDOU2F.d.ts","sourceRoot":"","sources":["../../../src/registration/verifications/verifyAttestationFIDOU2F.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAStF;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CA4DlB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationFIDOU2F.js b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationFIDOU2F.js new file mode 100644 index 0000000000000000000000000000000000000000..77fd0c10c026bd45b7cde06fd40f5000605bb1a2 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationFIDOU2F.js @@ -0,0 +1,51 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyAttestationFIDOU2F = verifyAttestationFIDOU2F; +const convertCOSEtoPKCS_js_1 = require("../../helpers/convertCOSEtoPKCS.js"); +const convertCertBufferToPEM_js_1 = require("../../helpers/convertCertBufferToPEM.js"); +const validateCertificatePath_js_1 = require("../../helpers/validateCertificatePath.js"); +const verifySignature_js_1 = require("../../helpers/verifySignature.js"); +const index_js_1 = require("../../helpers/iso/index.js"); +const cose_js_1 = require("../../helpers/cose.js"); +/** + * Verify an attestation response with fmt 'fido-u2f' + */ +async function verifyAttestationFIDOU2F(options) { + const { attStmt, clientDataHash, rpIdHash, credentialID, credentialPublicKey, aaguid, rootCertificates, } = options; + const reservedByte = Uint8Array.from([0x00]); + const publicKey = (0, convertCOSEtoPKCS_js_1.convertCOSEtoPKCS)(credentialPublicKey); + const signatureBase = index_js_1.isoUint8Array.concat([ + reservedByte, + rpIdHash, + clientDataHash, + credentialID, + publicKey, + ]); + const sig = attStmt.get('sig'); + const x5c = attStmt.get('x5c'); + if (!x5c) { + throw new Error('No attestation certificate provided in attestation statement (FIDOU2F)'); + } + if (!sig) { + throw new Error('No attestation signature provided in attestation statement (FIDOU2F)'); + } + // FIDO spec says that aaguid _must_ equal 0x00 here to be legit + const aaguidToHex = Number.parseInt(index_js_1.isoUint8Array.toHex(aaguid), 16); + if (aaguidToHex !== 0x00) { + throw new Error(`AAGUID "${aaguidToHex}" was not expected value`); + } + try { + // Try validating the certificate path using the root certificates set via SettingsService + await (0, validateCertificatePath_js_1.validateCertificatePath)(x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM), rootCertificates); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (FIDOU2F)`); + } + return (0, verifySignature_js_1.verifySignature)({ + signature: sig, + data: signatureBase, + x509Certificate: x5c[0], + hashAlgorithm: cose_js_1.COSEALG.ES256, + }); +} diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationPacked.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationPacked.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..7b54a02d24c42731533d75b8612bb3e0368ad3d3 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationPacked.d.ts @@ -0,0 +1,6 @@ +import type { AttestationFormatVerifierOpts } from '../verifyRegistrationResponse.js'; +/** + * Verify an attestation response with fmt 'packed' + */ +export declare function verifyAttestationPacked(options: AttestationFormatVerifierOpts): Promise; +//# sourceMappingURL=verifyAttestationPacked.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationPacked.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationPacked.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..65e0747378cdb2b6d9c18e88f81d07d46ae7b32b --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationPacked.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyAttestationPacked.d.ts","sourceRoot":"","sources":["../../../src/registration/verifications/verifyAttestationPacked.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAYtF;;GAEG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,OAAO,CAAC,CA0JlB"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationPacked.js b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationPacked.js new file mode 100644 index 0000000000000000000000000000000000000000..cb9ca872f8121382c34ec85f2270381a54ffe073 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifications/verifyAttestationPacked.js @@ -0,0 +1,116 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyAttestationPacked = verifyAttestationPacked; +const cose_js_1 = require("../../helpers/cose.js"); +const convertCertBufferToPEM_js_1 = require("../../helpers/convertCertBufferToPEM.js"); +const validateCertificatePath_js_1 = require("../../helpers/validateCertificatePath.js"); +const getCertificateInfo_js_1 = require("../../helpers/getCertificateInfo.js"); +const verifySignature_js_1 = require("../../helpers/verifySignature.js"); +const index_js_1 = require("../../helpers/iso/index.js"); +const validateExtFIDOGenCEAAGUID_js_1 = require("../../helpers/validateExtFIDOGenCEAAGUID.js"); +const metadataService_js_1 = require("../../services/metadataService.js"); +const verifyAttestationWithMetadata_js_1 = require("../../metadata/verifyAttestationWithMetadata.js"); +/** + * Verify an attestation response with fmt 'packed' + */ +async function verifyAttestationPacked(options) { + const { attStmt, clientDataHash, authData, credentialPublicKey, aaguid, rootCertificates, } = options; + const sig = attStmt.get('sig'); + const x5c = attStmt.get('x5c'); + const alg = attStmt.get('alg'); + if (!sig) { + throw new Error('No attestation signature provided in attestation statement (Packed)'); + } + if (!alg) { + throw new Error('Attestation statement did not contain alg (Packed)'); + } + if (!(0, cose_js_1.isCOSEAlg)(alg)) { + throw new Error(`Attestation statement contained invalid alg ${alg} (Packed)`); + } + const signatureBase = index_js_1.isoUint8Array.concat([authData, clientDataHash]); + let verified = false; + if (x5c) { + const { subject, basicConstraintsCA, version, notBefore, notAfter, parsedCertificate, } = (0, getCertificateInfo_js_1.getCertificateInfo)(x5c[0]); + const { OU, CN, O, C } = subject; + if (OU !== 'Authenticator Attestation') { + throw new Error('Certificate OU was not "Authenticator Attestation" (Packed|Full)'); + } + if (!CN) { + throw new Error('Certificate CN was empty (Packed|Full)'); + } + if (!O) { + throw new Error('Certificate O was empty (Packed|Full)'); + } + if (!C || C.length !== 2) { + throw new Error('Certificate C was not two-character ISO 3166 code (Packed|Full)'); + } + if (basicConstraintsCA) { + throw new Error('Certificate basic constraints CA was not `false` (Packed|Full)'); + } + if (version !== 2) { + throw new Error('Certificate version was not `3` (ASN.1 value of 2) (Packed|Full)'); + } + let now = new Date(); + if (notBefore > now) { + throw new Error(`Certificate not good before "${notBefore.toString()}" (Packed|Full)`); + } + now = new Date(); + if (notAfter < now) { + throw new Error(`Certificate not good after "${notAfter.toString()}" (Packed|Full)`); + } + // Validate attestation statement AAGUID against leaf cert AAGUID + try { + await (0, validateExtFIDOGenCEAAGUID_js_1.validateExtFIDOGenCEAAGUID)(parsedCertificate.tbsCertificate.extensions, aaguid); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (Packed|Full)`); + } + // If available, validate attestation alg and x5c with info in the metadata statement + const statement = await metadataService_js_1.MetadataService.getStatement(aaguid); + if (statement) { + // The presence of x5c means this is a full attestation. Check to see if attestationTypes + // includes packed attestations. + if (statement.attestationTypes.indexOf('basic_full') < 0) { + throw new Error('Metadata does not indicate support for full attestations (Packed|Full)'); + } + try { + await (0, verifyAttestationWithMetadata_js_1.verifyAttestationWithMetadata)({ + statement, + credentialPublicKey, + x5c, + attestationStatementAlg: alg, + }); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (Packed|Full)`); + } + } + else { + try { + // Try validating the certificate path using the root certificates set via SettingsService + await (0, validateCertificatePath_js_1.validateCertificatePath)(x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM), rootCertificates); + } + catch (err) { + const _err = err; + throw new Error(`${_err.message} (Packed|Full)`); + } + } + verified = await (0, verifySignature_js_1.verifySignature)({ + signature: sig, + data: signatureBase, + x509Certificate: x5c[0], + hashAlgorithm: alg, + }); + } + else { + verified = await (0, verifySignature_js_1.verifySignature)({ + signature: sig, + data: signatureBase, + credentialPublicKey, + hashAlgorithm: alg, + }); + } + return verified; +} diff --git a/node_modules/@simplewebauthn/server/script/registration/verifyRegistrationResponse.d.ts b/node_modules/@simplewebauthn/server/script/registration/verifyRegistrationResponse.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3460d16c90dc23bee4fdef46ebb8bed6f3249094 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifyRegistrationResponse.d.ts @@ -0,0 +1,94 @@ +import type { COSEAlgorithmIdentifier, CredentialDeviceType, RegistrationResponseJSON, Uint8Array_, WebAuthnCredential } from '../types/index.js'; +import { type AttestationFormat, type AttestationStatement } from '../helpers/decodeAttestationObject.js'; +import type { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js'; +/** + * Configurable options when calling `verifyRegistrationResponse()` + */ +export type VerifyRegistrationResponseOpts = Parameters[0]; +/** + * Verify that the user has legitimately completed the registration process + * + * **Options:** + * + * @param response - Response returned by **@simplewebauthn/browser**'s `startAuthentication()` + * @param expectedChallenge - The base64url-encoded `options.challenge` returned by `generateRegistrationOptions()` + * @param expectedOrigin - Website URL (or array of URLs) that the registration should have occurred on + * @param expectedRPID - RP ID (or array of IDs) that was specified in the registration options + * @param expectedType **(Optional)** - The response type expected ('webauthn.create') + * @param requireUserPresence **(Optional)** - Enforce user presence by the authenticator (or skip it during auto registration) Defaults to `true` + * @param requireUserVerification **(Optional)** - Enforce user verification by the authenticator (via PIN, fingerprint, etc...) Defaults to `true` + * @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported for attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms. Defaults to all supported algorithm IDs + * @param attestationSafetyNetEnforceCTSCheck **(Optional)** - Require that an Android device's system integrity has not been tampered with if it uses SafetyNet attestation. Defaults to `true` + */ +export declare function verifyRegistrationResponse(options: { + response: RegistrationResponseJSON; + expectedChallenge: string | ((challenge: string) => boolean | Promise); + expectedOrigin: string | string[]; + expectedRPID?: string | string[]; + expectedType?: string | string[]; + requireUserPresence?: boolean; + requireUserVerification?: boolean; + supportedAlgorithmIDs?: COSEAlgorithmIdentifier[]; + attestationSafetyNetEnforceCTSCheck?: boolean; +}): Promise; +/** + * Result of registration verification + * + * @param verified If the assertion response could be verified + * @param registrationInfo.fmt Type of attestation + * @param registrationInfo.counter The number of times the authenticator reported it has been used. + * **Should be kept in a DB for later reference to help prevent replay attacks!** + * @param registrationInfo.aaguid Authenticator's Attestation GUID indicating the type of the + * authenticator + * @param registrationInfo.credentialPublicKey The credential's public key + * @param registrationInfo.credentialID The credential's credential ID for the public key above + * @param registrationInfo.credentialType The type of the credential returned by the browser + * @param registrationInfo.userVerified Whether the user was uniquely identified during attestation + * @param registrationInfo.attestationObject The raw `response.attestationObject` Buffer returned by + * the authenticator + * @param registrationInfo.credentialDeviceType Whether this is a single-device or multi-device + * credential. **Should be kept in a DB for later reference!** + * @param registrationInfo.credentialBackedUp Whether or not the multi-device credential has been + * backed up. Always `false` for single-device credentials. **Should be kept in a DB for later + * reference!** + * @param registrationInfo.origin The origin of the website that the registration occurred on + * @param registrationInfo?.rpID The RP ID that the registration occurred on, if one or more were + * specified in the registration options + * @param registrationInfo?.authenticatorExtensionResults The authenticator extensions returned + * by the browser + */ +export type VerifiedRegistrationResponse = { + verified: false; + registrationInfo?: never; +} | { + verified: true; + registrationInfo: { + fmt: AttestationFormat; + aaguid: string; + credential: WebAuthnCredential; + credentialType: 'public-key'; + attestationObject: Uint8Array_; + userVerified: boolean; + credentialDeviceType: CredentialDeviceType; + credentialBackedUp: boolean; + origin: string; + rpID?: string; + authenticatorExtensionResults?: AuthenticationExtensionsAuthenticatorOutputs; + }; +}; +/** + * Values passed to all attestation format verifiers, from which they are free to use as they please + */ +export type AttestationFormatVerifierOpts = { + aaguid: Uint8Array_; + attStmt: AttestationStatement; + authData: Uint8Array_; + clientDataHash: Uint8Array_; + credentialID: Uint8Array_; + credentialPublicKey: Uint8Array_; + rootCertificates: string[]; + rpIdHash: Uint8Array_; + verifyTimestampMS?: boolean; + attestationSafetyNetEnforceCTSCheck?: boolean; +}; +//# sourceMappingURL=verifyRegistrationResponse.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifyRegistrationResponse.d.ts.map b/node_modules/@simplewebauthn/server/script/registration/verifyRegistrationResponse.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f5230294f78f8d46ca07113c389fff4da2ddcdd8 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifyRegistrationResponse.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"verifyRegistrationResponse.d.ts","sourceRoot":"","sources":["../../src/registration/verifyRegistrationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,EACX,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EAE1B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;AAoBhH;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9F;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,0BAA0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,CAAC;IAC9B,QAAQ,EAAE,WAAW,CAAC;IACtB,cAAc,EAAE,WAAW,CAAC;IAC5B,YAAY,EAAE,WAAW,CAAC;IAC1B,mBAAmB,EAAE,WAAW,CAAC;IACjC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,WAAW,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,mCAAmC,CAAC,EAAE,OAAO,CAAC;CAC/C,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/registration/verifyRegistrationResponse.js b/node_modules/@simplewebauthn/server/script/registration/verifyRegistrationResponse.js new file mode 100644 index 0000000000000000000000000000000000000000..a275bdb6d58676f23ed019754ccddfc93537b05e --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/registration/verifyRegistrationResponse.js @@ -0,0 +1,216 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.verifyRegistrationResponse = verifyRegistrationResponse; +const decodeAttestationObject_js_1 = require("../helpers/decodeAttestationObject.js"); +const decodeClientDataJSON_js_1 = require("../helpers/decodeClientDataJSON.js"); +const parseAuthenticatorData_js_1 = require("../helpers/parseAuthenticatorData.js"); +const toHash_js_1 = require("../helpers/toHash.js"); +const decodeCredentialPublicKey_js_1 = require("../helpers/decodeCredentialPublicKey.js"); +const cose_js_1 = require("../helpers/cose.js"); +const convertAAGUIDToString_js_1 = require("../helpers/convertAAGUIDToString.js"); +const parseBackupFlags_js_1 = require("../helpers/parseBackupFlags.js"); +const matchExpectedRPID_js_1 = require("../helpers/matchExpectedRPID.js"); +const index_js_1 = require("../helpers/iso/index.js"); +const settingsService_js_1 = require("../services/settingsService.js"); +const generateRegistrationOptions_js_1 = require("./generateRegistrationOptions.js"); +const verifyAttestationFIDOU2F_js_1 = require("./verifications/verifyAttestationFIDOU2F.js"); +const verifyAttestationPacked_js_1 = require("./verifications/verifyAttestationPacked.js"); +const verifyAttestationAndroidSafetyNet_js_1 = require("./verifications/verifyAttestationAndroidSafetyNet.js"); +const verifyAttestationTPM_js_1 = require("./verifications/tpm/verifyAttestationTPM.js"); +const verifyAttestationAndroidKey_js_1 = require("./verifications/verifyAttestationAndroidKey.js"); +const verifyAttestationApple_js_1 = require("./verifications/verifyAttestationApple.js"); +/** + * Verify that the user has legitimately completed the registration process + * + * **Options:** + * + * @param response - Response returned by **@simplewebauthn/browser**'s `startAuthentication()` + * @param expectedChallenge - The base64url-encoded `options.challenge` returned by `generateRegistrationOptions()` + * @param expectedOrigin - Website URL (or array of URLs) that the registration should have occurred on + * @param expectedRPID - RP ID (or array of IDs) that was specified in the registration options + * @param expectedType **(Optional)** - The response type expected ('webauthn.create') + * @param requireUserPresence **(Optional)** - Enforce user presence by the authenticator (or skip it during auto registration) Defaults to `true` + * @param requireUserVerification **(Optional)** - Enforce user verification by the authenticator (via PIN, fingerprint, etc...) Defaults to `true` + * @param supportedAlgorithmIDs **(Optional)** - Array of numeric COSE algorithm identifiers supported for attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms. Defaults to all supported algorithm IDs + * @param attestationSafetyNetEnforceCTSCheck **(Optional)** - Require that an Android device's system integrity has not been tampered with if it uses SafetyNet attestation. Defaults to `true` + */ +async function verifyRegistrationResponse(options) { + const { response, expectedChallenge, expectedOrigin, expectedRPID, expectedType, requireUserPresence = true, requireUserVerification = true, supportedAlgorithmIDs = generateRegistrationOptions_js_1.supportedCOSEAlgorithmIdentifiers, attestationSafetyNetEnforceCTSCheck = true, } = options; + const { id, rawId, type: credentialType, response: attestationResponse } = response; + // Ensure credential specified an ID + if (!id) { + throw new Error('Missing credential ID'); + } + // Ensure ID is base64url-encoded + if (id !== rawId) { + throw new Error('Credential ID was not base64url-encoded'); + } + // Make sure credential type is public-key + if (credentialType !== 'public-key') { + throw new Error(`Unexpected credential type ${credentialType}, expected "public-key"`); + } + const clientDataJSON = (0, decodeClientDataJSON_js_1.decodeClientDataJSON)(attestationResponse.clientDataJSON); + const { type, origin, challenge, tokenBinding } = clientDataJSON; + // Make sure we're handling an registration + if (Array.isArray(expectedType)) { + if (!expectedType.includes(type)) { + const joinedExpectedType = expectedType.join(', '); + throw new Error(`Unexpected registration response type "${type}", expected one of: ${joinedExpectedType}`); + } + } + else if (expectedType) { + if (type !== expectedType) { + throw new Error(`Unexpected registration response type "${type}", expected "${expectedType}"`); + } + } + else if (type !== 'webauthn.create') { + throw new Error(`Unexpected registration response type: ${type}`); + } + // Ensure the device provided the challenge we gave it + if (typeof expectedChallenge === 'function') { + if (!(await expectedChallenge(challenge))) { + throw new Error(`Custom challenge verifier returned false for registration response challenge "${challenge}"`); + } + } + else if (challenge !== expectedChallenge) { + throw new Error(`Unexpected registration response challenge "${challenge}", expected "${expectedChallenge}"`); + } + // Check that the origin is our site + if (Array.isArray(expectedOrigin)) { + if (!expectedOrigin.includes(origin)) { + throw new Error(`Unexpected registration response origin "${origin}", expected one of: ${expectedOrigin.join(', ')}`); + } + } + else { + if (origin !== expectedOrigin) { + throw new Error(`Unexpected registration response origin "${origin}", expected "${expectedOrigin}"`); + } + } + if (tokenBinding) { + if (typeof tokenBinding !== 'object') { + throw new Error(`Unexpected value for TokenBinding "${tokenBinding}"`); + } + if (['present', 'supported', 'not-supported'].indexOf(tokenBinding.status) < 0) { + throw new Error(`Unexpected tokenBinding.status value of "${tokenBinding.status}"`); + } + } + const attestationObject = index_js_1.isoBase64URL.toBuffer(attestationResponse.attestationObject); + const decodedAttestationObject = (0, decodeAttestationObject_js_1.decodeAttestationObject)(attestationObject); + const fmt = decodedAttestationObject.get('fmt'); + const authData = decodedAttestationObject.get('authData'); + const attStmt = decodedAttestationObject.get('attStmt'); + const parsedAuthData = (0, parseAuthenticatorData_js_1.parseAuthenticatorData)(authData); + const { aaguid, rpIdHash, flags, credentialID, counter, credentialPublicKey, extensionsData, } = parsedAuthData; + // Make sure the response's RP ID is ours + let matchedRPID; + if (expectedRPID) { + let expectedRPIDs = []; + if (typeof expectedRPID === 'string') { + expectedRPIDs = [expectedRPID]; + } + else { + expectedRPIDs = expectedRPID; + } + matchedRPID = await (0, matchExpectedRPID_js_1.matchExpectedRPID)(rpIdHash, expectedRPIDs); + } + // Make sure someone was physically present + if (requireUserPresence && !flags.up) { + throw new Error('User presence was required, but user was not present'); + } + // Enforce user verification if specified + if (requireUserVerification && !flags.uv) { + throw new Error('User verification was required, but user could not be verified'); + } + if (!credentialID) { + throw new Error('No credential ID was provided by authenticator'); + } + if (!credentialPublicKey) { + throw new Error('No public key was provided by authenticator'); + } + if (!aaguid) { + throw new Error('No AAGUID was present during registration'); + } + const decodedPublicKey = (0, decodeCredentialPublicKey_js_1.decodeCredentialPublicKey)(credentialPublicKey); + const alg = decodedPublicKey.get(cose_js_1.COSEKEYS.alg); + if (typeof alg !== 'number') { + throw new Error('Credential public key was missing numeric alg'); + } + // Make sure the key algorithm is one we specified within the registration options + if (!supportedAlgorithmIDs.includes(alg)) { + const supported = supportedAlgorithmIDs.join(', '); + throw new Error(`Unexpected public key alg "${alg}", expected one of "${supported}"`); + } + const clientDataHash = await (0, toHash_js_1.toHash)(index_js_1.isoBase64URL.toBuffer(attestationResponse.clientDataJSON)); + const rootCertificates = settingsService_js_1.SettingsService.getRootCertificates({ + identifier: fmt, + }); + // Prepare arguments to pass to the relevant verification method + const verifierOpts = { + aaguid, + attStmt, + authData, + clientDataHash, + credentialID, + credentialPublicKey, + rootCertificates, + rpIdHash, + attestationSafetyNetEnforceCTSCheck, + }; + /** + * Verification can only be performed when attestation = 'direct' + */ + let verified = false; + if (fmt === 'fido-u2f') { + verified = await (0, verifyAttestationFIDOU2F_js_1.verifyAttestationFIDOU2F)(verifierOpts); + } + else if (fmt === 'packed') { + verified = await (0, verifyAttestationPacked_js_1.verifyAttestationPacked)(verifierOpts); + } + else if (fmt === 'android-safetynet') { + verified = await (0, verifyAttestationAndroidSafetyNet_js_1.verifyAttestationAndroidSafetyNet)(verifierOpts); + } + else if (fmt === 'android-key') { + verified = await (0, verifyAttestationAndroidKey_js_1.verifyAttestationAndroidKey)(verifierOpts); + } + else if (fmt === 'tpm') { + verified = await (0, verifyAttestationTPM_js_1.verifyAttestationTPM)(verifierOpts); + } + else if (fmt === 'apple') { + verified = await (0, verifyAttestationApple_js_1.verifyAttestationApple)(verifierOpts); + } + else if (fmt === 'none') { + if (attStmt.size > 0) { + throw new Error('None attestation had unexpected attestation statement'); + } + // This is the weaker of the attestations, so there's nothing else to really check + verified = true; + } + else { + throw new Error(`Unsupported Attestation Format: ${fmt}`); + } + if (!verified) { + return { verified: false }; + } + const { credentialDeviceType, credentialBackedUp } = (0, parseBackupFlags_js_1.parseBackupFlags)(flags); + return { + verified: true, + registrationInfo: { + fmt, + aaguid: (0, convertAAGUIDToString_js_1.convertAAGUIDToString)(aaguid), + credentialType, + credential: { + id: index_js_1.isoBase64URL.fromBuffer(credentialID), + publicKey: credentialPublicKey, + counter, + transports: response.response.transports, + }, + attestationObject, + userVerified: flags.uv, + credentialDeviceType, + credentialBackedUp, + origin: clientDataJSON.origin, + rpID: matchedRPID, + authenticatorExtensionResults: extensionsData, + }, + }; +} diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-key.d.ts b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-key.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..d9db114c26e8f86db66c7daf0fc86ba37cfe43fc --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-key.d.ts @@ -0,0 +1,49 @@ +/** + * Google Hardware Attestation Root 1 + * + * Downloaded from https://developer.android.com/training/articles/security-key-attestation#root_certificate + * (first entry) + * + * Valid until 2026-05-24 @ 09:28 PST + * + * SHA256 Fingerprint + * C1:98:4A:3E:F4:5C:1E:2A:91:85:51:DE:10:60:3C:86:F7:05:1B:22:49:C4:89:1C:AE:32:30:EA:BD:0C:97:D5 + */ +export declare const Google_Hardware_Attestation_Root_1 = "-----BEGIN CERTIFICATE-----\nMIIFYDCCA0igAwIBAgIJAOj6GWMU0voY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oDOgMYYvaHR0cHM6Ly9hbmRyb2lk\nLmdvb2dsZWFwaXMuY29tL2F0dGVzdGF0aW9uL2NybC8wDQYJKoZIhvcNAQELBQAD\nggIBACDIw41L3KlXG0aMiS//cqrG+EShHUGo8HNsw30W1kJtjn6UBwRM6jnmiwfB\nPb8VA91chb2vssAtX2zbTvqBJ9+LBPGCdw/E53Rbf86qhxKaiAHOjpvAy5Y3m00m\nqC0w/Zwvju1twb4vhLaJ5NkUJYsUS7rmJKHHBnETLi8GFqiEsqTWpG/6ibYCv7rY\nDBJDcR9W62BW9jfIoBQcxUCUJouMPH25lLNcDc1ssqvC2v7iUgI9LeoM1sNovqPm\nQUiG9rHli1vXxzCyaMTjwftkJLkf6724DFhuKug2jITV0QkXvaJWF4nUaHOTNA4u\nJU9WDvZLI1j83A+/xnAJUucIv/zGJ1AMH2boHqF8CY16LpsYgBt6tKxxWH00XcyD\nCdW2KlBCeqbQPcsFmWyWugxdcekhYsAWyoSf818NUsZdBWBaR/OukXrNLfkQ79Iy\nZohZbvabO/X+MVT3rriAoKc8oE2Uws6DF+60PV7/WIPjNvXySdqspImSN78mflxD\nqwLqRBYkA3I75qppLGG9rp7UCdRjxMl8ZDBld+7yvHVgt1cVzJx9xnyGCC23Uaic\nMDSXYrB4I4WHXPGjxhZuCuPBLTdOLU8YRvMYdEvYebWHMpvwGCF6bAx3JBpIeOQ1\nwDB5y0USicV3YgYGmi+NZfhA4URSh77Yd6uuJOJENRaNVTzk\n-----END CERTIFICATE-----\n"; +/** + * Google Hardware Attestation Root 2 + * + * Downloaded from https://developer.android.com/training/articles/security-key-attestation#root_certificate + * (second entry) + * + * Valid until 2034-11-18 @ 12:37 PST + * + * SHA256 Fingerprint + * 1E:F1:A0:4B:8B:A5:8A:B9:45:89:AC:49:8C:89:82:A7:83:F2:4E:A7:30:7E:01:59:A0:C3:A7:3B:37:7D:87:CC + */ +export declare const Google_Hardware_Attestation_Root_2 = "-----BEGIN CERTIFICATE-----\nMIIFHDCCA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AgIEMA0GCSqGSIb3DQEBCwUAA4ICAQBOMaBc8oumXb2voc7XCWnu\nXKhBBK3e2KMGz39t7lA3XXRe2ZLLAkLM5y3J7tURkf5a1SutfdOyXAmeE6SRo83U\nh6WszodmMkxK5GM4JGrnt4pBisu5igXEydaW7qq2CdC6DOGjG+mEkN8/TA6p3cno\nL/sPyz6evdjLlSeJ8rFBH6xWyIZCbrcpYEJzXaUOEaxxXxgYz5/cTiVKN2M1G2ok\nQBUIYSY6bjEL4aUN5cfo7ogP3UvliEo3Eo0YgwuzR2v0KR6C1cZqZJSTnghIC/vA\nD32KdNQ+c3N+vl2OTsUVMC1GiWkngNx1OO1+kXW+YTnnTUOtOIswUP/Vqd5SYgAI\nmMAfY8U9/iIgkQj6T2W6FsScy94IN9fFhE1UtzmLoBIuUFsVXJMTz+Jucth+IqoW\nFua9v1R93/k98p41pjtFX+H8DslVgfP097vju4KDlqN64xV1grw3ZLl4CiOe/A91\noeLm2UHOq6wn3esB4r2EIQKb6jTVGu5sYCcdWpXr0AUVqcABPdgL+H7qJguBw09o\njm6xNIrw2OocrDKsudk/okr/AwqEyPKw9WnMlQgLIKw1rODG2NvU9oR3GVGdMkUB\nZutL8VuFkERQGt6vQ2OCw0sV47VMkuYbacK/xyZFiRcrPJPb41zgbQj9XAEyLKCH\nex0SdDrx+tWUDqG8At2JHA==\n-----END CERTIFICATE-----\n"; +/** + * Google Hardware Attestation Root 3 + * + * Downloaded from https://developer.android.com/training/articles/security-key-attestation#root_certificate + * (third entry) + * + * Valid until 2036-11-13 @ 15:10 PST + * + * SHA256 Fingerprint + * AB:66:41:17:8A:36:E1:79:AA:0C:1C:DD:DF:9A:16:EB:45:FA:20:94:3E:2B:8C:D7:C7:C0:5C:26:CF:8B:48:7A + */ +export declare const Google_Hardware_Attestation_Root_3 = "\n-----BEGIN CERTIFICATE-----\nMIIFHDCCAwSgAwIBAgIJAMNrfES5rhgxMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV\nBAUTEG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BEk2FQvh11J3o3lna0o7rd8RFHnN00q4hi6TapFhh4qaw/iG6Xg+xOan\n63niLWIC5GOPFgPeYXM9+nBb3zZzC8ABypYuCusWCmt6Tn3+Pjbz3MTVhRGXuT/T\nQH4KGFY4PhvzAyXwdjTOCXID+aHud4RLcSySr0Fq/L+R8TWalvM1wJJPhyRjqRCJ\nerGtfBagiALzvhnmY7U1qFcS0NCnKjoO7oFedKdWlZz0YAfu3aGCJd4KHT0MsGiL\nZez9WP81xYSrKMNEsDK+zK5fVzw6jA7cxmpXcARTnmAuGUeI7VVDhDzKeVOctf3a\n0qQLwC+d0+xrETZ4r2fRGNw2YEs2W8Qj6oDcfPvq9JySe7pJ6wcHnl5EZ0lwc4xH\n7Y4Dx9RA1JlfooLMw3tOdJZH0enxPXaydfAD3YifeZpFaUzicHeLzVJLt9dvGB0b\nHQLE4+EqKFgOZv2EoP686DQqbVS1u+9k0p2xbMA105TBIk7npraa8VM0fnrRKi7w\nlZKwdH+aNAyhbXRW9xsnODJ+g8eF452zvbiKKngEKirK5LGieoXBX7tZ9D1GNBH2\nOb3bKOwwIWdEFle/YF/h6zWgdeoaNGDqVBrLr2+0DtWoiB1aDEjLWl9FmyIUyUm7\nmD/vFDkzF+wm7cyWpQpCVQ==\n-----END CERTIFICATE-----\n"; +/** + * Google Hardware Attestation Root 4 + * + * Downloaded from https://developer.android.com/training/articles/security-key-attestation#root_certificate + * (fourth entry) + * + * Valid until 2042-03-15 @ 11:07 PDT + * + * SHA256 Fingerprint + * CE:DB:1C:B6:DC:89:6A:E5:EC:79:73:48:BC:E9:28:67:53:C2:B3:8E:E7:1C:E0:FB:E3:4A:9A:12:48:80:0D:FC + */ +export declare const Google_Hardware_Attestation_Root_4 = "\n-----BEGIN CERTIFICATE-----\nMIIFHDCCAwSgAwIBAgIJAPHBcqaZ6vUdMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV\nBAUTEGY5MjAwOWU4NTNiNmIwNDUwHhcNMjIwMzIwMTgwNzQ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5AORHARs1hhqGIC\nW/nKMav574f9rZN4PC2ZlufGXb7sIdJpGiO9ctRhiLuYuly10JccUZGEHpHSYM2G\ntkgYbZba6lsCPYAAP83cyDV+1aOkTf1RCp/lM0PKvmxYN10RYsK631jrleGdcdkx\noSK//mSQbgcWnmAEZrzHoF1/0gso1HZgIn0YLzVhLSA/iXCX4QT2h3J5z3znluKG\n1nv8NQdxei2DIIhASWfu804CA96cQKTTlaae2fweqXjdN1/v2nqOhngNyz1361mF\nmr4XmaKH/ItTwOe72NI9ZcwS1lVaCvsIkTDCEXdm9rCNPAY10iTunIHFXRh+7KPz\nlHGewCq/8TOohBRn0/NNfh7uRslOSZ/xKbN9tMBtw37Z8d2vvnXq/YWdsm1+JLVw\nn6yYD/yacNJBlwpddla8eaVMjsF6nBnIgQOf9zKSe06nSTqvgwUHosgOECZJZ1Eu\nzbH4yswbt02tKtKEFhx+v+OTge/06V+jGsqTWLsfrOCNLuA8H++z+pUENmpqnnHo\nvaI47gC+TNpkgYGkkBT6B/m/U01BuOBBTzhIlMEZq9qkDWuM2cA5kW5V3FJUcfHn\nw1IdYIg2Wxg7yHcQZemFQg==\n-----END CERTIFICATE-----\n"; +//# sourceMappingURL=android-key.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-key.d.ts.map b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-key.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..a4a69d156c77c3bff2387aa39e9b4b7151991f84 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-key.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"android-key.d.ts","sourceRoot":"","sources":["../../../src/services/defaultRootCerts/android-key.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,u6DA+B9C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,60DA8B9C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,+0DA+B9C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kCAAkC,+0DA+B9C,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-key.js b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-key.js new file mode 100644 index 0000000000000000000000000000000000000000..42f63ff3db7a55590c43fcdceee9771683e82403 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-key.js @@ -0,0 +1,174 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Google_Hardware_Attestation_Root_4 = exports.Google_Hardware_Attestation_Root_3 = exports.Google_Hardware_Attestation_Root_2 = exports.Google_Hardware_Attestation_Root_1 = void 0; +/** + * Google Hardware Attestation Root 1 + * + * Downloaded from https://developer.android.com/training/articles/security-key-attestation#root_certificate + * (first entry) + * + * Valid until 2026-05-24 @ 09:28 PST + * + * SHA256 Fingerprint + * C1:98:4A:3E:F4:5C:1E:2A:91:85:51:DE:10:60:3C:86:F7:05:1B:22:49:C4:89:1C:AE:32:30:EA:BD:0C:97:D5 + */ +exports.Google_Hardware_Attestation_Root_1 = `-----BEGIN CERTIFICATE----- +MIIFYDCCA0igAwIBAgIJAOj6GWMU0voYMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV +BAUTEGY5MjAwOWU4NTNiNmIwNDUwHhcNMTYwNTI2MTYyODUyWhcNMjYwNTI0MTYy +ODUyWjAbMRkwFwYDVQQFExBmOTIwMDllODUzYjZiMDQ1MIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEAr7bHgiuxpwHsK7Qui8xUFmOr75gvMsd/dTEDDJdS +Sxtf6An7xyqpRR90PL2abxM1dEqlXnf2tqw1Ne4Xwl5jlRfdnJLmN0pTy/4lj4/7 +tv0Sk3iiKkypnEUtR6WfMgH0QZfKHM1+di+y9TFRtv6y//0rb+T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Hli1vXxzCyaMTjwftkJLkf6724DFhuKug2jITV0QkXvaJWF4nUaHOTNA4u +JU9WDvZLI1j83A+/xnAJUucIv/zGJ1AMH2boHqF8CY16LpsYgBt6tKxxWH00XcyD +CdW2KlBCeqbQPcsFmWyWugxdcekhYsAWyoSf818NUsZdBWBaR/OukXrNLfkQ79Iy +ZohZbvabO/X+MVT3rriAoKc8oE2Uws6DF+60PV7/WIPjNvXySdqspImSN78mflxD +qwLqRBYkA3I75qppLGG9rp7UCdRjxMl8ZDBld+7yvHVgt1cVzJx9xnyGCC23Uaic +MDSXYrB4I4WHXPGjxhZuCuPBLTdOLU8YRvMYdEvYebWHMpvwGCF6bAx3JBpIeOQ1 +wDB5y0USicV3YgYGmi+NZfhA4URSh77Yd6uuJOJENRaNVTzk +-----END CERTIFICATE----- +`; +/** + * Google Hardware Attestation Root 2 + * + * Downloaded from https://developer.android.com/training/articles/security-key-attestation#root_certificate + * (second entry) + * + * Valid until 2034-11-18 @ 12:37 PST + * + * SHA256 Fingerprint + * 1E:F1:A0:4B:8B:A5:8A:B9:45:89:AC:49:8C:89:82:A7:83:F2:4E:A7:30:7E:01:59:A0:C3:A7:3B:37:7D:87:CC + */ +exports.Google_Hardware_Attestation_Root_2 = `-----BEGIN CERTIFICATE----- +MIIFHDCCAwSgAwIBAgIJANUP8luj8tazMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV +BAUTEGY5MjAwOWU4NTNiNmIwNDUwHhcNMTkxMTIyMjAzNzU4WhcNMzQxMTE4MjAz +NzU4WjAbMRkwFwYDVQQFExBmOTIwMDllODUzYjZiMDQ1MIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEAr7bHgiuxpwHsK7Qui8xUFmOr75gvMsd/dTEDDJdS +Sxtf6An7xyqpRR90PL2abxM1dEqlXnf2tqw1Ne4Xwl5jlRfdnJLmN0pTy/4lj4/7 +tv0Sk3iiKkypnEUtR6WfMgH0QZfKHM1+di+y9TFRtv6y//0rb+T+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8U9/iIgkQj6T2W6FsScy94IN9fFhE1UtzmLoBIuUFsVXJMTz+Jucth+IqoW +Fua9v1R93/k98p41pjtFX+H8DslVgfP097vju4KDlqN64xV1grw3ZLl4CiOe/A91 +oeLm2UHOq6wn3esB4r2EIQKb6jTVGu5sYCcdWpXr0AUVqcABPdgL+H7qJguBw09o +jm6xNIrw2OocrDKsudk/okr/AwqEyPKw9WnMlQgLIKw1rODG2NvU9oR3GVGdMkUB +ZutL8VuFkERQGt6vQ2OCw0sV47VMkuYbacK/xyZFiRcrPJPb41zgbQj9XAEyLKCH +ex0SdDrx+tWUDqG8At2JHA== +-----END CERTIFICATE----- +`; +/** + * Google Hardware Attestation Root 3 + * + * Downloaded from https://developer.android.com/training/articles/security-key-attestation#root_certificate + * (third entry) + * + * Valid until 2036-11-13 @ 15:10 PST + * + * SHA256 Fingerprint + * AB:66:41:17:8A:36:E1:79:AA:0C:1C:DD:DF:9A:16:EB:45:FA:20:94:3E:2B:8C:D7:C7:C0:5C:26:CF:8B:48:7A + */ +exports.Google_Hardware_Attestation_Root_3 = ` +-----BEGIN CERTIFICATE----- +MIIFHDCCAwSgAwIBAgIJAMNrfES5rhgxMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV +BAUTEGY5MjAwOWU4NTNiNmIwNDUwHhcNMjExMTE3MjMxMDQyWhcNMzYxMTEzMjMx +MDQyWjAbMRkwFwYDVQQFExBmOTIwMDllODUzYjZiMDQ1MIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEAr7bHgiuxpwHsK7Qui8xUFmOr75gvMsd/dTEDDJdS +Sxtf6An7xyqpRR90PL2abxM1dEqlXnf2tqw1Ne4Xwl5jlRfdnJLmN0pTy/4lj4/7 +tv0Sk3iiKkypnEUtR6WfMgH0QZfKHM1+di+y9TFRtv6y//0rb+T+W8a9nsNL/ggj +nar86461qO0rOs2cXjp3kOG1FEJ5MVmFmBGtnrKpa73XpXyTqRxB/M0n1n/W9nGq +C4FSYa04T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ZH0enxPXaydfAD3YifeZpFaUzicHeLzVJLt9dvGB0b +HQLE4+EqKFgOZv2EoP686DQqbVS1u+9k0p2xbMA105TBIk7npraa8VM0fnrRKi7w +lZKwdH+aNAyhbXRW9xsnODJ+g8eF452zvbiKKngEKirK5LGieoXBX7tZ9D1GNBH2 +Ob3bKOwwIWdEFle/YF/h6zWgdeoaNGDqVBrLr2+0DtWoiB1aDEjLWl9FmyIUyUm7 +mD/vFDkzF+wm7cyWpQpCVQ== +-----END CERTIFICATE----- +`; +/** + * Google Hardware Attestation Root 4 + * + * Downloaded from https://developer.android.com/training/articles/security-key-attestation#root_certificate + * (fourth entry) + * + * Valid until 2042-03-15 @ 11:07 PDT + * + * SHA256 Fingerprint + * CE:DB:1C:B6:DC:89:6A:E5:EC:79:73:48:BC:E9:28:67:53:C2:B3:8E:E7:1C:E0:FB:E3:4A:9A:12:48:80:0D:FC + */ +exports.Google_Hardware_Attestation_Root_4 = ` +-----BEGIN CERTIFICATE----- +MIIFHDCCAwSgAwIBAgIJAPHBcqaZ6vUdMA0GCSqGSIb3DQEBCwUAMBsxGTAXBgNV +BAUTEGY5MjAwOWU4NTNiNmIwNDUwHhcNMjIwMzIwMTgwNzQ4WhcNNDIwMzE1MTgw +NzQ4WjAbMRkwFwYDVQQFExBmOTIwMDllODUzYjZiMDQ1MIICIjANBgkqhkiG9w0B +AQEFAAOCAg8AMIICCgKCAgEAr7bHgiuxpwHsK7Qui8xUFmOr75gvMsd/dTEDDJdS +Sxtf6An7xyqpRR90PL2abxM1dEqlXnf2tqw1Ne4Xwl5jlRfdnJLmN0pTy/4lj4/7 +tv0Sk3iiKkypnEUtR6WfMgH0QZfKHM1+di+y9TFRtv6y//0rb+T+W8a9nsNL/ggj +nar86461qO0rOs2cXjp3kOG1FEJ5MVmFmBGtnrKpa73XpXyTqRxB/M0n1n/W9nGq +C4FSYa04T6N5RIZGBN2z2MT5IKGbFlbC8UrW0DxW7AYImQQcHtGl/m00QLVWutHQ +oVJYnFP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STqvgwUHosgOECZJZ1Eu +zbH4yswbt02tKtKEFhx+v+OTge/06V+jGsqTWLsfrOCNLuA8H++z+pUENmpqnnHo +vaI47gC+TNpkgYGkkBT6B/m/U01BuOBBTzhIlMEZq9qkDWuM2cA5kW5V3FJUcfHn +w1IdYIg2Wxg7yHcQZemFQg== +-----END CERTIFICATE----- +`; diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-safetynet.d.ts b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-safetynet.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..31d655d6569f9ecebda6ddf832249403d202c29b --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-safetynet.d.ts @@ -0,0 +1,12 @@ +/** + * GlobalSign Root CA + * + * Downloaded from https://pki.goog/roots.pem + * + * Valid until 2028-01-28 @ 04:00 PST + * + * SHA256 Fingerprint + * EB:D4:10:40:E4:BB:3E:C7:42:C9:E3:81:D3:1E:F2:A4:1A:48:B6:68:5C:96:E7:CE:F3:C1:DF:6C:D4:33:1C:99 + */ +export declare const GlobalSign_Root_CA = "-----BEGIN CERTIFICATE-----\nMIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG\nA1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv\nb3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw\nMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i\nYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT\naWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ\njc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp\nxy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp\n1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG\nsnUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ\nU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8\n9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E\nBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B\nAQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz\nyj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE\n38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP\nAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad\nDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME\nHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==\n-----END CERTIFICATE-----\n"; +//# sourceMappingURL=android-safetynet.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-safetynet.d.ts.map b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-safetynet.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..ec9a1f1ad823af2b53d6443e4a9358e4d3067b74 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-safetynet.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"android-safetynet.d.ts","sourceRoot":"","sources":["../../../src/services/defaultRootCerts/android-safetynet.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,uwCAqB9B,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-safetynet.js b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-safetynet.js new file mode 100644 index 0000000000000000000000000000000000000000..70136d86340f5902af8526e8111ca486c39ff865 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/android-safetynet.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GlobalSign_Root_CA = void 0; +/** + * GlobalSign Root CA + * + * Downloaded from https://pki.goog/roots.pem + * + * Valid until 2028-01-28 @ 04:00 PST + * + * SHA256 Fingerprint + * EB:D4:10:40:E4:BB:3E:C7:42:C9:E3:81:D3:1E:F2:A4:1A:48:B6:68:5C:96:E7:CE:F3:C1:DF:6C:D4:33:1C:99 + */ +exports.GlobalSign_Root_CA = `-----BEGIN CERTIFICATE----- +MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG +A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv +b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw +MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i +YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT +aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ +jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp +xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp +1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG +snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ +U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8 +9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E +BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B +AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz +yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE +38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP +AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad +DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME +HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== +-----END CERTIFICATE----- +`; diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/apple.d.ts b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/apple.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..2af589db3ea3ca8ffafb71453be41b733ab41a71 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/apple.d.ts @@ -0,0 +1,12 @@ +/** + * Apple WebAuthn Root CA + * + * Downloaded from https://www.apple.com/certificateauthority/Apple_WebAuthn_Root_CA.pem + * + * Valid until 2045-03-14 @ 17:00 PST + * + * SHA256 Fingerprint + * 09:15:DD:5C:07:A2:8D:B5:49:D1:F6:77:BB:5A:75:D4:BF:BE:95:61:A7:73:42:43:27:76:2E:9E:02:F9:BB:29 + */ +export declare const Apple_WebAuthn_Root_CA = "-----BEGIN CERTIFICATE-----\nMIICEjCCAZmgAwIBAgIQaB0BbHo84wIlpQGUKEdXcTAKBggqhkjOPQQDAzBLMR8w\nHQYDVQQDDBZBcHBsZSBXZWJBdXRobiBSb290IENBMRMwEQYDVQQKDApBcHBsZSBJ\nbmMuMRMwEQYDVQQIDApDYWxpZm9ybmlhMB4XDTIwMDMxODE4MjEzMloXDTQ1MDMx\nNTAwMDAwMFowSzEfMB0GA1UEAwwWQXBwbGUgV2ViQXV0aG4gUm9vdCBDQTETMBEG\nA1UECgwKQXBwbGUgSW5jLjETMBEGA1UECAwKQ2FsaWZvcm5pYTB2MBAGByqGSM49\nAgEGBSuBBAAiA2IABCJCQ2pTVhzjl4Wo6IhHtMSAzO2cv+H9DQKev3//fG59G11k\nxu9eI0/7o6V5uShBpe1u6l6mS19S1FEh6yGljnZAJ+2GNP1mi/YK2kSXIuTHjxA/\npcoRf7XkOtO4o1qlcaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUJtdk\n2cV4wlpn0afeaxLQG2PxxtcwDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49BAMDA2cA\nMGQCMFrZ+9DsJ1PW9hfNdBywZDsWDbWFp28it1d/5w2RPkRX3Bbn/UbDTNLx7Jr3\njAGGiQIwHFj+dJZYUJR786osByBelJYsVZd2GbHQu209b5RCmGQ21gpSAk9QZW4B\n1bWeT0vT\n-----END CERTIFICATE-----\n"; +//# sourceMappingURL=apple.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/apple.d.ts.map b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/apple.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..70a1279a4a3d465115f5349db833a4fa798fe687 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/apple.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"apple.d.ts","sourceRoot":"","sources":["../../../src/services/defaultRootCerts/apple.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,6xBAclC,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/apple.js b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/apple.js new file mode 100644 index 0000000000000000000000000000000000000000..c01b5644dc1bd3c48c2ea40fc4f4d1f68f208d96 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/apple.js @@ -0,0 +1,28 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Apple_WebAuthn_Root_CA = void 0; +/** + * Apple WebAuthn Root CA + * + * Downloaded from https://www.apple.com/certificateauthority/Apple_WebAuthn_Root_CA.pem + * + * Valid until 2045-03-14 @ 17:00 PST + * + * SHA256 Fingerprint + * 09:15:DD:5C:07:A2:8D:B5:49:D1:F6:77:BB:5A:75:D4:BF:BE:95:61:A7:73:42:43:27:76:2E:9E:02:F9:BB:29 + */ +exports.Apple_WebAuthn_Root_CA = `-----BEGIN CERTIFICATE----- +MIICEjCCAZmgAwIBAgIQaB0BbHo84wIlpQGUKEdXcTAKBggqhkjOPQQDAzBLMR8w +HQYDVQQDDBZBcHBsZSBXZWJBdXRobiBSb290IENBMRMwEQYDVQQKDApBcHBsZSBJ +bmMuMRMwEQYDVQQIDApDYWxpZm9ybmlhMB4XDTIwMDMxODE4MjEzMloXDTQ1MDMx +NTAwMDAwMFowSzEfMB0GA1UEAwwWQXBwbGUgV2ViQXV0aG4gUm9vdCBDQTETMBEG +A1UECgwKQXBwbGUgSW5jLjETMBEGA1UECAwKQ2FsaWZvcm5pYTB2MBAGByqGSM49 +AgEGBSuBBAAiA2IABCJCQ2pTVhzjl4Wo6IhHtMSAzO2cv+H9DQKev3//fG59G11k +xu9eI0/7o6V5uShBpe1u6l6mS19S1FEh6yGljnZAJ+2GNP1mi/YK2kSXIuTHjxA/ +pcoRf7XkOtO4o1qlcaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUJtdk +2cV4wlpn0afeaxLQG2PxxtcwDgYDVR0PAQH/BAQDAgEGMAoGCCqGSM49BAMDA2cA +MGQCMFrZ+9DsJ1PW9hfNdBywZDsWDbWFp28it1d/5w2RPkRX3Bbn/UbDTNLx7Jr3 +jAGGiQIwHFj+dJZYUJR786osByBelJYsVZd2GbHQu209b5RCmGQ21gpSAk9QZW4B +1bWeT0vT +-----END CERTIFICATE----- +`; diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/mds.d.ts b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/mds.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..0eee0cb36941174faf8161e12e8bf94fe5c0016b --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/mds.d.ts @@ -0,0 +1,12 @@ +/** + * GlobalSign Root CA - R3 + * + * Downloaded from https://valid.r3.roots.globalsign.com/ + * + * Valid until 2029-03-18 @ 00:00 PST + * + * SHA256 Fingerprint + * CB:B5:22:D7:B7:F1:27:AD:6A:01:13:86:5B:DF:1C:D4:10:2E:7D:07:59:AF:63:5A:7C:F4:72:0D:C9:63:C5:3B + */ +export declare const GlobalSign_Root_CA_R3 = "-----BEGIN CERTIFICATE-----\nMIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G\nA1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp\nZ24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4\nMTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG\nA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI\nhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8\nRgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT\ngHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm\nKPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd\nQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ\nXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw\nDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o\nLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU\nRUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp\njjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK\n6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX\nmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs\nMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH\nWD9f\n-----END CERTIFICATE-----\n "; +//# sourceMappingURL=mds.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/mds.d.ts.map b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/mds.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..51da1f440eca87d070b7a089883fa3de36c1a96f --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/mds.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"mds.d.ts","sourceRoot":"","sources":["../../../src/services/defaultRootCerts/mds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,wuCAqBhC,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/mds.js b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/mds.js new file mode 100644 index 0000000000000000000000000000000000000000..753a11e9106da37518b4d868ed0ceee3fa847521 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/defaultRootCerts/mds.js @@ -0,0 +1,35 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.GlobalSign_Root_CA_R3 = void 0; +/** + * GlobalSign Root CA - R3 + * + * Downloaded from https://valid.r3.roots.globalsign.com/ + * + * Valid until 2029-03-18 @ 00:00 PST + * + * SHA256 Fingerprint + * CB:B5:22:D7:B7:F1:27:AD:6A:01:13:86:5B:DF:1C:D4:10:2E:7D:07:59:AF:63:5A:7C:F4:72:0D:C9:63:C5:3B + */ +exports.GlobalSign_Root_CA_R3 = `-----BEGIN CERTIFICATE----- +MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4G +A1UECxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNp +Z24xEzARBgNVBAMTCkdsb2JhbFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4 +MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEG +A1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2lnbjCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWtiHL8 +RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsT +gHeMCOFJ0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmm +KPZpO/bLyCiR5Z2KYVc3rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zd +QQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjlOCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZ +XriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2xmmFghcCAwEAAaNCMEAw +DgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFI/wS3+o +LkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZU +RUm7lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMp +jjM5RcOO5LlXbKr8EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK +6fBdRoyV3XpYKBovHd7NADdBj+1EbddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQX +mcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18YIvDQVETI53O9zJrlAGomecs +Mx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7rkpeDMdmztcpH +WD9f +-----END CERTIFICATE----- + `; diff --git a/node_modules/@simplewebauthn/server/script/services/metadataService.d.ts b/node_modules/@simplewebauthn/server/script/services/metadataService.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..8a330689fd65ca2dbe759d50a8cb69baac8e5fd5 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/metadataService.d.ts @@ -0,0 +1,78 @@ +import type { MetadataStatement } from '../metadata/mdsTypes.js'; +import type { Uint8Array_ } from '../types/index.js'; +/** + * Allow MetadataService to accommodate unregistered AAGUIDs (`"permissive"`), or only allow + * registered AAGUIDs (`"strict"`). Currently primarily impacts how `getStatement()` operates + */ +export type VerificationMode = 'permissive' | 'strict'; +interface MetadataService { + /** + * Prepare the service to handle remote MDS servers and/or cache local metadata statements. + * + * **Options:** + * + * @param opts.mdsServers An array of URLs to FIDO Alliance Metadata Service + * (version 3.0)-compatible servers. Defaults to the official FIDO MDS server + * @param opts.statements An array of local metadata statements. Statements will be loaded but + * not refreshed + * @param opts.verificationMode How MetadataService will handle unregistered AAGUIDs. Defaults to + * `"strict"` which throws errors during registration response verification when an + * unregistered AAGUID is encountered. Set to `"permissive"` to allow registration by + * authenticators with unregistered AAGUIDs + */ + initialize(opts?: { + mdsServers?: string[]; + statements?: MetadataStatement[]; + verificationMode?: VerificationMode; + }): Promise; + /** + * Get a metadata statement for a given AAGUID. + * + * This method will coordinate updating the cache as per the `nextUpdate` property in the initial + * BLOB download. + */ + getStatement(aaguid: string | Uint8Array): Promise; +} +/** + * An implementation of `MetadataService` that can download and parse BLOBs, and support on-demand + * requesting and caching of individual metadata statements. + * + * https://fidoalliance.org/metadata/ + */ +export declare class BaseMetadataService implements MetadataService { + private mdsCache; + private statementCache; + private state; + private verificationMode; + initialize(opts?: { + mdsServers?: string[]; + statements?: MetadataStatement[]; + verificationMode?: VerificationMode; + }): Promise; + getStatement(aaguid: string | Uint8Array_): Promise; + /** + * Download and process the latest BLOB from MDS + */ + private downloadBlob; + /** + * Verify and process the MDS metadata blob + */ + private verifyBlob; + /** + * A helper method to pause execution until the service is ready + */ + private pauseUntilReady; + /** + * Report service status on change + */ + private setState; +} +/** + * A basic service for coordinating interactions with the FIDO Metadata Service. This includes BLOB + * download and parsing, and on-demand requesting and caching of individual metadata statements. + * + * https://fidoalliance.org/metadata/ + */ +export declare const MetadataService: MetadataService; +export {}; +//# sourceMappingURL=metadataService.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/metadataService.d.ts.map b/node_modules/@simplewebauthn/server/script/services/metadataService.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..d2b8add1386e7edf59d6adf51172311486784798 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/metadataService.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"metadataService.d.ts","sourceRoot":"","sources":["../../src/services/metadataService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAA4B,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAI3F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmCrD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,QAAQ,CAAC;AAIvD,UAAU,eAAe;IACvB;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,IAAI,CAAC,EAAE;QAChB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;QACjC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;KACrC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB;;;;;OAKG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAAC;CACnF;AAED;;;;;GAKG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IACzD,OAAO,CAAC,QAAQ,CAAoC;IACpD,OAAO,CAAC,cAAc,CAA6C;IACnE,OAAO,CAAC,KAAK,CAAyC;IACtD,OAAO,CAAC,gBAAgB,CAA8B;IAEhD,UAAU,CACd,IAAI,GAAE;QACJ,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAC;QACjC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;KAChC,GACL,OAAO,CAAC,IAAI,CAAC;IA4EV,YAAY,CAChB,MAAM,EAAE,MAAM,GAAG,WAAW,GAC3B,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC;IA8DzC;;OAEG;YACW,YAAY;IAU1B;;OAEG;YACW,UAAU;IA8CxB;;OAEG;IACH,OAAO,CAAC,eAAe;IAgCvB;;OAEG;IACH,OAAO,CAAC,QAAQ;CAWjB;AAED;;;;;GAKG;AACH,eAAO,MAAM,eAAe,EAAE,eAA2C,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/metadataService.js b/node_modules/@simplewebauthn/server/script/services/metadataService.js new file mode 100644 index 0000000000000000000000000000000000000000..26d3e4bdf175be9374a7b4b91af1a36a48188545 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/metadataService.js @@ -0,0 +1,272 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.MetadataService = exports.BaseMetadataService = void 0; +const convertAAGUIDToString_js_1 = require("../helpers/convertAAGUIDToString.js"); +const verifyMDSBlob_js_1 = require("../metadata/verifyMDSBlob.js"); +const logging_js_1 = require("../helpers/logging.js"); +const fetch_js_1 = require("../helpers/fetch.js"); +/** + * An instance of `CachedMDS` that will not trigger attempts to refresh the associated entry's blob + */ +const NonRefreshingMDS = { + url: '', + no: 0, + nextUpdate: new Date(0), +}; +const defaultURLMDS = 'https://mds.fidoalliance.org/'; // v3 +var SERVICE_STATE; +(function (SERVICE_STATE) { + SERVICE_STATE[SERVICE_STATE["DISABLED"] = 0] = "DISABLED"; + SERVICE_STATE[SERVICE_STATE["REFRESHING"] = 1] = "REFRESHING"; + SERVICE_STATE[SERVICE_STATE["READY"] = 2] = "READY"; +})(SERVICE_STATE || (SERVICE_STATE = {})); +const log = (0, logging_js_1.getLogger)('MetadataService'); +/** + * An implementation of `MetadataService` that can download and parse BLOBs, and support on-demand + * requesting and caching of individual metadata statements. + * + * https://fidoalliance.org/metadata/ + */ +class BaseMetadataService { + constructor() { + Object.defineProperty(this, "mdsCache", { + enumerable: true, + configurable: true, + writable: true, + value: {} + }); + Object.defineProperty(this, "statementCache", { + enumerable: true, + configurable: true, + writable: true, + value: {} + }); + Object.defineProperty(this, "state", { + enumerable: true, + configurable: true, + writable: true, + value: SERVICE_STATE.DISABLED + }); + Object.defineProperty(this, "verificationMode", { + enumerable: true, + configurable: true, + writable: true, + value: 'strict' + }); + } + async initialize(opts = {}) { + // Reset statement cache + this.statementCache = {}; + const { mdsServers = [defaultURLMDS], statements, verificationMode } = opts; + this.setState(SERVICE_STATE.REFRESHING); + /** + * If metadata statements are provided, load them into the cache first. These statements will + * not be refreshed when a stale one is detected. + */ + if (statements?.length) { + let statementsAdded = 0; + statements.forEach((statement) => { + // Only cache statements that are for FIDO2-compatible authenticators + if (statement.aaguid) { + this.statementCache[statement.aaguid] = { + entry: { + metadataStatement: statement, + statusReports: [], + timeOfLastStatusChange: '1970-01-01', + }, + url: NonRefreshingMDS.url, + }; + statementsAdded += 1; + } + }); + log(`Cached ${statementsAdded} local statements`); + } + /** + * If MDS servers are provided, then download blobs from them, verify them, and then add their + * entries to the cache. Blobs loaded in this way will be refreshed when a stale entry within is + * detected. + */ + if (mdsServers?.length) { + // Get a current count so we know how many new statements we've added from MDS servers + const currentCacheCount = Object.keys(this.statementCache).length; + let numServers = mdsServers.length; + for (const url of mdsServers) { + try { + const cachedMDS = { + url, + no: 0, + nextUpdate: new Date(0), + }; + const blob = await this.downloadBlob(cachedMDS); + await this.verifyBlob(blob, cachedMDS); + } + catch (err) { + // Notify of the error and move on + log(`Could not download BLOB from ${url}:`, err); + numServers -= 1; + } + } + // Calculate the difference to get the total number of new statements we successfully added + const newCacheCount = Object.keys(this.statementCache).length; + const cacheDiff = newCacheCount - currentCacheCount; + log(`Cached ${cacheDiff} statements from ${numServers} metadata server(s)`); + } + if (verificationMode) { + this.verificationMode = verificationMode; + } + this.setState(SERVICE_STATE.READY); + } + async getStatement(aaguid) { + if (this.state === SERVICE_STATE.DISABLED) { + return; + } + if (!aaguid) { + return; + } + if (aaguid instanceof Uint8Array) { + aaguid = (0, convertAAGUIDToString_js_1.convertAAGUIDToString)(aaguid); + } + // If a cache refresh is in progress then pause this until the service is ready + await this.pauseUntilReady(); + // Try to grab a cached statement + const cachedStatement = this.statementCache[aaguid]; + if (!cachedStatement) { + if (this.verificationMode === 'strict') { + // FIDO conformance requires RP's to only support registered AAGUID's + throw new Error(`No metadata statement found for aaguid "${aaguid}"`); + } + // Allow registration verification to continue without using metadata + return; + } + // If the statement points to an MDS API, check the MDS' nextUpdate to see if we need to refresh + if (cachedStatement.url) { + const mds = this.mdsCache[cachedStatement.url]; + const now = new Date(); + if (now > mds.nextUpdate) { + try { + this.setState(SERVICE_STATE.REFRESHING); + const blob = await this.downloadBlob(mds); + await this.verifyBlob(blob, mds); + } + finally { + this.setState(SERVICE_STATE.READY); + } + } + } + const { entry } = cachedStatement; + // Check to see if the this aaguid has a status report with a "compromised" status + for (const report of entry.statusReports) { + const { status } = report; + if (status === 'USER_VERIFICATION_BYPASS' || + status === 'ATTESTATION_KEY_COMPROMISE' || + status === 'USER_KEY_REMOTE_COMPROMISE' || + status === 'USER_KEY_PHYSICAL_COMPROMISE') { + throw new Error(`Detected compromised aaguid "${aaguid}"`); + } + } + return entry.metadataStatement; + } + /** + * Download and process the latest BLOB from MDS + */ + async downloadBlob(cachedMDS) { + const { url } = cachedMDS; + // Get latest "BLOB" (FIDO's terminology, not mine) + const resp = await (0, fetch_js_1.fetch)(url); + const data = await resp.text(); + return data; + } + /** + * Verify and process the MDS metadata blob + */ + async verifyBlob(blob, cachedMDS) { + const { url, no } = cachedMDS; + const { payload, parsedNextUpdate } = await (0, verifyMDSBlob_js_1.verifyMDSBlob)(blob); + if (payload.no <= no) { + // From FIDO MDS docs: "also ignore the file if its number (no) is less or equal to the + // number of the last BLOB cached locally." + throw new Error(`Latest BLOB no. ${payload.no} is not greater than previous no. ${no}`); + } + // Cache statements for FIDO2 devices + for (const entry of payload.entries) { + // Only cache entries with an `aaguid` + if (entry.aaguid) { + this.statementCache[entry.aaguid] = { entry, url }; + } + } + if (url) { + // Remember info about the server so we can refresh later + this.mdsCache[url] = { + ...cachedMDS, + // Store the payload `no` to make sure we're getting the next BLOB in the sequence + no: payload.no, + // Remember when we need to refresh this blob + nextUpdate: parsedNextUpdate, + }; + } + else { + /** + * This blob will not be refreshed, but we should still alert if the blob's `nextUpdate` is + * in the past + */ + if (parsedNextUpdate < new Date()) { + // TODO (Feb 2026): It'd be more actionable for devs if a specific error was raised here, + // then this message was logged higher up when it can include the array index of the stale + // blob. + log(`⚠️ This MDS blob (serial: ${payload.no}) contains stale data as of ${parsedNextUpdate.toISOString()}. Please consider re-initializing MetadataService with a newer MDS blob.`); + } + } + } + /** + * A helper method to pause execution until the service is ready + */ + pauseUntilReady() { + if (this.state === SERVICE_STATE.READY) { + return new Promise((resolve) => { + resolve(); + }); + } + // State isn't ready, so set up polling + const readyPromise = new Promise((resolve, reject) => { + const totalTimeoutMS = 70000; + const intervalMS = 100; + let iterations = totalTimeoutMS / intervalMS; + // Check service state every `intervalMS` milliseconds + const intervalID = globalThis.setInterval(() => { + if (iterations < 1) { + clearInterval(intervalID); + reject(`State did not become ready in ${totalTimeoutMS / 1000} seconds`); + } + else if (this.state === SERVICE_STATE.READY) { + clearInterval(intervalID); + resolve(); + } + iterations -= 1; + }, intervalMS); + }); + return readyPromise; + } + /** + * Report service status on change + */ + setState(newState) { + this.state = newState; + if (newState === SERVICE_STATE.DISABLED) { + log('MetadataService is DISABLED'); + } + else if (newState === SERVICE_STATE.REFRESHING) { + log('MetadataService is REFRESHING'); + } + else if (newState === SERVICE_STATE.READY) { + log('MetadataService is READY'); + } + } +} +exports.BaseMetadataService = BaseMetadataService; +/** + * A basic service for coordinating interactions with the FIDO Metadata Service. This includes BLOB + * download and parsing, and on-demand requesting and caching of individual metadata statements. + * + * https://fidoalliance.org/metadata/ + */ +exports.MetadataService = new BaseMetadataService(); diff --git a/node_modules/@simplewebauthn/server/script/services/settingsService.d.ts b/node_modules/@simplewebauthn/server/script/services/settingsService.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..611592b042efff086d80bc565097253fb91b37c6 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/settingsService.d.ts @@ -0,0 +1,39 @@ +import type { AttestationFormat } from '../helpers/decodeAttestationObject.js'; +import type { Uint8Array_ } from '../types/index.js'; +export type RootCertIdentifier = AttestationFormat | 'mds'; +interface SettingsService { + /** + * Set potential root certificates for attestation formats that use them. Root certs will be tried + * one-by-one when validating a certificate path. + * + * Certificates can be specified as a raw `Buffer`, or as a PEM-formatted string. If a + * `Buffer` is passed in it will be converted to PEM format. + */ + setRootCertificates(opts: { + identifier: RootCertIdentifier; + certificates: (Uint8Array_ | string)[]; + }): void; + /** + * Get any registered root certificates for the specified attestation format + */ + getRootCertificates(opts: { + identifier: RootCertIdentifier; + }): string[]; +} +/** + * A basic service for specifying acceptable root certificates for all supported attestation + * statement formats. + * + * In addition, default root certificates are included for the following statement formats: + * + * - `'android-key'` + * - `'android-safetynet'` + * - `'apple'` + * - `'android-mds'` + * + * These can be overwritten as needed by setting alternative root certificates for their format + * identifier using `setRootCertificates()`. + */ +export declare const SettingsService: SettingsService; +export {}; +//# sourceMappingURL=settingsService.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/settingsService.d.ts.map b/node_modules/@simplewebauthn/server/script/services/settingsService.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..432da95f601084ced18fba89858d21382fbe3ace --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/settingsService.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"settingsService.d.ts","sourceRoot":"","sources":["../../src/services/settingsService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAYrD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,KAAK,CAAC;AAE3D,UAAU,eAAe;IACvB;;;;;;OAMG;IACH,mBAAmB,CAAC,IAAI,EAAE;QACxB,UAAU,EAAE,kBAAkB,CAAC;QAC/B,YAAY,EAAE,CAAC,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC;KACxC,GAAG,IAAI,CAAC;IAET;;OAEG;IACH,mBAAmB,CAAC,IAAI,EAAE;QAAE,UAAU,EAAE,kBAAkB,CAAA;KAAE,GAAG,MAAM,EAAE,CAAC;CACzE;AAkCD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,eAAe,EAAE,eAA2C,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/services/settingsService.js b/node_modules/@simplewebauthn/server/script/services/settingsService.js new file mode 100644 index 0000000000000000000000000000000000000000..b64fc2b7e70cf5799544d2d7da4806ac438858e5 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/services/settingsService.js @@ -0,0 +1,74 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.SettingsService = void 0; +const convertCertBufferToPEM_js_1 = require("../helpers/convertCertBufferToPEM.js"); +const android_safetynet_js_1 = require("./defaultRootCerts/android-safetynet.js"); +const android_key_js_1 = require("./defaultRootCerts/android-key.js"); +const apple_js_1 = require("./defaultRootCerts/apple.js"); +const mds_js_1 = require("./defaultRootCerts/mds.js"); +class BaseSettingsService { + constructor() { + // Certificates are stored as PEM-formatted strings + Object.defineProperty(this, "pemCertificates", { + enumerable: true, + configurable: true, + writable: true, + value: void 0 + }); + this.pemCertificates = new Map(); + } + setRootCertificates(opts) { + const { identifier, certificates } = opts; + const newCertificates = []; + for (const cert of certificates) { + if (cert instanceof Uint8Array) { + newCertificates.push((0, convertCertBufferToPEM_js_1.convertCertBufferToPEM)(cert)); + } + else { + newCertificates.push(cert); + } + } + this.pemCertificates.set(identifier, newCertificates); + } + getRootCertificates(opts) { + const { identifier } = opts; + return this.pemCertificates.get(identifier) ?? []; + } +} +/** + * A basic service for specifying acceptable root certificates for all supported attestation + * statement formats. + * + * In addition, default root certificates are included for the following statement formats: + * + * - `'android-key'` + * - `'android-safetynet'` + * - `'apple'` + * - `'android-mds'` + * + * These can be overwritten as needed by setting alternative root certificates for their format + * identifier using `setRootCertificates()`. + */ +exports.SettingsService = new BaseSettingsService(); +// Initialize default certificates +exports.SettingsService.setRootCertificates({ + identifier: 'android-key', + certificates: [ + android_key_js_1.Google_Hardware_Attestation_Root_1, + android_key_js_1.Google_Hardware_Attestation_Root_2, + android_key_js_1.Google_Hardware_Attestation_Root_3, + android_key_js_1.Google_Hardware_Attestation_Root_4, + ], +}); +exports.SettingsService.setRootCertificates({ + identifier: 'android-safetynet', + certificates: [android_safetynet_js_1.GlobalSign_Root_CA], +}); +exports.SettingsService.setRootCertificates({ + identifier: 'apple', + certificates: [apple_js_1.Apple_WebAuthn_Root_CA], +}); +exports.SettingsService.setRootCertificates({ + identifier: 'mds', + certificates: [mds_js_1.GlobalSign_Root_CA_R3], +}); diff --git a/node_modules/@simplewebauthn/server/script/types/dom.d.ts b/node_modules/@simplewebauthn/server/script/types/dom.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..29caf7fd9cb3e6a49f63845cb76c7a963244ecf7 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/types/dom.d.ts @@ -0,0 +1,329 @@ +/** + * DO NOT MODIFY THESE FILES! + * + * These files were copied from the **types** package. To update this file, make changes to those + * files instead and then run the following command from the monorepo root folder: + * + * deno task codegen:types + */ +/** + * Generated from typescript@5.6.3 + * To regenerate, run the following command from the package root: + * deno task extract-dom-types + */ +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse) + */ +export interface AuthenticatorAssertionResponse extends AuthenticatorResponse { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse/authenticatorData) */ + readonly authenticatorData: ArrayBuffer; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse/signature) */ + readonly signature: ArrayBuffer; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAssertionResponse/userHandle) */ + readonly userHandle: ArrayBuffer | null; +} +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse) + */ +export interface AuthenticatorAttestationResponse extends AuthenticatorResponse { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse/attestationObject) */ + readonly attestationObject: ArrayBuffer; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse/getAuthenticatorData) */ + getAuthenticatorData(): ArrayBuffer; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse/getPublicKey) */ + getPublicKey(): ArrayBuffer | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse/getPublicKeyAlgorithm) */ + getPublicKeyAlgorithm(): COSEAlgorithmIdentifier; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorAttestationResponse/getTransports) */ + getTransports(): string[]; +} +export interface AuthenticationExtensionsClientInputs { + appid?: string; + credProps?: boolean; + hmacCreateSecret?: boolean; + minPinLength?: boolean; +} +export interface AuthenticationExtensionsClientOutputs { + appid?: boolean; + credProps?: CredentialPropertiesOutput; + hmacCreateSecret?: boolean; +} +export interface AuthenticatorSelectionCriteria { + authenticatorAttachment?: AuthenticatorAttachment; + requireResidentKey?: boolean; + residentKey?: ResidentKeyRequirement; + userVerification?: UserVerificationRequirement; +} +/** + * Basic cryptography features available in the current context. It allows access to a cryptographically strong random number generator and to cryptographic primitives. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto) + */ +export interface Crypto { + /** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/subtle) + */ + readonly subtle: SubtleCrypto; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues) */ + getRandomValues(array: T): T; + /** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID) + */ + randomUUID(): `${string}-${string}-${string}-${string}-${string}`; +} +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PublicKeyCredential) + */ +export interface PublicKeyCredential extends Credential { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/PublicKeyCredential/authenticatorAttachment) */ + readonly authenticatorAttachment: string | null; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/PublicKeyCredential/rawId) */ + readonly rawId: ArrayBuffer; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/PublicKeyCredential/response) */ + readonly response: AuthenticatorResponse; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/PublicKeyCredential/getClientExtensionResults) */ + getClientExtensionResults(): AuthenticationExtensionsClientOutputs; +} +export interface PublicKeyCredentialCreationOptions { + attestation?: AttestationConveyancePreference; + authenticatorSelection?: AuthenticatorSelectionCriteria; + challenge: BufferSource; + excludeCredentials?: PublicKeyCredentialDescriptor[]; + extensions?: AuthenticationExtensionsClientInputs; + pubKeyCredParams: PublicKeyCredentialParameters[]; + rp: PublicKeyCredentialRpEntity; + timeout?: number; + user: PublicKeyCredentialUserEntity; +} +export interface PublicKeyCredentialDescriptor { + id: BufferSource; + transports?: AuthenticatorTransport[]; + type: PublicKeyCredentialType; +} +export interface PublicKeyCredentialParameters { + alg: COSEAlgorithmIdentifier; + type: PublicKeyCredentialType; +} +export interface PublicKeyCredentialRequestOptions { + allowCredentials?: PublicKeyCredentialDescriptor[]; + challenge: BufferSource; + extensions?: AuthenticationExtensionsClientInputs; + rpId?: string; + timeout?: number; + userVerification?: UserVerificationRequirement; +} +export interface PublicKeyCredentialUserEntity extends PublicKeyCredentialEntity { + displayName: string; + id: BufferSource; +} +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorResponse) + */ +export interface AuthenticatorResponse { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/AuthenticatorResponse/clientDataJSON) */ + readonly clientDataJSON: ArrayBuffer; +} +export interface CredentialPropertiesOutput { + rk?: boolean; +} +/** + * This Web Crypto API interface provides a number of low-level cryptographic functions. It is accessed via the Crypto.subtle properties available in a window context (via Window.crypto). + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto) + */ +export interface SubtleCrypto { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/decrypt) */ + decrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveBits) */ + deriveBits(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, length: number): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/deriveKey) */ + deriveKey(algorithm: AlgorithmIdentifier | EcdhKeyDeriveParams | HkdfParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: AlgorithmIdentifier | AesDerivedKeyParams | HmacImportParams | HkdfParams | Pbkdf2Params, extractable: boolean, keyUsages: KeyUsage[]): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/digest) */ + digest(algorithm: AlgorithmIdentifier, data: BufferSource): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/encrypt) */ + encrypt(algorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, key: CryptoKey, data: BufferSource): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/exportKey) */ + exportKey(format: "jwk", key: CryptoKey): Promise; + exportKey(format: Exclude, key: CryptoKey): Promise; + exportKey(format: KeyFormat, key: CryptoKey): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/generateKey) */ + generateKey(algorithm: "Ed25519", extractable: boolean, keyUsages: ReadonlyArray<"sign" | "verify">): Promise; + generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams, extractable: boolean, keyUsages: ReadonlyArray): Promise; + generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: ReadonlyArray): Promise; + generateKey(algorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: KeyUsage[]): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/importKey) */ + importKey(format: "jwk", keyData: JsonWebKey, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: ReadonlyArray): Promise; + importKey(format: Exclude, keyData: BufferSource, algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/sign) */ + sign(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams, key: CryptoKey, data: BufferSource): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/unwrapKey) */ + unwrapKey(format: KeyFormat, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams, unwrappedKeyAlgorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | AesKeyAlgorithm, extractable: boolean, keyUsages: KeyUsage[]): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/verify) */ + verify(algorithm: AlgorithmIdentifier | RsaPssParams | EcdsaParams, key: CryptoKey, signature: BufferSource, data: BufferSource): Promise; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/SubtleCrypto/wrapKey) */ + wrapKey(format: KeyFormat, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier | RsaOaepParams | AesCtrParams | AesCbcParams | AesGcmParams): Promise; +} +/** + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Credential) + */ +export interface Credential { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Credential/id) */ + readonly id: string; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Credential/type) */ + readonly type: string; +} +export interface PublicKeyCredentialRpEntity extends PublicKeyCredentialEntity { + id?: string; +} +export interface PublicKeyCredentialEntity { + name: string; +} +export interface RsaOaepParams extends Algorithm { + label?: BufferSource; +} +export interface AesCtrParams extends Algorithm { + counter: BufferSource; + length: number; +} +export interface AesCbcParams extends Algorithm { + iv: BufferSource; +} +export interface AesGcmParams extends Algorithm { + additionalData?: BufferSource; + iv: BufferSource; + tagLength?: number; +} +/** + * The CryptoKey dictionary of the Web Crypto API represents a cryptographic key. + * Available only in secure contexts. + * + * [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey) + */ +export interface CryptoKey { + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/algorithm) */ + readonly algorithm: KeyAlgorithm; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/extractable) */ + readonly extractable: boolean; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/type) */ + readonly type: KeyType; + /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CryptoKey/usages) */ + readonly usages: KeyUsage[]; +} +export interface EcdhKeyDeriveParams extends Algorithm { + public: CryptoKey; +} +export interface HkdfParams extends Algorithm { + hash: HashAlgorithmIdentifier; + info: BufferSource; + salt: BufferSource; +} +export interface Pbkdf2Params extends Algorithm { + hash: HashAlgorithmIdentifier; + iterations: number; + salt: BufferSource; +} +export interface AesDerivedKeyParams extends Algorithm { + length: number; +} +export interface HmacImportParams extends Algorithm { + hash: HashAlgorithmIdentifier; + length?: number; +} +export interface JsonWebKey { + alg?: string; + crv?: string; + d?: string; + dp?: string; + dq?: string; + e?: string; + ext?: boolean; + k?: string; + key_ops?: string[]; + kty?: string; + n?: string; + oth?: RsaOtherPrimesInfo[]; + p?: string; + q?: string; + qi?: string; + use?: string; + x?: string; + y?: string; +} +export interface CryptoKeyPair { + privateKey: CryptoKey; + publicKey: CryptoKey; +} +export interface RsaHashedKeyGenParams extends RsaKeyGenParams { + hash: HashAlgorithmIdentifier; +} +export interface EcKeyGenParams extends Algorithm { + namedCurve: NamedCurve; +} +export interface AesKeyGenParams extends Algorithm { + length: number; +} +export interface HmacKeyGenParams extends Algorithm { + hash: HashAlgorithmIdentifier; + length?: number; +} +export interface RsaHashedImportParams extends Algorithm { + hash: HashAlgorithmIdentifier; +} +export interface EcKeyImportParams extends Algorithm { + namedCurve: NamedCurve; +} +export interface AesKeyAlgorithm extends KeyAlgorithm { + length: number; +} +export interface RsaPssParams extends Algorithm { + saltLength: number; +} +export interface EcdsaParams extends Algorithm { + hash: HashAlgorithmIdentifier; +} +export interface Algorithm { + name: string; +} +export interface KeyAlgorithm { + name: string; +} +export interface RsaOtherPrimesInfo { + d?: string; + r?: string; + t?: string; +} +export interface RsaKeyGenParams extends Algorithm { + modulusLength: number; + publicExponent: BigInteger; +} +export type AttestationConveyancePreference = "direct" | "enterprise" | "indirect" | "none"; +export type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; +export type COSEAlgorithmIdentifier = number; +export type ResidentKeyRequirement = "discouraged" | "preferred" | "required"; +export type UserVerificationRequirement = "discouraged" | "preferred" | "required"; +export type AuthenticatorAttachment = "cross-platform" | "platform"; +export type BufferSource = ArrayBufferView | ArrayBuffer; +export type PublicKeyCredentialType = "public-key"; +export type AlgorithmIdentifier = Algorithm | string; +export type KeyUsage = "decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey"; +export type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki"; +export type KeyType = "private" | "public" | "secret"; +export type HashAlgorithmIdentifier = AlgorithmIdentifier; +export type NamedCurve = string; +export type BigInteger = Uint8Array; +//# sourceMappingURL=dom.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/types/dom.d.ts.map b/node_modules/@simplewebauthn/server/script/types/dom.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..f0be52b43bd410ad33b66057befb1636266c582f --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/types/dom.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/types/dom.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH;;;;GAIG;AACH;;;;GAIG;AACH,MAAM,WAAW,8BAA+B,SAAQ,qBAAqB;IACzE,mHAAmH;IACnH,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC;IACxC,2GAA2G;IAC3G,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC;IAChC,4GAA4G;IAC5G,QAAQ,CAAC,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;CAC3C;AAED;;;;GAIG;AACH,MAAM,WAAW,gCAAiC,SAAQ,qBAAqB;IAC3E,qHAAqH;IACrH,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC;IACxC,wHAAwH;IACxH,oBAAoB,IAAI,WAAW,CAAC;IACpC,gHAAgH;IAChH,YAAY,IAAI,WAAW,GAAG,IAAI,CAAC;IACnC,yHAAyH;IACzH,qBAAqB,IAAI,uBAAuB,CAAC;IACjD,iHAAiH;IACjH,aAAa,IAAI,MAAM,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,oCAAoC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,qCAAqC;IAClD,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git a/node_modules/@simplewebauthn/server/script/types/dom.js b/node_modules/@simplewebauthn/server/script/types/dom.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/types/dom.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@simplewebauthn/server/script/types/index.d.ts b/node_modules/@simplewebauthn/server/script/types/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..45e05d53c956f06c4fbf2a8f639d2f2c7de52a52 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/types/index.d.ts @@ -0,0 +1,220 @@ +/** + * DO NOT MODIFY THESE FILES! + * + * These files were copied from the **types** package. To update this file, make changes to those + * files instead and then run the following command from the monorepo root folder: + * + * deno task codegen:types + */ +import type { AttestationConveyancePreference, AuthenticationExtensionsClientInputs, AuthenticationExtensionsClientOutputs, AuthenticatorAssertionResponse, AuthenticatorAttachment, AuthenticatorAttestationResponse, AuthenticatorSelectionCriteria, COSEAlgorithmIdentifier, PublicKeyCredential, PublicKeyCredentialCreationOptions, PublicKeyCredentialDescriptor, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptions, PublicKeyCredentialRpEntity, PublicKeyCredentialType, UserVerificationRequirement } from './dom.js'; +export type { AttestationConveyancePreference, AuthenticationExtensionsClientInputs, AuthenticationExtensionsClientOutputs, AuthenticatorAssertionResponse, AuthenticatorAttachment, AuthenticatorAttestationResponse, AuthenticatorSelectionCriteria, AuthenticatorTransport, COSEAlgorithmIdentifier, Crypto, PublicKeyCredential, PublicKeyCredentialCreationOptions, PublicKeyCredentialDescriptor, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptions, PublicKeyCredentialRpEntity, PublicKeyCredentialType, PublicKeyCredentialUserEntity, ResidentKeyRequirement, UserVerificationRequirement, } from './dom.js'; +/** + * A variant of PublicKeyCredentialCreationOptions suitable for JSON transmission to the browser to + * (eventually) get passed into navigator.credentials.create(...) in the browser. + * + * This should eventually get replaced with official TypeScript DOM types when WebAuthn L3 types + * eventually make it into the language: + * + * https://w3c.github.io/webauthn/#dictdef-publickeycredentialcreationoptionsjson + */ +export interface PublicKeyCredentialCreationOptionsJSON { + rp: PublicKeyCredentialRpEntity; + user: PublicKeyCredentialUserEntityJSON; + challenge: Base64URLString; + pubKeyCredParams: PublicKeyCredentialParameters[]; + timeout?: number; + excludeCredentials?: PublicKeyCredentialDescriptorJSON[]; + authenticatorSelection?: AuthenticatorSelectionCriteria; + hints?: PublicKeyCredentialHint[]; + attestation?: AttestationConveyancePreference; + attestationFormats?: AttestationFormat[]; + extensions?: AuthenticationExtensionsClientInputs; +} +/** + * A variant of PublicKeyCredentialRequestOptions suitable for JSON transmission to the browser to + * (eventually) get passed into navigator.credentials.get(...) in the browser. + */ +export interface PublicKeyCredentialRequestOptionsJSON { + challenge: Base64URLString; + timeout?: number; + rpId?: string; + allowCredentials?: PublicKeyCredentialDescriptorJSON[]; + userVerification?: UserVerificationRequirement; + hints?: PublicKeyCredentialHint[]; + extensions?: AuthenticationExtensionsClientInputs; +} +/** + * https://w3c.github.io/webauthn/#dictdef-publickeycredentialdescriptorjson + */ +export interface PublicKeyCredentialDescriptorJSON { + id: Base64URLString; + type: PublicKeyCredentialType; + transports?: AuthenticatorTransportFuture[]; +} +/** + * https://w3c.github.io/webauthn/#dictdef-publickeycredentialuserentityjson + */ +export interface PublicKeyCredentialUserEntityJSON { + id: string; + name: string; + displayName: string; +} +/** + * The value returned from navigator.credentials.create() + */ +export interface RegistrationCredential extends PublicKeyCredentialFuture { + response: AuthenticatorAttestationResponseFuture; +} +/** + * A slightly-modified RegistrationCredential to simplify working with ArrayBuffers that + * are Base64URL-encoded in the browser so that they can be sent as JSON to the server. + * + * https://w3c.github.io/webauthn/#dictdef-registrationresponsejson + */ +export interface RegistrationResponseJSON { + id: Base64URLString; + rawId: Base64URLString; + response: AuthenticatorAttestationResponseJSON; + authenticatorAttachment?: AuthenticatorAttachment; + clientExtensionResults: AuthenticationExtensionsClientOutputs; + type: PublicKeyCredentialType; +} +/** + * The value returned from navigator.credentials.get() + */ +export interface AuthenticationCredential extends PublicKeyCredentialFuture { + response: AuthenticatorAssertionResponse; +} +/** + * A slightly-modified AuthenticationCredential to simplify working with ArrayBuffers that + * are Base64URL-encoded in the browser so that they can be sent as JSON to the server. + * + * https://w3c.github.io/webauthn/#dictdef-authenticationresponsejson + */ +export interface AuthenticationResponseJSON { + id: Base64URLString; + rawId: Base64URLString; + response: AuthenticatorAssertionResponseJSON; + authenticatorAttachment?: AuthenticatorAttachment; + clientExtensionResults: AuthenticationExtensionsClientOutputs; + type: PublicKeyCredentialType; +} +/** + * A slightly-modified AuthenticatorAttestationResponse to simplify working with ArrayBuffers that + * are Base64URL-encoded in the browser so that they can be sent as JSON to the server. + * + * https://w3c.github.io/webauthn/#dictdef-authenticatorattestationresponsejson + */ +export interface AuthenticatorAttestationResponseJSON { + clientDataJSON: Base64URLString; + attestationObject: Base64URLString; + authenticatorData?: Base64URLString; + transports?: AuthenticatorTransportFuture[]; + publicKeyAlgorithm?: COSEAlgorithmIdentifier; + publicKey?: Base64URLString; +} +/** + * A slightly-modified AuthenticatorAssertionResponse to simplify working with ArrayBuffers that + * are Base64URL-encoded in the browser so that they can be sent as JSON to the server. + * + * https://w3c.github.io/webauthn/#dictdef-authenticatorassertionresponsejson + */ +export interface AuthenticatorAssertionResponseJSON { + clientDataJSON: Base64URLString; + authenticatorData: Base64URLString; + signature: Base64URLString; + userHandle?: Base64URLString; +} +/** + * Public key credential information needed to verify authentication responses + */ +export type WebAuthnCredential = { + id: Base64URLString; + publicKey: Uint8Array_; + counter: number; + transports?: AuthenticatorTransportFuture[]; +}; +/** + * An attempt to communicate that this isn't just any string, but a Base64URL-encoded string + */ +export type Base64URLString = string; +/** + * AuthenticatorAttestationResponse in TypeScript's DOM lib is outdated (up through v3.9.7). + * Maintain an augmented version here so we can implement additional properties as the WebAuthn + * spec evolves. + * + * See https://www.w3.org/TR/webauthn-2/#iface-authenticatorattestationresponse + * + * Properties marked optional are not supported in all browsers. + */ +export interface AuthenticatorAttestationResponseFuture extends AuthenticatorAttestationResponse { + getTransports(): AuthenticatorTransportFuture[]; +} +/** + * A super class of TypeScript's `AuthenticatorTransport` that includes support for the latest + * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to + * know about it (sometime after 4.6.3) + */ +export type AuthenticatorTransportFuture = 'ble' | 'cable' | 'hybrid' | 'internal' | 'nfc' | 'smart-card' | 'usb'; +/** + * A super class of TypeScript's `PublicKeyCredentialDescriptor` that knows about the latest + * transports. Should eventually be replaced by TypeScript's when TypeScript gets updated to + * know about it (sometime after 4.6.3) + */ +export interface PublicKeyCredentialDescriptorFuture extends Omit { + transports?: AuthenticatorTransportFuture[]; +} +/** */ +export type PublicKeyCredentialJSON = RegistrationResponseJSON | AuthenticationResponseJSON; +/** + * A super class of TypeScript's `PublicKeyCredential` that knows about upcoming WebAuthn features + */ +export interface PublicKeyCredentialFuture extends PublicKeyCredential { + type: PublicKeyCredentialType; + isConditionalMediationAvailable?(): Promise; + parseCreationOptionsFromJSON?(options: PublicKeyCredentialCreationOptionsJSON): PublicKeyCredentialCreationOptions; + parseRequestOptionsFromJSON?(options: PublicKeyCredentialRequestOptionsJSON): PublicKeyCredentialRequestOptions; + toJSON?(): PublicKeyCredentialJSON; +} +/** + * The two types of credentials as defined by bit 3 ("Backup Eligibility") in authenticator data: + * - `"singleDevice"` credentials will never be backed up + * - `"multiDevice"` credentials can be backed up + */ +export type CredentialDeviceType = 'singleDevice' | 'multiDevice'; +/** + * Categories of authenticators that Relying Parties can pass along to browsers during + * registration. Browsers that understand these values can optimize their modal experience to + * start the user off in a particular registration flow: + * + * - `hybrid`: A platform authenticator on a mobile device + * - `security-key`: A portable FIDO2 authenticator capable of being used on multiple devices via a USB or NFC connection + * - `client-device`: The device that WebAuthn is being called on. Typically synonymous with platform authenticators + * + * See https://w3c.github.io/webauthn/#enumdef-publickeycredentialhint + * + * These values are less strict than `authenticatorAttachment` + */ +export type PublicKeyCredentialHint = 'hybrid' | 'security-key' | 'client-device'; +/** + * Values for an attestation object's `fmt` + * + * See https://www.iana.org/assignments/webauthn/webauthn.xhtml#webauthn-attestation-statement-format-ids + */ +export type AttestationFormat = 'fido-u2f' | 'packed' | 'android-safetynet' | 'android-key' | 'tpm' | 'apple' | 'none'; +/** + * Equivalent to `Uint8Array` before TypeScript 5.7, and `Uint8Array` in TypeScript 5.7 + * and beyond. + * + * **Context** + * + * `Uint8Array` became a generic type in TypeScript 5.7, requiring types defined simply as + * `Uint8Array` to be refactored to `Uint8Array` starting in Deno 2.2. `Uint8Array` is + * _not_ generic in Deno 2.1.x and earlier, though, so this type helps bridge this gap. + * + * Inspired by Deno's std library: + * + * https://github.com/denoland/std/blob/b5a5fe4f96b91c1fe8dba5cc0270092dd11d3287/bytes/_types.ts#L11 + */ +export type Uint8Array_ = ReturnType; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/types/index.d.ts.map b/node_modules/@simplewebauthn/server/script/types/index.d.ts.map new file mode 100644 index 0000000000000000000000000000000000000000..bbe447a9050b6fc3438f5af9c2b6d1ffa63689a1 --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/types/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,+BAA+B,EAC/B,oCAAoC,EACpC,qCAAqC,EACrC,8BAA8B,EAC9B,uBAAuB,EACvB,gCAAgC,EAChC,8BAA8B,EAC9B,uBAAuB,EACvB,mBAAmB,EACnB,kCAAkC,EAClC,6BAA6B,EAC7B,6BAA6B,EAC7B,iCAAiC,EACjC,2BAA2B,EAC3B,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,+BAA+B,E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Ac,GAAG,eAAe,CAAC;AAElF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,QAAQ,GACR,mBAAmB,GACnB,aAAa,GACb,KAAK,GACL,OAAO,GACP,MAAM,CAAC;AAEX;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/node_modules/@simplewebauthn/server/script/types/index.js b/node_modules/@simplewebauthn/server/script/types/index.js new file mode 100644 index 0000000000000000000000000000000000000000..c8ad2e549bdc6801e0d1c80b0308d4b9bd4985ce --- /dev/null +++ b/node_modules/@simplewebauthn/server/script/types/index.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/node_modules/@standard-schema/spec/LICENSE b/node_modules/@standard-schema/spec/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..ea54e0ddad405b2ee635d687a876613214160ba2 --- /dev/null +++ b/node_modules/@standard-schema/spec/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Colin McDonnell + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/node_modules/@standard-schema/spec/README.md b/node_modules/@standard-schema/spec/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f9813ffa878e7914dc2928ab13db856850e8d83e --- /dev/null +++ b/node_modules/@standard-schema/spec/README.md @@ -0,0 +1,198 @@ +

+ Standard Schema fire logo +
+ Standard Schema

+

+ A family of specs for interoperable TypeScript +
+ standardschema.dev +

+
+ + + +The Standard Schema project is a set of interfaces that standardize the provision and consumption of shared functionality in the TypeScript ecosystem. + +Its goal is to allow tools to accept a single input that includes all the types and capabilities they need— no library-specific adapters, no extra dependencies. The result is an ecosystem that's fair for implementers, friendly for consumers, and open for end users. + +## The specifications + +The specifications can be found below in their entirety. Libraries wishing to implement a spec can copy/paste the code block below into their codebase. They're also available at `@standard-schema/spec` on [npm](https://www.npmjs.com/package/@standard-schema/spec) and [JSR](https://jsr.io/@standard-schema/spec). + +```ts +// ######################### +// ### Standard Typed ### +// ######################### + +/** The Standard Typed interface. This is a base type extended by other specs. */ +export interface StandardTypedV1 { + /** The Standard properties. */ + readonly "~standard": StandardTypedV1.Props; +} + +export declare namespace StandardTypedV1 { + /** The Standard Typed properties interface. */ + export interface Props { + /** The version number of the standard. */ + readonly version: 1; + /** The vendor name of the schema library. */ + readonly vendor: string; + /** Inferred types associated with the schema. */ + readonly types?: Types | undefined; + } + + /** The Standard Typed types interface. */ + export interface Types { + /** The input type of the schema. */ + readonly input: Input; + /** The output type of the schema. */ + readonly output: Output; + } + + /** Infers the input type of a Standard Typed. */ + export type InferInput = NonNullable< + Schema["~standard"]["types"] + >["input"]; + + /** Infers the output type of a Standard Typed. */ + export type InferOutput = NonNullable< + Schema["~standard"]["types"] + >["output"]; +} + +// ########################## +// ### Standard Schema ### +// ########################## + +/** The Standard Schema interface. */ +export interface StandardSchemaV1 { + /** The Standard Schema properties. */ + readonly "~standard": StandardSchemaV1.Props; +} + +export declare namespace StandardSchemaV1 { + /** The Standard Schema properties interface. */ + export interface Props + extends StandardTypedV1.Props { + /** Validates unknown input values. */ + readonly validate: ( + value: unknown, + options?: StandardSchemaV1.Options | undefined + ) => Result | Promise>; + } + + /** The result interface of the validate function. */ + export type Result = SuccessResult | FailureResult; + + /** The result interface if validation succeeds. */ + export interface SuccessResult { + /** The typed output value. */ + readonly value: Output; + /** A falsy value for `issues` indicates success. */ + readonly issues?: undefined; + } + + export interface Options { + /** Explicit support for additional vendor-specific parameters, if needed. */ + readonly libraryOptions?: Record | undefined; + } + + /** The result interface if validation fails. */ + export interface FailureResult { + /** The issues of failed validation. */ + readonly issues: ReadonlyArray; + } + + /** The issue interface of the failure output. */ + export interface Issue { + /** The error message of the issue. */ + readonly message: string; + /** The path of the issue, if any. */ + readonly path?: ReadonlyArray | undefined; + } + + /** The path segment interface of the issue. */ + export interface PathSegment { + /** The key representing a path segment. */ + readonly key: PropertyKey; + } + + /** The Standard types interface. */ + export interface Types + extends StandardTypedV1.Types {} + + /** Infers the input type of a Standard. */ + export type InferInput = + StandardTypedV1.InferInput; + + /** Infers the output type of a Standard. */ + export type InferOutput = + StandardTypedV1.InferOutput; +} + +// ############################### +// ### Standard JSON Schema ### +// ############################### + +/** The Standard JSON Schema interface. */ +export interface StandardJSONSchemaV1 { + /** The Standard JSON Schema properties. */ + readonly "~standard": StandardJSONSchemaV1.Props; +} + +export declare namespace StandardJSONSchemaV1 { + /** The Standard JSON Schema properties interface. */ + export interface Props + extends StandardTypedV1.Props { + /** Methods for generating the input/output JSON Schema. */ + readonly jsonSchema: StandardJSONSchemaV1.Converter; + } + + /** The Standard JSON Schema converter interface. */ + export interface Converter { + /** Converts the input type to JSON Schema. May throw if conversion is not supported. */ + readonly input: ( + options: StandardJSONSchemaV1.Options + ) => Record; + /** Converts the output type to JSON Schema. May throw if conversion is not supported. */ + readonly output: ( + options: StandardJSONSchemaV1.Options + ) => Record; + } + + /** + * The target version of the generated JSON Schema. + * + * It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target. + * + * The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`. + */ + export type Target = + | "draft-2020-12" + | "draft-07" + | "openapi-3.0" + // Accepts any string for future targets while preserving autocomplete + | ({} & string); + + /** The options for the input/output methods. */ + export interface Options { + /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */ + readonly target: Target; + + /** Explicit support for additional vendor-specific parameters, if needed. */ + readonly libraryOptions?: Record | undefined; + } + + /** The Standard types interface. */ + export interface Types + extends StandardTypedV1.Types {} + + /** Infers the input type of a Standard. */ + export type InferInput = + StandardTypedV1.InferInput; + + /** Infers the output type of a Standard. */ + export type InferOutput = + StandardTypedV1.InferOutput; +} +``` diff --git a/node_modules/@standard-schema/spec/dist/index.cjs b/node_modules/@standard-schema/spec/dist/index.cjs new file mode 100644 index 0000000000000000000000000000000000000000..321666eb3e061c8fa6e38f0d5ce040591cd19da4 --- /dev/null +++ b/node_modules/@standard-schema/spec/dist/index.cjs @@ -0,0 +1,18 @@ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var src_exports = {}; +module.exports = __toCommonJS(src_exports); diff --git a/node_modules/@standard-schema/spec/dist/index.d.cts b/node_modules/@standard-schema/spec/dist/index.d.cts new file mode 100644 index 0000000000000000000000000000000000000000..5e4acaad22d61471cc675bd4a1c776eb96b38ce1 --- /dev/null +++ b/node_modules/@standard-schema/spec/dist/index.d.cts @@ -0,0 +1,119 @@ +/** The Standard Typed interface. This is a base type extended by other specs. */ +interface StandardTypedV1 { + /** The Standard properties. */ + readonly "~standard": StandardTypedV1.Props; +} +declare namespace StandardTypedV1 { + /** The Standard Typed properties interface. */ + interface Props { + /** The version number of the standard. */ + readonly version: 1; + /** The vendor name of the schema library. */ + readonly vendor: string; + /** Inferred types associated with the schema. */ + readonly types?: Types | undefined; + } + /** The Standard Typed types interface. */ + interface Types { + /** The input type of the schema. */ + readonly input: Input; + /** The output type of the schema. */ + readonly output: Output; + } + /** Infers the input type of a Standard Typed. */ + type InferInput = NonNullable["input"]; + /** Infers the output type of a Standard Typed. */ + type InferOutput = NonNullable["output"]; +} +/** The Standard Schema interface. */ +interface StandardSchemaV1 { + /** The Standard Schema properties. */ + readonly "~standard": StandardSchemaV1.Props; +} +declare namespace StandardSchemaV1 { + /** The Standard Schema properties interface. */ + interface Props extends StandardTypedV1.Props { + /** Validates unknown input values. */ + readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result | Promise>; + } + /** The result interface of the validate function. */ + type Result = SuccessResult | FailureResult; + /** The result interface if validation succeeds. */ + interface SuccessResult { + /** The typed output value. */ + readonly value: Output; + /** A falsy value for `issues` indicates success. */ + readonly issues?: undefined; + } + interface Options { + /** Explicit support for additional vendor-specific parameters, if needed. */ + readonly libraryOptions?: Record | undefined; + } + /** The result interface if validation fails. */ + interface FailureResult { + /** The issues of failed validation. */ + readonly issues: ReadonlyArray; + } + /** The issue interface of the failure output. */ + interface Issue { + /** The error message of the issue. */ + readonly message: string; + /** The path of the issue, if any. */ + readonly path?: ReadonlyArray | undefined; + } + /** The path segment interface of the issue. */ + interface PathSegment { + /** The key representing a path segment. */ + readonly key: PropertyKey; + } + /** The Standard types interface. */ + interface Types extends StandardTypedV1.Types { + } + /** Infers the input type of a Standard. */ + type InferInput = StandardTypedV1.InferInput; + /** Infers the output type of a Standard. */ + type InferOutput = StandardTypedV1.InferOutput; +} +/** The Standard JSON Schema interface. */ +interface StandardJSONSchemaV1 { + /** The Standard JSON Schema properties. */ + readonly "~standard": StandardJSONSchemaV1.Props; +} +declare namespace StandardJSONSchemaV1 { + /** The Standard JSON Schema properties interface. */ + interface Props extends StandardTypedV1.Props { + /** Methods for generating the input/output JSON Schema. */ + readonly jsonSchema: StandardJSONSchemaV1.Converter; + } + /** The Standard JSON Schema converter interface. */ + interface Converter { + /** Converts the input type to JSON Schema. May throw if conversion is not supported. */ + readonly input: (options: StandardJSONSchemaV1.Options) => Record; + /** Converts the output type to JSON Schema. May throw if conversion is not supported. */ + readonly output: (options: StandardJSONSchemaV1.Options) => Record; + } + /** + * The target version of the generated JSON Schema. + * + * It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target. + * + * The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`. + */ + type Target = "draft-2020-12" | "draft-07" | "openapi-3.0" | ({} & string); + /** The options for the input/output methods. */ + interface Options { + /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */ + readonly target: Target; + /** Explicit support for additional vendor-specific parameters, if needed. */ + readonly libraryOptions?: Record | undefined; + } + /** The Standard types interface. */ + interface Types extends StandardTypedV1.Types { + } + /** Infers the input type of a Standard. */ + type InferInput = StandardTypedV1.InferInput; + /** Infers the output type of a Standard. */ + type InferOutput = StandardTypedV1.InferOutput; +} + +export { StandardJSONSchemaV1, StandardSchemaV1, StandardTypedV1 }; diff --git a/node_modules/@standard-schema/spec/dist/index.d.ts b/node_modules/@standard-schema/spec/dist/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e4acaad22d61471cc675bd4a1c776eb96b38ce1 --- /dev/null +++ b/node_modules/@standard-schema/spec/dist/index.d.ts @@ -0,0 +1,119 @@ +/** The Standard Typed interface. This is a base type extended by other specs. */ +interface StandardTypedV1 { + /** The Standard properties. */ + readonly "~standard": StandardTypedV1.Props; +} +declare namespace StandardTypedV1 { + /** The Standard Typed properties interface. */ + interface Props { + /** The version number of the standard. */ + readonly version: 1; + /** The vendor name of the schema library. */ + readonly vendor: string; + /** Inferred types associated with the schema. */ + readonly types?: Types | undefined; + } + /** The Standard Typed types interface. */ + interface Types { + /** The input type of the schema. */ + readonly input: Input; + /** The output type of the schema. */ + readonly output: Output; + } + /** Infers the input type of a Standard Typed. */ + type InferInput = NonNullable["input"]; + /** Infers the output type of a Standard Typed. */ + type InferOutput = NonNullable["output"]; +} +/** The Standard Schema interface. */ +interface StandardSchemaV1 { + /** The Standard Schema properties. */ + readonly "~standard": StandardSchemaV1.Props; +} +declare namespace StandardSchemaV1 { + /** The Standard Schema properties interface. */ + interface Props extends StandardTypedV1.Props { + /** Validates unknown input values. */ + readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result | Promise>; + } + /** The result interface of the validate function. */ + type Result = SuccessResult | FailureResult; + /** The result interface if validation succeeds. */ + interface SuccessResult { + /** The typed output value. */ + readonly value: Output; + /** A falsy value for `issues` indicates success. */ + readonly issues?: undefined; + } + interface Options { + /** Explicit support for additional vendor-specific parameters, if needed. */ + readonly libraryOptions?: Record | undefined; + } + /** The result interface if validation fails. */ + interface FailureResult { + /** The issues of failed validation. */ + readonly issues: ReadonlyArray; + } + /** The issue interface of the failure output. */ + interface Issue { + /** The error message of the issue. */ + readonly message: string; + /** The path of the issue, if any. */ + readonly path?: ReadonlyArray | undefined; + } + /** The path segment interface of the issue. */ + interface PathSegment { + /** The key representing a path segment. */ + readonly key: PropertyKey; + } + /** The Standard types interface. */ + interface Types extends StandardTypedV1.Types { + } + /** Infers the input type of a Standard. */ + type InferInput = StandardTypedV1.InferInput; + /** Infers the output type of a Standard. */ + type InferOutput = StandardTypedV1.InferOutput; +} +/** The Standard JSON Schema interface. */ +interface StandardJSONSchemaV1 { + /** The Standard JSON Schema properties. */ + readonly "~standard": StandardJSONSchemaV1.Props; +} +declare namespace StandardJSONSchemaV1 { + /** The Standard JSON Schema properties interface. */ + interface Props extends StandardTypedV1.Props { + /** Methods for generating the input/output JSON Schema. */ + readonly jsonSchema: StandardJSONSchemaV1.Converter; + } + /** The Standard JSON Schema converter interface. */ + interface Converter { + /** Converts the input type to JSON Schema. May throw if conversion is not supported. */ + readonly input: (options: StandardJSONSchemaV1.Options) => Record; + /** Converts the output type to JSON Schema. May throw if conversion is not supported. */ + readonly output: (options: StandardJSONSchemaV1.Options) => Record; + } + /** + * The target version of the generated JSON Schema. + * + * It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target. + * + * The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`. + */ + type Target = "draft-2020-12" | "draft-07" | "openapi-3.0" | ({} & string); + /** The options for the input/output methods. */ + interface Options { + /** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */ + readonly target: Target; + /** Explicit support for additional vendor-specific parameters, if needed. */ + readonly libraryOptions?: Record | undefined; + } + /** The Standard types interface. */ + interface Types extends StandardTypedV1.Types { + } + /** Infers the input type of a Standard. */ + type InferInput = StandardTypedV1.InferInput; + /** Infers the output type of a Standard. */ + type InferOutput = StandardTypedV1.InferOutput; +} + +export { StandardJSONSchemaV1, StandardSchemaV1, StandardTypedV1 }; diff --git a/node_modules/@standard-schema/spec/dist/index.js b/node_modules/@standard-schema/spec/dist/index.js new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/node_modules/@standard-schema/spec/package.json b/node_modules/@standard-schema/spec/package.json new file mode 100644 index 0000000000000000000000000000000000000000..62bb5518706bf743a2140f03aa5271507ae9bcdf --- /dev/null +++ b/node_modules/@standard-schema/spec/package.json @@ -0,0 +1,52 @@ +{ + "name": "@standard-schema/spec", + "description": "A family of specs for interoperable TypeScript", + "version": "1.1.0", + "license": "MIT", + "author": "Colin McDonnell", + "homepage": "https://standardschema.dev", + "repository": { + "type": "git", + "url": "https://github.com/standard-schema/standard-schema" + }, + "keywords": [ + "typescript", + "schema", + "validation", + "standard", + "interface" + ], + "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "standard-schema-spec": "./src/index.ts", + "import": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/index.d.cts", + "default": "./dist/index.cjs" + } + } + }, + "sideEffects": false, + "files": [ + "dist" + ], + "publishConfig": { + "access": "public" + }, + "devDependencies": { + "tsup": "^8.3.0", + "typescript": "^5.6.2" + }, + "scripts": { + "lint": "pnpm biome lint ./src", + "format": "pnpm biome format --write ./src", + "check": "pnpm biome check ./src", + "build": "tsup" + } +} \ No newline at end of file diff --git a/node_modules/@swc/core-linux-x64-gnu/LICENSE b/node_modules/@swc/core-linux-x64-gnu/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..6a08504909fe063aedf79b9113c240dec13858d5 --- /dev/null +++ b/node_modules/@swc/core-linux-x64-gnu/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2024 SWC contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/node_modules/@swc/core-linux-x64-gnu/README.md b/node_modules/@swc/core-linux-x64-gnu/README.md new file mode 100644 index 0000000000000000000000000000000000000000..7ada5175bd44a807f1e424d8c5cb3a458a82b689 --- /dev/null +++ b/node_modules/@swc/core-linux-x64-gnu/README.md @@ -0,0 +1,3 @@ +# `@swc/core-linux-x64-gnu` + +This is the **x86_64-unknown-linux-gnu** binary for `@swc/core` diff --git a/node_modules/@swc/core-linux-x64-gnu/package.json b/node_modules/@swc/core-linux-x64-gnu/package.json new file mode 100644 index 0000000000000000000000000000000000000000..a3cb929bb7377d527d430513538a8f605bc70931 --- /dev/null +++ b/node_modules/@swc/core-linux-x64-gnu/package.json @@ -0,0 +1,46 @@ +{ + "name": "@swc/core-linux-x64-gnu", + "version": "1.15.41", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "main": "swc.linux-x64-gnu.node", + "files": [ + "swc.linux-x64-gnu.node", + "swc" + ], + "libc": [ + "glibc" + ], + "description": "Super-fast alternative for babel", + "keywords": [ + "swc", + "swcpack", + "babel", + "typescript", + "rust", + "webpack", + "tsc" + ], + "author": "강동윤 ", + "homepage": "https://swc.rs", + "license": "Apache-2.0 AND MIT", + "engines": { + "node": ">=10" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/", + "access": "public", + "provenance": true + }, + "repository": { + "type": "git", + "url": "git+https://github.com/swc-project/swc.git" + }, + "bugs": { + "url": "https://github.com/swc-project/swc/issues" + } +} \ No newline at end of file diff --git a/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node b/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node new file mode 100644 index 0000000000000000000000000000000000000000..6f3f525265a7a91d01d759ac5335ace1670ba201 --- /dev/null +++ b/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fb8c79638a6b5c783ca3df525ec70223094ff17e2502e00c0c9042ce94354fba +size 27992576 diff --git a/node_modules/@swc/core-linux-x64-musl/LICENSE b/node_modules/@swc/core-linux-x64-musl/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..6a08504909fe063aedf79b9113c240dec13858d5 --- /dev/null +++ b/node_modules/@swc/core-linux-x64-musl/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2024 SWC contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/node_modules/@swc/core-linux-x64-musl/README.md b/node_modules/@swc/core-linux-x64-musl/README.md new file mode 100644 index 0000000000000000000000000000000000000000..abc775dcdf708ae2c20ac0b0f57ed72cba5e1d2d --- /dev/null +++ b/node_modules/@swc/core-linux-x64-musl/README.md @@ -0,0 +1,3 @@ +# `@swc/core-linux-x64-musl` + +This is the **x86_64-unknown-linux-musl** binary for `@swc/core` diff --git a/node_modules/@swc/core-linux-x64-musl/package.json b/node_modules/@swc/core-linux-x64-musl/package.json new file mode 100644 index 0000000000000000000000000000000000000000..37bf65d4ca4ef1807bda7c56c35d58466c4e2c25 --- /dev/null +++ b/node_modules/@swc/core-linux-x64-musl/package.json @@ -0,0 +1,46 @@ +{ + "name": "@swc/core-linux-x64-musl", + "version": "1.15.41", + "os": [ + "linux" + ], + "cpu": [ + "x64" + ], + "main": "swc.linux-x64-musl.node", + "files": [ + "swc.linux-x64-musl.node", + "swc" + ], + "libc": [ + "musl" + ], + "description": "Super-fast alternative for babel", + "keywords": [ + "swc", + "swcpack", + "babel", + "typescript", + "rust", + "webpack", + "tsc" + ], + "author": "강동윤 ", + "homepage": "https://swc.rs", + "license": "Apache-2.0 AND MIT", + "engines": { + "node": ">=10" + }, + "publishConfig": { + "registry": "https://registry.npmjs.org/", + "access": "public", + "provenance": true + }, + "repository": { + "type": "git", + "url": "git+https://github.com/swc-project/swc.git" + }, + "bugs": { + "url": "https://github.com/swc-project/swc/issues" + } +} \ No newline at end of file diff --git a/node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node b/node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node new file mode 100644 index 0000000000000000000000000000000000000000..f5e3b73260b99161d03f0eb550974f054d05c566 --- /dev/null +++ b/node_modules/@swc/core-linux-x64-musl/swc.linux-x64-musl.node @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:eae2d971a14db0cdc55df0b4dd6489cc7ebce69c696cb890098a2a613bb1c762 +size 34548496 diff --git a/node_modules/@swc/core/LICENSE b/node_modules/@swc/core/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..6a08504909fe063aedf79b9113c240dec13858d5 --- /dev/null +++ b/node_modules/@swc/core/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright 2024 SWC contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/node_modules/@swc/core/README.md b/node_modules/@swc/core/README.md new file mode 100644 index 0000000000000000000000000000000000000000..297707cd429f35313276c295c02c1064ce23a802 --- /dev/null +++ b/node_modules/@swc/core/README.md @@ -0,0 +1,100 @@ +

+ + swc + +

+ +

+ Make the web (development) faster. +

+ +

+ downloads (@swc/core) + downloads (3rd party) +

+

+ undefined + GitHub release (latest SemVer) +

+

+ GitHub code size in bytes + node-current (scoped) +

+

+ Discord +

+ +SWC (stands for `Speedy Web Compiler`) is a super-fast TypeScript / JavaScript compiler written in Rust. It's a library for Rust and JavaScript at the same time. If you are using SWC from Rust, see [rustdoc](https://rustdoc.swc.rs/swc/) and for most users, your entry point for using the library will be [parser](https://rustdoc.swc.rs/swc_ecma_parser/). + +Also, SWC tries to ensure that + +> If you select the latest version of each crates, it will work + +for rust users. + +MSRV of crates is currently `1.73`. + +To update all SWC crates you use, you can run `curl https://raw.githubusercontent.com/swc-project/swc/main/scripts/update-all-swc-crates.sh | bash -s`. This script will update all dependencies to the latest version and run `cargo build` to ensure that everything works. +Note that you need + +- `jq` +- `cargo upgrade` + +command to run the script. + +Supported Node Versions: + +- Node v10+ for usage +- Node v20+ for development + +--- + +If you are using SWC from JavaScript, please refer to [docs on the website](https://swc.rs/docs/installation/). + +# Documentation + +Check out the documentation [in the website](https://swc.rs/docs/installation/). + +# Features + +Please see [comparison with babel](https://swc.rs/docs/migrating-from-babel). + +# Performance + +Please see [benchmark results](https://swc.rs/docs/benchmark-transform) on the website. + +# Supporting development + +

Supporting swc

+ +## Star History + +[![Star History Chart](https://api.star-history.com/svg?repos=swc-project/swc&type=Timeline)](https://www.star-history.com/#swc-project/swc&Timeline) + +## Powered by + +[![JetBrains logo.](https://resources.jetbrains.com/storage/products/company/brand/logos/jetbrains.svg)](https://jb.gg/OpenSourceSupport) + +## Sponsors + +

+ + Sponsors + +

+ +SWC is a community-driven project, and is maintained by a group of [volunteers](https://swc.rs/docs/team). If you'd like to help support the future of the project, please consider: + +- Giving developer time on the project. (Message us on [Discord](https://discord.gg/GnHbXTdZz6) (preferred) or [Github discussions](https://github.com/swc-project/swc/discussions) for guidance!) +- Giving funds by becoming a sponsor (see https://opencollective.com/swc)! + +## Contributing + +See [CONTRIBUTING.md](CONTRIBUTING.md). You may also find the architecture +documentation useful ([ARCHITECTURE.md](ARCHITECTURE.md)). + +## License + +SWC is primarily distributed under the terms of the Apache License (Version 2.0). + +See [LICENSE](LICENSE) for details. diff --git a/node_modules/@swc/core/Visitor.d.ts b/node_modules/@swc/core/Visitor.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..256c2bc6beccb088d150fdfb15137fec6a1e6d16 --- /dev/null +++ b/node_modules/@swc/core/Visitor.d.ts @@ -0,0 +1,218 @@ +import { Accessibility, Argument, ArrayExpression, ArrayPattern, ArrowFunctionExpression, AssignmentExpression, AssignmentPattern, AssignmentPatternProperty, AssignmentProperty, AwaitExpression, BigIntLiteral, BinaryExpression, BindingIdentifier, BlockStatement, BooleanLiteral, BreakStatement, CallExpression, CatchClause, Class, ClassDeclaration, ClassExpression, ClassMember, ClassMethod, ClassProperty, ComputedPropName, ConditionalExpression, Constructor, ContinueStatement, DebuggerStatement, Declaration, Decorator, DefaultDecl, DoWhileStatement, EmptyStatement, ExportAllDeclaration, ExportDeclaration, ExportDefaultDeclaration, ExportDefaultExpression, ExportDefaultSpecifier, ExportNamedDeclaration, ExportNamespaceSpecifier, ExportSpecifier, ExprOrSpread, Expression, ExpressionStatement, Fn, ForInStatement, ForOfStatement, ForStatement, FunctionDeclaration, FunctionExpression, GetterProperty, Identifier, IfStatement, Import, ImportDeclaration, ImportDefaultSpecifier, ImportNamespaceSpecifier, ImportSpecifier, JSXAttrValue, JSXAttribute, JSXAttributeName, JSXAttributeOrSpread, JSXClosingElement, JSXClosingFragment, JSXElement, JSXElementChild, JSXElementName, JSXEmptyExpression, JSXExpressionContainer, JSXFragment, JSXMemberExpression, JSXNamespacedName, JSXObject, JSXOpeningElement, JSXOpeningFragment, JSXSpreadChild, JSXText, KeyValuePatternProperty, KeyValueProperty, LabeledStatement, MemberExpression, MetaProperty, MethodProperty, Module, ModuleDeclaration, ModuleExportName, ModuleItem, NamedExportSpecifier, NamedImportSpecifier, NewExpression, NullLiteral, NumericLiteral, ObjectExpression, ObjectPattern, ObjectPatternProperty, OptionalChainingCall, OptionalChainingExpression, Param, ParenthesisExpression, Pattern, PrivateMethod, PrivateName, PrivateProperty, Program, Property, PropertyName, RegExpLiteral, RestElement, ReturnStatement, Script, SequenceExpression, SetterProperty, SpreadElement, Statement, StaticBlock, StringLiteral, Super, SuperPropExpression, SwitchCase, SwitchStatement, TaggedTemplateExpression, TemplateLiteral, ThisExpression, ThrowStatement, TryStatement, TsAsExpression, TsCallSignatureDeclaration, TsConstAssertion, TsConstructSignatureDeclaration, TsEntityName, TsEnumDeclaration, TsEnumMember, TsEnumMemberId, TsExportAssignment, TsExpressionWithTypeArguments, TsExternalModuleReference, TsFnParameter, TsGetterSignature, TsImportEqualsDeclaration, TsIndexSignature, TsInstantiation, TsInterfaceBody, TsInterfaceDeclaration, TsMethodSignature, TsModuleBlock, TsModuleDeclaration, TsModuleName, TsModuleReference, TsNamespaceBody, TsNamespaceDeclaration, TsNamespaceExportDeclaration, TsNonNullExpression, TsParameterProperty, TsParameterPropertyParameter, TsPropertySignature, TsQualifiedName, TsSatisfiesExpression, TsSetterSignature, TsType, TsTypeAliasDeclaration, TsTypeAnnotation, TsTypeAssertion, TsTypeElement, TsTypeParameter, TsTypeParameterDeclaration, TsTypeParameterInstantiation, UnaryExpression, UpdateExpression, VariableDeclaration, VariableDeclarator, WhileStatement, WithStatement, YieldExpression } from "@swc/types"; +/** + * @deprecated JavaScript API is deprecated. Please use Wasm plugin instead. + */ +export declare class Visitor { + visitProgram(n: Program): Program; + visitModule(m: Module): Module; + visitScript(m: Script): Script; + visitModuleItems(items: ModuleItem[]): ModuleItem[]; + visitModuleItem(n: ModuleItem): ModuleItem; + visitModuleDeclaration(n: ModuleDeclaration): ModuleDeclaration; + visitTsNamespaceExportDeclaration(n: TsNamespaceExportDeclaration): ModuleDeclaration; + visitTsExportAssignment(n: TsExportAssignment): TsExportAssignment; + visitTsImportEqualsDeclaration(n: TsImportEqualsDeclaration): ModuleDeclaration; + visitTsModuleReference(n: TsModuleReference): TsModuleReference; + visitTsExternalModuleReference(n: TsExternalModuleReference): TsExternalModuleReference; + visitExportAllDeclaration(n: ExportAllDeclaration): ModuleDeclaration; + visitExportDefaultExpression(n: ExportDefaultExpression): ModuleDeclaration; + visitExportNamedDeclaration(n: ExportNamedDeclaration): ModuleDeclaration; + visitExportSpecifiers(nodes: ExportSpecifier[]): ExportSpecifier[]; + visitExportSpecifier(n: ExportSpecifier): ExportSpecifier; + visitNamedExportSpecifier(n: NamedExportSpecifier): ExportSpecifier; + visitModuleExportName(n: ModuleExportName): ModuleExportName; + visitExportNamespaceSpecifier(n: ExportNamespaceSpecifier): ExportSpecifier; + visitExportDefaultSpecifier(n: ExportDefaultSpecifier): ExportSpecifier; + visitOptionalStringLiteral(n: StringLiteral | undefined): StringLiteral | undefined; + visitExportDefaultDeclaration(n: ExportDefaultDeclaration): ModuleDeclaration; + visitDefaultDeclaration(n: DefaultDecl): DefaultDecl; + visitFunctionExpression(n: FunctionExpression): FunctionExpression; + visitClassExpression(n: ClassExpression): ClassExpression; + visitExportDeclaration(n: ExportDeclaration): ModuleDeclaration; + visitArrayExpression(e: ArrayExpression): Expression; + visitArrayElement(e: ExprOrSpread | undefined): ExprOrSpread | undefined; + visitExprOrSpread(e: ExprOrSpread): ExprOrSpread; + visitExprOrSpreads(nodes: ExprOrSpread[]): ExprOrSpread[]; + visitSpreadElement(e: SpreadElement): SpreadElement; + visitOptionalExpression(e: Expression | undefined): Expression | undefined; + visitArrowFunctionExpression(e: ArrowFunctionExpression): Expression; + visitArrowBody(body: BlockStatement | Expression): BlockStatement | Expression; + visitBlockStatement(block: BlockStatement): BlockStatement; + visitStatements(stmts: Statement[]): Statement[]; + visitStatement(stmt: Statement): Statement; + visitSwitchStatement(stmt: SwitchStatement): Statement; + visitSwitchCases(cases: SwitchCase[]): SwitchCase[]; + visitSwitchCase(c: SwitchCase): SwitchCase; + visitIfStatement(stmt: IfStatement): Statement; + visitOptionalStatement(stmt: Statement | undefined): Statement | undefined; + visitBreakStatement(stmt: BreakStatement): Statement; + visitWhileStatement(stmt: WhileStatement): Statement; + visitTryStatement(stmt: TryStatement): Statement; + visitCatchClause(handler: CatchClause | undefined): CatchClause | undefined; + visitThrowStatement(stmt: ThrowStatement): Statement; + visitReturnStatement(stmt: ReturnStatement): Statement; + visitLabeledStatement(stmt: LabeledStatement): Statement; + visitForStatement(stmt: ForStatement): Statement; + visitForOfStatement(stmt: ForOfStatement): Statement; + visitForInStatement(stmt: ForInStatement): Statement; + visitEmptyStatement(stmt: EmptyStatement): EmptyStatement; + visitDoWhileStatement(stmt: DoWhileStatement): Statement; + visitDebuggerStatement(stmt: DebuggerStatement): Statement; + visitWithStatement(stmt: WithStatement): Statement; + visitDeclaration(decl: Declaration): Declaration; + visitVariableDeclaration(n: VariableDeclaration): VariableDeclaration; + visitVariableDeclarators(nodes: VariableDeclarator[]): VariableDeclarator[]; + visitVariableDeclarator(n: VariableDeclarator): VariableDeclarator; + visitTsTypeAliasDeclaration(n: TsTypeAliasDeclaration): Declaration; + visitTsModuleDeclaration(n: TsModuleDeclaration): Declaration; + visitTsModuleName(n: TsModuleName): TsModuleName; + visitTsNamespaceBody(n: TsNamespaceBody): TsNamespaceBody | undefined; + visitTsNamespaceDeclaration(n: TsNamespaceDeclaration): TsModuleBlock | TsNamespaceDeclaration; + visitTsModuleBlock(n: TsModuleBlock): TsModuleBlock | TsNamespaceDeclaration; + visitTsInterfaceDeclaration(n: TsInterfaceDeclaration): TsInterfaceDeclaration; + visitTsInterfaceBody(n: TsInterfaceBody): TsInterfaceBody; + visitTsTypeElements(nodes: TsTypeElement[]): TsTypeElement[]; + visitTsTypeElement(n: TsTypeElement): TsTypeElement; + visitTsCallSignatureDeclaration(n: TsCallSignatureDeclaration): TsCallSignatureDeclaration; + visitTsConstructSignatureDeclaration(n: TsConstructSignatureDeclaration): TsConstructSignatureDeclaration; + visitTsPropertySignature(n: TsPropertySignature): TsPropertySignature; + visitTsGetterSignature(n: TsGetterSignature): TsGetterSignature; + visitTsSetterSignature(n: TsSetterSignature): TsSetterSignature; + visitTsMethodSignature(n: TsMethodSignature): TsMethodSignature; + visitTsEnumDeclaration(n: TsEnumDeclaration): Declaration; + visitTsEnumMembers(nodes: TsEnumMember[]): TsEnumMember[]; + visitTsEnumMember(n: TsEnumMember): TsEnumMember; + visitTsEnumMemberId(n: TsEnumMemberId): TsEnumMemberId; + visitFunctionDeclaration(decl: FunctionDeclaration): Declaration; + visitClassDeclaration(decl: ClassDeclaration): Declaration; + visitClassBody(members: ClassMember[]): ClassMember[]; + visitClassMember(member: ClassMember): ClassMember; + visitTsIndexSignature(n: TsIndexSignature): TsIndexSignature; + visitTsFnParameters(params: TsFnParameter[]): TsFnParameter[]; + visitTsFnParameter(n: TsFnParameter): TsFnParameter; + visitPrivateProperty(n: PrivateProperty): ClassMember; + visitPrivateMethod(n: PrivateMethod): ClassMember; + visitPrivateName(n: PrivateName): PrivateName; + visitConstructor(n: Constructor): ClassMember; + visitConstructorParameters(nodes: (Param | TsParameterProperty)[]): (Param | TsParameterProperty)[]; + visitConstructorParameter(n: Param | TsParameterProperty): Param | TsParameterProperty; + visitStaticBlock(n: StaticBlock): StaticBlock; + visitTsParameterProperty(n: TsParameterProperty): TsParameterProperty | Param; + visitTsParameterPropertyParameter(n: TsParameterPropertyParameter): TsParameterPropertyParameter; + visitPropertyName(key: PropertyName): PropertyName; + visitAccessibility(n: Accessibility | undefined): Accessibility | undefined; + visitClassProperty(n: ClassProperty): ClassMember; + visitClassMethod(n: ClassMethod): ClassMember; + visitComputedPropertyKey(n: ComputedPropName): ComputedPropName; + visitClass(n: T): T; + visitFunction(n: T): T; + visitTsExpressionsWithTypeArguments(nodes: TsExpressionWithTypeArguments[]): TsExpressionWithTypeArguments[]; + visitTsExpressionWithTypeArguments(n: TsExpressionWithTypeArguments): TsExpressionWithTypeArguments; + visitTsTypeParameterInstantiation(n: TsTypeParameterInstantiation | undefined): TsTypeParameterInstantiation | undefined; + visitTsTypes(nodes: TsType[]): TsType[]; + visitTsEntityName(n: TsEntityName): TsEntityName; + visitTsQualifiedName(n: TsQualifiedName): TsQualifiedName; + visitDecorators(nodes: Decorator[] | undefined): Decorator[] | undefined; + visitDecorator(n: Decorator): Decorator; + visitExpressionStatement(stmt: ExpressionStatement): Statement; + visitContinueStatement(stmt: ContinueStatement): Statement; + visitExpression(n: Expression): Expression; + visitOptionalChainingExpression(n: OptionalChainingExpression): Expression; + visitMemberExpressionOrOptionalChainingCall(n: MemberExpression | OptionalChainingCall): MemberExpression | OptionalChainingCall; + visitOptionalChainingCall(n: OptionalChainingCall): OptionalChainingCall; + visitAssignmentExpression(n: AssignmentExpression): Expression; + visitPatternOrExpression(n: Pattern | Expression): Pattern | Expression; + visitYieldExpression(n: YieldExpression): Expression; + visitUpdateExpression(n: UpdateExpression): Expression; + visitUnaryExpression(n: UnaryExpression): Expression; + visitTsTypeAssertion(n: TsTypeAssertion): Expression; + visitTsConstAssertion(n: TsConstAssertion): Expression; + visitTsInstantiation(n: TsInstantiation): TsInstantiation; + visitTsNonNullExpression(n: TsNonNullExpression): Expression; + visitTsAsExpression(n: TsAsExpression): Expression; + visitTsSatisfiesExpression(n: TsSatisfiesExpression): Expression; + visitThisExpression(n: ThisExpression): Expression; + visitTemplateLiteral(n: TemplateLiteral): Expression; + visitParameters(n: Param[]): Param[]; + visitParameter(n: Param): Param; + visitTaggedTemplateExpression(n: TaggedTemplateExpression): Expression; + visitSequenceExpression(n: SequenceExpression): Expression; + visitRegExpLiteral(n: RegExpLiteral): Expression; + visitParenthesisExpression(n: ParenthesisExpression): Expression; + visitObjectExpression(n: ObjectExpression): Expression; + visitObjectProperties(nodes: (Property | SpreadElement)[]): (Property | SpreadElement)[]; + visitObjectProperty(n: Property | SpreadElement): Property | SpreadElement; + visitProperty(n: Property): Property | SpreadElement; + visitSetterProperty(n: SetterProperty): Property | SpreadElement; + visitMethodProperty(n: MethodProperty): Property | SpreadElement; + visitKeyValueProperty(n: KeyValueProperty): Property | SpreadElement; + visitGetterProperty(n: GetterProperty): Property | SpreadElement; + visitAssignmentProperty(n: AssignmentProperty): Property | SpreadElement; + visitNullLiteral(n: NullLiteral): NullLiteral; + visitNewExpression(n: NewExpression): Expression; + visitTsTypeArguments(n: TsTypeParameterInstantiation | undefined): TsTypeParameterInstantiation | undefined; + visitArguments(nodes: Argument[]): Argument[]; + visitArgument(n: Argument): Argument; + visitMetaProperty(n: MetaProperty): Expression; + visitMemberExpression(n: MemberExpression): MemberExpression; + visitSuperPropExpression(n: SuperPropExpression): Expression; + visitCallee(n: Expression | Super | Import): Expression | Super | Import; + visitJSXText(n: JSXText): JSXText; + visitJSXNamespacedName(n: JSXNamespacedName): JSXNamespacedName; + visitJSXMemberExpression(n: JSXMemberExpression): JSXMemberExpression; + visitJSXObject(n: JSXObject): JSXObject; + visitJSXFragment(n: JSXFragment): JSXFragment; + visitJSXClosingFragment(n: JSXClosingFragment): JSXClosingFragment; + visitJSXElementChildren(nodes: JSXElementChild[]): JSXElementChild[]; + visitJSXElementChild(n: JSXElementChild): JSXElementChild; + visitJSXExpressionContainer(n: JSXExpressionContainer): JSXExpressionContainer; + visitJSXSpreadChild(n: JSXSpreadChild): JSXElementChild; + visitJSXOpeningFragment(n: JSXOpeningFragment): JSXOpeningFragment; + visitJSXEmptyExpression(n: JSXEmptyExpression): Expression; + visitJSXElement(n: JSXElement): JSXElement; + visitJSXClosingElement(n: JSXClosingElement | undefined): JSXClosingElement | undefined; + visitJSXElementName(n: JSXElementName): JSXElementName; + visitJSXOpeningElement(n: JSXOpeningElement): JSXOpeningElement; + visitJSXAttributes(attrs: JSXAttributeOrSpread[] | undefined): JSXAttributeOrSpread[] | undefined; + visitJSXAttributeOrSpread(n: JSXAttributeOrSpread): JSXAttributeOrSpread; + visitJSXAttributeOrSpreads(nodes: JSXAttributeOrSpread[]): JSXAttributeOrSpread[]; + visitJSXAttribute(n: JSXAttribute): JSXAttributeOrSpread; + visitJSXAttributeValue(n: JSXAttrValue | undefined): JSXAttrValue | undefined; + visitJSXAttributeName(n: JSXAttributeName): JSXAttributeName; + visitConditionalExpression(n: ConditionalExpression): Expression; + visitCallExpression(n: CallExpression): Expression; + visitBooleanLiteral(n: BooleanLiteral): BooleanLiteral; + visitBinaryExpression(n: BinaryExpression): Expression; + visitAwaitExpression(n: AwaitExpression): Expression; + visitTsTypeParameterDeclaration(n: TsTypeParameterDeclaration | undefined): TsTypeParameterDeclaration | undefined; + visitTsTypeParameters(nodes: TsTypeParameter[]): TsTypeParameter[]; + visitTsTypeParameter(n: TsTypeParameter): TsTypeParameter; + visitTsTypeAnnotation(a: TsTypeAnnotation | undefined): TsTypeAnnotation | undefined; + visitTsType(n: TsType): TsType; + visitPatterns(nodes: Pattern[]): Pattern[]; + visitImportDeclaration(n: ImportDeclaration): ImportDeclaration; + visitImportSpecifiers(nodes: ImportSpecifier[]): ImportSpecifier[]; + visitImportSpecifier(node: ImportSpecifier): ImportSpecifier; + visitNamedImportSpecifier(node: NamedImportSpecifier): NamedImportSpecifier; + visitImportNamespaceSpecifier(node: ImportNamespaceSpecifier): ImportNamespaceSpecifier; + visitImportDefaultSpecifier(node: ImportDefaultSpecifier): ImportSpecifier; + visitBindingIdentifier(i: BindingIdentifier): BindingIdentifier; + visitIdentifierReference(i: Identifier): Identifier; + visitLabelIdentifier(label: Identifier): Identifier; + visitIdentifier(n: Identifier): Identifier; + visitStringLiteral(n: StringLiteral): StringLiteral; + visitNumericLiteral(n: NumericLiteral): NumericLiteral; + visitBigIntLiteral(n: BigIntLiteral): BigIntLiteral; + visitPattern(n: Pattern): Pattern; + visitRestElement(n: RestElement): RestElement; + visitAssignmentPattern(n: AssignmentPattern): Pattern; + visitObjectPattern(n: ObjectPattern): Pattern; + visitObjectPatternProperties(nodes: ObjectPatternProperty[]): ObjectPatternProperty[]; + visitObjectPatternProperty(n: ObjectPatternProperty): ObjectPatternProperty; + visitKeyValuePatternProperty(n: KeyValuePatternProperty): ObjectPatternProperty; + visitAssignmentPatternProperty(n: AssignmentPatternProperty): ObjectPatternProperty; + visitArrayPattern(n: ArrayPattern): Pattern; + visitArrayPatternElements(nodes: (Pattern | undefined)[]): (Pattern | undefined)[]; + visitArrayPatternElement(n: Pattern | undefined): Pattern | undefined; +} +export default Visitor; diff --git a/node_modules/@swc/core/Visitor.js b/node_modules/@swc/core/Visitor.js new file mode 100644 index 0000000000000000000000000000000000000000..3844d231086cfeae20905e0406a330bd217d3ee9 --- /dev/null +++ b/node_modules/@swc/core/Visitor.js @@ -0,0 +1,1399 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Visitor = void 0; +/** + * @deprecated JavaScript API is deprecated. Please use Wasm plugin instead. + */ +class Visitor { + visitProgram(n) { + switch (n.type) { + case "Module": + return this.visitModule(n); + case "Script": + return this.visitScript(n); + } + } + visitModule(m) { + m.body = this.visitModuleItems(m.body); + return m; + } + visitScript(m) { + m.body = this.visitStatements(m.body); + return m; + } + visitModuleItems(items) { + return items.map(this.visitModuleItem.bind(this)); + } + visitModuleItem(n) { + switch (n.type) { + case "ExportDeclaration": + case "ExportDefaultDeclaration": + case "ExportNamedDeclaration": + case "ExportDefaultExpression": + case "ImportDeclaration": + case "ExportAllDeclaration": + case "TsImportEqualsDeclaration": + case "TsExportAssignment": + case "TsNamespaceExportDeclaration": + return this.visitModuleDeclaration(n); + default: + return this.visitStatement(n); + } + } + visitModuleDeclaration(n) { + switch (n.type) { + case "ExportDeclaration": + return this.visitExportDeclaration(n); + case "ExportDefaultDeclaration": + return this.visitExportDefaultDeclaration(n); + case "ExportNamedDeclaration": + return this.visitExportNamedDeclaration(n); + case "ExportDefaultExpression": + return this.visitExportDefaultExpression(n); + case "ImportDeclaration": + return this.visitImportDeclaration(n); + case "ExportAllDeclaration": + return this.visitExportAllDeclaration(n); + case "TsImportEqualsDeclaration": + return this.visitTsImportEqualsDeclaration(n); + case "TsExportAssignment": + return this.visitTsExportAssignment(n); + case "TsNamespaceExportDeclaration": + return this.visitTsNamespaceExportDeclaration(n); + } + } + visitTsNamespaceExportDeclaration(n) { + n.id = this.visitBindingIdentifier(n.id); + return n; + } + visitTsExportAssignment(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitTsImportEqualsDeclaration(n) { + n.id = this.visitBindingIdentifier(n.id); + n.moduleRef = this.visitTsModuleReference(n.moduleRef); + return n; + } + visitTsModuleReference(n) { + switch (n.type) { + case "Identifier": + return this.visitIdentifierReference(n); + case "TsExternalModuleReference": + return this.visitTsExternalModuleReference(n); + case "TsQualifiedName": + return this.visitTsQualifiedName(n); + } + } + visitTsExternalModuleReference(n) { + n.expression = this.visitStringLiteral(n.expression); + return n; + } + visitExportAllDeclaration(n) { + n.source = this.visitStringLiteral(n.source); + return n; + } + visitExportDefaultExpression(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitExportNamedDeclaration(n) { + n.specifiers = this.visitExportSpecifiers(n.specifiers); + n.source = this.visitOptionalStringLiteral(n.source); + return n; + } + visitExportSpecifiers(nodes) { + return nodes.map(this.visitExportSpecifier.bind(this)); + } + visitExportSpecifier(n) { + switch (n.type) { + case "ExportDefaultSpecifier": + return this.visitExportDefaultSpecifier(n); + case "ExportNamespaceSpecifier": + return this.visitExportNamespaceSpecifier(n); + case "ExportSpecifier": + return this.visitNamedExportSpecifier(n); + } + } + visitNamedExportSpecifier(n) { + if (n.exported) { + n.exported = this.visitModuleExportName(n.exported); + } + n.orig = this.visitModuleExportName(n.orig); + return n; + } + visitModuleExportName(n) { + switch (n.type) { + case "Identifier": + return this.visitIdentifier(n); + case "StringLiteral": + return this.visitStringLiteral(n); + } + } + visitExportNamespaceSpecifier(n) { + n.name = this.visitModuleExportName(n.name); + return n; + } + visitExportDefaultSpecifier(n) { + n.exported = this.visitBindingIdentifier(n.exported); + return n; + } + visitOptionalStringLiteral(n) { + if (n) { + return this.visitStringLiteral(n); + } + } + visitExportDefaultDeclaration(n) { + n.decl = this.visitDefaultDeclaration(n.decl); + return n; + } + visitDefaultDeclaration(n) { + switch (n.type) { + case "ClassExpression": + return this.visitClassExpression(n); + case "FunctionExpression": + return this.visitFunctionExpression(n); + case "TsInterfaceDeclaration": + return this.visitTsInterfaceDeclaration(n); + } + } + visitFunctionExpression(n) { + n = this.visitFunction(n); + if (n.identifier) { + n.identifier = this.visitBindingIdentifier(n.identifier); + } + return n; + } + visitClassExpression(n) { + n = this.visitClass(n); + if (n.identifier) { + n.identifier = this.visitBindingIdentifier(n.identifier); + } + return n; + } + visitExportDeclaration(n) { + n.declaration = this.visitDeclaration(n.declaration); + return n; + } + visitArrayExpression(e) { + if (e.elements) { + e.elements = e.elements.map(this.visitArrayElement.bind(this)); + } + return e; + } + visitArrayElement(e) { + if (e) { + return this.visitExprOrSpread(e); + } + } + visitExprOrSpread(e) { + return Object.assign(Object.assign({}, e), { expression: this.visitExpression(e.expression) }); + } + visitExprOrSpreads(nodes) { + return nodes.map(this.visitExprOrSpread.bind(this)); + } + visitSpreadElement(e) { + e.arguments = this.visitExpression(e.arguments); + return e; + } + visitOptionalExpression(e) { + if (e) { + return this.visitExpression(e); + } + } + visitArrowFunctionExpression(e) { + e.body = this.visitArrowBody(e.body); + e.params = this.visitPatterns(e.params); + e.returnType = this.visitTsTypeAnnotation(e.returnType); + e.typeParameters = this.visitTsTypeParameterDeclaration(e.typeParameters); + return e; + } + visitArrowBody(body) { + switch (body.type) { + case "BlockStatement": + return this.visitBlockStatement(body); + default: + return this.visitExpression(body); + } + } + visitBlockStatement(block) { + block.stmts = this.visitStatements(block.stmts); + return block; + } + visitStatements(stmts) { + return stmts.map(this.visitStatement.bind(this)); + } + visitStatement(stmt) { + switch (stmt.type) { + case "ClassDeclaration": + case "FunctionDeclaration": + case "TsEnumDeclaration": + case "TsInterfaceDeclaration": + case "TsModuleDeclaration": + case "TsTypeAliasDeclaration": + case "VariableDeclaration": + return this.visitDeclaration(stmt); + case "BreakStatement": + return this.visitBreakStatement(stmt); + case "BlockStatement": + return this.visitBlockStatement(stmt); + case "ContinueStatement": + return this.visitContinueStatement(stmt); + case "DebuggerStatement": + return this.visitDebuggerStatement(stmt); + case "DoWhileStatement": + return this.visitDoWhileStatement(stmt); + case "EmptyStatement": + return this.visitEmptyStatement(stmt); + case "ForInStatement": + return this.visitForInStatement(stmt); + case "ForOfStatement": + return this.visitForOfStatement(stmt); + case "ForStatement": + return this.visitForStatement(stmt); + case "IfStatement": + return this.visitIfStatement(stmt); + case "LabeledStatement": + return this.visitLabeledStatement(stmt); + case "ReturnStatement": + return this.visitReturnStatement(stmt); + case "SwitchStatement": + return this.visitSwitchStatement(stmt); + case "ThrowStatement": + return this.visitThrowStatement(stmt); + case "TryStatement": + return this.visitTryStatement(stmt); + case "WhileStatement": + return this.visitWhileStatement(stmt); + case "WithStatement": + return this.visitWithStatement(stmt); + case "ExpressionStatement": + return this.visitExpressionStatement(stmt); + default: + throw new Error(`Unknown statement type: ` + stmt.type); + } + } + visitSwitchStatement(stmt) { + stmt.discriminant = this.visitExpression(stmt.discriminant); + stmt.cases = this.visitSwitchCases(stmt.cases); + return stmt; + } + visitSwitchCases(cases) { + return cases.map(this.visitSwitchCase.bind(this)); + } + visitSwitchCase(c) { + c.test = this.visitOptionalExpression(c.test); + c.consequent = this.visitStatements(c.consequent); + return c; + } + visitIfStatement(stmt) { + stmt.test = this.visitExpression(stmt.test); + stmt.consequent = this.visitStatement(stmt.consequent); + stmt.alternate = this.visitOptionalStatement(stmt.alternate); + return stmt; + } + visitOptionalStatement(stmt) { + if (stmt) { + return this.visitStatement(stmt); + } + } + visitBreakStatement(stmt) { + if (stmt.label) { + stmt.label = this.visitLabelIdentifier(stmt.label); + } + return stmt; + } + visitWhileStatement(stmt) { + stmt.test = this.visitExpression(stmt.test); + stmt.body = this.visitStatement(stmt.body); + return stmt; + } + visitTryStatement(stmt) { + stmt.block = this.visitBlockStatement(stmt.block); + stmt.handler = this.visitCatchClause(stmt.handler); + if (stmt.finalizer) { + stmt.finalizer = this.visitBlockStatement(stmt.finalizer); + } + return stmt; + } + visitCatchClause(handler) { + if (handler) { + if (handler.param) { + handler.param = this.visitPattern(handler.param); + } + handler.body = this.visitBlockStatement(handler.body); + } + return handler; + } + visitThrowStatement(stmt) { + stmt.argument = this.visitExpression(stmt.argument); + return stmt; + } + visitReturnStatement(stmt) { + if (stmt.argument) { + stmt.argument = this.visitExpression(stmt.argument); + } + return stmt; + } + visitLabeledStatement(stmt) { + stmt.label = this.visitLabelIdentifier(stmt.label); + stmt.body = this.visitStatement(stmt.body); + return stmt; + } + visitForStatement(stmt) { + if (stmt.init) { + if (stmt.init.type === "VariableDeclaration") { + stmt.init = this.visitVariableDeclaration(stmt.init); + } + else { + stmt.init = this.visitOptionalExpression(stmt.init); + } + } + stmt.test = this.visitOptionalExpression(stmt.test); + stmt.update = this.visitOptionalExpression(stmt.update); + stmt.body = this.visitStatement(stmt.body); + return stmt; + } + visitForOfStatement(stmt) { + if (stmt.left.type === "VariableDeclaration") { + stmt.left = this.visitVariableDeclaration(stmt.left); + } + else { + stmt.left = this.visitPattern(stmt.left); + } + stmt.right = this.visitExpression(stmt.right); + stmt.body = this.visitStatement(stmt.body); + return stmt; + } + visitForInStatement(stmt) { + if (stmt.left.type === "VariableDeclaration") { + stmt.left = this.visitVariableDeclaration(stmt.left); + } + else { + stmt.left = this.visitPattern(stmt.left); + } + stmt.right = this.visitExpression(stmt.right); + stmt.body = this.visitStatement(stmt.body); + return stmt; + } + visitEmptyStatement(stmt) { + return stmt; + } + visitDoWhileStatement(stmt) { + stmt.body = this.visitStatement(stmt.body); + stmt.test = this.visitExpression(stmt.test); + return stmt; + } + visitDebuggerStatement(stmt) { + return stmt; + } + visitWithStatement(stmt) { + stmt.object = this.visitExpression(stmt.object); + stmt.body = this.visitStatement(stmt.body); + return stmt; + } + visitDeclaration(decl) { + switch (decl.type) { + case "ClassDeclaration": + return this.visitClassDeclaration(decl); + case "FunctionDeclaration": + return this.visitFunctionDeclaration(decl); + case "TsEnumDeclaration": + return this.visitTsEnumDeclaration(decl); + case "TsInterfaceDeclaration": + return this.visitTsInterfaceDeclaration(decl); + case "TsModuleDeclaration": + return this.visitTsModuleDeclaration(decl); + case "TsTypeAliasDeclaration": + return this.visitTsTypeAliasDeclaration(decl); + case "VariableDeclaration": + return this.visitVariableDeclaration(decl); + } + } + visitVariableDeclaration(n) { + n.declarations = this.visitVariableDeclarators(n.declarations); + return n; + } + visitVariableDeclarators(nodes) { + return nodes.map(this.visitVariableDeclarator.bind(this)); + } + visitVariableDeclarator(n) { + n.id = this.visitPattern(n.id); + n.init = this.visitOptionalExpression(n.init); + return n; + } + visitTsTypeAliasDeclaration(n) { + n.id = this.visitBindingIdentifier(n.id); + n.typeAnnotation = this.visitTsType(n.typeAnnotation); + n.typeParams = this.visitTsTypeParameterDeclaration(n.typeParams); + return n; + } + visitTsModuleDeclaration(n) { + n.id = this.visitTsModuleName(n.id); + if (n.body) { + n.body = this.visitTsNamespaceBody(n.body); + } + return n; + } + visitTsModuleName(n) { + switch (n.type) { + case "Identifier": + return this.visitBindingIdentifier(n); + case "StringLiteral": + return this.visitStringLiteral(n); + } + } + visitTsNamespaceBody(n) { + if (n) { + switch (n.type) { + case "TsModuleBlock": + return this.visitTsModuleBlock(n); + case "TsNamespaceDeclaration": + return this.visitTsNamespaceDeclaration(n); + } + } + } + visitTsNamespaceDeclaration(n) { + const body = this.visitTsNamespaceBody(n.body); + if (body) { + n.body = body; + } + n.id = this.visitBindingIdentifier(n.id); + return n; + } + visitTsModuleBlock(n) { + n.body = this.visitModuleItems(n.body); + return n; + } + visitTsInterfaceDeclaration(n) { + n.id = this.visitBindingIdentifier(n.id); + n.typeParams = this.visitTsTypeParameterDeclaration(n.typeParams); + n.extends = this.visitTsExpressionsWithTypeArguments(n.extends); + n.body = this.visitTsInterfaceBody(n.body); + return n; + } + visitTsInterfaceBody(n) { + n.body = this.visitTsTypeElements(n.body); + return n; + } + visitTsTypeElements(nodes) { + return nodes.map(this.visitTsTypeElement.bind(this)); + } + visitTsTypeElement(n) { + switch (n.type) { + case "TsCallSignatureDeclaration": + return this.visitTsCallSignatureDeclaration(n); + case "TsConstructSignatureDeclaration": + return this.visitTsConstructSignatureDeclaration(n); + case "TsPropertySignature": + return this.visitTsPropertySignature(n); + case "TsGetterSignature": + return this.visitTsGetterSignature(n); + case "TsSetterSignature": + return this.visitTsSetterSignature(n); + case "TsMethodSignature": + return this.visitTsMethodSignature(n); + case "TsIndexSignature": + return this.visitTsIndexSignature(n); + } + } + visitTsCallSignatureDeclaration(n) { + n.params = this.visitTsFnParameters(n.params); + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitTsConstructSignatureDeclaration(n) { + n.params = this.visitTsFnParameters(n.params); + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitTsPropertySignature(n) { + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitTsGetterSignature(n) { + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitTsSetterSignature(n) { + n.param = this.visitTsFnParameter(n.param); + return n; + } + visitTsMethodSignature(n) { + n.params = this.visitTsFnParameters(n.params); + n.typeAnn = this.visitTsTypeAnnotation(n.typeAnn); + return n; + } + visitTsEnumDeclaration(n) { + n.id = this.visitIdentifier(n.id); + n.members = this.visitTsEnumMembers(n.members); + return n; + } + visitTsEnumMembers(nodes) { + return nodes.map(this.visitTsEnumMember.bind(this)); + } + visitTsEnumMember(n) { + n.id = this.visitTsEnumMemberId(n.id); + n.init = this.visitOptionalExpression(n.init); + return n; + } + visitTsEnumMemberId(n) { + switch (n.type) { + case "Identifier": + return this.visitBindingIdentifier(n); + case "StringLiteral": + return this.visitStringLiteral(n); + } + } + visitFunctionDeclaration(decl) { + decl.identifier = this.visitIdentifier(decl.identifier); + decl = this.visitFunction(decl); + return decl; + } + visitClassDeclaration(decl) { + decl = this.visitClass(decl); + decl.identifier = this.visitIdentifier(decl.identifier); + return decl; + } + visitClassBody(members) { + return members.map(this.visitClassMember.bind(this)); + } + visitClassMember(member) { + switch (member.type) { + case "ClassMethod": + return this.visitClassMethod(member); + case "ClassProperty": + return this.visitClassProperty(member); + case "Constructor": + return this.visitConstructor(member); + case "PrivateMethod": + return this.visitPrivateMethod(member); + case "PrivateProperty": + return this.visitPrivateProperty(member); + case "TsIndexSignature": + return this.visitTsIndexSignature(member); + case "EmptyStatement": + return this.visitEmptyStatement(member); + case "StaticBlock": + return this.visitStaticBlock(member); + } + } + visitTsIndexSignature(n) { + n.params = this.visitTsFnParameters(n.params); + if (n.typeAnnotation) + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitTsFnParameters(params) { + return params.map(this.visitTsFnParameter.bind(this)); + } + visitTsFnParameter(n) { + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitPrivateProperty(n) { + n.decorators = this.visitDecorators(n.decorators); + n.key = this.visitPrivateName(n.key); + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + n.value = this.visitOptionalExpression(n.value); + return n; + } + visitPrivateMethod(n) { + n.accessibility = this.visitAccessibility(n.accessibility); + n.function = this.visitFunction(n.function); + n.key = this.visitPrivateName(n.key); + return n; + } + visitPrivateName(n) { + return n; + } + visitConstructor(n) { + n.accessibility = this.visitAccessibility(n.accessibility); + n.key = this.visitPropertyName(n.key); + n.params = this.visitConstructorParameters(n.params); + if (n.body) { + n.body = this.visitBlockStatement(n.body); + } + return n; + } + visitConstructorParameters(nodes) { + return nodes.map(this.visitConstructorParameter.bind(this)); + } + visitConstructorParameter(n) { + switch (n.type) { + case "TsParameterProperty": + return this.visitTsParameterProperty(n); + default: + return this.visitParameter(n); + } + } + visitStaticBlock(n) { + n.body = this.visitBlockStatement(n.body); + return n; + } + visitTsParameterProperty(n) { + n.accessibility = this.visitAccessibility(n.accessibility); + n.decorators = this.visitDecorators(n.decorators); + n.param = this.visitTsParameterPropertyParameter(n.param); + return n; + } + visitTsParameterPropertyParameter(n) { + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitPropertyName(key) { + switch (key.type) { + case "Identifier": + return this.visitBindingIdentifier(key); + case "StringLiteral": + return this.visitStringLiteral(key); + case "NumericLiteral": + return this.visitNumericLiteral(key); + case "BigIntLiteral": + return this.visitBigIntLiteral(key); + default: + return this.visitComputedPropertyKey(key); + } + } + visitAccessibility(n) { + return n; + } + visitClassProperty(n) { + n.accessibility = this.visitAccessibility(n.accessibility); + n.decorators = this.visitDecorators(n.decorators); + n.key = this.visitPropertyName(n.key); + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + n.value = this.visitOptionalExpression(n.value); + return n; + } + visitClassMethod(n) { + n.accessibility = this.visitAccessibility(n.accessibility); + n.function = this.visitFunction(n.function); + n.key = this.visitPropertyName(n.key); + return n; + } + visitComputedPropertyKey(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitClass(n) { + n.decorators = this.visitDecorators(n.decorators); + n.superClass = this.visitOptionalExpression(n.superClass); + n.superTypeParams = this.visitTsTypeParameterInstantiation(n.superTypeParams); + if (n.implements) { + n.implements = this.visitTsExpressionsWithTypeArguments(n.implements); + } + n.body = this.visitClassBody(n.body); + return n; + } + visitFunction(n) { + n.decorators = this.visitDecorators(n.decorators); + n.params = this.visitParameters(n.params); + if (n.body) { + n.body = this.visitBlockStatement(n.body); + } + n.returnType = this.visitTsTypeAnnotation(n.returnType); + n.typeParameters = this.visitTsTypeParameterDeclaration(n.typeParameters); + return n; + } + visitTsExpressionsWithTypeArguments(nodes) { + return nodes.map(this.visitTsExpressionWithTypeArguments.bind(this)); + } + visitTsExpressionWithTypeArguments(n) { + n.expression = this.visitExpression(n.expression); + n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments); + return n; + } + visitTsTypeParameterInstantiation(n) { + if (n) { + n.params = this.visitTsTypes(n.params); + } + return n; + } + visitTsTypes(nodes) { + return nodes.map(this.visitTsType.bind(this)); + } + visitTsEntityName(n) { + switch (n.type) { + case "Identifier": + return this.visitBindingIdentifier(n); + case "TsQualifiedName": + return this.visitTsQualifiedName(n); + } + } + visitTsQualifiedName(n) { + n.left = this.visitTsEntityName(n.left); + n.right = this.visitIdentifier(n.right); + return n; + } + visitDecorators(nodes) { + if (nodes) { + return nodes.map(this.visitDecorator.bind(this)); + } + } + visitDecorator(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitExpressionStatement(stmt) { + stmt.expression = this.visitExpression(stmt.expression); + return stmt; + } + visitContinueStatement(stmt) { + if (stmt.label) { + stmt.label = this.visitLabelIdentifier(stmt.label); + } + return stmt; + } + visitExpression(n) { + switch (n.type) { + case "ArrayExpression": + return this.visitArrayExpression(n); + case "ArrowFunctionExpression": + return this.visitArrowFunctionExpression(n); + case "AssignmentExpression": + return this.visitAssignmentExpression(n); + case "AwaitExpression": + return this.visitAwaitExpression(n); + case "BigIntLiteral": + return this.visitBigIntLiteral(n); + case "BinaryExpression": + return this.visitBinaryExpression(n); + case "BooleanLiteral": + return this.visitBooleanLiteral(n); + case "CallExpression": + return this.visitCallExpression(n); + case "ClassExpression": + return this.visitClassExpression(n); + case "ConditionalExpression": + return this.visitConditionalExpression(n); + case "FunctionExpression": + return this.visitFunctionExpression(n); + case "Identifier": + return this.visitIdentifierReference(n); + case "JSXElement": + return this.visitJSXElement(n); + case "JSXEmptyExpression": + return this.visitJSXEmptyExpression(n); + case "JSXFragment": + return this.visitJSXFragment(n); + case "JSXMemberExpression": + return this.visitJSXMemberExpression(n); + case "JSXNamespacedName": + return this.visitJSXNamespacedName(n); + case "JSXText": + return this.visitJSXText(n); + case "MemberExpression": + return this.visitMemberExpression(n); + case "SuperPropExpression": + return this.visitSuperPropExpression(n); + case "MetaProperty": + return this.visitMetaProperty(n); + case "NewExpression": + return this.visitNewExpression(n); + case "NullLiteral": + return this.visitNullLiteral(n); + case "NumericLiteral": + return this.visitNumericLiteral(n); + case "ObjectExpression": + return this.visitObjectExpression(n); + case "ParenthesisExpression": + return this.visitParenthesisExpression(n); + case "PrivateName": + return this.visitPrivateName(n); + case "RegExpLiteral": + return this.visitRegExpLiteral(n); + case "SequenceExpression": + return this.visitSequenceExpression(n); + case "StringLiteral": + return this.visitStringLiteral(n); + case "TaggedTemplateExpression": + return this.visitTaggedTemplateExpression(n); + case "TemplateLiteral": + return this.visitTemplateLiteral(n); + case "ThisExpression": + return this.visitThisExpression(n); + case "TsAsExpression": + return this.visitTsAsExpression(n); + case "TsSatisfiesExpression": + return this.visitTsSatisfiesExpression(n); + case "TsNonNullExpression": + return this.visitTsNonNullExpression(n); + case "TsTypeAssertion": + return this.visitTsTypeAssertion(n); + case "TsConstAssertion": + return this.visitTsConstAssertion(n); + case "TsInstantiation": + return this.visitTsInstantiation(n); + case "UnaryExpression": + return this.visitUnaryExpression(n); + case "UpdateExpression": + return this.visitUpdateExpression(n); + case "YieldExpression": + return this.visitYieldExpression(n); + case "OptionalChainingExpression": + return this.visitOptionalChainingExpression(n); + case "Invalid": + return n; + } + } + visitOptionalChainingExpression(n) { + n.base = this.visitMemberExpressionOrOptionalChainingCall(n.base); + return n; + } + visitMemberExpressionOrOptionalChainingCall(n) { + switch (n.type) { + case "MemberExpression": + return this.visitMemberExpression(n); + case "CallExpression": + return this.visitOptionalChainingCall(n); + } + } + visitOptionalChainingCall(n) { + n.callee = this.visitExpression(n.callee); + n.arguments = this.visitExprOrSpreads(n.arguments); + if (n.typeArguments) + n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments); + return n; + } + visitAssignmentExpression(n) { + n.left = this.visitPatternOrExpression(n.left); + n.right = this.visitExpression(n.right); + return n; + } + visitPatternOrExpression(n) { + switch (n.type) { + case "ObjectPattern": + case "ArrayPattern": + case "Identifier": + case "AssignmentPattern": + case "RestElement": + return this.visitPattern(n); + default: + return this.visitExpression(n); + } + } + visitYieldExpression(n) { + n.argument = this.visitOptionalExpression(n.argument); + return n; + } + visitUpdateExpression(n) { + n.argument = this.visitExpression(n.argument); + return n; + } + visitUnaryExpression(n) { + n.argument = this.visitExpression(n.argument); + return n; + } + visitTsTypeAssertion(n) { + n.expression = this.visitExpression(n.expression); + n.typeAnnotation = this.visitTsType(n.typeAnnotation); + return n; + } + visitTsConstAssertion(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitTsInstantiation(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitTsNonNullExpression(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitTsAsExpression(n) { + n.expression = this.visitExpression(n.expression); + n.typeAnnotation = this.visitTsType(n.typeAnnotation); + return n; + } + visitTsSatisfiesExpression(n) { + n.expression = this.visitExpression(n.expression); + n.typeAnnotation = this.visitTsType(n.typeAnnotation); + return n; + } + visitThisExpression(n) { + return n; + } + visitTemplateLiteral(n) { + n.expressions = n.expressions.map(this.visitExpression.bind(this)); + return n; + } + visitParameters(n) { + return n.map(this.visitParameter.bind(this)); + } + visitParameter(n) { + n.pat = this.visitPattern(n.pat); + return n; + } + visitTaggedTemplateExpression(n) { + n.tag = this.visitExpression(n.tag); + const template = this.visitTemplateLiteral(n.template); + if (template.type === "TemplateLiteral") { + n.template = template; + } + return n; + } + visitSequenceExpression(n) { + n.expressions = n.expressions.map(this.visitExpression.bind(this)); + return n; + } + visitRegExpLiteral(n) { + return n; + } + visitParenthesisExpression(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitObjectExpression(n) { + if (n.properties) { + n.properties = this.visitObjectProperties(n.properties); + } + return n; + } + visitObjectProperties(nodes) { + return nodes.map(this.visitObjectProperty.bind(this)); + } + visitObjectProperty(n) { + switch (n.type) { + case "SpreadElement": + return this.visitSpreadElement(n); + default: + return this.visitProperty(n); + } + } + visitProperty(n) { + switch (n.type) { + case "Identifier": + return this.visitIdentifier(n); + case "AssignmentProperty": + return this.visitAssignmentProperty(n); + case "GetterProperty": + return this.visitGetterProperty(n); + case "KeyValueProperty": + return this.visitKeyValueProperty(n); + case "MethodProperty": + return this.visitMethodProperty(n); + case "SetterProperty": + return this.visitSetterProperty(n); + } + } + visitSetterProperty(n) { + n.key = this.visitPropertyName(n.key); + n.param = this.visitPattern(n.param); + if (n.body) { + n.body = this.visitBlockStatement(n.body); + } + return n; + } + visitMethodProperty(n) { + n.key = this.visitPropertyName(n.key); + if (n.body) { + n.body = this.visitBlockStatement(n.body); + } + n.decorators = this.visitDecorators(n.decorators); + n.params = this.visitParameters(n.params); + n.returnType = this.visitTsTypeAnnotation(n.returnType); + n.typeParameters = this.visitTsTypeParameterDeclaration(n.typeParameters); + return n; + } + visitKeyValueProperty(n) { + n.key = this.visitPropertyName(n.key); + n.value = this.visitExpression(n.value); + return n; + } + visitGetterProperty(n) { + n.key = this.visitPropertyName(n.key); + if (n.body) { + n.body = this.visitBlockStatement(n.body); + } + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitAssignmentProperty(n) { + n.key = this.visitIdentifier(n.key); + n.value = this.visitExpression(n.value); + return n; + } + visitNullLiteral(n) { + return n; + } + visitNewExpression(n) { + n.callee = this.visitExpression(n.callee); + if (n.arguments) { + n.arguments = this.visitArguments(n.arguments); + } + n.typeArguments = this.visitTsTypeArguments(n.typeArguments); + return n; + } + visitTsTypeArguments(n) { + if (n) { + n.params = this.visitTsTypes(n.params); + } + return n; + } + visitArguments(nodes) { + return nodes.map(this.visitArgument.bind(this)); + } + visitArgument(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitMetaProperty(n) { + return n; + } + visitMemberExpression(n) { + n.object = this.visitExpression(n.object); + switch (n.property.type) { + case "Computed": { + n.property = this.visitComputedPropertyKey(n.property); + return n; + } + case "Identifier": { + n.property = this.visitIdentifier(n.property); + return n; + } + case "PrivateName": { + n.property = this.visitPrivateName(n.property); + return n; + } + } + } + visitSuperPropExpression(n) { + switch (n.property.type) { + case "Computed": { + n.property = this.visitComputedPropertyKey(n.property); + return n; + } + case "Identifier": { + n.property = this.visitIdentifier(n.property); + return n; + } + } + } + visitCallee(n) { + if (n.type === "Super" || n.type === "Import") { + return n; + } + return this.visitExpression(n); + } + visitJSXText(n) { + return n; + } + visitJSXNamespacedName(n) { + n.namespace = this.visitIdentifierReference(n.namespace); + n.name = this.visitIdentifierReference(n.name); + return n; + } + visitJSXMemberExpression(n) { + n.object = this.visitJSXObject(n.object); + n.property = this.visitIdentifierReference(n.property); + return n; + } + visitJSXObject(n) { + switch (n.type) { + case "Identifier": + return this.visitIdentifierReference(n); + case "JSXMemberExpression": + return this.visitJSXMemberExpression(n); + } + } + visitJSXFragment(n) { + n.opening = this.visitJSXOpeningFragment(n.opening); + if (n.children) { + n.children = this.visitJSXElementChildren(n.children); + } + n.closing = this.visitJSXClosingFragment(n.closing); + return n; + } + visitJSXClosingFragment(n) { + return n; + } + visitJSXElementChildren(nodes) { + return nodes.map(this.visitJSXElementChild.bind(this)); + } + visitJSXElementChild(n) { + switch (n.type) { + case "JSXElement": + return this.visitJSXElement(n); + case "JSXExpressionContainer": + return this.visitJSXExpressionContainer(n); + case "JSXFragment": + return this.visitJSXFragment(n); + case "JSXSpreadChild": + return this.visitJSXSpreadChild(n); + case "JSXText": + return this.visitJSXText(n); + } + } + visitJSXExpressionContainer(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitJSXSpreadChild(n) { + n.expression = this.visitExpression(n.expression); + return n; + } + visitJSXOpeningFragment(n) { + return n; + } + visitJSXEmptyExpression(n) { + return n; + } + visitJSXElement(n) { + n.opening = this.visitJSXOpeningElement(n.opening); + n.children = this.visitJSXElementChildren(n.children); + n.closing = this.visitJSXClosingElement(n.closing); + return n; + } + visitJSXClosingElement(n) { + if (n) { + n.name = this.visitJSXElementName(n.name); + } + return n; + } + visitJSXElementName(n) { + switch (n.type) { + case "Identifier": + return this.visitIdentifierReference(n); + case "JSXMemberExpression": + return this.visitJSXMemberExpression(n); + case "JSXNamespacedName": + return this.visitJSXNamespacedName(n); + } + } + visitJSXOpeningElement(n) { + n.name = this.visitJSXElementName(n.name); + n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments); + n.attributes = this.visitJSXAttributeOrSpreads(n.attributes); + return n; + } + visitJSXAttributes(attrs) { + if (attrs) + return attrs.map(this.visitJSXAttributeOrSpread.bind(this)); + } + visitJSXAttributeOrSpread(n) { + switch (n.type) { + case "JSXAttribute": + return this.visitJSXAttribute(n); + case "SpreadElement": + return this.visitSpreadElement(n); + } + } + visitJSXAttributeOrSpreads(nodes) { + return nodes.map(this.visitJSXAttributeOrSpread.bind(this)); + } + visitJSXAttribute(n) { + n.name = this.visitJSXAttributeName(n.name); + n.value = this.visitJSXAttributeValue(n.value); + return n; + } + visitJSXAttributeValue(n) { + if (!n) + return n; + switch (n.type) { + case "StringLiteral": + return this.visitStringLiteral(n); + case "JSXElement": + return this.visitJSXElement(n); + case "JSXExpressionContainer": + return this.visitJSXExpressionContainer(n); + case "JSXFragment": + return this.visitJSXFragment(n); + } + return n; + } + visitJSXAttributeName(n) { + switch (n.type) { + case "Identifier": + return this.visitIdentifierReference(n); + case "JSXNamespacedName": + return this.visitJSXNamespacedName(n); + } + } + visitConditionalExpression(n) { + n.test = this.visitExpression(n.test); + n.consequent = this.visitExpression(n.consequent); + n.alternate = this.visitExpression(n.alternate); + return n; + } + visitCallExpression(n) { + n.callee = this.visitCallee(n.callee); + n.typeArguments = this.visitTsTypeParameterInstantiation(n.typeArguments); + if (n.arguments) { + n.arguments = this.visitArguments(n.arguments); + } + return n; + } + visitBooleanLiteral(n) { + return n; + } + visitBinaryExpression(n) { + n.left = this.visitExpression(n.left); + n.right = this.visitExpression(n.right); + return n; + } + visitAwaitExpression(n) { + n.argument = this.visitExpression(n.argument); + return n; + } + visitTsTypeParameterDeclaration(n) { + if (n) { + n.parameters = this.visitTsTypeParameters(n.parameters); + } + return n; + } + visitTsTypeParameters(nodes) { + return nodes.map(this.visitTsTypeParameter.bind(this)); + } + visitTsTypeParameter(n) { + if (n.constraint) { + n.constraint = this.visitTsType(n.constraint); + } + if (n.default) { + n.default = this.visitTsType(n.default); + } + n.name = this.visitIdentifierReference(n.name); + return n; + } + visitTsTypeAnnotation(a) { + if (a) { + a.typeAnnotation = this.visitTsType(a.typeAnnotation); + } + return a; + } + visitTsType(n) { + throw new Error("Method visitTsType not implemented."); + } + visitPatterns(nodes) { + return nodes.map(this.visitPattern.bind(this)); + } + visitImportDeclaration(n) { + n.source = this.visitStringLiteral(n.source); + n.specifiers = this.visitImportSpecifiers(n.specifiers || []); + return n; + } + visitImportSpecifiers(nodes) { + return nodes.map(this.visitImportSpecifier.bind(this)); + } + visitImportSpecifier(node) { + switch (node.type) { + case "ImportDefaultSpecifier": + return this.visitImportDefaultSpecifier(node); + case "ImportNamespaceSpecifier": + return this.visitImportNamespaceSpecifier(node); + case "ImportSpecifier": + return this.visitNamedImportSpecifier(node); + } + } + visitNamedImportSpecifier(node) { + node.local = this.visitBindingIdentifier(node.local); + if (node.imported) { + node.imported = this.visitModuleExportName(node.imported); + } + return node; + } + visitImportNamespaceSpecifier(node) { + node.local = this.visitBindingIdentifier(node.local); + return node; + } + visitImportDefaultSpecifier(node) { + node.local = this.visitBindingIdentifier(node.local); + return node; + } + visitBindingIdentifier(i) { + if (i.typeAnnotation) { + i.typeAnnotation = this.visitTsTypeAnnotation(i.typeAnnotation); + } + return this.visitIdentifier(i); + } + visitIdentifierReference(i) { + return this.visitIdentifier(i); + } + visitLabelIdentifier(label) { + return this.visitIdentifier(label); + } + visitIdentifier(n) { + return n; + } + visitStringLiteral(n) { + return n; + } + visitNumericLiteral(n) { + return n; + } + visitBigIntLiteral(n) { + return n; + } + visitPattern(n) { + switch (n.type) { + case "Identifier": + return this.visitBindingIdentifier(n); + case "ArrayPattern": + return this.visitArrayPattern(n); + case "ObjectPattern": + return this.visitObjectPattern(n); + case "AssignmentPattern": + return this.visitAssignmentPattern(n); + case "RestElement": + return this.visitRestElement(n); + default: + return this.visitExpression(n); + } + } + visitRestElement(n) { + n.argument = this.visitPattern(n.argument); + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitAssignmentPattern(n) { + n.left = this.visitPattern(n.left); + n.right = this.visitExpression(n.right); + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitObjectPattern(n) { + n.properties = this.visitObjectPatternProperties(n.properties || []); + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + return n; + } + visitObjectPatternProperties(nodes) { + return nodes.map(this.visitObjectPatternProperty.bind(this)); + } + visitObjectPatternProperty(n) { + switch (n.type) { + case "AssignmentPatternProperty": + return this.visitAssignmentPatternProperty(n); + case "KeyValuePatternProperty": + return this.visitKeyValuePatternProperty(n); + case "RestElement": + return this.visitRestElement(n); + } + } + visitKeyValuePatternProperty(n) { + n.key = this.visitPropertyName(n.key); + n.value = this.visitPattern(n.value); + return n; + } + visitAssignmentPatternProperty(n) { + n.key = this.visitBindingIdentifier(n.key); + n.value = this.visitOptionalExpression(n.value); + return n; + } + visitArrayPattern(n) { + n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation); + n.elements = this.visitArrayPatternElements(n.elements); + return n; + } + visitArrayPatternElements(nodes) { + return nodes.map(this.visitArrayPatternElement.bind(this)); + } + visitArrayPatternElement(n) { + if (n) { + n = this.visitPattern(n); + } + return n; + } +} +exports.Visitor = Visitor; +exports.default = Visitor; diff --git a/node_modules/@swc/core/binding.d.ts b/node_modules/@swc/core/binding.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..abf62fc271ddab870568d23dfe738bb05fb4d24c --- /dev/null +++ b/node_modules/@swc/core/binding.d.ts @@ -0,0 +1,59 @@ +/* auto-generated by NAPI-RS */ +/* eslint-disable */ + +export class Compiler { + constructor() +} +export type JsCompiler = Compiler + +export declare function analyze(src: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise + +export declare function bundle(confItems: Buffer, signal?: AbortSignal | undefined | null): Promise<{ [index: string]: { code: string, map?: string } }> + +export declare function getTargetTriple(): string + +export declare function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): void + +export declare function minify(code: Buffer, opts: Buffer, isJson: boolean, extras: NapiMinifyExtra, signal?: AbortSignal | undefined | null): Promise + +export declare function minifySync(code: Buffer, opts: Buffer, isJson: boolean, extras: NapiMinifyExtra): TransformOutput + +export interface NapiMinifyExtra { + mangleNameCache?: object +} + +export declare function newMangleNameCache(): object + +export declare function parse(src: Buffer | string, options: Buffer, filename?: string | undefined | null, signal?: AbortSignal | undefined | null): Promise + +export declare function parseFile(path: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise + +export declare function parseFileSync(path: string, opts: Buffer): string + +export declare function parseSync(src: Buffer | string, opts: Buffer, filename?: string | undefined | null): string + +export declare function print(programJson: string, options: Buffer, signal?: AbortSignal | undefined | null): Promise + +export declare function printSync(program: string, options: Buffer): TransformOutput + +export declare function transform(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise + +export declare function transformFile(src: string, isModule: boolean, options: Buffer, signal?: AbortSignal | undefined | null): Promise + +export declare function transformFileSync(s: string, isModule: boolean, opts: Buffer): TransformOutput + +export interface TransformOutput { + code: string + map?: string + output?: string + extractedComments?: Array + diagnostics: Array +} + +/** Hack for `Type Generation` */ +export interface TransformOutput { + code: string + map?: string +} + +export declare function transformSync(s: string, isModule: boolean, opts: Buffer): TransformOutput diff --git a/node_modules/@swc/core/binding.js b/node_modules/@swc/core/binding.js new file mode 100644 index 0000000000000000000000000000000000000000..34cf2801f7a96916dd635ebd013ec15407411a96 --- /dev/null +++ b/node_modules/@swc/core/binding.js @@ -0,0 +1,368 @@ +// prettier-ignore +/* eslint-disable */ +/* auto-generated by NAPI-RS */ + +const { readFileSync } = require('fs') + +let nativeBinding = null +const loadErrors = [] + +const isMusl = () => { + let musl = false + if (process.platform === 'linux') { + musl = isMuslFromFilesystem() + if (musl === null) { + musl = isMuslFromReport() + } + if (musl === null) { + musl = isMuslFromChildProcess() + } + } + return musl +} + +const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-') + +const isMuslFromFilesystem = () => { + try { + return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl') + } catch { + return null + } +} + +const isMuslFromReport = () => { + const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null + if (!report) { + return null + } + if (report.header && report.header.glibcVersionRuntime) { + return false + } + if (Array.isArray(report.sharedObjects)) { + if (report.sharedObjects.some(isFileMusl)) { + return true + } + } + return false +} + +const isMuslFromChildProcess = () => { + try { + return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl') + } catch (e) { + // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false + return false + } +} + +function requireNative() { + if (process.platform === 'android') { + if (process.arch === 'arm64') { + try { + return require('./swc.android-arm64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-android-arm64') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'arm') { + try { + return require('./swc.android-arm-eabi.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-android-arm-eabi') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`)) + } + } else if (process.platform === 'win32') { + if (process.arch === 'x64') { + try { + return require('./swc.win32-x64-msvc.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-win32-x64-msvc') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'ia32') { + try { + return require('./swc.win32-ia32-msvc.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-win32-ia32-msvc') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'arm64') { + try { + return require('./swc.win32-arm64-msvc.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-win32-arm64-msvc') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`)) + } + } else if (process.platform === 'darwin') { + try { + return require('./swc.darwin-universal.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-darwin-universal') + } catch (e) { + loadErrors.push(e) + } + + if (process.arch === 'x64') { + try { + return require('./swc.darwin-x64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-darwin-x64') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'arm64') { + try { + return require('./swc.darwin-arm64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-darwin-arm64') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`)) + } + } else if (process.platform === 'freebsd') { + if (process.arch === 'x64') { + try { + return require('./swc.freebsd-x64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-freebsd-x64') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'arm64') { + try { + return require('./swc.freebsd-arm64.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-freebsd-arm64') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`)) + } + } else if (process.platform === 'linux') { + if (process.arch === 'x64') { + if (isMusl()) { + try { + return require('./swc.linux-x64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-x64-musl') + } catch (e) { + loadErrors.push(e) + } + + } else { + try { + return require('./swc.linux-x64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-x64-gnu') + } catch (e) { + loadErrors.push(e) + } + + } + } else if (process.arch === 'arm64') { + if (isMusl()) { + try { + return require('./swc.linux-arm64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-arm64-musl') + } catch (e) { + loadErrors.push(e) + } + + } else { + try { + return require('./swc.linux-arm64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-arm64-gnu') + } catch (e) { + loadErrors.push(e) + } + + } + } else if (process.arch === 'arm') { + try { + return require('./swc.linux-arm-gnueabihf.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-arm-gnueabihf') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 'riscv64') { + if (isMusl()) { + try { + return require('./swc.linux-riscv64-musl.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-riscv64-musl') + } catch (e) { + loadErrors.push(e) + } + + } else { + try { + return require('./swc.linux-riscv64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-riscv64-gnu') + } catch (e) { + loadErrors.push(e) + } + + } + } else if (process.arch === 'ppc64') { + try { + return require('./swc.linux-ppc64-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-ppc64-gnu') + } catch (e) { + loadErrors.push(e) + } + + } else if (process.arch === 's390x') { + try { + return require('./swc.linux-s390x-gnu.node') + } catch (e) { + loadErrors.push(e) + } + try { + return require('@swc/core-linux-s390x-gnu') + } catch (e) { + loadErrors.push(e) + } + + } else { + loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`)) + } + } else { + loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`)) + } +} + +nativeBinding = requireNative() + +if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) { + try { + nativeBinding = require('./swc.wasi.cjs') + } catch (err) { + if (process.env.NAPI_RS_FORCE_WASI) { + console.error(err) + } + } + if (!nativeBinding) { + try { + nativeBinding = require('@swc/core-wasm32-wasi') + } catch (err) { + if (process.env.NAPI_RS_FORCE_WASI) { + console.error(err) + } + } + } +} + +if (!nativeBinding) { + if (loadErrors.length > 0) { + // TODO Link to documentation with potential fixes + // - The package owner could build/publish bindings for this arch + // - The user may need to bundle the correct files + // - The user may need to re-install node_modules to get new packages + throw new Error('Failed to load native binding', { cause: loadErrors }) + } + throw new Error(`Failed to load native binding`) +} + +module.exports.Compiler = nativeBinding.Compiler +module.exports.JsCompiler = nativeBinding.JsCompiler +module.exports.analyze = nativeBinding.analyze +module.exports.bundle = nativeBinding.bundle +module.exports.getTargetTriple = nativeBinding.getTargetTriple +module.exports.initCustomTraceSubscriber = nativeBinding.initCustomTraceSubscriber +module.exports.minify = nativeBinding.minify +module.exports.minifySync = nativeBinding.minifySync +module.exports.newMangleNameCache = nativeBinding.newMangleNameCache +module.exports.parse = nativeBinding.parse +module.exports.parseFile = nativeBinding.parseFile +module.exports.parseFileSync = nativeBinding.parseFileSync +module.exports.parseSync = nativeBinding.parseSync +module.exports.print = nativeBinding.print +module.exports.printSync = nativeBinding.printSync +module.exports.transform = nativeBinding.transform +module.exports.transformFile = nativeBinding.transformFile +module.exports.transformFileSync = nativeBinding.transformFileSync +module.exports.transformSync = nativeBinding.transformSync diff --git a/node_modules/@swc/core/index.d.ts b/node_modules/@swc/core/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..baa63b753ee128d8d0b70549c6f57cb1d02336db --- /dev/null +++ b/node_modules/@swc/core/index.d.ts @@ -0,0 +1,119 @@ +import type { Plugin, ParseOptions, Module, Output, Options, Script, Program, JsMinifyOptions, WasmAnalysisOptions } from "@swc/types"; +export type * from "@swc/types"; +export { newMangleNameCache as experimental_newMangleNameCache } from "./binding"; +import { BundleInput } from "./spack"; +import type { NapiMinifyExtra } from "./binding"; +/** + * Version of the swc binding. + */ +export declare const version: string; +/** + * @deprecated JavaScript API is deprecated. Please use Wasm plugin instead. + */ +export declare function plugins(ps: Plugin[]): Plugin; +export declare class Compiler { + private fallbackBindingsPluginWarningDisplayed; + minify(src: string | Buffer, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Promise; + minifySync(src: string | Buffer, opts?: JsMinifyOptions, extras?: NapiMinifyExtra): Output; + /** + * @deprecated Use Rust instead. + */ + parse(src: string, options: ParseOptions & { + isModule: false; + }): Promise or