@certchip/signer 0.1.11 → 0.1.15

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 CHANGED
@@ -12,6 +12,7 @@ Cross-platform code and document signing CLI tool with SSH key authentication.
12
12
  - **Text/Source Signing** - JS, Python, Go, Rust, and more
13
13
  - **Hash-based Signing** - Default mode: only hash sent to server, not the file
14
14
  - **Windows KSP** - Native Windows crypto integration (Windows only)
15
+ - **Structured Output** - JSON, table, or CSV output for scripting and automation
15
16
 
16
17
  ## Installation
17
18
 
@@ -167,6 +168,28 @@ signercli -codesign-cert -o cert.pem # Save to file
167
168
  signercli -codesign-set <password>
168
169
  ```
169
170
 
171
+ **Alternative: `-cert` commands (compatible with signer.exe)**
172
+
173
+ ```bash
174
+ # List certificates (with purpose filter)
175
+ signercli -cert -list # List all certificates
176
+ signercli -cert -list codesign # List code signing certificates
177
+ signercli -cert -list docsign # List document signing certificates
178
+
179
+ # Get/Set certificate ID
180
+ signercli -cert -id # Show current configuration
181
+ signercli -cert -id <cert_id> # Set certificate ID
182
+ signercli -cert -id <cert_id> <label> # Set with label
183
+
184
+ # Get certificate PEM
185
+ signercli -cert -pem
186
+
187
+ # Set private key password
188
+ signercli -cert -password <password>
189
+ ```
190
+
191
+ > **Note:** The `-cert` commands use the same API endpoints as `signer.exe`, ensuring full compatibility between both tools.
192
+
170
193
  #### Configuration
171
194
 
172
195
  Profiles store connection settings. The `default` profile is used when no profile is specified. Other profiles inherit missing settings from `default`.
@@ -216,6 +239,7 @@ signercli -login -profile staging # Uses 'staging' (overrides host)
216
239
  | `-include-chain` | Include certificate chain |
217
240
  | `-timestamp-url <url>` | Timestamp server URL |
218
241
  | `-hash-algorithm <alg>` | Default hash algorithm |
242
+ | `-output-format <type>` | Default output format (classic, json, table, csv) |
219
243
 
220
244
  **Document Signing Options:**
221
245
 
@@ -249,6 +273,90 @@ signercli <file> LOG_INF # Info output
249
273
  # Available: LOG_NON, LOG_ERR, LOG_WRN, LOG_DBG, LOG_INF
250
274
  ```
251
275
 
276
+ #### Output Format
277
+
278
+ Both `signercli` and `signer` support structured output formats for scripting and automation.
279
+
280
+ ```bash
281
+ # JSON format (default for scripting)
282
+ signercli -verify myapp.exe -format json
283
+ signercli -config list -format json
284
+ signercli -logout -format json
285
+
286
+ # Table format (aligned columns)
287
+ signercli -verify myapp.exe -format table
288
+
289
+ # CSV format (spreadsheet-friendly)
290
+ signercli -config list -format csv
291
+
292
+ # Classic format (default - human-readable)
293
+ signercli -verify myapp.exe
294
+ ```
295
+
296
+ **Format Options:**
297
+
298
+ | Format | Description | Best for |
299
+ |--------|-------------|----------|
300
+ | `classic` | Human-readable output (default) | Interactive use |
301
+ | `json` | JSON structured output | CI/CD, scripting, automation |
302
+ | `table` | Aligned table format | Terminal display |
303
+ | `csv` | Comma-separated values | Spreadsheets, data processing |
304
+
305
+ **Example: JSON output from verify command**
306
+
307
+ ```bash
308
+ $ signercli -verify myapp.exe -format json
309
+ ```
310
+
311
+ ```json
312
+ {
313
+ "command": "verify",
314
+ "status": "valid",
315
+ "file": "myapp.exe",
316
+ "method": "AUTHENTICODE",
317
+ "signer": "Example Company",
318
+ "serialNumber": "0123456789abcdef",
319
+ "timestamp": "2025-01-15 10:30:00",
320
+ "success": true
321
+ }
322
+ ```
323
+
324
+ **Example: JSON output from config list**
325
+
326
+ ```bash
327
+ $ signercli -config list -format json
328
+ ```
329
+
330
+ ```json
331
+ {
332
+ "command": "config-list",
333
+ "count": 3,
334
+ "profiles": ["default", "production", "staging"],
335
+ "success": true
336
+ }
337
+ ```
338
+
339
+ **Example: JSON output from login**
340
+
341
+ ```bash
342
+ $ signercli -login https://signer.example.com admin -pw secret -format json
343
+ ```
344
+
345
+ ```json
346
+ {
347
+ "command": "login",
348
+ "status": "success",
349
+ "username": "admin",
350
+ "expiresIn": 86400,
351
+ "certificate": {
352
+ "cn": "Example Company Code Signing"
353
+ },
354
+ "success": true
355
+ }
356
+ ```
357
+
358
+ > **Note:** Interactive authentication (password prompt, SSH key selection) is not available with structured output formats. Use `-user` and `-pw` options or `-key` option for non-interactive login.
359
+
252
360
  ---
253
361
 
254
362
  ### signer (Windows only)
@@ -267,6 +375,14 @@ signer -login <url> [username] # Login and register certificate
267
375
  signer -logout # Logout and remove certificate
268
376
  signer -list # List available certificates
269
377
 
378
+ # Certificate Management
379
+ signer -cert -list # List available certificates
380
+ signer -cert -list codesign # Filter by purpose
381
+ signer -cert -id # Show current certificate configuration
382
+ signer -cert -id <cert_id> # Set certificate ID
383
+ signer -cert -pem # Get certificate PEM
384
+ signer -cert -password <password> # Set private key password
385
+
270
386
  # KSP Provider Management
271
387
  signer -register # Register Certchip KSP provider
272
388
  signer -unregister # Unregister KSP provider
@@ -371,10 +487,16 @@ signercli -config set pdf-signing \
371
487
  -doc-font-size 12 \
372
488
  -doc-opacity 0.8
373
489
 
490
+ # Create an automation profile with JSON output
491
+ signercli -config set automation \
492
+ -host https://signer.example.com \
493
+ -output-format json
494
+
374
495
  # Use the profile
375
496
  signercli -login -profile production
376
497
  signercli myapp.exe -profile production
377
498
  signercli document.pdf -profile pdf-signing
499
+ signercli -verify myapp.exe -profile automation # Outputs JSON automatically
378
500
  ```
379
501
 
380
502
  ## Supported File Types
@@ -425,16 +547,45 @@ signercli document.pdf -profile pdf-signing
425
547
  #!/bin/bash
426
548
  set -e
427
549
 
428
- # Login
429
- signercli -login "$SIGNER_URL" "$SIGNER_USER" -key "$SSH_KEY_PATH"
550
+ # Login with JSON output for parsing
551
+ result=$(signercli -login "$SIGNER_URL" -user "$SIGNER_USER" -pw "$SIGNER_PW" -format json)
552
+ if ! echo "$result" | jq -e '.success' > /dev/null; then
553
+ echo "Login failed: $(echo "$result" | jq -r '.error')"
554
+ exit 1
555
+ fi
430
556
 
431
557
  # Sign all executables
432
558
  for exe in dist/*.exe; do
433
559
  signercli "$exe"
434
560
  done
435
561
 
436
- # Logout
437
- signercli -logout
562
+ # Logout with JSON output
563
+ signercli -logout -format json
564
+ ```
565
+
566
+ ### CI/CD Pipeline with Verification
567
+
568
+ ```bash
569
+ #!/bin/bash
570
+ set -e
571
+
572
+ # Sign and verify with JSON output
573
+ signercli -login "$SIGNER_URL" -user "$SIGNER_USER" -pw "$SIGNER_PW" -format json
574
+
575
+ for exe in dist/*.exe; do
576
+ signercli "$exe"
577
+
578
+ # Verify and parse JSON result
579
+ verify_result=$(signercli -verify "$exe" -format json)
580
+ status=$(echo "$verify_result" | jq -r '.status')
581
+
582
+ if [ "$status" != "valid" ]; then
583
+ echo "Verification failed for $exe"
584
+ exit 1
585
+ fi
586
+ done
587
+
588
+ signercli -logout -format json
438
589
  ```
439
590
 
440
591
  ### TypeScript Usage
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certchip/signer",
3
- "version": "0.1.11",
3
+ "version": "0.1.15",
4
4
  "description": "Cross-platform code and document signing CLI tool",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",