@bcts/seedtool-cli 1.0.0-alpha.21 → 1.0.0-alpha.23

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/main.mjs CHANGED
@@ -13,7 +13,6 @@ import { SSKR_SHARE, SSKR_SHARE_V1 } from "@bcts/tags";
13
13
  import { sha256 } from "@noble/hashes/sha2.js";
14
14
  import { hkdf } from "@noble/hashes/hkdf.js";
15
15
  import fs from "node:fs";
16
-
17
16
  //#region src/cli.ts
18
17
  /**
19
18
  * Copyright © 2023-2026 Blockchain Commons, LLC
@@ -24,63 +23,6 @@ import fs from "node:fs";
24
23
  * Ported from seedtool-cli-rust/src/cli.rs
25
24
  */
26
25
  /**
27
- * Input format keys.
28
- * Matches Rust InputFormatKey enum in format.rs
29
- */
30
- let InputFormatKey = /* @__PURE__ */ function(InputFormatKey) {
31
- InputFormatKey["Random"] = "random";
32
- InputFormatKey["Hex"] = "hex";
33
- InputFormatKey["Btw"] = "btw";
34
- InputFormatKey["Btwu"] = "btwu";
35
- InputFormatKey["Btwm"] = "btwm";
36
- InputFormatKey["Bits"] = "bits";
37
- InputFormatKey["Cards"] = "cards";
38
- InputFormatKey["Dice"] = "dice";
39
- InputFormatKey["Base6"] = "base6";
40
- InputFormatKey["Base10"] = "base10";
41
- InputFormatKey["Ints"] = "ints";
42
- InputFormatKey["Bip39"] = "bip39";
43
- InputFormatKey["Sskr"] = "sskr";
44
- InputFormatKey["Envelope"] = "envelope";
45
- InputFormatKey["Multipart"] = "multipart";
46
- InputFormatKey["Seed"] = "seed";
47
- return InputFormatKey;
48
- }({});
49
- /**
50
- * Output format keys.
51
- * Matches Rust OutputFormatKey enum in format.rs
52
- */
53
- let OutputFormatKey = /* @__PURE__ */ function(OutputFormatKey) {
54
- OutputFormatKey["Hex"] = "hex";
55
- OutputFormatKey["Btw"] = "btw";
56
- OutputFormatKey["Btwu"] = "btwu";
57
- OutputFormatKey["Btwm"] = "btwm";
58
- OutputFormatKey["Bits"] = "bits";
59
- OutputFormatKey["Cards"] = "cards";
60
- OutputFormatKey["Dice"] = "dice";
61
- OutputFormatKey["Base6"] = "base6";
62
- OutputFormatKey["Base10"] = "base10";
63
- OutputFormatKey["Ints"] = "ints";
64
- OutputFormatKey["Bip39"] = "bip39";
65
- OutputFormatKey["Sskr"] = "sskr";
66
- OutputFormatKey["Envelope"] = "envelope";
67
- OutputFormatKey["Multipart"] = "multipart";
68
- OutputFormatKey["Seed"] = "seed";
69
- return OutputFormatKey;
70
- }({});
71
- /**
72
- * SSKR output format keys.
73
- * Matches Rust SSKRFormatKey enum in sskr.rs
74
- */
75
- let SSKRFormatKey = /* @__PURE__ */ function(SSKRFormatKey) {
76
- SSKRFormatKey["Envelope"] = "envelope";
77
- SSKRFormatKey["Btw"] = "btw";
78
- SSKRFormatKey["Btwm"] = "btwm";
79
- SSKRFormatKey["Btwu"] = "btwu";
80
- SSKRFormatKey["Ur"] = "ur";
81
- return SSKRFormatKey;
82
- }({});
83
- /**
84
26
  * CLI state and configuration.
85
27
  * Matches Rust Cli struct.
86
28
  */
@@ -90,9 +32,9 @@ var Cli = class Cli {
90
32
  /** The number of output units (hex bytes, base-10 digits, etc.) */
91
33
  count = 16;
92
34
  /** The input format. Default: Random */
93
- in = InputFormatKey.Random;
35
+ in = "random";
94
36
  /** The output format. Default: Hex */
95
- out = OutputFormatKey.Hex;
37
+ out = "hex";
96
38
  /** The lowest int returned (0-254). Default: 0 */
97
39
  low = 0;
98
40
  /** The highest int returned (1-255), low < high. Default: 9 */
@@ -112,7 +54,7 @@ var Cli = class Cli {
112
54
  /** The number of groups that must meet their threshold. Default: 1 */
113
55
  groupThreshold = 1;
114
56
  /** SSKR output format. Default: Envelope */
115
- sskrFormat = SSKRFormatKey.Envelope;
57
+ sskrFormat = "envelope";
116
58
  /** Deterministic RNG seed string. */
117
59
  deterministic;
118
60
  /** The seed being processed (internal state). */
@@ -218,7 +160,6 @@ var Cli = class Cli {
218
160
  return cli;
219
161
  }
220
162
  };
221
-
222
163
  //#endregion
223
164
  //#region src/seed.ts
224
165
  /**
@@ -426,7 +367,6 @@ var Seed$1 = class Seed$1 {
426
367
  return true;
427
368
  }
428
369
  };
429
-
430
370
  //#endregion
431
371
  //#region src/util.ts
432
372
  /**
@@ -540,7 +480,6 @@ function digitsToData(inStr, low, high) {
540
480
  }
541
481
  return new Uint8Array(result);
542
482
  }
543
-
544
483
  //#endregion
545
484
  //#region src/formats/hex.ts
546
485
  /**
@@ -563,7 +502,6 @@ var HexFormat = class {
563
502
  return dataToHex(state.expectSeed().data());
564
503
  }
565
504
  };
566
-
567
505
  //#endregion
568
506
  //#region src/formats/bip39.ts
569
507
  /**
@@ -588,18 +526,9 @@ var Bip39Format = class {
588
526
  return entropyToMnemonic(state.expectSeed().data(), wordlist);
589
527
  }
590
528
  };
591
-
592
529
  //#endregion
593
530
  //#region src/formats/sskr.ts
594
531
  /**
595
- * Copyright © 2023-2026 Blockchain Commons, LLC
596
- * Copyright © 2025-2026 Parity Technologies
597
- *
598
- *
599
- * SSKR format
600
- * Ported from seedtool-cli-rust/src/formats/sskr.rs
601
- */
602
- /**
603
532
  * SSKR format handler.
604
533
  * Round-trippable: sskr shares → seed → sskr shares.
605
534
  * Supports multiple sub-formats: envelope, btw, btwm, btwu, ur.
@@ -624,15 +553,15 @@ var SSKRFormat = class {
624
553
  };
625
554
  function outputSskrSeed(seed, spec, format) {
626
555
  switch (format) {
627
- case SSKRFormatKey.Envelope: {
556
+ case "envelope": {
628
557
  const seedEnvelope = seed.toEnvelope();
629
558
  const contentKey = SymmetricKey.new();
630
559
  return seedEnvelope.wrap().encryptSubject(contentKey).sskrSplitFlattened(spec, contentKey).map((env) => env.urString()).join("\n");
631
560
  }
632
- case SSKRFormatKey.Btw: return makeBytewordsShares(spec, seed, BytewordsStyle.Standard);
633
- case SSKRFormatKey.Btwm: return makeBytewordsShares(spec, seed, BytewordsStyle.Minimal);
634
- case SSKRFormatKey.Btwu: return makeBytewordsShares(spec, seed, BytewordsStyle.Uri);
635
- case SSKRFormatKey.Ur: return makeShares(spec, seed).map((share) => {
561
+ case "btw": return makeBytewordsShares(spec, seed, BytewordsStyle.Standard);
562
+ case "btwm": return makeBytewordsShares(spec, seed, BytewordsStyle.Minimal);
563
+ case "btwu": return makeBytewordsShares(spec, seed, BytewordsStyle.Uri);
564
+ case "ur": return makeShares(spec, seed).map((share) => {
636
565
  return UR.new("sskr", toByteString(share.asBytes())).toString();
637
566
  }).join("\n");
638
567
  }
@@ -742,7 +671,6 @@ function parseSskrSeed(input) {
742
671
  if (urLegacyResult !== null) return urLegacyResult;
743
672
  throw new Error("Insufficient or invalid SSKR shares.");
744
673
  }
745
-
746
674
  //#endregion
747
675
  //#region src/formats/envelope.ts
748
676
  /**
@@ -766,7 +694,6 @@ var EnvelopeFormat = class {
766
694
  return state.toEnvelope().urString();
767
695
  }
768
696
  };
769
-
770
697
  //#endregion
771
698
  //#region src/formats/seed-format.ts
772
699
  /**
@@ -791,7 +718,6 @@ var SeedFormat = class {
791
718
  return state.seedWithOverrides().toComponentsSeed().urString();
792
719
  }
793
720
  };
794
-
795
721
  //#endregion
796
722
  //#region src/formats/multipart.ts
797
723
  /**
@@ -828,7 +754,6 @@ var MultipartFormat = class {
828
754
  return parts.join("\n");
829
755
  }
830
756
  };
831
-
832
757
  //#endregion
833
758
  //#region src/formats/random.ts
834
759
  /**
@@ -848,7 +773,6 @@ var RandomFormat = class {
848
773
  return state;
849
774
  }
850
775
  };
851
-
852
776
  //#endregion
853
777
  //#region src/random.ts
854
778
  /**
@@ -956,7 +880,6 @@ function sha256DeterministicRandomString(str, n) {
956
880
  function deterministicRandom(entropy, n) {
957
881
  return hkdfHmacSha256(sha256(entropy), new Uint8Array(0), n);
958
882
  }
959
-
960
883
  //#endregion
961
884
  //#region src/formats/base6.ts
962
885
  /**
@@ -982,7 +905,6 @@ var Base6Format = class {
982
905
  return dataToInts(state.expectSeed().data(), 0, 5, "");
983
906
  }
984
907
  };
985
-
986
908
  //#endregion
987
909
  //#region src/formats/base10.ts
988
910
  /**
@@ -1008,7 +930,6 @@ var Base10Format = class {
1008
930
  return dataToInts(state.expectSeed().data(), 0, 9, "");
1009
931
  }
1010
932
  };
1011
-
1012
933
  //#endregion
1013
934
  //#region src/formats/bits.ts
1014
935
  /**
@@ -1034,7 +955,6 @@ var BitsFormat = class {
1034
955
  return dataToInts(state.expectSeed().data(), 0, 1, "");
1035
956
  }
1036
957
  };
1037
-
1038
958
  //#endregion
1039
959
  //#region src/formats/dice.ts
1040
960
  /**
@@ -1060,7 +980,6 @@ var DiceFormat = class {
1060
980
  return dataToInts(state.expectSeed().data(), 1, 6, "");
1061
981
  }
1062
982
  };
1063
-
1064
983
  //#endregion
1065
984
  //#region src/formats/cards.ts
1066
985
  const CARD_SUITS = "cdhs";
@@ -1130,7 +1049,6 @@ var CardsFormat = class {
1130
1049
  return dataToAlphabet(state.expectSeed().data(), 52, toCard);
1131
1050
  }
1132
1051
  };
1133
-
1134
1052
  //#endregion
1135
1053
  //#region src/formats/ints.ts
1136
1054
  /**
@@ -1154,7 +1072,6 @@ var IntsFormat = class {
1154
1072
  return dataToInts(state.expectSeed().data(), state.low, state.high, " ");
1155
1073
  }
1156
1074
  };
1157
-
1158
1075
  //#endregion
1159
1076
  //#region src/formats/bytewords-standard.ts
1160
1077
  /**
@@ -1178,7 +1095,6 @@ var BytewordsStandardFormat = class {
1178
1095
  return encodeBytewords(state.expectSeed().data(), BytewordsStyle.Standard);
1179
1096
  }
1180
1097
  };
1181
-
1182
1098
  //#endregion
1183
1099
  //#region src/formats/bytewords-minimal.ts
1184
1100
  /**
@@ -1202,7 +1118,6 @@ var BytewordsMinimalFormat = class {
1202
1118
  return encodeBytewords(state.expectSeed().data(), BytewordsStyle.Minimal);
1203
1119
  }
1204
1120
  };
1205
-
1206
1121
  //#endregion
1207
1122
  //#region src/formats/bytewords-uri.ts
1208
1123
  /**
@@ -1226,39 +1141,30 @@ var BytewordsUriFormat = class {
1226
1141
  return encodeBytewords(state.expectSeed().data(), BytewordsStyle.Uri);
1227
1142
  }
1228
1143
  };
1229
-
1230
1144
  //#endregion
1231
1145
  //#region src/formats/format.ts
1232
1146
  /**
1233
- * Copyright © 2023-2026 Blockchain Commons, LLC
1234
- * Copyright © 2025-2026 Parity Technologies
1235
- *
1236
- *
1237
- * Format traits and factory functions
1238
- * Ported from seedtool-cli-rust/src/formats/format.rs
1239
- */
1240
- /**
1241
1147
  * Select input format by key.
1242
1148
  * Matches Rust select_input_format function.
1243
1149
  */
1244
1150
  function selectInputFormat(key) {
1245
1151
  switch (key) {
1246
- case InputFormatKey.Random: return new RandomFormat();
1247
- case InputFormatKey.Hex: return new HexFormat();
1248
- case InputFormatKey.Btw: return new BytewordsStandardFormat();
1249
- case InputFormatKey.Btwu: return new BytewordsUriFormat();
1250
- case InputFormatKey.Btwm: return new BytewordsMinimalFormat();
1251
- case InputFormatKey.Bits: return new BitsFormat();
1252
- case InputFormatKey.Cards: return new CardsFormat();
1253
- case InputFormatKey.Dice: return new DiceFormat();
1254
- case InputFormatKey.Base6: return new Base6Format();
1255
- case InputFormatKey.Base10: return new Base10Format();
1256
- case InputFormatKey.Ints: return new IntsFormat();
1257
- case InputFormatKey.Bip39: return new Bip39Format();
1258
- case InputFormatKey.Sskr: return new SSKRFormat();
1259
- case InputFormatKey.Envelope: return new EnvelopeFormat();
1260
- case InputFormatKey.Multipart: return new MultipartFormat();
1261
- case InputFormatKey.Seed: return new SeedFormat();
1152
+ case "random": return new RandomFormat();
1153
+ case "hex": return new HexFormat();
1154
+ case "btw": return new BytewordsStandardFormat();
1155
+ case "btwu": return new BytewordsUriFormat();
1156
+ case "btwm": return new BytewordsMinimalFormat();
1157
+ case "bits": return new BitsFormat();
1158
+ case "cards": return new CardsFormat();
1159
+ case "dice": return new DiceFormat();
1160
+ case "base6": return new Base6Format();
1161
+ case "base10": return new Base10Format();
1162
+ case "ints": return new IntsFormat();
1163
+ case "bip39": return new Bip39Format();
1164
+ case "sskr": return new SSKRFormat();
1165
+ case "envelope": return new EnvelopeFormat();
1166
+ case "multipart": return new MultipartFormat();
1167
+ case "seed": return new SeedFormat();
1262
1168
  }
1263
1169
  }
1264
1170
  /**
@@ -1267,24 +1173,23 @@ function selectInputFormat(key) {
1267
1173
  */
1268
1174
  function selectOutputFormat(key) {
1269
1175
  switch (key) {
1270
- case OutputFormatKey.Hex: return new HexFormat();
1271
- case OutputFormatKey.Btw: return new BytewordsStandardFormat();
1272
- case OutputFormatKey.Btwu: return new BytewordsUriFormat();
1273
- case OutputFormatKey.Btwm: return new BytewordsMinimalFormat();
1274
- case OutputFormatKey.Bits: return new BitsFormat();
1275
- case OutputFormatKey.Cards: return new CardsFormat();
1276
- case OutputFormatKey.Dice: return new DiceFormat();
1277
- case OutputFormatKey.Base6: return new Base6Format();
1278
- case OutputFormatKey.Base10: return new Base10Format();
1279
- case OutputFormatKey.Ints: return new IntsFormat();
1280
- case OutputFormatKey.Bip39: return new Bip39Format();
1281
- case OutputFormatKey.Sskr: return new SSKRFormat();
1282
- case OutputFormatKey.Envelope: return new EnvelopeFormat();
1283
- case OutputFormatKey.Multipart: return new MultipartFormat();
1284
- case OutputFormatKey.Seed: return new SeedFormat();
1176
+ case "hex": return new HexFormat();
1177
+ case "btw": return new BytewordsStandardFormat();
1178
+ case "btwu": return new BytewordsUriFormat();
1179
+ case "btwm": return new BytewordsMinimalFormat();
1180
+ case "bits": return new BitsFormat();
1181
+ case "cards": return new CardsFormat();
1182
+ case "dice": return new DiceFormat();
1183
+ case "base6": return new Base6Format();
1184
+ case "base10": return new Base10Format();
1185
+ case "ints": return new IntsFormat();
1186
+ case "bip39": return new Bip39Format();
1187
+ case "sskr": return new SSKRFormat();
1188
+ case "envelope": return new EnvelopeFormat();
1189
+ case "multipart": return new MultipartFormat();
1190
+ case "seed": return new SeedFormat();
1285
1191
  }
1286
1192
  }
1287
-
1288
1193
  //#endregion
1289
1194
  //#region src/main.ts
1290
1195
  /**
@@ -1407,7 +1312,7 @@ try {
1407
1312
  console.error(message);
1408
1313
  process.exit(1);
1409
1314
  }
1410
-
1411
1315
  //#endregion
1412
- export { };
1316
+ export {};
1317
+
1413
1318
  //# sourceMappingURL=main.mjs.map