@tinycloud/sdk-core 2.9.0 → 2.10.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,7 +1,9 @@
1
1
  import { z } from 'zod';
2
- import { InvokeFunction, InvokeAnyFunction, ParsedNetworkId, ServiceError, Result as Result$1, ServiceSession, FetchFunction, ServiceConstructor, RetryPolicy, TelemetryConfig, IServiceContext, IService, IKVService, ISQLService, IDuckDbService, IHooksService, IDataVaultService, IEncryptionService, ISecretsService, IDatabaseHandle, SqlValue, QueryResponse } from '@tinycloud/sdk-services';
3
- export { BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CanonicalDecryptRequest, CanonicalJson, ColumnInfo, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DataVaultConfig, DataVaultService, DatabaseHandle, DecryptCapabilityProof, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DecryptTransportResponseError, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, ErrorCode, ErrorCodes, ExecuteOptions, ExecuteResponse, FetchFunction, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IEncryptionService, IHooksService, IKVService, IPrefixedKVService, ISQLService, ISecretsService, IService, IServiceContext, InlineEncryptedEnvelope, InvokeAnyEntry, InvokeAnyFunction, InvokeFunction, KVCreateSignedReadUrlOptions, KVDeleteOptions, KVGetOptions, KVHeadOptions, KVListOptions, KVListResponse, KVPutOptions, KVResponse, KVResponseHeaders, KVService, KVServiceConfig, KVSignedReadUrlResponse, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, ParsedNetworkId, PrefixedKVService, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, ResolvedSecretPath, Result, RetryPolicy, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceError, ServiceSession, SignedReceiverKeyInput, SqlStatement, SqlValue, SubscribeOptions, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VerifyDecryptResponseInput, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalHashHex, canonicalSignedResponse, canonicalizeEncryptionJson, canonicalizeSecretScope, checkDecryptInvocationInput, clearTinyCloudDebugLogs, createVaultCrypto, decryptEnvelopeWithKey, defaultRetryPolicy, deriveSignedReceiverKey, disableTinyCloudDebug, discoverNetwork, enableTinyCloudDebug, encryptToNetwork, base64Decode as encryptionBase64Decode, base64Encode as encryptionBase64Encode, encryptionError, utf8Decode as encryptionUtf8Decode, utf8Encode as encryptionUtf8Encode, ensureNetworkUsableForDecrypt, err, generateRandomReceiverKey, getTinyCloudDebugLogs, hexDecode, hexEncode, installTinyCloudDebugGlobals, isNetworkId, networkDiscoveryKey, ok, openWrappedKey, parseNetworkId, resolveSecretListPrefix, resolveSecretPath, serviceError, tinyCloudDebugLogger, validateEnvelope, verifyDecryptResponse } from '@tinycloud/sdk-services';
2
+ import { InvokeFunction, InvokeAnyFunction, ParsedNetworkId, ServiceError, Result, FetchFunction, ServiceConstructor, RetryPolicy, TelemetryConfig, IServiceContext, IService, IKVService, ISQLService, IDuckDbService, IHooksService, IDataVaultService, IEncryptionService, ISecretsService, ServiceSession, IDatabaseHandle, SqlValue, QueryResponse } from '@tinycloud/sdk-services';
3
+ export { BatchOptions, BatchResponse, BuildCanonicalDecryptRequestInput, BuildDecryptFactsInput, BuildDecryptInvocationInput, BuiltDecryptInvocation, CanonicalDecryptRequest, CanonicalJson, ColumnInfo, DECRYPT_ACTION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, DEFAULT_ENCRYPTION_ALG, DEFAULT_KEY_VERSION, DataVaultConfig, DataVaultService, DatabaseHandle, DecryptCapabilityProof, DecryptEnvelopeOptions, DecryptInvocationFact, DecryptInvocationSigner, DecryptRequestBody, DecryptResponseBody, DecryptTransport, DecryptTransportResponseError, DiscoverNetworkInput, DiscoveredNetwork, DiscoverySource, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, ENCRYPTION_NETWORK_URN_PREFIX, ENCRYPTION_SERVICE, ENCRYPTION_SERVICE_SHORT, ENVELOPE_VERSION, EncryptToNetworkInput, EncryptToNetworkOptions, EncryptToNetworkResult, EncryptionCrypto, EncryptionError, EncryptionErrorInput, EncryptionService, EncryptionServiceConfig, ErrorCode, ErrorCodes, ExecuteOptions, ExecuteResponse, FetchFunction, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IEncryptionService, IHooksService, IKVService, IPrefixedKVService, ISQLService, ISecretsService, IService, IServiceContext, InlineEncryptedEnvelope, InvokeAnyEntry, InvokeAnyFunction, InvokeFunction, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVDeleteOptions, KVGetOptions, KVHeadOptions, KVListOptions, KVListResponse, KVPutOptions, KVResponse, KVResponseHeaders, KVService, KVServiceConfig, KVSignedReadUrlResponse, NETWORK_NAME_PATTERN, NetworkDescriptor, NetworkIdError, NodeDescriptorFetcher, ParsedNetworkId, PrefixedKVService, QueryOptions, QueryResponse, RandomReceiverKeyInput, ReceiverKeyPair, ReceiverKeySigner, ResolvedSecretPath, Result, RetryPolicy, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceError, ServiceSession, SignedReceiverKeyInput, SqlStatement, SqlValue, SubscribeOptions, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VerifyDecryptResponseInput, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalHashHex, canonicalSignedResponse, canonicalizeEncryptionJson, canonicalizeSecretScope, checkDecryptInvocationInput, clearTinyCloudDebugLogs, createVaultCrypto, decryptEnvelopeWithKey, defaultRetryPolicy, deriveSignedReceiverKey, disableTinyCloudDebug, discoverNetwork, enableTinyCloudDebug, encryptToNetwork, base64Decode as encryptionBase64Decode, base64Encode as encryptionBase64Encode, encryptionError, utf8Decode as encryptionUtf8Decode, utf8Encode as encryptionUtf8Encode, ensureNetworkUsableForDecrypt, err, generateRandomReceiverKey, getTinyCloudDebugLogs, hexDecode, hexEncode, installTinyCloudDebugGlobals, isNetworkId, networkDiscoveryKey, ok, openWrappedKey, parseNetworkId, resolveSecretListPrefix, resolveSecretPath, serviceError, tinyCloudDebugLogger, validateEnvelope, verifyDecryptResponse } from '@tinycloud/sdk-services';
4
4
  export { HOLDER_KEY_BINDING_PRESENTATION_SCHEMA, HolderKeyBindingPresentation, LISTEN_SQL_STATEMENT_CATALOG, ListenSqlStatementName, POLICY_ENGINE_CHALLENGE_REQUEST_SCHEMA, POLICY_ENGINE_CHALLENGE_RESPONSE_SCHEMA, POLICY_ENGINE_DENIAL_SCHEMA, POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES, POLICY_ENGINE_RESOLVE_REQUEST_SCHEMA, PORTABLE_DELEGATION_SCHEMA, PolicyEngineGrantPresentationDenialCode, PortableDelegation, REQUESTER_ENGINE_RETRY_ATTEMPTS, REQUESTER_ENGINE_RETRY_MAX_DELAY_MS, REQUESTER_NEAR_EXPIRY_SECONDS, RequesterEndpointResolution, RequesterHttpRequest, RequesterHttpResponse, RequesterInvocationCapability, RequesterSigningCapability, RequesterTransport, TranscriptRequester, TranscriptRequesterError, TranscriptRequesterErrorCode, TranscriptRequesterErrorState, TranscriptRequesterOptions, TranscriptRequesterReadKvResult, TranscriptRequesterReadSqlResult, createTranscriptRequester, deriveDelegationCid, parseNodeNativePortableDelegation } from './requester/index.cjs';
5
+ import { m as Delegation, e as CreateDelegationParams, G as GenerateShareParams, az as ShareLink, b8 as SpaceInfo, I as ICapabilityKeyRegistry, y as ISharingService, D as DelegationManager, b as AccountDelegationQueryOptions, A as AccountDelegationPage, w as DelegationRevocationReceipt } from './recipient-types.schema-B2wH53_t.cjs';
6
+ export { c as AccountDelegationRecord, d as AccountDelegationResource, C as CapabilityEntry, bH as CapabilityKeyRegistry, bI as CapabilityKeyRegistryErrorCode, bJ as CapabilityKeyRegistryErrorCodes, f as CreateDelegationWasmParams, g as CreateDelegationWasmResult, h as CreateOwnerDelegationParams, i as DelegateReceivedShareParams, j as DelegatedResource, k as DelegatedShareAccess, l as DelegatedShareKey, n as DelegationApiResponse, o as DelegationChain, p as DelegationChainV2, q as DelegationDirection, a as DelegationError, r as DelegationErrorCode, s as DelegationErrorCodes, t as DelegationFilters, u as DelegationManagerConfig, v as DelegationRecord, R as DelegationResult, x as DelegationStatus, E as EncodedShareData, z as IngestOptions, J as JWK, K as KeyInfo, B as KeyProvider, F as KeyType, M as MAX_CONTENT_BYTES, H as MAX_SEALED_SHARE_CONTENT_BYTES, L as MAX_SHARE_ARTIFACT_BYTES, N as MAX_SHARE_CONTENT_BYTES, O as MemorySenderShareKeyStorage, P as MemorySenderShareRecordStorage, Q as MemoryShareCache, S as OwnerDelegationReceipt, T as OwnerShareAction, U as OwnerShareMatcher, V as OwnerSharePolicyRegistration, W as OwnerSharePolicyRegistrationReceipt, X as OwnerSharePolicyV2, Y as ReceiveOptions, Z as RegisterOwnerSharePolicyParams, _ as SHARE_DELIVERY_AUTHORIZATION_DOMAIN, $ as SenderShareKeyStorage, a0 as SenderShareRecord, a1 as SenderShareRecordStorage, a2 as SenderShareRevocationScope, a3 as SenderShareStore, a4 as ShareAccess, a5 as ShareAccessError, a6 as ShareAccessV2, a7 as ShareAction, a9 as ShareAddressedDelegationEnvelopeV2, aa as ShareAddressedDelegationEnvelopeV2Schema, ab as ShareAddressedDelegationRequestV2, ac as ShareAddressedDelegationRequestV2Schema, ad as ShareAddressedDelegationResponseV2, ae as ShareAddressedDelegationResponseV2Schema, af as ShareAddressedRecipientMatcher, ag as ShareArtifactInput, ah as ShareArtifactResult, ai as ShareArtifactV2, aj as ShareCache, ak as ShareCacheEntry, al as ShareCacheKey, am as ShareCacheMetadata, an as ShareCapabilityLike, ao as ShareConflict, ap as ShareContentMetadata, aq as ShareContentSource, ar as ShareDeliveryAuthorization, as as ShareDeliveryAuthorizationReceipt, at as ShareDeliveryAuthorizationRequest, au as ShareDetachedProof, av as ShareEnvelopeError, aw as ShareEnvelopeV2, ax as ShareExpiryBounds, ay as ShareKvContentSource, aA as ShareLinkData, aB as ShareLinkLocation, aC as ShareListEntry, aD as ShareListResult, aE as ShareNativeAction, aF as ShareNativeInvokeEnvelopeV1, aG as ShareNativeInvokeErrorResult, aH as ShareNativeInvokeInput, aI as ShareNativeInvokeResult, aJ as ShareNativeInvokeSuccessResult, aK as ShareNativeResponse, aL as ShareNativeResponseSchema, aM as SharePolicy, aN as SharePolicyBinding, aO as SharePolicySession, aP as SharePolicySessionV1, aQ as SharePolicySessionWireV1, aR as ShareReadInvocationV1, aS as ShareReadResult, aT as ShareRecipientClient, aU as ShareRecipientClientOptions, aW as ShareRecipientPolicy, aY as ShareRecipientResult, aZ as ShareRecipientTarget, a$ as ShareResource, b1 as ShareSaveOptions, b2 as ShareSchema, b3 as ShareSqlContentSource, b4 as ShareWireAction, b5 as SharingService, b6 as SharingServiceConfig, b7 as SignedDelegation, b9 as SpaceOwnership, bK as StoredDelegationChain, ba as ValidateShareDeliveryAuthorizationExpected, bb as VerifyShareEnvelopeOptions, bc as canonicalOwnerSharePolicy, bd as computeOwnerShareRegistrationCid, be as computeShareCid, bL as createCapabilityKeyRegistry, bf as createDelegatedShareKey, bg as createPolicyEnforcementDelegation, bh as createShareArtifact, bi as createShareArtifactAsync, bj as createSharePolicy, bk as createSharingService, bl as decryptShareBytesAsync, bm as encodeInlineShareUrl, bn as encodeShareArtifact, bo as encodeShareUrl, bp as encryptShareBytes, bq as encryptShareBytesAsync, br as intersectShareCapabilities, bs as isV2ShareLink, bt as normalizeShareActions, bu as normalizeShareRecipientTarget, bv as normalizeShareResource, bw as parseShareArtifact, bx as parseShareUrl, by as restoreDelegatedShareKey, bz as shareCapabilityAllows, bA as shareDeliveryTrustedKid, bB as signShareEnvelope, bC as validateOwnerSharePolicyRegistration, bD as validateOwnerSharePolicyRegistrationBytes, bE as validateShareDeliveryAuthorizationBytes, bF as verifyShareCid, bG as verifyShareEnvelope } from './recipient-types.schema-B2wH53_t.cjs';
5
7
  export { ACCOUNT_INDEX_SCHEMA, BOOTSTRAP_ALLOWLIST, BOOTSTRAP_DEFAULT_SPACE, BOOTSTRAP_ENCRYPTION_NETWORK_NAME, BOOTSTRAP_ENCRYPTION_NETWORK_RESOURCE_TEMPLATE, BOOTSTRAP_MANIFEST, BOOTSTRAP_PERSISTED_APPLICATION_MANIFESTS, BOOTSTRAP_PUBLIC_SPACE, BOOTSTRAP_SESSION_REQUESTS, BOOTSTRAP_SPACE_MANIFESTS, BOOTSTRAP_SPACE_NAMES, BootstrapAllowlistEntry, BootstrapAllowlistKind, BootstrapEncryptionNetworkStep, BootstrapManifest, BootstrapRawAbilityAllowlistEntry, BootstrapSchemaStep, BootstrapSeedApplicationsStep, BootstrapSeedSpacesStep, BootstrapSpaceDescriptor, BootstrapSpaceName, BootstrapSpaceStep, BootstrapStep, BootstrapStepKind, CAPABILITIES, CAPABILITY_REGISTRY, CapabilityRegistryEntry, CapabilityStatus, DUCKDB, ENCRYPTION, HOOKS, KV, SECRET_RECORDS_SCHEMA, SPACE, SQL, TINYCLOUD_ACCOUNT_SPACE_MANIFEST, TINYCLOUD_APPLICATIONS_SPACE_MANIFEST, TINYCLOUD_DEFAULT_SPACE_MANIFEST, TINYCLOUD_PUBLIC_SPACE_MANIFEST, TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST, bootstrapEncryptionNetworkId, bootstrapSpaceId, bootstrapSteps, composeBootstrapSpaceManifest } from '@tinycloud/bootstrap';
6
8
  export { E as ED25519_JCS_SIGNATURE_SUITE, b as EIP191_JCS_SIGNATURE_SUITE, J as JsonObject, c as POLICY_ENGINE_RECORD_SCHEMA, d as POLICY_SCHEMA, e as POLICY_STATUS_SCHEMA, a as Policy, P as PolicyEngineRecord, f as PolicyStatus, g as SignatureMaterialError, h as SignatureSuite, i as SignatureVerificationError, j as SignedObjectCanonicalizationError, k as SignedObjectDigestError, l as SignedObjectErrorCode, m as SignedObjectIdError, n as SignedObjectKind, o as SignedObjectMaterial, p as SignedObjectProfileError, q as SignedObjectSchemaError, r as SignedObjectSignature, S as SignedObjectSigner, s as SignedObjectVerificationResult, t as SignedPolicyObject, u as SigningKeyBindingError, v as UnsignedPolicy, U as UnsignedPolicyEngineRecord, w as UnsignedPolicyObject, x as UnsignedPolicyStatus, y as UnsupportedSignatureSuiteError, z as canonicalizeSignedObjectUnsigned, A as createAndSignPolicy, B as createAndSignPolicyEngineRecord, C as createAndSignPolicyStatus, D as createAndSignSignedObject, F as deriveSignedObjectMaterial, G as signedObjectIdFor, H as toSignedObjectError, I as validatePolicyEngineRecordSigned, K as validatePolicyEngineRecordSignedShape, L as validatePolicyEngineRecordUnsigned, M as validatePolicySigned, N as validatePolicySignedShape, O as validatePolicyStatusSigned, Q as validatePolicyStatusSignedShape, R as validatePolicyStatusUnsigned, T as validatePolicyUnsigned, V as verifyPolicy, W as verifyPolicyEngineRecord, X as verifyPolicyStatus, Y as verifySignedObject } from './signed-object-IMAm5a32.cjs';
7
9
  export { a as JsonValue, j as jcsCanonicalize, n as normalizeJson, s as serializeJcsJson } from './capability-BjzXwtNw.cjs';
@@ -986,18 +988,18 @@ declare const PersistedTinyCloudSessionSchema: z.ZodObject<{
986
988
  verificationMethod: z.ZodString;
987
989
  }, "strip", z.ZodTypeAny, {
988
990
  spaceId: string;
991
+ delegationCid: string;
989
992
  delegationHeader: {
990
993
  Authorization: string;
991
994
  };
992
- delegationCid: string;
993
995
  verificationMethod: string;
994
996
  spaces?: Record<string, string> | undefined;
995
997
  }, {
996
998
  spaceId: string;
999
+ delegationCid: string;
997
1000
  delegationHeader: {
998
1001
  Authorization: string;
999
1002
  };
1000
- delegationCid: string;
1001
1003
  verificationMethod: string;
1002
1004
  spaces?: Record<string, string> | undefined;
1003
1005
  }>;
@@ -1038,18 +1040,18 @@ declare const PersistedSessionDataSchema: z.ZodObject<{
1038
1040
  verificationMethod: z.ZodString;
1039
1041
  }, "strip", z.ZodTypeAny, {
1040
1042
  spaceId: string;
1043
+ delegationCid: string;
1041
1044
  delegationHeader: {
1042
1045
  Authorization: string;
1043
1046
  };
1044
- delegationCid: string;
1045
1047
  verificationMethod: string;
1046
1048
  spaces?: Record<string, string> | undefined;
1047
1049
  }, {
1048
1050
  spaceId: string;
1051
+ delegationCid: string;
1049
1052
  delegationHeader: {
1050
1053
  Authorization: string;
1051
1054
  };
1052
- delegationCid: string;
1053
1055
  verificationMethod: string;
1054
1056
  spaces?: Record<string, string> | undefined;
1055
1057
  }>>;
@@ -1095,10 +1097,10 @@ declare const PersistedSessionDataSchema: z.ZodObject<{
1095
1097
  } | undefined;
1096
1098
  tinycloudSession?: {
1097
1099
  spaceId: string;
1100
+ delegationCid: string;
1098
1101
  delegationHeader: {
1099
1102
  Authorization: string;
1100
1103
  };
1101
- delegationCid: string;
1102
1104
  verificationMethod: string;
1103
1105
  spaces?: Record<string, string> | undefined;
1104
1106
  } | undefined;
@@ -1118,10 +1120,10 @@ declare const PersistedSessionDataSchema: z.ZodObject<{
1118
1120
  } | undefined;
1119
1121
  tinycloudSession?: {
1120
1122
  spaceId: string;
1123
+ delegationCid: string;
1121
1124
  delegationHeader: {
1122
1125
  Authorization: string;
1123
1126
  };
1124
- delegationCid: string;
1125
1127
  verificationMethod: string;
1126
1128
  spaces?: Record<string, string> | undefined;
1127
1129
  } | undefined;
@@ -1169,14 +1171,14 @@ declare const TinyCloudSessionSchema: z.ZodObject<{
1169
1171
  siwe: string;
1170
1172
  signature: string;
1171
1173
  spaceId: string;
1174
+ jwk: {} & {
1175
+ [k: string]: unknown;
1176
+ };
1177
+ delegationCid: string;
1172
1178
  delegationHeader: {
1173
1179
  Authorization: string;
1174
1180
  };
1175
- delegationCid: string;
1176
1181
  verificationMethod: string;
1177
- jwk: {} & {
1178
- [k: string]: unknown;
1179
- };
1180
1182
  spaces?: Record<string, string> | undefined;
1181
1183
  }, {
1182
1184
  chainId: number;
@@ -1185,14 +1187,14 @@ declare const TinyCloudSessionSchema: z.ZodObject<{
1185
1187
  siwe: string;
1186
1188
  signature: string;
1187
1189
  spaceId: string;
1190
+ jwk: {} & {
1191
+ [k: string]: unknown;
1192
+ };
1193
+ delegationCid: string;
1188
1194
  delegationHeader: {
1189
1195
  Authorization: string;
1190
1196
  };
1191
- delegationCid: string;
1192
1197
  verificationMethod: string;
1193
- jwk: {} & {
1194
- [k: string]: unknown;
1195
- };
1196
1198
  spaces?: Record<string, string> | undefined;
1197
1199
  }>;
1198
1200
  type TinyCloudSession = z.infer<typeof TinyCloudSessionSchema>;
@@ -1223,2088 +1225,53 @@ interface ValidationError extends ServiceError {
1223
1225
  * }
1224
1226
  * ```
1225
1227
  */
1226
- declare function validatePersistedSessionData(data: unknown): Result$1<PersistedSessionData, ValidationError>;
1228
+ declare function validatePersistedSessionData(data: unknown): Result<PersistedSessionData, ValidationError>;
1227
1229
 
1228
1230
  /**
1229
1231
  * Session storage types and interfaces.
1230
1232
  *
1231
1233
  * Types are derived from Zod schemas in storage.schema.ts.
1232
1234
  *
1233
- * @packageDocumentation
1234
- */
1235
-
1236
- /**
1237
- * Session storage interface.
1238
- *
1239
- * Abstracts how sessions are persisted across different platforms.
1240
- * - Browser: localStorage
1241
- * - Node.js: file system or memory
1242
- */
1243
- interface ISessionStorage {
1244
- /**
1245
- * Save a session for an address.
1246
- * @param address - Ethereum address (key for lookup)
1247
- * @param session - Session data to persist
1248
- */
1249
- save(address: string, session: PersistedSessionData): Promise<void>;
1250
- /**
1251
- * Load a session for an address.
1252
- * @param address - Ethereum address
1253
- * @returns Session data or null if not found
1254
- */
1255
- load(address: string): Promise<PersistedSessionData | null>;
1256
- /**
1257
- * Clear a session for an address.
1258
- * @param address - Ethereum address
1259
- */
1260
- clear(address: string): Promise<void>;
1261
- /**
1262
- * Check if a session exists for an address (synchronous check).
1263
- * @param address - Ethereum address
1264
- * @returns true if session exists
1265
- */
1266
- exists(address: string): boolean;
1267
- /**
1268
- * Check if the storage backend is available.
1269
- * @returns true if storage can be used
1270
- */
1271
- isAvailable(): boolean;
1272
- }
1273
-
1274
- /**
1275
- * Zod schemas for delegation management types.
1276
- *
1277
- * These schemas provide runtime validation for delegation, capability key management,
1278
- * and sharing link functionality. Types are derived from schemas using z.infer<>.
1279
- *
1280
- * @packageDocumentation
1281
- */
1282
-
1283
- /**
1284
- * Result type pattern for delegation operations.
1285
- */
1286
- type Result<T, E = DelegationError> = {
1287
- ok: true;
1288
- data: T;
1289
- } | {
1290
- ok: false;
1291
- error: E;
1292
- };
1293
- /**
1294
- * JSON Web Key representation for cryptographic keys.
1295
- * Follows the JWK specification (RFC 7517).
1296
- */
1297
- declare const JWKSchema: z.ZodObject<{
1298
- /** Key type (e.g., "EC", "RSA", "OKP") */
1299
- kty: z.ZodString;
1300
- /** Curve for EC/OKP keys (e.g., "P-256", "Ed25519") */
1301
- crv: z.ZodOptional<z.ZodString>;
1302
- /** X coordinate for EC keys, public key for OKP */
1303
- x: z.ZodOptional<z.ZodString>;
1304
- /** Y coordinate for EC keys */
1305
- y: z.ZodOptional<z.ZodString>;
1306
- /** Private key value (d parameter) */
1307
- d: z.ZodOptional<z.ZodString>;
1308
- /** Public exponent for RSA keys */
1309
- e: z.ZodOptional<z.ZodString>;
1310
- /** Modulus for RSA keys */
1311
- n: z.ZodOptional<z.ZodString>;
1312
- /** Key ID */
1313
- kid: z.ZodOptional<z.ZodString>;
1314
- /** Algorithm */
1315
- alg: z.ZodOptional<z.ZodString>;
1316
- /** Key use (e.g., "sig", "enc") */
1317
- use: z.ZodOptional<z.ZodString>;
1318
- /** Key operations (e.g., ["sign", "verify"]) */
1319
- key_ops: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1320
- }, "strip", z.ZodTypeAny, {
1321
- kty: string;
1322
- crv?: string | undefined;
1323
- x?: string | undefined;
1324
- y?: string | undefined;
1325
- d?: string | undefined;
1326
- e?: string | undefined;
1327
- n?: string | undefined;
1328
- kid?: string | undefined;
1329
- alg?: string | undefined;
1330
- use?: string | undefined;
1331
- key_ops?: string[] | undefined;
1332
- }, {
1333
- kty: string;
1334
- crv?: string | undefined;
1335
- x?: string | undefined;
1336
- y?: string | undefined;
1337
- d?: string | undefined;
1338
- e?: string | undefined;
1339
- n?: string | undefined;
1340
- kid?: string | undefined;
1341
- alg?: string | undefined;
1342
- use?: string | undefined;
1343
- key_ops?: string[] | undefined;
1344
- }>;
1345
- type JWK = z.infer<typeof JWKSchema>;
1346
- /**
1347
- * Type of key in the capability registry.
1348
- */
1349
- declare const KeyTypeSchema: z.ZodEnum<["main", "session", "ingested"]>;
1350
- type KeyType = z.infer<typeof KeyTypeSchema>;
1351
- /**
1352
- * Information about a cryptographic key used for delegations.
1353
- */
1354
- declare const KeyInfoSchema: z.ZodObject<{
1355
- /** Unique identifier for this key */
1356
- id: z.ZodString;
1357
- /** DID associated with this key */
1358
- did: z.ZodString;
1359
- /** Type of key determining its authority level */
1360
- type: z.ZodEnum<["main", "session", "ingested"]>;
1361
- /** Private key in JWK format */
1362
- jwk: z.ZodOptional<z.ZodObject<{
1363
- /** Key type (e.g., "EC", "RSA", "OKP") */
1364
- kty: z.ZodString;
1365
- /** Curve for EC/OKP keys (e.g., "P-256", "Ed25519") */
1366
- crv: z.ZodOptional<z.ZodString>;
1367
- /** X coordinate for EC keys, public key for OKP */
1368
- x: z.ZodOptional<z.ZodString>;
1369
- /** Y coordinate for EC keys */
1370
- y: z.ZodOptional<z.ZodString>;
1371
- /** Private key value (d parameter) */
1372
- d: z.ZodOptional<z.ZodString>;
1373
- /** Public exponent for RSA keys */
1374
- e: z.ZodOptional<z.ZodString>;
1375
- /** Modulus for RSA keys */
1376
- n: z.ZodOptional<z.ZodString>;
1377
- /** Key ID */
1378
- kid: z.ZodOptional<z.ZodString>;
1379
- /** Algorithm */
1380
- alg: z.ZodOptional<z.ZodString>;
1381
- /** Key use (e.g., "sig", "enc") */
1382
- use: z.ZodOptional<z.ZodString>;
1383
- /** Key operations (e.g., ["sign", "verify"]) */
1384
- key_ops: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1385
- }, "strip", z.ZodTypeAny, {
1386
- kty: string;
1387
- crv?: string | undefined;
1388
- x?: string | undefined;
1389
- y?: string | undefined;
1390
- d?: string | undefined;
1391
- e?: string | undefined;
1392
- n?: string | undefined;
1393
- kid?: string | undefined;
1394
- alg?: string | undefined;
1395
- use?: string | undefined;
1396
- key_ops?: string[] | undefined;
1397
- }, {
1398
- kty: string;
1399
- crv?: string | undefined;
1400
- x?: string | undefined;
1401
- y?: string | undefined;
1402
- d?: string | undefined;
1403
- e?: string | undefined;
1404
- n?: string | undefined;
1405
- kid?: string | undefined;
1406
- alg?: string | undefined;
1407
- use?: string | undefined;
1408
- key_ops?: string[] | undefined;
1409
- }>>;
1410
- /** Priority for key selection (lower = higher priority) */
1411
- priority: z.ZodNumber;
1412
- }, "strip", z.ZodTypeAny, {
1413
- type: "session" | "main" | "ingested";
1414
- did: string;
1415
- id: string;
1416
- priority: number;
1417
- jwk?: {
1418
- kty: string;
1419
- crv?: string | undefined;
1420
- x?: string | undefined;
1421
- y?: string | undefined;
1422
- d?: string | undefined;
1423
- e?: string | undefined;
1424
- n?: string | undefined;
1425
- kid?: string | undefined;
1426
- alg?: string | undefined;
1427
- use?: string | undefined;
1428
- key_ops?: string[] | undefined;
1429
- } | undefined;
1430
- }, {
1431
- type: "session" | "main" | "ingested";
1432
- did: string;
1433
- id: string;
1434
- priority: number;
1435
- jwk?: {
1436
- kty: string;
1437
- crv?: string | undefined;
1438
- x?: string | undefined;
1439
- y?: string | undefined;
1440
- d?: string | undefined;
1441
- e?: string | undefined;
1442
- n?: string | undefined;
1443
- kid?: string | undefined;
1444
- alg?: string | undefined;
1445
- use?: string | undefined;
1446
- key_ops?: string[] | undefined;
1447
- } | undefined;
1448
- }>;
1449
- type KeyInfo = z.infer<typeof KeyInfoSchema>;
1450
- /**
1451
- * Error type for delegation operations.
1452
- */
1453
- declare const DelegationErrorSchema: z.ZodObject<{
1454
- /** Error code for programmatic handling */
1455
- code: z.ZodString;
1456
- /** Human-readable error message */
1457
- message: z.ZodString;
1458
- /** The service that produced the error */
1459
- service: z.ZodLiteral<"delegation">;
1460
- /** Original error if wrapping another error */
1461
- cause: z.ZodOptional<z.ZodType<Error, z.ZodTypeDef, Error>>;
1462
- /** Additional metadata about the error */
1463
- meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
1464
- }, "strip", z.ZodTypeAny, {
1465
- code: string;
1466
- message: string;
1467
- service: "delegation";
1468
- cause?: Error | undefined;
1469
- meta?: Record<string, unknown> | undefined;
1470
- }, {
1471
- code: string;
1472
- message: string;
1473
- service: "delegation";
1474
- cause?: Error | undefined;
1475
- meta?: Record<string, unknown> | undefined;
1476
- }>;
1477
- type DelegationError = z.infer<typeof DelegationErrorSchema>;
1478
- /**
1479
- * Error codes for delegation operations.
1480
- */
1481
- declare const DelegationErrorCodes: {
1482
- readonly AUTH_REQUIRED: "AUTH_REQUIRED";
1483
- readonly AUTH_EXPIRED: "AUTH_EXPIRED";
1484
- readonly NOT_INITIALIZED: "NOT_INITIALIZED";
1485
- readonly NOT_FOUND: "NOT_FOUND";
1486
- readonly REVOKED: "REVOKED";
1487
- readonly NETWORK_ERROR: "NETWORK_ERROR";
1488
- readonly TIMEOUT: "TIMEOUT";
1489
- readonly ABORTED: "ABORTED";
1490
- readonly INVALID_INPUT: "INVALID_INPUT";
1491
- readonly PERMISSION_DENIED: "PERMISSION_DENIED";
1492
- readonly CREATION_FAILED: "CREATION_FAILED";
1493
- readonly REVOCATION_FAILED: "REVOCATION_FAILED";
1494
- readonly INVALID_TOKEN: "INVALID_TOKEN";
1495
- readonly KV_SERVICE_UNAVAILABLE: "KV_SERVICE_UNAVAILABLE";
1496
- readonly DATA_FETCH_FAILED: "DATA_FETCH_FAILED";
1497
- readonly VALIDATION_ERROR: "VALIDATION_ERROR";
1498
- };
1499
- type DelegationErrorCode = (typeof DelegationErrorCodes)[keyof typeof DelegationErrorCodes];
1500
- /**
1501
- * Represents a delegation from one DID to another.
1502
- */
1503
- declare const DelegationSchema: z.ZodObject<{
1504
- /** Content identifier (CID) of the delegation */
1505
- cid: z.ZodString;
1506
- /** DID of the delegate (the party receiving the delegation) */
1507
- delegateDID: z.ZodString;
1508
- /** Space ID this delegation applies to */
1509
- spaceId: z.ZodString;
1510
- /** Resource path this delegation grants access to */
1511
- path: z.ZodString;
1512
- /** Actions this delegation authorizes */
1513
- actions: z.ZodArray<z.ZodString, "many">;
1514
- /** Exact ReCap caveats that constrain every action in this scope. */
1515
- caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
1516
- /** When this delegation expires (accepts Date or ISO string from JSON) */
1517
- expiry: z.ZodDate;
1518
- /** Whether this delegation has been revoked */
1519
- isRevoked: z.ZodBoolean;
1520
- /** DID of the delegator (the party granting the delegation) */
1521
- delegatorDID: z.ZodOptional<z.ZodString>;
1522
- /** When this delegation was created (accepts Date or ISO string from JSON) */
1523
- createdAt: z.ZodOptional<z.ZodDate>;
1524
- /** Parent delegation CID if this is a sub-delegation */
1525
- parentCid: z.ZodOptional<z.ZodString>;
1526
- /** Whether sub-delegation is allowed */
1527
- allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
1528
- /** Authorization header (UCAN bearer token) */
1529
- authHeader: z.ZodOptional<z.ZodString>;
1530
- }, "strip", z.ZodTypeAny, {
1531
- path: string;
1532
- expiry: Date;
1533
- actions: string[];
1534
- spaceId: string;
1535
- cid: string;
1536
- delegateDID: string;
1537
- isRevoked: boolean;
1538
- caveats?: Record<string, unknown>[] | undefined;
1539
- createdAt?: Date | undefined;
1540
- delegatorDID?: string | undefined;
1541
- parentCid?: string | undefined;
1542
- allowSubDelegation?: boolean | undefined;
1543
- authHeader?: string | undefined;
1544
- }, {
1545
- path: string;
1546
- expiry: Date;
1547
- actions: string[];
1548
- spaceId: string;
1549
- cid: string;
1550
- delegateDID: string;
1551
- isRevoked: boolean;
1552
- caveats?: Record<string, unknown>[] | undefined;
1553
- createdAt?: Date | undefined;
1554
- delegatorDID?: string | undefined;
1555
- parentCid?: string | undefined;
1556
- allowSubDelegation?: boolean | undefined;
1557
- authHeader?: string | undefined;
1558
- }>;
1559
- type Delegation = z.infer<typeof DelegationSchema>;
1560
- /** Node-confirmed lifecycle state for one delegation. */
1561
- declare const DelegationStatusSchema: z.ZodEffects<z.ZodObject<{
1562
- cid: z.ZodString;
1563
- status: z.ZodEnum<["active", "revoked", "expired", "unavailable", "not_found"]>;
1564
- exists: z.ZodBoolean;
1565
- active: z.ZodBoolean;
1566
- revoked: z.ZodBoolean;
1567
- expired: z.ZodBoolean;
1568
- }, "strict", z.ZodTypeAny, {
1569
- status: "active" | "revoked" | "expired" | "unavailable" | "not_found";
1570
- active: boolean;
1571
- revoked: boolean;
1572
- cid: string;
1573
- expired: boolean;
1574
- exists: boolean;
1575
- }, {
1576
- status: "active" | "revoked" | "expired" | "unavailable" | "not_found";
1577
- active: boolean;
1578
- revoked: boolean;
1579
- cid: string;
1580
- expired: boolean;
1581
- exists: boolean;
1582
- }>, {
1583
- status: "active" | "revoked" | "expired" | "unavailable" | "not_found";
1584
- active: boolean;
1585
- revoked: boolean;
1586
- cid: string;
1587
- expired: boolean;
1588
- exists: boolean;
1589
- }, {
1590
- status: "active" | "revoked" | "expired" | "unavailable" | "not_found";
1591
- active: boolean;
1592
- revoked: boolean;
1593
- cid: string;
1594
- expired: boolean;
1595
- exists: boolean;
1596
- }>;
1597
- type DelegationStatus = z.infer<typeof DelegationStatusSchema>;
1598
- declare const DelegationRevocationReceiptSchema: z.ZodObject<{
1599
- revoked: z.ZodLiteral<true>;
1600
- cid: z.ZodString;
1601
- }, "strict", z.ZodTypeAny, {
1602
- revoked: true;
1603
- cid: string;
1604
- }, {
1605
- revoked: true;
1606
- cid: string;
1607
- }>;
1608
- type DelegationRevocationReceipt = z.infer<typeof DelegationRevocationReceiptSchema>;
1609
- declare const AccountDelegationResourceSchema: z.ZodObject<{
1610
- resource: z.ZodString;
1611
- actions: z.ZodArray<z.ZodString, "many">;
1612
- caveats: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
1613
- }, "strict", z.ZodTypeAny, {
1614
- actions: string[];
1615
- caveats: Record<string, unknown>[];
1616
- resource: string;
1617
- }, {
1618
- actions: string[];
1619
- caveats: Record<string, unknown>[];
1620
- resource: string;
1621
- }>;
1622
- declare const AccountDelegationRecordSchema: z.ZodObject<{
1623
- cid: z.ZodString;
1624
- direction: z.ZodEnum<["granted", "received"]>;
1625
- delegatorDid: z.ZodString;
1626
- delegateDid: z.ZodString;
1627
- resources: z.ZodArray<z.ZodObject<{
1628
- resource: z.ZodString;
1629
- actions: z.ZodArray<z.ZodString, "many">;
1630
- caveats: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
1631
- }, "strict", z.ZodTypeAny, {
1632
- actions: string[];
1633
- caveats: Record<string, unknown>[];
1634
- resource: string;
1635
- }, {
1636
- actions: string[];
1637
- caveats: Record<string, unknown>[];
1638
- resource: string;
1639
- }>, "many">;
1640
- parents: z.ZodArray<z.ZodString, "many">;
1641
- issuedAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1642
- notBefore: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1643
- expiresAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1644
- status: z.ZodEnum<["active", "pending", "expired", "revoked", "ancestor_revoked"]>;
1645
- revokedAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>>;
1646
- revokedBy: z.ZodOptional<z.ZodString>;
1647
- revokedAncestorCid: z.ZodOptional<z.ZodString>;
1648
- }, "strict", z.ZodTypeAny, {
1649
- status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1650
- notBefore: Date | null;
1651
- resources: {
1652
- actions: string[];
1653
- caveats: Record<string, unknown>[];
1654
- resource: string;
1655
- }[];
1656
- expiresAt: Date | null;
1657
- issuedAt: Date | null;
1658
- cid: string;
1659
- direction: "received" | "granted";
1660
- delegatorDid: string;
1661
- delegateDid: string;
1662
- parents: string[];
1663
- revokedAt?: Date | null | undefined;
1664
- revokedBy?: string | undefined;
1665
- revokedAncestorCid?: string | undefined;
1666
- }, {
1667
- status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1668
- notBefore: string | null;
1669
- resources: {
1670
- actions: string[];
1671
- caveats: Record<string, unknown>[];
1672
- resource: string;
1673
- }[];
1674
- expiresAt: string | null;
1675
- issuedAt: string | null;
1676
- cid: string;
1677
- direction: "received" | "granted";
1678
- delegatorDid: string;
1679
- delegateDid: string;
1680
- parents: string[];
1681
- revokedAt?: string | null | undefined;
1682
- revokedBy?: string | undefined;
1683
- revokedAncestorCid?: string | undefined;
1684
- }>;
1685
- declare const AccountDelegationPageSchema: z.ZodObject<{
1686
- schemaVersion: z.ZodLiteral<2>;
1687
- items: z.ZodArray<z.ZodObject<{
1688
- cid: z.ZodString;
1689
- direction: z.ZodEnum<["granted", "received"]>;
1690
- delegatorDid: z.ZodString;
1691
- delegateDid: z.ZodString;
1692
- resources: z.ZodArray<z.ZodObject<{
1693
- resource: z.ZodString;
1694
- actions: z.ZodArray<z.ZodString, "many">;
1695
- caveats: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
1696
- }, "strict", z.ZodTypeAny, {
1697
- actions: string[];
1698
- caveats: Record<string, unknown>[];
1699
- resource: string;
1700
- }, {
1701
- actions: string[];
1702
- caveats: Record<string, unknown>[];
1703
- resource: string;
1704
- }>, "many">;
1705
- parents: z.ZodArray<z.ZodString, "many">;
1706
- issuedAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1707
- notBefore: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1708
- expiresAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1709
- status: z.ZodEnum<["active", "pending", "expired", "revoked", "ancestor_revoked"]>;
1710
- revokedAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>>;
1711
- revokedBy: z.ZodOptional<z.ZodString>;
1712
- revokedAncestorCid: z.ZodOptional<z.ZodString>;
1713
- }, "strict", z.ZodTypeAny, {
1714
- status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1715
- notBefore: Date | null;
1716
- resources: {
1717
- actions: string[];
1718
- caveats: Record<string, unknown>[];
1719
- resource: string;
1720
- }[];
1721
- expiresAt: Date | null;
1722
- issuedAt: Date | null;
1723
- cid: string;
1724
- direction: "received" | "granted";
1725
- delegatorDid: string;
1726
- delegateDid: string;
1727
- parents: string[];
1728
- revokedAt?: Date | null | undefined;
1729
- revokedBy?: string | undefined;
1730
- revokedAncestorCid?: string | undefined;
1731
- }, {
1732
- status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1733
- notBefore: string | null;
1734
- resources: {
1735
- actions: string[];
1736
- caveats: Record<string, unknown>[];
1737
- resource: string;
1738
- }[];
1739
- expiresAt: string | null;
1740
- issuedAt: string | null;
1741
- cid: string;
1742
- direction: "received" | "granted";
1743
- delegatorDid: string;
1744
- delegateDid: string;
1745
- parents: string[];
1746
- revokedAt?: string | null | undefined;
1747
- revokedBy?: string | undefined;
1748
- revokedAncestorCid?: string | undefined;
1749
- }>, "many">;
1750
- nextCursor: z.ZodOptional<z.ZodString>;
1751
- }, "strict", z.ZodTypeAny, {
1752
- schemaVersion: 2;
1753
- items: {
1754
- status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1755
- notBefore: Date | null;
1756
- resources: {
1757
- actions: string[];
1758
- caveats: Record<string, unknown>[];
1759
- resource: string;
1760
- }[];
1761
- expiresAt: Date | null;
1762
- issuedAt: Date | null;
1763
- cid: string;
1764
- direction: "received" | "granted";
1765
- delegatorDid: string;
1766
- delegateDid: string;
1767
- parents: string[];
1768
- revokedAt?: Date | null | undefined;
1769
- revokedBy?: string | undefined;
1770
- revokedAncestorCid?: string | undefined;
1771
- }[];
1772
- nextCursor?: string | undefined;
1773
- }, {
1774
- schemaVersion: 2;
1775
- items: {
1776
- status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1777
- notBefore: string | null;
1778
- resources: {
1779
- actions: string[];
1780
- caveats: Record<string, unknown>[];
1781
- resource: string;
1782
- }[];
1783
- expiresAt: string | null;
1784
- issuedAt: string | null;
1785
- cid: string;
1786
- direction: "received" | "granted";
1787
- delegatorDid: string;
1788
- delegateDid: string;
1789
- parents: string[];
1790
- revokedAt?: string | null | undefined;
1791
- revokedBy?: string | undefined;
1792
- revokedAncestorCid?: string | undefined;
1793
- }[];
1794
- nextCursor?: string | undefined;
1795
- }>;
1796
- type AccountDelegationResource = z.infer<typeof AccountDelegationResourceSchema>;
1797
- type AccountDelegationRecord = z.infer<typeof AccountDelegationRecordSchema>;
1798
- type AccountDelegationPage = z.infer<typeof AccountDelegationPageSchema>;
1799
- declare const AccountDelegationQueryOptionsSchema: z.ZodObject<{
1800
- direction: z.ZodOptional<z.ZodEnum<["granted", "received", "all"]>>;
1801
- status: z.ZodOptional<z.ZodEnum<["active", "pending", "expired", "revoked", "ancestor_revoked"]>>;
1802
- space: z.ZodOptional<z.ZodString>;
1803
- limit: z.ZodOptional<z.ZodNumber>;
1804
- cursor: z.ZodOptional<z.ZodString>;
1805
- }, "strict", z.ZodTypeAny, {
1806
- status?: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked" | undefined;
1807
- space?: string | undefined;
1808
- direction?: "received" | "all" | "granted" | undefined;
1809
- limit?: number | undefined;
1810
- cursor?: string | undefined;
1811
- }, {
1812
- status?: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked" | undefined;
1813
- space?: string | undefined;
1814
- direction?: "received" | "all" | "granted" | undefined;
1815
- limit?: number | undefined;
1816
- cursor?: string | undefined;
1817
- }>;
1818
- type AccountDelegationQueryOptions = z.infer<typeof AccountDelegationQueryOptionsSchema>;
1819
- /**
1820
- * Entry in the capability registry mapping a capability to available keys.
1821
- */
1822
- declare const CapabilityEntrySchema: z.ZodObject<{
1823
- /** Resource URI this capability applies to */
1824
- resource: z.ZodString;
1825
- /** Action this capability authorizes */
1826
- action: z.ZodString;
1827
- /** Keys that can exercise this capability, ordered by priority */
1828
- keys: z.ZodArray<z.ZodObject<{
1829
- /** Unique identifier for this key */
1830
- id: z.ZodString;
1831
- /** DID associated with this key */
1832
- did: z.ZodString;
1833
- /** Type of key determining its authority level */
1834
- type: z.ZodEnum<["main", "session", "ingested"]>;
1835
- /** Private key in JWK format */
1836
- jwk: z.ZodOptional<z.ZodObject<{
1837
- /** Key type (e.g., "EC", "RSA", "OKP") */
1838
- kty: z.ZodString;
1839
- /** Curve for EC/OKP keys (e.g., "P-256", "Ed25519") */
1840
- crv: z.ZodOptional<z.ZodString>;
1841
- /** X coordinate for EC keys, public key for OKP */
1842
- x: z.ZodOptional<z.ZodString>;
1843
- /** Y coordinate for EC keys */
1844
- y: z.ZodOptional<z.ZodString>;
1845
- /** Private key value (d parameter) */
1846
- d: z.ZodOptional<z.ZodString>;
1847
- /** Public exponent for RSA keys */
1848
- e: z.ZodOptional<z.ZodString>;
1849
- /** Modulus for RSA keys */
1850
- n: z.ZodOptional<z.ZodString>;
1851
- /** Key ID */
1852
- kid: z.ZodOptional<z.ZodString>;
1853
- /** Algorithm */
1854
- alg: z.ZodOptional<z.ZodString>;
1855
- /** Key use (e.g., "sig", "enc") */
1856
- use: z.ZodOptional<z.ZodString>;
1857
- /** Key operations (e.g., ["sign", "verify"]) */
1858
- key_ops: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1859
- }, "strip", z.ZodTypeAny, {
1860
- kty: string;
1861
- crv?: string | undefined;
1862
- x?: string | undefined;
1863
- y?: string | undefined;
1864
- d?: string | undefined;
1865
- e?: string | undefined;
1866
- n?: string | undefined;
1867
- kid?: string | undefined;
1868
- alg?: string | undefined;
1869
- use?: string | undefined;
1870
- key_ops?: string[] | undefined;
1871
- }, {
1872
- kty: string;
1873
- crv?: string | undefined;
1874
- x?: string | undefined;
1875
- y?: string | undefined;
1876
- d?: string | undefined;
1877
- e?: string | undefined;
1878
- n?: string | undefined;
1879
- kid?: string | undefined;
1880
- alg?: string | undefined;
1881
- use?: string | undefined;
1882
- key_ops?: string[] | undefined;
1883
- }>>;
1884
- /** Priority for key selection (lower = higher priority) */
1885
- priority: z.ZodNumber;
1886
- }, "strip", z.ZodTypeAny, {
1887
- type: "session" | "main" | "ingested";
1888
- did: string;
1889
- id: string;
1890
- priority: number;
1891
- jwk?: {
1892
- kty: string;
1893
- crv?: string | undefined;
1894
- x?: string | undefined;
1895
- y?: string | undefined;
1896
- d?: string | undefined;
1897
- e?: string | undefined;
1898
- n?: string | undefined;
1899
- kid?: string | undefined;
1900
- alg?: string | undefined;
1901
- use?: string | undefined;
1902
- key_ops?: string[] | undefined;
1903
- } | undefined;
1904
- }, {
1905
- type: "session" | "main" | "ingested";
1906
- did: string;
1907
- id: string;
1908
- priority: number;
1909
- jwk?: {
1910
- kty: string;
1911
- crv?: string | undefined;
1912
- x?: string | undefined;
1913
- y?: string | undefined;
1914
- d?: string | undefined;
1915
- e?: string | undefined;
1916
- n?: string | undefined;
1917
- kid?: string | undefined;
1918
- alg?: string | undefined;
1919
- use?: string | undefined;
1920
- key_ops?: string[] | undefined;
1921
- } | undefined;
1922
- }>, "many">;
1923
- /** The delegation that grants this capability */
1924
- delegation: z.ZodObject<{
1925
- /** Content identifier (CID) of the delegation */
1926
- cid: z.ZodString;
1927
- /** DID of the delegate (the party receiving the delegation) */
1928
- delegateDID: z.ZodString;
1929
- /** Space ID this delegation applies to */
1930
- spaceId: z.ZodString;
1931
- /** Resource path this delegation grants access to */
1932
- path: z.ZodString;
1933
- /** Actions this delegation authorizes */
1934
- actions: z.ZodArray<z.ZodString, "many">;
1935
- /** Exact ReCap caveats that constrain every action in this scope. */
1936
- caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
1937
- /** When this delegation expires (accepts Date or ISO string from JSON) */
1938
- expiry: z.ZodDate;
1939
- /** Whether this delegation has been revoked */
1940
- isRevoked: z.ZodBoolean;
1941
- /** DID of the delegator (the party granting the delegation) */
1942
- delegatorDID: z.ZodOptional<z.ZodString>;
1943
- /** When this delegation was created (accepts Date or ISO string from JSON) */
1944
- createdAt: z.ZodOptional<z.ZodDate>;
1945
- /** Parent delegation CID if this is a sub-delegation */
1946
- parentCid: z.ZodOptional<z.ZodString>;
1947
- /** Whether sub-delegation is allowed */
1948
- allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
1949
- /** Authorization header (UCAN bearer token) */
1950
- authHeader: z.ZodOptional<z.ZodString>;
1951
- }, "strip", z.ZodTypeAny, {
1952
- path: string;
1953
- expiry: Date;
1954
- actions: string[];
1955
- spaceId: string;
1956
- cid: string;
1957
- delegateDID: string;
1958
- isRevoked: boolean;
1959
- caveats?: Record<string, unknown>[] | undefined;
1960
- createdAt?: Date | undefined;
1961
- delegatorDID?: string | undefined;
1962
- parentCid?: string | undefined;
1963
- allowSubDelegation?: boolean | undefined;
1964
- authHeader?: string | undefined;
1965
- }, {
1966
- path: string;
1967
- expiry: Date;
1968
- actions: string[];
1969
- spaceId: string;
1970
- cid: string;
1971
- delegateDID: string;
1972
- isRevoked: boolean;
1973
- caveats?: Record<string, unknown>[] | undefined;
1974
- createdAt?: Date | undefined;
1975
- delegatorDID?: string | undefined;
1976
- parentCid?: string | undefined;
1977
- allowSubDelegation?: boolean | undefined;
1978
- authHeader?: string | undefined;
1979
- }>;
1980
- /** When this capability expires (accepts Date or ISO string from JSON) */
1981
- expiresAt: z.ZodOptional<z.ZodDate>;
1982
- }, "strip", z.ZodTypeAny, {
1983
- keys: {
1984
- type: "session" | "main" | "ingested";
1985
- did: string;
1986
- id: string;
1987
- priority: number;
1988
- jwk?: {
1989
- kty: string;
1990
- crv?: string | undefined;
1991
- x?: string | undefined;
1992
- y?: string | undefined;
1993
- d?: string | undefined;
1994
- e?: string | undefined;
1995
- n?: string | undefined;
1996
- kid?: string | undefined;
1997
- alg?: string | undefined;
1998
- use?: string | undefined;
1999
- key_ops?: string[] | undefined;
2000
- } | undefined;
2001
- }[];
2002
- delegation: {
2003
- path: string;
2004
- expiry: Date;
2005
- actions: string[];
2006
- spaceId: string;
2007
- cid: string;
2008
- delegateDID: string;
2009
- isRevoked: boolean;
2010
- caveats?: Record<string, unknown>[] | undefined;
2011
- createdAt?: Date | undefined;
2012
- delegatorDID?: string | undefined;
2013
- parentCid?: string | undefined;
2014
- allowSubDelegation?: boolean | undefined;
2015
- authHeader?: string | undefined;
2016
- };
2017
- resource: string;
2018
- action: string;
2019
- expiresAt?: Date | undefined;
2020
- }, {
2021
- keys: {
2022
- type: "session" | "main" | "ingested";
2023
- did: string;
2024
- id: string;
2025
- priority: number;
2026
- jwk?: {
2027
- kty: string;
2028
- crv?: string | undefined;
2029
- x?: string | undefined;
2030
- y?: string | undefined;
2031
- d?: string | undefined;
2032
- e?: string | undefined;
2033
- n?: string | undefined;
2034
- kid?: string | undefined;
2035
- alg?: string | undefined;
2036
- use?: string | undefined;
2037
- key_ops?: string[] | undefined;
2038
- } | undefined;
2039
- }[];
2040
- delegation: {
2041
- path: string;
2042
- expiry: Date;
2043
- actions: string[];
2044
- spaceId: string;
2045
- cid: string;
2046
- delegateDID: string;
2047
- isRevoked: boolean;
2048
- caveats?: Record<string, unknown>[] | undefined;
2049
- createdAt?: Date | undefined;
2050
- delegatorDID?: string | undefined;
2051
- parentCid?: string | undefined;
2052
- allowSubDelegation?: boolean | undefined;
2053
- authHeader?: string | undefined;
2054
- };
2055
- resource: string;
2056
- action: string;
2057
- expiresAt?: Date | undefined;
2058
- }>;
2059
- type CapabilityEntry = z.infer<typeof CapabilityEntrySchema>;
2060
- /**
2061
- * Persistent record of a delegation stored in the system.
2062
- */
2063
- declare const DelegationRecordSchema: z.ZodObject<{
2064
- /** Content identifier (CID) of the delegation */
2065
- cid: z.ZodString;
2066
- /** Space ID this delegation applies to */
2067
- spaceId: z.ZodString;
2068
- /** DID of the delegator (grantor) */
2069
- delegator: z.ZodString;
2070
- /** DID of the delegatee (recipient) */
2071
- delegatee: z.ZodString;
2072
- /** Key ID used to sign/exercise this delegation */
2073
- keyId: z.ZodOptional<z.ZodString>;
2074
- /** Resource path pattern this delegation grants access to */
2075
- path: z.ZodString;
2076
- /** Actions this delegation authorizes */
2077
- actions: z.ZodArray<z.ZodString, "many">;
2078
- /** When this delegation expires (accepts Date or ISO string from JSON) */
2079
- expiry: z.ZodOptional<z.ZodDate>;
2080
- /** When this delegation becomes valid (not before) (accepts Date or ISO string) */
2081
- notBefore: z.ZodOptional<z.ZodDate>;
2082
- /** Whether this delegation has been revoked */
2083
- isRevoked: z.ZodBoolean;
2084
- /** When this delegation was created (accepts Date or ISO string from JSON) */
2085
- createdAt: z.ZodDate;
2086
- /** Parent delegation CID if this is a sub-delegation */
2087
- parentCid: z.ZodOptional<z.ZodString>;
2088
- }, "strip", z.ZodTypeAny, {
2089
- path: string;
2090
- actions: string[];
2091
- createdAt: Date;
2092
- spaceId: string;
2093
- cid: string;
2094
- isRevoked: boolean;
2095
- delegator: string;
2096
- delegatee: string;
2097
- notBefore?: Date | undefined;
2098
- expiry?: Date | undefined;
2099
- parentCid?: string | undefined;
2100
- keyId?: string | undefined;
2101
- }, {
2102
- path: string;
2103
- actions: string[];
2104
- createdAt: Date;
2105
- spaceId: string;
2106
- cid: string;
2107
- isRevoked: boolean;
2108
- delegator: string;
2109
- delegatee: string;
2110
- notBefore?: Date | undefined;
2111
- expiry?: Date | undefined;
2112
- parentCid?: string | undefined;
2113
- keyId?: string | undefined;
2114
- }>;
2115
- type DelegationRecord = z.infer<typeof DelegationRecordSchema>;
2116
- /**
2117
- * Parameters for creating a new delegation.
2118
- */
2119
- declare const CreateDelegationParamsSchema: z.ZodObject<{
2120
- /** DID of the delegate (the party receiving the delegation) */
2121
- delegateDID: z.ZodString;
2122
- /** Resource path this delegation grants access to */
2123
- path: z.ZodString;
2124
- /** Actions to authorize */
2125
- actions: z.ZodArray<z.ZodString, "many">;
2126
- /** When this delegation expires (accepts Date or ISO string) */
2127
- expiry: z.ZodOptional<z.ZodDate>;
2128
- /** Whether to disable sub-delegation */
2129
- disableSubDelegation: z.ZodOptional<z.ZodBoolean>;
2130
- /** Optional statement for the SIWE message */
2131
- statement: z.ZodOptional<z.ZodString>;
2132
- }, "strip", z.ZodTypeAny, {
2133
- path: string;
2134
- actions: string[];
2135
- delegateDID: string;
2136
- statement?: string | undefined;
2137
- expiry?: Date | undefined;
2138
- disableSubDelegation?: boolean | undefined;
2139
- }, {
2140
- path: string;
2141
- actions: string[];
2142
- delegateDID: string;
2143
- statement?: string | undefined;
2144
- expiry?: Date | undefined;
2145
- disableSubDelegation?: boolean | undefined;
2146
- }>;
2147
- type CreateDelegationParams = z.infer<typeof CreateDelegationParamsSchema>;
2148
- /**
2149
- * A chain of delegations from root to leaf (array format).
2150
- */
2151
- declare const DelegationChainSchema: z.ZodArray<z.ZodObject<{
2152
- /** Content identifier (CID) of the delegation */
2153
- cid: z.ZodString;
2154
- /** DID of the delegate (the party receiving the delegation) */
2155
- delegateDID: z.ZodString;
2156
- /** Space ID this delegation applies to */
2157
- spaceId: z.ZodString;
2158
- /** Resource path this delegation grants access to */
2159
- path: z.ZodString;
2160
- /** Actions this delegation authorizes */
2161
- actions: z.ZodArray<z.ZodString, "many">;
2162
- /** Exact ReCap caveats that constrain every action in this scope. */
2163
- caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
2164
- /** When this delegation expires (accepts Date or ISO string from JSON) */
2165
- expiry: z.ZodDate;
2166
- /** Whether this delegation has been revoked */
2167
- isRevoked: z.ZodBoolean;
2168
- /** DID of the delegator (the party granting the delegation) */
2169
- delegatorDID: z.ZodOptional<z.ZodString>;
2170
- /** When this delegation was created (accepts Date or ISO string from JSON) */
2171
- createdAt: z.ZodOptional<z.ZodDate>;
2172
- /** Parent delegation CID if this is a sub-delegation */
2173
- parentCid: z.ZodOptional<z.ZodString>;
2174
- /** Whether sub-delegation is allowed */
2175
- allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
2176
- /** Authorization header (UCAN bearer token) */
2177
- authHeader: z.ZodOptional<z.ZodString>;
2178
- }, "strip", z.ZodTypeAny, {
2179
- path: string;
2180
- expiry: Date;
2181
- actions: string[];
2182
- spaceId: string;
2183
- cid: string;
2184
- delegateDID: string;
2185
- isRevoked: boolean;
2186
- caveats?: Record<string, unknown>[] | undefined;
2187
- createdAt?: Date | undefined;
2188
- delegatorDID?: string | undefined;
2189
- parentCid?: string | undefined;
2190
- allowSubDelegation?: boolean | undefined;
2191
- authHeader?: string | undefined;
2192
- }, {
2193
- path: string;
2194
- expiry: Date;
2195
- actions: string[];
2196
- spaceId: string;
2197
- cid: string;
2198
- delegateDID: string;
2199
- isRevoked: boolean;
2200
- caveats?: Record<string, unknown>[] | undefined;
2201
- createdAt?: Date | undefined;
2202
- delegatorDID?: string | undefined;
2203
- parentCid?: string | undefined;
2204
- allowSubDelegation?: boolean | undefined;
2205
- authHeader?: string | undefined;
2206
- }>, "many">;
2207
- type DelegationChain = z.infer<typeof DelegationChainSchema>;
2208
- /**
2209
- * Structured delegation chain (v2 spec).
2210
- */
2211
- declare const DelegationChainV2Schema: z.ZodObject<{
2212
- /** The root delegation from the original authority */
2213
- root: z.ZodObject<{
2214
- /** Content identifier (CID) of the delegation */
2215
- cid: z.ZodString;
2216
- /** DID of the delegate (the party receiving the delegation) */
2217
- delegateDID: z.ZodString;
2218
- /** Space ID this delegation applies to */
2219
- spaceId: z.ZodString;
2220
- /** Resource path this delegation grants access to */
2221
- path: z.ZodString;
2222
- /** Actions this delegation authorizes */
2223
- actions: z.ZodArray<z.ZodString, "many">;
2224
- /** Exact ReCap caveats that constrain every action in this scope. */
2225
- caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
2226
- /** When this delegation expires (accepts Date or ISO string from JSON) */
2227
- expiry: z.ZodDate;
2228
- /** Whether this delegation has been revoked */
2229
- isRevoked: z.ZodBoolean;
2230
- /** DID of the delegator (the party granting the delegation) */
2231
- delegatorDID: z.ZodOptional<z.ZodString>;
2232
- /** When this delegation was created (accepts Date or ISO string from JSON) */
2233
- createdAt: z.ZodOptional<z.ZodDate>;
2234
- /** Parent delegation CID if this is a sub-delegation */
2235
- parentCid: z.ZodOptional<z.ZodString>;
2236
- /** Whether sub-delegation is allowed */
2237
- allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
2238
- /** Authorization header (UCAN bearer token) */
2239
- authHeader: z.ZodOptional<z.ZodString>;
2240
- }, "strip", z.ZodTypeAny, {
2241
- path: string;
2242
- expiry: Date;
2243
- actions: string[];
2244
- spaceId: string;
2245
- cid: string;
2246
- delegateDID: string;
2247
- isRevoked: boolean;
2248
- caveats?: Record<string, unknown>[] | undefined;
2249
- createdAt?: Date | undefined;
2250
- delegatorDID?: string | undefined;
2251
- parentCid?: string | undefined;
2252
- allowSubDelegation?: boolean | undefined;
2253
- authHeader?: string | undefined;
2254
- }, {
2255
- path: string;
2256
- expiry: Date;
2257
- actions: string[];
2258
- spaceId: string;
2259
- cid: string;
2260
- delegateDID: string;
2261
- isRevoked: boolean;
2262
- caveats?: Record<string, unknown>[] | undefined;
2263
- createdAt?: Date | undefined;
2264
- delegatorDID?: string | undefined;
2265
- parentCid?: string | undefined;
2266
- allowSubDelegation?: boolean | undefined;
2267
- authHeader?: string | undefined;
2268
- }>;
2269
- /** Intermediate delegations in the chain (may be empty) */
2270
- chain: z.ZodArray<z.ZodObject<{
2271
- /** Content identifier (CID) of the delegation */
2272
- cid: z.ZodString;
2273
- /** DID of the delegate (the party receiving the delegation) */
2274
- delegateDID: z.ZodString;
2275
- /** Space ID this delegation applies to */
2276
- spaceId: z.ZodString;
2277
- /** Resource path this delegation grants access to */
2278
- path: z.ZodString;
2279
- /** Actions this delegation authorizes */
2280
- actions: z.ZodArray<z.ZodString, "many">;
2281
- /** Exact ReCap caveats that constrain every action in this scope. */
2282
- caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
2283
- /** When this delegation expires (accepts Date or ISO string from JSON) */
2284
- expiry: z.ZodDate;
2285
- /** Whether this delegation has been revoked */
2286
- isRevoked: z.ZodBoolean;
2287
- /** DID of the delegator (the party granting the delegation) */
2288
- delegatorDID: z.ZodOptional<z.ZodString>;
2289
- /** When this delegation was created (accepts Date or ISO string from JSON) */
2290
- createdAt: z.ZodOptional<z.ZodDate>;
2291
- /** Parent delegation CID if this is a sub-delegation */
2292
- parentCid: z.ZodOptional<z.ZodString>;
2293
- /** Whether sub-delegation is allowed */
2294
- allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
2295
- /** Authorization header (UCAN bearer token) */
2296
- authHeader: z.ZodOptional<z.ZodString>;
2297
- }, "strip", z.ZodTypeAny, {
2298
- path: string;
2299
- expiry: Date;
2300
- actions: string[];
2301
- spaceId: string;
2302
- cid: string;
2303
- delegateDID: string;
2304
- isRevoked: boolean;
2305
- caveats?: Record<string, unknown>[] | undefined;
2306
- createdAt?: Date | undefined;
2307
- delegatorDID?: string | undefined;
2308
- parentCid?: string | undefined;
2309
- allowSubDelegation?: boolean | undefined;
2310
- authHeader?: string | undefined;
2311
- }, {
2312
- path: string;
2313
- expiry: Date;
2314
- actions: string[];
2315
- spaceId: string;
2316
- cid: string;
2317
- delegateDID: string;
2318
- isRevoked: boolean;
2319
- caveats?: Record<string, unknown>[] | undefined;
2320
- createdAt?: Date | undefined;
2321
- delegatorDID?: string | undefined;
2322
- parentCid?: string | undefined;
2323
- allowSubDelegation?: boolean | undefined;
2324
- authHeader?: string | undefined;
2325
- }>, "many">;
2326
- /** The final delegation to the current user */
2327
- leaf: z.ZodObject<{
2328
- /** Content identifier (CID) of the delegation */
2329
- cid: z.ZodString;
2330
- /** DID of the delegate (the party receiving the delegation) */
2331
- delegateDID: z.ZodString;
2332
- /** Space ID this delegation applies to */
2333
- spaceId: z.ZodString;
2334
- /** Resource path this delegation grants access to */
2335
- path: z.ZodString;
2336
- /** Actions this delegation authorizes */
2337
- actions: z.ZodArray<z.ZodString, "many">;
2338
- /** Exact ReCap caveats that constrain every action in this scope. */
2339
- caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
2340
- /** When this delegation expires (accepts Date or ISO string from JSON) */
2341
- expiry: z.ZodDate;
2342
- /** Whether this delegation has been revoked */
2343
- isRevoked: z.ZodBoolean;
2344
- /** DID of the delegator (the party granting the delegation) */
2345
- delegatorDID: z.ZodOptional<z.ZodString>;
2346
- /** When this delegation was created (accepts Date or ISO string from JSON) */
2347
- createdAt: z.ZodOptional<z.ZodDate>;
2348
- /** Parent delegation CID if this is a sub-delegation */
2349
- parentCid: z.ZodOptional<z.ZodString>;
2350
- /** Whether sub-delegation is allowed */
2351
- allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
2352
- /** Authorization header (UCAN bearer token) */
2353
- authHeader: z.ZodOptional<z.ZodString>;
2354
- }, "strip", z.ZodTypeAny, {
2355
- path: string;
2356
- expiry: Date;
2357
- actions: string[];
2358
- spaceId: string;
2359
- cid: string;
2360
- delegateDID: string;
2361
- isRevoked: boolean;
2362
- caveats?: Record<string, unknown>[] | undefined;
2363
- createdAt?: Date | undefined;
2364
- delegatorDID?: string | undefined;
2365
- parentCid?: string | undefined;
2366
- allowSubDelegation?: boolean | undefined;
2367
- authHeader?: string | undefined;
2368
- }, {
2369
- path: string;
2370
- expiry: Date;
2371
- actions: string[];
2372
- spaceId: string;
2373
- cid: string;
2374
- delegateDID: string;
2375
- isRevoked: boolean;
2376
- caveats?: Record<string, unknown>[] | undefined;
2377
- createdAt?: Date | undefined;
2378
- delegatorDID?: string | undefined;
2379
- parentCid?: string | undefined;
2380
- allowSubDelegation?: boolean | undefined;
2381
- authHeader?: string | undefined;
2382
- }>;
2383
- }, "strip", z.ZodTypeAny, {
2384
- root: {
2385
- path: string;
2386
- expiry: Date;
2387
- actions: string[];
2388
- spaceId: string;
2389
- cid: string;
2390
- delegateDID: string;
2391
- isRevoked: boolean;
2392
- caveats?: Record<string, unknown>[] | undefined;
2393
- createdAt?: Date | undefined;
2394
- delegatorDID?: string | undefined;
2395
- parentCid?: string | undefined;
2396
- allowSubDelegation?: boolean | undefined;
2397
- authHeader?: string | undefined;
2398
- };
2399
- chain: {
2400
- path: string;
2401
- expiry: Date;
2402
- actions: string[];
2403
- spaceId: string;
2404
- cid: string;
2405
- delegateDID: string;
2406
- isRevoked: boolean;
2407
- caveats?: Record<string, unknown>[] | undefined;
2408
- createdAt?: Date | undefined;
2409
- delegatorDID?: string | undefined;
2410
- parentCid?: string | undefined;
2411
- allowSubDelegation?: boolean | undefined;
2412
- authHeader?: string | undefined;
2413
- }[];
2414
- leaf: {
2415
- path: string;
2416
- expiry: Date;
2417
- actions: string[];
2418
- spaceId: string;
2419
- cid: string;
2420
- delegateDID: string;
2421
- isRevoked: boolean;
2422
- caveats?: Record<string, unknown>[] | undefined;
2423
- createdAt?: Date | undefined;
2424
- delegatorDID?: string | undefined;
2425
- parentCid?: string | undefined;
2426
- allowSubDelegation?: boolean | undefined;
2427
- authHeader?: string | undefined;
2428
- };
2429
- }, {
2430
- root: {
2431
- path: string;
2432
- expiry: Date;
2433
- actions: string[];
2434
- spaceId: string;
2435
- cid: string;
2436
- delegateDID: string;
2437
- isRevoked: boolean;
2438
- caveats?: Record<string, unknown>[] | undefined;
2439
- createdAt?: Date | undefined;
2440
- delegatorDID?: string | undefined;
2441
- parentCid?: string | undefined;
2442
- allowSubDelegation?: boolean | undefined;
2443
- authHeader?: string | undefined;
2444
- };
2445
- chain: {
2446
- path: string;
2447
- expiry: Date;
2448
- actions: string[];
2449
- spaceId: string;
2450
- cid: string;
2451
- delegateDID: string;
2452
- isRevoked: boolean;
2453
- caveats?: Record<string, unknown>[] | undefined;
2454
- createdAt?: Date | undefined;
2455
- delegatorDID?: string | undefined;
2456
- parentCid?: string | undefined;
2457
- allowSubDelegation?: boolean | undefined;
2458
- authHeader?: string | undefined;
2459
- }[];
2460
- leaf: {
2461
- path: string;
2462
- expiry: Date;
2463
- actions: string[];
2464
- spaceId: string;
2465
- cid: string;
2466
- delegateDID: string;
2467
- isRevoked: boolean;
2468
- caveats?: Record<string, unknown>[] | undefined;
2469
- createdAt?: Date | undefined;
2470
- delegatorDID?: string | undefined;
2471
- parentCid?: string | undefined;
2472
- allowSubDelegation?: boolean | undefined;
2473
- authHeader?: string | undefined;
2474
- };
2475
- }>;
2476
- type DelegationChainV2 = z.infer<typeof DelegationChainV2Schema>;
2477
- /**
2478
- * Direction of delegation to filter by.
2479
- */
2480
- declare const DelegationDirectionSchema: z.ZodEnum<["granted", "received", "all"]>;
2481
- type DelegationDirection = z.infer<typeof DelegationDirectionSchema>;
2482
- /**
2483
- * Filters for listing delegations.
2484
- */
2485
- declare const DelegationFiltersSchema: z.ZodObject<{
2486
- /** Filter by delegation direction */
2487
- direction: z.ZodOptional<z.ZodEnum<["granted", "received", "all"]>>;
2488
- /** Filter by resource path pattern */
2489
- path: z.ZodOptional<z.ZodString>;
2490
- /** Filter by required actions */
2491
- actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2492
- /** Include revoked delegations */
2493
- includeRevoked: z.ZodOptional<z.ZodBoolean>;
2494
- /** Filter by delegator DID */
2495
- delegator: z.ZodOptional<z.ZodString>;
2496
- /** Filter by delegatee DID */
2497
- delegatee: z.ZodOptional<z.ZodString>;
2498
- /** Only include delegations valid at this time */
2499
- validAt: z.ZodOptional<z.ZodDate>;
2500
- /** Maximum number of results to return */
2501
- limit: z.ZodOptional<z.ZodNumber>;
2502
- /** Cursor for pagination */
2503
- cursor: z.ZodOptional<z.ZodString>;
2504
- }, "strip", z.ZodTypeAny, {
2505
- path?: string | undefined;
2506
- actions?: string[] | undefined;
2507
- direction?: "received" | "all" | "granted" | undefined;
2508
- limit?: number | undefined;
2509
- cursor?: string | undefined;
2510
- delegator?: string | undefined;
2511
- delegatee?: string | undefined;
2512
- includeRevoked?: boolean | undefined;
2513
- validAt?: Date | undefined;
2514
- }, {
2515
- path?: string | undefined;
2516
- actions?: string[] | undefined;
2517
- direction?: "received" | "all" | "granted" | undefined;
2518
- limit?: number | undefined;
2519
- cursor?: string | undefined;
2520
- delegator?: string | undefined;
2521
- delegatee?: string | undefined;
2522
- includeRevoked?: boolean | undefined;
2523
- validAt?: Date | undefined;
2524
- }>;
2525
- type DelegationFilters = z.infer<typeof DelegationFiltersSchema>;
2526
- /**
2527
- * Type of space ownership.
2528
- */
2529
- declare const SpaceOwnershipSchema: z.ZodEnum<["owned", "delegated"]>;
2530
- type SpaceOwnership = z.infer<typeof SpaceOwnershipSchema>;
2531
- /**
2532
- * Information about a space the user has access to.
2533
- */
2534
- declare const SpaceInfoSchema: z.ZodObject<{
2535
- /** Space identifier */
2536
- id: z.ZodString;
2537
- /** Human-readable name for the space */
2538
- name: z.ZodOptional<z.ZodString>;
2539
- /** DID of the space owner */
2540
- owner: z.ZodString;
2541
- /** Whether user owns or has delegated access */
2542
- type: z.ZodEnum<["owned", "delegated"]>;
2543
- /** Permissions the user has in this space */
2544
- permissions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2545
- /** When the access expires (for delegated spaces) */
2546
- expiresAt: z.ZodOptional<z.ZodDate>;
2547
- }, "strip", z.ZodTypeAny, {
2548
- type: "owned" | "delegated";
2549
- id: string;
2550
- owner: string;
2551
- name?: string | undefined;
2552
- expiresAt?: Date | undefined;
2553
- permissions?: string[] | undefined;
2554
- }, {
2555
- type: "owned" | "delegated";
2556
- id: string;
2557
- owner: string;
2558
- name?: string | undefined;
2559
- expiresAt?: Date | undefined;
2560
- permissions?: string[] | undefined;
2561
- }>;
2562
- type SpaceInfo = z.infer<typeof SpaceInfoSchema>;
2563
- /**
2564
- * Schema for encoding share link data.
2565
- */
2566
- declare const ShareSchemaSchema: z.ZodEnum<["base64", "compact", "ipfs"]>;
2567
- type ShareSchema = z.infer<typeof ShareSchemaSchema>;
2568
- /**
2569
- * A shareable link containing delegation credentials.
2570
- */
2571
- declare const ShareLinkSchema: z.ZodObject<{
2572
- /** Unique token identifying this share link */
2573
- token: z.ZodString;
2574
- /** Full URL for sharing */
2575
- url: z.ZodString;
2576
- /** The delegation this link grants access to */
2577
- delegation: z.ZodObject<{
2578
- /** Content identifier (CID) of the delegation */
2579
- cid: z.ZodString;
2580
- /** DID of the delegate (the party receiving the delegation) */
2581
- delegateDID: z.ZodString;
2582
- /** Space ID this delegation applies to */
2583
- spaceId: z.ZodString;
2584
- /** Resource path this delegation grants access to */
2585
- path: z.ZodString;
2586
- /** Actions this delegation authorizes */
2587
- actions: z.ZodArray<z.ZodString, "many">;
2588
- /** Exact ReCap caveats that constrain every action in this scope. */
2589
- caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
2590
- /** When this delegation expires (accepts Date or ISO string from JSON) */
2591
- expiry: z.ZodDate;
2592
- /** Whether this delegation has been revoked */
2593
- isRevoked: z.ZodBoolean;
2594
- /** DID of the delegator (the party granting the delegation) */
2595
- delegatorDID: z.ZodOptional<z.ZodString>;
2596
- /** When this delegation was created (accepts Date or ISO string from JSON) */
2597
- createdAt: z.ZodOptional<z.ZodDate>;
2598
- /** Parent delegation CID if this is a sub-delegation */
2599
- parentCid: z.ZodOptional<z.ZodString>;
2600
- /** Whether sub-delegation is allowed */
2601
- allowSubDelegation: z.ZodOptional<z.ZodBoolean>;
2602
- /** Authorization header (UCAN bearer token) */
2603
- authHeader: z.ZodOptional<z.ZodString>;
2604
- }, "strip", z.ZodTypeAny, {
2605
- path: string;
2606
- expiry: Date;
2607
- actions: string[];
2608
- spaceId: string;
2609
- cid: string;
2610
- delegateDID: string;
2611
- isRevoked: boolean;
2612
- caveats?: Record<string, unknown>[] | undefined;
2613
- createdAt?: Date | undefined;
2614
- delegatorDID?: string | undefined;
2615
- parentCid?: string | undefined;
2616
- allowSubDelegation?: boolean | undefined;
2617
- authHeader?: string | undefined;
2618
- }, {
2619
- path: string;
2620
- expiry: Date;
2621
- actions: string[];
2622
- spaceId: string;
2623
- cid: string;
2624
- delegateDID: string;
2625
- isRevoked: boolean;
2626
- caveats?: Record<string, unknown>[] | undefined;
2627
- createdAt?: Date | undefined;
2628
- delegatorDID?: string | undefined;
2629
- parentCid?: string | undefined;
2630
- allowSubDelegation?: boolean | undefined;
2631
- authHeader?: string | undefined;
2632
- }>;
2633
- /** Encoding schema used for the link */
2634
- schema: z.ZodEnum<["base64", "compact", "ipfs"]>;
2635
- /** When this share link expires */
2636
- expiresAt: z.ZodOptional<z.ZodDate>;
2637
- /** Human-readable description of what is being shared */
2638
- description: z.ZodOptional<z.ZodString>;
2639
- }, "strip", z.ZodTypeAny, {
2640
- delegation: {
2641
- path: string;
2642
- expiry: Date;
2643
- actions: string[];
2644
- spaceId: string;
2645
- cid: string;
2646
- delegateDID: string;
2647
- isRevoked: boolean;
2648
- caveats?: Record<string, unknown>[] | undefined;
2649
- createdAt?: Date | undefined;
2650
- delegatorDID?: string | undefined;
2651
- parentCid?: string | undefined;
2652
- allowSubDelegation?: boolean | undefined;
2653
- authHeader?: string | undefined;
2654
- };
2655
- schema: "base64" | "compact" | "ipfs";
2656
- url: string;
2657
- token: string;
2658
- description?: string | undefined;
2659
- expiresAt?: Date | undefined;
2660
- }, {
2661
- delegation: {
2662
- path: string;
2663
- expiry: Date;
2664
- actions: string[];
2665
- spaceId: string;
2666
- cid: string;
2667
- delegateDID: string;
2668
- isRevoked: boolean;
2669
- caveats?: Record<string, unknown>[] | undefined;
2670
- createdAt?: Date | undefined;
2671
- delegatorDID?: string | undefined;
2672
- parentCid?: string | undefined;
2673
- allowSubDelegation?: boolean | undefined;
2674
- authHeader?: string | undefined;
2675
- };
2676
- schema: "base64" | "compact" | "ipfs";
2677
- url: string;
2678
- token: string;
2679
- description?: string | undefined;
2680
- expiresAt?: Date | undefined;
2681
- }>;
2682
- type ShareLink = z.infer<typeof ShareLinkSchema>;
2683
- type ShareLinkData<T = unknown> = {
2684
- data: T;
2685
- delegation: Delegation;
2686
- spaceId: string;
2687
- path: string;
2688
- };
2689
- /**
2690
- * Options for ingesting an external delegation.
2691
- */
2692
- declare const IngestOptionsSchema: z.ZodObject<{
2693
- /** Whether to persist the delegation to storage */
2694
- persist: z.ZodOptional<z.ZodBoolean>;
2695
- /** Whether to validate the full delegation chain */
2696
- validateChain: z.ZodOptional<z.ZodBoolean>;
2697
- /** Name for the ingested key */
2698
- keyName: z.ZodOptional<z.ZodString>;
2699
- /** Whether to create a session key for this delegation */
2700
- createSessionKey: z.ZodOptional<z.ZodBoolean>;
2701
- /** Override the priority for the ingested key */
2702
- priority: z.ZodOptional<z.ZodNumber>;
2703
- }, "strip", z.ZodTypeAny, {
2704
- priority?: number | undefined;
2705
- persist?: boolean | undefined;
2706
- validateChain?: boolean | undefined;
2707
- keyName?: string | undefined;
2708
- createSessionKey?: boolean | undefined;
2709
- }, {
2710
- priority?: number | undefined;
2711
- persist?: boolean | undefined;
2712
- validateChain?: boolean | undefined;
2713
- keyName?: string | undefined;
2714
- createSessionKey?: boolean | undefined;
2715
- }>;
2716
- type IngestOptions = z.infer<typeof IngestOptionsSchema>;
2717
- /**
2718
- * Parameters for generating a share link.
2719
- */
2720
- declare const GenerateShareParamsSchema: z.ZodObject<{
2721
- /** Resource path to share */
2722
- path: z.ZodString;
2723
- /** Actions to authorize */
2724
- actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2725
- /** When the share link expires */
2726
- expiry: z.ZodOptional<z.ZodDate>;
2727
- /** Encoding schema for the link */
2728
- schema: z.ZodOptional<z.ZodEnum<["base64", "compact", "ipfs"]>>;
2729
- /** Human-readable description */
2730
- description: z.ZodOptional<z.ZodString>;
2731
- /** Base URL for the share link */
2732
- baseUrl: z.ZodOptional<z.ZodString>;
2733
- }, "strip", z.ZodTypeAny, {
2734
- path: string;
2735
- schema?: "base64" | "compact" | "ipfs" | undefined;
2736
- expiry?: Date | undefined;
2737
- description?: string | undefined;
2738
- actions?: string[] | undefined;
2739
- baseUrl?: string | undefined;
2740
- }, {
2741
- path: string;
2742
- schema?: "base64" | "compact" | "ipfs" | undefined;
2743
- expiry?: Date | undefined;
2744
- description?: string | undefined;
2745
- actions?: string[] | undefined;
2746
- baseUrl?: string | undefined;
2747
- }>;
2748
- type GenerateShareParams = z.infer<typeof GenerateShareParamsSchema>;
2749
- /**
2750
- * Configuration for DelegationManager.
2751
- * Note: ServiceSession, InvokeFunction, and FetchFunction are external types.
2752
- */
2753
- declare const DelegationManagerConfigSchema: z.ZodObject<{
2754
- /** TinyCloud host URLs */
2755
- hosts: z.ZodArray<z.ZodString, "many">;
2756
- /** Account space used by account-wide delegation history queries */
2757
- accountSpaceId: z.ZodOptional<z.ZodString>;
2758
- /** Active session for authentication */
2759
- session: z.ZodEffects<z.ZodUnknown, ServiceSession, unknown>;
2760
- /** Platform-specific invoke function */
2761
- invoke: z.ZodEffects<z.ZodUnknown, InvokeFunction, unknown>;
2762
- /** Platform-specific invoke function for raw resource URIs */
2763
- invokeAny: z.ZodOptional<z.ZodEffects<z.ZodUnknown, InvokeAnyFunction, unknown>>;
2764
- /** Optional custom fetch implementation */
2765
- fetch: z.ZodOptional<z.ZodEffects<z.ZodUnknown, FetchFunction, unknown>>;
2766
- }, "strip", z.ZodTypeAny, {
2767
- session: ServiceSession;
2768
- hosts: string[];
2769
- invoke: InvokeFunction;
2770
- invokeAny?: InvokeAnyFunction | undefined;
2771
- accountSpaceId?: string | undefined;
2772
- fetch?: FetchFunction | undefined;
2773
- }, {
2774
- hosts: string[];
2775
- invokeAny?: unknown;
2776
- session?: unknown;
2777
- accountSpaceId?: string | undefined;
2778
- invoke?: unknown;
2779
- fetch?: unknown;
2780
- }>;
2781
- type DelegationManagerConfig = z.infer<typeof DelegationManagerConfigSchema>;
2782
- /**
2783
- * Provider interface for cryptographic key operations.
2784
- */
2785
- declare const KeyProviderSchema: z.ZodObject<{
2786
- /** Generate a new session key, returns key ID */
2787
- createSessionKey: z.ZodEffects<z.ZodUnknown, (name: string) => Promise<string>, unknown>;
2788
- /** Get JWK for a key */
2789
- getJWK: z.ZodEffects<z.ZodUnknown, (keyId: string) => object, unknown>;
2790
- /** Get DID for a key */
2791
- getDID: z.ZodEffects<z.ZodUnknown, (keyId: string) => Promise<string>, unknown>;
2792
- }, "strip", z.ZodTypeAny, {
2793
- createSessionKey: (name: string) => Promise<string>;
2794
- getJWK: (keyId: string) => object;
2795
- getDID: (keyId: string) => Promise<string>;
2796
- }, {
2797
- createSessionKey?: unknown;
2798
- getJWK?: unknown;
2799
- getDID?: unknown;
2800
- }>;
2801
- type KeyProvider = z.infer<typeof KeyProviderSchema>;
2802
- /**
2803
- * Response from the delegation API.
2804
- */
2805
- declare const DelegationApiResponseSchema: z.ZodObject<{
2806
- /** SIWE message content */
2807
- siwe: z.ZodString;
2808
- /** Signature of the SIWE message */
2809
- signature: z.ZodString;
2810
- /** Delegation version */
2811
- version: z.ZodNumber;
2812
- /** CID of the created delegation */
2813
- cid: z.ZodOptional<z.ZodString>;
2814
- }, "strip", z.ZodTypeAny, {
2815
- siwe: string;
2816
- signature: string;
2817
- version: number;
2818
- cid?: string | undefined;
2819
- }, {
2820
- siwe: string;
2821
- signature: string;
2822
- version: number;
2823
- cid?: string | undefined;
2824
- }>;
2825
- type DelegationApiResponse = z.infer<typeof DelegationApiResponseSchema>;
2826
- /**
2827
- * A single (service, space, path, actions) entry inside a
2828
- * createDelegation WASM result.
2829
- *
2830
- * Mirrors the Rust `DelegatedResource` struct in
2831
- * `tinycloud-sdk-wasm/src/session.rs`. Field names match the manifest
2832
- * {@link PermissionEntry} shape so callers can reconstruct what they sent
2833
- * without having to re-parse the UCAN.
2834
- *
2835
- * `service` is the short form (e.g. `"kv"`, `"sql"`) as returned by the
2836
- * Rust layer. The SDK layer translates to the long form
2837
- * (`"tinycloud.kv"`) when comparing against manifests.
2838
- */
2839
- declare const DelegatedResourceSchema: z.ZodObject<{
2840
- /** Short-form service name, e.g. "kv", "sql", "duckdb", "capabilities", "hooks". */
2841
- service: z.ZodString;
2842
- /** Full space id string, e.g. "tinycloud:pkh:eip155:1:0x....:default". */
2843
- space: z.ZodString;
2844
- /** Resource path; empty string when the resource URI had no path segment. */
2845
- path: z.ZodString;
2846
- /** Full-URN ability strings, e.g. ["tinycloud.kv/get", "tinycloud.kv/put"]. */
2847
- actions: z.ZodArray<z.ZodString, "many">;
2848
- /** Exact ReCap caveats that constrain every action in this scope. */
2849
- caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
2850
- }, "strip", z.ZodTypeAny, {
2851
- path: string;
2852
- actions: string[];
2853
- space: string;
2854
- service: string;
2855
- caveats?: Record<string, unknown>[] | undefined;
2856
- }, {
2857
- path: string;
2858
- actions: string[];
2859
- space: string;
2860
- service: string;
2861
- caveats?: Record<string, unknown>[] | undefined;
2862
- }>;
2863
- type DelegatedResource = z.infer<typeof DelegatedResourceSchema>;
2864
- /**
2865
- * Input parameters for the createDelegation WASM function.
2866
- *
2867
- * A single call may encode multiple `(service, path, actions)` entries
2868
- * via the `abilities` map — the underlying UCAN will contain one
2869
- * attenuation entry per `(service, path)` pair, all signed by the same
2870
- * session key in one blob.
2871
- *
2872
- * The `abilities` shape is identical to what `prepareSession` accepts
2873
- * (`Record<shortService, Record<path, actionURNs[]>>`), so manifest
2874
- * resolution can feed both sides from one data structure.
2875
- */
2876
- declare const CreateDelegationWasmParamsSchema: z.ZodObject<{
2877
- /** The session containing delegation credentials */
2878
- session: z.ZodEffects<z.ZodUnknown, ServiceSession, unknown>;
2879
- /** DID of the delegate */
2880
- delegateDID: z.ZodString;
2881
- /** Space ID this delegation applies to */
2882
- spaceId: z.ZodString;
2883
- /**
2884
- * Multi-resource abilities map: short-service → path → full-URN actions.
2885
- * Matches the shape accepted by `prepareSession`.
2886
- *
2887
- * Example:
2888
- * ```
2889
- * {
2890
- * kv: {
2891
- * "com.listen.app/": ["tinycloud.kv/get", "tinycloud.kv/put"]
2892
- * },
2893
- * sql: {
2894
- * "com.listen.app/data.sqlite": ["tinycloud.sql/read"]
2895
- * }
2896
- * }
2897
- * ```
2898
- */
2899
- abilities: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
2900
- /** Expiration time in seconds since Unix epoch */
2901
- expirationSecs: z.ZodNumber;
2902
- /** Optional not-before time in seconds since Unix epoch */
2903
- notBeforeSecs: z.ZodOptional<z.ZodNumber>;
2904
- }, "strip", z.ZodTypeAny, {
2905
- spaceId: string;
2906
- session: ServiceSession;
2907
- delegateDID: string;
2908
- abilities: Record<string, Record<string, string[]>>;
2909
- expirationSecs: number;
2910
- notBeforeSecs?: number | undefined;
2911
- }, {
2912
- spaceId: string;
2913
- delegateDID: string;
2914
- abilities: Record<string, Record<string, string[]>>;
2915
- expirationSecs: number;
2916
- session?: unknown;
2917
- notBeforeSecs?: number | undefined;
2918
- }>;
2919
- type CreateDelegationWasmParams = z.infer<typeof CreateDelegationWasmParamsSchema>;
2920
- /**
2921
- * Result from the createDelegation WASM function.
2922
- *
2923
- * A single UCAN may cover multiple resources. The `resources` array
2924
- * describes every `(service, space, path, actions)` entry granted, in
2925
- * deterministic (service, path) lexicographic order (the Rust side sorts
2926
- * the HashMap entries before signing).
2927
- */
2928
- declare const CreateDelegationWasmResultSchema: z.ZodObject<{
2929
- /** Base64url-encoded UCAN delegation */
2930
- delegation: z.ZodString;
2931
- /** CID of the delegation */
2932
- cid: z.ZodString;
2933
- /** DID of the delegate */
2934
- delegateDID: z.ZodString;
2935
- /** Expiration time */
2936
- expiry: z.ZodDate;
2937
- /**
2938
- * All (service, space, path, actions) entries granted by this delegation.
2939
- * Always non-empty on success.
2940
- */
2941
- resources: z.ZodArray<z.ZodObject<{
2942
- /** Short-form service name, e.g. "kv", "sql", "duckdb", "capabilities", "hooks". */
2943
- service: z.ZodString;
2944
- /** Full space id string, e.g. "tinycloud:pkh:eip155:1:0x....:default". */
2945
- space: z.ZodString;
2946
- /** Resource path; empty string when the resource URI had no path segment. */
2947
- path: z.ZodString;
2948
- /** Full-URN ability strings, e.g. ["tinycloud.kv/get", "tinycloud.kv/put"]. */
2949
- actions: z.ZodArray<z.ZodString, "many">;
2950
- /** Exact ReCap caveats that constrain every action in this scope. */
2951
- caveats: z.ZodOptional<z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">>;
2952
- }, "strip", z.ZodTypeAny, {
2953
- path: string;
2954
- actions: string[];
2955
- space: string;
2956
- service: string;
2957
- caveats?: Record<string, unknown>[] | undefined;
2958
- }, {
2959
- path: string;
2960
- actions: string[];
2961
- space: string;
2962
- service: string;
2963
- caveats?: Record<string, unknown>[] | undefined;
2964
- }>, "many">;
2965
- }, "strip", z.ZodTypeAny, {
2966
- resources: {
2967
- path: string;
2968
- actions: string[];
2969
- space: string;
2970
- service: string;
2971
- caveats?: Record<string, unknown>[] | undefined;
2972
- }[];
2973
- delegation: string;
2974
- expiry: Date;
2975
- cid: string;
2976
- delegateDID: string;
2977
- }, {
2978
- resources: {
2979
- path: string;
2980
- actions: string[];
2981
- space: string;
2982
- service: string;
2983
- caveats?: Record<string, unknown>[] | undefined;
2984
- }[];
2985
- delegation: string;
2986
- expiry: Date;
2987
- cid: string;
2988
- delegateDID: string;
2989
- }>;
2990
- type CreateDelegationWasmResult = z.infer<typeof CreateDelegationWasmResultSchema>;
2991
-
2992
- /**
2993
- * CapabilityKeyRegistry - Tracks keys and their capabilities for automatic key selection.
2994
- *
2995
- * The registry maintains mappings between:
2996
- * - Keys and their associated delegations
2997
- * - Capabilities (resource/action pairs) and the keys that can exercise them
2998
- *
2999
- * This enables automatic key selection when performing operations, choosing
3000
- * the most appropriate key based on priority and validity.
3001
- *
3002
- * @packageDocumentation
3003
- */
3004
-
3005
- /**
3006
- * Error codes specific to CapabilityKeyRegistry operations.
3007
- */
3008
- declare const CapabilityKeyRegistryErrorCodes: {
3009
- /** Key not found in registry */
3010
- readonly KEY_NOT_FOUND: "KEY_NOT_FOUND";
3011
- /** No key available for the requested capability */
3012
- readonly NO_CAPABLE_KEY: "NO_CAPABLE_KEY";
3013
- /** Delegation has expired */
3014
- readonly DELEGATION_EXPIRED: "DELEGATION_EXPIRED";
3015
- /** Delegation has been revoked */
3016
- readonly DELEGATION_REVOKED: "DELEGATION_REVOKED";
3017
- /** Invalid delegation data */
3018
- readonly INVALID_DELEGATION: "INVALID_DELEGATION";
3019
- /** Key already registered */
3020
- readonly KEY_EXISTS: "KEY_EXISTS";
3021
- };
3022
- type CapabilityKeyRegistryErrorCode = (typeof CapabilityKeyRegistryErrorCodes)[keyof typeof CapabilityKeyRegistryErrorCodes];
3023
- /**
3024
- * Stored delegation with chain information.
3025
- */
3026
- interface StoredDelegationChain {
3027
- /** The delegation itself */
3028
- delegation: Delegation;
3029
- /** Parent delegation CID if this is a sub-delegation */
3030
- parentCid?: string;
3031
- /** Key ID used to sign/exercise this delegation */
3032
- keyId: string;
3033
- /** When this was stored */
3034
- storedAt: Date;
3035
- }
3036
- /**
3037
- * Interface for the CapabilityKeyRegistry.
3038
- *
3039
- * Tracks keys and their capabilities for automatic key selection.
3040
- */
3041
- interface ICapabilityKeyRegistry {
3042
- /**
3043
- * Register a key with its associated delegations.
3044
- *
3045
- * @param key - Key information
3046
- * @param delegations - Delegations granted to this key
3047
- */
3048
- registerKey(key: KeyInfo, delegations: Delegation[]): void;
3049
- /**
3050
- * Remove a key and all its associated delegations.
3051
- *
3052
- * @param keyId - The key ID to remove
3053
- */
3054
- removeKey(keyId: string): void;
3055
- /**
3056
- * Get a key that can exercise the specified capability.
3057
- *
3058
- * Uses the key selection algorithm:
3059
- * 1. Filter keys that have the required capability
3060
- * 2. Check delegation validity (not expired, not revoked)
3061
- * 3. Sort by priority (session=0, main=1, ingested=2)
3062
- * 4. Return highest priority valid key
3063
- *
3064
- * @param resource - Resource URI (e.g., "tinycloud://space-id/kv/my-data")
3065
- * @param action - Action to perform (e.g., "tinycloud.kv/get")
3066
- * @returns The best matching key, or null if none available
3067
- */
3068
- getKeyForCapability(resource: string, action: string): KeyInfo | null;
3069
- /**
3070
- * Get all registered capabilities.
3071
- *
3072
- * @returns All capability entries in the registry
3073
- */
3074
- getAllCapabilities(): CapabilityEntry[];
3075
- /**
3076
- * Get all delegations for a specific key.
3077
- *
3078
- * @param keyId - The key ID
3079
- * @returns Array of delegations for this key
3080
- */
3081
- getDelegationsForKey(keyId: string): Delegation[];
3082
- /**
3083
- * Ingest a key and delegation from an external source (e.g., sharing link).
3084
- *
3085
- * @param key - Key information to ingest
3086
- * @param delegation - Delegation to associate with the key
3087
- * @param options - Ingestion options
3088
- */
3089
- ingestKey(key: KeyInfo, delegation: Delegation, options?: IngestOptions): void;
3090
- /**
3091
- * Check if a delegation is currently valid.
3092
- *
3093
- * @param delegation - The delegation to check
3094
- * @returns true if valid, false if expired or revoked
3095
- */
3096
- isDelegationValid(delegation: Delegation): boolean;
3097
- /**
3098
- * Get a key by its ID.
3099
- *
3100
- * @param keyId - The key ID
3101
- * @returns The key info, or undefined if not found
3102
- */
3103
- getKey(keyId: string): KeyInfo | undefined;
3104
- /**
3105
- * Get all registered keys.
3106
- *
3107
- * @returns Array of all registered keys
3108
- */
3109
- getAllKeys(): KeyInfo[];
3110
- /**
3111
- * Clear all registered keys and delegations.
3112
- */
3113
- clear(): void;
3114
- /**
3115
- * Revoke a delegation by CID.
3116
- *
3117
- * @param cid - The delegation CID to revoke
3118
- * @returns Result indicating success or failure
3119
- */
3120
- revokeDelegation(cid: string): Result$1<void, ServiceError>;
3121
- /**
3122
- * Find capabilities that match a resource path pattern.
3123
- *
3124
- * @param resourcePattern - Resource pattern (supports wildcards)
3125
- * @param action - Optional action filter
3126
- * @returns Matching capability entries
3127
- */
3128
- findCapabilities(resourcePattern: string, action?: string): CapabilityEntry[];
3129
- }
3130
- /**
3131
- * CapabilityKeyRegistry - Tracks keys and their capabilities for automatic key selection.
3132
- *
3133
- * @example
3134
- * ```typescript
3135
- * const registry = new CapabilityKeyRegistry();
3136
- *
3137
- * // Register a session key with its delegations
3138
- * registry.registerKey(sessionKey, [rootDelegation]);
3139
- *
3140
- * // Get the best key for an operation
3141
- * const key = registry.getKeyForCapability(
3142
- * "tinycloud://my-space/kv/data",
3143
- * "tinycloud.kv/get"
3144
- * );
3145
- *
3146
- * if (key) {
3147
- * // Use this key for the operation
3148
- * console.log("Using key:", key.id);
3149
- * }
3150
- * ```
3151
- */
3152
- declare class CapabilityKeyRegistry implements ICapabilityKeyRegistry {
3153
- /**
3154
- * Registry of all keys indexed by ID.
3155
- */
3156
- private keys;
3157
- /**
3158
- * Delegation storage.
3159
- */
3160
- private store;
3161
- /**
3162
- * Register a key with its associated delegations.
3163
- *
3164
- * @param key - Key information
3165
- * @param delegations - Delegations granted to this key
3166
- */
3167
- registerKey(key: KeyInfo, delegations: Delegation[]): void;
3168
- /**
3169
- * Remove a key and all its associated delegations.
3170
- *
3171
- * @param keyId - The key ID to remove
3172
- */
3173
- removeKey(keyId: string): void;
3174
- /**
3175
- * Get a key that can exercise the specified capability.
3176
- *
3177
- * Key selection algorithm:
3178
- * 1. Filter keys that have the required capability
3179
- * 2. Check delegation validity (not expired, not revoked)
3180
- * 3. Sort by priority (session=0, main=1, ingested=2)
3181
- * 4. Return highest priority valid key
3182
- *
3183
- * @param resource - Resource URI
3184
- * @param action - Action to perform
3185
- * @returns The best matching key, or null if none available
3186
- */
3187
- getKeyForCapability(resource: string, action: string): KeyInfo | null;
3188
- /**
3189
- * Get all registered capabilities.
3190
- *
3191
- * @returns All capability entries in the registry
3192
- */
3193
- getAllCapabilities(): CapabilityEntry[];
3194
- /**
3195
- * Get all delegations for a specific key.
3196
- *
3197
- * @param keyId - The key ID
3198
- * @returns Array of delegations for this key
3199
- */
3200
- getDelegationsForKey(keyId: string): Delegation[];
3201
- /**
3202
- * Ingest a key and delegation from an external source.
3203
- *
3204
- * @param key - Key information to ingest
3205
- * @param delegation - Delegation to associate with the key
3206
- * @param options - Ingestion options
3207
- */
3208
- ingestKey(key: KeyInfo, delegation: Delegation, options?: IngestOptions): void;
3209
- /**
3210
- * Check if a delegation is currently valid.
3211
- *
3212
- * @param delegation - The delegation to check
3213
- * @returns true if valid, false if expired or revoked
3214
- */
3215
- isDelegationValid(delegation: Delegation): boolean;
3216
- /**
3217
- * Get a key by its ID.
3218
- *
3219
- * @param keyId - The key ID
3220
- * @returns The key info, or undefined if not found
3221
- */
3222
- getKey(keyId: string): KeyInfo | undefined;
3223
- /**
3224
- * Get all registered keys.
3225
- *
3226
- * @returns Array of all registered keys
3227
- */
3228
- getAllKeys(): KeyInfo[];
3229
- /**
3230
- * Clear all registered keys and delegations.
3231
- */
3232
- clear(): void;
3233
- /**
3234
- * Revoke a delegation by CID.
3235
- *
3236
- * @param cid - The delegation CID to revoke
3237
- * @returns Result indicating success or failure
3238
- */
3239
- revokeDelegation(cid: string): Result$1<void, ServiceError>;
3240
- /**
3241
- * Find capabilities that match a resource path pattern.
3242
- *
3243
- * @param resourcePattern - Resource pattern (supports wildcards)
3244
- * @param action - Optional action filter
3245
- * @returns Matching capability entries
3246
- */
3247
- findCapabilities(resourcePattern: string, action?: string): CapabilityEntry[];
3248
- /**
3249
- * Add a delegation to the store.
3250
- *
3251
- * @param key - The key associated with this delegation
3252
- * @param delegation - The delegation to add
3253
- */
3254
- private addDelegation;
1235
+ * @packageDocumentation
1236
+ */
1237
+
1238
+ /**
1239
+ * Session storage interface.
1240
+ *
1241
+ * Abstracts how sessions are persisted across different platforms.
1242
+ * - Browser: localStorage
1243
+ * - Node.js: file system or memory
1244
+ */
1245
+ interface ISessionStorage {
3255
1246
  /**
3256
- * Create a capability key for indexing.
3257
- *
3258
- * @param resource - Resource path
3259
- * @param action - Action
3260
- * @returns Combined key string
1247
+ * Save a session for an address.
1248
+ * @param address - Ethereum address (key for lookup)
1249
+ * @param session - Session data to persist
3261
1250
  */
3262
- private makeCapabilityKey;
3263
- private sameDelegationScope;
1251
+ save(address: string, session: PersistedSessionData): Promise<void>;
3264
1252
  /**
3265
- * Find capability entries that match a resource and action.
3266
- *
3267
- * @param resource - Resource to match
3268
- * @param action - Action to match
3269
- * @returns Matching entries
1253
+ * Load a session for an address.
1254
+ * @param address - Ethereum address
1255
+ * @returns Session data or null if not found
3270
1256
  */
3271
- private findMatchingEntries;
1257
+ load(address: string): Promise<PersistedSessionData | null>;
3272
1258
  /**
3273
- * Check if an action pattern matches a specific action.
3274
- *
3275
- * @param pattern - Action pattern (may include wildcard like "tinycloud.kv/*")
3276
- * @param action - Specific action to check
3277
- * @returns true if pattern matches action
1259
+ * Clear a session for an address.
1260
+ * @param address - Ethereum address
3278
1261
  */
3279
- private actionMatches;
1262
+ clear(address: string): Promise<void>;
3280
1263
  /**
3281
- * Check if a resource matches a pattern.
3282
- *
3283
- * Patterns support:
3284
- * - Exact match: "/kv/data" matches "/kv/data"
3285
- * - Wildcard suffix: "/kv/*" matches "/kv/anything"
3286
- * - Double wildcard: "/kv/**" matches "/kv/any/nested/path"
3287
- *
3288
- * @param resource - The specific resource being accessed
3289
- * @param pattern - The pattern from the delegation
3290
- * @returns true if resource matches pattern
1264
+ * Check if a session exists for an address (synchronous check).
1265
+ * @param address - Ethereum address
1266
+ * @returns true if session exists
3291
1267
  */
3292
- private resourceMatchesPattern;
1268
+ exists(address: string): boolean;
3293
1269
  /**
3294
- * Check if a specific resource matches a resource pattern for searching.
3295
- *
3296
- * @param entryResource - The resource from a capability entry
3297
- * @param searchPattern - The pattern to search for
3298
- * @returns true if entry resource matches search pattern
1270
+ * Check if the storage backend is available.
1271
+ * @returns true if storage can be used
3299
1272
  */
3300
- private matchesResourcePattern;
1273
+ isAvailable(): boolean;
3301
1274
  }
3302
- /**
3303
- * Create a new CapabilityKeyRegistry instance.
3304
- *
3305
- * @returns A new registry instance
3306
- */
3307
- declare function createCapabilityKeyRegistry(): ICapabilityKeyRegistry;
3308
1275
 
3309
1276
  /**
3310
1277
  * SignStrategy types for TinyCloud authorization.
@@ -3969,7 +1936,7 @@ declare class TinyCloud {
3969
1936
  *
3970
1937
  * Requires the user to be signed in and services to be initialized.
3971
1938
  */
3972
- ensurePublicSpace(): Promise<Result$1<void, ServiceError>>;
1939
+ ensurePublicSpace(): Promise<Result<void, ServiceError>>;
3973
1940
  /**
3974
1941
  * Get a KVService scoped to the user's own public space.
3975
1942
  * Writes require authentication (owner/delegate).
@@ -3987,7 +1954,7 @@ declare class TinyCloud {
3987
1954
  * @param fetchFn - Optional custom fetch function
3988
1955
  * @returns The data at the key
3989
1956
  */
3990
- static readPublicSpace<T = unknown>(host: string, spaceId: string, key: string, fetchFn?: FetchFunction): Promise<Result$1<T, ServiceError>>;
1957
+ static readPublicSpace<T = unknown>(host: string, spaceId: string, key: string, fetchFn?: FetchFunction): Promise<Result<T, ServiceError>>;
3991
1958
  /**
3992
1959
  * Read from any user's public space by address (unauthenticated).
3993
1960
  * Convenience method that constructs the space ID from address and chain ID.
@@ -3999,590 +1966,8 @@ declare class TinyCloud {
3999
1966
  * @param fetchFn - Optional custom fetch function
4000
1967
  * @returns The data at the key
4001
1968
  */
4002
- static readPublicKey<T = unknown>(host: string, address: string, chainId: number, key: string, fetchFn?: FetchFunction): Promise<Result$1<T, ServiceError>>;
4003
- }
4004
-
4005
- /**
4006
- * DelegationManager - Handles delegation CRUD operations.
4007
- *
4008
- * This class manages the creation, revocation, listing, and querying
4009
- * of delegations within TinyCloud. It extracts and improves upon the
4010
- * delegation functionality previously in ITinyCloudStorage.
4011
- *
4012
- * @packageDocumentation
4013
- */
4014
-
4015
- /**
4016
- * DelegationManager handles all delegation-related operations.
4017
- *
4018
- * @example
4019
- * ```typescript
4020
- * import { DelegationManager } from "@tinycloud/sdk-core/delegations";
4021
- *
4022
- * const delegations = new DelegationManager({
4023
- * hosts: ["https://node.tinycloud.xyz"],
4024
- * session,
4025
- * invoke,
4026
- * });
4027
- *
4028
- * // Create a delegation
4029
- * const result = await delegations.create({
4030
- * delegateDID: "did:pkh:eip155:1:0x...",
4031
- * path: "shared/",
4032
- * actions: ["tinycloud.kv/get", "tinycloud.kv/list"],
4033
- * expiry: new Date(Date.now() + 24 * 60 * 60 * 1000), // 24 hours
4034
- * });
4035
- *
4036
- * if (result.ok) {
4037
- * console.log("Created delegation:", result.data.cid);
4038
- * }
4039
- * ```
4040
- */
4041
- declare class DelegationManager {
4042
- private hosts;
4043
- private session;
4044
- private invoke;
4045
- private invokeAny?;
4046
- private fetchFn;
4047
- private accountSpaceId?;
4048
- /**
4049
- * Creates a new DelegationManager instance.
4050
- *
4051
- * @param config - Configuration including hosts, session, and invoke function
4052
- */
4053
- constructor(config: DelegationManagerConfig);
4054
- /**
4055
- * Updates the session (e.g., after re-authentication).
4056
- *
4057
- * @param session - New session to use for operations
4058
- */
4059
- updateSession(session: ServiceSession): void;
4060
- /**
4061
- * Gets the primary host URL.
4062
- */
4063
- private get host();
4064
- /**
4065
- * Executes an invoke operation against the delegation API.
4066
- */
4067
- private invokeOperation;
4068
- /**
4069
- * Creates a new delegation.
4070
- *
4071
- * Delegates specific permissions to another DID for a given path.
4072
- * The delegatee can then use these permissions to access resources
4073
- * within the specified scope.
4074
- *
4075
- * @param params - Parameters for the delegation
4076
- * @returns Result containing the created Delegation or an error
4077
- *
4078
- * @example
4079
- * ```typescript
4080
- * const result = await manager.create({
4081
- * delegateDID: bob.did,
4082
- * path: "documents/shared/",
4083
- * actions: ["tinycloud.kv/get", "tinycloud.kv/put"],
4084
- * expiry: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000), // 7 days
4085
- * });
4086
- * ```
4087
- */
4088
- create(params: CreateDelegationParams): Promise<Result<Delegation>>;
4089
- /**
4090
- * Revokes an existing delegation.
4091
- *
4092
- * Once revoked, the delegation can no longer be used to access resources.
4093
- * This also invalidates any sub-delegations derived from this delegation.
4094
- *
4095
- * @param cid - The CID of the delegation to revoke
4096
- * @returns Result indicating success or an error
4097
- *
4098
- * @example
4099
- * ```typescript
4100
- * const result = await manager.revoke("bafy...");
4101
- * if (result.ok) {
4102
- * console.log("Delegation revoked successfully");
4103
- * }
4104
- * ```
4105
- */
4106
- revoke(cid: string): Promise<Result<DelegationRevocationReceipt>>;
4107
- /**
4108
- * Reads the node-confirmed lifecycle state of one delegation without
4109
- * exposing delegation metadata.
4110
- */
4111
- status(cid: string): Promise<Result<DelegationStatus>>;
4112
- /** Query lifecycle-complete delegation history for the authenticated account. */
4113
- query(options?: AccountDelegationQueryOptions): Promise<Result<AccountDelegationPage>>;
4114
- /**
4115
- * Lists all delegations for the current session's space.
4116
- *
4117
- * Returns both delegations created by the current user (as delegator)
4118
- * and delegations granted to the current user (as delegatee).
4119
- *
4120
- * @returns Result containing an array of Delegations or an error
4121
- *
4122
- * @example
4123
- * ```typescript
4124
- * const result = await manager.list();
4125
- * if (result.ok) {
4126
- * for (const delegation of result.data) {
4127
- * console.log(`${delegation.cid}: ${delegation.path} -> ${delegation.delegateDID}`);
4128
- * }
4129
- * }
4130
- * ```
4131
- */
4132
- list(): Promise<Result<Delegation[]>>;
4133
- /**
4134
- * Gets the full delegation chain for a given delegation.
4135
- *
4136
- * Returns the chain of delegations from the root (original delegator)
4137
- * to the specified delegation, including all intermediate sub-delegations.
4138
- *
4139
- * @param cid - The CID of the delegation to get the chain for
4140
- * @returns Result containing the DelegationChain or an error
4141
- *
4142
- * @example
4143
- * ```typescript
4144
- * const result = await manager.getChain("bafy...");
4145
- * if (result.ok) {
4146
- * console.log("Chain length:", result.data.length);
4147
- * for (const delegation of result.data) {
4148
- * console.log(`- ${delegation.delegatorDID} -> ${delegation.delegateDID}`);
4149
- * }
4150
- * }
4151
- * ```
4152
- */
4153
- getChain(cid: string): Promise<Result<DelegationChain>>;
4154
- /**
4155
- * Checks if the current session has permission for a given path and action.
4156
- *
4157
- * This can be used to verify permissions before attempting an operation,
4158
- * or to implement custom access control logic.
4159
- *
4160
- * @param path - The resource path to check
4161
- * @param action - The action to check (e.g., "tinycloud.kv/get")
4162
- * @returns Result containing a boolean indicating permission or an error
4163
- *
4164
- * @example
4165
- * ```typescript
4166
- * const result = await manager.checkPermission("documents/private/", "tinycloud.kv/put");
4167
- * if (result.ok && result.data) {
4168
- * console.log("Permission granted");
4169
- * } else {
4170
- * console.log("Permission denied");
4171
- * }
4172
- * ```
4173
- */
4174
- checkPermission(path: string, action: string): Promise<Result<boolean>>;
4175
- }
4176
-
4177
- /**
4178
- * SharingService - v2 sharing link service with embedded private keys.
4179
- *
4180
- * This service implements the v2 sharing specification, which embeds private keys
4181
- * directly in sharing links. This allows recipients to exercise delegations
4182
- * without requiring prior session setup.
4183
- *
4184
- * Key differences from v1 SharingLinks:
4185
- * - Private keys are embedded in the link (not just tokens)
4186
- * - Recipients can optionally sub-delegate to their own session key
4187
- * - Pre-configured KV service returned for immediate use
4188
- *
4189
- * @packageDocumentation
4190
- */
4191
-
4192
- /**
4193
- * Data encoded in a sharing link.
4194
- */
4195
- interface EncodedShareData {
4196
- /** Private key in JWK format (includes d parameter) */
4197
- key: JWK;
4198
- /** DID of the key */
4199
- keyDid: string;
4200
- /** The delegation granting access */
4201
- delegation: Delegation;
4202
- /** Resource path this link grants access to */
4203
- path: string;
4204
- /** TinyCloud host URL */
4205
- host: string;
4206
- /** Space ID */
4207
- spaceId: string;
4208
- /** Schema version */
4209
- version: 1;
4210
- }
4211
- /**
4212
- * Options for receiving a sharing link.
4213
- */
4214
- interface ReceiveOptions {
4215
- /**
4216
- * Whether to automatically create a sub-delegation to the current session key.
4217
- * Default: true
4218
- */
4219
- autoSubdelegate?: boolean;
4220
- /**
4221
- * Whether to use the current session key for operations (requires autoSubdelegate).
4222
- * Default: true
4223
- */
4224
- useSessionKey?: boolean;
4225
- /**
4226
- * Ingestion options passed to CapabilityKeyRegistry.
4227
- */
4228
- ingestOptions?: IngestOptions;
4229
- }
4230
- /**
4231
- * Result of receiving a sharing link.
4232
- */
4233
- interface ShareAccess {
4234
- /** The delegation that was received/created */
4235
- delegation: Delegation;
4236
- /** Key info for the received key */
4237
- key: KeyInfo;
4238
- /** Pre-configured KV service for the shared path */
4239
- kv: IKVService;
4240
- /** The space ID */
4241
- spaceId: string;
4242
- /** The path prefix for this share */
4243
- path: string;
4244
- }
4245
- /**
4246
- * Parameters for attenuating a received share to another principal.
4247
- *
4248
- * Omitted path/actions/expiry inherit the received share's exact values. Any
4249
- * supplied value must be equal to or an attenuated subset of the parent.
4250
- */
4251
- interface DelegateReceivedShareParams {
4252
- /** DID that may exercise the child delegation. */
4253
- delegateDID: string;
4254
- /** Equal to or below the shared path. Defaults to the shared path. */
4255
- path?: string;
4256
- /** Subset of the shared actions. Defaults to all shared actions. */
4257
- actions?: string[];
4258
- /** No later than the sharing-link expiry. Defaults to the parent expiry. */
4259
- expiry?: Date;
4260
- /** Optional node origin that further narrows the configured-host allowlist. */
4261
- expectedHost?: string;
4262
- }
4263
- /**
4264
- * A transport-ready child delegation with non-secret source lineage.
4265
- *
4266
- * `delegation.delegationHeader` is a live bearer credential. Treat it like a
4267
- * secret: do not log it or persist it outside secure credential storage.
4268
- * Only `source` is safe to retain as non-secret lineage metadata.
4269
- */
4270
- interface DelegatedShareAccess {
4271
- delegation: Delegation & {
4272
- delegationHeader: {
4273
- Authorization: string;
4274
- };
4275
- ownerAddress: string;
4276
- chainId: number;
4277
- host: string;
4278
- resources: Array<{
4279
- service: string;
4280
- space: string;
4281
- path: string;
4282
- actions: string[];
4283
- }>;
4284
- disableSubDelegation: boolean;
4285
- };
4286
- source: {
4287
- parentCid: string;
4288
- spaceId: string;
4289
- path: string;
4290
- host: string;
4291
- expiresAt: Date;
4292
- };
4293
- }
4294
- /**
4295
- * Configuration for SharingService.
4296
- */
4297
- interface SharingServiceConfig {
4298
- /** TinyCloud host URLs */
4299
- hosts: string[];
4300
- /**
4301
- * Active session for authentication.
4302
- * Required for generate(), optional for receive().
4303
- */
4304
- session?: ServiceSession;
4305
- /** Platform-specific invoke function */
4306
- invoke: InvokeFunction;
4307
- /** Optional custom fetch implementation */
4308
- fetch?: FetchFunction;
4309
- /** Key provider for cryptographic operations */
4310
- keyProvider: KeyProvider;
4311
- /** Capability key registry for key/delegation management */
4312
- registry: ICapabilityKeyRegistry;
4313
- /**
4314
- * Delegation manager for creating delegations (used if createDelegation not provided).
4315
- * Required for generate(), optional for receive().
4316
- */
4317
- delegationManager?: DelegationManager;
4318
- /** Factory for creating KV service instances */
4319
- createKVService: (config: {
4320
- hosts: string[];
4321
- session: ServiceSession;
4322
- invoke: InvokeFunction;
4323
- fetch?: FetchFunction;
4324
- pathPrefix?: string;
4325
- }) => IKVService;
4326
- /** Base URL for sharing links (e.g., "https://share.myapp.com") */
4327
- baseUrl?: string;
4328
- /**
4329
- * Custom delegation creation function. When provided, this is used instead
4330
- * of delegationManager.create(). This allows platforms to use their own
4331
- * delegation creation logic (e.g., SIWE-based /delegate endpoint).
4332
- */
4333
- createDelegation?: (params: CreateDelegationParams) => Promise<Result<Delegation, DelegationError>>;
4334
- /**
4335
- * WASM function for client-side delegation creation.
4336
- * When provided, this is preferred over server-side creation (createDelegation/delegationManager).
4337
- * Creates UCAN delegations directly without requiring server roundtrip.
4338
- */
4339
- createDelegationWasm?: (params: CreateDelegationWasmParams) => CreateDelegationWasmResult;
4340
- /** Compute a CID for serialized delegation bytes. Required for share attenuation. */
4341
- computeCid?: (data: Uint8Array, codec: bigint) => string;
4342
- /**
4343
- * Path prefix for KV operations.
4344
- * When set, paths passed to generate() are prefixed with this value.
4345
- * This ensures the share path matches the session's authorized paths.
4346
- */
4347
- pathPrefix?: string;
4348
- /**
4349
- * Session expiry time.
4350
- * When set, sharing link expiry is clamped to not exceed this value
4351
- * unless onRootDelegationNeeded is provided and returns a new delegation.
4352
- */
4353
- sessionExpiry?: Date;
4354
- /**
4355
- * Callback to create a DIRECT delegation from the root (wallet) to a share key.
4356
- * This bypasses the session delegation chain, allowing share links with
4357
- * expiry longer than the current session.
4358
- *
4359
- * When provided and share expiry > session expiry:
4360
- * 1. SharingService creates the ephemeral share key
4361
- * 2. This callback is invoked with the share key DID
4362
- * 3. The callback signs a direct PKH -> share key delegation with the wallet
4363
- * 4. The returned delegation is used for the share link
4364
- *
4365
- * This is the CORRECT solution for long-lived share links because:
4366
- * - It creates a fresh delegation chain: PKH -> share key
4367
- * - Not constrained by session expiry (no sub-delegation from session key)
4368
- *
4369
- * @param params - Parameters for creating the root delegation
4370
- * @returns The delegation from wallet to share key, or undefined to fall back to session extension
4371
- */
4372
- onRootDelegationNeeded?: (params: {
4373
- /** DID of the share key to delegate to */
4374
- shareKeyDID: string;
4375
- /** Space ID */
4376
- spaceId: string;
4377
- /** Path to grant access to */
4378
- path: string;
4379
- /** Actions to grant */
4380
- actions: string[];
4381
- /** Requested expiry time */
4382
- requestedExpiry: Date;
4383
- }) => Promise<Delegation | undefined>;
4384
- /** Reject operations after the host session/service graph has been retired. */
4385
- assertActive?: () => void;
4386
- }
4387
- /**
4388
- * Interface for the SharingService.
4389
- */
4390
- interface ISharingService {
4391
- /**
4392
- * Generate a sharing link with an embedded private key.
4393
- *
4394
- * This creates a new session key, delegates to it, and encodes
4395
- * the key and delegation into a shareable link.
4396
- */
4397
- generate(params: GenerateShareParams): Promise<Result<ShareLink, DelegationError>>;
4398
- /**
4399
- * Receive and activate a sharing link.
4400
- *
4401
- * Decodes the link, ingests the key into the registry, and optionally
4402
- * creates a sub-delegation to the current session key.
4403
- */
4404
- receive(link: string, options?: ReceiveOptions): Promise<Result<ShareAccess, DelegationError>>;
4405
- /**
4406
- * Consume a sharing link locally and create an attenuated child delegation.
4407
- * The raw link and embedded private JWK are never returned. The returned
4408
- * child delegation is itself a sensitive bearer credential.
4409
- */
4410
- delegateReceivedShare(link: string, params: DelegateReceivedShareParams): Promise<Result<DelegatedShareAccess, DelegationError>>;
4411
- /**
4412
- * Encode sharing data into a link string.
4413
- */
4414
- encodeLink(data: EncodedShareData, schema?: ShareSchema): string;
4415
- /**
4416
- * Decode a link string into sharing data.
4417
- */
4418
- decodeLink(link: string): EncodedShareData;
4419
- }
4420
- /**
4421
- * SharingService - v2 sharing link service with embedded private keys.
4422
- *
4423
- * @example
4424
- * ```typescript
4425
- * import { SharingService } from "@tinycloud/sdk-core/delegations";
4426
- *
4427
- * const sharing = new SharingService({
4428
- * hosts: ["https://node.tinycloud.xyz"],
4429
- * session,
4430
- * invoke,
4431
- * keyProvider,
4432
- * registry,
4433
- * delegationManager,
4434
- * createKVService,
4435
- * baseUrl: "https://share.myapp.com"
4436
- * });
4437
- *
4438
- * // Generate a sharing link
4439
- * const result = await sharing.generate({
4440
- * path: "/kv/documents/report.pdf",
4441
- * actions: ["tinycloud.kv/get"],
4442
- * expiry: new Date("2024-12-31")
4443
- * });
4444
- *
4445
- * if (result.ok) {
4446
- * console.log("Share this URL:", result.data.url);
4447
- * }
4448
- *
4449
- * // Receive a sharing link
4450
- * const receiveResult = await sharing.receive(shareUrl);
4451
- * if (receiveResult.ok) {
4452
- * // Use the pre-configured KV service
4453
- * const data = await receiveResult.data.kv.get("report.pdf");
4454
- * }
4455
- * ```
4456
- */
4457
- declare class SharingService implements ISharingService {
4458
- private hosts;
4459
- private session?;
4460
- private invoke;
4461
- private fetchFn;
4462
- private keyProvider;
4463
- private registry;
4464
- private delegationManager?;
4465
- private createKVService;
4466
- private baseUrl;
4467
- private createDelegationFn?;
4468
- private createDelegationWasmFn?;
4469
- private computeCidFn?;
4470
- private pathPrefix;
4471
- private sessionExpiry?;
4472
- private onRootDelegationNeeded?;
4473
- private assertActiveFn?;
4474
- /**
4475
- * Creates a new SharingService instance.
4476
- */
4477
- constructor(config: SharingServiceConfig);
4478
- /**
4479
- * Gets the primary host URL.
4480
- */
4481
- private get host();
4482
- /**
4483
- * Updates the session (e.g., after re-authentication).
4484
- */
4485
- updateSession(session: ServiceSession): void;
4486
- /**
4487
- * Updates the service configuration.
4488
- * Used to add full capabilities (session, delegationManager, createDelegation, createDelegationWasm) after signIn.
4489
- */
4490
- updateConfig(config: Partial<Pick<SharingServiceConfig, "session" | "delegationManager" | "createDelegation" | "createDelegationWasm" | "sessionExpiry" | "onRootDelegationNeeded" | "assertActive">>): void;
4491
- /**
4492
- * Generate a sharing link with an embedded private key.
4493
- *
4494
- * Flow:
4495
- * 1. Spawn new session key (unique per share)
4496
- * 2. Create delegation from current session to spawned key
4497
- * 3. Package: { key (with private!), delegation, path, host }
4498
- * 4. Encode based on schema (base64 for now)
4499
- * 5. Return link string
4500
- */
4501
- generate(params: GenerateShareParams): Promise<Result<ShareLink, DelegationError>>;
4502
- /**
4503
- * Check if any key in the registry can satisfy the delegation request.
4504
- * A key can satisfy if it has a delegation that:
4505
- * 1. Covers the required path (exact match or parent path)
4506
- * 2. Has all required actions
4507
- * 3. Has sufficient expiry (delegation.expiry >= requestedExpiry)
4508
- * 4. Allows sub-delegation
4509
- * @internal
4510
- */
4511
- private findSuitableKeyForDelegation;
4512
- private retiredGraphError;
4513
- /**
4514
- * Check if a delegation path matches/covers the requested path.
4515
- * A delegation path covers the request if:
4516
- * - It's an exact match
4517
- * - It's a parent path (e.g., delegation for "" covers "foo/bar")
4518
- * - It uses wildcards that match
4519
- * @internal
4520
- */
4521
- private pathMatches;
4522
- /**
4523
- * Create a delegation from the current session to a share key.
4524
- * This is the fallback path when root delegation is not available.
4525
- * @internal
4526
- */
4527
- private createSessionDelegation;
4528
- /**
4529
- * Receive and activate a sharing link.
4530
- *
4531
- * Flow:
4532
- * 1. Decode link -> extract { key, delegation, path, host }
4533
- * 2. Ingest key into CapabilityKeyRegistry
4534
- * 3. If autoSubdelegate (default true) + useSessionKey:
4535
- * - Create sub-delegation from ingested key -> current session
4536
- * - Register sub-delegation capabilities
4537
- * 4. Return ShareAccess with pre-configured KV service
4538
- */
4539
- receive(link: string, options?: ReceiveOptions): Promise<Result<ShareAccess, DelegationError>>;
4540
- /**
4541
- * Create a constrained child delegation from a received sharing link.
4542
- *
4543
- * This is the safe handoff for a browser delegating shared input to an
4544
- * agent or service: the bearer link is decoded and used only in this SDK
4545
- * instance, while the recipient receives a child UCAN without the embedded
4546
- * private key. The child UCAN is a sensitive bearer credential and must not
4547
- * be logged or stored insecurely.
4548
- */
4549
- delegateReceivedShare(link: string, params: DelegateReceivedShareParams): Promise<Result<DelegatedShareAccess, DelegationError>>;
4550
- /**
4551
- * The child-delegation WASM boundary accepts action-only abilities. Reject
4552
- * every constrained parent branch before that boundary can broaden it.
4553
- */
4554
- private assertDelegationCaveatsPreservable;
4555
- /**
4556
- * Encode sharing data into a link string.
4557
- *
4558
- * @param data - The share data to encode
4559
- * @param schema - The encoding schema (default: "base64")
4560
- * @returns Encoded link string
4561
- */
4562
- encodeLink(data: EncodedShareData, schema?: ShareSchema): string;
4563
- /**
4564
- * Decode a link string into sharing data.
4565
- *
4566
- * @param link - The encoded link string (may include URL prefix)
4567
- * @returns Decoded share data
4568
- * @throws Error if link format is invalid or data fails validation
4569
- */
4570
- decodeLink(link: string): EncodedShareData;
4571
- /**
4572
- * Decode and validate a link string into sharing data.
4573
- *
4574
- * Internal method that returns a Result instead of throwing.
4575
- * Used by receive() for proper error handling.
4576
- *
4577
- * @param link - The encoded link string (may include URL prefix)
4578
- * @returns Result with decoded share data or validation error
4579
- */
4580
- private decodeLinkWithValidation;
1969
+ static readPublicKey<T = unknown>(host: string, address: string, chainId: number, key: string, fetchFn?: FetchFunction): Promise<Result<T, ServiceError>>;
4581
1970
  }
4582
- /**
4583
- * Create a new SharingService instance.
4584
- */
4585
- declare function createSharingService(config: SharingServiceConfig): ISharingService;
4586
1971
 
4587
1972
  /**
4588
1973
  * Interface for space-scoped delegation operations.
@@ -4593,19 +1978,19 @@ interface ISpaceScopedDelegations {
4593
1978
  /**
4594
1979
  * List delegations created by the user in this space (outgoing).
4595
1980
  */
4596
- list(): Promise<Result$1<Delegation[], ServiceError>>;
1981
+ list(): Promise<Result<Delegation[], ServiceError>>;
4597
1982
  /**
4598
1983
  * List delegations received by the user for this space (incoming).
4599
1984
  */
4600
- listReceived(): Promise<Result$1<Delegation[], ServiceError>>;
1985
+ listReceived(): Promise<Result<Delegation[], ServiceError>>;
4601
1986
  /**
4602
1987
  * Create a delegation within this space.
4603
1988
  */
4604
- create(params: Omit<CreateDelegationParams, "spaceId">): Promise<Result$1<Delegation, ServiceError>>;
1989
+ create(params: Omit<CreateDelegationParams, "spaceId">): Promise<Result<Delegation, ServiceError>>;
4605
1990
  /**
4606
1991
  * Revoke a delegation within this space.
4607
1992
  */
4608
- revoke(cid: string): Promise<Result$1<void, ServiceError>>;
1993
+ revoke(cid: string): Promise<Result<void, ServiceError>>;
4609
1994
  }
4610
1995
  /**
4611
1996
  * Interface for space-scoped sharing operations.
@@ -4616,15 +2001,15 @@ interface ISpaceScopedSharing {
4616
2001
  /**
4617
2002
  * Generate a sharing link for a resource in this space.
4618
2003
  */
4619
- generate(params: Omit<GenerateShareParams, "spaceId">): Promise<Result$1<ShareLink, ServiceError>>;
2004
+ generate(params: Omit<GenerateShareParams, "spaceId">): Promise<Result<ShareLink, ServiceError>>;
4620
2005
  /**
4621
2006
  * List active sharing links in this space.
4622
2007
  */
4623
- list(): Promise<Result$1<ShareLink[], ServiceError>>;
2008
+ list(): Promise<Result<ShareLink[], ServiceError>>;
4624
2009
  /**
4625
2010
  * Revoke a sharing link.
4626
2011
  */
4627
- revoke(token: string): Promise<Result$1<void, ServiceError>>;
2012
+ revoke(token: string): Promise<Result<void, ServiceError>>;
4628
2013
  }
4629
2014
  /**
4630
2015
  * Interface for a Space object.
@@ -4663,7 +2048,7 @@ interface ISpace {
4663
2048
  /**
4664
2049
  * Get space metadata.
4665
2050
  */
4666
- info(): Promise<Result$1<SpaceInfo, ServiceError>>;
2051
+ info(): Promise<Result<SpaceInfo, ServiceError>>;
4667
2052
  }
4668
2053
  /**
4669
2054
  * Configuration for creating a Space object.
@@ -4700,7 +2085,7 @@ interface SpaceConfig {
4700
2085
  /**
4701
2086
  * Function to get space info.
4702
2087
  */
4703
- getInfo: (spaceId: string) => Promise<Result$1<SpaceInfo, ServiceError>>;
2088
+ getInfo: (spaceId: string) => Promise<Result<SpaceInfo, ServiceError>>;
4704
2089
  }
4705
2090
  /**
4706
2091
  * Space - Provides scoped access to services within a specific space.
@@ -4772,7 +2157,7 @@ declare class Space implements ISpace {
4772
2157
  *
4773
2158
  * @returns Result containing space information
4774
2159
  */
4775
- info(): Promise<Result$1<SpaceInfo, ServiceError>>;
2160
+ info(): Promise<Result<SpaceInfo, ServiceError>>;
4776
2161
  }
4777
2162
 
4778
2163
  /**
@@ -4817,7 +2202,7 @@ interface SpaceDelegationParams extends Omit<CreateDelegationParams, "spaceId">
4817
2202
  * Function type for creating delegations.
4818
2203
  * Platform SDKs provide this to handle SIWE-based delegation creation.
4819
2204
  */
4820
- type CreateDelegationFunction = (params: SpaceDelegationParams) => Promise<Result$1<Delegation, ServiceError>>;
2205
+ type CreateDelegationFunction = (params: SpaceDelegationParams) => Promise<Result<Delegation, ServiceError>>;
4821
2206
  /**
4822
2207
  * Configuration for SpaceService.
4823
2208
  */
@@ -4858,13 +2243,13 @@ interface ISpaceService {
4858
2243
  /**
4859
2244
  * List all spaces the user has access to (owned + delegated).
4860
2245
  */
4861
- list(): Promise<Result$1<SpaceInfo[], ServiceError>>;
2246
+ list(): Promise<Result<SpaceInfo[], ServiceError>>;
4862
2247
  /**
4863
2248
  * Create a new space.
4864
2249
  *
4865
2250
  * @param name - The name for the new space
4866
2251
  */
4867
- create(name: string): Promise<Result$1<SpaceInfo, ServiceError>>;
2252
+ create(name: string): Promise<Result<SpaceInfo, ServiceError>>;
4868
2253
  /**
4869
2254
  * Get a Space object by name or full URI.
4870
2255
  *
@@ -4879,7 +2264,7 @@ interface ISpaceService {
4879
2264
  *
4880
2265
  * @param nameOrUri - Short name or full URI
4881
2266
  */
4882
- exists(nameOrUri: string): Promise<Result$1<boolean, ServiceError>>;
2267
+ exists(nameOrUri: string): Promise<Result<boolean, ServiceError>>;
4883
2268
  /**
4884
2269
  * Get the current user's primary space ID.
4885
2270
  */
@@ -5006,7 +2391,7 @@ declare class SpaceService implements ISpaceService {
5006
2391
  * Combines owned spaces (from the server) with delegated spaces
5007
2392
  * (from the capability registry).
5008
2393
  */
5009
- list(): Promise<Result$1<SpaceInfo[], ServiceError>>;
2394
+ list(): Promise<Result<SpaceInfo[], ServiceError>>;
5010
2395
  /**
5011
2396
  * List owned spaces from the server.
5012
2397
  */
@@ -5028,7 +2413,7 @@ declare class SpaceService implements ISpaceService {
5028
2413
  *
5029
2414
  * @param name - The name for the new space
5030
2415
  */
5031
- create(name: string): Promise<Result$1<SpaceInfo, ServiceError>>;
2416
+ create(name: string): Promise<Result<SpaceInfo, ServiceError>>;
5032
2417
  private notifySpaceRegistered;
5033
2418
  /**
5034
2419
  * Get a Space object by name or full URI.
@@ -5043,7 +2428,7 @@ declare class SpaceService implements ISpaceService {
5043
2428
  /**
5044
2429
  * Check if a space exists and the user has access.
5045
2430
  */
5046
- exists(nameOrUri: string): Promise<Result$1<boolean, ServiceError>>;
2431
+ exists(nameOrUri: string): Promise<Result<boolean, ServiceError>>;
5047
2432
  /**
5048
2433
  * Get space info from server or cache.
5049
2434
  */
@@ -5162,39 +2547,39 @@ interface AccountServiceConfig {
5162
2547
  declare class AccountService {
5163
2548
  private readonly config;
5164
2549
  constructor(config: AccountServiceConfig);
5165
- status(): Promise<Result$1<AccountStatus>>;
2550
+ status(): Promise<Result<AccountStatus>>;
5166
2551
  readonly applications: {
5167
- list: (options?: AccountApplicationListOptions) => Promise<Result$1<AccountApplication[]>>;
5168
- get: (appId: string) => Promise<Result$1<AccountApplication>>;
5169
- register: (manifest: Manifest | Manifest[]) => Promise<Result$1<AccountApplication>>;
5170
- remove: (appId: string) => Promise<Result$1<void>>;
2552
+ list: (options?: AccountApplicationListOptions) => Promise<Result<AccountApplication[]>>;
2553
+ get: (appId: string) => Promise<Result<AccountApplication>>;
2554
+ register: (manifest: Manifest | Manifest[]) => Promise<Result<AccountApplication>>;
2555
+ remove: (appId: string) => Promise<Result<void>>;
5171
2556
  };
5172
2557
  readonly spaces: {
5173
- list: (options?: AccountSpaceListOptions) => Promise<Result$1<AccountSpace[]>>;
5174
- get: (spaceId: string) => Promise<Result$1<AccountSpace>>;
5175
- register: (space: SpaceInfo | AccountSpace) => Promise<Result$1<AccountSpace>>;
5176
- syncAccessible: () => Promise<Result$1<AccountSpace[]>>;
5177
- remove: (spaceId: string) => Promise<Result$1<void>>;
2558
+ list: (options?: AccountSpaceListOptions) => Promise<Result<AccountSpace[]>>;
2559
+ get: (spaceId: string) => Promise<Result<AccountSpace>>;
2560
+ register: (space: SpaceInfo | AccountSpace) => Promise<Result<AccountSpace>>;
2561
+ syncAccessible: () => Promise<Result<AccountSpace[]>>;
2562
+ remove: (spaceId: string) => Promise<Result<void>>;
5178
2563
  };
5179
2564
  readonly delegations: {
5180
- query: (options?: AccountDelegationQueryOptions) => Promise<Result$1<AccountDelegationPage>>;
5181
- list: (options?: AccountDelegationListOptions) => Promise<Result$1<AccountDelegation[]>>;
5182
- revoke: (input: string | AccountDelegationRevokeOptions) => Promise<Result$1<DelegationRevocationReceipt | void>>;
2565
+ query: (options?: AccountDelegationQueryOptions) => Promise<Result<AccountDelegationPage>>;
2566
+ list: (options?: AccountDelegationListOptions) => Promise<Result<AccountDelegation[]>>;
2567
+ revoke: (input: string | AccountDelegationRevokeOptions) => Promise<Result<DelegationRevocationReceipt | void>>;
5183
2568
  };
5184
2569
  readonly index: {
5185
- ensure: () => Promise<Result$1<AccountIndexEnsureResult>>;
5186
- rebuild: () => Promise<Result$1<AccountIndexRebuildResult>>;
2570
+ ensure: () => Promise<Result<AccountIndexEnsureResult>>;
2571
+ rebuild: () => Promise<Result<AccountIndexRebuildResult>>;
5187
2572
  applications: {
5188
- list: () => Promise<Result$1<AccountApplication[]>>;
2573
+ list: () => Promise<Result<AccountApplication[]>>;
5189
2574
  };
5190
2575
  spaces: {
5191
- list: () => Promise<Result$1<AccountSpace[]>>;
2576
+ list: () => Promise<Result<AccountSpace[]>>;
5192
2577
  };
5193
2578
  delegations: {
5194
- list: (options?: AccountDelegationListOptions) => Promise<Result$1<AccountDelegation[]>>;
2579
+ list: (options?: AccountDelegationListOptions) => Promise<Result<AccountDelegation[]>>;
5195
2580
  };
5196
- query: <T = Record<string, unknown>>(sql: string, params?: SqlValue[]) => Promise<Result$1<QueryResponse<T>>>;
5197
- status: () => Promise<Result$1<AccountIndexStatus>>;
2581
+ query: <T = Record<string, unknown>>(sql: string, params?: SqlValue[]) => Promise<Result<QueryResponse<T>>>;
2582
+ status: () => Promise<Result<AccountIndexStatus>>;
5198
2583
  };
5199
2584
  private accountKV;
5200
2585
  private accountDb;
@@ -5274,6 +2659,10 @@ declare function submitHostDelegation(host: string, headers: Record<string, stri
5274
2659
  * This submits the session delegation to the server, enabling the session
5275
2660
  * key to perform operations on behalf of the user.
5276
2661
  *
2662
+ * Concurrent calls with the same host and a byte-identical delegation header
2663
+ * share a single `POST /delegate`; see {@link inFlightActivations}. Sequential
2664
+ * calls always issue a fresh request.
2665
+ *
5277
2666
  * @param host - TinyCloud server URL
5278
2667
  * @param delegationHeader - Session delegation header (from session.delegationHeader)
5279
2668
  * @returns Result indicating success/failure (404 means space doesn't exist)
@@ -5554,4 +2943,4 @@ declare const EXPIRY: {
5554
2943
  declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
5555
2944
  type ExpiryTier = keyof typeof EXPIRY;
5556
2945
 
5557
- export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, type AccountApplication, type AccountApplicationListOptions, type AccountDelegation, type AccountDelegationListOptions, type AccountDelegationPage, type AccountDelegationQueryOptions, type AccountDelegationRecord, type AccountDelegationResource, type AccountDelegationRevokeOptions, type AccountIndexEnsureResult, type AccountIndexRebuildResult, type AccountIndexStatus, type AccountIndexedReadOptions, AccountService, type AccountServiceConfig, type AccountSpace, type AccountSpaceListOptions, type AccountStatus, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CanonicalAddress, type CanonicalParsedNetworkId, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_KNOWLEDGE_ROOT, DEFAULT_LOCAL_NODE_PIN_STORAGE_KEY, DEFAULT_LOCAL_NODE_URL, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegateReceivedShareParams, type DelegatedResource, type DelegatedShareAccess, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, type DelegationRevocationReceipt, type DelegationStatus, type DidCacheKeyOptions, type DidEqualsOptions, type DiscoverLocalTinyCloudNodeOptions, type DiscoveredLocalTinyCloudNode, ENCRYPTION_MANIFEST_SPACE, ENCRYPTION_PERMISSION_SERVICE, EXPIRY, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type ExpiryTier, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, IdentityParseError, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, LOCAL_LINK_HOST_SUFFIX, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, type LocalNodeIdentityStore, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestKnowledge, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type OpenKeyCallbackStrategy, type OpenKeySigningRequestBody, type OpenKeySigningResponseBody, type OpenKeySigningStrategyOptions, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedSessionProof, type PersistedTinyCloudSession, type PkhDidParts, ProtocolMismatchError, type ReceiveOptions, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SECRETS_SPACE, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidatedPersistedSessionProof, type ValidationError, VersionCheckError, type WasmRecapEntry, type WebStorageLike, actionContains, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeRecapCaveats, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createInMemoryLocalNodeIdentityStore, createLocalStorageLocalNodeIdentityStore, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, didCacheKey, didEquals, discoverLocalTinyCloudNode, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, isEvmAddress, loadManifest, locationPayloadForRecord, makePkhSpaceId, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseRecapCapabilities, parseSpaceUri, pkhDid, principalDid, principalDidEquals, recapCaveatsEqual, resolveCloudLocation, resolveManifest, resolveManifestKnowledgeRoot, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
2946
+ export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, type AccountApplication, type AccountApplicationListOptions, type AccountDelegation, type AccountDelegationListOptions, AccountDelegationPage, AccountDelegationQueryOptions, type AccountDelegationRevokeOptions, type AccountIndexEnsureResult, type AccountIndexRebuildResult, type AccountIndexStatus, type AccountIndexedReadOptions, AccountService, type AccountServiceConfig, type AccountSpace, type AccountSpaceListOptions, type AccountStatus, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CanonicalAddress, type CanonicalParsedNetworkId, CaveatedDelegationUnsupportedError, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, CreateDelegationParams, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_KNOWLEDGE_ROOT, DEFAULT_LOCAL_NODE_PIN_STORAGE_KEY, DEFAULT_LOCAL_NODE_URL, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, Delegation, DelegationManager, DelegationRevocationReceipt, type DidCacheKeyOptions, type DidEqualsOptions, type DiscoverLocalTinyCloudNodeOptions, type DiscoveredLocalTinyCloudNode, ENCRYPTION_MANIFEST_SPACE, ENCRYPTION_PERMISSION_SERVICE, EXPIRY, type EnsData, EnsDataSchema, type EventEmitterStrategy, type ExpiryTier, type Extension, GenerateShareParams, ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, IdentityParseError, LOCAL_LINK_HOST_SUFFIX, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, type LocalNodeIdentityStore, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestKnowledge, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type OpenKeyCallbackStrategy, type OpenKeySigningRequestBody, type OpenKeySigningResponseBody, type OpenKeySigningStrategyOptions, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedSessionProof, type PersistedTinyCloudSession, type PkhDidParts, ProtocolMismatchError, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SECRETS_SPACE, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, ShareLink, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, SpaceInfo, SpaceService, type SpaceServiceConfig, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidatedPersistedSessionProof, type ValidationError, VersionCheckError, type WasmRecapEntry, type WebStorageLike, actionContains, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeRecapCaveats, checkNodeInfo, composeManifestRequest, createInMemoryLocalNodeIdentityStore, createLocalStorageLocalNodeIdentityStore, createOpenKeyCallbackSigningStrategy, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, didCacheKey, didEquals, discoverLocalTinyCloudNode, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, isEvmAddress, loadManifest, locationPayloadForRecord, makePkhSpaceId, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseRecapCapabilities, parseSpaceUri, pkhDid, principalDid, principalDidEquals, recapCaveatsEqual, resolveCloudLocation, resolveManifest, resolveManifestKnowledgeRoot, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };