@tinycloud/node-sdk 2.2.0-beta.6 → 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.
- package/dist/{core-DdMPUB5s.d.cts → core-DcJ27GsA.d.cts} +71 -4
- package/dist/{core-DdMPUB5s.d.ts → core-DcJ27GsA.d.ts} +71 -4
- package/dist/core.cjs +794 -168
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +700 -71
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +797 -171
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +701 -71
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -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, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISharingService, CreateDelegationParams, DelegationResult,
|
|
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
|
*
|
|
@@ -770,6 +777,8 @@ declare class TinyCloudNode {
|
|
|
770
777
|
private _duckdb?;
|
|
771
778
|
private _hooks?;
|
|
772
779
|
private _vault?;
|
|
780
|
+
private _baseSecrets?;
|
|
781
|
+
private _secrets?;
|
|
773
782
|
/** Cached public KV with proper delegation (set by ensurePublicSpace) */
|
|
774
783
|
private _publicKV?;
|
|
775
784
|
/** Session key ID - always available */
|
|
@@ -783,9 +792,12 @@ declare class TinyCloudNode {
|
|
|
783
792
|
private _sharingService;
|
|
784
793
|
private _delegationManager?;
|
|
785
794
|
private _spaceService?;
|
|
795
|
+
private runtimePermissionGrants;
|
|
786
796
|
private get nodeFeatures();
|
|
787
797
|
/** SIWE domain — uses config override or defaults to app.tinycloud.xyz */
|
|
788
798
|
private get siweDomain();
|
|
799
|
+
private readonly invokeWithRuntimePermissions;
|
|
800
|
+
private readonly invokeAnyWithRuntimePermissions;
|
|
789
801
|
/**
|
|
790
802
|
* Create a new TinyCloudNode instance.
|
|
791
803
|
*
|
|
@@ -949,6 +961,8 @@ declare class TinyCloudNode {
|
|
|
949
961
|
* @internal
|
|
950
962
|
*/
|
|
951
963
|
private initializeServices;
|
|
964
|
+
private createSpaceScopedKVService;
|
|
965
|
+
private createVaultService;
|
|
952
966
|
/**
|
|
953
967
|
* Initialize the v2 delegation system services.
|
|
954
968
|
* @internal
|
|
@@ -1006,6 +1020,11 @@ declare class TinyCloudNode {
|
|
|
1006
1020
|
* Call `vault.unlock(signer)` after signIn() to derive encryption keys.
|
|
1007
1021
|
*/
|
|
1008
1022
|
get vault(): IDataVaultService;
|
|
1023
|
+
/**
|
|
1024
|
+
* App-facing secrets API backed by the `secrets` space vault.
|
|
1025
|
+
*/
|
|
1026
|
+
get secrets(): ISecretsService;
|
|
1027
|
+
private getBaseSecrets;
|
|
1009
1028
|
/**
|
|
1010
1029
|
* Hooks write stream subscription API.
|
|
1011
1030
|
*/
|
|
@@ -1052,6 +1071,28 @@ declare class TinyCloudNode {
|
|
|
1052
1071
|
/** Get a delegation by CID */
|
|
1053
1072
|
get: (cid: string) => Delegation | undefined;
|
|
1054
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[]>;
|
|
1055
1096
|
/**
|
|
1056
1097
|
* Get the DelegationManager for delegation CRUD operations.
|
|
1057
1098
|
*
|
|
@@ -1108,6 +1149,10 @@ declare class TinyCloudNode {
|
|
|
1108
1149
|
* @see spaces
|
|
1109
1150
|
*/
|
|
1110
1151
|
get spaceService(): ISpaceService;
|
|
1152
|
+
/**
|
|
1153
|
+
* Get a Space object by short name or full URI.
|
|
1154
|
+
*/
|
|
1155
|
+
space(nameOrUri: string): ISpace;
|
|
1111
1156
|
/**
|
|
1112
1157
|
* Get the SharingService for creating and receiving v2 sharing links.
|
|
1113
1158
|
*
|
|
@@ -1213,8 +1258,9 @@ declare class TinyCloudNode {
|
|
|
1213
1258
|
* Issue a delegation using the capability-chain flow.
|
|
1214
1259
|
*
|
|
1215
1260
|
* When every requested permission is a subset of the current
|
|
1216
|
-
* session's recap,
|
|
1217
|
-
*
|
|
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
|
|
1218
1264
|
* {@link PermissionNotInManifestError} is raised (carrying the
|
|
1219
1265
|
* missing entries) so the caller can trigger an escalation flow
|
|
1220
1266
|
* (e.g. `TinyCloudWeb.requestPermissions`). Passing
|
|
@@ -1278,7 +1324,28 @@ declare class TinyCloudNode {
|
|
|
1278
1324
|
* @internal
|
|
1279
1325
|
*/
|
|
1280
1326
|
private createDelegationViaWasmPath;
|
|
1327
|
+
private createDelegationViaRuntimeGrant;
|
|
1281
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;
|
|
1282
1349
|
/**
|
|
1283
1350
|
* Issue a delegation via the legacy wallet-signed SIWE path for a single
|
|
1284
1351
|
* {@link PermissionEntry}. Shares the implementation with the public
|
|
@@ -1468,4 +1535,4 @@ declare class WasmKeyProvider implements KeyProvider {
|
|
|
1468
1535
|
*/
|
|
1469
1536
|
declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
|
|
1470
1537
|
|
|
1471
|
-
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
|
|
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, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISharingService, CreateDelegationParams, DelegationResult,
|
|
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
|
*
|
|
@@ -770,6 +777,8 @@ declare class TinyCloudNode {
|
|
|
770
777
|
private _duckdb?;
|
|
771
778
|
private _hooks?;
|
|
772
779
|
private _vault?;
|
|
780
|
+
private _baseSecrets?;
|
|
781
|
+
private _secrets?;
|
|
773
782
|
/** Cached public KV with proper delegation (set by ensurePublicSpace) */
|
|
774
783
|
private _publicKV?;
|
|
775
784
|
/** Session key ID - always available */
|
|
@@ -783,9 +792,12 @@ declare class TinyCloudNode {
|
|
|
783
792
|
private _sharingService;
|
|
784
793
|
private _delegationManager?;
|
|
785
794
|
private _spaceService?;
|
|
795
|
+
private runtimePermissionGrants;
|
|
786
796
|
private get nodeFeatures();
|
|
787
797
|
/** SIWE domain — uses config override or defaults to app.tinycloud.xyz */
|
|
788
798
|
private get siweDomain();
|
|
799
|
+
private readonly invokeWithRuntimePermissions;
|
|
800
|
+
private readonly invokeAnyWithRuntimePermissions;
|
|
789
801
|
/**
|
|
790
802
|
* Create a new TinyCloudNode instance.
|
|
791
803
|
*
|
|
@@ -949,6 +961,8 @@ declare class TinyCloudNode {
|
|
|
949
961
|
* @internal
|
|
950
962
|
*/
|
|
951
963
|
private initializeServices;
|
|
964
|
+
private createSpaceScopedKVService;
|
|
965
|
+
private createVaultService;
|
|
952
966
|
/**
|
|
953
967
|
* Initialize the v2 delegation system services.
|
|
954
968
|
* @internal
|
|
@@ -1006,6 +1020,11 @@ declare class TinyCloudNode {
|
|
|
1006
1020
|
* Call `vault.unlock(signer)` after signIn() to derive encryption keys.
|
|
1007
1021
|
*/
|
|
1008
1022
|
get vault(): IDataVaultService;
|
|
1023
|
+
/**
|
|
1024
|
+
* App-facing secrets API backed by the `secrets` space vault.
|
|
1025
|
+
*/
|
|
1026
|
+
get secrets(): ISecretsService;
|
|
1027
|
+
private getBaseSecrets;
|
|
1009
1028
|
/**
|
|
1010
1029
|
* Hooks write stream subscription API.
|
|
1011
1030
|
*/
|
|
@@ -1052,6 +1071,28 @@ declare class TinyCloudNode {
|
|
|
1052
1071
|
/** Get a delegation by CID */
|
|
1053
1072
|
get: (cid: string) => Delegation | undefined;
|
|
1054
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[]>;
|
|
1055
1096
|
/**
|
|
1056
1097
|
* Get the DelegationManager for delegation CRUD operations.
|
|
1057
1098
|
*
|
|
@@ -1108,6 +1149,10 @@ declare class TinyCloudNode {
|
|
|
1108
1149
|
* @see spaces
|
|
1109
1150
|
*/
|
|
1110
1151
|
get spaceService(): ISpaceService;
|
|
1152
|
+
/**
|
|
1153
|
+
* Get a Space object by short name or full URI.
|
|
1154
|
+
*/
|
|
1155
|
+
space(nameOrUri: string): ISpace;
|
|
1111
1156
|
/**
|
|
1112
1157
|
* Get the SharingService for creating and receiving v2 sharing links.
|
|
1113
1158
|
*
|
|
@@ -1213,8 +1258,9 @@ declare class TinyCloudNode {
|
|
|
1213
1258
|
* Issue a delegation using the capability-chain flow.
|
|
1214
1259
|
*
|
|
1215
1260
|
* When every requested permission is a subset of the current
|
|
1216
|
-
* session's recap,
|
|
1217
|
-
*
|
|
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
|
|
1218
1264
|
* {@link PermissionNotInManifestError} is raised (carrying the
|
|
1219
1265
|
* missing entries) so the caller can trigger an escalation flow
|
|
1220
1266
|
* (e.g. `TinyCloudWeb.requestPermissions`). Passing
|
|
@@ -1278,7 +1324,28 @@ declare class TinyCloudNode {
|
|
|
1278
1324
|
* @internal
|
|
1279
1325
|
*/
|
|
1280
1326
|
private createDelegationViaWasmPath;
|
|
1327
|
+
private createDelegationViaRuntimeGrant;
|
|
1281
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;
|
|
1282
1349
|
/**
|
|
1283
1350
|
* Issue a delegation via the legacy wallet-signed SIWE path for a single
|
|
1284
1351
|
* {@link PermissionEntry}. Shares the implementation with the public
|
|
@@ -1468,4 +1535,4 @@ declare class WasmKeyProvider implements KeyProvider {
|
|
|
1468
1535
|
*/
|
|
1469
1536
|
declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
|
|
1470
1537
|
|
|
1471
|
-
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
|
|
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 };
|