@arbidocs/client 0.5.59 → 0.5.61
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/README.md +10 -0
- package/dist/index.cjs +33 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -31
- package/dist/index.d.ts +86 -31
- package/dist/index.js +32 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -281,6 +281,16 @@ import {
|
|
|
281
281
|
} from '@arbidocs/client'
|
|
282
282
|
```
|
|
283
283
|
|
|
284
|
+
### Logger
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
import { configureLogger, logger } from '@arbidocs/client'
|
|
288
|
+
|
|
289
|
+
configureLogger({ verbose: import.meta.env.DEV }) // once, at startup
|
|
290
|
+
logger.error('always printed')
|
|
291
|
+
logger.warn('printed only when verbose') // likewise info, debug
|
|
292
|
+
```
|
|
293
|
+
|
|
284
294
|
## How It Works
|
|
285
295
|
|
|
286
296
|
### Zero-Knowledge Auth
|
package/dist/index.cjs
CHANGED
|
@@ -166,12 +166,15 @@ function createSessionManager(options = {}) {
|
|
|
166
166
|
}
|
|
167
167
|
var ACCESS_TOKEN_STORAGE_KEY = "arbi_access_token";
|
|
168
168
|
var SESSION_STORAGE_KEY = "arbi_session";
|
|
169
|
-
function browserSessionStateStorage() {
|
|
169
|
+
function browserSessionStateStorage(namespace) {
|
|
170
|
+
const suffix = namespace ? `:${namespace}` : "";
|
|
171
|
+
const sessionKey = SESSION_STORAGE_KEY + suffix;
|
|
172
|
+
const accessTokenKey = ACCESS_TOKEN_STORAGE_KEY + suffix;
|
|
170
173
|
return {
|
|
171
174
|
load() {
|
|
172
175
|
try {
|
|
173
|
-
const rest = JSON.parse(window.localStorage.getItem(
|
|
174
|
-
const accessToken = window.sessionStorage.getItem(
|
|
176
|
+
const rest = JSON.parse(window.localStorage.getItem(sessionKey) ?? "null");
|
|
177
|
+
const accessToken = window.sessionStorage.getItem(accessTokenKey);
|
|
175
178
|
return { ...rest ?? {}, accessToken };
|
|
176
179
|
} catch {
|
|
177
180
|
return null;
|
|
@@ -179,11 +182,11 @@ function browserSessionStateStorage() {
|
|
|
179
182
|
},
|
|
180
183
|
save({ accessToken, ...rest }) {
|
|
181
184
|
try {
|
|
182
|
-
if (accessToken) window.sessionStorage.setItem(
|
|
183
|
-
else window.sessionStorage.removeItem(
|
|
185
|
+
if (accessToken) window.sessionStorage.setItem(accessTokenKey, accessToken);
|
|
186
|
+
else window.sessionStorage.removeItem(accessTokenKey);
|
|
184
187
|
if (rest.signedIn || rest.isSsoMode)
|
|
185
|
-
window.localStorage.setItem(
|
|
186
|
-
else window.localStorage.removeItem(
|
|
188
|
+
window.localStorage.setItem(sessionKey, JSON.stringify(rest));
|
|
189
|
+
else window.localStorage.removeItem(sessionKey);
|
|
187
190
|
} catch {
|
|
188
191
|
}
|
|
189
192
|
}
|
|
@@ -2406,6 +2409,27 @@ function isMessageType(msg, type) {
|
|
|
2406
2409
|
return msg.type === type;
|
|
2407
2410
|
}
|
|
2408
2411
|
|
|
2412
|
+
// src/logger.ts
|
|
2413
|
+
var verbose = false;
|
|
2414
|
+
function configureLogger(options) {
|
|
2415
|
+
verbose = options.verbose;
|
|
2416
|
+
}
|
|
2417
|
+
var logger = {
|
|
2418
|
+
/** Always printed, production included. */
|
|
2419
|
+
error: (...args) => {
|
|
2420
|
+
console.error(...args);
|
|
2421
|
+
},
|
|
2422
|
+
warn: (...args) => {
|
|
2423
|
+
if (verbose) console.warn(...args);
|
|
2424
|
+
},
|
|
2425
|
+
info: (...args) => {
|
|
2426
|
+
if (verbose) console.info(...args);
|
|
2427
|
+
},
|
|
2428
|
+
debug: (...args) => {
|
|
2429
|
+
if (verbose) console.debug(...args);
|
|
2430
|
+
}
|
|
2431
|
+
};
|
|
2432
|
+
|
|
2409
2433
|
exports.ACCESS_TOKEN_STORAGE_KEY = ACCESS_TOKEN_STORAGE_KEY;
|
|
2410
2434
|
exports.API_PREFIX = API_PREFIX;
|
|
2411
2435
|
exports.CALL_KEY_BYTES = CALL_KEY_BYTES;
|
|
@@ -2430,6 +2454,7 @@ exports.changePassword = changePassword;
|
|
|
2430
2454
|
exports.clearAllData = clearAllData;
|
|
2431
2455
|
exports.clearSession = clearSession;
|
|
2432
2456
|
exports.computeSharedSecret = computeSharedSecret;
|
|
2457
|
+
exports.configureLogger = configureLogger;
|
|
2433
2458
|
exports.createAllWorkspacesOpener = createAllWorkspacesOpener;
|
|
2434
2459
|
exports.createArbiClient = createArbiClient;
|
|
2435
2460
|
exports.createAuthMessage = createAuthMessage;
|
|
@@ -2486,6 +2511,7 @@ exports.initializeDatabase = initializeDatabase;
|
|
|
2486
2511
|
exports.isAbortError = isAbortError;
|
|
2487
2512
|
exports.isEncryptedRecoveryKey = isEncryptedRecoveryKey;
|
|
2488
2513
|
exports.isMessageType = isMessageType;
|
|
2514
|
+
exports.logger = logger;
|
|
2489
2515
|
exports.openCallKeyOf = openCallKeyOf;
|
|
2490
2516
|
exports.openSealedCallKey = openSealedCallKey;
|
|
2491
2517
|
exports.openSealedChatKey = openSealedChatKey;
|