@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/index.cjs CHANGED
@@ -17368,6 +17368,7 @@ function addRawAbility(rawAbilities, resource, action) {
17368
17368
  }
17369
17369
  var NodeUserAuthorization = class {
17370
17370
  constructor(config) {
17371
+ this.activeSessionKeyId = "default";
17371
17372
  this.extensions = [];
17372
17373
  this._nodeFeatures = [];
17373
17374
  this._lastActivationSkippedSpaceIds = [];
@@ -17416,7 +17417,7 @@ var NodeUserAuthorization = class {
17416
17417
  this.includeAccountRegistryPermissions = config.includeAccountRegistryPermissions ?? true;
17417
17418
  this._manifest = config.manifest;
17418
17419
  this._capabilityRequest = config.capabilityRequest;
17419
- this.sessionManager = this.wasm.createSessionManager();
17420
+ this.sessionManager = config.sessionManager ?? this.wasm.createSessionManager();
17420
17421
  }
17421
17422
  /**
17422
17423
  * Return the manifest currently driving sign-in behavior, or
@@ -17923,7 +17924,8 @@ var NodeUserAuthorization = class {
17923
17924
  const chainId = this._chainId;
17924
17925
  await this.resolveTinyCloudHostsForSignIn(address, chainId);
17925
17926
  const keyId = `session-${Date.now()}`;
17926
- this.sessionManager.renameSessionKeyId("default", keyId);
17927
+ this.sessionManager.renameSessionKeyId(this.activeSessionKeyId, keyId);
17928
+ this.activeSessionKeyId = keyId;
17927
17929
  const jwkString = this.sessionManager.jwk(keyId);
17928
17930
  if (!jwkString) {
17929
17931
  throw new Error("Failed to create session key");
@@ -18072,7 +18074,8 @@ var NodeUserAuthorization = class {
18072
18074
  const address = (0, import_sdk_core2.canonicalizeAddress)(await this.signer.getAddress());
18073
18075
  const chainId = await this.signer.getChainId();
18074
18076
  const keyId = `session-${Date.now()}`;
18075
- this.sessionManager.renameSessionKeyId("default", keyId);
18077
+ this.sessionManager.renameSessionKeyId(this.activeSessionKeyId, keyId);
18078
+ this.activeSessionKeyId = keyId;
18076
18079
  const jwkString = this.sessionManager.jwk(keyId);
18077
18080
  if (!jwkString) {
18078
18081
  throw new Error("Failed to create session key");
@@ -18976,6 +18979,7 @@ var _TinyCloudNode = class _TinyCloudNode {
18976
18979
  signer: this.signer,
18977
18980
  signStrategy: config.signStrategy ?? { type: "auto-sign" },
18978
18981
  wasmBindings: this.wasmBindings,
18982
+ sessionManager: this.sessionManager,
18979
18983
  sessionStorage: config.sessionStorage ?? new MemorySessionStorage(),
18980
18984
  domain: this.siweDomain,
18981
18985
  spacePrefix: config.prefix,
@@ -19164,6 +19168,11 @@ var _TinyCloudNode = class _TinyCloudNode {
19164
19168
  this.runtimePermissionGrants = [];
19165
19169
  await this.tc.signIn(options);
19166
19170
  this.syncResolvedHostFromAuth();
19171
+ const signedInSession = this.currentTinyCloudSession();
19172
+ if (signedInSession) {
19173
+ this.sessionKeyId = signedInSession.sessionKey;
19174
+ this.sessionKeyJwk = signedInSession.jwk;
19175
+ }
19167
19176
  this.initializeServices();
19168
19177
  const primarySession = this.currentTinyCloudSession();
19169
19178
  if (primarySession) {
@@ -19965,6 +19974,7 @@ var _TinyCloudNode = class _TinyCloudNode {
19965
19974
  signer: this.signer,
19966
19975
  signStrategy: this.config.signStrategy ?? { type: "auto-sign" },
19967
19976
  wasmBindings: this.wasmBindings,
19977
+ sessionManager: this.sessionManager,
19968
19978
  sessionStorage: options?.sessionStorage ?? this.config.sessionStorage ?? new MemorySessionStorage(),
19969
19979
  domain: this.siweDomain,
19970
19980
  spacePrefix: prefix,
@@ -20012,6 +20022,7 @@ var _TinyCloudNode = class _TinyCloudNode {
20012
20022
  signer: this.signer,
20013
20023
  signStrategy: this.config.signStrategy ?? { type: "auto-sign" },
20014
20024
  wasmBindings: this.wasmBindings,
20025
+ sessionManager: this.sessionManager,
20015
20026
  sessionStorage: options?.sessionStorage ?? this.config.sessionStorage ?? new MemorySessionStorage(),
20016
20027
  domain: this.siweDomain,
20017
20028
  spacePrefix: prefix,
@@ -20487,7 +20498,10 @@ var _TinyCloudNode = class _TinyCloudNode {
20487
20498
  delegationCid: params.session.delegationCid,
20488
20499
  jwk: params.session.jwk,
20489
20500
  spaceId: params.session.spaceId,
20490
- verificationMethod: params.session.verificationMethod
20501
+ // Session storage carries the verification method as a DID URL
20502
+ // (`did:key:...#key-id`). The Rust UCAN builder expects the principal
20503
+ // DID here and rejects the fragment as an invalid audience DID.
20504
+ verificationMethod: params.session.verificationMethod.split("#", 1)[0]
20491
20505
  };
20492
20506
  const result = this.wasmBindings.createDelegation(
20493
20507
  wasmSession,