@rockcarver/frodo-lib 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +32 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +30 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/.github/README.md +121 -0
- package/.github/workflows/pipeline.yml +287 -0
- package/.prettierrc +6 -0
- package/CHANGELOG.md +512 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/LICENSE +21 -0
- package/README.md +8 -0
- package/docs/CONTRIBUTE.md +96 -0
- package/docs/PIPELINE.md +169 -0
- package/docs/images/npm_versioning_guidelines.png +0 -0
- package/docs/images/release_pipeline.png +0 -0
- package/jsconfig.json +6 -0
- package/package.json +95 -0
- package/resources/sampleEntitiesFile.json +8 -0
- package/resources/sampleEnvFile.env +2 -0
- package/src/api/AuthenticateApi.js +33 -0
- package/src/api/BaseApi.js +242 -0
- package/src/api/CirclesOfTrustApi.js +87 -0
- package/src/api/EmailTemplateApi.js +37 -0
- package/src/api/IdmConfigApi.js +88 -0
- package/src/api/LogApi.js +45 -0
- package/src/api/ManagedObjectApi.js +62 -0
- package/src/api/OAuth2ClientApi.js +69 -0
- package/src/api/OAuth2OIDCApi.js +73 -0
- package/src/api/OAuth2ProviderApi.js +32 -0
- package/src/api/RealmApi.js +99 -0
- package/src/api/Saml2Api.js +176 -0
- package/src/api/ScriptApi.js +84 -0
- package/src/api/SecretsApi.js +151 -0
- package/src/api/ServerInfoApi.js +41 -0
- package/src/api/SocialIdentityProvidersApi.js +114 -0
- package/src/api/StartupApi.js +45 -0
- package/src/api/ThemeApi.js +181 -0
- package/src/api/TreeApi.js +207 -0
- package/src/api/VariablesApi.js +104 -0
- package/src/api/utils/ApiUtils.js +77 -0
- package/src/api/utils/ApiUtils.test.js +96 -0
- package/src/api/utils/Base64.js +62 -0
- package/src/index.js +32 -0
- package/src/index.test.js +13 -0
- package/src/ops/AdminOps.js +901 -0
- package/src/ops/AuthenticateOps.js +342 -0
- package/src/ops/CirclesOfTrustOps.js +350 -0
- package/src/ops/ConnectionProfileOps.js +254 -0
- package/src/ops/EmailTemplateOps.js +326 -0
- package/src/ops/IdmOps.js +227 -0
- package/src/ops/IdpOps.js +342 -0
- package/src/ops/JourneyOps.js +2026 -0
- package/src/ops/LogOps.js +357 -0
- package/src/ops/ManagedObjectOps.js +34 -0
- package/src/ops/OAuth2ClientOps.js +151 -0
- package/src/ops/OrganizationOps.js +85 -0
- package/src/ops/RealmOps.js +139 -0
- package/src/ops/SamlOps.js +541 -0
- package/src/ops/ScriptOps.js +211 -0
- package/src/ops/SecretsOps.js +288 -0
- package/src/ops/StartupOps.js +114 -0
- package/src/ops/ThemeOps.js +379 -0
- package/src/ops/VariablesOps.js +185 -0
- package/src/ops/templates/OAuth2ClientTemplate.json +270 -0
- package/src/ops/templates/OrgModelUserAttributesTemplate.json +149 -0
- package/src/ops/templates/cloud/GenericExtensionAttributesTemplate.json +392 -0
- package/src/ops/templates/cloud/managed.json +4119 -0
- package/src/ops/utils/Console.js +434 -0
- package/src/ops/utils/DataProtection.js +92 -0
- package/src/ops/utils/DataProtection.test.js +28 -0
- package/src/ops/utils/ExportImportUtils.js +146 -0
- package/src/ops/utils/ExportImportUtils.test.js +119 -0
- package/src/ops/utils/OpsUtils.js +76 -0
- package/src/ops/utils/Wordwrap.js +11 -0
- package/src/storage/SessionStorage.js +45 -0
- package/src/storage/StaticStorage.js +15 -0
- package/test/e2e/journey/baseline/ForgottenUsername.journey.json +216 -0
- package/test/e2e/journey/baseline/Login.journey.json +205 -0
- package/test/e2e/journey/baseline/PasswordGrant.journey.json +139 -0
- package/test/e2e/journey/baseline/ProgressiveProfile.journey.json +198 -0
- package/test/e2e/journey/baseline/Registration.journey.json +249 -0
- package/test/e2e/journey/baseline/ResetPassword.journey.json +268 -0
- package/test/e2e/journey/baseline/UpdatePassword.journey.json +323 -0
- package/test/e2e/journey/baseline/allAlphaJourneys.journeys.json +1520 -0
- package/test/e2e/journey/delete/ForgottenUsername.journey.json +216 -0
- package/test/e2e/journey/delete/Login.journey.json +205 -0
- package/test/e2e/journey/delete/PasswordGrant.journey.json +139 -0
- package/test/e2e/journey/delete/ProgressiveProfile.journey.json +198 -0
- package/test/e2e/journey/delete/Registration.journey.json +249 -0
- package/test/e2e/journey/delete/ResetPassword.journey.json +268 -0
- package/test/e2e/journey/delete/UpdatePassword.journey.json +323 -0
- package/test/e2e/journey/delete/deleteMe.journey.json +230 -0
- package/test/e2e/journey/list/Disabled.journey.json +43 -0
- package/test/e2e/journey/list/ForgottenUsername.journey.json +216 -0
- package/test/e2e/journey/list/Login.journey.json +205 -0
- package/test/e2e/journey/list/PasswordGrant.journey.json +139 -0
- package/test/e2e/journey/list/ProgressiveProfile.journey.json +198 -0
- package/test/e2e/journey/list/Registration.journey.json +249 -0
- package/test/e2e/journey/list/ResetPassword.journey.json +268 -0
- package/test/e2e/journey/list/UpdatePassword.journey.json +323 -0
- package/test/e2e/setup.js +107 -0
- package/test/e2e/theme/baseline/Contrast.theme.json +95 -0
- package/test/e2e/theme/baseline/Highlander.theme.json +95 -0
- package/test/e2e/theme/baseline/Robroy.theme.json +95 -0
- package/test/e2e/theme/baseline/Starter-Theme.theme.json +94 -0
- package/test/e2e/theme/baseline/Zardoz.theme.json +95 -0
- package/test/e2e/theme/import/Contrast.theme.json +95 -0
- package/test/e2e/theme/import/Highlander.theme.json +95 -0
- package/test/e2e/theme/import/Robroy.theme.json +95 -0
- package/test/e2e/theme/import/Starter-Theme.theme.json +94 -0
- package/test/e2e/theme/import/Zardoz.default.theme.json +95 -0
- package/test/fs_tmp/.gitkeep +2 -0
- package/test/global/setup.js +65 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import { generateAmApi } from './BaseApi.js';
|
|
4
|
+
import { getCurrentRealmPath } from './utils/ApiUtils.js';
|
|
5
|
+
import storage from '../storage/SessionStorage.js';
|
|
6
|
+
|
|
7
|
+
const providerByLocationAndIdURLTemplate = '%s/json%s/realm-config/saml2/%s/%s';
|
|
8
|
+
const createHostedProviderURLTemplate =
|
|
9
|
+
'%s/json%s/realm-config/saml2/hosted/?_action=create';
|
|
10
|
+
const createRemoteProviderURLTemplate =
|
|
11
|
+
'%s/json%s/realm-config/saml2/remote/?_action=importEntity';
|
|
12
|
+
const queryAllProvidersURLTemplate =
|
|
13
|
+
'%s/json%s/realm-config/saml2?_queryFilter=true';
|
|
14
|
+
const queryProvidersByEntityIdURLTemplate =
|
|
15
|
+
'%s/json%s/realm-config/saml2?_queryFilter=%s&_fields=%s';
|
|
16
|
+
const metadataByEntityIdURLTemplate =
|
|
17
|
+
'%s/saml2/jsp/exportmetadata.jsp?entityid=%s&realm=%s';
|
|
18
|
+
const apiVersion = 'protocol=2.1,resource=1.0';
|
|
19
|
+
const getApiConfig = () => {
|
|
20
|
+
const configPath = getCurrentRealmPath();
|
|
21
|
+
return {
|
|
22
|
+
path: `${configPath}/realm-config/saml2`,
|
|
23
|
+
apiVersion,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Get all SAML2 entity providers
|
|
29
|
+
* @returns {Promise} a promise that resolves to an array of saml2 entity stubs
|
|
30
|
+
*/
|
|
31
|
+
export async function getProviders() {
|
|
32
|
+
const urlString = util.format(
|
|
33
|
+
queryAllProvidersURLTemplate,
|
|
34
|
+
storage.session.getTenant(),
|
|
35
|
+
getCurrentRealmPath()
|
|
36
|
+
);
|
|
37
|
+
return generateAmApi(getApiConfig()).get(urlString, {
|
|
38
|
+
withCredentials: true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Find all providers matching the filter and return the requested fields
|
|
44
|
+
* @param {String} filter CREST filter string, eg "entityId+eq+'${entityId}'"
|
|
45
|
+
* @param {String} fields Comma-delimited list of fields to include in the response
|
|
46
|
+
* @returns {Promise} a promise that resolves to an array of saml2 entities
|
|
47
|
+
*/
|
|
48
|
+
export async function findProviders(filter = 'true', fields = '*') {
|
|
49
|
+
const urlString = util.format(
|
|
50
|
+
queryProvidersByEntityIdURLTemplate,
|
|
51
|
+
storage.session.getTenant(),
|
|
52
|
+
getCurrentRealmPath(),
|
|
53
|
+
encodeURIComponent(filter),
|
|
54
|
+
fields
|
|
55
|
+
);
|
|
56
|
+
return generateAmApi(getApiConfig()).get(urlString, {
|
|
57
|
+
withCredentials: true,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Geta SAML2 entity provider by location and id
|
|
63
|
+
* @param {String} location Entity provider location (hosted or remote)
|
|
64
|
+
* @param {String} entityId64 Base64-encoded provider entity id
|
|
65
|
+
* @returns {Promise} a promise that resolves to a saml2 entity provider object
|
|
66
|
+
*/
|
|
67
|
+
export async function getProviderByLocationAndId(location, entityId64) {
|
|
68
|
+
const urlString = util.format(
|
|
69
|
+
providerByLocationAndIdURLTemplate,
|
|
70
|
+
storage.session.getTenant(),
|
|
71
|
+
getCurrentRealmPath(),
|
|
72
|
+
location,
|
|
73
|
+
entityId64
|
|
74
|
+
);
|
|
75
|
+
return generateAmApi(getApiConfig()).get(urlString, {
|
|
76
|
+
withCredentials: true,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get SAML2 entity provider by entity id
|
|
82
|
+
* @param {String} entityId Provider entity id
|
|
83
|
+
* @returns {Promise} a promise that resolves to a saml2 entity provider object or null
|
|
84
|
+
*/
|
|
85
|
+
export async function getProvider(entityId) {
|
|
86
|
+
const response = await findProviders(`entityId eq '${entityId}'`, 'location');
|
|
87
|
+
switch (response.data.resultCount) {
|
|
88
|
+
case 0:
|
|
89
|
+
throw new Error(`No provider with entity id '${entityId}' found`);
|
|
90
|
+
case 1: {
|
|
91
|
+
const { location } = response.data.result[0];
|
|
92
|
+
const id = response.data.result[0]._id;
|
|
93
|
+
return getProviderByLocationAndId(location, id);
|
|
94
|
+
}
|
|
95
|
+
default:
|
|
96
|
+
throw new Error(`Multiple providers with entity id '${entityId}' found`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get a SAML2 entity provider's metadata URL by entity id
|
|
102
|
+
* @param {String} entityId SAML2 entity id
|
|
103
|
+
* @returns {String} the URL to get the metadata from
|
|
104
|
+
*/
|
|
105
|
+
export function getProviderMetadataUrl(entityId) {
|
|
106
|
+
return util.format(
|
|
107
|
+
metadataByEntityIdURLTemplate,
|
|
108
|
+
storage.session.getTenant(),
|
|
109
|
+
encodeURIComponent(entityId),
|
|
110
|
+
storage.session.getRealm()
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Get a SAML2 entity provider's metadata by entity id
|
|
116
|
+
* @param {String} entityId SAML2 entity id
|
|
117
|
+
* @returns {Promise} a promise that resolves to an object containing a SAML2 metadata
|
|
118
|
+
*/
|
|
119
|
+
export async function getProviderMetadata(entityId) {
|
|
120
|
+
return generateAmApi(getApiConfig()).get(getProviderMetadataUrl(entityId), {
|
|
121
|
+
withCredentials: true,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Create a SAML2 entity provider
|
|
127
|
+
* @param {String} location 'hosted' or 'remote'
|
|
128
|
+
* @param {Object} providerData Object representing a SAML entity provider
|
|
129
|
+
* @param {String} metaData Base64-encoded metadata XML. Only required for remote providers
|
|
130
|
+
* @returns {Promise} a promise that resolves to a saml2 entity provider object
|
|
131
|
+
*/
|
|
132
|
+
export async function createProvider(location, providerData, metaData) {
|
|
133
|
+
let postData = _.cloneDeep(providerData);
|
|
134
|
+
let urlString = util.format(
|
|
135
|
+
createHostedProviderURLTemplate,
|
|
136
|
+
storage.session.getTenant(),
|
|
137
|
+
getCurrentRealmPath(storage.session.getRealm())
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
if (location === 'remote') {
|
|
141
|
+
/**
|
|
142
|
+
* Remote entity providers must be created using XML metadata
|
|
143
|
+
*/
|
|
144
|
+
urlString = util.format(
|
|
145
|
+
createRemoteProviderURLTemplate,
|
|
146
|
+
storage.session.getTenant(),
|
|
147
|
+
getCurrentRealmPath(storage.session.getRealm())
|
|
148
|
+
);
|
|
149
|
+
postData = {
|
|
150
|
+
standardMetadata: metaData,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return generateAmApi(getApiConfig()).post(urlString, postData, {
|
|
155
|
+
withCredentials: true,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Update SAML2 entity provider
|
|
161
|
+
* @param {String} location Entity provider location (hosted or remote)
|
|
162
|
+
* @param {Object} providerData Object representing a SAML entity provider
|
|
163
|
+
* @returns {Promise} a promise that resolves to a saml2 entity provider object
|
|
164
|
+
*/
|
|
165
|
+
export async function updateProvider(location, providerData) {
|
|
166
|
+
const urlString = util.format(
|
|
167
|
+
providerByLocationAndIdURLTemplate,
|
|
168
|
+
storage.session.getTenant(),
|
|
169
|
+
getCurrentRealmPath(),
|
|
170
|
+
location,
|
|
171
|
+
providerData._id
|
|
172
|
+
);
|
|
173
|
+
return generateAmApi(getApiConfig()).put(urlString, providerData, {
|
|
174
|
+
withCredentials: true,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import { generateAmApi } from './BaseApi.js';
|
|
3
|
+
import { getCurrentRealmPath } from './utils/ApiUtils.js';
|
|
4
|
+
import storage from '../storage/SessionStorage.js';
|
|
5
|
+
|
|
6
|
+
const scriptURLTemplate = '%s/json%s/scripts/%s';
|
|
7
|
+
const scriptListURLTemplate = '%s/json%s/scripts?_queryFilter=true';
|
|
8
|
+
const scriptQueryURLTemplate =
|
|
9
|
+
'%s/json%s/scripts?_queryFilter=name+eq+%%22%s%%22';
|
|
10
|
+
const apiVersion = 'protocol=2.0,resource=1.0';
|
|
11
|
+
const getApiConfig = () => {
|
|
12
|
+
const configPath = getCurrentRealmPath();
|
|
13
|
+
return {
|
|
14
|
+
path: `${configPath}/authentication/authenticationtrees`,
|
|
15
|
+
apiVersion,
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get all scripts
|
|
21
|
+
* @returns {Promise} a promise that resolves to an object containing an array of script objects
|
|
22
|
+
*/
|
|
23
|
+
export async function getScripts() {
|
|
24
|
+
const urlString = util.format(
|
|
25
|
+
scriptListURLTemplate,
|
|
26
|
+
storage.session.getTenant(),
|
|
27
|
+
getCurrentRealmPath()
|
|
28
|
+
);
|
|
29
|
+
return generateAmApi(getApiConfig()).get(urlString, {
|
|
30
|
+
withCredentials: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get script by name
|
|
36
|
+
* @param {String} name script name
|
|
37
|
+
* @returns {Promise} a promise that resolves to an object containing a script object
|
|
38
|
+
*/
|
|
39
|
+
export async function getScriptByName(name) {
|
|
40
|
+
const urlString = util.format(
|
|
41
|
+
scriptQueryURLTemplate,
|
|
42
|
+
storage.session.getTenant(),
|
|
43
|
+
getCurrentRealmPath(),
|
|
44
|
+
name
|
|
45
|
+
);
|
|
46
|
+
return generateAmApi(getApiConfig()).get(urlString, {
|
|
47
|
+
withCredentials: true,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Get script by id
|
|
53
|
+
* @param {String} id script uuid/name
|
|
54
|
+
* @returns {Promise} a promise that resolves to an object containing a script object
|
|
55
|
+
*/
|
|
56
|
+
export async function getScript(id) {
|
|
57
|
+
const urlString = util.format(
|
|
58
|
+
scriptURLTemplate,
|
|
59
|
+
storage.session.getTenant(),
|
|
60
|
+
getCurrentRealmPath(),
|
|
61
|
+
id
|
|
62
|
+
);
|
|
63
|
+
return generateAmApi(getApiConfig()).get(urlString, {
|
|
64
|
+
withCredentials: true,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Put script
|
|
70
|
+
* @param {String} id script uuid
|
|
71
|
+
* @param {Object} data script object
|
|
72
|
+
* @returns {Promise} a promise that resolves to an object containing a script object
|
|
73
|
+
*/
|
|
74
|
+
export async function putScript(id, data) {
|
|
75
|
+
const urlString = util.format(
|
|
76
|
+
scriptURLTemplate,
|
|
77
|
+
storage.session.getTenant(),
|
|
78
|
+
getCurrentRealmPath(storage.session.getRealm()),
|
|
79
|
+
id
|
|
80
|
+
);
|
|
81
|
+
return generateAmApi(getApiConfig()).put(urlString, data, {
|
|
82
|
+
withCredentials: true,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import { encode } from './utils/Base64.js';
|
|
3
|
+
import { getTenantURL } from './utils/ApiUtils.js';
|
|
4
|
+
import { generateESVApi } from './BaseApi.js';
|
|
5
|
+
import storage from '../storage/SessionStorage.js';
|
|
6
|
+
|
|
7
|
+
const secretsListURLTemplate = '%s/environment/secrets';
|
|
8
|
+
const secretListVersionsURLTemplate = '%s/environment/secrets/%s/versions';
|
|
9
|
+
const secretCreateNewVersionURLTemplate = `${secretListVersionsURLTemplate}?_action=create`;
|
|
10
|
+
const secretGetVersionURLTemplate = `${secretListVersionsURLTemplate}/%s`;
|
|
11
|
+
const secretVersionStatusURLTemplate = `${secretGetVersionURLTemplate}?_action=changestatus`;
|
|
12
|
+
const secretURLTemplate = '%s/environment/secrets/%s';
|
|
13
|
+
const secretSetDescriptionURLTemplate = `${secretURLTemplate}?_action=setDescription`;
|
|
14
|
+
|
|
15
|
+
const apiVersion = 'protocol=1.0,resource=1.0';
|
|
16
|
+
const getApiConfig = () => ({
|
|
17
|
+
path: `/environment/secrets`,
|
|
18
|
+
apiVersion,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export async function getSecrets() {
|
|
22
|
+
const urlString = util.format(
|
|
23
|
+
secretsListURLTemplate,
|
|
24
|
+
getTenantURL(storage.session.getTenant())
|
|
25
|
+
);
|
|
26
|
+
return generateESVApi(getApiConfig()).get(urlString, {
|
|
27
|
+
withCredentials: true,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function getSecret(id) {
|
|
32
|
+
const urlString = util.format(
|
|
33
|
+
secretURLTemplate,
|
|
34
|
+
getTenantURL(storage.session.getTenant()),
|
|
35
|
+
id
|
|
36
|
+
);
|
|
37
|
+
return generateESVApi(getApiConfig()).get(urlString, {
|
|
38
|
+
withCredentials: true,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function putSecret(
|
|
43
|
+
id,
|
|
44
|
+
value,
|
|
45
|
+
description,
|
|
46
|
+
encoding = 'generic',
|
|
47
|
+
useInPlaceholders = true
|
|
48
|
+
) {
|
|
49
|
+
if (encoding !== 'generic')
|
|
50
|
+
throw new Error(`Unsupported encoding: ${encoding}`);
|
|
51
|
+
const data = {
|
|
52
|
+
valueBase64: encode(value),
|
|
53
|
+
description,
|
|
54
|
+
encoding,
|
|
55
|
+
useInPlaceholders,
|
|
56
|
+
};
|
|
57
|
+
const urlString = util.format(
|
|
58
|
+
secretURLTemplate,
|
|
59
|
+
getTenantURL(storage.session.getTenant()),
|
|
60
|
+
id
|
|
61
|
+
);
|
|
62
|
+
return generateESVApi(getApiConfig()).put(urlString, data, {
|
|
63
|
+
withCredentials: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export async function setSecretDescription(id, description) {
|
|
68
|
+
const urlString = util.format(
|
|
69
|
+
secretSetDescriptionURLTemplate,
|
|
70
|
+
getTenantURL(storage.session.getTenant()),
|
|
71
|
+
id
|
|
72
|
+
);
|
|
73
|
+
return generateESVApi(getApiConfig()).post(
|
|
74
|
+
urlString,
|
|
75
|
+
{ description },
|
|
76
|
+
{ withCredentials: true }
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export async function deleteSecret(id) {
|
|
81
|
+
const urlString = util.format(
|
|
82
|
+
secretURLTemplate,
|
|
83
|
+
getTenantURL(storage.session.getTenant()),
|
|
84
|
+
id
|
|
85
|
+
);
|
|
86
|
+
return generateESVApi(getApiConfig()).delete(urlString, {
|
|
87
|
+
withCredentials: true,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function getSecretVersions(id) {
|
|
92
|
+
const urlString = util.format(
|
|
93
|
+
secretListVersionsURLTemplate,
|
|
94
|
+
getTenantURL(storage.session.getTenant()),
|
|
95
|
+
id
|
|
96
|
+
);
|
|
97
|
+
return generateESVApi(getApiConfig()).get(urlString, {
|
|
98
|
+
withCredentials: true,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export async function createNewVersionOfSecret(id, value) {
|
|
103
|
+
const urlString = util.format(
|
|
104
|
+
secretCreateNewVersionURLTemplate,
|
|
105
|
+
getTenantURL(storage.session.getTenant()),
|
|
106
|
+
id
|
|
107
|
+
);
|
|
108
|
+
return generateESVApi(getApiConfig()).post(
|
|
109
|
+
urlString,
|
|
110
|
+
{ valueBase64: encode(value) },
|
|
111
|
+
{ withCredentials: true }
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export async function getVersionOfSecret(id, version) {
|
|
116
|
+
const urlString = util.format(
|
|
117
|
+
secretGetVersionURLTemplate,
|
|
118
|
+
getTenantURL(storage.session.getTenant()),
|
|
119
|
+
id,
|
|
120
|
+
version
|
|
121
|
+
);
|
|
122
|
+
return generateESVApi(getApiConfig()).get(urlString, {
|
|
123
|
+
withCredentials: true,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export async function setStatusOfVersionOfSecret(id, version, status) {
|
|
128
|
+
const urlString = util.format(
|
|
129
|
+
secretVersionStatusURLTemplate,
|
|
130
|
+
getTenantURL(storage.session.getTenant()),
|
|
131
|
+
id,
|
|
132
|
+
version
|
|
133
|
+
);
|
|
134
|
+
return generateESVApi(getApiConfig()).post(
|
|
135
|
+
urlString,
|
|
136
|
+
{ status },
|
|
137
|
+
{ withCredentials: true }
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export async function deleteVersionOfSecret(id, version) {
|
|
142
|
+
const urlString = util.format(
|
|
143
|
+
secretGetVersionURLTemplate,
|
|
144
|
+
getTenantURL(storage.session.getTenant()),
|
|
145
|
+
id,
|
|
146
|
+
version
|
|
147
|
+
);
|
|
148
|
+
return generateESVApi(getApiConfig()).delete(urlString, {
|
|
149
|
+
withCredentials: true,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import { generateAmApi } from './BaseApi.js';
|
|
3
|
+
import storage from '../storage/SessionStorage.js';
|
|
4
|
+
|
|
5
|
+
const serverInfoUrlTemplate = '%s/json/serverinfo/%s';
|
|
6
|
+
|
|
7
|
+
const serverInfoApiVersion = 'resource=1.1';
|
|
8
|
+
const getServerInfoApiConfig = () => ({
|
|
9
|
+
apiVersion: serverInfoApiVersion,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const serverVersionoApiVersion = 'resource=1.0';
|
|
13
|
+
const getServerVersionApiConfig = () => ({
|
|
14
|
+
apiVersion: serverVersionoApiVersion,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Get server info
|
|
19
|
+
* @returns {Promise} a promise that resolves to an object containing a server info object
|
|
20
|
+
*/
|
|
21
|
+
export async function getServerInfo() {
|
|
22
|
+
const urlString = util.format(
|
|
23
|
+
serverInfoUrlTemplate,
|
|
24
|
+
storage.session.getTenant(),
|
|
25
|
+
'*'
|
|
26
|
+
);
|
|
27
|
+
return generateAmApi(getServerInfoApiConfig()).get(urlString, {});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get server version info
|
|
32
|
+
* @returns {Promise} a promise that resolves to an object containing a server version info object
|
|
33
|
+
*/
|
|
34
|
+
export async function getServerVersionInfo() {
|
|
35
|
+
const urlString = util.format(
|
|
36
|
+
serverInfoUrlTemplate,
|
|
37
|
+
storage.session.getTenant(),
|
|
38
|
+
'version'
|
|
39
|
+
);
|
|
40
|
+
return generateAmApi(getServerVersionApiConfig()).get(urlString, {});
|
|
41
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import { generateAmApi } from './BaseApi.js';
|
|
3
|
+
import { deleteDeepByKey, getCurrentRealmPath } from './utils/ApiUtils.js';
|
|
4
|
+
import storage from '../storage/SessionStorage.js';
|
|
5
|
+
|
|
6
|
+
const getAllProviderTypesURLTemplate =
|
|
7
|
+
'%s/json%s/realm-config/services/SocialIdentityProviders?_action=getAllTypes';
|
|
8
|
+
const providerByTypeAndIdURLTemplate =
|
|
9
|
+
'%s/json%s/realm-config/services/SocialIdentityProviders/%s/%s';
|
|
10
|
+
const getAllProvidersURLTemplate =
|
|
11
|
+
'%s/json%s/realm-config/services/SocialIdentityProviders?_action=nextdescendents';
|
|
12
|
+
const getProvidersByTypeURLTemplate =
|
|
13
|
+
'%s/json%s/realm-config/services/SocialIdentityProviders/%s?_queryFilter=true';
|
|
14
|
+
const apiVersion = 'protocol=2.1,resource=1.0';
|
|
15
|
+
const getApiConfig = () => {
|
|
16
|
+
const configPath = getCurrentRealmPath();
|
|
17
|
+
return {
|
|
18
|
+
path: `${configPath}/realm-config/services/SocialIdentityProviders`,
|
|
19
|
+
apiVersion,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get social identity provider types
|
|
25
|
+
* @returns {Promise} a promise that resolves to an object containing an array of social identity provider types
|
|
26
|
+
*/
|
|
27
|
+
export async function getSocialIdentityProviderTypes() {
|
|
28
|
+
const urlString = util.format(
|
|
29
|
+
getAllProviderTypesURLTemplate,
|
|
30
|
+
storage.session.getTenant(),
|
|
31
|
+
getCurrentRealmPath()
|
|
32
|
+
);
|
|
33
|
+
return generateAmApi(getApiConfig()).get(urlString, {
|
|
34
|
+
withCredentials: true,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Get social identity providers by type
|
|
40
|
+
* @param {String} type social identity provider type
|
|
41
|
+
* @returns {Promise} a promise that resolves to an object containing an array of social identity providers of the requested type
|
|
42
|
+
*/
|
|
43
|
+
export async function getSocialIdentityProvidersByType(type) {
|
|
44
|
+
const urlString = util.format(
|
|
45
|
+
getProvidersByTypeURLTemplate,
|
|
46
|
+
storage.session.getTenant(),
|
|
47
|
+
getCurrentRealmPath(),
|
|
48
|
+
type
|
|
49
|
+
);
|
|
50
|
+
return generateAmApi(getApiConfig()).get(urlString, {
|
|
51
|
+
withCredentials: true,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get all social identity providers
|
|
57
|
+
* @returns {Promise} a promise that resolves to an object containing an array of social identity providers
|
|
58
|
+
*/
|
|
59
|
+
export async function getSocialIdentityProviders() {
|
|
60
|
+
const urlString = util.format(
|
|
61
|
+
getAllProvidersURLTemplate,
|
|
62
|
+
storage.session.getTenant(),
|
|
63
|
+
getCurrentRealmPath()
|
|
64
|
+
);
|
|
65
|
+
return generateAmApi(getApiConfig()).post(
|
|
66
|
+
urlString,
|
|
67
|
+
{},
|
|
68
|
+
{
|
|
69
|
+
withCredentials: true,
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Get social identity provider by type and id
|
|
76
|
+
* @param {*} type social identity provider type
|
|
77
|
+
* @param {*} id social identity provider id/name
|
|
78
|
+
* @returns {Promise} a promise that resolves to an object containing a social identity provider
|
|
79
|
+
*/
|
|
80
|
+
export async function getProviderByTypeAndId(type, id) {
|
|
81
|
+
const urlString = util.format(
|
|
82
|
+
providerByTypeAndIdURLTemplate,
|
|
83
|
+
storage.session.getTenant(),
|
|
84
|
+
getCurrentRealmPath(),
|
|
85
|
+
type,
|
|
86
|
+
id
|
|
87
|
+
);
|
|
88
|
+
return generateAmApi(getApiConfig()).get(urlString, {
|
|
89
|
+
withCredentials: true,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get social identity provider by type and id
|
|
95
|
+
* @param {String} type social identity provider type
|
|
96
|
+
* @param {String} id social identity provider id/name
|
|
97
|
+
* @param {Object} data a social identity provider object
|
|
98
|
+
* @returns {Promise} a promise that resolves to an object containing a social identity provider
|
|
99
|
+
*/
|
|
100
|
+
export async function putProviderByTypeAndId(type, id, data) {
|
|
101
|
+
// until we figure out a way to use transport keys in Frodo,
|
|
102
|
+
// we'll have to drop those encrypted attributes.
|
|
103
|
+
const providerData = deleteDeepByKey(data, '-encrypted');
|
|
104
|
+
const urlString = util.format(
|
|
105
|
+
providerByTypeAndIdURLTemplate,
|
|
106
|
+
storage.session.getTenant(),
|
|
107
|
+
getCurrentRealmPath(storage.session.getRealm()),
|
|
108
|
+
type,
|
|
109
|
+
id
|
|
110
|
+
);
|
|
111
|
+
return generateAmApi(getApiConfig()).put(urlString, providerData, {
|
|
112
|
+
withCredentials: true,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import util from 'util';
|
|
2
|
+
import { getTenantURL } from './utils/ApiUtils.js';
|
|
3
|
+
import { generateESVApi } from './BaseApi.js';
|
|
4
|
+
import storage from '../storage/SessionStorage.js';
|
|
5
|
+
|
|
6
|
+
const startupURLTemplate = '%s/environment/startup';
|
|
7
|
+
const startupInitiateRestartURLTemplate = `${startupURLTemplate}?_action=restart`;
|
|
8
|
+
|
|
9
|
+
const apiVersion = 'protocol=1.0,resource=1.0';
|
|
10
|
+
const getApiConfig = () => ({
|
|
11
|
+
path: `/environment/startup`,
|
|
12
|
+
apiVersion,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get status
|
|
17
|
+
* @returns {Promise} a promise that resolves to a status object
|
|
18
|
+
*/
|
|
19
|
+
export async function getStatus() {
|
|
20
|
+
const urlString = util.format(
|
|
21
|
+
startupURLTemplate,
|
|
22
|
+
getTenantURL(storage.session.getTenant())
|
|
23
|
+
);
|
|
24
|
+
return generateESVApi(getApiConfig()).get(urlString, {
|
|
25
|
+
withCredentials: true,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Initiate restart
|
|
31
|
+
* @returns {Promise} a promise that resolves to a status object
|
|
32
|
+
*/
|
|
33
|
+
export async function initiateRestart() {
|
|
34
|
+
const { restartStatus } = (await getStatus()).data;
|
|
35
|
+
if (restartStatus === 'ready') {
|
|
36
|
+
const urlString = util.format(
|
|
37
|
+
startupInitiateRestartURLTemplate,
|
|
38
|
+
getTenantURL(storage.session.getTenant())
|
|
39
|
+
);
|
|
40
|
+
return generateESVApi(getApiConfig()).post(urlString, null, {
|
|
41
|
+
withCredentials: true,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Not ready! Current status: ${restartStatus}`);
|
|
45
|
+
}
|