@fgv/ts-extras 5.1.0-5 → 5.1.0-50

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 (488) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +90 -0
  3. package/dist/index.browser.js +6 -2
  4. package/dist/index.browser.js.map +1 -0
  5. package/dist/index.js +2 -1
  6. package/dist/index.js.map +1 -0
  7. package/dist/packlets/ai-assist/chatRequestBuilders.js +282 -0
  8. package/dist/packlets/ai-assist/chatRequestBuilders.js.map +1 -0
  9. package/dist/packlets/ai-assist/{apiClient.js → completionClient.js} +165 -214
  10. package/dist/packlets/ai-assist/completionClient.js.map +1 -0
  11. package/dist/packlets/ai-assist/converters.js +47 -3
  12. package/dist/packlets/ai-assist/converters.js.map +1 -0
  13. package/dist/packlets/ai-assist/embeddingClient.js +345 -0
  14. package/dist/packlets/ai-assist/embeddingClient.js.map +1 -0
  15. package/dist/packlets/ai-assist/endpoint.js +107 -0
  16. package/dist/packlets/ai-assist/endpoint.js.map +1 -0
  17. package/dist/packlets/ai-assist/http.js +104 -0
  18. package/dist/packlets/ai-assist/http.js.map +1 -0
  19. package/dist/packlets/ai-assist/imageGenerationClient.js +454 -0
  20. package/dist/packlets/ai-assist/imageGenerationClient.js.map +1 -0
  21. package/dist/packlets/ai-assist/imageOptionsResolver.js +193 -0
  22. package/dist/packlets/ai-assist/imageOptionsResolver.js.map +1 -0
  23. package/dist/packlets/ai-assist/index.js +12 -4
  24. package/dist/packlets/ai-assist/index.js.map +1 -0
  25. package/dist/packlets/ai-assist/jsonCompletion.js +93 -0
  26. package/dist/packlets/ai-assist/jsonCompletion.js.map +1 -0
  27. package/dist/packlets/ai-assist/jsonResponse.js +423 -0
  28. package/dist/packlets/ai-assist/jsonResponse.js.map +1 -0
  29. package/dist/packlets/ai-assist/listModelsClient.js +294 -0
  30. package/dist/packlets/ai-assist/listModelsClient.js.map +1 -0
  31. package/dist/packlets/ai-assist/model.js +301 -9
  32. package/dist/packlets/ai-assist/model.js.map +1 -0
  33. package/dist/packlets/ai-assist/registry.js +376 -12
  34. package/dist/packlets/ai-assist/registry.js.map +1 -0
  35. package/dist/packlets/ai-assist/sseParser.js +123 -0
  36. package/dist/packlets/ai-assist/sseParser.js.map +1 -0
  37. package/dist/packlets/ai-assist/streamingAdapters/anthropic.js +376 -0
  38. package/dist/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -0
  39. package/dist/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js +687 -0
  40. package/dist/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js.map +1 -0
  41. package/dist/packlets/ai-assist/streamingAdapters/common.js +187 -0
  42. package/dist/packlets/ai-assist/streamingAdapters/common.js.map +1 -0
  43. package/dist/packlets/ai-assist/streamingAdapters/gemini.js +208 -0
  44. package/dist/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -0
  45. package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js +175 -0
  46. package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -0
  47. package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js +390 -0
  48. package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -0
  49. package/dist/packlets/ai-assist/streamingAdapters/proxy.js +178 -0
  50. package/dist/packlets/ai-assist/streamingAdapters/proxy.js.map +1 -0
  51. package/dist/packlets/ai-assist/streamingClient.js +140 -0
  52. package/dist/packlets/ai-assist/streamingClient.js.map +1 -0
  53. package/dist/packlets/ai-assist/thinkingOptionsResolver.js +288 -0
  54. package/dist/packlets/ai-assist/thinkingOptionsResolver.js.map +1 -0
  55. package/dist/packlets/ai-assist/toolFormats.js +106 -10
  56. package/dist/packlets/ai-assist/toolFormats.js.map +1 -0
  57. package/dist/packlets/conversion/converters.js +35 -1
  58. package/dist/packlets/conversion/converters.js.map +1 -0
  59. package/dist/packlets/conversion/index.js.map +1 -0
  60. package/dist/packlets/crypto-utils/constants.js.map +1 -0
  61. package/dist/packlets/crypto-utils/converters.js +42 -4
  62. package/dist/packlets/crypto-utils/converters.js.map +1 -0
  63. package/dist/packlets/crypto-utils/directEncryptionProvider.js.map +1 -0
  64. package/dist/packlets/crypto-utils/encryptedFile.js +37 -0
  65. package/dist/packlets/crypto-utils/encryptedFile.js.map +1 -0
  66. package/dist/packlets/crypto-utils/hpkeProvider.js +355 -0
  67. package/dist/packlets/crypto-utils/hpkeProvider.js.map +1 -0
  68. package/dist/packlets/crypto-utils/index.browser.js +13 -2
  69. package/dist/packlets/crypto-utils/index.browser.js.map +1 -0
  70. package/dist/packlets/crypto-utils/index.js +9 -1
  71. package/dist/packlets/crypto-utils/index.js.map +1 -0
  72. package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js +71 -0
  73. package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -0
  74. package/dist/packlets/crypto-utils/keystore/converters.js +111 -16
  75. package/dist/packlets/crypto-utils/keystore/converters.js.map +1 -0
  76. package/dist/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js +287 -0
  77. package/dist/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js.map +1 -0
  78. package/dist/packlets/crypto-utils/keystore/index.browser.js +36 -0
  79. package/dist/packlets/crypto-utils/keystore/index.browser.js.map +1 -0
  80. package/dist/packlets/crypto-utils/keystore/index.js +3 -0
  81. package/dist/packlets/crypto-utils/keystore/index.js.map +1 -0
  82. package/dist/packlets/crypto-utils/keystore/keyStore.js +872 -119
  83. package/dist/packlets/crypto-utils/keystore/keyStore.js.map +1 -0
  84. package/dist/packlets/crypto-utils/keystore/model.js +35 -4
  85. package/dist/packlets/crypto-utils/keystore/model.js.map +1 -0
  86. package/dist/packlets/crypto-utils/keystore/privateKeyStorage.js +21 -0
  87. package/dist/packlets/crypto-utils/keystore/privateKeyStorage.js.map +1 -0
  88. package/dist/packlets/crypto-utils/model.js +32 -0
  89. package/dist/packlets/crypto-utils/model.js.map +1 -0
  90. package/dist/packlets/crypto-utils/nodeCryptoProvider.js +347 -1
  91. package/dist/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -0
  92. package/dist/packlets/crypto-utils/seedDerivedKeyPair.js +120 -0
  93. package/dist/packlets/crypto-utils/seedDerivedKeyPair.js.map +1 -0
  94. package/dist/packlets/crypto-utils/spkiHelpers.js +284 -0
  95. package/dist/packlets/crypto-utils/spkiHelpers.js.map +1 -0
  96. package/dist/packlets/csv/csvFileHelpers.js +0 -14
  97. package/dist/packlets/csv/csvFileHelpers.js.map +1 -0
  98. package/dist/packlets/csv/csvHelpers.js +14 -0
  99. package/dist/packlets/csv/csvHelpers.js.map +1 -0
  100. package/dist/packlets/csv/index.browser.js +1 -3
  101. package/dist/packlets/csv/index.browser.js.map +1 -0
  102. package/dist/packlets/csv/index.js.map +1 -0
  103. package/dist/packlets/experimental/extendedArray.js.map +1 -0
  104. package/dist/packlets/experimental/formatter.js.map +1 -0
  105. package/dist/packlets/experimental/index.js.map +1 -0
  106. package/dist/packlets/experimental/rangeOf.js.map +1 -0
  107. package/dist/packlets/hash/index.browser.js.map +1 -0
  108. package/dist/packlets/hash/index.js.map +1 -0
  109. package/dist/packlets/hash/index.node.js.map +1 -0
  110. package/dist/packlets/hash/md5Normalizer.browser.js.map +1 -0
  111. package/dist/packlets/hash/md5Normalizer.js.map +1 -0
  112. package/dist/packlets/mustache/index.js.map +1 -0
  113. package/dist/packlets/mustache/interfaces.js.map +1 -0
  114. package/dist/packlets/mustache/mustacheTemplate.js +42 -4
  115. package/dist/packlets/mustache/mustacheTemplate.js.map +1 -0
  116. package/dist/packlets/record-jar/index.browser.js +1 -3
  117. package/dist/packlets/record-jar/index.browser.js.map +1 -0
  118. package/dist/packlets/record-jar/index.js.map +1 -0
  119. package/dist/packlets/record-jar/recordJarFileHelpers.js +0 -18
  120. package/dist/packlets/record-jar/recordJarFileHelpers.js.map +1 -0
  121. package/dist/packlets/record-jar/recordJarHelpers.js +18 -0
  122. package/dist/packlets/record-jar/recordJarHelpers.js.map +1 -0
  123. package/dist/packlets/safer-fetch/addressClassification.js +438 -0
  124. package/dist/packlets/safer-fetch/addressClassification.js.map +1 -0
  125. package/dist/packlets/safer-fetch/addressPolicy.js +119 -0
  126. package/dist/packlets/safer-fetch/addressPolicy.js.map +1 -0
  127. package/dist/packlets/safer-fetch/contentType.js +120 -0
  128. package/dist/packlets/safer-fetch/contentType.js.map +1 -0
  129. package/dist/packlets/safer-fetch/deadline.js +254 -0
  130. package/dist/packlets/safer-fetch/deadline.js.map +1 -0
  131. package/dist/packlets/safer-fetch/defaults.js +131 -0
  132. package/dist/packlets/safer-fetch/defaults.js.map +1 -0
  133. package/dist/packlets/safer-fetch/failureReason.js +21 -0
  134. package/dist/packlets/safer-fetch/failureReason.js.map +1 -0
  135. package/dist/packlets/safer-fetch/guards.js +148 -0
  136. package/dist/packlets/safer-fetch/guards.js.map +1 -0
  137. package/dist/packlets/safer-fetch/index.browser.js +58 -0
  138. package/dist/packlets/safer-fetch/index.browser.js.map +1 -0
  139. package/dist/packlets/safer-fetch/index.js +52 -0
  140. package/dist/packlets/safer-fetch/index.js.map +1 -0
  141. package/dist/packlets/safer-fetch/model.js +21 -0
  142. package/dist/packlets/safer-fetch/model.js.map +1 -0
  143. package/dist/packlets/safer-fetch/nodeAddressGuard.js +191 -0
  144. package/dist/packlets/safer-fetch/nodeAddressGuard.js.map +1 -0
  145. package/dist/packlets/safer-fetch/redirect.js +93 -0
  146. package/dist/packlets/safer-fetch/redirect.js.map +1 -0
  147. package/dist/packlets/safer-fetch/retry.js +188 -0
  148. package/dist/packlets/safer-fetch/retry.js.map +1 -0
  149. package/dist/packlets/safer-fetch/saferFetch.js +755 -0
  150. package/dist/packlets/safer-fetch/saferFetch.js.map +1 -0
  151. package/dist/packlets/safer-fetch/transport.js +50 -0
  152. package/dist/packlets/safer-fetch/transport.js.map +1 -0
  153. package/dist/packlets/yaml/converters.js.map +1 -0
  154. package/dist/packlets/yaml/index.js +1 -0
  155. package/dist/packlets/yaml/index.js.map +1 -0
  156. package/dist/packlets/yaml/serializers.js +48 -0
  157. package/dist/packlets/yaml/serializers.js.map +1 -0
  158. package/dist/packlets/zip-file-tree/index.js.map +1 -0
  159. package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js +99 -9
  160. package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -0
  161. package/dist/packlets/zip-file-tree/zipFileTreeWriter.js +16 -1
  162. package/dist/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -0
  163. package/dist/ts-extras.d.ts +6648 -553
  164. package/dist/tsdoc-metadata.json +1 -1
  165. package/lib/index.browser.d.ts +5 -2
  166. package/lib/index.browser.d.ts.map +1 -0
  167. package/lib/index.browser.js +11 -3
  168. package/lib/index.browser.js.map +1 -0
  169. package/lib/index.d.ts +2 -1
  170. package/lib/index.d.ts.map +1 -0
  171. package/lib/index.js +3 -1
  172. package/lib/index.js.map +1 -0
  173. package/lib/packlets/ai-assist/chatRequestBuilders.d.ts +149 -0
  174. package/lib/packlets/ai-assist/chatRequestBuilders.d.ts.map +1 -0
  175. package/lib/packlets/ai-assist/chatRequestBuilders.js +293 -0
  176. package/lib/packlets/ai-assist/chatRequestBuilders.js.map +1 -0
  177. package/lib/packlets/ai-assist/completionClient.d.ts +74 -0
  178. package/lib/packlets/ai-assist/completionClient.d.ts.map +1 -0
  179. package/lib/packlets/ai-assist/{apiClient.js → completionClient.js} +164 -213
  180. package/lib/packlets/ai-assist/completionClient.js.map +1 -0
  181. package/lib/packlets/ai-assist/converters.d.ts +15 -1
  182. package/lib/packlets/ai-assist/converters.d.ts.map +1 -0
  183. package/lib/packlets/ai-assist/converters.js +47 -3
  184. package/lib/packlets/ai-assist/converters.js.map +1 -0
  185. package/lib/packlets/ai-assist/embeddingClient.d.ts +69 -0
  186. package/lib/packlets/ai-assist/embeddingClient.d.ts.map +1 -0
  187. package/lib/packlets/ai-assist/embeddingClient.js +349 -0
  188. package/lib/packlets/ai-assist/embeddingClient.js.map +1 -0
  189. package/lib/packlets/ai-assist/endpoint.d.ts +49 -0
  190. package/lib/packlets/ai-assist/endpoint.d.ts.map +1 -0
  191. package/lib/packlets/ai-assist/endpoint.js +113 -0
  192. package/lib/packlets/ai-assist/endpoint.js.map +1 -0
  193. package/lib/packlets/ai-assist/http.d.ts +34 -0
  194. package/lib/packlets/ai-assist/http.d.ts.map +1 -0
  195. package/lib/packlets/ai-assist/http.js +109 -0
  196. package/lib/packlets/ai-assist/http.js.map +1 -0
  197. package/lib/packlets/ai-assist/imageGenerationClient.d.ts +46 -0
  198. package/lib/packlets/ai-assist/imageGenerationClient.d.ts.map +1 -0
  199. package/lib/packlets/ai-assist/imageGenerationClient.js +458 -0
  200. package/lib/packlets/ai-assist/imageGenerationClient.js.map +1 -0
  201. package/lib/packlets/ai-assist/imageOptionsResolver.d.ts +66 -0
  202. package/lib/packlets/ai-assist/imageOptionsResolver.d.ts.map +1 -0
  203. package/lib/packlets/ai-assist/imageOptionsResolver.js +197 -0
  204. package/lib/packlets/ai-assist/imageOptionsResolver.js.map +1 -0
  205. package/lib/packlets/ai-assist/index.d.ts +12 -4
  206. package/lib/packlets/ai-assist/index.d.ts.map +1 -0
  207. package/lib/packlets/ai-assist/index.js +47 -4
  208. package/lib/packlets/ai-assist/index.js.map +1 -0
  209. package/lib/packlets/ai-assist/jsonCompletion.d.ts +93 -0
  210. package/lib/packlets/ai-assist/jsonCompletion.d.ts.map +1 -0
  211. package/lib/packlets/ai-assist/jsonCompletion.js +97 -0
  212. package/lib/packlets/ai-assist/jsonCompletion.js.map +1 -0
  213. package/lib/packlets/ai-assist/jsonResponse.d.ts +194 -0
  214. package/lib/packlets/ai-assist/jsonResponse.d.ts.map +1 -0
  215. package/lib/packlets/ai-assist/jsonResponse.js +429 -0
  216. package/lib/packlets/ai-assist/jsonResponse.js.map +1 -0
  217. package/lib/packlets/ai-assist/listModelsClient.d.ts +46 -0
  218. package/lib/packlets/ai-assist/listModelsClient.d.ts.map +1 -0
  219. package/lib/packlets/ai-assist/listModelsClient.js +298 -0
  220. package/lib/packlets/ai-assist/listModelsClient.js.map +1 -0
  221. package/lib/packlets/ai-assist/model.d.ts +1346 -12
  222. package/lib/packlets/ai-assist/model.d.ts.map +1 -0
  223. package/lib/packlets/ai-assist/model.js +309 -10
  224. package/lib/packlets/ai-assist/model.js.map +1 -0
  225. package/lib/packlets/ai-assist/registry.d.ts +76 -1
  226. package/lib/packlets/ai-assist/registry.d.ts.map +1 -0
  227. package/lib/packlets/ai-assist/registry.js +381 -13
  228. package/lib/packlets/ai-assist/registry.js.map +1 -0
  229. package/lib/packlets/ai-assist/sseParser.d.ts +45 -0
  230. package/lib/packlets/ai-assist/sseParser.d.ts.map +1 -0
  231. package/lib/packlets/ai-assist/sseParser.js +128 -0
  232. package/lib/packlets/ai-assist/sseParser.js.map +1 -0
  233. package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts +72 -0
  234. package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts.map +1 -0
  235. package/lib/packlets/ai-assist/streamingAdapters/anthropic.js +379 -0
  236. package/lib/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -0
  237. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.d.ts +269 -0
  238. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.d.ts.map +1 -0
  239. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js +694 -0
  240. package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js.map +1 -0
  241. package/lib/packlets/ai-assist/streamingAdapters/common.d.ts +163 -0
  242. package/lib/packlets/ai-assist/streamingAdapters/common.d.ts.map +1 -0
  243. package/lib/packlets/ai-assist/streamingAdapters/common.js +193 -0
  244. package/lib/packlets/ai-assist/streamingAdapters/common.js.map +1 -0
  245. package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts +43 -0
  246. package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts.map +1 -0
  247. package/lib/packlets/ai-assist/streamingAdapters/gemini.js +211 -0
  248. package/lib/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -0
  249. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.d.ts +19 -0
  250. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.d.ts.map +1 -0
  251. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js +178 -0
  252. package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -0
  253. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts +33 -0
  254. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts.map +1 -0
  255. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js +393 -0
  256. package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -0
  257. package/lib/packlets/ai-assist/streamingAdapters/proxy.d.ts +34 -0
  258. package/lib/packlets/ai-assist/streamingAdapters/proxy.d.ts.map +1 -0
  259. package/lib/packlets/ai-assist/streamingAdapters/proxy.js +181 -0
  260. package/lib/packlets/ai-assist/streamingAdapters/proxy.js.map +1 -0
  261. package/lib/packlets/ai-assist/streamingClient.d.ts +50 -0
  262. package/lib/packlets/ai-assist/streamingClient.d.ts.map +1 -0
  263. package/lib/packlets/ai-assist/streamingClient.js +146 -0
  264. package/lib/packlets/ai-assist/streamingClient.js.map +1 -0
  265. package/lib/packlets/ai-assist/thinkingOptionsResolver.d.ts +87 -0
  266. package/lib/packlets/ai-assist/thinkingOptionsResolver.d.ts.map +1 -0
  267. package/lib/packlets/ai-assist/thinkingOptionsResolver.js +294 -0
  268. package/lib/packlets/ai-assist/thinkingOptionsResolver.js.map +1 -0
  269. package/lib/packlets/ai-assist/toolFormats.d.ts +40 -9
  270. package/lib/packlets/ai-assist/toolFormats.d.ts.map +1 -0
  271. package/lib/packlets/ai-assist/toolFormats.js +107 -10
  272. package/lib/packlets/ai-assist/toolFormats.js.map +1 -0
  273. package/lib/packlets/conversion/converters.d.ts +8 -1
  274. package/lib/packlets/conversion/converters.d.ts.map +1 -0
  275. package/lib/packlets/conversion/converters.js +36 -2
  276. package/lib/packlets/conversion/converters.js.map +1 -0
  277. package/lib/packlets/conversion/index.d.ts.map +1 -0
  278. package/lib/packlets/conversion/index.js.map +1 -0
  279. package/lib/packlets/crypto-utils/constants.d.ts.map +1 -0
  280. package/lib/packlets/crypto-utils/constants.js.map +1 -0
  281. package/lib/packlets/crypto-utils/converters.d.ts +20 -1
  282. package/lib/packlets/crypto-utils/converters.d.ts.map +1 -0
  283. package/lib/packlets/crypto-utils/converters.js +43 -5
  284. package/lib/packlets/crypto-utils/converters.js.map +1 -0
  285. package/lib/packlets/crypto-utils/directEncryptionProvider.d.ts.map +1 -0
  286. package/lib/packlets/crypto-utils/directEncryptionProvider.js.map +1 -0
  287. package/lib/packlets/crypto-utils/encryptedFile.d.ts +25 -0
  288. package/lib/packlets/crypto-utils/encryptedFile.d.ts.map +1 -0
  289. package/lib/packlets/crypto-utils/encryptedFile.js +38 -0
  290. package/lib/packlets/crypto-utils/encryptedFile.js.map +1 -0
  291. package/lib/packlets/crypto-utils/hpkeProvider.d.ts +150 -0
  292. package/lib/packlets/crypto-utils/hpkeProvider.d.ts.map +1 -0
  293. package/lib/packlets/crypto-utils/hpkeProvider.js +359 -0
  294. package/lib/packlets/crypto-utils/hpkeProvider.js.map +1 -0
  295. package/lib/packlets/crypto-utils/index.browser.d.ts +5 -1
  296. package/lib/packlets/crypto-utils/index.browser.d.ts.map +1 -0
  297. package/lib/packlets/crypto-utils/index.browser.js +28 -3
  298. package/lib/packlets/crypto-utils/index.browser.js.map +1 -0
  299. package/lib/packlets/crypto-utils/index.d.ts +5 -1
  300. package/lib/packlets/crypto-utils/index.d.ts.map +1 -0
  301. package/lib/packlets/crypto-utils/index.js +24 -1
  302. package/lib/packlets/crypto-utils/index.js.map +1 -0
  303. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts +54 -0
  304. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts.map +1 -0
  305. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js +74 -0
  306. package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -0
  307. package/lib/packlets/crypto-utils/keystore/converters.d.ts +68 -6
  308. package/lib/packlets/crypto-utils/keystore/converters.d.ts.map +1 -0
  309. package/lib/packlets/crypto-utils/keystore/converters.js +109 -14
  310. package/lib/packlets/crypto-utils/keystore/converters.js.map +1 -0
  311. package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.d.ts +148 -0
  312. package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.d.ts.map +1 -0
  313. package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js +324 -0
  314. package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js.map +1 -0
  315. package/lib/packlets/crypto-utils/keystore/index.browser.d.ts +10 -0
  316. package/lib/packlets/crypto-utils/keystore/index.browser.d.ts.map +1 -0
  317. package/lib/packlets/crypto-utils/keystore/index.browser.js +76 -0
  318. package/lib/packlets/crypto-utils/keystore/index.browser.js.map +1 -0
  319. package/lib/packlets/crypto-utils/keystore/index.d.ts +2 -0
  320. package/lib/packlets/crypto-utils/keystore/index.d.ts.map +1 -0
  321. package/lib/packlets/crypto-utils/keystore/index.js +5 -1
  322. package/lib/packlets/crypto-utils/keystore/index.js.map +1 -0
  323. package/lib/packlets/crypto-utils/keystore/keyStore.d.ts +314 -13
  324. package/lib/packlets/crypto-utils/keystore/keyStore.d.ts.map +1 -0
  325. package/lib/packlets/crypto-utils/keystore/keyStore.js +877 -124
  326. package/lib/packlets/crypto-utils/keystore/keyStore.js.map +1 -0
  327. package/lib/packlets/crypto-utils/keystore/model.d.ts +404 -21
  328. package/lib/packlets/crypto-utils/keystore/model.d.ts.map +1 -0
  329. package/lib/packlets/crypto-utils/keystore/model.js +37 -5
  330. package/lib/packlets/crypto-utils/keystore/model.js.map +1 -0
  331. package/lib/packlets/crypto-utils/keystore/privateKeyStorage.d.ts +53 -0
  332. package/lib/packlets/crypto-utils/keystore/privateKeyStorage.d.ts.map +1 -0
  333. package/lib/packlets/crypto-utils/keystore/privateKeyStorage.js +22 -0
  334. package/lib/packlets/crypto-utils/keystore/privateKeyStorage.js.map +1 -0
  335. package/lib/packlets/crypto-utils/model.d.ts +518 -10
  336. package/lib/packlets/crypto-utils/model.d.ts.map +1 -0
  337. package/lib/packlets/crypto-utils/model.js +33 -1
  338. package/lib/packlets/crypto-utils/model.js.map +1 -0
  339. package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts +142 -2
  340. package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts.map +1 -0
  341. package/lib/packlets/crypto-utils/nodeCryptoProvider.js +346 -0
  342. package/lib/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -0
  343. package/lib/packlets/crypto-utils/seedDerivedKeyPair.d.ts +42 -0
  344. package/lib/packlets/crypto-utils/seedDerivedKeyPair.d.ts.map +1 -0
  345. package/lib/packlets/crypto-utils/seedDerivedKeyPair.js +123 -0
  346. package/lib/packlets/crypto-utils/seedDerivedKeyPair.js.map +1 -0
  347. package/lib/packlets/crypto-utils/spkiHelpers.d.ts +151 -0
  348. package/lib/packlets/crypto-utils/spkiHelpers.d.ts.map +1 -0
  349. package/lib/packlets/crypto-utils/spkiHelpers.js +297 -0
  350. package/lib/packlets/crypto-utils/spkiHelpers.js.map +1 -0
  351. package/lib/packlets/csv/csvFileHelpers.d.ts +0 -10
  352. package/lib/packlets/csv/csvFileHelpers.d.ts.map +1 -0
  353. package/lib/packlets/csv/csvFileHelpers.js +0 -15
  354. package/lib/packlets/csv/csvFileHelpers.js.map +1 -0
  355. package/lib/packlets/csv/csvHelpers.d.ts +10 -0
  356. package/lib/packlets/csv/csvHelpers.d.ts.map +1 -0
  357. package/lib/packlets/csv/csvHelpers.js +15 -0
  358. package/lib/packlets/csv/csvHelpers.js.map +1 -0
  359. package/lib/packlets/csv/index.browser.d.ts +0 -1
  360. package/lib/packlets/csv/index.browser.d.ts.map +1 -0
  361. package/lib/packlets/csv/index.browser.js +1 -5
  362. package/lib/packlets/csv/index.browser.js.map +1 -0
  363. package/lib/packlets/csv/index.d.ts.map +1 -0
  364. package/lib/packlets/csv/index.js.map +1 -0
  365. package/lib/packlets/experimental/extendedArray.d.ts.map +1 -0
  366. package/lib/packlets/experimental/extendedArray.js.map +1 -0
  367. package/lib/packlets/experimental/formatter.d.ts.map +1 -0
  368. package/lib/packlets/experimental/formatter.js.map +1 -0
  369. package/lib/packlets/experimental/index.d.ts.map +1 -0
  370. package/lib/packlets/experimental/index.js.map +1 -0
  371. package/lib/packlets/experimental/rangeOf.d.ts.map +1 -0
  372. package/lib/packlets/experimental/rangeOf.js.map +1 -0
  373. package/lib/packlets/hash/index.browser.d.ts.map +1 -0
  374. package/lib/packlets/hash/index.browser.js.map +1 -0
  375. package/lib/packlets/hash/index.d.ts.map +1 -0
  376. package/lib/packlets/hash/index.js.map +1 -0
  377. package/lib/packlets/hash/index.node.d.ts.map +1 -0
  378. package/lib/packlets/hash/index.node.js.map +1 -0
  379. package/lib/packlets/hash/md5Normalizer.browser.d.ts.map +1 -0
  380. package/lib/packlets/hash/md5Normalizer.browser.js.map +1 -0
  381. package/lib/packlets/hash/md5Normalizer.d.ts.map +1 -0
  382. package/lib/packlets/hash/md5Normalizer.js.map +1 -0
  383. package/lib/packlets/mustache/index.d.ts +1 -1
  384. package/lib/packlets/mustache/index.d.ts.map +1 -0
  385. package/lib/packlets/mustache/index.js.map +1 -0
  386. package/lib/packlets/mustache/interfaces.d.ts +34 -0
  387. package/lib/packlets/mustache/interfaces.d.ts.map +1 -0
  388. package/lib/packlets/mustache/interfaces.js.map +1 -0
  389. package/lib/packlets/mustache/mustacheTemplate.d.ts +2 -0
  390. package/lib/packlets/mustache/mustacheTemplate.d.ts.map +1 -0
  391. package/lib/packlets/mustache/mustacheTemplate.js +42 -4
  392. package/lib/packlets/mustache/mustacheTemplate.js.map +1 -0
  393. package/lib/packlets/record-jar/index.browser.d.ts +0 -1
  394. package/lib/packlets/record-jar/index.browser.d.ts.map +1 -0
  395. package/lib/packlets/record-jar/index.browser.js +1 -5
  396. package/lib/packlets/record-jar/index.browser.js.map +1 -0
  397. package/lib/packlets/record-jar/index.d.ts.map +1 -0
  398. package/lib/packlets/record-jar/index.js.map +1 -0
  399. package/lib/packlets/record-jar/recordJarFileHelpers.d.ts +0 -11
  400. package/lib/packlets/record-jar/recordJarFileHelpers.d.ts.map +1 -0
  401. package/lib/packlets/record-jar/recordJarFileHelpers.js +0 -19
  402. package/lib/packlets/record-jar/recordJarFileHelpers.js.map +1 -0
  403. package/lib/packlets/record-jar/recordJarHelpers.d.ts +11 -0
  404. package/lib/packlets/record-jar/recordJarHelpers.d.ts.map +1 -0
  405. package/lib/packlets/record-jar/recordJarHelpers.js +19 -0
  406. package/lib/packlets/record-jar/recordJarHelpers.js.map +1 -0
  407. package/lib/packlets/safer-fetch/addressClassification.d.ts +144 -0
  408. package/lib/packlets/safer-fetch/addressClassification.d.ts.map +1 -0
  409. package/lib/packlets/safer-fetch/addressClassification.js +441 -0
  410. package/lib/packlets/safer-fetch/addressClassification.js.map +1 -0
  411. package/lib/packlets/safer-fetch/addressPolicy.d.ts +113 -0
  412. package/lib/packlets/safer-fetch/addressPolicy.d.ts.map +1 -0
  413. package/lib/packlets/safer-fetch/addressPolicy.js +123 -0
  414. package/lib/packlets/safer-fetch/addressPolicy.js.map +1 -0
  415. package/lib/packlets/safer-fetch/contentType.d.ts +51 -0
  416. package/lib/packlets/safer-fetch/contentType.d.ts.map +1 -0
  417. package/lib/packlets/safer-fetch/contentType.js +127 -0
  418. package/lib/packlets/safer-fetch/contentType.js.map +1 -0
  419. package/lib/packlets/safer-fetch/deadline.d.ts +138 -0
  420. package/lib/packlets/safer-fetch/deadline.d.ts.map +1 -0
  421. package/lib/packlets/safer-fetch/deadline.js +258 -0
  422. package/lib/packlets/safer-fetch/deadline.js.map +1 -0
  423. package/lib/packlets/safer-fetch/defaults.d.ts +108 -0
  424. package/lib/packlets/safer-fetch/defaults.d.ts.map +1 -0
  425. package/lib/packlets/safer-fetch/defaults.js +134 -0
  426. package/lib/packlets/safer-fetch/defaults.js.map +1 -0
  427. package/lib/packlets/safer-fetch/failureReason.d.ts +148 -0
  428. package/lib/packlets/safer-fetch/failureReason.d.ts.map +1 -0
  429. package/lib/packlets/safer-fetch/failureReason.js +22 -0
  430. package/lib/packlets/safer-fetch/failureReason.js.map +1 -0
  431. package/lib/packlets/safer-fetch/guards.d.ts +62 -0
  432. package/lib/packlets/safer-fetch/guards.d.ts.map +1 -0
  433. package/lib/packlets/safer-fetch/guards.js +153 -0
  434. package/lib/packlets/safer-fetch/guards.js.map +1 -0
  435. package/lib/packlets/safer-fetch/index.browser.d.ts +33 -0
  436. package/lib/packlets/safer-fetch/index.browser.d.ts.map +1 -0
  437. package/lib/packlets/safer-fetch/index.browser.js +82 -0
  438. package/lib/packlets/safer-fetch/index.browser.js.map +1 -0
  439. package/lib/packlets/safer-fetch/index.d.ts +27 -0
  440. package/lib/packlets/safer-fetch/index.d.ts.map +1 -0
  441. package/lib/packlets/safer-fetch/index.js +78 -0
  442. package/lib/packlets/safer-fetch/index.js.map +1 -0
  443. package/lib/packlets/safer-fetch/model.d.ts +373 -0
  444. package/lib/packlets/safer-fetch/model.d.ts.map +1 -0
  445. package/lib/packlets/safer-fetch/model.js +22 -0
  446. package/lib/packlets/safer-fetch/model.js.map +1 -0
  447. package/lib/packlets/safer-fetch/nodeAddressGuard.d.ts +129 -0
  448. package/lib/packlets/safer-fetch/nodeAddressGuard.d.ts.map +1 -0
  449. package/lib/packlets/safer-fetch/nodeAddressGuard.js +196 -0
  450. package/lib/packlets/safer-fetch/nodeAddressGuard.js.map +1 -0
  451. package/lib/packlets/safer-fetch/redirect.d.ts +62 -0
  452. package/lib/packlets/safer-fetch/redirect.d.ts.map +1 -0
  453. package/lib/packlets/safer-fetch/redirect.js +98 -0
  454. package/lib/packlets/safer-fetch/redirect.js.map +1 -0
  455. package/lib/packlets/safer-fetch/retry.d.ts +162 -0
  456. package/lib/packlets/safer-fetch/retry.d.ts.map +1 -0
  457. package/lib/packlets/safer-fetch/retry.js +197 -0
  458. package/lib/packlets/safer-fetch/retry.js.map +1 -0
  459. package/lib/packlets/safer-fetch/saferFetch.d.ts +108 -0
  460. package/lib/packlets/safer-fetch/saferFetch.d.ts.map +1 -0
  461. package/lib/packlets/safer-fetch/saferFetch.js +760 -0
  462. package/lib/packlets/safer-fetch/saferFetch.js.map +1 -0
  463. package/lib/packlets/safer-fetch/transport.d.ts +18 -0
  464. package/lib/packlets/safer-fetch/transport.d.ts.map +1 -0
  465. package/lib/packlets/safer-fetch/transport.js +53 -0
  466. package/lib/packlets/safer-fetch/transport.js.map +1 -0
  467. package/lib/packlets/yaml/converters.d.ts.map +1 -0
  468. package/lib/packlets/yaml/converters.js.map +1 -0
  469. package/lib/packlets/yaml/index.d.ts +1 -0
  470. package/lib/packlets/yaml/index.d.ts.map +1 -0
  471. package/lib/packlets/yaml/index.js +1 -0
  472. package/lib/packlets/yaml/index.js.map +1 -0
  473. package/lib/packlets/yaml/serializers.d.ts +45 -0
  474. package/lib/packlets/yaml/serializers.d.ts.map +1 -0
  475. package/lib/packlets/yaml/serializers.js +84 -0
  476. package/lib/packlets/yaml/serializers.js.map +1 -0
  477. package/lib/packlets/zip-file-tree/index.d.ts.map +1 -0
  478. package/lib/packlets/zip-file-tree/index.js.map +1 -0
  479. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts +84 -8
  480. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts.map +1 -0
  481. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js +99 -9
  482. package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -0
  483. package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts +26 -1
  484. package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts.map +1 -0
  485. package/lib/packlets/zip-file-tree/zipFileTreeWriter.js +17 -1
  486. package/lib/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -0
  487. package/package.json +30 -15
  488. package/lib/packlets/ai-assist/apiClient.d.ts +0 -60
@@ -1,7 +1,17 @@
1
1
  import { JsonValue } from '@fgv/ts-json-base';
2
- import { Result } from '@fgv/ts-utils';
2
+ import { Brand, Result, Uuid } from '@fgv/ts-utils';
3
3
  import * as Constants from './constants';
4
4
  export { Constants };
5
+ /**
6
+ * A multibase base64url-encoded SPKI (SubjectPublicKeyInfo) public key string —
7
+ * a `'m'` multibase prefix followed by a base64url-no-pad body. Produced by
8
+ * {@link CryptoUtils.exportPublicKeyAsMultibaseSpki} and consumed by
9
+ * {@link CryptoUtils.importPublicKeyFromMultibaseSpki}. Obtain the brand at a
10
+ * boundary via {@link CryptoUtils.isValidMultibaseSpkiPublicKey} or the
11
+ * {@link CryptoUtils.Converters.multibaseSpkiPublicKey} converter.
12
+ * @public
13
+ */
14
+ export type MultibaseSpkiPublicKey = Brand<string, 'MultibaseSpkiPublicKey'>;
5
15
  /**
6
16
  * Supported encryption algorithms.
7
17
  * @public
@@ -45,28 +55,269 @@ export interface IEncryptionResult {
45
55
  readonly encryptedData: Uint8Array;
46
56
  }
47
57
  /**
48
- * Supported key derivation functions.
58
+ * Result of a raw-byte AES-256-GCM encryption via
59
+ * {@link CryptoUtils.ICryptoProvider.encryptBytes | encryptBytes}. The
60
+ * authentication tag is returned separately from the ciphertext, mirroring the
61
+ * separated-tag convention of {@link CryptoUtils.IEncryptionResult}. The exact
62
+ * byte layout is:
63
+ * - `ciphertext`: the AES-GCM ciphertext, byte-for-byte the same length as the
64
+ * input plaintext (GCM is a stream cipher — no padding). Empty plaintext
65
+ * yields an empty `ciphertext`.
66
+ * - `authTag`: the 16-byte (128-bit) GCM authentication tag, computed over the
67
+ * ciphertext, the nonce, and any `aad`.
68
+ *
69
+ * The caller persists both fields alongside the (caller-owned) nonce and feeds
70
+ * them back to {@link CryptoUtils.ICryptoProvider.decryptBytes | decryptBytes}.
49
71
  * @public
50
72
  */
51
- export type KeyDerivationFunction = 'pbkdf2';
73
+ export interface IEncryptBytesResult {
74
+ /**
75
+ * The AES-256-GCM ciphertext. Same length as the input plaintext (no tag
76
+ * appended — the tag is carried separately in the `authTag` field).
77
+ */
78
+ readonly ciphertext: Uint8Array;
79
+ /**
80
+ * The 16-byte (128-bit) GCM authentication tag.
81
+ */
82
+ readonly authTag: Uint8Array;
83
+ }
52
84
  /**
53
- * Key derivation parameters stored in encrypted files.
54
- * Allows decryption with password without needing to know the original salt/iterations.
85
+ * Asymmetric keypair algorithms supported by the crypto provider.
86
+ * - `'ecdsa-p256'`: ECDSA over the P-256 curve, for signing.
87
+ * - `'rsa-oaep-2048'`: RSA-OAEP, 2048-bit modulus with SHA-256, for encryption.
88
+ * - `'ecdh-p256'`: ECDH over the P-256 curve, for key agreement
89
+ * (e.g. as the recipient keypair in
90
+ * {@link CryptoUtils.ICryptoProvider.wrapBytes | wrapBytes} /
91
+ * {@link CryptoUtils.ICryptoProvider.unwrapBytes | unwrapBytes}).
92
+ * - `'ed25519'`: EdDSA over the Edwards25519 curve, for signing.
93
+ * Deterministic — the per-signature nonce is derived from the private key
94
+ * and message rather than sampled randomly, eliminating the random-nonce
95
+ * reuse risk that ECDSA carries. Distinct from X25519 (key agreement over
96
+ * the Montgomery form, Curve25519).
97
+ * - `'x25519'`: Diffie-Hellman key agreement over the Montgomery form of
98
+ * Curve25519. Key-agreement only — use `deriveBits`/`deriveKey` to produce
99
+ * a shared secret from one party's private key and the peer's public key.
100
+ * Distinct from Ed25519 (which uses the twisted-Edwards form for signing).
101
+ * @public
102
+ */
103
+ export type KeyPairAlgorithm = 'ecdsa-p256' | 'rsa-oaep-2048' | 'ecdh-p256' | 'ed25519' | 'x25519';
104
+ /**
105
+ * The subset of {@link CryptoUtils.KeyPairAlgorithm} whose keypair can be
106
+ * derived *deterministically* from a fixed secret seed, for use with
107
+ * {@link CryptoUtils.ICryptoProvider.importKeyPairFromSeed | importKeyPairFromSeed}.
108
+ *
109
+ * Two algorithms are supported, both of whose 32-byte private scalar *is* the
110
+ * seed and whose public key is a deterministic function of it, so the same seed
111
+ * always yields the same keypair on every runtime:
112
+ * - `'ed25519'` — signing keypair (RFC 8032). Private usage `'sign'`, public
113
+ * usage `'verify'`.
114
+ * - `'x25519'` — Diffie-Hellman key-agreement keypair (RFC 7748), the recipient
115
+ * keypair consumed by {@link CryptoUtils.HpkeProvider}. Private usage
116
+ * `'deriveBits'`, public key imported with no usages. Deriving a fixed X25519
117
+ * recipient keypair from a checked-in seed is what makes a deterministic HPKE
118
+ * seal/open round-trip vector possible.
119
+ *
120
+ * The type is a proper subset of {@link CryptoUtils.KeyPairAlgorithm} because
121
+ * algorithms like RSA or the NIST curves are not recoverable from a bare seed.
55
122
  * @public
56
123
  */
57
- export interface IKeyDerivationParams {
124
+ export type SeedDerivableAlgorithm = 'ed25519' | 'x25519';
125
+ /**
126
+ * Caller-supplied HKDF parameters that domain-separate one
127
+ * {@link CryptoUtils.ICryptoProvider.wrapBytes | wrapBytes} call from another.
128
+ * Two wraps that share recipient but differ on `salt` or `info` derive distinct
129
+ * wrap keys, so callers should pick values that bind the wrap to its
130
+ * application context (e.g. a content hash for `salt` and a secret name for
131
+ * `info`).
132
+ *
133
+ * Both fields are required; pass an empty `Uint8Array` if the caller has no
134
+ * value to bind on a given axis. Silent defaulting would hide protocol
135
+ * mistakes, so the API does not pick defaults.
136
+ * @public
137
+ */
138
+ export interface IWrapBytesOptions {
58
139
  /**
59
- * Key derivation function used.
140
+ * HKDF salt. Domain-separates this wrap from others in different contexts.
141
+ * Caller picks; common choices include a content hash, document id, channel
142
+ * id, etc.
60
143
  */
61
- readonly kdf: KeyDerivationFunction;
144
+ readonly salt: Uint8Array;
62
145
  /**
63
- * Base64-encoded salt used for key derivation.
146
+ * HKDF info. Further binds the derived key to a specific use within the
147
+ * calling application. Caller picks; common choices include a secret name,
148
+ * message type, or version tag.
64
149
  */
150
+ readonly info: Uint8Array;
151
+ }
152
+ /**
153
+ * Output of {@link CryptoUtils.ICryptoProvider.wrapBytes | wrapBytes}. The
154
+ * shape is JSON-serializable so it can travel directly over the wire or be
155
+ * persisted as-is.
156
+ * @public
157
+ */
158
+ export interface IWrappedBytes {
159
+ /**
160
+ * Sender's ephemeral ECDH P-256 public key as a JSON Web Key. The matching
161
+ * ephemeral private key is dropped after the shared-secret derive.
162
+ */
163
+ readonly ephemeralPublicKey: JsonWebKey;
164
+ /**
165
+ * AES-GCM nonce, base64-encoded. 12 bytes (96 bits) — the standard AES-GCM
166
+ * nonce length.
167
+ */
168
+ readonly nonce: string;
169
+ /**
170
+ * AES-GCM ciphertext concatenated with the 16-byte authentication tag,
171
+ * base64-encoded. Tampering with either the nonce or the ciphertext causes
172
+ * unwrap to fail GCM authentication.
173
+ */
174
+ readonly ciphertext: string;
175
+ }
176
+ /**
177
+ * All valid key pair algorithms.
178
+ * @public
179
+ */
180
+ export declare const allKeyPairAlgorithms: ReadonlyArray<KeyPairAlgorithm>;
181
+ /**
182
+ * Supported key derivation functions.
183
+ * @public
184
+ */
185
+ export type KeyDerivationFunction = 'pbkdf2' | 'argon2id';
186
+ /**
187
+ * PBKDF2 key derivation parameters.
188
+ * @public
189
+ */
190
+ export interface IPbkdf2KeyDerivationParams {
191
+ /** Key derivation function discriminator. */
192
+ readonly kdf: 'pbkdf2';
193
+ /** Base64-encoded salt used for key derivation. */
65
194
  readonly salt: string;
195
+ /** Number of iterations used for key derivation. */
196
+ readonly iterations: number;
197
+ }
198
+ /**
199
+ * Argon2id key derivation parameters (RFC 9106).
200
+ * @public
201
+ */
202
+ export interface IArgon2idKeyDerivationParams {
203
+ /** Key derivation function discriminator. */
204
+ readonly kdf: 'argon2id';
205
+ /** Base64-encoded salt used for key derivation. */
206
+ readonly salt: string;
207
+ /** Memory cost in kibibytes. */
208
+ readonly memoryKiB: number;
209
+ /** Number of passes (time cost). */
210
+ readonly iterations: number;
211
+ /** Degree of parallelism. */
212
+ readonly parallelism: number;
213
+ }
214
+ /**
215
+ * Key derivation parameters stored in encrypted files.
216
+ * Discriminated union on `kdf` field: `'pbkdf2'` or `'argon2id'`.
217
+ * @public
218
+ */
219
+ export type IKeyDerivationParams = IPbkdf2KeyDerivationParams | IArgon2idKeyDerivationParams;
220
+ /**
221
+ * Parameters for Argon2id key derivation (RFC 9106).
222
+ * All fields are required; fgv does not pick defaults silently.
223
+ * @public
224
+ */
225
+ export interface IArgon2idParams {
226
+ /**
227
+ * Memory cost in kibibytes (KiB).
228
+ * OWASP 2023 minimum: 19456 (19 MiB). Stronger: 65536 (64 MiB).
229
+ * Constraint: \>= 8.
230
+ */
231
+ readonly memoryKiB: number;
66
232
  /**
67
- * Number of iterations used for key derivation.
233
+ * Number of passes (iterations / time cost).
234
+ * OWASP 2023 minimum: 2. Range: \>= 1.
68
235
  */
69
236
  readonly iterations: number;
237
+ /**
238
+ * Degree of parallelism (threads).
239
+ * Note: WASM-based implementations compute sequentially regardless of this value,
240
+ * but the value is wired into the algorithm and AFFECTS the output hash bytes.
241
+ * Callers must use the same parallelism value consistently for a given secret.
242
+ * Range: 1–255.
243
+ */
244
+ readonly parallelism: number;
245
+ /**
246
+ * Number of output bytes (hash length).
247
+ * Typical values: 16 (128-bit), 32 (256-bit, AES-256 key), 64 (512-bit).
248
+ * Constraint: \>= 4.
249
+ */
250
+ readonly outputBytes: number;
251
+ }
252
+ /**
253
+ * Recommended OWASP 2023 minimum Argon2id parameters.
254
+ * Suitable for recovery-row key derivation (high-entropy inputs).
255
+ * @public
256
+ */
257
+ export declare const ARGON2ID_OWASP_MIN: IArgon2idParams;
258
+ /**
259
+ * Stronger Argon2id parameters suitable for user-typed passphrases.
260
+ * @public
261
+ */
262
+ export declare const ARGON2ID_PASSPHRASE: IArgon2idParams;
263
+ /**
264
+ * Optional keyed-hashing inputs for {@link CryptoUtils.IArgon2idProvider.argon2id | argon2id}
265
+ * (RFC 9106 §3.1). These are distinct from the cost parameters in
266
+ * {@link CryptoUtils.IArgon2idParams} — they change the derived output but are
267
+ * not tuning knobs. Both fields are optional; omitting a field (or passing an
268
+ * empty `Uint8Array`) is a no-op that leaves the output byte-identical to a call
269
+ * with no options at all.
270
+ * @public
271
+ */
272
+ export interface IArgon2idKeyingOptions {
273
+ /**
274
+ * Optional secret key K (RFC 9106 keyed hashing, sometimes called a "pepper").
275
+ * When present and non-empty it is mixed into the hash so that the derived
276
+ * output cannot be reproduced without also knowing K. Empty or omitted means
277
+ * no secret. Honored by both the Node and browser backends.
278
+ */
279
+ readonly secret?: Uint8Array;
280
+ /**
281
+ * Optional associated data X (RFC 9106 §3.1). When present and non-empty it is
282
+ * mixed into the hash. **Node-only:** the WASM (`hash-wasm`) browser backend
283
+ * has no associated-data input, so `BrowserArgon2Provider` fails loudly rather
284
+ * than silently dropping it (which would produce wrong bytes). Empty or omitted
285
+ * means no associated data and is accepted by both backends.
286
+ */
287
+ readonly associatedData?: Uint8Array;
288
+ }
289
+ /**
290
+ * Argon2id key derivation provider (RFC 9106).
291
+ *
292
+ * Implementations are in separate packages to avoid WASM bundle costs for
293
+ * consumers who don't need Argon2id:
294
+ * - Node: `@fgv/ts-extras-argon2` (`NodeArgon2Provider`)
295
+ * - Browser: `@fgv/ts-web-extras-argon2` (`BrowserArgon2Provider`)
296
+ *
297
+ * @public
298
+ */
299
+ export interface IArgon2idProvider {
300
+ /**
301
+ * Derives key material from a password using Argon2id (RFC 9106 §3.1).
302
+ *
303
+ * Returns the raw derived bytes as a `Uint8Array`. For the same inputs that
304
+ * both backends support, the Node and browser implementations produce
305
+ * byte-identical output. The optional `associatedData` in
306
+ * {@link CryptoUtils.IArgon2idKeyingOptions} is the one exception: it is
307
+ * Node-only (the browser WASM backend has no associated-data input), so a call
308
+ * that supplies non-empty `associatedData` is not portable to the browser
309
+ * backend. Every input the browser backend *does* support (including the
310
+ * optional `secret`) is byte-identical across the two.
311
+ *
312
+ * @param password - Password or passphrase. Accepts string (UTF-8) or raw bytes.
313
+ * @param salt - Salt bytes. Must be random and unique per credential (\>= 16 bytes recommended).
314
+ * @param params - Argon2id parameters. Use `ARGON2ID_OWASP_MIN` as a starting point.
315
+ * @param options - Optional {@link CryptoUtils.IArgon2idKeyingOptions | keyed-hashing inputs}
316
+ * (secret K and/or associated data X). Omitting them (the default) leaves the
317
+ * output byte-identical to prior behavior.
318
+ * @returns Success with derived bytes, Failure with error context.
319
+ */
320
+ argon2id(password: Uint8Array | string, salt: Uint8Array, params: IArgon2idParams, options?: IArgon2idKeyingOptions): Promise<Result<Uint8Array>>;
70
321
  }
71
322
  /**
72
323
  * Generic encrypted file format.
@@ -132,6 +383,68 @@ export interface ICryptoProvider {
132
383
  * @returns Success with decrypted UTF-8 string, or Failure with error
133
384
  */
134
385
  decrypt(encryptedData: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array): Promise<Result<string>>;
386
+ /**
387
+ * Encrypts raw bytes using AES-256-GCM with a **caller-supplied nonce** and
388
+ * optional additional authenticated data (AAD).
389
+ *
390
+ * This is the raw-byte sibling of {@link CryptoUtils.ICryptoProvider.encrypt | encrypt}.
391
+ * Unlike `encrypt`, it takes and returns `Uint8Array` (no UTF-8 coding), the
392
+ * caller owns the nonce (rather than the provider generating one), and it
393
+ * binds optional `aad` into the GCM authentication. Use it when you need to
394
+ * bind context (e.g. an actor id, key version, or row kind) into the
395
+ * authentication so a wrapped secret cannot be replayed across
396
+ * users/versions/kinds, or when you manage nonces yourself.
397
+ *
398
+ * @remarks
399
+ * **⚠️ NONCE UNIQUENESS IS THE CALLER'S RESPONSIBILITY AND IS CRITICAL.**
400
+ * Because the caller supplies the nonce, this primitive cannot guarantee
401
+ * uniqueness. Reusing a `(key, nonce)` pair for two different messages is
402
+ * **catastrophic** for AES-GCM: it breaks confidentiality (the XOR of the two
403
+ * plaintexts leaks) AND authentication (the GCM authentication key can be
404
+ * recovered, letting an attacker forge tags for arbitrary messages under that
405
+ * key). The caller MUST use a unique nonce for every message encrypted under a
406
+ * given key — draw it from {@link CryptoUtils.ICryptoProvider.generateRandomBytes | generateRandomBytes(12)}
407
+ * (12 random bytes has negligible collision probability well within a single
408
+ * key's message budget) or from a strictly-increasing counter. Never hardcode
409
+ * a nonce and never reuse one.
410
+ *
411
+ * @param key - 32-byte AES-256 key. Wrong lengths fail with error context.
412
+ * @param nonce - 12-byte (96-bit) GCM nonce. MUST be unique per message under
413
+ * `key` (see the nonce-uniqueness warning above). Wrong lengths fail with
414
+ * error context.
415
+ * @param plaintext - The bytes to encrypt. Empty plaintext is permitted and
416
+ * round-trips (GCM produces a valid tag over zero-length plaintext).
417
+ * @param aad - Optional additional authenticated data bound into the GCM tag
418
+ * but NOT encrypted. If provided at encrypt time, the identical bytes must be
419
+ * supplied to `decryptBytes` or decryption fails authentication. Absent means
420
+ * no AAD.
421
+ * @returns `Success` with the {@link CryptoUtils.IEncryptBytesResult | ciphertext and 16-byte auth tag},
422
+ * or `Failure` with error context.
423
+ */
424
+ encryptBytes(key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, aad?: Uint8Array): Promise<Result<IEncryptBytesResult>>;
425
+ /**
426
+ * Decrypts raw bytes produced by
427
+ * {@link CryptoUtils.ICryptoProvider.encryptBytes | encryptBytes} using
428
+ * AES-256-GCM. The inverse of `encryptBytes`: the `ciphertext` and `authTag`
429
+ * from an `encryptBytes` result, together with the same `key`, `nonce`, and
430
+ * `aad`, recover the original plaintext.
431
+ *
432
+ * Fails (never throws) on any authentication failure: a tampered ciphertext
433
+ * or tag, the wrong key or nonce, or an `aad` that differs from the one used
434
+ * at encrypt time. AES-GCM authentication is fail-closed — a mismatched `aad`
435
+ * fails exactly as a tampered ciphertext does.
436
+ *
437
+ * @param key - 32-byte AES-256 key (the same key used to encrypt).
438
+ * @param nonce - 12-byte (96-bit) GCM nonce (the same nonce used to encrypt).
439
+ * @param ciphertext - The ciphertext from the `encryptBytes` result.
440
+ * @param authTag - The 16-byte (128-bit) GCM authentication tag from the
441
+ * `encryptBytes` result.
442
+ * @param aad - The identical additional authenticated data supplied at encrypt
443
+ * time (or absent if none was supplied). A mismatch fails authentication.
444
+ * @returns `Success` with the decrypted plaintext bytes, or `Failure` with
445
+ * error context (including all authentication failures).
446
+ */
447
+ decryptBytes(key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, authTag: Uint8Array, aad?: Uint8Array): Promise<Result<Uint8Array>>;
135
448
  /**
136
449
  * Generates a random 32-byte key suitable for AES-256.
137
450
  * @returns Success with generated key, or Failure with error
@@ -145,12 +458,27 @@ export interface ICryptoProvider {
145
458
  * @returns Success with derived 32-byte key, or Failure with error
146
459
  */
147
460
  deriveKey(password: string, salt: Uint8Array, iterations: number): Promise<Result<Uint8Array>>;
461
+ /**
462
+ * Computes a SHA-256 hash of the given data.
463
+ * @param data - UTF-8 string to hash
464
+ * @returns Success with hex-encoded hash string, or Failure with error
465
+ */
466
+ sha256(data: string): Promise<Result<string>>;
148
467
  /**
149
468
  * Generates cryptographically secure random bytes.
150
469
  * @param length - Number of bytes to generate
151
470
  * @returns Success with random bytes, or Failure with error
152
471
  */
153
472
  generateRandomBytes(length: number): Result<Uint8Array>;
473
+ /**
474
+ * Generates a cryptographically random UUIDv4 using the provider's
475
+ * underlying source of randomness. The default Node and browser
476
+ * implementations delegate to `globalThis.crypto.randomUUID`;
477
+ * deterministic providers (e.g. test stubs) may override to produce
478
+ * reproducible values.
479
+ * @returns Success with a canonical UUID, or Failure with error.
480
+ */
481
+ generateUuid(): Result<Uuid>;
154
482
  /**
155
483
  * Encodes binary data to base64 string.
156
484
  * @param data - Binary data to encode
@@ -163,6 +491,186 @@ export interface ICryptoProvider {
163
491
  * @returns Success with decoded bytes, or Failure if invalid base64
164
492
  */
165
493
  fromBase64(base64: string): Result<Uint8Array>;
494
+ /**
495
+ * Generates a new asymmetric keypair for the requested algorithm.
496
+ * @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} to use.
497
+ * @param extractable - Whether the resulting `CryptoKey` objects may be exported.
498
+ * Set `false` on backends that store `CryptoKey` references directly (e.g.
499
+ * IndexedDB). Set `true` when the private key must round-trip through JWK or
500
+ * PKCS#8 (e.g. encrypted-file backends).
501
+ * @returns Success with the generated `CryptoKeyPair`, or Failure with error context.
502
+ */
503
+ generateKeyPair(algorithm: KeyPairAlgorithm, extractable: boolean): Promise<Result<CryptoKeyPair>>;
504
+ /**
505
+ * Derives an asymmetric keypair *deterministically* from a fixed secret seed.
506
+ * The same `seed` always yields the same keypair on every runtime, so this is
507
+ * the primitive to use when a keypair must be reconstructable from stored seed
508
+ * material (key escrow, HD-style derivation, deterministic test vectors) rather
509
+ * than freshly sampled by {@link CryptoUtils.ICryptoProvider.generateKeyPair | generateKeyPair}.
510
+ *
511
+ * For both `'ed25519'` and `'x25519'` the private key *is* its 32-byte seed and
512
+ * the public key is a deterministic function of that seed (RFC 8032 / RFC 7748),
513
+ * so the returned public key is recovered even when the caller requests a
514
+ * non-extractable private key. The transient extractable key used internally to
515
+ * recover the public half is never returned or logged when `extractable` is
516
+ * `false`. The returned keys carry the algorithm's usages: `'ed25519'` →
517
+ * private `'sign'` / public `'verify'`; `'x25519'` → private `'deriveBits'` /
518
+ * public no-usage (ready to hand to {@link CryptoUtils.HpkeProvider}).
519
+ * @param algorithm - The {@link CryptoUtils.SeedDerivableAlgorithm | seed-derivable algorithm}
520
+ * (`'ed25519'` or `'x25519'`); any other value fails loudly with context.
521
+ * @param seed - The secret seed. It must be exactly 32 bytes for both supported
522
+ * algorithms; any other length fails loudly, before any WebCrypto call. The
523
+ * bytes are copied, not retained or mutated.
524
+ * @param extractable - Whether the returned private key may be exported. The
525
+ * returned public key is identical for a given seed regardless of this flag.
526
+ * @returns Success with the derived `CryptoKeyPair`, or Failure with error context.
527
+ */
528
+ importKeyPairFromSeed(algorithm: SeedDerivableAlgorithm, seed: Uint8Array, extractable: boolean): Promise<Result<CryptoKeyPair>>;
529
+ /**
530
+ * Exports the public half of a keypair as a JSON Web Key.
531
+ * @param publicKey - The public `CryptoKey` to export. Must be an `extractable`
532
+ * key generated for an asymmetric algorithm.
533
+ * @returns Success with the JWK, or Failure with error context.
534
+ */
535
+ exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>>;
536
+ /**
537
+ * Re-imports a public-key JWK as a `CryptoKey` usable for verification or
538
+ * encryption (depending on algorithm).
539
+ * @param jwk - The JSON Web Key produced by {@link CryptoUtils.ICryptoProvider.exportPublicKeyJwk | exportPublicKeyJwk}.
540
+ * @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} the
541
+ * key was generated for. Determines the import parameters and key usages.
542
+ * @returns Success with the imported public `CryptoKey`, or Failure with error context.
543
+ */
544
+ importPublicKeyJwk(jwk: JsonWebKey, algorithm: KeyPairAlgorithm): Promise<Result<CryptoKey>>;
545
+ /**
546
+ * Exports a public `CryptoKey` as a DER-encoded SPKI (SubjectPublicKeyInfo) blob.
547
+ * SPKI is the standard algorithm-agnostic format for public key storage and transport.
548
+ * @param publicKey - The `CryptoKey` to export. Must have `key.type === 'public'`.
549
+ * @returns `Success` with the raw SPKI bytes, or `Failure` with error context.
550
+ */
551
+ exportPublicKeySpki(publicKey: CryptoKey): Promise<Result<Uint8Array>>;
552
+ /**
553
+ * Imports a public key from a DER-encoded SPKI blob.
554
+ * @param spkiBytes - The raw SPKI bytes produced by {@link CryptoUtils.ICryptoProvider.exportPublicKeySpki | exportPublicKeySpki}.
555
+ * @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} the key was generated for.
556
+ * @returns `Success` with the imported public `CryptoKey`, or `Failure` with error context.
557
+ */
558
+ importPublicKeySpki(spkiBytes: Uint8Array, algorithm: KeyPairAlgorithm): Promise<Result<CryptoKey>>;
559
+ /**
560
+ * Wraps `plaintext` for delivery to the holder of the private key paired
561
+ * with `recipientPublicKey`. Uses ECIES with ECDH P-256, HKDF-SHA256, and
562
+ * AES-GCM-256.
563
+ *
564
+ * Generates a fresh ephemeral keypair per call; the ephemeral private key
565
+ * is discarded after the shared-secret derive. Only the recipient (with the
566
+ * matching private key) and the same HKDF parameters can recover
567
+ * `plaintext`.
568
+ *
569
+ * Empty `plaintext` is permitted; the resulting wrap contains only the
570
+ * 16-byte GCM authentication tag and round-trips back to an empty
571
+ * `Uint8Array`.
572
+ * @param plaintext - The bytes to wrap. Any length supported by AES-GCM
573
+ * (in practice, well below 2^39 - 256 bits).
574
+ * @param recipientPublicKey - The recipient's ECDH P-256 public `CryptoKey`.
575
+ * Must have algorithm name `'ECDH'` and named curve `'P-256'`; mismatched
576
+ * algorithm or curve yields a `Failure` with error context.
577
+ * @param options - HKDF parameters; see {@link CryptoUtils.IWrapBytesOptions | IWrapBytesOptions}.
578
+ * @returns `Success` with the wrapped payload, or `Failure` with error context.
579
+ */
580
+ wrapBytes(plaintext: Uint8Array, recipientPublicKey: CryptoKey, options: IWrapBytesOptions): Promise<Result<IWrappedBytes>>;
581
+ /**
582
+ * Inverse of {@link CryptoUtils.ICryptoProvider.wrapBytes | wrapBytes}.
583
+ * Recovers the original `plaintext` from a wrapped payload using the
584
+ * recipient's private key.
585
+ *
586
+ * Returns a `Failure` (never throws) on any of:
587
+ * - Tampered nonce or ciphertext (AES-GCM authentication fails)
588
+ * - Wrong private key (different shared secret derives a different wrap key)
589
+ * - Wrong HKDF parameters (different wrap key)
590
+ * - Malformed `ephemeralPublicKey` JWK
591
+ * - Malformed base64 in `nonce` or `ciphertext`
592
+ * @param wrapped - The wrapped payload produced by `wrapBytes`.
593
+ * @param recipientPrivateKey - The recipient's ECDH P-256 private
594
+ * `CryptoKey`. Must have algorithm name `'ECDH'` and named curve `'P-256'`,
595
+ * and key usages including `'deriveKey'` or `'deriveBits'`.
596
+ * @param options - The same HKDF parameters used at wrap time.
597
+ * @returns `Success` with the original `plaintext`, or `Failure` with error context.
598
+ */
599
+ unwrapBytes(wrapped: IWrappedBytes, recipientPrivateKey: CryptoKey, options: IWrapBytesOptions): Promise<Result<Uint8Array>>;
600
+ /**
601
+ * Signs `data` with `privateKey` using the algorithm inferred from the key.
602
+ * Delegates to `crypto.subtle.sign`; the algorithm is derived from
603
+ * `privateKey.algorithm.name` — ECDSA keys are augmented with
604
+ * `hash: 'SHA-256'` at sign time (the hash is not stored in the key);
605
+ * all other algorithm names are passed through as-is.
606
+ * Intended for Ed25519 and ECDSA-P256 asymmetric private keys; for
607
+ * HMAC-SHA256 authentication codes use {@link ICryptoProvider.hmacSha256} instead.
608
+ * @param privateKey - A `CryptoKey` with `'sign'` usage (e.g. generated by
609
+ * {@link CryptoUtils.ICryptoProvider.generateKeyPair | generateKeyPair} with
610
+ * `'ecdsa-p256'` or `'ed25519'`).
611
+ * @param data - The bytes to sign.
612
+ * @returns `Success` with the raw signature bytes, or `Failure` with error context.
613
+ */
614
+ sign(privateKey: CryptoKey, data: Uint8Array): Promise<Result<Uint8Array>>;
615
+ /**
616
+ * Verifies a signature produced by {@link ICryptoProvider.sign}.
617
+ * Delegates to `crypto.subtle.verify`; the algorithm is derived from
618
+ * `publicKey.algorithm.name` — ECDSA keys are augmented with
619
+ * `hash: 'SHA-256'`; all other algorithm names are passed through as-is.
620
+ * Intended for Ed25519 and ECDSA-P256 asymmetric public keys; for
621
+ * HMAC-SHA256 verification use {@link ICryptoProvider.verifyHmacSha256} instead.
622
+ * @param publicKey - A `CryptoKey` with `'verify'` usage (e.g. the public
623
+ * half of a keypair generated by
624
+ * {@link CryptoUtils.ICryptoProvider.generateKeyPair | generateKeyPair} with
625
+ * `'ecdsa-p256'` or `'ed25519'`).
626
+ * @param signature - The raw signature bytes produced by `sign`.
627
+ * @param data - The original data that was signed.
628
+ * @returns `Success` with `true` if the signature is valid, `false` if it is
629
+ * not, or `Failure` with error context if the operation itself failed.
630
+ */
631
+ verify(publicKey: CryptoKey, signature: Uint8Array, data: Uint8Array): Promise<Result<boolean>>;
632
+ /**
633
+ * Compares two byte arrays in constant time.
634
+ *
635
+ * The comparison visits all bytes of `a` and `b` regardless of where they
636
+ * diverge, accumulating XOR differences with bitwise-OR. No early-return is
637
+ * possible once the length check passes, making timing independent of the
638
+ * byte values. This prevents timing side-channels when comparing MAC outputs,
639
+ * signed-token bytes, or any secret-derived byte sequences.
640
+ *
641
+ * Returns `false` immediately (before the loop) when `a.length !== b.length`;
642
+ * the length mismatch itself is not secret in normal use.
643
+ * @param a - First byte array.
644
+ * @param b - Second byte array.
645
+ * @returns `true` if the arrays have the same length and identical contents,
646
+ * `false` otherwise.
647
+ */
648
+ timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;
649
+ /**
650
+ * Computes an HMAC-SHA256 authentication code for `data` using `key`.
651
+ *
652
+ * The key must be a `CryptoKey` with `'sign'` usage and algorithm name
653
+ * `'HMAC'` (e.g. derived via PBKDF2 or imported with
654
+ * `crypto.subtle.importKey`). Use {@link ICryptoProvider.verifyHmacSha256}
655
+ * for constant-time verification of the output.
656
+ * @param key - An HMAC `CryptoKey` with `'sign'` usage.
657
+ * @param data - The bytes to authenticate.
658
+ * @returns `Success` with the 32-byte MAC, or `Failure` with error context.
659
+ */
660
+ hmacSha256(key: CryptoKey, data: Uint8Array): Promise<Result<Uint8Array>>;
661
+ /**
662
+ * Verifies an HMAC-SHA256 authentication code in constant time.
663
+ *
664
+ * Computes the expected MAC over `data` with `key`, then compares it to
665
+ * `signature` using {@link ICryptoProvider.timingSafeEqual} so that
666
+ * mismatches do not leak information through timing.
667
+ * @param key - An HMAC `CryptoKey` with `'sign'` usage.
668
+ * @param signature - The MAC bytes to verify (typically 32 bytes).
669
+ * @param data - The original data that was authenticated.
670
+ * @returns `Success` with `true` if the MAC is valid, `false` if it is not,
671
+ * or `Failure` with error context if the MAC computation itself failed.
672
+ */
673
+ verifyHmacSha256(key: CryptoKey, signature: Uint8Array, data: Uint8Array): Promise<Result<boolean>>;
166
674
  }
167
675
  /**
168
676
  * High-level interface for encrypting JSON content by secret name.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/pack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CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;CAC/C;AAMD;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAC9B,MAAM,GACN,MAAM,GACN,MAAM,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;AAEjF;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAE/C;;;OAGG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,eAAe,CAAC;IAEzC;;OAEG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,sBAAsB,CAAC;IAE/C;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;CACrD;AAMD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAMtD"}
@@ -52,10 +52,42 @@ var __importStar = (this && this.__importStar) || (function () {
52
52
  };
53
53
  })();
54
54
  Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.Constants = void 0;
55
+ exports.ARGON2ID_PASSPHRASE = exports.ARGON2ID_OWASP_MIN = exports.allKeyPairAlgorithms = exports.Constants = void 0;
56
56
  exports.isEncryptedFile = isEncryptedFile;
57
57
  const Constants = __importStar(require("./constants"));
58
58
  exports.Constants = Constants;
59
+ /**
60
+ * All valid key pair algorithms.
61
+ * @public
62
+ */
63
+ exports.allKeyPairAlgorithms = [
64
+ 'ecdsa-p256',
65
+ 'rsa-oaep-2048',
66
+ 'ecdh-p256',
67
+ 'ed25519',
68
+ 'x25519'
69
+ ];
70
+ /**
71
+ * Recommended OWASP 2023 minimum Argon2id parameters.
72
+ * Suitable for recovery-row key derivation (high-entropy inputs).
73
+ * @public
74
+ */
75
+ exports.ARGON2ID_OWASP_MIN = {
76
+ memoryKiB: 19456,
77
+ iterations: 2,
78
+ parallelism: 1,
79
+ outputBytes: 32
80
+ };
81
+ /**
82
+ * Stronger Argon2id parameters suitable for user-typed passphrases.
83
+ * @public
84
+ */
85
+ exports.ARGON2ID_PASSPHRASE = {
86
+ memoryKiB: 65536,
87
+ iterations: 3,
88
+ parallelism: 1,
89
+ outputBytes: 32
90
+ };
59
91
  // ============================================================================
60
92
  // Detection Helper
61
93
  // ============================================================================