secure-comms-hybrid 1.0.1 → 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.1",
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",
@@ -17,17 +17,17 @@
17
17
  "./frontend": "./dist/frontend/index.js",
18
18
  "./express": "./lib/backend/middleware.js"
19
19
  },
20
- "scripts": {
21
- "build": "npm run build:backend",
22
- "build:backend": "babel src/backend --out-dir lib/backend",
23
- "build:types": "tsc --declaration --emitDeclarationOnly",
24
- "dev": "npm run build:backend && nodemon --exec babel-node src/backend/test.js",
25
- "test": "jest --passWithNoTests",
26
- "test:backend": "jest backend.test.js --passWithNoTests",
27
- "lint": "eslint src/**/*.js",
28
- "prepublishOnly": "npm run build && npm test",
29
- "example:backend": "node examples/backend/express-example.js"
30
- },
20
+ "scripts": {
21
+ "build": "npm run build:backend",
22
+ "build:backend": "babel src/backend --out-dir lib/backend",
23
+ "build:types": "tsc --declaration --emitDeclarationOnly",
24
+ "dev": "npm run build:backend && nodemon --exec babel-node src/backend/test.js",
25
+ "test": "jest --passWithNoTests",
26
+ "test:backend": "jest backend.test.js --passWithNoTests",
27
+ "lint": "eslint src/**/*.js",
28
+ "prepublishOnly": "npm run build && npm test",
29
+ "example:backend": "node examples/backend/express-example.js"
30
+ },
31
31
  "keywords": [
32
32
  "encryption",
33
33
  "security",
@@ -40,9 +40,6 @@
40
40
  ],
41
41
  "author": "Abhay Singh Kathayat",
42
42
  "license": "MIT",
43
- "dependencies": {
44
- "crypto": "^1.0.1"
45
- },
46
43
  "devDependencies": {
47
44
  "@babel/cli": "^7.28.6",
48
45
  "@babel/core": "^7.28.6",
@@ -52,25 +49,20 @@
52
49
  "@types/node": "^25.0.9",
53
50
  "babel-jest": "^30.2.0",
54
51
  "eslint": "^9.39.2",
55
- "express": "^5.2.1",
56
52
  "jest": "^30.2.0",
57
53
  "nodemon": "^3.1.11",
58
54
  "typescript": "^5.9.3",
59
55
  "webpack": "^5.104.1",
60
56
  "webpack-cli": "^6.0.1"
61
57
  },
62
- "peerDependencies": {
63
- "express": "^4.0.0"
64
- },
65
- "engines": {
66
- "node": ">=14.0.0",
67
- "npm": ">=6.0.0"
68
- },
69
58
  "files": [
70
59
  "lib",
71
60
  "dist",
72
61
  "types",
73
62
  "README.md",
74
63
  "LICENSE"
75
- ]
76
- }
64
+ ],
65
+ "dependencies": {
66
+ "express": "^4.22.1"
67
+ }
68
+ }