spd-lib 1.1.8 → 1.1.9
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/index.js +10 -6
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -32,7 +32,9 @@ this.salt = salt;
|
|
|
32
32
|
const dmap = await this.CITS(data)
|
|
33
33
|
await sodium.ready;
|
|
34
34
|
const dat = Buffer.from(dmap[0]);
|
|
35
|
-
const compressedData = zlib.deflateSync(dat
|
|
35
|
+
const compressedData = zlib.deflateSync(dat,{
|
|
36
|
+
level:9
|
|
37
|
+
});
|
|
36
38
|
const nonce = sodium.randombytes_buf(sodium.crypto_box_NONCEBYTES);
|
|
37
39
|
const encryptedData = sodium.crypto_secretbox_easy(compressedData, nonce, this.userKey);
|
|
38
40
|
const hash = crypto.createHash('sha256').update(encryptedData).digest('hex');
|
|
@@ -45,7 +47,9 @@ this.salt = salt;
|
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
const spdData = JSON.stringify({ data: this.data, salt: Array.from(this.salt) });
|
|
48
|
-
const compressedSpdData = zlib.deflateSync(spdData
|
|
50
|
+
const compressedSpdData = zlib.deflateSync(spdData,{
|
|
51
|
+
level:9
|
|
52
|
+
});
|
|
49
53
|
fs.writeFileSync(outputPath, compressedSpdData, { mode: 0o600 });
|
|
50
54
|
}
|
|
51
55
|
|
|
@@ -59,7 +63,7 @@ this.salt = salt;
|
|
|
59
63
|
|
|
60
64
|
await sodium.ready;
|
|
61
65
|
const compressedSpdData = fs.readFileSync(spdPath);
|
|
62
|
-
const spdData = zlib.inflateSync(compressedSpdData).toString('utf8');
|
|
66
|
+
const spdData = zlib.inflateSync(compressedSpdData,{level:9}).toString('utf8');
|
|
63
67
|
const { data, salt } = JSON.parse(spdData);
|
|
64
68
|
|
|
65
69
|
const { pqcKey } = await new SPD().convertPasscodeToPQCKeySalted(passcode, new Uint8Array(salt));
|
|
@@ -97,7 +101,7 @@ this.salt = salt;
|
|
|
97
101
|
this.data.forEach(async dat => {
|
|
98
102
|
try{
|
|
99
103
|
const decryptedData = sodium.crypto_secretbox_open_easy(dat.data, dat.nonce, this.userKey);
|
|
100
|
-
const decompressedData = zlib.inflateSync(decryptedData);
|
|
104
|
+
const decompressedData = zlib.inflateSync(decryptedData,{level:9});
|
|
101
105
|
const dt = decompressedData.toString('utf8');
|
|
102
106
|
extractedFiles[dat.dataName] = await this.CSTI(dt, dat.dataType);
|
|
103
107
|
}catch{
|
|
@@ -131,7 +135,7 @@ this.salt = salt;
|
|
|
131
135
|
|
|
132
136
|
saveData() {
|
|
133
137
|
const spdData = JSON.stringify({ data: this.data, salt: Array.from(this.salt) });
|
|
134
|
-
const compressedSpdData = zlib.deflateSync(spdData);
|
|
138
|
+
const compressedSpdData = zlib.deflateSync(spdData,{level:9});
|
|
135
139
|
return compressedSpdData;
|
|
136
140
|
}
|
|
137
141
|
|
|
@@ -144,7 +148,7 @@ this.salt = salt;
|
|
|
144
148
|
|
|
145
149
|
await sodium.ready;
|
|
146
150
|
const spdDataBuffer = Buffer.from(spdData, 'base64');
|
|
147
|
-
const spdData2 = zlib.inflateSync(spdDataBuffer).toString('utf8');
|
|
151
|
+
const spdData2 = zlib.inflateSync(spdDataBuffer,{level:9}).toString('utf8');
|
|
148
152
|
const { data, salt } = JSON.parse(spdData2);
|
|
149
153
|
const { pqcKey } = await new SPD().convertPasscodeToPQCKeySalted(passcode, new Uint8Array(salt));
|
|
150
154
|
const pbk = pqcKey.publicKey;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spd-lib",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "SPD or Secure Packaged Data is a compress PQC protected file format to store sensitive data localy",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,6 +21,6 @@
|
|
|
21
21
|
"author": "ALS-OPSS",
|
|
22
22
|
"license": "ISC",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"libsodium-wrappers": "^0.7.
|
|
24
|
+
"libsodium-wrappers": "^0.7.15"
|
|
25
25
|
}
|
|
26
26
|
}
|