@tinycloud/node-sdk 1.3.0 → 1.4.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
@@ -18122,6 +18122,46 @@ var _TinyCloudNode = class _TinyCloudNode {
18122
18122
  await this.tc.signIn();
18123
18123
  this.initializeServices();
18124
18124
  }
18125
+ /**
18126
+ * Restore a previously established session from stored delegation data.
18127
+ *
18128
+ * This is used by the CLI to restore a session that was created via the
18129
+ * browser-based delegation flow (OpenKey `/delegate` page). Instead of
18130
+ * signing in with a private key, it injects the delegation data directly.
18131
+ *
18132
+ * @param sessionData - The stored delegation data from the browser flow
18133
+ */
18134
+ async restoreSession(sessionData) {
18135
+ this._kv = void 0;
18136
+ this._sql = void 0;
18137
+ this._serviceContext = void 0;
18138
+ if (sessionData.address) {
18139
+ this._address = sessionData.address;
18140
+ }
18141
+ if (sessionData.chainId) {
18142
+ this._chainId = sessionData.chainId;
18143
+ }
18144
+ this._serviceContext = new import_sdk_core4.ServiceContext({
18145
+ invoke: import_node_sdk_wasm4.invoke,
18146
+ fetch: globalThis.fetch.bind(globalThis),
18147
+ hosts: [this.config.host]
18148
+ });
18149
+ this._kv = new import_sdk_core4.KVService({});
18150
+ this._kv.initialize(this._serviceContext);
18151
+ this._serviceContext.registerService("kv", this._kv);
18152
+ this._sql = new import_sdk_core4.SQLService({});
18153
+ this._sql.initialize(this._serviceContext);
18154
+ this._serviceContext.registerService("sql", this._sql);
18155
+ const serviceSession = {
18156
+ delegationHeader: sessionData.delegationHeader,
18157
+ delegationCid: sessionData.delegationCid,
18158
+ spaceId: sessionData.spaceId,
18159
+ verificationMethod: sessionData.verificationMethod,
18160
+ jwk: sessionData.jwk
18161
+ };
18162
+ this._serviceContext.setSession(serviceSession);
18163
+ this.initializeV2Services(serviceSession);
18164
+ }
18125
18165
  /**
18126
18166
  * Connect a wallet to upgrade from session-only mode to wallet mode.
18127
18167
  *