@darkauth/client
Advanced tools
+16
-6
@@ -32,5 +32,15 @@ import { compactDecrypt } from "jose"; | ||
| const EMPTY_DRK = new Uint8Array(0); | ||
| const ID_TOKEN_KEY = "id_token"; | ||
| export function setConfig(next) { | ||
| cfg = { ...cfg, ...next }; | ||
| } | ||
| function setStoredIdToken(token) { | ||
| localStorage.setItem(ID_TOKEN_KEY, token); | ||
| } | ||
| function getStoredIdToken() { | ||
| return localStorage.getItem(ID_TOKEN_KEY); | ||
| } | ||
| function clearStoredIdToken() { | ||
| localStorage.removeItem(ID_TOKEN_KEY); | ||
| } | ||
| function bytesToBase64Url(bytes) { | ||
@@ -162,3 +172,3 @@ let s = ""; | ||
| catch { } | ||
| sessionStorage.setItem("id_token", idToken); | ||
| setStoredIdToken(idToken); | ||
| localStorage.removeItem("drk_protected"); | ||
@@ -187,3 +197,3 @@ if (refreshToken) | ||
| catch { } | ||
| sessionStorage.setItem("id_token", idToken); | ||
| setStoredIdToken(idToken); | ||
| const obfuscatedDrk = obfuscateKey(drk); | ||
@@ -196,3 +206,3 @@ localStorage.setItem("drk_protected", bytesToBase64Url(obfuscatedDrk)); | ||
| export function getStoredSession() { | ||
| const idToken = sessionStorage.getItem("id_token"); | ||
| const idToken = getStoredIdToken(); | ||
| const obfuscatedDrkBase64 = localStorage.getItem("drk_protected"); | ||
@@ -238,3 +248,3 @@ if (!idToken) | ||
| const newRefreshToken = tokenResponse.refresh_token; | ||
| sessionStorage.setItem("id_token", idToken); | ||
| setStoredIdToken(idToken); | ||
| if (newRefreshToken) | ||
@@ -250,3 +260,3 @@ localStorage.setItem("refresh_token", newRefreshToken); | ||
| export function logout() { | ||
| sessionStorage.removeItem("id_token"); | ||
| clearStoredIdToken(); | ||
| localStorage.removeItem("drk_protected"); | ||
@@ -258,3 +268,3 @@ sessionStorage.removeItem("zk_eph_priv_jwk"); | ||
| export function getCurrentUser() { | ||
| const idToken = sessionStorage.getItem("id_token"); | ||
| const idToken = getStoredIdToken(); | ||
| if (!idToken) | ||
@@ -261,0 +271,0 @@ return null; |
+1
-1
| { | ||
| "name": "@darkauth/client", | ||
| "version": "0.2.1", | ||
| "version": "1.4.3", | ||
| "license": "MIT", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
28068
0.61%480
2.13%1
-50%