@jbrowse/plugin-authentication 2.5.0 → 2.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DropboxOAuthModel/configSchema.d.ts +3 -14
- package/dist/DropboxOAuthModel/configSchema.js +0 -9
- package/dist/DropboxOAuthModel/index.js +0 -1
- package/dist/DropboxOAuthModel/model.d.ts +35 -33
- package/dist/DropboxOAuthModel/model.js +26 -36
- package/dist/DropboxOAuthModel/util.d.ts +1 -0
- package/dist/DropboxOAuthModel/util.js +27 -0
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.d.ts +2 -1
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.js +10 -12
- package/dist/ExternalTokenModel/configSchema.js +0 -1
- package/dist/ExternalTokenModel/index.js +0 -1
- package/dist/ExternalTokenModel/model.js +0 -1
- package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +15 -0
- package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +19 -0
- package/dist/GoogleDriveOAuthModel/configSchema.d.ts +0 -5
- package/dist/GoogleDriveOAuthModel/configSchema.js +0 -1
- package/dist/GoogleDriveOAuthModel/index.js +0 -1
- package/dist/GoogleDriveOAuthModel/model.d.ts +36 -121
- package/dist/GoogleDriveOAuthModel/model.js +38 -52
- package/dist/GoogleDriveOAuthModel/util.d.ts +1 -0
- package/dist/GoogleDriveOAuthModel/util.js +16 -0
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.d.ts +2 -1
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.js +17 -22
- package/dist/HTTPBasicModel/configSchema.js +0 -1
- package/dist/HTTPBasicModel/index.js +0 -1
- package/dist/HTTPBasicModel/model.d.ts +36 -4
- package/dist/HTTPBasicModel/model.js +24 -10
- package/dist/OAuthModel/configSchema.d.ts +0 -8
- package/dist/OAuthModel/configSchema.js +1 -10
- package/dist/OAuthModel/index.js +0 -1
- package/dist/OAuthModel/model.d.ts +103 -18
- package/dist/OAuthModel/model.js +165 -114
- package/dist/OAuthModel/util.d.ts +7 -0
- package/dist/OAuthModel/util.js +59 -0
- package/dist/index.d.ts +7 -433
- package/dist/index.js +0 -1
- package/dist/util.d.ts +6 -0
- package/dist/util.js +22 -0
- package/esm/DropboxOAuthModel/configSchema.d.ts +3 -14
- package/esm/DropboxOAuthModel/configSchema.js +0 -9
- package/esm/DropboxOAuthModel/index.js +0 -1
- package/esm/DropboxOAuthModel/model.d.ts +35 -33
- package/esm/DropboxOAuthModel/model.js +26 -36
- package/esm/DropboxOAuthModel/util.d.ts +1 -0
- package/esm/DropboxOAuthModel/util.js +23 -0
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.d.ts +2 -1
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.js +10 -12
- package/esm/ExternalTokenModel/configSchema.js +0 -1
- package/esm/ExternalTokenModel/index.js +0 -1
- package/esm/ExternalTokenModel/model.js +0 -1
- package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +15 -0
- package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +15 -0
- package/esm/GoogleDriveOAuthModel/configSchema.d.ts +0 -5
- package/esm/GoogleDriveOAuthModel/configSchema.js +0 -1
- package/esm/GoogleDriveOAuthModel/index.js +0 -1
- package/esm/GoogleDriveOAuthModel/model.d.ts +36 -121
- package/esm/GoogleDriveOAuthModel/model.js +37 -50
- package/esm/GoogleDriveOAuthModel/util.d.ts +1 -0
- package/esm/GoogleDriveOAuthModel/util.js +12 -0
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.d.ts +2 -1
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.js +18 -23
- package/esm/HTTPBasicModel/configSchema.js +0 -1
- package/esm/HTTPBasicModel/index.js +0 -1
- package/esm/HTTPBasicModel/model.d.ts +36 -4
- package/esm/HTTPBasicModel/model.js +24 -10
- package/esm/OAuthModel/configSchema.d.ts +0 -8
- package/esm/OAuthModel/configSchema.js +1 -10
- package/esm/OAuthModel/index.js +0 -1
- package/esm/OAuthModel/model.d.ts +103 -18
- package/esm/OAuthModel/model.js +164 -87
- package/esm/OAuthModel/util.d.ts +7 -0
- package/esm/OAuthModel/util.js +29 -0
- package/esm/index.d.ts +7 -433
- package/esm/index.js +0 -1
- package/esm/util.d.ts +6 -0
- package/esm/util.js +17 -0
- package/package.json +4 -6
- package/dist/DropboxOAuthModel/configSchema.js.map +0 -1
- package/dist/DropboxOAuthModel/index.js.map +0 -1
- package/dist/DropboxOAuthModel/model.js.map +0 -1
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.js.map +0 -1
- package/dist/ExternalTokenModel/configSchema.js.map +0 -1
- package/dist/ExternalTokenModel/index.js.map +0 -1
- package/dist/ExternalTokenModel/model.js.map +0 -1
- package/dist/GoogleDriveOAuthModel/configSchema.js.map +0 -1
- package/dist/GoogleDriveOAuthModel/index.js.map +0 -1
- package/dist/GoogleDriveOAuthModel/model.js.map +0 -1
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.js.map +0 -1
- package/dist/HTTPBasicModel/configSchema.js.map +0 -1
- package/dist/HTTPBasicModel/index.js.map +0 -1
- package/dist/HTTPBasicModel/model.js.map +0 -1
- package/dist/OAuthModel/configSchema.js.map +0 -1
- package/dist/OAuthModel/index.js.map +0 -1
- package/dist/OAuthModel/model.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/esm/DropboxOAuthModel/configSchema.js.map +0 -1
- package/esm/DropboxOAuthModel/index.js.map +0 -1
- package/esm/DropboxOAuthModel/model.js.map +0 -1
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.js.map +0 -1
- package/esm/ExternalTokenModel/configSchema.js.map +0 -1
- package/esm/ExternalTokenModel/index.js.map +0 -1
- package/esm/ExternalTokenModel/model.js.map +0 -1
- package/esm/GoogleDriveOAuthModel/configSchema.js.map +0 -1
- package/esm/GoogleDriveOAuthModel/index.js.map +0 -1
- package/esm/GoogleDriveOAuthModel/model.js.map +0 -1
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.js.map +0 -1
- package/esm/HTTPBasicModel/configSchema.js.map +0 -1
- package/esm/HTTPBasicModel/index.js.map +0 -1
- package/esm/HTTPBasicModel/model.js.map +0 -1
- package/esm/OAuthModel/configSchema.js.map +0 -1
- package/esm/OAuthModel/index.js.map +0 -1
- package/esm/OAuthModel/model.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/src/DropboxOAuthModel/configSchema.ts +0 -77
- package/src/DropboxOAuthModel/index.ts +0 -2
- package/src/DropboxOAuthModel/model.tsx +0 -141
- package/src/ExternalTokenModel/ExternalTokenEntryForm.tsx +0 -57
- package/src/ExternalTokenModel/configSchema.ts +0 -36
- package/src/ExternalTokenModel/index.ts +0 -2
- package/src/ExternalTokenModel/model.tsx +0 -70
- package/src/GoogleDriveOAuthModel/configSchema.ts +0 -61
- package/src/GoogleDriveOAuthModel/index.ts +0 -2
- package/src/GoogleDriveOAuthModel/model.tsx +0 -174
- package/src/HTTPBasicModel/HTTPBasicLoginForm.tsx +0 -71
- package/src/HTTPBasicModel/configSchema.ts +0 -43
- package/src/HTTPBasicModel/index.ts +0 -2
- package/src/HTTPBasicModel/model.tsx +0 -70
- package/src/OAuthModel/configSchema.ts +0 -98
- package/src/OAuthModel/index.ts +0 -2
- package/src/OAuthModel/model.tsx +0 -348
- package/src/__snapshots__/index.test.js.snap +0 -8
- package/src/index.test.js +0 -96
- package/src/index.ts +0 -108
|
@@ -32,14 +32,6 @@ declare const DropboxOAuthConfigSchema: import("@jbrowse/core/configuration/conf
|
|
|
32
32
|
type: string;
|
|
33
33
|
defaultValue: string[];
|
|
34
34
|
};
|
|
35
|
-
/**
|
|
36
|
-
* #slot
|
|
37
|
-
*/
|
|
38
|
-
hasRefreshToken: {
|
|
39
|
-
description: string;
|
|
40
|
-
type: string;
|
|
41
|
-
defaultValue: boolean;
|
|
42
|
-
};
|
|
43
35
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
44
36
|
tokenType: {
|
|
45
37
|
description: string;
|
|
@@ -68,7 +60,9 @@ declare const DropboxOAuthConfigSchema: import("@jbrowse/core/configuration/conf
|
|
|
68
60
|
};
|
|
69
61
|
scopes: {
|
|
70
62
|
description: string;
|
|
71
|
-
type: string;
|
|
63
|
+
type: string; /**
|
|
64
|
+
* #baseConfiguration
|
|
65
|
+
*/
|
|
72
66
|
defaultValue: string;
|
|
73
67
|
};
|
|
74
68
|
state: {
|
|
@@ -81,11 +75,6 @@ declare const DropboxOAuthConfigSchema: import("@jbrowse/core/configuration/conf
|
|
|
81
75
|
type: string;
|
|
82
76
|
defaultValue: string;
|
|
83
77
|
};
|
|
84
|
-
hasRefreshToken: {
|
|
85
|
-
description: string;
|
|
86
|
-
type: string;
|
|
87
|
-
defaultValue: boolean;
|
|
88
|
-
};
|
|
89
78
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
90
79
|
name: {
|
|
91
80
|
description: string;
|
|
@@ -45,14 +45,6 @@ const DropboxOAuthConfigSchema = ConfigurationSchema('DropboxOAuthInternetAccoun
|
|
|
45
45
|
'getdropbox.com',
|
|
46
46
|
],
|
|
47
47
|
},
|
|
48
|
-
/**
|
|
49
|
-
* #slot
|
|
50
|
-
*/
|
|
51
|
-
hasRefreshToken: {
|
|
52
|
-
description: 'true if the endpoint can supply a refresh token',
|
|
53
|
-
type: 'boolean',
|
|
54
|
-
defaultValue: true,
|
|
55
|
-
},
|
|
56
48
|
}, {
|
|
57
49
|
/**
|
|
58
50
|
* #baseConfiguration
|
|
@@ -61,4 +53,3 @@ const DropboxOAuthConfigSchema = ConfigurationSchema('DropboxOAuthInternetAccoun
|
|
|
61
53
|
explicitlyTyped: true,
|
|
62
54
|
});
|
|
63
55
|
export default DropboxOAuthConfigSchema;
|
|
64
|
-
//# sourceMappingURL=configSchema.js.map
|
|
@@ -2,7 +2,10 @@ import React from 'react';
|
|
|
2
2
|
import { UriLocation } from '@jbrowse/core/util/types';
|
|
3
3
|
import { SvgIconProps } from '@mui/material';
|
|
4
4
|
import { Instance } from 'mobx-state-tree';
|
|
5
|
-
export declare function DropboxIcon(props: SvgIconProps): JSX.Element;
|
|
5
|
+
export declare function DropboxIcon(props: SvgIconProps): React.JSX.Element;
|
|
6
|
+
/**
|
|
7
|
+
* #stateModel DropboxOAuthInternetAccount
|
|
8
|
+
*/
|
|
6
9
|
declare const stateModelFactory: (configSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
7
10
|
authEndpoint: {
|
|
8
11
|
description: string;
|
|
@@ -24,11 +27,6 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
24
27
|
type: string;
|
|
25
28
|
defaultValue: string[];
|
|
26
29
|
};
|
|
27
|
-
hasRefreshToken: {
|
|
28
|
-
description: string;
|
|
29
|
-
type: string;
|
|
30
|
-
defaultValue: boolean;
|
|
31
|
-
};
|
|
32
30
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
33
31
|
tokenType: {
|
|
34
32
|
description: string;
|
|
@@ -70,11 +68,6 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
70
68
|
type: string;
|
|
71
69
|
defaultValue: string;
|
|
72
70
|
};
|
|
73
|
-
hasRefreshToken: {
|
|
74
|
-
description: string;
|
|
75
|
-
type: string;
|
|
76
|
-
defaultValue: boolean;
|
|
77
|
-
};
|
|
78
71
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
79
72
|
name: {
|
|
80
73
|
description: string;
|
|
@@ -90,7 +83,7 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
90
83
|
description: string;
|
|
91
84
|
type: string;
|
|
92
85
|
defaultValue: string;
|
|
93
|
-
};
|
|
86
|
+
};
|
|
94
87
|
tokenType: {
|
|
95
88
|
description: string;
|
|
96
89
|
type: string;
|
|
@@ -121,7 +114,9 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
121
114
|
defaultValue: string;
|
|
122
115
|
};
|
|
123
116
|
tokenType: {
|
|
124
|
-
description: string;
|
|
117
|
+
description: string; /**
|
|
118
|
+
* #property
|
|
119
|
+
*/
|
|
125
120
|
type: string;
|
|
126
121
|
defaultValue: string;
|
|
127
122
|
};
|
|
@@ -174,11 +169,6 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
174
169
|
type: string;
|
|
175
170
|
defaultValue: string;
|
|
176
171
|
};
|
|
177
|
-
hasRefreshToken: {
|
|
178
|
-
description: string;
|
|
179
|
-
type: string;
|
|
180
|
-
defaultValue: boolean;
|
|
181
|
-
};
|
|
182
172
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
183
173
|
name: {
|
|
184
174
|
description: string;
|
|
@@ -194,7 +184,7 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
194
184
|
description: string;
|
|
195
185
|
type: string;
|
|
196
186
|
defaultValue: string;
|
|
197
|
-
};
|
|
187
|
+
};
|
|
198
188
|
tokenType: {
|
|
199
189
|
description: string;
|
|
200
190
|
type: string;
|
|
@@ -207,7 +197,13 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
207
197
|
};
|
|
208
198
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
|
|
209
199
|
} & {
|
|
200
|
+
/**
|
|
201
|
+
* #property
|
|
202
|
+
*/
|
|
210
203
|
type: import("mobx-state-tree").ISimpleType<"DropboxOAuthInternetAccount">;
|
|
204
|
+
/**
|
|
205
|
+
* #property
|
|
206
|
+
*/
|
|
211
207
|
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
212
208
|
authEndpoint: {
|
|
213
209
|
description: string;
|
|
@@ -229,11 +225,6 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
229
225
|
type: string;
|
|
230
226
|
defaultValue: string[];
|
|
231
227
|
};
|
|
232
|
-
hasRefreshToken: {
|
|
233
|
-
description: string;
|
|
234
|
-
type: string;
|
|
235
|
-
defaultValue: boolean;
|
|
236
|
-
};
|
|
237
228
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
238
229
|
tokenType: {
|
|
239
230
|
description: string;
|
|
@@ -275,11 +266,6 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
275
266
|
type: string;
|
|
276
267
|
defaultValue: string;
|
|
277
268
|
};
|
|
278
|
-
hasRefreshToken: {
|
|
279
|
-
description: string;
|
|
280
|
-
type: string;
|
|
281
|
-
defaultValue: boolean;
|
|
282
|
-
};
|
|
283
269
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
284
270
|
name: {
|
|
285
271
|
description: string;
|
|
@@ -295,7 +281,7 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
295
281
|
description: string;
|
|
296
282
|
type: string;
|
|
297
283
|
defaultValue: string;
|
|
298
|
-
};
|
|
284
|
+
};
|
|
299
285
|
tokenType: {
|
|
300
286
|
description: string;
|
|
301
287
|
type: string;
|
|
@@ -308,7 +294,9 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
308
294
|
};
|
|
309
295
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>, undefined>>;
|
|
310
296
|
}, {
|
|
311
|
-
readonly name: string;
|
|
297
|
+
readonly name: string; /**
|
|
298
|
+
* #getter
|
|
299
|
+
*/
|
|
312
300
|
readonly description: string;
|
|
313
301
|
readonly internetAccountId: string;
|
|
314
302
|
readonly authHeader: string;
|
|
@@ -365,7 +353,6 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
365
353
|
readonly scopes: string;
|
|
366
354
|
state(): string | undefined;
|
|
367
355
|
readonly responseType: "code" | "token";
|
|
368
|
-
readonly hasRefreshToken: boolean;
|
|
369
356
|
readonly refreshTokenKey: string;
|
|
370
357
|
} & {
|
|
371
358
|
storeRefreshToken(refreshToken: string): void;
|
|
@@ -381,10 +368,25 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
381
368
|
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
382
369
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
383
370
|
} & {
|
|
384
|
-
|
|
371
|
+
getFetcher(loc?: UriLocation | undefined): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
372
|
+
} & {
|
|
373
|
+
/**
|
|
374
|
+
* #getter
|
|
375
|
+
* The FileSelector icon for Dropbox
|
|
376
|
+
*/
|
|
377
|
+
readonly toggleContents: React.JSX.Element;
|
|
378
|
+
/**
|
|
379
|
+
* #getter
|
|
380
|
+
*/
|
|
385
381
|
readonly selectorLabel: string;
|
|
386
382
|
} & {
|
|
383
|
+
/**
|
|
384
|
+
* #method
|
|
385
|
+
*/
|
|
387
386
|
getFetcher(location?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
387
|
+
/**
|
|
388
|
+
* #action
|
|
389
|
+
*/
|
|
388
390
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
389
391
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
390
392
|
export default stateModelFactory;
|
|
@@ -4,56 +4,46 @@ import { SvgIcon } from '@mui/material';
|
|
|
4
4
|
import { types } from 'mobx-state-tree';
|
|
5
5
|
import baseModel from '../OAuthModel/model';
|
|
6
6
|
import { configSchema as OAuthConfigSchema } from '../OAuthModel';
|
|
7
|
-
|
|
8
|
-
const dropboxErrorMessages = {
|
|
9
|
-
shared_link_not_found: "The shared link wasn't found.",
|
|
10
|
-
shared_link_access_denied: 'The caller is not allowed to access this shared link.',
|
|
11
|
-
unsupported_link_type: 'This type of link is not supported; use files/export instead.',
|
|
12
|
-
shared_link_is_directory: 'Directories cannot be retrieved by this endpoint.',
|
|
13
|
-
};
|
|
7
|
+
import { getDescriptiveErrorMessage } from './util';
|
|
14
8
|
export function DropboxIcon(props) {
|
|
15
9
|
return (React.createElement(SvgIcon, { ...props },
|
|
16
10
|
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" })));
|
|
17
11
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
errorMessage = await response.text();
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
errorMessage = '';
|
|
25
|
-
}
|
|
26
|
-
if (errorMessage) {
|
|
27
|
-
let errorMessageParsed;
|
|
28
|
-
try {
|
|
29
|
-
errorMessageParsed = JSON.parse(errorMessage);
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
errorMessageParsed = undefined;
|
|
33
|
-
}
|
|
34
|
-
if (errorMessageParsed) {
|
|
35
|
-
const messageTag = errorMessageParsed.error['.tag'];
|
|
36
|
-
errorMessage = dropboxErrorMessages[messageTag] || messageTag;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return `Network response failure — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`;
|
|
40
|
-
}
|
|
12
|
+
/**
|
|
13
|
+
* #stateModel DropboxOAuthInternetAccount
|
|
14
|
+
*/
|
|
41
15
|
const stateModelFactory = (configSchema) => {
|
|
42
16
|
return baseModel(OAuthConfigSchema)
|
|
43
17
|
.named('DropboxOAuthInternetAccount')
|
|
44
18
|
.props({
|
|
19
|
+
/**
|
|
20
|
+
* #property
|
|
21
|
+
*/
|
|
45
22
|
type: types.literal('DropboxOAuthInternetAccount'),
|
|
23
|
+
/**
|
|
24
|
+
* #property
|
|
25
|
+
*/
|
|
46
26
|
configuration: ConfigurationReference(configSchema),
|
|
47
27
|
})
|
|
48
28
|
.views(() => ({
|
|
29
|
+
/**
|
|
30
|
+
* #getter
|
|
31
|
+
* The FileSelector icon for Dropbox
|
|
32
|
+
*/
|
|
49
33
|
get toggleContents() {
|
|
50
34
|
return React.createElement(DropboxIcon, null);
|
|
51
35
|
},
|
|
36
|
+
/**
|
|
37
|
+
* #getter
|
|
38
|
+
*/
|
|
52
39
|
get selectorLabel() {
|
|
53
40
|
return 'Enter Dropbox share link';
|
|
54
41
|
},
|
|
55
42
|
}))
|
|
56
43
|
.actions(self => ({
|
|
44
|
+
/**
|
|
45
|
+
* #method
|
|
46
|
+
*/
|
|
57
47
|
getFetcher(location) {
|
|
58
48
|
return async (input, init) => {
|
|
59
49
|
const authToken = await self.getToken(location);
|
|
@@ -61,12 +51,14 @@ const stateModelFactory = (configSchema) => {
|
|
|
61
51
|
newInit.headers.append('Dropbox-API-Arg', JSON.stringify({ url: input }));
|
|
62
52
|
const response = await fetch('https://content.dropboxapi.com/2/sharing/get_shared_link_file', newInit);
|
|
63
53
|
if (!response.ok) {
|
|
64
|
-
|
|
65
|
-
throw new Error(message);
|
|
54
|
+
throw new Error(await getDescriptiveErrorMessage(response));
|
|
66
55
|
}
|
|
67
56
|
return response;
|
|
68
57
|
};
|
|
69
58
|
},
|
|
59
|
+
/**
|
|
60
|
+
* #action
|
|
61
|
+
*/
|
|
70
62
|
async validateToken(token, location) {
|
|
71
63
|
const response = await fetch('https://api.dropboxapi.com/2/sharing/get_shared_link_metadata', {
|
|
72
64
|
method: 'POST',
|
|
@@ -79,18 +71,16 @@ const stateModelFactory = (configSchema) => {
|
|
|
79
71
|
}),
|
|
80
72
|
});
|
|
81
73
|
if (!response.ok) {
|
|
82
|
-
const refreshToken = self.
|
|
74
|
+
const refreshToken = self.retrieveRefreshToken();
|
|
83
75
|
if (refreshToken) {
|
|
84
76
|
self.removeRefreshToken();
|
|
85
77
|
const newToken = await self.exchangeRefreshForAccessToken(refreshToken);
|
|
86
78
|
return this.validateToken(newToken, location);
|
|
87
79
|
}
|
|
88
|
-
|
|
89
|
-
throw new Error(`Token could not be validated. ${message}`);
|
|
80
|
+
throw new Error(await getDescriptiveErrorMessage(response, 'Token could not be validated'));
|
|
90
81
|
}
|
|
91
82
|
return token;
|
|
92
83
|
},
|
|
93
84
|
}));
|
|
94
85
|
};
|
|
95
86
|
export default stateModelFactory;
|
|
96
|
-
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDescriptiveErrorMessage(response: Response, reason?: string): Promise<string>;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
const dropboxErrorMessages = {
|
|
7
|
+
shared_link_not_found: "The shared link wasn't found.",
|
|
8
|
+
shared_link_access_denied: 'The caller is not allowed to access this shared link.',
|
|
9
|
+
unsupported_link_type: 'This type of link is not supported; use files/export instead.',
|
|
10
|
+
shared_link_is_directory: 'Directories cannot be retrieved by this endpoint.',
|
|
11
|
+
};
|
|
12
|
+
export async function getDescriptiveErrorMessage(response, reason) {
|
|
13
|
+
let errorMessage = '';
|
|
14
|
+
try {
|
|
15
|
+
const err = JSON.parse(await response.text());
|
|
16
|
+
const tag = err.error['.tag'];
|
|
17
|
+
errorMessage = dropboxErrorMessages[tag] || tag;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
/* do nothing */
|
|
21
|
+
}
|
|
22
|
+
return getResponseError({ response, reason, statusText: errorMessage });
|
|
23
|
+
}
|
|
@@ -3,16 +3,14 @@ import { Button, DialogContent, DialogActions, TextField } from '@mui/material';
|
|
|
3
3
|
import { Dialog } from '@jbrowse/core/ui';
|
|
4
4
|
export const ExternalTokenEntryForm = ({ internetAccountId, handleClose, }) => {
|
|
5
5
|
const [token, setToken] = useState('');
|
|
6
|
-
return (React.createElement(
|
|
7
|
-
React.createElement(
|
|
8
|
-
React.createElement(
|
|
9
|
-
|
|
10
|
-
React.createElement(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
React.createElement(Button, { variant: "contained", color: "primary", onClick: () => handleClose() }, "Cancel")))));
|
|
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", inputProps: { 'data-testid': 'entry-externalToken' }, onChange: event => setToken(event.target.value), margin: "dense" })),
|
|
9
|
+
React.createElement(DialogActions, null,
|
|
10
|
+
React.createElement(Button, { variant: "contained", color: "primary", type: "submit", disabled: !token, onClick: () => {
|
|
11
|
+
if (token) {
|
|
12
|
+
handleClose(token);
|
|
13
|
+
}
|
|
14
|
+
} }, "Add"),
|
|
15
|
+
React.createElement(Button, { variant: "contained", color: "secondary", onClick: () => handleClose() }, "Cancel"))));
|
|
17
16
|
};
|
|
18
|
-
//# sourceMappingURL=ExternalTokenEntryForm.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RemoteFileWithRangeCache } from '@jbrowse/core/util/io';
|
|
2
|
+
import { FilehandleOptions, Stats, PolyfilledResponse } from 'generic-filehandle';
|
|
3
|
+
export interface RequestInitWithMetadata extends RequestInit {
|
|
4
|
+
metadataOnly?: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface GoogleDriveFilehandleOptions extends FilehandleOptions {
|
|
7
|
+
fetch(input: RequestInfo, opts?: RequestInitWithMetadata): Promise<PolyfilledResponse>;
|
|
8
|
+
}
|
|
9
|
+
export declare class GoogleDriveFile extends RemoteFileWithRangeCache {
|
|
10
|
+
private statsPromise;
|
|
11
|
+
constructor(source: string, opts: GoogleDriveFilehandleOptions);
|
|
12
|
+
fetch(input: RequestInfo, opts?: RequestInitWithMetadata): Promise<PolyfilledResponse>;
|
|
13
|
+
stat(): Promise<Stats>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { RemoteFileWithRangeCache } from '@jbrowse/core/util/io';
|
|
2
|
+
export class GoogleDriveFile extends RemoteFileWithRangeCache {
|
|
3
|
+
constructor(source, opts) {
|
|
4
|
+
super(source, opts);
|
|
5
|
+
this.statsPromise = this.fetch(source, {
|
|
6
|
+
metadataOnly: true,
|
|
7
|
+
}).then((response) => response.json());
|
|
8
|
+
}
|
|
9
|
+
async fetch(input, opts) {
|
|
10
|
+
return super.fetch(input, opts);
|
|
11
|
+
}
|
|
12
|
+
async stat() {
|
|
13
|
+
return this.statsPromise;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -75,11 +75,6 @@ declare const GoogleDriveOAuthConfigSchema: import("@jbrowse/core/configuration/
|
|
|
75
75
|
type: string;
|
|
76
76
|
defaultValue: string;
|
|
77
77
|
};
|
|
78
|
-
hasRefreshToken: {
|
|
79
|
-
description: string;
|
|
80
|
-
type: string;
|
|
81
|
-
defaultValue: boolean;
|
|
82
|
-
};
|
|
83
78
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
84
79
|
name: {
|
|
85
80
|
description: string;
|