@tinycloud/node-sdk 3.1.0-beta.9 → 3.2.0-beta.0
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-AEx5vAa8.d.cts} +21 -0
- package/dist/{core-CC7uDKZP.d.ts → core-AEx5vAa8.d.ts} +21 -0
- package/dist/core.cjs +171 -85
- 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 +171 -85
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +171 -85
- 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 +171 -85
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
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-AEx5vAa8.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-AEx5vAa8.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 }
|
|
@@ -6385,8 +6434,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6385
6434
|
* @throws {@link PermissionNotInManifestError} when any requested
|
|
6386
6435
|
* entry is not a subset of the granted session capabilities and
|
|
6387
6436
|
* `forceWalletSign` is not set.
|
|
6437
|
+
* @throws when `onPrepared` is combined with `forceWalletSign: true`,
|
|
6438
|
+
* before anything is signed.
|
|
6439
|
+
* @throws the `onPrepared` rejection, unchanged, without activating the
|
|
6440
|
+
* delegation.
|
|
6388
6441
|
*/
|
|
6389
6442
|
async delegateTo(did, permissions, options) {
|
|
6443
|
+
const onPrepared = options?.onPrepared;
|
|
6444
|
+
if (onPrepared && options?.forceWalletSign) {
|
|
6445
|
+
throw new Error(
|
|
6446
|
+
"delegateTo: onPrepared cannot be combined with forceWalletSign=true; the wallet-signed path activates the delegation before it could be handed to onPrepared."
|
|
6447
|
+
);
|
|
6448
|
+
}
|
|
6390
6449
|
const session = this.currentTinyCloudSession();
|
|
6391
6450
|
if (!session) {
|
|
6392
6451
|
throw new SessionExpiredError(/* @__PURE__ */ new Date(0));
|
|
@@ -6445,7 +6504,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6445
6504
|
expandedEntries,
|
|
6446
6505
|
runtimeExpiration,
|
|
6447
6506
|
runtimeGrant,
|
|
6448
|
-
runtimeOperations
|
|
6507
|
+
runtimeOperations,
|
|
6508
|
+
onPrepared
|
|
6449
6509
|
);
|
|
6450
6510
|
return { delegation: delegation2, prompted: false };
|
|
6451
6511
|
}
|
|
@@ -6455,7 +6515,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6455
6515
|
did,
|
|
6456
6516
|
expandedEntries,
|
|
6457
6517
|
effectiveExpiration,
|
|
6458
|
-
session
|
|
6518
|
+
session,
|
|
6519
|
+
onPrepared
|
|
6459
6520
|
);
|
|
6460
6521
|
return { delegation, prompted: false };
|
|
6461
6522
|
}
|
|
@@ -6509,7 +6570,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6509
6570
|
*
|
|
6510
6571
|
* @internal
|
|
6511
6572
|
*/
|
|
6512
|
-
async createDelegationViaWasmPath(did, entries, expirationTime, session) {
|
|
6573
|
+
async createDelegationViaWasmPath(did, entries, expirationTime, session, onPrepared) {
|
|
6513
6574
|
if (entries.length === 0) {
|
|
6514
6575
|
throw new Error(
|
|
6515
6576
|
"createDelegationViaWasmPath requires a non-empty entries array"
|
|
@@ -6572,17 +6633,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6572
6633
|
});
|
|
6573
6634
|
const primary = result.resources[0];
|
|
6574
6635
|
const delegationHeader = { Authorization: result.delegation };
|
|
6575
|
-
const
|
|
6576
|
-
this.config.host,
|
|
6577
|
-
delegationHeader
|
|
6578
|
-
);
|
|
6579
|
-
if (!activateResult.success) {
|
|
6580
|
-
throw Object.assign(
|
|
6581
|
-
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
6582
|
-
{ cause: activateResult }
|
|
6583
|
-
);
|
|
6584
|
-
}
|
|
6585
|
-
return {
|
|
6636
|
+
const delegation = {
|
|
6586
6637
|
cid: result.cid,
|
|
6587
6638
|
delegationHeader,
|
|
6588
6639
|
spaceId,
|
|
@@ -6596,8 +6647,22 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6596
6647
|
chainId: session.chainId,
|
|
6597
6648
|
host: this.config.host
|
|
6598
6649
|
};
|
|
6650
|
+
if (onPrepared) {
|
|
6651
|
+
await onPrepared(delegation);
|
|
6652
|
+
}
|
|
6653
|
+
const activateResult = await activateSessionWithHost2(
|
|
6654
|
+
this.config.host,
|
|
6655
|
+
delegationHeader
|
|
6656
|
+
);
|
|
6657
|
+
if (!activateResult.success) {
|
|
6658
|
+
throw Object.assign(
|
|
6659
|
+
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
6660
|
+
{ cause: activateResult }
|
|
6661
|
+
);
|
|
6662
|
+
}
|
|
6663
|
+
return delegation;
|
|
6599
6664
|
}
|
|
6600
|
-
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations) {
|
|
6665
|
+
async createDelegationViaRuntimeGrant(did, entries, expirationTime, grant, requestedOperations, onPrepared) {
|
|
6601
6666
|
this.assertRuntimeGrantCaveatsPreservable(entries, requestedOperations, grant);
|
|
6602
6667
|
this.assertDelegationCaveatsPreservable(entries);
|
|
6603
6668
|
const result = this.createDelegationWrapper({
|
|
@@ -6610,17 +6675,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6610
6675
|
const primary = result.resources[0];
|
|
6611
6676
|
const delegationHeader = { Authorization: result.delegation };
|
|
6612
6677
|
const targetHost = grant.delegation.host ?? this.config.host;
|
|
6613
|
-
const
|
|
6614
|
-
targetHost,
|
|
6615
|
-
delegationHeader
|
|
6616
|
-
);
|
|
6617
|
-
if (!activateResult.success) {
|
|
6618
|
-
throw Object.assign(
|
|
6619
|
-
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
6620
|
-
{ cause: activateResult }
|
|
6621
|
-
);
|
|
6622
|
-
}
|
|
6623
|
-
return {
|
|
6678
|
+
const delegation = {
|
|
6624
6679
|
cid: result.cid,
|
|
6625
6680
|
delegationHeader,
|
|
6626
6681
|
spaceId: grant.session.spaceId,
|
|
@@ -6634,6 +6689,20 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6634
6689
|
chainId: grant.delegation.chainId,
|
|
6635
6690
|
host: targetHost
|
|
6636
6691
|
};
|
|
6692
|
+
if (onPrepared) {
|
|
6693
|
+
await onPrepared(delegation);
|
|
6694
|
+
}
|
|
6695
|
+
const activateResult = await activateSessionWithHost2(
|
|
6696
|
+
targetHost,
|
|
6697
|
+
delegationHeader
|
|
6698
|
+
);
|
|
6699
|
+
if (!activateResult.success) {
|
|
6700
|
+
throw Object.assign(
|
|
6701
|
+
new Error(`Failed to activate delegation with host: ${describeHostFailure2(activateResult)}`),
|
|
6702
|
+
{ cause: activateResult }
|
|
6703
|
+
);
|
|
6704
|
+
}
|
|
6705
|
+
return delegation;
|
|
6637
6706
|
}
|
|
6638
6707
|
resolvePermissionSpace(space, session) {
|
|
6639
6708
|
if (space === void 0) {
|
|
@@ -6734,6 +6803,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6734
6803
|
permissionsToAbilities(entries) {
|
|
6735
6804
|
const abilities = {};
|
|
6736
6805
|
for (const entry of entries) {
|
|
6806
|
+
if (this.isRawRevocationPermissionEntry(entry)) continue;
|
|
6737
6807
|
const service = this.shortServiceName(entry.service);
|
|
6738
6808
|
abilities[service] ?? (abilities[service] = {});
|
|
6739
6809
|
const existing = abilities[service][entry.path] ?? [];
|
|
@@ -6751,9 +6821,16 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6751
6821
|
isEncryptionPermissionEntry(entry) {
|
|
6752
6822
|
return entry.service === ENCRYPTION_PERMISSION_SERVICE2 && this.isEncryptionNetworkOperation("encryption", entry.path, entry.space);
|
|
6753
6823
|
}
|
|
6824
|
+
isRawRevocationPermissionEntry(entry) {
|
|
6825
|
+
return entry.service === "tinycloud.delegation" && entry.path === "" && entry.space?.startsWith("urn:cid:") === true && entry.actions.includes("tinycloud.delegation/revoke");
|
|
6826
|
+
}
|
|
6754
6827
|
permissionsToRawAbilities(entries) {
|
|
6755
6828
|
const rawAbilities = {};
|
|
6756
6829
|
for (const entry of entries) {
|
|
6830
|
+
if (this.isRawRevocationPermissionEntry(entry)) {
|
|
6831
|
+
rawAbilities[entry.space] = [...new Set(entry.actions)];
|
|
6832
|
+
continue;
|
|
6833
|
+
}
|
|
6757
6834
|
if (!this.isEncryptionPermissionEntry(entry)) {
|
|
6758
6835
|
continue;
|
|
6759
6836
|
}
|
|
@@ -6773,7 +6850,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6773
6850
|
return entries.flatMap((entry) => {
|
|
6774
6851
|
const service = this.shortServiceName(entry.service);
|
|
6775
6852
|
return entry.actions.map((action) => ({
|
|
6776
|
-
...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
6853
|
+
...this.isRawRevocationPermissionEntry(entry) ? { resource: entry.space } : this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
6777
6854
|
service,
|
|
6778
6855
|
path: entry.path,
|
|
6779
6856
|
action,
|
|
@@ -6783,11 +6860,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6783
6860
|
}
|
|
6784
6861
|
/** Raw network authority cannot be covered by a nested encryption space. */
|
|
6785
6862
|
signedCapabilitySubset(requested, granted) {
|
|
6786
|
-
const rawGranted = granted.filter((entry) => this.isEncryptionPermissionEntry(entry)).map((entry) => ({ ...entry, space: "encryption" })
|
|
6787
|
-
const spaceGranted = granted.filter(
|
|
6863
|
+
const rawGranted = granted.filter((entry) => this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry)).map((entry) => this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry);
|
|
6864
|
+
const spaceGranted = granted.filter(
|
|
6865
|
+
(entry) => !this.isEncryptionPermissionEntry(entry) && !this.isRawRevocationPermissionEntry(entry)
|
|
6866
|
+
);
|
|
6788
6867
|
const missing = requested.filter((entry) => {
|
|
6789
|
-
const raw = this.isEncryptionPermissionEntry(entry);
|
|
6790
|
-
const comparable = raw ? { ...entry, space: "encryption" } : entry;
|
|
6868
|
+
const raw = this.isEncryptionPermissionEntry(entry) || this.isRawRevocationPermissionEntry(entry);
|
|
6869
|
+
const comparable = raw && this.isEncryptionPermissionEntry(entry) ? { ...entry, space: "encryption" } : entry;
|
|
6791
6870
|
return !isCapabilitySubset([comparable], raw ? rawGranted : spaceGranted).subset;
|
|
6792
6871
|
});
|
|
6793
6872
|
return { subset: missing.length === 0, missing };
|
|
@@ -6802,10 +6881,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6802
6881
|
}
|
|
6803
6882
|
permissionEntriesToOperations(entries, session) {
|
|
6804
6883
|
return entries.flatMap((entry) => {
|
|
6805
|
-
const
|
|
6884
|
+
const rawRevocation = this.isRawRevocationPermissionEntry(entry);
|
|
6885
|
+
const spaceId = rawRevocation ? void 0 : this.resolvePermissionSpace(entry.space, session);
|
|
6806
6886
|
const service = this.shortServiceName(entry.service);
|
|
6807
6887
|
return entry.actions.map((action) => ({
|
|
6808
|
-
...this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
6888
|
+
...rawRevocation ? { resource: entry.space } : this.isEncryptionNetworkOperation(service, entry.path, entry.space) ? { resource: entry.path } : { spaceId },
|
|
6809
6889
|
service,
|
|
6810
6890
|
path: entry.path,
|
|
6811
6891
|
action,
|
|
@@ -6884,7 +6964,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6884
6964
|
delegatedResourcesForEntries(entries, spaceId) {
|
|
6885
6965
|
return entries.map((entry) => ({
|
|
6886
6966
|
service: this.shortServiceName(entry.service),
|
|
6887
|
-
space: this.isEncryptionPermissionEntry(entry) ? "encryption" : spaceId,
|
|
6967
|
+
space: this.isRawRevocationPermissionEntry(entry) ? entry.space : this.isEncryptionPermissionEntry(entry) ? "encryption" : spaceId,
|
|
6888
6968
|
path: entry.path,
|
|
6889
6969
|
actions: [...entry.actions],
|
|
6890
6970
|
...entry.caveats === void 0 ? {} : { caveats: cloneRecapCaveats(entry.caveats) }
|
|
@@ -6894,8 +6974,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6894
6974
|
const resources = delegation.resources !== void 0 && delegation.resources.length > 0 ? delegation.resources : this.flatDelegationResources(delegation);
|
|
6895
6975
|
return resources.flatMap((resource) => {
|
|
6896
6976
|
const service = this.invocationServiceName(resource.service);
|
|
6977
|
+
const rawRevocation = service === "delegation" && resource.space.startsWith("urn:cid:") && resource.path === "";
|
|
6897
6978
|
return resource.actions.map((action) => ({
|
|
6898
|
-
...this.isEncryptionNetworkOperation(service, resource.path, resource.space) ? { resource: resource.path } : { spaceId: resource.space },
|
|
6979
|
+
...rawRevocation ? { resource: resource.space } : this.isEncryptionNetworkOperation(service, resource.path, resource.space) ? { resource: resource.path } : { spaceId: resource.space },
|
|
6899
6980
|
service,
|
|
6900
6981
|
path: resource.path,
|
|
6901
6982
|
action,
|
|
@@ -6941,7 +7022,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6941
7022
|
* @internal
|
|
6942
7023
|
*/
|
|
6943
7024
|
buildActivationAbilities(delegation) {
|
|
6944
|
-
var _a, _b, _c;
|
|
7025
|
+
var _a, _b, _c, _d;
|
|
6945
7026
|
const resources = delegation.resources !== void 0 && delegation.resources.length > 0 ? delegation.resources : this.flatDelegationResources(delegation);
|
|
6946
7027
|
const abilities = {};
|
|
6947
7028
|
const rawAbilities = {};
|
|
@@ -6961,13 +7042,18 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
6961
7042
|
addActions(rawAbilities[resource.path], resource.actions);
|
|
6962
7043
|
continue;
|
|
6963
7044
|
}
|
|
7045
|
+
if (service === "delegation" && resource.space.startsWith("urn:cid:") && resource.path === "") {
|
|
7046
|
+
rawAbilities[_b = resource.space] ?? (rawAbilities[_b] = []);
|
|
7047
|
+
addActions(rawAbilities[resource.space], resource.actions);
|
|
7048
|
+
continue;
|
|
7049
|
+
}
|
|
6964
7050
|
if (resource.space !== delegation.spaceId) {
|
|
6965
7051
|
throw new Error(
|
|
6966
7052
|
`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
7053
|
);
|
|
6968
7054
|
}
|
|
6969
7055
|
abilities[service] ?? (abilities[service] = {});
|
|
6970
|
-
(
|
|
7056
|
+
(_c = abilities[service])[_d = resource.path] ?? (_c[_d] = []);
|
|
6971
7057
|
addActions(abilities[service][resource.path], resource.actions);
|
|
6972
7058
|
}
|
|
6973
7059
|
return { abilities, rawAbilities };
|