@tinycloud/sdk-core 2.7.0-beta.2 → 2.7.0-beta.3

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.ts CHANGED
@@ -3,8 +3,8 @@ import { InvokeFunction, InvokeAnyFunction, ParsedNetworkId, ServiceError, Resul
3
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, 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, 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.js';
5
5
  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
- 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-C9Gur3ZY.js';
7
- export { a as JsonValue, j as jcsCanonicalize, n as normalizeJson, s as serializeJcsJson } from './capability-Dbx-xqUh.js';
6
+ 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-BHkLbCXI.js';
7
+ export { b as JsonValue, j as jcsCanonicalize, n as normalizeJson, s as serializeJcsJson } from './capability-DpdAwc1W.js';
8
8
  export { SiweMessage } from 'siwe';
9
9
 
10
10
  /**
@@ -1502,6 +1502,227 @@ declare const DelegationStatusSchema: z.ZodEffects<z.ZodObject<{
1502
1502
  exists: boolean;
1503
1503
  }>;
1504
1504
  type DelegationStatus = z.infer<typeof DelegationStatusSchema>;
1505
+ declare const DelegationRevocationReceiptSchema: z.ZodObject<{
1506
+ revoked: z.ZodLiteral<true>;
1507
+ cid: z.ZodString;
1508
+ }, "strict", z.ZodTypeAny, {
1509
+ revoked: true;
1510
+ cid: string;
1511
+ }, {
1512
+ revoked: true;
1513
+ cid: string;
1514
+ }>;
1515
+ type DelegationRevocationReceipt = z.infer<typeof DelegationRevocationReceiptSchema>;
1516
+ declare const AccountDelegationResourceSchema: z.ZodObject<{
1517
+ resource: z.ZodString;
1518
+ actions: z.ZodArray<z.ZodString, "many">;
1519
+ caveats: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
1520
+ }, "strict", z.ZodTypeAny, {
1521
+ actions: string[];
1522
+ caveats: Record<string, unknown>[];
1523
+ resource: string;
1524
+ }, {
1525
+ actions: string[];
1526
+ caveats: Record<string, unknown>[];
1527
+ resource: string;
1528
+ }>;
1529
+ declare const AccountDelegationRecordSchema: z.ZodObject<{
1530
+ cid: z.ZodString;
1531
+ direction: z.ZodEnum<["granted", "received"]>;
1532
+ delegatorDid: z.ZodString;
1533
+ delegateDid: z.ZodString;
1534
+ resources: z.ZodArray<z.ZodObject<{
1535
+ resource: z.ZodString;
1536
+ actions: z.ZodArray<z.ZodString, "many">;
1537
+ caveats: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
1538
+ }, "strict", z.ZodTypeAny, {
1539
+ actions: string[];
1540
+ caveats: Record<string, unknown>[];
1541
+ resource: string;
1542
+ }, {
1543
+ actions: string[];
1544
+ caveats: Record<string, unknown>[];
1545
+ resource: string;
1546
+ }>, "many">;
1547
+ parents: z.ZodArray<z.ZodString, "many">;
1548
+ issuedAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1549
+ notBefore: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1550
+ expiresAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1551
+ status: z.ZodEnum<["active", "pending", "expired", "revoked", "ancestor_revoked"]>;
1552
+ revokedAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>>;
1553
+ revokedBy: z.ZodOptional<z.ZodString>;
1554
+ revokedAncestorCid: z.ZodOptional<z.ZodString>;
1555
+ }, "strict", z.ZodTypeAny, {
1556
+ status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1557
+ notBefore: Date | null;
1558
+ resources: {
1559
+ actions: string[];
1560
+ caveats: Record<string, unknown>[];
1561
+ resource: string;
1562
+ }[];
1563
+ expiresAt: Date | null;
1564
+ issuedAt: Date | null;
1565
+ cid: string;
1566
+ direction: "received" | "granted";
1567
+ delegatorDid: string;
1568
+ delegateDid: string;
1569
+ parents: string[];
1570
+ revokedAt?: Date | null | undefined;
1571
+ revokedBy?: string | undefined;
1572
+ revokedAncestorCid?: string | undefined;
1573
+ }, {
1574
+ status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1575
+ notBefore: string | null;
1576
+ resources: {
1577
+ actions: string[];
1578
+ caveats: Record<string, unknown>[];
1579
+ resource: string;
1580
+ }[];
1581
+ expiresAt: string | null;
1582
+ issuedAt: string | null;
1583
+ cid: string;
1584
+ direction: "received" | "granted";
1585
+ delegatorDid: string;
1586
+ delegateDid: string;
1587
+ parents: string[];
1588
+ revokedAt?: string | null | undefined;
1589
+ revokedBy?: string | undefined;
1590
+ revokedAncestorCid?: string | undefined;
1591
+ }>;
1592
+ declare const AccountDelegationPageSchema: z.ZodObject<{
1593
+ schemaVersion: z.ZodLiteral<2>;
1594
+ items: z.ZodArray<z.ZodObject<{
1595
+ cid: z.ZodString;
1596
+ direction: z.ZodEnum<["granted", "received"]>;
1597
+ delegatorDid: z.ZodString;
1598
+ delegateDid: z.ZodString;
1599
+ resources: z.ZodArray<z.ZodObject<{
1600
+ resource: z.ZodString;
1601
+ actions: z.ZodArray<z.ZodString, "many">;
1602
+ caveats: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>, "many">;
1603
+ }, "strict", z.ZodTypeAny, {
1604
+ actions: string[];
1605
+ caveats: Record<string, unknown>[];
1606
+ resource: string;
1607
+ }, {
1608
+ actions: string[];
1609
+ caveats: Record<string, unknown>[];
1610
+ resource: string;
1611
+ }>, "many">;
1612
+ parents: z.ZodArray<z.ZodString, "many">;
1613
+ issuedAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1614
+ notBefore: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1615
+ expiresAt: z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>;
1616
+ status: z.ZodEnum<["active", "pending", "expired", "revoked", "ancestor_revoked"]>;
1617
+ revokedAt: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, Date, string>>>;
1618
+ revokedBy: z.ZodOptional<z.ZodString>;
1619
+ revokedAncestorCid: z.ZodOptional<z.ZodString>;
1620
+ }, "strict", z.ZodTypeAny, {
1621
+ status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1622
+ notBefore: Date | null;
1623
+ resources: {
1624
+ actions: string[];
1625
+ caveats: Record<string, unknown>[];
1626
+ resource: string;
1627
+ }[];
1628
+ expiresAt: Date | null;
1629
+ issuedAt: Date | null;
1630
+ cid: string;
1631
+ direction: "received" | "granted";
1632
+ delegatorDid: string;
1633
+ delegateDid: string;
1634
+ parents: string[];
1635
+ revokedAt?: Date | null | undefined;
1636
+ revokedBy?: string | undefined;
1637
+ revokedAncestorCid?: string | undefined;
1638
+ }, {
1639
+ status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1640
+ notBefore: string | null;
1641
+ resources: {
1642
+ actions: string[];
1643
+ caveats: Record<string, unknown>[];
1644
+ resource: string;
1645
+ }[];
1646
+ expiresAt: string | null;
1647
+ issuedAt: string | null;
1648
+ cid: string;
1649
+ direction: "received" | "granted";
1650
+ delegatorDid: string;
1651
+ delegateDid: string;
1652
+ parents: string[];
1653
+ revokedAt?: string | null | undefined;
1654
+ revokedBy?: string | undefined;
1655
+ revokedAncestorCid?: string | undefined;
1656
+ }>, "many">;
1657
+ nextCursor: z.ZodOptional<z.ZodString>;
1658
+ }, "strict", z.ZodTypeAny, {
1659
+ schemaVersion: 2;
1660
+ items: {
1661
+ status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1662
+ notBefore: Date | null;
1663
+ resources: {
1664
+ actions: string[];
1665
+ caveats: Record<string, unknown>[];
1666
+ resource: string;
1667
+ }[];
1668
+ expiresAt: Date | null;
1669
+ issuedAt: Date | null;
1670
+ cid: string;
1671
+ direction: "received" | "granted";
1672
+ delegatorDid: string;
1673
+ delegateDid: string;
1674
+ parents: string[];
1675
+ revokedAt?: Date | null | undefined;
1676
+ revokedBy?: string | undefined;
1677
+ revokedAncestorCid?: string | undefined;
1678
+ }[];
1679
+ nextCursor?: string | undefined;
1680
+ }, {
1681
+ schemaVersion: 2;
1682
+ items: {
1683
+ status: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked";
1684
+ notBefore: string | null;
1685
+ resources: {
1686
+ actions: string[];
1687
+ caveats: Record<string, unknown>[];
1688
+ resource: string;
1689
+ }[];
1690
+ expiresAt: string | null;
1691
+ issuedAt: string | null;
1692
+ cid: string;
1693
+ direction: "received" | "granted";
1694
+ delegatorDid: string;
1695
+ delegateDid: string;
1696
+ parents: string[];
1697
+ revokedAt?: string | null | undefined;
1698
+ revokedBy?: string | undefined;
1699
+ revokedAncestorCid?: string | undefined;
1700
+ }[];
1701
+ nextCursor?: string | undefined;
1702
+ }>;
1703
+ type AccountDelegationResource = z.infer<typeof AccountDelegationResourceSchema>;
1704
+ type AccountDelegationRecord = z.infer<typeof AccountDelegationRecordSchema>;
1705
+ type AccountDelegationPage = z.infer<typeof AccountDelegationPageSchema>;
1706
+ declare const AccountDelegationQueryOptionsSchema: z.ZodObject<{
1707
+ direction: z.ZodOptional<z.ZodEnum<["granted", "received", "all"]>>;
1708
+ status: z.ZodOptional<z.ZodEnum<["active", "pending", "expired", "revoked", "ancestor_revoked"]>>;
1709
+ space: z.ZodOptional<z.ZodString>;
1710
+ limit: z.ZodOptional<z.ZodNumber>;
1711
+ cursor: z.ZodOptional<z.ZodString>;
1712
+ }, "strict", z.ZodTypeAny, {
1713
+ status?: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked" | undefined;
1714
+ space?: string | undefined;
1715
+ direction?: "received" | "all" | "granted" | undefined;
1716
+ limit?: number | undefined;
1717
+ cursor?: string | undefined;
1718
+ }, {
1719
+ status?: "active" | "revoked" | "expired" | "pending" | "ancestor_revoked" | undefined;
1720
+ space?: string | undefined;
1721
+ direction?: "received" | "all" | "granted" | undefined;
1722
+ limit?: number | undefined;
1723
+ cursor?: string | undefined;
1724
+ }>;
1725
+ type AccountDelegationQueryOptions = z.infer<typeof AccountDelegationQueryOptionsSchema>;
1505
1726
  /**
1506
1727
  * Entry in the capability registry mapping a capability to available keys.
1507
1728
  */
@@ -2162,23 +2383,23 @@ declare const DelegationFiltersSchema: z.ZodObject<{
2162
2383
  }, "strip", z.ZodTypeAny, {
2163
2384
  path?: string | undefined;
2164
2385
  actions?: string[] | undefined;
2386
+ direction?: "received" | "all" | "granted" | undefined;
2387
+ limit?: number | undefined;
2388
+ cursor?: string | undefined;
2165
2389
  delegator?: string | undefined;
2166
2390
  delegatee?: string | undefined;
2167
- direction?: "received" | "all" | "granted" | undefined;
2168
2391
  includeRevoked?: boolean | undefined;
2169
2392
  validAt?: Date | undefined;
2170
- limit?: number | undefined;
2171
- cursor?: string | undefined;
2172
2393
  }, {
2173
2394
  path?: string | undefined;
2174
2395
  actions?: string[] | undefined;
2396
+ direction?: "received" | "all" | "granted" | undefined;
2397
+ limit?: number | undefined;
2398
+ cursor?: string | undefined;
2175
2399
  delegator?: string | undefined;
2176
2400
  delegatee?: string | undefined;
2177
- direction?: "received" | "all" | "granted" | undefined;
2178
2401
  includeRevoked?: boolean | undefined;
2179
2402
  validAt?: Date | undefined;
2180
- limit?: number | undefined;
2181
- cursor?: string | undefined;
2182
2403
  }>;
2183
2404
  type DelegationFilters = z.infer<typeof DelegationFiltersSchema>;
2184
2405
  /**
@@ -2405,6 +2626,8 @@ type GenerateShareParams = z.infer<typeof GenerateShareParamsSchema>;
2405
2626
  declare const DelegationManagerConfigSchema: z.ZodObject<{
2406
2627
  /** TinyCloud host URLs */
2407
2628
  hosts: z.ZodArray<z.ZodString, "many">;
2629
+ /** Account space used by account-wide delegation history queries */
2630
+ accountSpaceId: z.ZodOptional<z.ZodString>;
2408
2631
  /** Active session for authentication */
2409
2632
  session: z.ZodEffects<z.ZodUnknown, ServiceSession, unknown>;
2410
2633
  /** Platform-specific invoke function */
@@ -2418,11 +2641,13 @@ declare const DelegationManagerConfigSchema: z.ZodObject<{
2418
2641
  hosts: string[];
2419
2642
  invoke: InvokeFunction;
2420
2643
  invokeAny?: InvokeAnyFunction | undefined;
2644
+ accountSpaceId?: string | undefined;
2421
2645
  fetch?: FetchFunction | undefined;
2422
2646
  }, {
2423
2647
  hosts: string[];
2424
2648
  invokeAny?: unknown;
2425
2649
  session?: unknown;
2650
+ accountSpaceId?: string | undefined;
2426
2651
  invoke?: unknown;
2427
2652
  fetch?: unknown;
2428
2653
  }>;
@@ -3679,6 +3904,7 @@ declare class DelegationManager {
3679
3904
  private invoke;
3680
3905
  private invokeAny?;
3681
3906
  private fetchFn;
3907
+ private accountSpaceId?;
3682
3908
  /**
3683
3909
  * Creates a new DelegationManager instance.
3684
3910
  *
@@ -3737,12 +3963,14 @@ declare class DelegationManager {
3737
3963
  * }
3738
3964
  * ```
3739
3965
  */
3740
- revoke(cid: string): Promise<Result<void>>;
3966
+ revoke(cid: string): Promise<Result<DelegationRevocationReceipt>>;
3741
3967
  /**
3742
3968
  * Reads the node-confirmed lifecycle state of one delegation without
3743
3969
  * exposing delegation metadata.
3744
3970
  */
3745
3971
  status(cid: string): Promise<Result<DelegationStatus>>;
3972
+ /** Query lifecycle-complete delegation history for the authenticated account. */
3973
+ query(options?: AccountDelegationQueryOptions): Promise<Result<AccountDelegationPage>>;
3746
3974
  /**
3747
3975
  * Lists all delegations for the current session's space.
3748
3976
  *
@@ -4783,6 +5011,7 @@ interface AccountServiceConfig {
4783
5011
  getPrimarySpaceId: () => string | undefined;
4784
5012
  getAccountSpaceId: () => string | undefined;
4785
5013
  getSpaces: () => ISpaceService;
5014
+ getDelegationManager?: () => Pick<DelegationManager, "query" | "revoke">;
4786
5015
  getAccountDb?: () => IDatabaseHandle | undefined;
4787
5016
  ensureAccountSpaceHosted?: () => Promise<void>;
4788
5017
  }
@@ -4804,8 +5033,9 @@ declare class AccountService {
4804
5033
  remove: (spaceId: string) => Promise<Result$1<void>>;
4805
5034
  };
4806
5035
  readonly delegations: {
5036
+ query: (options?: AccountDelegationQueryOptions) => Promise<Result$1<AccountDelegationPage>>;
4807
5037
  list: (options?: AccountDelegationListOptions) => Promise<Result$1<AccountDelegation[]>>;
4808
- revoke: (options: AccountDelegationRevokeOptions) => Promise<Result$1<void>>;
5038
+ revoke: (input: string | AccountDelegationRevokeOptions) => Promise<Result$1<DelegationRevocationReceipt | void>>;
4809
5039
  };
4810
5040
  readonly index: {
4811
5041
  ensure: () => Promise<Result$1<AccountIndexEnsureResult>>;
@@ -5070,4 +5300,4 @@ declare const EXPIRY: {
5070
5300
  declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
5071
5301
  type ExpiryTier = keyof typeof EXPIRY;
5072
5302
 
5073
- export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, type AccountApplication, type AccountApplicationListOptions, type AccountDelegation, type AccountDelegationListOptions, 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, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_KNOWLEDGE_ROOT, 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 DelegationStatus, type DidCacheKeyOptions, type DidEqualsOptions, 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, 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 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 ValidationError, VersionCheckError, type WasmRecapEntry, actionContains, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, didCacheKey, didEquals, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, isEvmAddress, loadManifest, locationPayloadForRecord, makePkhSpaceId, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseRecapCapabilities, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveCloudLocation, resolveManifest, resolveManifestKnowledgeRoot, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
5303
+ 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, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_KNOWLEDGE_ROOT, 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, 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, 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 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 ValidationError, VersionCheckError, type WasmRecapEntry, actionContains, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, didCacheKey, didEquals, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, isEvmAddress, loadManifest, locationPayloadForRecord, makePkhSpaceId, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseRecapCapabilities, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveCloudLocation, resolveManifest, resolveManifestKnowledgeRoot, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
package/dist/index.js CHANGED
@@ -3455,6 +3455,43 @@ var DelegationStatusSchema = z4.object({
3455
3455
  });
3456
3456
  }
3457
3457
  });
3458
+ var DelegationRevocationReceiptSchema = z4.object({
3459
+ revoked: z4.literal(true),
3460
+ cid: z4.string().min(1)
3461
+ }).strict();
3462
+ var AccountDelegationResourceSchema = z4.object({
3463
+ resource: z4.string().min(1),
3464
+ actions: z4.array(z4.string()),
3465
+ caveats: z4.array(z4.record(z4.string(), z4.unknown()))
3466
+ }).strict();
3467
+ var AccountDelegationDateSchema = z4.string().datetime({ offset: true }).transform((value) => new Date(value));
3468
+ var AccountDelegationRecordSchema = z4.object({
3469
+ cid: z4.string().min(1),
3470
+ direction: z4.enum(["granted", "received"]),
3471
+ delegatorDid: z4.string().min(1),
3472
+ delegateDid: z4.string().min(1),
3473
+ resources: z4.array(AccountDelegationResourceSchema),
3474
+ parents: z4.array(z4.string()),
3475
+ issuedAt: AccountDelegationDateSchema.nullable(),
3476
+ notBefore: AccountDelegationDateSchema.nullable(),
3477
+ expiresAt: AccountDelegationDateSchema.nullable(),
3478
+ status: z4.enum(["active", "pending", "expired", "revoked", "ancestor_revoked"]),
3479
+ revokedAt: AccountDelegationDateSchema.nullable().optional(),
3480
+ revokedBy: z4.string().optional(),
3481
+ revokedAncestorCid: z4.string().optional()
3482
+ }).strict();
3483
+ var AccountDelegationPageSchema = z4.object({
3484
+ schemaVersion: z4.literal(2),
3485
+ items: z4.array(AccountDelegationRecordSchema),
3486
+ nextCursor: z4.string().optional()
3487
+ }).strict();
3488
+ var AccountDelegationQueryOptionsSchema = z4.object({
3489
+ direction: z4.enum(["granted", "received", "all"]).optional(),
3490
+ status: z4.enum(["active", "pending", "expired", "revoked", "ancestor_revoked"]).optional(),
3491
+ space: z4.string().trim().min(1).optional(),
3492
+ limit: z4.number().int().min(1).max(100).optional(),
3493
+ cursor: z4.string().min(1).optional()
3494
+ }).strict();
3458
3495
  var CapabilityEntrySchema = z4.object({
3459
3496
  /** Resource URI this capability applies to */
3460
3497
  resource: z4.string(),
@@ -3609,6 +3646,8 @@ var GenerateShareParamsSchema = z4.object({
3609
3646
  var DelegationManagerConfigSchema = z4.object({
3610
3647
  /** TinyCloud host URLs */
3611
3648
  hosts: z4.array(z4.string()),
3649
+ /** Account space used by account-wide delegation history queries */
3650
+ accountSpaceId: z4.string().min(1).optional(),
3612
3651
  /** Active session for authentication */
3613
3652
  session: z4.unknown().refine(
3614
3653
  (val) => val !== null && typeof val === "object",
@@ -5898,12 +5937,20 @@ function withCapabilitiesReadForSpaces(resources) {
5898
5937
  ]);
5899
5938
  }
5900
5939
  function accountRegistryPermissions() {
5901
- return [ACCOUNT_REGISTRY_PATH, "spaces/"].map((path) => ({
5902
- service: "tinycloud.kv",
5903
- space: ACCOUNT_REGISTRY_SPACE,
5904
- path,
5905
- actions: ["tinycloud.kv/get", "tinycloud.kv/put", "tinycloud.kv/list"]
5906
- }));
5940
+ return [
5941
+ ...[ACCOUNT_REGISTRY_PATH, "spaces/"].map((path) => ({
5942
+ service: "tinycloud.kv",
5943
+ space: ACCOUNT_REGISTRY_SPACE,
5944
+ path,
5945
+ actions: ["tinycloud.kv/get", "tinycloud.kv/put", "tinycloud.kv/list"]
5946
+ })),
5947
+ {
5948
+ service: "tinycloud.delegation",
5949
+ space: ACCOUNT_REGISTRY_SPACE,
5950
+ path: "",
5951
+ actions: ["tinycloud.delegation/list"]
5952
+ }
5953
+ ];
5907
5954
  }
5908
5955
  function accountRegistryIndexPermission() {
5909
5956
  return {
@@ -6170,6 +6217,18 @@ var AccountService = class {
6170
6217
  }
6171
6218
  };
6172
6219
  this.delegations = {
6220
+ query: async (options = {}) => {
6221
+ const manager = this.config.getDelegationManager?.();
6222
+ if (!manager) {
6223
+ return err3(serviceError3(
6224
+ "NOT_INITIALIZED",
6225
+ "Delegation history requires an authenticated delegation manager",
6226
+ SERVICE_NAME2
6227
+ ));
6228
+ }
6229
+ const queried = await manager.query(options);
6230
+ return queried.ok ? ok3(queried.data) : accountErr(queried.error);
6231
+ },
6173
6232
  list: async (options = {}) => {
6174
6233
  if (options.preferIndex) {
6175
6234
  const indexed = await this.index.delegations.list(options);
@@ -6204,10 +6263,23 @@ var AccountService = class {
6204
6263
  delegations.sort((a, b) => a.spaceId.localeCompare(b.spaceId) || a.cid.localeCompare(b.cid));
6205
6264
  return ok3(delegations);
6206
6265
  },
6207
- revoke: async (options) => {
6208
- const space = await this.resolveSpace(options.space);
6266
+ revoke: async (input) => {
6267
+ const cid = typeof input === "string" ? input : input.cid;
6268
+ const manager = this.config.getDelegationManager?.();
6269
+ if (manager) {
6270
+ const revoked2 = await manager.revoke(cid);
6271
+ return revoked2.ok ? ok3(revoked2.data) : accountErr(revoked2.error);
6272
+ }
6273
+ if (typeof input === "string") {
6274
+ return err3(serviceError3(
6275
+ "NOT_INITIALIZED",
6276
+ "CID-only revocation requires an authenticated delegation manager",
6277
+ SERVICE_NAME2
6278
+ ));
6279
+ }
6280
+ const space = await this.resolveSpace(input.space);
6209
6281
  if (!space.ok) return space;
6210
- const revoked = await this.config.getSpaces().get(space.data.id).delegations.revoke(options.cid);
6282
+ const revoked = await this.config.getSpaces().get(space.data.id).delegations.revoke(cid);
6211
6283
  if (!revoked.ok) return accountErr(revoked.error);
6212
6284
  return ok3(void 0);
6213
6285
  }
@@ -6980,6 +7052,7 @@ var DelegationManager = class {
6980
7052
  this.invoke = config.invoke;
6981
7053
  this.invokeAny = config.invokeAny;
6982
7054
  this.fetchFn = config.fetch ?? globalThis.fetch.bind(globalThis);
7055
+ this.accountSpaceId = config.accountSpaceId;
6983
7056
  }
6984
7057
  /**
6985
7058
  * Updates the session (e.g., after re-authentication).
@@ -7185,7 +7258,19 @@ var DelegationManager = class {
7185
7258
  )
7186
7259
  };
7187
7260
  }
7188
- return { ok: true, data: void 0 };
7261
+ const parsed = DelegationRevocationReceiptSchema.safeParse(await response.json());
7262
+ if (!parsed.success || parsed.data.cid !== cid) {
7263
+ return {
7264
+ ok: false,
7265
+ error: createError(
7266
+ DelegationErrorCodes.REVOCATION_FAILED,
7267
+ "Node returned an invalid delegation revocation receipt",
7268
+ void 0,
7269
+ { cid }
7270
+ )
7271
+ };
7272
+ }
7273
+ return { ok: true, data: parsed.data };
7189
7274
  } catch (error) {
7190
7275
  if (error instanceof Error && error.name === "AbortError") {
7191
7276
  return {
@@ -7282,6 +7367,86 @@ var DelegationManager = class {
7282
7367
  };
7283
7368
  }
7284
7369
  }
7370
+ /** Query lifecycle-complete delegation history for the authenticated account. */
7371
+ async query(options = {}) {
7372
+ const validated = AccountDelegationQueryOptionsSchema.safeParse(options);
7373
+ if (!validated.success) {
7374
+ return {
7375
+ ok: false,
7376
+ error: createError(
7377
+ DelegationErrorCodes.INVALID_INPUT,
7378
+ "Invalid delegation query options",
7379
+ void 0,
7380
+ { issues: validated.error.issues }
7381
+ )
7382
+ };
7383
+ }
7384
+ if (!this.invokeAny) {
7385
+ return {
7386
+ ok: false,
7387
+ error: createError(
7388
+ DelegationErrorCodes.NOT_INITIALIZED,
7389
+ "Delegation query requires an invokeAny function"
7390
+ )
7391
+ };
7392
+ }
7393
+ if (!this.accountSpaceId) {
7394
+ return {
7395
+ ok: false,
7396
+ error: createError(
7397
+ DelegationErrorCodes.NOT_INITIALIZED,
7398
+ "Delegation query requires an account space"
7399
+ )
7400
+ };
7401
+ }
7402
+ try {
7403
+ const invocationHeaders = this.invokeAny(this.session, [{
7404
+ spaceId: this.accountSpaceId,
7405
+ service: "delegation",
7406
+ path: "",
7407
+ action: DelegationAction.LIST
7408
+ }]);
7409
+ const headers = Object.fromEntries(new Headers(invocationHeaders).entries());
7410
+ headers["content-type"] = "application/json";
7411
+ const response = await this.fetchFn(`${this.host}/delegation/query`, {
7412
+ method: "POST",
7413
+ headers,
7414
+ body: JSON.stringify(validated.data)
7415
+ });
7416
+ if (!response.ok) {
7417
+ const errorText = await response.text();
7418
+ return {
7419
+ ok: false,
7420
+ error: createError(
7421
+ DelegationErrorCodes.NETWORK_ERROR,
7422
+ `Failed to query delegations: ${response.status} - ${errorText}`,
7423
+ void 0,
7424
+ { status: response.status }
7425
+ )
7426
+ };
7427
+ }
7428
+ const parsed = AccountDelegationPageSchema.safeParse(await response.json());
7429
+ if (!parsed.success) {
7430
+ return {
7431
+ ok: false,
7432
+ error: createError(
7433
+ DelegationErrorCodes.INVALID_TOKEN,
7434
+ "Node returned an invalid delegation query response"
7435
+ )
7436
+ };
7437
+ }
7438
+ return { ok: true, data: parsed.data };
7439
+ } catch (error) {
7440
+ return {
7441
+ ok: false,
7442
+ error: createError(
7443
+ DelegationErrorCodes.NETWORK_ERROR,
7444
+ `Network error during delegation query: ${String(error)}`,
7445
+ error instanceof Error ? error : void 0
7446
+ )
7447
+ };
7448
+ }
7449
+ }
7285
7450
  /**
7286
7451
  * Lists all delegations for the current session's space.
7287
7452
  *