@jbrowse/plugin-authentication 2.4.2 → 2.6.1

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 (102) hide show
  1. package/dist/DropboxOAuthModel/configSchema.d.ts +105 -1
  2. package/dist/DropboxOAuthModel/configSchema.js +0 -8
  3. package/dist/DropboxOAuthModel/configSchema.js.map +1 -1
  4. package/dist/DropboxOAuthModel/model.d.ts +304 -8
  5. package/dist/DropboxOAuthModel/model.js +26 -35
  6. package/dist/DropboxOAuthModel/model.js.map +1 -1
  7. package/dist/DropboxOAuthModel/util.d.ts +1 -0
  8. package/dist/DropboxOAuthModel/util.js +28 -0
  9. package/dist/DropboxOAuthModel/util.js.map +1 -0
  10. package/dist/ExternalTokenModel/ExternalTokenEntryForm.d.ts +2 -2
  11. package/dist/ExternalTokenModel/ExternalTokenEntryForm.js +10 -11
  12. package/dist/ExternalTokenModel/ExternalTokenEntryForm.js.map +1 -1
  13. package/dist/ExternalTokenModel/configSchema.d.ts +36 -1
  14. package/dist/ExternalTokenModel/model.d.ts +93 -3
  15. package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +15 -0
  16. package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +20 -0
  17. package/dist/GoogleDriveOAuthModel/GoogleDriveFilehandle.js.map +1 -0
  18. package/dist/GoogleDriveOAuthModel/configSchema.d.ts +105 -1
  19. package/dist/GoogleDriveOAuthModel/model.d.ts +219 -20
  20. package/dist/GoogleDriveOAuthModel/model.js +38 -51
  21. package/dist/GoogleDriveOAuthModel/model.js.map +1 -1
  22. package/dist/GoogleDriveOAuthModel/util.d.ts +1 -0
  23. package/dist/GoogleDriveOAuthModel/util.js +17 -0
  24. package/dist/GoogleDriveOAuthModel/util.js.map +1 -0
  25. package/dist/HTTPBasicModel/HTTPBasicLoginForm.d.ts +2 -2
  26. package/dist/HTTPBasicModel/HTTPBasicLoginForm.js +17 -21
  27. package/dist/HTTPBasicModel/HTTPBasicLoginForm.js.map +1 -1
  28. package/dist/HTTPBasicModel/configSchema.d.ts +44 -1
  29. package/dist/HTTPBasicModel/model.d.ts +135 -3
  30. package/dist/HTTPBasicModel/model.js +24 -9
  31. package/dist/HTTPBasicModel/model.js.map +1 -1
  32. package/dist/OAuthModel/configSchema.d.ts +94 -1
  33. package/dist/OAuthModel/configSchema.js +1 -9
  34. package/dist/OAuthModel/configSchema.js.map +1 -1
  35. package/dist/OAuthModel/model.d.ts +263 -8
  36. package/dist/OAuthModel/model.js +165 -113
  37. package/dist/OAuthModel/model.js.map +1 -1
  38. package/dist/OAuthModel/util.d.ts +7 -0
  39. package/dist/OAuthModel/util.js +60 -0
  40. package/dist/OAuthModel/util.js.map +1 -0
  41. package/dist/index.d.ts +954 -105
  42. package/dist/util.d.ts +6 -0
  43. package/dist/util.js +23 -0
  44. package/dist/util.js.map +1 -0
  45. package/esm/DropboxOAuthModel/configSchema.d.ts +105 -1
  46. package/esm/DropboxOAuthModel/configSchema.js +0 -8
  47. package/esm/DropboxOAuthModel/configSchema.js.map +1 -1
  48. package/esm/DropboxOAuthModel/model.d.ts +304 -8
  49. package/esm/DropboxOAuthModel/model.js +26 -35
  50. package/esm/DropboxOAuthModel/model.js.map +1 -1
  51. package/esm/DropboxOAuthModel/util.d.ts +1 -0
  52. package/esm/DropboxOAuthModel/util.js +24 -0
  53. package/esm/DropboxOAuthModel/util.js.map +1 -0
  54. package/esm/ExternalTokenModel/ExternalTokenEntryForm.d.ts +2 -2
  55. package/esm/ExternalTokenModel/ExternalTokenEntryForm.js +10 -11
  56. package/esm/ExternalTokenModel/ExternalTokenEntryForm.js.map +1 -1
  57. package/esm/ExternalTokenModel/configSchema.d.ts +36 -1
  58. package/esm/ExternalTokenModel/model.d.ts +93 -3
  59. package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.d.ts +15 -0
  60. package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.js +16 -0
  61. package/esm/GoogleDriveOAuthModel/GoogleDriveFilehandle.js.map +1 -0
  62. package/esm/GoogleDriveOAuthModel/configSchema.d.ts +105 -1
  63. package/esm/GoogleDriveOAuthModel/model.d.ts +219 -20
  64. package/esm/GoogleDriveOAuthModel/model.js +37 -49
  65. package/esm/GoogleDriveOAuthModel/model.js.map +1 -1
  66. package/esm/GoogleDriveOAuthModel/util.d.ts +1 -0
  67. package/esm/GoogleDriveOAuthModel/util.js +13 -0
  68. package/esm/GoogleDriveOAuthModel/util.js.map +1 -0
  69. package/esm/HTTPBasicModel/HTTPBasicLoginForm.d.ts +2 -2
  70. package/esm/HTTPBasicModel/HTTPBasicLoginForm.js +18 -22
  71. package/esm/HTTPBasicModel/HTTPBasicLoginForm.js.map +1 -1
  72. package/esm/HTTPBasicModel/configSchema.d.ts +44 -1
  73. package/esm/HTTPBasicModel/model.d.ts +135 -3
  74. package/esm/HTTPBasicModel/model.js +24 -9
  75. package/esm/HTTPBasicModel/model.js.map +1 -1
  76. package/esm/OAuthModel/configSchema.d.ts +94 -1
  77. package/esm/OAuthModel/configSchema.js +1 -9
  78. package/esm/OAuthModel/configSchema.js.map +1 -1
  79. package/esm/OAuthModel/model.d.ts +263 -8
  80. package/esm/OAuthModel/model.js +164 -86
  81. package/esm/OAuthModel/model.js.map +1 -1
  82. package/esm/OAuthModel/util.d.ts +7 -0
  83. package/esm/OAuthModel/util.js +30 -0
  84. package/esm/OAuthModel/util.js.map +1 -0
  85. package/esm/index.d.ts +954 -105
  86. package/esm/util.d.ts +6 -0
  87. package/esm/util.js +18 -0
  88. package/esm/util.js.map +1 -0
  89. package/package.json +3 -4
  90. package/src/DropboxOAuthModel/configSchema.ts +0 -8
  91. package/src/DropboxOAuthModel/model.tsx +35 -54
  92. package/src/DropboxOAuthModel/util.ts +36 -0
  93. package/src/ExternalTokenModel/ExternalTokenEntryForm.tsx +39 -41
  94. package/src/GoogleDriveOAuthModel/GoogleDriveFilehandle.ts +38 -0
  95. package/src/GoogleDriveOAuthModel/model.tsx +54 -104
  96. package/src/GoogleDriveOAuthModel/util.ts +29 -0
  97. package/src/HTTPBasicModel/HTTPBasicLoginForm.tsx +53 -56
  98. package/src/HTTPBasicModel/model.tsx +26 -11
  99. package/src/OAuthModel/configSchema.ts +2 -9
  100. package/src/OAuthModel/model.tsx +190 -108
  101. package/src/OAuthModel/util.ts +33 -0
  102. package/src/util.ts +25 -0
@@ -3,75 +3,60 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GoogleDriveFile = void 0;
7
6
  const react_1 = __importDefault(require("react"));
8
7
  const configuration_1 = require("@jbrowse/core/configuration");
9
8
  const mobx_state_tree_1 = require("mobx-state-tree");
10
- const io_1 = require("@jbrowse/core/util/io");
11
9
  const material_1 = require("@mui/material");
12
10
  const model_1 = __importDefault(require("../OAuthModel/model"));
13
11
  const OAuthModel_1 = require("../OAuthModel");
14
- class GoogleDriveFile extends io_1.RemoteFileWithRangeCache {
15
- constructor(source, opts) {
16
- super(source, opts);
17
- this.statsPromise = this.fetch(source, {
18
- metadataOnly: true,
19
- }).then((response) => response.json());
20
- }
21
- async fetch(input, opts) {
22
- return super.fetch(input, opts);
23
- }
24
- async stat() {
25
- return this.statsPromise;
26
- }
27
- }
28
- exports.GoogleDriveFile = GoogleDriveFile;
12
+ const util_1 = require("./util");
13
+ const GoogleDriveFilehandle_1 = require("./GoogleDriveFilehandle");
29
14
  function GoogleDriveIcon(props) {
30
15
  return (react_1.default.createElement(material_1.SvgIcon, { ...props },
31
16
  react_1.default.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" })));
32
17
  }
33
- async function getDescriptiveErrorMessage(response) {
34
- let errorMessage;
35
- try {
36
- errorMessage = await response.text();
37
- }
38
- catch (error) {
39
- errorMessage = '';
40
- }
41
- if (errorMessage) {
42
- let errorMessageParsed;
43
- try {
44
- errorMessageParsed = JSON.parse(errorMessage);
45
- }
46
- catch (error) {
47
- errorMessageParsed = undefined;
48
- }
49
- if (errorMessageParsed) {
50
- errorMessage = errorMessageParsed.error.message;
51
- }
52
- }
53
- return `Network response failure — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`;
18
+ function getUri(str) {
19
+ const urlId = str.match(/[-\w]{25,}/);
20
+ return `https://www.googleapis.com/drive/v3/files/${urlId}`;
54
21
  }
55
- const stateModelFactory = (configSchema) => {
22
+ /**
23
+ * #stateModel GoogleDriveOAuthInternetAccount
24
+ */
25
+ function stateModelFactory(configSchema) {
56
26
  return (0, model_1.default)(OAuthModel_1.configSchema)
57
27
  .named('GoogleDriveOAuthInternetAccount')
58
28
  .props({
29
+ /**
30
+ * #property
31
+ */
59
32
  type: mobx_state_tree_1.types.literal('GoogleDriveOAuthInternetAccount'),
33
+ /**
34
+ * #property
35
+ */
60
36
  configuration: (0, configuration_1.ConfigurationReference)(configSchema),
61
37
  })
62
38
  .views(() => ({
39
+ /**
40
+ * #getter
41
+ * The FileSelector icon for Google drive
42
+ */
63
43
  get toggleContents() {
64
44
  return react_1.default.createElement(GoogleDriveIcon, null);
65
45
  },
46
+ /**
47
+ * #getter
48
+ */
66
49
  get selectorLabel() {
67
50
  return 'Enter Google Drive share link';
68
51
  },
69
52
  }))
70
53
  .actions(self => ({
54
+ /**
55
+ * #method
56
+ */
71
57
  getFetcher(location) {
72
58
  return async (input, init) => {
73
- const urlId = String(input).match(/[-\w]{25,}/);
74
- const driveUrl = new URL(`https://www.googleapis.com/drive/v3/files/${urlId}`);
59
+ const driveUrl = new URL(getUri(String(input)));
75
60
  const searchParams = new URLSearchParams();
76
61
  if (init === null || init === void 0 ? void 0 : init.metadataOnly) {
77
62
  searchParams.append('fields', 'size');
@@ -81,35 +66,37 @@ const stateModelFactory = (configSchema) => {
81
66
  }
82
67
  driveUrl.search = searchParams.toString();
83
68
  const authToken = await self.getToken(location);
84
- const newInit = self.addAuthHeaderToInit({ ...init, method: 'GET', credentials: 'same-origin' }, authToken);
85
- const response = await fetch(driveUrl.toString(), newInit);
69
+ const response = await fetch(driveUrl, self.addAuthHeaderToInit({ ...init, method: 'GET', credentials: 'same-origin' }, authToken));
86
70
  if (!response.ok) {
87
- const message = await getDescriptiveErrorMessage(response);
88
- throw new Error(message);
71
+ throw new Error(await (0, util_1.getDescriptiveErrorMessage)(response));
89
72
  }
90
73
  return response;
91
74
  };
92
75
  },
76
+ /**
77
+ * #method
78
+ */
93
79
  openLocation(location) {
94
- return new GoogleDriveFile(location.uri, {
80
+ return new GoogleDriveFilehandle_1.GoogleDriveFile(location.uri, {
95
81
  fetch: this.getFetcher(location),
96
82
  });
97
83
  },
84
+ /**
85
+ * #action
86
+ */
98
87
  async validateToken(token, location) {
99
- const urlId = location.uri.match(/[-\w]{25,}/);
100
- const response = await fetch(`https://www.googleapis.com/drive/v3/files/${urlId}`, {
88
+ const response = await fetch(getUri(location.uri), {
101
89
  headers: {
102
90
  Authorization: `Bearer ${token}`,
103
91
  'Content-Type': 'application/x-www-form-urlencoded',
104
92
  },
105
93
  });
106
94
  if (!response.ok) {
107
- const message = await getDescriptiveErrorMessage(response);
108
- throw new Error(`Token could not be validated. ${message}`);
95
+ throw new Error(await (0, util_1.getDescriptiveErrorMessage)(response, 'Token could not be validated'));
109
96
  }
110
97
  return token;
111
98
  },
112
99
  }));
113
- };
100
+ }
114
101
  exports.default = stateModelFactory;
115
102
  //# sourceMappingURL=model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/GoogleDriveOAuthModel/model.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,+DAAoE;AACpE,qDAAiD;AACjD,8CAAgE;AAEhE,4CAAqD;AASrD,gEAA2C;AAC3C,8CAAiE;AA2BjE,MAAa,eAAgB,SAAQ,6BAAwB;IAE3D,YAAY,MA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AA8B,CAC/B,CACF,CAAA;aACF;YACD,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAC,CAAC,CAAA;AACP,CAAC;AAvFD,oCAuFC"}
@@ -0,0 +1 @@
1
+ export declare function getDescriptiveErrorMessage(response: Response, reason?: string): Promise<string>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getDescriptiveErrorMessage = void 0;
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
+ /* do nothing */
13
+ }
14
+ return (0, util_1.getResponseError)({ response, reason, statusText: errorMessage });
15
+ }
16
+ exports.getDescriptiveErrorMessage = getDescriptiveErrorMessage;
17
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/GoogleDriveOAuthModel/util.ts"],"names":[],"mappings":";;;AAAA,kCAA0C;AAgBnC,KAAK,UAAU,0BAA0B,CAC9C,QAAkB,EAClB,MAAe;IAEf,IAAI,YAAY,GAAG,EAAE,CAAA;IACrB,IAAI;QACF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAqB,CAAA;QACjE,YAAY,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAA;KACjC;IAAC,OAAO,KAAK,EAAE;QACd,gBAAgB;KACjB;IACD,OAAO,IAAA,uBAAgB,EAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAA;AACzE,CAAC;AAZD,gEAYC"}
@@ -1,5 +1,5 @@
1
- /// <reference types="react" />
1
+ import React from 'react';
2
2
  export declare const HTTPBasicLoginForm: ({ internetAccountId, handleClose, }: {
3
3
  internetAccountId: string;
4
4
  handleClose: (arg?: string) => void;
5
- }) => JSX.Element;
5
+ }) => React.JSX.Element;
@@ -26,30 +26,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.HTTPBasicLoginForm = void 0;
27
27
  const react_1 = __importStar(require("react"));
28
28
  const material_1 = require("@mui/material");
29
+ const ui_1 = require("@jbrowse/core/ui");
29
30
  const HTTPBasicLoginForm = ({ internetAccountId, handleClose, }) => {
30
31
  const [username, setUsername] = (0, react_1.useState)('');
31
32
  const [password, setPassword] = (0, react_1.useState)('');
32
- function onSubmit(event) {
33
- if (username && password) {
34
- handleClose(btoa(`${username}:${password}`));
35
- }
36
- else {
37
- handleClose();
38
- }
39
- event.preventDefault();
40
- }
41
- return (react_1.default.createElement(react_1.default.Fragment, null,
42
- react_1.default.createElement(material_1.Dialog, { open: true, maxWidth: "xl", "data-testid": "login-httpbasic" },
43
- react_1.default.createElement(material_1.DialogTitle, null,
44
- "Log In for ",
45
- internetAccountId),
46
- react_1.default.createElement("form", { onSubmit: onSubmit },
47
- react_1.default.createElement(material_1.DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
48
- react_1.default.createElement(material_1.TextField, { required: true, label: "Username", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-username' }, onChange: event => setUsername(event.target.value), margin: "dense" }),
49
- react_1.default.createElement(material_1.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" })),
50
- react_1.default.createElement(material_1.DialogActions, null,
51
- react_1.default.createElement(material_1.Button, { variant: "contained", color: "primary", type: "submit" }, "Submit"),
52
- react_1.default.createElement(material_1.Button, { variant: "contained", type: "submit", onClick: () => handleClose() }, "Cancel"))))));
33
+ return (react_1.default.createElement(ui_1.Dialog, { open: true, maxWidth: "xl", "data-testid": "login-httpbasic", title: `Log In for ${internetAccountId}` },
34
+ react_1.default.createElement("form", { onSubmit: event => {
35
+ if (username && password) {
36
+ handleClose(btoa(`${username}:${password}`));
37
+ }
38
+ else {
39
+ handleClose();
40
+ }
41
+ event.preventDefault();
42
+ } },
43
+ react_1.default.createElement(material_1.DialogContent, { style: { display: 'flex', flexDirection: 'column' } },
44
+ react_1.default.createElement(material_1.TextField, { required: true, label: "Username", variant: "outlined", inputProps: { 'data-testid': 'login-httpbasic-username' }, onChange: event => setUsername(event.target.value), margin: "dense" }),
45
+ react_1.default.createElement(material_1.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" })),
46
+ react_1.default.createElement(material_1.DialogActions, null,
47
+ react_1.default.createElement(material_1.Button, { variant: "contained", color: "primary", type: "submit" }, "Submit"),
48
+ react_1.default.createElement(material_1.Button, { variant: "contained", color: "secondary", type: "submit", onClick: () => handleClose() }, "Cancel")))));
53
49
  };
54
50
  exports.HTTPBasicLoginForm = HTTPBasicLoginForm;
55
51
  //# sourceMappingURL=HTTPBasicLoginForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HTTPBasicLoginForm.js","sourceRoot":"","sources":["../../src/HTTPBasicModel/HTTPBasicLoginForm.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAuC;AACvC,4CAOsB;AAEf,MAAM,kBAAkB,GAAG,CAAC,EACjC,iBAAiB,EACjB,WAAW,GAIZ,EAAE,EAAE;IACH,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,EAAE,CAAC,CAAA;IAC5C,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,IAAA,gBAAQ,EAAC,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;a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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;YAChB,8BAAC,wBAAa;gBACZ,8BAAC,iBAAM,IAAC,OAAO,EAAC,WAAW,EAAC,KAAK,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,aAEhD;gBACT,8BAAC,iBAAM,IACL,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,WAAW,EACjB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,aAGrB,CACK,CACX,CACA,CACV,CAAA;AACH,CAAC,CAAA;AA/DY,QAAA,kBAAkB,sBA+D9B"}
@@ -1,5 +1,48 @@
1
1
  import { Instance } from 'mobx-state-tree';
2
- declare const HTTPBasicConfigSchema: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
2
+ declare const HTTPBasicConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
3
+ /**
4
+ * #slot
5
+ */
6
+ tokenType: {
7
+ description: string;
8
+ type: string;
9
+ defaultValue: string;
10
+ };
11
+ /**
12
+ * #slot
13
+ */
14
+ validateWithHEAD: {
15
+ description: string;
16
+ type: string;
17
+ defaultValue: boolean;
18
+ };
19
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
20
+ name: {
21
+ description: string;
22
+ type: string;
23
+ defaultValue: string;
24
+ };
25
+ description: {
26
+ description: string;
27
+ type: string;
28
+ defaultValue: string;
29
+ };
30
+ authHeader: {
31
+ description: string;
32
+ type: string;
33
+ defaultValue: string;
34
+ };
35
+ tokenType: {
36
+ description: string;
37
+ type: string;
38
+ defaultValue: string;
39
+ };
40
+ domains: {
41
+ description: string;
42
+ type: string;
43
+ defaultValue: never[];
44
+ };
45
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
3
46
  export type HTTPBasicInternetAccountConfigModel = typeof HTTPBasicConfigSchema;
4
47
  export type HTTPBasicInternetAccountConfig = Instance<HTTPBasicInternetAccountConfigModel>;
5
48
  export default HTTPBasicConfigSchema;
@@ -1,13 +1,136 @@
1
1
  /// <reference types="react" />
2
2
  import { UriLocation } from '@jbrowse/core/util/types';
3
- import { HTTPBasicInternetAccountConfigModel } from './configSchema';
4
3
  import { Instance } from 'mobx-state-tree';
5
- declare const stateModelFactory: (configSchema: HTTPBasicInternetAccountConfigModel) => import("mobx-state-tree").IModelType<{
4
+ /**
5
+ * #stateModel HTTPBasicInternetAccount
6
+ */
7
+ declare const stateModelFactory: (configSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
8
+ tokenType: {
9
+ description: string;
10
+ type: string;
11
+ defaultValue: string;
12
+ };
13
+ validateWithHEAD: {
14
+ description: string;
15
+ type: string;
16
+ defaultValue: boolean; /**
17
+ * #property
18
+ */
19
+ };
20
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
21
+ name: {
22
+ description: string;
23
+ type: string;
24
+ defaultValue: string;
25
+ };
26
+ description: {
27
+ description: string;
28
+ type: string;
29
+ defaultValue: string;
30
+ };
31
+ authHeader: {
32
+ description: string;
33
+ type: string;
34
+ defaultValue: string;
35
+ };
36
+ tokenType: {
37
+ description: string;
38
+ type: string;
39
+ defaultValue: string;
40
+ };
41
+ domains: {
42
+ description: string;
43
+ type: string;
44
+ /**
45
+ * #property
46
+ */
47
+ defaultValue: never[];
48
+ };
49
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>) => import("mobx-state-tree").IModelType<{
6
50
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
7
51
  type: import("mobx-state-tree").ISimpleType<string>;
52
+ configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
53
+ name: {
54
+ description: string;
55
+ type: string;
56
+ defaultValue: string;
57
+ }; /**
58
+ * #property
59
+ */
60
+ description: {
61
+ description: string;
62
+ type: string;
63
+ defaultValue: string;
64
+ }; /**
65
+ * #getter
66
+ */
67
+ authHeader: {
68
+ description: string;
69
+ type: string;
70
+ defaultValue: string;
71
+ };
72
+ tokenType: {
73
+ description: string;
74
+ type: string;
75
+ defaultValue: string;
76
+ };
77
+ domains: {
78
+ description: string;
79
+ type: string;
80
+ defaultValue: never[];
81
+ };
82
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>;
8
83
  } & {
84
+ /**
85
+ * #property
86
+ */
9
87
  type: import("mobx-state-tree").ISimpleType<"HTTPBasicInternetAccount">;
10
- configuration: import("mobx-state-tree").ITypeUnion<any, any, any>;
88
+ /**
89
+ * #property
90
+ */
91
+ configuration: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
92
+ tokenType: {
93
+ description: string;
94
+ type: string;
95
+ defaultValue: string;
96
+ };
97
+ validateWithHEAD: {
98
+ description: string;
99
+ type: string;
100
+ defaultValue: boolean; /**
101
+ * #property
102
+ */
103
+ };
104
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
105
+ name: {
106
+ description: string;
107
+ type: string;
108
+ defaultValue: string;
109
+ };
110
+ description: {
111
+ description: string;
112
+ type: string;
113
+ defaultValue: string;
114
+ };
115
+ authHeader: {
116
+ description: string;
117
+ type: string;
118
+ defaultValue: string;
119
+ };
120
+ tokenType: {
121
+ description: string;
122
+ type: string;
123
+ defaultValue: string;
124
+ };
125
+ domains: {
126
+ description: string;
127
+ type: string;
128
+ /**
129
+ * #property
130
+ */
131
+ defaultValue: never[];
132
+ };
133
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
11
134
  }, {
12
135
  readonly name: string;
13
136
  readonly description: string;
@@ -57,9 +180,18 @@ declare const stateModelFactory: (configSchema: HTTPBasicInternetAccountConfigMo
57
180
  } & {
58
181
  openLocation(location: UriLocation): import("@jbrowse/core/util/io").RemoteFileWithRangeCache;
59
182
  } & {
183
+ /**
184
+ * #getter
185
+ */
60
186
  readonly validateWithHEAD: boolean;
61
187
  } & {
188
+ /**
189
+ * #action
190
+ */
62
191
  getTokenFromUser(resolve: (token: string) => void, reject: (error: Error) => void): void;
192
+ /**
193
+ * #action
194
+ */
63
195
  validateToken(token: string, location: UriLocation): Promise<string>;
64
196
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
65
197
  export default stateModelFactory;
@@ -4,18 +4,34 @@ const configuration_1 = require("@jbrowse/core/configuration");
4
4
  const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
5
5
  const mobx_state_tree_1 = require("mobx-state-tree");
6
6
  const HTTPBasicLoginForm_1 = require("./HTTPBasicLoginForm");
7
+ const util_1 = require("../util");
8
+ /**
9
+ * #stateModel HTTPBasicInternetAccount
10
+ */
7
11
  const stateModelFactory = (configSchema) => {
8
12
  return models_1.InternetAccount.named('HTTPBasicInternetAccount')
9
13
  .props({
14
+ /**
15
+ * #property
16
+ */
10
17
  type: mobx_state_tree_1.types.literal('HTTPBasicInternetAccount'),
18
+ /**
19
+ * #property
20
+ */
11
21
  configuration: (0, configuration_1.ConfigurationReference)(configSchema),
12
22
  })
13
23
  .views(self => ({
24
+ /**
25
+ * #getter
26
+ */
14
27
  get validateWithHEAD() {
15
28
  return (0, configuration_1.getConf)(self, 'validateWithHEAD');
16
29
  },
17
30
  }))
18
31
  .actions(self => ({
32
+ /**
33
+ * #action
34
+ */
19
35
  getTokenFromUser(resolve, reject) {
20
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
37
  const { session } = (0, mobx_state_tree_1.getRoot)(self);
@@ -28,13 +44,16 @@ const stateModelFactory = (configSchema) => {
28
44
  resolve(token);
29
45
  }
30
46
  else {
31
- reject(new Error('user cancelled entry'));
47
+ reject(new Error('User cancelled entry'));
32
48
  }
33
49
  doneCallback();
34
50
  },
35
51
  },
36
52
  ]);
37
53
  },
54
+ /**
55
+ * #action
56
+ */
38
57
  async validateToken(token, location) {
39
58
  if (!self.validateWithHEAD) {
40
59
  return token;
@@ -42,14 +61,10 @@ const stateModelFactory = (configSchema) => {
42
61
  const newInit = self.addAuthHeaderToInit({ method: 'HEAD' }, token);
43
62
  const response = await fetch(location.uri, newInit);
44
63
  if (!response.ok) {
45
- let errorMessage;
46
- try {
47
- errorMessage = await response.text();
48
- }
49
- catch (error) {
50
- errorMessage = '';
51
- }
52
- throw new Error(`Error validating token — ${response.status} (${response.statusText})${errorMessage ? ` (${errorMessage})` : ''}`);
64
+ throw new Error(await (0, util_1.getResponseError)({
65
+ response,
66
+ reason: 'Error validating token',
67
+ }));
53
68
  }
54
69
  return token;
55
70
  },
@@ -1 +1 @@
1
- {"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/HTTPBasicModel/model.tsx"],"names":[],"mappings":";;AAAA,+DAA6E;AAC7E,uEAA4E;AAG5E,qDAA0D;AAE1D,6DAAyD;AAEzD,MAAM,iBAAiB,GAAG,CACxB,YAAiD,EACjD,EAAE;IACF,OAAO,wBAAe,CAAC,KAAK,CAAC,0BAA0B,CAAC;SACrD,KAAK,CAAC;QACL,IAAI,EAAE,uBAAK,CAAC,OAAO,CAAC,0BAA0B,CAAC;QAC/C,aAAa,EAAE,IAAA,sCAAsB,EAAC,YAAY,CAAC;KACpD,CAAC;SACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACd,IAAI,gBAAgB;YAClB,OAAO,IAAA,uBAAO,EAAC,I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ACL,MAAM,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAA;yBAC1C;wBACD,YAAY,EAAE,CAAA;oBAChB,CAAC;iBACF;aACF,CAAC,CAAA;QACJ,CAAC;QACD;;WAEG;QACH,KAAK,CAAC,aAAa,CAAC,KAAa,EAAE,QAAqB;YACtD,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;gBAC1B,OAAO,KAAK,CAAA;aACb;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAA;YACnE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YACnD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;gBAChB,MAAM,IAAI,KAAK,CACb,MAAM,IAAA,uBAAgB,EAAC;oBACrB,QAAQ;oBACR,MAAM,EAAE,wBAAwB;iBACjC,CAAC,CACH,CAAA;aACF;YACD,OAAO,KAAK,CAAA;QACd,CAAC;KACF,CAAC,CAAC,CAAA;AACP,CAAC,CAAA;AAED,kBAAe,iBAAiB,CAAA"}
@@ -1,5 +1,98 @@
1
1
  import { Instance } from 'mobx-state-tree';
2
- declare const OAuthConfigSchema: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
2
+ declare const OAuthConfigSchema: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
3
+ /**
4
+ * #slot
5
+ */
6
+ tokenType: {
7
+ description: string;
8
+ type: string;
9
+ defaultValue: string;
10
+ };
11
+ /**
12
+ * #slot
13
+ */
14
+ authEndpoint: {
15
+ description: string;
16
+ type: string;
17
+ defaultValue: string;
18
+ };
19
+ /**
20
+ * #slot
21
+ */
22
+ tokenEndpoint: {
23
+ description: string;
24
+ type: string;
25
+ defaultValue: string;
26
+ };
27
+ /**
28
+ * #slot
29
+ */
30
+ needsPKCE: {
31
+ description: string;
32
+ type: string;
33
+ defaultValue: boolean;
34
+ };
35
+ /**
36
+ * #slot
37
+ */
38
+ clientId: {
39
+ description: string;
40
+ type: string;
41
+ defaultValue: string;
42
+ };
43
+ /**
44
+ * #slot
45
+ */
46
+ scopes: {
47
+ description: string;
48
+ type: string;
49
+ defaultValue: string;
50
+ };
51
+ /**
52
+ * #slot
53
+ */
54
+ state: {
55
+ description: string;
56
+ type: string;
57
+ defaultValue: string;
58
+ };
59
+ /**
60
+ * #slot
61
+ */
62
+ responseType: {
63
+ description: string;
64
+ type: string;
65
+ defaultValue: string;
66
+ };
67
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
68
+ name: {
69
+ description: string;
70
+ type: string;
71
+ defaultValue: string;
72
+ };
73
+ description: {
74
+ description: string;
75
+ type: string;
76
+ defaultValue: string;
77
+ }; /**
78
+ * #slot
79
+ */
80
+ authHeader: {
81
+ description: string;
82
+ type: string;
83
+ defaultValue: string;
84
+ };
85
+ tokenType: {
86
+ description: string;
87
+ type: string;
88
+ defaultValue: string;
89
+ };
90
+ domains: {
91
+ description: string;
92
+ type: string;
93
+ defaultValue: never[];
94
+ };
95
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, "internetAccountId">>, undefined>>;
3
96
  export type OAuthInternetAccountConfigModel = typeof OAuthConfigSchema;
4
97
  export type OAuthInternetAccountConfig = Instance<OAuthInternetAccountConfigModel>;
5
98
  export default OAuthConfigSchema;