@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>;
|
|
@@ -3,75 +3,60 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GoogleDriveFile = void 0;
|
|
7
6
|
const react_1 = __importDefault(require("react"));
|
|
8
7
|
const configuration_1 = require("@jbrowse/core/configuration");
|
|
9
8
|
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
10
|
-
const io_1 = require("@jbrowse/core/util/io");
|
|
11
9
|
const material_1 = require("@mui/material");
|
|
12
10
|
const model_1 = __importDefault(require("../OAuthModel/model"));
|
|
13
11
|
const OAuthModel_1 = require("../OAuthModel");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
super(source, opts);
|
|
17
|
-
this.statsPromise = this.fetch(source, {
|
|
18
|
-
metadataOnly: true,
|
|
19
|
-
}).then((response) => response.json());
|
|
20
|
-
}
|
|
21
|
-
async fetch(input, opts) {
|
|
22
|
-
return super.fetch(input, opts);
|
|
23
|
-
}
|
|
24
|
-
async stat() {
|
|
25
|
-
return this.statsPromise;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.GoogleDriveFile = GoogleDriveFile;
|
|
12
|
+
const util_1 = require("./util");
|
|
13
|
+
const GoogleDriveFilehandle_1 = require("./GoogleDriveFilehandle");
|
|
29
14
|
function GoogleDriveIcon(props) {
|
|
30
15
|
return (react_1.default.createElement(material_1.SvgIcon, { ...props },
|
|
31
16
|
react_1.default.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" })));
|
|
32
17
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
errorMessage = await response.text();
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
errorMessage = '';
|
|
40
|
-
}
|
|
41
|
-
if (errorMessage) {
|
|
42
|
-
let errorMessageParsed;
|
|
43
|
-
try {
|
|
44
|
-
errorMessageParsed = JSON.parse(errorMessage);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
errorMessageParsed = undefined;
|
|
48
|
-
}
|
|
49
|
-
if (errorMessageParsed) {
|
|
50
|
-
errorMessage = errorMessageParsed.error.message;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return `Network response failure — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`;
|
|
18
|
+
function getUri(str) {
|
|
19
|
+
const urlId = str.match(/[-\w]{25,}/);
|
|
20
|
+
return `https://www.googleapis.com/drive/v3/files/${urlId}`;
|
|
54
21
|
}
|
|
55
|
-
|
|
22
|
+
/**
|
|
23
|
+
* #stateModel GoogleDriveOAuthInternetAccount
|
|
24
|
+
*/
|
|
25
|
+
function stateModelFactory(configSchema) {
|
|
56
26
|
return (0, model_1.default)(OAuthModel_1.configSchema)
|
|
57
27
|
.named('GoogleDriveOAuthInternetAccount')
|
|
58
28
|
.props({
|
|
29
|
+
/**
|
|
30
|
+
* #property
|
|
31
|
+
*/
|
|
59
32
|
type: mobx_state_tree_1.types.literal('GoogleDriveOAuthInternetAccount'),
|
|
33
|
+
/**
|
|
34
|
+
* #property
|
|
35
|
+
*/
|
|
60
36
|
configuration: (0, configuration_1.ConfigurationReference)(configSchema),
|
|
61
37
|
})
|
|
62
38
|
.views(() => ({
|
|
39
|
+
/**
|
|
40
|
+
* #getter
|
|
41
|
+
* The FileSelector icon for Google drive
|
|
42
|
+
*/
|
|
63
43
|
get toggleContents() {
|
|
64
44
|
return react_1.default.createElement(GoogleDriveIcon, null);
|
|
65
45
|
},
|
|
46
|
+
/**
|
|
47
|
+
* #getter
|
|
48
|
+
*/
|
|
66
49
|
get selectorLabel() {
|
|
67
50
|
return 'Enter Google Drive share link';
|
|
68
51
|
},
|
|
69
52
|
}))
|
|
70
53
|
.actions(self => ({
|
|
54
|
+
/**
|
|
55
|
+
* #method
|
|
56
|
+
*/
|
|
71
57
|
getFetcher(location) {
|
|
72
58
|
return async (input, init) => {
|
|
73
|
-
const
|
|
74
|
-
const driveUrl = new URL(`https://www.googleapis.com/drive/v3/files/${urlId}`);
|
|
59
|
+
const driveUrl = new URL(getUri(String(input)));
|
|
75
60
|
const searchParams = new URLSearchParams();
|
|
76
61
|
if (init === null || init === void 0 ? void 0 : init.metadataOnly) {
|
|
77
62
|
searchParams.append('fields', 'size');
|
|
@@ -81,35 +66,36 @@ const stateModelFactory = (configSchema) => {
|
|
|
81
66
|
}
|
|
82
67
|
driveUrl.search = searchParams.toString();
|
|
83
68
|
const authToken = await self.getToken(location);
|
|
84
|
-
const
|
|
85
|
-
const response = await fetch(driveUrl.toString(), newInit);
|
|
69
|
+
const response = await fetch(driveUrl, self.addAuthHeaderToInit({ ...init, method: 'GET', credentials: 'same-origin' }, authToken));
|
|
86
70
|
if (!response.ok) {
|
|
87
|
-
|
|
88
|
-
throw new Error(message);
|
|
71
|
+
throw new Error(await (0, util_1.getDescriptiveErrorMessage)(response));
|
|
89
72
|
}
|
|
90
73
|
return response;
|
|
91
74
|
};
|
|
92
75
|
},
|
|
76
|
+
/**
|
|
77
|
+
* #method
|
|
78
|
+
*/
|
|
93
79
|
openLocation(location) {
|
|
94
|
-
return new GoogleDriveFile(location.uri, {
|
|
80
|
+
return new GoogleDriveFilehandle_1.GoogleDriveFile(location.uri, {
|
|
95
81
|
fetch: this.getFetcher(location),
|
|
96
82
|
});
|
|
97
83
|
},
|
|
84
|
+
/**
|
|
85
|
+
* #action
|
|
86
|
+
*/
|
|
98
87
|
async validateToken(token, location) {
|
|
99
|
-
const
|
|
100
|
-
const response = await fetch(`https://www.googleapis.com/drive/v3/files/${urlId}`, {
|
|
88
|
+
const response = await fetch(getUri(location.uri), {
|
|
101
89
|
headers: {
|
|
102
90
|
Authorization: `Bearer ${token}`,
|
|
103
91
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
104
92
|
},
|
|
105
93
|
});
|
|
106
94
|
if (!response.ok) {
|
|
107
|
-
|
|
108
|
-
throw new Error(`Token could not be validated. ${message}`);
|
|
95
|
+
throw new Error(await (0, util_1.getDescriptiveErrorMessage)(response, 'Token could not be validated'));
|
|
109
96
|
}
|
|
110
97
|
return token;
|
|
111
98
|
},
|
|
112
99
|
}));
|
|
113
|
-
}
|
|
100
|
+
}
|
|
114
101
|
exports.default = stateModelFactory;
|
|
115
|
-
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDescriptiveErrorMessage(response: Response, reason?: string): Promise<string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDescriptiveErrorMessage = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
async function getDescriptiveErrorMessage(response, reason) {
|
|
6
|
+
let errorMessage = '';
|
|
7
|
+
try {
|
|
8
|
+
const err = JSON.parse(await response.text());
|
|
9
|
+
errorMessage = err.error.message;
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
/* do nothing */
|
|
13
|
+
}
|
|
14
|
+
return (0, util_1.getResponseError)({ response, reason, statusText: errorMessage });
|
|
15
|
+
}
|
|
16
|
+
exports.getDescriptiveErrorMessage = getDescriptiveErrorMessage;
|
|
@@ -26,30 +26,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.HTTPBasicLoginForm = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const material_1 = require("@mui/material");
|
|
29
|
+
const ui_1 = require("@jbrowse/core/ui");
|
|
29
30
|
const HTTPBasicLoginForm = ({ internetAccountId, handleClose, }) => {
|
|
30
31
|
const [username, setUsername] = (0, react_1.useState)('');
|
|
31
32
|
const [password, setPassword] = (0, react_1.useState)('');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
react_1.default.createElement(material_1.
|
|
48
|
-
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" }),
|
|
49
|
-
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" })),
|
|
50
|
-
react_1.default.createElement(material_1.DialogActions, null,
|
|
51
|
-
react_1.default.createElement(material_1.Button, { variant: "contained", color: "primary", type: "submit" }, "Submit"),
|
|
52
|
-
react_1.default.createElement(material_1.Button, { variant: "contained", type: "submit", onClick: () => handleClose() }, "Cancel"))))));
|
|
33
|
+
return (react_1.default.createElement(ui_1.Dialog, { open: true, maxWidth: "xl", "data-testid": "login-httpbasic", title: `Log In for ${internetAccountId}` },
|
|
34
|
+
react_1.default.createElement("form", { onSubmit: event => {
|
|
35
|
+
if (username && password) {
|
|
36
|
+
handleClose(btoa(`${username}:${password}`));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
handleClose();
|
|
40
|
+
}
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
} },
|
|
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" })),
|
|
46
|
+
react_1.default.createElement(material_1.DialogActions, null,
|
|
47
|
+
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")))));
|
|
53
49
|
};
|
|
54
50
|
exports.HTTPBasicLoginForm = HTTPBasicLoginForm;
|
|
55
|
-
//# sourceMappingURL=HTTPBasicLoginForm.js.map
|
|
@@ -8,4 +8,3 @@ var configSchema_1 = require("./configSchema");
|
|
|
8
8
|
Object.defineProperty(exports, "configSchema", { enumerable: true, get: function () { return __importDefault(configSchema_1).default; } });
|
|
9
9
|
var model_1 = require("./model");
|
|
10
10
|
Object.defineProperty(exports, "modelFactory", { enumerable: true, get: function () { return __importDefault(model_1).default; } });
|
|
11
|
-
//# sourceMappingURL=index.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;
|
|
@@ -4,18 +4,34 @@ const configuration_1 = require("@jbrowse/core/configuration");
|
|
|
4
4
|
const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
|
|
5
5
|
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
6
6
|
const HTTPBasicLoginForm_1 = require("./HTTPBasicLoginForm");
|
|
7
|
+
const util_1 = require("../util");
|
|
8
|
+
/**
|
|
9
|
+
* #stateModel HTTPBasicInternetAccount
|
|
10
|
+
*/
|
|
7
11
|
const stateModelFactory = (configSchema) => {
|
|
8
12
|
return models_1.InternetAccount.named('HTTPBasicInternetAccount')
|
|
9
13
|
.props({
|
|
14
|
+
/**
|
|
15
|
+
* #property
|
|
16
|
+
*/
|
|
10
17
|
type: mobx_state_tree_1.types.literal('HTTPBasicInternetAccount'),
|
|
18
|
+
/**
|
|
19
|
+
* #property
|
|
20
|
+
*/
|
|
11
21
|
configuration: (0, configuration_1.ConfigurationReference)(configSchema),
|
|
12
22
|
})
|
|
13
23
|
.views(self => ({
|
|
24
|
+
/**
|
|
25
|
+
* #getter
|
|
26
|
+
*/
|
|
14
27
|
get validateWithHEAD() {
|
|
15
28
|
return (0, configuration_1.getConf)(self, 'validateWithHEAD');
|
|
16
29
|
},
|
|
17
30
|
}))
|
|
18
31
|
.actions(self => ({
|
|
32
|
+
/**
|
|
33
|
+
* #action
|
|
34
|
+
*/
|
|
19
35
|
getTokenFromUser(resolve, reject) {
|
|
20
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
37
|
const { session } = (0, mobx_state_tree_1.getRoot)(self);
|
|
@@ -28,13 +44,16 @@ const stateModelFactory = (configSchema) => {
|
|
|
28
44
|
resolve(token);
|
|
29
45
|
}
|
|
30
46
|
else {
|
|
31
|
-
reject(new Error('
|
|
47
|
+
reject(new Error('User cancelled entry'));
|
|
32
48
|
}
|
|
33
49
|
doneCallback();
|
|
34
50
|
},
|
|
35
51
|
},
|
|
36
52
|
]);
|
|
37
53
|
},
|
|
54
|
+
/**
|
|
55
|
+
* #action
|
|
56
|
+
*/
|
|
38
57
|
async validateToken(token, location) {
|
|
39
58
|
if (!self.validateWithHEAD) {
|
|
40
59
|
return token;
|
|
@@ -42,18 +61,13 @@ const stateModelFactory = (configSchema) => {
|
|
|
42
61
|
const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token);
|
|
43
62
|
const response = await fetch(location.uri, newInit);
|
|
44
63
|
if (!response.ok) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
errorMessage = '';
|
|
51
|
-
}
|
|
52
|
-
throw new Error(`Error validating token — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`);
|
|
64
|
+
throw new Error(await (0, util_1.getResponseError)({
|
|
65
|
+
response,
|
|
66
|
+
reason: 'Error validating token',
|
|
67
|
+
}));
|
|
53
68
|
}
|
|
54
69
|
return token;
|
|
55
70
|
},
|
|
56
71
|
}));
|
|
57
72
|
};
|
|
58
73
|
exports.default = stateModelFactory;
|
|
59
|
-
//# 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;
|