@attest-it/core 0.0.0 → 0.0.2
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/dist/{chunk-UWYR7JNE.js → chunk-CEE7ONNG.js} +20 -25
- package/dist/chunk-CEE7ONNG.js.map +1 -0
- package/dist/core-alpha.d.ts +33 -36
- package/dist/core-beta.d.ts +33 -36
- package/dist/core-public.d.ts +33 -36
- package/dist/core-unstripped.d.ts +33 -36
- package/dist/{crypto-ITLMIMRJ.js → crypto-VAXWUGKL.js} +3 -3
- package/dist/{crypto-ITLMIMRJ.js.map → crypto-VAXWUGKL.js.map} +1 -1
- package/dist/index.cjs +21 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -36
- package/dist/index.d.ts +36 -37
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-UWYR7JNE.js.map +0 -1
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Supported signature algorithms.
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export declare type Algorithm = 'ed25519' | 'rsa';
|
|
8
|
-
|
|
9
3
|
/**
|
|
10
4
|
* A single attestation entry.
|
|
11
5
|
* @public
|
|
@@ -64,8 +58,6 @@ export declare interface AttestItSettings {
|
|
|
64
58
|
attestationsPath: string;
|
|
65
59
|
/** Default command to execute for attestation (can be overridden per suite) */
|
|
66
60
|
defaultCommand?: string;
|
|
67
|
-
/** Cryptographic algorithm to use for signatures */
|
|
68
|
-
algorithm: 'ed25519' | 'rsa';
|
|
69
61
|
}
|
|
70
62
|
|
|
71
63
|
/**
|
|
@@ -143,24 +135,21 @@ export declare class ConfigNotFoundError extends Error {
|
|
|
143
135
|
*/
|
|
144
136
|
declare const configSchema: z.ZodObject<{
|
|
145
137
|
settings: z.ZodDefault<z.ZodObject<{
|
|
146
|
-
algorithm: z.ZodDefault<z.ZodEnum<["ed25519", "rsa"]>>;
|
|
147
138
|
attestationsPath: z.ZodDefault<z.ZodString>;
|
|
148
139
|
defaultCommand: z.ZodOptional<z.ZodString>;
|
|
149
140
|
maxAgeDays: z.ZodDefault<z.ZodNumber>;
|
|
150
141
|
publicKeyPath: z.ZodDefault<z.ZodString>;
|
|
151
|
-
}, "
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
publicKeyPath?: string | undefined;
|
|
163
|
-
}>>;
|
|
142
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
143
|
+
attestationsPath: z.ZodDefault<z.ZodString>;
|
|
144
|
+
defaultCommand: z.ZodOptional<z.ZodString>;
|
|
145
|
+
maxAgeDays: z.ZodDefault<z.ZodNumber>;
|
|
146
|
+
publicKeyPath: z.ZodDefault<z.ZodString>;
|
|
147
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
148
|
+
attestationsPath: z.ZodDefault<z.ZodString>;
|
|
149
|
+
defaultCommand: z.ZodOptional<z.ZodString>;
|
|
150
|
+
maxAgeDays: z.ZodDefault<z.ZodNumber>;
|
|
151
|
+
publicKeyPath: z.ZodDefault<z.ZodString>;
|
|
152
|
+
}, z.ZodTypeAny, "passthrough">>>;
|
|
164
153
|
suites: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
165
154
|
command: z.ZodOptional<z.ZodString>;
|
|
166
155
|
description: z.ZodOptional<z.ZodString>;
|
|
@@ -200,12 +189,11 @@ declare const configSchema: z.ZodObject<{
|
|
|
200
189
|
version: z.ZodLiteral<1>;
|
|
201
190
|
}, "strict", z.ZodTypeAny, {
|
|
202
191
|
settings: {
|
|
203
|
-
algorithm: "ed25519" | "rsa";
|
|
204
192
|
attestationsPath: string;
|
|
205
193
|
defaultCommand?: string | undefined;
|
|
206
194
|
maxAgeDays: number;
|
|
207
195
|
publicKeyPath: string;
|
|
208
|
-
};
|
|
196
|
+
} & { [k: string]: unknown };
|
|
209
197
|
suites: Record<string, {
|
|
210
198
|
command?: string | undefined;
|
|
211
199
|
description?: string | undefined;
|
|
@@ -216,13 +204,12 @@ declare const configSchema: z.ZodObject<{
|
|
|
216
204
|
}>;
|
|
217
205
|
version: 1;
|
|
218
206
|
}, {
|
|
219
|
-
settings?: {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
} | undefined;
|
|
207
|
+
settings?: undefined | z.objectInputType<{
|
|
208
|
+
attestationsPath: z.ZodDefault<z.ZodString>;
|
|
209
|
+
defaultCommand: z.ZodOptional<z.ZodString>;
|
|
210
|
+
maxAgeDays: z.ZodDefault<z.ZodNumber>;
|
|
211
|
+
publicKeyPath: z.ZodDefault<z.ZodString>;
|
|
212
|
+
}, z.ZodTypeAny, "passthrough">;
|
|
226
213
|
suites: Record<string, {
|
|
227
214
|
command?: string | undefined;
|
|
228
215
|
description?: string | undefined;
|
|
@@ -326,7 +313,11 @@ export declare interface FingerprintResult {
|
|
|
326
313
|
}
|
|
327
314
|
|
|
328
315
|
/**
|
|
329
|
-
* Generate a new keypair using OpenSSL.
|
|
316
|
+
* Generate a new RSA-2048 keypair using OpenSSL.
|
|
317
|
+
*
|
|
318
|
+
* RSA-2048 with SHA-256 is used because it's universally supported across
|
|
319
|
+
* all OpenSSL and LibreSSL versions, including older macOS systems.
|
|
320
|
+
*
|
|
330
321
|
* @param options - Generation options
|
|
331
322
|
* @returns Paths to generated keys
|
|
332
323
|
* @throws Error if OpenSSL fails or keys exist without force
|
|
@@ -353,8 +344,6 @@ export declare function getDefaultPublicKeyPath(): string;
|
|
|
353
344
|
* @public
|
|
354
345
|
*/
|
|
355
346
|
export declare interface KeygenOptions {
|
|
356
|
-
/** Algorithm to use (default: ed25519) */
|
|
357
|
-
algorithm?: Algorithm;
|
|
358
347
|
/** Path for private key (default: OS-specific config dir) */
|
|
359
348
|
privatePath?: string;
|
|
360
349
|
/** Path for public key (default: repo root) */
|
|
@@ -490,7 +479,11 @@ export declare function listPackageFiles(packages: string[], ignore?: string[],
|
|
|
490
479
|
export declare function setKeyPermissions(keyPath: string): Promise<void>;
|
|
491
480
|
|
|
492
481
|
/**
|
|
493
|
-
* Sign data using
|
|
482
|
+
* Sign data using an RSA private key with SHA-256.
|
|
483
|
+
*
|
|
484
|
+
* Uses `openssl dgst -sha256 -sign` which is universally supported across
|
|
485
|
+
* all OpenSSL and LibreSSL versions.
|
|
486
|
+
*
|
|
494
487
|
* @param options - Signing options
|
|
495
488
|
* @returns Base64-encoded signature
|
|
496
489
|
* @throws Error if signing fails
|
|
@@ -596,7 +589,11 @@ export declare function listPackageFiles(packages: string[], ignore?: string[],
|
|
|
596
589
|
export declare type VerificationStatus = 'EXPIRED' | 'FINGERPRINT_CHANGED' | 'INVALIDATED_BY_PARENT' | 'NEEDS_ATTESTATION' | 'SIGNATURE_INVALID' | 'VALID';
|
|
597
590
|
|
|
598
591
|
/**
|
|
599
|
-
* Verify a signature using
|
|
592
|
+
* Verify a signature using an RSA public key with SHA-256.
|
|
593
|
+
*
|
|
594
|
+
* Uses `openssl dgst -sha256 -verify` which is universally supported across
|
|
595
|
+
* all OpenSSL and LibreSSL versions.
|
|
596
|
+
*
|
|
600
597
|
* @param options - Verification options
|
|
601
598
|
* @returns true if signature is valid
|
|
602
599
|
* @throws Error if verification fails (not just invalid signature)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { checkOpenSSL, generateKeyPair, getDefaultPrivateKeyPath, getDefaultPublicKeyPath, setKeyPermissions, sign, verify } from './chunk-
|
|
2
|
-
//# sourceMappingURL=crypto-
|
|
3
|
-
//# sourceMappingURL=crypto-
|
|
1
|
+
export { checkOpenSSL, generateKeyPair, getDefaultPrivateKeyPath, getDefaultPublicKeyPath, setKeyPermissions, sign, verify } from './chunk-CEE7ONNG.js';
|
|
2
|
+
//# sourceMappingURL=crypto-VAXWUGKL.js.map
|
|
3
|
+
//# sourceMappingURL=crypto-VAXWUGKL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"crypto-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"crypto-VAXWUGKL.js"}
|
package/dist/index.cjs
CHANGED
|
@@ -142,7 +142,6 @@ async function cleanupFiles(...paths) {
|
|
|
142
142
|
async function generateKeyPair(options = {}) {
|
|
143
143
|
await ensureOpenSSLAvailable();
|
|
144
144
|
const {
|
|
145
|
-
algorithm = "ed25519",
|
|
146
145
|
privatePath = getDefaultPrivateKeyPath(),
|
|
147
146
|
publicPath = getDefaultPublicKeyPath(),
|
|
148
147
|
force = false
|
|
@@ -160,7 +159,15 @@ async function generateKeyPair(options = {}) {
|
|
|
160
159
|
await ensureDir(path2__namespace.dirname(privatePath));
|
|
161
160
|
await ensureDir(path2__namespace.dirname(publicPath));
|
|
162
161
|
try {
|
|
163
|
-
const genArgs =
|
|
162
|
+
const genArgs = [
|
|
163
|
+
"genpkey",
|
|
164
|
+
"-algorithm",
|
|
165
|
+
"RSA",
|
|
166
|
+
"-pkeyopt",
|
|
167
|
+
"rsa_keygen_bits:2048",
|
|
168
|
+
"-out",
|
|
169
|
+
privatePath
|
|
170
|
+
];
|
|
164
171
|
const genResult = await runOpenSSL(genArgs);
|
|
165
172
|
if (genResult.exitCode !== 0) {
|
|
166
173
|
throw new Error(`Failed to generate private key: ${genResult.stderr}`);
|
|
@@ -192,16 +199,8 @@ async function sign(options) {
|
|
|
192
199
|
const sigFile = path2__namespace.join(tmpDir, "sig.bin");
|
|
193
200
|
try {
|
|
194
201
|
await fs2__namespace.writeFile(dataFile, processBuffer);
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
"-sign",
|
|
198
|
-
"-inkey",
|
|
199
|
-
privateKeyPath,
|
|
200
|
-
"-in",
|
|
201
|
-
dataFile,
|
|
202
|
-
"-out",
|
|
203
|
-
sigFile
|
|
204
|
-
]);
|
|
202
|
+
const signArgs = ["dgst", "-sha256", "-sign", privateKeyPath, "-out", sigFile, dataFile];
|
|
203
|
+
const result = await runOpenSSL(signArgs);
|
|
205
204
|
if (result.exitCode !== 0) {
|
|
206
205
|
throw new Error(`Failed to sign data: ${result.stderr}`);
|
|
207
206
|
}
|
|
@@ -229,21 +228,17 @@ async function verify(options) {
|
|
|
229
228
|
try {
|
|
230
229
|
await fs2__namespace.writeFile(dataFile, processBuffer);
|
|
231
230
|
await fs2__namespace.writeFile(sigFile, sigBuffer);
|
|
232
|
-
const
|
|
233
|
-
"
|
|
231
|
+
const verifyArgs = [
|
|
232
|
+
"dgst",
|
|
233
|
+
"-sha256",
|
|
234
234
|
"-verify",
|
|
235
|
-
"-pubin",
|
|
236
|
-
"-inkey",
|
|
237
235
|
publicKeyPath,
|
|
238
|
-
"-
|
|
236
|
+
"-signature",
|
|
239
237
|
sigFile,
|
|
240
|
-
"-in",
|
|
241
238
|
dataFile
|
|
242
|
-
]
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
return result.exitCode === 0;
|
|
239
|
+
];
|
|
240
|
+
const result = await runOpenSSL(verifyArgs);
|
|
241
|
+
return result.exitCode === 0 && result.stdout.toString().includes("Verified OK");
|
|
247
242
|
} finally {
|
|
248
243
|
try {
|
|
249
244
|
await fs2__namespace.rm(tmpDir, { recursive: true, force: true });
|
|
@@ -268,9 +263,9 @@ var settingsSchema = zod.z.object({
|
|
|
268
263
|
maxAgeDays: zod.z.number().int().positive().default(30),
|
|
269
264
|
publicKeyPath: zod.z.string().default(".attest-it/pubkey.pem"),
|
|
270
265
|
attestationsPath: zod.z.string().default(".attest-it/attestations.json"),
|
|
271
|
-
defaultCommand: zod.z.string().optional()
|
|
272
|
-
|
|
273
|
-
}).
|
|
266
|
+
defaultCommand: zod.z.string().optional()
|
|
267
|
+
// Note: algorithm field was removed - RSA is the only supported algorithm
|
|
268
|
+
}).passthrough();
|
|
274
269
|
var suiteSchema = zod.z.object({
|
|
275
270
|
description: zod.z.string().optional(),
|
|
276
271
|
packages: zod.z.array(zod.z.string().min(1, "Package path cannot be empty")).min(1, "At least one package pattern is required"),
|
|
@@ -403,7 +398,6 @@ function toAttestItConfig(config) {
|
|
|
403
398
|
maxAgeDays: config.settings.maxAgeDays,
|
|
404
399
|
publicKeyPath: config.settings.publicKeyPath,
|
|
405
400
|
attestationsPath: config.settings.attestationsPath,
|
|
406
|
-
algorithm: config.settings.algorithm,
|
|
407
401
|
...config.settings.defaultCommand !== void 0 && {
|
|
408
402
|
defaultCommand: config.settings.defaultCommand
|
|
409
403
|
}
|