@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.
@@ -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
- }, "strict", z.ZodTypeAny, {
152
- algorithm: "ed25519" | "rsa";
153
- attestationsPath: string;
154
- defaultCommand?: string | undefined;
155
- maxAgeDays: number;
156
- publicKeyPath: string;
157
- }, {
158
- algorithm?: "ed25519" | "rsa" | undefined;
159
- attestationsPath?: string | undefined;
160
- defaultCommand?: string | undefined;
161
- maxAgeDays?: number | undefined;
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
- algorithm?: "ed25519" | "rsa" | undefined;
221
- attestationsPath?: string | undefined;
222
- defaultCommand?: string | undefined;
223
- maxAgeDays?: number | undefined;
224
- publicKeyPath?: string | undefined;
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 a private key.
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 a public key.
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-UWYR7JNE.js';
2
- //# sourceMappingURL=crypto-ITLMIMRJ.js.map
3
- //# sourceMappingURL=crypto-ITLMIMRJ.js.map
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-ITLMIMRJ.js"}
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 = algorithm === "ed25519" ? ["genpkey", "-algorithm", "Ed25519", "-out", privatePath] : ["genpkey", "-algorithm", "RSA", "-pkeyopt", "rsa_keygen_bits:2048", "-out", privatePath];
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 result = await runOpenSSL([
196
- "pkeyutl",
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 result = await runOpenSSL([
233
- "pkeyutl",
231
+ const verifyArgs = [
232
+ "dgst",
233
+ "-sha256",
234
234
  "-verify",
235
- "-pubin",
236
- "-inkey",
237
235
  publicKeyPath,
238
- "-sigfile",
236
+ "-signature",
239
237
  sigFile,
240
- "-in",
241
238
  dataFile
242
- ]);
243
- if (result.exitCode !== 0 && result.exitCode !== 1) {
244
- throw new Error(`Verification error: ${result.stderr}`);
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
- algorithm: zod.z.enum(["ed25519", "rsa"]).default("ed25519")
273
- }).strict();
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
  }