@sendsafely/sendsafely 1.1.8 → 1.1.10
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/lib/SendSafely.js +35 -1
- package/package.json +4 -4
package/lib/SendSafely.js
CHANGED
|
@@ -42,6 +42,7 @@ function SendSafely(url, apiKeyId, apiKeySecret, requestAPI){
|
|
|
42
42
|
this.uploadAPI = undefined;
|
|
43
43
|
this.url = url;
|
|
44
44
|
this.requestAPI = (requestAPI === undefined) ? "NODE_API" : requestAPI;
|
|
45
|
+
this.wrapperRequest = new FetchRequest({url: url, apiKey: apiKeyId, apiKeySecret: apiKeySecret});
|
|
45
46
|
|
|
46
47
|
sjcl.codec.utf8String.fromBits = function(a) {
|
|
47
48
|
var b = "",
|
|
@@ -969,6 +970,35 @@ function SendSafely(url, apiKeyId, apiKeySecret, requestAPI){
|
|
|
969
970
|
new FeedbackHandler(myself.eventHandler, myself.request).execute(log, stacktrace, systemInfo, myself.async);
|
|
970
971
|
};
|
|
971
972
|
|
|
973
|
+
this.sendSignedRequest = function (endpoint, HTTPMethod, mimeType, requestData, successCallback, customErrorEvent) {
|
|
974
|
+
this.wrapperRequest.sendSignedRequest({
|
|
975
|
+
url: endpoint,
|
|
976
|
+
HTTPMethod: HTTPMethod.toUpperCase(),
|
|
977
|
+
mimetype: mimeType
|
|
978
|
+
}, requestData)
|
|
979
|
+
.then(function (response) {
|
|
980
|
+
if (response.status === 200) {
|
|
981
|
+
// Success
|
|
982
|
+
return response.json();
|
|
983
|
+
} else {
|
|
984
|
+
// HTTP request error
|
|
985
|
+
myself.eventHandler.raiseError(response.status, response.error, customErrorEvent);
|
|
986
|
+
}
|
|
987
|
+
}).then(function (responseData) {
|
|
988
|
+
if (responseData.hasOwnProperty('response') && responseData.response.toUpperCase() === 'SUCCESS') {
|
|
989
|
+
if (successCallback !== undefined) {
|
|
990
|
+
successCallback(responseData);
|
|
991
|
+
}
|
|
992
|
+
} else {
|
|
993
|
+
// SendSafely server returned an error for the user
|
|
994
|
+
myself.eventHandler.raiseError(responseData.response, responseData.message, customErrorEvent);
|
|
995
|
+
}
|
|
996
|
+
}).catch(function (error) {
|
|
997
|
+
// catch errors thrown by fetch
|
|
998
|
+
myself.eventHandler.raiseError(error.code, error.message, customErrorEvent);
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
|
|
972
1002
|
}
|
|
973
1003
|
|
|
974
1004
|
//Other Functions
|
|
@@ -2378,7 +2408,11 @@ function DownloadAndDecryptFile (eventHandler, request, serverWorkerURI) {
|
|
|
2378
2408
|
|
|
2379
2409
|
function getDownloadPathFromConfig(config, file) {
|
|
2380
2410
|
var downloadPath = "";
|
|
2381
|
-
|
|
2411
|
+
|
|
2412
|
+
// sanitize file name to avoid conflicts with OS file systems
|
|
2413
|
+
config.fileName = config.fileName.replaceAll(/[<>:"\/\\|?*]/g, '_');
|
|
2414
|
+
file.fileName = file.fileName.replaceAll(/[<>:"\/\\|?*]/g, '_');
|
|
2415
|
+
|
|
2382
2416
|
if (config.path && config.fileName) {
|
|
2383
2417
|
downloadPath = path.join(config.path, config.fileName);
|
|
2384
2418
|
} else if (config.path) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendsafely/sendsafely",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"main": "./lib/SendSafely.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"description": "The SendSafely JavaScript SDK for Node.js lets you integrate SendSafely secure data transfer capabilities directly into your Node.js application.",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"jquery": "^3.4.1",
|
|
13
|
-
"make-fetch-happen": "^
|
|
14
|
-
"openpgp": "4.
|
|
15
|
-
"sjcl": "
|
|
13
|
+
"make-fetch-happen": "^11.1.1",
|
|
14
|
+
"openpgp": "4.10.11",
|
|
15
|
+
"sjcl": "1.0.8",
|
|
16
16
|
"window": "^4.2.7",
|
|
17
17
|
"xmlhttprequest": "^1.8.0"
|
|
18
18
|
},
|