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 +142 -126
- package/dist/cjs/components/cache/SCC.js +623 -0
- package/dist/cjs/components/cache/SCC.js.map +1 -0
- package/dist/cjs/components/cache/index.js +3 -616
- package/dist/cjs/components/cache/index.js.map +1 -1
- package/dist/cjs/components/cache/useCache.js +0 -11
- package/dist/cjs/components/cache/useCache.js.map +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/cache/SecureCacheAdapter.js +3 -4
- package/dist/cjs/src/cache/SecureCacheAdapter.js.map +1 -1
- package/dist/cjs/src/cache/index.js +29 -9
- package/dist/cjs/src/cache/index.js.map +1 -1
- package/dist/esm/components/cache/SCC.js +621 -0
- package/dist/esm/components/cache/SCC.js.map +1 -0
- package/dist/esm/components/cache/index.js +4 -615
- package/dist/esm/components/cache/index.js.map +1 -1
- package/dist/esm/components/cache/useCache.js +0 -11
- package/dist/esm/components/cache/useCache.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/src/cache/SecureCacheAdapter.js +2 -3
- package/dist/esm/src/cache/SecureCacheAdapter.js.map +1 -1
- package/dist/esm/src/cache/index.js +1 -2
- package/dist/esm/src/cache/index.js.map +1 -1
- package/dist/index.d.ts +705 -715
- package/package.json +3 -4
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
|
[](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
|
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
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
|
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
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
|
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
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
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
} from
|
|
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(
|
|
63
|
-
|
|
64
|
-
|
|
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(
|
|
77
|
-
|
|
78
|
-
|
|
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
|
|
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(
|
|
97
|
+
secureData.setEncryptionKey("your-encryption-key-2025");
|
|
90
98
|
secureData.encryptAll();
|
|
91
99
|
|
|
92
100
|
// Secure object storage
|
|
93
101
|
const secureObj = fObject({
|
|
94
|
-
|
|
95
|
-
|
|
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(
|
|
107
|
+
const apiKey = secureObj.get("apiKey");
|
|
100
108
|
```
|
|
101
109
|
|
|
102
110
|
### Password Management
|
|
103
111
|
|
|
104
112
|
```typescript
|
|
105
|
-
import { Password } from
|
|
113
|
+
import { Password } from "xypriss-security";
|
|
106
114
|
|
|
107
115
|
// Hash passwords with Argon2ID
|
|
108
|
-
const hashedPassword = await Password.hash(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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(
|
|
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
|
|
130
|
+
import { XyPrissSecurity as security, KeyDerivation } from "xypriss-security";
|
|
123
131
|
|
|
124
132
|
// Generate encryption keys
|
|
125
|
-
const key = await KeyDerivation.deriveKey(
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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(
|
|
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
|
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
145
|
-
-
|
|
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
|
-
|
|
149
|
-
-
|
|
150
|
-
-
|
|
151
|
-
-
|
|
152
|
-
-
|
|
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
|
-
|
|
156
|
-
-
|
|
157
|
-
-
|
|
158
|
-
-
|
|
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
|
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
-
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
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(
|
|
194
|
-
|
|
195
|
-
|
|
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([
|
|
203
|
-
|
|
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
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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,
|
|
237
|
+
const token = generateSecureToken(32, "base64url");
|
|
223
238
|
```
|
|
224
239
|
|
|
225
240
|
#### Hash Operations
|
|
226
241
|
|
|
227
242
|
```typescript
|
|
228
|
-
const hash = Hash.create(
|
|
229
|
-
|
|
230
|
-
|
|
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
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
-
|
|
271
|
-
-
|
|
272
|
-
-
|
|
273
|
-
-
|
|
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
|
-
-
|
|
278
|
-
-
|
|
279
|
-
-
|
|
280
|
-
-
|
|
281
|
-
-
|
|
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
|
-
-
|
|
294
|
-
-
|
|
295
|
-
-
|
|
308
|
+
- [Documentation](./docs/)
|
|
309
|
+
- [GitHub Issues](https://github.com/Nehonix-Team/XyPriss/issues)
|
|
310
|
+
- [Security Advisories](https://github.com/Nehonix-Team/XyPriss/security)
|
|
311
|
+
|