secure-comms-hybrid 1.0.3 → 1.0.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.
@@ -2,7 +2,7 @@ const crypto = require('crypto');
2
2
  const {
3
3
  CRYPTO_CONFIG,
4
4
  ERRORS
5
- } = require('../shared/constants');
5
+ } = require('./constants');
6
6
  class HybridCrypto {
7
7
  constructor(options = {}) {
8
8
  this.options = {
@@ -0,0 +1,40 @@
1
+ export const CRYPTO_CONFIG = {
2
+ RSA: {
3
+ MODULUS_LENGTH: 2048,
4
+ PUBLIC_KEY_ENCODING: {
5
+ type: 'spki',
6
+ format: 'pem'
7
+ },
8
+ PRIVATE_KEY_ENCODING: {
9
+ type: 'pkcs8',
10
+ format: 'pem'
11
+ },
12
+ PADDING: 'RSA_PKCS1_OAEP_PADDING',
13
+ HASH: 'SHA-256'
14
+ },
15
+ AES: {
16
+ ALGORITHM: 'AES-GCM',
17
+ KEY_LENGTH: 256,
18
+ IV_LENGTH: 12,
19
+ TAG_LENGTH: 128
20
+ },
21
+ SESSION: {
22
+ EXPIRY_MS: 5 * 60 * 1000,
23
+ // 5 minutes
24
+ CLEANUP_INTERVAL: 60 * 1000 // 1 minute
25
+ },
26
+ HEADERS: {
27
+ ENCRYPTED: 'X-Encrypted',
28
+ CLIENT_ID: 'X-Client-ID',
29
+ ENCRYPTION_ALGORITHM: 'X-Encryption-Algorithm',
30
+ SESSION_EXPIRY: 'X-Session-Expiry'
31
+ }
32
+ };
33
+ export const ERRORS = {
34
+ NOT_INITIALIZED: 'Encryption not initialized',
35
+ SESSION_EXPIRED: 'Session expired',
36
+ DECRYPTION_FAILED: 'Decryption failed',
37
+ ENCRYPTION_FAILED: 'Encryption failed',
38
+ INVALID_REQUEST: 'Invalid encrypted request',
39
+ MISSING_CLIENT_ID: 'Missing client ID'
40
+ };
@@ -1,7 +1,7 @@
1
1
  const {
2
2
  CRYPTO_CONFIG,
3
3
  ERRORS
4
- } = require('../shared/constants');
4
+ } = require('./constants');
5
5
  function createEncryptionMiddleware(hybridCrypto, options = {}) {
6
6
  const {
7
7
  excludedPaths = ['/health', '/'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "secure-comms-hybrid",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Hybrid encryption (RSA + AES) for secure client-server communications",
5
5
  "main": "lib/backend/index.js",
6
6
  "browser": "dist/frontend/index.js",