@rockcarver/frodo-lib 0.12.5-0 → 0.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +27 -8
  2. package/cjs/api/ApiTypes.js +42 -0
  3. package/cjs/api/ApiTypes.js.map +1 -0
  4. package/cjs/api/Saml2Api.js +1 -1
  5. package/cjs/api/Saml2Api.js.map +1 -1
  6. package/cjs/api/utils/ApiUtils.js +3 -11
  7. package/cjs/api/utils/ApiUtils.js.map +1 -1
  8. package/cjs/api/utils/ApiUtils.test.js.map +1 -1
  9. package/cjs/index.js +9 -1
  10. package/cjs/index.js.map +1 -1
  11. package/cjs/ops/CirclesOfTrustOps.js +12 -1
  12. package/cjs/ops/CirclesOfTrustOps.js.map +1 -1
  13. package/cjs/ops/EmailTemplateOps.js +12 -0
  14. package/cjs/ops/EmailTemplateOps.js.map +1 -1
  15. package/cjs/ops/IdmOps.js +8 -3
  16. package/cjs/ops/IdmOps.js.map +1 -1
  17. package/cjs/ops/IdpOps.js +12 -1
  18. package/cjs/ops/IdpOps.js.map +1 -1
  19. package/cjs/ops/JourneyOps.js +388 -140
  20. package/cjs/ops/JourneyOps.js.map +1 -1
  21. package/cjs/ops/NodeOps.js +13 -0
  22. package/cjs/ops/NodeOps.js.map +1 -1
  23. package/cjs/ops/OpsTypes.js +6 -0
  24. package/cjs/ops/OpsTypes.js.map +1 -0
  25. package/cjs/ops/Saml2Ops.js +24 -1
  26. package/cjs/ops/Saml2Ops.js.map +1 -1
  27. package/cjs/ops/ScriptOps.js +12 -0
  28. package/cjs/ops/ScriptOps.js.map +1 -1
  29. package/cjs/ops/ThemeOps.js +12 -0
  30. package/cjs/ops/ThemeOps.js.map +1 -1
  31. package/cjs/ops/utils/Console.js +18 -1
  32. package/cjs/ops/utils/Console.js.map +1 -1
  33. package/cjs/ops/utils/ExportImportUtils.js.map +1 -1
  34. package/cjs/ops/utils/OpsUtils.js +1 -1
  35. package/cjs/ops/utils/OpsUtils.js.map +1 -1
  36. package/cjs/ops/utils/OpsUtils.test.js.map +1 -0
  37. package/cjs/storage/SessionStorage.js +4 -0
  38. package/cjs/storage/SessionStorage.js.map +1 -1
  39. package/esm/api/ApiTypes.mjs +33 -0
  40. package/esm/api/Saml2Api.mjs +1 -1
  41. package/esm/api/utils/ApiUtils.mjs +3 -9
  42. package/esm/api/utils/ApiUtils.test.mjs +5 -5
  43. package/esm/index.mjs +2 -0
  44. package/esm/ops/CirclesOfTrustOps.mjs +11 -1
  45. package/esm/ops/EmailTemplateOps.mjs +11 -1
  46. package/esm/ops/IdmOps.mjs +8 -3
  47. package/esm/ops/IdpOps.mjs +11 -1
  48. package/esm/ops/JourneyOps.mjs +269 -82
  49. package/esm/ops/NodeOps.mjs +11 -0
  50. package/esm/ops/OpsTypes.mjs +2 -0
  51. package/esm/ops/Saml2Ops.mjs +20 -2
  52. package/esm/ops/ScriptOps.mjs +10 -0
  53. package/esm/ops/ThemeOps.mjs +10 -0
  54. package/esm/ops/utils/Console.mjs +16 -1
  55. package/esm/ops/utils/OpsUtils.mjs +2 -2
  56. package/esm/ops/utils/OpsUtils.test.mjs +50 -0
  57. package/esm/storage/SessionStorage.mjs +4 -0
  58. package/package.json +1 -1
  59. package/types/api/ApiTypes.d.ts +102 -0
  60. package/types/api/ApiTypes.d.ts.map +1 -0
  61. package/types/api/Saml2Api.d.ts +1 -1
  62. package/types/api/Saml2Api.d.ts.map +1 -1
  63. package/types/api/utils/ApiUtils.d.ts.map +1 -1
  64. package/types/index.d.ts +2 -0
  65. package/types/index.d.ts.map +1 -1
  66. package/types/ops/CirclesOfTrustOps.d.ts +7 -0
  67. package/types/ops/CirclesOfTrustOps.d.ts.map +1 -1
  68. package/types/ops/EmailTemplateOps.d.ts +7 -0
  69. package/types/ops/EmailTemplateOps.d.ts.map +1 -1
  70. package/types/ops/IdmOps.d.ts.map +1 -1
  71. package/types/ops/IdpOps.d.ts +7 -0
  72. package/types/ops/IdpOps.d.ts.map +1 -1
  73. package/types/ops/JourneyOps.d.ts +107 -89
  74. package/types/ops/JourneyOps.d.ts.map +1 -1
  75. package/types/ops/NodeOps.d.ts +8 -0
  76. package/types/ops/NodeOps.d.ts.map +1 -1
  77. package/types/ops/OpsTypes.d.ts +66 -0
  78. package/types/ops/OpsTypes.d.ts.map +1 -0
  79. package/types/ops/Saml2Ops.d.ts +13 -0
  80. package/types/ops/Saml2Ops.d.ts.map +1 -1
  81. package/types/ops/ScriptOps.d.ts +7 -0
  82. package/types/ops/ScriptOps.d.ts.map +1 -1
  83. package/types/ops/ThemeOps.d.ts +7 -0
  84. package/types/ops/ThemeOps.d.ts.map +1 -1
  85. package/types/ops/utils/Console.d.ts +9 -1
  86. package/types/ops/utils/Console.d.ts.map +1 -1
  87. package/types/ops/utils/ExportImportUtils.d.ts.map +1 -1
  88. package/types/ops/utils/OpsUtils.d.ts.map +1 -1
  89. package/types/storage/SessionStorage.d.ts +4 -0
  90. package/types/storage/SessionStorage.d.ts.map +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.12.6] - 2022-09-30
11
+
12
+ ### Added
13
+
14
+ - \#104: Enhanced `frodo journey describe` command to include more details
15
+
16
+ ## [0.12.5] - 2022-09-29
17
+
18
+ ### Fixed
19
+
20
+ - \#98: Frodo now properly runs `frodo idm export -A -D ./idm <host>` command
21
+ - \#100: Frodo now properly handles nested realms when specified as `/parent/child`
22
+ - \#101: Frodo now properly sets the identity resource when the realm was specified with a leading slash
23
+ - \#102: Frodo now properly replaces existing themes on import when the realm was specified with a leading slash
24
+
10
25
  ## [0.12.5-0] - 2022-09-19
11
26
 
12
27
  ## [0.12.4] - 2022-09-17
@@ -15,9 +30,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
30
 
16
31
  - Frodo now allows two new parameters when adding a connection profile:
17
32
 
18
- \--authentication-service [service] Name of the authentication service/tree to use.
33
+ \--authentication-service [service] Name of the authentication service/tree to use.
19
34
 
20
- \--authentication-header-overrides [headers] Map of headers: {"host":"am.example.com:8081"}.
35
+ \--authentication-header-overrides [headers] Map of headers: {"host":"am.example.com:8081"}.
21
36
 
22
37
  These parameters are currently only supported in the `frodo conn add` command and the configuration elements will be automatically applied to commands issued using that connection profile.
23
38
 
@@ -27,13 +42,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
27
42
  Saving creds in /Users/vscheuber/.frodo/.frodorc...
28
43
  Updating connection profile https://platform.example.com:9443/am
29
44
  Advanced setting: Authentication Service: ldapService
30
- Advanced setting: Authentication Header Overrides:
45
+ Advanced setting: Authentication Header Overrides:
31
46
  { host: 'am.example.com:8081' }
32
47
  %
33
48
 
34
49
  After the connection profile is created with the additional parameters, the environment can be accessed as usual. In this case it requires the `-k` parameter for every command, as the environment uses a self-signed certificate.
35
50
 
36
- % frodo journey list platform alpha -k
51
+ % frodo journey list platform alpha -k
37
52
  ForgeOps deployment detected.
38
53
  Connected to ForgeRock Access Management 7.2.0 Build 64ef7ebc01ed3df1a1264d7b0400351bc101361f (2022-June-27 08:15)
39
54
  Listing journeys in realm "alpha"...
@@ -125,7 +140,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
125
140
 
126
141
  ### Changed
127
142
 
128
- - \#19: `frodo-lib` is now a typescript project.
143
+ - \#19: `frodo-lib` is now a typescript project.
129
144
 
130
145
  ## [0.11.1-7] - 2022-08-21
131
146
 
@@ -324,9 +339,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
324
339
 
325
340
  - Changed `idm` sub-commands to align with other commands:
326
341
  - The sub-commands `export`, `exportAll`, and `exportAllRaw` have been collapsed into one: `export`
327
- - `idm export -A` (`--all-separate`) is now the way to export all idm configuration.
342
+ - `idm export -A` (`--all-separate`) is now the way to export all idm configuration.
328
343
  - Options `-e` and `-E` select old `exportAll` functionality with variable replacement and filtering
329
- - Omitting options `-e` and `-E`, selects the old `exportAllRaw` functionality without variable replacement and without filtering
344
+ - Omitting options `-e` and `-E`, selects the old `exportAllRaw` functionality without variable replacement and without filtering
330
345
  - Renamed sample resource files for `idm export` command:
331
346
  - `<frodo home>/resources/sampleEntitiesFile.json`
332
347
  - `<frodo home>/resources/sampleEnvFile.env`
@@ -551,7 +566,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
551
566
  - Fixed problem with adding connection profiles
552
567
  - Miscellaneous bug fixes
553
568
 
554
- [Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.12.5-0...HEAD
569
+ [Unreleased]: https://github.com/rockcarver/frodo-lib/compare/v0.12.6...HEAD
570
+
571
+ [0.12.6]: https://github.com/rockcarver/frodo-lib/compare/v0.12.5...v0.12.6
572
+
573
+ [0.12.5]: https://github.com/rockcarver/frodo-lib/compare/v0.12.5-0...v0.12.5
555
574
 
556
575
  [0.12.5-0]: https://github.com/rockcarver/frodo-lib/compare/v0.12.4...v0.12.5-0
557
576
 
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ScriptLanguage = exports.ScriptContext = exports.Saml2ProiderLocation = void 0;
7
+ var ScriptLanguage;
8
+ exports.ScriptLanguage = ScriptLanguage;
9
+
10
+ (function (ScriptLanguage) {
11
+ ScriptLanguage["GROOVY"] = "GROOVY";
12
+ ScriptLanguage["JAVASCRIPT"] = "JAVASCRIPT";
13
+ })(ScriptLanguage || (exports.ScriptLanguage = ScriptLanguage = {}));
14
+
15
+ var ScriptContext;
16
+ exports.ScriptContext = ScriptContext;
17
+
18
+ (function (ScriptContext) {
19
+ ScriptContext["OAUTH2_ACCESS_TOKEN_MODIFICATION"] = "OAUTH2_ACCESS_TOKEN_MODIFICATION";
20
+ ScriptContext["AUTHENTICATION_CLIENT_SIDE"] = "AUTHENTICATION_CLIENT_SIDE";
21
+ ScriptContext["AUTHENTICATION_TREE_DECISION_NODE"] = "AUTHENTICATION_TREE_DECISION_NODE";
22
+ ScriptContext["AUTHENTICATION_SERVER_SIDE"] = "AUTHENTICATION_SERVER_SIDE";
23
+ ScriptContext["SOCIAL_IDP_PROFILE_TRANSFORMATION"] = "SOCIAL_IDP_PROFILE_TRANSFORMATION";
24
+ ScriptContext["OAUTH2_VALIDATE_SCOPE"] = "OAUTH2_VALIDATE_SCOPE";
25
+ ScriptContext["CONFIG_PROVIDER_NODE"] = "CONFIG_PROVIDER_NODE";
26
+ ScriptContext["OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER"] = "OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER";
27
+ ScriptContext["OAUTH2_EVALUATE_SCOPE"] = "OAUTH2_EVALUATE_SCOPE";
28
+ ScriptContext["POLICY_CONDITION"] = "POLICY_CONDITION";
29
+ ScriptContext["OIDC_CLAIMS"] = "OIDC_CLAIMS";
30
+ ScriptContext["SAML2_IDP_ADAPTER"] = "SAML2_IDP_ADAPTER";
31
+ ScriptContext["SAML2_IDP_ATTRIBUTE_MAPPER"] = "SAML2_IDP_ATTRIBUTE_MAPPER";
32
+ ScriptContext["OAUTH2_MAY_ACT"] = "OAUTH2_MAY_ACT";
33
+ })(ScriptContext || (exports.ScriptContext = ScriptContext = {}));
34
+
35
+ var Saml2ProiderLocation;
36
+ exports.Saml2ProiderLocation = Saml2ProiderLocation;
37
+
38
+ (function (Saml2ProiderLocation) {
39
+ Saml2ProiderLocation["HOSTED"] = "hosted";
40
+ Saml2ProiderLocation["REMOTE"] = "remote";
41
+ })(Saml2ProiderLocation || (exports.Saml2ProiderLocation = Saml2ProiderLocation = {}));
42
+ //# sourceMappingURL=ApiTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApiTypes.js","names":["ScriptLanguage","ScriptContext","Saml2ProiderLocation"],"sources":["api/ApiTypes.ts"],"sourcesContent":["interface ObjectSkeletonInterface {\n _id: string;\n _rev?: number;\n [k: string]: string | number | ObjectSkeletonInterface;\n}\n\nexport interface UiConfigInterface {\n categories: string[];\n}\n\nexport interface NodeRefSkeletonInterface {\n connections: Record<string, string>;\n displayName: string;\n nodeType: string;\n x: number;\n y: number;\n}\n\nexport interface InnerNodeRefSkeletonInterface {\n _id: string;\n displayName: string;\n nodeType: string;\n}\n\nexport type TreeSkeleton = ObjectSkeletonInterface & {\n entryNodeId: string;\n nodes: Record<string, NodeRefSkeletonInterface>;\n identityResource?: string;\n uiConfig?: UiConfigInterface;\n enabled?: boolean;\n};\n\nexport type AmServiceType = ObjectSkeletonInterface & {\n name: string;\n};\n\nexport type NodeSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n nodes?: InnerNodeRefSkeletonInterface[];\n tree?: string;\n identityResource?: string;\n};\n\nexport type SocialIdpSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n enabled: boolean;\n};\n\nexport type EmailTemplateSkeleton = ObjectSkeletonInterface & {\n defaultLocale?: string;\n displayName?: string;\n enabled?: boolean;\n from: string;\n subject: Record<string, string>;\n};\n\nexport type ThemeSkeleton = ObjectSkeletonInterface & {\n name: string;\n isDefault: boolean;\n linkedTrees: string[];\n};\n\nexport enum ScriptLanguage {\n GROOVY = 'GROOVY',\n JAVASCRIPT = 'JAVASCRIPT',\n}\n\nexport enum ScriptContext {\n OAUTH2_ACCESS_TOKEN_MODIFICATION = 'OAUTH2_ACCESS_TOKEN_MODIFICATION',\n AUTHENTICATION_CLIENT_SIDE = 'AUTHENTICATION_CLIENT_SIDE',\n AUTHENTICATION_TREE_DECISION_NODE = 'AUTHENTICATION_TREE_DECISION_NODE',\n AUTHENTICATION_SERVER_SIDE = 'AUTHENTICATION_SERVER_SIDE',\n SOCIAL_IDP_PROFILE_TRANSFORMATION = 'SOCIAL_IDP_PROFILE_TRANSFORMATION',\n OAUTH2_VALIDATE_SCOPE = 'OAUTH2_VALIDATE_SCOPE',\n CONFIG_PROVIDER_NODE = 'CONFIG_PROVIDER_NODE',\n OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER = 'OAUTH2_AUTHORIZE_ENDPOINT_DATA_PROVIDER',\n OAUTH2_EVALUATE_SCOPE = 'OAUTH2_EVALUATE_SCOPE',\n POLICY_CONDITION = 'POLICY_CONDITION',\n OIDC_CLAIMS = 'OIDC_CLAIMS',\n SAML2_IDP_ADAPTER = 'SAML2_IDP_ADAPTER',\n SAML2_IDP_ATTRIBUTE_MAPPER = 'SAML2_IDP_ATTRIBUTE_MAPPER',\n OAUTH2_MAY_ACT = 'OAUTH2_MAY_ACT',\n}\n\nexport type ScriptSkeleton = ObjectSkeletonInterface & {\n name: string;\n description: string;\n isDefault: boolean;\n script: string;\n language: ScriptLanguage;\n context: ScriptContext;\n createdBy: string;\n creationDate: number;\n lastModifiedBy: string;\n lastModifiedDate: number;\n};\n\nexport enum Saml2ProiderLocation {\n HOSTED = 'hosted',\n REMOTE = 'remote',\n}\n\nexport type Saml2ProviderSkeleton = ObjectSkeletonInterface & {\n entityId: string;\n entityLocation: Saml2ProiderLocation;\n serviceProvider: unknown;\n identityProvider: unknown;\n attributeQueryProvider: unknown;\n xacmlPolicyEnforcementPoint: unknown;\n};\n\nexport type CircleOfTrustSkeleton = ObjectSkeletonInterface & {\n _type: AmServiceType;\n status: string;\n trustedProviders: string[];\n};\n"],"mappings":";;;;;;IA8DYA,c;;;WAAAA,c;EAAAA,c;EAAAA,c;GAAAA,c,8BAAAA,c;;IAKAC,a;;;WAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;EAAAA,a;GAAAA,a,6BAAAA,a;;IA8BAC,oB;;;WAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB"}
@@ -54,7 +54,7 @@ function getProviders() {
54
54
  }
55
55
  /**
56
56
  * Find all providers matching the filter and return the requested fields
57
- * @param {string} filter CREST filter string, eg "entityId+eq+'${entityId}'"
57
+ * @param {string} filter CREST filter string, eg "entityId+eq+'${entityId}'" or "true" for all providers
58
58
  * @param {string} fields Comma-delimited list of fields to include in the response
59
59
  * @returns {Promise} a promise that resolves to an object containing an array of saml2 entities
60
60
  */
@@ -1 +1 @@
1
- {"version":3,"file":"Saml2Api.js","names":["providerByLocationAndIdURLTemplate","createHostedProviderURLTemplate","createRemoteProviderURLTemplate","queryAllProvidersURLTemplate","queryProvidersByEntityIdURLTemplate","metadataByEntityIdURLTemplate","apiVersion","getApiConfig","configPath","getCurrentRealmPath","path","getProviders","urlString","util","format","storage","session","getTenant","data","generateAmApi","get","withCredentials","findProviders","filter","fields","encodeURIComponent","getProviderByLocationAndId","location","entityId64","getProvider","entityId","response","resultCount","Error","result","id","_id","getProviderMetadataUrl","getRealm","getProviderMetadata","createProvider","providerData","metaData","postData","_","cloneDeep","standardMetadata","post","updateProvider","put"],"sources":["api/Saml2Api.ts"],"sourcesContent":["import util from 'util';\nimport _ from 'lodash';\nimport { generateAmApi } from './BaseApi';\nimport { getCurrentRealmPath } from './utils/ApiUtils';\nimport storage from '../storage/SessionStorage';\n\nconst providerByLocationAndIdURLTemplate = '%s/json%s/realm-config/saml2/%s/%s';\nconst createHostedProviderURLTemplate =\n '%s/json%s/realm-config/saml2/hosted/?_action=create';\nconst createRemoteProviderURLTemplate =\n '%s/json%s/realm-config/saml2/remote/?_action=importEntity';\nconst queryAllProvidersURLTemplate =\n '%s/json%s/realm-config/saml2?_queryFilter=true';\nconst queryProvidersByEntityIdURLTemplate =\n '%s/json%s/realm-config/saml2?_queryFilter=%s&_fields=%s';\nconst metadataByEntityIdURLTemplate =\n '%s/saml2/jsp/exportmetadata.jsp?entityid=%s&realm=%s';\nconst apiVersion = 'protocol=2.1,resource=1.0';\nconst getApiConfig = () => {\n const configPath = getCurrentRealmPath();\n return {\n path: `${configPath}/realm-config/saml2`,\n apiVersion,\n };\n};\n\n/**\n * Get all SAML2 entity providers\n * @returns {Promise} a promise that resolves to an array of saml2 entity stubs\n */\nexport async function getProviders() {\n const urlString = util.format(\n queryAllProvidersURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath()\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Find all providers matching the filter and return the requested fields\n * @param {string} filter CREST filter string, eg \"entityId+eq+'${entityId}'\"\n * @param {string} fields Comma-delimited list of fields to include in the response\n * @returns {Promise} a promise that resolves to an object containing an array of saml2 entities\n */\nexport async function findProviders(filter = 'true', fields = '*') {\n const urlString = util.format(\n queryProvidersByEntityIdURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath(),\n encodeURIComponent(filter),\n fields\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function getProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n const urlString = util.format(\n providerByLocationAndIdURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath(),\n location,\n entityId64\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get SAML2 entity provider by entity id\n * @param {string} entityId Provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object or null\n */\nexport async function getProvider(entityId) {\n const response = await findProviders(`entityId eq '${entityId}'`, 'location');\n switch (response.resultCount) {\n case 0:\n throw new Error(`No provider with entity id '${entityId}' found`);\n case 1: {\n const { location } = response.result[0];\n const id = response.result[0]._id;\n return getProviderByLocationAndId(location, id);\n }\n default:\n throw new Error(`Multiple providers with entity id '${entityId}' found`);\n }\n}\n\n/**\n * Get a SAML2 entity provider's metadata URL by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {string} the URL to get the metadata from\n */\nexport function getProviderMetadataUrl(entityId) {\n return util.format(\n metadataByEntityIdURLTemplate,\n storage.session.getTenant(),\n encodeURIComponent(entityId),\n storage.session.getRealm()\n );\n}\n\n/**\n * Get a SAML2 entity provider's metadata by entity id\n * @param {String} entityId SAML2 entity id\n * @returns {Promise} a promise that resolves to an object containing a SAML2 metadata\n */\nexport async function getProviderMetadata(entityId) {\n const { data } = await generateAmApi(getApiConfig()).get(\n getProviderMetadataUrl(entityId),\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Create a SAML2 entity provider\n * @param {String} location 'hosted' or 'remote'\n * @param {Object} providerData Object representing a SAML entity provider\n * @param {String} metaData Base64-encoded metadata XML. Only required for remote providers\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function createProvider(location, providerData, metaData) {\n let postData = _.cloneDeep(providerData);\n let urlString = util.format(\n createHostedProviderURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath()\n );\n\n if (location === 'remote') {\n /**\n * Remote entity providers must be created using XML metadata\n */\n urlString = util.format(\n createRemoteProviderURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath()\n );\n postData = {\n standardMetadata: metaData,\n };\n }\n\n const { data } = await generateAmApi(getApiConfig()).post(\n urlString,\n postData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Update SAML2 entity provider\n * @param {String} location Entity provider location (hosted or remote)\n * @param {Object} providerData Object representing a SAML entity provider\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function updateProvider(location, providerData) {\n const urlString = util.format(\n providerByLocationAndIdURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath(),\n location,\n providerData._id\n );\n const { data } = await generateAmApi(getApiConfig()).put(\n urlString,\n providerData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;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AGC,aAAA,CAAKC,MAAL,CAChBd,kCADgB,EAEhBe,uBAAA,CAAQC,OAAR,CAAgBC,SAAhB,EAFgB,EAGhB,IAAAR,6BAAA,GAHgB,EAIhBkB,QAJgB,EAKhBc,YAAY,CAACL,GALG,CAAlB;;IAOA,IAAM;MAAElB;IAAF,UAAiB,IAAAC,sBAAA,EAAcZ,YAAY,EAA1B,EAA8B0C,GAA9B,CACrBrC,SADqB,EAErB6B,YAFqB,EAGrB;MACEpB,eAAe,EAAE;IADnB,CAHqB,CAAvB;IAOA,OAAOH,IAAP;EACD,C"}
1
+ {"version":3,"file":"Saml2Api.js","names":["providerByLocationAndIdURLTemplate","createHostedProviderURLTemplate","createRemoteProviderURLTemplate","queryAllProvidersURLTemplate","queryProvidersByEntityIdURLTemplate","metadataByEntityIdURLTemplate","apiVersion","getApiConfig","configPath","getCurrentRealmPath","path","getProviders","urlString","util","format","storage","session","getTenant","data","generateAmApi","get","withCredentials","findProviders","filter","fields","encodeURIComponent","getProviderByLocationAndId","location","entityId64","getProvider","entityId","response","resultCount","Error","result","id","_id","getProviderMetadataUrl","getRealm","getProviderMetadata","createProvider","providerData","metaData","postData","_","cloneDeep","standardMetadata","post","updateProvider","put"],"sources":["api/Saml2Api.ts"],"sourcesContent":["import util from 'util';\nimport _ from 'lodash';\nimport { generateAmApi } from './BaseApi';\nimport { getCurrentRealmPath } from './utils/ApiUtils';\nimport storage from '../storage/SessionStorage';\n\nconst providerByLocationAndIdURLTemplate = '%s/json%s/realm-config/saml2/%s/%s';\nconst createHostedProviderURLTemplate =\n '%s/json%s/realm-config/saml2/hosted/?_action=create';\nconst createRemoteProviderURLTemplate =\n '%s/json%s/realm-config/saml2/remote/?_action=importEntity';\nconst queryAllProvidersURLTemplate =\n '%s/json%s/realm-config/saml2?_queryFilter=true';\nconst queryProvidersByEntityIdURLTemplate =\n '%s/json%s/realm-config/saml2?_queryFilter=%s&_fields=%s';\nconst metadataByEntityIdURLTemplate =\n '%s/saml2/jsp/exportmetadata.jsp?entityid=%s&realm=%s';\nconst apiVersion = 'protocol=2.1,resource=1.0';\nconst getApiConfig = () => {\n const configPath = getCurrentRealmPath();\n return {\n path: `${configPath}/realm-config/saml2`,\n apiVersion,\n };\n};\n\n/**\n * Get all SAML2 entity providers\n * @returns {Promise} a promise that resolves to an array of saml2 entity stubs\n */\nexport async function getProviders() {\n const urlString = util.format(\n queryAllProvidersURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath()\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Find all providers matching the filter and return the requested fields\n * @param {string} filter CREST filter string, eg \"entityId+eq+'${entityId}'\" or \"true\" for all providers\n * @param {string} fields Comma-delimited list of fields to include in the response\n * @returns {Promise} a promise that resolves to an object containing an array of saml2 entities\n */\nexport async function findProviders(filter = 'true', fields = '*') {\n const urlString = util.format(\n queryProvidersByEntityIdURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath(),\n encodeURIComponent(filter),\n fields\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Geta SAML2 entity provider by location and id\n * @param {string} location Entity provider location (hosted or remote)\n * @param {string} entityId64 Base64-encoded provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function getProviderByLocationAndId(\n location: string,\n entityId64: string\n) {\n const urlString = util.format(\n providerByLocationAndIdURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath(),\n location,\n entityId64\n );\n const { data } = await generateAmApi(getApiConfig()).get(urlString, {\n withCredentials: true,\n });\n return data;\n}\n\n/**\n * Get SAML2 entity provider by entity id\n * @param {string} entityId Provider entity id\n * @returns {Promise} a promise that resolves to a saml2 entity provider object or null\n */\nexport async function getProvider(entityId) {\n const response = await findProviders(`entityId eq '${entityId}'`, 'location');\n switch (response.resultCount) {\n case 0:\n throw new Error(`No provider with entity id '${entityId}' found`);\n case 1: {\n const { location } = response.result[0];\n const id = response.result[0]._id;\n return getProviderByLocationAndId(location, id);\n }\n default:\n throw new Error(`Multiple providers with entity id '${entityId}' found`);\n }\n}\n\n/**\n * Get a SAML2 entity provider's metadata URL by entity id\n * @param {string} entityId SAML2 entity id\n * @returns {string} the URL to get the metadata from\n */\nexport function getProviderMetadataUrl(entityId) {\n return util.format(\n metadataByEntityIdURLTemplate,\n storage.session.getTenant(),\n encodeURIComponent(entityId),\n storage.session.getRealm()\n );\n}\n\n/**\n * Get a SAML2 entity provider's metadata by entity id\n * @param {String} entityId SAML2 entity id\n * @returns {Promise} a promise that resolves to an object containing a SAML2 metadata\n */\nexport async function getProviderMetadata(entityId) {\n const { data } = await generateAmApi(getApiConfig()).get(\n getProviderMetadataUrl(entityId),\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Create a SAML2 entity provider\n * @param {String} location 'hosted' or 'remote'\n * @param {Object} providerData Object representing a SAML entity provider\n * @param {String} metaData Base64-encoded metadata XML. Only required for remote providers\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function createProvider(location, providerData, metaData) {\n let postData = _.cloneDeep(providerData);\n let urlString = util.format(\n createHostedProviderURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath()\n );\n\n if (location === 'remote') {\n /**\n * Remote entity providers must be created using XML metadata\n */\n urlString = util.format(\n createRemoteProviderURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath()\n );\n postData = {\n standardMetadata: metaData,\n };\n }\n\n const { data } = await generateAmApi(getApiConfig()).post(\n urlString,\n postData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n\n/**\n * Update SAML2 entity provider\n * @param {String} location Entity provider location (hosted or remote)\n * @param {Object} providerData Object representing a SAML entity provider\n * @returns {Promise} a promise that resolves to a saml2 entity provider object\n */\nexport async function updateProvider(location, providerData) {\n const urlString = util.format(\n providerByLocationAndIdURLTemplate,\n storage.session.getTenant(),\n getCurrentRealmPath(),\n location,\n providerData._id\n );\n const { data } = await generateAmApi(getApiConfig()).put(\n urlString,\n providerData,\n {\n withCredentials: true,\n }\n );\n return data;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,kCAAkC,GAAG,oCAA3C;AACA,IAAMC,+BAA+B,GACnC,qDADF;AAEA,IAAMC,+BAA+B,GACnC,2DADF;AAEA,IAAMC,4BAA4B,GAChC,gDADF;AAEA,IAAMC,mCAAmC,GACvC,yDADF;AAEA,IAAMC,6BAA6B,GACjC,sDADF;AAEA,IAAMC,UAAU,GAAG,2BAAnB;;AACA,IAAMC,YAAY,GAAG,MAAM;EACzB,IAAMC,UAAU,GAAG,IAAAC,6BAAA,GAAnB;EACA,OAAO;IACLC,IAAI,YAAKF,UAAL,wBADC;IAELF;EAFK,CAAP;AAID,CAND;AAQA;AACA;AACA;AACA;;;SACsBK,Y;;;AAYtB;AACA;AACA;AACA;AACA;AACA;;;;oCAjBO,aAA8B;IACnC,IAAMC,SAAS,GAAGC,aAAA,CAAKC,MAAL,CAChBX,4BADgB,EAEhBY,uBAAA,CAAQC,OAAR,CAAgBC,SAAhB,EAFgB,EAGhB,IAAAR,6BAAA,GAHgB,CAAlB;;IAKA,IAAM;MAAES;IAAF,UAAiB,IAAAC,sBAAA,EAAcZ,YAAY,EAA1B,EAA8Ba,GAA9B,CAAkCR,SAAlC,EAA6C;MAClES,eAAe,EAAE;IADiD,CAA7C,CAAvB;IAGA,OAAOH,IAAP;EACD,C;;;;SAQqBI,a;;;AActB;AACA;AACA;AACA;AACA;AACA;;;;qCAnBO,aAA4D;IAAA,IAA/BC,MAA+B,uEAAtB,MAAsB;IAAA,IAAdC,MAAc,uEAAL,GAAK;;IACjE,IAAMZ,SAAS,GAAGC,aAAA,CAAKC,MAAL,CAChBV,mCADgB,EAEhBW,uBAAA,CAAQC,OAAR,CAAgBC,SAAhB,EAFgB,EAGhB,IAAAR,6BAAA,GAHgB,EAIhBgB,kBAAkB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;IADnB,CAHqB,CAAvB;IAOA,OAAOH,IAAP;EACD,C;;;;SAQqB8B,c;;;;;sCAAf,WAA8BrB,QAA9B,EAAwCc,YAAxC,EAAsD;IAC3D,IAAM7B,SAAS,GAAGC,aAAA,CAAKC,MAAL,CAChBd,kCADgB,EAEhBe,uBAAA,CAAQC,OAAR,CAAgBC,SAAhB,EAFgB,EAGhB,IAAAR,6BAAA,GAHgB,EAIhBkB,QAJgB,EAKhBc,YAAY,CAACL,GALG,CAAlB;;IAOA,IAAM;MAAElB;IAAF,UAAiB,IAAAC,sBAAA,EAAcZ,YAAY,EAA1B,EAA8B0C,GAA9B,CACrBrC,SADqB,EAErB6B,YAFqB,EAGrB;MACEpB,eAAe,EAAE;IADnB,CAHqB,CAAvB;IAOA,OAAOH,IAAP;EACD,C"}
@@ -10,31 +10,23 @@ exports.getRealmName = getRealmName;
10
10
  exports.getTenantURL = getTenantURL;
11
11
  exports.parseUrl = parseUrl;
12
12
 
13
- var _util = _interopRequireDefault(require("util"));
14
-
15
13
  var _SessionStorage = _interopRequireDefault(require("../../storage/SessionStorage"));
16
14
 
17
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
16
 
19
- var realmPathTemplate = '/realms/%s';
20
17
  /**
21
18
  * Get current realm path
22
19
  * @returns {String} a CREST-compliant realm path, e.g. /realms/root/realms/alpha
23
20
  */
24
-
25
21
  function getCurrentRealmPath() {
26
22
  var realm = _SessionStorage.default.session.getRealm();
27
23
 
28
- if (realm.startsWith('/') && realm.length > 1) {
24
+ if (realm.startsWith('/')) {
29
25
  realm = realm.substring(1);
30
26
  }
31
27
 
32
- var realmPath = _util.default.format(realmPathTemplate, 'root');
33
-
34
- if (realm !== '/') {
35
- realmPath += _util.default.format(realmPathTemplate, realm);
36
- }
37
-
28
+ var elements = ['root'].concat(realm.split('/').filter(element => element !== ''));
29
+ var realmPath = "/realms/".concat(elements.join('/realms/'));
38
30
  return realmPath;
39
31
  }
40
32
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ApiUtils.js","names":["realmPathTemplate","getCurrentRealmPath","realm","storage","session","getRealm","startsWith","length","substring","realmPath","util","format","getCurrentRealmName","components","split","realmName","getRealmName","getTenantURL","tenant","parsedUrl","URL","protocol","host","deleteDeepByKey","object","obj","keys","Object","key","indexOf","parseUrl","href","m","match","r","hash","hostname","origin","pathname","port","search","username","password","searchParam","toUpperCase","query","substr","vars","i","pair","decodeURIComponent"],"sources":["api/utils/ApiUtils.ts"],"sourcesContent":["import util from 'util';\nimport storage from '../../storage/SessionStorage';\n\nconst realmPathTemplate = '/realms/%s';\n\n/**\n * Get current realm path\n * @returns {String} a CREST-compliant realm path, e.g. /realms/root/realms/alpha\n */\nexport function getCurrentRealmPath() {\n let realm = storage.session.getRealm();\n if (realm.startsWith('/') && realm.length > 1) {\n realm = realm.substring(1);\n }\n let realmPath = util.format(realmPathTemplate, 'root');\n if (realm !== '/') {\n realmPath += util.format(realmPathTemplate, realm);\n }\n return realmPath;\n}\n\n/**\n * Get current realm name\n * @returns {String} name of the current realm. /alpha -> alpha\n */\nexport function getCurrentRealmName() {\n const realm = storage.session.getRealm();\n const components = realm.split('/');\n let realmName = '/';\n if (components.length > 0 && realmName !== realm) {\n realmName = components[components.length - 1];\n }\n return realmName;\n}\n\n/**\n * Get current realm name\n * @param {String} realm realm\n * @returns {String} name of the realm. /alpha -> alpha\n */\nexport function getRealmName(realm) {\n const components = realm.split('/');\n let realmName = '/';\n if (components.length > 0 && realmName !== realm) {\n realmName = components[components.length - 1];\n }\n return realmName;\n}\n\n/**\n * Get tenant base URL\n * @param {String} tenant tenant URL with path and query params\n * @returns {String} tenant base URL without path and query params\n */\nexport function getTenantURL(tenant) {\n const parsedUrl = new URL(tenant);\n return `${parsedUrl.protocol}//${parsedUrl.host}`;\n}\n\n/**\n * Deep delete keys and their values from an input object. If a key in object contains substring, the key an its value is deleted.\n * @param {Object} object input object that needs keys removed\n * @param {String} substring substring to search for in key\n * @returns the modified object without the matching keys and their values\n */\nexport function deleteDeepByKey(object, substring) {\n const obj = object;\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (key.indexOf(substring) > 0) {\n delete obj[key];\n } else if (Object(obj[key]) === obj[key]) {\n obj[key] = deleteDeepByKey(obj[key], substring);\n }\n }\n return obj;\n}\n\n/*\n * Parse a URL into its components and make them easily accessible by name\n *\n * Use in a Scripte Decision Node Script as follows:\n * var referer = parseUrl(requestHeaders.get(\"referer\").get(0));\n * var origin = referer.origin;\n *\n * e.g.: https://openam-volker-dev.forgeblocks.com/am/XUI/?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim#/\n * {\n * hash: '#/',\n * host: 'openam-volker-dev.forgeblocks.com',\n * hostname: 'openam-volker-dev.forgeblocks.com',\n * href: 'https://openam-volker-dev.forgeblocks.com/am/XUI/?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim#/',\n * origin: 'https://openam-volker-dev.forgeblocks.com',\n * pathname: '/am/XUI/',\n * port: '',\n * protocol: 'https',\n * search: '?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim',\n * username: '',\n * password: '',\n * searchParam: {\n * realm: '/bravo',\n * authIndexType: 'service',\n * authIndexValue: 'InitiateOwnerClaim'\n * }\n * }\n */\nexport function parseUrl(href) {\n const m = href.match(\n /^(([^:/?#]+):?(?:\\/\\/((?:([^/?#:]*):([^/?#:]*)@)?([^/?#:]*)(?::([^/?#:]*))?)))?([^?#]*)(\\?[^#]*)?(#.*)?$/\n ),\n r = {\n hash: m[10] || '', // #/\n host: m[3] || '', // openam-volker-dev.forgeblocks.com\n hostname: m[6] || '', // openam-volker-dev.forgeblocks.com\n href: m[0] || '', // https://openam-volker-dev.forgeblocks.com/am/XUI/?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim#/\n origin: m[1] || '', // https://openam-volker-dev.forgeblocks.com\n pathname: m[8] || (m[1] ? '/' : ''), // /am/XUI/\n port: m[7] || '', //\n protocol: m[2] || '', // https\n search: m[9] || '', // ?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim\n username: m[4] || '', //\n password: m[5] || '', //\n searchParam: {}, // { realm: '/bravo',\n // authIndexType: 'service',\n // authIndexValue: 'InitiateOwnerClaim' }\n };\n if (r.protocol.length == 2) {\n r.protocol = 'file:///' + r.protocol.toUpperCase();\n r.origin = r.protocol + '//' + r.host;\n }\n if (r.search.length > 2) {\n const query = r.search.indexOf('?') === 0 ? r.search.substr(1) : r.search;\n const vars = query.split('&');\n for (let i = 0; i < vars.length; i++) {\n const pair = vars[i].split('=');\n r.searchParam[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);\n }\n }\n r.href = r.origin + r.pathname + r.search + r.hash;\n return r;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;;;AAEA,IAAMA,iBAAiB,GAAG,YAA1B;AAEA;AACA;AACA;AACA;;AACO,SAASC,mBAAT,GAA+B;EACpC,IAAIC,KAAK,GAAGC,uBAAA,CAAQC,OAAR,CAAgBC,QAAhB,EAAZ;;EACA,IAAIH,KAAK,CAACI,UAAN,CAAiB,GAAjB,KAAyBJ,KAAK,CAACK,MAAN,GAAe,CAA5C,EAA+C;IAC7CL,KAAK,GAAGA,KAAK,CAACM,SAAN,CAAgB,CAAhB,CAAR;EACD;;EACD,IAAIC,SAAS,GAAGC,aAAA,CAAKC,MAAL,CAAYX,iBAAZ,EAA+B,MAA/B,CAAhB;;EACA,IAAIE,KAAK,KAAK,GAAd,EAAmB;IACjBO,SAAS,IAAIC,aAAA,CAAKC,MAAL,CAAYX,iBAAZ,EAA+BE,KAA/B,CAAb;EACD;;EACD,OAAOO,SAAP;AACD;AAED;AACA;AACA;AACA;;;AACO,SAASG,mBAAT,GAA+B;EACpC,IAAMV,KAAK,GAAGC,uBAAA,CAAQC,OAAR,CAAgBC,QAAhB,EAAd;;EACA,IAAMQ,UAAU,GAAGX,KAAK,CAACY,KAAN,CAAY,GAAZ,CAAnB;EACA,IAAIC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AA4B;IAC1B2B,CAAC,CAACb,QAAF,GAAa,aAAaa,CAAC,CAACb,QAAF,CAAWuB,WAAX,EAA1B;IACAV,CAAC,CAACG,MAAF,GAAWH,CAAC,CAACb,QAAF,GAAa,IAAb,GAAoBa,CAAC,CAACZ,IAAjC;EACD;;EACD,IAAIY,CAAC,CAACM,MAAF,CAASjC,MAAT,GAAkB,CAAtB,EAAyB;IACvB,IAAMsC,KAAK,GAAGX,CAAC,CAACM,MAAF,CAASX,OAAT,CAAiB,GAAjB,MAA0B,CAA1B,GAA8BK,CAAC,CAACM,MAAF,CAASM,MAAT,CAAgB,CAAhB,CAA9B,GAAmDZ,CAAC,CAACM,MAAnE;IACA,IAAMO,IAAI,GAAGF,KAAK,CAAC/B,KAAN,CAAY,GAAZ,CAAb;;IACA,KAAK,IAAIkC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,IAAI,CAACxC,MAAzB,EAAiCyC,CAAC,EAAlC,EAAsC;MACpC,IAAMC,IAAI,GAAGF,IAAI,CAACC,CAAD,CAAJ,CAAQlC,KAAR,CAAc,GAAd,CAAb;MACAoB,CAAC,CAACS,WAAF,CAAcO,kBAAkB,CAACD,IAAI,CAAC,CAAD,CAAL,CAAhC,IAA6CC,kBAAkB,CAACD,IAAI,CAAC,CAAD,CAAL,CAA/D;IACD;EACF;;EACDf,CAAC,CAACH,IAAF,GAASG,CAAC,CAACG,MAAF,GAAWH,CAAC,CAACI,QAAb,GAAwBJ,CAAC,CAACM,MAA1B,GAAmCN,CAAC,CAACC,IAA9C;EACA,OAAOD,CAAP;AACD"}
1
+ {"version":3,"file":"ApiUtils.js","names":["getCurrentRealmPath","realm","storage","session","getRealm","startsWith","substring","elements","concat","split","filter","element","realmPath","join","getCurrentRealmName","components","realmName","length","getRealmName","getTenantURL","tenant","parsedUrl","URL","protocol","host","deleteDeepByKey","object","obj","keys","Object","key","indexOf","parseUrl","href","m","match","r","hash","hostname","origin","pathname","port","search","username","password","searchParam","toUpperCase","query","substr","vars","i","pair","decodeURIComponent"],"sources":["api/utils/ApiUtils.ts"],"sourcesContent":["import storage from '../../storage/SessionStorage';\n\n/**\n * Get current realm path\n * @returns {String} a CREST-compliant realm path, e.g. /realms/root/realms/alpha\n */\nexport function getCurrentRealmPath() {\n let realm = storage.session.getRealm();\n if (realm.startsWith('/')) {\n realm = realm.substring(1);\n }\n const elements = ['root'].concat(\n realm.split('/').filter((element) => element !== '')\n );\n const realmPath = `/realms/${elements.join('/realms/')}`;\n return realmPath;\n}\n\n/**\n * Get current realm name\n * @returns {String} name of the current realm. /alpha -> alpha\n */\nexport function getCurrentRealmName() {\n const realm = storage.session.getRealm();\n const components = realm.split('/');\n let realmName = '/';\n if (components.length > 0 && realmName !== realm) {\n realmName = components[components.length - 1];\n }\n return realmName;\n}\n\n/**\n * Get current realm name\n * @param {String} realm realm\n * @returns {String} name of the realm. /alpha -> alpha\n */\nexport function getRealmName(realm) {\n const components = realm.split('/');\n let realmName = '/';\n if (components.length > 0 && realmName !== realm) {\n realmName = components[components.length - 1];\n }\n return realmName;\n}\n\n/**\n * Get tenant base URL\n * @param {String} tenant tenant URL with path and query params\n * @returns {String} tenant base URL without path and query params\n */\nexport function getTenantURL(tenant) {\n const parsedUrl = new URL(tenant);\n return `${parsedUrl.protocol}//${parsedUrl.host}`;\n}\n\n/**\n * Deep delete keys and their values from an input object. If a key in object contains substring, the key an its value is deleted.\n * @param {Object} object input object that needs keys removed\n * @param {String} substring substring to search for in key\n * @returns the modified object without the matching keys and their values\n */\nexport function deleteDeepByKey(object, substring) {\n const obj = object;\n const keys = Object.keys(obj);\n for (const key of keys) {\n if (key.indexOf(substring) > 0) {\n delete obj[key];\n } else if (Object(obj[key]) === obj[key]) {\n obj[key] = deleteDeepByKey(obj[key], substring);\n }\n }\n return obj;\n}\n\n/*\n * Parse a URL into its components and make them easily accessible by name\n *\n * Use in a Scripte Decision Node Script as follows:\n * var referer = parseUrl(requestHeaders.get(\"referer\").get(0));\n * var origin = referer.origin;\n *\n * e.g.: https://openam-volker-dev.forgeblocks.com/am/XUI/?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim#/\n * {\n * hash: '#/',\n * host: 'openam-volker-dev.forgeblocks.com',\n * hostname: 'openam-volker-dev.forgeblocks.com',\n * href: 'https://openam-volker-dev.forgeblocks.com/am/XUI/?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim#/',\n * origin: 'https://openam-volker-dev.forgeblocks.com',\n * pathname: '/am/XUI/',\n * port: '',\n * protocol: 'https',\n * search: '?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim',\n * username: '',\n * password: '',\n * searchParam: {\n * realm: '/bravo',\n * authIndexType: 'service',\n * authIndexValue: 'InitiateOwnerClaim'\n * }\n * }\n */\nexport function parseUrl(href) {\n const m = href.match(\n /^(([^:/?#]+):?(?:\\/\\/((?:([^/?#:]*):([^/?#:]*)@)?([^/?#:]*)(?::([^/?#:]*))?)))?([^?#]*)(\\?[^#]*)?(#.*)?$/\n ),\n r = {\n hash: m[10] || '', // #/\n host: m[3] || '', // openam-volker-dev.forgeblocks.com\n hostname: m[6] || '', // openam-volker-dev.forgeblocks.com\n href: m[0] || '', // https://openam-volker-dev.forgeblocks.com/am/XUI/?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim#/\n origin: m[1] || '', // https://openam-volker-dev.forgeblocks.com\n pathname: m[8] || (m[1] ? '/' : ''), // /am/XUI/\n port: m[7] || '', //\n protocol: m[2] || '', // https\n search: m[9] || '', // ?realm=/bravo&authIndexType=service&authIndexValue=InitiateOwnerClaim\n username: m[4] || '', //\n password: m[5] || '', //\n searchParam: {}, // { realm: '/bravo',\n // authIndexType: 'service',\n // authIndexValue: 'InitiateOwnerClaim' }\n };\n if (r.protocol.length == 2) {\n r.protocol = 'file:///' + r.protocol.toUpperCase();\n r.origin = r.protocol + '//' + r.host;\n }\n if (r.search.length > 2) {\n const query = r.search.indexOf('?') === 0 ? r.search.substr(1) : r.search;\n const vars = query.split('&');\n for (let i = 0; i < vars.length; i++) {\n const pair = vars[i].split('=');\n r.searchParam[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);\n }\n }\n r.href = r.origin + r.pathname + r.search + r.hash;\n return r;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;;;;AAEA;AACA;AACA;AACA;AACO,SAASA,mBAAT,GAA+B;EACpC,IAAIC,KAAK,GAAGC,uBAAA,CAAQC,OAAR,CAAgBC,QAAhB,EAAZ;;EACA,IAAIH,KAAK,CAACI,UAAN,CAAiB,GAAjB,CAAJ,EAA2B;IACzBJ,KAAK,GAAGA,KAAK,CAACK,SAAN,CAAgB,CAAhB,CAAR;EACD;;EACD,IAAMC,QAAQ,GAAG,CAAC,MAAD,EAASC,MAAT,CACfP,KAAK,CAACQ,KAAN,CAAY,GAAZ,EAAiBC,MAAjB,CAAyBC,OAAD,IAAaA,OAAO,KAAK,EAAjD,CADe,CAAjB;EAGA,IAAMC,SAAS,qBAAcL,QAAQ,CAACM,IAAT,CAAc,UAAd,CAAd,CAAf;EACA,OAAOD,SAAP;AACD;AAED;AACA;AACA;AACA;;;AACO,SAASE,mBAAT,GAA+B;EACpC,IAAMb,KAAK,GAAGC,uBAAA,CAAQC,OAAR,CAAgBC,QAAhB,EAAd;;EACA,IAAMW,UAAU,GAAGd,KAAK,CAACQ,KAAN,CAAY,GAAZ,CAAnB;EACA,IAAIO,SAAS,GAAG,GAAhB;;EACA,IAAID,UAAU,CAACE,MAAX,GAAoB,CAApB,IAAyBD,SAAS,KAAKf,KAA3C,EAAkD;IAChDe,SAAS,GAAGD,UAAU,CAACA,UAAU,CAACE,MAAX,GAAoB,CAArB,CAAtB;EACD;;EACD,OAAOD,SAAP;AACD;AAED;AACA;AACA;AACA;AACA;;;AACO,SAASE,YAAT,CAAsBjB,KAAtB,EAA6B;EAClC,IAAMc,UAAU,GAAGd,KAAK,CAACQ,KAAN,CAAY,GAAZ,CAAnB;EACA,IAAIO,SAAS,GAAG,GAA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M,MAAT,CAAgB,CAAhB,CAA9B,GAAmDZ,CAAC,CAACM,MAAnE;IACA,IAAMO,IAAI,GAAGF,KAAK,CAACtC,KAAN,CAAY,GAAZ,CAAb;;IACA,KAAK,IAAIyC,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGD,IAAI,CAAChC,MAAzB,EAAiCiC,CAAC,EAAlC,EAAsC;MACpC,IAAMC,IAAI,GAAGF,IAAI,CAACC,CAAD,CAAJ,CAAQzC,KAAR,CAAc,GAAd,CAAb;MACA2B,CAAC,CAACS,WAAF,CAAcO,kBAAkB,CAACD,IAAI,CAAC,CAAD,CAAL,CAAhC,IAA6CC,kBAAkB,CAACD,IAAI,CAAC,CAAD,CAAL,CAA/D;IACD;EACF;;EACDf,CAAC,CAACH,IAAF,GAASG,CAAC,CAACG,MAAF,GAAWH,CAAC,CAACI,QAAb,GAAwBJ,CAAC,CAACM,MAA1B,GAAmCN,CAAC,CAACC,IAA9C;EACA,OAAOD,CAAP;AACD"}
@@ -1 +1 @@
1
- {"version":3,"file":"ApiUtils.test.js","names":["test","skip","expect","toBe","REALM_PATH","sessionStorage","session","setItem","testString","getCurrentRealmPath","URL_WITH_TENANT","parsed","getTenantURL","trap","toThrow"],"sources":["api/utils/ApiUtils.test.ts"],"sourcesContent":["import { getCurrentRealmPath, getTenantURL } from './ApiUtils';\nimport sessionStorage from '../../storage/SessionStorage';\n\ntest.skip('replaceAll should be deleted because it works like native String.replaceAll', () => {\n // Arrange\n // Act\n // Assert\n expect(true).toBe(false);\n});\n\ntest('getCurrentRealmPath should prepend realmPath to specified realm', () => {\n // Arrange\n const REALM_PATH = 'alpha';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root/realms/alpha');\n});\n\ntest('getCurrentRealmPath should prepend realmPath to specified realm with leading slash', () => {\n // Arrange\n const REALM_PATH = '/alpha';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root/realms/alpha');\n});\n\ntest('getCurrentRealmPath \"/\" should resolve to root', () => {\n // Arrange\n const REALM_PATH = '/';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root');\n});\n\ntest('getCurrentRealmPath should not handle multiple leading slash', () => {\n // Arrange\n const REALM_PATH = '//alpha';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root/realms//alpha');\n});\n\ntest('getCurrentRealmPath should not handle nested depth realms', () => {\n // Arrange\n const REALM_PATH = '/alpha/erm';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root/realms/alpha/erm');\n});\n\ntest('getTenantURL should parse the https protocol and the hostname', () => {\n // Arrange\n const URL_WITH_TENANT =\n 'https://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';\n\n // Act\n const parsed = getTenantURL(URL_WITH_TENANT);\n\n // Assert\n expect(parsed).toBe('https://example.frodo.com');\n});\n\ntest('getTenantURL should not validate protocol', () => {\n // Arrange\n const URL_WITH_TENANT =\n 'ftp://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';\n // Act\n const parsed = getTenantURL(URL_WITH_TENANT);\n // Assert\n expect(parsed).toBe('ftp://example.frodo.com');\n});\n\ntest('getTenantURL Invalid URL should throw', () => {\n // Arrange\n const URL_WITH_TENANT =\n '//:example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';\n // Act\n const trap = () => {\n getTenantURL(URL_WITH_TENANT);\n };\n // Assert\n expect(trap).toThrow('Invalid URL');\n});\n"],"mappings":";;AAAA;;AACA;;;;AAEAA,IAAI,CAACC,IAAL,CAAU,6EAAV,EAAyF,MAAM;EAC7F;EACA;EACA;EACAC,MAAM,CAAC,IAAD,CAAN,CAA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AwB,4BAAxB;AACD,CARG,CAAJ;AAUAH,IAAI,CAAC,2DAAD,EAA8D,MAAM;EACtE;EACA,IAAMI,UAAU,GAAG,YAAnB;;EACAC,uBAAA,CAAeC,OAAf,CAAuBC,OAAvB,CAA+B,OAA/B,EAAwCH,UAAxC,EAHsE,CAItE;;;EACA,IAAMI,UAAU,GAAG,IAAAC,6BAAA,GAAnB,CALsE,CAMtE;;EACAP,MAAM,CAACM,UAAD,CAAN,CAAmBL,IAAnB,CAAwB,+BAAxB;AACD,CARG,CAAJ;AAUAH,IAAI,CAAC,+DAAD,EAAkE,MAAM;EAC1E;EACA,IAAMU,eAAe,GACnB,kEADF,CAF0E,CAK1E;;EACA,IAAMC,MAAM,GAAG,IAAAC,sBAAA,EAAaF,eAAb,CAAf,CAN0E,CAQ1E;;EACAR,MAAM,CAACS,MAAD,CAAN,CAAeR,IAAf,CAAoB,2BAApB;AACD,CAVG,CAAJ;AAYAH,IAAI,CAAC,2CAAD,EAA8C,MAAM;EACtD;EACA,IAAMU,eAAe,GACnB,gEADF,CAFsD,CAItD;;EACA,IAAMC,MAAM,GAAG,IAAAC,sBAAA,EAAaF,eAAb,CAAf,CALsD,CAMtD;;EACAR,MAAM,CAACS,MAAD,CAAN,CAAeR,IAAf,CAAoB,yBAApB;AACD,CARG,CAAJ;AAUAH,IAAI,CAAC,uCAAD,EAA0C,MAAM;EAClD;EACA,IAAMU,eAAe,GACnB,6DADF,CAFkD,CAIlD;;EACA,IAAMG,IAAI,GAAG,MAAM;IACjB,IAAAD,sBAAA,EAAaF,eAAb;EACD,CAFD,CALkD,CAQlD;;;EACAR,MAAM,CAACW,IAAD,CAAN,CAAaC,OAAb,CAAqB,aAArB;AACD,CAVG,CAAJ"}
1
+ {"version":3,"file":"ApiUtils.test.js","names":["test","skip","expect","toBe","REALM_PATH","sessionStorage","session","setItem","testString","getCurrentRealmPath","URL_WITH_TENANT","parsed","getTenantURL","trap","toThrow"],"sources":["api/utils/ApiUtils.test.ts"],"sourcesContent":["import { getCurrentRealmPath, getTenantURL } from './ApiUtils';\nimport sessionStorage from '../../storage/SessionStorage';\n\ntest.skip('replaceAll should be deleted because it works like native String.replaceAll', () => {\n // Arrange\n // Act\n // Assert\n expect(true).toBe(false);\n});\n\ntest('getCurrentRealmPath should prepend realmPath to specified realm', () => {\n // Arrange\n const REALM_PATH = 'alpha';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root/realms/alpha');\n});\n\ntest('getCurrentRealmPath should prepend realmPath to specified realm with leading slash', () => {\n // Arrange\n const REALM_PATH = '/alpha';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root/realms/alpha');\n});\n\ntest('getCurrentRealmPath \"/\" should resolve to root', () => {\n // Arrange\n const REALM_PATH = '/';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root');\n});\n\ntest('getCurrentRealmPath should handle multiple leading slashes', () => {\n // Arrange\n const REALM_PATH = '//alpha';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root/realms/alpha');\n});\n\ntest('getCurrentRealmPath should handle nested realms', () => {\n // Arrange\n const REALM_PATH = '/parent/child';\n sessionStorage.session.setItem('realm', REALM_PATH);\n // Act\n const testString = getCurrentRealmPath();\n // Assert\n expect(testString).toBe('/realms/root/realms/parent/realms/child');\n});\n\ntest('getTenantURL should parse the https protocol and the hostname', () => {\n // Arrange\n const URL_WITH_TENANT =\n 'https://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';\n\n // Act\n const parsed = getTenantURL(URL_WITH_TENANT);\n\n // Assert\n expect(parsed).toBe('https://example.frodo.com');\n});\n\ntest('getTenantURL should not validate protocol', () => {\n // Arrange\n const URL_WITH_TENANT =\n 'ftp://example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';\n // Act\n const parsed = getTenantURL(URL_WITH_TENANT);\n // Assert\n expect(parsed).toBe('ftp://example.frodo.com');\n});\n\ntest('getTenantURL Invalid URL should throw', () => {\n // Arrange\n const URL_WITH_TENANT =\n '//:example.frodo.com/am/ui-admin/#realms/%2Falpha/dashboard';\n // Act\n const trap = () => {\n getTenantURL(URL_WITH_TENANT);\n };\n // Assert\n expect(trap).toThrow('Invalid URL');\n});\n"],"mappings":";;AAAA;;AACA;;;;AAEAA,IAAI,CAACC,IAAL,CAAU,6EAAV,EAAyF,MAAM;EAC7F;EACA;EACA;EACAC,MAAM,CAAC,IAAD,CAAN,CAAaC,IAAb,CAAkB,KAAlB;AACD,CALD;AAOAH,IAAI,CAAC,iEAAD,EAAoE,MAAM;EAC5E;EACA,IAAMI,UAAU,GAAG,OAAnB;;EACAC,uBAAA,CAAeC,OAAf,CAAuBC,OAAvB,CAA+B,OAA/B,EAAwCH,UAAxC,EAH4E,CAI5E;;;EACA,IAAMI,UAAU,GAAG,IAAAC,6BAAA,GAAnB,CAL4E,CAM5E;;EACAP,MAAM,CAACM,UAAD,CAAN,CAAmBL,IAAnB,CAAwB,2BAAxB;AACD,CARG,CAAJ;AAUAH,IAAI,CAAC,oFAAD,EAAuF,MAAM;EAC/F;EACA,IAAMI,UAAU,GAAG,QAAnB;;EACAC,uBAAA,CAAeC,OAAf,CAAuBC,OAAvB,CAA+B,OAA/B,EAAwCH,UAAxC,EAH+F,CAI/F;;;EACA,IAAMI,UAAU,GAAG,IAAAC,6BAAA,GAAnB,CAL+F,CAM/F;;EACAP,MAAM,CAACM,UAAD,CAAN,CAAmBL,IAAnB,CAAwB,2BAAxB;AACD,CARG,CAAJ;AAUAH,IAAI,CAAC,gDAAD,EAAmD,MAAM;EAC3D;EACA,IAAMI,UAAU,GAAG,GAAnB;;EACAC,uBAAA,CAAeC,OAAf,CAAuBC,OAAvB,CAA+B,OAA/B,EAAwCH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,yBAApB;AACD,CARG,CAAJ;AAUAH,IAAI,CAAC,uCAAD,EAA0C,MAAM;EAClD;EACA,IAAMU,eAAe,GACnB,6DADF,CAFkD,CAIlD;;EACA,IAAMG,IAAI,GAAG,MAAM;IACjB,IAAAD,sBAAA,EAAaF,eAAb;EACD,CAFD,CALkD,CAQlD;;;EACAR,MAAM,CAACW,IAAD,CAAN,CAAaC,OAAb,CAAqB,aAArB;AACD,CAVG,CAAJ"}
package/cjs/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.VariablesRaw = exports.Variables = exports.Utils = exports.TreeRaw = exports.Theme = exports.StartupRaw = exports.Startup = exports.SecretsRaw = exports.Secrets = exports.Script = exports.Saml2 = exports.Realm = exports.Organization = exports.OAuth2OIDCApi = exports.OAuth2Client = exports.NodeRaw = exports.ManagedObject = exports.Log = exports.Journey = exports.Idp = exports.Idm = exports.EmailTemplate = exports.ConnectionProfile = exports.CirclesOfTrust = exports.Authenticate = exports.Admin = void 0;
6
+ exports.VariablesRaw = exports.Variables = exports.Utils = exports.TypesRaw = exports.Types = exports.TreeRaw = exports.Theme = exports.StartupRaw = exports.Startup = exports.SecretsRaw = exports.Secrets = exports.Script = exports.Saml2 = exports.Realm = exports.Organization = exports.OAuth2OIDCApi = exports.OAuth2Client = exports.NodeRaw = exports.ManagedObject = exports.Log = exports.Journey = exports.Idp = exports.Idm = exports.EmailTemplate = exports.ConnectionProfile = exports.CirclesOfTrust = exports.Authenticate = exports.Admin = void 0;
7
7
  exports.getVersion = getVersion;
8
8
  exports.state = void 0;
9
9
 
@@ -13,6 +13,10 @@ var _path = _interopRequireDefault(require("path"));
13
13
 
14
14
  var _url = require("url");
15
15
 
16
+ var _TypesRaw = _interopRequireWildcard(require("./api/ApiTypes"));
17
+
18
+ exports.TypesRaw = _TypesRaw;
19
+
16
20
  var _NodeRaw = _interopRequireWildcard(require("./api/NodeApi"));
17
21
 
18
22
  exports.NodeRaw = _NodeRaw;
@@ -33,6 +37,10 @@ var _VariablesRaw = _interopRequireWildcard(require("./api/VariablesApi"));
33
37
 
34
38
  exports.VariablesRaw = _VariablesRaw;
35
39
 
40
+ var _Types = _interopRequireWildcard(require("./ops/OpsTypes"));
41
+
42
+ exports.Types = _Types;
43
+
36
44
  var _Admin = _interopRequireWildcard(require("./ops/AdminOps"));
37
45
 
38
46
  exports.Admin = _Admin;
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["__dirname","path","dirname","fileURLToPath","pkg","JSON","parse","fs","readFileSync","resolve","getVersion","version"],"sources":["index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')\n);\n\nexport function getVersion() {\n return `v${pkg.version}`;\n}\n\n// Api Layer\nexport * as NodeRaw from './api/NodeApi';\nexport * as TreeRaw from './api/TreeApi';\nexport * as StartupRaw from './api/StartupApi';\nexport * as SecretsRaw from './api/SecretsApi';\nexport * as VariablesRaw from './api/VariablesApi';\n\n// Ops Layer\nexport * as Admin from './ops/AdminOps';\nexport * as Authenticate from './ops/AuthenticateOps';\nexport * as CirclesOfTrust from './ops/CirclesOfTrustOps';\nexport * as ConnectionProfile from './ops/ConnectionProfileOps';\nexport * as EmailTemplate from './ops/EmailTemplateOps';\nexport * as Idm from './ops/IdmOps';\nexport * as Idp from './ops/IdpOps';\nexport * as Journey from './ops/JourneyOps';\nexport * as Log from './ops/LogOps';\nexport * as ManagedObject from './ops/ManagedObjectOps';\nexport * as OAuth2Client from './ops/OAuth2ClientOps';\nexport * as Organization from './ops/OrganizationOps';\nexport * as Realm from './ops/RealmOps';\nexport * as Saml2 from './ops/Saml2Ops';\nexport * as Script from './ops/ScriptOps';\nexport * as Secrets from './ops/SecretsOps';\nexport * as Startup from './ops/StartupOps';\nexport * as Theme from './ops/ThemeOps';\nexport * as Variables from './ops/VariablesOps';\n// TODO: revisit if there are better ways\nexport * as Utils from './ops/utils/OpsUtils';\n// TODO: reconsider the aproach to pass in state from client\n// lib should be stateless, an aplication should own its state\nexport * as state from './storage/SessionStorage';\n// TODO: need to figure out if this is the right approach or if we should even\n// use a public oauth2/oidc library. might be ok for now since there is only\n// one place where the cli needs to execute an oauth flow.\nexport * as OAuth2OIDCApi from './api/OAuth2OIDCApi';\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,QAAS,GAAGC,aAAA,CAAKC,OAAL,CAAa,IAAAC,kBAAA,sDAAb,CAAlB;;AAEA,IAAMC,GAAG,GAAGC,IAAI,CAACC,KAAL,CACVC,WAAA,CAAGC,YAAH,CAAgBP,aAAA,CAAKQ,OAAL,CAAaT,QAAb,EAAwB,iBAAxB,CAAhB,EAA4D,MAA5D,CADU,CAAZ;;AAIO,SAASU,UAAT,GAAsB;EAC3B,kBAAWN,GAAG,CAACO,OAAf;AACD,C,CAED"}
1
+ {"version":3,"file":"index.js","names":["__dirname","path","dirname","fileURLToPath","pkg","JSON","parse","fs","readFileSync","resolve","getVersion","version"],"sources":["index.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nconst pkg = JSON.parse(\n fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf8')\n);\n\nexport function getVersion() {\n return `v${pkg.version}`;\n}\n\n// Api Layer\nexport * as TypesRaw from './api/ApiTypes';\nexport * as NodeRaw from './api/NodeApi';\nexport * as TreeRaw from './api/TreeApi';\nexport * as StartupRaw from './api/StartupApi';\nexport * as SecretsRaw from './api/SecretsApi';\nexport * as VariablesRaw from './api/VariablesApi';\n\n// Ops Layer\nexport * as Types from './ops/OpsTypes';\nexport * as Admin from './ops/AdminOps';\nexport * as Authenticate from './ops/AuthenticateOps';\nexport * as CirclesOfTrust from './ops/CirclesOfTrustOps';\nexport * as ConnectionProfile from './ops/ConnectionProfileOps';\nexport * as EmailTemplate from './ops/EmailTemplateOps';\nexport * as Idm from './ops/IdmOps';\nexport * as Idp from './ops/IdpOps';\nexport * as Journey from './ops/JourneyOps';\nexport * as Log from './ops/LogOps';\nexport * as ManagedObject from './ops/ManagedObjectOps';\nexport * as OAuth2Client from './ops/OAuth2ClientOps';\nexport * as Organization from './ops/OrganizationOps';\nexport * as Realm from './ops/RealmOps';\nexport * as Saml2 from './ops/Saml2Ops';\nexport * as Script from './ops/ScriptOps';\nexport * as Secrets from './ops/SecretsOps';\nexport * as Startup from './ops/StartupOps';\nexport * as Theme from './ops/ThemeOps';\nexport * as Variables from './ops/VariablesOps';\n// TODO: revisit if there are better ways\nexport * as Utils from './ops/utils/OpsUtils';\n// TODO: reconsider the aproach to pass in state from client\n// lib should be stateless, an aplication should own its state\nexport * as state from './storage/SessionStorage';\n// TODO: need to figure out if this is the right approach or if we should even\n// use a public oauth2/oidc library. might be ok for now since there is only\n// one place where the cli needs to execute an oauth flow.\nexport * as OAuth2OIDCApi from './api/OAuth2OIDCApi';\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,QAAS,GAAGC,aAAA,CAAKC,OAAL,CAAa,IAAAC,kBAAA,sDAAb,CAAlB;;AAEA,IAAMC,GAAG,GAAGC,IAAI,CAACC,KAAL,CACVC,WAAA,CAAGC,YAAH,CAAgBP,aAAA,CAAKQ,OAAL,CAAaT,QAAb,EAAwB,iBAAxB,CAAhB,EAA4D,MAA5D,CADU,CAAZ;;AAIO,SAASU,UAAT,GAAsB;EAC3B,kBAAWN,GAAG,CAACO,OAAf;AACD,C,CAED"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.exportCircleOfTrust = exportCircleOfTrust;
7
7
  exports.exportCirclesOfTrustToFile = exportCirclesOfTrustToFile;
8
8
  exports.exportCirclesOfTrustToFiles = exportCirclesOfTrustToFiles;
9
+ exports.getOneLineDescription = getOneLineDescription;
9
10
  exports.importCircleOfTrust = importCircleOfTrust;
10
11
  exports.importCirclesOfTrustFromFile = importCirclesOfTrustFromFile;
11
12
  exports.importCirclesOfTrustFromFiles = importCirclesOfTrustFromFiles;
@@ -28,7 +29,17 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
28
29
 
29
30
  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); }); }; }
30
31
 
31
- // use a function vs a template variable to avoid problems in loops
32
+ /**
33
+ * Get a one-line description of the circle of trust object
34
+ * @param {CircleOfTrustSkeleton} cotObj circle of trust object to describe
35
+ * @returns {string} a one-line description
36
+ */
37
+ function getOneLineDescription(cotObj) {
38
+ var description = "[".concat(cotObj._id['brightCyan'], "]");
39
+ return description;
40
+ } // use a function vs a template variable to avoid problems in loops
41
+
42
+
32
43
  function getFileDataTemplate() {
33
44
  return {
34
45
  meta: {},
@@ -1 +1 @@
1
- {"version":3,"file":"CirclesOfTrustOps.js","names":["getFileDataTemplate","meta","script","saml","hosted","remote","metadata","cot","listCirclesOfTrust","long","cotList","getCirclesOfTrust","result","error","printMessage","sort","a","b","_id","localeCompare","forEach","table","createTable","push","description","status","trustedProviders","map","provider","split","join","toString","exportDependencies","cotData","fileData","exportCircleOfTrust","cotId","file","fileName","getTypedFilename","createProgressIndicator","_","cloneDeep","getCircleOfTrust","updateProgressIndicator","saveJsonToFile","stopProgressIndicator","brightCyan","err","exportCirclesOfTrustToFile","getRealmString","allCotData","length","_rev","exportCirclesOfTrustToFiles","importDependencies","importCircleOfTrust","fs","readFile","data","JSON","parse","validateImport","get","createCircleOfTrust","createProviderErr","response","importFirstCircleOfTrust","hasOwnProperty","call","createCircleOfTrustErr","importCirclesOfTrustFromFile","Object","keys","importCirclesOfTrustFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","total","totalErrors","readFileSync","errors"],"sources":["ops/CirclesOfTrustOps.ts"],"sourcesContent":["import fs from 'fs';\nimport _ from 'lodash';\nimport {\n createTable,\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from './utils/Console';\nimport {\n getCirclesOfTrust,\n getCircleOfTrust,\n createCircleOfTrust,\n} from '../api/CirclesOfTrustApi';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n validateImport,\n} from './utils/ExportImportUtils';\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n script: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n cot: {},\n },\n };\n}\n\n/**\n * List entity providers\n * @param {String} long Long list format with details\n */\nexport async function listCirclesOfTrust(long = false) {\n let cotList = [];\n try {\n cotList = (await getCirclesOfTrust()).result;\n } catch (error) {\n printMessage(`getCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n cotList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n cotList.forEach((cot) => {\n printMessage(`${cot._id}`, 'data');\n });\n } else {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Description'['brightCyan'],\n 'Status'['brightCyan'],\n 'Trusted Providers'['brightCyan'],\n ]);\n cotList.forEach((cot) => {\n table.push([\n cot._id,\n cot.description,\n cot.status,\n cot.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('\\n'),\n ]);\n });\n printMessage(table.toString());\n }\n}\n\n/**\n * Include dependencies in the export file\n * @param {Object} cotData Object representing a SAML circle of trust\n * @param {Object} fileData File data object to add dependencies to\n */\nasync function exportDependencies(cotData, fileData) {\n // TODO: Export dependencies\n return [cotData, fileData];\n}\n\n/**\n * Export a single circle of trust to file\n * @param {String} cotId circle of trust id/name\n * @param {String} file Optional filename\n */\nexport async function exportCircleOfTrust(cotId, file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(cotId, 'cot.saml');\n }\n createProgressIndicator(1, `Exporting circle of trust ${cotId}`);\n try {\n const cotData = _.cloneDeep(getCircleOfTrust(cotId));\n delete cotData['_rev'];\n updateProgressIndicator(`Exporting ${cotId}`);\n const fileData = getFileDataTemplate();\n fileData.saml.cot[cotId] = cotData;\n await exportDependencies(cotData, fileData);\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${cotId.brightCyan} to ${fileName.brightCyan}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all circles of trust to one file\n * @param {String} file Optional filename\n */\nexport async function exportCirclesOfTrustToFile(file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(\n `all${getRealmString()}CirclesOfTrust`,\n 'cot.saml'\n );\n }\n const fileData = getFileDataTemplate();\n let allCotData = [];\n try {\n allCotData = _.cloneDeep((await getCirclesOfTrust()).result);\n createProgressIndicator(allCotData.length, 'Exporting circles of trust');\n for (const cotData of allCotData) {\n delete cotData._rev;\n updateProgressIndicator(`Exporting circle of trust ${cotData._id}`);\n // eslint-disable-next-line no-await-in-loop\n await exportDependencies(cotData, fileData);\n fileData.saml.cot[cotData._id] = cotData;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${allCotData.length} circle(s) of trust exported to ${fileName}.`\n );\n } catch (error) {\n printMessage(`getCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n}\n\n/**\n * Export all circles of trust to individual files\n */\nexport async function exportCirclesOfTrustToFiles() {\n let allCotData = [];\n try {\n allCotData = _.cloneDeep((await getCirclesOfTrust()).result);\n createProgressIndicator(allCotData.length, 'Exporting circles of trust');\n for (const cotData of allCotData) {\n delete cotData._rev;\n updateProgressIndicator(`Exporting circle of trust ${cotData._id}`);\n const fileName = getTypedFilename(cotData._id, 'cot.saml');\n const fileData = getFileDataTemplate();\n // eslint-disable-next-line no-await-in-loop\n await exportDependencies(cotData, fileData);\n fileData.saml.cot[cotData._id] = cotData;\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${allCotData.length} providers exported.`);\n } catch (error) {\n printMessage(`getCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n}\n\n/**\n * Include dependencies from the import file\n * @param {Object} cotData Object representing a SAML circle of trust\n * @param {Object} fileData File data object to read dependencies from\n */\nasync function importDependencies(cotData, fileData) {\n // TODO: Import dependencies\n return [cotData, fileData];\n}\n\n/**\n * Import a SAML circle of trust by id/name from file\n * @param {String} cotId Circle of trust id/name\n * @param {String} file Import file name\n */\nexport async function importCircleOfTrust(cotId, 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 circle of trust...');\n const cotData = _.get(fileData, ['saml', 'cot', cotId]);\n if (cotData) {\n updateProgressIndicator(`Importing ${cotId}`);\n await importDependencies(cotData, fileData);\n try {\n await createCircleOfTrust(cotData);\n stopProgressIndicator(`Successfully imported ${cotId}.`);\n } catch (createProviderErr) {\n stopProgressIndicator(`Error importing ${cotId}.`);\n printMessage(`Error importing ${cotId}`, 'error');\n printMessage(createProviderErr.response.data, 'error');\n }\n } else {\n stopProgressIndicator(\n `Circle of trust ${cotId.brightCyan} not found in ${file.brightCyan}!`\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import first SAML circle of trust from file\n * @param {String} file Import file name\n */\nexport async function importFirstCircleOfTrust(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 circle of trust...');\n for (const cotId in fileData.saml.cot) {\n if ({}.hasOwnProperty.call(fileData.saml.cot, cotId)) {\n const cotData = _.cloneDeep(fileData.saml.cot[cotId]);\n updateProgressIndicator(`Importing ${cotId}`);\n // eslint-disable-next-line no-await-in-loop\n await importDependencies(cotData, fileData);\n try {\n await createCircleOfTrust(cotData);\n stopProgressIndicator(`Successfully imported ${cotId}.`);\n } catch (createCircleOfTrustErr) {\n stopProgressIndicator(`Error importing ${cotId}.`);\n printMessage(`Error importing ${cotId}`, 'error');\n printMessage(createCircleOfTrustErr.response.data, 'error');\n }\n break;\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML circles of trust from file\n * @param {String} file Import file name\n */\nexport async function importCirclesOfTrustFromFile(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.saml.cot).length,\n 'Importing circles of trust...'\n );\n for (const cotId in fileData.saml.cot) {\n if ({}.hasOwnProperty.call(fileData.saml.cot, cotId)) {\n const cotData = _.cloneDeep(fileData.saml.cot[cotId]);\n // eslint-disable-next-line no-await-in-loop\n await importDependencies(cotData, fileData);\n try {\n // eslint-disable-next-line no-await-in-loop\n await createCircleOfTrust(cotData);\n updateProgressIndicator(`Imported ${cotId}`);\n } catch (createCircleOfTrustErr) {\n printMessage(`\\nError importing ${cotId}`, 'error');\n printMessage(createCircleOfTrustErr.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Circles of trust imported.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML circles of trust from all *.cot.saml.json files in the current directory\n */\nexport async function importCirclesOfTrustFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.cot.saml.json')\n );\n createProgressIndicator(jsonFiles.length, 'Importing circles or trust...');\n let total = 0;\n let totalErrors = 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 total += _.keys(fileData.saml.cot).length;\n let errors = 0;\n for (const cotId in fileData.saml.cot) {\n if ({}.hasOwnProperty.call(fileData.saml.cot, cotId)) {\n const cotData = _.cloneDeep(fileData.saml.cot[cotId]);\n // eslint-disable-next-line no-await-in-loop\n await importDependencies(cotData, fileData);\n try {\n // eslint-disable-next-line no-await-in-loop\n await createCircleOfTrust(cotData);\n // updateProgressIndicator(`Imported ${cotId}`);\n } catch (createCircleOfTrustErr) {\n errors += 1;\n printMessage(`\\nError importing ${cotId}`, 'error');\n printMessage(createCircleOfTrustErr.response.data, 'error');\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(\n `Imported ${\n _.keys(fileData.saml.cot).length - errors\n } circle(s) of trust from ${file}`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} circle(s) of trust from ${\n jsonFiles.length\n } file(s).`\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAOA;;AAKA;;;;;;;;AAOA;AACA,SAASA,mBAAT,GAA+B;EAC7B,OAAO;IACLC,IAAI,EAAE,EADD;IAELC,MAAM,EAAE,EAFH;IAGLC,IAAI,EAAE;MACJC,MAAM,EAAE,EADJ;MAEJC,MAAM,EAAE,EAFJ;MAGJC,QAAQ,EAAE,EAHN;MAIJC,GAAG,EAAE;IAJD;EAHD,CAAP;AAUD;AAED;AACA;AACA;AACA;;;SACsBC,kB;;;AAkCtB;AACA;AACA;AACA;AACA;;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AEIL,SAAS,CAACzB,MAFd;EAKD,C"}
1
+ {"version":3,"file":"CirclesOfTrustOps.js","names":["getOneLineDescription","cotObj","description","_id","getFileDataTemplate","meta","script","saml","hosted","remote","metadata","cot","listCirclesOfTrust","long","cotList","getCirclesOfTrust","result","error","printMessage","sort","a","b","localeCompare","forEach","table","createTable","push","status","trustedProviders","map","provider","split","join","toString","exportDependencies","cotData","fileData","exportCircleOfTrust","cotId","file","fileName","getTypedFilename","createProgressIndicator","_","cloneDeep","getCircleOfTrust","updateProgressIndicator","saveJsonToFile","stopProgressIndicator","brightCyan","err","exportCirclesOfTrustToFile","getRealmString","allCotData","length","_rev","exportCirclesOfTrustToFiles","importDependencies","importCircleOfTrust","fs","readFile","data","JSON","parse","validateImport","get","createCircleOfTrust","createProviderErr","response","importFirstCircleOfTrust","hasOwnProperty","call","createCircleOfTrustErr","importCirclesOfTrustFromFile","Object","keys","importCirclesOfTrustFromFiles","names","readdirSync","jsonFiles","filter","name","toLowerCase","endsWith","total","totalErrors","readFileSync","errors"],"sources":["ops/CirclesOfTrustOps.ts"],"sourcesContent":["import fs from 'fs';\nimport _ from 'lodash';\nimport {\n createTable,\n printMessage,\n createProgressIndicator,\n updateProgressIndicator,\n stopProgressIndicator,\n} from './utils/Console';\nimport {\n getCirclesOfTrust,\n getCircleOfTrust,\n createCircleOfTrust,\n} from '../api/CirclesOfTrustApi';\nimport {\n getRealmString,\n getTypedFilename,\n saveJsonToFile,\n validateImport,\n} from './utils/ExportImportUtils';\nimport { CircleOfTrustSkeleton } from '../api/ApiTypes';\n\n/**\n * Get a one-line description of the circle of trust object\n * @param {CircleOfTrustSkeleton} cotObj circle of trust object to describe\n * @returns {string} a one-line description\n */\nexport function getOneLineDescription(cotObj: CircleOfTrustSkeleton): string {\n const description = `[${cotObj._id['brightCyan']}]`;\n return description;\n}\n\n// use a function vs a template variable to avoid problems in loops\nfunction getFileDataTemplate() {\n return {\n meta: {},\n script: {},\n saml: {\n hosted: {},\n remote: {},\n metadata: {},\n cot: {},\n },\n };\n}\n\n/**\n * List entity providers\n * @param {String} long Long list format with details\n */\nexport async function listCirclesOfTrust(long = false) {\n let cotList = [];\n try {\n cotList = (await getCirclesOfTrust()).result;\n } catch (error) {\n printMessage(`getCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n cotList.sort((a, b) => a._id.localeCompare(b._id));\n if (!long) {\n cotList.forEach((cot) => {\n printMessage(`${cot._id}`, 'data');\n });\n } else {\n const table = createTable([\n 'Name'['brightCyan'],\n 'Description'['brightCyan'],\n 'Status'['brightCyan'],\n 'Trusted Providers'['brightCyan'],\n ]);\n cotList.forEach((cot) => {\n table.push([\n cot._id,\n cot.description,\n cot.status,\n cot.trustedProviders\n .map((provider) => provider.split('|')[0])\n .join('\\n'),\n ]);\n });\n printMessage(table.toString());\n }\n}\n\n/**\n * Include dependencies in the export file\n * @param {Object} cotData Object representing a SAML circle of trust\n * @param {Object} fileData File data object to add dependencies to\n */\nasync function exportDependencies(cotData, fileData) {\n // TODO: Export dependencies\n return [cotData, fileData];\n}\n\n/**\n * Export a single circle of trust to file\n * @param {String} cotId circle of trust id/name\n * @param {String} file Optional filename\n */\nexport async function exportCircleOfTrust(cotId, file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(cotId, 'cot.saml');\n }\n createProgressIndicator(1, `Exporting circle of trust ${cotId}`);\n try {\n const cotData = _.cloneDeep(getCircleOfTrust(cotId));\n delete cotData['_rev'];\n updateProgressIndicator(`Exporting ${cotId}`);\n const fileData = getFileDataTemplate();\n fileData.saml.cot[cotId] = cotData;\n await exportDependencies(cotData, fileData);\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `Exported ${cotId.brightCyan} to ${fileName.brightCyan}.`\n );\n } catch (err) {\n stopProgressIndicator(`${err}`);\n printMessage(err, 'error');\n }\n}\n\n/**\n * Export all circles of trust to one file\n * @param {String} file Optional filename\n */\nexport async function exportCirclesOfTrustToFile(file = null) {\n let fileName = file;\n if (!fileName) {\n fileName = getTypedFilename(\n `all${getRealmString()}CirclesOfTrust`,\n 'cot.saml'\n );\n }\n const fileData = getFileDataTemplate();\n let allCotData = [];\n try {\n allCotData = _.cloneDeep((await getCirclesOfTrust()).result);\n createProgressIndicator(allCotData.length, 'Exporting circles of trust');\n for (const cotData of allCotData) {\n delete cotData._rev;\n updateProgressIndicator(`Exporting circle of trust ${cotData._id}`);\n // eslint-disable-next-line no-await-in-loop\n await exportDependencies(cotData, fileData);\n fileData.saml.cot[cotData._id] = cotData;\n }\n saveJsonToFile(fileData, fileName);\n stopProgressIndicator(\n `${allCotData.length} circle(s) of trust exported to ${fileName}.`\n );\n } catch (error) {\n printMessage(`getCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n}\n\n/**\n * Export all circles of trust to individual files\n */\nexport async function exportCirclesOfTrustToFiles() {\n let allCotData = [];\n try {\n allCotData = _.cloneDeep((await getCirclesOfTrust()).result);\n createProgressIndicator(allCotData.length, 'Exporting circles of trust');\n for (const cotData of allCotData) {\n delete cotData._rev;\n updateProgressIndicator(`Exporting circle of trust ${cotData._id}`);\n const fileName = getTypedFilename(cotData._id, 'cot.saml');\n const fileData = getFileDataTemplate();\n // eslint-disable-next-line no-await-in-loop\n await exportDependencies(cotData, fileData);\n fileData.saml.cot[cotData._id] = cotData;\n saveJsonToFile(fileData, fileName);\n }\n stopProgressIndicator(`${allCotData.length} providers exported.`);\n } catch (error) {\n printMessage(`getCirclesOfTrust ERROR: ${error}`, 'error');\n printMessage(error, 'data');\n }\n}\n\n/**\n * Include dependencies from the import file\n * @param {Object} cotData Object representing a SAML circle of trust\n * @param {Object} fileData File data object to read dependencies from\n */\nasync function importDependencies(cotData, fileData) {\n // TODO: Import dependencies\n return [cotData, fileData];\n}\n\n/**\n * Import a SAML circle of trust by id/name from file\n * @param {String} cotId Circle of trust id/name\n * @param {String} file Import file name\n */\nexport async function importCircleOfTrust(cotId, 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 circle of trust...');\n const cotData = _.get(fileData, ['saml', 'cot', cotId]);\n if (cotData) {\n updateProgressIndicator(`Importing ${cotId}`);\n await importDependencies(cotData, fileData);\n try {\n await createCircleOfTrust(cotData);\n stopProgressIndicator(`Successfully imported ${cotId}.`);\n } catch (createProviderErr) {\n stopProgressIndicator(`Error importing ${cotId}.`);\n printMessage(`Error importing ${cotId}`, 'error');\n printMessage(createProviderErr.response.data, 'error');\n }\n } else {\n stopProgressIndicator(\n `Circle of trust ${cotId.brightCyan} not found in ${file.brightCyan}!`\n );\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import first SAML circle of trust from file\n * @param {String} file Import file name\n */\nexport async function importFirstCircleOfTrust(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 circle of trust...');\n for (const cotId in fileData.saml.cot) {\n if ({}.hasOwnProperty.call(fileData.saml.cot, cotId)) {\n const cotData = _.cloneDeep(fileData.saml.cot[cotId]);\n updateProgressIndicator(`Importing ${cotId}`);\n // eslint-disable-next-line no-await-in-loop\n await importDependencies(cotData, fileData);\n try {\n await createCircleOfTrust(cotData);\n stopProgressIndicator(`Successfully imported ${cotId}.`);\n } catch (createCircleOfTrustErr) {\n stopProgressIndicator(`Error importing ${cotId}.`);\n printMessage(`Error importing ${cotId}`, 'error');\n printMessage(createCircleOfTrustErr.response.data, 'error');\n }\n break;\n }\n }\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML circles of trust from file\n * @param {String} file Import file name\n */\nexport async function importCirclesOfTrustFromFile(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.saml.cot).length,\n 'Importing circles of trust...'\n );\n for (const cotId in fileData.saml.cot) {\n if ({}.hasOwnProperty.call(fileData.saml.cot, cotId)) {\n const cotData = _.cloneDeep(fileData.saml.cot[cotId]);\n // eslint-disable-next-line no-await-in-loop\n await importDependencies(cotData, fileData);\n try {\n // eslint-disable-next-line no-await-in-loop\n await createCircleOfTrust(cotData);\n updateProgressIndicator(`Imported ${cotId}`);\n } catch (createCircleOfTrustErr) {\n printMessage(`\\nError importing ${cotId}`, 'error');\n printMessage(createCircleOfTrustErr.response.data, 'error');\n }\n }\n }\n stopProgressIndicator(`Circles of trust imported.`);\n } else {\n printMessage('Import validation failed...', 'error');\n }\n });\n}\n\n/**\n * Import all SAML circles of trust from all *.cot.saml.json files in the current directory\n */\nexport async function importCirclesOfTrustFromFiles() {\n const names = fs.readdirSync('.');\n const jsonFiles = names.filter((name) =>\n name.toLowerCase().endsWith('.cot.saml.json')\n );\n createProgressIndicator(jsonFiles.length, 'Importing circles or trust...');\n let total = 0;\n let totalErrors = 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 total += _.keys(fileData.saml.cot).length;\n let errors = 0;\n for (const cotId in fileData.saml.cot) {\n if ({}.hasOwnProperty.call(fileData.saml.cot, cotId)) {\n const cotData = _.cloneDeep(fileData.saml.cot[cotId]);\n // eslint-disable-next-line no-await-in-loop\n await importDependencies(cotData, fileData);\n try {\n // eslint-disable-next-line no-await-in-loop\n await createCircleOfTrust(cotData);\n // updateProgressIndicator(`Imported ${cotId}`);\n } catch (createCircleOfTrustErr) {\n errors += 1;\n printMessage(`\\nError importing ${cotId}`, 'error');\n printMessage(createCircleOfTrustErr.response.data, 'error');\n }\n }\n }\n totalErrors += errors;\n updateProgressIndicator(\n `Imported ${\n _.keys(fileData.saml.cot).length - errors\n } circle(s) of trust from ${file}`\n );\n } else {\n printMessage(`Validation of ${file} failed!`, 'error');\n }\n }\n stopProgressIndicator(\n `Imported ${total - totalErrors} of ${total} circle(s) of trust from ${\n jsonFiles.length\n } file(s).`\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAOA;;AAKA;;;;;;;;AAQA;AACA;AACA;AACA;AACA;AACO,SAASA,qBAAT,CAA+BC,MAA/B,EAAsE;EAC3E,IAAMC,WAAW,cAAOD,MAAM,CAACE,GAAP,CAAW,YAAX,CAAP,MAAjB;EACA,OAAOD,WAAP;AACD,C,CAED;;;AACA,SAASE,mBAAT,GAA+B;EAC7B,OAAO;IACLC,IAAI,EAAE,EADD;IAELC,MAAM,EAAE,EAFH;IAGLC,IAAI,EAAE;MACJC,MAAM,EAAE,EADJ;MAEJC,MAAM,EAAE,EAFJ;MAGJC,QAAQ,EAAE,EAHN;MAIJC,GAAG,EAAE;IAJD;EAHD,CAAP;AAUD;AAED;AACA;AACA;AACA;;;SACsBC,kB;;;AAkCtB;AACA;AACA;AACA;AACA;;;;0CAtCO,aAAgD;IAAA,IAAdC,IAAc,uEAAP,KAAO;IACrD,IAAIC,OAAO,GAAG,EAAd;;IACA,IAAI;MACFA,OAAO,GAAG,OAAO,IAAAC,oCAAA,GAAP,EAA4BC,MAAtC;IACD,CAFD,CAEE,OAAOC,KAAP,EAAc;MACd,IAAAC,qBAAA,qCAAyCD,KAAzC,GAAkD,OAAlD;MACA,IAAAC,qBAAA,EAAaD,KAAb,EAAoB,MAApB;IACD;;IACDH,OAAO,CAACK,IAAR,CAAa,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,CAACjB,GAAF,CAAMmB,aAAN,CAAoBD,CAAC,CAAClB,GAAtB,CAAvB;;IACA,IAAI,CAACU,IAAL,EAAW;MACTC,OAAO,CAACS,OAAR,CAAiBZ,GAAD,IAAS;QACvB,IAAAO,qBAAA,YAAgBP,GAAG,CAACR,GAApB,GAA2B,MAA3B;MACD,CAFD;IAGD,CAJD,MAIO;MACL,IAAMqB,KAAK,GAAG,I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AAUC,QAAV,CAAxB;;YACA,IAAI;cACF;cACA,MAAM,IAAA8B,sCAAA,EAAoB/B,OAApB,CAAN,CAFE,CAGF;YACD,CAJD,CAIE,OAAOqC,sBAAP,EAA+B;cAC/Be,MAAM,IAAI,CAAV;cACA,IAAArE,qBAAA,8BAAkCoB,KAAlC,GAA2C,OAA3C;cACA,IAAApB,qBAAA,EAAasD,sBAAsB,CAACJ,QAAvB,CAAgCP,IAA7C,EAAmD,OAAnD;YACD;UACF;QACF;;QACDwB,WAAW,IAAIE,MAAf;QACA,IAAAzC,gCAAA,qBAEIH,eAAA,CAAEgC,IAAF,CAAOvC,QAAQ,CAAC7B,IAAT,CAAcI,GAArB,EAA0B2C,MAA1B,GAAmCiC,MAFvC,sCAG8BhD,IAH9B;MAKD,CAzBD,MAyBO;QACL,IAAArB,qBAAA,0BAA8BqB,IAA9B,eAA8C,OAA9C;MACD;IACF;;IACD,IAAAS,8BAAA,qBACcoC,KAAK,GAAGC,WADtB,iBACwCD,KADxC,sCAEIL,SAAS,CAACzB,MAFd;EAKD,C"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.exportEmailTemplateToFile = exportEmailTemplateToFile;
7
7
  exports.exportEmailTemplatesToFile = exportEmailTemplatesToFile;
8
8
  exports.exportEmailTemplatesToFiles = exportEmailTemplatesToFiles;
9
+ exports.getOneLineDescription = getOneLineDescription;
9
10
  exports.importEmailTemplateFromFile = importEmailTemplateFromFile;
10
11
  exports.importEmailTemplatesFromFile = importEmailTemplatesFromFile;
11
12
  exports.importEmailTemplatesFromFiles = importEmailTemplatesFromFiles;
@@ -44,6 +45,17 @@ function getFileDataTemplate() {
44
45
  emailTemplate: {}
45
46
  };
46
47
  }
48
+ /**
49
+ * Get a one-line description of the email template
50
+ * @param {EmailTemplateSkeleton} templateObj email template object to describe
51
+ * @returns {string} a one-line description
52
+ */
53
+
54
+
55
+ function getOneLineDescription(templateObj) {
56
+ var description = "[".concat(templateObj._id.split('/')[1]['brightCyan'], "] ").concat(templateObj.displayName['brightYellow'], " - ").concat(templateObj.subject[templateObj.defaultLocale]['brightYellow']);
57
+ return description;
58
+ }
47
59
  /**
48
60
  * List email templates
49
61
  * @param {boolean} long Long list format with details