@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
@@ -555,13 +555,6 @@ export class Keccak {
555
555
  }
556
556
  }
557
557
  const genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher(() => new Keccak(blockLen, suffix, outputLen), info);
558
- // /** SHA3-224 hash function. */
559
- // export const sha3_224: CHash = /* @__PURE__ */ genKeccak(
560
- // 0x06,
561
- // 144,
562
- // 28,
563
- // /* @__PURE__ */ oidNist(0x07),
564
- // );
565
558
  /** SHA3-256 hash function. Different from keccak-256. */
566
559
  export const sha3_256 = /* @__PURE__ */ genKeccak(0x06, 136, 32,
567
560
  /* @__PURE__ */ oidNist(0x08));
@@ -588,11 +581,3 @@ genShake(0x1f, 168, 16, /* @__PURE__ */ oidNist(0x0b));
588
581
  export const shake256 =
589
582
  /* @__PURE__ */
590
583
  genShake(0x1f, 136, 32, /* @__PURE__ */ oidNist(0x0c));
591
- // /** SHAKE128 XOF with 256-bit output (NIST version). */
592
- // export const shake128_32: CHashXOF<Keccak, ShakeOpts> =
593
- // /* @__PURE__ */
594
- // genShake(0x1f, 168, 32, /* @__PURE__ */ oidNist(0x0b));
595
- // /** SHAKE256 XOF with 512-bit output (NIST version). */
596
- // export const shake256_64: CHashXOF<Keccak, ShakeOpts> =
597
- // /* @__PURE__ */
598
- // genShake(0x1f, 136, 64, /* @__PURE__ */ oidNist(0x0c));
@@ -8,7 +8,8 @@ export declare class HkdfNative extends NativeAlgorithm implements KdfInterface
8
8
  readonly hashSize: number;
9
9
  protected _suiteId: Uint8Array;
10
10
  protected readonly algHash: HmacKeyGenParams;
11
- constructor();
11
+ protected readonly _fallbackExtract: ((salt: Uint8Array, ikm: Uint8Array) => Uint8Array) | undefined;
12
+ constructor(fallbackExtract?: (salt: Uint8Array, ikm: Uint8Array) => Uint8Array);
12
13
  init(suiteId: Uint8Array): void;
13
14
  buildLabeledIkm(label: Uint8Array, ikm: Uint8Array): Uint8Array;
14
15
  buildLabeledInfo(label: Uint8Array, info: Uint8Array, len: number): Uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../../../src/src/kdfs/hkdf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAIlE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAalD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,GAAG,eAAe,GACvC,UAAU,CAEZ;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,eAAe,GAAG,eAAe,GACvC,WAAW,CASb;AAED,qBAAa,UAAW,SAAQ,eAAgB,YAAW,YAAY;IACrE,SAAgB,EAAE,EAAE,KAAK,CAAoB;IAC7C,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,KAAK,CAAoB;IACtC,SAAS;IACA,QAAQ,EAAE,MAAM,CAAM;IAC/B,8CAA8C;IACrC,OAAO,EAAE,gBAAgB,CAIhC;CACH;AAED,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C,gCAAgC;IACvB,EAAE,EAAE,KAAK,CAAoB;IACtC,SAAS;IACA,QAAQ,EAAE,MAAM,CAAM;IAC/B,8CAA8C;IACrC,OAAO,EAAE,gBAAgB,CAIhC;CACH"}
@@ -26,7 +26,7 @@ export function toArrayBuffer(input) {
26
26
  return new Uint8Array(input).slice().buffer;
27
27
  }
28
28
  export class HkdfNative extends NativeAlgorithm {
29
- constructor() {
29
+ constructor(fallbackExtract) {
30
30
  super();
31
31
  Object.defineProperty(this, "id", {
32
32
  enumerable: true,
@@ -56,6 +56,13 @@ export class HkdfNative extends NativeAlgorithm {
56
56
  length: 256,
57
57
  }
58
58
  });
59
+ Object.defineProperty(this, "_fallbackExtract", {
60
+ enumerable: true,
61
+ configurable: true,
62
+ writable: true,
63
+ value: void 0
64
+ });
65
+ this._fallbackExtract = fallbackExtract;
59
66
  }
60
67
  init(suiteId) {
61
68
  this._suiteId = suiteId;
@@ -84,10 +91,13 @@ export class HkdfNative extends NativeAlgorithm {
84
91
  const saltBuf = salt.byteLength === 0
85
92
  ? new ArrayBuffer(this.hashSize)
86
93
  : toArrayBuffer(salt);
94
+ const ikmBuf = toArrayBuffer(ikm);
87
95
  if (saltBuf.byteLength !== this.hashSize) {
96
+ if (this._fallbackExtract !== undefined) {
97
+ return this._fallbackExtract(new Uint8Array(saltBuf), new Uint8Array(ikmBuf)).buffer;
98
+ }
88
99
  throw new InvalidParamError("The salt length must be the same as the hashSize");
89
100
  }
90
- const ikmBuf = toArrayBuffer(ikm);
91
101
  const key = await this._api.importKey("raw", saltBuf, this.algHash, false, [
92
102
  "sign",
93
103
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"xCurve.d.ts","sourceRoot":"","sources":["../../../../src/src/kems/dhkemPrimitives/x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EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAWnD,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAa7D,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,UAAU;CAwCnB"}
@@ -2,7 +2,7 @@ import { EMPTY } from "../../consts.js";
2
2
  import { DeriveKeyPairError, DeserializeError, NotSupportedError, SerializeError, } from "../../errors.js";
3
3
  import { toArrayBuffer } from "../../kdfs/hkdf.js";
4
4
  import { KEM_USAGES, LABEL_DKP_PRK, LABEL_SK, } from "../../interfaces/dhkemPrimitives.js";
5
- import { base64UrlToBytes } from "../../utils/misc.js";
5
+ import { base64UrlToBytes, loadCrypto } from "../../utils/misc.js";
6
6
  import { XCryptoKey } from "../../xCryptoKey.js";
7
7
  /**
8
8
  * Base DhkemPrimitives implementation for Montgomery curves (X25519/X448).
@@ -97,9 +97,20 @@ export class XCurveDhkemPrimitives {
97
97
  }
98
98
  async generateKeyPair() {
99
99
  try {
100
- const rawSk = await this._curve.utils.randomSecretKey();
100
+ let rawSk;
101
+ try {
102
+ rawSk = this._curve.utils.randomSecretKey();
103
+ }
104
+ catch {
105
+ // Sync crypto not available (e.g., Node.js <= v18 ESM); async fallback
106
+ const cryptoApi = await loadCrypto();
107
+ const fallbackRawSk = new Uint8Array(this._nSk);
108
+ cryptoApi.getRandomValues(fallbackRawSk);
109
+ rawSk = fallbackRawSk;
110
+ }
101
111
  const sk = new XCryptoKey(this._algName, rawSk, "private", KEM_USAGES);
102
- const pk = await this.derivePublicKey(sk);
112
+ const rawPk = this._curve.getPublicKey(rawSk);
113
+ const pk = new XCryptoKey(this._algName, rawPk, "public");
103
114
  return { publicKey: pk, privateKey: sk };
104
115
  }
105
116
  catch (e) {
@@ -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,EAAE,MAAM,mBAAmB,CAAC;AAE1C,eAAO,MAAM,QAAQ,QAAO,OAE0B,CAAC;AAEvD;;;GAGG;AACH,wBAAgB,MAAM,IAAI,OAAO,CAOhC;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;AAED,wBAAsB,UA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,GAAG,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,GAAG,UAAU,CAS5D"}
@@ -146,19 +146,52 @@ export async function loadSubtleCrypto() {
146
146
  throw new Error("Failed to load SubtleCrypto");
147
147
  }
148
148
  }
149
- export async function loadCrypto() {
149
+ /** Cached reference to the Crypto object for synchronous access. */
150
+ let _cryptoApi;
151
+ /**
152
+ * Returns the Crypto object synchronously.
153
+ * Uses globalThis.crypto on modern runtimes, with a CJS require("crypto")
154
+ * fallback for Node.js <= v18. The result is cached after the first call.
155
+ */
156
+ export function getCrypto() {
157
+ if (_cryptoApi)
158
+ return _cryptoApi;
159
+ // Modern runtimes: Deno, browsers, Node.js >= 17.6, Bun, Cloudflare Workers
150
160
  if (typeof dntShim.dntGlobalThis !== "undefined" && globalThis.crypto !== undefined) {
151
- // Browsers, Node.js >= v19, Cloudflare Workers, Bun, etc.
152
- return globalThis.crypto;
161
+ _cryptoApi = globalThis.crypto;
162
+ return _cryptoApi;
153
163
  }
154
- // Node.js <= v18
164
+ // Node.js <= v18 CJS fallback: require is a module-local binding in CJS
165
+ // (not on globalThis), so we reference it directly.
155
166
  try {
156
- // @ts-ignore: to ignore "crypto"
157
- const { webcrypto } = await import("crypto"); // node:crypto
158
- return webcrypto;
159
- }
160
- catch (_e) {
161
- throw new Error("failed to load Crypto");
167
+ // @ts-ignore: require exists in CJS builds via dnt
168
+ if (typeof require === "function") {
169
+ // @ts-ignore: require exists in CJS builds via dnt
170
+ const { webcrypto } = require("crypto");
171
+ _cryptoApi = webcrypto;
172
+ return _cryptoApi;
173
+ }
174
+ }
175
+ catch {
176
+ // ignore
177
+ }
178
+ throw new Error("crypto.getRandomValues must be defined");
179
+ }
180
+ export async function loadCrypto() {
181
+ try {
182
+ return getCrypto();
183
+ }
184
+ catch {
185
+ // ESM fallback for Node.js <= v18 (require not available)
186
+ try {
187
+ // @ts-ignore: to ignore "crypto"
188
+ const { webcrypto } = await import("crypto"); // node:crypto
189
+ _cryptoApi = webcrypto;
190
+ return _cryptoApi;
191
+ }
192
+ catch (_e) {
193
+ throw new Error("failed to load Crypto");
194
+ }
162
195
  }
163
196
  }
164
197
  /**
@@ -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,UAAU,CAAC;AAEf,kCAAkC;AAClC,wBAAgB,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,WAAW,CAMh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MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACnC,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACrC,IAAI,CAmBN;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7D,MAAM,EAAE,CACN,IAAI,CAAC,EAAE,UAAU,KACd;QAAE,SAAS,EAAE,UAAU,CAAC;QAAC,SAAS,EAAE,UAAU,CAAA;KAAE,CAAC;IACtD,YAAY,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,UAAU,CAAC;CACrD;AAED,qEAAqE;AACrE,MAAM,WAAW,MAAO,SAAQ,UAAU;IAExC,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,IAAI,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,KAAK,UAAU,CAAC;IAC7D,MAAM,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC;CAC9E;AAaD,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,WAAW,SAAK,GAAG,UAAU,CAExD;AAGD,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,UAAU,CAAA;CAAE,CAgB3D"}
@@ -11,8 +11,8 @@
11
11
  * Hex, bytes and number utilities.
12
12
  * @module
13
13
  */
14
- import { loadCrypto } from "./misc.js";
15
14
  import { N_0 } from "../consts.js";
15
+ import { getCrypto } from "./misc.js";
16
16
  /** Checks if something is Uint8Array. Be careful: nodejs Buffer will return true. */
17
17
  export function isBytes(a) {
18
18
  return a instanceof Uint8Array ||
@@ -79,7 +79,7 @@ export function clean(...arrays) {
79
79
  const _endianTestBuffer = /* @__PURE__ */ new Uint32Array([0x11223344]);
80
80
  const _endianTestBytes = /* @__PURE__ */ new Uint8Array(_endianTestBuffer.buffer);
81
81
  /** Is current platform little-endian? Most are. Big-Endian platform: IBM */
82
- export const isLE = /* @__PURE__ */ _endianTestBytes[0] === 0x44;
82
+ export const isLE = _endianTestBytes[0] === 0x44;
83
83
  /** The byte swap operation for uint32 */
84
84
  export function byteSwap(word) {
85
85
  return (((word << 24) & 0xff000000) |
@@ -119,7 +119,7 @@ typeof Uint8Array.from([]).toHex === "function" &&
119
119
  typeof Uint8Array.fromHex === "function")();
120
120
  // Array where index 0xf0 (240) is mapped to string 'f0'
121
121
  const hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
122
- const HEX_TO_BIGINT = /* @__PURE__ */ [
122
+ const HEX_TO_BIGINT = [
123
123
  0n,
124
124
  1n,
125
125
  2n,
@@ -246,7 +246,12 @@ export function bytesToNumberBE(bytes) {
246
246
  return hexToNumber(bytesToHex(bytes));
247
247
  }
248
248
  export function bytesToNumberLE(bytes) {
249
- return hexToNumber(bytesToHex(copyBytes(abytes(bytes)).reverse()));
249
+ abytes(bytes);
250
+ let result = N_0;
251
+ for (let i = bytes.length - 1; i >= 0; i--) {
252
+ result = (result << 8n) | BigInt(bytes[i]);
253
+ }
254
+ return result;
250
255
  }
251
256
  export function numberToBytesBE(n, len) {
252
257
  anumber(len);
@@ -257,7 +262,16 @@ export function numberToBytesBE(n, len) {
257
262
  return res;
258
263
  }
259
264
  export function numberToBytesLE(n, len) {
260
- return numberToBytesBE(n, len).reverse();
265
+ anumber(len);
266
+ let v = BigInt(abignumer(n));
267
+ const result = new Uint8Array(len);
268
+ for (let i = 0; i < len; i++) {
269
+ result[i] = Number(v & 0xffn);
270
+ v >>= 8n;
271
+ }
272
+ if (v !== N_0)
273
+ throw new Error("number too large");
274
+ return result;
261
275
  }
262
276
  /**
263
277
  * Copies Uint8Array. We can't use u8a.slice(), because u8a can be Buffer,
@@ -345,11 +359,8 @@ export function validateObject(object, fields = {}, optFields = {}) {
345
359
  // return cr.getRandomValues(new Uint8Array(bytesLength));
346
360
  // }
347
361
  /** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */
348
- export async function randomBytesAsync(bytesLength = 32) {
349
- const api = await loadCrypto();
350
- const rnd = new Uint8Array(bytesLength);
351
- api.getRandomValues(rnd);
352
- return rnd;
362
+ export function randomBytes(bytesLength = 32) {
363
+ return getCrypto().getRandomValues(new Uint8Array(bytesLength));
353
364
  }
354
365
  // 06 09 60 86 48 01 65 03 04 02
355
366
  export function oidNist(suffix) {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hpke/common",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
4
4
  "description": "A Hybrid Public Key Encryption (HPKE) internal-use common module for @hpke family modules.",
5
5
  "keywords": [
6
6
  "hpke",
@@ -30,6 +30,10 @@
30
30
  },
31
31
  "./package.json": "./package.json"
32
32
  },
33
+ "funding": {
34
+ "type": "github",
35
+ "url": "https://github.com/sponsors/dajiaji"
36
+ },
33
37
  "sideEffects": false,
34
38
  "engines": {
35
39
  "node": ">=16.0.0"
@@ -12,7 +12,7 @@ export type CurveType = {
12
12
  type: "x25519" | "x448";
13
13
  adjustScalarBytes: (bytes: Uint8Array) => Uint8Array;
14
14
  powPminus2: (x: bigint) => bigint;
15
- randomBytes?: (bytesLength?: number) => Promise<Uint8Array>;
15
+ randomBytes?: (bytesLength?: number) => Uint8Array;
16
16
  };
17
17
  export type MontgomeryECDH = {
18
18
  scalarMult: (scalar: Uint8Array, u: Uint8Array) => Uint8Array;
@@ -20,7 +20,7 @@ export type MontgomeryECDH = {
20
20
  getSharedSecret: (secretKeyA: Uint8Array, publicKeyB: Uint8Array) => Uint8Array;
21
21
  getPublicKey: (secretKey: Uint8Array) => Uint8Array;
22
22
  utils: {
23
- randomSecretKey: (seed?: Uint8Array) => Promise<Uint8Array>;
23
+ randomSecretKey: (seed?: Uint8Array) => Uint8Array;
24
24
  };
25
25
  GuBytes: Uint8Array;
26
26
  lengths: CurveLengths;
@@ -1 +1 @@
1
- {"version":3,"file":"montgomery.d.ts","sourceRoot":"","sources":["../../../src/src/curve/montgomery.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmBH,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAI7D,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,iBAAiB,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,UAAU,CAAC;IACrD,UAAU,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAClC,WAAW,CAAC,EAAE,CAAC,WAAW,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CAC7D,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC,EAAE,UAAU,KAAK,UAAU,CAAC;IAC9D,cAAc,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,CAAC;IACnD,eAAe,EAAE,CACf,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,KACnB,UAAU,CAAC;IAChB,YAAY,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,UAAU,CAAC;IACpD,KAAK,EAAE;QACL,eAAe,EAAE,CAAC,IAAI,CAAC,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;KAC7D,CAAC;IACF,OAAO,EAAE,UAAU,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,CACN,IAAI,CA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CAAC;CACvD,CAAC;AAUF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,SAAS,GAAG,cAAc,CAqJ9D"}
@@ -42,8 +42,8 @@
42
42
  const is25519 = type === "x25519";
43
43
  if (!is25519 && type !== "x448")
44
44
  throw new Error("invalid type");
45
- const randomBytes_ = rand || noble_js_1.randomBytesAsync;
46
- const montgomeryBits = is25519 ? 255n : 448n;
45
+ const randomBytes_ = rand || noble_js_1.randomBytes;
46
+ const montgomeryBits = is25519 ? 255 : 448;
47
47
  const fieldLen = is25519 ? 32 : 56;
48
48
  const Gu = is25519 ? 9n : 5n;
49
49
  // RFC 7748 #5:
@@ -62,17 +62,20 @@
62
62
  function encodeU(u) {
63
63
  return (0, noble_js_1.numberToBytesLE)(modP(u), fieldLen);
64
64
  }
65
+ // Mask for clearing bit 255 (x25519): (1n << 255n) - 1n
66
+ const uMask = is25519 ? (consts_js_1.N_1 << 255n) - consts_js_1.N_1 : consts_js_1.N_0;
65
67
  function decodeU(u) {
66
- const _u = (0, noble_js_1.copyBytes)((0, noble_js_1.abytes)(u, fieldLen, "uCoordinate"));
68
+ (0, noble_js_1.abytes)(u, fieldLen, "uCoordinate");
69
+ let n = (0, noble_js_1.bytesToNumberLE)(u);
67
70
  // RFC: When receiving such an array, implementations of X25519
68
71
  // (but not X448) MUST mask the most significant bit in the final byte.
69
72
  if (is25519)
70
- _u[31] &= 127; // 0b0111_1111
73
+ n &= uMask;
71
74
  // RFC: Implementations MUST accept non-canonical values and process them as
72
75
  // if they had been reduced modulo the field prime. The non-canonical
73
76
  // values are 2^255 - 19 through 2^255 - 1 for X25519 and 2^448 - 2^224
74
77
  // - 1 through 2^448 - 1 for X448.
75
- return modP((0, noble_js_1.bytesToNumberLE)(_u));
78
+ return modP(n);
76
79
  }
77
80
  function decodeScalar(scalar) {
78
81
  return (0, noble_js_1.bytesToNumberLE)(adjustScalarBytes((0, noble_js_1.copyBytes)((0, noble_js_1.abytes)(scalar, fieldLen, "scalar"))));
@@ -86,24 +89,21 @@
86
89
  throw new Error("invalid private or public key received");
87
90
  return encodeU(pu);
88
91
  }
92
+ // Pre-decoded base point u-coordinate (avoids redundant decode on every call)
93
+ const GuDecoded = modP(Gu);
89
94
  // Computes public key from private. By doing scalar multiplication of base point.
90
95
  function scalarMultBase(scalar) {
91
- return scalarMult(scalar, GuBytes);
96
+ const pu = montgomeryLadder(GuDecoded, decodeScalar(scalar));
97
+ if (pu === consts_js_1.N_0)
98
+ throw new Error("invalid private or public key received");
99
+ return encodeU(pu);
92
100
  }
93
101
  const getPublicKey = scalarMultBase;
94
102
  const getSharedSecret = scalarMult;
95
- // cswap from RFC7748 "example code"
96
- function cswap(swap, x_2, x_3) {
97
- // dummy = mask(swap) AND (x_2 XOR x_3)
98
- // Where mask(swap) is the all-1 or all-0 word of the same length as x_2
99
- // and x_3, computed, e.g., as mask(swap) = 0 - swap.
100
- const dummy = modP(swap * (x_2 - x_3));
101
- x_2 = modP(x_2 - dummy); // x_2 = x_2 XOR dummy
102
- x_3 = modP(x_3 + dummy); // x_3 = x_3 XOR dummy
103
- return { x_2, x_3 };
104
- }
105
103
  /**
106
104
  * Montgomery x-only multiplication ladder.
105
+ * cswap is inlined to avoid per-iteration object allocations.
106
+ * Loop counter uses number instead of bigint to avoid BigInt arithmetic overhead.
107
107
  * @param pointU u coordinate (x) on Montgomery Curve 25519
108
108
  * @param scalar by which the point would be multiplied
109
109
  * @returns new Point on Montgomery curve
@@ -118,11 +118,19 @@
118
118
  let x_3 = u;
119
119
  let z_3 = consts_js_1.N_1;
120
120
  let swap = consts_js_1.N_0;
121
- for (let t = montgomeryBits - 1n; t >= consts_js_1.N_0; t--) {
122
- const k_t = (k >> t) & consts_js_1.N_1;
121
+ let dummy;
122
+ for (let t = montgomeryBits - 1; t >= 0; t--) {
123
+ const k_t = (k >> BigInt(t)) & consts_js_1.N_1;
123
124
  swap ^= k_t;
124
- ({ x_2, x_3 } = cswap(swap, x_2, x_3));
125
- ({ x_2: z_2, x_3: z_3 } = cswap(swap, z_2, z_3));
125
+ // Masked cswap (best-effort constant-time for BigInt).
126
+ // Only dummy needs modP; x/z reductions are deferred to the
127
+ // subsequent multiplications in the ladder body.
128
+ dummy = modP(swap * (x_2 - x_3));
129
+ x_2 -= dummy;
130
+ x_3 += dummy;
131
+ dummy = modP(swap * (z_2 - z_3));
132
+ z_2 -= dummy;
133
+ z_3 += dummy;
126
134
  swap = k_t;
127
135
  const A = x_2 + z_2;
128
136
  const AA = modP(A * A);
@@ -138,10 +146,17 @@
138
146
  x_3 = modP(dacb * dacb);
139
147
  z_3 = modP(x_1 * modP(da_cb * da_cb));
140
148
  x_2 = modP(AA * BB);
141
- z_2 = modP(E * (AA + modP(a24 * E)));
149
+ // a24 is small (17-bit for x25519, 16-bit for x448), so a24 * E adds
150
+ // only ~17 bits beyond P — negligible impact on the outer multiplication.
151
+ z_2 = modP(E * (AA + a24 * E));
142
152
  }
143
- ({ x_2, x_3 } = cswap(swap, x_2, x_3));
144
- ({ x_2: z_2, x_3: z_3 } = cswap(swap, z_2, z_3));
153
+ // Final masked cswap
154
+ dummy = modP(swap * (x_2 - x_3));
155
+ x_2 -= dummy;
156
+ x_3 += dummy;
157
+ dummy = modP(swap * (z_2 - z_3));
158
+ z_2 -= dummy;
159
+ z_3 += dummy;
145
160
  const z2 = powPminus2(z_2); // `Fp.pow(x, P - N_2)` is much slower equivalent
146
161
  return modP(x_2 * z2); // Return x_2 * (z_2^(p - 2))
147
162
  }
@@ -150,9 +165,9 @@
150
165
  publicKey: fieldLen,
151
166
  seed: fieldLen,
152
167
  };
153
- const randomSecretKey = async (seed) => {
168
+ const randomSecretKey = (seed) => {
154
169
  if (seed === undefined) {
155
- seed = await randomBytes_(fieldLen);
170
+ seed = randomBytes_(fieldLen);
156
171
  }
157
172
  (0, noble_js_1.abytes)(seed, lengths.seed, "seed");
158
173
  return seed;
@@ -1 +1 @@
1
- {"version":3,"file":"sha3.d.ts","sourceRoot":"","sources":["../../../src/src/hash/sha3.ts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AAM,IAAI,UAAU;IAGpB,OAAO,IAAI,IAAI;IAIf,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;CAehC;AASD,yDAAyD;AACzD,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAC;AAEF,8BAA8B;AAC9B,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAC;AAEF,8BAA8B;AAC9B,eAAO,MAAM,QAAQ,EAAE,KAKtB,CAAC;AAEF,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,KAAgD,CAAC;AAC1E,yDAAyD;AACzD,eAAO,MAAM,UAAU,EAAE,KAAgD,CAAC;AAC1E,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,KAAgD,CAAC;AAC1E,gCAAgC;AAChC,eAAO,MAAM,UAAU,EAAE,KAA+C,CAAC;AAEzE,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAmB3C,0CAA0C;AAC1C,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAEO,CAAC;AACzD,0CAA0C;AAC1C,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAEO,CAAC"}
@@ -569,13 +569,6 @@
569
569
  }
570
570
  exports.Keccak = Keccak;
571
571
  const genKeccak = (suffix, blockLen, outputLen, info = {}) => (0, hash_js_1.createHasher)(() => new Keccak(blockLen, suffix, outputLen), info);
572
- // /** SHA3-224 hash function. */
573
- // export const sha3_224: CHash = /* @__PURE__ */ genKeccak(
574
- // 0x06,
575
- // 144,
576
- // 28,
577
- // /* @__PURE__ */ oidNist(0x07),
578
- // );
579
572
  /** SHA3-256 hash function. Different from keccak-256. */
580
573
  exports.sha3_256 = genKeccak(0x06, 136, 32,
581
574
  /* @__PURE__ */ (0, noble_js_1.oidNist)(0x08));
@@ -603,11 +596,3 @@
603
596
  /* @__PURE__ */
604
597
  genShake(0x1f, 136, 32, /* @__PURE__ */ (0, noble_js_1.oidNist)(0x0c));
605
598
  });
606
- // /** SHAKE128 XOF with 256-bit output (NIST version). */
607
- // export const shake128_32: CHashXOF<Keccak, ShakeOpts> =
608
- // /* @__PURE__ */
609
- // genShake(0x1f, 168, 32, /* @__PURE__ */ oidNist(0x0b));
610
- // /** SHAKE256 XOF with 512-bit output (NIST version). */
611
- // export const shake256_64: CHashXOF<Keccak, ShakeOpts> =
612
- // /* @__PURE__ */
613
- // genShake(0x1f, 136, 64, /* @__PURE__ */ oidNist(0x0c));
@@ -8,7 +8,8 @@ export declare class HkdfNative extends NativeAlgorithm implements KdfInterface
8
8
  readonly hashSize: number;
9
9
  protected _suiteId: Uint8Array;
10
10
  protected readonly algHash: HmacKeyGenParams;
11
- constructor();
11
+ protected readonly _fallbackExtract: ((salt: Uint8Array, ikm: Uint8Array) => Uint8Array) | undefined;
12
+ constructor(fallbackExtract?: (salt: Uint8Array, ikm: Uint8Array) => Uint8Array);
12
13
  init(suiteId: Uint8Array): void;
13
14
  buildLabeledIkm(label: Uint8Array, ikm: Uint8Array): Uint8Array;
14
15
  buildLabeledInfo(label: Uint8Array, info: Uint8Array, len: number): Uint8Array;
@@ -1 +1 @@
1
- {"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../../../src/src/kdfs/hkdf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAIlE,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAalD,wBAAgB,YAAY,CAC1B,KAAK,EAAE,eAAe,GAAG,eAAe,GACvC,UAAU,CAEZ;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,eAAe,GAAG,eAAe,GACvC,WAAW,CASb;AAED,qBAAa,UAAW,SAAQ,eAAgB,YAAW,YAAY;IACrE,SAAgB,EAAE,EAAE,KAAK,CAAoB;IAC7C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E,KAAK,CAAoB;IACtC,SAAS;IACA,QAAQ,EAAE,MAAM,CAAM;IAC/B,8CAA8C;IACrC,OAAO,EAAE,gBAAgB,CAIhC;CACH;AAED,qBAAa,gBAAiB,SAAQ,UAAU;IAC9C,gCAAgC;IACvB,EAAE,EAAE,KAAK,CAAoB;IACtC,SAAS;IACA,QAAQ,EAAE,MAAM,CAAM;IAC/B,8CAA8C;IACrC,OAAO,EAAE,gBAAgB,CAIhC;CACH"}
@@ -40,7 +40,7 @@
40
40
  return new Uint8Array(input).slice().buffer;
41
41
  }
42
42
  class HkdfNative extends algorithm_js_1.NativeAlgorithm {
43
- constructor() {
43
+ constructor(fallbackExtract) {
44
44
  super();
45
45
  Object.defineProperty(this, "id", {
46
46
  enumerable: true,
@@ -70,6 +70,13 @@
70
70
  length: 256,
71
71
  }
72
72
  });
73
+ Object.defineProperty(this, "_fallbackExtract", {
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true,
77
+ value: void 0
78
+ });
79
+ this._fallbackExtract = fallbackExtract;
73
80
  }
74
81
  init(suiteId) {
75
82
  this._suiteId = suiteId;
@@ -98,10 +105,13 @@
98
105
  const saltBuf = salt.byteLength === 0
99
106
  ? new ArrayBuffer(this.hashSize)
100
107
  : toArrayBuffer(salt);
108
+ const ikmBuf = toArrayBuffer(ikm);
101
109
  if (saltBuf.byteLength !== this.hashSize) {
110
+ if (this._fallbackExtract !== undefined) {
111
+ return this._fallbackExtract(new Uint8Array(saltBuf), new Uint8Array(ikmBuf)).buffer;
112
+ }
102
113
  throw new errors_js_1.InvalidParamError("The salt length must be the same as the hashSize");
103
114
  }
104
- const ikmBuf = toArrayBuffer(ikm);
105
115
  const key = await this._api.importKey("raw", saltBuf, this.algHash, false, [
106
116
  "sign",
107
117
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"xCurve.d.ts","sourceRoot":"","sources":["../../../../src/src/kems/dhkemPrimitives/xCurve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eA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EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAa7D,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,UAAU;CAwCnB"}
@@ -109,9 +109,20 @@
109
109
  }
110
110
  async generateKeyPair() {
111
111
  try {
112
- const rawSk = await this._curve.utils.randomSecretKey();
112
+ let rawSk;
113
+ try {
114
+ rawSk = this._curve.utils.randomSecretKey();
115
+ }
116
+ catch {
117
+ // Sync crypto not available (e.g., Node.js <= v18 ESM); async fallback
118
+ const cryptoApi = await (0, misc_js_1.loadCrypto)();
119
+ const fallbackRawSk = new Uint8Array(this._nSk);
120
+ cryptoApi.getRandomValues(fallbackRawSk);
121
+ rawSk = fallbackRawSk;
122
+ }
113
123
  const sk = new xCryptoKey_js_1.XCryptoKey(this._algName, rawSk, "private", dhkemPrimitives_js_1.KEM_USAGES);
114
- const pk = await this.derivePublicKey(sk);
124
+ const rawPk = this._curve.getPublicKey(rawSk);
125
+ const pk = new xCryptoKey_js_1.XCryptoKey(this._algName, rawPk, "public");
115
126
  return { publicKey: pk, privateKey: sk };
116
127
  }
117
128
  catch (e) {