@jbrowse/core 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (179) hide show
  1. package/BaseFeatureWidget/BaseFeatureDetail.d.ts +6 -0
  2. package/BaseFeatureWidget/BaseFeatureDetail.js +313 -592
  3. package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -479
  4. package/BaseFeatureWidget/index.js +88 -126
  5. package/BaseFeatureWidget/types.js +1 -4
  6. package/BaseFeatureWidget/util.js +40 -75
  7. package/CorePlugin.js +55 -94
  8. package/Plugin.js +9 -34
  9. package/PluginLoader.js +153 -422
  10. package/PluginManager.d.ts +17 -14
  11. package/PluginManager.js +377 -666
  12. package/ReExports/Attributes.js +3 -10
  13. package/ReExports/BaseCard.js +3 -10
  14. package/ReExports/DataGrid.js +5 -12
  15. package/ReExports/FeatureDetails.js +3 -10
  16. package/ReExports/index.js +6 -12
  17. package/ReExports/list.d.ts +5 -0
  18. package/ReExports/list.js +271 -7
  19. package/ReExports/material-ui-colors.js +15 -16
  20. package/ReExports/modules.d.ts +0 -1
  21. package/ReExports/modules.js +453 -798
  22. package/TextSearch/BaseResults.js +51 -123
  23. package/TextSearch/TextSearchManager.js +66 -144
  24. package/assemblyManager/assembly.js +280 -555
  25. package/assemblyManager/assemblyConfigSchema.js +47 -64
  26. package/assemblyManager/assemblyManager.js +126 -272
  27. package/assemblyManager/index.js +9 -22
  28. package/configuration/configurationSchema.js +167 -203
  29. package/configuration/configurationSlot.js +248 -326
  30. package/configuration/index.js +19 -35
  31. package/configuration/util.js +131 -173
  32. package/data_adapters/BaseAdapter.d.ts +2 -2
  33. package/data_adapters/BaseAdapter.js +132 -521
  34. package/data_adapters/CytobandAdapter.js +40 -126
  35. package/data_adapters/dataAdapterCache.js +77 -158
  36. package/package.json +4 -5
  37. package/pluggableElementTypes/AdapterType.js +24 -79
  38. package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
  39. package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
  40. package/pluggableElementTypes/ConnectionType.js +22 -65
  41. package/pluggableElementTypes/DisplayType.js +35 -82
  42. package/pluggableElementTypes/InternetAccountType.js +23 -64
  43. package/pluggableElementTypes/PluggableElementBase.js +8 -20
  44. package/pluggableElementTypes/RpcMethodType.js +85 -427
  45. package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
  46. package/pluggableElementTypes/TrackType.js +26 -70
  47. package/pluggableElementTypes/ViewType.js +21 -63
  48. package/pluggableElementTypes/WidgetType.js +21 -64
  49. package/pluggableElementTypes/index.d.ts +4 -3
  50. package/pluggableElementTypes/index.js +42 -125
  51. package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
  52. package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
  53. package/pluggableElementTypes/models/BaseTrackModel.js +139 -199
  54. package/pluggableElementTypes/models/BaseViewModel.js +24 -40
  55. package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
  56. package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
  57. package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
  58. package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
  59. package/pluggableElementTypes/models/index.js +21 -70
  60. package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
  61. package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
  62. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
  63. package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
  64. package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -264
  65. package/pluggableElementTypes/renderers/RendererType.js +31 -105
  66. package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
  67. package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
  68. package/pluggableElementTypes/renderers/index.js +19 -62
  69. package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
  70. package/rpc/BaseRpcDriver.js +169 -405
  71. package/rpc/MainThreadRpcDriver.js +27 -150
  72. package/rpc/RpcManager.js +58 -159
  73. package/rpc/WebWorkerRpcDriver.js +54 -171
  74. package/rpc/configSchema.js +25 -49
  75. package/rpc/coreRpcMethods.js +221 -959
  76. package/rpc/remoteAbortSignals.js +46 -70
  77. package/tsconfig.build.tsbuildinfo +1 -1
  78. package/ui/AboutDialog.js +106 -162
  79. package/ui/App.js +157 -242
  80. package/ui/AssemblySelector.js +59 -120
  81. package/ui/CascadingMenu.js +101 -196
  82. package/ui/ColorPicker.d.ts +16 -0
  83. package/ui/ColorPicker.js +97 -0
  84. package/ui/Drawer.js +28 -61
  85. package/ui/DrawerWidget.js +108 -202
  86. package/ui/DropDownMenu.js +60 -91
  87. package/ui/EditableTypography.js +87 -149
  88. package/ui/ErrorMessage.js +41 -56
  89. package/ui/FactoryResetDialog.js +24 -57
  90. package/ui/FatalErrorDialog.js +59 -91
  91. package/ui/FileSelector/FileSelector.js +123 -189
  92. package/ui/FileSelector/LocalFileChooser.js +44 -75
  93. package/ui/FileSelector/UrlChooser.js +17 -38
  94. package/ui/FileSelector/index.js +6 -12
  95. package/ui/Icons.js +45 -69
  96. package/ui/Logo.js +57 -110
  97. package/ui/Menu.js +232 -354
  98. package/ui/PrerenderedCanvas.js +63 -87
  99. package/ui/ResizeHandle.js +87 -116
  100. package/ui/ReturnToImportFormDialog.js +32 -63
  101. package/ui/SanitizedHTML.js +64 -47
  102. package/ui/Snackbar.js +74 -101
  103. package/ui/SnackbarModel.js +37 -51
  104. package/ui/Tooltip.js +49 -76
  105. package/ui/ViewContainer.js +113 -196
  106. package/ui/colors.d.ts +10 -0
  107. package/ui/colors.js +78 -0
  108. package/ui/index.js +51 -181
  109. package/ui/react-colorful.d.ts +17 -0
  110. package/ui/react-colorful.js +455 -0
  111. package/ui/theme.js +199 -247
  112. package/util/Base1DUtils.js +163 -202
  113. package/util/Base1DViewModel.js +121 -168
  114. package/util/QuickLRU.js +84 -332
  115. package/util/TimeTraveller.d.ts +19 -0
  116. package/util/TimeTraveller.js +86 -0
  117. package/util/aborting.js +49 -127
  118. package/util/analytics.js +91 -154
  119. package/util/blockTypes.js +106 -240
  120. package/util/calculateDynamicBlocks.js +98 -128
  121. package/util/calculateStaticBlocks.js +105 -125
  122. package/util/color/cssColorsLevel4.js +156 -160
  123. package/util/color/index.js +33 -55
  124. package/util/compositeMap.js +49 -333
  125. package/util/formatFastaStrings.js +9 -14
  126. package/util/idMaker.js +18 -31
  127. package/util/index.d.ts +7 -20
  128. package/util/index.js +742 -1188
  129. package/util/io/RemoteFileWithRangeCache.js +88 -257
  130. package/util/io/index.js +95 -169
  131. package/util/jexl.js +60 -115
  132. package/util/jexlStrings.js +24 -29
  133. package/util/layouts/BaseLayout.js +1 -4
  134. package/util/layouts/GranularRectLayout.js +388 -555
  135. package/util/layouts/MultiLayout.js +41 -109
  136. package/util/layouts/PrecomputedLayout.js +56 -112
  137. package/util/layouts/PrecomputedMultiLayout.js +22 -59
  138. package/util/layouts/SceneGraph.js +127 -197
  139. package/util/layouts/index.js +29 -66
  140. package/util/mst-reflection.js +55 -71
  141. package/util/offscreenCanvasPonyfill.js +66 -134
  142. package/util/offscreenCanvasUtils.d.ts +2 -7
  143. package/util/offscreenCanvasUtils.js +49 -146
  144. package/util/range.js +29 -40
  145. package/util/rxjs.js +20 -27
  146. package/util/simpleFeature.js +88 -152
  147. package/util/stats.js +91 -151
  148. package/util/tracks.js +130 -173
  149. package/util/types/index.js +110 -179
  150. package/util/types/mst.js +91 -146
  151. package/util/types/util.js +1 -4
  152. package/util/when.js +54 -101
  153. package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
  154. package/BaseFeatureWidget/index.test.js +0 -69
  155. package/TextSearch/BaseResults.test.js +0 -42
  156. package/configuration/configurationSchema.test.js +0 -266
  157. package/configuration/configurationSlot.test.js +0 -69
  158. package/configuration/util.test.js +0 -39
  159. package/data_adapters/BaseAdapter.test.js +0 -200
  160. package/declare.d.js +0 -1
  161. package/pluggableElementTypes/RpcMethodType.test.js +0 -118
  162. package/pluggableElementTypes/renderers/declare.d.js +0 -1
  163. package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
  164. package/rpc/BaseRpcDriver.test.js +0 -540
  165. package/rpc/declaration.d.js +0 -1
  166. package/ui/FatalErrorDialog.test.js +0 -82
  167. package/ui/SanitizedHTML.test.js +0 -36
  168. package/ui/theme.test.js +0 -92
  169. package/util/Base1DViewModel.test.js +0 -130
  170. package/util/calculateDynamicBlocks.test.js +0 -74
  171. package/util/calculateStaticBlocks.test.js +0 -297
  172. package/util/declare.d.js +0 -1
  173. package/util/formatFastaStrings.test.js +0 -40
  174. package/util/index.test.js +0 -213
  175. package/util/jexlStrings.test.js +0 -48
  176. package/util/layouts/GranularRectLayout.test.js +0 -99
  177. package/util/range.test.js +0 -64
  178. package/util/simpleFeature.test.js +0 -34
  179. package/util/stats.test.js +0 -172
@@ -1,127 +1,91 @@
1
1
  "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
8
3
  exports.InternetAccount = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
-
16
- var _mobxStateTree = require("mobx-state-tree");
17
-
18
- var _configuration = require("../../configuration");
19
-
20
- var _io = require("../../util/io");
21
-
22
- var _mst = require("../../util/types/mst");
23
-
24
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
-
26
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
27
-
28
- var inWebWorker = typeof sessionStorage === 'undefined';
29
-
30
- var InternetAccount = _mobxStateTree.types.model('InternetAccount', {
31
- id: _mst.ElementId,
32
- type: _mobxStateTree.types.string
33
- }).views(function (self) {
34
- return {
4
+ const mobx_state_tree_1 = require("mobx-state-tree");
5
+ const configuration_1 = require("../../configuration");
6
+ const io_1 = require("../../util/io");
7
+ const mst_1 = require("../../util/types/mst");
8
+ const inWebWorker = typeof sessionStorage === 'undefined';
9
+ exports.InternetAccount = mobx_state_tree_1.types
10
+ .model('InternetAccount', {
11
+ id: mst_1.ElementId,
12
+ type: mobx_state_tree_1.types.string,
13
+ })
14
+ .views(self => ({
35
15
  get name() {
36
- return (0, _configuration.getConf)(self, 'name');
16
+ return (0, configuration_1.getConf)(self, 'name');
37
17
  },
38
-
39
18
  get description() {
40
- return (0, _configuration.getConf)(self, 'description');
19
+ return (0, configuration_1.getConf)(self, 'description');
41
20
  },
42
-
43
21
  get internetAccountId() {
44
- return (0, _configuration.getConf)(self, 'internetAccountId');
22
+ return (0, configuration_1.getConf)(self, 'internetAccountId');
45
23
  },
46
-
47
24
  get authHeader() {
48
- return (0, _configuration.getConf)(self, 'authHeader');
25
+ return (0, configuration_1.getConf)(self, 'authHeader');
49
26
  },
50
-
51
27
  get tokenType() {
52
- return (0, _configuration.getConf)(self, 'tokenType');
28
+ return (0, configuration_1.getConf)(self, 'tokenType');
53
29
  },
54
-
55
30
  get domains() {
56
- return (0, _configuration.getConf)(self, 'domains');
31
+ return (0, configuration_1.getConf)(self, 'domains');
57
32
  },
58
-
59
33
  /**
60
34
  * Can use this to customize what is displayed in fileSelector's toggle box
61
35
  */
62
36
  get toggleContents() {
63
- return null;
37
+ return null;
64
38
  },
65
-
66
39
  /**
67
40
  * Can use this to customize what the fileSelector. It takes a prop called
68
41
  * `setLocation` that should be used to set a UriLocation
69
42
  */
70
43
  get SelectorComponent() {
71
- return undefined;
44
+ return undefined;
72
45
  },
73
-
74
46
  /**
75
47
  * Can use this to add a label to the UrlChooser. Has no effect if a custom
76
48
  * SelectorComponent is supplied
77
49
  */
78
50
  get selectorLabel() {
79
- return undefined;
80
- }
81
-
82
- };
83
- }).views(function (self) {
84
- return {
51
+ return undefined;
52
+ },
53
+ }))
54
+ .views(self => ({
85
55
  /**
86
56
  * Determine whether this internetAccount provides credentials for a URL
87
57
  * @param location - UriLocation of resource
88
58
  * @returns true or false
89
59
  */
90
- handlesLocation: function handlesLocation(location) {
91
- return self.domains.some(function (domain) {
92
- return location === null || location === void 0 ? void 0 : location.uri.includes(domain);
93
- });
60
+ handlesLocation(location) {
61
+ return self.domains.some((domain) => location === null || location === void 0 ? void 0 : location.uri.includes(domain));
94
62
  },
95
-
96
63
  /**
97
64
  * The key used to store this internetAccount's token in sessionStorage
98
65
  */
99
66
  get tokenKey() {
100
- return "".concat(self.internetAccountId, "-token");
101
- }
102
-
103
- };
104
- }).actions(function (self) {
105
- return {
67
+ return `${self.internetAccountId}-token`;
68
+ },
69
+ }))
70
+ .actions(self => ({
106
71
  /**
107
72
  * Must be implemented by a model extending or composing this one. Pass the
108
73
  * user's token to `resolve`.
109
74
  * @param resolve - Pass the token to this function
110
75
  * @param reject - If there is an error getting the token, call this function
111
76
  */
112
- getTokenFromUser: function getTokenFromUser(resolve, reject) {
113
- throw new Error('getTokenFromUser must be implemented by extending model');
77
+ getTokenFromUser(resolve, reject) {
78
+ throw new Error('getTokenFromUser must be implemented by extending model');
114
79
  },
115
- storeToken: function storeToken(token) {
116
- sessionStorage.setItem(self.tokenKey, token);
80
+ storeToken(token) {
81
+ sessionStorage.setItem(self.tokenKey, token);
117
82
  },
118
- removeToken: function removeToken() {
119
- sessionStorage.removeItem(self.tokenKey);
83
+ removeToken() {
84
+ sessionStorage.removeItem(self.tokenKey);
120
85
  },
121
- retrieveToken: function retrieveToken() {
122
- return sessionStorage.getItem(self.tokenKey);
86
+ retrieveToken() {
87
+ return sessionStorage.getItem(self.tokenKey);
123
88
  },
124
-
125
89
  /**
126
90
  * This can be used by an internetAccount to validate a token works before
127
91
  * it is used. This is run when preAuthorizationInformation is requested, so
@@ -134,170 +98,85 @@ var InternetAccount = _mobxStateTree.types.model('InternetAccount', {
134
98
  * @param location - UriLocation of the resource
135
99
  * @returns - Valid auth token
136
100
  */
137
- validateToken: function validateToken(token, location) {
138
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
139
- return _regenerator.default.wrap(function _callee$(_context) {
140
- while (1) {
141
- switch (_context.prev = _context.next) {
142
- case 0:
143
- return _context.abrupt("return", token);
144
-
145
- case 1:
146
- case "end":
147
- return _context.stop();
101
+ async validateToken(token, location) {
102
+ return token;
103
+ },
104
+ }))
105
+ .actions(self => {
106
+ let tokenPromise = undefined;
107
+ return {
108
+ /**
109
+ * Try to get the token from the location pre-auth, from local storage,
110
+ * or from a previously cached promise. If token is not available, uses
111
+ * `getTokenFromUser`.
112
+ * @param location - UriLocation of the resource
113
+ * @returns A promise for the token
114
+ */
115
+ async getToken(location) {
116
+ var _a, _b;
117
+ if (tokenPromise) {
118
+ return tokenPromise;
148
119
  }
149
- }
150
- }, _callee);
151
- }))();
152
- }
153
- };
154
- }).actions(function (self) {
155
- var tokenPromise = undefined;
156
- return {
157
- /**
158
- * Try to get the token from the location pre-auth, from local storage,
159
- * or from a previously cached promise. If token is not available, uses
160
- * `getTokenFromUser`.
161
- * @param location - UriLocation of the resource
162
- * @returns A promise for the token
163
- */
164
- getToken: function getToken(location) {
165
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
166
- var _location$internetAcc, _location$internetAcc2;
167
-
168
- var token;
169
- return _regenerator.default.wrap(function _callee2$(_context2) {
170
- while (1) {
171
- switch (_context2.prev = _context2.next) {
172
- case 0:
173
- if (!tokenPromise) {
174
- _context2.next = 2;
175
- break;
176
- }
177
-
178
- return _context2.abrupt("return", tokenPromise);
179
-
180
- case 2:
181
- token = location === null || location === void 0 ? void 0 : (_location$internetAcc = location.internetAccountPreAuthorization) === null || _location$internetAcc === void 0 ? void 0 : (_location$internetAcc2 = _location$internetAcc.authInfo) === null || _location$internetAcc2 === void 0 ? void 0 : _location$internetAcc2.token;
182
-
183
- if (!token) {
184
- _context2.next = 6;
185
- break;
186
- }
187
-
120
+ let token = (_b = (_a = location === null || location === void 0 ? void 0 : location.internetAccountPreAuthorization) === null || _a === void 0 ? void 0 : _a.authInfo) === null || _b === void 0 ? void 0 : _b.token;
121
+ if (token) {
188
122
  tokenPromise = Promise.resolve(token);
189
- return _context2.abrupt("return", tokenPromise);
190
-
191
- case 6:
192
- if (!inWebWorker) {
193
- _context2.next = 8;
194
- break;
195
- }
196
-
123
+ return tokenPromise;
124
+ }
125
+ if (inWebWorker) {
197
126
  throw new Error('Did not get internet account pre-authorization info in worker');
198
-
199
- case 8:
200
- token = self.retrieveToken();
201
-
202
- if (!token) {
203
- _context2.next = 12;
204
- break;
205
- }
206
-
127
+ }
128
+ token = self.retrieveToken();
129
+ if (token) {
207
130
  tokenPromise = Promise.resolve(token);
208
- return _context2.abrupt("return", tokenPromise);
209
-
210
- case 12:
211
- tokenPromise = new Promise(function (r, x) {
212
- function resolve(token) {
131
+ return tokenPromise;
132
+ }
133
+ tokenPromise = new Promise((r, x) => {
134
+ function resolve(token) {
213
135
  self.storeToken(token);
214
136
  r(token);
215
- }
216
-
217
- function reject(error) {
137
+ }
138
+ function reject(error) {
218
139
  self.removeToken();
219
140
  x(error);
220
- }
221
-
222
- self.getTokenFromUser(resolve, reject);
223
- });
224
- return _context2.abrupt("return", tokenPromise);
225
-
226
- case 14:
227
- case "end":
228
- return _context2.stop();
229
- }
230
- }
231
- }, _callee2);
232
- }))();
233
- }
234
- };
235
- }).actions(function (self) {
236
- return {
237
- addAuthHeaderToInit: function addAuthHeaderToInit() {
238
- var init = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
239
- var token = arguments.length > 1 ? arguments[1] : undefined;
240
- var tokenInfoString = self.tokenType ? "".concat(self.tokenType, " ").concat(token) : token;
241
- var newHeaders = new Headers(init.headers || {});
242
- newHeaders.append(self.authHeader, tokenInfoString);
243
- return _objectSpread(_objectSpread({}, init), {}, {
244
- headers: newHeaders
245
- });
141
+ }
142
+ self.getTokenFromUser(resolve, reject);
143
+ });
144
+ return tokenPromise;
145
+ },
146
+ };
147
+ })
148
+ .actions(self => ({
149
+ addAuthHeaderToInit(init = {}, token) {
150
+ const tokenInfoString = self.tokenType
151
+ ? `${self.tokenType} ${token}`
152
+ : token;
153
+ const newHeaders = new Headers(init.headers || {});
154
+ newHeaders.append(self.authHeader, tokenInfoString);
155
+ return { ...init, headers: newHeaders };
246
156
  },
247
-
248
157
  /**
249
158
  * Gets the token and returns it along with the information needed to
250
159
  * create a new internetAccount.
251
160
  * @param location - UriLocation of the resource
252
161
  * @returns
253
162
  */
254
- getPreAuthorizationInformation: function getPreAuthorizationInformation(location) {
255
- return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
256
- var authToken, validatedToken;
257
- return _regenerator.default.wrap(function _callee3$(_context3) {
258
- while (1) {
259
- switch (_context3.prev = _context3.next) {
260
- case 0:
261
- _context3.next = 2;
262
- return self.getToken(location);
263
-
264
- case 2:
265
- authToken = _context3.sent;
266
- _context3.prev = 3;
267
- _context3.next = 6;
268
- return self.validateToken(authToken, location);
269
-
270
- case 6:
271
- validatedToken = _context3.sent;
272
- _context3.next = 13;
273
- break;
274
-
275
- case 9:
276
- _context3.prev = 9;
277
- _context3.t0 = _context3["catch"](3);
278
- self.removeToken();
279
- throw _context3.t0;
280
-
281
- case 13:
282
- return _context3.abrupt("return", {
283
- internetAccountType: self.type,
284
- authInfo: {
285
- token: validatedToken,
286
- configuration: (0, _configuration.getConf)(self)
287
- }
288
- });
289
-
290
- case 14:
291
- case "end":
292
- return _context3.stop();
293
- }
294
- }
295
- }, _callee3, null, [[3, 9]]);
296
- }))();
297
- }
298
- };
299
- }).actions(function (self) {
300
- return {
163
+ async getPreAuthorizationInformation(location) {
164
+ const authToken = await self.getToken(location);
165
+ let validatedToken;
166
+ try {
167
+ validatedToken = await self.validateToken(authToken, location);
168
+ }
169
+ catch (error) {
170
+ self.removeToken();
171
+ throw error;
172
+ }
173
+ return {
174
+ internetAccountType: self.type,
175
+ authInfo: { token: validatedToken, configuration: (0, configuration_1.getConf)(self) },
176
+ };
177
+ },
178
+ }))
179
+ .actions(self => ({
301
180
  /**
302
181
  * Get a fetch method that will add any needed authentication headers to
303
182
  * the request before sending it. If location is provided, it will be
@@ -305,49 +184,23 @@ var InternetAccount = _mobxStateTree.types.model('InternetAccount', {
305
184
  * @param location - UriLocation of the resource
306
185
  * @returns A function that can be used to fetch
307
186
  */
308
- getFetcher: function getFetcher(location) {
309
- return /*#__PURE__*/function () {
310
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(input, init) {
311
- var authToken, newInit;
312
- return _regenerator.default.wrap(function _callee4$(_context4) {
313
- while (1) {
314
- switch (_context4.prev = _context4.next) {
315
- case 0:
316
- _context4.next = 2;
317
- return self.getToken(location);
318
-
319
- case 2:
320
- authToken = _context4.sent;
321
- newInit = self.addAuthHeaderToInit(init, authToken);
322
- return _context4.abrupt("return", fetch(input, newInit));
323
-
324
- case 5:
325
- case "end":
326
- return _context4.stop();
327
- }
328
- }
329
- }, _callee4);
330
- }));
331
-
332
- return function (_x, _x2) {
333
- return _ref.apply(this, arguments);
187
+ getFetcher(location) {
188
+ return async (input, init) => {
189
+ const authToken = await self.getToken(location);
190
+ const newInit = self.addAuthHeaderToInit(init, authToken);
191
+ return fetch(input, newInit);
334
192
  };
335
- }();
336
- }
337
- };
338
- }).actions(function (self) {
339
- return {
193
+ },
194
+ }))
195
+ .actions(self => ({
340
196
  /**
341
197
  * Gets a filehandle that uses a fetch that adds auth headers
342
198
  * @param location - UriLocation of the resource
343
199
  * @returns A filehandle
344
200
  */
345
- openLocation: function openLocation(location) {
346
- return new _io.RemoteFileWithRangeCache(location.uri, {
347
- fetch: self.getFetcher(location)
348
- });
349
- }
350
- };
351
- });
352
-
353
- exports.InternetAccount = InternetAccount;
201
+ openLocation(location) {
202
+ return new io_1.RemoteFileWithRangeCache(location.uri, {
203
+ fetch: self.getFetcher(location),
204
+ });
205
+ },
206
+ }));
@@ -1,26 +1,15 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _configuration = require("../../configuration");
9
-
10
- var _default = (0, _configuration.ConfigurationSchema)('BaseConnection', {
11
- name: {
12
- type: 'string',
13
- defaultValue: 'nameOfConnection',
14
- description: 'a unique name for this connection'
15
- },
16
- assemblyNames: {
17
- type: 'stringArray',
18
- defaultValue: [],
19
- description: 'optional list of names of assemblies in this connection'
20
- }
21
- }, {
22
- explicitlyTyped: true,
23
- explicitIdentifier: 'connectionId'
24
- });
25
-
26
- exports.default = _default;
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const configuration_1 = require("../../configuration");
4
+ exports.default = (0, configuration_1.ConfigurationSchema)('BaseConnection', {
5
+ name: {
6
+ type: 'string',
7
+ defaultValue: 'nameOfConnection',
8
+ description: 'a unique name for this connection',
9
+ },
10
+ assemblyNames: {
11
+ type: 'stringArray',
12
+ defaultValue: [],
13
+ description: 'optional list of names of assemblies in this connection',
14
+ },
15
+ }, { explicitlyTyped: true, explicitIdentifier: 'connectionId' });
@@ -1,40 +1,31 @@
1
1
  "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
2
+ Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.BaseInternetAccountConfig = void 0;
7
-
8
- var _configuration = require("../../configuration");
9
-
10
- var BaseInternetAccountConfig = (0, _configuration.ConfigurationSchema)('InternetAccount', {
11
- name: {
12
- description: 'descriptive name of the internet account',
13
- type: 'string',
14
- defaultValue: ''
15
- },
16
- description: {
17
- description: 'a description of the internet account',
18
- type: 'string',
19
- defaultValue: ''
20
- },
21
- authHeader: {
22
- description: 'request header for credentials',
23
- type: 'string',
24
- defaultValue: 'Authorization'
25
- },
26
- tokenType: {
27
- description: 'a custom name for a token to include in the header',
28
- type: 'string',
29
- defaultValue: ''
30
- },
31
- domains: {
32
- description: 'array of valid domains the url can contain to use this account',
33
- type: 'stringArray',
34
- defaultValue: []
35
- }
36
- }, {
37
- explicitIdentifier: 'internetAccountId',
38
- explicitlyTyped: true
39
- });
40
- exports.BaseInternetAccountConfig = BaseInternetAccountConfig;
4
+ const configuration_1 = require("../../configuration");
5
+ exports.BaseInternetAccountConfig = (0, configuration_1.ConfigurationSchema)('InternetAccount', {
6
+ name: {
7
+ description: 'descriptive name of the internet account',
8
+ type: 'string',
9
+ defaultValue: '',
10
+ },
11
+ description: {
12
+ description: 'a description of the internet account',
13
+ type: 'string',
14
+ defaultValue: '',
15
+ },
16
+ authHeader: {
17
+ description: 'request header for credentials',
18
+ type: 'string',
19
+ defaultValue: 'Authorization',
20
+ },
21
+ tokenType: {
22
+ description: 'a custom name for a token to include in the header',
23
+ type: 'string',
24
+ defaultValue: '',
25
+ },
26
+ domains: {
27
+ description: 'array of valid domains the url can contain to use this account',
28
+ type: 'stringArray',
29
+ defaultValue: [],
30
+ },
31
+ }, { explicitIdentifier: 'internetAccountId', explicitlyTyped: true });