@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
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import { EncryptionAlgorithm, ICryptoProvider, IKeyDerivationParams } from '../model';
|
|
1
|
+
import { EncryptionAlgorithm, ICryptoProvider, IArgon2idParams, IKeyDerivationParams, IPbkdf2KeyDerivationParams, KeyPairAlgorithm } from '../model';
|
|
2
|
+
import { IPrivateKeyStorage } from './privateKeyStorage';
|
|
3
|
+
export { allKeyPairAlgorithms, KeyPairAlgorithm } from '../model';
|
|
2
4
|
/**
|
|
3
5
|
* Format version for key store files.
|
|
6
|
+
*
|
|
7
|
+
* - `'keystore-v1'`: the original format (no private-key escrow).
|
|
8
|
+
* - `'keystore-v2'`: adds the optional `escrowedPrivateKeyJwk` field on
|
|
9
|
+
* asymmetric-keypair entries. A strict superset of v1 — the field is
|
|
10
|
+
* optional, so a v2 reader opens a v1 vault with no special-casing, and a
|
|
11
|
+
* v1 vault opened and re-saved is silently upgraded to v2.
|
|
4
12
|
* @public
|
|
5
13
|
*/
|
|
6
|
-
export type KeyStoreFormat = 'keystore-v1';
|
|
14
|
+
export type KeyStoreFormat = 'keystore-v1' | 'keystore-v2';
|
|
7
15
|
/**
|
|
8
|
-
*
|
|
16
|
+
* All recognized key store format versions (readable by the current library).
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare const allKeyStoreFormats: ReadonlyArray<KeyStoreFormat>;
|
|
20
|
+
/**
|
|
21
|
+
* Current format version constant. New vaults are written as `'keystore-v2'`.
|
|
9
22
|
* @public
|
|
10
23
|
*/
|
|
11
24
|
export declare const KEYSTORE_FORMAT: KeyStoreFormat;
|
|
@@ -21,31 +34,55 @@ export declare const DEFAULT_KEYSTORE_ITERATIONS: number;
|
|
|
21
34
|
*/
|
|
22
35
|
export declare const MIN_SALT_LENGTH: number;
|
|
23
36
|
/**
|
|
24
|
-
* Discriminator for secret types stored in the vault.
|
|
37
|
+
* Discriminator for symmetric secret types stored in the vault.
|
|
25
38
|
* - `'encryption-key'`: A 32-byte AES-256 encryption key.
|
|
26
39
|
* - `'api-key'`: An arbitrary-length API key string (UTF-8 encoded).
|
|
27
40
|
* @public
|
|
28
41
|
*/
|
|
29
|
-
export type
|
|
42
|
+
export type KeyStoreSymmetricSecretType = 'encryption-key' | 'api-key';
|
|
43
|
+
/**
|
|
44
|
+
* All valid symmetric secret types.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare const allKeyStoreSymmetricSecretTypes: ReadonlyArray<KeyStoreSymmetricSecretType>;
|
|
48
|
+
/**
|
|
49
|
+
* Discriminator for asymmetric secret types stored in the vault.
|
|
50
|
+
* - `'asymmetric-keypair'`: A public/private key pair. The public key is held in
|
|
51
|
+
* the vault as a JWK; the private key lives in the supplied
|
|
52
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage} provider.
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
export type KeyStoreAsymmetricSecretType = 'asymmetric-keypair';
|
|
56
|
+
/**
|
|
57
|
+
* All valid asymmetric secret types.
|
|
58
|
+
* @public
|
|
59
|
+
*/
|
|
60
|
+
export declare const allKeyStoreAsymmetricSecretTypes: ReadonlyArray<KeyStoreAsymmetricSecretType>;
|
|
61
|
+
/**
|
|
62
|
+
* Discriminator for any secret type stored in the vault.
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
export type KeyStoreSecretType = KeyStoreSymmetricSecretType | KeyStoreAsymmetricSecretType;
|
|
30
66
|
/**
|
|
31
67
|
* All valid key store secret types.
|
|
32
68
|
* @public
|
|
33
69
|
*/
|
|
34
70
|
export declare const allKeyStoreSecretTypes: ReadonlyArray<KeyStoreSecretType>;
|
|
35
71
|
/**
|
|
36
|
-
* A secret entry stored in the vault (in-memory representation).
|
|
72
|
+
* A symmetric secret entry stored in the vault (in-memory representation).
|
|
73
|
+
* Holds the raw key material directly — for `'encryption-key'` it is a 32-byte
|
|
74
|
+
* AES-256 key; for `'api-key'` it is the UTF-8 encoded API key string.
|
|
37
75
|
* @public
|
|
38
76
|
*/
|
|
39
|
-
export interface
|
|
77
|
+
export interface IKeyStoreSymmetricEntry {
|
|
40
78
|
/**
|
|
41
79
|
* Unique name for this secret (used as lookup key).
|
|
42
80
|
*/
|
|
43
81
|
readonly name: string;
|
|
44
82
|
/**
|
|
45
|
-
*
|
|
46
|
-
* Defaults to `'encryption-key'` for backwards compatibility.
|
|
83
|
+
* Symmetric secret type discriminator.
|
|
47
84
|
*/
|
|
48
|
-
readonly type:
|
|
85
|
+
readonly type: KeyStoreSymmetricSecretType;
|
|
49
86
|
/**
|
|
50
87
|
* The secret data.
|
|
51
88
|
* - For `'encryption-key'`: 32-byte AES-256 key.
|
|
@@ -62,19 +99,98 @@ export interface IKeyStoreSecretEntry {
|
|
|
62
99
|
readonly createdAt: string;
|
|
63
100
|
}
|
|
64
101
|
/**
|
|
65
|
-
*
|
|
102
|
+
* An asymmetric keypair entry stored in the vault (in-memory representation).
|
|
103
|
+
* Holds only the public key (as a JWK) and a stable handle (`id`) the
|
|
104
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage} provider uses to fetch the private key.
|
|
66
105
|
* @public
|
|
67
106
|
*/
|
|
68
|
-
export interface
|
|
107
|
+
export interface IKeyStoreAsymmetricEntry {
|
|
108
|
+
/**
|
|
109
|
+
* Unique name for this entry (used as vault lookup key, renameable).
|
|
110
|
+
*/
|
|
111
|
+
readonly name: string;
|
|
112
|
+
/**
|
|
113
|
+
* Asymmetric secret type discriminator.
|
|
114
|
+
*/
|
|
115
|
+
readonly type: KeyStoreAsymmetricSecretType;
|
|
116
|
+
/**
|
|
117
|
+
* Immutable handle used by {@link CryptoUtils.KeyStore.IPrivateKeyStorage} to address the
|
|
118
|
+
* private key. Independent of `name`; survives renames.
|
|
119
|
+
*/
|
|
120
|
+
readonly id: string;
|
|
121
|
+
/**
|
|
122
|
+
* Algorithm used to generate this keypair.
|
|
123
|
+
*/
|
|
124
|
+
readonly algorithm: KeyPairAlgorithm;
|
|
125
|
+
/**
|
|
126
|
+
* The public key as a JSON Web Key.
|
|
127
|
+
*/
|
|
128
|
+
readonly publicKeyJwk: JsonWebKey;
|
|
129
|
+
/**
|
|
130
|
+
* Optional escrowed copy of the private key, as a JSON Web Key. Present only
|
|
131
|
+
* when the entry was created with `addKeyPair(name, { escrow: true })`.
|
|
132
|
+
*
|
|
133
|
+
* This is an opt-in cross-device recovery affordance: the private key is
|
|
134
|
+
* carried inside the vault's AES-GCM ciphertext (same custody class as
|
|
135
|
+
* `publicKeyJwk`), so a recovered vault plus the master password can
|
|
136
|
+
* reconstitute the signing/decryption identity on a fresh device via
|
|
137
|
+
* `getKeyPair(name, { rehydrate: true })`.
|
|
138
|
+
*
|
|
139
|
+
* SECURITY: when present, the master password becomes the sole gate
|
|
140
|
+
* protecting this private key. Use a strong KDF for escrow-bearing stores.
|
|
141
|
+
* See the {@link CryptoUtils.KeyStore.KeyStore} class docs.
|
|
142
|
+
*/
|
|
143
|
+
readonly escrowedPrivateKeyJwk?: JsonWebKey;
|
|
144
|
+
/**
|
|
145
|
+
* Optional description for this entry.
|
|
146
|
+
*/
|
|
147
|
+
readonly description?: string;
|
|
148
|
+
/**
|
|
149
|
+
* When this entry was added (ISO 8601).
|
|
150
|
+
*/
|
|
151
|
+
readonly createdAt: string;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Any vault entry, discriminated by `type`.
|
|
155
|
+
* @public
|
|
156
|
+
*/
|
|
157
|
+
export type IKeyStoreEntry = IKeyStoreSymmetricEntry | IKeyStoreAsymmetricEntry;
|
|
158
|
+
/**
|
|
159
|
+
* Backwards-compatible alias for {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntry}.
|
|
160
|
+
* @deprecated Use {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntry} for symmetric
|
|
161
|
+
* entries or {@link CryptoUtils.KeyStore.IKeyStoreEntry} for the discriminated union.
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
export type IKeyStoreSecretEntry = IKeyStoreSymmetricEntry;
|
|
165
|
+
/**
|
|
166
|
+
* JSON-serializable representation of a symmetric secret entry.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* Describes the *normalized* shape after parsing. `type` is required here
|
|
170
|
+
* because the converter (see
|
|
171
|
+
* {@link CryptoUtils.KeyStore.Converters.keystoreSymmetricEntryJson | keystoreSymmetricEntryJson})
|
|
172
|
+
* injects the default `'encryption-key'` when reading vaults written before
|
|
173
|
+
* asymmetric-keypair support added the discriminator. Raw on-wire bytes from
|
|
174
|
+
* a legacy vault may therefore omit `type`; downstream code only ever sees
|
|
175
|
+
* the post-conversion shape declared here.
|
|
176
|
+
*
|
|
177
|
+
* @public
|
|
178
|
+
*/
|
|
179
|
+
export interface IKeyStoreSymmetricEntryJson {
|
|
69
180
|
/**
|
|
70
181
|
* Unique name for this secret.
|
|
71
182
|
*/
|
|
72
183
|
readonly name: string;
|
|
73
184
|
/**
|
|
74
|
-
*
|
|
75
|
-
*
|
|
185
|
+
* Symmetric secret type discriminator.
|
|
186
|
+
*
|
|
187
|
+
* Required on this normalized model type. Vaults written prior to the
|
|
188
|
+
* asymmetric-keypair support may omit this field on the wire; the
|
|
189
|
+
* converter injects `'encryption-key'` when missing for backwards
|
|
190
|
+
* compatibility, so by the time a value of this type is observed the
|
|
191
|
+
* discriminator is always present.
|
|
76
192
|
*/
|
|
77
|
-
readonly type
|
|
193
|
+
readonly type: KeyStoreSymmetricSecretType;
|
|
78
194
|
/**
|
|
79
195
|
* Base64-encoded secret data.
|
|
80
196
|
*/
|
|
@@ -89,7 +205,63 @@ export interface IKeyStoreSecretEntryJson {
|
|
|
89
205
|
readonly createdAt: string;
|
|
90
206
|
}
|
|
91
207
|
/**
|
|
92
|
-
*
|
|
208
|
+
* JSON-serializable representation of an asymmetric keypair entry.
|
|
209
|
+
* The private key is not present here — it lives in the
|
|
210
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage} provider, addressed by `id`.
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
213
|
+
export interface IKeyStoreAsymmetricEntryJson {
|
|
214
|
+
/**
|
|
215
|
+
* Unique name for this entry.
|
|
216
|
+
*/
|
|
217
|
+
readonly name: string;
|
|
218
|
+
/**
|
|
219
|
+
* Asymmetric secret type discriminator.
|
|
220
|
+
*/
|
|
221
|
+
readonly type: KeyStoreAsymmetricSecretType;
|
|
222
|
+
/**
|
|
223
|
+
* Immutable handle used by {@link CryptoUtils.KeyStore.IPrivateKeyStorage} to address the
|
|
224
|
+
* private key.
|
|
225
|
+
*/
|
|
226
|
+
readonly id: string;
|
|
227
|
+
/**
|
|
228
|
+
* Algorithm used to generate this keypair.
|
|
229
|
+
*/
|
|
230
|
+
readonly algorithm: KeyPairAlgorithm;
|
|
231
|
+
/**
|
|
232
|
+
* The public key as a JSON Web Key.
|
|
233
|
+
*/
|
|
234
|
+
readonly publicKeyJwk: JsonWebKey;
|
|
235
|
+
/**
|
|
236
|
+
* Optional escrowed copy of the private key, as a JSON Web Key. Present only
|
|
237
|
+
* on `'keystore-v2'` vaults whose entry was created with escrow enabled. A
|
|
238
|
+
* v1 vault omits the field; a v2 reader treats its absence as "no escrow".
|
|
239
|
+
*/
|
|
240
|
+
readonly escrowedPrivateKeyJwk?: JsonWebKey;
|
|
241
|
+
/**
|
|
242
|
+
* Optional description.
|
|
243
|
+
*/
|
|
244
|
+
readonly description?: string;
|
|
245
|
+
/**
|
|
246
|
+
* When this entry was added (ISO 8601).
|
|
247
|
+
*/
|
|
248
|
+
readonly createdAt: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Any JSON vault entry, discriminated by `type`.
|
|
252
|
+
* @public
|
|
253
|
+
*/
|
|
254
|
+
export type IKeyStoreEntryJson = IKeyStoreSymmetricEntryJson | IKeyStoreAsymmetricEntryJson;
|
|
255
|
+
/**
|
|
256
|
+
* Backwards-compatible alias for {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntryJson}.
|
|
257
|
+
* @deprecated Use {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntryJson} for
|
|
258
|
+
* symmetric entries or {@link CryptoUtils.KeyStore.IKeyStoreEntryJson} for the
|
|
259
|
+
* discriminated union.
|
|
260
|
+
* @public
|
|
261
|
+
*/
|
|
262
|
+
export type IKeyStoreSecretEntryJson = IKeyStoreSymmetricEntryJson;
|
|
263
|
+
/**
|
|
264
|
+
* The decrypted vault contents - a versioned map of entries.
|
|
93
265
|
* @public
|
|
94
266
|
*/
|
|
95
267
|
export interface IKeyStoreVaultContents {
|
|
@@ -98,9 +270,9 @@ export interface IKeyStoreVaultContents {
|
|
|
98
270
|
*/
|
|
99
271
|
readonly version: KeyStoreFormat;
|
|
100
272
|
/**
|
|
101
|
-
* Map of
|
|
273
|
+
* Map of entry name to entry (symmetric or asymmetric).
|
|
102
274
|
*/
|
|
103
|
-
readonly secrets: Record<string,
|
|
275
|
+
readonly secrets: Record<string, IKeyStoreEntryJson>;
|
|
104
276
|
}
|
|
105
277
|
/**
|
|
106
278
|
* The encrypted key store file format.
|
|
@@ -128,9 +300,9 @@ export interface IKeyStoreFile {
|
|
|
128
300
|
*/
|
|
129
301
|
readonly encryptedData: string;
|
|
130
302
|
/**
|
|
131
|
-
* Key derivation parameters
|
|
303
|
+
* Key derivation parameters for the vault master key (always PBKDF2).
|
|
132
304
|
*/
|
|
133
|
-
readonly keyDerivation:
|
|
305
|
+
readonly keyDerivation: IPbkdf2KeyDerivationParams;
|
|
134
306
|
}
|
|
135
307
|
/**
|
|
136
308
|
* Key store lock state.
|
|
@@ -150,6 +322,12 @@ export interface IKeyStoreCreateParams {
|
|
|
150
322
|
* PBKDF2 iterations (defaults to DEFAULT_KEYSTORE_ITERATIONS).
|
|
151
323
|
*/
|
|
152
324
|
readonly iterations?: number;
|
|
325
|
+
/**
|
|
326
|
+
* Optional private-key storage backend. Required to use `addKeyPair` /
|
|
327
|
+
* `getKeyPair`; absent backends still permit opening, listing, and reading
|
|
328
|
+
* public-key metadata for asymmetric entries.
|
|
329
|
+
*/
|
|
330
|
+
readonly privateKeyStorage?: IPrivateKeyStorage;
|
|
153
331
|
}
|
|
154
332
|
/**
|
|
155
333
|
* Parameters for opening an existing key store.
|
|
@@ -164,6 +342,12 @@ export interface IKeyStoreOpenParams {
|
|
|
164
342
|
* The encrypted key store file content.
|
|
165
343
|
*/
|
|
166
344
|
readonly keystoreFile: IKeyStoreFile;
|
|
345
|
+
/**
|
|
346
|
+
* Optional private-key storage backend. Required to use `addKeyPair` /
|
|
347
|
+
* `getKeyPair`; absent backends still permit opening, listing, and reading
|
|
348
|
+
* public-key metadata for asymmetric entries.
|
|
349
|
+
*/
|
|
350
|
+
readonly privateKeyStorage?: IPrivateKeyStorage;
|
|
167
351
|
}
|
|
168
352
|
/**
|
|
169
353
|
* Result of adding a secret to the key store.
|
|
@@ -173,11 +357,19 @@ export interface IAddSecretResult {
|
|
|
173
357
|
/**
|
|
174
358
|
* The secret entry that was added.
|
|
175
359
|
*/
|
|
176
|
-
readonly entry:
|
|
360
|
+
readonly entry: IKeyStoreSymmetricEntry;
|
|
177
361
|
/**
|
|
178
362
|
* Whether this replaced an existing secret.
|
|
179
363
|
*/
|
|
180
364
|
readonly replaced: boolean;
|
|
365
|
+
/**
|
|
366
|
+
* Best-effort warning from displaced-resource cleanup. Set when this call
|
|
367
|
+
* replaced an asymmetric-keypair entry but the corresponding
|
|
368
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete failed; the new
|
|
369
|
+
* entry is still committed and the orphaned blob is left for consumer-side
|
|
370
|
+
* GC to reconcile.
|
|
371
|
+
*/
|
|
372
|
+
readonly warning?: string;
|
|
181
373
|
}
|
|
182
374
|
/**
|
|
183
375
|
* Options for adding a secret.
|
|
@@ -199,6 +391,18 @@ export interface IImportSecretOptions extends IAddSecretOptions {
|
|
|
199
391
|
*/
|
|
200
392
|
readonly replace?: boolean;
|
|
201
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Options for importing raw key material via {@link KeyStore.importSecret}.
|
|
396
|
+
* Extends {@link IImportSecretOptions} with a type classification.
|
|
397
|
+
* @public
|
|
398
|
+
*/
|
|
399
|
+
export interface IImportKeyOptions extends IImportSecretOptions {
|
|
400
|
+
/**
|
|
401
|
+
* Symmetric secret type classification for the imported key material.
|
|
402
|
+
* @defaultValue 'encryption-key'
|
|
403
|
+
*/
|
|
404
|
+
readonly type?: KeyStoreSymmetricSecretType;
|
|
405
|
+
}
|
|
202
406
|
/**
|
|
203
407
|
* Options for adding a secret derived from a password.
|
|
204
408
|
* @public
|
|
@@ -234,6 +438,131 @@ export interface IAddSecretFromPasswordResult extends IAddSecretResult {
|
|
|
234
438
|
*/
|
|
235
439
|
readonly keyDerivation: IKeyDerivationParams;
|
|
236
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Options for adding an Argon2id password-derived secret.
|
|
443
|
+
* @public
|
|
444
|
+
*/
|
|
445
|
+
export interface IAddSecretFromPasswordArgon2idOptions {
|
|
446
|
+
/**
|
|
447
|
+
* Argon2id parameters. Defaults to {@link CryptoUtils.ARGON2ID_OWASP_MIN}.
|
|
448
|
+
*/
|
|
449
|
+
readonly params?: IArgon2idParams;
|
|
450
|
+
/**
|
|
451
|
+
* Optional description for the secret.
|
|
452
|
+
*/
|
|
453
|
+
readonly description?: string;
|
|
454
|
+
/**
|
|
455
|
+
* Whether to replace an existing secret with the same name.
|
|
456
|
+
*/
|
|
457
|
+
readonly replace?: boolean;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Options for adding an asymmetric keypair to the key store.
|
|
461
|
+
* @public
|
|
462
|
+
*/
|
|
463
|
+
export interface IAddKeyPairOptions {
|
|
464
|
+
/**
|
|
465
|
+
* Algorithm to use for the new keypair.
|
|
466
|
+
*/
|
|
467
|
+
readonly algorithm: KeyPairAlgorithm;
|
|
468
|
+
/**
|
|
469
|
+
* Optional description for the entry.
|
|
470
|
+
*/
|
|
471
|
+
readonly description?: string;
|
|
472
|
+
/**
|
|
473
|
+
* Whether to replace an existing entry with the same name.
|
|
474
|
+
* Replacement mints a fresh storage `id` and best-effort deletes the
|
|
475
|
+
* displaced storage blob; see the keystore design doc for details.
|
|
476
|
+
*/
|
|
477
|
+
readonly replace?: boolean;
|
|
478
|
+
/**
|
|
479
|
+
* Overrides the storage-backend-derived extractability for this key only.
|
|
480
|
+
* Omit to keep the default (`!privateKeyStorage.supportsNonExtractable`).
|
|
481
|
+
* A value the backend cannot honor fails loudly rather than silently
|
|
482
|
+
* downgrading.
|
|
483
|
+
*/
|
|
484
|
+
readonly extractable?: boolean;
|
|
485
|
+
/**
|
|
486
|
+
* Opt in to private-key escrow. When `true`, an encrypted copy of the
|
|
487
|
+
* private key (as a JWK) is carried inside the vault entry
|
|
488
|
+
* (`escrowedPrivateKeyJwk`), enabling cross-device recovery from the vault
|
|
489
|
+
* file plus the master password alone via
|
|
490
|
+
* `getKeyPair(name, { rehydrate: true })`.
|
|
491
|
+
*
|
|
492
|
+
* Orthogonal to `extractable`: the escrow copy is always captured (the
|
|
493
|
+
* transient keypair is generated extractable so it can be exported to JWK),
|
|
494
|
+
* while the LIVE stored key's extractability still follows the normal rule
|
|
495
|
+
* (`extractable` override, else the backend default). So escrow does not
|
|
496
|
+
* change how extractable the day-to-day key is — only whether a recovery
|
|
497
|
+
* copy is retained in the vault.
|
|
498
|
+
*
|
|
499
|
+
* @defaultValue false — no escrow copy is written (today's behavior).
|
|
500
|
+
*
|
|
501
|
+
* SECURITY: escrow makes the master password the sole gate protecting a
|
|
502
|
+
* private key that would otherwise be unrecoverable from the vault. Use a
|
|
503
|
+
* strong KDF (Argon2id-derived or high-iteration PBKDF2) for escrow-bearing
|
|
504
|
+
* stores. See the {@link CryptoUtils.KeyStore.KeyStore} class docs.
|
|
505
|
+
*/
|
|
506
|
+
readonly escrow?: boolean;
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* Options for retrieving an asymmetric keypair via {@link CryptoUtils.KeyStore.KeyStore.getKeyPair}.
|
|
510
|
+
* @public
|
|
511
|
+
*/
|
|
512
|
+
export interface IGetKeyPairOptions {
|
|
513
|
+
/**
|
|
514
|
+
* Opt in to escrow rehydration. When `true` AND no private-key blob exists
|
|
515
|
+
* under the entry's storage `id` AND the entry carries an
|
|
516
|
+
* `escrowedPrivateKeyJwk`, the escrowed JWK is imported (non-extractable
|
|
517
|
+
* where the backend supports it) and stored under the entry's `id` before
|
|
518
|
+
* being returned — filling a gap on a fresh device from the recovered vault.
|
|
519
|
+
*
|
|
520
|
+
* Fill-a-gap only: an existing storage blob is never overwritten. When a
|
|
521
|
+
* blob is present it is loaded as usual and the escrow copy is ignored.
|
|
522
|
+
*
|
|
523
|
+
* @defaultValue false — today's behavior: load from storage or fail.
|
|
524
|
+
*/
|
|
525
|
+
readonly rehydrate?: boolean;
|
|
526
|
+
}
|
|
527
|
+
/**
|
|
528
|
+
* Result of adding an asymmetric keypair to the key store.
|
|
529
|
+
* @public
|
|
530
|
+
*/
|
|
531
|
+
export interface IAddKeyPairResult {
|
|
532
|
+
/**
|
|
533
|
+
* The asymmetric entry that was added.
|
|
534
|
+
*/
|
|
535
|
+
readonly entry: IKeyStoreAsymmetricEntry;
|
|
536
|
+
/**
|
|
537
|
+
* Whether this replaced an existing entry.
|
|
538
|
+
*/
|
|
539
|
+
readonly replaced: boolean;
|
|
540
|
+
/**
|
|
541
|
+
* Best-effort warning from displaced-resource cleanup. Set when this call
|
|
542
|
+
* replaced a prior entry but the corresponding
|
|
543
|
+
* {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete failed; the new
|
|
544
|
+
* keypair is still committed and the orphaned blob is left for consumer-side
|
|
545
|
+
* GC to reconcile.
|
|
546
|
+
*/
|
|
547
|
+
readonly warning?: string;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Result of removing a secret from the key store.
|
|
551
|
+
* @public
|
|
552
|
+
*/
|
|
553
|
+
export interface IRemoveSecretResult {
|
|
554
|
+
/**
|
|
555
|
+
* The secret entry that was removed from the vault.
|
|
556
|
+
*/
|
|
557
|
+
readonly entry: IKeyStoreEntry;
|
|
558
|
+
/**
|
|
559
|
+
* Best-effort warning from {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete
|
|
560
|
+
* for asymmetric entries when the storage call failed. The vault entry is
|
|
561
|
+
* still considered removed and the orphaned blob is left for consumer-side
|
|
562
|
+
* GC to reconcile.
|
|
563
|
+
*/
|
|
564
|
+
readonly warning?: string;
|
|
565
|
+
}
|
|
237
566
|
/**
|
|
238
567
|
* Checks if a JSON object appears to be a key store file.
|
|
239
568
|
* Uses the format field as a discriminator.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../src/packlets/crypto-utils/keystore/model.ts"],"names":[],"mappings":"AAoBA,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,eAAe,EACf,oBA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M,CAAC;CAC3B;AAMD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAMrD"}
|
|
@@ -19,13 +19,22 @@
|
|
|
19
19
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
20
|
// SOFTWARE.
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.DEFAULT_SECRET_ITERATIONS = exports.allKeyStoreSecretTypes = exports.MIN_SALT_LENGTH = exports.DEFAULT_KEYSTORE_ITERATIONS = exports.KEYSTORE_FORMAT = void 0;
|
|
22
|
+
exports.DEFAULT_SECRET_ITERATIONS = exports.allKeyStoreSecretTypes = exports.allKeyStoreAsymmetricSecretTypes = exports.allKeyStoreSymmetricSecretTypes = exports.MIN_SALT_LENGTH = exports.DEFAULT_KEYSTORE_ITERATIONS = exports.KEYSTORE_FORMAT = exports.allKeyStoreFormats = exports.allKeyPairAlgorithms = void 0;
|
|
23
23
|
exports.isKeyStoreFile = isKeyStoreFile;
|
|
24
|
+
// Re-export so consumers can continue to access the algorithm enum via the
|
|
25
|
+
// CryptoUtils.KeyStore namespace alongside the rest of the keystore types.
|
|
26
|
+
var model_1 = require("../model");
|
|
27
|
+
Object.defineProperty(exports, "allKeyPairAlgorithms", { enumerable: true, get: function () { return model_1.allKeyPairAlgorithms; } });
|
|
24
28
|
/**
|
|
25
|
-
*
|
|
29
|
+
* All recognized key store format versions (readable by the current library).
|
|
26
30
|
* @public
|
|
27
31
|
*/
|
|
28
|
-
exports.
|
|
32
|
+
exports.allKeyStoreFormats = ['keystore-v1', 'keystore-v2'];
|
|
33
|
+
/**
|
|
34
|
+
* Current format version constant. New vaults are written as `'keystore-v2'`.
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
exports.KEYSTORE_FORMAT = 'keystore-v2';
|
|
29
38
|
/**
|
|
30
39
|
* Default PBKDF2 iterations for key store encryption.
|
|
31
40
|
* Higher than regular files since this protects the master key vault.
|
|
@@ -37,11 +46,29 @@ exports.DEFAULT_KEYSTORE_ITERATIONS = 600000;
|
|
|
37
46
|
* @public
|
|
38
47
|
*/
|
|
39
48
|
exports.MIN_SALT_LENGTH = 16;
|
|
49
|
+
/**
|
|
50
|
+
* All valid symmetric secret types.
|
|
51
|
+
* @public
|
|
52
|
+
*/
|
|
53
|
+
exports.allKeyStoreSymmetricSecretTypes = [
|
|
54
|
+
'encryption-key',
|
|
55
|
+
'api-key'
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* All valid asymmetric secret types.
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
exports.allKeyStoreAsymmetricSecretTypes = [
|
|
62
|
+
'asymmetric-keypair'
|
|
63
|
+
];
|
|
40
64
|
/**
|
|
41
65
|
* All valid key store secret types.
|
|
42
66
|
* @public
|
|
43
67
|
*/
|
|
44
|
-
exports.allKeyStoreSecretTypes = [
|
|
68
|
+
exports.allKeyStoreSecretTypes = [
|
|
69
|
+
...exports.allKeyStoreAsymmetricSecretTypes,
|
|
70
|
+
...exports.allKeyStoreSymmetricSecretTypes
|
|
71
|
+
];
|
|
45
72
|
/**
|
|
46
73
|
* Default PBKDF2 iterations for secret-level key derivation.
|
|
47
74
|
* Lower than keystore encryption since these are used more frequently.
|
|
@@ -63,6 +90,6 @@ function isKeyStoreFile(json) {
|
|
|
63
90
|
return false;
|
|
64
91
|
}
|
|
65
92
|
const obj = json;
|
|
66
|
-
return obj.format === exports.
|
|
93
|
+
return typeof obj.format === 'string' && exports.allKeyStoreFormats.includes(obj.format);
|
|
67
94
|
}
|
|
68
95
|
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../src/packlets/crypto-utils/keystore/model.ts"],"names":[],"mappings":";AAAA,kCAAkC;AAClC,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,+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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 {\n EncryptionAlgorithm,\n ICryptoProvider,\n IArgon2idParams,\n IKeyDerivationParams,\n IPbkdf2KeyDerivationParams,\n KeyPairAlgorithm\n} from '../model';\nimport { IPrivateKeyStorage } from './privateKeyStorage';\n\n// Re-export so consumers can continue to access the algorithm enum via the\n// CryptoUtils.KeyStore namespace alongside the rest of the keystore types.\nexport { allKeyPairAlgorithms, KeyPairAlgorithm } from '../model';\n\n// ============================================================================\n// Key Store Format Types\n// ============================================================================\n\n/**\n * Format version for key store files.\n *\n * - `'keystore-v1'`: the original format (no private-key escrow).\n * - `'keystore-v2'`: adds the optional `escrowedPrivateKeyJwk` field on\n * asymmetric-keypair entries. A strict superset of v1 — the field is\n * optional, so a v2 reader opens a v1 vault with no special-casing, and a\n * v1 vault opened and re-saved is silently upgraded to v2.\n * @public\n */\nexport type KeyStoreFormat = 'keystore-v1' | 'keystore-v2';\n\n/**\n * All recognized key store format versions (readable by the current library).\n * @public\n */\nexport const allKeyStoreFormats: ReadonlyArray<KeyStoreFormat> = ['keystore-v1', 'keystore-v2'];\n\n/**\n * Current format version constant. New vaults are written as `'keystore-v2'`.\n * @public\n */\nexport const KEYSTORE_FORMAT: KeyStoreFormat = 'keystore-v2';\n\n/**\n * Default PBKDF2 iterations for key store encryption.\n * Higher than regular files since this protects the master key vault.\n * @public\n */\nexport const DEFAULT_KEYSTORE_ITERATIONS: number = 600000;\n\n/**\n * Minimum salt length for key derivation.\n * @public\n */\nexport const MIN_SALT_LENGTH: number = 16;\n\n// ============================================================================\n// Key Store Vault Contents (Decrypted State)\n// ============================================================================\n\n/**\n * Discriminator for symmetric secret types stored in the vault.\n * - `'encryption-key'`: A 32-byte AES-256 encryption key.\n * - `'api-key'`: An arbitrary-length API key string (UTF-8 encoded).\n * @public\n */\nexport type KeyStoreSymmetricSecretType = 'encryption-key' | 'api-key';\n\n/**\n * All valid symmetric secret types.\n * @public\n */\nexport const allKeyStoreSymmetricSecretTypes: ReadonlyArray<KeyStoreSymmetricSecretType> = [\n 'encryption-key',\n 'api-key'\n];\n\n/**\n * Discriminator for asymmetric secret types stored in the vault.\n * - `'asymmetric-keypair'`: A public/private key pair. The public key is held in\n * the vault as a JWK; the private key lives in the supplied\n * {@link CryptoUtils.KeyStore.IPrivateKeyStorage} provider.\n * @public\n */\nexport type KeyStoreAsymmetricSecretType = 'asymmetric-keypair';\n\n/**\n * All valid asymmetric secret types.\n * @public\n */\nexport const allKeyStoreAsymmetricSecretTypes: ReadonlyArray<KeyStoreAsymmetricSecretType> = [\n 'asymmetric-keypair'\n];\n\n/**\n * Discriminator for any secret type stored in the vault.\n * @public\n */\nexport type KeyStoreSecretType = KeyStoreSymmetricSecretType | KeyStoreAsymmetricSecretType;\n\n/**\n * All valid key store secret types.\n * @public\n */\nexport const allKeyStoreSecretTypes: ReadonlyArray<KeyStoreSecretType> = [\n ...allKeyStoreAsymmetricSecretTypes,\n ...allKeyStoreSymmetricSecretTypes\n];\n\n/**\n * A symmetric secret entry stored in the vault (in-memory representation).\n * Holds the raw key material directly — for `'encryption-key'` it is a 32-byte\n * AES-256 key; for `'api-key'` it is the UTF-8 encoded API key string.\n * @public\n */\nexport interface IKeyStoreSymmetricEntry {\n /**\n * Unique name for this secret (used as lookup key).\n */\n readonly name: string;\n\n /**\n * Symmetric secret type discriminator.\n */\n readonly type: KeyStoreSymmetricSecretType;\n\n /**\n * The secret data.\n * - For `'encryption-key'`: 32-byte AES-256 key.\n * - For `'api-key'`: UTF-8 encoded API key string (arbitrary length).\n */\n readonly key: Uint8Array;\n\n /**\n * Optional description for this secret.\n */\n readonly description?: string;\n\n /**\n * When this secret was added (ISO 8601).\n */\n readonly createdAt: string;\n}\n\n/**\n * An asymmetric keypair entry stored in the vault (in-memory representation).\n * Holds only the public key (as a JWK) and a stable handle (`id`) the\n * {@link CryptoUtils.KeyStore.IPrivateKeyStorage} provider uses to fetch the private key.\n * @public\n */\nexport interface IKeyStoreAsymmetricEntry {\n /**\n * Unique name for this entry (used as vault lookup key, renameable).\n */\n readonly name: string;\n\n /**\n * Asymmetric secret type discriminator.\n */\n readonly type: KeyStoreAsymmetricSecretType;\n\n /**\n * Immutable handle used by {@link CryptoUtils.KeyStore.IPrivateKeyStorage} to address the\n * private key. Independent of `name`; survives renames.\n */\n readonly id: string;\n\n /**\n * Algorithm used to generate this keypair.\n */\n readonly algorithm: KeyPairAlgorithm;\n\n /**\n * The public key as a JSON Web Key.\n */\n readonly publicKeyJwk: JsonWebKey;\n\n /**\n * Optional escrowed copy of the private key, as a JSON Web Key. Present only\n * when the entry was created with `addKeyPair(name, { escrow: true })`.\n *\n * This is an opt-in cross-device recovery affordance: the private key is\n * carried inside the vault's AES-GCM ciphertext (same custody class as\n * `publicKeyJwk`), so a recovered vault plus the master password can\n * reconstitute the signing/decryption identity on a fresh device via\n * `getKeyPair(name, { rehydrate: true })`.\n *\n * SECURITY: when present, the master password becomes the sole gate\n * protecting this private key. Use a strong KDF for escrow-bearing stores.\n * See the {@link CryptoUtils.KeyStore.KeyStore} class docs.\n */\n readonly escrowedPrivateKeyJwk?: JsonWebKey;\n\n /**\n * Optional description for this entry.\n */\n readonly description?: string;\n\n /**\n * When this entry was added (ISO 8601).\n */\n readonly createdAt: string;\n}\n\n/**\n * Any vault entry, discriminated by `type`.\n * @public\n */\nexport type IKeyStoreEntry = IKeyStoreSymmetricEntry | IKeyStoreAsymmetricEntry;\n\n/**\n * Backwards-compatible alias for {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntry}.\n * @deprecated Use {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntry} for symmetric\n * entries or {@link CryptoUtils.KeyStore.IKeyStoreEntry} for the discriminated union.\n * @public\n */\nexport type IKeyStoreSecretEntry = IKeyStoreSymmetricEntry;\n\n/**\n * JSON-serializable representation of a symmetric secret entry.\n *\n * @remarks\n * Describes the *normalized* shape after parsing. `type` is required here\n * because the converter (see\n * {@link CryptoUtils.KeyStore.Converters.keystoreSymmetricEntryJson | keystoreSymmetricEntryJson})\n * injects the default `'encryption-key'` when reading vaults written before\n * asymmetric-keypair support added the discriminator. Raw on-wire bytes from\n * a legacy vault may therefore omit `type`; downstream code only ever sees\n * the post-conversion shape declared here.\n *\n * @public\n */\nexport interface IKeyStoreSymmetricEntryJson {\n /**\n * Unique name for this secret.\n */\n readonly name: string;\n\n /**\n * Symmetric secret type discriminator.\n *\n * Required on this normalized model type. Vaults written prior to the\n * asymmetric-keypair support may omit this field on the wire; the\n * converter injects `'encryption-key'` when missing for backwards\n * compatibility, so by the time a value of this type is observed the\n * discriminator is always present.\n */\n readonly type: KeyStoreSymmetricSecretType;\n\n /**\n * Base64-encoded secret data.\n */\n readonly key: string;\n\n /**\n * Optional description.\n */\n readonly description?: string;\n\n /**\n * When this secret was added (ISO 8601).\n */\n readonly createdAt: string;\n}\n\n/**\n * JSON-serializable representation of an asymmetric keypair entry.\n * The private key is not present here — it lives in the\n * {@link CryptoUtils.KeyStore.IPrivateKeyStorage} provider, addressed by `id`.\n * @public\n */\nexport interface IKeyStoreAsymmetricEntryJson {\n /**\n * Unique name for this entry.\n */\n readonly name: string;\n\n /**\n * Asymmetric secret type discriminator.\n */\n readonly type: KeyStoreAsymmetricSecretType;\n\n /**\n * Immutable handle used by {@link CryptoUtils.KeyStore.IPrivateKeyStorage} to address the\n * private key.\n */\n readonly id: string;\n\n /**\n * Algorithm used to generate this keypair.\n */\n readonly algorithm: KeyPairAlgorithm;\n\n /**\n * The public key as a JSON Web Key.\n */\n readonly publicKeyJwk: JsonWebKey;\n\n /**\n * Optional escrowed copy of the private key, as a JSON Web Key. Present only\n * on `'keystore-v2'` vaults whose entry was created with escrow enabled. A\n * v1 vault omits the field; a v2 reader treats its absence as \"no escrow\".\n */\n readonly escrowedPrivateKeyJwk?: JsonWebKey;\n\n /**\n * Optional description.\n */\n readonly description?: string;\n\n /**\n * When this entry was added (ISO 8601).\n */\n readonly createdAt: string;\n}\n\n/**\n * Any JSON vault entry, discriminated by `type`.\n * @public\n */\nexport type IKeyStoreEntryJson = IKeyStoreSymmetricEntryJson | IKeyStoreAsymmetricEntryJson;\n\n/**\n * Backwards-compatible alias for {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntryJson}.\n * @deprecated Use {@link CryptoUtils.KeyStore.IKeyStoreSymmetricEntryJson} for\n * symmetric entries or {@link CryptoUtils.KeyStore.IKeyStoreEntryJson} for the\n * discriminated union.\n * @public\n */\nexport type IKeyStoreSecretEntryJson = IKeyStoreSymmetricEntryJson;\n\n/**\n * The decrypted vault contents - a versioned map of entries.\n * @public\n */\nexport interface IKeyStoreVaultContents {\n /**\n * Format version for vault contents.\n */\n readonly version: KeyStoreFormat;\n\n /**\n * Map of entry name to entry (symmetric or asymmetric).\n */\n readonly secrets: Record<string, IKeyStoreEntryJson>;\n}\n\n// ============================================================================\n// Key Store File Format (Encrypted State)\n// ============================================================================\n\n/**\n * The encrypted key store file format.\n * @public\n */\nexport interface IKeyStoreFile {\n /**\n * Format identifier.\n */\n readonly format: KeyStoreFormat;\n\n /**\n * Algorithm used for encryption.\n */\n readonly algorithm: EncryptionAlgorithm;\n\n /**\n * Base64-encoded initialization vector.\n */\n readonly iv: string;\n\n /**\n * Base64-encoded authentication tag.\n */\n readonly authTag: string;\n\n /**\n * Base64-encoded encrypted vault contents.\n */\n readonly encryptedData: string;\n\n /**\n * Key derivation parameters for the vault master key (always PBKDF2).\n */\n readonly keyDerivation: IPbkdf2KeyDerivationParams;\n}\n\n// ============================================================================\n// Key Store State and Configuration\n// ============================================================================\n\n/**\n * Key store lock state.\n * @public\n */\nexport type KeyStoreLockState = 'locked' | 'unlocked';\n\n/**\n * Parameters for creating a new key store.\n * @public\n */\nexport interface IKeyStoreCreateParams {\n /**\n * Crypto provider to use.\n */\n readonly cryptoProvider: ICryptoProvider;\n\n /**\n * PBKDF2 iterations (defaults to DEFAULT_KEYSTORE_ITERATIONS).\n */\n readonly iterations?: number;\n\n /**\n * Optional private-key storage backend. Required to use `addKeyPair` /\n * `getKeyPair`; absent backends still permit opening, listing, and reading\n * public-key metadata for asymmetric entries.\n */\n readonly privateKeyStorage?: IPrivateKeyStorage;\n}\n\n/**\n * Parameters for opening an existing key store.\n * @public\n */\nexport interface IKeyStoreOpenParams {\n /**\n * Crypto provider to use.\n */\n readonly cryptoProvider: ICryptoProvider;\n\n /**\n * The encrypted key store file content.\n */\n readonly keystoreFile: IKeyStoreFile;\n\n /**\n * Optional private-key storage backend. Required to use `addKeyPair` /\n * `getKeyPair`; absent backends still permit opening, listing, and reading\n * public-key metadata for asymmetric entries.\n */\n readonly privateKeyStorage?: IPrivateKeyStorage;\n}\n\n/**\n * Result of adding a secret to the key store.\n * @public\n */\nexport interface IAddSecretResult {\n /**\n * The secret entry that was added.\n */\n readonly entry: IKeyStoreSymmetricEntry;\n\n /**\n * Whether this replaced an existing secret.\n */\n readonly replaced: boolean;\n\n /**\n * Best-effort warning from displaced-resource cleanup. Set when this call\n * replaced an asymmetric-keypair entry but the corresponding\n * {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete failed; the new\n * entry is still committed and the orphaned blob is left for consumer-side\n * GC to reconcile.\n */\n readonly warning?: string;\n}\n\n/**\n * Options for adding a secret.\n * @public\n */\nexport interface IAddSecretOptions {\n /**\n * Optional description for the secret.\n */\n readonly description?: string;\n}\n\n/**\n * Options for importing a secret.\n * @public\n */\nexport interface IImportSecretOptions extends IAddSecretOptions {\n /**\n * Whether to replace an existing secret with the same name.\n */\n readonly replace?: boolean;\n}\n\n/**\n * Options for importing raw key material via {@link KeyStore.importSecret}.\n * Extends {@link IImportSecretOptions} with a type classification.\n * @public\n */\nexport interface IImportKeyOptions extends IImportSecretOptions {\n /**\n * Symmetric secret type classification for the imported key material.\n * @defaultValue 'encryption-key'\n */\n readonly type?: KeyStoreSymmetricSecretType;\n}\n\n/**\n * Options for adding a secret derived from a password.\n * @public\n */\nexport interface IAddSecretFromPasswordOptions extends IAddSecretOptions {\n /**\n * Whether to replace an existing secret with the same name.\n */\n readonly replace?: boolean;\n\n /**\n * PBKDF2 iterations for key derivation.\n * @defaultValue DEFAULT_SECRET_ITERATIONS (350000)\n */\n readonly iterations?: number;\n}\n\n/**\n * Default PBKDF2 iterations for secret-level key derivation.\n * Lower than keystore encryption since these are used more frequently.\n * @public\n */\nexport const DEFAULT_SECRET_ITERATIONS: number = 350000;\n\n/**\n * Result of adding a password-derived secret.\n * Extends {@link IAddSecretResult} with key derivation parameters\n * needed to store alongside encrypted files.\n * @public\n */\nexport interface IAddSecretFromPasswordResult extends IAddSecretResult {\n /**\n * Key derivation parameters used to derive the secret key.\n * Store these in encrypted file metadata so the password alone\n * can re-derive the same key for decryption.\n */\n readonly keyDerivation: IKeyDerivationParams;\n}\n\n/**\n * Options for adding an Argon2id password-derived secret.\n * @public\n */\nexport interface IAddSecretFromPasswordArgon2idOptions {\n /**\n * Argon2id parameters. Defaults to {@link CryptoUtils.ARGON2ID_OWASP_MIN}.\n */\n readonly params?: IArgon2idParams;\n /**\n * Optional description for the secret.\n */\n readonly description?: string;\n /**\n * Whether to replace an existing secret with the same name.\n */\n readonly replace?: boolean;\n}\n\n/**\n * Options for adding an asymmetric keypair to the key store.\n * @public\n */\nexport interface IAddKeyPairOptions {\n /**\n * Algorithm to use for the new keypair.\n */\n readonly algorithm: KeyPairAlgorithm;\n\n /**\n * Optional description for the entry.\n */\n readonly description?: string;\n\n /**\n * Whether to replace an existing entry with the same name.\n * Replacement mints a fresh storage `id` and best-effort deletes the\n * displaced storage blob; see the keystore design doc for details.\n */\n readonly replace?: boolean;\n\n /**\n * Overrides the storage-backend-derived extractability for this key only.\n * Omit to keep the default (`!privateKeyStorage.supportsNonExtractable`).\n * A value the backend cannot honor fails loudly rather than silently\n * downgrading.\n */\n readonly extractable?: boolean;\n\n /**\n * Opt in to private-key escrow. When `true`, an encrypted copy of the\n * private key (as a JWK) is carried inside the vault entry\n * (`escrowedPrivateKeyJwk`), enabling cross-device recovery from the vault\n * file plus the master password alone via\n * `getKeyPair(name, { rehydrate: true })`.\n *\n * Orthogonal to `extractable`: the escrow copy is always captured (the\n * transient keypair is generated extractable so it can be exported to JWK),\n * while the LIVE stored key's extractability still follows the normal rule\n * (`extractable` override, else the backend default). So escrow does not\n * change how extractable the day-to-day key is — only whether a recovery\n * copy is retained in the vault.\n *\n * @defaultValue false — no escrow copy is written (today's behavior).\n *\n * SECURITY: escrow makes the master password the sole gate protecting a\n * private key that would otherwise be unrecoverable from the vault. Use a\n * strong KDF (Argon2id-derived or high-iteration PBKDF2) for escrow-bearing\n * stores. See the {@link CryptoUtils.KeyStore.KeyStore} class docs.\n */\n readonly escrow?: boolean;\n}\n\n/**\n * Options for retrieving an asymmetric keypair via {@link CryptoUtils.KeyStore.KeyStore.getKeyPair}.\n * @public\n */\nexport interface IGetKeyPairOptions {\n /**\n * Opt in to escrow rehydration. When `true` AND no private-key blob exists\n * under the entry's storage `id` AND the entry carries an\n * `escrowedPrivateKeyJwk`, the escrowed JWK is imported (non-extractable\n * where the backend supports it) and stored under the entry's `id` before\n * being returned — filling a gap on a fresh device from the recovered vault.\n *\n * Fill-a-gap only: an existing storage blob is never overwritten. When a\n * blob is present it is loaded as usual and the escrow copy is ignored.\n *\n * @defaultValue false — today's behavior: load from storage or fail.\n */\n readonly rehydrate?: boolean;\n}\n\n/**\n * Result of adding an asymmetric keypair to the key store.\n * @public\n */\nexport interface IAddKeyPairResult {\n /**\n * The asymmetric entry that was added.\n */\n readonly entry: IKeyStoreAsymmetricEntry;\n\n /**\n * Whether this replaced an existing entry.\n */\n readonly replaced: boolean;\n\n /**\n * Best-effort warning from displaced-resource cleanup. Set when this call\n * replaced a prior entry but the corresponding\n * {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete failed; the new\n * keypair is still committed and the orphaned blob is left for consumer-side\n * GC to reconcile.\n */\n readonly warning?: string;\n}\n\n/**\n * Result of removing a secret from the key store.\n * @public\n */\nexport interface IRemoveSecretResult {\n /**\n * The secret entry that was removed from the vault.\n */\n readonly entry: IKeyStoreEntry;\n\n /**\n * Best-effort warning from {@link CryptoUtils.KeyStore.IPrivateKeyStorage}.delete\n * for asymmetric entries when the storage call failed. The vault entry is\n * still considered removed and the orphaned blob is left for consumer-side\n * GC to reconcile.\n */\n readonly warning?: string;\n}\n\n// ============================================================================\n// Detection Helper\n// ============================================================================\n\n/**\n * Checks if a JSON object appears to be a key store file.\n * Uses the format field as a discriminator.\n * @param json - JSON object to check\n * @returns true if the object has the key store format field\n * @public\n */\nexport function isKeyStoreFile(json: unknown): boolean {\n if (typeof json !== 'object' || json === null) {\n return false;\n }\n const obj = json as Record<string, unknown>;\n return typeof obj.format === 'string' && (allKeyStoreFormats as ReadonlyArray<string>).includes(obj.format);\n}\n"]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Result } from '@fgv/ts-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Pluggable backend that persists raw asymmetric private keys outside of the
|
|
4
|
+
* encrypted keystore vault. Concrete implementations:
|
|
5
|
+
* - {@link CryptoUtils.KeyStore.EncryptedFilePrivateKeyStorage} in
|
|
6
|
+
* `@fgv/ts-extras` — directory-on-disk, AES-256-GCM-encrypted JWK per key
|
|
7
|
+
* (Node; `supportsNonExtractable: false`).
|
|
8
|
+
* - `IdbPrivateKeyStorage` in `@fgv/ts-web-extras` — IndexedDB-backed, stores
|
|
9
|
+
* `CryptoKey` objects directly (browser; `supportsNonExtractable: true`).
|
|
10
|
+
*
|
|
11
|
+
* The keystore writes storage-first: a private key is always stored here
|
|
12
|
+
* before the corresponding public-key vault entry is committed. Conversely,
|
|
13
|
+
* deletes hit the vault first and then this storage best-effort. As a result,
|
|
14
|
+
* crashes or skipped saves can leave orphaned blobs here; callers are expected
|
|
15
|
+
* to reconcile via {@link CryptoUtils.KeyStore.IPrivateKeyStorage.list} cross-referenced
|
|
16
|
+
* against the keystore's asymmetric entries.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export interface IPrivateKeyStorage {
|
|
21
|
+
/**
|
|
22
|
+
* Whether keys generated for this backend may be marked
|
|
23
|
+
* `extractable: false`. `true` on backends that store `CryptoKey`
|
|
24
|
+
* objects directly (e.g. IndexedDB). `false` on backends that must
|
|
25
|
+
* round-trip via JWK (e.g. encrypted-file backends).
|
|
26
|
+
*/
|
|
27
|
+
readonly supportsNonExtractable: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Stores `key` under `id`. Returns the stored `id` on success so the
|
|
30
|
+
* call can compose into a Result chain.
|
|
31
|
+
* @param id - Storage handle to write under.
|
|
32
|
+
* @param key - The private `CryptoKey` to persist.
|
|
33
|
+
*/
|
|
34
|
+
store(id: string, key: CryptoKey): Promise<Result<string>>;
|
|
35
|
+
/**
|
|
36
|
+
* Loads the private key previously stored under `id`.
|
|
37
|
+
* @param id - Storage handle to look up.
|
|
38
|
+
*/
|
|
39
|
+
load(id: string): Promise<Result<CryptoKey>>;
|
|
40
|
+
/**
|
|
41
|
+
* Deletes the entry stored under `id`. Returns the deleted `id` on
|
|
42
|
+
* success so the call can compose into a Result chain.
|
|
43
|
+
* @param id - Storage handle to remove.
|
|
44
|
+
*/
|
|
45
|
+
delete(id: string): Promise<Result<string>>;
|
|
46
|
+
/**
|
|
47
|
+
* Lists every `id` currently held by the backend. Used by consumers to
|
|
48
|
+
* garbage-collect orphans left by crashes or aborted sessions; the
|
|
49
|
+
* keystore itself does not invoke this automatically.
|
|
50
|
+
*/
|
|
51
|
+
list(): Promise<Result<readonly string[]>>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=privateKeyStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privateKeyStorage.d.ts","sourceRoot":"","sources":["../../../../src/packlets/crypto-utils/keystore/privateKeyStorage.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;IAEzC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAE3D;;;OAGG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAE7C;;;;OAIG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAE5C;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;CAC5C"}
|