@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 +48 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.mjs +40 -77
- package/dist/index.mjs.map +1 -1
- package/dist/main.mjs +41 -136
- package/dist/main.mjs.map +1 -1
- package/package.json +18 -18
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,6 @@ import { entropyToMnemonic, mnemonicToEntropy, validateMnemonic } from "@scure/b
|
|
|
9
9
|
import { wordlist } from "@scure/bip39/wordlists/english.js";
|
|
10
10
|
import { BytewordsStyle, MultipartDecoder, MultipartEncoder, UR, decodeBytewords, encodeBytewords } from "@bcts/uniform-resources";
|
|
11
11
|
import { SSKR_SHARE, SSKR_SHARE_V1 } from "@bcts/tags";
|
|
12
|
-
|
|
13
12
|
//#region src/cli.ts
|
|
14
13
|
/**
|
|
15
14
|
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
@@ -135,9 +134,9 @@ var Cli = class Cli {
|
|
|
135
134
|
/** The number of output units (hex bytes, base-10 digits, etc.) */
|
|
136
135
|
count = 16;
|
|
137
136
|
/** The input format. Default: Random */
|
|
138
|
-
in =
|
|
137
|
+
in = "random";
|
|
139
138
|
/** The output format. Default: Hex */
|
|
140
|
-
out =
|
|
139
|
+
out = "hex";
|
|
141
140
|
/** The lowest int returned (0-254). Default: 0 */
|
|
142
141
|
low = 0;
|
|
143
142
|
/** The highest int returned (1-255), low < high. Default: 9 */
|
|
@@ -157,7 +156,7 @@ var Cli = class Cli {
|
|
|
157
156
|
/** The number of groups that must meet their threshold. Default: 1 */
|
|
158
157
|
groupThreshold = 1;
|
|
159
158
|
/** SSKR output format. Default: Envelope */
|
|
160
|
-
sskrFormat =
|
|
159
|
+
sskrFormat = "envelope";
|
|
161
160
|
/** Deterministic RNG seed string. */
|
|
162
161
|
deterministic;
|
|
163
162
|
/** The seed being processed (internal state). */
|
|
@@ -263,7 +262,6 @@ var Cli = class Cli {
|
|
|
263
262
|
return cli;
|
|
264
263
|
}
|
|
265
264
|
};
|
|
266
|
-
|
|
267
265
|
//#endregion
|
|
268
266
|
//#region src/seed.ts
|
|
269
267
|
/**
|
|
@@ -471,7 +469,6 @@ var Seed = class Seed {
|
|
|
471
469
|
return true;
|
|
472
470
|
}
|
|
473
471
|
};
|
|
474
|
-
|
|
475
472
|
//#endregion
|
|
476
473
|
//#region src/random.ts
|
|
477
474
|
/**
|
|
@@ -579,7 +576,6 @@ function sha256DeterministicRandomString(str, n) {
|
|
|
579
576
|
function deterministicRandom(entropy, n) {
|
|
580
577
|
return hkdfHmacSha256(sha256(entropy), new Uint8Array(0), n);
|
|
581
578
|
}
|
|
582
|
-
|
|
583
579
|
//#endregion
|
|
584
580
|
//#region src/util.ts
|
|
585
581
|
/**
|
|
@@ -693,7 +689,6 @@ function digitsToData(inStr, low, high) {
|
|
|
693
689
|
}
|
|
694
690
|
return new Uint8Array(result);
|
|
695
691
|
}
|
|
696
|
-
|
|
697
692
|
//#endregion
|
|
698
693
|
//#region src/formats/hex.ts
|
|
699
694
|
/**
|
|
@@ -716,7 +711,6 @@ var HexFormat = class {
|
|
|
716
711
|
return dataToHex(state.expectSeed().data());
|
|
717
712
|
}
|
|
718
713
|
};
|
|
719
|
-
|
|
720
714
|
//#endregion
|
|
721
715
|
//#region src/formats/bip39.ts
|
|
722
716
|
/**
|
|
@@ -741,18 +735,9 @@ var Bip39Format = class {
|
|
|
741
735
|
return entropyToMnemonic(state.expectSeed().data(), wordlist);
|
|
742
736
|
}
|
|
743
737
|
};
|
|
744
|
-
|
|
745
738
|
//#endregion
|
|
746
739
|
//#region src/formats/sskr.ts
|
|
747
740
|
/**
|
|
748
|
-
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
749
|
-
* Copyright © 2025-2026 Parity Technologies
|
|
750
|
-
*
|
|
751
|
-
*
|
|
752
|
-
* SSKR format
|
|
753
|
-
* Ported from seedtool-cli-rust/src/formats/sskr.rs
|
|
754
|
-
*/
|
|
755
|
-
/**
|
|
756
741
|
* SSKR format handler.
|
|
757
742
|
* Round-trippable: sskr shares → seed → sskr shares.
|
|
758
743
|
* Supports multiple sub-formats: envelope, btw, btwm, btwu, ur.
|
|
@@ -777,15 +762,15 @@ var SSKRFormat = class {
|
|
|
777
762
|
};
|
|
778
763
|
function outputSskrSeed(seed, spec, format) {
|
|
779
764
|
switch (format) {
|
|
780
|
-
case
|
|
765
|
+
case "envelope": {
|
|
781
766
|
const seedEnvelope = seed.toEnvelope();
|
|
782
767
|
const contentKey = SymmetricKey.new();
|
|
783
768
|
return seedEnvelope.wrap().encryptSubject(contentKey).sskrSplitFlattened(spec, contentKey).map((env) => env.urString()).join("\n");
|
|
784
769
|
}
|
|
785
|
-
case
|
|
786
|
-
case
|
|
787
|
-
case
|
|
788
|
-
case
|
|
770
|
+
case "btw": return makeBytewordsShares(spec, seed, BytewordsStyle.Standard);
|
|
771
|
+
case "btwm": return makeBytewordsShares(spec, seed, BytewordsStyle.Minimal);
|
|
772
|
+
case "btwu": return makeBytewordsShares(spec, seed, BytewordsStyle.Uri);
|
|
773
|
+
case "ur": return makeShares(spec, seed).map((share) => {
|
|
789
774
|
return UR.new("sskr", toByteString(share.asBytes())).toString();
|
|
790
775
|
}).join("\n");
|
|
791
776
|
}
|
|
@@ -895,7 +880,6 @@ function parseSskrSeed(input) {
|
|
|
895
880
|
if (urLegacyResult !== null) return urLegacyResult;
|
|
896
881
|
throw new Error("Insufficient or invalid SSKR shares.");
|
|
897
882
|
}
|
|
898
|
-
|
|
899
883
|
//#endregion
|
|
900
884
|
//#region src/formats/envelope.ts
|
|
901
885
|
/**
|
|
@@ -919,7 +903,6 @@ var EnvelopeFormat = class {
|
|
|
919
903
|
return state.toEnvelope().urString();
|
|
920
904
|
}
|
|
921
905
|
};
|
|
922
|
-
|
|
923
906
|
//#endregion
|
|
924
907
|
//#region src/formats/seed-format.ts
|
|
925
908
|
/**
|
|
@@ -944,7 +927,6 @@ var SeedFormat = class {
|
|
|
944
927
|
return state.seedWithOverrides().toComponentsSeed().urString();
|
|
945
928
|
}
|
|
946
929
|
};
|
|
947
|
-
|
|
948
930
|
//#endregion
|
|
949
931
|
//#region src/formats/multipart.ts
|
|
950
932
|
/**
|
|
@@ -981,7 +963,6 @@ var MultipartFormat = class {
|
|
|
981
963
|
return parts.join("\n");
|
|
982
964
|
}
|
|
983
965
|
};
|
|
984
|
-
|
|
985
966
|
//#endregion
|
|
986
967
|
//#region src/formats/random.ts
|
|
987
968
|
/**
|
|
@@ -1001,7 +982,6 @@ var RandomFormat = class {
|
|
|
1001
982
|
return state;
|
|
1002
983
|
}
|
|
1003
984
|
};
|
|
1004
|
-
|
|
1005
985
|
//#endregion
|
|
1006
986
|
//#region src/formats/base6.ts
|
|
1007
987
|
/**
|
|
@@ -1027,7 +1007,6 @@ var Base6Format = class {
|
|
|
1027
1007
|
return dataToInts(state.expectSeed().data(), 0, 5, "");
|
|
1028
1008
|
}
|
|
1029
1009
|
};
|
|
1030
|
-
|
|
1031
1010
|
//#endregion
|
|
1032
1011
|
//#region src/formats/base10.ts
|
|
1033
1012
|
/**
|
|
@@ -1053,7 +1032,6 @@ var Base10Format = class {
|
|
|
1053
1032
|
return dataToInts(state.expectSeed().data(), 0, 9, "");
|
|
1054
1033
|
}
|
|
1055
1034
|
};
|
|
1056
|
-
|
|
1057
1035
|
//#endregion
|
|
1058
1036
|
//#region src/formats/bits.ts
|
|
1059
1037
|
/**
|
|
@@ -1079,7 +1057,6 @@ var BitsFormat = class {
|
|
|
1079
1057
|
return dataToInts(state.expectSeed().data(), 0, 1, "");
|
|
1080
1058
|
}
|
|
1081
1059
|
};
|
|
1082
|
-
|
|
1083
1060
|
//#endregion
|
|
1084
1061
|
//#region src/formats/dice.ts
|
|
1085
1062
|
/**
|
|
@@ -1105,7 +1082,6 @@ var DiceFormat = class {
|
|
|
1105
1082
|
return dataToInts(state.expectSeed().data(), 1, 6, "");
|
|
1106
1083
|
}
|
|
1107
1084
|
};
|
|
1108
|
-
|
|
1109
1085
|
//#endregion
|
|
1110
1086
|
//#region src/formats/cards.ts
|
|
1111
1087
|
const CARD_SUITS = "cdhs";
|
|
@@ -1175,7 +1151,6 @@ var CardsFormat = class {
|
|
|
1175
1151
|
return dataToAlphabet(state.expectSeed().data(), 52, toCard);
|
|
1176
1152
|
}
|
|
1177
1153
|
};
|
|
1178
|
-
|
|
1179
1154
|
//#endregion
|
|
1180
1155
|
//#region src/formats/ints.ts
|
|
1181
1156
|
/**
|
|
@@ -1199,7 +1174,6 @@ var IntsFormat = class {
|
|
|
1199
1174
|
return dataToInts(state.expectSeed().data(), state.low, state.high, " ");
|
|
1200
1175
|
}
|
|
1201
1176
|
};
|
|
1202
|
-
|
|
1203
1177
|
//#endregion
|
|
1204
1178
|
//#region src/formats/bytewords-standard.ts
|
|
1205
1179
|
/**
|
|
@@ -1223,7 +1197,6 @@ var BytewordsStandardFormat = class {
|
|
|
1223
1197
|
return encodeBytewords(state.expectSeed().data(), BytewordsStyle.Standard);
|
|
1224
1198
|
}
|
|
1225
1199
|
};
|
|
1226
|
-
|
|
1227
1200
|
//#endregion
|
|
1228
1201
|
//#region src/formats/bytewords-minimal.ts
|
|
1229
1202
|
/**
|
|
@@ -1247,7 +1220,6 @@ var BytewordsMinimalFormat = class {
|
|
|
1247
1220
|
return encodeBytewords(state.expectSeed().data(), BytewordsStyle.Minimal);
|
|
1248
1221
|
}
|
|
1249
1222
|
};
|
|
1250
|
-
|
|
1251
1223
|
//#endregion
|
|
1252
1224
|
//#region src/formats/bytewords-uri.ts
|
|
1253
1225
|
/**
|
|
@@ -1271,39 +1243,30 @@ var BytewordsUriFormat = class {
|
|
|
1271
1243
|
return encodeBytewords(state.expectSeed().data(), BytewordsStyle.Uri);
|
|
1272
1244
|
}
|
|
1273
1245
|
};
|
|
1274
|
-
|
|
1275
1246
|
//#endregion
|
|
1276
1247
|
//#region src/formats/format.ts
|
|
1277
1248
|
/**
|
|
1278
|
-
* Copyright © 2023-2026 Blockchain Commons, LLC
|
|
1279
|
-
* Copyright © 2025-2026 Parity Technologies
|
|
1280
|
-
*
|
|
1281
|
-
*
|
|
1282
|
-
* Format traits and factory functions
|
|
1283
|
-
* Ported from seedtool-cli-rust/src/formats/format.rs
|
|
1284
|
-
*/
|
|
1285
|
-
/**
|
|
1286
1249
|
* Select input format by key.
|
|
1287
1250
|
* Matches Rust select_input_format function.
|
|
1288
1251
|
*/
|
|
1289
1252
|
function selectInputFormat(key) {
|
|
1290
1253
|
switch (key) {
|
|
1291
|
-
case
|
|
1292
|
-
case
|
|
1293
|
-
case
|
|
1294
|
-
case
|
|
1295
|
-
case
|
|
1296
|
-
case
|
|
1297
|
-
case
|
|
1298
|
-
case
|
|
1299
|
-
case
|
|
1300
|
-
case
|
|
1301
|
-
case
|
|
1302
|
-
case
|
|
1303
|
-
case
|
|
1304
|
-
case
|
|
1305
|
-
case
|
|
1306
|
-
case
|
|
1254
|
+
case "random": return new RandomFormat();
|
|
1255
|
+
case "hex": return new HexFormat();
|
|
1256
|
+
case "btw": return new BytewordsStandardFormat();
|
|
1257
|
+
case "btwu": return new BytewordsUriFormat();
|
|
1258
|
+
case "btwm": return new BytewordsMinimalFormat();
|
|
1259
|
+
case "bits": return new BitsFormat();
|
|
1260
|
+
case "cards": return new CardsFormat();
|
|
1261
|
+
case "dice": return new DiceFormat();
|
|
1262
|
+
case "base6": return new Base6Format();
|
|
1263
|
+
case "base10": return new Base10Format();
|
|
1264
|
+
case "ints": return new IntsFormat();
|
|
1265
|
+
case "bip39": return new Bip39Format();
|
|
1266
|
+
case "sskr": return new SSKRFormat();
|
|
1267
|
+
case "envelope": return new EnvelopeFormat();
|
|
1268
|
+
case "multipart": return new MultipartFormat();
|
|
1269
|
+
case "seed": return new SeedFormat();
|
|
1307
1270
|
}
|
|
1308
1271
|
}
|
|
1309
1272
|
/**
|
|
@@ -1312,24 +1275,24 @@ function selectInputFormat(key) {
|
|
|
1312
1275
|
*/
|
|
1313
1276
|
function selectOutputFormat(key) {
|
|
1314
1277
|
switch (key) {
|
|
1315
|
-
case
|
|
1316
|
-
case
|
|
1317
|
-
case
|
|
1318
|
-
case
|
|
1319
|
-
case
|
|
1320
|
-
case
|
|
1321
|
-
case
|
|
1322
|
-
case
|
|
1323
|
-
case
|
|
1324
|
-
case
|
|
1325
|
-
case
|
|
1326
|
-
case
|
|
1327
|
-
case
|
|
1328
|
-
case
|
|
1329
|
-
case
|
|
1278
|
+
case "hex": return new HexFormat();
|
|
1279
|
+
case "btw": return new BytewordsStandardFormat();
|
|
1280
|
+
case "btwu": return new BytewordsUriFormat();
|
|
1281
|
+
case "btwm": return new BytewordsMinimalFormat();
|
|
1282
|
+
case "bits": return new BitsFormat();
|
|
1283
|
+
case "cards": return new CardsFormat();
|
|
1284
|
+
case "dice": return new DiceFormat();
|
|
1285
|
+
case "base6": return new Base6Format();
|
|
1286
|
+
case "base10": return new Base10Format();
|
|
1287
|
+
case "ints": return new IntsFormat();
|
|
1288
|
+
case "bip39": return new Bip39Format();
|
|
1289
|
+
case "sskr": return new SSKRFormat();
|
|
1290
|
+
case "envelope": return new EnvelopeFormat();
|
|
1291
|
+
case "multipart": return new MultipartFormat();
|
|
1292
|
+
case "seed": return new SeedFormat();
|
|
1330
1293
|
}
|
|
1331
1294
|
}
|
|
1332
|
-
|
|
1333
1295
|
//#endregion
|
|
1334
1296
|
export { Base10Format, Base6Format, Bip39Format, BitsFormat, BytewordsMinimalFormat, BytewordsStandardFormat, BytewordsUriFormat, CardsFormat, Cli, DeterministicRandomNumberGenerator, DiceFormat, EnvelopeFormat, HexFormat, InputFormatKey, IntsFormat, MultipartFormat, OutputFormatKey, RandomFormat, SSKRFormat, SSKRFormatKey, Seed, SeedFormat, dataToAlphabet, dataToBase, dataToHex, dataToInts, deterministicRandom, digitsToData, hexToData, hkdfHmacSha256, parseDate, parseGroupSpec, parseGroupThreshold, parseHighInt, parseInts, parseLowInt, selectInputFormat, selectOutputFormat, sha256DeterministicRandom };
|
|
1297
|
+
|
|
1335
1298
|
//# sourceMappingURL=index.mjs.map
|