effect 4.1.0 → 4.1.2
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 +30 -0
- package/THIRD_PARTY_NOTICES.md +62 -0
- package/ai-docs/package.json +2 -2
- package/dist/BigDecimal.d.ts +139 -7
- package/dist/BigDecimal.d.ts.map +1 -1
- package/dist/BigDecimal.js +83 -14
- package/dist/BigDecimal.js.map +1 -1
- package/dist/ByteSize.d.ts.map +1 -1
- package/dist/ByteSize.js +27 -14
- package/dist/ByteSize.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/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 +38 -32
- package/dist/Iterable.js.map +1 -1
- package/dist/JsonSchema.d.ts.map +1 -1
- package/dist/JsonSchema.js +27 -6
- package/dist/JsonSchema.js.map +1 -1
- package/dist/MutableRef.d.ts.map +1 -1
- package/dist/MutableRef.js +0 -7
- package/dist/MutableRef.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.map +1 -1
- package/dist/Pool.js +2 -1
- package/dist/Pool.js.map +1 -1
- package/dist/Ref.d.ts.map +1 -1
- package/dist/Ref.js +0 -8
- package/dist/Ref.js.map +1 -1
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +8 -3
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +2 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +2 -1
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +4 -2
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +4 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +2 -2
- package/dist/SchemaTransformation.js +2 -2
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +6 -5
- package/dist/Stream.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 +120 -6
- package/dist/ai/McpServer.d.ts.map +1 -1
- package/dist/ai/McpServer.js +258 -49
- package/dist/ai/McpServer.js.map +1 -1
- 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/Tool.d.ts.map +1 -1
- package/dist/ai/Tool.js +5 -7
- package/dist/ai/Tool.js.map +1 -1
- package/dist/ai/internal/mcpCore.js +72 -3
- package/dist/ai/internal/mcpCore.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2024_11_05.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_03_26.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_06_18.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js +3 -1
- package/dist/ai/internal/mcpProtocol/v2025_11_25.js.map +1 -1
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js +44 -8
- package/dist/ai/internal/mcpProtocol/v2026_07_28.js.map +1 -1
- package/dist/ai/internal/mcpProtocol.js +12 -0
- package/dist/ai/internal/mcpProtocol.js.map +1 -1
- package/dist/ai/internal/mcpRuntime.js +3 -3
- 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/structured-output.js +11 -2
- package/dist/ai/internal/structured-output.js.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/cluster/ClusterWorkflowEngine.js +30 -11
- package/dist/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/cluster/Entity.d.ts +26 -0
- package/dist/cluster/Entity.d.ts.map +1 -1
- package/dist/cluster/Entity.js.map +1 -1
- package/dist/cluster/MessageStorage.d.ts +6 -6
- package/dist/cluster/MessageStorage.d.ts.map +1 -1
- package/dist/cluster/MessageStorage.js +1 -3
- package/dist/cluster/MessageStorage.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/Runners.d.ts.map +1 -1
- package/dist/cluster/Runners.js +13 -2
- package/dist/cluster/Runners.js.map +1 -1
- package/dist/cluster/Sharding.d.ts +13 -0
- package/dist/cluster/Sharding.d.ts.map +1 -1
- package/dist/cluster/Sharding.js +4 -1
- package/dist/cluster/Sharding.js.map +1 -1
- package/dist/cluster/internal/clusterAbandon.d.ts.map +1 -1
- package/dist/cluster/internal/clusterAbandon.js +6 -4
- package/dist/cluster/internal/clusterAbandon.js.map +1 -1
- package/dist/cluster/internal/entityManager.js +63 -11
- package/dist/cluster/internal/entityManager.js.map +1 -1
- package/dist/cluster/internal/transactionNotifications.d.ts +5 -0
- package/dist/cluster/internal/transactionNotifications.d.ts.map +1 -0
- package/dist/cluster/internal/transactionNotifications.js +5 -0
- package/dist/cluster/internal/transactionNotifications.js.map +1 -0
- package/dist/crypto/Aead.d.ts +2 -1
- package/dist/crypto/Aead.d.ts.map +1 -1
- package/dist/crypto/Aead.js +2 -2
- package/dist/crypto/Aead.js.map +1 -1
- package/dist/crypto/Cipher.d.ts +2 -1
- package/dist/crypto/Cipher.d.ts.map +1 -1
- package/dist/crypto/Cipher.js +2 -2
- package/dist/crypto/Cipher.js.map +1 -1
- package/dist/crypto/KeyAgreement.d.ts +3 -2
- package/dist/crypto/KeyAgreement.d.ts.map +1 -1
- package/dist/crypto/KeyAgreement.js +2 -2
- package/dist/crypto/KeyAgreement.js.map +1 -1
- package/dist/crypto/KeyFormat.d.ts +33 -1
- package/dist/crypto/KeyFormat.d.ts.map +1 -1
- package/dist/crypto/KeyFormat.js.map +1 -1
- package/dist/crypto/KeyWrap.d.ts +4 -3
- package/dist/crypto/KeyWrap.d.ts.map +1 -1
- package/dist/crypto/KeyWrap.js +2 -2
- package/dist/crypto/KeyWrap.js.map +1 -1
- package/dist/crypto/Mac.d.ts +2 -1
- package/dist/crypto/Mac.d.ts.map +1 -1
- package/dist/crypto/Mac.js +2 -2
- package/dist/crypto/Mac.js.map +1 -1
- package/dist/crypto/Signature.d.ts +3 -2
- package/dist/crypto/Signature.d.ts.map +1 -1
- package/dist/crypto/Signature.js +2 -2
- package/dist/crypto/Signature.js.map +1 -1
- package/dist/crypto/WebCrypto.d.ts +19 -0
- package/dist/crypto/WebCrypto.d.ts.map +1 -1
- package/dist/crypto/WebCrypto.js.map +1 -1
- package/dist/crypto/internal/asymmetric.js.map +1 -1
- package/dist/crypto/internal/key.js +3 -2
- package/dist/crypto/internal/key.js.map +1 -1
- package/dist/encoding/Base64Url.d.ts.map +1 -1
- package/dist/encoding/Base64Url.js +26 -3
- package/dist/encoding/Base64Url.js.map +1 -1
- package/dist/encoding/Json5.d.ts +44 -0
- package/dist/encoding/Json5.d.ts.map +1 -0
- package/dist/encoding/Json5.js +56 -0
- package/dist/encoding/Json5.js.map +1 -0
- package/dist/encoding/Jsonc.d.ts +47 -0
- package/dist/encoding/Jsonc.d.ts.map +1 -0
- package/dist/encoding/Jsonc.js +120 -0
- package/dist/encoding/Jsonc.js.map +1 -0
- 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 +94 -0
- package/dist/encoding/SchemaBinary.d.ts.map +1 -1
- package/dist/encoding/SchemaBinary.js +219 -6
- 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/index.d.ts +10 -0
- package/dist/encoding/index.d.ts.map +1 -1
- package/dist/encoding/index.js +10 -0
- package/dist/encoding/index.js.map +1 -1
- package/dist/eventlog/EventLog.d.ts +7 -0
- package/dist/eventlog/EventLog.d.ts.map +1 -1
- package/dist/eventlog/EventLog.js +7 -0
- package/dist/eventlog/EventLog.js.map +1 -1
- package/dist/eventlog/EventLogServer.d.ts +7 -1
- package/dist/eventlog/EventLogServer.d.ts.map +1 -1
- package/dist/eventlog/EventLogServer.js +55 -24
- package/dist/eventlog/EventLogServer.js.map +1 -1
- package/dist/eventlog/EventLogServerEncrypted.d.ts +10 -0
- package/dist/eventlog/EventLogServerEncrypted.d.ts.map +1 -1
- 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 +21 -0
- package/dist/eventlog/EventLogSessionAuth.d.ts.map +1 -1
- package/dist/eventlog/EventLogSessionAuth.js +22 -0
- package/dist/eventlog/EventLogSessionAuth.js.map +1 -1
- 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/HttpClient.d.ts +204 -16
- package/dist/http/HttpClient.d.ts.map +1 -1
- package/dist/http/HttpClient.js +93 -13
- package/dist/http/HttpClient.js.map +1 -1
- package/dist/http/HttpServerRequest.d.ts.map +1 -1
- package/dist/http/HttpServerRequest.js +38 -22
- package/dist/http/HttpServerRequest.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-api/HttpApiSchema.js +1 -1
- package/dist/http-api/HttpApiSchema.js.map +1 -1
- package/dist/internal/dateTime.js +66 -27
- package/dist/internal/dateTime.js.map +1 -1
- package/dist/internal/effect.js +10 -0
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/glob.js +234 -56
- package/dist/internal/glob.js.map +1 -1
- 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/jsonParser.d.ts +5 -0
- package/dist/internal/jsonParser.d.ts.map +1 -0
- package/dist/internal/jsonParser.js +280 -0
- package/dist/internal/jsonParser.js.map +1 -0
- package/dist/internal/persistence.js +8 -1
- package/dist/internal/persistence.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/sql.js +16 -0
- package/dist/internal/sql.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/OtlpExporter.d.ts +4 -0
- package/dist/observability/OtlpExporter.d.ts.map +1 -1
- package/dist/observability/OtlpExporter.js +40 -12
- package/dist/observability/OtlpExporter.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/RateLimiter.d.ts +15 -0
- package/dist/persistence/RateLimiter.d.ts.map +1 -1
- package/dist/persistence/RateLimiter.js +76 -16
- 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/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 +14 -2
- package/dist/rpc/RpcClient.d.ts.map +1 -1
- package/dist/rpc/RpcClient.js +38 -21
- package/dist/rpc/RpcClient.js.map +1 -1
- package/dist/rpc/RpcMessage.d.ts +3 -2
- package/dist/rpc/RpcMessage.d.ts.map +1 -1
- package/dist/rpc/RpcMessage.js.map +1 -1
- package/dist/rpc/RpcServer.d.ts.map +1 -1
- package/dist/rpc/RpcServer.js +10 -1
- package/dist/rpc/RpcServer.js.map +1 -1
- package/dist/sql/Migrator.d.ts +9 -1
- package/dist/sql/Migrator.d.ts.map +1 -1
- package/dist/sql/Migrator.js +18 -6
- package/dist/sql/Migrator.js.map +1 -1
- package/dist/sql/SqlClient.d.ts +46 -3
- package/dist/sql/SqlClient.d.ts.map +1 -1
- package/dist/sql/SqlClient.js +40 -15
- package/dist/sql/SqlClient.js.map +1 -1
- package/dist/sql/Statement.d.ts +46 -3
- package/dist/sql/Statement.d.ts.map +1 -1
- package/dist/sql/Statement.js +32 -26
- package/dist/sql/Statement.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/package.json +7 -3
- package/src/BigDecimal.ts +170 -16
- package/src/ByteSize.ts +29 -14
- package/src/Equal.ts +3 -3
- package/src/Hash.ts +5 -4
- package/src/Iterable.ts +28 -19
- package/src/JsonSchema.ts +45 -7
- package/src/MutableRef.ts +1 -8
- package/src/Path.ts +6 -1
- package/src/Pool.ts +2 -1
- package/src/Ref.ts +0 -8
- package/src/Schedule.ts +8 -6
- package/src/Schema.ts +3 -2
- package/src/SchemaRepresentation.ts +4 -2
- package/src/SchemaTransformation.ts +2 -2
- package/src/Stream.ts +6 -5
- package/src/ai/McpClient.ts +488 -91
- package/src/ai/McpSchema.ts +119 -0
- package/src/ai/McpServer.ts +302 -56
- package/src/ai/Prompt.ts +16 -11
- package/src/ai/Tool.ts +5 -10
- package/src/ai/internal/mcpCore.ts +165 -12
- package/src/ai/internal/mcpProtocol/v2024_11_05.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_03_26.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_06_18.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2025_11_25.ts +3 -1
- package/src/ai/internal/mcpProtocol/v2026_07_28.ts +42 -9
- package/src/ai/internal/mcpProtocol.ts +15 -0
- package/src/ai/internal/mcpRuntime.ts +6 -3
- package/src/ai/internal/mcpSkills.ts +480 -0
- package/src/ai/internal/structured-output.ts +10 -4
- package/src/cluster/ClusterWorkflowEngine.ts +48 -33
- package/src/cluster/Entity.ts +52 -0
- package/src/cluster/MessageStorage.ts +3 -6
- package/src/cluster/Reply.ts +1 -1
- package/src/cluster/Runners.ts +16 -2
- package/src/cluster/Sharding.ts +17 -1
- package/src/cluster/internal/clusterAbandon.ts +7 -7
- package/src/cluster/internal/entityManager.ts +89 -15
- package/src/cluster/internal/transactionNotifications.ts +7 -0
- package/src/crypto/Aead.ts +3 -3
- package/src/crypto/Cipher.ts +3 -3
- package/src/crypto/KeyAgreement.ts +4 -4
- package/src/crypto/KeyFormat.ts +30 -1
- package/src/crypto/KeyWrap.ts +6 -6
- package/src/crypto/Mac.ts +3 -3
- package/src/crypto/Signature.ts +4 -4
- package/src/crypto/WebCrypto.ts +20 -0
- package/src/crypto/internal/asymmetric.ts +2 -1
- package/src/crypto/internal/key.ts +12 -5
- package/src/encoding/Base64Url.ts +27 -3
- package/src/encoding/Json5.ts +59 -0
- package/src/encoding/Jsonc.ts +126 -0
- package/src/encoding/Ndjson.ts +6 -5
- package/src/encoding/SchemaBinary.ts +228 -7
- package/src/encoding/Sse.ts +5 -3
- package/src/encoding/index.ts +12 -0
- package/src/eventlog/EventLog.ts +7 -0
- package/src/eventlog/EventLogServer.ts +67 -24
- package/src/eventlog/EventLogServerEncrypted.ts +5 -0
- package/src/eventlog/EventLogServerUnencrypted.ts +19 -2
- package/src/eventlog/EventLogSessionAuth.ts +26 -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/HttpClient.ts +244 -33
- package/src/http/HttpServerRequest.ts +61 -23
- package/src/http/internal/mimeTypes.ts +4 -1
- package/src/http-api/HttpApiSchema.ts +1 -1
- package/src/internal/dateTime.ts +80 -27
- package/src/internal/effect.ts +6 -0
- package/src/internal/glob.ts +279 -63
- package/src/internal/graphql.ts +27 -9
- package/src/internal/graphqlHeaders.ts +13 -0
- package/src/internal/jsonParser.ts +307 -0
- package/src/internal/persistence.ts +9 -1
- package/src/internal/request.ts +51 -58
- package/src/internal/schema/fromJsonSchemaDocument.ts +11 -10
- package/src/internal/sql.ts +25 -0
- 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/OtlpExporter.ts +42 -18
- 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/RateLimiter.ts +97 -19
- package/src/persistence/index.ts +1 -1
- package/src/reactivity/AtomRegistry.ts +19 -8
- package/src/rpc/Rpc.ts +3 -1
- package/src/rpc/RpcClient.ts +44 -24
- package/src/rpc/RpcMessage.ts +3 -2
- package/src/rpc/RpcServer.ts +12 -1
- package/src/sql/Migrator.ts +35 -18
- package/src/sql/SqlClient.ts +91 -22
- package/src/sql/Statement.ts +60 -35
- package/src/workflow/Workflow.ts +4 -0
- package/src/workflow/WorkflowEngine.ts +5 -0
package/src/jose/Jws.ts
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact JSON Web Signatures.
|
|
3
|
+
*
|
|
4
|
+
* The signing algorithm is the key's: {@link sign} writes it into the
|
|
5
|
+
* protected header and {@link verify} rejects a token whose `alg` differs.
|
|
6
|
+
* {@link verifyWithKeySet} resolves the key from the `Jwks` service and
|
|
7
|
+
* requires an allowlist of asymmetric algorithms. Headers with `crit` or `b64`
|
|
8
|
+
* are rejected.
|
|
9
|
+
*
|
|
10
|
+
* Bound untrusted token length before verification; this module does not
|
|
11
|
+
* impose a token-size limit.
|
|
12
|
+
*
|
|
13
|
+
* HMAC signatures run on the `Mac` service. On Node.js and Bun,
|
|
14
|
+
* `NodeCrypto.layerMac` and `BunCrypto.layerMac` compute them synchronously
|
|
15
|
+
* with `node:crypto` instead of through Web Crypto for byte-backed keys, such
|
|
16
|
+
* as those from `Jwk.importSecret`.
|
|
17
|
+
*
|
|
18
|
+
* @stability unstable
|
|
19
|
+
* @since 4.1.1
|
|
20
|
+
*/
|
|
21
|
+
import * as Mac from "../crypto/Mac.ts"
|
|
22
|
+
import * as Signature from "../crypto/Signature.ts"
|
|
23
|
+
import * as Effect from "../Effect.ts"
|
|
24
|
+
import * as Base64Url from "../encoding/Base64Url.ts"
|
|
25
|
+
import * as Redacted from "../Redacted.ts"
|
|
26
|
+
import * as Schema from "../Schema.ts"
|
|
27
|
+
import {
|
|
28
|
+
cryptoFailure,
|
|
29
|
+
decodeHeader,
|
|
30
|
+
decodeSegment,
|
|
31
|
+
encodeHeader,
|
|
32
|
+
fail,
|
|
33
|
+
invalidArgument,
|
|
34
|
+
invalidToken,
|
|
35
|
+
split,
|
|
36
|
+
utf8
|
|
37
|
+
} from "./internal/compact.ts"
|
|
38
|
+
import * as JoseError from "./JoseError.ts"
|
|
39
|
+
import {
|
|
40
|
+
Algorithm,
|
|
41
|
+
AsymmetricAlgorithm,
|
|
42
|
+
type HmacAlgorithm,
|
|
43
|
+
type PublicKey,
|
|
44
|
+
type SecretKey,
|
|
45
|
+
type SigningKey,
|
|
46
|
+
type VerificationKey
|
|
47
|
+
} from "./Jwk.ts"
|
|
48
|
+
import { Jwks } from "./Jwks.ts"
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Schema for an authenticated JWS protected header, including additional
|
|
52
|
+
* JSON-valued parameters.
|
|
53
|
+
*
|
|
54
|
+
* @stability unstable
|
|
55
|
+
* @category schemas
|
|
56
|
+
* @since 4.1.1
|
|
57
|
+
*/
|
|
58
|
+
export const ProtectedHeader = Schema.StructWithRest(
|
|
59
|
+
Schema.Struct({
|
|
60
|
+
alg: Algorithm,
|
|
61
|
+
kid: Schema.optionalKey(Schema.String),
|
|
62
|
+
typ: Schema.optionalKey(Schema.String),
|
|
63
|
+
cty: Schema.optionalKey(Schema.String)
|
|
64
|
+
}),
|
|
65
|
+
[Schema.Record(Schema.String, Schema.Json)]
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* An authenticated JWS protected header.
|
|
70
|
+
*
|
|
71
|
+
* @stability unstable
|
|
72
|
+
* @category models
|
|
73
|
+
* @since 4.1.1
|
|
74
|
+
*/
|
|
75
|
+
export type ProtectedHeader = typeof ProtectedHeader.Type
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Standard header parameters to sign. Signing also accepts additional
|
|
79
|
+
* JSON-valued parameters. `alg` comes from the key and `kid` defaults to the
|
|
80
|
+
* key's.
|
|
81
|
+
*
|
|
82
|
+
* @stability unstable
|
|
83
|
+
* @category models
|
|
84
|
+
* @since 4.1.1
|
|
85
|
+
*/
|
|
86
|
+
export interface Header {
|
|
87
|
+
readonly alg?: never
|
|
88
|
+
readonly crit?: never
|
|
89
|
+
readonly b64?: never
|
|
90
|
+
readonly kid?: string | undefined
|
|
91
|
+
readonly typ?: string | undefined
|
|
92
|
+
readonly cty?: string | undefined
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The protected header and payload of a verified JWS.
|
|
97
|
+
*
|
|
98
|
+
* @stability unstable
|
|
99
|
+
* @category models
|
|
100
|
+
* @since 4.1.1
|
|
101
|
+
*/
|
|
102
|
+
export interface Verified {
|
|
103
|
+
readonly protectedHeader: ProtectedHeader
|
|
104
|
+
readonly payload: Uint8Array
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Options for {@link verifyWithKeySet}.
|
|
109
|
+
*
|
|
110
|
+
* @stability unstable
|
|
111
|
+
* @category models
|
|
112
|
+
* @since 4.1.1
|
|
113
|
+
*/
|
|
114
|
+
export interface VerifyWithKeySetOptions {
|
|
115
|
+
/**
|
|
116
|
+
* The algorithms a token may use. Must not be empty.
|
|
117
|
+
*/
|
|
118
|
+
readonly algorithms: ReadonlyArray<AsymmetricAlgorithm>
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Services required to sign and verify with any key.
|
|
123
|
+
*
|
|
124
|
+
* @stability unstable
|
|
125
|
+
* @category models
|
|
126
|
+
* @since 4.1.1
|
|
127
|
+
*/
|
|
128
|
+
export type Requirements = Mac.Mac | Signature.Signature
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Services required to sign or verify with a key of type `K`: `Mac` for
|
|
132
|
+
* HMAC keys and `Signature` for asymmetric keys. A union of key types
|
|
133
|
+
* requires both.
|
|
134
|
+
*
|
|
135
|
+
* @stability unstable
|
|
136
|
+
* @category models
|
|
137
|
+
* @since 4.1.1
|
|
138
|
+
*/
|
|
139
|
+
export type KeyRequirements<K extends SigningKey | VerificationKey> = K extends SecretKey<HmacAlgorithm> ? Mac.Mac
|
|
140
|
+
: Signature.Signature
|
|
141
|
+
|
|
142
|
+
const decodeProtectedHeader = Schema.decodeUnknownOption(ProtectedHeader)
|
|
143
|
+
|
|
144
|
+
interface Parsed {
|
|
145
|
+
readonly protectedHeader: ProtectedHeader
|
|
146
|
+
readonly payload: Uint8Array
|
|
147
|
+
readonly signature: Uint8Array
|
|
148
|
+
readonly signingInput: Uint8Array
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Parses a compact JWS without verifying it.
|
|
153
|
+
*
|
|
154
|
+
* @internal
|
|
155
|
+
*/
|
|
156
|
+
export const parse = Effect.fnUntraced(function*(
|
|
157
|
+
token: string | Redacted.Redacted<string>
|
|
158
|
+
): Effect.fn.Return<Parsed, JoseError.JoseError> {
|
|
159
|
+
const [header, payload, signature] = yield* split(token, 3)
|
|
160
|
+
const protectedHeader = yield* decodeHeader(header, decodeProtectedHeader, ["crit", "b64"])
|
|
161
|
+
const payloadBytes = decodeSegment(payload)
|
|
162
|
+
const signatureBytes = decodeSegment(signature)
|
|
163
|
+
if (payloadBytes === undefined || signatureBytes === undefined) {
|
|
164
|
+
return yield* invalidToken("The payload or signature is not base64url")
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
protectedHeader,
|
|
168
|
+
payload: payloadBytes,
|
|
169
|
+
signature: signatureBytes,
|
|
170
|
+
signingInput: utf8(`${header}.${payload}`)
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
const signFailure = cryptoFailure("Could not sign with the key")
|
|
175
|
+
const verifyFailure = cryptoFailure("Could not verify with the key")
|
|
176
|
+
|
|
177
|
+
const isAsymmetricAlgorithm = Schema.is(AsymmetricAlgorithm)
|
|
178
|
+
|
|
179
|
+
const algorithmNotAllowed = fail(new JoseError.AlgorithmNotAllowed())
|
|
180
|
+
|
|
181
|
+
const authenticated = (parsed: Parsed, valid: boolean): Effect.Effect<Verified, JoseError.JoseError> =>
|
|
182
|
+
valid
|
|
183
|
+
? Effect.succeed({ protectedHeader: parsed.protectedHeader, payload: parsed.payload })
|
|
184
|
+
: fail(new JoseError.SignatureVerificationFailed())
|
|
185
|
+
|
|
186
|
+
const verifySignature = Effect.fnUntraced(function*(
|
|
187
|
+
parsed: Parsed,
|
|
188
|
+
key: PublicKey
|
|
189
|
+
): Effect.fn.Return<Verified, JoseError.JoseError, Signature.Signature> {
|
|
190
|
+
const signature = yield* Signature.Signature
|
|
191
|
+
const valid = yield* signature.verify(key.key, parsed.signature, parsed.signingInput).pipe(
|
|
192
|
+
Effect.mapError(verifyFailure)
|
|
193
|
+
)
|
|
194
|
+
return yield* authenticated(parsed, valid)
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Signs a payload as a compact JWS with the key's algorithm.
|
|
199
|
+
*
|
|
200
|
+
* **Example** (Signing and verifying a payload)
|
|
201
|
+
*
|
|
202
|
+
* ```ts import.meta.vitest
|
|
203
|
+
* import { Effect, Layer, Redacted } from "effect"
|
|
204
|
+
* import { Mac, SecureRandom, Signature } from "effect/crypto"
|
|
205
|
+
* import { Jwk, Jws } from "effect/jose"
|
|
206
|
+
*
|
|
207
|
+
* const layer = Layer.mergeAll(Mac.layerWebCrypto, Signature.layerWebCrypto).pipe(
|
|
208
|
+
* Layer.provide(SecureRandom.layerWebCrypto)
|
|
209
|
+
* )
|
|
210
|
+
*
|
|
211
|
+
* const payload = await Effect.runPromise(Effect.gen(function*() {
|
|
212
|
+
* // Fixed public example material; generate application secrets securely.
|
|
213
|
+
* const key = yield* Jwk.importSecret(
|
|
214
|
+
* Redacted.make({ kty: "oct", k: "BwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc" } as const),
|
|
215
|
+
* "HS256"
|
|
216
|
+
* )
|
|
217
|
+
* const token = yield* Jws.sign(new TextEncoder().encode("hello"), key)
|
|
218
|
+
* const verified = yield* Jws.verify(token, key)
|
|
219
|
+
* return new TextDecoder().decode(verified.payload)
|
|
220
|
+
* }).pipe(Effect.provide(layer)))
|
|
221
|
+
* payload // => "hello"
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* @see {@link verify}
|
|
225
|
+
*
|
|
226
|
+
* @stability unstable
|
|
227
|
+
* @category cryptography
|
|
228
|
+
* @since 4.1.1
|
|
229
|
+
*/
|
|
230
|
+
export const sign: <
|
|
231
|
+
K extends SigningKey,
|
|
232
|
+
H extends object & { readonly [P in keyof H]: Schema.Json | undefined } = Header
|
|
233
|
+
>(
|
|
234
|
+
payload: Uint8Array,
|
|
235
|
+
key: K,
|
|
236
|
+
header?: Header & H
|
|
237
|
+
) => Effect.Effect<Redacted.Redacted<string>, JoseError.JoseError, KeyRequirements<K>> = Effect.fnUntraced(function*(
|
|
238
|
+
payload: Uint8Array,
|
|
239
|
+
key: SigningKey,
|
|
240
|
+
header?: Header
|
|
241
|
+
): Effect.fn.Return<Redacted.Redacted<string>, JoseError.JoseError, Requirements> {
|
|
242
|
+
const protectedHeader = yield* encodeHeader({ alg: key.algorithm }, key.kid, header, ["crit", "b64"])
|
|
243
|
+
const signingInput = `${protectedHeader}.${Base64Url.encode(payload)}`
|
|
244
|
+
const data = utf8(signingInput)
|
|
245
|
+
let signature: Uint8Array
|
|
246
|
+
if (key._tag === "SecretKey") {
|
|
247
|
+
const mac = yield* Mac.Mac
|
|
248
|
+
signature = yield* mac.sign(key.key, data).pipe(Effect.mapError(signFailure))
|
|
249
|
+
} else {
|
|
250
|
+
const signer = yield* Signature.Signature
|
|
251
|
+
signature = yield* signer.sign(key.key, data).pipe(Effect.mapError(signFailure))
|
|
252
|
+
}
|
|
253
|
+
return Redacted.make(`${signingInput}.${Base64Url.encode(signature)}`)
|
|
254
|
+
}) as any // Each branch uses only the service its key type requires.
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Verifies a compact JWS with a key. The token's `alg` must be the key's
|
|
258
|
+
* algorithm.
|
|
259
|
+
*
|
|
260
|
+
* @see {@link sign}
|
|
261
|
+
* @see {@link verifyWithKeySet} for resolving the key from the `Jwks` service
|
|
262
|
+
*
|
|
263
|
+
* @stability unstable
|
|
264
|
+
* @category cryptography
|
|
265
|
+
* @since 4.1.1
|
|
266
|
+
*/
|
|
267
|
+
export const verify: <K extends VerificationKey>(
|
|
268
|
+
token: string | Redacted.Redacted<string>,
|
|
269
|
+
key: K
|
|
270
|
+
) => Effect.Effect<Verified, JoseError.JoseError, KeyRequirements<K>> = Effect.fnUntraced(function*(
|
|
271
|
+
token: string | Redacted.Redacted<string>,
|
|
272
|
+
key: VerificationKey
|
|
273
|
+
): Effect.fn.Return<Verified, JoseError.JoseError, Requirements> {
|
|
274
|
+
const parsed = yield* parse(token)
|
|
275
|
+
if (parsed.protectedHeader.alg !== key.algorithm) return yield* algorithmNotAllowed
|
|
276
|
+
if (key._tag === "PublicKey") return yield* verifySignature(parsed, key)
|
|
277
|
+
const mac = yield* Mac.Mac
|
|
278
|
+
const valid = yield* mac.verify(key.key, parsed.signature, parsed.signingInput).pipe(
|
|
279
|
+
Effect.mapError(verifyFailure)
|
|
280
|
+
)
|
|
281
|
+
return yield* authenticated(parsed, valid)
|
|
282
|
+
}) as any // Each branch uses only the service its key type requires.
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Verifies a compact JWS with a public key resolved from the `Jwks` service by
|
|
286
|
+
* the token's `alg` and `kid`.
|
|
287
|
+
*
|
|
288
|
+
* **Details**
|
|
289
|
+
*
|
|
290
|
+
* The token's `alg` must be in `algorithms`, which is checked before any key
|
|
291
|
+
* lookup. The resolved key's algorithm must match the token's. HMAC tokens
|
|
292
|
+
* are always rejected.
|
|
293
|
+
*
|
|
294
|
+
* @see {@link verify} for verifying with a known key
|
|
295
|
+
*
|
|
296
|
+
* @stability unstable
|
|
297
|
+
* @category cryptography
|
|
298
|
+
* @since 4.1.1
|
|
299
|
+
*/
|
|
300
|
+
export const verifyWithKeySet = Effect.fnUntraced(function*(
|
|
301
|
+
token: string | Redacted.Redacted<string>,
|
|
302
|
+
options: VerifyWithKeySetOptions
|
|
303
|
+
): Effect.fn.Return<Verified & { readonly key: PublicKey }, JoseError.JoseError, Jwks | Signature.Signature> {
|
|
304
|
+
if (options.algorithms.length === 0) return yield* invalidArgument("algorithms must not be empty")
|
|
305
|
+
const parsed = yield* parse(token)
|
|
306
|
+
const { alg, kid } = parsed.protectedHeader
|
|
307
|
+
if (!isAsymmetricAlgorithm(alg) || !options.algorithms.includes(alg)) return yield* algorithmNotAllowed
|
|
308
|
+
const jwks = yield* Jwks
|
|
309
|
+
const key = yield* jwks.resolve({ algorithm: alg, kid, protectedHeader: parsed.protectedHeader })
|
|
310
|
+
if (key.algorithm !== alg) return yield* algorithmNotAllowed
|
|
311
|
+
return { ...(yield* verifySignature(parsed, key)), key }
|
|
312
|
+
})
|