@tinycloud/node-sdk 3.1.0-beta.10 → 3.1.0-beta.12
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/{core-CC7uDKZP.d.cts → core-CMDgVfBj.d.cts} +4 -0
- package/dist/{core-CC7uDKZP.d.ts → core-CMDgVfBj.d.ts} +4 -0
- package/dist/core.cjs +125 -59
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +125 -59
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +125 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +125 -59
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/core.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
|
|
2
|
-
export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './core-
|
|
2
|
+
export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './core-CMDgVfBj.cjs';
|
|
3
3
|
import 'events';
|
|
4
4
|
import '@tinycloud/sdk-services';
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AccountApplication, AccountApplicationListOptions, AccountApplicationRegisterOptions, AccountDelegation, AccountDelegationListOptions, AccountDelegationRevokeOptions, AccountIndexEnsureResult, AccountIndexRebuildResult, AccountIndexStatus, AccountIndexedReadOptions, AccountService, AccountServiceConfig, AccountSpace, AccountSpaceListOptions, AccountStatus, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CanonicalAddress, CanonicalParsedNetworkId, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, CaveatedDelegationUnsupportedError, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DataVaultConfig, DataVaultService, DatabaseHandle, DelegateReceivedShareParams, DelegatedShareAccess, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DidCacheKeyOptions, DidEqualsOptions, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISecretsService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IdentityParseError, IngestOptions, InvokeFunction, JWK, KVBatchReadResponse, KVCreateSignedReadUrlOptions, KVResponse, KVService, KVServiceConfig, KVSignedReadUrlResponse, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestSecretActions, ManifestValidationError, OpenKeyCallbackStrategy, OpenKeySigningRequestBody, OpenKeySigningResponseBody, OpenKeySigningStrategyOptions, ParsedSecretCatalogKey, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PkhDidParts, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, RegisterBatchSuccess, RegisterPolicyV3Input, RegisterPolicyV3Receipt, ResolvedCapabilities, ResolvedDelegate, ResolvedSecretPath, ResourceCapability, SECRET_NAME_RE, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, SecretCatalogEntry, SecretPayload, SecretScopeOptions, SecretsError, SecretsService, ServiceContext, ServiceContextConfig, ServiceSession, SessionExpiredError, ShareAccess, ShareLink, ShareLinkData, ShareSchema, SharingService, SharingServiceConfig, SignCallback, SignInOptions, SignRequest, SignResponse, SilentNotificationHandler, Space, SpaceAbilitiesMap, SpaceConfig, SpaceCreationContext, SpaceErrorCode, SpaceErrorCodes, SpaceInfo, SpaceOwnership, SpaceService, SpaceServiceConfig, SqlStatement, SqlValue, StoredDelegationChain, TableInfo, TelemetryConfig, TelemetryEventHandler, TinyCloud, TinyCloudConfig, TinyCloudDebugEnableOptions, TinyCloudDebugEvent, TinyCloudDebugLevel, TinyCloudDebugLogger, TinyCloudDebugTimer, TinyCloudSession, UnsupportedFeatureError, VAULT_PERMISSION_SERVICE, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultNetworkReadResult, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, addressStorageKey, buildSpaceUri, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, canonicalizeNetworkId, canonicalizeSecretScope, checkNodeInfo, clearTinyCloudDebugLogs, composeManifestRequest, createCapabilityKeyRegistry, createOpenKeyCallbackSigningStrategy, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, didCacheKey, didEquals, disableTinyCloudDebug, enableTinyCloudDebug, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, getTinyCloudDebugLogs, installTinyCloudDebugGlobals, isCapabilitySubset, isEvmAddress, loadManifest, makePkhSpaceId, makePublicSpaceId, parseCanonicalNetworkId, parseExpiry, parsePkhDid, parseSecretCatalogKey, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveManifest, resolveSecretListPrefix, resolveSecretPath, resourceCapabilitiesToSpaceAbilitiesMap, tinyCloudDebugLogger, validateManifest } from '@tinycloud/sdk-core';
|
|
2
|
-
export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './core-
|
|
2
|
+
export { e as BootstrapWarning, C as CompactRuntimeDelegationInput, f as CreateOwnerDelegationParams, D as DelegateToOptions, g as DelegateToResult, h as DelegatedAccess, E as EnsureEncryptionNetworkOptions, F as FileSessionStorage, I as InvalidRestoredSessionError, M as MemorySessionStorage, N as NodeEventEmitterStrategy, j as NodeUserAuthorization, k as NodeUserAuthorizationConfig, O as OwnerDelegationReceipt, P as PortableDelegation, p as RuntimePermissionGrantOptions, S as SecretPermissionHint, q as SecretReadInput, r as SecretReadResult, t as SignStrategy, T as TinyCloudNode, u as TinyCloudNodeConfig, U as UnifiedOwnerRootInput, v as UnifiedOwnerRootReceipt, w as UnsupportedSessionRestoreError, V as ValidatedRuntimeDelegation, W as WasmKeyProvider, y as WasmKeyProviderConfig, z as activateCompactRuntimeDelegation, H as createWasmKeyProvider, J as defaultSignStrategy, K as deserializeDelegation, Q as serializeDelegation } from './core-CMDgVfBj.js';
|
|
3
3
|
import 'events';
|
|
4
4
|
import '@tinycloud/sdk-services';
|
package/dist/core.js
CHANGED
|
@@ -2708,15 +2708,21 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2708
2708
|
if (!this.wasmBindings.invokeAny) {
|
|
2709
2709
|
throw new Error("WASM binding does not support invokeAny");
|
|
2710
2710
|
}
|
|
2711
|
-
const
|
|
2711
|
+
const routedEntries = entries;
|
|
2712
|
+
const operations = routedEntries.flatMap((entry) => {
|
|
2712
2713
|
const operation = this.operationFromInvokeAnyEntry(entry);
|
|
2713
2714
|
return operation ? [operation] : [];
|
|
2714
2715
|
});
|
|
2715
|
-
const
|
|
2716
|
-
const
|
|
2717
|
-
|
|
2716
|
+
const authorityCid = routedEntries.length === 1 ? routedEntries[0]?.revokeAuthorityCid : void 0;
|
|
2717
|
+
const explicitGrant = authorityCid === void 0 ? void 0 : this.runtimePermissionGrants.find((grant2) => grant2.delegation.cid === authorityCid);
|
|
2718
|
+
if (authorityCid !== void 0 && !explicitGrant) {
|
|
2719
|
+
throw new Error(`Explicit revocation authority ${authorityCid} is not installed.`);
|
|
2720
|
+
}
|
|
2721
|
+
const grant = explicitGrant ?? this.findGrantForOperations(operations);
|
|
2722
|
+
const invocationSession = explicitGrant ? explicitGrant.session : !grant || grant.provenance === "primary" ? session : grant.session;
|
|
2723
|
+
const caveatPreservingEntries = routedEntries.map(({ revokeAuthorityCid: _cid, ...entry }) => {
|
|
2718
2724
|
const requested = this.operationFromInvokeAnyEntry(entry);
|
|
2719
|
-
const granted = requested && grant.operations.find(
|
|
2725
|
+
const granted = grant && requested && grant.operations.find(
|
|
2720
2726
|
(candidate) => this.operationCovers(candidate, requested)
|
|
2721
2727
|
);
|
|
2722
2728
|
if (!granted?.caveats?.length) {
|
|
@@ -2726,7 +2732,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2726
2732
|
throw new Error("Invocation caveats do not match signed ReCap authority.");
|
|
2727
2733
|
}
|
|
2728
2734
|
return { ...entry, caveats: cloneRecapCaveats(granted.caveats) };
|
|
2729
|
-
})
|
|
2735
|
+
});
|
|
2730
2736
|
return this.wasmBindings.invokeAny(invocationSession, caveatPreservingEntries, facts);
|
|
2731
2737
|
};
|
|
2732
2738
|
this.explicitHost = config.host;
|
|
@@ -3191,12 +3197,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3191
3197
|
if (!auth) {
|
|
3192
3198
|
throw new Error("Account bootstrap requires an active wallet session");
|
|
3193
3199
|
}
|
|
3200
|
+
const accountSpaceId = this.ownedSpaceId(ACCOUNT_REGISTRY_SPACE2);
|
|
3194
3201
|
const skipped = auth.lastActivationSkippedSpaceIds;
|
|
3202
|
+
if (skipped.includes(accountSpaceId)) return { action: "run", mode: "fresh" };
|
|
3195
3203
|
if (skipped.some((spaceId) => enshrinedSpaceIds.has(spaceId))) {
|
|
3196
|
-
return { action: "run", mode: "
|
|
3204
|
+
return { action: "run", mode: "repair" };
|
|
3197
3205
|
}
|
|
3198
3206
|
try {
|
|
3199
|
-
const accountSpaceId = this.ownedSpaceId(ACCOUNT_REGISTRY_SPACE2);
|
|
3200
3207
|
const markerPermission = {
|
|
3201
3208
|
service: "tinycloud.kv",
|
|
3202
3209
|
space: accountSpaceId,
|
|
@@ -3208,7 +3215,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3208
3215
|
}
|
|
3209
3216
|
const marker = await this.readBootstrapCompletionMarker();
|
|
3210
3217
|
if (marker.ok) {
|
|
3211
|
-
if (this.isAcceptedBootstrapCompletionMarker(marker.data.data)) {
|
|
3218
|
+
if (this.isAcceptedBootstrapCompletionMarker(marker.data.data, steps.map((step) => step.id))) {
|
|
3212
3219
|
return { action: "skip" };
|
|
3213
3220
|
}
|
|
3214
3221
|
return { action: "run", mode: "repair" };
|
|
@@ -3258,12 +3265,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3258
3265
|
);
|
|
3259
3266
|
}
|
|
3260
3267
|
}
|
|
3261
|
-
|
|
3268
|
+
/**
|
|
3269
|
+
* A marker written before a canonical space was added triggers one bounded repair.
|
|
3270
|
+
*/
|
|
3271
|
+
isAcceptedBootstrapCompletionMarker(value, canonicalStepIds) {
|
|
3262
3272
|
if (typeof value !== "object" || value === null) return false;
|
|
3263
3273
|
const entries = Object.entries(value);
|
|
3264
3274
|
const markerValue = (name) => entries.find(([key]) => key === name)?.[1];
|
|
3265
3275
|
const version = markerValue("v");
|
|
3266
|
-
|
|
3276
|
+
const stepIds = markerValue("stepIds");
|
|
3277
|
+
return typeof version === "number" && Number.isInteger(version) && ACCEPTED_MARKER_VERSIONS.some((acceptedVersion) => acceptedVersion === version) && Array.isArray(stepIds) && canonicalStepIds.every((stepId) => stepIds.includes(stepId));
|
|
3267
3278
|
}
|
|
3268
3279
|
markerReadIsUnhostedSpace(meta) {
|
|
3269
3280
|
return meta?.status === 404;
|
|
@@ -3350,30 +3361,39 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3350
3361
|
}
|
|
3351
3362
|
}
|
|
3352
3363
|
if (step.kind === "seed-spaces") {
|
|
3353
|
-
const
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3364
|
+
const inputs = step.spaces.map((space) => ({
|
|
3365
|
+
spaceId: space.spaceId,
|
|
3366
|
+
name: space.name,
|
|
3367
|
+
ownerDid: this.did,
|
|
3368
|
+
type: "owned",
|
|
3369
|
+
permissions: ["*"],
|
|
3370
|
+
status: "active"
|
|
3371
|
+
}));
|
|
3372
|
+
if (mode === "fresh") {
|
|
3373
|
+
const registered = await this.account.spaces.registerBatch(inputs);
|
|
3374
|
+
if (!registered.ok) {
|
|
3375
|
+
throw Object.assign(
|
|
3376
|
+
new Error(`Failed to seed account spaces: ${registered.error.message}`),
|
|
3377
|
+
{ cause: registered.error }
|
|
3378
|
+
);
|
|
3379
|
+
}
|
|
3380
|
+
const batchError = registered.data.recoveredFromBatchError;
|
|
3381
|
+
if (batchError) {
|
|
3382
|
+
warnings.push({
|
|
3383
|
+
stepId: step.id,
|
|
3384
|
+
kind: "batch-write-reconciled",
|
|
3385
|
+
code: batchError.code,
|
|
3386
|
+
message: batchError.message
|
|
3387
|
+
});
|
|
3388
|
+
}
|
|
3389
|
+
} else {
|
|
3390
|
+
const ensured = await this.account.spaces.registerMissing(inputs);
|
|
3391
|
+
if (!ensured.ok) {
|
|
3392
|
+
throw Object.assign(
|
|
3393
|
+
new Error(`Failed to seed account spaces: ${ensured.error.message}`),
|
|
3394
|
+
{ cause: ensured.error }
|
|
3395
|
+
);
|
|
3396
|
+
}
|
|
3377
3397
|
}
|
|
3378
3398
|
}
|
|
3379
3399
|
if (step.kind === "seed-applications") {
|
|
@@ -4058,6 +4078,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4058
4078
|
stagedSessionExpiry,
|
|
4059
4079
|
stagedRecap
|
|
4060
4080
|
);
|
|
4081
|
+
const stagedAccountSpaceId = stagedAddress ? this.wasmBindings.makeSpaceId(stagedAddress, stagedChainId, ACCOUNT_REGISTRY_SPACE2) : void 0;
|
|
4061
4082
|
const stagedGraph = this.stageRestoredServiceGraph({
|
|
4062
4083
|
host: stagedHost,
|
|
4063
4084
|
manager: stagedManager,
|
|
@@ -4066,6 +4087,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4066
4087
|
nodeDid: stagedNodeDid,
|
|
4067
4088
|
address: stagedAddress,
|
|
4068
4089
|
chainId: stagedChainId,
|
|
4090
|
+
accountSpaceId: stagedAccountSpaceId,
|
|
4069
4091
|
tinyCloudSession: stagedTcSession,
|
|
4070
4092
|
sessionExpiry: stagedSessionExpiry,
|
|
4071
4093
|
recap: stagedRecap
|
|
@@ -4231,6 +4253,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4231
4253
|
}
|
|
4232
4254
|
const delegationManager = new DelegationManager({
|
|
4233
4255
|
hosts: [input.host],
|
|
4256
|
+
accountSpaceId: input.accountSpaceId,
|
|
4234
4257
|
session: input.serviceSession,
|
|
4235
4258
|
invoke: graph.invoke,
|
|
4236
4259
|
invokeAny: graph.invokeAny,
|
|
@@ -5935,6 +5958,14 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5935
5958
|
delegation.delegationHeader
|
|
5936
5959
|
);
|
|
5937
5960
|
if (!activateResult.success) {
|
|
5961
|
+
if (this.operationsFromDelegation(delegation).some(
|
|
5962
|
+
(operation) => operation.resource?.startsWith("urn:cid:") === true && operation.service === "delegation" && operation.action === "tinycloud.delegation/revoke"
|
|
5963
|
+
) && activateResult.status === 401 && /Cannot find parent delegation/i.test(activateResult.error ?? "")) {
|
|
5964
|
+
throw Object.assign(
|
|
5965
|
+
new Error("The host cannot activate a root raw-CID revoke authority without a parent delegation."),
|
|
5966
|
+
{ code: "RAW_RECAP_RESOURCE_UNSUPPORTED", cause: activateResult }
|
|
5967
|
+
);
|
|
5968
|
+
}
|
|
5938
5969
|
throw Object.assign(
|
|
5939
5970
|
new Error(`Failed to activate runtime permission delegation: ${describeHostFailure2(activateResult)}`),
|
|
5940
5971
|
{ cause: activateResult }
|
|
@@ -5982,10 +6013,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
5982
6013
|
}
|
|
5983
6014
|
this.assertDelegationCaveatsPreservable(expanded);
|
|
5984
6015
|
const rawEntries = expanded.filter(
|
|
5985
|
-
(entry) => this.isEncryptionPermissionEntry(entry)
|
|
6016
|
+
(entry) => this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry)
|
|
5986
6017
|
);
|
|
5987
6018
|
const spaceEntries = expanded.filter(
|
|
5988
|
-
(entry) => !this.isEncryptionPermissionEntry(entry)
|
|
6019
|
+
(entry) => !this.isEncryptionPermissionEntry(entry) && !this.isRawRevocationPermissionEntry(entry)
|
|
5989
6020
|
);
|
|
5990
6021
|
const bySpace = /* @__PURE__ */ new Map();
|
|
5991
6022
|
for (const entry of spaceEntries) {
|
|
@@ -6012,17 +6043,29 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6012
6043
|
}
|
|
6013
6044
|
const delegatedEntries = [...entries, ...rawForDelegation];
|
|
6014
6045
|
const abilities = this.permissionsToAbilities(entries);
|
|
6015
|
-
const prepared =
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6046
|
+
const prepared = (() => {
|
|
6047
|
+
try {
|
|
6048
|
+
return this.wasmBindings.prepareSession({
|
|
6049
|
+
abilities,
|
|
6050
|
+
...rawForDelegation.length > 0 ? { rawAbilities: this.permissionsToRawAbilities(rawForDelegation) } : {},
|
|
6051
|
+
address: this.wasmBindings.ensureEip55(session.address),
|
|
6052
|
+
chainId: session.chainId,
|
|
6053
|
+
domain: this.siweDomain,
|
|
6054
|
+
issuedAt: now.toISOString(),
|
|
6055
|
+
expirationTime: expiresAt.toISOString(),
|
|
6056
|
+
spaceId,
|
|
6057
|
+
jwk: session.jwk
|
|
6058
|
+
});
|
|
6059
|
+
} catch (error) {
|
|
6060
|
+
if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && /invalid ReCap resource URI/i.test(error instanceof Error ? error.message : String(error))) {
|
|
6061
|
+
throw Object.assign(
|
|
6062
|
+
new Error("This WASM build cannot encode raw urn:cid ReCap resources."),
|
|
6063
|
+
{ code: "RAW_RECAP_RESOURCE_UNSUPPORTED", cause: error }
|
|
6064
|
+
);
|
|
6065
|
+
}
|
|
6066
|
+
throw error;
|
|
6067
|
+
}
|
|
6068
|
+
})();
|
|
6026
6069
|
const signature = await this.signer.signMessage(prepared.siwe);
|
|
6027
6070
|
const delegatedSession = this.wasmBindings.completeSessionSetup({
|
|
6028
6071
|
...prepared,
|
|
@@ -6033,6 +6076,12 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6033
6076
|
delegatedSession.delegationHeader
|
|
6034
6077
|
);
|
|
6035
6078
|
if (!activateResult.success) {
|
|
6079
|
+
if (rawForDelegation.some((entry) => this.isRawRevocationPermissionEntry(entry)) && activateResult.status === 401 && /Cannot find parent delegation/i.test(activateResult.error ?? "")) {
|
|
6080
|
+
throw Object.assign(
|
|
6081
|
+
new Error("The host cannot activate a root raw-CID revoke authority without a parent delegation."),
|
|
6082
|
+
{ code: "RAW_RECAP_RESOURCE_UNSUPPORTED", cause: activateResult }
|
|
6083
|
+
);
|
|
6084
|
+
}
|
|
6036
6085
|
throw Object.assign(
|
|
6037
6086
|
new Error(`Failed to activate runtime permission delegation: ${describeHostFailure2(activateResult)}`),
|
|
6038
6087
|
{ cause: activateResult }
|
|
@@ -6734,6 +6783,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6734
6783
|
permissionsToAbilities(entries) {
|
|
6735
6784
|
const abilities = {};
|
|
6736
6785
|
for (const entry of entries) {
|
|
6786
|
+
if (this.isRawRevocationPermissionEntry(entry)) continue;
|
|
6737
6787
|
const service = this.shortServiceName(entry.service);
|
|
6738
6788
|
abilities[service] ?? (abilities[service] = {});
|
|
6739
6789
|
const existing = abilities[service][entry.path] ?? [];
|
|
@@ -6751,9 +6801,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6751
6801
|
isEncryptionPermissionEntry(entry) {
|
|
6752
6802
|
return entry.service === ENCRYPTION_PERMISSION_SERVICE2 && this.isEncryptionNetworkOperation("encryption", entry.path, entry.space);
|
|
6753
6803
|
}
|
|
6804
|
+
isRawRevocationPermissionEntry(entry) {
|
|
6805
|
+
return entry.service === "tinycloud.delegation" && entry.path === "" && entry.space?.startsWith("urn:cid:") === true && entry.actions.includes("tinycloud.delegation/revoke");
|
|
6806
|
+
}
|
|
6754
6807
|
permissionsToRawAbilities(entries) {
|
|
6755
6808
|
const rawAbilities = {};
|
|
6756
6809
|
for (const entry of entries) {
|
|
6810
|
+
if (this.isRawRevocationPermissionEntry(entry)) {
|
|
6811
|
+
rawAbilities[entry.space] = [...new Set(entry.actions)];
|
|
6812
|
+
continue;
|
|
6813
|
+
}
|
|
6757
6814
|
if (!this.isEncryptionPermissionEntry(entry)) {
|
|
6758
6815
|
continue;
|
|
6759
6816
|
}
|
|
@@ -6773,7 +6830,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6773
6830
|
return entries.flatMap((entry) => {
|
|
6774
6831
|
const service = this.shortServiceName(entry.service);
|
|
6775
6832
|
return entry.actions.map((action) => ({
|
|
6776
|
-
...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
6833
|
+
...this.isRawRevocationPermissionEntry(entry) ? { resource: entry.space } : this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
6777
6834
|
service,
|
|
6778
6835
|
path: entry.path,
|
|
6779
6836
|
action,
|
|
@@ -6783,11 +6840,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6783
6840
|
}
|
|
6784
6841
|
/** Raw network authority cannot be covered by a nested encryption space. */
|
|
6785
6842
|
signedCapabilitySubset(requested, granted) {
|
|
6786
|
-
const rawGranted = granted.filter((entry) => this.isEncryptionPermissionEntry(entry)).map((entry) => ({ ...entry, space: "encryption" })
|
|
6787
|
-
const spaceGranted = granted.filter(
|
|
6843
|
+
const rawGranted = granted.filter((entry) => this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry)).map((entry) => this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry);
|
|
6844
|
+
const spaceGranted = granted.filter(
|
|
6845
|
+
(entry) => !this.isEncryptionPermissionEntry(entry) && !this.isRawRevocationPermissionEntry(entry)
|
|
6846
|
+
);
|
|
6788
6847
|
const missing = requested.filter((entry) => {
|
|
6789
|
-
const raw = this.isEncryptionPermissionEntry(entry);
|
|
6790
|
-
const comparable = raw ? { ...entry, space: "encryption" } : entry;
|
|
6848
|
+
const raw = this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry);
|
|
6849
|
+
const comparable = raw && this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry;
|
|
6791
6850
|
return !isCapabilitySubset([comparable], raw ? rawGranted : spaceGranted).subset;
|
|
6792
6851
|
});
|
|
6793
6852
|
return { subset: missing.length === 0, missing };
|
|
@@ -6802,10 +6861,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6802
6861
|
}
|
|
6803
6862
|
permissionEntriesToOperations(entries, session) {
|
|
6804
6863
|
return entries.flatMap((entry) => {
|
|
6805
|
-
const
|
|
6864
|
+
const rawRevocation = this.isRawRevocationPermissionEntry(entry);
|
|
6865
|
+
const spaceId = rawRevocation ? void 0 : this.resolvePermissionSpace(entry.space, session);
|
|
6806
6866
|
const service = this.shortServiceName(entry.service);
|
|
6807
6867
|
return entry.actions.map((action) => ({
|
|
6808
|
-
...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
6868
|
+
...rawRevocation ? { resource: entry.space } : this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
6809
6869
|
service,
|
|
6810
6870
|
path: entry.path,
|
|
6811
6871
|
action,
|
|
@@ -6884,7 +6944,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6884
6944
|
delegatedResourcesForEntries(entries, spaceId) {
|
|
6885
6945
|
return entries.map((entry) => ({
|
|
6886
6946
|
service: this.shortServiceName(entry.service),
|
|
6887
|
-
space: this.isEncryptionPermissionEntry(entry) ? "encryption" : spaceId,
|
|
6947
|
+
space: this.isRawRevocationPermissionEntry(entry) ? entry.space : this.isEncryptionPermissionEntry(entry) ? "encryption" : spaceId,
|
|
6888
6948
|
path: entry.path,
|
|
6889
6949
|
actions: [...entry.actions],
|
|
6890
6950
|
...entry.caveats === void 0 ? {} : { caveats: cloneRecapCaveats(entry.caveats) }
|
|
@@ -6894,8 +6954,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6894
6954
|
const resources = delegation.resources !== void 0 && delegation.resources.length > 0 ? delegation.resources : this.flatDelegationResources(delegation);
|
|
6895
6955
|
return resources.flatMap((resource) => {
|
|
6896
6956
|
const service = this.invocationServiceName(resource.service);
|
|
6957
|
+
const rawRevocation = service === "delegation" && resource.space.startsWith("urn:cid:") && resource.path === "";
|
|
6897
6958
|
return resource.actions.map((action) => ({
|
|
6898
|
-
...this.isEncryptionNetworkOperation(service, resource.path, resource.space) ? { resource: resource.path } : { spaceId: resource.space },
|
|
6959
|
+
...rawRevocation ? { resource: resource.space } : this.isEncryptionNetworkOperation(service, resource.path, resource.space) ? { resource: resource.path } : { spaceId: resource.space },
|
|
6899
6960
|
service,
|
|
6900
6961
|
path: resource.path,
|
|
6901
6962
|
action,
|
|
@@ -6941,7 +7002,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6941
7002
|
* @internal
|
|
6942
7003
|
*/
|
|
6943
7004
|
buildActivationAbilities(delegation) {
|
|
6944
|
-
var _a, _b, _c;
|
|
7005
|
+
var _a, _b, _c, _d;
|
|
6945
7006
|
const resources = delegation.resources !== void 0 && delegation.resources.length > 0 ? delegation.resources : this.flatDelegationResources(delegation);
|
|
6946
7007
|
const abilities = {};
|
|
6947
7008
|
const rawAbilities = {};
|
|
@@ -6961,13 +7022,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6961
7022
|
addActions(rawAbilities[resource.path], resource.actions);
|
|
6962
7023
|
continue;
|
|
6963
7024
|
}
|
|
7025
|
+
if (service === "delegation" && resource.space.startsWith("urn:cid:") && resource.path === "") {
|
|
7026
|
+
rawAbilities[_b = resource.space] ?? (rawAbilities[_b] = []);
|
|
7027
|
+
addActions(rawAbilities[resource.space], resource.actions);
|
|
7028
|
+
continue;
|
|
7029
|
+
}
|
|
6964
7030
|
if (resource.space !== delegation.spaceId) {
|
|
6965
7031
|
throw new Error(
|
|
6966
7032
|
`useDelegation: resource targets space '${resource.space}' but the delegation activates space '${delegation.spaceId}'. Multi-space delegations cannot be activated in a single useDelegation call.`
|
|
6967
7033
|
);
|
|
6968
7034
|
}
|
|
6969
7035
|
abilities[service] ?? (abilities[service] = {});
|
|
6970
|
-
(
|
|
7036
|
+
(_c = abilities[service])[_d = resource.path] ?? (_c[_d] = []);
|
|
6971
7037
|
addActions(abilities[service][resource.path], resource.actions);
|
|
6972
7038
|
}
|
|
6973
7039
|
return { abilities, rawAbilities };
|