@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.
Files changed (343) hide show
  1. package/LICENSE.md +11 -14
  2. package/README.md +20 -7
  3. package/{dist → esm}/authentication/generateAuthenticationOptions.d.ts +2 -2
  4. package/esm/authentication/generateAuthenticationOptions.js +36 -0
  5. package/{dist → esm}/authentication/verifyAuthenticationResponse.d.ts +2 -2
  6. package/esm/authentication/verifyAuthenticationResponse.js +164 -0
  7. package/esm/deps.d.ts +11 -0
  8. package/esm/deps.js +14 -0
  9. package/esm/helpers/convertAAGUIDToString.js +17 -0
  10. package/esm/helpers/convertCOSEtoPKCS.js +21 -0
  11. package/{dist → esm}/helpers/convertCertBufferToPEM.d.ts +1 -1
  12. package/esm/helpers/convertCertBufferToPEM.js +31 -0
  13. package/esm/helpers/convertPEMToBytes.js +11 -0
  14. package/{dist → esm}/helpers/convertX509PublicKeyToCOSE.d.ts +1 -1
  15. package/esm/helpers/convertX509PublicKeyToCOSE.js +70 -0
  16. package/{dist → esm}/helpers/cose.d.ts +2 -1
  17. package/esm/helpers/cose.js +81 -0
  18. package/{dist → esm}/helpers/decodeAttestationObject.d.ts +3 -0
  19. package/esm/helpers/decodeAttestationObject.js +13 -0
  20. package/esm/helpers/decodeAuthenticatorExtensions.js +34 -0
  21. package/{dist → esm}/helpers/decodeClientDataJSON.d.ts +3 -0
  22. package/esm/helpers/decodeClientDataJSON.js +13 -0
  23. package/esm/helpers/decodeCredentialPublicKey.d.ts +5 -0
  24. package/esm/helpers/decodeCredentialPublicKey.js +8 -0
  25. package/esm/helpers/fetch.d.ts +8 -0
  26. package/esm/helpers/fetch.js +12 -0
  27. package/esm/helpers/generateChallenge.d.ts +7 -0
  28. package/esm/helpers/generateChallenge.js +21 -0
  29. package/{dist → esm}/helpers/getCertificateInfo.d.ts +1 -1
  30. package/esm/helpers/getCertificateInfo.js +76 -0
  31. package/esm/helpers/index.d.ts +22 -0
  32. package/esm/helpers/index.js +16 -0
  33. package/{dist → esm}/helpers/isCertRevoked.d.ts +1 -1
  34. package/esm/helpers/isCertRevoked.js +98 -0
  35. package/{dist → esm}/helpers/iso/index.d.ts +4 -4
  36. package/esm/helpers/iso/index.js +11 -0
  37. package/esm/helpers/iso/isoBase64URL.js +57 -0
  38. package/{dist → esm}/helpers/iso/isoCBOR.d.ts +1 -1
  39. package/esm/helpers/iso/isoCBOR.js +44 -0
  40. package/{dist → esm}/helpers/iso/isoCrypto/digest.d.ts +1 -1
  41. package/esm/helpers/iso/isoCrypto/digest.js +14 -0
  42. package/{dist → esm}/helpers/iso/isoCrypto/getRandomValues.d.ts +1 -1
  43. package/esm/helpers/iso/isoCrypto/getRandomValues.js +11 -0
  44. package/esm/helpers/iso/isoCrypto/getWebCrypto.d.ts +6 -0
  45. package/esm/helpers/iso/isoCrypto/getWebCrypto.js +40 -0
  46. package/esm/helpers/iso/isoCrypto/importKey.js +8 -0
  47. package/esm/helpers/iso/isoCrypto/index.d.ts +3 -0
  48. package/esm/helpers/iso/isoCrypto/index.js +3 -0
  49. package/{dist → esm}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +2 -2
  50. package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js +20 -0
  51. package/{dist → esm}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +2 -2
  52. package/esm/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +19 -0
  53. package/esm/helpers/iso/isoCrypto/structs.js +1 -0
  54. package/esm/helpers/iso/isoCrypto/unwrapEC2Signature.js +30 -0
  55. package/{dist → esm}/helpers/iso/isoCrypto/verify.d.ts +1 -1
  56. package/esm/helpers/iso/isoCrypto/verify.js +28 -0
  57. package/{dist → esm}/helpers/iso/isoCrypto/verifyEC2.d.ts +1 -1
  58. package/esm/helpers/iso/isoCrypto/verifyEC2.js +73 -0
  59. package/{dist → esm}/helpers/iso/isoCrypto/verifyOKP.d.ts +1 -1
  60. package/esm/helpers/iso/isoCrypto/verifyOKP.js +51 -0
  61. package/{dist → esm}/helpers/iso/isoCrypto/verifyRSA.d.ts +1 -1
  62. package/esm/helpers/iso/isoCrypto/verifyRSA.js +91 -0
  63. package/esm/helpers/iso/isoUint8Array.js +75 -0
  64. package/{dist → esm}/helpers/logging.d.ts +1 -1
  65. package/esm/helpers/logging.js +19 -0
  66. package/{dist → esm}/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +1 -1
  67. package/esm/helpers/mapX509SignatureAlgToCOSEAlg.js +35 -0
  68. package/esm/helpers/matchExpectedRPID.js +41 -0
  69. package/{dist → esm}/helpers/parseAuthenticatorData.d.ts +4 -1
  70. package/esm/helpers/parseAuthenticatorData.js +71 -0
  71. package/{dist → esm}/helpers/parseBackupFlags.d.ts +4 -1
  72. package/esm/helpers/parseBackupFlags.js +25 -0
  73. package/{dist → esm}/helpers/toHash.d.ts +1 -1
  74. package/esm/helpers/toHash.js +12 -0
  75. package/esm/helpers/validateCertificatePath.js +122 -0
  76. package/{dist → esm}/helpers/verifySignature.d.ts +4 -1
  77. package/esm/helpers/verifySignature.js +32 -0
  78. package/esm/index.d.ts +17 -0
  79. package/esm/index.js +11 -0
  80. package/{dist → esm}/metadata/mdsTypes.d.ts +1 -1
  81. package/esm/metadata/mdsTypes.js +17 -0
  82. package/esm/metadata/parseJWT.js +12 -0
  83. package/{dist → esm}/metadata/verifyAttestationWithMetadata.d.ts +3 -3
  84. package/esm/metadata/verifyAttestationWithMetadata.js +159 -0
  85. package/esm/metadata/verifyJWT.js +37 -0
  86. package/esm/package.json +3 -0
  87. package/{dist → esm}/registration/generateRegistrationOptions.d.ts +2 -2
  88. package/esm/registration/generateRegistrationOptions.js +142 -0
  89. package/esm/registration/verifications/tpm/constants.js +182 -0
  90. package/esm/registration/verifications/tpm/parseCertInfo.js +58 -0
  91. package/esm/registration/verifications/tpm/parsePubArea.js +94 -0
  92. package/{dist → esm}/registration/verifications/tpm/verifyAttestationTPM.d.ts +1 -1
  93. package/esm/registration/verifications/tpm/verifyAttestationTPM.js +323 -0
  94. package/{dist → esm}/registration/verifications/verifyAttestationAndroidKey.d.ts +1 -1
  95. package/esm/registration/verifications/verifyAttestationAndroidKey.js +90 -0
  96. package/{dist → esm}/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts +1 -1
  97. package/esm/registration/verifications/verifyAttestationAndroidSafetyNet.js +112 -0
  98. package/{dist → esm}/registration/verifications/verifyAttestationApple.d.ts +1 -1
  99. package/esm/registration/verifications/verifyAttestationApple.js +57 -0
  100. package/{dist → esm}/registration/verifications/verifyAttestationFIDOU2F.d.ts +1 -1
  101. package/esm/registration/verifications/verifyAttestationFIDOU2F.js +48 -0
  102. package/{dist → esm}/registration/verifications/verifyAttestationPacked.d.ts +1 -1
  103. package/esm/registration/verifications/verifyAttestationPacked.js +105 -0
  104. package/{dist → esm}/registration/verifyRegistrationResponse.d.ts +3 -3
  105. package/esm/registration/verifyRegistrationResponse.js +198 -0
  106. package/esm/services/defaultRootCerts/android-key.js +85 -0
  107. package/esm/services/defaultRootCerts/android-safetynet.js +32 -0
  108. package/esm/services/defaultRootCerts/apple.js +25 -0
  109. package/esm/services/defaultRootCerts/mds.js +32 -0
  110. package/{dist → esm}/services/metadataService.d.ts +1 -1
  111. package/{dist → esm}/services/metadataService.js +52 -36
  112. package/{dist → esm}/services/settingsService.d.ts +1 -1
  113. package/esm/services/settingsService.js +65 -0
  114. package/package.json +40 -42
  115. package/script/authentication/generateAuthenticationOptions.d.ts +23 -0
  116. package/{dist → script}/authentication/generateAuthenticationOptions.js +8 -9
  117. package/script/authentication/verifyAuthenticationResponse.d.ts +66 -0
  118. package/{dist → script}/authentication/verifyAuthenticationResponse.js +25 -23
  119. package/script/deps.d.ts +11 -0
  120. package/script/deps.js +71 -0
  121. package/script/helpers/convertAAGUIDToString.d.ts +4 -0
  122. package/{dist → script}/helpers/convertAAGUIDToString.js +2 -3
  123. package/script/helpers/convertCOSEtoPKCS.d.ts +4 -0
  124. package/{dist → script}/helpers/convertCOSEtoPKCS.js +7 -8
  125. package/script/helpers/convertCertBufferToPEM.d.ts +5 -0
  126. package/{dist → script}/helpers/convertCertBufferToPEM.js +5 -6
  127. package/script/helpers/convertPEMToBytes.d.ts +4 -0
  128. package/{dist → script}/helpers/convertPEMToBytes.js +2 -3
  129. package/script/helpers/convertX509PublicKeyToCOSE.d.ts +2 -0
  130. package/{dist → script}/helpers/convertX509PublicKeyToCOSE.js +21 -25
  131. package/script/helpers/cose.d.ts +98 -0
  132. package/{dist → script}/helpers/cose.js +1 -1
  133. package/script/helpers/decodeAttestationObject.d.ts +29 -0
  134. package/script/helpers/decodeAttestationObject.js +17 -0
  135. package/script/helpers/decodeAuthenticatorExtensions.d.ts +20 -0
  136. package/{dist → script}/helpers/decodeAuthenticatorExtensions.js +2 -3
  137. package/script/helpers/decodeClientDataJSON.d.ts +17 -0
  138. package/script/helpers/decodeClientDataJSON.js +17 -0
  139. package/script/helpers/decodeCredentialPublicKey.d.ts +5 -0
  140. package/script/helpers/decodeCredentialPublicKey.js +12 -0
  141. package/script/helpers/fetch.d.ts +8 -0
  142. package/script/helpers/fetch.js +16 -0
  143. package/script/helpers/generateChallenge.d.ts +7 -0
  144. package/{dist → script}/helpers/generateChallenge.js +9 -6
  145. package/script/helpers/getCertificateInfo.d.ts +31 -0
  146. package/{dist → script}/helpers/getCertificateInfo.js +4 -6
  147. package/script/helpers/index.d.ts +22 -0
  148. package/script/helpers/index.js +59 -0
  149. package/script/helpers/isCertRevoked.d.ts +8 -0
  150. package/{dist → script}/helpers/isCertRevoked.js +20 -25
  151. package/script/helpers/iso/index.d.ts +11 -0
  152. package/{dist → script}/helpers/iso/index.js +4 -5
  153. package/script/helpers/iso/isoBase64URL.d.ts +37 -0
  154. package/{dist → script}/helpers/iso/isoBase64URL.js +9 -13
  155. package/script/helpers/iso/isoCBOR.d.ts +12 -0
  156. package/{dist → script}/helpers/iso/isoCBOR.js +8 -28
  157. package/script/helpers/iso/isoCrypto/digest.d.ts +8 -0
  158. package/script/helpers/iso/isoCrypto/digest.js +18 -0
  159. package/script/helpers/iso/isoCrypto/getRandomValues.d.ts +6 -0
  160. package/script/helpers/iso/isoCrypto/getRandomValues.js +15 -0
  161. package/script/helpers/iso/isoCrypto/getWebCrypto.d.ts +6 -0
  162. package/script/helpers/iso/isoCrypto/getWebCrypto.js +44 -0
  163. package/script/helpers/iso/isoCrypto/importKey.d.ts +4 -0
  164. package/script/helpers/iso/isoCrypto/importKey.js +12 -0
  165. package/script/helpers/iso/isoCrypto/index.d.ts +3 -0
  166. package/{dist → script}/helpers/iso/isoCrypto/index.js +6 -7
  167. package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.d.ts +6 -0
  168. package/{dist → script}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js +6 -6
  169. package/script/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.d.ts +6 -0
  170. package/{dist → script}/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js +5 -6
  171. package/script/helpers/iso/isoCrypto/structs.d.ts +3 -0
  172. package/{dist → script}/helpers/iso/isoCrypto/structs.js +0 -1
  173. package/script/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts +6 -0
  174. package/{dist → script}/helpers/iso/isoCrypto/unwrapEC2Signature.js +4 -6
  175. package/script/helpers/iso/isoCrypto/verify.d.ts +10 -0
  176. package/script/helpers/iso/isoCrypto/verify.js +32 -0
  177. package/script/helpers/iso/isoCrypto/verifyEC2.d.ts +10 -0
  178. package/{dist → script}/helpers/iso/isoCrypto/verifyEC2.js +19 -22
  179. package/script/helpers/iso/isoCrypto/verifyOKP.d.ts +6 -0
  180. package/{dist → script}/helpers/iso/isoCrypto/verifyOKP.js +13 -16
  181. package/script/helpers/iso/isoCrypto/verifyRSA.d.ts +10 -0
  182. package/{dist → script}/helpers/iso/isoCrypto/verifyRSA.js +19 -22
  183. package/script/helpers/iso/isoUint8Array.d.ts +36 -0
  184. package/{dist → script}/helpers/iso/isoUint8Array.js +7 -8
  185. package/script/helpers/logging.d.ts +17 -0
  186. package/{dist → script}/helpers/logging.js +2 -6
  187. package/script/helpers/mapX509SignatureAlgToCOSEAlg.d.ts +8 -0
  188. package/{dist → script}/helpers/mapX509SignatureAlgToCOSEAlg.js +8 -9
  189. package/script/helpers/matchExpectedRPID.d.ts +7 -0
  190. package/{dist → script}/helpers/matchExpectedRPID.js +5 -6
  191. package/script/helpers/parseAuthenticatorData.d.ts +28 -0
  192. package/{dist → script}/helpers/parseAuthenticatorData.js +19 -16
  193. package/script/helpers/parseBackupFlags.d.ts +19 -0
  194. package/{dist → script}/helpers/parseBackupFlags.js +2 -2
  195. package/script/helpers/toHash.d.ts +6 -0
  196. package/{dist → script}/helpers/toHash.js +4 -5
  197. package/script/helpers/validateCertificatePath.d.ts +6 -0
  198. package/{dist → script}/helpers/validateCertificatePath.js +13 -15
  199. package/script/helpers/verifySignature.d.ts +14 -0
  200. package/script/helpers/verifySignature.js +36 -0
  201. package/script/index.d.ts +17 -0
  202. package/script/index.js +19 -0
  203. package/script/metadata/mdsTypes.d.ts +216 -0
  204. package/{dist → script}/metadata/mdsTypes.js +0 -1
  205. package/script/metadata/parseJWT.d.ts +4 -0
  206. package/{dist → script}/metadata/parseJWT.js +3 -4
  207. package/script/metadata/verifyAttestationWithMetadata.d.ts +29 -0
  208. package/{dist → script}/metadata/verifyAttestationWithMetadata.js +24 -22
  209. package/script/metadata/verifyJWT.d.ts +10 -0
  210. package/script/metadata/verifyJWT.js +41 -0
  211. package/script/package.json +3 -0
  212. package/script/registration/generateRegistrationOptions.d.ts +43 -0
  213. package/{dist → script}/registration/generateRegistrationOptions.js +9 -10
  214. package/script/registration/verifications/tpm/constants.d.ts +47 -0
  215. package/{dist → script}/registration/verifications/tpm/constants.js +1 -2
  216. package/script/registration/verifications/tpm/parseCertInfo.d.ts +24 -0
  217. package/{dist → script}/registration/verifications/tpm/parseCertInfo.js +13 -14
  218. package/script/registration/verifications/tpm/parsePubArea.d.ts +43 -0
  219. package/{dist → script}/registration/verifications/tpm/parsePubArea.js +16 -17
  220. package/script/registration/verifications/tpm/verifyAttestationTPM.d.ts +2 -0
  221. package/{dist → script}/registration/verifications/tpm/verifyAttestationTPM.js +58 -58
  222. package/script/registration/verifications/verifyAttestationAndroidKey.d.ts +5 -0
  223. package/{dist → script}/registration/verifications/verifyAttestationAndroidKey.js +22 -26
  224. package/script/registration/verifications/verifyAttestationAndroidSafetyNet.d.ts +5 -0
  225. package/{dist → script}/registration/verifications/verifyAttestationAndroidSafetyNet.js +22 -23
  226. package/script/registration/verifications/verifyAttestationApple.d.ts +2 -0
  227. package/{dist → script}/registration/verifications/verifyAttestationApple.js +15 -17
  228. package/script/registration/verifications/verifyAttestationFIDOU2F.d.ts +5 -0
  229. package/{dist → script}/registration/verifications/verifyAttestationFIDOU2F.js +12 -13
  230. package/script/registration/verifications/verifyAttestationPacked.d.ts +5 -0
  231. package/{dist → script}/registration/verifications/verifyAttestationPacked.js +17 -18
  232. package/script/registration/verifyRegistrationResponse.d.ts +85 -0
  233. package/{dist → script}/registration/verifyRegistrationResponse.js +39 -38
  234. package/script/services/defaultRootCerts/android-key.d.ts +24 -0
  235. package/{dist → script}/services/defaultRootCerts/android-key.js +0 -1
  236. package/script/services/defaultRootCerts/android-safetynet.d.ts +11 -0
  237. package/{dist → script}/services/defaultRootCerts/android-safetynet.js +0 -1
  238. package/script/services/defaultRootCerts/apple.d.ts +11 -0
  239. package/{dist → script}/services/defaultRootCerts/apple.js +0 -1
  240. package/script/services/defaultRootCerts/mds.d.ts +11 -0
  241. package/{dist → script}/services/defaultRootCerts/mds.js +0 -1
  242. package/script/services/metadataService.d.ts +53 -0
  243. package/script/services/metadataService.js +277 -0
  244. package/script/services/settingsService.d.ts +25 -0
  245. package/{dist → script}/services/settingsService.js +21 -13
  246. package/dist/authentication/generateAuthenticationOptions.js.map +0 -1
  247. package/dist/authentication/verifyAuthenticationResponse.js.map +0 -1
  248. package/dist/helpers/convertAAGUIDToString.js.map +0 -1
  249. package/dist/helpers/convertCOSEtoPKCS.js.map +0 -1
  250. package/dist/helpers/convertCertBufferToPEM.js.map +0 -1
  251. package/dist/helpers/convertPEMToBytes.js.map +0 -1
  252. package/dist/helpers/convertX509PublicKeyToCOSE.js.map +0 -1
  253. package/dist/helpers/cose.js.map +0 -1
  254. package/dist/helpers/decodeAttestationObject.js +0 -14
  255. package/dist/helpers/decodeAttestationObject.js.map +0 -1
  256. package/dist/helpers/decodeAuthenticatorExtensions.js.map +0 -1
  257. package/dist/helpers/decodeClientDataJSON.js +0 -14
  258. package/dist/helpers/decodeClientDataJSON.js.map +0 -1
  259. package/dist/helpers/decodeCredentialPublicKey.d.ts +0 -2
  260. package/dist/helpers/decodeCredentialPublicKey.js +0 -9
  261. package/dist/helpers/decodeCredentialPublicKey.js.map +0 -1
  262. package/dist/helpers/generateChallenge.d.ts +0 -4
  263. package/dist/helpers/generateChallenge.js.map +0 -1
  264. package/dist/helpers/getCertificateInfo.js.map +0 -1
  265. package/dist/helpers/index.d.ts +0 -22
  266. package/dist/helpers/index.js +0 -60
  267. package/dist/helpers/index.js.map +0 -1
  268. package/dist/helpers/isCertRevoked.js.map +0 -1
  269. package/dist/helpers/iso/index.js.map +0 -1
  270. package/dist/helpers/iso/isoBase64URL.js.map +0 -1
  271. package/dist/helpers/iso/isoCBOR.js.map +0 -1
  272. package/dist/helpers/iso/isoCrypto/digest.js +0 -21
  273. package/dist/helpers/iso/isoCrypto/digest.js.map +0 -1
  274. package/dist/helpers/iso/isoCrypto/getRandomValues.js +0 -18
  275. package/dist/helpers/iso/isoCrypto/getRandomValues.js.map +0 -1
  276. package/dist/helpers/iso/isoCrypto/importKey.js +0 -13
  277. package/dist/helpers/iso/isoCrypto/importKey.js.map +0 -1
  278. package/dist/helpers/iso/isoCrypto/index.d.ts +0 -3
  279. package/dist/helpers/iso/isoCrypto/index.js.map +0 -1
  280. package/dist/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoAlg.js.map +0 -1
  281. package/dist/helpers/iso/isoCrypto/mapCoseAlgToWebCryptoKeyAlgName.js.map +0 -1
  282. package/dist/helpers/iso/isoCrypto/structs.js.map +0 -1
  283. package/dist/helpers/iso/isoCrypto/unwrapEC2Signature.js.map +0 -1
  284. package/dist/helpers/iso/isoCrypto/verify.js +0 -28
  285. package/dist/helpers/iso/isoCrypto/verify.js.map +0 -1
  286. package/dist/helpers/iso/isoCrypto/verifyEC2.js.map +0 -1
  287. package/dist/helpers/iso/isoCrypto/verifyOKP.js.map +0 -1
  288. package/dist/helpers/iso/isoCrypto/verifyRSA.js.map +0 -1
  289. package/dist/helpers/iso/isoUint8Array.js.map +0 -1
  290. package/dist/helpers/logging.js.map +0 -1
  291. package/dist/helpers/mapX509SignatureAlgToCOSEAlg.js.map +0 -1
  292. package/dist/helpers/matchExpectedRPID.js.map +0 -1
  293. package/dist/helpers/parseAuthenticatorData.js.map +0 -1
  294. package/dist/helpers/parseBackupFlags.js.map +0 -1
  295. package/dist/helpers/toHash.js.map +0 -1
  296. package/dist/helpers/validateCertificatePath.js.map +0 -1
  297. package/dist/helpers/verifySignature.js +0 -33
  298. package/dist/helpers/verifySignature.js.map +0 -1
  299. package/dist/index.d.ts +0 -17
  300. package/dist/index.js +0 -20
  301. package/dist/index.js.map +0 -1
  302. package/dist/metadata/mdsTypes.js.map +0 -1
  303. package/dist/metadata/parseJWT.js.map +0 -1
  304. package/dist/metadata/verifyAttestationWithMetadata.js.map +0 -1
  305. package/dist/metadata/verifyJWT.js +0 -42
  306. package/dist/metadata/verifyJWT.js.map +0 -1
  307. package/dist/registration/generateRegistrationOptions.js.map +0 -1
  308. package/dist/registration/verifications/tpm/constants.js.map +0 -1
  309. package/dist/registration/verifications/tpm/parseCertInfo.js.map +0 -1
  310. package/dist/registration/verifications/tpm/parsePubArea.js.map +0 -1
  311. package/dist/registration/verifications/tpm/verifyAttestationTPM.js.map +0 -1
  312. package/dist/registration/verifications/verifyAttestationAndroidKey.js.map +0 -1
  313. package/dist/registration/verifications/verifyAttestationAndroidSafetyNet.js.map +0 -1
  314. package/dist/registration/verifications/verifyAttestationApple.js.map +0 -1
  315. package/dist/registration/verifications/verifyAttestationFIDOU2F.js.map +0 -1
  316. package/dist/registration/verifications/verifyAttestationPacked.js.map +0 -1
  317. package/dist/registration/verifyRegistrationResponse.js.map +0 -1
  318. package/dist/services/defaultRootCerts/android-key.js.map +0 -1
  319. package/dist/services/defaultRootCerts/android-safetynet.js.map +0 -1
  320. package/dist/services/defaultRootCerts/apple.js.map +0 -1
  321. package/dist/services/defaultRootCerts/mds.js.map +0 -1
  322. package/dist/services/metadataService.js.map +0 -1
  323. package/dist/services/settingsService.js.map +0 -1
  324. /package/{dist → esm}/helpers/convertAAGUIDToString.d.ts +0 -0
  325. /package/{dist → esm}/helpers/convertCOSEtoPKCS.d.ts +0 -0
  326. /package/{dist → esm}/helpers/convertPEMToBytes.d.ts +0 -0
  327. /package/{dist → esm}/helpers/decodeAuthenticatorExtensions.d.ts +0 -0
  328. /package/{dist → esm}/helpers/iso/isoBase64URL.d.ts +0 -0
  329. /package/{dist → esm}/helpers/iso/isoCrypto/importKey.d.ts +0 -0
  330. /package/{dist → esm}/helpers/iso/isoCrypto/structs.d.ts +0 -0
  331. /package/{dist → esm}/helpers/iso/isoCrypto/unwrapEC2Signature.d.ts +0 -0
  332. /package/{dist → esm}/helpers/iso/isoUint8Array.d.ts +0 -0
  333. /package/{dist → esm}/helpers/matchExpectedRPID.d.ts +0 -0
  334. /package/{dist → esm}/helpers/validateCertificatePath.d.ts +0 -0
  335. /package/{dist → esm}/metadata/parseJWT.d.ts +0 -0
  336. /package/{dist → esm}/metadata/verifyJWT.d.ts +0 -0
  337. /package/{dist → esm}/registration/verifications/tpm/constants.d.ts +0 -0
  338. /package/{dist → esm}/registration/verifications/tpm/parseCertInfo.d.ts +0 -0
  339. /package/{dist → esm}/registration/verifications/tpm/parsePubArea.d.ts +0 -0
  340. /package/{dist → esm}/services/defaultRootCerts/android-key.d.ts +0 -0
  341. /package/{dist → esm}/services/defaultRootCerts/android-safetynet.d.ts +0 -0
  342. /package/{dist → esm}/services/defaultRootCerts/apple.d.ts +0 -0
  343. /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,6 @@
1
+ import type { Crypto } from '../../../deps.js';
2
+ /**
3
+ * Try to get an instance of the Crypto API from the current runtime. Should support Node,
4
+ * as well as others, like Deno, that implement Web APIs.
5
+ */
6
+ export declare function getWebCrypto(): Promise<Crypto>;
@@ -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,4 @@
1
+ export declare function importKey(opts: {
2
+ keyData: JsonWebKey;
3
+ algorithm: AlgorithmIdentifier | RsaHashedImportParams | EcKeyImportParams;
4
+ }): Promise<CryptoKey>;
@@ -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;
@@ -0,0 +1,3 @@
1
+ export { digest } from './digest.js';
2
+ export { getRandomValues } from './getRandomValues.js';
3
+ export { verify } from './verify.js';
@@ -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 digest_1 = require("./digest");
5
- Object.defineProperty(exports, "digest", { enumerable: true, get: function () { return digest_1.digest; } });
6
- var getRandomValues_1 = require("./getRandomValues");
7
- Object.defineProperty(exports, "getRandomValues", { enumerable: true, get: function () { return getRandomValues_1.getRandomValues; } });
8
- var verify_1 = require("./verify");
9
- Object.defineProperty(exports, "verify", { enumerable: true, get: function () { return verify_1.verify; } });
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 cose_1 = require("../../cose");
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 ([cose_1.COSEALG.RS1].indexOf(alg) >= 0) {
9
+ if ([cose_js_1.COSEALG.RS1].indexOf(alg) >= 0) {
10
10
  return 'SHA-1';
11
11
  }
12
- else if ([cose_1.COSEALG.ES256, cose_1.COSEALG.PS256, cose_1.COSEALG.RS256].indexOf(alg) >= 0) {
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 ([cose_1.COSEALG.ES384, cose_1.COSEALG.PS384, cose_1.COSEALG.RS384].indexOf(alg) >= 0) {
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 ([cose_1.COSEALG.ES512, cose_1.COSEALG.PS512, cose_1.COSEALG.RS512, cose_1.COSEALG.EdDSA].indexOf(alg) >= 0) {
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 cose_1 = require("../../cose");
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 ([cose_1.COSEALG.EdDSA].indexOf(alg) >= 0) {
9
+ if ([cose_js_1.COSEALG.EdDSA].indexOf(alg) >= 0) {
10
10
  return 'Ed25519';
11
11
  }
12
- else if ([cose_1.COSEALG.ES256, cose_1.COSEALG.ES384, cose_1.COSEALG.ES512, cose_1.COSEALG.ES256K].indexOf(alg) >= 0) {
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 ([cose_1.COSEALG.RS256, cose_1.COSEALG.RS384, cose_1.COSEALG.RS512, cose_1.COSEALG.RS1].indexOf(alg) >= 0) {
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 ([cose_1.COSEALG.PS256, cose_1.COSEALG.PS384, cose_1.COSEALG.PS512].indexOf(alg) >= 0) {
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
@@ -0,0 +1,3 @@
1
+ export type SubtleCryptoAlg = 'SHA-1' | 'SHA-256' | 'SHA-384' | 'SHA-512';
2
+ export type SubtleCryptoCrv = 'P-256' | 'P-384' | 'P-521' | 'Ed25519';
3
+ export type SubtleCryptoKeyAlgName = 'ECDSA' | 'Ed25519' | 'RSASSA-PKCS1-v1_5' | 'RSA-PSS';
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=structs.js.map
@@ -0,0 +1,6 @@
1
+ /**
2
+ * In WebAuthn, EC2 signatures are wrapped in ASN.1 structure so we need to peel r and s apart.
3
+ *
4
+ * See https://www.w3.org/TR/webauthn-2/#sctn-signature-attestation-types
5
+ */
6
+ export declare function unwrapEC2Signature(signature: Uint8Array): Uint8Array;
@@ -1,16 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.unwrapEC2Signature = void 0;
4
- const asn1_ecc_1 = require("@peculiar/asn1-ecc");
5
- const asn1_schema_1 = require("@peculiar/asn1-schema");
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 = asn1_schema_1.AsnParser.parse(signature, asn1_ecc_1.ECDSASigValue);
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 = __1.isoUint8Array.concat([rBytes, sBytes]);
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 iso_webcrypto_1 = __importDefault(require("@simplewebauthn/iso-webcrypto"));
8
- const cose_1 = require("../../cose");
9
- const mapCoseAlgToWebCryptoAlg_1 = require("./mapCoseAlgToWebCryptoAlg");
10
- const importKey_1 = require("./importKey");
11
- const index_1 = require("../index");
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(cose_1.COSEKEYS.alg);
19
- const crv = cosePublicKey.get(cose_1.COSEKEYS.crv);
20
- const x = cosePublicKey.get(cose_1.COSEKEYS.x);
21
- const y = cosePublicKey.get(cose_1.COSEKEYS.y);
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 === cose_1.COSECRV.P256) {
33
+ if (crv === cose_js_1.COSECRV.P256) {
36
34
  _crv = 'P-256';
37
35
  }
38
- else if (crv === cose_1.COSECRV.P384) {
36
+ else if (crv === cose_js_1.COSECRV.P384) {
39
37
  _crv = 'P-384';
40
38
  }
41
- else if (crv === cose_1.COSECRV.P521) {
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: index_1.isoBase64URL.fromBuffer(x),
51
- y: index_1.isoBase64URL.fromBuffer(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, importKey_1.importKey)({
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, mapCoseAlgToWebCryptoAlg_1.mapCoseAlgToWebCryptoAlg)(alg);
67
+ let subtleAlg = (0, mapCoseAlgToWebCryptoAlg_js_1.mapCoseAlgToWebCryptoAlg)(alg);
70
68
  if (shaHashOverride) {
71
- subtleAlg = (0, mapCoseAlgToWebCryptoAlg_1.mapCoseAlgToWebCryptoAlg)(shaHashOverride);
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 iso_webcrypto_1.default.subtle.verify(verifyAlgorithm, key, signature, data);
75
+ return WebCrypto.subtle.verify(verifyAlgorithm, key, signature, data);
78
76
  }
79
77
  exports.verifyEC2 = verifyEC2;
80
- //# sourceMappingURL=verifyEC2.js.map
@@ -0,0 +1,6 @@
1
+ import { COSEPublicKeyOKP } from '../../cose.js';
2
+ export declare function verifyOKP(opts: {
3
+ cosePublicKey: COSEPublicKeyOKP;
4
+ signature: Uint8Array;
5
+ data: Uint8Array;
6
+ }): Promise<boolean>;
@@ -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 iso_webcrypto_1 = __importDefault(require("@simplewebauthn/iso-webcrypto"));
8
- const cose_1 = require("../../cose");
9
- const index_1 = require("../../index");
10
- const importKey_1 = require("./importKey");
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 alg = cosePublicKey.get(cose_1.COSEKEYS.alg);
14
- const crv = cosePublicKey.get(cose_1.COSEKEYS.crv);
15
- const x = cosePublicKey.get(cose_1.COSEKEYS.x);
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, cose_1.isCOSEAlg)(alg)) {
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 === cose_1.COSECRV.ED25519) {
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: index_1.isoBase64URL.fromBuffer(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, importKey_1.importKey)({
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 iso_webcrypto_1.default.subtle.verify(verifyAlgorithm, key, signature, data);
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 iso_webcrypto_1 = __importDefault(require("@simplewebauthn/iso-webcrypto"));
8
- const cose_1 = require("../../cose");
9
- const mapCoseAlgToWebCryptoAlg_1 = require("./mapCoseAlgToWebCryptoAlg");
10
- const importKey_1 = require("./importKey");
11
- const index_1 = require("../index");
12
- const mapCoseAlgToWebCryptoKeyAlgName_1 = require("./mapCoseAlgToWebCryptoKeyAlgName");
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 alg = cosePublicKey.get(cose_1.COSEKEYS.alg);
19
- const n = cosePublicKey.get(cose_1.COSEKEYS.n);
20
- const e = cosePublicKey.get(cose_1.COSEKEYS.e);
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, cose_1.isCOSEAlg)(alg)) {
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: index_1.isoBase64URL.fromBuffer(n),
37
- e: index_1.isoBase64URL.fromBuffer(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, mapCoseAlgToWebCryptoKeyAlgName_1.mapCoseAlgToWebCryptoKeyAlgName)(alg),
42
- hash: { name: (0, mapCoseAlgToWebCryptoAlg_1.mapCoseAlgToWebCryptoAlg)(alg) },
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, mapCoseAlgToWebCryptoKeyAlgName_1.mapCoseAlgToWebCryptoKeyAlgName)(alg),
43
+ name: (0, mapCoseAlgToWebCryptoKeyAlgName_js_1.mapCoseAlgToWebCryptoKeyAlgName)(alg),
46
44
  };
47
45
  if (shaHashOverride) {
48
- keyAlgorithm.hash.name = (0, mapCoseAlgToWebCryptoAlg_1.mapCoseAlgToWebCryptoAlg)(shaHashOverride);
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, importKey_1.importKey)({
89
+ const key = await (0, importKey_js_1.importKey)({
92
90
  keyData,
93
91
  algorithm: keyAlgorithm,
94
92
  });
95
- return iso_webcrypto_1.default.subtle.verify(verifyAlgorithm, key, signature, data);
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 && !/[^a-fA-F0-9]/u.test(hex);
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 = (_a = hex.match(/.{1,2}/g)) !== null && _a !== void 0 ? _a : [];
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