@dvrd/dvr-controls 1.1.27 → 1.1.28
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dvrd/dvr-controls",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.28",
|
|
4
4
|
"description": "Custom web controls",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"files": [
|
|
@@ -10,9 +10,6 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://bitbucket.org/Naampie/dvr-controls/"
|
|
12
12
|
},
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "npm publish"
|
|
15
|
-
},
|
|
16
13
|
"author": "Dave van Rijn",
|
|
17
14
|
"license": "ISC",
|
|
18
15
|
"browserslist": {
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Copyright (c) 2024. Dave van Rijn Development
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import Cookies
|
|
5
|
+
import Cookies from "js-cookie";
|
|
6
6
|
|
|
7
|
-
export const setCookie = (key: string, value: string, args?: CookieAttributes) => {
|
|
7
|
+
export const setCookie = (key: string, value: string, args?: Cookies.CookieAttributes) => {
|
|
8
8
|
Cookies.set(key, value, {...args})
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export const removeCookie = (key: string, args?: CookieAttributes) => {
|
|
11
|
+
export const removeCookie = (key: string, args?: Cookies.CookieAttributes) => {
|
|
12
12
|
Cookies.remove(key, args);
|
|
13
13
|
};
|
|
14
14
|
|
package/src/js/util/jwtUtil.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2024. Dave van Rijn Development
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import Cookies
|
|
6
|
-
import {
|
|
5
|
+
import Cookies from "js-cookie";
|
|
6
|
+
import {getSetting} from "./miscUtil";
|
|
7
7
|
|
|
8
8
|
let jwtToken: string | null = null;
|
|
9
9
|
|
|
@@ -20,14 +20,14 @@ export const getJwt = (cookieName: string = 'JWT'): string | null => {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export function setJWT(token: string | null, options?: {
|
|
23
|
-
preserveNull?: boolean; useStorage?: boolean, cookieName?: string; attributes?: CookieAttributes
|
|
23
|
+
preserveNull?: boolean; useStorage?: boolean, cookieName?: string; attributes?: Cookies.CookieAttributes
|
|
24
24
|
}) {
|
|
25
25
|
jwtToken = token;
|
|
26
26
|
const preserveNull = options?.preserveNull ?? false;
|
|
27
27
|
const useStorage = options?.useStorage ?? true;
|
|
28
28
|
if (window.allowCookies || !token) {
|
|
29
29
|
if (token) {
|
|
30
|
-
let cookieOptions: CookieAttributes = {expires: 1, sameSite: 'strict', ...options?.attributes};
|
|
30
|
+
let cookieOptions: Cookies.CookieAttributes = {expires: 1, sameSite: 'strict', ...options?.attributes};
|
|
31
31
|
if (getSetting('mode') !== 'dev') {
|
|
32
32
|
cookieOptions.secure = true;
|
|
33
33
|
cookieOptions.sameSite = 'strict';
|
|
@@ -40,12 +40,12 @@ export function setJWT(token: string | null, options?: {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export const setJwt = (token: string | null, preserveOnNull: boolean = false, includeStorage: boolean = true,
|
|
43
|
-
_options?: CookieAttributes) => {
|
|
43
|
+
_options?: Cookies.CookieAttributes) => {
|
|
44
44
|
console.debug('Settings JWT token', {token, preserveOnNull, includeStorage, allowCookies: window.allowCookies});
|
|
45
45
|
jwtToken = token;
|
|
46
46
|
if (window.allowCookies || !token) {
|
|
47
47
|
if (token) {
|
|
48
|
-
let options: CookieAttributes = {expires: 1, sameSite: 'strict'};
|
|
48
|
+
let options: Cookies.CookieAttributes = {expires: 1, sameSite: 'strict'};
|
|
49
49
|
if (_options) options = Object.assign({}, options, _options);
|
|
50
50
|
if (getSetting('mode') !== 'dev') {
|
|
51
51
|
options.secure = true;
|