@tinycloud/cli 0.9.1-beta.9 → 0.10.0
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 +8 -8
- package/dist/index.js +1355 -1302
- package/dist/index.js.map +1 -1
- package/dist/legacy-entry.js +698 -1419
- package/dist/legacy-entry.js.map +1 -1
- package/package.json +11 -7
- package/skills/tc-cli/AUTH.md +24 -0
- package/skills/tc-cli/INSTALL.md +26 -0
- package/skills/tc-cli/REFERENCE.md +166 -0
- package/skills/tc-cli/SDK.md +11 -0
- package/skills/tc-cli/SKILL.md +44 -0
- package/skills/tc-cli/release.json +16 -0
package/dist/legacy-entry.js
CHANGED
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
tinycloudConfigPath,
|
|
38
38
|
tinycloudHomePath
|
|
39
39
|
} from "@tinycloud/operations/state";
|
|
40
|
-
var CONFIG_DIR, PROFILES_DIR, CONFIG_FILE, DEFAULT_HOST, DEFAULT_OPENKEY_HOST,
|
|
40
|
+
var CONFIG_DIR, PROFILES_DIR, CONFIG_FILE, DEFAULT_HOST, DEFAULT_OPENKEY_HOST, DEFAULT_PROFILE, DEFAULT_CHAIN_ID, ExitCode;
|
|
41
41
|
var init_constants = __esm({
|
|
42
42
|
"src/config/constants.ts"() {
|
|
43
43
|
"use strict";
|
|
@@ -46,7 +46,6 @@ var init_constants = __esm({
|
|
|
46
46
|
CONFIG_FILE = tinycloudConfigPath();
|
|
47
47
|
DEFAULT_HOST = "https://node.tinycloud.xyz";
|
|
48
48
|
DEFAULT_OPENKEY_HOST = "https://openkey.so";
|
|
49
|
-
DEFAULT_OPENKEY_DEVICE_API_HOST = "https://api.openkey.so";
|
|
50
49
|
DEFAULT_PROFILE = "default";
|
|
51
50
|
DEFAULT_CHAIN_ID = 1;
|
|
52
51
|
ExitCode = {
|
|
@@ -219,13 +218,6 @@ function formatTable(headers, rows) {
|
|
|
219
218
|
);
|
|
220
219
|
return [headerLine, separator, ...dataLines].join("\n");
|
|
221
220
|
}
|
|
222
|
-
function output(data, humanFormatter) {
|
|
223
|
-
if (shouldOutputJson() || !humanFormatter) {
|
|
224
|
-
outputJson(data);
|
|
225
|
-
} else {
|
|
226
|
-
process.stdout.write(humanFormatter() + "\n");
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
221
|
function formatCheck(ok2, label, detail) {
|
|
230
222
|
const icon = ok2 === "warn" ? theme.warn("\u26A0") : ok2 ? theme.success("\u2713") : theme.error("\u2717");
|
|
231
223
|
const detailStr = detail ? ` ${theme.muted(`(${detail})`)}` : "";
|
|
@@ -376,14 +368,17 @@ var init_errors = __esm({
|
|
|
376
368
|
this.metadata = metadata;
|
|
377
369
|
this.name = "CLIError";
|
|
378
370
|
}
|
|
371
|
+
code;
|
|
372
|
+
exitCode;
|
|
373
|
+
metadata;
|
|
379
374
|
};
|
|
380
375
|
}
|
|
381
376
|
});
|
|
382
377
|
|
|
383
|
-
//
|
|
378
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/util.js
|
|
384
379
|
var util, objectUtil, ZodParsedType, getParsedType;
|
|
385
380
|
var init_util = __esm({
|
|
386
|
-
"
|
|
381
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/util.js"() {
|
|
387
382
|
"use strict";
|
|
388
383
|
(function(util3) {
|
|
389
384
|
util3.assertEqual = (_) => {
|
|
@@ -415,10 +410,10 @@ var init_util = __esm({
|
|
|
415
410
|
return obj[e];
|
|
416
411
|
});
|
|
417
412
|
};
|
|
418
|
-
util3.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (
|
|
413
|
+
util3.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
419
414
|
const keys = [];
|
|
420
|
-
for (const key in
|
|
421
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
415
|
+
for (const key in object) {
|
|
416
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
422
417
|
keys.push(key);
|
|
423
418
|
}
|
|
424
419
|
}
|
|
@@ -518,10 +513,10 @@ var init_util = __esm({
|
|
|
518
513
|
}
|
|
519
514
|
});
|
|
520
515
|
|
|
521
|
-
//
|
|
516
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/ZodError.js
|
|
522
517
|
var ZodIssueCode, quotelessJson, ZodError;
|
|
523
518
|
var init_ZodError = __esm({
|
|
524
|
-
"
|
|
519
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/ZodError.js"() {
|
|
525
520
|
"use strict";
|
|
526
521
|
init_util();
|
|
527
522
|
ZodIssueCode = util.arrayToEnum([
|
|
@@ -643,10 +638,10 @@ var init_ZodError = __esm({
|
|
|
643
638
|
}
|
|
644
639
|
});
|
|
645
640
|
|
|
646
|
-
//
|
|
641
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/locales/en.js
|
|
647
642
|
var errorMap, en_default;
|
|
648
643
|
var init_en = __esm({
|
|
649
|
-
"
|
|
644
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/locales/en.js"() {
|
|
650
645
|
"use strict";
|
|
651
646
|
init_ZodError();
|
|
652
647
|
init_util();
|
|
@@ -754,7 +749,7 @@ var init_en = __esm({
|
|
|
754
749
|
}
|
|
755
750
|
});
|
|
756
751
|
|
|
757
|
-
//
|
|
752
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/errors.js
|
|
758
753
|
function setErrorMap(map) {
|
|
759
754
|
overrideErrorMap = map;
|
|
760
755
|
}
|
|
@@ -763,14 +758,14 @@ function getErrorMap() {
|
|
|
763
758
|
}
|
|
764
759
|
var overrideErrorMap;
|
|
765
760
|
var init_errors2 = __esm({
|
|
766
|
-
"
|
|
761
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/errors.js"() {
|
|
767
762
|
"use strict";
|
|
768
763
|
init_en();
|
|
769
764
|
overrideErrorMap = en_default;
|
|
770
765
|
}
|
|
771
766
|
});
|
|
772
767
|
|
|
773
|
-
//
|
|
768
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/parseUtil.js
|
|
774
769
|
function addIssueToContext(ctx, issueData) {
|
|
775
770
|
const overrideMap = getErrorMap();
|
|
776
771
|
const issue = makeIssue({
|
|
@@ -792,7 +787,7 @@ function addIssueToContext(ctx, issueData) {
|
|
|
792
787
|
}
|
|
793
788
|
var makeIssue, EMPTY_PATH, ParseStatus, INVALID, DIRTY, OK, isAborted, isDirty, isValid, isAsync;
|
|
794
789
|
var init_parseUtil = __esm({
|
|
795
|
-
"
|
|
790
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/parseUtil.js"() {
|
|
796
791
|
"use strict";
|
|
797
792
|
init_errors2();
|
|
798
793
|
init_en();
|
|
@@ -888,17 +883,17 @@ var init_parseUtil = __esm({
|
|
|
888
883
|
}
|
|
889
884
|
});
|
|
890
885
|
|
|
891
|
-
//
|
|
886
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/typeAliases.js
|
|
892
887
|
var init_typeAliases = __esm({
|
|
893
|
-
"
|
|
888
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/typeAliases.js"() {
|
|
894
889
|
"use strict";
|
|
895
890
|
}
|
|
896
891
|
});
|
|
897
892
|
|
|
898
|
-
//
|
|
893
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/errorUtil.js
|
|
899
894
|
var errorUtil;
|
|
900
895
|
var init_errorUtil = __esm({
|
|
901
|
-
"
|
|
896
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/helpers/errorUtil.js"() {
|
|
902
897
|
"use strict";
|
|
903
898
|
(function(errorUtil3) {
|
|
904
899
|
errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
@@ -907,7 +902,7 @@ var init_errorUtil = __esm({
|
|
|
907
902
|
}
|
|
908
903
|
});
|
|
909
904
|
|
|
910
|
-
//
|
|
905
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/types.js
|
|
911
906
|
function processCreateParams(params) {
|
|
912
907
|
if (!params)
|
|
913
908
|
return {};
|
|
@@ -1101,7 +1096,7 @@ function custom(check, _params = {}, fatal) {
|
|
|
1101
1096
|
}
|
|
1102
1097
|
var ParseInputLazyPath, handleResult, ZodType, cuidRegex, cuid2Regex, ulidRegex, uuidRegex, nanoidRegex, jwtRegex, durationRegex, emailRegex, _emojiRegex, emojiRegex, ipv4Regex, ipv4CidrRegex, ipv6Regex, ipv6CidrRegex, base64Regex, base64urlRegex, dateRegexSource, dateRegex, ZodString, ZodNumber, ZodBigInt, ZodBoolean, ZodDate, ZodSymbol, ZodUndefined, ZodNull, ZodAny, ZodUnknown, ZodNever, ZodVoid, ZodArray, ZodObject, ZodUnion, getDiscriminator, ZodDiscriminatedUnion, ZodIntersection, ZodTuple, ZodRecord, ZodMap, ZodSet, ZodFunction, ZodLazy, ZodLiteral, ZodEnum, ZodNativeEnum, ZodPromise, ZodEffects, ZodOptional, ZodNullable, ZodDefault, ZodCatch, ZodNaN, BRAND, ZodBranded, ZodPipeline, ZodReadonly, late, ZodFirstPartyTypeKind, instanceOfType, stringType, numberType, nanType, bigIntType, booleanType, dateType, symbolType, undefinedType, nullType, anyType, unknownType, neverType, voidType, arrayType, objectType, strictObjectType, unionType, discriminatedUnionType, intersectionType, tupleType, recordType, mapType, setType, functionType, lazyType, literalType, enumType, nativeEnumType, promiseType, effectsType, optionalType, nullableType, preprocessType, pipelineType, ostring, onumber, oboolean, coerce, NEVER;
|
|
1103
1098
|
var init_types = __esm({
|
|
1104
|
-
"
|
|
1099
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/types.js"() {
|
|
1105
1100
|
"use strict";
|
|
1106
1101
|
init_ZodError();
|
|
1107
1102
|
init_errors2();
|
|
@@ -4364,7 +4359,7 @@ var init_types = __esm({
|
|
|
4364
4359
|
}
|
|
4365
4360
|
});
|
|
4366
4361
|
|
|
4367
|
-
//
|
|
4362
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/external.js
|
|
4368
4363
|
var external_exports = {};
|
|
4369
4364
|
__export(external_exports, {
|
|
4370
4365
|
BRAND: () => BRAND,
|
|
@@ -4476,7 +4471,7 @@ __export(external_exports, {
|
|
|
4476
4471
|
void: () => voidType
|
|
4477
4472
|
});
|
|
4478
4473
|
var init_external = __esm({
|
|
4479
|
-
"
|
|
4474
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/v3/external.js"() {
|
|
4480
4475
|
"use strict";
|
|
4481
4476
|
init_errors2();
|
|
4482
4477
|
init_parseUtil();
|
|
@@ -4487,26 +4482,26 @@ var init_external = __esm({
|
|
|
4487
4482
|
}
|
|
4488
4483
|
});
|
|
4489
4484
|
|
|
4490
|
-
//
|
|
4485
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/index.js
|
|
4491
4486
|
var init_zod = __esm({
|
|
4492
|
-
"
|
|
4487
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/zod/index.js"() {
|
|
4493
4488
|
"use strict";
|
|
4494
4489
|
init_external();
|
|
4495
4490
|
init_external();
|
|
4496
4491
|
}
|
|
4497
4492
|
});
|
|
4498
4493
|
|
|
4499
|
-
//
|
|
4494
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/cryptoNode.js
|
|
4500
4495
|
import * as nc from "crypto";
|
|
4501
4496
|
var crypto2;
|
|
4502
4497
|
var init_cryptoNode = __esm({
|
|
4503
|
-
"
|
|
4498
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/cryptoNode.js"() {
|
|
4504
4499
|
"use strict";
|
|
4505
4500
|
crypto2 = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
|
|
4506
4501
|
}
|
|
4507
4502
|
});
|
|
4508
4503
|
|
|
4509
|
-
//
|
|
4504
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/utils.js
|
|
4510
4505
|
function isBytes(a) {
|
|
4511
4506
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
4512
4507
|
}
|
|
@@ -4539,9 +4534,6 @@ function aoutput(out, instance) {
|
|
|
4539
4534
|
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
4540
4535
|
}
|
|
4541
4536
|
}
|
|
4542
|
-
function u8(arr) {
|
|
4543
|
-
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
4544
|
-
}
|
|
4545
4537
|
function u32(arr) {
|
|
4546
4538
|
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
|
4547
4539
|
}
|
|
@@ -4569,11 +4561,11 @@ function bytesToHex(bytes) {
|
|
|
4569
4561
|
abytes(bytes);
|
|
4570
4562
|
if (hasHexBuiltin)
|
|
4571
4563
|
return bytes.toHex();
|
|
4572
|
-
let
|
|
4564
|
+
let hex = "";
|
|
4573
4565
|
for (let i = 0; i < bytes.length; i++) {
|
|
4574
|
-
|
|
4566
|
+
hex += hexes[bytes[i]];
|
|
4575
4567
|
}
|
|
4576
|
-
return
|
|
4568
|
+
return hex;
|
|
4577
4569
|
}
|
|
4578
4570
|
function asciiToBase16(ch) {
|
|
4579
4571
|
if (ch >= asciis._0 && ch <= asciis._9)
|
|
@@ -4584,21 +4576,21 @@ function asciiToBase16(ch) {
|
|
|
4584
4576
|
return ch - (asciis.a - 10);
|
|
4585
4577
|
return;
|
|
4586
4578
|
}
|
|
4587
|
-
function hexToBytes(
|
|
4588
|
-
if (typeof
|
|
4589
|
-
throw new Error("hex string expected, got " + typeof
|
|
4579
|
+
function hexToBytes(hex) {
|
|
4580
|
+
if (typeof hex !== "string")
|
|
4581
|
+
throw new Error("hex string expected, got " + typeof hex);
|
|
4590
4582
|
if (hasHexBuiltin)
|
|
4591
|
-
return Uint8Array.fromHex(
|
|
4592
|
-
const hl =
|
|
4583
|
+
return Uint8Array.fromHex(hex);
|
|
4584
|
+
const hl = hex.length;
|
|
4593
4585
|
const al = hl / 2;
|
|
4594
4586
|
if (hl % 2)
|
|
4595
4587
|
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
4596
4588
|
const array = new Uint8Array(al);
|
|
4597
4589
|
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
4598
|
-
const n1 = asciiToBase16(
|
|
4599
|
-
const n2 = asciiToBase16(
|
|
4590
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
|
4591
|
+
const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
|
|
4600
4592
|
if (n1 === void 0 || n2 === void 0) {
|
|
4601
|
-
const char =
|
|
4593
|
+
const char = hex[hi] + hex[hi + 1];
|
|
4602
4594
|
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
4603
4595
|
}
|
|
4604
4596
|
array[ai] = n1 * 16 + n2;
|
|
@@ -4639,14 +4631,6 @@ function createHasher(hashCons) {
|
|
|
4639
4631
|
hashC.create = () => hashCons();
|
|
4640
4632
|
return hashC;
|
|
4641
4633
|
}
|
|
4642
|
-
function createXOFer(hashCons) {
|
|
4643
|
-
const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
|
|
4644
|
-
const tmp = hashCons({});
|
|
4645
|
-
hashC.outputLen = tmp.outputLen;
|
|
4646
|
-
hashC.blockLen = tmp.blockLen;
|
|
4647
|
-
hashC.create = (opts) => hashCons(opts);
|
|
4648
|
-
return hashC;
|
|
4649
|
-
}
|
|
4650
4634
|
function randomBytes(bytesLength = 32) {
|
|
4651
4635
|
if (crypto2 && typeof crypto2.getRandomValues === "function") {
|
|
4652
4636
|
return crypto2.getRandomValues(new Uint8Array(bytesLength));
|
|
@@ -4656,13 +4640,12 @@ function randomBytes(bytesLength = 32) {
|
|
|
4656
4640
|
}
|
|
4657
4641
|
throw new Error("crypto.getRandomValues must be defined");
|
|
4658
4642
|
}
|
|
4659
|
-
var isLE,
|
|
4643
|
+
var isLE, swap32IfBE, hasHexBuiltin, hexes, asciis, Hash;
|
|
4660
4644
|
var init_utils = __esm({
|
|
4661
|
-
"
|
|
4645
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/utils.js"() {
|
|
4662
4646
|
"use strict";
|
|
4663
4647
|
init_cryptoNode();
|
|
4664
4648
|
isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
|
4665
|
-
swap8IfBE = isLE ? (n) => n : (n) => byteSwap(n);
|
|
4666
4649
|
swap32IfBE = isLE ? (u) => u : byteSwap32;
|
|
4667
4650
|
hasHexBuiltin = /* @__PURE__ */ (() => (
|
|
4668
4651
|
// @ts-ignore
|
|
@@ -4675,7 +4658,7 @@ var init_utils = __esm({
|
|
|
4675
4658
|
}
|
|
4676
4659
|
});
|
|
4677
4660
|
|
|
4678
|
-
//
|
|
4661
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/_md.js
|
|
4679
4662
|
function setBigUint64(view, byteOffset, value, isLE2) {
|
|
4680
4663
|
if (typeof view.setBigUint64 === "function")
|
|
4681
4664
|
return view.setBigUint64(byteOffset, value, isLE2);
|
|
@@ -4696,7 +4679,7 @@ function Maj(a, b, c) {
|
|
|
4696
4679
|
}
|
|
4697
4680
|
var HashMD, SHA256_IV, SHA512_IV;
|
|
4698
4681
|
var init_md = __esm({
|
|
4699
|
-
"
|
|
4682
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/_md.js"() {
|
|
4700
4683
|
"use strict";
|
|
4701
4684
|
init_utils();
|
|
4702
4685
|
HashMD = class extends Hash {
|
|
@@ -4820,7 +4803,7 @@ var init_md = __esm({
|
|
|
4820
4803
|
}
|
|
4821
4804
|
});
|
|
4822
4805
|
|
|
4823
|
-
//
|
|
4806
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/_u64.js
|
|
4824
4807
|
function fromBig(n, le = false) {
|
|
4825
4808
|
if (le)
|
|
4826
4809
|
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
@@ -4842,7 +4825,7 @@ function add(Ah, Al, Bh, Bl) {
|
|
|
4842
4825
|
}
|
|
4843
4826
|
var U32_MASK64, _32n, shrSH, shrSL, rotrSH, rotrSL, rotrBH, rotrBL, rotlSH, rotlSL, rotlBH, rotlBL, add3L, add3H, add4L, add4H, add5L, add5H;
|
|
4844
4827
|
var init_u64 = __esm({
|
|
4845
|
-
"
|
|
4828
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/_u64.js"() {
|
|
4846
4829
|
"use strict";
|
|
4847
4830
|
U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
4848
4831
|
_32n = /* @__PURE__ */ BigInt(32);
|
|
@@ -4865,10 +4848,10 @@ var init_u64 = __esm({
|
|
|
4865
4848
|
}
|
|
4866
4849
|
});
|
|
4867
4850
|
|
|
4868
|
-
//
|
|
4851
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/sha2.js
|
|
4869
4852
|
var SHA256_K, SHA256_W, SHA256, K512, SHA512_Kh, SHA512_Kl, SHA512_W_H, SHA512_W_L, SHA512, sha256, sha512;
|
|
4870
4853
|
var init_sha2 = __esm({
|
|
4871
|
-
"
|
|
4854
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/sha2.js"() {
|
|
4872
4855
|
"use strict";
|
|
4873
4856
|
init_md();
|
|
4874
4857
|
init_u64();
|
|
@@ -5212,7 +5195,7 @@ var init_sha2 = __esm({
|
|
|
5212
5195
|
}
|
|
5213
5196
|
});
|
|
5214
5197
|
|
|
5215
|
-
//
|
|
5198
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/utils.js
|
|
5216
5199
|
function _abool2(value, title = "") {
|
|
5217
5200
|
if (typeof value !== "boolean") {
|
|
5218
5201
|
const prefix = title && `"${title}"`;
|
|
@@ -5232,10 +5215,10 @@ function _abytes2(value, length4, title = "") {
|
|
|
5232
5215
|
}
|
|
5233
5216
|
return value;
|
|
5234
5217
|
}
|
|
5235
|
-
function hexToNumber(
|
|
5236
|
-
if (typeof
|
|
5237
|
-
throw new Error("hex string expected, got " + typeof
|
|
5238
|
-
return
|
|
5218
|
+
function hexToNumber(hex) {
|
|
5219
|
+
if (typeof hex !== "string")
|
|
5220
|
+
throw new Error("hex string expected, got " + typeof hex);
|
|
5221
|
+
return hex === "" ? _0n : BigInt("0x" + hex);
|
|
5239
5222
|
}
|
|
5240
5223
|
function bytesToNumberBE(bytes) {
|
|
5241
5224
|
return hexToNumber(bytesToHex(bytes));
|
|
@@ -5250,16 +5233,16 @@ function numberToBytesBE(n, len) {
|
|
|
5250
5233
|
function numberToBytesLE(n, len) {
|
|
5251
5234
|
return numberToBytesBE(n, len).reverse();
|
|
5252
5235
|
}
|
|
5253
|
-
function ensureBytes(title,
|
|
5236
|
+
function ensureBytes(title, hex, expectedLength) {
|
|
5254
5237
|
let res;
|
|
5255
|
-
if (typeof
|
|
5238
|
+
if (typeof hex === "string") {
|
|
5256
5239
|
try {
|
|
5257
|
-
res = hexToBytes(
|
|
5240
|
+
res = hexToBytes(hex);
|
|
5258
5241
|
} catch (e) {
|
|
5259
5242
|
throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
|
|
5260
5243
|
}
|
|
5261
|
-
} else if (isBytes(
|
|
5262
|
-
res = Uint8Array.from(
|
|
5244
|
+
} else if (isBytes(hex)) {
|
|
5245
|
+
res = Uint8Array.from(hex);
|
|
5263
5246
|
} else {
|
|
5264
5247
|
throw new Error(title + " must be hex string or Uint8Array");
|
|
5265
5248
|
}
|
|
@@ -5292,11 +5275,11 @@ function bitLen(n) {
|
|
|
5292
5275
|
;
|
|
5293
5276
|
return len;
|
|
5294
5277
|
}
|
|
5295
|
-
function _validateObject(
|
|
5296
|
-
if (!
|
|
5278
|
+
function _validateObject(object, fields, optFields = {}) {
|
|
5279
|
+
if (!object || typeof object !== "object")
|
|
5297
5280
|
throw new Error("expected valid options object");
|
|
5298
5281
|
function checkField(fieldName, expectedType, isOpt) {
|
|
5299
|
-
const val =
|
|
5282
|
+
const val = object[fieldName];
|
|
5300
5283
|
if (isOpt && val === void 0)
|
|
5301
5284
|
return;
|
|
5302
5285
|
const current = typeof val;
|
|
@@ -5319,7 +5302,7 @@ function memoized(fn) {
|
|
|
5319
5302
|
}
|
|
5320
5303
|
var _0n, _1n, isPosBig, bitMask, notImplemented;
|
|
5321
5304
|
var init_utils2 = __esm({
|
|
5322
|
-
"
|
|
5305
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/utils.js"() {
|
|
5323
5306
|
"use strict";
|
|
5324
5307
|
init_utils();
|
|
5325
5308
|
init_utils();
|
|
@@ -5333,7 +5316,7 @@ var init_utils2 = __esm({
|
|
|
5333
5316
|
}
|
|
5334
5317
|
});
|
|
5335
5318
|
|
|
5336
|
-
//
|
|
5319
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/modular.js
|
|
5337
5320
|
function mod(a, b) {
|
|
5338
5321
|
const result = a % b;
|
|
5339
5322
|
return result >= _0n2 ? result : b + result;
|
|
@@ -5630,7 +5613,7 @@ function Field(ORDER, bitLenOrOpts, isLE2 = false, opts = {}) {
|
|
|
5630
5613
|
}
|
|
5631
5614
|
var _0n2, _1n2, _2n, _3n, _4n, _5n, _7n, _8n, _9n, _16n, isNegativeLE, FIELD_FIELDS;
|
|
5632
5615
|
var init_modular = __esm({
|
|
5633
|
-
"
|
|
5616
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/modular.js"() {
|
|
5634
5617
|
"use strict";
|
|
5635
5618
|
init_utils2();
|
|
5636
5619
|
_0n2 = BigInt(0);
|
|
@@ -5666,7 +5649,7 @@ var init_modular = __esm({
|
|
|
5666
5649
|
}
|
|
5667
5650
|
});
|
|
5668
5651
|
|
|
5669
|
-
//
|
|
5652
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/curve.js
|
|
5670
5653
|
function negateCt(condition, item) {
|
|
5671
5654
|
const neg = item.negate();
|
|
5672
5655
|
return condition ? neg : item;
|
|
@@ -5799,7 +5782,7 @@ function _createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
|
|
|
5799
5782
|
}
|
|
5800
5783
|
var _0n3, _1n3, pointPrecomputes, pointWindowSizes, wNAF;
|
|
5801
5784
|
var init_curve = __esm({
|
|
5802
|
-
"
|
|
5785
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/curve.js"() {
|
|
5803
5786
|
"use strict";
|
|
5804
5787
|
init_utils2();
|
|
5805
5788
|
init_modular();
|
|
@@ -5937,7 +5920,7 @@ var init_curve = __esm({
|
|
|
5937
5920
|
}
|
|
5938
5921
|
});
|
|
5939
5922
|
|
|
5940
|
-
//
|
|
5923
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/edwards.js
|
|
5941
5924
|
function isEdValidXY(Fp2, CURVE, x, y) {
|
|
5942
5925
|
const x2 = Fp2.sqr(x);
|
|
5943
5926
|
const y2 = Fp2.sqr(y);
|
|
@@ -6233,7 +6216,7 @@ function eddsa(Point2, cHash, eddsaOpts = {}) {
|
|
|
6233
6216
|
});
|
|
6234
6217
|
const { prehash } = eddsaOpts;
|
|
6235
6218
|
const { BASE, Fp: Fp2, Fn: Fn2 } = Point2;
|
|
6236
|
-
const
|
|
6219
|
+
const randomBytes5 = eddsaOpts.randomBytes || randomBytes;
|
|
6237
6220
|
const adjustScalarBytes2 = eddsaOpts.adjustScalarBytes || ((bytes) => bytes);
|
|
6238
6221
|
const domain = eddsaOpts.domain || ((data, ctx, phflag) => {
|
|
6239
6222
|
_abool2(phflag, "phflag");
|
|
@@ -6315,7 +6298,7 @@ function eddsa(Point2, cHash, eddsaOpts = {}) {
|
|
|
6315
6298
|
signature: 2 * _size,
|
|
6316
6299
|
seed: _size
|
|
6317
6300
|
};
|
|
6318
|
-
function randomSecretKey(seed =
|
|
6301
|
+
function randomSecretKey(seed = randomBytes5(lengths.seed)) {
|
|
6319
6302
|
return _abytes2(seed, lengths.seed, "seed");
|
|
6320
6303
|
}
|
|
6321
6304
|
function keygen(seed) {
|
|
@@ -6418,7 +6401,7 @@ function twistedEdwards(c) {
|
|
|
6418
6401
|
}
|
|
6419
6402
|
var _0n4, _1n4, _2n2, _8n2, PrimeEdwardsPoint;
|
|
6420
6403
|
var init_edwards = __esm({
|
|
6421
|
-
"
|
|
6404
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/abstract/edwards.js"() {
|
|
6422
6405
|
"use strict";
|
|
6423
6406
|
init_utils2();
|
|
6424
6407
|
init_curve();
|
|
@@ -6497,7 +6480,7 @@ var init_edwards = __esm({
|
|
|
6497
6480
|
}
|
|
6498
6481
|
});
|
|
6499
6482
|
|
|
6500
|
-
//
|
|
6483
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/ed25519.js
|
|
6501
6484
|
function ed25519_pow_2_252_3(x) {
|
|
6502
6485
|
const _10n = BigInt(10), _20n = BigInt(20), _40n = BigInt(40), _80n = BigInt(80);
|
|
6503
6486
|
const P = ed25519_CURVE_p;
|
|
@@ -6575,7 +6558,7 @@ function ristretto255_map(bytes) {
|
|
|
6575
6558
|
}
|
|
6576
6559
|
var _0n5, _1n5, _2n3, _3n2, _5n2, _8n3, ed25519_CURVE_p, ed25519_CURVE, ED25519_SQRT_M1, Fp, Fn, ed25519Defaults, ed25519, SQRT_M1, SQRT_AD_MINUS_ONE, INVSQRT_A_MINUS_D, ONE_MINUS_D_SQ, D_MINUS_ONE_SQ, invertSqrt, MAX_255B, bytes255ToNumberLE, _RistrettoPoint;
|
|
6577
6560
|
var init_ed25519 = __esm({
|
|
6578
|
-
"
|
|
6561
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/curves/esm/ed25519.js"() {
|
|
6579
6562
|
"use strict";
|
|
6580
6563
|
init_sha2();
|
|
6581
6564
|
init_utils();
|
|
@@ -6636,8 +6619,8 @@ var init_ed25519 = __esm({
|
|
|
6636
6619
|
return new __RistrettoPoint(ep);
|
|
6637
6620
|
}
|
|
6638
6621
|
/** @deprecated use `import { ristretto255_hasher } from '@noble/curves/ed25519.js';` */
|
|
6639
|
-
static hashToCurve(
|
|
6640
|
-
return ristretto255_map(ensureBytes("ristrettoHash",
|
|
6622
|
+
static hashToCurve(hex) {
|
|
6623
|
+
return ristretto255_map(ensureBytes("ristrettoHash", hex, 64));
|
|
6641
6624
|
}
|
|
6642
6625
|
static fromBytes(bytes) {
|
|
6643
6626
|
abytes(bytes, 32);
|
|
@@ -6670,8 +6653,8 @@ var init_ed25519 = __esm({
|
|
|
6670
6653
|
* Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-decode).
|
|
6671
6654
|
* @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
|
|
6672
6655
|
*/
|
|
6673
|
-
static fromHex(
|
|
6674
|
-
return __RistrettoPoint.fromBytes(ensureBytes("ristrettoHex",
|
|
6656
|
+
static fromHex(hex) {
|
|
6657
|
+
return __RistrettoPoint.fromBytes(ensureBytes("ristrettoHex", hex, 32));
|
|
6675
6658
|
}
|
|
6676
6659
|
static msm(points, scalars) {
|
|
6677
6660
|
return pippenger(__RistrettoPoint, ed25519.Point.Fn, points, scalars);
|
|
@@ -6732,7 +6715,7 @@ var init_ed25519 = __esm({
|
|
|
6732
6715
|
}
|
|
6733
6716
|
});
|
|
6734
6717
|
|
|
6735
|
-
//
|
|
6718
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/isHex.js
|
|
6736
6719
|
function isHex(value, { strict = true } = {}) {
|
|
6737
6720
|
if (!value)
|
|
6738
6721
|
return false;
|
|
@@ -6741,34 +6724,34 @@ function isHex(value, { strict = true } = {}) {
|
|
|
6741
6724
|
return strict ? /^0x[0-9a-fA-F]*$/.test(value) : value.startsWith("0x");
|
|
6742
6725
|
}
|
|
6743
6726
|
var init_isHex = __esm({
|
|
6744
|
-
"
|
|
6727
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/isHex.js"() {
|
|
6745
6728
|
"use strict";
|
|
6746
6729
|
}
|
|
6747
6730
|
});
|
|
6748
6731
|
|
|
6749
|
-
//
|
|
6732
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/size.js
|
|
6750
6733
|
function size(value) {
|
|
6751
6734
|
if (isHex(value, { strict: false }))
|
|
6752
6735
|
return Math.ceil((value.length - 2) / 2);
|
|
6753
6736
|
return value.length;
|
|
6754
6737
|
}
|
|
6755
6738
|
var init_size = __esm({
|
|
6756
|
-
"
|
|
6739
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/size.js"() {
|
|
6757
6740
|
"use strict";
|
|
6758
6741
|
init_isHex();
|
|
6759
6742
|
}
|
|
6760
6743
|
});
|
|
6761
6744
|
|
|
6762
|
-
//
|
|
6745
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/version.js
|
|
6763
6746
|
var version;
|
|
6764
6747
|
var init_version = __esm({
|
|
6765
|
-
"
|
|
6748
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/version.js"() {
|
|
6766
6749
|
"use strict";
|
|
6767
|
-
version = "2.
|
|
6750
|
+
version = "2.56.8";
|
|
6768
6751
|
}
|
|
6769
6752
|
});
|
|
6770
6753
|
|
|
6771
|
-
//
|
|
6754
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/base.js
|
|
6772
6755
|
function walk(err2, fn) {
|
|
6773
6756
|
if (fn?.(err2))
|
|
6774
6757
|
return err2;
|
|
@@ -6778,7 +6761,7 @@ function walk(err2, fn) {
|
|
|
6778
6761
|
}
|
|
6779
6762
|
var errorConfig, BaseError;
|
|
6780
6763
|
var init_base = __esm({
|
|
6781
|
-
"
|
|
6764
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/base.js"() {
|
|
6782
6765
|
"use strict";
|
|
6783
6766
|
init_version();
|
|
6784
6767
|
errorConfig = {
|
|
@@ -6859,10 +6842,10 @@ var init_base = __esm({
|
|
|
6859
6842
|
}
|
|
6860
6843
|
});
|
|
6861
6844
|
|
|
6862
|
-
//
|
|
6845
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/data.js
|
|
6863
6846
|
var SizeExceedsPaddingSizeError;
|
|
6864
6847
|
var init_data = __esm({
|
|
6865
|
-
"
|
|
6848
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/data.js"() {
|
|
6866
6849
|
"use strict";
|
|
6867
6850
|
init_base();
|
|
6868
6851
|
SizeExceedsPaddingSizeError = class extends BaseError {
|
|
@@ -6873,7 +6856,7 @@ var init_data = __esm({
|
|
|
6873
6856
|
}
|
|
6874
6857
|
});
|
|
6875
6858
|
|
|
6876
|
-
//
|
|
6859
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/pad.js
|
|
6877
6860
|
function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
|
|
6878
6861
|
if (typeof hexOrBytes === "string")
|
|
6879
6862
|
return padHex(hexOrBytes, { dir, size: size2 });
|
|
@@ -6882,14 +6865,14 @@ function pad(hexOrBytes, { dir, size: size2 = 32 } = {}) {
|
|
|
6882
6865
|
function padHex(hex_, { dir, size: size2 = 32 } = {}) {
|
|
6883
6866
|
if (size2 === null)
|
|
6884
6867
|
return hex_;
|
|
6885
|
-
const
|
|
6886
|
-
if (
|
|
6868
|
+
const hex = hex_.replace("0x", "");
|
|
6869
|
+
if (hex.length > size2 * 2)
|
|
6887
6870
|
throw new SizeExceedsPaddingSizeError({
|
|
6888
|
-
size: Math.ceil(
|
|
6871
|
+
size: Math.ceil(hex.length / 2),
|
|
6889
6872
|
targetSize: size2,
|
|
6890
6873
|
type: "hex"
|
|
6891
6874
|
});
|
|
6892
|
-
return `0x${
|
|
6875
|
+
return `0x${hex[dir === "right" ? "padEnd" : "padStart"](size2 * 2, "0")}`;
|
|
6893
6876
|
}
|
|
6894
6877
|
function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
|
|
6895
6878
|
if (size2 === null)
|
|
@@ -6908,16 +6891,16 @@ function padBytes(bytes, { dir, size: size2 = 32 } = {}) {
|
|
|
6908
6891
|
return paddedBytes;
|
|
6909
6892
|
}
|
|
6910
6893
|
var init_pad = __esm({
|
|
6911
|
-
"
|
|
6894
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/pad.js"() {
|
|
6912
6895
|
"use strict";
|
|
6913
6896
|
init_data();
|
|
6914
6897
|
}
|
|
6915
6898
|
});
|
|
6916
6899
|
|
|
6917
|
-
//
|
|
6900
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/encoding.js
|
|
6918
6901
|
var IntegerOutOfRangeError, SizeOverflowError;
|
|
6919
6902
|
var init_encoding = __esm({
|
|
6920
|
-
"
|
|
6903
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/encoding.js"() {
|
|
6921
6904
|
"use strict";
|
|
6922
6905
|
init_base();
|
|
6923
6906
|
IntegerOutOfRangeError = class extends BaseError {
|
|
@@ -6933,7 +6916,7 @@ var init_encoding = __esm({
|
|
|
6933
6916
|
}
|
|
6934
6917
|
});
|
|
6935
6918
|
|
|
6936
|
-
//
|
|
6919
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/fromHex.js
|
|
6937
6920
|
function assertSize(hexOrBytes, { size: size2 }) {
|
|
6938
6921
|
if (size(hexOrBytes) > size2)
|
|
6939
6922
|
throw new SizeOverflowError({
|
|
@@ -6941,21 +6924,21 @@ function assertSize(hexOrBytes, { size: size2 }) {
|
|
|
6941
6924
|
maxSize: size2
|
|
6942
6925
|
});
|
|
6943
6926
|
}
|
|
6944
|
-
function hexToBigInt(
|
|
6927
|
+
function hexToBigInt(hex, opts = {}) {
|
|
6945
6928
|
const { signed } = opts;
|
|
6946
6929
|
if (opts.size)
|
|
6947
|
-
assertSize(
|
|
6948
|
-
const value = BigInt(
|
|
6930
|
+
assertSize(hex, { size: opts.size });
|
|
6931
|
+
const value = BigInt(hex);
|
|
6949
6932
|
if (!signed)
|
|
6950
6933
|
return value;
|
|
6951
|
-
const size2 = (
|
|
6934
|
+
const size2 = Math.ceil((hex.length - 2) / 2);
|
|
6952
6935
|
const max = (1n << BigInt(size2) * 8n - 1n) - 1n;
|
|
6953
6936
|
if (value <= max)
|
|
6954
6937
|
return value;
|
|
6955
6938
|
return value - BigInt(`0x${"f".padStart(size2 * 2, "f")}`) - 1n;
|
|
6956
6939
|
}
|
|
6957
|
-
function hexToNumber2(
|
|
6958
|
-
const value = hexToBigInt(
|
|
6940
|
+
function hexToNumber2(hex, opts = {}) {
|
|
6941
|
+
const value = hexToBigInt(hex, opts);
|
|
6959
6942
|
const number = Number(value);
|
|
6960
6943
|
if (!Number.isSafeInteger(number))
|
|
6961
6944
|
throw new IntegerOutOfRangeError({
|
|
@@ -6968,14 +6951,14 @@ function hexToNumber2(hex2, opts = {}) {
|
|
|
6968
6951
|
return number;
|
|
6969
6952
|
}
|
|
6970
6953
|
var init_fromHex = __esm({
|
|
6971
|
-
"
|
|
6954
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/fromHex.js"() {
|
|
6972
6955
|
"use strict";
|
|
6973
6956
|
init_encoding();
|
|
6974
6957
|
init_size();
|
|
6975
6958
|
}
|
|
6976
6959
|
});
|
|
6977
6960
|
|
|
6978
|
-
//
|
|
6961
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/toHex.js
|
|
6979
6962
|
function toHex(value, opts = {}) {
|
|
6980
6963
|
if (typeof value === "number" || typeof value === "bigint")
|
|
6981
6964
|
return numberToHex(value, opts);
|
|
@@ -6987,24 +6970,24 @@ function toHex(value, opts = {}) {
|
|
|
6987
6970
|
return bytesToHex2(value, opts);
|
|
6988
6971
|
}
|
|
6989
6972
|
function boolToHex(value, opts = {}) {
|
|
6990
|
-
const
|
|
6973
|
+
const hex = `0x${Number(value)}`;
|
|
6991
6974
|
if (typeof opts.size === "number") {
|
|
6992
|
-
assertSize(
|
|
6993
|
-
return pad(
|
|
6975
|
+
assertSize(hex, { size: opts.size });
|
|
6976
|
+
return pad(hex, { size: opts.size });
|
|
6994
6977
|
}
|
|
6995
|
-
return
|
|
6978
|
+
return hex;
|
|
6996
6979
|
}
|
|
6997
6980
|
function bytesToHex2(value, opts = {}) {
|
|
6998
6981
|
let string2 = "";
|
|
6999
6982
|
for (let i = 0; i < value.length; i++) {
|
|
7000
6983
|
string2 += hexes2[value[i]];
|
|
7001
6984
|
}
|
|
7002
|
-
const
|
|
6985
|
+
const hex = `0x${string2}`;
|
|
7003
6986
|
if (typeof opts.size === "number") {
|
|
7004
|
-
assertSize(
|
|
7005
|
-
return pad(
|
|
6987
|
+
assertSize(hex, { size: opts.size });
|
|
6988
|
+
return pad(hex, { dir: "right", size: opts.size });
|
|
7006
6989
|
}
|
|
7007
|
-
return
|
|
6990
|
+
return hex;
|
|
7008
6991
|
}
|
|
7009
6992
|
function numberToHex(value_, opts = {}) {
|
|
7010
6993
|
const { signed, size: size2 } = opts;
|
|
@@ -7029,10 +7012,10 @@ function numberToHex(value_, opts = {}) {
|
|
|
7029
7012
|
value: `${value_}${suffix}`
|
|
7030
7013
|
});
|
|
7031
7014
|
}
|
|
7032
|
-
const
|
|
7015
|
+
const hex = `0x${(signed && value < 0 ? (1n << BigInt(size2 * 8)) + BigInt(value) : value).toString(16)}`;
|
|
7033
7016
|
if (size2)
|
|
7034
|
-
return pad(
|
|
7035
|
-
return
|
|
7017
|
+
return pad(hex, { size: size2 });
|
|
7018
|
+
return hex;
|
|
7036
7019
|
}
|
|
7037
7020
|
function stringToHex(value_, opts = {}) {
|
|
7038
7021
|
const value = encoder.encode(value_);
|
|
@@ -7040,7 +7023,7 @@ function stringToHex(value_, opts = {}) {
|
|
|
7040
7023
|
}
|
|
7041
7024
|
var hexes2, encoder;
|
|
7042
7025
|
var init_toHex = __esm({
|
|
7043
|
-
"
|
|
7026
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/toHex.js"() {
|
|
7044
7027
|
"use strict";
|
|
7045
7028
|
init_encoding();
|
|
7046
7029
|
init_pad();
|
|
@@ -7050,7 +7033,7 @@ var init_toHex = __esm({
|
|
|
7050
7033
|
}
|
|
7051
7034
|
});
|
|
7052
7035
|
|
|
7053
|
-
//
|
|
7036
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/toBytes.js
|
|
7054
7037
|
function toBytes2(value, opts = {}) {
|
|
7055
7038
|
if (typeof value === "number" || typeof value === "bigint")
|
|
7056
7039
|
return numberToBytes(value, opts);
|
|
@@ -7079,12 +7062,12 @@ function charCodeToBase16(char) {
|
|
|
7079
7062
|
return void 0;
|
|
7080
7063
|
}
|
|
7081
7064
|
function hexToBytes2(hex_, opts = {}) {
|
|
7082
|
-
let
|
|
7065
|
+
let hex = hex_;
|
|
7083
7066
|
if (opts.size) {
|
|
7084
|
-
assertSize(
|
|
7085
|
-
|
|
7067
|
+
assertSize(hex, { size: opts.size });
|
|
7068
|
+
hex = pad(hex, { dir: "right", size: opts.size });
|
|
7086
7069
|
}
|
|
7087
|
-
let hexString =
|
|
7070
|
+
let hexString = hex.slice(2);
|
|
7088
7071
|
if (hexString.length % 2)
|
|
7089
7072
|
hexString = `0${hexString}`;
|
|
7090
7073
|
const length4 = hexString.length / 2;
|
|
@@ -7100,8 +7083,8 @@ function hexToBytes2(hex_, opts = {}) {
|
|
|
7100
7083
|
return bytes;
|
|
7101
7084
|
}
|
|
7102
7085
|
function numberToBytes(value, opts) {
|
|
7103
|
-
const
|
|
7104
|
-
return hexToBytes2(
|
|
7086
|
+
const hex = numberToHex(value, opts);
|
|
7087
|
+
return hexToBytes2(hex);
|
|
7105
7088
|
}
|
|
7106
7089
|
function stringToBytes(value, opts = {}) {
|
|
7107
7090
|
const bytes = encoder2.encode(value);
|
|
@@ -7113,7 +7096,7 @@ function stringToBytes(value, opts = {}) {
|
|
|
7113
7096
|
}
|
|
7114
7097
|
var encoder2, charCodeMap;
|
|
7115
7098
|
var init_toBytes = __esm({
|
|
7116
|
-
"
|
|
7099
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/encoding/toBytes.js"() {
|
|
7117
7100
|
"use strict";
|
|
7118
7101
|
init_base();
|
|
7119
7102
|
init_isHex();
|
|
@@ -7132,7 +7115,7 @@ var init_toBytes = __esm({
|
|
|
7132
7115
|
}
|
|
7133
7116
|
});
|
|
7134
7117
|
|
|
7135
|
-
//
|
|
7118
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/sha3.js
|
|
7136
7119
|
function keccakP(s, rounds = 24) {
|
|
7137
7120
|
const B = new Uint32Array(5 * 2);
|
|
7138
7121
|
for (let round = 24 - rounds; round < 24; round++) {
|
|
@@ -7175,7 +7158,7 @@ function keccakP(s, rounds = 24) {
|
|
|
7175
7158
|
}
|
|
7176
7159
|
var _0n6, _1n6, _2n4, _7n2, _256n, _0x71n, SHA3_PI, SHA3_ROTL, _SHA3_IOTA, IOTAS, SHA3_IOTA_H, SHA3_IOTA_L, rotlH, rotlL, Keccak, gen, keccak_256;
|
|
7177
7160
|
var init_sha3 = __esm({
|
|
7178
|
-
"
|
|
7161
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/sha3.js"() {
|
|
7179
7162
|
"use strict";
|
|
7180
7163
|
init_u64();
|
|
7181
7164
|
init_utils();
|
|
@@ -7321,7 +7304,7 @@ var init_sha3 = __esm({
|
|
|
7321
7304
|
}
|
|
7322
7305
|
});
|
|
7323
7306
|
|
|
7324
|
-
//
|
|
7307
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/hash/keccak256.js
|
|
7325
7308
|
function keccak256(value, to_) {
|
|
7326
7309
|
const to = to_ || "hex";
|
|
7327
7310
|
const bytes = keccak_256(isHex(value, { strict: false }) ? toBytes2(value) : value);
|
|
@@ -7330,7 +7313,7 @@ function keccak256(value, to_) {
|
|
|
7330
7313
|
return toHex(bytes);
|
|
7331
7314
|
}
|
|
7332
7315
|
var init_keccak256 = __esm({
|
|
7333
|
-
"
|
|
7316
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/hash/keccak256.js"() {
|
|
7334
7317
|
"use strict";
|
|
7335
7318
|
init_sha3();
|
|
7336
7319
|
init_isHex();
|
|
@@ -7339,10 +7322,10 @@ var init_keccak256 = __esm({
|
|
|
7339
7322
|
}
|
|
7340
7323
|
});
|
|
7341
7324
|
|
|
7342
|
-
//
|
|
7325
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/address.js
|
|
7343
7326
|
var InvalidAddressError;
|
|
7344
7327
|
var init_address = __esm({
|
|
7345
|
-
"
|
|
7328
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/errors/address.js"() {
|
|
7346
7329
|
"use strict";
|
|
7347
7330
|
init_base();
|
|
7348
7331
|
InvalidAddressError = class extends BaseError {
|
|
@@ -7359,10 +7342,10 @@ var init_address = __esm({
|
|
|
7359
7342
|
}
|
|
7360
7343
|
});
|
|
7361
7344
|
|
|
7362
|
-
//
|
|
7345
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/lru.js
|
|
7363
7346
|
var LruMap;
|
|
7364
7347
|
var init_lru = __esm({
|
|
7365
|
-
"
|
|
7348
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/lru.js"() {
|
|
7366
7349
|
"use strict";
|
|
7367
7350
|
LruMap = class extends Map {
|
|
7368
7351
|
constructor(size2) {
|
|
@@ -7377,18 +7360,20 @@ var init_lru = __esm({
|
|
|
7377
7360
|
}
|
|
7378
7361
|
get(key) {
|
|
7379
7362
|
const value = super.get(key);
|
|
7380
|
-
if (super.has(key)
|
|
7381
|
-
|
|
7363
|
+
if (super.has(key)) {
|
|
7364
|
+
super.delete(key);
|
|
7382
7365
|
super.set(key, value);
|
|
7383
7366
|
}
|
|
7384
7367
|
return value;
|
|
7385
7368
|
}
|
|
7386
7369
|
set(key, value) {
|
|
7370
|
+
if (super.has(key))
|
|
7371
|
+
super.delete(key);
|
|
7387
7372
|
super.set(key, value);
|
|
7388
7373
|
if (this.maxSize && this.size > this.maxSize) {
|
|
7389
|
-
const firstKey =
|
|
7390
|
-
if (firstKey)
|
|
7391
|
-
|
|
7374
|
+
const firstKey = super.keys().next().value;
|
|
7375
|
+
if (firstKey !== void 0)
|
|
7376
|
+
super.delete(firstKey);
|
|
7392
7377
|
}
|
|
7393
7378
|
return this;
|
|
7394
7379
|
}
|
|
@@ -7396,7 +7381,7 @@ var init_lru = __esm({
|
|
|
7396
7381
|
}
|
|
7397
7382
|
});
|
|
7398
7383
|
|
|
7399
|
-
//
|
|
7384
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/getAddress.js
|
|
7400
7385
|
function checksumAddress(address_, chainId) {
|
|
7401
7386
|
if (checksumAddressCache.has(`${address_}.${chainId}`))
|
|
7402
7387
|
return checksumAddressCache.get(`${address_}.${chainId}`);
|
|
@@ -7422,7 +7407,7 @@ function getAddress(address, chainId) {
|
|
|
7422
7407
|
}
|
|
7423
7408
|
var checksumAddressCache;
|
|
7424
7409
|
var init_getAddress = __esm({
|
|
7425
|
-
"
|
|
7410
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/getAddress.js"() {
|
|
7426
7411
|
"use strict";
|
|
7427
7412
|
init_address();
|
|
7428
7413
|
init_toBytes();
|
|
@@ -7433,7 +7418,7 @@ var init_getAddress = __esm({
|
|
|
7433
7418
|
}
|
|
7434
7419
|
});
|
|
7435
7420
|
|
|
7436
|
-
//
|
|
7421
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/isAddress.js
|
|
7437
7422
|
function isAddress(address, options) {
|
|
7438
7423
|
const { strict = true } = options ?? {};
|
|
7439
7424
|
const cacheKey2 = `${address}.${strict}`;
|
|
@@ -7453,7 +7438,7 @@ function isAddress(address, options) {
|
|
|
7453
7438
|
}
|
|
7454
7439
|
var addressRegex, isAddressCache;
|
|
7455
7440
|
var init_isAddress = __esm({
|
|
7456
|
-
"
|
|
7441
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/isAddress.js"() {
|
|
7457
7442
|
"use strict";
|
|
7458
7443
|
init_lru();
|
|
7459
7444
|
init_getAddress();
|
|
@@ -7462,7 +7447,7 @@ var init_isAddress = __esm({
|
|
|
7462
7447
|
}
|
|
7463
7448
|
});
|
|
7464
7449
|
|
|
7465
|
-
//
|
|
7450
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/concat.js
|
|
7466
7451
|
function concat(values) {
|
|
7467
7452
|
if (typeof values[0] === "string")
|
|
7468
7453
|
return concatHex(values);
|
|
@@ -7485,28 +7470,28 @@ function concatHex(values) {
|
|
|
7485
7470
|
return `0x${values.reduce((acc, x) => acc + x.replace("0x", ""), "")}`;
|
|
7486
7471
|
}
|
|
7487
7472
|
var init_concat = __esm({
|
|
7488
|
-
"
|
|
7473
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/data/concat.js"() {
|
|
7489
7474
|
"use strict";
|
|
7490
7475
|
}
|
|
7491
7476
|
});
|
|
7492
7477
|
|
|
7493
|
-
//
|
|
7478
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js
|
|
7494
7479
|
function publicKeyToAddress(publicKey) {
|
|
7495
7480
|
const address = keccak256(`0x${publicKey.substring(4)}`).substring(26);
|
|
7496
7481
|
return checksumAddress(`0x${address}`);
|
|
7497
7482
|
}
|
|
7498
7483
|
var init_publicKeyToAddress = __esm({
|
|
7499
|
-
"
|
|
7484
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/accounts/utils/publicKeyToAddress.js"() {
|
|
7500
7485
|
"use strict";
|
|
7501
7486
|
init_getAddress();
|
|
7502
7487
|
init_keccak256();
|
|
7503
7488
|
}
|
|
7504
7489
|
});
|
|
7505
7490
|
|
|
7506
|
-
//
|
|
7491
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/hmac.js
|
|
7507
7492
|
var HMAC, hmac;
|
|
7508
7493
|
var init_hmac = __esm({
|
|
7509
|
-
"
|
|
7494
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@noble/hashes/esm/hmac.js"() {
|
|
7510
7495
|
"use strict";
|
|
7511
7496
|
init_utils();
|
|
7512
7497
|
HMAC = class extends Hash {
|
|
@@ -7578,7 +7563,7 @@ var init_hmac = __esm({
|
|
|
7578
7563
|
}
|
|
7579
7564
|
});
|
|
7580
7565
|
|
|
7581
|
-
//
|
|
7566
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js
|
|
7582
7567
|
function isBytes2(a) {
|
|
7583
7568
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
7584
7569
|
}
|
|
@@ -7591,23 +7576,23 @@ function abool(title, value) {
|
|
|
7591
7576
|
throw new Error(title + " boolean expected, got " + value);
|
|
7592
7577
|
}
|
|
7593
7578
|
function numberToHexUnpadded(num2) {
|
|
7594
|
-
const
|
|
7595
|
-
return
|
|
7579
|
+
const hex = num2.toString(16);
|
|
7580
|
+
return hex.length & 1 ? "0" + hex : hex;
|
|
7596
7581
|
}
|
|
7597
|
-
function hexToNumber3(
|
|
7598
|
-
if (typeof
|
|
7599
|
-
throw new Error("hex string expected, got " + typeof
|
|
7600
|
-
return
|
|
7582
|
+
function hexToNumber3(hex) {
|
|
7583
|
+
if (typeof hex !== "string")
|
|
7584
|
+
throw new Error("hex string expected, got " + typeof hex);
|
|
7585
|
+
return hex === "" ? _0n7 : BigInt("0x" + hex);
|
|
7601
7586
|
}
|
|
7602
7587
|
function bytesToHex3(bytes) {
|
|
7603
7588
|
abytes2(bytes);
|
|
7604
7589
|
if (hasHexBuiltin2)
|
|
7605
7590
|
return bytes.toHex();
|
|
7606
|
-
let
|
|
7591
|
+
let hex = "";
|
|
7607
7592
|
for (let i = 0; i < bytes.length; i++) {
|
|
7608
|
-
|
|
7593
|
+
hex += hexes3[bytes[i]];
|
|
7609
7594
|
}
|
|
7610
|
-
return
|
|
7595
|
+
return hex;
|
|
7611
7596
|
}
|
|
7612
7597
|
function asciiToBase162(ch) {
|
|
7613
7598
|
if (ch >= asciis2._0 && ch <= asciis2._9)
|
|
@@ -7618,21 +7603,21 @@ function asciiToBase162(ch) {
|
|
|
7618
7603
|
return ch - (asciis2.a - 10);
|
|
7619
7604
|
return;
|
|
7620
7605
|
}
|
|
7621
|
-
function hexToBytes3(
|
|
7622
|
-
if (typeof
|
|
7623
|
-
throw new Error("hex string expected, got " + typeof
|
|
7606
|
+
function hexToBytes3(hex) {
|
|
7607
|
+
if (typeof hex !== "string")
|
|
7608
|
+
throw new Error("hex string expected, got " + typeof hex);
|
|
7624
7609
|
if (hasHexBuiltin2)
|
|
7625
|
-
return Uint8Array.fromHex(
|
|
7626
|
-
const hl =
|
|
7610
|
+
return Uint8Array.fromHex(hex);
|
|
7611
|
+
const hl = hex.length;
|
|
7627
7612
|
const al = hl / 2;
|
|
7628
7613
|
if (hl % 2)
|
|
7629
7614
|
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
|
7630
7615
|
const array = new Uint8Array(al);
|
|
7631
7616
|
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
7632
|
-
const n1 = asciiToBase162(
|
|
7633
|
-
const n2 = asciiToBase162(
|
|
7617
|
+
const n1 = asciiToBase162(hex.charCodeAt(hi));
|
|
7618
|
+
const n2 = asciiToBase162(hex.charCodeAt(hi + 1));
|
|
7634
7619
|
if (n1 === void 0 || n2 === void 0) {
|
|
7635
|
-
const char =
|
|
7620
|
+
const char = hex[hi] + hex[hi + 1];
|
|
7636
7621
|
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
|
7637
7622
|
}
|
|
7638
7623
|
array[ai] = n1 * 16 + n2;
|
|
@@ -7652,16 +7637,16 @@ function numberToBytesBE2(n, len) {
|
|
|
7652
7637
|
function numberToBytesLE2(n, len) {
|
|
7653
7638
|
return numberToBytesBE2(n, len).reverse();
|
|
7654
7639
|
}
|
|
7655
|
-
function ensureBytes2(title,
|
|
7640
|
+
function ensureBytes2(title, hex, expectedLength) {
|
|
7656
7641
|
let res;
|
|
7657
|
-
if (typeof
|
|
7642
|
+
if (typeof hex === "string") {
|
|
7658
7643
|
try {
|
|
7659
|
-
res = hexToBytes3(
|
|
7644
|
+
res = hexToBytes3(hex);
|
|
7660
7645
|
} catch (e) {
|
|
7661
7646
|
throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
|
|
7662
7647
|
}
|
|
7663
|
-
} else if (isBytes2(
|
|
7664
|
-
res = Uint8Array.from(
|
|
7648
|
+
} else if (isBytes2(hex)) {
|
|
7649
|
+
res = Uint8Array.from(hex);
|
|
7665
7650
|
} else {
|
|
7666
7651
|
throw new Error(title + " must be hex string or Uint8Array");
|
|
7667
7652
|
}
|
|
@@ -7751,15 +7736,15 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
7751
7736
|
};
|
|
7752
7737
|
return genUntil;
|
|
7753
7738
|
}
|
|
7754
|
-
function validateObject2(
|
|
7739
|
+
function validateObject2(object, validators, optValidators = {}) {
|
|
7755
7740
|
const checkField = (fieldName, type, isOptional) => {
|
|
7756
7741
|
const checkVal = validatorFns[type];
|
|
7757
7742
|
if (typeof checkVal !== "function")
|
|
7758
7743
|
throw new Error("invalid validator function");
|
|
7759
|
-
const val =
|
|
7744
|
+
const val = object[fieldName];
|
|
7760
7745
|
if (isOptional && val === void 0)
|
|
7761
7746
|
return;
|
|
7762
|
-
if (!checkVal(val,
|
|
7747
|
+
if (!checkVal(val, object)) {
|
|
7763
7748
|
throw new Error("param " + String(fieldName) + " is invalid. Expected " + type + ", got " + val);
|
|
7764
7749
|
}
|
|
7765
7750
|
};
|
|
@@ -7767,7 +7752,7 @@ function validateObject2(object2, validators, optValidators = {}) {
|
|
|
7767
7752
|
checkField(fieldName, type, false);
|
|
7768
7753
|
for (const [fieldName, type] of Object.entries(optValidators))
|
|
7769
7754
|
checkField(fieldName, type, true);
|
|
7770
|
-
return
|
|
7755
|
+
return object;
|
|
7771
7756
|
}
|
|
7772
7757
|
function memoized2(fn) {
|
|
7773
7758
|
const map = /* @__PURE__ */ new WeakMap();
|
|
@@ -7782,7 +7767,7 @@ function memoized2(fn) {
|
|
|
7782
7767
|
}
|
|
7783
7768
|
var _0n7, _1n7, hasHexBuiltin2, hexes3, asciis2, isPosBig2, bitMask2, u8n, u8fr, validatorFns;
|
|
7784
7769
|
var init_utils3 = __esm({
|
|
7785
|
-
"
|
|
7770
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js"() {
|
|
7786
7771
|
"use strict";
|
|
7787
7772
|
_0n7 = /* @__PURE__ */ BigInt(0);
|
|
7788
7773
|
_1n7 = /* @__PURE__ */ BigInt(1);
|
|
@@ -7802,13 +7787,13 @@ var init_utils3 = __esm({
|
|
|
7802
7787
|
stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
|
|
7803
7788
|
isSafeInteger: (val) => Number.isSafeInteger(val),
|
|
7804
7789
|
array: (val) => Array.isArray(val),
|
|
7805
|
-
field: (val,
|
|
7790
|
+
field: (val, object) => object.Fp.isValid(val),
|
|
7806
7791
|
hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
|
|
7807
7792
|
};
|
|
7808
7793
|
}
|
|
7809
7794
|
});
|
|
7810
7795
|
|
|
7811
|
-
//
|
|
7796
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js
|
|
7812
7797
|
function mod2(a, b) {
|
|
7813
7798
|
const result = a % b;
|
|
7814
7799
|
return result >= _0n8 ? result : b + result;
|
|
@@ -8057,7 +8042,7 @@ function mapHashToField(key, fieldOrder, isLE2 = false) {
|
|
|
8057
8042
|
}
|
|
8058
8043
|
var _0n8, _1n8, _2n5, _3n3, _4n2, _5n3, _8n4, FIELD_FIELDS2;
|
|
8059
8044
|
var init_modular2 = __esm({
|
|
8060
|
-
"
|
|
8045
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js"() {
|
|
8061
8046
|
"use strict";
|
|
8062
8047
|
init_utils();
|
|
8063
8048
|
init_utils3();
|
|
@@ -8090,7 +8075,7 @@ var init_modular2 = __esm({
|
|
|
8090
8075
|
}
|
|
8091
8076
|
});
|
|
8092
8077
|
|
|
8093
|
-
//
|
|
8078
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js
|
|
8094
8079
|
function constTimeNegate(condition, item) {
|
|
8095
8080
|
const neg = item.negate();
|
|
8096
8081
|
return condition ? neg : item;
|
|
@@ -8321,7 +8306,7 @@ function validateBasic(curve) {
|
|
|
8321
8306
|
}
|
|
8322
8307
|
var _0n9, _1n9, pointPrecomputes2, pointWindowSizes2;
|
|
8323
8308
|
var init_curve2 = __esm({
|
|
8324
|
-
"
|
|
8309
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js"() {
|
|
8325
8310
|
"use strict";
|
|
8326
8311
|
init_modular2();
|
|
8327
8312
|
init_utils3();
|
|
@@ -8332,7 +8317,7 @@ var init_curve2 = __esm({
|
|
|
8332
8317
|
}
|
|
8333
8318
|
});
|
|
8334
8319
|
|
|
8335
|
-
//
|
|
8320
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js
|
|
8336
8321
|
function validateSigVerOpts(opts) {
|
|
8337
8322
|
if (opts.lowS !== void 0)
|
|
8338
8323
|
abool("lowS", opts.lowS);
|
|
@@ -8502,8 +8487,8 @@ function weierstrassPoints(opts) {
|
|
|
8502
8487
|
* Converts hash string or Uint8Array to Point.
|
|
8503
8488
|
* @param hex short/long ECDSA hex
|
|
8504
8489
|
*/
|
|
8505
|
-
static fromHex(
|
|
8506
|
-
const P = Point2.fromAffine(fromBytes2(ensureBytes2("pointHex",
|
|
8490
|
+
static fromHex(hex) {
|
|
8491
|
+
const P = Point2.fromAffine(fromBytes2(ensureBytes2("pointHex", hex)));
|
|
8507
8492
|
P.assertValidity();
|
|
8508
8493
|
return P;
|
|
8509
8494
|
}
|
|
@@ -8858,15 +8843,15 @@ function weierstrass(curveDef) {
|
|
|
8858
8843
|
Object.freeze(this);
|
|
8859
8844
|
}
|
|
8860
8845
|
// pair (bytes of r, bytes of s)
|
|
8861
|
-
static fromCompact(
|
|
8846
|
+
static fromCompact(hex) {
|
|
8862
8847
|
const l = nByteLength;
|
|
8863
|
-
|
|
8864
|
-
return new Signature(slcNum(
|
|
8848
|
+
hex = ensureBytes2("compactSignature", hex, l * 2);
|
|
8849
|
+
return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
|
|
8865
8850
|
}
|
|
8866
8851
|
// DER encoded ECDSA signature
|
|
8867
8852
|
// https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
|
|
8868
|
-
static fromDER(
|
|
8869
|
-
const { r, s } = DER.toSig(ensureBytes2("DER",
|
|
8853
|
+
static fromDER(hex) {
|
|
8854
|
+
const { r, s } = DER.toSig(ensureBytes2("DER", hex));
|
|
8870
8855
|
return new Signature(r, s);
|
|
8871
8856
|
}
|
|
8872
8857
|
/**
|
|
@@ -8997,7 +8982,7 @@ function weierstrass(curveDef) {
|
|
|
8997
8982
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
|
8998
8983
|
if (["recovered", "canonical"].some((k) => k in opts))
|
|
8999
8984
|
throw new Error("sign() legacy options not supported");
|
|
9000
|
-
const { hash, randomBytes:
|
|
8985
|
+
const { hash, randomBytes: randomBytes5 } = CURVE;
|
|
9001
8986
|
let { lowS, prehash, extraEntropy: ent } = opts;
|
|
9002
8987
|
if (lowS == null)
|
|
9003
8988
|
lowS = true;
|
|
@@ -9009,7 +8994,7 @@ function weierstrass(curveDef) {
|
|
|
9009
8994
|
const d = normPrivateKeyToScalar(privateKey);
|
|
9010
8995
|
const seedArgs = [int2octets(d), int2octets(h1int)];
|
|
9011
8996
|
if (ent != null && ent !== false) {
|
|
9012
|
-
const e = ent === true ?
|
|
8997
|
+
const e = ent === true ? randomBytes5(Fp2.BYTES) : ent;
|
|
9013
8998
|
seedArgs.push(ensureBytes2("extraEntropy", e));
|
|
9014
8999
|
}
|
|
9015
9000
|
const seed = concatBytes3(...seedArgs);
|
|
@@ -9209,7 +9194,7 @@ function mapToCurveSimpleSWU(Fp2, opts) {
|
|
|
9209
9194
|
}
|
|
9210
9195
|
var DERErr, DER, _0n10, _1n10, _2n6, _3n4, _4n3;
|
|
9211
9196
|
var init_weierstrass = __esm({
|
|
9212
|
-
"
|
|
9197
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js"() {
|
|
9213
9198
|
"use strict";
|
|
9214
9199
|
init_curve2();
|
|
9215
9200
|
init_modular2();
|
|
@@ -9283,12 +9268,12 @@ var init_weierstrass = __esm({
|
|
|
9283
9268
|
const { Err: E } = DER;
|
|
9284
9269
|
if (num2 < _0n10)
|
|
9285
9270
|
throw new E("integer: negative integers are not allowed");
|
|
9286
|
-
let
|
|
9287
|
-
if (Number.parseInt(
|
|
9288
|
-
|
|
9289
|
-
if (
|
|
9271
|
+
let hex = numberToHexUnpadded(num2);
|
|
9272
|
+
if (Number.parseInt(hex[0], 16) & 8)
|
|
9273
|
+
hex = "00" + hex;
|
|
9274
|
+
if (hex.length & 1)
|
|
9290
9275
|
throw new E("unexpected DER parsing assertion: unpadded hex");
|
|
9291
|
-
return
|
|
9276
|
+
return hex;
|
|
9292
9277
|
},
|
|
9293
9278
|
decode(data) {
|
|
9294
9279
|
const { Err: E } = DER;
|
|
@@ -9299,9 +9284,9 @@ var init_weierstrass = __esm({
|
|
|
9299
9284
|
return bytesToNumberBE2(data);
|
|
9300
9285
|
}
|
|
9301
9286
|
},
|
|
9302
|
-
toSig(
|
|
9287
|
+
toSig(hex) {
|
|
9303
9288
|
const { Err: E, _int: int, _tlv: tlv } = DER;
|
|
9304
|
-
const data = ensureBytes2("signature",
|
|
9289
|
+
const data = ensureBytes2("signature", hex);
|
|
9305
9290
|
const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
|
|
9306
9291
|
if (seqLeftBytes.length)
|
|
9307
9292
|
throw new E("invalid signature: left bytes after parsing");
|
|
@@ -9327,7 +9312,7 @@ var init_weierstrass = __esm({
|
|
|
9327
9312
|
}
|
|
9328
9313
|
});
|
|
9329
9314
|
|
|
9330
|
-
//
|
|
9315
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js
|
|
9331
9316
|
function getHash(hash) {
|
|
9332
9317
|
return {
|
|
9333
9318
|
hash,
|
|
@@ -9340,7 +9325,7 @@ function createCurve(curveDef, defHash) {
|
|
|
9340
9325
|
return { ...create4(defHash), create: create4 };
|
|
9341
9326
|
}
|
|
9342
9327
|
var init_shortw_utils = __esm({
|
|
9343
|
-
"
|
|
9328
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js"() {
|
|
9344
9329
|
"use strict";
|
|
9345
9330
|
init_hmac();
|
|
9346
9331
|
init_utils();
|
|
@@ -9348,7 +9333,7 @@ var init_shortw_utils = __esm({
|
|
|
9348
9333
|
}
|
|
9349
9334
|
});
|
|
9350
9335
|
|
|
9351
|
-
//
|
|
9336
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js
|
|
9352
9337
|
function i2osp(value, length4) {
|
|
9353
9338
|
anum(value);
|
|
9354
9339
|
anum(length4);
|
|
@@ -9496,7 +9481,7 @@ function createHasher2(Point2, mapToCurve, defaults) {
|
|
|
9496
9481
|
}
|
|
9497
9482
|
var os2ip;
|
|
9498
9483
|
var init_hash_to_curve = __esm({
|
|
9499
|
-
"
|
|
9484
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js"() {
|
|
9500
9485
|
"use strict";
|
|
9501
9486
|
init_modular2();
|
|
9502
9487
|
init_utils3();
|
|
@@ -9504,7 +9489,7 @@ var init_hash_to_curve = __esm({
|
|
|
9504
9489
|
}
|
|
9505
9490
|
});
|
|
9506
9491
|
|
|
9507
|
-
//
|
|
9492
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js
|
|
9508
9493
|
var secp256k1_exports = {};
|
|
9509
9494
|
__export(secp256k1_exports, {
|
|
9510
9495
|
encodeToCurve: () => encodeToCurve,
|
|
@@ -9608,7 +9593,7 @@ function schnorrVerify(signature, message, publicKey) {
|
|
|
9608
9593
|
}
|
|
9609
9594
|
var secp256k1P, secp256k1N, _0n11, _1n11, _2n7, divNearest, Fpk1, secp256k1, TAGGED_HASH_PREFIXES, pointToBytes, numTo32b, modP, modN, Point, GmulAdd, num, schnorr, isoMap, mapSWU, secp256k1_hasher, hashToCurve, encodeToCurve;
|
|
9610
9595
|
var init_secp256k1 = __esm({
|
|
9611
|
-
"
|
|
9596
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js"() {
|
|
9612
9597
|
"use strict";
|
|
9613
9598
|
init_sha2();
|
|
9614
9599
|
init_utils();
|
|
@@ -9736,7 +9721,7 @@ var init_secp256k1 = __esm({
|
|
|
9736
9721
|
}
|
|
9737
9722
|
});
|
|
9738
9723
|
|
|
9739
|
-
//
|
|
9724
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverPublicKey.js
|
|
9740
9725
|
async function recoverPublicKey({ hash, signature }) {
|
|
9741
9726
|
const hashHex = isHex(hash) ? hash : toHex(hash);
|
|
9742
9727
|
const { secp256k1: secp256k12 } = await Promise.resolve().then(() => (init_secp256k1(), secp256k1_exports));
|
|
@@ -9767,7 +9752,7 @@ function toRecoveryBit(yParityOrV) {
|
|
|
9767
9752
|
throw new Error("Invalid yParityOrV value");
|
|
9768
9753
|
}
|
|
9769
9754
|
var init_recoverPublicKey = __esm({
|
|
9770
|
-
"
|
|
9755
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverPublicKey.js"() {
|
|
9771
9756
|
"use strict";
|
|
9772
9757
|
init_isHex();
|
|
9773
9758
|
init_size();
|
|
@@ -9776,29 +9761,19 @@ var init_recoverPublicKey = __esm({
|
|
|
9776
9761
|
}
|
|
9777
9762
|
});
|
|
9778
9763
|
|
|
9779
|
-
//
|
|
9764
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverAddress.js
|
|
9780
9765
|
async function recoverAddress({ hash, signature }) {
|
|
9781
9766
|
return publicKeyToAddress(await recoverPublicKey({ hash, signature }));
|
|
9782
9767
|
}
|
|
9783
9768
|
var init_recoverAddress = __esm({
|
|
9784
|
-
"
|
|
9769
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverAddress.js"() {
|
|
9785
9770
|
"use strict";
|
|
9786
9771
|
init_publicKeyToAddress();
|
|
9787
9772
|
init_recoverPublicKey();
|
|
9788
9773
|
}
|
|
9789
9774
|
});
|
|
9790
9775
|
|
|
9791
|
-
//
|
|
9792
|
-
var sha2562;
|
|
9793
|
-
var init_sha256 = __esm({
|
|
9794
|
-
"../../node_modules/@noble/hashes/esm/sha256.js"() {
|
|
9795
|
-
"use strict";
|
|
9796
|
-
init_sha2();
|
|
9797
|
-
sha2562 = sha256;
|
|
9798
|
-
}
|
|
9799
|
-
});
|
|
9800
|
-
|
|
9801
|
-
// ../../node_modules/viem/_esm/utils/address/isAddressEqual.js
|
|
9776
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/isAddressEqual.js
|
|
9802
9777
|
function isAddressEqual(a, b) {
|
|
9803
9778
|
if (!isAddress(a, { strict: false }))
|
|
9804
9779
|
throw new InvalidAddressError({ address: a });
|
|
@@ -9807,23 +9782,23 @@ function isAddressEqual(a, b) {
|
|
|
9807
9782
|
return a.toLowerCase() === b.toLowerCase();
|
|
9808
9783
|
}
|
|
9809
9784
|
var init_isAddressEqual = __esm({
|
|
9810
|
-
"
|
|
9785
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/address/isAddressEqual.js"() {
|
|
9811
9786
|
"use strict";
|
|
9812
9787
|
init_address();
|
|
9813
9788
|
init_isAddress();
|
|
9814
9789
|
}
|
|
9815
9790
|
});
|
|
9816
9791
|
|
|
9817
|
-
//
|
|
9792
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/constants/strings.js
|
|
9818
9793
|
var presignMessagePrefix;
|
|
9819
9794
|
var init_strings = __esm({
|
|
9820
|
-
"
|
|
9795
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/constants/strings.js"() {
|
|
9821
9796
|
"use strict";
|
|
9822
9797
|
presignMessagePrefix = "Ethereum Signed Message:\n";
|
|
9823
9798
|
}
|
|
9824
9799
|
});
|
|
9825
9800
|
|
|
9826
|
-
//
|
|
9801
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/toPrefixedMessage.js
|
|
9827
9802
|
function toPrefixedMessage(message_) {
|
|
9828
9803
|
const message = (() => {
|
|
9829
9804
|
if (typeof message_ === "string")
|
|
@@ -9836,7 +9811,7 @@ function toPrefixedMessage(message_) {
|
|
|
9836
9811
|
return concat([prefix, message]);
|
|
9837
9812
|
}
|
|
9838
9813
|
var init_toPrefixedMessage = __esm({
|
|
9839
|
-
"
|
|
9814
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/toPrefixedMessage.js"() {
|
|
9840
9815
|
"use strict";
|
|
9841
9816
|
init_strings();
|
|
9842
9817
|
init_concat();
|
|
@@ -9845,36 +9820,36 @@ var init_toPrefixedMessage = __esm({
|
|
|
9845
9820
|
}
|
|
9846
9821
|
});
|
|
9847
9822
|
|
|
9848
|
-
//
|
|
9823
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/hashMessage.js
|
|
9849
9824
|
function hashMessage(message, to_) {
|
|
9850
9825
|
return keccak256(toPrefixedMessage(message), to_);
|
|
9851
9826
|
}
|
|
9852
9827
|
var init_hashMessage = __esm({
|
|
9853
|
-
"
|
|
9828
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/hashMessage.js"() {
|
|
9854
9829
|
"use strict";
|
|
9855
9830
|
init_keccak256();
|
|
9856
9831
|
init_toPrefixedMessage();
|
|
9857
9832
|
}
|
|
9858
9833
|
});
|
|
9859
9834
|
|
|
9860
|
-
//
|
|
9835
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverMessageAddress.js
|
|
9861
9836
|
async function recoverMessageAddress({ message, signature }) {
|
|
9862
9837
|
return recoverAddress({ hash: hashMessage(message), signature });
|
|
9863
9838
|
}
|
|
9864
9839
|
var init_recoverMessageAddress = __esm({
|
|
9865
|
-
"
|
|
9840
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/recoverMessageAddress.js"() {
|
|
9866
9841
|
"use strict";
|
|
9867
9842
|
init_hashMessage();
|
|
9868
9843
|
init_recoverAddress();
|
|
9869
9844
|
}
|
|
9870
9845
|
});
|
|
9871
9846
|
|
|
9872
|
-
//
|
|
9847
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/verifyMessage.js
|
|
9873
9848
|
async function verifyMessage({ address, message, signature }) {
|
|
9874
9849
|
return isAddressEqual(getAddress(address), await recoverMessageAddress({ message, signature }));
|
|
9875
9850
|
}
|
|
9876
9851
|
var init_verifyMessage = __esm({
|
|
9877
|
-
"
|
|
9852
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/utils/signature/verifyMessage.js"() {
|
|
9878
9853
|
"use strict";
|
|
9879
9854
|
init_getAddress();
|
|
9880
9855
|
init_isAddressEqual();
|
|
@@ -9882,367 +9857,15 @@ var init_verifyMessage = __esm({
|
|
|
9882
9857
|
}
|
|
9883
9858
|
});
|
|
9884
9859
|
|
|
9885
|
-
//
|
|
9860
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/index.js
|
|
9886
9861
|
var init_esm = __esm({
|
|
9887
|
-
"
|
|
9862
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/viem/_esm/index.js"() {
|
|
9888
9863
|
"use strict";
|
|
9889
9864
|
init_verifyMessage();
|
|
9890
9865
|
}
|
|
9891
9866
|
});
|
|
9892
9867
|
|
|
9893
|
-
//
|
|
9894
|
-
function G1s(a, b, c, d, x) {
|
|
9895
|
-
a = a + b + x | 0;
|
|
9896
|
-
d = rotr(d ^ a, 16);
|
|
9897
|
-
c = c + d | 0;
|
|
9898
|
-
b = rotr(b ^ c, 12);
|
|
9899
|
-
return { a, b, c, d };
|
|
9900
|
-
}
|
|
9901
|
-
function G2s(a, b, c, d, x) {
|
|
9902
|
-
a = a + b + x | 0;
|
|
9903
|
-
d = rotr(d ^ a, 8);
|
|
9904
|
-
c = c + d | 0;
|
|
9905
|
-
b = rotr(b ^ c, 7);
|
|
9906
|
-
return { a, b, c, d };
|
|
9907
|
-
}
|
|
9908
|
-
var init_blake = __esm({
|
|
9909
|
-
"../../node_modules/@noble/hashes/esm/_blake.js"() {
|
|
9910
|
-
"use strict";
|
|
9911
|
-
init_utils();
|
|
9912
|
-
}
|
|
9913
|
-
});
|
|
9914
|
-
|
|
9915
|
-
// ../../node_modules/@noble/hashes/esm/blake2.js
|
|
9916
|
-
function compress(s, offset, msg, rounds, v0, v1, v2, v3, v42, v5, v62, v7, v8, v9, v10, v11, v12, v13, v14, v15) {
|
|
9917
|
-
let j = 0;
|
|
9918
|
-
for (let i = 0; i < rounds; i++) {
|
|
9919
|
-
({ a: v0, b: v42, c: v8, d: v12 } = G1s(v0, v42, v8, v12, msg[offset + s[j++]]));
|
|
9920
|
-
({ a: v0, b: v42, c: v8, d: v12 } = G2s(v0, v42, v8, v12, msg[offset + s[j++]]));
|
|
9921
|
-
({ a: v1, b: v5, c: v9, d: v13 } = G1s(v1, v5, v9, v13, msg[offset + s[j++]]));
|
|
9922
|
-
({ a: v1, b: v5, c: v9, d: v13 } = G2s(v1, v5, v9, v13, msg[offset + s[j++]]));
|
|
9923
|
-
({ a: v2, b: v62, c: v10, d: v14 } = G1s(v2, v62, v10, v14, msg[offset + s[j++]]));
|
|
9924
|
-
({ a: v2, b: v62, c: v10, d: v14 } = G2s(v2, v62, v10, v14, msg[offset + s[j++]]));
|
|
9925
|
-
({ a: v3, b: v7, c: v11, d: v15 } = G1s(v3, v7, v11, v15, msg[offset + s[j++]]));
|
|
9926
|
-
({ a: v3, b: v7, c: v11, d: v15 } = G2s(v3, v7, v11, v15, msg[offset + s[j++]]));
|
|
9927
|
-
({ a: v0, b: v5, c: v10, d: v15 } = G1s(v0, v5, v10, v15, msg[offset + s[j++]]));
|
|
9928
|
-
({ a: v0, b: v5, c: v10, d: v15 } = G2s(v0, v5, v10, v15, msg[offset + s[j++]]));
|
|
9929
|
-
({ a: v1, b: v62, c: v11, d: v12 } = G1s(v1, v62, v11, v12, msg[offset + s[j++]]));
|
|
9930
|
-
({ a: v1, b: v62, c: v11, d: v12 } = G2s(v1, v62, v11, v12, msg[offset + s[j++]]));
|
|
9931
|
-
({ a: v2, b: v7, c: v8, d: v13 } = G1s(v2, v7, v8, v13, msg[offset + s[j++]]));
|
|
9932
|
-
({ a: v2, b: v7, c: v8, d: v13 } = G2s(v2, v7, v8, v13, msg[offset + s[j++]]));
|
|
9933
|
-
({ a: v3, b: v42, c: v9, d: v14 } = G1s(v3, v42, v9, v14, msg[offset + s[j++]]));
|
|
9934
|
-
({ a: v3, b: v42, c: v9, d: v14 } = G2s(v3, v42, v9, v14, msg[offset + s[j++]]));
|
|
9935
|
-
}
|
|
9936
|
-
return { v0, v1, v2, v3, v4: v42, v5, v6: v62, v7, v8, v9, v10, v11, v12, v13, v14, v15 };
|
|
9937
|
-
}
|
|
9938
|
-
var BLAKE2;
|
|
9939
|
-
var init_blake2 = __esm({
|
|
9940
|
-
"../../node_modules/@noble/hashes/esm/blake2.js"() {
|
|
9941
|
-
"use strict";
|
|
9942
|
-
init_blake();
|
|
9943
|
-
init_utils();
|
|
9944
|
-
BLAKE2 = class extends Hash {
|
|
9945
|
-
constructor(blockLen, outputLen) {
|
|
9946
|
-
super();
|
|
9947
|
-
this.finished = false;
|
|
9948
|
-
this.destroyed = false;
|
|
9949
|
-
this.length = 0;
|
|
9950
|
-
this.pos = 0;
|
|
9951
|
-
anumber(blockLen);
|
|
9952
|
-
anumber(outputLen);
|
|
9953
|
-
this.blockLen = blockLen;
|
|
9954
|
-
this.outputLen = outputLen;
|
|
9955
|
-
this.buffer = new Uint8Array(blockLen);
|
|
9956
|
-
this.buffer32 = u32(this.buffer);
|
|
9957
|
-
}
|
|
9958
|
-
update(data) {
|
|
9959
|
-
aexists(this);
|
|
9960
|
-
data = toBytes(data);
|
|
9961
|
-
abytes(data);
|
|
9962
|
-
const { blockLen, buffer, buffer32 } = this;
|
|
9963
|
-
const len = data.length;
|
|
9964
|
-
const offset = data.byteOffset;
|
|
9965
|
-
const buf = data.buffer;
|
|
9966
|
-
for (let pos = 0; pos < len; ) {
|
|
9967
|
-
if (this.pos === blockLen) {
|
|
9968
|
-
swap32IfBE(buffer32);
|
|
9969
|
-
this.compress(buffer32, 0, false);
|
|
9970
|
-
swap32IfBE(buffer32);
|
|
9971
|
-
this.pos = 0;
|
|
9972
|
-
}
|
|
9973
|
-
const take = Math.min(blockLen - this.pos, len - pos);
|
|
9974
|
-
const dataOffset = offset + pos;
|
|
9975
|
-
if (take === blockLen && !(dataOffset % 4) && pos + take < len) {
|
|
9976
|
-
const data32 = new Uint32Array(buf, dataOffset, Math.floor((len - pos) / 4));
|
|
9977
|
-
swap32IfBE(data32);
|
|
9978
|
-
for (let pos32 = 0; pos + blockLen < len; pos32 += buffer32.length, pos += blockLen) {
|
|
9979
|
-
this.length += blockLen;
|
|
9980
|
-
this.compress(data32, pos32, false);
|
|
9981
|
-
}
|
|
9982
|
-
swap32IfBE(data32);
|
|
9983
|
-
continue;
|
|
9984
|
-
}
|
|
9985
|
-
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
9986
|
-
this.pos += take;
|
|
9987
|
-
this.length += take;
|
|
9988
|
-
pos += take;
|
|
9989
|
-
}
|
|
9990
|
-
return this;
|
|
9991
|
-
}
|
|
9992
|
-
digestInto(out) {
|
|
9993
|
-
aexists(this);
|
|
9994
|
-
aoutput(out, this);
|
|
9995
|
-
const { pos, buffer32 } = this;
|
|
9996
|
-
this.finished = true;
|
|
9997
|
-
clean(this.buffer.subarray(pos));
|
|
9998
|
-
swap32IfBE(buffer32);
|
|
9999
|
-
this.compress(buffer32, 0, true);
|
|
10000
|
-
swap32IfBE(buffer32);
|
|
10001
|
-
const out32 = u32(out);
|
|
10002
|
-
this.get().forEach((v, i) => out32[i] = swap8IfBE(v));
|
|
10003
|
-
}
|
|
10004
|
-
digest() {
|
|
10005
|
-
const { buffer, outputLen } = this;
|
|
10006
|
-
this.digestInto(buffer);
|
|
10007
|
-
const res = buffer.slice(0, outputLen);
|
|
10008
|
-
this.destroy();
|
|
10009
|
-
return res;
|
|
10010
|
-
}
|
|
10011
|
-
_cloneInto(to) {
|
|
10012
|
-
const { buffer, length: length4, finished, destroyed, outputLen, pos } = this;
|
|
10013
|
-
to || (to = new this.constructor({ dkLen: outputLen }));
|
|
10014
|
-
to.set(...this.get());
|
|
10015
|
-
to.buffer.set(buffer);
|
|
10016
|
-
to.destroyed = destroyed;
|
|
10017
|
-
to.finished = finished;
|
|
10018
|
-
to.length = length4;
|
|
10019
|
-
to.pos = pos;
|
|
10020
|
-
to.outputLen = outputLen;
|
|
10021
|
-
return to;
|
|
10022
|
-
}
|
|
10023
|
-
clone() {
|
|
10024
|
-
return this._cloneInto();
|
|
10025
|
-
}
|
|
10026
|
-
};
|
|
10027
|
-
}
|
|
10028
|
-
});
|
|
10029
|
-
|
|
10030
|
-
// ../../node_modules/@noble/hashes/esm/blake3.js
|
|
10031
|
-
var B3_Flags, B3_IV, B3_SIGMA, BLAKE3, blake3;
|
|
10032
|
-
var init_blake3 = __esm({
|
|
10033
|
-
"../../node_modules/@noble/hashes/esm/blake3.js"() {
|
|
10034
|
-
"use strict";
|
|
10035
|
-
init_md();
|
|
10036
|
-
init_u64();
|
|
10037
|
-
init_blake2();
|
|
10038
|
-
init_utils();
|
|
10039
|
-
B3_Flags = {
|
|
10040
|
-
CHUNK_START: 1,
|
|
10041
|
-
CHUNK_END: 2,
|
|
10042
|
-
PARENT: 4,
|
|
10043
|
-
ROOT: 8,
|
|
10044
|
-
KEYED_HASH: 16,
|
|
10045
|
-
DERIVE_KEY_CONTEXT: 32,
|
|
10046
|
-
DERIVE_KEY_MATERIAL: 64
|
|
10047
|
-
};
|
|
10048
|
-
B3_IV = SHA256_IV.slice();
|
|
10049
|
-
B3_SIGMA = /* @__PURE__ */ (() => {
|
|
10050
|
-
const Id = Array.from({ length: 16 }, (_, i) => i);
|
|
10051
|
-
const permute = (arr) => [2, 6, 3, 10, 7, 0, 4, 13, 1, 11, 12, 5, 9, 14, 15, 8].map((i) => arr[i]);
|
|
10052
|
-
const res = [];
|
|
10053
|
-
for (let i = 0, v = Id; i < 7; i++, v = permute(v))
|
|
10054
|
-
res.push(...v);
|
|
10055
|
-
return Uint8Array.from(res);
|
|
10056
|
-
})();
|
|
10057
|
-
BLAKE3 = class _BLAKE3 extends BLAKE2 {
|
|
10058
|
-
constructor(opts = {}, flags = 0) {
|
|
10059
|
-
super(64, opts.dkLen === void 0 ? 32 : opts.dkLen);
|
|
10060
|
-
this.chunkPos = 0;
|
|
10061
|
-
this.chunksDone = 0;
|
|
10062
|
-
this.flags = 0 | 0;
|
|
10063
|
-
this.stack = [];
|
|
10064
|
-
this.posOut = 0;
|
|
10065
|
-
this.bufferOut32 = new Uint32Array(16);
|
|
10066
|
-
this.chunkOut = 0;
|
|
10067
|
-
this.enableXOF = true;
|
|
10068
|
-
const { key, context } = opts;
|
|
10069
|
-
const hasContext = context !== void 0;
|
|
10070
|
-
if (key !== void 0) {
|
|
10071
|
-
if (hasContext)
|
|
10072
|
-
throw new Error('Only "key" or "context" can be specified at same time');
|
|
10073
|
-
const k = toBytes(key).slice();
|
|
10074
|
-
abytes(k, 32);
|
|
10075
|
-
this.IV = u32(k);
|
|
10076
|
-
swap32IfBE(this.IV);
|
|
10077
|
-
this.flags = flags | B3_Flags.KEYED_HASH;
|
|
10078
|
-
} else if (hasContext) {
|
|
10079
|
-
const ctx = toBytes(context);
|
|
10080
|
-
const contextKey = new _BLAKE3({ dkLen: 32 }, B3_Flags.DERIVE_KEY_CONTEXT).update(ctx).digest();
|
|
10081
|
-
this.IV = u32(contextKey);
|
|
10082
|
-
swap32IfBE(this.IV);
|
|
10083
|
-
this.flags = flags | B3_Flags.DERIVE_KEY_MATERIAL;
|
|
10084
|
-
} else {
|
|
10085
|
-
this.IV = B3_IV.slice();
|
|
10086
|
-
this.flags = flags;
|
|
10087
|
-
}
|
|
10088
|
-
this.state = this.IV.slice();
|
|
10089
|
-
this.bufferOut = u8(this.bufferOut32);
|
|
10090
|
-
}
|
|
10091
|
-
// Unused
|
|
10092
|
-
get() {
|
|
10093
|
-
return [];
|
|
10094
|
-
}
|
|
10095
|
-
set() {
|
|
10096
|
-
}
|
|
10097
|
-
b2Compress(counter, flags, buf, bufPos = 0) {
|
|
10098
|
-
const { state: s, pos } = this;
|
|
10099
|
-
const { h, l } = fromBig(BigInt(counter), true);
|
|
10100
|
-
const { v0, v1, v2, v3, v4: v42, v5, v6: v62, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = compress(B3_SIGMA, bufPos, buf, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], h, l, pos, flags);
|
|
10101
|
-
s[0] = v0 ^ v8;
|
|
10102
|
-
s[1] = v1 ^ v9;
|
|
10103
|
-
s[2] = v2 ^ v10;
|
|
10104
|
-
s[3] = v3 ^ v11;
|
|
10105
|
-
s[4] = v42 ^ v12;
|
|
10106
|
-
s[5] = v5 ^ v13;
|
|
10107
|
-
s[6] = v62 ^ v14;
|
|
10108
|
-
s[7] = v7 ^ v15;
|
|
10109
|
-
}
|
|
10110
|
-
compress(buf, bufPos = 0, isLast = false) {
|
|
10111
|
-
let flags = this.flags;
|
|
10112
|
-
if (!this.chunkPos)
|
|
10113
|
-
flags |= B3_Flags.CHUNK_START;
|
|
10114
|
-
if (this.chunkPos === 15 || isLast)
|
|
10115
|
-
flags |= B3_Flags.CHUNK_END;
|
|
10116
|
-
if (!isLast)
|
|
10117
|
-
this.pos = this.blockLen;
|
|
10118
|
-
this.b2Compress(this.chunksDone, flags, buf, bufPos);
|
|
10119
|
-
this.chunkPos += 1;
|
|
10120
|
-
if (this.chunkPos === 16 || isLast) {
|
|
10121
|
-
let chunk = this.state;
|
|
10122
|
-
this.state = this.IV.slice();
|
|
10123
|
-
for (let last, chunks = this.chunksDone + 1; isLast || !(chunks & 1); chunks >>= 1) {
|
|
10124
|
-
if (!(last = this.stack.pop()))
|
|
10125
|
-
break;
|
|
10126
|
-
this.buffer32.set(last, 0);
|
|
10127
|
-
this.buffer32.set(chunk, 8);
|
|
10128
|
-
this.pos = this.blockLen;
|
|
10129
|
-
this.b2Compress(0, this.flags | B3_Flags.PARENT, this.buffer32, 0);
|
|
10130
|
-
chunk = this.state;
|
|
10131
|
-
this.state = this.IV.slice();
|
|
10132
|
-
}
|
|
10133
|
-
this.chunksDone++;
|
|
10134
|
-
this.chunkPos = 0;
|
|
10135
|
-
this.stack.push(chunk);
|
|
10136
|
-
}
|
|
10137
|
-
this.pos = 0;
|
|
10138
|
-
}
|
|
10139
|
-
_cloneInto(to) {
|
|
10140
|
-
to = super._cloneInto(to);
|
|
10141
|
-
const { IV, flags, state, chunkPos, posOut, chunkOut, stack, chunksDone } = this;
|
|
10142
|
-
to.state.set(state.slice());
|
|
10143
|
-
to.stack = stack.map((i) => Uint32Array.from(i));
|
|
10144
|
-
to.IV.set(IV);
|
|
10145
|
-
to.flags = flags;
|
|
10146
|
-
to.chunkPos = chunkPos;
|
|
10147
|
-
to.chunksDone = chunksDone;
|
|
10148
|
-
to.posOut = posOut;
|
|
10149
|
-
to.chunkOut = chunkOut;
|
|
10150
|
-
to.enableXOF = this.enableXOF;
|
|
10151
|
-
to.bufferOut32.set(this.bufferOut32);
|
|
10152
|
-
return to;
|
|
10153
|
-
}
|
|
10154
|
-
destroy() {
|
|
10155
|
-
this.destroyed = true;
|
|
10156
|
-
clean(this.state, this.buffer32, this.IV, this.bufferOut32);
|
|
10157
|
-
clean(...this.stack);
|
|
10158
|
-
}
|
|
10159
|
-
// Same as b2Compress, but doesn't modify state and returns 16 u32 array (instead of 8)
|
|
10160
|
-
b2CompressOut() {
|
|
10161
|
-
const { state: s, pos, flags, buffer32, bufferOut32: out32 } = this;
|
|
10162
|
-
const { h, l } = fromBig(BigInt(this.chunkOut++));
|
|
10163
|
-
swap32IfBE(buffer32);
|
|
10164
|
-
const { v0, v1, v2, v3, v4: v42, v5, v6: v62, v7, v8, v9, v10, v11, v12, v13, v14, v15 } = compress(B3_SIGMA, 0, buffer32, 7, s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7], B3_IV[0], B3_IV[1], B3_IV[2], B3_IV[3], l, h, pos, flags);
|
|
10165
|
-
out32[0] = v0 ^ v8;
|
|
10166
|
-
out32[1] = v1 ^ v9;
|
|
10167
|
-
out32[2] = v2 ^ v10;
|
|
10168
|
-
out32[3] = v3 ^ v11;
|
|
10169
|
-
out32[4] = v42 ^ v12;
|
|
10170
|
-
out32[5] = v5 ^ v13;
|
|
10171
|
-
out32[6] = v62 ^ v14;
|
|
10172
|
-
out32[7] = v7 ^ v15;
|
|
10173
|
-
out32[8] = s[0] ^ v8;
|
|
10174
|
-
out32[9] = s[1] ^ v9;
|
|
10175
|
-
out32[10] = s[2] ^ v10;
|
|
10176
|
-
out32[11] = s[3] ^ v11;
|
|
10177
|
-
out32[12] = s[4] ^ v12;
|
|
10178
|
-
out32[13] = s[5] ^ v13;
|
|
10179
|
-
out32[14] = s[6] ^ v14;
|
|
10180
|
-
out32[15] = s[7] ^ v15;
|
|
10181
|
-
swap32IfBE(buffer32);
|
|
10182
|
-
swap32IfBE(out32);
|
|
10183
|
-
this.posOut = 0;
|
|
10184
|
-
}
|
|
10185
|
-
finish() {
|
|
10186
|
-
if (this.finished)
|
|
10187
|
-
return;
|
|
10188
|
-
this.finished = true;
|
|
10189
|
-
clean(this.buffer.subarray(this.pos));
|
|
10190
|
-
let flags = this.flags | B3_Flags.ROOT;
|
|
10191
|
-
if (this.stack.length) {
|
|
10192
|
-
flags |= B3_Flags.PARENT;
|
|
10193
|
-
swap32IfBE(this.buffer32);
|
|
10194
|
-
this.compress(this.buffer32, 0, true);
|
|
10195
|
-
swap32IfBE(this.buffer32);
|
|
10196
|
-
this.chunksDone = 0;
|
|
10197
|
-
this.pos = this.blockLen;
|
|
10198
|
-
} else {
|
|
10199
|
-
flags |= (!this.chunkPos ? B3_Flags.CHUNK_START : 0) | B3_Flags.CHUNK_END;
|
|
10200
|
-
}
|
|
10201
|
-
this.flags = flags;
|
|
10202
|
-
this.b2CompressOut();
|
|
10203
|
-
}
|
|
10204
|
-
writeInto(out) {
|
|
10205
|
-
aexists(this, false);
|
|
10206
|
-
abytes(out);
|
|
10207
|
-
this.finish();
|
|
10208
|
-
const { blockLen, bufferOut } = this;
|
|
10209
|
-
for (let pos = 0, len = out.length; pos < len; ) {
|
|
10210
|
-
if (this.posOut >= blockLen)
|
|
10211
|
-
this.b2CompressOut();
|
|
10212
|
-
const take = Math.min(blockLen - this.posOut, len - pos);
|
|
10213
|
-
out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
|
|
10214
|
-
this.posOut += take;
|
|
10215
|
-
pos += take;
|
|
10216
|
-
}
|
|
10217
|
-
return out;
|
|
10218
|
-
}
|
|
10219
|
-
xofInto(out) {
|
|
10220
|
-
if (!this.enableXOF)
|
|
10221
|
-
throw new Error("XOF is not possible after digest call");
|
|
10222
|
-
return this.writeInto(out);
|
|
10223
|
-
}
|
|
10224
|
-
xof(bytes) {
|
|
10225
|
-
anumber(bytes);
|
|
10226
|
-
return this.xofInto(new Uint8Array(bytes));
|
|
10227
|
-
}
|
|
10228
|
-
digestInto(out) {
|
|
10229
|
-
aoutput(out, this);
|
|
10230
|
-
if (this.finished)
|
|
10231
|
-
throw new Error("digest() was already called");
|
|
10232
|
-
this.enableXOF = false;
|
|
10233
|
-
this.writeInto(out);
|
|
10234
|
-
this.destroy();
|
|
10235
|
-
return out;
|
|
10236
|
-
}
|
|
10237
|
-
digest() {
|
|
10238
|
-
return this.digestInto(new Uint8Array(this.outputLen));
|
|
10239
|
-
}
|
|
10240
|
-
};
|
|
10241
|
-
blake3 = /* @__PURE__ */ createXOFer((opts) => new BLAKE3(opts));
|
|
10242
|
-
}
|
|
10243
|
-
});
|
|
10244
|
-
|
|
10245
|
-
// ../bootstrap/dist/index.js
|
|
9868
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/bootstrap/dist/index.js
|
|
10246
9869
|
function actionKey(action) {
|
|
10247
9870
|
if (action === "*") return "ALL";
|
|
10248
9871
|
return action.toUpperCase().replace(/[^A-Z0-9]/g, "_");
|
|
@@ -10397,7 +10020,7 @@ function composeBootstrapSpaceManifest(space) {
|
|
|
10397
10020
|
}
|
|
10398
10021
|
var CAPABILITIES, KV, SQL, DUCKDB, CAPABILITIES2, HOOKS, ENCRYPTION, SPACE, CAPABILITY_REGISTRY, DEFAULT_MANIFEST_SPACE, ACCOUNT_REGISTRY_SPACE, ACCOUNT_REGISTRY_PATH, SECRETS_SPACE, BOOTSTRAP_DEFAULT_SPACE, BOOTSTRAP_PUBLIC_SPACE, BOOTSTRAP_ENCRYPTION_NETWORK_NAME, BOOTSTRAP_ENCRYPTION_NETWORK_RESOURCE_TEMPLATE, DEFAULT_EXPIRY_MS, VAULT_PERMISSION_SERVICE, ENCRYPTION_PERMISSION_SERVICE, ENCRYPTION_MANIFEST_SPACE, NETWORK_CREATE_ACTION, BOOTSTRAP_SPACE_NAMES, TINYCLOUD_DEFAULT_SPACE_MANIFEST, TINYCLOUD_APPLICATIONS_SPACE_MANIFEST, TINYCLOUD_ACCOUNT_SPACE_MANIFEST, TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST, TINYCLOUD_PUBLIC_SPACE_MANIFEST, BOOTSTRAP_SPACE_MANIFESTS, BOOTSTRAP_PERSISTED_APPLICATION_MANIFESTS, ACCOUNT_INDEX_SCHEMA, SECRET_RECORDS_SCHEMA, BOOTSTRAP_MANIFEST, ACCOUNT_MANIFEST_PERMISSIONS, BOOTSTRAP_DEFAULT_ONLY_SESSION_REQUEST, BOOTSTRAP_WIDENED_DEFAULT_SESSION_REQUEST, BOOTSTRAP_SESSION_REQUESTS, ACCOUNT_SESSION_RAW_ALLOWLIST, BOOTSTRAP_ALLOWLIST;
|
|
10399
10022
|
var init_dist = __esm({
|
|
10400
|
-
"
|
|
10023
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/bootstrap/dist/index.js"() {
|
|
10401
10024
|
"use strict";
|
|
10402
10025
|
CAPABILITIES = [
|
|
10403
10026
|
{ urn: "tinycloud.kv/get", service: "tinycloud.kv", status: "active" },
|
|
@@ -10786,9 +10409,9 @@ var init_dist = __esm({
|
|
|
10786
10409
|
}
|
|
10787
10410
|
});
|
|
10788
10411
|
|
|
10789
|
-
//
|
|
10412
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/ms/index.js
|
|
10790
10413
|
var require_ms = __commonJS({
|
|
10791
|
-
"
|
|
10414
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/ms/index.js"(exports, module) {
|
|
10792
10415
|
"use strict";
|
|
10793
10416
|
var s = 1e3;
|
|
10794
10417
|
var m = s * 60;
|
|
@@ -10903,9 +10526,9 @@ var require_ms = __commonJS({
|
|
|
10903
10526
|
}
|
|
10904
10527
|
});
|
|
10905
10528
|
|
|
10906
|
-
//
|
|
10529
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-services/dist/internal/decrypt-transport-response-error.cjs
|
|
10907
10530
|
var require_decrypt_transport_response_error = __commonJS({
|
|
10908
|
-
"
|
|
10531
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-services/dist/internal/decrypt-transport-response-error.cjs"(exports, module) {
|
|
10909
10532
|
"use strict";
|
|
10910
10533
|
var __defProp4 = Object.defineProperty;
|
|
10911
10534
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -10940,7 +10563,7 @@ var require_decrypt_transport_response_error = __commonJS({
|
|
|
10940
10563
|
}
|
|
10941
10564
|
});
|
|
10942
10565
|
|
|
10943
|
-
//
|
|
10566
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-services/dist/index.js
|
|
10944
10567
|
function ok(data) {
|
|
10945
10568
|
return { ok: true, data };
|
|
10946
10569
|
}
|
|
@@ -11809,9 +11432,7 @@ function canonicalizeSecretScope(scope) {
|
|
|
11809
11432
|
}
|
|
11810
11433
|
const trimmed = scope.trim();
|
|
11811
11434
|
if (trimmed === "") {
|
|
11812
|
-
throw new Error(
|
|
11813
|
-
"Secret scope must be non-empty; omit scope for global secrets."
|
|
11814
|
-
);
|
|
11435
|
+
throw new Error("Secret scope must be non-empty; omit scope for global secrets.");
|
|
11815
11436
|
}
|
|
11816
11437
|
const canonical = trimmed.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
11817
11438
|
if (canonical === "") {
|
|
@@ -12602,7 +12223,7 @@ function encErr(error) {
|
|
|
12602
12223
|
}
|
|
12603
12224
|
var import_decrypt_transport_response_error, ErrorCodes, defaultRetryPolicy, TelemetryEvents, REDACTED, SAFE_NUMBER_FIELDS, SAFE_BOOLEAN_FIELDS, DEBUG_FLAG, MAX_EVENTS, TinyCloudDebugLogger, tinyCloudDebugLogger, ServiceErrorSchema, GenericResultSchema, KVResponseHeadersSchema, GenericKVResponseSchema, KVListResponseSchema, KVListResultSchema, ServiceRequestEventSchema, ServiceResponseEventSchema, ServiceErrorEventSchema, ServiceRetryEventSchema, TelemetrySpanEventSchema, RetryPolicySchema, ServiceSessionSchema, BaseService, PrefixedKVService, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, KVAction, MAX_KV_BATCH_READ_ITEMS, KVService, SQLMigrations, DatabaseHandle, SQLAction, DDL_TOKENS, MIGRATIONS_TABLE, MIGRATIONS_SCHEMA, MIGRATIONS_META_NAMESPACE, MIGRATIONS_META_ID, SQLService, DuckDbDatabaseHandle, DuckDbAction, DuckDbService, AsyncQueue, HooksService, VaultVersionConfig, CURRENT_VAULT_VERSION, VaultHeaders, DB_NAME, DB_VERSION, STORE_NAME, WRAP_KEY_ID, DataVaultService, SECRET_NAME_RE, SECRET_PREFIX, SCOPED_SECRET_PREFIX, RESERVED_SECRET_SCOPES, HEX, URN_PREFIX, NETWORK_NAME_RE, PKH_EIP155_DID_RE, NetworkIdError, DEFAULT_ENCRYPTION_ALG, ENVELOPE_VERSION, DEFAULT_KEY_VERSION, DECRYPT_FACT_TYPE, DECRYPT_RESULT_TYPE, EncryptionService;
|
|
12604
12225
|
var init_dist2 = __esm({
|
|
12605
|
-
"
|
|
12226
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-services/dist/index.js"() {
|
|
12606
12227
|
"use strict";
|
|
12607
12228
|
init_zod();
|
|
12608
12229
|
init_dist();
|
|
@@ -14673,7 +14294,7 @@ var init_dist2 = __esm({
|
|
|
14673
14294
|
async handleErrorResponse(response, operation) {
|
|
14674
14295
|
const errorText = await response.text();
|
|
14675
14296
|
const errorBody = parseServiceErrorBody(errorText);
|
|
14676
|
-
const
|
|
14297
|
+
const errorCode = this.mapHttpStatusToErrorCode(
|
|
14677
14298
|
response.status,
|
|
14678
14299
|
errorBody.error
|
|
14679
14300
|
);
|
|
@@ -14691,7 +14312,7 @@ var init_dist2 = __esm({
|
|
|
14691
14312
|
if (resource) meta.resource = resource;
|
|
14692
14313
|
}
|
|
14693
14314
|
return err(
|
|
14694
|
-
serviceError(
|
|
14315
|
+
serviceError(errorCode, message, "sql", { meta })
|
|
14695
14316
|
);
|
|
14696
14317
|
}
|
|
14697
14318
|
mapHttpStatusToErrorCode(status, serverError) {
|
|
@@ -15021,7 +14642,7 @@ var init_dist2 = __esm({
|
|
|
15021
14642
|
async handleErrorResponse(response, operation) {
|
|
15022
14643
|
const errorText = await response.text();
|
|
15023
14644
|
const errorBody = parseServiceErrorBody(errorText);
|
|
15024
|
-
const
|
|
14645
|
+
const errorCode = this.mapHttpStatusToErrorCode(
|
|
15025
14646
|
response.status,
|
|
15026
14647
|
errorBody.error
|
|
15027
14648
|
);
|
|
@@ -15039,7 +14660,7 @@ var init_dist2 = __esm({
|
|
|
15039
14660
|
if (resource) meta.resource = resource;
|
|
15040
14661
|
}
|
|
15041
14662
|
return err(
|
|
15042
|
-
serviceError(
|
|
14663
|
+
serviceError(errorCode, message, "duckdb", { meta })
|
|
15043
14664
|
);
|
|
15044
14665
|
}
|
|
15045
14666
|
mapHttpStatusToErrorCode(status, serverError) {
|
|
@@ -16805,10 +16426,7 @@ var init_dist2 = __esm({
|
|
|
16805
16426
|
const descriptor = usable.data;
|
|
16806
16427
|
const networkPublicKey = base64Decode2(descriptor.publicEncryptionKey);
|
|
16807
16428
|
const result = encryptToNetwork(this.crypto, {
|
|
16808
|
-
|
|
16809
|
-
// that spelling in the envelope so a later response can be compared
|
|
16810
|
-
// byte-for-byte (notably for checksummed did:pkh principals).
|
|
16811
|
-
networkId: descriptor.networkId,
|
|
16429
|
+
networkId,
|
|
16812
16430
|
networkPublicKey,
|
|
16813
16431
|
plaintext,
|
|
16814
16432
|
...options?.aad !== void 0 ? { aad: options.aad } : {},
|
|
@@ -16970,7 +16588,7 @@ var init_dist2 = __esm({
|
|
|
16970
16588
|
}
|
|
16971
16589
|
});
|
|
16972
16590
|
|
|
16973
|
-
//
|
|
16591
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/share-sdk/dist/index.js
|
|
16974
16592
|
function setErrorMap2(map) {
|
|
16975
16593
|
overrideErrorMap2 = map;
|
|
16976
16594
|
}
|
|
@@ -17473,25 +17091,25 @@ function encodeTo(int, target, offset = 0) {
|
|
|
17473
17091
|
function encodingLength(int) {
|
|
17474
17092
|
return varint_default.encodingLength(int);
|
|
17475
17093
|
}
|
|
17476
|
-
function create(code22,
|
|
17477
|
-
const size2 =
|
|
17094
|
+
function create(code22, digest4) {
|
|
17095
|
+
const size2 = digest4.byteLength;
|
|
17478
17096
|
const sizeOffset = encodingLength(code22);
|
|
17479
17097
|
const digestOffset = sizeOffset + encodingLength(size2);
|
|
17480
17098
|
const bytes3 = new Uint8Array(digestOffset + size2);
|
|
17481
17099
|
encodeTo(code22, bytes3, 0);
|
|
17482
17100
|
encodeTo(size2, bytes3, sizeOffset);
|
|
17483
|
-
bytes3.set(
|
|
17484
|
-
return new Digest(code22, size2,
|
|
17101
|
+
bytes3.set(digest4, digestOffset);
|
|
17102
|
+
return new Digest(code22, size2, digest4, bytes3);
|
|
17485
17103
|
}
|
|
17486
17104
|
function decode4(multihash) {
|
|
17487
17105
|
const bytes3 = coerce22(multihash);
|
|
17488
17106
|
const [code22, sizeOffset] = decode3(bytes3);
|
|
17489
17107
|
const [size2, digestOffset] = decode3(bytes3.subarray(sizeOffset));
|
|
17490
|
-
const
|
|
17491
|
-
if (
|
|
17108
|
+
const digest4 = bytes3.subarray(sizeOffset + digestOffset);
|
|
17109
|
+
if (digest4.byteLength !== size2) {
|
|
17492
17110
|
throw new Error("Incorrect length");
|
|
17493
17111
|
}
|
|
17494
|
-
return new Digest(code22, size2,
|
|
17112
|
+
return new Digest(code22, size2, digest4, bytes3);
|
|
17495
17113
|
}
|
|
17496
17114
|
function equals2(a, b) {
|
|
17497
17115
|
if (a === b) {
|
|
@@ -17584,8 +17202,8 @@ function encodeCID(version2, code22, multihash) {
|
|
|
17584
17202
|
return bytes3;
|
|
17585
17203
|
}
|
|
17586
17204
|
async function computeCid(bytes3) {
|
|
17587
|
-
const
|
|
17588
|
-
return CID.create(1, code,
|
|
17205
|
+
const digest4 = create(SHA256_CODE, sha256(new Uint8Array(bytes3)));
|
|
17206
|
+
return CID.create(1, code, digest4).toString();
|
|
17589
17207
|
}
|
|
17590
17208
|
function isCanonicalRawCid(cidString) {
|
|
17591
17209
|
let cid2;
|
|
@@ -17697,7 +17315,7 @@ function validateV3Invariants(value, ctx) {
|
|
|
17697
17315
|
if (value.contentSource.encryptionNetwork !== value.encryptionNetwork) {
|
|
17698
17316
|
ctx.addIssue({ code: external_exports2.ZodIssueCode.custom, path: ["encryptionNetwork"], message: "encryption network is not bound to the source" });
|
|
17699
17317
|
}
|
|
17700
|
-
if (value.attestedEnforcerBinding.enforcerDid !== value.target.nodeAudience || value.attestedEnforcerBinding.signature.signerDid !== value.
|
|
17318
|
+
if (value.attestedEnforcerBinding.enforcerDid !== value.target.nodeAudience || value.attestedEnforcerBinding.nodeAudience !== value.target.nodeAudience || value.attestedEnforcerBinding.signature.signerDid !== value.target.nodeAudience || Date.parse(value.attestedEnforcerBinding.expiresAt) < Date.parse(value.expiry)) {
|
|
17701
17319
|
ctx.addIssue({ code: external_exports2.ZodIssueCode.custom, path: ["attestedEnforcerBinding"], message: "enforcer binding does not cover the target and share lifetime" });
|
|
17702
17320
|
}
|
|
17703
17321
|
if (value.policy.contentSource.shareId !== value.contentSource.shareId || value.policy.contentSource.kvResource !== value.contentSource.kvResource || value.policy.contentSource.selector !== value.contentSource.selector || value.policy.contentSource.encryptionNetwork !== value.encryptionNetwork || value.policy.contentSource.encryptedSymmetricKeyDigestHex !== value.contentSource.encryptedSymmetricKeyDigestHex || value.policy.contentSource.keyVersion !== value.contentSource.keyVersion || value.policy.contentSource.mode !== value.contentSource.mode || value.policy.contentSource.initialCiphertextDigestHex !== value.contentSource.initialCiphertextDigestHex) {
|
|
@@ -18041,42 +17659,6 @@ function serialize(value) {
|
|
|
18041
17659
|
function canonicalize2(value) {
|
|
18042
17660
|
return serialize(value);
|
|
18043
17661
|
}
|
|
18044
|
-
function verifyCompactUcanAuthorization(authorization, expectedCid) {
|
|
18045
|
-
if (/\s/.test(authorization)) throw new TypeError("compact Authorization contains whitespace");
|
|
18046
|
-
const segments = authorization.split(".");
|
|
18047
|
-
if (segments.length !== 3 || segments.some((segment) => segment.length === 0)) throw new TypeError("compact Authorization must contain three segments");
|
|
18048
|
-
const [headerSegment, payloadSegment, signatureSegment] = segments;
|
|
18049
|
-
const headerBytes = fromBase64Url(headerSegment);
|
|
18050
|
-
const payloadBytes = fromBase64Url(payloadSegment);
|
|
18051
|
-
const signature = fromBase64Url(signatureSegment);
|
|
18052
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
18053
|
-
const header = JSON.parse(decoder.decode(headerBytes));
|
|
18054
|
-
const payload = JSON.parse(decoder.decode(payloadBytes));
|
|
18055
|
-
if (canonicalize2(header) !== decoder.decode(headerBytes) || canonicalize2(payload) !== decoder.decode(payloadBytes)) throw new TypeError("compact Authorization JSON is not canonical");
|
|
18056
|
-
assertExactKeys(header, ["alg", "jwk", "typ", "ucv"], "protected header");
|
|
18057
|
-
const jwk = object(header.jwk, "protected JWK");
|
|
18058
|
-
assertExactKeys(jwk, ["alg", "crv", "kty", "x"], "protected JWK");
|
|
18059
|
-
if (header.alg !== "EdDSA" || header.typ !== "JWT" || header.ucv !== "0.10.0" || jwk.alg !== "EdDSA" || jwk.crv !== "Ed25519" || jwk.kty !== "OKP" || typeof jwk.x !== "string") throw new TypeError("compact Authorization header is invalid");
|
|
18060
|
-
assertExactKeys(payload, ["att", "aud", "exp", "fct", "iss", "nbf", "nnc", "prf"], "UCAN payload");
|
|
18061
|
-
if (typeof payload.iss !== "string" || typeof payload.aud !== "string" || typeof payload.nnc !== "string" || !Number.isInteger(payload.nbf) || !Number.isInteger(payload.exp) || payload.nbf >= payload.exp || !Array.isArray(payload.prf) || payload.prf.some((proof) => typeof proof !== "string") || !Array.isArray(payload.fct) || payload.fct.length !== 1) throw new TypeError("compact Authorization payload is invalid");
|
|
18062
|
-
const principal = payload.iss.split("#", 1)[0];
|
|
18063
|
-
const publicKey = ed25519PublicKeyFromDidKey(principal);
|
|
18064
|
-
if (!equal(publicKey, fromBase64Url(jwk.x))) throw new TypeError("compact Authorization JWK does not bind issuer");
|
|
18065
|
-
if (!ed25519.verify(signature, new TextEncoder().encode(`${headerSegment}.${payloadSegment}`), publicKey, { zip215: false })) throw new TypeError("compact Authorization signature is invalid");
|
|
18066
|
-
const cid2 = CID.createV1(85, create(30, blake3(new TextEncoder().encode(authorization)))).toString();
|
|
18067
|
-
if (expectedCid !== void 0 && cid2 !== expectedCid) throw new TypeError("compact Authorization CID mismatch");
|
|
18068
|
-
return { authorization, cid: cid2, header, payload };
|
|
18069
|
-
}
|
|
18070
|
-
function object(value, label) {
|
|
18071
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new TypeError(`${label} must be an object`);
|
|
18072
|
-
return value;
|
|
18073
|
-
}
|
|
18074
|
-
function assertExactKeys(value, keys, label) {
|
|
18075
|
-
if (Object.keys(value).length !== keys.length || Object.keys(value).some((key) => !keys.includes(key))) throw new TypeError(`${label} has unknown or missing fields`);
|
|
18076
|
-
}
|
|
18077
|
-
function equal(left, right) {
|
|
18078
|
-
return left.length === right.length && left.every((byte, index) => byte === right[index]);
|
|
18079
|
-
}
|
|
18080
17662
|
function signingBytes(unsigned) {
|
|
18081
17663
|
const domain = utf8Bytes(ENVELOPE_SIGNATURE_DOMAIN);
|
|
18082
17664
|
const body = utf8Bytes(canonicalize2(unsigned));
|
|
@@ -18093,14 +17675,6 @@ function signingBytesV2(unsigned) {
|
|
|
18093
17675
|
bytes3.set(body, domain.length);
|
|
18094
17676
|
return bytes3;
|
|
18095
17677
|
}
|
|
18096
|
-
function signingBytesV3(unsigned) {
|
|
18097
|
-
const domain = utf8Bytes(ENVELOPE_V3_SIGNATURE_DOMAIN);
|
|
18098
|
-
const body = utf8Bytes(canonicalize2(unsigned));
|
|
18099
|
-
const bytes3 = new Uint8Array(domain.length + body.length);
|
|
18100
|
-
bytes3.set(domain);
|
|
18101
|
-
bytes3.set(body, domain.length);
|
|
18102
|
-
return bytes3;
|
|
18103
|
-
}
|
|
18104
17678
|
function signEnvelope(envelopeWithoutSig, ed25519PrivKey) {
|
|
18105
17679
|
const unsigned = unsignedShareEnvelopeSchema.parse(envelopeWithoutSig);
|
|
18106
17680
|
const publicKey = ed25519.getPublicKey(ed25519PrivKey);
|
|
@@ -18148,92 +17722,6 @@ async function verifyEnvelopeV2(envelope, options) {
|
|
|
18148
17722
|
if (parsed.authorizationTarget.kind === "policy") return await computeCid(fromBase64Url(parsed.authorizationTarget.policyBytes)) === parsed.authorizationTarget.policyCid;
|
|
18149
17723
|
return true;
|
|
18150
17724
|
}
|
|
18151
|
-
function verifyEnvelopeV3SignatureOnly(envelope) {
|
|
18152
|
-
const parsed = shareEnvelopeV3Schema.parse(envelope);
|
|
18153
|
-
const { signature, ...unsigned } = parsed;
|
|
18154
|
-
return ed25519.verify(fromBase64Url(signature.value), sha2562(signingBytesV3(unsigned)), ed25519PublicKeyFromDidKey(signature.signerDid), ED25519_VERIFY_OPTS2);
|
|
18155
|
-
}
|
|
18156
|
-
async function verifyEnvelopeV3(envelope, options) {
|
|
18157
|
-
const parsed = shareEnvelopeV3Schema.parse(envelope);
|
|
18158
|
-
if (parsed.signature.signerDid !== options.expectedSignerDid || parsed.signature.signerDid !== parsed.policy.ownerDid || !verifyEnvelopeV3SignatureOnly(parsed)) return false;
|
|
18159
|
-
const { policy } = parsed;
|
|
18160
|
-
const unsignedPolicy = { ...policy };
|
|
18161
|
-
delete unsignedPolicy.policyId;
|
|
18162
|
-
delete unsignedPolicy.signature;
|
|
18163
|
-
const policySignatureDomain = policy.schema === "xyz.tinycloud.policy/policy/v2" ? POLICY_V2_SIGNATURE_DOMAIN : POLICY_V1_SIGNATURE_DOMAIN;
|
|
18164
|
-
const policyDigest = sha2562(new TextEncoder().encode(`${policySignatureDomain}${canonicalize2(unsignedPolicy)}`));
|
|
18165
|
-
const policySignature = policy.signature;
|
|
18166
|
-
if (policySignature.suite !== "Ed25519" || policySignature.signerDid !== policy.ownerDid) return false;
|
|
18167
|
-
let policyPublicKey;
|
|
18168
|
-
let policySignatureBytes;
|
|
18169
|
-
try {
|
|
18170
|
-
policyPublicKey = ed25519PublicKeyFromDidKey(policy.ownerDid);
|
|
18171
|
-
policySignatureBytes = fromBase64Url(policySignature.value);
|
|
18172
|
-
} catch {
|
|
18173
|
-
return false;
|
|
18174
|
-
}
|
|
18175
|
-
if (policySignatureBytes.length !== 64 || !ed25519.verify(policySignatureBytes, policyDigest, policyPublicKey, ED25519_VERIFY_OPTS2)) return false;
|
|
18176
|
-
const policyIdDigest = policyDigest;
|
|
18177
|
-
if (policy.policyId !== `pol_${base32Lower(policyIdDigest)}`) return false;
|
|
18178
|
-
const policyBytes = new TextEncoder().encode(canonicalize2(policy));
|
|
18179
|
-
if (await computeCid(policyBytes) !== parsed.policyCid) return false;
|
|
18180
|
-
const sourceDigest = sha2562(new TextEncoder().encode(`${CONTENT_SOURCE_V1_DOMAIN}${canonicalize2(policy.contentSource)}`));
|
|
18181
|
-
if (hex(sourceDigest) !== parsed.contentSourceDigestHex) return false;
|
|
18182
|
-
const sortedCapabilities = [...policy.capabilityCeiling].sort((left, right) => canonicalize2(left).localeCompare(canonicalize2(right)));
|
|
18183
|
-
const capabilityCeilingHashHex = hex(sha2562(new TextEncoder().encode(`${POLICY_CAPABILITY_V1_DOMAIN}${canonicalize2(sortedCapabilities)}`)));
|
|
18184
|
-
const nativeProjection2 = sortedCapabilities.map((capability) => capability.kind === "encryption" ? { service: "tinycloud.encryption", space: capability.resource, path: capability.resource, actions: [capability.action] } : { service: "tinycloud.kv", space: capability.resource.slice(0, capability.resource.indexOf("/kv/")), path: capability.resource.split("/kv/")[1], actions: [...capability.actions], caveat: { type: "xyz.tinycloud.resource/selector", kind: capability.selector, value: capability.resource } }).sort((left, right) => canonicalize2(left).localeCompare(canonicalize2(right)));
|
|
18185
|
-
const nativeProjectionHashHex = hex(sha2562(new TextEncoder().encode(`${NATIVE_PROJECTION_V1_DOMAIN}${canonicalize2(nativeProjection2)}`)));
|
|
18186
|
-
const expectedAttenuation = Object.fromEntries(sortedCapabilities.map((capability) => capability.kind === "encryption" ? [capability.resource, { [capability.action]: [{}] }] : [capability.resource, Object.fromEntries(capability.actions.map((action) => [action, [{ kind: capability.selector, type: "xyz.tinycloud.resource/selector", value: capability.resource }]]))]));
|
|
18187
|
-
const kv = policy.capabilityCeiling.find((capability) => capability.kind === "kv");
|
|
18188
|
-
const expectedKvActions = parsed.actions.flatMap((action) => action === "read" ? ["tinycloud.kv/get", "tinycloud.kv/metadata"] : action === "list" ? ["tinycloud.kv/list"] : ["tinycloud.kv/put"]);
|
|
18189
|
-
const marker = parsed.contentSource.kvResource.indexOf("/kv/");
|
|
18190
|
-
const resourceSpace = marker < 1 ? "" : parsed.contentSource.kvResource.slice(0, marker);
|
|
18191
|
-
const resourcePath = marker < 1 ? "" : parsed.contentSource.kvResource.slice(marker + 4);
|
|
18192
|
-
if (parsed.shareId !== parsed.contentSource.shareId || resourceSpace !== parsed.target.spaceId || resourcePath !== parsed.resource.path.replace(/\/$/, "") || parsed.resource.kind !== parsed.contentSource.selector || kv?.kind !== "kv" || expectedKvActions.some((action) => !kv.actions.includes(action)) || parsed.encryptionNetwork !== parsed.contentSource.encryptionNetwork || parsed.contentSource.keyVersion <= 0 || policy.expiresAt !== void 0 && Date.parse(parsed.expiry) > Date.parse(policy.expiresAt)) return false;
|
|
18193
|
-
const binding = parsed.attestedEnforcerBinding;
|
|
18194
|
-
const { signature: bindingSignature, ...unsignedBinding } = binding;
|
|
18195
|
-
const expectedBindingDigestHex = hex(sha2562(new TextEncoder().encode(canonicalize2({ enforcerDid: binding.enforcerDid, nodeAudience: binding.nodeAudience }))));
|
|
18196
|
-
if (binding.enforcerDid !== parsed.target.nodeAudience || binding.attestationBindingDigestHex !== expectedBindingDigestHex || bindingSignature.signerDid !== binding.nodeAudience || bindingSignature.suite !== "Ed25519" || Date.parse(binding.issuedAt) > Date.now() || Date.parse(binding.expiresAt) <= Date.now() || Date.parse(binding.expiresAt) < Date.parse(parsed.expiry)) return false;
|
|
18197
|
-
try {
|
|
18198
|
-
const digest3 = sha2562(new TextEncoder().encode(`${ATTESTED_ENFORCER_V2_DOMAIN}${canonicalize2(unsignedBinding)}`));
|
|
18199
|
-
if (!ed25519.verify(fromBase64Url(bindingSignature.value), digest3, ed25519PublicKeyFromDidKey(binding.nodeAudience), ED25519_VERIFY_OPTS2)) return false;
|
|
18200
|
-
} catch {
|
|
18201
|
-
return false;
|
|
18202
|
-
}
|
|
18203
|
-
if (parsed.policyRoot.role !== "policy-authority" || parsed.enforcementRoot.role !== "policy-enforcement" || parsed.policyRoot.cid === parsed.enforcementRoot.cid) return false;
|
|
18204
|
-
try {
|
|
18205
|
-
const policyRoot = verifyCompactUcanAuthorization(parsed.policyRoot.authorization, parsed.policyRoot.cid);
|
|
18206
|
-
const enforcementRoot = verifyCompactUcanAuthorization(parsed.enforcementRoot.authorization, parsed.enforcementRoot.cid);
|
|
18207
|
-
const policyFact = policyRoot.payload.fct[0];
|
|
18208
|
-
const enforcementFact = enforcementRoot.payload.fct[0];
|
|
18209
|
-
const common = ["ownerDid", "policyId", "policyDigestHex", "policyCid", "contentSourceDigestHex", "capabilityCeilingHashHex", "nativeProjectionHashHex", "nodeAudience"];
|
|
18210
|
-
const policyKeys = [...common, "role", "mode"];
|
|
18211
|
-
const enforcementKeys = [...policyKeys, "enforcerDid"];
|
|
18212
|
-
if (Object.keys(policyFact).length !== policyKeys.length || policyKeys.some((key) => !(key in policyFact)) || Object.keys(enforcementFact).length !== enforcementKeys.length || enforcementKeys.some((key) => !(key in enforcementFact)) || policyRoot.payload.prf.length !== 0 || enforcementRoot.payload.prf.length !== 0 || policyRoot.payload.iss.split("#", 1)[0] !== policy.ownerDid || enforcementRoot.payload.iss.split("#", 1)[0] !== policy.ownerDid || policyRoot.payload.nbf !== enforcementRoot.payload.nbf || policyRoot.payload.exp !== enforcementRoot.payload.exp || canonicalize2(policyRoot.payload.att) !== canonicalize2(expectedAttenuation) || canonicalize2(enforcementRoot.payload.att) !== canonicalize2(expectedAttenuation) || policyFact.role !== "policy-authority" || policyFact.mode !== "policy-source" || "enforcerDid" in policyFact || enforcementFact.role !== "policy-enforcement" || enforcementFact.mode !== "conditional-mint" || policyRoot.payload.aud !== `did:tinycloud:policy:${hex(policyIdDigest)}` || enforcementRoot.payload.aud !== binding.enforcerDid || enforcementFact.enforcerDid !== binding.enforcerDid || common.some((key) => policyFact[key] !== enforcementFact[key]) || policyFact.ownerDid !== policy.ownerDid || policyFact.policyId !== policy.policyId || policyFact.policyDigestHex !== hex(policyIdDigest) || policyFact.policyCid !== parsed.policyCid || policyFact.contentSourceDigestHex !== parsed.contentSourceDigestHex || policyFact.capabilityCeilingHashHex !== capabilityCeilingHashHex || policyFact.nativeProjectionHashHex !== nativeProjectionHashHex || policyFact.nodeAudience !== binding.nodeAudience || policyRoot.payload.exp * 1e3 < Date.parse(parsed.expiry)) return false;
|
|
18213
|
-
} catch {
|
|
18214
|
-
return false;
|
|
18215
|
-
}
|
|
18216
|
-
return true;
|
|
18217
|
-
}
|
|
18218
|
-
function hex(bytes3) {
|
|
18219
|
-
return [...bytes3].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
18220
|
-
}
|
|
18221
|
-
function base32Lower(bytes3) {
|
|
18222
|
-
const alphabet2 = "abcdefghijklmnopqrstuvwxyz234567";
|
|
18223
|
-
let output2 = "";
|
|
18224
|
-
let buffer = 0;
|
|
18225
|
-
let bits = 0;
|
|
18226
|
-
for (const byte of bytes3) {
|
|
18227
|
-
buffer = buffer << 8 | byte;
|
|
18228
|
-
bits += 8;
|
|
18229
|
-
while (bits >= 5) {
|
|
18230
|
-
output2 += alphabet2[buffer >>> bits - 5 & 31];
|
|
18231
|
-
bits -= 5;
|
|
18232
|
-
}
|
|
18233
|
-
}
|
|
18234
|
-
if (bits > 0) output2 += alphabet2[buffer << 5 - bits & 31];
|
|
18235
|
-
return output2;
|
|
18236
|
-
}
|
|
18237
17725
|
function assertCanonicalCid(cidString) {
|
|
18238
17726
|
const cid2 = CID.parse(cidString);
|
|
18239
17727
|
if (cid2.version !== 1 || cid2.code !== code || cid2.multihash.code !== 18 || // sha2-256 (0x12) only, at the link layer too
|
|
@@ -18391,12 +17879,8 @@ async function readResponseBytes(response, limit, tooLargeCode) {
|
|
|
18391
17879
|
function registryFetcher(options, limit, tooLargeCode = "max-bytes-exceeded", stage = "envelope") {
|
|
18392
17880
|
if (options.fetchBlob !== void 0) return async (input) => {
|
|
18393
17881
|
try {
|
|
18394
|
-
options.
|
|
18395
|
-
const bytes3 = await options.fetchBlob({ ...input, ...options.signal === void 0 ? {} : { signal: options.signal } });
|
|
18396
|
-
options.signal?.throwIfAborted();
|
|
18397
|
-
return boundedBytes(bytes3, limit, tooLargeCode);
|
|
17882
|
+
return boundedBytes(await options.fetchBlob(input), limit, tooLargeCode);
|
|
18398
17883
|
} catch (error) {
|
|
18399
|
-
if (options.signal?.aborted) throw options.signal.reason ?? error;
|
|
18400
17884
|
if (error instanceof ShareReceiveError) throw error;
|
|
18401
17885
|
throw new ShareReceiveError("fetch-failed", "registry unavailable", { stage });
|
|
18402
17886
|
}
|
|
@@ -18406,26 +17890,17 @@ function registryFetcher(options, limit, tooLargeCode = "max-bytes-exceeded", st
|
|
|
18406
17890
|
const base33 = options.registryBaseUrl.replace(/\/+$/, "");
|
|
18407
17891
|
return async ({ cid: cid2 }) => {
|
|
18408
17892
|
try {
|
|
18409
|
-
|
|
18410
|
-
const response = await fetchFn(`${base33}/ipfs/${cid2}?format=raw`, {
|
|
18411
|
-
headers: { accept: "application/vnd.ipld.raw" },
|
|
18412
|
-
redirect: "error",
|
|
18413
|
-
...options.signal === void 0 ? {} : { signal: options.signal }
|
|
18414
|
-
});
|
|
18415
|
-
options.signal?.throwIfAborted();
|
|
17893
|
+
const response = await fetchFn(`${base33}/ipfs/${cid2}?format=raw`, { headers: { accept: "application/vnd.ipld.raw" }, redirect: "error" });
|
|
18416
17894
|
if (!response.ok) throw new ShareReceiveError("fetch-failed", `registry returned ${response.status}`, { stage });
|
|
18417
|
-
|
|
18418
|
-
options.signal?.throwIfAborted();
|
|
18419
|
-
return bytes3;
|
|
17895
|
+
return await readResponseBytes(response, limit, tooLargeCode);
|
|
18420
17896
|
} catch (error) {
|
|
18421
|
-
if (options.signal?.aborted) throw options.signal.reason ?? error;
|
|
18422
17897
|
if (error instanceof ShareReceiveError) throw error;
|
|
18423
17898
|
throw new ShareReceiveError("fetch-failed", "registry unavailable", { stage });
|
|
18424
17899
|
}
|
|
18425
17900
|
};
|
|
18426
17901
|
}
|
|
18427
17902
|
function metadataFor(envelope, origin) {
|
|
18428
|
-
if (envelope.version === 2
|
|
17903
|
+
if (envelope.version === 2) {
|
|
18429
17904
|
const targetKind3 = envelope.recipientMatcher.kind === "recipientDid" ? "recipientDid" : envelope.recipientMatcher.kind === "exactEmail" ? "email" : envelope.recipientMatcher.kind === "emailDomain" ? "emailDomain" : "bearer";
|
|
18430
17905
|
return {
|
|
18431
17906
|
protocol: "tinycloud-share",
|
|
@@ -18441,7 +17916,7 @@ function metadataFor(envelope, origin) {
|
|
|
18441
17916
|
...envelope.display.filename === void 0 ? {} : { filename: envelope.display.filename },
|
|
18442
17917
|
...envelope.display.mode === void 0 ? {} : { mode: envelope.display.mode }
|
|
18443
17918
|
},
|
|
18444
|
-
...envelope.
|
|
17919
|
+
...envelope.content === void 0 ? {} : { content: { cid: envelope.content.cid } }
|
|
18445
17920
|
};
|
|
18446
17921
|
}
|
|
18447
17922
|
return {
|
|
@@ -18466,10 +17941,8 @@ function parseEnvelope(bytes3) {
|
|
|
18466
17941
|
const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes3);
|
|
18467
17942
|
const value = JSON.parse(text);
|
|
18468
17943
|
if (canonicalize2(value) !== text) throw new Error("share envelope is not canonical JSON");
|
|
18469
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
18470
|
-
|
|
18471
|
-
if (version2 === 3) return shareEnvelopeV3Schema.parse(value);
|
|
18472
|
-
if (version2 === 2) return shareEnvelopeV2Schema.parse(value);
|
|
17944
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value) && value.version === 2) {
|
|
17945
|
+
return shareEnvelopeV2Schema.parse(value);
|
|
18473
17946
|
}
|
|
18474
17947
|
return shareEnvelopeSchema.parse(value);
|
|
18475
17948
|
} catch {
|
|
@@ -18541,19 +18014,6 @@ async function verifyV2Envelope(envelope, linkOrigin, options) {
|
|
|
18541
18014
|
if (options.trustedSignerDid === void 0 || envelope.signature.signerDid !== options.trustedSignerDid) throw new ShareReceiveError("signature-invalid", "an addressed signer trust root is required");
|
|
18542
18015
|
}
|
|
18543
18016
|
}
|
|
18544
|
-
async function verifyV3Envelope(envelope, linkOrigin, options) {
|
|
18545
|
-
if (options.expectedOrigin !== void 0 && linkOrigin !== options.expectedOrigin) {
|
|
18546
|
-
throw new ShareReceiveError("origin-mismatch", "share link origin does not match the trusted origin");
|
|
18547
|
-
}
|
|
18548
|
-
try {
|
|
18549
|
-
if (!await verifyEnvelopeV3(envelope, { expectedSignerDid: envelope.policy.ownerDid })) throw new Error("signature");
|
|
18550
|
-
} catch {
|
|
18551
|
-
throw new ShareReceiveError("signature-invalid", "share signature is invalid");
|
|
18552
|
-
}
|
|
18553
|
-
const expiry = Date.parse(envelope.expiry);
|
|
18554
|
-
if (!Number.isFinite(expiry)) throw new ShareReceiveError("envelope-invalid", "share expiry is invalid");
|
|
18555
|
-
if (expiry <= (options.now?.() ?? Date.now())) throw new ShareReceiveError("expired", "share has expired", { expiresAt: envelope.expiry });
|
|
18556
|
-
}
|
|
18557
18017
|
async function verifyV1PolicyEnvelope(envelope, linkOrigin, options) {
|
|
18558
18018
|
if (envelope.authorizationTarget.kind !== "policy") throw new ShareReceiveError("unsupported-target", "share target is not an addressed policy", { reason: "policy-target" });
|
|
18559
18019
|
if (envelope.target.origin !== linkOrigin || options.expectedOrigin !== void 0 && (linkOrigin !== options.expectedOrigin || envelope.target.origin !== options.expectedOrigin)) {
|
|
@@ -18585,18 +18045,12 @@ async function inspectShare(link2, options = {}) {
|
|
|
18585
18045
|
const resolved = await resolveShareEnvelope(link2, options);
|
|
18586
18046
|
if (resolved.envelope.version === 1 && resolved.envelope.authorizationTarget.kind === "policy") await verifyV1PolicyEnvelope(resolved.envelope, resolved.origin, options);
|
|
18587
18047
|
else if (resolved.envelope.version === 1) await verifyResolved(resolved.envelope, resolved.origin, options);
|
|
18588
|
-
else
|
|
18589
|
-
|
|
18590
|
-
if (resolved.envelope.version === 2 || resolved.envelope.version === 3 || resolved.envelope.authorizationTarget.kind === "policy") options.onResolvedAddressedEnvelope?.(resolved.envelope, resolved.cid);
|
|
18048
|
+
else await verifyV2Envelope(resolved.envelope, resolved.origin, options);
|
|
18049
|
+
if (resolved.envelope.version === 2 || resolved.envelope.authorizationTarget.kind === "policy") options.onResolvedAddressedEnvelope?.(resolved.envelope, resolved.cid);
|
|
18591
18050
|
return { metadata: metadataFor(resolved.envelope, resolved.origin), link: { origin: resolved.origin, cid: resolved.cid, kind: resolved.kind } };
|
|
18592
18051
|
}
|
|
18593
18052
|
async function receiveShare(link2, options = {}) {
|
|
18594
18053
|
const resolved = await resolveShareEnvelope(link2, options);
|
|
18595
|
-
if (resolved.envelope.version === 3) {
|
|
18596
|
-
await verifyV3Envelope(resolved.envelope, resolved.origin, options);
|
|
18597
|
-
options.onResolvedAddressedEnvelope?.(resolved.envelope, resolved.cid);
|
|
18598
|
-
return { state: "authorization-required", method: resolved.envelope.recipientMatcher.kind === "recipientDid" ? "openkey-device" : "email-claim" };
|
|
18599
|
-
}
|
|
18600
18054
|
if (resolved.envelope.version === 2) {
|
|
18601
18055
|
await verifyV2Envelope(resolved.envelope, resolved.origin, options);
|
|
18602
18056
|
options.onResolvedAddressedEnvelope?.(resolved.envelope, resolved.cid);
|
|
@@ -18920,12 +18374,6 @@ async function publishShare(options) {
|
|
|
18920
18374
|
envelopeKey?.fill(0);
|
|
18921
18375
|
}
|
|
18922
18376
|
}
|
|
18923
|
-
function authorizationMethodForTarget(target) {
|
|
18924
|
-
if (target.kind === "recipientDid") return "openkey-device";
|
|
18925
|
-
if (target.kind === "email") return "email-claim";
|
|
18926
|
-
if (target.kind === "emailDomain") return "email-claim";
|
|
18927
|
-
return void 0;
|
|
18928
|
-
}
|
|
18929
18377
|
function equals3(aa, bb) {
|
|
18930
18378
|
if (aa === bb) {
|
|
18931
18379
|
return true;
|
|
@@ -19171,109 +18619,6 @@ function rfc46482({ name: name2, prefix, bitsPerChar, alphabet: alphabet2 }) {
|
|
|
19171
18619
|
}
|
|
19172
18620
|
});
|
|
19173
18621
|
}
|
|
19174
|
-
function validEmail(value) {
|
|
19175
|
-
return /^[^@\s]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i.test(value);
|
|
19176
|
-
}
|
|
19177
|
-
function validDomain(value) {
|
|
19178
|
-
return /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))+$/i.test(value);
|
|
19179
|
-
}
|
|
19180
|
-
function validRecipientDid(value) {
|
|
19181
|
-
if (value.length === 0 || value.length > 2048 || /[\u0000-\u0020\u007f]/.test(value)) return false;
|
|
19182
|
-
const parts = value.split(":");
|
|
19183
|
-
if (parts.length < 3 || parts[0] !== "did" || !/^[a-z0-9]+$/.test(parts[1] ?? "")) return false;
|
|
19184
|
-
const identifier = parts.slice(2);
|
|
19185
|
-
if (identifier.some((part) => part.length === 0)) return false;
|
|
19186
|
-
if (parts[1] === "web") {
|
|
19187
|
-
const host = identifier[0] ?? "";
|
|
19188
|
-
if (host.length > 253 || host.split(".").some((label) => !label || label.length > 63 || !/^[A-Za-z0-9-]+$/.test(label) || label.startsWith("-") || label.endsWith("-"))) return false;
|
|
19189
|
-
return identifier.slice(1).every((part) => /^[A-Za-z0-9._%-]+$/.test(part));
|
|
19190
|
-
}
|
|
19191
|
-
if (parts[1] === "pkh") return identifier.length >= 3 && identifier.every((part) => /^[A-Za-z0-9._%-]+$/.test(part));
|
|
19192
|
-
if (parts[1] === "key") {
|
|
19193
|
-
try {
|
|
19194
|
-
const bytes3 = base58btc2.decode(identifier.join(":"));
|
|
19195
|
-
return bytes3.length === 34 && bytes3[0] === 237 && bytes3[1] === 1;
|
|
19196
|
-
} catch {
|
|
19197
|
-
return false;
|
|
19198
|
-
}
|
|
19199
|
-
}
|
|
19200
|
-
return false;
|
|
19201
|
-
}
|
|
19202
|
-
function normalizeShareTarget(target) {
|
|
19203
|
-
if (target.kind === "bearer") return target;
|
|
19204
|
-
if (target.kind === "recipientDid") {
|
|
19205
|
-
if (!validRecipientDid(target.did)) throw new TypeError("recipient DID is invalid");
|
|
19206
|
-
return { kind: target.kind, did: target.did };
|
|
19207
|
-
}
|
|
19208
|
-
if (target.kind === "email") {
|
|
19209
|
-
if (!validEmail(target.address)) throw new TypeError("recipient email is invalid");
|
|
19210
|
-
const at = target.address.lastIndexOf("@");
|
|
19211
|
-
return { kind: target.kind, address: `${target.address.slice(0, at)}@${target.address.slice(at + 1).toLowerCase()}` };
|
|
19212
|
-
}
|
|
19213
|
-
if (!validDomain(target.domain)) throw new TypeError("recipient email domain is invalid");
|
|
19214
|
-
return { kind: target.kind, domain: target.domain.toLowerCase() };
|
|
19215
|
-
}
|
|
19216
|
-
function targetAuthorizationMethod(target) {
|
|
19217
|
-
return authorizationMethodForTarget(target);
|
|
19218
|
-
}
|
|
19219
|
-
async function publishTargetShare(input) {
|
|
19220
|
-
const target = normalizeShareTarget(input.target);
|
|
19221
|
-
if (target.kind === "bearer") return publishShare(input);
|
|
19222
|
-
if (input.targetAdapter === void 0) {
|
|
19223
|
-
return {
|
|
19224
|
-
state: "authorization-required",
|
|
19225
|
-
method: targetAuthorizationMethod(target)
|
|
19226
|
-
};
|
|
19227
|
-
}
|
|
19228
|
-
const source = input.source instanceof Uint8Array ? input.source.slice() : await (async () => {
|
|
19229
|
-
const chunks = [];
|
|
19230
|
-
let size2 = 0;
|
|
19231
|
-
for await (const chunk of input.source) {
|
|
19232
|
-
if (!(chunk instanceof Uint8Array)) throw new TypeError("addressed publication source yielded invalid bytes");
|
|
19233
|
-
size2 += chunk.byteLength;
|
|
19234
|
-
if (size2 > (input.maxBytes ?? 100 * 1024 * 1024)) throw new TypeError("addressed publication exceeds maxBytes");
|
|
19235
|
-
chunks.push(chunk.slice());
|
|
19236
|
-
}
|
|
19237
|
-
const bytes3 = new Uint8Array(size2);
|
|
19238
|
-
let offset = 0;
|
|
19239
|
-
for (const chunk of chunks) {
|
|
19240
|
-
bytes3.set(chunk, offset);
|
|
19241
|
-
offset += chunk.byteLength;
|
|
19242
|
-
}
|
|
19243
|
-
return bytes3;
|
|
19244
|
-
})();
|
|
19245
|
-
const files = input.files === void 0 || input.files.length === 0 ? [{ bytes: source }] : input.files;
|
|
19246
|
-
const limit = input.maxBytes ?? SHARE_CONTENT_LIMIT;
|
|
19247
|
-
let totalBytes = 0;
|
|
19248
|
-
for (const file of files) {
|
|
19249
|
-
totalBytes += file.bytes.byteLength;
|
|
19250
|
-
if (!Number.isSafeInteger(totalBytes) || totalBytes > limit) {
|
|
19251
|
-
throw new SharePublishError("max-bytes-exceeded", "addressed publication exceeds the combined byte limit");
|
|
19252
|
-
}
|
|
19253
|
-
}
|
|
19254
|
-
return input.targetAdapter.publish({
|
|
19255
|
-
source,
|
|
19256
|
-
filename: input.filename,
|
|
19257
|
-
...input.files === void 0 ? {} : { files: input.files },
|
|
19258
|
-
...input.mediaType === void 0 ? {} : { mediaType: input.mediaType },
|
|
19259
|
-
...input.resourceKind === void 0 ? {} : { resourceKind: input.resourceKind },
|
|
19260
|
-
...input.actions === void 0 ? {} : { actions: input.actions },
|
|
19261
|
-
target,
|
|
19262
|
-
expiresAt: input.expiresAt ?? new Date((input.now?.() ?? Date.now()) + 7 * 24 * 60 * 60 * 1e3),
|
|
19263
|
-
origin: input.origin,
|
|
19264
|
-
...input.inline === void 0 ? {} : { inline: input.inline },
|
|
19265
|
-
upload: {
|
|
19266
|
-
...input.registryBaseUrl === void 0 ? {} : { registryBaseUrl: input.registryBaseUrl },
|
|
19267
|
-
...input.fetchFn === void 0 ? {} : { fetchFn: input.fetchFn },
|
|
19268
|
-
...input.authorizeUpload === void 0 ? {} : { authorizeUpload: input.authorizeUpload },
|
|
19269
|
-
...input.authorizationOrigin === void 0 ? {} : { authorizationOrigin: input.authorizationOrigin },
|
|
19270
|
-
...input.credentials === void 0 ? {} : { credentials: input.credentials },
|
|
19271
|
-
...input.allowInsecureRegistry === void 0 ? {} : { allowInsecureRegistry: input.allowInsecureRegistry },
|
|
19272
|
-
...input.uploadBlob === void 0 ? {} : { uploadBlob: input.uploadBlob }
|
|
19273
|
-
},
|
|
19274
|
-
...input.notify === void 0 ? {} : { notify: input.notify }
|
|
19275
|
-
});
|
|
19276
|
-
}
|
|
19277
18622
|
function encode4(num2, out, offset) {
|
|
19278
18623
|
out = out || [];
|
|
19279
18624
|
offset = offset || 0;
|
|
@@ -19315,25 +18660,25 @@ function encodeTo2(int, target, offset = 0) {
|
|
|
19315
18660
|
function encodingLength2(int) {
|
|
19316
18661
|
return varint_default2.encodingLength(int);
|
|
19317
18662
|
}
|
|
19318
|
-
function create2(code3,
|
|
19319
|
-
const size2 =
|
|
18663
|
+
function create2(code3, digest4) {
|
|
18664
|
+
const size2 = digest4.byteLength;
|
|
19320
18665
|
const sizeOffset = encodingLength2(code3);
|
|
19321
18666
|
const digestOffset = sizeOffset + encodingLength2(size2);
|
|
19322
18667
|
const bytes3 = new Uint8Array(digestOffset + size2);
|
|
19323
18668
|
encodeTo2(code3, bytes3, 0);
|
|
19324
18669
|
encodeTo2(size2, bytes3, sizeOffset);
|
|
19325
|
-
bytes3.set(
|
|
19326
|
-
return new Digest2(code3, size2,
|
|
18670
|
+
bytes3.set(digest4, digestOffset);
|
|
18671
|
+
return new Digest2(code3, size2, digest4, bytes3);
|
|
19327
18672
|
}
|
|
19328
18673
|
function decode8(multihash) {
|
|
19329
18674
|
const bytes3 = coerce3(multihash);
|
|
19330
18675
|
const [code3, sizeOffset] = decode7(bytes3);
|
|
19331
18676
|
const [size2, digestOffset] = decode7(bytes3.subarray(sizeOffset));
|
|
19332
|
-
const
|
|
19333
|
-
if (
|
|
18677
|
+
const digest4 = bytes3.subarray(sizeOffset + digestOffset);
|
|
18678
|
+
if (digest4.byteLength !== size2) {
|
|
19334
18679
|
throw new Error("Incorrect length");
|
|
19335
18680
|
}
|
|
19336
|
-
return new Digest2(code3, size2,
|
|
18681
|
+
return new Digest2(code3, size2, digest4, bytes3);
|
|
19337
18682
|
}
|
|
19338
18683
|
function equals4(a, b) {
|
|
19339
18684
|
if (a === b) {
|
|
@@ -19425,6 +18770,115 @@ function encodeCID2(version2, code3, multihash) {
|
|
|
19425
18770
|
bytes3.set(multihash, hashOffset);
|
|
19426
18771
|
return bytes3;
|
|
19427
18772
|
}
|
|
18773
|
+
function authorizationMethodForTarget(target) {
|
|
18774
|
+
if (target.kind === "recipientDid") return "openkey-device";
|
|
18775
|
+
if (target.kind === "email") return "email-claim";
|
|
18776
|
+
if (target.kind === "emailDomain") return "email-claim";
|
|
18777
|
+
return void 0;
|
|
18778
|
+
}
|
|
18779
|
+
function validEmail(value) {
|
|
18780
|
+
return /^[^@\s]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i.test(value);
|
|
18781
|
+
}
|
|
18782
|
+
function validDomain(value) {
|
|
18783
|
+
return /^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)(?:\.(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?))+$/i.test(value);
|
|
18784
|
+
}
|
|
18785
|
+
function validRecipientDid(value) {
|
|
18786
|
+
if (value.length === 0 || value.length > 2048 || /[\u0000-\u0020\u007f]/.test(value)) return false;
|
|
18787
|
+
const parts = value.split(":");
|
|
18788
|
+
if (parts.length < 3 || parts[0] !== "did" || !/^[a-z0-9]+$/.test(parts[1] ?? "")) return false;
|
|
18789
|
+
const identifier = parts.slice(2);
|
|
18790
|
+
if (identifier.some((part) => part.length === 0)) return false;
|
|
18791
|
+
if (parts[1] === "web") {
|
|
18792
|
+
const host = identifier[0] ?? "";
|
|
18793
|
+
if (host.length > 253 || host.split(".").some((label) => !label || label.length > 63 || !/^[A-Za-z0-9-]+$/.test(label) || label.startsWith("-") || label.endsWith("-"))) return false;
|
|
18794
|
+
return identifier.slice(1).every((part) => /^[A-Za-z0-9._%-]+$/.test(part));
|
|
18795
|
+
}
|
|
18796
|
+
if (parts[1] === "pkh") return identifier.length >= 3 && identifier.every((part) => /^[A-Za-z0-9._%-]+$/.test(part));
|
|
18797
|
+
if (parts[1] === "key") {
|
|
18798
|
+
try {
|
|
18799
|
+
const bytes3 = base58btc2.decode(identifier.join(":"));
|
|
18800
|
+
return bytes3.length === 34 && bytes3[0] === 237 && bytes3[1] === 1;
|
|
18801
|
+
} catch {
|
|
18802
|
+
return false;
|
|
18803
|
+
}
|
|
18804
|
+
}
|
|
18805
|
+
return false;
|
|
18806
|
+
}
|
|
18807
|
+
function normalizeShareTarget(target) {
|
|
18808
|
+
if (target.kind === "bearer") return target;
|
|
18809
|
+
if (target.kind === "recipientDid") {
|
|
18810
|
+
if (!validRecipientDid(target.did)) throw new TypeError("recipient DID is invalid");
|
|
18811
|
+
return { kind: target.kind, did: target.did };
|
|
18812
|
+
}
|
|
18813
|
+
if (target.kind === "email") {
|
|
18814
|
+
if (!validEmail(target.address)) throw new TypeError("recipient email is invalid");
|
|
18815
|
+
const at = target.address.lastIndexOf("@");
|
|
18816
|
+
return { kind: target.kind, address: `${target.address.slice(0, at)}@${target.address.slice(at + 1).toLowerCase()}` };
|
|
18817
|
+
}
|
|
18818
|
+
if (!validDomain(target.domain)) throw new TypeError("recipient email domain is invalid");
|
|
18819
|
+
return { kind: target.kind, domain: target.domain.toLowerCase() };
|
|
18820
|
+
}
|
|
18821
|
+
function targetAuthorizationMethod(target) {
|
|
18822
|
+
return authorizationMethodForTarget(target);
|
|
18823
|
+
}
|
|
18824
|
+
async function publishTargetShare(input) {
|
|
18825
|
+
const target = normalizeShareTarget(input.target);
|
|
18826
|
+
if (target.kind === "bearer") return publishShare(input);
|
|
18827
|
+
if (input.targetAdapter === void 0) {
|
|
18828
|
+
return {
|
|
18829
|
+
state: "authorization-required",
|
|
18830
|
+
method: targetAuthorizationMethod(target)
|
|
18831
|
+
};
|
|
18832
|
+
}
|
|
18833
|
+
const source = input.source instanceof Uint8Array ? input.source.slice() : await (async () => {
|
|
18834
|
+
const chunks = [];
|
|
18835
|
+
let size2 = 0;
|
|
18836
|
+
for await (const chunk of input.source) {
|
|
18837
|
+
if (!(chunk instanceof Uint8Array)) throw new TypeError("addressed publication source yielded invalid bytes");
|
|
18838
|
+
size2 += chunk.byteLength;
|
|
18839
|
+
if (size2 > (input.maxBytes ?? 100 * 1024 * 1024)) throw new TypeError("addressed publication exceeds maxBytes");
|
|
18840
|
+
chunks.push(chunk.slice());
|
|
18841
|
+
}
|
|
18842
|
+
const bytes3 = new Uint8Array(size2);
|
|
18843
|
+
let offset = 0;
|
|
18844
|
+
for (const chunk of chunks) {
|
|
18845
|
+
bytes3.set(chunk, offset);
|
|
18846
|
+
offset += chunk.byteLength;
|
|
18847
|
+
}
|
|
18848
|
+
return bytes3;
|
|
18849
|
+
})();
|
|
18850
|
+
const files = input.files === void 0 || input.files.length === 0 ? [{ bytes: source }] : input.files;
|
|
18851
|
+
const limit = input.maxBytes ?? SHARE_CONTENT_LIMIT;
|
|
18852
|
+
let totalBytes = 0;
|
|
18853
|
+
for (const file of files) {
|
|
18854
|
+
totalBytes += file.bytes.byteLength;
|
|
18855
|
+
if (!Number.isSafeInteger(totalBytes) || totalBytes > limit) {
|
|
18856
|
+
throw new SharePublishError("max-bytes-exceeded", "addressed publication exceeds the combined byte limit");
|
|
18857
|
+
}
|
|
18858
|
+
}
|
|
18859
|
+
return input.targetAdapter.publish({
|
|
18860
|
+
source,
|
|
18861
|
+
filename: input.filename,
|
|
18862
|
+
...input.files === void 0 ? {} : { files: input.files },
|
|
18863
|
+
...input.mediaType === void 0 ? {} : { mediaType: input.mediaType },
|
|
18864
|
+
...input.resourceKind === void 0 ? {} : { resourceKind: input.resourceKind },
|
|
18865
|
+
...input.actions === void 0 ? {} : { actions: input.actions },
|
|
18866
|
+
target,
|
|
18867
|
+
expiresAt: input.expiresAt ?? new Date((input.now?.() ?? Date.now()) + 7 * 24 * 60 * 60 * 1e3),
|
|
18868
|
+
origin: input.origin,
|
|
18869
|
+
...input.inline === void 0 ? {} : { inline: input.inline },
|
|
18870
|
+
upload: {
|
|
18871
|
+
...input.registryBaseUrl === void 0 ? {} : { registryBaseUrl: input.registryBaseUrl },
|
|
18872
|
+
...input.fetchFn === void 0 ? {} : { fetchFn: input.fetchFn },
|
|
18873
|
+
...input.authorizeUpload === void 0 ? {} : { authorizeUpload: input.authorizeUpload },
|
|
18874
|
+
...input.authorizationOrigin === void 0 ? {} : { authorizationOrigin: input.authorizationOrigin },
|
|
18875
|
+
...input.credentials === void 0 ? {} : { credentials: input.credentials },
|
|
18876
|
+
...input.allowInsecureRegistry === void 0 ? {} : { allowInsecureRegistry: input.allowInsecureRegistry },
|
|
18877
|
+
...input.uploadBlob === void 0 ? {} : { uploadBlob: input.uploadBlob }
|
|
18878
|
+
},
|
|
18879
|
+
...input.notify === void 0 ? {} : { notify: input.notify }
|
|
18880
|
+
});
|
|
18881
|
+
}
|
|
19428
18882
|
function historyRecordForPublishedShare(result, now = /* @__PURE__ */ new Date()) {
|
|
19429
18883
|
const target = result.metadata.target.kind;
|
|
19430
18884
|
const supplied = result.metadata.recipientMatcher;
|
|
@@ -19455,7 +18909,6 @@ function historyRecordForPublishedShare(result, now = /* @__PURE__ */ new Date()
|
|
|
19455
18909
|
registeredAt: now.toISOString(),
|
|
19456
18910
|
expiresAt: result.metadata.expiresAt,
|
|
19457
18911
|
link: result.url,
|
|
19458
|
-
...result.deliveryMaterial === void 0 ? {} : { deliveryMaterial: result.deliveryMaterial },
|
|
19459
18912
|
...result.metadata.display.filename === void 0 ? {} : { filename: result.metadata.display.filename }
|
|
19460
18913
|
};
|
|
19461
18914
|
}
|
|
@@ -19491,11 +18944,11 @@ async function notifyShare(input) {
|
|
|
19491
18944
|
}
|
|
19492
18945
|
async function defaultIdempotencyKey(shareId, recipient) {
|
|
19493
18946
|
const canonicalRecipient = canonicalize2(recipient.trim().toLowerCase());
|
|
19494
|
-
const
|
|
18947
|
+
const digest4 = new Uint8Array(await crypto.subtle.digest(
|
|
19495
18948
|
"SHA-256",
|
|
19496
18949
|
new TextEncoder().encode(canonicalRecipient)
|
|
19497
18950
|
));
|
|
19498
|
-
return `tinycloud-share:${shareId}:${toBase64Url(
|
|
18951
|
+
return `tinycloud-share:${shareId}:${toBase64Url(digest4)}`;
|
|
19499
18952
|
}
|
|
19500
18953
|
function targetKind2(record2) {
|
|
19501
18954
|
if (record2.targetKind !== void 0) return record2.targetKind;
|
|
@@ -19545,16 +18998,13 @@ async function migrateShare(input) {
|
|
|
19545
18998
|
const value = await receiveLegacyShare(input.link, input.reader);
|
|
19546
18999
|
return { protocol: "tinycloud-share", version: 1, legacy: true, value, migrated: await input.publish(value) };
|
|
19547
19000
|
}
|
|
19548
|
-
var __defProp2, __export2, external_exports2, util2, objectUtil2, ZodParsedType2, getParsedType2, ZodIssueCode2, quotelessJson2, ZodError2, errorMap2, en_default2, overrideErrorMap2, makeIssue2, EMPTY_PATH2, ParseStatus2, INVALID2, DIRTY2, OK2, isAborted2, isDirty2, isValid2, isAsync2, errorUtil2, ParseInputLazyPath2, handleResult2, ZodType2, cuidRegex2, cuid2Regex2, ulidRegex2, uuidRegex2, nanoidRegex2, jwtRegex2, durationRegex2, emailRegex2, _emojiRegex2, emojiRegex2, ipv4Regex2, ipv4CidrRegex2, ipv6Regex2, ipv6CidrRegex2, base64Regex2, base64urlRegex2, dateRegexSource2, dateRegex2, ZodString2, ZodNumber2, ZodBigInt2, ZodBoolean2, ZodDate2, ZodSymbol2, ZodUndefined2, ZodNull2, ZodAny2, ZodUnknown2, ZodNever2, ZodVoid2, ZodArray2, ZodObject2, ZodUnion2, getDiscriminator2, ZodDiscriminatedUnion2, ZodIntersection2, ZodTuple2, ZodRecord2, ZodMap2, ZodSet2, ZodFunction2, ZodLazy2, ZodLiteral2, ZodEnum2, ZodNativeEnum2, ZodPromise2, ZodEffects2, ZodOptional2, ZodNullable2, ZodDefault2, ZodCatch2, ZodNaN2, BRAND2, ZodBranded2, ZodPipeline2, ZodReadonly2, late2, ZodFirstPartyTypeKind2, instanceOfType2, stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, ostring2, onumber2, oboolean2, coerce2, NEVER2, empty, src, _brrp__multiformats_scope_baseX, base_x_default, Encoder, Decoder, ComposedDecoder, Codec, base32, base32upper, base32pad, base32padupper, base32hex, base32hexupper, base32hexpad, base32hexpadupper, base32z, base36, base36upper, base58btc, base58flickr, encode_1, MSB, REST, MSBALL, INT, decode2, MSB$1, REST$1, N1, N2, N3, N4, N5, N6, N7, N8, N9, length, varint, _brrp_varint, varint_default, Digest, cache, CID, DAG_PB_CODE, SHA_256_CODE, cidSymbol, code, SHA256_CODE, base64, base64pad, base64url, base64urlpad, ED25519_MULTICODEC_PREFIX, PUBLIC_KEY_LENGTH, base64UrlString, sessionJwkCommonFields, okpPrivateJwkSchema, ecPrivateJwkSchema, sessionJwkSchema, policyTargetSchema, bearerKeyTargetSchema, recipientDidTargetSchema, authorizationTargetSchema, resourceSelectorSchema, targetSchema, displaySchema, contentPointerSchema, signatureSchema, unsignedShareEnvelopeSchema, shareEnvelopeSchema, recipientMatcherSchema, shareActionSchema, kvContentSourceSchema, sqlContentSourceSchema, contentSourceSchema, v2TargetSchema, shareDecryptionSchema, ownerAuthoritySchema, contentMetadataSchema, unsignedShareEnvelopeV2BaseSchema, unsignedShareEnvelopeV2Schema, shareEnvelopeV2Schema, unifiedResourceSchema, unifiedEncryptionNetworkSchema, unifiedKvCapabilitySchema, unifiedEncryptionCapabilitySchema, unifiedCapabilitySchema, unifiedContentSourceSchema,
|
|
19001
|
+
var __defProp2, __export2, external_exports2, util2, objectUtil2, ZodParsedType2, getParsedType2, ZodIssueCode2, quotelessJson2, ZodError2, errorMap2, en_default2, overrideErrorMap2, makeIssue2, EMPTY_PATH2, ParseStatus2, INVALID2, DIRTY2, OK2, isAborted2, isDirty2, isValid2, isAsync2, errorUtil2, ParseInputLazyPath2, handleResult2, ZodType2, cuidRegex2, cuid2Regex2, ulidRegex2, uuidRegex2, nanoidRegex2, jwtRegex2, durationRegex2, emailRegex2, _emojiRegex2, emojiRegex2, ipv4Regex2, ipv4CidrRegex2, ipv6Regex2, ipv6CidrRegex2, base64Regex2, base64urlRegex2, dateRegexSource2, dateRegex2, ZodString2, ZodNumber2, ZodBigInt2, ZodBoolean2, ZodDate2, ZodSymbol2, ZodUndefined2, ZodNull2, ZodAny2, ZodUnknown2, ZodNever2, ZodVoid2, ZodArray2, ZodObject2, ZodUnion2, getDiscriminator2, ZodDiscriminatedUnion2, ZodIntersection2, ZodTuple2, ZodRecord2, ZodMap2, ZodSet2, ZodFunction2, ZodLazy2, ZodLiteral2, ZodEnum2, ZodNativeEnum2, ZodPromise2, ZodEffects2, ZodOptional2, ZodNullable2, ZodDefault2, ZodCatch2, ZodNaN2, BRAND2, ZodBranded2, ZodPipeline2, ZodReadonly2, late2, ZodFirstPartyTypeKind2, instanceOfType2, stringType2, numberType2, nanType2, bigIntType2, booleanType2, dateType2, symbolType2, undefinedType2, nullType2, anyType2, unknownType2, neverType2, voidType2, arrayType2, objectType2, strictObjectType2, unionType2, discriminatedUnionType2, intersectionType2, tupleType2, recordType2, mapType2, setType2, functionType2, lazyType2, literalType2, enumType2, nativeEnumType2, promiseType2, effectsType2, optionalType2, nullableType2, preprocessType2, pipelineType2, ostring2, onumber2, oboolean2, coerce2, NEVER2, empty, src, _brrp__multiformats_scope_baseX, base_x_default, Encoder, Decoder, ComposedDecoder, Codec, base32, base32upper, base32pad, base32padupper, base32hex, base32hexupper, base32hexpad, base32hexpadupper, base32z, base36, base36upper, base58btc, base58flickr, encode_1, MSB, REST, MSBALL, INT, decode2, MSB$1, REST$1, N1, N2, N3, N4, N5, N6, N7, N8, N9, length, varint, _brrp_varint, varint_default, Digest, cache, CID, DAG_PB_CODE, SHA_256_CODE, cidSymbol, code, SHA256_CODE, base64, base64pad, base64url, base64urlpad, ED25519_MULTICODEC_PREFIX, PUBLIC_KEY_LENGTH, base64UrlString, sessionJwkCommonFields, okpPrivateJwkSchema, ecPrivateJwkSchema, sessionJwkSchema, policyTargetSchema, bearerKeyTargetSchema, recipientDidTargetSchema, authorizationTargetSchema, resourceSelectorSchema, targetSchema, displaySchema, contentPointerSchema, signatureSchema, unsignedShareEnvelopeSchema, shareEnvelopeSchema, recipientMatcherSchema, shareActionSchema, kvContentSourceSchema, sqlContentSourceSchema, contentSourceSchema, v2TargetSchema, shareDecryptionSchema, ownerAuthoritySchema, contentMetadataSchema, unsignedShareEnvelopeV2BaseSchema, unsignedShareEnvelopeV2Schema, shareEnvelopeV2Schema, unifiedResourceSchema, unifiedEncryptionNetworkSchema, unifiedKvCapabilitySchema, unifiedEncryptionCapabilitySchema, unifiedCapabilitySchema, unifiedContentSourceSchema, unifiedPolicySchema, unifiedRootSchema, attestedEnforcerBindingV2Schema, v3TargetSchema, unsignedShareEnvelopeV3BaseSchema, unsignedShareEnvelopeV3Schema, shareEnvelopeV3Schema, BEARER_READ_ABILITY, READ_ABILITIES, ED25519_VERIFY_OPTS, ENVELOPE_AAD_LABEL, SEALED_BLOB_VERSION, AAD, KEY_LENGTH, NONCE_LENGTH, TAG_LENGTH, HEADER_LENGTH, ED25519_VERIFY_OPTS2, ENVELOPE_SIGNATURE_DOMAIN, ENVELOPE_V2_SIGNATURE_DOMAIN, KEY_LENGTH2, INLINE_PREFIX, MAX_INLINE_BYTES, SHARE_RESULT_VERSION, DEFAULT_MAX_SEALED_BLOB_BYTES, DEFAULT_MAX_CONTENT_BLOB_BYTES, CONTENT_SEALED_OVERHEAD, ShareReceiveError, SHARE_CONTENT_LIMIT, SHARE_SEALED_OVERHEAD, SHARE_PUBLISH_RESULT_VERSION, DEFAULT_SHARE_LIFETIME_MS, SharePublishError, empty2, src2, _brrp__multiformats_scope_baseX2, base_x_default2, Encoder2, Decoder2, ComposedDecoder2, Codec2, base322, base32upper2, base32pad2, base32padupper2, base32hex2, base32hexupper2, base32hexpad2, base32hexpadupper2, base32z2, base362, base36upper2, base58btc2, base58flickr2, encode_12, MSB2, REST2, MSBALL2, INT2, decode6, MSB$12, REST$12, N12, N22, N32, N42, N52, N62, N72, N82, N92, length2, varint2, _brrp_varint2, varint_default2, Digest2, cache2, CID2, DAG_PB_CODE2, SHA_256_CODE2, cidSymbol2, MAX_CONTENT_BYTES, ShareNotifyError, SHARE_V2_PROTOCOL, DOMAIN, PRESENTATION_DOMAIN, SESSION_DOMAIN, INVOCATION_DOMAIN;
|
|
19549
19002
|
var init_dist3 = __esm({
|
|
19550
|
-
"
|
|
19003
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/share-sdk/dist/index.js"() {
|
|
19551
19004
|
"use strict";
|
|
19552
19005
|
init_sha2();
|
|
19553
19006
|
init_ed25519();
|
|
19554
19007
|
init_ed25519();
|
|
19555
|
-
init_blake3();
|
|
19556
|
-
init_ed25519();
|
|
19557
|
-
init_sha256();
|
|
19558
19008
|
init_ed25519();
|
|
19559
19009
|
__defProp2 = Object.defineProperty;
|
|
19560
19010
|
__export2 = (target, all) => {
|
|
@@ -23564,10 +23014,10 @@ var init_dist3 = __esm({
|
|
|
23564
23014
|
/**
|
|
23565
23015
|
* Creates a multihash digest.
|
|
23566
23016
|
*/
|
|
23567
|
-
constructor(code22, size2,
|
|
23017
|
+
constructor(code22, size2, digest4, bytes3) {
|
|
23568
23018
|
this.code = code22;
|
|
23569
23019
|
this.size = size2;
|
|
23570
|
-
this.digest =
|
|
23020
|
+
this.digest = digest4;
|
|
23571
23021
|
this.bytes = bytes3;
|
|
23572
23022
|
}
|
|
23573
23023
|
};
|
|
@@ -23630,8 +23080,8 @@ var init_dist3 = __esm({
|
|
|
23630
23080
|
toV1() {
|
|
23631
23081
|
switch (this.version) {
|
|
23632
23082
|
case 0: {
|
|
23633
|
-
const { code: code22, digest:
|
|
23634
|
-
const multihash = create(code22,
|
|
23083
|
+
const { code: code22, digest: digest4 } = this.multihash;
|
|
23084
|
+
const multihash = create(code22, digest4);
|
|
23635
23085
|
return _CID.createV1(this.code, multihash);
|
|
23636
23086
|
}
|
|
23637
23087
|
case 1: {
|
|
@@ -23685,8 +23135,8 @@ var init_dist3 = __esm({
|
|
|
23685
23135
|
return new _CID(version2, code22, multihash, bytes3 ?? encodeCID(version2, code22, multihash.bytes));
|
|
23686
23136
|
} else if (value[cidSymbol] === true) {
|
|
23687
23137
|
const { version: version2, multihash, code: code22 } = value;
|
|
23688
|
-
const
|
|
23689
|
-
return _CID.create(version2, code22,
|
|
23138
|
+
const digest4 = decode4(multihash);
|
|
23139
|
+
return _CID.create(version2, code22, digest4);
|
|
23690
23140
|
} else {
|
|
23691
23141
|
return null;
|
|
23692
23142
|
}
|
|
@@ -23696,11 +23146,11 @@ var init_dist3 = __esm({
|
|
|
23696
23146
|
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
23697
23147
|
* @param digest - (Multi)hash of the of the content.
|
|
23698
23148
|
*/
|
|
23699
|
-
static create(version2, code22,
|
|
23149
|
+
static create(version2, code22, digest4) {
|
|
23700
23150
|
if (typeof code22 !== "number") {
|
|
23701
23151
|
throw new Error("String codecs are no longer supported");
|
|
23702
23152
|
}
|
|
23703
|
-
if (!(
|
|
23153
|
+
if (!(digest4.bytes instanceof Uint8Array)) {
|
|
23704
23154
|
throw new Error("Invalid digest");
|
|
23705
23155
|
}
|
|
23706
23156
|
switch (version2) {
|
|
@@ -23708,12 +23158,12 @@ var init_dist3 = __esm({
|
|
|
23708
23158
|
if (code22 !== DAG_PB_CODE) {
|
|
23709
23159
|
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
|
|
23710
23160
|
} else {
|
|
23711
|
-
return new _CID(version2, code22,
|
|
23161
|
+
return new _CID(version2, code22, digest4, digest4.bytes);
|
|
23712
23162
|
}
|
|
23713
23163
|
}
|
|
23714
23164
|
case 1: {
|
|
23715
|
-
const bytes3 = encodeCID(version2, code22,
|
|
23716
|
-
return new _CID(version2, code22,
|
|
23165
|
+
const bytes3 = encodeCID(version2, code22, digest4.bytes);
|
|
23166
|
+
return new _CID(version2, code22, digest4, bytes3);
|
|
23717
23167
|
}
|
|
23718
23168
|
default: {
|
|
23719
23169
|
throw new Error("Invalid version");
|
|
@@ -23723,8 +23173,8 @@ var init_dist3 = __esm({
|
|
|
23723
23173
|
/**
|
|
23724
23174
|
* Simplified version of `create` for CIDv0.
|
|
23725
23175
|
*/
|
|
23726
|
-
static createV0(
|
|
23727
|
-
return _CID.create(0, DAG_PB_CODE,
|
|
23176
|
+
static createV0(digest4) {
|
|
23177
|
+
return _CID.create(0, DAG_PB_CODE, digest4);
|
|
23728
23178
|
}
|
|
23729
23179
|
/**
|
|
23730
23180
|
* Simplified version of `create` for CIDv1.
|
|
@@ -23732,8 +23182,8 @@ var init_dist3 = __esm({
|
|
|
23732
23182
|
* @param code - Content encoding format code.
|
|
23733
23183
|
* @param digest - Multihash of the content.
|
|
23734
23184
|
*/
|
|
23735
|
-
static createV1(code22,
|
|
23736
|
-
return _CID.create(1, code22,
|
|
23185
|
+
static createV1(code22, digest4) {
|
|
23186
|
+
return _CID.create(1, code22, digest4);
|
|
23737
23187
|
}
|
|
23738
23188
|
/**
|
|
23739
23189
|
* Decoded a CID from its binary representation. The byte array must contain
|
|
@@ -23766,8 +23216,8 @@ var init_dist3 = __esm({
|
|
|
23766
23216
|
throw new Error("Incorrect length");
|
|
23767
23217
|
}
|
|
23768
23218
|
const digestBytes3 = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
23769
|
-
const
|
|
23770
|
-
const cid2 = specs.version === 0 ? _CID.createV0(
|
|
23219
|
+
const digest4 = new Digest(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
|
|
23220
|
+
const cid2 = specs.version === 0 ? _CID.createV0(digest4) : _CID.createV1(specs.codec, digest4);
|
|
23771
23221
|
return [cid2, bytes3.subarray(specs.size)];
|
|
23772
23222
|
}
|
|
23773
23223
|
/**
|
|
@@ -24042,12 +23492,9 @@ var init_dist3 = __esm({
|
|
|
24042
23492
|
unsignedShareEnvelopeV2Schema = unsignedShareEnvelopeV2BaseSchema.superRefine(validateV2Invariants);
|
|
24043
23493
|
shareEnvelopeV2Schema = unsignedShareEnvelopeV2BaseSchema.extend({ signature: signatureSchema }).strict().superRefine(validateV2Invariants);
|
|
24044
23494
|
unifiedResourceSchema = external_exports2.string().refine((value) => {
|
|
24045
|
-
const
|
|
24046
|
-
if (
|
|
24047
|
-
const
|
|
24048
|
-
const legacy = space.startsWith("tinycloud://");
|
|
24049
|
-
if (legacy ? /[:/?#%]/.test(space.slice("tinycloud://".length)) : !space.startsWith("tinycloud:") || /[/?#%]/.test(space)) return false;
|
|
24050
|
-
const path = value.slice(marker + 4);
|
|
23495
|
+
const match = /^tinycloud:\/\/([^/]+)\/kv\/(.+)$/.exec(value);
|
|
23496
|
+
if (match === null || /[:?#%]/.test(match[1])) return false;
|
|
23497
|
+
const path = match[2];
|
|
24051
23498
|
return !path.startsWith("/") && !path.endsWith("/") && !path.includes("//") && path.split("/").every((segment) => segment.length > 0 && segment !== "." && segment !== "..");
|
|
24052
23499
|
}, { message: "expected canonical TinyCloud KV resource" });
|
|
24053
23500
|
unifiedEncryptionNetworkSchema = external_exports2.string().refine((value) => {
|
|
@@ -24085,7 +23532,7 @@ var init_dist3 = __esm({
|
|
|
24085
23532
|
mode: external_exports2.union([external_exports2.literal("mutable"), external_exports2.literal("immutable")]),
|
|
24086
23533
|
initialCiphertextDigestHex: external_exports2.string().regex(/^[0-9a-f]{64}$/).optional()
|
|
24087
23534
|
}).strict();
|
|
24088
|
-
|
|
23535
|
+
unifiedPolicySchema = external_exports2.object({
|
|
24089
23536
|
schema: external_exports2.literal("xyz.tinycloud.policy/policy/v1"),
|
|
24090
23537
|
policyId: external_exports2.string().regex(/^pol_[a-z2-7]+$/),
|
|
24091
23538
|
ownerDid: external_exports2.string().min(1),
|
|
@@ -24095,31 +23542,6 @@ var init_dist3 = __esm({
|
|
|
24095
23542
|
capabilityCeiling: external_exports2.array(unifiedCapabilitySchema).min(2),
|
|
24096
23543
|
signature: external_exports2.object({ suite: external_exports2.string().min(1), signerDid: external_exports2.string().min(1), value: external_exports2.string().min(1) }).strict()
|
|
24097
23544
|
}).strict();
|
|
24098
|
-
policyCredentialRequirementV1Schema = external_exports2.object({
|
|
24099
|
-
type: external_exports2.literal("TinyCloudPolicyCredentialRequirement"),
|
|
24100
|
-
version: external_exports2.literal(1),
|
|
24101
|
-
requirementDigest: external_exports2.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
24102
|
-
descriptorDigest: external_exports2.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
24103
|
-
issuerDid: external_exports2.string().min(1),
|
|
24104
|
-
issuerKid: external_exports2.string().min(1),
|
|
24105
|
-
profile: external_exports2.object({ id: external_exports2.string().min(1), version: external_exports2.literal(1) }).strict(),
|
|
24106
|
-
credentialType: external_exports2.object({ id: external_exports2.string().min(1), version: external_exports2.literal(1) }).strict()
|
|
24107
|
-
}).strict();
|
|
24108
|
-
unifiedPolicyV2Schema = external_exports2.object({
|
|
24109
|
-
schema: external_exports2.literal("xyz.tinycloud.policy/policy/v2"),
|
|
24110
|
-
policyId: external_exports2.string().regex(/^pol_[a-z2-7]+$/),
|
|
24111
|
-
ownerDid: external_exports2.string().min(1),
|
|
24112
|
-
createdAt: external_exports2.string().datetime({ offset: true }),
|
|
24113
|
-
expiresAt: external_exports2.string().datetime({ offset: true }).optional(),
|
|
24114
|
-
contentSource: unifiedContentSourceSchema,
|
|
24115
|
-
capabilityCeiling: external_exports2.array(unifiedCapabilitySchema).min(2),
|
|
24116
|
-
credentialRequirement: policyCredentialRequirementV1Schema,
|
|
24117
|
-
signature: external_exports2.object({ suite: external_exports2.literal("Ed25519"), signerDid: external_exports2.string().min(1), value: external_exports2.string().min(1) }).strict()
|
|
24118
|
-
}).strict();
|
|
24119
|
-
unifiedPolicySchema = external_exports2.discriminatedUnion("schema", [
|
|
24120
|
-
unifiedPolicyV1Schema,
|
|
24121
|
-
unifiedPolicyV2Schema
|
|
24122
|
-
]);
|
|
24123
23545
|
unifiedRootSchema = external_exports2.object({
|
|
24124
23546
|
cid: external_exports2.string().min(1),
|
|
24125
23547
|
authorization: external_exports2.string().regex(/^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/),
|
|
@@ -24175,13 +23597,6 @@ var init_dist3 = __esm({
|
|
|
24175
23597
|
ED25519_VERIFY_OPTS2 = { zip215: false };
|
|
24176
23598
|
ENVELOPE_SIGNATURE_DOMAIN = "xyz.tinycloud.share/envelope/v1\0";
|
|
24177
23599
|
ENVELOPE_V2_SIGNATURE_DOMAIN = "xyz.tinycloud.share/envelope/v2\0";
|
|
24178
|
-
ENVELOPE_V3_SIGNATURE_DOMAIN = "xyz.tinycloud.share/envelope/v3\0";
|
|
24179
|
-
POLICY_V1_SIGNATURE_DOMAIN = "xyz.tinycloud.policy/policy/v1\0";
|
|
24180
|
-
POLICY_V2_SIGNATURE_DOMAIN = "xyz.tinycloud.policy/policy/v2\0";
|
|
24181
|
-
CONTENT_SOURCE_V1_DOMAIN = "xyz.tinycloud.policy/ContentSource/v1\0";
|
|
24182
|
-
POLICY_CAPABILITY_V1_DOMAIN = "xyz.tinycloud.policy/PolicyCapability/v1\0";
|
|
24183
|
-
NATIVE_PROJECTION_V1_DOMAIN = "xyz.tinycloud.policy/NativeProjection/v1\0";
|
|
24184
|
-
ATTESTED_ENFORCER_V2_DOMAIN = "xyz.tinycloud.policy/AttestedEnforcerBinding/v2\0";
|
|
24185
23600
|
KEY_LENGTH2 = 32;
|
|
24186
23601
|
INLINE_PREFIX = "#v=2&p=";
|
|
24187
23602
|
MAX_INLINE_BYTES = 256 * 1024;
|
|
@@ -24305,17 +23720,6 @@ var init_dist3 = __esm({
|
|
|
24305
23720
|
return this.decoder.decode(input);
|
|
24306
23721
|
}
|
|
24307
23722
|
};
|
|
24308
|
-
base58btc2 = baseX2({
|
|
24309
|
-
name: "base58btc",
|
|
24310
|
-
prefix: "z",
|
|
24311
|
-
alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
|
24312
|
-
});
|
|
24313
|
-
base58flickr2 = baseX2({
|
|
24314
|
-
name: "base58flickr",
|
|
24315
|
-
prefix: "Z",
|
|
24316
|
-
alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
|
|
24317
|
-
});
|
|
24318
|
-
textEncoder = new TextEncoder();
|
|
24319
23723
|
base322 = rfc46482({
|
|
24320
23724
|
prefix: "b",
|
|
24321
23725
|
name: "base32",
|
|
@@ -24380,6 +23784,16 @@ var init_dist3 = __esm({
|
|
|
24380
23784
|
name: "base36upper",
|
|
24381
23785
|
alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
24382
23786
|
});
|
|
23787
|
+
base58btc2 = baseX2({
|
|
23788
|
+
name: "base58btc",
|
|
23789
|
+
prefix: "z",
|
|
23790
|
+
alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
|
23791
|
+
});
|
|
23792
|
+
base58flickr2 = baseX2({
|
|
23793
|
+
name: "base58flickr",
|
|
23794
|
+
prefix: "Z",
|
|
23795
|
+
alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
|
|
23796
|
+
});
|
|
24383
23797
|
encode_12 = encode4;
|
|
24384
23798
|
MSB2 = 128;
|
|
24385
23799
|
REST2 = 127;
|
|
@@ -24415,10 +23829,10 @@ var init_dist3 = __esm({
|
|
|
24415
23829
|
/**
|
|
24416
23830
|
* Creates a multihash digest.
|
|
24417
23831
|
*/
|
|
24418
|
-
constructor(code3, size2,
|
|
23832
|
+
constructor(code3, size2, digest4, bytes3) {
|
|
24419
23833
|
this.code = code3;
|
|
24420
23834
|
this.size = size2;
|
|
24421
|
-
this.digest =
|
|
23835
|
+
this.digest = digest4;
|
|
24422
23836
|
this.bytes = bytes3;
|
|
24423
23837
|
}
|
|
24424
23838
|
};
|
|
@@ -24481,8 +23895,8 @@ var init_dist3 = __esm({
|
|
|
24481
23895
|
toV1() {
|
|
24482
23896
|
switch (this.version) {
|
|
24483
23897
|
case 0: {
|
|
24484
|
-
const { code: code3, digest:
|
|
24485
|
-
const multihash = create2(code3,
|
|
23898
|
+
const { code: code3, digest: digest4 } = this.multihash;
|
|
23899
|
+
const multihash = create2(code3, digest4);
|
|
24486
23900
|
return _CID2.createV1(this.code, multihash);
|
|
24487
23901
|
}
|
|
24488
23902
|
case 1: {
|
|
@@ -24536,8 +23950,8 @@ var init_dist3 = __esm({
|
|
|
24536
23950
|
return new _CID2(version2, code3, multihash, bytes3 ?? encodeCID2(version2, code3, multihash.bytes));
|
|
24537
23951
|
} else if (value[cidSymbol2] === true) {
|
|
24538
23952
|
const { version: version2, multihash, code: code3 } = value;
|
|
24539
|
-
const
|
|
24540
|
-
return _CID2.create(version2, code3,
|
|
23953
|
+
const digest4 = decode8(multihash);
|
|
23954
|
+
return _CID2.create(version2, code3, digest4);
|
|
24541
23955
|
} else {
|
|
24542
23956
|
return null;
|
|
24543
23957
|
}
|
|
@@ -24547,11 +23961,11 @@ var init_dist3 = __esm({
|
|
|
24547
23961
|
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
24548
23962
|
* @param digest - (Multi)hash of the of the content.
|
|
24549
23963
|
*/
|
|
24550
|
-
static create(version2, code3,
|
|
23964
|
+
static create(version2, code3, digest4) {
|
|
24551
23965
|
if (typeof code3 !== "number") {
|
|
24552
23966
|
throw new Error("String codecs are no longer supported");
|
|
24553
23967
|
}
|
|
24554
|
-
if (!(
|
|
23968
|
+
if (!(digest4.bytes instanceof Uint8Array)) {
|
|
24555
23969
|
throw new Error("Invalid digest");
|
|
24556
23970
|
}
|
|
24557
23971
|
switch (version2) {
|
|
@@ -24559,12 +23973,12 @@ var init_dist3 = __esm({
|
|
|
24559
23973
|
if (code3 !== DAG_PB_CODE2) {
|
|
24560
23974
|
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE2}) block encoding`);
|
|
24561
23975
|
} else {
|
|
24562
|
-
return new _CID2(version2, code3,
|
|
23976
|
+
return new _CID2(version2, code3, digest4, digest4.bytes);
|
|
24563
23977
|
}
|
|
24564
23978
|
}
|
|
24565
23979
|
case 1: {
|
|
24566
|
-
const bytes3 = encodeCID2(version2, code3,
|
|
24567
|
-
return new _CID2(version2, code3,
|
|
23980
|
+
const bytes3 = encodeCID2(version2, code3, digest4.bytes);
|
|
23981
|
+
return new _CID2(version2, code3, digest4, bytes3);
|
|
24568
23982
|
}
|
|
24569
23983
|
default: {
|
|
24570
23984
|
throw new Error("Invalid version");
|
|
@@ -24574,8 +23988,8 @@ var init_dist3 = __esm({
|
|
|
24574
23988
|
/**
|
|
24575
23989
|
* Simplified version of `create` for CIDv0.
|
|
24576
23990
|
*/
|
|
24577
|
-
static createV0(
|
|
24578
|
-
return _CID2.create(0, DAG_PB_CODE2,
|
|
23991
|
+
static createV0(digest4) {
|
|
23992
|
+
return _CID2.create(0, DAG_PB_CODE2, digest4);
|
|
24579
23993
|
}
|
|
24580
23994
|
/**
|
|
24581
23995
|
* Simplified version of `create` for CIDv1.
|
|
@@ -24583,8 +23997,8 @@ var init_dist3 = __esm({
|
|
|
24583
23997
|
* @param code - Content encoding format code.
|
|
24584
23998
|
* @param digest - Multihash of the content.
|
|
24585
23999
|
*/
|
|
24586
|
-
static createV1(code3,
|
|
24587
|
-
return _CID2.create(1, code3,
|
|
24000
|
+
static createV1(code3, digest4) {
|
|
24001
|
+
return _CID2.create(1, code3, digest4);
|
|
24588
24002
|
}
|
|
24589
24003
|
/**
|
|
24590
24004
|
* Decoded a CID from its binary representation. The byte array must contain
|
|
@@ -24617,8 +24031,8 @@ var init_dist3 = __esm({
|
|
|
24617
24031
|
throw new Error("Incorrect length");
|
|
24618
24032
|
}
|
|
24619
24033
|
const digestBytes3 = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
24620
|
-
const
|
|
24621
|
-
const cid2 = specs.version === 0 ? _CID2.createV0(
|
|
24034
|
+
const digest4 = new Digest2(specs.multihashCode, specs.digestSize, digestBytes3, multihashBytes);
|
|
24035
|
+
const cid2 = specs.version === 0 ? _CID2.createV0(digest4) : _CID2.createV1(specs.codec, digest4);
|
|
24622
24036
|
return [cid2, bytes3.subarray(specs.size)];
|
|
24623
24037
|
}
|
|
24624
24038
|
/**
|
|
@@ -24699,7 +24113,7 @@ var init_dist3 = __esm({
|
|
|
24699
24113
|
}
|
|
24700
24114
|
});
|
|
24701
24115
|
|
|
24702
|
-
//
|
|
24116
|
+
// ../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-core/dist/index.js
|
|
24703
24117
|
import { SiweMessage } from "siwe";
|
|
24704
24118
|
function equals5(aa, bb) {
|
|
24705
24119
|
if (aa === bb) {
|
|
@@ -25379,13 +24793,13 @@ function concat2(arrays, length22) {
|
|
|
25379
24793
|
if (length22 == null) {
|
|
25380
24794
|
length22 = arrays.reduce((acc, curr) => acc + curr.length, 0);
|
|
25381
24795
|
}
|
|
25382
|
-
const
|
|
24796
|
+
const output = allocUnsafe(length22);
|
|
25383
24797
|
let offset = 0;
|
|
25384
24798
|
for (const arr of arrays) {
|
|
25385
|
-
|
|
24799
|
+
output.set(arr, offset);
|
|
25386
24800
|
offset += arr.length;
|
|
25387
24801
|
}
|
|
25388
|
-
return asUint8Array(
|
|
24802
|
+
return asUint8Array(output);
|
|
25389
24803
|
}
|
|
25390
24804
|
function createCodec(name2, prefix, encode52, decode72) {
|
|
25391
24805
|
return {
|
|
@@ -25781,13 +25195,13 @@ function createInMemoryLocalNodeIdentityStore() {
|
|
|
25781
25195
|
}
|
|
25782
25196
|
};
|
|
25783
25197
|
}
|
|
25784
|
-
function locationPayloadForRecord(
|
|
25198
|
+
function locationPayloadForRecord(record) {
|
|
25785
25199
|
return {
|
|
25786
|
-
version:
|
|
25787
|
-
subject:
|
|
25788
|
-
multiaddrs: [...
|
|
25789
|
-
updated_at:
|
|
25790
|
-
sequence:
|
|
25200
|
+
version: record.version,
|
|
25201
|
+
subject: record.subject,
|
|
25202
|
+
multiaddrs: [...record.multiaddrs],
|
|
25203
|
+
updated_at: record.updated_at,
|
|
25204
|
+
sequence: record.sequence
|
|
25791
25205
|
};
|
|
25792
25206
|
}
|
|
25793
25207
|
function canonicalLocationPayload(payload) {
|
|
@@ -25838,13 +25252,13 @@ function validateLocationRecord(input) {
|
|
|
25838
25252
|
return { ...payload, signature };
|
|
25839
25253
|
}
|
|
25840
25254
|
async function verifyLocationRecord(input) {
|
|
25841
|
-
const
|
|
25842
|
-
const payload = canonicalLocationPayload(locationPayloadForRecord(
|
|
25843
|
-
if (
|
|
25844
|
-
return verifyPkhSignature(
|
|
25255
|
+
const record = validateLocationRecord(input);
|
|
25256
|
+
const payload = canonicalLocationPayload(locationPayloadForRecord(record));
|
|
25257
|
+
if (record.subject.startsWith("did:pkh:")) {
|
|
25258
|
+
return verifyPkhSignature(record.subject, payload, record.signature);
|
|
25845
25259
|
}
|
|
25846
|
-
if (
|
|
25847
|
-
return verifyDidKeySignature(
|
|
25260
|
+
if (record.subject.startsWith("did:key:")) {
|
|
25261
|
+
return verifyDidKeySignature(record.subject, payload, record.signature);
|
|
25848
25262
|
}
|
|
25849
25263
|
return false;
|
|
25850
25264
|
}
|
|
@@ -25951,18 +25365,18 @@ async function fetchRegistryLocalLinkCandidates(options2, fetchFn, existingCandi
|
|
|
25951
25365
|
}
|
|
25952
25366
|
const registryUrl = options2.registryUrl ?? DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL;
|
|
25953
25367
|
try {
|
|
25954
|
-
const
|
|
25955
|
-
if (!
|
|
25368
|
+
const record = await fetchLocationRecord(registryUrl, options2.subject, fetchFn);
|
|
25369
|
+
if (!record) {
|
|
25956
25370
|
return [];
|
|
25957
25371
|
}
|
|
25958
25372
|
const shouldVerify = options2.verifyRecords ?? true;
|
|
25959
|
-
if (shouldVerify && !await verifyLocationRecord(
|
|
25373
|
+
if (shouldVerify && !await verifyLocationRecord(record)) {
|
|
25960
25374
|
debugLog(
|
|
25961
25375
|
`registry record signature invalid for ${options2.subject}; skipping local-link lookup`
|
|
25962
25376
|
);
|
|
25963
25377
|
return [];
|
|
25964
25378
|
}
|
|
25965
|
-
return extractLocalLinkUrls(
|
|
25379
|
+
return extractLocalLinkUrls(record).filter((url) => !existingCandidates.some((c) => c.url === url)).map((url) => ({
|
|
25966
25380
|
source: "local-link",
|
|
25967
25381
|
url,
|
|
25968
25382
|
timeoutMs: LOCAL_LINK_PROBE_TIMEOUT_MS
|
|
@@ -25971,12 +25385,12 @@ async function fetchRegistryLocalLinkCandidates(options2, fetchFn, existingCandi
|
|
|
25971
25385
|
return [];
|
|
25972
25386
|
}
|
|
25973
25387
|
}
|
|
25974
|
-
function extractLocalLinkUrls(
|
|
25975
|
-
if (!
|
|
25388
|
+
function extractLocalLinkUrls(record) {
|
|
25389
|
+
if (!record) {
|
|
25976
25390
|
return [];
|
|
25977
25391
|
}
|
|
25978
25392
|
const urls = [];
|
|
25979
|
-
for (const addr of
|
|
25393
|
+
for (const addr of record.multiaddrs) {
|
|
25980
25394
|
let url;
|
|
25981
25395
|
try {
|
|
25982
25396
|
url = multiaddrToHttpUrl(addr);
|
|
@@ -26080,7 +25494,7 @@ async function verifyPkhSignature(did, payload, signature) {
|
|
|
26080
25494
|
}
|
|
26081
25495
|
function verifyDidKeySignature(did, payload, signature) {
|
|
26082
25496
|
const publicKey = ed25519PublicKeyFromDidKey2(did);
|
|
26083
|
-
const signatureBytes =
|
|
25497
|
+
const signatureBytes = decodeBase64Url3(signature);
|
|
26084
25498
|
if (signatureBytes.length !== 64) {
|
|
26085
25499
|
throw new LocationRecordValidationError(
|
|
26086
25500
|
"did:key signature must be a base64url Ed25519 signature"
|
|
@@ -26110,7 +25524,7 @@ function ed25519PublicKeyFromDidKey2(did) {
|
|
|
26110
25524
|
"did:key must be an Ed25519 public key"
|
|
26111
25525
|
);
|
|
26112
25526
|
}
|
|
26113
|
-
function
|
|
25527
|
+
function decodeBase64Url3(value) {
|
|
26114
25528
|
const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
26115
25529
|
const bytes2 = [];
|
|
26116
25530
|
let buffer = 0;
|
|
@@ -26131,9 +25545,9 @@ function decodeBase64Url4(value) {
|
|
|
26131
25545
|
}
|
|
26132
25546
|
return Uint8Array.from(bytes2);
|
|
26133
25547
|
}
|
|
26134
|
-
var import_ms, __defProp3, __typeError, __defNormalProp, __export3, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, objectHasOwn, base32_exports, empty3, src3, _brrp__multiformats_scope_baseX3, base_x_default3, Encoder3, Decoder3, ComposedDecoder3, Codec3, base323, base32upper3, base32pad3, base32padupper3, base32hex3, base32hexupper3, base32hexpad3, base32hexpadupper3, base32z3, base36_exports, base363, base36upper3, base58_exports, base58btc3, base58flickr3, encode_13, MSB3, REST3, MSBALL3, INT3, decode22, MSB$13, REST$13, N13, N23, N33, N43, N53, N63, N73, N83, N93, length3, varint3, _brrp_varint3, varint_default3, Digest3, cache3, _a, CID3, DAG_PB_CODE3, SHA_256_CODE3, cidSymbol3,
|
|
25548
|
+
var import_ms, __defProp3, __typeError, __defNormalProp, __export3, __publicField, __accessCheck, __privateGet, __privateAdd, __privateSet, EnsDataSchema, SiweConfigSchema, ClientSessionSchema, objectHasOwn, base32_exports, empty3, src3, _brrp__multiformats_scope_baseX3, base_x_default3, Encoder3, Decoder3, ComposedDecoder3, Codec3, base323, base32upper3, base32pad3, base32padupper3, base32hex3, base32hexupper3, base32hexpad3, base32hexpadupper3, base32z3, base36_exports, base363, base36upper3, base58_exports, base58btc3, base58flickr3, encode_13, MSB3, REST3, MSBALL3, INT3, decode22, MSB$13, REST$13, N13, N23, N33, N43, N53, N63, N73, N83, N93, length3, varint3, _brrp_varint3, varint_default3, Digest3, cache3, _a, CID3, DAG_PB_CODE3, SHA_256_CODE3, cidSymbol3, textEncoder, objectHasOwn2, CEILING_SERVICES, GRANTABLE_ACTIONS, base10_exports, base10, base16_exports, base16, base16upper, base2_exports, base22, base256emoji_exports, alphabet, alphabetBytesToChars, alphabetCharsToBytes, base256emoji, base64_exports, base642, base64pad2, base64url2, base64urlpad2, base8_exports, base8, identity_exports, identity, textEncoder2, textDecoder, identity_exports2, code2, name, encode42, identity2, sha2_browser_exports, DEFAULT_MIN_DIGEST_LENGTH, Hasher, sha2562, sha5122, bases, hashes, textEncoder3, objectHasOwn3, TRANSCRIPT_SHARE_BOOTSTRAP_SCHEMA, OWNER_NODE_ENDPOINT_SCHEMA, W3C_VC_CREDENTIAL_VERIFIER, objectHasOwn4, CompactHeaderSchema, CompactPayloadSchema, POLICY_ENGINE_CHALLENGE_RESPONSE_SCHEMA, POLICY_ENGINE_DENIAL_SCHEMA, POLICY_ENGINE_GRANT_PRESENTATION_DENIAL_CODES, JsonValueSchema, Rfc3339Schema, SignedRecordSchema, PolicyEngineSchema, OwnerNodeSchema, ResourceHintSchema, BootstrapSchema, SignatureSchema, ChallengeSchema, ChallengeResponseSchema, DenialSchema, ErrorEnvelopeDenialSchema, WireDelegationSchema, ResolveResponseSchema, DelegateReceiptSchema, SqlReadResponseSchema, KvReadResponseSchema, LISTEN_SQL_STATEMENT_CATALOG, LISTEN_SQL_STATEMENT_BY_NAME, JWKSchema, KeyTypeSchema, KeyInfoSchema, DelegationErrorSchema, DelegationSchema, DelegationStatusSchema, DelegationRevocationReceiptSchema, AccountDelegationResourceSchema, AccountDelegationDateSchema, AccountDelegationRecordSchema, AccountDelegationPageSchema, AccountDelegationQueryOptionsSchema, CapabilityEntrySchema, DelegationRecordSchema, CreateDelegationParamsSchema, DelegationChainSchema, DelegationChainV2Schema, DelegationDirectionSchema, DelegationFiltersSchema, SpaceOwnershipSchema, SpaceInfoSchema, ShareSchemaSchema, ShareLinkSchema, ShareLinkDataSchema, IngestOptionsSchema, GenerateShareParamsSchema, DelegationManagerConfigSchema, KeyProviderSchema, DelegationApiResponseSchema, DelegatedResourceSchema, CreateDelegationWasmParamsSchema, CreateDelegationWasmResultSchema, EPHEMERAL_MS, SIGNED_READ_URL_MS, SESSION_MS, SHARE_MS, APP_MS, MAX_MS, EXPIRY, DEFAULT_SIGNED_READ_URL_EXPIRY_MS2, EncodedShareDataSchema, ReceiveOptionsSchema, SharingServiceConfigSchema, DEFAULT_KNOWLEDGE_ROOT, ManifestValidationError, SERVICE_SHORT_TO_LONG, SERVICE_LONG_TO_SHORT, DEFAULT_MAX_INLINE_BYTES, MAX_SHARE_CONTENT_BYTES, MAX_SEALED_SHARE_CONTENT_BYTES, MAX_SHARE_ARTIFACT_BYTES, PUBLISHED_AAD, ShareRecipientTargetSchema, ShareResourceSchema, ShareActionSchema, ShareRecipientPolicySchema, ShareRecipientClientOptionsSchema, ShareNativeActionSchema, ShareWireActionSchema, ShareContentSourceSchema, ShareAddressedRecipientSchema, ShareAddressedDelegationRequestV2Schema, ShareAddressedDelegationEnvelopeV2Schema, ShareAddressedDelegationResponseV2Schema, ShareNativeResponseEntrySchema, ShareNativeResponseBase, ShareNativeResponseSchema, ResourceSchema, PortableDelegationSchema, MAX_NATIVE_CURSOR_BYTES, DEFAULT_EXPIRY_MS2, MAX_CONTENT_BYTES2, ethereumAddressPattern, EnsDataSchema2, PersistedTinyCloudSessionSchema, PersistedSessionDataSchema, TinyCloudSessionSchema, SpaceConfigSchema, SpaceServiceConfigSchema, SpaceDelegationParamsSchema, ServerDelegationInfoSchema, ServerDelegationsResponseSchema, ServerOwnedSpaceSchema, ServerOwnedSpacesResponseSchema, ServerCreateSpaceResponseSchema, ServerSpaceInfoResponseSchema, AutoApproveSpaceCreationHandler, defaultSpaceCreationHandler, N122, N222, N322, N422, N522, N622, N722, MSB22, REST22, string, ascii, BASES, bases_default, InvalidMultiaddrError, ValidationError, InvalidParametersError, UnknownProtocolError, Parser, MAX_IPV6_LENGTH, MAX_IPV4_LENGTH, parser, CODE_IP4, CODE_TCP, CODE_UDP, CODE_DCCP, CODE_IP6, CODE_IP6ZONE, CODE_IPCIDR, CODE_DNS, CODE_DNS4, CODE_DNS6, CODE_DNSADDR, CODE_SCTP, CODE_UDT, CODE_UTP, CODE_UNIX, CODE_P2P, CODE_ONION, CODE_ONION3, CODE_GARLIC64, CODE_GARLIC32, CODE_TLS, CODE_SNI, CODE_NOISE, CODE_QUIC, CODE_QUIC_V1, CODE_WEBTRANSPORT, CODE_CERTHASH, CODE_HTTP, CODE_HTTP_PATH, CODE_HTTPS, CODE_WS, CODE_WSS, CODE_P2P_WEBSOCKET_STAR, CODE_P2P_STARDUST, CODE_P2P_WEBRTC_STAR, CODE_P2P_WEBRTC_DIRECT, CODE_WEBRTC_DIRECT, CODE_WEBRTC, CODE_P2P_CIRCUIT, CODE_MEMORY, ip4ToBytes, ip6ToBytes, ip4ToString, ip6ToString, decoders, anybaseDecoder, validatePort, V, Registry, registry, codecs, inspect, symbol, _a2, _components, _string, _bytes, _Multiaddr, Multiaddr, ASSUME_HTTP_CODES, interpreters, word, boundry, v4, v6segment, v6, v46Exact, v4exact, v6exact, ipRegex, toString3, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, LOCAL_LOOPBACK_PROBE_TIMEOUT_MS, LOCAL_LINK_PROBE_TIMEOUT_MS, LOCAL_LINK_HOST_SUFFIX, LocationRecordValidationError, defaultLocalNodeIdentityStore, DNS_LABEL_REGEX;
|
|
26135
25549
|
var init_dist4 = __esm({
|
|
26136
|
-
"
|
|
25550
|
+
"../../../../../../../tmp/tmp.IpDdxMyG8g/node_modules/@tinycloud/sdk-core/dist/index.js"() {
|
|
26137
25551
|
"use strict";
|
|
26138
25552
|
init_zod();
|
|
26139
25553
|
init_zod();
|
|
@@ -26677,7 +26091,7 @@ var init_dist4 = __esm({
|
|
|
26677
26091
|
DAG_PB_CODE3 = 112;
|
|
26678
26092
|
SHA_256_CODE3 = 18;
|
|
26679
26093
|
cidSymbol3 = /* @__PURE__ */ Symbol.for("@ipld/js-cid/CID");
|
|
26680
|
-
|
|
26094
|
+
textEncoder = new TextEncoder();
|
|
26681
26095
|
objectHasOwn2 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
|
|
26682
26096
|
Object.prototype.hasOwnProperty
|
|
26683
26097
|
);
|
|
@@ -26807,7 +26221,7 @@ var init_dist4 = __esm({
|
|
|
26807
26221
|
encode: (buf) => toString(buf),
|
|
26808
26222
|
decode: (str) => fromString(str)
|
|
26809
26223
|
});
|
|
26810
|
-
|
|
26224
|
+
textEncoder2 = new TextEncoder();
|
|
26811
26225
|
textDecoder = new TextDecoder();
|
|
26812
26226
|
identity_exports2 = {};
|
|
26813
26227
|
__export3(identity_exports2, {
|
|
@@ -26819,7 +26233,7 @@ var init_dist4 = __esm({
|
|
|
26819
26233
|
identity2 = { code: code2, name, encode: encode42, digest };
|
|
26820
26234
|
sha2_browser_exports = {};
|
|
26821
26235
|
__export3(sha2_browser_exports, {
|
|
26822
|
-
sha256: () =>
|
|
26236
|
+
sha256: () => sha2562,
|
|
26823
26237
|
sha512: () => sha5122
|
|
26824
26238
|
});
|
|
26825
26239
|
DEFAULT_MIN_DIGEST_LENGTH = 20;
|
|
@@ -26856,7 +26270,7 @@ var init_dist4 = __esm({
|
|
|
26856
26270
|
}
|
|
26857
26271
|
}
|
|
26858
26272
|
};
|
|
26859
|
-
|
|
26273
|
+
sha2562 = from22({
|
|
26860
26274
|
name: "sha2-256",
|
|
26861
26275
|
code: 18,
|
|
26862
26276
|
encode: sha("SHA-256")
|
|
@@ -30055,12 +29469,12 @@ async function loadPermissionRequest(source, profile) {
|
|
|
30055
29469
|
}
|
|
30056
29470
|
return resolvePermissionSpaces(raw.permissions, profile);
|
|
30057
29471
|
}
|
|
30058
|
-
async function loadManifestPermissions(source, profile) {
|
|
29472
|
+
async function loadManifestPermissions(source, profile, options = {}) {
|
|
30059
29473
|
const raw = await loadManifestText(source);
|
|
30060
29474
|
const manifest = JSON.parse(raw);
|
|
30061
29475
|
if (typeof manifest.id === "string") {
|
|
30062
29476
|
const resolved = resolveManifest(manifest);
|
|
30063
|
-
return resolvePermissionSpaces(resolved.resources, profile);
|
|
29477
|
+
return resolvePermissionSpaces(resolved.resources, profile, options);
|
|
30064
29478
|
}
|
|
30065
29479
|
if (typeof manifest.app_id === "string") {
|
|
30066
29480
|
const permissions = (manifest.permissions ?? []).filter((entry) => entry !== null && typeof entry === "object").map((entry) => {
|
|
@@ -30079,7 +29493,7 @@ async function loadManifestPermissions(source, profile) {
|
|
|
30079
29493
|
};
|
|
30080
29494
|
});
|
|
30081
29495
|
permissions.push(...await secretPermissionsFromAppManifest(manifest, profile));
|
|
30082
|
-
return resolvePermissionSpaces(permissions, profile);
|
|
29496
|
+
return resolvePermissionSpaces(permissions, profile, options);
|
|
30083
29497
|
}
|
|
30084
29498
|
throw new CLIError(
|
|
30085
29499
|
"INVALID_MANIFEST",
|
|
@@ -30149,9 +29563,9 @@ function compactPermission(permission) {
|
|
|
30149
29563
|
const actions = permission.actions.map((action) => action.startsWith(`${service}/`) ? action.slice(service.length + 1) : action).join(",");
|
|
30150
29564
|
return `${service}:${space}:${permission.path}:${actions}`;
|
|
30151
29565
|
}
|
|
30152
|
-
async function resolvePermissionSpaces(entries, profile) {
|
|
29566
|
+
async function resolvePermissionSpaces(entries, profile, options = {}) {
|
|
30153
29567
|
const profileConfig = await ProfileManager.getProfile(profile);
|
|
30154
|
-
const allowLogicalSpaces = resolveProfilePosture(profileConfig) === "delegate-session";
|
|
29568
|
+
const allowLogicalSpaces = options.allowLogicalSpaces || resolveProfilePosture(profileConfig) === "delegate-session";
|
|
30155
29569
|
const resolved = [];
|
|
30156
29570
|
for (const entry of entries) {
|
|
30157
29571
|
const service = normalizeService(entry.service);
|
|
@@ -30975,18 +30389,68 @@ Open this URL in a browser to authenticate:
|
|
|
30975
30389
|
});
|
|
30976
30390
|
}
|
|
30977
30391
|
|
|
30978
|
-
// src/auth/
|
|
30392
|
+
// src/auth/scoped-login.ts
|
|
30393
|
+
init_errors();
|
|
30979
30394
|
init_constants();
|
|
30980
|
-
|
|
30981
|
-
|
|
30982
|
-
|
|
30983
|
-
|
|
30984
|
-
|
|
30985
|
-
|
|
30986
|
-
|
|
30987
|
-
|
|
30988
|
-
|
|
30989
|
-
}
|
|
30395
|
+
function normalizeSpace(space) {
|
|
30396
|
+
return space.replace(/(eip155:\d+:)(0x[0-9a-fA-F]{40})/, (_, prefix, address) => prefix + address.toLowerCase());
|
|
30397
|
+
}
|
|
30398
|
+
function validateLoginPermissions(permissions) {
|
|
30399
|
+
if (!permissions.length || permissions.some(
|
|
30400
|
+
(p) => !p.service?.startsWith("tinycloud.") || !p.space || !p.space.startsWith("tinycloud:") && !/^[A-Za-z0-9_-]+$/.test(p.space) || typeof p.path !== "string" || !p.actions?.length || p.actions.some((action) => !action.startsWith(`${p.service}/`))
|
|
30401
|
+
) || new Set(permissions.map((p) => normalizeSpace(p.space))).size !== 1) {
|
|
30402
|
+
throw new CLIError("INVALID_LOGIN_SCOPE", "First login requires non-empty permissions in one TinyCloud space. Request additional spaces after login.", ExitCode.USAGE_ERROR);
|
|
30403
|
+
}
|
|
30404
|
+
}
|
|
30405
|
+
async function verifyScopedLogin(data, key, sessionDid, requested, expectedOwner) {
|
|
30406
|
+
let proof;
|
|
30407
|
+
try {
|
|
30408
|
+
if (typeof data.siwe !== "string" || typeof data.signature !== "string" || typeof data.address !== "string" || !Number.isSafeInteger(data.chainId) || typeof data.spaceId !== "string" || typeof data.delegationCid !== "string" || !data.delegationHeader || typeof data.delegationHeader !== "object" || typeof data.verificationMethod !== "string" || data.verificationMethod.split("#")[0] !== sessionDid.split("#")[0]) throw new Error();
|
|
30409
|
+
const { NodeWasmBindings: NodeWasmBindings2 } = await import("@tinycloud/node-sdk");
|
|
30410
|
+
proof = new NodeWasmBindings2().validatePersistedSession({
|
|
30411
|
+
delegationHeader: data.delegationHeader,
|
|
30412
|
+
delegationCid: data.delegationCid,
|
|
30413
|
+
spaceId: data.spaceId,
|
|
30414
|
+
jwk: key,
|
|
30415
|
+
address: data.address,
|
|
30416
|
+
chainId: data.chainId,
|
|
30417
|
+
siwe: data.siwe,
|
|
30418
|
+
signature: data.signature
|
|
30419
|
+
});
|
|
30420
|
+
if (!proof.verifiedRecap?.length || !proof.expiresAt || !Number.isFinite(Date.parse(proof.expiresAt))) throw new Error();
|
|
30421
|
+
} catch (error) {
|
|
30422
|
+
if (/expir/i.test(error instanceof Error ? error.message : String(error))) {
|
|
30423
|
+
throw new CLIError("AUTH_EXPIRED", "The approved session has expired. No scoped session was saved.", ExitCode.AUTH_REQUIRED);
|
|
30424
|
+
}
|
|
30425
|
+
throw new CLIError("OPENKEY_PROOF_INVALID", "OpenKey did not return a complete, verifiable session proof. No scoped session was saved.", ExitCode.AUTH_REQUIRED);
|
|
30426
|
+
}
|
|
30427
|
+
if (Date.parse(proof.expiresAt) <= Date.now()) {
|
|
30428
|
+
throw new CLIError("AUTH_EXPIRED", "The approved session has expired. No scoped session was saved.", ExitCode.AUTH_REQUIRED);
|
|
30429
|
+
}
|
|
30430
|
+
const ownerDid = `did:pkh:eip155:${data.chainId}:${data.address}`;
|
|
30431
|
+
if (expectedOwner && normalizeSpace(expectedOwner) !== normalizeSpace(ownerDid)) {
|
|
30432
|
+
throw new CLIError("OPENKEY_OWNER_MISMATCH", "The approved signing identity differs from the expected owner. No scoped session was saved.", ExitCode.PERMISSION_DENIED);
|
|
30433
|
+
}
|
|
30434
|
+
const spaceId = data.spaceId;
|
|
30435
|
+
const allowed = new Set(requested.flatMap((permission) => {
|
|
30436
|
+
const expectedSpace = permission.space.startsWith("tinycloud:") ? permission.space : `tinycloud:${ownerDid.slice(4)}:${permission.space}`;
|
|
30437
|
+
if (normalizeSpace(expectedSpace) !== normalizeSpace(spaceId)) {
|
|
30438
|
+
throw new CLIError("OPENKEY_SCOPE_MISMATCH", "The approved space differs from the requested space. No scoped session was saved.", ExitCode.PERMISSION_DENIED);
|
|
30439
|
+
}
|
|
30440
|
+
return permission.actions.map((action) => JSON.stringify([permission.service, normalizeSpace(expectedSpace), permission.path, action]));
|
|
30441
|
+
}));
|
|
30442
|
+
const permissions = proof.verifiedRecap.map((entry) => {
|
|
30443
|
+
const service = entry.service.startsWith("tinycloud.") ? entry.service : `tinycloud.${entry.service}`;
|
|
30444
|
+
const actions = entry.actions.map((action) => action.includes("/") ? action : `${service}/${action}`);
|
|
30445
|
+
for (const action of actions) {
|
|
30446
|
+
if (!allowed.has(JSON.stringify([service, normalizeSpace(entry.space), entry.path, action]))) {
|
|
30447
|
+
throw new CLIError("OPENKEY_GRANT_BROADENED", "The signed grant contains authority beyond the login manifest. No scoped session was saved.", ExitCode.PERMISSION_DENIED);
|
|
30448
|
+
}
|
|
30449
|
+
}
|
|
30450
|
+
return { service, space: entry.space, path: entry.path, actions };
|
|
30451
|
+
});
|
|
30452
|
+
return { ...data, jwk: key, ownerDid, permissions, expiresAt: proof.expiresAt, expiry: proof.expiresAt, expirationTime: proof.expiresAt };
|
|
30453
|
+
}
|
|
30990
30454
|
|
|
30991
30455
|
// src/auth/local-key.ts
|
|
30992
30456
|
import { TCWSessionManager, importKey, initPanicHook } from "@tinycloud/node-sdk-wasm";
|
|
@@ -31058,251 +30522,6 @@ async function localKeySignIn(options) {
|
|
|
31058
30522
|
};
|
|
31059
30523
|
}
|
|
31060
30524
|
|
|
31061
|
-
// src/auth/device-auth.ts
|
|
31062
|
-
var SHARE_DEVICE_DELEGATION_SECONDS = 30 * 24 * 60 * 60;
|
|
31063
|
-
var SHARE_DEVICE_PERMISSIONS = [{
|
|
31064
|
-
service: "tinycloud.capabilities",
|
|
31065
|
-
space: "applications",
|
|
31066
|
-
path: "",
|
|
31067
|
-
actions: ["tinycloud.capabilities/read"]
|
|
31068
|
-
}];
|
|
31069
|
-
function digest2(value) {
|
|
31070
|
-
return createHash("sha256").update(value).digest("base64url");
|
|
31071
|
-
}
|
|
31072
|
-
function canonicalOrigin(value, label) {
|
|
31073
|
-
const url = new URL(value);
|
|
31074
|
-
const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost";
|
|
31075
|
-
if (url.origin !== value || url.protocol !== "https:" && !(loopback && url.protocol === "http:")) {
|
|
31076
|
-
throw new Error(`${label} must be a canonical HTTPS origin`);
|
|
31077
|
-
}
|
|
31078
|
-
return value;
|
|
31079
|
-
}
|
|
31080
|
-
function jsonEqual(left, right) {
|
|
31081
|
-
const canonical = (value) => Array.isArray(value) ? value.map(canonical) : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, entry]) => [key, canonical(entry)])) : value;
|
|
31082
|
-
return JSON.stringify(canonical(left)) === JSON.stringify(canonical(right));
|
|
31083
|
-
}
|
|
31084
|
-
function validateStart(value) {
|
|
31085
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("OpenKey returned an invalid device authorization response");
|
|
31086
|
-
const result = value;
|
|
31087
|
-
if (typeof result.transactionId !== "string" || !/^[A-Za-z0-9_-]{20,}$/.test(result.transactionId) || typeof result.userCode !== "string" || !/^[A-Z2-9]{4}-[A-Z2-9]{4}$/.test(result.userCode) || typeof result.verificationUri !== "string" || typeof result.verificationUriComplete !== "string" || !Number.isSafeInteger(result.expiresIn) || Number(result.expiresIn) < 60 || !Number.isSafeInteger(result.interval) || Number(result.interval) < 1) throw new Error("OpenKey returned an invalid device authorization response");
|
|
31088
|
-
canonicalOrigin(new URL(result.verificationUri).origin, "verification URI");
|
|
31089
|
-
if (new URL(result.verificationUriComplete).origin !== new URL(result.verificationUri).origin) {
|
|
31090
|
-
throw new Error("OpenKey returned an invalid verification URI");
|
|
31091
|
-
}
|
|
31092
|
-
return result;
|
|
31093
|
-
}
|
|
31094
|
-
async function responseJson(response) {
|
|
31095
|
-
try {
|
|
31096
|
-
return await response.json();
|
|
31097
|
-
} catch {
|
|
31098
|
-
throw new Error(`OpenKey device authorization failed (HTTP ${response.status})`);
|
|
31099
|
-
}
|
|
31100
|
-
}
|
|
31101
|
-
function errorCode(value) {
|
|
31102
|
-
return value && typeof value === "object" && typeof value.error === "string" ? value.error : void 0;
|
|
31103
|
-
}
|
|
31104
|
-
function publicSessionJwk(value) {
|
|
31105
|
-
const publicJwk = publicJwkForDelegation(value);
|
|
31106
|
-
const record = publicJwk;
|
|
31107
|
-
if (record.kty !== "OKP" || record.crv !== "Ed25519" || typeof record.x !== "string") {
|
|
31108
|
-
throw new Error("CLI session key is not a public Ed25519 JWK");
|
|
31109
|
-
}
|
|
31110
|
-
return publicJwk;
|
|
31111
|
-
}
|
|
31112
|
-
function publicRelayJwk(value) {
|
|
31113
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("OpenKey returned an invalid relay key");
|
|
31114
|
-
const jwk = value;
|
|
31115
|
-
if (jwk.kty !== "EC" || jwk.crv !== "P-256" || typeof jwk.x !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(jwk.x) || typeof jwk.y !== "string" || !/^[A-Za-z0-9_-]{43}$/.test(jwk.y) || "d" in jwk) throw new Error("OpenKey returned an invalid relay key");
|
|
31116
|
-
return { kty: "EC", crv: "P-256", x: jwk.x, y: jwk.y };
|
|
31117
|
-
}
|
|
31118
|
-
function decodeCanonicalBase64Url(value, label) {
|
|
31119
|
-
if (typeof value !== "string" || !/^[A-Za-z0-9_-]+$/.test(value)) throw new Error(`OpenKey returned an invalid ${label}`);
|
|
31120
|
-
const decoded = Buffer.from(value, "base64url");
|
|
31121
|
-
if (decoded.toString("base64url") !== value) throw new Error(`OpenKey returned an invalid ${label}`);
|
|
31122
|
-
return decoded;
|
|
31123
|
-
}
|
|
31124
|
-
function deriveRelayKey(sharedSecret, transactionId) {
|
|
31125
|
-
const extracted = createHmac("sha256", Buffer.from(transactionId)).update(sharedSecret).digest();
|
|
31126
|
-
return createHmac("sha256", extracted).update(Buffer.from("openkey-device-relay-v1")).update(Buffer.from([1])).digest();
|
|
31127
|
-
}
|
|
31128
|
-
function decryptRelayResult(envelope, transactionId, privateKey) {
|
|
31129
|
-
if (!envelope || typeof envelope !== "object" || Array.isArray(envelope)) throw new Error("OpenKey returned an invalid encrypted relay result");
|
|
31130
|
-
const relay = envelope;
|
|
31131
|
-
if (relay.version !== 1 || relay.algorithm !== "ECDH-P256-A256GCM") throw new Error("OpenKey returned an unsupported encrypted relay result");
|
|
31132
|
-
const peer = createPublicKey({ key: publicRelayJwk(relay.ephemeralPublicJwk), format: "jwk" });
|
|
31133
|
-
const nonce = decodeCanonicalBase64Url(relay.nonce, "relay nonce");
|
|
31134
|
-
const ciphertext = decodeCanonicalBase64Url(relay.ciphertext, "relay ciphertext");
|
|
31135
|
-
if (nonce.length !== 12 || ciphertext.length <= 16) throw new Error("OpenKey returned an invalid encrypted relay result");
|
|
31136
|
-
const sharedSecret = diffieHellman({ privateKey, publicKey: peer });
|
|
31137
|
-
const key = deriveRelayKey(sharedSecret, transactionId);
|
|
31138
|
-
const decipher = createDecipheriv("aes-256-gcm", key, nonce);
|
|
31139
|
-
decipher.setAAD(Buffer.from(transactionId));
|
|
31140
|
-
decipher.setAuthTag(ciphertext.subarray(ciphertext.length - 16));
|
|
31141
|
-
let value;
|
|
31142
|
-
try {
|
|
31143
|
-
value = JSON.parse(Buffer.concat([decipher.update(ciphertext.subarray(0, -16)), decipher.final()]).toString("utf8"));
|
|
31144
|
-
} catch {
|
|
31145
|
-
throw new Error("OpenKey returned an unreadable encrypted relay result");
|
|
31146
|
-
}
|
|
31147
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("OpenKey returned an invalid encrypted relay result");
|
|
31148
|
-
return value;
|
|
31149
|
-
}
|
|
31150
|
-
function assertShareDelegationPermissions(value) {
|
|
31151
|
-
if (!Array.isArray(value) || value.length !== 1) throw new Error("OpenKey returned a delegation outside the requested Share scope");
|
|
31152
|
-
const permission = value[0];
|
|
31153
|
-
if (!permission || permission.service !== "tinycloud.capabilities" && permission.service !== "capabilities" || permission.space !== "applications" && !(typeof permission.space === "string" && permission.space.endsWith(":applications")) || permission.path !== "" || !Array.isArray(permission.actions) || permission.actions.length !== 1 || permission.actions[0] !== "tinycloud.capabilities/read") throw new Error("OpenKey returned a delegation outside the requested Share scope");
|
|
31154
|
-
}
|
|
31155
|
-
function assertApprovedBinding(input) {
|
|
31156
|
-
if (input.binding.transactionId !== input.transactionId || input.binding.sessionDid !== input.sessionDid || input.binding.nodeOrigin !== input.nodeOrigin || input.binding.shareOrigin !== input.shareOrigin || !jsonEqual(input.binding.permissions, SHARE_DEVICE_PERMISSIONS)) throw new Error("OpenKey returned a delegation with the wrong device binding");
|
|
31157
|
-
const expiresAt = Date.parse(input.binding.delegationExpiresAt);
|
|
31158
|
-
if (!Number.isFinite(expiresAt) || expiresAt <= Date.now() || expiresAt > Date.now() + SHARE_DEVICE_DELEGATION_SECONDS * 1e3 + 3e4) {
|
|
31159
|
-
throw new Error("OpenKey returned a delegation outside the requested expiry window");
|
|
31160
|
-
}
|
|
31161
|
-
if (input.delegation.verificationMethod !== input.sessionDid) {
|
|
31162
|
-
throw new Error("OpenKey returned a delegation for a different CLI session DID");
|
|
31163
|
-
}
|
|
31164
|
-
assertShareDelegationPermissions(input.delegation.permissions);
|
|
31165
|
-
const delegationExpiryValue = input.delegation.expiresAt ?? input.delegation.expirationTime ?? input.delegation.expiry;
|
|
31166
|
-
const delegationExpiresAt = typeof delegationExpiryValue === "string" ? Date.parse(delegationExpiryValue) : Number.NaN;
|
|
31167
|
-
if (!Number.isFinite(delegationExpiresAt) || delegationExpiresAt !== expiresAt) {
|
|
31168
|
-
throw new Error("OpenKey returned a delegation outside the approved expiry window");
|
|
31169
|
-
}
|
|
31170
|
-
if (!input.delegation.jwk || typeof input.delegation.jwk !== "object" || !jsonEqual(publicSessionJwk(input.delegation.jwk), input.publicJwk)) {
|
|
31171
|
-
throw new Error("OpenKey returned a delegation for a different CLI session key");
|
|
31172
|
-
}
|
|
31173
|
-
const invalid = validateDelegationCallbackPayload(input.delegation);
|
|
31174
|
-
if (invalid) throw new Error(`OpenKey returned an invalid delegation: ${invalid}`);
|
|
31175
|
-
}
|
|
31176
|
-
async function acquireShareDeviceDelegation(input) {
|
|
31177
|
-
const openkeyHost = canonicalOrigin(input.openkeyHost ?? DEFAULT_OPENKEY_DEVICE_API_HOST, "OpenKey host");
|
|
31178
|
-
const nodeOrigin = canonicalOrigin(input.nodeOrigin, "TinyCloud node origin");
|
|
31179
|
-
const shareOrigin = canonicalOrigin(input.shareOrigin, "Share origin");
|
|
31180
|
-
const fetchFn = input.fetchFn ?? globalThis.fetch;
|
|
31181
|
-
const deviceSecret = randomBytes3(32).toString("base64url");
|
|
31182
|
-
const codeVerifier = randomBytes3(32).toString("base64url");
|
|
31183
|
-
const relayKeys = generateKeyPairSync("ec", { namedCurve: "prime256v1" });
|
|
31184
|
-
const relayPublicJwk = publicRelayJwk(relayKeys.publicKey.export({ format: "jwk" }));
|
|
31185
|
-
const publicJwk = publicSessionJwk(input.jwk);
|
|
31186
|
-
const startResponse = await fetchFn(`${openkeyHost}/api/device-authorizations`, {
|
|
31187
|
-
method: "POST",
|
|
31188
|
-
credentials: "omit",
|
|
31189
|
-
redirect: "error",
|
|
31190
|
-
referrerPolicy: "no-referrer",
|
|
31191
|
-
headers: { accept: "application/json", "content-type": "application/json" },
|
|
31192
|
-
body: JSON.stringify({
|
|
31193
|
-
deviceSecretHash: digest2(deviceSecret),
|
|
31194
|
-
codeChallenge: digest2(codeVerifier),
|
|
31195
|
-
relayPublicJwk,
|
|
31196
|
-
sessionDid: input.sessionDid,
|
|
31197
|
-
publicJwk,
|
|
31198
|
-
permissions: SHARE_DEVICE_PERMISSIONS,
|
|
31199
|
-
nodeOrigin,
|
|
31200
|
-
shareOrigin,
|
|
31201
|
-
delegationTtlSeconds: SHARE_DEVICE_DELEGATION_SECONDS
|
|
31202
|
-
})
|
|
31203
|
-
});
|
|
31204
|
-
const startValue = await responseJson(startResponse);
|
|
31205
|
-
if (!startResponse.ok) throw new Error(`OpenKey device authorization failed: ${errorCode(startValue) ?? startResponse.status}`);
|
|
31206
|
-
const started = validateStart(startValue);
|
|
31207
|
-
(input.emitInstructions ?? ((value) => {
|
|
31208
|
-
process.stderr.write(`OpenKey device authorization
|
|
31209
|
-
Visit: ${value.verificationUri}
|
|
31210
|
-
Code: ${value.userCode}
|
|
31211
|
-
|
|
31212
|
-
Waiting for approval\u2026
|
|
31213
|
-
`);
|
|
31214
|
-
}))({ verificationUri: started.verificationUri, verificationUriComplete: started.verificationUriComplete, userCode: started.userCode });
|
|
31215
|
-
const deadline = Date.now() + started.expiresIn * 1e3;
|
|
31216
|
-
let interval = started.interval;
|
|
31217
|
-
const wait = input.wait ?? ((milliseconds) => new Promise((resolve4) => setTimeout(resolve4, milliseconds)));
|
|
31218
|
-
while (Date.now() < deadline) {
|
|
31219
|
-
await wait(interval * 1e3);
|
|
31220
|
-
const response = await fetchFn(`${openkeyHost}/api/device-authorizations/token`, {
|
|
31221
|
-
method: "POST",
|
|
31222
|
-
credentials: "omit",
|
|
31223
|
-
redirect: "error",
|
|
31224
|
-
referrerPolicy: "no-referrer",
|
|
31225
|
-
headers: { accept: "application/json", "content-type": "application/json" },
|
|
31226
|
-
body: JSON.stringify({ transactionId: started.transactionId, deviceSecret, codeVerifier })
|
|
31227
|
-
});
|
|
31228
|
-
const value = await responseJson(response);
|
|
31229
|
-
const code3 = errorCode(value);
|
|
31230
|
-
if (response.status === 429 && code3 === "slow_down") {
|
|
31231
|
-
interval += 1;
|
|
31232
|
-
continue;
|
|
31233
|
-
}
|
|
31234
|
-
if (!response.ok) throw new Error(`OpenKey device authorization failed: ${code3 ?? response.status}`);
|
|
31235
|
-
const result = value;
|
|
31236
|
-
if (result.status === "pending") {
|
|
31237
|
-
interval = Math.max(interval, result.interval);
|
|
31238
|
-
continue;
|
|
31239
|
-
}
|
|
31240
|
-
if (result.status !== "approved" || !result.relay || !result.binding) {
|
|
31241
|
-
throw new Error("OpenKey returned an invalid device authorization result");
|
|
31242
|
-
}
|
|
31243
|
-
const delegation = decryptRelayResult(result.relay, started.transactionId, relayKeys.privateKey);
|
|
31244
|
-
assertApprovedBinding({ binding: result.binding, transactionId: started.transactionId, sessionDid: input.sessionDid, nodeOrigin, shareOrigin, publicJwk, delegation });
|
|
31245
|
-
return delegation;
|
|
31246
|
-
}
|
|
31247
|
-
throw new Error("OpenKey device authorization expired before approval");
|
|
31248
|
-
}
|
|
31249
|
-
function mergePrivateJwkIntoSession(session, key) {
|
|
31250
|
-
const sessionJwk = session.jwk;
|
|
31251
|
-
if (!sessionJwk || typeof sessionJwk !== "object") return session;
|
|
31252
|
-
const sessionJwkRecord = sessionJwk;
|
|
31253
|
-
if (typeof sessionJwkRecord.d === "string" && sessionJwkRecord.d.length > 0) return session;
|
|
31254
|
-
const privateParameter = key.d;
|
|
31255
|
-
if (typeof privateParameter !== "string" || privateParameter.length === 0) return session;
|
|
31256
|
-
return { ...session, jwk: { ...sessionJwkRecord, d: privateParameter } };
|
|
31257
|
-
}
|
|
31258
|
-
async function ensureShareDeviceAuthorization(input) {
|
|
31259
|
-
let profile = await ProfileManager.getProfile(input.profileName).catch(() => null);
|
|
31260
|
-
if (profile?.authMethod === "local" && input.allowReplaceLocal !== true) {
|
|
31261
|
-
throw new Error("This profile uses a local owner key. Run `tc auth login --device` explicitly to replace its authentication posture.");
|
|
31262
|
-
}
|
|
31263
|
-
let key = await ProfileManager.getKey(input.profileName);
|
|
31264
|
-
if (!key) {
|
|
31265
|
-
const generated = generateKey2();
|
|
31266
|
-
key = generated.jwk;
|
|
31267
|
-
await ProfileManager.setKey(input.profileName, key);
|
|
31268
|
-
}
|
|
31269
|
-
const sessionDid = keyToDID(key);
|
|
31270
|
-
profile = {
|
|
31271
|
-
...profile,
|
|
31272
|
-
name: input.profileName,
|
|
31273
|
-
host: input.nodeOrigin,
|
|
31274
|
-
chainId: profile?.chainId ?? DEFAULT_CHAIN_ID,
|
|
31275
|
-
spaceName: profile?.spaceName ?? "applications",
|
|
31276
|
-
did: sessionDid,
|
|
31277
|
-
sessionDid,
|
|
31278
|
-
createdAt: profile?.createdAt ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
31279
|
-
posture: "owner-openkey",
|
|
31280
|
-
operatorType: profile?.operatorType ?? "human",
|
|
31281
|
-
authMethod: "openkey",
|
|
31282
|
-
openkeyHost: input.openkeyHost ?? profile?.openkeyHost
|
|
31283
|
-
};
|
|
31284
|
-
await ProfileManager.setProfile(input.profileName, profile);
|
|
31285
|
-
const delegation = await acquireShareDeviceDelegation({
|
|
31286
|
-
sessionDid,
|
|
31287
|
-
jwk: key,
|
|
31288
|
-
nodeOrigin: input.nodeOrigin,
|
|
31289
|
-
shareOrigin: input.shareOrigin,
|
|
31290
|
-
openkeyHost: input.openkeyHost ?? profile.openkeyHost,
|
|
31291
|
-
fetchFn: input.fetchFn,
|
|
31292
|
-
emitInstructions: input.emitInstructions,
|
|
31293
|
-
wait: input.wait
|
|
31294
|
-
});
|
|
31295
|
-
const session = mergePrivateJwkIntoSession(delegation, key);
|
|
31296
|
-
await ProfileManager.setSession(input.profileName, session);
|
|
31297
|
-
const updatedProfile = {
|
|
31298
|
-
...profile,
|
|
31299
|
-
ownerDid: typeof session.ownerDid === "string" ? session.ownerDid : profile.ownerDid,
|
|
31300
|
-
spaceId: typeof session.spaceId === "string" ? session.spaceId : profile.spaceId
|
|
31301
|
-
};
|
|
31302
|
-
await ProfileManager.setProfile(input.profileName, updatedProfile);
|
|
31303
|
-
return { profile: updatedProfile, delegation: session };
|
|
31304
|
-
}
|
|
31305
|
-
|
|
31306
30525
|
// src/commands/auth.ts
|
|
31307
30526
|
init_theme();
|
|
31308
30527
|
function resolveOpenKeyHost(profile) {
|
|
@@ -31310,7 +30529,7 @@ function resolveOpenKeyHost(profile) {
|
|
|
31310
30529
|
}
|
|
31311
30530
|
async function promptAuthMethod() {
|
|
31312
30531
|
if (!isInteractive()) {
|
|
31313
|
-
return "
|
|
30532
|
+
return "local";
|
|
31314
30533
|
}
|
|
31315
30534
|
const rl = createInterface2({
|
|
31316
30535
|
input: process.stdin,
|
|
@@ -31336,20 +30555,19 @@ async function promptAuthMethod() {
|
|
|
31336
30555
|
}
|
|
31337
30556
|
function registerAuthCommand(program) {
|
|
31338
30557
|
const auth = program.command("auth").description("Authentication management");
|
|
31339
|
-
auth.command("login").description("Authenticate with TinyCloud").option("--
|
|
30558
|
+
auth.command("login").description("Authenticate with TinyCloud").option("--paste", "Use manual paste mode instead of browser callback").option("--no-popup", "Print the OpenKey URL without opening a browser").option("--method <method>", "Authentication method: local or openkey").option("--manifest <fileOrBase64>", "Request only this manifest's permissions during OpenKey login (one space)").option("--expiry <duration>", "OpenKey session lifetime, e.g. 1h or 7d").option("--owner <did>", "Require this existing primary DID for scoped login").action(async (options, cmd) => {
|
|
31340
30559
|
try {
|
|
31341
|
-
if (options.device && options.paste) {
|
|
31342
|
-
throw new CLIError("INVALID_ARGUMENT", "--device and --paste are mutually exclusive.", ExitCode.USAGE_ERROR);
|
|
31343
|
-
}
|
|
31344
30560
|
const globalOpts = cmd.optsWithGlobals();
|
|
31345
30561
|
const ctx = await ProfileManager.resolveContext(globalOpts);
|
|
31346
|
-
|
|
31347
|
-
|
|
31348
|
-
|
|
30562
|
+
if ((options.manifest || options.expiry || options.owner) && options.method === "local") {
|
|
30563
|
+
throw new CLIError("INVALID_ARGUMENT", "--manifest, --expiry and --owner require OpenKey login.", ExitCode.USAGE_ERROR);
|
|
30564
|
+
}
|
|
30565
|
+
if (options.owner && !options.manifest) {
|
|
30566
|
+
throw new CLIError("INVALID_ARGUMENT", "--owner requires --manifest so the signed identity is verified.", ExitCode.USAGE_ERROR);
|
|
31349
30567
|
}
|
|
31350
|
-
|
|
31351
|
-
|
|
31352
|
-
|
|
30568
|
+
const permissions = options.manifest ? await loadManifestPermissions(options.manifest, ctx.profile, { allowLogicalSpaces: true }) : void 0;
|
|
30569
|
+
let method;
|
|
30570
|
+
if (options.method) {
|
|
31353
30571
|
if (options.method !== "local" && options.method !== "openkey") {
|
|
31354
30572
|
throw new CLIError(
|
|
31355
30573
|
"INVALID_METHOD",
|
|
@@ -31359,7 +30577,7 @@ function registerAuthCommand(program) {
|
|
|
31359
30577
|
}
|
|
31360
30578
|
method = options.method;
|
|
31361
30579
|
} else {
|
|
31362
|
-
method = await promptAuthMethod();
|
|
30580
|
+
method = options.manifest || options.expiry ? "openkey" : await promptAuthMethod();
|
|
31363
30581
|
}
|
|
31364
30582
|
if (method === "local") {
|
|
31365
30583
|
await handleLocalAuth(ctx.profile, ctx.host);
|
|
@@ -31367,7 +30585,9 @@ function registerAuthCommand(program) {
|
|
|
31367
30585
|
await handleOpenKeyAuth(ctx.profile, ctx.host, {
|
|
31368
30586
|
paste: options.paste,
|
|
31369
30587
|
noPopup: options.popup === false,
|
|
31370
|
-
|
|
30588
|
+
permissions,
|
|
30589
|
+
expiry: parseExpiryOption(options.expiry),
|
|
30590
|
+
expectedOwner: options.owner
|
|
31371
30591
|
});
|
|
31372
30592
|
}
|
|
31373
30593
|
} catch (error) {
|
|
@@ -31955,15 +31175,15 @@ async function importRequestBoundDelegation(ctx, artifact) {
|
|
|
31955
31175
|
);
|
|
31956
31176
|
switch (result.status) {
|
|
31957
31177
|
case "ok": {
|
|
31958
|
-
const
|
|
31178
|
+
const output = result.output;
|
|
31959
31179
|
outputJson({
|
|
31960
31180
|
imported: true,
|
|
31961
|
-
activated:
|
|
31181
|
+
activated: output.activated,
|
|
31962
31182
|
kind: "tinycloud.auth.delegation",
|
|
31963
31183
|
requestId: typeof artifact === "object" && artifact !== null && typeof artifact.requestId === "string" ? artifact.requestId : null,
|
|
31964
|
-
delegationCid:
|
|
31965
|
-
permissions:
|
|
31966
|
-
expiry:
|
|
31184
|
+
delegationCid: output.cid,
|
|
31185
|
+
permissions: output.effectivePermissions,
|
|
31186
|
+
expiry: output.expiry
|
|
31967
31187
|
});
|
|
31968
31188
|
return;
|
|
31969
31189
|
}
|
|
@@ -32462,33 +31682,35 @@ async function handleLocalAuth(profileName, host, options = {}) {
|
|
|
32462
31682
|
return { profile: updatedProfile, sessionResult };
|
|
32463
31683
|
}
|
|
32464
31684
|
async function handleOpenKeyAuth(profileName, host, options = {}) {
|
|
32465
|
-
if (options.device) {
|
|
32466
|
-
const result = await ensureShareDeviceAuthorization({
|
|
32467
|
-
profileName,
|
|
32468
|
-
nodeOrigin: host,
|
|
32469
|
-
shareOrigin: "https://share.tinycloud.xyz",
|
|
32470
|
-
openkeyHost: process.env.TC_OPENKEY_HOST,
|
|
32471
|
-
allowReplaceLocal: true
|
|
32472
|
-
});
|
|
32473
|
-
outputJson({
|
|
32474
|
-
authenticated: true,
|
|
32475
|
-
profile: profileName,
|
|
32476
|
-
did: result.profile.did,
|
|
32477
|
-
spaceId: result.profile.spaceId ?? null,
|
|
32478
|
-
authMethod: "openkey",
|
|
32479
|
-
mode: "device"
|
|
32480
|
-
});
|
|
32481
|
-
return;
|
|
32482
|
-
}
|
|
32483
31685
|
const { profile, delegationData } = await refreshOpenKeySession(profileName, host, options);
|
|
32484
31686
|
outputJson({
|
|
32485
31687
|
authenticated: true,
|
|
32486
31688
|
profile: profileName,
|
|
32487
31689
|
did: profile.did,
|
|
32488
31690
|
spaceId: delegationData.spaceId,
|
|
32489
|
-
authMethod: "openkey"
|
|
31691
|
+
authMethod: "openkey",
|
|
31692
|
+
...options.permissions ? { scoped: true, ownerDid: profile.ownerDid, host, permissions: delegationData.permissions, expiresAt: delegationData.expiresAt, activation: delegationData.hostActivated === true ? "confirmed-by-openkey" : "unverified" } : {}
|
|
32490
31693
|
});
|
|
32491
31694
|
}
|
|
31695
|
+
function mergePrivateJwkIntoSession(session, key) {
|
|
31696
|
+
const sessionJwk = session.jwk;
|
|
31697
|
+
if (!sessionJwk || typeof sessionJwk !== "object") {
|
|
31698
|
+
return session;
|
|
31699
|
+
}
|
|
31700
|
+
const sessionJwkRecord = sessionJwk;
|
|
31701
|
+
const sessionD = sessionJwkRecord.d;
|
|
31702
|
+
if (typeof sessionD === "string" && sessionD.length > 0) {
|
|
31703
|
+
return session;
|
|
31704
|
+
}
|
|
31705
|
+
const keyD = key.d;
|
|
31706
|
+
if (typeof keyD !== "string" || keyD.length === 0) {
|
|
31707
|
+
return session;
|
|
31708
|
+
}
|
|
31709
|
+
return {
|
|
31710
|
+
...session,
|
|
31711
|
+
jwk: { ...sessionJwkRecord, d: keyD }
|
|
31712
|
+
};
|
|
31713
|
+
}
|
|
32492
31714
|
async function refreshOpenKeySession(profileName, host, options = {}) {
|
|
32493
31715
|
const key = await ProfileManager.getKey(profileName);
|
|
32494
31716
|
if (!key) {
|
|
@@ -32499,18 +31721,23 @@ async function refreshOpenKeySession(profileName, host, options = {}) {
|
|
|
32499
31721
|
);
|
|
32500
31722
|
}
|
|
32501
31723
|
const profile = await ProfileManager.getProfile(profileName);
|
|
31724
|
+
if (options.permissions !== void 0) validateLoginPermissions(options.permissions);
|
|
32502
31725
|
const acquireOpenKey = options.openKeyAcquisition ?? startAuthFlow;
|
|
32503
31726
|
const delegationData = await acquireOpenKey(profile.did, {
|
|
32504
31727
|
paste: options.paste,
|
|
32505
31728
|
noPopup: options.noPopup,
|
|
32506
31729
|
jwk: key,
|
|
32507
31730
|
host,
|
|
32508
|
-
openkeyHost: resolveOpenKeyHost(profile)
|
|
31731
|
+
openkeyHost: resolveOpenKeyHost(profile),
|
|
31732
|
+
permissions: options.permissions,
|
|
31733
|
+
expiry: options.expiry,
|
|
31734
|
+
...options.permissions ? { reason: "Allow this local TinyCloud profile to use the permissions in the installed application manifest." } : {}
|
|
32509
31735
|
});
|
|
32510
|
-
const sanitizedSession = mergePrivateJwkIntoSession(delegationData, key);
|
|
31736
|
+
const sanitizedSession = options.permissions ? await verifyScopedLogin(delegationData, key, profile.sessionDid ?? profile.did, options.permissions, options.expectedOwner ?? profile.ownerDid) : mergePrivateJwkIntoSession(delegationData, key);
|
|
32511
31737
|
await ProfileManager.setSession(profileName, sanitizedSession);
|
|
32512
31738
|
const updatedProfile = {
|
|
32513
31739
|
...profile,
|
|
31740
|
+
host,
|
|
32514
31741
|
sessionDid: profile.sessionDid ?? profile.did,
|
|
32515
31742
|
posture: profile.posture ?? "owner-openkey",
|
|
32516
31743
|
operatorType: profile.operatorType ?? "human",
|
|
@@ -32654,6 +31881,99 @@ complete -c tc -l quiet -s q -d "Suppress non-essential output"
|
|
|
32654
31881
|
`;
|
|
32655
31882
|
}
|
|
32656
31883
|
|
|
31884
|
+
// package.json
|
|
31885
|
+
var package_default = {
|
|
31886
|
+
name: "@tinycloud/cli",
|
|
31887
|
+
version: "0.10.0",
|
|
31888
|
+
description: "TinyCloud CLI - manage data, delegations, and nodes from the terminal",
|
|
31889
|
+
author: "TinyCloud, Inc.",
|
|
31890
|
+
license: "EGPL",
|
|
31891
|
+
type: "module",
|
|
31892
|
+
main: "dist/index.js",
|
|
31893
|
+
types: "dist/index.d.ts",
|
|
31894
|
+
bin: {
|
|
31895
|
+
tc: "./bin/tc"
|
|
31896
|
+
},
|
|
31897
|
+
files: [
|
|
31898
|
+
"dist",
|
|
31899
|
+
"bin",
|
|
31900
|
+
"skills"
|
|
31901
|
+
],
|
|
31902
|
+
engines: {
|
|
31903
|
+
node: ">=20"
|
|
31904
|
+
},
|
|
31905
|
+
scripts: {
|
|
31906
|
+
build: "tsup",
|
|
31907
|
+
clean: "rm -rf dist",
|
|
31908
|
+
dev: "tsup --watch",
|
|
31909
|
+
"generate:reference": "bun scripts/generate-reference.ts",
|
|
31910
|
+
"check:generated": "bun scripts/generate-reference.ts --check",
|
|
31911
|
+
"check:coverage": "bun scripts/check-coverage.ts",
|
|
31912
|
+
"smoke:delegated-secrets": "bun scripts/live-delegated-secrets-smoke.ts",
|
|
31913
|
+
"check:skill-pack": "node scripts/check-skill-pack.mjs",
|
|
31914
|
+
"test:scoped-login": "bun test src/auth/scoped-login.test.ts",
|
|
31915
|
+
"test:packed": "node scripts/test-packed-cli.mjs"
|
|
31916
|
+
},
|
|
31917
|
+
dependencies: {
|
|
31918
|
+
"@tinycloud/share-sdk": "0.2.0",
|
|
31919
|
+
"@tinycloud/share-envelope": "0.2.0",
|
|
31920
|
+
"@tinycloud/node-sdk": "2.11.0",
|
|
31921
|
+
"@tinycloud/node-sdk-wasm": "1.7.6",
|
|
31922
|
+
"@tinycloud/operations": "0.3.2",
|
|
31923
|
+
chalk: "^5.3.0",
|
|
31924
|
+
commander: "^14.0.0",
|
|
31925
|
+
open: "^11.0.0",
|
|
31926
|
+
ora: "^9.3.0",
|
|
31927
|
+
siwe: "^3.0.0"
|
|
31928
|
+
},
|
|
31929
|
+
devDependencies: {
|
|
31930
|
+
"@types/node": "^20",
|
|
31931
|
+
tsup: "^8.0.0",
|
|
31932
|
+
typescript: "^5.9.3"
|
|
31933
|
+
}
|
|
31934
|
+
};
|
|
31935
|
+
|
|
31936
|
+
// src/commands/context.ts
|
|
31937
|
+
init_profiles();
|
|
31938
|
+
init_space();
|
|
31939
|
+
init_formatter();
|
|
31940
|
+
init_errors();
|
|
31941
|
+
function registerContextCommand(program) {
|
|
31942
|
+
program.command("context").description("Report selected identity, host, space and local session state as JSON (does not test access)").option("--space <name|uri>", "Resolve this space in the selected profile").action(async (options, cmd) => {
|
|
31943
|
+
try {
|
|
31944
|
+
const ctx = await ProfileManager.resolveContext(cmd.optsWithGlobals());
|
|
31945
|
+
const profile = await ProfileManager.getProfile(ctx.profile);
|
|
31946
|
+
const session = await ProfileManager.getSession(ctx.profile);
|
|
31947
|
+
const spaceId = await resolveSpaceUri(options.space, ctx.profile) ?? (typeof session?.spaceId === "string" ? session.spaceId : profile.spaceId ?? null);
|
|
31948
|
+
const expiryValues = [
|
|
31949
|
+
session?.expiresAt,
|
|
31950
|
+
session?.expiry,
|
|
31951
|
+
session?.expirationTime,
|
|
31952
|
+
typeof session?.siwe === "string" ? session.siwe.match(/^Expiration Time:\s*(.+)$/m)?.[1] : void 0
|
|
31953
|
+
];
|
|
31954
|
+
const expiry = expiryValues.find((value) => typeof value === "string" && Number.isFinite(Date.parse(value)));
|
|
31955
|
+
const expiresAt = typeof expiry === "string" ? new Date(expiry).toISOString() : null;
|
|
31956
|
+
outputJson({
|
|
31957
|
+
schemaVersion: 1,
|
|
31958
|
+
cliVersion: package_default.version,
|
|
31959
|
+
profile: ctx.profile,
|
|
31960
|
+
ownerDid: profile.ownerDid ?? null,
|
|
31961
|
+
sessionDid: profile.sessionDid ?? profile.did,
|
|
31962
|
+
host: ctx.host,
|
|
31963
|
+
spaceId,
|
|
31964
|
+
session: {
|
|
31965
|
+
state: session === null ? "missing" : expiresAt === null ? "unknown-expiry" : Date.parse(expiresAt) <= Date.now() ? "expired" : "present",
|
|
31966
|
+
expiresAt,
|
|
31967
|
+
evidence: "local-metadata"
|
|
31968
|
+
},
|
|
31969
|
+
access: "not-tested"
|
|
31970
|
+
});
|
|
31971
|
+
} catch (error) {
|
|
31972
|
+
handleError(error);
|
|
31973
|
+
}
|
|
31974
|
+
});
|
|
31975
|
+
}
|
|
31976
|
+
|
|
32657
31977
|
// src/commands/delegation.ts
|
|
32658
31978
|
init_profiles();
|
|
32659
31979
|
init_formatter();
|
|
@@ -33064,36 +32384,6 @@ ${rowCount} row${rowCount === 1 ? "" : "s"} returned`) + "\n");
|
|
|
33064
32384
|
});
|
|
33065
32385
|
}
|
|
33066
32386
|
|
|
33067
|
-
// src/commands/enable.ts
|
|
33068
|
-
init_profiles();
|
|
33069
|
-
init_errors();
|
|
33070
|
-
init_formatter();
|
|
33071
|
-
function registerEnableCommand(program) {
|
|
33072
|
-
const enable = program.command("enable").description("Enable a narrowly scoped TinyCloud service");
|
|
33073
|
-
enable.command("share").description("Approve Share publishing through OpenKey device authorization").action(async (_options, command) => {
|
|
33074
|
-
try {
|
|
33075
|
-
const context = await ProfileManager.resolveContext(command.optsWithGlobals());
|
|
33076
|
-
const result = await ensureShareDeviceAuthorization({
|
|
33077
|
-
profileName: context.profile,
|
|
33078
|
-
nodeOrigin: context.host,
|
|
33079
|
-
shareOrigin: "https://share.tinycloud.xyz",
|
|
33080
|
-
openkeyHost: process.env.TC_OPENKEY_HOST,
|
|
33081
|
-
allowReplaceLocal: true
|
|
33082
|
-
});
|
|
33083
|
-
const value = {
|
|
33084
|
-
enabled: true,
|
|
33085
|
-
service: "share",
|
|
33086
|
-
profile: context.profile,
|
|
33087
|
-
sessionDid: result.profile.sessionDid ?? result.profile.did,
|
|
33088
|
-
expiresAt: result.delegation.expiresAt ?? result.delegation.expirationTime ?? result.delegation.expiry
|
|
33089
|
-
};
|
|
33090
|
-
output(value, () => `Share enabled for profile ${context.profile}.`);
|
|
33091
|
-
} catch (error) {
|
|
33092
|
-
handleError(error);
|
|
33093
|
-
}
|
|
33094
|
-
});
|
|
33095
|
-
}
|
|
33096
|
-
|
|
33097
32387
|
// src/commands/init.ts
|
|
33098
32388
|
init_profiles();
|
|
33099
32389
|
init_formatter();
|
|
@@ -34829,7 +34119,7 @@ function receiveJson(result, path) {
|
|
|
34829
34119
|
// src/share/io.ts
|
|
34830
34120
|
import { constants } from "fs";
|
|
34831
34121
|
import { lstat, mkdir as mkdir3, mkdtemp, open as open3, readFile as readFile9, realpath, stat as stat2, link, rename as rename2, rm as rm2, unlink } from "fs/promises";
|
|
34832
|
-
import { randomBytes as
|
|
34122
|
+
import { randomBytes as randomBytes3 } from "crypto";
|
|
34833
34123
|
import { basename as basename2, join as join6, resolve as resolve2, sep } from "path";
|
|
34834
34124
|
var MAX_SHARE_STDIN_BYTES = 100 * 1024 * 1024;
|
|
34835
34125
|
var MAX_SHARE_URL_BYTES = 64 * 1024;
|
|
@@ -34908,7 +34198,7 @@ async function writeShareOutput(directory, filename, bytes, force) {
|
|
|
34908
34198
|
const stagingDirectory = await mkdtemp(join6(stableDirectory, ".tinycloud-share-stage-"));
|
|
34909
34199
|
const stagingInfo = await lstat(stagingDirectory);
|
|
34910
34200
|
if (!stagingInfo.isDirectory() || (stagingInfo.mode & 511) !== 448) throw new Error("OUTPUT_EXISTS");
|
|
34911
|
-
const stagingPath = join6(stagingDirectory, `.tinycloud-share-${
|
|
34201
|
+
const stagingPath = join6(stagingDirectory, `.tinycloud-share-${randomBytes3(16).toString("hex")}.tmp`);
|
|
34912
34202
|
let temporaryPath;
|
|
34913
34203
|
let handle;
|
|
34914
34204
|
try {
|
|
@@ -34961,11 +34251,11 @@ function parseShareTarget(value) {
|
|
|
34961
34251
|
if (value.includes("@")) return { kind: "email", address: value };
|
|
34962
34252
|
throw new CLIError("INVALID_ARGUMENT", "--to must be anyone, a did:, an email address, or domain:example.com", 2);
|
|
34963
34253
|
}
|
|
34964
|
-
function publishServices(
|
|
34254
|
+
function publishServices() {
|
|
34965
34255
|
return {
|
|
34966
34256
|
...shareServices.uploadBlob === void 0 ? {} : { uploadBlob: shareServices.uploadBlob },
|
|
34967
34257
|
...shareServices.authorizeUpload === void 0 ? {} : { authorizeUpload: shareServices.authorizeUpload },
|
|
34968
|
-
...shareServices.authorizeUpload === void 0
|
|
34258
|
+
...shareServices.authorizeUpload === void 0 ? {} : { authorizationOrigin: SHARE_ORIGIN },
|
|
34969
34259
|
...shareServices.credentials === void 0 ? {} : { credentials: shareServices.credentials },
|
|
34970
34260
|
...shareServices.fetchFn === void 0 ? {} : { fetchFn: shareServices.fetchFn }
|
|
34971
34261
|
};
|
|
@@ -35011,9 +34301,6 @@ function inputUrl(value, stdin) {
|
|
|
35011
34301
|
if (value === void 0 || value.length === 0) throw new CLIError("INVALID_ARGUMENT", "a share URL or - is required", 2);
|
|
35012
34302
|
return Promise.resolve(value);
|
|
35013
34303
|
}
|
|
35014
|
-
function jsonOutput(options, command) {
|
|
35015
|
-
return options.json === true || command.optsWithGlobals().json === true;
|
|
35016
|
-
}
|
|
35017
34304
|
function expires(value) {
|
|
35018
34305
|
try {
|
|
35019
34306
|
return new Date(Date.now() + parseDuration(value));
|
|
@@ -35064,9 +34351,8 @@ function assertAggregateInputLimit(inputs, maxBytes) {
|
|
|
35064
34351
|
}
|
|
35065
34352
|
function registerShareCommand(program) {
|
|
35066
34353
|
const share = program.command("share").description("Publish and consume TinyCloud Share links");
|
|
35067
|
-
share.command("publish <files...>").description("Publish one or more bounded files as a Share").option("--name <filename>", "Filename for stdin input").option("--to <target>", "Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Share lifetime", "7d").option("--max-bytes <bytes>", "Bound input bytes").option("--media-type <type>", "Media type for a single input").option("--action <actions...>", "Addressed permission: read, list, or edit").option("--prefix", "Publish multiple inputs beneath one addressed prefix").option("--binary", "Allow non-UTF-8 bearer content").option("--inline", "Embed the sealed envelope in the URL fragment").option("--compact", "Use a CID-addressed compact link (default)").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").action(async (files, options
|
|
34354
|
+
share.command("publish <files...>").description("Publish one or more bounded files as a Share").option("--name <filename>", "Filename for stdin input").option("--to <target>", "Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Share lifetime", "7d").option("--max-bytes <bytes>", "Bound input bytes").option("--media-type <type>", "Media type for a single input").option("--action <actions...>", "Addressed permission: read, list, or edit").option("--prefix", "Publish multiple inputs beneath one addressed prefix").option("--binary", "Allow non-UTF-8 bearer content").option("--inline", "Embed the sealed envelope in the URL fragment").option("--compact", "Use a CID-addressed compact link (default)").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").action(async (files, options) => {
|
|
35068
34355
|
try {
|
|
35069
|
-
const json = jsonOutput(options, command);
|
|
35070
34356
|
if (options.inline && options.compact) throw new CLIError("INVALID_ARGUMENT", "--inline and --compact are mutually exclusive", 2);
|
|
35071
34357
|
const maxBytes = byteLimit(options.maxBytes);
|
|
35072
34358
|
if (files.length === 0 || files.includes("-") && files.length > 1) throw new CLIError("INVALID_ARGUMENT", "stdin must be the only publish input", 2);
|
|
@@ -35095,10 +34381,10 @@ function registerShareCommand(program) {
|
|
|
35095
34381
|
allowInsecureRegistry: options.insecureRegistry === true,
|
|
35096
34382
|
notify: options.notify === true,
|
|
35097
34383
|
targetAdapter: shareServices.targetAdapter,
|
|
35098
|
-
...publishServices(
|
|
34384
|
+
...publishServices()
|
|
35099
34385
|
});
|
|
35100
34386
|
if ("state" in result) {
|
|
35101
|
-
if (json) {
|
|
34387
|
+
if (options.json) {
|
|
35102
34388
|
writeJson2({ protocol: "tinycloud-share", version: 1, authorization: authorizationRequiredJson(result) });
|
|
35103
34389
|
process.exitCode = 6;
|
|
35104
34390
|
return;
|
|
@@ -35111,27 +34397,25 @@ function registerShareCommand(program) {
|
|
|
35111
34397
|
const delivery = await notifyShare({ shareId: record.shareId, recipient: target.address, record, adapter: shareServices.delivery });
|
|
35112
34398
|
if (delivery.state === "partial-failure") process.exitCode = 9;
|
|
35113
34399
|
}
|
|
35114
|
-
if (json) writeJson2(redactPublishedShare(result));
|
|
34400
|
+
if (options.json) writeJson2(redactPublishedShare(result));
|
|
35115
34401
|
else publishHuman(result);
|
|
35116
34402
|
} catch (error) {
|
|
35117
34403
|
handleError(shareCliError(error));
|
|
35118
34404
|
}
|
|
35119
34405
|
});
|
|
35120
|
-
share.command("inspect [url]").description("Verify a share link and print safe metadata").option("--stdin", "Read the complete URL from stdin").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).action(async (url, options
|
|
34406
|
+
share.command("inspect [url]").description("Verify a share link and print safe metadata").option("--stdin", "Read the complete URL from stdin").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).action(async (url, options) => {
|
|
35121
34407
|
try {
|
|
35122
|
-
const json = jsonOutput(options, command);
|
|
35123
34408
|
const link2 = await inputUrl(url, options.stdin === true);
|
|
35124
34409
|
const result = await inspectShare(link2, { registryBaseUrl: options.registry, expectedOrigin: options.viewerOrigin, ...fetchServices() });
|
|
35125
|
-
if (json) writeJson2(result);
|
|
34410
|
+
if (options.json) writeJson2(result);
|
|
35126
34411
|
else inspectHuman(result);
|
|
35127
34412
|
} catch (error) {
|
|
35128
34413
|
handleError(shareCliError(error));
|
|
35129
34414
|
}
|
|
35130
34415
|
});
|
|
35131
|
-
share.command("receive [url]").description("Verify and receive a share link").option("--stdin", "Read the complete URL from stdin").option("--output <directory>", "Create the file in this directory").option("--stdout", "Write verified plaintext bytes to stdout").option("--force", "Allow replacing an existing non-symlink output").option("--max-bytes <bytes>", "Bound received content bytes").option("--resume-token <token>", "Resume a previously returned recipient authorization step").option("--authorization-proof-file <path>", "Read the JSON authorization proof from a file").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).option("--legacy", "Read a legacy tc1: link (read-only)").action(async (url, options
|
|
34416
|
+
share.command("receive [url]").description("Verify and receive a share link").option("--stdin", "Read the complete URL from stdin").option("--output <directory>", "Create the file in this directory").option("--stdout", "Write verified plaintext bytes to stdout").option("--force", "Allow replacing an existing non-symlink output").option("--max-bytes <bytes>", "Bound received content bytes").option("--resume-token <token>", "Resume a previously returned recipient authorization step").option("--authorization-proof-file <path>", "Read the JSON authorization proof from a file").option("--json", "Print versioned redacted JSON").option("--registry <url>", "Registry read endpoint", DEFAULT_READ_REGISTRY).option("--viewer-origin <origin>", "Require this canonical Share origin", SHARE_ORIGIN).option("--legacy", "Read a legacy tc1: link (read-only)").action(async (url, options) => {
|
|
35132
34417
|
try {
|
|
35133
|
-
|
|
35134
|
-
if (options.stdout && json) throw new CLIError("INVALID_ARGUMENT", "--stdout and --json are mutually exclusive", 2);
|
|
34418
|
+
if (options.stdout && options.json) throw new CLIError("INVALID_ARGUMENT", "--stdout and --json are mutually exclusive", 2);
|
|
35135
34419
|
const maxBytes = byteLimit(options.maxBytes);
|
|
35136
34420
|
const link2 = await inputUrl(url, options.stdin === true);
|
|
35137
34421
|
const proof = await authorizationProof(options);
|
|
@@ -35142,9 +34426,9 @@ function registerShareCommand(program) {
|
|
|
35142
34426
|
process.stdout.write(Buffer.from(bytes));
|
|
35143
34427
|
return;
|
|
35144
34428
|
}
|
|
35145
|
-
const
|
|
35146
|
-
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, path:
|
|
35147
|
-
else receiveHuman(
|
|
34429
|
+
const output2 = await writeShareOutput(options.output ?? ".", "share.md", bytes, options.force === true);
|
|
34430
|
+
if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, path: output2 });
|
|
34431
|
+
else receiveHuman(output2);
|
|
35148
34432
|
return;
|
|
35149
34433
|
}
|
|
35150
34434
|
const result = await receiveShare(link2, {
|
|
@@ -35157,7 +34441,7 @@ function registerShareCommand(program) {
|
|
|
35157
34441
|
...proof === void 0 ? {} : { authorizationProof: proof }
|
|
35158
34442
|
});
|
|
35159
34443
|
if ("state" in result) {
|
|
35160
|
-
if (json) {
|
|
34444
|
+
if (options.json) {
|
|
35161
34445
|
writeJson2({ protocol: "tinycloud-share", version: 1, authorization: authorizationRequiredJson(result) });
|
|
35162
34446
|
process.exitCode = 6;
|
|
35163
34447
|
return;
|
|
@@ -35168,16 +34452,15 @@ function registerShareCommand(program) {
|
|
|
35168
34452
|
process.stdout.write(Buffer.from(result.bytes));
|
|
35169
34453
|
return;
|
|
35170
34454
|
}
|
|
35171
|
-
const
|
|
35172
|
-
if (json) receiveJson(result,
|
|
35173
|
-
else receiveHuman(
|
|
34455
|
+
const output = await writeShareOutput(options.output ?? ".", result.metadata.display.filename ?? "share.md", result.bytes, options.force === true);
|
|
34456
|
+
if (options.json) receiveJson(result, output);
|
|
34457
|
+
else receiveHuman(output);
|
|
35174
34458
|
} catch (error) {
|
|
35175
34459
|
handleError(shareCliError(error));
|
|
35176
34460
|
}
|
|
35177
34461
|
});
|
|
35178
|
-
share.command("migrate [url]").description("Read a legacy tc1 link and re-mint a modern Share link").option("--stdin", "Read the complete legacy link from stdin").option("--name <filename>", "Filename for the migrated content", "migrated.md").option("--to <target>", "Modern Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Modern share lifetime", "7d").option("--max-bytes <bytes>", "Bound migrated content bytes").option("--inline", "Embed the sealed envelope in the URL fragment").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").option("--json", "Print versioned redacted JSON").action(async (url, options
|
|
34462
|
+
share.command("migrate [url]").description("Read a legacy tc1 link and re-mint a modern Share link").option("--stdin", "Read the complete legacy link from stdin").option("--name <filename>", "Filename for the migrated content", "migrated.md").option("--to <target>", "Modern Share target", "anyone").option("--notify", "Request idempotent email delivery for addressed targets").option("--expires <duration>", "Modern share lifetime", "7d").option("--max-bytes <bytes>", "Bound migrated content bytes").option("--inline", "Embed the sealed envelope in the URL fragment").option("--registry <url>", "Authenticated registry upload endpoint", DEFAULT_REGISTRY).option("--viewer-origin <origin>", "Canonical HTTPS viewer origin", SHARE_ORIGIN).option("--insecure-registry", "Allow an explicit localhost HTTP registry for hermetic tests").option("--json", "Print versioned redacted JSON").action(async (url, options) => {
|
|
35179
34463
|
try {
|
|
35180
|
-
const json = jsonOutput(options, command);
|
|
35181
34464
|
if (shareServices.legacyReader === void 0) throw new CLIError("UNSUPPORTED_LINK", "legacy migration requires an installed read-only tc1 adapter", 2);
|
|
35182
34465
|
const link2 = await inputUrl(url, options.stdin === true);
|
|
35183
34466
|
if (!isLegacyShareLink(link2)) throw new CLIError("UNSUPPORTED_LINK", "only tc1: links can be migrated", 2);
|
|
@@ -35199,7 +34482,7 @@ function registerShareCommand(program) {
|
|
|
35199
34482
|
allowInsecureRegistry: options.insecureRegistry === true,
|
|
35200
34483
|
notify: options.notify === true,
|
|
35201
34484
|
targetAdapter: shareServices.targetAdapter,
|
|
35202
|
-
...publishServices(
|
|
34485
|
+
...publishServices()
|
|
35203
34486
|
});
|
|
35204
34487
|
if ("state" in result) throw new CLIError(result.method === "openkey-device" ? "DEVICE_AUTH_REQUIRED" : "CLAIM_REQUIRED", "recipient authorization is required; continue through the configured authority adapter", 6);
|
|
35205
34488
|
const record = await rememberPublishedShare(result);
|
|
@@ -35213,44 +34496,41 @@ function registerShareCommand(program) {
|
|
|
35213
34496
|
return result;
|
|
35214
34497
|
}
|
|
35215
34498
|
});
|
|
35216
|
-
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, migrated: redactPublishedShare(migrated.migrated) });
|
|
34499
|
+
if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, legacy: true, migrated: redactPublishedShare(migrated.migrated) });
|
|
35217
34500
|
else publishHuman(migrated.migrated);
|
|
35218
34501
|
} catch (error) {
|
|
35219
34502
|
handleError(shareCliError(error));
|
|
35220
34503
|
}
|
|
35221
34504
|
});
|
|
35222
|
-
share.command("list").description("List encrypted sender history without complete bearer URLs").option("--json", "Print versioned redacted JSON").action(async (options
|
|
34505
|
+
share.command("list").description("List encrypted sender history without complete bearer URLs").option("--json", "Print versioned redacted JSON").action(async (options) => {
|
|
35223
34506
|
try {
|
|
35224
|
-
const json = jsonOutput(options, command);
|
|
35225
34507
|
if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
|
|
35226
34508
|
const result = await listShares(shareServices.records);
|
|
35227
|
-
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, shares: result });
|
|
34509
|
+
if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, shares: result });
|
|
35228
34510
|
else process.stdout.write(result.map((item) => `${item.shareId} ${item.target} ${item.expiresAt}`).join("\n") + (result.length ? "\n" : ""));
|
|
35229
34511
|
} catch (error) {
|
|
35230
34512
|
handleError(shareCliError(error));
|
|
35231
34513
|
}
|
|
35232
34514
|
});
|
|
35233
|
-
share.command("show <id>").description("Show one redacted sender-history record").option("--reveal-link", "Explicitly include the complete link").option("--json", "Print versioned redacted JSON").action(async (id, options
|
|
34515
|
+
share.command("show <id>").description("Show one redacted sender-history record").option("--reveal-link", "Explicitly include the complete link").option("--json", "Print versioned redacted JSON").action(async (id, options) => {
|
|
35234
34516
|
try {
|
|
35235
|
-
|
|
35236
|
-
if (options.revealLink && json) throw new CLIError("INVALID_ARGUMENT", "--reveal-link cannot be combined with --json", 2);
|
|
34517
|
+
if (options.revealLink && options.json) throw new CLIError("INVALID_ARGUMENT", "--reveal-link cannot be combined with --json", 2);
|
|
35237
34518
|
if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
|
|
35238
34519
|
const result = await showShare({ storage: shareServices.records, shareId: id, revealLink: options.revealLink === true, link: options.revealLink ? await shareServices.linkFor?.(id) : void 0 });
|
|
35239
|
-
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, share: result });
|
|
34520
|
+
if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, share: result });
|
|
35240
34521
|
else writeJson2(result);
|
|
35241
34522
|
} catch (error) {
|
|
35242
34523
|
handleError(shareCliError(error));
|
|
35243
34524
|
}
|
|
35244
34525
|
});
|
|
35245
|
-
share.command("notify <id>").description("Retry idempotent delivery without recreating the share").requiredOption("--to <address>", "Recipient email").option("--json", "Print versioned JSON").action(async (id, options
|
|
34526
|
+
share.command("notify <id>").description("Retry idempotent delivery without recreating the share").requiredOption("--to <address>", "Recipient email").option("--json", "Print versioned JSON").action(async (id, options) => {
|
|
35246
34527
|
try {
|
|
35247
|
-
const json = jsonOutput(options, command);
|
|
35248
34528
|
if (shareServices.delivery === void 0) throw new CLIError("AUTH_REQUIRED", "delivery authority is not configured", 3);
|
|
35249
34529
|
if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
|
|
35250
34530
|
const record = await shareServices.records.get(id);
|
|
35251
34531
|
if (record === void 0) throw new CLIError("NOT_FOUND", "share not found", 4);
|
|
35252
34532
|
const result = await notifyShare({ shareId: id, recipient: options.to, record, adapter: shareServices.delivery });
|
|
35253
|
-
if (json) writeJson2(result);
|
|
34533
|
+
if (options.json) writeJson2(result);
|
|
35254
34534
|
else process.stdout.write(`${result.state}
|
|
35255
34535
|
`);
|
|
35256
34536
|
if (result.state === "partial-failure") process.exitCode = 9;
|
|
@@ -35258,9 +34538,8 @@ function registerShareCommand(program) {
|
|
|
35258
34538
|
handleError(shareCliError(error));
|
|
35259
34539
|
}
|
|
35260
34540
|
});
|
|
35261
|
-
share.command("revoke <id>").description("Revoke addressed shares; report bearer retention honestly").option("--ancestor", "Revoke the owner delegation ancestry").option("--json", "Print versioned JSON").action(async (id, options
|
|
34541
|
+
share.command("revoke <id>").description("Revoke addressed shares; report bearer retention honestly").option("--ancestor", "Revoke the owner delegation ancestry").option("--json", "Print versioned JSON").action(async (id, options) => {
|
|
35262
34542
|
try {
|
|
35263
|
-
const json = jsonOutput(options, command);
|
|
35264
34543
|
if (shareServices.records === void 0) throw new CLIError("AUTH_REQUIRED", "sender history storage is not configured", 3);
|
|
35265
34544
|
const record = shareServices.getRecord ? await shareServices.getRecord(id) : await shareServices.records.get(id);
|
|
35266
34545
|
if (record === void 0) throw new CLIError("NOT_FOUND", "share not found", 4);
|
|
@@ -35268,7 +34547,7 @@ function registerShareCommand(program) {
|
|
|
35268
34547
|
if (result.state === "unsupported") {
|
|
35269
34548
|
throw new CLIError("UNSUPPORTED_TARGET", result.reason, 2);
|
|
35270
34549
|
}
|
|
35271
|
-
if (json) writeJson2({ protocol: "tinycloud-share", version: 1, result });
|
|
34550
|
+
if (options.json) writeJson2({ protocol: "tinycloud-share", version: 1, result });
|
|
35272
34551
|
else process.stdout.write(`${result.state}
|
|
35273
34552
|
`);
|
|
35274
34553
|
} catch (error) {
|
|
@@ -35282,7 +34561,7 @@ init_profiles();
|
|
|
35282
34561
|
init_formatter();
|
|
35283
34562
|
init_errors();
|
|
35284
34563
|
init_constants();
|
|
35285
|
-
import { randomBytes as
|
|
34564
|
+
import { randomBytes as randomBytes4 } from "crypto";
|
|
35286
34565
|
import { mkdir as mkdir4, writeFile as writeFile6 } from "fs/promises";
|
|
35287
34566
|
import { dirname as dirname3 } from "path";
|
|
35288
34567
|
init_host();
|
|
@@ -35365,7 +34644,7 @@ it directly with \`tc space host <name>\` (no request needed).
|
|
|
35365
34644
|
const artifact = {
|
|
35366
34645
|
kind: "tinycloud.host.request",
|
|
35367
34646
|
version: 1,
|
|
35368
|
-
requestId: `hostreq_${Date.now().toString(36)}_${
|
|
34647
|
+
requestId: `hostreq_${Date.now().toString(36)}_${randomBytes4(4).toString("hex")}`,
|
|
35369
34648
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
35370
34649
|
spaceName,
|
|
35371
34650
|
spaceId,
|
|
@@ -36446,8 +35725,8 @@ function registerVarsCommand(program) {
|
|
|
36446
35725
|
// src/command-registry.ts
|
|
36447
35726
|
function registerTinyCloudCommands(program) {
|
|
36448
35727
|
registerInitCommand(program);
|
|
35728
|
+
registerContextCommand(program);
|
|
36449
35729
|
registerAuthCommand(program);
|
|
36450
|
-
registerEnableCommand(program);
|
|
36451
35730
|
registerKvCommand(program);
|
|
36452
35731
|
registerSpaceCommand(program);
|
|
36453
35732
|
registerDelegationCommand(program);
|