spd-lib 1.1.0 → 1.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.
Files changed (2) hide show
  1. package/index.js +9 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -44,10 +44,7 @@ this.salt = salt;
44
44
  throw new Error('Invalid output path or salt.');
45
45
  }
46
46
 
47
- const keyPair = {
48
- publicKey: Array.from(this.keyPair.publicKey)
49
- };
50
- const spdData = JSON.stringify({ keyPair, data: this.data, salt: Array.from(this.salt) });
47
+ const spdData = JSON.stringify({ data: this.data, salt: Array.from(this.salt) });
51
48
  const compressedSpdData = zlib.deflateSync(spdData);
52
49
  fs.writeFileSync(outputPath, compressedSpdData, { mode: 0o600 });
53
50
  }
@@ -61,14 +58,14 @@ this.salt = salt;
61
58
  await sodium.ready;
62
59
  const compressedSpdData = fs.readFileSync(spdPath);
63
60
  const spdData = zlib.inflateSync(compressedSpdData).toString('utf8');
64
- const { keyPair, data, salt } = JSON.parse(spdData);
61
+ const { data, salt } = JSON.parse(spdData);
65
62
 
66
63
  const { pqcKey } = await new SPD().convertPasscodeToPQCKeySalted(passcode, new Uint8Array(salt));
67
64
  const pbk = pqcKey.publicKey;
68
65
  const spd = new SPD();
69
66
  spd.userKey = pbk;
70
67
  spd.keyPair = {
71
- publicKey: Buffer.from(keyPair.publicKey)
68
+ publicKey: pbk.publicKey
72
69
  };
73
70
  spd.data = data.map(dat => ({
74
71
  dataName: dat.dataName,
@@ -117,10 +114,7 @@ this.salt = salt;
117
114
  }
118
115
 
119
116
  saveData() {
120
- const keyPair = {
121
- publicKey: Array.from(this.keyPair.publicKey)
122
- };
123
- const spdData = JSON.stringify({ keyPair, data: this.data, salt: Array.from(this.salt) });
117
+ const spdData = JSON.stringify({ data: this.data, salt: Array.from(this.salt) });
124
118
  const compressedSpdData = zlib.deflateSync(spdData);
125
119
  return compressedSpdData;
126
120
  }
@@ -133,14 +127,14 @@ this.salt = salt;
133
127
  await sodium.ready;
134
128
  const spdDataBuffer = Buffer.from(spdData, 'base64');
135
129
  const spdData2 = zlib.inflateSync(spdDataBuffer).toString('utf8');
136
- const { keyPair, data, salt } = JSON.parse(spdData2);
130
+ const { data, salt } = JSON.parse(spdData2);
137
131
 
138
132
  const { pqcKey } = await new SPD().convertPasscodeToPQCKeySalted(passcode, new Uint8Array(salt));
139
133
  const pbk = pqcKey.publicKey;
140
134
  const spd = new SPD();
141
135
  spd.userKey = pbk;
142
136
  spd.keyPair = {
143
- publicKey: Buffer.from(keyPair.publicKey)
137
+ publicKey: pbk.publicKey
144
138
  };
145
139
  spd.data = data.map(dat => ({
146
140
  dataName: dat.dataName,
@@ -297,6 +291,6 @@ this.salt = salt;
297
291
  }
298
292
  }
299
293
 
300
- module.exports = {
301
- SPD,
302
- };
294
+ //module.exports = {
295
+ // SPD,
296
+ //};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spd-lib",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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": {