@tinycloud/node-sdk 2.2.0-beta.11 → 2.2.0-beta.12

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
@@ -17032,6 +17032,7 @@ __export(index_exports, {
17032
17032
  CapabilityKeyRegistryErrorCodes: () => import_sdk_core16.CapabilityKeyRegistryErrorCodes,
17033
17033
  DEFAULT_MANIFEST_SPACE: () => import_sdk_core9.DEFAULT_MANIFEST_SPACE,
17034
17034
  DEFAULT_MANIFEST_VERSION: () => import_sdk_core9.DEFAULT_MANIFEST_VERSION,
17035
+ DEFAULT_SIGNED_READ_URL_EXPIRY_MS: () => import_sdk_core10.DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
17035
17036
  DataVaultService: () => import_sdk_core13.DataVaultService,
17036
17037
  DatabaseHandle: () => import_sdk_core11.DatabaseHandle,
17037
17038
  DelegatedAccess: () => DelegatedAccess,
@@ -17384,6 +17385,23 @@ var NodeUserAuthorization = class {
17384
17385
  get tinyCloudSession() {
17385
17386
  return this._tinyCloudSession;
17386
17387
  }
17388
+ /**
17389
+ * Rehydrate the auth-layer session from previously-persisted delegation
17390
+ * data. Used by {@link TinyCloudNode.restoreSession} so that downstream
17391
+ * surfaces that read from `tinyCloudSession` (notably
17392
+ * `grantRuntimePermissions`, which extracts the SIWE expiry from it) work
17393
+ * without re-running the full sign-in flow.
17394
+ *
17395
+ * Caller must supply the same fields that `signIn` would have written —
17396
+ * `siwe` is the load-bearing one because `extractSiweExpiration` returns
17397
+ * undefined for missing SIWEs and the SDK then treats the session as
17398
+ * expired-at-epoch-zero.
17399
+ */
17400
+ setRestoredTinyCloudSession(session) {
17401
+ this._tinyCloudSession = session;
17402
+ this._address = session.address;
17403
+ this._chainId = session.chainId;
17404
+ }
17387
17405
  async resolveTinyCloudHostsForSignIn(address, chainId) {
17388
17406
  if (this.tinycloudHosts && this.tinycloudHosts.length > 0) {
17389
17407
  return;
@@ -18798,6 +18816,33 @@ var _TinyCloudNode = class _TinyCloudNode {
18798
18816
  this._vault.initialize(this._serviceContext);
18799
18817
  this._serviceContext.registerService("vault", this._vault);
18800
18818
  this.initializeV2Services(serviceSession);
18819
+ if (sessionData.siwe && sessionData.address && sessionData.chainId) {
18820
+ const tcSession = {
18821
+ address: sessionData.address,
18822
+ chainId: sessionData.chainId,
18823
+ sessionKey: JSON.stringify(sessionData.jwk),
18824
+ spaceId: sessionData.spaceId,
18825
+ delegationCid: sessionData.delegationCid,
18826
+ delegationHeader: sessionData.delegationHeader,
18827
+ verificationMethod: sessionData.verificationMethod,
18828
+ jwk: sessionData.jwk,
18829
+ siwe: sessionData.siwe,
18830
+ signature: sessionData.signature ?? ""
18831
+ };
18832
+ if (this.auth) {
18833
+ this.auth.setRestoredTinyCloudSession(tcSession);
18834
+ } else {
18835
+ this._restoredTcSession = tcSession;
18836
+ }
18837
+ }
18838
+ }
18839
+ /**
18840
+ * Resolve the currently-active TinyCloudSession, preferring the auth
18841
+ * layer's value (wallet mode) and falling back to the node-level
18842
+ * rehydration set by {@link restoreSession} (session-only mode).
18843
+ */
18844
+ currentTinyCloudSession() {
18845
+ return this.auth?.tinyCloudSession ?? this._restoredTcSession;
18801
18846
  }
18802
18847
  /**
18803
18848
  * Connect a wallet to upgrade from session-only mode to wallet mode.
@@ -19472,7 +19517,7 @@ var _TinyCloudNode = class _TinyCloudNode {
19472
19517
  * every requested permission.
19473
19518
  */
19474
19519
  hasRuntimePermissions(permissions) {
19475
- const session = this.auth?.tinyCloudSession;
19520
+ const session = this.currentTinyCloudSession();
19476
19521
  if (!session || !Array.isArray(permissions) || permissions.length === 0) {
19477
19522
  return false;
19478
19523
  }
@@ -19492,7 +19537,7 @@ var _TinyCloudNode = class _TinyCloudNode {
19492
19537
  if (permissions === void 0) {
19493
19538
  return this.runtimePermissionGrants.map((grant) => grant.delegation);
19494
19539
  }
19495
- const session = this.auth?.tinyCloudSession;
19540
+ const session = this.currentTinyCloudSession();
19496
19541
  if (!session || !Array.isArray(permissions) || permissions.length === 0) {
19497
19542
  return [];
19498
19543
  }
@@ -19506,7 +19551,7 @@ var _TinyCloudNode = class _TinyCloudNode {
19506
19551
  * matching service calls and downstream `delegateTo()` calls can use it.
19507
19552
  */
19508
19553
  async useRuntimeDelegation(delegation) {
19509
- const session = this.auth?.tinyCloudSession;
19554
+ const session = this.currentTinyCloudSession();
19510
19555
  if (!session) {
19511
19556
  throw new import_sdk_core5.SessionExpiredError(/* @__PURE__ */ new Date(0));
19512
19557
  }
@@ -19545,7 +19590,7 @@ var _TinyCloudNode = class _TinyCloudNode {
19545
19590
  if (!Array.isArray(permissions) || permissions.length === 0) {
19546
19591
  throw new Error("grantRuntimePermissions requires a non-empty permissions array");
19547
19592
  }
19548
- const session = this.auth?.tinyCloudSession;
19593
+ const session = this.currentTinyCloudSession();
19549
19594
  if (!session) {
19550
19595
  throw new import_sdk_core5.SessionExpiredError(/* @__PURE__ */ new Date(0));
19551
19596
  }
@@ -20963,6 +21008,7 @@ var import_sdk_core19 = require("@tinycloud/sdk-core");
20963
21008
  CapabilityKeyRegistryErrorCodes,
20964
21009
  DEFAULT_MANIFEST_SPACE,
20965
21010
  DEFAULT_MANIFEST_VERSION,
21011
+ DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
20966
21012
  DataVaultService,
20967
21013
  DatabaseHandle,
20968
21014
  DelegatedAccess,