signal-codec 1.0.0
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/LICENSE +21 -0
- package/README.md +289 -0
- package/dist/checker.d.ts +30 -0
- package/dist/checker.js +69 -0
- package/dist/checker.test.d.ts +1 -0
- package/dist/checker.test.js +85 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +26 -0
- package/dist/codec-verifier.d.ts +30 -0
- package/dist/codec-verifier.js +69 -0
- package/dist/codec-verifier.test.d.ts +1 -0
- package/dist/codec-verifier.test.js +85 -0
- package/dist/fragment-scanner.d.ts +39 -0
- package/dist/fragment-scanner.js +150 -0
- package/dist/fragment-scanner.test.d.ts +1 -0
- package/dist/fragment-scanner.test.js +55 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +110 -0
- package/dist/matrix.d.ts +35 -0
- package/dist/matrix.js +80 -0
- package/dist/matrix.test.d.ts +1 -0
- package/dist/matrix.test.js +68 -0
- package/dist/protocol-reporter.d.ts +34 -0
- package/dist/protocol-reporter.js +107 -0
- package/dist/protocol-reporter.test.d.ts +1 -0
- package/dist/protocol-reporter.test.js +82 -0
- package/dist/reporter.d.ts +34 -0
- package/dist/reporter.js +104 -0
- package/dist/reporter.test.d.ts +1 -0
- package/dist/reporter.test.js +82 -0
- package/dist/scanner.d.ts +39 -0
- package/dist/scanner.js +150 -0
- package/dist/scanner.test.d.ts +1 -0
- package/dist/scanner.test.js +55 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 License Guard Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# signal-codec
|
|
2
|
+
|
|
3
|
+
> Verify transmission protocol compatibility across signal fragments
|
|
4
|
+
|
|
5
|
+
**Part of the [Amulet Digital](https://github.com/apassanisi) Signal Archives**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/signal-codec)
|
|
8
|
+
[](https://www.npmjs.com/package/signal-codec)
|
|
9
|
+
[](https://www.npmjs.com/package/signal-codec)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
|
|
12
|
+
A minimal, fast protocol that scans your archival node and verifies that all signal fragments use compatible transmission codecs (licenses). Identifies codec conflicts, unverified protocols, and viral encoding that could corrupt the archive.
|
|
13
|
+
|
|
14
|
+
## Overview
|
|
15
|
+
|
|
16
|
+
In the Signal Archives, every signal fragment is transmitted using a specific **codec** (license) that defines how it can be decoded, modified, and retransmitted.
|
|
17
|
+
|
|
18
|
+
When fragments with incompatible codecs interact, transmission fails or becomes corrupted. `signal-codec` verifies codec interoperability across your entire archival node.
|
|
19
|
+
|
|
20
|
+
### Codec Types
|
|
21
|
+
|
|
22
|
+
**Open Codecs** (Permissive)
|
|
23
|
+
- MIT, Apache-2.0, BSD-3-Clause, ISC
|
|
24
|
+
- Universal interoperability
|
|
25
|
+
- Can be freely retransmitted
|
|
26
|
+
|
|
27
|
+
**Viral Codecs** (Copyleft)
|
|
28
|
+
- GPL-2.0, GPL-3.0, AGPL-3.0
|
|
29
|
+
- Force all connected fragments to adopt same encoding
|
|
30
|
+
- Override other codec standards
|
|
31
|
+
|
|
32
|
+
**Encrypted Codecs** (Restricted)
|
|
33
|
+
- UNLICENSED, PROPRIETARY
|
|
34
|
+
- Unknown compatibility
|
|
35
|
+
- Verification impossible
|
|
36
|
+
|
|
37
|
+
**Multi-Codec Fragments** (Dual-licensed)
|
|
38
|
+
- "MIT OR Apache-2.0"
|
|
39
|
+
- Adapt to compatible codec
|
|
40
|
+
- Flexible transmission
|
|
41
|
+
|
|
42
|
+
## Features
|
|
43
|
+
|
|
44
|
+
- **Fragment scanning** - recursively analyzes all installed fragments
|
|
45
|
+
- **Codec verification** - validates transmission protocol compatibility
|
|
46
|
+
- **Viral codec detection** - flags GPL/AGPL fragments for review
|
|
47
|
+
- **Multi-codec support** - handles "MIT OR Apache-2.0" style encoding
|
|
48
|
+
- **Fast** - analyzes hundreds of fragments in seconds
|
|
49
|
+
- **Beautiful output** - formatted tables with color-coded conflicts
|
|
50
|
+
- **JSON export** - machine-readable output with `--json` flag
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install -g signal-codec
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or run directly:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx signal-codec
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
### Analyze current archive
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
signal-codec
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Analyze specific archive
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
signal-codec /path/to/archive
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Detailed analysis
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
signal-codec --detailed
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### JSON output
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
signal-codec --json
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Example Output
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
◆ SIGNAL-CODEC — Transmission Protocol Analysis
|
|
94
|
+
────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
Archive Codec: MIT
|
|
97
|
+
Fragments Analyzed: 245
|
|
98
|
+
Codec Conflicts: 2
|
|
99
|
+
|
|
100
|
+
⚠ 2 transmission protocol conflicts detected
|
|
101
|
+
|
|
102
|
+
────────────────────────────────────────────
|
|
103
|
+
Codec Conflicts
|
|
104
|
+
────────────────────────────────────────────
|
|
105
|
+
|
|
106
|
+
Fragment Codec Conflict
|
|
107
|
+
────────────────────────────────────────────────────────
|
|
108
|
+
gpl-package GPL-3.0 [error] Viral codec incompatible with MIT
|
|
109
|
+
internal-tool ENCRYPTED [warning] Codec verification failed
|
|
110
|
+
|
|
111
|
+
✗ 1 incompatible codec
|
|
112
|
+
⚠ 1 unverified codec
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Configuration
|
|
116
|
+
|
|
117
|
+
Create a `signal-codec.config.json` in your archive root:
|
|
118
|
+
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"ignoreFragments": ["internal-package"],
|
|
122
|
+
"allowViralCodecs": ["GPL-2.0"],
|
|
123
|
+
"treatEncryptedAs": "warning"
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Codec Interoperability Matrix
|
|
128
|
+
|
|
129
|
+
The tool includes a default interoperability matrix that handles common codec scenarios:
|
|
130
|
+
|
|
131
|
+
### Open Codecs (Universal)
|
|
132
|
+
- **MIT**: Interoperable with MIT, Apache-2.0, BSD-3-Clause, ISC, BSD-2-Clause, MPL-2.0
|
|
133
|
+
- **Apache-2.0**: Interoperable with MIT, Apache-2.0, BSD-3-Clause, ISC
|
|
134
|
+
- **BSD-3-Clause**: Interoperable with MIT, Apache-2.0, BSD-3-Clause, ISC, BSD-2-Clause
|
|
135
|
+
- **ISC**: Interoperable with most open codecs
|
|
136
|
+
|
|
137
|
+
### Viral Codecs (Override)
|
|
138
|
+
- **GPL-2.0**: Only interoperable with GPL-2.0, AGPL-2.0 (forces adoption)
|
|
139
|
+
- **GPL-3.0**: Only interoperable with GPL-3.0, AGPL-3.0 (forces adoption)
|
|
140
|
+
- **AGPL-3.0**: Most restrictive viral codec (network transmission clause)
|
|
141
|
+
|
|
142
|
+
### Special Cases
|
|
143
|
+
- **ENCRYPTED**: Flags as warning - verification required
|
|
144
|
+
- **PROPRIETARY**: Flags as warning - manual review required
|
|
145
|
+
- **Multi-codec (MIT OR Apache)**: Interoperable if any codec matches
|
|
146
|
+
|
|
147
|
+
## How It Works
|
|
148
|
+
|
|
149
|
+
1. Reads archive manifest (`package.json`) to determine archive codec
|
|
150
|
+
2. Scans installed fragments to catalog transmission protocols
|
|
151
|
+
3. Checks each fragment's codec against interoperability matrix
|
|
152
|
+
4. Reports conflicts grouped by severity (error, warning, info)
|
|
153
|
+
5. Returns exit code (0 for verified, 1 for conflicts)
|
|
154
|
+
|
|
155
|
+
## Common Conflicts
|
|
156
|
+
|
|
157
|
+
### "Viral codec incompatible"
|
|
158
|
+
Viral codecs (GPL/AGPL) force all connected fragments to adopt the same encoding:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
# Fragment pathway
|
|
162
|
+
your-archive (MIT)
|
|
163
|
+
└─ some-package
|
|
164
|
+
└─ gpl-library (GPL-3.0) ⚠️
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Resolution:**
|
|
168
|
+
- Find open codec alternative
|
|
169
|
+
- Check for dual-codec release
|
|
170
|
+
- Isolate in development-only pathway
|
|
171
|
+
- Adopt GPL-3.0 for entire archive
|
|
172
|
+
|
|
173
|
+
### "Codec verification failed"
|
|
174
|
+
Some fragments don't document their transmission protocol:
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
cd node_modules/fragment-name && cat LICENSE
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### "Fragments not found"
|
|
181
|
+
Run `npm install` first to install signal fragments.
|
|
182
|
+
|
|
183
|
+
## API Usage
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { CodecGuard } from 'signal-codec';
|
|
187
|
+
|
|
188
|
+
const guard = new CodecGuard();
|
|
189
|
+
await guard.verify('./my-archive', { verbose: true });
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Field Notes
|
|
193
|
+
|
|
194
|
+
Transmission protocol compatibility is essential for archival integrity. When fragments with incompatible codecs interact, the transmission either fails or corrupts surrounding signals.
|
|
195
|
+
|
|
196
|
+
Viral codecs (GPL/AGPL) are particularly challenging - they override all surrounding encoding standards, forcing the entire transmission pathway to adopt the same protocol. This is intentional: viral codecs ensure derivative transmissions remain open and verifiable.
|
|
197
|
+
|
|
198
|
+
Encrypted codecs (proprietary/unlicensed) present unknown risk. Without documented transmission protocols, codec verification is impossible. These fragments should be reviewed manually before integration.
|
|
199
|
+
|
|
200
|
+
Multi-codec fragments offer flexibility - they can adapt their encoding to match the surrounding transmission environment. When possible, prefer fragments that support multiple interoperable codecs.
|
|
201
|
+
|
|
202
|
+
## Supported Codecs
|
|
203
|
+
|
|
204
|
+
`signal-codec` includes transmission protocol verification for:
|
|
205
|
+
|
|
206
|
+
**Open Codecs:**
|
|
207
|
+
- MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC
|
|
208
|
+
- 0BSD, Unlicense, WTFPL
|
|
209
|
+
- MPL-2.0, LGPL-2.1, LGPL-3.0
|
|
210
|
+
|
|
211
|
+
**Viral Codecs:**
|
|
212
|
+
- GPL-2.0, GPL-3.0
|
|
213
|
+
- AGPL-2.0, AGPL-3.0
|
|
214
|
+
|
|
215
|
+
**Encrypted Codecs:**
|
|
216
|
+
- UNLICENSED, PROPRIETARY
|
|
217
|
+
- Custom/Unknown codecs
|
|
218
|
+
|
|
219
|
+
**Multi-Codec:**
|
|
220
|
+
- Any SPDX expression (e.g., "MIT OR Apache-2.0")
|
|
221
|
+
|
|
222
|
+
For unknown codecs, `signal-codec` flags them for manual verification.
|
|
223
|
+
|
|
224
|
+
## Troubleshooting
|
|
225
|
+
|
|
226
|
+
### "Failed to analyze archive"
|
|
227
|
+
|
|
228
|
+
Ensure you're in an archival node with a manifest (package.json):
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npm init
|
|
232
|
+
npm install signal-codec
|
|
233
|
+
signal-codec
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### "Viral codec detected"
|
|
237
|
+
|
|
238
|
+
Viral codecs (GPL/AGPL) force codec adoption. Options:
|
|
239
|
+
|
|
240
|
+
1. Replace with open codec alternative
|
|
241
|
+
2. Adopt viral codec for entire archive
|
|
242
|
+
3. Isolate fragment in development pathway
|
|
243
|
+
4. Check for dual-codec availability
|
|
244
|
+
|
|
245
|
+
### "Codec verification failed"
|
|
246
|
+
|
|
247
|
+
Some fragments don't document codecs. Options:
|
|
248
|
+
|
|
249
|
+
1. Review fragment source for protocol info
|
|
250
|
+
2. Contact fragment maintainer
|
|
251
|
+
3. Assume open codec (risk)
|
|
252
|
+
4. Remove fragment if incompatible
|
|
253
|
+
|
|
254
|
+
## Migration from spdx-checker
|
|
255
|
+
|
|
256
|
+
`signal-codec` is the rebranded version of `spdx-checker`, now part of the Amulet Digital Signal Archives.
|
|
257
|
+
|
|
258
|
+
**To migrate:**
|
|
259
|
+
```bash
|
|
260
|
+
npm uninstall -g spdx-checker
|
|
261
|
+
npm install -g signal-codec
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
All functionality is preserved. CLI commands are compatible.
|
|
265
|
+
|
|
266
|
+
## Contributing
|
|
267
|
+
|
|
268
|
+
We welcome contributions to the Signal Archives! See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
269
|
+
|
|
270
|
+
## License
|
|
271
|
+
|
|
272
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
273
|
+
|
|
274
|
+
## Support
|
|
275
|
+
|
|
276
|
+
- 🐛 [Report codec conflicts](https://github.com/apassanisi/signal-codec/issues)
|
|
277
|
+
- 💬 [Network discussions](https://github.com/apassanisi/signal-codec/discussions)
|
|
278
|
+
- 📚 [Archive documentation](https://github.com/apassanisi/signal-codec#readme)
|
|
279
|
+
|
|
280
|
+
## Related Archival Tools
|
|
281
|
+
|
|
282
|
+
- [void-purge](https://github.com/apassanisi/void-purge) — Remove orphaned artifacts
|
|
283
|
+
- [signal-decay](https://github.com/apassanisi/signal-decay) — Detect signal corruption
|
|
284
|
+
- [PixelFactory](https://github.com/apassanisi/PixelFactory) — The Initiate's Lens
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
*Signal integrity maintained by Amulet Digital*
|
|
289
|
+
*Archive Protocol • Node: signal-codec • Version: 1.0.0*
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DependencyInfo } from './scanner';
|
|
2
|
+
export interface CompatibilityIssue {
|
|
3
|
+
package: string;
|
|
4
|
+
license: string;
|
|
5
|
+
severity: 'error' | 'warning' | 'info';
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckResult {
|
|
9
|
+
projectLicense: string;
|
|
10
|
+
totalDependencies: number;
|
|
11
|
+
issues: CompatibilityIssue[];
|
|
12
|
+
summary: {
|
|
13
|
+
errors: number;
|
|
14
|
+
warnings: number;
|
|
15
|
+
info: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Checker for license compatibility issues
|
|
20
|
+
*/
|
|
21
|
+
export declare class Checker {
|
|
22
|
+
/**
|
|
23
|
+
* Check all dependencies for compatibility issues
|
|
24
|
+
*/
|
|
25
|
+
check(dependencies: DependencyInfo[], projectLicense: string): CheckResult;
|
|
26
|
+
/**
|
|
27
|
+
* Check a single dependency for issues
|
|
28
|
+
*/
|
|
29
|
+
private checkDependency;
|
|
30
|
+
}
|
package/dist/checker.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Checker = void 0;
|
|
4
|
+
const matrix_1 = require("./matrix");
|
|
5
|
+
/**
|
|
6
|
+
* Checker for license compatibility issues
|
|
7
|
+
*/
|
|
8
|
+
class Checker {
|
|
9
|
+
/**
|
|
10
|
+
* Check all dependencies for compatibility issues
|
|
11
|
+
*/
|
|
12
|
+
check(dependencies, projectLicense) {
|
|
13
|
+
const issues = [];
|
|
14
|
+
for (const dep of dependencies) {
|
|
15
|
+
const depIssues = this.checkDependency(dep, projectLicense);
|
|
16
|
+
issues.push(...depIssues);
|
|
17
|
+
}
|
|
18
|
+
const result = {
|
|
19
|
+
projectLicense,
|
|
20
|
+
totalDependencies: dependencies.length,
|
|
21
|
+
issues,
|
|
22
|
+
summary: {
|
|
23
|
+
errors: issues.filter((i) => i.severity === 'error').length,
|
|
24
|
+
warnings: issues.filter((i) => i.severity === 'warning').length,
|
|
25
|
+
info: issues.filter((i) => i.severity === 'info').length,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check a single dependency for issues
|
|
32
|
+
*/
|
|
33
|
+
checkDependency(dep, projectLicense) {
|
|
34
|
+
const issues = [];
|
|
35
|
+
// Check for missing license
|
|
36
|
+
if (matrix_1.MISSING_LICENSE_PATTERNS.has(dep.license)) {
|
|
37
|
+
issues.push({
|
|
38
|
+
package: dep.name,
|
|
39
|
+
license: dep.license,
|
|
40
|
+
severity: 'warning',
|
|
41
|
+
message: `No license specified`,
|
|
42
|
+
});
|
|
43
|
+
return issues;
|
|
44
|
+
}
|
|
45
|
+
// Check for high-risk licenses
|
|
46
|
+
const licenses = (0, matrix_1.parseSpdxExpression)(dep.license);
|
|
47
|
+
for (const license of licenses) {
|
|
48
|
+
if (matrix_1.HIGH_RISK_LICENSES.has(license)) {
|
|
49
|
+
issues.push({
|
|
50
|
+
package: dep.name,
|
|
51
|
+
license: dep.license,
|
|
52
|
+
severity: 'warning',
|
|
53
|
+
message: `${license} license detected - review for compatibility`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Check compatibility with project license
|
|
58
|
+
if (!(0, matrix_1.isCompatible)(projectLicense, dep.license)) {
|
|
59
|
+
issues.push({
|
|
60
|
+
package: dep.name,
|
|
61
|
+
license: dep.license,
|
|
62
|
+
severity: 'error',
|
|
63
|
+
message: `${dep.license} is not compatible with ${projectLicense}`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return issues;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Checker = Checker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const checker_1 = require("./checker");
|
|
4
|
+
describe('Checker', () => {
|
|
5
|
+
let checker;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
checker = new checker_1.Checker();
|
|
8
|
+
});
|
|
9
|
+
describe('check', () => {
|
|
10
|
+
it('should return no issues for compatible licenses', () => {
|
|
11
|
+
const deps = [
|
|
12
|
+
{
|
|
13
|
+
name: 'some-lib',
|
|
14
|
+
version: '1.0.0',
|
|
15
|
+
license: 'MIT',
|
|
16
|
+
location: '/path/to/lib',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'another-lib',
|
|
20
|
+
version: '2.0.0',
|
|
21
|
+
license: 'Apache-2.0',
|
|
22
|
+
location: '/path/to/lib',
|
|
23
|
+
},
|
|
24
|
+
];
|
|
25
|
+
const result = checker.check(deps, 'MIT');
|
|
26
|
+
expect(result.issues).toHaveLength(0);
|
|
27
|
+
expect(result.summary.errors).toBe(0);
|
|
28
|
+
});
|
|
29
|
+
it('should flag incompatible licenses', () => {
|
|
30
|
+
const deps = [
|
|
31
|
+
{
|
|
32
|
+
name: 'gpl-lib',
|
|
33
|
+
version: '1.0.0',
|
|
34
|
+
license: 'GPL-3.0',
|
|
35
|
+
location: '/path/to/lib',
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
const result = checker.check(deps, 'MIT');
|
|
39
|
+
expect(result.issues.length).toBeGreaterThan(0);
|
|
40
|
+
expect(result.summary.errors).toBeGreaterThan(0);
|
|
41
|
+
});
|
|
42
|
+
it('should flag missing licenses', () => {
|
|
43
|
+
const deps = [
|
|
44
|
+
{
|
|
45
|
+
name: 'no-license-lib',
|
|
46
|
+
version: '1.0.0',
|
|
47
|
+
license: 'UNLICENSED',
|
|
48
|
+
location: '/path/to/lib',
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
const result = checker.check(deps, 'MIT');
|
|
52
|
+
expect(result.issues.length).toBeGreaterThan(0);
|
|
53
|
+
});
|
|
54
|
+
it('should flag high-risk licenses', () => {
|
|
55
|
+
const deps = [
|
|
56
|
+
{
|
|
57
|
+
name: 'gpl-lib',
|
|
58
|
+
version: '1.0.0',
|
|
59
|
+
license: 'GPL-3.0',
|
|
60
|
+
location: '/path/to/lib',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
const result = checker.check(deps, 'GPL-3.0');
|
|
64
|
+
expect(result.issues.length).toBeGreaterThan(0);
|
|
65
|
+
});
|
|
66
|
+
it('should include total dependency count', () => {
|
|
67
|
+
const deps = [
|
|
68
|
+
{
|
|
69
|
+
name: 'lib1',
|
|
70
|
+
version: '1.0.0',
|
|
71
|
+
license: 'MIT',
|
|
72
|
+
location: '/path',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'lib2',
|
|
76
|
+
version: '1.0.0',
|
|
77
|
+
license: 'MIT',
|
|
78
|
+
location: '/path',
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
const result = checker.check(deps, 'MIT');
|
|
82
|
+
expect(result.totalDependencies).toBe(2);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const index_1 = require("./index");
|
|
6
|
+
commander_1.program
|
|
7
|
+
.name('signal-codec')
|
|
8
|
+
.description('Verify transmission protocol compatibility across signal fragments')
|
|
9
|
+
.version('1.0.0');
|
|
10
|
+
commander_1.program
|
|
11
|
+
.arguments('[path]')
|
|
12
|
+
.option('--verbose', 'Show verbose output')
|
|
13
|
+
.option('--json', 'Output results as JSON')
|
|
14
|
+
.action(async (dirPath, options) => {
|
|
15
|
+
try {
|
|
16
|
+
const projectRoot = dirPath || process.cwd();
|
|
17
|
+
const guard = new index_1.CodecGuard();
|
|
18
|
+
await guard.verify(projectRoot, options);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
22
|
+
console.error(`\x1b[31m✗\x1b[0m ${message}`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
commander_1.program.parse();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { DependencyInfo } from './fragment-scanner';
|
|
2
|
+
export interface CompatibilityIssue {
|
|
3
|
+
package: string;
|
|
4
|
+
license: string;
|
|
5
|
+
severity: 'error' | 'warning' | 'info';
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CheckResult {
|
|
9
|
+
projectLicense: string;
|
|
10
|
+
totalDependencies: number;
|
|
11
|
+
issues: CompatibilityIssue[];
|
|
12
|
+
summary: {
|
|
13
|
+
errors: number;
|
|
14
|
+
warnings: number;
|
|
15
|
+
info: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Checker for license compatibility issues
|
|
20
|
+
*/
|
|
21
|
+
export declare class Checker {
|
|
22
|
+
/**
|
|
23
|
+
* Check all dependencies for compatibility issues
|
|
24
|
+
*/
|
|
25
|
+
check(dependencies: DependencyInfo[], projectLicense: string): CheckResult;
|
|
26
|
+
/**
|
|
27
|
+
* Check a single dependency for issues
|
|
28
|
+
*/
|
|
29
|
+
private checkDependency;
|
|
30
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Checker = void 0;
|
|
4
|
+
const matrix_1 = require("./matrix");
|
|
5
|
+
/**
|
|
6
|
+
* Checker for license compatibility issues
|
|
7
|
+
*/
|
|
8
|
+
class Checker {
|
|
9
|
+
/**
|
|
10
|
+
* Check all dependencies for compatibility issues
|
|
11
|
+
*/
|
|
12
|
+
check(dependencies, projectLicense) {
|
|
13
|
+
const issues = [];
|
|
14
|
+
for (const dep of dependencies) {
|
|
15
|
+
const depIssues = this.checkDependency(dep, projectLicense);
|
|
16
|
+
issues.push(...depIssues);
|
|
17
|
+
}
|
|
18
|
+
const result = {
|
|
19
|
+
projectLicense,
|
|
20
|
+
totalDependencies: dependencies.length,
|
|
21
|
+
issues,
|
|
22
|
+
summary: {
|
|
23
|
+
errors: issues.filter((i) => i.severity === 'error').length,
|
|
24
|
+
warnings: issues.filter((i) => i.severity === 'warning').length,
|
|
25
|
+
info: issues.filter((i) => i.severity === 'info').length,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check a single dependency for issues
|
|
32
|
+
*/
|
|
33
|
+
checkDependency(dep, projectLicense) {
|
|
34
|
+
const issues = [];
|
|
35
|
+
// Check for missing license
|
|
36
|
+
if (matrix_1.MISSING_LICENSE_PATTERNS.has(dep.license)) {
|
|
37
|
+
issues.push({
|
|
38
|
+
package: dep.name,
|
|
39
|
+
license: dep.license,
|
|
40
|
+
severity: 'warning',
|
|
41
|
+
message: `No license specified`,
|
|
42
|
+
});
|
|
43
|
+
return issues;
|
|
44
|
+
}
|
|
45
|
+
// Check for high-risk licenses
|
|
46
|
+
const licenses = (0, matrix_1.parseSpdxExpression)(dep.license);
|
|
47
|
+
for (const license of licenses) {
|
|
48
|
+
if (matrix_1.HIGH_RISK_LICENSES.has(license)) {
|
|
49
|
+
issues.push({
|
|
50
|
+
package: dep.name,
|
|
51
|
+
license: dep.license,
|
|
52
|
+
severity: 'warning',
|
|
53
|
+
message: `${license} license detected - review for compatibility`,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
// Check compatibility with project license
|
|
58
|
+
if (!(0, matrix_1.isCompatible)(projectLicense, dep.license)) {
|
|
59
|
+
issues.push({
|
|
60
|
+
package: dep.name,
|
|
61
|
+
license: dep.license,
|
|
62
|
+
severity: 'error',
|
|
63
|
+
message: `${dep.license} is not compatible with ${projectLicense}`,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return issues;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.Checker = Checker;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|