@raytio/decrypt-helper 5.1.1 → 5.1.2
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/CHANGELOG.md +5 -0
- package/dist/api/authedFetch.d.ts +1 -1
- package/dist/api/authedFetch.js +12 -2
- package/dist/api/getFiles.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## 5.1.2 (2022-11-10)
|
|
11
|
+
|
|
12
|
+
- !195 retry API requests that fail with a 504 error
|
|
13
|
+
- !195 fix crash from corrupted binary files
|
|
14
|
+
|
|
10
15
|
## 5.1.1 (2022-08-15)
|
|
11
16
|
|
|
12
17
|
- !189 load verifier details faster
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function authedFetch<T>(apiToken: string, url: string, options?: RequestInit): Promise<T>;
|
|
1
|
+
export declare function authedFetch<T>(apiToken: string, url: string, options?: RequestInit, retrying?: boolean): Promise<T>;
|
package/dist/api/authedFetch.js
CHANGED
|
@@ -10,12 +10,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.authedFetch = void 0;
|
|
13
|
-
function authedFetch(apiToken, url, options) {
|
|
13
|
+
function authedFetch(apiToken, url, options, retrying = false) {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
-
|
|
15
|
+
console.log(`[API] ${retrying ? "Retry" : "Start"} ${url}`);
|
|
16
|
+
const startTime = +new Date();
|
|
17
|
+
const req = yield fetch(url, Object.assign(Object.assign({}, options), { headers: { Authorization: `Bearer ${apiToken}` } }));
|
|
18
|
+
const apiResp = yield req.json();
|
|
16
19
|
if (apiResp.message) {
|
|
20
|
+
if (!retrying && req.status === 504) {
|
|
21
|
+
console.log(`[API] Error ${req.status} (will retry) ${url}`);
|
|
22
|
+
return authedFetch(apiToken, url, options, true);
|
|
23
|
+
}
|
|
24
|
+
console.log(`[API] Error ${req.status} (no retry) ${url}`);
|
|
17
25
|
throw new Error(`Failed due to API Error from ${url}: "${apiResp.message}"`);
|
|
18
26
|
}
|
|
27
|
+
const totalTime = ((+new Date() - startTime) / 1000).toFixed(1);
|
|
28
|
+
console.log(`[API] Finish${retrying ? " after retry" : ""} (${totalTime}s) ${url}`);
|
|
19
29
|
return apiResp;
|
|
20
30
|
});
|
|
21
31
|
}
|
package/dist/api/getFiles.js
CHANGED
|
@@ -19,7 +19,7 @@ const mime_types_1 = require("mime-types");
|
|
|
19
19
|
const file_1 = require("../helpers/file");
|
|
20
20
|
const authedFetch_1 = require("./authedFetch");
|
|
21
21
|
const TEMP_OBJ_PREFIX = "urn:temp_object:";
|
|
22
|
-
const getFileExtn = (b64) => (0, mime_types_1.extension)(b64.split(":")[1].split(";base64,")[0]) || "txt";
|
|
22
|
+
const getFileExtn = (b64) => { var _a; return (0, mime_types_1.extension)(((_a = b64.split(":")[1]) === null || _a === void 0 ? void 0 : _a.split(";base64,")[0]) || "text/plain") || "txt"; };
|
|
23
23
|
const decryptFile = (encryptedData, encryptedObj, applicationDecryptor, wdek) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
const clonedEncryptedObj = JSON.parse(JSON.stringify(encryptedObj));
|
|
25
25
|
clonedEncryptedObj.encrypted_data.data = encryptedData;
|