@rockcarver/frodo-lib 0.17.3 → 0.17.4
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 +5 -1
- package/cjs/api/Saml2Api.js +36 -14
- package/cjs/api/Saml2Api.js.map +1 -1
- package/cjs/api/ScriptApi.js +23 -2
- package/cjs/api/ScriptApi.js.map +1 -1
- package/cjs/ops/IdpOps.js +3 -3
- package/cjs/ops/IdpOps.js.map +1 -1
- package/cjs/ops/JourneyOps.js +49 -35
- package/cjs/ops/JourneyOps.js.map +1 -1
- package/cjs/ops/JourneyOps.test.js.map +1 -1
- package/cjs/ops/OpsTypes.js.map +1 -1
- package/cjs/ops/Saml2Ops.js +104 -57
- package/cjs/ops/Saml2Ops.js.map +1 -1
- package/cjs/ops/Saml2Ops.test.js.map +1 -1
- package/cjs/ops/ScriptOps.js +193 -186
- package/cjs/ops/ScriptOps.js.map +1 -1
- package/cjs/ops/ScriptOps.test.js.map +1 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js +5 -0
- package/cjs/test/mocks/ForgeRockApiMockEngine.js.map +1 -1
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney1.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney2.journey.json +76 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney3.journey.json +873 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney4.journey.json +930 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney5.journey.json +873 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney6.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney7.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney8.journey.json +148 -0
- package/cjs/test/mocks/JourneyOps/importJourney/FrodoTestJourney9.journey.json +148 -0
- package/esm/api/Saml2Api.mjs +17 -1
- package/esm/api/ScriptApi.mjs +17 -2
- package/esm/ops/IdpOps.mjs +4 -4
- package/esm/ops/JourneyOps.mjs +30 -21
- package/esm/ops/JourneyOps.test.mjs +220 -246
- package/esm/ops/Saml2Ops.mjs +66 -31
- package/esm/ops/Saml2Ops.test.mjs +399 -333
- package/esm/ops/ScriptOps.mjs +148 -152
- package/esm/ops/ScriptOps.test.mjs +282 -0
- package/esm/test/mocks/ForgeRockApiMockEngine.mjs +4 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney1.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney2.journey.json +76 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney3.journey.json +873 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney4.journey.json +930 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney5.journey.json +873 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney6.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney7.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney8.journey.json +148 -0
- package/esm/test/mocks/JourneyOps/importJourney/FrodoTestJourney9.journey.json +148 -0
- package/package.json +10 -2
- package/types/api/Saml2Api.d.ts +8 -1
- package/types/api/Saml2Api.d.ts.map +1 -1
- package/types/api/ScriptApi.d.ts +7 -1
- package/types/api/ScriptApi.d.ts.map +1 -1
- package/types/ops/IdpOps.d.ts.map +1 -1
- package/types/ops/JourneyOps.d.ts +17 -3
- package/types/ops/JourneyOps.d.ts.map +1 -1
- package/types/ops/OpsTypes.d.ts +1 -1
- package/types/ops/OpsTypes.d.ts.map +1 -1
- package/types/ops/Saml2Ops.d.ts +24 -12
- package/types/ops/Saml2Ops.d.ts.map +1 -1
- package/types/ops/ScriptOps.d.ts +56 -20
- package/types/ops/ScriptOps.d.ts.map +1 -1
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts +1 -0
- package/types/test/mocks/ForgeRockApiMockEngine.d.ts.map +1 -1
package/esm/ops/Saml2Ops.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
import { Saml2ProiderLocation } from '../api/ApiTypes';
|
|
3
|
-
import { createProvider,
|
|
3
|
+
import { createProvider, deleteRawProvider, findProviders, getProviderByLocationAndId as _getProviderByLocationAndId, getProviderMetadata as _getProviderMetadata, getProviderMetadataUrl as _getProviderMetadataUrl, getRawProvider as _getRawProvider, getProviders, getRawProviders as _getRawProviders, putRawProvider as _putRawProvider, deleteProviderByLocationAndId } from '../api/Saml2Api';
|
|
4
4
|
import { getScript } from '../api/ScriptApi';
|
|
5
5
|
import { decode, decodeBase64Url, encode, encodeBase64Url } from '../api/utils/Base64';
|
|
6
|
-
import {
|
|
6
|
+
import { putScript } from './ScriptOps';
|
|
7
7
|
import { createProgressIndicator, debugMessage, printMessage, stopProgressIndicator, updateProgressIndicator } from './utils/Console';
|
|
8
|
-
import { convertBase64TextToArray, convertBase64UrlTextToArray, convertTextArrayToBase64, convertTextArrayToBase64Url } from './utils/ExportImportUtils';
|
|
8
|
+
import { convertBase64TextToArray, convertBase64UrlTextToArray, convertTextArrayToBase64, convertTextArrayToBase64Url, getMetadata } from './utils/ExportImportUtils';
|
|
9
9
|
export const roleMap = {
|
|
10
10
|
identityProvider: 'IDP',
|
|
11
11
|
serviceProvider: 'SP',
|
|
@@ -16,7 +16,7 @@ export const roleMap = {
|
|
|
16
16
|
// use a function vs a template variable to avoid problems in loops
|
|
17
17
|
export function createSaml2ExportTemplate() {
|
|
18
18
|
return {
|
|
19
|
-
meta:
|
|
19
|
+
meta: getMetadata(),
|
|
20
20
|
script: {},
|
|
21
21
|
saml: {
|
|
22
22
|
hosted: {},
|
|
@@ -40,7 +40,7 @@ export async function getSaml2ProviderStubs() {
|
|
|
40
40
|
/**
|
|
41
41
|
* Geta SAML2 entity provider by location and id
|
|
42
42
|
* @param {string} location Entity provider location (hosted or remote)
|
|
43
|
-
* @param {string} entityId64 Base64-encoded provider entity id
|
|
43
|
+
* @param {string} entityId64 Base64-encoded-without-padding provider entity id
|
|
44
44
|
* @returns {Promise} a promise that resolves to a saml2 entity provider object
|
|
45
45
|
*/
|
|
46
46
|
export async function getProviderByLocationAndId(location, entityId64) {
|
|
@@ -58,8 +58,8 @@ export function getProviderMetadataUrl(entityId) {
|
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Get a SAML2 entity provider's metadata by entity id
|
|
61
|
-
* @param {
|
|
62
|
-
* @returns {Promise} a promise that resolves to an object containing a SAML2 metadata
|
|
61
|
+
* @param {string} entityId SAML2 entity id
|
|
62
|
+
* @returns {Promise<object>} a promise that resolves to an object containing a SAML2 metadata
|
|
63
63
|
*/
|
|
64
64
|
export async function getProviderMetadata(entityId) {
|
|
65
65
|
return _getProviderMetadata(entityId);
|
|
@@ -67,8 +67,8 @@ export async function getProviderMetadata(entityId) {
|
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
69
|
* Include dependencies in the export file
|
|
70
|
-
* @param {
|
|
71
|
-
* @param {
|
|
70
|
+
* @param {object} providerData Object representing a SAML entity provider
|
|
71
|
+
* @param {object} fileData File data object to add dependencies to
|
|
72
72
|
*/
|
|
73
73
|
async function exportDependencies(providerData, fileData) {
|
|
74
74
|
const attrMapperScriptId = _.get(providerData, ['identityProvider', 'assertionProcessing', 'attributeMapper', 'attributeMapperScript']);
|
|
@@ -92,7 +92,7 @@ async function exportDependencies(providerData, fileData) {
|
|
|
92
92
|
|
|
93
93
|
/**
|
|
94
94
|
*
|
|
95
|
-
* @param {
|
|
95
|
+
* @param {string} entityId Provider entity id
|
|
96
96
|
* @returns {Promise<Saml2ProviderStub>} Promise resolving to a Saml2ExportInterface object.
|
|
97
97
|
*/
|
|
98
98
|
export async function getSaml2ProviderStub(entityId) {
|
|
@@ -113,7 +113,7 @@ export async function getSaml2ProviderStub(entityId) {
|
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
115
|
* Export a single entity provider. The response can be saved to file as is.
|
|
116
|
-
* @param {
|
|
116
|
+
* @param {string} entityId Provider entity id
|
|
117
117
|
* @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.
|
|
118
118
|
*/
|
|
119
119
|
export async function getSaml2Provider(entityId) {
|
|
@@ -128,9 +128,42 @@ export async function getSaml2Provider(entityId) {
|
|
|
128
128
|
return providerData;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Delete an entity provider. The response can be saved to file as is.
|
|
133
|
+
* @param {string} entityId Provider entity id
|
|
134
|
+
* @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.
|
|
135
|
+
*/
|
|
136
|
+
export async function deleteSaml2Provider(entityId) {
|
|
137
|
+
debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);
|
|
138
|
+
const stub = await getSaml2ProviderStub(entityId);
|
|
139
|
+
const {
|
|
140
|
+
location
|
|
141
|
+
} = stub;
|
|
142
|
+
const id = stub._id;
|
|
143
|
+
const providerData = await deleteProviderByLocationAndId(location, id);
|
|
144
|
+
debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);
|
|
145
|
+
return providerData;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Delete all entity providers.
|
|
150
|
+
* @returns {Promise<Saml2ProviderSkeleton[]>} Promise resolving to an array of Saml2ProviderSkeleton objects.
|
|
151
|
+
*/
|
|
152
|
+
export async function deleteSaml2Providers() {
|
|
153
|
+
debugMessage(`Saml2Ops.deleteSaml2Providers: start`);
|
|
154
|
+
const providers = [];
|
|
155
|
+
const stubs = await getSaml2ProviderStubs();
|
|
156
|
+
for (const stub of stubs) {
|
|
157
|
+
const provider = await deleteProviderByLocationAndId(stub.location, stub._id);
|
|
158
|
+
providers.push(provider);
|
|
159
|
+
}
|
|
160
|
+
debugMessage(`Saml2Ops.deleteSaml2Providers: end [deleted ${providers.length} providers]`);
|
|
161
|
+
return providers;
|
|
162
|
+
}
|
|
163
|
+
|
|
131
164
|
/**
|
|
132
165
|
* Export a single entity provider. The response can be saved to file as is.
|
|
133
|
-
* @param {
|
|
166
|
+
* @param {string} entityId Provider entity id
|
|
134
167
|
* @returns {Promise<Saml2ExportInterface>} Promise resolving to a Saml2ExportInterface object.
|
|
135
168
|
*/
|
|
136
169
|
export async function exportSaml2Provider(entityId) {
|
|
@@ -165,8 +198,8 @@ export async function exportSaml2Providers() {
|
|
|
165
198
|
|
|
166
199
|
/**
|
|
167
200
|
* Include dependencies from the import file
|
|
168
|
-
* @param {
|
|
169
|
-
* @param {
|
|
201
|
+
* @param {object} providerData Object representing a SAML entity provider
|
|
202
|
+
* @param {object} fileData File data object to read dependencies from
|
|
170
203
|
*/
|
|
171
204
|
async function importDependencies(providerData, fileData) {
|
|
172
205
|
debugMessage(`Saml2Ops.importDependencies: start`);
|
|
@@ -175,23 +208,23 @@ async function importDependencies(providerData, fileData) {
|
|
|
175
208
|
debugMessage(`Saml2Ops.importDependencies: attributeMapperScript=${attrMapperScriptId}`);
|
|
176
209
|
const scriptData = _.get(fileData, ['script', attrMapperScriptId]);
|
|
177
210
|
scriptData.script = convertTextArrayToBase64(scriptData.script);
|
|
178
|
-
await
|
|
211
|
+
await putScript(attrMapperScriptId, scriptData);
|
|
179
212
|
}
|
|
180
213
|
const idpAdapterScriptId = _.get(providerData, ['identityProvider', 'advanced', 'idpAdapter', 'idpAdapterScript']);
|
|
181
214
|
if (idpAdapterScriptId && idpAdapterScriptId !== '[Empty]') {
|
|
182
215
|
debugMessage(`Saml2Ops.importDependencies: idpAdapterScript=${idpAdapterScriptId}`);
|
|
183
216
|
const scriptData = _.get(fileData, ['script', idpAdapterScriptId]);
|
|
184
217
|
scriptData.script = convertTextArrayToBase64(scriptData.script);
|
|
185
|
-
await
|
|
218
|
+
await putScript(idpAdapterScriptId, scriptData);
|
|
186
219
|
}
|
|
187
220
|
debugMessage(`Saml2Ops.importDependencies: end`);
|
|
188
221
|
}
|
|
189
222
|
|
|
190
223
|
/**
|
|
191
224
|
* Find provider in import file and return its location
|
|
192
|
-
* @param {
|
|
193
|
-
* @param {
|
|
194
|
-
* @returns {
|
|
225
|
+
* @param {string} entityId64 Base64-encoded provider entity id
|
|
226
|
+
* @param {Saml2ExportInterface} data Import file json data
|
|
227
|
+
* @returns {string} 'hosted' or 'remote' if found, undefined otherwise
|
|
195
228
|
*/
|
|
196
229
|
function getLocation(entityId64, data) {
|
|
197
230
|
if (data.saml.hosted[entityId64]) {
|
|
@@ -224,6 +257,7 @@ export async function importSaml2Provider(entityId, importData) {
|
|
|
224
257
|
throw new Error(`Provider ${entityId} not found in import data!`);
|
|
225
258
|
}
|
|
226
259
|
debugMessage(`Saml2Ops.importSaml2Provider: end`);
|
|
260
|
+
return true;
|
|
227
261
|
}
|
|
228
262
|
|
|
229
263
|
/**
|
|
@@ -286,36 +320,37 @@ export async function importSaml2Providers(importData) {
|
|
|
286
320
|
/**
|
|
287
321
|
* Deletes entity provider
|
|
288
322
|
* @param {string} entityId The entity id for the entity to be deleted
|
|
323
|
+
* @returns {Promise<Saml2ProviderSkeleton>} Promise resolving to a Saml2ExportInterface object.
|
|
289
324
|
*/
|
|
290
|
-
export async function
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
}
|
|
325
|
+
export async function deleteRawSaml2Provider(entityId) {
|
|
326
|
+
debugMessage(`Saml2Ops.deleteSaml2Provider: start [entityId=${entityId}]`);
|
|
327
|
+
const response = await deleteRawProvider(entityId);
|
|
328
|
+
debugMessage(`Saml2Ops.deleteSaml2Provider: end [entityId=${entityId}]`);
|
|
329
|
+
return response;
|
|
296
330
|
}
|
|
297
331
|
|
|
298
332
|
/**
|
|
299
333
|
* Deletes all entity providers.
|
|
300
334
|
*/
|
|
301
|
-
export async function
|
|
302
|
-
const applicationList = (await
|
|
335
|
+
export async function deleteRawSaml2Providers() {
|
|
336
|
+
const applicationList = (await getRawSaml2Providers()).result;
|
|
303
337
|
const deleteApplicationPromises = [];
|
|
304
338
|
applicationList.forEach(item => {
|
|
305
339
|
printMessage(`Deleting Application ${item._id}`, 'error');
|
|
306
|
-
deleteApplicationPromises.push(
|
|
340
|
+
deleteApplicationPromises.push(deleteRawProvider(item._id));
|
|
307
341
|
});
|
|
308
342
|
const deleteApplicationResult = await Promise.all(deleteApplicationPromises);
|
|
309
343
|
if (deleteApplicationResult.length == applicationList.length) {
|
|
310
344
|
printMessage('SAML Entity cleanup done', 'info');
|
|
311
345
|
}
|
|
346
|
+
return deleteApplicationResult;
|
|
312
347
|
}
|
|
313
348
|
|
|
314
349
|
/**
|
|
315
350
|
* Retrieves all entity providers using the legacy federation enpoints.
|
|
316
351
|
* @returns {Promise} a promise that resolves to an object containing an array of providers
|
|
317
352
|
*/
|
|
318
|
-
export async function
|
|
353
|
+
export async function getRawSaml2Providers() {
|
|
319
354
|
return _getRawProviders();
|
|
320
355
|
}
|
|
321
356
|
|
|
@@ -324,7 +359,7 @@ export async function getRawProviders() {
|
|
|
324
359
|
* @param {string} entityId The entity provider id
|
|
325
360
|
* @returns {Promise} a promise that resolves to an object containing an array of providers
|
|
326
361
|
*/
|
|
327
|
-
export async function
|
|
362
|
+
export async function getRawSaml2Provider(entityId) {
|
|
328
363
|
return _getRawProvider(entityId);
|
|
329
364
|
}
|
|
330
365
|
|
|
@@ -334,7 +369,7 @@ export async function getRawProvider(entityId) {
|
|
|
334
369
|
* @param {string} entityData The actual data containing the entity provider configuration
|
|
335
370
|
* @returns {Promise} Promise that resolves to a provider object
|
|
336
371
|
*/
|
|
337
|
-
export async function
|
|
372
|
+
export async function putRawSaml2Provider(entityId, entityData) {
|
|
338
373
|
return _putRawProvider(entityId, entityData);
|
|
339
374
|
}
|
|
340
375
|
//# sourceMappingURL=Saml2Ops.js.map
|