@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
|
@@ -1,114 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Instance } from 'mobx-state-tree';
|
|
3
|
-
import { RemoteFileWithRangeCache } from '@jbrowse/core/util/io';
|
|
4
3
|
import { UriLocation } from '@jbrowse/core/util/types';
|
|
5
|
-
import {
|
|
4
|
+
import { GoogleDriveOAuthInternetAccountConfigModel } from './configSchema';
|
|
5
|
+
import { GoogleDriveFile } from './GoogleDriveFilehandle';
|
|
6
6
|
export interface RequestInitWithMetadata extends RequestInit {
|
|
7
7
|
metadataOnly?: boolean;
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export
|
|
13
|
-
private statsPromise;
|
|
14
|
-
constructor(source: string, opts: GoogleDriveFilehandleOptions);
|
|
15
|
-
fetch(input: RequestInfo, opts?: RequestInitWithMetadata): Promise<PolyfilledResponse>;
|
|
16
|
-
stat(): Promise<Stats>;
|
|
17
|
-
}
|
|
18
|
-
declare const stateModelFactory: (configSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
19
|
-
authEndpoint: {
|
|
20
|
-
description: string;
|
|
21
|
-
type: string;
|
|
22
|
-
defaultValue: string;
|
|
23
|
-
};
|
|
24
|
-
scopes: {
|
|
25
|
-
description: string;
|
|
26
|
-
type: string;
|
|
27
|
-
defaultValue: string;
|
|
28
|
-
};
|
|
29
|
-
domains: {
|
|
30
|
-
description: string;
|
|
31
|
-
type: string;
|
|
32
|
-
defaultValue: string[];
|
|
33
|
-
};
|
|
34
|
-
responseType: {
|
|
35
|
-
description: string;
|
|
36
|
-
type: string;
|
|
37
|
-
defaultValue: string;
|
|
38
|
-
};
|
|
39
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
40
|
-
tokenType: {
|
|
41
|
-
description: string;
|
|
42
|
-
type: string;
|
|
43
|
-
defaultValue: string;
|
|
44
|
-
};
|
|
45
|
-
authEndpoint: {
|
|
46
|
-
description: string;
|
|
47
|
-
type: string;
|
|
48
|
-
defaultValue: string;
|
|
49
|
-
};
|
|
50
|
-
tokenEndpoint: {
|
|
51
|
-
description: string;
|
|
52
|
-
type: string;
|
|
53
|
-
defaultValue: string;
|
|
54
|
-
};
|
|
55
|
-
needsPKCE: {
|
|
56
|
-
description: string;
|
|
57
|
-
type: string;
|
|
58
|
-
defaultValue: boolean;
|
|
59
|
-
};
|
|
60
|
-
clientId: {
|
|
61
|
-
description: string;
|
|
62
|
-
type: string;
|
|
63
|
-
defaultValue: string;
|
|
64
|
-
};
|
|
65
|
-
scopes: {
|
|
66
|
-
description: string;
|
|
67
|
-
type: string;
|
|
68
|
-
defaultValue: string;
|
|
69
|
-
};
|
|
70
|
-
state: {
|
|
71
|
-
description: string;
|
|
72
|
-
type: string;
|
|
73
|
-
defaultValue: string;
|
|
74
|
-
};
|
|
75
|
-
responseType: {
|
|
76
|
-
description: string;
|
|
77
|
-
type: string;
|
|
78
|
-
defaultValue: string;
|
|
79
|
-
};
|
|
80
|
-
hasRefreshToken: {
|
|
81
|
-
description: string;
|
|
82
|
-
type: string;
|
|
83
|
-
defaultValue: boolean;
|
|
84
|
-
};
|
|
85
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
86
|
-
name: {
|
|
87
|
-
description: string;
|
|
88
|
-
type: string;
|
|
89
|
-
defaultValue: string;
|
|
90
|
-
};
|
|
91
|
-
description: {
|
|
92
|
-
description: string;
|
|
93
|
-
type: string;
|
|
94
|
-
defaultValue: string;
|
|
95
|
-
};
|
|
96
|
-
authHeader: {
|
|
97
|
-
description: string;
|
|
98
|
-
type: string;
|
|
99
|
-
defaultValue: string;
|
|
100
|
-
};
|
|
101
|
-
tokenType: {
|
|
102
|
-
description: string;
|
|
103
|
-
type: string;
|
|
104
|
-
defaultValue: string;
|
|
105
|
-
};
|
|
106
|
-
domains: {
|
|
107
|
-
description: string;
|
|
108
|
-
type: string;
|
|
109
|
-
defaultValue: never[];
|
|
110
|
-
};
|
|
111
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>, undefined>>) => import("mobx-state-tree").IModelType<{
|
|
9
|
+
/**
|
|
10
|
+
* #stateModel GoogleDriveOAuthInternetAccount
|
|
11
|
+
*/
|
|
12
|
+
export default function stateModelFactory(configSchema: GoogleDriveOAuthInternetAccountConfigModel): import("mobx-state-tree").IModelType<{
|
|
112
13
|
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
113
14
|
type: import("mobx-state-tree").ISimpleType<string>;
|
|
114
15
|
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
@@ -181,11 +82,6 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
181
82
|
type: string;
|
|
182
83
|
defaultValue: string;
|
|
183
84
|
};
|
|
184
|
-
hasRefreshToken: {
|
|
185
|
-
description: string;
|
|
186
|
-
type: string;
|
|
187
|
-
defaultValue: boolean;
|
|
188
|
-
};
|
|
189
85
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
190
86
|
name: {
|
|
191
87
|
description: string;
|
|
@@ -214,7 +110,13 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
214
110
|
};
|
|
215
111
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
|
|
216
112
|
} & {
|
|
113
|
+
/**
|
|
114
|
+
* #property
|
|
115
|
+
*/
|
|
217
116
|
type: import("mobx-state-tree").ISimpleType<"GoogleDriveOAuthInternetAccount">;
|
|
117
|
+
/**
|
|
118
|
+
* #property
|
|
119
|
+
*/
|
|
218
120
|
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
219
121
|
authEndpoint: {
|
|
220
122
|
description: string;
|
|
@@ -277,11 +179,6 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
277
179
|
type: string;
|
|
278
180
|
defaultValue: string;
|
|
279
181
|
};
|
|
280
|
-
hasRefreshToken: {
|
|
281
|
-
description: string;
|
|
282
|
-
type: string;
|
|
283
|
-
defaultValue: boolean;
|
|
284
|
-
};
|
|
285
182
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
286
183
|
name: {
|
|
287
184
|
description: string;
|
|
@@ -356,18 +253,19 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
356
253
|
} & {
|
|
357
254
|
getFetcher(loc?: UriLocation | undefined): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
358
255
|
} & {
|
|
359
|
-
openLocation(location: UriLocation): RemoteFileWithRangeCache;
|
|
256
|
+
openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
|
|
360
257
|
} & {
|
|
361
258
|
readonly codeVerifierPKCE: string;
|
|
362
259
|
} & {
|
|
363
260
|
readonly authEndpoint: string;
|
|
364
|
-
readonly tokenEndpoint: string;
|
|
261
|
+
readonly tokenEndpoint: string; /**
|
|
262
|
+
* #method
|
|
263
|
+
*/
|
|
365
264
|
readonly needsPKCE: boolean;
|
|
366
265
|
readonly clientId: string;
|
|
367
266
|
readonly scopes: string;
|
|
368
267
|
state(): string | undefined;
|
|
369
268
|
readonly responseType: "code" | "token";
|
|
370
|
-
readonly hasRefreshToken: boolean;
|
|
371
269
|
readonly refreshTokenKey: string;
|
|
372
270
|
} & {
|
|
373
271
|
storeRefreshToken(refreshToken: string): void;
|
|
@@ -383,13 +281,30 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
383
281
|
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
384
282
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
385
283
|
} & {
|
|
386
|
-
|
|
284
|
+
getFetcher(loc?: UriLocation | undefined): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
285
|
+
} & {
|
|
286
|
+
/**
|
|
287
|
+
* #getter
|
|
288
|
+
* The FileSelector icon for Google drive
|
|
289
|
+
*/
|
|
290
|
+
readonly toggleContents: React.JSX.Element;
|
|
291
|
+
/**
|
|
292
|
+
* #getter
|
|
293
|
+
*/
|
|
387
294
|
readonly selectorLabel: string;
|
|
388
295
|
} & {
|
|
389
|
-
|
|
296
|
+
/**
|
|
297
|
+
* #method
|
|
298
|
+
*/
|
|
299
|
+
getFetcher(location?: UriLocation): (input: RequestInfo, init?: RequestInitWithMetadata) => Promise<Response>;
|
|
300
|
+
/**
|
|
301
|
+
* #method
|
|
302
|
+
*/
|
|
390
303
|
openLocation(location: UriLocation): GoogleDriveFile;
|
|
304
|
+
/**
|
|
305
|
+
* #action
|
|
306
|
+
*/
|
|
391
307
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
392
308
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
393
|
-
export default stateModelFactory;
|
|
394
309
|
export type GoogleDriveOAuthStateModel = ReturnType<typeof stateModelFactory>;
|
|
395
310
|
export type GoogleDriveOAuthModel = Instance<GoogleDriveOAuthStateModel>;
|
|
@@ -1,70 +1,57 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ConfigurationReference } from '@jbrowse/core/configuration';
|
|
3
3
|
import { types } from 'mobx-state-tree';
|
|
4
|
-
import { RemoteFileWithRangeCache } from '@jbrowse/core/util/io';
|
|
5
4
|
import { SvgIcon } from '@mui/material';
|
|
6
5
|
import baseModel from '../OAuthModel/model';
|
|
7
6
|
import { configSchema as OAuthConfigSchema } from '../OAuthModel';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
super(source, opts);
|
|
11
|
-
this.statsPromise = this.fetch(source, {
|
|
12
|
-
metadataOnly: true,
|
|
13
|
-
}).then((response) => response.json());
|
|
14
|
-
}
|
|
15
|
-
async fetch(input, opts) {
|
|
16
|
-
return super.fetch(input, opts);
|
|
17
|
-
}
|
|
18
|
-
async stat() {
|
|
19
|
-
return this.statsPromise;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
7
|
+
import { getDescriptiveErrorMessage } from './util';
|
|
8
|
+
import { GoogleDriveFile } from './GoogleDriveFilehandle';
|
|
22
9
|
function GoogleDriveIcon(props) {
|
|
23
10
|
return (React.createElement(SvgIcon, { ...props },
|
|
24
11
|
React.createElement("path", { d: "M7.71,3.5L1.15,15L4.58,21L11.13,9.5M9.73,15L6.3,21H19.42L22.85,15M22.28,14L15.42,2H8.58L8.57,2L15.43,14H22.28Z" })));
|
|
25
12
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
errorMessage = await response.text();
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
errorMessage = '';
|
|
33
|
-
}
|
|
34
|
-
if (errorMessage) {
|
|
35
|
-
let errorMessageParsed;
|
|
36
|
-
try {
|
|
37
|
-
errorMessageParsed = JSON.parse(errorMessage);
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
errorMessageParsed = undefined;
|
|
41
|
-
}
|
|
42
|
-
if (errorMessageParsed) {
|
|
43
|
-
errorMessage = errorMessageParsed.error.message;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return `Network response failure — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`;
|
|
13
|
+
function getUri(str) {
|
|
14
|
+
const urlId = str.match(/[-\w]{25,}/);
|
|
15
|
+
return `https://www.googleapis.com/drive/v3/files/${urlId}`;
|
|
47
16
|
}
|
|
48
|
-
|
|
17
|
+
/**
|
|
18
|
+
* #stateModel GoogleDriveOAuthInternetAccount
|
|
19
|
+
*/
|
|
20
|
+
export default function stateModelFactory(configSchema) {
|
|
49
21
|
return baseModel(OAuthConfigSchema)
|
|
50
22
|
.named('GoogleDriveOAuthInternetAccount')
|
|
51
23
|
.props({
|
|
24
|
+
/**
|
|
25
|
+
* #property
|
|
26
|
+
*/
|
|
52
27
|
type: types.literal('GoogleDriveOAuthInternetAccount'),
|
|
28
|
+
/**
|
|
29
|
+
* #property
|
|
30
|
+
*/
|
|
53
31
|
configuration: ConfigurationReference(configSchema),
|
|
54
32
|
})
|
|
55
33
|
.views(() => ({
|
|
34
|
+
/**
|
|
35
|
+
* #getter
|
|
36
|
+
* The FileSelector icon for Google drive
|
|
37
|
+
*/
|
|
56
38
|
get toggleContents() {
|
|
57
39
|
return React.createElement(GoogleDriveIcon, null);
|
|
58
40
|
},
|
|
41
|
+
/**
|
|
42
|
+
* #getter
|
|
43
|
+
*/
|
|
59
44
|
get selectorLabel() {
|
|
60
45
|
return 'Enter Google Drive share link';
|
|
61
46
|
},
|
|
62
47
|
}))
|
|
63
48
|
.actions(self => ({
|
|
49
|
+
/**
|
|
50
|
+
* #method
|
|
51
|
+
*/
|
|
64
52
|
getFetcher(location) {
|
|
65
53
|
return async (input, init) => {
|
|
66
|
-
const
|
|
67
|
-
const driveUrl = new URL(`https://www.googleapis.com/drive/v3/files/${urlId}`);
|
|
54
|
+
const driveUrl = new URL(getUri(String(input)));
|
|
68
55
|
const searchParams = new URLSearchParams();
|
|
69
56
|
if (init === null || init === void 0 ? void 0 : init.metadataOnly) {
|
|
70
57
|
searchParams.append('fields', 'size');
|
|
@@ -74,35 +61,35 @@ const stateModelFactory = (configSchema) => {
|
|
|
74
61
|
}
|
|
75
62
|
driveUrl.search = searchParams.toString();
|
|
76
63
|
const authToken = await self.getToken(location);
|
|
77
|
-
const
|
|
78
|
-
const response = await fetch(driveUrl.toString(), newInit);
|
|
64
|
+
const response = await fetch(driveUrl, self.addAuthHeaderToInit({ ...init, method: 'GET', credentials: 'same-origin' }, authToken));
|
|
79
65
|
if (!response.ok) {
|
|
80
|
-
|
|
81
|
-
throw new Error(message);
|
|
66
|
+
throw new Error(await getDescriptiveErrorMessage(response));
|
|
82
67
|
}
|
|
83
68
|
return response;
|
|
84
69
|
};
|
|
85
70
|
},
|
|
71
|
+
/**
|
|
72
|
+
* #method
|
|
73
|
+
*/
|
|
86
74
|
openLocation(location) {
|
|
87
75
|
return new GoogleDriveFile(location.uri, {
|
|
88
76
|
fetch: this.getFetcher(location),
|
|
89
77
|
});
|
|
90
78
|
},
|
|
79
|
+
/**
|
|
80
|
+
* #action
|
|
81
|
+
*/
|
|
91
82
|
async validateToken(token, location) {
|
|
92
|
-
const
|
|
93
|
-
const response = await fetch(`https://www.googleapis.com/drive/v3/files/${urlId}`, {
|
|
83
|
+
const response = await fetch(getUri(location.uri), {
|
|
94
84
|
headers: {
|
|
95
85
|
Authorization: `Bearer ${token}`,
|
|
96
86
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
97
87
|
},
|
|
98
88
|
});
|
|
99
89
|
if (!response.ok) {
|
|
100
|
-
|
|
101
|
-
throw new Error(`Token could not be validated. ${message}`);
|
|
90
|
+
throw new Error(await getDescriptiveErrorMessage(response, 'Token could not be validated'));
|
|
102
91
|
}
|
|
103
92
|
return token;
|
|
104
93
|
},
|
|
105
94
|
}));
|
|
106
|
-
}
|
|
107
|
-
export default stateModelFactory;
|
|
108
|
-
//# sourceMappingURL=model.js.map
|
|
95
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDescriptiveErrorMessage(response: Response, reason?: string): Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getResponseError } from '../util';
|
|
2
|
+
export async function getDescriptiveErrorMessage(response, reason) {
|
|
3
|
+
let errorMessage = '';
|
|
4
|
+
try {
|
|
5
|
+
const err = JSON.parse(await response.text());
|
|
6
|
+
errorMessage = err.error.message;
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
/* do nothing */
|
|
10
|
+
}
|
|
11
|
+
return getResponseError({ response, reason, statusText: errorMessage });
|
|
12
|
+
}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { Button,
|
|
2
|
+
import { Button, DialogContent, DialogActions, TextField } from '@mui/material';
|
|
3
|
+
import { Dialog } from '@jbrowse/core/ui';
|
|
3
4
|
export const HTTPBasicLoginForm = ({ internetAccountId, handleClose, }) => {
|
|
4
5
|
const [username, setUsername] = useState('');
|
|
5
6
|
const [password, setPassword] = useState('');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
React.createElement(
|
|
22
|
-
React.createElement(TextField, { required: true, label: "Username", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-username' }, onChange: event => setUsername(event.target.value), margin: "dense" }),
|
|
23
|
-
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" })),
|
|
24
|
-
React.createElement(DialogActions, null,
|
|
25
|
-
React.createElement(Button, { variant: "contained", color: "primary", type: "submit" }, "Submit"),
|
|
26
|
-
React.createElement(Button, { variant: "contained", type: "submit", onClick: () => handleClose() }, "Cancel"))))));
|
|
7
|
+
return (React.createElement(Dialog, { open: true, maxWidth: "xl", "data-testid": "login-httpbasic", title: `Log In for ${internetAccountId}` },
|
|
8
|
+
React.createElement("form", { onSubmit: event => {
|
|
9
|
+
if (username && password) {
|
|
10
|
+
handleClose(btoa(`${username}:${password}`));
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
handleClose();
|
|
14
|
+
}
|
|
15
|
+
event.preventDefault();
|
|
16
|
+
} },
|
|
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" })),
|
|
20
|
+
React.createElement(DialogActions, null,
|
|
21
|
+
React.createElement(Button, { variant: "contained", color: "primary", type: "submit" }, "Submit"),
|
|
22
|
+
React.createElement(Button, { variant: "contained", color: "secondary", type: "submit", onClick: () => handleClose() }, "Cancel")))));
|
|
27
23
|
};
|
|
28
|
-
//# sourceMappingURL=HTTPBasicLoginForm.js.map
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { UriLocation } from '@jbrowse/core/util/types';
|
|
3
3
|
import { Instance } from 'mobx-state-tree';
|
|
4
|
+
/**
|
|
5
|
+
* #stateModel HTTPBasicInternetAccount
|
|
6
|
+
*/
|
|
4
7
|
declare const stateModelFactory: (configSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
5
8
|
tokenType: {
|
|
6
9
|
description: string;
|
|
@@ -10,7 +13,9 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
10
13
|
validateWithHEAD: {
|
|
11
14
|
description: string;
|
|
12
15
|
type: string;
|
|
13
|
-
defaultValue: boolean;
|
|
16
|
+
defaultValue: boolean; /**
|
|
17
|
+
* #property
|
|
18
|
+
*/
|
|
14
19
|
};
|
|
15
20
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
16
21
|
name: {
|
|
@@ -36,6 +41,9 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
36
41
|
domains: {
|
|
37
42
|
description: string;
|
|
38
43
|
type: string;
|
|
44
|
+
/**
|
|
45
|
+
* #property
|
|
46
|
+
*/
|
|
39
47
|
defaultValue: never[];
|
|
40
48
|
};
|
|
41
49
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>) => import("mobx-state-tree").IModelType<{
|
|
@@ -46,12 +54,16 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
46
54
|
description: string;
|
|
47
55
|
type: string;
|
|
48
56
|
defaultValue: string;
|
|
49
|
-
};
|
|
57
|
+
}; /**
|
|
58
|
+
* #property
|
|
59
|
+
*/
|
|
50
60
|
description: {
|
|
51
61
|
description: string;
|
|
52
62
|
type: string;
|
|
53
63
|
defaultValue: string;
|
|
54
|
-
};
|
|
64
|
+
}; /**
|
|
65
|
+
* #getter
|
|
66
|
+
*/
|
|
55
67
|
authHeader: {
|
|
56
68
|
description: string;
|
|
57
69
|
type: string;
|
|
@@ -69,7 +81,13 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
69
81
|
};
|
|
70
82
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>;
|
|
71
83
|
} & {
|
|
84
|
+
/**
|
|
85
|
+
* #property
|
|
86
|
+
*/
|
|
72
87
|
type: import("mobx-state-tree").ISimpleType<"HTTPBasicInternetAccount">;
|
|
88
|
+
/**
|
|
89
|
+
* #property
|
|
90
|
+
*/
|
|
73
91
|
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
74
92
|
tokenType: {
|
|
75
93
|
description: string;
|
|
@@ -79,7 +97,9 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
79
97
|
validateWithHEAD: {
|
|
80
98
|
description: string;
|
|
81
99
|
type: string;
|
|
82
|
-
defaultValue: boolean;
|
|
100
|
+
defaultValue: boolean; /**
|
|
101
|
+
* #property
|
|
102
|
+
*/
|
|
83
103
|
};
|
|
84
104
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
85
105
|
name: {
|
|
@@ -105,6 +125,9 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
105
125
|
domains: {
|
|
106
126
|
description: string;
|
|
107
127
|
type: string;
|
|
128
|
+
/**
|
|
129
|
+
* #property
|
|
130
|
+
*/
|
|
108
131
|
defaultValue: never[];
|
|
109
132
|
};
|
|
110
133
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
|
|
@@ -157,9 +180,18 @@ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configurat
|
|
|
157
180
|
} & {
|
|
158
181
|
openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
|
|
159
182
|
} & {
|
|
183
|
+
/**
|
|
184
|
+
* #getter
|
|
185
|
+
*/
|
|
160
186
|
readonly validateWithHEAD: boolean;
|
|
161
187
|
} & {
|
|
188
|
+
/**
|
|
189
|
+
* #action
|
|
190
|
+
*/
|
|
162
191
|
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
192
|
+
/**
|
|
193
|
+
* #action
|
|
194
|
+
*/
|
|
163
195
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
164
196
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
165
197
|
export default stateModelFactory;
|
|
@@ -2,18 +2,34 @@ import { ConfigurationReference, getConf } from '@jbrowse/core/configuration';
|
|
|
2
2
|
import { InternetAccount } from '@jbrowse/core/pluggableElementTypes/models';
|
|
3
3
|
import { types, getRoot } from 'mobx-state-tree';
|
|
4
4
|
import { HTTPBasicLoginForm } from './HTTPBasicLoginForm';
|
|
5
|
+
import { getResponseError } from '../util';
|
|
6
|
+
/**
|
|
7
|
+
* #stateModel HTTPBasicInternetAccount
|
|
8
|
+
*/
|
|
5
9
|
const stateModelFactory = (configSchema) => {
|
|
6
10
|
return InternetAccount.named('HTTPBasicInternetAccount')
|
|
7
11
|
.props({
|
|
12
|
+
/**
|
|
13
|
+
* #property
|
|
14
|
+
*/
|
|
8
15
|
type: types.literal('HTTPBasicInternetAccount'),
|
|
16
|
+
/**
|
|
17
|
+
* #property
|
|
18
|
+
*/
|
|
9
19
|
configuration: ConfigurationReference(configSchema),
|
|
10
20
|
})
|
|
11
21
|
.views(self => ({
|
|
22
|
+
/**
|
|
23
|
+
* #getter
|
|
24
|
+
*/
|
|
12
25
|
get validateWithHEAD() {
|
|
13
26
|
return getConf(self, 'validateWithHEAD');
|
|
14
27
|
},
|
|
15
28
|
}))
|
|
16
29
|
.actions(self => ({
|
|
30
|
+
/**
|
|
31
|
+
* #action
|
|
32
|
+
*/
|
|
17
33
|
getTokenFromUser(resolve, reject) {
|
|
18
34
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
35
|
const { session } = getRoot(self);
|
|
@@ -26,13 +42,16 @@ const stateModelFactory = (configSchema) => {
|
|
|
26
42
|
resolve(token);
|
|
27
43
|
}
|
|
28
44
|
else {
|
|
29
|
-
reject(new Error('
|
|
45
|
+
reject(new Error('User cancelled entry'));
|
|
30
46
|
}
|
|
31
47
|
doneCallback();
|
|
32
48
|
},
|
|
33
49
|
},
|
|
34
50
|
]);
|
|
35
51
|
},
|
|
52
|
+
/**
|
|
53
|
+
* #action
|
|
54
|
+
*/
|
|
36
55
|
async validateToken(token, location) {
|
|
37
56
|
if (!self.validateWithHEAD) {
|
|
38
57
|
return token;
|
|
@@ -40,18 +59,13 @@ const stateModelFactory = (configSchema) => {
|
|
|
40
59
|
const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token);
|
|
41
60
|
const response = await fetch(location.uri, newInit);
|
|
42
61
|
if (!response.ok) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
errorMessage = '';
|
|
49
|
-
}
|
|
50
|
-
throw new Error(`Error validating token — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`);
|
|
62
|
+
throw new Error(await getResponseError({
|
|
63
|
+
response,
|
|
64
|
+
reason: 'Error validating token',
|
|
65
|
+
}));
|
|
51
66
|
}
|
|
52
67
|
return token;
|
|
53
68
|
},
|
|
54
69
|
}));
|
|
55
70
|
};
|
|
56
71
|
export default stateModelFactory;
|
|
57
|
-
//# sourceMappingURL=model.js.map
|
|
@@ -64,14 +64,6 @@ declare const OAuthConfigSchema: import("@jbrowse/core/configuration/configurati
|
|
|
64
64
|
type: string;
|
|
65
65
|
defaultValue: string;
|
|
66
66
|
};
|
|
67
|
-
/**
|
|
68
|
-
* #slot
|
|
69
|
-
*/
|
|
70
|
-
hasRefreshToken: {
|
|
71
|
-
description: string;
|
|
72
|
-
type: string;
|
|
73
|
-
defaultValue: boolean;
|
|
74
|
-
};
|
|
75
67
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
76
68
|
name: {
|
|
77
69
|
description: string;
|
|
@@ -65,18 +65,10 @@ const OAuthConfigSchema = ConfigurationSchema('OAuthInternetAccount', {
|
|
|
65
65
|
* #slot
|
|
66
66
|
*/
|
|
67
67
|
responseType: {
|
|
68
|
-
description:
|
|
68
|
+
description: "the type of response from the authorization endpoint. can be 'token' or 'code'",
|
|
69
69
|
type: 'string',
|
|
70
70
|
defaultValue: 'code',
|
|
71
71
|
},
|
|
72
|
-
/**
|
|
73
|
-
* #slot
|
|
74
|
-
*/
|
|
75
|
-
hasRefreshToken: {
|
|
76
|
-
description: 'true if the endpoint can supply a refresh token',
|
|
77
|
-
type: 'boolean',
|
|
78
|
-
defaultValue: false,
|
|
79
|
-
},
|
|
80
72
|
}, {
|
|
81
73
|
/**
|
|
82
74
|
* #baseConfiguration
|
|
@@ -85,4 +77,3 @@ const OAuthConfigSchema = ConfigurationSchema('OAuthInternetAccount', {
|
|
|
85
77
|
explicitlyTyped: true,
|
|
86
78
|
});
|
|
87
79
|
export default OAuthConfigSchema;
|
|
88
|
-
//# sourceMappingURL=configSchema.js.map
|
package/esm/OAuthModel/index.js
CHANGED