@arbidocs/client 0.5.58 → 0.5.59
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 +38 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -6
- package/dist/index.d.ts +11 -6
- package/dist/index.js +38 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -10,6 +10,36 @@ var sodium__default = /*#__PURE__*/_interopDefault(sodium);
|
|
|
10
10
|
|
|
11
11
|
// src/client.ts
|
|
12
12
|
|
|
13
|
+
// src/memory-persistence.ts
|
|
14
|
+
function copy(keys) {
|
|
15
|
+
return {
|
|
16
|
+
...keys,
|
|
17
|
+
signingPrivateKey: keys.signingPrivateKey.slice(),
|
|
18
|
+
...keys.serverSessionKey ? { serverSessionKey: keys.serverSessionKey.slice() } : {}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function createMemorySessionPersistence() {
|
|
22
|
+
let saved = null;
|
|
23
|
+
const clear = () => {
|
|
24
|
+
saved?.signingPrivateKey.fill(0);
|
|
25
|
+
saved?.serverSessionKey?.fill(0);
|
|
26
|
+
saved = null;
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
async getSession() {
|
|
30
|
+
return saved ? copy(saved) : null;
|
|
31
|
+
},
|
|
32
|
+
async saveSession(keys) {
|
|
33
|
+
const next = copy(keys);
|
|
34
|
+
clear();
|
|
35
|
+
saved = next;
|
|
36
|
+
},
|
|
37
|
+
async clearSession() {
|
|
38
|
+
clear();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
13
43
|
// src/http-transport.ts
|
|
14
44
|
function createHttpTransport(options = {}) {
|
|
15
45
|
const { timeoutMs } = options;
|
|
@@ -2013,8 +2043,8 @@ function createArbiClient(options) {
|
|
|
2013
2043
|
decryptMessageWithSharedSecret
|
|
2014
2044
|
},
|
|
2015
2045
|
storage: {
|
|
2016
|
-
getSession,
|
|
2017
|
-
saveSession
|
|
2046
|
+
getSession: () => persistence.getSession(),
|
|
2047
|
+
saveSession: (data) => persistence.saveSession(data)
|
|
2018
2048
|
}
|
|
2019
2049
|
};
|
|
2020
2050
|
}
|
|
@@ -2028,7 +2058,7 @@ function createTransport(options) {
|
|
|
2028
2058
|
onRetryCloneFailed,
|
|
2029
2059
|
userEmail
|
|
2030
2060
|
} = options;
|
|
2031
|
-
const persistence = options.persistence ?? { getSession, saveSession };
|
|
2061
|
+
const persistence = options.persistence ?? (typeof indexedDB === "undefined" ? createMemorySessionPersistence() : { getSession, saveSession, clearSession: clearAllData });
|
|
2032
2062
|
const baseUrlOption = options.baseUrl;
|
|
2033
2063
|
const base = typeof baseUrlOption === "function" ? baseUrlOption : () => baseUrlOption;
|
|
2034
2064
|
const transport = createHttpTransport(options.transport);
|
|
@@ -2290,7 +2320,10 @@ function createTransport(options) {
|
|
|
2290
2320
|
}).catch((error) => console.warn("[API] Server logout failed:", error));
|
|
2291
2321
|
}
|
|
2292
2322
|
session.clear();
|
|
2293
|
-
if (everywhere)
|
|
2323
|
+
if (everywhere) {
|
|
2324
|
+
if (persistence.clearSession) await persistence.clearSession();
|
|
2325
|
+
else if (typeof indexedDB !== "undefined") await clearAllData();
|
|
2326
|
+
}
|
|
2294
2327
|
} finally {
|
|
2295
2328
|
gate.reopen();
|
|
2296
2329
|
}
|
|
@@ -2404,6 +2437,7 @@ exports.createAutoReloginMiddleware = createAutoReloginMiddleware;
|
|
|
2404
2437
|
exports.createBearerAuthMiddleware = createBearerAuthMiddleware;
|
|
2405
2438
|
exports.createContentHash = createContentHash;
|
|
2406
2439
|
exports.createHttpTransport = createHttpTransport;
|
|
2440
|
+
exports.createMemorySessionPersistence = createMemorySessionPersistence;
|
|
2407
2441
|
exports.createOfflineSealer = createOfflineSealer;
|
|
2408
2442
|
exports.createRecoveryFile = createRecoveryFile;
|
|
2409
2443
|
exports.createRecoveryUrl = createRecoveryUrl;
|