@internxt/sdk 1.5.25 → 1.6.4
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/dist/auth/index.d.ts +127 -122
- package/dist/auth/index.js +378 -310
- package/dist/auth/types.d.ts +65 -54
- package/dist/auth/types.js +26 -26
- package/dist/drive/backups/index.d.ts +18 -18
- package/dist/drive/backups/index.js +40 -40
- package/dist/drive/backups/types.d.ts +27 -27
- package/dist/drive/backups/types.js +2 -2
- package/dist/drive/index.d.ts +7 -7
- package/dist/drive/index.js +23 -19
- package/dist/drive/payments/index.d.ts +66 -71
- package/dist/drive/payments/index.js +206 -208
- package/dist/drive/payments/types.d.ts +180 -176
- package/dist/drive/payments/types.js +37 -37
- package/dist/drive/referrals/index.d.ts +19 -19
- package/dist/drive/referrals/index.js +54 -50
- package/dist/drive/referrals/types.d.ts +21 -21
- package/dist/drive/referrals/types.js +18 -18
- package/dist/drive/share/index.d.ts +319 -319
- package/dist/drive/share/index.js +544 -540
- package/dist/drive/share/types.d.ts +360 -360
- package/dist/drive/share/types.js +2 -2
- package/dist/drive/storage/index.d.ts +315 -315
- package/dist/drive/storage/index.js +634 -630
- package/dist/drive/storage/types.d.ts +480 -473
- package/dist/drive/storage/types.js +13 -13
- package/dist/drive/trash/index.d.ts +75 -75
- package/dist/drive/trash/index.js +184 -180
- package/dist/drive/trash/types.d.ts +29 -29
- package/dist/drive/trash/types.js +2 -2
- package/dist/drive/users/index.d.ts +135 -135
- package/dist/drive/users/index.js +208 -204
- package/dist/drive/users/types.d.ts +53 -51
- package/dist/drive/users/types.js +2 -2
- package/dist/index.d.ts +6 -6
- package/dist/index.js +35 -31
- package/dist/network/download.d.ts +8 -8
- package/dist/network/download.js +123 -123
- package/dist/network/errors/codes.d.ts +24 -24
- package/dist/network/errors/codes.js +48 -48
- package/dist/network/errors/context.d.ts +35 -35
- package/dist/network/errors/context.js +39 -39
- package/dist/network/errors/download.d.ts +4 -4
- package/dist/network/errors/download.js +52 -48
- package/dist/network/errors/index.d.ts +3 -3
- package/dist/network/errors/index.js +19 -15
- package/dist/network/errors/upload.d.ts +13 -13
- package/dist/network/errors/upload.js +82 -78
- package/dist/network/index.d.ts +70 -70
- package/dist/network/index.js +315 -311
- package/dist/network/types.d.ts +102 -102
- package/dist/network/types.js +18 -18
- package/dist/network/upload.d.ts +4 -4
- package/dist/network/upload.js +158 -159
- package/dist/photos/devices/index.d.ts +10 -10
- package/dist/photos/devices/index.js +79 -79
- package/dist/photos/index.d.ts +17 -17
- package/dist/photos/index.js +56 -52
- package/dist/photos/photos/index.d.ts +60 -60
- package/dist/photos/photos/index.js +225 -225
- package/dist/photos/shares/index.d.ts +8 -8
- package/dist/photos/shares/index.js +34 -34
- package/dist/photos/types.d.ts +154 -154
- package/dist/photos/types.js +19 -19
- package/dist/photos/users/index.d.ts +7 -7
- package/dist/photos/users/index.js +46 -46
- package/dist/shared/headers/index.d.ts +21 -21
- package/dist/shared/headers/index.js +78 -79
- package/dist/shared/http/client.d.ts +85 -85
- package/dist/shared/http/client.js +172 -172
- package/dist/shared/http/types.d.ts +7 -7
- package/dist/shared/http/types.js +2 -2
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.js +17 -13
- package/dist/shared/types/apiConnection.d.ts +12 -12
- package/dist/shared/types/apiConnection.js +2 -2
- package/dist/shared/types/appsumo.d.ts +16 -16
- package/dist/shared/types/appsumo.js +12 -12
- package/dist/shared/types/errors.d.ts +5 -5
- package/dist/shared/types/errors.js +28 -28
- package/dist/shared/types/teams.d.ts +9 -9
- package/dist/shared/types/teams.js +2 -2
- package/dist/shared/types/userSettings.d.ts +43 -29
- package/dist/shared/types/userSettings.js +2 -2
- package/dist/utils.d.ts +3 -3
- package/dist/utils.js +24 -25
- package/dist/workspaces/index.d.ts +176 -176
- package/dist/workspaces/index.js +419 -415
- package/dist/workspaces/index.test.d.ts +1 -1
- package/dist/workspaces/index.test.js +908 -903
- package/dist/workspaces/types.d.ts +294 -291
- package/dist/workspaces/types.js +2 -2
- package/package.json +13 -13
package/dist/network/download.js
CHANGED
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g =
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
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;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.
|
|
55
|
-
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
err_1
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
123
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
28
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
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;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.FileVersionOneError = void 0;
|
|
55
|
+
exports.downloadFile = downloadFile;
|
|
56
|
+
var errors_1 = require("./errors");
|
|
57
|
+
var types_1 = require("./types");
|
|
58
|
+
var FileVersionOneError = /** @class */ (function (_super) {
|
|
59
|
+
__extends(FileVersionOneError, _super);
|
|
60
|
+
function FileVersionOneError() {
|
|
61
|
+
var _this = _super.call(this, 'File version 1') || this;
|
|
62
|
+
Object.setPrototypeOf(_this, FileVersionOneError.prototype);
|
|
63
|
+
return _this;
|
|
64
|
+
}
|
|
65
|
+
return FileVersionOneError;
|
|
66
|
+
}(Error));
|
|
67
|
+
exports.FileVersionOneError = FileVersionOneError;
|
|
68
|
+
function downloadFile(fileId, bucketId, mnemonic, network, crypto, toBinaryData, downloadFile, decryptFile, opts) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var iv, indexHex, key, mnemonicIsValid, _a, index, shards, version, size, downloadables, err_1, context;
|
|
71
|
+
return __generator(this, function (_b) {
|
|
72
|
+
switch (_b.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
_b.trys.push([0, 5, , 6]);
|
|
75
|
+
if (!(opts === null || opts === void 0 ? void 0 : opts.token)) {
|
|
76
|
+
mnemonicIsValid = crypto.validateMnemonic(mnemonic);
|
|
77
|
+
if (!mnemonicIsValid) {
|
|
78
|
+
throw new errors_1.DownloadInvalidMnemonicError();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return [4 /*yield*/, network.getDownloadLinks(bucketId, fileId, opts === null || opts === void 0 ? void 0 : opts.token)];
|
|
82
|
+
case 1:
|
|
83
|
+
_a = _b.sent(), index = _a.index, shards = _a.shards, version = _a.version, size = _a.size;
|
|
84
|
+
if (!version || version === 1) {
|
|
85
|
+
throw new FileVersionOneError();
|
|
86
|
+
}
|
|
87
|
+
iv = toBinaryData(index, types_1.BinaryDataEncoding.HEX).slice(0, 16);
|
|
88
|
+
return [4 /*yield*/, crypto.generateFileKey(mnemonic, bucketId, toBinaryData(index, types_1.BinaryDataEncoding.HEX))];
|
|
89
|
+
case 2:
|
|
90
|
+
key = _b.sent();
|
|
91
|
+
downloadables = shards.sort(function (sA, sB) { return sA.index - sB.index; });
|
|
92
|
+
return [4 /*yield*/, downloadFile(downloadables, size)];
|
|
93
|
+
case 3:
|
|
94
|
+
_b.sent();
|
|
95
|
+
return [4 /*yield*/, decryptFile(crypto.algorithm.type, key, iv, size)];
|
|
96
|
+
case 4:
|
|
97
|
+
_b.sent();
|
|
98
|
+
return [3 /*break*/, 6];
|
|
99
|
+
case 5:
|
|
100
|
+
err_1 = _b.sent();
|
|
101
|
+
context = (0, errors_1.getNetworkErrorContext)({
|
|
102
|
+
bucketId: bucketId,
|
|
103
|
+
fileId: fileId,
|
|
104
|
+
user: network.credentials.username,
|
|
105
|
+
pass: network.credentials.password,
|
|
106
|
+
token: (opts === null || opts === void 0 ? void 0 : opts.token) || 'none',
|
|
107
|
+
crypto: {
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
109
|
+
index: indexHex ? indexHex.toString('hex') : 'none',
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
111
|
+
iv: iv ? iv.toString('hex') : 'none',
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
113
|
+
key: key ? key.toString('hex') : 'none',
|
|
114
|
+
mnemonic: mnemonic
|
|
115
|
+
}
|
|
116
|
+
}, err_1);
|
|
117
|
+
err_1.context = context;
|
|
118
|
+
throw err_1;
|
|
119
|
+
case 6: return [2 /*return*/];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NETWORK ERROR CODES FORMAT: 1****
|
|
3
|
-
* -UPLOAD ERRORS: 1***
|
|
4
|
-
* -DOWNLOAD ERRORS: 2***
|
|
5
|
-
* -CRYPTOGRAPHIC ERRORS: 1**
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
declare enum UploadErrorCode {
|
|
9
|
-
InvalidMnemonic = 11100
|
|
10
|
-
}
|
|
11
|
-
declare enum DownloadErrorCode {
|
|
12
|
-
InvalidMnemonic = 12100
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export declare class CodeError extends Error {
|
|
16
|
-
code: NetworkErrorCode;
|
|
17
|
-
message: string;
|
|
18
|
-
constructor(code: NetworkErrorCode, message: string);
|
|
19
|
-
}
|
|
20
|
-
declare const _default: {
|
|
21
|
-
Upload: typeof UploadErrorCode;
|
|
22
|
-
Download: typeof DownloadErrorCode;
|
|
23
|
-
};
|
|
24
|
-
export default _default;
|
|
1
|
+
/**
|
|
2
|
+
* NETWORK ERROR CODES FORMAT: 1****
|
|
3
|
+
* -UPLOAD ERRORS: 1***
|
|
4
|
+
* -DOWNLOAD ERRORS: 2***
|
|
5
|
+
* -CRYPTOGRAPHIC ERRORS: 1**
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
declare enum UploadErrorCode {
|
|
9
|
+
InvalidMnemonic = 11100
|
|
10
|
+
}
|
|
11
|
+
declare enum DownloadErrorCode {
|
|
12
|
+
InvalidMnemonic = 12100
|
|
13
|
+
}
|
|
14
|
+
type NetworkErrorCode = UploadErrorCode | DownloadErrorCode;
|
|
15
|
+
export declare class CodeError extends Error {
|
|
16
|
+
code: NetworkErrorCode;
|
|
17
|
+
message: string;
|
|
18
|
+
constructor(code: NetworkErrorCode, message: string);
|
|
19
|
+
}
|
|
20
|
+
declare const _default: {
|
|
21
|
+
Upload: typeof UploadErrorCode;
|
|
22
|
+
Download: typeof DownloadErrorCode;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.CodeError = void 0;
|
|
19
|
-
/**
|
|
20
|
-
* NETWORK ERROR CODES FORMAT: 1****
|
|
21
|
-
* -UPLOAD ERRORS: 1***
|
|
22
|
-
* -DOWNLOAD ERRORS: 2***
|
|
23
|
-
* -CRYPTOGRAPHIC ERRORS: 1**
|
|
24
|
-
*
|
|
25
|
-
*/
|
|
26
|
-
var UploadErrorCode;
|
|
27
|
-
(function (UploadErrorCode) {
|
|
28
|
-
UploadErrorCode[UploadErrorCode["InvalidMnemonic"] = 11100] = "InvalidMnemonic";
|
|
29
|
-
})(UploadErrorCode || (UploadErrorCode = {}));
|
|
30
|
-
var DownloadErrorCode;
|
|
31
|
-
(function (DownloadErrorCode) {
|
|
32
|
-
DownloadErrorCode[DownloadErrorCode["InvalidMnemonic"] = 12100] = "InvalidMnemonic";
|
|
33
|
-
})(DownloadErrorCode || (DownloadErrorCode = {}));
|
|
34
|
-
var CodeError = /** @class */ (function (_super) {
|
|
35
|
-
__extends(CodeError, _super);
|
|
36
|
-
function CodeError(code, message) {
|
|
37
|
-
var _this = _super.call(this, message) || this;
|
|
38
|
-
_this.code = code;
|
|
39
|
-
_this.message = message;
|
|
40
|
-
return _this;
|
|
41
|
-
}
|
|
42
|
-
return CodeError;
|
|
43
|
-
}(Error));
|
|
44
|
-
exports.CodeError = CodeError;
|
|
45
|
-
exports.default = {
|
|
46
|
-
Upload: UploadErrorCode,
|
|
47
|
-
Download: DownloadErrorCode
|
|
48
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.CodeError = void 0;
|
|
19
|
+
/**
|
|
20
|
+
* NETWORK ERROR CODES FORMAT: 1****
|
|
21
|
+
* -UPLOAD ERRORS: 1***
|
|
22
|
+
* -DOWNLOAD ERRORS: 2***
|
|
23
|
+
* -CRYPTOGRAPHIC ERRORS: 1**
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
var UploadErrorCode;
|
|
27
|
+
(function (UploadErrorCode) {
|
|
28
|
+
UploadErrorCode[UploadErrorCode["InvalidMnemonic"] = 11100] = "InvalidMnemonic";
|
|
29
|
+
})(UploadErrorCode || (UploadErrorCode = {}));
|
|
30
|
+
var DownloadErrorCode;
|
|
31
|
+
(function (DownloadErrorCode) {
|
|
32
|
+
DownloadErrorCode[DownloadErrorCode["InvalidMnemonic"] = 12100] = "InvalidMnemonic";
|
|
33
|
+
})(DownloadErrorCode || (DownloadErrorCode = {}));
|
|
34
|
+
var CodeError = /** @class */ (function (_super) {
|
|
35
|
+
__extends(CodeError, _super);
|
|
36
|
+
function CodeError(code, message) {
|
|
37
|
+
var _this = _super.call(this, message) || this;
|
|
38
|
+
_this.code = code;
|
|
39
|
+
_this.message = message;
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
return CodeError;
|
|
43
|
+
}(Error));
|
|
44
|
+
exports.CodeError = CodeError;
|
|
45
|
+
exports.default = {
|
|
46
|
+
Upload: UploadErrorCode,
|
|
47
|
+
Download: DownloadErrorCode
|
|
48
|
+
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { DownloadInvalidMnemonicError } from './download';
|
|
2
|
-
import { UploadInvalidMnemonicError } from './upload';
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
bucketId: string;
|
|
6
|
-
fileSize: number;
|
|
7
|
-
user: string;
|
|
8
|
-
pass: string;
|
|
9
|
-
crypto: {
|
|
10
|
-
index: string;
|
|
11
|
-
mnemonic?: string;
|
|
12
|
-
key: string;
|
|
13
|
-
iv: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
export
|
|
17
|
-
bucketId: string;
|
|
18
|
-
fileId: string;
|
|
19
|
-
user: string;
|
|
20
|
-
pass: string;
|
|
21
|
-
token: string;
|
|
22
|
-
crypto: {
|
|
23
|
-
index: string;
|
|
24
|
-
mnemonic?: string;
|
|
25
|
-
key: string;
|
|
26
|
-
iv: string;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export
|
|
30
|
-
export declare class ErrorWithContext extends Error {
|
|
31
|
-
context: Partial<NetworkContext>;
|
|
32
|
-
constructor(context: Partial<NetworkContext>);
|
|
33
|
-
}
|
|
34
|
-
export declare function getNetworkErrorContext(input: NetworkContext, err: NetworkError): Partial<NetworkContext>;
|
|
35
|
-
export {};
|
|
1
|
+
import { DownloadInvalidMnemonicError } from './download';
|
|
2
|
+
import { UploadInvalidMnemonicError } from './upload';
|
|
3
|
+
type NetworkError = UploadInvalidMnemonicError | DownloadInvalidMnemonicError | Error;
|
|
4
|
+
export type NetworkUploadContext = {
|
|
5
|
+
bucketId: string;
|
|
6
|
+
fileSize: number;
|
|
7
|
+
user: string;
|
|
8
|
+
pass: string;
|
|
9
|
+
crypto: {
|
|
10
|
+
index: string;
|
|
11
|
+
mnemonic?: string;
|
|
12
|
+
key: string;
|
|
13
|
+
iv: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export type NetworkDownloadContext = {
|
|
17
|
+
bucketId: string;
|
|
18
|
+
fileId: string;
|
|
19
|
+
user: string;
|
|
20
|
+
pass: string;
|
|
21
|
+
token: string;
|
|
22
|
+
crypto: {
|
|
23
|
+
index: string;
|
|
24
|
+
mnemonic?: string;
|
|
25
|
+
key: string;
|
|
26
|
+
iv: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type NetworkContext = NetworkUploadContext | NetworkDownloadContext;
|
|
30
|
+
export declare class ErrorWithContext extends Error {
|
|
31
|
+
context: Partial<NetworkContext>;
|
|
32
|
+
constructor(context: Partial<NetworkContext>);
|
|
33
|
+
}
|
|
34
|
+
export declare function getNetworkErrorContext(input: NetworkContext, err: NetworkError): Partial<NetworkContext>;
|
|
35
|
+
export {};
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.
|
|
19
|
-
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_this
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ErrorWithContext = void 0;
|
|
19
|
+
exports.getNetworkErrorContext = getNetworkErrorContext;
|
|
20
|
+
var download_1 = require("./download");
|
|
21
|
+
var upload_1 = require("./upload");
|
|
22
|
+
var ErrorWithContext = /** @class */ (function (_super) {
|
|
23
|
+
__extends(ErrorWithContext, _super);
|
|
24
|
+
function ErrorWithContext(context) {
|
|
25
|
+
var _this = _super.call(this) || this;
|
|
26
|
+
_this.context = context;
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
return ErrorWithContext;
|
|
30
|
+
}(Error));
|
|
31
|
+
exports.ErrorWithContext = ErrorWithContext;
|
|
32
|
+
function getNetworkErrorContext(input, err) {
|
|
33
|
+
var output = Object.assign({}, input);
|
|
34
|
+
delete output.crypto.mnemonic;
|
|
35
|
+
if (err instanceof upload_1.UploadInvalidMnemonicError || err instanceof download_1.DownloadInvalidMnemonicError) {
|
|
36
|
+
output.crypto.mnemonic = input.crypto.mnemonic;
|
|
37
|
+
}
|
|
38
|
+
return output;
|
|
39
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeError } from './codes';
|
|
2
|
-
export declare class DownloadInvalidMnemonicError extends CodeError {
|
|
3
|
-
constructor();
|
|
4
|
-
}
|
|
1
|
+
import { CodeError } from './codes';
|
|
2
|
+
export declare class DownloadInvalidMnemonicError extends CodeError {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|