@suveren/gateway 0.40.0 → 0.41.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/content/guides/6-risks.md +1 -0
  2. package/dist/control-plane/index.mjs +182 -37
  3. package/dist/mcp-server/http.mjs +357 -71
  4. package/dist/ui/assets/{index-C-lA_7Lt.js → index-CO-dj98E.js} +27 -27
  5. package/dist/ui/index.html +1 -1
  6. package/node_modules/@hap/core/README.md +3 -3
  7. package/node_modules/@hap/core/dist/index.d.mts +567 -123
  8. package/node_modules/@hap/core/dist/index.d.ts +567 -123
  9. package/node_modules/@hap/core/dist/index.js +869 -23
  10. package/node_modules/@hap/core/dist/index.mjs +829 -22
  11. package/node_modules/@hap/core/node_modules/@hpke/core/LICENSE +21 -0
  12. package/node_modules/@hap/core/node_modules/@hpke/core/README.md +263 -0
  13. package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts +11 -0
  14. package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.d.ts.map +1 -0
  15. package/node_modules/@hap/core/node_modules/@hpke/core/esm/mod.js +6 -0
  16. package/node_modules/@hap/core/node_modules/@hpke/core/esm/package.json +3 -0
  17. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts +80 -0
  18. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.d.ts.map +1 -0
  19. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/aesGcm.js +167 -0
  20. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts +34 -0
  21. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.d.ts.map +1 -0
  22. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/aeads/exportOnly.js +56 -0
  23. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts +145 -0
  24. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.d.ts.map +1 -0
  25. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/cipherSuiteNative.js +326 -0
  26. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts +15 -0
  27. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.d.ts.map +1 -0
  28. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/encryptionContext.js +68 -0
  29. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts +19 -0
  30. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.d.ts.map +1 -0
  31. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/exporterContext.js +62 -0
  32. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts +17 -0
  33. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.d.ts.map +1 -0
  34. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/aeadParams.js +1 -0
  35. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts +13 -0
  36. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
  37. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/cipherSuiteParams.js +1 -0
  38. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts +8 -0
  39. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.d.ts.map +1 -0
  40. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encapsulator.js +1 -0
  41. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts +40 -0
  42. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.d.ts.map +1 -0
  43. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/encryptionContext.js +1 -0
  44. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts +17 -0
  45. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.d.ts.map +1 -0
  46. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/exporter.js +1 -0
  47. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts +7 -0
  48. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.d.ts.map +1 -0
  49. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/keyInfo.js +1 -0
  50. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts +10 -0
  51. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.d.ts.map +1 -0
  52. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/interfaces/responses.js +1 -0
  53. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts +26 -0
  54. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.d.ts.map +1 -0
  55. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemNative.js +112 -0
  56. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
  57. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
  58. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +214 -0
  59. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +24 -0
  60. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
  61. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +214 -0
  62. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts +38 -0
  63. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.d.ts.map +1 -0
  64. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX25519.js +66 -0
  65. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts +38 -0
  66. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.d.ts.map +1 -0
  67. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/kems/dhkemX448.js +66 -0
  68. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts +5 -0
  69. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.d.ts.map +1 -0
  70. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/mutex.js +28 -0
  71. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts +236 -0
  72. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.d.ts.map +1 -0
  73. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/native.js +235 -0
  74. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts +6 -0
  75. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.d.ts.map +1 -0
  76. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/recipientContext.js +38 -0
  77. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts +11 -0
  78. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.d.ts.map +1 -0
  79. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/senderContext.js +45 -0
  80. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts +2 -0
  81. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.d.ts.map +1 -0
  82. package/node_modules/@hap/core/node_modules/@hpke/core/esm/src/utils/emitNotSupported.js +6 -0
  83. package/node_modules/@hap/core/node_modules/@hpke/core/package.json +46 -0
  84. package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts +11 -0
  85. package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.d.ts.map +1 -0
  86. package/node_modules/@hap/core/node_modules/@hpke/core/script/mod.js +47 -0
  87. package/node_modules/@hap/core/node_modules/@hpke/core/script/package.json +3 -0
  88. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts +80 -0
  89. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.d.ts.map +1 -0
  90. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/aesGcm.js +183 -0
  91. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts +34 -0
  92. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.d.ts.map +1 -0
  93. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/aeads/exportOnly.js +70 -0
  94. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts +145 -0
  95. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.d.ts.map +1 -0
  96. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/cipherSuiteNative.js +340 -0
  97. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts +15 -0
  98. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.d.ts.map +1 -0
  99. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/encryptionContext.js +82 -0
  100. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts +19 -0
  101. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.d.ts.map +1 -0
  102. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/exporterContext.js +78 -0
  103. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts +17 -0
  104. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.d.ts.map +1 -0
  105. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/aeadParams.js +12 -0
  106. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts +13 -0
  107. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.d.ts.map +1 -0
  108. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/cipherSuiteParams.js +12 -0
  109. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts +8 -0
  110. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.d.ts.map +1 -0
  111. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encapsulator.js +12 -0
  112. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts +40 -0
  113. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.d.ts.map +1 -0
  114. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/encryptionContext.js +12 -0
  115. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts +17 -0
  116. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.d.ts.map +1 -0
  117. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/exporter.js +12 -0
  118. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts +7 -0
  119. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.d.ts.map +1 -0
  120. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/keyInfo.js +12 -0
  121. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts +10 -0
  122. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.d.ts.map +1 -0
  123. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/interfaces/responses.js +12 -0
  124. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts +26 -0
  125. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.d.ts.map +1 -0
  126. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemNative.js +128 -0
  127. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +24 -0
  128. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -0
  129. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +228 -0
  130. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +24 -0
  131. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -0
  132. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +228 -0
  133. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts +38 -0
  134. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.d.ts.map +1 -0
  135. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX25519.js +80 -0
  136. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts +38 -0
  137. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.d.ts.map +1 -0
  138. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/kems/dhkemX448.js +80 -0
  139. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts +5 -0
  140. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.d.ts.map +1 -0
  141. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/mutex.js +42 -0
  142. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts +236 -0
  143. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.d.ts.map +1 -0
  144. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/native.js +255 -0
  145. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts +6 -0
  146. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.d.ts.map +1 -0
  147. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/recipientContext.js +52 -0
  148. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts +11 -0
  149. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.d.ts.map +1 -0
  150. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/senderContext.js +59 -0
  151. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts +2 -0
  152. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.d.ts.map +1 -0
  153. package/node_modules/@hap/core/node_modules/@hpke/core/script/src/utils/emitNotSupported.js +19 -0
  154. package/node_modules/@hap/core/package.json +2 -1
  155. package/node_modules/@hap/core/src/canonicalize.ts +9 -0
  156. package/node_modules/@hap/core/src/commitment-modes.ts +21 -9
  157. package/node_modules/@hap/core/src/errors.ts +24 -8
  158. package/node_modules/@hap/core/src/gatekeeper.ts +52 -8
  159. package/node_modules/@hap/core/src/index.ts +5 -1
  160. package/node_modules/@hap/core/src/issuance.ts +250 -0
  161. package/node_modules/@hap/core/src/mandate.ts +52 -14
  162. package/node_modules/@hap/core/src/owner-signature.ts +86 -39
  163. package/node_modules/@hap/core/src/profile.ts +45 -0
  164. package/node_modules/@hap/core/src/proposal-content.ts +219 -0
  165. package/node_modules/@hap/core/src/ticket-projection.ts +167 -0
  166. package/node_modules/@hap/core/src/ticket.ts +254 -20
  167. package/node_modules/@hap/core/src/types.ts +33 -5
  168. package/node_modules/@hap/core/src/verifier-policy.ts +178 -0
  169. package/node_modules/@hap/core/src/versions.ts +50 -19
  170. package/node_modules/@hono/node-server/dist/index.cjs +31 -6
  171. package/node_modules/@hono/node-server/dist/index.mjs +31 -6
  172. package/node_modules/@hono/node-server/package.json +1 -1
  173. package/node_modules/@hpke/common/esm/package.json +5 -1
  174. package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts +2 -2
  175. package/node_modules/@hpke/common/esm/src/curve/montgomery.d.ts.map +1 -1
  176. package/node_modules/@hpke/common/esm/src/curve/montgomery.js +41 -26
  177. package/node_modules/@hpke/common/esm/src/hash/sha3.d.ts.map +1 -1
  178. package/node_modules/@hpke/common/esm/src/hash/sha3.js +0 -15
  179. package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts +2 -1
  180. package/node_modules/@hpke/common/esm/src/kdfs/hkdf.d.ts.map +1 -1
  181. package/node_modules/@hpke/common/esm/src/kdfs/hkdf.js +12 -2
  182. package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
  183. package/node_modules/@hpke/common/esm/src/kems/dhkemPrimitives/xCurve.js +14 -3
  184. package/node_modules/@hpke/common/esm/src/utils/misc.d.ts +6 -0
  185. package/node_modules/@hpke/common/esm/src/utils/misc.d.ts.map +1 -1
  186. package/node_modules/@hpke/common/esm/src/utils/misc.js +43 -10
  187. package/node_modules/@hpke/common/esm/src/utils/noble.d.ts +1 -1
  188. package/node_modules/@hpke/common/esm/src/utils/noble.d.ts.map +1 -1
  189. package/node_modules/@hpke/common/esm/src/utils/noble.js +21 -10
  190. package/node_modules/@hpke/common/package.json +5 -1
  191. package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts +2 -2
  192. package/node_modules/@hpke/common/script/src/curve/montgomery.d.ts.map +1 -1
  193. package/node_modules/@hpke/common/script/src/curve/montgomery.js +40 -25
  194. package/node_modules/@hpke/common/script/src/hash/sha3.d.ts.map +1 -1
  195. package/node_modules/@hpke/common/script/src/hash/sha3.js +0 -15
  196. package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts +2 -1
  197. package/node_modules/@hpke/common/script/src/kdfs/hkdf.d.ts.map +1 -1
  198. package/node_modules/@hpke/common/script/src/kdfs/hkdf.js +12 -2
  199. package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.d.ts.map +1 -1
  200. package/node_modules/@hpke/common/script/src/kems/dhkemPrimitives/xCurve.js +13 -2
  201. package/node_modules/@hpke/common/script/src/utils/misc.d.ts +6 -0
  202. package/node_modules/@hpke/common/script/src/utils/misc.d.ts.map +1 -1
  203. package/node_modules/@hpke/common/script/src/utils/misc.js +43 -9
  204. package/node_modules/@hpke/common/script/src/utils/noble.d.ts +1 -1
  205. package/node_modules/@hpke/common/script/src/utils/noble.d.ts.map +1 -1
  206. package/node_modules/@hpke/common/script/src/utils/noble.js +22 -11
  207. package/node_modules/@hpke/core/README.md +56 -56
  208. package/node_modules/@hpke/core/esm/package.json +2 -1
  209. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
  210. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
  211. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x25519.js +3 -201
  212. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts +3 -21
  213. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
  214. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/x448.js +3 -201
  215. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
  216. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
  217. package/node_modules/@hpke/core/esm/src/kems/dhkemPrimitives/xCurveNative.js +216 -0
  218. package/node_modules/@hpke/core/package.json +6 -2
  219. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts +3 -21
  220. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.d.ts.map +1 -1
  221. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x25519.js +4 -202
  222. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts +3 -21
  223. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.d.ts.map +1 -1
  224. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/x448.js +4 -202
  225. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts +26 -0
  226. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.d.ts.map +1 -0
  227. package/node_modules/@hpke/core/script/src/kems/dhkemPrimitives/xCurveNative.js +230 -0
  228. package/node_modules/@types/node/README.md +1 -1
  229. package/node_modules/@types/node/package.json +2 -2
  230. package/node_modules/@types/node/zlib.d.ts +752 -0
  231. package/node_modules/encodeurl/README.md +14 -0
  232. package/node_modules/encodeurl/index.js +5 -10
  233. package/node_modules/encodeurl/package.json +10 -6
  234. package/node_modules/express-rate-limit/dist/index.cjs +7 -3
  235. package/node_modules/express-rate-limit/dist/index.mjs +7 -3
  236. package/node_modules/express-rate-limit/package.json +10 -10
  237. package/node_modules/hono/dist/cjs/adapter/bun/serve-static.js +1 -1
  238. package/node_modules/hono/dist/cjs/adapter/bun/websocket.js +1 -1
  239. package/node_modules/hono/dist/cjs/context.js +1 -1
  240. package/node_modules/hono/dist/cjs/helper/css/common.js +3 -5
  241. package/node_modules/hono/dist/cjs/hono-base.js +4 -10
  242. package/node_modules/hono/dist/cjs/hono.js +0 -1
  243. package/node_modules/hono/dist/cjs/middleware/basic-auth/index.js +1 -1
  244. package/node_modules/hono/dist/cjs/middleware/bearer-auth/index.js +1 -1
  245. package/node_modules/hono/dist/cjs/middleware/csrf/index.js +2 -2
  246. package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +2 -2
  247. package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +2 -2
  248. package/node_modules/hono/dist/cjs/middleware/mount/index.js +4 -4
  249. package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +13 -11
  250. package/node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js +4 -4
  251. package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +39 -51
  252. package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +15 -5
  253. package/node_modules/hono/dist/cjs/utils/jwt/jwt.js +2 -1
  254. package/node_modules/hono/dist/cjs/utils/mount.js +35 -0
  255. package/node_modules/hono/dist/cjs/utils/url.js +10 -0
  256. package/node_modules/hono/dist/cjs/validator/validator.js +1 -1
  257. package/node_modules/hono/dist/context.js +1 -1
  258. package/node_modules/hono/dist/helper/css/common.js +3 -5
  259. package/node_modules/hono/dist/hono-base.js +4 -10
  260. package/node_modules/hono/dist/hono.js +0 -1
  261. package/node_modules/hono/dist/middleware/basic-auth/index.js +1 -1
  262. package/node_modules/hono/dist/middleware/bearer-auth/index.js +1 -1
  263. package/node_modules/hono/dist/middleware/csrf/index.js +2 -2
  264. package/node_modules/hono/dist/middleware/jwk/jwk.js +2 -2
  265. package/node_modules/hono/dist/middleware/jwt/jwt.js +2 -2
  266. package/node_modules/hono/dist/middleware/language/language.js +1 -1
  267. package/node_modules/hono/dist/middleware/mount/index.js +4 -4
  268. package/node_modules/hono/dist/router/reg-exp-router/node.js +13 -11
  269. package/node_modules/hono/dist/router/reg-exp-router/prepared-router.js +5 -5
  270. package/node_modules/hono/dist/router/reg-exp-router/router.js +40 -52
  271. package/node_modules/hono/dist/router/reg-exp-router/trie.js +15 -5
  272. package/node_modules/hono/dist/types/middleware/mount/index.d.ts +1 -0
  273. package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -3
  274. package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +1 -1
  275. package/node_modules/hono/dist/types/utils/mount.d.ts +4 -0
  276. package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
  277. package/node_modules/hono/dist/utils/jwt/jwt.js +2 -1
  278. package/node_modules/hono/dist/utils/mount.js +34 -0
  279. package/node_modules/hono/dist/utils/url.js +10 -1
  280. package/node_modules/hono/dist/validator/validator.js +1 -1
  281. package/node_modules/hono/package.json +1 -1
  282. package/node_modules/ip-address/README.md +39 -39
  283. package/node_modules/ip-address/dist/ipv6.js +1 -1
  284. package/node_modules/ip-address/dist/ipv6.js.map +1 -1
  285. package/node_modules/ip-address/package.json +1 -1
  286. package/node_modules/jose/dist/types/jwt/decrypt.d.ts +3 -0
  287. package/node_modules/jose/dist/types/jwt/unsecured.d.ts +2 -0
  288. package/node_modules/jose/dist/types/jwt/verify.d.ts +3 -0
  289. package/node_modules/jose/dist/types/types.d.ts +8 -0
  290. package/node_modules/jose/dist/types/util/decode_jwt.d.ts +1 -0
  291. package/node_modules/jose/dist/webapi/jwks/remote.js +3 -1
  292. package/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
  293. package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +2 -1
  294. package/node_modules/jose/package.json +1 -1
  295. package/node_modules/qs/CHANGELOG.md +29 -22
  296. package/node_modules/qs/dist/qs.js +14 -14
  297. package/node_modules/qs/eslint.config.mjs +6 -0
  298. package/node_modules/qs/lib/stringify.js +1 -1
  299. package/node_modules/qs/package.json +5 -5
  300. package/node_modules/qs/test/stringify.js +74 -0
  301. package/package.json +2 -2
@@ -52,6 +52,12 @@ export declare function bytesToHex(v: Uint8Array): string;
52
52
  */
53
53
  export declare function kemToKeyGenAlgorithm(kem: KemId): KeyAlgorithm;
54
54
  export declare function loadSubtleCrypto(): Promise<SubtleCrypto>;
55
+ /**
56
+ * Returns the Crypto object synchronously.
57
+ * Uses globalThis.crypto on modern runtimes, with a CJS require("crypto")
58
+ * fallback for Node.js <= v18. The result is cached after the first call.
59
+ */
60
+ export declare function getCrypto(): Crypto;
55
61
  export declare function loadCrypto(): Promise<Crypto>;
56
62
  /**
57
63
  * XOR for Uint8Array.
@@ -1 +1 @@
1
- {"version":3,"file":"misc.d.ts","sourceRoot":"","sources":["../../../src/src/utils/misc.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAA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hC;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,MAAO,OAAO,KAAG,CAAC,IAAI,aAIE,CAAC;AAErD;;GAEG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAatD;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAK/D;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAQtD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAKtD;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAWhD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,KAAK,GAAG,YAAY,CAuB7D;AAED,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CAa9D;AAKD;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAqBlC;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAclD;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAS5D"}
@@ -43,6 +43,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
43
43
  exports.bytesToHex = bytesToHex;
44
44
  exports.kemToKeyGenAlgorithm = kemToKeyGenAlgorithm;
45
45
  exports.loadSubtleCrypto = loadSubtleCrypto;
46
+ exports.getCrypto = getCrypto;
46
47
  exports.loadCrypto = loadCrypto;
47
48
  exports.xor = xor;
48
49
  const dntShim = __importStar(require("../../_dnt.shims.js"));
@@ -195,19 +196,52 @@ var __importStar = (this && this.__importStar) || function (mod) {
195
196
  throw new Error("Failed to load SubtleCrypto");
196
197
  }
197
198
  }
198
- async function loadCrypto() {
199
+ /** Cached reference to the Crypto object for synchronous access. */
200
+ let _cryptoApi;
201
+ /**
202
+ * Returns the Crypto object synchronously.
203
+ * Uses globalThis.crypto on modern runtimes, with a CJS require("crypto")
204
+ * fallback for Node.js <= v18. The result is cached after the first call.
205
+ */
206
+ function getCrypto() {
207
+ if (_cryptoApi)
208
+ return _cryptoApi;
209
+ // Modern runtimes: Deno, browsers, Node.js >= 17.6, Bun, Cloudflare Workers
199
210
  if (typeof dntShim.dntGlobalThis !== "undefined" && globalThis.crypto !== undefined) {
200
- // Browsers, Node.js >= v19, Cloudflare Workers, Bun, etc.
201
- return globalThis.crypto;
211
+ _cryptoApi = globalThis.crypto;
212
+ return _cryptoApi;
202
213
  }
203
- // Node.js <= v18
214
+ // Node.js <= v18 CJS fallback: require is a module-local binding in CJS
215
+ // (not on globalThis), so we reference it directly.
204
216
  try {
205
- // @ts-ignore: to ignore "crypto"
206
- const { webcrypto } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("crypto"))) : new Promise((resolve_2, reject_2) => { require(["crypto"], resolve_2, reject_2); }).then(__importStar)); // node:crypto
207
- return webcrypto;
217
+ // @ts-ignore: require exists in CJS builds via dnt
218
+ if (typeof require === "function") {
219
+ // @ts-ignore: require exists in CJS builds via dnt
220
+ const { webcrypto } = require("crypto");
221
+ _cryptoApi = webcrypto;
222
+ return _cryptoApi;
223
+ }
208
224
  }
209
- catch (_e) {
210
- throw new Error("failed to load Crypto");
225
+ catch {
226
+ // ignore
227
+ }
228
+ throw new Error("crypto.getRandomValues must be defined");
229
+ }
230
+ async function loadCrypto() {
231
+ try {
232
+ return getCrypto();
233
+ }
234
+ catch {
235
+ // ESM fallback for Node.js <= v18 (require not available)
236
+ try {
237
+ // @ts-ignore: to ignore "crypto"
238
+ const { webcrypto } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("crypto"))) : new Promise((resolve_2, reject_2) => { require(["crypto"], resolve_2, reject_2); }).then(__importStar)); // node:crypto
239
+ _cryptoApi = webcrypto;
240
+ return _cryptoApi;
241
+ }
242
+ catch (_e) {
243
+ throw new Error("failed to load Crypto");
244
+ }
211
245
  }
212
246
  }
213
247
  /**
@@ -110,7 +110,7 @@ export interface Signer extends CryptoKeys {
110
110
  verify: (sig: Uint8Array, msg: Uint8Array, publicKey: Uint8Array) => boolean;
111
111
  }
112
112
  /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
113
- export declare function randomBytesAsync(bytesLength?: number): Promise<Uint8Array>;
113
+ export declare function randomBytes(bytesLength?: number): Uint8Array;
114
114
  export declare function oidNist(suffix: number): {
115
115
  oid: Uint8Array;
116
116
  };
@@ -1 +1 @@
1
- {"version":3,"file":"noble.d.ts","sourceRoot":"","sources":["../../../src/src/utils/noble.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAUH,qFAAqF;AACrF,wBAAgB,OAAO,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,UAAU,CAGnD;AAED,6CAA6C;AAC7C,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,GAAE,MAAW,GAAG,IAAI,CAK3D;AAED,uCAAuC;AACvC,wBAAgB,MAAM,CACpB,KAAK,EAAE,UAAU,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,GAAE,MAAW,GACjB,UAAU,CAWZ;AAID,gEAAgE;AAChE,wBAAgB,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,UAAO,GAAG,IAAI,CAKjE;AAED,kDAAkD;AAClD,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,IAAI,CAMrD;AAUD,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAClB,SAAS,GACT,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,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15
15
  else if (typeof define === "function" && define.amd) {
16
- define(["require", "exports", "./misc.js", "../consts.js"], factory);
16
+ define(["require", "exports", "../consts.js", "./misc.js"], factory);
17
17
  }
18
18
  })(function (require, exports) {
19
19
  "use strict";
@@ -49,14 +49,14 @@
49
49
  exports.inRange = inRange;
50
50
  exports.aInRange = aInRange;
51
51
  exports.validateObject = validateObject;
52
- exports.randomBytesAsync = randomBytesAsync;
52
+ exports.randomBytes = randomBytes;
53
53
  exports.oidNist = oidNist;
54
54
  /**
55
55
  * Hex, bytes and number utilities.
56
56
  * @module
57
57
  */
58
- const misc_js_1 = require("./misc.js");
59
58
  const consts_js_1 = require("../consts.js");
59
+ const misc_js_1 = require("./misc.js");
60
60
  /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
61
61
  function isBytes(a) {
62
62
  return a instanceof Uint8Array ||
@@ -163,7 +163,7 @@
163
163
  typeof Uint8Array.fromHex === "function")();
164
164
  // Array where index 0xf0 (240) is mapped to string 'f0'
165
165
  const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
166
- const HEX_TO_BIGINT = /* @__PURE__ */ [
166
+ const HEX_TO_BIGINT = [
167
167
  0n,
168
168
  1n,
169
169
  2n,
@@ -290,7 +290,12 @@
290
290
  return hexToNumber(bytesToHex(bytes));
291
291
  }
292
292
  function bytesToNumberLE(bytes) {
293
- return hexToNumber(bytesToHex(copyBytes(abytes(bytes)).reverse()));
293
+ abytes(bytes);
294
+ let result = consts_js_1.N_0;
295
+ for (let i = bytes.length - 1; i >= 0; i--) {
296
+ result = (result << 8n) | BigInt(bytes[i]);
297
+ }
298
+ return result;
294
299
  }
295
300
  function numberToBytesBE(n, len) {
296
301
  anumber(len);
@@ -301,7 +306,16 @@
301
306
  return res;
302
307
  }
303
308
  function numberToBytesLE(n, len) {
304
- return numberToBytesBE(n, len).reverse();
309
+ anumber(len);
310
+ let v = BigInt(abignumer(n));
311
+ const result = new Uint8Array(len);
312
+ for (let i = 0; i < len; i++) {
313
+ result[i] = Number(v & 0xffn);
314
+ v >>= 8n;
315
+ }
316
+ if (v !== consts_js_1.N_0)
317
+ throw new Error("number too large");
318
+ return result;
305
319
  }
306
320
  /**
307
321
  * Copies Uint8Array. We can't use u8a.slice(), because u8a can be Buffer,
@@ -389,11 +403,8 @@
389
403
  // return cr.getRandomValues(new Uint8Array(bytesLength));
390
404
  // }
391
405
  /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
392
- async function randomBytesAsync(bytesLength = 32) {
393
- const api = await (0, misc_js_1.loadCrypto)();
394
- const rnd = new Uint8Array(bytesLength);
395
- api.getRandomValues(rnd);
396
- return rnd;
406
+ function randomBytes(bytesLength = 32) {
407
+ return (0, misc_js_1.getCrypto)().getRandomValues(new Uint8Array(bytesLength));
397
408
  }
398
409
  // 06 09 60 86 48 01 65 03 04 02
399
410
  function oidNist(suffix) {
@@ -77,24 +77,24 @@ Using esm.sh:
77
77
  ```html
78
78
  <!-- use a specific version -->
79
79
  <script type="module">
80
- import {
81
- Aes128Gcm,
82
- CipherSuite,
83
- DhkemP256HkdfSha256,
84
- HkdfSha256,
85
- } from "https://esm.sh/@hpke/core@<SEMVER>";
86
- // ...
80
+ import {
81
+ Aes128Gcm,
82
+ CipherSuite,
83
+ DhkemP256HkdfSha256,
84
+ HkdfSha256,
85
+ } from "https://esm.sh/@hpke/core@<SEMVER>";
86
+ // ...
87
87
  </script>
88
88
 
89
89
  <!-- use the latest stable version -->
90
90
  <script type="module">
91
- import {
92
- Aes128Gcm,
93
- CipherSuite,
94
- DhkemP256HkdfSha256,
95
- HkdfSha256,
96
- } from "https://esm.sh/@hpke/core";
97
- // ...
91
+ import {
92
+ Aes128Gcm,
93
+ CipherSuite,
94
+ DhkemP256HkdfSha256,
95
+ HkdfSha256,
96
+ } from "https://esm.sh/@hpke/core";
97
+ // ...
98
98
  </script>
99
99
  ```
100
100
 
@@ -103,8 +103,8 @@ Using unpkg:
103
103
  ```html
104
104
  <!-- use a specific version -->
105
105
  <script type="module">
106
- import * as hpke from "https://unpkg.com/@hpke/core@<SEMVER>/esm/mod.js";
107
- // ...
106
+ import * as hpke from "https://unpkg.com/@hpke/core@<SEMVER>/esm/mod.js";
107
+ // ...
108
108
  </script>
109
109
  ```
110
110
 
@@ -211,46 +211,46 @@ try {
211
211
  <head></head>
212
212
  <body>
213
213
  <script type="module">
214
- import {
215
- Aes128Gcm,
216
- CipherSuite,
217
- DhkemP256HkdfSha256,
218
- HkdfSha256,
219
- } from "https://esm.sh/@hpke/core";
220
-
221
- globalThis.doHpke = async () => {
222
- const suite = new CipherSuite({
223
- kem: new DhkemP256HkdfSha256(),
224
- kdf: new HkdfSha256(),
225
- aead: new Aes128Gcm(),
226
- });
227
-
228
- const rkp = await suite.kem.generateKeyPair();
229
-
230
- const sender = await suite.createSenderContext({
231
- recipientPublicKey: rkp.publicKey,
232
- });
233
-
234
- const recipient = await suite.createRecipientContext({
235
- recipientKey: rkp.privateKey, // rkp (CryptoKeyPair) is also acceptable.
236
- enc: sender.enc,
237
- });
238
-
239
- // encrypt
240
- const ct = await sender.seal(
241
- new TextEncoder().encode("hello world!"),
242
- );
243
-
244
- // decrypt
245
- try {
246
- const pt = await recipient.open(ct);
247
-
248
- // hello world!
249
- alert(new TextDecoder().decode(pt));
250
- } catch (err) {
251
- alert("failed to decrypt.");
252
- }
253
- };
214
+ import {
215
+ Aes128Gcm,
216
+ CipherSuite,
217
+ DhkemP256HkdfSha256,
218
+ HkdfSha256,
219
+ } from "https://esm.sh/@hpke/core";
220
+
221
+ globalThis.doHpke = async () => {
222
+ const suite = new CipherSuite({
223
+ kem: new DhkemP256HkdfSha256(),
224
+ kdf: new HkdfSha256(),
225
+ aead: new Aes128Gcm(),
226
+ });
227
+
228
+ const rkp = await suite.kem.generateKeyPair();
229
+
230
+ const sender = await suite.createSenderContext({
231
+ recipientPublicKey: rkp.publicKey,
232
+ });
233
+
234
+ const recipient = await suite.createRecipientContext({
235
+ recipientKey: rkp.privateKey, // rkp (CryptoKeyPair) is also acceptable.
236
+ enc: sender.enc,
237
+ });
238
+
239
+ // encrypt
240
+ const ct = await sender.seal(
241
+ new TextEncoder().encode("hello world!"),
242
+ );
243
+
244
+ // decrypt
245
+ try {
246
+ const pt = await recipient.open(ct);
247
+
248
+ // hello world!
249
+ alert(new TextDecoder().decode(pt));
250
+ } catch (err) {
251
+ alert("failed to decrypt.");
252
+ }
253
+ };
254
254
  </script>
255
255
  <button type="button" onclick="doHpke()">do HPKE</button>
256
256
  </body>
@@ -1,3 +1,4 @@
1
1
  {
2
- "type": "module"
2
+ "type": "module",
3
+ "sideEffects": false
3
4
  }
@@ -1,24 +1,6 @@
1
- import type { DhkemPrimitives, KdfInterface } from "@hpke/common";
2
- import { NativeAlgorithm } from "@hpke/common";
3
- export declare class X25519 extends NativeAlgorithm implements DhkemPrimitives {
4
- private _hkdf;
5
- private _alg;
6
- private _nPk;
7
- private _nSk;
8
- private _nDh;
9
- private _pkcs8AlgId;
1
+ import type { KdfInterface } from "@hpke/common";
2
+ import { XCurveNativeDhkemPrimitives } from "./xCurveNative.js";
3
+ export declare class X25519 extends XCurveNativeDhkemPrimitives {
10
4
  constructor(hkdf: KdfInterface);
11
- serializePublicKey(key: CryptoKey): Promise<ArrayBuffer>;
12
- deserializePublicKey(key: ArrayBufferLike | ArrayBufferView): Promise<CryptoKey>;
13
- serializePrivateKey(key: CryptoKey): Promise<ArrayBuffer>;
14
- deserializePrivateKey(key: ArrayBufferLike | ArrayBufferView): Promise<CryptoKey>;
15
- importKey(format: "raw" | "jwk", key: ArrayBuffer | JsonWebKey, isPublic: boolean): Promise<CryptoKey>;
16
- generateKeyPair(): Promise<CryptoKeyPair>;
17
- deriveKeyPair(ikm: ArrayBufferLike | ArrayBufferView): Promise<CryptoKeyPair>;
18
- derivePublicKey(key: CryptoKey): Promise<CryptoKey>;
19
- dh(sk: CryptoKey, pk: CryptoKey): Promise<ArrayBuffer>;
20
- private _importRawKey;
21
- private _importJWK;
22
- private _deserializePkcs8Key;
23
5
  }
24
6
  //# sourceMappingURL=x25519.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"x25519.d.ts","sourceRoot":"","sources":["../../../../src/src/kems/dhkemPrimitives/x25519.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,EAQL,eAAe,EAIhB,MAAM,cAAc,CAAC;AAgBtB,qBAAa,MAAO,SAAQ,eAAgB,YAAW,eAAe;IACpE,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,IAAI,CAAe;IAC3B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,WAAW,CAAa;gBAEpB,IAAI,EAAE,YAAY;IAUjB,kBAAkB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IASxD,oBAAoB,CAC/B,GAAG,EAAE,eAAe,GAAG,eAAe,GACrC,OAAO,CAAC,SAAS,CAAC;IASR,mBAAmB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAazD,qBAAqB,CAChC,GAAG,EAAE,eAAe,GAAG,eAAe,GACrC,OAAO,CAAC,SAAS,CAAC;IASR,SAAS,CACpB,MAAM,EAAE,KAAK,GAAG,KAAK,EACrB,GAAG,EAAE,WAAW,GAAG,UAAU,EAC7B,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,SAAS,CAAC;IAgBR,eAAe,IAAI,OAAO,CAAC,aAAa,CAAC;IAazC,aAAa,CACxB,GAAG,EAAE,eAAe,GAAG,eAAe,GACrC,OAAO,CAAC,aAAa,CAAC;IA2BZ,eAAe,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IA4CnD,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;YAiBrD,aAAa;YAsBb,UAAU;YAkCV,oBAAoB;CAcnC"}
1
+ {"version":3,"file":"x25519.d.ts","sourceRoot":"","sources":["../../../../src/src/kems/dhkemPrimitives/x25519.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAchE,qBAAa,MAAO,SAAQ,2BAA2B;gBACzC,IAAI,EAAE,YAAY;CAG/B"}
@@ -1,5 +1,4 @@
1
- import { base64UrlToBytes, DeriveKeyPairError, DeserializeError, EMPTY, KEM_USAGES, LABEL_DKP_PRK, LABEL_SK, NativeAlgorithm, NotSupportedError, SerializeError, toArrayBuffer, } from "@hpke/common";
2
- const ALG_NAME = "X25519";
1
+ import { XCurveNativeDhkemPrimitives } from "./xCurveNative.js";
3
2
  // deno-fmt-ignore
4
3
  const PKCS8_ALG_ID_X25519 = new Uint8Array([
5
4
  0x30, 0x2e, 0x02, 0x01, 0x00, 0x30, 0x05, 0x06,
@@ -10,205 +9,8 @@ const BASE_POINT_X25519 = /* @__PURE__ */ (() => {
10
9
  p[0] = 9;
11
10
  return p;
12
11
  })();
13
- export class X25519 extends NativeAlgorithm {
12
+ export class X25519 extends XCurveNativeDhkemPrimitives {
14
13
  constructor(hkdf) {
15
- super();
16
- Object.defineProperty(this, "_hkdf", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: void 0
21
- });
22
- Object.defineProperty(this, "_alg", {
23
- enumerable: true,
24
- configurable: true,
25
- writable: true,
26
- value: void 0
27
- });
28
- Object.defineProperty(this, "_nPk", {
29
- enumerable: true,
30
- configurable: true,
31
- writable: true,
32
- value: void 0
33
- });
34
- Object.defineProperty(this, "_nSk", {
35
- enumerable: true,
36
- configurable: true,
37
- writable: true,
38
- value: void 0
39
- });
40
- Object.defineProperty(this, "_nDh", {
41
- enumerable: true,
42
- configurable: true,
43
- writable: true,
44
- value: void 0
45
- });
46
- Object.defineProperty(this, "_pkcs8AlgId", {
47
- enumerable: true,
48
- configurable: true,
49
- writable: true,
50
- value: void 0
51
- });
52
- this._alg = { name: ALG_NAME };
53
- this._hkdf = hkdf;
54
- this._nPk = 32;
55
- this._nSk = 32;
56
- this._nDh = 32;
57
- this._pkcs8AlgId = PKCS8_ALG_ID_X25519;
58
- }
59
- async serializePublicKey(key) {
60
- await this._setup();
61
- try {
62
- return await this._api.exportKey("raw", key);
63
- }
64
- catch (e) {
65
- throw new SerializeError(e);
66
- }
67
- }
68
- async deserializePublicKey(key) {
69
- await this._setup();
70
- try {
71
- return await this._importRawKey(toArrayBuffer(key), true);
72
- }
73
- catch (e) {
74
- throw new DeserializeError(e);
75
- }
76
- }
77
- async serializePrivateKey(key) {
78
- await this._setup();
79
- try {
80
- const jwk = await this._api.exportKey("jwk", key);
81
- if (!("d" in jwk)) {
82
- throw new Error("Not private key");
83
- }
84
- return base64UrlToBytes(jwk["d"]).buffer;
85
- }
86
- catch (e) {
87
- throw new SerializeError(e);
88
- }
89
- }
90
- async deserializePrivateKey(key) {
91
- await this._setup();
92
- try {
93
- return await this._importRawKey(toArrayBuffer(key), false);
94
- }
95
- catch (e) {
96
- throw new DeserializeError(e);
97
- }
98
- }
99
- async importKey(format, key, isPublic) {
100
- await this._setup();
101
- try {
102
- if (format === "raw") {
103
- return await this._importRawKey(key, isPublic);
104
- }
105
- // jwk
106
- if (key instanceof ArrayBuffer) {
107
- throw new Error("Invalid jwk key format");
108
- }
109
- return await this._importJWK(key, isPublic);
110
- }
111
- catch (e) {
112
- throw new DeserializeError(e);
113
- }
114
- }
115
- async generateKeyPair() {
116
- await this._setup();
117
- try {
118
- return await this._api.generateKey(ALG_NAME, true, KEM_USAGES);
119
- }
120
- catch (e) {
121
- throw new NotSupportedError(e);
122
- }
123
- }
124
- async deriveKeyPair(ikm) {
125
- await this._setup();
126
- try {
127
- const rawIkm = toArrayBuffer(ikm);
128
- const dkpPrk = await this._hkdf.labeledExtract(EMPTY, LABEL_DKP_PRK, new Uint8Array(rawIkm));
129
- const rawSk = await this._hkdf.labeledExpand(dkpPrk, LABEL_SK, EMPTY, this._nSk);
130
- const rawSkBytes = new Uint8Array(rawSk);
131
- const sk = await this._deserializePkcs8Key(rawSkBytes);
132
- rawSkBytes.fill(0);
133
- return {
134
- privateKey: sk,
135
- publicKey: await this.derivePublicKey(sk),
136
- };
137
- }
138
- catch (e) {
139
- throw new DeriveKeyPairError(e);
140
- }
141
- }
142
- async derivePublicKey(key) {
143
- await this._setup();
144
- try {
145
- const jwk = await this._api.exportKey("jwk", key);
146
- delete jwk["d"];
147
- delete jwk["key_ops"];
148
- return await this._api.importKey("jwk", jwk, this._alg, true, []);
149
- }
150
- catch {
151
- try {
152
- // Firefox fails to export JWK from some imported X25519 private keys.
153
- const bp = await this._api.importKey("raw", BASE_POINT_X25519.buffer, this._alg, true, []);
154
- const bits = await this._api.deriveBits({
155
- name: ALG_NAME,
156
- public: bp,
157
- }, key, this._nPk * 8);
158
- return await this._api.importKey("raw", bits, this._alg, true, []);
159
- }
160
- catch (e) {
161
- throw new DeserializeError(e);
162
- }
163
- }
164
- }
165
- async dh(sk, pk) {
166
- await this._setup();
167
- try {
168
- const bits = await this._api.deriveBits({
169
- name: ALG_NAME,
170
- public: pk,
171
- }, sk, this._nDh * 8);
172
- return bits;
173
- }
174
- catch (e) {
175
- throw new SerializeError(e);
176
- }
177
- }
178
- async _importRawKey(key, isPublic) {
179
- if (isPublic && key.byteLength !== this._nPk) {
180
- throw new Error("Invalid public key for the ciphersuite");
181
- }
182
- if (!isPublic && key.byteLength !== this._nSk) {
183
- throw new Error("Invalid private key for the ciphersuite");
184
- }
185
- if (isPublic) {
186
- return await this._api.importKey("raw", key, this._alg, true, []);
187
- }
188
- return await this._deserializePkcs8Key(new Uint8Array(key));
189
- }
190
- async _importJWK(key, isPublic) {
191
- if (typeof key.kty === "undefined" || key.kty !== "OKP") {
192
- throw new Error(`Invalid kty: ${key.crv}`);
193
- }
194
- if (typeof key.crv === "undefined" || key.crv !== ALG_NAME) {
195
- throw new Error(`Invalid crv: ${key.crv}`);
196
- }
197
- if (isPublic) {
198
- if (typeof key.d !== "undefined") {
199
- throw new Error("Invalid key: `d` should not be set");
200
- }
201
- return await this._api.importKey("jwk", key, this._alg, true, []);
202
- }
203
- if (typeof key.d === "undefined") {
204
- throw new Error("Invalid key: `d` not found");
205
- }
206
- return await this._api.importKey("jwk", key, this._alg, true, KEM_USAGES);
207
- }
208
- async _deserializePkcs8Key(k) {
209
- const pkcs8Key = new Uint8Array(this._pkcs8AlgId.length + k.length);
210
- pkcs8Key.set(this._pkcs8AlgId, 0);
211
- pkcs8Key.set(k, this._pkcs8AlgId.length);
212
- return await this._api.importKey("pkcs8", pkcs8Key, this._alg, true, KEM_USAGES);
14
+ super("X25519", 32, PKCS8_ALG_ID_X25519, BASE_POINT_X25519, hkdf);
213
15
  }
214
16
  }
@@ -1,24 +1,6 @@
1
- import type { DhkemPrimitives, KdfInterface } from "@hpke/common";
2
- import { NativeAlgorithm } from "@hpke/common";
3
- export declare class X448 extends NativeAlgorithm implements DhkemPrimitives {
4
- private _hkdf;
5
- private _alg;
6
- private _nPk;
7
- private _nSk;
8
- private _nDh;
9
- private _pkcs8AlgId;
1
+ import type { KdfInterface } from "@hpke/common";
2
+ import { XCurveNativeDhkemPrimitives } from "./xCurveNative.js";
3
+ export declare class X448 extends XCurveNativeDhkemPrimitives {
10
4
  constructor(hkdf: KdfInterface);
11
- serializePublicKey(key: CryptoKey): Promise<ArrayBuffer>;
12
- deserializePublicKey(key: ArrayBufferLike | ArrayBufferView): Promise<CryptoKey>;
13
- serializePrivateKey(key: CryptoKey): Promise<ArrayBuffer>;
14
- deserializePrivateKey(key: ArrayBufferLike | ArrayBufferView): Promise<CryptoKey>;
15
- importKey(format: "raw" | "jwk", key: ArrayBuffer | JsonWebKey, isPublic: boolean): Promise<CryptoKey>;
16
- generateKeyPair(): Promise<CryptoKeyPair>;
17
- deriveKeyPair(ikm: ArrayBufferLike | ArrayBufferView): Promise<CryptoKeyPair>;
18
- derivePublicKey(key: CryptoKey): Promise<CryptoKey>;
19
- dh(sk: CryptoKey, pk: CryptoKey): Promise<ArrayBuffer>;
20
- private _importRawKey;
21
- private _importJWK;
22
- private _deserializePkcs8Key;
23
5
  }
24
6
  //# sourceMappingURL=x448.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"x448.d.ts","sourceRoot":"","sources":["../../../../src/src/kems/dhkemPrimitives/x448.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAElE,OAAO,EAQL,eAAe,EAIhB,MAAM,cAAc,CAAC;AAgBtB,qBAAa,IAAK,SAAQ,eAAgB,YAAW,eAAe;IAClE,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,IAAI,CAAe;IAC3B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,WAAW,CAAa;gBAEpB,IAAI,EAAE,YAAY;IAUjB,kBAAkB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IASxD,oBAAoB,CAC/B,GAAG,EAAE,eAAe,GAAG,eAAe,GACrC,OAAO,CAAC,SAAS,CAAC;IASR,mBAAmB,CAAC,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAazD,qBAAqB,CAChC,GAAG,EAAE,eAAe,GAAG,eAAe,GACrC,OAAO,CAAC,SAAS,CAAC;IASR,SAAS,CACpB,MAAM,EAAE,KAAK,GAAG,KAAK,EACrB,GAAG,EAAE,WAAW,GAAG,UAAU,EAC7B,QAAQ,EAAE,OAAO,GAChB,OAAO,CAAC,SAAS,CAAC;IAgBR,eAAe,IAAI,OAAO,CAAC,aAAa,CAAC;IAaz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