xypriss-security 1.0.9 → 1.0.11

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/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ <div align="center">
2
+ <img src="https://sdk.nehonix.space/assets/xypriss/mode/global/logo.png" alt="XyPriss Logo" width="200"/>
3
+ </div>
4
+
1
5
  # XyPriss Security
2
6
 
3
7
  [![npm version](https://badge.fury.io/js/xypriss-security.svg)](https://badge.fury.io/js/xypriss-security)
@@ -11,28 +15,32 @@ XyPriss Security is an advanced JavaScript security library designed for enterpr
11
15
  ## Key Features
12
16
 
13
17
  ### Secure Data Structures
14
- - SecureArray: Military-grade encrypted arrays with AES-256-CTR-HMAC
15
- - SecureString: Protected string handling with automatic memory cleanup
16
- - SecureObject: Encrypted object storage with metadata management
17
- - SecureBuffer: Protected memory allocation with secure wiping
18
+
19
+ - SecureArray: Military-grade encrypted arrays with AES-256-CTR-HMAC
20
+ - SecureString: Protected string handling with automatic memory cleanup
21
+ - SecureObject: Encrypted object storage with metadata management
22
+ - SecureBuffer: Protected memory allocation with secure wiping
18
23
 
19
24
  ### Cryptographic Operations
20
- - Token Generation: Secure random tokens with configurable entropy
21
- - Password Management: Argon2ID hashing with pepper support
22
- - Hash Functions: SHA-256/512, BLAKE3, with timing-safe operations
23
- - Key Derivation: PBKDF2, Argon2, scrypt implementations
25
+
26
+ - Token Generation: Secure random tokens with configurable entropy
27
+ - Password Management: Argon2ID hashing with pepper support
28
+ - Hash Functions: SHA-256/512, BLAKE3, with timing-safe operations
29
+ - Key Derivation: PBKDF2, Argon2, scrypt implementations
24
30
 
25
31
  ### Advanced Security Features
26
- - Quantum-Resistant Cryptography: Post-quantum algorithms (Kyber, Dilithium)
27
- - Tamper-Evident Logging: Immutable audit trails with cryptographic verification
28
- - Fortified Functions: Tamper-resistant function execution with integrity checks
29
- - Side-Channel Protection: Timing-safe operations and memory protection
32
+
33
+ - Quantum-Resistant Cryptography: Post-quantum algorithms (Kyber, Dilithium)
34
+ - Tamper-Evident Logging: Immutable audit trails with cryptographic verification
35
+ - Fortified Functions: Tamper-resistant function execution with integrity checks
36
+ - Side-Channel Protection: Timing-safe operations and memory protection
30
37
 
31
38
  ### Enterprise Features
32
- - Zero Dependencies: Self-contained with no external dependencies
33
- - Browser & Node.js: Universal compatibility across environments
34
- - TypeScript Native: Full type safety and IntelliSense support
35
- - Performance Optimized: Benchmarked for high-throughput applications
39
+
40
+ - Zero Dependencies: Self-contained with no external dependencies
41
+ - Browser & Node.js: Universal compatibility across environments
42
+ - TypeScript Native: Full type safety and IntelliSense support
43
+ - Performance Optimized: Benchmarked for high-throughput applications
36
44
 
37
45
  ## Installation
38
46
 
@@ -41,6 +49,7 @@ npm install xypriss-security
41
49
  ```
42
50
 
43
51
  For use with XyPriss framework:
52
+
44
53
  ```bash
45
54
  npm install xypriss xypriss-security
46
55
  ```
@@ -50,87 +59,86 @@ npm install xypriss xypriss-security
50
59
  ### Basic Usage
51
60
 
52
61
  ```typescript
53
- import {
54
- XyPrissSecurity,
55
- fString,
56
- fArray,
57
- Hash,
58
- generateSecureToken
59
- } from 'xypriss-security';
62
+ import {
63
+ XyPrissSecurity,
64
+ fString,
65
+ fArray,
66
+ Hash,
67
+ generateSecureToken,
68
+ } from "xypriss-security";
60
69
 
61
70
  // Create secure strings
62
- const securePassword = fString('my-secret-password', {
63
- protectionLevel: 'maximum',
64
- enableEncryption: true
71
+ const securePassword = fString("my-secret-password", {
72
+ protectionLevel: "maximum",
73
+ enableEncryption: true,
65
74
  });
66
75
 
67
76
  // Generate secure random tokens
68
77
  const token = generateSecureToken({
69
78
  length: 32,
70
79
  entropy: "maximum",
71
-
72
80
  });
73
81
  console.log(token); // 64-character hex string
74
82
 
75
83
  // Hash operations
76
- const hash = Hash.create('sensitive-data', {
77
- algorithm: 'sha256',
78
- outputFormat: 'hex'
84
+ const hash = Hash.create("sensitive-data", {
85
+ algorithm: "sha256",
86
+ outputFormat: "hex",
79
87
  });
80
88
  ```
81
89
 
82
90
  ### Secure Data Handling
83
91
 
84
92
  ```typescript
85
- import { fArray, fObject } from 'xypriss-security';
93
+ import { fArray, fObject } from "xypriss-security";
86
94
 
87
95
  // Secure array operations
88
96
  const secureData = fArray([1, 2, 3, 4, 5]);
89
- secureData.setEncryptionKey('your-encryption-key-2025');
97
+ secureData.setEncryptionKey("your-encryption-key-2025");
90
98
  secureData.encryptAll();
91
99
 
92
100
  // Secure object storage
93
101
  const secureObj = fObject({
94
- apiKey: 'secret-api-key',
95
- credentials: { username: 'admin', password: 'secure123' }
102
+ apiKey: "secret-api-key",
103
+ credentials: { username: "admin", password: "secure123" },
96
104
  });
97
105
 
98
106
  // Access with automatic decryption
99
- const apiKey = secureObj.get('apiKey');
107
+ const apiKey = secureObj.get("apiKey");
100
108
  ```
101
109
 
102
110
  ### Password Management
103
111
 
104
112
  ```typescript
105
- import { Password } from 'xypriss-security';
113
+ import { Password } from "xypriss-security";
106
114
 
107
115
  // Hash passwords with Argon2ID
108
- const hashedPassword = await Password.hash('user-password', {
109
- algorithm: 'argon2id',
110
- memoryCost: 65536,
111
- timeCost: 3,
112
- parallelism: 4
116
+ const hashedPassword = await Password.hash("user-password", {
117
+ algorithm: "argon2id",
118
+ memoryCost: 65536,
119
+ timeCost: 3,
120
+ parallelism: 4,
113
121
  });
114
122
 
115
123
  // Verify passwords
116
- const isValid = await Password.verify('user-password', hashedPassword);
124
+ const isValid = await Password.verify("user-password", hashedPassword);
117
125
  ```
118
126
 
119
127
  ### Cryptographic Operations
120
128
 
121
129
  ```typescript
122
- import { XyPrissSecurity as security, KeyDerivation } from 'xypriss-security';
130
+ import { XyPrissSecurity as security, KeyDerivation } from "xypriss-security";
123
131
 
124
132
  // Generate encryption keys
125
- const key = await KeyDerivation.deriveKey('master-password', {
126
- salt: 'unique-salt',
127
- iterations: 100000,
128
- keyLength: 32,
129
- algorithm: 'pbkdf2'
133
+ const key = await KeyDerivation.deriveKey("master-password", {
134
+ salt: "unique-salt",
135
+ iterations: 100000,
136
+ keyLength: 32,
137
+ algorithm: "pbkdf2",
130
138
  });
131
139
 
132
140
  // Encrypt/decrypt data
133
- const encrypted = await security.encrypt('sensitive-data', key);
141
+ const encrypted = await security.encrypt("sensitive-data", key);
134
142
  const decrypted = await security.decrypt(encrypted, key);
135
143
  ```
136
144
 
@@ -139,29 +147,33 @@ const decrypted = await security.decrypt(encrypted, key);
139
147
  ### Core Modules
140
148
 
141
149
  #### Security Core (`/core`)
142
- - crypto.ts: Main cryptographic operations and algorithms
143
- - hash.ts: Secure hashing functions with timing-safe operations
144
- - random.ts: Cryptographically secure random number generation
145
- - validators.ts: Input validation and sanitization utilities
150
+
151
+ - crypto.ts: Main cryptographic operations and algorithms
152
+ - hash.ts: Secure hashing functions with timing-safe operations
153
+ - random.ts: Cryptographically secure random number generation
154
+ - validators.ts: Input validation and sanitization utilities
146
155
 
147
156
  #### Secure Components (`/components`)
148
- - secure-array: Encrypted array implementation
149
- - secure-string: Protected string handling
150
- - secure-object: Encrypted object storage
151
- - secure-memory: Memory management and protection
152
- - fortified-function: Tamper-resistant function execution
157
+
158
+ - secure-array: Encrypted array implementation
159
+ - secure-string: Protected string handling
160
+ - secure-object: Encrypted object storage
161
+ - secure-memory: Memory management and protection
162
+ - fortified-function: Tamper-resistant function execution
153
163
 
154
164
  #### Advanced Features (`/components`)
155
- - post-quantum: Quantum-resistant cryptographic algorithms
156
- - tamper-evident-logging: Immutable audit trail system
157
- - side-channel: Protection against timing and cache attacks
158
- - attestation: Code and data integrity verification
165
+
166
+ - post-quantum: Quantum-resistant cryptographic algorithms
167
+ - tamper-evident-logging: Immutable audit trail system
168
+ - side-channel: Protection against timing and cache attacks
169
+ - attestation: Code and data integrity verification
159
170
 
160
171
  #### Utilities (`/utils`)
161
- - errorHandler: Secure error handling and logging
162
- - performanceMonitor: Security-aware performance monitoring
163
- - securityUtils: General security utility functions
164
- - patterns: Security pattern matching and detection
172
+
173
+ - errorHandler: Secure error handling and logging
174
+ - performanceMonitor: Security-aware performance monitoring
175
+ - securityUtils: General security utility functions
176
+ - patterns: Security pattern matching and detection
165
177
 
166
178
  ## API Reference
167
179
 
@@ -171,17 +183,17 @@ The main entry point for the security library.
171
183
 
172
184
  ```typescript
173
185
  class XyPrissSecurity {
174
- constructor(config?: SecurityConfig);
175
-
176
- // Core methods
177
- encrypt(data: any, options?: EncryptionOptions): Promise<string>;
178
- decrypt(encryptedData: string, options?: DecryptionOptions): Promise<any>;
179
- hash(data: string, options?: HashOptions): string;
180
- generateToken(length?: number): string;
181
-
182
- // Validation methods
183
- validateInput(input: any, rules: ValidationRules): ValidationResult;
184
- sanitize(input: string, options?: SanitizeOptions): string;
186
+ constructor(config?: SecurityConfig);
187
+
188
+ // Core methods
189
+ encrypt(data: any, options?: EncryptionOptions): Promise<string>;
190
+ decrypt(encryptedData: string, options?: DecryptionOptions): Promise<any>;
191
+ hash(data: string, options?: HashOptions): string;
192
+ generateToken(length?: number): string;
193
+
194
+ // Validation methods
195
+ validateInput(input: any, rules: ValidationRules): ValidationResult;
196
+ sanitize(input: string, options?: SanitizeOptions): string;
185
197
  }
186
198
  ```
187
199
 
@@ -190,28 +202,31 @@ class XyPrissSecurity {
190
202
  #### fString (SecureString)
191
203
 
192
204
  ```typescript
193
- const secureStr = fString('sensitive-data', {
194
- protectionLevel: 'maximum',
195
- enableEncryption: true
205
+ const secureStr = fString("sensitive-data", {
206
+ protectionLevel: "maximum",
207
+ enableEncryption: true,
196
208
  });
197
209
  ```
198
210
 
199
211
  #### fArray (SecureArray)
200
212
 
201
213
  ```typescript
202
- const secureArr = fArray(['item1', 'item2'], {
203
- encryptionKey: 'your-key'
214
+ const secureArr = fArray(["item1", "item2"], {
215
+ encryptionKey: "your-key",
204
216
  });
205
217
  ```
206
218
 
207
219
  #### fObject (SecureObject)
208
220
 
209
221
  ```typescript
210
- const secureObj = fObject({
211
- key: 'value'
212
- }, {
213
- enableEncryption: true
214
- });
222
+ const secureObj = fObject(
223
+ {
224
+ key: "value",
225
+ },
226
+ {
227
+ enableEncryption: true,
228
+ }
229
+ );
215
230
  ```
216
231
 
217
232
  ### Utility Functions
@@ -219,15 +234,15 @@ const secureObj = fObject({
219
234
  #### generateSecureToken
220
235
 
221
236
  ```typescript
222
- const token = generateSecureToken(32, 'base64url');
237
+ const token = generateSecureToken(32, "base64url");
223
238
  ```
224
239
 
225
240
  #### Hash Operations
226
241
 
227
242
  ```typescript
228
- const hash = Hash.create('data', {
229
- algorithm: 'sha256',
230
- outputFormat: 'hex'
243
+ const hash = Hash.create("data", {
244
+ algorithm: "sha256",
245
+ outputFormat: "hex",
231
246
  });
232
247
  ```
233
248
 
@@ -237,29 +252,29 @@ const hash = Hash.create('data', {
237
252
 
238
253
  ```typescript
239
254
  interface SecurityConfig {
240
- encryption?: {
241
- algorithm?: 'aes-256-gcm' | 'chacha20-poly1305';
242
- keyDerivation?: 'pbkdf2' | 'argon2' | 'scrypt';
243
- iterations?: number;
244
- };
245
-
246
- memory?: {
247
- secureWipe?: boolean;
248
- protectedAllocation?: boolean;
249
- maxBufferSize?: number;
250
- };
251
-
252
- logging?: {
253
- auditTrail?: boolean;
254
- tamperEvident?: boolean;
255
- logLevel?: 'debug' | 'info' | 'warn' | 'error';
256
- };
257
-
258
- validation?: {
259
- strictMode?: boolean;
260
- sanitizeInputs?: boolean;
261
- maxInputLength?: number;
262
- };
255
+ encryption?: {
256
+ algorithm?: "aes-256-gcm" | "chacha20-poly1305";
257
+ keyDerivation?: "pbkdf2" | "argon2" | "scrypt";
258
+ iterations?: number;
259
+ };
260
+
261
+ memory?: {
262
+ secureWipe?: boolean;
263
+ protectedAllocation?: boolean;
264
+ maxBufferSize?: number;
265
+ };
266
+
267
+ logging?: {
268
+ auditTrail?: boolean;
269
+ tamperEvident?: boolean;
270
+ logLevel?: "debug" | "info" | "warn" | "error";
271
+ };
272
+
273
+ validation?: {
274
+ strictMode?: boolean;
275
+ sanitizeInputs?: boolean;
276
+ maxInputLength?: number;
277
+ };
263
278
  }
264
279
  ```
265
280
 
@@ -267,18 +282,18 @@ interface SecurityConfig {
267
282
 
268
283
  XyPriss Security is optimized for high-performance applications:
269
284
 
270
- - Encryption: 10,000+ operations/second (AES-256-GCM)
271
- - Hashing: 50,000+ operations/second (SHA-256)
272
- - Memory: Zero-copy operations where possible
273
- - CPU: Optimized algorithms with SIMD support
285
+ - Encryption: 10,000+ operations/second (AES-256-GCM)
286
+ - Hashing: 50,000+ operations/second (SHA-256)
287
+ - Memory: Zero-copy operations where possible
288
+ - CPU: Optimized algorithms with SIMD support
274
289
 
275
290
  ## Security Guarantees
276
291
 
277
- - Memory Safety: Automatic secure memory wiping
278
- - Timing Safety: Constant-time operations for sensitive data
279
- - Quantum Resistance: Post-quantum cryptographic algorithms
280
- - Side-Channel Protection: Resistance to timing and cache attacks
281
- - Tamper Evidence: Cryptographic integrity verification
292
+ - Memory Safety: Automatic secure memory wiping
293
+ - Timing Safety: Constant-time operations for sensitive data
294
+ - Quantum Resistance: Post-quantum cryptographic algorithms
295
+ - Side-Channel Protection: Resistance to timing and cache attacks
296
+ - Tamper Evidence: Cryptographic integrity verification
282
297
 
283
298
  ## Contributing
284
299
 
@@ -290,6 +305,7 @@ MIT License - see [LICENSE](./LICENSE) file for details.
290
305
 
291
306
  ## Support
292
307
 
293
- - [Documentation](./docs/)
294
- - [GitHub Issues](https://github.com/Nehonix-Team/XyPriss/issues)
295
- - [Security Advisories](https://github.com/Nehonix-Team/XyPriss/security)
308
+ - [Documentation](./docs/)
309
+ - [GitHub Issues](https://github.com/Nehonix-Team/XyPriss/issues)
310
+ - [Security Advisories](https://github.com/Nehonix-Team/XyPriss/security)
311
+