@tinycloud/node-sdk 3.2.6-beta.2 → 3.2.6-beta.3

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
@@ -21653,12 +21653,18 @@ var _TinyCloudNode = class _TinyCloudNode {
21653
21653
  }
21654
21654
  async endSession() {
21655
21655
  const leavingAddress = this.address ?? this._restoredTcSession?.address;
21656
- this.teardownSession();
21656
+ const leavingAuth = this.auth;
21657
21657
  try {
21658
- await this.accountRegistryTail;
21659
- if (this.replicationRuntime) await (await this.replicationRuntime).unbind();
21658
+ this.teardownSession();
21660
21659
  } finally {
21661
- if (leavingAddress) await this.clearPersistedSessionFor(leavingAddress);
21660
+ try {
21661
+ await this.accountRegistryTail;
21662
+ if (this.replicationRuntime) await (await this.replicationRuntime).unbind();
21663
+ } finally {
21664
+ if (leavingAddress) {
21665
+ await (leavingAuth ? leavingAuth.clearPersistedSession(leavingAddress) : this.config.sessionStorage?.clear(leavingAddress));
21666
+ }
21667
+ }
21662
21668
  }
21663
21669
  }
21664
21670
  /**
@@ -21670,19 +21676,21 @@ var _TinyCloudNode = class _TinyCloudNode {
21670
21676
  this.pendingAccountRegistrySync?.controller.abort();
21671
21677
  const oldGraph = this._serviceGraph;
21672
21678
  const oldCore = this.tc;
21673
- const sessionKey = createDefaultSessionKey(this.wasmBindings);
21674
- this.sessionManager = sessionKey.manager;
21675
- this.sessionKeyId = sessionKey.keyId;
21676
- this.sessionKeyJwk = sessionKey.jwk;
21677
- this.auth?.resetSession(
21678
- sessionKey.manager,
21679
- sessionKey.keyId,
21679
+ const oldAuth = this.auth;
21680
+ this.auth = null;
21681
+ this.tc = null;
21682
+ this._address = void 0;
21683
+ this._restoredTcSession = void 0;
21684
+ this._activeServiceSession = void 0;
21685
+ oldGraph.retire();
21686
+ oldCore?.retireServices();
21687
+ oldAuth?.resetSession(
21688
+ this.sessionManager,
21689
+ this.sessionKeyId,
21680
21690
  this.explicitHost ? [this.explicitHost] : void 0
21681
21691
  );
21682
21692
  this.config.host = this.explicitHost ?? DEFAULT_HOST;
21683
- this._address = void 0;
21684
21693
  this._chainId = 1;
21685
- this._restoredTcSession = void 0;
21686
21694
  this._restoredNodeFeatures = void 0;
21687
21695
  this._activeServiceSession = void 0;
21688
21696
  this._serviceContext = void 0;
@@ -21709,20 +21717,25 @@ var _TinyCloudNode = class _TinyCloudNode {
21709
21717
  this._bootstrapStatus = { skipped: false };
21710
21718
  this.replicationDelegateSession = void 0;
21711
21719
  this.replicationScopeError = void 0;
21720
+ const sessionKey = createDefaultSessionKey(this.wasmBindings);
21721
+ this.sessionManager = sessionKey.manager;
21722
+ this.sessionKeyId = sessionKey.keyId;
21723
+ this.sessionKeyJwk = sessionKey.jwk;
21724
+ oldAuth?.resetSession(
21725
+ sessionKey.manager,
21726
+ sessionKey.keyId,
21727
+ this.explicitHost ? [this.explicitHost] : void 0
21728
+ );
21712
21729
  this._serviceGraph = this.createServiceGraphLifetime();
21713
- oldGraph.retire();
21730
+ this.auth = oldAuth;
21714
21731
  this.tc = this.auth ? new import_sdk_core9.TinyCloud(this.auth, {
21715
21732
  invokeAny: this.invokeAnyWithRuntimePermissions,
21716
21733
  telemetry: this.config.telemetry
21717
21734
  }) : null;
21718
- oldCore?.retireServices();
21719
21735
  this._capabilityRegistry = new import_sdk_core9.CapabilityKeyRegistry();
21720
21736
  this._keyProvider = new WasmKeyProvider({ sessionManager: this.sessionManager });
21721
21737
  this._sharingService = this.createReceiveOnlySharing();
21722
21738
  }
21723
- async clearPersistedSessionFor(address) {
21724
- await (this.auth ? this.auth.clearPersistedSession(address) : this.config.sessionStorage?.clear(address));
21725
- }
21726
21739
  /** Throws when a sign-out started after `epoch` was read. */
21727
21740
  assertSessionEpoch(epoch, operation) {
21728
21741
  if (epoch !== this.sessionEpoch) {