@jbrowse/plugin-authentication 3.6.5 → 4.0.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.
Files changed (85) hide show
  1. package/esm/DropboxOAuthModel/configSchema.d.ts +5 -5
  2. package/esm/DropboxOAuthModel/configSchema.js +1 -1
  3. package/esm/DropboxOAuthModel/index.d.ts +2 -2
  4. package/esm/DropboxOAuthModel/index.js +2 -2
  5. package/esm/DropboxOAuthModel/model.d.ts +18 -18
  6. package/esm/DropboxOAuthModel/model.js +5 -5
  7. package/esm/DropboxOAuthModel/util.js +1 -1
  8. package/esm/ExternalTokenModel/configSchema.d.ts +4 -4
  9. package/esm/ExternalTokenModel/index.d.ts +2 -2
  10. package/esm/ExternalTokenModel/index.js +2 -2
  11. package/esm/ExternalTokenModel/model.d.ts +13 -13
  12. package/esm/ExternalTokenModel/model.js +2 -2
  13. package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +1 -0
  14. package/esm/GoogleDriveOAuthModel/configSchema.d.ts +5 -5
  15. package/esm/GoogleDriveOAuthModel/configSchema.js +1 -1
  16. package/esm/GoogleDriveOAuthModel/index.d.ts +2 -2
  17. package/esm/GoogleDriveOAuthModel/index.js +2 -2
  18. package/esm/GoogleDriveOAuthModel/model.d.ts +19 -19
  19. package/esm/GoogleDriveOAuthModel/model.js +7 -7
  20. package/esm/GoogleDriveOAuthModel/util.js +1 -1
  21. package/esm/HTTPBasicModel/configSchema.d.ts +4 -4
  22. package/esm/HTTPBasicModel/index.d.ts +2 -2
  23. package/esm/HTTPBasicModel/index.js +2 -2
  24. package/esm/HTTPBasicModel/model.d.ts +13 -13
  25. package/esm/HTTPBasicModel/model.js +3 -3
  26. package/esm/OAuthModel/configSchema.d.ts +4 -4
  27. package/esm/OAuthModel/index.d.ts +2 -2
  28. package/esm/OAuthModel/index.js +2 -2
  29. package/esm/OAuthModel/model.d.ts +12 -12
  30. package/esm/OAuthModel/model.js +3 -3
  31. package/esm/OAuthModel/util.js +1 -2
  32. package/esm/index.d.ts +68 -68
  33. package/esm/index.js +23 -26
  34. package/esm/util.js +1 -1
  35. package/package.json +23 -30
  36. package/dist/DropboxOAuthModel/DropboxIcon.d.ts +0 -2
  37. package/dist/DropboxOAuthModel/DropboxIcon.js +0 -8
  38. package/dist/DropboxOAuthModel/configSchema.d.ts +0 -93
  39. package/dist/DropboxOAuthModel/configSchema.js +0 -42
  40. package/dist/DropboxOAuthModel/index.d.ts +0 -2
  41. package/dist/DropboxOAuthModel/index.js +0 -10
  42. package/dist/DropboxOAuthModel/model.d.ts +0 -279
  43. package/dist/DropboxOAuthModel/model.js +0 -65
  44. package/dist/DropboxOAuthModel/util.d.ts +0 -1
  45. package/dist/DropboxOAuthModel/util.js +0 -21
  46. package/dist/ExternalTokenModel/ExternalTokenEntryForm.d.ts +0 -4
  47. package/dist/ExternalTokenModel/ExternalTokenEntryForm.js +0 -24
  48. package/dist/ExternalTokenModel/configSchema.d.ts +0 -37
  49. package/dist/ExternalTokenModel/configSchema.js +0 -16
  50. package/dist/ExternalTokenModel/index.d.ts +0 -2
  51. package/dist/ExternalTokenModel/index.js +0 -10
  52. package/dist/ExternalTokenModel/model.d.ts +0 -126
  53. package/dist/ExternalTokenModel/model.js +0 -57
  54. package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +0 -15
  55. package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +0 -19
  56. package/dist/GoogleDriveOAuthModel/GoogleDriveIcon.d.ts +0 -2
  57. package/dist/GoogleDriveOAuthModel/GoogleDriveIcon.js +0 -8
  58. package/dist/GoogleDriveOAuthModel/configSchema.d.ts +0 -93
  59. package/dist/GoogleDriveOAuthModel/configSchema.js +0 -34
  60. package/dist/GoogleDriveOAuthModel/index.d.ts +0 -2
  61. package/dist/GoogleDriveOAuthModel/index.js +0 -10
  62. package/dist/GoogleDriveOAuthModel/model.d.ts +0 -283
  63. package/dist/GoogleDriveOAuthModel/model.js +0 -72
  64. package/dist/GoogleDriveOAuthModel/util.d.ts +0 -1
  65. package/dist/GoogleDriveOAuthModel/util.js +0 -14
  66. package/dist/HTTPBasicModel/HTTPBasicLoginForm.d.ts +0 -4
  67. package/dist/HTTPBasicModel/HTTPBasicLoginForm.js +0 -32
  68. package/dist/HTTPBasicModel/configSchema.d.ts +0 -42
  69. package/dist/HTTPBasicModel/configSchema.js +0 -21
  70. package/dist/HTTPBasicModel/index.d.ts +0 -2
  71. package/dist/HTTPBasicModel/index.js +0 -10
  72. package/dist/HTTPBasicModel/model.d.ts +0 -131
  73. package/dist/HTTPBasicModel/model.js +0 -54
  74. package/dist/OAuthModel/configSchema.d.ts +0 -72
  75. package/dist/OAuthModel/configSchema.js +0 -51
  76. package/dist/OAuthModel/index.d.ts +0 -2
  77. package/dist/OAuthModel/index.js +0 -10
  78. package/dist/OAuthModel/model.d.ts +0 -182
  79. package/dist/OAuthModel/model.js +0 -289
  80. package/dist/OAuthModel/util.d.ts +0 -7
  81. package/dist/OAuthModel/util.js +0 -66
  82. package/dist/index.d.ts +0 -1026
  83. package/dist/index.js +0 -84
  84. package/dist/util.d.ts +0 -6
  85. package/dist/util.js +0 -21
@@ -1,283 +0,0 @@
1
- import { GoogleDriveFile } from './GoogleDriveFilehandle';
2
- import type { GoogleDriveOAuthInternetAccountConfigModel } from './configSchema';
3
- import type { UriLocation } from '@jbrowse/core/util/types';
4
- import type { Instance } from 'mobx-state-tree';
5
- export interface RequestInitWithMetadata extends RequestInit {
6
- metadataOnly?: boolean;
7
- }
8
- export default function stateModelFactory(configSchema: GoogleDriveOAuthInternetAccountConfigModel): import("mobx-state-tree").IModelType<{
9
- id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
10
- type: import("mobx-state-tree").ISimpleType<string>;
11
- configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
12
- name: {
13
- description: string;
14
- type: string;
15
- defaultValue: string;
16
- };
17
- description: {
18
- description: string;
19
- type: string;
20
- defaultValue: string;
21
- };
22
- authHeader: {
23
- description: string;
24
- type: string;
25
- defaultValue: string;
26
- };
27
- tokenType: {
28
- description: string;
29
- type: string;
30
- defaultValue: string;
31
- };
32
- domains: {
33
- description: string;
34
- type: string;
35
- defaultValue: never[];
36
- };
37
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>;
38
- } & {
39
- type: import("mobx-state-tree").ISimpleType<"OAuthInternetAccount">;
40
- configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
41
- tokenType: {
42
- description: string;
43
- type: string;
44
- defaultValue: string;
45
- };
46
- authEndpoint: {
47
- description: string;
48
- type: string;
49
- defaultValue: string;
50
- };
51
- tokenEndpoint: {
52
- description: string;
53
- type: string;
54
- defaultValue: string;
55
- };
56
- needsPKCE: {
57
- description: string;
58
- type: string;
59
- defaultValue: boolean;
60
- };
61
- clientId: {
62
- description: string;
63
- type: string;
64
- defaultValue: string;
65
- };
66
- scopes: {
67
- description: string;
68
- type: string;
69
- defaultValue: string;
70
- };
71
- state: {
72
- description: string;
73
- type: string;
74
- defaultValue: string;
75
- };
76
- responseType: {
77
- description: string;
78
- type: string;
79
- defaultValue: string;
80
- };
81
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
82
- name: {
83
- description: string;
84
- type: string;
85
- defaultValue: string;
86
- };
87
- description: {
88
- description: string;
89
- type: string;
90
- defaultValue: string;
91
- };
92
- authHeader: {
93
- description: string;
94
- type: string;
95
- defaultValue: string;
96
- };
97
- tokenType: {
98
- description: string;
99
- type: string;
100
- defaultValue: string;
101
- };
102
- domains: {
103
- description: string;
104
- type: string;
105
- defaultValue: never[];
106
- };
107
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
108
- } & {
109
- type: import("mobx-state-tree").ISimpleType<"GoogleDriveOAuthInternetAccount">;
110
- configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
111
- authEndpoint: {
112
- description: string;
113
- type: string;
114
- defaultValue: string;
115
- };
116
- scopes: {
117
- description: string;
118
- type: string;
119
- defaultValue: string;
120
- };
121
- domains: {
122
- description: string;
123
- type: string;
124
- defaultValue: string[];
125
- };
126
- responseType: {
127
- description: string;
128
- type: string;
129
- defaultValue: string;
130
- };
131
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
132
- tokenType: {
133
- description: string;
134
- type: string;
135
- defaultValue: string;
136
- };
137
- authEndpoint: {
138
- description: string;
139
- type: string;
140
- defaultValue: string;
141
- };
142
- tokenEndpoint: {
143
- description: string;
144
- type: string;
145
- defaultValue: string;
146
- };
147
- needsPKCE: {
148
- description: string;
149
- type: string;
150
- defaultValue: boolean;
151
- };
152
- clientId: {
153
- description: string;
154
- type: string;
155
- defaultValue: string;
156
- };
157
- scopes: {
158
- description: string;
159
- type: string;
160
- defaultValue: string;
161
- };
162
- state: {
163
- description: string;
164
- type: string;
165
- defaultValue: string;
166
- };
167
- responseType: {
168
- description: string;
169
- type: string;
170
- defaultValue: string;
171
- };
172
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
173
- name: {
174
- description: string;
175
- type: string;
176
- defaultValue: string;
177
- };
178
- description: {
179
- description: string;
180
- type: string;
181
- defaultValue: string;
182
- };
183
- authHeader: {
184
- description: string;
185
- type: string;
186
- defaultValue: string;
187
- };
188
- tokenType: {
189
- description: string;
190
- type: string;
191
- defaultValue: string;
192
- };
193
- domains: {
194
- description: string;
195
- type: string;
196
- defaultValue: never[];
197
- };
198
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>, undefined>>;
199
- }, {
200
- readonly name: string;
201
- readonly description: string;
202
- readonly internetAccountId: string;
203
- readonly authHeader: string;
204
- readonly tokenType: string;
205
- readonly domains: string[];
206
- readonly toggleContents: React.ReactNode;
207
- readonly SelectorComponent: import("@jbrowse/core/util/types").AnyReactComponentType | undefined;
208
- readonly selectorLabel: string | undefined;
209
- } & {
210
- handlesLocation(location: UriLocation): boolean;
211
- readonly tokenKey: string;
212
- } & {
213
- getTokenFromUser(_resolve: (token: string) => void, _reject: (error: Error) => void): void;
214
- storeToken(token: string): void;
215
- removeToken(): void;
216
- retrieveToken(): string | null;
217
- validateToken(token: string, _loc: UriLocation): Promise<string>;
218
- } & {
219
- getToken(location?: UriLocation): Promise<string>;
220
- } & {
221
- addAuthHeaderToInit(init?: RequestInit, token?: string): {
222
- headers: Headers;
223
- body?: BodyInit | null;
224
- cache?: RequestCache;
225
- credentials?: RequestCredentials;
226
- integrity?: string;
227
- keepalive?: boolean;
228
- method?: string;
229
- mode?: RequestMode;
230
- priority?: RequestPriority;
231
- redirect?: RequestRedirect;
232
- referrer?: string;
233
- referrerPolicy?: ReferrerPolicy;
234
- signal?: AbortSignal | null;
235
- window?: null;
236
- };
237
- getPreAuthorizationInformation(location: UriLocation): Promise<{
238
- internetAccountType: string;
239
- authInfo: {
240
- token: string;
241
- configuration: any;
242
- };
243
- }>;
244
- } & {
245
- getFetcher(loc?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
246
- } & {
247
- openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
248
- } & {
249
- readonly codeVerifierPKCE: string;
250
- } & {
251
- readonly authEndpoint: string;
252
- readonly tokenEndpoint: string;
253
- readonly needsPKCE: boolean;
254
- readonly clientId: string;
255
- readonly scopes: string;
256
- state(): string | undefined;
257
- readonly responseType: "token" | "code";
258
- readonly refreshTokenKey: string;
259
- } & {
260
- storeRefreshToken(refreshToken: string): void;
261
- removeRefreshToken(): void;
262
- retrieveRefreshToken(): string | null;
263
- exchangeAuthorizationForAccessToken(token: string, redirectUri: string): Promise<string>;
264
- exchangeRefreshForAccessToken(refreshToken: string): Promise<string>;
265
- } & {
266
- addMessageChannel(resolve: (token: string) => void, reject: (error: Error) => void): void;
267
- deleteMessageChannel(): void;
268
- finishOAuthWindow(event: MessageEvent, resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
269
- useEndpointForAuthorization(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
270
- getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
271
- validateToken(token: string, location: UriLocation): Promise<string>;
272
- } & {
273
- getFetcher(loc?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
274
- } & {
275
- readonly toggleContents: import("react/jsx-runtime").JSX.Element;
276
- readonly selectorLabel: string;
277
- } & {
278
- getFetcher(location?: UriLocation): (input: RequestInfo, init?: RequestInitWithMetadata) => Promise<Response>;
279
- openLocation(location: UriLocation): GoogleDriveFile;
280
- validateToken(token: string, location: UriLocation): Promise<string>;
281
- }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
282
- export type GoogleDriveOAuthStateModel = ReturnType<typeof stateModelFactory>;
283
- export type GoogleDriveOAuthModel = Instance<GoogleDriveOAuthStateModel>;
@@ -1,72 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.default = stateModelFactory;
7
- const jsx_runtime_1 = require("react/jsx-runtime");
8
- const configuration_1 = require("@jbrowse/core/configuration");
9
- const mobx_state_tree_1 = require("mobx-state-tree");
10
- const OAuthModel_1 = require("../OAuthModel");
11
- const GoogleDriveFilehandle_1 = require("./GoogleDriveFilehandle");
12
- const GoogleDriveIcon_1 = __importDefault(require("./GoogleDriveIcon"));
13
- const util_1 = require("./util");
14
- const model_1 = __importDefault(require("../OAuthModel/model"));
15
- function getUri(str) {
16
- const urlId = /[-\w]{25,}/.exec(str);
17
- return `https://www.googleapis.com/drive/v3/files/${urlId}`;
18
- }
19
- function stateModelFactory(configSchema) {
20
- return (0, model_1.default)(OAuthModel_1.configSchema)
21
- .named('GoogleDriveOAuthInternetAccount')
22
- .props({
23
- type: mobx_state_tree_1.types.literal('GoogleDriveOAuthInternetAccount'),
24
- configuration: (0, configuration_1.ConfigurationReference)(configSchema),
25
- })
26
- .views(() => ({
27
- get toggleContents() {
28
- return (0, jsx_runtime_1.jsx)(GoogleDriveIcon_1.default, {});
29
- },
30
- get selectorLabel() {
31
- return 'Enter Google Drive share link';
32
- },
33
- }))
34
- .actions(self => ({
35
- getFetcher(location) {
36
- return async (input, init) => {
37
- const driveUrl = new URL(getUri(String(input)));
38
- const searchParams = new URLSearchParams();
39
- if (init === null || init === void 0 ? void 0 : init.metadataOnly) {
40
- searchParams.append('fields', 'size');
41
- }
42
- else {
43
- searchParams.append('alt', 'media');
44
- }
45
- driveUrl.search = searchParams.toString();
46
- const authToken = await self.getToken(location);
47
- const response = await fetch(driveUrl, self.addAuthHeaderToInit({ ...init, method: 'GET', credentials: 'same-origin' }, authToken));
48
- if (!response.ok) {
49
- throw new Error(await (0, util_1.getDescriptiveErrorMessage)(response));
50
- }
51
- return response;
52
- };
53
- },
54
- openLocation(location) {
55
- return new GoogleDriveFilehandle_1.GoogleDriveFile(location.uri, {
56
- fetch: this.getFetcher(location),
57
- });
58
- },
59
- async validateToken(token, location) {
60
- const response = await fetch(getUri(location.uri), {
61
- headers: {
62
- Authorization: `Bearer ${token}`,
63
- 'Content-Type': 'application/x-www-form-urlencoded',
64
- },
65
- });
66
- if (!response.ok) {
67
- throw new Error(await (0, util_1.getDescriptiveErrorMessage)(response, 'Token could not be validated'));
68
- }
69
- return token;
70
- },
71
- }));
72
- }
@@ -1 +0,0 @@
1
- export declare function getDescriptiveErrorMessage(response: Response, reason?: string): Promise<string>;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDescriptiveErrorMessage = getDescriptiveErrorMessage;
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
- }
13
- return (0, util_1.getResponseError)({ response, reason, statusText: errorMessage });
14
- }
@@ -1,4 +0,0 @@
1
- export declare function HTTPBasicLoginForm({ internetAccountId, handleClose, }: {
2
- internetAccountId: string;
3
- handleClose: (arg?: string) => void;
4
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HTTPBasicLoginForm = HTTPBasicLoginForm;
4
- const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const ui_1 = require("@jbrowse/core/ui");
7
- const material_1 = require("@mui/material");
8
- function HTTPBasicLoginForm({ internetAccountId, handleClose, }) {
9
- const [username, setUsername] = (0, react_1.useState)('');
10
- const [password, setPassword] = (0, react_1.useState)('');
11
- return ((0, jsx_runtime_1.jsx)(ui_1.Dialog, { open: true, maxWidth: "xl", "data-testid": "login-httpbasic", title: `Log in for ${internetAccountId}`, onClose: () => {
12
- handleClose();
13
- }, children: (0, jsx_runtime_1.jsxs)("form", { onSubmit: event => {
14
- if (username && password) {
15
- handleClose(btoa(`${username}:${password}`));
16
- }
17
- else {
18
- handleClose();
19
- }
20
- event.preventDefault();
21
- }, children: [(0, jsx_runtime_1.jsxs)(material_1.DialogContent, { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, label: "Username", variant: "outlined", onChange: event => {
22
- setUsername(event.target.value);
23
- }, margin: "dense", slotProps: {
24
- htmlInput: { 'data-testid': 'login-httpbasic-username' },
25
- } }), (0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, label: "Password", type: "password", autoComplete: "current-password", variant: "outlined", onChange: event => {
26
- setPassword(event.target.value);
27
- }, margin: "dense", slotProps: {
28
- htmlInput: { 'data-testid': 'login-httpbasic-password' },
29
- } })] }), (0, jsx_runtime_1.jsxs)(material_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "primary", type: "submit", children: "Submit" }), (0, jsx_runtime_1.jsx)(material_1.Button, { variant: "contained", color: "secondary", type: "submit", onClick: () => {
30
- handleClose();
31
- }, children: "Cancel" })] })] }) }));
32
- }
@@ -1,42 +0,0 @@
1
- import type { Instance } from 'mobx-state-tree';
2
- declare const HTTPBasicConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
3
- tokenType: {
4
- description: string;
5
- type: string;
6
- defaultValue: string;
7
- };
8
- validateWithHEAD: {
9
- description: string;
10
- type: string;
11
- defaultValue: boolean;
12
- };
13
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
14
- name: {
15
- description: string;
16
- type: string;
17
- defaultValue: string;
18
- };
19
- description: {
20
- description: string;
21
- type: string;
22
- defaultValue: string;
23
- };
24
- authHeader: {
25
- description: string;
26
- type: string;
27
- defaultValue: string;
28
- };
29
- tokenType: {
30
- description: string;
31
- type: string;
32
- defaultValue: string;
33
- };
34
- domains: {
35
- description: string;
36
- type: string;
37
- defaultValue: never[];
38
- };
39
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
40
- export type HTTPBasicInternetAccountConfigModel = typeof HTTPBasicConfigSchema;
41
- export type HTTPBasicInternetAccountConfig = Instance<HTTPBasicInternetAccountConfigModel>;
42
- export default HTTPBasicConfigSchema;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const configuration_1 = require("@jbrowse/core/configuration");
4
- const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
5
- function x() { }
6
- const HTTPBasicConfigSchema = (0, configuration_1.ConfigurationSchema)('HTTPBasicInternetAccount', {
7
- tokenType: {
8
- description: 'a custom name for a token to include in the header',
9
- type: 'string',
10
- defaultValue: 'Basic',
11
- },
12
- validateWithHEAD: {
13
- description: 'validate the token with a HEAD request before using it',
14
- type: 'boolean',
15
- defaultValue: true,
16
- },
17
- }, {
18
- baseConfiguration: models_1.BaseInternetAccountConfig,
19
- explicitlyTyped: true,
20
- });
21
- exports.default = HTTPBasicConfigSchema;
@@ -1,2 +0,0 @@
1
- export { default as configSchema } from './configSchema';
2
- export { default as modelFactory } from './model';
@@ -1,10 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.modelFactory = exports.configSchema = void 0;
7
- var configSchema_1 = require("./configSchema");
8
- Object.defineProperty(exports, "configSchema", { enumerable: true, get: function () { return __importDefault(configSchema_1).default; } });
9
- var model_1 = require("./model");
10
- Object.defineProperty(exports, "modelFactory", { enumerable: true, get: function () { return __importDefault(model_1).default; } });
@@ -1,131 +0,0 @@
1
- import type { HTTPBasicInternetAccountConfigModel } from './configSchema';
2
- import type { UriLocation } from '@jbrowse/core/util/types';
3
- import type { Instance } from 'mobx-state-tree';
4
- declare const stateModelFactory: (configSchema: HTTPBasicInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
5
- id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
6
- type: import("mobx-state-tree").ISimpleType<string>;
7
- configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
8
- name: {
9
- description: string;
10
- type: string;
11
- defaultValue: string;
12
- };
13
- description: {
14
- description: string;
15
- type: string;
16
- defaultValue: string;
17
- };
18
- authHeader: {
19
- description: string;
20
- type: string;
21
- defaultValue: string;
22
- };
23
- tokenType: {
24
- description: string;
25
- type: string;
26
- defaultValue: string;
27
- };
28
- domains: {
29
- description: string;
30
- type: string;
31
- defaultValue: never[];
32
- };
33
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>;
34
- } & {
35
- type: import("mobx-state-tree").ISimpleType<"HTTPBasicInternetAccount">;
36
- configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
37
- tokenType: {
38
- description: string;
39
- type: string;
40
- defaultValue: string;
41
- };
42
- validateWithHEAD: {
43
- description: string;
44
- type: string;
45
- defaultValue: boolean;
46
- };
47
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
48
- name: {
49
- description: string;
50
- type: string;
51
- defaultValue: string;
52
- };
53
- description: {
54
- description: string;
55
- type: string;
56
- defaultValue: string;
57
- };
58
- authHeader: {
59
- description: string;
60
- type: string;
61
- defaultValue: string;
62
- };
63
- tokenType: {
64
- description: string;
65
- type: string;
66
- defaultValue: string;
67
- };
68
- domains: {
69
- description: string;
70
- type: string;
71
- defaultValue: never[];
72
- };
73
- }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
74
- }, {
75
- readonly name: string;
76
- readonly description: string;
77
- readonly internetAccountId: string;
78
- readonly authHeader: string;
79
- readonly tokenType: string;
80
- readonly domains: string[];
81
- readonly toggleContents: React.ReactNode;
82
- readonly SelectorComponent: import("@jbrowse/core/util/types").AnyReactComponentType | undefined;
83
- readonly selectorLabel: string | undefined;
84
- } & {
85
- handlesLocation(location: UriLocation): boolean;
86
- readonly tokenKey: string;
87
- } & {
88
- getTokenFromUser(_resolve: (token: string) => void, _reject: (error: Error) => void): void;
89
- storeToken(token: string): void;
90
- removeToken(): void;
91
- retrieveToken(): string | null;
92
- validateToken(token: string, _loc: UriLocation): Promise<string>;
93
- } & {
94
- getToken(location?: UriLocation): Promise<string>;
95
- } & {
96
- addAuthHeaderToInit(init?: RequestInit, token?: string): {
97
- headers: Headers;
98
- body?: BodyInit | null;
99
- cache?: RequestCache;
100
- credentials?: RequestCredentials;
101
- integrity?: string;
102
- keepalive?: boolean;
103
- method?: string;
104
- mode?: RequestMode;
105
- priority?: RequestPriority;
106
- redirect?: RequestRedirect;
107
- referrer?: string;
108
- referrerPolicy?: ReferrerPolicy;
109
- signal?: AbortSignal | null;
110
- window?: null;
111
- };
112
- getPreAuthorizationInformation(location: UriLocation): Promise<{
113
- internetAccountType: string;
114
- authInfo: {
115
- token: string;
116
- configuration: any;
117
- };
118
- }>;
119
- } & {
120
- getFetcher(loc?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
121
- } & {
122
- openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
123
- } & {
124
- readonly validateWithHEAD: boolean;
125
- } & {
126
- getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
127
- validateToken(token: string, location: UriLocation): Promise<string>;
128
- }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
129
- export default stateModelFactory;
130
- export type HTTPBasicStateModel = ReturnType<typeof stateModelFactory>;
131
- export type HTTPBasicModel = Instance<HTTPBasicStateModel>;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const configuration_1 = require("@jbrowse/core/configuration");
4
- const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
5
- const mobx_state_tree_1 = require("mobx-state-tree");
6
- const HTTPBasicLoginForm_1 = require("./HTTPBasicLoginForm");
7
- const util_1 = require("../util");
8
- const stateModelFactory = (configSchema) => {
9
- return models_1.InternetAccount.named('HTTPBasicInternetAccount')
10
- .props({
11
- type: mobx_state_tree_1.types.literal('HTTPBasicInternetAccount'),
12
- configuration: (0, configuration_1.ConfigurationReference)(configSchema),
13
- })
14
- .views(self => ({
15
- get validateWithHEAD() {
16
- return (0, configuration_1.getConf)(self, 'validateWithHEAD');
17
- },
18
- }))
19
- .actions(self => ({
20
- getTokenFromUser(resolve, reject) {
21
- const { session } = (0, mobx_state_tree_1.getRoot)(self);
22
- session.queueDialog((doneCallback) => [
23
- HTTPBasicLoginForm_1.HTTPBasicLoginForm,
24
- {
25
- internetAccountId: self.internetAccountId,
26
- handleClose: (token) => {
27
- if (token) {
28
- resolve(token);
29
- }
30
- else {
31
- reject(new Error('User cancelled entry'));
32
- }
33
- doneCallback();
34
- },
35
- },
36
- ]);
37
- },
38
- async validateToken(token, location) {
39
- if (!self.validateWithHEAD) {
40
- return token;
41
- }
42
- const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token);
43
- const response = await fetch(location.uri, newInit);
44
- if (!response.ok) {
45
- throw new Error(await (0, util_1.getResponseError)({
46
- response,
47
- reason: 'Error validating token',
48
- }));
49
- }
50
- return token;
51
- },
52
- }));
53
- };
54
- exports.default = stateModelFactory;