@jbrowse/plugin-authentication 2.13.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -224,7 +224,7 @@ declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfi
224
224
  } & {
225
225
  getToken(location?: UriLocation): Promise<string>;
226
226
  } & {
227
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
227
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
228
228
  headers: Headers;
229
229
  body?: BodyInit | null;
230
230
  cache?: RequestCache;
@@ -31,13 +31,17 @@ const ExternalTokenEntryForm = ({ internetAccountId, handleClose, }) => {
31
31
  const [token, setToken] = (0, react_1.useState)('');
32
32
  return (react_1.default.createElement(ui_1.Dialog, { open: true, maxWidth: "xl", "data-testid": "externalToken-form", title: `Enter token for ${internetAccountId}` },
33
33
  react_1.default.createElement(material_1.DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
34
- react_1.default.createElement(material_1.TextField, { required: true, label: "Enter Token", variant: "outlined", inputProps: { 'data-testid': 'entry-externalToken' }, onChange: event => setToken(event.target.value), margin: "dense" })),
34
+ react_1.default.createElement(material_1.TextField, { required: true, label: "Enter Token", variant: "outlined", inputProps: { 'data-testid': 'entry-externalToken' }, onChange: event => {
35
+ setToken(event.target.value);
36
+ }, margin: "dense" })),
35
37
  react_1.default.createElement(material_1.DialogActions, null,
36
38
  react_1.default.createElement(material_1.Button, { variant: "contained", color: "primary", type: "submit", disabled: !token, onClick: () => {
37
39
  if (token) {
38
40
  handleClose(token);
39
41
  }
40
42
  } }, "Add"),
41
- react_1.default.createElement(material_1.Button, { variant: "contained", color: "secondary", onClick: () => handleClose() }, "Cancel"))));
43
+ react_1.default.createElement(material_1.Button, { variant: "contained", color: "secondary", onClick: () => {
44
+ handleClose();
45
+ } }, "Cancel"))));
42
46
  };
43
47
  exports.ExternalTokenEntryForm = ExternalTokenEntryForm;
@@ -88,7 +88,7 @@ declare const stateModelFactory: (configSchema: ExternalTokenInternetAccountConf
88
88
  } & {
89
89
  getToken(location?: UriLocation): Promise<string>;
90
90
  } & {
91
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
91
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
92
92
  headers: Headers;
93
93
  body?: BodyInit | null;
94
94
  cache?: RequestCache;
@@ -17,7 +17,6 @@ const stateModelFactory = (configSchema) => {
17
17
  }))
18
18
  .actions(self => ({
19
19
  getTokenFromUser(resolve, reject) {
20
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
20
  const { session } = (0, mobx_state_tree_1.getRoot)(self);
22
21
  session.queueDialog((doneCallback) => [
23
22
  ExternalTokenEntryForm_1.ExternalTokenEntryForm,
@@ -49,7 +48,7 @@ const stateModelFactory = (configSchema) => {
49
48
  catch (error) {
50
49
  errorMessage = '';
51
50
  }
52
- throw new Error(`Token could not be validated — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`);
51
+ throw new Error(`Token could not be validated — ${response.status} ${errorMessage ? ` (${errorMessage})` : ''}`);
53
52
  }
54
53
  return token;
55
54
  },
@@ -228,7 +228,7 @@ export default function stateModelFactory(configSchema: GoogleDriveOAuthInternet
228
228
  } & {
229
229
  getToken(location?: UriLocation): Promise<string>;
230
230
  } & {
231
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
231
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
232
232
  headers: Headers;
233
233
  body?: BodyInit | null;
234
234
  cache?: RequestCache;
@@ -13,7 +13,7 @@ const util_1 = require("./util");
13
13
  const GoogleDriveFilehandle_1 = require("./GoogleDriveFilehandle");
14
14
  const GoogleDriveIcon_1 = __importDefault(require("./GoogleDriveIcon"));
15
15
  function getUri(str) {
16
- const urlId = str.match(/[-\w]{25,}/);
16
+ const urlId = /[-\w]{25,}/.exec(str);
17
17
  return `https://www.googleapis.com/drive/v3/files/${urlId}`;
18
18
  }
19
19
  /**
@@ -41,9 +41,15 @@ function HTTPBasicLoginForm({ internetAccountId, handleClose, }) {
41
41
  event.preventDefault();
42
42
  } },
43
43
  react_1.default.createElement(material_1.DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
44
- react_1.default.createElement(material_1.TextField, { required: true, label: "Username", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-username' }, onChange: event => setUsername(event.target.value), margin: "dense" }),
45
- react_1.default.createElement(material_1.TextField, { required: true, label: "Password", type: "password", autoComplete: "current-password", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-password' }, onChange: event => setPassword(event.target.value), margin: "dense" })),
44
+ react_1.default.createElement(material_1.TextField, { required: true, label: "Username", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-username' }, onChange: event => {
45
+ setUsername(event.target.value);
46
+ }, margin: "dense" }),
47
+ react_1.default.createElement(material_1.TextField, { required: true, label: "Password", type: "password", autoComplete: "current-password", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-password' }, onChange: event => {
48
+ setPassword(event.target.value);
49
+ }, margin: "dense" })),
46
50
  react_1.default.createElement(material_1.DialogActions, null,
47
51
  react_1.default.createElement(material_1.Button, { variant: "contained", color: "primary", type: "submit" }, "Submit"),
48
- react_1.default.createElement(material_1.Button, { variant: "contained", color: "secondary", type: "submit", onClick: () => handleClose() }, "Cancel")))));
52
+ react_1.default.createElement(material_1.Button, { variant: "contained", color: "secondary", type: "submit", onClick: () => {
53
+ handleClose();
54
+ } }, "Cancel")))));
49
55
  }
@@ -102,7 +102,7 @@ declare const stateModelFactory: (configSchema: HTTPBasicInternetAccountConfigMo
102
102
  } & {
103
103
  getToken(location?: UriLocation): Promise<string>;
104
104
  } & {
105
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
105
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
106
106
  headers: Headers;
107
107
  body?: BodyInit | null;
108
108
  cache?: RequestCache;
@@ -33,7 +33,6 @@ const stateModelFactory = (configSchema) => {
33
33
  * #action
34
34
  */
35
35
  getTokenFromUser(resolve, reject) {
36
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
36
  const { session } = (0, mobx_state_tree_1.getRoot)(self);
38
37
  session.queueDialog((doneCallback) => [
39
38
  HTTPBasicLoginForm_1.HTTPBasicLoginForm,
@@ -132,7 +132,7 @@ declare const stateModelFactory: (configSchema: OAuthInternetAccountConfigModel)
132
132
  } & {
133
133
  getToken(location?: UriLocation): Promise<string>;
134
134
  } & {
135
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
135
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
136
136
  headers: Headers;
137
137
  body?: BodyInit | null;
138
138
  cache?: RequestCache;
@@ -134,7 +134,9 @@ const stateModelFactory = (configSchema) => {
134
134
  }));
135
135
  }
136
136
  const data = await response.json();
137
- return (0, util_2.processTokenResponse)(data, token => this.storeRefreshToken(token));
137
+ return (0, util_2.processTokenResponse)(data, token => {
138
+ this.storeRefreshToken(token);
139
+ });
138
140
  },
139
141
  /**
140
142
  * #action
@@ -154,11 +156,15 @@ const stateModelFactory = (configSchema) => {
154
156
  const text = await response.text();
155
157
  throw new Error(await (0, util_3.getResponseError)({
156
158
  response,
157
- statusText: (0, util_2.processError)(text, () => this.removeRefreshToken()),
159
+ statusText: (0, util_2.processError)(text, () => {
160
+ this.removeRefreshToken();
161
+ }),
158
162
  }));
159
163
  }
160
164
  const data = await response.json();
161
- return (0, util_2.processTokenResponse)(data, token => this.storeRefreshToken(token));
165
+ return (0, util_2.processTokenResponse)(data, token => {
166
+ this.storeRefreshToken(token);
167
+ });
162
168
  },
163
169
  }))
164
170
  .actions(self => {
@@ -188,7 +194,8 @@ const stateModelFactory = (configSchema) => {
188
194
  */
189
195
  async finishOAuthWindow(event, resolve, reject) {
190
196
  if (event.data.name !== `JBrowseAuthWindow-${self.internetAccountId}`) {
191
- return this.deleteMessageChannel();
197
+ this.deleteMessageChannel();
198
+ return;
192
199
  }
193
200
  const redirectUriWithInfo = event.data.redirectUri;
194
201
  const fixedQueryString = redirectUriWithInfo.replace('#', '?');
@@ -198,32 +205,42 @@ const stateModelFactory = (configSchema) => {
198
205
  if (urlParams.has('access_token')) {
199
206
  const token = urlParams.get('access_token');
200
207
  if (!token) {
201
- return reject(new Error('Error with token endpoint'));
208
+ reject(new Error('Error with token endpoint'));
209
+ return;
202
210
  }
203
211
  self.storeToken(token);
204
- return resolve(token);
212
+ resolve(token);
213
+ return;
205
214
  }
206
215
  if (urlParams.has('code')) {
207
216
  const code = urlParams.get('code');
208
217
  if (!code) {
209
- return reject(new Error('Error with authorization endpoint'));
218
+ reject(new Error('Error with authorization endpoint'));
219
+ return;
210
220
  }
211
221
  try {
212
222
  const token = await self.exchangeAuthorizationForAccessToken(code, redirectUrl.origin + redirectUrl.pathname);
213
223
  self.storeToken(token);
214
- return resolve(token);
224
+ resolve(token);
225
+ return;
215
226
  }
216
227
  catch (e) {
217
- return e instanceof Error
218
- ? reject(e)
219
- : reject(new Error(String(e)));
228
+ if (e instanceof Error) {
229
+ reject(e);
230
+ }
231
+ else {
232
+ reject(new Error(String(e)));
233
+ }
234
+ return;
220
235
  }
221
236
  }
222
237
  if (redirectUriWithInfo.includes('access_denied')) {
223
- return reject(new Error('OAuth flow was cancelled'));
238
+ reject(new Error('OAuth flow was cancelled'));
239
+ return;
224
240
  }
225
241
  if (redirectUriWithInfo.includes('error')) {
226
- return reject(new Error('OAuth flow error: ' + queryStringSearch));
242
+ reject(new Error(`OAuth flow error: ${queryStringSearch}`));
243
+ return;
227
244
  }
228
245
  this.deleteMessageChannel();
229
246
  },
@@ -239,7 +256,7 @@ const stateModelFactory = (configSchema) => {
239
256
  const data = {
240
257
  client_id: self.clientId,
241
258
  redirect_uri: redirectUri,
242
- response_type: self.responseType || 'code',
259
+ response_type: self.responseType,
243
260
  token_access_type: 'offline',
244
261
  };
245
262
  if (self.state()) {
@@ -271,7 +288,7 @@ const stateModelFactory = (configSchema) => {
271
288
  this.finishOAuthWindow(eventFromDesktop, resolve, reject);
272
289
  }
273
290
  else {
274
- window.open(url, eventName, `width=500,height=600,left=0,top=0`);
291
+ window.open(url, eventName, 'width=500,height=600,left=0,top=0');
275
292
  }
276
293
  },
277
294
  /**
package/dist/index.d.ts CHANGED
@@ -194,7 +194,7 @@ export default class AuthenticationPlugin extends Plugin {
194
194
  } & {
195
195
  getToken(location?: import("@jbrowse/core/util").UriLocation): Promise<string>;
196
196
  } & {
197
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
197
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
198
198
  headers: Headers;
199
199
  body?: BodyInit | null;
200
200
  cache?: RequestCache;
@@ -368,7 +368,7 @@ export default class AuthenticationPlugin extends Plugin {
368
368
  } & {
369
369
  getToken(location?: import("@jbrowse/core/util").UriLocation): Promise<string>;
370
370
  } & {
371
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
371
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
372
372
  headers: Headers;
373
373
  body?: BodyInit | null;
374
374
  cache?: RequestCache;
@@ -531,7 +531,7 @@ export default class AuthenticationPlugin extends Plugin {
531
531
  } & {
532
532
  getToken(location?: import("@jbrowse/core/util").UriLocation): Promise<string>;
533
533
  } & {
534
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
534
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
535
535
  headers: Headers;
536
536
  body?: BodyInit | null;
537
537
  cache?: RequestCache;
@@ -866,7 +866,7 @@ export default class AuthenticationPlugin extends Plugin {
866
866
  } & {
867
867
  getToken(location?: import("@jbrowse/core/util").UriLocation): Promise<string>;
868
868
  } & {
869
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
869
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
870
870
  headers: Headers;
871
871
  body?: BodyInit | null;
872
872
  cache?: RequestCache;
package/dist/util.js CHANGED
@@ -13,7 +13,7 @@ async function getResponseError({ response, reason, statusText, }) {
13
13
  }
14
14
  async function getError(response) {
15
15
  try {
16
- return response.text();
16
+ return await response.text();
17
17
  }
18
18
  catch (e) {
19
19
  return response.statusText;
@@ -224,7 +224,7 @@ declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfi
224
224
  } & {
225
225
  getToken(location?: UriLocation): Promise<string>;
226
226
  } & {
227
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
227
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
228
228
  headers: Headers;
229
229
  body?: BodyInit | null;
230
230
  cache?: RequestCache;
@@ -5,12 +5,16 @@ export const ExternalTokenEntryForm = ({ internetAccountId, handleClose, }) => {
5
5
  const [token, setToken] = useState('');
6
6
  return (React.createElement(Dialog, { open: true, maxWidth: "xl", "data-testid": "externalToken-form", title: `Enter token for ${internetAccountId}` },
7
7
  React.createElement(DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
8
- React.createElement(TextField, { required: true, label: "Enter Token", variant: "outlined", inputProps: { 'data-testid': 'entry-externalToken' }, onChange: event => setToken(event.target.value), margin: "dense" })),
8
+ React.createElement(TextField, { required: true, label: "Enter Token", variant: "outlined", inputProps: { 'data-testid': 'entry-externalToken' }, onChange: event => {
9
+ setToken(event.target.value);
10
+ }, margin: "dense" })),
9
11
  React.createElement(DialogActions, null,
10
12
  React.createElement(Button, { variant: "contained", color: "primary", type: "submit", disabled: !token, onClick: () => {
11
13
  if (token) {
12
14
  handleClose(token);
13
15
  }
14
16
  } }, "Add"),
15
- React.createElement(Button, { variant: "contained", color: "secondary", onClick: () => handleClose() }, "Cancel"))));
17
+ React.createElement(Button, { variant: "contained", color: "secondary", onClick: () => {
18
+ handleClose();
19
+ } }, "Cancel"))));
16
20
  };
@@ -88,7 +88,7 @@ declare const stateModelFactory: (configSchema: ExternalTokenInternetAccountConf
88
88
  } & {
89
89
  getToken(location?: UriLocation): Promise<string>;
90
90
  } & {
91
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
91
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
92
92
  headers: Headers;
93
93
  body?: BodyInit | null;
94
94
  cache?: RequestCache;
@@ -15,7 +15,6 @@ const stateModelFactory = (configSchema) => {
15
15
  }))
16
16
  .actions(self => ({
17
17
  getTokenFromUser(resolve, reject) {
18
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
19
18
  const { session } = getRoot(self);
20
19
  session.queueDialog((doneCallback) => [
21
20
  ExternalTokenEntryForm,
@@ -47,7 +46,7 @@ const stateModelFactory = (configSchema) => {
47
46
  catch (error) {
48
47
  errorMessage = '';
49
48
  }
50
- throw new Error(`Token could not be validated — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`);
49
+ throw new Error(`Token could not be validated — ${response.status} ${errorMessage ? ` (${errorMessage})` : ''}`);
51
50
  }
52
51
  return token;
53
52
  },
@@ -228,7 +228,7 @@ export default function stateModelFactory(configSchema: GoogleDriveOAuthInternet
228
228
  } & {
229
229
  getToken(location?: UriLocation): Promise<string>;
230
230
  } & {
231
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
231
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
232
232
  headers: Headers;
233
233
  body?: BodyInit | null;
234
234
  cache?: RequestCache;
@@ -7,7 +7,7 @@ import { getDescriptiveErrorMessage } from './util';
7
7
  import { GoogleDriveFile } from './GoogleDriveFilehandle';
8
8
  import GoogleDriveIcon from './GoogleDriveIcon';
9
9
  function getUri(str) {
10
- const urlId = str.match(/[-\w]{25,}/);
10
+ const urlId = /[-\w]{25,}/.exec(str);
11
11
  return `https://www.googleapis.com/drive/v3/files/${urlId}`;
12
12
  }
13
13
  /**
@@ -15,9 +15,15 @@ export function HTTPBasicLoginForm({ internetAccountId, handleClose, }) {
15
15
  event.preventDefault();
16
16
  } },
17
17
  React.createElement(DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
18
- React.createElement(TextField, { required: true, label: "Username", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-username' }, onChange: event => setUsername(event.target.value), margin: "dense" }),
19
- React.createElement(TextField, { required: true, label: "Password", type: "password", autoComplete: "current-password", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-password' }, onChange: event => setPassword(event.target.value), margin: "dense" })),
18
+ React.createElement(TextField, { required: true, label: "Username", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-username' }, onChange: event => {
19
+ setUsername(event.target.value);
20
+ }, margin: "dense" }),
21
+ React.createElement(TextField, { required: true, label: "Password", type: "password", autoComplete: "current-password", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-password' }, onChange: event => {
22
+ setPassword(event.target.value);
23
+ }, margin: "dense" })),
20
24
  React.createElement(DialogActions, null,
21
25
  React.createElement(Button, { variant: "contained", color: "primary", type: "submit" }, "Submit"),
22
- React.createElement(Button, { variant: "contained", color: "secondary", type: "submit", onClick: () => handleClose() }, "Cancel")))));
26
+ React.createElement(Button, { variant: "contained", color: "secondary", type: "submit", onClick: () => {
27
+ handleClose();
28
+ } }, "Cancel")))));
23
29
  }
@@ -102,7 +102,7 @@ declare const stateModelFactory: (configSchema: HTTPBasicInternetAccountConfigMo
102
102
  } & {
103
103
  getToken(location?: UriLocation): Promise<string>;
104
104
  } & {
105
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
105
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
106
106
  headers: Headers;
107
107
  body?: BodyInit | null;
108
108
  cache?: RequestCache;
@@ -31,7 +31,6 @@ const stateModelFactory = (configSchema) => {
31
31
  * #action
32
32
  */
33
33
  getTokenFromUser(resolve, reject) {
34
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
34
  const { session } = getRoot(self);
36
35
  session.queueDialog((doneCallback) => [
37
36
  HTTPBasicLoginForm,
@@ -132,7 +132,7 @@ declare const stateModelFactory: (configSchema: OAuthInternetAccountConfigModel)
132
132
  } & {
133
133
  getToken(location?: UriLocation): Promise<string>;
134
134
  } & {
135
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
135
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
136
136
  headers: Headers;
137
137
  body?: BodyInit | null;
138
138
  cache?: RequestCache;
@@ -132,7 +132,9 @@ const stateModelFactory = (configSchema) => {
132
132
  }));
133
133
  }
134
134
  const data = await response.json();
135
- return processTokenResponse(data, token => this.storeRefreshToken(token));
135
+ return processTokenResponse(data, token => {
136
+ this.storeRefreshToken(token);
137
+ });
136
138
  },
137
139
  /**
138
140
  * #action
@@ -152,11 +154,15 @@ const stateModelFactory = (configSchema) => {
152
154
  const text = await response.text();
153
155
  throw new Error(await getResponseError({
154
156
  response,
155
- statusText: processError(text, () => this.removeRefreshToken()),
157
+ statusText: processError(text, () => {
158
+ this.removeRefreshToken();
159
+ }),
156
160
  }));
157
161
  }
158
162
  const data = await response.json();
159
- return processTokenResponse(data, token => this.storeRefreshToken(token));
163
+ return processTokenResponse(data, token => {
164
+ this.storeRefreshToken(token);
165
+ });
160
166
  },
161
167
  }))
162
168
  .actions(self => {
@@ -186,7 +192,8 @@ const stateModelFactory = (configSchema) => {
186
192
  */
187
193
  async finishOAuthWindow(event, resolve, reject) {
188
194
  if (event.data.name !== `JBrowseAuthWindow-${self.internetAccountId}`) {
189
- return this.deleteMessageChannel();
195
+ this.deleteMessageChannel();
196
+ return;
190
197
  }
191
198
  const redirectUriWithInfo = event.data.redirectUri;
192
199
  const fixedQueryString = redirectUriWithInfo.replace('#', '?');
@@ -196,32 +203,42 @@ const stateModelFactory = (configSchema) => {
196
203
  if (urlParams.has('access_token')) {
197
204
  const token = urlParams.get('access_token');
198
205
  if (!token) {
199
- return reject(new Error('Error with token endpoint'));
206
+ reject(new Error('Error with token endpoint'));
207
+ return;
200
208
  }
201
209
  self.storeToken(token);
202
- return resolve(token);
210
+ resolve(token);
211
+ return;
203
212
  }
204
213
  if (urlParams.has('code')) {
205
214
  const code = urlParams.get('code');
206
215
  if (!code) {
207
- return reject(new Error('Error with authorization endpoint'));
216
+ reject(new Error('Error with authorization endpoint'));
217
+ return;
208
218
  }
209
219
  try {
210
220
  const token = await self.exchangeAuthorizationForAccessToken(code, redirectUrl.origin + redirectUrl.pathname);
211
221
  self.storeToken(token);
212
- return resolve(token);
222
+ resolve(token);
223
+ return;
213
224
  }
214
225
  catch (e) {
215
- return e instanceof Error
216
- ? reject(e)
217
- : reject(new Error(String(e)));
226
+ if (e instanceof Error) {
227
+ reject(e);
228
+ }
229
+ else {
230
+ reject(new Error(String(e)));
231
+ }
232
+ return;
218
233
  }
219
234
  }
220
235
  if (redirectUriWithInfo.includes('access_denied')) {
221
- return reject(new Error('OAuth flow was cancelled'));
236
+ reject(new Error('OAuth flow was cancelled'));
237
+ return;
222
238
  }
223
239
  if (redirectUriWithInfo.includes('error')) {
224
- return reject(new Error('OAuth flow error: ' + queryStringSearch));
240
+ reject(new Error(`OAuth flow error: ${queryStringSearch}`));
241
+ return;
225
242
  }
226
243
  this.deleteMessageChannel();
227
244
  },
@@ -237,7 +254,7 @@ const stateModelFactory = (configSchema) => {
237
254
  const data = {
238
255
  client_id: self.clientId,
239
256
  redirect_uri: redirectUri,
240
- response_type: self.responseType || 'code',
257
+ response_type: self.responseType,
241
258
  token_access_type: 'offline',
242
259
  };
243
260
  if (self.state()) {
@@ -269,7 +286,7 @@ const stateModelFactory = (configSchema) => {
269
286
  this.finishOAuthWindow(eventFromDesktop, resolve, reject);
270
287
  }
271
288
  else {
272
- window.open(url, eventName, `width=500,height=600,left=0,top=0`);
289
+ window.open(url, eventName, 'width=500,height=600,left=0,top=0');
273
290
  }
274
291
  },
275
292
  /**
package/esm/index.d.ts CHANGED
@@ -194,7 +194,7 @@ export default class AuthenticationPlugin extends Plugin {
194
194
  } & {
195
195
  getToken(location?: import("@jbrowse/core/util").UriLocation): Promise<string>;
196
196
  } & {
197
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
197
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
198
198
  headers: Headers;
199
199
  body?: BodyInit | null;
200
200
  cache?: RequestCache;
@@ -368,7 +368,7 @@ export default class AuthenticationPlugin extends Plugin {
368
368
  } & {
369
369
  getToken(location?: import("@jbrowse/core/util").UriLocation): Promise<string>;
370
370
  } & {
371
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
371
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
372
372
  headers: Headers;
373
373
  body?: BodyInit | null;
374
374
  cache?: RequestCache;
@@ -531,7 +531,7 @@ export default class AuthenticationPlugin extends Plugin {
531
531
  } & {
532
532
  getToken(location?: import("@jbrowse/core/util").UriLocation): Promise<string>;
533
533
  } & {
534
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
534
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
535
535
  headers: Headers;
536
536
  body?: BodyInit | null;
537
537
  cache?: RequestCache;
@@ -866,7 +866,7 @@ export default class AuthenticationPlugin extends Plugin {
866
866
  } & {
867
867
  getToken(location?: import("@jbrowse/core/util").UriLocation): Promise<string>;
868
868
  } & {
869
- addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
869
+ addAuthHeaderToInit(init?: RequestInit, token?: string): {
870
870
  headers: Headers;
871
871
  body?: BodyInit | null;
872
872
  cache?: RequestCache;
package/esm/util.js CHANGED
@@ -9,7 +9,7 @@ export async function getResponseError({ response, reason, statusText, }) {
9
9
  }
10
10
  export async function getError(response) {
11
11
  try {
12
- return response.text();
12
+ return await response.text();
13
13
  }
14
14
  catch (e) {
15
15
  return response.statusText;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-authentication",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "JBrowse 2 Authentication",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -24,7 +24,7 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "build": "npm-run-all build:*",
27
- "test": "cd ../..; jest plugins/authentication",
27
+ "test": "cd ../..; jest --passWithNoTests plugins/authentication",
28
28
  "prepublishOnly": "yarn test",
29
29
  "prepack": "yarn build && yarn useDist",
30
30
  "postpack": "yarn useSrc",
@@ -55,5 +55,5 @@
55
55
  "distModule": "esm/index.js",
56
56
  "srcModule": "src/index.ts",
57
57
  "module": "esm/index.js",
58
- "gitHead": "efe02fb9616e20e929cceeed46eb96420c1b6923"
58
+ "gitHead": "9fb8231d932db40adf0a283081765431756c66ff"
59
59
  }