@tinycloud/sdk-core 2.4.0-beta.1 → 2.4.0-beta.10
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.cjs +2216 -1355
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +200 -59
- package/dist/index.d.ts +200 -59
- package/dist/index.js +2212 -1348
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 } from '@tinycloud/sdk-services';
|
|
2
|
+
import { InvokeFunction, InvokeAnyFunction, ParsedNetworkId, ServiceError, Result as Result$1, ServiceSession, FetchFunction, ServiceConstructor, RetryPolicy, TelemetryConfig, IServiceContext, IService, IKVService, ISQLService, IDuckDbService, IHooksService, IDataVaultService, IEncryptionService, IDatabaseHandle, SqlValue, QueryResponse } from '@tinycloud/sdk-services';
|
|
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, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VerifyDecryptResponseInput, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalHashHex, canonicalSignedResponse, canonicalizeEncryptionJson, canonicalizeSecretScope, checkDecryptInvocationInput, createVaultCrypto, decryptEnvelopeWithKey, defaultRetryPolicy, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, base64Decode as encryptionBase64Decode, base64Encode as encryptionBase64Encode, encryptionError, utf8Decode as encryptionUtf8Decode, utf8Encode as encryptionUtf8Encode, ensureNetworkUsableForDecrypt, err, generateRandomReceiverKey, hexDecode, hexEncode, isNetworkId, networkDiscoveryKey, ok, openWrappedKey, parseNetworkId, resolveSecretListPrefix, resolveSecretPath, serviceError, validateEnvelope, verifyDecryptResponse } from '@tinycloud/sdk-services';
|
|
4
4
|
export { SiweMessage } from 'siwe';
|
|
5
5
|
|
|
@@ -3505,63 +3505,6 @@ declare class TinyCloud {
|
|
|
3505
3505
|
static readPublicKey<T = unknown>(host: string, address: string, chainId: number, key: string, fetchFn?: FetchFunction): Promise<Result$1<T, ServiceError>>;
|
|
3506
3506
|
}
|
|
3507
3507
|
|
|
3508
|
-
/**
|
|
3509
|
-
* Shared space utilities for TinyCloud.
|
|
3510
|
-
*
|
|
3511
|
-
* These functions are platform-agnostic and can be used by both
|
|
3512
|
-
* web-sdk and node-sdk for space hosting and session activation.
|
|
3513
|
-
*/
|
|
3514
|
-
/**
|
|
3515
|
-
* Result of a space hosting or session activation attempt.
|
|
3516
|
-
*/
|
|
3517
|
-
interface SpaceHostResult {
|
|
3518
|
-
/** Whether the operation succeeded (2xx status) */
|
|
3519
|
-
success: boolean;
|
|
3520
|
-
/** HTTP status code */
|
|
3521
|
-
status: number;
|
|
3522
|
-
/** Error message if failed */
|
|
3523
|
-
error?: string;
|
|
3524
|
-
/** Space IDs that were successfully activated */
|
|
3525
|
-
activated?: string[];
|
|
3526
|
-
/** Space IDs that were skipped (e.g., space doesn't exist yet) */
|
|
3527
|
-
skipped?: string[];
|
|
3528
|
-
}
|
|
3529
|
-
/**
|
|
3530
|
-
* Fetch the peer ID from TinyCloud server for space hosting.
|
|
3531
|
-
*
|
|
3532
|
-
* The peer ID identifies the TinyCloud server instance that will host the space.
|
|
3533
|
-
*
|
|
3534
|
-
* @param host - TinyCloud server URL (e.g., "https://node.tinycloud.xyz")
|
|
3535
|
-
* @param spaceId - The space ID to host
|
|
3536
|
-
* @returns The peer ID string
|
|
3537
|
-
* @throws Error if the request fails
|
|
3538
|
-
*/
|
|
3539
|
-
declare function fetchPeerId(host: string, spaceId: string): Promise<string>;
|
|
3540
|
-
/**
|
|
3541
|
-
* Submit a space hosting delegation to TinyCloud server.
|
|
3542
|
-
*
|
|
3543
|
-
* This registers a new space with the server, allowing the user
|
|
3544
|
-
* to store data in it.
|
|
3545
|
-
*
|
|
3546
|
-
* @param host - TinyCloud server URL
|
|
3547
|
-
* @param headers - Delegation headers (from siweToDelegationHeaders)
|
|
3548
|
-
* @returns Result indicating success/failure
|
|
3549
|
-
*/
|
|
3550
|
-
declare function submitHostDelegation(host: string, headers: Record<string, string>): Promise<SpaceHostResult>;
|
|
3551
|
-
/**
|
|
3552
|
-
* Activate a session with TinyCloud server.
|
|
3553
|
-
*
|
|
3554
|
-
* This submits the session delegation to the server, enabling the session
|
|
3555
|
-
* key to perform operations on behalf of the user.
|
|
3556
|
-
*
|
|
3557
|
-
* @param host - TinyCloud server URL
|
|
3558
|
-
* @param delegationHeader - Session delegation header (from session.delegationHeader)
|
|
3559
|
-
* @returns Result indicating success/failure (404 means space doesn't exist)
|
|
3560
|
-
*/
|
|
3561
|
-
declare function activateSessionWithHost(host: string, delegationHeader: {
|
|
3562
|
-
Authorization: string;
|
|
3563
|
-
}): Promise<SpaceHostResult>;
|
|
3564
|
-
|
|
3565
3508
|
/**
|
|
3566
3509
|
* DelegationManager - Handles delegation CRUD operations.
|
|
3567
3510
|
*
|
|
@@ -4312,6 +4255,8 @@ interface SpaceServiceConfig {
|
|
|
4312
4255
|
* Required for space.delegations.create() to work.
|
|
4313
4256
|
*/
|
|
4314
4257
|
createDelegation?: CreateDelegationFunction;
|
|
4258
|
+
/** Optional best-effort hook after the SDK discovers or creates a space. */
|
|
4259
|
+
onSpaceRegistered?: (space: SpaceInfo) => void | Promise<void>;
|
|
4315
4260
|
}
|
|
4316
4261
|
/**
|
|
4317
4262
|
* Interface for SpaceService.
|
|
@@ -4432,6 +4377,7 @@ declare class SpaceService implements ISpaceService {
|
|
|
4432
4377
|
private _userDid?;
|
|
4433
4378
|
private sharingService?;
|
|
4434
4379
|
private createDelegationFn?;
|
|
4380
|
+
private onSpaceRegisteredFn?;
|
|
4435
4381
|
/** Cache of created Space objects */
|
|
4436
4382
|
private spaceCache;
|
|
4437
4383
|
/** Cache of space info */
|
|
@@ -4489,6 +4435,7 @@ declare class SpaceService implements ISpaceService {
|
|
|
4489
4435
|
* @param name - The name for the new space
|
|
4490
4436
|
*/
|
|
4491
4437
|
create(name: string): Promise<Result$1<SpaceInfo, ServiceError>>;
|
|
4438
|
+
private notifySpaceRegistered;
|
|
4492
4439
|
/**
|
|
4493
4440
|
* Get a Space object by name or full URI.
|
|
4494
4441
|
*
|
|
@@ -4535,6 +4482,200 @@ declare class SpaceService implements ISpaceService {
|
|
|
4535
4482
|
*/
|
|
4536
4483
|
declare function createSpaceService(config: SpaceServiceConfig): ISpaceService;
|
|
4537
4484
|
|
|
4485
|
+
interface AccountApplication {
|
|
4486
|
+
appId: string;
|
|
4487
|
+
manifests: Manifest[];
|
|
4488
|
+
updatedAt?: string;
|
|
4489
|
+
name?: string;
|
|
4490
|
+
description?: string;
|
|
4491
|
+
manifestHash?: string;
|
|
4492
|
+
}
|
|
4493
|
+
interface AccountSpace {
|
|
4494
|
+
spaceId: string;
|
|
4495
|
+
name: string;
|
|
4496
|
+
ownerDid: string;
|
|
4497
|
+
type: "owned" | "delegated" | "discovered";
|
|
4498
|
+
permissions: string[];
|
|
4499
|
+
status: "active" | "archived";
|
|
4500
|
+
registeredAt?: string;
|
|
4501
|
+
updatedAt?: string;
|
|
4502
|
+
expiresAt?: Date;
|
|
4503
|
+
}
|
|
4504
|
+
interface AccountDelegation {
|
|
4505
|
+
cid: string;
|
|
4506
|
+
direction: "granted" | "received";
|
|
4507
|
+
spaceId: string;
|
|
4508
|
+
spaceName?: string;
|
|
4509
|
+
counterpartyDid: string;
|
|
4510
|
+
delegateDid: string;
|
|
4511
|
+
delegatorDid?: string;
|
|
4512
|
+
path: string;
|
|
4513
|
+
actions: string[];
|
|
4514
|
+
expiry: Date;
|
|
4515
|
+
status: "active" | "expired" | "revoked";
|
|
4516
|
+
createdAt?: Date;
|
|
4517
|
+
}
|
|
4518
|
+
interface AccountStatus {
|
|
4519
|
+
did: string;
|
|
4520
|
+
host: string;
|
|
4521
|
+
primarySpaceId?: string;
|
|
4522
|
+
accountSpaceId?: string;
|
|
4523
|
+
applications: number;
|
|
4524
|
+
spaces: number;
|
|
4525
|
+
grantedDelegations: number;
|
|
4526
|
+
receivedDelegations: number;
|
|
4527
|
+
}
|
|
4528
|
+
interface AccountIndexRebuildResult {
|
|
4529
|
+
database: string;
|
|
4530
|
+
applications: number;
|
|
4531
|
+
spaces: number;
|
|
4532
|
+
delegations: number;
|
|
4533
|
+
syncedAt: string;
|
|
4534
|
+
}
|
|
4535
|
+
interface AccountIndexedReadOptions {
|
|
4536
|
+
preferIndex?: boolean;
|
|
4537
|
+
refreshIndex?: boolean;
|
|
4538
|
+
}
|
|
4539
|
+
type AccountApplicationListOptions = AccountIndexedReadOptions;
|
|
4540
|
+
type AccountSpaceListOptions = AccountIndexedReadOptions;
|
|
4541
|
+
interface AccountDelegationListOptions {
|
|
4542
|
+
direction?: "granted" | "received" | "all";
|
|
4543
|
+
space?: string;
|
|
4544
|
+
preferIndex?: boolean;
|
|
4545
|
+
refreshIndex?: boolean;
|
|
4546
|
+
}
|
|
4547
|
+
interface AccountDelegationRevokeOptions {
|
|
4548
|
+
cid: string;
|
|
4549
|
+
space: string;
|
|
4550
|
+
}
|
|
4551
|
+
interface AccountServiceConfig {
|
|
4552
|
+
getDid: () => string;
|
|
4553
|
+
getHost: () => string;
|
|
4554
|
+
getPrimarySpaceId: () => string | undefined;
|
|
4555
|
+
getAccountSpaceId: () => string | undefined;
|
|
4556
|
+
getSpaces: () => ISpaceService;
|
|
4557
|
+
getAccountDb?: () => IDatabaseHandle | undefined;
|
|
4558
|
+
ensureAccountSpaceHosted?: () => Promise<void>;
|
|
4559
|
+
}
|
|
4560
|
+
declare class AccountService {
|
|
4561
|
+
private readonly config;
|
|
4562
|
+
constructor(config: AccountServiceConfig);
|
|
4563
|
+
status(): Promise<Result$1<AccountStatus>>;
|
|
4564
|
+
readonly applications: {
|
|
4565
|
+
list: (options?: AccountApplicationListOptions) => Promise<Result$1<AccountApplication[]>>;
|
|
4566
|
+
get: (appId: string) => Promise<Result$1<AccountApplication>>;
|
|
4567
|
+
register: (manifest: Manifest | Manifest[]) => Promise<Result$1<AccountApplication>>;
|
|
4568
|
+
remove: (appId: string) => Promise<Result$1<void>>;
|
|
4569
|
+
};
|
|
4570
|
+
readonly spaces: {
|
|
4571
|
+
list: (options?: AccountSpaceListOptions) => Promise<Result$1<AccountSpace[]>>;
|
|
4572
|
+
get: (spaceId: string) => Promise<Result$1<AccountSpace>>;
|
|
4573
|
+
register: (space: SpaceInfo | AccountSpace) => Promise<Result$1<AccountSpace>>;
|
|
4574
|
+
syncAccessible: () => Promise<Result$1<AccountSpace[]>>;
|
|
4575
|
+
remove: (spaceId: string) => Promise<Result$1<void>>;
|
|
4576
|
+
};
|
|
4577
|
+
readonly delegations: {
|
|
4578
|
+
list: (options?: AccountDelegationListOptions) => Promise<Result$1<AccountDelegation[]>>;
|
|
4579
|
+
revoke: (options: AccountDelegationRevokeOptions) => Promise<Result$1<void>>;
|
|
4580
|
+
};
|
|
4581
|
+
readonly index: {
|
|
4582
|
+
rebuild: () => Promise<Result$1<AccountIndexRebuildResult>>;
|
|
4583
|
+
applications: {
|
|
4584
|
+
list: () => Promise<Result$1<AccountApplication[]>>;
|
|
4585
|
+
};
|
|
4586
|
+
spaces: {
|
|
4587
|
+
list: () => Promise<Result$1<AccountSpace[]>>;
|
|
4588
|
+
};
|
|
4589
|
+
delegations: {
|
|
4590
|
+
list: (options?: AccountDelegationListOptions) => Promise<Result$1<AccountDelegation[]>>;
|
|
4591
|
+
};
|
|
4592
|
+
query: <T = Record<string, unknown>>(sql: string, params?: SqlValue[]) => Promise<Result$1<QueryResponse<T>>>;
|
|
4593
|
+
status: () => Promise<Result$1<AccountIndexStatus>>;
|
|
4594
|
+
};
|
|
4595
|
+
private accountKV;
|
|
4596
|
+
private accountDb;
|
|
4597
|
+
private indexHasApplicationHash;
|
|
4598
|
+
private upsertApplicationIndexQuietly;
|
|
4599
|
+
private upsertApplicationIndex;
|
|
4600
|
+
private deleteApplicationIndexQuietly;
|
|
4601
|
+
private deleteApplicationIndex;
|
|
4602
|
+
private upsertSpaceIndexQuietly;
|
|
4603
|
+
private upsertSpaceIndex;
|
|
4604
|
+
private deleteSpaceIndexQuietly;
|
|
4605
|
+
private deleteSpaceIndex;
|
|
4606
|
+
private resolveSpace;
|
|
4607
|
+
private replaceApplicationsIndexQuietly;
|
|
4608
|
+
private replaceSpacesIndexQuietly;
|
|
4609
|
+
private replaceDelegationsIndexQuietly;
|
|
4610
|
+
private ensureAccountIndex;
|
|
4611
|
+
}
|
|
4612
|
+
interface AccountIndexStatus {
|
|
4613
|
+
database: string;
|
|
4614
|
+
state: "ready" | "missing";
|
|
4615
|
+
sources: Array<{
|
|
4616
|
+
source: string;
|
|
4617
|
+
syncedAt: string;
|
|
4618
|
+
count: number;
|
|
4619
|
+
}>;
|
|
4620
|
+
}
|
|
4621
|
+
|
|
4622
|
+
/**
|
|
4623
|
+
* Shared space utilities for TinyCloud.
|
|
4624
|
+
*
|
|
4625
|
+
* These functions are platform-agnostic and can be used by both
|
|
4626
|
+
* web-sdk and node-sdk for space hosting and session activation.
|
|
4627
|
+
*/
|
|
4628
|
+
/**
|
|
4629
|
+
* Result of a space hosting or session activation attempt.
|
|
4630
|
+
*/
|
|
4631
|
+
interface SpaceHostResult {
|
|
4632
|
+
/** Whether the operation succeeded (2xx status) */
|
|
4633
|
+
success: boolean;
|
|
4634
|
+
/** HTTP status code */
|
|
4635
|
+
status: number;
|
|
4636
|
+
/** Error message if failed */
|
|
4637
|
+
error?: string;
|
|
4638
|
+
/** Space IDs that were successfully activated */
|
|
4639
|
+
activated?: string[];
|
|
4640
|
+
/** Space IDs that were skipped (e.g., space doesn't exist yet) */
|
|
4641
|
+
skipped?: string[];
|
|
4642
|
+
}
|
|
4643
|
+
/**
|
|
4644
|
+
* Fetch the peer ID from TinyCloud server for space hosting.
|
|
4645
|
+
*
|
|
4646
|
+
* The peer ID identifies the TinyCloud server instance that will host the space.
|
|
4647
|
+
*
|
|
4648
|
+
* @param host - TinyCloud server URL (e.g., "https://node.tinycloud.xyz")
|
|
4649
|
+
* @param spaceId - The space ID to host
|
|
4650
|
+
* @returns The peer ID string
|
|
4651
|
+
* @throws Error if the request fails
|
|
4652
|
+
*/
|
|
4653
|
+
declare function fetchPeerId(host: string, spaceId: string): Promise<string>;
|
|
4654
|
+
/**
|
|
4655
|
+
* Submit a space hosting delegation to TinyCloud server.
|
|
4656
|
+
*
|
|
4657
|
+
* This registers a new space with the server, allowing the user
|
|
4658
|
+
* to store data in it.
|
|
4659
|
+
*
|
|
4660
|
+
* @param host - TinyCloud server URL
|
|
4661
|
+
* @param headers - Delegation headers (from siweToDelegationHeaders)
|
|
4662
|
+
* @returns Result indicating success/failure
|
|
4663
|
+
*/
|
|
4664
|
+
declare function submitHostDelegation(host: string, headers: Record<string, string>): Promise<SpaceHostResult>;
|
|
4665
|
+
/**
|
|
4666
|
+
* Activate a session with TinyCloud server.
|
|
4667
|
+
*
|
|
4668
|
+
* This submits the session delegation to the server, enabling the session
|
|
4669
|
+
* key to perform operations on behalf of the user.
|
|
4670
|
+
*
|
|
4671
|
+
* @param host - TinyCloud server URL
|
|
4672
|
+
* @param delegationHeader - Session delegation header (from session.delegationHeader)
|
|
4673
|
+
* @returns Result indicating success/failure (404 means space doesn't exist)
|
|
4674
|
+
*/
|
|
4675
|
+
declare function activateSessionWithHost(host: string, delegationHeader: {
|
|
4676
|
+
Authorization: string;
|
|
4677
|
+
}): Promise<SpaceHostResult>;
|
|
4678
|
+
|
|
4538
4679
|
/**
|
|
4539
4680
|
* Protocol version checking for SDK-to-node compatibility.
|
|
4540
4681
|
*
|
|
@@ -4697,4 +4838,4 @@ declare const EXPIRY: {
|
|
|
4697
4838
|
declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
|
|
4698
4839
|
type ExpiryTier = keyof typeof EXPIRY;
|
|
4699
4840
|
|
|
4700
|
-
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, 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_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, 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 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 ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, 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, 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, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, 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, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
|
|
4841
|
+
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, type AccountApplication, type AccountApplicationListOptions, type AccountDelegation, type AccountDelegationListOptions, type AccountDelegationRevokeOptions, 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_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, 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 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 ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, 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, 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, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, 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, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 } from '@tinycloud/sdk-services';
|
|
2
|
+
import { InvokeFunction, InvokeAnyFunction, ParsedNetworkId, ServiceError, Result as Result$1, ServiceSession, FetchFunction, ServiceConstructor, RetryPolicy, TelemetryConfig, IServiceContext, IService, IKVService, ISQLService, IDuckDbService, IHooksService, IDataVaultService, IEncryptionService, IDatabaseHandle, SqlValue, QueryResponse } from '@tinycloud/sdk-services';
|
|
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, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VerifyDecryptResponseInput, ViewInfo, WasmVaultFunctions, WellKnownDescriptorFetcher, buildCanonicalDecryptRequest, buildDecryptAttenuation, buildDecryptFacts, buildDecryptInvocation, buildNetworkId, canonicalHashHex, canonicalSignedResponse, canonicalizeEncryptionJson, canonicalizeSecretScope, checkDecryptInvocationInput, createVaultCrypto, decryptEnvelopeWithKey, defaultRetryPolicy, deriveSignedReceiverKey, discoverNetwork, encryptToNetwork, base64Decode as encryptionBase64Decode, base64Encode as encryptionBase64Encode, encryptionError, utf8Decode as encryptionUtf8Decode, utf8Encode as encryptionUtf8Encode, ensureNetworkUsableForDecrypt, err, generateRandomReceiverKey, hexDecode, hexEncode, isNetworkId, networkDiscoveryKey, ok, openWrappedKey, parseNetworkId, resolveSecretListPrefix, resolveSecretPath, serviceError, validateEnvelope, verifyDecryptResponse } from '@tinycloud/sdk-services';
|
|
4
4
|
export { SiweMessage } from 'siwe';
|
|
5
5
|
|
|
@@ -3505,63 +3505,6 @@ declare class TinyCloud {
|
|
|
3505
3505
|
static readPublicKey<T = unknown>(host: string, address: string, chainId: number, key: string, fetchFn?: FetchFunction): Promise<Result$1<T, ServiceError>>;
|
|
3506
3506
|
}
|
|
3507
3507
|
|
|
3508
|
-
/**
|
|
3509
|
-
* Shared space utilities for TinyCloud.
|
|
3510
|
-
*
|
|
3511
|
-
* These functions are platform-agnostic and can be used by both
|
|
3512
|
-
* web-sdk and node-sdk for space hosting and session activation.
|
|
3513
|
-
*/
|
|
3514
|
-
/**
|
|
3515
|
-
* Result of a space hosting or session activation attempt.
|
|
3516
|
-
*/
|
|
3517
|
-
interface SpaceHostResult {
|
|
3518
|
-
/** Whether the operation succeeded (2xx status) */
|
|
3519
|
-
success: boolean;
|
|
3520
|
-
/** HTTP status code */
|
|
3521
|
-
status: number;
|
|
3522
|
-
/** Error message if failed */
|
|
3523
|
-
error?: string;
|
|
3524
|
-
/** Space IDs that were successfully activated */
|
|
3525
|
-
activated?: string[];
|
|
3526
|
-
/** Space IDs that were skipped (e.g., space doesn't exist yet) */
|
|
3527
|
-
skipped?: string[];
|
|
3528
|
-
}
|
|
3529
|
-
/**
|
|
3530
|
-
* Fetch the peer ID from TinyCloud server for space hosting.
|
|
3531
|
-
*
|
|
3532
|
-
* The peer ID identifies the TinyCloud server instance that will host the space.
|
|
3533
|
-
*
|
|
3534
|
-
* @param host - TinyCloud server URL (e.g., "https://node.tinycloud.xyz")
|
|
3535
|
-
* @param spaceId - The space ID to host
|
|
3536
|
-
* @returns The peer ID string
|
|
3537
|
-
* @throws Error if the request fails
|
|
3538
|
-
*/
|
|
3539
|
-
declare function fetchPeerId(host: string, spaceId: string): Promise<string>;
|
|
3540
|
-
/**
|
|
3541
|
-
* Submit a space hosting delegation to TinyCloud server.
|
|
3542
|
-
*
|
|
3543
|
-
* This registers a new space with the server, allowing the user
|
|
3544
|
-
* to store data in it.
|
|
3545
|
-
*
|
|
3546
|
-
* @param host - TinyCloud server URL
|
|
3547
|
-
* @param headers - Delegation headers (from siweToDelegationHeaders)
|
|
3548
|
-
* @returns Result indicating success/failure
|
|
3549
|
-
*/
|
|
3550
|
-
declare function submitHostDelegation(host: string, headers: Record<string, string>): Promise<SpaceHostResult>;
|
|
3551
|
-
/**
|
|
3552
|
-
* Activate a session with TinyCloud server.
|
|
3553
|
-
*
|
|
3554
|
-
* This submits the session delegation to the server, enabling the session
|
|
3555
|
-
* key to perform operations on behalf of the user.
|
|
3556
|
-
*
|
|
3557
|
-
* @param host - TinyCloud server URL
|
|
3558
|
-
* @param delegationHeader - Session delegation header (from session.delegationHeader)
|
|
3559
|
-
* @returns Result indicating success/failure (404 means space doesn't exist)
|
|
3560
|
-
*/
|
|
3561
|
-
declare function activateSessionWithHost(host: string, delegationHeader: {
|
|
3562
|
-
Authorization: string;
|
|
3563
|
-
}): Promise<SpaceHostResult>;
|
|
3564
|
-
|
|
3565
3508
|
/**
|
|
3566
3509
|
* DelegationManager - Handles delegation CRUD operations.
|
|
3567
3510
|
*
|
|
@@ -4312,6 +4255,8 @@ interface SpaceServiceConfig {
|
|
|
4312
4255
|
* Required for space.delegations.create() to work.
|
|
4313
4256
|
*/
|
|
4314
4257
|
createDelegation?: CreateDelegationFunction;
|
|
4258
|
+
/** Optional best-effort hook after the SDK discovers or creates a space. */
|
|
4259
|
+
onSpaceRegistered?: (space: SpaceInfo) => void | Promise<void>;
|
|
4315
4260
|
}
|
|
4316
4261
|
/**
|
|
4317
4262
|
* Interface for SpaceService.
|
|
@@ -4432,6 +4377,7 @@ declare class SpaceService implements ISpaceService {
|
|
|
4432
4377
|
private _userDid?;
|
|
4433
4378
|
private sharingService?;
|
|
4434
4379
|
private createDelegationFn?;
|
|
4380
|
+
private onSpaceRegisteredFn?;
|
|
4435
4381
|
/** Cache of created Space objects */
|
|
4436
4382
|
private spaceCache;
|
|
4437
4383
|
/** Cache of space info */
|
|
@@ -4489,6 +4435,7 @@ declare class SpaceService implements ISpaceService {
|
|
|
4489
4435
|
* @param name - The name for the new space
|
|
4490
4436
|
*/
|
|
4491
4437
|
create(name: string): Promise<Result$1<SpaceInfo, ServiceError>>;
|
|
4438
|
+
private notifySpaceRegistered;
|
|
4492
4439
|
/**
|
|
4493
4440
|
* Get a Space object by name or full URI.
|
|
4494
4441
|
*
|
|
@@ -4535,6 +4482,200 @@ declare class SpaceService implements ISpaceService {
|
|
|
4535
4482
|
*/
|
|
4536
4483
|
declare function createSpaceService(config: SpaceServiceConfig): ISpaceService;
|
|
4537
4484
|
|
|
4485
|
+
interface AccountApplication {
|
|
4486
|
+
appId: string;
|
|
4487
|
+
manifests: Manifest[];
|
|
4488
|
+
updatedAt?: string;
|
|
4489
|
+
name?: string;
|
|
4490
|
+
description?: string;
|
|
4491
|
+
manifestHash?: string;
|
|
4492
|
+
}
|
|
4493
|
+
interface AccountSpace {
|
|
4494
|
+
spaceId: string;
|
|
4495
|
+
name: string;
|
|
4496
|
+
ownerDid: string;
|
|
4497
|
+
type: "owned" | "delegated" | "discovered";
|
|
4498
|
+
permissions: string[];
|
|
4499
|
+
status: "active" | "archived";
|
|
4500
|
+
registeredAt?: string;
|
|
4501
|
+
updatedAt?: string;
|
|
4502
|
+
expiresAt?: Date;
|
|
4503
|
+
}
|
|
4504
|
+
interface AccountDelegation {
|
|
4505
|
+
cid: string;
|
|
4506
|
+
direction: "granted" | "received";
|
|
4507
|
+
spaceId: string;
|
|
4508
|
+
spaceName?: string;
|
|
4509
|
+
counterpartyDid: string;
|
|
4510
|
+
delegateDid: string;
|
|
4511
|
+
delegatorDid?: string;
|
|
4512
|
+
path: string;
|
|
4513
|
+
actions: string[];
|
|
4514
|
+
expiry: Date;
|
|
4515
|
+
status: "active" | "expired" | "revoked";
|
|
4516
|
+
createdAt?: Date;
|
|
4517
|
+
}
|
|
4518
|
+
interface AccountStatus {
|
|
4519
|
+
did: string;
|
|
4520
|
+
host: string;
|
|
4521
|
+
primarySpaceId?: string;
|
|
4522
|
+
accountSpaceId?: string;
|
|
4523
|
+
applications: number;
|
|
4524
|
+
spaces: number;
|
|
4525
|
+
grantedDelegations: number;
|
|
4526
|
+
receivedDelegations: number;
|
|
4527
|
+
}
|
|
4528
|
+
interface AccountIndexRebuildResult {
|
|
4529
|
+
database: string;
|
|
4530
|
+
applications: number;
|
|
4531
|
+
spaces: number;
|
|
4532
|
+
delegations: number;
|
|
4533
|
+
syncedAt: string;
|
|
4534
|
+
}
|
|
4535
|
+
interface AccountIndexedReadOptions {
|
|
4536
|
+
preferIndex?: boolean;
|
|
4537
|
+
refreshIndex?: boolean;
|
|
4538
|
+
}
|
|
4539
|
+
type AccountApplicationListOptions = AccountIndexedReadOptions;
|
|
4540
|
+
type AccountSpaceListOptions = AccountIndexedReadOptions;
|
|
4541
|
+
interface AccountDelegationListOptions {
|
|
4542
|
+
direction?: "granted" | "received" | "all";
|
|
4543
|
+
space?: string;
|
|
4544
|
+
preferIndex?: boolean;
|
|
4545
|
+
refreshIndex?: boolean;
|
|
4546
|
+
}
|
|
4547
|
+
interface AccountDelegationRevokeOptions {
|
|
4548
|
+
cid: string;
|
|
4549
|
+
space: string;
|
|
4550
|
+
}
|
|
4551
|
+
interface AccountServiceConfig {
|
|
4552
|
+
getDid: () => string;
|
|
4553
|
+
getHost: () => string;
|
|
4554
|
+
getPrimarySpaceId: () => string | undefined;
|
|
4555
|
+
getAccountSpaceId: () => string | undefined;
|
|
4556
|
+
getSpaces: () => ISpaceService;
|
|
4557
|
+
getAccountDb?: () => IDatabaseHandle | undefined;
|
|
4558
|
+
ensureAccountSpaceHosted?: () => Promise<void>;
|
|
4559
|
+
}
|
|
4560
|
+
declare class AccountService {
|
|
4561
|
+
private readonly config;
|
|
4562
|
+
constructor(config: AccountServiceConfig);
|
|
4563
|
+
status(): Promise<Result$1<AccountStatus>>;
|
|
4564
|
+
readonly applications: {
|
|
4565
|
+
list: (options?: AccountApplicationListOptions) => Promise<Result$1<AccountApplication[]>>;
|
|
4566
|
+
get: (appId: string) => Promise<Result$1<AccountApplication>>;
|
|
4567
|
+
register: (manifest: Manifest | Manifest[]) => Promise<Result$1<AccountApplication>>;
|
|
4568
|
+
remove: (appId: string) => Promise<Result$1<void>>;
|
|
4569
|
+
};
|
|
4570
|
+
readonly spaces: {
|
|
4571
|
+
list: (options?: AccountSpaceListOptions) => Promise<Result$1<AccountSpace[]>>;
|
|
4572
|
+
get: (spaceId: string) => Promise<Result$1<AccountSpace>>;
|
|
4573
|
+
register: (space: SpaceInfo | AccountSpace) => Promise<Result$1<AccountSpace>>;
|
|
4574
|
+
syncAccessible: () => Promise<Result$1<AccountSpace[]>>;
|
|
4575
|
+
remove: (spaceId: string) => Promise<Result$1<void>>;
|
|
4576
|
+
};
|
|
4577
|
+
readonly delegations: {
|
|
4578
|
+
list: (options?: AccountDelegationListOptions) => Promise<Result$1<AccountDelegation[]>>;
|
|
4579
|
+
revoke: (options: AccountDelegationRevokeOptions) => Promise<Result$1<void>>;
|
|
4580
|
+
};
|
|
4581
|
+
readonly index: {
|
|
4582
|
+
rebuild: () => Promise<Result$1<AccountIndexRebuildResult>>;
|
|
4583
|
+
applications: {
|
|
4584
|
+
list: () => Promise<Result$1<AccountApplication[]>>;
|
|
4585
|
+
};
|
|
4586
|
+
spaces: {
|
|
4587
|
+
list: () => Promise<Result$1<AccountSpace[]>>;
|
|
4588
|
+
};
|
|
4589
|
+
delegations: {
|
|
4590
|
+
list: (options?: AccountDelegationListOptions) => Promise<Result$1<AccountDelegation[]>>;
|
|
4591
|
+
};
|
|
4592
|
+
query: <T = Record<string, unknown>>(sql: string, params?: SqlValue[]) => Promise<Result$1<QueryResponse<T>>>;
|
|
4593
|
+
status: () => Promise<Result$1<AccountIndexStatus>>;
|
|
4594
|
+
};
|
|
4595
|
+
private accountKV;
|
|
4596
|
+
private accountDb;
|
|
4597
|
+
private indexHasApplicationHash;
|
|
4598
|
+
private upsertApplicationIndexQuietly;
|
|
4599
|
+
private upsertApplicationIndex;
|
|
4600
|
+
private deleteApplicationIndexQuietly;
|
|
4601
|
+
private deleteApplicationIndex;
|
|
4602
|
+
private upsertSpaceIndexQuietly;
|
|
4603
|
+
private upsertSpaceIndex;
|
|
4604
|
+
private deleteSpaceIndexQuietly;
|
|
4605
|
+
private deleteSpaceIndex;
|
|
4606
|
+
private resolveSpace;
|
|
4607
|
+
private replaceApplicationsIndexQuietly;
|
|
4608
|
+
private replaceSpacesIndexQuietly;
|
|
4609
|
+
private replaceDelegationsIndexQuietly;
|
|
4610
|
+
private ensureAccountIndex;
|
|
4611
|
+
}
|
|
4612
|
+
interface AccountIndexStatus {
|
|
4613
|
+
database: string;
|
|
4614
|
+
state: "ready" | "missing";
|
|
4615
|
+
sources: Array<{
|
|
4616
|
+
source: string;
|
|
4617
|
+
syncedAt: string;
|
|
4618
|
+
count: number;
|
|
4619
|
+
}>;
|
|
4620
|
+
}
|
|
4621
|
+
|
|
4622
|
+
/**
|
|
4623
|
+
* Shared space utilities for TinyCloud.
|
|
4624
|
+
*
|
|
4625
|
+
* These functions are platform-agnostic and can be used by both
|
|
4626
|
+
* web-sdk and node-sdk for space hosting and session activation.
|
|
4627
|
+
*/
|
|
4628
|
+
/**
|
|
4629
|
+
* Result of a space hosting or session activation attempt.
|
|
4630
|
+
*/
|
|
4631
|
+
interface SpaceHostResult {
|
|
4632
|
+
/** Whether the operation succeeded (2xx status) */
|
|
4633
|
+
success: boolean;
|
|
4634
|
+
/** HTTP status code */
|
|
4635
|
+
status: number;
|
|
4636
|
+
/** Error message if failed */
|
|
4637
|
+
error?: string;
|
|
4638
|
+
/** Space IDs that were successfully activated */
|
|
4639
|
+
activated?: string[];
|
|
4640
|
+
/** Space IDs that were skipped (e.g., space doesn't exist yet) */
|
|
4641
|
+
skipped?: string[];
|
|
4642
|
+
}
|
|
4643
|
+
/**
|
|
4644
|
+
* Fetch the peer ID from TinyCloud server for space hosting.
|
|
4645
|
+
*
|
|
4646
|
+
* The peer ID identifies the TinyCloud server instance that will host the space.
|
|
4647
|
+
*
|
|
4648
|
+
* @param host - TinyCloud server URL (e.g., "https://node.tinycloud.xyz")
|
|
4649
|
+
* @param spaceId - The space ID to host
|
|
4650
|
+
* @returns The peer ID string
|
|
4651
|
+
* @throws Error if the request fails
|
|
4652
|
+
*/
|
|
4653
|
+
declare function fetchPeerId(host: string, spaceId: string): Promise<string>;
|
|
4654
|
+
/**
|
|
4655
|
+
* Submit a space hosting delegation to TinyCloud server.
|
|
4656
|
+
*
|
|
4657
|
+
* This registers a new space with the server, allowing the user
|
|
4658
|
+
* to store data in it.
|
|
4659
|
+
*
|
|
4660
|
+
* @param host - TinyCloud server URL
|
|
4661
|
+
* @param headers - Delegation headers (from siweToDelegationHeaders)
|
|
4662
|
+
* @returns Result indicating success/failure
|
|
4663
|
+
*/
|
|
4664
|
+
declare function submitHostDelegation(host: string, headers: Record<string, string>): Promise<SpaceHostResult>;
|
|
4665
|
+
/**
|
|
4666
|
+
* Activate a session with TinyCloud server.
|
|
4667
|
+
*
|
|
4668
|
+
* This submits the session delegation to the server, enabling the session
|
|
4669
|
+
* key to perform operations on behalf of the user.
|
|
4670
|
+
*
|
|
4671
|
+
* @param host - TinyCloud server URL
|
|
4672
|
+
* @param delegationHeader - Session delegation header (from session.delegationHeader)
|
|
4673
|
+
* @returns Result indicating success/failure (404 means space doesn't exist)
|
|
4674
|
+
*/
|
|
4675
|
+
declare function activateSessionWithHost(host: string, delegationHeader: {
|
|
4676
|
+
Authorization: string;
|
|
4677
|
+
}): Promise<SpaceHostResult>;
|
|
4678
|
+
|
|
4538
4679
|
/**
|
|
4539
4680
|
* Protocol version checking for SDK-to-node compatibility.
|
|
4540
4681
|
*
|
|
@@ -4697,4 +4838,4 @@ declare const EXPIRY: {
|
|
|
4697
4838
|
declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
|
|
4698
4839
|
type ExpiryTier = keyof typeof EXPIRY;
|
|
4699
4840
|
|
|
4700
|
-
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, 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_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, 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 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 ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, 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, 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, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, 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, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
|
|
4841
|
+
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, type AccountApplication, type AccountApplicationListOptions, type AccountDelegation, type AccountDelegationListOptions, type AccountDelegationRevokeOptions, 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_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, 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 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 ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, 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, 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, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, 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, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
|