@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,108 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ConfigurationReference } from '@jbrowse/core/configuration';
|
|
3
|
+
import { types } from 'mobx-state-tree';
|
|
4
|
+
import { RemoteFileWithRangeCache } from '@jbrowse/core/util/io';
|
|
5
|
+
import { SvgIcon } from '@mui/material';
|
|
6
|
+
import baseModel from '../OAuthModel/model';
|
|
7
|
+
import { configSchema as OAuthConfigSchema } from '../OAuthModel';
|
|
8
|
+
export class GoogleDriveFile extends RemoteFileWithRangeCache {
|
|
9
|
+
constructor(source, opts) {
|
|
10
|
+
super(source, opts);
|
|
11
|
+
this.statsPromise = this.fetch(source, {
|
|
12
|
+
metadataOnly: true,
|
|
13
|
+
}).then((response) => response.json());
|
|
14
|
+
}
|
|
15
|
+
async fetch(input, opts) {
|
|
16
|
+
return super.fetch(input, opts);
|
|
17
|
+
}
|
|
18
|
+
async stat() {
|
|
19
|
+
return this.statsPromise;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function GoogleDriveIcon(props) {
|
|
23
|
+
return (React.createElement(SvgIcon, { ...props },
|
|
24
|
+
React.createElement("path", { d: "M7.71,3.5L1.15,15L4.58,21L11.13,9.5M9.73,15L6.3,21H19.42L22.85,15M22.28,14L15.42,2H8.58L8.57,2L15.43,14H22.28Z" })));
|
|
25
|
+
}
|
|
26
|
+
async function getDescriptiveErrorMessage(response) {
|
|
27
|
+
let errorMessage;
|
|
28
|
+
try {
|
|
29
|
+
errorMessage = await response.text();
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
errorMessage = '';
|
|
33
|
+
}
|
|
34
|
+
if (errorMessage) {
|
|
35
|
+
let errorMessageParsed;
|
|
36
|
+
try {
|
|
37
|
+
errorMessageParsed = JSON.parse(errorMessage);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
errorMessageParsed = undefined;
|
|
41
|
+
}
|
|
42
|
+
if (errorMessageParsed) {
|
|
43
|
+
errorMessage = errorMessageParsed.error.message;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return `Network response failure — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`;
|
|
47
|
+
}
|
|
48
|
+
const stateModelFactory = (configSchema) => {
|
|
49
|
+
return baseModel(OAuthConfigSchema)
|
|
50
|
+
.named('GoogleDriveOAuthInternetAccount')
|
|
51
|
+
.props({
|
|
52
|
+
type: types.literal('GoogleDriveOAuthInternetAccount'),
|
|
53
|
+
configuration: ConfigurationReference(configSchema),
|
|
54
|
+
})
|
|
55
|
+
.views(() => ({
|
|
56
|
+
get toggleContents() {
|
|
57
|
+
return React.createElement(GoogleDriveIcon, null);
|
|
58
|
+
},
|
|
59
|
+
get selectorLabel() {
|
|
60
|
+
return 'Enter Google Drive share link';
|
|
61
|
+
},
|
|
62
|
+
}))
|
|
63
|
+
.actions(self => ({
|
|
64
|
+
getFetcher(location) {
|
|
65
|
+
return async (input, init) => {
|
|
66
|
+
const urlId = String(input).match(/[-\w]{25,}/);
|
|
67
|
+
const driveUrl = new URL(`https://www.googleapis.com/drive/v3/files/${urlId}`);
|
|
68
|
+
const searchParams = new URLSearchParams();
|
|
69
|
+
if (init === null || init === void 0 ? void 0 : init.metadataOnly) {
|
|
70
|
+
searchParams.append('fields', 'size');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
searchParams.append('alt', 'media');
|
|
74
|
+
}
|
|
75
|
+
driveUrl.search = searchParams.toString();
|
|
76
|
+
const authToken = await self.getToken(location);
|
|
77
|
+
const newInit = self.addAuthHeaderToInit({ ...init, method: 'GET', credentials: 'same-origin' }, authToken);
|
|
78
|
+
const response = await fetch(driveUrl.toString(), newInit);
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
const message = await getDescriptiveErrorMessage(response);
|
|
81
|
+
throw new Error(message);
|
|
82
|
+
}
|
|
83
|
+
return response;
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
openLocation(location) {
|
|
87
|
+
return new GoogleDriveFile(location.uri, {
|
|
88
|
+
fetch: this.getFetcher(location),
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
async validateToken(token, location) {
|
|
92
|
+
const urlId = location.uri.match(/[-\w]{25,}/);
|
|
93
|
+
const response = await fetch(`https://www.googleapis.com/drive/v3/files/${urlId}`, {
|
|
94
|
+
headers: {
|
|
95
|
+
Authorization: `Bearer ${token}`,
|
|
96
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
const message = await getDescriptiveErrorMessage(response);
|
|
101
|
+
throw new Error(`Token could not be validated. ${message}`);
|
|
102
|
+
}
|
|
103
|
+
return token;
|
|
104
|
+
},
|
|
105
|
+
}));
|
|
106
|
+
};
|
|
107
|
+
export default stateModelFactory;
|
|
108
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/GoogleDriveOAuthModel/model.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAY,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,OAAO,EAAgB,OAAO,EAAE,MAAM,eAAe,CAAA;AASrD,OAAO,SAAS,MAAM,qBAAqB,CAAA;AAC3C,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAA;AA2BjE,MAAM,OAAO,eAAgB,SAAQ,wBAAwB;IAE3D,YAAY,MAAc,EAAE,IAAkC;QAC5D,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACnB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACrC,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC,IAAI,CAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;IAClD,CAAC;IAED,KAAK,CAAC,KAAK,CACT,KAAkB,EAClB,IAA8B;QAE9B,OAAO,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACjC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;CACF;AAED,SAAS,eAAe,CAAC,KAAmB;IAC1C,OAAO,CACL,oBAAC,OAAO,OAAK,KAAK;QAChB,8BAAM,CAAC,EAAC,gHAAgH,GAAG,CACnH,CACX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KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;YAC9C,MAAM,QAAQ,GAAG,MAAM,KAAK,CAC1B,6CAA6C,KAAK,EAAE,EACpD;gBACE,OAAO,EAAE;oBACP,aAAa,EAAE,UAAU,KAAK,EAAE;oBAChC,cAAc,EAAE,mCAAmC;iBACpD;aACF,CACF,CAAA;YACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;gBAChB,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,28 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button, Dialog, DialogContent, DialogTitle, DialogActions, TextField, } from '@mui/material';
|
|
3
|
+
export const HTTPBasicLoginForm = ({ internetAccountId, handleClose, }) => {
|
|
4
|
+
const [username, setUsername] = useState('');
|
|
5
|
+
const [password, setPassword] = useState('');
|
|
6
|
+
function onSubmit(event) {
|
|
7
|
+
if (username && password) {
|
|
8
|
+
handleClose(btoa(`${username}:${password}`));
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
handleClose();
|
|
12
|
+
}
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
}
|
|
15
|
+
return (React.createElement(React.Fragment, null,
|
|
16
|
+
React.createElement(Dialog, { open: true, maxWidth: "xl", "data-testid": "login-httpbasic" },
|
|
17
|
+
React.createElement(DialogTitle, null,
|
|
18
|
+
"Log In for ",
|
|
19
|
+
internetAccountId),
|
|
20
|
+
React.createElement("form", { onSubmit: onSubmit },
|
|
21
|
+
React.createElement(DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
|
|
22
|
+
React.createElement(TextField, { required: true, label: "Username", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-username' }, onChange: event => setUsername(event.target.value), margin: "dense" }),
|
|
23
|
+
React.createElement(TextField, { required: true, label: "Password", type: "password", autoComplete: "current-password", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-password' }, onChange: event => setPassword(event.target.value), margin: "dense" })),
|
|
24
|
+
React.createElement(DialogActions, null,
|
|
25
|
+
React.createElement(Button, { variant: "contained", color: "primary", type: "submit" }, "Submit"),
|
|
26
|
+
React.createElement(Button, { variant: "contained", type: "submit", onClick: () => handleClose() }, "Cancel"))))));
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=HTTPBasicLoginForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HTTPBasicLoginForm.js","sourceRoot":"","sources":["../../src/HTTPBasicModel/HTTPBasicLoginForm.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACvC,OAAO,EACL,MAAM,EACN,MAAM,EACN,aAAa,EACb,WAAW,EACX,aAAa,EACb,SAAS,GACV,MAAM,eAAe,CAAA;AAEtB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,iBAAiB,EACjB,WAAW,GAIZ,EAAE,EAAE;IACH,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC5C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAA;IAE5C,SAAS,QAAQ,CAAC,KAAuC;QACvD,IAAI,QAAQ,IAAI,QAAQ,EAAE;YACxB,WAAW,CAAC,IAAI,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC,CAAC,CAAA;SAC7C;aAAM;YACL,WAAW,EAAE,CAAA;SACd;QACD,KAAK,CAAC,cAAc,EAAE,CAAA;IACxB,CAAC;IAED,OAAO,CACL;QACE,oBAAC,MAAM,IAAC,IAAI,QAAC,QAAQ,EAAC,IAAI,iBAAa,iBAAiB;YACtD,oBAAC,WAAW;;gBAAa,iBAAiB,CAAe;YACzD,8BAAM,QAAQ,EAAE,QAAQ;gBACtB,oBAAC,aAAa,IAAC,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE;oBAChE,oBAAC,SAAS,IACR,QAAQ,QACR,KAAK,EAAC,UAAU,EAChB,OAAO,EAAC,UAAU,EAClB,UAAU,EAAE,EAAE,aAAa,EAAE,0BAA0B,EAAE,EACzD,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAClD,MAAM,EAAC,OAAO,GACd;oBACF,oBAAC,SAAS,IACR,QAAQ,QACR,KAAK,EAAC,UAAU,EAChB,IAAI,EAAC,UAAU,EACf,YAAY,EAAC,kBAAkB,EAC/B,OAAO,EAAC,UAAU,EAClB,UAAU,EAAE,EAAE,aAAa,EAAE,0BAA0B,EAAE,EACzD,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAClD,MAAM,EAAC,OAAO,GACd,CACY;gBAChB,oBAAC,aAAa;oBACZ,oBAAC,MAAM,IAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,aAEhD;oBACT,oBAAC,MAAM,IACL,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,aAGrB,CACK,CACX,CACA,CACR,CACJ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Instance } from 'mobx-state-tree';
|
|
2
|
+
declare const HTTPBasicConfigSchema: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
|
|
3
|
+
export declare type HTTPBasicInternetAccountConfigModel = typeof HTTPBasicConfigSchema;
|
|
4
|
+
export declare type HTTPBasicInternetAccountConfig = Instance<HTTPBasicInternetAccountConfigModel>;
|
|
5
|
+
export default HTTPBasicConfigSchema;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
+
import { BaseInternetAccountConfig } from '@jbrowse/core/pluggableElementTypes/models';
|
|
3
|
+
/**
|
|
4
|
+
* #config HTTPBasicInternetAccount
|
|
5
|
+
*/
|
|
6
|
+
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
7
|
+
const HTTPBasicConfigSchema = ConfigurationSchema('HTTPBasicInternetAccount', {
|
|
8
|
+
/**
|
|
9
|
+
* #slot
|
|
10
|
+
*/
|
|
11
|
+
tokenType: {
|
|
12
|
+
description: 'a custom name for a token to include in the header',
|
|
13
|
+
type: 'string',
|
|
14
|
+
defaultValue: 'Basic',
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* #slot
|
|
18
|
+
*/
|
|
19
|
+
validateWithHEAD: {
|
|
20
|
+
description: 'validate the token with a HEAD request before using it',
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
defaultValue: true,
|
|
23
|
+
},
|
|
24
|
+
}, {
|
|
25
|
+
/**
|
|
26
|
+
* #baseConfiguration
|
|
27
|
+
*/
|
|
28
|
+
baseConfiguration: BaseInternetAccountConfig,
|
|
29
|
+
explicitlyTyped: true,
|
|
30
|
+
});
|
|
31
|
+
export default HTTPBasicConfigSchema;
|
|
32
|
+
//# sourceMappingURL=configSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../../src/HTTPBasicModel/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,qBAAqB,GAAG,mBAAmB,CAC/C,0BAA0B,EAC1B;IACE;;OAEG;IACH,SAAS,EAAE;QACT,WAAW,EAAE,oDAAoD;QACjE,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,OAAO;KACtB;IACD;;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;AAMD,eAAe,qBAAqB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/HTTPBasicModel/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 { HTTPBasicInternetAccountConfigModel } from './configSchema';
|
|
4
|
+
import { Instance } from 'mobx-state-tree';
|
|
5
|
+
declare const stateModelFactory: (configSchema: HTTPBasicInternetAccountConfigModel) => 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<"HTTPBasicInternetAccount">;
|
|
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 HTTPBasicStateModel = ReturnType<typeof stateModelFactory>;
|
|
67
|
+
export declare type HTTPBasicModel = Instance<HTTPBasicStateModel>;
|
|
@@ -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 { HTTPBasicLoginForm } from './HTTPBasicLoginForm';
|
|
5
|
+
const stateModelFactory = (configSchema) => {
|
|
6
|
+
return InternetAccount.named('HTTPBasicInternetAccount')
|
|
7
|
+
.props({
|
|
8
|
+
type: types.literal('HTTPBasicInternetAccount'),
|
|
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
|
+
HTTPBasicLoginForm,
|
|
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(`Error validating token — ${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/HTTPBasicModel/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,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,iBAAiB,GAAG,CACxB,YAAiD,EACjD,EAAE;IACF,OAAO,eAAe,CAAC,KAAK,CAAC,0BAA0B,CAAC;SACrD,KAAK,CAAC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GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;iBACrC;gBAAC,OAAO,KAAK,EAAE;oBACd,YAAY,GAAG,EAAE,CAAA;iBAClB;gBACD,MAAM,IAAI,KAAK,CACb,4BAA4B,QAAQ,CAAC,MAAM,KACzC,QAAQ,CAAC,UACX,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,YAAY,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAC/C,CAAA;aACF;YACD,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAC,CAAC,CAAA;AACP,CAAC,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Instance } from 'mobx-state-tree';
|
|
2
|
+
declare const OAuthConfigSchema: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
|
|
3
|
+
export declare type OAuthInternetAccountConfigModel = typeof OAuthConfigSchema;
|
|
4
|
+
export declare type OAuthInternetAccountConfig = Instance<OAuthInternetAccountConfigModel>;
|
|
5
|
+
export default OAuthConfigSchema;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration';
|
|
2
|
+
import { BaseInternetAccountConfig } from '@jbrowse/core/pluggableElementTypes/models';
|
|
3
|
+
/**
|
|
4
|
+
* #config OAuthInternetAccount
|
|
5
|
+
*/
|
|
6
|
+
function x() { } // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
7
|
+
const OAuthConfigSchema = ConfigurationSchema('OAuthInternetAccount', {
|
|
8
|
+
/**
|
|
9
|
+
* #slot
|
|
10
|
+
*/
|
|
11
|
+
tokenType: {
|
|
12
|
+
description: 'a custom name for a token to include in the header',
|
|
13
|
+
type: 'string',
|
|
14
|
+
defaultValue: 'Bearer',
|
|
15
|
+
},
|
|
16
|
+
/**
|
|
17
|
+
* #slot
|
|
18
|
+
*/
|
|
19
|
+
authEndpoint: {
|
|
20
|
+
description: 'the authorization code endpoint of the internet account',
|
|
21
|
+
type: 'string',
|
|
22
|
+
defaultValue: '',
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* #slot
|
|
26
|
+
*/
|
|
27
|
+
tokenEndpoint: {
|
|
28
|
+
description: 'the token endpoint of the internet account',
|
|
29
|
+
type: 'string',
|
|
30
|
+
defaultValue: '',
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* #slot
|
|
34
|
+
*/
|
|
35
|
+
needsPKCE: {
|
|
36
|
+
description: 'boolean to indicate if the endpoint needs a PKCE code',
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
defaultValue: false,
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* #slot
|
|
42
|
+
*/
|
|
43
|
+
clientId: {
|
|
44
|
+
description: 'id for the OAuth application',
|
|
45
|
+
type: 'string',
|
|
46
|
+
defaultValue: '',
|
|
47
|
+
},
|
|
48
|
+
/**
|
|
49
|
+
* #slot
|
|
50
|
+
*/
|
|
51
|
+
scopes: {
|
|
52
|
+
description: 'optional scopes for the authorization call',
|
|
53
|
+
type: 'string',
|
|
54
|
+
defaultValue: '',
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* #slot
|
|
58
|
+
*/
|
|
59
|
+
state: {
|
|
60
|
+
description: 'optional state for the authorization call',
|
|
61
|
+
type: 'string',
|
|
62
|
+
defaultValue: '',
|
|
63
|
+
},
|
|
64
|
+
/**
|
|
65
|
+
* #slot
|
|
66
|
+
*/
|
|
67
|
+
responseType: {
|
|
68
|
+
description: 'the type of response from the authorization endpoint',
|
|
69
|
+
type: 'string',
|
|
70
|
+
defaultValue: 'code',
|
|
71
|
+
},
|
|
72
|
+
/**
|
|
73
|
+
* #slot
|
|
74
|
+
*/
|
|
75
|
+
hasRefreshToken: {
|
|
76
|
+
description: 'true if the endpoint can supply a refresh token',
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
defaultValue: false,
|
|
79
|
+
},
|
|
80
|
+
}, {
|
|
81
|
+
/**
|
|
82
|
+
* #baseConfiguration
|
|
83
|
+
*/
|
|
84
|
+
baseConfiguration: BaseInternetAccountConfig,
|
|
85
|
+
explicitlyTyped: true,
|
|
86
|
+
});
|
|
87
|
+
export default OAuthConfigSchema;
|
|
88
|
+
//# sourceMappingURL=configSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configSchema.js","sourceRoot":"","sources":["../../src/OAuthModel/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,iBAAiB,GAAG,mBAAmB,CAC3C,sBAAsB,EACtB;IACE;;OAEG;IACH,SAAS,EAAE;QACT,WAAW,EAAE,oDAAoD;QACjE,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,QAAQ;KACvB;IACD;;OAEG;IACH,YAAY,EAAE;QACZ,WAAW,EAAE,yDAAyD;QACtE,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,EAAE;KACjB;IACD;;OAEG;IACH,aAAa,EAAE;QACb,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,EAAE;KACjB;IACD;;OAEG;IACH,SAAS,EAAE;QACT,WAAW,EAAE,uDAAuD;QACpE,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;IACD;;OAEG;IACH,QAAQ,EAAE;QACR,WAAW,EAAE,8BAA8B;QAC3C,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,EAAE;KACjB;IACD;;OAEG;IACH,MAAM,EAAE;QACN,WAAW,EAAE,4CAA4C;QACzD,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,EAAE;KACjB;IACD;;OAEG;IACH,KAAK,EAAE;QACL,WAAW,EAAE,2CAA2C;QACxD,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,EAAE;KACjB;IACD;;OAEG;IACH,YAAY,EAAE;QACZ,WAAW,EAAE,sDAAsD;QACnE,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,MAAM;KACrB;IACD;;OAEG;IACH,eAAe,EAAE;QACf,WAAW,EAAE,iDAAiD;QAC9D,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;CACF,EACD;IACE;;OAEG;IACH,iBAAiB,EAAE,yBAAyB;IAC5C,eAAe,EAAE,IAAI;CACtB,CACF,CAAA;AAKD,eAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/OAuthModel/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,91 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { UriLocation } from '@jbrowse/core/util';
|
|
3
|
+
import { Instance } from 'mobx-state-tree';
|
|
4
|
+
import { OAuthInternetAccountConfigModel } from './configSchema';
|
|
5
|
+
declare const stateModelFactory: (configSchema: OAuthInternetAccountConfigModel) => 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<"OAuthInternetAccount">;
|
|
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").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 codeVerifierPKCE: string;
|
|
61
|
+
} & {
|
|
62
|
+
readonly authEndpoint: string;
|
|
63
|
+
readonly tokenEndpoint: string;
|
|
64
|
+
readonly needsPKCE: boolean;
|
|
65
|
+
readonly clientId: string;
|
|
66
|
+
readonly scopes: string;
|
|
67
|
+
/**
|
|
68
|
+
* OAuth state parameter: https://www.rfc-editor.org/rfc/rfc6749#section-4.1.1
|
|
69
|
+
* Can override or extend if dynamic state is needed.
|
|
70
|
+
*/
|
|
71
|
+
state(): string | undefined;
|
|
72
|
+
readonly responseType: "code" | "token";
|
|
73
|
+
readonly hasRefreshToken: boolean;
|
|
74
|
+
readonly refreshTokenKey: string;
|
|
75
|
+
} & {
|
|
76
|
+
storeRefreshToken(refreshToken: string): void;
|
|
77
|
+
removeRefreshToken(): void;
|
|
78
|
+
retrieveRefreshToken(): string | null;
|
|
79
|
+
exchangeAuthorizationForAccessToken(token: string, redirectUri: string): Promise<string>;
|
|
80
|
+
exchangeRefreshForAccessToken(refreshToken: string): Promise<string>;
|
|
81
|
+
} & {
|
|
82
|
+
addMessageChannel(resolve: (token: string) => void, reject: (error: Error) => void): void;
|
|
83
|
+
deleteMessageChannel(): void;
|
|
84
|
+
finishOAuthWindow(event: MessageEvent, resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
85
|
+
useEndpointForAuthorization(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
86
|
+
getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): Promise<void>;
|
|
87
|
+
validateToken(token: string, location: UriLocation): Promise<string>;
|
|
88
|
+
}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
|
|
89
|
+
export default stateModelFactory;
|
|
90
|
+
export declare type OAuthStateModel = ReturnType<typeof stateModelFactory>;
|
|
91
|
+
export declare type OAuthModel = Instance<OAuthStateModel>;
|