effect 4.0.7 → 4.1.0
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/README.md +1 -1
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +3 -0
- package/dist/BigDecimal.js.map +1 -1
- package/dist/Channel.d.ts +12 -6
- package/dist/Channel.d.ts.map +1 -1
- package/dist/Channel.js +9 -3
- package/dist/Channel.js.map +1 -1
- package/dist/Config.d.ts +7 -1
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js.map +1 -1
- package/dist/Context.d.ts +18 -1
- package/dist/Context.d.ts.map +1 -1
- package/dist/Context.js +27 -8
- package/dist/Context.js.map +1 -1
- package/dist/Cron.d.ts +81 -11
- package/dist/Cron.d.ts.map +1 -1
- package/dist/Cron.js +101 -26
- package/dist/Cron.js.map +1 -1
- package/dist/Duration.d.ts +78 -0
- package/dist/Duration.d.ts.map +1 -1
- package/dist/Duration.js +123 -0
- package/dist/Duration.js.map +1 -1
- package/dist/Effect.d.ts +164 -7
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +11 -1
- package/dist/Effect.js.map +1 -1
- package/dist/FileSystem.d.ts +59 -4
- package/dist/FileSystem.d.ts.map +1 -1
- package/dist/FileSystem.js +9 -2
- package/dist/FileSystem.js.map +1 -1
- package/dist/Glob.d.ts +165 -0
- package/dist/Glob.d.ts.map +1 -0
- package/dist/Glob.js +127 -0
- package/dist/Glob.js.map +1 -0
- package/dist/Match.d.ts +86 -0
- package/dist/Match.d.ts.map +1 -1
- package/dist/Match.js +72 -0
- package/dist/Match.js.map +1 -1
- package/dist/Pool.d.ts +51 -0
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +59 -9
- package/dist/Pool.js.map +1 -1
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +3 -3
- package/dist/Random.js.map +1 -1
- package/dist/RcMap.d.ts.map +1 -1
- package/dist/RcMap.js +8 -2
- package/dist/RcMap.js.map +1 -1
- package/dist/Schedule.d.ts +18 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +7 -2
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +666 -41
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +650 -0
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaGetter.d.ts +6 -1
- package/dist/SchemaGetter.d.ts.map +1 -1
- package/dist/SchemaGetter.js +22 -11
- package/dist/SchemaGetter.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +14 -0
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +16 -0
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +8 -3
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +6 -3
- package/dist/SchemaTransformation.js.map +1 -1
- package/dist/ScopedCache.d.ts.map +1 -1
- package/dist/ScopedCache.js +5 -7
- package/dist/ScopedCache.js.map +1 -1
- package/dist/Semaphore.d.ts +130 -0
- package/dist/Semaphore.d.ts.map +1 -1
- package/dist/Semaphore.js +40 -0
- package/dist/Semaphore.js.map +1 -1
- package/dist/Stream.d.ts +13 -4
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +9 -0
- package/dist/Stream.js.map +1 -1
- package/dist/Terminal.d.ts +18 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +1 -1
- package/dist/Terminal.js.map +1 -1
- package/dist/ai/AiError.d.ts +43 -116
- package/dist/ai/AiError.d.ts.map +1 -1
- package/dist/ai/AiError.js +53 -72
- package/dist/ai/AiError.js.map +1 -1
- package/dist/ai/Decision.d.ts +196 -15
- package/dist/ai/Decision.d.ts.map +1 -1
- package/dist/ai/Decision.js +130 -0
- package/dist/ai/Decision.js.map +1 -1
- package/dist/ai/DecisionModel.d.ts +54 -13
- package/dist/ai/DecisionModel.d.ts.map +1 -1
- package/dist/ai/DecisionModel.js +123 -12
- package/dist/ai/DecisionModel.js.map +1 -1
- package/dist/ai/McpServer.d.ts +630 -29
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +562 -116
- package/dist/ai/McpServer.js.map +1 -1
- package/dist/ai/McpTest.d.ts +130 -0
- package/dist/ai/McpTest.d.ts.map +1 -0
- package/dist/ai/McpTest.js +237 -0
- package/dist/ai/McpTest.js.map +1 -0
- package/dist/ai/Response.d.ts +1 -25
- package/dist/ai/Response.d.ts.map +1 -1
- package/dist/ai/Response.js +1 -10
- package/dist/ai/Response.js.map +1 -1
- package/dist/ai/Tool.d.ts +19 -1
- package/dist/ai/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -1
- package/dist/ai/index.js +5 -0
- package/dist/ai/index.js.map +1 -1
- package/dist/ai/internal/mcpCore.js +17 -12
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +4 -5
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +18 -10
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +13 -0
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +5 -3
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpStatefulRuntime.js +6 -1
- package/dist/ai/internal/mcpStatefulRuntime.js.map +1 -1
- package/dist/cli/Argument.d.ts +6 -0
- package/dist/cli/Argument.d.ts.map +1 -1
- package/dist/cli/Argument.js +2 -0
- package/dist/cli/Argument.js.map +1 -1
- package/dist/cli/CliOutput.d.ts +65 -1
- package/dist/cli/CliOutput.d.ts.map +1 -1
- package/dist/cli/CliOutput.js +94 -37
- package/dist/cli/CliOutput.js.map +1 -1
- package/dist/cli/Command.d.ts +23 -0
- package/dist/cli/Command.d.ts.map +1 -1
- package/dist/cli/Command.js +8 -0
- package/dist/cli/Command.js.map +1 -1
- package/dist/cli/Flag.d.ts +107 -0
- package/dist/cli/Flag.d.ts.map +1 -1
- package/dist/cli/Flag.js +37 -0
- package/dist/cli/Flag.js.map +1 -1
- package/dist/cli/HelpDoc.d.ts +15 -1
- package/dist/cli/HelpDoc.d.ts.map +1 -1
- package/dist/cli/Param.d.ts +6 -0
- package/dist/cli/Param.d.ts.map +1 -1
- package/dist/cli/Param.js +2 -0
- package/dist/cli/Param.js.map +1 -1
- package/dist/cli/Primitive.d.ts +14 -0
- package/dist/cli/Primitive.d.ts.map +1 -1
- package/dist/cli/Primitive.js +15 -1
- package/dist/cli/Primitive.js.map +1 -1
- package/dist/cli/Prompt.d.ts +1 -0
- package/dist/cli/Prompt.d.ts.map +1 -1
- package/dist/cli/Prompt.js +1 -0
- package/dist/cli/Prompt.js.map +1 -1
- package/dist/cli/internal/help.d.ts.map +1 -1
- package/dist/cli/internal/help.js +17 -10
- package/dist/cli/internal/help.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +90 -28
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/ShardingConfig.d.ts +72 -6
- package/dist/cluster/ShardingConfig.d.ts.map +1 -1
- package/dist/cluster/ShardingConfig.js +4 -0
- package/dist/cluster/ShardingConfig.js.map +1 -1
- package/dist/cluster/SingleRunner.d.ts +3 -3
- package/dist/cluster/SingleRunner.d.ts.map +1 -1
- package/dist/cluster/SingleRunner.js +1 -1
- package/dist/cluster/SqlMessageStorage.d.ts +37 -6
- package/dist/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/cluster/SqlMessageStorage.js +34 -7
- package/dist/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/cluster/SqlRunnerStorage.d.ts.map +1 -1
- package/dist/cluster/SqlRunnerStorage.js +23 -8
- package/dist/cluster/SqlRunnerStorage.js.map +1 -1
- package/dist/crypto/Aead.d.ts +322 -0
- package/dist/crypto/Aead.d.ts.map +1 -0
- package/dist/crypto/Aead.js +331 -0
- package/dist/crypto/Aead.js.map +1 -0
- package/dist/crypto/Cipher.d.ts +235 -0
- package/dist/crypto/Cipher.d.ts.map +1 -0
- package/dist/crypto/Cipher.js +233 -0
- package/dist/crypto/Cipher.js.map +1 -0
- package/dist/crypto/CryptoError.d.ts +212 -0
- package/dist/crypto/CryptoError.d.ts.map +1 -0
- package/dist/crypto/CryptoError.js +202 -0
- package/dist/crypto/CryptoError.js.map +1 -0
- package/dist/crypto/Digest.d.ts +143 -0
- package/dist/crypto/Digest.d.ts.map +1 -0
- package/dist/crypto/Digest.js +146 -0
- package/dist/crypto/Digest.js.map +1 -0
- package/dist/crypto/Kdf.d.ts +220 -0
- package/dist/crypto/Kdf.d.ts.map +1 -0
- package/dist/crypto/Kdf.js +212 -0
- package/dist/crypto/Kdf.js.map +1 -0
- package/dist/crypto/KeyAgreement.d.ts +323 -0
- package/dist/crypto/KeyAgreement.d.ts.map +1 -0
- package/dist/crypto/KeyAgreement.js +303 -0
- package/dist/crypto/KeyAgreement.js.map +1 -0
- package/dist/crypto/KeyFormat.d.ts +309 -0
- package/dist/crypto/KeyFormat.d.ts.map +1 -0
- package/dist/crypto/KeyFormat.js +556 -0
- package/dist/crypto/KeyFormat.js.map +1 -0
- package/dist/crypto/KeyWrap.d.ts +389 -0
- package/dist/crypto/KeyWrap.d.ts.map +1 -0
- package/dist/crypto/KeyWrap.js +381 -0
- package/dist/crypto/KeyWrap.js.map +1 -0
- package/dist/crypto/Mac.d.ts +277 -0
- package/dist/crypto/Mac.d.ts.map +1 -0
- package/dist/crypto/Mac.js +288 -0
- package/dist/crypto/Mac.js.map +1 -0
- package/dist/crypto/SecureRandom.d.ts +340 -0
- package/dist/crypto/SecureRandom.d.ts.map +1 -0
- package/dist/crypto/SecureRandom.js +257 -0
- package/dist/crypto/SecureRandom.js.map +1 -0
- package/dist/crypto/Signature.d.ts +448 -0
- package/dist/crypto/Signature.d.ts.map +1 -0
- package/dist/crypto/Signature.js +484 -0
- package/dist/crypto/Signature.js.map +1 -0
- package/dist/crypto/WebCrypto.d.ts +61 -0
- package/dist/crypto/WebCrypto.d.ts.map +1 -0
- package/dist/crypto/WebCrypto.js +63 -0
- package/dist/crypto/WebCrypto.js.map +1 -0
- package/dist/crypto/index.d.ts +65 -0
- package/dist/crypto/index.d.ts.map +1 -0
- package/dist/crypto/index.js +66 -0
- package/dist/crypto/index.js.map +1 -0
- package/dist/crypto/internal/asymmetric.d.ts +2 -0
- package/dist/crypto/internal/asymmetric.d.ts.map +1 -0
- package/dist/crypto/internal/asymmetric.js +210 -0
- package/dist/crypto/internal/asymmetric.js.map +1 -0
- package/dist/crypto/internal/chacha.d.ts +46 -0
- package/dist/crypto/internal/chacha.d.ts.map +1 -0
- package/dist/crypto/internal/chacha.js +885 -0
- package/dist/crypto/internal/chacha.js.map +1 -0
- package/dist/crypto/internal/der.d.ts +6 -0
- package/dist/crypto/internal/der.d.ts.map +1 -0
- package/dist/crypto/internal/der.js +86 -0
- package/dist/crypto/internal/der.js.map +1 -0
- package/dist/crypto/internal/digest.d.ts +2 -0
- package/dist/crypto/internal/digest.d.ts.map +1 -0
- package/dist/crypto/internal/digest.js +15 -0
- package/dist/crypto/internal/digest.js.map +1 -0
- package/dist/crypto/internal/key.d.ts +2 -0
- package/dist/crypto/internal/key.d.ts.map +1 -0
- package/dist/crypto/internal/key.js +170 -0
- package/dist/crypto/internal/key.js.map +1 -0
- package/dist/crypto/internal/md5.d.ts +39 -0
- package/dist/crypto/internal/md5.d.ts.map +1 -0
- package/dist/crypto/internal/md5.js +179 -0
- package/dist/crypto/internal/md5.js.map +1 -0
- package/dist/crypto/internal/webCrypto.d.ts +2 -0
- package/dist/crypto/internal/webCrypto.d.ts.map +1 -0
- package/dist/crypto/internal/webCrypto.js +111 -0
- package/dist/crypto/internal/webCrypto.js.map +1 -0
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +3 -2
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Csv.d.ts +608 -0
- package/dist/encoding/Csv.d.ts.map +1 -0
- package/dist/encoding/Csv.js +718 -0
- package/dist/encoding/Csv.js.map +1 -0
- package/dist/encoding/Hex.d.ts +3 -2
- package/dist/encoding/Hex.d.ts.map +1 -1
- package/dist/encoding/Hex.js +3 -2
- package/dist/encoding/Hex.js.map +1 -1
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +42 -4
- package/dist/encoding/SchemaBinary.js.map +1 -1
- package/dist/encoding/Toml.d.ts +17 -3
- package/dist/encoding/Toml.d.ts.map +1 -1
- package/dist/encoding/Toml.js +104 -16
- package/dist/encoding/Toml.js.map +1 -1
- package/dist/encoding/Yaml.d.ts +8 -1
- package/dist/encoding/Yaml.d.ts.map +1 -1
- package/dist/encoding/Yaml.js +54 -18
- package/dist/encoding/Yaml.js.map +1 -1
- package/dist/encoding/index.d.ts +5 -0
- package/dist/encoding/index.d.ts.map +1 -1
- package/dist/encoding/index.js +5 -0
- package/dist/encoding/index.js.map +1 -1
- package/dist/eventlog/EventJournal.d.ts.map +1 -1
- package/dist/eventlog/EventJournal.js +6 -3
- package/dist/eventlog/EventJournal.js.map +1 -1
- package/dist/eventlog/EventLog.d.ts +119 -4
- package/dist/eventlog/EventLog.d.ts.map +1 -1
- package/dist/eventlog/EventLog.js +200 -12
- package/dist/eventlog/EventLog.js.map +1 -1
- package/dist/eventlog/EventLogEncryption.d.ts +41 -4
- package/dist/eventlog/EventLogEncryption.d.ts.map +1 -1
- package/dist/eventlog/EventLogEncryption.js +83 -64
- package/dist/eventlog/EventLogEncryption.js.map +1 -1
- package/dist/eventlog/EventLogMessage.d.ts +279 -0
- package/dist/eventlog/EventLogMessage.d.ts.map +1 -1
- package/dist/eventlog/EventLogMessage.js +217 -1
- package/dist/eventlog/EventLogMessage.js.map +1 -1
- package/dist/eventlog/EventLogRemote.d.ts +200 -28
- package/dist/eventlog/EventLogRemote.d.ts.map +1 -1
- package/dist/eventlog/EventLogRemote.js +186 -16
- package/dist/eventlog/EventLogRemote.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts +3 -0
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +18 -10
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.d.ts +326 -5
- package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.js +769 -14
- package/dist/eventlog/EventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.d.ts +5 -3
- package/dist/eventlog/EventLogSessionAuth.d.ts.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.js +41 -64
- package/dist/eventlog/EventLogSessionAuth.js.map +1 -1
- package/dist/eventlog/EventRow.d.ts +4 -0
- package/dist/eventlog/EventRow.d.ts.map +1 -1
- package/dist/eventlog/EventRow.js +12 -2
- package/dist/eventlog/EventRow.js.map +1 -1
- package/dist/eventlog/SqlEventJournal.js +2 -2
- package/dist/eventlog/SqlEventJournal.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts +21 -5
- package/dist/eventlog/SqlEventLogServerEncrypted.d.ts.map +1 -1
- package/dist/eventlog/SqlEventLogServerEncrypted.js +1048 -113
- package/dist/eventlog/SqlEventLogServerEncrypted.js.map +1 -1
- package/dist/eventlog/SqlEventLogServerUnencrypted.js +2 -2
- package/dist/eventlog/SqlEventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/internal/batches.d.ts +12 -0
- package/dist/eventlog/internal/batches.d.ts.map +1 -0
- package/dist/eventlog/internal/batches.js +26 -0
- package/dist/eventlog/internal/batches.js.map +1 -0
- package/dist/eventlog/internal/compaction.d.ts +38 -0
- package/dist/eventlog/internal/compaction.d.ts.map +1 -0
- package/dist/eventlog/internal/compaction.js +33 -0
- package/dist/eventlog/internal/compaction.js.map +1 -0
- package/dist/eventlog/internal/identityRootSecretDerivation.js +66 -67
- package/dist/eventlog/internal/identityRootSecretDerivation.js.map +1 -1
- package/dist/eventlog/internal/remoteCompaction.d.ts +31 -0
- package/dist/eventlog/internal/remoteCompaction.d.ts.map +1 -0
- package/dist/eventlog/internal/remoteCompaction.js +76 -0
- package/dist/eventlog/internal/remoteCompaction.js.map +1 -0
- package/dist/http/Cookies.d.ts +172 -0
- package/dist/http/Cookies.d.ts.map +1 -1
- package/dist/http/Cookies.js +143 -1
- package/dist/http/Cookies.js.map +1 -1
- package/dist/http/FetchHttpClient.d.ts +26 -2
- package/dist/http/FetchHttpClient.d.ts.map +1 -1
- package/dist/http/FetchHttpClient.js +78 -15
- package/dist/http/FetchHttpClient.js.map +1 -1
- package/dist/http/HttpClient.d.ts +79 -8
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +65 -5
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpClientRequest.d.ts +9 -5
- package/dist/http/HttpClientRequest.d.ts.map +1 -1
- package/dist/http/HttpClientRequest.js +2 -3
- package/dist/http/HttpClientRequest.js.map +1 -1
- package/dist/http/HttpClientResponse.d.ts.map +1 -1
- package/dist/http/HttpClientResponse.js +3 -2
- package/dist/http/HttpClientResponse.js.map +1 -1
- package/dist/http/HttpMethod.d.ts +7 -1
- package/dist/http/HttpMethod.d.ts.map +1 -1
- package/dist/http/HttpMethod.js +3 -8
- package/dist/http/HttpMethod.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts +5 -2
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +6 -17
- package/dist/http/HttpServerRequest.js.map +1 -1
- package/dist/http/HttpServerResponse.d.ts.map +1 -1
- package/dist/http/HttpServerResponse.js +3 -2
- package/dist/http/HttpServerResponse.js.map +1 -1
- package/dist/http/HttpTraceContext.d.ts +2 -1
- package/dist/http/HttpTraceContext.d.ts.map +1 -1
- package/dist/http/HttpTraceContext.js +7 -5
- package/dist/http/HttpTraceContext.js.map +1 -1
- package/dist/http/ProblemDetails.d.ts +96 -0
- package/dist/http/ProblemDetails.d.ts.map +1 -0
- package/dist/http/ProblemDetails.js +98 -0
- package/dist/http/ProblemDetails.js.map +1 -0
- package/dist/http/index.d.ts +5 -0
- package/dist/http/index.d.ts.map +1 -1
- package/dist/http/index.js +5 -0
- package/dist/http/index.js.map +1 -1
- package/dist/http/internal/decompression.js +3 -2
- package/dist/http/internal/decompression.js.map +1 -1
- package/dist/http/internal/urlParams.js +8 -0
- package/dist/http/internal/urlParams.js.map +1 -1
- package/dist/http-api/HttpApiBuilder.js +19 -5
- package/dist/http-api/HttpApiBuilder.js.map +1 -1
- package/dist/http-api/HttpApiClient.d.ts +63 -0
- package/dist/http-api/HttpApiClient.d.ts.map +1 -1
- package/dist/http-api/HttpApiClient.js +51 -0
- package/dist/http-api/HttpApiClient.js.map +1 -1
- package/dist/http-api/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/http-api/HttpApiEndpoint.js +14 -5
- package/dist/http-api/HttpApiEndpoint.js.map +1 -1
- package/dist/http-api/HttpApiError.d.ts +185 -13
- package/dist/http-api/HttpApiError.d.ts.map +1 -1
- package/dist/http-api/HttpApiError.js +128 -0
- package/dist/http-api/HttpApiError.js.map +1 -1
- package/dist/http-api/HttpApiMiddleware.d.ts +64 -17
- package/dist/http-api/HttpApiMiddleware.d.ts.map +1 -1
- package/dist/http-api/HttpApiMiddleware.js +85 -1
- package/dist/http-api/HttpApiMiddleware.js.map +1 -1
- package/dist/http-api/HttpApiSchema.d.ts +76 -14
- package/dist/http-api/HttpApiSchema.d.ts.map +1 -1
- package/dist/http-api/HttpApiSchema.js +53 -0
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +25 -14
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/glob.d.ts +2 -0
- package/dist/internal/glob.d.ts.map +1 -0
- package/dist/internal/glob.js +630 -0
- package/dist/internal/glob.js.map +1 -0
- package/dist/internal/matcher.js +10 -0
- package/dist/internal/matcher.js.map +1 -1
- package/dist/internal/persistence.js +9 -0
- package/dist/internal/persistence.js.map +1 -1
- package/dist/internal/rcRef.js +4 -1
- package/dist/internal/rcRef.js.map +1 -1
- package/dist/internal/schema/toCodeDocument.js +6 -3
- package/dist/internal/schema/toCodeDocument.js.map +1 -1
- package/dist/internal/trie.js +42 -13
- package/dist/internal/trie.js.map +1 -1
- package/dist/internal/ulid.js +41 -0
- package/dist/internal/ulid.js.map +1 -1
- package/dist/internal/uuid.js +52 -8
- package/dist/internal/uuid.js.map +1 -1
- package/dist/internal/version.js +1 -1
- package/dist/observability/Otlp.d.ts +15 -4
- package/dist/observability/Otlp.d.ts.map +1 -1
- package/dist/observability/Otlp.js +10 -0
- package/dist/observability/Otlp.js.map +1 -1
- package/dist/observability/OtlpResource.d.ts +7 -0
- package/dist/observability/OtlpResource.d.ts.map +1 -1
- package/dist/observability/OtlpResource.js +11 -1
- package/dist/observability/OtlpResource.js.map +1 -1
- package/dist/persistence/KeyValueStore.d.ts +47 -2
- package/dist/persistence/KeyValueStore.d.ts.map +1 -1
- package/dist/persistence/KeyValueStore.js +129 -18
- package/dist/persistence/KeyValueStore.js.map +1 -1
- package/dist/persistence/PersistedQueue.d.ts +9 -0
- package/dist/persistence/PersistedQueue.d.ts.map +1 -1
- package/dist/persistence/PersistedQueue.js +94 -52
- package/dist/persistence/PersistedQueue.js.map +1 -1
- package/dist/persistence/Persistence.d.ts +10 -4
- package/dist/persistence/Persistence.d.ts.map +1 -1
- package/dist/persistence/Persistence.js +18 -11
- package/dist/persistence/Persistence.js.map +1 -1
- package/dist/process/ChildProcess.d.ts +207 -67
- package/dist/process/ChildProcess.d.ts.map +1 -1
- package/dist/process/ChildProcess.js +56 -158
- package/dist/process/ChildProcess.js.map +1 -1
- package/dist/process/ChildProcessSpawner.d.ts +5 -0
- package/dist/process/ChildProcessSpawner.d.ts.map +1 -1
- package/dist/process/ChildProcessSpawner.js.map +1 -1
- package/dist/process/CommandLine.d.ts +294 -0
- package/dist/process/CommandLine.d.ts.map +1 -0
- package/dist/process/CommandLine.js +481 -0
- package/dist/process/CommandLine.js.map +1 -0
- package/dist/process/index.d.ts +5 -0
- package/dist/process/index.d.ts.map +1 -1
- package/dist/process/index.js +5 -0
- package/dist/process/index.js.map +1 -1
- package/dist/reactivity/Atom.d.ts +2 -1
- package/dist/reactivity/Atom.d.ts.map +1 -1
- package/dist/reactivity/Atom.js +3 -4
- package/dist/reactivity/Atom.js.map +1 -1
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +16 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +50 -16
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcMessage.d.ts +10 -1
- package/dist/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/rpc/RpcMessage.js +1 -0
- package/dist/rpc/RpcMessage.js.map +1 -1
- package/dist/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/rpc/RpcSerialization.js +6 -0
- package/dist/rpc/RpcSerialization.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts +31 -0
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +139 -66
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/schema/Model.d.ts +14 -0
- package/dist/schema/Model.d.ts.map +1 -1
- package/dist/schema/Model.js +18 -3
- package/dist/schema/Model.js.map +1 -1
- package/dist/sql/Migrator.d.ts +0 -19
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +3 -48
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/MigratorFileSystem.d.ts +21 -0
- package/dist/sql/MigratorFileSystem.d.ts.map +1 -0
- package/dist/sql/MigratorFileSystem.js +57 -0
- package/dist/sql/MigratorFileSystem.js.map +1 -0
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +5 -9
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +20 -6
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +0 -13
- package/dist/sql/Statement.js.map +1 -1
- package/dist/sql/index.js +1 -1
- package/dist/testing/index.d.ts +0 -5
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +0 -5
- package/dist/testing/index.js.map +1 -1
- package/dist/workflow/internal/crypto.js +9 -8
- package/dist/workflow/internal/crypto.js.map +1 -1
- package/package.json +3 -1
- package/src/BigDecimal.ts +3 -0
- package/src/Channel.ts +17 -11
- package/src/Config.ts +7 -1
- package/src/Context.ts +34 -10
- package/src/Cron.ts +178 -29
- package/src/Duration.ts +140 -0
- package/src/Effect.ts +914 -85
- package/src/FileSystem.ts +65 -4
- package/src/Glob.ts +205 -0
- package/src/Match.ts +127 -0
- package/src/Pool.ts +73 -15
- package/src/Random.ts +3 -3
- package/src/RcMap.ts +5 -1
- package/src/Schedule.ts +26 -3
- package/src/Schema.ts +1189 -62
- package/src/SchemaGetter.ts +27 -11
- package/src/SchemaRepresentation.ts +19 -0
- package/src/SchemaTransformation.ts +8 -3
- package/src/ScopedCache.ts +5 -9
- package/src/Semaphore.ts +141 -0
- package/src/Stream.ts +15 -6
- package/src/Terminal.ts +19 -1
- package/src/ai/AiError.ts +56 -80
- package/src/ai/Decision.ts +257 -6
- package/src/ai/DecisionModel.ts +171 -28
- package/src/ai/McpServer.ts +1269 -286
- package/src/ai/McpTest.ts +380 -0
- package/src/ai/Response.ts +2 -22
- package/src/ai/Tool.ts +27 -8
- package/src/ai/index.ts +6 -0
- package/src/ai/internal/mcpCore.ts +78 -44
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +4 -7
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +15 -10
- package/src/ai/internal/mcpProtocol.ts +29 -0
- package/src/ai/internal/mcpRuntime.ts +9 -5
- package/src/ai/internal/mcpStatefulRuntime.ts +14 -2
- package/src/cli/Argument.ts +6 -0
- package/src/cli/CliOutput.ts +117 -49
- package/src/cli/Command.ts +23 -0
- package/src/cli/Flag.ts +107 -0
- package/src/cli/HelpDoc.ts +18 -1
- package/src/cli/Param.ts +6 -0
- package/src/cli/Primitive.ts +16 -1
- package/src/cli/Prompt.ts +1 -0
- package/src/cli/internal/help.ts +21 -9
- package/src/cluster/Sharding.ts +93 -26
- package/src/cluster/ShardingConfig.ts +41 -3
- package/src/cluster/SingleRunner.ts +3 -3
- package/src/cluster/SqlMessageStorage.ts +49 -17
- package/src/cluster/SqlRunnerStorage.ts +37 -27
- package/src/crypto/Aead.ts +517 -0
- package/src/crypto/Cipher.ts +326 -0
- package/src/crypto/CryptoError.ts +242 -0
- package/src/crypto/Digest.ts +167 -0
- package/src/crypto/Kdf.ts +315 -0
- package/src/crypto/KeyAgreement.ts +489 -0
- package/src/crypto/KeyFormat.ts +712 -0
- package/src/crypto/KeyWrap.ts +639 -0
- package/src/crypto/Mac.ts +386 -0
- package/src/crypto/SecureRandom.ts +459 -0
- package/src/crypto/Signature.ts +673 -0
- package/src/crypto/WebCrypto.ts +64 -0
- package/src/crypto/index.ts +78 -0
- package/src/crypto/internal/asymmetric.ts +329 -0
- package/src/crypto/internal/chacha.ts +1088 -0
- package/src/crypto/internal/der.ts +110 -0
- package/src/crypto/internal/digest.ts +16 -0
- package/src/crypto/internal/key.ts +235 -0
- package/src/crypto/internal/md5.ts +170 -0
- package/src/crypto/internal/webCrypto.ts +150 -0
- package/src/encoding/Base64Url.ts +5 -2
- package/src/encoding/Csv.ts +1298 -0
- package/src/encoding/Hex.ts +3 -2
- package/src/encoding/SchemaBinary.ts +40 -4
- package/src/encoding/Toml.ts +85 -20
- package/src/encoding/Yaml.ts +61 -18
- package/src/encoding/index.ts +6 -0
- package/src/eventlog/EventJournal.ts +4 -3
- package/src/eventlog/EventLog.ts +340 -15
- package/src/eventlog/EventLogEncryption.ts +118 -110
- package/src/eventlog/EventLogMessage.ts +273 -1
- package/src/eventlog/EventLogRemote.ts +367 -23
- package/src/eventlog/EventLogServer.ts +23 -8
- package/src/eventlog/EventLogServerEncrypted.ts +1130 -67
- package/src/eventlog/EventLogSessionAuth.ts +56 -70
- package/src/eventlog/EventRow.ts +12 -3
- package/src/eventlog/SqlEventJournal.ts +2 -2
- package/src/eventlog/SqlEventLogServerEncrypted.ts +1244 -136
- package/src/eventlog/SqlEventLogServerUnencrypted.ts +2 -2
- package/src/eventlog/internal/batches.ts +30 -0
- package/src/eventlog/internal/compaction.ts +64 -0
- package/src/eventlog/internal/identityRootSecretDerivation.ts +93 -123
- package/src/eventlog/internal/remoteCompaction.ts +92 -0
- package/src/http/Cookies.ts +281 -1
- package/src/http/FetchHttpClient.ts +88 -16
- package/src/http/HttpClient.ts +89 -22
- package/src/http/HttpClientRequest.ts +12 -9
- package/src/http/HttpClientResponse.ts +3 -2
- package/src/http/HttpMethod.ts +10 -2
- package/src/http/HttpServerRequest.ts +15 -30
- package/src/http/HttpServerResponse.ts +3 -2
- package/src/http/HttpTraceContext.ts +7 -4
- package/src/http/ProblemDetails.ts +149 -0
- package/src/http/index.ts +6 -0
- package/src/http/internal/decompression.ts +4 -4
- package/src/http/internal/urlParams.ts +8 -0
- package/src/http-api/HttpApiBuilder.ts +24 -12
- package/src/http-api/HttpApiClient.ts +67 -1
- package/src/http-api/HttpApiEndpoint.ts +14 -5
- package/src/http-api/HttpApiError.ts +250 -0
- package/src/http-api/HttpApiMiddleware.ts +95 -1
- package/src/http-api/HttpApiSchema.ts +105 -14
- package/src/index.ts +6 -6
- package/src/internal/effect.ts +34 -18
- package/src/internal/glob.ts +736 -0
- package/src/internal/matcher.ts +17 -0
- package/src/internal/persistence.ts +11 -0
- package/src/internal/rcRef.ts +4 -1
- package/src/internal/schema/toCodeDocument.ts +7 -3
- package/src/internal/trie.ts +43 -14
- package/src/internal/ulid.ts +44 -0
- package/src/internal/uuid.ts +57 -16
- package/src/internal/version.ts +1 -1
- package/src/observability/Otlp.ts +21 -4
- package/src/observability/OtlpResource.ts +9 -1
- package/src/persistence/KeyValueStore.ts +219 -22
- package/src/persistence/PersistedQueue.ts +128 -59
- package/src/persistence/Persistence.ts +20 -13
- package/src/process/ChildProcess.ts +255 -260
- package/src/process/ChildProcessSpawner.ts +5 -0
- package/src/process/CommandLine.ts +630 -0
- package/src/process/index.ts +6 -0
- package/src/reactivity/Atom.ts +5 -5
- package/src/reactivity/AtomRegistry.ts +1 -1
- package/src/rpc/RpcClient.ts +62 -26
- package/src/rpc/RpcMessage.ts +10 -1
- package/src/rpc/RpcSerialization.ts +3 -0
- package/src/rpc/RpcServer.ts +176 -78
- package/src/schema/Model.ts +26 -3
- package/src/sql/Migrator.ts +4 -63
- package/src/sql/MigratorFileSystem.ts +71 -0
- package/src/sql/SqlClient.ts +2 -16
- package/src/sql/Statement.ts +8 -7
- package/src/sql/index.ts +1 -1
- package/src/testing/index.ts +0 -6
- package/src/workflow/internal/crypto.ts +15 -11
- package/dist/Crypto.d.ts +0 -244
- package/dist/Crypto.d.ts.map +0 -1
- package/dist/Crypto.js +0 -139
- package/dist/Crypto.js.map +0 -1
- package/dist/testing/TestCrypto.d.ts +0 -73
- package/dist/testing/TestCrypto.d.ts.map +0 -1
- package/dist/testing/TestCrypto.js +0 -87
- package/dist/testing/TestCrypto.js.map +0 -1
- package/src/Crypto.ts +0 -347
- package/src/testing/TestCrypto.ts +0 -94
|
@@ -0,0 +1,885 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ChaCha20-Poly1305 (RFC 8439) and XChaCha20-Poly1305
|
|
3
|
+
* (draft-irtf-cfrg-xchacha-03), vendored from `@noble/ciphers`.
|
|
4
|
+
*
|
|
5
|
+
* Upstream: https://github.com/paulmillr/noble-ciphers
|
|
6
|
+
* Version: 2.4.0, commit d9e8a6a599e7ed729d9be03854c46a3c73bd9a79
|
|
7
|
+
* Files: `src/chacha.ts` (`chachaCore`, `hchacha`, `chacha20`, `xchacha20`,
|
|
8
|
+
* `_poly1305_aead`), `src/_arx.ts` (`createCipher`), `src/_poly1305.ts`
|
|
9
|
+
* (`Poly1305`), and the helpers they use from `src/utils.ts`. `@noble/ciphers`
|
|
10
|
+
* 1.0.0 was audited by Cure53 in 2024.
|
|
11
|
+
*
|
|
12
|
+
* Changes from upstream: merged into one file, removed the `TArg`/`TRet` type
|
|
13
|
+
* helpers, `@example` blocks, the reduced-round and original ChaCha variants,
|
|
14
|
+
* the PRGs, and the `wrapCipher` argument wrapper, whose checks the `Aead`
|
|
15
|
+
* layers run before calling this code. `Poly1305` is constructed directly
|
|
16
|
+
* instead of through `wrapMacConstructor`, and `decrypt` returns `undefined`
|
|
17
|
+
* on a tag mismatch instead of throwing, so any exception is a bug. The
|
|
18
|
+
* cipher core, Poly1305 arithmetic, and AEAD construction are unchanged.
|
|
19
|
+
*
|
|
20
|
+
* The MIT License (MIT)
|
|
21
|
+
*
|
|
22
|
+
* Copyright (c) 2022 Paul Miller (https://paulmillr.com)
|
|
23
|
+
* Copyright (c) 2016 Thomas Pornin <pornin@bolet.org>
|
|
24
|
+
*
|
|
25
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
26
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
27
|
+
* in the Software without restriction, including without limitation the rights
|
|
28
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
29
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
30
|
+
* furnished to do so, subject to the following conditions:
|
|
31
|
+
*
|
|
32
|
+
* The above copyright notice and this permission notice shall be included in
|
|
33
|
+
* all copies or substantial portions of the Software.
|
|
34
|
+
*
|
|
35
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
36
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
37
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
38
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
39
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
40
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
41
|
+
* THE SOFTWARE.
|
|
42
|
+
*
|
|
43
|
+
* @internal
|
|
44
|
+
*/
|
|
45
|
+
function isBytes(a) {
|
|
46
|
+
// Plain `instanceof Uint8Array` is too strict for some Buffer / proxy /
|
|
47
|
+
// cross-realm cases. The fallback still requires a real ArrayBuffer view
|
|
48
|
+
// so plain JSON-deserialized `{ constructor: ... }`
|
|
49
|
+
// spoofing is rejected, and `BYTES_PER_ELEMENT === 1` keeps the fallback on byte-oriented views.
|
|
50
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in a && a.BYTES_PER_ELEMENT === 1;
|
|
51
|
+
}
|
|
52
|
+
const atitle = title => title ? `"${title}" ` : "";
|
|
53
|
+
function abool(value, title = "") {
|
|
54
|
+
if (typeof value !== "boolean") {
|
|
55
|
+
throw new TypeError(atitle(title) + "expected boolean, got type=" + typeof value);
|
|
56
|
+
}
|
|
57
|
+
return value;
|
|
58
|
+
}
|
|
59
|
+
function anumber(n, title = "") {
|
|
60
|
+
if (typeof n !== "number") {
|
|
61
|
+
throw new TypeError(atitle(title) + "expected number, got " + typeof n);
|
|
62
|
+
}
|
|
63
|
+
if (!Number.isSafeInteger(n) || n < 0) {
|
|
64
|
+
throw new RangeError(atitle(title) + "expected integer >= 0, got " + n);
|
|
65
|
+
}
|
|
66
|
+
return n;
|
|
67
|
+
}
|
|
68
|
+
function abytes(value, length, title = "") {
|
|
69
|
+
// Success path first: this runs at the start of every update() / digestInto(), and the
|
|
70
|
+
// common `abytes(data)` form must not pay for length handling it does not use.
|
|
71
|
+
if (isBytes(value) && (length === undefined || value.length === length)) {
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
// Error path: recompute freely to build the exact message.
|
|
75
|
+
if (length !== undefined) anumber(length, "length");
|
|
76
|
+
const bytes = isBytes(value);
|
|
77
|
+
const ofLen = length !== undefined ? ` of length ${length}` : "";
|
|
78
|
+
const got = bytes ? `length=${value.length}` : `type=${typeof value}`;
|
|
79
|
+
const message = atitle(title) + "expected Uint8Array" + ofLen + ", got " + got;
|
|
80
|
+
if (!bytes) throw new TypeError(message);
|
|
81
|
+
throw new RangeError(message);
|
|
82
|
+
}
|
|
83
|
+
const aobject = (value, label) => {
|
|
84
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
85
|
+
throw new TypeError(label === "object" ? "expected valid options object" : `"${label}" expected object, got type=${typeof value}`);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function checkOpts(defaults, opts) {
|
|
89
|
+
aobject(defaults, "defaults");
|
|
90
|
+
aobject(opts, "opts");
|
|
91
|
+
// Mutates defaults by design. __proto__ follows Object.assign semantics here and can only
|
|
92
|
+
// affect this local option object; callers already control this low-level options surface.
|
|
93
|
+
const merged = Object.assign(defaults, opts);
|
|
94
|
+
return merged;
|
|
95
|
+
}
|
|
96
|
+
function aexists(instance, checkFinished = true) {
|
|
97
|
+
// Runs on every update()/digestInto(); the flags are library-owned booleans, so only their
|
|
98
|
+
// truthiness is checked - re-validating their type per call was pure hot-path overhead.
|
|
99
|
+
if (instance.destroyed) throw new Error("hash was destroyed");
|
|
100
|
+
if (checkFinished && instance.finished) throw new Error("digest() was already called");
|
|
101
|
+
}
|
|
102
|
+
function aoutput(out, instance) {
|
|
103
|
+
abytes(out, undefined, "output");
|
|
104
|
+
// `outputLen` is a library-owned readonly number; the negated comparison keeps failing fast
|
|
105
|
+
// when it is missing/NaN (comparisons with undefined/NaN are false) without an anumber() call.
|
|
106
|
+
const min = instance.outputLen;
|
|
107
|
+
if (!(out.length >= min)) {
|
|
108
|
+
throw new RangeError("\"output\" expected length >= " + min);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function u32(arr) {
|
|
112
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
113
|
+
}
|
|
114
|
+
function clean(...arrays) {
|
|
115
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
116
|
+
arrays[i].fill(0);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function createView(arr) {
|
|
120
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
121
|
+
}
|
|
122
|
+
const isLE = /* @__PURE__ */(() => new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();
|
|
123
|
+
function byteSwap(word) {
|
|
124
|
+
return word << 24 & 0xff000000 | word << 8 & 0xff0000 | word >>> 8 & 0xff00 | word >>> 24 & 0xff;
|
|
125
|
+
}
|
|
126
|
+
function byteSwap32(arr) {
|
|
127
|
+
for (let i = 0; i < arr.length; i++) {
|
|
128
|
+
arr[i] = byteSwap(arr[i]);
|
|
129
|
+
}
|
|
130
|
+
return arr;
|
|
131
|
+
}
|
|
132
|
+
const swap32IfBE = isLE ? u => u : byteSwap32;
|
|
133
|
+
function overlapBytes(a, b) {
|
|
134
|
+
// Zero-length views cannot overwrite anything, even if their offset sits inside another range.
|
|
135
|
+
if (!a.byteLength || !b.byteLength) return false;
|
|
136
|
+
return a.buffer === b.buffer &&
|
|
137
|
+
// best we can do, may fail with an obscure Proxy
|
|
138
|
+
a.byteOffset < b.byteOffset + b.byteLength &&
|
|
139
|
+
// a starts before b end
|
|
140
|
+
b.byteOffset < a.byteOffset + a.byteLength // b starts before a end
|
|
141
|
+
;
|
|
142
|
+
}
|
|
143
|
+
function complexOverlapBytes(input, output) {
|
|
144
|
+
// This is very cursed. It works somehow, but I'm completely unsure,
|
|
145
|
+
// reasoning about overlapping aligned windows is very hard.
|
|
146
|
+
if (overlapBytes(input, output) && input.byteOffset < output.byteOffset) {
|
|
147
|
+
throw new Error("complex overlap of input and output is not supported");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function equalBytes(a, b) {
|
|
151
|
+
a = abytes(a);
|
|
152
|
+
b = abytes(b);
|
|
153
|
+
if (a.length !== b.length) return false;
|
|
154
|
+
let diff = 0;
|
|
155
|
+
for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
|
|
156
|
+
return diff === 0;
|
|
157
|
+
}
|
|
158
|
+
function getOutput(expectedLength, out, onlyAligned = true) {
|
|
159
|
+
if (out === undefined) return new Uint8Array(expectedLength);
|
|
160
|
+
// Keep Buffer/cross-realm Uint8Array support here instead of trusting a shape-compatible object.
|
|
161
|
+
abytes(out, expectedLength, "output");
|
|
162
|
+
if (onlyAligned && !isAligned32(out)) throw new Error("invalid output, must be aligned");
|
|
163
|
+
return out;
|
|
164
|
+
}
|
|
165
|
+
function u64Lengths(dataLength, aadLength, isLE) {
|
|
166
|
+
// Reject coercible non-number lengths like '10' and true before BigInt(...) accepts them.
|
|
167
|
+
anumber(dataLength);
|
|
168
|
+
anumber(aadLength);
|
|
169
|
+
abool(isLE);
|
|
170
|
+
const num = new Uint8Array(16);
|
|
171
|
+
const view = createView(num);
|
|
172
|
+
view.setBigUint64(0, BigInt(aadLength), isLE);
|
|
173
|
+
view.setBigUint64(8, BigInt(dataLength), isLE);
|
|
174
|
+
return num;
|
|
175
|
+
}
|
|
176
|
+
function isAligned32(bytes) {
|
|
177
|
+
return bytes.byteOffset % 4 === 0;
|
|
178
|
+
}
|
|
179
|
+
function copyBytes(bytes) {
|
|
180
|
+
// `Uint8Array.from(...)` would also accept arrays / other typed arrays. Keep this helper strict
|
|
181
|
+
// because callers use it at byte-validation boundaries before mutating the detached copy.
|
|
182
|
+
return Uint8Array.from(abytes(bytes));
|
|
183
|
+
}
|
|
184
|
+
// _arx.ts
|
|
185
|
+
// Replaces `TextEncoder` for ASCII literals, which is enough for sigma constants.
|
|
186
|
+
// Non-ASCII input would not match UTF-8 `TextEncoder` output.
|
|
187
|
+
const encodeStr = str => Uint8Array.from(str.split(""), c => c.charCodeAt(0));
|
|
188
|
+
// Raw `createCipher(...)` exports consume these native-endian `u32(...)` views directly.
|
|
189
|
+
// RFC 8439 §2.3 / RFC 7539 §2.3 only define the 256-bit-key constants; this 16-byte sigma is
|
|
190
|
+
// kept for legacy allowShortKeys Salsa/ChaCha variants.
|
|
191
|
+
const sigma16_32 = /* @__PURE__ */(() => swap32IfBE(u32(encodeStr("expand 16-byte k"))))();
|
|
192
|
+
// RFC 8439 §2.3 / RFC 7539 §2.3 define words 0-3 as
|
|
193
|
+
// `0x61707865 0x3320646e 0x79622d32 0x6b206574`, i.e. `expand 32-byte k`.
|
|
194
|
+
const sigma32_32 = /* @__PURE__ */(() => swap32IfBE(u32(encodeStr("expand 32-byte k"))))();
|
|
195
|
+
function rotl(a, b) {
|
|
196
|
+
return a << b | a >>> 32 - b;
|
|
197
|
+
}
|
|
198
|
+
// Salsa and Chacha block length is always 512-bit
|
|
199
|
+
const BLOCK_LEN = 64;
|
|
200
|
+
// RFC 8439 §2.2 / RFC 7539 §2.2: the ChaCha state has 16 32-bit words.
|
|
201
|
+
const BLOCK_LEN32 = 16;
|
|
202
|
+
// Counter policy for the shared public `counter` argument:
|
|
203
|
+
// - RFC/IETF ChaCha20 uses a 32-bit counter.
|
|
204
|
+
// - OpenSSL/Node `chacha20` instead treat the full 16-byte IV as a 128-bit
|
|
205
|
+
// counter state and carry into the next word.
|
|
206
|
+
// - Raw `chacha20orig`, `salsa20`, `xsalsa20`, and `xchacha20` use 64-bit counters in libsodium
|
|
207
|
+
// and libtomcrypt, while some libs (for example libtomcrypt's RFC/IETF path) reject the max
|
|
208
|
+
// boundary instead of carrying.
|
|
209
|
+
// - AEAD wrappers diverge too: libsodium `xchacha20poly1305` uses the IETF payload counter from
|
|
210
|
+
// block 1, while `secretstream_xchacha20poly1305` is a different protocol with rekey/reset.
|
|
211
|
+
// Noble intentionally throws instead of silently picking one wrap model for users. In the default
|
|
212
|
+
// path, even a 32-bit boundary would take 2^32 blocks * 64 bytes = 256 GiB, which is practically
|
|
213
|
+
// unreachable for normal JS callers; advanced users who pass `counter` explicitly can implement
|
|
214
|
+
// whatever wider carry / wrap policy they need on top.
|
|
215
|
+
const MAX_COUNTER = /* @__PURE__ */(() => 2 ** 32 - 1)();
|
|
216
|
+
const U32_EMPTY = /* @__PURE__ */Uint32Array.of();
|
|
217
|
+
function runCipher(core, sigma, key, nonce, data, output, counter, rounds) {
|
|
218
|
+
const len = data.length;
|
|
219
|
+
const block = new Uint8Array(BLOCK_LEN);
|
|
220
|
+
const b32 = u32(block);
|
|
221
|
+
// Make sure that buffers aligned to 4 bytes
|
|
222
|
+
const isAligned = isLE && isAligned32(data) && isAligned32(output);
|
|
223
|
+
const d32 = isAligned ? u32(data) : U32_EMPTY;
|
|
224
|
+
const o32 = isAligned ? u32(output) : U32_EMPTY;
|
|
225
|
+
// RFC 8439 §2.4.1 / RFC 7539 §2.4.1 allow XORing one keystream block at a time and
|
|
226
|
+
// truncating the final partial block instead of materializing the whole keystream.
|
|
227
|
+
if (!isLE) {
|
|
228
|
+
for (let pos = 0; pos < len; counter++) {
|
|
229
|
+
core(sigma, key, nonce, b32, counter, rounds);
|
|
230
|
+
// RFC 8439 §2.4 / RFC 7539 §2.4 serialize keystream words in little-endian order.
|
|
231
|
+
swap32IfBE(b32);
|
|
232
|
+
if (counter >= MAX_COUNTER) throw new Error("arx: counter overflow");
|
|
233
|
+
const take = Math.min(BLOCK_LEN, len - pos);
|
|
234
|
+
for (let j = 0, posj; j < take; j++) {
|
|
235
|
+
posj = pos + j;
|
|
236
|
+
output[posj] = data[posj] ^ block[j];
|
|
237
|
+
}
|
|
238
|
+
pos += take;
|
|
239
|
+
}
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
for (let pos = 0; pos < len; counter++) {
|
|
243
|
+
core(sigma, key, nonce, b32, counter, rounds);
|
|
244
|
+
// See MAX_COUNTER policy note above: never silently wrap the shared public counter.
|
|
245
|
+
if (counter >= MAX_COUNTER) throw new Error("arx: counter overflow");
|
|
246
|
+
const take = Math.min(BLOCK_LEN, len - pos);
|
|
247
|
+
// aligned to 4 bytes
|
|
248
|
+
if (isAligned && take === BLOCK_LEN) {
|
|
249
|
+
const pos32 = pos / 4;
|
|
250
|
+
if (pos % 4 !== 0) throw new Error("arx: invalid block position");
|
|
251
|
+
for (let j = 0, posj; j < BLOCK_LEN32; j++) {
|
|
252
|
+
posj = pos32 + j;
|
|
253
|
+
o32[posj] = d32[posj] ^ b32[j];
|
|
254
|
+
}
|
|
255
|
+
pos += BLOCK_LEN;
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
for (let j = 0, posj; j < take; j++) {
|
|
259
|
+
posj = pos + j;
|
|
260
|
+
output[posj] = data[posj] ^ block[j];
|
|
261
|
+
}
|
|
262
|
+
pos += take;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function createCipher(core, opts) {
|
|
266
|
+
const {
|
|
267
|
+
allowShortKeys,
|
|
268
|
+
extendNonceFn,
|
|
269
|
+
counterLength,
|
|
270
|
+
counterRight,
|
|
271
|
+
rounds
|
|
272
|
+
} = checkOpts({
|
|
273
|
+
allowShortKeys: false,
|
|
274
|
+
counterLength: 8,
|
|
275
|
+
counterRight: false,
|
|
276
|
+
rounds: 20
|
|
277
|
+
}, opts);
|
|
278
|
+
if (typeof core !== "function") throw new Error("core must be a function");
|
|
279
|
+
anumber(counterLength);
|
|
280
|
+
anumber(rounds);
|
|
281
|
+
abool(counterRight);
|
|
282
|
+
abool(allowShortKeys);
|
|
283
|
+
return (key, nonce, data, output, counter = 0) => {
|
|
284
|
+
abytes(key, undefined, "key");
|
|
285
|
+
abytes(nonce, undefined, "nonce");
|
|
286
|
+
abytes(data, undefined, "data");
|
|
287
|
+
const len = data.length;
|
|
288
|
+
// Raw XorStream APIs return ciphertext/plaintext bytes directly, so caller-provided outputs
|
|
289
|
+
// must match the logical result length exactly instead of returning an oversized workspace.
|
|
290
|
+
const hasOutput = output !== undefined;
|
|
291
|
+
output = getOutput(len, output, false);
|
|
292
|
+
if (hasOutput) complexOverlapBytes(data, output);
|
|
293
|
+
anumber(counter);
|
|
294
|
+
// See MAX_COUNTER policy note above: reject advanced explicit-counter requests before any wrap.
|
|
295
|
+
if (counter < 0 || counter >= MAX_COUNTER) throw new Error("arx: counter overflow");
|
|
296
|
+
const toClean = [];
|
|
297
|
+
// Key & sigma
|
|
298
|
+
// key=16 -> sigma16, k=key|key
|
|
299
|
+
// key=32 -> sigma32, k=key
|
|
300
|
+
let l = key.length;
|
|
301
|
+
let k;
|
|
302
|
+
let sigma;
|
|
303
|
+
if (l === 32) {
|
|
304
|
+
// Copy caller keys too: big-endian normalization, extended-nonce subkey derivation, and
|
|
305
|
+
// final clean(...) all mutate or wipe the temporary buffer in place.
|
|
306
|
+
toClean.push(k = copyBytes(key));
|
|
307
|
+
sigma = sigma32_32;
|
|
308
|
+
} else if (l === 16 && allowShortKeys) {
|
|
309
|
+
k = new Uint8Array(32);
|
|
310
|
+
k.set(key);
|
|
311
|
+
k.set(key, 16);
|
|
312
|
+
sigma = sigma16_32;
|
|
313
|
+
toClean.push(k);
|
|
314
|
+
} else {
|
|
315
|
+
abytes(key, 32, "arx key");
|
|
316
|
+
throw new Error("invalid key size");
|
|
317
|
+
// throw new Error(`"arx key" expected Uint8Array of length 32, got length=${l}`);
|
|
318
|
+
}
|
|
319
|
+
// Nonce
|
|
320
|
+
// salsa20: 8 (8-byte counter)
|
|
321
|
+
// chacha20orig: 8 (8-byte counter)
|
|
322
|
+
// chacha20: 12 (4-byte counter)
|
|
323
|
+
// xsalsa20: 24 (16 -> hsalsa, 8 -> old nonce)
|
|
324
|
+
// xchacha20: 24 (16 -> hchacha, 8 -> old nonce)
|
|
325
|
+
// Copy before taking u32(...) views on misaligned inputs, and on big-endian so later
|
|
326
|
+
// swap32IfBE(...) never mutates caller nonce bytes in place.
|
|
327
|
+
if (!isLE || !isAligned32(nonce)) toClean.push(nonce = copyBytes(nonce));
|
|
328
|
+
let k32 = u32(k);
|
|
329
|
+
// hsalsa & hchacha: handle extended nonce
|
|
330
|
+
if (extendNonceFn) {
|
|
331
|
+
if (nonce.length !== 24) throw new Error("arx: extended nonce must be 24 bytes");
|
|
332
|
+
const n16 = nonce.subarray(0, 16);
|
|
333
|
+
if (isLE) extendNonceFn(sigma, k32, u32(n16), k32);else {
|
|
334
|
+
const sigmaRaw = swap32IfBE(Uint32Array.from(sigma));
|
|
335
|
+
extendNonceFn(sigmaRaw, k32, u32(n16), k32);
|
|
336
|
+
clean(sigmaRaw);
|
|
337
|
+
swap32IfBE(k32);
|
|
338
|
+
}
|
|
339
|
+
nonce = nonce.subarray(16);
|
|
340
|
+
} else if (!isLE) swap32IfBE(k32);
|
|
341
|
+
// Handle nonce counter
|
|
342
|
+
const nonceNcLen = 16 - counterLength;
|
|
343
|
+
if (nonceNcLen !== nonce.length) {
|
|
344
|
+
throw new Error(`arx: nonce must be ${nonceNcLen} or 16 bytes`);
|
|
345
|
+
}
|
|
346
|
+
// Normalize 64-bit-nonce layouts to the 12-byte core input: ChaCha/XChaCha prefix 4 zero
|
|
347
|
+
// counter bytes, while Salsa/XSalsa append them after the nonce words.
|
|
348
|
+
if (nonceNcLen !== 12) {
|
|
349
|
+
const nc = new Uint8Array(12);
|
|
350
|
+
nc.set(nonce, counterRight ? 0 : 12 - nonce.length);
|
|
351
|
+
nonce = nc;
|
|
352
|
+
toClean.push(nonce);
|
|
353
|
+
}
|
|
354
|
+
const n32 = swap32IfBE(u32(nonce));
|
|
355
|
+
// Ensure temporary key/nonce copies are wiped even if the remaining
|
|
356
|
+
// runtime guard in runCipher(...) throws on counter overflow.
|
|
357
|
+
try {
|
|
358
|
+
runCipher(core, sigma, k32, n32, data, output, counter, rounds);
|
|
359
|
+
return output;
|
|
360
|
+
} finally {
|
|
361
|
+
clean(...toClean);
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
// _poly1305.ts
|
|
366
|
+
// Little-endian 2-byte load used by the Poly1305 limb decomposition.
|
|
367
|
+
function u8to16(a, i) {
|
|
368
|
+
return a[i++] & 0xff | (a[i++] & 0xff) << 8;
|
|
369
|
+
}
|
|
370
|
+
class Poly1305 {
|
|
371
|
+
blockLen = 16;
|
|
372
|
+
outputLen = 16;
|
|
373
|
+
buffer = /*#__PURE__*/new Uint8Array(16);
|
|
374
|
+
r = /*#__PURE__*/new Uint16Array(10); // Allocating 1 array with .subarray() here is slower than 3
|
|
375
|
+
h = /*#__PURE__*/new Uint16Array(10);
|
|
376
|
+
pad = /*#__PURE__*/new Uint16Array(8);
|
|
377
|
+
pos = 0;
|
|
378
|
+
finished = false;
|
|
379
|
+
destroyed = false;
|
|
380
|
+
// Can be speed-up using BigUint64Array, at the cost of complexity
|
|
381
|
+
constructor(key) {
|
|
382
|
+
key = copyBytes(abytes(key, 32, "key"));
|
|
383
|
+
const t0 = u8to16(key, 0);
|
|
384
|
+
const t1 = u8to16(key, 2);
|
|
385
|
+
const t2 = u8to16(key, 4);
|
|
386
|
+
const t3 = u8to16(key, 6);
|
|
387
|
+
const t4 = u8to16(key, 8);
|
|
388
|
+
const t5 = u8to16(key, 10);
|
|
389
|
+
const t6 = u8to16(key, 12);
|
|
390
|
+
const t7 = u8to16(key, 14);
|
|
391
|
+
// RFC 8439 §2.5.1 / RFC 7539 §2.5.1 clamp r before multiplication.
|
|
392
|
+
// These masks unpack that clamped value into 13-bit limbs, while pad
|
|
393
|
+
// keeps the raw s half for finalize().
|
|
394
|
+
// {@link https://github.com/floodyberry/poly1305-donna/blob/e6ad6e091d30d7f4ec2d4f978be1fcfcbce72781/poly1305-donna-16.h#L47 | poly1305-donna reference}
|
|
395
|
+
this.r[0] = t0 & 0x1fff;
|
|
396
|
+
this.r[1] = (t0 >>> 13 | t1 << 3) & 0x1fff;
|
|
397
|
+
this.r[2] = (t1 >>> 10 | t2 << 6) & 0x1f03;
|
|
398
|
+
this.r[3] = (t2 >>> 7 | t3 << 9) & 0x1fff;
|
|
399
|
+
this.r[4] = (t3 >>> 4 | t4 << 12) & 0x00ff;
|
|
400
|
+
this.r[5] = t4 >>> 1 & 0x1ffe;
|
|
401
|
+
this.r[6] = (t4 >>> 14 | t5 << 2) & 0x1fff;
|
|
402
|
+
this.r[7] = (t5 >>> 11 | t6 << 5) & 0x1f81;
|
|
403
|
+
this.r[8] = (t6 >>> 8 | t7 << 8) & 0x1fff;
|
|
404
|
+
this.r[9] = t7 >>> 5 & 0x007f;
|
|
405
|
+
for (let i = 0; i < 8; i++) this.pad[i] = u8to16(key, 16 + 2 * i);
|
|
406
|
+
}
|
|
407
|
+
process(data, offset, isLast = false) {
|
|
408
|
+
// RFC 8439 §2.5 / §2.5.1 and RFC 7539 §2.5 / §2.5.1 add an extra high
|
|
409
|
+
// bit to every full 16-byte block. The final partial block gets its
|
|
410
|
+
// explicit `1` byte during digestInto(), so `hibit` stays zero there.
|
|
411
|
+
const hibit = isLast ? 0 : 1 << 11;
|
|
412
|
+
const {
|
|
413
|
+
h,
|
|
414
|
+
r
|
|
415
|
+
} = this;
|
|
416
|
+
const r0 = r[0];
|
|
417
|
+
const r1 = r[1];
|
|
418
|
+
const r2 = r[2];
|
|
419
|
+
const r3 = r[3];
|
|
420
|
+
const r4 = r[4];
|
|
421
|
+
const r5 = r[5];
|
|
422
|
+
const r6 = r[6];
|
|
423
|
+
const r7 = r[7];
|
|
424
|
+
const r8 = r[8];
|
|
425
|
+
const r9 = r[9];
|
|
426
|
+
const t0 = u8to16(data, offset + 0);
|
|
427
|
+
const t1 = u8to16(data, offset + 2);
|
|
428
|
+
const t2 = u8to16(data, offset + 4);
|
|
429
|
+
const t3 = u8to16(data, offset + 6);
|
|
430
|
+
const t4 = u8to16(data, offset + 8);
|
|
431
|
+
const t5 = u8to16(data, offset + 10);
|
|
432
|
+
const t6 = u8to16(data, offset + 12);
|
|
433
|
+
const t7 = u8to16(data, offset + 14);
|
|
434
|
+
let h0 = h[0] + (t0 & 0x1fff);
|
|
435
|
+
let h1 = h[1] + ((t0 >>> 13 | t1 << 3) & 0x1fff);
|
|
436
|
+
let h2 = h[2] + ((t1 >>> 10 | t2 << 6) & 0x1fff);
|
|
437
|
+
let h3 = h[3] + ((t2 >>> 7 | t3 << 9) & 0x1fff);
|
|
438
|
+
let h4 = h[4] + ((t3 >>> 4 | t4 << 12) & 0x1fff);
|
|
439
|
+
let h5 = h[5] + (t4 >>> 1 & 0x1fff);
|
|
440
|
+
let h6 = h[6] + ((t4 >>> 14 | t5 << 2) & 0x1fff);
|
|
441
|
+
let h7 = h[7] + ((t5 >>> 11 | t6 << 5) & 0x1fff);
|
|
442
|
+
let h8 = h[8] + ((t6 >>> 8 | t7 << 8) & 0x1fff);
|
|
443
|
+
let h9 = h[9] + (t7 >>> 5 | hibit);
|
|
444
|
+
let c = 0;
|
|
445
|
+
let d0 = c + h0 * r0 + h1 * (5 * r9) + h2 * (5 * r8) + h3 * (5 * r7) + h4 * (5 * r6);
|
|
446
|
+
c = d0 >>> 13;
|
|
447
|
+
d0 &= 0x1fff;
|
|
448
|
+
d0 += h5 * (5 * r5) + h6 * (5 * r4) + h7 * (5 * r3) + h8 * (5 * r2) + h9 * (5 * r1);
|
|
449
|
+
c += d0 >>> 13;
|
|
450
|
+
d0 &= 0x1fff;
|
|
451
|
+
let d1 = c + h0 * r1 + h1 * r0 + h2 * (5 * r9) + h3 * (5 * r8) + h4 * (5 * r7);
|
|
452
|
+
c = d1 >>> 13;
|
|
453
|
+
d1 &= 0x1fff;
|
|
454
|
+
d1 += h5 * (5 * r6) + h6 * (5 * r5) + h7 * (5 * r4) + h8 * (5 * r3) + h9 * (5 * r2);
|
|
455
|
+
c += d1 >>> 13;
|
|
456
|
+
d1 &= 0x1fff;
|
|
457
|
+
let d2 = c + h0 * r2 + h1 * r1 + h2 * r0 + h3 * (5 * r9) + h4 * (5 * r8);
|
|
458
|
+
c = d2 >>> 13;
|
|
459
|
+
d2 &= 0x1fff;
|
|
460
|
+
d2 += h5 * (5 * r7) + h6 * (5 * r6) + h7 * (5 * r5) + h8 * (5 * r4) + h9 * (5 * r3);
|
|
461
|
+
c += d2 >>> 13;
|
|
462
|
+
d2 &= 0x1fff;
|
|
463
|
+
let d3 = c + h0 * r3 + h1 * r2 + h2 * r1 + h3 * r0 + h4 * (5 * r9);
|
|
464
|
+
c = d3 >>> 13;
|
|
465
|
+
d3 &= 0x1fff;
|
|
466
|
+
d3 += h5 * (5 * r8) + h6 * (5 * r7) + h7 * (5 * r6) + h8 * (5 * r5) + h9 * (5 * r4);
|
|
467
|
+
c += d3 >>> 13;
|
|
468
|
+
d3 &= 0x1fff;
|
|
469
|
+
let d4 = c + h0 * r4 + h1 * r3 + h2 * r2 + h3 * r1 + h4 * r0;
|
|
470
|
+
c = d4 >>> 13;
|
|
471
|
+
d4 &= 0x1fff;
|
|
472
|
+
d4 += h5 * (5 * r9) + h6 * (5 * r8) + h7 * (5 * r7) + h8 * (5 * r6) + h9 * (5 * r5);
|
|
473
|
+
c += d4 >>> 13;
|
|
474
|
+
d4 &= 0x1fff;
|
|
475
|
+
let d5 = c + h0 * r5 + h1 * r4 + h2 * r3 + h3 * r2 + h4 * r1;
|
|
476
|
+
c = d5 >>> 13;
|
|
477
|
+
d5 &= 0x1fff;
|
|
478
|
+
d5 += h5 * r0 + h6 * (5 * r9) + h7 * (5 * r8) + h8 * (5 * r7) + h9 * (5 * r6);
|
|
479
|
+
c += d5 >>> 13;
|
|
480
|
+
d5 &= 0x1fff;
|
|
481
|
+
let d6 = c + h0 * r6 + h1 * r5 + h2 * r4 + h3 * r3 + h4 * r2;
|
|
482
|
+
c = d6 >>> 13;
|
|
483
|
+
d6 &= 0x1fff;
|
|
484
|
+
d6 += h5 * r1 + h6 * r0 + h7 * (5 * r9) + h8 * (5 * r8) + h9 * (5 * r7);
|
|
485
|
+
c += d6 >>> 13;
|
|
486
|
+
d6 &= 0x1fff;
|
|
487
|
+
let d7 = c + h0 * r7 + h1 * r6 + h2 * r5 + h3 * r4 + h4 * r3;
|
|
488
|
+
c = d7 >>> 13;
|
|
489
|
+
d7 &= 0x1fff;
|
|
490
|
+
d7 += h5 * r2 + h6 * r1 + h7 * r0 + h8 * (5 * r9) + h9 * (5 * r8);
|
|
491
|
+
c += d7 >>> 13;
|
|
492
|
+
d7 &= 0x1fff;
|
|
493
|
+
let d8 = c + h0 * r8 + h1 * r7 + h2 * r6 + h3 * r5 + h4 * r4;
|
|
494
|
+
c = d8 >>> 13;
|
|
495
|
+
d8 &= 0x1fff;
|
|
496
|
+
d8 += h5 * r3 + h6 * r2 + h7 * r1 + h8 * r0 + h9 * (5 * r9);
|
|
497
|
+
c += d8 >>> 13;
|
|
498
|
+
d8 &= 0x1fff;
|
|
499
|
+
let d9 = c + h0 * r9 + h1 * r8 + h2 * r7 + h3 * r6 + h4 * r5;
|
|
500
|
+
c = d9 >>> 13;
|
|
501
|
+
d9 &= 0x1fff;
|
|
502
|
+
d9 += h5 * r4 + h6 * r3 + h7 * r2 + h8 * r1 + h9 * r0;
|
|
503
|
+
c += d9 >>> 13;
|
|
504
|
+
d9 &= 0x1fff;
|
|
505
|
+
c = (c << 2) + c | 0;
|
|
506
|
+
c = c + d0 | 0;
|
|
507
|
+
d0 = c & 0x1fff;
|
|
508
|
+
c = c >>> 13;
|
|
509
|
+
d1 += c;
|
|
510
|
+
h[0] = d0;
|
|
511
|
+
h[1] = d1;
|
|
512
|
+
h[2] = d2;
|
|
513
|
+
h[3] = d3;
|
|
514
|
+
h[4] = d4;
|
|
515
|
+
h[5] = d5;
|
|
516
|
+
h[6] = d6;
|
|
517
|
+
h[7] = d7;
|
|
518
|
+
h[8] = d8;
|
|
519
|
+
h[9] = d9;
|
|
520
|
+
}
|
|
521
|
+
finalize() {
|
|
522
|
+
const {
|
|
523
|
+
h,
|
|
524
|
+
pad
|
|
525
|
+
} = this;
|
|
526
|
+
const g = new Uint16Array(10);
|
|
527
|
+
let c = h[1] >>> 13;
|
|
528
|
+
h[1] &= 0x1fff;
|
|
529
|
+
for (let i = 2; i < 10; i++) {
|
|
530
|
+
h[i] += c;
|
|
531
|
+
c = h[i] >>> 13;
|
|
532
|
+
h[i] &= 0x1fff;
|
|
533
|
+
}
|
|
534
|
+
h[0] += c * 5;
|
|
535
|
+
c = h[0] >>> 13;
|
|
536
|
+
h[0] &= 0x1fff;
|
|
537
|
+
h[1] += c;
|
|
538
|
+
c = h[1] >>> 13;
|
|
539
|
+
h[1] &= 0x1fff;
|
|
540
|
+
h[2] += c;
|
|
541
|
+
// RFC 8439 §2.5 / RFC 7539 §2.5 reduce modulo 2^130-5 before repacking
|
|
542
|
+
// to 16-bit words and adding the raw s half.
|
|
543
|
+
g[0] = h[0] + 5;
|
|
544
|
+
c = g[0] >>> 13;
|
|
545
|
+
g[0] &= 0x1fff;
|
|
546
|
+
for (let i = 1; i < 10; i++) {
|
|
547
|
+
g[i] = h[i] + c;
|
|
548
|
+
c = g[i] >>> 13;
|
|
549
|
+
g[i] &= 0x1fff;
|
|
550
|
+
}
|
|
551
|
+
g[9] -= 1 << 13;
|
|
552
|
+
let mask = (c ^ 1) - 1;
|
|
553
|
+
for (let i = 0; i < 10; i++) g[i] &= mask;
|
|
554
|
+
mask = ~mask;
|
|
555
|
+
for (let i = 0; i < 10; i++) h[i] = h[i] & mask | g[i];
|
|
556
|
+
h[0] = (h[0] | h[1] << 13) & 0xffff;
|
|
557
|
+
h[1] = (h[1] >>> 3 | h[2] << 10) & 0xffff;
|
|
558
|
+
h[2] = (h[2] >>> 6 | h[3] << 7) & 0xffff;
|
|
559
|
+
h[3] = (h[3] >>> 9 | h[4] << 4) & 0xffff;
|
|
560
|
+
h[4] = (h[4] >>> 12 | h[5] << 1 | h[6] << 14) & 0xffff;
|
|
561
|
+
h[5] = (h[6] >>> 2 | h[7] << 11) & 0xffff;
|
|
562
|
+
h[6] = (h[7] >>> 5 | h[8] << 8) & 0xffff;
|
|
563
|
+
h[7] = (h[8] >>> 8 | h[9] << 5) & 0xffff;
|
|
564
|
+
let f = h[0] + pad[0];
|
|
565
|
+
h[0] = f & 0xffff;
|
|
566
|
+
for (let i = 1; i < 8; i++) {
|
|
567
|
+
f = (h[i] + pad[i] | 0) + (f >>> 16) | 0;
|
|
568
|
+
h[i] = f & 0xffff;
|
|
569
|
+
}
|
|
570
|
+
clean(g);
|
|
571
|
+
}
|
|
572
|
+
update(data) {
|
|
573
|
+
aexists(this);
|
|
574
|
+
abytes(data);
|
|
575
|
+
data = copyBytes(data);
|
|
576
|
+
const {
|
|
577
|
+
buffer,
|
|
578
|
+
blockLen
|
|
579
|
+
} = this;
|
|
580
|
+
const len = data.length;
|
|
581
|
+
for (let pos = 0; pos < len;) {
|
|
582
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
583
|
+
// Fast path: we have at least one block in input
|
|
584
|
+
if (take === blockLen) {
|
|
585
|
+
for (; blockLen <= len - pos; pos += blockLen) this.process(data, pos);
|
|
586
|
+
continue;
|
|
587
|
+
}
|
|
588
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
589
|
+
this.pos += take;
|
|
590
|
+
pos += take;
|
|
591
|
+
if (this.pos === blockLen) {
|
|
592
|
+
this.process(buffer, 0, false);
|
|
593
|
+
this.pos = 0;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
return this;
|
|
597
|
+
}
|
|
598
|
+
destroy() {
|
|
599
|
+
// `aexists(this)` guards update/digest paths, so destroy must mark the instance unusable too.
|
|
600
|
+
this.destroyed = true;
|
|
601
|
+
clean(this.h, this.r, this.buffer, this.pad);
|
|
602
|
+
}
|
|
603
|
+
digestInto(out) {
|
|
604
|
+
aexists(this);
|
|
605
|
+
aoutput(out, this);
|
|
606
|
+
this.finished = true;
|
|
607
|
+
const {
|
|
608
|
+
buffer,
|
|
609
|
+
h
|
|
610
|
+
} = this;
|
|
611
|
+
let {
|
|
612
|
+
pos
|
|
613
|
+
} = this;
|
|
614
|
+
if (pos) {
|
|
615
|
+
// RFC 8439 §2.5 / RFC 7539 §2.5: the final short block appends a
|
|
616
|
+
// single `0x01` byte and zero-fills the remaining bytes before the
|
|
617
|
+
// last multiplication step.
|
|
618
|
+
buffer[pos++] = 1;
|
|
619
|
+
for (; pos < 16; pos++) buffer[pos] = 0;
|
|
620
|
+
this.process(buffer, 0, true);
|
|
621
|
+
}
|
|
622
|
+
this.finalize();
|
|
623
|
+
let opos = 0;
|
|
624
|
+
for (let i = 0; i < 8; i++) {
|
|
625
|
+
out[opos++] = h[i] >>> 0;
|
|
626
|
+
out[opos++] = h[i] >>> 8;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
digest() {
|
|
630
|
+
const {
|
|
631
|
+
buffer,
|
|
632
|
+
outputLen
|
|
633
|
+
} = this;
|
|
634
|
+
this.digestInto(buffer);
|
|
635
|
+
// Copy out before destroy() zeroes the internal buffer.
|
|
636
|
+
const res = buffer.slice(0, outputLen);
|
|
637
|
+
this.destroy();
|
|
638
|
+
return res;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
// chacha.ts
|
|
642
|
+
/** RFC 8439 §2.3 block core for `state = constants | key | counter | nonce`. */
|
|
643
|
+
// prettier-ignore
|
|
644
|
+
function chachaCore(s, k, n, out, cnt, rounds = 20) {
|
|
645
|
+
let y00 = s[0],
|
|
646
|
+
y01 = s[1],
|
|
647
|
+
y02 = s[2],
|
|
648
|
+
y03 = s[3],
|
|
649
|
+
// "expa" "nd 3" "2-by" "te k"
|
|
650
|
+
y04 = k[0],
|
|
651
|
+
y05 = k[1],
|
|
652
|
+
y06 = k[2],
|
|
653
|
+
y07 = k[3],
|
|
654
|
+
// Key Key Key Key
|
|
655
|
+
y08 = k[4],
|
|
656
|
+
y09 = k[5],
|
|
657
|
+
y10 = k[6],
|
|
658
|
+
y11 = k[7],
|
|
659
|
+
// Key Key Key Key
|
|
660
|
+
y12 = cnt,
|
|
661
|
+
y13 = n[0],
|
|
662
|
+
y14 = n[1],
|
|
663
|
+
y15 = n[2]; // Counter Nonce Nonce Nonce
|
|
664
|
+
// Save state to temporary variables
|
|
665
|
+
let x00 = y00,
|
|
666
|
+
x01 = y01,
|
|
667
|
+
x02 = y02,
|
|
668
|
+
x03 = y03,
|
|
669
|
+
x04 = y04,
|
|
670
|
+
x05 = y05,
|
|
671
|
+
x06 = y06,
|
|
672
|
+
x07 = y07,
|
|
673
|
+
x08 = y08,
|
|
674
|
+
x09 = y09,
|
|
675
|
+
x10 = y10,
|
|
676
|
+
x11 = y11,
|
|
677
|
+
x12 = y12,
|
|
678
|
+
x13 = y13,
|
|
679
|
+
x14 = y14,
|
|
680
|
+
x15 = y15;
|
|
681
|
+
for (let r = 0; r < rounds; r += 2) {
|
|
682
|
+
x00 = x00 + x04 | 0;
|
|
683
|
+
x12 = rotl(x12 ^ x00, 16);
|
|
684
|
+
x08 = x08 + x12 | 0;
|
|
685
|
+
x04 = rotl(x04 ^ x08, 12);
|
|
686
|
+
x00 = x00 + x04 | 0;
|
|
687
|
+
x12 = rotl(x12 ^ x00, 8);
|
|
688
|
+
x08 = x08 + x12 | 0;
|
|
689
|
+
x04 = rotl(x04 ^ x08, 7);
|
|
690
|
+
x01 = x01 + x05 | 0;
|
|
691
|
+
x13 = rotl(x13 ^ x01, 16);
|
|
692
|
+
x09 = x09 + x13 | 0;
|
|
693
|
+
x05 = rotl(x05 ^ x09, 12);
|
|
694
|
+
x01 = x01 + x05 | 0;
|
|
695
|
+
x13 = rotl(x13 ^ x01, 8);
|
|
696
|
+
x09 = x09 + x13 | 0;
|
|
697
|
+
x05 = rotl(x05 ^ x09, 7);
|
|
698
|
+
x02 = x02 + x06 | 0;
|
|
699
|
+
x14 = rotl(x14 ^ x02, 16);
|
|
700
|
+
x10 = x10 + x14 | 0;
|
|
701
|
+
x06 = rotl(x06 ^ x10, 12);
|
|
702
|
+
x02 = x02 + x06 | 0;
|
|
703
|
+
x14 = rotl(x14 ^ x02, 8);
|
|
704
|
+
x10 = x10 + x14 | 0;
|
|
705
|
+
x06 = rotl(x06 ^ x10, 7);
|
|
706
|
+
x03 = x03 + x07 | 0;
|
|
707
|
+
x15 = rotl(x15 ^ x03, 16);
|
|
708
|
+
x11 = x11 + x15 | 0;
|
|
709
|
+
x07 = rotl(x07 ^ x11, 12);
|
|
710
|
+
x03 = x03 + x07 | 0;
|
|
711
|
+
x15 = rotl(x15 ^ x03, 8);
|
|
712
|
+
x11 = x11 + x15 | 0;
|
|
713
|
+
x07 = rotl(x07 ^ x11, 7);
|
|
714
|
+
x00 = x00 + x05 | 0;
|
|
715
|
+
x15 = rotl(x15 ^ x00, 16);
|
|
716
|
+
x10 = x10 + x15 | 0;
|
|
717
|
+
x05 = rotl(x05 ^ x10, 12);
|
|
718
|
+
x00 = x00 + x05 | 0;
|
|
719
|
+
x15 = rotl(x15 ^ x00, 8);
|
|
720
|
+
x10 = x10 + x15 | 0;
|
|
721
|
+
x05 = rotl(x05 ^ x10, 7);
|
|
722
|
+
x01 = x01 + x06 | 0;
|
|
723
|
+
x12 = rotl(x12 ^ x01, 16);
|
|
724
|
+
x11 = x11 + x12 | 0;
|
|
725
|
+
x06 = rotl(x06 ^ x11, 12);
|
|
726
|
+
x01 = x01 + x06 | 0;
|
|
727
|
+
x12 = rotl(x12 ^ x01, 8);
|
|
728
|
+
x11 = x11 + x12 | 0;
|
|
729
|
+
x06 = rotl(x06 ^ x11, 7);
|
|
730
|
+
x02 = x02 + x07 | 0;
|
|
731
|
+
x13 = rotl(x13 ^ x02, 16);
|
|
732
|
+
x08 = x08 + x13 | 0;
|
|
733
|
+
x07 = rotl(x07 ^ x08, 12);
|
|
734
|
+
x02 = x02 + x07 | 0;
|
|
735
|
+
x13 = rotl(x13 ^ x02, 8);
|
|
736
|
+
x08 = x08 + x13 | 0;
|
|
737
|
+
x07 = rotl(x07 ^ x08, 7);
|
|
738
|
+
x03 = x03 + x04 | 0;
|
|
739
|
+
x14 = rotl(x14 ^ x03, 16);
|
|
740
|
+
x09 = x09 + x14 | 0;
|
|
741
|
+
x04 = rotl(x04 ^ x09, 12);
|
|
742
|
+
x03 = x03 + x04 | 0;
|
|
743
|
+
x14 = rotl(x14 ^ x03, 8);
|
|
744
|
+
x09 = x09 + x14 | 0;
|
|
745
|
+
x04 = rotl(x04 ^ x09, 7);
|
|
746
|
+
}
|
|
747
|
+
// RFC 8439 §2.3 / §2.3.1: add the original state words back in state order.
|
|
748
|
+
let oi = 0;
|
|
749
|
+
out[oi++] = y00 + x00 | 0;
|
|
750
|
+
out[oi++] = y01 + x01 | 0;
|
|
751
|
+
out[oi++] = y02 + x02 | 0;
|
|
752
|
+
out[oi++] = y03 + x03 | 0;
|
|
753
|
+
out[oi++] = y04 + x04 | 0;
|
|
754
|
+
out[oi++] = y05 + x05 | 0;
|
|
755
|
+
out[oi++] = y06 + x06 | 0;
|
|
756
|
+
out[oi++] = y07 + x07 | 0;
|
|
757
|
+
out[oi++] = y08 + x08 | 0;
|
|
758
|
+
out[oi++] = y09 + x09 | 0;
|
|
759
|
+
out[oi++] = y10 + x10 | 0;
|
|
760
|
+
out[oi++] = y11 + x11 | 0;
|
|
761
|
+
out[oi++] = y12 + x12 | 0;
|
|
762
|
+
out[oi++] = y13 + x13 | 0;
|
|
763
|
+
out[oi++] = y14 + x14 | 0;
|
|
764
|
+
out[oi++] = y15 + x15 | 0;
|
|
765
|
+
}
|
|
766
|
+
// prettier-ignore
|
|
767
|
+
function hchacha(s, k, i, out) {
|
|
768
|
+
// Runs the shared chachaCore permutation, then subtracts the RFC 8439 feed-forward
|
|
769
|
+
// it applies, recovering the raw permutation words hchacha needs.
|
|
770
|
+
// LE hosts read the caller arrays in place (no copies); BE hosts get
|
|
771
|
+
// byte-swapped scratch copies, wiped before returning.
|
|
772
|
+
const s2 = isLE ? s : swap32IfBE(s.slice(0, 4));
|
|
773
|
+
const k2 = isLE ? k : swap32IfBE(k.slice(0, 8));
|
|
774
|
+
const i2 = isLE ? i : swap32IfBE(i.slice(0, 4));
|
|
775
|
+
const t = new Uint32Array(16);
|
|
776
|
+
chachaCore(s2, k2, i2.subarray(1), t, i2[0]);
|
|
777
|
+
let oi = 0;
|
|
778
|
+
out[oi++] = t[0] - s2[0] | 0;
|
|
779
|
+
out[oi++] = t[1] - s2[1] | 0;
|
|
780
|
+
out[oi++] = t[2] - s2[2] | 0;
|
|
781
|
+
out[oi++] = t[3] - s2[3] | 0;
|
|
782
|
+
out[oi++] = t[12] - i2[0] | 0;
|
|
783
|
+
out[oi++] = t[13] - i2[1] | 0;
|
|
784
|
+
out[oi++] = t[14] - i2[2] | 0;
|
|
785
|
+
out[oi++] = t[15] - i2[3] | 0;
|
|
786
|
+
swap32IfBE(out);
|
|
787
|
+
if (!isLE) clean(s2, k2, i2);
|
|
788
|
+
clean(t);
|
|
789
|
+
}
|
|
790
|
+
const chacha20 = /* @__PURE__ */createCipher(chachaCore, {
|
|
791
|
+
counterRight: false,
|
|
792
|
+
counterLength: 4,
|
|
793
|
+
allowShortKeys: false
|
|
794
|
+
});
|
|
795
|
+
const xchacha20 = /* @__PURE__ */createCipher(chachaCore, {
|
|
796
|
+
counterRight: false,
|
|
797
|
+
counterLength: 8,
|
|
798
|
+
extendNonceFn: hchacha,
|
|
799
|
+
allowShortKeys: false
|
|
800
|
+
});
|
|
801
|
+
// RFC 8439 §2.8.1 pad16(x): shared zero block for AAD/ciphertext padding.
|
|
802
|
+
const ZEROS16 = /* @__PURE__ */new Uint8Array(16);
|
|
803
|
+
// RFC 8439 §2.8 / §2.8.1: aligned inputs add nothing, otherwise append 16-(len%16) zero bytes.
|
|
804
|
+
const updatePadded = (h, msg) => {
|
|
805
|
+
h.update(msg);
|
|
806
|
+
const leftover = msg.length % 16;
|
|
807
|
+
if (leftover) h.update(ZEROS16.subarray(leftover));
|
|
808
|
+
};
|
|
809
|
+
// RFC 8439 §2.6.1 poly1305_key_gen returns `block[0..31]`, so AEAD key
|
|
810
|
+
// generation only needs 32 zero bytes.
|
|
811
|
+
const ZEROS32 = /* @__PURE__ */new Uint8Array(32);
|
|
812
|
+
function computeTag(fn, key, nonce, ciphertext, AAD) {
|
|
813
|
+
if (AAD !== undefined) abytes(AAD, undefined, "AAD");
|
|
814
|
+
// RFC 8439 §2.6 / §2.8: derive the Poly1305 one-time key from counter 0,
|
|
815
|
+
// then MAC AAD || pad16(AAD) || ciphertext || pad16(ciphertext) || len(AAD) || len(ciphertext).
|
|
816
|
+
const authKey = fn(key, nonce, ZEROS32);
|
|
817
|
+
const lengths = u64Lengths(ciphertext.length, AAD ? AAD.length : 0, true);
|
|
818
|
+
// Methods below can be replaced with
|
|
819
|
+
// `return poly1305_computeTag_small(authKey, lengths, ciphertext, AAD)`
|
|
820
|
+
// from `test/misc/micro-ciphers.ts`.
|
|
821
|
+
const h = new Poly1305(authKey);
|
|
822
|
+
if (AAD) updatePadded(h, AAD);
|
|
823
|
+
updatePadded(h, ciphertext);
|
|
824
|
+
h.update(lengths);
|
|
825
|
+
const res = h.digest();
|
|
826
|
+
clean(authKey, lengths);
|
|
827
|
+
return res;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* AEAD algorithm from RFC 8439.
|
|
831
|
+
* Salsa20 and chacha (RFC 8439) use poly1305 differently.
|
|
832
|
+
* We could have composed them, but it's hard because of authKey:
|
|
833
|
+
* In salsa20, authKey changes position in salsa stream.
|
|
834
|
+
* In chacha, authKey can't be computed inside computeTag, it modifies the counter.
|
|
835
|
+
*/
|
|
836
|
+
const _poly1305_aead = xorStream => (key, nonce, AAD) => {
|
|
837
|
+
// This borrows caller key/nonce/AAD buffers by reference; mutating them after construction
|
|
838
|
+
// changes future encrypt/decrypt results.
|
|
839
|
+
const tagLength = 16;
|
|
840
|
+
return {
|
|
841
|
+
encrypt(plaintext, output) {
|
|
842
|
+
const plength = plaintext.length;
|
|
843
|
+
output = getOutput(plength + tagLength, output, false);
|
|
844
|
+
output.set(plaintext);
|
|
845
|
+
const oPlain = output.subarray(0, -tagLength);
|
|
846
|
+
// RFC 8439 §2.8: payload encryption starts at counter 1 because counter 0 produced the OTK.
|
|
847
|
+
xorStream(key, nonce, oPlain, oPlain, 1);
|
|
848
|
+
const tag = computeTag(xorStream, key, nonce, oPlain, AAD);
|
|
849
|
+
output.set(tag, plength); // append tag
|
|
850
|
+
clean(tag);
|
|
851
|
+
return output;
|
|
852
|
+
},
|
|
853
|
+
decrypt(ciphertext, output) {
|
|
854
|
+
output = getOutput(ciphertext.length - tagLength, output, false);
|
|
855
|
+
const data = ciphertext.subarray(0, -tagLength);
|
|
856
|
+
const passedTag = ciphertext.subarray(-tagLength);
|
|
857
|
+
const tag = computeTag(xorStream, key, nonce, data, AAD);
|
|
858
|
+
// RFC 8439 §2.8 / §4: authenticate ciphertext before decrypting it, and compare tags with
|
|
859
|
+
// the constant-time equalBytes() helper rather than decrypting speculative plaintext first.
|
|
860
|
+
if (!equalBytes(passedTag, tag)) {
|
|
861
|
+
clean(tag);
|
|
862
|
+
return undefined;
|
|
863
|
+
}
|
|
864
|
+
output.set(ciphertext.subarray(0, -tagLength));
|
|
865
|
+
// Actual decryption
|
|
866
|
+
xorStream(key, nonce, output, output, 1); // start stream with i=1
|
|
867
|
+
clean(tag);
|
|
868
|
+
return output;
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
};
|
|
872
|
+
/**
|
|
873
|
+
* ChaCha20-Poly1305 from RFC 8439, with a 32-byte key and a 12-byte nonce.
|
|
874
|
+
*
|
|
875
|
+
* @internal
|
|
876
|
+
*/
|
|
877
|
+
export const chacha20Poly1305 = /* @__PURE__ */_poly1305_aead(chacha20);
|
|
878
|
+
/**
|
|
879
|
+
* XChaCha20-Poly1305 from draft-irtf-cfrg-xchacha-03, with a 32-byte key and a
|
|
880
|
+
* 24-byte nonce.
|
|
881
|
+
*
|
|
882
|
+
* @internal
|
|
883
|
+
*/
|
|
884
|
+
export const xchacha20Poly1305 = /* @__PURE__ */_poly1305_aead(xchacha20);
|
|
885
|
+
//# sourceMappingURL=chacha.js.map
|