@webex/test-users 2.60.1-next.9 → 2.60.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -64
- package/dist/index.js.map +1 -1
- package/dist/whistler.js +4 -6
- package/dist/whistler.js.map +1 -1
- package/package.json +14 -15
- package/src/index.js +0 -58
- package/src/whistler.js +2 -6
package/dist/index.js
CHANGED
|
@@ -27,21 +27,20 @@ _Object$defineProperty(exports, "removeWhistlerTestUser", {
|
|
|
27
27
|
return _whistler.removeTestUser;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
exports.setPreferredSite = setPreferredSite;
|
|
31
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
32
30
|
var _now = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/date/now"));
|
|
33
31
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
32
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
33
|
+
var _defaultsDeep2 = _interopRequireDefault(require("lodash/defaultsDeep"));
|
|
34
34
|
var _assert = _interopRequireDefault(require("assert"));
|
|
35
35
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
36
36
|
var _btoa = _interopRequireDefault(require("btoa"));
|
|
37
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
38
37
|
var _nodeRandomName = _interopRequireDefault(require("node-random-name"));
|
|
39
38
|
var _httpCore = require("@webex/http-core");
|
|
40
39
|
var _whistler = _interopRequireWildcard(require("./whistler"));
|
|
41
|
-
function _getRequireWildcardCache(
|
|
42
|
-
function _interopRequireWildcard(
|
|
43
|
-
function ownKeys(
|
|
44
|
-
function _objectSpread(
|
|
40
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
41
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
42
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
43
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
45
44
|
var BASE_PATH_SECURE = '/users/test_users_s';
|
|
46
45
|
var BASE_PATH = '/users/test_users';
|
|
47
46
|
|
|
@@ -156,10 +155,6 @@ function requestWithAuth(options) {
|
|
|
156
155
|
* @property {string} [roles] defaults to []
|
|
157
156
|
* @property {string} [scope] defaults to WEBEX_SCOPE
|
|
158
157
|
* @property {string} [type] used to create a machine
|
|
159
|
-
* @property {boolean} [forceCreate] force creates the user, to be used in conjunction with ensureExistsInWebexSites
|
|
160
|
-
* @property {boolean} [ensureExistsInWebexSites] syncs the user in provided webexSites (syncInWebexSites)
|
|
161
|
-
* @property {Array.<string>} [syncInWebexSites] used to define in which sites account should be synced
|
|
162
|
-
* @property {string} [orgAdminAuthorization] bearer token of org admin to use syncInWebexSites
|
|
163
158
|
*/
|
|
164
159
|
|
|
165
160
|
/**
|
|
@@ -207,7 +202,7 @@ function createTestUser() {
|
|
|
207
202
|
clientSecret: clientSecret,
|
|
208
203
|
displayName: options.displayName || (0, _nodeRandomName.default)(),
|
|
209
204
|
emailTemplate: options.emailAddress,
|
|
210
|
-
entitlements: options.entitlements || ['spark', 'squaredCallInitiation', 'squaredRoomModeration', 'squaredInviter', 'webExSquared'
|
|
205
|
+
entitlements: options.entitlements || ['spark', 'squaredCallInitiation', 'squaredRoomModeration', 'squaredInviter', 'webExSquared'],
|
|
211
206
|
idbrokerUrl: idbrokerUrl,
|
|
212
207
|
machineType: options.machineType,
|
|
213
208
|
orgId: options.orgId,
|
|
@@ -215,11 +210,7 @@ function createTestUser() {
|
|
|
215
210
|
password: options.password || "".concat(_uuid.default.v4(), "zAY1*"),
|
|
216
211
|
roles: options.roles || [],
|
|
217
212
|
scopes: options.scope || process.env.WEBEX_SCOPE,
|
|
218
|
-
type: options.type
|
|
219
|
-
forceCreate: options.forceCreate || false,
|
|
220
|
-
ensureExistsInWebexSites: options.ensureExistsInWebexSites || false,
|
|
221
|
-
syncInWebexSites: options.syncInWebexSites,
|
|
222
|
-
orgAdminAuthorization: options.orgAdminAuthorization
|
|
213
|
+
type: options.type
|
|
223
214
|
};
|
|
224
215
|
return requestWithAuth({
|
|
225
216
|
method: 'POST',
|
|
@@ -265,7 +256,7 @@ function loginTestUser(options) {
|
|
|
265
256
|
method: 'POST',
|
|
266
257
|
uri: "".concat(cigServiceUrl).concat(BASE_PATH, "/login"),
|
|
267
258
|
json: true,
|
|
268
|
-
body:
|
|
259
|
+
body: (0, _defaultsDeep2.default)(options, {
|
|
269
260
|
clientId: clientId,
|
|
270
261
|
clientSecret: clientSecret
|
|
271
262
|
})
|
|
@@ -317,50 +308,4 @@ function removeTestUser() {
|
|
|
317
308
|
uri: "".concat(cigServiceUrl).concat(BASE_PATH, "/delete")
|
|
318
309
|
});
|
|
319
310
|
}
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Sets the preferredWebexSite for the provided user
|
|
323
|
-
*
|
|
324
|
-
* This method should be used to ensure a created test user has the right webex site set.
|
|
325
|
-
*
|
|
326
|
-
* @param {Object} options
|
|
327
|
-
* @param {string} options.userId user id to set site
|
|
328
|
-
* @param {string} options.preferredSite new preferred webexsite
|
|
329
|
-
* @param {string} options.orgId orgId of the site
|
|
330
|
-
* @param {string} options.identityServiceUrl url of identity service
|
|
331
|
-
* @param {string} options.authorization
|
|
332
|
-
* @param {string} options.clientId
|
|
333
|
-
* @param {string} options.clientSecret
|
|
334
|
-
* @returns {Promise}
|
|
335
|
-
*/
|
|
336
|
-
function setPreferredSite() {
|
|
337
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
338
|
-
var clientId = options.clientId || process.env.WEBEX_CLIENT_ID;
|
|
339
|
-
var clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;
|
|
340
|
-
if (!clientId) {
|
|
341
|
-
throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');
|
|
342
|
-
}
|
|
343
|
-
if (!clientSecret) {
|
|
344
|
-
throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/* eslint-disable no-useless-escape */
|
|
348
|
-
var body = {
|
|
349
|
-
schemas: ['urn:scim:schemas:core:1.0', 'urn:scim:schemas:extension:cisco:commonidentity:1.0'],
|
|
350
|
-
userPreferences: [{
|
|
351
|
-
value: "\"preferredWebExSite\":\"".concat(options.preferredSite, "\"")
|
|
352
|
-
}]
|
|
353
|
-
};
|
|
354
|
-
/* eslint-enable no-useless-escape */
|
|
355
|
-
|
|
356
|
-
return (0, _httpCore.request)({
|
|
357
|
-
method: 'PATCH',
|
|
358
|
-
headers: {
|
|
359
|
-
authorization: options.authorization
|
|
360
|
-
},
|
|
361
|
-
uri: "".concat(options.identityServiceUrl, "/identity/scim/").concat(options.orgId, "/v1/Users/").concat(options.userId),
|
|
362
|
-
json: true,
|
|
363
|
-
body: body
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
311
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_assert","_interopRequireDefault","require","_uuid","_btoa","_lodash","_nodeRandomName","_httpCore","_whistler","_interopRequireWildcard","_getRequireWildcardCache","e","_WeakMap","r","t","__esModule","_typeof","default","has","get","n","__proto__","a","_Object$defineProperty","_Object$getOwnPropertyDescriptor","u","Object","prototype","hasOwnProperty","call","i","set","ownKeys","_Object$keys","_Object$getOwnPropertySymbols","o","filter","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty2","_Object$getOwnPropertyDescriptors","_Object$defineProperties","BASE_PATH_SECURE","BASE_PATH","fixToken","token","now","_now","expires_in","expires","refresh_token_expires_in","refresh_token_expires","token_type","access_token","authorization","concat","clientToken","getClientCredentials","_ref","clientId","clientSecret","idbrokerUrl","_promise","resolve","request","method","uri","json","form","grant_type","scope","client_id","client_secret","headers","btoa","then","res","body","requestWithAuth","options","createTestUser","undefined","process","env","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","IDBROKER_BASE_URL","cigServiceUrl","WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL","WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL","Error","authCodeOnly","displayName","randomName","emailTemplate","emailAddress","entitlements","machineType","orgId","password","uuid","v4","roles","scopes","WEBEX_SCOPE","type","forceCreate","ensureExistsInWebexSites","syncInWebexSites","orgAdminAuthorization","user","email","name","loginTestUser","_","defaultsDeep","removeTestUser","id","reject","assert","user_id","refresh_token","user_type","userType","setPreferredSite","schemas","userPreferences","value","preferredSite","identityServiceUrl","userId"],"sources":["index.js"],"sourcesContent":["import assert from 'assert';\n\nimport uuid from 'uuid';\nimport btoa from 'btoa';\nimport _ from 'lodash';\nimport randomName from 'node-random-name';\nimport {request} from '@webex/http-core';\n\nconst BASE_PATH_SECURE = '/users/test_users_s';\nconst BASE_PATH = '/users/test_users';\n\n/**\n * Computes `expires` and `refresh_token_expires` from `expires_in` and\n * `refresh_token_expires_in` and creates an `authorization` string.\n * @param {Object} token\n * @private\n * @returns {Object}\n */\nfunction fixToken(token) {\n const now = Date.now();\n\n if (token.expires_in && !token.expires) {\n token.expires = now + token.expires_in * 1000;\n }\n\n if (token.refresh_token_expires_in && !token.refresh_token_expires) {\n /* eslint camelcase: [0] */\n token.refresh_token_expires = now + token.refresh_token_expires_in * 1000;\n }\n\n if (token.token_type && token.access_token) {\n token.authorization = `${token.token_type} ${token.access_token}`;\n }\n\n return token;\n}\n\nlet clientToken;\n\n/**\n * Fetches credentials to talk to the test_users_s endpoint\n *\n * Caches result in `clientToken` variable for multiple runs\n * @param {Object} options\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.idbrokerUrl\n * @private\n * @returns {String}\n */\nfunction getClientCredentials({clientId, clientSecret, idbrokerUrl}) {\n if (clientToken) {\n return Promise.resolve(clientToken);\n }\n\n return request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,\n json: true,\n form: {\n grant_type: 'client_credentials',\n scope: 'Identity:SCIM webexsquare:get_conversation',\n client_id: clientId,\n client_secret: clientSecret,\n },\n headers: {\n // Note: we can't request's auth hash here because this endpoint expects\n // us to send the auth header *without including \"Basic \"* before the\n // token string\n authorization: btoa(`${clientId}:${clientSecret}`),\n },\n })\n .then((res) => {\n const token = fixToken(res.body);\n\n return `${token.token_type} ${token.access_token}`;\n })\n .then((token) => {\n clientToken = token;\n\n return clientToken;\n });\n}\n\n/**\n * Makes a request authorized with client credentials\n * @param {Object} options\n * @param {Object} options.body\n * @param {string} options.body.clientId\n * @param {string} options.body.clientSecret\n * @param {string} options.body.idbrokerUrl\n * @private\n * @returns {Promise<HttpResponseObject>}\n */\nfunction requestWithAuth(options) {\n return getClientCredentials(options.body).then((authorization) => {\n options.headers = options.headers || {};\n options.headers.authorization = authorization;\n\n return request(options);\n });\n}\n\n/**\n * @typedef {Object} AccessTokenObject\n * @property {string} token.access_token\n * @property {Number} token.expires_in\n * @property {string} token.token_type\n * @property {string} token.refresh_token\n * @property {Number} token.refresh_token_expires_in\n * @property {string} token.expires\n * @property {string} token.refresh_token_expires\n */\n\n/**\n * @typedef {Object} CreateUserOptions\n * @property {boolean} [authCodeOnly] generates auth_code\n * @param {string} [clientId] defaults to WEBEX_CLIENT_ID\n * @param {string} [clientSecret] defaults to WEBEX_CLIENT_SECRET\n * @param {string} [cigServiceUrl] defaults to WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL\n * @property {string} [displayName]\n * @property {string} [emailAddress]\n * @property {Array.<string>} [entitlements]\n * @param {string} [idbrokerUrl] defaults to IDBROKER_BASE_URL\n * @property {string} [machineType] used when creating a machine user/device\n * @property {string} [orgId] organization ID to create the user under\n * @property {string} [password] defaults to a random password\n * @property {string} [roles] defaults to []\n * @property {string} [scope] defaults to WEBEX_SCOPE\n * @property {string} [type] used to create a machine\n * @property {boolean} [forceCreate] force creates the user, to be used in conjunction with ensureExistsInWebexSites\n * @property {boolean} [ensureExistsInWebexSites] syncs the user in provided webexSites (syncInWebexSites)\n * @property {Array.<string>} [syncInWebexSites] used to define in which sites account should be synced\n * @property {string} [orgAdminAuthorization] bearer token of org admin to use syncInWebexSites\n */\n\n/**\n * @typedef {Object} TestUserObject\n * @property {string} password\n * @property {string} emailAddress\n * @property {string} displayName\n * @property {string} id\n * @property {string} userName\n * @property {string} email\n * @property {string} name\n * @property {string} givenName\n * @property {string} type\n * @property {Array.<string>} entitlements\n * @property {string} orgId\n * @property {AccessTokenObject} token\n */\n\n/**\n * Creates a test user\n * @param {CreateUserOptions} options\n * @returns {Promise.<TestUserObject>}\n */\nexport function createTestUser(options = {}) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;\n const cigServiceUrl =\n options.cigServiceUrl ||\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!idbrokerUrl) {\n throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');\n }\n\n if (!cigServiceUrl) {\n throw new Error(\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\n );\n }\n\n const body = {\n authCodeOnly: options.authCodeOnly,\n clientId,\n clientSecret,\n displayName: options.displayName || randomName(),\n emailTemplate: options.emailAddress,\n entitlements: options.entitlements || [\n 'spark',\n 'squaredCallInitiation',\n 'squaredRoomModeration',\n 'squaredInviter',\n 'webExSquared',\n 'basicMessage',\n ],\n idbrokerUrl,\n machineType: options.machineType,\n orgId: options.orgId,\n // The five characters on the end are to hit all the password requirements\n password: options.password || `${uuid.v4()}zAY1*`,\n roles: options.roles || [],\n scopes: options.scope || process.env.WEBEX_SCOPE,\n type: options.type,\n forceCreate: options.forceCreate || false,\n ensureExistsInWebexSites: options.ensureExistsInWebexSites || false,\n syncInWebexSites: options.syncInWebexSites,\n orgAdminAuthorization: options.orgAdminAuthorization,\n };\n\n return requestWithAuth({\n method: 'POST',\n uri: `${cigServiceUrl}${BASE_PATH_SECURE}`,\n json: true,\n body,\n }).then((res) => ({\n password: body.password,\n emailAddress: res.body.user.email,\n displayName: res.body.user.name,\n ...res.body.user,\n token: fixToken(res.body.token),\n }));\n}\n\n/**\n * Exchanges a user name/password for an access token\n * @param {Object} options\n * @param {string} options.id\n * @param {string} options.email\n * @param {string} options.password\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.cigServiceUrl\n * @returns {Promise.<AccessTokenObject>}\n */\nexport function loginTestUser(options) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const cigServiceUrl =\n options.cigServiceUrl ||\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!cigServiceUrl) {\n throw new Error(\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\n );\n }\n\n return request({\n method: 'POST',\n uri: `${cigServiceUrl}${BASE_PATH}/login`,\n json: true,\n body: _.defaultsDeep(options, {\n clientId,\n clientSecret,\n }),\n }).then((res) => fixToken(res.body));\n}\n\n/**\n * Removes a test user\n * @param {Object} options\n * @param {string} options.id user id to remove\n * @param {string} options.cigServiceUrl\n * @param {Object} options.token\n * @param {string} options.token.authorization\n * @param {string} [options.token.refresh_token]\n * @returns {Promise}\n */\nexport function removeTestUser(options = {}) {\n const cigServiceUrl =\n options.cigServiceUrl ||\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!cigServiceUrl) {\n throw new Error(\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\n );\n }\n\n if (!options.id) {\n return Promise.reject(new Error('options.id is required'));\n }\n\n if (!options.token) {\n return loginTestUser(options).then((token) => {\n options.token = token;\n\n return removeTestUser(options);\n });\n }\n\n assert(options.token.authorization, 'options.token.authorization must be defined');\n\n return request({\n method: 'POST',\n json: true,\n headers: {\n authorization: options.token.authorization,\n },\n body: {\n /* eslint-disable camelcase */\n user_id: options.id,\n refresh_token: options.token.refresh_token,\n user_type: options.userType || 'PERSON',\n /* eslint-enable camelcase */\n },\n uri: `${cigServiceUrl}${BASE_PATH}/delete`,\n });\n}\n\n/**\n * Sets the preferredWebexSite for the provided user\n *\n * This method should be used to ensure a created test user has the right webex site set.\n *\n * @param {Object} options\n * @param {string} options.userId user id to set site\n * @param {string} options.preferredSite new preferred webexsite\n * @param {string} options.orgId orgId of the site\n * @param {string} options.identityServiceUrl url of identity service\n * @param {string} options.authorization\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @returns {Promise}\n */\nexport function setPreferredSite(options = {}) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n /* eslint-disable no-useless-escape */\n const body = {\n schemas: ['urn:scim:schemas:core:1.0', 'urn:scim:schemas:extension:cisco:commonidentity:1.0'],\n userPreferences: [\n {\n value: `\\\"preferredWebExSite\\\":\\\"${options.preferredSite}\\\"`,\n },\n ],\n };\n /* eslint-enable no-useless-escape */\n\n return request({\n method: 'PATCH',\n headers: {\n authorization: options.authorization,\n },\n uri: `${options.identityServiceUrl}/identity/scim/${options.orgId}/v1/Users/${options.userId}`,\n json: true,\n body,\n });\n}\n\nexport {\n default as create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AAe;EAChE,IAAMxB,YAAY,GAAGmB,OAAO,CAACnB,YAAY,IAAIsB,OAAO,CAACC,GAAG,CAACE,mBAAmB;EAE5E,IAAI,CAAC1B,QAAQ,EAAE;IACb,MAAM,IAAI+B,KAAK,CAAC,iEAAiE,CAAC;EACpF;EAEA,IAAI,CAAC9B,YAAY,EAAE;IACjB,MAAM,IAAI8B,KAAK,CAAC,yEAAyE,CAAC;EAC5F;;EAEA;EACA,IAAMb,IAAI,GAAG;IACXgD,OAAO,EAAE,CAAC,2BAA2B,EAAE,qDAAqD,CAAC;IAC7FC,eAAe,EAAE,CACf;MACEC,KAAK,8BAAAxE,MAAA,CAA8BwB,OAAO,CAACiD,aAAa;IAC1D,CAAC;EAEL,CAAC;EACD;;EAEA,OAAO,IAAAhE,iBAAO,EAAC;IACbC,MAAM,EAAE,OAAO;IACfQ,OAAO,EAAE;MACPnB,aAAa,EAAEyB,OAAO,CAACzB;IACzB,CAAC;IACDY,GAAG,KAAAX,MAAA,CAAKwB,OAAO,CAACkD,kBAAkB,qBAAA1E,MAAA,CAAkBwB,OAAO,CAACmB,KAAK,gBAAA3C,MAAA,CAAawB,OAAO,CAACmD,MAAM,CAAE;IAC9F/D,IAAI,EAAE,IAAI;IACVU,IAAI,EAAJA;EACF,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"names":["_assert","_interopRequireDefault","require","_uuid","_btoa","_nodeRandomName","_httpCore","_whistler","_interopRequireWildcard","_getRequireWildcardCache","nodeInterop","_WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","default","cache","has","get","newObj","hasPropertyDescriptor","_Object$defineProperty","_Object$getOwnPropertyDescriptor","key","Object","prototype","hasOwnProperty","call","desc","set","ownKeys","object","enumerableOnly","keys","_Object$keys","_Object$getOwnPropertySymbols","symbols","filter","sym","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","_defineProperty2","_Object$getOwnPropertyDescriptors","_Object$defineProperties","BASE_PATH_SECURE","BASE_PATH","fixToken","token","now","_now","expires_in","expires","refresh_token_expires_in","refresh_token_expires","token_type","access_token","authorization","concat","clientToken","getClientCredentials","_ref","clientId","clientSecret","idbrokerUrl","_promise","resolve","request","method","uri","json","form","grant_type","scope","client_id","client_secret","headers","btoa","then","res","body","requestWithAuth","options","createTestUser","undefined","process","env","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","IDBROKER_BASE_URL","cigServiceUrl","WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL","WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL","Error","authCodeOnly","displayName","randomName","emailTemplate","emailAddress","entitlements","machineType","orgId","password","uuid","v4","roles","scopes","WEBEX_SCOPE","type","user","email","name","loginTestUser","_defaultsDeep2","removeTestUser","id","reject","assert","user_id","refresh_token","user_type","userType"],"sources":["index.js"],"sourcesContent":["import assert from 'assert';\n\nimport uuid from 'uuid';\nimport btoa from 'btoa';\nimport _ from 'lodash';\nimport randomName from 'node-random-name';\nimport {request} from '@webex/http-core';\n\nconst BASE_PATH_SECURE = '/users/test_users_s';\nconst BASE_PATH = '/users/test_users';\n\n/**\n * Computes `expires` and `refresh_token_expires` from `expires_in` and\n * `refresh_token_expires_in` and creates an `authorization` string.\n * @param {Object} token\n * @private\n * @returns {Object}\n */\nfunction fixToken(token) {\n const now = Date.now();\n\n if (token.expires_in && !token.expires) {\n token.expires = now + token.expires_in * 1000;\n }\n\n if (token.refresh_token_expires_in && !token.refresh_token_expires) {\n /* eslint camelcase: [0] */\n token.refresh_token_expires = now + token.refresh_token_expires_in * 1000;\n }\n\n if (token.token_type && token.access_token) {\n token.authorization = `${token.token_type} ${token.access_token}`;\n }\n\n return token;\n}\n\nlet clientToken;\n\n/**\n * Fetches credentials to talk to the test_users_s endpoint\n *\n * Caches result in `clientToken` variable for multiple runs\n * @param {Object} options\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.idbrokerUrl\n * @private\n * @returns {String}\n */\nfunction getClientCredentials({clientId, clientSecret, idbrokerUrl}) {\n if (clientToken) {\n return Promise.resolve(clientToken);\n }\n\n return request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,\n json: true,\n form: {\n grant_type: 'client_credentials',\n scope: 'Identity:SCIM webexsquare:get_conversation',\n client_id: clientId,\n client_secret: clientSecret,\n },\n headers: {\n // Note: we can't request's auth hash here because this endpoint expects\n // us to send the auth header *without including \"Basic \"* before the\n // token string\n authorization: btoa(`${clientId}:${clientSecret}`),\n },\n })\n .then((res) => {\n const token = fixToken(res.body);\n\n return `${token.token_type} ${token.access_token}`;\n })\n .then((token) => {\n clientToken = token;\n\n return clientToken;\n });\n}\n\n/**\n * Makes a request authorized with client credentials\n * @param {Object} options\n * @param {Object} options.body\n * @param {string} options.body.clientId\n * @param {string} options.body.clientSecret\n * @param {string} options.body.idbrokerUrl\n * @private\n * @returns {Promise<HttpResponseObject>}\n */\nfunction requestWithAuth(options) {\n return getClientCredentials(options.body).then((authorization) => {\n options.headers = options.headers || {};\n options.headers.authorization = authorization;\n\n return request(options);\n });\n}\n\n/**\n * @typedef {Object} AccessTokenObject\n * @property {string} token.access_token\n * @property {Number} token.expires_in\n * @property {string} token.token_type\n * @property {string} token.refresh_token\n * @property {Number} token.refresh_token_expires_in\n * @property {string} token.expires\n * @property {string} token.refresh_token_expires\n */\n\n/**\n * @typedef {Object} CreateUserOptions\n * @property {boolean} [authCodeOnly] generates auth_code\n * @param {string} [clientId] defaults to WEBEX_CLIENT_ID\n * @param {string} [clientSecret] defaults to WEBEX_CLIENT_SECRET\n * @param {string} [cigServiceUrl] defaults to WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL\n * @property {string} [displayName]\n * @property {string} [emailAddress]\n * @property {Array.<string>} [entitlements]\n * @param {string} [idbrokerUrl] defaults to IDBROKER_BASE_URL\n * @property {string} [machineType] used when creating a machine user/device\n * @property {string} [orgId] organization ID to create the user under\n * @property {string} [password] defaults to a random password\n * @property {string} [roles] defaults to []\n * @property {string} [scope] defaults to WEBEX_SCOPE\n * @property {string} [type] used to create a machine\n */\n\n/**\n * @typedef {Object} TestUserObject\n * @property {string} password\n * @property {string} emailAddress\n * @property {string} displayName\n * @property {string} id\n * @property {string} userName\n * @property {string} email\n * @property {string} name\n * @property {string} givenName\n * @property {string} type\n * @property {Array.<string>} entitlements\n * @property {string} orgId\n * @property {AccessTokenObject} token\n */\n\n/**\n * Creates a test user\n * @param {CreateUserOptions} options\n * @returns {Promise.<TestUserObject>}\n */\nexport function createTestUser(options = {}) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;\n const cigServiceUrl =\n options.cigServiceUrl ||\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!idbrokerUrl) {\n throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');\n }\n\n if (!cigServiceUrl) {\n throw new Error(\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\n );\n }\n\n const body = {\n authCodeOnly: options.authCodeOnly,\n clientId,\n clientSecret,\n displayName: options.displayName || randomName(),\n emailTemplate: options.emailAddress,\n entitlements: options.entitlements || [\n 'spark',\n 'squaredCallInitiation',\n 'squaredRoomModeration',\n 'squaredInviter',\n 'webExSquared',\n ],\n idbrokerUrl,\n machineType: options.machineType,\n orgId: options.orgId,\n // The five characters on the end are to hit all the password requirements\n password: options.password || `${uuid.v4()}zAY1*`,\n roles: options.roles || [],\n scopes: options.scope || process.env.WEBEX_SCOPE,\n type: options.type,\n };\n\n return requestWithAuth({\n method: 'POST',\n uri: `${cigServiceUrl}${BASE_PATH_SECURE}`,\n json: true,\n body,\n }).then((res) => ({\n password: body.password,\n emailAddress: res.body.user.email,\n displayName: res.body.user.name,\n ...res.body.user,\n token: fixToken(res.body.token),\n }));\n}\n\n/**\n * Exchanges a user name/password for an access token\n * @param {Object} options\n * @param {string} options.id\n * @param {string} options.email\n * @param {string} options.password\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.cigServiceUrl\n * @returns {Promise.<AccessTokenObject>}\n */\nexport function loginTestUser(options) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const cigServiceUrl =\n options.cigServiceUrl ||\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!cigServiceUrl) {\n throw new Error(\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\n );\n }\n\n return request({\n method: 'POST',\n uri: `${cigServiceUrl}${BASE_PATH}/login`,\n json: true,\n body: _.defaultsDeep(options, {\n clientId,\n clientSecret,\n }),\n }).then((res) => fixToken(res.body));\n}\n\n/**\n * Removes a test user\n * @param {Object} options\n * @param {string} options.id user id to remove\n * @param {string} options.cigServiceUrl\n * @param {Object} options.token\n * @param {string} options.token.authorization\n * @param {string} [options.token.refresh_token]\n * @returns {Promise}\n */\nexport function removeTestUser(options = {}) {\n const cigServiceUrl =\n options.cigServiceUrl ||\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\n\n if (!cigServiceUrl) {\n throw new Error(\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\n );\n }\n\n if (!options.id) {\n return Promise.reject(new Error('options.id is required'));\n }\n\n if (!options.token) {\n return loginTestUser(options).then((token) => {\n options.token = token;\n\n return removeTestUser(options);\n });\n }\n\n assert(options.token.authorization, 'options.token.authorization must be defined');\n\n return request({\n method: 'POST',\n json: true,\n headers: {\n authorization: options.token.authorization,\n },\n body: {\n /* eslint-disable camelcase */\n user_id: options.id,\n refresh_token: options.token.refresh_token,\n user_type: options.userType || 'PERSON',\n /* eslint-enable camelcase */\n },\n uri: `${cigServiceUrl}${BASE_PATH}/delete`,\n });\n}\n\nexport {\n default as createWhistlerTestUser,\n removeTestUser as removeWhistlerTestUser,\n} from './whistler';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,KAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA,IAAAG,eAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAoTA,IAAAK,SAAA,GAAAC,uBAAA,CAAAN,OAAA;AAGoB,SAAAO,yBAAAC,WAAA,eAAAC,QAAA,kCAAAC,iBAAA,OAAAD,QAAA,QAAAE,gBAAA,OAAAF,QAAA,YAAAF,wBAAA,YAAAA,yBAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAF,wBAAAM,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,aAAAE,OAAA,CAAAF,GAAA,yBAAAA,GAAA,4BAAAG,OAAA,EAAAH,GAAA,UAAAI,KAAA,GAAAT,wBAA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R,OAAO,CAACQ,aAAa,IACrBL,OAAO,CAACC,GAAG,CAACK,uCAAuC,IACnDN,OAAO,CAACC,GAAG,CAACM,yCAAyC;EAEvD,IAAI,CAACF,aAAa,EAAE;IAClB,MAAM,IAAIG,KAAK,CACb,8FAA8F,CAC/F;EACH;EAEA,IAAI,CAACX,OAAO,CAACiC,EAAE,EAAE;IACf,OAAOlD,QAAA,CAAAzD,OAAA,CAAQ4G,MAAM,CAAC,IAAIvB,KAAK,CAAC,wBAAwB,CAAC,CAAC;EAC5D;EAEA,IAAI,CAACX,OAAO,CAAClC,KAAK,EAAE;IAClB,OAAOgE,aAAa,CAAC9B,OAAO,CAAC,CAACJ,IAAI,CAAC,UAAC9B,KAAK,EAAK;MAC5CkC,OAAO,CAAClC,KAAK,GAAGA,KAAK;MAErB,OAAOkE,cAAc,CAAChC,OAAO,CAAC;IAChC,CAAC,CAAC;EACJ;EAEA,IAAAmC,eAAM,EAACnC,OAAO,CAAClC,KAAK,CAACS,aAAa,EAAE,6CAA6C,CAAC;EAElF,OAAO,IAAAU,iBAAO,EAAC;IACbC,MAAM,EAAE,MAAM;IACdE,IAAI,EAAE,IAAI;IACVM,OAAO,EAAE;MACPnB,aAAa,EAAEyB,OAAO,CAAClC,KAAK,CAACS;IAC/B,CAAC;IACDuB,IAAI,EAAE;MACJ;MACAsC,OAAO,EAAEpC,OAAO,CAACiC,EAAE;MACnBI,aAAa,EAAErC,OAAO,CAAClC,KAAK,CAACuE,aAAa;MAC1CC,SAAS,EAAEtC,OAAO,CAACuC,QAAQ,IAAI;MAC/B;IACF,CAAC;;IACDpD,GAAG,KAAAX,MAAA,CAAKgC,aAAa,EAAAhC,MAAA,CAAGZ,SAAS;EACnC,CAAC,CAAC;AACJ"}
|
package/dist/whistler.js
CHANGED
|
@@ -15,10 +15,8 @@ exports.removeTestUser = removeTestUser;
|
|
|
15
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/defineProperty"));
|
|
16
16
|
var _btoa = _interopRequireDefault(require("btoa"));
|
|
17
17
|
var _httpCore = require("@webex/http-core");
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
function ownKeys(e, r) { var t = _Object$keys(e); if (_Object$getOwnPropertySymbols) { var o = _Object$getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return _Object$getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
21
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(e, _Object$getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { _Object$defineProperty(e, r, _Object$getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
20
|
/**
|
|
23
21
|
* Fetches credentials/access_token to talk to the whistler endpoint
|
|
24
22
|
*
|
|
@@ -104,8 +102,8 @@ function createTestUser() {
|
|
|
104
102
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
105
103
|
var clientId = options.clientId || process.env.WEBEX_CLIENT_ID;
|
|
106
104
|
var clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;
|
|
107
|
-
var machineAccount = options.machineAccount || process.env.WHISTLER_MACHINE_ACCOUNT
|
|
108
|
-
var machinePassword = options.machinePassword || process.env.WHISTLER_MACHINE_PASSWORD
|
|
105
|
+
var machineAccount = options.machineAccount || process.env.WHISTLER_MACHINE_ACCOUNT;
|
|
106
|
+
var machinePassword = options.machinePassword || process.env.WHISTLER_MACHINE_PASSWORD;
|
|
109
107
|
var idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;
|
|
110
108
|
var orgId = options.orgId || process.env.WHISTLER_TEST_ORG_ID;
|
|
111
109
|
var whistlerServiceUrl = options.whistlerServiceUrl || process.env.WHISTLER_API_SERVICE_URL;
|
package/dist/whistler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_btoa","_interopRequireDefault","require","_httpCore","_nodeRandomName","_uuid","ownKeys","e","r","t","_Object$keys","_Object$getOwnPropertySymbols","o","filter","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","Object","forEach","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","getClientCredentials","_ref","clientId","clientSecret","orgId","idbrokerUrl","machineAccount","machinePassword","request","method","uri","concat","json","body","uid","password","then","res","form","assertion","BearerToken","grant_type","scope","self_contained_token","client_id","client_secret","headers","authorization","btoa","token_type","access_token","createTestUser","options","undefined","process","env","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","WHISTLER_MACHINE_ACCOUNT","randomName","WHISTLER_MACHINE_PASSWORD","uuid","v4","IDBROKER_BASE_URL","WHISTLER_TEST_ORG_ID","whistlerServiceUrl","WHISTLER_API_SERVICE_URL","reservationGroup","userScopes","Error","qs","isAccessTokenRequired","responseMetaData","ciPassword","emailAddress","name","displayName","webExUserName","token","ciAccessToken","reservationUrl","removeTestUser"],"sources":["whistler.js"],"sourcesContent":["import btoa from 'btoa';\nimport {request} from '@webex/http-core';\nimport randomName from 'node-random-name';\nimport uuid from 'uuid';\n\n/**\n * Fetches credentials/access_token to talk to the whistler endpoint\n *\n * @param {Object} options\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.idbrokerUrl\n * @param {string} options.orgId\n * @param {string} options.machineAccount\n * @param {string} options.machinePassword\n * @private\n * @returns {Promise<string>}\n */\nconst getClientCredentials = ({\n clientId,\n clientSecret,\n orgId,\n idbrokerUrl,\n machineAccount,\n machinePassword,\n}) =>\n request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/token/${orgId}/v2/actions/GetBearerToken/invoke`,\n json: true,\n body: {\n uid: machineAccount,\n password: machinePassword,\n },\n })\n .then((res) =>\n request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,\n json: true,\n form: {\n assertion: res.body.BearerToken,\n grant_type: 'urn:ietf:params:oauth:grant-type:saml2-bearer',\n scope: 'webexsquare:get_conversation webexsquare:admin',\n self_contained_token: true,\n client_id: clientId,\n client_secret: clientSecret,\n },\n headers: {\n // Note: we can't request's auth hash here because this endpoint expects\n // us to send the auth header *without including \"Basic \"* before the\n // token string\n // authorization: `Basic + ${btoa(`${clientId}:${clientSecret}`)}`\n authorization: btoa(`${clientId}:${clientSecret}`),\n },\n })\n )\n .then((res) => `${res.body.token_type} ${res.body.access_token}`);\n\n/**\n * @typedef {Object} TestUserObject\n * @property {string} password\n * @property {string} emailAddress\n * @property {string} displayName\n * @property {string} token\n * @property {string} reservationUrl\n * @property {object} responseMetaData - whistler given properties\n */\n\n/**\n * @typedef {Object} CreateUserOptions\n * @param {Object} [options]\n * @param {string} [whistlerServiceUrl] defaults to WHISTLER_API_SERVICE_URL\n * @param {string} [options.clientId] defaults to WEBEX_CLIENT_ID\n * @param {string} [options.clientSecret] defaults to WEBEX_CLIENT_SECRET\n * @param {string} [options.idbrokerUrl] defaults to IDBROKER_BASE_URL\n * @param {string} [options.orgId] organization ID to create the user under\n * @param {string} [options.machineAccount] defaults to WHISTLER_MACHINE_ACCOUNT\n * @param {string} [options.machinePassword] defaults to WHISTLER_MACHINE_PASSWORD\n */\n\n/**\n * Creates a test user\n * @param {CreateUserOptions} options\n * @returns {Promise.<TestUserObject>}\n */\nexport default function createTestUser(options = {}) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const machineAccount =\n options.machineAccount || process.env.WHISTLER_MACHINE_ACCOUNT || randomName();\n const machinePassword =\n options.machinePassword || process.env.WHISTLER_MACHINE_PASSWORD || `${uuid.v4()}zAY1*`;\n const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;\n const orgId = options.orgId || process.env.WHISTLER_TEST_ORG_ID;\n const whistlerServiceUrl = options.whistlerServiceUrl || process.env.WHISTLER_API_SERVICE_URL;\n const {reservationGroup, userScopes} = options;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!machineAccount) {\n throw new Error(\n 'options.machineAccount or process.env.WHISTLER_MACHINE_ACCOUNT must be defined'\n );\n }\n\n if (!machinePassword) {\n throw new Error(\n 'options.machinePassword or process.env.WHISTLER_MACHINE_PASSWORD must be defined'\n );\n }\n if (!idbrokerUrl) {\n throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');\n }\n\n if (!orgId) {\n throw new Error('options.orgId or process.env.WHISTLER_TEST_ORG_ID must be defined');\n }\n\n if (!whistlerServiceUrl) {\n throw new Error(\n 'options.whistlerServiceUrl or process.env.WHISTLER_API_SERVICE_URL must be defined'\n );\n }\n\n // For reservation groups and user scopes\n // Please check https://confluence-eng-gpk2.cisco.com/conf/pages/viewpage.action?spaceKey=LOCUS&title=Whistler+APIs#WhistlerAPIs-GET/reservations/testUser\n return getClientCredentials({\n clientId,\n clientSecret,\n machineAccount,\n machinePassword,\n idbrokerUrl,\n orgId,\n })\n .then((authorization) =>\n request({\n method: 'GET',\n uri: `${whistlerServiceUrl}/reservations/testUser`,\n qs: {\n reservationGroup,\n userScopes,\n isAccessTokenRequired: true,\n },\n headers: {\n authorization,\n },\n })\n )\n .then((res) => ({\n password: res.body.responseMetaData.ciPassword,\n emailAddress: res.body.responseMetaData.name,\n displayName: res.body.responseMetaData.webExUserName,\n token: res.body.responseMetaData.ciAccessToken,\n reservationUrl: res.body.reservationUrl,\n ...res.body.responseMetaData,\n }));\n}\n\n/**\n *\n * @param {Object} options\n * @returns {Promise}\n */\nexport function removeTestUser(options = {}) {\n return request({\n method: 'DELETE',\n headers: {\n authorization: `Bearer ${options.token}`,\n },\n uri: options.reservationUrl,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAAwB,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,YAAA,CAAAH,CAAA,OAAAI,6BAAA,QAAAC,CAAA,GAAAD,6BAAA,CAAAJ,CAAA,GAAAC,CAAA,KAAAI,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAL,CAAA,WAAAM,gCAAA,CAAAP,CAAA,EAAAC,CAAA,EAAAO,UAAA,OAAAN,CAAA,CAAAO,IAAA,CAAAC,KAAA,CAAAR,CAAA,EAAAG,CAAA,YAAAH,CAAA;AAAA,SAAAS,cAAAX,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAW,SAAA,CAAAC,MAAA,EAAAZ,CAAA,UAAAC,CAAA,WAAAU,SAAA,CAAAX,CAAA,IAAAW,SAAA,CAAAX,CAAA,QAAAA,CAAA,OAAAF,O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AkB,2BAAwB;MAClDK,EAAE,EAAE;QACFH,gBAAgB,EAAhBA,gBAAgB;QAChBC,UAAU,EAAVA,UAAU;QACVG,qBAAqB,EAAE;MACzB,CAAC;MACDzB,OAAO,EAAE;QACPC,aAAa,EAAbA;MACF;IACF,CAAC,CAAC;EAAA,CACJ,CAAC,CACAX,IAAI,CAAC,UAACC,GAAG;IAAA,OAAA3B,aAAA;MACRyB,QAAQ,EAAEE,GAAG,CAACJ,IAAI,CAACuC,gBAAgB,CAACC,UAAU;MAC9CC,YAAY,EAAErC,GAAG,CAACJ,IAAI,CAACuC,gBAAgB,CAACG,IAAI;MAC5CC,WAAW,EAAEvC,GAAG,CAACJ,IAAI,CAACuC,gBAAgB,CAACK,aAAa;MACpDC,KAAK,EAAEzC,GAAG,CAACJ,IAAI,CAACuC,gBAAgB,CAACO,aAAa;MAC9CC,cAAc,EAAE3C,GAAG,CAACJ,IAAI,CAAC+C;IAAc,GACpC3C,GAAG,CAACJ,IAAI,CAACuC,gBAAgB;EAAA,CAC5B,CAAC;AACP;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASS,cAAcA,CAAA,EAAe;EAAA,IAAd7B,OAAO,GAAAzC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAA0C,SAAA,GAAA1C,SAAA,MAAG,CAAC,CAAC;EACzC,OAAO,IAAAiB,iBAAO,EAAC;IACbC,MAAM,EAAE,QAAQ;IAChBiB,OAAO,EAAE;MACPC,aAAa,YAAAhB,MAAA,CAAYqB,OAAO,CAAC0B,KAAK;IACxC,CAAC;IACDhD,GAAG,EAAEsB,OAAO,CAAC4B;EACf,CAAC,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"names":["_btoa","_interopRequireDefault","require","_httpCore","ownKeys","object","enumerableOnly","keys","_Object$keys","_Object$getOwnPropertySymbols","symbols","filter","sym","_Object$getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","Object","forEach","key","_defineProperty2","default","_Object$getOwnPropertyDescriptors","_Object$defineProperties","_Object$defineProperty","getClientCredentials","_ref","clientId","clientSecret","orgId","idbrokerUrl","machineAccount","machinePassword","request","method","uri","concat","json","body","uid","password","then","res","form","assertion","BearerToken","grant_type","scope","self_contained_token","client_id","client_secret","headers","authorization","btoa","token_type","access_token","createTestUser","options","undefined","process","env","WEBEX_CLIENT_ID","WEBEX_CLIENT_SECRET","WHISTLER_MACHINE_ACCOUNT","WHISTLER_MACHINE_PASSWORD","IDBROKER_BASE_URL","WHISTLER_TEST_ORG_ID","whistlerServiceUrl","WHISTLER_API_SERVICE_URL","reservationGroup","userScopes","Error","qs","isAccessTokenRequired","responseMetaData","ciPassword","emailAddress","name","displayName","webExUserName","token","ciAccessToken","reservationUrl","removeTestUser"],"sources":["whistler.js"],"sourcesContent":["import btoa from 'btoa';\nimport {request} from '@webex/http-core';\n\n/**\n * Fetches credentials/access_token to talk to the whistler endpoint\n *\n * @param {Object} options\n * @param {string} options.clientId\n * @param {string} options.clientSecret\n * @param {string} options.idbrokerUrl\n * @param {string} options.orgId\n * @param {string} options.machineAccount\n * @param {string} options.machinePassword\n * @private\n * @returns {Promise<string>}\n */\nconst getClientCredentials = ({\n clientId,\n clientSecret,\n orgId,\n idbrokerUrl,\n machineAccount,\n machinePassword,\n}) =>\n request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/token/${orgId}/v2/actions/GetBearerToken/invoke`,\n json: true,\n body: {\n uid: machineAccount,\n password: machinePassword,\n },\n })\n .then((res) =>\n request({\n method: 'POST',\n uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,\n json: true,\n form: {\n assertion: res.body.BearerToken,\n grant_type: 'urn:ietf:params:oauth:grant-type:saml2-bearer',\n scope: 'webexsquare:get_conversation webexsquare:admin',\n self_contained_token: true,\n client_id: clientId,\n client_secret: clientSecret,\n },\n headers: {\n // Note: we can't request's auth hash here because this endpoint expects\n // us to send the auth header *without including \"Basic \"* before the\n // token string\n // authorization: `Basic + ${btoa(`${clientId}:${clientSecret}`)}`\n authorization: btoa(`${clientId}:${clientSecret}`),\n },\n })\n )\n .then((res) => `${res.body.token_type} ${res.body.access_token}`);\n\n/**\n * @typedef {Object} TestUserObject\n * @property {string} password\n * @property {string} emailAddress\n * @property {string} displayName\n * @property {string} token\n * @property {string} reservationUrl\n * @property {object} responseMetaData - whistler given properties\n */\n\n/**\n * @typedef {Object} CreateUserOptions\n * @param {Object} [options]\n * @param {string} [whistlerServiceUrl] defaults to WHISTLER_API_SERVICE_URL\n * @param {string} [options.clientId] defaults to WEBEX_CLIENT_ID\n * @param {string} [options.clientSecret] defaults to WEBEX_CLIENT_SECRET\n * @param {string} [options.idbrokerUrl] defaults to IDBROKER_BASE_URL\n * @param {string} [options.orgId] organization ID to create the user under\n * @param {string} [options.machineAccount] defaults to WHISTLER_MACHINE_ACCOUNT\n * @param {string} [options.machinePassword] defaults to WHISTLER_MACHINE_PASSWORD\n */\n\n/**\n * Creates a test user\n * @param {CreateUserOptions} options\n * @returns {Promise.<TestUserObject>}\n */\nexport default function createTestUser(options = {}) {\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\n const machineAccount = options.machineAccount || process.env.WHISTLER_MACHINE_ACCOUNT;\n const machinePassword = options.machinePassword || process.env.WHISTLER_MACHINE_PASSWORD;\n const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;\n const orgId = options.orgId || process.env.WHISTLER_TEST_ORG_ID;\n const whistlerServiceUrl = options.whistlerServiceUrl || process.env.WHISTLER_API_SERVICE_URL;\n const {reservationGroup, userScopes} = options;\n\n if (!clientId) {\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\n }\n\n if (!clientSecret) {\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\n }\n\n if (!machineAccount) {\n throw new Error(\n 'options.machineAccount or process.env.WHISTLER_MACHINE_ACCOUNT must be defined'\n );\n }\n\n if (!machinePassword) {\n throw new Error(\n 'options.machinePassword or process.env.WHISTLER_MACHINE_PASSWORD must be defined'\n );\n }\n if (!idbrokerUrl) {\n throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');\n }\n\n if (!orgId) {\n throw new Error('options.orgId or process.env.WHISTLER_TEST_ORG_ID must be defined');\n }\n\n if (!whistlerServiceUrl) {\n throw new Error(\n 'options.whistlerServiceUrl or process.env.WHISTLER_API_SERVICE_URL must be defined'\n );\n }\n\n // For reservation groups and user scopes\n // Please check https://confluence-eng-gpk2.cisco.com/conf/pages/viewpage.action?spaceKey=LOCUS&title=Whistler+APIs#WhistlerAPIs-GET/reservations/testUser\n return getClientCredentials({\n clientId,\n clientSecret,\n machineAccount,\n machinePassword,\n idbrokerUrl,\n orgId,\n })\n .then((authorization) =>\n request({\n method: 'GET',\n uri: `${whistlerServiceUrl}/reservations/testUser`,\n qs: {\n reservationGroup,\n userScopes,\n isAccessTokenRequired: true,\n },\n headers: {\n authorization,\n },\n })\n )\n .then((res) => ({\n password: res.body.responseMetaData.ciPassword,\n emailAddress: res.body.responseMetaData.name,\n displayName: res.body.responseMetaData.webExUserName,\n token: res.body.responseMetaData.ciAccessToken,\n reservationUrl: res.body.reservationUrl,\n ...res.body.responseMetaData,\n }));\n}\n\n/**\n *\n * @param {Object} options\n * @returns {Promise}\n */\nexport function removeTestUser(options = {}) {\n return request({\n method: 'DELETE',\n headers: {\n authorization: `Bearer ${options.token}`,\n },\n uri: options.reservationUrl,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAAyC,SAAAE,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,YAAA,CAAAH,MAAA,OAAAI,6BAAA,QAAAC,OAAA,GAAAD,6BAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,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"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/test-users",
|
|
3
|
+
"version": "2.60.2",
|
|
3
4
|
"description": "Cisco Webex Test Users",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"main": "dist/index.js",
|
|
@@ -10,7 +11,7 @@
|
|
|
10
11
|
"directory": "packages/@webex/test-users"
|
|
11
12
|
},
|
|
12
13
|
"engines": {
|
|
13
|
-
"node": ">=
|
|
14
|
+
"node": ">=14"
|
|
14
15
|
},
|
|
15
16
|
"browserify": {
|
|
16
17
|
"transform": [
|
|
@@ -20,22 +21,22 @@
|
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"@babel/core": "^7.17.10",
|
|
23
|
-
"@webex/babel-config-legacy": "
|
|
24
|
-
"@webex/eslint-config-legacy": "
|
|
25
|
-
"@webex/jest-config-legacy": "
|
|
26
|
-
"@webex/legacy-tools": "
|
|
27
|
-
"@webex/test-helper-chai": "2.60.
|
|
28
|
-
"@webex/test-helper-mocha": "2.60.
|
|
29
|
-
"@webex/test-helper-mock-webex": "2.60.
|
|
30
|
-
"@webex/test-helper-test-users": "2.60.
|
|
24
|
+
"@webex/babel-config-legacy": "2.60.2",
|
|
25
|
+
"@webex/eslint-config-legacy": "2.60.2",
|
|
26
|
+
"@webex/jest-config-legacy": "2.60.2",
|
|
27
|
+
"@webex/legacy-tools": "2.60.2",
|
|
28
|
+
"@webex/test-helper-chai": "2.60.2",
|
|
29
|
+
"@webex/test-helper-mocha": "2.60.2",
|
|
30
|
+
"@webex/test-helper-mock-webex": "2.60.2",
|
|
31
|
+
"@webex/test-helper-test-users": "2.60.2",
|
|
31
32
|
"chai": "^4.3.4",
|
|
32
33
|
"chai-as-promised": "^7.1.1",
|
|
33
34
|
"eslint": "^8.24.0",
|
|
34
35
|
"prettier": "^2.7.1"
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
|
-
"@webex/http-core": "2.60.
|
|
38
|
-
"@webex/test-helper-mocha": "2.60.
|
|
38
|
+
"@webex/http-core": "2.60.2",
|
|
39
|
+
"@webex/test-helper-mocha": "2.60.2",
|
|
39
40
|
"btoa": "^1.2.1",
|
|
40
41
|
"lodash": "^4.17.21",
|
|
41
42
|
"node-random-name": "^1.0.1",
|
|
@@ -44,12 +45,10 @@
|
|
|
44
45
|
"scripts": {
|
|
45
46
|
"build": "yarn build:src",
|
|
46
47
|
"build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
|
|
47
|
-
"deploy:npm": "yarn npm publish",
|
|
48
48
|
"test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
|
|
49
49
|
"test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
|
|
50
50
|
"test:integration:broken": "webex-legacy-tools test --integration --runner mocha",
|
|
51
51
|
"test:style": "eslint ./src/**/*.*",
|
|
52
52
|
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/index.js
CHANGED
|
@@ -128,10 +128,6 @@ function requestWithAuth(options) {
|
|
|
128
128
|
* @property {string} [roles] defaults to []
|
|
129
129
|
* @property {string} [scope] defaults to WEBEX_SCOPE
|
|
130
130
|
* @property {string} [type] used to create a machine
|
|
131
|
-
* @property {boolean} [forceCreate] force creates the user, to be used in conjunction with ensureExistsInWebexSites
|
|
132
|
-
* @property {boolean} [ensureExistsInWebexSites] syncs the user in provided webexSites (syncInWebexSites)
|
|
133
|
-
* @property {Array.<string>} [syncInWebexSites] used to define in which sites account should be synced
|
|
134
|
-
* @property {string} [orgAdminAuthorization] bearer token of org admin to use syncInWebexSites
|
|
135
131
|
*/
|
|
136
132
|
|
|
137
133
|
/**
|
|
@@ -194,7 +190,6 @@ export function createTestUser(options = {}) {
|
|
|
194
190
|
'squaredRoomModeration',
|
|
195
191
|
'squaredInviter',
|
|
196
192
|
'webExSquared',
|
|
197
|
-
'basicMessage',
|
|
198
193
|
],
|
|
199
194
|
idbrokerUrl,
|
|
200
195
|
machineType: options.machineType,
|
|
@@ -204,10 +199,6 @@ export function createTestUser(options = {}) {
|
|
|
204
199
|
roles: options.roles || [],
|
|
205
200
|
scopes: options.scope || process.env.WEBEX_SCOPE,
|
|
206
201
|
type: options.type,
|
|
207
|
-
forceCreate: options.forceCreate || false,
|
|
208
|
-
ensureExistsInWebexSites: options.ensureExistsInWebexSites || false,
|
|
209
|
-
syncInWebexSites: options.syncInWebexSites,
|
|
210
|
-
orgAdminAuthorization: options.orgAdminAuthorization,
|
|
211
202
|
};
|
|
212
203
|
|
|
213
204
|
return requestWithAuth({
|
|
@@ -321,55 +312,6 @@ export function removeTestUser(options = {}) {
|
|
|
321
312
|
});
|
|
322
313
|
}
|
|
323
314
|
|
|
324
|
-
/**
|
|
325
|
-
* Sets the preferredWebexSite for the provided user
|
|
326
|
-
*
|
|
327
|
-
* This method should be used to ensure a created test user has the right webex site set.
|
|
328
|
-
*
|
|
329
|
-
* @param {Object} options
|
|
330
|
-
* @param {string} options.userId user id to set site
|
|
331
|
-
* @param {string} options.preferredSite new preferred webexsite
|
|
332
|
-
* @param {string} options.orgId orgId of the site
|
|
333
|
-
* @param {string} options.identityServiceUrl url of identity service
|
|
334
|
-
* @param {string} options.authorization
|
|
335
|
-
* @param {string} options.clientId
|
|
336
|
-
* @param {string} options.clientSecret
|
|
337
|
-
* @returns {Promise}
|
|
338
|
-
*/
|
|
339
|
-
export function setPreferredSite(options = {}) {
|
|
340
|
-
const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;
|
|
341
|
-
const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;
|
|
342
|
-
|
|
343
|
-
if (!clientId) {
|
|
344
|
-
throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (!clientSecret) {
|
|
348
|
-
throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/* eslint-disable no-useless-escape */
|
|
352
|
-
const body = {
|
|
353
|
-
schemas: ['urn:scim:schemas:core:1.0', 'urn:scim:schemas:extension:cisco:commonidentity:1.0'],
|
|
354
|
-
userPreferences: [
|
|
355
|
-
{
|
|
356
|
-
value: `\"preferredWebExSite\":\"${options.preferredSite}\"`,
|
|
357
|
-
},
|
|
358
|
-
],
|
|
359
|
-
};
|
|
360
|
-
/* eslint-enable no-useless-escape */
|
|
361
|
-
|
|
362
|
-
return request({
|
|
363
|
-
method: 'PATCH',
|
|
364
|
-
headers: {
|
|
365
|
-
authorization: options.authorization,
|
|
366
|
-
},
|
|
367
|
-
uri: `${options.identityServiceUrl}/identity/scim/${options.orgId}/v1/Users/${options.userId}`,
|
|
368
|
-
json: true,
|
|
369
|
-
body,
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
|
|
373
315
|
export {
|
|
374
316
|
default as createWhistlerTestUser,
|
|
375
317
|
removeTestUser as removeWhistlerTestUser,
|
package/src/whistler.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import btoa from 'btoa';
|
|
2
2
|
import {request} from '@webex/http-core';
|
|
3
|
-
import randomName from 'node-random-name';
|
|
4
|
-
import uuid from 'uuid';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Fetches credentials/access_token to talk to the whistler endpoint
|
|
@@ -87,10 +85,8 @@ const getClientCredentials = ({
|
|
|
87
85
|
export default function createTestUser(options = {}) {
|
|
88
86
|
const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;
|
|
89
87
|
const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;
|
|
90
|
-
const machineAccount =
|
|
91
|
-
|
|
92
|
-
const machinePassword =
|
|
93
|
-
options.machinePassword || process.env.WHISTLER_MACHINE_PASSWORD || `${uuid.v4()}zAY1*`;
|
|
88
|
+
const machineAccount = options.machineAccount || process.env.WHISTLER_MACHINE_ACCOUNT;
|
|
89
|
+
const machinePassword = options.machinePassword || process.env.WHISTLER_MACHINE_PASSWORD;
|
|
94
90
|
const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;
|
|
95
91
|
const orgId = options.orgId || process.env.WHISTLER_TEST_ORG_ID;
|
|
96
92
|
const whistlerServiceUrl = options.whistlerServiceUrl || process.env.WHISTLER_API_SERVICE_URL;
|