@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,56 @@
|
|
|
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
|
+
// The WebSocket bearer-subprotocol constants are defined in `../wire/protocol.js`
|
|
11
|
+
// as part of the wire contract shared between client and server. They are
|
|
12
|
+
// re-exported here so this module stays a stable import site for them.
|
|
13
|
+
export { WS_BEARER_SUBPROTOCOL_PREFIX, WS_SYNC_SUBPROTOCOL } from '../wire/protocol.js';
|
|
14
|
+
export function createAuthCredentialSource(initialToken) {
|
|
15
|
+
let authToken = normalizeToken(initialToken);
|
|
16
|
+
return {
|
|
17
|
+
getAuthToken: () => authToken,
|
|
18
|
+
setAuthToken(token) {
|
|
19
|
+
authToken = normalizeToken(token);
|
|
20
|
+
},
|
|
21
|
+
authorizationHeader() {
|
|
22
|
+
return authorizationHeaderForToken(authToken);
|
|
23
|
+
},
|
|
24
|
+
withAuthHeaders(headers = {}) {
|
|
25
|
+
const authorization = authorizationHeaderForToken(authToken);
|
|
26
|
+
return authorization ? { ...headers, Authorization: authorization } : { ...headers };
|
|
27
|
+
},
|
|
28
|
+
applyAuthQueryParam(params, paramName = 'authorization') {
|
|
29
|
+
applyAuthToQueryParams(params, () => authToken, paramName);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function resolveAuthToken(getAuthToken, fallbackToken) {
|
|
34
|
+
return normalizeToken(getAuthToken?.() ?? fallbackToken) ?? undefined;
|
|
35
|
+
}
|
|
36
|
+
export function authorizationHeaderForToken(token) {
|
|
37
|
+
const normalized = normalizeToken(token);
|
|
38
|
+
return normalized ? `Bearer ${normalized}` : undefined;
|
|
39
|
+
}
|
|
40
|
+
export function withAuthHeaders(getAuthToken, headers = {}, fallbackToken) {
|
|
41
|
+
const authorization = authorizationHeaderForToken(resolveAuthToken(getAuthToken, fallbackToken));
|
|
42
|
+
return authorization ? { ...headers, Authorization: authorization } : { ...headers };
|
|
43
|
+
}
|
|
44
|
+
export function applyAuthToQueryParams(params, getAuthToken, paramName = 'authorization', fallbackToken) {
|
|
45
|
+
const authorization = authorizationHeaderForToken(resolveAuthToken(getAuthToken, fallbackToken));
|
|
46
|
+
if (authorization) {
|
|
47
|
+
params.set(paramName, authorization);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function normalizeToken(token) {
|
|
51
|
+
if (!token)
|
|
52
|
+
return null;
|
|
53
|
+
const trimmed = token.trim();
|
|
54
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=credentialSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentialSource.js","sourceRoot":"","sources":["../../src/auth/credentialSource.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,kFAAkF;AAClF,0EAA0E;AAC1E,uEAAuE;AACvE,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAmBxF,MAAM,UAAU,0BAA0B,CACxC,YAA4B;IAE5B,IAAI,SAAS,GAAG,cAAc,CAAC,YAAY,CAAC,CAAC;IAE7C,OAAO;QACL,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;QAC7B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,EACvB,YAAyC,EACzC,SAAS,GAAG,eAAe,EAC3B,aAA6B;IAE7B,MAAM,aAAa,GAAG,2BAA2B,CAC/C,gBAAgB,CAAC,YAAY,EAAE,aAAa,CAAC,CAC9C,CAAC;IACF,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,KAAgC;IACtD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hosted Ablo Cloud endpoint constants, with no dependencies of their own.
|
|
3
|
+
*
|
|
4
|
+
* This is the single place the hosted API host is declared. URL resolution, the
|
|
5
|
+
* CLI's default URL, the data-source connector's base, the generated OpenAPI
|
|
6
|
+
* server entry, and the network probe's default all import from here, so
|
|
7
|
+
* changing the API domain is a one-line edit.
|
|
8
|
+
*
|
|
9
|
+
* These constants are kept dependency-free deliberately: several low-level
|
|
10
|
+
* modules consume them, and routing those modules through the auth layer would
|
|
11
|
+
* pull the error registry and credential policy into otherwise-clean paths and
|
|
12
|
+
* risk an import cycle.
|
|
13
|
+
*/
|
|
14
|
+
/** The hosted API domain (no scheme). */
|
|
15
|
+
export declare const ABLO_HOSTED_API_DOMAIN = "api.abloatai.com";
|
|
16
|
+
/** The hosted HTTP origin — `https://` + {@link ABLO_HOSTED_API_DOMAIN}. */
|
|
17
|
+
export declare const ABLO_HOSTED_HTTP_BASE_URL = "https://api.abloatai.com";
|
|
18
|
+
/** Default `baseURL` when the caller passes none. Same value as
|
|
19
|
+
* {@link ABLO_HOSTED_HTTP_BASE_URL}; kept as a distinct name because it is
|
|
20
|
+
* the documented client-options default. */
|
|
21
|
+
export declare const ABLO_DEFAULT_BASE_URL = "https://api.abloatai.com";
|
|
22
|
+
//# sourceMappingURL=hostedEndpoints.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostedEndpoints.d.ts","sourceRoot":"","sources":["../../src/auth/hostedEndpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,yCAAyC;AACzC,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAEzD,4EAA4E;AAC5E,eAAO,MAAM,yBAAyB,6BAAsC,CAAC;AAE7E;;6CAE6C;AAC7C,eAAO,MAAM,qBAAqB,6BAA4B,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hosted Ablo Cloud endpoint constants, with no dependencies of their own.
|
|
3
|
+
*
|
|
4
|
+
* This is the single place the hosted API host is declared. URL resolution, the
|
|
5
|
+
* CLI's default URL, the data-source connector's base, the generated OpenAPI
|
|
6
|
+
* server entry, and the network probe's default all import from here, so
|
|
7
|
+
* changing the API domain is a one-line edit.
|
|
8
|
+
*
|
|
9
|
+
* These constants are kept dependency-free deliberately: several low-level
|
|
10
|
+
* modules consume them, and routing those modules through the auth layer would
|
|
11
|
+
* pull the error registry and credential policy into otherwise-clean paths and
|
|
12
|
+
* risk an import cycle.
|
|
13
|
+
*/
|
|
14
|
+
/** The hosted API domain (no scheme). */
|
|
15
|
+
export const ABLO_HOSTED_API_DOMAIN = 'api.abloatai.com';
|
|
16
|
+
/** The hosted HTTP origin — `https://` + {@link ABLO_HOSTED_API_DOMAIN}. */
|
|
17
|
+
export const ABLO_HOSTED_HTTP_BASE_URL = `https://${ABLO_HOSTED_API_DOMAIN}`;
|
|
18
|
+
/** Default `baseURL` when the caller passes none. Same value as
|
|
19
|
+
* {@link ABLO_HOSTED_HTTP_BASE_URL}; kept as a distinct name because it is
|
|
20
|
+
* the documented client-options default. */
|
|
21
|
+
export const ABLO_DEFAULT_BASE_URL = ABLO_HOSTED_HTTP_BASE_URL;
|
|
22
|
+
//# sourceMappingURL=hostedEndpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostedEndpoints.js","sourceRoot":"","sources":["../../src/auth/hostedEndpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,yCAAyC;AACzC,MAAM,CAAC,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAEzD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,yBAAyB,GAAG,WAAW,sBAAsB,EAAE,CAAC;AAE7E;;6CAE6C;AAC7C,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a participant's identity and scope when an {@link Ablo} client is
|
|
3
|
+
* constructed, following whichever of three authentication paths the caller's
|
|
4
|
+
* options select:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Hosted cloud** — the caller passed an `apiKey`. The client exchanges it
|
|
7
|
+
* for a capability token and scope, then starts a scheduler that re-mints the
|
|
8
|
+
* token before it expires, so the rotation is invisible to the caller.
|
|
9
|
+
* 2. **Self-derived** — the caller passed a bearer or capability token but not
|
|
10
|
+
* an identity. The client asks the identity endpoint to recover the
|
|
11
|
+
* participant id and scope from the token.
|
|
12
|
+
* 3. **Explicit** — a self-hosted caller passed the organization id and a user
|
|
13
|
+
* or agent id directly. No server round-trip; the client trusts the caller.
|
|
14
|
+
*
|
|
15
|
+
* Each branch is a separate function below, so it can be read and tested on its own.
|
|
16
|
+
*/
|
|
17
|
+
import type { ParticipantKind } from '../types/participant.js';
|
|
18
|
+
import { type RefreshScheduler } from '../auth/index.js';
|
|
19
|
+
import type { BootstrapScope } from '../auth/bootstrapScope.js';
|
|
20
|
+
import type { Logger } from '../logger.js';
|
|
21
|
+
import type { AuthCredentialSource } from '../auth/credentialSource.js';
|
|
22
|
+
import type { CredentialProvider } from './credentialResult.js';
|
|
23
|
+
export interface IdentityResolveInput {
|
|
24
|
+
readonly options: {
|
|
25
|
+
readonly capabilityToken?: string;
|
|
26
|
+
readonly bootstrapBaseUrl?: string;
|
|
27
|
+
readonly user?: {
|
|
28
|
+
id: string;
|
|
29
|
+
teamIds?: string[];
|
|
30
|
+
};
|
|
31
|
+
readonly agentId?: string;
|
|
32
|
+
readonly syncGroups?: string[];
|
|
33
|
+
};
|
|
34
|
+
readonly internalOptions: {
|
|
35
|
+
readonly organizationId?: string;
|
|
36
|
+
};
|
|
37
|
+
readonly url: string;
|
|
38
|
+
readonly kind: ParticipantKind;
|
|
39
|
+
readonly configuredApiKey: string | CredentialProvider | null;
|
|
40
|
+
readonly configuredAuthToken: string | null;
|
|
41
|
+
readonly bootstrapHelper: BootstrapScope;
|
|
42
|
+
readonly auth: AuthCredentialSource;
|
|
43
|
+
readonly logger: Logger;
|
|
44
|
+
}
|
|
45
|
+
export interface ResolvedIdentity {
|
|
46
|
+
readonly userId: string;
|
|
47
|
+
readonly accountScope: string;
|
|
48
|
+
/** Concrete project selected by the credential. The org id is the default project. */
|
|
49
|
+
readonly projectId: string | null;
|
|
50
|
+
/** Data environment selected by the credential. Null for explicit/self-hosted identities. */
|
|
51
|
+
readonly environment: 'sandbox' | 'production' | null;
|
|
52
|
+
/** Concrete sandbox selected by the credential, when applicable. */
|
|
53
|
+
readonly sandboxId: string | null;
|
|
54
|
+
readonly teamIds: string[] | undefined;
|
|
55
|
+
readonly capabilityToken: string | undefined;
|
|
56
|
+
readonly syncGroups: readonly string[] | undefined;
|
|
57
|
+
readonly participantKind: ParticipantKind;
|
|
58
|
+
/** Set only on the hosted-cloud path; the caller keeps it to stop refreshes on shutdown. */
|
|
59
|
+
readonly refreshScheduler: RefreshScheduler | null;
|
|
60
|
+
}
|
|
61
|
+
export declare function resolveParticipantIdentity(input: IdentityResolveInput): Promise<ResolvedIdentity>;
|
|
62
|
+
//# source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AAe,EAAE,cAAc,CAAC;IACzC,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,sFAAsF;IACtF,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,6FAA6F;IAC7F,QAAQ,CAAC,WAAW,EAAE,SAAS,GAAG,YAAY,GAAG,IAAI,CAAC;IACtD,oEAAoE;IACpE,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC;IACnD,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAC1C,4FAA4F;IAC5F,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACpD;AAED,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,gBAAgB,CAAC,CAyH3B"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a participant's identity and scope when an {@link Ablo} client is
|
|
3
|
+
* constructed, following whichever of three authentication paths the caller's
|
|
4
|
+
* options select:
|
|
5
|
+
*
|
|
6
|
+
* 1. **Hosted cloud** — the caller passed an `apiKey`. The client exchanges it
|
|
7
|
+
* for a capability token and scope, then starts a scheduler that re-mints the
|
|
8
|
+
* token before it expires, so the rotation is invisible to the caller.
|
|
9
|
+
* 2. **Self-derived** — the caller passed a bearer or capability token but not
|
|
10
|
+
* an identity. The client asks the identity endpoint to recover the
|
|
11
|
+
* participant id and scope from the token.
|
|
12
|
+
* 3. **Explicit** — a self-hosted caller passed the organization id and a user
|
|
13
|
+
* or agent id directly. No server round-trip; the client trusts the caller.
|
|
14
|
+
*
|
|
15
|
+
* Each branch is a separate function below, so it can be read and tested on its own.
|
|
16
|
+
*/
|
|
17
|
+
import { AbloAuthenticationError } from '../errors.js';
|
|
18
|
+
import { exchangeApiKey } from '../auth/index.js';
|
|
19
|
+
import { mintUserSessionKey } from '../auth/index.js';
|
|
20
|
+
import { resolveIdentity } from '../auth/index.js';
|
|
21
|
+
import { createRefreshScheduler, } from '../auth/index.js';
|
|
22
|
+
import { resolveCredential, } from '../auth/credentialPolicy.js';
|
|
23
|
+
import { resolveApiKeyValue, resolveBootstrapBaseUrl } from './apiKey.js';
|
|
24
|
+
export async function resolveParticipantIdentity(input) {
|
|
25
|
+
const { options, internalOptions, url, kind, configuredApiKey, configuredAuthToken, bootstrapHelper, auth, logger, } = input;
|
|
26
|
+
const apiKeyValue = await resolveApiKeyValue(configuredApiKey);
|
|
27
|
+
// Resolve the http(s) base URL, coercing ws/wss to http/https even when
|
|
28
|
+
// `bootstrapBaseUrl` is an explicit override (see auth.ts).
|
|
29
|
+
const baseUrl = resolveBootstrapBaseUrl({
|
|
30
|
+
url,
|
|
31
|
+
bootstrapBaseUrl: options.bootstrapBaseUrl,
|
|
32
|
+
});
|
|
33
|
+
// An organization id plus a caller-supplied participant id is the explicit path:
|
|
34
|
+
// the caller already knows its own identity, so no server round-trip is needed.
|
|
35
|
+
const hasExplicitIdentity = internalOptions.organizationId != null &&
|
|
36
|
+
(kind === 'agent' ? options.agentId != null : options.user?.id != null);
|
|
37
|
+
// The credential-routing decision lives in `credentialPolicy`: it classifies the
|
|
38
|
+
// apiKey by prefix (`sk_`/`ek_`/`rk_`/`pk_`) and picks a route. The hosted
|
|
39
|
+
// exchange is the one mint the policy performs (via the injected
|
|
40
|
+
// `exchangeApiKey`); every other route simply returns the bearer to use. The
|
|
41
|
+
// switch below applies scope and sets up the refresh scheduler for each case.
|
|
42
|
+
const cred = await resolveCredential({
|
|
43
|
+
apiKeyValue,
|
|
44
|
+
configuredApiKey,
|
|
45
|
+
capabilityToken: options.capabilityToken,
|
|
46
|
+
authToken: configuredAuthToken,
|
|
47
|
+
hasExplicitIdentity,
|
|
48
|
+
}, {
|
|
49
|
+
primitives: {
|
|
50
|
+
exchangeApiKey,
|
|
51
|
+
mintUserSessionKey,
|
|
52
|
+
resolveIdentity,
|
|
53
|
+
resolveApiKeyValue,
|
|
54
|
+
},
|
|
55
|
+
exchangeArgs: {
|
|
56
|
+
baseUrl,
|
|
57
|
+
participantKind: (kind === 'agent' ? 'agent' : 'system'),
|
|
58
|
+
participantId: options.agentId ?? options.user?.id,
|
|
59
|
+
wideScope: true,
|
|
60
|
+
ttlSeconds: 3600,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
switch (cred.kind) {
|
|
64
|
+
case 'publishable':
|
|
65
|
+
// `pk_` is a long-lived, browser-safe, read-only project key. It is used
|
|
66
|
+
// directly as the bearer and is never exchanged for a short-lived
|
|
67
|
+
// capability, so it never expires and there is nothing to refresh. The
|
|
68
|
+
// server resolves the organization and read-only scope from the key itself;
|
|
69
|
+
// we still call `/auth/identity` with the `pk_` bearer to learn the account
|
|
70
|
+
// scope and sync groups for the bootstrap cache.
|
|
71
|
+
return resolveViaIdentity({
|
|
72
|
+
bearer: cred.getBearer,
|
|
73
|
+
baseUrl,
|
|
74
|
+
options,
|
|
75
|
+
bootstrapHelper,
|
|
76
|
+
auth,
|
|
77
|
+
});
|
|
78
|
+
case 'exchange':
|
|
79
|
+
// Hosted-cloud (`sk_`): the policy exchanged the apiKey for a capability
|
|
80
|
+
// token; here we apply the returned scope and set up the refresh scheduler.
|
|
81
|
+
return resolveHosted({
|
|
82
|
+
cred,
|
|
83
|
+
configuredApiKey,
|
|
84
|
+
baseUrl,
|
|
85
|
+
kind,
|
|
86
|
+
options,
|
|
87
|
+
bootstrapHelper,
|
|
88
|
+
auth,
|
|
89
|
+
logger,
|
|
90
|
+
});
|
|
91
|
+
case 'pre-minted':
|
|
92
|
+
// Self-derived: a pre-minted `ek_`/`rk_` bearer or an explicit capability
|
|
93
|
+
// token authenticates `/auth/identity` directly (no exchange, no refresh).
|
|
94
|
+
return resolveViaIdentity({
|
|
95
|
+
bearer: cred.getBearer,
|
|
96
|
+
baseUrl,
|
|
97
|
+
options,
|
|
98
|
+
bootstrapHelper,
|
|
99
|
+
auth,
|
|
100
|
+
});
|
|
101
|
+
case 'explicit': {
|
|
102
|
+
// Explicit self-hosted identity: the caller supplied its own organization id
|
|
103
|
+
// and user or agent id.
|
|
104
|
+
const userId = kind === 'agent' ? options.agentId : options.user.id;
|
|
105
|
+
const accountScope = internalOptions.organizationId;
|
|
106
|
+
bootstrapHelper.setCacheScope(accountScope);
|
|
107
|
+
bootstrapHelper.setSyncGroups(options.syncGroups);
|
|
108
|
+
auth.setAuthToken(cred.getBearer);
|
|
109
|
+
return {
|
|
110
|
+
userId,
|
|
111
|
+
accountScope,
|
|
112
|
+
projectId: accountScope,
|
|
113
|
+
environment: null,
|
|
114
|
+
sandboxId: null,
|
|
115
|
+
teamIds: kind === 'user' ? options.user?.teamIds : undefined,
|
|
116
|
+
capabilityToken: cred.getBearer,
|
|
117
|
+
syncGroups: options.syncGroups,
|
|
118
|
+
participantKind: kind,
|
|
119
|
+
refreshScheduler: null,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Resolves identity through the `/auth/identity` endpoint for the publishable
|
|
126
|
+
* (`pk_`) and pre-minted (`ek_`/`rk_` or explicit capability token) routes. The
|
|
127
|
+
* bearer is used as-is, the server resolves the identity, and any caller-passed
|
|
128
|
+
* sync groups are merged with the server-resolved set.
|
|
129
|
+
*/
|
|
130
|
+
async function resolveViaIdentity(input) {
|
|
131
|
+
const { bearer, baseUrl, options, bootstrapHelper, auth } = input;
|
|
132
|
+
const identity = await resolveIdentity({ baseUrl, authToken: bearer });
|
|
133
|
+
// Merge the caller's sync groups with the server-resolved set rather than
|
|
134
|
+
// letting the server response overwrite them. A client may compose groups such
|
|
135
|
+
// as `['default', 'org:<id>', 'user:<id>', 'team:<id>']` from the resolved
|
|
136
|
+
// session and pass them in; the identity endpoint can return an empty set (for
|
|
137
|
+
// example, for cookie-authenticated users), and an empty set makes the server
|
|
138
|
+
// bootstrap fall back to `['default']`, so no deltas fan out and live updates
|
|
139
|
+
// appear only on a hard reload. Merging keeps the caller's groups intact.
|
|
140
|
+
const callerGroups = options.syncGroups ?? [];
|
|
141
|
+
const mergedSyncGroups = callerGroups.length > 0
|
|
142
|
+
? [...new Set([...callerGroups, ...identity.syncGroups])]
|
|
143
|
+
: identity.syncGroups;
|
|
144
|
+
bootstrapHelper.setCacheScope(identity.accountScope);
|
|
145
|
+
bootstrapHelper.setSyncGroups(mergedSyncGroups);
|
|
146
|
+
auth.setAuthToken(bearer);
|
|
147
|
+
return {
|
|
148
|
+
userId: identity.participantId,
|
|
149
|
+
accountScope: identity.accountScope,
|
|
150
|
+
projectId: identity.projectId ?? identity.accountScope,
|
|
151
|
+
environment: identity.environment ?? null,
|
|
152
|
+
sandboxId: identity.sandboxId ?? null,
|
|
153
|
+
teamIds: undefined,
|
|
154
|
+
capabilityToken: bearer,
|
|
155
|
+
syncGroups: mergedSyncGroups,
|
|
156
|
+
participantKind: identity.participantKind,
|
|
157
|
+
refreshScheduler: null,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
async function resolveHosted(input) {
|
|
161
|
+
// The managed-cloud shape, `Ablo({ schema, apiKey })`. The credential policy has
|
|
162
|
+
// already exchanged the apiKey via `exchangeApiKey`; here we apply the returned
|
|
163
|
+
// scope and set up the refresh scheduler.
|
|
164
|
+
const { exchange } = input.cred;
|
|
165
|
+
const baseUrl = input.baseUrl;
|
|
166
|
+
// The refresh path re-runs `exchangeApiKey` with a freshly-resolved apiKey, so
|
|
167
|
+
// it needs the same argument bag the policy used for the initial exchange.
|
|
168
|
+
const participantKind = input.kind === 'agent' ? 'agent' : 'system';
|
|
169
|
+
const exchangeArgs = {
|
|
170
|
+
baseUrl,
|
|
171
|
+
participantKind,
|
|
172
|
+
participantId: input.options.agentId ?? input.options.user?.id,
|
|
173
|
+
wideScope: true,
|
|
174
|
+
ttlSeconds: 3600,
|
|
175
|
+
};
|
|
176
|
+
input.bootstrapHelper.setCacheScope(exchange.scope.organizationId);
|
|
177
|
+
input.bootstrapHelper.setSyncGroups(exchange.scope.syncGroups);
|
|
178
|
+
input.auth.setAuthToken(exchange.token);
|
|
179
|
+
// Capability tokens carry a server-set TTL (3600s by default). Without proactive
|
|
180
|
+
// refresh, the socket would be force-closed at expiry, or the next reconnect
|
|
181
|
+
// would fail with a 401. The scheduler re-mints ahead of that, so the consumer
|
|
182
|
+
// never sees the rotation.
|
|
183
|
+
const refreshScheduler = createRefreshScheduler({
|
|
184
|
+
initialExpiresAtMs: Date.parse(exchange.expiresAt),
|
|
185
|
+
refresh: async () => {
|
|
186
|
+
// Read the apiKey fresh each time — supports a CredentialProvider
|
|
187
|
+
// (rotating credentials) shape.
|
|
188
|
+
const freshApiKey = await resolveApiKeyValue(input.configuredApiKey);
|
|
189
|
+
if (!freshApiKey) {
|
|
190
|
+
throw new AbloAuthenticationError('apiKey unavailable during refresh', { code: 'apikey_missing' });
|
|
191
|
+
}
|
|
192
|
+
const next = await exchangeApiKey({
|
|
193
|
+
...exchangeArgs,
|
|
194
|
+
apiKey: freshApiKey,
|
|
195
|
+
});
|
|
196
|
+
input.auth.setAuthToken(next.token);
|
|
197
|
+
return { expiresAtMs: Date.parse(next.expiresAt) };
|
|
198
|
+
},
|
|
199
|
+
onError: (err) => {
|
|
200
|
+
input.logger.debug('cap token refresh failed; will retry', {
|
|
201
|
+
error: err.message,
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
return {
|
|
206
|
+
userId: exchange.scope.participantId,
|
|
207
|
+
accountScope: exchange.scope.organizationId,
|
|
208
|
+
// The legacy capability exchange response predates the explicit plane
|
|
209
|
+
// fields returned by `/auth/identity`. A hosted secret-key client defaults
|
|
210
|
+
// to the org-default project; browser sessions use resolveViaIdentity and
|
|
211
|
+
// therefore receive the concrete project/environment/sandbox tuple.
|
|
212
|
+
projectId: exchange.scope.organizationId,
|
|
213
|
+
environment: null,
|
|
214
|
+
sandboxId: null,
|
|
215
|
+
// teamIds isn't needed because the server already encoded
|
|
216
|
+
// team-level access into scope.syncGroups.
|
|
217
|
+
teamIds: undefined,
|
|
218
|
+
capabilityToken: exchange.token,
|
|
219
|
+
syncGroups: exchange.scope.syncGroups,
|
|
220
|
+
participantKind: input.kind,
|
|
221
|
+
refreshScheduler,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/auth/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,sBAAsB,GAEvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,iBAAiB,GAElB,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAqC1E,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,KAA2B;IAE3B,MAAM,EACJ,OAAO,EACP,eAAe,EACf,GAAG,EACH,IAAI,EACJ,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,IAAI,EACJ,MAAM,GACP,G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C3B,CAAC;YACJ,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,cAAc,CAAC;gBAChC,GAAG,YAAY;gBACf,MAAM,EAAE,WAAW;aACpB,CAAC,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;QACrD,CAAC;QACD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACf,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,sCAAsC,EAAE;gBACzD,KAAK,EAAE,GAAG,CAAC,OAAO;aACnB,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,aAAa;QACpC,YAAY,EAAE,QAAQ,CAAC,KAAK,CAAC,cAAc;QAC3C,sEAAsE;QACtE,2EAA2E;QAC3E,0EAA0E;QAC1E,oEAAoE;QACpE,SAAS,EAAE,QAAQ,CAAC,KAAK,CAAC,cAAc;QACxC,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,IAAI;QACf,0DAA0D;QAC1D,2CAA2C;QAC3C,OAAO,EAAE,SAAS;QAClB,eAAe,EAAE,QAAQ,CAAC,KAAK;QAC/B,UAAU,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU;QACrC,eAAe,EAAE,KAAK,CAAC,IAAI;QAC3B,gBAAgB;KACjB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exchanges an API key for a capability token and the scope it grants.
|
|
3
|
+
*
|
|
4
|
+
* The `Ablo({...})` factory calls this during startup when you provide an
|
|
5
|
+
* `apiKey` but no explicit capability token, organization, or user identity. It
|
|
6
|
+
* sends one `POST /v1/capabilities` request; the server responds with the
|
|
7
|
+
* granted scope and any user metadata, which the client uses to populate its
|
|
8
|
+
* session state. The API key is the only credential you handle directly — this
|
|
9
|
+
* exchange happens automatically behind it.
|
|
10
|
+
*/
|
|
11
|
+
import { type EphemeralKeyResponse, type IdentityResolveResponse } from './schemas.js';
|
|
12
|
+
import type { ParticipantKind } from '../types/participant.js';
|
|
13
|
+
import type { CapabilityMintResponse, GrantedOperation } from './capability.js';
|
|
14
|
+
export { ABLO_DEFAULT_BASE_URL, ABLO_HOSTED_API_DOMAIN, ABLO_HOSTED_HTTP_BASE_URL, } from './hostedEndpoints.js';
|
|
15
|
+
export { normalizeAbloHostedBaseUrl } from './apiKey.js';
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Use {@link CapabilityMintResponse}. This is a type-only,
|
|
18
|
+
* one-release rename bridge; both names resolve to the same canonical Zod
|
|
19
|
+
* contract and no runtime parser or schema is duplicated.
|
|
20
|
+
*/
|
|
21
|
+
export type CapabilityExchangeResponse = CapabilityMintResponse;
|
|
22
|
+
export type { EphemeralKeyResponse, IdentityResolveResponse, } from './schemas.js';
|
|
23
|
+
export { parseCapabilityMintResponse } from './schemas.js';
|
|
24
|
+
export { credentialEndpointErrorSchema, credentialEndpointKindSchema, credentialEndpointSuccessSchema, credentialEndpointErrorCode, parseCredentialEndpointSuccess, } from './credentialEndpointProtocol.js';
|
|
25
|
+
export type { CredentialEndpointError, CredentialEndpointSuccess, } from './credentialEndpointProtocol.js';
|
|
26
|
+
export type { CredentialProvider, CredentialProviderResult, } from './credentialResult.js';
|
|
27
|
+
export { capabilityRotationRequestSchema, capabilityRotationResponseSchema, sessionRevocationResponseSchema, revokeCapability, rotateCapability, } from './capabilityLifecycle.js';
|
|
28
|
+
export type { RevokeCapabilityRequest, RotateCapabilityRequest, } from './capabilityLifecycle.js';
|
|
29
|
+
export { capabilityOperationSchema, capabilityCanSchema, capabilityCanSchemaFor, capabilityScopeSchema, capabilityRequestSchema, capabilityMintResponseSchema, grantedOperationSchema, grantedOperations, expandReadYourWrites, modelWireNames, capabilityModelAliases, unresolvableOperations, } from './capability.js';
|
|
30
|
+
export type { CapabilityOperation, CapabilityCan, CapabilityGrant, CapabilityScope, CapabilityMintResponse, CapabilityRequest, CapabilityModelShape, GrantedOperation, } from './capability.js';
|
|
31
|
+
export interface ExchangeApiKeyRequest {
|
|
32
|
+
readonly apiKey: string;
|
|
33
|
+
readonly baseUrl: string;
|
|
34
|
+
readonly participantKind: ParticipantKind;
|
|
35
|
+
readonly participantId?: string;
|
|
36
|
+
readonly organizationId?: string;
|
|
37
|
+
readonly syncGroups?: readonly string[];
|
|
38
|
+
/** The grant's verb axis, already in wire form. Build it with
|
|
39
|
+
* `grantedOperations(can)` rather than assembling `model.verb` by hand. */
|
|
40
|
+
readonly operations?: readonly GrantedOperation[];
|
|
41
|
+
/**
|
|
42
|
+
* Grants a wider scope than the narrow-by-default behavior. This is an internal
|
|
43
|
+
* escalation used only by the startup exchange; it is stripped from the
|
|
44
|
+
* published type declarations and is not meant to be set by application code.
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
readonly wideScope?: boolean;
|
|
48
|
+
readonly ttlSeconds: number;
|
|
49
|
+
readonly label?: string;
|
|
50
|
+
readonly userMeta?: Record<string, unknown>;
|
|
51
|
+
readonly fetch?: typeof fetch;
|
|
52
|
+
readonly timeoutMs?: number;
|
|
53
|
+
}
|
|
54
|
+
export declare function exchangeApiKey(options: ExchangeApiKeyRequest): Promise<CapabilityMintResponse>;
|
|
55
|
+
interface MintUserSessionBase {
|
|
56
|
+
/** Your secret API key (an `sk_` key). Minting a session is a server-side
|
|
57
|
+
* operation, so it always presents the secret key, never a token derived
|
|
58
|
+
* from it. */
|
|
59
|
+
readonly apiKey: string;
|
|
60
|
+
readonly baseUrl: string;
|
|
61
|
+
/** The end user's identifier in your identity provider. It becomes the
|
|
62
|
+
* session's `participantId`. */
|
|
63
|
+
readonly userId: string;
|
|
64
|
+
/** The organization to mint the session into, for a platform that manages many
|
|
65
|
+
* organizations. Requires the secret key to carry the `ephemeral:mint-any-org`
|
|
66
|
+
* capability. Omit to mint into the key's own organization. */
|
|
67
|
+
readonly organizationId?: string;
|
|
68
|
+
/** Points this session's schema at a shared project while its data stays scoped
|
|
69
|
+
* to `organizationId`. Use this when each customer has its own organization but
|
|
70
|
+
* they all share one schema: keep a single schema project, and every customer's
|
|
71
|
+
* session resolves its schema from it instead of pushing the schema into each
|
|
72
|
+
* organization separately. Requires the secret key to carry the
|
|
73
|
+
* `ephemeral:mint-any-org` capability. Omit to resolve the schema from the
|
|
74
|
+
* session's own organization. */
|
|
75
|
+
readonly schemaProject?: {
|
|
76
|
+
/** The organization that owns the shared schema project. */
|
|
77
|
+
readonly organizationId: string;
|
|
78
|
+
/** The project the schema was pushed under. */
|
|
79
|
+
readonly projectId: string;
|
|
80
|
+
};
|
|
81
|
+
readonly syncGroups?: readonly string[];
|
|
82
|
+
readonly ttlSeconds: number;
|
|
83
|
+
readonly label?: string;
|
|
84
|
+
readonly fetch?: typeof fetch;
|
|
85
|
+
readonly timeoutMs?: number;
|
|
86
|
+
}
|
|
87
|
+
export type MintUserSessionRequest = MintUserSessionBase & {
|
|
88
|
+
/** Required least-privilege operation allowlist. */
|
|
89
|
+
readonly operations: readonly GrantedOperation[];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Mints an end-user session key (an `ek_` key) by calling
|
|
93
|
+
* `POST /v1/ephemeral_keys`, using your secret key as authorization. Your
|
|
94
|
+
* backend calls this to issue a session that a browser can present as its bearer
|
|
95
|
+
* credential; the server trusts the resulting key because a secret key minted it.
|
|
96
|
+
*
|
|
97
|
+
* This is a distinct endpoint from `/v1/capabilities`, which exchanges keys for
|
|
98
|
+
* agents and systems and cannot mint sessions for human users.
|
|
99
|
+
*/
|
|
100
|
+
export declare function mintUserSessionKey(options: MintUserSessionRequest): Promise<EphemeralKeyResponse>;
|
|
101
|
+
export interface ResolveIdentityRequest {
|
|
102
|
+
readonly baseUrl: string;
|
|
103
|
+
readonly authToken?: string;
|
|
104
|
+
readonly fetch?: typeof fetch;
|
|
105
|
+
readonly timeoutMs?: number;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Resolves the caller's identity from an authenticated request by calling
|
|
109
|
+
* `GET /auth/identity`. This lets browser and session flows learn who the
|
|
110
|
+
* current user is without requiring the application to pass a user id up front —
|
|
111
|
+
* for example, to key local storage.
|
|
112
|
+
*/
|
|
113
|
+
export declare function resolveIdentity(options: ResolveIdentityRequest): Promise<IdentityResolveResponse>;
|
|
114
|
+
/**
|
|
115
|
+
* Keeps a capability token fresh so a long-lived client never disconnects when
|
|
116
|
+
* its token expires.
|
|
117
|
+
*
|
|
118
|
+
* A capability token has a shorter lifetime — one hour by default — than a
|
|
119
|
+
* typical browser session. Without a refresh, the WebSocket is force-closed at
|
|
120
|
+
* expiry (close code 1008) or the next reconnect fails with a 401, and either way
|
|
121
|
+
* the user sees a mid-session disconnect. The scheduler prevents that by
|
|
122
|
+
* re-minting the token ahead of time.
|
|
123
|
+
*
|
|
124
|
+
* Three triggers share one refresh path:
|
|
125
|
+
*
|
|
126
|
+
* 1. Proactive — a timer set for `expiresAtMs - bufferMs - now`.
|
|
127
|
+
* 2. Visibility — when a hidden tab becomes visible and the token is already
|
|
128
|
+
* within the buffer window, refresh immediately. This covers a
|
|
129
|
+
* background tab whose timers were throttled while it was idle.
|
|
130
|
+
* 3. Reactive — the caller invokes {@link RefreshScheduler.refreshNow} after
|
|
131
|
+
* observing an auth failure, such as a WebSocket close 1008 or
|
|
132
|
+
* 4001.
|
|
133
|
+
*
|
|
134
|
+
* All three await the same in-flight promise, so concurrent triggers mint the
|
|
135
|
+
* token only once. Each successful refresh records the new expiry and reschedules
|
|
136
|
+
* the proactive timer.
|
|
137
|
+
*
|
|
138
|
+
* The refresh margin is `max(60s, ttl/10)` — six minutes for a one-hour token,
|
|
139
|
+
* and it scales down for shorter lifetimes.
|
|
140
|
+
*/
|
|
141
|
+
export interface RefreshSchedulerOptions {
|
|
142
|
+
/** Initial absolute expiry, ms since epoch (server-supplied). */
|
|
143
|
+
readonly initialExpiresAtMs: number;
|
|
144
|
+
/**
|
|
145
|
+
* Performs the token exchange and returns the new expiry. Errors propagate to
|
|
146
|
+
* `onError`; the scheduler stays alive and retries on its next trigger. It does
|
|
147
|
+
* not back off between retries, since the common failure here is a revoked API
|
|
148
|
+
* key, for which retrying would not help.
|
|
149
|
+
*/
|
|
150
|
+
readonly refresh: () => Promise<{
|
|
151
|
+
expiresAtMs: number;
|
|
152
|
+
}>;
|
|
153
|
+
/** Called on every successful refresh. */
|
|
154
|
+
readonly onRefreshed?: (info: {
|
|
155
|
+
expiresAtMs: number;
|
|
156
|
+
}) => void;
|
|
157
|
+
/** Called on every refresh failure. */
|
|
158
|
+
readonly onError?: (error: Error) => void;
|
|
159
|
+
/**
|
|
160
|
+
* Override the buffer (ms ahead of expiry to refresh). Defaults to
|
|
161
|
+
* `max(60_000, ttlMs * 0.1)`. Tests use a tiny value to exercise
|
|
162
|
+
* scheduling without burning real time.
|
|
163
|
+
*/
|
|
164
|
+
readonly bufferMs?: number;
|
|
165
|
+
/**
|
|
166
|
+
* If true, install a `visibilitychange` listener on `document` that
|
|
167
|
+
* triggers a refresh when the tab becomes visible and the token is
|
|
168
|
+
* within the buffer window. No-op if `document` is undefined (Node).
|
|
169
|
+
* Default: true in browser environments.
|
|
170
|
+
*/
|
|
171
|
+
readonly attachVisibilityListener?: boolean;
|
|
172
|
+
/** Time source. Override in tests; defaults to `Date.now`. */
|
|
173
|
+
readonly now?: () => number;
|
|
174
|
+
/** Timer pair. Override in tests. */
|
|
175
|
+
readonly setTimer?: (fn: () => void, ms: number) => ReturnType<typeof setTimeout>;
|
|
176
|
+
readonly clearTimer?: (handle: ReturnType<typeof setTimeout>) => void;
|
|
177
|
+
}
|
|
178
|
+
export interface RefreshScheduler {
|
|
179
|
+
/** Force a refresh now. Idempotent — concurrent calls share one promise. */
|
|
180
|
+
refreshNow(): Promise<{
|
|
181
|
+
expiresAtMs: number;
|
|
182
|
+
}>;
|
|
183
|
+
/** Stop scheduling. Safe to call multiple times. */
|
|
184
|
+
dispose(): void;
|
|
185
|
+
/** Current absolute expiry. Updated after each successful refresh. */
|
|
186
|
+
readonly expiresAtMs: number;
|
|
187
|
+
}
|
|
188
|
+
export declare function createRefreshScheduler(options: RefreshSchedulerOptions): RefreshScheduler;
|
|
189
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAI7B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,GAAG,sBAAsB,CAAC;AAEhE,YAAY,EACV,oBAAoB,EACpB,uBAAuB,GACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,+BAA+B,EAC/B,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,+BAA+B,EAC/B,gCAAgC,EAChC,+BAA+B,EAC/B,gBAAgB,EAChB,gBAAgB,GACjB,MA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