@simplewebauthn/server 7.4.0 → 8.0.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 +20 -7
- 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 +11 -0
- package/esm/deps.js +14 -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 -42
- 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 +11 -0
- package/script/deps.js +71 -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 +9 -13
- 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,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRandomValues = void 0;
|
|
4
|
+
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
5
|
+
/**
|
|
6
|
+
* Fill up the provided bytes array with random bytes equal to its length.
|
|
7
|
+
*
|
|
8
|
+
* @returns the same bytes array passed into the method
|
|
9
|
+
*/
|
|
10
|
+
async function getRandomValues(array) {
|
|
11
|
+
const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)();
|
|
12
|
+
WebCrypto.getRandomValues(array);
|
|
13
|
+
return array;
|
|
14
|
+
}
|
|
15
|
+
exports.getRandomValues = getRandomValues;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWebCrypto = void 0;
|
|
4
|
+
let webCrypto = undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Try to get an instance of the Crypto API from the current runtime. Should support Node,
|
|
7
|
+
* as well as others, like Deno, that implement Web APIs.
|
|
8
|
+
*/
|
|
9
|
+
async function getWebCrypto() {
|
|
10
|
+
if (webCrypto) {
|
|
11
|
+
return webCrypto;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
/**
|
|
15
|
+
* Naively attempt a Node import...
|
|
16
|
+
*/
|
|
17
|
+
// @ts-ignore: We'll handle any errors...
|
|
18
|
+
// dnt-shim-ignore
|
|
19
|
+
const _crypto = await require('node:crypto');
|
|
20
|
+
webCrypto = _crypto.webcrypto;
|
|
21
|
+
}
|
|
22
|
+
catch (_err) {
|
|
23
|
+
/**
|
|
24
|
+
* Naively attempt to access Crypto as a global object, which popular alternative run-times
|
|
25
|
+
* support.
|
|
26
|
+
*/
|
|
27
|
+
// @ts-ignore: ...right here.
|
|
28
|
+
const _crypto = globalThis.crypto;
|
|
29
|
+
if (!_crypto) {
|
|
30
|
+
// We tried to access it both in Node and globally, so bail out
|
|
31
|
+
throw new MissingWebCrypto();
|
|
32
|
+
}
|
|
33
|
+
webCrypto = _crypto;
|
|
34
|
+
}
|
|
35
|
+
return webCrypto;
|
|
36
|
+
}
|
|
37
|
+
exports.getWebCrypto = getWebCrypto;
|
|
38
|
+
class MissingWebCrypto extends Error {
|
|
39
|
+
constructor() {
|
|
40
|
+
const message = 'An instance of the Crypto API could not be located';
|
|
41
|
+
super(message);
|
|
42
|
+
this.name = 'MissingWebCrypto';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.importKey = void 0;
|
|
4
|
+
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
5
|
+
async function importKey(opts) {
|
|
6
|
+
const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)();
|
|
7
|
+
const { keyData, algorithm } = opts;
|
|
8
|
+
return WebCrypto.subtle.importKey('jwk', keyData, algorithm, false, [
|
|
9
|
+
'verify',
|
|
10
|
+
]);
|
|
11
|
+
}
|
|
12
|
+
exports.importKey = importKey;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.verify = exports.getRandomValues = exports.digest = void 0;
|
|
4
|
-
var
|
|
5
|
-
Object.defineProperty(exports, "digest", { enumerable: true, get: function () { return
|
|
6
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "getRandomValues", { enumerable: true, get: function () { return
|
|
8
|
-
var
|
|
9
|
-
Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
|
4
|
+
var digest_js_1 = require("./digest.js");
|
|
5
|
+
Object.defineProperty(exports, "digest", { enumerable: true, get: function () { return digest_js_1.digest; } });
|
|
6
|
+
var getRandomValues_js_1 = require("./getRandomValues.js");
|
|
7
|
+
Object.defineProperty(exports, "getRandomValues", { enumerable: true, get: function () { return getRandomValues_js_1.getRandomValues; } });
|
|
8
|
+
var verify_js_1 = require("./verify.js");
|
|
9
|
+
Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return verify_js_1.verify; } });
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SubtleCryptoAlg } from './structs.js';
|
|
2
|
+
import { COSEALG } from '../../cose.js';
|
|
3
|
+
/**
|
|
4
|
+
* Convert a COSE alg ID into a corresponding string value that WebCrypto APIs expect
|
|
5
|
+
*/
|
|
6
|
+
export declare function mapCoseAlgToWebCryptoAlg(alg: COSEALG): SubtleCryptoAlg;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapCoseAlgToWebCryptoAlg = void 0;
|
|
4
|
-
const
|
|
4
|
+
const cose_js_1 = require("../../cose.js");
|
|
5
5
|
/**
|
|
6
6
|
* Convert a COSE alg ID into a corresponding string value that WebCrypto APIs expect
|
|
7
7
|
*/
|
|
8
8
|
function mapCoseAlgToWebCryptoAlg(alg) {
|
|
9
|
-
if ([
|
|
9
|
+
if ([cose_js_1.COSEALG.RS1].indexOf(alg) >= 0) {
|
|
10
10
|
return 'SHA-1';
|
|
11
11
|
}
|
|
12
|
-
else if ([
|
|
12
|
+
else if ([cose_js_1.COSEALG.ES256, cose_js_1.COSEALG.PS256, cose_js_1.COSEALG.RS256].indexOf(alg) >= 0) {
|
|
13
13
|
return 'SHA-256';
|
|
14
14
|
}
|
|
15
|
-
else if ([
|
|
15
|
+
else if ([cose_js_1.COSEALG.ES384, cose_js_1.COSEALG.PS384, cose_js_1.COSEALG.RS384].indexOf(alg) >= 0) {
|
|
16
16
|
return 'SHA-384';
|
|
17
17
|
}
|
|
18
|
-
else if ([
|
|
18
|
+
else if ([cose_js_1.COSEALG.ES512, cose_js_1.COSEALG.PS512, cose_js_1.COSEALG.RS512, cose_js_1.COSEALG.EdDSA].indexOf(alg) >=
|
|
19
|
+
0) {
|
|
19
20
|
return 'SHA-512';
|
|
20
21
|
}
|
|
21
22
|
throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto alg`);
|
|
22
23
|
}
|
|
23
24
|
exports.mapCoseAlgToWebCryptoAlg = mapCoseAlgToWebCryptoAlg;
|
|
24
|
-
//# sourceMappingURL=mapCoseAlgToWebCryptoAlg.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { COSEALG } from '../../cose.js';
|
|
2
|
+
import { SubtleCryptoKeyAlgName } from './structs.js';
|
|
3
|
+
/**
|
|
4
|
+
* Convert a COSE alg ID into a corresponding key algorithm string value that WebCrypto APIs expect
|
|
5
|
+
*/
|
|
6
|
+
export declare function mapCoseAlgToWebCryptoKeyAlgName(alg: COSEALG): SubtleCryptoKeyAlgName;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mapCoseAlgToWebCryptoKeyAlgName = void 0;
|
|
4
|
-
const
|
|
4
|
+
const cose_js_1 = require("../../cose.js");
|
|
5
5
|
/**
|
|
6
6
|
* Convert a COSE alg ID into a corresponding key algorithm string value that WebCrypto APIs expect
|
|
7
7
|
*/
|
|
8
8
|
function mapCoseAlgToWebCryptoKeyAlgName(alg) {
|
|
9
|
-
if ([
|
|
9
|
+
if ([cose_js_1.COSEALG.EdDSA].indexOf(alg) >= 0) {
|
|
10
10
|
return 'Ed25519';
|
|
11
11
|
}
|
|
12
|
-
else if ([
|
|
12
|
+
else if ([cose_js_1.COSEALG.ES256, cose_js_1.COSEALG.ES384, cose_js_1.COSEALG.ES512, cose_js_1.COSEALG.ES256K].indexOf(alg) >= 0) {
|
|
13
13
|
return 'ECDSA';
|
|
14
14
|
}
|
|
15
|
-
else if ([
|
|
15
|
+
else if ([cose_js_1.COSEALG.RS256, cose_js_1.COSEALG.RS384, cose_js_1.COSEALG.RS512, cose_js_1.COSEALG.RS1].indexOf(alg) >= 0) {
|
|
16
16
|
return 'RSASSA-PKCS1-v1_5';
|
|
17
17
|
}
|
|
18
|
-
else if ([
|
|
18
|
+
else if ([cose_js_1.COSEALG.PS256, cose_js_1.COSEALG.PS384, cose_js_1.COSEALG.PS512].indexOf(alg) >= 0) {
|
|
19
19
|
return 'RSA-PSS';
|
|
20
20
|
}
|
|
21
21
|
throw new Error(`Could not map COSE alg value of ${alg} to a WebCrypto key alg name`);
|
|
22
22
|
}
|
|
23
23
|
exports.mapCoseAlgToWebCryptoKeyAlgName = mapCoseAlgToWebCryptoKeyAlgName;
|
|
24
|
-
//# sourceMappingURL=mapCoseAlgToWebCryptoKeyAlgName.js.map
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.unwrapEC2Signature = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const __1 = require("../");
|
|
4
|
+
const deps_js_1 = require("../../../deps.js");
|
|
5
|
+
const index_js_1 = require("../index.js");
|
|
7
6
|
/**
|
|
8
7
|
* In WebAuthn, EC2 signatures are wrapped in ASN.1 structure so we need to peel r and s apart.
|
|
9
8
|
*
|
|
10
9
|
* See https://www.w3.org/TR/webauthn-2/#sctn-signature-attestation-types
|
|
11
10
|
*/
|
|
12
11
|
function unwrapEC2Signature(signature) {
|
|
13
|
-
const parsedSignature =
|
|
12
|
+
const parsedSignature = deps_js_1.AsnParser.parse(signature, deps_js_1.ECDSASigValue);
|
|
14
13
|
let rBytes = new Uint8Array(parsedSignature.r);
|
|
15
14
|
let sBytes = new Uint8Array(parsedSignature.s);
|
|
16
15
|
if (shouldRemoveLeadingZero(rBytes)) {
|
|
@@ -19,7 +18,7 @@ function unwrapEC2Signature(signature) {
|
|
|
19
18
|
if (shouldRemoveLeadingZero(sBytes)) {
|
|
20
19
|
sBytes = sBytes.slice(1);
|
|
21
20
|
}
|
|
22
|
-
const finalSignature =
|
|
21
|
+
const finalSignature = index_js_1.isoUint8Array.concat([rBytes, sBytes]);
|
|
23
22
|
return finalSignature;
|
|
24
23
|
}
|
|
25
24
|
exports.unwrapEC2Signature = unwrapEC2Signature;
|
|
@@ -33,4 +32,3 @@ exports.unwrapEC2Signature = unwrapEC2Signature;
|
|
|
33
32
|
function shouldRemoveLeadingZero(bytes) {
|
|
34
33
|
return bytes[0] === 0x0 && (bytes[1] & (1 << 7)) !== 0;
|
|
35
34
|
}
|
|
36
|
-
//# sourceMappingURL=unwrapEC2Signature.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { COSEALG, COSEPublicKey } from '../../cose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Verify signatures with their public key. Supports EC2 and RSA public keys.
|
|
4
|
+
*/
|
|
5
|
+
export declare function verify(opts: {
|
|
6
|
+
cosePublicKey: COSEPublicKey;
|
|
7
|
+
signature: Uint8Array;
|
|
8
|
+
data: Uint8Array;
|
|
9
|
+
shaHashOverride?: COSEALG;
|
|
10
|
+
}): Promise<boolean>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verify = void 0;
|
|
4
|
+
const cose_js_1 = require("../../cose.js");
|
|
5
|
+
const verifyEC2_js_1 = require("./verifyEC2.js");
|
|
6
|
+
const verifyRSA_js_1 = require("./verifyRSA.js");
|
|
7
|
+
const verifyOKP_js_1 = require("./verifyOKP.js");
|
|
8
|
+
const unwrapEC2Signature_js_1 = require("./unwrapEC2Signature.js");
|
|
9
|
+
/**
|
|
10
|
+
* Verify signatures with their public key. Supports EC2 and RSA public keys.
|
|
11
|
+
*/
|
|
12
|
+
function verify(opts) {
|
|
13
|
+
const { cosePublicKey, signature, data, shaHashOverride } = opts;
|
|
14
|
+
if ((0, cose_js_1.isCOSEPublicKeyEC2)(cosePublicKey)) {
|
|
15
|
+
const unwrappedSignature = (0, unwrapEC2Signature_js_1.unwrapEC2Signature)(signature);
|
|
16
|
+
return (0, verifyEC2_js_1.verifyEC2)({
|
|
17
|
+
cosePublicKey,
|
|
18
|
+
signature: unwrappedSignature,
|
|
19
|
+
data,
|
|
20
|
+
shaHashOverride,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else if ((0, cose_js_1.isCOSEPublicKeyRSA)(cosePublicKey)) {
|
|
24
|
+
return (0, verifyRSA_js_1.verifyRSA)({ cosePublicKey, signature, data, shaHashOverride });
|
|
25
|
+
}
|
|
26
|
+
else if ((0, cose_js_1.isCOSEPublicKeyOKP)(cosePublicKey)) {
|
|
27
|
+
return (0, verifyOKP_js_1.verifyOKP)({ cosePublicKey, signature, data });
|
|
28
|
+
}
|
|
29
|
+
const kty = cosePublicKey.get(cose_js_1.COSEKEYS.kty);
|
|
30
|
+
throw new Error(`Signature verification with public key of kty ${kty} is not supported by this method`);
|
|
31
|
+
}
|
|
32
|
+
exports.verify = verify;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { COSEALG, COSEPublicKeyEC2 } from '../../cose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Verify a signature using an EC2 public key
|
|
4
|
+
*/
|
|
5
|
+
export declare function verifyEC2(opts: {
|
|
6
|
+
cosePublicKey: COSEPublicKeyEC2;
|
|
7
|
+
signature: Uint8Array;
|
|
8
|
+
data: Uint8Array;
|
|
9
|
+
shaHashOverride?: COSEALG;
|
|
10
|
+
}): Promise<boolean>;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.verifyEC2 = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
4
|
+
const cose_js_1 = require("../../cose.js");
|
|
5
|
+
const mapCoseAlgToWebCryptoAlg_js_1 = require("./mapCoseAlgToWebCryptoAlg.js");
|
|
6
|
+
const importKey_js_1 = require("./importKey.js");
|
|
7
|
+
const index_js_1 = require("../index.js");
|
|
8
|
+
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
12
9
|
/**
|
|
13
10
|
* Verify a signature using an EC2 public key
|
|
14
11
|
*/
|
|
15
12
|
async function verifyEC2(opts) {
|
|
16
13
|
const { cosePublicKey, signature, data, shaHashOverride } = opts;
|
|
14
|
+
const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)();
|
|
17
15
|
// Import the public key
|
|
18
|
-
const alg = cosePublicKey.get(
|
|
19
|
-
const crv = cosePublicKey.get(
|
|
20
|
-
const x = cosePublicKey.get(
|
|
21
|
-
const y = cosePublicKey.get(
|
|
16
|
+
const alg = cosePublicKey.get(cose_js_1.COSEKEYS.alg);
|
|
17
|
+
const crv = cosePublicKey.get(cose_js_1.COSEKEYS.crv);
|
|
18
|
+
const x = cosePublicKey.get(cose_js_1.COSEKEYS.x);
|
|
19
|
+
const y = cosePublicKey.get(cose_js_1.COSEKEYS.y);
|
|
22
20
|
if (!alg) {
|
|
23
21
|
throw new Error('Public key was missing alg (EC2)');
|
|
24
22
|
}
|
|
@@ -32,13 +30,13 @@ async function verifyEC2(opts) {
|
|
|
32
30
|
throw new Error('Public key was missing y (EC2)');
|
|
33
31
|
}
|
|
34
32
|
let _crv;
|
|
35
|
-
if (crv ===
|
|
33
|
+
if (crv === cose_js_1.COSECRV.P256) {
|
|
36
34
|
_crv = 'P-256';
|
|
37
35
|
}
|
|
38
|
-
else if (crv ===
|
|
36
|
+
else if (crv === cose_js_1.COSECRV.P384) {
|
|
39
37
|
_crv = 'P-384';
|
|
40
38
|
}
|
|
41
|
-
else if (crv ===
|
|
39
|
+
else if (crv === cose_js_1.COSECRV.P521) {
|
|
42
40
|
_crv = 'P-521';
|
|
43
41
|
}
|
|
44
42
|
else {
|
|
@@ -47,8 +45,8 @@ async function verifyEC2(opts) {
|
|
|
47
45
|
const keyData = {
|
|
48
46
|
kty: 'EC',
|
|
49
47
|
crv: _crv,
|
|
50
|
-
x:
|
|
51
|
-
y:
|
|
48
|
+
x: index_js_1.isoBase64URL.fromBuffer(x),
|
|
49
|
+
y: index_js_1.isoBase64URL.fromBuffer(y),
|
|
52
50
|
ext: false,
|
|
53
51
|
};
|
|
54
52
|
const keyAlgorithm = {
|
|
@@ -61,20 +59,19 @@ async function verifyEC2(opts) {
|
|
|
61
59
|
name: 'ECDSA',
|
|
62
60
|
namedCurve: _crv,
|
|
63
61
|
};
|
|
64
|
-
const key = await (0,
|
|
62
|
+
const key = await (0, importKey_js_1.importKey)({
|
|
65
63
|
keyData,
|
|
66
64
|
algorithm: keyAlgorithm,
|
|
67
65
|
});
|
|
68
66
|
// Determine which SHA algorithm to use for signature verification
|
|
69
|
-
let subtleAlg = (0,
|
|
67
|
+
let subtleAlg = (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(alg);
|
|
70
68
|
if (shaHashOverride) {
|
|
71
|
-
subtleAlg = (0,
|
|
69
|
+
subtleAlg = (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(shaHashOverride);
|
|
72
70
|
}
|
|
73
71
|
const verifyAlgorithm = {
|
|
74
72
|
name: 'ECDSA',
|
|
75
73
|
hash: { name: subtleAlg },
|
|
76
74
|
};
|
|
77
|
-
return
|
|
75
|
+
return WebCrypto.subtle.verify(verifyAlgorithm, key, signature, data);
|
|
78
76
|
}
|
|
79
77
|
exports.verifyEC2 = verifyEC2;
|
|
80
|
-
//# sourceMappingURL=verifyEC2.js.map
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.verifyOKP = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
4
|
+
const cose_js_1 = require("../../cose.js");
|
|
5
|
+
const index_js_1 = require("../../index.js");
|
|
6
|
+
const importKey_js_1 = require("./importKey.js");
|
|
7
|
+
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
11
8
|
async function verifyOKP(opts) {
|
|
12
9
|
const { cosePublicKey, signature, data } = opts;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
10
|
+
const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)();
|
|
11
|
+
const alg = cosePublicKey.get(cose_js_1.COSEKEYS.alg);
|
|
12
|
+
const crv = cosePublicKey.get(cose_js_1.COSEKEYS.crv);
|
|
13
|
+
const x = cosePublicKey.get(cose_js_1.COSEKEYS.x);
|
|
16
14
|
if (!alg) {
|
|
17
15
|
throw new Error('Public key was missing alg (OKP)');
|
|
18
16
|
}
|
|
19
|
-
if (!(0,
|
|
17
|
+
if (!(0, cose_js_1.isCOSEAlg)(alg)) {
|
|
20
18
|
throw new Error(`Public key had invalid alg ${alg} (OKP)`);
|
|
21
19
|
}
|
|
22
20
|
if (!crv) {
|
|
@@ -28,7 +26,7 @@ async function verifyOKP(opts) {
|
|
|
28
26
|
// Pulled key import steps from here:
|
|
29
27
|
// https://wicg.github.io/webcrypto-secure-curves/#ed25519-operations
|
|
30
28
|
let _crv;
|
|
31
|
-
if (crv ===
|
|
29
|
+
if (crv === cose_js_1.COSECRV.ED25519) {
|
|
32
30
|
_crv = 'Ed25519';
|
|
33
31
|
}
|
|
34
32
|
else {
|
|
@@ -38,21 +36,20 @@ async function verifyOKP(opts) {
|
|
|
38
36
|
kty: 'OKP',
|
|
39
37
|
crv: _crv,
|
|
40
38
|
alg: 'EdDSA',
|
|
41
|
-
x:
|
|
39
|
+
x: index_js_1.isoBase64URL.fromBuffer(x),
|
|
42
40
|
ext: false,
|
|
43
41
|
};
|
|
44
42
|
const keyAlgorithm = {
|
|
45
43
|
name: _crv,
|
|
46
44
|
namedCurve: _crv,
|
|
47
45
|
};
|
|
48
|
-
const key = await (0,
|
|
46
|
+
const key = await (0, importKey_js_1.importKey)({
|
|
49
47
|
keyData,
|
|
50
48
|
algorithm: keyAlgorithm,
|
|
51
49
|
});
|
|
52
50
|
const verifyAlgorithm = {
|
|
53
51
|
name: _crv,
|
|
54
52
|
};
|
|
55
|
-
return
|
|
53
|
+
return WebCrypto.subtle.verify(verifyAlgorithm, key, signature, data);
|
|
56
54
|
}
|
|
57
55
|
exports.verifyOKP = verifyOKP;
|
|
58
|
-
//# sourceMappingURL=verifyOKP.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { COSEALG, COSEPublicKeyRSA } from '../../cose.js';
|
|
2
|
+
/**
|
|
3
|
+
* Verify a signature using an RSA public key
|
|
4
|
+
*/
|
|
5
|
+
export declare function verifyRSA(opts: {
|
|
6
|
+
cosePublicKey: COSEPublicKeyRSA;
|
|
7
|
+
signature: Uint8Array;
|
|
8
|
+
data: Uint8Array;
|
|
9
|
+
shaHashOverride?: COSEALG;
|
|
10
|
+
}): Promise<boolean>;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.verifyRSA = void 0;
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
4
|
+
const cose_js_1 = require("../../cose.js");
|
|
5
|
+
const mapCoseAlgToWebCryptoAlg_js_1 = require("./mapCoseAlgToWebCryptoAlg.js");
|
|
6
|
+
const importKey_js_1 = require("./importKey.js");
|
|
7
|
+
const index_js_1 = require("../index.js");
|
|
8
|
+
const mapCoseAlgToWebCryptoKeyAlgName_js_1 = require("./mapCoseAlgToWebCryptoKeyAlgName.js");
|
|
9
|
+
const getWebCrypto_js_1 = require("./getWebCrypto.js");
|
|
13
10
|
/**
|
|
14
11
|
* Verify a signature using an RSA public key
|
|
15
12
|
*/
|
|
16
13
|
async function verifyRSA(opts) {
|
|
17
14
|
const { cosePublicKey, signature, data, shaHashOverride } = opts;
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
15
|
+
const WebCrypto = await (0, getWebCrypto_js_1.getWebCrypto)();
|
|
16
|
+
const alg = cosePublicKey.get(cose_js_1.COSEKEYS.alg);
|
|
17
|
+
const n = cosePublicKey.get(cose_js_1.COSEKEYS.n);
|
|
18
|
+
const e = cosePublicKey.get(cose_js_1.COSEKEYS.e);
|
|
21
19
|
if (!alg) {
|
|
22
20
|
throw new Error('Public key was missing alg (RSA)');
|
|
23
21
|
}
|
|
24
|
-
if (!(0,
|
|
22
|
+
if (!(0, cose_js_1.isCOSEAlg)(alg)) {
|
|
25
23
|
throw new Error(`Public key had invalid alg ${alg} (RSA)`);
|
|
26
24
|
}
|
|
27
25
|
if (!n) {
|
|
@@ -33,19 +31,19 @@ async function verifyRSA(opts) {
|
|
|
33
31
|
const keyData = {
|
|
34
32
|
kty: 'RSA',
|
|
35
33
|
alg: '',
|
|
36
|
-
n:
|
|
37
|
-
e:
|
|
34
|
+
n: index_js_1.isoBase64URL.fromBuffer(n),
|
|
35
|
+
e: index_js_1.isoBase64URL.fromBuffer(e),
|
|
38
36
|
ext: false,
|
|
39
37
|
};
|
|
40
38
|
const keyAlgorithm = {
|
|
41
|
-
name: (0,
|
|
42
|
-
hash: { name: (0,
|
|
39
|
+
name: (0, mapCoseAlgToWebCryptoKeyAlgName_js_1.mapCoseAlgToWebCryptoKeyAlgName)(alg),
|
|
40
|
+
hash: { name: (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(alg) },
|
|
43
41
|
};
|
|
44
42
|
const verifyAlgorithm = {
|
|
45
|
-
name: (0,
|
|
43
|
+
name: (0, mapCoseAlgToWebCryptoKeyAlgName_js_1.mapCoseAlgToWebCryptoKeyAlgName)(alg),
|
|
46
44
|
};
|
|
47
45
|
if (shaHashOverride) {
|
|
48
|
-
keyAlgorithm.hash.name = (0,
|
|
46
|
+
keyAlgorithm.hash.name = (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(shaHashOverride);
|
|
49
47
|
}
|
|
50
48
|
if (keyAlgorithm.name === 'RSASSA-PKCS1-v1_5') {
|
|
51
49
|
if (keyAlgorithm.hash.name === 'SHA-256') {
|
|
@@ -88,11 +86,10 @@ async function verifyRSA(opts) {
|
|
|
88
86
|
else {
|
|
89
87
|
throw new Error(`Unexpected RSA key algorithm ${alg} (${keyAlgorithm.name})`);
|
|
90
88
|
}
|
|
91
|
-
const key = await (0,
|
|
89
|
+
const key = await (0, importKey_js_1.importKey)({
|
|
92
90
|
keyData,
|
|
93
91
|
algorithm: keyAlgorithm,
|
|
94
92
|
});
|
|
95
|
-
return
|
|
93
|
+
return WebCrypto.subtle.verify(verifyAlgorithm, key, signature, data);
|
|
96
94
|
}
|
|
97
95
|
exports.verifyRSA = verifyRSA;
|
|
98
|
-
//# sourceMappingURL=verifyRSA.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make sure two Uint8Arrays are deeply equivalent
|
|
3
|
+
*/
|
|
4
|
+
export declare function areEqual(array1: Uint8Array, array2: Uint8Array): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Convert a Uint8Array to Hexadecimal.
|
|
7
|
+
*
|
|
8
|
+
* A replacement for `Buffer.toString('hex')`
|
|
9
|
+
*/
|
|
10
|
+
export declare function toHex(array: Uint8Array): string;
|
|
11
|
+
/**
|
|
12
|
+
* Convert a hexadecimal string to isoUint8Array.
|
|
13
|
+
*
|
|
14
|
+
* A replacement for `Buffer.from('...', 'hex')`
|
|
15
|
+
*/
|
|
16
|
+
export declare function fromHex(hex: string): Uint8Array;
|
|
17
|
+
/**
|
|
18
|
+
* Combine multiple Uint8Arrays into a single Uint8Array
|
|
19
|
+
*/
|
|
20
|
+
export declare function concat(arrays: Uint8Array[]): Uint8Array;
|
|
21
|
+
/**
|
|
22
|
+
* Convert bytes into a UTF-8 string
|
|
23
|
+
*/
|
|
24
|
+
export declare function toUTF8String(array: Uint8Array): string;
|
|
25
|
+
/**
|
|
26
|
+
* Convert a UTF-8 string back into bytes
|
|
27
|
+
*/
|
|
28
|
+
export declare function fromUTF8String(utf8String: string): Uint8Array;
|
|
29
|
+
/**
|
|
30
|
+
* Convert an ASCII string to Uint8Array
|
|
31
|
+
*/
|
|
32
|
+
export declare function fromASCIIString(value: string): Uint8Array;
|
|
33
|
+
/**
|
|
34
|
+
* Prepare a DataView we can slice our way around in as we parse the bytes in a Uint8Array
|
|
35
|
+
*/
|
|
36
|
+
export declare function toDataView(array: Uint8Array): DataView;
|
|
@@ -17,7 +17,7 @@ exports.areEqual = areEqual;
|
|
|
17
17
|
* A replacement for `Buffer.toString('hex')`
|
|
18
18
|
*/
|
|
19
19
|
function toHex(array) {
|
|
20
|
-
const hexParts = Array.from(array, i => i.toString(16).padStart(2, '0'));
|
|
20
|
+
const hexParts = Array.from(array, (i) => i.toString(16).padStart(2, '0'));
|
|
21
21
|
// adce000235bcc60a648b0b25f1f05503
|
|
22
22
|
return hexParts.join('');
|
|
23
23
|
}
|
|
@@ -28,16 +28,16 @@ exports.toHex = toHex;
|
|
|
28
28
|
* A replacement for `Buffer.from('...', 'hex')`
|
|
29
29
|
*/
|
|
30
30
|
function fromHex(hex) {
|
|
31
|
-
var _a;
|
|
32
31
|
if (!hex) {
|
|
33
32
|
return Uint8Array.from([]);
|
|
34
33
|
}
|
|
35
|
-
const isValid = hex.length !== 0 && hex.length % 2 === 0 &&
|
|
34
|
+
const isValid = hex.length !== 0 && hex.length % 2 === 0 &&
|
|
35
|
+
!/[^a-fA-F0-9]/u.test(hex);
|
|
36
36
|
if (!isValid) {
|
|
37
37
|
throw new Error('Invalid hex string');
|
|
38
38
|
}
|
|
39
|
-
const byteStrings =
|
|
40
|
-
return Uint8Array.from(byteStrings.map(byte => parseInt(byte, 16)));
|
|
39
|
+
const byteStrings = hex.match(/.{1,2}/g) ?? [];
|
|
40
|
+
return Uint8Array.from(byteStrings.map((byte) => parseInt(byte, 16)));
|
|
41
41
|
}
|
|
42
42
|
exports.fromHex = fromHex;
|
|
43
43
|
/**
|
|
@@ -47,7 +47,7 @@ function concat(arrays) {
|
|
|
47
47
|
let pointer = 0;
|
|
48
48
|
const totalLength = arrays.reduce((prev, curr) => prev + curr.length, 0);
|
|
49
49
|
const toReturn = new Uint8Array(totalLength);
|
|
50
|
-
arrays.forEach(arr => {
|
|
50
|
+
arrays.forEach((arr) => {
|
|
51
51
|
toReturn.set(arr, pointer);
|
|
52
52
|
pointer += arr.length;
|
|
53
53
|
});
|
|
@@ -74,7 +74,7 @@ exports.fromUTF8String = fromUTF8String;
|
|
|
74
74
|
* Convert an ASCII string to Uint8Array
|
|
75
75
|
*/
|
|
76
76
|
function fromASCIIString(value) {
|
|
77
|
-
return Uint8Array.from(value.split('').map(x => x.charCodeAt(0)));
|
|
77
|
+
return Uint8Array.from(value.split('').map((x) => x.charCodeAt(0)));
|
|
78
78
|
}
|
|
79
79
|
exports.fromASCIIString = fromASCIIString;
|
|
80
80
|
/**
|
|
@@ -84,4 +84,3 @@ function toDataView(array) {
|
|
|
84
84
|
return new DataView(array.buffer, array.byteOffset, array.length);
|
|
85
85
|
}
|
|
86
86
|
exports.toDataView = toDataView;
|
|
87
|
-
//# sourceMappingURL=isoUint8Array.js.map
|