@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,216 @@
1
+ import type { Base64URLString } from '../deps.js';
2
+ /**
3
+ * Metadata Service structures
4
+ * https://fidoalliance.org/specs/mds/fido-metadata-service-v3.0-ps-20210518.html
5
+ */
6
+ export type MDSJWTHeader = {
7
+ alg: string;
8
+ typ: string;
9
+ x5c: Base64URLString[];
10
+ };
11
+ export type MDSJWTPayload = {
12
+ legalHeader: string;
13
+ no: number;
14
+ nextUpdate: string;
15
+ entries: MetadataBLOBPayloadEntry[];
16
+ };
17
+ export type MetadataBLOBPayloadEntry = {
18
+ aaid?: string;
19
+ aaguid?: string;
20
+ attestationCertificateKeyIdentifiers?: string[];
21
+ metadataStatement?: MetadataStatement;
22
+ biometricStatusReports?: BiometricStatusReport[];
23
+ statusReports: StatusReport[];
24
+ timeOfLastStatusChange: string;
25
+ rogueListURL?: string;
26
+ rogueListHash?: string;
27
+ };
28
+ export type BiometricStatusReport = {
29
+ certLevel: number;
30
+ modality: UserVerify;
31
+ effectiveDate?: string;
32
+ certificationDescriptor?: string;
33
+ certificateNumber?: string;
34
+ certificationPolicyVersion?: string;
35
+ certificationRequirementsVersion?: string;
36
+ };
37
+ export type StatusReport = {
38
+ status: AuthenticatorStatus;
39
+ effectiveDate?: string;
40
+ authenticatorVersion?: number;
41
+ certificate?: string;
42
+ url?: string;
43
+ certificationDescriptor?: string;
44
+ certificateNumber?: string;
45
+ certificationPolicyVersion?: string;
46
+ certificationRequirementsVersion?: string;
47
+ };
48
+ export type AuthenticatorStatus = 'NOT_FIDO_CERTIFIED' | 'FIDO_CERTIFIED' | 'USER_VERIFICATION_BYPASS' | 'ATTESTATION_KEY_COMPROMISE' | 'USER_KEY_REMOTE_COMPROMISE' | 'USER_KEY_PHYSICAL_COMPROMISE' | 'UPDATE_AVAILABLE' | 'REVOKED' | 'SELF_ASSERTION_SUBMITTED' | 'FIDO_CERTIFIED_L1' | 'FIDO_CERTIFIED_L1plus' | 'FIDO_CERTIFIED_L2' | 'FIDO_CERTIFIED_L2plus' | 'FIDO_CERTIFIED_L3' | 'FIDO_CERTIFIED_L3plus';
49
+ /**
50
+ * Types defined in the FIDO Metadata Statement spec
51
+ *
52
+ * See https://fidoalliance.org/specs/mds/fido-metadata-statement-v3.0-ps-20210518.html
53
+ */
54
+ export type CodeAccuracyDescriptor = {
55
+ base: number;
56
+ minLength: number;
57
+ maxRetries?: number;
58
+ blockSlowdown?: number;
59
+ };
60
+ export type BiometricAccuracyDescriptor = {
61
+ selfAttestedFRR?: number;
62
+ selfAttestedFAR?: number;
63
+ maxTemplates?: number;
64
+ maxRetries?: number;
65
+ blockSlowdown?: number;
66
+ };
67
+ export type PatternAccuracyDescriptor = {
68
+ minComplexity: number;
69
+ maxRetries?: number;
70
+ blockSlowdown?: number;
71
+ };
72
+ export type VerificationMethodDescriptor = {
73
+ userVerificationMethod: UserVerify;
74
+ caDesc?: CodeAccuracyDescriptor;
75
+ baDesc?: BiometricAccuracyDescriptor;
76
+ paDesc?: PatternAccuracyDescriptor;
77
+ };
78
+ export type VerificationMethodANDCombinations = VerificationMethodDescriptor[];
79
+ export type rgbPaletteEntry = {
80
+ r: number;
81
+ g: number;
82
+ b: number;
83
+ };
84
+ export type DisplayPNGCharacteristicsDescriptor = {
85
+ width: number;
86
+ height: number;
87
+ bitDepth: number;
88
+ colorType: number;
89
+ compression: number;
90
+ filter: number;
91
+ interlace: number;
92
+ plte?: rgbPaletteEntry[];
93
+ };
94
+ export type EcdaaTrustAnchor = {
95
+ X: string;
96
+ Y: string;
97
+ c: string;
98
+ sx: string;
99
+ sy: string;
100
+ G1Curve: string;
101
+ };
102
+ export type ExtensionDescriptor = {
103
+ id: string;
104
+ tag?: number;
105
+ data?: string;
106
+ fail_if_unknown: boolean;
107
+ };
108
+ export type AlternativeDescriptions = {
109
+ [langCode: string]: string;
110
+ };
111
+ export type MetadataStatement = {
112
+ legalHeader?: string;
113
+ aaid?: string;
114
+ aaguid?: string;
115
+ attestationCertificateKeyIdentifiers?: string[];
116
+ description: string;
117
+ alternativeDescriptions?: AlternativeDescriptions;
118
+ authenticatorVersion: number;
119
+ protocolFamily: string;
120
+ schema: number;
121
+ upv: Version[];
122
+ authenticationAlgorithms: AlgSign[];
123
+ publicKeyAlgAndEncodings: AlgKey[];
124
+ attestationTypes: Attestation[];
125
+ userVerificationDetails: VerificationMethodANDCombinations[];
126
+ keyProtection: KeyProtection[];
127
+ isKeyRestricted?: boolean;
128
+ isFreshUserVerificationRequired?: boolean;
129
+ matcherProtection: MatcherProtection[];
130
+ cryptoStrength?: number;
131
+ attachmentHint?: AttachmentHint[];
132
+ tcDisplay: TransactionConfirmationDisplay[];
133
+ tcDisplayContentType?: string;
134
+ tcDisplayPNGCharacteristics?: DisplayPNGCharacteristicsDescriptor[];
135
+ attestationRootCertificates: string[];
136
+ ecdaaTrustAnchors?: EcdaaTrustAnchor[];
137
+ icon?: string;
138
+ supportedExtensions?: ExtensionDescriptor[];
139
+ authenticatorGetInfo?: AuthenticatorGetInfo;
140
+ };
141
+ /**
142
+ * Types declared in other specs
143
+ */
144
+ /**
145
+ * USER_VERIFY
146
+ * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#user-verification-methods
147
+ */
148
+ export type UserVerify = 'presence_internal' | 'fingerprint_internal' | 'passcode_internal' | 'voiceprint_internal' | 'faceprint_internal' | 'location_internal' | 'eyeprint_internal' | 'pattern_internal' | 'handprint_internal' | 'passcode_external' | 'pattern_external' | 'none' | 'all';
149
+ /**
150
+ * ALG_SIGN
151
+ * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#authentication-algorithms
152
+ *
153
+ * Using this helpful TS pattern here so that we can strongly enforce the existence of COSE info
154
+ * mappings in `algSignToCOSEInfoMap` in verifyAttestationWithMetadata.ts
155
+ */
156
+ export type AlgSign = typeof AlgSign[number];
157
+ declare const AlgSign: readonly ["secp256r1_ecdsa_sha256_raw", "secp256r1_ecdsa_sha256_der", "rsassa_pss_sha256_raw", "rsassa_pss_sha256_der", "secp256k1_ecdsa_sha256_raw", "secp256k1_ecdsa_sha256_der", "rsassa_pss_sha384_raw", "rsassa_pkcsv15_sha256_raw", "rsassa_pkcsv15_sha384_raw", "rsassa_pkcsv15_sha512_raw", "rsassa_pkcsv15_sha1_raw", "secp384r1_ecdsa_sha384_raw", "secp512r1_ecdsa_sha256_raw", "ed25519_eddsa_sha512_raw"];
158
+ /**
159
+ * ALG_KEY
160
+ * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#public-key-representation-formats
161
+ */
162
+ export type AlgKey = 'ecc_x962_raw' | 'ecc_x962_der' | 'rsa_2048_raw' | 'rsa_2048_der' | 'cose';
163
+ /**
164
+ * ATTESTATION
165
+ * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#authenticator-attestation-types
166
+ */
167
+ export type Attestation = 'basic_full' | 'basic_surrogate' | 'ecdaa' | 'attca' | 'anonca' | 'none';
168
+ /**
169
+ * KEY_PROTECTION
170
+ * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#key-protection-types
171
+ */
172
+ export type KeyProtection = 'software' | 'hardware' | 'tee' | 'secure_element' | 'remote_handle';
173
+ /**
174
+ * MATCHER_PROTECTION
175
+ * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#matcher-protection-types
176
+ */
177
+ export type MatcherProtection = 'software' | 'tee' | 'on_chip';
178
+ /**
179
+ * ATTACHMENT_HINT
180
+ * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#authenticator-attachment-hints
181
+ */
182
+ export type AttachmentHint = 'internal' | 'external' | 'wired' | 'wireless' | 'nfc' | 'bluetooth' | 'network' | 'ready' | 'wifi_direct';
183
+ /**
184
+ * TRANSACTION_CONFIRMATION_DISPLAY
185
+ * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#transaction-confirmation-display-types
186
+ */
187
+ export type TransactionConfirmationDisplay = 'any' | 'privileged_software' | 'tee' | 'hardware' | 'remote';
188
+ /**
189
+ * https://fidoalliance.org/specs/fido-uaf-v1.2-ps-20201020/fido-uaf-protocol-v1.2-ps-20201020.html#version-interface
190
+ */
191
+ export type Version = {
192
+ major: number;
193
+ minor: number;
194
+ };
195
+ /**
196
+ * https://fidoalliance.org/specs/fido-v2.0-ps-20190130/fido-client-to-authenticator-protocol-v2.0-ps-20190130.html#authenticatorGetInfoz
197
+ */
198
+ export type AuthenticatorGetInfo = {
199
+ versions: ('FIDO_2_0' | 'U2F_V2')[];
200
+ extensions?: string[];
201
+ aaguid: string;
202
+ options?: {
203
+ plat?: boolean;
204
+ rk?: boolean;
205
+ clientPin?: boolean;
206
+ up?: boolean;
207
+ uv?: boolean;
208
+ };
209
+ maxMsgSize?: number;
210
+ pinProtocols?: number[];
211
+ algorithms?: {
212
+ type: 'public-key';
213
+ alg: number;
214
+ }[];
215
+ };
216
+ export {};
@@ -16,4 +16,3 @@ const AlgSign = [
16
16
  'secp512r1_ecdsa_sha256_raw',
17
17
  'ed25519_eddsa_sha512_raw',
18
18
  ];
19
- //# sourceMappingURL=mdsTypes.js.map
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Process a JWT into Javascript-friendly data structures
3
+ */
4
+ export declare function parseJWT<T1, T2>(jwt: string): [T1, T2, string];
@@ -1,17 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseJWT = void 0;
4
- const iso_1 = require("../helpers/iso");
4
+ const index_js_1 = require("../helpers/iso/index.js");
5
5
  /**
6
6
  * Process a JWT into Javascript-friendly data structures
7
7
  */
8
8
  function parseJWT(jwt) {
9
9
  const parts = jwt.split('.');
10
10
  return [
11
- JSON.parse(iso_1.isoBase64URL.toString(parts[0])),
12
- JSON.parse(iso_1.isoBase64URL.toString(parts[1])),
11
+ JSON.parse(index_js_1.isoBase64URL.toString(parts[0])),
12
+ JSON.parse(index_js_1.isoBase64URL.toString(parts[1])),
13
13
  parts[2],
14
14
  ];
15
15
  }
16
16
  exports.parseJWT = parseJWT;
17
- //# sourceMappingURL=parseJWT.js.map
@@ -0,0 +1,29 @@
1
+ import type { Base64URLString } from '../deps.js';
2
+ import type { AlgSign, MetadataStatement } from './mdsTypes.js';
3
+ import { COSEALG, COSECRV, COSEKTY } from '../helpers/cose.js';
4
+ /**
5
+ * Match properties of the authenticator's attestation statement against expected values as
6
+ * registered with the FIDO Alliance Metadata Service
7
+ */
8
+ export declare function verifyAttestationWithMetadata({ statement, credentialPublicKey, x5c, attestationStatementAlg, }: {
9
+ statement: MetadataStatement;
10
+ credentialPublicKey: Uint8Array;
11
+ x5c: Uint8Array[] | Base64URLString[];
12
+ attestationStatementAlg?: number;
13
+ }): Promise<boolean>;
14
+ type COSEInfo = {
15
+ kty: COSEKTY;
16
+ alg: COSEALG;
17
+ crv?: COSECRV;
18
+ };
19
+ /**
20
+ * Convert ALG_SIGN values to COSE info
21
+ *
22
+ * Values pulled from `ALG_KEY_COSE` definitions in the FIDO Registry of Predefined Values
23
+ *
24
+ * https://fidoalliance.org/specs/common-specs/fido-registry-v2.2-ps-20220523.html#authentication-algorithms
25
+ */
26
+ export declare const algSignToCOSEInfoMap: {
27
+ [key in AlgSign]: COSEInfo;
28
+ };
29
+ export {};
@@ -1,19 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.algSignToCOSEInfoMap = exports.verifyAttestationWithMetadata = void 0;
4
- const convertCertBufferToPEM_1 = require("../helpers/convertCertBufferToPEM");
5
- const validateCertificatePath_1 = require("../helpers/validateCertificatePath");
6
- const decodeCredentialPublicKey_1 = require("../helpers/decodeCredentialPublicKey");
7
- const cose_1 = require("../helpers/cose");
4
+ const convertCertBufferToPEM_js_1 = require("../helpers/convertCertBufferToPEM.js");
5
+ const validateCertificatePath_js_1 = require("../helpers/validateCertificatePath.js");
6
+ const decodeCredentialPublicKey_js_1 = require("../helpers/decodeCredentialPublicKey.js");
7
+ const cose_js_1 = require("../helpers/cose.js");
8
8
  /**
9
9
  * Match properties of the authenticator's attestation statement against expected values as
10
10
  * registered with the FIDO Alliance Metadata Service
11
11
  */
12
12
  async function verifyAttestationWithMetadata({ statement, credentialPublicKey, x5c, attestationStatementAlg, }) {
13
- const { authenticationAlgorithms, authenticatorGetInfo, attestationRootCertificates } = statement;
13
+ const { authenticationAlgorithms, authenticatorGetInfo, attestationRootCertificates, } = statement;
14
14
  // Make sure the alg in the attestation statement matches one of the ones specified in metadata
15
15
  const keypairCOSEAlgs = new Set();
16
- authenticationAlgorithms.forEach(algSign => {
16
+ authenticationAlgorithms.forEach((algSign) => {
17
17
  // Map algSign string to { kty, alg, crv }
18
18
  const algSignCOSEINFO = exports.algSignToCOSEInfoMap[algSign];
19
19
  // Keeping this statement here just in case MDS returns something unexpected
@@ -22,9 +22,9 @@ async function verifyAttestationWithMetadata({ statement, credentialPublicKey, x
22
22
  }
23
23
  });
24
24
  // Extract the public key's COSE info for comparison
25
- const decodedPublicKey = (0, decodeCredentialPublicKey_1.decodeCredentialPublicKey)(credentialPublicKey);
26
- const kty = decodedPublicKey.get(cose_1.COSEKEYS.kty);
27
- const alg = decodedPublicKey.get(cose_1.COSEKEYS.alg);
25
+ const decodedPublicKey = (0, decodeCredentialPublicKey_js_1.decodeCredentialPublicKey)(credentialPublicKey);
26
+ const kty = decodedPublicKey.get(cose_js_1.COSEKEYS.kty);
27
+ const alg = decodedPublicKey.get(cose_js_1.COSEKEYS.alg);
28
28
  if (!kty) {
29
29
  throw new Error('Credential public key was missing kty');
30
30
  }
@@ -36,8 +36,8 @@ async function verifyAttestationWithMetadata({ statement, credentialPublicKey, x
36
36
  }
37
37
  // Assume everything is a number because these values should be
38
38
  const publicKeyCOSEInfo = { kty, alg };
39
- if ((0, cose_1.isCOSEPublicKeyEC2)(decodedPublicKey)) {
40
- const crv = decodedPublicKey.get(cose_1.COSEKEYS.crv);
39
+ if ((0, cose_js_1.isCOSEPublicKeyEC2)(decodedPublicKey)) {
40
+ const crv = decodedPublicKey.get(cose_js_1.COSEKEYS.crv);
41
41
  publicKeyCOSEInfo.crv = crv;
42
42
  }
43
43
  /**
@@ -47,9 +47,10 @@ async function verifyAttestationWithMetadata({ statement, credentialPublicKey, x
47
47
  let foundMatch = false;
48
48
  for (const keypairAlg of keypairCOSEAlgs) {
49
49
  // Make sure algorithm and key type match
50
- if (keypairAlg.alg === publicKeyCOSEInfo.alg && keypairAlg.kty === publicKeyCOSEInfo.kty) {
50
+ if (keypairAlg.alg === publicKeyCOSEInfo.alg &&
51
+ keypairAlg.kty === publicKeyCOSEInfo.kty) {
51
52
  // If not an RSA keypair then make sure curve numbers match too
52
- if ((keypairAlg.kty === cose_1.COSEKTY.EC2 || keypairAlg.kty === cose_1.COSEKTY.OKP) &&
53
+ if ((keypairAlg.kty === cose_js_1.COSEKTY.EC2 || keypairAlg.kty === cose_js_1.COSEKTY.OKP) &&
53
54
  keypairAlg.crv === publicKeyCOSEInfo.crv) {
54
55
  foundMatch = true;
55
56
  }
@@ -76,7 +77,7 @@ async function verifyAttestationWithMetadata({ statement, credentialPublicKey, x
76
77
  * ]
77
78
  * ```
78
79
  */
79
- const debugMDSAlgs = authenticationAlgorithms.map(algSign => `'${algSign}' (COSE info: ${stringifyCOSEInfo(exports.algSignToCOSEInfoMap[algSign])})`);
80
+ const debugMDSAlgs = authenticationAlgorithms.map((algSign) => `'${algSign}' (COSE info: ${stringifyCOSEInfo(exports.algSignToCOSEInfoMap[algSign])})`);
80
81
  const strMDSAlgs = JSON.stringify(debugMDSAlgs, null, 2).replace(/"/g, '');
81
82
  /**
82
83
  * Construct useful error output about the public key
@@ -87,27 +88,29 @@ async function verifyAttestationWithMetadata({ statement, credentialPublicKey, x
87
88
  /**
88
89
  * Confirm the attestation statement's algorithm is one supported according to metadata
89
90
  */
90
- if (attestationStatementAlg !== undefined && (authenticatorGetInfo === null || authenticatorGetInfo === void 0 ? void 0 : authenticatorGetInfo.algorithms) !== undefined) {
91
- const getInfoAlgs = authenticatorGetInfo.algorithms.map(_alg => _alg.alg);
91
+ if (attestationStatementAlg !== undefined &&
92
+ authenticatorGetInfo?.algorithms !== undefined) {
93
+ const getInfoAlgs = authenticatorGetInfo.algorithms.map((_alg) => _alg.alg);
92
94
  if (getInfoAlgs.indexOf(attestationStatementAlg) < 0) {
93
95
  throw new Error(`Attestation statement alg ${attestationStatementAlg} did not match one of ${getInfoAlgs}`);
94
96
  }
95
97
  }
96
98
  // Prepare to check the certificate chain
97
- const authenticatorCerts = x5c.map(convertCertBufferToPEM_1.convertCertBufferToPEM);
98
- const statementRootCerts = attestationRootCertificates.map(convertCertBufferToPEM_1.convertCertBufferToPEM);
99
+ const authenticatorCerts = x5c.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM);
100
+ const statementRootCerts = attestationRootCertificates.map(convertCertBufferToPEM_js_1.convertCertBufferToPEM);
99
101
  /**
100
102
  * If an authenticator returns exactly one certificate in its x5c, and that cert is found in the
101
103
  * metadata statement then the authenticator is "self-referencing". In this case we forego
102
104
  * certificate chain validation.
103
105
  */
104
106
  let authenticatorIsSelfReferencing = false;
105
- if (authenticatorCerts.length === 1 && statementRootCerts.indexOf(authenticatorCerts[0]) >= 0) {
107
+ if (authenticatorCerts.length === 1 &&
108
+ statementRootCerts.indexOf(authenticatorCerts[0]) >= 0) {
106
109
  authenticatorIsSelfReferencing = true;
107
110
  }
108
111
  if (!authenticatorIsSelfReferencing) {
109
112
  try {
110
- await (0, validateCertificatePath_1.validateCertificatePath)(authenticatorCerts, statementRootCerts);
113
+ await (0, validateCertificatePath_js_1.validateCertificatePath)(authenticatorCerts, statementRootCerts);
111
114
  }
112
115
  catch (err) {
113
116
  const _err = err;
@@ -150,7 +153,7 @@ exports.algSignToCOSEInfoMap = {
150
153
  function stringifyCOSEInfo(info) {
151
154
  const { kty, alg, crv } = info;
152
155
  let toReturn = '';
153
- if (kty !== cose_1.COSEKTY.RSA) {
156
+ if (kty !== cose_js_1.COSEKTY.RSA) {
154
157
  toReturn = `{ kty: ${kty}, alg: ${alg}, crv: ${crv} }`;
155
158
  }
156
159
  else {
@@ -158,4 +161,3 @@ function stringifyCOSEInfo(info) {
158
161
  }
159
162
  return toReturn;
160
163
  }
161
- //# sourceMappingURL=verifyAttestationWithMetadata.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Lightweight verification for FIDO MDS JWTs. Supports use of EC2 and RSA.
3
+ *
4
+ * If this ever needs to support more JWS algorithms, here's the list of them:
5
+ *
6
+ * https://www.rfc-editor.org/rfc/rfc7518.html#section-3.1
7
+ *
8
+ * (Pulled from https://www.rfc-editor.org/rfc/rfc7515#section-4.1.1)
9
+ */
10
+ export declare function verifyJWT(jwt: string, leafCert: Uint8Array): Promise<boolean>;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyJWT = void 0;
4
+ const convertX509PublicKeyToCOSE_js_1 = require("../helpers/convertX509PublicKeyToCOSE.js");
5
+ const index_js_1 = require("../helpers/iso/index.js");
6
+ const cose_js_1 = require("../helpers/cose.js");
7
+ const verifyEC2_js_1 = require("../helpers/iso/isoCrypto/verifyEC2.js");
8
+ const verifyRSA_js_1 = require("../helpers/iso/isoCrypto/verifyRSA.js");
9
+ /**
10
+ * Lightweight verification for FIDO MDS JWTs. Supports use of EC2 and RSA.
11
+ *
12
+ * If this ever needs to support more JWS algorithms, here's the list of them:
13
+ *
14
+ * https://www.rfc-editor.org/rfc/rfc7518.html#section-3.1
15
+ *
16
+ * (Pulled from https://www.rfc-editor.org/rfc/rfc7515#section-4.1.1)
17
+ */
18
+ function verifyJWT(jwt, leafCert) {
19
+ const [header, payload, signature] = jwt.split('.');
20
+ const certCOSE = (0, convertX509PublicKeyToCOSE_js_1.convertX509PublicKeyToCOSE)(leafCert);
21
+ const data = index_js_1.isoUint8Array.fromUTF8String(`${header}.${payload}`);
22
+ const signatureBytes = index_js_1.isoBase64URL.toBuffer(signature);
23
+ if ((0, cose_js_1.isCOSEPublicKeyEC2)(certCOSE)) {
24
+ return (0, verifyEC2_js_1.verifyEC2)({
25
+ data,
26
+ signature: signatureBytes,
27
+ cosePublicKey: certCOSE,
28
+ shaHashOverride: cose_js_1.COSEALG.ES256,
29
+ });
30
+ }
31
+ else if ((0, cose_js_1.isCOSEPublicKeyRSA)(certCOSE)) {
32
+ return (0, verifyRSA_js_1.verifyRSA)({
33
+ data,
34
+ signature: signatureBytes,
35
+ cosePublicKey: certCOSE,
36
+ });
37
+ }
38
+ const kty = certCOSE.get(cose_js_1.COSEKEYS.kty);
39
+ throw new Error(`JWT verification with public key of kty ${kty} is not supported by this method`);
40
+ }
41
+ exports.verifyJWT = verifyJWT;
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "commonjs"
3
+ }
@@ -0,0 +1,43 @@
1
+ import type { AttestationConveyancePreference, AuthenticationExtensionsClientInputs, AuthenticatorSelectionCriteria, COSEAlgorithmIdentifier, PublicKeyCredentialCreationOptionsJSON, PublicKeyCredentialDescriptorFuture } from '../deps.js';
2
+ export type GenerateRegistrationOptionsOpts = {
3
+ rpName: string;
4
+ rpID: string;
5
+ userID: string;
6
+ userName: string;
7
+ challenge?: string | Uint8Array;
8
+ userDisplayName?: string;
9
+ timeout?: number;
10
+ attestationType?: AttestationConveyancePreference;
11
+ excludeCredentials?: PublicKeyCredentialDescriptorFuture[];
12
+ authenticatorSelection?: AuthenticatorSelectionCriteria;
13
+ extensions?: AuthenticationExtensionsClientInputs;
14
+ supportedAlgorithmIDs?: COSEAlgorithmIdentifier[];
15
+ };
16
+ /**
17
+ * Supported crypto algo identifiers
18
+ * See https://w3c.github.io/webauthn/#sctn-alg-identifier
19
+ * and https://www.iana.org/assignments/cose/cose.xhtml#algorithms
20
+ */
21
+ export declare const supportedCOSEAlgorithmIdentifiers: COSEAlgorithmIdentifier[];
22
+ /**
23
+ * Prepare a value to pass into navigator.credentials.create(...) for authenticator "registration"
24
+ *
25
+ * **Options:**
26
+ *
27
+ * @param rpName User-visible, "friendly" website/service name
28
+ * @param rpID Valid domain name (after `https://`)
29
+ * @param userID User's website-specific unique ID
30
+ * @param userName User's website-specific username (email, etc...)
31
+ * @param challenge Random value the authenticator needs to sign and pass back
32
+ * @param userDisplayName User's actual name
33
+ * @param timeout How long (in ms) the user can take to complete attestation
34
+ * @param attestationType Specific attestation statement
35
+ * @param excludeCredentials Authenticators registered by the user so the user can't register the
36
+ * same credential multiple times
37
+ * @param authenticatorSelection Advanced criteria for restricting the types of authenticators that
38
+ * may be used
39
+ * @param extensions Additional plugins the authenticator or browser should use during attestation
40
+ * @param supportedAlgorithmIDs Array of numeric COSE algorithm identifiers supported for
41
+ * attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms
42
+ */
43
+ export declare function generateRegistrationOptions(options: GenerateRegistrationOptionsOpts): Promise<PublicKeyCredentialCreationOptionsJSON>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generateRegistrationOptions = exports.supportedCOSEAlgorithmIdentifiers = void 0;
4
- const generateChallenge_1 = require("../helpers/generateChallenge");
5
- const iso_1 = require("../helpers/iso");
4
+ const generateChallenge_js_1 = require("../helpers/generateChallenge.js");
5
+ const index_js_1 = require("../helpers/iso/index.js");
6
6
  /**
7
7
  * Supported crypto algo identifiers
8
8
  * See https://w3c.github.io/webauthn/#sctn-alg-identifier
@@ -69,12 +69,12 @@ const defaultSupportedAlgorithmIDs = [-8, -7, -257];
69
69
  * @param supportedAlgorithmIDs Array of numeric COSE algorithm identifiers supported for
70
70
  * attestation by this RP. See https://www.iana.org/assignments/cose/cose.xhtml#algorithms
71
71
  */
72
- function generateRegistrationOptions(options) {
73
- const { rpName, rpID, userID, userName, challenge = (0, generateChallenge_1.generateChallenge)(), userDisplayName = userName, timeout = 60000, attestationType = 'none', excludeCredentials = [], authenticatorSelection = defaultAuthenticatorSelection, extensions, supportedAlgorithmIDs = defaultSupportedAlgorithmIDs, } = options;
72
+ async function generateRegistrationOptions(options) {
73
+ const { rpName, rpID, userID, userName, challenge = await (0, generateChallenge_js_1.generateChallenge)(), userDisplayName = userName, timeout = 60000, attestationType = 'none', excludeCredentials = [], authenticatorSelection = defaultAuthenticatorSelection, extensions, supportedAlgorithmIDs = defaultSupportedAlgorithmIDs, } = options;
74
74
  /**
75
75
  * Prepare pubKeyCredParams from the array of algorithm ID's
76
76
  */
77
- const pubKeyCredParams = supportedAlgorithmIDs.map(id => ({
77
+ const pubKeyCredParams = supportedAlgorithmIDs.map((id) => ({
78
78
  alg: id,
79
79
  type: 'public-key',
80
80
  }));
@@ -116,10 +116,10 @@ function generateRegistrationOptions(options) {
116
116
  */
117
117
  let _challenge = challenge;
118
118
  if (typeof _challenge === 'string') {
119
- _challenge = iso_1.isoUint8Array.fromASCIIString(_challenge);
119
+ _challenge = index_js_1.isoUint8Array.fromASCIIString(_challenge);
120
120
  }
121
121
  return {
122
- challenge: iso_1.isoBase64URL.fromBuffer(_challenge),
122
+ challenge: index_js_1.isoBase64URL.fromBuffer(_challenge),
123
123
  rp: {
124
124
  name: rpName,
125
125
  id: rpID,
@@ -132,9 +132,9 @@ function generateRegistrationOptions(options) {
132
132
  pubKeyCredParams,
133
133
  timeout,
134
134
  attestation: attestationType,
135
- excludeCredentials: excludeCredentials.map(cred => ({
135
+ excludeCredentials: excludeCredentials.map((cred) => ({
136
136
  ...cred,
137
- id: iso_1.isoBase64URL.fromBuffer(cred.id),
137
+ id: index_js_1.isoBase64URL.fromBuffer(cred.id),
138
138
  })),
139
139
  authenticatorSelection,
140
140
  extensions: {
@@ -144,4 +144,3 @@ function generateRegistrationOptions(options) {
144
144
  };
145
145
  }
146
146
  exports.generateRegistrationOptions = generateRegistrationOptions;
147
- //# sourceMappingURL=generateRegistrationOptions.js.map
@@ -0,0 +1,47 @@
1
+ /**
2
+ * A whole lotta domain knowledge is captured here, with hazy connections to source
3
+ * documents. Good places to start searching for more info on these values are the
4
+ * following Trusted Computing Group TPM Library docs linked in the WebAuthn API:
5
+ *
6
+ * - https://www.trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-1-Architecture-01.38.pdf
7
+ * - https://www.trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-2-Structures-01.38.pdf
8
+ * - https://www.trustedcomputinggroup.org/wp-content/uploads/TPM-Rev-2.0-Part-3-Commands-01.38.pdf
9
+ */
10
+ /**
11
+ * 6.9 TPM_ST (Structure Tags)
12
+ */
13
+ export declare const TPM_ST: {
14
+ [key: number]: string;
15
+ };
16
+ /**
17
+ * 6.3 TPM_ALG_ID
18
+ */
19
+ export declare const TPM_ALG: {
20
+ [key: number]: string;
21
+ };
22
+ /**
23
+ * 6.4 TPM_ECC_CURVE
24
+ */
25
+ export declare const TPM_ECC_CURVE: {
26
+ [key: number]: string;
27
+ };
28
+ type ManufacturerInfo = {
29
+ name: string;
30
+ id: string;
31
+ };
32
+ /**
33
+ * Sourced from https://trustedcomputinggroup.org/resource/vendor-id-registry/
34
+ *
35
+ * Latest version:
36
+ * https://trustedcomputinggroup.org/wp-content/uploads/TCG-TPM-Vendor-ID-Registry-Version-1.02-Revision-1.00.pdf
37
+ */
38
+ export declare const TPM_MANUFACTURERS: {
39
+ [key: string]: ManufacturerInfo;
40
+ };
41
+ /**
42
+ * Match TPM public area curve ID's to `crv` numbers used in COSE public keys
43
+ */
44
+ export declare const TPM_ECC_CURVE_COSE_CRV_MAP: {
45
+ [key: string]: number;
46
+ };
47
+ export {};
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/ban-ts-comment */
2
+ // deno-lint-ignore-file no-dupe-keys
3
3
  /**
4
4
  * A whole lotta domain knowledge is captured here, with hazy connections to source
5
5
  * documents. Good places to start searching for more info on these values are the
@@ -183,4 +183,3 @@ exports.TPM_ECC_CURVE_COSE_CRV_MAP = {
183
183
  TPM_ECC_BN_P256: 1,
184
184
  TPM_ECC_SM2_P256: 1, // p256
185
185
  };
186
- //# sourceMappingURL=constants.js.map
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Cut up a TPM attestation's certInfo into intelligible chunks
3
+ */
4
+ export declare function parseCertInfo(certInfo: Uint8Array): ParsedCertInfo;
5
+ type ParsedCertInfo = {
6
+ magic: number;
7
+ type: string;
8
+ qualifiedSigner: Uint8Array;
9
+ extraData: Uint8Array;
10
+ clockInfo: {
11
+ clock: Uint8Array;
12
+ resetCount: number;
13
+ restartCount: number;
14
+ safe: boolean;
15
+ };
16
+ firmwareVersion: Uint8Array;
17
+ attested: {
18
+ nameAlg: string;
19
+ nameAlgBuffer: Uint8Array;
20
+ name: Uint8Array;
21
+ qualifiedName: Uint8Array;
22
+ };
23
+ };
24
+ export {};