@rockcarver/frodo-lib 0.12.2-8 → 0.12.2
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/CHANGELOG.md +33 -1
- package/cjs/index.js +3 -3
- package/cjs/index.js.map +1 -1
- package/cjs/ops/AdminOps.js +63 -34
- package/cjs/ops/AdminOps.js.map +1 -1
- package/cjs/ops/IdmOps.test.js.map +1 -0
- package/cjs/ops/IdpOps.js +75 -74
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/IdpOps.test.js.map +1 -0
- package/cjs/ops/JourneyOps.js +5 -2
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/{SamlOps.js → Saml2Ops.js} +75 -73
- package/cjs/ops/Saml2Ops.js.map +1 -0
- package/cjs/ops/Saml2Ops.test.js.map +1 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +9 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/IdmConfigApi/getAllConfigEntities/entities.json +490 -0
- package/esm/index.mjs +1 -1
- package/esm/ops/AdminOps.mjs +32 -29
- package/esm/ops/IdmOps.test.mjs +43 -0
- package/esm/ops/IdpOps.mjs +30 -29
- package/esm/ops/IdpOps.test.mjs +63 -0
- package/esm/ops/JourneyOps.mjs +5 -2
- package/esm/ops/{SamlOps.mjs → Saml2Ops.mjs} +24 -22
- package/esm/ops/Saml2Ops.test.mjs +89 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +7 -0
- package/esm/test/mocks/IdmConfigApi/getAllConfigEntities/entities.json +490 -0
- package/package.json +2 -2
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/ops/AdminOps.d.ts +1 -0
- package/types/ops/AdminOps.d.ts.map +1 -1
- package/types/ops/IdpOps.d.ts +12 -12
- package/types/ops/IdpOps.d.ts.map +1 -1
- package/types/ops/JourneyOps.d.ts.map +1 -1
- package/types/ops/{SamlOps.d.ts → Saml2Ops.d.ts} +10 -10
- package/types/ops/Saml2Ops.d.ts.map +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
- package/cjs/ops/SamlOps.js.map +0 -1
- package/types/ops/SamlOps.d.ts.map +0 -1
package/cjs/ops/IdpOps.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
6
|
+
exports.exportSocialProviderToFile = exportSocialProviderToFile;
|
|
7
|
+
exports.exportSocialProvidersToFile = exportSocialProvidersToFile;
|
|
8
|
+
exports.exportSocialProvidersToFiles = exportSocialProvidersToFiles;
|
|
9
|
+
exports.getSocialProvider = getSocialProvider;
|
|
10
|
+
exports.importFirstSocialProviderFromFile = importFirstSocialProviderFromFile;
|
|
11
|
+
exports.importSocialProviderFromFile = importSocialProviderFromFile;
|
|
12
|
+
exports.importSocialProvidersFromFile = importSocialProvidersFromFile;
|
|
13
|
+
exports.importSocialProvidersFromFiles = importSocialProvidersFromFiles;
|
|
14
|
+
exports.listSocialProviders = listSocialProviders;
|
|
15
15
|
|
|
16
16
|
var _fs = _interopRequireDefault(require("fs"));
|
|
17
17
|
|
|
@@ -44,63 +44,64 @@ function getFileDataTemplate() {
|
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
46
|
|
|
47
|
-
function
|
|
48
|
-
return
|
|
47
|
+
function listSocialProviders() {
|
|
48
|
+
return _listSocialProviders.apply(this, arguments);
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
51
51
|
* Get social identity provider by id
|
|
52
|
-
* @param {String}
|
|
52
|
+
* @param {String} providerId social identity provider id/name
|
|
53
53
|
* @returns {Promise} a promise that resolves a social identity provider object
|
|
54
54
|
*/
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
function _listSocialProviders() {
|
|
58
|
+
_listSocialProviders = _asyncToGenerator(function* () {
|
|
59
|
+
try {
|
|
60
|
+
var providers = yield (0, _SocialIdentityProvidersApi.getSocialIdentityProviders)();
|
|
61
|
+
providers.result.sort((a, b) => a._id.localeCompare(b._id));
|
|
62
|
+
providers.result.forEach(socialIdentityProvider => {
|
|
62
63
|
(0, _Console.printMessage)("".concat(socialIdentityProvider._id), 'data');
|
|
63
64
|
});
|
|
64
|
-
}
|
|
65
|
-
(0, _Console.printMessage)("
|
|
65
|
+
} catch (err) {
|
|
66
|
+
(0, _Console.printMessage)("listSocialProviders ERROR: ".concat(err.message), 'error');
|
|
66
67
|
(0, _Console.printMessage)(err, 'error');
|
|
67
|
-
}
|
|
68
|
+
}
|
|
68
69
|
});
|
|
69
|
-
return
|
|
70
|
+
return _listSocialProviders.apply(this, arguments);
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
function
|
|
73
|
-
return
|
|
73
|
+
function getSocialProvider(_x) {
|
|
74
|
+
return _getSocialProvider.apply(this, arguments);
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
76
77
|
* Export provider by id
|
|
77
|
-
* @param {String}
|
|
78
|
+
* @param {String} providerId provider id/name
|
|
78
79
|
* @param {String} file optional export file name
|
|
79
80
|
*/
|
|
80
81
|
|
|
81
82
|
|
|
82
|
-
function
|
|
83
|
-
|
|
83
|
+
function _getSocialProvider() {
|
|
84
|
+
_getSocialProvider = _asyncToGenerator(function* (providerId) {
|
|
84
85
|
return (0, _SocialIdentityProvidersApi.getSocialIdentityProviders)().then(response => {
|
|
85
|
-
var foundProviders = response.result.filter(provider => provider._id ===
|
|
86
|
+
var foundProviders = response.result.filter(provider => provider._id === providerId);
|
|
86
87
|
|
|
87
88
|
switch (foundProviders.length) {
|
|
88
89
|
case 1:
|
|
89
90
|
return foundProviders[0];
|
|
90
91
|
|
|
91
92
|
case 0:
|
|
92
|
-
throw new Error("Provider '".concat(
|
|
93
|
+
throw new Error("Provider '".concat(providerId, "' not found"));
|
|
93
94
|
|
|
94
95
|
default:
|
|
95
|
-
throw new Error("".concat(foundProviders.length, " providers '").concat(
|
|
96
|
+
throw new Error("".concat(foundProviders.length, " providers '").concat(providerId, "' found"));
|
|
96
97
|
}
|
|
97
98
|
});
|
|
98
99
|
});
|
|
99
|
-
return
|
|
100
|
+
return _getSocialProvider.apply(this, arguments);
|
|
100
101
|
}
|
|
101
102
|
|
|
102
|
-
function
|
|
103
|
-
return
|
|
103
|
+
function exportSocialProviderToFile(_x2) {
|
|
104
|
+
return _exportSocialProviderToFile.apply(this, arguments);
|
|
104
105
|
}
|
|
105
106
|
/**
|
|
106
107
|
* Export all providers
|
|
@@ -108,19 +109,19 @@ function exportProvider(_x2) {
|
|
|
108
109
|
*/
|
|
109
110
|
|
|
110
111
|
|
|
111
|
-
function
|
|
112
|
-
|
|
112
|
+
function _exportSocialProviderToFile() {
|
|
113
|
+
_exportSocialProviderToFile = _asyncToGenerator(function* (providerId) {
|
|
113
114
|
var file = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
114
115
|
var fileName = file;
|
|
115
116
|
|
|
116
117
|
if (!fileName) {
|
|
117
|
-
fileName = (0, _ExportImportUtils.getTypedFilename)(
|
|
118
|
+
fileName = (0, _ExportImportUtils.getTypedFilename)(providerId, 'idp');
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
(0, _Console.createProgressIndicator)(1, "Exporting ".concat(
|
|
121
|
+
(0, _Console.createProgressIndicator)(1, "Exporting ".concat(providerId));
|
|
121
122
|
|
|
122
123
|
try {
|
|
123
|
-
var idpData = yield
|
|
124
|
+
var idpData = yield getSocialProvider(providerId);
|
|
124
125
|
(0, _Console.updateProgressIndicator)("Writing file ".concat(fileName));
|
|
125
126
|
var fileData = getFileDataTemplate();
|
|
126
127
|
fileData.idp[idpData._id] = idpData;
|
|
@@ -132,25 +133,25 @@ function _exportProvider() {
|
|
|
132
133
|
}
|
|
133
134
|
|
|
134
135
|
(0, _ExportImportUtils.saveJsonToFile)(fileData, fileName);
|
|
135
|
-
(0, _Console.stopProgressIndicator)("Exported ".concat(
|
|
136
|
+
(0, _Console.stopProgressIndicator)("Exported ".concat(providerId['brightCyan'], " to ").concat(fileName['brightCyan'], "."));
|
|
136
137
|
} catch (err) {
|
|
137
138
|
(0, _Console.stopProgressIndicator)("".concat(err));
|
|
138
139
|
(0, _Console.printMessage)("".concat(err), 'error');
|
|
139
140
|
}
|
|
140
141
|
});
|
|
141
|
-
return
|
|
142
|
+
return _exportSocialProviderToFile.apply(this, arguments);
|
|
142
143
|
}
|
|
143
144
|
|
|
144
|
-
function
|
|
145
|
-
return
|
|
145
|
+
function exportSocialProvidersToFile(_x3) {
|
|
146
|
+
return _exportSocialProvidersToFile.apply(this, arguments);
|
|
146
147
|
}
|
|
147
148
|
/**
|
|
148
149
|
* Export all providers to individual files
|
|
149
150
|
*/
|
|
150
151
|
|
|
151
152
|
|
|
152
|
-
function
|
|
153
|
-
|
|
153
|
+
function _exportSocialProvidersToFile() {
|
|
154
|
+
_exportSocialProvidersToFile = _asyncToGenerator(function* (file) {
|
|
154
155
|
var fileName = file;
|
|
155
156
|
|
|
156
157
|
if (!fileName) {
|
|
@@ -176,21 +177,21 @@ function _exportProvidersToFile() {
|
|
|
176
177
|
(0, _ExportImportUtils.saveJsonToFile)(fileData, fileName);
|
|
177
178
|
(0, _Console.stopProgressIndicator)("".concat(allIdpsData.length, " providers exported to ").concat(fileName, "."));
|
|
178
179
|
});
|
|
179
|
-
return
|
|
180
|
+
return _exportSocialProvidersToFile.apply(this, arguments);
|
|
180
181
|
}
|
|
181
182
|
|
|
182
|
-
function
|
|
183
|
-
return
|
|
183
|
+
function exportSocialProvidersToFiles() {
|
|
184
|
+
return _exportSocialProvidersToFiles.apply(this, arguments);
|
|
184
185
|
}
|
|
185
186
|
/**
|
|
186
187
|
* Import provider by id/name
|
|
187
|
-
* @param {String}
|
|
188
|
+
* @param {String} providerId provider id/name
|
|
188
189
|
* @param {String} file import file name
|
|
189
190
|
*/
|
|
190
191
|
|
|
191
192
|
|
|
192
|
-
function
|
|
193
|
-
|
|
193
|
+
function _exportSocialProvidersToFiles() {
|
|
194
|
+
_exportSocialProvidersToFiles = _asyncToGenerator(function* () {
|
|
194
195
|
var allIdpsData = yield (yield (0, _SocialIdentityProvidersApi.getSocialIdentityProviders)()).result; // printMessage(allIdpsData, 'data');
|
|
195
196
|
|
|
196
197
|
(0, _Console.createProgressIndicator)(allIdpsData.length, 'Exporting providers');
|
|
@@ -213,11 +214,11 @@ function _exportProvidersToFiles() {
|
|
|
213
214
|
|
|
214
215
|
(0, _Console.stopProgressIndicator)("".concat(allIdpsData.length, " providers exported."));
|
|
215
216
|
});
|
|
216
|
-
return
|
|
217
|
+
return _exportSocialProvidersToFiles.apply(this, arguments);
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
function
|
|
220
|
-
return
|
|
220
|
+
function importSocialProviderFromFile(_x4, _x5) {
|
|
221
|
+
return _importSocialProviderFromFile.apply(this, arguments);
|
|
221
222
|
}
|
|
222
223
|
/**
|
|
223
224
|
* Import first provider from file
|
|
@@ -225,8 +226,8 @@ function importProviderById(_x4, _x5) {
|
|
|
225
226
|
*/
|
|
226
227
|
|
|
227
228
|
|
|
228
|
-
function
|
|
229
|
-
|
|
229
|
+
function _importSocialProviderFromFile() {
|
|
230
|
+
_importSocialProviderFromFile = _asyncToGenerator(function* (providerId, file) {
|
|
230
231
|
_fs.default.readFile(file, 'utf8', /*#__PURE__*/function () {
|
|
231
232
|
var _ref = _asyncToGenerator(function* (err, data) {
|
|
232
233
|
if (err) throw err;
|
|
@@ -238,7 +239,7 @@ function _importProviderById() {
|
|
|
238
239
|
|
|
239
240
|
var _loop = function* _loop(idpId) {
|
|
240
241
|
if ({}.hasOwnProperty.call(fileData.idp, idpId)) {
|
|
241
|
-
if (idpId ===
|
|
242
|
+
if (idpId === providerId) {
|
|
242
243
|
found = true;
|
|
243
244
|
(0, _Console.updateProgressIndicator)("Importing ".concat(fileData.idp[idpId]._id));
|
|
244
245
|
var scriptId = fileData.idp[idpId].transform;
|
|
@@ -251,10 +252,10 @@ function _importProviderById() {
|
|
|
251
252
|
}
|
|
252
253
|
|
|
253
254
|
(0, _SocialIdentityProvidersApi.putProviderByTypeAndId)(fileData.idp[idpId]._type._id, idpId, fileData.idp[idpId]).then(() => {
|
|
254
|
-
(0, _Console.stopProgressIndicator)("Successfully imported provider ".concat(
|
|
255
|
+
(0, _Console.stopProgressIndicator)("Successfully imported provider ".concat(providerId, "."));
|
|
255
256
|
}).catch(importProviderErr => {
|
|
256
257
|
(0, _Console.stopProgressIndicator)("Error importing provider ".concat(fileData.idp[idpId]._id));
|
|
257
|
-
(0, _Console.printMessage)("\nError importing provider ".concat(
|
|
258
|
+
(0, _Console.printMessage)("\nError importing provider ".concat(providerId), 'error');
|
|
258
259
|
(0, _Console.printMessage)(importProviderErr.response.data, 'error');
|
|
259
260
|
});
|
|
260
261
|
return "break";
|
|
@@ -269,7 +270,7 @@ function _importProviderById() {
|
|
|
269
270
|
}
|
|
270
271
|
|
|
271
272
|
if (!found) {
|
|
272
|
-
(0, _Console.stopProgressIndicator)("Provider ".concat(
|
|
273
|
+
(0, _Console.stopProgressIndicator)("Provider ".concat(providerId.brightCyan, " not found in ").concat(file.brightCyan, "!"));
|
|
273
274
|
}
|
|
274
275
|
} else {
|
|
275
276
|
(0, _Console.printMessage)('Import validation failed...', 'error');
|
|
@@ -281,11 +282,11 @@ function _importProviderById() {
|
|
|
281
282
|
};
|
|
282
283
|
}());
|
|
283
284
|
});
|
|
284
|
-
return
|
|
285
|
+
return _importSocialProviderFromFile.apply(this, arguments);
|
|
285
286
|
}
|
|
286
287
|
|
|
287
|
-
function
|
|
288
|
-
return
|
|
288
|
+
function importFirstSocialProviderFromFile(_x6) {
|
|
289
|
+
return _importFirstSocialProviderFromFile.apply(this, arguments);
|
|
289
290
|
}
|
|
290
291
|
/**
|
|
291
292
|
* Import all providers from file
|
|
@@ -293,8 +294,8 @@ function importFirstProvider(_x6) {
|
|
|
293
294
|
*/
|
|
294
295
|
|
|
295
296
|
|
|
296
|
-
function
|
|
297
|
-
|
|
297
|
+
function _importFirstSocialProviderFromFile() {
|
|
298
|
+
_importFirstSocialProviderFromFile = _asyncToGenerator(function* (file) {
|
|
298
299
|
_fs.default.readFile(file, 'utf8', /*#__PURE__*/function () {
|
|
299
300
|
var _ref2 = _asyncToGenerator(function* (err, data) {
|
|
300
301
|
if (err) throw err;
|
|
@@ -342,19 +343,19 @@ function _importFirstProvider() {
|
|
|
342
343
|
};
|
|
343
344
|
}());
|
|
344
345
|
});
|
|
345
|
-
return
|
|
346
|
+
return _importFirstSocialProviderFromFile.apply(this, arguments);
|
|
346
347
|
}
|
|
347
348
|
|
|
348
|
-
function
|
|
349
|
-
return
|
|
349
|
+
function importSocialProvidersFromFile(_x7) {
|
|
350
|
+
return _importSocialProvidersFromFile.apply(this, arguments);
|
|
350
351
|
}
|
|
351
352
|
/**
|
|
352
353
|
* Import providers from *.idp.json files in current working directory
|
|
353
354
|
*/
|
|
354
355
|
|
|
355
356
|
|
|
356
|
-
function
|
|
357
|
-
|
|
357
|
+
function _importSocialProvidersFromFile() {
|
|
358
|
+
_importSocialProvidersFromFile = _asyncToGenerator(function* (file) {
|
|
358
359
|
_fs.default.readFile(file, 'utf8', /*#__PURE__*/function () {
|
|
359
360
|
var _ref3 = _asyncToGenerator(function* (err, data) {
|
|
360
361
|
if (err) throw err;
|
|
@@ -394,15 +395,15 @@ function _importProvidersFromFile() {
|
|
|
394
395
|
};
|
|
395
396
|
}());
|
|
396
397
|
});
|
|
397
|
-
return
|
|
398
|
+
return _importSocialProvidersFromFile.apply(this, arguments);
|
|
398
399
|
}
|
|
399
400
|
|
|
400
|
-
function
|
|
401
|
-
return
|
|
401
|
+
function importSocialProvidersFromFiles() {
|
|
402
|
+
return _importSocialProvidersFromFiles.apply(this, arguments);
|
|
402
403
|
}
|
|
403
404
|
|
|
404
|
-
function
|
|
405
|
-
|
|
405
|
+
function _importSocialProvidersFromFiles() {
|
|
406
|
+
_importSocialProvidersFromFiles = _asyncToGenerator(function* () {
|
|
406
407
|
var names = _fs.default.readdirSync('.');
|
|
407
408
|
|
|
408
409
|
var jsonFiles = names.filter(name => name.toLowerCase().endsWith('.idp.json'));
|
|
@@ -437,6 +438,6 @@ function _importProvidersFromFiles() {
|
|
|
437
438
|
|
|
438
439
|
(0, _Console.stopProgressIndicator)("Finished importing ".concat(total, " provider(s) from ").concat(jsonFiles.length, " file(s)."));
|
|
439
440
|
});
|
|
440
|
-
return
|
|
441
|
+
return _importSocialProvidersFromFiles.apply(this, arguments);
|
|
441
442
|
}
|
|
442
443
|
//# sourceMappingURL=IdpOps.js.map
|
package/cjs/ops/IdpOps.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdpOps.js","names":["getFileDataTemplate","meta","script","idp","listProviders","getSocialIdentityProviders","then","response","result","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","printMessage","catch","err","message","getSocialIdentityProviderById","id","foundProviders","filter","provider","length","Error","exportProvider","file","fileName","getTypedFilename","createProgressIndicator","idpData","updateProgressIndicator","fileData","transform","scriptData","getScript","convertBase64TextToArray","saveJsonToFile","stopProgressIndicator","exportProvidersToFile","getRealmString","allIdpsData","exportProvidersToFiles","importProviderById","fs","readFile","data","JSON","parse","validateImport","found","idpId","hasOwnProperty","call","scriptId","convertTextArrayToBase64","createOrUpdateScript","putProviderByTypeAndId","_type","importProviderErr","brightCyan","importFirstProvider","importProvidersFromFile","Object","keys","name","importProvidersFromFiles","names","readdirSync","jsonFiles","toLowerCase","endsWith","total","readFileSync","count"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import fs from 'fs';\nimport {\n getSocialIdentityProviders,\n putProviderByTypeAndId,\n} from '../api/SocialIdentityProvidersApi';\nimport { getScript } from '../api/ScriptApi';\nimport { createOrUpdateScript } from './ScriptOps';\nimport {\n convertBase64TextToArray,\n convertTextArrayToBase64,\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n validateImport,\n} from './utils/ExportImportUtils';\nimport {\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from './utils/Console';\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n script: {},\n idp: {},\n };\n}\n\n/**\n * List providers\n */\nexport async function listProviders() {\n getSocialIdentityProviders()\n .then((response) => {\n response.result.sort((a, b) => a._id.localeCompare(b._id));\n response.result.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n })\n .catch((err) => {\n printMessage(`listProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n });\n}\n\n/**\n * Get social identity provider by id\n * @param {String} id social identity provider id/name\n * @returns {Promise} a promise that resolves a social identity provider object\n */\nexport async function getSocialIdentityProviderById(id) {\n return getSocialIdentityProviders().then((response) => {\n const foundProviders = response.result.filter(\n (provider) => provider._id === id\n );\n switch (foundProviders.length) {\n case 1:\n return foundProviders[0];\n case 0:\n throw new Error(`Provider '${id}' not found`);\n default:\n throw new Error(`${foundProviders.length} providers '${id}' found`);\n }\n });\n}\n\n/**\n * Export provider by id\n * @param {String} id provider id/name\n * @param {String} file optional export file name\n */\nexport async function exportProvider(id, file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(id, 'idp');\n }\n createProgressIndicator(1, `Exporting ${id}`);\n try {\n const idpData = await getSocialIdentityProviderById(id);\n updateProgressIndicator(`Writing file ${fileName}`);\n const fileData = getFileDataTemplate();\n fileData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[idpData.transform] = scriptData;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${id['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(`${err}`, 'error');\n }\n}\n\n/**\n * Export all providers\n * @param {String} file optional export file name\n */\nexport async function exportProvidersToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = getFileDataTemplate();\n const allIdpsData = (await getSocialIdentityProviders()).result;\n createProgressIndicator(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressIndicator(`Exporting provider ${idpData._id}`);\n fileData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n // eslint-disable-next-line no-await-in-loop\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[idpData.transform] = scriptData;\n }\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${allIdpsData.length} providers exported to ${fileName}.`\n );\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportProvidersToFiles() {\n const allIdpsData = await (await getSocialIdentityProviders()).result;\n // printMessage(allIdpsData, 'data');\n createProgressIndicator(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressIndicator(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = getFileDataTemplate();\n fileData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n // eslint-disable-next-line no-await-in-loop\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[idpData.transform] = scriptData;\n }\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${allIdpsData.length} providers exported.`);\n}\n\n/**\n * Import provider by id/name\n * @param {String} id provider id/name\n * @param {String} file import file name\n */\nexport async function importProviderById(id, file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(1, 'Importing provider...');\n let found = false;\n for (const idpId in fileData.idp) {\n if ({}.hasOwnProperty.call(fileData.idp, idpId)) {\n if (idpId === id) {\n found = true;\n updateProgressIndicator(`Importing ${fileData.idp[idpId]._id}`);\n const scriptId = fileData.idp[idpId].transform;\n const scriptData = fileData.script[scriptId];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n // eslint-disable-next-line no-await-in-loop\n await createOrUpdateScript(\n fileData.idp[idpId].transform,\n fileData.script[fileData.idp[idpId].transform]\n );\n }\n putProviderByTypeAndId(\n fileData.idp[idpId]._type._id,\n idpId,\n fileData.idp[idpId]\n )\n .then(() => {\n stopProgressIndicator(`Successfully imported provider ${id}.`);\n })\n .catch((importProviderErr) => {\n stopProgressIndicator(\n `Error importing provider ${fileData.idp[idpId]._id}`\n );\n printMessage(`\\nError importing provider ${id}`, 'error');\n printMessage(importProviderErr.response.data, 'error');\n });\n break;\n }\n }\n }\n if (!found) {\n stopProgressIndicator(\n `Provider ${id.brightCyan} not found in ${file.brightCyan}!`\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n */\nexport async function importFirstProvider(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(1, 'Importing provider...');\n for (const idpId in fileData.idp) {\n if ({}.hasOwnProperty.call(fileData.idp, idpId)) {\n updateProgressIndicator(`Importing ${fileData.idp[idpId]._id}`);\n const scriptId = fileData.idp[idpId].transform;\n const scriptData = fileData.script[scriptId];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n // eslint-disable-next-line no-await-in-loop\n await createOrUpdateScript(\n fileData.idp[idpId].transform,\n fileData.script[fileData.idp[idpId].transform]\n );\n }\n putProviderByTypeAndId(\n fileData.idp[idpId]._type._id,\n idpId,\n fileData.idp[idpId]\n ).then((result) => {\n if (result == null) {\n stopProgressIndicator(\n `Error importing provider ${fileData.idp[idpId]._id}`\n );\n printMessage(\n `Error importing provider ${fileData.idp[idpId]._id}`,\n 'error'\n );\n } else {\n stopProgressIndicator(\n `Successfully imported provider ${fileData.idp[idpId]._id}.`\n );\n }\n });\n break;\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all providers from file\n * @param {String} file import file name\n */\nexport async function importProvidersFromFile(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n Object.keys(fileData.idp).length,\n 'Importing providers...'\n );\n for (const idpId in fileData.idp) {\n if ({}.hasOwnProperty.call(fileData.idp, idpId)) {\n const scriptId = fileData.idp[idpId].transform;\n const scriptData = fileData.script[scriptId];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n // eslint-disable-next-line no-await-in-loop\n await createOrUpdateScript(\n fileData.idp[idpId].transform,\n fileData.script[fileData.idp[idpId].transform]\n );\n }\n // eslint-disable-next-line no-await-in-loop\n const result = await putProviderByTypeAndId(\n fileData.idp[idpId]._type._id,\n idpId,\n fileData.idp[idpId]\n );\n if (!result) {\n updateProgressIndicator(\n `Successfully imported ${fileData.idp[idpId].name}`\n );\n }\n }\n }\n stopProgressIndicator(`Providers imported.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressIndicator(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n const count = Object.keys(fileData.idp).length;\n total += count;\n for (const idpId in fileData.idp) {\n if ({}.hasOwnProperty.call(fileData.idp, idpId)) {\n // eslint-disable-next-line no-await-in-loop\n const result = await putProviderByTypeAndId(\n fileData.idp[idpId]._type._id,\n idpId,\n fileData.idp[idpId]\n );\n if (result == null) {\n printMessage(\n `Error importing ${count} providers from ${file}`,\n 'error'\n );\n }\n }\n }\n updateProgressIndicator(`Imported ${count} provider(s) from ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AAIA;;AACA;;AACA;;AAQA;;;;;;;;AAOA;AACA,SAASA,mBAAT,GAA+B;EAC7B,OAAO;IACLC,IAAI,EAAE,EADD;IAELC,MAAM,EAAE,EAFH;IAGLC,GAAG,EAAE;EAHA,CAAP;AAKD;AAED;AACA;AACA;;;SACsBC,a;;;AActB;AACA;AACA;AACA;AACA;;;;qCAlBO,aAA+B;IACpC,IAAAC,sDAAA,IACGC,IADH,CACSC,QAAD,IAAc;MAClBA,QAAQ,CAACC,MAAT,CAAgBC,IAAhB,CAAqB,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAACE,GAAF,CAAMC,aAAN,CAAoBF,CAAC,CAACC,GAAtB,CAA/B;MACAL,QAAQ,CAACC,MAAT,CAAgBM,OAAhB,CAAyBC,sBAAD,IAA4B;QAClD,IAAAC,qBAAA,YAAgBD,sBAAsB,CAACH,GAAvC,GAA8C,MAA9C;MACD,CAFD;IAGD,CANH,EAOGK,KAPH,CAOUC,GAAD,IAAS;MACd,IAAAF,qBAAA,iCAAqCE,GAAG,CAACC,OAAzC,GAAoD,OAApD;MACA,IAAAH,qBAAA,EAAaE,GAAb,EAAkB,OAAlB;IACD,CAVH;EAWD,C;;;;SAOqBE,6B;;;AAgBtB;AACA;A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,cAAH,CAAkBC,IAAlB,CAAuBrB,QAAQ,CAAC/B,GAAhC,EAAqCkD,KAArC,CAAJ,EAAiD;YAC/C;YACA,IAAM7C,MAAM,SAAS,IAAAmD,kDAAA,EACnBzB,QAAQ,CAAC/B,GAAT,CAAakD,KAAb,EAAoBO,KAApB,CAA0BhD,GADP,EAEnByC,KAFmB,EAGnBnB,QAAQ,CAAC/B,GAAT,CAAakD,KAAb,CAHmB,CAArB;;YAKA,IAAI7C,MAAM,IAAI,IAAd,EAAoB;cAClB,IAAAQ,qBAAA,4BACqB4D,KADrB,6BAC6ChD,IAD7C,GAEE,OAFF;YAID;UACF;QACF;;QACD,IAAAK,gCAAA,qBAAoC2C,KAApC,+BAA8DhD,IAA9D;MACD,CApBD,MAoBO;QACL,IAAAZ,qBAAA,0BAA8BY,IAA9B,eAA8C,OAA9C;MACD;IACF;;IACD,IAAAY,8BAAA,+BACwBkC,KADxB,+BACkDH,SAAS,CAAC9C,MAD5D;EAGD,C"}
|
|
1
|
+
{"version":3,"file":"IdpOps.js","names":["getFileDataTemplate","meta","script","idp","listSocialProviders","providers","getSocialIdentityProviders","result","sort","a","b","_id","localeCompare","forEach","socialIdentityProvider","printMessage","err","message","getSocialProvider","providerId","then","response","foundProviders","filter","provider","length","Error","exportSocialProviderToFile","file","fileName","getTypedFilename","createProgressIndicator","idpData","updateProgressIndicator","fileData","transform","scriptData","getScript","convertBase64TextToArray","saveJsonToFile","stopProgressIndicator","exportSocialProvidersToFile","getRealmString","allIdpsData","exportSocialProvidersToFiles","importSocialProviderFromFile","fs","readFile","data","JSON","parse","validateImport","found","idpId","hasOwnProperty","call","scriptId","convertTextArrayToBase64","createOrUpdateScript","putProviderByTypeAndId","_type","catch","importProviderErr","brightCyan","importFirstSocialProviderFromFile","importSocialProvidersFromFile","Object","keys","name","importSocialProvidersFromFiles","names","readdirSync","jsonFiles","toLowerCase","endsWith","total","readFileSync","count"],"sources":["ops/IdpOps.ts"],"sourcesContent":["import fs from 'fs';\nimport {\n getSocialIdentityProviders,\n putProviderByTypeAndId,\n} from '../api/SocialIdentityProvidersApi';\nimport { getScript } from '../api/ScriptApi';\nimport { createOrUpdateScript } from './ScriptOps';\nimport {\n convertBase64TextToArray,\n convertTextArrayToBase64,\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n validateImport,\n} from './utils/ExportImportUtils';\nimport {\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from './utils/Console';\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n script: {},\n idp: {},\n };\n}\n\n/**\n * List providers\n */\nexport async function listSocialProviders() {\n try {\n const providers = await getSocialIdentityProviders();\n providers.result.sort((a, b) => a._id.localeCompare(b._id));\n providers.result.forEach((socialIdentityProvider) => {\n printMessage(`${socialIdentityProvider._id}`, 'data');\n });\n } catch (err) {\n printMessage(`listSocialProviders ERROR: ${err.message}`, 'error');\n printMessage(err, 'error');\n }\n}\n\n/**\n * Get social identity provider by id\n * @param {String} providerId social identity provider id/name\n * @returns {Promise} a promise that resolves a social identity provider object\n */\nexport async function getSocialProvider(providerId) {\n return getSocialIdentityProviders().then((response) => {\n const foundProviders = response.result.filter(\n (provider) => provider._id === providerId\n );\n switch (foundProviders.length) {\n case 1:\n return foundProviders[0];\n case 0:\n throw new Error(`Provider '${providerId}' not found`);\n default:\n throw new Error(\n `${foundProviders.length} providers '${providerId}' found`\n );\n }\n });\n}\n\n/**\n * Export provider by id\n * @param {String} providerId provider id/name\n * @param {String} file optional export file name\n */\nexport async function exportSocialProviderToFile(providerId, file = '') {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(providerId, 'idp');\n }\n createProgressIndicator(1, `Exporting ${providerId}`);\n try {\n const idpData = await getSocialProvider(providerId);\n updateProgressIndicator(`Writing file ${fileName}`);\n const fileData = getFileDataTemplate();\n fileData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[idpData.transform] = scriptData;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${providerId['brightCyan']} to ${fileName['brightCyan']}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(`${err}`, 'error');\n }\n}\n\n/**\n * Export all providers\n * @param {String} file optional export file name\n */\nexport async function exportSocialProvidersToFile(file) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(`all${getRealmString()}Providers`, 'idp');\n }\n const fileData = getFileDataTemplate();\n const allIdpsData = (await getSocialIdentityProviders()).result;\n createProgressIndicator(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressIndicator(`Exporting provider ${idpData._id}`);\n fileData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n // eslint-disable-next-line no-await-in-loop\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[idpData.transform] = scriptData;\n }\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${allIdpsData.length} providers exported to ${fileName}.`\n );\n}\n\n/**\n * Export all providers to individual files\n */\nexport async function exportSocialProvidersToFiles() {\n const allIdpsData = await (await getSocialIdentityProviders()).result;\n // printMessage(allIdpsData, 'data');\n createProgressIndicator(allIdpsData.length, 'Exporting providers');\n for (const idpData of allIdpsData) {\n updateProgressIndicator(`Writing provider ${idpData._id}`);\n const fileName = getTypedFilename(idpData._id, 'idp');\n const fileData = getFileDataTemplate();\n fileData.idp[idpData._id] = idpData;\n if (idpData.transform) {\n // eslint-disable-next-line no-await-in-loop\n const scriptData = await getScript(idpData.transform);\n scriptData.script = convertBase64TextToArray(scriptData.script);\n fileData.script[idpData.transform] = scriptData;\n }\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${allIdpsData.length} providers exported.`);\n}\n\n/**\n * Import provider by id/name\n * @param {String} providerId provider id/name\n * @param {String} file import file name\n */\nexport async function importSocialProviderFromFile(providerId, file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(1, 'Importing provider...');\n let found = false;\n for (const idpId in fileData.idp) {\n if ({}.hasOwnProperty.call(fileData.idp, idpId)) {\n if (idpId === providerId) {\n found = true;\n updateProgressIndicator(`Importing ${fileData.idp[idpId]._id}`);\n const scriptId = fileData.idp[idpId].transform;\n const scriptData = fileData.script[scriptId];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n // eslint-disable-next-line no-await-in-loop\n await createOrUpdateScript(\n fileData.idp[idpId].transform,\n fileData.script[fileData.idp[idpId].transform]\n );\n }\n putProviderByTypeAndId(\n fileData.idp[idpId]._type._id,\n idpId,\n fileData.idp[idpId]\n )\n .then(() => {\n stopProgressIndicator(\n `Successfully imported provider ${providerId}.`\n );\n })\n .catch((importProviderErr) => {\n stopProgressIndicator(\n `Error importing provider ${fileData.idp[idpId]._id}`\n );\n printMessage(\n `\\nError importing provider ${providerId}`,\n 'error'\n );\n printMessage(importProviderErr.response.data, 'error');\n });\n break;\n }\n }\n }\n if (!found) {\n stopProgressIndicator(\n `Provider ${providerId.brightCyan} not found in ${file.brightCyan}!`\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import first provider from file\n * @param {String} file import file name\n */\nexport async function importFirstSocialProviderFromFile(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(1, 'Importing provider...');\n for (const idpId in fileData.idp) {\n if ({}.hasOwnProperty.call(fileData.idp, idpId)) {\n updateProgressIndicator(`Importing ${fileData.idp[idpId]._id}`);\n const scriptId = fileData.idp[idpId].transform;\n const scriptData = fileData.script[scriptId];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n // eslint-disable-next-line no-await-in-loop\n await createOrUpdateScript(\n fileData.idp[idpId].transform,\n fileData.script[fileData.idp[idpId].transform]\n );\n }\n putProviderByTypeAndId(\n fileData.idp[idpId]._type._id,\n idpId,\n fileData.idp[idpId]\n ).then((result) => {\n if (result == null) {\n stopProgressIndicator(\n `Error importing provider ${fileData.idp[idpId]._id}`\n );\n printMessage(\n `Error importing provider ${fileData.idp[idpId]._id}`,\n 'error'\n );\n } else {\n stopProgressIndicator(\n `Successfully imported provider ${fileData.idp[idpId]._id}.`\n );\n }\n });\n break;\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all providers from file\n * @param {String} file import file name\n */\nexport async function importSocialProvidersFromFile(file) {\n fs.readFile(file, 'utf8', async (err, data) => {\n if (err) throw err;\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n createProgressIndicator(\n Object.keys(fileData.idp).length,\n 'Importing providers...'\n );\n for (const idpId in fileData.idp) {\n if ({}.hasOwnProperty.call(fileData.idp, idpId)) {\n const scriptId = fileData.idp[idpId].transform;\n const scriptData = fileData.script[scriptId];\n if (scriptId && scriptData) {\n scriptData.script = convertTextArrayToBase64(scriptData.script);\n // eslint-disable-next-line no-await-in-loop\n await createOrUpdateScript(\n fileData.idp[idpId].transform,\n fileData.script[fileData.idp[idpId].transform]\n );\n }\n // eslint-disable-next-line no-await-in-loop\n const result = await putProviderByTypeAndId(\n fileData.idp[idpId]._type._id,\n idpId,\n fileData.idp[idpId]\n );\n if (!result) {\n updateProgressIndicator(\n `Successfully imported ${fileData.idp[idpId].name}`\n );\n }\n }\n }\n stopProgressIndicator(`Providers imported.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import providers from *.idp.json files in current working directory\n */\nexport async function importSocialProvidersFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.idp.json')\n );\n\n createProgressIndicator(jsonFiles.length, 'Importing providers...');\n let total = 0;\n for (const file of jsonFiles) {\n const data = fs.readFileSync(file, 'utf8');\n const fileData = JSON.parse(data);\n if (validateImport(fileData.meta)) {\n const count = Object.keys(fileData.idp).length;\n total += count;\n for (const idpId in fileData.idp) {\n if ({}.hasOwnProperty.call(fileData.idp, idpId)) {\n // eslint-disable-next-line no-await-in-loop\n const result = await putProviderByTypeAndId(\n fileData.idp[idpId]._type._id,\n idpId,\n fileData.idp[idpId]\n );\n if (result == null) {\n printMessage(\n `Error importing ${count} providers from ${file}`,\n 'error'\n );\n }\n }\n }\n updateProgressIndicator(`Imported ${count} provider(s) from ${file}`);\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Finished importing ${total} provider(s) from ${jsonFiles.length} file(s).`\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AAIA;;AACA;;AACA;;AAQA;;;;;;;;AAOA;AACA,SAASA,mBAAT,GAA+B;EAC7B,OAAO;IACLC,IAAI,EAAE,EADD;IAELC,MAAM,EAAE,EAFH;IAGLC,GAAG,EAAE;EAHA,CAAP;AAKD;AAED;AACA;AACA;;;SACsBC,mB;;;AAatB;AACA;AACA;AACA;AACA;;;;2CAjBO,aAAqC;IAC1C,IAAI;MACF,IAAMC,SAAS,SAAS,IAAAC,sDAAA,GAAxB;MACAD,SAAS,CAACE,MAAV,CAAiBC,IAAjB,CAAsB,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAACE,GAAF,CAAMC,aAAN,CAAoBF,CAAC,CAACC,GAAtB,CAAhC;MACAN,SAAS,CAACE,MAAV,CAAiBM,OAAjB,CAA0BC,sBAAD,IAA4B;QACnD,IAAAC,qBAAA,YAAgBD,sBAAsB,CAACH,GAAvC,GAA8C,MAA9C;MACD,CAFD;IAGD,CAND,CAME,OAAOK,GAAP,EAAY;MACZ,IAAAD,qBAAA,uCAA2CC,GAAG,CAACC,OAA/C,GAA0D,OAA1D;MACA,IAAAF,qBAAA,EAAaC,GA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AAoBnB,QAAQ,CAAC/B,GAA7B,EAAkC;UAChC,IAAI,GAAGmD,cAAH,CAAkBC,IAAlB,CAAuBrB,QAAQ,CAAC/B,GAAhC,EAAqCkD,KAArC,CAAJ,EAAiD;YAC/C;YACA,IAAM9C,MAAM,SAAS,IAAAoD,kDAAA,EACnBzB,QAAQ,CAAC/B,GAAT,CAAakD,KAAb,EAAoBO,KAApB,CAA0BjD,GADP,EAEnB0C,KAFmB,EAGnBnB,QAAQ,CAAC/B,GAAT,CAAakD,KAAb,CAHmB,CAArB;;YAKA,IAAI9C,MAAM,IAAI,IAAd,EAAoB;cAClB,IAAAQ,qBAAA,4BACqB8D,KADrB,6BAC6CjD,IAD7C,GAEE,OAFF;YAID;UACF;QACF;;QACD,IAAAK,gCAAA,qBAAoC4C,KAApC,+BAA8DjD,IAA9D;MACD,CApBD,MAoBO;QACL,IAAAb,qBAAA,0BAA8Ba,IAA9B,eAA8C,OAA9C;MACD;IACF;;IACD,IAAAY,8BAAA,+BACwBmC,KADxB,+BACkDH,SAAS,CAAC/C,MAD5D;EAGD,C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdpOps.test.js","names":["mock","MockAdapter","axios","state","default","session","setTenant","setRealm","setCookieName","setCookieValue","setDeploymentType","global","CLOUD_DEPLOYMENT_TYPE_KEY","describe","test","expect","Idp","exportSocialProviderToFile","toBeDefined","exportSocialProvidersToFile","exportSocialProvidersToFiles","getSocialProvider","importFirstSocialProviderFromFile","importSocialProviderFromFile","importSocialProvidersFromFile","importSocialProvidersFromFiles","listSocialProviders","mockGetSocialProviders","assertions","toBeTruthy"],"sources":["ops/IdpOps.test.ts"],"sourcesContent":["import axios from 'axios';\nimport MockAdapter from 'axios-mock-adapter';\nimport { Idp, state } from '../index';\nimport * as global from '../storage/StaticStorage';\nimport { mockGetSocialProviders } from '../test/mocks/ForgeRockApiMockEngine';\n\nconst mock = new MockAdapter(axios);\n\nstate.default.session.setTenant('https://openam-frodo-dev.forgeblocks.com/am');\nstate.default.session.setRealm('alpha');\nstate.default.session.setCookieName('cookieName');\nstate.default.session.setCookieValue('cookieValue');\nstate.default.session.setDeploymentType(global.CLOUD_DEPLOYMENT_TYPE_KEY);\n\ndescribe('IdpOps - exportSocialProviderToFile()', () => {\n test('exportSocialProviderToFile() 0: Method is implemented', async () => {\n expect(Idp.exportSocialProviderToFile).toBeDefined();\n });\n});\n\ndescribe('IdpOps - exportSocialProvidersToFile()', () => {\n test('exportSocialProvidersToFile() 0: Method is implemented', async () => {\n expect(Idp.exportSocialProvidersToFile).toBeDefined();\n });\n});\n\ndescribe('IdpOps - exportSocialProvidersToFiles()', () => {\n test('exportSocialProvidersToFiles() 0: Method is implemented', async () => {\n expect(Idp.exportSocialProvidersToFiles).toBeDefined();\n });\n});\n\ndescribe('IdpOps - getSocialProvider()', () => {\n test('getSocialProvider() 0: Method is implemented', async () => {\n expect(Idp.getSocialProvider).toBeDefined();\n });\n});\n\ndescribe('IdpOps - importFirstSocialProviderFromFile()', () => {\n test('importFirstSocialProviderFromFile() 0: Method is implemented', async () => {\n expect(Idp.importFirstSocialProviderFromFile).toBeDefined();\n });\n});\n\ndescribe('IdpOps - importSocialProviderFromFile()', () => {\n test('importSocialProviderFromFile() 0: Method is implemented', async () => {\n expect(Idp.importSocialProviderFromFile).toBeDefined();\n });\n});\n\ndescribe('IdpOps - importSocialProvidersFromFile()', () => {\n test('importSocialProvidersFromFile() 0: Method is implemented', async () => {\n expect(Idp.importSocialProvidersFromFile).toBeDefined();\n });\n});\n\ndescribe('IdpOps - importSocialProvidersFromFiles()', () => {\n test('importSocialProvidersFromFiles() 0: Method is implemented', async () => {\n expect(Idp.importSocialProvidersFromFiles).toBeDefined();\n });\n});\n\ndescribe('IdpOps - listSocialProviders()', () => {\n test('listSocialProviders() 0: Method is implemented', async () => {\n expect(Idp.listSocialProviders).toBeDefined();\n });\n\n test('listSocialProviders() 1: List social identity providers', async () => {\n mockGetSocialProviders(mock);\n expect.assertions(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iseResults = yield Promise.resolve(themePromise);
|
|
493
493
|
|
|
494
494
|
for (var themeObject of themePromiseResults) {
|
|
495
|
+
var _themeObject$linkedTr;
|
|
496
|
+
|
|
495
497
|
if (themeObject && ( // has the theme been specified by id or name in a page node?
|
|
496
498
|
themes.includes(themeObject._id) || themes.includes(themeObject.name) || // has this journey been linked to a theme?
|
|
497
|
-
themeObject.linkedTrees.includes(treeObject._id))) {
|
|
499
|
+
(_themeObject$linkedTr = themeObject.linkedTrees) !== null && _themeObject$linkedTr !== void 0 && _themeObject$linkedTr.includes(treeObject._id))) {
|
|
498
500
|
if (verbose) (0, _Console.printMessage)(" - ".concat(themeObject._id, " (").concat(themeObject.name, ")"), 'info');
|
|
499
501
|
exportData.themes.push(themeObject);
|
|
500
502
|
}
|
|
501
503
|
}
|
|
502
504
|
} catch (error) {
|
|
503
|
-
(0, _Console.printMessage)(error
|
|
505
|
+
(0, _Console.printMessage)(error, 'error');
|
|
506
|
+
(0, _Console.printMessage)('Error handling themes: ' + error.message, 'error');
|
|
504
507
|
}
|
|
505
508
|
}
|
|
506
509
|
|