@sendsafely/sendsafely 1.1.7 → 1.1.8
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 +1 -1
- package/lib/keyGeneratorWorker.js +0 -0
- package/package.json +1 -1
- package/examples/CreateNewPackage/CreateNewPackage.js +0 -138
- package/examples/CreateNewPackage/README.md +0 -27
- package/examples/CreateNewPackage/package.json +0 -15
- package/examples/CreateNewPackage/test1.txt +0 -1
- package/examples/CreateNewPackage/test2.txt +0 -1
package/lib/SendSafely.js
CHANGED
|
@@ -353,7 +353,7 @@ function SendSafely(url, apiKeyId, apiKeySecret, requestAPI){
|
|
|
353
353
|
};
|
|
354
354
|
|
|
355
355
|
this.shouldNotifyRecipients = function() {
|
|
356
|
-
var notifyRecipients = (myself.notifyRecipients === undefined) ?
|
|
356
|
+
var notifyRecipients = (myself.notifyRecipients === undefined) ? false : myself.notifyRecipients;
|
|
357
357
|
return notifyRecipients;
|
|
358
358
|
};
|
|
359
359
|
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
var fs = require('fs');
|
|
2
|
-
var SendSafely = require('@sendsafely/sendsafely');
|
|
3
|
-
|
|
4
|
-
var fileArray = [];
|
|
5
|
-
var fileUploadCount = 0;
|
|
6
|
-
var recipientAddedCount = 0;
|
|
7
|
-
var newPackageId;
|
|
8
|
-
var newServerSecret;
|
|
9
|
-
var newPackageCode;
|
|
10
|
-
var newKeyCode;
|
|
11
|
-
|
|
12
|
-
var filesToUpload = ["test1.txt", "test2.txt"];
|
|
13
|
-
var recipientsToAdd = ["user+one@example.com", "user+two@example.com", "user+three@example.com"];
|
|
14
|
-
var publicKeys = [];
|
|
15
|
-
var fileIds = [];
|
|
16
|
-
|
|
17
|
-
var privateKey = ""
|
|
18
|
-
var publicKeyId = "";
|
|
19
|
-
var files = [];
|
|
20
|
-
|
|
21
|
-
//var sendSafely = new SendSafely("https://demo.sendsafely.com", "exAPIkeyxyz", "exAPIsecretxyz");
|
|
22
|
-
var sendSafely = new SendSafely("https://ORGANIZATION_HOST", "API_KEY", "API_SECRET");
|
|
23
|
-
|
|
24
|
-
sendSafely.verifyCredentials(function(email) {
|
|
25
|
-
initEvents();
|
|
26
|
-
console.log("Connected to SendSafely as user " + email);
|
|
27
|
-
getFiles();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
function initEvents() {
|
|
31
|
-
sendSafely.on('save.file',function(data) {
|
|
32
|
-
var fileName = files.find(f=>{ return f.fileId === data.fileId }).fileId;
|
|
33
|
-
fs.writeFile(fileName, data.file, (err) => {
|
|
34
|
-
if(err) {
|
|
35
|
-
throw err;
|
|
36
|
-
}
|
|
37
|
-
console.log('The file has been saved! ' + data.fileId);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
sendSafely.on('sendsafely.error', function(error, errorMsg) {
|
|
42
|
-
console.log(error)
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getFiles() {
|
|
47
|
-
if (fileArray.length == filesToUpload.length) {
|
|
48
|
-
step1();
|
|
49
|
-
} else {
|
|
50
|
-
console.log("Reading file " + filesToUpload[fileArray.length]);
|
|
51
|
-
fs.readFile(filesToUpload[fileArray.length], function(err, data) {
|
|
52
|
-
if (err) {
|
|
53
|
-
throw err
|
|
54
|
-
}
|
|
55
|
-
var file = {
|
|
56
|
-
size: data.length,
|
|
57
|
-
name: filesToUpload[fileArray.length],
|
|
58
|
-
data: data
|
|
59
|
-
};
|
|
60
|
-
fileArray.push(file);
|
|
61
|
-
getFiles();
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function step1() {
|
|
67
|
-
console.log("Generate new key pair")
|
|
68
|
-
sendSafely.generateKeyPair("Node example",false,function(privateKey, publicKey){
|
|
69
|
-
console.log("New key pair generated");
|
|
70
|
-
newPrivateKey = privateKey;
|
|
71
|
-
newPublicKey = publicKey;
|
|
72
|
-
publicKeyId = publicKey.id
|
|
73
|
-
step2();
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function step2() {
|
|
78
|
-
sendSafely.createPackage(function(packageId, serverSecret, packageCode, keyCode) {
|
|
79
|
-
newPackageId = packageId;
|
|
80
|
-
newServerSecret = serverSecret;
|
|
81
|
-
newPackageCode = packageCode;
|
|
82
|
-
newKeyCode = keyCode;
|
|
83
|
-
console.log("Created new Package ID: " + packageId);
|
|
84
|
-
console.log("KeyCode: " + keyCode);
|
|
85
|
-
console.log("Server Secret: " + serverSecret);
|
|
86
|
-
console.log("Package Code: " + packageCode);
|
|
87
|
-
sendSafely.encryptAndUploadFiles(newPackageId, newKeyCode, newServerSecret, fileArray, "js", function(packageId,fileId, fileSize,fileName) {
|
|
88
|
-
fileUploadCount++;
|
|
89
|
-
fileIds.push(fileId);
|
|
90
|
-
console.log("Upload Complete - File " + fileUploadCount + " - " + fileName);
|
|
91
|
-
if (fileUploadCount == filesToUpload.length) {
|
|
92
|
-
console.log("All Uploads Complete");
|
|
93
|
-
step3();
|
|
94
|
-
}
|
|
95
|
-
})
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function step3() {
|
|
100
|
-
console.log("Encrypting and Uploading Message");
|
|
101
|
-
sendSafely.encryptAndUploadMessage(newPackageId, newKeyCode, newServerSecret, "This is a test package from Node.js", function(encryptedMessage) {
|
|
102
|
-
console.log("Message Added");
|
|
103
|
-
console.log("Adding Recipients");
|
|
104
|
-
for (var i = 0; i < recipientsToAdd.length; i++) {
|
|
105
|
-
sendSafely.addRecipient(newPackageId, recipientsToAdd[i], undefined, function(finished) {
|
|
106
|
-
recipientAddedCount++;
|
|
107
|
-
console.log("Recipient " + recipientAddedCount + " added");
|
|
108
|
-
if (recipientAddedCount == recipientsToAdd.length) {
|
|
109
|
-
console.log("Finalizing Package");
|
|
110
|
-
sendSafely.finalizePackage(newPackageId, newPackageCode, newKeyCode, function(done) {
|
|
111
|
-
console.log("Secure Link: " + done);
|
|
112
|
-
step4();
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function step4() {
|
|
121
|
-
console.log("Getting keycode");
|
|
122
|
-
sendSafely.getKeycode(newPrivateKey,publicKeyId,newPackageId,function(keycode){
|
|
123
|
-
console.log('Decrypted keycode from private key : ' + keycode);
|
|
124
|
-
console.log('Keycode from package : ' + newKeyCode);
|
|
125
|
-
step5();
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function step5() {
|
|
130
|
-
sendSafely.packageInformation(newPackageId,function(res){
|
|
131
|
-
files = res.files;
|
|
132
|
-
for(var i = 0; i < res.files.length; i++) {
|
|
133
|
-
var file = res.files[i];
|
|
134
|
-
console.log('Downloading file ' + file.fileName);
|
|
135
|
-
sendSafely.downloadFile(newPackageId,file.fileId,newKeyCode);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
# Node.js SendSafely Sample Application
|
|
3
|
-
|
|
4
|
-
CreateNewPackage.js is a sample application demonstrating core SendSafely secure data transfer capabilities using the Sendsafely JavaScript API for Node.js.
|
|
5
|
-
|
|
6
|
-
## Quickstart
|
|
7
|
-
Install the @sendsafely/sendsafely Node module
|
|
8
|
-
```console
|
|
9
|
-
npm install
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
Update the SendSafely object in CreateNewPackage.js with your SendSafely organization hostname and a API Key and Secret.
|
|
13
|
-
|
|
14
|
-
```javascript
|
|
15
|
-
//var sendSafely = new SendSafely("https://demo.sendsafely.com", "exAPIkeyxyz", "exAPIsecretxyz");
|
|
16
|
-
var sendSafely = new SendSafely("https://ORGANIZATION_HOST", "API_KEY", "API_SECRET");
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
*You can generate your own API_KEY and API_SECRET from the API Keys section of your Profile page when logged into your SendSafely portal.*
|
|
20
|
-
|
|
21
|
-
Run CreateNewPackage sample application using Node
|
|
22
|
-
```console
|
|
23
|
-
node CreateNewPackage.js
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Support
|
|
27
|
-
For support, please contact support@sendsafely.com.
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"dependencies": {
|
|
3
|
-
"@sendsafely/sendsafely": "^1.x.x"
|
|
4
|
-
},
|
|
5
|
-
"name": "createnewpackage",
|
|
6
|
-
"version": "1.0.0",
|
|
7
|
-
"main": "CreateNewPackage.js",
|
|
8
|
-
"devDependencies": {},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
-
},
|
|
12
|
-
"author": "",
|
|
13
|
-
"license": "",
|
|
14
|
-
"description": ""
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World 1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Hello World 2
|