@geekmidas/auth 0.0.4 → 0.1.0
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 +343 -214
- package/dist/{cacheTokenStorage-BlpcZwef.d.mts → cacheTokenStorage-BzBRJfd-.d.mts} +2 -1
- package/dist/cacheTokenStorage-Ca05vf3T.mjs +2 -1
- package/dist/cacheTokenStorage-Ca05vf3T.mjs.map +1 -0
- package/dist/cacheTokenStorage-CvptztkW.cjs +2 -1
- package/dist/cacheTokenStorage-CvptztkW.cjs.map +1 -0
- package/dist/cacheTokenStorage-yNUpDD8W.d.cts +2 -1
- package/dist/cacheTokenStorage.d.mts +1 -1
- package/dist/{chunk-DWy1uDak.cjs → chunk-CUT6urMc.cjs} +0 -9
- package/dist/client-DaiUm0UZ.cjs +2 -1
- package/dist/client-DaiUm0UZ.cjs.map +1 -0
- package/dist/client-DjNZS6vZ.mjs +2 -1
- package/dist/client-DjNZS6vZ.mjs.map +1 -0
- package/dist/client.d.mts +1 -1
- package/dist/hono/jwt.cjs +92 -0
- package/dist/hono/jwt.cjs.map +1 -0
- package/dist/hono/jwt.d.cts +45 -0
- package/dist/hono/jwt.d.mts +45 -0
- package/dist/hono/jwt.mjs +91 -0
- package/dist/hono/jwt.mjs.map +1 -0
- package/dist/hono/oidc.cjs +104 -0
- package/dist/hono/oidc.cjs.map +1 -0
- package/dist/hono/oidc.d.cts +48 -0
- package/dist/hono/oidc.d.mts +48 -0
- package/dist/hono/oidc.mjs +103 -0
- package/dist/hono/oidc.mjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/jwt-Bo_eACEi.cjs +70 -0
- package/dist/jwt-Bo_eACEi.cjs.map +1 -0
- package/dist/jwt-D88cPJyT.mjs +52 -0
- package/dist/jwt-D88cPJyT.mjs.map +1 -0
- package/dist/jwt-DF9kFbmh.d.cts +61 -0
- package/dist/jwt-DH8CJ2xC.d.mts +61 -0
- package/dist/jwt.cjs +5 -0
- package/dist/jwt.d.cts +2 -0
- package/dist/jwt.d.mts +2 -0
- package/dist/jwt.mjs +3 -0
- package/dist/lambda/jwt.cjs +126 -0
- package/dist/lambda/jwt.cjs.map +1 -0
- package/dist/lambda/jwt.d.cts +52 -0
- package/dist/lambda/jwt.d.mts +52 -0
- package/dist/lambda/jwt.mjs +125 -0
- package/dist/lambda/jwt.mjs.map +1 -0
- package/dist/lambda/oidc.cjs +117 -0
- package/dist/lambda/oidc.cjs.map +1 -0
- package/dist/lambda/oidc.d.cts +44 -0
- package/dist/lambda/oidc.d.mts +44 -0
- package/dist/lambda/oidc.mjs +116 -0
- package/dist/lambda/oidc.mjs.map +1 -0
- package/dist/oidc-C0KyYaAK.cjs +68 -0
- package/dist/oidc-C0KyYaAK.cjs.map +1 -0
- package/dist/oidc-CKOGLxjV.d.mts +86 -0
- package/dist/oidc-DDLIB5gb.d.cts +86 -0
- package/dist/oidc-KA30gMlx.mjs +62 -0
- package/dist/oidc-KA30gMlx.mjs.map +1 -0
- package/dist/oidc.cjs +3 -0
- package/dist/oidc.d.cts +3 -0
- package/dist/oidc.d.mts +3 -0
- package/dist/oidc.mjs +3 -0
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.mts +2 -2
- package/dist/{tokenManager-CCcFk2Py.d.mts → tokenManager--Q93eNYr.d.mts} +2 -1
- package/dist/tokenManager-BVXxfHRa.mjs +2 -1
- package/dist/tokenManager-BVXxfHRa.mjs.map +1 -0
- package/dist/{tokenManager-B60gFnEF.cjs → tokenManager-EPmwgai2.cjs} +3 -2
- package/dist/tokenManager-EPmwgai2.cjs.map +1 -0
- package/dist/{tokenManager-mpzJKLvX.d.cts → tokenManager-H6-lWEah.d.cts} +2 -1
- package/dist/tokenManager.cjs +1 -1
- package/dist/tokenManager.d.cts +1 -1
- package/dist/tokenManager.d.mts +1 -1
- package/package.json +56 -4
- package/src/__tests__/hono-jwt.spec.ts +232 -0
- package/src/__tests__/hono-oidc.spec.ts +605 -0
- package/src/__tests__/jwt.spec.ts +174 -0
- package/src/__tests__/lambda-jwt.spec.ts +278 -0
- package/src/__tests__/lambda-oidc.spec.ts +623 -0
- package/src/__tests__/oidc.spec.ts +405 -0
- package/src/hono/jwt.ts +142 -0
- package/src/hono/oidc.ts +170 -0
- package/src/jwt.ts +106 -0
- package/src/lambda/jwt.ts +210 -0
- package/src/lambda/oidc.ts +203 -0
- package/src/oidc.ts +156 -0
- package/dist/__tests__/cacheTokenStorage.spec.cjs +0 -146
- package/dist/__tests__/cacheTokenStorage.spec.d.cts +0 -1
- package/dist/__tests__/cacheTokenStorage.spec.d.mts +0 -1
- package/dist/__tests__/cacheTokenStorage.spec.mjs +0 -145
- package/dist/__tests__/client.spec.cjs +0 -17281
- package/dist/__tests__/client.spec.d.cts +0 -1
- package/dist/__tests__/client.spec.d.mts +0 -1
- package/dist/__tests__/client.spec.mjs +0 -17308
- package/dist/__tests__/tokenManager.spec.cjs +0 -197
- package/dist/__tests__/tokenManager.spec.d.cts +0 -1
- package/dist/__tests__/tokenManager.spec.d.mts +0 -1
- package/dist/__tests__/tokenManager.spec.mjs +0 -196
- package/dist/playground.cjs +0 -0
- package/dist/playground.d.cts +0 -1
- package/dist/playground.d.mts +0 -1
- package/dist/playground.mjs +0 -0
- package/src/playground.ts +0 -0
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
const require_chunk = require('../chunk-DWy1uDak.cjs');
|
|
2
|
-
const require_cacheTokenStorage = require('../cacheTokenStorage-CvptztkW.cjs');
|
|
3
|
-
const __geekmidas_cache_memory = require_chunk.__toESM(require("@geekmidas/cache/memory"));
|
|
4
|
-
const vitest = require_chunk.__toESM(require("vitest"));
|
|
5
|
-
|
|
6
|
-
//#region src/__tests__/cacheTokenStorage.spec.ts
|
|
7
|
-
(0, vitest.describe)("CacheTokenStorage", () => {
|
|
8
|
-
let storage;
|
|
9
|
-
let cache;
|
|
10
|
-
(0, vitest.beforeEach)(() => {
|
|
11
|
-
cache = new __geekmidas_cache_memory.InMemoryCache();
|
|
12
|
-
storage = new require_cacheTokenStorage.CacheTokenStorage(cache);
|
|
13
|
-
});
|
|
14
|
-
(0, vitest.describe)("access token operations", () => {
|
|
15
|
-
(0, vitest.it)("should store and retrieve access token", async () => {
|
|
16
|
-
await storage.setAccessToken("test-access-token");
|
|
17
|
-
const token = await storage.getAccessToken();
|
|
18
|
-
(0, vitest.expect)(token).toBe("test-access-token");
|
|
19
|
-
});
|
|
20
|
-
(0, vitest.it)("should return null when no access token exists", async () => {
|
|
21
|
-
const token = await storage.getAccessToken();
|
|
22
|
-
(0, vitest.expect)(token).toBeNull();
|
|
23
|
-
});
|
|
24
|
-
(0, vitest.it)("should store access token with TTL", async () => {
|
|
25
|
-
await storage.setAccessToken("test-access-token", 3600);
|
|
26
|
-
const token = await storage.getAccessToken();
|
|
27
|
-
(0, vitest.expect)(token).toBe("test-access-token");
|
|
28
|
-
});
|
|
29
|
-
(0, vitest.it)("should overwrite existing access token", async () => {
|
|
30
|
-
await storage.setAccessToken("first-token");
|
|
31
|
-
await storage.setAccessToken("second-token");
|
|
32
|
-
const token = await storage.getAccessToken();
|
|
33
|
-
(0, vitest.expect)(token).toBe("second-token");
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
(0, vitest.describe)("refresh token operations", () => {
|
|
37
|
-
(0, vitest.it)("should store and retrieve refresh token", async () => {
|
|
38
|
-
await storage.setRefreshToken("test-refresh-token");
|
|
39
|
-
const token = await storage.getRefreshToken();
|
|
40
|
-
(0, vitest.expect)(token).toBe("test-refresh-token");
|
|
41
|
-
});
|
|
42
|
-
(0, vitest.it)("should return null when no refresh token exists", async () => {
|
|
43
|
-
const token = await storage.getRefreshToken();
|
|
44
|
-
(0, vitest.expect)(token).toBeNull();
|
|
45
|
-
});
|
|
46
|
-
(0, vitest.it)("should store refresh token with TTL", async () => {
|
|
47
|
-
await storage.setRefreshToken("test-refresh-token", 7200);
|
|
48
|
-
const token = await storage.getRefreshToken();
|
|
49
|
-
(0, vitest.expect)(token).toBe("test-refresh-token");
|
|
50
|
-
});
|
|
51
|
-
(0, vitest.it)("should overwrite existing refresh token", async () => {
|
|
52
|
-
await storage.setRefreshToken("first-refresh-token");
|
|
53
|
-
await storage.setRefreshToken("second-refresh-token");
|
|
54
|
-
const token = await storage.getRefreshToken();
|
|
55
|
-
(0, vitest.expect)(token).toBe("second-refresh-token");
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
(0, vitest.describe)("token lifecycle", () => {
|
|
59
|
-
(0, vitest.it)("should store both tokens independently", async () => {
|
|
60
|
-
await storage.setAccessToken("access-token");
|
|
61
|
-
await storage.setRefreshToken("refresh-token");
|
|
62
|
-
const accessToken = await storage.getAccessToken();
|
|
63
|
-
const refreshToken = await storage.getRefreshToken();
|
|
64
|
-
(0, vitest.expect)(accessToken).toBe("access-token");
|
|
65
|
-
(0, vitest.expect)(refreshToken).toBe("refresh-token");
|
|
66
|
-
});
|
|
67
|
-
(0, vitest.it)("should clear both tokens", async () => {
|
|
68
|
-
await storage.setAccessToken("access-token");
|
|
69
|
-
await storage.setRefreshToken("refresh-token");
|
|
70
|
-
await storage.clearTokens();
|
|
71
|
-
const accessToken = await storage.getAccessToken();
|
|
72
|
-
const refreshToken = await storage.getRefreshToken();
|
|
73
|
-
(0, vitest.expect)(accessToken).toBeNull();
|
|
74
|
-
(0, vitest.expect)(refreshToken).toBeNull();
|
|
75
|
-
});
|
|
76
|
-
(0, vitest.it)("should clear tokens when some are missing", async () => {
|
|
77
|
-
await storage.setAccessToken("access-token");
|
|
78
|
-
await storage.clearTokens();
|
|
79
|
-
const accessToken = await storage.getAccessToken();
|
|
80
|
-
const refreshToken = await storage.getRefreshToken();
|
|
81
|
-
(0, vitest.expect)(accessToken).toBeNull();
|
|
82
|
-
(0, vitest.expect)(refreshToken).toBeNull();
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
(0, vitest.describe)("custom storage keys", () => {
|
|
86
|
-
(0, vitest.it)("should use custom keys for token storage", async () => {
|
|
87
|
-
const customStorage = new require_cacheTokenStorage.CacheTokenStorage(cache, "custom_access_key", "custom_refresh_key");
|
|
88
|
-
await customStorage.setAccessToken("access-token");
|
|
89
|
-
await customStorage.setRefreshToken("refresh-token");
|
|
90
|
-
const accessToken = await customStorage.getAccessToken();
|
|
91
|
-
const refreshToken = await customStorage.getRefreshToken();
|
|
92
|
-
(0, vitest.expect)(accessToken).toBe("access-token");
|
|
93
|
-
(0, vitest.expect)(refreshToken).toBe("refresh-token");
|
|
94
|
-
});
|
|
95
|
-
(0, vitest.it)("should isolate tokens between different storage instances", async () => {
|
|
96
|
-
const defaultStorage = new require_cacheTokenStorage.CacheTokenStorage(cache);
|
|
97
|
-
const customStorage = new require_cacheTokenStorage.CacheTokenStorage(cache, "custom_access", "custom_refresh");
|
|
98
|
-
await defaultStorage.setAccessToken("default-access");
|
|
99
|
-
await customStorage.setAccessToken("custom-access");
|
|
100
|
-
const defaultToken = await defaultStorage.getAccessToken();
|
|
101
|
-
const customToken = await customStorage.getAccessToken();
|
|
102
|
-
(0, vitest.expect)(defaultToken).toBe("default-access");
|
|
103
|
-
(0, vitest.expect)(customToken).toBe("custom-access");
|
|
104
|
-
});
|
|
105
|
-
(0, vitest.it)("should clear tokens independently with custom keys", async () => {
|
|
106
|
-
const defaultStorage = new require_cacheTokenStorage.CacheTokenStorage(cache);
|
|
107
|
-
const customStorage = new require_cacheTokenStorage.CacheTokenStorage(cache, "custom_access", "custom_refresh");
|
|
108
|
-
await defaultStorage.setAccessToken("default-access");
|
|
109
|
-
await customStorage.setAccessToken("custom-access");
|
|
110
|
-
await defaultStorage.clearTokens();
|
|
111
|
-
const defaultToken = await defaultStorage.getAccessToken();
|
|
112
|
-
const customToken = await customStorage.getAccessToken();
|
|
113
|
-
(0, vitest.expect)(defaultToken).toBeNull();
|
|
114
|
-
(0, vitest.expect)(customToken).toBe("custom-access");
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
(0, vitest.describe)("integration with real cache", () => {
|
|
118
|
-
(0, vitest.it)("should work with multiple cache instances", async () => {
|
|
119
|
-
const cache1 = new __geekmidas_cache_memory.InMemoryCache();
|
|
120
|
-
const cache2 = new __geekmidas_cache_memory.InMemoryCache();
|
|
121
|
-
const storage1 = new require_cacheTokenStorage.CacheTokenStorage(cache1);
|
|
122
|
-
const storage2 = new require_cacheTokenStorage.CacheTokenStorage(cache2);
|
|
123
|
-
await storage1.setAccessToken("token-1");
|
|
124
|
-
await storage2.setAccessToken("token-2");
|
|
125
|
-
const token1 = await storage1.getAccessToken();
|
|
126
|
-
const token2 = await storage2.getAccessToken();
|
|
127
|
-
(0, vitest.expect)(token1).toBe("token-1");
|
|
128
|
-
(0, vitest.expect)(token2).toBe("token-2");
|
|
129
|
-
});
|
|
130
|
-
(0, vitest.it)("should maintain token state across operations", async () => {
|
|
131
|
-
await storage.setAccessToken("initial-access");
|
|
132
|
-
await storage.setRefreshToken("initial-refresh");
|
|
133
|
-
let accessToken = await storage.getAccessToken();
|
|
134
|
-
let refreshToken = await storage.getRefreshToken();
|
|
135
|
-
(0, vitest.expect)(accessToken).toBe("initial-access");
|
|
136
|
-
(0, vitest.expect)(refreshToken).toBe("initial-refresh");
|
|
137
|
-
await storage.setAccessToken("updated-access");
|
|
138
|
-
accessToken = await storage.getAccessToken();
|
|
139
|
-
refreshToken = await storage.getRefreshToken();
|
|
140
|
-
(0, vitest.expect)(accessToken).toBe("updated-access");
|
|
141
|
-
(0, vitest.expect)(refreshToken).toBe("initial-refresh");
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
//#endregion
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { CacheTokenStorage } from "../cacheTokenStorage-Ca05vf3T.mjs";
|
|
2
|
-
import { InMemoryCache } from "@geekmidas/cache/memory";
|
|
3
|
-
import { beforeEach, describe, expect, it } from "vitest";
|
|
4
|
-
|
|
5
|
-
//#region src/__tests__/cacheTokenStorage.spec.ts
|
|
6
|
-
describe("CacheTokenStorage", () => {
|
|
7
|
-
let storage;
|
|
8
|
-
let cache;
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
cache = new InMemoryCache();
|
|
11
|
-
storage = new CacheTokenStorage(cache);
|
|
12
|
-
});
|
|
13
|
-
describe("access token operations", () => {
|
|
14
|
-
it("should store and retrieve access token", async () => {
|
|
15
|
-
await storage.setAccessToken("test-access-token");
|
|
16
|
-
const token = await storage.getAccessToken();
|
|
17
|
-
expect(token).toBe("test-access-token");
|
|
18
|
-
});
|
|
19
|
-
it("should return null when no access token exists", async () => {
|
|
20
|
-
const token = await storage.getAccessToken();
|
|
21
|
-
expect(token).toBeNull();
|
|
22
|
-
});
|
|
23
|
-
it("should store access token with TTL", async () => {
|
|
24
|
-
await storage.setAccessToken("test-access-token", 3600);
|
|
25
|
-
const token = await storage.getAccessToken();
|
|
26
|
-
expect(token).toBe("test-access-token");
|
|
27
|
-
});
|
|
28
|
-
it("should overwrite existing access token", async () => {
|
|
29
|
-
await storage.setAccessToken("first-token");
|
|
30
|
-
await storage.setAccessToken("second-token");
|
|
31
|
-
const token = await storage.getAccessToken();
|
|
32
|
-
expect(token).toBe("second-token");
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
describe("refresh token operations", () => {
|
|
36
|
-
it("should store and retrieve refresh token", async () => {
|
|
37
|
-
await storage.setRefreshToken("test-refresh-token");
|
|
38
|
-
const token = await storage.getRefreshToken();
|
|
39
|
-
expect(token).toBe("test-refresh-token");
|
|
40
|
-
});
|
|
41
|
-
it("should return null when no refresh token exists", async () => {
|
|
42
|
-
const token = await storage.getRefreshToken();
|
|
43
|
-
expect(token).toBeNull();
|
|
44
|
-
});
|
|
45
|
-
it("should store refresh token with TTL", async () => {
|
|
46
|
-
await storage.setRefreshToken("test-refresh-token", 7200);
|
|
47
|
-
const token = await storage.getRefreshToken();
|
|
48
|
-
expect(token).toBe("test-refresh-token");
|
|
49
|
-
});
|
|
50
|
-
it("should overwrite existing refresh token", async () => {
|
|
51
|
-
await storage.setRefreshToken("first-refresh-token");
|
|
52
|
-
await storage.setRefreshToken("second-refresh-token");
|
|
53
|
-
const token = await storage.getRefreshToken();
|
|
54
|
-
expect(token).toBe("second-refresh-token");
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe("token lifecycle", () => {
|
|
58
|
-
it("should store both tokens independently", async () => {
|
|
59
|
-
await storage.setAccessToken("access-token");
|
|
60
|
-
await storage.setRefreshToken("refresh-token");
|
|
61
|
-
const accessToken = await storage.getAccessToken();
|
|
62
|
-
const refreshToken = await storage.getRefreshToken();
|
|
63
|
-
expect(accessToken).toBe("access-token");
|
|
64
|
-
expect(refreshToken).toBe("refresh-token");
|
|
65
|
-
});
|
|
66
|
-
it("should clear both tokens", async () => {
|
|
67
|
-
await storage.setAccessToken("access-token");
|
|
68
|
-
await storage.setRefreshToken("refresh-token");
|
|
69
|
-
await storage.clearTokens();
|
|
70
|
-
const accessToken = await storage.getAccessToken();
|
|
71
|
-
const refreshToken = await storage.getRefreshToken();
|
|
72
|
-
expect(accessToken).toBeNull();
|
|
73
|
-
expect(refreshToken).toBeNull();
|
|
74
|
-
});
|
|
75
|
-
it("should clear tokens when some are missing", async () => {
|
|
76
|
-
await storage.setAccessToken("access-token");
|
|
77
|
-
await storage.clearTokens();
|
|
78
|
-
const accessToken = await storage.getAccessToken();
|
|
79
|
-
const refreshToken = await storage.getRefreshToken();
|
|
80
|
-
expect(accessToken).toBeNull();
|
|
81
|
-
expect(refreshToken).toBeNull();
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe("custom storage keys", () => {
|
|
85
|
-
it("should use custom keys for token storage", async () => {
|
|
86
|
-
const customStorage = new CacheTokenStorage(cache, "custom_access_key", "custom_refresh_key");
|
|
87
|
-
await customStorage.setAccessToken("access-token");
|
|
88
|
-
await customStorage.setRefreshToken("refresh-token");
|
|
89
|
-
const accessToken = await customStorage.getAccessToken();
|
|
90
|
-
const refreshToken = await customStorage.getRefreshToken();
|
|
91
|
-
expect(accessToken).toBe("access-token");
|
|
92
|
-
expect(refreshToken).toBe("refresh-token");
|
|
93
|
-
});
|
|
94
|
-
it("should isolate tokens between different storage instances", async () => {
|
|
95
|
-
const defaultStorage = new CacheTokenStorage(cache);
|
|
96
|
-
const customStorage = new CacheTokenStorage(cache, "custom_access", "custom_refresh");
|
|
97
|
-
await defaultStorage.setAccessToken("default-access");
|
|
98
|
-
await customStorage.setAccessToken("custom-access");
|
|
99
|
-
const defaultToken = await defaultStorage.getAccessToken();
|
|
100
|
-
const customToken = await customStorage.getAccessToken();
|
|
101
|
-
expect(defaultToken).toBe("default-access");
|
|
102
|
-
expect(customToken).toBe("custom-access");
|
|
103
|
-
});
|
|
104
|
-
it("should clear tokens independently with custom keys", async () => {
|
|
105
|
-
const defaultStorage = new CacheTokenStorage(cache);
|
|
106
|
-
const customStorage = new CacheTokenStorage(cache, "custom_access", "custom_refresh");
|
|
107
|
-
await defaultStorage.setAccessToken("default-access");
|
|
108
|
-
await customStorage.setAccessToken("custom-access");
|
|
109
|
-
await defaultStorage.clearTokens();
|
|
110
|
-
const defaultToken = await defaultStorage.getAccessToken();
|
|
111
|
-
const customToken = await customStorage.getAccessToken();
|
|
112
|
-
expect(defaultToken).toBeNull();
|
|
113
|
-
expect(customToken).toBe("custom-access");
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
describe("integration with real cache", () => {
|
|
117
|
-
it("should work with multiple cache instances", async () => {
|
|
118
|
-
const cache1 = new InMemoryCache();
|
|
119
|
-
const cache2 = new InMemoryCache();
|
|
120
|
-
const storage1 = new CacheTokenStorage(cache1);
|
|
121
|
-
const storage2 = new CacheTokenStorage(cache2);
|
|
122
|
-
await storage1.setAccessToken("token-1");
|
|
123
|
-
await storage2.setAccessToken("token-2");
|
|
124
|
-
const token1 = await storage1.getAccessToken();
|
|
125
|
-
const token2 = await storage2.getAccessToken();
|
|
126
|
-
expect(token1).toBe("token-1");
|
|
127
|
-
expect(token2).toBe("token-2");
|
|
128
|
-
});
|
|
129
|
-
it("should maintain token state across operations", async () => {
|
|
130
|
-
await storage.setAccessToken("initial-access");
|
|
131
|
-
await storage.setRefreshToken("initial-refresh");
|
|
132
|
-
let accessToken = await storage.getAccessToken();
|
|
133
|
-
let refreshToken = await storage.getRefreshToken();
|
|
134
|
-
expect(accessToken).toBe("initial-access");
|
|
135
|
-
expect(refreshToken).toBe("initial-refresh");
|
|
136
|
-
await storage.setAccessToken("updated-access");
|
|
137
|
-
accessToken = await storage.getAccessToken();
|
|
138
|
-
refreshToken = await storage.getRefreshToken();
|
|
139
|
-
expect(accessToken).toBe("updated-access");
|
|
140
|
-
expect(refreshToken).toBe("initial-refresh");
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
//#endregion
|