@jbrowse/plugin-authentication 2.17.0 → 3.0.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.
Files changed (70) hide show
  1. package/dist/DropboxOAuthModel/DropboxIcon.d.ts +2 -3
  2. package/dist/DropboxOAuthModel/DropboxIcon.js +2 -6
  3. package/dist/DropboxOAuthModel/configSchema.d.ts +1 -13
  4. package/dist/DropboxOAuthModel/configSchema.js +1 -19
  5. package/dist/DropboxOAuthModel/model.d.ts +5 -28
  6. package/dist/DropboxOAuthModel/model.js +4 -26
  7. package/dist/DropboxOAuthModel/util.js +0 -5
  8. package/dist/ExternalTokenModel/ExternalTokenEntryForm.d.ts +1 -2
  9. package/dist/ExternalTokenModel/ExternalTokenEntryForm.js +16 -41
  10. package/dist/ExternalTokenModel/configSchema.d.ts +1 -4
  11. package/dist/ExternalTokenModel/configSchema.js +1 -10
  12. package/dist/ExternalTokenModel/model.d.ts +3 -3
  13. package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +3 -3
  14. package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +1 -1
  15. package/dist/GoogleDriveOAuthModel/GoogleDriveIcon.d.ts +2 -3
  16. package/dist/GoogleDriveOAuthModel/GoogleDriveIcon.js +2 -6
  17. package/dist/GoogleDriveOAuthModel/configSchema.d.ts +1 -13
  18. package/dist/GoogleDriveOAuthModel/configSchema.js +1 -19
  19. package/dist/GoogleDriveOAuthModel/model.d.ts +5 -31
  20. package/dist/GoogleDriveOAuthModel/model.js +4 -29
  21. package/dist/GoogleDriveOAuthModel/util.js +0 -1
  22. package/dist/HTTPBasicModel/HTTPBasicLoginForm.d.ts +1 -2
  23. package/dist/HTTPBasicModel/HTTPBasicLoginForm.js +17 -44
  24. package/dist/HTTPBasicModel/configSchema.d.ts +1 -7
  25. package/dist/HTTPBasicModel/configSchema.js +1 -13
  26. package/dist/HTTPBasicModel/model.d.ts +3 -21
  27. package/dist/HTTPBasicModel/model.js +0 -18
  28. package/dist/OAuthModel/configSchema.d.ts +1 -25
  29. package/dist/OAuthModel/configSchema.js +1 -31
  30. package/dist/OAuthModel/model.d.ts +4 -90
  31. package/dist/OAuthModel/model.js +11 -101
  32. package/dist/OAuthModel/util.js +17 -9
  33. package/dist/index.d.ts +4 -4
  34. package/dist/index.js +3 -3
  35. package/esm/DropboxOAuthModel/DropboxIcon.d.ts +2 -3
  36. package/esm/DropboxOAuthModel/DropboxIcon.js +2 -3
  37. package/esm/DropboxOAuthModel/configSchema.d.ts +1 -13
  38. package/esm/DropboxOAuthModel/configSchema.js +1 -19
  39. package/esm/DropboxOAuthModel/model.d.ts +5 -28
  40. package/esm/DropboxOAuthModel/model.js +4 -26
  41. package/esm/DropboxOAuthModel/util.js +0 -5
  42. package/esm/ExternalTokenModel/ExternalTokenEntryForm.d.ts +1 -2
  43. package/esm/ExternalTokenModel/ExternalTokenEntryForm.js +16 -18
  44. package/esm/ExternalTokenModel/configSchema.d.ts +1 -4
  45. package/esm/ExternalTokenModel/configSchema.js +1 -10
  46. package/esm/ExternalTokenModel/model.d.ts +3 -3
  47. package/esm/ExternalTokenModel/model.js +1 -1
  48. package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +3 -3
  49. package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +1 -1
  50. package/esm/GoogleDriveOAuthModel/GoogleDriveIcon.d.ts +2 -3
  51. package/esm/GoogleDriveOAuthModel/GoogleDriveIcon.js +2 -3
  52. package/esm/GoogleDriveOAuthModel/configSchema.d.ts +1 -13
  53. package/esm/GoogleDriveOAuthModel/configSchema.js +1 -19
  54. package/esm/GoogleDriveOAuthModel/model.d.ts +5 -31
  55. package/esm/GoogleDriveOAuthModel/model.js +4 -29
  56. package/esm/GoogleDriveOAuthModel/util.js +0 -1
  57. package/esm/HTTPBasicModel/HTTPBasicLoginForm.d.ts +1 -2
  58. package/esm/HTTPBasicModel/HTTPBasicLoginForm.js +17 -21
  59. package/esm/HTTPBasicModel/configSchema.d.ts +1 -7
  60. package/esm/HTTPBasicModel/configSchema.js +1 -13
  61. package/esm/HTTPBasicModel/model.d.ts +3 -21
  62. package/esm/HTTPBasicModel/model.js +1 -19
  63. package/esm/OAuthModel/configSchema.d.ts +1 -25
  64. package/esm/OAuthModel/configSchema.js +1 -31
  65. package/esm/OAuthModel/model.d.ts +4 -90
  66. package/esm/OAuthModel/model.js +11 -101
  67. package/esm/OAuthModel/util.js +0 -2
  68. package/esm/index.d.ts +4 -4
  69. package/esm/index.js +3 -3
  70. package/package.json +3 -3
@@ -4,117 +4,70 @@ const configuration_1 = require("@jbrowse/core/configuration");
4
4
  const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
5
5
  const util_1 = require("@jbrowse/core/util");
6
6
  const mobx_state_tree_1 = require("mobx-state-tree");
7
- const buffer_1 = require("buffer");
8
7
  const util_2 = require("./util");
9
8
  const util_3 = require("../util");
10
- /**
11
- * #stateModel OAuthInternetAccount
12
- */
9
+ function encode(uint8array) {
10
+ const output = [];
11
+ for (let i = 0, length = uint8array.length; i < length; i++) {
12
+ output.push(String.fromCharCode(uint8array[i]));
13
+ }
14
+ return btoa(output.join(''));
15
+ }
13
16
  const stateModelFactory = (configSchema) => {
14
17
  return models_1.InternetAccount.named('OAuthInternetAccount')
15
18
  .props({
16
- /**
17
- * #property
18
- */
19
19
  type: mobx_state_tree_1.types.literal('OAuthInternetAccount'),
20
- /**
21
- * #property
22
- */
23
20
  configuration: (0, configuration_1.ConfigurationReference)(configSchema),
24
21
  })
25
22
  .views(() => {
26
23
  let codeVerifier = undefined;
27
24
  return {
28
- /**
29
- * #getter
30
- */
31
25
  get codeVerifierPKCE() {
32
- if (codeVerifier) {
33
- return codeVerifier;
26
+ if (!codeVerifier) {
27
+ const array = new Uint8Array(32);
28
+ globalThis.crypto.getRandomValues(array);
29
+ codeVerifier = (0, util_2.fixup)(encode(array));
34
30
  }
35
- const array = new Uint8Array(32);
36
- globalThis.crypto.getRandomValues(array);
37
- codeVerifier = (0, util_2.fixup)(buffer_1.Buffer.from(array).toString('base64'));
38
31
  return codeVerifier;
39
32
  },
40
33
  };
41
34
  })
42
35
  .views(self => ({
43
- /**
44
- * #getter
45
- */
46
36
  get authEndpoint() {
47
37
  return (0, configuration_1.getConf)(self, 'authEndpoint');
48
38
  },
49
- /**
50
- * #getter
51
- */
52
39
  get tokenEndpoint() {
53
40
  return (0, configuration_1.getConf)(self, 'tokenEndpoint');
54
41
  },
55
- /**
56
- * #getter
57
- */
58
42
  get needsPKCE() {
59
43
  return (0, configuration_1.getConf)(self, 'needsPKCE');
60
44
  },
61
- /**
62
- * #getter
63
- */
64
45
  get clientId() {
65
46
  return (0, configuration_1.getConf)(self, 'clientId');
66
47
  },
67
- /**
68
- * #getter
69
- */
70
48
  get scopes() {
71
49
  return (0, configuration_1.getConf)(self, 'scopes');
72
50
  },
73
- /**
74
- * #method
75
- * OAuth state parameter:
76
- * https://www.rfc-editor.org/rfc/rfc6749#section-4.1.1
77
- *
78
- * Can override or extend if dynamic state is needed.
79
- */
80
51
  state() {
81
52
  return (0, configuration_1.getConf)(self, 'state');
82
53
  },
83
- /**
84
- * #getter
85
- */
86
54
  get responseType() {
87
55
  return (0, configuration_1.getConf)(self, 'responseType');
88
56
  },
89
- /**
90
- * #getter
91
- */
92
57
  get refreshTokenKey() {
93
58
  return `${self.internetAccountId}-refreshToken`;
94
59
  },
95
60
  }))
96
61
  .actions(self => ({
97
- /**
98
- * #action
99
- */
100
62
  storeRefreshToken(refreshToken) {
101
63
  localStorage.setItem(self.refreshTokenKey, refreshToken);
102
64
  },
103
- /**
104
- * #action
105
- */
106
65
  removeRefreshToken() {
107
66
  localStorage.removeItem(self.refreshTokenKey);
108
67
  },
109
- /**
110
- * #method
111
- */
112
68
  retrieveRefreshToken() {
113
69
  return localStorage.getItem(self.refreshTokenKey);
114
70
  },
115
- /**
116
- * #action
117
- */
118
71
  async exchangeAuthorizationForAccessToken(token, redirectUri) {
119
72
  const params = new URLSearchParams(Object.entries({
120
73
  code: token,
@@ -139,9 +92,6 @@ const stateModelFactory = (configSchema) => {
139
92
  this.storeRefreshToken(token);
140
93
  });
141
94
  },
142
- /**
143
- * #action
144
- */
145
95
  async exchangeRefreshForAccessToken(refreshToken) {
146
96
  const response = await fetch(self.tokenEndpoint, {
147
97
  method: 'POST',
@@ -172,27 +122,15 @@ const stateModelFactory = (configSchema) => {
172
122
  let listener;
173
123
  let exchangedTokenPromise = undefined;
174
124
  return {
175
- /**
176
- * #action
177
- * used to listen to child window for auth code/token
178
- */
179
125
  addMessageChannel(resolve, reject) {
180
126
  listener = event => {
181
- // this should probably get better handling, but ignored for now
182
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
183
127
  this.finishOAuthWindow(event, resolve, reject);
184
128
  };
185
129
  window.addEventListener('message', listener);
186
130
  },
187
- /**
188
- * #action
189
- */
190
131
  deleteMessageChannel() {
191
132
  window.removeEventListener('message', listener);
192
133
  },
193
- /**
194
- * #action
195
- */
196
134
  async finishOAuthWindow(event, resolve, reject) {
197
135
  if (event.data.name !== `JBrowseAuthWindow-${self.internetAccountId}`) {
198
136
  this.deleteMessageChannel();
@@ -245,11 +183,6 @@ const stateModelFactory = (configSchema) => {
245
183
  }
246
184
  this.deleteMessageChannel();
247
185
  },
248
- /**
249
- * #action
250
- * opens external OAuth flow, popup for web and new browser window for
251
- * desktop
252
- */
253
186
  async useEndpointForAuthorization(resolve, reject) {
254
187
  const redirectUri = util_1.isElectron
255
188
  ? 'http://localhost/auth'
@@ -284,22 +217,15 @@ const stateModelFactory = (configSchema) => {
284
217
  const eventFromDesktop = new MessageEvent('message', {
285
218
  data: { name: eventName, redirectUri: redirectUri },
286
219
  });
287
- // may want to improve handling
288
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
289
220
  this.finishOAuthWindow(eventFromDesktop, resolve, reject);
290
221
  }
291
222
  else {
292
223
  window.open(url, eventName, 'width=500,height=600,left=0,top=0');
293
224
  }
294
225
  },
295
- /**
296
- * #action
297
- */
298
226
  async getTokenFromUser(resolve, reject) {
299
227
  const refreshToken = self.retrieveRefreshToken();
300
228
  let doUserFlow = true;
301
- // if there is a refresh token, then try it out, and only if that
302
- // refresh token succeeds, set doUserFlow to false
303
229
  if (refreshToken) {
304
230
  try {
305
231
  const token = await self.exchangeRefreshForAccessToken(refreshToken);
@@ -313,14 +239,9 @@ const stateModelFactory = (configSchema) => {
313
239
  }
314
240
  if (doUserFlow) {
315
241
  this.addMessageChannel(resolve, reject);
316
- // may want to improve handling
317
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
318
242
  this.useEndpointForAuthorization(resolve, reject);
319
243
  }
320
244
  },
321
- /**
322
- * #action
323
- */
324
245
  async validateToken(token, location) {
325
246
  const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token);
326
247
  const response = await fetch(location.uri, newInit);
@@ -339,7 +260,6 @@ const stateModelFactory = (configSchema) => {
339
260
  }
340
261
  catch (err) {
341
262
  console.error('Token could not be refreshed', err);
342
- // let original error be thrown
343
263
  }
344
264
  }
345
265
  throw new Error(await (0, util_3.getResponseError)({
@@ -354,16 +274,6 @@ const stateModelFactory = (configSchema) => {
354
274
  .actions(self => {
355
275
  const superGetFetcher = self.getFetcher;
356
276
  return {
357
- /**
358
- * #action
359
- * Get a fetch method that will add any needed authentication headers
360
- * to the request before sending it. If location is provided, it will
361
- * be checked to see if it includes a token in it's pre-auth
362
- * information.
363
- *
364
- * @param loc - UriLocation of the resource
365
- * @returns A function that can be used to fetch
366
- */
367
277
  getFetcher(loc) {
368
278
  const fetcher = superGetFetcher(loc);
369
279
  return async (input, init) => {
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.fixup = fixup;
27
37
  exports.generateChallenge = generateChallenge;
@@ -35,7 +45,6 @@ async function generateChallenge(val) {
35
45
  const Base64 = await Promise.resolve().then(() => __importStar(require('crypto-js/enc-base64')));
36
46
  return fixup(Base64.stringify(sha256(val)));
37
47
  }
38
- // if response is JSON, checks if it needs to remove tokens in error, or just plain throw
39
48
  function processError(text, invalidErrorCb) {
40
49
  var _a;
41
50
  try {
@@ -46,7 +55,6 @@ function processError(text, invalidErrorCb) {
46
55
  return (_a = obj === null || obj === void 0 ? void 0 : obj.error_description) !== null && _a !== void 0 ? _a : text;
47
56
  }
48
57
  catch (e) {
49
- /* response text is not json, just use original text as error */
50
58
  }
51
59
  return text;
52
60
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import Plugin from '@jbrowse/core/Plugin';
2
- import PluginManager from '@jbrowse/core/PluginManager';
3
2
  import { modelFactory as GoogleDriveOAuthInternetAccountModelFactory } from './GoogleDriveOAuthModel';
3
+ import type PluginManager from '@jbrowse/core/PluginManager';
4
4
  export default class AuthenticationPlugin extends Plugin {
5
5
  name: string;
6
6
  exports: {
@@ -230,7 +230,7 @@ export default class AuthenticationPlugin extends Plugin {
230
230
  readonly clientId: string;
231
231
  readonly scopes: string;
232
232
  state(): string | undefined;
233
- readonly responseType: "code" | "token";
233
+ readonly responseType: "token" | "code";
234
234
  readonly refreshTokenKey: string;
235
235
  } & {
236
236
  storeRefreshToken(refreshToken: string): void;
@@ -902,7 +902,7 @@ export default class AuthenticationPlugin extends Plugin {
902
902
  readonly clientId: string;
903
903
  readonly scopes: string;
904
904
  state(): string | undefined;
905
- readonly responseType: "code" | "token";
905
+ readonly responseType: "token" | "code";
906
906
  readonly refreshTokenKey: string;
907
907
  } & {
908
908
  storeRefreshToken(refreshToken: string): void;
@@ -920,7 +920,7 @@ export default class AuthenticationPlugin extends Plugin {
920
920
  } & {
921
921
  getFetcher(loc?: import("@jbrowse/core/util").UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
922
922
  } & {
923
- readonly toggleContents: import("react").JSX.Element;
923
+ readonly toggleContents: import("react/jsx-runtime").JSX.Element;
924
924
  readonly selectorLabel: string;
925
925
  } & {
926
926
  getFetcher(location?: import("@jbrowse/core/util").UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
package/dist/index.js CHANGED
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.GoogleDriveOAuthInternetAccountModelFactory = exports.GoogleDriveOAuthConfigSchema = exports.DropboxOAuthInternetAccountModelFactory = exports.DropboxOAuthConfigSchema = exports.HTTPBasicInternetAccountModelFactory = exports.HTTPBasicConfigSchema = exports.ExternalTokenInternetAccountModelFactory = exports.ExternalTokenConfigSchema = exports.OAuthInternetAccountModelFactory = exports.OAuthConfigSchema = void 0;
7
7
  const Plugin_1 = __importDefault(require("@jbrowse/core/Plugin"));
8
8
  const InternetAccountType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/InternetAccountType"));
9
- const OAuthModel_1 = require("./OAuthModel");
10
- const ExternalTokenModel_1 = require("./ExternalTokenModel");
11
- const HTTPBasicModel_1 = require("./HTTPBasicModel");
12
9
  const DropboxOAuthModel_1 = require("./DropboxOAuthModel");
10
+ const ExternalTokenModel_1 = require("./ExternalTokenModel");
13
11
  const GoogleDriveOAuthModel_1 = require("./GoogleDriveOAuthModel");
12
+ const HTTPBasicModel_1 = require("./HTTPBasicModel");
13
+ const OAuthModel_1 = require("./OAuthModel");
14
14
  class AuthenticationPlugin extends Plugin_1.default {
15
15
  constructor() {
16
16
  super(...arguments);
@@ -1,3 +1,2 @@
1
- import React from 'react';
2
- import { SvgIconProps } from '@mui/material';
3
- export default function DropboxIcon(props: SvgIconProps): React.JSX.Element;
1
+ import type { SvgIconProps } from '@mui/material';
2
+ export default function DropboxIcon(props: SvgIconProps): import("react/jsx-runtime").JSX.Element;
@@ -1,6 +1,5 @@
1
- import React from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { SvgIcon } from '@mui/material';
3
3
  export default function DropboxIcon(props) {
4
- return (React.createElement(SvgIcon, { ...props },
5
- React.createElement("path", { d: "M3 6.2L8 9.39L13 6.2L8 3L3 6.2M13 6.2L18 9.39L23 6.2L18 3L13 6.2M3 12.55L8 15.74L13 12.55L8 9.35L3 12.55M18 9.35L13 12.55L18 15.74L23 12.55L18 9.35M8.03 16.8L13.04 20L18.04 16.8L13.04 13.61L8.03 16.8Z" })));
4
+ return (_jsx(SvgIcon, { ...props, children: _jsx("path", { d: "M3 6.2L8 9.39L13 6.2L8 3L3 6.2M13 6.2L18 9.39L23 6.2L18 3L13 6.2M3 12.55L8 15.74L13 12.55L8 9.35L3 12.55M18 9.35L13 12.55L18 15.74L23 12.55L18 9.35M8.03 16.8L13.04 20L18.04 16.8L13.04 13.61L8.03 16.8Z" }) }));
6
5
  }
@@ -1,32 +1,20 @@
1
- import { Instance } from 'mobx-state-tree';
1
+ import type { Instance } from 'mobx-state-tree';
2
2
  declare const DropboxOAuthConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
3
- /**
4
- * #slot
5
- */
6
3
  authEndpoint: {
7
4
  description: string;
8
5
  type: string;
9
6
  defaultValue: string;
10
7
  };
11
- /**
12
- * #slot
13
- */
14
8
  tokenEndpoint: {
15
9
  description: string;
16
10
  type: string;
17
11
  defaultValue: string;
18
12
  };
19
- /**
20
- * #slot
21
- */
22
13
  needsPKCE: {
23
14
  description: string;
24
15
  type: string;
25
16
  defaultValue: boolean;
26
17
  };
27
- /**
28
- * #slot
29
- */
30
18
  domains: {
31
19
  description: string;
32
20
  type: string;
@@ -1,37 +1,22 @@
1
1
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
2
  import OAuthConfigSchema from '../OAuthModel/configSchema';
3
- /**
4
- * #config DropboxOAuthInternetAccount
5
- */
6
- function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ function x() { }
7
4
  const DropboxOAuthConfigSchema = ConfigurationSchema('DropboxOAuthInternetAccount', {
8
- /**
9
- * #slot
10
- */
11
5
  authEndpoint: {
12
6
  description: 'the authorization code endpoint of the internet account',
13
7
  type: 'string',
14
8
  defaultValue: 'https://www.dropbox.com/oauth2/authorize',
15
9
  },
16
- /**
17
- * #slot
18
- */
19
10
  tokenEndpoint: {
20
11
  description: 'the token endpoint of the internet account',
21
12
  type: 'string',
22
13
  defaultValue: 'https://api.dropbox.com/oauth2/token',
23
14
  },
24
- /**
25
- * #slot
26
- */
27
15
  needsPKCE: {
28
16
  description: 'boolean to indicate if the endpoint needs a PKCE code',
29
17
  type: 'boolean',
30
18
  defaultValue: true,
31
19
  },
32
- /**
33
- * #slot
34
- */
35
20
  domains: {
36
21
  description: 'array of valid domains the url can contain to use this account',
37
22
  type: 'stringArray',
@@ -46,9 +31,6 @@ const DropboxOAuthConfigSchema = ConfigurationSchema('DropboxOAuthInternetAccoun
46
31
  ],
47
32
  },
48
33
  }, {
49
- /**
50
- * #baseConfiguration
51
- */
52
34
  baseConfiguration: OAuthConfigSchema,
53
35
  explicitlyTyped: true,
54
36
  });
@@ -1,10 +1,6 @@
1
- import React from 'react';
2
- import { UriLocation } from '@jbrowse/core/util/types';
3
- import { Instance } from 'mobx-state-tree';
4
- import { DropboxOAuthInternetAccountConfigModel } from './configSchema';
5
- /**
6
- * #stateModel DropboxOAuthInternetAccount
7
- */
1
+ import type { DropboxOAuthInternetAccountConfigModel } from './configSchema';
2
+ import type { UriLocation } from '@jbrowse/core/util/types';
3
+ import type { Instance } from 'mobx-state-tree';
8
4
  declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
9
5
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
10
6
  type: import("mobx-state-tree").ISimpleType<string>;
@@ -106,13 +102,7 @@ declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfi
106
102
  };
107
103
  }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
108
104
  } & {
109
- /**
110
- * #property
111
- */
112
105
  type: import("mobx-state-tree").ISimpleType<"DropboxOAuthInternetAccount">;
113
- /**
114
- * #property
115
- */
116
106
  configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
117
107
  authEndpoint: {
118
108
  description: string;
@@ -260,7 +250,7 @@ declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfi
260
250
  readonly clientId: string;
261
251
  readonly scopes: string;
262
252
  state(): string | undefined;
263
- readonly responseType: "code" | "token";
253
+ readonly responseType: "token" | "code";
264
254
  readonly refreshTokenKey: string;
265
255
  } & {
266
256
  storeRefreshToken(refreshToken: string): void;
@@ -278,23 +268,10 @@ declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfi
278
268
  } & {
279
269
  getFetcher(loc?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
280
270
  } & {
281
- /**
282
- * #getter
283
- * The FileSelector icon for Dropbox
284
- */
285
- readonly toggleContents: React.JSX.Element;
286
- /**
287
- * #getter
288
- */
271
+ readonly toggleContents: import("react/jsx-runtime").JSX.Element;
289
272
  readonly selectorLabel: string;
290
273
  } & {
291
- /**
292
- * #method
293
- */
294
274
  getFetcher(location?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
295
- /**
296
- * #action
297
- */
298
275
  validateToken(token: string, location: UriLocation): Promise<string>;
299
276
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
300
277
  export default stateModelFactory;
@@ -1,45 +1,26 @@
1
- import React from 'react';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ConfigurationReference } from '@jbrowse/core/configuration';
3
3
  import { types } from 'mobx-state-tree';
4
- import baseModel from '../OAuthModel/model';
5
4
  import { configSchema as OAuthConfigSchema } from '../OAuthModel';
6
- import { getDescriptiveErrorMessage } from './util';
7
5
  import DropboxIcon from './DropboxIcon';
8
- /**
9
- * #stateModel DropboxOAuthInternetAccount
10
- */
6
+ import { getDescriptiveErrorMessage } from './util';
7
+ import baseModel from '../OAuthModel/model';
11
8
  const stateModelFactory = (configSchema) => {
12
9
  return baseModel(OAuthConfigSchema)
13
10
  .named('DropboxOAuthInternetAccount')
14
11
  .props({
15
- /**
16
- * #property
17
- */
18
12
  type: types.literal('DropboxOAuthInternetAccount'),
19
- /**
20
- * #property
21
- */
22
13
  configuration: ConfigurationReference(configSchema),
23
14
  })
24
15
  .views(() => ({
25
- /**
26
- * #getter
27
- * The FileSelector icon for Dropbox
28
- */
29
16
  get toggleContents() {
30
- return React.createElement(DropboxIcon, null);
17
+ return _jsx(DropboxIcon, {});
31
18
  },
32
- /**
33
- * #getter
34
- */
35
19
  get selectorLabel() {
36
20
  return 'Enter Dropbox share link';
37
21
  },
38
22
  }))
39
23
  .actions(self => ({
40
- /**
41
- * #method
42
- */
43
24
  getFetcher(location) {
44
25
  return async (input, init) => {
45
26
  const authToken = await self.getToken(location);
@@ -52,9 +33,6 @@ const stateModelFactory = (configSchema) => {
52
33
  return response;
53
34
  };
54
35
  },
55
- /**
56
- * #action
57
- */
58
36
  async validateToken(token, location) {
59
37
  const response = await fetch('https://api.dropboxapi.com/2/sharing/get_shared_link_metadata', {
60
38
  method: 'POST',
@@ -1,8 +1,4 @@
1
1
  import { getResponseError } from '../util';
2
- /**
3
- * Error messages from
4
- * https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file
5
- * */
6
2
  const dropboxErrorMessages = {
7
3
  shared_link_not_found: "The shared link wasn't found.",
8
4
  shared_link_access_denied: 'The caller is not allowed to access this shared link.',
@@ -17,7 +13,6 @@ export async function getDescriptiveErrorMessage(response, reason) {
17
13
  errorMessage = dropboxErrorMessages[tag] || tag;
18
14
  }
19
15
  catch (error) {
20
- /* do nothing */
21
16
  }
22
17
  return getResponseError({ response, reason, statusText: errorMessage });
23
18
  }
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
1
  export declare const ExternalTokenEntryForm: ({ internetAccountId, handleClose, }: {
3
2
  internetAccountId: string;
4
3
  handleClose: (token?: string) => void;
5
- }) => React.JSX.Element;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -1,22 +1,20 @@
1
- import React, { useState } from 'react';
2
- import { Button, DialogContent, DialogActions, TextField } from '@mui/material';
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
3
  import { Dialog } from '@jbrowse/core/ui';
4
+ import { Button, DialogActions, DialogContent, TextField } from '@mui/material';
4
5
  export const ExternalTokenEntryForm = ({ internetAccountId, handleClose, }) => {
5
6
  const [token, setToken] = useState('');
6
- return (React.createElement(Dialog, { open: true, maxWidth: "xl", "data-testid": "externalToken-form", title: `Enter token for ${internetAccountId}` },
7
- React.createElement(DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
8
- React.createElement(TextField, { required: true, label: "Enter Token", variant: "outlined", onChange: event => {
9
- setToken(event.target.value);
10
- }, margin: "dense", slotProps: {
11
- htmlInput: { 'data-testid': 'entry-externalToken' },
12
- } })),
13
- React.createElement(DialogActions, null,
14
- React.createElement(Button, { variant: "contained", color: "primary", type: "submit", disabled: !token, onClick: () => {
15
- if (token) {
16
- handleClose(token);
17
- }
18
- } }, "Add"),
19
- React.createElement(Button, { variant: "contained", color: "secondary", onClick: () => {
20
- handleClose();
21
- } }, "Cancel"))));
7
+ return (_jsxs(Dialog, { open: true, maxWidth: "xl", "data-testid": "externalToken-form", onClose: () => {
8
+ handleClose();
9
+ }, title: `Enter token for ${internetAccountId}`, children: [_jsx(DialogContent, { style: { display: 'flex', flexDirection: 'column' }, children: _jsx(TextField, { required: true, label: "Enter Token", variant: "outlined", onChange: event => {
10
+ setToken(event.target.value);
11
+ }, margin: "dense", slotProps: {
12
+ htmlInput: { 'data-testid': 'entry-externalToken' },
13
+ } }) }), _jsxs(DialogActions, { children: [_jsx(Button, { variant: "contained", color: "primary", type: "submit", disabled: !token, onClick: () => {
14
+ if (token) {
15
+ handleClose(token);
16
+ }
17
+ }, children: "Add" }), _jsx(Button, { variant: "contained", color: "secondary", onClick: () => {
18
+ handleClose();
19
+ }, children: "Cancel" })] })] }));
22
20
  };
@@ -1,8 +1,5 @@
1
- import { Instance } from 'mobx-state-tree';
1
+ import type { Instance } from 'mobx-state-tree';
2
2
  declare const ExternalTokenConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
3
- /**
4
- * #slot
5
- */
6
3
  validateWithHEAD: {
7
4
  description: string;
8
5
  type: string;
@@ -1,22 +1,13 @@
1
1
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
2
  import { BaseInternetAccountConfig } from '@jbrowse/core/pluggableElementTypes/models';
3
- /**
4
- * #config ExternalTokenInternetAccount
5
- */
6
- function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
3
+ function x() { }
7
4
  const ExternalTokenConfigSchema = ConfigurationSchema('ExternalTokenInternetAccount', {
8
- /**
9
- * #slot
10
- */
11
5
  validateWithHEAD: {
12
6
  description: 'validate the token with a HEAD request before using it',
13
7
  type: 'boolean',
14
8
  defaultValue: true,
15
9
  },
16
10
  }, {
17
- /**
18
- * #baseConfiguration
19
- */
20
11
  baseConfiguration: BaseInternetAccountConfig,
21
12
  explicitlyTyped: true,
22
13
  });