@redhat-cloud-services/frontend-components-config-utilities 2.0.3 → 3.0.0-beta.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/babel-transform-imports.d.ts +14 -0
- package/babel-transform-imports.js +164 -0
- package/babel-transform-imports.js.map +1 -0
- package/cookieTransform.d.ts +16 -0
- package/cookieTransform.js +41 -52
- package/cookieTransform.js.map +1 -0
- package/extension-mapper.d.ts +14 -0
- package/extension-mapper.js +56 -75
- package/extension-mapper.js.map +1 -0
- package/extensions-plugin.d.ts +1 -0
- package/extensions-plugin.js +44 -51
- package/extensions-plugin.js.map +1 -0
- package/federated-modules.d.ts +20 -0
- package/federated-modules.js +111 -112
- package/federated-modules.js.map +1 -0
- package/generate-pf-shared-assets-list.d.ts +2 -0
- package/generate-pf-shared-assets-list.js +101 -0
- package/generate-pf-shared-assets-list.js.map +1 -0
- package/index.d.ts +15 -0
- package/index.js +43 -1
- package/index.js.map +1 -0
- package/jsVarName.d.ts +2 -0
- package/jsVarName.js +8 -10
- package/jsVarName.js.map +1 -0
- package/package.json +14 -2
- package/proxy.d.ts +38 -0
- package/proxy.js +323 -308
- package/proxy.js.map +1 -0
- package/search-ignored-styles.d.ts +2 -0
- package/search-ignored-styles.js +71 -33
- package/search-ignored-styles.js.map +1 -0
- package/serve-federated.d.ts +2 -0
- package/serve-federated.js +35 -33
- package/serve-federated.js.map +1 -0
- package/serveLocalFile.d.ts +11 -0
- package/serveLocalFile.js +19 -16
- package/serveLocalFile.js.map +1 -0
- package/standalone/helpers/checkout.d.ts +5 -0
- package/standalone/helpers/checkout.js +67 -46
- package/standalone/helpers/checkout.js.map +1 -0
- package/standalone/helpers/index.d.ts +8 -0
- package/standalone/helpers/index.js +47 -62
- package/standalone/helpers/index.js.map +1 -0
- package/standalone/helpers/router.d.ts +3 -0
- package/standalone/helpers/router.js +17 -10
- package/standalone/helpers/router.js.map +1 -0
- package/standalone/index.d.ts +1 -0
- package/standalone/index.js +18 -1
- package/standalone/index.js.map +1 -0
- package/standalone/services/backofficeProxy.d.ts +7 -0
- package/standalone/services/backofficeProxy.js +54 -51
- package/standalone/services/backofficeProxy.js.map +1 -0
- package/standalone/services/default/chrome.d.ts +24 -0
- package/standalone/services/default/chrome.js +98 -81
- package/standalone/services/default/chrome.js.map +1 -0
- package/standalone/services/default/config.d.ts +13 -0
- package/standalone/services/default/config.js +13 -6
- package/standalone/services/default/config.js.map +1 -0
- package/standalone/services/default/entitlements.d.ts +19 -0
- package/standalone/services/default/entitlements.js +37 -34
- package/standalone/services/default/entitlements.js.map +1 -0
- package/standalone/services/default/index.d.ts +56 -0
- package/standalone/services/default/index.js +15 -11
- package/standalone/services/default/index.js.map +1 -0
- package/standalone/services/default/keycloak/realm_export.json +4805 -4805
- package/standalone/services/default/landing.d.ts +14 -0
- package/standalone/services/default/landing.js +19 -14
- package/standalone/services/default/landing.js.map +1 -0
- package/standalone/services/index.d.ts +91 -0
- package/standalone/services/index.js +13 -9
- package/standalone/services/index.js.map +1 -0
- package/standalone/services/rbac.d.ts +29 -0
- package/standalone/services/rbac.js +53 -61
- package/standalone/services/rbac.js.map +1 -0
- package/standalone/startService.d.ts +13 -0
- package/standalone/startService.js +82 -33
- package/standalone/startService.js.map +1 -0
- package/chrome-render-loader.js +0 -8
- package/chrome-render-loader.test.js +0 -44
- package/standalone/services/default/keycloak/export_keycloak.sh +0 -8
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const createPfReactTransform: (roots?: never[], moduleOverrides?: {
|
|
2
|
+
[importName: string]: string;
|
|
3
|
+
}) => (string | {
|
|
4
|
+
'@patternfly/react-core': {
|
|
5
|
+
transform: (importName: string) => string;
|
|
6
|
+
preventFullImport: boolean;
|
|
7
|
+
skipDefaultConversion: boolean;
|
|
8
|
+
};
|
|
9
|
+
'@patternfly/react-icons': {
|
|
10
|
+
transform: (importName: string) => string | undefined;
|
|
11
|
+
preventFullImport: boolean;
|
|
12
|
+
};
|
|
13
|
+
})[];
|
|
14
|
+
export default createPfReactTransform;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
+
if (ar || !(i in from)) {
|
|
39
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
+
ar[i] = from[i];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
var glob = __importStar(require("glob"));
|
|
47
|
+
var defaultRoot = process.cwd();
|
|
48
|
+
var PROPS_MATCH = /Props$/g;
|
|
49
|
+
var VARIANT_MATCH = /Variants?$/g;
|
|
50
|
+
var POSITION_MATCH = /Position$/g;
|
|
51
|
+
var iconMapper = {
|
|
52
|
+
AnsibeTowerIcon: 'ansibeTower-icon',
|
|
53
|
+
ChartSpikeIcon: 'chartSpike-icon',
|
|
54
|
+
CloudServerIcon: 'cloudServer-icon',
|
|
55
|
+
};
|
|
56
|
+
var ICONS_CACHE = {};
|
|
57
|
+
var COMPONENTS_CACHE = {};
|
|
58
|
+
function findIconInRoots(roots, icon) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
var result = ICONS_CACHE[icon];
|
|
61
|
+
if (result) {
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
var nameSpecifier = icon.replace(/([A-Z])/g, function (g) { return "-".concat(g[0].toLowerCase()); }).replace(/^-/, '');
|
|
65
|
+
var location = (_a = roots
|
|
66
|
+
.map(function (root) {
|
|
67
|
+
return glob.sync("".concat(root, "/node_modules/@patternfly/react-icons/dist/esm/**/").concat(iconMapper[icon] || nameSpecifier, ".js"));
|
|
68
|
+
})
|
|
69
|
+
.flat()) === null || _a === void 0 ? void 0 : _a[0];
|
|
70
|
+
if (!location) {
|
|
71
|
+
throw new Error("Cannot find source files for the ".concat(icon, " icon. Expected filename ").concat(nameSpecifier, ". It is possible the icon name does not match the filename pattern. You can look for the source file and add a new entry to the \"iconMapper\" object in your babel.config.js."));
|
|
72
|
+
}
|
|
73
|
+
return (_b = location.split('node_modules/').pop()) === null || _b === void 0 ? void 0 : _b.replace(/\.js$/, '').replace('/esm/', '/dynamic/');
|
|
74
|
+
}
|
|
75
|
+
function findPfRoots(roots, importName) {
|
|
76
|
+
var _a, _b, _c, _d;
|
|
77
|
+
if (COMPONENTS_CACHE[importName]) {
|
|
78
|
+
return COMPONENTS_CACHE[importName];
|
|
79
|
+
}
|
|
80
|
+
var importTemplate = "@patternfly/react-core/dist/esm/**/".concat(importName, ".js");
|
|
81
|
+
var componentSource = (_a = roots
|
|
82
|
+
.map(function (root) {
|
|
83
|
+
return glob.sync("".concat(root, "/node_modules/").concat(importTemplate));
|
|
84
|
+
})
|
|
85
|
+
.flat()) === null || _a === void 0 ? void 0 : _a[0];
|
|
86
|
+
if (!componentSource && importName.match(PROPS_MATCH)) {
|
|
87
|
+
componentSource = (_b = roots
|
|
88
|
+
.map(function (root) {
|
|
89
|
+
return glob.sync("".concat(root, "/node_modules/").concat(importTemplate.replace(/\.js$/, '').replace(PROPS_MATCH, ''), ".js"));
|
|
90
|
+
})
|
|
91
|
+
.flat()) === null || _b === void 0 ? void 0 : _b[0];
|
|
92
|
+
}
|
|
93
|
+
if (!componentSource && importName.match(VARIANT_MATCH)) {
|
|
94
|
+
componentSource = (_c = roots
|
|
95
|
+
.map(function (root) {
|
|
96
|
+
return glob.sync("".concat(root, "/node_modules/").concat(importTemplate.replace(/\.js$/, '').replace(VARIANT_MATCH, ''), ".js"));
|
|
97
|
+
})
|
|
98
|
+
.flat()) === null || _c === void 0 ? void 0 : _c[0];
|
|
99
|
+
}
|
|
100
|
+
if (!componentSource && importName.match(POSITION_MATCH)) {
|
|
101
|
+
componentSource = (_d = roots
|
|
102
|
+
.map(function (root) {
|
|
103
|
+
return glob.sync("".concat(root, "/node_modules/").concat(importTemplate.replace(/\.js$/, '').replace(POSITION_MATCH, ''), ".js"));
|
|
104
|
+
})
|
|
105
|
+
.flat()) === null || _d === void 0 ? void 0 : _d[0];
|
|
106
|
+
}
|
|
107
|
+
if (!componentSource) {
|
|
108
|
+
throw new Error("Unable to find source file for ".concat(importName, "! Please find a source file for the component and add it to \"moduleOverrides\" argument of the createPfReactTransform babel plugin."));
|
|
109
|
+
}
|
|
110
|
+
componentSource = componentSource.split('/esm/').pop();
|
|
111
|
+
var componentFragments = componentSource.split('/');
|
|
112
|
+
componentFragments.pop();
|
|
113
|
+
componentSource = "@patternfly/react-core/dist/dynamic/".concat(componentFragments.join('/'));
|
|
114
|
+
COMPONENTS_CACHE[importName] = componentSource;
|
|
115
|
+
return componentSource;
|
|
116
|
+
}
|
|
117
|
+
var MISMATCHED_CORE_MODULES = {
|
|
118
|
+
getResizeObserver: 'helpers/resizeObserver',
|
|
119
|
+
useOUIAProps: 'helpers/OUIA/ouia',
|
|
120
|
+
OUIAProps: 'helpers/OUIA/ouia',
|
|
121
|
+
getDefaultOUIAId: 'helpers/OUIA/ouia',
|
|
122
|
+
useOUIAId: 'helpers/OUIA/ouia',
|
|
123
|
+
handleArrows: 'helpers/KeyboardHandler',
|
|
124
|
+
setTabIndex: 'helpers/KeyboardHandler',
|
|
125
|
+
IconComponentProps: 'components/Icon',
|
|
126
|
+
TreeViewDataItem: 'components/TreeView',
|
|
127
|
+
clipboardCopyFunc: 'components/ClipboardCopy',
|
|
128
|
+
};
|
|
129
|
+
function populateCoreCache(roots, moduleOverrides) {
|
|
130
|
+
if (Object.values(COMPONENTS_CACHE).length === 0) {
|
|
131
|
+
Object.entries(__assign(__assign({}, MISMATCHED_CORE_MODULES), moduleOverrides)).forEach(function (_a) {
|
|
132
|
+
var importName = _a[0], pathPartial = _a[1];
|
|
133
|
+
var expectedPath = "@patternfly/react-core/dist/dynamic/".concat(pathPartial);
|
|
134
|
+
var exists = roots.map(function (root) { return glob.sync("".concat(root, "/node_modules/").concat(expectedPath).replace(/\/\//, '/')); }).flat().length > 0;
|
|
135
|
+
if (!exists) {
|
|
136
|
+
throw new Error("No module found at ".concat(expectedPath, " while trying to resolve module overrides! Please verify that ").concat(pathPartial, " matches the desired ").concat(importName, " component source file path."));
|
|
137
|
+
}
|
|
138
|
+
COMPONENTS_CACHE[importName] = expectedPath;
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
var createPfReactTransform = function (roots, moduleOverrides) {
|
|
143
|
+
if (roots === void 0) { roots = []; }
|
|
144
|
+
if (moduleOverrides === void 0) { moduleOverrides = {}; }
|
|
145
|
+
var internalRoots = __spreadArray([defaultRoot], roots, true);
|
|
146
|
+
populateCoreCache(internalRoots, moduleOverrides);
|
|
147
|
+
return [
|
|
148
|
+
'transform-imports',
|
|
149
|
+
{
|
|
150
|
+
'@patternfly/react-core': {
|
|
151
|
+
transform: function (importName) { return findPfRoots(internalRoots, importName); },
|
|
152
|
+
preventFullImport: false,
|
|
153
|
+
skipDefaultConversion: true,
|
|
154
|
+
},
|
|
155
|
+
'@patternfly/react-icons': {
|
|
156
|
+
transform: function (importName) { return findIconInRoots(internalRoots, importName); },
|
|
157
|
+
preventFullImport: true,
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
];
|
|
161
|
+
};
|
|
162
|
+
exports.default = createPfReactTransform;
|
|
163
|
+
module.exports = createPfReactTransform;
|
|
164
|
+
//# sourceMappingURL=babel-transform-imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"babel-transform-imports.js","sourceRoot":"","sources":["src/babel-transform-imports.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA6B;AAC7B,IAAM,WAAW,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAElC,IAAM,WAAW,GAAG,SAAS,CAAC;AAC9B,IAAM,aAAa,GAAG,aAAa,CAAC;AACpC,IAAM,cAAc,GAAG,YAAY,CAAC;AAEpC,IAAM,UAAU,GAAmC;IACjD,eAAe,EAAE,kBAAkB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AAY,CAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAtE,CAAsE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;YAC7H,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CACb,6BAAsB,YAAY,2EAAiE,WAAW,kCAAwB,UAAU,iCAA8B,CAC/K,CAAC;aACH;YAED,gBAAgB,CAAC,UAAU,CAAC,GAAG,YAAY,CAAC;QAC9C,CAAC,CAAC,CAAC;KACJ;AACH,CAAC;AAED,IAAM,sBAAsB,GAAG,UAAC,KAAU,EAAE,eAAsD;IAAlE,sBAAA,EAAA,UAAU;IAAE,gCAAA,EAAA,oBAAsD;IAChG,IAAM,aAAa,kBAAI,WAAW,GAAK,KAAK,OAAC,CAAC;IAC9C,iBAAiB,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;IAClD,OAAO;QACL,mBAAmB;QACnB;YACE,wBAAwB,EAAE;gBACxB,SAAS,EAAE,UAAC,UAAkB,IAAK,OAAA,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC,EAAtC,CAAsC;gBACzE,iBAAiB,EAAE,KAAK;gBACxB,qBAAqB,EAAE,IAAI;aAC5B;YACD,yBAAyB,EAAE;gBACzB,SAAS,EAAE,UAAC,UAAkB,IAAK,OAAA,eAAe,CAAC,aAAa,EAAE,UAAU,CAAC,EAA1C,CAA0C;gBAC7E,iBAAiB,EAAE,IAAI;aACxB;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,sBAAsB,CAAC;AACtC,MAAM,CAAC,OAAO,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Request as ExpressRequest, Response } from 'express';
|
|
3
|
+
import type * as http from 'http';
|
|
4
|
+
export type Entitlement = {
|
|
5
|
+
is_entitled?: boolean;
|
|
6
|
+
is_trial?: boolean;
|
|
7
|
+
};
|
|
8
|
+
declare function cookieTransform(proxyReq: http.ClientRequest, req: ExpressRequest, _res: Response, { entitlements, user, internal, identity: customIdentity, }: {
|
|
9
|
+
entitlements?: {
|
|
10
|
+
[sku: string]: Entitlement;
|
|
11
|
+
};
|
|
12
|
+
user: any;
|
|
13
|
+
internal: any;
|
|
14
|
+
identity: any;
|
|
15
|
+
}): void;
|
|
16
|
+
export default cookieTransform;
|
package/cookieTransform.js
CHANGED
|
@@ -1,55 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
migrations: { is_entitled: true },
|
|
11
|
-
ansible: { is_entitled: true },
|
|
12
|
-
cost_management: { is_entitled: true },
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function cookieTransform(proxyReq, req, _res, { entitlements = defaultEntitlements, user, internal, identity: customIdentity }) {
|
|
16
|
-
const { cookie, authorization } = req.headers;
|
|
17
|
-
const match = cookie?.match(/cs_jwt=([^;]+)/) || authorization?.match(/^Bearer (.*)$/);
|
|
18
|
-
|
|
19
|
-
if (match) {
|
|
20
|
-
const cs_jwt = match[1];
|
|
21
|
-
const { payload } = jws.decode(cs_jwt);
|
|
22
|
-
|
|
23
|
-
const identity = {
|
|
24
|
-
entitlements,
|
|
25
|
-
identity: {
|
|
26
|
-
type: 'User',
|
|
27
|
-
auth_type: 'basic-auth',
|
|
28
|
-
account_number: payload.account_number + '',
|
|
29
|
-
org_id: payload.org_id,
|
|
30
|
-
...customIdentity,
|
|
31
|
-
user: {
|
|
32
|
-
username: payload.username,
|
|
33
|
-
email: payload.email,
|
|
34
|
-
first_name: payload.first_name,
|
|
35
|
-
last_name: payload.last_name,
|
|
36
|
-
is_active: true,
|
|
37
|
-
is_org_admin: payload.is_org_admin,
|
|
38
|
-
is_internal: payload.is_internal,
|
|
39
|
-
locale: 'en-US',
|
|
40
|
-
user_id: payload.account_id + '',
|
|
41
|
-
...user,
|
|
42
|
-
},
|
|
43
|
-
internal: {
|
|
44
|
-
org_id: payload.org_id,
|
|
45
|
-
auth_time: payload.auth_time,
|
|
46
|
-
...internal,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
49
10
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var jws_1 = __importDefault(require("jws"));
|
|
18
|
+
var defaultEntitlements = {
|
|
19
|
+
insights: { is_entitled: true },
|
|
20
|
+
smart_management: { is_entitled: true },
|
|
21
|
+
openshift: { is_entitled: true },
|
|
22
|
+
hybrid: { is_entitled: true },
|
|
23
|
+
migrations: { is_entitled: true },
|
|
24
|
+
ansible: { is_entitled: true },
|
|
25
|
+
cost_management: { is_entitled: true },
|
|
26
|
+
};
|
|
27
|
+
function cookieTransform(proxyReq, req, _res, _a) {
|
|
28
|
+
var _b = _a.entitlements, entitlements = _b === void 0 ? defaultEntitlements : _b, user = _a.user, internal = _a.internal, customIdentity = _a.identity;
|
|
29
|
+
var _c = req.headers, cookie = _c.cookie, authorization = _c.authorization;
|
|
30
|
+
var match = (cookie === null || cookie === void 0 ? void 0 : cookie.match(/cs_jwt=([^;]+)/)) || (authorization === null || authorization === void 0 ? void 0 : authorization.match(/^Bearer (.*)$/));
|
|
31
|
+
if (match) {
|
|
32
|
+
var cs_jwt = match[1];
|
|
33
|
+
var payload = jws_1.default.decode(cs_jwt).payload;
|
|
34
|
+
var identity = {
|
|
35
|
+
entitlements: entitlements,
|
|
36
|
+
identity: __assign(__assign({ type: 'User', auth_type: 'basic-auth', account_number: payload.account_number + '', org_id: payload.org_id }, customIdentity), { user: __assign({ username: payload.username, email: payload.email, first_name: payload.first_name, last_name: payload.last_name, is_active: true, is_org_admin: payload.is_org_admin, is_internal: payload.is_internal, locale: 'en-US', user_id: payload.account_id + '' }, user), internal: __assign({ org_id: payload.org_id, auth_time: payload.auth_time }, internal) }),
|
|
37
|
+
};
|
|
38
|
+
var identityB64 = Buffer.from(JSON.stringify(identity), 'utf8').toString('base64');
|
|
39
|
+
proxyReq.setHeader('x-rh-identity', identityB64);
|
|
40
|
+
}
|
|
53
41
|
}
|
|
54
|
-
|
|
42
|
+
exports.default = cookieTransform;
|
|
55
43
|
module.exports = cookieTransform;
|
|
44
|
+
//# sourceMappingURL=cookieTransform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookieTransform.js","sourceRoot":"","sources":["src/cookieTransform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,4CAAsB;AAOtB,IAAM,mBAAmB,GAAmC;IAC1D,QAAQ,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;IAC/B,gBAAgB,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;IACvC,SAAS,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;IAChC,MAAM,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;IAC7B,UAAU,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;IACjC,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;IAC9B,eAAe,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE;CACvC,CAAC;AAEF,SAAS,eAAe,CACtB,QAA4B,EAC5B,GAAmB,EACnB,IAAc,E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AAC,SAAS,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACrF,QAAQ,CAAC,SAAS,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;KAClD;AACH,CAAC;AAED,kBAAe,eAAe,CAAC;AAC/B,MAAM,CAAC,OAAO,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DynamicRemotePluginOptions, PluginRuntimeMetadata } from '@openshift/dynamic-plugin-sdk-webpack';
|
|
2
|
+
import { Compiler } from 'webpack';
|
|
3
|
+
export type ExtensionsMapperOptions = {
|
|
4
|
+
pluginManifestFile?: string;
|
|
5
|
+
remoteEntryFile?: string;
|
|
6
|
+
remoteEntryCallback?: string;
|
|
7
|
+
};
|
|
8
|
+
declare class ExtensionsMapper {
|
|
9
|
+
options: Required<ExtensionsMapperOptions>;
|
|
10
|
+
plugin: Partial<DynamicRemotePluginOptions & PluginRuntimeMetadata>;
|
|
11
|
+
constructor(plugin: DynamicRemotePluginOptions & PluginRuntimeMetadata, options: ExtensionsMapperOptions);
|
|
12
|
+
apply(compiler: Compiler): void;
|
|
13
|
+
}
|
|
14
|
+
export default ExtensionsMapper;
|
package/extension-mapper.js
CHANGED
|
@@ -1,77 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
this.plugin = plugin;
|
|
10
|
-
this.options = {
|
|
11
|
-
remoteEntryCallback: 'window.loadPluginEntry',
|
|
12
|
-
remoteEntryFile: 'plugin-entry.js',
|
|
13
|
-
pluginManifestFile: 'plugin-manifest.json',
|
|
14
|
-
...options,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
apply(compiler) {
|
|
19
|
-
compiler.hooks.thisCompilation.tap(ExtensionsMapper.name, (compilation) => {
|
|
20
|
-
// Generate extensions manifest
|
|
21
|
-
compilation.hooks.processAssets.tap(
|
|
22
|
-
{
|
|
23
|
-
name: ExtensionsMapper.name,
|
|
24
|
-
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
25
|
-
},
|
|
26
|
-
() => {
|
|
27
|
-
compilation.emitAsset(
|
|
28
|
-
this.options.pluginManifestFile,
|
|
29
|
-
new webpack.sources.RawSource(
|
|
30
|
-
Buffer.from(
|
|
31
|
-
JSON.stringify(
|
|
32
|
-
{
|
|
33
|
-
version: '0.0.0',
|
|
34
|
-
description: '',
|
|
35
|
-
displayName: '',
|
|
36
|
-
dependencies: {},
|
|
37
|
-
disableStaticPlugins: {},
|
|
38
|
-
...this.plugin,
|
|
39
|
-
},
|
|
40
|
-
null,
|
|
41
|
-
2
|
|
42
|
-
)
|
|
43
|
-
)
|
|
44
|
-
)
|
|
45
|
-
);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
46
8
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (fromIndex < 0) {
|
|
62
|
-
const error = new webpack.WebpackError(`Missing call to ${this.options.remoteEntryCallback}`);
|
|
63
|
-
error.file = this.options.remoteEntryFile;
|
|
64
|
-
compilation.errors.push(error);
|
|
65
|
-
} else {
|
|
66
|
-
newSource.insert(fromIndex + this.options.remoteEntryCallback.length + 1, `'${this.plugin.name}@${this.plugin.version}', `);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return newSource;
|
|
70
|
-
});
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var webpack_1 = __importDefault(require("webpack"));
|
|
18
|
+
var ExtensionsMapper = (function () {
|
|
19
|
+
function ExtensionsMapper(plugin, options) {
|
|
20
|
+
if (!plugin) {
|
|
21
|
+
throw new Error('Missing plugin config!');
|
|
71
22
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
23
|
+
this.plugin = plugin;
|
|
24
|
+
this.options = __assign({ remoteEntryCallback: 'window.loadPluginEntry', remoteEntryFile: 'plugin-entry.js', pluginManifestFile: 'plugin-manifest.json' }, options);
|
|
25
|
+
}
|
|
26
|
+
ExtensionsMapper.prototype.apply = function (compiler) {
|
|
27
|
+
var _this = this;
|
|
28
|
+
compiler.hooks.thisCompilation.tap(ExtensionsMapper.name, function (compilation) {
|
|
29
|
+
compilation.hooks.processAssets.tap({
|
|
30
|
+
name: ExtensionsMapper.name,
|
|
31
|
+
stage: webpack_1.default.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
|
|
32
|
+
}, function () {
|
|
33
|
+
compilation.emitAsset(_this.options.pluginManifestFile, new webpack_1.default.sources.RawSource(Buffer.from(JSON.stringify(__assign({ version: '0.0.0', description: '', displayName: '', dependencies: {}, disableStaticPlugins: {} }, _this.plugin), null, 2))));
|
|
34
|
+
});
|
|
35
|
+
compilation.hooks.processAssets.tap({
|
|
36
|
+
name: ExtensionsMapper.name,
|
|
37
|
+
stage: webpack_1.default.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
|
|
38
|
+
}, function () {
|
|
39
|
+
compilation.updateAsset(_this.options.remoteEntryFile, function (source) {
|
|
40
|
+
var newSource = new webpack_1.default.sources.ReplaceSource(source);
|
|
41
|
+
var fromIndex = source.source().toString().indexOf("".concat(_this.options.remoteEntryCallback, "("));
|
|
42
|
+
if (fromIndex < 0) {
|
|
43
|
+
var error = new webpack_1.default.WebpackError("Missing call to ".concat(_this.options.remoteEntryCallback));
|
|
44
|
+
error.file = _this.options.remoteEntryFile;
|
|
45
|
+
compilation.errors.push(error);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
newSource.insert(fromIndex + _this.options.remoteEntryCallback.length + 1, "'".concat(_this.plugin.name, "@").concat(_this.plugin.version, "', "));
|
|
49
|
+
}
|
|
50
|
+
return newSource;
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
return ExtensionsMapper;
|
|
56
|
+
}());
|
|
57
|
+
exports.default = ExtensionsMapper;
|
|
58
|
+
//# sourceMappingURL=extension-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension-mapper.js","sourceRoot":"","sources":["src/extension-mapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,oDAA4C;AAY5C;IAGE,0BAAY,MAA0D,EAAE,OAAgC;QACtG,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,cACV,mBAAmB,EAAE,wBAAwB,EAC7C,eAAe,EAAE,iBAAiB,EAClC,kBAAkB,EAAE,sBAAsB,IACvC,OAAO,CACX,CAAC;IACJ,CAAC;IAED,gCAAK,GAAL,UAAM,QAAkB;QAAxB,iBAwDC;QAvDC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,UAAC,WAAW;YAEpE,WAAW,CAAC,KAA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C,IAAI,CAAC,KAAK,CAAC,CAAC;qBAChC;yBAAM;wBACL,SAAS,CAAC,MAAM,CAAC,SAAS,GAAG,KAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,WAAI,KAAI,CAAC,MAAM,CAAC,IAAI,cAAI,KAAI,CAAC,MAAM,CAAC,OAAO,QAAK,CAAC,CAAC;qBAC7H;oBAED,OAAO,SAAS,CAAC;gBACnB,CAAC,CAAC,CAAC;YACL,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACH,uBAAC;AAAD,CAAC,AA1ED,IA0EC;AAED,kBAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/extensions-plugin.js
CHANGED
|
@@ -1,54 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.plugin = plugin;
|
|
12
|
-
this.fedMod = {
|
|
13
|
-
moduleName: 'plugin-entry',
|
|
14
|
-
libName: 'window.loadPluginEntry',
|
|
15
|
-
useFileHash: false,
|
|
16
|
-
libType: 'jsonp',
|
|
17
|
-
...fedMod,
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
18
10
|
};
|
|
19
|
-
this
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
var path_1 = require("path");
|
|
27
|
+
var federated_modules_1 = __importDefault(require("./federated-modules"));
|
|
28
|
+
var extension_mapper_1 = __importDefault(require("./extension-mapper"));
|
|
29
|
+
var ExtensionsPlugin = (function () {
|
|
30
|
+
function ExtensionsPlugin(plugin, fedMod, options) {
|
|
31
|
+
if (!plugin) {
|
|
32
|
+
throw new Error('Missing plugin config!');
|
|
33
|
+
}
|
|
34
|
+
this.plugin = plugin;
|
|
35
|
+
this.fedMod = __assign({ moduleName: 'plugin-entry', libName: 'window.loadPluginEntry', useFileHash: false, libType: 'jsonp' }, fedMod);
|
|
36
|
+
this.options = __assign({ remoteEntryCallback: 'window.loadPluginEntry', remoteEntryFile: "".concat(this.fedMod.moduleName, ".js"), pluginManifestFile: 'plugin-manifest.json' }, options);
|
|
37
|
+
}
|
|
38
|
+
ExtensionsPlugin.prototype.apply = function (compiler) {
|
|
39
|
+
var root = this.fedMod.root || compiler.context;
|
|
40
|
+
var _a = require((0, path_1.resolve)(root, './package.json')) || {}, insights = _a.insights, version = _a.version, description = _a.description;
|
|
41
|
+
(0, federated_modules_1.default)(__assign(__assign({}, this.fedMod), { root: root })).apply(compiler);
|
|
42
|
+
new extension_mapper_1.default(__assign(__assign({}, this.plugin), { name: this.plugin.name || (insights && insights.appname), version: this.plugin.version || version || '0.0.0', displayName: this.plugin.displayName || '', description: this.plugin.description || description || '', dependencies: __assign({}, (this.plugin.dependencies || {})), disableStaticPlugins: __spreadArray([], (this.plugin.disableStaticPlugins || []), true), extensions: __spreadArray([], (this.plugin.extensions || []), true) }), this.options).apply(compiler);
|
|
24
43
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
apply(compiler) {
|
|
28
|
-
const root = this.fedMod.root || compiler.context;
|
|
29
|
-
const { insights, version, description } = require(resolve(root, './package.json')) || {};
|
|
30
|
-
|
|
31
|
-
// create federation module
|
|
32
|
-
fedModule({
|
|
33
|
-
...this.fedMod,
|
|
34
|
-
root,
|
|
35
|
-
}).apply(compiler);
|
|
36
|
-
|
|
37
|
-
// generate plugin manifest and update plugin-entry file
|
|
38
|
-
new ExtensionsMapper(
|
|
39
|
-
{
|
|
40
|
-
...this.plugin,
|
|
41
|
-
name: this.plugin.name || (insights && insights.appname),
|
|
42
|
-
version: this.plugin.version || version || '0.0.0',
|
|
43
|
-
displayName: this.plugin.displayName || '',
|
|
44
|
-
description: this.plugin.description || description || '',
|
|
45
|
-
dependencies: { ...(this.plugin.dependencies || {}) },
|
|
46
|
-
disableStaticPlugins: [...(this.plugin.disableStaticPlugins || [])],
|
|
47
|
-
extensions: [...(this.plugin.extensions || [])],
|
|
48
|
-
},
|
|
49
|
-
this.options
|
|
50
|
-
).apply(compiler);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
44
|
+
return ExtensionsPlugin;
|
|
45
|
+
}());
|
|
54
46
|
module.exports = ExtensionsPlugin;
|
|
47
|
+
//# sourceMappingURL=extensions-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extensions-plugin.js","sourceRoot":"","sources":["src/extensions-plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA+B;AAC/B,0EAA4C;AAC5C,wEAAkD;AAqBlD;IAIE,0BAAY,MAAW,EAAE,MAAuB,EAAE,OAAyC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AAY,IAAI,EAAE,CAAC,GACnD,oBAAoB,oBAAM,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,IAAI,EAAE,CAAC,SAClE,UAAU,oBAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,YAEhD,IAAI,CAAC,OAAO,CACb,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IACpB,CAAC;IACH,uBAAC;AAAD,CAAC,AAlDD,IAkDC;AAED,MAAM,CAAC,OAAO,GAAG,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DynamicRemotePlugin, EncodedExtension, PluginBuildMetadata, WebpackSharedConfig } from '@openshift/dynamic-plugin-sdk-webpack';
|
|
2
|
+
export type FederatedModulesConfig = {
|
|
3
|
+
root: string;
|
|
4
|
+
exposes?: {
|
|
5
|
+
[module: string]: string;
|
|
6
|
+
};
|
|
7
|
+
shared?: {
|
|
8
|
+
[module: string]: WebpackSharedConfig;
|
|
9
|
+
}[];
|
|
10
|
+
debug?: boolean;
|
|
11
|
+
moduleName?: string;
|
|
12
|
+
useFileHash?: boolean;
|
|
13
|
+
separateRuntime?: boolean;
|
|
14
|
+
exclude?: string[];
|
|
15
|
+
eager?: boolean;
|
|
16
|
+
pluginMetadata?: PluginBuildMetadata;
|
|
17
|
+
extensions?: EncodedExtension[];
|
|
18
|
+
};
|
|
19
|
+
declare const federatedModules: ({ root, exposes, shared, debug, moduleName, useFileHash, separateRuntime, exclude, eager, pluginMetadata, extensions, }: FederatedModulesConfig) => DynamicRemotePlugin;
|
|
20
|
+
export default federatedModules;
|