@fgv/ts-extras 5.1.0-4 → 5.1.0-41
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.
- package/dist/index.browser.js +4 -2
- package/dist/index.browser.js.map +1 -0
- package/dist/index.js.map +1 -0
- package/dist/packlets/ai-assist/apiClient.js +886 -158
- package/dist/packlets/ai-assist/apiClient.js.map +1 -0
- package/dist/packlets/ai-assist/chatRequestBuilders.js +282 -0
- package/dist/packlets/ai-assist/chatRequestBuilders.js.map +1 -0
- package/dist/packlets/ai-assist/converters.js +47 -3
- package/dist/packlets/ai-assist/converters.js.map +1 -0
- package/dist/packlets/ai-assist/embeddingClient.js +345 -0
- package/dist/packlets/ai-assist/embeddingClient.js.map +1 -0
- package/dist/packlets/ai-assist/endpoint.js +78 -0
- package/dist/packlets/ai-assist/endpoint.js.map +1 -0
- package/dist/packlets/ai-assist/http.js +75 -0
- package/dist/packlets/ai-assist/http.js.map +1 -0
- package/dist/packlets/ai-assist/imageOptionsResolver.js +193 -0
- package/dist/packlets/ai-assist/imageOptionsResolver.js.map +1 -0
- package/dist/packlets/ai-assist/index.js +10 -4
- package/dist/packlets/ai-assist/index.js.map +1 -0
- package/dist/packlets/ai-assist/jsonCompletion.js +93 -0
- package/dist/packlets/ai-assist/jsonCompletion.js.map +1 -0
- package/dist/packlets/ai-assist/jsonResponse.js +149 -0
- package/dist/packlets/ai-assist/jsonResponse.js.map +1 -0
- package/dist/packlets/ai-assist/model.js +193 -9
- package/dist/packlets/ai-assist/model.js.map +1 -0
- package/dist/packlets/ai-assist/registry.js +314 -12
- package/dist/packlets/ai-assist/registry.js.map +1 -0
- package/dist/packlets/ai-assist/sseParser.js +123 -0
- package/dist/packlets/ai-assist/sseParser.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/anthropic.js +368 -0
- package/dist/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js +687 -0
- package/dist/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/common.js +187 -0
- package/dist/packlets/ai-assist/streamingAdapters/common.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/gemini.js +204 -0
- package/dist/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js +170 -0
- package/dist/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js +386 -0
- package/dist/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -0
- package/dist/packlets/ai-assist/streamingAdapters/proxy.js +173 -0
- package/dist/packlets/ai-assist/streamingAdapters/proxy.js.map +1 -0
- package/dist/packlets/ai-assist/streamingClient.js +140 -0
- package/dist/packlets/ai-assist/streamingClient.js.map +1 -0
- package/dist/packlets/ai-assist/thinkingOptionsResolver.js +288 -0
- package/dist/packlets/ai-assist/thinkingOptionsResolver.js.map +1 -0
- package/dist/packlets/ai-assist/toolFormats.js +106 -10
- package/dist/packlets/ai-assist/toolFormats.js.map +1 -0
- package/dist/packlets/conversion/converters.js +35 -1
- package/dist/packlets/conversion/converters.js.map +1 -0
- package/dist/packlets/conversion/index.js.map +1 -0
- package/dist/packlets/crypto-utils/constants.js.map +1 -0
- package/dist/packlets/crypto-utils/converters.js +42 -4
- package/dist/packlets/crypto-utils/converters.js.map +1 -0
- package/dist/packlets/crypto-utils/directEncryptionProvider.js.map +1 -0
- package/dist/packlets/crypto-utils/encryptedFile.js.map +1 -0
- package/dist/packlets/crypto-utils/hpkeProvider.js +355 -0
- package/dist/packlets/crypto-utils/hpkeProvider.js.map +1 -0
- package/dist/packlets/crypto-utils/index.browser.js +10 -2
- package/dist/packlets/crypto-utils/index.browser.js.map +1 -0
- package/dist/packlets/crypto-utils/index.js +6 -0
- package/dist/packlets/crypto-utils/index.js.map +1 -0
- package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js +71 -0
- package/dist/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/converters.js +105 -14
- package/dist/packlets/crypto-utils/keystore/converters.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js +287 -0
- package/dist/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/index.browser.js +36 -0
- package/dist/packlets/crypto-utils/keystore/index.browser.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/index.js +3 -0
- package/dist/packlets/crypto-utils/keystore/index.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/keyStore.js +773 -119
- package/dist/packlets/crypto-utils/keystore/keyStore.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/model.js +30 -4
- package/dist/packlets/crypto-utils/keystore/model.js.map +1 -0
- package/dist/packlets/crypto-utils/keystore/privateKeyStorage.js +21 -0
- package/dist/packlets/crypto-utils/keystore/privateKeyStorage.js.map +1 -0
- package/dist/packlets/crypto-utils/model.js +32 -0
- package/dist/packlets/crypto-utils/model.js.map +1 -0
- package/dist/packlets/crypto-utils/nodeCryptoProvider.js +336 -1
- package/dist/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -0
- package/dist/packlets/crypto-utils/spkiHelpers.js +240 -0
- package/dist/packlets/crypto-utils/spkiHelpers.js.map +1 -0
- package/dist/packlets/csv/csvFileHelpers.js +0 -14
- package/dist/packlets/csv/csvFileHelpers.js.map +1 -0
- package/dist/packlets/csv/csvHelpers.js +14 -0
- package/dist/packlets/csv/csvHelpers.js.map +1 -0
- package/dist/packlets/csv/index.browser.js +1 -3
- package/dist/packlets/csv/index.browser.js.map +1 -0
- package/dist/packlets/csv/index.js.map +1 -0
- package/dist/packlets/experimental/extendedArray.js.map +1 -0
- package/dist/packlets/experimental/formatter.js.map +1 -0
- package/dist/packlets/experimental/index.js.map +1 -0
- package/dist/packlets/experimental/rangeOf.js.map +1 -0
- package/dist/packlets/hash/index.browser.js.map +1 -0
- package/dist/packlets/hash/index.js.map +1 -0
- package/dist/packlets/hash/index.node.js.map +1 -0
- package/dist/packlets/hash/md5Normalizer.browser.js.map +1 -0
- package/dist/packlets/hash/md5Normalizer.js.map +1 -0
- package/dist/packlets/mustache/index.js.map +1 -0
- package/dist/packlets/mustache/interfaces.js.map +1 -0
- package/dist/packlets/mustache/mustacheTemplate.js +42 -4
- package/dist/packlets/mustache/mustacheTemplate.js.map +1 -0
- package/dist/packlets/record-jar/index.browser.js +1 -3
- package/dist/packlets/record-jar/index.browser.js.map +1 -0
- package/dist/packlets/record-jar/index.js.map +1 -0
- package/dist/packlets/record-jar/recordJarFileHelpers.js +0 -18
- package/dist/packlets/record-jar/recordJarFileHelpers.js.map +1 -0
- package/dist/packlets/record-jar/recordJarHelpers.js +18 -0
- package/dist/packlets/record-jar/recordJarHelpers.js.map +1 -0
- package/dist/packlets/yaml/converters.js.map +1 -0
- package/dist/packlets/yaml/index.js +1 -0
- package/dist/packlets/yaml/index.js.map +1 -0
- package/dist/packlets/yaml/serializers.js +48 -0
- package/dist/packlets/yaml/serializers.js.map +1 -0
- package/dist/packlets/zip-file-tree/index.js.map +1 -0
- package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js +2 -2
- package/dist/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -0
- package/dist/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -0
- package/dist/ts-extras.d.ts +4342 -285
- package/dist/tsdoc-metadata.json +1 -1
- package/lib/index.browser.d.ts +4 -2
- package/lib/index.browser.d.ts.map +1 -0
- package/lib/index.browser.js +8 -3
- package/lib/index.browser.js.map +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js.map +1 -0
- package/lib/packlets/ai-assist/apiClient.d.ts +115 -32
- package/lib/packlets/ai-assist/apiClient.d.ts.map +1 -0
- package/lib/packlets/ai-assist/apiClient.js +888 -156
- package/lib/packlets/ai-assist/apiClient.js.map +1 -0
- package/lib/packlets/ai-assist/chatRequestBuilders.d.ts +149 -0
- package/lib/packlets/ai-assist/chatRequestBuilders.d.ts.map +1 -0
- package/lib/packlets/ai-assist/chatRequestBuilders.js +293 -0
- package/lib/packlets/ai-assist/chatRequestBuilders.js.map +1 -0
- package/lib/packlets/ai-assist/converters.d.ts +15 -1
- package/lib/packlets/ai-assist/converters.d.ts.map +1 -0
- package/lib/packlets/ai-assist/converters.js +47 -3
- package/lib/packlets/ai-assist/converters.js.map +1 -0
- package/lib/packlets/ai-assist/embeddingClient.d.ts +69 -0
- package/lib/packlets/ai-assist/embeddingClient.d.ts.map +1 -0
- package/lib/packlets/ai-assist/embeddingClient.js +349 -0
- package/lib/packlets/ai-assist/embeddingClient.js.map +1 -0
- package/lib/packlets/ai-assist/endpoint.d.ts +28 -0
- package/lib/packlets/ai-assist/endpoint.d.ts.map +1 -0
- package/lib/packlets/ai-assist/endpoint.js +82 -0
- package/lib/packlets/ai-assist/endpoint.js.map +1 -0
- package/lib/packlets/ai-assist/http.d.ts +24 -0
- package/lib/packlets/ai-assist/http.d.ts.map +1 -0
- package/lib/packlets/ai-assist/http.js +78 -0
- package/lib/packlets/ai-assist/http.js.map +1 -0
- package/lib/packlets/ai-assist/imageOptionsResolver.d.ts +66 -0
- package/lib/packlets/ai-assist/imageOptionsResolver.d.ts.map +1 -0
- package/lib/packlets/ai-assist/imageOptionsResolver.js +197 -0
- package/lib/packlets/ai-assist/imageOptionsResolver.js.map +1 -0
- package/lib/packlets/ai-assist/index.d.ts +10 -4
- package/lib/packlets/ai-assist/index.d.ts.map +1 -0
- package/lib/packlets/ai-assist/index.js +36 -1
- package/lib/packlets/ai-assist/index.js.map +1 -0
- package/lib/packlets/ai-assist/jsonCompletion.d.ts +93 -0
- package/lib/packlets/ai-assist/jsonCompletion.d.ts.map +1 -0
- package/lib/packlets/ai-assist/jsonCompletion.js +97 -0
- package/lib/packlets/ai-assist/jsonCompletion.js.map +1 -0
- package/lib/packlets/ai-assist/jsonResponse.d.ts +91 -0
- package/lib/packlets/ai-assist/jsonResponse.d.ts.map +1 -0
- package/lib/packlets/ai-assist/jsonResponse.js +154 -0
- package/lib/packlets/ai-assist/jsonResponse.js.map +1 -0
- package/lib/packlets/ai-assist/model.d.ts +1202 -12
- package/lib/packlets/ai-assist/model.d.ts.map +1 -0
- package/lib/packlets/ai-assist/model.js +198 -10
- package/lib/packlets/ai-assist/model.js.map +1 -0
- package/lib/packlets/ai-assist/registry.d.ts +56 -1
- package/lib/packlets/ai-assist/registry.d.ts.map +1 -0
- package/lib/packlets/ai-assist/registry.js +319 -13
- package/lib/packlets/ai-assist/registry.js.map +1 -0
- package/lib/packlets/ai-assist/sseParser.d.ts +45 -0
- package/lib/packlets/ai-assist/sseParser.d.ts.map +1 -0
- package/lib/packlets/ai-assist/sseParser.js +128 -0
- package/lib/packlets/ai-assist/sseParser.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts +72 -0
- package/lib/packlets/ai-assist/streamingAdapters/anthropic.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/anthropic.js +371 -0
- package/lib/packlets/ai-assist/streamingAdapters/anthropic.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.d.ts +260 -0
- package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js +694 -0
- package/lib/packlets/ai-assist/streamingAdapters/clientToolContinuationBuilder.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/common.d.ts +154 -0
- package/lib/packlets/ai-assist/streamingAdapters/common.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/common.js +193 -0
- package/lib/packlets/ai-assist/streamingAdapters/common.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts +43 -0
- package/lib/packlets/ai-assist/streamingAdapters/gemini.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/gemini.js +207 -0
- package/lib/packlets/ai-assist/streamingAdapters/gemini.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiChat.d.ts +19 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiChat.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js +173 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiChat.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts +33 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js +389 -0
- package/lib/packlets/ai-assist/streamingAdapters/openaiResponses.js.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/proxy.d.ts +34 -0
- package/lib/packlets/ai-assist/streamingAdapters/proxy.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingAdapters/proxy.js +176 -0
- package/lib/packlets/ai-assist/streamingAdapters/proxy.js.map +1 -0
- package/lib/packlets/ai-assist/streamingClient.d.ts +50 -0
- package/lib/packlets/ai-assist/streamingClient.d.ts.map +1 -0
- package/lib/packlets/ai-assist/streamingClient.js +146 -0
- package/lib/packlets/ai-assist/streamingClient.js.map +1 -0
- package/lib/packlets/ai-assist/thinkingOptionsResolver.d.ts +87 -0
- package/lib/packlets/ai-assist/thinkingOptionsResolver.d.ts.map +1 -0
- package/lib/packlets/ai-assist/thinkingOptionsResolver.js +294 -0
- package/lib/packlets/ai-assist/thinkingOptionsResolver.js.map +1 -0
- package/lib/packlets/ai-assist/toolFormats.d.ts +40 -9
- package/lib/packlets/ai-assist/toolFormats.d.ts.map +1 -0
- package/lib/packlets/ai-assist/toolFormats.js +107 -10
- package/lib/packlets/ai-assist/toolFormats.js.map +1 -0
- package/lib/packlets/conversion/converters.d.ts +8 -1
- package/lib/packlets/conversion/converters.d.ts.map +1 -0
- package/lib/packlets/conversion/converters.js +36 -2
- package/lib/packlets/conversion/converters.js.map +1 -0
- package/lib/packlets/conversion/index.d.ts.map +1 -0
- package/lib/packlets/conversion/index.js.map +1 -0
- package/lib/packlets/crypto-utils/constants.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/constants.js.map +1 -0
- package/lib/packlets/crypto-utils/converters.d.ts +20 -1
- package/lib/packlets/crypto-utils/converters.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/converters.js +43 -5
- package/lib/packlets/crypto-utils/converters.js.map +1 -0
- package/lib/packlets/crypto-utils/directEncryptionProvider.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/directEncryptionProvider.js.map +1 -0
- package/lib/packlets/crypto-utils/encryptedFile.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/encryptedFile.js.map +1 -0
- package/lib/packlets/crypto-utils/hpkeProvider.d.ts +150 -0
- package/lib/packlets/crypto-utils/hpkeProvider.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/hpkeProvider.js +359 -0
- package/lib/packlets/crypto-utils/hpkeProvider.js.map +1 -0
- package/lib/packlets/crypto-utils/index.browser.d.ts +4 -1
- package/lib/packlets/crypto-utils/index.browser.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/index.browser.js +22 -3
- package/lib/packlets/crypto-utils/index.browser.js.map +1 -0
- package/lib/packlets/crypto-utils/index.d.ts +3 -0
- package/lib/packlets/crypto-utils/index.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/index.js +18 -1
- package/lib/packlets/crypto-utils/index.js.map +1 -0
- package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts +54 -0
- package/lib/packlets/crypto-utils/keyPairAlgorithmParams.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js +74 -0
- package/lib/packlets/crypto-utils/keyPairAlgorithmParams.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/converters.d.ts +68 -6
- package/lib/packlets/crypto-utils/keystore/converters.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/converters.js +103 -12
- package/lib/packlets/crypto-utils/keystore/converters.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.d.ts +148 -0
- package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js +324 -0
- package/lib/packlets/crypto-utils/keystore/encryptedFilePrivateKeyStorage.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/index.browser.d.ts +10 -0
- package/lib/packlets/crypto-utils/keystore/index.browser.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/index.browser.js +76 -0
- package/lib/packlets/crypto-utils/keystore/index.browser.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/index.d.ts +2 -0
- package/lib/packlets/crypto-utils/keystore/index.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/index.js +5 -1
- package/lib/packlets/crypto-utils/keystore/index.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/keyStore.d.ts +270 -13
- package/lib/packlets/crypto-utils/keystore/keyStore.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/keyStore.js +778 -124
- package/lib/packlets/crypto-utils/keystore/keyStore.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/model.d.ts +350 -21
- package/lib/packlets/crypto-utils/keystore/model.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/model.js +32 -5
- package/lib/packlets/crypto-utils/keystore/model.js.map +1 -0
- package/lib/packlets/crypto-utils/keystore/privateKeyStorage.d.ts +53 -0
- package/lib/packlets/crypto-utils/keystore/privateKeyStorage.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/keystore/privateKeyStorage.js +22 -0
- package/lib/packlets/crypto-utils/keystore/privateKeyStorage.js.map +1 -0
- package/lib/packlets/crypto-utils/model.d.ts +437 -10
- package/lib/packlets/crypto-utils/model.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/model.js +33 -1
- package/lib/packlets/crypto-utils/model.js.map +1 -0
- package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts +134 -2
- package/lib/packlets/crypto-utils/nodeCryptoProvider.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/nodeCryptoProvider.js +335 -0
- package/lib/packlets/crypto-utils/nodeCryptoProvider.js.map +1 -0
- package/lib/packlets/crypto-utils/spkiHelpers.d.ts +125 -0
- package/lib/packlets/crypto-utils/spkiHelpers.d.ts.map +1 -0
- package/lib/packlets/crypto-utils/spkiHelpers.js +251 -0
- package/lib/packlets/crypto-utils/spkiHelpers.js.map +1 -0
- package/lib/packlets/csv/csvFileHelpers.d.ts +0 -10
- package/lib/packlets/csv/csvFileHelpers.d.ts.map +1 -0
- package/lib/packlets/csv/csvFileHelpers.js +0 -15
- package/lib/packlets/csv/csvFileHelpers.js.map +1 -0
- package/lib/packlets/csv/csvHelpers.d.ts +10 -0
- package/lib/packlets/csv/csvHelpers.d.ts.map +1 -0
- package/lib/packlets/csv/csvHelpers.js +15 -0
- package/lib/packlets/csv/csvHelpers.js.map +1 -0
- package/lib/packlets/csv/index.browser.d.ts +0 -1
- package/lib/packlets/csv/index.browser.d.ts.map +1 -0
- package/lib/packlets/csv/index.browser.js +1 -5
- package/lib/packlets/csv/index.browser.js.map +1 -0
- package/lib/packlets/csv/index.d.ts.map +1 -0
- package/lib/packlets/csv/index.js.map +1 -0
- package/lib/packlets/experimental/extendedArray.d.ts.map +1 -0
- package/lib/packlets/experimental/extendedArray.js.map +1 -0
- package/lib/packlets/experimental/formatter.d.ts.map +1 -0
- package/lib/packlets/experimental/formatter.js.map +1 -0
- package/lib/packlets/experimental/index.d.ts.map +1 -0
- package/lib/packlets/experimental/index.js.map +1 -0
- package/lib/packlets/experimental/rangeOf.d.ts.map +1 -0
- package/lib/packlets/experimental/rangeOf.js.map +1 -0
- package/lib/packlets/hash/index.browser.d.ts.map +1 -0
- package/lib/packlets/hash/index.browser.js.map +1 -0
- package/lib/packlets/hash/index.d.ts.map +1 -0
- package/lib/packlets/hash/index.js.map +1 -0
- package/lib/packlets/hash/index.node.d.ts.map +1 -0
- package/lib/packlets/hash/index.node.js.map +1 -0
- package/lib/packlets/hash/md5Normalizer.browser.d.ts.map +1 -0
- package/lib/packlets/hash/md5Normalizer.browser.js.map +1 -0
- package/lib/packlets/hash/md5Normalizer.d.ts.map +1 -0
- package/lib/packlets/hash/md5Normalizer.js.map +1 -0
- package/lib/packlets/mustache/index.d.ts +1 -1
- package/lib/packlets/mustache/index.d.ts.map +1 -0
- package/lib/packlets/mustache/index.js.map +1 -0
- package/lib/packlets/mustache/interfaces.d.ts +34 -0
- package/lib/packlets/mustache/interfaces.d.ts.map +1 -0
- package/lib/packlets/mustache/interfaces.js.map +1 -0
- package/lib/packlets/mustache/mustacheTemplate.d.ts +2 -0
- package/lib/packlets/mustache/mustacheTemplate.d.ts.map +1 -0
- package/lib/packlets/mustache/mustacheTemplate.js +42 -4
- package/lib/packlets/mustache/mustacheTemplate.js.map +1 -0
- package/lib/packlets/record-jar/index.browser.d.ts +0 -1
- package/lib/packlets/record-jar/index.browser.d.ts.map +1 -0
- package/lib/packlets/record-jar/index.browser.js +1 -5
- package/lib/packlets/record-jar/index.browser.js.map +1 -0
- package/lib/packlets/record-jar/index.d.ts.map +1 -0
- package/lib/packlets/record-jar/index.js.map +1 -0
- package/lib/packlets/record-jar/recordJarFileHelpers.d.ts +0 -11
- package/lib/packlets/record-jar/recordJarFileHelpers.d.ts.map +1 -0
- package/lib/packlets/record-jar/recordJarFileHelpers.js +0 -19
- package/lib/packlets/record-jar/recordJarFileHelpers.js.map +1 -0
- package/lib/packlets/record-jar/recordJarHelpers.d.ts +11 -0
- package/lib/packlets/record-jar/recordJarHelpers.d.ts.map +1 -0
- package/lib/packlets/record-jar/recordJarHelpers.js +19 -0
- package/lib/packlets/record-jar/recordJarHelpers.js.map +1 -0
- package/lib/packlets/yaml/converters.d.ts.map +1 -0
- package/lib/packlets/yaml/converters.js.map +1 -0
- package/lib/packlets/yaml/index.d.ts +1 -0
- package/lib/packlets/yaml/index.d.ts.map +1 -0
- package/lib/packlets/yaml/index.js +1 -0
- package/lib/packlets/yaml/index.js.map +1 -0
- package/lib/packlets/yaml/serializers.d.ts +45 -0
- package/lib/packlets/yaml/serializers.d.ts.map +1 -0
- package/lib/packlets/yaml/serializers.js +84 -0
- package/lib/packlets/yaml/serializers.js.map +1 -0
- package/lib/packlets/zip-file-tree/index.d.ts.map +1 -0
- package/lib/packlets/zip-file-tree/index.js.map +1 -0
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts +2 -2
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.d.ts.map +1 -0
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js +2 -2
- package/lib/packlets/zip-file-tree/zipFileTreeAccessors.js.map +1 -0
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.d.ts.map +1 -0
- package/lib/packlets/zip-file-tree/zipFileTreeWriter.js.map +1 -0
- package/package.json +20 -15
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) 2026 Erik Fortune
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
// in the Software without restriction, including without limitation the rights
|
|
7
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
// furnished to do so, subject to the following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
// copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
// SOFTWARE.
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
//# sourceMappingURL=privateKeyStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privateKeyStorage.js","sourceRoot":"","sources":["../../../../src/packlets/crypto-utils/keystore/privateKeyStorage.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAC3D,EAAE;AACF,iFAAiF;AACjF,kDAAkD;AAClD,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY","sourcesContent":["// Copyright (c) 2026 Erik Fortune\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in all\n// copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n// SOFTWARE.\n\nimport { Result } from '@fgv/ts-utils';\n\n/**\n * Pluggable backend that persists raw asymmetric private keys outside of the\n * encrypted keystore vault. Concrete implementations:\n * - {@link CryptoUtils.KeyStore.EncryptedFilePrivateKeyStorage} in\n * `@fgv/ts-extras` — directory-on-disk, AES-256-GCM-encrypted JWK per key\n * (Node; `supportsNonExtractable: false`).\n * - `IdbPrivateKeyStorage` in `@fgv/ts-web-extras` — IndexedDB-backed, stores\n * `CryptoKey` objects directly (browser; `supportsNonExtractable: true`).\n *\n * The keystore writes storage-first: a private key is always stored here\n * before the corresponding public-key vault entry is committed. Conversely,\n * deletes hit the vault first and then this storage best-effort. As a result,\n * crashes or skipped saves can leave orphaned blobs here; callers are expected\n * to reconcile via {@link CryptoUtils.KeyStore.IPrivateKeyStorage.list} cross-referenced\n * against the keystore's asymmetric entries.\n *\n * @public\n */\nexport interface IPrivateKeyStorage {\n /**\n * Whether keys generated for this backend may be marked\n * `extractable: false`. `true` on backends that store `CryptoKey`\n * objects directly (e.g. IndexedDB). `false` on backends that must\n * round-trip via JWK (e.g. encrypted-file backends).\n */\n readonly supportsNonExtractable: boolean;\n\n /**\n * Stores `key` under `id`. Returns the stored `id` on success so the\n * call can compose into a Result chain.\n * @param id - Storage handle to write under.\n * @param key - The private `CryptoKey` to persist.\n */\n store(id: string, key: CryptoKey): Promise<Result<string>>;\n\n /**\n * Loads the private key previously stored under `id`.\n * @param id - Storage handle to look up.\n */\n load(id: string): Promise<Result<CryptoKey>>;\n\n /**\n * Deletes the entry stored under `id`. Returns the deleted `id` on\n * success so the call can compose into a Result chain.\n * @param id - Storage handle to remove.\n */\n delete(id: string): Promise<Result<string>>;\n\n /**\n * Lists every `id` currently held by the backend. Used by consumers to\n * garbage-collect orphans left by crashes or aborted sessions; the\n * keystore itself does not invoke this automatically.\n */\n list(): Promise<Result<readonly string[]>>;\n}\n"]}
|
|
@@ -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,213 @@ export interface IEncryptionResult {
|
|
|
45
55
|
readonly encryptedData: Uint8Array;
|
|
46
56
|
}
|
|
47
57
|
/**
|
|
48
|
-
*
|
|
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
|
|
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
|
-
*
|
|
54
|
-
*
|
|
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
|
+
* Caller-supplied HKDF parameters that domain-separate one
|
|
106
|
+
* {@link CryptoUtils.ICryptoProvider.wrapBytes | wrapBytes} call from another.
|
|
107
|
+
* Two wraps that share recipient but differ on `salt` or `info` derive distinct
|
|
108
|
+
* wrap keys, so callers should pick values that bind the wrap to its
|
|
109
|
+
* application context (e.g. a content hash for `salt` and a secret name for
|
|
110
|
+
* `info`).
|
|
111
|
+
*
|
|
112
|
+
* Both fields are required; pass an empty `Uint8Array` if the caller has no
|
|
113
|
+
* value to bind on a given axis. Silent defaulting would hide protocol
|
|
114
|
+
* mistakes, so the API does not pick defaults.
|
|
55
115
|
* @public
|
|
56
116
|
*/
|
|
57
|
-
export interface
|
|
117
|
+
export interface IWrapBytesOptions {
|
|
118
|
+
/**
|
|
119
|
+
* HKDF salt. Domain-separates this wrap from others in different contexts.
|
|
120
|
+
* Caller picks; common choices include a content hash, document id, channel
|
|
121
|
+
* id, etc.
|
|
122
|
+
*/
|
|
123
|
+
readonly salt: Uint8Array;
|
|
58
124
|
/**
|
|
59
|
-
*
|
|
125
|
+
* HKDF info. Further binds the derived key to a specific use within the
|
|
126
|
+
* calling application. Caller picks; common choices include a secret name,
|
|
127
|
+
* message type, or version tag.
|
|
60
128
|
*/
|
|
61
|
-
readonly
|
|
129
|
+
readonly info: Uint8Array;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Output of {@link CryptoUtils.ICryptoProvider.wrapBytes | wrapBytes}. The
|
|
133
|
+
* shape is JSON-serializable so it can travel directly over the wire or be
|
|
134
|
+
* persisted as-is.
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
export interface IWrappedBytes {
|
|
62
138
|
/**
|
|
63
|
-
*
|
|
139
|
+
* Sender's ephemeral ECDH P-256 public key as a JSON Web Key. The matching
|
|
140
|
+
* ephemeral private key is dropped after the shared-secret derive.
|
|
64
141
|
*/
|
|
142
|
+
readonly ephemeralPublicKey: JsonWebKey;
|
|
143
|
+
/**
|
|
144
|
+
* AES-GCM nonce, base64-encoded. 12 bytes (96 bits) — the standard AES-GCM
|
|
145
|
+
* nonce length.
|
|
146
|
+
*/
|
|
147
|
+
readonly nonce: string;
|
|
148
|
+
/**
|
|
149
|
+
* AES-GCM ciphertext concatenated with the 16-byte authentication tag,
|
|
150
|
+
* base64-encoded. Tampering with either the nonce or the ciphertext causes
|
|
151
|
+
* unwrap to fail GCM authentication.
|
|
152
|
+
*/
|
|
153
|
+
readonly ciphertext: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* All valid key pair algorithms.
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export declare const allKeyPairAlgorithms: ReadonlyArray<KeyPairAlgorithm>;
|
|
160
|
+
/**
|
|
161
|
+
* Supported key derivation functions.
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
export type KeyDerivationFunction = 'pbkdf2' | 'argon2id';
|
|
165
|
+
/**
|
|
166
|
+
* PBKDF2 key derivation parameters.
|
|
167
|
+
* @public
|
|
168
|
+
*/
|
|
169
|
+
export interface IPbkdf2KeyDerivationParams {
|
|
170
|
+
/** Key derivation function discriminator. */
|
|
171
|
+
readonly kdf: 'pbkdf2';
|
|
172
|
+
/** Base64-encoded salt used for key derivation. */
|
|
65
173
|
readonly salt: string;
|
|
174
|
+
/** Number of iterations used for key derivation. */
|
|
175
|
+
readonly iterations: number;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Argon2id key derivation parameters (RFC 9106).
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
export interface IArgon2idKeyDerivationParams {
|
|
182
|
+
/** Key derivation function discriminator. */
|
|
183
|
+
readonly kdf: 'argon2id';
|
|
184
|
+
/** Base64-encoded salt used for key derivation. */
|
|
185
|
+
readonly salt: string;
|
|
186
|
+
/** Memory cost in kibibytes. */
|
|
187
|
+
readonly memoryKiB: number;
|
|
188
|
+
/** Number of passes (time cost). */
|
|
189
|
+
readonly iterations: number;
|
|
190
|
+
/** Degree of parallelism. */
|
|
191
|
+
readonly parallelism: number;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Key derivation parameters stored in encrypted files.
|
|
195
|
+
* Discriminated union on `kdf` field: `'pbkdf2'` or `'argon2id'`.
|
|
196
|
+
* @public
|
|
197
|
+
*/
|
|
198
|
+
export type IKeyDerivationParams = IPbkdf2KeyDerivationParams | IArgon2idKeyDerivationParams;
|
|
199
|
+
/**
|
|
200
|
+
* Parameters for Argon2id key derivation (RFC 9106).
|
|
201
|
+
* All fields are required; fgv does not pick defaults silently.
|
|
202
|
+
* @public
|
|
203
|
+
*/
|
|
204
|
+
export interface IArgon2idParams {
|
|
66
205
|
/**
|
|
67
|
-
*
|
|
206
|
+
* Memory cost in kibibytes (KiB).
|
|
207
|
+
* OWASP 2023 minimum: 19456 (19 MiB). Stronger: 65536 (64 MiB).
|
|
208
|
+
* Constraint: \>= 8.
|
|
209
|
+
*/
|
|
210
|
+
readonly memoryKiB: number;
|
|
211
|
+
/**
|
|
212
|
+
* Number of passes (iterations / time cost).
|
|
213
|
+
* OWASP 2023 minimum: 2. Range: \>= 1.
|
|
68
214
|
*/
|
|
69
215
|
readonly iterations: number;
|
|
216
|
+
/**
|
|
217
|
+
* Degree of parallelism (threads).
|
|
218
|
+
* Note: WASM-based implementations compute sequentially regardless of this value,
|
|
219
|
+
* but the value is wired into the algorithm and AFFECTS the output hash bytes.
|
|
220
|
+
* Callers must use the same parallelism value consistently for a given secret.
|
|
221
|
+
* Range: 1–255.
|
|
222
|
+
*/
|
|
223
|
+
readonly parallelism: number;
|
|
224
|
+
/**
|
|
225
|
+
* Number of output bytes (hash length).
|
|
226
|
+
* Typical values: 16 (128-bit), 32 (256-bit, AES-256 key), 64 (512-bit).
|
|
227
|
+
* Constraint: \>= 4.
|
|
228
|
+
*/
|
|
229
|
+
readonly outputBytes: number;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Recommended OWASP 2023 minimum Argon2id parameters.
|
|
233
|
+
* Suitable for recovery-row key derivation (high-entropy inputs).
|
|
234
|
+
* @public
|
|
235
|
+
*/
|
|
236
|
+
export declare const ARGON2ID_OWASP_MIN: IArgon2idParams;
|
|
237
|
+
/**
|
|
238
|
+
* Stronger Argon2id parameters suitable for user-typed passphrases.
|
|
239
|
+
* @public
|
|
240
|
+
*/
|
|
241
|
+
export declare const ARGON2ID_PASSPHRASE: IArgon2idParams;
|
|
242
|
+
/**
|
|
243
|
+
* Argon2id key derivation provider (RFC 9106).
|
|
244
|
+
*
|
|
245
|
+
* Implementations are in separate packages to avoid WASM bundle costs for
|
|
246
|
+
* consumers who don't need Argon2id:
|
|
247
|
+
* - Node: `@fgv/ts-extras-argon2` (`NodeArgon2Provider`)
|
|
248
|
+
* - Browser: `@fgv/ts-web-extras-argon2` (`BrowserArgon2Provider`)
|
|
249
|
+
*
|
|
250
|
+
* @public
|
|
251
|
+
*/
|
|
252
|
+
export interface IArgon2idProvider {
|
|
253
|
+
/**
|
|
254
|
+
* Derives key material from a password using Argon2id (RFC 9106 §3.1).
|
|
255
|
+
*
|
|
256
|
+
* Returns the raw derived bytes as a `Uint8Array`. Both Node and browser
|
|
257
|
+
* implementations produce bit-identical output for identical inputs.
|
|
258
|
+
*
|
|
259
|
+
* @param password - Password or passphrase. Accepts string (UTF-8) or raw bytes.
|
|
260
|
+
* @param salt - Salt bytes. Must be random and unique per credential (\>= 16 bytes recommended).
|
|
261
|
+
* @param params - Argon2id parameters. Use `ARGON2ID_OWASP_MIN` as a starting point.
|
|
262
|
+
* @returns Success with derived bytes, Failure with error context.
|
|
263
|
+
*/
|
|
264
|
+
argon2id(password: Uint8Array | string, salt: Uint8Array, params: IArgon2idParams): Promise<Result<Uint8Array>>;
|
|
70
265
|
}
|
|
71
266
|
/**
|
|
72
267
|
* Generic encrypted file format.
|
|
@@ -132,6 +327,68 @@ export interface ICryptoProvider {
|
|
|
132
327
|
* @returns Success with decrypted UTF-8 string, or Failure with error
|
|
133
328
|
*/
|
|
134
329
|
decrypt(encryptedData: Uint8Array, key: Uint8Array, iv: Uint8Array, authTag: Uint8Array): Promise<Result<string>>;
|
|
330
|
+
/**
|
|
331
|
+
* Encrypts raw bytes using AES-256-GCM with a **caller-supplied nonce** and
|
|
332
|
+
* optional additional authenticated data (AAD).
|
|
333
|
+
*
|
|
334
|
+
* This is the raw-byte sibling of {@link CryptoUtils.ICryptoProvider.encrypt | encrypt}.
|
|
335
|
+
* Unlike `encrypt`, it takes and returns `Uint8Array` (no UTF-8 coding), the
|
|
336
|
+
* caller owns the nonce (rather than the provider generating one), and it
|
|
337
|
+
* binds optional `aad` into the GCM authentication. Use it when you need to
|
|
338
|
+
* bind context (e.g. an actor id, key version, or row kind) into the
|
|
339
|
+
* authentication so a wrapped secret cannot be replayed across
|
|
340
|
+
* users/versions/kinds, or when you manage nonces yourself.
|
|
341
|
+
*
|
|
342
|
+
* @remarks
|
|
343
|
+
* **⚠️ NONCE UNIQUENESS IS THE CALLER'S RESPONSIBILITY AND IS CRITICAL.**
|
|
344
|
+
* Because the caller supplies the nonce, this primitive cannot guarantee
|
|
345
|
+
* uniqueness. Reusing a `(key, nonce)` pair for two different messages is
|
|
346
|
+
* **catastrophic** for AES-GCM: it breaks confidentiality (the XOR of the two
|
|
347
|
+
* plaintexts leaks) AND authentication (the GCM authentication key can be
|
|
348
|
+
* recovered, letting an attacker forge tags for arbitrary messages under that
|
|
349
|
+
* key). The caller MUST use a unique nonce for every message encrypted under a
|
|
350
|
+
* given key — draw it from {@link CryptoUtils.ICryptoProvider.generateRandomBytes | generateRandomBytes(12)}
|
|
351
|
+
* (12 random bytes has negligible collision probability well within a single
|
|
352
|
+
* key's message budget) or from a strictly-increasing counter. Never hardcode
|
|
353
|
+
* a nonce and never reuse one.
|
|
354
|
+
*
|
|
355
|
+
* @param key - 32-byte AES-256 key. Wrong lengths fail with error context.
|
|
356
|
+
* @param nonce - 12-byte (96-bit) GCM nonce. MUST be unique per message under
|
|
357
|
+
* `key` (see the nonce-uniqueness warning above). Wrong lengths fail with
|
|
358
|
+
* error context.
|
|
359
|
+
* @param plaintext - The bytes to encrypt. Empty plaintext is permitted and
|
|
360
|
+
* round-trips (GCM produces a valid tag over zero-length plaintext).
|
|
361
|
+
* @param aad - Optional additional authenticated data bound into the GCM tag
|
|
362
|
+
* but NOT encrypted. If provided at encrypt time, the identical bytes must be
|
|
363
|
+
* supplied to `decryptBytes` or decryption fails authentication. Absent means
|
|
364
|
+
* no AAD.
|
|
365
|
+
* @returns `Success` with the {@link CryptoUtils.IEncryptBytesResult | ciphertext and 16-byte auth tag},
|
|
366
|
+
* or `Failure` with error context.
|
|
367
|
+
*/
|
|
368
|
+
encryptBytes(key: Uint8Array, nonce: Uint8Array, plaintext: Uint8Array, aad?: Uint8Array): Promise<Result<IEncryptBytesResult>>;
|
|
369
|
+
/**
|
|
370
|
+
* Decrypts raw bytes produced by
|
|
371
|
+
* {@link CryptoUtils.ICryptoProvider.encryptBytes | encryptBytes} using
|
|
372
|
+
* AES-256-GCM. The inverse of `encryptBytes`: the `ciphertext` and `authTag`
|
|
373
|
+
* from an `encryptBytes` result, together with the same `key`, `nonce`, and
|
|
374
|
+
* `aad`, recover the original plaintext.
|
|
375
|
+
*
|
|
376
|
+
* Fails (never throws) on any authentication failure: a tampered ciphertext
|
|
377
|
+
* or tag, the wrong key or nonce, or an `aad` that differs from the one used
|
|
378
|
+
* at encrypt time. AES-GCM authentication is fail-closed — a mismatched `aad`
|
|
379
|
+
* fails exactly as a tampered ciphertext does.
|
|
380
|
+
*
|
|
381
|
+
* @param key - 32-byte AES-256 key (the same key used to encrypt).
|
|
382
|
+
* @param nonce - 12-byte (96-bit) GCM nonce (the same nonce used to encrypt).
|
|
383
|
+
* @param ciphertext - The ciphertext from the `encryptBytes` result.
|
|
384
|
+
* @param authTag - The 16-byte (128-bit) GCM authentication tag from the
|
|
385
|
+
* `encryptBytes` result.
|
|
386
|
+
* @param aad - The identical additional authenticated data supplied at encrypt
|
|
387
|
+
* time (or absent if none was supplied). A mismatch fails authentication.
|
|
388
|
+
* @returns `Success` with the decrypted plaintext bytes, or `Failure` with
|
|
389
|
+
* error context (including all authentication failures).
|
|
390
|
+
*/
|
|
391
|
+
decryptBytes(key: Uint8Array, nonce: Uint8Array, ciphertext: Uint8Array, authTag: Uint8Array, aad?: Uint8Array): Promise<Result<Uint8Array>>;
|
|
135
392
|
/**
|
|
136
393
|
* Generates a random 32-byte key suitable for AES-256.
|
|
137
394
|
* @returns Success with generated key, or Failure with error
|
|
@@ -145,12 +402,27 @@ export interface ICryptoProvider {
|
|
|
145
402
|
* @returns Success with derived 32-byte key, or Failure with error
|
|
146
403
|
*/
|
|
147
404
|
deriveKey(password: string, salt: Uint8Array, iterations: number): Promise<Result<Uint8Array>>;
|
|
405
|
+
/**
|
|
406
|
+
* Computes a SHA-256 hash of the given data.
|
|
407
|
+
* @param data - UTF-8 string to hash
|
|
408
|
+
* @returns Success with hex-encoded hash string, or Failure with error
|
|
409
|
+
*/
|
|
410
|
+
sha256(data: string): Promise<Result<string>>;
|
|
148
411
|
/**
|
|
149
412
|
* Generates cryptographically secure random bytes.
|
|
150
413
|
* @param length - Number of bytes to generate
|
|
151
414
|
* @returns Success with random bytes, or Failure with error
|
|
152
415
|
*/
|
|
153
416
|
generateRandomBytes(length: number): Result<Uint8Array>;
|
|
417
|
+
/**
|
|
418
|
+
* Generates a cryptographically random UUIDv4 using the provider's
|
|
419
|
+
* underlying source of randomness. The default Node and browser
|
|
420
|
+
* implementations delegate to `globalThis.crypto.randomUUID`;
|
|
421
|
+
* deterministic providers (e.g. test stubs) may override to produce
|
|
422
|
+
* reproducible values.
|
|
423
|
+
* @returns Success with a canonical UUID, or Failure with error.
|
|
424
|
+
*/
|
|
425
|
+
generateUuid(): Result<Uuid>;
|
|
154
426
|
/**
|
|
155
427
|
* Encodes binary data to base64 string.
|
|
156
428
|
* @param data - Binary data to encode
|
|
@@ -163,6 +435,161 @@ export interface ICryptoProvider {
|
|
|
163
435
|
* @returns Success with decoded bytes, or Failure if invalid base64
|
|
164
436
|
*/
|
|
165
437
|
fromBase64(base64: string): Result<Uint8Array>;
|
|
438
|
+
/**
|
|
439
|
+
* Generates a new asymmetric keypair for the requested algorithm.
|
|
440
|
+
* @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} to use.
|
|
441
|
+
* @param extractable - Whether the resulting `CryptoKey` objects may be exported.
|
|
442
|
+
* Set `false` on backends that store `CryptoKey` references directly (e.g.
|
|
443
|
+
* IndexedDB). Set `true` when the private key must round-trip through JWK or
|
|
444
|
+
* PKCS#8 (e.g. encrypted-file backends).
|
|
445
|
+
* @returns Success with the generated `CryptoKeyPair`, or Failure with error context.
|
|
446
|
+
*/
|
|
447
|
+
generateKeyPair(algorithm: KeyPairAlgorithm, extractable: boolean): Promise<Result<CryptoKeyPair>>;
|
|
448
|
+
/**
|
|
449
|
+
* Exports the public half of a keypair as a JSON Web Key.
|
|
450
|
+
* @param publicKey - The public `CryptoKey` to export. Must be an `extractable`
|
|
451
|
+
* key generated for an asymmetric algorithm.
|
|
452
|
+
* @returns Success with the JWK, or Failure with error context.
|
|
453
|
+
*/
|
|
454
|
+
exportPublicKeyJwk(publicKey: CryptoKey): Promise<Result<JsonWebKey>>;
|
|
455
|
+
/**
|
|
456
|
+
* Re-imports a public-key JWK as a `CryptoKey` usable for verification or
|
|
457
|
+
* encryption (depending on algorithm).
|
|
458
|
+
* @param jwk - The JSON Web Key produced by {@link CryptoUtils.ICryptoProvider.exportPublicKeyJwk | exportPublicKeyJwk}.
|
|
459
|
+
* @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} the
|
|
460
|
+
* key was generated for. Determines the import parameters and key usages.
|
|
461
|
+
* @returns Success with the imported public `CryptoKey`, or Failure with error context.
|
|
462
|
+
*/
|
|
463
|
+
importPublicKeyJwk(jwk: JsonWebKey, algorithm: KeyPairAlgorithm): Promise<Result<CryptoKey>>;
|
|
464
|
+
/**
|
|
465
|
+
* Exports a public `CryptoKey` as a DER-encoded SPKI (SubjectPublicKeyInfo) blob.
|
|
466
|
+
* SPKI is the standard algorithm-agnostic format for public key storage and transport.
|
|
467
|
+
* @param publicKey - The `CryptoKey` to export. Must have `key.type === 'public'`.
|
|
468
|
+
* @returns `Success` with the raw SPKI bytes, or `Failure` with error context.
|
|
469
|
+
*/
|
|
470
|
+
exportPublicKeySpki(publicKey: CryptoKey): Promise<Result<Uint8Array>>;
|
|
471
|
+
/**
|
|
472
|
+
* Imports a public key from a DER-encoded SPKI blob.
|
|
473
|
+
* @param spkiBytes - The raw SPKI bytes produced by {@link CryptoUtils.ICryptoProvider.exportPublicKeySpki | exportPublicKeySpki}.
|
|
474
|
+
* @param algorithm - The {@link CryptoUtils.KeyPairAlgorithm | algorithm} the key was generated for.
|
|
475
|
+
* @returns `Success` with the imported public `CryptoKey`, or `Failure` with error context.
|
|
476
|
+
*/
|
|
477
|
+
importPublicKeySpki(spkiBytes: Uint8Array, algorithm: KeyPairAlgorithm): Promise<Result<CryptoKey>>;
|
|
478
|
+
/**
|
|
479
|
+
* Wraps `plaintext` for delivery to the holder of the private key paired
|
|
480
|
+
* with `recipientPublicKey`. Uses ECIES with ECDH P-256, HKDF-SHA256, and
|
|
481
|
+
* AES-GCM-256.
|
|
482
|
+
*
|
|
483
|
+
* Generates a fresh ephemeral keypair per call; the ephemeral private key
|
|
484
|
+
* is discarded after the shared-secret derive. Only the recipient (with the
|
|
485
|
+
* matching private key) and the same HKDF parameters can recover
|
|
486
|
+
* `plaintext`.
|
|
487
|
+
*
|
|
488
|
+
* Empty `plaintext` is permitted; the resulting wrap contains only the
|
|
489
|
+
* 16-byte GCM authentication tag and round-trips back to an empty
|
|
490
|
+
* `Uint8Array`.
|
|
491
|
+
* @param plaintext - The bytes to wrap. Any length supported by AES-GCM
|
|
492
|
+
* (in practice, well below 2^39 - 256 bits).
|
|
493
|
+
* @param recipientPublicKey - The recipient's ECDH P-256 public `CryptoKey`.
|
|
494
|
+
* Must have algorithm name `'ECDH'` and named curve `'P-256'`; mismatched
|
|
495
|
+
* algorithm or curve yields a `Failure` with error context.
|
|
496
|
+
* @param options - HKDF parameters; see {@link CryptoUtils.IWrapBytesOptions | IWrapBytesOptions}.
|
|
497
|
+
* @returns `Success` with the wrapped payload, or `Failure` with error context.
|
|
498
|
+
*/
|
|
499
|
+
wrapBytes(plaintext: Uint8Array, recipientPublicKey: CryptoKey, options: IWrapBytesOptions): Promise<Result<IWrappedBytes>>;
|
|
500
|
+
/**
|
|
501
|
+
* Inverse of {@link CryptoUtils.ICryptoProvider.wrapBytes | wrapBytes}.
|
|
502
|
+
* Recovers the original `plaintext` from a wrapped payload using the
|
|
503
|
+
* recipient's private key.
|
|
504
|
+
*
|
|
505
|
+
* Returns a `Failure` (never throws) on any of:
|
|
506
|
+
* - Tampered nonce or ciphertext (AES-GCM authentication fails)
|
|
507
|
+
* - Wrong private key (different shared secret derives a different wrap key)
|
|
508
|
+
* - Wrong HKDF parameters (different wrap key)
|
|
509
|
+
* - Malformed `ephemeralPublicKey` JWK
|
|
510
|
+
* - Malformed base64 in `nonce` or `ciphertext`
|
|
511
|
+
* @param wrapped - The wrapped payload produced by `wrapBytes`.
|
|
512
|
+
* @param recipientPrivateKey - The recipient's ECDH P-256 private
|
|
513
|
+
* `CryptoKey`. Must have algorithm name `'ECDH'` and named curve `'P-256'`,
|
|
514
|
+
* and key usages including `'deriveKey'` or `'deriveBits'`.
|
|
515
|
+
* @param options - The same HKDF parameters used at wrap time.
|
|
516
|
+
* @returns `Success` with the original `plaintext`, or `Failure` with error context.
|
|
517
|
+
*/
|
|
518
|
+
unwrapBytes(wrapped: IWrappedBytes, recipientPrivateKey: CryptoKey, options: IWrapBytesOptions): Promise<Result<Uint8Array>>;
|
|
519
|
+
/**
|
|
520
|
+
* Signs `data` with `privateKey` using the algorithm inferred from the key.
|
|
521
|
+
* Delegates to `crypto.subtle.sign`; the algorithm is derived from
|
|
522
|
+
* `privateKey.algorithm.name` — ECDSA keys are augmented with
|
|
523
|
+
* `hash: 'SHA-256'` at sign time (the hash is not stored in the key);
|
|
524
|
+
* all other algorithm names are passed through as-is.
|
|
525
|
+
* Intended for Ed25519 and ECDSA-P256 asymmetric private keys; for
|
|
526
|
+
* HMAC-SHA256 authentication codes use {@link ICryptoProvider.hmacSha256} instead.
|
|
527
|
+
* @param privateKey - A `CryptoKey` with `'sign'` usage (e.g. generated by
|
|
528
|
+
* {@link CryptoUtils.ICryptoProvider.generateKeyPair | generateKeyPair} with
|
|
529
|
+
* `'ecdsa-p256'` or `'ed25519'`).
|
|
530
|
+
* @param data - The bytes to sign.
|
|
531
|
+
* @returns `Success` with the raw signature bytes, or `Failure` with error context.
|
|
532
|
+
*/
|
|
533
|
+
sign(privateKey: CryptoKey, data: Uint8Array): Promise<Result<Uint8Array>>;
|
|
534
|
+
/**
|
|
535
|
+
* Verifies a signature produced by {@link ICryptoProvider.sign}.
|
|
536
|
+
* Delegates to `crypto.subtle.verify`; the algorithm is derived from
|
|
537
|
+
* `publicKey.algorithm.name` — ECDSA keys are augmented with
|
|
538
|
+
* `hash: 'SHA-256'`; all other algorithm names are passed through as-is.
|
|
539
|
+
* Intended for Ed25519 and ECDSA-P256 asymmetric public keys; for
|
|
540
|
+
* HMAC-SHA256 verification use {@link ICryptoProvider.verifyHmacSha256} instead.
|
|
541
|
+
* @param publicKey - A `CryptoKey` with `'verify'` usage (e.g. the public
|
|
542
|
+
* half of a keypair generated by
|
|
543
|
+
* {@link CryptoUtils.ICryptoProvider.generateKeyPair | generateKeyPair} with
|
|
544
|
+
* `'ecdsa-p256'` or `'ed25519'`).
|
|
545
|
+
* @param signature - The raw signature bytes produced by `sign`.
|
|
546
|
+
* @param data - The original data that was signed.
|
|
547
|
+
* @returns `Success` with `true` if the signature is valid, `false` if it is
|
|
548
|
+
* not, or `Failure` with error context if the operation itself failed.
|
|
549
|
+
*/
|
|
550
|
+
verify(publicKey: CryptoKey, signature: Uint8Array, data: Uint8Array): Promise<Result<boolean>>;
|
|
551
|
+
/**
|
|
552
|
+
* Compares two byte arrays in constant time.
|
|
553
|
+
*
|
|
554
|
+
* The comparison visits all bytes of `a` and `b` regardless of where they
|
|
555
|
+
* diverge, accumulating XOR differences with bitwise-OR. No early-return is
|
|
556
|
+
* possible once the length check passes, making timing independent of the
|
|
557
|
+
* byte values. This prevents timing side-channels when comparing MAC outputs,
|
|
558
|
+
* signed-token bytes, or any secret-derived byte sequences.
|
|
559
|
+
*
|
|
560
|
+
* Returns `false` immediately (before the loop) when `a.length !== b.length`;
|
|
561
|
+
* the length mismatch itself is not secret in normal use.
|
|
562
|
+
* @param a - First byte array.
|
|
563
|
+
* @param b - Second byte array.
|
|
564
|
+
* @returns `true` if the arrays have the same length and identical contents,
|
|
565
|
+
* `false` otherwise.
|
|
566
|
+
*/
|
|
567
|
+
timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
568
|
+
/**
|
|
569
|
+
* Computes an HMAC-SHA256 authentication code for `data` using `key`.
|
|
570
|
+
*
|
|
571
|
+
* The key must be a `CryptoKey` with `'sign'` usage and algorithm name
|
|
572
|
+
* `'HMAC'` (e.g. derived via PBKDF2 or imported with
|
|
573
|
+
* `crypto.subtle.importKey`). Use {@link ICryptoProvider.verifyHmacSha256}
|
|
574
|
+
* for constant-time verification of the output.
|
|
575
|
+
* @param key - An HMAC `CryptoKey` with `'sign'` usage.
|
|
576
|
+
* @param data - The bytes to authenticate.
|
|
577
|
+
* @returns `Success` with the 32-byte MAC, or `Failure` with error context.
|
|
578
|
+
*/
|
|
579
|
+
hmacSha256(key: CryptoKey, data: Uint8Array): Promise<Result<Uint8Array>>;
|
|
580
|
+
/**
|
|
581
|
+
* Verifies an HMAC-SHA256 authentication code in constant time.
|
|
582
|
+
*
|
|
583
|
+
* Computes the expected MAC over `data` with `key`, then compares it to
|
|
584
|
+
* `signature` using {@link ICryptoProvider.timingSafeEqual} so that
|
|
585
|
+
* mismatches do not leak information through timing.
|
|
586
|
+
* @param key - An HMAC `CryptoKey` with `'sign'` usage.
|
|
587
|
+
* @param signature - The MAC bytes to verify (typically 32 bytes).
|
|
588
|
+
* @param data - The original data that was authenticated.
|
|
589
|
+
* @returns `Success` with `true` if the MAC is valid, `false` if it is not,
|
|
590
|
+
* or `Failure` with error context if the MAC computation itself failed.
|
|
591
|
+
*/
|
|
592
|
+
verifyHmacSha256(key: CryptoKey, signature: Uint8Array, data: Uint8Array): Promise<Result<boolean>>;
|
|
166
593
|
}
|
|
167
594
|
/**
|
|
168
595
|
* High-level interface for encrypting JSON content by secret name.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/packlets/crypto-utils/model.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,CAAC;AAMrB;;;;;;;;GAQG;AACH,MAAM,MAAM,sBAAsB,GAAG,KAAK,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;AAM7E;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,SAAS,CAAC,iBA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AE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;CACrG;AAMD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;;OAOG;IACH,aAAa,CAAC,SAAS,GAAG,SAAS,EACjC,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,SAAS,EAClB,QAAQ,CAAC,EAAE,SAAS,GACnB,OAAO,CAAC,MAAM,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
|
// ============================================================================
|