@tinycloud/node-sdk 2.6.3 → 2.6.4-beta.1
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-C6iGIPrJ.d.cts → core-BVk0VwGe.d.cts} +4 -1
- package/dist/{core-C6iGIPrJ.d.ts → core-BVk0VwGe.d.ts} +4 -1
- package/dist/core.cjs +18 -4
- 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 +18 -4
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +18 -4
- 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 +18 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, AccountService, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider,
|
|
1
|
+
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, AccountService, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { InvokeFunction, InvokeAnyFunction } from '@tinycloud/sdk-services';
|
|
4
4
|
|
|
@@ -199,6 +199,8 @@ interface NodeUserAuthorizationConfig {
|
|
|
199
199
|
enablePublicSpace?: boolean;
|
|
200
200
|
/** WASM bindings for cryptographic operations. Required. */
|
|
201
201
|
wasmBindings: IWasmBindings;
|
|
202
|
+
/** Existing session manager to share with a higher-level SDK client. */
|
|
203
|
+
sessionManager?: ISessionManager;
|
|
202
204
|
/**
|
|
203
205
|
* SIWE nonce override. If omitted, the WASM layer generates a random nonce.
|
|
204
206
|
* If `siweConfig.nonce` is also provided, `siweConfig.nonce` wins.
|
|
@@ -295,6 +297,7 @@ declare class NodeUserAuthorization implements IUserAuthorization {
|
|
|
295
297
|
private _capabilityRequest?;
|
|
296
298
|
private readonly includeAccountRegistryPermissions;
|
|
297
299
|
private sessionManager;
|
|
300
|
+
private activeSessionKeyId;
|
|
298
301
|
private extensions;
|
|
299
302
|
private _session?;
|
|
300
303
|
private _tinyCloudSession?;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, AccountService, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider,
|
|
1
|
+
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, ISessionManager, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignRequest, SignInOptions, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, AccountService, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider, JWK } from '@tinycloud/sdk-core';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { InvokeFunction, InvokeAnyFunction } from '@tinycloud/sdk-services';
|
|
4
4
|
|
|
@@ -199,6 +199,8 @@ interface NodeUserAuthorizationConfig {
|
|
|
199
199
|
enablePublicSpace?: boolean;
|
|
200
200
|
/** WASM bindings for cryptographic operations. Required. */
|
|
201
201
|
wasmBindings: IWasmBindings;
|
|
202
|
+
/** Existing session manager to share with a higher-level SDK client. */
|
|
203
|
+
sessionManager?: ISessionManager;
|
|
202
204
|
/**
|
|
203
205
|
* SIWE nonce override. If omitted, the WASM layer generates a random nonce.
|
|
204
206
|
* If `siweConfig.nonce` is also provided, `siweConfig.nonce` wins.
|
|
@@ -295,6 +297,7 @@ declare class NodeUserAuthorization implements IUserAuthorization {
|
|
|
295
297
|
private _capabilityRequest?;
|
|
296
298
|
private readonly includeAccountRegistryPermissions;
|
|
297
299
|
private sessionManager;
|
|
300
|
+
private activeSessionKeyId;
|
|
298
301
|
private extensions;
|
|
299
302
|
private _session?;
|
|
300
303
|
private _tinyCloudSession?;
|
package/dist/core.cjs
CHANGED
|
@@ -348,6 +348,7 @@ function addRawAbility(rawAbilities, resource, action) {
|
|
|
348
348
|
}
|
|
349
349
|
var NodeUserAuthorization = class {
|
|
350
350
|
constructor(config) {
|
|
351
|
+
this.activeSessionKeyId = "default";
|
|
351
352
|
this.extensions = [];
|
|
352
353
|
this._nodeFeatures = [];
|
|
353
354
|
this._lastActivationSkippedSpaceIds = [];
|
|
@@ -396,7 +397,7 @@ var NodeUserAuthorization = class {
|
|
|
396
397
|
this.includeAccountRegistryPermissions = config.includeAccountRegistryPermissions ?? true;
|
|
397
398
|
this._manifest = config.manifest;
|
|
398
399
|
this._capabilityRequest = config.capabilityRequest;
|
|
399
|
-
this.sessionManager = this.wasm.createSessionManager();
|
|
400
|
+
this.sessionManager = config.sessionManager ?? this.wasm.createSessionManager();
|
|
400
401
|
}
|
|
401
402
|
/**
|
|
402
403
|
* Return the manifest currently driving sign-in behavior, or
|
|
@@ -903,7 +904,8 @@ var NodeUserAuthorization = class {
|
|
|
903
904
|
const chainId = this._chainId;
|
|
904
905
|
await this.resolveTinyCloudHostsForSignIn(address, chainId);
|
|
905
906
|
const keyId = `session-${Date.now()}`;
|
|
906
|
-
this.sessionManager.renameSessionKeyId(
|
|
907
|
+
this.sessionManager.renameSessionKeyId(this.activeSessionKeyId, keyId);
|
|
908
|
+
this.activeSessionKeyId = keyId;
|
|
907
909
|
const jwkString = this.sessionManager.jwk(keyId);
|
|
908
910
|
if (!jwkString) {
|
|
909
911
|
throw new Error("Failed to create session key");
|
|
@@ -1052,7 +1054,8 @@ var NodeUserAuthorization = class {
|
|
|
1052
1054
|
const address = (0, import_sdk_core3.canonicalizeAddress)(await this.signer.getAddress());
|
|
1053
1055
|
const chainId = await this.signer.getChainId();
|
|
1054
1056
|
const keyId = `session-${Date.now()}`;
|
|
1055
|
-
this.sessionManager.renameSessionKeyId(
|
|
1057
|
+
this.sessionManager.renameSessionKeyId(this.activeSessionKeyId, keyId);
|
|
1058
|
+
this.activeSessionKeyId = keyId;
|
|
1056
1059
|
const jwkString = this.sessionManager.jwk(keyId);
|
|
1057
1060
|
if (!jwkString) {
|
|
1058
1061
|
throw new Error("Failed to create session key");
|
|
@@ -1959,6 +1962,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1959
1962
|
signer: this.signer,
|
|
1960
1963
|
signStrategy: config.signStrategy ?? { type: "auto-sign" },
|
|
1961
1964
|
wasmBindings: this.wasmBindings,
|
|
1965
|
+
sessionManager: this.sessionManager,
|
|
1962
1966
|
sessionStorage: config.sessionStorage ?? new MemorySessionStorage(),
|
|
1963
1967
|
domain: this.siweDomain,
|
|
1964
1968
|
spacePrefix: config.prefix,
|
|
@@ -2147,6 +2151,11 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2147
2151
|
this.runtimePermissionGrants = [];
|
|
2148
2152
|
await this.tc.signIn(options);
|
|
2149
2153
|
this.syncResolvedHostFromAuth();
|
|
2154
|
+
const signedInSession = this.currentTinyCloudSession();
|
|
2155
|
+
if (signedInSession) {
|
|
2156
|
+
this.sessionKeyId = signedInSession.sessionKey;
|
|
2157
|
+
this.sessionKeyJwk = signedInSession.jwk;
|
|
2158
|
+
}
|
|
2150
2159
|
this.initializeServices();
|
|
2151
2160
|
const primarySession = this.currentTinyCloudSession();
|
|
2152
2161
|
if (primarySession) {
|
|
@@ -2948,6 +2957,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2948
2957
|
signer: this.signer,
|
|
2949
2958
|
signStrategy: this.config.signStrategy ?? { type: "auto-sign" },
|
|
2950
2959
|
wasmBindings: this.wasmBindings,
|
|
2960
|
+
sessionManager: this.sessionManager,
|
|
2951
2961
|
sessionStorage: options?.sessionStorage ?? this.config.sessionStorage ?? new MemorySessionStorage(),
|
|
2952
2962
|
domain: this.siweDomain,
|
|
2953
2963
|
spacePrefix: prefix,
|
|
@@ -2995,6 +3005,7 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2995
3005
|
signer: this.signer,
|
|
2996
3006
|
signStrategy: this.config.signStrategy ?? { type: "auto-sign" },
|
|
2997
3007
|
wasmBindings: this.wasmBindings,
|
|
3008
|
+
sessionManager: this.sessionManager,
|
|
2998
3009
|
sessionStorage: options?.sessionStorage ?? this.config.sessionStorage ?? new MemorySessionStorage(),
|
|
2999
3010
|
domain: this.siweDomain,
|
|
3000
3011
|
spacePrefix: prefix,
|
|
@@ -3470,7 +3481,10 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3470
3481
|
delegationCid: params.session.delegationCid,
|
|
3471
3482
|
jwk: params.session.jwk,
|
|
3472
3483
|
spaceId: params.session.spaceId,
|
|
3473
|
-
|
|
3484
|
+
// Session storage carries the verification method as a DID URL
|
|
3485
|
+
// (`did:key:...#key-id`). The Rust UCAN builder expects the principal
|
|
3486
|
+
// DID here and rejects the fragment as an invalid audience DID.
|
|
3487
|
+
verificationMethod: params.session.verificationMethod.split("#", 1)[0]
|
|
3474
3488
|
};
|
|
3475
3489
|
const result = this.wasmBindings.createDelegation(
|
|
3476
3490
|
wasmSession,
|