@jbrowse/plugin-authentication 4.3.0 → 5.0.0-beta.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/esm/DropboxOAuthModel/DropboxIcon.d.ts +1 -1
- package/esm/DropboxOAuthModel/configSchema.d.ts +110 -82
- package/esm/DropboxOAuthModel/configSchema.js +32 -2
- package/esm/DropboxOAuthModel/index.js +2 -2
- package/esm/DropboxOAuthModel/model.d.ts +235 -201
- package/esm/DropboxOAuthModel/model.js +46 -21
- package/esm/DropboxOAuthModel/util.d.ts +1 -1
- package/esm/DropboxOAuthModel/util.js +9 -12
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.d.ts +1 -1
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.js +11 -15
- package/esm/ExternalTokenModel/configSchema.d.ts +43 -24
- package/esm/ExternalTokenModel/configSchema.js +22 -1
- package/esm/ExternalTokenModel/index.js +2 -2
- package/esm/ExternalTokenModel/model.d.ts +47 -71
- package/esm/ExternalTokenModel/model.js +11 -54
- package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +2 -9
- package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +27 -6
- package/esm/GoogleDriveOAuthModel/GoogleDriveIcon.d.ts +1 -1
- package/esm/GoogleDriveOAuthModel/configSchema.d.ts +109 -82
- package/esm/GoogleDriveOAuthModel/configSchema.js +32 -3
- package/esm/GoogleDriveOAuthModel/index.js +2 -2
- package/esm/GoogleDriveOAuthModel/model.d.ts +230 -202
- package/esm/GoogleDriveOAuthModel/model.js +45 -22
- package/esm/GoogleDriveOAuthModel/util.d.ts +1 -1
- package/esm/GoogleDriveOAuthModel/util.js +2 -11
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.d.ts +1 -1
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.js +17 -22
- package/esm/HTTPBasicModel/configSchema.d.ts +51 -28
- package/esm/HTTPBasicModel/configSchema.js +26 -1
- package/esm/HTTPBasicModel/index.js +2 -2
- package/esm/HTTPBasicModel/model.d.ts +55 -76
- package/esm/HTTPBasicModel/model.js +21 -51
- package/esm/OAuthModel/OAuthLoginPrompt.d.ts +4 -0
- package/esm/OAuthModel/OAuthLoginPrompt.js +12 -0
- package/esm/OAuthModel/configSchema.d.ts +79 -52
- package/esm/OAuthModel/configSchema.js +30 -1
- package/esm/OAuthModel/index.js +2 -2
- package/esm/OAuthModel/model.d.ts +218 -114
- package/esm/OAuthModel/model.js +361 -217
- package/esm/OAuthModel/util.d.ts +46 -7
- package/esm/OAuthModel/util.js +159 -16
- package/esm/index.d.ts +295 -981
- package/esm/index.js +29 -45
- package/esm/lazyLoginForms.d.ts +18 -0
- package/esm/lazyLoginForms.js +25 -0
- package/esm/tokenEntryModelFactory.d.ts +125 -0
- package/esm/tokenEntryModelFactory.js +85 -0
- package/esm/util.d.ts +10 -0
- package/esm/util.js +24 -2
- package/package.json +10 -13
|
@@ -5,197 +5,206 @@ import type { Instance } from '@jbrowse/mobx-state-tree';
|
|
|
5
5
|
export interface RequestInitWithMetadata extends RequestInit {
|
|
6
6
|
metadataOnly?: boolean;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* #stateModel GoogleDriveOAuthInternetAccount
|
|
10
|
+
*/
|
|
11
|
+
export default function stateModelFactory(configSchema: GoogleDriveOAuthInternetAccountConfigModel): import("@jbrowse/mobx-state-tree").IModelType<Omit<Omit<{
|
|
9
12
|
id: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
10
13
|
type: import("@jbrowse/mobx-state-tree").ISimpleType<string>;
|
|
11
|
-
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
12
|
-
name: {
|
|
13
|
-
description:
|
|
14
|
-
type: string;
|
|
15
|
-
defaultValue:
|
|
16
|
-
};
|
|
17
|
-
description: {
|
|
18
|
-
description:
|
|
19
|
-
type: string;
|
|
20
|
-
defaultValue:
|
|
21
|
-
};
|
|
22
|
-
authHeader: {
|
|
23
|
-
description:
|
|
24
|
-
type: string;
|
|
25
|
-
defaultValue:
|
|
26
|
-
};
|
|
27
|
-
tokenType: {
|
|
28
|
-
description:
|
|
29
|
-
type: string;
|
|
30
|
-
defaultValue:
|
|
31
|
-
};
|
|
32
|
-
domains: {
|
|
33
|
-
description:
|
|
34
|
-
type:
|
|
35
|
-
defaultValue:
|
|
36
|
-
};
|
|
37
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId"
|
|
38
|
-
} & {
|
|
39
|
-
type: import("@jbrowse/mobx-state-tree").
|
|
40
|
-
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
41
|
-
tokenType: {
|
|
42
|
-
description:
|
|
43
|
-
type: string;
|
|
44
|
-
defaultValue:
|
|
45
|
-
};
|
|
46
|
-
authEndpoint: {
|
|
47
|
-
description:
|
|
48
|
-
type: string;
|
|
49
|
-
defaultValue:
|
|
50
|
-
};
|
|
51
|
-
tokenEndpoint: {
|
|
52
|
-
description:
|
|
53
|
-
type: string;
|
|
54
|
-
defaultValue:
|
|
55
|
-
};
|
|
56
|
-
needsPKCE: {
|
|
57
|
-
description:
|
|
58
|
-
type:
|
|
59
|
-
defaultValue:
|
|
60
|
-
};
|
|
61
|
-
clientId: {
|
|
62
|
-
description:
|
|
63
|
-
type: string;
|
|
64
|
-
defaultValue:
|
|
65
|
-
};
|
|
66
|
-
scopes: {
|
|
67
|
-
description:
|
|
68
|
-
type: string;
|
|
69
|
-
defaultValue:
|
|
70
|
-
};
|
|
71
|
-
state: {
|
|
72
|
-
description:
|
|
73
|
-
type: string;
|
|
74
|
-
defaultValue:
|
|
75
|
-
};
|
|
76
|
-
responseType: {
|
|
77
|
-
description:
|
|
78
|
-
type: string;
|
|
79
|
-
defaultValue:
|
|
14
|
+
configuration: import("@jbrowse/core/configuration/configurationSchema").IConfigurationReference<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
15
|
+
readonly name: {
|
|
16
|
+
readonly description: "descriptive name of the internet account";
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly defaultValue: "";
|
|
19
|
+
};
|
|
20
|
+
readonly description: {
|
|
21
|
+
readonly description: "a description of the internet account";
|
|
22
|
+
readonly type: "string";
|
|
23
|
+
readonly defaultValue: "";
|
|
24
|
+
};
|
|
25
|
+
readonly authHeader: {
|
|
26
|
+
readonly description: "request header for credentials";
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly defaultValue: "Authorization";
|
|
29
|
+
};
|
|
30
|
+
readonly tokenType: {
|
|
31
|
+
readonly description: "a custom name for a token to include in the header";
|
|
32
|
+
readonly type: "string";
|
|
33
|
+
readonly defaultValue: "";
|
|
34
|
+
};
|
|
35
|
+
readonly domains: {
|
|
36
|
+
readonly description: "array of valid domains the url can contain to use this account";
|
|
37
|
+
readonly type: "stringArray";
|
|
38
|
+
readonly defaultValue: readonly [];
|
|
39
|
+
};
|
|
40
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>>;
|
|
41
|
+
}, "configuration" | "type"> & {
|
|
42
|
+
type: import("@jbrowse/mobx-state-tree").ILiteralType<"OAuthInternetAccount">;
|
|
43
|
+
configuration: import("@jbrowse/core/configuration/configurationSchema").IConfigurationReference<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
44
|
+
readonly tokenType: {
|
|
45
|
+
readonly description: "a custom name for a token to include in the header";
|
|
46
|
+
readonly type: "string";
|
|
47
|
+
readonly defaultValue: "Bearer";
|
|
48
|
+
};
|
|
49
|
+
readonly authEndpoint: {
|
|
50
|
+
readonly description: "the authorization code endpoint of the internet account";
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
readonly defaultValue: "";
|
|
53
|
+
};
|
|
54
|
+
readonly tokenEndpoint: {
|
|
55
|
+
readonly description: "the token endpoint of the internet account";
|
|
56
|
+
readonly type: "string";
|
|
57
|
+
readonly defaultValue: "";
|
|
58
|
+
};
|
|
59
|
+
readonly needsPKCE: {
|
|
60
|
+
readonly description: "boolean to indicate if the endpoint needs a PKCE code";
|
|
61
|
+
readonly type: "boolean";
|
|
62
|
+
readonly defaultValue: false;
|
|
63
|
+
};
|
|
64
|
+
readonly clientId: {
|
|
65
|
+
readonly description: "id for the OAuth application";
|
|
66
|
+
readonly type: "string";
|
|
67
|
+
readonly defaultValue: "";
|
|
68
|
+
};
|
|
69
|
+
readonly scopes: {
|
|
70
|
+
readonly description: "optional scopes for the authorization call";
|
|
71
|
+
readonly type: "string";
|
|
72
|
+
readonly defaultValue: "";
|
|
73
|
+
};
|
|
74
|
+
readonly state: {
|
|
75
|
+
readonly description: "optional state for the authorization call";
|
|
76
|
+
readonly type: "string";
|
|
77
|
+
readonly defaultValue: "";
|
|
78
|
+
};
|
|
79
|
+
readonly responseType: {
|
|
80
|
+
readonly description: "the type of response from the authorization endpoint. can be 'token' or 'code'";
|
|
81
|
+
readonly type: "string";
|
|
82
|
+
readonly defaultValue: "code";
|
|
80
83
|
};
|
|
81
84
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
82
|
-
name: {
|
|
83
|
-
description:
|
|
84
|
-
type: string;
|
|
85
|
-
defaultValue:
|
|
86
|
-
};
|
|
87
|
-
description: {
|
|
88
|
-
description:
|
|
89
|
-
type: string;
|
|
90
|
-
defaultValue:
|
|
91
|
-
};
|
|
92
|
-
authHeader: {
|
|
93
|
-
description:
|
|
94
|
-
type: string;
|
|
95
|
-
defaultValue:
|
|
96
|
-
};
|
|
97
|
-
tokenType: {
|
|
98
|
-
description:
|
|
99
|
-
type: string;
|
|
100
|
-
defaultValue:
|
|
101
|
-
};
|
|
102
|
-
domains: {
|
|
103
|
-
description:
|
|
104
|
-
type:
|
|
105
|
-
defaultValue:
|
|
106
|
-
};
|
|
107
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined
|
|
108
|
-
} & {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
85
|
+
readonly name: {
|
|
86
|
+
readonly description: "descriptive name of the internet account";
|
|
87
|
+
readonly type: "string";
|
|
88
|
+
readonly defaultValue: "";
|
|
89
|
+
};
|
|
90
|
+
readonly description: {
|
|
91
|
+
readonly description: "a description of the internet account";
|
|
92
|
+
readonly type: "string";
|
|
93
|
+
readonly defaultValue: "";
|
|
94
|
+
};
|
|
95
|
+
readonly authHeader: {
|
|
96
|
+
readonly description: "request header for credentials";
|
|
97
|
+
readonly type: "string";
|
|
98
|
+
readonly defaultValue: "Authorization";
|
|
99
|
+
};
|
|
100
|
+
readonly tokenType: {
|
|
101
|
+
readonly description: "a custom name for a token to include in the header";
|
|
102
|
+
readonly type: "string";
|
|
103
|
+
readonly defaultValue: "";
|
|
104
|
+
};
|
|
105
|
+
readonly domains: {
|
|
106
|
+
readonly description: "array of valid domains the url can contain to use this account";
|
|
107
|
+
readonly type: "stringArray";
|
|
108
|
+
readonly defaultValue: readonly [];
|
|
109
|
+
};
|
|
110
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>>;
|
|
111
|
+
}, "configuration" | "type"> & {
|
|
112
|
+
/**
|
|
113
|
+
* #property
|
|
114
|
+
*/
|
|
115
|
+
type: import("@jbrowse/mobx-state-tree").ILiteralType<"GoogleDriveOAuthInternetAccount">;
|
|
116
|
+
/**
|
|
117
|
+
* #property
|
|
118
|
+
*/
|
|
119
|
+
configuration: import("@jbrowse/core/configuration/configurationSchema").IConfigurationReference<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
120
|
+
readonly authEndpoint: {
|
|
121
|
+
readonly description: "the authorization code endpoint of the internet account";
|
|
122
|
+
readonly type: "string";
|
|
123
|
+
readonly defaultValue: "https://accounts.google.com/o/oauth2/v2/auth";
|
|
124
|
+
};
|
|
125
|
+
readonly scopes: {
|
|
126
|
+
readonly description: "optional scopes for the authorization call";
|
|
127
|
+
readonly type: "string";
|
|
128
|
+
readonly defaultValue: "https://www.googleapis.com/auth/drive.readonly";
|
|
129
|
+
};
|
|
130
|
+
readonly domains: {
|
|
131
|
+
readonly description: "array of valid domains the url can contain to use this account";
|
|
132
|
+
readonly type: "stringArray";
|
|
133
|
+
readonly defaultValue: readonly ["drive.google.com"];
|
|
134
|
+
};
|
|
135
|
+
readonly responseType: {
|
|
136
|
+
readonly description: "the type of response from the authorization endpoint";
|
|
137
|
+
readonly type: "string";
|
|
138
|
+
readonly defaultValue: "token";
|
|
130
139
|
};
|
|
131
140
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
132
|
-
tokenType: {
|
|
133
|
-
description:
|
|
134
|
-
type: string;
|
|
135
|
-
defaultValue:
|
|
136
|
-
};
|
|
137
|
-
authEndpoint: {
|
|
138
|
-
description:
|
|
139
|
-
type: string;
|
|
140
|
-
defaultValue:
|
|
141
|
-
};
|
|
142
|
-
tokenEndpoint: {
|
|
143
|
-
description:
|
|
144
|
-
type: string;
|
|
145
|
-
defaultValue:
|
|
146
|
-
};
|
|
147
|
-
needsPKCE: {
|
|
148
|
-
description:
|
|
149
|
-
type:
|
|
150
|
-
defaultValue:
|
|
151
|
-
};
|
|
152
|
-
clientId: {
|
|
153
|
-
description:
|
|
154
|
-
type: string;
|
|
155
|
-
defaultValue:
|
|
156
|
-
};
|
|
157
|
-
scopes: {
|
|
158
|
-
description:
|
|
159
|
-
type: string;
|
|
160
|
-
defaultValue:
|
|
161
|
-
};
|
|
162
|
-
state: {
|
|
163
|
-
description:
|
|
164
|
-
type: string;
|
|
165
|
-
defaultValue:
|
|
166
|
-
};
|
|
167
|
-
responseType: {
|
|
168
|
-
description:
|
|
169
|
-
type: string;
|
|
170
|
-
defaultValue:
|
|
141
|
+
readonly tokenType: {
|
|
142
|
+
readonly description: "a custom name for a token to include in the header";
|
|
143
|
+
readonly type: "string";
|
|
144
|
+
readonly defaultValue: "Bearer";
|
|
145
|
+
};
|
|
146
|
+
readonly authEndpoint: {
|
|
147
|
+
readonly description: "the authorization code endpoint of the internet account";
|
|
148
|
+
readonly type: "string";
|
|
149
|
+
readonly defaultValue: "";
|
|
150
|
+
};
|
|
151
|
+
readonly tokenEndpoint: {
|
|
152
|
+
readonly description: "the token endpoint of the internet account";
|
|
153
|
+
readonly type: "string";
|
|
154
|
+
readonly defaultValue: "";
|
|
155
|
+
};
|
|
156
|
+
readonly needsPKCE: {
|
|
157
|
+
readonly description: "boolean to indicate if the endpoint needs a PKCE code";
|
|
158
|
+
readonly type: "boolean";
|
|
159
|
+
readonly defaultValue: false;
|
|
160
|
+
};
|
|
161
|
+
readonly clientId: {
|
|
162
|
+
readonly description: "id for the OAuth application";
|
|
163
|
+
readonly type: "string";
|
|
164
|
+
readonly defaultValue: "";
|
|
165
|
+
};
|
|
166
|
+
readonly scopes: {
|
|
167
|
+
readonly description: "optional scopes for the authorization call";
|
|
168
|
+
readonly type: "string";
|
|
169
|
+
readonly defaultValue: "";
|
|
170
|
+
};
|
|
171
|
+
readonly state: {
|
|
172
|
+
readonly description: "optional state for the authorization call";
|
|
173
|
+
readonly type: "string";
|
|
174
|
+
readonly defaultValue: "";
|
|
175
|
+
};
|
|
176
|
+
readonly responseType: {
|
|
177
|
+
readonly description: "the type of response from the authorization endpoint. can be 'token' or 'code'";
|
|
178
|
+
readonly type: "string";
|
|
179
|
+
readonly defaultValue: "code";
|
|
171
180
|
};
|
|
172
181
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
173
|
-
name: {
|
|
174
|
-
description:
|
|
175
|
-
type: string;
|
|
176
|
-
defaultValue:
|
|
177
|
-
};
|
|
178
|
-
description: {
|
|
179
|
-
description:
|
|
180
|
-
type: string;
|
|
181
|
-
defaultValue:
|
|
182
|
-
};
|
|
183
|
-
authHeader: {
|
|
184
|
-
description:
|
|
185
|
-
type: string;
|
|
186
|
-
defaultValue:
|
|
187
|
-
};
|
|
188
|
-
tokenType: {
|
|
189
|
-
description:
|
|
190
|
-
type: string;
|
|
191
|
-
defaultValue:
|
|
192
|
-
};
|
|
193
|
-
domains: {
|
|
194
|
-
description:
|
|
195
|
-
type:
|
|
196
|
-
defaultValue:
|
|
197
|
-
};
|
|
198
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>, undefined
|
|
182
|
+
readonly name: {
|
|
183
|
+
readonly description: "descriptive name of the internet account";
|
|
184
|
+
readonly type: "string";
|
|
185
|
+
readonly defaultValue: "";
|
|
186
|
+
};
|
|
187
|
+
readonly description: {
|
|
188
|
+
readonly description: "a description of the internet account";
|
|
189
|
+
readonly type: "string";
|
|
190
|
+
readonly defaultValue: "";
|
|
191
|
+
};
|
|
192
|
+
readonly authHeader: {
|
|
193
|
+
readonly description: "request header for credentials";
|
|
194
|
+
readonly type: "string";
|
|
195
|
+
readonly defaultValue: "Authorization";
|
|
196
|
+
};
|
|
197
|
+
readonly tokenType: {
|
|
198
|
+
readonly description: "a custom name for a token to include in the header";
|
|
199
|
+
readonly type: "string";
|
|
200
|
+
readonly defaultValue: "";
|
|
201
|
+
};
|
|
202
|
+
readonly domains: {
|
|
203
|
+
readonly description: "array of valid domains the url can contain to use this account";
|
|
204
|
+
readonly type: "stringArray";
|
|
205
|
+
readonly defaultValue: readonly [];
|
|
206
|
+
};
|
|
207
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>, undefined>>>;
|
|
199
208
|
}, {
|
|
200
209
|
readonly name: string;
|
|
201
210
|
readonly description: string;
|
|
@@ -204,22 +213,21 @@ export default function stateModelFactory(configSchema: GoogleDriveOAuthInternet
|
|
|
204
213
|
readonly tokenType: string;
|
|
205
214
|
readonly domains: string[];
|
|
206
215
|
readonly toggleContents: React.ReactNode;
|
|
207
|
-
readonly SelectorComponent: import("@jbrowse/core/util").AnyReactComponentType | undefined;
|
|
208
216
|
readonly selectorLabel: string | undefined;
|
|
217
|
+
readonly showInFileSelector: boolean;
|
|
209
218
|
} & {
|
|
210
219
|
handlesLocation(location: UriLocation): boolean;
|
|
211
220
|
readonly tokenKey: string;
|
|
212
221
|
} & {
|
|
213
222
|
getTokenFromUser(_resolve: (token: string) => void, _reject: (error: Error) => void): void;
|
|
214
223
|
storeToken(token: string): void;
|
|
215
|
-
|
|
216
|
-
retrieveToken(): string | null;
|
|
224
|
+
retrieveToken(): string | undefined;
|
|
217
225
|
validateToken(token: string, _loc: UriLocation): Promise<string>;
|
|
218
226
|
} & {
|
|
227
|
+
removeToken(): void;
|
|
219
228
|
getToken(location?: UriLocation): Promise<string>;
|
|
220
229
|
} & {
|
|
221
230
|
addAuthHeaderToInit(init?: RequestInit, token?: string): {
|
|
222
|
-
headers: Headers;
|
|
223
231
|
body?: BodyInit | null;
|
|
224
232
|
cache?: RequestCache;
|
|
225
233
|
credentials?: RequestCredentials;
|
|
@@ -233,51 +241,71 @@ export default function stateModelFactory(configSchema: GoogleDriveOAuthInternet
|
|
|
233
241
|
referrerPolicy?: ReferrerPolicy;
|
|
234
242
|
signal?: AbortSignal | null;
|
|
235
243
|
window?: null;
|
|
244
|
+
headers: Headers;
|
|
236
245
|
};
|
|
246
|
+
fetchWithToken(loc: UriLocation | undefined, run: (token: string) => Promise<Response>): Promise<Response>;
|
|
237
247
|
getPreAuthorizationInformation(location: UriLocation): Promise<{
|
|
238
248
|
internetAccountType: string;
|
|
239
249
|
authInfo: {
|
|
240
250
|
token: string;
|
|
241
|
-
configuration: any
|
|
251
|
+
configuration: import("@jbrowse/mobx-state-tree").ModelSnapshotType<Record<string, any>>;
|
|
242
252
|
};
|
|
243
253
|
}>;
|
|
244
254
|
} & {
|
|
245
255
|
getFetcher(loc?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
246
256
|
} & {
|
|
247
|
-
openLocation(location: UriLocation): import("@
|
|
257
|
+
openLocation(location: UriLocation): import("@gmod/range-cache-filehandle").RemoteFileWithRangeCache;
|
|
248
258
|
} & {
|
|
249
|
-
readonly
|
|
259
|
+
readonly conf: import("../OAuthModel/configSchema.ts").OAuthInternetAccountConfig;
|
|
250
260
|
} & {
|
|
251
261
|
readonly authEndpoint: string;
|
|
252
262
|
readonly tokenEndpoint: string;
|
|
253
263
|
readonly needsPKCE: boolean;
|
|
254
264
|
readonly clientId: string;
|
|
255
265
|
readonly scopes: string;
|
|
256
|
-
state
|
|
257
|
-
readonly responseType:
|
|
266
|
+
readonly state: string;
|
|
267
|
+
readonly responseType: 'token' | 'code';
|
|
258
268
|
readonly refreshTokenKey: string;
|
|
269
|
+
readonly authFlowParams: Record<string, string>;
|
|
259
270
|
} & {
|
|
260
271
|
storeRefreshToken(refreshToken: string): void;
|
|
261
272
|
removeRefreshToken(): void;
|
|
262
|
-
retrieveRefreshToken(): string |
|
|
263
|
-
|
|
273
|
+
retrieveRefreshToken(): string | undefined;
|
|
274
|
+
} & {
|
|
275
|
+
postTokenGrant(grant: Record<string, string>, describeError: (response: Response) => Promise<string>): Promise<string>;
|
|
276
|
+
} & {
|
|
277
|
+
exchangeAuthorizationForAccessToken(code: string, redirectUri: string, codeVerifier: string | undefined): Promise<string>;
|
|
264
278
|
exchangeRefreshForAccessToken(refreshToken: string): Promise<string>;
|
|
265
279
|
} & {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
useEndpointForAuthorization(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
280
|
+
validateTokenWithProbe(token: string, probe: (token: string) => Promise<Response>, describeError: (response: Response, reason?: string) => Promise<string>): Promise<string>;
|
|
281
|
+
getTokenViaAuthFlow(): Promise<string>;
|
|
282
|
+
} & {
|
|
270
283
|
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
271
284
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
272
285
|
} & {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
286
|
+
/**
|
|
287
|
+
* #getter
|
|
288
|
+
* The FileSelector icon for Google drive
|
|
289
|
+
*/
|
|
290
|
+
readonly toggleContents: import("react").JSX.Element;
|
|
291
|
+
/**
|
|
292
|
+
* #getter
|
|
293
|
+
*/
|
|
276
294
|
readonly selectorLabel: string;
|
|
277
295
|
} & {
|
|
296
|
+
/**
|
|
297
|
+
* #method
|
|
298
|
+
*/
|
|
278
299
|
getFetcher(location?: UriLocation): (input: RequestInfo, init?: RequestInitWithMetadata) => Promise<Response>;
|
|
279
|
-
|
|
300
|
+
/**
|
|
301
|
+
* #action
|
|
302
|
+
*/
|
|
280
303
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
304
|
+
} & {
|
|
305
|
+
/**
|
|
306
|
+
* #method
|
|
307
|
+
*/
|
|
308
|
+
openLocation(location: UriLocation): GoogleDriveFile;
|
|
281
309
|
}, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>;
|
|
282
310
|
export type GoogleDriveOAuthStateModel = ReturnType<typeof stateModelFactory>;
|
|
283
311
|
export type GoogleDriveOAuthModel = Instance<GoogleDriveOAuthStateModel>;
|
|
@@ -1,35 +1,59 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { ConfigurationReference } from '@jbrowse/core/configuration';
|
|
3
3
|
import { types } from '@jbrowse/mobx-state-tree';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
4
|
+
import { configSchema as OAuthConfigSchema } from '../OAuthModel/index.js';
|
|
5
|
+
import baseModel from '../OAuthModel/model.js';
|
|
6
|
+
import { GoogleDriveFile } from './GoogleDriveFilehandle.js';
|
|
7
|
+
import GoogleDriveIcon from './GoogleDriveIcon.js';
|
|
8
|
+
import { getDescriptiveErrorMessage } from './util.js';
|
|
9
9
|
function getUri(str) {
|
|
10
|
-
const urlId =
|
|
11
|
-
|
|
10
|
+
const urlId = /\/d\/([-\w]{25,})/.exec(str);
|
|
11
|
+
if (!urlId) {
|
|
12
|
+
throw new Error(`Could not extract Google Drive file ID from URL: ${str}`);
|
|
13
|
+
}
|
|
14
|
+
return `https://www.googleapis.com/drive/v3/files/${urlId[1]}`;
|
|
12
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* #stateModel GoogleDriveOAuthInternetAccount
|
|
18
|
+
*/
|
|
13
19
|
export default function stateModelFactory(configSchema) {
|
|
14
20
|
return baseModel(OAuthConfigSchema)
|
|
15
21
|
.named('GoogleDriveOAuthInternetAccount')
|
|
16
22
|
.props({
|
|
23
|
+
/**
|
|
24
|
+
* #property
|
|
25
|
+
*/
|
|
17
26
|
type: types.literal('GoogleDriveOAuthInternetAccount'),
|
|
27
|
+
/**
|
|
28
|
+
* #property
|
|
29
|
+
*/
|
|
18
30
|
configuration: ConfigurationReference(configSchema),
|
|
19
31
|
})
|
|
20
32
|
.views(() => ({
|
|
33
|
+
/**
|
|
34
|
+
* #getter
|
|
35
|
+
* The FileSelector icon for Google drive
|
|
36
|
+
*/
|
|
21
37
|
get toggleContents() {
|
|
22
38
|
return _jsx(GoogleDriveIcon, {});
|
|
23
39
|
},
|
|
40
|
+
/**
|
|
41
|
+
* #getter
|
|
42
|
+
*/
|
|
24
43
|
get selectorLabel() {
|
|
25
44
|
return 'Enter Google Drive share link';
|
|
26
45
|
},
|
|
27
46
|
}))
|
|
28
47
|
.actions(self => ({
|
|
48
|
+
/**
|
|
49
|
+
* #method
|
|
50
|
+
*/
|
|
29
51
|
getFetcher(location) {
|
|
30
52
|
return async (input, init) => {
|
|
31
53
|
const driveUrl = new URL(getUri(String(input)));
|
|
32
54
|
const searchParams = new URLSearchParams();
|
|
55
|
+
// metadataOnly: private flag used by GoogleDriveFile constructor to
|
|
56
|
+
// pre-fetch just the file size for stat() without downloading content
|
|
33
57
|
if (init?.metadataOnly) {
|
|
34
58
|
searchParams.append('fields', 'size');
|
|
35
59
|
}
|
|
@@ -37,30 +61,29 @@ export default function stateModelFactory(configSchema) {
|
|
|
37
61
|
searchParams.append('alt', 'media');
|
|
38
62
|
}
|
|
39
63
|
driveUrl.search = searchParams.toString();
|
|
40
|
-
const
|
|
41
|
-
const response = await fetch(driveUrl, self.addAuthHeaderToInit({ ...init, method: 'GET', credentials: 'same-origin' }, authToken));
|
|
64
|
+
const response = await self.fetchWithToken(location, authToken => fetch(driveUrl, self.addAuthHeaderToInit({ ...init, method: 'GET', credentials: 'same-origin' }, authToken)));
|
|
42
65
|
if (!response.ok) {
|
|
43
66
|
throw new Error(await getDescriptiveErrorMessage(response));
|
|
44
67
|
}
|
|
45
68
|
return response;
|
|
46
69
|
};
|
|
47
70
|
},
|
|
71
|
+
/**
|
|
72
|
+
* #action
|
|
73
|
+
*/
|
|
74
|
+
async validateToken(token, location) {
|
|
75
|
+
const uri = getUri(location.uri);
|
|
76
|
+
return self.validateTokenWithProbe(token, authToken => fetch(uri, { headers: { Authorization: `Bearer ${authToken}` } }), getDescriptiveErrorMessage);
|
|
77
|
+
},
|
|
78
|
+
}))
|
|
79
|
+
.actions(self => ({
|
|
80
|
+
/**
|
|
81
|
+
* #method
|
|
82
|
+
*/
|
|
48
83
|
openLocation(location) {
|
|
49
84
|
return new GoogleDriveFile(location.uri, {
|
|
50
|
-
fetch:
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
async validateToken(token, location) {
|
|
54
|
-
const response = await fetch(getUri(location.uri), {
|
|
55
|
-
headers: {
|
|
56
|
-
Authorization: `Bearer ${token}`,
|
|
57
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
58
|
-
},
|
|
85
|
+
fetch: self.getFetcher(location),
|
|
59
86
|
});
|
|
60
|
-
if (!response.ok) {
|
|
61
|
-
throw new Error(await getDescriptiveErrorMessage(response, 'Token could not be validated'));
|
|
62
|
-
}
|
|
63
|
-
return token;
|
|
64
87
|
},
|
|
65
88
|
}));
|
|
66
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const getDescriptiveErrorMessage: (response: Response, reason?: string) => Promise<string>;
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
let errorMessage = '';
|
|
4
|
-
try {
|
|
5
|
-
const err = JSON.parse(await response.text());
|
|
6
|
-
errorMessage = err.error.message;
|
|
7
|
-
}
|
|
8
|
-
catch (error) {
|
|
9
|
-
}
|
|
10
|
-
return getResponseError({ response, reason, statusText: errorMessage });
|
|
11
|
-
}
|
|
1
|
+
import { descriptiveErrorMessage } from '../util.js';
|
|
2
|
+
export const getDescriptiveErrorMessage = descriptiveErrorMessage(err => err.error.message);
|