@simplewebauthn/server 7.4.0 → 8.0.0-alpha.0
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/LICENSE.md +11 -14
- package/README.md +6 -2
- package/{dist → esm}/authentication/generateAuthenticationOptions.d.ts +2 -2
- package/esm/authentication/generateAuthenticationOptions.js +36 -0
- package/{dist → esm}/authentication/verifyAuthenticationResponse.d.ts +2 -2
- package/esm/authentication/verifyAuthenticationResponse.js +164 -0
- package/esm/deps.d.ts +10 -0
- package/esm/deps.js +12 -0
- package/esm/helpers/convertAAGUIDToString.js +17 -0
- package/esm/helpers/convertCOSEtoPKCS.js +21 -0
- package/{dist → esm}/helpers/convertCertBufferToPEM.d.ts +1 -1
- package/esm/helpers/convertCertBufferToPEM.js +31 -0
- package/esm/helpers/convertPEMToBytes.js +11 -0
- package/{dist → esm}/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
- package/esm/helpers/convertX509PublicKeyToCOSE.js +70 -0
- package/{dist → esm}/helpers/cose.d.ts +2 -1
- package/esm/helpers/cose.js +81 -0
- package/{dist → esm}/helpers/decodeAttestationObject.d.ts +3 -0
- package/esm/helpers/decodeAttestationObject.js +13 -0
- package/esm/helpers/decodeAuthenticatorExtensions.js +34 -0
- package/{dist → esm}/helpers/decodeClientDataJSON.d.ts +3 -0
- package/esm/helpers/decodeClientDataJSON.js +13 -0
- package/esm/helpers/decodeCredentialPublicKey.d.ts +5 -0
- package/esm/helpers/decodeCredentialPublicKey.js +8 -0
- package/esm/helpers/fetch.d.ts +8 -0
- package/esm/helpers/fetch.js +12 -0
- package/esm/helpers/generateChallenge.d.ts +7 -0
- package/esm/helpers/generateChallenge.js +21 -0
- package/{dist → esm}/helpers/getCertificateInfo.d.ts +1 -1
- package/esm/helpers/getCertificateInfo.js +76 -0
- package/esm/helpers/index.d.ts +22 -0
- package/esm/helpers/index.js +16 -0
- package/{dist → esm}/helpers/isCertRevoked.d.ts +1 -1
- package/esm/helpers/isCertRevoked.js +98 -0
- package/{dist → esm}/helpers/iso/index.d.ts +4 -4
- package/esm/helpers/iso/index.js +11 -0
- package/esm/helpers/iso/isoBase64URL.js +57 -0
- package/{dist → esm}/helpers/iso/isoCBOR.d.ts +1 -1
- package/esm/helpers/iso/isoCBOR.js +44 -0
- package/{dist → esm}/helpers/iso/isoCrypto/digest.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/digest.js +14 -0
- package/{dist → esm}/helpers/iso/isoCrypto/getRandomValues.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/getRandomValues.js +11 -0
- package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts +6 -0
- package/esm/helpers/iso/isoCrypto/getWebCrypto.js +40 -0
- package/esm/helpers/iso/isoCrypto/importKey.js +8 -0
- package/esm/helpers/iso/isoCrypto/index.d.ts +3 -0
- package/esm/helpers/iso/isoCrypto/index.js +3 -0
- package/{dist → esm}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +2 -2
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js +20 -0
- package/{dist → esm}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +2 -2
- package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +19 -0
- package/esm/helpers/iso/isoCrypto/structs.js +1 -0
- package/esm/helpers/iso/isoCrypto/unwrapEC2Signature.js +30 -0
- package/{dist → esm}/helpers/iso/isoCrypto/verify.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/verify.js +28 -0
- package/{dist → esm}/helpers/iso/isoCrypto/verifyEC2.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/verifyEC2.js +73 -0
- package/{dist → esm}/helpers/iso/isoCrypto/verifyOKP.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/verifyOKP.js +51 -0
- package/{dist → esm}/helpers/iso/isoCrypto/verifyRSA.d.ts +1 -1
- package/esm/helpers/iso/isoCrypto/verifyRSA.js +91 -0
- package/esm/helpers/iso/isoUint8Array.js +75 -0
- package/{dist → esm}/helpers/logging.d.ts +1 -1
- package/esm/helpers/logging.js +19 -0
- package/{dist → esm}/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +1 -1
- package/esm/helpers/mapX509SignatureAlgToCOSEAlg.js +35 -0
- package/esm/helpers/matchExpectedRPID.js +41 -0
- package/{dist → esm}/helpers/parseAuthenticatorData.d.ts +4 -1
- package/esm/helpers/parseAuthenticatorData.js +71 -0
- package/{dist → esm}/helpers/parseBackupFlags.d.ts +4 -1
- package/esm/helpers/parseBackupFlags.js +25 -0
- package/{dist → esm}/helpers/toHash.d.ts +1 -1
- package/esm/helpers/toHash.js +12 -0
- package/esm/helpers/validateCertificatePath.js +122 -0
- package/{dist → esm}/helpers/verifySignature.d.ts +4 -1
- package/esm/helpers/verifySignature.js +32 -0
- package/esm/index.d.ts +17 -0
- package/esm/index.js +11 -0
- package/{dist → esm}/metadata/mdsTypes.d.ts +1 -1
- package/esm/metadata/mdsTypes.js +17 -0
- package/esm/metadata/parseJWT.js +12 -0
- package/{dist → esm}/metadata/verifyAttestationWithMetadata.d.ts +3 -3
- package/esm/metadata/verifyAttestationWithMetadata.js +159 -0
- package/esm/metadata/verifyJWT.js +37 -0
- package/esm/package.json +3 -0
- package/{dist → esm}/registration/generateRegistrationOptions.d.ts +2 -2
- package/esm/registration/generateRegistrationOptions.js +142 -0
- package/esm/registration/verifications/tpm/constants.js +182 -0
- package/esm/registration/verifications/tpm/parseCertInfo.js +58 -0
- package/esm/registration/verifications/tpm/parsePubArea.js +94 -0
- package/{dist → esm}/registration/verifications/tpm/verifyAttestationTPM.d.ts +1 -1
- package/esm/registration/verifications/tpm/verifyAttestationTPM.js +323 -0
- package/{dist → esm}/registration/verifications/verifyAttestationAndroidKey.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationAndroidKey.js +90 -0
- package/{dist → esm}/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationAndroidSafetyNet.js +112 -0
- package/{dist → esm}/registration/verifications/verifyAttestationApple.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationApple.js +57 -0
- package/{dist → esm}/registration/verifications/verifyAttestationFIDOU2F.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationFIDOU2F.js +48 -0
- package/{dist → esm}/registration/verifications/verifyAttestationPacked.d.ts +1 -1
- package/esm/registration/verifications/verifyAttestationPacked.js +105 -0
- package/{dist → esm}/registration/verifyRegistrationResponse.d.ts +3 -3
- package/esm/registration/verifyRegistrationResponse.js +198 -0
- package/esm/services/defaultRootCerts/android-key.js +85 -0
- package/esm/services/defaultRootCerts/android-safetynet.js +32 -0
- package/esm/services/defaultRootCerts/apple.js +25 -0
- package/esm/services/defaultRootCerts/mds.js +32 -0
- package/{dist → esm}/services/metadataService.d.ts +1 -1
- package/{dist → esm}/services/metadataService.js +52 -36
- package/{dist → esm}/services/settingsService.d.ts +1 -1
- package/esm/services/settingsService.js +65 -0
- package/package.json +40 -45
- package/script/authentication/generateAuthenticationOptions.d.ts +23 -0
- package/{dist → script}/authentication/generateAuthenticationOptions.js +8 -9
- package/script/authentication/verifyAuthenticationResponse.d.ts +66 -0
- package/{dist → script}/authentication/verifyAuthenticationResponse.js +25 -23
- package/script/deps.d.ts +10 -0
- package/script/deps.js +68 -0
- package/script/helpers/convertAAGUIDToString.d.ts +4 -0
- package/{dist → script}/helpers/convertAAGUIDToString.js +2 -3
- package/script/helpers/convertCOSEtoPKCS.d.ts +4 -0
- package/{dist → script}/helpers/convertCOSEtoPKCS.js +7 -8
- package/script/helpers/convertCertBufferToPEM.d.ts +5 -0
- package/{dist → script}/helpers/convertCertBufferToPEM.js +5 -6
- package/script/helpers/convertPEMToBytes.d.ts +4 -0
- package/{dist → script}/helpers/convertPEMToBytes.js +2 -3
- package/script/helpers/convertX509PublicKeyToCOSE.d.ts +2 -0
- package/{dist → script}/helpers/convertX509PublicKeyToCOSE.js +21 -25
- package/script/helpers/cose.d.ts +98 -0
- package/{dist → script}/helpers/cose.js +1 -1
- package/script/helpers/decodeAttestationObject.d.ts +29 -0
- package/script/helpers/decodeAttestationObject.js +17 -0
- package/script/helpers/decodeAuthenticatorExtensions.d.ts +20 -0
- package/{dist → script}/helpers/decodeAuthenticatorExtensions.js +2 -3
- package/script/helpers/decodeClientDataJSON.d.ts +17 -0
- package/script/helpers/decodeClientDataJSON.js +17 -0
- package/script/helpers/decodeCredentialPublicKey.d.ts +5 -0
- package/script/helpers/decodeCredentialPublicKey.js +12 -0
- package/script/helpers/fetch.d.ts +8 -0
- package/script/helpers/fetch.js +16 -0
- package/script/helpers/generateChallenge.d.ts +7 -0
- package/{dist → script}/helpers/generateChallenge.js +9 -6
- package/script/helpers/getCertificateInfo.d.ts +31 -0
- package/{dist → script}/helpers/getCertificateInfo.js +4 -6
- package/script/helpers/index.d.ts +22 -0
- package/script/helpers/index.js +59 -0
- package/script/helpers/isCertRevoked.d.ts +8 -0
- package/{dist → script}/helpers/isCertRevoked.js +20 -25
- package/script/helpers/iso/index.d.ts +11 -0
- package/{dist → script}/helpers/iso/index.js +4 -5
- package/script/helpers/iso/isoBase64URL.d.ts +37 -0
- package/{dist → script}/helpers/iso/isoBase64URL.js +0 -1
- package/script/helpers/iso/isoCBOR.d.ts +12 -0
- package/{dist → script}/helpers/iso/isoCBOR.js +8 -28
- package/script/helpers/iso/isoCrypto/digest.d.ts +8 -0
- package/script/helpers/iso/isoCrypto/digest.js +18 -0
- package/script/helpers/iso/isoCrypto/getRandomValues.d.ts +6 -0
- package/script/helpers/iso/isoCrypto/getRandomValues.js +15 -0
- package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts +6 -0
- package/script/helpers/iso/isoCrypto/getWebCrypto.js +44 -0
- package/script/helpers/iso/isoCrypto/importKey.d.ts +4 -0
- package/script/helpers/iso/isoCrypto/importKey.js +12 -0
- package/script/helpers/iso/isoCrypto/index.d.ts +3 -0
- package/{dist → script}/helpers/iso/isoCrypto/index.js +6 -7
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +6 -0
- package/{dist → script}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js +6 -6
- package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +6 -0
- package/{dist → script}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +5 -6
- package/script/helpers/iso/isoCrypto/structs.d.ts +3 -0
- package/{dist → script}/helpers/iso/isoCrypto/structs.js +0 -1
- package/script/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts +6 -0
- package/{dist → script}/helpers/iso/isoCrypto/unwrapEC2Signature.js +4 -6
- package/script/helpers/iso/isoCrypto/verify.d.ts +10 -0
- package/script/helpers/iso/isoCrypto/verify.js +32 -0
- package/script/helpers/iso/isoCrypto/verifyEC2.d.ts +10 -0
- package/{dist → script}/helpers/iso/isoCrypto/verifyEC2.js +19 -22
- package/script/helpers/iso/isoCrypto/verifyOKP.d.ts +6 -0
- package/{dist → script}/helpers/iso/isoCrypto/verifyOKP.js +13 -16
- package/script/helpers/iso/isoCrypto/verifyRSA.d.ts +10 -0
- package/{dist → script}/helpers/iso/isoCrypto/verifyRSA.js +19 -22
- package/script/helpers/iso/isoUint8Array.d.ts +36 -0
- package/{dist → script}/helpers/iso/isoUint8Array.js +7 -8
- package/script/helpers/logging.d.ts +17 -0
- package/{dist → script}/helpers/logging.js +2 -6
- package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +8 -0
- package/{dist → script}/helpers/mapX509SignatureAlgToCOSEAlg.js +8 -9
- package/script/helpers/matchExpectedRPID.d.ts +7 -0
- package/{dist → script}/helpers/matchExpectedRPID.js +5 -6
- package/script/helpers/parseAuthenticatorData.d.ts +28 -0
- package/{dist → script}/helpers/parseAuthenticatorData.js +19 -16
- package/script/helpers/parseBackupFlags.d.ts +19 -0
- package/{dist → script}/helpers/parseBackupFlags.js +2 -2
- package/script/helpers/toHash.d.ts +6 -0
- package/{dist → script}/helpers/toHash.js +4 -5
- package/script/helpers/validateCertificatePath.d.ts +6 -0
- package/{dist → script}/helpers/validateCertificatePath.js +13 -15
- package/script/helpers/verifySignature.d.ts +14 -0
- package/script/helpers/verifySignature.js +36 -0
- package/script/index.d.ts +17 -0
- package/script/index.js +19 -0
- package/script/metadata/mdsTypes.d.ts +216 -0
- package/{dist → script}/metadata/mdsTypes.js +0 -1
- package/script/metadata/parseJWT.d.ts +4 -0
- package/{dist → script}/metadata/parseJWT.js +3 -4
- package/script/metadata/verifyAttestationWithMetadata.d.ts +29 -0
- package/{dist → script}/metadata/verifyAttestationWithMetadata.js +24 -22
- package/script/metadata/verifyJWT.d.ts +10 -0
- package/script/metadata/verifyJWT.js +41 -0
- package/script/package.json +3 -0
- package/script/registration/generateRegistrationOptions.d.ts +43 -0
- package/{dist → script}/registration/generateRegistrationOptions.js +9 -10
- package/script/registration/verifications/tpm/constants.d.ts +47 -0
- package/{dist → script}/registration/verifications/tpm/constants.js +1 -2
- package/script/registration/verifications/tpm/parseCertInfo.d.ts +24 -0
- package/{dist → script}/registration/verifications/tpm/parseCertInfo.js +13 -14
- package/script/registration/verifications/tpm/parsePubArea.d.ts +43 -0
- package/{dist → script}/registration/verifications/tpm/parsePubArea.js +16 -17
- package/script/registration/verifications/tpm/verifyAttestationTPM.d.ts +2 -0
- package/{dist → script}/registration/verifications/tpm/verifyAttestationTPM.js +58 -58
- package/script/registration/verifications/verifyAttestationAndroidKey.d.ts +5 -0
- package/{dist → script}/registration/verifications/verifyAttestationAndroidKey.js +22 -26
- package/script/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts +5 -0
- package/{dist → script}/registration/verifications/verifyAttestationAndroidSafetyNet.js +22 -23
- package/script/registration/verifications/verifyAttestationApple.d.ts +2 -0
- package/{dist → script}/registration/verifications/verifyAttestationApple.js +15 -17
- package/script/registration/verifications/verifyAttestationFIDOU2F.d.ts +5 -0
- package/{dist → script}/registration/verifications/verifyAttestationFIDOU2F.js +12 -13
- package/script/registration/verifications/verifyAttestationPacked.d.ts +5 -0
- package/{dist → script}/registration/verifications/verifyAttestationPacked.js +17 -18
- package/script/registration/verifyRegistrationResponse.d.ts +85 -0
- package/{dist → script}/registration/verifyRegistrationResponse.js +39 -38
- package/script/services/defaultRootCerts/android-key.d.ts +24 -0
- package/{dist → script}/services/defaultRootCerts/android-key.js +0 -1
- package/script/services/defaultRootCerts/android-safetynet.d.ts +11 -0
- package/{dist → script}/services/defaultRootCerts/android-safetynet.js +0 -1
- package/script/services/defaultRootCerts/apple.d.ts +11 -0
- package/{dist → script}/services/defaultRootCerts/apple.js +0 -1
- package/script/services/defaultRootCerts/mds.d.ts +11 -0
- package/{dist → script}/services/defaultRootCerts/mds.js +0 -1
- package/script/services/metadataService.d.ts +53 -0
- package/script/services/metadataService.js +277 -0
- package/script/services/settingsService.d.ts +25 -0
- package/{dist → script}/services/settingsService.js +21 -13
- package/dist/authentication/generateAuthenticationOptions.js.map +0 -1
- package/dist/authentication/verifyAuthenticationResponse.js.map +0 -1
- package/dist/helpers/convertAAGUIDToString.js.map +0 -1
- package/dist/helpers/convertCOSEtoPKCS.js.map +0 -1
- package/dist/helpers/convertCertBufferToPEM.js.map +0 -1
- package/dist/helpers/convertPEMToBytes.js.map +0 -1
- package/dist/helpers/convertX509PublicKeyToCOSE.js.map +0 -1
- package/dist/helpers/cose.js.map +0 -1
- package/dist/helpers/decodeAttestationObject.js +0 -14
- package/dist/helpers/decodeAttestationObject.js.map +0 -1
- package/dist/helpers/decodeAuthenticatorExtensions.js.map +0 -1
- package/dist/helpers/decodeClientDataJSON.js +0 -14
- package/dist/helpers/decodeClientDataJSON.js.map +0 -1
- package/dist/helpers/decodeCredentialPublicKey.d.ts +0 -2
- package/dist/helpers/decodeCredentialPublicKey.js +0 -9
- package/dist/helpers/decodeCredentialPublicKey.js.map +0 -1
- package/dist/helpers/generateChallenge.d.ts +0 -4
- package/dist/helpers/generateChallenge.js.map +0 -1
- package/dist/helpers/getCertificateInfo.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -22
- package/dist/helpers/index.js +0 -60
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/isCertRevoked.js.map +0 -1
- package/dist/helpers/iso/index.js.map +0 -1
- package/dist/helpers/iso/isoBase64URL.js.map +0 -1
- package/dist/helpers/iso/isoCBOR.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/digest.js +0 -21
- package/dist/helpers/iso/isoCrypto/digest.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/getRandomValues.js +0 -18
- package/dist/helpers/iso/isoCrypto/getRandomValues.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/importKey.js +0 -13
- package/dist/helpers/iso/isoCrypto/importKey.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/index.d.ts +0 -3
- package/dist/helpers/iso/isoCrypto/index.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/structs.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/unwrapEC2Signature.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/verify.js +0 -28
- package/dist/helpers/iso/isoCrypto/verify.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/verifyEC2.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/verifyOKP.js.map +0 -1
- package/dist/helpers/iso/isoCrypto/verifyRSA.js.map +0 -1
- package/dist/helpers/iso/isoUint8Array.js.map +0 -1
- package/dist/helpers/logging.js.map +0 -1
- package/dist/helpers/mapX509SignatureAlgToCOSEAlg.js.map +0 -1
- package/dist/helpers/matchExpectedRPID.js.map +0 -1
- package/dist/helpers/parseAuthenticatorData.js.map +0 -1
- package/dist/helpers/parseBackupFlags.js.map +0 -1
- package/dist/helpers/toHash.js.map +0 -1
- package/dist/helpers/validateCertificatePath.js.map +0 -1
- package/dist/helpers/verifySignature.js +0 -33
- package/dist/helpers/verifySignature.js.map +0 -1
- package/dist/index.d.ts +0 -17
- package/dist/index.js +0 -20
- package/dist/index.js.map +0 -1
- package/dist/metadata/mdsTypes.js.map +0 -1
- package/dist/metadata/parseJWT.js.map +0 -1
- package/dist/metadata/verifyAttestationWithMetadata.js.map +0 -1
- package/dist/metadata/verifyJWT.js +0 -42
- package/dist/metadata/verifyJWT.js.map +0 -1
- package/dist/registration/generateRegistrationOptions.js.map +0 -1
- package/dist/registration/verifications/tpm/constants.js.map +0 -1
- package/dist/registration/verifications/tpm/parseCertInfo.js.map +0 -1
- package/dist/registration/verifications/tpm/parsePubArea.js.map +0 -1
- package/dist/registration/verifications/tpm/verifyAttestationTPM.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationAndroidKey.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationAndroidSafetyNet.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationApple.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationFIDOU2F.js.map +0 -1
- package/dist/registration/verifications/verifyAttestationPacked.js.map +0 -1
- package/dist/registration/verifyRegistrationResponse.js.map +0 -1
- package/dist/services/defaultRootCerts/android-key.js.map +0 -1
- package/dist/services/defaultRootCerts/android-safetynet.js.map +0 -1
- package/dist/services/defaultRootCerts/apple.js.map +0 -1
- package/dist/services/defaultRootCerts/mds.js.map +0 -1
- package/dist/services/metadataService.js.map +0 -1
- package/dist/services/settingsService.js.map +0 -1
- /package/{dist → esm}/helpers/convertAAGUIDToString.d.ts +0 -0
- /package/{dist → esm}/helpers/convertCOSEtoPKCS.d.ts +0 -0
- /package/{dist → esm}/helpers/convertPEMToBytes.d.ts +0 -0
- /package/{dist → esm}/helpers/decodeAuthenticatorExtensions.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoBase64URL.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoCrypto/importKey.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoCrypto/structs.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts +0 -0
- /package/{dist → esm}/helpers/iso/isoUint8Array.d.ts +0 -0
- /package/{dist → esm}/helpers/matchExpectedRPID.d.ts +0 -0
- /package/{dist → esm}/helpers/validateCertificatePath.d.ts +0 -0
- /package/{dist → esm}/metadata/parseJWT.d.ts +0 -0
- /package/{dist → esm}/metadata/verifyJWT.d.ts +0 -0
- /package/{dist → esm}/registration/verifications/tpm/constants.d.ts +0 -0
- /package/{dist → esm}/registration/verifications/tpm/parseCertInfo.d.ts +0 -0
- /package/{dist → esm}/registration/verifications/tpm/parsePubArea.d.ts +0 -0
- /package/{dist → esm}/services/defaultRootCerts/android-key.d.ts +0 -0
- /package/{dist → esm}/services/defaultRootCerts/android-safetynet.d.ts +0 -0
- /package/{dist → esm}/services/defaultRootCerts/apple.d.ts +0 -0
- /package/{dist → esm}/services/defaultRootCerts/mds.d.ts +0 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { AuthenticationResponseJSON, AuthenticatorDevice, CredentialDeviceType, UserVerificationRequirement } from '../deps.js';
|
|
2
|
+
import { AuthenticationExtensionsAuthenticatorOutputs } from '../helpers/decodeAuthenticatorExtensions.js';
|
|
3
|
+
export type VerifyAuthenticationResponseOpts = {
|
|
4
|
+
response: AuthenticationResponseJSON;
|
|
5
|
+
expectedChallenge: string | ((challenge: string) => boolean);
|
|
6
|
+
expectedOrigin: string | string[];
|
|
7
|
+
expectedRPID: string | string[];
|
|
8
|
+
authenticator: AuthenticatorDevice;
|
|
9
|
+
requireUserVerification?: boolean;
|
|
10
|
+
advancedFIDOConfig?: {
|
|
11
|
+
userVerification?: UserVerificationRequirement;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Verify that the user has legitimately completed the login process
|
|
16
|
+
*
|
|
17
|
+
* **Options:**
|
|
18
|
+
*
|
|
19
|
+
* @param response Response returned by **@simplewebauthn/browser**'s `startAssertion()`
|
|
20
|
+
* @param expectedChallenge The base64url-encoded `options.challenge` returned by
|
|
21
|
+
* `generateAuthenticationOptions()`
|
|
22
|
+
* @param expectedOrigin Website URL (or array of URLs) that the registration should have occurred on
|
|
23
|
+
* @param expectedRPID RP ID (or array of IDs) that was specified in the registration options
|
|
24
|
+
* @param authenticator An internal {@link AuthenticatorDevice} matching the credential's ID
|
|
25
|
+
* @param requireUserVerification (Optional) Enforce user verification by the authenticator
|
|
26
|
+
* (via PIN, fingerprint, etc...)
|
|
27
|
+
* @param advancedFIDOConfig (Optional) Options for satisfying more stringent FIDO RP feature
|
|
28
|
+
* requirements
|
|
29
|
+
* @param advancedFIDOConfig.userVerification (Optional) Enable alternative rules for evaluating the
|
|
30
|
+
* User Presence and User Verified flags in authenticator data: UV (and UP) flags are optional
|
|
31
|
+
* unless this value is `"required"`
|
|
32
|
+
*/
|
|
33
|
+
export declare function verifyAuthenticationResponse(options: VerifyAuthenticationResponseOpts): Promise<VerifiedAuthenticationResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Result of authentication verification
|
|
36
|
+
*
|
|
37
|
+
* @param verified If the authentication response could be verified
|
|
38
|
+
* @param authenticationInfo.credentialID The ID of the authenticator used during authentication.
|
|
39
|
+
* Should be used to identify which DB authenticator entry needs its `counter` updated to the value
|
|
40
|
+
* below
|
|
41
|
+
* @param authenticationInfo.newCounter The number of times the authenticator identified above
|
|
42
|
+
* reported it has been used. **Should be kept in a DB for later reference to help prevent replay
|
|
43
|
+
* attacks!**
|
|
44
|
+
* @param authenticationInfo.credentialDeviceType Whether this is a single-device or multi-device
|
|
45
|
+
* credential. **Should be kept in a DB for later reference!**
|
|
46
|
+
* @param authenticationInfo.credentialBackedUp Whether or not the multi-device credential has been
|
|
47
|
+
* backed up. Always `false` for single-device credentials. **Should be kept in a DB for later
|
|
48
|
+
* reference!**
|
|
49
|
+
* @param authenticationInfo.origin The origin of the website that the authentication occurred on
|
|
50
|
+
* @param authenticationInfo.rpID The RP ID that the authentication occurred on
|
|
51
|
+
* @param authenticationInfo?.authenticatorExtensionResults The authenticator extensions returned
|
|
52
|
+
* by the browser
|
|
53
|
+
*/
|
|
54
|
+
export type VerifiedAuthenticationResponse = {
|
|
55
|
+
verified: boolean;
|
|
56
|
+
authenticationInfo: {
|
|
57
|
+
credentialID: Uint8Array;
|
|
58
|
+
newCounter: number;
|
|
59
|
+
userVerified: boolean;
|
|
60
|
+
credentialDeviceType: CredentialDeviceType;
|
|
61
|
+
credentialBackedUp: boolean;
|
|
62
|
+
origin: string;
|
|
63
|
+
rpID: string;
|
|
64
|
+
authenticatorExtensionResults?: AuthenticationExtensionsAuthenticatorOutputs;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verifyAuthenticationResponse = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
4
|
+
const decodeClientDataJSON_js_1 = require("../helpers/decodeClientDataJSON.js");
|
|
5
|
+
const toHash_js_1 = require("../helpers/toHash.js");
|
|
6
|
+
const verifySignature_js_1 = require("../helpers/verifySignature.js");
|
|
7
|
+
const parseAuthenticatorData_js_1 = require("../helpers/parseAuthenticatorData.js");
|
|
8
|
+
const parseBackupFlags_js_1 = require("../helpers/parseBackupFlags.js");
|
|
9
|
+
const matchExpectedRPID_js_1 = require("../helpers/matchExpectedRPID.js");
|
|
10
|
+
const index_js_1 = require("../helpers/iso/index.js");
|
|
11
11
|
/**
|
|
12
12
|
* Verify that the user has legitimately completed the login process
|
|
13
13
|
*
|
|
@@ -45,10 +45,10 @@ async function verifyAuthenticationResponse(options) {
|
|
|
45
45
|
if (!response) {
|
|
46
46
|
throw new Error('Credential missing response');
|
|
47
47
|
}
|
|
48
|
-
if (typeof
|
|
48
|
+
if (typeof assertionResponse?.clientDataJSON !== 'string') {
|
|
49
49
|
throw new Error('Credential response clientDataJSON was not a string');
|
|
50
50
|
}
|
|
51
|
-
const clientDataJSON = (0,
|
|
51
|
+
const clientDataJSON = (0, decodeClientDataJSON_js_1.decodeClientDataJSON)(assertionResponse.clientDataJSON);
|
|
52
52
|
const { type, origin, challenge, tokenBinding } = clientDataJSON;
|
|
53
53
|
// Make sure we're handling an authentication
|
|
54
54
|
if (type !== 'webauthn.get') {
|
|
@@ -75,13 +75,14 @@ async function verifyAuthenticationResponse(options) {
|
|
|
75
75
|
throw new Error(`Unexpected authentication response origin "${origin}", expected "${expectedOrigin}"`);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
if (!
|
|
78
|
+
if (!index_js_1.isoBase64URL.isBase64url(assertionResponse.authenticatorData)) {
|
|
79
79
|
throw new Error('Credential response authenticatorData was not a base64url string');
|
|
80
80
|
}
|
|
81
|
-
if (!
|
|
81
|
+
if (!index_js_1.isoBase64URL.isBase64url(assertionResponse.signature)) {
|
|
82
82
|
throw new Error('Credential response signature was not a base64url string');
|
|
83
83
|
}
|
|
84
|
-
if (assertionResponse.userHandle &&
|
|
84
|
+
if (assertionResponse.userHandle &&
|
|
85
|
+
typeof assertionResponse.userHandle !== 'string') {
|
|
85
86
|
throw new Error('Credential response userHandle was not a string');
|
|
86
87
|
}
|
|
87
88
|
if (tokenBinding) {
|
|
@@ -92,8 +93,8 @@ async function verifyAuthenticationResponse(options) {
|
|
|
92
93
|
throw new Error(`Unexpected tokenBinding status ${tokenBinding.status}`);
|
|
93
94
|
}
|
|
94
95
|
}
|
|
95
|
-
const authDataBuffer =
|
|
96
|
-
const parsedAuthData = (0,
|
|
96
|
+
const authDataBuffer = index_js_1.isoBase64URL.toBuffer(assertionResponse.authenticatorData);
|
|
97
|
+
const parsedAuthData = (0, parseAuthenticatorData_js_1.parseAuthenticatorData)(authDataBuffer);
|
|
97
98
|
const { rpIdHash, flags, counter, extensionsData } = parsedAuthData;
|
|
98
99
|
// Make sure the response's RP ID is ours
|
|
99
100
|
let expectedRPIDs = [];
|
|
@@ -103,7 +104,7 @@ async function verifyAuthenticationResponse(options) {
|
|
|
103
104
|
else {
|
|
104
105
|
expectedRPIDs = expectedRPID;
|
|
105
106
|
}
|
|
106
|
-
const matchedRPID = await (0,
|
|
107
|
+
const matchedRPID = await (0, matchExpectedRPID_js_1.matchExpectedRPID)(rpIdHash, expectedRPIDs);
|
|
107
108
|
if (advancedFIDOConfig !== undefined) {
|
|
108
109
|
const { userVerification: fidoUserVerification } = advancedFIDOConfig;
|
|
109
110
|
/**
|
|
@@ -115,7 +116,8 @@ async function verifyAuthenticationResponse(options) {
|
|
|
115
116
|
throw new Error('User verification required, but user could not be verified');
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
|
-
else if (fidoUserVerification === 'preferred' ||
|
|
119
|
+
else if (fidoUserVerification === 'preferred' ||
|
|
120
|
+
fidoUserVerification === 'discouraged') {
|
|
119
121
|
// Ignore `flags.uv`
|
|
120
122
|
}
|
|
121
123
|
}
|
|
@@ -132,19 +134,20 @@ async function verifyAuthenticationResponse(options) {
|
|
|
132
134
|
throw new Error('User verification required, but user could not be verified');
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
|
-
const clientDataHash = await (0,
|
|
136
|
-
const signatureBase =
|
|
137
|
-
const signature =
|
|
138
|
-
if ((counter > 0 || authenticator.counter > 0) &&
|
|
137
|
+
const clientDataHash = await (0, toHash_js_1.toHash)(index_js_1.isoBase64URL.toBuffer(assertionResponse.clientDataJSON));
|
|
138
|
+
const signatureBase = index_js_1.isoUint8Array.concat([authDataBuffer, clientDataHash]);
|
|
139
|
+
const signature = index_js_1.isoBase64URL.toBuffer(assertionResponse.signature);
|
|
140
|
+
if ((counter > 0 || authenticator.counter > 0) &&
|
|
141
|
+
counter <= authenticator.counter) {
|
|
139
142
|
// Error out when the counter in the DB is greater than or equal to the counter in the
|
|
140
143
|
// dataStruct. It's related to how the authenticator maintains the number of times its been
|
|
141
144
|
// used for this client. If this happens, then someone's somehow increased the counter
|
|
142
145
|
// on the device without going through this site
|
|
143
146
|
throw new Error(`Response counter value ${counter} was lower than expected ${authenticator.counter}`);
|
|
144
147
|
}
|
|
145
|
-
const { credentialDeviceType, credentialBackedUp } = (0,
|
|
148
|
+
const { credentialDeviceType, credentialBackedUp } = (0, parseBackupFlags_js_1.parseBackupFlags)(flags);
|
|
146
149
|
const toReturn = {
|
|
147
|
-
verified: await (0,
|
|
150
|
+
verified: await (0, verifySignature_js_1.verifySignature)({
|
|
148
151
|
signature,
|
|
149
152
|
data: signatureBase,
|
|
150
153
|
credentialPublicKey: authenticator.credentialPublicKey,
|
|
@@ -163,4 +166,3 @@ async function verifyAuthenticationResponse(options) {
|
|
|
163
166
|
return toReturn;
|
|
164
167
|
}
|
|
165
168
|
exports.verifyAuthenticationResponse = verifyAuthenticationResponse;
|
|
166
|
-
//# sourceMappingURL=verifyAuthenticationResponse.js.map
|
package/script/deps.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { AttestationConveyancePreference, AuthenticationExtensionsClientInputs, AuthenticationResponseJSON, AuthenticatorDevice, AuthenticatorSelectionCriteria, Base64URLString, COSEAlgorithmIdentifier, CredentialDeviceType, Crypto, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialDescriptorFuture, PublicKeyCredentialParameters, PublicKeyCredentialRequestOptionsJSON, RegistrationResponseJSON, UserVerificationRequirement, } from '@simplewebauthn/typescript-types';
|
|
2
|
+
export * as cborx from 'cbor-x';
|
|
3
|
+
export { fetch as crossFetch } from 'cross-fetch';
|
|
4
|
+
export { default as debug } from 'debug';
|
|
5
|
+
export type { Debugger } from '@types/debug';
|
|
6
|
+
export { AsnParser, AsnSerializer } from '@peculiar/asn1-schema';
|
|
7
|
+
export { AuthorityKeyIdentifier, BasicConstraints, Certificate, CertificateList, CRLDistributionPoints, ExtendedKeyUsage, id_ce_authorityKeyIdentifier, id_ce_basicConstraints, id_ce_cRLDistributionPoints, id_ce_extKeyUsage, id_ce_subjectAltName, id_ce_subjectKeyIdentifier, Name, SubjectAlternativeName, SubjectKeyIdentifier, } from '@peculiar/asn1-x509';
|
|
8
|
+
export { ECDSASigValue, ECParameters, id_ecPublicKey, id_secp256r1, id_secp384r1, } from '@peculiar/asn1-ecc';
|
|
9
|
+
export { RSAPublicKey } from '@peculiar/asn1-rsa';
|
|
10
|
+
export { id_ce_keyDescription, KeyDescription } from '@peculiar/asn1-android';
|
package/script/deps.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.KeyDescription = exports.id_ce_keyDescription = exports.RSAPublicKey = exports.id_secp384r1 = exports.id_secp256r1 = exports.id_ecPublicKey = exports.ECParameters = exports.ECDSASigValue = exports.SubjectKeyIdentifier = exports.SubjectAlternativeName = exports.Name = exports.id_ce_subjectKeyIdentifier = exports.id_ce_subjectAltName = exports.id_ce_extKeyUsage = exports.id_ce_cRLDistributionPoints = exports.id_ce_basicConstraints = exports.id_ce_authorityKeyIdentifier = exports.ExtendedKeyUsage = exports.CRLDistributionPoints = exports.CertificateList = exports.Certificate = exports.BasicConstraints = exports.AuthorityKeyIdentifier = exports.AsnSerializer = exports.AsnParser = exports.debug = exports.crossFetch = exports.cborx = void 0;
|
|
30
|
+
// cbor (a.k.a. cbor-x in Node land)
|
|
31
|
+
exports.cborx = __importStar(require("cbor-x"));
|
|
32
|
+
// cross-fetch
|
|
33
|
+
var cross_fetch_1 = require("cross-fetch");
|
|
34
|
+
Object.defineProperty(exports, "crossFetch", { enumerable: true, get: function () { return cross_fetch_1.fetch; } });
|
|
35
|
+
// debug
|
|
36
|
+
var debug_1 = require("debug");
|
|
37
|
+
Object.defineProperty(exports, "debug", { enumerable: true, get: function () { return __importDefault(debug_1).default; } });
|
|
38
|
+
// @peculiar libraries
|
|
39
|
+
var asn1_schema_1 = require("@peculiar/asn1-schema");
|
|
40
|
+
Object.defineProperty(exports, "AsnParser", { enumerable: true, get: function () { return asn1_schema_1.AsnParser; } });
|
|
41
|
+
Object.defineProperty(exports, "AsnSerializer", { enumerable: true, get: function () { return asn1_schema_1.AsnSerializer; } });
|
|
42
|
+
var asn1_x509_1 = require("@peculiar/asn1-x509");
|
|
43
|
+
Object.defineProperty(exports, "AuthorityKeyIdentifier", { enumerable: true, get: function () { return asn1_x509_1.AuthorityKeyIdentifier; } });
|
|
44
|
+
Object.defineProperty(exports, "BasicConstraints", { enumerable: true, get: function () { return asn1_x509_1.BasicConstraints; } });
|
|
45
|
+
Object.defineProperty(exports, "Certificate", { enumerable: true, get: function () { return asn1_x509_1.Certificate; } });
|
|
46
|
+
Object.defineProperty(exports, "CertificateList", { enumerable: true, get: function () { return asn1_x509_1.CertificateList; } });
|
|
47
|
+
Object.defineProperty(exports, "CRLDistributionPoints", { enumerable: true, get: function () { return asn1_x509_1.CRLDistributionPoints; } });
|
|
48
|
+
Object.defineProperty(exports, "ExtendedKeyUsage", { enumerable: true, get: function () { return asn1_x509_1.ExtendedKeyUsage; } });
|
|
49
|
+
Object.defineProperty(exports, "id_ce_authorityKeyIdentifier", { enumerable: true, get: function () { return asn1_x509_1.id_ce_authorityKeyIdentifier; } });
|
|
50
|
+
Object.defineProperty(exports, "id_ce_basicConstraints", { enumerable: true, get: function () { return asn1_x509_1.id_ce_basicConstraints; } });
|
|
51
|
+
Object.defineProperty(exports, "id_ce_cRLDistributionPoints", { enumerable: true, get: function () { return asn1_x509_1.id_ce_cRLDistributionPoints; } });
|
|
52
|
+
Object.defineProperty(exports, "id_ce_extKeyUsage", { enumerable: true, get: function () { return asn1_x509_1.id_ce_extKeyUsage; } });
|
|
53
|
+
Object.defineProperty(exports, "id_ce_subjectAltName", { enumerable: true, get: function () { return asn1_x509_1.id_ce_subjectAltName; } });
|
|
54
|
+
Object.defineProperty(exports, "id_ce_subjectKeyIdentifier", { enumerable: true, get: function () { return asn1_x509_1.id_ce_subjectKeyIdentifier; } });
|
|
55
|
+
Object.defineProperty(exports, "Name", { enumerable: true, get: function () { return asn1_x509_1.Name; } });
|
|
56
|
+
Object.defineProperty(exports, "SubjectAlternativeName", { enumerable: true, get: function () { return asn1_x509_1.SubjectAlternativeName; } });
|
|
57
|
+
Object.defineProperty(exports, "SubjectKeyIdentifier", { enumerable: true, get: function () { return asn1_x509_1.SubjectKeyIdentifier; } });
|
|
58
|
+
var asn1_ecc_1 = require("@peculiar/asn1-ecc");
|
|
59
|
+
Object.defineProperty(exports, "ECDSASigValue", { enumerable: true, get: function () { return asn1_ecc_1.ECDSASigValue; } });
|
|
60
|
+
Object.defineProperty(exports, "ECParameters", { enumerable: true, get: function () { return asn1_ecc_1.ECParameters; } });
|
|
61
|
+
Object.defineProperty(exports, "id_ecPublicKey", { enumerable: true, get: function () { return asn1_ecc_1.id_ecPublicKey; } });
|
|
62
|
+
Object.defineProperty(exports, "id_secp256r1", { enumerable: true, get: function () { return asn1_ecc_1.id_secp256r1; } });
|
|
63
|
+
Object.defineProperty(exports, "id_secp384r1", { enumerable: true, get: function () { return asn1_ecc_1.id_secp384r1; } });
|
|
64
|
+
var asn1_rsa_1 = require("@peculiar/asn1-rsa");
|
|
65
|
+
Object.defineProperty(exports, "RSAPublicKey", { enumerable: true, get: function () { return asn1_rsa_1.RSAPublicKey; } });
|
|
66
|
+
var asn1_android_1 = require("@peculiar/asn1-android");
|
|
67
|
+
Object.defineProperty(exports, "id_ce_keyDescription", { enumerable: true, get: function () { return asn1_android_1.id_ce_keyDescription; } });
|
|
68
|
+
Object.defineProperty(exports, "KeyDescription", { enumerable: true, get: function () { return asn1_android_1.KeyDescription; } });
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertAAGUIDToString = void 0;
|
|
4
|
-
const
|
|
4
|
+
const index_js_1 = require("./iso/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Convert the aaguid buffer in authData into a UUID string
|
|
7
7
|
*/
|
|
8
8
|
function convertAAGUIDToString(aaguid) {
|
|
9
9
|
// Raw Hex: adce000235bcc60a648b0b25f1f05503
|
|
10
|
-
const hex =
|
|
10
|
+
const hex = index_js_1.isoUint8Array.toHex(aaguid);
|
|
11
11
|
const segments = [
|
|
12
12
|
hex.slice(0, 8),
|
|
13
13
|
hex.slice(8, 12),
|
|
@@ -19,4 +19,3 @@ function convertAAGUIDToString(aaguid) {
|
|
|
19
19
|
return segments.join('-');
|
|
20
20
|
}
|
|
21
21
|
exports.convertAAGUIDToString = convertAAGUIDToString;
|
|
22
|
-
//# sourceMappingURL=convertAAGUIDToString.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertCOSEtoPKCS = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const index_js_1 = require("./iso/index.js");
|
|
5
|
+
const cose_js_1 = require("./cose.js");
|
|
6
6
|
/**
|
|
7
7
|
* Takes COSE-encoded public key and converts it to PKCS key
|
|
8
8
|
*/
|
|
@@ -10,17 +10,16 @@ function convertCOSEtoPKCS(cosePublicKey) {
|
|
|
10
10
|
// This is a little sloppy, I'm using COSEPublicKeyEC2 since it could have both x and y, but when
|
|
11
11
|
// there's no y it means it's probably better typed as COSEPublicKeyOKP. I'll leave this for now
|
|
12
12
|
// and revisit it later if it ever becomes an actual problem.
|
|
13
|
-
const struct =
|
|
13
|
+
const struct = index_js_1.isoCBOR.decodeFirst(cosePublicKey);
|
|
14
14
|
const tag = Uint8Array.from([0x04]);
|
|
15
|
-
const x = struct.get(
|
|
16
|
-
const y = struct.get(
|
|
15
|
+
const x = struct.get(cose_js_1.COSEKEYS.x);
|
|
16
|
+
const y = struct.get(cose_js_1.COSEKEYS.y);
|
|
17
17
|
if (!x) {
|
|
18
18
|
throw new Error('COSE public key was missing x');
|
|
19
19
|
}
|
|
20
20
|
if (y) {
|
|
21
|
-
return
|
|
21
|
+
return index_js_1.isoUint8Array.concat([tag, x, y]);
|
|
22
22
|
}
|
|
23
|
-
return
|
|
23
|
+
return index_js_1.isoUint8Array.concat([tag, x]);
|
|
24
24
|
}
|
|
25
25
|
exports.convertCOSEtoPKCS = convertCOSEtoPKCS;
|
|
26
|
-
//# sourceMappingURL=convertCOSEtoPKCS.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertCertBufferToPEM = void 0;
|
|
4
|
-
const
|
|
4
|
+
const index_js_1 = require("./iso/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Convert buffer to an OpenSSL-compatible PEM text format.
|
|
7
7
|
*/
|
|
@@ -11,10 +11,10 @@ function convertCertBufferToPEM(certBuffer) {
|
|
|
11
11
|
* Get certBuffer to a base64 representation
|
|
12
12
|
*/
|
|
13
13
|
if (typeof certBuffer === 'string') {
|
|
14
|
-
if (
|
|
15
|
-
b64cert =
|
|
14
|
+
if (index_js_1.isoBase64URL.isBase64url(certBuffer)) {
|
|
15
|
+
b64cert = index_js_1.isoBase64URL.toBase64(certBuffer);
|
|
16
16
|
}
|
|
17
|
-
else if (
|
|
17
|
+
else if (index_js_1.isoBase64URL.isBase64(certBuffer)) {
|
|
18
18
|
b64cert = certBuffer;
|
|
19
19
|
}
|
|
20
20
|
else {
|
|
@@ -22,7 +22,7 @@ function convertCertBufferToPEM(certBuffer) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
b64cert =
|
|
25
|
+
b64cert = index_js_1.isoBase64URL.fromBuffer(certBuffer, 'base64');
|
|
26
26
|
}
|
|
27
27
|
let PEMKey = '';
|
|
28
28
|
for (let i = 0; i < Math.ceil(b64cert.length / 64); i += 1) {
|
|
@@ -33,4 +33,3 @@ function convertCertBufferToPEM(certBuffer) {
|
|
|
33
33
|
return PEMKey;
|
|
34
34
|
}
|
|
35
35
|
exports.convertCertBufferToPEM = convertCertBufferToPEM;
|
|
36
|
-
//# sourceMappingURL=convertCertBufferToPEM.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertPEMToBytes = void 0;
|
|
4
|
-
const
|
|
4
|
+
const index_js_1 = require("./iso/index.js");
|
|
5
5
|
/**
|
|
6
6
|
* Take a certificate in PEM format and convert it to bytes
|
|
7
7
|
*/
|
|
@@ -10,7 +10,6 @@ function convertPEMToBytes(pem) {
|
|
|
10
10
|
.replace('-----BEGIN CERTIFICATE-----', '')
|
|
11
11
|
.replace('-----END CERTIFICATE-----', '')
|
|
12
12
|
.replace(/[\n ]/g, '');
|
|
13
|
-
return
|
|
13
|
+
return index_js_1.isoBase64URL.toBuffer(certBase64, 'base64');
|
|
14
14
|
}
|
|
15
15
|
exports.convertPEMToBytes = convertPEMToBytes;
|
|
16
|
-
//# sourceMappingURL=convertPEMToBytes.js.map
|
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.convertX509PublicKeyToCOSE = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const asn1_rsa_1 = require("@peculiar/asn1-rsa");
|
|
8
|
-
const cose_1 = require("./cose");
|
|
9
|
-
const mapX509SignatureAlgToCOSEAlg_1 = require("./mapX509SignatureAlgToCOSEAlg");
|
|
4
|
+
const deps_js_1 = require("../deps.js");
|
|
5
|
+
const cose_js_1 = require("./cose.js");
|
|
6
|
+
const mapX509SignatureAlgToCOSEAlg_js_1 = require("./mapX509SignatureAlgToCOSEAlg.js");
|
|
10
7
|
function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
11
8
|
let cosePublicKey = new Map();
|
|
12
9
|
/**
|
|
13
10
|
* Time to extract the public key from an X.509 certificate
|
|
14
11
|
*/
|
|
15
|
-
const x509 =
|
|
12
|
+
const x509 = deps_js_1.AsnParser.parse(x509Certificate, deps_js_1.Certificate);
|
|
16
13
|
const { tbsCertificate } = x509;
|
|
17
14
|
const { subjectPublicKeyInfo, signature: _tbsSignature } = tbsCertificate;
|
|
18
15
|
const signatureAlgorithm = _tbsSignature.algorithm;
|
|
19
16
|
const publicKeyAlgorithmID = subjectPublicKeyInfo.algorithm.algorithm;
|
|
20
|
-
if (publicKeyAlgorithmID ===
|
|
17
|
+
if (publicKeyAlgorithmID === deps_js_1.id_ecPublicKey) {
|
|
21
18
|
/**
|
|
22
19
|
* EC2 Public Key
|
|
23
20
|
*/
|
|
24
21
|
if (!subjectPublicKeyInfo.algorithm.parameters) {
|
|
25
22
|
throw new Error('Certificate public key was missing parameters (EC2)');
|
|
26
23
|
}
|
|
27
|
-
const ecParameters =
|
|
24
|
+
const ecParameters = deps_js_1.AsnParser.parse(new Uint8Array(subjectPublicKeyInfo.algorithm.parameters), deps_js_1.ECParameters);
|
|
28
25
|
let crv = -999;
|
|
29
26
|
const { namedCurve } = ecParameters;
|
|
30
|
-
if (namedCurve ===
|
|
31
|
-
crv =
|
|
27
|
+
if (namedCurve === deps_js_1.id_secp256r1) {
|
|
28
|
+
crv = cose_js_1.COSECRV.P256;
|
|
32
29
|
}
|
|
33
|
-
else if (namedCurve ===
|
|
34
|
-
crv =
|
|
30
|
+
else if (namedCurve === deps_js_1.id_secp384r1) {
|
|
31
|
+
crv = cose_js_1.COSECRV.P384;
|
|
35
32
|
}
|
|
36
33
|
else {
|
|
37
34
|
throw new Error(`Certificate public key contained unexpected namedCurve ${namedCurve} (EC2)`);
|
|
@@ -43,30 +40,30 @@ function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
43
40
|
// Public key is in "uncompressed form", so we can split the remaining bytes in half
|
|
44
41
|
let pointer = 1;
|
|
45
42
|
const halfLength = (subjectPublicKey.length - 1) / 2;
|
|
46
|
-
x = subjectPublicKey.slice(pointer,
|
|
43
|
+
x = subjectPublicKey.slice(pointer, pointer += halfLength);
|
|
47
44
|
y = subjectPublicKey.slice(pointer);
|
|
48
45
|
}
|
|
49
46
|
else {
|
|
50
47
|
throw new Error('TODO: Figure out how to handle public keys in "compressed form"');
|
|
51
48
|
}
|
|
52
49
|
const coseEC2PubKey = new Map();
|
|
53
|
-
coseEC2PubKey.set(
|
|
54
|
-
coseEC2PubKey.set(
|
|
55
|
-
coseEC2PubKey.set(
|
|
56
|
-
coseEC2PubKey.set(
|
|
57
|
-
coseEC2PubKey.set(
|
|
50
|
+
coseEC2PubKey.set(cose_js_1.COSEKEYS.kty, cose_js_1.COSEKTY.EC2);
|
|
51
|
+
coseEC2PubKey.set(cose_js_1.COSEKEYS.alg, (0, mapX509SignatureAlgToCOSEAlg_js_1.mapX509SignatureAlgToCOSEAlg)(signatureAlgorithm));
|
|
52
|
+
coseEC2PubKey.set(cose_js_1.COSEKEYS.crv, crv);
|
|
53
|
+
coseEC2PubKey.set(cose_js_1.COSEKEYS.x, x);
|
|
54
|
+
coseEC2PubKey.set(cose_js_1.COSEKEYS.y, y);
|
|
58
55
|
cosePublicKey = coseEC2PubKey;
|
|
59
56
|
}
|
|
60
57
|
else if (publicKeyAlgorithmID === '1.2.840.113549.1.1.1') {
|
|
61
58
|
/**
|
|
62
59
|
* RSA public key
|
|
63
60
|
*/
|
|
64
|
-
const rsaPublicKey =
|
|
61
|
+
const rsaPublicKey = deps_js_1.AsnParser.parse(subjectPublicKeyInfo.subjectPublicKey, deps_js_1.RSAPublicKey);
|
|
65
62
|
const coseRSAPubKey = new Map();
|
|
66
|
-
coseRSAPubKey.set(
|
|
67
|
-
coseRSAPubKey.set(
|
|
68
|
-
coseRSAPubKey.set(
|
|
69
|
-
coseRSAPubKey.set(
|
|
63
|
+
coseRSAPubKey.set(cose_js_1.COSEKEYS.kty, cose_js_1.COSEKTY.RSA);
|
|
64
|
+
coseRSAPubKey.set(cose_js_1.COSEKEYS.alg, (0, mapX509SignatureAlgToCOSEAlg_js_1.mapX509SignatureAlgToCOSEAlg)(signatureAlgorithm));
|
|
65
|
+
coseRSAPubKey.set(cose_js_1.COSEKEYS.n, new Uint8Array(rsaPublicKey.modulus));
|
|
66
|
+
coseRSAPubKey.set(cose_js_1.COSEKEYS.e, new Uint8Array(rsaPublicKey.publicExponent));
|
|
70
67
|
cosePublicKey = coseRSAPubKey;
|
|
71
68
|
}
|
|
72
69
|
else {
|
|
@@ -75,4 +72,3 @@ function convertX509PublicKeyToCOSE(x509Certificate) {
|
|
|
75
72
|
return cosePublicKey;
|
|
76
73
|
}
|
|
77
74
|
exports.convertX509PublicKeyToCOSE = convertX509PublicKeyToCOSE;
|
|
78
|
-
//# sourceMappingURL=convertX509PublicKeyToCOSE.js.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fundamental values that are needed to discern the more specific COSE public key types below.
|
|
3
|
+
*
|
|
4
|
+
* The use of `Maps` here is due to CBOR encoding being used with public keys, and the CBOR "Map"
|
|
5
|
+
* type is being decoded to JavaScript's `Map` type instead of, say, a basic Object as us JS
|
|
6
|
+
* developers might prefer.
|
|
7
|
+
*
|
|
8
|
+
* These types are an unorthodox way of saying "these Maps should involve these discrete lists of
|
|
9
|
+
* keys", but it works.
|
|
10
|
+
*/
|
|
11
|
+
export type COSEPublicKey = {
|
|
12
|
+
get(key: COSEKEYS.kty): COSEKTY | undefined;
|
|
13
|
+
get(key: COSEKEYS.alg): COSEALG | undefined;
|
|
14
|
+
set(key: COSEKEYS.kty, value: COSEKTY): void;
|
|
15
|
+
set(key: COSEKEYS.alg, value: COSEALG): void;
|
|
16
|
+
};
|
|
17
|
+
export type COSEPublicKeyOKP = COSEPublicKey & {
|
|
18
|
+
get(key: COSEKEYS.crv): number | undefined;
|
|
19
|
+
get(key: COSEKEYS.x): Uint8Array | undefined;
|
|
20
|
+
set(key: COSEKEYS.crv, value: number): void;
|
|
21
|
+
set(key: COSEKEYS.x, value: Uint8Array): void;
|
|
22
|
+
};
|
|
23
|
+
export type COSEPublicKeyEC2 = COSEPublicKey & {
|
|
24
|
+
get(key: COSEKEYS.crv): number | undefined;
|
|
25
|
+
get(key: COSEKEYS.x): Uint8Array | undefined;
|
|
26
|
+
get(key: COSEKEYS.y): Uint8Array | undefined;
|
|
27
|
+
set(key: COSEKEYS.crv, value: number): void;
|
|
28
|
+
set(key: COSEKEYS.x, value: Uint8Array): void;
|
|
29
|
+
set(key: COSEKEYS.y, value: Uint8Array): void;
|
|
30
|
+
};
|
|
31
|
+
export type COSEPublicKeyRSA = COSEPublicKey & {
|
|
32
|
+
get(key: COSEKEYS.n): Uint8Array | undefined;
|
|
33
|
+
get(key: COSEKEYS.e): Uint8Array | undefined;
|
|
34
|
+
set(key: COSEKEYS.n, value: Uint8Array): void;
|
|
35
|
+
set(key: COSEKEYS.e, value: Uint8Array): void;
|
|
36
|
+
};
|
|
37
|
+
export declare function isCOSEPublicKeyOKP(cosePublicKey: COSEPublicKey): cosePublicKey is COSEPublicKeyOKP;
|
|
38
|
+
export declare function isCOSEPublicKeyEC2(cosePublicKey: COSEPublicKey): cosePublicKey is COSEPublicKeyEC2;
|
|
39
|
+
export declare function isCOSEPublicKeyRSA(cosePublicKey: COSEPublicKey): cosePublicKey is COSEPublicKeyRSA;
|
|
40
|
+
/**
|
|
41
|
+
* COSE Keys
|
|
42
|
+
*
|
|
43
|
+
* https://www.iana.org/assignments/cose/cose.xhtml#key-common-parameters
|
|
44
|
+
* https://www.iana.org/assignments/cose/cose.xhtml#key-type-parameters
|
|
45
|
+
*/
|
|
46
|
+
export declare enum COSEKEYS {
|
|
47
|
+
kty = 1,
|
|
48
|
+
alg = 3,
|
|
49
|
+
crv = -1,
|
|
50
|
+
x = -2,
|
|
51
|
+
y = -3,
|
|
52
|
+
n = -1,
|
|
53
|
+
e = -2
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* COSE Key Types
|
|
57
|
+
*
|
|
58
|
+
* https://www.iana.org/assignments/cose/cose.xhtml#key-type
|
|
59
|
+
*/
|
|
60
|
+
export declare enum COSEKTY {
|
|
61
|
+
OKP = 1,
|
|
62
|
+
EC2 = 2,
|
|
63
|
+
RSA = 3
|
|
64
|
+
}
|
|
65
|
+
export declare function isCOSEKty(kty: number | undefined): kty is COSEKTY;
|
|
66
|
+
/**
|
|
67
|
+
* COSE Curves
|
|
68
|
+
*
|
|
69
|
+
* https://www.iana.org/assignments/cose/cose.xhtml#elliptic-curves
|
|
70
|
+
*/
|
|
71
|
+
export declare enum COSECRV {
|
|
72
|
+
P256 = 1,
|
|
73
|
+
P384 = 2,
|
|
74
|
+
P521 = 3,
|
|
75
|
+
ED25519 = 6,
|
|
76
|
+
SECP256K1 = 8
|
|
77
|
+
}
|
|
78
|
+
export declare function isCOSECrv(crv: number | undefined): crv is COSECRV;
|
|
79
|
+
/**
|
|
80
|
+
* COSE Algorithms
|
|
81
|
+
*
|
|
82
|
+
* https://www.iana.org/assignments/cose/cose.xhtml#algorithms
|
|
83
|
+
*/
|
|
84
|
+
export declare enum COSEALG {
|
|
85
|
+
ES256 = -7,
|
|
86
|
+
EdDSA = -8,
|
|
87
|
+
ES384 = -35,
|
|
88
|
+
ES512 = -36,
|
|
89
|
+
PS256 = -37,
|
|
90
|
+
PS384 = -38,
|
|
91
|
+
PS512 = -39,
|
|
92
|
+
ES256K = -47,
|
|
93
|
+
RS256 = -257,
|
|
94
|
+
RS384 = -258,
|
|
95
|
+
RS512 = -259,
|
|
96
|
+
RS1 = -65535
|
|
97
|
+
}
|
|
98
|
+
export declare function isCOSEAlg(alg: number | undefined): alg is COSEALG;
|
|
@@ -58,6 +58,7 @@ var COSECRV;
|
|
|
58
58
|
COSECRV[COSECRV["P384"] = 2] = "P384";
|
|
59
59
|
COSECRV[COSECRV["P521"] = 3] = "P521";
|
|
60
60
|
COSECRV[COSECRV["ED25519"] = 6] = "ED25519";
|
|
61
|
+
COSECRV[COSECRV["SECP256K1"] = 8] = "SECP256K1";
|
|
61
62
|
})(COSECRV = exports.COSECRV || (exports.COSECRV = {}));
|
|
62
63
|
function isCOSECrv(crv) {
|
|
63
64
|
return Object.values(COSECRV).indexOf(crv) >= 0;
|
|
@@ -87,4 +88,3 @@ function isCOSEAlg(alg) {
|
|
|
87
88
|
return Object.values(COSEALG).indexOf(alg) >= 0;
|
|
88
89
|
}
|
|
89
90
|
exports.isCOSEAlg = isCOSEAlg;
|
|
90
|
-
//# sourceMappingURL=cose.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an AttestationObject buffer to a proper object
|
|
3
|
+
*
|
|
4
|
+
* @param base64AttestationObject Attestation Object buffer
|
|
5
|
+
*/
|
|
6
|
+
export declare function decodeAttestationObject(attestationObject: Uint8Array): AttestationObject;
|
|
7
|
+
export type AttestationFormat = 'fido-u2f' | 'packed' | 'android-safetynet' | 'android-key' | 'tpm' | 'apple' | 'none';
|
|
8
|
+
export type AttestationObject = {
|
|
9
|
+
get(key: 'fmt'): AttestationFormat;
|
|
10
|
+
get(key: 'attStmt'): AttestationStatement;
|
|
11
|
+
get(key: 'authData'): Uint8Array;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* `AttestationStatement` will be an instance of `Map`, but these keys help make finite the list of
|
|
15
|
+
* possible values within it.
|
|
16
|
+
*/
|
|
17
|
+
export type AttestationStatement = {
|
|
18
|
+
get(key: 'sig'): Uint8Array | undefined;
|
|
19
|
+
get(key: 'x5c'): Uint8Array[] | undefined;
|
|
20
|
+
get(key: 'response'): Uint8Array | undefined;
|
|
21
|
+
get(key: 'alg'): number | undefined;
|
|
22
|
+
get(key: 'ver'): string | undefined;
|
|
23
|
+
get(key: 'certInfo'): Uint8Array | undefined;
|
|
24
|
+
get(key: 'pubArea'): Uint8Array | undefined;
|
|
25
|
+
readonly size: number;
|
|
26
|
+
};
|
|
27
|
+
export declare const _decodeAttestationObjectInternals: {
|
|
28
|
+
stubThis: (value: AttestationObject) => AttestationObject;
|
|
29
|
+
};
|