@abloatai/transaction 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONVENTIONS.md +83 -0
- package/README.md +48 -0
- package/dist/ablo.d.ts +90 -0
- package/dist/ablo.d.ts.map +1 -0
- package/dist/ablo.js +34 -0
- package/dist/ablo.js.map +1 -0
- package/dist/ai-sdk/coordinatedTool.d.ts +123 -0
- package/dist/ai-sdk/coordinatedTool.d.ts.map +1 -0
- package/dist/ai-sdk/coordinatedTool.js +135 -0
- package/dist/ai-sdk/coordinatedTool.js.map +1 -0
- package/dist/ai-sdk/index.d.ts +2 -0
- package/dist/ai-sdk/index.d.ts.map +1 -0
- package/dist/ai-sdk/index.js +2 -0
- package/dist/ai-sdk/index.js.map +1 -0
- package/dist/auth/apiKey.d.ts +154 -0
- package/dist/auth/apiKey.d.ts.map +1 -0
- package/dist/auth/apiKey.js +408 -0
- package/dist/auth/apiKey.js.map +1 -0
- package/dist/auth/bootstrapScope.d.ts +16 -0
- package/dist/auth/bootstrapScope.d.ts.map +1 -0
- package/dist/auth/bootstrapScope.js +2 -0
- package/dist/auth/bootstrapScope.js.map +1 -0
- package/dist/auth/browserCredentialSafety.d.ts +7 -0
- package/dist/auth/browserCredentialSafety.d.ts.map +1 -0
- package/dist/auth/browserCredentialSafety.js +29 -0
- package/dist/auth/browserCredentialSafety.js.map +1 -0
- package/dist/auth/capability.d.ts +241 -0
- package/dist/auth/capability.d.ts.map +1 -0
- package/dist/auth/capability.js +253 -0
- package/dist/auth/capability.js.map +1 -0
- package/dist/auth/capabilityLifecycle.d.ts +47 -0
- package/dist/auth/capabilityLifecycle.d.ts.map +1 -0
- package/dist/auth/capabilityLifecycle.js +108 -0
- package/dist/auth/capabilityLifecycle.js.map +1 -0
- package/dist/auth/credentialEndpoint.d.ts +10 -0
- package/dist/auth/credentialEndpoint.d.ts.map +1 -0
- package/dist/auth/credentialEndpoint.js +58 -0
- package/dist/auth/credentialEndpoint.js.map +1 -0
- package/dist/auth/credentialEndpointProtocol.d.ts +24 -0
- package/dist/auth/credentialEndpointProtocol.d.ts.map +1 -0
- package/dist/auth/credentialEndpointProtocol.js +34 -0
- package/dist/auth/credentialEndpointProtocol.js.map +1 -0
- package/dist/auth/credentialKind.d.ts +4 -0
- package/dist/auth/credentialKind.d.ts.map +1 -0
- package/dist/auth/credentialKind.js +15 -0
- package/dist/auth/credentialKind.js.map +1 -0
- package/dist/auth/credentialPolicy.d.ts +141 -0
- package/dist/auth/credentialPolicy.d.ts.map +1 -0
- package/dist/auth/credentialPolicy.js +113 -0
- package/dist/auth/credentialPolicy.js.map +1 -0
- package/dist/auth/credentialResult.d.ts +7 -0
- package/dist/auth/credentialResult.d.ts.map +1 -0
- package/dist/auth/credentialResult.js +9 -0
- package/dist/auth/credentialResult.js.map +1 -0
- package/dist/auth/credentialSource.d.ts +31 -0
- package/dist/auth/credentialSource.d.ts.map +1 -0
- package/dist/auth/credentialSource.js +56 -0
- package/dist/auth/credentialSource.js.map +1 -0
- package/dist/auth/hostedEndpoints.d.ts +22 -0
- package/dist/auth/hostedEndpoints.d.ts.map +1 -0
- package/dist/auth/hostedEndpoints.js +22 -0
- package/dist/auth/hostedEndpoints.js.map +1 -0
- package/dist/auth/identity.d.ts +62 -0
- package/dist/auth/identity.d.ts.map +1 -0
- package/dist/auth/identity.js +224 -0
- package/dist/auth/identity.js.map +1 -0
- package/dist/auth/index.d.ts +189 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +312 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/schemas.d.ts +41 -0
- package/dist/auth/schemas.d.ts.map +1 -0
- package/dist/auth/schemas.js +69 -0
- package/dist/auth/schemas.js.map +1 -0
- package/dist/auth/sessionMint.d.ts +29 -0
- package/dist/auth/sessionMint.d.ts.map +1 -0
- package/dist/auth/sessionMint.js +92 -0
- package/dist/auth/sessionMint.js.map +1 -0
- package/dist/auth/token.d.ts +4 -0
- package/dist/auth/token.d.ts.map +1 -0
- package/dist/auth/token.js +4 -0
- package/dist/auth/token.js.map +1 -0
- package/dist/batching/index.d.ts +56 -0
- package/dist/batching/index.d.ts.map +1 -0
- package/dist/batching/index.js +148 -0
- package/dist/batching/index.js.map +1 -0
- package/dist/coordination/awaitClaimGrant.d.ts +57 -0
- package/dist/coordination/awaitClaimGrant.d.ts.map +1 -0
- package/dist/coordination/awaitClaimGrant.js +138 -0
- package/dist/coordination/awaitClaimGrant.js.map +1 -0
- package/dist/coordination/claimHeartbeatLoop.d.ts +85 -0
- package/dist/coordination/claimHeartbeatLoop.d.ts.map +1 -0
- package/dist/coordination/claimHeartbeatLoop.js +109 -0
- package/dist/coordination/claimHeartbeatLoop.js.map +1 -0
- package/dist/coordination/claimMeta.d.ts +50 -0
- package/dist/coordination/claimMeta.d.ts.map +1 -0
- package/dist/coordination/claimMeta.js +53 -0
- package/dist/coordination/claimMeta.js.map +1 -0
- package/dist/coordination/events.d.ts +75 -0
- package/dist/coordination/events.d.ts.map +1 -0
- package/dist/coordination/events.js +8 -0
- package/dist/coordination/events.js.map +1 -0
- package/dist/coordination/index.d.ts +20 -0
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +46 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/coordination/locator.d.ts +106 -0
- package/dist/coordination/locator.d.ts.map +1 -0
- package/dist/coordination/locator.js +110 -0
- package/dist/coordination/locator.js.map +1 -0
- package/dist/coordination/schema.d.ts +1332 -0
- package/dist/coordination/schema.d.ts.map +1 -0
- package/dist/coordination/schema.js +1137 -0
- package/dist/coordination/schema.js.map +1 -0
- package/dist/coordination/targetConflict.d.ts +3 -0
- package/dist/coordination/targetConflict.d.ts.map +1 -0
- package/dist/coordination/targetConflict.js +74 -0
- package/dist/coordination/targetConflict.js.map +1 -0
- package/dist/coordination/trace.d.ts +79 -0
- package/dist/coordination/trace.d.ts.map +1 -0
- package/dist/coordination/trace.js +139 -0
- package/dist/coordination/trace.js.map +1 -0
- package/dist/docs/catalog.d.ts +73 -0
- package/dist/docs/catalog.d.ts.map +1 -0
- package/dist/docs/catalog.js +231 -0
- package/dist/docs/catalog.js.map +1 -0
- package/dist/docs/index.d.ts +11 -0
- package/dist/docs/index.d.ts.map +1 -0
- package/dist/docs/index.js +11 -0
- package/dist/docs/index.js.map +1 -0
- package/dist/durableWrites.d.ts +63 -0
- package/dist/durableWrites.d.ts.map +1 -0
- package/dist/durableWrites.js +72 -0
- package/dist/durableWrites.js.map +1 -0
- package/dist/environment.d.ts +106 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/environment.js +109 -0
- package/dist/environment.js.map +1 -0
- package/dist/errorCodes.d.ts +411 -0
- package/dist/errorCodes.d.ts.map +1 -0
- package/dist/errorCodes.js +500 -0
- package/dist/errorCodes.js.map +1 -0
- package/dist/errors.d.ts +429 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +687 -0
- package/dist/errors.js.map +1 -0
- package/dist/footprint.d.ts +112 -0
- package/dist/footprint.d.ts.map +1 -0
- package/dist/footprint.js +0 -0
- package/dist/footprint.js.map +1 -0
- package/dist/headlessClient.d.ts +10 -0
- package/dist/headlessClient.d.ts.map +1 -0
- package/dist/headlessClient.js +114 -0
- package/dist/headlessClient.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/keys/index.d.ts +88 -0
- package/dist/keys/index.d.ts.map +1 -0
- package/dist/keys/index.js +208 -0
- package/dist/keys/index.js.map +1 -0
- package/dist/log/syncDeltaRow.d.ts +159 -0
- package/dist/log/syncDeltaRow.d.ts.map +1 -0
- package/dist/log/syncDeltaRow.js +96 -0
- package/dist/log/syncDeltaRow.js.map +1 -0
- package/dist/logger.d.ts +17 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +8 -0
- package/dist/logger.js.map +1 -0
- package/dist/observability.d.ts +54 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +20 -0
- package/dist/observability.js.map +1 -0
- package/dist/policy/types.d.ts +218 -0
- package/dist/policy/types.d.ts.map +1 -0
- package/dist/policy/types.js +127 -0
- package/dist/policy/types.js.map +1 -0
- package/dist/resources/functionalUpdate.d.ts +80 -0
- package/dist/resources/functionalUpdate.d.ts.map +1 -0
- package/dist/resources/functionalUpdate.js +88 -0
- package/dist/resources/functionalUpdate.js.map +1 -0
- package/dist/resources/httpResources.d.ts +449 -0
- package/dist/resources/httpResources.d.ts.map +1 -0
- package/dist/resources/httpResources.js +8 -0
- package/dist/resources/httpResources.js.map +1 -0
- package/dist/resources/modelOperations.d.ts +380 -0
- package/dist/resources/modelOperations.d.ts.map +1 -0
- package/dist/resources/modelOperations.js +13 -0
- package/dist/resources/modelOperations.js.map +1 -0
- package/dist/resources/mutationOptions.d.ts +67 -0
- package/dist/resources/mutationOptions.d.ts.map +1 -0
- package/dist/resources/mutationOptions.js +10 -0
- package/dist/resources/mutationOptions.js.map +1 -0
- package/dist/resources/where.d.ts +102 -0
- package/dist/resources/where.d.ts.map +1 -0
- package/dist/resources/where.js +116 -0
- package/dist/resources/where.js.map +1 -0
- package/dist/resources/writeOptionsSchema.d.ts +48 -0
- package/dist/resources/writeOptionsSchema.d.ts.map +1 -0
- package/dist/resources/writeOptionsSchema.js +74 -0
- package/dist/resources/writeOptionsSchema.js.map +1 -0
- package/dist/schema/coordination.d.ts +113 -0
- package/dist/schema/coordination.d.ts.map +1 -0
- package/dist/schema/coordination.js +134 -0
- package/dist/schema/coordination.js.map +1 -0
- package/dist/schema/ddl.d.ts +98 -0
- package/dist/schema/ddl.d.ts.map +1 -0
- package/dist/schema/ddl.js +492 -0
- package/dist/schema/ddl.js.map +1 -0
- package/dist/schema/ddlLock.d.ts +36 -0
- package/dist/schema/ddlLock.d.ts.map +1 -0
- package/dist/schema/ddlLock.js +47 -0
- package/dist/schema/ddlLock.js.map +1 -0
- package/dist/schema/diff.d.ts +226 -0
- package/dist/schema/diff.d.ts.map +1 -0
- package/dist/schema/diff.js +290 -0
- package/dist/schema/diff.js.map +1 -0
- package/dist/schema/field.d.ts +121 -0
- package/dist/schema/field.d.ts.map +1 -0
- package/dist/schema/field.js +266 -0
- package/dist/schema/field.js.map +1 -0
- package/dist/schema/fieldRef.d.ts +58 -0
- package/dist/schema/fieldRef.d.ts.map +1 -0
- package/dist/schema/fieldRef.js +26 -0
- package/dist/schema/fieldRef.js.map +1 -0
- package/dist/schema/generate.d.ts +20 -0
- package/dist/schema/generate.d.ts.map +1 -0
- package/dist/schema/generate.js +87 -0
- package/dist/schema/generate.js.map +1 -0
- package/dist/schema/index.d.ts +43 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +81 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/loadStrategy.d.ts +46 -0
- package/dist/schema/loadStrategy.d.ts.map +1 -0
- package/dist/schema/loadStrategy.js +47 -0
- package/dist/schema/loadStrategy.js.map +1 -0
- package/dist/schema/model.d.ts +380 -0
- package/dist/schema/model.d.ts.map +1 -0
- package/dist/schema/model.js +124 -0
- package/dist/schema/model.js.map +1 -0
- package/dist/schema/openapi.d.ts +59 -0
- package/dist/schema/openapi.d.ts.map +1 -0
- package/dist/schema/openapi.js +508 -0
- package/dist/schema/openapi.js.map +1 -0
- package/dist/schema/queries.d.ts +202 -0
- package/dist/schema/queries.d.ts.map +1 -0
- package/dist/schema/queries.js +144 -0
- package/dist/schema/queries.js.map +1 -0
- package/dist/schema/relation.d.ts +205 -0
- package/dist/schema/relation.d.ts.map +1 -0
- package/dist/schema/relation.js +105 -0
- package/dist/schema/relation.js.map +1 -0
- package/dist/schema/residency.d.ts +30 -0
- package/dist/schema/residency.d.ts.map +1 -0
- package/dist/schema/residency.js +26 -0
- package/dist/schema/residency.js.map +1 -0
- package/dist/schema/roles.d.ts +250 -0
- package/dist/schema/roles.d.ts.map +1 -0
- package/dist/schema/roles.js +231 -0
- package/dist/schema/roles.js.map +1 -0
- package/dist/schema/schema.d.ts +352 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/schema/schema.js +326 -0
- package/dist/schema/schema.js.map +1 -0
- package/dist/schema/select.d.ts +41 -0
- package/dist/schema/select.d.ts.map +1 -0
- package/dist/schema/select.js +91 -0
- package/dist/schema/select.js.map +1 -0
- package/dist/schema/serialize.d.ts +116 -0
- package/dist/schema/serialize.d.ts.map +1 -0
- package/dist/schema/serialize.js +278 -0
- package/dist/schema/serialize.js.map +1 -0
- package/dist/schema/sugar.d.ts +110 -0
- package/dist/schema/sugar.d.ts.map +1 -0
- package/dist/schema/sugar.js +84 -0
- package/dist/schema/sugar.js.map +1 -0
- package/dist/schema/tenancy.d.ts +140 -0
- package/dist/schema/tenancy.d.ts.map +1 -0
- package/dist/schema/tenancy.js +191 -0
- package/dist/schema/tenancy.js.map +1 -0
- package/dist/server/adapter.d.ts +174 -0
- package/dist/server/adapter.d.ts.map +1 -0
- package/dist/server/adapter.js +19 -0
- package/dist/server/adapter.js.map +1 -0
- package/dist/server/commit.d.ts +108 -0
- package/dist/server/commit.d.ts.map +1 -0
- package/dist/server/commit.js +2 -0
- package/dist/server/commit.js.map +1 -0
- package/dist/server/index.d.ts +15 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/index.js +3 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/readConfig.d.ts +81 -0
- package/dist/server/readConfig.d.ts.map +1 -0
- package/dist/server/readConfig.js +9 -0
- package/dist/server/readConfig.js.map +1 -0
- package/dist/server/storageMode.d.ts +24 -0
- package/dist/server/storageMode.d.ts.map +1 -0
- package/dist/server/storageMode.js +18 -0
- package/dist/server/storageMode.js.map +1 -0
- package/dist/source/adapter.d.ts +84 -0
- package/dist/source/adapter.d.ts.map +1 -0
- package/dist/source/adapter.js +25 -0
- package/dist/source/adapter.js.map +1 -0
- package/dist/source/adapters/drizzle.d.ts +49 -0
- package/dist/source/adapters/drizzle.d.ts.map +1 -0
- package/dist/source/adapters/drizzle.js +220 -0
- package/dist/source/adapters/drizzle.js.map +1 -0
- package/dist/source/adapters/kysely.d.ts +43 -0
- package/dist/source/adapters/kysely.d.ts.map +1 -0
- package/dist/source/adapters/kysely.js +206 -0
- package/dist/source/adapters/kysely.js.map +1 -0
- package/dist/source/adapters/kyselyMutationCore.d.ts +77 -0
- package/dist/source/adapters/kyselyMutationCore.d.ts.map +1 -0
- package/dist/source/adapters/kyselyMutationCore.js +126 -0
- package/dist/source/adapters/kyselyMutationCore.js.map +1 -0
- package/dist/source/adapters/memory.d.ts +14 -0
- package/dist/source/adapters/memory.d.ts.map +1 -0
- package/dist/source/adapters/memory.js +131 -0
- package/dist/source/adapters/memory.js.map +1 -0
- package/dist/source/adapters/prisma.d.ts +64 -0
- package/dist/source/adapters/prisma.d.ts.map +1 -0
- package/dist/source/adapters/prisma.js +203 -0
- package/dist/source/adapters/prisma.js.map +1 -0
- package/dist/source/conformance.d.ts +38 -0
- package/dist/source/conformance.d.ts.map +1 -0
- package/dist/source/conformance.js +216 -0
- package/dist/source/conformance.js.map +1 -0
- package/dist/source/connector.d.ts +96 -0
- package/dist/source/connector.d.ts.map +1 -0
- package/dist/source/connector.js +267 -0
- package/dist/source/connector.js.map +1 -0
- package/dist/source/connectorProtocol.d.ts +155 -0
- package/dist/source/connectorProtocol.d.ts.map +1 -0
- package/dist/source/connectorProtocol.js +164 -0
- package/dist/source/connectorProtocol.js.map +1 -0
- package/dist/source/contract.d.ts +196 -0
- package/dist/source/contract.d.ts.map +1 -0
- package/dist/source/contract.js +165 -0
- package/dist/source/contract.js.map +1 -0
- package/dist/source/drizzle.d.ts +2 -0
- package/dist/source/drizzle.d.ts.map +1 -0
- package/dist/source/drizzle.js +2 -0
- package/dist/source/drizzle.js.map +1 -0
- package/dist/source/factory.d.ts +93 -0
- package/dist/source/factory.d.ts.map +1 -0
- package/dist/source/factory.js +287 -0
- package/dist/source/factory.js.map +1 -0
- package/dist/source/idempotency.d.ts +62 -0
- package/dist/source/idempotency.d.ts.map +1 -0
- package/dist/source/idempotency.js +145 -0
- package/dist/source/idempotency.js.map +1 -0
- package/dist/source/index.d.ts +24 -0
- package/dist/source/index.d.ts.map +1 -0
- package/dist/source/index.js +29 -0
- package/dist/source/index.js.map +1 -0
- package/dist/source/kysely.d.ts +3 -0
- package/dist/source/kysely.d.ts.map +1 -0
- package/dist/source/kysely.js +3 -0
- package/dist/source/kysely.js.map +1 -0
- package/dist/source/migrations.d.ts +22 -0
- package/dist/source/migrations.d.ts.map +1 -0
- package/dist/source/migrations.js +104 -0
- package/dist/source/migrations.js.map +1 -0
- package/dist/source/next.d.ts +33 -0
- package/dist/source/next.d.ts.map +1 -0
- package/dist/source/next.js +26 -0
- package/dist/source/next.js.map +1 -0
- package/dist/source/pushQueue.d.ts +135 -0
- package/dist/source/pushQueue.d.ts.map +1 -0
- package/dist/source/pushQueue.js +257 -0
- package/dist/source/pushQueue.js.map +1 -0
- package/dist/source/signing.d.ts +93 -0
- package/dist/source/signing.d.ts.map +1 -0
- package/dist/source/signing.js +163 -0
- package/dist/source/signing.js.map +1 -0
- package/dist/source/types.d.ts +402 -0
- package/dist/source/types.d.ts.map +1 -0
- package/dist/source/types.js +60 -0
- package/dist/source/types.js.map +1 -0
- package/dist/syncLog/contract.d.ts +21 -0
- package/dist/syncLog/contract.d.ts.map +1 -0
- package/dist/syncLog/contract.js +20 -0
- package/dist/syncLog/contract.js.map +1 -0
- package/dist/syncLog/index.d.ts +2 -0
- package/dist/syncLog/index.d.ts.map +1 -0
- package/dist/syncLog/index.js +2 -0
- package/dist/syncLog/index.js.map +1 -0
- package/dist/testing/fixtures/httpResponses.d.ts +74 -0
- package/dist/testing/fixtures/httpResponses.d.ts.map +1 -0
- package/dist/testing/fixtures/httpResponses.js +102 -0
- package/dist/testing/fixtures/httpResponses.js.map +1 -0
- package/dist/transactionLayer.d.ts +110 -0
- package/dist/transactionLayer.d.ts.map +1 -0
- package/dist/transactionLayer.js +25 -0
- package/dist/transactionLayer.js.map +1 -0
- package/dist/transactions/settlement/commitEnvelope.d.ts +144 -0
- package/dist/transactions/settlement/commitEnvelope.d.ts.map +1 -0
- package/dist/transactions/settlement/commitEnvelope.js +162 -0
- package/dist/transactions/settlement/commitEnvelope.js.map +1 -0
- package/dist/transactions/settlement/httpCommitEnvelope.d.ts +54 -0
- package/dist/transactions/settlement/httpCommitEnvelope.d.ts.map +1 -0
- package/dist/transactions/settlement/httpCommitEnvelope.js +208 -0
- package/dist/transactions/settlement/httpCommitEnvelope.js.map +1 -0
- package/dist/transactions/settlement/idempotencyKey.d.ts +11 -0
- package/dist/transactions/settlement/idempotencyKey.d.ts.map +1 -0
- package/dist/transactions/settlement/idempotencyKey.js +10 -0
- package/dist/transactions/settlement/idempotencyKey.js.map +1 -0
- package/dist/transactions/settlement/pendingWrite.d.ts +113 -0
- package/dist/transactions/settlement/pendingWrite.d.ts.map +1 -0
- package/dist/transactions/settlement/pendingWrite.js +21 -0
- package/dist/transactions/settlement/pendingWrite.js.map +1 -0
- package/dist/transport/commitFrames.d.ts +91 -0
- package/dist/transport/commitFrames.d.ts.map +1 -0
- package/dist/transport/commitFrames.js +135 -0
- package/dist/transport/commitFrames.js.map +1 -0
- package/dist/transport/connectionManager.d.ts +216 -0
- package/dist/transport/connectionManager.d.ts.map +1 -0
- package/dist/transport/connectionManager.js +674 -0
- package/dist/transport/connectionManager.js.map +1 -0
- package/dist/transport/credentialLifecycle.d.ts +178 -0
- package/dist/transport/credentialLifecycle.d.ts.map +1 -0
- package/dist/transport/credentialLifecycle.js +324 -0
- package/dist/transport/credentialLifecycle.js.map +1 -0
- package/dist/transport/heartbeat.d.ts +66 -0
- package/dist/transport/heartbeat.d.ts.map +1 -0
- package/dist/transport/heartbeat.js +94 -0
- package/dist/transport/heartbeat.js.map +1 -0
- package/dist/transport/httpClient.d.ts +143 -0
- package/dist/transport/httpClient.d.ts.map +1 -0
- package/dist/transport/httpClient.js +150 -0
- package/dist/transport/httpClient.js.map +1 -0
- package/dist/transport/httpFeed.d.ts +4 -0
- package/dist/transport/httpFeed.d.ts.map +1 -0
- package/dist/transport/httpFeed.js +94 -0
- package/dist/transport/httpFeed.js.map +1 -0
- package/dist/transport/httpOptions.d.ts +34 -0
- package/dist/transport/httpOptions.d.ts.map +1 -0
- package/dist/transport/httpOptions.js +13 -0
- package/dist/transport/httpOptions.js.map +1 -0
- package/dist/transport/httpTransport.d.ts +68 -0
- package/dist/transport/httpTransport.d.ts.map +1 -0
- package/dist/transport/httpTransport.js +1433 -0
- package/dist/transport/httpTransport.js.map +1 -0
- package/dist/transport/networkProbe.d.ts +85 -0
- package/dist/transport/networkProbe.d.ts.map +1 -0
- package/dist/transport/networkProbe.js +208 -0
- package/dist/transport/networkProbe.js.map +1 -0
- package/dist/transport/wsFrameHandlers.d.ts +129 -0
- package/dist/transport/wsFrameHandlers.d.ts.map +1 -0
- package/dist/transport/wsFrameHandlers.js +429 -0
- package/dist/transport/wsFrameHandlers.js.map +1 -0
- package/dist/transport/wsTransport.d.ts +575 -0
- package/dist/transport/wsTransport.d.ts.map +1 -0
- package/dist/transport/wsTransport.js +1024 -0
- package/dist/transport/wsTransport.js.map +1 -0
- package/dist/types/assertExact.d.ts +18 -0
- package/dist/types/assertExact.d.ts.map +1 -0
- package/dist/types/assertExact.js +2 -0
- package/dist/types/assertExact.js.map +1 -0
- package/dist/types/global.d.ts +108 -0
- package/dist/types/global.d.ts.map +1 -0
- package/dist/types/global.js +41 -0
- package/dist/types/global.js.map +1 -0
- package/dist/types/index.d.ts +206 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +57 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/modelData.d.ts +11 -0
- package/dist/types/modelData.d.ts.map +1 -0
- package/dist/types/modelData.js +10 -0
- package/dist/types/modelData.js.map +1 -0
- package/dist/types/participant.d.ts +21 -0
- package/dist/types/participant.d.ts.map +1 -0
- package/dist/types/participant.js +11 -0
- package/dist/types/participant.js.map +1 -0
- package/dist/types/streams.d.ts +545 -0
- package/dist/types/streams.d.ts.map +1 -0
- package/dist/types/streams.js +12 -0
- package/dist/types/streams.js.map +1 -0
- package/dist/utils/asyncIterator.d.ts +35 -0
- package/dist/utils/asyncIterator.d.ts.map +1 -0
- package/dist/utils/asyncIterator.js +136 -0
- package/dist/utils/asyncIterator.js.map +1 -0
- package/dist/utils/duration.d.ts +51 -0
- package/dist/utils/duration.d.ts.map +1 -0
- package/dist/utils/duration.js +78 -0
- package/dist/utils/duration.js.map +1 -0
- package/dist/utils/json.d.ts +58 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +277 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/webhooks/events.d.ts +44 -0
- package/dist/webhooks/events.d.ts.map +1 -0
- package/dist/webhooks/events.js +43 -0
- package/dist/webhooks/events.js.map +1 -0
- package/dist/webhooks/index.d.ts +9 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/index.js +9 -0
- package/dist/webhooks/index.js.map +1 -0
- package/dist/wire/accountResponses.d.ts +463 -0
- package/dist/wire/accountResponses.d.ts.map +1 -0
- package/dist/wire/accountResponses.js +294 -0
- package/dist/wire/accountResponses.js.map +1 -0
- package/dist/wire/auth.d.ts +57 -0
- package/dist/wire/auth.d.ts.map +1 -0
- package/dist/wire/auth.js +71 -0
- package/dist/wire/auth.js.map +1 -0
- package/dist/wire/bootstrapReason.d.ts +10 -0
- package/dist/wire/bootstrapReason.d.ts.map +1 -0
- package/dist/wire/bootstrapReason.js +9 -0
- package/dist/wire/bootstrapReason.js.map +1 -0
- package/dist/wire/claimEvent.d.ts +70 -0
- package/dist/wire/claimEvent.d.ts.map +1 -0
- package/dist/wire/claimEvent.js +74 -0
- package/dist/wire/claimEvent.js.map +1 -0
- package/dist/wire/claims.d.ts +475 -0
- package/dist/wire/claims.d.ts.map +1 -0
- package/dist/wire/claims.js +326 -0
- package/dist/wire/claims.js.map +1 -0
- package/dist/wire/commit.d.ts +604 -0
- package/dist/wire/commit.d.ts.map +1 -0
- package/dist/wire/commit.js +322 -0
- package/dist/wire/commit.js.map +1 -0
- package/dist/wire/delta.d.ts +251 -0
- package/dist/wire/delta.d.ts.map +1 -0
- package/dist/wire/delta.js +148 -0
- package/dist/wire/delta.js.map +1 -0
- package/dist/wire/errorEnvelope.d.ts +73 -0
- package/dist/wire/errorEnvelope.d.ts.map +1 -0
- package/dist/wire/errorEnvelope.js +124 -0
- package/dist/wire/errorEnvelope.js.map +1 -0
- package/dist/wire/feedCursor.d.ts +61 -0
- package/dist/wire/feedCursor.d.ts.map +1 -0
- package/dist/wire/feedCursor.js +83 -0
- package/dist/wire/feedCursor.js.map +1 -0
- package/dist/wire/feedEvent.d.ts +264 -0
- package/dist/wire/feedEvent.d.ts.map +1 -0
- package/dist/wire/feedEvent.js +66 -0
- package/dist/wire/feedEvent.js.map +1 -0
- package/dist/wire/frames.d.ts +195 -0
- package/dist/wire/frames.d.ts.map +1 -0
- package/dist/wire/frames.js +51 -0
- package/dist/wire/frames.js.map +1 -0
- package/dist/wire/inboundFrames.d.ts +490 -0
- package/dist/wire/inboundFrames.d.ts.map +1 -0
- package/dist/wire/inboundFrames.js +117 -0
- package/dist/wire/inboundFrames.js.map +1 -0
- package/dist/wire/index.d.ts +55 -0
- package/dist/wire/index.d.ts.map +1 -0
- package/dist/wire/index.js +84 -0
- package/dist/wire/index.js.map +1 -0
- package/dist/wire/listEnvelope.d.ts +38 -0
- package/dist/wire/listEnvelope.d.ts.map +1 -0
- package/dist/wire/listEnvelope.js +43 -0
- package/dist/wire/listEnvelope.js.map +1 -0
- package/dist/wire/modelMutations.d.ts +32 -0
- package/dist/wire/modelMutations.d.ts.map +1 -0
- package/dist/wire/modelMutations.js +53 -0
- package/dist/wire/modelMutations.js.map +1 -0
- package/dist/wire/modelResponses.d.ts +79 -0
- package/dist/wire/modelResponses.d.ts.map +1 -0
- package/dist/wire/modelResponses.js +44 -0
- package/dist/wire/modelResponses.js.map +1 -0
- package/dist/wire/modelShape.d.ts +79 -0
- package/dist/wire/modelShape.d.ts.map +1 -0
- package/dist/wire/modelShape.js +75 -0
- package/dist/wire/modelShape.js.map +1 -0
- package/dist/wire/protocol.d.ts +39 -0
- package/dist/wire/protocol.d.ts.map +1 -0
- package/dist/wire/protocol.js +39 -0
- package/dist/wire/protocol.js.map +1 -0
- package/dist/wire/protocolVersion.d.ts +74 -0
- package/dist/wire/protocolVersion.d.ts.map +1 -0
- package/dist/wire/protocolVersion.js +84 -0
- package/dist/wire/protocolVersion.js.map +1 -0
- package/package.json +187 -0
- package/src/ablo.ts +139 -0
- package/src/ai-sdk/coordinatedTool.ts +214 -0
- package/src/ai-sdk/index.ts +7 -0
- package/src/auth/apiKey.ts +540 -0
- package/src/auth/bootstrapScope.ts +15 -0
- package/src/auth/browserCredentialSafety.ts +48 -0
- package/src/auth/capability.ts +326 -0
- package/src/auth/capabilityLifecycle.ts +174 -0
- package/src/auth/credentialEndpoint.ts +79 -0
- package/src/auth/credentialEndpointProtocol.ts +51 -0
- package/src/auth/credentialKind.ts +20 -0
- package/src/auth/credentialPolicy.ts +244 -0
- package/src/auth/credentialResult.ts +23 -0
- package/src/auth/credentialSource.ts +99 -0
- package/src/auth/hostedEndpoints.ts +24 -0
- package/src/auth/identity.ts +330 -0
- package/src/auth/index.ts +592 -0
- package/src/auth/schemas.ts +94 -0
- package/src/auth/sessionMint.ts +126 -0
- package/src/auth/token.ts +4 -0
- package/src/batching/index.ts +200 -0
- package/src/coordination/awaitClaimGrant.ts +243 -0
- package/src/coordination/claimHeartbeatLoop.ts +165 -0
- package/src/coordination/claimMeta.ts +56 -0
- package/src/coordination/events.ts +86 -0
- package/src/coordination/index.ts +181 -0
- package/src/coordination/locator.ts +200 -0
- package/src/coordination/schema.ts +1346 -0
- package/src/coordination/targetConflict.ts +85 -0
- package/src/coordination/trace.ts +173 -0
- package/src/docs/catalog.ts +274 -0
- package/src/docs/index.ts +18 -0
- package/src/durableWrites.ts +134 -0
- package/src/environment.ts +132 -0
- package/src/errorCodes.ts +1591 -0
- package/src/errors.ts +918 -0
- package/src/footprint.ts +0 -0
- package/src/headlessClient.ts +161 -0
- package/src/index.ts +52 -0
- package/src/keys/index.ts +254 -0
- package/src/log/syncDeltaRow.ts +119 -0
- package/src/logger.ts +22 -0
- package/src/observability.ts +85 -0
- package/src/policy/types.ts +292 -0
- package/src/resources/functionalUpdate.ts +151 -0
- package/src/resources/httpResources.ts +520 -0
- package/src/resources/modelOperations.ts +444 -0
- package/src/resources/mutationOptions.ts +66 -0
- package/src/resources/where.ts +160 -0
- package/src/resources/writeOptionsSchema.ts +91 -0
- package/src/schema/coordination.ts +161 -0
- package/src/schema/ddl.ts +593 -0
- package/src/schema/ddlLock.ts +53 -0
- package/src/schema/diff.ts +489 -0
- package/src/schema/field.ts +321 -0
- package/src/schema/fieldRef.ts +88 -0
- package/src/schema/generate.ts +95 -0
- package/src/schema/index.ts +278 -0
- package/src/schema/loadStrategy.ts +52 -0
- package/src/schema/model.ts +476 -0
- package/src/schema/openapi.ts +658 -0
- package/src/schema/queries.ts +273 -0
- package/src/schema/relation.ts +291 -0
- package/src/schema/residency.ts +30 -0
- package/src/schema/roles.ts +325 -0
- package/src/schema/schema.ts +825 -0
- package/src/schema/select.ts +115 -0
- package/src/schema/serialize.ts +373 -0
- package/src/schema/sugar.ts +194 -0
- package/src/schema/tenancy.ts +221 -0
- package/src/server/adapter.ts +203 -0
- package/src/server/commit.ts +109 -0
- package/src/server/index.ts +26 -0
- package/src/server/readConfig.ts +82 -0
- package/src/server/storageMode.ts +20 -0
- package/src/source/adapter.ts +85 -0
- package/src/source/adapters/drizzle.ts +291 -0
- package/src/source/adapters/kysely.ts +346 -0
- package/src/source/adapters/kyselyMutationCore.ts +220 -0
- package/src/source/adapters/memory.ts +154 -0
- package/src/source/adapters/prisma.ts +282 -0
- package/src/source/conformance.ts +287 -0
- package/src/source/connector.ts +394 -0
- package/src/source/connectorProtocol.ts +189 -0
- package/src/source/contract.ts +221 -0
- package/src/source/drizzle.ts +1 -0
- package/src/source/factory.ts +444 -0
- package/src/source/idempotency.ts +189 -0
- package/src/source/index.ts +182 -0
- package/src/source/kysely.ts +2 -0
- package/src/source/migrations.ts +109 -0
- package/src/source/next.ts +38 -0
- package/src/source/pushQueue.ts +368 -0
- package/src/source/signing.ts +279 -0
- package/src/source/types.ts +502 -0
- package/src/syncLog/contract.ts +32 -0
- package/src/syncLog/index.ts +1 -0
- package/src/testing/fixtures/httpResponses.ts +155 -0
- package/src/transactionLayer.ts +122 -0
- package/src/transactions/settlement/commitEnvelope.ts +192 -0
- package/src/transactions/settlement/httpCommitEnvelope.ts +250 -0
- package/src/transactions/settlement/idempotencyKey.ts +11 -0
- package/src/transactions/settlement/pendingWrite.ts +24 -0
- package/src/transport/commitFrames.ts +225 -0
- package/src/transport/connectionManager.ts +856 -0
- package/src/transport/credentialLifecycle.ts +389 -0
- package/src/transport/heartbeat.ts +118 -0
- package/src/transport/httpClient.ts +354 -0
- package/src/transport/httpFeed.ts +111 -0
- package/src/transport/httpOptions.ts +41 -0
- package/src/transport/httpTransport.ts +1976 -0
- package/src/transport/networkProbe.ts +249 -0
- package/src/transport/wsFrameHandlers.ts +619 -0
- package/src/transport/wsTransport.ts +1491 -0
- package/src/types/assertExact.ts +17 -0
- package/src/types/global.ts +123 -0
- package/src/types/index.ts +270 -0
- package/src/types/modelData.ts +11 -0
- package/src/types/participant.ts +22 -0
- package/src/types/streams.ts +702 -0
- package/src/utils/asyncIterator.ts +141 -0
- package/src/utils/duration.ts +88 -0
- package/src/utils/json.ts +281 -0
- package/src/webhooks/events.ts +96 -0
- package/src/webhooks/index.ts +12 -0
- package/src/wire/accountResponses.ts +328 -0
- package/src/wire/auth.ts +86 -0
- package/src/wire/bootstrapReason.ts +10 -0
- package/src/wire/claimEvent.ts +85 -0
- package/src/wire/claims.ts +370 -0
- package/src/wire/commit.ts +379 -0
- package/src/wire/delta.ts +173 -0
- package/src/wire/errorEnvelope.ts +133 -0
- package/src/wire/feedCursor.ts +91 -0
- package/src/wire/feedEvent.ts +74 -0
- package/src/wire/frames.ts +77 -0
- package/src/wire/inboundFrames.ts +182 -0
- package/src/wire/index.ts +328 -0
- package/src/wire/listEnvelope.ts +51 -0
- package/src/wire/modelMutations.ts +55 -0
- package/src/wire/modelResponses.ts +48 -0
- package/src/wire/modelShape.ts +83 -0
- package/src/wire/protocol.ts +39 -0
- package/src/wire/protocolVersion.ts +97 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AbloAuthenticationError, hasWireCode, translateHttpError, } from '../errors.js';
|
|
3
|
+
import { capabilityScopeSchema } from './capability.js';
|
|
4
|
+
export const sessionRevocationResponseSchema = z.object({
|
|
5
|
+
id: z.string().min(1),
|
|
6
|
+
deleted: z.literal(true),
|
|
7
|
+
activeSessionsClosed: z.number().int().nonnegative(),
|
|
8
|
+
});
|
|
9
|
+
export const capabilityRotationRequestSchema = z.object({
|
|
10
|
+
graceSeconds: z.number().int().positive().optional(),
|
|
11
|
+
ttlSeconds: z.number().int().positive().optional(),
|
|
12
|
+
});
|
|
13
|
+
export const capabilityRotationResponseSchema = z.object({
|
|
14
|
+
capabilityId: z.string().min(1),
|
|
15
|
+
token: z.string().trim().min(1),
|
|
16
|
+
expiresAt: z.iso.datetime().nullable(),
|
|
17
|
+
organizationId: z.string().min(1),
|
|
18
|
+
scope: capabilityScopeSchema,
|
|
19
|
+
rotatedFrom: z.object({
|
|
20
|
+
capabilityId: z.string().min(1),
|
|
21
|
+
expiresAt: z.iso.datetime(),
|
|
22
|
+
}),
|
|
23
|
+
});
|
|
24
|
+
async function requestCapabilityLifecycle(options) {
|
|
25
|
+
if (!options.apiKey) {
|
|
26
|
+
throw new AbloAuthenticationError('Session lifecycle operations require a secret (sk_) API key.', { code: 'apikey_missing' });
|
|
27
|
+
}
|
|
28
|
+
if (!options.baseUrl) {
|
|
29
|
+
throw new AbloAuthenticationError('baseUrl is required for session lifecycle operations.', { code: 'base_url_missing' });
|
|
30
|
+
}
|
|
31
|
+
const controller = new AbortController();
|
|
32
|
+
const timer = setTimeout(() => controller.abort(), options.timeoutMs ?? 10_000);
|
|
33
|
+
let response;
|
|
34
|
+
try {
|
|
35
|
+
response = await (options.fetch ?? fetch)(`${options.baseUrl.replace(/\/+$/, '')}/v1/capabilities/${encodeURIComponent(options.id)}${options.suffix ?? ''}`, {
|
|
36
|
+
method: options.method,
|
|
37
|
+
headers: {
|
|
38
|
+
Authorization: `Bearer ${options.apiKey}`,
|
|
39
|
+
...(options.body ? { 'Content-Type': 'application/json' } : {}),
|
|
40
|
+
},
|
|
41
|
+
...(options.body ? { body: JSON.stringify(options.body) } : {}),
|
|
42
|
+
signal: controller.signal,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new AbloAuthenticationError(`session lifecycle request failed: ${error instanceof Error ? error.message : String(error)}`, { code: 'exchange_network_error', cause: error });
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
}
|
|
51
|
+
if (!response.ok) {
|
|
52
|
+
let body = null;
|
|
53
|
+
try {
|
|
54
|
+
body = await response.json();
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// A non-JSON error still receives a stable client-side code below.
|
|
58
|
+
}
|
|
59
|
+
const requestId = response.headers.get('x-request-id') ?? undefined;
|
|
60
|
+
throw hasWireCode(body)
|
|
61
|
+
? translateHttpError(response.status, body, requestId)
|
|
62
|
+
: new AbloAuthenticationError(`session lifecycle request rejected (${response.status})`, { code: 'exchange_failed', httpStatus: response.status });
|
|
63
|
+
}
|
|
64
|
+
return response.json();
|
|
65
|
+
}
|
|
66
|
+
export async function revokeCapability(options) {
|
|
67
|
+
const raw = await requestCapabilityLifecycle({
|
|
68
|
+
...options,
|
|
69
|
+
method: 'DELETE',
|
|
70
|
+
});
|
|
71
|
+
const parsed = sessionRevocationResponseSchema.safeParse(raw);
|
|
72
|
+
if (!parsed.success) {
|
|
73
|
+
throw new AbloAuthenticationError('Session revoke response was malformed.', { code: 'exchange_malformed_response', cause: parsed.error });
|
|
74
|
+
}
|
|
75
|
+
return parsed.data;
|
|
76
|
+
}
|
|
77
|
+
export async function rotateCapability(options) {
|
|
78
|
+
const body = {
|
|
79
|
+
...(options.graceSeconds !== undefined
|
|
80
|
+
? { graceSeconds: options.graceSeconds }
|
|
81
|
+
: {}),
|
|
82
|
+
...(options.ttlSeconds !== undefined
|
|
83
|
+
? { ttlSeconds: options.ttlSeconds }
|
|
84
|
+
: {}),
|
|
85
|
+
};
|
|
86
|
+
const raw = await requestCapabilityLifecycle({
|
|
87
|
+
...options,
|
|
88
|
+
method: 'POST',
|
|
89
|
+
suffix: '/rotate',
|
|
90
|
+
...(Object.keys(body).length > 0 ? { body } : {}),
|
|
91
|
+
});
|
|
92
|
+
const parsed = capabilityRotationResponseSchema.safeParse(raw);
|
|
93
|
+
if (!parsed.success) {
|
|
94
|
+
throw new AbloAuthenticationError('Session rotation response was malformed.', { code: 'exchange_malformed_response', cause: parsed.error });
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
id: parsed.data.capabilityId,
|
|
98
|
+
token: parsed.data.token,
|
|
99
|
+
expiresAt: parsed.data.expiresAt,
|
|
100
|
+
organizationId: parsed.data.organizationId,
|
|
101
|
+
scope: parsed.data.scope,
|
|
102
|
+
rotatedFrom: {
|
|
103
|
+
id: parsed.data.rotatedFrom.capabilityId,
|
|
104
|
+
expiresAt: parsed.data.rotatedFrom.expiresAt,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=capabilityLifecycle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilityLifecycle.js","sourceRoot":"","sources":["../../src/auth/capabilityLifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO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,CAAC,IAAI,CAAC,KAAK;QACxB,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS;QAChC,cAAc,EAAE,MAAM,CAAC,IAAI,CAAC,cAAc;QAC1C,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK;QACxB,WAAW,EAAE;YACX,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY;YACxC,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS;SAC7C;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CredentialProvider } from './credentialResult.js';
|
|
2
|
+
export interface CredentialEndpointOptions {
|
|
3
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
4
|
+
readonly timeoutMs?: number;
|
|
5
|
+
readonly allowCrossOrigin?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function isCredentialEndpoint(value: string): boolean;
|
|
8
|
+
/** Strict, injectable client for the browser session-mint protocol. */
|
|
9
|
+
export declare function createEndpointCredentialResolver(endpoint: string, options?: CredentialEndpointOptions): CredentialProvider;
|
|
10
|
+
//# sourceMappingURL=credentialEndpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialEndpoint.d.ts","sourceRoot":"","sources":["../../src/auth/credentialEndpoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAQhE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IACzC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE3D;AAsBD,uEAAuE;AACvE,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,yBAA8B,GACtC,kBAAkB,CAoCpB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { credentialEndpointErrorCode, parseCredentialEndpointSuccess, } from './credentialEndpointProtocol.js';
|
|
2
|
+
const DEFAULT_AUTH_TIMEOUT_MS = 10_000;
|
|
3
|
+
export function isCredentialEndpoint(value) {
|
|
4
|
+
return value.startsWith('/') || /^https?:\/\//i.test(value);
|
|
5
|
+
}
|
|
6
|
+
function assertEndpointOrigin(endpoint, allowCrossOrigin) {
|
|
7
|
+
if (allowCrossOrigin || endpoint.startsWith('/'))
|
|
8
|
+
return;
|
|
9
|
+
if (typeof window === 'undefined')
|
|
10
|
+
return;
|
|
11
|
+
const endpointOrigin = new URL(endpoint, window.location.href).origin;
|
|
12
|
+
if (endpointOrigin !== window.location.origin) {
|
|
13
|
+
throw new Error('credential endpoint must be same-origin; set ' +
|
|
14
|
+
'`allowCrossOriginAuthEndpoint: true` only after configuring CORS and CSRF protection');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function readJson(response) {
|
|
18
|
+
try {
|
|
19
|
+
return await response.json();
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Strict, injectable client for the browser session-mint protocol. */
|
|
26
|
+
export function createEndpointCredentialResolver(endpoint, options = {}) {
|
|
27
|
+
assertEndpointOrigin(endpoint, options.allowCrossOrigin ?? false);
|
|
28
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
29
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_AUTH_TIMEOUT_MS;
|
|
30
|
+
return async () => {
|
|
31
|
+
const controller = new AbortController();
|
|
32
|
+
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
33
|
+
try {
|
|
34
|
+
const response = await fetchImpl(endpoint, {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
credentials: 'include',
|
|
37
|
+
cache: 'no-store',
|
|
38
|
+
headers: { accept: 'application/json' },
|
|
39
|
+
signal: controller.signal,
|
|
40
|
+
});
|
|
41
|
+
const body = await readJson(response);
|
|
42
|
+
if (response.status === 401 &&
|
|
43
|
+
credentialEndpointErrorCode(body) === 'session_expired') {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
if (!response.ok) {
|
|
47
|
+
const code = credentialEndpointErrorCode(body);
|
|
48
|
+
throw new Error(`credential endpoint ${endpoint} answered ${response.status}` +
|
|
49
|
+
(code ? ` (${code})` : ''));
|
|
50
|
+
}
|
|
51
|
+
return parseCredentialEndpointSuccess(body);
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
clearTimeout(timeout);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=credentialEndpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialEndpoint.js","sourceRoot":"","sources":["../../src/auth/credentialEndpoint.ts"],"names":[],"mappings":"AACA,OAAO,EACL,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,uBAAuB,GAAG,MAAM,CAAC;AAQvC,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,SAAS,oBAAoB,CAAC,QAAgB,EAAE,gBAAyB;IACvE,IAAI,gBAAgB,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO;IACzD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAC1C,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;IACtE,IAAI,cAAc,KAAK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CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;gBAC/C,MAAM,IAAI,KAAK,CACb,uBAAuB,QAAQ,aAAa,QAAQ,CAAC,MAAM,EAAE;oBAC3D,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAC7B,CAAC;YACJ,CAAC;YACD,OAAO,8BAA8B,CAAC,IAAI,CAAC,CAAC;QAC9C,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,OAAO,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const credentialEndpointKindSchema: z.ZodEnum<{
|
|
3
|
+
ephemeral: "ephemeral";
|
|
4
|
+
restricted: "restricted";
|
|
5
|
+
}>;
|
|
6
|
+
export declare const credentialEndpointSuccessSchema: z.ZodObject<{
|
|
7
|
+
token: z.ZodString;
|
|
8
|
+
expiresAt: z.ZodISODateTime;
|
|
9
|
+
credentialKind: z.ZodEnum<{
|
|
10
|
+
ephemeral: "ephemeral";
|
|
11
|
+
restricted: "restricted";
|
|
12
|
+
}>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const credentialEndpointErrorSchema: z.ZodObject<{
|
|
15
|
+
error: z.ZodObject<{
|
|
16
|
+
code: z.ZodString;
|
|
17
|
+
message: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export type CredentialEndpointSuccess = z.infer<typeof credentialEndpointSuccessSchema>;
|
|
21
|
+
export type CredentialEndpointError = z.infer<typeof credentialEndpointErrorSchema>;
|
|
22
|
+
export declare function parseCredentialEndpointSuccess(raw: unknown): CredentialEndpointSuccess;
|
|
23
|
+
export declare function credentialEndpointErrorCode(raw: unknown): string | null;
|
|
24
|
+
//# sourceMappingURL=credentialEndpointProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialEndpointProtocol.d.ts","sourceRoot":"","sources":["../../src/auth/credentialEndpointProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,4BAA4B;;;EAGvC,CAAC;AAEH,eAAO,MAAM,+BAA+B;;;;;;;kBAI1C,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;kBAKxC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,+BAA+B,CACvC,CAAC;AACF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,OAAO,GACX,yBAAyB,CAe3B;AAED,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGvE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { classifyCredentialKind } from './credentialKind.js';
|
|
3
|
+
export const credentialEndpointKindSchema = z.enum([
|
|
4
|
+
'ephemeral',
|
|
5
|
+
'restricted',
|
|
6
|
+
]);
|
|
7
|
+
export const credentialEndpointSuccessSchema = z.strictObject({
|
|
8
|
+
token: z.string().trim().min(1),
|
|
9
|
+
expiresAt: z.iso.datetime({ offset: true }),
|
|
10
|
+
credentialKind: credentialEndpointKindSchema,
|
|
11
|
+
});
|
|
12
|
+
export const credentialEndpointErrorSchema = z.strictObject({
|
|
13
|
+
error: z.strictObject({
|
|
14
|
+
code: z.string().min(1),
|
|
15
|
+
message: z.string().optional(),
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
export function parseCredentialEndpointSuccess(raw) {
|
|
19
|
+
const parsed = credentialEndpointSuccessSchema.safeParse(raw);
|
|
20
|
+
if (!parsed.success) {
|
|
21
|
+
throw new Error(`credential endpoint returned a malformed success body: ${z.prettifyError(parsed.error)}`);
|
|
22
|
+
}
|
|
23
|
+
const actualKind = classifyCredentialKind(parsed.data.token);
|
|
24
|
+
if (actualKind !== parsed.data.credentialKind) {
|
|
25
|
+
throw new Error(`credential endpoint declared ${parsed.data.credentialKind} but returned ` +
|
|
26
|
+
`${actualKind ?? 'an unknown credential kind'}`);
|
|
27
|
+
}
|
|
28
|
+
return parsed.data;
|
|
29
|
+
}
|
|
30
|
+
export function credentialEndpointErrorCode(raw) {
|
|
31
|
+
const parsed = credentialEndpointErrorSchema.safeParse(raw);
|
|
32
|
+
return parsed.success ? parsed.data.error.code : null;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=credentialEndpointProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialEndpointProtocol.js","sourceRoot":"","sources":["../../src/auth/credentialEndpointProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC,IAAI,CAAC;IACjD,WAAW;IACX,YAAY;CACb,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC,YAAY,CAAC;IAC5D,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/B,SAAS,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;IAC3C,cAAc,EAAE,4BAA4B;CAC7C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC,YAAY,CAAC;IAC1D,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACvB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC/B,CAAC;CACH,CAAC,CAAC;AASH,MAAM,UAAU,8BAA8B,CAC5C,GAAY;IAEZ,MAAM,MAAM,GAAG,+BAA+B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC9D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,0DAA0D,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAC1F,CAAC;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7D,IAAI,UAAU,KAAK,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,gCAAgC,MAAM,CAAC,IAAI,CAAC,cAAc,gBAAgB;YACxE,GAAG,UAAU,IAAI,4BAA4B,EAAE,CAClD,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,2BAA2B,CAAC,GAAY;IACtD,MAAM,MAAM,GAAG,6BAA6B,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type CredentialKind = 'secret' | 'ephemeral' | 'restricted' | 'publishable';
|
|
2
|
+
/** Browser-safe prefix classification; server checksum validation stays server-side. */
|
|
3
|
+
export declare function classifyCredentialKind(value: string): CredentialKind | null;
|
|
4
|
+
//# sourceMappingURL=credentialKind.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialKind.d.ts","sourceRoot":"","sources":["../../src/auth/credentialKind.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GACtB,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,CAAC;AASlB,wFAAwF;AACxF,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAK3E"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const KIND_BY_PREFIX = [
|
|
2
|
+
['sk_', 'secret'],
|
|
3
|
+
['ek_', 'ephemeral'],
|
|
4
|
+
['rk_', 'restricted'],
|
|
5
|
+
['pk_', 'publishable'],
|
|
6
|
+
];
|
|
7
|
+
/** Browser-safe prefix classification; server checksum validation stays server-side. */
|
|
8
|
+
export function classifyCredentialKind(value) {
|
|
9
|
+
for (const [prefix, kind] of KIND_BY_PREFIX) {
|
|
10
|
+
if (value.startsWith(prefix))
|
|
11
|
+
return kind;
|
|
12
|
+
}
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=credentialKind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialKind.js","sourceRoot":"","sources":["../../src/auth/credentialKind.ts"],"names":[],"mappings":"AAMA,MAAM,cAAc,GAAmD;IACrE,CAAC,KAAK,EAAE,QAAQ,CAAC;IACjB,CAAC,KAAK,EAAE,WAAW,CAAC;IACpB,CAAC,KAAK,EAAE,YAAY,CAAC;IACrB,CAAC,KAAK,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF,wFAAwF;AACxF,MAAM,UAAU,sBAAsB,CAAC,KAAa;IAClD,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,cAAc,EAAE,CAAC;QAC5C,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;IAC5C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides what a credential is and how to use it when a client connects. A
|
|
3
|
+
* caller configures an Ablo client with an API key, and this module answers two
|
|
4
|
+
* questions about that value: which of the four key kinds it is, and which
|
|
5
|
+
* connect-time route it takes.
|
|
6
|
+
*
|
|
7
|
+
* The routing decision is the only thing that lives here. This module does not
|
|
8
|
+
* perform the network calls that mint or exchange credentials;
|
|
9
|
+
* {@link resolveCredential} delegates those to primitives the caller supplies,
|
|
10
|
+
* so the decision of what to do stays separate from the work of doing it.
|
|
11
|
+
*
|
|
12
|
+
* {@link classifyCredentialKind} is a plain string check with no Node
|
|
13
|
+
* dependencies, so it is safe to run in a browser bundle. It recognizes the key
|
|
14
|
+
* prefixes `sk_` (secret), `rk_` (restricted), `ek_` (ephemeral), and `pk_`
|
|
15
|
+
* (publishable), but does not validate a key's checksum or environment segment.
|
|
16
|
+
*/
|
|
17
|
+
import type { exchangeApiKey, mintUserSessionKey, resolveIdentity } from './index.js';
|
|
18
|
+
import { classifyCredentialKind, type CredentialKind } from './credentialKind.js';
|
|
19
|
+
import type { CredentialProvider } from './credentialResult.js';
|
|
20
|
+
/**
|
|
21
|
+
* The shape of the function that resolves a configured `apiKey` — which may be a
|
|
22
|
+
* string or an async setter — down to a concrete string, or `null` when no key
|
|
23
|
+
* is available. It is declared here structurally, rather than imported, to avoid
|
|
24
|
+
* a circular dependency between this module and the code that supplies the
|
|
25
|
+
* function. Any function with a matching shape satisfies it.
|
|
26
|
+
*/
|
|
27
|
+
type ResolveApiKeyValueFn = (apiKey: string | CredentialProvider | null) => Promise<string | null>;
|
|
28
|
+
/**
|
|
29
|
+
* The four kinds of Ablo API key, one per prefix: `sk_` is secret, `ek_` is
|
|
30
|
+
* ephemeral, `rk_` is restricted, and `pk_` is publishable. The list is declared
|
|
31
|
+
* here, rather than imported, so this browser-safe module stays free of Node-only
|
|
32
|
+
* dependencies.
|
|
33
|
+
*/
|
|
34
|
+
export { classifyCredentialKind, type CredentialKind };
|
|
35
|
+
/**
|
|
36
|
+
* The set of authentication primitives that {@link resolveCredential} delegates
|
|
37
|
+
* to. Injecting them keeps the network calls that mint and exchange credentials
|
|
38
|
+
* in one place and leaves this module responsible only for the routing decision.
|
|
39
|
+
* {@link resolveCredential} never calls `mintUserSessionKey` itself — an
|
|
40
|
+
* ephemeral `ek_` key is minted before the client connects and arrives ready to
|
|
41
|
+
* use — but it is listed here to describe the full primitive surface.
|
|
42
|
+
*/
|
|
43
|
+
export interface CredentialPrimitives {
|
|
44
|
+
readonly exchangeApiKey: typeof exchangeApiKey;
|
|
45
|
+
readonly mintUserSessionKey: typeof mintUserSessionKey;
|
|
46
|
+
readonly resolveIdentity: typeof resolveIdentity;
|
|
47
|
+
readonly resolveApiKeyValue: ResolveApiKeyValueFn;
|
|
48
|
+
}
|
|
49
|
+
export interface ResolveCredentialContext {
|
|
50
|
+
readonly primitives: CredentialPrimitives;
|
|
51
|
+
/**
|
|
52
|
+
* The arguments for the credential exchange, minus the `apiKey`. The caller
|
|
53
|
+
* derives the base URL and participant scope and supplies them here;
|
|
54
|
+
* {@link resolveCredential} fills in the resolved `apiKey` and calls
|
|
55
|
+
* `exchangeApiKey`.
|
|
56
|
+
*/
|
|
57
|
+
readonly exchangeArgs: Omit<Parameters<typeof exchangeApiKey>[0], 'apiKey'>;
|
|
58
|
+
}
|
|
59
|
+
export interface ResolveCredentialInput {
|
|
60
|
+
/** Resolved string value of the configured `apiKey` (callable already invoked), or null. */
|
|
61
|
+
readonly apiKeyValue: string | null;
|
|
62
|
+
/** The configured `apiKey` (string or setter) — threaded onto the refresh path. */
|
|
63
|
+
readonly configuredApiKey: string | CredentialProvider | null;
|
|
64
|
+
/** Explicit caller-supplied capability token (`options.capabilityToken`). */
|
|
65
|
+
readonly capabilityToken: string | undefined;
|
|
66
|
+
/** Configured static `authToken`. */
|
|
67
|
+
readonly authToken: string | null;
|
|
68
|
+
/** True when the caller already knows its own identity, so no server round-trip is needed to resolve it. */
|
|
69
|
+
readonly hasExplicitIdentity: boolean;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The outcome of the connect-time decision, as a discriminated union over the
|
|
73
|
+
* route rather than the key kind: an `ek_` and an `rk_` key both take the
|
|
74
|
+
* `pre-minted` route, as does a bare capability token. The caller switches on
|
|
75
|
+
* `kind` and wires up the scope and side effects each route needs.
|
|
76
|
+
*
|
|
77
|
+
* Every variant carries the same three fields:
|
|
78
|
+
* - `getBearer` — the token used to authenticate the bootstrap and `/auth/*`
|
|
79
|
+
* requests, and to seed the credential source.
|
|
80
|
+
* - `expiresAtMs` — when the credential expires, which drives the refresh
|
|
81
|
+
* scheduler, or `null` when there is nothing to refresh.
|
|
82
|
+
* - `controlPlaneKey` — the original configured API key when the route minted
|
|
83
|
+
* its bearer through an exchange, so a refresh can mint again; otherwise
|
|
84
|
+
* `null`.
|
|
85
|
+
*/
|
|
86
|
+
export type ResolvedCredential =
|
|
87
|
+
/** `pk_` — long-lived browser-safe read-only project key. Used directly as the
|
|
88
|
+
* bearer; never exchanged, never refreshed. Identity resolved via `/auth/identity`. */
|
|
89
|
+
{
|
|
90
|
+
readonly kind: 'publishable';
|
|
91
|
+
readonly getBearer: string;
|
|
92
|
+
readonly expiresAtMs: null;
|
|
93
|
+
readonly controlPlaneKey: null;
|
|
94
|
+
}
|
|
95
|
+
/** `sk_` (no explicit cap token) — hosted-cloud. Exchanged for a capability
|
|
96
|
+
* token via `exchangeApiKey`; the refresh scheduler re-mints before expiry. */
|
|
97
|
+
| {
|
|
98
|
+
readonly kind: 'exchange';
|
|
99
|
+
/** Result of the initial `exchangeApiKey` call. */
|
|
100
|
+
readonly exchange: Awaited<ReturnType<typeof exchangeApiKey>>;
|
|
101
|
+
readonly getBearer: string;
|
|
102
|
+
readonly expiresAtMs: number;
|
|
103
|
+
/** The configured apiKey (string or setter) — read fresh on each refresh. */
|
|
104
|
+
readonly controlPlaneKey: string | CredentialProvider;
|
|
105
|
+
}
|
|
106
|
+
/** A pre-minted `ek_` or `rk_` key, or an explicit capability or auth token,
|
|
107
|
+
* used as the bearer without any exchange. Identity resolved via `/auth/identity`. */
|
|
108
|
+
| {
|
|
109
|
+
readonly kind: 'pre-minted';
|
|
110
|
+
readonly getBearer: string;
|
|
111
|
+
readonly expiresAtMs: null;
|
|
112
|
+
readonly controlPlaneKey: null;
|
|
113
|
+
}
|
|
114
|
+
/** The caller already knows its own organization and user or agent id, so there
|
|
115
|
+
* is no server round-trip; the optional bearer is the initial capability token. */
|
|
116
|
+
| {
|
|
117
|
+
readonly kind: 'explicit';
|
|
118
|
+
readonly getBearer: string | undefined;
|
|
119
|
+
readonly expiresAtMs: null;
|
|
120
|
+
readonly controlPlaneKey: null;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Routes a configured API key to its connect-time outcome. It classifies the
|
|
124
|
+
* key, then returns one of four {@link ResolvedCredential} variants, delegating
|
|
125
|
+
* any credential exchange to the injected `exchangeApiKey` primitive. The caller
|
|
126
|
+
* switches on the result's `kind` to wire up scope and the refresh scheduler.
|
|
127
|
+
*
|
|
128
|
+
* The routes, in the order they are tried:
|
|
129
|
+
* 0. A `pk_` key with no explicit capability token becomes `publishable`: used
|
|
130
|
+
* directly as the bearer, with no refresh.
|
|
131
|
+
* 1. Any other exchangeable key (one that is not a pre-minted `ek_` or `rk_`)
|
|
132
|
+
* with no explicit capability token becomes `exchange`: a round-trip mints a
|
|
133
|
+
* capability token, and the refresh scheduler renews it before it expires.
|
|
134
|
+
* 2. Otherwise, when the caller's identity is not yet known, the result is
|
|
135
|
+
* `pre-minted`: the capability token is used as-is. Throws `session_expired`
|
|
136
|
+
* when there is no token to authenticate `/auth/identity`.
|
|
137
|
+
* 3. Otherwise, when the caller already knows its identity, the result is
|
|
138
|
+
* `explicit`, with no round-trip.
|
|
139
|
+
*/
|
|
140
|
+
export declare function resolveCredential(input: ResolveCredentialInput, ctx: ResolveCredentialContext): Promise<ResolvedCredential>;
|
|
141
|
+
//# sourceMappingURL=credentialPolicy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialPolicy.d.ts","sourceRoot":"","sources":["../../src/auth/credentialPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACtF,OAAO,EACL,sBAAsB,EACtB,KAAK,cAAc,EACpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;GAMG;AACH,KAAK,oBAAoB,GAAG,CAC1B,MAAM,EAAE,MAAM,GAAG,kBAAkB,GAAG,IAAI,KACvC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE5B;;;;;GAKG;AACH,OAAO,EAAE,sBAAsB,EAAE,KAAK,cAAc,EAAE,CAAC;AAIvD;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,cAAc,EAAE,OAAO,cAAc,CAAC;IAC/C,QAAQ,CAAC,kBAAkB,EAAE,OAAO,kBAAkB,CAAC;IACvD,QAAQ,CAAC,eAAe,EAAE,OAAO,eAAe,CAAC;IACjD,QAAQ,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;CACnD;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,UAAU,EAAE,oBAAoB,CAAC;IAC1C;;;;;OAKG;IACH,QAAQ,CAAC,YAAY,EAAE,IAAI,CACzB,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,EACpC,QAAQ,CACT,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,4FAA4F;IAC5F,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,C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AAE,IAAI,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,IAAI,CAAC;CAChC,CAAC;AAEN;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,sBAAsB,EAC7B,GAAG,EAAE,wBAAwB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CAkF7B"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decides what a credential is and how to use it when a client connects. A
|
|
3
|
+
* caller configures an Ablo client with an API key, and this module answers two
|
|
4
|
+
* questions about that value: which of the four key kinds it is, and which
|
|
5
|
+
* connect-time route it takes.
|
|
6
|
+
*
|
|
7
|
+
* The routing decision is the only thing that lives here. This module does not
|
|
8
|
+
* perform the network calls that mint or exchange credentials;
|
|
9
|
+
* {@link resolveCredential} delegates those to primitives the caller supplies,
|
|
10
|
+
* so the decision of what to do stays separate from the work of doing it.
|
|
11
|
+
*
|
|
12
|
+
* {@link classifyCredentialKind} is a plain string check with no Node
|
|
13
|
+
* dependencies, so it is safe to run in a browser bundle. It recognizes the key
|
|
14
|
+
* prefixes `sk_` (secret), `rk_` (restricted), `ek_` (ephemeral), and `pk_`
|
|
15
|
+
* (publishable), but does not validate a key's checksum or environment segment.
|
|
16
|
+
*/
|
|
17
|
+
import { AbloAuthenticationError } from '../errors.js';
|
|
18
|
+
import { classifyCredentialKind, } from './credentialKind.js';
|
|
19
|
+
/**
|
|
20
|
+
* The four kinds of Ablo API key, one per prefix: `sk_` is secret, `ek_` is
|
|
21
|
+
* ephemeral, `rk_` is restricted, and `pk_` is publishable. The list is declared
|
|
22
|
+
* here, rather than imported, so this browser-safe module stays free of Node-only
|
|
23
|
+
* dependencies.
|
|
24
|
+
*/
|
|
25
|
+
export { classifyCredentialKind };
|
|
26
|
+
/**
|
|
27
|
+
* Routes a configured API key to its connect-time outcome. It classifies the
|
|
28
|
+
* key, then returns one of four {@link ResolvedCredential} variants, delegating
|
|
29
|
+
* any credential exchange to the injected `exchangeApiKey` primitive. The caller
|
|
30
|
+
* switches on the result's `kind` to wire up scope and the refresh scheduler.
|
|
31
|
+
*
|
|
32
|
+
* The routes, in the order they are tried:
|
|
33
|
+
* 0. A `pk_` key with no explicit capability token becomes `publishable`: used
|
|
34
|
+
* directly as the bearer, with no refresh.
|
|
35
|
+
* 1. Any other exchangeable key (one that is not a pre-minted `ek_` or `rk_`)
|
|
36
|
+
* with no explicit capability token becomes `exchange`: a round-trip mints a
|
|
37
|
+
* capability token, and the refresh scheduler renews it before it expires.
|
|
38
|
+
* 2. Otherwise, when the caller's identity is not yet known, the result is
|
|
39
|
+
* `pre-minted`: the capability token is used as-is. Throws `session_expired`
|
|
40
|
+
* when there is no token to authenticate `/auth/identity`.
|
|
41
|
+
* 3. Otherwise, when the caller already knows its identity, the result is
|
|
42
|
+
* `explicit`, with no round-trip.
|
|
43
|
+
*/
|
|
44
|
+
export async function resolveCredential(input, ctx) {
|
|
45
|
+
const { apiKeyValue, capabilityToken, authToken, hasExplicitIdentity } = input;
|
|
46
|
+
const kind = apiKeyValue != null ? classifyCredentialKind(apiKeyValue) : null;
|
|
47
|
+
// A pre-minted capability bearer (an ephemeral `ek_` or restricted `rk_` key)
|
|
48
|
+
// is not exchangeable: it was minted before connect and is used directly as the
|
|
49
|
+
// bearer on Route 2, never sent through `exchangeApiKey`, which expects an `sk_`.
|
|
50
|
+
const isPreMintedCapabilityBearer = kind === 'ephemeral' || kind === 'restricted';
|
|
51
|
+
const initialCapToken = capabilityToken ??
|
|
52
|
+
(isPreMintedCapabilityBearer ? apiKeyValue : undefined) ??
|
|
53
|
+
authToken ??
|
|
54
|
+
undefined;
|
|
55
|
+
// Route 0: a publishable `pk_` key — long-lived, browser-safe, and read-only.
|
|
56
|
+
// Used directly as the bearer; it is never exchanged, so it never expires and
|
|
57
|
+
// there is nothing to refresh.
|
|
58
|
+
if (apiKeyValue != null && kind === 'publishable' && capabilityToken == null) {
|
|
59
|
+
return {
|
|
60
|
+
kind: 'publishable',
|
|
61
|
+
getBearer: apiKeyValue,
|
|
62
|
+
expiresAtMs: null,
|
|
63
|
+
controlPlaneKey: null,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Route 1: an exchangeable key (such as a secret `sk_`) with no caller-supplied
|
|
67
|
+
// capability token. A pre-minted `ek_` or `rk_` is not exchangeable and falls
|
|
68
|
+
// through to the next route.
|
|
69
|
+
if (apiKeyValue != null &&
|
|
70
|
+
capabilityToken == null &&
|
|
71
|
+
!isPreMintedCapabilityBearer) {
|
|
72
|
+
const exchange = await ctx.primitives.exchangeApiKey({
|
|
73
|
+
...ctx.exchangeArgs,
|
|
74
|
+
apiKey: apiKeyValue,
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
kind: 'exchange',
|
|
78
|
+
exchange,
|
|
79
|
+
getBearer: exchange.token,
|
|
80
|
+
expiresAtMs: Date.parse(exchange.expiresAt),
|
|
81
|
+
controlPlaneKey: input.configuredApiKey ?? apiKeyValue,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// Route 2: pre-minted — use the capability token as-is. Reached when the
|
|
85
|
+
// caller's identity was not supplied.
|
|
86
|
+
if (!hasExplicitIdentity) {
|
|
87
|
+
if (initialCapToken == null) {
|
|
88
|
+
// With no key to exchange and no caller-supplied identity, this token is the
|
|
89
|
+
// only thing that could authenticate `/auth/identity`. When it is absent —
|
|
90
|
+
// commonly a function `apiKey` resolver returning `null` for a missing or
|
|
91
|
+
// expired session — report the re-authenticable condition here instead of
|
|
92
|
+
// making a round-trip that is bound to fail.
|
|
93
|
+
throw new AbloAuthenticationError('No auth token available to resolve identity — the session token is ' +
|
|
94
|
+
'missing or expired. Ensure your `apiKey` resolver returns a valid token, or ' +
|
|
95
|
+
'pass a static `apiKey` / `capabilityToken`.', { code: 'session_expired' });
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
kind: 'pre-minted',
|
|
99
|
+
getBearer: initialCapToken,
|
|
100
|
+
expiresAtMs: null,
|
|
101
|
+
controlPlaneKey: null,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
// Route 3: explicit — the caller already knows its own organization and user
|
|
105
|
+
// or agent id.
|
|
106
|
+
return {
|
|
107
|
+
kind: 'explicit',
|
|
108
|
+
getBearer: initialCapToken,
|
|
109
|
+
expiresAtMs: null,
|
|
110
|
+
controlPlaneKey: null,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=credentialPolicy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialPolicy.js","sourceRoot":"","sources":["../../src/auth/credentialPolicy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EACL,sBAAsB,GAEvB,MAAM,qBAAqB,CAAC;AAc7B;;;;;GAKG;AACH,OAAO,EAAE,sBAAsB,EAAuB,CAAC;AAkGvD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,KAA6B,EAC7B,GAA6B;IAE7B,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,mBAAmB,EAAE,GAAG,KAAK,CAAC;IAE/E,MAAM,IAAI,GAAG,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9E,8EAA8E;IAC9E,gFAAgF;IAChF,kFAAkF;IAClF,MAAM,2BAA2B,GAC/B,IAAI,KAAK,WAAW,IAAI,IAAI,KAAK,YAAY,CAAC;IAEhD,MAAM,eAAe,GACnB,eAAe;QACf,CAAC,2BAA2B,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;QACvD,SAAS;QACT,SAAS,CAAC;IAEZ,8EAA8E;IAC9E,8EAA8E;IAC9E,+BAA+B;IAC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U;QAChB,SAAS,EAAE,eAAe;QAC1B,WAAW,EAAE,IAAI;QACjB,eAAe,EAAE,IAAI;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CredentialEndpointSuccess } from './credentialEndpointProtocol.js';
|
|
2
|
+
export type CredentialProviderResult = string | CredentialEndpointSuccess | null;
|
|
3
|
+
/** Rotating secret provider or short-lived browser credential provider. */
|
|
4
|
+
export type CredentialProvider = () => Promise<CredentialProviderResult>;
|
|
5
|
+
export declare function credentialToken(result: CredentialProviderResult): string | null;
|
|
6
|
+
export declare function credentialExpiry(result: CredentialProviderResult): string | undefined;
|
|
7
|
+
//# sourceMappingURL=credentialResult.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialResult.d.ts","sourceRoot":"","sources":["../../src/auth/credentialResult.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAEjF,MAAM,MAAM,wBAAwB,GAChC,MAAM,GACN,yBAAyB,GACzB,IAAI,CAAC;AAET,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAEzE,wBAAgB,eAAe,CAC7B,MAAM,EAAE,wBAAwB,GAC/B,MAAM,GAAG,IAAI,CAEf;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,wBAAwB,GAC/B,MAAM,GAAG,SAAS,CAIpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function credentialToken(result) {
|
|
2
|
+
return typeof result === 'string' ? result : result?.token ?? null;
|
|
3
|
+
}
|
|
4
|
+
export function credentialExpiry(result) {
|
|
5
|
+
return typeof result === 'object' && result !== null
|
|
6
|
+
? result.expiresAt
|
|
7
|
+
: undefined;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=credentialResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialResult.js","sourceRoot":"","sources":["../../src/auth/credentialResult.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,eAAe,CAC7B,MAAgC;IAEhC,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,IAAI,IAAI,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,MAAgC;IAEhC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAClD,CAAC,CAAC,MAAM,CAAC,SAAS;QAClB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The single mutable holder for the active bearer credential every transport
|
|
3
|
+
* uses.
|
|
4
|
+
*
|
|
5
|
+
* Each transport reads the current token from this object at request or connect
|
|
6
|
+
* time — the HTTP request paths and the WebSocket URL authorizer alike. When the
|
|
7
|
+
* token is refreshed, it is written here once, and every reader observes the new
|
|
8
|
+
* value through its getter rather than being updated one by one.
|
|
9
|
+
*/
|
|
10
|
+
export { WS_BEARER_SUBPROTOCOL_PREFIX, WS_SYNC_SUBPROTOCOL } from '../wire/protocol.js';
|
|
11
|
+
export interface AuthCredentialSource {
|
|
12
|
+
/**
|
|
13
|
+
* Declared as a standalone closure rather than a method because callers pass
|
|
14
|
+
* it on by reference — the transport and the core client each take
|
|
15
|
+
* `getAuthToken` alone and call it with no receiver. The implementation is a
|
|
16
|
+
* closure over the token, so that is safe; typing it as a method would say
|
|
17
|
+
* otherwise and make every hand-off read as a lost `this`.
|
|
18
|
+
*/
|
|
19
|
+
getAuthToken: () => string | null;
|
|
20
|
+
setAuthToken(token: string | null | undefined): void;
|
|
21
|
+
authorizationHeader(): string | undefined;
|
|
22
|
+
withAuthHeaders(headers?: Record<string, string>): Record<string, string>;
|
|
23
|
+
applyAuthQueryParam(params: URLSearchParams, paramName?: string): void;
|
|
24
|
+
}
|
|
25
|
+
export type AuthTokenGetter = () => string | null | undefined;
|
|
26
|
+
export declare function createAuthCredentialSource(initialToken?: string | null): AuthCredentialSource;
|
|
27
|
+
export declare function resolveAuthToken(getAuthToken?: AuthTokenGetter, fallbackToken?: string | null): string | undefined;
|
|
28
|
+
export declare function authorizationHeaderForToken(token: string | null | undefined): string | undefined;
|
|
29
|
+
export declare function withAuthHeaders(getAuthToken: AuthTokenGetter | undefined, headers?: Record<string, string>, fallbackToken?: string | null): Record<string, string>;
|
|
30
|
+
export declare function applyAuthToQueryParams(params: URLSearchParams, getAuthToken: AuthTokenGetter | undefined, paramName?: string, fallbackToken?: string | null): void;
|
|
31
|
+
//# sourceMappingURL=credentialSource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialSource.d.ts","sourceRoot":"","sources":["../../src/auth/credentialSource.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAExF,MAAM,WAAW,oBAAoB;IACnC;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC;IACrD,mBAAmB,IAAI,MAAM,GAAG,SAAS,CAAC;IAC1C,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1E,mBAAmB,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxE;AAED,MAAM,MAAM,eAAe,GAAG,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAE9D,wBAAgB,0BAA0B,CACxC,YAAY,CAAC,EAAE,MAAM,GAAG,IAA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