ag-common 0.0.281 → 0.0.284
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/dist/ui/components/Button/index.d.ts +1 -0
- package/dist/ui/components/Button/index.js +19 -7
- package/dist/ui/components/LoginButton/index.js +1 -1
- package/dist/ui/helpers/callOpenApi/cached.js +3 -6
- package/dist/ui/helpers/callOpenApi/direct.d.ts +7 -1
- package/dist/ui/helpers/callOpenApi/direct.js +36 -17
- package/package.json +1 -1
|
@@ -49,18 +49,30 @@ exports.ButtonBase = (0, styled_components_1.css) `
|
|
|
49
49
|
}
|
|
50
50
|
padding-left: 1rem;
|
|
51
51
|
padding-right: 1rem;
|
|
52
|
-
background-color: ${colours_1.colours.darkGreen};
|
|
53
52
|
color: white;
|
|
54
|
-
&[data-invert='true'] {
|
|
55
|
-
color: ${colours_1.colours.darkGreen};
|
|
56
|
-
background-color: white;
|
|
57
|
-
border: solid 1px ${colours_1.colours.darkGreen};
|
|
58
|
-
}
|
|
59
53
|
|
|
60
54
|
&[data-disabled='true'] {
|
|
61
55
|
cursor: default;
|
|
62
56
|
background-color: #888;
|
|
63
57
|
}
|
|
58
|
+
|
|
59
|
+
&[data-theme='green'] {
|
|
60
|
+
background-color: ${colours_1.colours.darkGreen};
|
|
61
|
+
&[data-invert='true'] {
|
|
62
|
+
color: ${colours_1.colours.darkGreen};
|
|
63
|
+
background-color: white;
|
|
64
|
+
border: solid 1px ${colours_1.colours.darkGreen};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
&[data-theme='red'] {
|
|
69
|
+
background-color: ${colours_1.colours.orangeRed};
|
|
70
|
+
&[data-invert='true'] {
|
|
71
|
+
color: ${colours_1.colours.orangeRed};
|
|
72
|
+
background-color: white;
|
|
73
|
+
border: solid 1px ${colours_1.colours.orangeRed};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
64
76
|
`;
|
|
65
77
|
const BaseButton = styled_components_1.default.button `
|
|
66
78
|
${exports.ButtonBase}
|
|
@@ -75,6 +87,6 @@ const Button = (props) => {
|
|
|
75
87
|
? // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
88
|
BaseA
|
|
77
89
|
: BaseButton;
|
|
78
|
-
return (react_1.default.createElement(Component, Object.assign({ className: props.className, "data-invert": props.invert, "data-disabled": (_a = props.disabled) !== null && _a !== void 0 ? _a : false, role: "button", title: props.title || undefined }, props), props.children));
|
|
90
|
+
return (react_1.default.createElement(Component, Object.assign({ className: props.className, "data-invert": props.invert, "data-disabled": (_a = props.disabled) !== null && _a !== void 0 ? _a : false, role: "button", title: props.title || undefined, "data-theme": props.colourTheme || 'green' }, props), props.children));
|
|
79
91
|
};
|
|
80
92
|
exports.Button = Button;
|
|
@@ -17,6 +17,6 @@ const LoginButton = ({ className, text, invert, savePath, loginPath, style, }) =
|
|
|
17
17
|
redirect: savePath,
|
|
18
18
|
};
|
|
19
19
|
const lp = loginPath(state);
|
|
20
|
-
return (react_1.default.createElement(Base, { style: style, href: lp, title: text, "data-invert": invert, "data-disabled": false, className: className }, text));
|
|
20
|
+
return (react_1.default.createElement(Base, { style: style, href: lp, title: text, "data-invert": invert, "data-disabled": false, className: className, "data-theme": "green" }, text));
|
|
21
21
|
};
|
|
22
22
|
exports.LoginButton = LoginButton;
|
|
@@ -14,7 +14,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.callOpenApiCached = exports.callOpenApiCachedRaw = exports.setOpenApiCacheRaw = void 0;
|
|
16
16
|
const direct_1 = require("./direct");
|
|
17
|
-
const cookie_1 = require("../cookie");
|
|
18
17
|
const string_1 = require("../../../common/helpers/string");
|
|
19
18
|
const common_1 = require("../../../common");
|
|
20
19
|
const node_cache_1 = __importDefault(require("node-cache"));
|
|
@@ -25,11 +24,9 @@ let callOpenApiCache;
|
|
|
25
24
|
* @returns
|
|
26
25
|
*/
|
|
27
26
|
function getCacheKey({ cacheKey, overrideAuth, ssrCacheItems, }) {
|
|
28
|
-
const authkeyPrefix1 = (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
defaultValue: '',
|
|
32
|
-
});
|
|
27
|
+
const authkeyPrefix1 = (0, direct_1.getIdTokenAuthHeaderRaw)({
|
|
28
|
+
overrideAuth: overrideAuth,
|
|
29
|
+
});
|
|
33
30
|
const authPref = !authkeyPrefix1 ? '' : (0, common_1.hashCode)((0, string_1.toBase64)(authkeyPrefix1));
|
|
34
31
|
const ssrCachePref = !ssrCacheItems
|
|
35
32
|
? ''
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import { ICallOpenApi } from './types';
|
|
1
|
+
import { ICallOpenApi, OverrideAuth } from './types';
|
|
2
2
|
import { AxiosWrapperLite } from '../jwt';
|
|
3
|
+
/**
|
|
4
|
+
* get the id_token from provided value, or cookie, or LS
|
|
5
|
+
*/
|
|
6
|
+
export declare function getIdTokenAuthHeaderRaw({ overrideAuth, }: {
|
|
7
|
+
overrideAuth?: OverrideAuth;
|
|
8
|
+
}): string;
|
|
3
9
|
export declare const callOpenApi: <T, TDefaultApi>(p: ICallOpenApi<T, TDefaultApi>) => Promise<AxiosWrapperLite<T>>;
|
|
@@ -9,29 +9,48 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.callOpenApi = void 0;
|
|
12
|
+
exports.callOpenApi = exports.getIdTokenAuthHeaderRaw = void 0;
|
|
13
13
|
const cookie_1 = require("../cookie");
|
|
14
14
|
const sleep_1 = require("../../../common/helpers/sleep");
|
|
15
15
|
const array_1 = require("../../../common/helpers/array");
|
|
16
|
+
const useLocalStorage_1 = require("../useLocalStorage");
|
|
17
|
+
/**
|
|
18
|
+
* get the id_token from provided value, or cookie, or LS
|
|
19
|
+
*/
|
|
20
|
+
function getIdTokenAuthHeaderRaw({ overrideAuth, }) {
|
|
21
|
+
var _a;
|
|
22
|
+
let idToken;
|
|
23
|
+
//if override supplied will only use that and not refresh
|
|
24
|
+
if (overrideAuth === null || overrideAuth === void 0 ? void 0 : overrideAuth.id_token) {
|
|
25
|
+
idToken = overrideAuth === null || overrideAuth === void 0 ? void 0 : overrideAuth.id_token;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
idToken = (0, cookie_1.getCookieString)({
|
|
29
|
+
name: 'id_token',
|
|
30
|
+
defaultValue: '',
|
|
31
|
+
});
|
|
32
|
+
if (!idToken) {
|
|
33
|
+
const userLs = (0, useLocalStorage_1.getLocalStorageItem)('user', undefined);
|
|
34
|
+
if ((_a = userLs === null || userLs === void 0 ? void 0 : userLs.jwt) === null || _a === void 0 ? void 0 : _a.id_token) {
|
|
35
|
+
idToken = userLs.jwt.id_token;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return idToken;
|
|
40
|
+
}
|
|
41
|
+
exports.getIdTokenAuthHeaderRaw = getIdTokenAuthHeaderRaw;
|
|
42
|
+
/**
|
|
43
|
+
* get id_token, and then refresh
|
|
44
|
+
*/
|
|
16
45
|
function getIdTokenAuthHeader({ overrideAuth, refreshToken, }) {
|
|
17
46
|
var _a, _b;
|
|
18
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
let idToken;
|
|
20
|
-
//if
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
idToken = (0, cookie_1.getCookieString)({
|
|
26
|
-
name: 'id_token',
|
|
27
|
-
defaultValue: '',
|
|
28
|
-
});
|
|
29
|
-
//if we have a cookie token, can try to refresh
|
|
30
|
-
if (idToken) {
|
|
31
|
-
const updated = yield refreshToken();
|
|
32
|
-
if ((_a = updated === null || updated === void 0 ? void 0 : updated.jwt) === null || _a === void 0 ? void 0 : _a.id_token) {
|
|
33
|
-
idToken = (_b = updated === null || updated === void 0 ? void 0 : updated.jwt) === null || _b === void 0 ? void 0 : _b.id_token;
|
|
34
|
-
}
|
|
48
|
+
let idToken = getIdTokenAuthHeaderRaw({ overrideAuth });
|
|
49
|
+
//if we have a cookie token, can try to refresh
|
|
50
|
+
if (idToken) {
|
|
51
|
+
const updated = yield refreshToken();
|
|
52
|
+
if ((_a = updated === null || updated === void 0 ? void 0 : updated.jwt) === null || _a === void 0 ? void 0 : _a.id_token) {
|
|
53
|
+
idToken = (_b = updated === null || updated === void 0 ? void 0 : updated.jwt) === null || _b === void 0 ? void 0 : _b.id_token;
|
|
35
54
|
}
|
|
36
55
|
}
|
|
37
56
|
return idToken;
|