@jbrowse/plugin-authentication 2.16.1 → 2.18.0
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/DropboxIcon.d.ts +1 -1
- package/dist/DropboxOAuthModel/configSchema.d.ts +1 -13
- package/dist/DropboxOAuthModel/configSchema.js +1 -19
- package/dist/DropboxOAuthModel/model.d.ts +3 -25
- package/dist/DropboxOAuthModel/model.js +2 -24
- package/dist/DropboxOAuthModel/util.js +0 -5
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.js +8 -4
- package/dist/ExternalTokenModel/configSchema.d.ts +1 -4
- package/dist/ExternalTokenModel/configSchema.js +1 -10
- package/dist/ExternalTokenModel/model.d.ts +3 -3
- package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +1 -1
- package/dist/GoogleDriveOAuthModel/GoogleDriveIcon.d.ts +1 -1
- package/dist/GoogleDriveOAuthModel/configSchema.d.ts +1 -13
- package/dist/GoogleDriveOAuthModel/configSchema.js +1 -19
- package/dist/GoogleDriveOAuthModel/model.d.ts +3 -28
- package/dist/GoogleDriveOAuthModel/model.js +2 -27
- package/dist/GoogleDriveOAuthModel/util.js +0 -1
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.js +12 -6
- package/dist/HTTPBasicModel/configSchema.d.ts +1 -7
- package/dist/HTTPBasicModel/configSchema.js +1 -13
- package/dist/HTTPBasicModel/model.d.ts +3 -21
- package/dist/HTTPBasicModel/model.js +0 -18
- package/dist/OAuthModel/configSchema.d.ts +1 -25
- package/dist/OAuthModel/configSchema.js +1 -31
- package/dist/OAuthModel/model.d.ts +3 -89
- package/dist/OAuthModel/model.js +1 -96
- package/dist/OAuthModel/util.js +0 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/esm/DropboxOAuthModel/DropboxIcon.d.ts +1 -1
- package/esm/DropboxOAuthModel/configSchema.d.ts +1 -13
- package/esm/DropboxOAuthModel/configSchema.js +1 -19
- package/esm/DropboxOAuthModel/model.d.ts +3 -25
- package/esm/DropboxOAuthModel/model.js +2 -24
- package/esm/DropboxOAuthModel/util.js +0 -5
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.js +8 -4
- package/esm/ExternalTokenModel/configSchema.d.ts +1 -4
- package/esm/ExternalTokenModel/configSchema.js +1 -10
- package/esm/ExternalTokenModel/model.d.ts +3 -3
- package/esm/ExternalTokenModel/model.js +1 -1
- package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +1 -1
- package/esm/GoogleDriveOAuthModel/GoogleDriveIcon.d.ts +1 -1
- package/esm/GoogleDriveOAuthModel/configSchema.d.ts +1 -13
- package/esm/GoogleDriveOAuthModel/configSchema.js +1 -19
- package/esm/GoogleDriveOAuthModel/model.d.ts +3 -28
- package/esm/GoogleDriveOAuthModel/model.js +2 -27
- package/esm/GoogleDriveOAuthModel/util.js +0 -1
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.js +12 -6
- package/esm/HTTPBasicModel/configSchema.d.ts +1 -7
- package/esm/HTTPBasicModel/configSchema.js +1 -13
- package/esm/HTTPBasicModel/model.d.ts +3 -21
- package/esm/HTTPBasicModel/model.js +1 -19
- package/esm/OAuthModel/configSchema.d.ts +1 -25
- package/esm/OAuthModel/configSchema.js +1 -31
- package/esm/OAuthModel/model.d.ts +3 -89
- package/esm/OAuthModel/model.js +1 -96
- package/esm/OAuthModel/util.js +0 -2
- package/esm/index.d.ts +1 -1
- package/esm/index.js +3 -3
- package/package.json +2 -2
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
/**
|
|
5
|
-
* #stateModel HTTPBasicInternetAccount
|
|
6
|
-
*/
|
|
1
|
+
import type { HTTPBasicInternetAccountConfigModel } from './configSchema';
|
|
2
|
+
import type { UriLocation } from '@jbrowse/core/util/types';
|
|
3
|
+
import type { Instance } from 'mobx-state-tree';
|
|
7
4
|
declare const stateModelFactory: (configSchema: HTTPBasicInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
|
|
8
5
|
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
9
6
|
type: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -35,13 +32,7 @@ declare const stateModelFactory: (configSchema: HTTPBasicInternetAccountConfigMo
|
|
|
35
32
|
};
|
|
36
33
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>;
|
|
37
34
|
} & {
|
|
38
|
-
/**
|
|
39
|
-
* #property
|
|
40
|
-
*/
|
|
41
35
|
type: import("mobx-state-tree").ISimpleType<"HTTPBasicInternetAccount">;
|
|
42
|
-
/**
|
|
43
|
-
* #property
|
|
44
|
-
*/
|
|
45
36
|
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
46
37
|
tokenType: {
|
|
47
38
|
description: string;
|
|
@@ -130,18 +121,9 @@ declare const stateModelFactory: (configSchema: HTTPBasicInternetAccountConfigMo
|
|
|
130
121
|
} & {
|
|
131
122
|
openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
|
|
132
123
|
} & {
|
|
133
|
-
/**
|
|
134
|
-
* #getter
|
|
135
|
-
*/
|
|
136
124
|
readonly validateWithHEAD: boolean;
|
|
137
125
|
} & {
|
|
138
|
-
/**
|
|
139
|
-
* #action
|
|
140
|
-
*/
|
|
141
126
|
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
142
|
-
/**
|
|
143
|
-
* #action
|
|
144
|
-
*/
|
|
145
127
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
146
128
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
147
129
|
export default stateModelFactory;
|
|
@@ -5,33 +5,18 @@ 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
7
|
const util_1 = require("../util");
|
|
8
|
-
/**
|
|
9
|
-
* #stateModel HTTPBasicInternetAccount
|
|
10
|
-
*/
|
|
11
8
|
const stateModelFactory = (configSchema) => {
|
|
12
9
|
return models_1.InternetAccount.named('HTTPBasicInternetAccount')
|
|
13
10
|
.props({
|
|
14
|
-
/**
|
|
15
|
-
* #property
|
|
16
|
-
*/
|
|
17
11
|
type: mobx_state_tree_1.types.literal('HTTPBasicInternetAccount'),
|
|
18
|
-
/**
|
|
19
|
-
* #property
|
|
20
|
-
*/
|
|
21
12
|
configuration: (0, configuration_1.ConfigurationReference)(configSchema),
|
|
22
13
|
})
|
|
23
14
|
.views(self => ({
|
|
24
|
-
/**
|
|
25
|
-
* #getter
|
|
26
|
-
*/
|
|
27
15
|
get validateWithHEAD() {
|
|
28
16
|
return (0, configuration_1.getConf)(self, 'validateWithHEAD');
|
|
29
17
|
},
|
|
30
18
|
}))
|
|
31
19
|
.actions(self => ({
|
|
32
|
-
/**
|
|
33
|
-
* #action
|
|
34
|
-
*/
|
|
35
20
|
getTokenFromUser(resolve, reject) {
|
|
36
21
|
const { session } = (0, mobx_state_tree_1.getRoot)(self);
|
|
37
22
|
session.queueDialog((doneCallback) => [
|
|
@@ -50,9 +35,6 @@ const stateModelFactory = (configSchema) => {
|
|
|
50
35
|
},
|
|
51
36
|
]);
|
|
52
37
|
},
|
|
53
|
-
/**
|
|
54
|
-
* #action
|
|
55
|
-
*/
|
|
56
38
|
async validateToken(token, location) {
|
|
57
39
|
if (!self.validateWithHEAD) {
|
|
58
40
|
return token;
|
|
@@ -1,64 +1,40 @@
|
|
|
1
|
-
import { Instance } from 'mobx-state-tree';
|
|
1
|
+
import type { Instance } from 'mobx-state-tree';
|
|
2
2
|
declare const OAuthConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
3
|
-
/**
|
|
4
|
-
* #slot
|
|
5
|
-
*/
|
|
6
3
|
tokenType: {
|
|
7
4
|
description: string;
|
|
8
5
|
type: string;
|
|
9
6
|
defaultValue: string;
|
|
10
7
|
};
|
|
11
|
-
/**
|
|
12
|
-
* #slot
|
|
13
|
-
*/
|
|
14
8
|
authEndpoint: {
|
|
15
9
|
description: string;
|
|
16
10
|
type: string;
|
|
17
11
|
defaultValue: string;
|
|
18
12
|
};
|
|
19
|
-
/**
|
|
20
|
-
* #slot
|
|
21
|
-
*/
|
|
22
13
|
tokenEndpoint: {
|
|
23
14
|
description: string;
|
|
24
15
|
type: string;
|
|
25
16
|
defaultValue: string;
|
|
26
17
|
};
|
|
27
|
-
/**
|
|
28
|
-
* #slot
|
|
29
|
-
*/
|
|
30
18
|
needsPKCE: {
|
|
31
19
|
description: string;
|
|
32
20
|
type: string;
|
|
33
21
|
defaultValue: boolean;
|
|
34
22
|
};
|
|
35
|
-
/**
|
|
36
|
-
* #slot
|
|
37
|
-
*/
|
|
38
23
|
clientId: {
|
|
39
24
|
description: string;
|
|
40
25
|
type: string;
|
|
41
26
|
defaultValue: string;
|
|
42
27
|
};
|
|
43
|
-
/**
|
|
44
|
-
* #slot
|
|
45
|
-
*/
|
|
46
28
|
scopes: {
|
|
47
29
|
description: string;
|
|
48
30
|
type: string;
|
|
49
31
|
defaultValue: string;
|
|
50
32
|
};
|
|
51
|
-
/**
|
|
52
|
-
* #slot
|
|
53
|
-
*/
|
|
54
33
|
state: {
|
|
55
34
|
description: string;
|
|
56
35
|
type: string;
|
|
57
36
|
defaultValue: string;
|
|
58
37
|
};
|
|
59
|
-
/**
|
|
60
|
-
* #slot
|
|
61
|
-
*/
|
|
62
38
|
responseType: {
|
|
63
39
|
description: string;
|
|
64
40
|
type: string;
|
|
@@ -2,79 +2,49 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const configuration_1 = require("@jbrowse/core/configuration");
|
|
4
4
|
const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
|
|
5
|
-
|
|
6
|
-
* #config OAuthInternetAccount
|
|
7
|
-
*/
|
|
8
|
-
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
5
|
+
function x() { }
|
|
9
6
|
const OAuthConfigSchema = (0, configuration_1.ConfigurationSchema)('OAuthInternetAccount', {
|
|
10
|
-
/**
|
|
11
|
-
* #slot
|
|
12
|
-
*/
|
|
13
7
|
tokenType: {
|
|
14
8
|
description: 'a custom name for a token to include in the header',
|
|
15
9
|
type: 'string',
|
|
16
10
|
defaultValue: 'Bearer',
|
|
17
11
|
},
|
|
18
|
-
/**
|
|
19
|
-
* #slot
|
|
20
|
-
*/
|
|
21
12
|
authEndpoint: {
|
|
22
13
|
description: 'the authorization code endpoint of the internet account',
|
|
23
14
|
type: 'string',
|
|
24
15
|
defaultValue: '',
|
|
25
16
|
},
|
|
26
|
-
/**
|
|
27
|
-
* #slot
|
|
28
|
-
*/
|
|
29
17
|
tokenEndpoint: {
|
|
30
18
|
description: 'the token endpoint of the internet account',
|
|
31
19
|
type: 'string',
|
|
32
20
|
defaultValue: '',
|
|
33
21
|
},
|
|
34
|
-
/**
|
|
35
|
-
* #slot
|
|
36
|
-
*/
|
|
37
22
|
needsPKCE: {
|
|
38
23
|
description: 'boolean to indicate if the endpoint needs a PKCE code',
|
|
39
24
|
type: 'boolean',
|
|
40
25
|
defaultValue: false,
|
|
41
26
|
},
|
|
42
|
-
/**
|
|
43
|
-
* #slot
|
|
44
|
-
*/
|
|
45
27
|
clientId: {
|
|
46
28
|
description: 'id for the OAuth application',
|
|
47
29
|
type: 'string',
|
|
48
30
|
defaultValue: '',
|
|
49
31
|
},
|
|
50
|
-
/**
|
|
51
|
-
* #slot
|
|
52
|
-
*/
|
|
53
32
|
scopes: {
|
|
54
33
|
description: 'optional scopes for the authorization call',
|
|
55
34
|
type: 'string',
|
|
56
35
|
defaultValue: '',
|
|
57
36
|
},
|
|
58
|
-
/**
|
|
59
|
-
* #slot
|
|
60
|
-
*/
|
|
61
37
|
state: {
|
|
62
38
|
description: 'optional state for the authorization call',
|
|
63
39
|
type: 'string',
|
|
64
40
|
defaultValue: '',
|
|
65
41
|
},
|
|
66
|
-
/**
|
|
67
|
-
* #slot
|
|
68
|
-
*/
|
|
69
42
|
responseType: {
|
|
70
43
|
description: "the type of response from the authorization endpoint. can be 'token' or 'code'",
|
|
71
44
|
type: 'string',
|
|
72
45
|
defaultValue: 'code',
|
|
73
46
|
},
|
|
74
47
|
}, {
|
|
75
|
-
/**
|
|
76
|
-
* #baseConfiguration
|
|
77
|
-
*/
|
|
78
48
|
baseConfiguration: models_1.BaseInternetAccountConfig,
|
|
79
49
|
explicitlyTyped: true,
|
|
80
50
|
});
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
/**
|
|
5
|
-
* #stateModel OAuthInternetAccount
|
|
6
|
-
*/
|
|
1
|
+
import type { OAuthInternetAccountConfigModel } from './configSchema';
|
|
2
|
+
import type { UriLocation } from '@jbrowse/core/util';
|
|
3
|
+
import type { Instance } from 'mobx-state-tree';
|
|
7
4
|
declare const stateModelFactory: (configSchema: OAuthInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
|
|
8
5
|
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
9
6
|
type: import("mobx-state-tree").ISimpleType<string>;
|
|
@@ -35,13 +32,7 @@ declare const stateModelFactory: (configSchema: OAuthInternetAccountConfigModel)
|
|
|
35
32
|
};
|
|
36
33
|
}, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>;
|
|
37
34
|
} & {
|
|
38
|
-
/**
|
|
39
|
-
* #property
|
|
40
|
-
*/
|
|
41
35
|
type: import("mobx-state-tree").ISimpleType<"OAuthInternetAccount">;
|
|
42
|
-
/**
|
|
43
|
-
* #property
|
|
44
|
-
*/
|
|
45
36
|
configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
46
37
|
tokenType: {
|
|
47
38
|
description: string;
|
|
@@ -160,107 +151,30 @@ declare const stateModelFactory: (configSchema: OAuthInternetAccountConfigModel)
|
|
|
160
151
|
} & {
|
|
161
152
|
openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
|
|
162
153
|
} & {
|
|
163
|
-
/**
|
|
164
|
-
* #getter
|
|
165
|
-
*/
|
|
166
154
|
readonly codeVerifierPKCE: string;
|
|
167
155
|
} & {
|
|
168
|
-
/**
|
|
169
|
-
* #getter
|
|
170
|
-
*/
|
|
171
156
|
readonly authEndpoint: string;
|
|
172
|
-
/**
|
|
173
|
-
* #getter
|
|
174
|
-
*/
|
|
175
157
|
readonly tokenEndpoint: string;
|
|
176
|
-
/**
|
|
177
|
-
* #getter
|
|
178
|
-
*/
|
|
179
158
|
readonly needsPKCE: boolean;
|
|
180
|
-
/**
|
|
181
|
-
* #getter
|
|
182
|
-
*/
|
|
183
159
|
readonly clientId: string;
|
|
184
|
-
/**
|
|
185
|
-
* #getter
|
|
186
|
-
*/
|
|
187
160
|
readonly scopes: string;
|
|
188
|
-
/**
|
|
189
|
-
* #method
|
|
190
|
-
* OAuth state parameter:
|
|
191
|
-
* https://www.rfc-editor.org/rfc/rfc6749#section-4.1.1
|
|
192
|
-
*
|
|
193
|
-
* Can override or extend if dynamic state is needed.
|
|
194
|
-
*/
|
|
195
161
|
state(): string | undefined;
|
|
196
|
-
/**
|
|
197
|
-
* #getter
|
|
198
|
-
*/
|
|
199
162
|
readonly responseType: "code" | "token";
|
|
200
|
-
/**
|
|
201
|
-
* #getter
|
|
202
|
-
*/
|
|
203
163
|
readonly refreshTokenKey: string;
|
|
204
164
|
} & {
|
|
205
|
-
/**
|
|
206
|
-
* #action
|
|
207
|
-
*/
|
|
208
165
|
storeRefreshToken(refreshToken: string): void;
|
|
209
|
-
/**
|
|
210
|
-
* #action
|
|
211
|
-
*/
|
|
212
166
|
removeRefreshToken(): void;
|
|
213
|
-
/**
|
|
214
|
-
* #method
|
|
215
|
-
*/
|
|
216
167
|
retrieveRefreshToken(): string | null;
|
|
217
|
-
/**
|
|
218
|
-
* #action
|
|
219
|
-
*/
|
|
220
168
|
exchangeAuthorizationForAccessToken(token: string, redirectUri: string): Promise<string>;
|
|
221
|
-
/**
|
|
222
|
-
* #action
|
|
223
|
-
*/
|
|
224
169
|
exchangeRefreshForAccessToken(refreshToken: string): Promise<string>;
|
|
225
170
|
} & {
|
|
226
|
-
/**
|
|
227
|
-
* #action
|
|
228
|
-
* used to listen to child window for auth code/token
|
|
229
|
-
*/
|
|
230
171
|
addMessageChannel(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
231
|
-
/**
|
|
232
|
-
* #action
|
|
233
|
-
*/
|
|
234
172
|
deleteMessageChannel(): void;
|
|
235
|
-
/**
|
|
236
|
-
* #action
|
|
237
|
-
*/
|
|
238
173
|
finishOAuthWindow(event: MessageEvent, resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
239
|
-
/**
|
|
240
|
-
* #action
|
|
241
|
-
* opens external OAuth flow, popup for web and new browser window for
|
|
242
|
-
* desktop
|
|
243
|
-
*/
|
|
244
174
|
useEndpointForAuthorization(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
245
|
-
/**
|
|
246
|
-
* #action
|
|
247
|
-
*/
|
|
248
175
|
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
249
|
-
/**
|
|
250
|
-
* #action
|
|
251
|
-
*/
|
|
252
176
|
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
253
177
|
} & {
|
|
254
|
-
/**
|
|
255
|
-
* #action
|
|
256
|
-
* Get a fetch method that will add any needed authentication headers
|
|
257
|
-
* to the request before sending it. If location is provided, it will
|
|
258
|
-
* be checked to see if it includes a token in it's pre-auth
|
|
259
|
-
* information.
|
|
260
|
-
*
|
|
261
|
-
* @param loc - UriLocation of the resource
|
|
262
|
-
* @returns A function that can be used to fetch
|
|
263
|
-
*/
|
|
264
178
|
getFetcher(loc?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
265
179
|
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
266
180
|
export default stateModelFactory;
|
package/dist/OAuthModel/model.js
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const buffer_1 = require("buffer");
|
|
3
4
|
const configuration_1 = require("@jbrowse/core/configuration");
|
|
4
5
|
const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
|
|
5
6
|
const util_1 = require("@jbrowse/core/util");
|
|
6
7
|
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
7
|
-
const buffer_1 = require("buffer");
|
|
8
8
|
const util_2 = require("./util");
|
|
9
9
|
const util_3 = require("../util");
|
|
10
|
-
/**
|
|
11
|
-
* #stateModel OAuthInternetAccount
|
|
12
|
-
*/
|
|
13
10
|
const stateModelFactory = (configSchema) => {
|
|
14
11
|
return models_1.InternetAccount.named('OAuthInternetAccount')
|
|
15
12
|
.props({
|
|
16
|
-
/**
|
|
17
|
-
* #property
|
|
18
|
-
*/
|
|
19
13
|
type: mobx_state_tree_1.types.literal('OAuthInternetAccount'),
|
|
20
|
-
/**
|
|
21
|
-
* #property
|
|
22
|
-
*/
|
|
23
14
|
configuration: (0, configuration_1.ConfigurationReference)(configSchema),
|
|
24
15
|
})
|
|
25
16
|
.views(() => {
|
|
26
17
|
let codeVerifier = undefined;
|
|
27
18
|
return {
|
|
28
|
-
/**
|
|
29
|
-
* #getter
|
|
30
|
-
*/
|
|
31
19
|
get codeVerifierPKCE() {
|
|
32
20
|
if (codeVerifier) {
|
|
33
21
|
return codeVerifier;
|
|
@@ -40,81 +28,41 @@ const stateModelFactory = (configSchema) => {
|
|
|
40
28
|
};
|
|
41
29
|
})
|
|
42
30
|
.views(self => ({
|
|
43
|
-
/**
|
|
44
|
-
* #getter
|
|
45
|
-
*/
|
|
46
31
|
get authEndpoint() {
|
|
47
32
|
return (0, configuration_1.getConf)(self, 'authEndpoint');
|
|
48
33
|
},
|
|
49
|
-
/**
|
|
50
|
-
* #getter
|
|
51
|
-
*/
|
|
52
34
|
get tokenEndpoint() {
|
|
53
35
|
return (0, configuration_1.getConf)(self, 'tokenEndpoint');
|
|
54
36
|
},
|
|
55
|
-
/**
|
|
56
|
-
* #getter
|
|
57
|
-
*/
|
|
58
37
|
get needsPKCE() {
|
|
59
38
|
return (0, configuration_1.getConf)(self, 'needsPKCE');
|
|
60
39
|
},
|
|
61
|
-
/**
|
|
62
|
-
* #getter
|
|
63
|
-
*/
|
|
64
40
|
get clientId() {
|
|
65
41
|
return (0, configuration_1.getConf)(self, 'clientId');
|
|
66
42
|
},
|
|
67
|
-
/**
|
|
68
|
-
* #getter
|
|
69
|
-
*/
|
|
70
43
|
get scopes() {
|
|
71
44
|
return (0, configuration_1.getConf)(self, 'scopes');
|
|
72
45
|
},
|
|
73
|
-
/**
|
|
74
|
-
* #method
|
|
75
|
-
* OAuth state parameter:
|
|
76
|
-
* https://www.rfc-editor.org/rfc/rfc6749#section-4.1.1
|
|
77
|
-
*
|
|
78
|
-
* Can override or extend if dynamic state is needed.
|
|
79
|
-
*/
|
|
80
46
|
state() {
|
|
81
47
|
return (0, configuration_1.getConf)(self, 'state');
|
|
82
48
|
},
|
|
83
|
-
/**
|
|
84
|
-
* #getter
|
|
85
|
-
*/
|
|
86
49
|
get responseType() {
|
|
87
50
|
return (0, configuration_1.getConf)(self, 'responseType');
|
|
88
51
|
},
|
|
89
|
-
/**
|
|
90
|
-
* #getter
|
|
91
|
-
*/
|
|
92
52
|
get refreshTokenKey() {
|
|
93
53
|
return `${self.internetAccountId}-refreshToken`;
|
|
94
54
|
},
|
|
95
55
|
}))
|
|
96
56
|
.actions(self => ({
|
|
97
|
-
/**
|
|
98
|
-
* #action
|
|
99
|
-
*/
|
|
100
57
|
storeRefreshToken(refreshToken) {
|
|
101
58
|
localStorage.setItem(self.refreshTokenKey, refreshToken);
|
|
102
59
|
},
|
|
103
|
-
/**
|
|
104
|
-
* #action
|
|
105
|
-
*/
|
|
106
60
|
removeRefreshToken() {
|
|
107
61
|
localStorage.removeItem(self.refreshTokenKey);
|
|
108
62
|
},
|
|
109
|
-
/**
|
|
110
|
-
* #method
|
|
111
|
-
*/
|
|
112
63
|
retrieveRefreshToken() {
|
|
113
64
|
return localStorage.getItem(self.refreshTokenKey);
|
|
114
65
|
},
|
|
115
|
-
/**
|
|
116
|
-
* #action
|
|
117
|
-
*/
|
|
118
66
|
async exchangeAuthorizationForAccessToken(token, redirectUri) {
|
|
119
67
|
const params = new URLSearchParams(Object.entries({
|
|
120
68
|
code: token,
|
|
@@ -139,9 +87,6 @@ const stateModelFactory = (configSchema) => {
|
|
|
139
87
|
this.storeRefreshToken(token);
|
|
140
88
|
});
|
|
141
89
|
},
|
|
142
|
-
/**
|
|
143
|
-
* #action
|
|
144
|
-
*/
|
|
145
90
|
async exchangeRefreshForAccessToken(refreshToken) {
|
|
146
91
|
const response = await fetch(self.tokenEndpoint, {
|
|
147
92
|
method: 'POST',
|
|
@@ -172,27 +117,15 @@ const stateModelFactory = (configSchema) => {
|
|
|
172
117
|
let listener;
|
|
173
118
|
let exchangedTokenPromise = undefined;
|
|
174
119
|
return {
|
|
175
|
-
/**
|
|
176
|
-
* #action
|
|
177
|
-
* used to listen to child window for auth code/token
|
|
178
|
-
*/
|
|
179
120
|
addMessageChannel(resolve, reject) {
|
|
180
121
|
listener = event => {
|
|
181
|
-
// this should probably get better handling, but ignored for now
|
|
182
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
183
122
|
this.finishOAuthWindow(event, resolve, reject);
|
|
184
123
|
};
|
|
185
124
|
window.addEventListener('message', listener);
|
|
186
125
|
},
|
|
187
|
-
/**
|
|
188
|
-
* #action
|
|
189
|
-
*/
|
|
190
126
|
deleteMessageChannel() {
|
|
191
127
|
window.removeEventListener('message', listener);
|
|
192
128
|
},
|
|
193
|
-
/**
|
|
194
|
-
* #action
|
|
195
|
-
*/
|
|
196
129
|
async finishOAuthWindow(event, resolve, reject) {
|
|
197
130
|
if (event.data.name !== `JBrowseAuthWindow-${self.internetAccountId}`) {
|
|
198
131
|
this.deleteMessageChannel();
|
|
@@ -245,11 +178,6 @@ const stateModelFactory = (configSchema) => {
|
|
|
245
178
|
}
|
|
246
179
|
this.deleteMessageChannel();
|
|
247
180
|
},
|
|
248
|
-
/**
|
|
249
|
-
* #action
|
|
250
|
-
* opens external OAuth flow, popup for web and new browser window for
|
|
251
|
-
* desktop
|
|
252
|
-
*/
|
|
253
181
|
async useEndpointForAuthorization(resolve, reject) {
|
|
254
182
|
const redirectUri = util_1.isElectron
|
|
255
183
|
? 'http://localhost/auth'
|
|
@@ -284,22 +212,15 @@ const stateModelFactory = (configSchema) => {
|
|
|
284
212
|
const eventFromDesktop = new MessageEvent('message', {
|
|
285
213
|
data: { name: eventName, redirectUri: redirectUri },
|
|
286
214
|
});
|
|
287
|
-
// may want to improve handling
|
|
288
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
289
215
|
this.finishOAuthWindow(eventFromDesktop, resolve, reject);
|
|
290
216
|
}
|
|
291
217
|
else {
|
|
292
218
|
window.open(url, eventName, 'width=500,height=600,left=0,top=0');
|
|
293
219
|
}
|
|
294
220
|
},
|
|
295
|
-
/**
|
|
296
|
-
* #action
|
|
297
|
-
*/
|
|
298
221
|
async getTokenFromUser(resolve, reject) {
|
|
299
222
|
const refreshToken = self.retrieveRefreshToken();
|
|
300
223
|
let doUserFlow = true;
|
|
301
|
-
// if there is a refresh token, then try it out, and only if that
|
|
302
|
-
// refresh token succeeds, set doUserFlow to false
|
|
303
224
|
if (refreshToken) {
|
|
304
225
|
try {
|
|
305
226
|
const token = await self.exchangeRefreshForAccessToken(refreshToken);
|
|
@@ -313,14 +234,9 @@ const stateModelFactory = (configSchema) => {
|
|
|
313
234
|
}
|
|
314
235
|
if (doUserFlow) {
|
|
315
236
|
this.addMessageChannel(resolve, reject);
|
|
316
|
-
// may want to improve handling
|
|
317
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
318
237
|
this.useEndpointForAuthorization(resolve, reject);
|
|
319
238
|
}
|
|
320
239
|
},
|
|
321
|
-
/**
|
|
322
|
-
* #action
|
|
323
|
-
*/
|
|
324
240
|
async validateToken(token, location) {
|
|
325
241
|
const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token);
|
|
326
242
|
const response = await fetch(location.uri, newInit);
|
|
@@ -339,7 +255,6 @@ const stateModelFactory = (configSchema) => {
|
|
|
339
255
|
}
|
|
340
256
|
catch (err) {
|
|
341
257
|
console.error('Token could not be refreshed', err);
|
|
342
|
-
// let original error be thrown
|
|
343
258
|
}
|
|
344
259
|
}
|
|
345
260
|
throw new Error(await (0, util_3.getResponseError)({
|
|
@@ -354,16 +269,6 @@ const stateModelFactory = (configSchema) => {
|
|
|
354
269
|
.actions(self => {
|
|
355
270
|
const superGetFetcher = self.getFetcher;
|
|
356
271
|
return {
|
|
357
|
-
/**
|
|
358
|
-
* #action
|
|
359
|
-
* Get a fetch method that will add any needed authentication headers
|
|
360
|
-
* to the request before sending it. If location is provided, it will
|
|
361
|
-
* be checked to see if it includes a token in it's pre-auth
|
|
362
|
-
* information.
|
|
363
|
-
*
|
|
364
|
-
* @param loc - UriLocation of the resource
|
|
365
|
-
* @returns A function that can be used to fetch
|
|
366
|
-
*/
|
|
367
272
|
getFetcher(loc) {
|
|
368
273
|
const fetcher = superGetFetcher(loc);
|
|
369
274
|
return async (input, init) => {
|
package/dist/OAuthModel/util.js
CHANGED
|
@@ -35,7 +35,6 @@ async function generateChallenge(val) {
|
|
|
35
35
|
const Base64 = await Promise.resolve().then(() => __importStar(require('crypto-js/enc-base64')));
|
|
36
36
|
return fixup(Base64.stringify(sha256(val)));
|
|
37
37
|
}
|
|
38
|
-
// if response is JSON, checks if it needs to remove tokens in error, or just plain throw
|
|
39
38
|
function processError(text, invalidErrorCb) {
|
|
40
39
|
var _a;
|
|
41
40
|
try {
|
|
@@ -46,7 +45,6 @@ function processError(text, invalidErrorCb) {
|
|
|
46
45
|
return (_a = obj === null || obj === void 0 ? void 0 : obj.error_description) !== null && _a !== void 0 ? _a : text;
|
|
47
46
|
}
|
|
48
47
|
catch (e) {
|
|
49
|
-
/* response text is not json, just use original text as error */
|
|
50
48
|
}
|
|
51
49
|
return text;
|
|
52
50
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Plugin from '@jbrowse/core/Plugin';
|
|
2
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
3
2
|
import { modelFactory as GoogleDriveOAuthInternetAccountModelFactory } from './GoogleDriveOAuthModel';
|
|
3
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
4
4
|
export default class AuthenticationPlugin extends Plugin {
|
|
5
5
|
name: string;
|
|
6
6
|
exports: {
|
package/dist/index.js
CHANGED
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.GoogleDriveOAuthInternetAccountModelFactory = exports.GoogleDriveOAuthConfigSchema = exports.DropboxOAuthInternetAccountModelFactory = exports.DropboxOAuthConfigSchema = exports.HTTPBasicInternetAccountModelFactory = exports.HTTPBasicConfigSchema = exports.ExternalTokenInternetAccountModelFactory = exports.ExternalTokenConfigSchema = exports.OAuthInternetAccountModelFactory = exports.OAuthConfigSchema = void 0;
|
|
7
7
|
const Plugin_1 = __importDefault(require("@jbrowse/core/Plugin"));
|
|
8
8
|
const InternetAccountType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/InternetAccountType"));
|
|
9
|
-
const OAuthModel_1 = require("./OAuthModel");
|
|
10
|
-
const ExternalTokenModel_1 = require("./ExternalTokenModel");
|
|
11
|
-
const HTTPBasicModel_1 = require("./HTTPBasicModel");
|
|
12
9
|
const DropboxOAuthModel_1 = require("./DropboxOAuthModel");
|
|
10
|
+
const ExternalTokenModel_1 = require("./ExternalTokenModel");
|
|
13
11
|
const GoogleDriveOAuthModel_1 = require("./GoogleDriveOAuthModel");
|
|
12
|
+
const HTTPBasicModel_1 = require("./HTTPBasicModel");
|
|
13
|
+
const OAuthModel_1 = require("./OAuthModel");
|
|
14
14
|
class AuthenticationPlugin extends Plugin_1.default {
|
|
15
15
|
constructor() {
|
|
16
16
|
super(...arguments);
|
|
@@ -1,32 +1,20 @@
|
|
|
1
|
-
import { Instance } from 'mobx-state-tree';
|
|
1
|
+
import type { Instance } from 'mobx-state-tree';
|
|
2
2
|
declare const DropboxOAuthConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
|
|
3
|
-
/**
|
|
4
|
-
* #slot
|
|
5
|
-
*/
|
|
6
3
|
authEndpoint: {
|
|
7
4
|
description: string;
|
|
8
5
|
type: string;
|
|
9
6
|
defaultValue: string;
|
|
10
7
|
};
|
|
11
|
-
/**
|
|
12
|
-
* #slot
|
|
13
|
-
*/
|
|
14
8
|
tokenEndpoint: {
|
|
15
9
|
description: string;
|
|
16
10
|
type: string;
|
|
17
11
|
defaultValue: string;
|
|
18
12
|
};
|
|
19
|
-
/**
|
|
20
|
-
* #slot
|
|
21
|
-
*/
|
|
22
13
|
needsPKCE: {
|
|
23
14
|
description: string;
|
|
24
15
|
type: string;
|
|
25
16
|
defaultValue: boolean;
|
|
26
17
|
};
|
|
27
|
-
/**
|
|
28
|
-
* #slot
|
|
29
|
-
*/
|
|
30
18
|
domains: {
|
|
31
19
|
description: string;
|
|
32
20
|
type: string;
|