@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/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  //#region \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
@@ -7,16 +7,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __getProtoOf = Object.getPrototypeOf;
8
8
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
9
  var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
- key = keys[i];
13
- if (!__hasOwnProp.call(to, key) && key !== except) {
14
- __defProp(to, key, {
15
- get: ((k) => from[k]).bind(null, key),
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
- });
18
- }
19
- }
10
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
+ get: ((k) => from[k]).bind(null, key),
14
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
+ });
20
16
  }
21
17
  return to;
22
18
  };
@@ -24,10 +20,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
20
  value: mod,
25
21
  enumerable: true
26
22
  }) : target, mod));
27
-
28
23
  //#endregion
29
24
  let node_readline = require("node:readline");
30
- node_readline = __toESM(node_readline);
25
+ node_readline = __toESM(node_readline, 1);
31
26
  let _bcts_components = require("@bcts/components");
32
27
  let _bcts_envelope = require("@bcts/envelope");
33
28
  let _bcts_known_values = require("@bcts/known-values");
@@ -38,7 +33,6 @@ let _scure_bip39 = require("@scure/bip39");
38
33
  let _scure_bip39_wordlists_english_js = require("@scure/bip39/wordlists/english.js");
39
34
  let _bcts_uniform_resources = require("@bcts/uniform-resources");
40
35
  let _bcts_tags = require("@bcts/tags");
41
-
42
36
  //#region src/cli.ts
43
37
  /**
44
38
  * Copyright © 2023-2026 Blockchain Commons, LLC
@@ -164,9 +158,9 @@ var Cli = class Cli {
164
158
  /** The number of output units (hex bytes, base-10 digits, etc.) */
165
159
  count = 16;
166
160
  /** The input format. Default: Random */
167
- in = InputFormatKey.Random;
161
+ in = "random";
168
162
  /** The output format. Default: Hex */
169
- out = OutputFormatKey.Hex;
163
+ out = "hex";
170
164
  /** The lowest int returned (0-254). Default: 0 */
171
165
  low = 0;
172
166
  /** The highest int returned (1-255), low < high. Default: 9 */
@@ -186,7 +180,7 @@ var Cli = class Cli {
186
180
  /** The number of groups that must meet their threshold. Default: 1 */
187
181
  groupThreshold = 1;
188
182
  /** SSKR output format. Default: Envelope */
189
- sskrFormat = SSKRFormatKey.Envelope;
183
+ sskrFormat = "envelope";
190
184
  /** Deterministic RNG seed string. */
191
185
  deterministic;
192
186
  /** The seed being processed (internal state). */
@@ -292,7 +286,6 @@ var Cli = class Cli {
292
286
  return cli;
293
287
  }
294
288
  };
295
-
296
289
  //#endregion
297
290
  //#region src/seed.ts
298
291
  /**
@@ -500,7 +493,6 @@ var Seed = class Seed {
500
493
  return true;
501
494
  }
502
495
  };
503
-
504
496
  //#endregion
505
497
  //#region src/random.ts
506
498
  /**
@@ -608,7 +600,6 @@ function sha256DeterministicRandomString(str, n) {
608
600
  function deterministicRandom(entropy, n) {
609
601
  return hkdfHmacSha256((0, _noble_hashes_sha2_js.sha256)(entropy), new Uint8Array(0), n);
610
602
  }
611
-
612
603
  //#endregion
613
604
  //#region src/util.ts
614
605
  /**
@@ -722,7 +713,6 @@ function digitsToData(inStr, low, high) {
722
713
  }
723
714
  return new Uint8Array(result);
724
715
  }
725
-
726
716
  //#endregion
727
717
  //#region src/formats/hex.ts
728
718
  /**
@@ -745,7 +735,6 @@ var HexFormat = class {
745
735
  return dataToHex(state.expectSeed().data());
746
736
  }
747
737
  };
748
-
749
738
  //#endregion
750
739
  //#region src/formats/bip39.ts
751
740
  /**
@@ -770,18 +759,9 @@ var Bip39Format = class {
770
759
  return (0, _scure_bip39.entropyToMnemonic)(state.expectSeed().data(), _scure_bip39_wordlists_english_js.wordlist);
771
760
  }
772
761
  };
773
-
774
762
  //#endregion
775
763
  //#region src/formats/sskr.ts
776
764
  /**
777
- * Copyright © 2023-2026 Blockchain Commons, LLC
778
- * Copyright © 2025-2026 Parity Technologies
779
- *
780
- *
781
- * SSKR format
782
- * Ported from seedtool-cli-rust/src/formats/sskr.rs
783
- */
784
- /**
785
765
  * SSKR format handler.
786
766
  * Round-trippable: sskr shares → seed → sskr shares.
787
767
  * Supports multiple sub-formats: envelope, btw, btwm, btwu, ur.
@@ -806,15 +786,15 @@ var SSKRFormat = class {
806
786
  };
807
787
  function outputSskrSeed(seed, spec, format) {
808
788
  switch (format) {
809
- case SSKRFormatKey.Envelope: {
789
+ case "envelope": {
810
790
  const seedEnvelope = seed.toEnvelope();
811
791
  const contentKey = _bcts_envelope.SymmetricKey.new();
812
792
  return seedEnvelope.wrap().encryptSubject(contentKey).sskrSplitFlattened(spec, contentKey).map((env) => env.urString()).join("\n");
813
793
  }
814
- case SSKRFormatKey.Btw: return makeBytewordsShares(spec, seed, _bcts_uniform_resources.BytewordsStyle.Standard);
815
- case SSKRFormatKey.Btwm: return makeBytewordsShares(spec, seed, _bcts_uniform_resources.BytewordsStyle.Minimal);
816
- case SSKRFormatKey.Btwu: return makeBytewordsShares(spec, seed, _bcts_uniform_resources.BytewordsStyle.Uri);
817
- case SSKRFormatKey.Ur: return makeShares(spec, seed).map((share) => {
794
+ case "btw": return makeBytewordsShares(spec, seed, _bcts_uniform_resources.BytewordsStyle.Standard);
795
+ case "btwm": return makeBytewordsShares(spec, seed, _bcts_uniform_resources.BytewordsStyle.Minimal);
796
+ case "btwu": return makeBytewordsShares(spec, seed, _bcts_uniform_resources.BytewordsStyle.Uri);
797
+ case "ur": return makeShares(spec, seed).map((share) => {
818
798
  return _bcts_uniform_resources.UR.new("sskr", (0, _bcts_dcbor.toByteString)(share.asBytes())).toString();
819
799
  }).join("\n");
820
800
  }
@@ -924,7 +904,6 @@ function parseSskrSeed(input) {
924
904
  if (urLegacyResult !== null) return urLegacyResult;
925
905
  throw new Error("Insufficient or invalid SSKR shares.");
926
906
  }
927
-
928
907
  //#endregion
929
908
  //#region src/formats/envelope.ts
930
909
  /**
@@ -948,7 +927,6 @@ var EnvelopeFormat = class {
948
927
  return state.toEnvelope().urString();
949
928
  }
950
929
  };
951
-
952
930
  //#endregion
953
931
  //#region src/formats/seed-format.ts
954
932
  /**
@@ -973,7 +951,6 @@ var SeedFormat = class {
973
951
  return state.seedWithOverrides().toComponentsSeed().urString();
974
952
  }
975
953
  };
976
-
977
954
  //#endregion
978
955
  //#region src/formats/multipart.ts
979
956
  /**
@@ -1010,7 +987,6 @@ var MultipartFormat = class {
1010
987
  return parts.join("\n");
1011
988
  }
1012
989
  };
1013
-
1014
990
  //#endregion
1015
991
  //#region src/formats/random.ts
1016
992
  /**
@@ -1030,7 +1006,6 @@ var RandomFormat = class {
1030
1006
  return state;
1031
1007
  }
1032
1008
  };
1033
-
1034
1009
  //#endregion
1035
1010
  //#region src/formats/base6.ts
1036
1011
  /**
@@ -1056,7 +1031,6 @@ var Base6Format = class {
1056
1031
  return dataToInts(state.expectSeed().data(), 0, 5, "");
1057
1032
  }
1058
1033
  };
1059
-
1060
1034
  //#endregion
1061
1035
  //#region src/formats/base10.ts
1062
1036
  /**
@@ -1082,7 +1056,6 @@ var Base10Format = class {
1082
1056
  return dataToInts(state.expectSeed().data(), 0, 9, "");
1083
1057
  }
1084
1058
  };
1085
-
1086
1059
  //#endregion
1087
1060
  //#region src/formats/bits.ts
1088
1061
  /**
@@ -1108,7 +1081,6 @@ var BitsFormat = class {
1108
1081
  return dataToInts(state.expectSeed().data(), 0, 1, "");
1109
1082
  }
1110
1083
  };
1111
-
1112
1084
  //#endregion
1113
1085
  //#region src/formats/dice.ts
1114
1086
  /**
@@ -1134,7 +1106,6 @@ var DiceFormat = class {
1134
1106
  return dataToInts(state.expectSeed().data(), 1, 6, "");
1135
1107
  }
1136
1108
  };
1137
-
1138
1109
  //#endregion
1139
1110
  //#region src/formats/cards.ts
1140
1111
  const CARD_SUITS = "cdhs";
@@ -1204,7 +1175,6 @@ var CardsFormat = class {
1204
1175
  return dataToAlphabet(state.expectSeed().data(), 52, toCard);
1205
1176
  }
1206
1177
  };
1207
-
1208
1178
  //#endregion
1209
1179
  //#region src/formats/ints.ts
1210
1180
  /**
@@ -1228,7 +1198,6 @@ var IntsFormat = class {
1228
1198
  return dataToInts(state.expectSeed().data(), state.low, state.high, " ");
1229
1199
  }
1230
1200
  };
1231
-
1232
1201
  //#endregion
1233
1202
  //#region src/formats/bytewords-standard.ts
1234
1203
  /**
@@ -1252,7 +1221,6 @@ var BytewordsStandardFormat = class {
1252
1221
  return (0, _bcts_uniform_resources.encodeBytewords)(state.expectSeed().data(), _bcts_uniform_resources.BytewordsStyle.Standard);
1253
1222
  }
1254
1223
  };
1255
-
1256
1224
  //#endregion
1257
1225
  //#region src/formats/bytewords-minimal.ts
1258
1226
  /**
@@ -1276,7 +1244,6 @@ var BytewordsMinimalFormat = class {
1276
1244
  return (0, _bcts_uniform_resources.encodeBytewords)(state.expectSeed().data(), _bcts_uniform_resources.BytewordsStyle.Minimal);
1277
1245
  }
1278
1246
  };
1279
-
1280
1247
  //#endregion
1281
1248
  //#region src/formats/bytewords-uri.ts
1282
1249
  /**
@@ -1300,39 +1267,30 @@ var BytewordsUriFormat = class {
1300
1267
  return (0, _bcts_uniform_resources.encodeBytewords)(state.expectSeed().data(), _bcts_uniform_resources.BytewordsStyle.Uri);
1301
1268
  }
1302
1269
  };
1303
-
1304
1270
  //#endregion
1305
1271
  //#region src/formats/format.ts
1306
1272
  /**
1307
- * Copyright © 2023-2026 Blockchain Commons, LLC
1308
- * Copyright © 2025-2026 Parity Technologies
1309
- *
1310
- *
1311
- * Format traits and factory functions
1312
- * Ported from seedtool-cli-rust/src/formats/format.rs
1313
- */
1314
- /**
1315
1273
  * Select input format by key.
1316
1274
  * Matches Rust select_input_format function.
1317
1275
  */
1318
1276
  function selectInputFormat(key) {
1319
1277
  switch (key) {
1320
- case InputFormatKey.Random: return new RandomFormat();
1321
- case InputFormatKey.Hex: return new HexFormat();
1322
- case InputFormatKey.Btw: return new BytewordsStandardFormat();
1323
- case InputFormatKey.Btwu: return new BytewordsUriFormat();
1324
- case InputFormatKey.Btwm: return new BytewordsMinimalFormat();
1325
- case InputFormatKey.Bits: return new BitsFormat();
1326
- case InputFormatKey.Cards: return new CardsFormat();
1327
- case InputFormatKey.Dice: return new DiceFormat();
1328
- case InputFormatKey.Base6: return new Base6Format();
1329
- case InputFormatKey.Base10: return new Base10Format();
1330
- case InputFormatKey.Ints: return new IntsFormat();
1331
- case InputFormatKey.Bip39: return new Bip39Format();
1332
- case InputFormatKey.Sskr: return new SSKRFormat();
1333
- case InputFormatKey.Envelope: return new EnvelopeFormat();
1334
- case InputFormatKey.Multipart: return new MultipartFormat();
1335
- case InputFormatKey.Seed: return new SeedFormat();
1278
+ case "random": return new RandomFormat();
1279
+ case "hex": return new HexFormat();
1280
+ case "btw": return new BytewordsStandardFormat();
1281
+ case "btwu": return new BytewordsUriFormat();
1282
+ case "btwm": return new BytewordsMinimalFormat();
1283
+ case "bits": return new BitsFormat();
1284
+ case "cards": return new CardsFormat();
1285
+ case "dice": return new DiceFormat();
1286
+ case "base6": return new Base6Format();
1287
+ case "base10": return new Base10Format();
1288
+ case "ints": return new IntsFormat();
1289
+ case "bip39": return new Bip39Format();
1290
+ case "sskr": return new SSKRFormat();
1291
+ case "envelope": return new EnvelopeFormat();
1292
+ case "multipart": return new MultipartFormat();
1293
+ case "seed": return new SeedFormat();
1336
1294
  }
1337
1295
  }
1338
1296
  /**
@@ -1341,24 +1299,23 @@ function selectInputFormat(key) {
1341
1299
  */
1342
1300
  function selectOutputFormat(key) {
1343
1301
  switch (key) {
1344
- case OutputFormatKey.Hex: return new HexFormat();
1345
- case OutputFormatKey.Btw: return new BytewordsStandardFormat();
1346
- case OutputFormatKey.Btwu: return new BytewordsUriFormat();
1347
- case OutputFormatKey.Btwm: return new BytewordsMinimalFormat();
1348
- case OutputFormatKey.Bits: return new BitsFormat();
1349
- case OutputFormatKey.Cards: return new CardsFormat();
1350
- case OutputFormatKey.Dice: return new DiceFormat();
1351
- case OutputFormatKey.Base6: return new Base6Format();
1352
- case OutputFormatKey.Base10: return new Base10Format();
1353
- case OutputFormatKey.Ints: return new IntsFormat();
1354
- case OutputFormatKey.Bip39: return new Bip39Format();
1355
- case OutputFormatKey.Sskr: return new SSKRFormat();
1356
- case OutputFormatKey.Envelope: return new EnvelopeFormat();
1357
- case OutputFormatKey.Multipart: return new MultipartFormat();
1358
- case OutputFormatKey.Seed: return new SeedFormat();
1302
+ case "hex": return new HexFormat();
1303
+ case "btw": return new BytewordsStandardFormat();
1304
+ case "btwu": return new BytewordsUriFormat();
1305
+ case "btwm": return new BytewordsMinimalFormat();
1306
+ case "bits": return new BitsFormat();
1307
+ case "cards": return new CardsFormat();
1308
+ case "dice": return new DiceFormat();
1309
+ case "base6": return new Base6Format();
1310
+ case "base10": return new Base10Format();
1311
+ case "ints": return new IntsFormat();
1312
+ case "bip39": return new Bip39Format();
1313
+ case "sskr": return new SSKRFormat();
1314
+ case "envelope": return new EnvelopeFormat();
1315
+ case "multipart": return new MultipartFormat();
1316
+ case "seed": return new SeedFormat();
1359
1317
  }
1360
1318
  }
1361
-
1362
1319
  //#endregion
1363
1320
  exports.Base10Format = Base10Format;
1364
1321
  exports.Base6Format = Base6Format;
@@ -1399,4 +1356,5 @@ exports.parseLowInt = parseLowInt;
1399
1356
  exports.selectInputFormat = selectInputFormat;
1400
1357
  exports.selectOutputFormat = selectOutputFormat;
1401
1358
  exports.sha256DeterministicRandom = sha256DeterministicRandom;
1359
+
1402
1360
  //# sourceMappingURL=index.cjs.map