@simplewebauthn/server 13.3.3 → 14.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -4
- package/esm/authentication/generateAuthenticationOptions.d.ts +2 -2
- package/esm/authentication/generateAuthenticationOptions.d.ts.map +1 -1
- package/esm/authentication/verifyAuthenticationResponse.d.ts +1 -0
- package/esm/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/esm/authentication/verifyAuthenticationResponse.js +52 -2
- package/esm/errors/index.d.ts +17 -0
- package/esm/errors/index.d.ts.map +1 -0
- package/esm/errors/index.js +24 -0
- package/esm/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
- package/esm/helpers/convertX509PublicKeyToCOSE.d.ts.map +1 -1
- package/esm/helpers/convertX509PublicKeyToCOSE.js +22 -6
- package/esm/helpers/cose.d.ts +19 -2
- package/esm/helpers/cose.d.ts.map +1 -1
- package/esm/helpers/cose.js +15 -0
- package/esm/helpers/decodeClientDataJSON.d.ts +1 -0
- package/esm/helpers/decodeClientDataJSON.d.ts.map +1 -1
- package/esm/helpers/index.d.ts +2 -0
- package/esm/helpers/index.d.ts.map +1 -1
- package/esm/helpers/index.js +2 -0
- package/esm/helpers/isCertRevoked.d.ts +1 -0
- package/esm/helpers/isCertRevoked.d.ts.map +1 -1
- package/esm/helpers/isCertRevoked.js +1 -0
- package/esm/helpers/iso/isoCrypto/digest.js +2 -2
- package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/getWebCrypto.js +12 -0
- package/esm/helpers/iso/isoCrypto/importJWKKey.d.ts +9 -0
- package/esm/helpers/iso/isoCrypto/importJWKKey.d.ts.map +1 -0
- package/esm/helpers/iso/isoCrypto/{importKey.js → importJWKKey.js} +6 -4
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.d.ts +10 -0
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.d.ts.map +1 -0
- package/esm/helpers/iso/isoCrypto/{mapCoseAlgToWebCryptoAlg.js → mapCoseAlgToWebCryptoHashAlgName.js} +6 -3
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +4 -1
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +15 -0
- package/esm/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.d.ts +7 -0
- package/esm/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.d.ts.map +1 -0
- package/esm/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.js +16 -0
- package/esm/helpers/iso/isoCrypto/structs.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/structs.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verify.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verify.js +5 -1
- package/esm/helpers/iso/isoCrypto/verifyAKP.d.ts +9 -0
- package/esm/helpers/iso/isoCrypto/verifyAKP.d.ts.map +1 -0
- package/esm/helpers/iso/isoCrypto/verifyAKP.js +48 -0
- package/esm/helpers/iso/isoCrypto/verifyEC2.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verifyEC2.js +5 -8
- package/esm/helpers/iso/isoCrypto/verifyOKP.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verifyOKP.js +2 -5
- package/esm/helpers/iso/isoCrypto/verifyRSA.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/verifyRSA.js +5 -8
- package/esm/helpers/logging.d.ts +28 -10
- package/esm/helpers/logging.d.ts.map +1 -1
- package/esm/helpers/logging.js +27 -16
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +0 -3
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map +1 -1
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.js +19 -10
- package/esm/helpers/validateCertificatePath.d.ts +1 -0
- package/esm/helpers/validateCertificatePath.d.ts.map +1 -1
- package/esm/helpers/validateCertificatePath.js +26 -7
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/registration/generateRegistrationOptions.d.ts +10 -8
- package/esm/registration/generateRegistrationOptions.d.ts.map +1 -1
- package/esm/registration/generateRegistrationOptions.js +11 -29
- package/esm/registration/verifications/tpm/constants.d.ts +1 -2
- package/esm/registration/verifications/tpm/constants.d.ts.map +1 -1
- package/esm/registration/verifications/tpm/constants.js +1 -2
- package/esm/registration/verifications/tpm/isValidTPMManufacturerID.d.ts +3 -0
- package/esm/registration/verifications/tpm/isValidTPMManufacturerID.d.ts.map +1 -0
- package/esm/registration/verifications/tpm/isValidTPMManufacturerID.js +6 -0
- package/esm/registration/verifications/tpm/verifyAttestationTPM.d.ts.map +1 -1
- package/esm/registration/verifications/tpm/verifyAttestationTPM.js +3 -2
- package/esm/registration/verifications/verifyAttestationPacked.js +1 -1
- package/esm/registration/verifyRegistrationResponse.d.ts +3 -3
- package/esm/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/esm/registration/verifyRegistrationResponse.js +22 -11
- package/esm/services/metadataService.d.ts +4 -0
- package/esm/services/metadataService.d.ts.map +1 -1
- package/esm/services/metadataService.js +16 -10
- package/esm/services/settingsService.d.ts +4 -0
- package/esm/services/settingsService.d.ts.map +1 -1
- package/esm/services/settingsService.js +12 -0
- package/esm/types/dom.d.ts +236 -3
- package/esm/types/dom.d.ts.map +1 -1
- package/esm/types/index.d.ts +158 -44
- package/esm/types/index.d.ts.map +1 -1
- package/package.json +4 -2
- package/script/authentication/generateAuthenticationOptions.d.ts +2 -2
- package/script/authentication/generateAuthenticationOptions.d.ts.map +1 -1
- package/script/authentication/verifyAuthenticationResponse.d.ts +1 -0
- package/script/authentication/verifyAuthenticationResponse.d.ts.map +1 -1
- package/script/authentication/verifyAuthenticationResponse.js +52 -2
- package/script/errors/index.d.ts +17 -0
- package/script/errors/index.d.ts.map +1 -0
- package/script/errors/index.js +29 -0
- package/script/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
- package/script/helpers/convertX509PublicKeyToCOSE.d.ts.map +1 -1
- package/script/helpers/convertX509PublicKeyToCOSE.js +21 -5
- package/script/helpers/cose.d.ts +19 -2
- package/script/helpers/cose.d.ts.map +1 -1
- package/script/helpers/cose.js +17 -0
- package/script/helpers/decodeClientDataJSON.d.ts +1 -0
- package/script/helpers/decodeClientDataJSON.d.ts.map +1 -1
- package/script/helpers/index.d.ts +2 -0
- package/script/helpers/index.d.ts.map +1 -1
- package/script/helpers/index.js +4 -1
- package/script/helpers/isCertRevoked.d.ts +1 -0
- package/script/helpers/isCertRevoked.d.ts.map +1 -1
- package/script/helpers/isCertRevoked.js +1 -0
- package/script/helpers/iso/isoCrypto/digest.js +2 -2
- package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/getWebCrypto.js +12 -0
- package/script/helpers/iso/isoCrypto/importJWKKey.d.ts +9 -0
- package/script/helpers/iso/isoCrypto/importJWKKey.d.ts.map +1 -0
- package/script/helpers/iso/isoCrypto/{importKey.js → importJWKKey.js} +7 -5
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.d.ts +10 -0
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.d.ts.map +1 -0
- package/script/helpers/iso/isoCrypto/{mapCoseAlgToWebCryptoAlg.js → mapCoseAlgToWebCryptoHashAlgName.js} +7 -4
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +4 -1
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +15 -0
- package/script/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.d.ts +7 -0
- package/script/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.d.ts.map +1 -0
- package/script/helpers/iso/isoCrypto/runtimeSupportsWebCryptoKeyAlg.js +19 -0
- package/script/helpers/iso/isoCrypto/structs.d.ts +1 -1
- package/script/helpers/iso/isoCrypto/structs.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verify.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verify.js +4 -0
- package/script/helpers/iso/isoCrypto/verifyAKP.d.ts +9 -0
- package/script/helpers/iso/isoCrypto/verifyAKP.d.ts.map +1 -0
- package/script/helpers/iso/isoCrypto/verifyAKP.js +51 -0
- package/script/helpers/iso/isoCrypto/verifyEC2.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verifyEC2.js +5 -8
- package/script/helpers/iso/isoCrypto/verifyOKP.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verifyOKP.js +2 -5
- package/script/helpers/iso/isoCrypto/verifyRSA.d.ts.map +1 -1
- package/script/helpers/iso/isoCrypto/verifyRSA.js +5 -8
- package/script/helpers/logging.d.ts +28 -10
- package/script/helpers/logging.d.ts.map +1 -1
- package/script/helpers/logging.js +29 -17
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +0 -3
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts.map +1 -1
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.js +19 -10
- package/script/helpers/validateCertificatePath.d.ts +1 -0
- package/script/helpers/validateCertificatePath.d.ts.map +1 -1
- package/script/helpers/validateCertificatePath.js +26 -7
- package/script/index.d.ts +1 -0
- package/script/index.d.ts.map +1 -1
- package/script/index.js +1 -0
- package/script/registration/generateRegistrationOptions.d.ts +10 -8
- package/script/registration/generateRegistrationOptions.d.ts.map +1 -1
- package/script/registration/generateRegistrationOptions.js +13 -31
- package/script/registration/verifications/tpm/constants.d.ts +1 -2
- package/script/registration/verifications/tpm/constants.d.ts.map +1 -1
- package/script/registration/verifications/tpm/constants.js +1 -2
- package/script/registration/verifications/tpm/isValidTPMManufacturerID.d.ts +3 -0
- package/script/registration/verifications/tpm/isValidTPMManufacturerID.d.ts.map +1 -0
- package/script/registration/verifications/tpm/isValidTPMManufacturerID.js +9 -0
- package/script/registration/verifications/tpm/verifyAttestationTPM.d.ts.map +1 -1
- package/script/registration/verifications/tpm/verifyAttestationTPM.js +2 -1
- package/script/registration/verifications/verifyAttestationPacked.js +1 -1
- package/script/registration/verifyRegistrationResponse.d.ts +3 -3
- package/script/registration/verifyRegistrationResponse.d.ts.map +1 -1
- package/script/registration/verifyRegistrationResponse.js +24 -13
- package/script/services/metadataService.d.ts +4 -0
- package/script/services/metadataService.d.ts.map +1 -1
- package/script/services/metadataService.js +15 -9
- package/script/services/settingsService.d.ts +4 -0
- package/script/services/settingsService.d.ts.map +1 -1
- package/script/services/settingsService.js +12 -0
- package/script/types/dom.d.ts +236 -3
- package/script/types/dom.d.ts.map +1 -1
- package/script/types/index.d.ts +158 -44
- package/script/types/index.d.ts.map +1 -1
- package/esm/helpers/iso/isoCrypto/importKey.d.ts +0 -5
- package/esm/helpers/iso/isoCrypto/importKey.d.ts.map +0 -1
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +0 -7
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts.map +0 -1
- package/script/helpers/iso/isoCrypto/importKey.d.ts +0 -5
- package/script/helpers/iso/isoCrypto/importKey.d.ts.map +0 -1
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +0 -7
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
[](https://jsr.io/@simplewebauthn/server)
|
|
6
6
|
|
|
7
7
|
- [Installation](#installation)
|
|
8
|
-
- [Node LTS
|
|
9
|
-
- [Deno
|
|
8
|
+
- [Node LTS 22.x and higher](#node-lts-22x-and-higher)
|
|
9
|
+
- [Deno v2.4.x and higher](#deno-v24x-and-higher)
|
|
10
10
|
- [Documentation](#documentation)
|
|
11
11
|
- [Supported Attestation Formats](#supported-attestation-formats)
|
|
12
12
|
|
|
@@ -15,18 +15,22 @@
|
|
|
15
15
|
This package can be installed from **[NPM](https://www.npmjs.com/package/@simplewebauthn/server)**
|
|
16
16
|
and **[JSR](https://jsr.io/@simplewebauthn/server)**:
|
|
17
17
|
|
|
18
|
-
### Node LTS
|
|
18
|
+
### Node LTS 22.x and higher
|
|
19
19
|
|
|
20
20
|
```sh
|
|
21
21
|
npm install @simplewebauthn/server
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
> NOTE: This project will aim to support Node LTS releases through their Active and Maintenance windows as tracked on [the Node.js Releases page](https://nodejs.org/en/about/previous-releases).
|
|
25
|
+
|
|
26
|
+
### Deno v2.4.x and higher
|
|
25
27
|
|
|
26
28
|
```sh
|
|
27
29
|
deno add jsr:@simplewebauthn/server
|
|
28
30
|
```
|
|
29
31
|
|
|
32
|
+
> NOTE: [Deno no longer has LTS releases to track after April 30, 2026](https://docs.deno.com/runtime/fundamentals/stability_and_releases/#long-term-support-(lts)). This project will aim to support Deno minor releases for up to one year after their release.
|
|
33
|
+
|
|
30
34
|
## Documentation
|
|
31
35
|
|
|
32
36
|
You can find in-depth documentation on this package here:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthenticationExtensionsClientInputs,
|
|
1
|
+
import type { AuthenticationExtensionsClientInputs, Base64URLString, PublicKeyCredentialRequestOptionsJSON, Uint8Array_ } from '../types/index.js';
|
|
2
2
|
export type GenerateAuthenticationOptionsOpts = Parameters<typeof generateAuthenticationOptions>[0];
|
|
3
3
|
/**
|
|
4
4
|
* Prepare a value to pass into navigator.credentials.get(...) for authenticator authentication
|
|
@@ -16,7 +16,7 @@ export declare function generateAuthenticationOptions(options: {
|
|
|
16
16
|
rpID: string;
|
|
17
17
|
allowCredentials?: {
|
|
18
18
|
id: Base64URLString;
|
|
19
|
-
transports?:
|
|
19
|
+
transports?: string[];
|
|
20
20
|
}[];
|
|
21
21
|
challenge?: string | Uint8Array_;
|
|
22
22
|
timeout?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateAuthenticationOptions.d.ts","sourceRoot":"","sources":["../../src/authentication/generateAuthenticationOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,
|
|
1
|
+
{"version":3,"file":"generateAuthenticationOptions.d.ts","sourceRoot":"","sources":["../../src/authentication/generateAuthenticationOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,eAAe,EACf,qCAAqC,EACrC,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAI3B,MAAM,MAAM,iCAAiC,GAAG,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAC;AAEpG;;;;;;;;;;;GAWG;AACH,wBAAsB,6BAA6B,CACjD,OAAO,EAAE;IACP,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE;QACjB,EAAE,EAAE,eAAe,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,EAAE,CAAC;IACJ,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,UAAU,GAAG,WAAW,GAAG,aAAa,CAAC;IAC5D,UAAU,CAAC,EAAE,oCAAoC,CAAC;CACnD,GACA,OAAO,CAAC,qCAAqC,CAAC,CAoChD"}
|
|
@@ -26,6 +26,7 @@ export declare function verifyAuthenticationResponse(options: {
|
|
|
26
26
|
expectedRPID: string | string[];
|
|
27
27
|
credential: WebAuthnCredential;
|
|
28
28
|
expectedType?: string | string[];
|
|
29
|
+
expectedTopOrigin?: string | string[];
|
|
29
30
|
requireUserVerification?: boolean;
|
|
30
31
|
advancedFIDOConfig?: {
|
|
31
32
|
userVerification?: UserVerificationRequirement;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifyAuthenticationResponse.d.ts","sourceRoot":"","sources":["../../src/authentication/verifyAuthenticationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;
|
|
1
|
+
{"version":3,"file":"verifyAuthenticationResponse.d.ts","sourceRoot":"","sources":["../../src/authentication/verifyAuthenticationResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,eAAe,EACf,oBAAoB,EACpB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,KAAK,EAAE,4CAA4C,EAAE,MAAM,6CAA6C,CAAC;AAQhH;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG,UAAU,CAAC,OAAO,4BAA4B,CAAC,CAAC,CAAC,CAAC,CAAC;AAElG;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE;IACP,QAAQ,EAAE,0BAA0B,CAAC;IACrC,iBAAiB,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAChF,cAAc,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAChC,UAAU,EAAE,kBAAkB,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACjC,iBAAiB,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE;QACnB,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;KAChD,CAAC;CACH,GACA,OAAO,CAAC,8BAA8B,CAAC,CA6QzC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE;QAClB,YAAY,EAAE,eAAe,CAAC;QAC9B,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,OAAO,CAAC;QACtB,oBAAoB,EAAE,oBAAoB,CAAC;QAC3C,kBAAkB,EAAE,OAAO,CAAC;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,6BAA6B,CAAC,EAAE,4CAA4C,CAAC;KAC9E,CAAC;CACH,CAAC"}
|
|
@@ -5,6 +5,10 @@ import { parseAuthenticatorData } from '../helpers/parseAuthenticatorData.js';
|
|
|
5
5
|
import { parseBackupFlags } from '../helpers/parseBackupFlags.js';
|
|
6
6
|
import { matchExpectedRPID } from '../helpers/matchExpectedRPID.js';
|
|
7
7
|
import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.js';
|
|
8
|
+
import { decodeCredentialPublicKey } from '../helpers/decodeCredentialPublicKey.js';
|
|
9
|
+
import { COSEKEYS, isPQCCOSEAlg } from '../helpers/cose.js';
|
|
10
|
+
import { SettingsService } from '../services/settingsService.js';
|
|
11
|
+
import { PQCNotSupportedError } from '../errors/index.js';
|
|
8
12
|
/**
|
|
9
13
|
* Verify that the user has legitimately completed the authentication process
|
|
10
14
|
*
|
|
@@ -21,7 +25,7 @@ import { isoBase64URL, isoUint8Array } from '../helpers/iso/index.js';
|
|
|
21
25
|
* @param advancedFIDOConfig.userVerification **(Optional)** - Enable alternative rules for evaluating the User Presence and User Verified flags in authenticator data: UV (and UP) flags are optional unless this value is `"required"`
|
|
22
26
|
*/
|
|
23
27
|
export async function verifyAuthenticationResponse(options) {
|
|
24
|
-
const { response, expectedChallenge, expectedOrigin, expectedRPID, expectedType, credential, requireUserVerification = true, advancedFIDOConfig, } = options;
|
|
28
|
+
const { response, expectedChallenge, expectedOrigin, expectedRPID, expectedType, expectedTopOrigin, credential, requireUserVerification = true, advancedFIDOConfig, } = options;
|
|
25
29
|
const { id, rawId, type: credentialType, response: assertionResponse } = response;
|
|
26
30
|
// Ensure credential specified an ID
|
|
27
31
|
if (!id) {
|
|
@@ -42,7 +46,7 @@ export async function verifyAuthenticationResponse(options) {
|
|
|
42
46
|
throw new Error('Credential response clientDataJSON was not a string');
|
|
43
47
|
}
|
|
44
48
|
const clientDataJSON = decodeClientDataJSON(assertionResponse.clientDataJSON);
|
|
45
|
-
const { type, origin, challenge, tokenBinding } = clientDataJSON;
|
|
49
|
+
const { type, origin, challenge, tokenBinding, crossOrigin, topOrigin } = clientDataJSON;
|
|
46
50
|
// Make sure we're handling an authentication
|
|
47
51
|
if (Array.isArray(expectedType)) {
|
|
48
52
|
if (!expectedType.includes(type)) {
|
|
@@ -67,6 +71,44 @@ export async function verifyAuthenticationResponse(options) {
|
|
|
67
71
|
else if (challenge !== expectedChallenge) {
|
|
68
72
|
throw new Error(`Unexpected authentication response challenge "${challenge}", expected "${expectedChallenge}"`);
|
|
69
73
|
}
|
|
74
|
+
// Check that the authentication response is within an expected iframe
|
|
75
|
+
if (crossOrigin) {
|
|
76
|
+
/**
|
|
77
|
+
* TODO: Since Safari doesn't support `topOrigin` as of May 2026, only check this when
|
|
78
|
+
* `topOrigin` is available for now.
|
|
79
|
+
*/
|
|
80
|
+
if (topOrigin) {
|
|
81
|
+
if (!expectedTopOrigin) {
|
|
82
|
+
/**
|
|
83
|
+
* If `expectedTopOrigin` is not set, this should be considered an unexpected cross-origin
|
|
84
|
+
* request. Reject the response while helping the RP understand how they need to update this
|
|
85
|
+
* method call if they want to support verification of such WebAuthn authentication requests.
|
|
86
|
+
*/
|
|
87
|
+
throw new Error(`Detected cross-origin authentication response from top origin of "${topOrigin}", but a value for \`expectedTopOrigin\` was not specified when calling \`verifyAuthenticationResponse()\``);
|
|
88
|
+
}
|
|
89
|
+
if (Array.isArray(expectedTopOrigin)) {
|
|
90
|
+
if (!expectedTopOrigin.includes(topOrigin)) {
|
|
91
|
+
const joinedExpectedTopOrigin = expectedTopOrigin.join(', ');
|
|
92
|
+
throw new Error(`Unexpected cross-origin authentication response top origin of "${topOrigin}", expected one of: ${joinedExpectedTopOrigin}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (topOrigin !== expectedTopOrigin) {
|
|
97
|
+
throw new Error(`Unexpected cross-origin authentication response top origin of "${topOrigin}", expected: ${expectedTopOrigin}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (topOrigin) {
|
|
104
|
+
/**
|
|
105
|
+
* If `topOrigin` is set despite `crossOrigin` being false, this is an unexpected request.
|
|
106
|
+
*
|
|
107
|
+
* See https://w3c.github.io/webauthn/#dom-collectedclientdata-toporigin.
|
|
108
|
+
*/
|
|
109
|
+
throw new Error(`Unexpected top origin of "${topOrigin}" within a non-cross-origin authentication response. This error should be reported to the browser vendor as a WebAuthn specification violation with a link to https://w3c.github.io/webauthn/#dom-collectedclientdata-toporigin`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
70
112
|
// Check that the origin is our site
|
|
71
113
|
if (Array.isArray(expectedOrigin)) {
|
|
72
114
|
if (!expectedOrigin.includes(origin)) {
|
|
@@ -149,6 +191,14 @@ export async function verifyAuthenticationResponse(options) {
|
|
|
149
191
|
// on the device without going through this site
|
|
150
192
|
throw new Error(`Response counter value ${counter} was lower than expected ${credential.counter}`);
|
|
151
193
|
}
|
|
194
|
+
const decodedPublicKey = decodeCredentialPublicKey(credential.publicKey);
|
|
195
|
+
const pubKeyAlg = decodedPublicKey.get(COSEKEYS.alg);
|
|
196
|
+
if (typeof pubKeyAlg !== 'number') {
|
|
197
|
+
throw new Error('Credential public key was missing numeric alg');
|
|
198
|
+
}
|
|
199
|
+
if (isPQCCOSEAlg(pubKeyAlg) && !SettingsService.runtimeSupportsPQC()) {
|
|
200
|
+
throw new PQCNotSupportedError(pubKeyAlg);
|
|
201
|
+
}
|
|
152
202
|
const { credentialDeviceType, credentialBackedUp } = parseBackupFlags(flags);
|
|
153
203
|
const toReturn = {
|
|
154
204
|
verified: await verifySignature({
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { COSEALG } from '../helpers/cose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base error class that helps disambiguate SimpleWebAuthn library errors from other library errors
|
|
4
|
+
*/
|
|
5
|
+
export declare class SimpleWebAuthnError extends Error {
|
|
6
|
+
code: SimpleWebAuthnErrorCode;
|
|
7
|
+
constructor({ message, code, cause }: {
|
|
8
|
+
message: string;
|
|
9
|
+
code: SimpleWebAuthnErrorCode;
|
|
10
|
+
cause?: Error;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export declare class PQCNotSupportedError extends SimpleWebAuthnError {
|
|
14
|
+
constructor(alg: COSEALG);
|
|
15
|
+
}
|
|
16
|
+
export type SimpleWebAuthnErrorCode = 'RUNTIME_NO_PQC_SUPPORT';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAGlD;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,IAAI,EAAE,uBAAuB,CAAC;gBAElB,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACpC,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,uBAAuB,CAAC;QAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;KACf;CAKF;AAED,qBAAa,oBAAqB,SAAQ,mBAAmB;gBAC/C,GAAG,EAAE,OAAO;CAKzB;AAED,MAAM,MAAM,uBAAuB,GAAG,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mapCoseAlgToWebCryptoKeyAlgName } from '../helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base error class that helps disambiguate SimpleWebAuthn library errors from other library errors
|
|
4
|
+
*/
|
|
5
|
+
export class SimpleWebAuthnError extends Error {
|
|
6
|
+
constructor({ message, code, cause }) {
|
|
7
|
+
super(message, { cause });
|
|
8
|
+
Object.defineProperty(this, "code", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
configurable: true,
|
|
11
|
+
writable: true,
|
|
12
|
+
value: void 0
|
|
13
|
+
});
|
|
14
|
+
this.name = 'SimpleWebAuthnError';
|
|
15
|
+
this.code = code;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export class PQCNotSupportedError extends SimpleWebAuthnError {
|
|
19
|
+
constructor(alg) {
|
|
20
|
+
const webCryptoAlg = mapCoseAlgToWebCryptoKeyAlgName(alg);
|
|
21
|
+
const message = `This runtime's WebCrypto.subtle does not support use of ${webCryptoAlg}`;
|
|
22
|
+
super({ message, code: 'RUNTIME_NO_PQC_SUPPORT' });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COSEPublicKey } from './cose.js';
|
|
1
|
+
import { type COSEPublicKey } from './cose.js';
|
|
2
2
|
import type { Uint8Array_ } from '../types/index.js';
|
|
3
3
|
export declare function convertX509PublicKeyToCOSE(x509Certificate: Uint8Array_): COSEPublicKey;
|
|
4
4
|
//# sourceMappingURL=convertX509PublicKeyToCOSE.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convertX509PublicKeyToCOSE.d.ts","sourceRoot":"","sources":["../../src/helpers/convertX509PublicKeyToCOSE.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"convertX509PublicKeyToCOSE.d.ts","sourceRoot":"","sources":["../../src/helpers/convertX509PublicKeyToCOSE.ts"],"names":[],"mappings":"AAMA,OAAO,EAKL,KAAK,aAAa,EAInB,MAAM,WAAW,CAAC;AAEnB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAgB,0BAA0B,CACxC,eAAe,EAAE,WAAW,GAC3B,aAAa,CAsGf"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { AsnParser } from '@peculiar/asn1-schema';
|
|
2
2
|
import { Certificate } from '@peculiar/asn1-x509';
|
|
3
3
|
import { ECParameters, id_ecPublicKey, id_secp256r1, id_secp384r1 } from '@peculiar/asn1-ecc';
|
|
4
|
+
import { id_ml_dsa_44, id_ml_dsa_65, id_ml_dsa_87 } from '@peculiar/asn1-x509-post-quantum';
|
|
4
5
|
import { id_rsaEncryption, RSAPublicKey } from '@peculiar/asn1-rsa';
|
|
5
|
-
import { COSECRV, COSEKEYS, COSEKTY, } from './cose.js';
|
|
6
|
+
import { COSEALG, COSECRV, COSEKEYS, COSEKTY, } from './cose.js';
|
|
6
7
|
import { mapX509SignatureAlgToCOSEAlg } from './mapX509SignatureAlgToCOSEAlg.js';
|
|
7
8
|
export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
8
9
|
let cosePublicKey = new Map();
|
|
@@ -11,8 +12,7 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
11
12
|
*/
|
|
12
13
|
const x509 = AsnParser.parse(x509Certificate, Certificate);
|
|
13
14
|
const { tbsCertificate } = x509;
|
|
14
|
-
const { subjectPublicKeyInfo
|
|
15
|
-
const signatureAlgorithm = _tbsSignature.algorithm;
|
|
15
|
+
const { subjectPublicKeyInfo } = tbsCertificate;
|
|
16
16
|
const publicKeyAlgorithmID = subjectPublicKeyInfo.algorithm.algorithm;
|
|
17
17
|
if (publicKeyAlgorithmID === id_ecPublicKey) {
|
|
18
18
|
/**
|
|
@@ -22,12 +22,15 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
22
22
|
throw new Error('Certificate public key was missing parameters (EC2)');
|
|
23
23
|
}
|
|
24
24
|
const ecParameters = AsnParser.parse(new Uint8Array(subjectPublicKeyInfo.algorithm.parameters), ECParameters);
|
|
25
|
-
let
|
|
25
|
+
let alg;
|
|
26
|
+
let crv;
|
|
26
27
|
const { namedCurve } = ecParameters;
|
|
27
28
|
if (namedCurve === id_secp256r1) {
|
|
29
|
+
alg = COSEALG.ES256;
|
|
28
30
|
crv = COSECRV.P256;
|
|
29
31
|
}
|
|
30
32
|
else if (namedCurve === id_secp384r1) {
|
|
33
|
+
alg = COSEALG.ES384;
|
|
31
34
|
crv = COSECRV.P384;
|
|
32
35
|
}
|
|
33
36
|
else {
|
|
@@ -48,7 +51,7 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
48
51
|
}
|
|
49
52
|
const coseEC2PubKey = new Map();
|
|
50
53
|
coseEC2PubKey.set(COSEKEYS.kty, COSEKTY.EC2);
|
|
51
|
-
coseEC2PubKey.set(COSEKEYS.alg,
|
|
54
|
+
coseEC2PubKey.set(COSEKEYS.alg, alg);
|
|
52
55
|
coseEC2PubKey.set(COSEKEYS.crv, crv);
|
|
53
56
|
coseEC2PubKey.set(COSEKEYS.x, x);
|
|
54
57
|
coseEC2PubKey.set(COSEKEYS.y, y);
|
|
@@ -61,11 +64,24 @@ export function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
61
64
|
const rsaPublicKey = AsnParser.parse(subjectPublicKeyInfo.subjectPublicKey, RSAPublicKey);
|
|
62
65
|
const coseRSAPubKey = new Map();
|
|
63
66
|
coseRSAPubKey.set(COSEKEYS.kty, COSEKTY.RSA);
|
|
64
|
-
|
|
67
|
+
/**
|
|
68
|
+
* The algorithm ID is too ambiguous to know what this alg should really be. But practically
|
|
69
|
+
* speaking `shaHashOverride` is always specified when verifying signatures with RSA public keys
|
|
70
|
+
* which ultimately overrides this sensible default. Using RS256 also gets the correct WebCrypto
|
|
71
|
+
* alg name later on in verifyRSA.ts
|
|
72
|
+
*/
|
|
73
|
+
coseRSAPubKey.set(COSEKEYS.alg, COSEALG.RS256);
|
|
65
74
|
coseRSAPubKey.set(COSEKEYS.n, new Uint8Array(rsaPublicKey.modulus));
|
|
66
75
|
coseRSAPubKey.set(COSEKEYS.e, new Uint8Array(rsaPublicKey.publicExponent));
|
|
67
76
|
cosePublicKey = coseRSAPubKey;
|
|
68
77
|
}
|
|
78
|
+
else if ([id_ml_dsa_44, id_ml_dsa_65, id_ml_dsa_87].indexOf(publicKeyAlgorithmID) >= 0) {
|
|
79
|
+
const coseAKPPubKey = new Map();
|
|
80
|
+
coseAKPPubKey.set(COSEKEYS.kty, COSEKTY.AKP);
|
|
81
|
+
coseAKPPubKey.set(COSEKEYS.alg, mapX509SignatureAlgToCOSEAlg(publicKeyAlgorithmID));
|
|
82
|
+
coseAKPPubKey.set(COSEKEYS.pub, new Uint8Array(subjectPublicKeyInfo.subjectPublicKey));
|
|
83
|
+
cosePublicKey = coseAKPPubKey;
|
|
84
|
+
}
|
|
69
85
|
else {
|
|
70
86
|
throw new Error(`Certificate public key contained unexpected algorithm ID ${publicKeyAlgorithmID}`);
|
|
71
87
|
}
|
package/esm/helpers/cose.d.ts
CHANGED
|
@@ -48,6 +48,13 @@ export type COSEPublicKeyRSA = COSEPublicKey & {
|
|
|
48
48
|
set(key: COSEKEYS.n, value: Uint8Array_): void;
|
|
49
49
|
set(key: COSEKEYS.e, value: Uint8Array_): void;
|
|
50
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Values specific for AKP (ML-DSA) public keys
|
|
53
|
+
*/
|
|
54
|
+
export type COSEPublicKeyAKP = COSEPublicKey & {
|
|
55
|
+
get(key: COSEKEYS.pub): Uint8Array_ | undefined;
|
|
56
|
+
set(key: COSEKEYS.pub, value: Uint8Array_): void;
|
|
57
|
+
};
|
|
51
58
|
/**
|
|
52
59
|
* A type guard for determining if a COSE public key is an OKP key pair
|
|
53
60
|
*/
|
|
@@ -60,6 +67,10 @@ export declare function isCOSEPublicKeyEC2(cosePublicKey: COSEPublicKey): cosePu
|
|
|
60
67
|
* A type guard for determining if a COSE public key is an RSA key pair
|
|
61
68
|
*/
|
|
62
69
|
export declare function isCOSEPublicKeyRSA(cosePublicKey: COSEPublicKey): cosePublicKey is COSEPublicKeyRSA;
|
|
70
|
+
/**
|
|
71
|
+
* A type guard for determining if a COSE public key is an AKP key pair
|
|
72
|
+
*/
|
|
73
|
+
export declare function isCOSEPublicKeyAKP(cosePublicKey: COSEPublicKey): cosePublicKey is COSEPublicKeyAKP;
|
|
63
74
|
/**
|
|
64
75
|
* COSE Keys
|
|
65
76
|
*
|
|
@@ -73,7 +84,8 @@ export declare enum COSEKEYS {
|
|
|
73
84
|
x = -2,
|
|
74
85
|
y = -3,
|
|
75
86
|
n = -1,
|
|
76
|
-
e = -2
|
|
87
|
+
e = -2,
|
|
88
|
+
pub = -1
|
|
77
89
|
}
|
|
78
90
|
/**
|
|
79
91
|
* COSE Key Types
|
|
@@ -83,7 +95,8 @@ export declare enum COSEKEYS {
|
|
|
83
95
|
export declare enum COSEKTY {
|
|
84
96
|
OKP = 1,
|
|
85
97
|
EC2 = 2,
|
|
86
|
-
RSA = 3
|
|
98
|
+
RSA = 3,
|
|
99
|
+
AKP = 7
|
|
87
100
|
}
|
|
88
101
|
export declare function isCOSEKty(kty: number | undefined): kty is COSEKTY;
|
|
89
102
|
/**
|
|
@@ -113,10 +126,14 @@ export declare enum COSEALG {
|
|
|
113
126
|
PS384 = -38,
|
|
114
127
|
PS512 = -39,
|
|
115
128
|
ES256K = -47,
|
|
129
|
+
ML_DSA_44 = -48,
|
|
130
|
+
ML_DSA_65 = -49,
|
|
131
|
+
ML_DSA_87 = -50,
|
|
116
132
|
RS256 = -257,
|
|
117
133
|
RS384 = -258,
|
|
118
134
|
RS512 = -259,
|
|
119
135
|
RS1 = -65535
|
|
120
136
|
}
|
|
121
137
|
export declare function isCOSEAlg(alg: number | undefined): alg is COSEALG;
|
|
138
|
+
export declare function isPQCCOSEAlg(alg: COSEALG): boolean;
|
|
122
139
|
//# sourceMappingURL=cose.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cose.d.ts","sourceRoot":"","sources":["../../src/helpers/cose.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD;;;;;;;;;;GAUG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAE1B,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,GAAG,SAAS,CAAC;IAE5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC7C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAE7C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,GAAG,MAAM,GAAG,SAAS,CAAC;IAC3C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,GAAG,WAAW,GAAG,SAAS,CAAC;IAE9C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;CAChD,CAAC;AAE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AAG,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,IAAI,OAAO,CAEjE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD"}
|
package/esm/helpers/cose.js
CHANGED
|
@@ -19,6 +19,13 @@ export function isCOSEPublicKeyRSA(cosePublicKey) {
|
|
|
19
19
|
const kty = cosePublicKey.get(COSEKEYS.kty);
|
|
20
20
|
return isCOSEKty(kty) && kty === COSEKTY.RSA;
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* A type guard for determining if a COSE public key is an AKP key pair
|
|
24
|
+
*/
|
|
25
|
+
export function isCOSEPublicKeyAKP(cosePublicKey) {
|
|
26
|
+
const kty = cosePublicKey.get(COSEKEYS.kty);
|
|
27
|
+
return isCOSEKty(kty) && kty === COSEKTY.AKP;
|
|
28
|
+
}
|
|
22
29
|
/**
|
|
23
30
|
* COSE Keys
|
|
24
31
|
*
|
|
@@ -34,6 +41,7 @@ export var COSEKEYS;
|
|
|
34
41
|
COSEKEYS[COSEKEYS["y"] = -3] = "y";
|
|
35
42
|
COSEKEYS[COSEKEYS["n"] = -1] = "n";
|
|
36
43
|
COSEKEYS[COSEKEYS["e"] = -2] = "e";
|
|
44
|
+
COSEKEYS[COSEKEYS["pub"] = -1] = "pub";
|
|
37
45
|
})(COSEKEYS || (COSEKEYS = {}));
|
|
38
46
|
/**
|
|
39
47
|
* COSE Key Types
|
|
@@ -45,6 +53,7 @@ export var COSEKTY;
|
|
|
45
53
|
COSEKTY[COSEKTY["OKP"] = 1] = "OKP";
|
|
46
54
|
COSEKTY[COSEKTY["EC2"] = 2] = "EC2";
|
|
47
55
|
COSEKTY[COSEKTY["RSA"] = 3] = "RSA";
|
|
56
|
+
COSEKTY[COSEKTY["AKP"] = 7] = "AKP";
|
|
48
57
|
})(COSEKTY || (COSEKTY = {}));
|
|
49
58
|
export function isCOSEKty(kty) {
|
|
50
59
|
return Object.values(COSEKTY).indexOf(kty) >= 0;
|
|
@@ -80,6 +89,9 @@ export var COSEALG;
|
|
|
80
89
|
COSEALG[COSEALG["PS384"] = -38] = "PS384";
|
|
81
90
|
COSEALG[COSEALG["PS512"] = -39] = "PS512";
|
|
82
91
|
COSEALG[COSEALG["ES256K"] = -47] = "ES256K";
|
|
92
|
+
COSEALG[COSEALG["ML_DSA_44"] = -48] = "ML_DSA_44";
|
|
93
|
+
COSEALG[COSEALG["ML_DSA_65"] = -49] = "ML_DSA_65";
|
|
94
|
+
COSEALG[COSEALG["ML_DSA_87"] = -50] = "ML_DSA_87";
|
|
83
95
|
COSEALG[COSEALG["RS256"] = -257] = "RS256";
|
|
84
96
|
COSEALG[COSEALG["RS384"] = -258] = "RS384";
|
|
85
97
|
COSEALG[COSEALG["RS512"] = -259] = "RS512";
|
|
@@ -88,3 +100,6 @@ export var COSEALG;
|
|
|
88
100
|
export function isCOSEAlg(alg) {
|
|
89
101
|
return Object.values(COSEALG).indexOf(alg) >= 0;
|
|
90
102
|
}
|
|
103
|
+
export function isPQCCOSEAlg(alg) {
|
|
104
|
+
return [COSEALG.ML_DSA_44, COSEALG.ML_DSA_65, COSEALG.ML_DSA_87].indexOf(alg) >= 0;
|
|
105
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decodeClientDataJSON.d.ts","sourceRoot":"","sources":["../../src/helpers/decodeClientDataJSON.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAK1E;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE;QACb,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,eAAe,CAAC;KACnD,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B;sBACvB,cAAc;CACjC,CAAC"}
|
|
1
|
+
{"version":3,"file":"decodeClientDataJSON.d.ts","sourceRoot":"","sources":["../../src/helpers/decodeClientDataJSON.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,eAAe,GAAG,cAAc,CAK1E;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE;QACb,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,eAAe,CAAC;KACnD,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,8BAA8B;sBACvB,cAAc;CACjC,CAAC"}
|
package/esm/helpers/index.d.ts
CHANGED
|
@@ -15,4 +15,6 @@ export * from './verifySignature.js';
|
|
|
15
15
|
export * from './iso/index.js';
|
|
16
16
|
export * from '../metadata/verifyMDSBlob.js';
|
|
17
17
|
export * as cose from './cose.js';
|
|
18
|
+
export { COSEALG } from './cose.js';
|
|
19
|
+
export { type SimpleWebAuthnLogger } from './logging.js';
|
|
18
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC"}
|
package/esm/helpers/index.js
CHANGED
|
@@ -15,3 +15,5 @@ export * from './verifySignature.js';
|
|
|
15
15
|
export * from './iso/index.js';
|
|
16
16
|
export * from '../metadata/verifyMDSBlob.js';
|
|
17
17
|
export * as cose from './cose.js';
|
|
18
|
+
// Specially exporting this for easier `supportedAlgorithmIDs` argument definition
|
|
19
|
+
export { COSEALG } from './cose.js';
|
|
@@ -1 +1 @@
|
|
|
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"}
|
|
1
|
+
{"version":3,"file":"isCertRevoked.d.ts","sourceRoot":"","sources":["../../src/helpers/isCertRevoked.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAIL,KAAK,eAAe,EAErB,MAAM,gBAAgB,CAAC;AAexB;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAkG3E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mapCoseAlgToWebCryptoHashAlgName } from './mapCoseAlgToWebCryptoHashAlgName.js';
|
|
2
2
|
import { getWebCrypto } from './getWebCrypto.js';
|
|
3
3
|
/**
|
|
4
4
|
* Generate a digest of the provided data.
|
|
@@ -8,7 +8,7 @@ import { getWebCrypto } from './getWebCrypto.js';
|
|
|
8
8
|
*/
|
|
9
9
|
export async function digest(data, algorithm) {
|
|
10
10
|
const WebCrypto = await getWebCrypto();
|
|
11
|
-
const subtleAlgorithm =
|
|
11
|
+
const subtleAlgorithm = mapCoseAlgToWebCryptoHashAlgName(algorithm);
|
|
12
12
|
const hashed = await WebCrypto.subtle.digest(subtleAlgorithm, data);
|
|
13
13
|
return new Uint8Array(hashed);
|
|
14
14
|
}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,CA4C9C;AAED,qBAAa,gBAAiB,SAAQ,KAAK;;CAM1C;AAGD,eAAO,MAAM,sBAAsB;;iCAGJ,MAAM,GAAG,SAAS;CAGhD,CAAC"}
|
|
@@ -24,6 +24,18 @@ export function getWebCrypto() {
|
|
|
24
24
|
*/
|
|
25
25
|
const _globalThisCrypto = _getWebCryptoInternals.stubThisGlobalThisCrypto();
|
|
26
26
|
if (_globalThisCrypto) {
|
|
27
|
+
/**
|
|
28
|
+
* In Deno v2.7.x, TypeScript 5.9 defines `Crypto.getRandomValues()` as the following type:
|
|
29
|
+
*
|
|
30
|
+
* `getRandomValues<T extends ArrayBufferView>(array: T): T;`
|
|
31
|
+
*
|
|
32
|
+
* However in earlier versions of TypeScript, `Crypto.getRandomValues()` is defined as such:
|
|
33
|
+
*
|
|
34
|
+
* `getRandomValues<T extends ArrayBufferView | null>(array: T): T;`
|
|
35
|
+
*
|
|
36
|
+
* Casting to `as unknown as Crypto` here (using this project's `Crypto` types extracted from
|
|
37
|
+
* DOM types in an older, minimum-supported-Deno version of TypeScript) helps bridge the gap.
|
|
38
|
+
*/
|
|
27
39
|
webCrypto = _globalThisCrypto;
|
|
28
40
|
return resolve(webCrypto);
|
|
29
41
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a JWK-formatted public key into a WebCrypto CryptoKey that can be used for
|
|
3
|
+
* signature verification
|
|
4
|
+
*/
|
|
5
|
+
export declare function importJWKKey(opts: {
|
|
6
|
+
keyData: JsonWebKey;
|
|
7
|
+
algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams;
|
|
8
|
+
}): Promise<CryptoKey>;
|
|
9
|
+
//# sourceMappingURL=importJWKKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importJWKKey.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/importJWKKey.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,OAAO,EAAE,UAAU,CAAC;IACpB,SAAS,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,iBAAiB,CAAC;CAC5E,GAAG,OAAO,CAAC,SAAS,CAAC,CAMrB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { getWebCrypto } from './getWebCrypto.js';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Convert a JWK-formatted public key into a WebCrypto CryptoKey that can be used for
|
|
4
|
+
* signature verification
|
|
5
|
+
*/
|
|
6
|
+
export async function importJWKKey(opts) {
|
|
3
7
|
const WebCrypto = await getWebCrypto();
|
|
4
8
|
const { keyData, algorithm } = opts;
|
|
5
|
-
return WebCrypto.subtle.importKey('jwk', keyData, algorithm, false, [
|
|
6
|
-
'verify',
|
|
7
|
-
]);
|
|
9
|
+
return WebCrypto.subtle.importKey('jwk', keyData, algorithm, false, ['verify']);
|
|
8
10
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SubtleCryptoAlg } from './structs.js';
|
|
2
|
+
import { COSEALG } from '../../cose.js';
|
|
3
|
+
/**
|
|
4
|
+
* Convert a COSE alg ID into a corresponding hash algorithm string value that WebCrypto APIs expect
|
|
5
|
+
*
|
|
6
|
+
* Unless otherwise specified, mappings were referenced from
|
|
7
|
+
* https://w3c.github.io/webcrypto/#jwk-mapping-alg
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapCoseAlgToWebCryptoHashAlgName(alg: COSEALG): SubtleCryptoAlg;
|
|
10
|
+
//# sourceMappingURL=mapCoseAlgToWebCryptoHashAlgName.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapCoseAlgToWebCryptoHashAlgName.d.ts","sourceRoot":"","sources":["../../../../src/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoHashAlgName.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAe9E"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { COSEALG } from '../../cose.js';
|
|
2
2
|
/**
|
|
3
|
-
* Convert a COSE alg ID into a corresponding string value that WebCrypto APIs expect
|
|
3
|
+
* Convert a COSE alg ID into a corresponding hash algorithm string value that WebCrypto APIs expect
|
|
4
|
+
*
|
|
5
|
+
* Unless otherwise specified, mappings were referenced from
|
|
6
|
+
* https://w3c.github.io/webcrypto/#jwk-mapping-alg
|
|
4
7
|
*/
|
|
5
|
-
export function
|
|
8
|
+
export function mapCoseAlgToWebCryptoHashAlgName(alg) {
|
|
6
9
|
if ([COSEALG.RS1].indexOf(alg) >= 0) {
|
|
7
10
|
return 'SHA-1';
|
|
8
11
|
}
|
|
@@ -16,5 +19,5 @@ export function mapCoseAlgToWebCryptoAlg(alg) {
|
|
|
16
19
|
0) {
|
|
17
20
|
return 'SHA-512';
|
|
18
21
|
}
|
|
19
|
-
throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto alg`);
|
|
22
|
+
throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto hash alg name`);
|
|
20
23
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { COSEALG } from '../../cose.js';
|
|
2
|
-
import { SubtleCryptoKeyAlgName } from './structs.js';
|
|
2
|
+
import type { SubtleCryptoKeyAlgName } from './structs.js';
|
|
3
3
|
/**
|
|
4
4
|
* Convert a COSE alg ID into a corresponding key algorithm string value that WebCrypto APIs expect
|
|
5
|
+
*
|
|
6
|
+
* Unless otherwise specified, mappings were referenced from
|
|
7
|
+
* https://w3c.github.io/webcrypto/#jwk-mapping-alg
|
|
5
8
|
*/
|
|
6
9
|
export declare function mapCoseAlgToWebCryptoKeyAlgName(alg: COSEALG): SubtleCryptoKeyAlgName;
|
|
7
10
|
//# sourceMappingURL=mapCoseAlgToWebCryptoKeyAlgName.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,OAAO,GACX,sBAAsB,CAuBxB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { COSEALG } from '../../cose.js';
|
|
2
2
|
/**
|
|
3
3
|
* Convert a COSE alg ID into a corresponding key algorithm string value that WebCrypto APIs expect
|
|
4
|
+
*
|
|
5
|
+
* Unless otherwise specified, mappings were referenced from
|
|
6
|
+
* https://w3c.github.io/webcrypto/#jwk-mapping-alg
|
|
4
7
|
*/
|
|
5
8
|
export function mapCoseAlgToWebCryptoKeyAlgName(alg) {
|
|
6
9
|
if ([COSEALG.EdDSA].indexOf(alg) >= 0) {
|
|
@@ -15,5 +18,17 @@ export function mapCoseAlgToWebCryptoKeyAlgName(alg) {
|
|
|
15
18
|
else if ([COSEALG.PS256, COSEALG.PS384, COSEALG.PS512].indexOf(alg) >= 0) {
|
|
16
19
|
return 'RSA-PSS';
|
|
17
20
|
}
|
|
21
|
+
else if ([COSEALG.ML_DSA_44].indexOf(alg) >= 0) {
|
|
22
|
+
// https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-registration
|
|
23
|
+
return 'ML-DSA-44';
|
|
24
|
+
}
|
|
25
|
+
else if ([COSEALG.ML_DSA_65].indexOf(alg) >= 0) {
|
|
26
|
+
// https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-registration
|
|
27
|
+
return 'ML-DSA-65';
|
|
28
|
+
}
|
|
29
|
+
else if ([COSEALG.ML_DSA_87].indexOf(alg) >= 0) {
|
|
30
|
+
// https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-registration
|
|
31
|
+
return 'ML-DSA-87';
|
|
32
|
+
}
|
|
18
33
|
throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto key alg name`);
|
|
19
34
|
}
|