@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.
@@ -1767,7 +1767,6 @@ declare class TinyCloudNode {
1767
1767
  * invalidate sign-ins and restores still in flight (see `sessionEpoch`).
1768
1768
  */
1769
1769
  private teardownSession;
1770
- private clearPersistedSessionFor;
1771
1770
  /** Throws when a sign-out started after `epoch` was read. */
1772
1771
  private assertSessionEpoch;
1773
1772
  /**
@@ -1767,7 +1767,6 @@ declare class TinyCloudNode {
1767
1767
  * invalidate sign-ins and restores still in flight (see `sessionEpoch`).
1768
1768
  */
1769
1769
  private teardownSession;
1770
- private clearPersistedSessionFor;
1771
1770
  /** Throws when a sign-out started after `epoch` was read. */
1772
1771
  private assertSessionEpoch;
1773
1772
  /**
package/dist/core.cjs CHANGED
@@ -4145,12 +4145,18 @@ var _TinyCloudNode = class _TinyCloudNode {
4145
4145
  }
4146
4146
  async endSession() {
4147
4147
  const leavingAddress = this.address ?? this._restoredTcSession?.address;
4148
- this.teardownSession();
4148
+ const leavingAuth = this.auth;
4149
4149
  try {
4150
- await this.accountRegistryTail;
4151
- if (this.replicationRuntime) await (await this.replicationRuntime).unbind();
4150
+ this.teardownSession();
4152
4151
  } finally {
4153
- if (leavingAddress) await this.clearPersistedSessionFor(leavingAddress);
4152
+ try {
4153
+ await this.accountRegistryTail;
4154
+ if (this.replicationRuntime) await (await this.replicationRuntime).unbind();
4155
+ } finally {
4156
+ if (leavingAddress) {
4157
+ await (leavingAuth ? leavingAuth.clearPersistedSession(leavingAddress) : this.config.sessionStorage?.clear(leavingAddress));
4158
+ }
4159
+ }
4154
4160
  }
4155
4161
  }
4156
4162
  /**
@@ -4162,19 +4168,21 @@ var _TinyCloudNode = class _TinyCloudNode {
4162
4168
  this.pendingAccountRegistrySync?.controller.abort();
4163
4169
  const oldGraph = this._serviceGraph;
4164
4170
  const oldCore = this.tc;
4165
- const sessionKey = createDefaultSessionKey(this.wasmBindings);
4166
- this.sessionManager = sessionKey.manager;
4167
- this.sessionKeyId = sessionKey.keyId;
4168
- this.sessionKeyJwk = sessionKey.jwk;
4169
- this.auth?.resetSession(
4170
- sessionKey.manager,
4171
- sessionKey.keyId,
4171
+ const oldAuth = this.auth;
4172
+ this.auth = null;
4173
+ this.tc = null;
4174
+ this._address = void 0;
4175
+ this._restoredTcSession = void 0;
4176
+ this._activeServiceSession = void 0;
4177
+ oldGraph.retire();
4178
+ oldCore?.retireServices();
4179
+ oldAuth?.resetSession(
4180
+ this.sessionManager,
4181
+ this.sessionKeyId,
4172
4182
  this.explicitHost ? [this.explicitHost] : void 0
4173
4183
  );
4174
4184
  this.config.host = this.explicitHost ?? DEFAULT_HOST;
4175
- this._address = void 0;
4176
4185
  this._chainId = 1;
4177
- this._restoredTcSession = void 0;
4178
4186
  this._restoredNodeFeatures = void 0;
4179
4187
  this._activeServiceSession = void 0;
4180
4188
  this._serviceContext = void 0;
@@ -4201,20 +4209,25 @@ var _TinyCloudNode = class _TinyCloudNode {
4201
4209
  this._bootstrapStatus = { skipped: false };
4202
4210
  this.replicationDelegateSession = void 0;
4203
4211
  this.replicationScopeError = void 0;
4212
+ const sessionKey = createDefaultSessionKey(this.wasmBindings);
4213
+ this.sessionManager = sessionKey.manager;
4214
+ this.sessionKeyId = sessionKey.keyId;
4215
+ this.sessionKeyJwk = sessionKey.jwk;
4216
+ oldAuth?.resetSession(
4217
+ sessionKey.manager,
4218
+ sessionKey.keyId,
4219
+ this.explicitHost ? [this.explicitHost] : void 0
4220
+ );
4204
4221
  this._serviceGraph = this.createServiceGraphLifetime();
4205
- oldGraph.retire();
4222
+ this.auth = oldAuth;
4206
4223
  this.tc = this.auth ? new import_sdk_core10.TinyCloud(this.auth, {
4207
4224
  invokeAny: this.invokeAnyWithRuntimePermissions,
4208
4225
  telemetry: this.config.telemetry
4209
4226
  }) : null;
4210
- oldCore?.retireServices();
4211
4227
  this._capabilityRegistry = new import_sdk_core10.CapabilityKeyRegistry();
4212
4228
  this._keyProvider = new WasmKeyProvider({ sessionManager: this.sessionManager });
4213
4229
  this._sharingService = this.createReceiveOnlySharing();
4214
4230
  }
4215
- async clearPersistedSessionFor(address) {
4216
- await (this.auth ? this.auth.clearPersistedSession(address) : this.config.sessionStorage?.clear(address));
4217
- }
4218
4231
  /** Throws when a sign-out started after `epoch` was read. */
4219
4232
  assertSessionEpoch(epoch, operation) {
4220
4233
  if (epoch !== this.sessionEpoch) {