spd-lib 1.2.2 → 1.2.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.
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "spd-lib",
3
+ "version": "1.2.4",
4
+ "description": "SPD or Secure Packaged Data is a compress PQC protected file format to store sensitive data localy",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "prepublishOnly": "node obfuscate.js",
9
+ "package": "cp package-lock.json ./package/package-lock.json ; cp package.json ./package/package.json ; cp -R node_modules ./package/node_modules ; mkdir -p ./package/dist/ ; cp ./dist/index.js ./package/dist/index.js"
10
+ },
11
+ "keywords": [
12
+ "security",
13
+ "encryption",
14
+ "data-storage",
15
+ "persistent",
16
+ "crypto",
17
+ "compression",
18
+ "file",
19
+ "nodejs",
20
+ "libsodium",
21
+ "zlib"
22
+ ],
23
+ "author": "ALS-OPSS",
24
+ "license": "ISC",
25
+ "dependencies": {
26
+ "argon2": "^0.41.1",
27
+ "high-zip": "^1.0.0",
28
+ "libsodium-wrappers": "^0.7.15"
29
+ },
30
+ "devDependencies": {
31
+ "javascript-obfuscator": "^4.1.1",
32
+ "terser": "^5.39.0"
33
+ }
34
+ }
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "spd-lib",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "SPD or Secure Packaged Data is a compress PQC protected file format to store sensitive data localy",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "prepublishOnly": "node obfuscate.js",
9
+ "package": "cp package-lock.json ./package/package-lock.json ; cp package.json ./package/package.json ; cp -R node_modules ./package/node_modules ; mkdir -p ./package/dist/ ; cp ./dist/index.js ./package/dist/index.js"
8
10
  },
9
11
  "keywords": [
10
12
  "security",
@@ -22,6 +24,7 @@
22
24
  "license": "ISC",
23
25
  "dependencies": {
24
26
  "argon2": "^0.41.1",
27
+ "high-zip": "^1.0.0",
25
28
  "libsodium-wrappers": "^0.7.15"
26
29
  },
27
30
  "devDependencies": {
package/readme.md ADDED
@@ -0,0 +1,137 @@
1
+ # Secure Packaged Data (SPD)
2
+
3
+ The Secure Packaged Data (SPD) module provides functionality to securely store and retrieve data using encryption, compression, and hashing. This README explains how to use the SPD class and its methods.
4
+
5
+ ## Installation
6
+
7
+ First, ensure you have Node.js installed. Then, install the required packages:
8
+
9
+ ```sh
10
+ npm install spd-lib
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Below are the primary functionalities of the SPD class.
16
+
17
+ ### Initialization
18
+
19
+ Create an instance of the SPD class:
20
+
21
+ ```javascript
22
+ const { SPD } = require('spd-lib');
23
+
24
+ const spd = new SPD();
25
+ ```
26
+
27
+ ### Setting Passcode
28
+
29
+ Set a passcode for encrypting the data:
30
+
31
+ ```javascript
32
+ await spd.setPassKey('your-passcode');
33
+ ```
34
+
35
+ ### Adding Data
36
+
37
+ Add data to the SPD instance:
38
+
39
+ ```javascript
40
+ await spd.addData('dataName', yourData);
41
+ ```
42
+
43
+ ### Saving Data to File
44
+
45
+ Save the encrypted and compressed data to a file:
46
+
47
+ ```javascript
48
+ spd.saveToFile('path/to/output.spd');
49
+ ```
50
+
51
+ ### Loading Data from File
52
+
53
+ Load the data from an SPD file:
54
+
55
+ ```javascript
56
+ const loadedSPD = await SPD.loadFromFile('path/to/output.spd', 'your-passcode');
57
+ ```
58
+
59
+ ### Extracting Data
60
+
61
+ Extract and decrypt the data from the SPD instance:
62
+
63
+ ```javascript
64
+ const extractedData = await loadedSPD.extractData();
65
+ console.log(extractedData);
66
+ ```
67
+
68
+ ## Example
69
+
70
+ Here is a complete example of how to use the SPD module:
71
+
72
+ ```javascript
73
+ const { SPD } = require('./path/to/spd.js');
74
+
75
+ (async () => {
76
+ const spd = new SPD();
77
+ await spd.setPassKey('your-passcode');
78
+
79
+ const myData = {
80
+ name: "Alice",
81
+ age: 30,
82
+ isMember: true,
83
+ preferences: ["reading", "gaming"]
84
+ };
85
+
86
+ await spd.addData('userData', myData);
87
+
88
+ spd.saveToFile('path/to/output.spd');
89
+
90
+ const loadedSPD = await SPD.loadFromFile('path/to/output.spd', 'your-passcode');
91
+ const extractedData = await loadedSPD.extractData();
92
+
93
+ console.log(extractedData);
94
+ })();
95
+ ```
96
+
97
+ ## Methods
98
+
99
+ ### `async setPassKey(passcode)`
100
+
101
+ Sets the passcode for encrypting and decrypting data.
102
+
103
+ - **Parameters**: `passcode` (string) - The passcode to be used.
104
+
105
+ ### `async addData(name, data)`
106
+
107
+ Adds data to the SPD instance.
108
+
109
+ - **Parameters**:
110
+ - `name` (string) - The name of the data.
111
+ - `data` (any) - The data to be stored.
112
+
113
+ ### `saveToFile(outputPath)`
114
+
115
+ Saves the encrypted and compressed data to a file.
116
+
117
+ - **Parameters**: `outputPath` (string) - The path to save the file.
118
+
119
+ ### `static async loadFromFile(spdPath, passcode)`
120
+
121
+ Loads the SPD data from a file.
122
+
123
+ - **Parameters**:
124
+ - `spdPath` (string) - The path to the SPD file.
125
+ - `passcode` (string) - The passcode to decrypt the data.
126
+
127
+ - **Returns**: An instance of SPD with the loaded data.
128
+
129
+ ### `async extractData()`
130
+
131
+ Extracts and decrypts the data from the SPD instance.
132
+
133
+ - **Returns**: An object with the decrypted data.
134
+
135
+ ## License
136
+
137
+ This project is licensed under the MIT License.
package/readme.md.gz ADDED
Binary file
@@ -0,0 +1,137 @@
1
+ # Secure Packaged Data (SPD)
2
+
3
+ The Secure Packaged Data (SPD) module provides functionality to securely store and retrieve data using encryption, compression, and hashing. This README explains how to use the SPD class and its methods.
4
+
5
+ ## Installation
6
+
7
+ First, ensure you have Node.js installed. Then, install the required packages:
8
+
9
+ ```sh
10
+ npm install spd-lib
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Below are the primary functionalities of the SPD class.
16
+
17
+ ### Initialization
18
+
19
+ Create an instance of the SPD class:
20
+
21
+ ```javascript
22
+ const { SPD } = require('spd-lib');
23
+
24
+ const spd = new SPD();
25
+ ```
26
+
27
+ ### Setting Passcode
28
+
29
+ Set a passcode for encrypting the data:
30
+
31
+ ```javascript
32
+ await spd.setPassKey('your-passcode');
33
+ ```
34
+
35
+ ### Adding Data
36
+
37
+ Add data to the SPD instance:
38
+
39
+ ```javascript
40
+ await spd.addData('dataName', yourData);
41
+ ```
42
+
43
+ ### Saving Data to File
44
+
45
+ Save the encrypted and compressed data to a file:
46
+
47
+ ```javascript
48
+ spd.saveToFile('path/to/output.spd');
49
+ ```
50
+
51
+ ### Loading Data from File
52
+
53
+ Load the data from an SPD file:
54
+
55
+ ```javascript
56
+ const loadedSPD = await SPD.loadFromFile('path/to/output.spd', 'your-passcode');
57
+ ```
58
+
59
+ ### Extracting Data
60
+
61
+ Extract and decrypt the data from the SPD instance:
62
+
63
+ ```javascript
64
+ const extractedData = await loadedSPD.extractData();
65
+ console.log(extractedData);
66
+ ```
67
+
68
+ ## Example
69
+
70
+ Here is a complete example of how to use the SPD module:
71
+
72
+ ```javascript
73
+ const { SPD } = require('./path/to/spd.js');
74
+
75
+ (async () => {
76
+ const spd = new SPD();
77
+ await spd.setPassKey('your-passcode');
78
+
79
+ const myData = {
80
+ name: "Alice",
81
+ age: 30,
82
+ isMember: true,
83
+ preferences: ["reading", "gaming"]
84
+ };
85
+
86
+ await spd.addData('userData', myData);
87
+
88
+ spd.saveToFile('path/to/output.spd');
89
+
90
+ const loadedSPD = await SPD.loadFromFile('path/to/output.spd', 'your-passcode');
91
+ const extractedData = await loadedSPD.extractData();
92
+
93
+ console.log(extractedData);
94
+ })();
95
+ ```
96
+
97
+ ## Methods
98
+
99
+ ### `async setPassKey(passcode)`
100
+
101
+ Sets the passcode for encrypting and decrypting data.
102
+
103
+ - **Parameters**: `passcode` (string) - The passcode to be used.
104
+
105
+ ### `async addData(name, data)`
106
+
107
+ Adds data to the SPD instance.
108
+
109
+ - **Parameters**:
110
+ - `name` (string) - The name of the data.
111
+ - `data` (any) - The data to be stored.
112
+
113
+ ### `saveToFile(outputPath)`
114
+
115
+ Saves the encrypted and compressed data to a file.
116
+
117
+ - **Parameters**: `outputPath` (string) - The path to save the file.
118
+
119
+ ### `static async loadFromFile(spdPath, passcode)`
120
+
121
+ Loads the SPD data from a file.
122
+
123
+ - **Parameters**:
124
+ - `spdPath` (string) - The path to the SPD file.
125
+ - `passcode` (string) - The passcode to decrypt the data.
126
+
127
+ - **Returns**: An instance of SPD with the loaded data.
128
+
129
+ ### `async extractData()`
130
+
131
+ Extracts and decrypts the data from the SPD instance.
132
+
133
+ - **Returns**: An object with the decrypted data.
134
+
135
+ ## License
136
+
137
+ This project is licensed under the MIT License.