@webex/plugin-authorization-browser 3.8.0 → 3.8.1-next.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/BROWSER-OAUTH-FLOW-GUIDE.md +541 -0
- package/README.md +309 -22
- package/dist/authorization.js +61 -15
- package/dist/authorization.js.map +1 -1
- package/package.json +13 -13
- package/src/authorization.js +61 -16
- package/test/unit/spec/authorization.js +59 -0
package/README.md
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
# @webex/plugin-authorization-browser
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> OAuth2 authorization plugin for browser environments in the Cisco Webex JS SDK. Handles OAuth2 flows including Implicit Grant and Authorization Code Grant for web applications.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Table of Contents
|
|
6
6
|
|
|
7
|
-
- [
|
|
8
|
-
- [
|
|
9
|
-
- [
|
|
10
|
-
- [
|
|
11
|
-
- [
|
|
7
|
+
- [@webex/plugin-authorization-browser](#webexplugin-authorization-browser)
|
|
8
|
+
- [Table of Contents](#table-of-contents)
|
|
9
|
+
- [Install](#install)
|
|
10
|
+
- [What it Does](#what-it-does)
|
|
11
|
+
- [Usage](#usage)
|
|
12
|
+
- [Basic OAuth2 Login](#basic-oauth2-login)
|
|
13
|
+
- [Implicit Grant Flow](#implicit-grant-flow)
|
|
14
|
+
- [Authorization Code Grant Flow](#authorization-code-grant-flow)
|
|
15
|
+
- [Login with Popup Window](#login-with-popup-window)
|
|
16
|
+
- [JWT Authentication](#jwt-authentication)
|
|
17
|
+
- [Guest JWT Creation](#guest-jwt-creation)
|
|
18
|
+
- [Logout](#logout)
|
|
19
|
+
- [Checking Authentication Status](#checking-authentication-status)
|
|
20
|
+
- [Error Handling](#error-handling)
|
|
21
|
+
- [API Reference](#api-reference)
|
|
22
|
+
- [Methods](#methods)
|
|
23
|
+
- [`initiateLogin(options)`](#initiateloginoptions)
|
|
24
|
+
- [`initiateImplicitGrant(options)`](#initiateimplicitgrantoptions)
|
|
25
|
+
- [`initiateAuthorizationCodeGrant(options)`](#initiateauthorizationcodegrantoptions)
|
|
26
|
+
- [`requestAccessTokenFromJwt({ jwt })`](#requestaccesstokenfromjwt-jwt-)
|
|
27
|
+
- [`createJwt(options)`](#createjwtoptions)
|
|
28
|
+
- [`logout(options)`](#logoutoptions)
|
|
29
|
+
- [Properties](#properties)
|
|
30
|
+
- [`isAuthorizing` (boolean)](#isauthorizing-boolean)
|
|
31
|
+
- [`isAuthenticating` (boolean)](#isauthenticating-boolean)
|
|
32
|
+
- [`ready` (boolean)](#ready-boolean)
|
|
33
|
+
- [Maintainers](#maintainers)
|
|
34
|
+
- [Contribute](#contribute)
|
|
35
|
+
- [License](#license)
|
|
12
36
|
|
|
13
37
|
## Install
|
|
14
38
|
|
|
@@ -16,38 +40,301 @@
|
|
|
16
40
|
npm install --save @webex/plugin-authorization-browser
|
|
17
41
|
```
|
|
18
42
|
|
|
43
|
+
## What it Does
|
|
44
|
+
|
|
45
|
+
The `@webex/plugin-authorization-browser` plugin provides OAuth2 authentication capabilities specifically for browser environments. It:
|
|
46
|
+
|
|
47
|
+
- **Automatically handles OAuth2 flows**: Supports both Implicit Grant and Authorization Code Grant flows
|
|
48
|
+
- **Manages authentication state**: Tracks authorization status and handles token parsing from URL
|
|
49
|
+
- **Provides CSRF protection**: Generates and validates CSRF tokens for security
|
|
50
|
+
- **Supports popup authentication**: Can open login in a separate window
|
|
51
|
+
- **JWT token support**: Create and use JWT tokens for guest authentication
|
|
52
|
+
- **URL cleanup**: Automatically removes sensitive tokens from browser URL after authentication
|
|
53
|
+
- **Cross-browser compatibility**: Works across different browser environments
|
|
54
|
+
|
|
19
55
|
## Usage
|
|
20
56
|
|
|
21
|
-
|
|
57
|
+
### Basic OAuth2 Login
|
|
22
58
|
|
|
23
|
-
|
|
59
|
+
The simplest way to authenticate users:
|
|
24
60
|
|
|
25
|
-
```
|
|
26
|
-
|
|
61
|
+
```javascript
|
|
62
|
+
const Webex = require('webex');
|
|
63
|
+
|
|
64
|
+
// Initialize Webex SDK
|
|
65
|
+
const webex = Webex.init({
|
|
66
|
+
credentials: {
|
|
67
|
+
client_id: 'your-client-id',
|
|
68
|
+
redirect_uri: 'https://your-app.com/callback',
|
|
69
|
+
scope: 'spark:all'
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Start the login process
|
|
74
|
+
webex.authorization.initiateLogin()
|
|
75
|
+
.then(() => {
|
|
76
|
+
console.log('Login initiated');
|
|
77
|
+
// User will be redirected to Webex login page
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// After redirect, check if user is authenticated
|
|
81
|
+
if (webex.canAuthorize) {
|
|
82
|
+
console.log('User is authenticated');
|
|
83
|
+
// Make API calls
|
|
84
|
+
}
|
|
27
85
|
```
|
|
28
86
|
|
|
29
|
-
|
|
87
|
+
### Implicit Grant Flow
|
|
30
88
|
|
|
31
|
-
|
|
89
|
+
For public clients (single-page applications):
|
|
32
90
|
|
|
33
|
-
|
|
91
|
+
```javascript
|
|
92
|
+
const webex = Webex.init({
|
|
93
|
+
credentials: {
|
|
94
|
+
client_id: 'your-client-id',
|
|
95
|
+
redirect_uri: 'https://your-app.com/callback',
|
|
96
|
+
scope: 'spark:all'
|
|
97
|
+
// No client_secret for public clients
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Initiate implicit grant flow
|
|
102
|
+
webex.authorization.initiateImplicitGrant({
|
|
103
|
+
state: { customData: 'value' } // Optional state data
|
|
104
|
+
})
|
|
105
|
+
.then(() => {
|
|
106
|
+
console.log('Implicit grant flow started');
|
|
107
|
+
});
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Authorization Code Grant Flow
|
|
111
|
+
|
|
112
|
+
For confidential clients with client secret:
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
const webex = Webex.init({
|
|
116
|
+
credentials: {
|
|
117
|
+
client_id: 'your-client-id',
|
|
118
|
+
client_secret: 'your-client-secret',
|
|
119
|
+
redirect_uri: 'https://your-app.com/callback',
|
|
120
|
+
scope: 'spark:all',
|
|
121
|
+
clientType: 'confidential' // This triggers authorization code flow
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Initiate authorization code grant flow
|
|
126
|
+
webex.authorization.initiateAuthorizationCodeGrant({
|
|
127
|
+
state: { customData: 'value' }
|
|
128
|
+
})
|
|
129
|
+
.then(() => {
|
|
130
|
+
console.log('Authorization code flow started');
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Login with Popup Window
|
|
135
|
+
|
|
136
|
+
Open login in a separate popup window instead of redirecting:
|
|
137
|
+
|
|
138
|
+
```javascript
|
|
139
|
+
// Basic popup with default dimensions (600x800)
|
|
140
|
+
webex.authorization.initiateLogin({
|
|
141
|
+
separateWindow: true
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Custom popup dimensions
|
|
145
|
+
webex.authorization.initiateLogin({
|
|
146
|
+
separateWindow: {
|
|
147
|
+
width: 800,
|
|
148
|
+
height: 600
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// With custom state and popup
|
|
153
|
+
webex.authorization.initiateLogin({
|
|
154
|
+
state: {
|
|
155
|
+
returnUrl: '/dashboard',
|
|
156
|
+
userId: 'user123'
|
|
157
|
+
},
|
|
158
|
+
separateWindow: {
|
|
159
|
+
width: 900,
|
|
160
|
+
height: 700
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### JWT Authentication
|
|
166
|
+
|
|
167
|
+
Authenticate using a JWT token (useful for guest users):
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
// Assuming you have a JWT from your backend
|
|
171
|
+
const jwtToken = '<YOUR_JWT_TOKEN_HERE>';
|
|
172
|
+
|
|
173
|
+
webex.authorization.requestAccessTokenFromJwt({
|
|
174
|
+
jwt: jwtToken
|
|
175
|
+
})
|
|
176
|
+
.then(() => {
|
|
177
|
+
console.log('Authenticated with JWT');
|
|
178
|
+
// User is now authenticated and can make API calls
|
|
179
|
+
})
|
|
180
|
+
.catch(error => {
|
|
181
|
+
console.error('JWT authentication failed:', error);
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Guest JWT Creation
|
|
186
|
+
|
|
187
|
+
Create JWT tokens for guest users:
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
// Create a guest JWT token
|
|
191
|
+
webex.authorization.createJwt({
|
|
192
|
+
issuer: 'your-guest-issuer-id',
|
|
193
|
+
secretId: 'your-base64-encoded-secret',
|
|
194
|
+
displayName: 'Guest User Name', // Optional
|
|
195
|
+
expiresIn: '12h' // Token expiration
|
|
196
|
+
})
|
|
197
|
+
.then(({ jwt }) => {
|
|
198
|
+
console.log('Created guest JWT:', jwt);
|
|
199
|
+
|
|
200
|
+
// Use the JWT to authenticate
|
|
201
|
+
return webex.authorization.requestAccessTokenFromJwt({ jwt });
|
|
202
|
+
})
|
|
203
|
+
.then(() => {
|
|
204
|
+
console.log('Guest user authenticated');
|
|
205
|
+
})
|
|
206
|
+
.catch(error => {
|
|
207
|
+
console.error('Guest JWT creation failed:', error);
|
|
208
|
+
});
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Logout
|
|
212
|
+
|
|
213
|
+
Log out the current user:
|
|
214
|
+
|
|
215
|
+
```javascript
|
|
216
|
+
// Logout and redirect to Webex logout page
|
|
217
|
+
webex.authorization.logout();
|
|
34
218
|
|
|
35
|
-
|
|
36
|
-
webex.authorization
|
|
37
|
-
.then((authorization-browser) => {
|
|
38
|
-
console.log(authorization-browser);
|
|
39
|
-
})
|
|
219
|
+
// Logout without redirect (clean up local session only)
|
|
220
|
+
webex.authorization.logout({ noRedirect: true });
|
|
40
221
|
|
|
222
|
+
// Logout with custom logout URL
|
|
223
|
+
webex.authorization.logout({
|
|
224
|
+
goto: 'https://your-app.com/goodbye'
|
|
225
|
+
});
|
|
41
226
|
```
|
|
42
227
|
|
|
228
|
+
### Checking Authentication Status
|
|
229
|
+
|
|
230
|
+
```javascript
|
|
231
|
+
// Check if SDK can authorize (has valid token)
|
|
232
|
+
if (webex.canAuthorize) {
|
|
233
|
+
console.log('User is authenticated');
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Check if authorization is in progress
|
|
237
|
+
if (webex.authorization.isAuthorizing) {
|
|
238
|
+
console.log('Authorization in progress...');
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Listen for authentication events
|
|
242
|
+
webex.on('ready', () => {
|
|
243
|
+
console.log('SDK is ready and authenticated');
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
webex.on('unauthorized', () => {
|
|
247
|
+
console.log('User is not authenticated');
|
|
248
|
+
});
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Error Handling
|
|
252
|
+
|
|
253
|
+
```javascript
|
|
254
|
+
// Handle authentication errors from URL
|
|
255
|
+
try {
|
|
256
|
+
const webex = Webex.init({
|
|
257
|
+
credentials: { /* your config */ }
|
|
258
|
+
});
|
|
259
|
+
} catch (error) {
|
|
260
|
+
if (error.name === 'OAuthError') {
|
|
261
|
+
console.error('OAuth error:', error.message);
|
|
262
|
+
// Handle specific OAuth errors like access_denied
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// Handle JWT authentication errors
|
|
267
|
+
webex.authorization.requestAccessTokenFromJwt({ jwt: 'invalid-jwt' })
|
|
268
|
+
.catch(error => {
|
|
269
|
+
console.error('JWT authentication failed:', error);
|
|
270
|
+
});
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## API Reference
|
|
274
|
+
|
|
275
|
+
### Methods
|
|
276
|
+
|
|
277
|
+
#### `initiateLogin(options)`
|
|
278
|
+
|
|
279
|
+
Initiates the appropriate OAuth flow based on client configuration.
|
|
280
|
+
|
|
281
|
+
- `options.state` - Optional state object for custom data
|
|
282
|
+
- `options.separateWindow` - Boolean or object for popup window settings
|
|
283
|
+
|
|
284
|
+
#### `initiateImplicitGrant(options)`
|
|
285
|
+
|
|
286
|
+
Starts the Implicit Grant flow for public clients.
|
|
287
|
+
|
|
288
|
+
#### `initiateAuthorizationCodeGrant(options)`
|
|
289
|
+
|
|
290
|
+
Starts the Authorization Code Grant flow for confidential clients.
|
|
291
|
+
|
|
292
|
+
#### `requestAccessTokenFromJwt({ jwt })`
|
|
293
|
+
|
|
294
|
+
Exchanges a JWT for an access token.
|
|
295
|
+
|
|
296
|
+
#### `createJwt(options)`
|
|
297
|
+
|
|
298
|
+
Creates a JWT token for guest authentication.
|
|
299
|
+
|
|
300
|
+
- `options.issuer` - Guest issuer ID
|
|
301
|
+
- `options.secretId` - Base64 encoded secret
|
|
302
|
+
- `options.displayName` - Optional display name
|
|
303
|
+
- `options.expiresIn` - Token expiration time
|
|
304
|
+
|
|
305
|
+
#### `logout(options)`
|
|
306
|
+
|
|
307
|
+
Logs out the current user.
|
|
308
|
+
|
|
309
|
+
- `options.noRedirect` - Skip redirect to logout page
|
|
310
|
+
- `options.goto` - Custom redirect URL after logout
|
|
311
|
+
|
|
312
|
+
### Properties
|
|
313
|
+
|
|
314
|
+
#### `isAuthorizing` (boolean)
|
|
315
|
+
|
|
316
|
+
Indicates if an authorization flow is currently in progress.
|
|
317
|
+
|
|
318
|
+
#### `isAuthenticating` (boolean)
|
|
319
|
+
|
|
320
|
+
Alias for `isAuthorizing`.
|
|
321
|
+
|
|
322
|
+
#### `ready` (boolean)
|
|
323
|
+
|
|
324
|
+
Indicates if the authorization plugin has finished initialization.
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
43
328
|
## Maintainers
|
|
44
329
|
|
|
45
|
-
This package is maintained by
|
|
330
|
+
This package is maintained by Cisco Webex for Developers.
|
|
46
331
|
|
|
47
332
|
## Contribute
|
|
48
333
|
|
|
49
|
-
Pull requests welcome. Please see
|
|
334
|
+
Pull requests welcome. Please see CONTRIBUTING.md for more details.
|
|
50
335
|
|
|
51
336
|
## License
|
|
52
337
|
|
|
53
|
-
|
|
338
|
+
This project is licensed under the Cisco General Terms - see the LICENSE for details.
|
|
339
|
+
|
|
340
|
+
© 2016-2025 Cisco and/or its affiliates. All Rights Reserved.
|
package/dist/authorization.js
CHANGED
|
@@ -8,10 +8,13 @@ _Object$defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs2/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/asyncToGenerator"));
|
|
11
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/slicedToArray"));
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/typeof"));
|
|
11
13
|
var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime-corejs2/helpers/applyDecoratedDescriptor"));
|
|
12
14
|
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/json/stringify"));
|
|
13
15
|
var _apply = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/apply"));
|
|
14
16
|
var _assign = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/assign"));
|
|
17
|
+
var _entries = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/object/entries"));
|
|
15
18
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/promise"));
|
|
16
19
|
var _deleteProperty = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/delete-property"));
|
|
17
20
|
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/parse-int"));
|
|
@@ -121,11 +124,24 @@ var Authorization = _webexCore.WebexPlugin.extend((_dec = (0, _common.whileInFli
|
|
|
121
124
|
return ret;
|
|
122
125
|
},
|
|
123
126
|
/**
|
|
124
|
-
*
|
|
127
|
+
* Initiates the OAuth flow for user authentication.
|
|
128
|
+
* This function determines the type of OAuth flow to use based on the client type configuration.
|
|
129
|
+
* If the client is configured as "confidential", it will initiate the Authorization Code Grant flow;
|
|
130
|
+
* otherwise, it will initiate the Implicit Grant flow.
|
|
131
|
+
*
|
|
125
132
|
* @instance
|
|
126
133
|
* @memberof AuthorizationBrowser
|
|
127
|
-
* @param {Object} options
|
|
128
|
-
* @
|
|
134
|
+
* @param {Object} options - The options to configure the OAuth flow.
|
|
135
|
+
* @param {Object} [options.state] - An optional state object that can be used to include additional
|
|
136
|
+
* information such as security tokens. A CSRF token will be automatically generated and added to
|
|
137
|
+
* this state object.
|
|
138
|
+
* @param {boolean|Object} [options.separateWindow] - Determines if the login should open in a separate window.
|
|
139
|
+
* This can be a boolean or an object specifying window features:
|
|
140
|
+
* - If `true`, a new window with default dimensions is opened.
|
|
141
|
+
* - If an object, custom window features can be specified (e.g., `{width: 800, height: 600}`).
|
|
142
|
+
* @returns {Promise<void>} - A promise that resolves when the appropriate OAuth flow has been initiated.
|
|
143
|
+
* The promise does not necessarily indicate the completion of the login process.
|
|
144
|
+
* @throws {Error} - Throws an error if there are issues initiating the OAuth flow.
|
|
129
145
|
*/
|
|
130
146
|
initiateLogin: function initiateLogin() {
|
|
131
147
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -140,18 +156,48 @@ var Authorization = _webexCore.WebexPlugin.extend((_dec = (0, _common.whileInFli
|
|
|
140
156
|
return this.initiateImplicitGrant(options);
|
|
141
157
|
},
|
|
142
158
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
159
|
+
* Initiates the Implicit Grant flow for authorization.
|
|
160
|
+
* This function constructs the login URL and either opens it in a new
|
|
161
|
+
* window or in the current window based on the provided options.
|
|
162
|
+
* Typically called via {@link AuthorizationBrowser#initiateLogin}.
|
|
163
|
+
*
|
|
145
164
|
* @instance
|
|
146
165
|
* @memberof AuthorizationBrowser
|
|
147
|
-
* @param {Object} options
|
|
148
|
-
* @
|
|
166
|
+
* @param {Object} options - The options to configure the login flow.
|
|
167
|
+
* @param {Object} [options.separateWindow] - Determines if the login should open in a separate window.
|
|
168
|
+
* This can be a boolean or an object specifying window features:
|
|
169
|
+
* - If `true`, a new window with default dimensions is opened.
|
|
170
|
+
* - If an object, custom window features can be specified (e.g., `{width: 800, height: 600}`).
|
|
171
|
+
* @returns {Promise<void>} - A promise that resolves immediately after initiating the login flow.
|
|
172
|
+
* This promise does not indicate the completion of the login process.
|
|
173
|
+
* @throws {Error} - Throws an error if the login URL cannot be constructed or if window opening fails.
|
|
149
174
|
*/
|
|
150
175
|
initiateImplicitGrant: function initiateImplicitGrant(options) {
|
|
151
176
|
this.logger.info('authorization: initiating implicit grant flow');
|
|
152
|
-
|
|
177
|
+
var loginUrl = this.webex.credentials.buildLoginUrl((0, _assign.default)({
|
|
153
178
|
response_type: 'token'
|
|
154
179
|
}, options));
|
|
180
|
+
if (options !== null && options !== void 0 && options.separateWindow) {
|
|
181
|
+
// Default window settings
|
|
182
|
+
var defaultWindowSettings = {
|
|
183
|
+
width: 600,
|
|
184
|
+
height: 800
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// Merge user provided settings with defaults
|
|
188
|
+
var windowSettings = (0, _assign.default)(defaultWindowSettings, (0, _typeof2.default)(options.separateWindow) === 'object' ? options.separateWindow : {});
|
|
189
|
+
// Convert settings object to window.open features string
|
|
190
|
+
var windowFeatures = (0, _entries.default)(windowSettings).map(function (_ref) {
|
|
191
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
192
|
+
key = _ref2[0],
|
|
193
|
+
value = _ref2[1];
|
|
194
|
+
return "".concat(key, "=").concat(value);
|
|
195
|
+
}).join(',');
|
|
196
|
+
this.webex.getWindow().open(loginUrl, '_blank', windowFeatures);
|
|
197
|
+
} else {
|
|
198
|
+
// Default behavior - open in same window
|
|
199
|
+
this.webex.getWindow().location = loginUrl;
|
|
200
|
+
}
|
|
155
201
|
return _promise.default.resolve();
|
|
156
202
|
},
|
|
157
203
|
/**
|
|
@@ -184,9 +230,9 @@ var Authorization = _webexCore.WebexPlugin.extend((_dec = (0, _common.whileInFli
|
|
|
184
230
|
* identifies a user in your system
|
|
185
231
|
* @returns {Promise}
|
|
186
232
|
*/
|
|
187
|
-
requestAccessTokenFromJwt: function requestAccessTokenFromJwt(
|
|
233
|
+
requestAccessTokenFromJwt: function requestAccessTokenFromJwt(_ref3) {
|
|
188
234
|
var _this2 = this;
|
|
189
|
-
var jwt =
|
|
235
|
+
var jwt = _ref3.jwt;
|
|
190
236
|
var hydraUri = this.webex.internal.services.get('hydra', true);
|
|
191
237
|
if (hydraUri && hydraUri.slice(-1) !== '/') {
|
|
192
238
|
// add a `/` to hydra's uri from the services catalog so that
|
|
@@ -200,8 +246,8 @@ var Authorization = _webexCore.WebexPlugin.extend((_dec = (0, _common.whileInFli
|
|
|
200
246
|
headers: {
|
|
201
247
|
authorization: jwt
|
|
202
248
|
}
|
|
203
|
-
}).then(function (
|
|
204
|
-
var body =
|
|
249
|
+
}).then(function (_ref4) {
|
|
250
|
+
var body = _ref4.body;
|
|
205
251
|
return {
|
|
206
252
|
access_token: body.token,
|
|
207
253
|
token_type: 'Bearer',
|
|
@@ -238,13 +284,13 @@ var Authorization = _webexCore.WebexPlugin.extend((_dec = (0, _common.whileInFli
|
|
|
238
284
|
* @param {String} options.expiresIn
|
|
239
285
|
* @returns {Promise<object>}
|
|
240
286
|
*/
|
|
241
|
-
createJwt: function createJwt(
|
|
287
|
+
createJwt: function createJwt(_ref5) {
|
|
242
288
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
243
289
|
var issuer, secretId, displayName, expiresIn, secret, payload, alg, jwtToken;
|
|
244
290
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
245
291
|
while (1) switch (_context.prev = _context.next) {
|
|
246
292
|
case 0:
|
|
247
|
-
issuer =
|
|
293
|
+
issuer = _ref5.issuer, secretId = _ref5.secretId, displayName = _ref5.displayName, expiresIn = _ref5.expiresIn;
|
|
248
294
|
secret = Buffer.from(secretId, 'base64');
|
|
249
295
|
payload = {
|
|
250
296
|
"sub": "guest-user-".concat((0, _uuid.default)()),
|
|
@@ -375,7 +421,7 @@ var Authorization = _webexCore.WebexPlugin.extend((_dec = (0, _common.whileInFli
|
|
|
375
421
|
throw new Error("CSRF token ".concat(token, " does not match stored token ").concat(sessionToken));
|
|
376
422
|
}
|
|
377
423
|
},
|
|
378
|
-
version: "3.8.
|
|
424
|
+
version: "3.8.1-next.2"
|
|
379
425
|
}, ((0, _applyDecoratedDescriptor2.default)(_obj, "initiateImplicitGrant", [_dec], (0, _getOwnPropertyDescriptor.default)(_obj, "initiateImplicitGrant"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "initiateAuthorizationCodeGrant", [_dec2], (0, _getOwnPropertyDescriptor.default)(_obj, "initiateAuthorizationCodeGrant"), _obj), (0, _applyDecoratedDescriptor2.default)(_obj, "requestAccessTokenFromJwt", [_common.oneFlight], (0, _getOwnPropertyDescriptor.default)(_obj, "requestAccessTokenFromJwt"), _obj)), _obj)));
|
|
380
426
|
var _default = exports.default = Authorization;
|
|
381
427
|
//# sourceMappingURL=authorization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_querystring","_interopRequireDefault","require","_url","_common","_webexCore","_lodash","_uuid","_dec","_dec2","_obj","jwt","OAUTH2_CSRF_TOKEN","EMPTY_OBJECT_STRING","base64","encode","_stringify","default","Authorization","WebexPlugin","extend","whileInFlight","derived","isAuthenticating","deps","fn","isAuthorizing","session","type","ready","namespace","initialize","attrs","options","_this","ret","_apply","prototype","parse","location","url","webex","getWindow","href","_checkForErrors","hash","includes","substr","querystring","state","JSON","decode","tokenData","_parseHash","_cleanUrl","process","nextTick","credentials","set","supertoken","initiateLogin","arguments","length","undefined","csrf_token","_generateSecurityToken","config","clientType","initiateAuthorizationCodeGrant","initiateImplicitGrant","logger","info","buildLoginUrl","_assign","response_type","_promise","resolve","requestAccessTokenFromJwt","_ref","_this2","hydraUri","internal","services","get","slice","env","HYDRA_SERVICE_URL","request","method","uri","concat","headers","authorization","then","_ref2","body","access_token","token","token_type","expires_in","expiresIn","initServiceCatalogs","logout","noRedirect","buildLogoutUrl","createJwt","_ref3","_asyncToGenerator2","_regenerator","mark","_callee","issuer","secretId","displayName","secret","payload","alg","jwtToken","wrap","_callee$","_context","prev","next","Buffer","from","uuid","sign","abrupt","t0","reject","stop","query","error","ErrorConstructor","grantErrors","select","cloneDeep","history","replaceState","forEach","key","_deleteProperty","isEmpty","omit","stringify","format","v4","sessionStorage","setItem","_verifySecurityToken","_parseInt2","refresh_token_expires_in","sessionToken","getItem","removeItem","Error","version","_applyDecoratedDescriptor2","_getOwnPropertyDescriptor","oneFlight","_default","exports"],"sources":["authorization.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint camelcase: [0] */\n\nimport querystring from 'querystring';\nimport url from 'url';\n\nimport {base64, oneFlight, whileInFlight} from '@webex/common';\nimport {grantErrors, WebexPlugin} from '@webex/webex-core';\nimport {cloneDeep, isEmpty, omit} from 'lodash';\nimport uuid from 'uuid';\nconst jwt = require('jsonwebtoken');\n\nconst OAUTH2_CSRF_TOKEN = 'oauth2-csrf-token';\nconst EMPTY_OBJECT_STRING = base64.encode(JSON.stringify({}));\n\n/**\n * Browser support for OAuth2. Automatically parses the URL hash for an access\n * token\n * @class\n * @name AuthorizationBrowser\n */\nconst Authorization = WebexPlugin.extend({\n derived: {\n /**\n * Alias of {@link AuthorizationBrowser#isAuthorizing}\n * @instance\n * @memberof AuthorizationBrowser\n * @type {boolean}\n */\n isAuthenticating: {\n deps: ['isAuthorizing'],\n fn() {\n return this.isAuthorizing;\n },\n },\n },\n\n session: {\n /**\n * Indicates if an Authorization Code exchange is inflight\n * @instance\n * @memberof AuthorizationBrowser\n * @type {boolean}\n */\n isAuthorizing: {\n default: false,\n type: 'boolean',\n },\n ready: {\n default: false,\n type: 'boolean',\n },\n },\n\n namespace: 'Credentials',\n\n /**\n * Initializer\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} attrs {@link AmpersandState}\n * @param {boolean} attrs.parse Controls whether or not the the url should get\n * parsed for an access token\n * @private\n * @returns {Authorization}\n */\n // eslint-disable-next-line complexity\n initialize(attrs, options) {\n const ret = Reflect.apply(WebexPlugin.prototype.initialize, this, [attrs, options]);\n\n // Reminder, we can't do parse based on config, because config is not\n // available until nextTick and we want to be able to throw errors found in\n // the url.\n if (attrs.parse === false) {\n this.ready = true;\n\n return ret;\n }\n const location = url.parse(this.webex.getWindow().location.href, true);\n\n this._checkForErrors(location);\n\n let {hash} = location;\n\n if (!hash) {\n this.ready = true;\n\n return ret;\n }\n if (hash.includes('#')) {\n hash = hash.substr(1);\n }\n location.hash = querystring.parse(hash);\n if (location.hash.state) {\n location.hash.state = JSON.parse(base64.decode(location.hash.state));\n }\n const tokenData = this._parseHash(location);\n\n if (!tokenData) {\n return ret;\n }\n this._cleanUrl(location);\n\n // Wait until nextTick in case `credentials` hasn't initialized yet\n process.nextTick(() => {\n this.webex.credentials.set({supertoken: tokenData});\n this.ready = true;\n });\n\n return ret;\n },\n\n /**\n * Kicks off an oauth flow\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @returns {Promise}\n */\n initiateLogin(options = {}) {\n options.state = options.state || {};\n options.state.csrf_token = this._generateSecurityToken();\n\n // If we're not explicitly a confidential client, assume we're a public\n // client\n if (this.config.clientType === 'confidential') {\n return this.initiateAuthorizationCodeGrant(options);\n }\n\n return this.initiateImplicitGrant(options);\n },\n\n @whileInFlight('isAuthorizing')\n /**\n * Kicks off the Authorization Code grant flow. Typically called via\n * {@link AuthorizationBrowser#initiateLogin}\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @returns {Promise}\n */\n initiateImplicitGrant(options) {\n this.logger.info('authorization: initiating implicit grant flow');\n this.webex.getWindow().location = this.webex.credentials.buildLoginUrl(\n Object.assign({response_type: 'token'}, options)\n );\n\n return Promise.resolve();\n },\n\n @whileInFlight('isAuthorizing')\n /**\n * Kicks off the Implicit Code grant flow. Typically called via\n * {@link AuthorizationBrowser#initiateLogin}\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @returns {Promise}\n */\n initiateAuthorizationCodeGrant(options) {\n this.logger.info('authorization: initiating authorization code grant flow');\n this.webex.getWindow().location = this.webex.credentials.buildLoginUrl(\n Object.assign({response_type: 'code'}, options)\n );\n\n return Promise.resolve();\n },\n\n @oneFlight\n /**\n * Requests a Webex access token for a user already authenticated into\n * your product.\n *\n * Note: You'll need to supply a jwtRefreshCallback of the form\n * `Promise<jwt> = jwtRefreshCallback(webex)` for automatic token refresh to\n * work.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @param {Object} options.jwt This is a jwt generated by your backend that\n * identifies a user in your system\n * @returns {Promise}\n */\n requestAccessTokenFromJwt({jwt}) {\n let hydraUri = this.webex.internal.services.get('hydra', true);\n\n if (hydraUri && hydraUri.slice(-1) !== '/') {\n // add a `/` to hydra's uri from the services catalog so that\n // it matches the current env service format.\n hydraUri += '/';\n }\n\n hydraUri = hydraUri || process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1/';\n\n return this.webex\n .request({\n method: 'POST',\n uri: `${hydraUri}jwt/login`,\n headers: {\n authorization: jwt,\n },\n })\n .then(({body}) => ({\n access_token: body.token,\n token_type: 'Bearer',\n expires_in: body.expiresIn,\n }))\n .then((token) => {\n this.webex.credentials.set({\n supertoken: token,\n });\n })\n .then(() => this.webex.internal.services.initServiceCatalogs());\n },\n\n /**\n * Called by {@link WebexCore#logout()}. Redirects to the logout page\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @param {boolean} options.noRedirect if true, does not redirect\n * @returns {Promise}\n */\n logout(options = {}) {\n if (!options.noRedirect) {\n this.webex.getWindow().location = this.webex.credentials.buildLogoutUrl(options);\n }\n },\n\n /**\n * Creates a jwt user token\n * @param {object} options\n * @param {String} options.issuer Guest Issuer ID\n * @param {String} options.secretId Guest Secret ID\n * @param {String} options.displayName Guest Display Name | optional\n * @param {String} options.expiresIn\n * @returns {Promise<object>}\n */\n async createJwt({issuer, secretId, displayName, expiresIn}) {\n const secret = Buffer.from(secretId, 'base64');\n const payload = {\n \"sub\": `guest-user-${uuid()}`,\n \"iss\": issuer,\n \"name\": displayName || `Guest User - ${uuid()}`\n };\n const alg = 'HS256';\n\n try {\n\n const jwtToken = jwt.sign(payload, secret, { expiresIn });\n\n return Promise.resolve({jwt: jwtToken});\n } catch (e) {\n return Promise.reject(e);\n }\n },\n\n /**\n * Checks if the result of the login redirect contains an error string\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Promise}\n */\n _checkForErrors(location) {\n const {query} = location;\n\n if (query && query.error) {\n const ErrorConstructor = grantErrors.select(query.error);\n\n throw new ErrorConstructor(query);\n }\n },\n\n /**\n * Removes no-longer needed values from the url (access token, csrf token, etc)\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Promise}\n */\n _cleanUrl(location) {\n location = cloneDeep(location);\n if (this.webex.getWindow().history && this.webex.getWindow().history.replaceState) {\n [\n 'access_token',\n 'token_type',\n 'expires_in',\n 'refresh_token',\n 'refresh_token_expires_in',\n ].forEach((key) => Reflect.deleteProperty(location.hash, key));\n if (!isEmpty(location.hash.state)) {\n location.hash.state = base64.encode(\n JSON.stringify(omit(location.hash.state, 'csrf_token'))\n );\n if (location.hash.state === EMPTY_OBJECT_STRING) {\n Reflect.deleteProperty(location.hash, 'state');\n }\n } else {\n Reflect.deleteProperty(location.hash, 'state');\n }\n location.hash = querystring.stringify(location.hash);\n this.webex.getWindow().history.replaceState({}, null, url.format(location));\n }\n },\n\n /**\n * Generates a CSRF token and sticks in in sessionStorage\n * @instance\n * @memberof AuthorizationBrowser\n * @private\n * @returns {Promise}\n */\n _generateSecurityToken() {\n this.logger.info('authorization: generating csrf token');\n\n const token = uuid.v4();\n\n this.webex.getWindow().sessionStorage.setItem('oauth2-csrf-token', token);\n\n return token;\n },\n\n /**\n * Parses the url hash into an access token object\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Object}\n */\n _parseHash(location) {\n const hash = cloneDeep(location.hash);\n\n if (hash) {\n this._verifySecurityToken(hash);\n }\n if (!hash.access_token) {\n this.ready = true;\n\n return undefined;\n }\n if (hash.expires_in) {\n hash.expires_in = parseInt(hash.expires_in, 10);\n }\n if (hash.refresh_token_expires_in) {\n hash.refresh_token_expires_in = parseInt(hash.refresh_token_expires_in, 10);\n }\n\n return hash;\n },\n\n /**\n * Checks if the CSRF token in sessionStorage is the same as the one returned\n * in the url.\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} hash\n * @private\n * @returns {Promise}\n */\n _verifySecurityToken(hash) {\n const sessionToken = this.webex.getWindow().sessionStorage.getItem(OAUTH2_CSRF_TOKEN);\n\n this.webex.getWindow().sessionStorage.removeItem(OAUTH2_CSRF_TOKEN);\n if (!sessionToken) {\n return;\n }\n\n if (!hash.state) {\n throw new Error(`Expected CSRF token ${sessionToken}, but not found in redirect hash`);\n }\n\n if (!hash.state.csrf_token) {\n throw new Error(`Expected CSRF token ${sessionToken}, but not found in redirect hash`);\n }\n\n const token = hash.state.csrf_token;\n\n if (token !== sessionToken) {\n throw new Error(`CSRF token ${token} does not match stored token ${sessionToken}`);\n }\n },\n});\n\nexport default Authorization;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAMA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,K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;IACxF;IAEA,IAAI,CAAC3G,IAAI,CAACI,KAAK,CAACe,UAAU,EAAE;MAC1B,MAAM,IAAI2F,KAAK,wBAAAjE,MAAA,CAAwB8D,YAAY,qCAAkC,CAAC;IACxF;IAEA,IAAMvD,KAAK,GAAGpD,IAAI,CAACI,KAAK,CAACe,UAAU;IAEnC,IAAIiC,KAAK,KAAKuD,YAAY,EAAE;MAC1B,MAAM,IAAIG,KAAK,eAAAjE,MAAA,CAAeO,KAAK,mCAAAP,MAAA,CAAgC8D,YAAY,CAAE,CAAC;IACpF;EACF,CAAC;EAAAI,OAAA;AACH,CAAC,OAAAC,0BAAA,CAAA5I,OAAA,EAAAP,IAAA,4BAAAF,IAAA,OAAAsJ,yBAAA,CAAA7I,OAAA,EAAAP,IAAA,4BAAAA,IAAA,OAAAmJ,0BAAA,CAAA5I,OAAA,EAAAP,IAAA,qCAAAD,KAAA,OAAAqJ,yBAAA,CAAA7I,OAAA,EAAAP,IAAA,qCAAAA,IAAA,OAAAmJ,0BAAA,CAAA5I,OAAA,EAAAP,IAAA,gCA1NEqJ,iBAAS,OAAAD,yBAAA,CAAA7I,OAAA,EAAAP,IAAA,gCAAAA,IAAA,IAAAA,IAAA,EA0NX,CAAC;AAAC,IAAAsJ,QAAA,GAAAC,OAAA,CAAAhJ,OAAA,GAEYC,aAAa"}
|
|
1
|
+
{"version":3,"names":["_querystring","_interopRequireDefault","require","_url","_common","_webexCore","_lodash","_uuid","_dec","_dec2","_obj","jwt","OAUTH2_CSRF_TOKEN","EMPTY_OBJECT_STRING","base64","encode","_stringify","default","Authorization","WebexPlugin","extend","whileInFlight","derived","isAuthenticating","deps","fn","isAuthorizing","session","type","ready","namespace","initialize","attrs","options","_this","ret","_apply","prototype","parse","location","url","webex","getWindow","href","_checkForErrors","hash","includes","substr","querystring","state","JSON","decode","tokenData","_parseHash","_cleanUrl","process","nextTick","credentials","set","supertoken","initiateLogin","arguments","length","undefined","csrf_token","_generateSecurityToken","config","clientType","initiateAuthorizationCodeGrant","initiateImplicitGrant","logger","info","loginUrl","buildLoginUrl","_assign","response_type","separateWindow","defaultWindowSettings","width","height","windowSettings","_typeof2","windowFeatures","_entries","map","_ref","_ref2","_slicedToArray2","key","value","concat","join","open","_promise","resolve","requestAccessTokenFromJwt","_ref3","_this2","hydraUri","internal","services","get","slice","env","HYDRA_SERVICE_URL","request","method","uri","headers","authorization","then","_ref4","body","access_token","token","token_type","expires_in","expiresIn","initServiceCatalogs","logout","noRedirect","buildLogoutUrl","createJwt","_ref5","_asyncToGenerator2","_regenerator","mark","_callee","issuer","secretId","displayName","secret","payload","alg","jwtToken","wrap","_callee$","_context","prev","next","Buffer","from","uuid","sign","abrupt","t0","reject","stop","query","error","ErrorConstructor","grantErrors","select","cloneDeep","history","replaceState","forEach","_deleteProperty","isEmpty","omit","stringify","format","v4","sessionStorage","setItem","_verifySecurityToken","_parseInt2","refresh_token_expires_in","sessionToken","getItem","removeItem","Error","version","_applyDecoratedDescriptor2","_getOwnPropertyDescriptor","oneFlight","_default","exports"],"sources":["authorization.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/* eslint camelcase: [0] */\n\nimport querystring from 'querystring';\nimport url from 'url';\n\nimport {base64, oneFlight, whileInFlight} from '@webex/common';\nimport {grantErrors, WebexPlugin} from '@webex/webex-core';\nimport {cloneDeep, isEmpty, omit} from 'lodash';\nimport uuid from 'uuid';\nconst jwt = require('jsonwebtoken');\n\nconst OAUTH2_CSRF_TOKEN = 'oauth2-csrf-token';\nconst EMPTY_OBJECT_STRING = base64.encode(JSON.stringify({}));\n\n/**\n * Browser support for OAuth2. Automatically parses the URL hash for an access\n * token\n * @class\n * @name AuthorizationBrowser\n */\nconst Authorization = WebexPlugin.extend({\n derived: {\n /**\n * Alias of {@link AuthorizationBrowser#isAuthorizing}\n * @instance\n * @memberof AuthorizationBrowser\n * @type {boolean}\n */\n isAuthenticating: {\n deps: ['isAuthorizing'],\n fn() {\n return this.isAuthorizing;\n },\n },\n },\n\n session: {\n /**\n * Indicates if an Authorization Code exchange is inflight\n * @instance\n * @memberof AuthorizationBrowser\n * @type {boolean}\n */\n isAuthorizing: {\n default: false,\n type: 'boolean',\n },\n ready: {\n default: false,\n type: 'boolean',\n },\n },\n\n namespace: 'Credentials',\n\n /**\n * Initializer\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} attrs {@link AmpersandState}\n * @param {boolean} attrs.parse Controls whether or not the the url should get\n * parsed for an access token\n * @private\n * @returns {Authorization}\n */\n // eslint-disable-next-line complexity\n initialize(attrs, options) {\n const ret = Reflect.apply(WebexPlugin.prototype.initialize, this, [attrs, options]);\n\n // Reminder, we can't do parse based on config, because config is not\n // available until nextTick and we want to be able to throw errors found in\n // the url.\n if (attrs.parse === false) {\n this.ready = true;\n\n return ret;\n }\n const location = url.parse(this.webex.getWindow().location.href, true);\n\n this._checkForErrors(location);\n\n let {hash} = location;\n\n if (!hash) {\n this.ready = true;\n\n return ret;\n }\n if (hash.includes('#')) {\n hash = hash.substr(1);\n }\n location.hash = querystring.parse(hash);\n if (location.hash.state) {\n location.hash.state = JSON.parse(base64.decode(location.hash.state));\n }\n const tokenData = this._parseHash(location);\n\n if (!tokenData) {\n return ret;\n }\n this._cleanUrl(location);\n\n // Wait until nextTick in case `credentials` hasn't initialized yet\n process.nextTick(() => {\n this.webex.credentials.set({supertoken: tokenData});\n this.ready = true;\n });\n\n return ret;\n },\n\n/**\n * Initiates the OAuth flow for user authentication.\n * This function determines the type of OAuth flow to use based on the client type configuration.\n * If the client is configured as \"confidential\", it will initiate the Authorization Code Grant flow;\n * otherwise, it will initiate the Implicit Grant flow.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options - The options to configure the OAuth flow.\n * @param {Object} [options.state] - An optional state object that can be used to include additional\n * information such as security tokens. A CSRF token will be automatically generated and added to\n * this state object.\n * @param {boolean|Object} [options.separateWindow] - Determines if the login should open in a separate window.\n * This can be a boolean or an object specifying window features:\n * - If `true`, a new window with default dimensions is opened.\n * - If an object, custom window features can be specified (e.g., `{width: 800, height: 600}`).\n * @returns {Promise<void>} - A promise that resolves when the appropriate OAuth flow has been initiated.\n * The promise does not necessarily indicate the completion of the login process.\n * @throws {Error} - Throws an error if there are issues initiating the OAuth flow.\n */\n initiateLogin(options = {}) {\n options.state = options.state || {};\n options.state.csrf_token = this._generateSecurityToken();\n\n // If we're not explicitly a confidential client, assume we're a public\n // client\n if (this.config.clientType === 'confidential') {\n return this.initiateAuthorizationCodeGrant(options);\n }\n\n return this.initiateImplicitGrant(options);\n },\n\n @whileInFlight('isAuthorizing')\n/**\n * Initiates the Implicit Grant flow for authorization.\n * This function constructs the login URL and either opens it in a new\n * window or in the current window based on the provided options.\n * Typically called via {@link AuthorizationBrowser#initiateLogin}.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options - The options to configure the login flow.\n * @param {Object} [options.separateWindow] - Determines if the login should open in a separate window.\n * This can be a boolean or an object specifying window features:\n * - If `true`, a new window with default dimensions is opened.\n * - If an object, custom window features can be specified (e.g., `{width: 800, height: 600}`).\n * @returns {Promise<void>} - A promise that resolves immediately after initiating the login flow.\n * This promise does not indicate the completion of the login process.\n * @throws {Error} - Throws an error if the login URL cannot be constructed or if window opening fails.\n */\n initiateImplicitGrant(options) {\n\n this.logger.info('authorization: initiating implicit grant flow');\n const loginUrl = this.webex.credentials.buildLoginUrl(\n Object.assign({response_type: 'token'}, options)\n );\n\n if (options?.separateWindow) {\n // Default window settings\n const defaultWindowSettings = {\n width: 600,\n height: 800\n };\n\n // Merge user provided settings with defaults\n const windowSettings = Object.assign(\n defaultWindowSettings, \n typeof options.separateWindow === 'object' ? options.separateWindow : {}\n );\n // Convert settings object to window.open features string\n const windowFeatures = Object.entries(windowSettings)\n .map(([key, value]) => `${key}=${value}`)\n .join(',');\n this.webex.getWindow().open(loginUrl, '_blank', windowFeatures);\n } else {\n // Default behavior - open in same window\n this.webex.getWindow().location = loginUrl;\n }\n\n return Promise.resolve();\n },\n\n @whileInFlight('isAuthorizing')\n /**\n * Kicks off the Implicit Code grant flow. Typically called via\n * {@link AuthorizationBrowser#initiateLogin}\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @returns {Promise}\n */\n initiateAuthorizationCodeGrant(options) {\n this.logger.info('authorization: initiating authorization code grant flow');\n this.webex.getWindow().location = this.webex.credentials.buildLoginUrl(\n Object.assign({response_type: 'code'}, options)\n );\n\n return Promise.resolve();\n },\n\n @oneFlight\n /**\n * Requests a Webex access token for a user already authenticated into\n * your product.\n *\n * Note: You'll need to supply a jwtRefreshCallback of the form\n * `Promise<jwt> = jwtRefreshCallback(webex)` for automatic token refresh to\n * work.\n *\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @param {Object} options.jwt This is a jwt generated by your backend that\n * identifies a user in your system\n * @returns {Promise}\n */\n requestAccessTokenFromJwt({jwt}) {\n let hydraUri = this.webex.internal.services.get('hydra', true);\n\n if (hydraUri && hydraUri.slice(-1) !== '/') {\n // add a `/` to hydra's uri from the services catalog so that\n // it matches the current env service format.\n hydraUri += '/';\n }\n\n hydraUri = hydraUri || process.env.HYDRA_SERVICE_URL || 'https://api.ciscospark.com/v1/';\n\n return this.webex\n .request({\n method: 'POST',\n uri: `${hydraUri}jwt/login`,\n headers: {\n authorization: jwt,\n },\n })\n .then(({body}) => ({\n access_token: body.token,\n token_type: 'Bearer',\n expires_in: body.expiresIn,\n }))\n .then((token) => {\n this.webex.credentials.set({\n supertoken: token,\n });\n })\n .then(() => this.webex.internal.services.initServiceCatalogs());\n },\n\n /**\n * Called by {@link WebexCore#logout()}. Redirects to the logout page\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} options\n * @param {boolean} options.noRedirect if true, does not redirect\n * @returns {Promise}\n */\n logout(options = {}) {\n if (!options.noRedirect) {\n this.webex.getWindow().location = this.webex.credentials.buildLogoutUrl(options);\n }\n },\n\n /**\n * Creates a jwt user token\n * @param {object} options\n * @param {String} options.issuer Guest Issuer ID\n * @param {String} options.secretId Guest Secret ID\n * @param {String} options.displayName Guest Display Name | optional\n * @param {String} options.expiresIn\n * @returns {Promise<object>}\n */\n async createJwt({issuer, secretId, displayName, expiresIn}) {\n const secret = Buffer.from(secretId, 'base64');\n const payload = {\n \"sub\": `guest-user-${uuid()}`,\n \"iss\": issuer,\n \"name\": displayName || `Guest User - ${uuid()}`\n };\n const alg = 'HS256';\n\n try {\n\n const jwtToken = jwt.sign(payload, secret, { expiresIn });\n\n return Promise.resolve({jwt: jwtToken});\n } catch (e) {\n return Promise.reject(e);\n }\n },\n\n /**\n * Checks if the result of the login redirect contains an error string\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Promise}\n */\n _checkForErrors(location) {\n const {query} = location;\n\n if (query && query.error) {\n const ErrorConstructor = grantErrors.select(query.error);\n\n throw new ErrorConstructor(query);\n }\n },\n\n /**\n * Removes no-longer needed values from the url (access token, csrf token, etc)\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Promise}\n */\n _cleanUrl(location) {\n location = cloneDeep(location);\n if (this.webex.getWindow().history && this.webex.getWindow().history.replaceState) {\n [\n 'access_token',\n 'token_type',\n 'expires_in',\n 'refresh_token',\n 'refresh_token_expires_in',\n ].forEach((key) => Reflect.deleteProperty(location.hash, key));\n if (!isEmpty(location.hash.state)) {\n location.hash.state = base64.encode(\n JSON.stringify(omit(location.hash.state, 'csrf_token'))\n );\n if (location.hash.state === EMPTY_OBJECT_STRING) {\n Reflect.deleteProperty(location.hash, 'state');\n }\n } else {\n Reflect.deleteProperty(location.hash, 'state');\n }\n location.hash = querystring.stringify(location.hash);\n this.webex.getWindow().history.replaceState({}, null, url.format(location));\n }\n },\n\n /**\n * Generates a CSRF token and sticks in in sessionStorage\n * @instance\n * @memberof AuthorizationBrowser\n * @private\n * @returns {Promise}\n */\n _generateSecurityToken() {\n this.logger.info('authorization: generating csrf token');\n\n const token = uuid.v4();\n\n this.webex.getWindow().sessionStorage.setItem('oauth2-csrf-token', token);\n\n return token;\n },\n\n /**\n * Parses the url hash into an access token object\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} location\n * @private\n * @returns {Object}\n */\n _parseHash(location) {\n const hash = cloneDeep(location.hash);\n\n if (hash) {\n this._verifySecurityToken(hash);\n }\n if (!hash.access_token) {\n this.ready = true;\n\n return undefined;\n }\n if (hash.expires_in) {\n hash.expires_in = parseInt(hash.expires_in, 10);\n }\n if (hash.refresh_token_expires_in) {\n hash.refresh_token_expires_in = parseInt(hash.refresh_token_expires_in, 10);\n }\n\n return hash;\n },\n\n /**\n * Checks if the CSRF token in sessionStorage is the same as the one returned\n * in the url.\n * @instance\n * @memberof AuthorizationBrowser\n * @param {Object} hash\n * @private\n * @returns {Promise}\n */\n _verifySecurityToken(hash) {\n const sessionToken = this.webex.getWindow().sessionStorage.getItem(OAUTH2_CSRF_TOKEN);\n\n this.webex.getWindow().sessionStorage.removeItem(OAUTH2_CSRF_TOKEN);\n if (!sessionToken) {\n return;\n }\n\n if (!hash.state) {\n throw new Error(`Expected CSRF token ${sessionToken}, but not found in redirect hash`);\n }\n\n if (!hash.state.csrf_token) {\n throw new Error(`Expected CSRF token ${sessionToken}, but not found in redirect hash`);\n }\n\n const token = hash.state.csrf_token;\n\n if (token !== sessionToken) {\n throw new Error(`CSRF token ${token} does not match stored token ${sessionToken}`);\n }\n },\n});\n\nexport default Authorization;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAMA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,IAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAN,sBAAA,CAAAC,OAAA;AAAwB,IAAAM,IAAA,EAAAC,KAAA,EAAAC,IAAA;AAZx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