@tinycloud/sdk-core 2.4.0-beta.7 → 2.4.0-beta.9
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 +160 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +160 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -4532,9 +4532,17 @@ interface AccountIndexRebuildResult {
|
|
|
4532
4532
|
delegations: number;
|
|
4533
4533
|
syncedAt: string;
|
|
4534
4534
|
}
|
|
4535
|
+
interface AccountIndexedReadOptions {
|
|
4536
|
+
preferIndex?: boolean;
|
|
4537
|
+
refreshIndex?: boolean;
|
|
4538
|
+
}
|
|
4539
|
+
type AccountApplicationListOptions = AccountIndexedReadOptions;
|
|
4540
|
+
type AccountSpaceListOptions = AccountIndexedReadOptions;
|
|
4535
4541
|
interface AccountDelegationListOptions {
|
|
4536
4542
|
direction?: "granted" | "received" | "all";
|
|
4537
4543
|
space?: string;
|
|
4544
|
+
preferIndex?: boolean;
|
|
4545
|
+
refreshIndex?: boolean;
|
|
4538
4546
|
}
|
|
4539
4547
|
interface AccountDelegationRevokeOptions {
|
|
4540
4548
|
cid: string;
|
|
@@ -4554,13 +4562,13 @@ declare class AccountService {
|
|
|
4554
4562
|
constructor(config: AccountServiceConfig);
|
|
4555
4563
|
status(): Promise<Result$1<AccountStatus>>;
|
|
4556
4564
|
readonly applications: {
|
|
4557
|
-
list: () => Promise<Result$1<AccountApplication[]>>;
|
|
4565
|
+
list: (options?: AccountApplicationListOptions) => Promise<Result$1<AccountApplication[]>>;
|
|
4558
4566
|
get: (appId: string) => Promise<Result$1<AccountApplication>>;
|
|
4559
4567
|
register: (manifest: Manifest | Manifest[]) => Promise<Result$1<AccountApplication>>;
|
|
4560
4568
|
remove: (appId: string) => Promise<Result$1<void>>;
|
|
4561
4569
|
};
|
|
4562
4570
|
readonly spaces: {
|
|
4563
|
-
list: () => Promise<Result$1<AccountSpace[]>>;
|
|
4571
|
+
list: (options?: AccountSpaceListOptions) => Promise<Result$1<AccountSpace[]>>;
|
|
4564
4572
|
get: (spaceId: string) => Promise<Result$1<AccountSpace>>;
|
|
4565
4573
|
register: (space: SpaceInfo | AccountSpace) => Promise<Result$1<AccountSpace>>;
|
|
4566
4574
|
syncAccessible: () => Promise<Result$1<AccountSpace[]>>;
|
|
@@ -4587,14 +4595,22 @@ declare class AccountService {
|
|
|
4587
4595
|
private accountKV;
|
|
4588
4596
|
private accountDb;
|
|
4589
4597
|
private indexHasApplicationHash;
|
|
4598
|
+
private upsertApplicationIndexQuietly;
|
|
4590
4599
|
private upsertApplicationIndex;
|
|
4600
|
+
private deleteApplicationIndexQuietly;
|
|
4591
4601
|
private deleteApplicationIndex;
|
|
4602
|
+
private upsertSpaceIndexQuietly;
|
|
4592
4603
|
private upsertSpaceIndex;
|
|
4604
|
+
private deleteSpaceIndexQuietly;
|
|
4593
4605
|
private deleteSpaceIndex;
|
|
4594
4606
|
private resolveSpace;
|
|
4607
|
+
private replaceApplicationsIndexQuietly;
|
|
4608
|
+
private replaceSpacesIndexQuietly;
|
|
4609
|
+
private replaceDelegationsIndexQuietly;
|
|
4595
4610
|
}
|
|
4596
4611
|
interface AccountIndexStatus {
|
|
4597
4612
|
database: string;
|
|
4613
|
+
state: "ready" | "missing";
|
|
4598
4614
|
sources: Array<{
|
|
4599
4615
|
source: string;
|
|
4600
4616
|
syncedAt: string;
|
|
@@ -4821,4 +4837,4 @@ declare const EXPIRY: {
|
|
|
4821
4837
|
declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
|
|
4822
4838
|
type ExpiryTier = keyof typeof EXPIRY;
|
|
4823
4839
|
|
|
4824
|
-
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, type AccountApplication, type AccountDelegation, type AccountDelegationListOptions, type AccountDelegationRevokeOptions, type AccountIndexRebuildResult, type AccountIndexStatus, AccountService, type AccountServiceConfig, type AccountSpace, 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 };
|
|
4840
|
+
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
|
@@ -4532,9 +4532,17 @@ interface AccountIndexRebuildResult {
|
|
|
4532
4532
|
delegations: number;
|
|
4533
4533
|
syncedAt: string;
|
|
4534
4534
|
}
|
|
4535
|
+
interface AccountIndexedReadOptions {
|
|
4536
|
+
preferIndex?: boolean;
|
|
4537
|
+
refreshIndex?: boolean;
|
|
4538
|
+
}
|
|
4539
|
+
type AccountApplicationListOptions = AccountIndexedReadOptions;
|
|
4540
|
+
type AccountSpaceListOptions = AccountIndexedReadOptions;
|
|
4535
4541
|
interface AccountDelegationListOptions {
|
|
4536
4542
|
direction?: "granted" | "received" | "all";
|
|
4537
4543
|
space?: string;
|
|
4544
|
+
preferIndex?: boolean;
|
|
4545
|
+
refreshIndex?: boolean;
|
|
4538
4546
|
}
|
|
4539
4547
|
interface AccountDelegationRevokeOptions {
|
|
4540
4548
|
cid: string;
|
|
@@ -4554,13 +4562,13 @@ declare class AccountService {
|
|
|
4554
4562
|
constructor(config: AccountServiceConfig);
|
|
4555
4563
|
status(): Promise<Result$1<AccountStatus>>;
|
|
4556
4564
|
readonly applications: {
|
|
4557
|
-
list: () => Promise<Result$1<AccountApplication[]>>;
|
|
4565
|
+
list: (options?: AccountApplicationListOptions) => Promise<Result$1<AccountApplication[]>>;
|
|
4558
4566
|
get: (appId: string) => Promise<Result$1<AccountApplication>>;
|
|
4559
4567
|
register: (manifest: Manifest | Manifest[]) => Promise<Result$1<AccountApplication>>;
|
|
4560
4568
|
remove: (appId: string) => Promise<Result$1<void>>;
|
|
4561
4569
|
};
|
|
4562
4570
|
readonly spaces: {
|
|
4563
|
-
list: () => Promise<Result$1<AccountSpace[]>>;
|
|
4571
|
+
list: (options?: AccountSpaceListOptions) => Promise<Result$1<AccountSpace[]>>;
|
|
4564
4572
|
get: (spaceId: string) => Promise<Result$1<AccountSpace>>;
|
|
4565
4573
|
register: (space: SpaceInfo | AccountSpace) => Promise<Result$1<AccountSpace>>;
|
|
4566
4574
|
syncAccessible: () => Promise<Result$1<AccountSpace[]>>;
|
|
@@ -4587,14 +4595,22 @@ declare class AccountService {
|
|
|
4587
4595
|
private accountKV;
|
|
4588
4596
|
private accountDb;
|
|
4589
4597
|
private indexHasApplicationHash;
|
|
4598
|
+
private upsertApplicationIndexQuietly;
|
|
4590
4599
|
private upsertApplicationIndex;
|
|
4600
|
+
private deleteApplicationIndexQuietly;
|
|
4591
4601
|
private deleteApplicationIndex;
|
|
4602
|
+
private upsertSpaceIndexQuietly;
|
|
4592
4603
|
private upsertSpaceIndex;
|
|
4604
|
+
private deleteSpaceIndexQuietly;
|
|
4593
4605
|
private deleteSpaceIndex;
|
|
4594
4606
|
private resolveSpace;
|
|
4607
|
+
private replaceApplicationsIndexQuietly;
|
|
4608
|
+
private replaceSpacesIndexQuietly;
|
|
4609
|
+
private replaceDelegationsIndexQuietly;
|
|
4595
4610
|
}
|
|
4596
4611
|
interface AccountIndexStatus {
|
|
4597
4612
|
database: string;
|
|
4613
|
+
state: "ready" | "missing";
|
|
4598
4614
|
sources: Array<{
|
|
4599
4615
|
source: string;
|
|
4600
4616
|
syncedAt: string;
|
|
@@ -4821,4 +4837,4 @@ declare const EXPIRY: {
|
|
|
4821
4837
|
declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
|
|
4822
4838
|
type ExpiryTier = keyof typeof EXPIRY;
|
|
4823
4839
|
|
|
4824
|
-
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, type AccountApplication, type AccountDelegation, type AccountDelegationListOptions, type AccountDelegationRevokeOptions, type AccountIndexRebuildResult, type AccountIndexStatus, AccountService, type AccountServiceConfig, type AccountSpace, 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 };
|
|
4840
|
+
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.js
CHANGED
|
@@ -2812,7 +2812,7 @@ function accountRegistryIndexPermission() {
|
|
|
2812
2812
|
service: "tinycloud.sql",
|
|
2813
2813
|
space: ACCOUNT_REGISTRY_SPACE,
|
|
2814
2814
|
path: "account",
|
|
2815
|
-
actions: ["tinycloud.sql/read", "tinycloud.sql/write"]
|
|
2815
|
+
actions: ["tinycloud.sql/read", "tinycloud.sql/write", "tinycloud.sql/ddl"]
|
|
2816
2816
|
};
|
|
2817
2817
|
}
|
|
2818
2818
|
function composeManifestRequest(inputs, options = {}) {
|
|
@@ -2924,7 +2924,17 @@ var AccountService = class {
|
|
|
2924
2924
|
constructor(config) {
|
|
2925
2925
|
this.config = config;
|
|
2926
2926
|
this.applications = {
|
|
2927
|
-
list: async () => {
|
|
2927
|
+
list: async (options = {}) => {
|
|
2928
|
+
if (options.preferIndex) {
|
|
2929
|
+
const indexed = await this.index.applications.list();
|
|
2930
|
+
if (indexed.ok && indexed.data.length > 0) return indexed;
|
|
2931
|
+
if (!indexed.ok && !isMissingIndexError(indexed.error)) return indexed;
|
|
2932
|
+
const canonical = await this.applications.list();
|
|
2933
|
+
if (canonical.ok && options.refreshIndex !== false) {
|
|
2934
|
+
await this.replaceApplicationsIndexQuietly(canonical.data);
|
|
2935
|
+
}
|
|
2936
|
+
return canonical;
|
|
2937
|
+
}
|
|
2928
2938
|
const kvResult = this.accountKV();
|
|
2929
2939
|
if (!kvResult.ok) return kvResult;
|
|
2930
2940
|
const listed = await kvResult.data.list({ prefix: ACCOUNT_REGISTRY_PATH });
|
|
@@ -2983,8 +2993,7 @@ var AccountService = class {
|
|
|
2983
2993
|
const written = await kvResult.data.put(record.key, stored);
|
|
2984
2994
|
if (!written.ok) return accountErr(written.error);
|
|
2985
2995
|
registered = applicationFromRecord(record.key, stored);
|
|
2986
|
-
|
|
2987
|
-
if (!indexed.ok) return indexed;
|
|
2996
|
+
await this.upsertApplicationIndexQuietly(registered);
|
|
2988
2997
|
}
|
|
2989
2998
|
return ok3(registered);
|
|
2990
2999
|
},
|
|
@@ -2993,13 +3002,22 @@ var AccountService = class {
|
|
|
2993
3002
|
if (!kvResult.ok) return kvResult;
|
|
2994
3003
|
const removed = await kvResult.data.delete(applicationKey(appId));
|
|
2995
3004
|
if (!removed.ok) return accountErr(removed.error);
|
|
2996
|
-
|
|
2997
|
-
if (!indexed.ok) return indexed;
|
|
3005
|
+
await this.deleteApplicationIndexQuietly(appId);
|
|
2998
3006
|
return ok3(void 0);
|
|
2999
3007
|
}
|
|
3000
3008
|
};
|
|
3001
3009
|
this.spaces = {
|
|
3002
|
-
list: async () => {
|
|
3010
|
+
list: async (options = {}) => {
|
|
3011
|
+
if (options.preferIndex) {
|
|
3012
|
+
const indexed = await this.index.spaces.list();
|
|
3013
|
+
if (indexed.ok && indexed.data.length > 0) return indexed;
|
|
3014
|
+
if (!indexed.ok && !isMissingIndexError(indexed.error)) return indexed;
|
|
3015
|
+
const canonical = await this.spaces.syncAccessible();
|
|
3016
|
+
if (canonical.ok && options.refreshIndex !== false) {
|
|
3017
|
+
await this.replaceSpacesIndexQuietly(canonical.data);
|
|
3018
|
+
}
|
|
3019
|
+
return canonical;
|
|
3020
|
+
}
|
|
3003
3021
|
const kvResult = this.accountKV();
|
|
3004
3022
|
if (!kvResult.ok) return kvResult;
|
|
3005
3023
|
const listed = await kvResult.data.list({ prefix: ACCOUNT_SPACES_PATH });
|
|
@@ -3028,8 +3046,7 @@ var AccountService = class {
|
|
|
3028
3046
|
const written = await kvResult.data.put(spaceKey(stored.space_id), stored);
|
|
3029
3047
|
if (!written.ok) return accountErr(written.error);
|
|
3030
3048
|
const registered = spaceFromRecord(spaceKey(stored.space_id), stored);
|
|
3031
|
-
|
|
3032
|
-
if (!indexed.ok) return indexed;
|
|
3049
|
+
await this.upsertSpaceIndexQuietly(registered);
|
|
3033
3050
|
return ok3(registered);
|
|
3034
3051
|
},
|
|
3035
3052
|
syncAccessible: async () => {
|
|
@@ -3048,13 +3065,25 @@ var AccountService = class {
|
|
|
3048
3065
|
if (!kvResult.ok) return kvResult;
|
|
3049
3066
|
const removed = await kvResult.data.delete(spaceKey(spaceId));
|
|
3050
3067
|
if (!removed.ok) return accountErr(removed.error);
|
|
3051
|
-
|
|
3052
|
-
if (!indexed.ok) return indexed;
|
|
3068
|
+
await this.deleteSpaceIndexQuietly(spaceId);
|
|
3053
3069
|
return ok3(void 0);
|
|
3054
3070
|
}
|
|
3055
3071
|
};
|
|
3056
3072
|
this.delegations = {
|
|
3057
3073
|
list: async (options = {}) => {
|
|
3074
|
+
if (options.preferIndex) {
|
|
3075
|
+
const indexed = await this.index.delegations.list(options);
|
|
3076
|
+
if (indexed.ok && indexed.data.length > 0) return indexed;
|
|
3077
|
+
if (!indexed.ok && !isMissingIndexError(indexed.error)) return indexed;
|
|
3078
|
+
const live = await this.delegations.list({
|
|
3079
|
+
direction: options.direction,
|
|
3080
|
+
space: options.space
|
|
3081
|
+
});
|
|
3082
|
+
if (live.ok && options.refreshIndex !== false) {
|
|
3083
|
+
await this.replaceDelegationsIndexQuietly(live.data);
|
|
3084
|
+
}
|
|
3085
|
+
return live;
|
|
3086
|
+
}
|
|
3058
3087
|
const spaces = await this.config.getSpaces().list();
|
|
3059
3088
|
if (!spaces.ok) return accountErr(spaces.error);
|
|
3060
3089
|
const targetSpaces = options.space ? spaces.data.filter((space) => space.id === options.space || space.name === options.space) : spaces.data;
|
|
@@ -3227,9 +3256,15 @@ var AccountService = class {
|
|
|
3227
3256
|
const queried = await dbResult.data.query(
|
|
3228
3257
|
"SELECT source, synced_at, count FROM sync_state ORDER BY source"
|
|
3229
3258
|
);
|
|
3230
|
-
if (!queried.ok)
|
|
3259
|
+
if (!queried.ok) {
|
|
3260
|
+
if (isMissingIndexError(queried.error)) {
|
|
3261
|
+
return ok3({ database: ACCOUNT_INDEX_DB, state: "missing", sources: [] });
|
|
3262
|
+
}
|
|
3263
|
+
return accountErr(queried.error);
|
|
3264
|
+
}
|
|
3231
3265
|
return ok3({
|
|
3232
3266
|
database: ACCOUNT_INDEX_DB,
|
|
3267
|
+
state: "ready",
|
|
3233
3268
|
sources: queried.data.rows.map(([source, syncedAt, count]) => ({
|
|
3234
3269
|
source,
|
|
3235
3270
|
syncedAt,
|
|
@@ -3294,6 +3329,9 @@ var AccountService = class {
|
|
|
3294
3329
|
);
|
|
3295
3330
|
return queried.ok && queried.data.rows.length > 0;
|
|
3296
3331
|
}
|
|
3332
|
+
async upsertApplicationIndexQuietly(app) {
|
|
3333
|
+
await ignoreIndexFailure(() => this.upsertApplicationIndex(app));
|
|
3334
|
+
}
|
|
3297
3335
|
async upsertApplicationIndex(app) {
|
|
3298
3336
|
const dbResult = this.accountDb();
|
|
3299
3337
|
if (!dbResult.ok) return ok3(void 0);
|
|
@@ -3319,6 +3357,9 @@ var AccountService = class {
|
|
|
3319
3357
|
if (!written.ok) return accountErr(written.error);
|
|
3320
3358
|
return ok3(void 0);
|
|
3321
3359
|
}
|
|
3360
|
+
async deleteApplicationIndexQuietly(appId) {
|
|
3361
|
+
await ignoreIndexFailure(() => this.deleteApplicationIndex(appId));
|
|
3362
|
+
}
|
|
3322
3363
|
async deleteApplicationIndex(appId) {
|
|
3323
3364
|
const dbResult = this.accountDb();
|
|
3324
3365
|
if (!dbResult.ok) return ok3(void 0);
|
|
@@ -3330,6 +3371,9 @@ var AccountService = class {
|
|
|
3330
3371
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
3331
3372
|
return ok3(void 0);
|
|
3332
3373
|
}
|
|
3374
|
+
async upsertSpaceIndexQuietly(space) {
|
|
3375
|
+
await ignoreIndexFailure(() => this.upsertSpaceIndex(space));
|
|
3376
|
+
}
|
|
3333
3377
|
async upsertSpaceIndex(space) {
|
|
3334
3378
|
const dbResult = this.accountDb();
|
|
3335
3379
|
if (!dbResult.ok) return ok3(void 0);
|
|
@@ -3354,6 +3398,9 @@ var AccountService = class {
|
|
|
3354
3398
|
if (!written.ok) return accountErr(written.error);
|
|
3355
3399
|
return ok3(void 0);
|
|
3356
3400
|
}
|
|
3401
|
+
async deleteSpaceIndexQuietly(spaceId) {
|
|
3402
|
+
await ignoreIndexFailure(() => this.deleteSpaceIndex(spaceId));
|
|
3403
|
+
}
|
|
3357
3404
|
async deleteSpaceIndex(spaceId) {
|
|
3358
3405
|
const dbResult = this.accountDb();
|
|
3359
3406
|
if (!dbResult.ok) return ok3(void 0);
|
|
@@ -3375,6 +3422,98 @@ var AccountService = class {
|
|
|
3375
3422
|
}
|
|
3376
3423
|
return ok3(found);
|
|
3377
3424
|
}
|
|
3425
|
+
async replaceApplicationsIndexQuietly(applications) {
|
|
3426
|
+
await ignoreIndexFailure(async () => {
|
|
3427
|
+
const dbResult = this.accountDb();
|
|
3428
|
+
if (!dbResult.ok) return;
|
|
3429
|
+
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3430
|
+
await dbResult.data.batch([
|
|
3431
|
+
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3432
|
+
{ sql: "DELETE FROM applications" },
|
|
3433
|
+
{ sql: "DELETE FROM application_state" },
|
|
3434
|
+
...applications.map((app) => ({
|
|
3435
|
+
sql: "INSERT OR REPLACE INTO applications (app_id, name, description, updated_at, manifest_json) VALUES (?, ?, ?, ?, ?)",
|
|
3436
|
+
params: [
|
|
3437
|
+
app.appId,
|
|
3438
|
+
app.name ?? null,
|
|
3439
|
+
app.description ?? null,
|
|
3440
|
+
app.updatedAt ?? syncedAt,
|
|
3441
|
+
JSON.stringify(app.manifests)
|
|
3442
|
+
]
|
|
3443
|
+
})),
|
|
3444
|
+
...applications.map((app) => ({
|
|
3445
|
+
sql: "INSERT OR REPLACE INTO application_state (app_id, manifest_hash, indexed_at) VALUES (?, ?, ?)",
|
|
3446
|
+
params: [app.appId, app.manifestHash ?? hashJson(app.manifests), syncedAt]
|
|
3447
|
+
})),
|
|
3448
|
+
{
|
|
3449
|
+
sql: "INSERT OR REPLACE INTO sync_state (source, synced_at, count) VALUES (?, ?, ?)",
|
|
3450
|
+
params: ["applications", syncedAt, applications.length]
|
|
3451
|
+
}
|
|
3452
|
+
]);
|
|
3453
|
+
});
|
|
3454
|
+
}
|
|
3455
|
+
async replaceSpacesIndexQuietly(spaces) {
|
|
3456
|
+
await ignoreIndexFailure(async () => {
|
|
3457
|
+
const dbResult = this.accountDb();
|
|
3458
|
+
if (!dbResult.ok) return;
|
|
3459
|
+
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3460
|
+
await dbResult.data.batch([
|
|
3461
|
+
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3462
|
+
{ sql: "DELETE FROM spaces" },
|
|
3463
|
+
...spaces.map((space) => ({
|
|
3464
|
+
sql: "INSERT OR REPLACE INTO spaces (space_id, name, owner_did, type, permissions_json, status, registered_at, updated_at, expires_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
3465
|
+
params: [
|
|
3466
|
+
space.spaceId,
|
|
3467
|
+
space.name,
|
|
3468
|
+
space.ownerDid,
|
|
3469
|
+
space.type,
|
|
3470
|
+
JSON.stringify(space.permissions),
|
|
3471
|
+
space.status,
|
|
3472
|
+
space.registeredAt ?? syncedAt,
|
|
3473
|
+
space.updatedAt ?? syncedAt,
|
|
3474
|
+
space.expiresAt?.toISOString() ?? null
|
|
3475
|
+
]
|
|
3476
|
+
})),
|
|
3477
|
+
{
|
|
3478
|
+
sql: "INSERT OR REPLACE INTO sync_state (source, synced_at, count) VALUES (?, ?, ?)",
|
|
3479
|
+
params: ["spaces", syncedAt, spaces.length]
|
|
3480
|
+
}
|
|
3481
|
+
]);
|
|
3482
|
+
});
|
|
3483
|
+
}
|
|
3484
|
+
async replaceDelegationsIndexQuietly(delegations) {
|
|
3485
|
+
await ignoreIndexFailure(async () => {
|
|
3486
|
+
const dbResult = this.accountDb();
|
|
3487
|
+
if (!dbResult.ok) return;
|
|
3488
|
+
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3489
|
+
await dbResult.data.batch([
|
|
3490
|
+
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3491
|
+
{ sql: "DELETE FROM delegations" },
|
|
3492
|
+
...delegations.map((delegation) => ({
|
|
3493
|
+
sql: "INSERT OR REPLACE INTO delegations (cid, direction, space_id, space_name, counterparty_did, delegate_did, delegator_did, path, actions_json, expiry, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
3494
|
+
params: [
|
|
3495
|
+
delegation.cid,
|
|
3496
|
+
delegation.direction,
|
|
3497
|
+
delegation.spaceId,
|
|
3498
|
+
delegation.spaceName ?? null,
|
|
3499
|
+
delegation.counterpartyDid,
|
|
3500
|
+
delegation.delegateDid,
|
|
3501
|
+
delegation.delegatorDid ?? null,
|
|
3502
|
+
delegation.path,
|
|
3503
|
+
JSON.stringify(delegation.actions),
|
|
3504
|
+
delegation.expiry.toISOString(),
|
|
3505
|
+
delegation.status,
|
|
3506
|
+
delegation.createdAt?.toISOString() ?? null,
|
|
3507
|
+
syncedAt
|
|
3508
|
+
]
|
|
3509
|
+
})),
|
|
3510
|
+
{
|
|
3511
|
+
sql: "INSERT OR REPLACE INTO sync_state (source, synced_at, count) VALUES (?, ?, ?)",
|
|
3512
|
+
params: ["delegations", syncedAt, delegations.length]
|
|
3513
|
+
}
|
|
3514
|
+
]);
|
|
3515
|
+
});
|
|
3516
|
+
}
|
|
3378
3517
|
};
|
|
3379
3518
|
var ACCOUNT_INDEX_SCHEMA = [
|
|
3380
3519
|
`CREATE TABLE IF NOT EXISTS applications (
|
|
@@ -3581,6 +3720,15 @@ function mapDelegation(delegation, space, direction) {
|
|
|
3581
3720
|
function accountErr(error) {
|
|
3582
3721
|
return err3(serviceError3(error.code, error.message, SERVICE_NAME2, { cause: error.cause, meta: error.meta }));
|
|
3583
3722
|
}
|
|
3723
|
+
function isMissingIndexError(error) {
|
|
3724
|
+
return /no such table:/i.test(error.message);
|
|
3725
|
+
}
|
|
3726
|
+
async function ignoreIndexFailure(task) {
|
|
3727
|
+
try {
|
|
3728
|
+
await task();
|
|
3729
|
+
} catch {
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3584
3732
|
|
|
3585
3733
|
// src/index.ts
|
|
3586
3734
|
import {
|