@devshub198211/devguard 2.0.2 → 2.0.3

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.
@@ -1,114 +0,0 @@
1
- interface LockfileEntry {
2
- file: string;
3
- hash: string;
4
- size: number;
5
- mtime: number;
6
- }
7
- interface LockfileReport {
8
- valid: boolean;
9
- tampered: string[];
10
- missing: string[];
11
- added: string[];
12
- entries: LockfileEntry[];
13
- scannedAt: string;
14
- }
15
- interface LockfileSnapshot {
16
- version: 2;
17
- createdAt: string;
18
- host: string;
19
- entries: Record<string, {
20
- hash: string;
21
- size: number;
22
- }>;
23
- }
24
- declare function hashFile(filePath: string): string;
25
- declare function verifyLockfile(root?: string, snapshotPath?: string): LockfileReport;
26
- declare function createSnapshot(root?: string, snapshotPath?: string): LockfileSnapshot;
27
- /** Parse package-lock.json and extract all transitive dependency versions */
28
- declare function extractTransitiveDeps(root?: string): Record<string, string>;
29
-
30
- interface ScanRule {
31
- id: string;
32
- label: string;
33
- severity: "critical" | "high" | "medium" | "low";
34
- test: (script: string, decoded?: string) => boolean;
35
- }
36
- interface HookFinding {
37
- package: string;
38
- version: string;
39
- script: string;
40
- ruleId: string;
41
- pattern: string;
42
- severity: "critical" | "high" | "medium" | "low";
43
- raw: string;
44
- deobfuscated?: string;
45
- }
46
- declare function scanPackage(pkgJsonPath: string): HookFinding[];
47
- declare function scanNodeModules(root?: string): HookFinding[];
48
- declare function scanProject(root?: string): HookFinding[];
49
-
50
- interface TokenConfig {
51
- name: string;
52
- value: string;
53
- provider: "github" | "npm" | "generic";
54
- maxAgeDays?: number;
55
- createdAt?: number;
56
- }
57
- interface TokenStatus {
58
- name: string;
59
- provider: string;
60
- status: "ok" | "expiring_soon" | "stale" | "invalid" | "unknown";
61
- ageDays: number | null;
62
- maxAgeDays: number;
63
- message: string;
64
- }
65
- interface RotationResult {
66
- success: boolean;
67
- newToken?: string;
68
- error?: string;
69
- }
70
- declare function inspectGitHubToken(token: string, name?: string): Promise<TokenStatus>;
71
- declare function inspectNpmToken(token: string, name?: string): Promise<TokenStatus>;
72
- /**
73
- * Create a new npm token using an existing token.
74
- * WARNING: This uses the existing token for authentication. The caller should
75
- * revoke the old token after successful rotation.
76
- */
77
- declare function createNpmToken(existingToken: string, opts?: {
78
- readonly?: boolean;
79
- cidr?: string[];
80
- }): Promise<RotationResult>;
81
- declare function checkTokenAge(configs: TokenConfig[]): TokenStatus[];
82
- declare function maskToken(token: string): string;
83
- declare function loadTokensFromEnv(names: string[], maxAgeDays?: number): TokenConfig[];
84
-
85
- interface PinViolation {
86
- name: string;
87
- specifier: string;
88
- field: "dependencies" | "devDependencies" | "peerDependencies" | "optionalDependencies";
89
- suggestion: string;
90
- }
91
- interface SRICheck {
92
- name: string;
93
- version: string;
94
- lockfileHash: string;
95
- registryHash: string | null;
96
- match: boolean | null;
97
- }
98
- declare function enforceExactPins(pkgJsonPath: string): PinViolation[];
99
- declare function extractLockfileSRI(root?: string): Record<string, {
100
- version: string;
101
- integrity: string;
102
- }>;
103
- declare function fetchRegistrySRI(name: string, version: string): Promise<string | null>;
104
- /**
105
- * Deterministic alphabetical sampling instead of Math.random().
106
- * Samples the first N packages alphabetically — reproducible across runs.
107
- */
108
- declare function verifySRI(root?: string, sampleSize?: number): Promise<SRICheck[]>;
109
- declare function autoPin(pkgJsonPath: string, dryRun?: boolean): {
110
- fixed: number;
111
- content?: string;
112
- };
113
-
114
- export { type HookFinding, type LockfileEntry, type LockfileReport, type LockfileSnapshot, type PinViolation, type RotationResult, type SRICheck, type ScanRule, type TokenConfig, type TokenStatus, autoPin, checkTokenAge, createNpmToken, createSnapshot, enforceExactPins, extractLockfileSRI, extractTransitiveDeps, fetchRegistrySRI, hashFile, inspectGitHubToken, inspectNpmToken, loadTokensFromEnv, maskToken, scanNodeModules, scanPackage, scanProject, verifyLockfile, verifySRI };