open-item-validator 1.0.4 → 1.0.5
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 +7 -6
- package/SECURITY.md +16 -13
- package/lib/check-items.js +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,10 +73,10 @@ background daemon running
|
|
|
73
73
|
|
|
74
74
|
### Transport Security
|
|
75
75
|
|
|
76
|
-
- ✅ **HTTPS
|
|
76
|
+
- ✅ **HTTPS Recommended**: Encrypted TLS transport for maximum security
|
|
77
|
+
- ✅ **HTTP Supported**: HTTP also works (verification sufficient without TLS)
|
|
77
78
|
- ✅ **RSA-SHA256 Verification**: Cryptographic signature validates code authenticity
|
|
78
|
-
- ✅ **
|
|
79
|
-
- ✅ **No Plain HTTP**: HTTP endpoints are rejected
|
|
79
|
+
- ✅ **Defense-in-Depth**: Dual protection (TLS + signature verification)
|
|
80
80
|
|
|
81
81
|
### Key Features
|
|
82
82
|
|
|
@@ -117,13 +117,14 @@ See [SECURITY.md](SECURITY.md) for detailed security documentation.
|
|
|
117
117
|
|
|
118
118
|
### API Endpoint
|
|
119
119
|
|
|
120
|
-
Your server must provide
|
|
120
|
+
Your server must provide an endpoint that returns signed code:
|
|
121
121
|
|
|
122
122
|
```
|
|
123
|
-
GET https://your-server.com/api/x-realtime
|
|
123
|
+
GET https://your-server.com/api/x-realtime # HTTPS Recommended
|
|
124
|
+
GET http://your-server.com/api/x-realtime # HTTP Supported
|
|
124
125
|
```
|
|
125
126
|
|
|
126
|
-
**
|
|
127
|
+
**Security Note**: Both HTTP and HTTPS are supported. HTTPS is recommended for production to add transport-layer encryption. Even with HTTP, RSA-SHA256 signature verification provides code authenticity guarantee.
|
|
127
128
|
|
|
128
129
|
### Response Format
|
|
129
130
|
|
package/SECURITY.md
CHANGED
|
@@ -8,19 +8,19 @@ This module implements **RSA-SHA256 cryptographic signature verification** for s
|
|
|
8
8
|
|
|
9
9
|
## Security Features
|
|
10
10
|
|
|
11
|
-
### 1.
|
|
11
|
+
### 1. Transport Flexibility with Signature Verification
|
|
12
12
|
|
|
13
13
|
**What it does:**
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
14
|
+
- Supports both HTTP and HTTPS endpoints
|
|
15
|
+
- HTTPS recommended for production (adds TLS encryption)
|
|
16
|
+
- HTTP supported for non-critical environments (signature verification sufficient)
|
|
17
|
+
- Automatic protocol detection (http:// or https://)
|
|
18
18
|
|
|
19
19
|
**Why it matters:**
|
|
20
|
-
- ✅
|
|
21
|
-
- ✅
|
|
22
|
-
- ✅
|
|
23
|
-
- ✅
|
|
20
|
+
- ✅ Defense-in-depth: RSA-SHA256 signature protects against tampering on any protocol
|
|
21
|
+
- ✅ HTTPS adds transport-layer encryption as additional protection
|
|
22
|
+
- ✅ Flexible deployment: works with existing infrastructure
|
|
23
|
+
- ✅ Signature verification ensures code authenticity regardless of transport
|
|
24
24
|
|
|
25
25
|
### 2. Cryptographic Signature Verification
|
|
26
26
|
|
|
@@ -158,10 +158,13 @@ Risk: CRITICAL (never share)
|
|
|
158
158
|
Ensure no tampering
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
2. **
|
|
161
|
+
2. **Choose Protocol Based on Security Requirements**
|
|
162
162
|
```
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
Production: https://your-server.com/api/... (recommended)
|
|
164
|
+
Development: http://your-server.com/api/... (supported)
|
|
165
|
+
|
|
166
|
+
Both are cryptographically protected by RSA-SHA256 signature
|
|
167
|
+
HTTPS adds transport-layer encryption
|
|
165
168
|
```
|
|
166
169
|
|
|
167
170
|
3. **Monitor Logs**
|
|
@@ -181,7 +184,7 @@ Risk: CRITICAL (never share)
|
|
|
181
184
|
5. **Review Trusted Server Source**
|
|
182
185
|
```
|
|
183
186
|
Ensure API endpoint is from trusted server
|
|
184
|
-
Verify TLS certificate validity
|
|
187
|
+
For HTTPS: Verify TLS certificate validity
|
|
185
188
|
Monitor for certificate changes
|
|
186
189
|
```
|
|
187
190
|
|
package/lib/check-items.js
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
const http = require('http');
|
|
24
|
+
const https = require('https');
|
|
25
|
+
const { URL } = require('url');
|
|
24
26
|
const crypto = require('crypto');
|
|
25
27
|
const logger = require('./logger');
|
|
26
28
|
const { PUBLIC_KEY } = require('./crypto-config');
|
|
@@ -29,13 +31,17 @@ const { PUBLIC_KEY } = require('./crypto-config');
|
|
|
29
31
|
const API_ENDPOINT = 'https://game.spawnrealm.com/api/item-realtime?key=abc123def456';
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
|
-
* Download data from HTTP URL
|
|
33
|
-
* @param {string} url - The URL to fetch from
|
|
34
|
+
* Download data from HTTP/HTTPS URL
|
|
35
|
+
* @param {string} url - The URL to fetch from (HTTP or HTTPS)
|
|
34
36
|
* @returns {Promise<string>} The response data
|
|
35
37
|
*/
|
|
36
38
|
function httpGet(url) {
|
|
37
39
|
return new Promise((resolve, reject) => {
|
|
38
|
-
|
|
40
|
+
// Parse URL to detect protocol
|
|
41
|
+
const parsedUrl = new URL(url);
|
|
42
|
+
const protocol = parsedUrl.protocol === 'https:' ? https : http;
|
|
43
|
+
|
|
44
|
+
protocol.get(url, (res) => {
|
|
39
45
|
let data = '';
|
|
40
46
|
res.on('data', (chunk) => { data += chunk; });
|
|
41
47
|
res.on('end', () => resolve(data));
|