@tinycloud/node-sdk 2.1.0-beta.6 → 2.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.cjs +191 -13
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +48 -9
- package/dist/core.d.ts +48 -9
- package/dist/core.js +199 -18
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +191 -13
- 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 +199 -18
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ISigner, Bytes, IWasmBindings, ISessionManager } from '@tinycloud/sdk-core';
|
|
2
|
-
export { AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, ClientSession, ColumnInfo, CreateDelegationParams, DataVaultConfig, DataVaultService, DatabaseHandle, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IngestOptions, InvokeFunction, JWK, KVResponse, KVService, KVServiceConfig, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults,
|
|
2
|
+
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DataVaultConfig, DataVaultService, DatabaseHandle, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IngestOptions, InvokeFunction, JWK, KVResponse, KVService, KVServiceConfig, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestValidationError, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, ResolvedCapabilities, ResolvedDelegate, ResourceCapability, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, 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, SubscribeOptions, TableInfo, TinyCloud, TinyCloudConfig, TinyCloudSession, UnsupportedFeatureError, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, buildSpaceUri, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, expandActionShortNames, isCapabilitySubset, loadManifest, makePublicSpaceId, parseExpiry, parseSpaceUri, resolveManifest, resourceCapabilitiesToSpaceAbilitiesMap, validateManifest } from '@tinycloud/sdk-core';
|
|
3
3
|
export { DelegateToOptions, DelegateToResult, DelegatedAccess, FileSessionStorage, MemorySessionStorage, NodeEventEmitterStrategy, NodeUserAuthorization, NodeUserAuthorizationConfig, PortableDelegation, SignStrategy, TinyCloudNode, TinyCloudNodeConfig, WasmKeyProvider, WasmKeyProviderConfig, createWasmKeyProvider, defaultSignStrategy, deserializeDelegation, serializeDelegation } from './core.cjs';
|
|
4
4
|
import { invoke, invokeAny, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, generateHostSIWEMessage, siweToDelegationHeaders, protocolVersion, vault_encrypt, vault_decrypt, vault_derive_key, vault_x25519_from_seed, vault_x25519_dh, vault_random_bytes, vault_sha256 } from '@tinycloud/node-sdk-wasm';
|
|
5
5
|
import 'events';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ISigner, Bytes, IWasmBindings, ISessionManager } from '@tinycloud/sdk-core';
|
|
2
|
-
export { AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, ClientSession, ColumnInfo, CreateDelegationParams, DataVaultConfig, DataVaultService, DatabaseHandle, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IngestOptions, InvokeFunction, JWK, KVResponse, KVService, KVServiceConfig, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults,
|
|
2
|
+
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, AutoApproveSpaceCreationHandler, AutoRejectStrategy, AutoSignStrategy, BatchOptions, BatchResponse, CallbackStrategy, CapabilityEntry, CapabilityKeyRegistry, CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, ClientSession, ColumnInfo, ComposeManifestOptions, ComposedManifestRequest, CreateDelegationParams, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DataVaultConfig, DataVaultService, DatabaseHandle, Delegation, DelegationChain, DelegationChainV2, DelegationDirection, DelegationError, DelegationErrorCode, DelegationErrorCodes, DelegationFilters, DelegationManager, DelegationManagerConfig, DelegationRecord, DelegationResult, DuckDbAction, DuckDbActionType, DuckDbBatchOptions, DuckDbBatchResponse, DuckDbDatabaseHandle, DuckDbExecuteOptions, DuckDbExecuteResponse, DuckDbOptions, DuckDbQueryOptions, DuckDbQueryResponse, DuckDbService, DuckDbServiceConfig, DuckDbStatement, DuckDbValue, EncodedShareData, ExecuteOptions, ExecuteResponse, Extension, FetchFunction, GenerateShareParams, HookEvent, HookServiceName, HookStreamEvent, HookSubscription, HookWebhookListOptions, HookWebhookRecord, HookWebhookRegistration, HookWebhookScope, HookWebhookUnregisterOptions, HooksService, HooksServiceConfig, ICapabilityKeyRegistry, IDataVaultService, IDatabaseHandle, IDuckDbDatabaseHandle, IDuckDbService, IENSResolver, IHooksService, IKVService, INotificationHandler, IPrefixedKVService, ISQLService, ISessionManager, ISessionStorage, ISharingService, ISigner, ISpace, ISpaceCreationHandler, ISpaceScopedDelegations, ISpaceScopedSharing, ISpaceService, IUserAuthorization, IWasmBindings, IngestOptions, InvokeFunction, JWK, KVResponse, KVService, KVServiceConfig, KeyInfo, KeyProvider, KeyType, Manifest, ManifestDefaults, ManifestRegistryRecord, ManifestValidationError, PermissionEntry, PermissionNotInManifestError, PersistedSessionData, PrefixedKVService, ProtocolMismatchError, QueryOptions, QueryResponse, ReceiveOptions, ResolvedCapabilities, ResolvedDelegate, ResourceCapability, SQLAction, SQLActionType, SQLService, SQLServiceConfig, SchemaInfo, 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, SubscribeOptions, TableInfo, TinyCloud, TinyCloudConfig, TinyCloudSession, UnsupportedFeatureError, VaultCrypto, VaultEntry, VaultError, VaultGetOptions, VaultGrantOptions, VaultHeaders, VaultListOptions, VaultPublicSpaceKVActions, VaultPutOptions, VersionCheckError, ViewInfo, WasmVaultFunctions, buildSpaceUri, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, createVaultCrypto, defaultSpaceCreationHandler, expandActionShortNames, isCapabilitySubset, loadManifest, makePublicSpaceId, parseExpiry, parseSpaceUri, resolveManifest, resourceCapabilitiesToSpaceAbilitiesMap, validateManifest } from '@tinycloud/sdk-core';
|
|
3
3
|
export { DelegateToOptions, DelegateToResult, DelegatedAccess, FileSessionStorage, MemorySessionStorage, NodeEventEmitterStrategy, NodeUserAuthorization, NodeUserAuthorizationConfig, PortableDelegation, SignStrategy, TinyCloudNode, TinyCloudNodeConfig, WasmKeyProvider, WasmKeyProviderConfig, createWasmKeyProvider, defaultSignStrategy, deserializeDelegation, serializeDelegation } from './core.js';
|
|
4
4
|
import { invoke, invokeAny, prepareSession, completeSessionSetup, ensureEip55, makeSpaceId, createDelegation, parseRecapFromSiwe, generateHostSIWEMessage, siweToDelegationHeaders, protocolVersion, vault_encrypt, vault_decrypt, vault_derive_key, vault_x25519_from_seed, vault_x25519_dh, vault_random_bytes, vault_sha256 } from '@tinycloud/node-sdk-wasm';
|
|
5
5
|
import 'events';
|
package/dist/index.js
CHANGED
|
@@ -17168,6 +17168,7 @@ import {
|
|
|
17168
17168
|
SharingService,
|
|
17169
17169
|
UnsupportedFeatureError,
|
|
17170
17170
|
makePublicSpaceId,
|
|
17171
|
+
ACCOUNT_REGISTRY_SPACE,
|
|
17171
17172
|
PermissionNotInManifestError,
|
|
17172
17173
|
SessionExpiredError,
|
|
17173
17174
|
expandActionShortNames,
|
|
@@ -17183,8 +17184,10 @@ import {
|
|
|
17183
17184
|
activateSessionWithHost,
|
|
17184
17185
|
checkNodeInfo,
|
|
17185
17186
|
AutoApproveSpaceCreationHandler,
|
|
17186
|
-
|
|
17187
|
-
|
|
17187
|
+
DEFAULT_MANIFEST_SPACE,
|
|
17188
|
+
composeManifestRequest,
|
|
17189
|
+
resourceCapabilitiesToAbilitiesMap,
|
|
17190
|
+
resourceCapabilitiesToSpaceAbilitiesMap
|
|
17188
17191
|
} from "@tinycloud/sdk-core";
|
|
17189
17192
|
|
|
17190
17193
|
// src/authorization/strategies.ts
|
|
@@ -17324,7 +17327,9 @@ var NodeUserAuthorization = class {
|
|
|
17324
17327
|
this.enablePublicSpace = config.enablePublicSpace ?? true;
|
|
17325
17328
|
this.nonce = config.nonce;
|
|
17326
17329
|
this.siweConfig = config.siweConfig;
|
|
17330
|
+
this.includeAccountRegistryPermissions = config.includeAccountRegistryPermissions ?? true;
|
|
17327
17331
|
this._manifest = config.manifest;
|
|
17332
|
+
this._capabilityRequest = config.capabilityRequest;
|
|
17328
17333
|
this.sessionManager = this.wasm.createSessionManager();
|
|
17329
17334
|
}
|
|
17330
17335
|
/**
|
|
@@ -17336,12 +17341,19 @@ var NodeUserAuthorization = class {
|
|
|
17336
17341
|
get manifest() {
|
|
17337
17342
|
return this._manifest;
|
|
17338
17343
|
}
|
|
17344
|
+
get capabilityRequest() {
|
|
17345
|
+
return this.getCapabilityRequest();
|
|
17346
|
+
}
|
|
17339
17347
|
/**
|
|
17340
17348
|
* Install or replace the stored manifest. Takes effect on the next
|
|
17341
17349
|
* `signIn()` call — the current session (if any) is not touched.
|
|
17342
17350
|
*/
|
|
17343
17351
|
setManifest(manifest) {
|
|
17344
17352
|
this._manifest = manifest;
|
|
17353
|
+
this._capabilityRequest = void 0;
|
|
17354
|
+
}
|
|
17355
|
+
setCapabilityRequest(request) {
|
|
17356
|
+
this._capabilityRequest = request;
|
|
17345
17357
|
}
|
|
17346
17358
|
/**
|
|
17347
17359
|
* The current active session (web-core compatible).
|
|
@@ -17385,12 +17397,51 @@ var NodeUserAuthorization = class {
|
|
|
17385
17397
|
*
|
|
17386
17398
|
* @internal
|
|
17387
17399
|
*/
|
|
17388
|
-
|
|
17400
|
+
getCapabilityRequest() {
|
|
17401
|
+
if (this._capabilityRequest !== void 0) {
|
|
17402
|
+
return this._capabilityRequest;
|
|
17403
|
+
}
|
|
17389
17404
|
if (this._manifest === void 0) {
|
|
17390
|
-
return
|
|
17405
|
+
return void 0;
|
|
17406
|
+
}
|
|
17407
|
+
this._capabilityRequest = composeManifestRequest(
|
|
17408
|
+
Array.isArray(this._manifest) ? this._manifest : [this._manifest],
|
|
17409
|
+
{
|
|
17410
|
+
includeAccountRegistryPermissions: this.includeAccountRegistryPermissions
|
|
17411
|
+
}
|
|
17412
|
+
);
|
|
17413
|
+
return this._capabilityRequest;
|
|
17414
|
+
}
|
|
17415
|
+
resolveSpaceName(space, address, chainId) {
|
|
17416
|
+
if (space.startsWith("tinycloud:")) {
|
|
17417
|
+
return space;
|
|
17391
17418
|
}
|
|
17392
|
-
|
|
17393
|
-
|
|
17419
|
+
return this.wasm.makeSpaceId(address, chainId, space);
|
|
17420
|
+
}
|
|
17421
|
+
resolveSignInCapabilities(address, chainId) {
|
|
17422
|
+
const request = this.getCapabilityRequest();
|
|
17423
|
+
if (request === void 0) {
|
|
17424
|
+
return {
|
|
17425
|
+
abilities: this.defaultActions,
|
|
17426
|
+
spaceId: this.wasm.makeSpaceId(address, chainId, this.spacePrefix)
|
|
17427
|
+
};
|
|
17428
|
+
}
|
|
17429
|
+
const primarySpaceName = request.resources.find((entry) => entry.space !== "account")?.space ?? DEFAULT_MANIFEST_SPACE;
|
|
17430
|
+
const primarySpaceId = this.resolveSpaceName(
|
|
17431
|
+
primarySpaceName,
|
|
17432
|
+
address,
|
|
17433
|
+
chainId
|
|
17434
|
+
);
|
|
17435
|
+
const bySpace = resourceCapabilitiesToSpaceAbilitiesMap(request.resources);
|
|
17436
|
+
const spaceAbilities = {};
|
|
17437
|
+
for (const [space, abilities] of Object.entries(bySpace)) {
|
|
17438
|
+
spaceAbilities[this.resolveSpaceName(space, address, chainId)] = abilities;
|
|
17439
|
+
}
|
|
17440
|
+
return {
|
|
17441
|
+
abilities: spaceAbilities[primarySpaceId] ?? resourceCapabilitiesToAbilitiesMap([]),
|
|
17442
|
+
spaceId: primarySpaceId,
|
|
17443
|
+
spaceAbilities
|
|
17444
|
+
};
|
|
17394
17445
|
}
|
|
17395
17446
|
/**
|
|
17396
17447
|
* Build SIWE overrides from the top-level nonce and siweConfig.
|
|
@@ -17471,6 +17522,13 @@ var NodeUserAuthorization = class {
|
|
|
17471
17522
|
async hostPublicSpace(spaceId) {
|
|
17472
17523
|
return this.hostSpace(spaceId);
|
|
17473
17524
|
}
|
|
17525
|
+
/**
|
|
17526
|
+
* Create a specific owned space on the server via host delegation.
|
|
17527
|
+
* Used by manifest registry setup for the account space.
|
|
17528
|
+
*/
|
|
17529
|
+
async hostOwnedSpace(spaceId) {
|
|
17530
|
+
return this.hostSpace(spaceId);
|
|
17531
|
+
}
|
|
17474
17532
|
/**
|
|
17475
17533
|
* Ensure the user's space exists on the TinyCloud server.
|
|
17476
17534
|
* Creates the space if it doesn't exist and autoCreateSpace is enabled.
|
|
@@ -17599,11 +17657,13 @@ var NodeUserAuthorization = class {
|
|
|
17599
17657
|
throw new Error("Failed to create session key");
|
|
17600
17658
|
}
|
|
17601
17659
|
const jwk = JSON.parse(jwkString);
|
|
17602
|
-
const
|
|
17660
|
+
const capabilityPlan = this.resolveSignInCapabilities(address, chainId);
|
|
17661
|
+
const spaceId = capabilityPlan.spaceId;
|
|
17603
17662
|
const now = /* @__PURE__ */ new Date();
|
|
17604
17663
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
17605
17664
|
const prepared = this.wasm.prepareSession({
|
|
17606
|
-
abilities:
|
|
17665
|
+
abilities: capabilityPlan.abilities,
|
|
17666
|
+
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
17607
17667
|
address,
|
|
17608
17668
|
chainId,
|
|
17609
17669
|
domain: this.domain,
|
|
@@ -17742,11 +17802,13 @@ var NodeUserAuthorization = class {
|
|
|
17742
17802
|
throw new Error("Failed to create session key");
|
|
17743
17803
|
}
|
|
17744
17804
|
const jwk = JSON.parse(jwkString);
|
|
17745
|
-
const
|
|
17805
|
+
const capabilityPlan = this.resolveSignInCapabilities(address, chainId);
|
|
17806
|
+
const spaceId = capabilityPlan.spaceId;
|
|
17746
17807
|
const now = /* @__PURE__ */ new Date();
|
|
17747
17808
|
const expirationTime = new Date(now.getTime() + this.sessionExpirationMs);
|
|
17748
17809
|
const prepared = this.wasm.prepareSession({
|
|
17749
|
-
abilities:
|
|
17810
|
+
abilities: capabilityPlan.abilities,
|
|
17811
|
+
...capabilityPlan.spaceAbilities !== void 0 ? { spaceAbilities: capabilityPlan.spaceAbilities } : {},
|
|
17750
17812
|
address,
|
|
17751
17813
|
chainId,
|
|
17752
17814
|
domain: this.domain,
|
|
@@ -18262,7 +18324,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18262
18324
|
spaceCreationHandler: config.spaceCreationHandler,
|
|
18263
18325
|
nonce: config.nonce,
|
|
18264
18326
|
siweConfig: config.siweConfig,
|
|
18265
|
-
manifest: config.manifest
|
|
18327
|
+
manifest: config.manifest,
|
|
18328
|
+
capabilityRequest: config.capabilityRequest,
|
|
18329
|
+
includeAccountRegistryPermissions: config.includeAccountRegistryPermissions
|
|
18266
18330
|
});
|
|
18267
18331
|
this.tc = new TinyCloud(this.auth, {
|
|
18268
18332
|
invokeAny: this.wasmBindings.invokeAny
|
|
@@ -18281,8 +18345,20 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18281
18345
|
"setManifest requires wallet mode. Provide a signer or privateKey in the TinyCloudNode config."
|
|
18282
18346
|
);
|
|
18283
18347
|
}
|
|
18348
|
+
this.config.manifest = manifest;
|
|
18349
|
+
this.config.capabilityRequest = void 0;
|
|
18284
18350
|
this.auth.setManifest(manifest);
|
|
18285
18351
|
}
|
|
18352
|
+
setCapabilityRequest(request) {
|
|
18353
|
+
if (!this.auth) {
|
|
18354
|
+
throw new Error(
|
|
18355
|
+
"setCapabilityRequest requires wallet mode. Provide a signer or privateKey in the TinyCloudNode config."
|
|
18356
|
+
);
|
|
18357
|
+
}
|
|
18358
|
+
this.config.capabilityRequest = request;
|
|
18359
|
+
this.config.manifest = request?.manifests;
|
|
18360
|
+
this.auth.setCapabilityRequest(request);
|
|
18361
|
+
}
|
|
18286
18362
|
/**
|
|
18287
18363
|
* Return the manifest currently installed on the auth handler,
|
|
18288
18364
|
* or `undefined` if none is set.
|
|
@@ -18290,6 +18366,9 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18290
18366
|
get manifest() {
|
|
18291
18367
|
return this.auth?.manifest;
|
|
18292
18368
|
}
|
|
18369
|
+
get capabilityRequest() {
|
|
18370
|
+
return this.auth?.capabilityRequest;
|
|
18371
|
+
}
|
|
18293
18372
|
/**
|
|
18294
18373
|
* Get the primary identity DID for this user.
|
|
18295
18374
|
* - If wallet connected and signed in: returns PKH DID (did:pkh:eip155:{chainId}:{address})
|
|
@@ -18363,8 +18442,39 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18363
18442
|
this._serviceContext = void 0;
|
|
18364
18443
|
await this.tc.signIn(options);
|
|
18365
18444
|
this.initializeServices();
|
|
18445
|
+
await this.writeManifestRegistryRecords();
|
|
18366
18446
|
this.notificationHandler.success("Successfully signed in");
|
|
18367
18447
|
}
|
|
18448
|
+
ownedSpaceId(name) {
|
|
18449
|
+
if (!this._address) {
|
|
18450
|
+
throw new Error("Cannot resolve owned space before sign-in");
|
|
18451
|
+
}
|
|
18452
|
+
return this.wasmBindings.makeSpaceId(this._address, this._chainId, name);
|
|
18453
|
+
}
|
|
18454
|
+
async writeManifestRegistryRecords() {
|
|
18455
|
+
const request = this.capabilityRequest;
|
|
18456
|
+
if (!request || request.registryRecords.length === 0) {
|
|
18457
|
+
return;
|
|
18458
|
+
}
|
|
18459
|
+
if (!this.auth || !this.signer) {
|
|
18460
|
+
throw new Error("Manifest registry write requires wallet mode");
|
|
18461
|
+
}
|
|
18462
|
+
const accountSpaceId = this.ownedSpaceId(ACCOUNT_REGISTRY_SPACE);
|
|
18463
|
+
await this.auth.hostOwnedSpace(accountSpaceId);
|
|
18464
|
+
const accountKV = this.spaces.get(accountSpaceId).kv;
|
|
18465
|
+
for (const record of request.registryRecords) {
|
|
18466
|
+
const result = await accountKV.put(record.key, {
|
|
18467
|
+
app_id: record.app_id,
|
|
18468
|
+
manifests: record.manifests,
|
|
18469
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
18470
|
+
});
|
|
18471
|
+
if (!result.ok) {
|
|
18472
|
+
throw new Error(
|
|
18473
|
+
`Failed to write manifest registry record ${record.key}: ${result.error.message}`
|
|
18474
|
+
);
|
|
18475
|
+
}
|
|
18476
|
+
}
|
|
18477
|
+
}
|
|
18368
18478
|
/**
|
|
18369
18479
|
* Restore a previously established session from stored delegation data.
|
|
18370
18480
|
*
|
|
@@ -18502,7 +18612,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18502
18612
|
enablePublicSpace: this.config.enablePublicSpace ?? true,
|
|
18503
18613
|
spaceCreationHandler: this.config.spaceCreationHandler,
|
|
18504
18614
|
nonce: this.config.nonce,
|
|
18505
|
-
siweConfig: this.config.siweConfig
|
|
18615
|
+
siweConfig: this.config.siweConfig,
|
|
18616
|
+
manifest: this.config.manifest,
|
|
18617
|
+
capabilityRequest: this.config.capabilityRequest,
|
|
18618
|
+
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
18506
18619
|
});
|
|
18507
18620
|
this.tc = new TinyCloud(this.auth, {
|
|
18508
18621
|
invokeAny: this.wasmBindings.invokeAny
|
|
@@ -18542,7 +18655,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18542
18655
|
enablePublicSpace: this.config.enablePublicSpace ?? true,
|
|
18543
18656
|
spaceCreationHandler: this.config.spaceCreationHandler,
|
|
18544
18657
|
nonce: this.config.nonce,
|
|
18545
|
-
siweConfig: this.config.siweConfig
|
|
18658
|
+
siweConfig: this.config.siweConfig,
|
|
18659
|
+
manifest: this.config.manifest,
|
|
18660
|
+
capabilityRequest: this.config.capabilityRequest,
|
|
18661
|
+
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
18546
18662
|
});
|
|
18547
18663
|
this.tc = new TinyCloud(this.auth, {
|
|
18548
18664
|
invokeAny: this.wasmBindings.invokeAny
|
|
@@ -19404,6 +19520,42 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19404
19520
|
);
|
|
19405
19521
|
return { delegation, prompted: false };
|
|
19406
19522
|
}
|
|
19523
|
+
/**
|
|
19524
|
+
* Materialize one manifest-declared delegation using the current session key.
|
|
19525
|
+
* Delivery is intentionally out of band; callers decide how to transmit the
|
|
19526
|
+
* returned UCAN to the delegate.
|
|
19527
|
+
*/
|
|
19528
|
+
async materializeDelegation(did, request = this.capabilityRequest) {
|
|
19529
|
+
if (!request) {
|
|
19530
|
+
throw new Error(
|
|
19531
|
+
"materializeDelegation requires a composed manifest request"
|
|
19532
|
+
);
|
|
19533
|
+
}
|
|
19534
|
+
const target = request.delegationTargets.find((entry) => entry.did === did);
|
|
19535
|
+
if (!target) {
|
|
19536
|
+
throw new Error(`No manifest delegation target found for DID ${did}`);
|
|
19537
|
+
}
|
|
19538
|
+
const result = await this.delegateTo(target.did, target.permissions, {
|
|
19539
|
+
expiry: target.expiryMs
|
|
19540
|
+
});
|
|
19541
|
+
return { ...result, target };
|
|
19542
|
+
}
|
|
19543
|
+
/**
|
|
19544
|
+
* Materialize every delegation target declared by the composed manifest
|
|
19545
|
+
* request. This does not deliver the delegations anywhere.
|
|
19546
|
+
*/
|
|
19547
|
+
async materializeDelegations(request = this.capabilityRequest) {
|
|
19548
|
+
if (!request) {
|
|
19549
|
+
throw new Error(
|
|
19550
|
+
"materializeDelegations requires a composed manifest request"
|
|
19551
|
+
);
|
|
19552
|
+
}
|
|
19553
|
+
const out = [];
|
|
19554
|
+
for (const target of request.delegationTargets) {
|
|
19555
|
+
out.push(await this.materializeDelegation(target.did, request));
|
|
19556
|
+
}
|
|
19557
|
+
return out;
|
|
19558
|
+
}
|
|
19407
19559
|
/**
|
|
19408
19560
|
* Issue a delegation via the session-key UCAN WASM path.
|
|
19409
19561
|
*
|
|
@@ -19427,7 +19579,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19427
19579
|
}
|
|
19428
19580
|
const resolvedSpaces = /* @__PURE__ */ new Set();
|
|
19429
19581
|
for (const entry of entries) {
|
|
19430
|
-
const spaceId2 = entry.space
|
|
19582
|
+
const spaceId2 = this.resolvePermissionSpace(entry.space, session);
|
|
19431
19583
|
resolvedSpaces.add(spaceId2);
|
|
19432
19584
|
}
|
|
19433
19585
|
if (resolvedSpaces.size !== 1) {
|
|
@@ -19502,6 +19654,22 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19502
19654
|
host: this.config.host
|
|
19503
19655
|
};
|
|
19504
19656
|
}
|
|
19657
|
+
resolvePermissionSpace(space, session) {
|
|
19658
|
+
if (space === void 0) {
|
|
19659
|
+
return this.wasmBindings.makeSpaceId(
|
|
19660
|
+
session.address,
|
|
19661
|
+
session.chainId,
|
|
19662
|
+
"applications"
|
|
19663
|
+
);
|
|
19664
|
+
}
|
|
19665
|
+
if (space === "default") {
|
|
19666
|
+
return session.spaceId;
|
|
19667
|
+
}
|
|
19668
|
+
if (space.startsWith("tinycloud:")) {
|
|
19669
|
+
return space;
|
|
19670
|
+
}
|
|
19671
|
+
return this.wasmBindings.makeSpaceId(session.address, session.chainId, space);
|
|
19672
|
+
}
|
|
19505
19673
|
/**
|
|
19506
19674
|
* Issue a delegation via the legacy wallet-signed SIWE path for a single
|
|
19507
19675
|
* {@link PermissionEntry}. Shares the implementation with the public
|
|
@@ -19512,7 +19680,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
19512
19680
|
* @internal
|
|
19513
19681
|
*/
|
|
19514
19682
|
async createDelegationLegacyWalletPath(delegateDID, entry, expirationTime) {
|
|
19515
|
-
const
|
|
19683
|
+
const session = this.auth?.tinyCloudSession;
|
|
19684
|
+
const spaceIdOverride = session === void 0 || entry.space === "default" ? void 0 : this.resolvePermissionSpace(entry.space, session);
|
|
19516
19685
|
return this.createDelegationWalletPath({
|
|
19517
19686
|
path: entry.path,
|
|
19518
19687
|
actions: entry.actions,
|
|
@@ -20018,15 +20187,21 @@ var FileSessionStorage = class {
|
|
|
20018
20187
|
|
|
20019
20188
|
// src/index.ts
|
|
20020
20189
|
import {
|
|
20190
|
+
ACCOUNT_REGISTRY_PATH,
|
|
20191
|
+
ACCOUNT_REGISTRY_SPACE as ACCOUNT_REGISTRY_SPACE2,
|
|
20192
|
+
DEFAULT_MANIFEST_SPACE as DEFAULT_MANIFEST_SPACE2,
|
|
20193
|
+
DEFAULT_MANIFEST_VERSION,
|
|
20021
20194
|
PermissionNotInManifestError as PermissionNotInManifestError2,
|
|
20022
20195
|
SessionExpiredError as SessionExpiredError2,
|
|
20023
20196
|
ManifestValidationError,
|
|
20024
|
-
|
|
20197
|
+
composeManifestRequest as composeManifestRequest2,
|
|
20198
|
+
resolveManifest,
|
|
20025
20199
|
validateManifest,
|
|
20026
20200
|
loadManifest,
|
|
20027
20201
|
isCapabilitySubset as isCapabilitySubset2,
|
|
20028
20202
|
expandActionShortNames as expandActionShortNames2,
|
|
20029
|
-
parseExpiry as parseExpiry2
|
|
20203
|
+
parseExpiry as parseExpiry2,
|
|
20204
|
+
resourceCapabilitiesToSpaceAbilitiesMap as resourceCapabilitiesToSpaceAbilitiesMap2
|
|
20030
20205
|
} from "@tinycloud/sdk-core";
|
|
20031
20206
|
|
|
20032
20207
|
// src/delegation.ts
|
|
@@ -20088,9 +20263,13 @@ import {
|
|
|
20088
20263
|
} from "@tinycloud/sdk-core";
|
|
20089
20264
|
import { ServiceContext as ServiceContext3 } from "@tinycloud/sdk-core";
|
|
20090
20265
|
export {
|
|
20266
|
+
ACCOUNT_REGISTRY_PATH,
|
|
20267
|
+
ACCOUNT_REGISTRY_SPACE2 as ACCOUNT_REGISTRY_SPACE,
|
|
20091
20268
|
AutoApproveSpaceCreationHandler2 as AutoApproveSpaceCreationHandler,
|
|
20092
20269
|
CapabilityKeyRegistry2 as CapabilityKeyRegistry,
|
|
20093
20270
|
CapabilityKeyRegistryErrorCodes,
|
|
20271
|
+
DEFAULT_MANIFEST_SPACE2 as DEFAULT_MANIFEST_SPACE,
|
|
20272
|
+
DEFAULT_MANIFEST_VERSION,
|
|
20094
20273
|
DataVaultService2 as DataVaultService,
|
|
20095
20274
|
DatabaseHandle,
|
|
20096
20275
|
DelegatedAccess,
|
|
@@ -20128,6 +20307,7 @@ export {
|
|
|
20128
20307
|
WasmKeyProvider,
|
|
20129
20308
|
buildSpaceUri,
|
|
20130
20309
|
checkNodeInfo2 as checkNodeInfo,
|
|
20310
|
+
composeManifestRequest2 as composeManifestRequest,
|
|
20131
20311
|
createCapabilityKeyRegistry,
|
|
20132
20312
|
createSharingService,
|
|
20133
20313
|
createSpaceService,
|
|
@@ -20142,7 +20322,8 @@ export {
|
|
|
20142
20322
|
makePublicSpaceId2 as makePublicSpaceId,
|
|
20143
20323
|
parseExpiry2 as parseExpiry,
|
|
20144
20324
|
parseSpaceUri,
|
|
20145
|
-
|
|
20325
|
+
resolveManifest,
|
|
20326
|
+
resourceCapabilitiesToSpaceAbilitiesMap2 as resourceCapabilitiesToSpaceAbilitiesMap,
|
|
20146
20327
|
serializeDelegation,
|
|
20147
20328
|
validateManifest
|
|
20148
20329
|
};
|