@rh-support/utils 2.5.4 → 2.5.6
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/lib/esm/appUtils.d.ts +3 -0
- package/lib/esm/appUtils.d.ts.map +1 -1
- package/lib/esm/appUtils.js +40 -0
- package/package.json +4 -4
package/lib/esm/appUtils.d.ts
CHANGED
|
@@ -8,4 +8,7 @@ export declare const getStrataHeaders: (appName: string, accountNumber: string)
|
|
|
8
8
|
export declare const setStrataHeaders: (appName: string, accountNumber: string) => void;
|
|
9
9
|
export declare const getUserAgentForCaseMode: (isCaseCreate: boolean) => string;
|
|
10
10
|
export declare const setSecuredSupport: (isGs4?: boolean) => void;
|
|
11
|
+
export declare function getCookieValue(key: string): string;
|
|
12
|
+
export declare function enableScripts(): void;
|
|
13
|
+
export declare function waitForWindowVariable(variableName: string, timeout?: number): Promise<any>;
|
|
11
14
|
//# sourceMappingURL=appUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appUtils.d.ts","sourceRoot":"","sources":["../../src/appUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"appUtils.d.ts","sourceRoot":"","sources":["../../src/appUtils.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,cAe7B,CAAC;AAEF,eAAO,MAAM,aAAa,WAEzB,CAAC;AAEF,MAAM,WAAW,cAAc;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAGD,eAAO,MAAM,gBAAgB,YAAa,MAAM,iBAAiB,MAAM,KAAG,cAGxE,CAAC;AAEH,eAAO,MAAM,gBAAgB,YAAa,MAAM,iBAAiB,MAAM,SAItE,CAAC;AAgBF,eAAO,MAAM,uBAAuB,iBAAkB,OAAO,WAE5D,CAAC;AAGF,eAAO,MAAM,iBAAiB,WAAW,OAAO,SAG/C,CAAC;AAEF,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,UAGzC;AAGD,wBAAgB,aAAa,SAiB5B;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,SAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAgBxF"}
|
package/lib/esm/appUtils.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import find from 'lodash/find';
|
|
1
2
|
import get from 'lodash/get';
|
|
3
|
+
import map from 'lodash/map';
|
|
2
4
|
export const getAccessHostname = () => {
|
|
3
5
|
// returns the current access.redhat.com hostname (e.g if qa then would return access.qa.redhat.com)
|
|
4
6
|
if (typeof window !== 'undefined' && window) {
|
|
@@ -53,3 +55,41 @@ export const setSecuredSupport = (isGs4 = false) => {
|
|
|
53
55
|
securedSupport.isGs4 = isGs4;
|
|
54
56
|
securedSupport.pathPrefix = isGs4 ? '/secure-support' : '';
|
|
55
57
|
};
|
|
58
|
+
export function getCookieValue(key) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
const cookies = map(document.cookie.split(';'), (c) => c.split('='));
|
|
61
|
+
return (_b = (_a = find(cookies, (c) => c[0].trim() === key.trim())) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '';
|
|
62
|
+
}
|
|
63
|
+
// enable blocked scripts
|
|
64
|
+
export function enableScripts() {
|
|
65
|
+
const blockedScripts = document.querySelectorAll('script[data-cookieconsent="blocked"]');
|
|
66
|
+
// iterate through blocked scripts
|
|
67
|
+
blockedScripts.forEach((script) => {
|
|
68
|
+
// change script type from text/plain to text/javascript to make script executable
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
script.type = 'text/javascript';
|
|
71
|
+
const newScript = document.createElement('script');
|
|
72
|
+
// @ts-ignore
|
|
73
|
+
newScript.src = script.src;
|
|
74
|
+
// replace old script with new executable script
|
|
75
|
+
// @ts-ignore
|
|
76
|
+
script.parentNode.replaceChild(newScript, script);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
export function waitForWindowVariable(variableName, timeout = 5000) {
|
|
80
|
+
return new Promise((resolve, reject) => {
|
|
81
|
+
const startTime = Date.now();
|
|
82
|
+
function checkVariable() {
|
|
83
|
+
if (window[variableName] !== undefined) {
|
|
84
|
+
resolve(window[variableName]);
|
|
85
|
+
}
|
|
86
|
+
else if (Date.now() - startTime < timeout) {
|
|
87
|
+
setTimeout(checkVariable, 100);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
reject(new Error(`Timeout: ${variableName} not found after ${timeout}ms`));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
checkVariable();
|
|
94
|
+
});
|
|
95
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rh-support/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.6",
|
|
4
4
|
"description": "> TODO: description",
|
|
5
5
|
"author": "Vikas Rathee <vrathee@redhat.com>",
|
|
6
6
|
"license": "ISC",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"prepublishOnly": "npm run build"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@cee-eng/hydrajs": "4.
|
|
44
|
+
"@cee-eng/hydrajs": "4.18.33",
|
|
45
45
|
"localforage": "^1.10.0",
|
|
46
46
|
"lodash": "^4.17.21",
|
|
47
47
|
"qs": "^6.7.0",
|
|
48
48
|
"solr-query-builder": "1.0.1"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@cee-eng/hydrajs": "4.
|
|
51
|
+
"@cee-eng/hydrajs": "4.18.33",
|
|
52
52
|
"@rh-support/types": "2.0.4",
|
|
53
53
|
"date-fns": "3.6.0",
|
|
54
54
|
"date-fns-tz": "^3.1.3",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"defaults and supports es6-module",
|
|
75
75
|
"maintained node versions"
|
|
76
76
|
],
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "546b242324a0f5c12db8e448ed7ce8f374e48105"
|
|
78
78
|
}
|