@tinycloud/node-sdk 2.2.0-beta.7 → 2.2.0-beta.8

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.
@@ -1,4 +1,4 @@
1
- import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, PermissionEntry, ResolvedDelegate, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
1
+ import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, ISecretsService, ICapabilityKeyRegistry, PermissionEntry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
2
2
  import { EventEmitter } from 'events';
3
3
  import { InvokeFunction } from '@tinycloud/sdk-services';
4
4
 
@@ -739,6 +739,13 @@ interface DelegateToResult {
739
739
  delegation: PortableDelegation;
740
740
  prompted: boolean;
741
741
  }
742
+ /**
743
+ * Options for runtime permission escalation.
744
+ */
745
+ interface RuntimePermissionGrantOptions {
746
+ /** Override expiry. ms-format string ("7d", "1h") or raw milliseconds. */
747
+ expiry?: string | number;
748
+ }
742
749
  /**
743
750
  * High-level TinyCloud API for Node.js environments.
744
751
  *
@@ -785,9 +792,12 @@ declare class TinyCloudNode {
785
792
  private _sharingService;
786
793
  private _delegationManager?;
787
794
  private _spaceService?;
795
+ private runtimePermissionGrants;
788
796
  private get nodeFeatures();
789
797
  /** SIWE domain — uses config override or defaults to app.tinycloud.xyz */
790
798
  private get siweDomain();
799
+ private readonly invokeWithRuntimePermissions;
800
+ private readonly invokeAnyWithRuntimePermissions;
791
801
  /**
792
802
  * Create a new TinyCloudNode instance.
793
803
  *
@@ -1061,6 +1071,28 @@ declare class TinyCloudNode {
1061
1071
  /** Get a delegation by CID */
1062
1072
  get: (cid: string) => Delegation | undefined;
1063
1073
  };
1074
+ /**
1075
+ * Check whether the current session or an approved runtime delegation covers
1076
+ * every requested permission.
1077
+ */
1078
+ hasRuntimePermissions(permissions: PermissionEntry[]): boolean;
1079
+ /**
1080
+ * Return installed runtime permission delegations. When `permissions` is
1081
+ * provided, only delegations currently covering those permissions are
1082
+ * returned. Base-session manifest permissions are not represented here.
1083
+ */
1084
+ getRuntimePermissionDelegations(permissions?: PermissionEntry[]): PortableDelegation[];
1085
+ /**
1086
+ * Install a portable runtime permission delegation into this SDK instance so
1087
+ * matching service calls and downstream `delegateTo()` calls can use it.
1088
+ */
1089
+ useRuntimeDelegation(delegation: PortableDelegation): Promise<void>;
1090
+ /**
1091
+ * Store additional permissions as narrow delegations to the current session
1092
+ * key. Future service invocations automatically use a stored delegation when
1093
+ * its `(space, service, path, action)` covers the request.
1094
+ */
1095
+ grantRuntimePermissions(permissions: PermissionEntry[], options?: RuntimePermissionGrantOptions): Promise<PortableDelegation[]>;
1064
1096
  /**
1065
1097
  * Get the DelegationManager for delegation CRUD operations.
1066
1098
  *
@@ -1226,8 +1258,9 @@ declare class TinyCloudNode {
1226
1258
  * Issue a delegation using the capability-chain flow.
1227
1259
  *
1228
1260
  * When every requested permission is a subset of the current
1229
- * session's recap, the delegation is signed by the session key via
1230
- * WASM no wallet prompt. When at least one is NOT derivable, a
1261
+ * session's recap, or of one installed runtime permission delegation,
1262
+ * the delegation is signed by the session key via WASM no wallet
1263
+ * prompt. When at least one is NOT derivable, a
1231
1264
  * {@link PermissionNotInManifestError} is raised (carrying the
1232
1265
  * missing entries) so the caller can trigger an escalation flow
1233
1266
  * (e.g. `TinyCloudWeb.requestPermissions`). Passing
@@ -1291,7 +1324,28 @@ declare class TinyCloudNode {
1291
1324
  * @internal
1292
1325
  */
1293
1326
  private createDelegationViaWasmPath;
1327
+ private createDelegationViaRuntimeGrant;
1294
1328
  private resolvePermissionSpace;
1329
+ private expandPermissionEntries;
1330
+ private shortServiceName;
1331
+ private permissionsToAbilities;
1332
+ private permissionOperations;
1333
+ private sessionCoversPermissionEntries;
1334
+ private permissionEntriesToOperations;
1335
+ private findRuntimeGrantsForPermissionEntries;
1336
+ private runtimeDelegationFromSession;
1337
+ private runtimeGrantFromDelegation;
1338
+ private delegatedResourcesForEntries;
1339
+ private operationsFromDelegation;
1340
+ private flatDelegationResources;
1341
+ private selectInvocationSession;
1342
+ private findGrantForOperations;
1343
+ private findGrantForOperation;
1344
+ private pruneExpiredRuntimePermissionGrants;
1345
+ private operationCovers;
1346
+ private actionContains;
1347
+ private invocationServiceName;
1348
+ private pathContains;
1295
1349
  /**
1296
1350
  * Issue a delegation via the legacy wallet-signed SIWE path for a single
1297
1351
  * {@link PermissionEntry}. Shares the implementation with the public
@@ -1481,4 +1535,4 @@ declare class WasmKeyProvider implements KeyProvider {
1481
1535
  */
1482
1536
  declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
1483
1537
 
1484
- export { type DelegateToOptions as D, FileSessionStorage as F, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type PortableDelegation as P, type RestorableSession as R, type SignStrategy as S, TinyCloudNode as T, WasmKeyProvider as W, type DelegateToResult as a, DelegatedAccess as b, NodeUserAuthorization as c, type NodeUserAuthorizationConfig as d, type TinyCloudNodeConfig as e, type WasmKeyProviderConfig as f, createWasmKeyProvider as g, defaultSignStrategy as h, deserializeDelegation as i, serializeDelegation as s };
1538
+ export { type DelegateToOptions as D, FileSessionStorage as F, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type PortableDelegation as P, type RestorableSession as R, type SignStrategy as S, TinyCloudNode as T, WasmKeyProvider as W, type DelegateToResult as a, DelegatedAccess as b, NodeUserAuthorization as c, type NodeUserAuthorizationConfig as d, type RuntimePermissionGrantOptions as e, type TinyCloudNodeConfig as f, type WasmKeyProviderConfig as g, createWasmKeyProvider as h, defaultSignStrategy as i, deserializeDelegation as j, serializeDelegation as s };
@@ -1,4 +1,4 @@
1
- import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, PermissionEntry, ResolvedDelegate, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
1
+ import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, ISecretsService, ICapabilityKeyRegistry, PermissionEntry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
2
2
  import { EventEmitter } from 'events';
3
3
  import { InvokeFunction } from '@tinycloud/sdk-services';
4
4
 
@@ -739,6 +739,13 @@ interface DelegateToResult {
739
739
  delegation: PortableDelegation;
740
740
  prompted: boolean;
741
741
  }
742
+ /**
743
+ * Options for runtime permission escalation.
744
+ */
745
+ interface RuntimePermissionGrantOptions {
746
+ /** Override expiry. ms-format string ("7d", "1h") or raw milliseconds. */
747
+ expiry?: string | number;
748
+ }
742
749
  /**
743
750
  * High-level TinyCloud API for Node.js environments.
744
751
  *
@@ -785,9 +792,12 @@ declare class TinyCloudNode {
785
792
  private _sharingService;
786
793
  private _delegationManager?;
787
794
  private _spaceService?;
795
+ private runtimePermissionGrants;
788
796
  private get nodeFeatures();
789
797
  /** SIWE domain — uses config override or defaults to app.tinycloud.xyz */
790
798
  private get siweDomain();
799
+ private readonly invokeWithRuntimePermissions;
800
+ private readonly invokeAnyWithRuntimePermissions;
791
801
  /**
792
802
  * Create a new TinyCloudNode instance.
793
803
  *
@@ -1061,6 +1071,28 @@ declare class TinyCloudNode {
1061
1071
  /** Get a delegation by CID */
1062
1072
  get: (cid: string) => Delegation | undefined;
1063
1073
  };
1074
+ /**
1075
+ * Check whether the current session or an approved runtime delegation covers
1076
+ * every requested permission.
1077
+ */
1078
+ hasRuntimePermissions(permissions: PermissionEntry[]): boolean;
1079
+ /**
1080
+ * Return installed runtime permission delegations. When `permissions` is
1081
+ * provided, only delegations currently covering those permissions are
1082
+ * returned. Base-session manifest permissions are not represented here.
1083
+ */
1084
+ getRuntimePermissionDelegations(permissions?: PermissionEntry[]): PortableDelegation[];
1085
+ /**
1086
+ * Install a portable runtime permission delegation into this SDK instance so
1087
+ * matching service calls and downstream `delegateTo()` calls can use it.
1088
+ */
1089
+ useRuntimeDelegation(delegation: PortableDelegation): Promise<void>;
1090
+ /**
1091
+ * Store additional permissions as narrow delegations to the current session
1092
+ * key. Future service invocations automatically use a stored delegation when
1093
+ * its `(space, service, path, action)` covers the request.
1094
+ */
1095
+ grantRuntimePermissions(permissions: PermissionEntry[], options?: RuntimePermissionGrantOptions): Promise<PortableDelegation[]>;
1064
1096
  /**
1065
1097
  * Get the DelegationManager for delegation CRUD operations.
1066
1098
  *
@@ -1226,8 +1258,9 @@ declare class TinyCloudNode {
1226
1258
  * Issue a delegation using the capability-chain flow.
1227
1259
  *
1228
1260
  * When every requested permission is a subset of the current
1229
- * session's recap, the delegation is signed by the session key via
1230
- * WASM no wallet prompt. When at least one is NOT derivable, a
1261
+ * session's recap, or of one installed runtime permission delegation,
1262
+ * the delegation is signed by the session key via WASM no wallet
1263
+ * prompt. When at least one is NOT derivable, a
1231
1264
  * {@link PermissionNotInManifestError} is raised (carrying the
1232
1265
  * missing entries) so the caller can trigger an escalation flow
1233
1266
  * (e.g. `TinyCloudWeb.requestPermissions`). Passing
@@ -1291,7 +1324,28 @@ declare class TinyCloudNode {
1291
1324
  * @internal
1292
1325
  */
1293
1326
  private createDelegationViaWasmPath;
1327
+ private createDelegationViaRuntimeGrant;
1294
1328
  private resolvePermissionSpace;
1329
+ private expandPermissionEntries;
1330
+ private shortServiceName;
1331
+ private permissionsToAbilities;
1332
+ private permissionOperations;
1333
+ private sessionCoversPermissionEntries;
1334
+ private permissionEntriesToOperations;
1335
+ private findRuntimeGrantsForPermissionEntries;
1336
+ private runtimeDelegationFromSession;
1337
+ private runtimeGrantFromDelegation;
1338
+ private delegatedResourcesForEntries;
1339
+ private operationsFromDelegation;
1340
+ private flatDelegationResources;
1341
+ private selectInvocationSession;
1342
+ private findGrantForOperations;
1343
+ private findGrantForOperation;
1344
+ private pruneExpiredRuntimePermissionGrants;
1345
+ private operationCovers;
1346
+ private actionContains;
1347
+ private invocationServiceName;
1348
+ private pathContains;
1295
1349
  /**
1296
1350
  * Issue a delegation via the legacy wallet-signed SIWE path for a single
1297
1351
  * {@link PermissionEntry}. Shares the implementation with the public
@@ -1481,4 +1535,4 @@ declare class WasmKeyProvider implements KeyProvider {
1481
1535
  */
1482
1536
  declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
1483
1537
 
1484
- export { type DelegateToOptions as D, FileSessionStorage as F, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type PortableDelegation as P, type RestorableSession as R, type SignStrategy as S, TinyCloudNode as T, WasmKeyProvider as W, type DelegateToResult as a, DelegatedAccess as b, NodeUserAuthorization as c, type NodeUserAuthorizationConfig as d, type TinyCloudNodeConfig as e, type WasmKeyProviderConfig as f, createWasmKeyProvider as g, defaultSignStrategy as h, deserializeDelegation as i, serializeDelegation as s };
1538
+ export { type DelegateToOptions as D, FileSessionStorage as F, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type PortableDelegation as P, type RestorableSession as R, type SignStrategy as S, TinyCloudNode as T, WasmKeyProvider as W, type DelegateToResult as a, DelegatedAccess as b, NodeUserAuthorization as c, type NodeUserAuthorizationConfig as d, type RuntimePermissionGrantOptions as e, type TinyCloudNodeConfig as f, type WasmKeyProviderConfig as g, createWasmKeyProvider as h, defaultSignStrategy as i, deserializeDelegation as j, serializeDelegation as s };