@gvnrdao/dh-sdk 0.0.330 → 0.0.331
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.
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
/*! Axios v1.
|
|
8
|
+
/*! Axios v1.20.0 Copyright (c) 2026 Matt Zabriskie and contributors */
|
|
9
9
|
|
|
10
10
|
/*! MIT License. Copyright 2015-2022 Richard Moore <me@ricmoo.com>. See LICENSE.txt. */
|
|
11
11
|
|
package/dist/index.js
CHANGED
|
@@ -6893,6 +6893,7 @@ var ServerSession = class {
|
|
|
6893
6893
|
store;
|
|
6894
6894
|
onSignaturePrompt;
|
|
6895
6895
|
onSignatureResolved;
|
|
6896
|
+
onSessionRestored;
|
|
6896
6897
|
now;
|
|
6897
6898
|
fetchImpl;
|
|
6898
6899
|
cached = null;
|
|
@@ -6933,6 +6934,7 @@ var ServerSession = class {
|
|
|
6933
6934
|
this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
|
|
6934
6935
|
this.onSignaturePrompt = opts.onSignaturePrompt;
|
|
6935
6936
|
this.onSignatureResolved = opts.onSignatureResolved;
|
|
6937
|
+
this.onSessionRestored = opts.onSessionRestored;
|
|
6936
6938
|
this.now = opts.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
6937
6939
|
this.fetchImpl = opts.fetchImpl ?? ((...a) => fetch(...a));
|
|
6938
6940
|
}
|
|
@@ -7013,7 +7015,7 @@ var ServerSession = class {
|
|
|
7013
7015
|
*/
|
|
7014
7016
|
async logout() {
|
|
7015
7017
|
const cached = this.cached;
|
|
7016
|
-
const token = cached && cached.expiresAt > this.now() ? cached.token : await this.
|
|
7018
|
+
const token = cached && cached.expiresAt > this.now() ? cached.token : await this.tryResolveSilently(this.generation, false).then((session) => session?.token ?? null).catch(() => null);
|
|
7017
7019
|
await this.clearPersisted();
|
|
7018
7020
|
if (!token)
|
|
7019
7021
|
return;
|
|
@@ -7085,8 +7087,9 @@ var ServerSession = class {
|
|
|
7085
7087
|
*
|
|
7086
7088
|
* `gen` is the caller's clear-generation snapshot: writes to `this.cached`
|
|
7087
7089
|
* and the store are skipped if a `clearPersisted()` landed meanwhile.
|
|
7090
|
+
* `announce` gates `onSessionRestored` for the two persisted-store outcomes.
|
|
7088
7091
|
*/
|
|
7089
|
-
async tryResolveSilently(gen) {
|
|
7092
|
+
async tryResolveSilently(gen, announce = true) {
|
|
7090
7093
|
const nowSec = this.now();
|
|
7091
7094
|
if (this.cached && this.cached.expiresAt - REFRESH_LEEWAY_SECONDS > nowSec) {
|
|
7092
7095
|
return this.cached;
|
|
@@ -7101,6 +7104,8 @@ var ServerSession = class {
|
|
|
7101
7104
|
};
|
|
7102
7105
|
if (gen === this.generation)
|
|
7103
7106
|
this.cached = adopted;
|
|
7107
|
+
if (announce)
|
|
7108
|
+
this.onSessionRestored?.();
|
|
7104
7109
|
return adopted;
|
|
7105
7110
|
}
|
|
7106
7111
|
try {
|
|
@@ -7109,6 +7114,8 @@ var ServerSession = class {
|
|
|
7109
7114
|
this.persist(persisted.payload, session);
|
|
7110
7115
|
this.cached = session;
|
|
7111
7116
|
}
|
|
7117
|
+
if (announce)
|
|
7118
|
+
this.onSessionRestored?.();
|
|
7112
7119
|
return session;
|
|
7113
7120
|
} catch (error) {
|
|
7114
7121
|
if (!isLoginRejection(error))
|
|
@@ -19407,7 +19414,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
19407
19414
|
persistSession: config.sessionPersistence?.enabled,
|
|
19408
19415
|
sessionStore: config.sessionPersistence?.store,
|
|
19409
19416
|
onSignaturePrompt: config.onSessionSignaturePrompt,
|
|
19410
|
-
onSignatureResolved: config.onSessionSignatureResolved
|
|
19417
|
+
onSignatureResolved: config.onSessionSignatureResolved,
|
|
19418
|
+
onSessionRestored: config.onSessionRestored
|
|
19411
19419
|
});
|
|
19412
19420
|
}
|
|
19413
19421
|
const contractManagerResult = createContractManager({
|
package/dist/index.mjs
CHANGED
|
@@ -6804,6 +6804,7 @@ var ServerSession = class {
|
|
|
6804
6804
|
store;
|
|
6805
6805
|
onSignaturePrompt;
|
|
6806
6806
|
onSignatureResolved;
|
|
6807
|
+
onSessionRestored;
|
|
6807
6808
|
now;
|
|
6808
6809
|
fetchImpl;
|
|
6809
6810
|
cached = null;
|
|
@@ -6844,6 +6845,7 @@ var ServerSession = class {
|
|
|
6844
6845
|
this.store = opts.persistSession === false ? null : opts.sessionStore ?? createDefaultSessionStore();
|
|
6845
6846
|
this.onSignaturePrompt = opts.onSignaturePrompt;
|
|
6846
6847
|
this.onSignatureResolved = opts.onSignatureResolved;
|
|
6848
|
+
this.onSessionRestored = opts.onSessionRestored;
|
|
6847
6849
|
this.now = opts.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
6848
6850
|
this.fetchImpl = opts.fetchImpl ?? ((...a) => fetch(...a));
|
|
6849
6851
|
}
|
|
@@ -6924,7 +6926,7 @@ var ServerSession = class {
|
|
|
6924
6926
|
*/
|
|
6925
6927
|
async logout() {
|
|
6926
6928
|
const cached = this.cached;
|
|
6927
|
-
const token = cached && cached.expiresAt > this.now() ? cached.token : await this.
|
|
6929
|
+
const token = cached && cached.expiresAt > this.now() ? cached.token : await this.tryResolveSilently(this.generation, false).then((session) => session?.token ?? null).catch(() => null);
|
|
6928
6930
|
await this.clearPersisted();
|
|
6929
6931
|
if (!token)
|
|
6930
6932
|
return;
|
|
@@ -6996,8 +6998,9 @@ var ServerSession = class {
|
|
|
6996
6998
|
*
|
|
6997
6999
|
* `gen` is the caller's clear-generation snapshot: writes to `this.cached`
|
|
6998
7000
|
* and the store are skipped if a `clearPersisted()` landed meanwhile.
|
|
7001
|
+
* `announce` gates `onSessionRestored` for the two persisted-store outcomes.
|
|
6999
7002
|
*/
|
|
7000
|
-
async tryResolveSilently(gen) {
|
|
7003
|
+
async tryResolveSilently(gen, announce = true) {
|
|
7001
7004
|
const nowSec = this.now();
|
|
7002
7005
|
if (this.cached && this.cached.expiresAt - REFRESH_LEEWAY_SECONDS > nowSec) {
|
|
7003
7006
|
return this.cached;
|
|
@@ -7012,6 +7015,8 @@ var ServerSession = class {
|
|
|
7012
7015
|
};
|
|
7013
7016
|
if (gen === this.generation)
|
|
7014
7017
|
this.cached = adopted;
|
|
7018
|
+
if (announce)
|
|
7019
|
+
this.onSessionRestored?.();
|
|
7015
7020
|
return adopted;
|
|
7016
7021
|
}
|
|
7017
7022
|
try {
|
|
@@ -7020,6 +7025,8 @@ var ServerSession = class {
|
|
|
7020
7025
|
this.persist(persisted.payload, session);
|
|
7021
7026
|
this.cached = session;
|
|
7022
7027
|
}
|
|
7028
|
+
if (announce)
|
|
7029
|
+
this.onSessionRestored?.();
|
|
7023
7030
|
return session;
|
|
7024
7031
|
} catch (error) {
|
|
7025
7032
|
if (!isLoginRejection(error))
|
|
@@ -19332,7 +19339,8 @@ var DiamondHandsSDK = class _DiamondHandsSDK {
|
|
|
19332
19339
|
persistSession: config.sessionPersistence?.enabled,
|
|
19333
19340
|
sessionStore: config.sessionPersistence?.store,
|
|
19334
19341
|
onSignaturePrompt: config.onSessionSignaturePrompt,
|
|
19335
|
-
onSignatureResolved: config.onSessionSignatureResolved
|
|
19342
|
+
onSignatureResolved: config.onSessionSignatureResolved,
|
|
19343
|
+
onSessionRestored: config.onSessionRestored
|
|
19336
19344
|
});
|
|
19337
19345
|
}
|
|
19338
19346
|
const contractManagerResult = createContractManager({
|
|
@@ -111,6 +111,16 @@ interface BaseSDKConfig {
|
|
|
111
111
|
* contract wallet can leave that request open for minutes.
|
|
112
112
|
*/
|
|
113
113
|
onSessionSignatureResolved?: (ok: boolean) => void;
|
|
114
|
+
/**
|
|
115
|
+
* Fires when the server session is resolved from its persisted envelope
|
|
116
|
+
* WITHOUT a wallet prompt — the adopted JWT on reload, or a silent re-mint
|
|
117
|
+
* inside the 24h window. The two callbacks above are strictly paired with a
|
|
118
|
+
* prompt, so this is the only readiness signal on the returning-user path;
|
|
119
|
+
* a UI that reports "service session established" only from
|
|
120
|
+
* `onSessionSignatureResolved` stays dark for exactly the users who never had
|
|
121
|
+
* to sign.
|
|
122
|
+
*/
|
|
123
|
+
onSessionRestored?: () => void;
|
|
114
124
|
/**
|
|
115
125
|
* Fires during loan creation the moment the PKP has been minted and validated,
|
|
116
126
|
* before the `createPosition` transaction is submitted.
|
|
@@ -57,6 +57,16 @@ export interface ServerSessionOptions {
|
|
|
57
57
|
* "check your wallet" can never take it down.
|
|
58
58
|
*/
|
|
59
59
|
onSignatureResolved?: (ok: boolean) => void;
|
|
60
|
+
/**
|
|
61
|
+
* Fires when a session is resolved from the persisted envelope WITHOUT a
|
|
62
|
+
* wallet prompt — the adopted JWT on reload, or a silent re-mint. This is the
|
|
63
|
+
* only signal on the returning-user path: the two prompt callbacks above are
|
|
64
|
+
* strictly paired with a prompt, so a UI gated on "a service session exists"
|
|
65
|
+
* would otherwise stay dark for exactly the users who never had to sign.
|
|
66
|
+
* Not fired for the in-memory cache hit, nor while `logout()` resolves a
|
|
67
|
+
* token to revoke.
|
|
68
|
+
*/
|
|
69
|
+
onSessionRestored?: () => void;
|
|
60
70
|
/** Override for tests. */
|
|
61
71
|
now?: () => number;
|
|
62
72
|
/** Override for tests. */
|
|
@@ -80,6 +90,7 @@ export declare class ServerSession {
|
|
|
80
90
|
private readonly store;
|
|
81
91
|
private readonly onSignaturePrompt?;
|
|
82
92
|
private readonly onSignatureResolved?;
|
|
93
|
+
private readonly onSessionRestored?;
|
|
83
94
|
private readonly now;
|
|
84
95
|
private readonly fetchImpl;
|
|
85
96
|
private cached;
|
|
@@ -169,6 +180,7 @@ export declare class ServerSession {
|
|
|
169
180
|
*
|
|
170
181
|
* `gen` is the caller's clear-generation snapshot: writes to `this.cached`
|
|
171
182
|
* and the store are skipped if a `clearPersisted()` landed meanwhile.
|
|
183
|
+
* `announce` gates `onSessionRestored` for the two persisted-store outcomes.
|
|
172
184
|
*/
|
|
173
185
|
private tryResolveSilently;
|
|
174
186
|
/**
|
package/package.json
CHANGED