@better-auth/electron 1.5.4 → 1.5.6
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/client.mjs +19 -4
- package/dist/preload.d.mts +3152 -3044
- package/package.json +5 -5
package/dist/client.mjs
CHANGED
|
@@ -557,16 +557,31 @@ function hasBetterAuthCookies(setCookieHeader, cookiePrefix) {
|
|
|
557
557
|
//#endregion
|
|
558
558
|
//#region src/client.ts
|
|
559
559
|
const { app, safeStorage, webContents } = electron;
|
|
560
|
-
const storageAdapter = (storage) => {
|
|
560
|
+
const storageAdapter = (storage, sessionKeys) => {
|
|
561
|
+
const memory = /* @__PURE__ */ new Map();
|
|
561
562
|
return {
|
|
562
563
|
...storage,
|
|
563
564
|
getDecrypted: (name) => {
|
|
565
|
+
if (sessionKeys.has(name) && memory.has(name)) return memory.get(name) ?? null;
|
|
566
|
+
if (!safeStorage.isEncryptionAvailable()) return null;
|
|
564
567
|
const item = storage.getItem(name);
|
|
565
568
|
if (!item || typeof item !== "string") return null;
|
|
566
|
-
|
|
569
|
+
try {
|
|
570
|
+
return safeStorage.decryptString(Buffer.from(base64.decode(item)));
|
|
571
|
+
} catch {
|
|
572
|
+
return null;
|
|
573
|
+
}
|
|
567
574
|
},
|
|
568
575
|
setEncrypted: (name, value) => {
|
|
569
|
-
|
|
576
|
+
if (!safeStorage.isEncryptionAvailable()) {
|
|
577
|
+
if (sessionKeys.has(name)) memory.set(name, value);
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
try {
|
|
581
|
+
storage.setItem(name, base64.encode(safeStorage.encryptString(value)));
|
|
582
|
+
} catch {
|
|
583
|
+
return;
|
|
584
|
+
}
|
|
570
585
|
}
|
|
571
586
|
};
|
|
572
587
|
};
|
|
@@ -582,7 +597,7 @@ const electronClient = (options) => {
|
|
|
582
597
|
let store = null;
|
|
583
598
|
const cookieName = `${opts.storagePrefix}.cookie`;
|
|
584
599
|
const localCacheName = `${opts.storagePrefix}.local_cache`;
|
|
585
|
-
const { getDecrypted, setEncrypted } = storageAdapter(opts.storage);
|
|
600
|
+
const { getDecrypted, setEncrypted } = storageAdapter(opts.storage, new Set([cookieName, localCacheName]));
|
|
586
601
|
if ((isDevelopment() || isTest()) && /^(?!\.)(?!.*\.\.)(?!.*\.$)[^.]+\.[^.]+$/.test(scheme)) console.warn("The provided scheme does not follow the reverse domain name notation. For example: `app.example.com` -> `com.example.app`.");
|
|
587
602
|
return {
|
|
588
603
|
id: "electron",
|