@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
|
@@ -1,197 +1,206 @@
|
|
|
1
1
|
import type { DropboxOAuthInternetAccountConfigModel } from './configSchema.ts';
|
|
2
2
|
import type { UriLocation } from '@jbrowse/core/util/types';
|
|
3
3
|
import type { Instance } from '@jbrowse/mobx-state-tree';
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* #stateModel DropboxOAuthInternetAccount
|
|
6
|
+
*/
|
|
7
|
+
declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfigModel) => import("@jbrowse/mobx-state-tree").IModelType<Omit<Omit<{
|
|
5
8
|
id: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
6
9
|
type: import("@jbrowse/mobx-state-tree").ISimpleType<string>;
|
|
7
|
-
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
8
|
-
name: {
|
|
9
|
-
description:
|
|
10
|
-
type: string;
|
|
11
|
-
defaultValue:
|
|
12
|
-
};
|
|
13
|
-
description: {
|
|
14
|
-
description:
|
|
15
|
-
type: string;
|
|
16
|
-
defaultValue:
|
|
17
|
-
};
|
|
18
|
-
authHeader: {
|
|
19
|
-
description:
|
|
20
|
-
type: string;
|
|
21
|
-
defaultValue:
|
|
22
|
-
};
|
|
23
|
-
tokenType: {
|
|
24
|
-
description:
|
|
25
|
-
type: string;
|
|
26
|
-
defaultValue:
|
|
27
|
-
};
|
|
28
|
-
domains: {
|
|
29
|
-
description:
|
|
30
|
-
type:
|
|
31
|
-
defaultValue:
|
|
32
|
-
};
|
|
33
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId"
|
|
34
|
-
} & {
|
|
35
|
-
type: import("@jbrowse/mobx-state-tree").
|
|
36
|
-
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
37
|
-
tokenType: {
|
|
38
|
-
description:
|
|
39
|
-
type: string;
|
|
40
|
-
defaultValue:
|
|
41
|
-
};
|
|
42
|
-
authEndpoint: {
|
|
43
|
-
description:
|
|
44
|
-
type: string;
|
|
45
|
-
defaultValue:
|
|
46
|
-
};
|
|
47
|
-
tokenEndpoint: {
|
|
48
|
-
description:
|
|
49
|
-
type: string;
|
|
50
|
-
defaultValue:
|
|
51
|
-
};
|
|
52
|
-
needsPKCE: {
|
|
53
|
-
description:
|
|
54
|
-
type:
|
|
55
|
-
defaultValue:
|
|
56
|
-
};
|
|
57
|
-
clientId: {
|
|
58
|
-
description:
|
|
59
|
-
type: string;
|
|
60
|
-
defaultValue:
|
|
61
|
-
};
|
|
62
|
-
scopes: {
|
|
63
|
-
description:
|
|
64
|
-
type: string;
|
|
65
|
-
defaultValue:
|
|
66
|
-
};
|
|
67
|
-
state: {
|
|
68
|
-
description:
|
|
69
|
-
type: string;
|
|
70
|
-
defaultValue:
|
|
71
|
-
};
|
|
72
|
-
responseType: {
|
|
73
|
-
description:
|
|
74
|
-
type: string;
|
|
75
|
-
defaultValue:
|
|
10
|
+
configuration: import("@jbrowse/core/configuration/configurationSchema").IConfigurationReference<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
11
|
+
readonly name: {
|
|
12
|
+
readonly description: "descriptive name of the internet account";
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly defaultValue: "";
|
|
15
|
+
};
|
|
16
|
+
readonly description: {
|
|
17
|
+
readonly description: "a description of the internet account";
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly defaultValue: "";
|
|
20
|
+
};
|
|
21
|
+
readonly authHeader: {
|
|
22
|
+
readonly description: "request header for credentials";
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly defaultValue: "Authorization";
|
|
25
|
+
};
|
|
26
|
+
readonly tokenType: {
|
|
27
|
+
readonly description: "a custom name for a token to include in the header";
|
|
28
|
+
readonly type: "string";
|
|
29
|
+
readonly defaultValue: "";
|
|
30
|
+
};
|
|
31
|
+
readonly domains: {
|
|
32
|
+
readonly description: "array of valid domains the url can contain to use this account";
|
|
33
|
+
readonly type: "stringArray";
|
|
34
|
+
readonly defaultValue: readonly [];
|
|
35
|
+
};
|
|
36
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>>;
|
|
37
|
+
}, "configuration" | "type"> & {
|
|
38
|
+
type: import("@jbrowse/mobx-state-tree").ILiteralType<"OAuthInternetAccount">;
|
|
39
|
+
configuration: import("@jbrowse/core/configuration/configurationSchema").IConfigurationReference<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
40
|
+
readonly tokenType: {
|
|
41
|
+
readonly description: "a custom name for a token to include in the header";
|
|
42
|
+
readonly type: "string";
|
|
43
|
+
readonly defaultValue: "Bearer";
|
|
44
|
+
};
|
|
45
|
+
readonly authEndpoint: {
|
|
46
|
+
readonly description: "the authorization code endpoint of the internet account";
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
readonly defaultValue: "";
|
|
49
|
+
};
|
|
50
|
+
readonly tokenEndpoint: {
|
|
51
|
+
readonly description: "the token endpoint of the internet account";
|
|
52
|
+
readonly type: "string";
|
|
53
|
+
readonly defaultValue: "";
|
|
54
|
+
};
|
|
55
|
+
readonly needsPKCE: {
|
|
56
|
+
readonly description: "boolean to indicate if the endpoint needs a PKCE code";
|
|
57
|
+
readonly type: "boolean";
|
|
58
|
+
readonly defaultValue: false;
|
|
59
|
+
};
|
|
60
|
+
readonly clientId: {
|
|
61
|
+
readonly description: "id for the OAuth application";
|
|
62
|
+
readonly type: "string";
|
|
63
|
+
readonly defaultValue: "";
|
|
64
|
+
};
|
|
65
|
+
readonly scopes: {
|
|
66
|
+
readonly description: "optional scopes for the authorization call";
|
|
67
|
+
readonly type: "string";
|
|
68
|
+
readonly defaultValue: "";
|
|
69
|
+
};
|
|
70
|
+
readonly state: {
|
|
71
|
+
readonly description: "optional state for the authorization call";
|
|
72
|
+
readonly type: "string";
|
|
73
|
+
readonly defaultValue: "";
|
|
74
|
+
};
|
|
75
|
+
readonly responseType: {
|
|
76
|
+
readonly description: "the type of response from the authorization endpoint. can be 'token' or 'code'";
|
|
77
|
+
readonly type: "string";
|
|
78
|
+
readonly defaultValue: "code";
|
|
76
79
|
};
|
|
77
80
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
78
|
-
name: {
|
|
79
|
-
description:
|
|
80
|
-
type: string;
|
|
81
|
-
defaultValue:
|
|
82
|
-
};
|
|
83
|
-
description: {
|
|
84
|
-
description:
|
|
85
|
-
type: string;
|
|
86
|
-
defaultValue:
|
|
87
|
-
};
|
|
88
|
-
authHeader: {
|
|
89
|
-
description:
|
|
90
|
-
type: string;
|
|
91
|
-
defaultValue:
|
|
92
|
-
};
|
|
93
|
-
tokenType: {
|
|
94
|
-
description:
|
|
95
|
-
type: string;
|
|
96
|
-
defaultValue:
|
|
97
|
-
};
|
|
98
|
-
domains: {
|
|
99
|
-
description:
|
|
100
|
-
type:
|
|
101
|
-
defaultValue:
|
|
102
|
-
};
|
|
103
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined
|
|
104
|
-
} & {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
81
|
+
readonly name: {
|
|
82
|
+
readonly description: "descriptive name of the internet account";
|
|
83
|
+
readonly type: "string";
|
|
84
|
+
readonly defaultValue: "";
|
|
85
|
+
};
|
|
86
|
+
readonly description: {
|
|
87
|
+
readonly description: "a description of the internet account";
|
|
88
|
+
readonly type: "string";
|
|
89
|
+
readonly defaultValue: "";
|
|
90
|
+
};
|
|
91
|
+
readonly authHeader: {
|
|
92
|
+
readonly description: "request header for credentials";
|
|
93
|
+
readonly type: "string";
|
|
94
|
+
readonly defaultValue: "Authorization";
|
|
95
|
+
};
|
|
96
|
+
readonly tokenType: {
|
|
97
|
+
readonly description: "a custom name for a token to include in the header";
|
|
98
|
+
readonly type: "string";
|
|
99
|
+
readonly defaultValue: "";
|
|
100
|
+
};
|
|
101
|
+
readonly domains: {
|
|
102
|
+
readonly description: "array of valid domains the url can contain to use this account";
|
|
103
|
+
readonly type: "stringArray";
|
|
104
|
+
readonly defaultValue: readonly [];
|
|
105
|
+
};
|
|
106
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>>;
|
|
107
|
+
}, "configuration" | "type"> & {
|
|
108
|
+
/**
|
|
109
|
+
* #property
|
|
110
|
+
*/
|
|
111
|
+
type: import("@jbrowse/mobx-state-tree").ILiteralType<"DropboxOAuthInternetAccount">;
|
|
112
|
+
/**
|
|
113
|
+
* #property
|
|
114
|
+
*/
|
|
115
|
+
configuration: import("@jbrowse/core/configuration/configurationSchema").IConfigurationReference<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
116
|
+
readonly authEndpoint: {
|
|
117
|
+
readonly description: "the authorization code endpoint of the internet account";
|
|
118
|
+
readonly type: "string";
|
|
119
|
+
readonly defaultValue: "https://www.dropbox.com/oauth2/authorize";
|
|
120
|
+
};
|
|
121
|
+
readonly tokenEndpoint: {
|
|
122
|
+
readonly description: "the token endpoint of the internet account";
|
|
123
|
+
readonly type: "string";
|
|
124
|
+
readonly defaultValue: "https://api.dropbox.com/oauth2/token";
|
|
125
|
+
};
|
|
126
|
+
readonly needsPKCE: {
|
|
127
|
+
readonly description: "boolean to indicate if the endpoint needs a PKCE code";
|
|
128
|
+
readonly type: "boolean";
|
|
129
|
+
readonly defaultValue: true;
|
|
130
|
+
};
|
|
131
|
+
readonly domains: {
|
|
132
|
+
readonly description: "array of valid domains the url can contain to use this account";
|
|
133
|
+
readonly type: "stringArray";
|
|
134
|
+
readonly defaultValue: readonly ["addtodropbox.com", "db.tt", "dropbox.com", "dropboxapi.com", "dropboxbusiness.com", "dropbox.tech", "getdropbox.com"];
|
|
126
135
|
};
|
|
127
136
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
128
|
-
tokenType: {
|
|
129
|
-
description:
|
|
130
|
-
type: string;
|
|
131
|
-
defaultValue:
|
|
132
|
-
};
|
|
133
|
-
authEndpoint: {
|
|
134
|
-
description:
|
|
135
|
-
type: string;
|
|
136
|
-
defaultValue:
|
|
137
|
-
};
|
|
138
|
-
tokenEndpoint: {
|
|
139
|
-
description:
|
|
140
|
-
type: string;
|
|
141
|
-
defaultValue:
|
|
142
|
-
};
|
|
143
|
-
needsPKCE: {
|
|
144
|
-
description:
|
|
145
|
-
type:
|
|
146
|
-
defaultValue:
|
|
147
|
-
};
|
|
148
|
-
clientId: {
|
|
149
|
-
description:
|
|
150
|
-
type: string;
|
|
151
|
-
defaultValue:
|
|
152
|
-
};
|
|
153
|
-
scopes: {
|
|
154
|
-
description:
|
|
155
|
-
type: string;
|
|
156
|
-
defaultValue:
|
|
157
|
-
};
|
|
158
|
-
state: {
|
|
159
|
-
description:
|
|
160
|
-
type: string;
|
|
161
|
-
defaultValue:
|
|
162
|
-
};
|
|
163
|
-
responseType: {
|
|
164
|
-
description:
|
|
165
|
-
type: string;
|
|
166
|
-
defaultValue:
|
|
137
|
+
readonly tokenType: {
|
|
138
|
+
readonly description: "a custom name for a token to include in the header";
|
|
139
|
+
readonly type: "string";
|
|
140
|
+
readonly defaultValue: "Bearer";
|
|
141
|
+
};
|
|
142
|
+
readonly authEndpoint: {
|
|
143
|
+
readonly description: "the authorization code endpoint of the internet account";
|
|
144
|
+
readonly type: "string";
|
|
145
|
+
readonly defaultValue: "";
|
|
146
|
+
};
|
|
147
|
+
readonly tokenEndpoint: {
|
|
148
|
+
readonly description: "the token endpoint of the internet account";
|
|
149
|
+
readonly type: "string";
|
|
150
|
+
readonly defaultValue: "";
|
|
151
|
+
};
|
|
152
|
+
readonly needsPKCE: {
|
|
153
|
+
readonly description: "boolean to indicate if the endpoint needs a PKCE code";
|
|
154
|
+
readonly type: "boolean";
|
|
155
|
+
readonly defaultValue: false;
|
|
156
|
+
};
|
|
157
|
+
readonly clientId: {
|
|
158
|
+
readonly description: "id for the OAuth application";
|
|
159
|
+
readonly type: "string";
|
|
160
|
+
readonly defaultValue: "";
|
|
161
|
+
};
|
|
162
|
+
readonly scopes: {
|
|
163
|
+
readonly description: "optional scopes for the authorization call";
|
|
164
|
+
readonly type: "string";
|
|
165
|
+
readonly defaultValue: "";
|
|
166
|
+
};
|
|
167
|
+
readonly state: {
|
|
168
|
+
readonly description: "optional state for the authorization call";
|
|
169
|
+
readonly type: "string";
|
|
170
|
+
readonly defaultValue: "";
|
|
171
|
+
};
|
|
172
|
+
readonly responseType: {
|
|
173
|
+
readonly description: "the type of response from the authorization endpoint. can be 'token' or 'code'";
|
|
174
|
+
readonly type: "string";
|
|
175
|
+
readonly defaultValue: "code";
|
|
167
176
|
};
|
|
168
177
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
169
|
-
name: {
|
|
170
|
-
description:
|
|
171
|
-
type: string;
|
|
172
|
-
defaultValue:
|
|
173
|
-
};
|
|
174
|
-
description: {
|
|
175
|
-
description:
|
|
176
|
-
type: string;
|
|
177
|
-
defaultValue:
|
|
178
|
-
};
|
|
179
|
-
authHeader: {
|
|
180
|
-
description:
|
|
181
|
-
type: string;
|
|
182
|
-
defaultValue:
|
|
183
|
-
};
|
|
184
|
-
tokenType: {
|
|
185
|
-
description:
|
|
186
|
-
type: string;
|
|
187
|
-
defaultValue:
|
|
188
|
-
};
|
|
189
|
-
domains: {
|
|
190
|
-
description:
|
|
191
|
-
type:
|
|
192
|
-
defaultValue:
|
|
193
|
-
};
|
|
194
|
-
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>, undefined
|
|
178
|
+
readonly name: {
|
|
179
|
+
readonly description: "descriptive name of the internet account";
|
|
180
|
+
readonly type: "string";
|
|
181
|
+
readonly defaultValue: "";
|
|
182
|
+
};
|
|
183
|
+
readonly description: {
|
|
184
|
+
readonly description: "a description of the internet account";
|
|
185
|
+
readonly type: "string";
|
|
186
|
+
readonly defaultValue: "";
|
|
187
|
+
};
|
|
188
|
+
readonly authHeader: {
|
|
189
|
+
readonly description: "request header for credentials";
|
|
190
|
+
readonly type: "string";
|
|
191
|
+
readonly defaultValue: "Authorization";
|
|
192
|
+
};
|
|
193
|
+
readonly tokenType: {
|
|
194
|
+
readonly description: "a custom name for a token to include in the header";
|
|
195
|
+
readonly type: "string";
|
|
196
|
+
readonly defaultValue: "";
|
|
197
|
+
};
|
|
198
|
+
readonly domains: {
|
|
199
|
+
readonly description: "array of valid domains the url can contain to use this account";
|
|
200
|
+
readonly type: "stringArray";
|
|
201
|
+
readonly defaultValue: readonly [];
|
|
202
|
+
};
|
|
203
|
+
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>, undefined>>>;
|
|
195
204
|
}, {
|
|
196
205
|
readonly name: string;
|
|
197
206
|
readonly description: string;
|
|
@@ -200,22 +209,21 @@ declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfi
|
|
|
200
209
|
readonly tokenType: string;
|
|
201
210
|
readonly domains: string[];
|
|
202
211
|
readonly toggleContents: React.ReactNode;
|
|
203
|
-
readonly SelectorComponent: import("@jbrowse/core/util").AnyReactComponentType | undefined;
|
|
204
212
|
readonly selectorLabel: string | undefined;
|
|
213
|
+
readonly showInFileSelector: boolean;
|
|
205
214
|
} & {
|
|
206
215
|
handlesLocation(location: UriLocation): boolean;
|
|
207
216
|
readonly tokenKey: string;
|
|
208
217
|
} & {
|
|
209
218
|
getTokenFromUser(_resolve: (token: string) => void, _reject: (error: Error) => void): void;
|
|
210
219
|
storeToken(token: string): void;
|
|
211
|
-
|
|
212
|
-
retrieveToken(): string | null;
|
|
220
|
+
retrieveToken(): string | undefined;
|
|
213
221
|
validateToken(token: string, _loc: UriLocation): Promise<string>;
|
|
214
222
|
} & {
|
|
223
|
+
removeToken(): void;
|
|
215
224
|
getToken(location?: UriLocation): Promise<string>;
|
|
216
225
|
} & {
|
|
217
226
|
addAuthHeaderToInit(init?: RequestInit, token?: string): {
|
|
218
|
-
headers: Headers;
|
|
219
227
|
body?: BodyInit | null;
|
|
220
228
|
cache?: RequestCache;
|
|
221
229
|
credentials?: RequestCredentials;
|
|
@@ -229,49 +237,75 @@ declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfi
|
|
|
229
237
|
referrerPolicy?: ReferrerPolicy;
|
|
230
238
|
signal?: AbortSignal | null;
|
|
231
239
|
window?: null;
|
|
240
|
+
headers: Headers;
|
|
232
241
|
};
|
|
242
|
+
fetchWithToken(loc: UriLocation | undefined, run: (token: string) => Promise<Response>): Promise<Response>;
|
|
233
243
|
getPreAuthorizationInformation(location: UriLocation): Promise<{
|
|
234
244
|
internetAccountType: string;
|
|
235
245
|
authInfo: {
|
|
236
246
|
token: string;
|
|
237
|
-
configuration: any
|
|
247
|
+
configuration: import("@jbrowse/mobx-state-tree").ModelSnapshotType<Record<string, any>>;
|
|
238
248
|
};
|
|
239
249
|
}>;
|
|
240
250
|
} & {
|
|
241
251
|
getFetcher(loc?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
242
252
|
} & {
|
|
243
|
-
openLocation(location: UriLocation): import("@
|
|
253
|
+
openLocation(location: UriLocation): import("@gmod/range-cache-filehandle").RemoteFileWithRangeCache;
|
|
244
254
|
} & {
|
|
245
|
-
readonly
|
|
255
|
+
readonly conf: import("../OAuthModel/configSchema.ts").OAuthInternetAccountConfig;
|
|
246
256
|
} & {
|
|
247
257
|
readonly authEndpoint: string;
|
|
248
258
|
readonly tokenEndpoint: string;
|
|
249
259
|
readonly needsPKCE: boolean;
|
|
250
260
|
readonly clientId: string;
|
|
251
261
|
readonly scopes: string;
|
|
252
|
-
state
|
|
253
|
-
readonly responseType:
|
|
262
|
+
readonly state: string;
|
|
263
|
+
readonly responseType: 'token' | 'code';
|
|
254
264
|
readonly refreshTokenKey: string;
|
|
265
|
+
readonly authFlowParams: Record<string, string>;
|
|
255
266
|
} & {
|
|
256
267
|
storeRefreshToken(refreshToken: string): void;
|
|
257
268
|
removeRefreshToken(): void;
|
|
258
|
-
retrieveRefreshToken(): string |
|
|
259
|
-
|
|
269
|
+
retrieveRefreshToken(): string | undefined;
|
|
270
|
+
} & {
|
|
271
|
+
postTokenGrant(grant: Record<string, string>, describeError: (response: Response) => Promise<string>): Promise<string>;
|
|
272
|
+
} & {
|
|
273
|
+
exchangeAuthorizationForAccessToken(code: string, redirectUri: string, codeVerifier: string | undefined): Promise<string>;
|
|
260
274
|
exchangeRefreshForAccessToken(refreshToken: string): Promise<string>;
|
|
261
275
|
} & {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
useEndpointForAuthorization(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
276
|
+
validateTokenWithProbe(token: string, probe: (token: string) => Promise<Response>, describeError: (response: Response, reason?: string) => Promise<string>): Promise<string>;
|
|
277
|
+
getTokenViaAuthFlow(): Promise<string>;
|
|
278
|
+
} & {
|
|
266
279
|
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
267
280
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
268
281
|
} & {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
282
|
+
/**
|
|
283
|
+
* #getter
|
|
284
|
+
* The FileSelector icon for Dropbox
|
|
285
|
+
*/
|
|
286
|
+
readonly toggleContents: import("react").JSX.Element;
|
|
287
|
+
/**
|
|
288
|
+
* #getter
|
|
289
|
+
*/
|
|
272
290
|
readonly selectorLabel: string;
|
|
291
|
+
/**
|
|
292
|
+
* #getter
|
|
293
|
+
* Dropbox issues a refresh token only when the authorization request
|
|
294
|
+
* asks for offline access, and spells that `token_access_type` where
|
|
295
|
+
* other providers use `access_type` — so it belongs here rather than on
|
|
296
|
+
* every OAuth account.
|
|
297
|
+
*/
|
|
298
|
+
readonly authFlowParams: {
|
|
299
|
+
token_access_type: string;
|
|
300
|
+
};
|
|
273
301
|
} & {
|
|
302
|
+
/**
|
|
303
|
+
* #method
|
|
304
|
+
*/
|
|
274
305
|
getFetcher(location?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
306
|
+
/**
|
|
307
|
+
* #action
|
|
308
|
+
*/
|
|
275
309
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
276
310
|
}, import("@jbrowse/mobx-state-tree")._NotCustomized, import("@jbrowse/mobx-state-tree")._NotCustomized>;
|
|
277
311
|
export default stateModelFactory;
|
|
@@ -1,59 +1,84 @@
|
|
|
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
|
|
4
|
+
import { configSchema as OAuthConfigSchema } from '../OAuthModel/index.js';
|
|
5
|
+
import baseModel from '../OAuthModel/model.js';
|
|
6
|
+
import DropboxIcon from './DropboxIcon.js';
|
|
7
|
+
import { getDescriptiveErrorMessage } from './util.js';
|
|
8
|
+
/**
|
|
9
|
+
* #stateModel DropboxOAuthInternetAccount
|
|
10
|
+
*/
|
|
8
11
|
const stateModelFactory = (configSchema) => {
|
|
9
12
|
return baseModel(OAuthConfigSchema)
|
|
10
13
|
.named('DropboxOAuthInternetAccount')
|
|
11
14
|
.props({
|
|
15
|
+
/**
|
|
16
|
+
* #property
|
|
17
|
+
*/
|
|
12
18
|
type: types.literal('DropboxOAuthInternetAccount'),
|
|
19
|
+
/**
|
|
20
|
+
* #property
|
|
21
|
+
*/
|
|
13
22
|
configuration: ConfigurationReference(configSchema),
|
|
14
23
|
})
|
|
15
24
|
.views(() => ({
|
|
25
|
+
/**
|
|
26
|
+
* #getter
|
|
27
|
+
* The FileSelector icon for Dropbox
|
|
28
|
+
*/
|
|
16
29
|
get toggleContents() {
|
|
17
30
|
return _jsx(DropboxIcon, {});
|
|
18
31
|
},
|
|
32
|
+
/**
|
|
33
|
+
* #getter
|
|
34
|
+
*/
|
|
19
35
|
get selectorLabel() {
|
|
20
36
|
return 'Enter Dropbox share link';
|
|
21
37
|
},
|
|
38
|
+
/**
|
|
39
|
+
* #getter
|
|
40
|
+
* Dropbox issues a refresh token only when the authorization request
|
|
41
|
+
* asks for offline access, and spells that `token_access_type` where
|
|
42
|
+
* other providers use `access_type` — so it belongs here rather than on
|
|
43
|
+
* every OAuth account.
|
|
44
|
+
*/
|
|
45
|
+
get authFlowParams() {
|
|
46
|
+
return { token_access_type: 'offline' };
|
|
47
|
+
},
|
|
22
48
|
}))
|
|
23
49
|
.actions(self => ({
|
|
50
|
+
/**
|
|
51
|
+
* #method
|
|
52
|
+
*/
|
|
24
53
|
getFetcher(location) {
|
|
25
54
|
return async (input, init) => {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
55
|
+
const response = await self.fetchWithToken(location, authToken => {
|
|
56
|
+
// built per attempt: the Headers are appended to below, so a retry
|
|
57
|
+
// reusing them would send two Dropbox-API-Arg values
|
|
58
|
+
const newInit = self.addAuthHeaderToInit({ ...init, method: 'POST' }, authToken);
|
|
59
|
+
newInit.headers.append('Dropbox-API-Arg', JSON.stringify({ url: input }));
|
|
60
|
+
return fetch('https://content.dropboxapi.com/2/sharing/get_shared_link_file', newInit);
|
|
61
|
+
});
|
|
30
62
|
if (!response.ok) {
|
|
31
63
|
throw new Error(await getDescriptiveErrorMessage(response));
|
|
32
64
|
}
|
|
33
65
|
return response;
|
|
34
66
|
};
|
|
35
67
|
},
|
|
68
|
+
/**
|
|
69
|
+
* #action
|
|
70
|
+
*/
|
|
36
71
|
async validateToken(token, location) {
|
|
37
|
-
|
|
72
|
+
return self.validateTokenWithProbe(token, authToken => fetch('https://api.dropboxapi.com/2/sharing/get_shared_link_metadata', {
|
|
38
73
|
method: 'POST',
|
|
39
74
|
headers: {
|
|
40
|
-
Authorization: `Bearer ${
|
|
75
|
+
Authorization: `Bearer ${authToken}`,
|
|
41
76
|
'Content-Type': 'application/json',
|
|
42
77
|
},
|
|
43
78
|
body: JSON.stringify({
|
|
44
79
|
url: location.uri,
|
|
45
80
|
}),
|
|
46
|
-
});
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
const refreshToken = self.retrieveRefreshToken();
|
|
49
|
-
if (refreshToken) {
|
|
50
|
-
self.removeRefreshToken();
|
|
51
|
-
const newToken = await self.exchangeRefreshForAccessToken(refreshToken);
|
|
52
|
-
return this.validateToken(newToken, location);
|
|
53
|
-
}
|
|
54
|
-
throw new Error(await getDescriptiveErrorMessage(response, 'Token could not be validated'));
|
|
55
|
-
}
|
|
56
|
-
return token;
|
|
81
|
+
}), getDescriptiveErrorMessage);
|
|
57
82
|
},
|
|
58
83
|
}));
|
|
59
84
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const getDescriptiveErrorMessage: (response: Response, reason?: string) => Promise<string>;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { descriptiveErrorMessage } from '../util.js';
|
|
2
|
+
/**
|
|
3
|
+
* Error messages from
|
|
4
|
+
* https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file
|
|
5
|
+
* */
|
|
2
6
|
const dropboxErrorMessages = {
|
|
3
7
|
shared_link_not_found: "The shared link wasn't found.",
|
|
4
8
|
shared_link_access_denied: 'The caller is not allowed to access this shared link.',
|
|
5
9
|
unsupported_link_type: 'This type of link is not supported; use files/export instead.',
|
|
6
10
|
shared_link_is_directory: 'Directories cannot be retrieved by this endpoint.',
|
|
7
11
|
};
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const tag = err.error['.tag'];
|
|
13
|
-
errorMessage = dropboxErrorMessages[tag] || tag;
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
}
|
|
17
|
-
return getResponseError({ response, reason, statusText: errorMessage });
|
|
18
|
-
}
|
|
12
|
+
export const getDescriptiveErrorMessage = descriptiveErrorMessage(err => {
|
|
13
|
+
const tag = err.error['.tag'];
|
|
14
|
+
return dropboxErrorMessages[tag] ?? tag;
|
|
15
|
+
});
|