@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 +40 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -639,6 +639,26 @@ declare class TinyCloudNode {
|
|
|
639
639
|
* Requires wallet mode (privateKey in config).
|
|
640
640
|
*/
|
|
641
641
|
signIn(): Promise<void>;
|
|
642
|
+
/**
|
|
643
|
+
* Restore a previously established session from stored delegation data.
|
|
644
|
+
*
|
|
645
|
+
* This is used by the CLI to restore a session that was created via the
|
|
646
|
+
* browser-based delegation flow (OpenKey `/delegate` page). Instead of
|
|
647
|
+
* signing in with a private key, it injects the delegation data directly.
|
|
648
|
+
*
|
|
649
|
+
* @param sessionData - The stored delegation data from the browser flow
|
|
650
|
+
*/
|
|
651
|
+
restoreSession(sessionData: {
|
|
652
|
+
delegationHeader: {
|
|
653
|
+
Authorization: string;
|
|
654
|
+
};
|
|
655
|
+
delegationCid: string;
|
|
656
|
+
spaceId: string;
|
|
657
|
+
jwk: object;
|
|
658
|
+
verificationMethod: string;
|
|
659
|
+
address?: string;
|
|
660
|
+
chainId?: number;
|
|
661
|
+
}): Promise<void>;
|
|
642
662
|
/**
|
|
643
663
|
* Connect a wallet to upgrade from session-only mode to wallet mode.
|
|
644
664
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -639,6 +639,26 @@ declare class TinyCloudNode {
|
|
|
639
639
|
* Requires wallet mode (privateKey in config).
|
|
640
640
|
*/
|
|
641
641
|
signIn(): Promise<void>;
|
|
642
|
+
/**
|
|
643
|
+
* Restore a previously established session from stored delegation data.
|
|
644
|
+
*
|
|
645
|
+
* This is used by the CLI to restore a session that was created via the
|
|
646
|
+
* browser-based delegation flow (OpenKey `/delegate` page). Instead of
|
|
647
|
+
* signing in with a private key, it injects the delegation data directly.
|
|
648
|
+
*
|
|
649
|
+
* @param sessionData - The stored delegation data from the browser flow
|
|
650
|
+
*/
|
|
651
|
+
restoreSession(sessionData: {
|
|
652
|
+
delegationHeader: {
|
|
653
|
+
Authorization: string;
|
|
654
|
+
};
|
|
655
|
+
delegationCid: string;
|
|
656
|
+
spaceId: string;
|
|
657
|
+
jwk: object;
|
|
658
|
+
verificationMethod: string;
|
|
659
|
+
address?: string;
|
|
660
|
+
chainId?: number;
|
|
661
|
+
}): Promise<void>;
|
|
642
662
|
/**
|
|
643
663
|
* Connect a wallet to upgrade from session-only mode to wallet mode.
|
|
644
664
|
*
|
package/dist/index.js
CHANGED
|
@@ -18133,6 +18133,46 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
18133
18133
|
await this.tc.signIn();
|
|
18134
18134
|
this.initializeServices();
|
|
18135
18135
|
}
|
|
18136
|
+
/**
|
|
18137
|
+
* Restore a previously established session from stored delegation data.
|
|
18138
|
+
*
|
|
18139
|
+
* This is used by the CLI to restore a session that was created via the
|
|
18140
|
+
* browser-based delegation flow (OpenKey `/delegate` page). Instead of
|
|
18141
|
+
* signing in with a private key, it injects the delegation data directly.
|
|
18142
|
+
*
|
|
18143
|
+
* @param sessionData - The stored delegation data from the browser flow
|
|
18144
|
+
*/
|
|
18145
|
+
async restoreSession(sessionData) {
|
|
18146
|
+
this._kv = void 0;
|
|
18147
|
+
this._sql = void 0;
|
|
18148
|
+
this._serviceContext = void 0;
|
|
18149
|
+
if (sessionData.address) {
|
|
18150
|
+
this._address = sessionData.address;
|
|
18151
|
+
}
|
|
18152
|
+
if (sessionData.chainId) {
|
|
18153
|
+
this._chainId = sessionData.chainId;
|
|
18154
|
+
}
|
|
18155
|
+
this._serviceContext = new ServiceContext2({
|
|
18156
|
+
invoke: invoke2,
|
|
18157
|
+
fetch: globalThis.fetch.bind(globalThis),
|
|
18158
|
+
hosts: [this.config.host]
|
|
18159
|
+
});
|
|
18160
|
+
this._kv = new KVService2({});
|
|
18161
|
+
this._kv.initialize(this._serviceContext);
|
|
18162
|
+
this._serviceContext.registerService("kv", this._kv);
|
|
18163
|
+
this._sql = new SQLService2({});
|
|
18164
|
+
this._sql.initialize(this._serviceContext);
|
|
18165
|
+
this._serviceContext.registerService("sql", this._sql);
|
|
18166
|
+
const serviceSession = {
|
|
18167
|
+
delegationHeader: sessionData.delegationHeader,
|
|
18168
|
+
delegationCid: sessionData.delegationCid,
|
|
18169
|
+
spaceId: sessionData.spaceId,
|
|
18170
|
+
verificationMethod: sessionData.verificationMethod,
|
|
18171
|
+
jwk: sessionData.jwk
|
|
18172
|
+
};
|
|
18173
|
+
this._serviceContext.setSession(serviceSession);
|
|
18174
|
+
this.initializeV2Services(serviceSession);
|
|
18175
|
+
}
|
|
18136
18176
|
/**
|
|
18137
18177
|
* Connect a wallet to upgrade from session-only mode to wallet mode.
|
|
18138
18178
|
*
|