@webex/test-users 2.59.3-next.1 → 2.59.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js CHANGED
@@ -1,6 +1,6 @@
1
- const config = {
2
- root: true,
3
- extends: ['@webex/eslint-config-legacy'],
4
- };
5
-
6
- module.exports = config;
1
+ const config = {
2
+ root: true,
3
+ extends: ['@webex/eslint-config-legacy'],
4
+ };
5
+
6
+ module.exports = config;
package/README.md CHANGED
@@ -1,92 +1,92 @@
1
- # @webex/test-users
2
-
3
- [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
-
5
- > The Webex Test Users library allows developers to create test users for integration testing.
6
-
7
- - [@webex/test-users](#webextest-users)
8
- - [Install](#install)
9
- - [Usage](#usage)
10
- - [Implementation](#implementation)
11
- - [Whistler](#whistler)
12
- - [Maintainers](#maintainers)
13
- - [Contribute](#contribute)
14
- - [License](#license)
15
-
16
- ## Install
17
-
18
- ```bash
19
- npm install --save @webex/test-users
20
- ```
21
-
22
- ## Usage
23
-
24
- _Note: This package is NODE only, not for browser usage_
25
-
26
- With the test users library, you can create and remove Webex test users:
27
-
28
- ```javascript
29
- import {createTestUser, removeTestUser} from '@webex/test-users';
30
-
31
- createTestUser({displayName: 'Test User'}).then((myTestUser) => {
32
- // Do something amazing with myTestUser
33
-
34
- // When done, remove the test user
35
- removeTestUser(myTestUser);
36
- });
37
- ```
38
-
39
- The test users library falls back to a few environment variables if they aren't passed as config options:
40
-
41
- - `WEBEX_CLIENT_ID` - The Webex client ID that has access to create test users
42
- - `WEBEX_CLIENT_SECRET` - The Webex client secret for the given client id
43
- - `WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL` - The Webex url for conversation service to create test users
44
- - `WEBEX_SCOPE` - The Webex scope the test users should be created with
45
- - `IDBROKER_BASE_URL` - The Webex auth endpoint to get a client based access token
46
- - [DEPRECATED] `WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL` - use `WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL` instead
47
-
48
- ## Implementation
49
-
50
- Test User creation follows a different flow than standard users due to the fact that they are created on the fly.
51
-
52
- The creation steps are as follows:
53
-
54
- - A client access token is generated from the client id and secret.
55
- - Uses the "idbroker" url defined in `IDBROKER_BASE_URL` or passed via options
56
- - A test user is generated with the client access token
57
- - Uses the url defined in `WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL` or passed via options
58
-
59
- ### Whistler
60
-
61
- To use tests users from the Whistler Service, pass `whistler: true` to the `createTestUsers` options
62
- You will also need to `removeTestUser` once you're done using them
63
-
64
- ```javascript
65
- import {createTestUser, removeTestUser} from '@webex/test-users';
66
-
67
- createTestUser({whistler: true}).then((myTestUser) => {
68
- // Do something amazing with myTestUser
69
-
70
- // When done, remove the test user
71
- removeTestUser(myTestUser);
72
- });
73
- ```
74
-
75
- Whistler requires additional environment variables and scopes to generate test users:
76
-
77
- - `WHISTLER_MACHINE_ACCOUNT` - The Machine Account that can generate and authorize requests to the Whistler Service
78
- - `WHISTLER_MACHINE_PASSWORD` - The password for the given Machine Account
79
- - `WHISTLER_TEST_ORG_ID` - The Test Org ID that has the ability to get test users from the Whistler Service
80
- - `WHISTLER_API_SERVICE_URL` - The Webex url for the Whistler Service to get test users
81
-
82
- ## Maintainers
83
-
84
- This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
85
-
86
- ## Contribute
87
-
88
- Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
89
-
90
- ## License
91
-
92
- © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
1
+ # @webex/test-users
2
+
3
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
+
5
+ > The Webex Test Users library allows developers to create test users for integration testing.
6
+
7
+ - [@webex/test-users](#webextest-users)
8
+ - [Install](#install)
9
+ - [Usage](#usage)
10
+ - [Implementation](#implementation)
11
+ - [Whistler](#whistler)
12
+ - [Maintainers](#maintainers)
13
+ - [Contribute](#contribute)
14
+ - [License](#license)
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ npm install --save @webex/test-users
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ _Note: This package is NODE only, not for browser usage_
25
+
26
+ With the test users library, you can create and remove Webex test users:
27
+
28
+ ```javascript
29
+ import {createTestUser, removeTestUser} from '@webex/test-users';
30
+
31
+ createTestUser({displayName: 'Test User'}).then((myTestUser) => {
32
+ // Do something amazing with myTestUser
33
+
34
+ // When done, remove the test user
35
+ removeTestUser(myTestUser);
36
+ });
37
+ ```
38
+
39
+ The test users library falls back to a few environment variables if they aren't passed as config options:
40
+
41
+ - `WEBEX_CLIENT_ID` - The Webex client ID that has access to create test users
42
+ - `WEBEX_CLIENT_SECRET` - The Webex client secret for the given client id
43
+ - `WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL` - The Webex url for conversation service to create test users
44
+ - `WEBEX_SCOPE` - The Webex scope the test users should be created with
45
+ - `IDBROKER_BASE_URL` - The Webex auth endpoint to get a client based access token
46
+ - [DEPRECATED] `WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL` - use `WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL` instead
47
+
48
+ ## Implementation
49
+
50
+ Test User creation follows a different flow than standard users due to the fact that they are created on the fly.
51
+
52
+ The creation steps are as follows:
53
+
54
+ - A client access token is generated from the client id and secret.
55
+ - Uses the "idbroker" url defined in `IDBROKER_BASE_URL` or passed via options
56
+ - A test user is generated with the client access token
57
+ - Uses the url defined in `WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL` or passed via options
58
+
59
+ ### Whistler
60
+
61
+ To use tests users from the Whistler Service, pass `whistler: true` to the `createTestUsers` options
62
+ You will also need to `removeTestUser` once you're done using them
63
+
64
+ ```javascript
65
+ import {createTestUser, removeTestUser} from '@webex/test-users';
66
+
67
+ createTestUser({whistler: true}).then((myTestUser) => {
68
+ // Do something amazing with myTestUser
69
+
70
+ // When done, remove the test user
71
+ removeTestUser(myTestUser);
72
+ });
73
+ ```
74
+
75
+ Whistler requires additional environment variables and scopes to generate test users:
76
+
77
+ - `WHISTLER_MACHINE_ACCOUNT` - The Machine Account that can generate and authorize requests to the Whistler Service
78
+ - `WHISTLER_MACHINE_PASSWORD` - The password for the given Machine Account
79
+ - `WHISTLER_TEST_ORG_ID` - The Test Org ID that has the ability to get test users from the Whistler Service
80
+ - `WHISTLER_API_SERVICE_URL` - The Webex url for the Whistler Service to get test users
81
+
82
+ ## Maintainers
83
+
84
+ This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
85
+
86
+ ## Contribute
87
+
88
+ Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
89
+
90
+ ## License
91
+
92
+ © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
package/babel.config.js CHANGED
@@ -1,3 +1,3 @@
1
- const babelConfigLegacy = require('@webex/babel-config-legacy');
2
-
3
- module.exports = babelConfigLegacy;
1
+ const babelConfigLegacy = require('@webex/babel-config-legacy');
2
+
3
+ module.exports = babelConfigLegacy;
package/dist/index.js CHANGED
@@ -44,12 +44,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
44
44
  var BASE_PATH_SECURE = '/users/test_users_s';
45
45
  var BASE_PATH = '/users/test_users';
46
46
 
47
- /**
48
- * Computes `expires` and `refresh_token_expires` from `expires_in` and
49
- * `refresh_token_expires_in` and creates an `authorization` string.
50
- * @param {Object} token
51
- * @private
52
- * @returns {Object}
47
+ /**
48
+ * Computes `expires` and `refresh_token_expires` from `expires_in` and
49
+ * `refresh_token_expires_in` and creates an `authorization` string.
50
+ * @param {Object} token
51
+ * @private
52
+ * @returns {Object}
53
53
  */
54
54
  function fixToken(token) {
55
55
  var now = (0, _now.default)();
@@ -67,16 +67,16 @@ function fixToken(token) {
67
67
  }
68
68
  var clientToken;
69
69
 
70
- /**
71
- * Fetches credentials to talk to the test_users_s endpoint
72
- *
73
- * Caches result in `clientToken` variable for multiple runs
74
- * @param {Object} options
75
- * @param {string} options.clientId
76
- * @param {string} options.clientSecret
77
- * @param {string} options.idbrokerUrl
78
- * @private
79
- * @returns {String}
70
+ /**
71
+ * Fetches credentials to talk to the test_users_s endpoint
72
+ *
73
+ * Caches result in `clientToken` variable for multiple runs
74
+ * @param {Object} options
75
+ * @param {string} options.clientId
76
+ * @param {string} options.clientSecret
77
+ * @param {string} options.idbrokerUrl
78
+ * @private
79
+ * @returns {String}
80
80
  */
81
81
  function getClientCredentials(_ref) {
82
82
  var clientId = _ref.clientId,
@@ -110,15 +110,15 @@ function getClientCredentials(_ref) {
110
110
  });
111
111
  }
112
112
 
113
- /**
114
- * Makes a request authorized with client credentials
115
- * @param {Object} options
116
- * @param {Object} options.body
117
- * @param {string} options.body.clientId
118
- * @param {string} options.body.clientSecret
119
- * @param {string} options.body.idbrokerUrl
120
- * @private
121
- * @returns {Promise<HttpResponseObject>}
113
+ /**
114
+ * Makes a request authorized with client credentials
115
+ * @param {Object} options
116
+ * @param {Object} options.body
117
+ * @param {string} options.body.clientId
118
+ * @param {string} options.body.clientSecret
119
+ * @param {string} options.body.idbrokerUrl
120
+ * @private
121
+ * @returns {Promise<HttpResponseObject>}
122
122
  */
123
123
  function requestWithAuth(options) {
124
124
  return getClientCredentials(options.body).then(function (authorization) {
@@ -128,55 +128,55 @@ function requestWithAuth(options) {
128
128
  });
129
129
  }
130
130
 
131
- /**
132
- * @typedef {Object} AccessTokenObject
133
- * @property {string} token.access_token
134
- * @property {Number} token.expires_in
135
- * @property {string} token.token_type
136
- * @property {string} token.refresh_token
137
- * @property {Number} token.refresh_token_expires_in
138
- * @property {string} token.expires
139
- * @property {string} token.refresh_token_expires
131
+ /**
132
+ * @typedef {Object} AccessTokenObject
133
+ * @property {string} token.access_token
134
+ * @property {Number} token.expires_in
135
+ * @property {string} token.token_type
136
+ * @property {string} token.refresh_token
137
+ * @property {Number} token.refresh_token_expires_in
138
+ * @property {string} token.expires
139
+ * @property {string} token.refresh_token_expires
140
140
  */
141
141
 
142
- /**
143
- * @typedef {Object} CreateUserOptions
144
- * @property {boolean} [authCodeOnly] generates auth_code
145
- * @param {string} [clientId] defaults to WEBEX_CLIENT_ID
146
- * @param {string} [clientSecret] defaults to WEBEX_CLIENT_SECRET
147
- * @param {string} [cigServiceUrl] defaults to WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL
148
- * @property {string} [displayName]
149
- * @property {string} [emailAddress]
150
- * @property {Array.<string>} [entitlements]
151
- * @param {string} [idbrokerUrl] defaults to IDBROKER_BASE_URL
152
- * @property {string} [machineType] used when creating a machine user/device
153
- * @property {string} [orgId] organization ID to create the user under
154
- * @property {string} [password] defaults to a random password
155
- * @property {string} [roles] defaults to []
156
- * @property {string} [scope] defaults to WEBEX_SCOPE
157
- * @property {string} [type] used to create a machine
142
+ /**
143
+ * @typedef {Object} CreateUserOptions
144
+ * @property {boolean} [authCodeOnly] generates auth_code
145
+ * @param {string} [clientId] defaults to WEBEX_CLIENT_ID
146
+ * @param {string} [clientSecret] defaults to WEBEX_CLIENT_SECRET
147
+ * @param {string} [cigServiceUrl] defaults to WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL
148
+ * @property {string} [displayName]
149
+ * @property {string} [emailAddress]
150
+ * @property {Array.<string>} [entitlements]
151
+ * @param {string} [idbrokerUrl] defaults to IDBROKER_BASE_URL
152
+ * @property {string} [machineType] used when creating a machine user/device
153
+ * @property {string} [orgId] organization ID to create the user under
154
+ * @property {string} [password] defaults to a random password
155
+ * @property {string} [roles] defaults to []
156
+ * @property {string} [scope] defaults to WEBEX_SCOPE
157
+ * @property {string} [type] used to create a machine
158
158
  */
159
159
 
160
- /**
161
- * @typedef {Object} TestUserObject
162
- * @property {string} password
163
- * @property {string} emailAddress
164
- * @property {string} displayName
165
- * @property {string} id
166
- * @property {string} userName
167
- * @property {string} email
168
- * @property {string} name
169
- * @property {string} givenName
170
- * @property {string} type
171
- * @property {Array.<string>} entitlements
172
- * @property {string} orgId
173
- * @property {AccessTokenObject} token
160
+ /**
161
+ * @typedef {Object} TestUserObject
162
+ * @property {string} password
163
+ * @property {string} emailAddress
164
+ * @property {string} displayName
165
+ * @property {string} id
166
+ * @property {string} userName
167
+ * @property {string} email
168
+ * @property {string} name
169
+ * @property {string} givenName
170
+ * @property {string} type
171
+ * @property {Array.<string>} entitlements
172
+ * @property {string} orgId
173
+ * @property {AccessTokenObject} token
174
174
  */
175
175
 
176
- /**
177
- * Creates a test user
178
- * @param {CreateUserOptions} options
179
- * @returns {Promise.<TestUserObject>}
176
+ /**
177
+ * Creates a test user
178
+ * @param {CreateUserOptions} options
179
+ * @returns {Promise.<TestUserObject>}
180
180
  */
181
181
  function createTestUser() {
182
182
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -228,16 +228,16 @@ function createTestUser() {
228
228
  });
229
229
  }
230
230
 
231
- /**
232
- * Exchanges a user name/password for an access token
233
- * @param {Object} options
234
- * @param {string} options.id
235
- * @param {string} options.email
236
- * @param {string} options.password
237
- * @param {string} options.clientId
238
- * @param {string} options.clientSecret
239
- * @param {string} options.cigServiceUrl
240
- * @returns {Promise.<AccessTokenObject>}
231
+ /**
232
+ * Exchanges a user name/password for an access token
233
+ * @param {Object} options
234
+ * @param {string} options.id
235
+ * @param {string} options.email
236
+ * @param {string} options.password
237
+ * @param {string} options.clientId
238
+ * @param {string} options.clientSecret
239
+ * @param {string} options.cigServiceUrl
240
+ * @returns {Promise.<AccessTokenObject>}
241
241
  */
242
242
  function loginTestUser(options) {
243
243
  var clientId = options.clientId || process.env.WEBEX_CLIENT_ID;
@@ -265,15 +265,15 @@ function loginTestUser(options) {
265
265
  });
266
266
  }
267
267
 
268
- /**
269
- * Removes a test user
270
- * @param {Object} options
271
- * @param {string} options.id user id to remove
272
- * @param {string} options.cigServiceUrl
273
- * @param {Object} options.token
274
- * @param {string} options.token.authorization
275
- * @param {string} [options.token.refresh_token]
276
- * @returns {Promise}
268
+ /**
269
+ * Removes a test user
270
+ * @param {Object} options
271
+ * @param {string} options.id user id to remove
272
+ * @param {string} options.cigServiceUrl
273
+ * @param {Object} options.token
274
+ * @param {string} options.token.authorization
275
+ * @param {string} [options.token.refresh_token]
276
+ * @returns {Promise}
277
277
  */
278
278
  function removeTestUser() {
279
279
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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';\r\n\r\nimport uuid from 'uuid';\r\nimport btoa from 'btoa';\r\nimport _ from 'lodash';\r\nimport randomName from 'node-random-name';\r\nimport {request} from '@webex/http-core';\r\n\r\nconst BASE_PATH_SECURE = '/users/test_users_s';\r\nconst BASE_PATH = '/users/test_users';\r\n\r\n/**\r\n * Computes `expires` and `refresh_token_expires` from `expires_in` and\r\n * `refresh_token_expires_in` and creates an `authorization` string.\r\n * @param {Object} token\r\n * @private\r\n * @returns {Object}\r\n */\r\nfunction fixToken(token) {\r\n const now = Date.now();\r\n\r\n if (token.expires_in && !token.expires) {\r\n token.expires = now + token.expires_in * 1000;\r\n }\r\n\r\n if (token.refresh_token_expires_in && !token.refresh_token_expires) {\r\n /* eslint camelcase: [0] */\r\n token.refresh_token_expires = now + token.refresh_token_expires_in * 1000;\r\n }\r\n\r\n if (token.token_type && token.access_token) {\r\n token.authorization = `${token.token_type} ${token.access_token}`;\r\n }\r\n\r\n return token;\r\n}\r\n\r\nlet clientToken;\r\n\r\n/**\r\n * Fetches credentials to talk to the test_users_s endpoint\r\n *\r\n * Caches result in `clientToken` variable for multiple runs\r\n * @param {Object} options\r\n * @param {string} options.clientId\r\n * @param {string} options.clientSecret\r\n * @param {string} options.idbrokerUrl\r\n * @private\r\n * @returns {String}\r\n */\r\nfunction getClientCredentials({clientId, clientSecret, idbrokerUrl}) {\r\n if (clientToken) {\r\n return Promise.resolve(clientToken);\r\n }\r\n\r\n return request({\r\n method: 'POST',\r\n uri: `${idbrokerUrl}/idb/oauth2/v1/access_token`,\r\n json: true,\r\n form: {\r\n grant_type: 'client_credentials',\r\n scope: 'Identity:SCIM webexsquare:get_conversation',\r\n client_id: clientId,\r\n client_secret: clientSecret,\r\n },\r\n headers: {\r\n // Note: we can't request's auth hash here because this endpoint expects\r\n // us to send the auth header *without including \"Basic \"* before the\r\n // token string\r\n authorization: btoa(`${clientId}:${clientSecret}`),\r\n },\r\n })\r\n .then((res) => {\r\n const token = fixToken(res.body);\r\n\r\n return `${token.token_type} ${token.access_token}`;\r\n })\r\n .then((token) => {\r\n clientToken = token;\r\n\r\n return clientToken;\r\n });\r\n}\r\n\r\n/**\r\n * Makes a request authorized with client credentials\r\n * @param {Object} options\r\n * @param {Object} options.body\r\n * @param {string} options.body.clientId\r\n * @param {string} options.body.clientSecret\r\n * @param {string} options.body.idbrokerUrl\r\n * @private\r\n * @returns {Promise<HttpResponseObject>}\r\n */\r\nfunction requestWithAuth(options) {\r\n return getClientCredentials(options.body).then((authorization) => {\r\n options.headers = options.headers || {};\r\n options.headers.authorization = authorization;\r\n\r\n return request(options);\r\n });\r\n}\r\n\r\n/**\r\n * @typedef {Object} AccessTokenObject\r\n * @property {string} token.access_token\r\n * @property {Number} token.expires_in\r\n * @property {string} token.token_type\r\n * @property {string} token.refresh_token\r\n * @property {Number} token.refresh_token_expires_in\r\n * @property {string} token.expires\r\n * @property {string} token.refresh_token_expires\r\n */\r\n\r\n/**\r\n * @typedef {Object} CreateUserOptions\r\n * @property {boolean} [authCodeOnly] generates auth_code\r\n * @param {string} [clientId] defaults to WEBEX_CLIENT_ID\r\n * @param {string} [clientSecret] defaults to WEBEX_CLIENT_SECRET\r\n * @param {string} [cigServiceUrl] defaults to WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL\r\n * @property {string} [displayName]\r\n * @property {string} [emailAddress]\r\n * @property {Array.<string>} [entitlements]\r\n * @param {string} [idbrokerUrl] defaults to IDBROKER_BASE_URL\r\n * @property {string} [machineType] used when creating a machine user/device\r\n * @property {string} [orgId] organization ID to create the user under\r\n * @property {string} [password] defaults to a random password\r\n * @property {string} [roles] defaults to []\r\n * @property {string} [scope] defaults to WEBEX_SCOPE\r\n * @property {string} [type] used to create a machine\r\n */\r\n\r\n/**\r\n * @typedef {Object} TestUserObject\r\n * @property {string} password\r\n * @property {string} emailAddress\r\n * @property {string} displayName\r\n * @property {string} id\r\n * @property {string} userName\r\n * @property {string} email\r\n * @property {string} name\r\n * @property {string} givenName\r\n * @property {string} type\r\n * @property {Array.<string>} entitlements\r\n * @property {string} orgId\r\n * @property {AccessTokenObject} token\r\n */\r\n\r\n/**\r\n * Creates a test user\r\n * @param {CreateUserOptions} options\r\n * @returns {Promise.<TestUserObject>}\r\n */\r\nexport function createTestUser(options = {}) {\r\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\r\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\r\n const idbrokerUrl = options.idbrokerUrl || process.env.IDBROKER_BASE_URL;\r\n const cigServiceUrl =\r\n options.cigServiceUrl ||\r\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\r\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\r\n\r\n if (!clientId) {\r\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\r\n }\r\n\r\n if (!clientSecret) {\r\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\r\n }\r\n\r\n if (!idbrokerUrl) {\r\n throw new Error('options.idbrokerUrl or process.env.IDBROKER_BASE_URL must be defined');\r\n }\r\n\r\n if (!cigServiceUrl) {\r\n throw new Error(\r\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\r\n );\r\n }\r\n\r\n const body = {\r\n authCodeOnly: options.authCodeOnly,\r\n clientId,\r\n clientSecret,\r\n displayName: options.displayName || randomName(),\r\n emailTemplate: options.emailAddress,\r\n entitlements: options.entitlements || [\r\n 'spark',\r\n 'squaredCallInitiation',\r\n 'squaredRoomModeration',\r\n 'squaredInviter',\r\n 'webExSquared',\r\n ],\r\n idbrokerUrl,\r\n machineType: options.machineType,\r\n orgId: options.orgId,\r\n // The five characters on the end are to hit all the password requirements\r\n password: options.password || `${uuid.v4()}zAY1*`,\r\n roles: options.roles || [],\r\n scopes: options.scope || process.env.WEBEX_SCOPE,\r\n type: options.type,\r\n };\r\n\r\n return requestWithAuth({\r\n method: 'POST',\r\n uri: `${cigServiceUrl}${BASE_PATH_SECURE}`,\r\n json: true,\r\n body,\r\n }).then((res) => ({\r\n password: body.password,\r\n emailAddress: res.body.user.email,\r\n displayName: res.body.user.name,\r\n ...res.body.user,\r\n token: fixToken(res.body.token),\r\n }));\r\n}\r\n\r\n/**\r\n * Exchanges a user name/password for an access token\r\n * @param {Object} options\r\n * @param {string} options.id\r\n * @param {string} options.email\r\n * @param {string} options.password\r\n * @param {string} options.clientId\r\n * @param {string} options.clientSecret\r\n * @param {string} options.cigServiceUrl\r\n * @returns {Promise.<AccessTokenObject>}\r\n */\r\nexport function loginTestUser(options) {\r\n const clientId = options.clientId || process.env.WEBEX_CLIENT_ID;\r\n const clientSecret = options.clientSecret || process.env.WEBEX_CLIENT_SECRET;\r\n const cigServiceUrl =\r\n options.cigServiceUrl ||\r\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\r\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\r\n\r\n if (!clientId) {\r\n throw new Error('options.clientId or process.env.WEBEX_CLIENT_ID must be defined');\r\n }\r\n\r\n if (!clientSecret) {\r\n throw new Error('options.clientSecret or process.env.WEBEX_CLIENT_SECRET must be defined');\r\n }\r\n\r\n if (!cigServiceUrl) {\r\n throw new Error(\r\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\r\n );\r\n }\r\n\r\n return request({\r\n method: 'POST',\r\n uri: `${cigServiceUrl}${BASE_PATH}/login`,\r\n json: true,\r\n body: _.defaultsDeep(options, {\r\n clientId,\r\n clientSecret,\r\n }),\r\n }).then((res) => fixToken(res.body));\r\n}\r\n\r\n/**\r\n * Removes a test user\r\n * @param {Object} options\r\n * @param {string} options.id user id to remove\r\n * @param {string} options.cigServiceUrl\r\n * @param {Object} options.token\r\n * @param {string} options.token.authorization\r\n * @param {string} [options.token.refresh_token]\r\n * @returns {Promise}\r\n */\r\nexport function removeTestUser(options = {}) {\r\n const cigServiceUrl =\r\n options.cigServiceUrl ||\r\n process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL ||\r\n process.env.WEBEX_TEST_USERS_CONVERSATION_SERVICE_URL;\r\n\r\n if (!cigServiceUrl) {\r\n throw new Error(\r\n 'options.cigServiceUrl or process.env.WEBEX_TEST_USERS_CI_GATEWAY_SERVICE_URL must be defined'\r\n );\r\n }\r\n\r\n if (!options.id) {\r\n return Promise.reject(new Error('options.id is required'));\r\n }\r\n\r\n if (!options.token) {\r\n return loginTestUser(options).then((token) => {\r\n options.token = token;\r\n\r\n return removeTestUser(options);\r\n });\r\n }\r\n\r\n assert(options.token.authorization, 'options.token.authorization must be defined');\r\n\r\n return request({\r\n method: 'POST',\r\n json: true,\r\n headers: {\r\n authorization: options.token.authorization,\r\n },\r\n body: {\r\n /* eslint-disable camelcase */\r\n user_id: options.id,\r\n refresh_token: options.token.refresh_token,\r\n user_type: options.userType || 'PERSON',\r\n /* eslint-enable camelcase */\r\n },\r\n uri: `${cigServiceUrl}${BASE_PATH}/delete`,\r\n });\r\n}\r\n\r\nexport {\r\n default as createWhistlerTestUser,\r\n removeTestUser as removeWhistlerTestUser,\r\n} from './whistler';\r\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,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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"}
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,K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AAE,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
@@ -17,18 +17,18 @@ var _btoa = _interopRequireDefault(require("btoa"));
17
17
  var _httpCore = require("@webex/http-core");
18
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
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; }
20
- /**
21
- * Fetches credentials/access_token to talk to the whistler endpoint
22
- *
23
- * @param {Object} options
24
- * @param {string} options.clientId
25
- * @param {string} options.clientSecret
26
- * @param {string} options.idbrokerUrl
27
- * @param {string} options.orgId
28
- * @param {string} options.machineAccount
29
- * @param {string} options.machinePassword
30
- * @private
31
- * @returns {Promise<string>}
20
+ /**
21
+ * Fetches credentials/access_token to talk to the whistler endpoint
22
+ *
23
+ * @param {Object} options
24
+ * @param {string} options.clientId
25
+ * @param {string} options.clientSecret
26
+ * @param {string} options.idbrokerUrl
27
+ * @param {string} options.orgId
28
+ * @param {string} options.machineAccount
29
+ * @param {string} options.machinePassword
30
+ * @private
31
+ * @returns {Promise<string>}
32
32
  */
33
33
  var getClientCredentials = function getClientCredentials(_ref) {
34
34
  var clientId = _ref.clientId,
@@ -71,32 +71,32 @@ var getClientCredentials = function getClientCredentials(_ref) {
71
71
  });
72
72
  };
73
73
 
74
- /**
75
- * @typedef {Object} TestUserObject
76
- * @property {string} password
77
- * @property {string} emailAddress
78
- * @property {string} displayName
79
- * @property {string} token
80
- * @property {string} reservationUrl
81
- * @property {object} responseMetaData - whistler given properties
74
+ /**
75
+ * @typedef {Object} TestUserObject
76
+ * @property {string} password
77
+ * @property {string} emailAddress
78
+ * @property {string} displayName
79
+ * @property {string} token
80
+ * @property {string} reservationUrl
81
+ * @property {object} responseMetaData - whistler given properties
82
82
  */
83
83
 
84
- /**
85
- * @typedef {Object} CreateUserOptions
86
- * @param {Object} [options]
87
- * @param {string} [whistlerServiceUrl] defaults to WHISTLER_API_SERVICE_URL
88
- * @param {string} [options.clientId] defaults to WEBEX_CLIENT_ID
89
- * @param {string} [options.clientSecret] defaults to WEBEX_CLIENT_SECRET
90
- * @param {string} [options.idbrokerUrl] defaults to IDBROKER_BASE_URL
91
- * @param {string} [options.orgId] organization ID to create the user under
92
- * @param {string} [options.machineAccount] defaults to WHISTLER_MACHINE_ACCOUNT
93
- * @param {string} [options.machinePassword] defaults to WHISTLER_MACHINE_PASSWORD
84
+ /**
85
+ * @typedef {Object} CreateUserOptions
86
+ * @param {Object} [options]
87
+ * @param {string} [whistlerServiceUrl] defaults to WHISTLER_API_SERVICE_URL
88
+ * @param {string} [options.clientId] defaults to WEBEX_CLIENT_ID
89
+ * @param {string} [options.clientSecret] defaults to WEBEX_CLIENT_SECRET
90
+ * @param {string} [options.idbrokerUrl] defaults to IDBROKER_BASE_URL
91
+ * @param {string} [options.orgId] organization ID to create the user under
92
+ * @param {string} [options.machineAccount] defaults to WHISTLER_MACHINE_ACCOUNT
93
+ * @param {string} [options.machinePassword] defaults to WHISTLER_MACHINE_PASSWORD
94
94
  */
95
95
 
96
- /**
97
- * Creates a test user
98
- * @param {CreateUserOptions} options
99
- * @returns {Promise.<TestUserObject>}
96
+ /**
97
+ * Creates a test user
98
+ * @param {CreateUserOptions} options
99
+ * @returns {Promise.<TestUserObject>}
100
100
  */
101
101
  function createTestUser() {
102
102
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
@@ -164,10 +164,10 @@ function createTestUser() {
164
164
  });
165
165
  }
166
166
 
167
- /**
168
- *
169
- * @param {Object} options
170
- * @returns {Promise}
167
+ /**
168
+ *
169
+ * @param {Object} options
170
+ * @returns {Promise}
171
171
  */
172
172
  function removeTestUser() {
173
173
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};