effect 4.0.7 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -1
- package/THIRD_PARTY_NOTICES.md +62 -0
- package/dist/BigDecimal.d.ts +139 -7
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +86 -14
- 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/Equal.d.ts +2 -2
- package/dist/Equal.d.ts.map +1 -1
- package/dist/Equal.js +3 -3
- package/dist/Equal.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/Hash.d.ts +3 -2
- package/dist/Hash.d.ts.map +1 -1
- package/dist/Hash.js +5 -4
- package/dist/Hash.js.map +1 -1
- package/dist/Iterable.d.ts.map +1 -1
- package/dist/Iterable.js +11 -8
- package/dist/Iterable.js.map +1 -1
- 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/Path.d.ts.map +1 -1
- package/dist/Path.js +5 -1
- package/dist/Path.js.map +1 -1
- package/dist/Pool.d.ts +51 -0
- package/dist/Pool.d.ts.map +1 -1
- package/dist/Pool.js +61 -10
- 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 +668 -42
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +652 -1
- 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 +18 -2
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +20 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +10 -5
- package/dist/SchemaTransformation.d.ts.map +1 -1
- package/dist/SchemaTransformation.js +8 -5
- 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/McpClient.d.ts +171 -19
- package/dist/ai/McpClient.d.ts.map +1 -1
- package/dist/ai/McpClient.js +277 -66
- package/dist/ai/McpClient.js.map +1 -1
- package/dist/ai/McpSchema.d.ts +108 -0
- package/dist/ai/McpSchema.d.ts.map +1 -1
- package/dist/ai/McpSchema.js +99 -0
- package/dist/ai/McpSchema.js.map +1 -1
- package/dist/ai/McpServer.d.ts +744 -29
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +763 -136
- 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/Prompt.d.ts.map +1 -1
- package/dist/ai/Prompt.js +20 -11
- package/dist/ai/Prompt.js.map +1 -1
- 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 +5 -7
- 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 +89 -15
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +7 -6
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +7 -6
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +7 -6
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +7 -6
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +60 -17
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +25 -0
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +8 -6
- package/dist/ai/internal/mcpRuntime.js.map +1 -1
- package/dist/ai/internal/mcpSkills.d.ts +2 -0
- package/dist/ai/internal/mcpSkills.d.ts.map +1 -0
- package/dist/ai/internal/mcpSkills.js +428 -0
- package/dist/ai/internal/mcpSkills.js.map +1 -0
- 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/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +15 -5
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Reply.d.ts +1 -1
- package/dist/cluster/Reply.d.ts.map +1 -1
- package/dist/cluster/Reply.js.map +1 -1
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +93 -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/cluster/internal/entityManager.js +15 -7
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/crypto/Aead.d.ts +323 -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 +236 -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 +324 -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 +341 -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 +390 -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 +278 -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 +449 -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 +80 -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 +171 -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 +29 -5
- 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/Ndjson.d.ts +5 -4
- package/dist/encoding/Ndjson.d.ts.map +1 -1
- package/dist/encoding/Ndjson.js +6 -5
- package/dist/encoding/Ndjson.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/Sse.d.ts +3 -1
- package/dist/encoding/Sse.d.ts.map +1 -1
- package/dist/encoding/Sse.js +5 -3
- package/dist/encoding/Sse.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 +126 -4
- package/dist/eventlog/EventLog.d.ts.map +1 -1
- package/dist/eventlog/EventLog.js +207 -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 +10 -1
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +45 -22
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.d.ts +336 -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/EventLogServerUnencrypted.d.ts +17 -0
- package/dist/eventlog/EventLogServerUnencrypted.d.ts.map +1 -1
- package/dist/eventlog/EventLogServerUnencrypted.js +14 -2
- package/dist/eventlog/EventLogServerUnencrypted.js.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.d.ts +26 -3
- package/dist/eventlog/EventLogSessionAuth.d.ts.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.js +63 -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/graphql/GraphQLClient.d.ts +3 -1
- package/dist/graphql/GraphQLClient.d.ts.map +1 -1
- package/dist/graphql/GraphQLClient.js.map +1 -1
- package/dist/graphql/GraphQLClientError.d.ts +14 -9
- package/dist/graphql/GraphQLClientError.d.ts.map +1 -1
- package/dist/graphql/GraphQLClientError.js +14 -21
- package/dist/graphql/GraphQLClientError.js.map +1 -1
- package/dist/graphql/GraphQLProtocol.d.ts +12 -3
- package/dist/graphql/GraphQLProtocol.d.ts.map +1 -1
- package/dist/graphql/GraphQLProtocol.js +4 -1
- package/dist/graphql/GraphQLProtocol.js.map +1 -1
- 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 +268 -15
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +140 -7
- 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 +44 -39
- 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/mimeTypes.d.ts +4 -1
- package/dist/http/internal/mimeTypes.d.ts.map +1 -1
- package/dist/http/internal/mimeTypes.js +4 -1
- package/dist/http/internal/mimeTypes.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 +54 -1
- 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/dateTime.js +49 -24
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +35 -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 +808 -0
- package/dist/internal/glob.js.map +1 -0
- package/dist/internal/graphql.js +21 -7
- package/dist/internal/graphql.js.map +1 -1
- package/dist/internal/graphqlHeaders.d.ts +7 -0
- package/dist/internal/graphqlHeaders.d.ts.map +1 -1
- package/dist/internal/graphqlHeaders.js +11 -0
- package/dist/internal/graphqlHeaders.js.map +1 -1
- 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/request.js +29 -42
- package/dist/internal/request.js.map +1 -1
- package/dist/internal/schema/fromJsonSchemaDocument.js +7 -8
- package/dist/internal/schema/fromJsonSchemaDocument.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/jose/JoseError.d.ts +285 -0
- package/dist/jose/JoseError.d.ts.map +1 -0
- package/dist/jose/JoseError.js +269 -0
- package/dist/jose/JoseError.js.map +1 -0
- package/dist/jose/Jwe.d.ts +128 -0
- package/dist/jose/Jwe.d.ts.map +1 -0
- package/dist/jose/Jwe.js +134 -0
- package/dist/jose/Jwe.js.map +1 -0
- package/dist/jose/Jwk.d.ts +597 -0
- package/dist/jose/Jwk.d.ts.map +1 -0
- package/dist/jose/Jwk.js +503 -0
- package/dist/jose/Jwk.js.map +1 -0
- package/dist/jose/Jwks.d.ts +236 -0
- package/dist/jose/Jwks.d.ts.map +1 -0
- package/dist/jose/Jwks.js +306 -0
- package/dist/jose/Jwks.js.map +1 -0
- package/dist/jose/Jws.d.ts +177 -0
- package/dist/jose/Jws.d.ts.map +1 -0
- package/dist/jose/Jws.js +183 -0
- package/dist/jose/Jws.js.map +1 -0
- package/dist/jose/Jwt.d.ts +270 -0
- package/dist/jose/Jwt.d.ts.map +1 -0
- package/dist/jose/Jwt.js +293 -0
- package/dist/jose/Jwt.js.map +1 -0
- package/dist/jose/index.d.ts +51 -0
- package/dist/jose/index.d.ts.map +1 -0
- package/dist/jose/index.js +52 -0
- package/dist/jose/index.js.map +1 -0
- package/dist/jose/internal/compact.d.ts +2 -0
- package/dist/jose/internal/compact.d.ts.map +1 -0
- package/dist/jose/internal/compact.js +179 -0
- package/dist/jose/internal/compact.js.map +1 -0
- package/dist/net/Host.d.ts.map +1 -1
- package/dist/net/Host.js +5 -10
- package/dist/net/Host.js.map +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/observability/OtlpSerialization.d.ts +1 -1
- package/dist/observability/OtlpSerialization.d.ts.map +1 -1
- package/dist/observability/OtlpSerialization.js +10 -4
- package/dist/observability/OtlpSerialization.js.map +1 -1
- package/dist/observability/internal/otlpProtobuf.js +3 -3
- package/dist/observability/internal/otlpProtobuf.js.map +1 -1
- package/dist/observability/internal/protobuf.js +6 -0
- package/dist/observability/internal/protobuf.js.map +1 -1
- package/dist/persistence/CircuitBreaker.d.ts +98 -38
- package/dist/persistence/CircuitBreaker.d.ts.map +1 -1
- package/dist/persistence/CircuitBreaker.js +67 -29
- package/dist/persistence/CircuitBreaker.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/persistence/RateLimiter.d.ts +8 -0
- package/dist/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/persistence/RateLimiter.js +63 -12
- package/dist/persistence/RateLimiter.js.map +1 -1
- package/dist/persistence/index.d.ts +1 -1
- package/dist/persistence/index.js +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 +17 -7
- package/dist/reactivity/AtomRegistry.js.map +1 -1
- package/dist/rpc/Rpc.d.ts +1 -1
- package/dist/rpc/Rpc.d.ts.map +1 -1
- package/dist/rpc/Rpc.js.map +1 -1
- package/dist/rpc/RpcClient.d.ts +28 -1
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +78 -27
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcMessage.d.ts +13 -3
- 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 +9 -20
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +20 -53
- 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 +38 -3
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +9 -12
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +61 -9
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +24 -33
- 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/Workflow.d.ts +4 -0
- package/dist/workflow/Workflow.d.ts.map +1 -1
- package/dist/workflow/Workflow.js.map +1 -1
- package/dist/workflow/WorkflowEngine.d.ts.map +1 -1
- package/dist/workflow/WorkflowEngine.js +5 -0
- package/dist/workflow/WorkflowEngine.js.map +1 -1
- package/dist/workflow/internal/crypto.js +9 -8
- package/dist/workflow/internal/crypto.js.map +1 -1
- package/package.json +7 -1
- package/src/BigDecimal.ts +173 -16
- 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/Equal.ts +3 -3
- package/src/FileSystem.ts +65 -4
- package/src/Glob.ts +205 -0
- package/src/Hash.ts +5 -4
- package/src/Iterable.ts +8 -5
- package/src/Match.ts +127 -0
- package/src/Path.ts +6 -1
- package/src/Pool.ts +75 -16
- package/src/Random.ts +3 -3
- package/src/RcMap.ts +5 -1
- package/src/Schedule.ts +26 -3
- package/src/Schema.ts +1191 -63
- package/src/SchemaGetter.ts +27 -11
- package/src/SchemaRepresentation.ts +23 -2
- package/src/SchemaTransformation.ts +10 -5
- 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/McpClient.ts +488 -91
- package/src/ai/McpSchema.ts +119 -0
- package/src/ai/McpServer.ts +1525 -319
- package/src/ai/McpTest.ts +380 -0
- package/src/ai/Prompt.ts +16 -11
- package/src/ai/Response.ts +2 -22
- package/src/ai/Tool.ts +32 -18
- package/src/ai/index.ts +6 -0
- package/src/ai/internal/mcpCore.ts +243 -56
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +7 -8
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +7 -8
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +7 -8
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +7 -8
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +56 -17
- package/src/ai/internal/mcpProtocol.ts +44 -0
- package/src/ai/internal/mcpRuntime.ts +15 -8
- package/src/ai/internal/mcpSkills.ts +480 -0
- 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/ClusterWorkflowEngine.ts +22 -8
- package/src/cluster/Reply.ts +1 -1
- package/src/cluster/Sharding.ts +96 -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/cluster/internal/entityManager.ts +24 -10
- 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 +741 -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 +84 -0
- package/src/crypto/index.ts +78 -0
- package/src/crypto/internal/asymmetric.ts +330 -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 +242 -0
- package/src/crypto/internal/md5.ts +170 -0
- package/src/crypto/internal/webCrypto.ts +150 -0
- package/src/encoding/Base64Url.ts +32 -5
- package/src/encoding/Csv.ts +1298 -0
- package/src/encoding/Hex.ts +3 -2
- package/src/encoding/Ndjson.ts +6 -5
- package/src/encoding/SchemaBinary.ts +40 -4
- package/src/encoding/Sse.ts +5 -3
- 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 +347 -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 +54 -20
- package/src/eventlog/EventLogServerEncrypted.ts +1135 -67
- package/src/eventlog/EventLogServerUnencrypted.ts +19 -2
- package/src/eventlog/EventLogSessionAuth.ts +82 -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/graphql/GraphQLClient.ts +3 -1
- package/src/graphql/GraphQLClientError.ts +15 -22
- package/src/graphql/GraphQLProtocol.ts +12 -3
- package/src/http/Cookies.ts +281 -1
- package/src/http/FetchHttpClient.ts +88 -16
- package/src/http/HttpClient.ts +299 -33
- 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 +76 -53
- 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/mimeTypes.ts +4 -1
- 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 +106 -15
- package/src/index.ts +6 -6
- package/src/internal/dateTime.ts +54 -24
- package/src/internal/effect.ts +40 -18
- package/src/internal/glob.ts +952 -0
- package/src/internal/graphql.ts +27 -9
- package/src/internal/graphqlHeaders.ts +13 -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/request.ts +51 -58
- package/src/internal/schema/fromJsonSchemaDocument.ts +11 -10
- 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/jose/JoseError.ts +329 -0
- package/src/jose/Jwe.ts +196 -0
- package/src/jose/Jwk.ts +777 -0
- package/src/jose/Jwks.ts +418 -0
- package/src/jose/Jws.ts +312 -0
- package/src/jose/Jwt.ts +493 -0
- package/src/jose/index.ts +58 -0
- package/src/jose/internal/compact.ts +195 -0
- package/src/net/Host.ts +5 -10
- package/src/observability/Otlp.ts +21 -4
- package/src/observability/OtlpResource.ts +9 -1
- package/src/observability/OtlpSerialization.ts +13 -5
- package/src/observability/internal/otlpProtobuf.ts +6 -6
- package/src/observability/internal/protobuf.ts +10 -0
- package/src/persistence/CircuitBreaker.ts +113 -48
- package/src/persistence/KeyValueStore.ts +219 -22
- package/src/persistence/PersistedQueue.ts +128 -59
- package/src/persistence/Persistence.ts +20 -13
- package/src/persistence/RateLimiter.ts +84 -15
- package/src/persistence/index.ts +1 -1
- 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 +20 -9
- package/src/rpc/Rpc.ts +3 -1
- package/src/rpc/RpcClient.ts +94 -38
- package/src/rpc/RpcMessage.ts +13 -3
- 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 +38 -80
- package/src/sql/MigratorFileSystem.ts +71 -0
- package/src/sql/SqlClient.ts +45 -24
- package/src/sql/Statement.ts +60 -29
- package/src/sql/index.ts +1 -1
- package/src/testing/index.ts +0 -6
- package/src/workflow/Workflow.ts +4 -0
- package/src/workflow/WorkflowEngine.ts +5 -0
- 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
package/src/Schema.ts
CHANGED
|
@@ -19,6 +19,14 @@ import type * as Brand from "./Brand.ts"
|
|
|
19
19
|
import * as ByteSize_ from "./ByteSize.ts"
|
|
20
20
|
import * as Cause_ from "./Cause.ts"
|
|
21
21
|
import * as Chunk_ from "./Chunk.ts"
|
|
22
|
+
import * as Aead_ from "./crypto/Aead.ts"
|
|
23
|
+
import * as Cipher_ from "./crypto/Cipher.ts"
|
|
24
|
+
import type * as CryptoError_ from "./crypto/CryptoError.ts"
|
|
25
|
+
import * as KeyAgreement_ from "./crypto/KeyAgreement.ts"
|
|
26
|
+
import * as KeyFormat_ from "./crypto/KeyFormat.ts"
|
|
27
|
+
import * as KeyWrap_ from "./crypto/KeyWrap.ts"
|
|
28
|
+
import * as Mac_ from "./crypto/Mac.ts"
|
|
29
|
+
import * as Signature_ from "./crypto/Signature.ts"
|
|
22
30
|
import * as Data from "./Data.ts"
|
|
23
31
|
import * as DateTime from "./DateTime.ts"
|
|
24
32
|
import type { Differ } from "./Differ.ts"
|
|
@@ -6329,9 +6337,35 @@ type Flatten<Schemas> = Schemas extends readonly [infer Head, ...infer Tail]
|
|
|
6329
6337
|
type MatchCasesResult<Cases> = {
|
|
6330
6338
|
[K in keyof Cases]-?: NonNullable<Cases[K]> extends (...args: Array<any>) => infer R ? R : never
|
|
6331
6339
|
}[keyof Cases]
|
|
6332
|
-
type MatchOrElseResult<Cases, OrElse
|
|
6333
|
-
MatchCasesResult<Cases> |
|
|
6340
|
+
type MatchOrElseResult<Cases, OrElse> = Unify<
|
|
6341
|
+
MatchCasesResult<Cases> | (OrElse extends (...args: Array<any>) => infer R ? R : never)
|
|
6334
6342
|
>
|
|
6343
|
+
type TaggedUnionMatch<Cases extends Record<PropertyKey, Constraint>, Value> = {
|
|
6344
|
+
<Handlers extends { [K in keyof Cases]: (value: Cases[K]["Type"]) => any }>(
|
|
6345
|
+
value: Value,
|
|
6346
|
+
cases: Handlers
|
|
6347
|
+
): Unify<ReturnType<Handlers[keyof Cases]>>
|
|
6348
|
+
<Handlers extends { [K in keyof Cases]: (value: Cases[K]["Type"]) => any }>(
|
|
6349
|
+
cases: Handlers
|
|
6350
|
+
): (value: Value) => Unify<ReturnType<Handlers[keyof Cases]>>
|
|
6351
|
+
}
|
|
6352
|
+
type TaggedUnionMatchOrElse<Cases extends Record<PropertyKey, Constraint>, Value, Tag extends PropertyKey> = {
|
|
6353
|
+
<Handlers, OrElse>(
|
|
6354
|
+
value: Value,
|
|
6355
|
+
cases:
|
|
6356
|
+
& Handlers
|
|
6357
|
+
& { [K in keyof Cases]?: (value: Cases[K]["Type"]) => any }
|
|
6358
|
+
& (Exclude<keyof Handlers, keyof Cases> extends never ? unknown : never),
|
|
6359
|
+
orElse: OrElse & ((value: Exclude<Value, { readonly [K in Tag]: keyof Handlers }>) => any)
|
|
6360
|
+
): MatchOrElseResult<Handlers, OrElse>
|
|
6361
|
+
<Handlers, OrElse>(
|
|
6362
|
+
cases:
|
|
6363
|
+
& Handlers
|
|
6364
|
+
& { [K in keyof Cases]?: (value: Cases[K]["Type"]) => any }
|
|
6365
|
+
& (Exclude<keyof Handlers, keyof Cases> extends never ? unknown : never),
|
|
6366
|
+
orElse: OrElse & ((value: Exclude<Value, { readonly [K in Tag]: keyof Handlers }>) => any)
|
|
6367
|
+
): (value: Value) => MatchOrElseResult<Handlers, OrElse>
|
|
6368
|
+
}
|
|
6335
6369
|
type TaggedUnionUtils<
|
|
6336
6370
|
Tag extends PropertyKey,
|
|
6337
6371
|
Members extends ReadonlyArray<Constraint & { readonly Type: { readonly [K in Tag]: PropertyKey } }>,
|
|
@@ -6352,46 +6386,15 @@ type TaggedUnionUtils<
|
|
|
6352
6386
|
keys: ReadonlyArray<Keys>
|
|
6353
6387
|
) => (value: Members[number]["Type"]) => value is Extract<Members[number]["Type"], { readonly [K in Tag]: Keys }>
|
|
6354
6388
|
readonly guards: { [M in Flattened[number] as M["Type"][Tag]]: (u: unknown) => u is M["Type"] }
|
|
6355
|
-
readonly match:
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
Cases extends { [M in Flattened[number] as M["Type"][Tag]]: (value: M["Type"]) => any }
|
|
6365
|
-
>(
|
|
6366
|
-
cases: Cases
|
|
6367
|
-
): (value: Members[number]["Type"]) => Cases[keyof Cases] extends (value: any) => infer R ? Unify<R>
|
|
6368
|
-
: never
|
|
6369
|
-
}
|
|
6370
|
-
readonly matchOrElse: {
|
|
6371
|
-
<
|
|
6372
|
-
Cases extends
|
|
6373
|
-
& { [M in Flattened[number] as M["Type"][Tag]]+?: (value: M["Type"]) => any }
|
|
6374
|
-
& { [K in Exclude<keyof Cases, Flattened[number]["Type"][Tag]>]: never },
|
|
6375
|
-
OrElse extends (
|
|
6376
|
-
value: Exclude<Members[number]["Type"], { readonly [K in Tag]: keyof Cases }>
|
|
6377
|
-
) => any
|
|
6378
|
-
>(
|
|
6379
|
-
value: Members[number]["Type"],
|
|
6380
|
-
cases: Cases,
|
|
6381
|
-
orElse: OrElse
|
|
6382
|
-
): MatchOrElseResult<Cases, OrElse>
|
|
6383
|
-
<
|
|
6384
|
-
Cases extends
|
|
6385
|
-
& { [M in Flattened[number] as M["Type"][Tag]]+?: (value: M["Type"]) => any }
|
|
6386
|
-
& { [K in Exclude<keyof Cases, Flattened[number]["Type"][Tag]>]: never },
|
|
6387
|
-
OrElse extends (
|
|
6388
|
-
value: Exclude<Members[number]["Type"], { readonly [K in Tag]: keyof Cases }>
|
|
6389
|
-
) => any
|
|
6390
|
-
>(
|
|
6391
|
-
cases: Cases,
|
|
6392
|
-
orElse: OrElse
|
|
6393
|
-
): (value: Members[number]["Type"]) => MatchOrElseResult<Cases, OrElse>
|
|
6394
|
-
}
|
|
6389
|
+
readonly match: TaggedUnionMatch<
|
|
6390
|
+
{ readonly [M in Flattened[number] as M["Type"][Tag]]: M },
|
|
6391
|
+
Members[number]["Type"]
|
|
6392
|
+
>
|
|
6393
|
+
readonly matchOrElse: TaggedUnionMatchOrElse<
|
|
6394
|
+
{ readonly [M in Flattened[number] as M["Type"][Tag]]: M },
|
|
6395
|
+
Members[number]["Type"],
|
|
6396
|
+
Tag
|
|
6397
|
+
>
|
|
6395
6398
|
}
|
|
6396
6399
|
/**
|
|
6397
6400
|
* Type-level representation returned by {@link toTaggedUnion}.
|
|
@@ -6541,26 +6544,8 @@ export interface TaggedUnion<Cases extends Record<string, Constraint>> extends
|
|
|
6541
6544
|
keys: ReadonlyArray<Keys>
|
|
6542
6545
|
) => (value: Cases[keyof Cases]["Type"]) => value is Extract<Cases[keyof Cases]["Type"], { _tag: Keys }>
|
|
6543
6546
|
readonly guards: { [K in keyof Cases]: (u: unknown) => u is Cases[K]["Type"] }
|
|
6544
|
-
readonly match:
|
|
6545
|
-
|
|
6546
|
-
cases: { [K in keyof Cases]: (value: Cases[K]["Type"]) => Output }
|
|
6547
|
-
): (value: Cases[keyof Cases]["Type"]) => Output
|
|
6548
|
-
<Output>(
|
|
6549
|
-
value: Cases[keyof Cases]["Type"],
|
|
6550
|
-
cases: { [K in keyof Cases]: (value: Cases[K]["Type"]) => Output }
|
|
6551
|
-
): Output
|
|
6552
|
-
}
|
|
6553
|
-
readonly matchOrElse: {
|
|
6554
|
-
<Output>(
|
|
6555
|
-
value: Cases[keyof Cases]["Type"],
|
|
6556
|
-
cases: { [K in keyof Cases]?: (value: Cases[K]["Type"]) => Output },
|
|
6557
|
-
orElse: (value: Cases[keyof Cases]["Type"]) => Output
|
|
6558
|
-
): Output
|
|
6559
|
-
<Output>(
|
|
6560
|
-
cases: { [K in keyof Cases]?: (value: Cases[K]["Type"]) => Output },
|
|
6561
|
-
orElse: (value: Cases[keyof Cases]["Type"]) => Output
|
|
6562
|
-
): (value: Cases[keyof Cases]["Type"]) => Output
|
|
6563
|
-
}
|
|
6547
|
+
readonly match: TaggedUnionMatch<Cases, Cases[keyof Cases]["Type"]>
|
|
6548
|
+
readonly matchOrElse: TaggedUnionMatchOrElse<Cases, Cases[keyof Cases]["Type"], "_tag">
|
|
6564
6549
|
}
|
|
6565
6550
|
/**
|
|
6566
6551
|
* Builds a discriminated union from a record of field sets, one per variant.
|
|
@@ -7120,6 +7105,51 @@ export function isULID(annotations?: Annotations.Filter) {
|
|
|
7120
7105
|
}
|
|
7121
7106
|
)
|
|
7122
7107
|
}
|
|
7108
|
+
|
|
7109
|
+
// oxlint-disable-next-line no-control-regex
|
|
7110
|
+
const ASCII_REGEXP = /^[\x00-\x7F]*$/u
|
|
7111
|
+
/**
|
|
7112
|
+
* Validates that a string contains only ASCII characters.
|
|
7113
|
+
*
|
|
7114
|
+
* **When to use**
|
|
7115
|
+
*
|
|
7116
|
+
* Use when a value must stay within the 7-bit ASCII range, for example
|
|
7117
|
+
* identifiers, protocol tokens, or data sent to systems that reject
|
|
7118
|
+
* non-ASCII input.
|
|
7119
|
+
*
|
|
7120
|
+
* **Details**
|
|
7121
|
+
*
|
|
7122
|
+
* This check accepts strings whose characters are all in the range `U+0000`
|
|
7123
|
+
* to `U+007F`, including control characters and the empty string.
|
|
7124
|
+
*
|
|
7125
|
+
* JSON Schema:
|
|
7126
|
+
*
|
|
7127
|
+
* This check corresponds to a `pattern` constraint in JSON Schema that matches
|
|
7128
|
+
* ASCII-only strings.
|
|
7129
|
+
*
|
|
7130
|
+
* Arbitrary:
|
|
7131
|
+
*
|
|
7132
|
+
* During arbitrary generation, this applies a `patterns`
|
|
7133
|
+
* constraint to ensure generated strings match the ASCII pattern.
|
|
7134
|
+
*
|
|
7135
|
+
* @stability unstable
|
|
7136
|
+
* @category validation
|
|
7137
|
+
* @since 4.0.6
|
|
7138
|
+
*/
|
|
7139
|
+
export function isAscii(annotations?: Annotations.Filter) {
|
|
7140
|
+
return isPattern(
|
|
7141
|
+
ASCII_REGEXP,
|
|
7142
|
+
{
|
|
7143
|
+
expected: "an ASCII string",
|
|
7144
|
+
representation: {
|
|
7145
|
+
id: "effect/schema/isAscii",
|
|
7146
|
+
payload: null
|
|
7147
|
+
},
|
|
7148
|
+
toCode: () => ({ runtime: "Schema.isAscii()" }),
|
|
7149
|
+
...annotations
|
|
7150
|
+
}
|
|
7151
|
+
)
|
|
7152
|
+
}
|
|
7123
7153
|
/**
|
|
7124
7154
|
* Validates that a string is valid Base64 encoded data.
|
|
7125
7155
|
*
|
|
@@ -10919,7 +10949,8 @@ export interface BigDecimalFromString extends decodeTo<BigDecimal, String> {
|
|
|
10919
10949
|
*
|
|
10920
10950
|
* **Gotchas**
|
|
10921
10951
|
*
|
|
10922
|
-
* An empty string decodes as zero.
|
|
10952
|
+
* An empty string decodes as zero. Strings with a scale outside ±10,000, such
|
|
10953
|
+
* as `"1e300000000"`, are rejected.
|
|
10923
10954
|
*
|
|
10924
10955
|
* @see {@link BigDecimal} for validating values that are already BigDecimal values
|
|
10925
10956
|
* @see {@link BigIntFromString} for parsing base-10 integer strings into bigint values
|
|
@@ -13711,6 +13742,33 @@ const durationFromMillis: SchemaTransformation.Transformation<Duration_.Duration
|
|
|
13711
13742
|
decode: (i) => Duration_.millis(i),
|
|
13712
13743
|
encode: (a) => Duration_.toMillis(a)
|
|
13713
13744
|
})
|
|
13745
|
+
const durationFromIsoString: SchemaTransformation.Transformation<Duration_.Duration, string> = SchemaTransformation
|
|
13746
|
+
.transformEffect<Duration_.Duration, string>({
|
|
13747
|
+
decode: (s, options) =>
|
|
13748
|
+
Option_.match(Duration_.fromIso(s), {
|
|
13749
|
+
onNone: () =>
|
|
13750
|
+
Effect.fail(
|
|
13751
|
+
new SchemaIssue.InvalidValue(
|
|
13752
|
+
{ expected: "an ISO 8601 duration without years or months" },
|
|
13753
|
+
s,
|
|
13754
|
+
options
|
|
13755
|
+
)
|
|
13756
|
+
),
|
|
13757
|
+
onSome: Effect.succeed
|
|
13758
|
+
}),
|
|
13759
|
+
encode: (a, options) =>
|
|
13760
|
+
Option_.match(Duration_.formatIso(a), {
|
|
13761
|
+
onNone: () =>
|
|
13762
|
+
Effect.fail(
|
|
13763
|
+
new SchemaIssue.InvalidValue(
|
|
13764
|
+
{ expected: "a finite Duration" },
|
|
13765
|
+
a,
|
|
13766
|
+
options
|
|
13767
|
+
)
|
|
13768
|
+
),
|
|
13769
|
+
onSome: Effect.succeed
|
|
13770
|
+
})
|
|
13771
|
+
})
|
|
13714
13772
|
/**
|
|
13715
13773
|
* Type-level representation of {@link Duration}.
|
|
13716
13774
|
*
|
|
@@ -13886,6 +13944,42 @@ export interface DurationFromMillis extends decodeTo<Duration, Number> {
|
|
|
13886
13944
|
export const DurationFromMillis: DurationFromMillis = Number.pipe(
|
|
13887
13945
|
decodeTo(Duration, durationFromMillis)
|
|
13888
13946
|
)
|
|
13947
|
+
/**
|
|
13948
|
+
* Type-level representation of {@link DurationFromIsoString}.
|
|
13949
|
+
*
|
|
13950
|
+
* @stability stable
|
|
13951
|
+
* @category models
|
|
13952
|
+
* @since 4.1.0
|
|
13953
|
+
*/
|
|
13954
|
+
export interface DurationFromIsoString extends decodeTo<Duration, String> {
|
|
13955
|
+
readonly "Rebuild": DurationFromIsoString
|
|
13956
|
+
}
|
|
13957
|
+
/**
|
|
13958
|
+
* Schema that decodes an ISO 8601 duration string into a `Duration`.
|
|
13959
|
+
*
|
|
13960
|
+
* **Details**
|
|
13961
|
+
*
|
|
13962
|
+
* Decoding:
|
|
13963
|
+
* - A string accepted by `Duration.fromIso` is decoded as a `Duration`, such
|
|
13964
|
+
* as `"PT1H30M"`, `"P1W2D"`, or `"-PT0.5S"`. Years and months are rejected
|
|
13965
|
+
* because they have no fixed length.
|
|
13966
|
+
*
|
|
13967
|
+
* Encoding:
|
|
13968
|
+
* - A finite `Duration` is encoded with `Duration.formatIso`, using days,
|
|
13969
|
+
* hours, minutes, and seconds. Encoding fails for `Duration.infinity` and
|
|
13970
|
+
* `Duration.negativeInfinity`.
|
|
13971
|
+
*
|
|
13972
|
+
* @see {@link DurationFromString} for the `"5 seconds"` string format
|
|
13973
|
+
*
|
|
13974
|
+
* @stability stable
|
|
13975
|
+
* @category schemas
|
|
13976
|
+
* @since 4.1.0
|
|
13977
|
+
*/
|
|
13978
|
+
export const DurationFromIsoString: DurationFromIsoString = String.annotate({
|
|
13979
|
+
expected: "an ISO 8601 duration string that will be decoded as a Duration"
|
|
13980
|
+
}).pipe(
|
|
13981
|
+
decodeTo(Duration, durationFromIsoString)
|
|
13982
|
+
)
|
|
13889
13983
|
|
|
13890
13984
|
// -----------------------------------------------------------------------------
|
|
13891
13985
|
// DNS schemas
|
|
@@ -14307,6 +14401,1040 @@ export const DnsRecord: DnsRecord = Union([
|
|
|
14307
14401
|
DnsTxtRecord
|
|
14308
14402
|
]).annotate({ identifier: "DnsRecord" })
|
|
14309
14403
|
|
|
14404
|
+
// -----------------------------------------------------------------------------
|
|
14405
|
+
// Crypto key schemas
|
|
14406
|
+
// -----------------------------------------------------------------------------
|
|
14407
|
+
|
|
14408
|
+
// Match operation parameters rather than object identity. RSA modulus length
|
|
14409
|
+
// affects generation only, so it is ignored here as on import.
|
|
14410
|
+
interface CryptoAlgorithm {
|
|
14411
|
+
readonly _tag?: string
|
|
14412
|
+
readonly name: string
|
|
14413
|
+
readonly hash?: { readonly name: string }
|
|
14414
|
+
readonly modulusLength?: number
|
|
14415
|
+
readonly saltLength?: number
|
|
14416
|
+
}
|
|
14417
|
+
|
|
14418
|
+
const cryptoAlgorithmEquals = (self: CryptoAlgorithm, that: CryptoAlgorithm): boolean =>
|
|
14419
|
+
self === that ||
|
|
14420
|
+
(self.name === that.name && self.hash?.name === that.hash?.name && self.saltLength === that.saltLength)
|
|
14421
|
+
|
|
14422
|
+
const cryptoDigestCode = (hash: { readonly name: string }) => `Digest.${hash.name.toLowerCase().replace("-", "")}`
|
|
14423
|
+
|
|
14424
|
+
const cryptoAlgorithmCode = (family: string, algorithm: CryptoAlgorithm): string => {
|
|
14425
|
+
if (algorithm.modulusLength === undefined || algorithm.hash === undefined || algorithm._tag === undefined) {
|
|
14426
|
+
const code = `${family}.${algorithm.name}`
|
|
14427
|
+
return algorithm.hash === undefined ? code : `{ ...${code}, hash: ${cryptoDigestCode(algorithm.hash)} }`
|
|
14428
|
+
}
|
|
14429
|
+
const factory = algorithm._tag.charAt(0).toLowerCase() + algorithm._tag.slice(1)
|
|
14430
|
+
const saltLength = algorithm.saltLength === undefined ? "" : `, saltLength: ${algorithm.saltLength}`
|
|
14431
|
+
return `${family}.${factory}({ hash: ${
|
|
14432
|
+
cryptoDigestCode(algorithm.hash)
|
|
14433
|
+
}, modulusLength: ${algorithm.modulusLength}${saltLength} })`
|
|
14434
|
+
}
|
|
14435
|
+
|
|
14436
|
+
const cryptoAlgorithmPayload = (algorithm: CryptoAlgorithm): Json => {
|
|
14437
|
+
const payload: { [key: string]: Json } = { name: algorithm.name }
|
|
14438
|
+
if (algorithm.hash !== undefined) payload.hash = algorithm.hash.name
|
|
14439
|
+
if (algorithm.modulusLength !== undefined) payload.modulusLength = algorithm.modulusLength
|
|
14440
|
+
if (algorithm.saltLength !== undefined) payload.saltLength = algorithm.saltLength
|
|
14441
|
+
return payload
|
|
14442
|
+
}
|
|
14443
|
+
|
|
14444
|
+
const declareCryptoKey = <K extends { readonly algorithm: CryptoAlgorithm }>(
|
|
14445
|
+
name: string,
|
|
14446
|
+
family: string,
|
|
14447
|
+
type: string,
|
|
14448
|
+
is: (u: unknown) => boolean,
|
|
14449
|
+
algorithm: CryptoAlgorithm
|
|
14450
|
+
): declare<K> => {
|
|
14451
|
+
const code = cryptoAlgorithmCode(family, algorithm)
|
|
14452
|
+
const forbidden = SchemaGetter.forbidden<never, unknown>(() =>
|
|
14453
|
+
`Cannot serialize ${family}.${type} values as JSON, use Schema.${name}FromFormat to read and write keys`
|
|
14454
|
+
)
|
|
14455
|
+
return declare<K>(
|
|
14456
|
+
(u): u is K => is(u) && cryptoAlgorithmEquals((u as K).algorithm, algorithm),
|
|
14457
|
+
{
|
|
14458
|
+
expected: `${family}.${type} for ${algorithm.name}`,
|
|
14459
|
+
representation: { id: `effect/crypto/${name}`, payload: cryptoAlgorithmPayload(algorithm) },
|
|
14460
|
+
toCode: () => ({
|
|
14461
|
+
runtime: `Schema.${name}(${code})`,
|
|
14462
|
+
Type: `${family}.${type}`,
|
|
14463
|
+
importDeclarations: [
|
|
14464
|
+
`import * as ${family} from "effect/crypto/${family}"`,
|
|
14465
|
+
...(code.includes("Digest.") ? [`import * as Digest from "effect/crypto/Digest"`] : [])
|
|
14466
|
+
]
|
|
14467
|
+
}),
|
|
14468
|
+
toCodecJson: () => link<K>()(Unknown, { decode: forbidden, encode: forbidden }),
|
|
14469
|
+
// Keys have no Arbitrary: linking to `Never` makes derivation fail.
|
|
14470
|
+
toCodecArbitrary: () => link<K>()(Never, { decode: forbidden, encode: forbidden }),
|
|
14471
|
+
toFormatter: () => (key) => globalThis.String(key),
|
|
14472
|
+
toEquivalence: () => (self, that) => self === that
|
|
14473
|
+
}
|
|
14474
|
+
)
|
|
14475
|
+
}
|
|
14476
|
+
|
|
14477
|
+
const cryptoIssue = (error: CryptoError_.CryptoError, input: unknown, options: SchemaAST.ParseOptions) =>
|
|
14478
|
+
new SchemaIssue.InvalidValue({ message: error.message, cause: error }, input, options)
|
|
14479
|
+
|
|
14480
|
+
const cryptoForbiddenEncode = (name: string, key: unknown, options: SchemaAST.ParseOptions) =>
|
|
14481
|
+
Effect.fail(
|
|
14482
|
+
new SchemaIssue.Forbidden(
|
|
14483
|
+
{ message: `Schema.${name} only decodes, pass { allowEncode: true } to encode the key` },
|
|
14484
|
+
key,
|
|
14485
|
+
options
|
|
14486
|
+
)
|
|
14487
|
+
)
|
|
14488
|
+
|
|
14489
|
+
type CryptoKeyOptions = { readonly allowEncode?: boolean | undefined }
|
|
14490
|
+
|
|
14491
|
+
const cryptoKeyFromBytes = <To extends Codec<any>>(
|
|
14492
|
+
name: string,
|
|
14493
|
+
to: To,
|
|
14494
|
+
fromBytes: (bytes: globalThis.Uint8Array) => Effect.Effect<To["Type"], CryptoError_.CryptoError>,
|
|
14495
|
+
toBytes: ((key: To["Type"]) => Effect.Effect<globalThis.Uint8Array, CryptoError_.CryptoError>) | undefined
|
|
14496
|
+
): decodeTo<To, Uint8Array> =>
|
|
14497
|
+
Uint8Array.pipe(decodeTo(
|
|
14498
|
+
to,
|
|
14499
|
+
SchemaTransformation.transformEffect({
|
|
14500
|
+
decode: (bytes, options) => Effect.mapError(fromBytes(bytes), (error) => cryptoIssue(error, bytes, options)),
|
|
14501
|
+
encode: (key, options) =>
|
|
14502
|
+
toBytes === undefined
|
|
14503
|
+
? cryptoForbiddenEncode(name, key, options)
|
|
14504
|
+
: Effect.mapError(toBytes(key), (error) => cryptoIssue(error, key, options))
|
|
14505
|
+
})
|
|
14506
|
+
))
|
|
14507
|
+
|
|
14508
|
+
const CryptoJsonWebKeyMember = optionalKey(String)
|
|
14509
|
+
|
|
14510
|
+
// The JWK members of RFC 7517 and RFC 7518 that `KeyFormat` reads and writes.
|
|
14511
|
+
// Other members are dropped.
|
|
14512
|
+
const CryptoJsonWebKey = Struct({
|
|
14513
|
+
kty: CryptoJsonWebKeyMember,
|
|
14514
|
+
crv: CryptoJsonWebKeyMember,
|
|
14515
|
+
alg: CryptoJsonWebKeyMember,
|
|
14516
|
+
use: CryptoJsonWebKeyMember,
|
|
14517
|
+
key_ops: optionalKey(ArraySchema(String)),
|
|
14518
|
+
ext: optionalKey(Boolean),
|
|
14519
|
+
k: CryptoJsonWebKeyMember,
|
|
14520
|
+
x: CryptoJsonWebKeyMember,
|
|
14521
|
+
y: CryptoJsonWebKeyMember,
|
|
14522
|
+
d: CryptoJsonWebKeyMember,
|
|
14523
|
+
n: CryptoJsonWebKeyMember,
|
|
14524
|
+
e: CryptoJsonWebKeyMember,
|
|
14525
|
+
p: CryptoJsonWebKeyMember,
|
|
14526
|
+
q: CryptoJsonWebKeyMember,
|
|
14527
|
+
dp: CryptoJsonWebKeyMember,
|
|
14528
|
+
dq: CryptoJsonWebKeyMember,
|
|
14529
|
+
qi: CryptoJsonWebKeyMember,
|
|
14530
|
+
oth: optionalKey(ArraySchema(Struct({
|
|
14531
|
+
r: CryptoJsonWebKeyMember,
|
|
14532
|
+
d: CryptoJsonWebKeyMember,
|
|
14533
|
+
t: CryptoJsonWebKeyMember
|
|
14534
|
+
})))
|
|
14535
|
+
}) as unknown as Codec<KeyFormat_.JsonWebKey>
|
|
14536
|
+
|
|
14537
|
+
const cryptoFormatData = <R extends KeyFormat_.Role, Data>(format: KeyFormat_.Format<R, "decode", Data>): Codec<Data> =>
|
|
14538
|
+
(format._tag === "jwk" ? CryptoJsonWebKey : format.pem ? String : Uint8Array) as Codec<any>
|
|
14539
|
+
|
|
14540
|
+
const cryptoKeyFromFormat = <To extends Codec<any>, R extends KeyFormat_.Role, Data>(
|
|
14541
|
+
name: string,
|
|
14542
|
+
to: To,
|
|
14543
|
+
format: KeyFormat_.Format<R, "decode", Data>,
|
|
14544
|
+
decode: (data: Data) => Effect.Effect<To["Type"], CryptoError_.CryptoError>,
|
|
14545
|
+
canEncode: boolean
|
|
14546
|
+
): decodeTo<To, Codec<Data>> => {
|
|
14547
|
+
// PKCS#1 and SEC1 are read only.
|
|
14548
|
+
const writable = canEncode && format._tag !== "pkcs1" && format._tag !== "sec1"
|
|
14549
|
+
return cryptoFormatData(format).pipe(decodeTo(
|
|
14550
|
+
to,
|
|
14551
|
+
SchemaTransformation.transformEffect<To["Type"], Data>({
|
|
14552
|
+
decode: (data, options) =>
|
|
14553
|
+
// Secret JWK decoding is synchronous, but all format schemas are async-only.
|
|
14554
|
+
Effect.flatMap(Effect.promise(() => Promise.resolve()), () =>
|
|
14555
|
+
Effect.mapError(decode(data), (error) => cryptoIssue(error, data, options))),
|
|
14556
|
+
encode: (key, options) =>
|
|
14557
|
+
writable
|
|
14558
|
+
? Effect.mapError(
|
|
14559
|
+
KeyFormat_.encode(format as any, key as KeyFormat_.Key) as Effect.Effect<Data, CryptoError_.CryptoError>,
|
|
14560
|
+
(error) => cryptoIssue(error, key, options)
|
|
14561
|
+
)
|
|
14562
|
+
: cryptoForbiddenEncode(name, key, options)
|
|
14563
|
+
})
|
|
14564
|
+
))
|
|
14565
|
+
}
|
|
14566
|
+
|
|
14567
|
+
/**
|
|
14568
|
+
* Type-level representation of {@link MacKey}.
|
|
14569
|
+
*
|
|
14570
|
+
* @stability unstable
|
|
14571
|
+
* @category models
|
|
14572
|
+
* @since 4.0.0
|
|
14573
|
+
*/
|
|
14574
|
+
export interface MacKey<A extends Mac_.Algorithm = Mac_.Algorithm> extends declare<Mac_.Key<A>> {
|
|
14575
|
+
readonly "Rebuild": MacKey<A>
|
|
14576
|
+
}
|
|
14577
|
+
|
|
14578
|
+
/**
|
|
14579
|
+
* Schema for live `Mac.Key` values of an algorithm.
|
|
14580
|
+
*
|
|
14581
|
+
* **Details**
|
|
14582
|
+
*
|
|
14583
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
14584
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
14585
|
+
* {@link MacKeyFromFormat} or {@link MacKeyFromBytes} to read and write keys.
|
|
14586
|
+
* Keys display redacted, compare by reference, and have no `Arbitrary`.
|
|
14587
|
+
*
|
|
14588
|
+
* @stability unstable
|
|
14589
|
+
* @category crypto
|
|
14590
|
+
* @since 4.0.0
|
|
14591
|
+
*/
|
|
14592
|
+
export const MacKey = <A extends Mac_.Algorithm>(algorithm: A): MacKey<A> =>
|
|
14593
|
+
declareCryptoKey<Mac_.Key<A>>("MacKey", "Mac", "Key", Mac_.isKey, algorithm)
|
|
14594
|
+
|
|
14595
|
+
/**
|
|
14596
|
+
* Schema that decodes raw key bytes into a `Mac.Key`.
|
|
14597
|
+
*
|
|
14598
|
+
* **Details**
|
|
14599
|
+
*
|
|
14600
|
+
* Decoding runs `Mac.key`, which is synchronous, so the schema works with
|
|
14601
|
+
* `Schema.decodeSync`. Under `Config.schema` the bytes are read as base64. A
|
|
14602
|
+
* `CryptoError` becomes an `InvalidValue` issue whose `cause` is the error.
|
|
14603
|
+
* Encoding fails with a `Forbidden` issue unless `allowEncode` is `true`.
|
|
14604
|
+
*
|
|
14605
|
+
* **Example** (Reading an HMAC key from the environment)
|
|
14606
|
+
*
|
|
14607
|
+
* ```ts import.meta.vitest
|
|
14608
|
+
* import { Config, ConfigProvider, Effect, Schema } from "effect"
|
|
14609
|
+
* import { Mac } from "effect/crypto"
|
|
14610
|
+
*
|
|
14611
|
+
* const config = Config.schema(Schema.MacKeyFromBytes(Mac.hmacSha256), "HMAC_KEY")
|
|
14612
|
+
* const provider = ConfigProvider.fromEnv({ env: { HMAC_KEY: "A".repeat(43) + "=" } })
|
|
14613
|
+
* const key = await Effect.runPromise(Effect.provide(config, ConfigProvider.layer(provider)))
|
|
14614
|
+
* key.algorithm.name // => "hmacSha256"
|
|
14615
|
+
* ```
|
|
14616
|
+
*
|
|
14617
|
+
* @stability unstable
|
|
14618
|
+
* @category crypto
|
|
14619
|
+
* @since 4.0.0
|
|
14620
|
+
*/
|
|
14621
|
+
export const MacKeyFromBytes = <A extends Mac_.Algorithm>(
|
|
14622
|
+
algorithm: A,
|
|
14623
|
+
options?: CryptoKeyOptions
|
|
14624
|
+
): decodeTo<MacKey<A>, Uint8Array> =>
|
|
14625
|
+
cryptoKeyFromBytes(
|
|
14626
|
+
"MacKeyFromBytes",
|
|
14627
|
+
MacKey(algorithm),
|
|
14628
|
+
(bytes) => Mac_.key(algorithm, bytes),
|
|
14629
|
+
options?.allowEncode === true ? Mac_.toBytes : undefined
|
|
14630
|
+
)
|
|
14631
|
+
|
|
14632
|
+
/**
|
|
14633
|
+
* Schema that decodes a `Mac.Key` from a JWK with `KeyFormat.decodeSecret`.
|
|
14634
|
+
*
|
|
14635
|
+
* **Details**
|
|
14636
|
+
*
|
|
14637
|
+
* Decoding returns an Effect, so use the async decoding functions:
|
|
14638
|
+
* `Schema.decodeSync` throws. A `CryptoError` becomes an `InvalidValue` issue
|
|
14639
|
+
* whose `cause` is the error. Encoding fails with a `Forbidden` issue unless
|
|
14640
|
+
* `allowEncode` is `true`.
|
|
14641
|
+
*
|
|
14642
|
+
* @stability unstable
|
|
14643
|
+
* @category crypto
|
|
14644
|
+
* @since 4.0.0
|
|
14645
|
+
*/
|
|
14646
|
+
export const MacKeyFromFormat = <A extends Mac_.Algorithm, Data>(
|
|
14647
|
+
format: KeyFormat_.Format<"secret", "decode", Data>,
|
|
14648
|
+
algorithm: A,
|
|
14649
|
+
options?: CryptoKeyOptions
|
|
14650
|
+
): decodeTo<MacKey<A>, Codec<Data>> =>
|
|
14651
|
+
cryptoKeyFromFormat(
|
|
14652
|
+
"MacKeyFromFormat",
|
|
14653
|
+
MacKey(algorithm),
|
|
14654
|
+
format,
|
|
14655
|
+
(data) => KeyFormat_.decodeSecret(format, algorithm, data) as Effect.Effect<Mac_.Key<A>, CryptoError_.CryptoError>,
|
|
14656
|
+
options?.allowEncode === true
|
|
14657
|
+
)
|
|
14658
|
+
|
|
14659
|
+
/**
|
|
14660
|
+
* Type-level representation of {@link AeadKey}.
|
|
14661
|
+
*
|
|
14662
|
+
* @stability unstable
|
|
14663
|
+
* @category models
|
|
14664
|
+
* @since 4.0.0
|
|
14665
|
+
*/
|
|
14666
|
+
export interface AeadKey<A extends Aead_.Algorithm = Aead_.Algorithm> extends declare<Aead_.Key<A>> {
|
|
14667
|
+
readonly "Rebuild": AeadKey<A>
|
|
14668
|
+
}
|
|
14669
|
+
|
|
14670
|
+
/**
|
|
14671
|
+
* Schema for live `Aead.Key` values of an algorithm.
|
|
14672
|
+
*
|
|
14673
|
+
* **Details**
|
|
14674
|
+
*
|
|
14675
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
14676
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
14677
|
+
* {@link AeadKeyFromFormat} or {@link AeadKeyFromBytes} to read and write
|
|
14678
|
+
* keys. Keys display redacted, compare by reference, and have no `Arbitrary`.
|
|
14679
|
+
*
|
|
14680
|
+
* @stability unstable
|
|
14681
|
+
* @category crypto
|
|
14682
|
+
* @since 4.0.0
|
|
14683
|
+
*/
|
|
14684
|
+
export const AeadKey = <A extends Aead_.Algorithm>(algorithm: A): AeadKey<A> =>
|
|
14685
|
+
declareCryptoKey<Aead_.Key<A>>("AeadKey", "Aead", "Key", Aead_.isKey, algorithm)
|
|
14686
|
+
|
|
14687
|
+
/**
|
|
14688
|
+
* Schema that decodes raw key bytes into an `Aead.Key`.
|
|
14689
|
+
*
|
|
14690
|
+
* **Details**
|
|
14691
|
+
*
|
|
14692
|
+
* Decoding runs `Aead.key`, which is synchronous, so the schema works with
|
|
14693
|
+
* `Schema.decodeSync`. Under `Config.schema` the bytes are read as base64. A
|
|
14694
|
+
* `CryptoError` becomes an `InvalidValue` issue whose `cause` is the error.
|
|
14695
|
+
* Encoding fails with a `Forbidden` issue unless `allowEncode` is `true`.
|
|
14696
|
+
*
|
|
14697
|
+
* @stability unstable
|
|
14698
|
+
* @category crypto
|
|
14699
|
+
* @since 4.0.0
|
|
14700
|
+
*/
|
|
14701
|
+
export const AeadKeyFromBytes = <A extends Aead_.Algorithm>(
|
|
14702
|
+
algorithm: A,
|
|
14703
|
+
options?: CryptoKeyOptions
|
|
14704
|
+
): decodeTo<AeadKey<A>, Uint8Array> =>
|
|
14705
|
+
cryptoKeyFromBytes(
|
|
14706
|
+
"AeadKeyFromBytes",
|
|
14707
|
+
AeadKey(algorithm),
|
|
14708
|
+
(bytes) => Aead_.key(algorithm, bytes),
|
|
14709
|
+
options?.allowEncode === true ? Aead_.toBytes : undefined
|
|
14710
|
+
)
|
|
14711
|
+
|
|
14712
|
+
/**
|
|
14713
|
+
* Schema that decodes an `Aead.Key` from a JWK with `KeyFormat.decodeSecret`.
|
|
14714
|
+
*
|
|
14715
|
+
* **Details**
|
|
14716
|
+
*
|
|
14717
|
+
* Decoding returns an Effect, so use the async decoding functions:
|
|
14718
|
+
* `Schema.decodeSync` throws. A `CryptoError` becomes an `InvalidValue` issue
|
|
14719
|
+
* whose `cause` is the error. Encoding fails with a `Forbidden` issue unless
|
|
14720
|
+
* `allowEncode` is `true`.
|
|
14721
|
+
*
|
|
14722
|
+
* @stability unstable
|
|
14723
|
+
* @category crypto
|
|
14724
|
+
* @since 4.0.0
|
|
14725
|
+
*/
|
|
14726
|
+
export const AeadKeyFromFormat = <A extends Aead_.Algorithm, Data>(
|
|
14727
|
+
format: KeyFormat_.Format<"secret", "decode", Data>,
|
|
14728
|
+
algorithm: A,
|
|
14729
|
+
options?: CryptoKeyOptions
|
|
14730
|
+
): decodeTo<AeadKey<A>, Codec<Data>> =>
|
|
14731
|
+
cryptoKeyFromFormat(
|
|
14732
|
+
"AeadKeyFromFormat",
|
|
14733
|
+
AeadKey(algorithm),
|
|
14734
|
+
format,
|
|
14735
|
+
(data) => KeyFormat_.decodeSecret(format, algorithm, data) as Effect.Effect<Aead_.Key<A>, CryptoError_.CryptoError>,
|
|
14736
|
+
options?.allowEncode === true
|
|
14737
|
+
)
|
|
14738
|
+
|
|
14739
|
+
/**
|
|
14740
|
+
* Type-level representation of {@link CipherKey}.
|
|
14741
|
+
*
|
|
14742
|
+
* @stability unstable
|
|
14743
|
+
* @category models
|
|
14744
|
+
* @since 4.0.0
|
|
14745
|
+
*/
|
|
14746
|
+
export interface CipherKey<A extends Cipher_.Algorithm = Cipher_.Algorithm> extends declare<Cipher_.Key<A>> {
|
|
14747
|
+
readonly "Rebuild": CipherKey<A>
|
|
14748
|
+
}
|
|
14749
|
+
|
|
14750
|
+
/**
|
|
14751
|
+
* Schema for live `Cipher.Key` values of an algorithm.
|
|
14752
|
+
*
|
|
14753
|
+
* **Details**
|
|
14754
|
+
*
|
|
14755
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
14756
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
14757
|
+
* {@link CipherKeyFromFormat} or {@link CipherKeyFromBytes} to read and
|
|
14758
|
+
* write keys. Keys display redacted, compare by reference, and have no
|
|
14759
|
+
* `Arbitrary`.
|
|
14760
|
+
*
|
|
14761
|
+
* @stability unstable
|
|
14762
|
+
* @category crypto
|
|
14763
|
+
* @since 4.0.0
|
|
14764
|
+
*/
|
|
14765
|
+
export const CipherKey = <A extends Cipher_.Algorithm>(algorithm: A): CipherKey<A> =>
|
|
14766
|
+
declareCryptoKey<Cipher_.Key<A>>(
|
|
14767
|
+
"CipherKey",
|
|
14768
|
+
"Cipher",
|
|
14769
|
+
"Key",
|
|
14770
|
+
Cipher_.isKey,
|
|
14771
|
+
algorithm
|
|
14772
|
+
)
|
|
14773
|
+
|
|
14774
|
+
/**
|
|
14775
|
+
* Schema that decodes raw key bytes into a `Cipher.Key`.
|
|
14776
|
+
*
|
|
14777
|
+
* **Details**
|
|
14778
|
+
*
|
|
14779
|
+
* Decoding runs `Cipher.key`, which is synchronous, so the schema works with
|
|
14780
|
+
* `Schema.decodeSync`. Under `Config.schema` the bytes are read as base64. A
|
|
14781
|
+
* `CryptoError` becomes an `InvalidValue` issue whose `cause` is the error.
|
|
14782
|
+
* Encoding fails with a `Forbidden` issue unless `allowEncode` is `true`.
|
|
14783
|
+
*
|
|
14784
|
+
* @stability unstable
|
|
14785
|
+
* @category crypto
|
|
14786
|
+
* @since 4.0.0
|
|
14787
|
+
*/
|
|
14788
|
+
export const CipherKeyFromBytes = <A extends Cipher_.Algorithm>(
|
|
14789
|
+
algorithm: A,
|
|
14790
|
+
options?: CryptoKeyOptions
|
|
14791
|
+
): decodeTo<CipherKey<A>, Uint8Array> =>
|
|
14792
|
+
cryptoKeyFromBytes(
|
|
14793
|
+
"CipherKeyFromBytes",
|
|
14794
|
+
CipherKey(algorithm),
|
|
14795
|
+
(bytes) => Cipher_.key(algorithm, bytes),
|
|
14796
|
+
options?.allowEncode === true ? Cipher_.toBytes : undefined
|
|
14797
|
+
)
|
|
14798
|
+
|
|
14799
|
+
/**
|
|
14800
|
+
* Schema that decodes a `Cipher.Key` from a JWK with
|
|
14801
|
+
* `KeyFormat.decodeSecret`.
|
|
14802
|
+
*
|
|
14803
|
+
* **Details**
|
|
14804
|
+
*
|
|
14805
|
+
* Decoding returns an Effect, so use the async decoding functions:
|
|
14806
|
+
* `Schema.decodeSync` throws. A `CryptoError` becomes an `InvalidValue` issue
|
|
14807
|
+
* whose `cause` is the error. Encoding fails with a `Forbidden` issue unless
|
|
14808
|
+
* `allowEncode` is `true`.
|
|
14809
|
+
*
|
|
14810
|
+
* @stability unstable
|
|
14811
|
+
* @category crypto
|
|
14812
|
+
* @since 4.0.0
|
|
14813
|
+
*/
|
|
14814
|
+
export const CipherKeyFromFormat = <A extends Cipher_.Algorithm, Data>(
|
|
14815
|
+
format: KeyFormat_.Format<"secret", "decode", Data>,
|
|
14816
|
+
algorithm: A,
|
|
14817
|
+
options?: CryptoKeyOptions
|
|
14818
|
+
): decodeTo<CipherKey<A>, Codec<Data>> =>
|
|
14819
|
+
cryptoKeyFromFormat(
|
|
14820
|
+
"CipherKeyFromFormat",
|
|
14821
|
+
CipherKey(algorithm),
|
|
14822
|
+
format,
|
|
14823
|
+
(data) =>
|
|
14824
|
+
KeyFormat_.decodeSecret(format, algorithm, data) as Effect.Effect<Cipher_.Key<A>, CryptoError_.CryptoError>,
|
|
14825
|
+
options?.allowEncode === true
|
|
14826
|
+
)
|
|
14827
|
+
|
|
14828
|
+
/**
|
|
14829
|
+
* Type-level representation of {@link SignaturePublicKey}.
|
|
14830
|
+
*
|
|
14831
|
+
* @stability unstable
|
|
14832
|
+
* @category models
|
|
14833
|
+
* @since 4.0.0
|
|
14834
|
+
*/
|
|
14835
|
+
export interface SignaturePublicKey<A extends Signature_.Algorithm = Signature_.Algorithm>
|
|
14836
|
+
extends declare<Signature_.PublicKey<A>>
|
|
14837
|
+
{
|
|
14838
|
+
readonly "Rebuild": SignaturePublicKey<A>
|
|
14839
|
+
}
|
|
14840
|
+
|
|
14841
|
+
/**
|
|
14842
|
+
* Schema for live `Signature.PublicKey` values of an algorithm.
|
|
14843
|
+
*
|
|
14844
|
+
* **Details**
|
|
14845
|
+
*
|
|
14846
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
14847
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
14848
|
+
* {@link SignaturePublicKeyFromFormat} or {@link SignaturePublicKeyFromBytes}
|
|
14849
|
+
* to read and write keys. Keys compare by reference and have no `Arbitrary`.
|
|
14850
|
+
*
|
|
14851
|
+
* @stability unstable
|
|
14852
|
+
* @category crypto
|
|
14853
|
+
* @since 4.0.0
|
|
14854
|
+
*/
|
|
14855
|
+
export const SignaturePublicKey = <A extends Signature_.Algorithm>(algorithm: A): SignaturePublicKey<A> =>
|
|
14856
|
+
declareCryptoKey<Signature_.PublicKey<A>>(
|
|
14857
|
+
"SignaturePublicKey",
|
|
14858
|
+
"Signature",
|
|
14859
|
+
"PublicKey",
|
|
14860
|
+
Signature_.isPublicKey,
|
|
14861
|
+
algorithm
|
|
14862
|
+
)
|
|
14863
|
+
|
|
14864
|
+
/**
|
|
14865
|
+
* Schema that decodes a raw public key into a `Signature.PublicKey`: 32 bytes
|
|
14866
|
+
* for Ed25519, or an uncompressed SEC1 point for ECDSA.
|
|
14867
|
+
*
|
|
14868
|
+
* **Details**
|
|
14869
|
+
*
|
|
14870
|
+
* Decoding runs `Signature.publicKey`, which is synchronous, so the schema
|
|
14871
|
+
* works with `Schema.decodeSync`. Under `Config.schema` the bytes are read as
|
|
14872
|
+
* base64. A `CryptoError` becomes an `InvalidValue` issue whose `cause` is
|
|
14873
|
+
* the error. RSA public keys have no raw form, so passing an RSA algorithm is
|
|
14874
|
+
* a type error.
|
|
14875
|
+
*
|
|
14876
|
+
* @stability unstable
|
|
14877
|
+
* @category crypto
|
|
14878
|
+
* @since 4.0.0
|
|
14879
|
+
*/
|
|
14880
|
+
export const SignaturePublicKeyFromBytes = <
|
|
14881
|
+
A extends Signature_.Ed25519 | Signature_.Ecdsa
|
|
14882
|
+
>(algorithm: A): decodeTo<SignaturePublicKey<A>, Uint8Array> =>
|
|
14883
|
+
cryptoKeyFromBytes(
|
|
14884
|
+
"SignaturePublicKeyFromBytes",
|
|
14885
|
+
SignaturePublicKey(algorithm),
|
|
14886
|
+
(bytes) => Signature_.publicKey(algorithm, bytes),
|
|
14887
|
+
Signature_.toBytes
|
|
14888
|
+
)
|
|
14889
|
+
|
|
14890
|
+
/**
|
|
14891
|
+
* Schema that decodes a `Signature.PublicKey` with
|
|
14892
|
+
* `KeyFormat.decodePublic` and encodes it with `KeyFormat.encode`.
|
|
14893
|
+
*
|
|
14894
|
+
* **Details**
|
|
14895
|
+
*
|
|
14896
|
+
* The format must hold public keys: `KeyFormat.spki`, `KeyFormat.jwk`, or
|
|
14897
|
+
* `KeyFormat.pem(KeyFormat.spki)`. A format for another role is a type
|
|
14898
|
+
* error. Decoding runs the runtime's key import, so use the async decoding
|
|
14899
|
+
* functions: `Schema.decodeSync` throws. A `CryptoError` becomes an
|
|
14900
|
+
* `InvalidValue` issue whose `cause` is the error.
|
|
14901
|
+
*
|
|
14902
|
+
* @stability unstable
|
|
14903
|
+
* @category crypto
|
|
14904
|
+
* @since 4.0.0
|
|
14905
|
+
*/
|
|
14906
|
+
export const SignaturePublicKeyFromFormat = <A extends Signature_.Algorithm, Data>(
|
|
14907
|
+
format: KeyFormat_.Format<"public", "decode", Data>,
|
|
14908
|
+
algorithm: A
|
|
14909
|
+
): decodeTo<SignaturePublicKey<A>, Codec<Data>> =>
|
|
14910
|
+
cryptoKeyFromFormat(
|
|
14911
|
+
"SignaturePublicKeyFromFormat",
|
|
14912
|
+
SignaturePublicKey(algorithm),
|
|
14913
|
+
format,
|
|
14914
|
+
(data) =>
|
|
14915
|
+
KeyFormat_.decodePublic(format, algorithm, data) as Effect.Effect<
|
|
14916
|
+
Signature_.PublicKey<A>,
|
|
14917
|
+
CryptoError_.CryptoError
|
|
14918
|
+
>,
|
|
14919
|
+
true
|
|
14920
|
+
)
|
|
14921
|
+
|
|
14922
|
+
/**
|
|
14923
|
+
* Type-level representation of {@link SignaturePrivateKey}.
|
|
14924
|
+
*
|
|
14925
|
+
* @stability unstable
|
|
14926
|
+
* @category models
|
|
14927
|
+
* @since 4.0.0
|
|
14928
|
+
*/
|
|
14929
|
+
export interface SignaturePrivateKey<A extends Signature_.Algorithm = Signature_.Algorithm>
|
|
14930
|
+
extends declare<Signature_.PrivateKey<A>>
|
|
14931
|
+
{
|
|
14932
|
+
readonly "Rebuild": SignaturePrivateKey<A>
|
|
14933
|
+
}
|
|
14934
|
+
|
|
14935
|
+
/**
|
|
14936
|
+
* Schema for live `Signature.PrivateKey` values of an algorithm.
|
|
14937
|
+
*
|
|
14938
|
+
* **Details**
|
|
14939
|
+
*
|
|
14940
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
14941
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
14942
|
+
* {@link SignaturePrivateKeyFromFormat} or
|
|
14943
|
+
* {@link SignaturePrivateKeyFromBytes} to read and write keys. Keys display
|
|
14944
|
+
* redacted, compare by reference, and have no `Arbitrary`.
|
|
14945
|
+
*
|
|
14946
|
+
* @stability unstable
|
|
14947
|
+
* @category crypto
|
|
14948
|
+
* @since 4.0.0
|
|
14949
|
+
*/
|
|
14950
|
+
export const SignaturePrivateKey = <A extends Signature_.Algorithm>(algorithm: A): SignaturePrivateKey<A> =>
|
|
14951
|
+
declareCryptoKey<Signature_.PrivateKey<A>>(
|
|
14952
|
+
"SignaturePrivateKey",
|
|
14953
|
+
"Signature",
|
|
14954
|
+
"PrivateKey",
|
|
14955
|
+
Signature_.isPrivateKey,
|
|
14956
|
+
algorithm
|
|
14957
|
+
)
|
|
14958
|
+
|
|
14959
|
+
/**
|
|
14960
|
+
* Schema that decodes an Ed25519 seed into a `Signature.PrivateKey`.
|
|
14961
|
+
*
|
|
14962
|
+
* **Details**
|
|
14963
|
+
*
|
|
14964
|
+
* Decoding runs `Signature.privateKey`, which is synchronous, so the schema
|
|
14965
|
+
* works with `Schema.decodeSync`. Under `Config.schema` the bytes are read as
|
|
14966
|
+
* base64. A `CryptoError` becomes an `InvalidValue` issue whose `cause` is
|
|
14967
|
+
* the error. ECDSA and RSA private keys have no raw form, so passing them is
|
|
14968
|
+
* a type error. Encoding fails with a `Forbidden` issue unless `allowEncode`
|
|
14969
|
+
* is `true`.
|
|
14970
|
+
*
|
|
14971
|
+
* @stability unstable
|
|
14972
|
+
* @category crypto
|
|
14973
|
+
* @since 4.0.0
|
|
14974
|
+
*/
|
|
14975
|
+
export const SignaturePrivateKeyFromBytes = <
|
|
14976
|
+
A extends Signature_.Ed25519
|
|
14977
|
+
>(algorithm: A, options?: CryptoKeyOptions): decodeTo<SignaturePrivateKey<A>, Uint8Array> =>
|
|
14978
|
+
cryptoKeyFromBytes(
|
|
14979
|
+
"SignaturePrivateKeyFromBytes",
|
|
14980
|
+
SignaturePrivateKey(algorithm),
|
|
14981
|
+
(bytes) => Signature_.privateKey(algorithm, bytes),
|
|
14982
|
+
options?.allowEncode === true ? Signature_.toBytes : undefined
|
|
14983
|
+
)
|
|
14984
|
+
|
|
14985
|
+
/**
|
|
14986
|
+
* Schema that decodes a `Signature.PrivateKey` with
|
|
14987
|
+
* `KeyFormat.decodePrivate`.
|
|
14988
|
+
*
|
|
14989
|
+
* **Details**
|
|
14990
|
+
*
|
|
14991
|
+
* The format must hold private keys: `KeyFormat.pkcs8`, `KeyFormat.jwk`,
|
|
14992
|
+
* `KeyFormat.pkcs1`, `KeyFormat.sec1`, or their PEM forms. A format for
|
|
14993
|
+
* another role is a type error. Decoding runs the runtime's key import, so
|
|
14994
|
+
* use the async decoding functions: `Schema.decodeSync` throws. A
|
|
14995
|
+
* `CryptoError` becomes an `InvalidValue` issue whose `cause` is the error.
|
|
14996
|
+
* Encoding fails with a `Forbidden` issue unless `allowEncode` is `true`,
|
|
14997
|
+
* and always for the read-only PKCS#1 and SEC1 formats.
|
|
14998
|
+
*
|
|
14999
|
+
* @stability unstable
|
|
15000
|
+
* @category crypto
|
|
15001
|
+
* @since 4.0.0
|
|
15002
|
+
*/
|
|
15003
|
+
export const SignaturePrivateKeyFromFormat = <A extends Signature_.Algorithm, Data>(
|
|
15004
|
+
format: KeyFormat_.Format<"private", "decode", Data>,
|
|
15005
|
+
algorithm: A,
|
|
15006
|
+
options?: CryptoKeyOptions
|
|
15007
|
+
): decodeTo<SignaturePrivateKey<A>, Codec<Data>> =>
|
|
15008
|
+
cryptoKeyFromFormat(
|
|
15009
|
+
"SignaturePrivateKeyFromFormat",
|
|
15010
|
+
SignaturePrivateKey(algorithm),
|
|
15011
|
+
format,
|
|
15012
|
+
(data) =>
|
|
15013
|
+
KeyFormat_.decodePrivate(format, algorithm, data) as Effect.Effect<
|
|
15014
|
+
Signature_.PrivateKey<A>,
|
|
15015
|
+
CryptoError_.CryptoError
|
|
15016
|
+
>,
|
|
15017
|
+
options?.allowEncode === true
|
|
15018
|
+
)
|
|
15019
|
+
|
|
15020
|
+
/**
|
|
15021
|
+
* Type-level representation of {@link KeyAgreementPublicKey}.
|
|
15022
|
+
*
|
|
15023
|
+
* @stability unstable
|
|
15024
|
+
* @category models
|
|
15025
|
+
* @since 4.0.0
|
|
15026
|
+
*/
|
|
15027
|
+
export interface KeyAgreementPublicKey<A extends KeyAgreement_.Algorithm = KeyAgreement_.Algorithm>
|
|
15028
|
+
extends declare<KeyAgreement_.PublicKey<A>>
|
|
15029
|
+
{
|
|
15030
|
+
readonly "Rebuild": KeyAgreementPublicKey<A>
|
|
15031
|
+
}
|
|
15032
|
+
|
|
15033
|
+
/**
|
|
15034
|
+
* Schema for live `KeyAgreement.PublicKey` values of an algorithm.
|
|
15035
|
+
*
|
|
15036
|
+
* **Details**
|
|
15037
|
+
*
|
|
15038
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
15039
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
15040
|
+
* {@link KeyAgreementPublicKeyFromFormat} or
|
|
15041
|
+
* {@link KeyAgreementPublicKeyFromBytes} to read and write keys. Keys compare
|
|
15042
|
+
* by reference and have no `Arbitrary`.
|
|
15043
|
+
*
|
|
15044
|
+
* @stability unstable
|
|
15045
|
+
* @category crypto
|
|
15046
|
+
* @since 4.0.0
|
|
15047
|
+
*/
|
|
15048
|
+
export const KeyAgreementPublicKey = <A extends KeyAgreement_.Algorithm>(algorithm: A): KeyAgreementPublicKey<A> =>
|
|
15049
|
+
declareCryptoKey<KeyAgreement_.PublicKey<A>>(
|
|
15050
|
+
"KeyAgreementPublicKey",
|
|
15051
|
+
"KeyAgreement",
|
|
15052
|
+
"PublicKey",
|
|
15053
|
+
KeyAgreement_.isPublicKey,
|
|
15054
|
+
algorithm
|
|
15055
|
+
)
|
|
15056
|
+
|
|
15057
|
+
/**
|
|
15058
|
+
* Schema that decodes a raw public key into a `KeyAgreement.PublicKey`: 32
|
|
15059
|
+
* bytes for X25519, or an uncompressed SEC1 point for ECDH.
|
|
15060
|
+
*
|
|
15061
|
+
* **Details**
|
|
15062
|
+
*
|
|
15063
|
+
* Decoding runs `KeyAgreement.publicKey`, which is synchronous, so the schema
|
|
15064
|
+
* works with `Schema.decodeSync`. Under `Config.schema` the bytes are read as
|
|
15065
|
+
* base64. A `CryptoError` becomes an `InvalidValue` issue whose `cause` is
|
|
15066
|
+
* the error.
|
|
15067
|
+
*
|
|
15068
|
+
* @stability unstable
|
|
15069
|
+
* @category crypto
|
|
15070
|
+
* @since 4.0.0
|
|
15071
|
+
*/
|
|
15072
|
+
export const KeyAgreementPublicKeyFromBytes = <A extends KeyAgreement_.Algorithm>(
|
|
15073
|
+
algorithm: A
|
|
15074
|
+
): decodeTo<KeyAgreementPublicKey<A>, Uint8Array> =>
|
|
15075
|
+
cryptoKeyFromBytes(
|
|
15076
|
+
"KeyAgreementPublicKeyFromBytes",
|
|
15077
|
+
KeyAgreementPublicKey(algorithm),
|
|
15078
|
+
(bytes) => KeyAgreement_.publicKey(algorithm, bytes),
|
|
15079
|
+
KeyAgreement_.toBytes
|
|
15080
|
+
)
|
|
15081
|
+
|
|
15082
|
+
/**
|
|
15083
|
+
* Schema that decodes a `KeyAgreement.PublicKey` with
|
|
15084
|
+
* `KeyFormat.decodePublic` and encodes it with `KeyFormat.encode`.
|
|
15085
|
+
*
|
|
15086
|
+
* **Details**
|
|
15087
|
+
*
|
|
15088
|
+
* The format must hold public keys: `KeyFormat.spki`, `KeyFormat.jwk`, or
|
|
15089
|
+
* `KeyFormat.pem(KeyFormat.spki)`. A format for another role is a type
|
|
15090
|
+
* error. Decoding runs the runtime's key import, so use the async decoding
|
|
15091
|
+
* functions: `Schema.decodeSync` throws. A `CryptoError` becomes an
|
|
15092
|
+
* `InvalidValue` issue whose `cause` is the error.
|
|
15093
|
+
*
|
|
15094
|
+
* @stability unstable
|
|
15095
|
+
* @category crypto
|
|
15096
|
+
* @since 4.0.0
|
|
15097
|
+
*/
|
|
15098
|
+
export const KeyAgreementPublicKeyFromFormat = <A extends KeyAgreement_.Algorithm, Data>(
|
|
15099
|
+
format: KeyFormat_.Format<"public", "decode", Data>,
|
|
15100
|
+
algorithm: A
|
|
15101
|
+
): decodeTo<KeyAgreementPublicKey<A>, Codec<Data>> =>
|
|
15102
|
+
cryptoKeyFromFormat(
|
|
15103
|
+
"KeyAgreementPublicKeyFromFormat",
|
|
15104
|
+
KeyAgreementPublicKey(algorithm),
|
|
15105
|
+
format,
|
|
15106
|
+
(data) =>
|
|
15107
|
+
KeyFormat_.decodePublic(format, algorithm, data) as Effect.Effect<
|
|
15108
|
+
KeyAgreement_.PublicKey<A>,
|
|
15109
|
+
CryptoError_.CryptoError
|
|
15110
|
+
>,
|
|
15111
|
+
true
|
|
15112
|
+
)
|
|
15113
|
+
|
|
15114
|
+
/**
|
|
15115
|
+
* Type-level representation of {@link KeyAgreementPrivateKey}.
|
|
15116
|
+
*
|
|
15117
|
+
* @stability unstable
|
|
15118
|
+
* @category models
|
|
15119
|
+
* @since 4.0.0
|
|
15120
|
+
*/
|
|
15121
|
+
export interface KeyAgreementPrivateKey<A extends KeyAgreement_.Algorithm = KeyAgreement_.Algorithm>
|
|
15122
|
+
extends declare<KeyAgreement_.PrivateKey<A>>
|
|
15123
|
+
{
|
|
15124
|
+
readonly "Rebuild": KeyAgreementPrivateKey<A>
|
|
15125
|
+
}
|
|
15126
|
+
|
|
15127
|
+
/**
|
|
15128
|
+
* Schema for live `KeyAgreement.PrivateKey` values of an algorithm.
|
|
15129
|
+
*
|
|
15130
|
+
* **Details**
|
|
15131
|
+
*
|
|
15132
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
15133
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
15134
|
+
* {@link KeyAgreementPrivateKeyFromFormat} or
|
|
15135
|
+
* {@link KeyAgreementPrivateKeyFromBytes} to read and write keys. Keys
|
|
15136
|
+
* display redacted, compare by reference, and have no `Arbitrary`.
|
|
15137
|
+
*
|
|
15138
|
+
* @stability unstable
|
|
15139
|
+
* @category crypto
|
|
15140
|
+
* @since 4.0.0
|
|
15141
|
+
*/
|
|
15142
|
+
export const KeyAgreementPrivateKey = <A extends KeyAgreement_.Algorithm>(
|
|
15143
|
+
algorithm: A
|
|
15144
|
+
): KeyAgreementPrivateKey<A> =>
|
|
15145
|
+
declareCryptoKey<KeyAgreement_.PrivateKey<A>>(
|
|
15146
|
+
"KeyAgreementPrivateKey",
|
|
15147
|
+
"KeyAgreement",
|
|
15148
|
+
"PrivateKey",
|
|
15149
|
+
KeyAgreement_.isPrivateKey,
|
|
15150
|
+
algorithm
|
|
15151
|
+
)
|
|
15152
|
+
|
|
15153
|
+
/**
|
|
15154
|
+
* Schema that decodes an X25519 private key into a
|
|
15155
|
+
* `KeyAgreement.PrivateKey`.
|
|
15156
|
+
*
|
|
15157
|
+
* **Details**
|
|
15158
|
+
*
|
|
15159
|
+
* Decoding runs `KeyAgreement.privateKey`, which is synchronous, so the
|
|
15160
|
+
* schema works with `Schema.decodeSync`. Under `Config.schema` the bytes are
|
|
15161
|
+
* read as base64. A `CryptoError` becomes an `InvalidValue` issue whose
|
|
15162
|
+
* `cause` is the error. ECDH private keys have no raw form, so passing them
|
|
15163
|
+
* is a type error. Encoding fails with a `Forbidden` issue unless
|
|
15164
|
+
* `allowEncode` is `true`.
|
|
15165
|
+
*
|
|
15166
|
+
* @stability unstable
|
|
15167
|
+
* @category crypto
|
|
15168
|
+
* @since 4.0.0
|
|
15169
|
+
*/
|
|
15170
|
+
export const KeyAgreementPrivateKeyFromBytes = <
|
|
15171
|
+
A extends KeyAgreement_.X25519
|
|
15172
|
+
>(algorithm: A, options?: CryptoKeyOptions): decodeTo<KeyAgreementPrivateKey<A>, Uint8Array> =>
|
|
15173
|
+
cryptoKeyFromBytes(
|
|
15174
|
+
"KeyAgreementPrivateKeyFromBytes",
|
|
15175
|
+
KeyAgreementPrivateKey(algorithm),
|
|
15176
|
+
(bytes) => KeyAgreement_.privateKey(algorithm, bytes),
|
|
15177
|
+
options?.allowEncode === true ? KeyAgreement_.toBytes : undefined
|
|
15178
|
+
)
|
|
15179
|
+
|
|
15180
|
+
/**
|
|
15181
|
+
* Schema that decodes a `KeyAgreement.PrivateKey` with
|
|
15182
|
+
* `KeyFormat.decodePrivate`.
|
|
15183
|
+
*
|
|
15184
|
+
* **Details**
|
|
15185
|
+
*
|
|
15186
|
+
* The format must hold private keys: `KeyFormat.pkcs8`, `KeyFormat.jwk`,
|
|
15187
|
+
* `KeyFormat.sec1`, or their PEM forms. A format for another role is a type
|
|
15188
|
+
* error. Decoding runs the runtime's key import, so use the async decoding
|
|
15189
|
+
* functions: `Schema.decodeSync` throws. A `CryptoError` becomes an
|
|
15190
|
+
* `InvalidValue` issue whose `cause` is the error. Encoding fails with a
|
|
15191
|
+
* `Forbidden` issue unless `allowEncode` is `true`, and always for the
|
|
15192
|
+
* read-only PKCS#1 and SEC1 formats.
|
|
15193
|
+
*
|
|
15194
|
+
* @stability unstable
|
|
15195
|
+
* @category crypto
|
|
15196
|
+
* @since 4.0.0
|
|
15197
|
+
*/
|
|
15198
|
+
export const KeyAgreementPrivateKeyFromFormat = <A extends KeyAgreement_.Algorithm, Data>(
|
|
15199
|
+
format: KeyFormat_.Format<"private", "decode", Data>,
|
|
15200
|
+
algorithm: A,
|
|
15201
|
+
options?: CryptoKeyOptions
|
|
15202
|
+
): decodeTo<KeyAgreementPrivateKey<A>, Codec<Data>> =>
|
|
15203
|
+
cryptoKeyFromFormat(
|
|
15204
|
+
"KeyAgreementPrivateKeyFromFormat",
|
|
15205
|
+
KeyAgreementPrivateKey(algorithm),
|
|
15206
|
+
format,
|
|
15207
|
+
(data) =>
|
|
15208
|
+
KeyFormat_.decodePrivate(format, algorithm, data) as Effect.Effect<
|
|
15209
|
+
KeyAgreement_.PrivateKey<A>,
|
|
15210
|
+
CryptoError_.CryptoError
|
|
15211
|
+
>,
|
|
15212
|
+
options?.allowEncode === true
|
|
15213
|
+
)
|
|
15214
|
+
|
|
15215
|
+
/**
|
|
15216
|
+
* Type-level representation of {@link KeyWrapKey}.
|
|
15217
|
+
*
|
|
15218
|
+
* @stability unstable
|
|
15219
|
+
* @category models
|
|
15220
|
+
* @since 4.0.0
|
|
15221
|
+
*/
|
|
15222
|
+
export interface KeyWrapKey<A extends KeyWrap_.AesKw = KeyWrap_.AesKw> extends declare<KeyWrap_.Key<A>> {
|
|
15223
|
+
readonly "Rebuild": KeyWrapKey<A>
|
|
15224
|
+
}
|
|
15225
|
+
|
|
15226
|
+
/**
|
|
15227
|
+
* Schema for live AES-KW `KeyWrap.Key` values of an algorithm.
|
|
15228
|
+
*
|
|
15229
|
+
* **Details**
|
|
15230
|
+
*
|
|
15231
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
15232
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
15233
|
+
* {@link KeyWrapKeyFromFormat} or {@link KeyWrapKeyFromBytes} to read and
|
|
15234
|
+
* write keys. Keys display redacted, compare by reference, and have no
|
|
15235
|
+
* `Arbitrary`.
|
|
15236
|
+
*
|
|
15237
|
+
* @stability unstable
|
|
15238
|
+
* @category crypto
|
|
15239
|
+
* @since 4.0.0
|
|
15240
|
+
*/
|
|
15241
|
+
export const KeyWrapKey = <A extends KeyWrap_.AesKw>(algorithm: A): KeyWrapKey<A> =>
|
|
15242
|
+
declareCryptoKey<KeyWrap_.Key<A>>("KeyWrapKey", "KeyWrap", "Key", KeyWrap_.isKey, algorithm)
|
|
15243
|
+
|
|
15244
|
+
/**
|
|
15245
|
+
* Schema that decodes raw key bytes into an AES-KW `KeyWrap.Key`.
|
|
15246
|
+
*
|
|
15247
|
+
* **Details**
|
|
15248
|
+
*
|
|
15249
|
+
* Decoding runs `KeyWrap.key`, which is synchronous, so the schema works with
|
|
15250
|
+
* `Schema.decodeSync`. Under `Config.schema` the bytes are read as base64. A
|
|
15251
|
+
* `CryptoError` becomes an `InvalidValue` issue whose `cause` is the error.
|
|
15252
|
+
* Encoding fails with a `Forbidden` issue unless `allowEncode` is `true`.
|
|
15253
|
+
*
|
|
15254
|
+
* @stability unstable
|
|
15255
|
+
* @category crypto
|
|
15256
|
+
* @since 4.0.0
|
|
15257
|
+
*/
|
|
15258
|
+
export const KeyWrapKeyFromBytes = <A extends KeyWrap_.AesKw>(
|
|
15259
|
+
algorithm: A,
|
|
15260
|
+
options?: CryptoKeyOptions
|
|
15261
|
+
): decodeTo<KeyWrapKey<A>, Uint8Array> =>
|
|
15262
|
+
cryptoKeyFromBytes(
|
|
15263
|
+
"KeyWrapKeyFromBytes",
|
|
15264
|
+
KeyWrapKey(algorithm),
|
|
15265
|
+
(bytes) => KeyWrap_.key(algorithm, bytes),
|
|
15266
|
+
options?.allowEncode === true ? KeyWrap_.toBytes : undefined
|
|
15267
|
+
)
|
|
15268
|
+
|
|
15269
|
+
/**
|
|
15270
|
+
* Schema that decodes an AES-KW `KeyWrap.Key` from a JWK with
|
|
15271
|
+
* `KeyFormat.decodeSecret`.
|
|
15272
|
+
*
|
|
15273
|
+
* **Details**
|
|
15274
|
+
*
|
|
15275
|
+
* Decoding returns an Effect, so use the async decoding functions:
|
|
15276
|
+
* `Schema.decodeSync` throws. A `CryptoError` becomes an `InvalidValue` issue
|
|
15277
|
+
* whose `cause` is the error. Encoding fails with a `Forbidden` issue unless
|
|
15278
|
+
* `allowEncode` is `true`.
|
|
15279
|
+
*
|
|
15280
|
+
* @stability unstable
|
|
15281
|
+
* @category crypto
|
|
15282
|
+
* @since 4.0.0
|
|
15283
|
+
*/
|
|
15284
|
+
export const KeyWrapKeyFromFormat = <A extends KeyWrap_.AesKw, Data>(
|
|
15285
|
+
format: KeyFormat_.Format<"secret", "decode", Data>,
|
|
15286
|
+
algorithm: A,
|
|
15287
|
+
options?: CryptoKeyOptions
|
|
15288
|
+
): decodeTo<KeyWrapKey<A>, Codec<Data>> =>
|
|
15289
|
+
cryptoKeyFromFormat(
|
|
15290
|
+
"KeyWrapKeyFromFormat",
|
|
15291
|
+
KeyWrapKey(algorithm),
|
|
15292
|
+
format,
|
|
15293
|
+
(data) =>
|
|
15294
|
+
KeyFormat_.decodeSecret(format, algorithm, data) as Effect.Effect<KeyWrap_.Key<A>, CryptoError_.CryptoError>,
|
|
15295
|
+
options?.allowEncode === true
|
|
15296
|
+
)
|
|
15297
|
+
|
|
15298
|
+
/**
|
|
15299
|
+
* Type-level representation of {@link KeyWrapPublicKey}.
|
|
15300
|
+
*
|
|
15301
|
+
* @stability unstable
|
|
15302
|
+
* @category models
|
|
15303
|
+
* @since 4.0.0
|
|
15304
|
+
*/
|
|
15305
|
+
export interface KeyWrapPublicKey<A extends KeyWrap_.RsaOaep = KeyWrap_.RsaOaep>
|
|
15306
|
+
extends declare<KeyWrap_.PublicKey<A>>
|
|
15307
|
+
{
|
|
15308
|
+
readonly "Rebuild": KeyWrapPublicKey<A>
|
|
15309
|
+
}
|
|
15310
|
+
|
|
15311
|
+
/**
|
|
15312
|
+
* Schema for live RSA-OAEP `KeyWrap.PublicKey` values of an algorithm.
|
|
15313
|
+
*
|
|
15314
|
+
* **Details**
|
|
15315
|
+
*
|
|
15316
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
15317
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
15318
|
+
* {@link KeyWrapPublicKeyFromFormat} to read and write keys. RSA-OAEP keys
|
|
15319
|
+
* have no raw form. Keys compare by reference and have no `Arbitrary`.
|
|
15320
|
+
*
|
|
15321
|
+
* @stability unstable
|
|
15322
|
+
* @category crypto
|
|
15323
|
+
* @since 4.0.0
|
|
15324
|
+
*/
|
|
15325
|
+
export const KeyWrapPublicKey = <A extends KeyWrap_.RsaOaep>(algorithm: A): KeyWrapPublicKey<A> =>
|
|
15326
|
+
declareCryptoKey<KeyWrap_.PublicKey<A>>(
|
|
15327
|
+
"KeyWrapPublicKey",
|
|
15328
|
+
"KeyWrap",
|
|
15329
|
+
"PublicKey",
|
|
15330
|
+
KeyWrap_.isPublicKey,
|
|
15331
|
+
algorithm
|
|
15332
|
+
)
|
|
15333
|
+
|
|
15334
|
+
/**
|
|
15335
|
+
* Schema that decodes an RSA-OAEP `KeyWrap.PublicKey` with
|
|
15336
|
+
* `KeyFormat.decodePublic` and encodes it with `KeyFormat.encode`.
|
|
15337
|
+
*
|
|
15338
|
+
* **Details**
|
|
15339
|
+
*
|
|
15340
|
+
* The format must hold public keys: `KeyFormat.spki`, `KeyFormat.jwk`, or
|
|
15341
|
+
* `KeyFormat.pem(KeyFormat.spki)`. A format for another role is a type
|
|
15342
|
+
* error. Decoding runs the runtime's key import, so use the async decoding
|
|
15343
|
+
* functions: `Schema.decodeSync` throws. A `CryptoError` becomes an
|
|
15344
|
+
* `InvalidValue` issue whose `cause` is the error.
|
|
15345
|
+
*
|
|
15346
|
+
* @stability unstable
|
|
15347
|
+
* @category crypto
|
|
15348
|
+
* @since 4.0.0
|
|
15349
|
+
*/
|
|
15350
|
+
export const KeyWrapPublicKeyFromFormat = <A extends KeyWrap_.RsaOaep, Data>(
|
|
15351
|
+
format: KeyFormat_.Format<"public", "decode", Data>,
|
|
15352
|
+
algorithm: A
|
|
15353
|
+
): decodeTo<KeyWrapPublicKey<A>, Codec<Data>> =>
|
|
15354
|
+
cryptoKeyFromFormat(
|
|
15355
|
+
"KeyWrapPublicKeyFromFormat",
|
|
15356
|
+
KeyWrapPublicKey(algorithm),
|
|
15357
|
+
format,
|
|
15358
|
+
(data) =>
|
|
15359
|
+
KeyFormat_.decodePublic(format, algorithm, data) as Effect.Effect<
|
|
15360
|
+
KeyWrap_.PublicKey<A>,
|
|
15361
|
+
CryptoError_.CryptoError
|
|
15362
|
+
>,
|
|
15363
|
+
true
|
|
15364
|
+
)
|
|
15365
|
+
|
|
15366
|
+
/**
|
|
15367
|
+
* Type-level representation of {@link KeyWrapPrivateKey}.
|
|
15368
|
+
*
|
|
15369
|
+
* @stability unstable
|
|
15370
|
+
* @category models
|
|
15371
|
+
* @since 4.0.0
|
|
15372
|
+
*/
|
|
15373
|
+
export interface KeyWrapPrivateKey<A extends KeyWrap_.RsaOaep = KeyWrap_.RsaOaep>
|
|
15374
|
+
extends declare<KeyWrap_.PrivateKey<A>>
|
|
15375
|
+
{
|
|
15376
|
+
readonly "Rebuild": KeyWrapPrivateKey<A>
|
|
15377
|
+
}
|
|
15378
|
+
|
|
15379
|
+
/**
|
|
15380
|
+
* Schema for live RSA-OAEP `KeyWrap.PrivateKey` values of an algorithm.
|
|
15381
|
+
*
|
|
15382
|
+
* **Details**
|
|
15383
|
+
*
|
|
15384
|
+
* Decoding checks the key's algorithm and returns the key itself. The key has
|
|
15385
|
+
* no JSON form: `toCodecJson` fails with a `Forbidden` issue, so use
|
|
15386
|
+
* {@link KeyWrapPrivateKeyFromFormat} to read and write keys. RSA-OAEP keys
|
|
15387
|
+
* have no raw form. Keys display redacted, compare by reference, and have no
|
|
15388
|
+
* `Arbitrary`.
|
|
15389
|
+
*
|
|
15390
|
+
* @stability unstable
|
|
15391
|
+
* @category crypto
|
|
15392
|
+
* @since 4.0.0
|
|
15393
|
+
*/
|
|
15394
|
+
export const KeyWrapPrivateKey = <A extends KeyWrap_.RsaOaep>(algorithm: A): KeyWrapPrivateKey<A> =>
|
|
15395
|
+
declareCryptoKey<KeyWrap_.PrivateKey<A>>(
|
|
15396
|
+
"KeyWrapPrivateKey",
|
|
15397
|
+
"KeyWrap",
|
|
15398
|
+
"PrivateKey",
|
|
15399
|
+
KeyWrap_.isPrivateKey,
|
|
15400
|
+
algorithm
|
|
15401
|
+
)
|
|
15402
|
+
|
|
15403
|
+
/**
|
|
15404
|
+
* Schema that decodes an RSA-OAEP `KeyWrap.PrivateKey` with
|
|
15405
|
+
* `KeyFormat.decodePrivate`.
|
|
15406
|
+
*
|
|
15407
|
+
* **Details**
|
|
15408
|
+
*
|
|
15409
|
+
* The format must hold private keys: `KeyFormat.pkcs8`, `KeyFormat.jwk`,
|
|
15410
|
+
* `KeyFormat.pkcs1`, or their PEM forms. A format for another role is a type
|
|
15411
|
+
* error. Decoding runs the runtime's key import, so use the async decoding
|
|
15412
|
+
* functions: `Schema.decodeSync` throws. A `CryptoError` becomes an
|
|
15413
|
+
* `InvalidValue` issue whose `cause` is the error. Encoding fails with a
|
|
15414
|
+
* `Forbidden` issue unless `allowEncode` is `true`, and always for the
|
|
15415
|
+
* read-only PKCS#1 format.
|
|
15416
|
+
*
|
|
15417
|
+
* @stability unstable
|
|
15418
|
+
* @category crypto
|
|
15419
|
+
* @since 4.0.0
|
|
15420
|
+
*/
|
|
15421
|
+
export const KeyWrapPrivateKeyFromFormat = <A extends KeyWrap_.RsaOaep, Data>(
|
|
15422
|
+
format: KeyFormat_.Format<"private", "decode", Data>,
|
|
15423
|
+
algorithm: A,
|
|
15424
|
+
options?: CryptoKeyOptions
|
|
15425
|
+
): decodeTo<KeyWrapPrivateKey<A>, Codec<Data>> =>
|
|
15426
|
+
cryptoKeyFromFormat(
|
|
15427
|
+
"KeyWrapPrivateKeyFromFormat",
|
|
15428
|
+
KeyWrapPrivateKey(algorithm),
|
|
15429
|
+
format,
|
|
15430
|
+
(data) =>
|
|
15431
|
+
KeyFormat_.decodePrivate(format, algorithm, data) as Effect.Effect<
|
|
15432
|
+
KeyWrap_.PrivateKey<A>,
|
|
15433
|
+
CryptoError_.CryptoError
|
|
15434
|
+
>,
|
|
15435
|
+
options?.allowEncode === true
|
|
15436
|
+
)
|
|
15437
|
+
|
|
14310
15438
|
// -----------------------------------------------------------------------------
|
|
14311
15439
|
// Exit schemas
|
|
14312
15440
|
// -----------------------------------------------------------------------------
|