@jbrowse/plugin-authentication 2.2.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/LICENSE +201 -0
- package/dist/DropboxOAuthModel/configSchema.d.ts +5 -0
- package/dist/DropboxOAuthModel/configSchema.js +69 -0
- package/dist/DropboxOAuthModel/configSchema.js.map +1 -0
- package/dist/DropboxOAuthModel/index.d.ts +2 -0
- package/dist/DropboxOAuthModel/index.js +11 -0
- package/dist/DropboxOAuthModel/index.js.map +1 -0
- package/dist/DropboxOAuthModel/model.d.ts +98 -0
- package/dist/DropboxOAuthModel/model.js +103 -0
- package/dist/DropboxOAuthModel/model.js.map +1 -0
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.d.ts +5 -0
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.js +59 -0
- package/dist/ExternalTokenModel/ExternalTokenEntryForm.js.map +1 -0
- package/dist/ExternalTokenModel/configSchema.d.ts +5 -0
- package/dist/ExternalTokenModel/configSchema.js +26 -0
- package/dist/ExternalTokenModel/configSchema.js.map +1 -0
- package/dist/ExternalTokenModel/index.d.ts +2 -0
- package/dist/ExternalTokenModel/index.js +11 -0
- package/dist/ExternalTokenModel/index.js.map +1 -0
- package/dist/ExternalTokenModel/model.d.ts +67 -0
- package/dist/ExternalTokenModel/model.js +59 -0
- package/dist/ExternalTokenModel/model.js.map +1 -0
- package/dist/GoogleDriveOAuthModel/configSchema.d.ts +5 -0
- package/dist/GoogleDriveOAuthModel/configSchema.js +53 -0
- package/dist/GoogleDriveOAuthModel/configSchema.js.map +1 -0
- package/dist/GoogleDriveOAuthModel/index.d.ts +2 -0
- package/dist/GoogleDriveOAuthModel/index.js +11 -0
- package/dist/GoogleDriveOAuthModel/index.js.map +1 -0
- package/dist/GoogleDriveOAuthModel/model.d.ts +111 -0
- package/dist/GoogleDriveOAuthModel/model.js +115 -0
- package/dist/GoogleDriveOAuthModel/model.js.map +1 -0
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.d.ts +5 -0
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.js +55 -0
- package/dist/HTTPBasicModel/HTTPBasicLoginForm.js.map +1 -0
- package/dist/HTTPBasicModel/configSchema.d.ts +5 -0
- package/dist/HTTPBasicModel/configSchema.js +34 -0
- package/dist/HTTPBasicModel/configSchema.js.map +1 -0
- package/dist/HTTPBasicModel/index.d.ts +2 -0
- package/dist/HTTPBasicModel/index.js +11 -0
- package/dist/HTTPBasicModel/index.js.map +1 -0
- package/dist/HTTPBasicModel/model.d.ts +67 -0
- package/dist/HTTPBasicModel/model.js +59 -0
- package/dist/HTTPBasicModel/model.js.map +1 -0
- package/dist/OAuthModel/configSchema.d.ts +5 -0
- package/dist/OAuthModel/configSchema.js +90 -0
- package/dist/OAuthModel/configSchema.js.map +1 -0
- package/dist/OAuthModel/index.d.ts +2 -0
- package/dist/OAuthModel/index.js +11 -0
- package/dist/OAuthModel/index.js.map +1 -0
- package/dist/OAuthModel/model.d.ts +91 -0
- package/dist/OAuthModel/model.js +317 -0
- package/dist/OAuthModel/model.js.map +1 -0
- package/dist/index.d.ts +399 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/esm/DropboxOAuthModel/configSchema.d.ts +5 -0
- package/esm/DropboxOAuthModel/configSchema.js +64 -0
- package/esm/DropboxOAuthModel/configSchema.js.map +1 -0
- package/esm/DropboxOAuthModel/index.d.ts +2 -0
- package/esm/DropboxOAuthModel/index.js +3 -0
- package/esm/DropboxOAuthModel/index.js.map +1 -0
- package/esm/DropboxOAuthModel/model.d.ts +98 -0
- package/esm/DropboxOAuthModel/model.js +96 -0
- package/esm/DropboxOAuthModel/model.js.map +1 -0
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.d.ts +5 -0
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.js +29 -0
- package/esm/ExternalTokenModel/ExternalTokenEntryForm.js.map +1 -0
- package/esm/ExternalTokenModel/configSchema.d.ts +5 -0
- package/esm/ExternalTokenModel/configSchema.js +24 -0
- package/esm/ExternalTokenModel/configSchema.js.map +1 -0
- package/esm/ExternalTokenModel/index.d.ts +2 -0
- package/esm/ExternalTokenModel/index.js +3 -0
- package/esm/ExternalTokenModel/index.js.map +1 -0
- package/esm/ExternalTokenModel/model.d.ts +67 -0
- package/esm/ExternalTokenModel/model.js +57 -0
- package/esm/ExternalTokenModel/model.js.map +1 -0
- package/esm/GoogleDriveOAuthModel/configSchema.d.ts +5 -0
- package/esm/GoogleDriveOAuthModel/configSchema.js +48 -0
- package/esm/GoogleDriveOAuthModel/configSchema.js.map +1 -0
- package/esm/GoogleDriveOAuthModel/index.d.ts +2 -0
- package/esm/GoogleDriveOAuthModel/index.js +3 -0
- package/esm/GoogleDriveOAuthModel/index.js.map +1 -0
- package/esm/GoogleDriveOAuthModel/model.d.ts +111 -0
- package/esm/GoogleDriveOAuthModel/model.js +108 -0
- package/esm/GoogleDriveOAuthModel/model.js.map +1 -0
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.d.ts +5 -0
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.js +28 -0
- package/esm/HTTPBasicModel/HTTPBasicLoginForm.js.map +1 -0
- package/esm/HTTPBasicModel/configSchema.d.ts +5 -0
- package/esm/HTTPBasicModel/configSchema.js +32 -0
- package/esm/HTTPBasicModel/configSchema.js.map +1 -0
- package/esm/HTTPBasicModel/index.d.ts +2 -0
- package/esm/HTTPBasicModel/index.js +3 -0
- package/esm/HTTPBasicModel/index.js.map +1 -0
- package/esm/HTTPBasicModel/model.d.ts +67 -0
- package/esm/HTTPBasicModel/model.js +57 -0
- package/esm/HTTPBasicModel/model.js.map +1 -0
- package/esm/OAuthModel/configSchema.d.ts +5 -0
- package/esm/OAuthModel/configSchema.js +88 -0
- package/esm/OAuthModel/configSchema.js.map +1 -0
- package/esm/OAuthModel/index.d.ts +2 -0
- package/esm/OAuthModel/index.js +3 -0
- package/esm/OAuthModel/index.js.map +1 -0
- package/esm/OAuthModel/model.d.ts +91 -0
- package/esm/OAuthModel/model.js +289 -0
- package/esm/OAuthModel/model.js.map +1 -0
- package/esm/index.d.ts +399 -0
- package/esm/index.js +64 -0
- package/esm/index.js.map +1 -0
- package/package.json +63 -0
- package/src/DropboxOAuthModel/configSchema.ts +77 -0
- package/src/DropboxOAuthModel/index.ts +2 -0
- package/src/DropboxOAuthModel/model.tsx +141 -0
- package/src/ExternalTokenModel/ExternalTokenEntryForm.tsx +61 -0
- package/src/ExternalTokenModel/configSchema.ts +36 -0
- package/src/ExternalTokenModel/index.ts +2 -0
- package/src/ExternalTokenModel/model.tsx +70 -0
- package/src/GoogleDriveOAuthModel/configSchema.ts +61 -0
- package/src/GoogleDriveOAuthModel/index.ts +2 -0
- package/src/GoogleDriveOAuthModel/model.tsx +174 -0
- package/src/HTTPBasicModel/HTTPBasicLoginForm.tsx +71 -0
- package/src/HTTPBasicModel/configSchema.ts +43 -0
- package/src/HTTPBasicModel/index.ts +2 -0
- package/src/HTTPBasicModel/model.tsx +70 -0
- package/src/OAuthModel/configSchema.ts +98 -0
- package/src/OAuthModel/index.ts +2 -0
- package/src/OAuthModel/model.tsx +357 -0
- package/src/__snapshots__/index.test.js.snap +8 -0
- package/src/index.test.js +96 -0
- package/src/index.ts +97 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { UriLocation } from '@jbrowse/core/util/types';
|
|
3
|
+
import { SvgIconProps } from '@mui/material';
|
|
4
|
+
import { Instance } from 'mobx-state-tree';
|
|
5
|
+
import { DropboxOAuthInternetAccountConfigModel } from './configSchema';
|
|
6
|
+
export declare function DropboxIcon(props: SvgIconProps): JSX.Element;
|
|
7
|
+
declare const stateModelFactory: (configSchema: DropboxOAuthInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
|
|
8
|
+
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
9
|
+
type: import("mobx-state-tree").ISimpleType<string>;
|
|
10
|
+
} & {
|
|
11
|
+
type: import("mobx-state-tree").ISimpleType<"OAuthInternetAccount">;
|
|
12
|
+
configuration: import("mobx-state-tree").ITypeUnion<any, any, any>;
|
|
13
|
+
} & {
|
|
14
|
+
type: import("mobx-state-tree").ISimpleType<"DropboxOAuthInternetAccount">;
|
|
15
|
+
configuration: import("mobx-state-tree").ITypeUnion<any, any, any>;
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly description: string;
|
|
19
|
+
readonly internetAccountId: string;
|
|
20
|
+
readonly authHeader: string;
|
|
21
|
+
readonly tokenType: string;
|
|
22
|
+
readonly domains: string[];
|
|
23
|
+
readonly toggleContents: React.ReactNode;
|
|
24
|
+
readonly SelectorComponent: import("@jbrowse/core/util/types").AnyReactComponentType | undefined;
|
|
25
|
+
readonly selectorLabel: string | undefined;
|
|
26
|
+
} & {
|
|
27
|
+
handlesLocation(location: UriLocation): boolean;
|
|
28
|
+
readonly tokenKey: string;
|
|
29
|
+
} & {
|
|
30
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
31
|
+
storeToken(token: string): void;
|
|
32
|
+
removeToken(): void;
|
|
33
|
+
retrieveToken(): string | null;
|
|
34
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
35
|
+
} & {
|
|
36
|
+
getToken(location?: UriLocation | undefined): Promise<string>;
|
|
37
|
+
} & {
|
|
38
|
+
addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
|
|
39
|
+
headers: Headers;
|
|
40
|
+
body?: BodyInit | null | undefined;
|
|
41
|
+
cache?: RequestCache | undefined;
|
|
42
|
+
credentials?: RequestCredentials | undefined;
|
|
43
|
+
integrity?: string | undefined;
|
|
44
|
+
keepalive?: boolean | undefined;
|
|
45
|
+
method?: string | undefined;
|
|
46
|
+
mode?: RequestMode | undefined;
|
|
47
|
+
redirect?: RequestRedirect | undefined;
|
|
48
|
+
referrer?: string | undefined;
|
|
49
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
50
|
+
signal?: AbortSignal | null | undefined;
|
|
51
|
+
window?: null | undefined;
|
|
52
|
+
};
|
|
53
|
+
getPreAuthorizationInformation(location: UriLocation): Promise<{
|
|
54
|
+
internetAccountType: string;
|
|
55
|
+
authInfo: {
|
|
56
|
+
token: string;
|
|
57
|
+
configuration: any;
|
|
58
|
+
};
|
|
59
|
+
}>;
|
|
60
|
+
} & {
|
|
61
|
+
getFetcher(location?: UriLocation | undefined): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
62
|
+
} & {
|
|
63
|
+
openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
|
|
64
|
+
} & {
|
|
65
|
+
readonly codeVerifierPKCE: string;
|
|
66
|
+
} & {
|
|
67
|
+
readonly authEndpoint: string;
|
|
68
|
+
readonly tokenEndpoint: string;
|
|
69
|
+
readonly needsPKCE: boolean;
|
|
70
|
+
readonly clientId: string;
|
|
71
|
+
readonly scopes: string;
|
|
72
|
+
state(): string | undefined;
|
|
73
|
+
readonly responseType: "code" | "token";
|
|
74
|
+
readonly hasRefreshToken: boolean;
|
|
75
|
+
readonly refreshTokenKey: string;
|
|
76
|
+
} & {
|
|
77
|
+
storeRefreshToken(refreshToken: string): void;
|
|
78
|
+
removeRefreshToken(): void;
|
|
79
|
+
retrieveRefreshToken(): string | null;
|
|
80
|
+
exchangeAuthorizationForAccessToken(token: string, redirectUri: string): Promise<string>;
|
|
81
|
+
exchangeRefreshForAccessToken(refreshToken: string): Promise<string>;
|
|
82
|
+
} & {
|
|
83
|
+
addMessageChannel(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
84
|
+
deleteMessageChannel(): void;
|
|
85
|
+
finishOAuthWindow(event: MessageEvent<any>, resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
86
|
+
useEndpointForAuthorization(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
87
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
88
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
89
|
+
} & {
|
|
90
|
+
readonly toggleContents: JSX.Element;
|
|
91
|
+
readonly selectorLabel: string;
|
|
92
|
+
} & {
|
|
93
|
+
getFetcher(location?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
94
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
95
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
96
|
+
export default stateModelFactory;
|
|
97
|
+
export declare type DropboxOAuthStateModel = ReturnType<typeof stateModelFactory>;
|
|
98
|
+
export declare type DropboxOAuthModel = Instance<DropboxOAuthStateModel>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ConfigurationReference } from '@jbrowse/core/configuration';
|
|
3
|
+
import { SvgIcon } from '@mui/material';
|
|
4
|
+
import { types } from 'mobx-state-tree';
|
|
5
|
+
import baseModel from '../OAuthModel/model';
|
|
6
|
+
import { configSchema as OAuthConfigSchema } from '../OAuthModel';
|
|
7
|
+
/** Error messages from https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file */
|
|
8
|
+
const dropboxErrorMessages = {
|
|
9
|
+
shared_link_not_found: "The shared link wasn't found.",
|
|
10
|
+
shared_link_access_denied: 'The caller is not allowed to access this shared link.',
|
|
11
|
+
unsupported_link_type: 'This type of link is not supported; use files/export instead.',
|
|
12
|
+
shared_link_is_directory: 'Directories cannot be retrieved by this endpoint.',
|
|
13
|
+
};
|
|
14
|
+
export function DropboxIcon(props) {
|
|
15
|
+
return (React.createElement(SvgIcon, { ...props },
|
|
16
|
+
React.createElement("path", { d: "M3 6.2L8 9.39L13 6.2L8 3L3 6.2M13 6.2L18 9.39L23 6.2L18 3L13 6.2M3 12.55L8 15.74L13 12.55L8 9.35L3 12.55M18 9.35L13 12.55L18 15.74L23 12.55L18 9.35M8.03 16.8L13.04 20L18.04 16.8L13.04 13.61L8.03 16.8Z" })));
|
|
17
|
+
}
|
|
18
|
+
async function getDescriptiveErrorMessage(response) {
|
|
19
|
+
let errorMessage;
|
|
20
|
+
try {
|
|
21
|
+
errorMessage = await response.text();
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
errorMessage = '';
|
|
25
|
+
}
|
|
26
|
+
if (errorMessage) {
|
|
27
|
+
let errorMessageParsed;
|
|
28
|
+
try {
|
|
29
|
+
errorMessageParsed = JSON.parse(errorMessage);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
errorMessageParsed = undefined;
|
|
33
|
+
}
|
|
34
|
+
if (errorMessageParsed) {
|
|
35
|
+
const messageTag = errorMessageParsed.error['.tag'];
|
|
36
|
+
errorMessage = dropboxErrorMessages[messageTag] || messageTag;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return `Network response failure — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`;
|
|
40
|
+
}
|
|
41
|
+
const stateModelFactory = (configSchema) => {
|
|
42
|
+
return baseModel(OAuthConfigSchema)
|
|
43
|
+
.named('DropboxOAuthInternetAccount')
|
|
44
|
+
.props({
|
|
45
|
+
type: types.literal('DropboxOAuthInternetAccount'),
|
|
46
|
+
configuration: ConfigurationReference(configSchema),
|
|
47
|
+
})
|
|
48
|
+
.views(() => ({
|
|
49
|
+
get toggleContents() {
|
|
50
|
+
return React.createElement(DropboxIcon, null);
|
|
51
|
+
},
|
|
52
|
+
get selectorLabel() {
|
|
53
|
+
return 'Enter Dropbox share link';
|
|
54
|
+
},
|
|
55
|
+
}))
|
|
56
|
+
.actions(self => ({
|
|
57
|
+
getFetcher(location) {
|
|
58
|
+
return async (input, init) => {
|
|
59
|
+
const authToken = await self.getToken(location);
|
|
60
|
+
const newInit = self.addAuthHeaderToInit({ ...init, method: 'POST' }, authToken);
|
|
61
|
+
newInit.headers.append('Dropbox-API-Arg', JSON.stringify({ url: input }));
|
|
62
|
+
const response = await fetch('https://content.dropboxapi.com/2/sharing/get_shared_link_file', newInit);
|
|
63
|
+
if (!response.ok) {
|
|
64
|
+
const message = await getDescriptiveErrorMessage(response);
|
|
65
|
+
throw new Error(message);
|
|
66
|
+
}
|
|
67
|
+
return response;
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
async validateToken(token, location) {
|
|
71
|
+
const response = await fetch('https://api.dropboxapi.com/2/sharing/get_shared_link_metadata', {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: `Bearer ${token}`,
|
|
75
|
+
'Content-Type': 'application/json',
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify({
|
|
78
|
+
url: location.uri,
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
if (!response.ok) {
|
|
82
|
+
const refreshToken = self.hasRefreshToken && self.retrieveRefreshToken();
|
|
83
|
+
if (refreshToken) {
|
|
84
|
+
self.removeRefreshToken();
|
|
85
|
+
const newToken = await self.exchangeRefreshForAccessToken(refreshToken);
|
|
86
|
+
return this.validateToken(newToken, location);
|
|
87
|
+
}
|
|
88
|
+
const message = await getDescriptiveErrorMessage(response);
|
|
89
|
+
throw new Error(`Token could not be validated. ${message}`);
|
|
90
|
+
}
|
|
91
|
+
return token;
|
|
92
|
+
},
|
|
93
|
+
}));
|
|
94
|
+
};
|
|
95
|
+
export default stateModelFactory;
|
|
96
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/DropboxOAuthModel/model.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE,OAAO,EAAgB,OAAO,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAY,KAAK,EAAE,MAAM,iBAAiB,CA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OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,KAAK,EAAE;oBAChC,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,GAAG,EAAE,QAAQ,CAAC,GAAG;iBAClB,CAAC;aACH,CACF,CAAA;YACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;gBAChB,MAAM,YAAY,GAChB,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAA;gBACrD,IAAI,YAAY,EAAE;oBAChB,IAAI,CAAC,kBAAkB,EAAE,CAAA;oBACzB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,6BAA6B,CACvD,YAAY,CACb,CAAA;oBACD,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;iBAC9C;gBACD,MAAM,OAAO,GAAG,MAAM,0BAA0B,CAAC,QAAQ,CAAC,CAAA;gBAC1D,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,EAAE,CAAC,CAAA;aAC5D;YACD,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAC,CAAC,CAAA;AACP,CAAC,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import Button from '@mui/material/Button';
|
|
3
|
+
import Dialog from '@mui/material/Dialog';
|
|
4
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
5
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
6
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
7
|
+
import TextField from '@mui/material/TextField';
|
|
8
|
+
export const ExternalTokenEntryForm = ({ internetAccountId, handleClose, }) => {
|
|
9
|
+
const [token, setToken] = useState('');
|
|
10
|
+
return (React.createElement(React.Fragment, null,
|
|
11
|
+
React.createElement(Dialog, { open: true, maxWidth: "xl", "data-testid": "externalToken-form" },
|
|
12
|
+
React.createElement(DialogTitle, null,
|
|
13
|
+
"Enter Token for ",
|
|
14
|
+
internetAccountId),
|
|
15
|
+
React.createElement(DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
|
|
16
|
+
React.createElement(TextField, { required: true, label: "Enter Token", variant: "outlined", inputProps: { 'data-testid': 'entry-externalToken' }, onChange: event => {
|
|
17
|
+
setToken(event.target.value);
|
|
18
|
+
}, margin: "dense" })),
|
|
19
|
+
React.createElement(DialogActions, null,
|
|
20
|
+
React.createElement(Button, { variant: "contained", color: "primary", type: "submit", disabled: !token, onClick: () => {
|
|
21
|
+
if (token) {
|
|
22
|
+
handleClose(token);
|
|
23
|
+
}
|
|
24
|
+
} }, "Add"),
|
|
25
|
+
React.createElement(Button, { variant: "contained", color: "primary", onClick: () => {
|
|
26
|
+
handleClose();
|
|
27
|
+
} }, "Cancel")))));
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=ExternalTokenEntryForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExternalTokenEntryForm.js","sourceRoot":"","sources":["../../src/ExternalTokenModel/ExternalTokenEntryForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,MAAM,MAAM,sBAAsB,CAAA;AACzC,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,WAAW,MAAM,2BAA2B,CAAA;AACnD,OAAO,aAAa,MAAM,6BAA6B,CAAA;AACvD,OAAO,SAAS,MAAM,yBAAyB,CAAA;AAE/C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EACrC,iBAAiB,EACjB,WAAW,GAIZ,EAAE,EAAE;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAEtC,OAAO,CACL;QACE,oBAAC,MAAM,IAAC,IAAI,QAAC,QAAQ,EAAC,IAAI,iBAAa,oBAAoB;YACzD,oBAAC,WAAW;;gBAAkB,iBAAiB,CAAe;YAC9D,oBAAC,aAAa,IAAC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE;gBAChE,oBAAC,SAAS,IACR,QAAQ,QACR,KAAK,EAAC,aAAa,EACnB,OAAO,EAAC,UAAU,EAClB,UAAU,EAAE,EAAE,aAAa,EAAE,qBAAqB,EAAE,EACpD,QAAQ,EAAE,KAAK,CAAC,EAAE;wBAChB,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;oBAC9B,CAAC,EACD,MAAM,EAAC,OAAO,GACd,CACY;YAChB,oBAAC,aAAa;gBACZ,oBAAC,MAAM,IACL,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,SAAS,EACf,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,KAAK,EAChB,OAAO,EAAE,GAAG,EAAE;wBACZ,IAAI,KAAK,EAAE;4BACT,WAAW,CAAC,KAAK,CAAC,CAAA;yBACnB;oBACH,CAAC,UAGM;gBACT,oBAAC,MAAM,IACL,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,SAAS,EACf,OAAO,EAAE,GAAG,EAAE;wBACZ,WAAW,EAAE,CAAA;oBACf,CAAC,aAGM,CACK,CACT,CACR,CACJ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Instance } from 'mobx-state-tree';
|
|
2
|
+
declare const ExternalTokenConfigSchema: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
|
|
3
|
+
export declare type ExternalTokenInternetAccountConfigModel = typeof ExternalTokenConfigSchema;
|
|
4
|
+
export declare type ExternalTokenInternetAccountConfig = Instance<ExternalTokenInternetAccountConfigModel>;
|
|
5
|
+
export default ExternalTokenConfigSchema;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
+
import { BaseInternetAccountConfig } from '@jbrowse/core/pluggableElementTypes/models';
|
|
3
|
+
/**
|
|
4
|
+
* #config ExternalTokenInternetAccount
|
|
5
|
+
*/
|
|
6
|
+
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
7
|
+
const ExternalTokenConfigSchema = ConfigurationSchema('ExternalTokenInternetAccount', {
|
|
8
|
+
/**
|
|
9
|
+
* #slot
|
|
10
|
+
*/
|
|
11
|
+
validateWithHEAD: {
|
|
12
|
+
description: 'validate the token with a HEAD request before using it',
|
|
13
|
+
type: 'boolean',
|
|
14
|
+
defaultValue: true,
|
|
15
|
+
},
|
|
16
|
+
}, {
|
|
17
|
+
/**
|
|
18
|
+
* #baseConfiguration
|
|
19
|
+
*/
|
|
20
|
+
baseConfiguration: BaseInternetAccountConfig,
|
|
21
|
+
explicitlyTyped: true,
|
|
22
|
+
});
|
|
23
|
+
export default ExternalTokenConfigSchema;
|
|
24
|
+
//# sourceMappingURL=configSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../../src/ExternalTokenModel/configSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AAEtF;;GAEG;AACH,SAAS,CAAC,KAAI,CAAC,CAAC,wDAAwD;AAExE,MAAM,yBAAyB,GAAG,mBAAmB,CACnD,8BAA8B,EAC9B;IACE;;OAEG;IACH,gBAAgB,EAAE;QAChB,WAAW,EAAE,wDAAwD;QACrE,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,IAAI;KACnB;CACF,EACD;IACE;;OAEG;IACH,iBAAiB,EAAE,yBAAyB;IAC5C,eAAe,EAAE,IAAI;CACtB,CACF,CAAA;AAOD,eAAe,yBAAyB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ExternalTokenModel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { UriLocation } from '@jbrowse/core/util/types';
|
|
3
|
+
import { ExternalTokenInternetAccountConfigModel } from './configSchema';
|
|
4
|
+
import { Instance } from 'mobx-state-tree';
|
|
5
|
+
declare const stateModelFactory: (configSchema: ExternalTokenInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
|
|
6
|
+
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
7
|
+
type: import("mobx-state-tree").ISimpleType<string>;
|
|
8
|
+
} & {
|
|
9
|
+
type: import("mobx-state-tree").ISimpleType<"ExternalTokenInternetAccount">;
|
|
10
|
+
configuration: import("mobx-state-tree").ITypeUnion<any, any, any>;
|
|
11
|
+
}, {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly description: string;
|
|
14
|
+
readonly internetAccountId: string;
|
|
15
|
+
readonly authHeader: string;
|
|
16
|
+
readonly tokenType: string;
|
|
17
|
+
readonly domains: string[];
|
|
18
|
+
readonly toggleContents: import("react").ReactNode;
|
|
19
|
+
readonly SelectorComponent: import("@jbrowse/core/util/types").AnyReactComponentType | undefined;
|
|
20
|
+
readonly selectorLabel: string | undefined;
|
|
21
|
+
} & {
|
|
22
|
+
handlesLocation(location: UriLocation): boolean;
|
|
23
|
+
readonly tokenKey: string;
|
|
24
|
+
} & {
|
|
25
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
26
|
+
storeToken(token: string): void;
|
|
27
|
+
removeToken(): void;
|
|
28
|
+
retrieveToken(): string | null;
|
|
29
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
30
|
+
} & {
|
|
31
|
+
getToken(location?: UriLocation | undefined): Promise<string>;
|
|
32
|
+
} & {
|
|
33
|
+
addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
|
|
34
|
+
headers: Headers;
|
|
35
|
+
body?: BodyInit | null | undefined;
|
|
36
|
+
cache?: RequestCache | undefined;
|
|
37
|
+
credentials?: RequestCredentials | undefined;
|
|
38
|
+
integrity?: string | undefined;
|
|
39
|
+
keepalive?: boolean | undefined;
|
|
40
|
+
method?: string | undefined;
|
|
41
|
+
mode?: RequestMode | undefined;
|
|
42
|
+
redirect?: RequestRedirect | undefined;
|
|
43
|
+
referrer?: string | undefined;
|
|
44
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
45
|
+
signal?: AbortSignal | null | undefined;
|
|
46
|
+
window?: null | undefined;
|
|
47
|
+
};
|
|
48
|
+
getPreAuthorizationInformation(location: UriLocation): Promise<{
|
|
49
|
+
internetAccountType: string;
|
|
50
|
+
authInfo: {
|
|
51
|
+
token: string;
|
|
52
|
+
configuration: any;
|
|
53
|
+
};
|
|
54
|
+
}>;
|
|
55
|
+
} & {
|
|
56
|
+
getFetcher(location?: UriLocation | undefined): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
57
|
+
} & {
|
|
58
|
+
openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
|
|
59
|
+
} & {
|
|
60
|
+
readonly validateWithHEAD: boolean;
|
|
61
|
+
} & {
|
|
62
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
63
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
64
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
65
|
+
export default stateModelFactory;
|
|
66
|
+
export declare type ExternalTokenStateModel = ReturnType<typeof stateModelFactory>;
|
|
67
|
+
export declare type ExternalTokenModel = Instance<ExternalTokenStateModel>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ConfigurationReference, getConf } from '@jbrowse/core/configuration';
|
|
2
|
+
import { InternetAccount } from '@jbrowse/core/pluggableElementTypes/models';
|
|
3
|
+
import { types, getRoot } from 'mobx-state-tree';
|
|
4
|
+
import { ExternalTokenEntryForm } from './ExternalTokenEntryForm';
|
|
5
|
+
const stateModelFactory = (configSchema) => {
|
|
6
|
+
return InternetAccount.named('ExternalTokenInternetAccount')
|
|
7
|
+
.props({
|
|
8
|
+
type: types.literal('ExternalTokenInternetAccount'),
|
|
9
|
+
configuration: ConfigurationReference(configSchema),
|
|
10
|
+
})
|
|
11
|
+
.views(self => ({
|
|
12
|
+
get validateWithHEAD() {
|
|
13
|
+
return getConf(self, 'validateWithHEAD');
|
|
14
|
+
},
|
|
15
|
+
}))
|
|
16
|
+
.actions(self => ({
|
|
17
|
+
getTokenFromUser(resolve, reject) {
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
const { session } = getRoot(self);
|
|
20
|
+
session.queueDialog((doneCallback) => [
|
|
21
|
+
ExternalTokenEntryForm,
|
|
22
|
+
{
|
|
23
|
+
internetAccountId: self.internetAccountId,
|
|
24
|
+
handleClose: (token) => {
|
|
25
|
+
if (token) {
|
|
26
|
+
resolve(token);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
reject(new Error('user cancelled entry'));
|
|
30
|
+
}
|
|
31
|
+
doneCallback();
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
},
|
|
36
|
+
async validateToken(token, location) {
|
|
37
|
+
if (!self.validateWithHEAD) {
|
|
38
|
+
return token;
|
|
39
|
+
}
|
|
40
|
+
const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token);
|
|
41
|
+
const response = await fetch(location.uri, newInit);
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
let errorMessage;
|
|
44
|
+
try {
|
|
45
|
+
errorMessage = await response.text();
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
errorMessage = '';
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`Token could not be validated — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`);
|
|
51
|
+
}
|
|
52
|
+
return token;
|
|
53
|
+
},
|
|
54
|
+
}));
|
|
55
|
+
};
|
|
56
|
+
export default stateModelFactory;
|
|
57
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/ExternalTokenModel/model.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AAC7E,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAA;AAG5E,OAAO,EAAY,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAE1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,MAAM,iBAAiB,GAAG,CACxB,YAAqD,EACrD,EAAE;IACF,OAAO,eAAe,CAAC,KAAK,CAAC,8BAA8B,CAAC;SACzD,KAAK,CAAC;QACL,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,8BAA8B,CAAC;QACnD,aAAa,EAAE,sBAAsB,CAAC,YAAY,CAAC;KACpD,CAAC;SACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACd,IAAI,gBAAgB;YAClB,OAAO,OAAO,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAA;QAC1C,CAAC;KACF,CAAC,CAAC;SACF,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAChB,gBAAgB,CACd,OAAgC,EAChC,MAA8B;YAE9B,8DAA8D;YAC9D,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAM,IAAI,CAAC,CAAA;YACtC,OAAO,CAAC,WAAW,CAAC,CAAC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ogleDriveOAuthConfigSchema: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
|
|
3
|
+
export declare type GoogleDriveOAuthInternetAccountConfigModel = typeof GoogleDriveOAuthConfigSchema;
|
|
4
|
+
export declare type GoogleDriveOAuthInternetAccountConfig = Instance<GoogleDriveOAuthInternetAccountConfigModel>;
|
|
5
|
+
export default GoogleDriveOAuthConfigSchema;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
+
import OAuthConfigSchema from '../OAuthModel/configSchema';
|
|
3
|
+
/**
|
|
4
|
+
* #config GoogleDriveOAuthInternetAccount
|
|
5
|
+
*/
|
|
6
|
+
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
7
|
+
const GoogleDriveOAuthConfigSchema = ConfigurationSchema('GoogleDriveOAuthInternetAccount', {
|
|
8
|
+
/**
|
|
9
|
+
* #slot
|
|
10
|
+
*/
|
|
11
|
+
authEndpoint: {
|
|
12
|
+
description: 'the authorization code endpoint of the internet account',
|
|
13
|
+
type: 'string',
|
|
14
|
+
defaultValue: 'https://accounts.google.com/o/oauth2/v2/auth',
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* #slot
|
|
18
|
+
*/
|
|
19
|
+
scopes: {
|
|
20
|
+
description: 'optional scopes for the authorization call',
|
|
21
|
+
type: 'string',
|
|
22
|
+
defaultValue: 'https://www.googleapis.com/auth/drive.readonly',
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* #slot
|
|
26
|
+
*/
|
|
27
|
+
domains: {
|
|
28
|
+
description: 'array of valid domains the url can contain to use this account',
|
|
29
|
+
type: 'stringArray',
|
|
30
|
+
defaultValue: ['drive.google.com"'],
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* #slot
|
|
34
|
+
*/
|
|
35
|
+
responseType: {
|
|
36
|
+
description: 'the type of response from the authorization endpoint',
|
|
37
|
+
type: 'string',
|
|
38
|
+
defaultValue: 'token',
|
|
39
|
+
},
|
|
40
|
+
}, {
|
|
41
|
+
/**
|
|
42
|
+
* #baseConfiguration
|
|
43
|
+
*/
|
|
44
|
+
baseConfiguration: OAuthConfigSchema,
|
|
45
|
+
explicitlyTyped: true,
|
|
46
|
+
});
|
|
47
|
+
export default GoogleDriveOAuthConfigSchema;
|
|
48
|
+
//# sourceMappingURL=configSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../../src/GoogleDriveOAuthModel/configSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAEjE,OAAO,iBAAiB,MAAM,4BAA4B,CAAA;AAE1D;;GAEG;AACH,SAAS,CAAC,KAAI,CAAC,CAAC,wDAAwD;AAExE,MAAM,4BAA4B,GAAG,mBAAmB,CACtD,iCAAiC,EACjC;IACE;;OAEG;IACH,YAAY,EAAE;QACZ,WAAW,EAAE,yDAAyD;QACtE,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,8CAA8C;KAC7D;IACD;;OAEG;IACH,MAAM,EAAE;QACN,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,gDAAgD;KAC/D;IACD;;OAEG;IACH,OAAO,EAAE;QACP,WAAW,EACT,gEAAgE;QAClE,IAAI,EAAE,aAAa;QACnB,YAAY,EAAE,CAAC,mBAAmB,CAAC;KACpC;IACD;;OAEG;IACH,YAAY,EAAE;QACZ,WAAW,EAAE,sDAAsD;QACnE,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,OAAO;KACtB;CACF,EACD;IACE;;OAEG;IACH,iBAAiB,EAAE,iBAAiB;IACpC,eAAe,EAAE,IAAI;CACtB,CACF,CAAA;AAOD,eAAe,4BAA4B,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/GoogleDriveOAuthModel/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Instance } from 'mobx-state-tree';
|
|
3
|
+
import { RemoteFileWithRangeCache } from '@jbrowse/core/util/io';
|
|
4
|
+
import { UriLocation } from '@jbrowse/core/util/types';
|
|
5
|
+
import { FilehandleOptions, Stats, PolyfilledResponse } from 'generic-filehandle';
|
|
6
|
+
import { GoogleDriveOAuthInternetAccountConfigModel } from './configSchema';
|
|
7
|
+
export interface RequestInitWithMetadata extends RequestInit {
|
|
8
|
+
metadataOnly?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface GoogleDriveFilehandleOptions extends FilehandleOptions {
|
|
11
|
+
fetch(input: RequestInfo, opts?: RequestInitWithMetadata): Promise<PolyfilledResponse>;
|
|
12
|
+
}
|
|
13
|
+
export declare class GoogleDriveFile extends RemoteFileWithRangeCache {
|
|
14
|
+
private statsPromise;
|
|
15
|
+
constructor(source: string, opts: GoogleDriveFilehandleOptions);
|
|
16
|
+
fetch(input: RequestInfo, opts?: RequestInitWithMetadata): Promise<PolyfilledResponse>;
|
|
17
|
+
stat(): Promise<Stats>;
|
|
18
|
+
}
|
|
19
|
+
declare const stateModelFactory: (configSchema: GoogleDriveOAuthInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
|
|
20
|
+
id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
|
|
21
|
+
type: import("mobx-state-tree").ISimpleType<string>;
|
|
22
|
+
} & {
|
|
23
|
+
type: import("mobx-state-tree").ISimpleType<"OAuthInternetAccount">;
|
|
24
|
+
configuration: import("mobx-state-tree").ITypeUnion<any, any, any>;
|
|
25
|
+
} & {
|
|
26
|
+
type: import("mobx-state-tree").ISimpleType<"GoogleDriveOAuthInternetAccount">;
|
|
27
|
+
configuration: import("mobx-state-tree").ITypeUnion<any, any, any>;
|
|
28
|
+
}, {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly description: string;
|
|
31
|
+
readonly internetAccountId: string;
|
|
32
|
+
readonly authHeader: string;
|
|
33
|
+
readonly tokenType: string;
|
|
34
|
+
readonly domains: string[];
|
|
35
|
+
readonly toggleContents: React.ReactNode;
|
|
36
|
+
readonly SelectorComponent: import("@jbrowse/core/util/types").AnyReactComponentType | undefined;
|
|
37
|
+
readonly selectorLabel: string | undefined;
|
|
38
|
+
} & {
|
|
39
|
+
handlesLocation(location: UriLocation): boolean;
|
|
40
|
+
readonly tokenKey: string;
|
|
41
|
+
} & {
|
|
42
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
43
|
+
storeToken(token: string): void;
|
|
44
|
+
removeToken(): void;
|
|
45
|
+
retrieveToken(): string | null;
|
|
46
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
47
|
+
} & {
|
|
48
|
+
getToken(location?: UriLocation | undefined): Promise<string>;
|
|
49
|
+
} & {
|
|
50
|
+
addAuthHeaderToInit(init: RequestInit | undefined, token: string): {
|
|
51
|
+
headers: Headers;
|
|
52
|
+
body?: BodyInit | null | undefined;
|
|
53
|
+
cache?: RequestCache | undefined;
|
|
54
|
+
credentials?: RequestCredentials | undefined;
|
|
55
|
+
integrity?: string | undefined;
|
|
56
|
+
keepalive?: boolean | undefined;
|
|
57
|
+
method?: string | undefined;
|
|
58
|
+
mode?: RequestMode | undefined;
|
|
59
|
+
redirect?: RequestRedirect | undefined;
|
|
60
|
+
referrer?: string | undefined;
|
|
61
|
+
referrerPolicy?: ReferrerPolicy | undefined;
|
|
62
|
+
signal?: AbortSignal | null | undefined;
|
|
63
|
+
window?: null | undefined;
|
|
64
|
+
};
|
|
65
|
+
getPreAuthorizationInformation(location: UriLocation): Promise<{
|
|
66
|
+
internetAccountType: string;
|
|
67
|
+
authInfo: {
|
|
68
|
+
token: string;
|
|
69
|
+
configuration: any;
|
|
70
|
+
};
|
|
71
|
+
}>;
|
|
72
|
+
} & {
|
|
73
|
+
getFetcher(location?: UriLocation | undefined): (input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>;
|
|
74
|
+
} & {
|
|
75
|
+
openLocation(location: UriLocation): RemoteFileWithRangeCache;
|
|
76
|
+
} & {
|
|
77
|
+
readonly codeVerifierPKCE: string;
|
|
78
|
+
} & {
|
|
79
|
+
readonly authEndpoint: string;
|
|
80
|
+
readonly tokenEndpoint: string;
|
|
81
|
+
readonly needsPKCE: boolean;
|
|
82
|
+
readonly clientId: string;
|
|
83
|
+
readonly scopes: string;
|
|
84
|
+
state(): string | undefined;
|
|
85
|
+
readonly responseType: "code" | "token";
|
|
86
|
+
readonly hasRefreshToken: boolean;
|
|
87
|
+
readonly refreshTokenKey: string;
|
|
88
|
+
} & {
|
|
89
|
+
storeRefreshToken(refreshToken: string): void;
|
|
90
|
+
removeRefreshToken(): void;
|
|
91
|
+
retrieveRefreshToken(): string | null;
|
|
92
|
+
exchangeAuthorizationForAccessToken(token: string, redirectUri: string): Promise<string>;
|
|
93
|
+
exchangeRefreshForAccessToken(refreshToken: string): Promise<string>;
|
|
94
|
+
} & {
|
|
95
|
+
addMessageChannel(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
96
|
+
deleteMessageChannel(): void;
|
|
97
|
+
finishOAuthWindow(event: MessageEvent<any>, resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
98
|
+
useEndpointForAuthorization(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
99
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
100
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
101
|
+
} & {
|
|
102
|
+
readonly toggleContents: JSX.Element;
|
|
103
|
+
readonly selectorLabel: string;
|
|
104
|
+
} & {
|
|
105
|
+
getFetcher(location?: UriLocation): (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
106
|
+
openLocation(location: UriLocation): GoogleDriveFile;
|
|
107
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
108
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
109
|
+
export default stateModelFactory;
|
|
110
|
+
export declare type GoogleDriveOAuthStateModel = ReturnType<typeof stateModelFactory>;
|
|
111
|
+
export declare type GoogleDriveOAuthModel = Instance<GoogleDriveOAuthStateModel>;
|