@arcote.tech/arc-adapter-db-sqlite-wasm 0.4.7 → 0.4.9
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.js +13 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1354,14 +1354,23 @@ var TOKEN_PREFIX = "arc:token:";
|
|
|
1354
1354
|
function hasLocalStorage() {
|
|
1355
1355
|
return typeof localStorage !== "undefined";
|
|
1356
1356
|
}
|
|
1357
|
+
function notifyTokenChange(scope) {
|
|
1358
|
+
if (typeof window !== "undefined") {
|
|
1359
|
+
queueMicrotask(() => {
|
|
1360
|
+
window.dispatchEvent(new CustomEvent("arc:token-change", { detail: { scope } }));
|
|
1361
|
+
});
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1357
1364
|
|
|
1358
1365
|
class AuthAdapter {
|
|
1359
1366
|
scopes = new Map;
|
|
1360
1367
|
setToken(token, scope = "default") {
|
|
1361
1368
|
if (!token) {
|
|
1362
1369
|
this.scopes.delete(scope);
|
|
1363
|
-
if (hasLocalStorage())
|
|
1370
|
+
if (hasLocalStorage()) {
|
|
1364
1371
|
localStorage.removeItem(TOKEN_PREFIX + scope);
|
|
1372
|
+
notifyTokenChange(scope);
|
|
1373
|
+
}
|
|
1365
1374
|
return;
|
|
1366
1375
|
}
|
|
1367
1376
|
try {
|
|
@@ -1382,8 +1391,10 @@ class AuthAdapter {
|
|
|
1382
1391
|
exp: payload.exp
|
|
1383
1392
|
}
|
|
1384
1393
|
});
|
|
1385
|
-
if (hasLocalStorage())
|
|
1394
|
+
if (hasLocalStorage()) {
|
|
1386
1395
|
localStorage.setItem(TOKEN_PREFIX + scope, token);
|
|
1396
|
+
notifyTokenChange(scope);
|
|
1397
|
+
}
|
|
1387
1398
|
} catch {
|
|
1388
1399
|
this.scopes.delete(scope);
|
|
1389
1400
|
if (hasLocalStorage())
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/arc-adapter-db-sqlite-wasm",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dev": "bun build ./src/index.ts ./src/worker.ts --outdir ./dist --target browser --format esm --watch"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@arcote.tech/arc": "^0.4.
|
|
26
|
+
"@arcote.tech/arc": "^0.4.9",
|
|
27
27
|
"@sqlite.org/sqlite-wasm": "^3.46.0-build1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|