@super-protocol/sdk-js 0.15.0 → 0.15.2-beta.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 (83) hide show
  1. package/build/TIIGenerator.js +129 -239
  2. package/build/connectors/BaseConnector.js +17 -47
  3. package/build/connectors/BlockchainConnector.js +222 -348
  4. package/build/connectors/BlockchainEventsListener.js +38 -92
  5. package/build/contracts/app.json +466 -35
  6. package/build/crypto/Crypto.js +63 -135
  7. package/build/crypto/index.js +1 -1
  8. package/build/crypto/nodejs/AES.js +62 -119
  9. package/build/crypto/nodejs/ARIA.js +61 -118
  10. package/build/crypto/nodejs/ECIES.js +51 -87
  11. package/build/crypto/nodejs/NativeCrypto.js +64 -118
  12. package/build/crypto/nodejs/RSA-Hybrid.js +54 -113
  13. package/build/index.d.ts +5 -0
  14. package/build/index.js +14 -2
  15. package/build/logger.d.ts +3 -1
  16. package/build/logger.js +2 -2
  17. package/build/models/EtlModel.js +65 -114
  18. package/build/models/Offer.js +227 -462
  19. package/build/models/Order.d.ts +4 -0
  20. package/build/models/Order.js +326 -559
  21. package/build/models/Provider.d.ts +2 -0
  22. package/build/models/Provider.js +74 -153
  23. package/build/models/TCB.js +67 -171
  24. package/build/models/TeeOffer.d.ts +1 -0
  25. package/build/models/TeeOffer.js +389 -731
  26. package/build/proto/Compression.js +20 -21
  27. package/build/proto/TRI.js +46 -50
  28. package/build/proto/TeeProperties.js +60 -66
  29. package/build/providers/storage/ChunksDownloadDecorator.d.ts +1 -1
  30. package/build/providers/storage/ChunksDownloadDecorator.js +125 -235
  31. package/build/providers/storage/IStorageProvider.d.ts +1 -1
  32. package/build/providers/storage/S3StorageProvider.js +173 -298
  33. package/build/providers/storage/StorageAdapter.d.ts +60 -0
  34. package/build/providers/storage/StorageAdapter.js +322 -0
  35. package/build/providers/storage/StorageContentWriter.d.ts +46 -0
  36. package/build/providers/storage/StorageContentWriter.js +182 -0
  37. package/build/providers/storage/StorageKeyValueAdapter.d.ts +23 -0
  38. package/build/providers/storage/StorageKeyValueAdapter.js +157 -0
  39. package/build/providers/storage/StorageMetadataReader.d.ts +20 -0
  40. package/build/providers/storage/StorageMetadataReader.js +67 -0
  41. package/build/providers/storage/StorjAdapter.d.ts +19 -0
  42. package/build/providers/storage/StorjAdapter.js +73 -0
  43. package/build/providers/storage/StorjStorageProvider.js +138 -315
  44. package/build/providers/storage/getStorageProvider.js +7 -7
  45. package/build/providers/storage/types.d.ts +7 -0
  46. package/build/providers/storage/types.js +2 -0
  47. package/build/staticModels/ActiveOffers.js +32 -100
  48. package/build/staticModels/ActiveOrders.js +42 -120
  49. package/build/staticModels/BaseStaticModel.js +7 -10
  50. package/build/staticModels/Consensus.d.ts +4 -1
  51. package/build/staticModels/Consensus.js +164 -220
  52. package/build/staticModels/Deposits.js +109 -201
  53. package/build/staticModels/Marks.js +21 -82
  54. package/build/staticModels/ModelPackager.js +34 -84
  55. package/build/staticModels/Offers.js +140 -266
  56. package/build/staticModels/Orders.d.ts +1 -0
  57. package/build/staticModels/Orders.js +286 -429
  58. package/build/staticModels/ProviderRegistry.js +114 -225
  59. package/build/staticModels/Superpro.js +17 -63
  60. package/build/staticModels/SuperproToken.js +90 -169
  61. package/build/staticModels/TeeOffers.js +220 -416
  62. package/build/store.js +2 -2
  63. package/build/types/HardwareInfo.js +2 -2
  64. package/build/types/Order.js +4 -4
  65. package/build/types/Provider.js +1 -1
  66. package/build/types/TeeOfferInfo.js +1 -1
  67. package/build/types/TeeOfferOption.js +2 -2
  68. package/build/types/TeeOfferSlot.js +2 -2
  69. package/build/types/ValueOfferSlot.js +3 -3
  70. package/build/utils/Monitoring.js +24 -28
  71. package/build/utils/NonceTracker.js +56 -121
  72. package/build/utils/PubSub.d.ts +9 -0
  73. package/build/utils/PubSub.js +36 -0
  74. package/build/utils/TxManager.js +121 -215
  75. package/build/utils/compressors/GzipCompressor.js +13 -50
  76. package/build/utils/compressors/UncompressedCompressor.js +10 -13
  77. package/build/utils/helpers/tryWithInterval.js +34 -78
  78. package/build/utils/resourceLoaders/BaseResourceLoader.js +26 -78
  79. package/build/utils/resourceLoaders/StorageProviderLoader.js +33 -97
  80. package/build/utils/resourceLoaders/UrlResourceLoader.js +29 -93
  81. package/build/utils/resourceLoaders/getResourceLoader.js +6 -6
  82. package/build/utils.js +60 -105
  83. package/package.json +4 -1
@@ -8,33 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
11
  var __asyncValues = (this && this.__asyncValues) || function (o) {
39
12
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
40
13
  var m = o[Symbol.asyncIterator], i;
@@ -58,12 +31,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
58
31
  return (mod && mod.__esModule) ? mod : { "default": mod };
59
32
  };
60
33
  Object.defineProperty(exports, "__esModule", { value: true });
61
- var buffer_1 = require("buffer");
62
- var utils_1 = require("../../utils");
63
- var stream_1 = __importDefault(require("stream"));
64
- var logger_1 = __importDefault(require("../../logger"));
65
- var StorJStorageProvider = /** @class */ (function () {
66
- function StorJStorageProvider(credentials, maximumConcurrent) {
34
+ const buffer_1 = require("buffer");
35
+ const utils_1 = require("../../utils");
36
+ const stream_1 = __importDefault(require("stream"));
37
+ const logger_1 = __importDefault(require("../../logger"));
38
+ class StorJStorageProvider {
39
+ constructor(credentials, maximumConcurrent) {
67
40
  this.logger = logger_1.default.child({ className: "StorJStorageProvider" });
68
41
  if (!(0, utils_1.isNodeJS)()) {
69
42
  throw Error("StorageProvider: StorJ is supported only in the node.js execution environment");
@@ -81,303 +54,153 @@ var StorJStorageProvider = /** @class */ (function () {
81
54
  this.accessToken = credentials.token;
82
55
  this.maximumConcurrent = maximumConcurrent;
83
56
  }
84
- StorJStorageProvider.prototype.uploadFile = function (inputStream, remotePath, contentLength, progressListener) {
57
+ uploadFile(inputStream, remotePath, contentLength, progressListener) {
85
58
  var _a, inputStream_1, inputStream_1_1;
86
59
  var _b, e_1, _c, _d;
87
- return __awaiter(this, void 0, void 0, function () {
88
- var storj, options, project, uploader, totalWritten, buffer, e_1_1, uploadingError_1, abortingError_1;
89
- return __generator(this, function (_e) {
90
- switch (_e.label) {
91
- case 0: return [4 /*yield*/, this.lazyStorj()];
92
- case 1:
93
- storj = _e.sent();
94
- options = new storj.UploadOptions();
95
- return [4 /*yield*/, this.lazyProject()];
96
- case 2:
97
- project = _e.sent();
98
- return [4 /*yield*/, project.uploadObject(this.bucket, this.prefix + remotePath, options)];
99
- case 3:
100
- uploader = _e.sent();
101
- totalWritten = 0;
102
- _e.label = 4;
103
- case 4:
104
- _e.trys.push([4, 21, , 26]);
105
- _e.label = 5;
106
- case 5:
107
- _e.trys.push([5, 13, 14, 19]);
108
- _a = true, inputStream_1 = __asyncValues(inputStream);
109
- _e.label = 6;
110
- case 6: return [4 /*yield*/, inputStream_1.next()];
111
- case 7:
112
- if (!(inputStream_1_1 = _e.sent(), _b = inputStream_1_1.done, !_b)) return [3 /*break*/, 12];
60
+ return __awaiter(this, void 0, void 0, function* () {
61
+ const storj = yield this.lazyStorj();
62
+ const options = new storj.UploadOptions();
63
+ const project = yield this.lazyProject();
64
+ const uploader = yield project.uploadObject(this.bucket, this.prefix + remotePath, options);
65
+ let totalWritten = 0;
66
+ try {
67
+ try {
68
+ for (_a = true, inputStream_1 = __asyncValues(inputStream); inputStream_1_1 = yield inputStream_1.next(), _b = inputStream_1_1.done, !_b;) {
113
69
  _d = inputStream_1_1.value;
114
70
  _a = false;
115
- _e.label = 8;
116
- case 8:
117
- _e.trys.push([8, , 10, 11]);
118
- buffer = _d;
119
- return [4 /*yield*/, uploader.write(buffer, buffer.length)];
120
- case 9:
121
- _e.sent();
122
- totalWritten += buffer.length;
123
- if (!!progressListener) {
124
- progressListener(contentLength, totalWritten);
71
+ try {
72
+ const buffer = _d;
73
+ yield uploader.write(buffer, buffer.length);
74
+ totalWritten += buffer.length;
75
+ if (!!progressListener) {
76
+ progressListener(contentLength, totalWritten);
77
+ }
78
+ }
79
+ finally {
80
+ _a = true;
125
81
  }
126
- return [3 /*break*/, 11];
127
- case 10:
128
- _a = true;
129
- return [7 /*endfinally*/];
130
- case 11: return [3 /*break*/, 6];
131
- case 12: return [3 /*break*/, 19];
132
- case 13:
133
- e_1_1 = _e.sent();
134
- e_1 = { error: e_1_1 };
135
- return [3 /*break*/, 19];
136
- case 14:
137
- _e.trys.push([14, , 17, 18]);
138
- if (!(!_a && !_b && (_c = inputStream_1.return))) return [3 /*break*/, 16];
139
- return [4 /*yield*/, _c.call(inputStream_1)];
140
- case 15:
141
- _e.sent();
142
- _e.label = 16;
143
- case 16: return [3 /*break*/, 18];
144
- case 17:
145
- if (e_1) throw e_1.error;
146
- return [7 /*endfinally*/];
147
- case 18: return [7 /*endfinally*/];
148
- case 19: return [4 /*yield*/, uploader.commit()];
149
- case 20:
150
- _e.sent();
151
- return [3 /*break*/, 26];
152
- case 21:
153
- uploadingError_1 = _e.sent();
154
- _e.label = 22;
155
- case 22:
156
- _e.trys.push([22, 24, , 25]);
157
- return [4 /*yield*/, uploader.abort()];
158
- case 23:
159
- _e.sent();
160
- return [3 /*break*/, 25];
161
- case 24:
162
- abortingError_1 = _e.sent();
163
- logger_1.default.error({ err: abortingError_1 }, "Failed to abort file uploading");
164
- return [3 /*break*/, 25];
165
- case 25: throw uploadingError_1;
166
- case 26: return [2 /*return*/];
82
+ }
167
83
  }
168
- });
169
- });
170
- };
171
- StorJStorageProvider.prototype.downloadFile = function (remotePath, config, progressListener) {
172
- return __awaiter(this, void 0, void 0, function () {
173
- var storj, project, length, _a, options, downloader, loader;
174
- var _this = this;
175
- return __generator(this, function (_b) {
176
- switch (_b.label) {
177
- case 0: return [4 /*yield*/, this.lazyStorj()];
178
- case 1:
179
- storj = _b.sent();
180
- return [4 /*yield*/, this.lazyProject()];
181
- case 2:
182
- project = _b.sent();
183
- _a = config.length;
184
- if (_a) return [3 /*break*/, 4];
185
- return [4 /*yield*/, this.getObjectSize(remotePath)];
186
- case 3:
187
- _a = (_b.sent());
188
- _b.label = 4;
189
- case 4:
190
- length = _a;
191
- options = new storj.DownloadOptions(config.offset || 0, length);
192
- return [4 /*yield*/, project.downloadObject(this.bucket, this.prefix + remotePath, options)];
193
- case 5:
194
- downloader = _b.sent();
195
- loader = function () {
196
- return __asyncGenerator(this, arguments, function () {
197
- var readBuffer, current, downloadResult, bytesRead;
198
- return __generator(this, function (_a) {
199
- switch (_a.label) {
200
- case 0:
201
- readBuffer = buffer_1.Buffer.alloc(StorJStorageProvider.DOWNLOAD_BUFFER_SIZE);
202
- current = 0;
203
- _a.label = 1;
204
- case 1:
205
- if (!(current < length)) return [3 /*break*/, 5];
206
- return [4 /*yield*/, __await(downloader.read(readBuffer, readBuffer.length))];
207
- case 2:
208
- downloadResult = _a.sent();
209
- bytesRead = downloadResult.bytes_read;
210
- current += bytesRead;
211
- return [4 /*yield*/, __await(buffer_1.Buffer.from(readBuffer.subarray(0, bytesRead)))];
212
- case 3: return [4 /*yield*/, _a.sent()];
213
- case 4:
214
- _a.sent();
215
- if (!!progressListener) {
216
- progressListener(length, current);
217
- }
218
- return [3 /*break*/, 1];
219
- case 5: return [2 /*return*/];
220
- }
221
- });
222
- });
223
- };
224
- return [2 /*return*/, stream_1.default.Readable.from(loader()).on("close", function () { return __awaiter(_this, void 0, void 0, function () {
225
- return __generator(this, function (_a) {
226
- switch (_a.label) {
227
- case 0: return [4 /*yield*/, downloader.close()];
228
- case 1:
229
- _a.sent();
230
- return [2 /*return*/];
231
- }
232
- });
233
- }); })];
84
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
85
+ finally {
86
+ try {
87
+ if (!_a && !_b && (_c = inputStream_1.return)) yield _c.call(inputStream_1);
88
+ }
89
+ finally { if (e_1) throw e_1.error; }
234
90
  }
235
- });
236
- });
237
- };
238
- StorJStorageProvider.prototype.deleteObject = function (remotePath) {
239
- return __awaiter(this, void 0, void 0, function () {
240
- var project;
241
- return __generator(this, function (_a) {
242
- switch (_a.label) {
243
- case 0: return [4 /*yield*/, this.lazyProject()];
244
- case 1:
245
- project = _a.sent();
246
- return [4 /*yield*/, project.deleteObject(this.bucket, this.prefix + remotePath)];
247
- case 2:
248
- _a.sent();
249
- return [2 /*return*/];
91
+ yield uploader.commit();
92
+ }
93
+ catch (uploadingError) {
94
+ try {
95
+ yield uploader.abort();
250
96
  }
251
- });
97
+ catch (abortingError) {
98
+ logger_1.default.error({ err: abortingError }, "Failed to abort file uploading");
99
+ }
100
+ throw uploadingError;
101
+ }
252
102
  });
253
- };
254
- StorJStorageProvider.prototype.listObjects = function (remotePath) {
255
- return __awaiter(this, void 0, void 0, function () {
256
- var storj, project, objects, result, key, value;
257
- return __generator(this, function (_a) {
258
- switch (_a.label) {
259
- case 0: return [4 /*yield*/, this.lazyStorj()];
260
- case 1:
261
- storj = _a.sent();
262
- return [4 /*yield*/, this.lazyProject()];
263
- case 2:
264
- project = _a.sent();
265
- return [4 /*yield*/, project.listObjects(this.bucket, {
266
- recursive: true,
267
- cursor: "",
268
- prefix: this.prefix + remotePath,
269
- system: true,
270
- custom: true,
271
- })];
272
- case 3:
273
- objects = _a.sent();
274
- result = [];
275
- for (key in Object.keys(objects)) {
276
- value = objects[key];
277
- result.push({
278
- name: value.key,
279
- size: value.system.content_length,
280
- isFolder: value.is_prefix == 1,
281
- childrenCount: value.custom.count,
282
- createdAt: new Date(value.system.created * 1000), // TODO: check timezone
283
- });
103
+ }
104
+ downloadFile(remotePath, config, progressListener) {
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ const storj = yield this.lazyStorj();
107
+ const project = yield this.lazyProject();
108
+ const length = config.length || (yield this.getObjectSize(remotePath));
109
+ const options = new storj.DownloadOptions(config.offset || 0, length);
110
+ const downloader = yield project.downloadObject(this.bucket, this.prefix + remotePath, options);
111
+ const loader = function () {
112
+ return __asyncGenerator(this, arguments, function* () {
113
+ const readBuffer = buffer_1.Buffer.alloc(StorJStorageProvider.DOWNLOAD_BUFFER_SIZE);
114
+ let current = 0;
115
+ while (current < length) {
116
+ // We have to cast result to any, because of the wrong type declartion in uplink-nodejs.
117
+ const downloadResult = yield __await(downloader.read(readBuffer, readBuffer.length));
118
+ const bytesRead = downloadResult.bytes_read;
119
+ current += bytesRead;
120
+ yield yield __await(buffer_1.Buffer.from(readBuffer.subarray(0, bytesRead)));
121
+ if (!!progressListener) {
122
+ progressListener(length, current);
284
123
  }
285
- return [2 /*return*/, result];
286
- }
287
- });
124
+ }
125
+ });
126
+ };
127
+ return stream_1.default.Readable.from(loader()).on("close", () => __awaiter(this, void 0, void 0, function* () {
128
+ yield downloader.close();
129
+ }));
288
130
  });
289
- };
290
- StorJStorageProvider.prototype.getObjectSize = function (remotePath) {
291
- return __awaiter(this, void 0, void 0, function () {
292
- var project, objectInfo;
293
- return __generator(this, function (_a) {
294
- switch (_a.label) {
295
- case 0: return [4 /*yield*/, this.lazyProject()];
296
- case 1:
297
- project = _a.sent();
298
- return [4 /*yield*/, project.statObject(this.bucket, this.prefix + remotePath)];
299
- case 2:
300
- objectInfo = _a.sent();
301
- return [2 /*return*/, objectInfo.system.content_length];
302
- }
303
- });
131
+ }
132
+ deleteObject(remotePath) {
133
+ return __awaiter(this, void 0, void 0, function* () {
134
+ const project = yield this.lazyProject();
135
+ yield project.deleteObject(this.bucket, this.prefix + remotePath);
304
136
  });
305
- };
306
- StorJStorageProvider.prototype.getLastModified = function (remotePath) {
307
- return __awaiter(this, void 0, void 0, function () {
308
- var project, objectInfo;
309
- return __generator(this, function (_a) {
310
- switch (_a.label) {
311
- case 0: return [4 /*yield*/, this.lazyProject()];
312
- case 1:
313
- project = _a.sent();
314
- return [4 /*yield*/, project.statObject(this.bucket, this.prefix + remotePath)];
315
- case 2:
316
- objectInfo = _a.sent();
317
- return [2 /*return*/, new Date(objectInfo.system.created * 1000)];
318
- }
137
+ }
138
+ listObjects(remotePath) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ const storj = yield this.lazyStorj();
141
+ const project = yield this.lazyProject();
142
+ const objects = yield project.listObjects(this.bucket, {
143
+ recursive: true,
144
+ cursor: "",
145
+ prefix: this.prefix + remotePath,
146
+ system: true,
147
+ custom: true,
319
148
  });
149
+ const result = [];
150
+ for (const key in Object.keys(objects)) {
151
+ const value = objects[key];
152
+ result.push({
153
+ name: value.key,
154
+ size: value.system.content_length,
155
+ isFolder: value.is_prefix == 1,
156
+ childrenCount: value.custom.count,
157
+ createdAt: new Date(value.system.created * 1000), // TODO: check timezone
158
+ });
159
+ }
160
+ return result;
320
161
  });
321
- };
322
- StorJStorageProvider.prototype.lazyStorj = function () {
323
- return __awaiter(this, void 0, void 0, function () {
324
- var _a;
325
- return __generator(this, function (_b) {
326
- switch (_b.label) {
327
- case 0:
328
- if (!!this._storj) return [3 /*break*/, 2];
329
- _a = this;
330
- return [4 /*yield*/, require("@super-protocol/uplink-nodejs")];
331
- case 1:
332
- _a._storj = _b.sent();
333
- _b.label = 2;
334
- case 2: return [2 /*return*/, this._storj];
335
- }
336
- });
162
+ }
163
+ getObjectSize(remotePath) {
164
+ return __awaiter(this, void 0, void 0, function* () {
165
+ const project = yield this.lazyProject();
166
+ const objectInfo = yield project.statObject(this.bucket, this.prefix + remotePath);
167
+ return objectInfo.system.content_length;
337
168
  });
338
- };
339
- StorJStorageProvider.prototype.lazyAccess = function () {
340
- return __awaiter(this, void 0, void 0, function () {
341
- var storj, uplink, _a;
342
- return __generator(this, function (_b) {
343
- switch (_b.label) {
344
- case 0:
345
- if (!!this._access) return [3 /*break*/, 3];
346
- return [4 /*yield*/, this.lazyStorj()];
347
- case 1:
348
- storj = _b.sent();
349
- uplink = new storj.Uplink();
350
- _a = this;
351
- return [4 /*yield*/, uplink.parseAccess(this.accessToken)];
352
- case 2:
353
- _a._access = _b.sent();
354
- _b.label = 3;
355
- case 3: return [2 /*return*/, this._access];
356
- }
357
- });
169
+ }
170
+ getLastModified(remotePath) {
171
+ return __awaiter(this, void 0, void 0, function* () {
172
+ const project = yield this.lazyProject();
173
+ const objectInfo = yield project.statObject(this.bucket, this.prefix + remotePath);
174
+ return new Date(objectInfo.system.created * 1000);
358
175
  });
359
- };
360
- StorJStorageProvider.prototype.lazyProject = function () {
361
- return __awaiter(this, void 0, void 0, function () {
362
- var access, _a;
363
- return __generator(this, function (_b) {
364
- switch (_b.label) {
365
- case 0:
366
- if (!!this._project) return [3 /*break*/, 3];
367
- return [4 /*yield*/, this.lazyAccess()];
368
- case 1:
369
- access = _b.sent();
370
- _a = this;
371
- return [4 /*yield*/, access.openProject(this.maximumConcurrent)];
372
- case 2:
373
- _a._project = _b.sent();
374
- _b.label = 3;
375
- case 3: return [2 /*return*/, this._project];
376
- }
377
- });
176
+ }
177
+ lazyStorj() {
178
+ return __awaiter(this, void 0, void 0, function* () {
179
+ if (!this._storj) {
180
+ this._storj = yield require("@super-protocol/uplink-nodejs");
181
+ }
182
+ return this._storj;
183
+ });
184
+ }
185
+ lazyAccess() {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ if (!this._access) {
188
+ const storj = yield this.lazyStorj();
189
+ const uplink = new storj.Uplink();
190
+ this._access = yield uplink.parseAccess(this.accessToken);
191
+ }
192
+ return this._access;
378
193
  });
379
- };
380
- StorJStorageProvider.DOWNLOAD_BUFFER_SIZE = 4194304; // 4mb
381
- return StorJStorageProvider;
382
- }());
194
+ }
195
+ lazyProject() {
196
+ return __awaiter(this, void 0, void 0, function* () {
197
+ if (!this._project) {
198
+ const access = yield this.lazyAccess();
199
+ this._project = yield access.openProject(this.maximumConcurrent);
200
+ }
201
+ return this._project;
202
+ });
203
+ }
204
+ }
383
205
  exports.default = StorJStorageProvider;
206
+ StorJStorageProvider.DOWNLOAD_BUFFER_SIZE = 4194304; // 4mb
@@ -3,17 +3,17 @@ 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
- var dto_js_1 = require("@super-protocol/dto-js");
7
- var StorjStorageProvider_1 = __importDefault(require("./StorjStorageProvider"));
8
- var S3StorageProvider_1 = require("./S3StorageProvider");
9
- exports.default = (function (storageAccess) {
10
- var key = storageAccess.storageType;
6
+ const dto_js_1 = require("@super-protocol/dto-js");
7
+ const StorjStorageProvider_1 = __importDefault(require("./StorjStorageProvider"));
8
+ const S3StorageProvider_1 = require("./S3StorageProvider");
9
+ exports.default = (storageAccess) => {
10
+ const key = storageAccess.storageType;
11
11
  switch (key) {
12
12
  case dto_js_1.StorageType.StorJ:
13
13
  return new StorjStorageProvider_1.default(storageAccess.credentials, storageAccess.maximumConcurrent);
14
14
  case dto_js_1.StorageType.S3:
15
15
  return new S3StorageProvider_1.S3StorageProvider(storageAccess.credentials);
16
16
  default:
17
- throw Error("Unsupported storageType ".concat(key));
17
+ throw Error(`Unsupported storageType ${key}`);
18
18
  }
19
- });
19
+ };
@@ -0,0 +1,7 @@
1
+ export interface CacheRecord<V> {
2
+ value: V | null;
3
+ modifiedTs: number;
4
+ }
5
+ export interface Performance {
6
+ now(): number;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });