tering-serieuze-sdk 1.2.0 → 1.2.1
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/api/auth.ts +1 -1
- package/src/cache/cookieCache.ts +4 -4
package/package.json
CHANGED
package/src/api/auth.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseModule } from "./base";
|
|
2
2
|
|
|
3
3
|
export class AuthModule extends BaseModule {
|
|
4
|
-
|
|
4
|
+
public static cacheKey = "TSS-TOKEN";
|
|
5
5
|
|
|
6
6
|
async getToken(): Promise<string | undefined> {
|
|
7
7
|
return this.cache.get(AuthModule.cacheKey);
|
package/src/cache/cookieCache.ts
CHANGED
|
@@ -6,8 +6,8 @@ export class CookieCache extends AbstractCache {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
public async get<T>(key: string): Promise<T | undefined> {
|
|
9
|
-
if (document.cookie.includes(
|
|
10
|
-
return document.cookie.split(
|
|
9
|
+
if (document.cookie.includes(`${key}=`)) {
|
|
10
|
+
return document.cookie.split(`${key}=`)[1]?.split(";")[0] as T;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
return undefined;
|
|
@@ -15,11 +15,11 @@ export class CookieCache extends AbstractCache {
|
|
|
15
15
|
|
|
16
16
|
public set<T>(key: string, value: T, lifetime?: number): void {
|
|
17
17
|
const expires = lifetime ? new Date(Date.now() + lifetime).toUTCString() : "";
|
|
18
|
-
document.cookie =
|
|
18
|
+
document.cookie = `${key}=${value}; expires=${expires}; path=/; samesite=strict; secure`;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
public remove(key: string): void {
|
|
22
|
-
document.cookie =
|
|
22
|
+
document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
public clear(): void {
|