@rockcarver/frodo-lib 2.0.0-43 → 2.0.0-44
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/build.zip +0 -0
- package/cjs/ops/CirclesOfTrustOps.js +268 -77
- package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
- package/cjs/ops/CirclesOfTrustOps.test.js +503 -0
- package/cjs/ops/CirclesOfTrustOps.test.js.map +1 -0
- package/cjs/ops/Saml2Ops.js +67 -44
- package/cjs/ops/Saml2Ops.js.map +1 -1
- package/cjs/test/mocks/CirclesOfTrustOps/importCircleOfTrust/2f04818d-561e-4f8a-82e8-af2426112138.cot.saml.json +31 -0
- package/cjs/test/mocks/CirclesOfTrustOps/importCircleOfTrust/AzureCOT.cot.saml.json +34 -0
- package/cjs/test/mocks/CirclesOfTrustOps/importCircleOfTrust/FR_COT.cot.saml.json +37 -0
- package/cjs/test/mocks/CirclesOfTrustOps/importCirclesOfTrust/allAlphaCirclesOfTrust.cot.saml.json +63 -0
- package/cjs/test/mocks/CirclesOfTrustOps/raw/2f04818d-561e-4f8a-82e8-af2426112138.cot.json +10 -0
- package/cjs/test/mocks/CirclesOfTrustOps/raw/AzureCOT.cot.json +16 -0
- package/cjs/test/mocks/CirclesOfTrustOps/raw/FR_COT.cot.json +19 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +21 -1
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/Saml2Ops/importSaml2Providers/cotTestProviders.saml.json +1713 -0
- package/esm/ops/CirclesOfTrustOps.js +239 -67
- package/esm/ops/CirclesOfTrustOps.js.map +1 -1
- package/esm/ops/CirclesOfTrustOps.test.js +484 -0
- package/esm/ops/CirclesOfTrustOps.test.js.map +1 -0
- package/esm/ops/Saml2Ops.js +16 -0
- package/esm/ops/Saml2Ops.js.map +1 -1
- package/esm/test/mocks/CirclesOfTrustOps/importCircleOfTrust/2f04818d-561e-4f8a-82e8-af2426112138.cot.saml.json +31 -0
- package/esm/test/mocks/CirclesOfTrustOps/importCircleOfTrust/AzureCOT.cot.saml.json +34 -0
- package/esm/test/mocks/CirclesOfTrustOps/importCircleOfTrust/FR_COT.cot.saml.json +37 -0
- package/esm/test/mocks/CirclesOfTrustOps/importCirclesOfTrust/allAlphaCirclesOfTrust.cot.saml.json +63 -0
- package/esm/test/mocks/CirclesOfTrustOps/raw/2f04818d-561e-4f8a-82e8-af2426112138.cot.json +10 -0
- package/esm/test/mocks/CirclesOfTrustOps/raw/AzureCOT.cot.json +16 -0
- package/esm/test/mocks/CirclesOfTrustOps/raw/FR_COT.cot.json +19 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.js +18 -2
- package/esm/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/esm/test/mocks/Saml2Ops/importSaml2Providers/cotTestProviders.saml.json +1713 -0
- package/package.json +1 -1
- package/types/ops/CirclesOfTrustOps.d.ts +16 -5
- package/types/ops/CirclesOfTrustOps.d.ts.map +1 -1
- package/types/ops/Saml2Ops.d.ts +7 -0
- package/types/ops/Saml2Ops.d.ts.map +1 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +7 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
package/build.zip
CHANGED
|
Binary file
|
|
@@ -19,6 +19,7 @@ exports.updateCircleOfTrust = updateCircleOfTrust;
|
|
|
19
19
|
var _CirclesOfTrustApi = require("../api/CirclesOfTrustApi.js");
|
|
20
20
|
var _Console = require("../utils/Console.js");
|
|
21
21
|
var _ExportImportUtils = require("../utils/ExportImportUtils.js");
|
|
22
|
+
var _Saml2Ops = require("./Saml2Ops.js");
|
|
22
23
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
23
24
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
24
25
|
var _default = state => {
|
|
@@ -29,8 +30,11 @@ var _default = state => {
|
|
|
29
30
|
});
|
|
30
31
|
},
|
|
31
32
|
readCirclesOfTrust() {
|
|
33
|
+
var _arguments = arguments;
|
|
32
34
|
return _asyncToGenerator(function* () {
|
|
35
|
+
var entityProviders = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : [];
|
|
33
36
|
return readCirclesOfTrust({
|
|
37
|
+
entityProviders,
|
|
34
38
|
state
|
|
35
39
|
});
|
|
36
40
|
})();
|
|
@@ -69,6 +73,16 @@ var _default = state => {
|
|
|
69
73
|
});
|
|
70
74
|
})();
|
|
71
75
|
},
|
|
76
|
+
deleteCirclesOfTrust() {
|
|
77
|
+
var _arguments2 = arguments;
|
|
78
|
+
return _asyncToGenerator(function* () {
|
|
79
|
+
var entityProviders = _arguments2.length > 0 && _arguments2[0] !== undefined ? _arguments2[0] : [];
|
|
80
|
+
return deleteCirclesOfTrust({
|
|
81
|
+
entityProviders,
|
|
82
|
+
state
|
|
83
|
+
});
|
|
84
|
+
})();
|
|
85
|
+
},
|
|
72
86
|
exportCircleOfTrust(cotId) {
|
|
73
87
|
return _asyncToGenerator(function* () {
|
|
74
88
|
return exportCircleOfTrust({
|
|
@@ -78,8 +92,11 @@ var _default = state => {
|
|
|
78
92
|
})();
|
|
79
93
|
},
|
|
80
94
|
exportCirclesOfTrust() {
|
|
95
|
+
var _arguments3 = arguments;
|
|
81
96
|
return _asyncToGenerator(function* () {
|
|
97
|
+
var entityProviders = _arguments3.length > 0 && _arguments3[0] !== undefined ? _arguments3[0] : [];
|
|
82
98
|
return exportCirclesOfTrust({
|
|
99
|
+
entityProviders,
|
|
83
100
|
state
|
|
84
101
|
});
|
|
85
102
|
})();
|
|
@@ -102,9 +119,12 @@ var _default = state => {
|
|
|
102
119
|
})();
|
|
103
120
|
},
|
|
104
121
|
importCirclesOfTrust(importData) {
|
|
122
|
+
var _arguments4 = arguments;
|
|
105
123
|
return _asyncToGenerator(function* () {
|
|
124
|
+
var entityProviders = _arguments4.length > 1 && _arguments4[1] !== undefined ? _arguments4[1] : [];
|
|
106
125
|
return importCirclesOfTrust({
|
|
107
126
|
importData,
|
|
127
|
+
entityProviders,
|
|
108
128
|
state
|
|
109
129
|
});
|
|
110
130
|
})();
|
|
@@ -177,7 +197,7 @@ function _readCirclesOfTrust() {
|
|
|
177
197
|
} = yield (0, _CirclesOfTrustApi.getCirclesOfTrust)({
|
|
178
198
|
state
|
|
179
199
|
});
|
|
180
|
-
if (entityProviders.length
|
|
200
|
+
if (entityProviders.length) {
|
|
181
201
|
(0, _Console.debugMessage)({
|
|
182
202
|
message: "CirclesOfTrustOps.getCirclesOfTrust: filtering results to entity providers: ".concat(entityProviders),
|
|
183
203
|
state
|
|
@@ -240,10 +260,25 @@ function _createCircleOfTrust2() {
|
|
|
240
260
|
state
|
|
241
261
|
} = _ref4;
|
|
242
262
|
if (cotId) cotData._id = cotId;
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
263
|
+
try {
|
|
264
|
+
var response = yield (0, _CirclesOfTrustApi.createCircleOfTrust)({
|
|
265
|
+
cotData,
|
|
266
|
+
state
|
|
267
|
+
});
|
|
268
|
+
return response;
|
|
269
|
+
} catch (error) {
|
|
270
|
+
var _error$response, _error$response2;
|
|
271
|
+
if (((_error$response = error.response) === null || _error$response === void 0 || (_error$response = _error$response.data) === null || _error$response === void 0 ? void 0 : _error$response.code) === 500 && ((_error$response2 = error.response) === null || _error$response2 === void 0 || (_error$response2 = _error$response2.data) === null || _error$response2 === void 0 ? void 0 : _error$response2.message) === "Unable to update entity provider's circle of trust") {
|
|
272
|
+
var _response = yield (0, _CirclesOfTrustApi.updateCircleOfTrust)({
|
|
273
|
+
cotId,
|
|
274
|
+
cotData,
|
|
275
|
+
state
|
|
276
|
+
});
|
|
277
|
+
return _response;
|
|
278
|
+
} else {
|
|
279
|
+
throw error;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
247
282
|
});
|
|
248
283
|
return _createCircleOfTrust2.apply(this, arguments);
|
|
249
284
|
}
|
|
@@ -262,11 +297,26 @@ function _updateCircleOfTrust2() {
|
|
|
262
297
|
cotData,
|
|
263
298
|
state
|
|
264
299
|
} = _ref5;
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
300
|
+
try {
|
|
301
|
+
var response = yield (0, _CirclesOfTrustApi.updateCircleOfTrust)({
|
|
302
|
+
cotId,
|
|
303
|
+
cotData,
|
|
304
|
+
state
|
|
305
|
+
});
|
|
306
|
+
return response;
|
|
307
|
+
} catch (error) {
|
|
308
|
+
var _error$response3, _error$response4, _error$response5;
|
|
309
|
+
if (((_error$response3 = error.response) === null || _error$response3 === void 0 || (_error$response3 = _error$response3.data) === null || _error$response3 === void 0 ? void 0 : _error$response3.code) === 500 && (((_error$response4 = error.response) === null || _error$response4 === void 0 || (_error$response4 = _error$response4.data) === null || _error$response4 === void 0 ? void 0 : _error$response4.message) === "Unable to update entity provider's circle of trust" || ((_error$response5 = error.response) === null || _error$response5 === void 0 || (_error$response5 = _error$response5.data) === null || _error$response5 === void 0 ? void 0 : _error$response5.message) === 'An error occurred while updating the COT memberships')) {
|
|
310
|
+
var _response2 = yield (0, _CirclesOfTrustApi.updateCircleOfTrust)({
|
|
311
|
+
cotId,
|
|
312
|
+
cotData,
|
|
313
|
+
state
|
|
314
|
+
});
|
|
315
|
+
return _response2;
|
|
316
|
+
} else {
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
270
320
|
});
|
|
271
321
|
return _updateCircleOfTrust2.apply(this, arguments);
|
|
272
322
|
}
|
|
@@ -315,18 +365,15 @@ function _deleteCirclesOfTrust() {
|
|
|
315
365
|
entityProviders,
|
|
316
366
|
state
|
|
317
367
|
});
|
|
318
|
-
cots = cots.filter(cot => {
|
|
319
|
-
for (var trustedProvider of cot.trustedProviders) {
|
|
320
|
-
var entityId = trustedProvider.split('|')[0];
|
|
321
|
-
if (!entityProviders.includes(entityId)) return false;
|
|
322
|
-
}
|
|
323
|
-
return true;
|
|
324
|
-
});
|
|
325
368
|
for (var cot of cots) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
369
|
+
try {
|
|
370
|
+
deleted.push(yield deleteCircleOfTrust({
|
|
371
|
+
cotId: cot._id,
|
|
372
|
+
state
|
|
373
|
+
}));
|
|
374
|
+
} catch (error) {
|
|
375
|
+
errors.push(error);
|
|
376
|
+
}
|
|
330
377
|
}
|
|
331
378
|
} catch (error) {
|
|
332
379
|
errors.push(error);
|
|
@@ -375,12 +422,12 @@ function _exportCircleOfTrust() {
|
|
|
375
422
|
}
|
|
376
423
|
if (errors.length) {
|
|
377
424
|
var errorMessages = errors.map(error => {
|
|
378
|
-
var _error$
|
|
379
|
-
if (((_error$
|
|
425
|
+
var _error$response6;
|
|
426
|
+
if (((_error$response6 = error.response) === null || _error$response6 === void 0 ? void 0 : _error$response6.status) === 404) {
|
|
380
427
|
return "Circle of trust ".concat(cotId, " does not exist in realm ").concat(state.getRealm());
|
|
381
428
|
} else {
|
|
382
|
-
var _error$
|
|
383
|
-
return ((_error$
|
|
429
|
+
var _error$response7;
|
|
430
|
+
return ((_error$response7 = error.response) === null || _error$response7 === void 0 || (_error$response7 = _error$response7.data) === null || _error$response7 === void 0 ? void 0 : _error$response7.message) || error.message;
|
|
384
431
|
}
|
|
385
432
|
}).join('\n');
|
|
386
433
|
throw new Error("Export error:\n".concat(errorMessages));
|
|
@@ -455,35 +502,73 @@ function _importCircleOfTrust() {
|
|
|
455
502
|
var response = null;
|
|
456
503
|
var errors = [];
|
|
457
504
|
var imported = [];
|
|
458
|
-
|
|
505
|
+
var _loop = function* _loop() {
|
|
459
506
|
if (id === cotId) {
|
|
460
507
|
try {
|
|
508
|
+
var validEntityIds = yield (0, _Saml2Ops.readSaml2EntityIds)({
|
|
509
|
+
state
|
|
510
|
+
});
|
|
511
|
+
var validProviders = validEntityIds.map(id => "".concat(id, "|saml2"));
|
|
461
512
|
var _cotData2 = importData.saml.cot[id];
|
|
462
513
|
delete _cotData2._rev;
|
|
514
|
+
// only allow adding valid providers
|
|
515
|
+
_cotData2.trustedProviders = validProviders.filter(value => _cotData2.trustedProviders.includes(value));
|
|
463
516
|
try {
|
|
464
517
|
response = yield createCircleOfTrust({
|
|
465
|
-
cotId
|
|
518
|
+
cotId,
|
|
466
519
|
cotData: _cotData2,
|
|
467
520
|
state
|
|
468
521
|
});
|
|
469
522
|
} catch (createError) {
|
|
470
523
|
var _createError$response;
|
|
471
|
-
if (((_createError$response = createError.response) === null || _createError$response === void 0 ? void 0 : _createError$response.status) === 409)
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
524
|
+
if (((_createError$response = createError.response) === null || _createError$response === void 0 ? void 0 : _createError$response.status) === 409) {
|
|
525
|
+
(0, _Console.debugMessage)({
|
|
526
|
+
message: "Circle of trust: ".concat(cotId, " already exists, updating..."),
|
|
527
|
+
state
|
|
528
|
+
});
|
|
529
|
+
var existingCot = yield readCircleOfTrust({
|
|
530
|
+
cotId,
|
|
531
|
+
state
|
|
532
|
+
});
|
|
533
|
+
(0, _Console.debugMessage)({
|
|
534
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: Existing trusted providers for ".concat(cotId, ":\n").concat(existingCot.trustedProviders.map(it => it.split('|')[0]).join('\n'), "."),
|
|
535
|
+
state
|
|
536
|
+
});
|
|
537
|
+
var providers = [...new Set([...existingCot.trustedProviders, ..._cotData2.trustedProviders])];
|
|
538
|
+
(0, _Console.debugMessage)({
|
|
539
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: Merged trusted providers for ".concat(cotId, ":\n").concat(providers.map(it => it.split('|')[0]).join('\n'), "."),
|
|
540
|
+
state
|
|
541
|
+
});
|
|
542
|
+
if (providers.length > existingCot.trustedProviders.length) {
|
|
543
|
+
existingCot.trustedProviders = providers;
|
|
544
|
+
response = yield updateCircleOfTrust({
|
|
545
|
+
cotId,
|
|
546
|
+
cotData: existingCot,
|
|
547
|
+
state
|
|
548
|
+
});
|
|
549
|
+
} else {
|
|
550
|
+
(0, _Console.debugMessage)({
|
|
551
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: No new trusted providers for ".concat(cotId, "."),
|
|
552
|
+
state
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
} else {
|
|
556
|
+
throw createError;
|
|
557
|
+
}
|
|
476
558
|
}
|
|
477
559
|
imported.push(id);
|
|
478
560
|
} catch (error) {
|
|
479
561
|
errors.push(error);
|
|
480
562
|
}
|
|
481
563
|
}
|
|
564
|
+
};
|
|
565
|
+
for (var id of Object.keys(importData.saml.cot)) {
|
|
566
|
+
yield* _loop();
|
|
482
567
|
}
|
|
483
568
|
if (errors.length) {
|
|
484
569
|
var errorMessages = errors.map(error => {
|
|
485
|
-
var _error$
|
|
486
|
-
return ((_error$
|
|
570
|
+
var _error$response8;
|
|
571
|
+
return JSON.stringify((_error$response8 = error.response) === null || _error$response8 === void 0 ? void 0 : _error$response8.data) || error.message;
|
|
487
572
|
}).join('\n');
|
|
488
573
|
throw new Error("Import error:\n".concat(errorMessages));
|
|
489
574
|
}
|
|
@@ -510,33 +595,72 @@ function _importFirstCircleOfTrust() {
|
|
|
510
595
|
var response = null;
|
|
511
596
|
var errors = [];
|
|
512
597
|
var imported = [];
|
|
513
|
-
|
|
598
|
+
var _loop2 = function* _loop2() {
|
|
514
599
|
try {
|
|
515
|
-
var
|
|
600
|
+
var validEntityIds = yield (0, _Saml2Ops.readSaml2EntityIds)({
|
|
601
|
+
state
|
|
602
|
+
});
|
|
603
|
+
var validProviders = validEntityIds.map(id => "".concat(id, "|saml2"));
|
|
604
|
+
var _cotData3 = importData.saml.cot[_cotId];
|
|
516
605
|
delete _cotData3._rev;
|
|
606
|
+
// only allow adding valid providers
|
|
607
|
+
_cotData3.trustedProviders = validProviders.filter(value => _cotData3.trustedProviders.includes(value));
|
|
517
608
|
try {
|
|
518
609
|
response = yield createCircleOfTrust({
|
|
610
|
+
cotId: _cotId,
|
|
519
611
|
cotData: _cotData3,
|
|
520
612
|
state
|
|
521
613
|
});
|
|
522
614
|
} catch (createError) {
|
|
523
615
|
var _createError$response2;
|
|
524
|
-
if (((_createError$response2 = createError.response) === null || _createError$response2 === void 0 ? void 0 : _createError$response2.status) === 409)
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
616
|
+
if (((_createError$response2 = createError.response) === null || _createError$response2 === void 0 ? void 0 : _createError$response2.status) === 409) {
|
|
617
|
+
(0, _Console.debugMessage)({
|
|
618
|
+
message: "Circle of trust: ".concat(_cotId, " already exists, updating..."),
|
|
619
|
+
state
|
|
620
|
+
});
|
|
621
|
+
var existingCot = yield readCircleOfTrust({
|
|
622
|
+
cotId: _cotId,
|
|
623
|
+
state
|
|
624
|
+
});
|
|
625
|
+
(0, _Console.debugMessage)({
|
|
626
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: Existing trusted providers for ".concat(_cotId, ":\n").concat(existingCot.trustedProviders.map(it => it.split('|')[0]).join('\n'), "."),
|
|
627
|
+
state
|
|
628
|
+
});
|
|
629
|
+
var providers = [...new Set([...existingCot.trustedProviders, ..._cotData3.trustedProviders])];
|
|
630
|
+
(0, _Console.debugMessage)({
|
|
631
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: Merged trusted providers for ".concat(_cotId, ":\n").concat(providers.map(it => it.split('|')[0]).join('\n'), "."),
|
|
632
|
+
state
|
|
633
|
+
});
|
|
634
|
+
if (providers.length > existingCot.trustedProviders.length) {
|
|
635
|
+
existingCot.trustedProviders = providers;
|
|
636
|
+
response = yield updateCircleOfTrust({
|
|
637
|
+
cotId: _cotId,
|
|
638
|
+
cotData: existingCot,
|
|
639
|
+
state
|
|
640
|
+
});
|
|
641
|
+
} else {
|
|
642
|
+
(0, _Console.debugMessage)({
|
|
643
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: No new trusted providers for ".concat(_cotId, "."),
|
|
644
|
+
state
|
|
645
|
+
});
|
|
646
|
+
}
|
|
647
|
+
} else {
|
|
648
|
+
throw createError;
|
|
649
|
+
}
|
|
529
650
|
}
|
|
530
|
-
imported.push(
|
|
651
|
+
imported.push(_cotId);
|
|
531
652
|
} catch (error) {
|
|
532
653
|
errors.push(error);
|
|
533
654
|
}
|
|
534
|
-
break
|
|
655
|
+
return 1; // break
|
|
656
|
+
};
|
|
657
|
+
for (var _cotId of Object.keys(importData.saml.cot)) {
|
|
658
|
+
if (yield* _loop2()) break;
|
|
535
659
|
}
|
|
536
660
|
if (errors.length) {
|
|
537
661
|
var errorMessages = errors.map(error => {
|
|
538
|
-
var _error$
|
|
539
|
-
return ((_error$
|
|
662
|
+
var _error$response9;
|
|
663
|
+
return ((_error$response9 = error.response) === null || _error$response9 === void 0 || (_error$response9 = _error$response9.data) === null || _error$response9 === void 0 ? void 0 : _error$response9.message) || error.message;
|
|
540
664
|
}).join('\n');
|
|
541
665
|
throw new Error("Import error:\n".concat(errorMessages));
|
|
542
666
|
}
|
|
@@ -557,57 +681,121 @@ function _importCirclesOfTrust() {
|
|
|
557
681
|
importData,
|
|
558
682
|
state
|
|
559
683
|
} = _ref12;
|
|
560
|
-
var
|
|
684
|
+
var responses = [];
|
|
561
685
|
var errors = [];
|
|
562
686
|
var imported = [];
|
|
563
687
|
entityProviders = entityProviders.map(id => "".concat(id, "|saml2"));
|
|
564
|
-
|
|
688
|
+
var validEntityIds = yield (0, _Saml2Ops.readSaml2EntityIds)({
|
|
689
|
+
state
|
|
690
|
+
});
|
|
691
|
+
var validProviders = validEntityIds.map(id => "".concat(id, "|saml2"));
|
|
692
|
+
var _loop3 = function* _loop3() {
|
|
565
693
|
try {
|
|
566
|
-
var _cotData4 = importData.saml.cot[
|
|
694
|
+
var _cotData4 = importData.saml.cot[_cotId2];
|
|
567
695
|
delete _cotData4._rev;
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
696
|
+
// apply filter and merge logic
|
|
697
|
+
if (entityProviders.length) {
|
|
698
|
+
// only allow filtering for valid providers
|
|
699
|
+
entityProviders = validProviders.filter(value => entityProviders.includes(value));
|
|
700
|
+
// determine if cot import candidate matches entity providers filter
|
|
701
|
+
var hasEntityId = false;
|
|
702
|
+
for (var trustedProvider of _cotData4.trustedProviders) {
|
|
703
|
+
if (!hasEntityId && entityProviders.includes(trustedProvider)) {
|
|
704
|
+
hasEntityId = true;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
if (hasEntityId) {
|
|
708
|
+
try {
|
|
709
|
+
var response = yield createCircleOfTrust({
|
|
710
|
+
cotId: _cotId2,
|
|
711
|
+
cotData: _cotData4,
|
|
712
|
+
state
|
|
713
|
+
});
|
|
714
|
+
imported.push(_cotId2);
|
|
715
|
+
responses.push(response);
|
|
716
|
+
} catch (createError) {
|
|
717
|
+
var _createError$response3;
|
|
718
|
+
if (((_createError$response3 = createError.response) === null || _createError$response3 === void 0 ? void 0 : _createError$response3.status) === 409) {
|
|
719
|
+
(0, _Console.debugMessage)({
|
|
720
|
+
message: "Circle of trust: ".concat(_cotId2, " already exists, updating..."),
|
|
721
|
+
state
|
|
722
|
+
});
|
|
723
|
+
var existingCot = yield readCircleOfTrust({
|
|
724
|
+
cotId: _cotId2,
|
|
725
|
+
state
|
|
726
|
+
});
|
|
727
|
+
(0, _Console.debugMessage)({
|
|
728
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: Existing trusted providers for ".concat(_cotId2, ":\n").concat(existingCot.trustedProviders.map(it => it.split('|')[0]).join('\n'), "."),
|
|
729
|
+
state
|
|
730
|
+
});
|
|
731
|
+
var providers = [...new Set([...existingCot.trustedProviders, ...entityProviders])];
|
|
732
|
+
(0, _Console.debugMessage)({
|
|
733
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: Updated trusted providers for ".concat(_cotId2, ":\n").concat(providers.map(it => it.split('|')[0]).join('\n'), "."),
|
|
734
|
+
state
|
|
735
|
+
});
|
|
736
|
+
if (providers.length > existingCot.trustedProviders.length) {
|
|
737
|
+
existingCot.trustedProviders = providers;
|
|
738
|
+
var _response3 = yield updateCircleOfTrust({
|
|
739
|
+
cotId: _cotId2,
|
|
740
|
+
cotData: existingCot,
|
|
741
|
+
state
|
|
742
|
+
});
|
|
743
|
+
imported.push(_cotId2);
|
|
744
|
+
responses.push(_response3);
|
|
745
|
+
} else {
|
|
746
|
+
(0, _Console.debugMessage)({
|
|
747
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: No new trusted providers for ".concat(_cotId2, "."),
|
|
748
|
+
state
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
} else {
|
|
752
|
+
throw createError;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
572
755
|
}
|
|
573
756
|
}
|
|
574
|
-
|
|
757
|
+
// import unfiltered but merge if existing cot
|
|
758
|
+
else {
|
|
759
|
+
// only allow adding valid providers
|
|
760
|
+
_cotData4.trustedProviders = validProviders.filter(value => _cotData4.trustedProviders.includes(value));
|
|
575
761
|
try {
|
|
576
|
-
|
|
577
|
-
cotId:
|
|
762
|
+
var _response4 = yield createCircleOfTrust({
|
|
763
|
+
cotId: _cotId2,
|
|
578
764
|
cotData: _cotData4,
|
|
579
765
|
state
|
|
580
|
-
})
|
|
766
|
+
});
|
|
767
|
+
responses.push(_response4);
|
|
581
768
|
} catch (createError) {
|
|
582
|
-
var _createError$
|
|
583
|
-
if (((_createError$
|
|
769
|
+
var _createError$response4;
|
|
770
|
+
if (((_createError$response4 = createError.response) === null || _createError$response4 === void 0 ? void 0 : _createError$response4.status) === 409) {
|
|
584
771
|
(0, _Console.debugMessage)({
|
|
585
|
-
message: "Circle of trust: ".concat(
|
|
772
|
+
message: "Circle of trust: ".concat(_cotId2, " already exists, updating..."),
|
|
586
773
|
state
|
|
587
774
|
});
|
|
588
|
-
var
|
|
589
|
-
cotId:
|
|
775
|
+
var _existingCot = yield readCircleOfTrust({
|
|
776
|
+
cotId: _cotId2,
|
|
590
777
|
state
|
|
591
778
|
});
|
|
592
779
|
(0, _Console.debugMessage)({
|
|
593
|
-
message: "CirclesOfTrustOps.importCirclesOfTrust: Existing trusted providers for ".concat(
|
|
780
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: Existing trusted providers for ".concat(_cotId2, ":\n").concat(_existingCot.trustedProviders.map(it => it.split('|')[0]).join('\n'), "."),
|
|
594
781
|
state
|
|
595
782
|
});
|
|
596
|
-
var
|
|
783
|
+
var _providers = [...new Set([..._existingCot.trustedProviders, ..._cotData4.trustedProviders])];
|
|
597
784
|
(0, _Console.debugMessage)({
|
|
598
|
-
message: "CirclesOfTrustOps.importCirclesOfTrust:
|
|
785
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: Merged trusted providers for ".concat(_cotId2, ":\n").concat(_providers.map(it => it.split('|')[0]).join('\n'), "."),
|
|
599
786
|
state
|
|
600
787
|
});
|
|
601
|
-
if (
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
cotId:
|
|
605
|
-
cotData:
|
|
788
|
+
if (_providers.length > _existingCot.trustedProviders.length) {
|
|
789
|
+
_existingCot.trustedProviders = _providers;
|
|
790
|
+
var _response5 = yield updateCircleOfTrust({
|
|
791
|
+
cotId: _cotId2,
|
|
792
|
+
cotData: _existingCot,
|
|
606
793
|
state
|
|
607
|
-
})
|
|
794
|
+
});
|
|
795
|
+
responses.push(_response5);
|
|
608
796
|
} else {
|
|
609
797
|
(0, _Console.debugMessage)({
|
|
610
|
-
message: "CirclesOfTrustOps.importCirclesOfTrust: No new trusted providers for ".concat(
|
|
798
|
+
message: "CirclesOfTrustOps.importCirclesOfTrust: No new trusted providers for ".concat(_cotId2, "."),
|
|
611
799
|
state
|
|
612
800
|
});
|
|
613
801
|
}
|
|
@@ -616,27 +804,30 @@ function _importCirclesOfTrust() {
|
|
|
616
804
|
}
|
|
617
805
|
}
|
|
618
806
|
}
|
|
619
|
-
imported.push(_cotId);
|
|
620
807
|
} catch (error) {
|
|
621
|
-
var _error$
|
|
808
|
+
var _error$response11, _error$response12;
|
|
622
809
|
(0, _Console.debugMessage)({
|
|
623
|
-
message: "Error ".concat((_error$
|
|
810
|
+
message: "Error ".concat((_error$response11 = error.response) === null || _error$response11 === void 0 ? void 0 : _error$response11.status, " creating/updating circle of trust: ").concat((_error$response12 = error.response) === null || _error$response12 === void 0 || (_error$response12 = _error$response12.data) === null || _error$response12 === void 0 ? void 0 : _error$response12.message),
|
|
624
811
|
state
|
|
625
812
|
});
|
|
626
813
|
errors.push(error);
|
|
627
814
|
}
|
|
815
|
+
imported.push(_cotId2);
|
|
816
|
+
};
|
|
817
|
+
for (var _cotId2 of Object.keys(importData.saml.cot)) {
|
|
818
|
+
yield* _loop3();
|
|
628
819
|
}
|
|
629
820
|
if (errors.length) {
|
|
630
821
|
var errorMessages = errors.map(error => {
|
|
631
|
-
var _error$
|
|
632
|
-
return ((_error$
|
|
822
|
+
var _error$response10;
|
|
823
|
+
return ((_error$response10 = error.response) === null || _error$response10 === void 0 || (_error$response10 = _error$response10.data) === null || _error$response10 === void 0 ? void 0 : _error$response10.message) || error.message;
|
|
633
824
|
}).join('\n');
|
|
634
825
|
throw new Error("".concat(errorMessages));
|
|
635
826
|
}
|
|
636
827
|
if (0 === imported.length) {
|
|
637
828
|
throw new Error("Import error:\nNo circles of trust found in import data!");
|
|
638
829
|
}
|
|
639
|
-
return
|
|
830
|
+
return responses;
|
|
640
831
|
});
|
|
641
832
|
return _importCirclesOfTrust.apply(this, arguments);
|
|
642
833
|
}
|