@svadmin/auth-utils 0.7.2 → 0.7.3
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/package.json +1 -1
- package/src/session.ts +6 -2
package/package.json
CHANGED
package/src/session.ts
CHANGED
|
@@ -51,12 +51,16 @@ export interface SessionManager {
|
|
|
51
51
|
// ─── Base64url helpers ────────────────────────────────────────
|
|
52
52
|
|
|
53
53
|
function base64urlEncode(data: string): string {
|
|
54
|
-
|
|
54
|
+
const bytes = new TextEncoder().encode(data);
|
|
55
|
+
const binString = Array.from(bytes, (bite) => String.fromCodePoint(bite)).join('');
|
|
56
|
+
return btoa(binString).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
function base64urlDecode(str: string): string {
|
|
58
60
|
const padded = str + '='.repeat((4 - (str.length % 4)) % 4);
|
|
59
|
-
|
|
61
|
+
const binString = atob(padded.replace(/-/g, '+').replace(/_/g, '/'));
|
|
62
|
+
const bytes = Uint8Array.from(binString, (m) => m.codePointAt(0)!);
|
|
63
|
+
return new TextDecoder().decode(bytes);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
// ─── Factory ──────────────────────────────────────────────────
|