@sendsafely/sendsafely 1.1.2 → 1.1.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/{FileUtil.js → lib/FileUtil.js} +13 -3
- package/{SendSafely.js → lib/SendSafely.js} +7 -4
- package/package.json +3 -4
- /package/{Dropzone.js → lib/Dropzone.js} +0 -0
- /package/{FetchRequest.js → lib/FetchRequest.js} +0 -0
- /package/{keyGeneratorWorker.js → lib/keyGeneratorWorker.js} +0 -0
- /package/{uploadWorker.js → lib/uploadWorker.js} +0 -0
|
@@ -29,6 +29,7 @@ function FileUtil(param) {
|
|
|
29
29
|
this.eof = false;
|
|
30
30
|
this.data = [];
|
|
31
31
|
this.tempSize = 0;
|
|
32
|
+
this.part = 1;
|
|
32
33
|
|
|
33
34
|
this.init = function() {
|
|
34
35
|
return new Promise(function(resolve) {
|
|
@@ -40,7 +41,7 @@ function FileUtil(param) {
|
|
|
40
41
|
myself.file.name = path.basename(myself.filePath);
|
|
41
42
|
|
|
42
43
|
if(myself.file.size > (myself.SEGMENT_SIZE/4)) {
|
|
43
|
-
myself.file.totalParts = Math.ceil((myself.file.size-(myself.SEGMENT_SIZE/4))/myself.SEGMENT_SIZE);
|
|
44
|
+
myself.file.totalParts = 1 + Math.ceil((myself.file.size-(myself.SEGMENT_SIZE/4))/myself.SEGMENT_SIZE);
|
|
44
45
|
} else {
|
|
45
46
|
myself.file.totalParts = 1;
|
|
46
47
|
}
|
|
@@ -56,9 +57,14 @@ function FileUtil(param) {
|
|
|
56
57
|
|
|
57
58
|
myself.readableStream.on('end', function() {
|
|
58
59
|
// done reading file
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
myself.eof = true;
|
|
61
|
+
if(myself.part === myself.file.totalParts) {
|
|
61
62
|
callback(true);
|
|
63
|
+
} else {
|
|
64
|
+
// increment extra part if file size is less than segment/4
|
|
65
|
+
// so that we callback with an empty array
|
|
66
|
+
myself.part++;
|
|
67
|
+
callback(false);
|
|
62
68
|
}
|
|
63
69
|
});
|
|
64
70
|
}
|
|
@@ -71,11 +77,15 @@ function FileUtil(param) {
|
|
|
71
77
|
if(!myself.reading && !myself.eof) {
|
|
72
78
|
myself.reading = true;
|
|
73
79
|
processChunk();
|
|
80
|
+
} else if(myself.part === myself.file.totalParts) {
|
|
81
|
+
//extra part padding with empty array if file size is less than segment/4
|
|
82
|
+
callback(true);
|
|
74
83
|
}
|
|
75
84
|
}
|
|
76
85
|
|
|
77
86
|
function processChunk() {
|
|
78
87
|
if(myself.tempSize === myself.SEGMENT_SIZE) {
|
|
88
|
+
myself.part++;
|
|
79
89
|
// callback when data size reaches SEGMENT_SIZE
|
|
80
90
|
callback(false);
|
|
81
91
|
} else {
|
|
@@ -2495,7 +2495,7 @@ function DownloadAndDecryptFile (eventHandler, request, serverWorkerURI) {
|
|
|
2495
2495
|
myself.eventHandler.raise(progressEvent, response.size);
|
|
2496
2496
|
return response.arrayBuffer();
|
|
2497
2497
|
} else {
|
|
2498
|
-
return response
|
|
2498
|
+
return response;
|
|
2499
2499
|
}
|
|
2500
2500
|
}).then(function(data){
|
|
2501
2501
|
if(isValidResponse(res)) {
|
|
@@ -2504,6 +2504,9 @@ function DownloadAndDecryptFile (eventHandler, request, serverWorkerURI) {
|
|
|
2504
2504
|
} else {
|
|
2505
2505
|
raiseDownloadError(data);
|
|
2506
2506
|
}
|
|
2507
|
+
}).catch(function(error) {
|
|
2508
|
+
console.error(error);
|
|
2509
|
+
myself.eventHandler.raiseError("FAIL", error);
|
|
2507
2510
|
});
|
|
2508
2511
|
|
|
2509
2512
|
function isValidResponse(res) {
|
|
@@ -2511,9 +2514,9 @@ function DownloadAndDecryptFile (eventHandler, request, serverWorkerURI) {
|
|
|
2511
2514
|
}
|
|
2512
2515
|
|
|
2513
2516
|
function raiseDownloadError(res) {
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
myself.eventHandler.raiseError("FAIL", "Server returned an error: " +
|
|
2517
|
+
console.error(res)
|
|
2518
|
+
let response = 'Response Code: ' + res.status + ', Response Text: ' + res.statusText;
|
|
2519
|
+
myself.eventHandler.raiseError("FAIL", "Server returned an error: " + response);
|
|
2517
2520
|
}
|
|
2518
2521
|
};
|
|
2519
2522
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendsafely/sendsafely",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"main": "SendSafely.js",
|
|
3
|
+
"version": "1.1.4",
|
|
4
|
+
"main": "./lib/SendSafely.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
7
|
},
|
|
@@ -29,6 +29,5 @@
|
|
|
29
29
|
"bugs": {
|
|
30
30
|
"url": "https://github.com/SendSafely/JavaScript-Node-Client-API/issues"
|
|
31
31
|
},
|
|
32
|
-
"homepage": "https://github.com/SendSafely/JavaScript-Node-Client-API#readme"
|
|
33
|
-
"devDependencies": {}
|
|
32
|
+
"homepage": "https://github.com/SendSafely/JavaScript-Node-Client-API#readme"
|
|
34
33
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|