@did-btcr2/method 0.24.1 → 0.25.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/dist/browser.js +697 -554
- package/dist/browser.mjs +697 -554
- package/dist/cjs/core/beacon/beacon.js.map +1 -1
- package/dist/cjs/core/beacon/cas-beacon.js +119 -7
- package/dist/cjs/core/beacon/cas-beacon.js.map +1 -1
- package/dist/cjs/core/beacon/factory.js +1 -1
- package/dist/cjs/core/beacon/factory.js.map +1 -1
- package/dist/cjs/core/beacon/{singleton.js → singleton-beacon.js} +18 -26
- package/dist/cjs/core/beacon/singleton-beacon.js.map +1 -0
- package/dist/cjs/core/beacon/smt-beacon.js +1 -1
- package/dist/cjs/core/beacon/smt-beacon.js.map +1 -1
- package/dist/{esm/core/resolve.js → cjs/core/resolver.js} +241 -93
- package/dist/cjs/core/resolver.js.map +1 -0
- package/dist/cjs/core/update.js +5 -5
- package/dist/cjs/core/update.js.map +1 -1
- package/dist/cjs/did-btcr2.js +34 -92
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +119 -7
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/factory.js +1 -1
- package/dist/esm/core/beacon/factory.js.map +1 -1
- package/dist/esm/core/beacon/{singleton.js → singleton-beacon.js} +18 -26
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -0
- package/dist/esm/core/beacon/smt-beacon.js +1 -1
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/{cjs/core/resolve.js → esm/core/resolver.js} +241 -93
- package/dist/esm/core/resolver.js.map +1 -0
- package/dist/esm/core/update.js +5 -5
- package/dist/esm/core/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +34 -92
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +9 -4
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +26 -7
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/{singleton.d.ts → singleton-beacon.d.ts} +7 -5
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -0
- package/dist/types/core/beacon/smt-beacon.d.ts +4 -3
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +5 -15
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolver.d.ts +167 -0
- package/dist/types/core/resolver.d.ts.map +1 -0
- package/dist/types/core/update.d.ts +3 -3
- package/dist/types/core/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +16 -16
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/core/beacon/beacon.ts +9 -5
- package/src/core/beacon/cas-beacon.ts +156 -10
- package/src/core/beacon/factory.ts +1 -1
- package/src/core/beacon/{singleton.ts → singleton-beacon.ts} +19 -35
- package/src/core/beacon/smt-beacon.ts +4 -3
- package/src/core/interfaces.ts +5 -16
- package/src/core/{resolve.ts → resolver.ts} +355 -130
- package/src/core/update.ts +7 -7
- package/src/did-btcr2.ts +37 -128
- package/src/index.ts +2 -2
- package/dist/cjs/core/beacon/singleton.js.map +0 -1
- package/dist/cjs/core/resolve.js.map +0 -1
- package/dist/esm/core/beacon/singleton.js.map +0 -1
- package/dist/esm/core/resolve.js.map +0 -1
- package/dist/types/core/beacon/singleton.d.ts.map +0 -1
- package/dist/types/core/resolve.d.ts +0 -93
- package/dist/types/core/resolve.d.ts.map +0 -1
package/dist/browser.mjs
CHANGED
|
@@ -1865,7 +1865,7 @@ var require_dist = __commonJS({
|
|
|
1865
1865
|
} else {
|
|
1866
1866
|
ENCODING_CONST = 734539939;
|
|
1867
1867
|
}
|
|
1868
|
-
function
|
|
1868
|
+
function encode44(prefix, words, LIMIT) {
|
|
1869
1869
|
LIMIT = LIMIT || 90;
|
|
1870
1870
|
if (prefix.length + 7 + words.length > LIMIT)
|
|
1871
1871
|
throw new TypeError("Exceeds length limit");
|
|
@@ -1934,7 +1934,7 @@ var require_dist = __commonJS({
|
|
|
1934
1934
|
if (typeof res === "object")
|
|
1935
1935
|
return res;
|
|
1936
1936
|
}
|
|
1937
|
-
function
|
|
1937
|
+
function decode48(str, LIMIT) {
|
|
1938
1938
|
const res = __decode(str, LIMIT);
|
|
1939
1939
|
if (typeof res === "object")
|
|
1940
1940
|
return res;
|
|
@@ -1942,8 +1942,8 @@ var require_dist = __commonJS({
|
|
|
1942
1942
|
}
|
|
1943
1943
|
return {
|
|
1944
1944
|
decodeUnsafe,
|
|
1945
|
-
decode:
|
|
1946
|
-
encode:
|
|
1945
|
+
decode: decode48,
|
|
1946
|
+
encode: encode44,
|
|
1947
1947
|
toWords,
|
|
1948
1948
|
fromWordsUnsafe,
|
|
1949
1949
|
fromWords
|
|
@@ -20065,7 +20065,7 @@ var require_utils2 = __commonJS({
|
|
|
20065
20065
|
return res;
|
|
20066
20066
|
}
|
|
20067
20067
|
utils2.toHex = toHex3;
|
|
20068
|
-
utils2.encode = function
|
|
20068
|
+
utils2.encode = function encode44(arr, enc) {
|
|
20069
20069
|
if (enc === "hex")
|
|
20070
20070
|
return toHex3(arr);
|
|
20071
20071
|
else
|
|
@@ -20439,7 +20439,7 @@ var require_base = __commonJS({
|
|
|
20439
20439
|
return [this.getY().isEven() ? 2 : 3].concat(x);
|
|
20440
20440
|
return [4].concat(x, this.getY().toArray("be", len));
|
|
20441
20441
|
};
|
|
20442
|
-
BasePoint.prototype.encode = function
|
|
20442
|
+
BasePoint.prototype.encode = function encode44(enc, compact) {
|
|
20443
20443
|
return utils2.encode(this._encode(compact), enc);
|
|
20444
20444
|
};
|
|
20445
20445
|
BasePoint.prototype.precompute = function precompute(power) {
|
|
@@ -25072,7 +25072,7 @@ var require_api = __commonJS({
|
|
|
25072
25072
|
this.decoders[enc] = this._createNamed(asn1.decoders[enc]);
|
|
25073
25073
|
return this.decoders[enc];
|
|
25074
25074
|
};
|
|
25075
|
-
Entity.prototype.decode = function
|
|
25075
|
+
Entity.prototype.decode = function decode48(data, enc, options2) {
|
|
25076
25076
|
return this._getDecoder(enc).decode(data, options2);
|
|
25077
25077
|
};
|
|
25078
25078
|
Entity.prototype._getEncoder = function _getEncoder(enc) {
|
|
@@ -25081,7 +25081,7 @@ var require_api = __commonJS({
|
|
|
25081
25081
|
this.encoders[enc] = this._createNamed(asn1.encoders[enc]);
|
|
25082
25082
|
return this.encoders[enc];
|
|
25083
25083
|
};
|
|
25084
|
-
Entity.prototype.encode = function
|
|
25084
|
+
Entity.prototype.encode = function encode44(data, enc, reporter) {
|
|
25085
25085
|
return this._getEncoder(enc).encode(data, reporter);
|
|
25086
25086
|
};
|
|
25087
25087
|
}
|
|
@@ -25545,7 +25545,7 @@ var require_node = __commonJS({
|
|
|
25545
25545
|
state.contains = item;
|
|
25546
25546
|
return this;
|
|
25547
25547
|
};
|
|
25548
|
-
Node.prototype._decode = function
|
|
25548
|
+
Node.prototype._decode = function decode48(input, options2) {
|
|
25549
25549
|
var state = this._baseState;
|
|
25550
25550
|
if (state.parent === null)
|
|
25551
25551
|
return input.wrapResult(state.children[0]._decode(input, options2));
|
|
@@ -25701,7 +25701,7 @@ var require_node = __commonJS({
|
|
|
25701
25701
|
Node.prototype._createEncoderBuffer = function createEncoderBuffer(data) {
|
|
25702
25702
|
return new EncoderBuffer(data, this.reporter);
|
|
25703
25703
|
};
|
|
25704
|
-
Node.prototype._encode = function
|
|
25704
|
+
Node.prototype._encode = function encode44(data, reporter, parent) {
|
|
25705
25705
|
var state = this._baseState;
|
|
25706
25706
|
if (state["default"] !== null && state["default"] === data)
|
|
25707
25707
|
return;
|
|
@@ -25712,7 +25712,7 @@ var require_node = __commonJS({
|
|
|
25712
25712
|
return;
|
|
25713
25713
|
return result;
|
|
25714
25714
|
};
|
|
25715
|
-
Node.prototype._encodeValue = function
|
|
25715
|
+
Node.prototype._encodeValue = function encode44(data, reporter, parent) {
|
|
25716
25716
|
var state = this._baseState;
|
|
25717
25717
|
if (state.parent === null)
|
|
25718
25718
|
return state.children[0]._encode(data, reporter || new Reporter());
|
|
@@ -25920,7 +25920,7 @@ var require_der2 = __commonJS({
|
|
|
25920
25920
|
this.tree._init(entity.body);
|
|
25921
25921
|
}
|
|
25922
25922
|
module.exports = DERDecoder;
|
|
25923
|
-
DERDecoder.prototype.decode = function
|
|
25923
|
+
DERDecoder.prototype.decode = function decode48(data, options2) {
|
|
25924
25924
|
if (!(data instanceof base5.DecoderBuffer))
|
|
25925
25925
|
data = new base5.DecoderBuffer(data, options2);
|
|
25926
25926
|
return this.tree._decode(data, options2);
|
|
@@ -26180,7 +26180,7 @@ var require_pem = __commonJS({
|
|
|
26180
26180
|
}
|
|
26181
26181
|
inherits(PEMDecoder, DERDecoder);
|
|
26182
26182
|
module.exports = PEMDecoder;
|
|
26183
|
-
PEMDecoder.prototype.decode = function
|
|
26183
|
+
PEMDecoder.prototype.decode = function decode48(data, options2) {
|
|
26184
26184
|
var lines = data.toString().split(/[\r\n]+/g);
|
|
26185
26185
|
var label = options2.label.toUpperCase();
|
|
26186
26186
|
var re = /^-----(BEGIN|END) ([^-]+)-----$/;
|
|
@@ -26240,7 +26240,7 @@ var require_der3 = __commonJS({
|
|
|
26240
26240
|
this.tree._init(entity.body);
|
|
26241
26241
|
}
|
|
26242
26242
|
module.exports = DEREncoder;
|
|
26243
|
-
DEREncoder.prototype.encode = function
|
|
26243
|
+
DEREncoder.prototype.encode = function encode44(data, reporter) {
|
|
26244
26244
|
return this.tree._encode(data, reporter).join();
|
|
26245
26245
|
};
|
|
26246
26246
|
function DERNode(parent) {
|
|
@@ -26467,7 +26467,7 @@ var require_pem2 = __commonJS({
|
|
|
26467
26467
|
}
|
|
26468
26468
|
inherits(PEMEncoder, DEREncoder);
|
|
26469
26469
|
module.exports = PEMEncoder;
|
|
26470
|
-
PEMEncoder.prototype.encode = function
|
|
26470
|
+
PEMEncoder.prototype.encode = function encode44(data, options2) {
|
|
26471
26471
|
var buf2 = DEREncoder.prototype.encode.call(this, data);
|
|
26472
26472
|
var p2 = buf2.toString("base64");
|
|
26473
26473
|
var out = ["-----BEGIN " + options2.label + "-----"];
|
|
@@ -36542,7 +36542,7 @@ var require_uri_all = __commonJS({
|
|
|
36542
36542
|
}
|
|
36543
36543
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
36544
36544
|
};
|
|
36545
|
-
var
|
|
36545
|
+
var decode48 = function decode49(input) {
|
|
36546
36546
|
var output6 = [];
|
|
36547
36547
|
var inputLength = input.length;
|
|
36548
36548
|
var i4 = 0;
|
|
@@ -36595,7 +36595,7 @@ var require_uri_all = __commonJS({
|
|
|
36595
36595
|
}
|
|
36596
36596
|
return String.fromCodePoint.apply(String, output6);
|
|
36597
36597
|
};
|
|
36598
|
-
var
|
|
36598
|
+
var encode44 = function encode45(input) {
|
|
36599
36599
|
var output6 = [];
|
|
36600
36600
|
input = ucs2decode(input);
|
|
36601
36601
|
var inputLength = input.length;
|
|
@@ -36716,12 +36716,12 @@ var require_uri_all = __commonJS({
|
|
|
36716
36716
|
};
|
|
36717
36717
|
var toUnicode = function toUnicode2(input) {
|
|
36718
36718
|
return mapDomain(input, function(string4) {
|
|
36719
|
-
return regexPunycode.test(string4) ?
|
|
36719
|
+
return regexPunycode.test(string4) ? decode48(string4.slice(4).toLowerCase()) : string4;
|
|
36720
36720
|
});
|
|
36721
36721
|
};
|
|
36722
36722
|
var toASCII = function toASCII2(input) {
|
|
36723
36723
|
return mapDomain(input, function(string4) {
|
|
36724
|
-
return regexNonASCII.test(string4) ? "xn--" +
|
|
36724
|
+
return regexNonASCII.test(string4) ? "xn--" + encode44(string4) : string4;
|
|
36725
36725
|
});
|
|
36726
36726
|
};
|
|
36727
36727
|
var punycode = {
|
|
@@ -36742,8 +36742,8 @@ var require_uri_all = __commonJS({
|
|
|
36742
36742
|
"decode": ucs2decode,
|
|
36743
36743
|
"encode": ucs2encode
|
|
36744
36744
|
},
|
|
36745
|
-
"decode":
|
|
36746
|
-
"encode":
|
|
36745
|
+
"decode": decode48,
|
|
36746
|
+
"encode": encode44,
|
|
36747
36747
|
"toASCII": toASCII,
|
|
36748
36748
|
"toUnicode": toUnicode
|
|
36749
36749
|
};
|
|
@@ -47367,9 +47367,9 @@ function anumArr(label, input) {
|
|
|
47367
47367
|
function chain(...args) {
|
|
47368
47368
|
const id = (a2) => a2;
|
|
47369
47369
|
const wrap2 = (a2, b) => (c2) => a2(b(c2));
|
|
47370
|
-
const
|
|
47371
|
-
const
|
|
47372
|
-
return { encode:
|
|
47370
|
+
const encode44 = args.map((x) => x.encode).reduceRight(wrap2, id);
|
|
47371
|
+
const decode48 = args.map((x) => x.decode).reduce(wrap2, id);
|
|
47372
|
+
return { encode: encode44, decode: decode48 };
|
|
47373
47373
|
}
|
|
47374
47374
|
// @__NO_SIDE_EFFECTS__
|
|
47375
47375
|
function alphabet(letters) {
|
|
@@ -47622,7 +47622,7 @@ function genBech32(encoding) {
|
|
|
47622
47622
|
const fromWords = _words.decode;
|
|
47623
47623
|
const toWords = _words.encode;
|
|
47624
47624
|
const fromWordsUnsafe = unsafeWrapper(fromWords);
|
|
47625
|
-
function
|
|
47625
|
+
function encode44(prefix, words, limit2 = 90) {
|
|
47626
47626
|
astr("bech32.encode prefix", prefix);
|
|
47627
47627
|
if (isBytes2(words))
|
|
47628
47628
|
words = Array.from(words);
|
|
@@ -47637,7 +47637,7 @@ function genBech32(encoding) {
|
|
|
47637
47637
|
const sum = bechChecksum(lowered, words, ENCODING_CONST);
|
|
47638
47638
|
return `${lowered}1${BECH_ALPHABET.encode(words)}${sum}`;
|
|
47639
47639
|
}
|
|
47640
|
-
function
|
|
47640
|
+
function decode48(str, limit2 = 90) {
|
|
47641
47641
|
astr("bech32.decode input", str);
|
|
47642
47642
|
const slen = str.length;
|
|
47643
47643
|
if (slen < 8 || limit2 !== false && slen > limit2)
|
|
@@ -47658,17 +47658,17 @@ function genBech32(encoding) {
|
|
|
47658
47658
|
throw new Error(`Invalid checksum in ${str}: expected "${sum}"`);
|
|
47659
47659
|
return { prefix, words };
|
|
47660
47660
|
}
|
|
47661
|
-
const decodeUnsafe = unsafeWrapper(
|
|
47661
|
+
const decodeUnsafe = unsafeWrapper(decode48);
|
|
47662
47662
|
function decodeToBytes(str) {
|
|
47663
|
-
const { prefix, words } =
|
|
47663
|
+
const { prefix, words } = decode48(str, false);
|
|
47664
47664
|
return { prefix, words, bytes: fromWords(words) };
|
|
47665
47665
|
}
|
|
47666
47666
|
function encodeFromBytes(prefix, bytes6) {
|
|
47667
|
-
return
|
|
47667
|
+
return encode44(prefix, toWords(bytes6));
|
|
47668
47668
|
}
|
|
47669
47669
|
return {
|
|
47670
|
-
encode:
|
|
47671
|
-
decode:
|
|
47670
|
+
encode: encode44,
|
|
47671
|
+
decode: decode48,
|
|
47672
47672
|
encodeFromBytes,
|
|
47673
47673
|
decodeToBytes,
|
|
47674
47674
|
decodeUnsafe,
|
|
@@ -50664,7 +50664,7 @@ function p2ms(a2, opts) {
|
|
|
50664
50664
|
const o2 = { network };
|
|
50665
50665
|
let chunks = [];
|
|
50666
50666
|
let decoded = false;
|
|
50667
|
-
function
|
|
50667
|
+
function decode48(output6) {
|
|
50668
50668
|
if (decoded) return;
|
|
50669
50669
|
decoded = true;
|
|
50670
50670
|
chunks = decompile(output6);
|
|
@@ -50687,7 +50687,7 @@ function p2ms(a2, opts) {
|
|
|
50687
50687
|
});
|
|
50688
50688
|
prop(o2, "m", () => {
|
|
50689
50689
|
if (!o2.output) return;
|
|
50690
|
-
|
|
50690
|
+
decode48(o2.output);
|
|
50691
50691
|
return o2.m;
|
|
50692
50692
|
});
|
|
50693
50693
|
prop(o2, "n", () => {
|
|
@@ -50696,7 +50696,7 @@ function p2ms(a2, opts) {
|
|
|
50696
50696
|
});
|
|
50697
50697
|
prop(o2, "pubkeys", () => {
|
|
50698
50698
|
if (!a2.output) return;
|
|
50699
|
-
|
|
50699
|
+
decode48(a2.output);
|
|
50700
50700
|
return o2.pubkeys;
|
|
50701
50701
|
});
|
|
50702
50702
|
prop(o2, "signatures", () => {
|
|
@@ -50717,7 +50717,7 @@ function p2ms(a2, opts) {
|
|
|
50717
50717
|
});
|
|
50718
50718
|
if (opts.validate) {
|
|
50719
50719
|
if (a2.output) {
|
|
50720
|
-
|
|
50720
|
+
decode48(a2.output);
|
|
50721
50721
|
parse(number(), chunks[0], { message: "Output is invalid" });
|
|
50722
50722
|
parse(number(), chunks[chunks.length - 2], {
|
|
50723
50723
|
message: "Output is invalid"
|
|
@@ -51478,7 +51478,7 @@ function base(ALPHABET2) {
|
|
|
51478
51478
|
const LEADER = ALPHABET2.charAt(0);
|
|
51479
51479
|
const FACTOR = Math.log(BASE) / Math.log(256);
|
|
51480
51480
|
const iFACTOR = Math.log(256) / Math.log(BASE);
|
|
51481
|
-
function
|
|
51481
|
+
function encode44(source) {
|
|
51482
51482
|
if (source instanceof Uint8Array) {
|
|
51483
51483
|
} else if (ArrayBuffer.isView(source)) {
|
|
51484
51484
|
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
@@ -51573,7 +51573,7 @@ function base(ALPHABET2) {
|
|
|
51573
51573
|
}
|
|
51574
51574
|
return vch;
|
|
51575
51575
|
}
|
|
51576
|
-
function
|
|
51576
|
+
function decode48(string4) {
|
|
51577
51577
|
const buffer2 = decodeUnsafe(string4);
|
|
51578
51578
|
if (buffer2) {
|
|
51579
51579
|
return buffer2;
|
|
@@ -51581,9 +51581,9 @@ function base(ALPHABET2) {
|
|
|
51581
51581
|
throw new Error("Non-base" + BASE + " character");
|
|
51582
51582
|
}
|
|
51583
51583
|
return {
|
|
51584
|
-
encode:
|
|
51584
|
+
encode: encode44,
|
|
51585
51585
|
decodeUnsafe,
|
|
51586
|
-
decode:
|
|
51586
|
+
decode: decode48
|
|
51587
51587
|
};
|
|
51588
51588
|
}
|
|
51589
51589
|
var esm_default = base;
|
|
@@ -51594,7 +51594,7 @@ var esm_default2 = esm_default(ALPHABET);
|
|
|
51594
51594
|
|
|
51595
51595
|
// ../../node_modules/.pnpm/bs58check@4.0.0/node_modules/bs58check/src/esm/base.js
|
|
51596
51596
|
function base_default(checksumFn) {
|
|
51597
|
-
function
|
|
51597
|
+
function encode44(payload) {
|
|
51598
51598
|
var payloadU8 = Uint8Array.from(payload);
|
|
51599
51599
|
var checksum2 = checksumFn(payloadU8);
|
|
51600
51600
|
var length7 = payloadU8.length + 4;
|
|
@@ -51617,7 +51617,7 @@ function base_default(checksumFn) {
|
|
|
51617
51617
|
return;
|
|
51618
51618
|
return decodeRaw(buffer2);
|
|
51619
51619
|
}
|
|
51620
|
-
function
|
|
51620
|
+
function decode48(str) {
|
|
51621
51621
|
var buffer2 = esm_default2.decode(str);
|
|
51622
51622
|
var payload = decodeRaw(buffer2);
|
|
51623
51623
|
if (payload == null)
|
|
@@ -51625,8 +51625,8 @@ function base_default(checksumFn) {
|
|
|
51625
51625
|
return payload;
|
|
51626
51626
|
}
|
|
51627
51627
|
return {
|
|
51628
|
-
encode:
|
|
51629
|
-
decode:
|
|
51628
|
+
encode: encode44,
|
|
51629
|
+
decode: decode48,
|
|
51630
51630
|
decodeUnsafe
|
|
51631
51631
|
};
|
|
51632
51632
|
}
|
|
@@ -54242,7 +54242,7 @@ init_shim();
|
|
|
54242
54242
|
var range2 = (n2) => [...Array(n2).keys()];
|
|
54243
54243
|
var isValidDERKey = (pubkey) => pubkey.length === 33 && [2, 3].includes(pubkey[0]) || pubkey.length === 65 && 4 === pubkey[0];
|
|
54244
54244
|
function makeConverter(TYPE_BYTE, isValidPubkey = isValidDERKey) {
|
|
54245
|
-
function
|
|
54245
|
+
function decode48(keyVal) {
|
|
54246
54246
|
if (keyVal.key[0] !== TYPE_BYTE) {
|
|
54247
54247
|
throw new Error(
|
|
54248
54248
|
"Decode Error: could not decode bip32Derivation with key 0x" + toHex(keyVal.key)
|
|
@@ -54272,7 +54272,7 @@ function makeConverter(TYPE_BYTE, isValidPubkey = isValidDERKey) {
|
|
|
54272
54272
|
}
|
|
54273
54273
|
return data;
|
|
54274
54274
|
}
|
|
54275
|
-
function
|
|
54275
|
+
function encode44(data) {
|
|
54276
54276
|
const head = Uint8Array.from([TYPE_BYTE]);
|
|
54277
54277
|
const key = concat([head, data.pubkey]);
|
|
54278
54278
|
const splitPath = data.path.split("/");
|
|
@@ -54302,8 +54302,8 @@ function makeConverter(TYPE_BYTE, isValidPubkey = isValidDERKey) {
|
|
|
54302
54302
|
return array2.filter((v) => compare(v.pubkey, item.pubkey) === 0).length === 0;
|
|
54303
54303
|
}
|
|
54304
54304
|
return {
|
|
54305
|
-
decode:
|
|
54306
|
-
encode:
|
|
54305
|
+
decode: decode48,
|
|
54306
|
+
encode: encode44,
|
|
54307
54307
|
check: check15,
|
|
54308
54308
|
expected: expected14,
|
|
54309
54309
|
canAddToArray: canAddToArray5
|
|
@@ -54331,7 +54331,7 @@ function makeChecker(pubkeyTypes) {
|
|
|
54331
54331
|
// ../../node_modules/.pnpm/bip174@3.0.0-rc.1/node_modules/bip174/src/esm/lib/converter/shared/redeemScript.js
|
|
54332
54332
|
init_shim();
|
|
54333
54333
|
function makeConverter2(TYPE_BYTE) {
|
|
54334
|
-
function
|
|
54334
|
+
function decode48(keyVal) {
|
|
54335
54335
|
if (keyVal.key[0] !== TYPE_BYTE) {
|
|
54336
54336
|
throw new Error(
|
|
54337
54337
|
"Decode Error: could not decode redeemScript with key 0x" + toHex(keyVal.key)
|
|
@@ -54339,7 +54339,7 @@ function makeConverter2(TYPE_BYTE) {
|
|
|
54339
54339
|
}
|
|
54340
54340
|
return keyVal.value;
|
|
54341
54341
|
}
|
|
54342
|
-
function
|
|
54342
|
+
function encode44(data) {
|
|
54343
54343
|
const key = Uint8Array.from([TYPE_BYTE]);
|
|
54344
54344
|
return {
|
|
54345
54345
|
key,
|
|
@@ -54354,8 +54354,8 @@ function makeConverter2(TYPE_BYTE) {
|
|
|
54354
54354
|
return !!currentData && !!newData && currentData.redeemScript === void 0;
|
|
54355
54355
|
}
|
|
54356
54356
|
return {
|
|
54357
|
-
decode:
|
|
54358
|
-
encode:
|
|
54357
|
+
decode: decode48,
|
|
54358
|
+
encode: encode44,
|
|
54359
54359
|
check: check15,
|
|
54360
54360
|
expected: expected14,
|
|
54361
54361
|
canAdd: canAdd10
|
|
@@ -54367,7 +54367,7 @@ init_shim();
|
|
|
54367
54367
|
var isValidBIP340Key = (pubkey) => pubkey.length === 32;
|
|
54368
54368
|
function makeConverter3(TYPE_BYTE) {
|
|
54369
54369
|
const parent = makeConverter(TYPE_BYTE, isValidBIP340Key);
|
|
54370
|
-
function
|
|
54370
|
+
function decode48(keyVal) {
|
|
54371
54371
|
const { numberValue: nHashes, bytes: nHashesLen } = decode5(
|
|
54372
54372
|
keyVal.value
|
|
54373
54373
|
);
|
|
@@ -54381,7 +54381,7 @@ function makeConverter3(TYPE_BYTE) {
|
|
|
54381
54381
|
}
|
|
54382
54382
|
return { ...base5, leafHashes };
|
|
54383
54383
|
}
|
|
54384
|
-
function
|
|
54384
|
+
function encode44(data) {
|
|
54385
54385
|
const base5 = parent.encode(data);
|
|
54386
54386
|
const nHashesLen = encodingLength2(data.leafHashes.length);
|
|
54387
54387
|
const nHashesBuf = new Uint8Array(nHashesLen);
|
|
@@ -54396,8 +54396,8 @@ function makeConverter3(TYPE_BYTE) {
|
|
|
54396
54396
|
) && parent.check(data);
|
|
54397
54397
|
}
|
|
54398
54398
|
return {
|
|
54399
|
-
decode:
|
|
54400
|
-
encode:
|
|
54399
|
+
decode: decode48,
|
|
54400
|
+
encode: encode44,
|
|
54401
54401
|
check: check15,
|
|
54402
54402
|
expected: expected14,
|
|
54403
54403
|
canAddToArray: parent.canAddToArray
|
|
@@ -54407,7 +54407,7 @@ function makeConverter3(TYPE_BYTE) {
|
|
|
54407
54407
|
// ../../node_modules/.pnpm/bip174@3.0.0-rc.1/node_modules/bip174/src/esm/lib/converter/shared/tapInternalKey.js
|
|
54408
54408
|
init_shim();
|
|
54409
54409
|
function makeConverter4(TYPE_BYTE) {
|
|
54410
|
-
function
|
|
54410
|
+
function decode48(keyVal) {
|
|
54411
54411
|
if (keyVal.key[0] !== TYPE_BYTE || keyVal.key.length !== 1) {
|
|
54412
54412
|
throw new Error(
|
|
54413
54413
|
"Decode Error: could not decode tapInternalKey with key 0x" + toHex(keyVal.key)
|
|
@@ -54420,7 +54420,7 @@ function makeConverter4(TYPE_BYTE) {
|
|
|
54420
54420
|
}
|
|
54421
54421
|
return keyVal.value;
|
|
54422
54422
|
}
|
|
54423
|
-
function
|
|
54423
|
+
function encode44(value3) {
|
|
54424
54424
|
const key = Uint8Array.from([TYPE_BYTE]);
|
|
54425
54425
|
return { key, value: value3 };
|
|
54426
54426
|
}
|
|
@@ -54432,8 +54432,8 @@ function makeConverter4(TYPE_BYTE) {
|
|
|
54432
54432
|
return !!currentData && !!newData && currentData.tapInternalKey === void 0;
|
|
54433
54433
|
}
|
|
54434
54434
|
return {
|
|
54435
|
-
decode:
|
|
54436
|
-
encode:
|
|
54435
|
+
decode: decode48,
|
|
54436
|
+
encode: encode44,
|
|
54437
54437
|
check: check15,
|
|
54438
54438
|
expected: expected14,
|
|
54439
54439
|
canAdd: canAdd10
|
|
@@ -54443,7 +54443,7 @@ function makeConverter4(TYPE_BYTE) {
|
|
|
54443
54443
|
// ../../node_modules/.pnpm/bip174@3.0.0-rc.1/node_modules/bip174/src/esm/lib/converter/shared/witnessScript.js
|
|
54444
54444
|
init_shim();
|
|
54445
54445
|
function makeConverter5(TYPE_BYTE) {
|
|
54446
|
-
function
|
|
54446
|
+
function decode48(keyVal) {
|
|
54447
54447
|
if (keyVal.key[0] !== TYPE_BYTE) {
|
|
54448
54448
|
throw new Error(
|
|
54449
54449
|
"Decode Error: could not decode witnessScript with key 0x" + toHex(keyVal.key)
|
|
@@ -54451,7 +54451,7 @@ function makeConverter5(TYPE_BYTE) {
|
|
|
54451
54451
|
}
|
|
54452
54452
|
return keyVal.value;
|
|
54453
54453
|
}
|
|
54454
|
-
function
|
|
54454
|
+
function encode44(data) {
|
|
54455
54455
|
const key = Uint8Array.from([TYPE_BYTE]);
|
|
54456
54456
|
return {
|
|
54457
54457
|
key,
|
|
@@ -54466,8 +54466,8 @@ function makeConverter5(TYPE_BYTE) {
|
|
|
54466
54466
|
return !!currentData && !!newData && currentData.witnessScript === void 0;
|
|
54467
54467
|
}
|
|
54468
54468
|
return {
|
|
54469
|
-
decode:
|
|
54470
|
-
encode:
|
|
54469
|
+
decode: decode48,
|
|
54470
|
+
encode: encode44,
|
|
54471
54471
|
check: check15,
|
|
54472
54472
|
expected: expected14,
|
|
54473
54473
|
canAdd: canAdd10
|
|
@@ -57244,7 +57244,7 @@ function canonicalize2(object2, algorithm = "jcs") {
|
|
|
57244
57244
|
function hash(canonicalized) {
|
|
57245
57245
|
return sha256(canonicalized);
|
|
57246
57246
|
}
|
|
57247
|
-
function
|
|
57247
|
+
function encode20(hashBytes, encoding = "base64url") {
|
|
57248
57248
|
const normalized = normalizeEncoding(encoding);
|
|
57249
57249
|
switch (normalized) {
|
|
57250
57250
|
case "hex":
|
|
@@ -57255,10 +57255,21 @@ function encodeHash(hashBytes, encoding = "hex") {
|
|
|
57255
57255
|
return base64urlnopad.encode(hashBytes);
|
|
57256
57256
|
}
|
|
57257
57257
|
}
|
|
57258
|
+
function decode19(encoded, encoding = "base64url") {
|
|
57259
|
+
const normalized = normalizeEncoding(encoding);
|
|
57260
|
+
switch (normalized) {
|
|
57261
|
+
case "hex":
|
|
57262
|
+
return hex.decode(encoded);
|
|
57263
|
+
case "base58":
|
|
57264
|
+
return base58.decode(encoded);
|
|
57265
|
+
case "base64url":
|
|
57266
|
+
return base64urlnopad.decode(encoded);
|
|
57267
|
+
}
|
|
57268
|
+
}
|
|
57258
57269
|
function canonicalHash(object2, options2) {
|
|
57259
57270
|
const algorithm = normalizeAlgorithm(options2?.algorithm ?? "jcs");
|
|
57260
|
-
const encoding = normalizeEncoding(options2?.encoding ?? "
|
|
57261
|
-
return
|
|
57271
|
+
const encoding = normalizeEncoding(options2?.encoding ?? "base64url");
|
|
57272
|
+
return encode20(hash(canonicalize2(object2, algorithm)), encoding);
|
|
57262
57273
|
}
|
|
57263
57274
|
|
|
57264
57275
|
// ../common/dist/esm/json-patch.js
|
|
@@ -61616,9 +61627,9 @@ function anumArr2(label, input) {
|
|
|
61616
61627
|
function chain2(...args) {
|
|
61617
61628
|
const id = (a2) => a2;
|
|
61618
61629
|
const wrap2 = (a2, b) => (c2) => a2(b(c2));
|
|
61619
|
-
const
|
|
61620
|
-
const
|
|
61621
|
-
return { encode:
|
|
61630
|
+
const encode44 = args.map((x) => x.encode).reduceRight(wrap2, id);
|
|
61631
|
+
const decode48 = args.map((x) => x.decode).reduce(wrap2, id);
|
|
61632
|
+
return { encode: encode44, decode: decode48 };
|
|
61622
61633
|
}
|
|
61623
61634
|
// @__NO_SIDE_EFFECTS__
|
|
61624
61635
|
function alphabet2(letters) {
|
|
@@ -65086,9 +65097,9 @@ function assertNumber(n2) {
|
|
|
65086
65097
|
}
|
|
65087
65098
|
function chain3(...args) {
|
|
65088
65099
|
const wrap2 = (a2, b) => (c2) => a2(b(c2));
|
|
65089
|
-
const
|
|
65090
|
-
const
|
|
65091
|
-
return { encode:
|
|
65100
|
+
const encode44 = Array.from(args).reverse().reduce((acc, i4) => acc ? wrap2(acc, i4.encode) : i4.encode, void 0);
|
|
65101
|
+
const decode48 = args.reduce((acc, i4) => acc ? wrap2(acc, i4.decode) : i4.decode, void 0);
|
|
65102
|
+
return { encode: encode44, decode: decode48 };
|
|
65092
65103
|
}
|
|
65093
65104
|
function alphabet3(alphabet6) {
|
|
65094
65105
|
return {
|
|
@@ -65369,7 +65380,7 @@ function genBech322(encoding) {
|
|
|
65369
65380
|
const fromWords = _words.decode;
|
|
65370
65381
|
const toWords = _words.encode;
|
|
65371
65382
|
const fromWordsUnsafe = unsafeWrapper2(fromWords);
|
|
65372
|
-
function
|
|
65383
|
+
function encode44(prefix, words, limit2 = 90) {
|
|
65373
65384
|
if (typeof prefix !== "string")
|
|
65374
65385
|
throw new Error(`bech32.encode prefix should be string, not ${typeof prefix}`);
|
|
65375
65386
|
if (!Array.isArray(words) || words.length && typeof words[0] !== "number")
|
|
@@ -65380,7 +65391,7 @@ function genBech322(encoding) {
|
|
|
65380
65391
|
prefix = prefix.toLowerCase();
|
|
65381
65392
|
return `${prefix}1${BECH_ALPHABET2.encode(words)}${bechChecksum2(prefix, words, ENCODING_CONST)}`;
|
|
65382
65393
|
}
|
|
65383
|
-
function
|
|
65394
|
+
function decode48(str, limit2 = 90) {
|
|
65384
65395
|
if (typeof str !== "string")
|
|
65385
65396
|
throw new Error(`bech32.decode input should be string, not ${typeof str}`);
|
|
65386
65397
|
if (str.length < 8 || limit2 !== false && str.length > limit2)
|
|
@@ -65402,12 +65413,12 @@ function genBech322(encoding) {
|
|
|
65402
65413
|
throw new Error(`Invalid checksum in ${str}: expected "${sum}"`);
|
|
65403
65414
|
return { prefix, words };
|
|
65404
65415
|
}
|
|
65405
|
-
const decodeUnsafe = unsafeWrapper2(
|
|
65416
|
+
const decodeUnsafe = unsafeWrapper2(decode48);
|
|
65406
65417
|
function decodeToBytes(str) {
|
|
65407
|
-
const { prefix, words } =
|
|
65418
|
+
const { prefix, words } = decode48(str, false);
|
|
65408
65419
|
return { prefix, words, bytes: fromWords(words) };
|
|
65409
65420
|
}
|
|
65410
|
-
return { encode:
|
|
65421
|
+
return { encode: encode44, decode: decode48, decodeToBytes, decodeUnsafe, fromWords, fromWordsUnsafe, toWords };
|
|
65411
65422
|
}
|
|
65412
65423
|
var bech324 = genBech322("bech32");
|
|
65413
65424
|
var bech32m4 = genBech322("bech32m");
|
|
@@ -67441,7 +67452,7 @@ __export2(nip19_exports, {
|
|
|
67441
67452
|
BECH32_REGEX: () => BECH32_REGEX,
|
|
67442
67453
|
Bech32MaxSize: () => Bech32MaxSize,
|
|
67443
67454
|
NostrTypeGuard: () => NostrTypeGuard,
|
|
67444
|
-
decode: () =>
|
|
67455
|
+
decode: () => decode20,
|
|
67445
67456
|
decodeNostrURI: () => decodeNostrURI,
|
|
67446
67457
|
encodeBytes: () => encodeBytes,
|
|
67447
67458
|
naddrEncode: () => naddrEncode,
|
|
@@ -67474,12 +67485,12 @@ function decodeNostrURI(nip19code) {
|
|
|
67474
67485
|
try {
|
|
67475
67486
|
if (nip19code.startsWith("nostr:"))
|
|
67476
67487
|
nip19code = nip19code.substring(6);
|
|
67477
|
-
return
|
|
67488
|
+
return decode20(nip19code);
|
|
67478
67489
|
} catch (_err) {
|
|
67479
67490
|
return { type: "invalid", data: null };
|
|
67480
67491
|
}
|
|
67481
67492
|
}
|
|
67482
|
-
function
|
|
67493
|
+
function decode20(code8) {
|
|
67483
67494
|
let { prefix, words } = bech324.decode(code8, Bech32MaxSize);
|
|
67484
67495
|
let data = new Uint8Array(bech324.fromWords(words));
|
|
67485
67496
|
switch (prefix) {
|
|
@@ -68183,7 +68194,7 @@ function parse22(uri) {
|
|
|
68183
68194
|
return {
|
|
68184
68195
|
uri: match[0],
|
|
68185
68196
|
value: match[1],
|
|
68186
|
-
decoded:
|
|
68197
|
+
decoded: decode20(match[1])
|
|
68187
68198
|
};
|
|
68188
68199
|
}
|
|
68189
68200
|
var nip25_exports = {};
|
|
@@ -68248,7 +68259,7 @@ function* parse3(content) {
|
|
|
68248
68259
|
const end = m2 ? u + 60 + m2.index : max;
|
|
68249
68260
|
try {
|
|
68250
68261
|
let pointer;
|
|
68251
|
-
let { data, type } =
|
|
68262
|
+
let { data, type } = decode20(content.substring(u + 1, end));
|
|
68252
68263
|
switch (type) {
|
|
68253
68264
|
case "npub":
|
|
68254
68265
|
pointer = { pubkey: data };
|
|
@@ -70987,31 +70998,108 @@ var CASBeacon = class extends Beacon {
|
|
|
70987
70998
|
}
|
|
70988
70999
|
/**
|
|
70989
71000
|
* Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-cas-beacon | 7.2.e.1 Process CAS Beacon}.
|
|
71001
|
+
*
|
|
71002
|
+
* For each signal, the signalBytes contain the hex-encoded hash of a CAS Announcement.
|
|
71003
|
+
* The CAS Announcement maps DIDs to their base64url-encoded update hashes.
|
|
71004
|
+
* This method looks up the CAS Announcement from the sidecar, extracts the update
|
|
71005
|
+
* hash for the DID being resolved, and retrieves the corresponding signed update.
|
|
71006
|
+
*
|
|
70990
71007
|
* @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
|
|
70991
71008
|
* @param {SidecarData} sidecar The sidecar data associated with the CAS Beacon.
|
|
70992
|
-
* @returns {
|
|
70993
|
-
* @throws {CASBeaconError} if
|
|
71009
|
+
* @returns {BeaconProcessResult} Successfully resolved updates and any data needs.
|
|
71010
|
+
* @throws {CASBeaconError} if hash verification fails (validation errors only).
|
|
70994
71011
|
*/
|
|
70995
71012
|
processSignals(signals, sidecar) {
|
|
70996
|
-
|
|
71013
|
+
const updates = new Array();
|
|
71014
|
+
const needs = new Array();
|
|
71015
|
+
const did = this.service.id.split("#")[0];
|
|
71016
|
+
for (const signal of signals) {
|
|
71017
|
+
const announcementHash = encode20(decode19(signal.signalBytes, "hex"));
|
|
71018
|
+
const casAnnouncement = sidecar.casMap.get(announcementHash);
|
|
71019
|
+
if (!casAnnouncement) {
|
|
71020
|
+
needs.push({
|
|
71021
|
+
kind: "NeedCASAnnouncement",
|
|
71022
|
+
announcementHash,
|
|
71023
|
+
beaconServiceId: this.service.id
|
|
71024
|
+
});
|
|
71025
|
+
continue;
|
|
71026
|
+
}
|
|
71027
|
+
const updateHash = casAnnouncement[did];
|
|
71028
|
+
if (!updateHash) {
|
|
71029
|
+
continue;
|
|
71030
|
+
}
|
|
71031
|
+
const signedUpdate = sidecar.updateMap.get(updateHash);
|
|
71032
|
+
if (!signedUpdate) {
|
|
71033
|
+
needs.push({
|
|
71034
|
+
kind: "NeedSignedUpdate",
|
|
71035
|
+
updateHash,
|
|
71036
|
+
beaconServiceId: this.service.id
|
|
71037
|
+
});
|
|
71038
|
+
continue;
|
|
71039
|
+
}
|
|
71040
|
+
updates.push([signedUpdate, signal.blockMetadata]);
|
|
71041
|
+
}
|
|
71042
|
+
return { updates, needs };
|
|
70997
71043
|
}
|
|
70998
71044
|
/**
|
|
70999
|
-
*
|
|
71045
|
+
* Broadcasts a CAS Beacon signal to the Bitcoin network.
|
|
71046
|
+
*
|
|
71047
|
+
* Creates a CAS Announcement mapping the DID to the update hash, then broadcasts
|
|
71048
|
+
* the hash of the announcement via OP_RETURN. The CAS Announcement is distributed
|
|
71049
|
+
* to resolvers via sidecar data.
|
|
71050
|
+
*
|
|
71000
71051
|
* @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
|
|
71001
71052
|
* @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
|
|
71002
71053
|
* @param {BitcoinConnection} bitcoin The Bitcoin network connection.
|
|
71003
|
-
* @
|
|
71004
|
-
* @throws {CASBeaconError} if
|
|
71054
|
+
* @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
|
|
71055
|
+
* @throws {CASBeaconError} if the bitcoin address is invalid or unfunded.
|
|
71005
71056
|
*/
|
|
71006
71057
|
async broadcastSignal(signedUpdate, secretKey, bitcoin2) {
|
|
71007
|
-
|
|
71058
|
+
const did = this.service.id.split("#")[0];
|
|
71059
|
+
const updateHash = canonicalHash(signedUpdate);
|
|
71060
|
+
const casAnnouncement = { [did]: updateHash };
|
|
71061
|
+
const announcementHash = hash(canonicalize2(casAnnouncement));
|
|
71062
|
+
const bitcoinAddress = this.service.serviceEndpoint.replace("bitcoin:", "");
|
|
71063
|
+
const utxos = await bitcoin2.rest.address.getUtxos(bitcoinAddress);
|
|
71064
|
+
if (!utxos.length) {
|
|
71065
|
+
throw new CASBeaconError(
|
|
71066
|
+
"No UTXOs found, please fund address!",
|
|
71067
|
+
"UNFUNDED_BEACON_ADDRESS",
|
|
71068
|
+
{ bitcoinAddress }
|
|
71069
|
+
);
|
|
71070
|
+
}
|
|
71071
|
+
const utxo = utxos.sort(
|
|
71072
|
+
(a2, b) => b.status.block_height - a2.status.block_height
|
|
71073
|
+
).shift();
|
|
71074
|
+
if (!utxo) {
|
|
71075
|
+
throw new CASBeaconError(
|
|
71076
|
+
"Beacon bitcoin address unfunded or utxos unconfirmed.",
|
|
71077
|
+
"UNFUNDED_BEACON_ADDRESS",
|
|
71078
|
+
{ bitcoinAddress }
|
|
71079
|
+
);
|
|
71080
|
+
}
|
|
71081
|
+
const prevTx = await bitcoin2.rest.transaction.getHex(utxo.txid);
|
|
71082
|
+
const spendTx = new Psbt2({ network: bitcoin2.data }).addInput({
|
|
71083
|
+
hash: utxo.txid,
|
|
71084
|
+
index: utxo.vout,
|
|
71085
|
+
nonWitnessUtxo: import_buffer.Buffer.from(prevTx, "hex")
|
|
71086
|
+
}).addOutput({ address: bitcoinAddress, value: BigInt(utxo.value) - BigInt(500) }).addOutput({ script: script_exports.compile([OPS.OP_RETURN, announcementHash]), value: 0n });
|
|
71087
|
+
const keyPair = SchnorrKeyPair.fromSecret(secretKey);
|
|
71088
|
+
const signer = {
|
|
71089
|
+
publicKey: keyPair.publicKey.compressed,
|
|
71090
|
+
sign: (hash5) => keyPair.secretKey.sign(hash5, { scheme: "ecdsa" })
|
|
71091
|
+
};
|
|
71092
|
+
const signedTx = spendTx.signInput(0, signer).finalizeAllInputs().extractTransaction().toHex();
|
|
71093
|
+
const txid = await bitcoin2.rest.transaction.send(signedTx);
|
|
71094
|
+
console.info(`CAS Beacon Signal Broadcasted with txid: ${txid}`);
|
|
71095
|
+
return signedUpdate;
|
|
71008
71096
|
}
|
|
71009
71097
|
};
|
|
71010
71098
|
|
|
71011
71099
|
// src/core/beacon/factory.ts
|
|
71012
71100
|
init_shim();
|
|
71013
71101
|
|
|
71014
|
-
// src/core/beacon/singleton.ts
|
|
71102
|
+
// src/core/beacon/singleton-beacon.ts
|
|
71015
71103
|
init_shim();
|
|
71016
71104
|
var SingletonBeacon = class extends Beacon {
|
|
71017
71105
|
/**
|
|
@@ -71023,33 +71111,27 @@ var SingletonBeacon = class extends Beacon {
|
|
|
71023
71111
|
}
|
|
71024
71112
|
/**
|
|
71025
71113
|
* Processes an array of Beacon Signals associated with a Singleton Beacon Service.
|
|
71026
|
-
* @
|
|
71027
|
-
* @
|
|
71114
|
+
* @param {Array<BeaconSignal>} signals The beacon signals discovered on-chain.
|
|
71115
|
+
* @param {SidecarData} sidecar The processed sidecar data.
|
|
71116
|
+
* @returns {BeaconProcessResult} Successfully resolved updates and any data needs.
|
|
71028
71117
|
*/
|
|
71029
|
-
|
|
71118
|
+
processSignals(signals, sidecar) {
|
|
71030
71119
|
const updates = new Array();
|
|
71120
|
+
const needs = new Array();
|
|
71031
71121
|
for (const signal of signals) {
|
|
71032
|
-
const updateHash = signal.signalBytes;
|
|
71122
|
+
const updateHash = encode20(decode19(signal.signalBytes, "hex"));
|
|
71033
71123
|
const signedUpdate = sidecar.updateMap.get(updateHash);
|
|
71034
71124
|
if (!signedUpdate) {
|
|
71035
|
-
|
|
71036
|
-
|
|
71037
|
-
|
|
71038
|
-
|
|
71039
|
-
);
|
|
71040
|
-
|
|
71041
|
-
const encodedUpdate = canonicalHash(signedUpdate, { encoding: "base64url" });
|
|
71042
|
-
const signalBytes = base64urlnopad.encode(import_buffer.Buffer.from(updateHash, "hex"));
|
|
71043
|
-
if (encodedUpdate !== signalBytes) {
|
|
71044
|
-
throw new SingletonBeaconError(
|
|
71045
|
-
`Hash mismatch: sidecar update ${encodedUpdate} !== signal bytes ${signalBytes}.`,
|
|
71046
|
-
INVALID_SIDECAR_DATA,
|
|
71047
|
-
{ encodedUpdate, signalBytes }
|
|
71048
|
-
);
|
|
71125
|
+
needs.push({
|
|
71126
|
+
kind: "NeedSignedUpdate",
|
|
71127
|
+
updateHash,
|
|
71128
|
+
beaconServiceId: this.service.id
|
|
71129
|
+
});
|
|
71130
|
+
continue;
|
|
71049
71131
|
}
|
|
71050
71132
|
updates.push([signedUpdate, signal.blockMetadata]);
|
|
71051
71133
|
}
|
|
71052
|
-
return updates;
|
|
71134
|
+
return { updates, needs };
|
|
71053
71135
|
}
|
|
71054
71136
|
/**
|
|
71055
71137
|
* Broadcasts a SingletonBeacon signal to the Bitcoin network.
|
|
@@ -71112,7 +71194,7 @@ var SMTBeacon = class extends Beacon {
|
|
|
71112
71194
|
* Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-smt-beacon | 7.2.e.1 Process SMT Beacon}.
|
|
71113
71195
|
* @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
|
|
71114
71196
|
* @param {SidecarData} sidecar The sidecar data associated with the SMT Beacon.
|
|
71115
|
-
* @returns {
|
|
71197
|
+
* @returns {BeaconProcessResult} The processed signals.
|
|
71116
71198
|
* @throws {SMTBeaconError} if processing fails.
|
|
71117
71199
|
*/
|
|
71118
71200
|
processSignals(signals, sidecar) {
|
|
@@ -71318,7 +71400,7 @@ function base2(ALPHABET2, name10) {
|
|
|
71318
71400
|
var LEADER = ALPHABET2.charAt(0);
|
|
71319
71401
|
var FACTOR = Math.log(BASE) / Math.log(256);
|
|
71320
71402
|
var iFACTOR = Math.log(256) / Math.log(BASE);
|
|
71321
|
-
function
|
|
71403
|
+
function encode44(source) {
|
|
71322
71404
|
if (source instanceof Uint8Array)
|
|
71323
71405
|
;
|
|
71324
71406
|
else if (ArrayBuffer.isView(source)) {
|
|
@@ -71416,7 +71498,7 @@ function base2(ALPHABET2, name10) {
|
|
|
71416
71498
|
}
|
|
71417
71499
|
return vch;
|
|
71418
71500
|
}
|
|
71419
|
-
function
|
|
71501
|
+
function decode48(string4) {
|
|
71420
71502
|
var buffer2 = decodeUnsafe(string4);
|
|
71421
71503
|
if (buffer2) {
|
|
71422
71504
|
return buffer2;
|
|
@@ -71424,9 +71506,9 @@ function base2(ALPHABET2, name10) {
|
|
|
71424
71506
|
throw new Error(`Non-${name10} character`);
|
|
71425
71507
|
}
|
|
71426
71508
|
return {
|
|
71427
|
-
encode:
|
|
71509
|
+
encode: encode44,
|
|
71428
71510
|
decodeUnsafe,
|
|
71429
|
-
decode:
|
|
71511
|
+
decode: decode48
|
|
71430
71512
|
};
|
|
71431
71513
|
}
|
|
71432
71514
|
var src = base2;
|
|
@@ -71526,19 +71608,19 @@ var Codec = class {
|
|
|
71526
71608
|
return this.decoder.decode(input);
|
|
71527
71609
|
}
|
|
71528
71610
|
};
|
|
71529
|
-
function from({ name: name10, prefix, encode:
|
|
71530
|
-
return new Codec(name10, prefix,
|
|
71611
|
+
function from({ name: name10, prefix, encode: encode44, decode: decode48 }) {
|
|
71612
|
+
return new Codec(name10, prefix, encode44, decode48);
|
|
71531
71613
|
}
|
|
71532
71614
|
function baseX({ name: name10, prefix, alphabet: alphabet6 }) {
|
|
71533
|
-
const { encode:
|
|
71615
|
+
const { encode: encode44, decode: decode48 } = base_x_default(alphabet6, name10);
|
|
71534
71616
|
return from({
|
|
71535
71617
|
prefix,
|
|
71536
71618
|
name: name10,
|
|
71537
|
-
encode:
|
|
71538
|
-
decode: (text) => coerce(
|
|
71619
|
+
encode: encode44,
|
|
71620
|
+
decode: (text) => coerce(decode48(text))
|
|
71539
71621
|
});
|
|
71540
71622
|
}
|
|
71541
|
-
function
|
|
71623
|
+
function decode21(string4, alphabetIdx, bitsPerChar, name10) {
|
|
71542
71624
|
let end = string4.length;
|
|
71543
71625
|
while (string4[end - 1] === "=") {
|
|
71544
71626
|
--end;
|
|
@@ -71564,7 +71646,7 @@ function decode20(string4, alphabetIdx, bitsPerChar, name10) {
|
|
|
71564
71646
|
}
|
|
71565
71647
|
return out;
|
|
71566
71648
|
}
|
|
71567
|
-
function
|
|
71649
|
+
function encode21(data, alphabet6, bitsPerChar) {
|
|
71568
71650
|
const pad2 = alphabet6[alphabet6.length - 1] === "=";
|
|
71569
71651
|
const mask = (1 << bitsPerChar) - 1;
|
|
71570
71652
|
let out = "";
|
|
@@ -71601,10 +71683,10 @@ function rfc4648({ name: name10, prefix, bitsPerChar, alphabet: alphabet6 }) {
|
|
|
71601
71683
|
prefix,
|
|
71602
71684
|
name: name10,
|
|
71603
71685
|
encode(input) {
|
|
71604
|
-
return
|
|
71686
|
+
return encode21(input, alphabet6, bitsPerChar);
|
|
71605
71687
|
},
|
|
71606
71688
|
decode(input) {
|
|
71607
|
-
return
|
|
71689
|
+
return decode21(input, alphabetIdx, bitsPerChar, name10);
|
|
71608
71690
|
}
|
|
71609
71691
|
});
|
|
71610
71692
|
}
|
|
@@ -71706,7 +71788,7 @@ var digest_exports = {};
|
|
|
71706
71788
|
__export(digest_exports, {
|
|
71707
71789
|
Digest: () => Digest,
|
|
71708
71790
|
create: () => create,
|
|
71709
|
-
decode: () =>
|
|
71791
|
+
decode: () => decode24,
|
|
71710
71792
|
equals: () => equals2,
|
|
71711
71793
|
hasCode: () => hasCode
|
|
71712
71794
|
});
|
|
@@ -71717,12 +71799,12 @@ init_shim();
|
|
|
71717
71799
|
|
|
71718
71800
|
// ../../node_modules/.pnpm/multiformats@13.4.1/node_modules/multiformats/dist/src/vendor/varint.js
|
|
71719
71801
|
init_shim();
|
|
71720
|
-
var encode_1 =
|
|
71802
|
+
var encode_1 = encode22;
|
|
71721
71803
|
var MSB = 128;
|
|
71722
71804
|
var REST = 127;
|
|
71723
71805
|
var MSBALL = ~REST;
|
|
71724
71806
|
var INT = Math.pow(2, 31);
|
|
71725
|
-
function
|
|
71807
|
+
function encode22(num3, out, offset) {
|
|
71726
71808
|
out = out || [];
|
|
71727
71809
|
offset = offset || 0;
|
|
71728
71810
|
var oldOffset = offset;
|
|
@@ -71735,10 +71817,10 @@ function encode21(num3, out, offset) {
|
|
|
71735
71817
|
num3 >>>= 7;
|
|
71736
71818
|
}
|
|
71737
71819
|
out[offset] = num3 | 0;
|
|
71738
|
-
|
|
71820
|
+
encode22.bytes = offset - oldOffset + 1;
|
|
71739
71821
|
return out;
|
|
71740
71822
|
}
|
|
71741
|
-
var
|
|
71823
|
+
var decode22 = read;
|
|
71742
71824
|
var MSB$1 = 128;
|
|
71743
71825
|
var REST$1 = 127;
|
|
71744
71826
|
function read(buf2, offset) {
|
|
@@ -71769,14 +71851,14 @@ var length2 = function(value3) {
|
|
|
71769
71851
|
};
|
|
71770
71852
|
var varint = {
|
|
71771
71853
|
encode: encode_1,
|
|
71772
|
-
decode:
|
|
71854
|
+
decode: decode22,
|
|
71773
71855
|
encodingLength: length2
|
|
71774
71856
|
};
|
|
71775
71857
|
var _brrp_varint = varint;
|
|
71776
71858
|
var varint_default = _brrp_varint;
|
|
71777
71859
|
|
|
71778
71860
|
// ../../node_modules/.pnpm/multiformats@13.4.1/node_modules/multiformats/dist/src/varint.js
|
|
71779
|
-
function
|
|
71861
|
+
function decode23(data, offset = 0) {
|
|
71780
71862
|
const code8 = varint_default.decode(data, offset);
|
|
71781
71863
|
return [code8, varint_default.decode.bytes];
|
|
71782
71864
|
}
|
|
@@ -71799,10 +71881,10 @@ function create(code8, digest2) {
|
|
|
71799
71881
|
bytes6.set(digest2, digestOffset);
|
|
71800
71882
|
return new Digest(code8, size, digest2, bytes6);
|
|
71801
71883
|
}
|
|
71802
|
-
function
|
|
71884
|
+
function decode24(multihash) {
|
|
71803
71885
|
const bytes6 = coerce(multihash);
|
|
71804
|
-
const [code8, sizeOffset] =
|
|
71805
|
-
const [size, digestOffset] =
|
|
71886
|
+
const [code8, sizeOffset] = decode23(bytes6);
|
|
71887
|
+
const [size, digestOffset] = decode23(bytes6.subarray(sizeOffset));
|
|
71806
71888
|
const digest2 = bytes6.subarray(sizeOffset + digestOffset);
|
|
71807
71889
|
if (digest2.byteLength !== size) {
|
|
71808
71890
|
throw new Error("Incorrect length");
|
|
@@ -71972,7 +72054,7 @@ var CID = class _CID {
|
|
|
71972
72054
|
return new _CID(version3, code8, multihash, bytes6 ?? encodeCID(version3, code8, multihash.bytes));
|
|
71973
72055
|
} else if (value3[cidSymbol] === true) {
|
|
71974
72056
|
const { version: version3, multihash, code: code8 } = value3;
|
|
71975
|
-
const digest2 =
|
|
72057
|
+
const digest2 = decode24(multihash);
|
|
71976
72058
|
return _CID.create(version3, code8, digest2);
|
|
71977
72059
|
} else {
|
|
71978
72060
|
return null;
|
|
@@ -72069,7 +72151,7 @@ var CID = class _CID {
|
|
|
72069
72151
|
static inspectBytes(initialBytes) {
|
|
72070
72152
|
let offset = 0;
|
|
72071
72153
|
const next = () => {
|
|
72072
|
-
const [i4, length7] =
|
|
72154
|
+
const [i4, length7] = decode23(initialBytes.subarray(offset));
|
|
72073
72155
|
offset += length7;
|
|
72074
72156
|
return i4;
|
|
72075
72157
|
};
|
|
@@ -72179,17 +72261,17 @@ var cidSymbol = Symbol.for("@ipld/js-cid/CID");
|
|
|
72179
72261
|
var raw_exports = {};
|
|
72180
72262
|
__export(raw_exports, {
|
|
72181
72263
|
code: () => code,
|
|
72182
|
-
decode: () =>
|
|
72183
|
-
encode: () =>
|
|
72264
|
+
decode: () => decode25,
|
|
72265
|
+
encode: () => encode23,
|
|
72184
72266
|
name: () => name
|
|
72185
72267
|
});
|
|
72186
72268
|
init_shim();
|
|
72187
72269
|
var name = "raw";
|
|
72188
72270
|
var code = 85;
|
|
72189
|
-
function
|
|
72271
|
+
function encode23(node) {
|
|
72190
72272
|
return coerce(node);
|
|
72191
72273
|
}
|
|
72192
|
-
function
|
|
72274
|
+
function decode25(data) {
|
|
72193
72275
|
return coerce(data);
|
|
72194
72276
|
}
|
|
72195
72277
|
|
|
@@ -72204,8 +72286,8 @@ init_shim();
|
|
|
72204
72286
|
// ../../node_modules/.pnpm/multiformats@13.4.1/node_modules/multiformats/dist/src/hashes/hasher.js
|
|
72205
72287
|
init_shim();
|
|
72206
72288
|
var DEFAULT_MIN_DIGEST_LENGTH = 20;
|
|
72207
|
-
function from2({ name: name10, code: code8, encode:
|
|
72208
|
-
return new Hasher(name10, code8,
|
|
72289
|
+
function from2({ name: name10, code: code8, encode: encode44, minDigestLength, maxDigestLength }) {
|
|
72290
|
+
return new Hasher(name10, code8, encode44, minDigestLength, maxDigestLength);
|
|
72209
72291
|
}
|
|
72210
72292
|
var Hasher = class {
|
|
72211
72293
|
name;
|
|
@@ -72213,10 +72295,10 @@ var Hasher = class {
|
|
|
72213
72295
|
encode;
|
|
72214
72296
|
minDigestLength;
|
|
72215
72297
|
maxDigestLength;
|
|
72216
|
-
constructor(name10, code8,
|
|
72298
|
+
constructor(name10, code8, encode44, minDigestLength, maxDigestLength) {
|
|
72217
72299
|
this.name = name10;
|
|
72218
72300
|
this.code = code8;
|
|
72219
|
-
this.encode =
|
|
72301
|
+
this.encode = encode44;
|
|
72220
72302
|
this.minDigestLength = minDigestLength ?? DEFAULT_MIN_DIGEST_LENGTH;
|
|
72221
72303
|
this.maxDigestLength = maxDigestLength;
|
|
72222
72304
|
}
|
|
@@ -72338,13 +72420,13 @@ var alphabetCharsToBytes = alphabet4.reduce((p2, c2, i4) => {
|
|
|
72338
72420
|
p2[codePoint] = i4;
|
|
72339
72421
|
return p2;
|
|
72340
72422
|
}, []);
|
|
72341
|
-
function
|
|
72423
|
+
function encode24(data) {
|
|
72342
72424
|
return data.reduce((p2, c2) => {
|
|
72343
72425
|
p2 += alphabetBytesToChars[c2];
|
|
72344
72426
|
return p2;
|
|
72345
72427
|
}, "");
|
|
72346
72428
|
}
|
|
72347
|
-
function
|
|
72429
|
+
function decode26(str) {
|
|
72348
72430
|
const byts = [];
|
|
72349
72431
|
for (const char of str) {
|
|
72350
72432
|
const codePoint = char.codePointAt(0);
|
|
@@ -72362,8 +72444,8 @@ function decode25(str) {
|
|
|
72362
72444
|
var base256emoji = from({
|
|
72363
72445
|
prefix: "\u{1F680}",
|
|
72364
72446
|
name: "base256emoji",
|
|
72365
|
-
encode:
|
|
72366
|
-
decode:
|
|
72447
|
+
encode: encode24,
|
|
72448
|
+
decode: decode26
|
|
72367
72449
|
});
|
|
72368
72450
|
|
|
72369
72451
|
// ../../node_modules/.pnpm/multiformats@13.4.1/node_modules/multiformats/dist/src/bases/base64.js
|
|
@@ -72430,8 +72512,8 @@ var identity = from({
|
|
|
72430
72512
|
var json_exports = {};
|
|
72431
72513
|
__export(json_exports, {
|
|
72432
72514
|
code: () => code2,
|
|
72433
|
-
decode: () =>
|
|
72434
|
-
encode: () =>
|
|
72515
|
+
decode: () => decode27,
|
|
72516
|
+
encode: () => encode25,
|
|
72435
72517
|
name: () => name2
|
|
72436
72518
|
});
|
|
72437
72519
|
init_shim();
|
|
@@ -72439,10 +72521,10 @@ var textEncoder = new TextEncoder();
|
|
|
72439
72521
|
var textDecoder = new TextDecoder();
|
|
72440
72522
|
var name2 = "json";
|
|
72441
72523
|
var code2 = 512;
|
|
72442
|
-
function
|
|
72524
|
+
function encode25(node) {
|
|
72443
72525
|
return textEncoder.encode(JSON.stringify(node));
|
|
72444
72526
|
}
|
|
72445
|
-
function
|
|
72527
|
+
function decode27(data) {
|
|
72446
72528
|
return JSON.parse(textDecoder.decode(data));
|
|
72447
72529
|
}
|
|
72448
72530
|
|
|
@@ -72454,7 +72536,7 @@ __export(identity_exports2, {
|
|
|
72454
72536
|
init_shim();
|
|
72455
72537
|
var code3 = 0;
|
|
72456
72538
|
var name3 = "identity";
|
|
72457
|
-
var
|
|
72539
|
+
var encode26 = coerce;
|
|
72458
72540
|
function digest(input, options2) {
|
|
72459
72541
|
if (options2?.truncate != null && options2.truncate !== input.byteLength) {
|
|
72460
72542
|
if (options2.truncate < 0 || options2.truncate > input.byteLength) {
|
|
@@ -72462,9 +72544,9 @@ function digest(input, options2) {
|
|
|
72462
72544
|
}
|
|
72463
72545
|
input = input.subarray(0, options2.truncate);
|
|
72464
72546
|
}
|
|
72465
|
-
return create(code3,
|
|
72547
|
+
return create(code3, encode26(input));
|
|
72466
72548
|
}
|
|
72467
|
-
var identity2 = { code: code3, name: name3, encode:
|
|
72549
|
+
var identity2 = { code: code3, name: name3, encode: encode26, digest };
|
|
72468
72550
|
|
|
72469
72551
|
// ../../node_modules/.pnpm/multiformats@13.4.1/node_modules/multiformats/dist/src/index.js
|
|
72470
72552
|
init_shim();
|
|
@@ -72498,17 +72580,17 @@ function allocUnsafe(size = 0) {
|
|
|
72498
72580
|
}
|
|
72499
72581
|
|
|
72500
72582
|
// ../../node_modules/.pnpm/uint8arrays@5.1.0/node_modules/uint8arrays/dist/src/util/bases.js
|
|
72501
|
-
function createCodec(name10, prefix,
|
|
72583
|
+
function createCodec(name10, prefix, encode44, decode48) {
|
|
72502
72584
|
return {
|
|
72503
72585
|
name: name10,
|
|
72504
72586
|
prefix,
|
|
72505
72587
|
encoder: {
|
|
72506
72588
|
name: name10,
|
|
72507
72589
|
prefix,
|
|
72508
|
-
encode:
|
|
72590
|
+
encode: encode44
|
|
72509
72591
|
},
|
|
72510
72592
|
decoder: {
|
|
72511
|
-
decode:
|
|
72593
|
+
decode: decode48
|
|
72512
72594
|
}
|
|
72513
72595
|
};
|
|
72514
72596
|
}
|
|
@@ -72800,7 +72882,7 @@ function base3(ALPHABET2, name10) {
|
|
|
72800
72882
|
var LEADER = ALPHABET2.charAt(0);
|
|
72801
72883
|
var FACTOR = Math.log(BASE) / Math.log(256);
|
|
72802
72884
|
var iFACTOR = Math.log(256) / Math.log(BASE);
|
|
72803
|
-
function
|
|
72885
|
+
function encode44(source) {
|
|
72804
72886
|
if (source instanceof Uint8Array)
|
|
72805
72887
|
;
|
|
72806
72888
|
else if (ArrayBuffer.isView(source)) {
|
|
@@ -72898,7 +72980,7 @@ function base3(ALPHABET2, name10) {
|
|
|
72898
72980
|
}
|
|
72899
72981
|
return vch;
|
|
72900
72982
|
}
|
|
72901
|
-
function
|
|
72983
|
+
function decode48(string4) {
|
|
72902
72984
|
var buffer2 = decodeUnsafe(string4);
|
|
72903
72985
|
if (buffer2) {
|
|
72904
72986
|
return buffer2;
|
|
@@ -72906,9 +72988,9 @@ function base3(ALPHABET2, name10) {
|
|
|
72906
72988
|
throw new Error(`Non-${name10} character`);
|
|
72907
72989
|
}
|
|
72908
72990
|
return {
|
|
72909
|
-
encode:
|
|
72991
|
+
encode: encode44,
|
|
72910
72992
|
decodeUnsafe,
|
|
72911
|
-
decode:
|
|
72993
|
+
decode: decode48
|
|
72912
72994
|
};
|
|
72913
72995
|
}
|
|
72914
72996
|
var src2 = base3;
|
|
@@ -73007,19 +73089,19 @@ var Codec2 = class {
|
|
|
73007
73089
|
return this.decoder.decode(input);
|
|
73008
73090
|
}
|
|
73009
73091
|
};
|
|
73010
|
-
function from3({ name: name10, prefix, encode:
|
|
73011
|
-
return new Codec2(name10, prefix,
|
|
73092
|
+
function from3({ name: name10, prefix, encode: encode44, decode: decode48 }) {
|
|
73093
|
+
return new Codec2(name10, prefix, encode44, decode48);
|
|
73012
73094
|
}
|
|
73013
73095
|
function baseX2({ name: name10, prefix, alphabet: alphabet6 }) {
|
|
73014
|
-
const { encode:
|
|
73096
|
+
const { encode: encode44, decode: decode48 } = base_x_default2(alphabet6, name10);
|
|
73015
73097
|
return from3({
|
|
73016
73098
|
prefix,
|
|
73017
73099
|
name: name10,
|
|
73018
|
-
encode:
|
|
73019
|
-
decode: (text) => coerce2(
|
|
73100
|
+
encode: encode44,
|
|
73101
|
+
decode: (text) => coerce2(decode48(text))
|
|
73020
73102
|
});
|
|
73021
73103
|
}
|
|
73022
|
-
function
|
|
73104
|
+
function decode28(string4, alphabet6, bitsPerChar, name10) {
|
|
73023
73105
|
const codes = {};
|
|
73024
73106
|
for (let i4 = 0; i4 < alphabet6.length; ++i4) {
|
|
73025
73107
|
codes[alphabet6[i4]] = i4;
|
|
@@ -73049,7 +73131,7 @@ function decode27(string4, alphabet6, bitsPerChar, name10) {
|
|
|
73049
73131
|
}
|
|
73050
73132
|
return out;
|
|
73051
73133
|
}
|
|
73052
|
-
function
|
|
73134
|
+
function encode27(data, alphabet6, bitsPerChar) {
|
|
73053
73135
|
const pad2 = alphabet6[alphabet6.length - 1] === "=";
|
|
73054
73136
|
const mask = (1 << bitsPerChar) - 1;
|
|
73055
73137
|
let out = "";
|
|
@@ -73078,10 +73160,10 @@ function rfc46482({ name: name10, prefix, bitsPerChar, alphabet: alphabet6 }) {
|
|
|
73078
73160
|
prefix,
|
|
73079
73161
|
name: name10,
|
|
73080
73162
|
encode(input) {
|
|
73081
|
-
return
|
|
73163
|
+
return encode27(input, alphabet6, bitsPerChar);
|
|
73082
73164
|
},
|
|
73083
73165
|
decode(input) {
|
|
73084
|
-
return
|
|
73166
|
+
return decode28(input, alphabet6, bitsPerChar, name10);
|
|
73085
73167
|
}
|
|
73086
73168
|
});
|
|
73087
73169
|
}
|
|
@@ -73656,7 +73738,7 @@ init_shim();
|
|
|
73656
73738
|
// ../../node_modules/.pnpm/multiformats@13.1.0/node_modules/multiformats/dist/src/varint.js
|
|
73657
73739
|
var varint_exports2 = {};
|
|
73658
73740
|
__export(varint_exports2, {
|
|
73659
|
-
decode: () =>
|
|
73741
|
+
decode: () => decode30,
|
|
73660
73742
|
encodeTo: () => encodeTo2,
|
|
73661
73743
|
encodingLength: () => encodingLength4
|
|
73662
73744
|
});
|
|
@@ -73664,12 +73746,12 @@ init_shim();
|
|
|
73664
73746
|
|
|
73665
73747
|
// ../../node_modules/.pnpm/multiformats@13.1.0/node_modules/multiformats/dist/src/vendor/varint.js
|
|
73666
73748
|
init_shim();
|
|
73667
|
-
var encode_12 =
|
|
73749
|
+
var encode_12 = encode28;
|
|
73668
73750
|
var MSB2 = 128;
|
|
73669
73751
|
var REST2 = 127;
|
|
73670
73752
|
var MSBALL2 = ~REST2;
|
|
73671
73753
|
var INT2 = Math.pow(2, 31);
|
|
73672
|
-
function
|
|
73754
|
+
function encode28(num3, out, offset) {
|
|
73673
73755
|
out = out || [];
|
|
73674
73756
|
offset = offset || 0;
|
|
73675
73757
|
var oldOffset = offset;
|
|
@@ -73682,10 +73764,10 @@ function encode27(num3, out, offset) {
|
|
|
73682
73764
|
num3 >>>= 7;
|
|
73683
73765
|
}
|
|
73684
73766
|
out[offset] = num3 | 0;
|
|
73685
|
-
|
|
73767
|
+
encode28.bytes = offset - oldOffset + 1;
|
|
73686
73768
|
return out;
|
|
73687
73769
|
}
|
|
73688
|
-
var
|
|
73770
|
+
var decode29 = read2;
|
|
73689
73771
|
var MSB$12 = 128;
|
|
73690
73772
|
var REST$12 = 127;
|
|
73691
73773
|
function read2(buf2, offset) {
|
|
@@ -73716,14 +73798,14 @@ var length3 = function(value3) {
|
|
|
73716
73798
|
};
|
|
73717
73799
|
var varint2 = {
|
|
73718
73800
|
encode: encode_12,
|
|
73719
|
-
decode:
|
|
73801
|
+
decode: decode29,
|
|
73720
73802
|
encodingLength: length3
|
|
73721
73803
|
};
|
|
73722
73804
|
var _brrp_varint2 = varint2;
|
|
73723
73805
|
var varint_default2 = _brrp_varint2;
|
|
73724
73806
|
|
|
73725
73807
|
// ../../node_modules/.pnpm/multiformats@13.1.0/node_modules/multiformats/dist/src/varint.js
|
|
73726
|
-
function
|
|
73808
|
+
function decode30(data, offset = 0) {
|
|
73727
73809
|
const code8 = varint_default2.decode(data, offset);
|
|
73728
73810
|
return [code8, varint_default2.decode.bytes];
|
|
73729
73811
|
}
|
|
@@ -73746,10 +73828,10 @@ function create2(code8, digest2) {
|
|
|
73746
73828
|
bytes6.set(digest2, digestOffset);
|
|
73747
73829
|
return new Digest2(code8, size, digest2, bytes6);
|
|
73748
73830
|
}
|
|
73749
|
-
function
|
|
73831
|
+
function decode31(multihash) {
|
|
73750
73832
|
const bytes6 = coerce2(multihash);
|
|
73751
|
-
const [code8, sizeOffset] =
|
|
73752
|
-
const [size, digestOffset] =
|
|
73833
|
+
const [code8, sizeOffset] = decode30(bytes6);
|
|
73834
|
+
const [size, digestOffset] = decode30(bytes6.subarray(sizeOffset));
|
|
73753
73835
|
const digest2 = bytes6.subarray(sizeOffset + digestOffset);
|
|
73754
73836
|
if (digest2.byteLength !== size) {
|
|
73755
73837
|
throw new Error("Incorrect length");
|
|
@@ -73916,7 +73998,7 @@ var CID2 = class _CID {
|
|
|
73916
73998
|
return new _CID(version3, code8, multihash, bytes6 ?? encodeCID2(version3, code8, multihash.bytes));
|
|
73917
73999
|
} else if (value3[cidSymbol2] === true) {
|
|
73918
74000
|
const { version: version3, multihash, code: code8 } = value3;
|
|
73919
|
-
const digest2 =
|
|
74001
|
+
const digest2 = decode31(multihash);
|
|
73920
74002
|
return _CID.create(version3, code8, digest2);
|
|
73921
74003
|
} else {
|
|
73922
74004
|
return null;
|
|
@@ -74013,7 +74095,7 @@ var CID2 = class _CID {
|
|
|
74013
74095
|
static inspectBytes(initialBytes) {
|
|
74014
74096
|
let offset = 0;
|
|
74015
74097
|
const next = () => {
|
|
74016
|
-
const [i4, length7] =
|
|
74098
|
+
const [i4, length7] = decode30(initialBytes.subarray(offset));
|
|
74017
74099
|
offset += length7;
|
|
74018
74100
|
return i4;
|
|
74019
74101
|
};
|
|
@@ -81465,72 +81547,72 @@ function getType(value3) {
|
|
|
81465
81547
|
}
|
|
81466
81548
|
|
|
81467
81549
|
// ../../node_modules/.pnpm/bencode@4.0.0/node_modules/bencode/lib/encode.js
|
|
81468
|
-
function
|
|
81550
|
+
function encode30(data, buffer2, offset) {
|
|
81469
81551
|
const buffers = [];
|
|
81470
81552
|
let result = null;
|
|
81471
|
-
|
|
81553
|
+
encode30._encode(buffers, data);
|
|
81472
81554
|
result = concat2(buffers);
|
|
81473
|
-
|
|
81555
|
+
encode30.bytes = result.length;
|
|
81474
81556
|
if (ArrayBuffer.isView(buffer2)) {
|
|
81475
81557
|
buffer2.set(result, offset);
|
|
81476
81558
|
return buffer2;
|
|
81477
81559
|
}
|
|
81478
81560
|
return result;
|
|
81479
81561
|
}
|
|
81480
|
-
|
|
81481
|
-
|
|
81482
|
-
|
|
81562
|
+
encode30.bytes = -1;
|
|
81563
|
+
encode30._floatConversionDetected = false;
|
|
81564
|
+
encode30._encode = function(buffers, data) {
|
|
81483
81565
|
if (data == null) {
|
|
81484
81566
|
return;
|
|
81485
81567
|
}
|
|
81486
81568
|
switch (getType(data)) {
|
|
81487
81569
|
case "object":
|
|
81488
|
-
|
|
81570
|
+
encode30.dict(buffers, data);
|
|
81489
81571
|
break;
|
|
81490
81572
|
case "map":
|
|
81491
|
-
|
|
81573
|
+
encode30.dictMap(buffers, data);
|
|
81492
81574
|
break;
|
|
81493
81575
|
case "array":
|
|
81494
|
-
|
|
81576
|
+
encode30.list(buffers, data);
|
|
81495
81577
|
break;
|
|
81496
81578
|
case "set":
|
|
81497
|
-
|
|
81579
|
+
encode30.listSet(buffers, data);
|
|
81498
81580
|
break;
|
|
81499
81581
|
case "string":
|
|
81500
|
-
|
|
81582
|
+
encode30.string(buffers, data);
|
|
81501
81583
|
break;
|
|
81502
81584
|
case "number":
|
|
81503
|
-
|
|
81585
|
+
encode30.number(buffers, data);
|
|
81504
81586
|
break;
|
|
81505
81587
|
case "boolean":
|
|
81506
|
-
|
|
81588
|
+
encode30.number(buffers, data);
|
|
81507
81589
|
break;
|
|
81508
81590
|
case "arraybufferview":
|
|
81509
|
-
|
|
81591
|
+
encode30.buffer(buffers, new Uint8Array(data.buffer, data.byteOffset, data.byteLength));
|
|
81510
81592
|
break;
|
|
81511
81593
|
case "arraybuffer":
|
|
81512
|
-
|
|
81594
|
+
encode30.buffer(buffers, new Uint8Array(data));
|
|
81513
81595
|
break;
|
|
81514
81596
|
}
|
|
81515
81597
|
};
|
|
81516
81598
|
var buffE = new Uint8Array([101]);
|
|
81517
81599
|
var buffD = new Uint8Array([100]);
|
|
81518
81600
|
var buffL = new Uint8Array([108]);
|
|
81519
|
-
|
|
81601
|
+
encode30.buffer = function(buffers, data) {
|
|
81520
81602
|
buffers.push(text2arr(data.length + ":"), data);
|
|
81521
81603
|
};
|
|
81522
|
-
|
|
81604
|
+
encode30.string = function(buffers, data) {
|
|
81523
81605
|
buffers.push(text2arr(text2arr(data).byteLength + ":" + data));
|
|
81524
81606
|
};
|
|
81525
|
-
|
|
81607
|
+
encode30.number = function(buffers, data) {
|
|
81526
81608
|
if (Number.isInteger(data)) return buffers.push(text2arr("i" + BigInt(data) + "e"));
|
|
81527
81609
|
const maxLo = 2147483648;
|
|
81528
81610
|
const hi = data / maxLo << 0;
|
|
81529
81611
|
const lo = data % maxLo << 0;
|
|
81530
81612
|
const val = hi * maxLo + lo;
|
|
81531
81613
|
buffers.push(text2arr("i" + val + "e"));
|
|
81532
|
-
if (val !== data && !
|
|
81533
|
-
|
|
81614
|
+
if (val !== data && !encode30._floatConversionDetected) {
|
|
81615
|
+
encode30._floatConversionDetected = true;
|
|
81534
81616
|
console.warn(
|
|
81535
81617
|
'WARNING: Possible data corruption detected with value "' + data + '":',
|
|
81536
81618
|
'Bencoding only defines support for integers, value was converted to "' + val + '"'
|
|
@@ -81538,7 +81620,7 @@ encode29.number = function(buffers, data) {
|
|
|
81538
81620
|
console.trace();
|
|
81539
81621
|
}
|
|
81540
81622
|
};
|
|
81541
|
-
|
|
81623
|
+
encode30.dict = function(buffers, data) {
|
|
81542
81624
|
buffers.push(buffD);
|
|
81543
81625
|
let j = 0;
|
|
81544
81626
|
let k;
|
|
@@ -81547,40 +81629,40 @@ encode29.dict = function(buffers, data) {
|
|
|
81547
81629
|
for (; j < kl; j++) {
|
|
81548
81630
|
k = keys[j];
|
|
81549
81631
|
if (data[k] == null) continue;
|
|
81550
|
-
|
|
81551
|
-
|
|
81632
|
+
encode30.string(buffers, k);
|
|
81633
|
+
encode30._encode(buffers, data[k]);
|
|
81552
81634
|
}
|
|
81553
81635
|
buffers.push(buffE);
|
|
81554
81636
|
};
|
|
81555
|
-
|
|
81637
|
+
encode30.dictMap = function(buffers, data) {
|
|
81556
81638
|
buffers.push(buffD);
|
|
81557
81639
|
const keys = Array.from(data.keys()).sort();
|
|
81558
81640
|
for (const key of keys) {
|
|
81559
81641
|
if (data.get(key) == null) continue;
|
|
81560
|
-
ArrayBuffer.isView(key) ?
|
|
81561
|
-
|
|
81642
|
+
ArrayBuffer.isView(key) ? encode30._encode(buffers, key) : encode30.string(buffers, String(key));
|
|
81643
|
+
encode30._encode(buffers, data.get(key));
|
|
81562
81644
|
}
|
|
81563
81645
|
buffers.push(buffE);
|
|
81564
81646
|
};
|
|
81565
|
-
|
|
81647
|
+
encode30.list = function(buffers, data) {
|
|
81566
81648
|
let i4 = 0;
|
|
81567
81649
|
const c2 = data.length;
|
|
81568
81650
|
buffers.push(buffL);
|
|
81569
81651
|
for (; i4 < c2; i4++) {
|
|
81570
81652
|
if (data[i4] == null) continue;
|
|
81571
|
-
|
|
81653
|
+
encode30._encode(buffers, data[i4]);
|
|
81572
81654
|
}
|
|
81573
81655
|
buffers.push(buffE);
|
|
81574
81656
|
};
|
|
81575
|
-
|
|
81657
|
+
encode30.listSet = function(buffers, data) {
|
|
81576
81658
|
buffers.push(buffL);
|
|
81577
81659
|
for (const item of data) {
|
|
81578
81660
|
if (item == null) continue;
|
|
81579
|
-
|
|
81661
|
+
encode30._encode(buffers, item);
|
|
81580
81662
|
}
|
|
81581
81663
|
buffers.push(buffE);
|
|
81582
81664
|
};
|
|
81583
|
-
var encode_default =
|
|
81665
|
+
var encode_default = encode30;
|
|
81584
81666
|
|
|
81585
81667
|
// ../../node_modules/.pnpm/bencode@4.0.0/node_modules/bencode/lib/decode.js
|
|
81586
81668
|
init_shim();
|
|
@@ -81612,7 +81694,7 @@ function getIntFromBuffer(buffer2, start2, end) {
|
|
|
81612
81694
|
}
|
|
81613
81695
|
return sum * sign;
|
|
81614
81696
|
}
|
|
81615
|
-
function
|
|
81697
|
+
function decode33(data, start2, end, encoding) {
|
|
81616
81698
|
if (data == null || data.length === 0) {
|
|
81617
81699
|
return null;
|
|
81618
81700
|
}
|
|
@@ -81624,32 +81706,32 @@ function decode32(data, start2, end, encoding) {
|
|
|
81624
81706
|
encoding = end;
|
|
81625
81707
|
end = void 0;
|
|
81626
81708
|
}
|
|
81627
|
-
|
|
81628
|
-
|
|
81629
|
-
|
|
81630
|
-
|
|
81631
|
-
return
|
|
81632
|
-
}
|
|
81633
|
-
|
|
81634
|
-
|
|
81635
|
-
|
|
81636
|
-
|
|
81637
|
-
|
|
81638
|
-
switch (
|
|
81709
|
+
decode33.position = 0;
|
|
81710
|
+
decode33.encoding = encoding || null;
|
|
81711
|
+
decode33.data = !ArrayBuffer.isView(data) ? text2arr(data) : new Uint8Array(data.slice(start2, end));
|
|
81712
|
+
decode33.bytes = decode33.data.length;
|
|
81713
|
+
return decode33.next();
|
|
81714
|
+
}
|
|
81715
|
+
decode33.bytes = 0;
|
|
81716
|
+
decode33.position = 0;
|
|
81717
|
+
decode33.data = null;
|
|
81718
|
+
decode33.encoding = null;
|
|
81719
|
+
decode33.next = function() {
|
|
81720
|
+
switch (decode33.data[decode33.position]) {
|
|
81639
81721
|
case DICTIONARY_START:
|
|
81640
|
-
return
|
|
81722
|
+
return decode33.dictionary();
|
|
81641
81723
|
case LIST_START:
|
|
81642
|
-
return
|
|
81724
|
+
return decode33.list();
|
|
81643
81725
|
case INTEGER_START:
|
|
81644
|
-
return
|
|
81726
|
+
return decode33.integer();
|
|
81645
81727
|
default:
|
|
81646
|
-
return
|
|
81728
|
+
return decode33.buffer();
|
|
81647
81729
|
}
|
|
81648
81730
|
};
|
|
81649
|
-
|
|
81650
|
-
let i4 =
|
|
81651
|
-
const c2 =
|
|
81652
|
-
const d2 =
|
|
81731
|
+
decode33.find = function(chr) {
|
|
81732
|
+
let i4 = decode33.position;
|
|
81733
|
+
const c2 = decode33.data.length;
|
|
81734
|
+
const d2 = decode33.data;
|
|
81653
81735
|
while (i4 < c2) {
|
|
81654
81736
|
if (d2[i4] === chr) return i4;
|
|
81655
81737
|
i4++;
|
|
@@ -81658,41 +81740,41 @@ decode32.find = function(chr) {
|
|
|
81658
81740
|
'Invalid data: Missing delimiter "' + String.fromCharCode(chr) + '" [0x' + chr.toString(16) + "]"
|
|
81659
81741
|
);
|
|
81660
81742
|
};
|
|
81661
|
-
|
|
81662
|
-
|
|
81743
|
+
decode33.dictionary = function() {
|
|
81744
|
+
decode33.position++;
|
|
81663
81745
|
const dict = {};
|
|
81664
|
-
while (
|
|
81665
|
-
const buffer2 =
|
|
81746
|
+
while (decode33.data[decode33.position] !== END_OF_TYPE) {
|
|
81747
|
+
const buffer2 = decode33.buffer();
|
|
81666
81748
|
let key = arr2text(buffer2);
|
|
81667
81749
|
if (key.includes("\uFFFD")) key = arr2hex(buffer2);
|
|
81668
|
-
dict[key] =
|
|
81750
|
+
dict[key] = decode33.next();
|
|
81669
81751
|
}
|
|
81670
|
-
|
|
81752
|
+
decode33.position++;
|
|
81671
81753
|
return dict;
|
|
81672
81754
|
};
|
|
81673
|
-
|
|
81674
|
-
|
|
81755
|
+
decode33.list = function() {
|
|
81756
|
+
decode33.position++;
|
|
81675
81757
|
const lst = [];
|
|
81676
|
-
while (
|
|
81677
|
-
lst.push(
|
|
81758
|
+
while (decode33.data[decode33.position] !== END_OF_TYPE) {
|
|
81759
|
+
lst.push(decode33.next());
|
|
81678
81760
|
}
|
|
81679
|
-
|
|
81761
|
+
decode33.position++;
|
|
81680
81762
|
return lst;
|
|
81681
81763
|
};
|
|
81682
|
-
|
|
81683
|
-
const end =
|
|
81684
|
-
const number7 = getIntFromBuffer(
|
|
81685
|
-
|
|
81764
|
+
decode33.integer = function() {
|
|
81765
|
+
const end = decode33.find(END_OF_TYPE);
|
|
81766
|
+
const number7 = getIntFromBuffer(decode33.data, decode33.position + 1, end);
|
|
81767
|
+
decode33.position += end + 1 - decode33.position;
|
|
81686
81768
|
return number7;
|
|
81687
81769
|
};
|
|
81688
|
-
|
|
81689
|
-
let sep =
|
|
81690
|
-
const length7 = getIntFromBuffer(
|
|
81770
|
+
decode33.buffer = function() {
|
|
81771
|
+
let sep = decode33.find(STRING_DELIM);
|
|
81772
|
+
const length7 = getIntFromBuffer(decode33.data, decode33.position, sep);
|
|
81691
81773
|
const end = ++sep + length7;
|
|
81692
|
-
|
|
81693
|
-
return
|
|
81774
|
+
decode33.position = end;
|
|
81775
|
+
return decode33.encoding ? arr2text(decode33.data.slice(sep, end)) : decode33.data.slice(sep, end);
|
|
81694
81776
|
};
|
|
81695
|
-
var decode_default =
|
|
81777
|
+
var decode_default = decode33;
|
|
81696
81778
|
|
|
81697
81779
|
// ../../node_modules/.pnpm/bencode@4.0.0/node_modules/bencode/lib/encoding-length.js
|
|
81698
81780
|
init_shim();
|
|
@@ -81909,7 +81991,7 @@ function sizeOf(ip) {
|
|
|
81909
81991
|
function familyOf(string4) {
|
|
81910
81992
|
return sizeOf(string4) === v4.size ? 1 : 2;
|
|
81911
81993
|
}
|
|
81912
|
-
function
|
|
81994
|
+
function encode31(ip, buff, offset) {
|
|
81913
81995
|
offset = ~~offset;
|
|
81914
81996
|
const size = sizeOf(ip);
|
|
81915
81997
|
if (typeof buff === "function") {
|
|
@@ -81920,7 +82002,7 @@ function encode30(ip, buff, offset) {
|
|
|
81920
82002
|
}
|
|
81921
82003
|
return v6.encode(ip, buff, offset);
|
|
81922
82004
|
}
|
|
81923
|
-
function
|
|
82005
|
+
function decode34(buff, offset, length7) {
|
|
81924
82006
|
offset = ~~offset;
|
|
81925
82007
|
length7 = length7 || buff.length - offset;
|
|
81926
82008
|
if (length7 === v4.size) {
|
|
@@ -82362,7 +82444,7 @@ function encodingLength7(str) {
|
|
|
82362
82444
|
}
|
|
82363
82445
|
return len;
|
|
82364
82446
|
}
|
|
82365
|
-
function
|
|
82447
|
+
function encode32(str, buf2, offset) {
|
|
82366
82448
|
const strLen = str.length;
|
|
82367
82449
|
if (offset === void 0 || offset === null) {
|
|
82368
82450
|
offset = 0;
|
|
@@ -82405,11 +82487,11 @@ function encode31(str, buf2, offset) {
|
|
|
82405
82487
|
}
|
|
82406
82488
|
}
|
|
82407
82489
|
}
|
|
82408
|
-
|
|
82490
|
+
encode32.bytes = off - offset;
|
|
82409
82491
|
return buf2;
|
|
82410
82492
|
}
|
|
82411
|
-
|
|
82412
|
-
function
|
|
82493
|
+
encode32.bytes = 0;
|
|
82494
|
+
function decode35(buf2, start2, end) {
|
|
82413
82495
|
let result = "";
|
|
82414
82496
|
if (start2 === void 0 || start2 === null) {
|
|
82415
82497
|
start2 = 0;
|
|
@@ -82434,10 +82516,10 @@ function decode34(buf2, start2, end) {
|
|
|
82434
82516
|
}
|
|
82435
82517
|
result += String.fromCharCode(num3);
|
|
82436
82518
|
}
|
|
82437
|
-
|
|
82519
|
+
decode35.bytes = end - start2;
|
|
82438
82520
|
return result;
|
|
82439
82521
|
}
|
|
82440
|
-
|
|
82522
|
+
decode35.bytes = 0;
|
|
82441
82523
|
|
|
82442
82524
|
// ../../node_modules/.pnpm/@dnsquery+dns-packet@6.1.1/node_modules/@dnsquery/dns-packet/buffer_utils.mjs
|
|
82443
82525
|
var isU8Arr = (input) => input instanceof Uint8Array;
|
|
@@ -82451,14 +82533,14 @@ function from4(input) {
|
|
|
82451
82533
|
if (Array.isArray(input)) {
|
|
82452
82534
|
return new Uint8Array(input);
|
|
82453
82535
|
}
|
|
82454
|
-
return
|
|
82536
|
+
return encode32(input);
|
|
82455
82537
|
}
|
|
82456
82538
|
function write(arr, str, start2) {
|
|
82457
82539
|
if (typeof str !== "string") {
|
|
82458
82540
|
throw new Error("unknown input type");
|
|
82459
82541
|
}
|
|
82460
|
-
|
|
82461
|
-
return
|
|
82542
|
+
encode32(str, arr, start2);
|
|
82543
|
+
return encode32.bytes;
|
|
82462
82544
|
}
|
|
82463
82545
|
var hexNum = {};
|
|
82464
82546
|
var numHex = new Array(255);
|
|
@@ -82559,12 +82641,12 @@ var FLUSH_MASK = 1 << 15;
|
|
|
82559
82641
|
var NOT_FLUSH_MASK = ~FLUSH_MASK;
|
|
82560
82642
|
var QU_MASK = 1 << 15;
|
|
82561
82643
|
var NOT_QU_MASK = ~QU_MASK;
|
|
82562
|
-
function codec({ bytes: bytes6 = 0, encode:
|
|
82563
|
-
|
|
82564
|
-
|
|
82644
|
+
function codec({ bytes: bytes6 = 0, encode: encode44, decode: decode48, encodingLength: encodingLength11 }) {
|
|
82645
|
+
encode44.bytes = bytes6;
|
|
82646
|
+
decode48.bytes = bytes6;
|
|
82565
82647
|
return {
|
|
82566
|
-
encode:
|
|
82567
|
-
decode:
|
|
82648
|
+
encode: encode44,
|
|
82649
|
+
decode: decode48,
|
|
82568
82650
|
encodingLength: encodingLength11 || (() => bytes6)
|
|
82569
82651
|
};
|
|
82570
82652
|
}
|
|
@@ -82609,7 +82691,7 @@ var name4 = codec({
|
|
|
82609
82691
|
if (totalLength > 254) {
|
|
82610
82692
|
throw new Error("Cannot decode name (name too long)");
|
|
82611
82693
|
}
|
|
82612
|
-
list.push(
|
|
82694
|
+
list.push(decode35(buf2, offset, offset + len));
|
|
82613
82695
|
offset += len;
|
|
82614
82696
|
consumedBytes += jumped ? 0 : len;
|
|
82615
82697
|
} else if ((len & 192) === 192) {
|
|
@@ -82648,7 +82730,7 @@ var string3 = codec({
|
|
|
82648
82730
|
decode(buf2, offset) {
|
|
82649
82731
|
if (!offset) offset = 0;
|
|
82650
82732
|
const len = buf2[offset];
|
|
82651
|
-
const s2 =
|
|
82733
|
+
const s2 = decode35(buf2, offset + 1, offset + 1 + len);
|
|
82652
82734
|
string3.decode.bytes = len + 1;
|
|
82653
82735
|
return s2;
|
|
82654
82736
|
},
|
|
@@ -82982,7 +83064,7 @@ var rcaa = codec({
|
|
|
82982
83064
|
offset += 1;
|
|
82983
83065
|
data.tag = string3.decode(buf2, offset);
|
|
82984
83066
|
offset += string3.decode.bytes;
|
|
82985
|
-
data.value =
|
|
83067
|
+
data.value = decode35(buf2, offset, oldOffset + len);
|
|
82986
83068
|
data.issuerCritical = !!(data.flags & rcaa.ISSUER_CRITICAL);
|
|
82987
83069
|
rcaa.decode.bytes = len + 2;
|
|
82988
83070
|
return data;
|
|
@@ -83080,7 +83162,7 @@ var roption = codec({
|
|
|
83080
83162
|
{
|
|
83081
83163
|
const spl = option.sourcePrefixLength || 0;
|
|
83082
83164
|
const fam = option.family || familyOf(option.ip, alloc2);
|
|
83083
|
-
const ipBuf =
|
|
83165
|
+
const ipBuf = encode31(option.ip, alloc2);
|
|
83084
83166
|
const ipLen = Math.ceil(spl / 8);
|
|
83085
83167
|
writeUInt16BE(buf2, ipLen + 4, offset);
|
|
83086
83168
|
offset += 2;
|
|
@@ -83152,7 +83234,7 @@ var roption = codec({
|
|
|
83152
83234
|
{
|
|
83153
83235
|
const padded = new Uint8Array(option.family === 1 ? 4 : 16);
|
|
83154
83236
|
copy(buf2, padded, 0, offset, offset + len - 4);
|
|
83155
|
-
option.ip =
|
|
83237
|
+
option.ip = decode34(padded);
|
|
83156
83238
|
}
|
|
83157
83239
|
break;
|
|
83158
83240
|
// case 12: Padding. No decode makes sense.
|
|
@@ -83778,8 +83860,8 @@ var packet = {
|
|
|
83778
83860
|
offset = encodeList(result.authorities, answer, buf2, offset);
|
|
83779
83861
|
offset = encodeList(result.additionals, answer, buf2, offset);
|
|
83780
83862
|
packet.encode.bytes = offset - oldOffset;
|
|
83781
|
-
if (allocing &&
|
|
83782
|
-
return buf2.slice(0,
|
|
83863
|
+
if (allocing && encode33.bytes !== buf2.length) {
|
|
83864
|
+
return buf2.slice(0, encode33.bytes);
|
|
83783
83865
|
}
|
|
83784
83866
|
return buf2;
|
|
83785
83867
|
},
|
|
@@ -83856,11 +83938,11 @@ var response = {
|
|
|
83856
83938
|
};
|
|
83857
83939
|
response.encode.bytes = 0;
|
|
83858
83940
|
response.decode.bytes = 0;
|
|
83859
|
-
var
|
|
83860
|
-
var
|
|
83941
|
+
var encode33 = packet.encode;
|
|
83942
|
+
var decode36 = packet.decode;
|
|
83861
83943
|
var encodingLength8 = packet.encodingLength;
|
|
83862
83944
|
function streamEncode(result) {
|
|
83863
|
-
const buf2 =
|
|
83945
|
+
const buf2 = encode33(result);
|
|
83864
83946
|
const combine3 = new Uint8Array(2 + buf2.byteLength);
|
|
83865
83947
|
writeUInt16BE(combine3, buf2.byteLength);
|
|
83866
83948
|
copy(buf2, combine3, 2, 0, buf2.length);
|
|
@@ -83873,8 +83955,8 @@ function streamDecode(sbuf) {
|
|
|
83873
83955
|
if (sbuf.byteLength < len + 2) {
|
|
83874
83956
|
return null;
|
|
83875
83957
|
}
|
|
83876
|
-
const result =
|
|
83877
|
-
streamDecode.bytes =
|
|
83958
|
+
const result = decode36(sbuf.slice(2));
|
|
83959
|
+
streamDecode.bytes = decode36.bytes;
|
|
83878
83960
|
return result;
|
|
83879
83961
|
}
|
|
83880
83962
|
streamDecode.bytes = 0;
|
|
@@ -84673,7 +84755,7 @@ var DidDhtUtils = class _DidDhtUtils {
|
|
|
84673
84755
|
static createBep44PutMessage(_a3) {
|
|
84674
84756
|
return __awaiter15(this, arguments, void 0, function* ({ dnsPacket, publicKeyBytes, signer }) {
|
|
84675
84757
|
const sequenceNumber = Math.ceil(Date.now() / 1e3);
|
|
84676
|
-
const encodedDnsPacket =
|
|
84758
|
+
const encodedDnsPacket = encode33(dnsPacket);
|
|
84677
84759
|
const bencodedData = bencode_default.encode({ seq: sequenceNumber, v: encodedDnsPacket }).subarray(1, -1);
|
|
84678
84760
|
if (bencodedData.length > 1e3) {
|
|
84679
84761
|
throw new DidError(DidErrorCode.InvalidDidDocumentLength, `DNS packet exceeds the 1000 byte maximum size: ${bencodedData.length} bytes`);
|
|
@@ -84798,7 +84880,7 @@ var DidDhtUtils = class _DidDhtUtils {
|
|
|
84798
84880
|
if (!isValid2) {
|
|
84799
84881
|
throw new DidError(DidErrorCode.InvalidSignature, `Invalid signature for DHT BEP44 message`);
|
|
84800
84882
|
}
|
|
84801
|
-
return
|
|
84883
|
+
return decode36(bep44Message.v);
|
|
84802
84884
|
});
|
|
84803
84885
|
}
|
|
84804
84886
|
/**
|
|
@@ -85072,8 +85154,8 @@ var Codec3 = class {
|
|
|
85072
85154
|
return this.decoder.decode(input);
|
|
85073
85155
|
}
|
|
85074
85156
|
};
|
|
85075
|
-
var from5 = ({ name: name10, prefix, encode:
|
|
85076
|
-
var
|
|
85157
|
+
var from5 = ({ name: name10, prefix, encode: encode44, decode: decode48 }) => new Codec3(name10, prefix, encode44, decode48);
|
|
85158
|
+
var decode37 = (string4, alphabet6, bitsPerChar, name10) => {
|
|
85077
85159
|
const codes = {};
|
|
85078
85160
|
for (let i4 = 0; i4 < alphabet6.length; ++i4) {
|
|
85079
85161
|
codes[alphabet6[i4]] = i4;
|
|
@@ -85103,7 +85185,7 @@ var decode36 = (string4, alphabet6, bitsPerChar, name10) => {
|
|
|
85103
85185
|
}
|
|
85104
85186
|
return out;
|
|
85105
85187
|
};
|
|
85106
|
-
var
|
|
85188
|
+
var encode34 = (data, alphabet6, bitsPerChar) => {
|
|
85107
85189
|
const pad2 = alphabet6[alphabet6.length - 1] === "=";
|
|
85108
85190
|
const mask = (1 << bitsPerChar) - 1;
|
|
85109
85191
|
let out = "";
|
|
@@ -85132,10 +85214,10 @@ var rfc46483 = ({ name: name10, prefix, bitsPerChar, alphabet: alphabet6 }) => {
|
|
|
85132
85214
|
prefix,
|
|
85133
85215
|
name: name10,
|
|
85134
85216
|
encode(input) {
|
|
85135
|
-
return
|
|
85217
|
+
return encode34(input, alphabet6, bitsPerChar);
|
|
85136
85218
|
},
|
|
85137
85219
|
decode(input) {
|
|
85138
|
-
return
|
|
85220
|
+
return decode37(input, alphabet6, bitsPerChar, name10);
|
|
85139
85221
|
}
|
|
85140
85222
|
});
|
|
85141
85223
|
};
|
|
@@ -85337,12 +85419,12 @@ init_shim();
|
|
|
85337
85419
|
|
|
85338
85420
|
// ../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/vendor/varint.js
|
|
85339
85421
|
init_shim();
|
|
85340
|
-
var encode_13 =
|
|
85422
|
+
var encode_13 = encode35;
|
|
85341
85423
|
var MSB3 = 128;
|
|
85342
85424
|
var REST3 = 127;
|
|
85343
85425
|
var MSBALL3 = ~REST3;
|
|
85344
85426
|
var INT3 = Math.pow(2, 31);
|
|
85345
|
-
function
|
|
85427
|
+
function encode35(num3, out, offset) {
|
|
85346
85428
|
out = out || [];
|
|
85347
85429
|
offset = offset || 0;
|
|
85348
85430
|
var oldOffset = offset;
|
|
@@ -85355,10 +85437,10 @@ function encode34(num3, out, offset) {
|
|
|
85355
85437
|
num3 >>>= 7;
|
|
85356
85438
|
}
|
|
85357
85439
|
out[offset] = num3 | 0;
|
|
85358
|
-
|
|
85440
|
+
encode35.bytes = offset - oldOffset + 1;
|
|
85359
85441
|
return out;
|
|
85360
85442
|
}
|
|
85361
|
-
var
|
|
85443
|
+
var decode38 = read3;
|
|
85362
85444
|
var MSB$13 = 128;
|
|
85363
85445
|
var REST$13 = 127;
|
|
85364
85446
|
function read3(buf2, offset) {
|
|
@@ -85389,14 +85471,14 @@ var length4 = function(value3) {
|
|
|
85389
85471
|
};
|
|
85390
85472
|
var varint3 = {
|
|
85391
85473
|
encode: encode_13,
|
|
85392
|
-
decode:
|
|
85474
|
+
decode: decode38,
|
|
85393
85475
|
encodingLength: length4
|
|
85394
85476
|
};
|
|
85395
85477
|
var _brrp_varint3 = varint3;
|
|
85396
85478
|
var varint_default3 = _brrp_varint3;
|
|
85397
85479
|
|
|
85398
85480
|
// ../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/varint.js
|
|
85399
|
-
var
|
|
85481
|
+
var decode39 = (data, offset = 0) => {
|
|
85400
85482
|
const code8 = varint_default3.decode(data, offset);
|
|
85401
85483
|
return [code8, varint_default3.decode.bytes];
|
|
85402
85484
|
};
|
|
@@ -85419,10 +85501,10 @@ var create3 = (code8, digest2) => {
|
|
|
85419
85501
|
bytes6.set(digest2, digestOffset);
|
|
85420
85502
|
return new Digest3(code8, size, digest2, bytes6);
|
|
85421
85503
|
};
|
|
85422
|
-
var
|
|
85504
|
+
var decode40 = (multihash) => {
|
|
85423
85505
|
const bytes6 = coerce3(multihash);
|
|
85424
|
-
const [code8, sizeOffset] =
|
|
85425
|
-
const [size, digestOffset] =
|
|
85506
|
+
const [code8, sizeOffset] = decode39(bytes6);
|
|
85507
|
+
const [size, digestOffset] = decode39(bytes6.subarray(sizeOffset));
|
|
85426
85508
|
const digest2 = bytes6.subarray(sizeOffset + digestOffset);
|
|
85427
85509
|
if (digest2.byteLength !== size) {
|
|
85428
85510
|
throw new Error("Incorrect length");
|
|
@@ -85451,7 +85533,7 @@ init_shim();
|
|
|
85451
85533
|
|
|
85452
85534
|
// ../../node_modules/.pnpm/multiformats@12.1.3/node_modules/multiformats/src/hashes/hasher.js
|
|
85453
85535
|
init_shim();
|
|
85454
|
-
var from6 = ({ name: name10, code: code8, encode:
|
|
85536
|
+
var from6 = ({ name: name10, code: code8, encode: encode44 }) => new Hasher2(name10, code8, encode44);
|
|
85455
85537
|
var Hasher2 = class {
|
|
85456
85538
|
/**
|
|
85457
85539
|
*
|
|
@@ -85459,10 +85541,10 @@ var Hasher2 = class {
|
|
|
85459
85541
|
* @param {Code} code
|
|
85460
85542
|
* @param {(input: Uint8Array) => Await<Uint8Array>} encode
|
|
85461
85543
|
*/
|
|
85462
|
-
constructor(name10, code8,
|
|
85544
|
+
constructor(name10, code8, encode44) {
|
|
85463
85545
|
this.name = name10;
|
|
85464
85546
|
this.code = code8;
|
|
85465
|
-
this.encode =
|
|
85547
|
+
this.encode = encode44;
|
|
85466
85548
|
}
|
|
85467
85549
|
/**
|
|
85468
85550
|
* @param {Uint8Array} input
|
|
@@ -85603,7 +85685,7 @@ var Multihash = class _Multihash {
|
|
|
85603
85685
|
let multihash;
|
|
85604
85686
|
const multihashBytes = Encoder4.decodeAsBytes(encodedMultihash, inputContextForErrorLogging);
|
|
85605
85687
|
try {
|
|
85606
|
-
multihash =
|
|
85688
|
+
multihash = decode40(multihashBytes);
|
|
85607
85689
|
} catch (_a3) {
|
|
85608
85690
|
throw new IonError(ErrorCode_default.MultihashStringNotAMultihash, `Given ${inputContextForErrorLogging} string '${encodedMultihash}' is not a multihash after decoding.`);
|
|
85609
85691
|
}
|
|
@@ -91164,7 +91246,7 @@ function encodeCustom(data, encoders, options2) {
|
|
|
91164
91246
|
tokensToEncoded(buf, tokens, encoders, options2);
|
|
91165
91247
|
return buf.toBytes(true);
|
|
91166
91248
|
}
|
|
91167
|
-
function
|
|
91249
|
+
function encode36(data, options2) {
|
|
91168
91250
|
options2 = Object.assign({}, defaultEncodeOptions, options2);
|
|
91169
91251
|
return encodeCustom(data, cborEncoders, options2);
|
|
91170
91252
|
}
|
|
@@ -91303,7 +91385,7 @@ function decodeFirst(data, options2) {
|
|
|
91303
91385
|
}
|
|
91304
91386
|
return [decoded, data.subarray(tokeniser.pos())];
|
|
91305
91387
|
}
|
|
91306
|
-
function
|
|
91388
|
+
function decode41(data, options2) {
|
|
91307
91389
|
const [decoded, remainder] = decodeFirst(data, options2);
|
|
91308
91390
|
if (remainder.length > 0) {
|
|
91309
91391
|
throw new Error(`${decodeErrPrefix} too many terminals, data makes no sense`);
|
|
@@ -91859,7 +91941,7 @@ var PinsImpl = class {
|
|
|
91859
91941
|
depth,
|
|
91860
91942
|
metadata: options2.metadata ?? {}
|
|
91861
91943
|
};
|
|
91862
|
-
await this.datastore.put(pinKey,
|
|
91944
|
+
await this.datastore.put(pinKey, encode36(pin), options2);
|
|
91863
91945
|
}
|
|
91864
91946
|
/**
|
|
91865
91947
|
* Walk a DAG in an iterable fashion
|
|
@@ -91891,7 +91973,7 @@ var PinsImpl = class {
|
|
|
91891
91973
|
pinnedBy: []
|
|
91892
91974
|
};
|
|
91893
91975
|
try {
|
|
91894
|
-
pinnedBlock =
|
|
91976
|
+
pinnedBlock = decode41(await this.datastore.get(blockKey, options2));
|
|
91895
91977
|
} catch (err) {
|
|
91896
91978
|
if (err.name !== "NotFoundError") {
|
|
91897
91979
|
throw err;
|
|
@@ -91907,13 +91989,13 @@ var PinsImpl = class {
|
|
|
91907
91989
|
return;
|
|
91908
91990
|
}
|
|
91909
91991
|
}
|
|
91910
|
-
await this.datastore.put(blockKey,
|
|
91992
|
+
await this.datastore.put(blockKey, encode36(pinnedBlock), options2);
|
|
91911
91993
|
options2.onProgress?.(new CustomProgressEvent("helia:pin:add", cid));
|
|
91912
91994
|
}
|
|
91913
91995
|
async *rm(cid, options2 = {}) {
|
|
91914
91996
|
const pinKey = toDSKey(cid);
|
|
91915
91997
|
const buf2 = await this.datastore.get(pinKey, options2);
|
|
91916
|
-
const pin =
|
|
91998
|
+
const pin = decode41(buf2);
|
|
91917
91999
|
await this.datastore.delete(pinKey, options2);
|
|
91918
92000
|
const queue = new Queue3({
|
|
91919
92001
|
concurrency: DAG_WALK_QUEUE_CONCURRENCY
|
|
@@ -91938,7 +92020,7 @@ var PinsImpl = class {
|
|
|
91938
92020
|
prefix: DATASTORE_PIN_PREFIX + (options2.cid != null ? `${options2.cid.toString(base36)}` : "")
|
|
91939
92021
|
}, options2)) {
|
|
91940
92022
|
const cid = CID.parse(key.toString().substring(5), base36);
|
|
91941
|
-
const pin =
|
|
92023
|
+
const pin = decode41(value3);
|
|
91942
92024
|
yield {
|
|
91943
92025
|
cid,
|
|
91944
92026
|
...pin
|
|
@@ -91952,14 +92034,14 @@ var PinsImpl = class {
|
|
|
91952
92034
|
async get(cid, options2) {
|
|
91953
92035
|
const pinKey = toDSKey(cid);
|
|
91954
92036
|
const buf2 = await this.datastore.get(pinKey, options2);
|
|
91955
|
-
return
|
|
92037
|
+
return decode41(buf2);
|
|
91956
92038
|
}
|
|
91957
92039
|
async setMetadata(cid, metadata, options2) {
|
|
91958
92040
|
const pinKey = toDSKey(cid);
|
|
91959
92041
|
const buf2 = await this.datastore.get(pinKey, options2);
|
|
91960
|
-
const pin =
|
|
92042
|
+
const pin = decode41(buf2);
|
|
91961
92043
|
pin.metadata = metadata ?? {};
|
|
91962
|
-
await this.datastore.put(pinKey,
|
|
92044
|
+
await this.datastore.put(pinKey, encode36(pin), options2);
|
|
91963
92045
|
}
|
|
91964
92046
|
};
|
|
91965
92047
|
|
|
@@ -93230,9 +93312,9 @@ init_shim();
|
|
|
93230
93312
|
var src_exports = {};
|
|
93231
93313
|
__export(src_exports, {
|
|
93232
93314
|
code: () => code4,
|
|
93233
|
-
decode: () =>
|
|
93315
|
+
decode: () => decode42,
|
|
93234
93316
|
decodeOptions: () => decodeOptions,
|
|
93235
|
-
encode: () =>
|
|
93317
|
+
encode: () => encode37,
|
|
93236
93318
|
encodeOptions: () => encodeOptions,
|
|
93237
93319
|
name: () => name5,
|
|
93238
93320
|
toByteView: () => toByteView
|
|
@@ -93322,15 +93404,15 @@ var decodeOptions = {
|
|
|
93322
93404
|
};
|
|
93323
93405
|
var name5 = "dag-cbor";
|
|
93324
93406
|
var code4 = 113;
|
|
93325
|
-
var
|
|
93326
|
-
var
|
|
93407
|
+
var encode37 = (node) => encode36(node, _encodeOptions);
|
|
93408
|
+
var decode42 = (data) => decode41(toByteView(data), _decodeOptions);
|
|
93327
93409
|
|
|
93328
93410
|
// ../../node_modules/.pnpm/@ipld+dag-json@10.2.5/node_modules/@ipld/dag-json/src/index.js
|
|
93329
93411
|
var src_exports2 = {};
|
|
93330
93412
|
__export(src_exports2, {
|
|
93331
93413
|
code: () => code5,
|
|
93332
|
-
decode: () =>
|
|
93333
|
-
encode: () =>
|
|
93414
|
+
decode: () => decode44,
|
|
93415
|
+
encode: () => encode39,
|
|
93334
93416
|
format: () => format3,
|
|
93335
93417
|
name: () => name6,
|
|
93336
93418
|
parse: () => parse5,
|
|
@@ -93499,7 +93581,7 @@ function mapSorter2(e1, e2) {
|
|
|
93499
93581
|
throw new Error(`${encodeErrPrefix} unexpected duplicate map keys, this is not supported`);
|
|
93500
93582
|
}
|
|
93501
93583
|
var defaultEncodeOptions2 = { addBreakTokens: true, mapSorter: mapSorter2 };
|
|
93502
|
-
function
|
|
93584
|
+
function encode38(data, options2) {
|
|
93503
93585
|
options2 = Object.assign({}, defaultEncodeOptions2, options2);
|
|
93504
93586
|
return encodeCustom(data, new JSONEncoder(), options2);
|
|
93505
93587
|
}
|
|
@@ -93900,9 +93982,9 @@ var Tokenizer = class {
|
|
|
93900
93982
|
}
|
|
93901
93983
|
}
|
|
93902
93984
|
};
|
|
93903
|
-
function
|
|
93985
|
+
function decode43(data, options2) {
|
|
93904
93986
|
options2 = Object.assign({ tokenizer: new Tokenizer(data, options2) }, options2);
|
|
93905
|
-
return
|
|
93987
|
+
return decode41(data, options2);
|
|
93906
93988
|
}
|
|
93907
93989
|
|
|
93908
93990
|
// ../../node_modules/.pnpm/@ipld+dag-json@10.2.5/node_modules/@ipld/dag-json/src/index.js
|
|
@@ -94070,15 +94152,15 @@ var decodeOptions2 = {
|
|
|
94070
94152
|
decodeOptions2.tags[42] = CID.parse;
|
|
94071
94153
|
var name6 = "dag-json";
|
|
94072
94154
|
var code5 = 297;
|
|
94073
|
-
var
|
|
94074
|
-
var
|
|
94155
|
+
var encode39 = (node) => encode38(node, encodeOptions2);
|
|
94156
|
+
var decode44 = (data) => {
|
|
94075
94157
|
const buf2 = toByteView2(data);
|
|
94076
94158
|
const options2 = Object.assign(decodeOptions2, { tokenizer: new DagJsonTokenizer(buf2, decodeOptions2) });
|
|
94077
|
-
return
|
|
94159
|
+
return decode43(buf2, options2);
|
|
94078
94160
|
};
|
|
94079
|
-
var format3 = (node) => utf8Decoder3.decode(
|
|
94161
|
+
var format3 = (node) => utf8Decoder3.decode(encode39(node));
|
|
94080
94162
|
var utf8Decoder3 = new TextDecoder();
|
|
94081
|
-
var parse5 = (data) =>
|
|
94163
|
+
var parse5 = (data) => decode44(utf8Encoder3.encode(data));
|
|
94082
94164
|
var utf8Encoder3 = new TextEncoder();
|
|
94083
94165
|
|
|
94084
94166
|
// ../../node_modules/.pnpm/@ipld+dag-pb@4.1.5/node_modules/@ipld/dag-pb/src/index.js
|
|
@@ -94087,8 +94169,8 @@ __export(src_exports3, {
|
|
|
94087
94169
|
code: () => code6,
|
|
94088
94170
|
createLink: () => createLink,
|
|
94089
94171
|
createNode: () => createNode,
|
|
94090
|
-
decode: () =>
|
|
94091
|
-
encode: () =>
|
|
94172
|
+
decode: () => decode45,
|
|
94173
|
+
encode: () => encode40,
|
|
94092
94174
|
name: () => name7,
|
|
94093
94175
|
prepare: () => prepare,
|
|
94094
94176
|
validate: () => validate3
|
|
@@ -94756,7 +94838,7 @@ function toByteView3(buf2) {
|
|
|
94756
94838
|
// ../../node_modules/.pnpm/@ipld+dag-pb@4.1.5/node_modules/@ipld/dag-pb/src/index.js
|
|
94757
94839
|
var name7 = "dag-pb";
|
|
94758
94840
|
var code6 = 112;
|
|
94759
|
-
function
|
|
94841
|
+
function encode40(node) {
|
|
94760
94842
|
validate3(node);
|
|
94761
94843
|
const pbn = {};
|
|
94762
94844
|
if (node.Links) {
|
|
@@ -94779,7 +94861,7 @@ function encode39(node) {
|
|
|
94779
94861
|
}
|
|
94780
94862
|
return encodeNode(pbn);
|
|
94781
94863
|
}
|
|
94782
|
-
function
|
|
94864
|
+
function decode45(bytes6) {
|
|
94783
94865
|
const buf2 = toByteView3(bytes6);
|
|
94784
94866
|
const pbn = decodeNode(buf2);
|
|
94785
94867
|
const node = {};
|
|
@@ -97768,7 +97850,7 @@ function decodeUint8ArrayList(buf2, offset) {
|
|
|
97768
97850
|
}
|
|
97769
97851
|
throw new RangeError("Could not decode varint");
|
|
97770
97852
|
}
|
|
97771
|
-
function
|
|
97853
|
+
function encode41(value3, buf2, offset = 0) {
|
|
97772
97854
|
if (buf2 == null) {
|
|
97773
97855
|
buf2 = allocUnsafe(encodingLength10(value3));
|
|
97774
97856
|
}
|
|
@@ -97778,7 +97860,7 @@ function encode40(value3, buf2, offset = 0) {
|
|
|
97778
97860
|
return encodeUint8ArrayList(value3, buf2, offset);
|
|
97779
97861
|
}
|
|
97780
97862
|
}
|
|
97781
|
-
function
|
|
97863
|
+
function decode46(buf2, offset = 0) {
|
|
97782
97864
|
if (buf2 instanceof Uint8Array) {
|
|
97783
97865
|
return decodeUint8Array(buf2, offset);
|
|
97784
97866
|
} else {
|
|
@@ -98840,12 +98922,12 @@ var CODEC_TYPES;
|
|
|
98840
98922
|
CODEC_TYPES2[CODEC_TYPES2["END_GROUP"] = 4] = "END_GROUP";
|
|
98841
98923
|
CODEC_TYPES2[CODEC_TYPES2["BIT32"] = 5] = "BIT32";
|
|
98842
98924
|
})(CODEC_TYPES || (CODEC_TYPES = {}));
|
|
98843
|
-
function createCodec2(name10, type,
|
|
98925
|
+
function createCodec2(name10, type, encode44, decode48) {
|
|
98844
98926
|
return {
|
|
98845
98927
|
name: name10,
|
|
98846
98928
|
type,
|
|
98847
|
-
encode:
|
|
98848
|
-
decode:
|
|
98929
|
+
encode: encode44,
|
|
98930
|
+
decode: decode48
|
|
98849
98931
|
};
|
|
98850
98932
|
}
|
|
98851
98933
|
|
|
@@ -98857,21 +98939,21 @@ function enumeration(v) {
|
|
|
98857
98939
|
}
|
|
98858
98940
|
return v[val];
|
|
98859
98941
|
}
|
|
98860
|
-
const
|
|
98942
|
+
const encode44 = function enumEncode(val, writer) {
|
|
98861
98943
|
const enumValue = findValue(val);
|
|
98862
98944
|
writer.int32(enumValue);
|
|
98863
98945
|
};
|
|
98864
|
-
const
|
|
98946
|
+
const decode48 = function enumDecode(reader) {
|
|
98865
98947
|
const val = reader.int32();
|
|
98866
98948
|
return findValue(val);
|
|
98867
98949
|
};
|
|
98868
|
-
return createCodec2("enum", CODEC_TYPES.VARINT,
|
|
98950
|
+
return createCodec2("enum", CODEC_TYPES.VARINT, encode44, decode48);
|
|
98869
98951
|
}
|
|
98870
98952
|
|
|
98871
98953
|
// ../../node_modules/.pnpm/protons-runtime@5.6.0/node_modules/protons-runtime/dist/src/codecs/message.js
|
|
98872
98954
|
init_shim();
|
|
98873
|
-
function message(
|
|
98874
|
-
return createCodec2("message", CODEC_TYPES.LENGTH_DELIMITED,
|
|
98955
|
+
function message(encode44, decode48) {
|
|
98956
|
+
return createCodec2("message", CODEC_TYPES.LENGTH_DELIMITED, encode44, decode48);
|
|
98875
98957
|
}
|
|
98876
98958
|
|
|
98877
98959
|
// ../../node_modules/.pnpm/protons-runtime@5.6.0/node_modules/protons-runtime/dist/src/index.js
|
|
@@ -100373,12 +100455,12 @@ function validateMaxDataLength(chunk, maxDataLength) {
|
|
|
100373
100455
|
var defaultEncoder = (length7) => {
|
|
100374
100456
|
const lengthLength = encodingLength10(length7);
|
|
100375
100457
|
const lengthBuf = allocUnsafe(lengthLength);
|
|
100376
|
-
|
|
100458
|
+
encode41(length7, lengthBuf);
|
|
100377
100459
|
defaultEncoder.bytes = lengthLength;
|
|
100378
100460
|
return lengthBuf;
|
|
100379
100461
|
};
|
|
100380
100462
|
defaultEncoder.bytes = 0;
|
|
100381
|
-
function
|
|
100463
|
+
function encode42(source, options2) {
|
|
100382
100464
|
options2 = options2 ?? {};
|
|
100383
100465
|
const encodeLength2 = options2.lengthEncoder ?? defaultEncoder;
|
|
100384
100466
|
const maxDataLength = options2?.maxDataLength ?? MAX_DATA_LENGTH;
|
|
@@ -100409,7 +100491,7 @@ function encode41(source, options2) {
|
|
|
100409
100491
|
}
|
|
100410
100492
|
}();
|
|
100411
100493
|
}
|
|
100412
|
-
|
|
100494
|
+
encode42.single = (chunk, options2) => {
|
|
100413
100495
|
options2 = options2 ?? {};
|
|
100414
100496
|
const encodeLength2 = options2.lengthEncoder ?? defaultEncoder;
|
|
100415
100497
|
const maxDataLength = options2?.maxDataLength ?? MAX_DATA_LENGTH;
|
|
@@ -100425,12 +100507,12 @@ var ReadMode;
|
|
|
100425
100507
|
ReadMode2[ReadMode2["DATA"] = 1] = "DATA";
|
|
100426
100508
|
})(ReadMode || (ReadMode = {}));
|
|
100427
100509
|
var defaultDecoder = (buf2) => {
|
|
100428
|
-
const length7 =
|
|
100510
|
+
const length7 = decode46(buf2);
|
|
100429
100511
|
defaultDecoder.bytes = encodingLength10(length7);
|
|
100430
100512
|
return length7;
|
|
100431
100513
|
};
|
|
100432
100514
|
defaultDecoder.bytes = 0;
|
|
100433
|
-
function
|
|
100515
|
+
function decode47(source, options2) {
|
|
100434
100516
|
const buffer2 = new Uint8ArrayList();
|
|
100435
100517
|
let mode = ReadMode.LENGTH;
|
|
100436
100518
|
let dataLength = -1;
|
|
@@ -100499,7 +100581,7 @@ function decode46(source, options2) {
|
|
|
100499
100581
|
}
|
|
100500
100582
|
}();
|
|
100501
100583
|
}
|
|
100502
|
-
|
|
100584
|
+
decode47.fromReader = (reader, options2) => {
|
|
100503
100585
|
let byteLength = 1;
|
|
100504
100586
|
const varByteSource = async function* () {
|
|
100505
100587
|
while (true) {
|
|
@@ -100524,7 +100606,7 @@ decode46.fromReader = (reader, options2) => {
|
|
|
100524
100606
|
const onLength = (l2) => {
|
|
100525
100607
|
byteLength = l2;
|
|
100526
100608
|
};
|
|
100527
|
-
return
|
|
100609
|
+
return decode47(varByteSource, {
|
|
100528
100610
|
...options2 ?? {},
|
|
100529
100611
|
onLength
|
|
100530
100612
|
});
|
|
@@ -101297,7 +101379,7 @@ var Network = class extends TypedEventEmitter {
|
|
|
101297
101379
|
setMaxListeners(Infinity, signal);
|
|
101298
101380
|
signal.addEventListener("abort", abortListener);
|
|
101299
101381
|
await stream.closeWrite();
|
|
101300
|
-
await pipe2(stream, (source) =>
|
|
101382
|
+
await pipe2(stream, (source) => decode47(source, {
|
|
101301
101383
|
maxDataLength: this.maxIncomingMessageSize
|
|
101302
101384
|
}), async (source) => {
|
|
101303
101385
|
for await (const data of source) {
|
|
@@ -101382,7 +101464,7 @@ var Network = class extends TypedEventEmitter {
|
|
|
101382
101464
|
const stream = await this.libp2p.dialProtocol(peerId, BITSWAP_120, options3);
|
|
101383
101465
|
await stream.closeRead();
|
|
101384
101466
|
try {
|
|
101385
|
-
await pipe2(splitMessage(message3, this.maxOutgoingMessageSize), (source) =>
|
|
101467
|
+
await pipe2(splitMessage(message3, this.maxOutgoingMessageSize), (source) => encode42(source), stream);
|
|
101386
101468
|
await stream.close(options3);
|
|
101387
101469
|
} catch (err) {
|
|
101388
101470
|
options3?.onProgress?.(new CustomProgressEvent("bitswap:network:send-wantlist:error", { peer: peerId, error: err }));
|
|
@@ -101583,14 +101665,14 @@ var TRANSPORT_IPFS_GATEWAY_HTTP_CODE2 = 2336;
|
|
|
101583
101665
|
function peerIdFromString(str, decoder2) {
|
|
101584
101666
|
let multihash;
|
|
101585
101667
|
if (str.charAt(0) === "1" || str.charAt(0) === "Q") {
|
|
101586
|
-
multihash =
|
|
101668
|
+
multihash = decode24(base58btc.decode(`z${str}`));
|
|
101587
101669
|
} else if (str.startsWith("k51qzi5uqu5") || str.startsWith("kzwfwjn5ji4") || str.startsWith("k2k4r8") || str.startsWith("bafz")) {
|
|
101588
101670
|
return peerIdFromCID(CID.parse(str));
|
|
101589
101671
|
} else {
|
|
101590
101672
|
if (decoder2 == null) {
|
|
101591
101673
|
throw new InvalidParametersError('Please pass a multibase decoder for strings that do not start with "1" or "Q"');
|
|
101592
101674
|
}
|
|
101593
|
-
multihash =
|
|
101675
|
+
multihash = decode24(decoder2.decode(str));
|
|
101594
101676
|
}
|
|
101595
101677
|
return peerIdFromMultihash(multihash);
|
|
101596
101678
|
}
|
|
@@ -101676,7 +101758,7 @@ function mapIterable(iter, map3) {
|
|
|
101676
101758
|
return iterator;
|
|
101677
101759
|
}
|
|
101678
101760
|
function peerIdFromString2(str) {
|
|
101679
|
-
const multihash =
|
|
101761
|
+
const multihash = decode24(base58btc.decode(`z${str}`));
|
|
101680
101762
|
return peerIdFromMultihash(multihash);
|
|
101681
101763
|
}
|
|
101682
101764
|
|
|
@@ -101915,7 +101997,7 @@ function varintEncoder(buf2) {
|
|
|
101915
101997
|
}, 0));
|
|
101916
101998
|
let offset = 0;
|
|
101917
101999
|
for (const num3 of buf2) {
|
|
101918
|
-
out =
|
|
102000
|
+
out = encode41(num3, out, offset);
|
|
101919
102001
|
offset += encodingLength10(num3);
|
|
101920
102002
|
}
|
|
101921
102003
|
return out;
|
|
@@ -102285,7 +102367,7 @@ function varintDecoder(buf2) {
|
|
|
102285
102367
|
}
|
|
102286
102368
|
const result = [];
|
|
102287
102369
|
while (buf2.length > 0) {
|
|
102288
|
-
const num3 =
|
|
102370
|
+
const num3 = decode46(buf2);
|
|
102289
102371
|
result.push(num3);
|
|
102290
102372
|
buf2 = buf2.slice(encodingLength10(num3));
|
|
102291
102373
|
}
|
|
@@ -103509,7 +103591,7 @@ function bytesToComponents(bytes6) {
|
|
|
103509
103591
|
const components = [];
|
|
103510
103592
|
let i4 = 0;
|
|
103511
103593
|
while (i4 < bytes6.length) {
|
|
103512
|
-
const code8 =
|
|
103594
|
+
const code8 = decode46(bytes6, i4);
|
|
103513
103595
|
const codec2 = registry.getProtocol(code8);
|
|
103514
103596
|
const codeLength = encodingLength10(code8);
|
|
103515
103597
|
const size = sizeForAddr(codec2, bytes6, i4 + codeLength);
|
|
@@ -103647,7 +103729,7 @@ function sizeForAddr(codec2, bytes6, offset) {
|
|
|
103647
103729
|
if (codec2.size > 0) {
|
|
103648
103730
|
return codec2.size / 8;
|
|
103649
103731
|
}
|
|
103650
|
-
return
|
|
103732
|
+
return decode46(bytes6, offset);
|
|
103651
103733
|
}
|
|
103652
103734
|
|
|
103653
103735
|
// ../../node_modules/.pnpm/@multiformats+multiaddr@12.5.1/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js
|
|
@@ -105273,14 +105355,14 @@ function multihashToIPNSRoutingKey(digest2) {
|
|
|
105273
105355
|
]);
|
|
105274
105356
|
}
|
|
105275
105357
|
function multihashFromIPNSRoutingKey(key) {
|
|
105276
|
-
const digest2 =
|
|
105358
|
+
const digest2 = decode24(key.slice(IPNS_PREFIX.length));
|
|
105277
105359
|
if (!isCodec(digest2, IDENTITY_CODEC2) && !isCodec(digest2, SHA2_256_CODEC)) {
|
|
105278
105360
|
throw new InvalidMultihashError("Multihash in IPNS key was not identity or sha2-256");
|
|
105279
105361
|
}
|
|
105280
105362
|
return digest2;
|
|
105281
105363
|
}
|
|
105282
105364
|
function parseCborData(buf2) {
|
|
105283
|
-
const data =
|
|
105365
|
+
const data = decode41(buf2);
|
|
105284
105366
|
if (data.ValidityType === 0) {
|
|
105285
105367
|
data.ValidityType = IpnsEntry.ValidityType.EOL;
|
|
105286
105368
|
} else {
|
|
@@ -106214,7 +106296,7 @@ var MemoryBlockstore = class extends BaseBlockstore {
|
|
|
106214
106296
|
options2?.signal?.throwIfAborted();
|
|
106215
106297
|
for (const [key, value3] of this.data.entries()) {
|
|
106216
106298
|
yield {
|
|
106217
|
-
cid: CID.createV1(code,
|
|
106299
|
+
cid: CID.createV1(code, decode24(base322.decode(key))),
|
|
106218
106300
|
block: value3
|
|
106219
106301
|
};
|
|
106220
106302
|
options2?.signal?.throwIfAborted();
|
|
@@ -106852,9 +106934,9 @@ var RecordEnvelope = class _RecordEnvelope {
|
|
|
106852
106934
|
};
|
|
106853
106935
|
var formatSignaturePayload = (domain, payloadType, payload) => {
|
|
106854
106936
|
const domainUint8Array = fromString2(domain);
|
|
106855
|
-
const domainLength =
|
|
106856
|
-
const payloadTypeLength =
|
|
106857
|
-
const payloadLength =
|
|
106937
|
+
const domainLength = encode41(domainUint8Array.byteLength);
|
|
106938
|
+
const payloadTypeLength = encode41(payloadType.length);
|
|
106939
|
+
const payloadLength = encode41(payload.length);
|
|
106858
106940
|
return new Uint8ArrayList(domainLength, domainUint8Array, payloadTypeLength, payloadType, payloadLength, payload);
|
|
106859
106941
|
};
|
|
106860
106942
|
|
|
@@ -107004,7 +107086,7 @@ var PeerRecord2 = class _PeerRecord {
|
|
|
107004
107086
|
*/
|
|
107005
107087
|
static createFromProtobuf = (buf2) => {
|
|
107006
107088
|
const peerRecord = PeerRecord.decode(buf2);
|
|
107007
|
-
const peerId = peerIdFromMultihash(
|
|
107089
|
+
const peerId = peerIdFromMultihash(decode24(peerRecord.peerId));
|
|
107008
107090
|
const multiaddrs = (peerRecord.addresses ?? []).map((a2) => multiaddr(a2.multiaddr));
|
|
107009
107091
|
const seqNumber = peerRecord.seq;
|
|
107010
107092
|
return new _PeerRecord({ peerId, multiaddrs, seqNumber });
|
|
@@ -111989,8 +112071,8 @@ function lpStream(duplex, opts = {}) {
|
|
|
111989
112071
|
if (opts.maxDataLength != null && opts.maxLengthLength == null) {
|
|
111990
112072
|
opts.maxLengthLength = encodingLength10(opts.maxDataLength);
|
|
111991
112073
|
}
|
|
111992
|
-
const decodeLength = opts?.lengthDecoder ??
|
|
111993
|
-
const encodeLength2 = opts?.lengthEncoder ??
|
|
112074
|
+
const decodeLength = opts?.lengthDecoder ?? decode46;
|
|
112075
|
+
const encodeLength2 = opts?.lengthEncoder ?? encode41;
|
|
111994
112076
|
const W = {
|
|
111995
112077
|
read: async (options2) => {
|
|
111996
112078
|
let dataLength = -1;
|
|
@@ -112143,7 +112225,7 @@ function optimisticSelect(stream, protocol, options2) {
|
|
|
112143
112225
|
// length of PROTOCOL_ID plus newline
|
|
112144
112226
|
fromString2(`${PROTOCOL_ID}
|
|
112145
112227
|
`),
|
|
112146
|
-
|
|
112228
|
+
encode41(protocolString.length),
|
|
112147
112229
|
fromString2(protocolString),
|
|
112148
112230
|
buf2
|
|
112149
112231
|
).subarray();
|
|
@@ -112313,7 +112395,7 @@ async function handle(stream, protocols2, options2) {
|
|
|
112313
112395
|
return { stream: lp.unwrap(), protocol };
|
|
112314
112396
|
}
|
|
112315
112397
|
if (protocol === "ls") {
|
|
112316
|
-
const protos = new Uint8ArrayList(...protocols2.map((p2) =>
|
|
112398
|
+
const protos = new Uint8ArrayList(...protocols2.map((p2) => encode42.single(fromString2(`${p2}
|
|
112317
112399
|
`))), fromString2("\n"));
|
|
112318
112400
|
options2.log.trace('handle: respond with "%s" for %s', protocols2, protocol);
|
|
112319
112401
|
await write3(lp, protos, options2);
|
|
@@ -118870,7 +118952,7 @@ var Noise = class {
|
|
|
118870
118952
|
// encrypt data + prefix with message length
|
|
118871
118953
|
network,
|
|
118872
118954
|
// send to the remote peer
|
|
118873
|
-
(source) =>
|
|
118955
|
+
(source) => decode47(source, { lengthDecoder: uint16BEDecode }),
|
|
118874
118956
|
// read message length prefix
|
|
118875
118957
|
decryptStream(handshake, this.metrics),
|
|
118876
118958
|
// decrypt the incoming data
|
|
@@ -120788,7 +120870,7 @@ var AutoNATService = class {
|
|
|
120788
120870
|
};
|
|
120789
120871
|
}
|
|
120790
120872
|
try {
|
|
120791
|
-
const digest2 =
|
|
120873
|
+
const digest2 = decode24(peer.id);
|
|
120792
120874
|
peerId = peerIdFromMultihash(digest2);
|
|
120793
120875
|
} catch (err) {
|
|
120794
120876
|
this.log.error("invalid PeerId - %e", err);
|
|
@@ -122961,7 +123043,7 @@ var CircuitRelayTransport = class {
|
|
|
122961
123043
|
});
|
|
122962
123044
|
return;
|
|
122963
123045
|
}
|
|
122964
|
-
const remotePeerId = peerIdFromMultihash(
|
|
123046
|
+
const remotePeerId = peerIdFromMultihash(decode24(request.peer.id));
|
|
122965
123047
|
if (await this.connectionGater.denyInboundRelayedConnection?.(connection.remotePeer, remotePeerId) === true) {
|
|
122966
123048
|
this.log.error("connection gater denied inbound relayed connection from %p", connection.remotePeer);
|
|
122967
123049
|
await pbstr.write({ type: StopMessage.Type.STATUS, status: Status.PERMISSION_DENIED }, {
|
|
@@ -124651,7 +124733,7 @@ function isPublicKeyKey(key) {
|
|
|
124651
124733
|
return toString2(key.subarray(0, 4)) === "/pk/";
|
|
124652
124734
|
}
|
|
124653
124735
|
function fromPublicKeyKey(key) {
|
|
124654
|
-
const multihash =
|
|
124736
|
+
const multihash = decode24(key.subarray(4));
|
|
124655
124737
|
return peerIdFromMultihash(multihash);
|
|
124656
124738
|
}
|
|
124657
124739
|
function createPutRecord(key, value3) {
|
|
@@ -124690,7 +124772,7 @@ function parseProviderKey(key) {
|
|
|
124690
124772
|
throw new Error(`incorrectly formatted provider entry key in datastore: ${key.toString()}`);
|
|
124691
124773
|
}
|
|
124692
124774
|
return {
|
|
124693
|
-
cid: CID.createV1(code,
|
|
124775
|
+
cid: CID.createV1(code, decode24(fromString2(cidStr, "base32"))),
|
|
124694
124776
|
peerId: peerIdFromString(peerIdStr)
|
|
124695
124777
|
};
|
|
124696
124778
|
}
|
|
@@ -124706,7 +124788,7 @@ function toProviderKey(prefix, cid, peerId) {
|
|
|
124706
124788
|
return new Key(parts.join("/"));
|
|
124707
124789
|
}
|
|
124708
124790
|
function readProviderTime(buf2) {
|
|
124709
|
-
return new Date(
|
|
124791
|
+
return new Date(decode46(buf2));
|
|
124710
124792
|
}
|
|
124711
124793
|
function timeOperationGenerator(fn, operationMetrics, type) {
|
|
124712
124794
|
return async function* (...args) {
|
|
@@ -124981,7 +125063,7 @@ function fromPbPeerInfo(peer) {
|
|
|
124981
125063
|
if (peer.id == null) {
|
|
124982
125064
|
throw new Error("Invalid peer in message");
|
|
124983
125065
|
}
|
|
124984
|
-
const multihash =
|
|
125066
|
+
const multihash = decode24(peer.id);
|
|
124985
125067
|
return {
|
|
124986
125068
|
id: peerIdFromMultihash(multihash),
|
|
124987
125069
|
multiaddrs: (peer.multiaddrs ?? []).map((a2) => multiaddr(a2))
|
|
@@ -125775,7 +125857,7 @@ var PeerRouting = class {
|
|
|
125775
125857
|
async getClosestPeersOffline(key, options2) {
|
|
125776
125858
|
const output6 = [];
|
|
125777
125859
|
try {
|
|
125778
|
-
const multihash =
|
|
125860
|
+
const multihash = decode24(key);
|
|
125779
125861
|
const targetPeerId = peerIdFromMultihash(multihash);
|
|
125780
125862
|
const peer = await this.components.peerStore.get(targetPeerId, options2);
|
|
125781
125863
|
output6.push({
|
|
@@ -125844,7 +125926,7 @@ var Providers = class {
|
|
|
125844
125926
|
*/
|
|
125845
125927
|
async writeProviderEntry(cid, peerId, options2) {
|
|
125846
125928
|
const key = toProviderKey(this.datastorePrefix, cid, peerId);
|
|
125847
|
-
const buffer2 =
|
|
125929
|
+
const buffer2 = encode41(options2?.time?.getTime() ?? Date.now());
|
|
125848
125930
|
await this.datastore.put(key, buffer2, options2);
|
|
125849
125931
|
}
|
|
125850
125932
|
/**
|
|
@@ -143814,7 +143896,7 @@ var RoutingTableRefresh = class {
|
|
|
143814
143896
|
const randomData = randomBytes7(2);
|
|
143815
143897
|
const randomUint16 = (randomData[1] << 8) + randomData[0];
|
|
143816
143898
|
const key = this._makePeerId(this.routingTable.kb.localPeer.kadId, randomUint16, targetCommonPrefixLength);
|
|
143817
|
-
const multihash =
|
|
143899
|
+
const multihash = decode24(key);
|
|
143818
143900
|
return peerIdFromMultihash(multihash);
|
|
143819
143901
|
}
|
|
143820
143902
|
_makePeerId(localKadId, randomPrefix, targetCommonPrefixLength) {
|
|
@@ -143912,7 +143994,7 @@ var AddProviderHandler = class {
|
|
|
143912
143994
|
}
|
|
143913
143995
|
this.log("%p asked us, %p to store provider record for for %c", peerId, this.peerId, cid);
|
|
143914
143996
|
await Promise.all(msg.providers.map(async (pi) => {
|
|
143915
|
-
const digest2 =
|
|
143997
|
+
const digest2 = decode24(pi.id);
|
|
143916
143998
|
const providerId = peerIdFromMultihash(digest2);
|
|
143917
143999
|
const providerMultiaddrs = pi.multiaddrs.map((buf2) => multiaddr(buf2));
|
|
143918
144000
|
if (!peerId.equals(providerId)) {
|
|
@@ -144915,13 +144997,13 @@ var Encoder5 = class {
|
|
|
144915
144997
|
write(msg, list) {
|
|
144916
144998
|
const pool2 = this._pool;
|
|
144917
144999
|
let offset = this._poolOffset;
|
|
144918
|
-
|
|
145000
|
+
encode41(msg.id << 3 | msg.type, pool2, offset);
|
|
144919
145001
|
offset += encodingLength10(msg.id << 3 | msg.type);
|
|
144920
145002
|
if ((msg.type === MessageTypes.NEW_STREAM || msg.type === MessageTypes.MESSAGE_INITIATOR || msg.type === MessageTypes.MESSAGE_RECEIVER) && msg.data != null) {
|
|
144921
|
-
|
|
145003
|
+
encode41(msg.data.length, pool2, offset);
|
|
144922
145004
|
offset += encodingLength10(msg.data.length);
|
|
144923
145005
|
} else {
|
|
144924
|
-
|
|
145006
|
+
encode41(0, pool2, offset);
|
|
144925
145007
|
offset += encodingLength10(0);
|
|
144926
145008
|
}
|
|
144927
145009
|
const header2 = pool2.subarray(this._poolOffset, offset);
|
|
@@ -144938,7 +145020,7 @@ var Encoder5 = class {
|
|
|
144938
145020
|
}
|
|
144939
145021
|
};
|
|
144940
145022
|
var encoder2 = new Encoder5();
|
|
144941
|
-
async function*
|
|
145023
|
+
async function* encode43(source) {
|
|
144942
145024
|
for await (const message2 of source) {
|
|
144943
145025
|
const list = new Uint8ArrayList();
|
|
144944
145026
|
encoder2.write(message2, list);
|
|
@@ -145071,7 +145153,7 @@ var MplexStreamMuxer = class {
|
|
|
145071
145153
|
}
|
|
145072
145154
|
}
|
|
145073
145155
|
});
|
|
145074
|
-
this.source = pipe2(this._source, (source) =>
|
|
145156
|
+
this.source = pipe2(this._source, (source) => encode43(source));
|
|
145075
145157
|
this.closeController = new AbortController();
|
|
145076
145158
|
this.rateLimiter = new RateLimiter({
|
|
145077
145159
|
points: init.disconnectThreshold ?? DISCONNECT_THRESHOLD,
|
|
@@ -145995,7 +146077,7 @@ var WebRTCStream = class extends AbstractStream {
|
|
|
145995
146077
|
};
|
|
145996
146078
|
const self2 = this;
|
|
145997
146079
|
Promise.resolve().then(async () => {
|
|
145998
|
-
for await (const buf2 of
|
|
146080
|
+
for await (const buf2 of decode47(this.incomingData)) {
|
|
145999
146081
|
const message2 = self2.processIncomingProtobuf(buf2);
|
|
146000
146082
|
if (message2 != null) {
|
|
146001
146083
|
self2.sourcePush(new Uint8ArrayList(message2));
|
|
@@ -146057,7 +146139,7 @@ var WebRTCStream = class extends AbstractStream {
|
|
|
146057
146139
|
const toSend = Math.min(data.byteLength, this.maxMessageSize);
|
|
146058
146140
|
const buf2 = data.subarray(0, toSend);
|
|
146059
146141
|
const messageBuf = Message3.encode({ message: buf2 });
|
|
146060
|
-
const sendBuf =
|
|
146142
|
+
const sendBuf = encode42.single(messageBuf);
|
|
146061
146143
|
this.log.trace("sending %d/%d bytes on channel", buf2.byteLength, bytesTotal);
|
|
146062
146144
|
await this._sendMessage(sendBuf);
|
|
146063
146145
|
data.consume(toSend);
|
|
@@ -146136,7 +146218,7 @@ var WebRTCStream = class extends AbstractStream {
|
|
|
146136
146218
|
}
|
|
146137
146219
|
this.log.trace("sending flag %s", flag.toString());
|
|
146138
146220
|
const messageBuf = Message3.encode({ flag });
|
|
146139
|
-
const prefixedBuf =
|
|
146221
|
+
const prefixedBuf = encode42.single(messageBuf);
|
|
146140
146222
|
try {
|
|
146141
146223
|
await this._sendMessage(prefixedBuf, false);
|
|
146142
146224
|
return true;
|
|
@@ -156302,7 +156384,7 @@ var BeaconSignalDiscovery = class {
|
|
|
156302
156384
|
// src/core/interfaces.ts
|
|
156303
156385
|
init_shim();
|
|
156304
156386
|
|
|
156305
|
-
// src/core/
|
|
156387
|
+
// src/core/resolver.ts
|
|
156306
156388
|
init_shim();
|
|
156307
156389
|
|
|
156308
156390
|
// ../cryptosuite/dist/esm/index.js
|
|
@@ -157154,10 +157236,10 @@ var Update = class {
|
|
|
157154
157236
|
* @param {Btcr2DidDocument} sourceDocument The source DID document to be updated.
|
|
157155
157237
|
* @param {PatchOperation[]} patches The array of JSON Patch operations to apply to the sourceDocument.
|
|
157156
157238
|
* @param {number} sourceVersionId The version ID of the source document.
|
|
157157
|
-
* @returns {
|
|
157239
|
+
* @returns {UnsignedBTCR2Update} The constructed UnsignedBTCR2Update object.
|
|
157158
157240
|
* @throws {UpdateError} InvalidDid if sourceDocument.id does not match identifier.
|
|
157159
157241
|
*/
|
|
157160
|
-
static
|
|
157242
|
+
static construct(sourceDocument, patches, sourceVersionId) {
|
|
157161
157243
|
const unsignedUpdate = {
|
|
157162
157244
|
"@context": [
|
|
157163
157245
|
"https://w3id.org/security/v2",
|
|
@@ -157168,7 +157250,7 @@ var Update = class {
|
|
|
157168
157250
|
patch: patches,
|
|
157169
157251
|
targetHash: "",
|
|
157170
157252
|
targetVersionId: sourceVersionId + 1,
|
|
157171
|
-
sourceHash: canonicalHash(sourceDocument
|
|
157253
|
+
sourceHash: canonicalHash(sourceDocument)
|
|
157172
157254
|
};
|
|
157173
157255
|
const targetDocument = JSONPatch.apply(sourceDocument, patches);
|
|
157174
157256
|
try {
|
|
@@ -157180,7 +157262,7 @@ var Update = class {
|
|
|
157180
157262
|
targetDocument
|
|
157181
157263
|
);
|
|
157182
157264
|
}
|
|
157183
|
-
unsignedUpdate.targetHash = canonicalHash(targetDocument
|
|
157265
|
+
unsignedUpdate.targetHash = canonicalHash(targetDocument);
|
|
157184
157266
|
return unsignedUpdate;
|
|
157185
157267
|
}
|
|
157186
157268
|
/**
|
|
@@ -157193,7 +157275,7 @@ var Update = class {
|
|
|
157193
157275
|
* @returns {SignedBTCR2Update} Did update payload secured with a proof => SignedBTCR2Update
|
|
157194
157276
|
* @throws {UpdateError} if the privateKeyBytes are invalid
|
|
157195
157277
|
*/
|
|
157196
|
-
static
|
|
157278
|
+
static sign(did, unsignedUpdate, verificationMethod, secretKey) {
|
|
157197
157279
|
const controller = verificationMethod.controller;
|
|
157198
157280
|
const id = verificationMethod.id.slice(verificationMethod.id.indexOf("#"));
|
|
157199
157281
|
const multikey = SchnorrMultikey.fromSecretKey(id, controller, secretKey);
|
|
@@ -157245,7 +157327,7 @@ var DidBtcr2 = class {
|
|
|
157245
157327
|
* @param {string} options.idType The type of identifier to create, either 'KEY' or 'EXTERNAL'. Defaults to 'KEY'.
|
|
157246
157328
|
* @param {number} options.version The version number of the did:btcr2 specification to use for creating the identifier. Defaults to 1.
|
|
157247
157329
|
* @param {string} options.network The Bitcoin network to use for the identifier, e.g. 'bitcoin', 'testnet', etc. Defaults to 'bitcoin'.
|
|
157248
|
-
* @returns {Promise<
|
|
157330
|
+
* @returns {Promise<string>} Promise resolving to an identifier string.
|
|
157249
157331
|
* @throws {MethodError} if any of the checks fail
|
|
157250
157332
|
* @example
|
|
157251
157333
|
* ```ts
|
|
@@ -157266,90 +157348,34 @@ var DidBtcr2 = class {
|
|
|
157266
157348
|
}
|
|
157267
157349
|
/**
|
|
157268
157350
|
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html | 7.2 Resolve}.
|
|
157269
|
-
* See specification for the {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process | Resolve Process}.
|
|
157270
|
-
* See {@link Resolve | Resolve (class)} for class implementation.
|
|
157271
157351
|
*
|
|
157272
|
-
*
|
|
157273
|
-
*
|
|
157274
|
-
*
|
|
157275
|
-
* deterministically created from the DID or provided by Sidecar Data.
|
|
157352
|
+
* Factory method that performs pure setup and returns a {@link Resolver} state machine.
|
|
157353
|
+
* The caller drives resolution by calling `resolver.resolve()` and `resolver.provide()`.
|
|
157354
|
+
* Analogous to Rust's `Document::read()`.
|
|
157276
157355
|
*
|
|
157277
157356
|
* @param {string} did The did:btcr2 identifier to be resolved.
|
|
157278
157357
|
* @param {ResolutionOptions} resolutionOptions Options used during the resolution process.
|
|
157279
|
-
* @returns {
|
|
157280
|
-
* @throws {ResolveError} If the resolution process fails at any step.
|
|
157358
|
+
* @returns {Resolver} A sans-I/O state machine the caller drives to completion.
|
|
157281
157359
|
* @example
|
|
157282
157360
|
* ```ts
|
|
157283
|
-
* const
|
|
157284
|
-
*
|
|
157285
|
-
* )
|
|
157361
|
+
* const resolver = DidBtcr2.resolve(did, { sidecar });
|
|
157362
|
+
* let state = resolver.resolve();
|
|
157363
|
+
* while (state.status === 'action-required') {
|
|
157364
|
+
* for (const need of state.needs) { ... provide data ... }
|
|
157365
|
+
* state = resolver.resolve();
|
|
157366
|
+
* }
|
|
157367
|
+
* const { didDocument, metadata } = state.result;
|
|
157286
157368
|
* ```
|
|
157287
157369
|
*/
|
|
157288
|
-
static
|
|
157289
|
-
|
|
157290
|
-
|
|
157291
|
-
|
|
157292
|
-
|
|
157293
|
-
|
|
157294
|
-
|
|
157295
|
-
|
|
157296
|
-
|
|
157297
|
-
updated: void 0,
|
|
157298
|
-
confirmations: void 0
|
|
157299
|
-
},
|
|
157300
|
-
didDocument: null
|
|
157301
|
-
};
|
|
157302
|
-
const didComponents = Identifier.decode(did);
|
|
157303
|
-
const sidecarData = Resolve.sidecarData(resolutionOptions.sidecar);
|
|
157304
|
-
const genesisDocument = resolutionOptions.sidecar?.genesisDocument;
|
|
157305
|
-
if (!genesisDocument) {
|
|
157306
|
-
if (didComponents.hrp === IdentifierHrp.x)
|
|
157307
|
-
throw new ResolveError(
|
|
157308
|
-
"External resolution requires genesisDocument",
|
|
157309
|
-
MISSING_UPDATE_DATA,
|
|
157310
|
-
resolutionOptions
|
|
157311
|
-
);
|
|
157312
|
-
}
|
|
157313
|
-
const currentDocument = await Resolve.currentDocument(didComponents, genesisDocument);
|
|
157314
|
-
const beaconServices = currentDocument.service.filter(BeaconUtils.isBeaconService).map(BeaconUtils.parseBeaconServiceEndpoint);
|
|
157315
|
-
if (!resolutionOptions?.drivers?.bitcoin) {
|
|
157316
|
-
throw new ResolveError(
|
|
157317
|
-
"Bitcoin connection required for resolve. Pass a configured driver via resolutionOptions.drivers.bitcoin or use DidBtcr2Api which injects it automatically.",
|
|
157318
|
-
MISSING_RESOLUTION_OPTIONS,
|
|
157319
|
-
resolutionOptions
|
|
157320
|
-
);
|
|
157321
|
-
}
|
|
157322
|
-
const bitcoin2 = resolutionOptions.drivers.bitcoin;
|
|
157323
|
-
const unsortedUpdates = await Resolve.beaconSignals(
|
|
157324
|
-
beaconServices,
|
|
157325
|
-
sidecarData,
|
|
157326
|
-
bitcoin2
|
|
157327
|
-
);
|
|
157328
|
-
if (!unsortedUpdates.length) {
|
|
157329
|
-
didResolutionResult.didDocument = currentDocument;
|
|
157330
|
-
didResolutionResult.didDocumentMetadata.deactivated = !!currentDocument.deactivated;
|
|
157331
|
-
didResolutionResult.didDocumentMetadata.versionId = versionId ?? "1";
|
|
157332
|
-
return didResolutionResult;
|
|
157333
|
-
}
|
|
157334
|
-
const result = await Resolve.updates(
|
|
157335
|
-
currentDocument,
|
|
157336
|
-
unsortedUpdates,
|
|
157337
|
-
resolutionOptions.versionTime,
|
|
157338
|
-
versionId
|
|
157339
|
-
);
|
|
157340
|
-
didResolutionResult.didDocument = result.didDocument;
|
|
157341
|
-
didResolutionResult.didDocumentMetadata = result.metadata;
|
|
157342
|
-
return didResolutionResult;
|
|
157343
|
-
} catch (error) {
|
|
157344
|
-
if (!(error instanceof ResolveError)) throw new Error(error.message ?? error, { cause: error });
|
|
157345
|
-
return {
|
|
157346
|
-
...EMPTY_DID_RESOLUTION_RESULT,
|
|
157347
|
-
didResolutionMetadata: {
|
|
157348
|
-
error: error.type,
|
|
157349
|
-
...error.message && { errorMessage: error.message }
|
|
157350
|
-
}
|
|
157351
|
-
};
|
|
157352
|
-
}
|
|
157370
|
+
static resolve(did, resolutionOptions = {}) {
|
|
157371
|
+
const didComponents = Identifier.decode(did);
|
|
157372
|
+
const sidecarData = Resolver.sidecarData(resolutionOptions.sidecar);
|
|
157373
|
+
const currentDocument = didComponents.hrp === IdentifierHrp.k ? Resolver.deterministic(didComponents) : null;
|
|
157374
|
+
return new Resolver(didComponents, sidecarData, currentDocument, {
|
|
157375
|
+
versionId: resolutionOptions.versionId,
|
|
157376
|
+
versionTime: resolutionOptions.versionTime,
|
|
157377
|
+
genesisDocument: resolutionOptions.sidecar?.genesisDocument
|
|
157378
|
+
});
|
|
157353
157379
|
}
|
|
157354
157380
|
/**
|
|
157355
157381
|
* Entry point for section {@link https://dcdpr.github.io/did-btcr2/#read | 7.3 Update}.
|
|
@@ -157417,8 +157443,8 @@ var DidBtcr2 = class {
|
|
|
157417
157443
|
verificationMethod
|
|
157418
157444
|
);
|
|
157419
157445
|
}
|
|
157420
|
-
const update =
|
|
157421
|
-
const signed =
|
|
157446
|
+
const update = Update.construct(sourceDocument, patches, sourceVersionId);
|
|
157447
|
+
const signed = Update.sign(sourceDocument.id, update, verificationMethod, secretKey);
|
|
157422
157448
|
const beaconService = sourceDocument.service.filter((service) => service.id === beaconId).filter((service) => !!service).shift();
|
|
157423
157449
|
if (!beaconService) {
|
|
157424
157450
|
throw new UpdateError(
|
|
@@ -157466,17 +157492,47 @@ var DidBtcr2 = class {
|
|
|
157466
157492
|
}
|
|
157467
157493
|
};
|
|
157468
157494
|
|
|
157469
|
-
// src/core/
|
|
157470
|
-
var
|
|
157495
|
+
// src/core/resolver.ts
|
|
157496
|
+
var Resolver = class _Resolver {
|
|
157497
|
+
// --- Immutable inputs ---
|
|
157498
|
+
#didComponents;
|
|
157499
|
+
#versionId;
|
|
157500
|
+
#versionTime;
|
|
157501
|
+
/**
|
|
157502
|
+
* The specific phase the Resolver is current in.
|
|
157503
|
+
*/
|
|
157504
|
+
#phase;
|
|
157505
|
+
#sidecarData;
|
|
157506
|
+
#currentDocument;
|
|
157507
|
+
#providedGenesisDocument = null;
|
|
157508
|
+
#beaconServicesSignals = /* @__PURE__ */ new Map();
|
|
157509
|
+
#processedServices = /* @__PURE__ */ new Set();
|
|
157510
|
+
#requestCache = /* @__PURE__ */ new Set();
|
|
157511
|
+
#unsortedUpdates = [];
|
|
157512
|
+
#resolvedResponse = null;
|
|
157513
|
+
/**
|
|
157514
|
+
* @internal — Use {@link DidBtcr2.resolve} to create instances.
|
|
157515
|
+
*/
|
|
157516
|
+
constructor(didComponents, sidecarData, currentDocument, options2) {
|
|
157517
|
+
this.#didComponents = didComponents;
|
|
157518
|
+
this.#sidecarData = sidecarData;
|
|
157519
|
+
this.#currentDocument = currentDocument;
|
|
157520
|
+
this.#versionId = options2?.versionId;
|
|
157521
|
+
this.#versionTime = options2?.versionTime;
|
|
157522
|
+
if (options2?.genesisDocument) {
|
|
157523
|
+
this.#providedGenesisDocument = options2.genesisDocument;
|
|
157524
|
+
}
|
|
157525
|
+
this.#phase = currentDocument ? "BeaconDiscovery" /* BeaconDiscovery */ : "GenesisDocument" /* GenesisDocument */;
|
|
157526
|
+
}
|
|
157471
157527
|
/**
|
|
157472
157528
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#if-genesis_bytes-is-a-secp256k1-public-key | 7.2.d.1 if genesis bytes is a secp256k1 Public Key}.
|
|
157473
157529
|
* @param {DidComponents} didComponents The decoded components of the did.
|
|
157474
157530
|
* @returns {DidDocument} The resolved DID Document object.
|
|
157475
157531
|
*/
|
|
157476
157532
|
static deterministic(didComponents) {
|
|
157477
|
-
const
|
|
157533
|
+
const genesisBytes = didComponents.genesisBytes;
|
|
157478
157534
|
const did = Identifier.encode(genesisBytes, didComponents);
|
|
157479
|
-
const { multibase
|
|
157535
|
+
const { multibase } = new CompressedSecp256k1PublicKey(genesisBytes);
|
|
157480
157536
|
const service = BeaconUtils.generateBeaconServices({
|
|
157481
157537
|
id: did,
|
|
157482
157538
|
publicKey: genesisBytes,
|
|
@@ -157489,7 +157545,7 @@ var Resolve = class {
|
|
|
157489
157545
|
id: `${did}#initialKey`,
|
|
157490
157546
|
type: "Multikey",
|
|
157491
157547
|
controller: did,
|
|
157492
|
-
publicKeyMultibase:
|
|
157548
|
+
publicKeyMultibase: multibase.encoded
|
|
157493
157549
|
}],
|
|
157494
157550
|
service
|
|
157495
157551
|
});
|
|
@@ -157497,22 +157553,21 @@ var Resolve = class {
|
|
|
157497
157553
|
/**
|
|
157498
157554
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#if-genesis_bytes-is-a-sha-256-hash | 7.2.d.2 if genesis_bytes is a SHA-256 Hash}.
|
|
157499
157555
|
* @param {DidComponents} didComponents BTCR2 DID components used to resolve the DID Document
|
|
157500
|
-
* @param {
|
|
157501
|
-
* @returns {
|
|
157556
|
+
* @param {object} genesisDocument The genesis document for resolving the DID Document.
|
|
157557
|
+
* @returns {DidDocument} The resolved DID Document object
|
|
157502
157558
|
* @throws {ResolveError} InvalidDidDocument if not conformant to DID Core v1.1
|
|
157503
157559
|
*/
|
|
157504
|
-
static
|
|
157505
|
-
const
|
|
157506
|
-
const
|
|
157507
|
-
|
|
157508
|
-
if (genesisHex !== hashBytes) {
|
|
157560
|
+
static external(didComponents, genesisDocument) {
|
|
157561
|
+
const genesisBytes = encode20(didComponents.genesisBytes);
|
|
157562
|
+
const genesisDocumentBytes = canonicalHash(genesisDocument);
|
|
157563
|
+
if (genesisBytes !== genesisDocumentBytes) {
|
|
157509
157564
|
throw new ResolveError(
|
|
157510
|
-
`Initial document mismatch: genesisBytes
|
|
157565
|
+
`Initial document mismatch: genesisBytes !== genesisDocumentBytes`,
|
|
157511
157566
|
INVALID_DID_DOCUMENT,
|
|
157512
|
-
{ genesisBytes,
|
|
157567
|
+
{ genesisBytes, genesisDocumentBytes }
|
|
157513
157568
|
);
|
|
157514
157569
|
}
|
|
157515
|
-
const did = Identifier.encode(genesisBytes, didComponents);
|
|
157570
|
+
const did = Identifier.encode(decode19(genesisBytes), didComponents);
|
|
157516
157571
|
const currentDocument = JSON.parse(
|
|
157517
157572
|
JSON.stringify(genesisDocument).replaceAll(ID_PLACEHOLDER_VALUE, did)
|
|
157518
157573
|
);
|
|
@@ -157521,18 +157576,18 @@ var Resolve = class {
|
|
|
157521
157576
|
/**
|
|
157522
157577
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-sidecar-data | Process Sidecar Data}
|
|
157523
157578
|
* @param {Sidecar} sidecar The sidecar data to process.
|
|
157524
|
-
* @returns {
|
|
157579
|
+
* @returns {SidecarData} The processed sidecar data containing maps of updates, CAS announcements, and SMT proofs.
|
|
157525
157580
|
*/
|
|
157526
157581
|
static sidecarData(sidecar = {}) {
|
|
157527
157582
|
const updateMap = /* @__PURE__ */ new Map();
|
|
157528
157583
|
if (sidecar.updates?.length)
|
|
157529
157584
|
for (const update of sidecar.updates) {
|
|
157530
|
-
updateMap.set(canonicalHash(update
|
|
157585
|
+
updateMap.set(canonicalHash(update), update);
|
|
157531
157586
|
}
|
|
157532
157587
|
const casMap = /* @__PURE__ */ new Map();
|
|
157533
157588
|
if (sidecar.casUpdates?.length)
|
|
157534
157589
|
for (const update of sidecar.casUpdates) {
|
|
157535
|
-
casMap.set(canonicalHash(update
|
|
157590
|
+
casMap.set(canonicalHash(update), update);
|
|
157536
157591
|
}
|
|
157537
157592
|
const smtMap = /* @__PURE__ */ new Map();
|
|
157538
157593
|
if (sidecar.smtProofs?.length)
|
|
@@ -157541,67 +157596,15 @@ var Resolve = class {
|
|
|
157541
157596
|
}
|
|
157542
157597
|
return { updateMap, casMap, smtMap };
|
|
157543
157598
|
}
|
|
157544
|
-
/**
|
|
157545
|
-
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#establish-current-document | 7.2.d Establish current_document}.
|
|
157546
|
-
* Resolution begins by creating an Initial Did Document called current_document (Current DID Document).
|
|
157547
|
-
* The current_document is iteratively patched with BTCR2 Signed Updates announced by Authorized Beacon Signals.
|
|
157548
|
-
* @param {DidComponents} didComponents The decoded components of the did.
|
|
157549
|
-
* @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
|
|
157550
|
-
* @returns {Promise<DidDocument>} The resolved DID Document object.
|
|
157551
|
-
* @throws {ResolveError} if the DID hrp is invalid, no sidecarData passed and hrp = "x".
|
|
157552
|
-
*/
|
|
157553
|
-
static async currentDocument(didComponents, genesisDocument) {
|
|
157554
|
-
const { hrp, genesisBytes } = didComponents;
|
|
157555
|
-
if (hrp === IdentifierHrp.x) {
|
|
157556
|
-
if (!genesisDocument)
|
|
157557
|
-
throw new ResolveError(
|
|
157558
|
-
"External resolution requires genesisDocument",
|
|
157559
|
-
MISSING_UPDATE_DATA,
|
|
157560
|
-
{ didComponents }
|
|
157561
|
-
);
|
|
157562
|
-
return await this.external(didComponents, genesisDocument);
|
|
157563
|
-
}
|
|
157564
|
-
if (hrp === IdentifierHrp.k) {
|
|
157565
|
-
if (!CompressedSecp256k1PublicKey.isValid(genesisBytes)) {
|
|
157566
|
-
throw new ResolveError(
|
|
157567
|
-
"Deterministic resolution requires valid secp256k1 public key",
|
|
157568
|
-
INVALID_DID,
|
|
157569
|
-
{ genesisBytes }
|
|
157570
|
-
);
|
|
157571
|
-
}
|
|
157572
|
-
return this.deterministic(didComponents);
|
|
157573
|
-
}
|
|
157574
|
-
throw new ResolveError(`Unsupported DID hrp ${hrp}`, INVALID_DID, { hrp });
|
|
157575
|
-
}
|
|
157576
|
-
/**
|
|
157577
|
-
* Finds uses the beacon services in the currentDocument to scan for onchain Beacon Signals (transactions) containing
|
|
157578
|
-
* Signal Bytes (last output in OP_RETURN transaction).
|
|
157579
|
-
* @param {Array<BeaconService>} beaconServices The array of BeaconService objects to search for signals.
|
|
157580
|
-
* @param {SidecarData} sidecarData The sidecar data containing maps of updates, CAS announcements, and SMT proofs.
|
|
157581
|
-
* @param {BitcoinConnection} bitcoin The bitcoin network connection used to fetch beacon signals
|
|
157582
|
-
* @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The array of BTCR2 Signed Updates announced by the Beacon Signals.
|
|
157583
|
-
*/
|
|
157584
|
-
static async beaconSignals(beaconServices, sidecarData, bitcoin2) {
|
|
157585
|
-
const beaconServicesSignals = bitcoin2.rest ? await BeaconSignalDiscovery.indexer(beaconServices, bitcoin2) : await BeaconSignalDiscovery.fullnode(beaconServices, bitcoin2);
|
|
157586
|
-
const promises = await Promise.all(
|
|
157587
|
-
Array.from(beaconServicesSignals.entries()).map(
|
|
157588
|
-
async ([service, signals]) => {
|
|
157589
|
-
if (!signals.length) return [];
|
|
157590
|
-
return BeaconFactory.establish(service).processSignals(signals, sidecarData);
|
|
157591
|
-
}
|
|
157592
|
-
)
|
|
157593
|
-
);
|
|
157594
|
-
return promises.flat();
|
|
157595
|
-
}
|
|
157596
157599
|
/**
|
|
157597
157600
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-updates | 7.2.f Process updates Array}.
|
|
157598
157601
|
* @param {DidDocument} currentDocument The current DID Document to apply the updates to.
|
|
157599
157602
|
* @param {Array<[SignedBTCR2Update, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
|
|
157600
157603
|
* @param {string} [versionTime] The optional version time to limit updates to.
|
|
157601
157604
|
* @param {string} [versionId] The optional version id to limit updates to.
|
|
157602
|
-
* @returns {
|
|
157605
|
+
* @returns {DidResolutionResponse} The updated DID Document, number of confirmations, and version id.
|
|
157603
157606
|
*/
|
|
157604
|
-
static
|
|
157607
|
+
static updates(currentDocument, unsortedUpdates, versionTime, versionId) {
|
|
157605
157608
|
let currentVersionId = 1;
|
|
157606
157609
|
const updateHashHistory = [];
|
|
157607
157610
|
const updates = unsortedUpdates.sort(
|
|
@@ -157617,7 +157620,7 @@ var Resolve = class {
|
|
|
157617
157620
|
}
|
|
157618
157621
|
};
|
|
157619
157622
|
for (const [update, block] of updates) {
|
|
157620
|
-
const currentDocumentHash = canonicalHash(response2.didDocument
|
|
157623
|
+
const currentDocumentHash = canonicalHash(response2.didDocument);
|
|
157621
157624
|
const blocktime = DateUtils.blocktimeToTimestamp(block.time);
|
|
157622
157625
|
response2.metadata.updated = DateUtils.toISOStringNonFractional(blocktime);
|
|
157623
157626
|
response2.metadata.confirmations = block.confirmations;
|
|
@@ -157637,9 +157640,9 @@ var Resolve = class {
|
|
|
157637
157640
|
{ sourceHash: update.sourceHash, currentDocumentHash }
|
|
157638
157641
|
);
|
|
157639
157642
|
}
|
|
157640
|
-
response2.didDocument =
|
|
157643
|
+
response2.didDocument = this.applyUpdate(response2.didDocument, update);
|
|
157641
157644
|
const unsignedUpdate = JSONUtils.deleteKeys(update, ["proof"]);
|
|
157642
|
-
updateHashHistory.push(canonicalHash(unsignedUpdate
|
|
157645
|
+
updateHashHistory.push(canonicalHash(unsignedUpdate));
|
|
157643
157646
|
} else if (update.targetVersionId > currentVersionId + 1) {
|
|
157644
157647
|
throw new ResolveError(
|
|
157645
157648
|
`Version Id Mismatch: targetVersionId cannot be > currentVersionId + 1`,
|
|
@@ -157652,20 +157655,23 @@ var Resolve = class {
|
|
|
157652
157655
|
}
|
|
157653
157656
|
currentVersionId++;
|
|
157654
157657
|
response2.metadata.versionId = `${currentVersionId}`;
|
|
157655
|
-
|
|
157658
|
+
const versionIdNumber = Number(versionId);
|
|
157659
|
+
if (!isNaN(versionIdNumber) && versionIdNumber <= currentVersionId) {
|
|
157656
157660
|
return response2;
|
|
157657
157661
|
}
|
|
157658
|
-
if (
|
|
157659
|
-
response2.metadata.deactivated =
|
|
157662
|
+
if (response2.didDocument.deactivated) {
|
|
157663
|
+
response2.metadata.deactivated = response2.didDocument.deactivated;
|
|
157660
157664
|
return response2;
|
|
157661
157665
|
}
|
|
157662
157666
|
}
|
|
157663
157667
|
return response2;
|
|
157664
157668
|
}
|
|
157669
|
+
// ─── Private static: update internals ──────────────────────────────
|
|
157665
157670
|
/**
|
|
157666
157671
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
|
|
157667
157672
|
* This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
|
|
157668
157673
|
* @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
|
|
157674
|
+
* @param {string[]} updateHashHistory The accumulated hash history for comparison.
|
|
157669
157675
|
* @returns {void} Does not return a value, but throws an error if the update is not a valid duplicate.
|
|
157670
157676
|
*/
|
|
157671
157677
|
static confirmDuplicate(update, updateHashHistory) {
|
|
@@ -157684,10 +157690,10 @@ var Resolve = class {
|
|
|
157684
157690
|
* Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | 7.2.f.3 Apply Update}.
|
|
157685
157691
|
* @param {DidDocument} currentDocument The current DID Document to apply the update to.
|
|
157686
157692
|
* @param {SignedBTCR2Update} update The BTCR2 Signed Update to apply.
|
|
157687
|
-
* @returns {
|
|
157693
|
+
* @returns {DidDocument} The updated DID Document after applying the update.
|
|
157688
157694
|
* @throws {ResolveError} If the update is invalid or cannot be applied.
|
|
157689
157695
|
*/
|
|
157690
|
-
static
|
|
157696
|
+
static applyUpdate(currentDocument, update) {
|
|
157691
157697
|
const capabilityId = update.proof?.capability;
|
|
157692
157698
|
if (!capabilityId) {
|
|
157693
157699
|
throw new ResolveError("No root capability found in update", INVALID_DID_UPDATE, update);
|
|
@@ -157720,7 +157726,7 @@ var Resolve = class {
|
|
|
157720
157726
|
}
|
|
157721
157727
|
const updatedDocument = JSONPatch.apply(currentDocument, update.patch);
|
|
157722
157728
|
DidDocument2.validate(updatedDocument);
|
|
157723
|
-
const currentDocumentHash = canonicalHash(updatedDocument
|
|
157729
|
+
const currentDocumentHash = canonicalHash(updatedDocument);
|
|
157724
157730
|
const updateTargetHash = update.targetHash;
|
|
157725
157731
|
if (update.targetHash !== currentDocumentHash) {
|
|
157726
157732
|
throw new ResolveError(
|
|
@@ -157731,6 +157737,143 @@ var Resolve = class {
|
|
|
157731
157737
|
}
|
|
157732
157738
|
return updatedDocument;
|
|
157733
157739
|
}
|
|
157740
|
+
// ─── Instance: state machine ───────────────────────────────────────
|
|
157741
|
+
/**
|
|
157742
|
+
* Advance the state machine. Returns either:
|
|
157743
|
+
* - `{ status: 'action-required', needs }` — caller must provide data via {@link provide}
|
|
157744
|
+
* - `{ status: 'resolved', result }` — resolution complete
|
|
157745
|
+
*
|
|
157746
|
+
* Analogous to Rust's `Resolver::resolve()`.
|
|
157747
|
+
*/
|
|
157748
|
+
resolve() {
|
|
157749
|
+
while (true) {
|
|
157750
|
+
switch (this.#phase) {
|
|
157751
|
+
// Phase: GenesisDocument
|
|
157752
|
+
// Only entered for EXTERNAL (x HRP) identifiers when genesis doc was not in sidecar.
|
|
157753
|
+
case "GenesisDocument" /* GenesisDocument */: {
|
|
157754
|
+
if (this.#providedGenesisDocument) {
|
|
157755
|
+
this.#currentDocument = _Resolver.external(
|
|
157756
|
+
this.#didComponents,
|
|
157757
|
+
this.#providedGenesisDocument
|
|
157758
|
+
);
|
|
157759
|
+
this.#providedGenesisDocument = null;
|
|
157760
|
+
this.#phase = "BeaconDiscovery" /* BeaconDiscovery */;
|
|
157761
|
+
continue;
|
|
157762
|
+
}
|
|
157763
|
+
const genesisHash = encode20(this.#didComponents.genesisBytes);
|
|
157764
|
+
return {
|
|
157765
|
+
status: "action-required",
|
|
157766
|
+
needs: [{ kind: "NeedGenesisDocument", genesisHash }]
|
|
157767
|
+
};
|
|
157768
|
+
}
|
|
157769
|
+
// Phase: BeaconDiscovery
|
|
157770
|
+
// Extract beacon services, emit NeedBeaconSignals for addresses not yet queried.
|
|
157771
|
+
case "BeaconDiscovery" /* BeaconDiscovery */: {
|
|
157772
|
+
const beaconServices = BeaconUtils.getBeaconServices(this.#currentDocument);
|
|
157773
|
+
const newServices = beaconServices.filter((service) => {
|
|
157774
|
+
const address = BeaconUtils.parseBitcoinAddress(service.serviceEndpoint);
|
|
157775
|
+
return !this.#requestCache.has(address);
|
|
157776
|
+
});
|
|
157777
|
+
if (newServices.length > 0) {
|
|
157778
|
+
for (const service of newServices) {
|
|
157779
|
+
const address = BeaconUtils.parseBitcoinAddress(service.serviceEndpoint);
|
|
157780
|
+
this.#requestCache.add(address);
|
|
157781
|
+
}
|
|
157782
|
+
return {
|
|
157783
|
+
status: "action-required",
|
|
157784
|
+
needs: [{ kind: "NeedBeaconSignals", beaconServices: newServices }]
|
|
157785
|
+
};
|
|
157786
|
+
}
|
|
157787
|
+
this.#phase = "BeaconProcess" /* BeaconProcess */;
|
|
157788
|
+
continue;
|
|
157789
|
+
}
|
|
157790
|
+
// Phase: BeaconProcess
|
|
157791
|
+
// Process each beacon's signals. Collect updates and data needs.
|
|
157792
|
+
case "BeaconProcess" /* BeaconProcess */: {
|
|
157793
|
+
const allNeeds = [];
|
|
157794
|
+
for (const [service, signals] of this.#beaconServicesSignals) {
|
|
157795
|
+
if (this.#processedServices.has(service.id) || !signals.length) continue;
|
|
157796
|
+
const beacon = BeaconFactory.establish(service);
|
|
157797
|
+
const result = beacon.processSignals(signals, this.#sidecarData);
|
|
157798
|
+
if (result.needs.length > 0) {
|
|
157799
|
+
allNeeds.push(...result.needs);
|
|
157800
|
+
} else {
|
|
157801
|
+
this.#unsortedUpdates.push(...result.updates);
|
|
157802
|
+
this.#processedServices.add(service.id);
|
|
157803
|
+
}
|
|
157804
|
+
}
|
|
157805
|
+
if (allNeeds.length > 0) {
|
|
157806
|
+
return { status: "action-required", needs: allNeeds };
|
|
157807
|
+
}
|
|
157808
|
+
this.#phase = "ApplyUpdates" /* ApplyUpdates */;
|
|
157809
|
+
continue;
|
|
157810
|
+
}
|
|
157811
|
+
// Phase: ApplyUpdates
|
|
157812
|
+
// Apply collected updates, then check for new beacon services (multi-round).
|
|
157813
|
+
case "ApplyUpdates" /* ApplyUpdates */: {
|
|
157814
|
+
if (this.#unsortedUpdates.length > 0) {
|
|
157815
|
+
this.#resolvedResponse = _Resolver.updates(
|
|
157816
|
+
this.#currentDocument,
|
|
157817
|
+
this.#unsortedUpdates,
|
|
157818
|
+
this.#versionTime,
|
|
157819
|
+
this.#versionId
|
|
157820
|
+
);
|
|
157821
|
+
this.#currentDocument = this.#resolvedResponse.didDocument;
|
|
157822
|
+
this.#unsortedUpdates = [];
|
|
157823
|
+
const beaconServices = BeaconUtils.getBeaconServices(this.#currentDocument);
|
|
157824
|
+
const hasNewServices = beaconServices.some((service) => {
|
|
157825
|
+
const address = BeaconUtils.parseBitcoinAddress(service.serviceEndpoint);
|
|
157826
|
+
return !this.#requestCache.has(address);
|
|
157827
|
+
});
|
|
157828
|
+
if (hasNewServices) {
|
|
157829
|
+
this.#phase = "BeaconDiscovery" /* BeaconDiscovery */;
|
|
157830
|
+
continue;
|
|
157831
|
+
}
|
|
157832
|
+
}
|
|
157833
|
+
this.#phase = "Complete" /* Complete */;
|
|
157834
|
+
continue;
|
|
157835
|
+
}
|
|
157836
|
+
// Phase: Complete
|
|
157837
|
+
case "Complete" /* Complete */: {
|
|
157838
|
+
return {
|
|
157839
|
+
status: "resolved",
|
|
157840
|
+
result: this.#resolvedResponse ?? {
|
|
157841
|
+
didDocument: this.#currentDocument,
|
|
157842
|
+
metadata: {
|
|
157843
|
+
versionId: this.#versionId ?? "1",
|
|
157844
|
+
deactivated: this.#currentDocument.deactivated || false
|
|
157845
|
+
}
|
|
157846
|
+
}
|
|
157847
|
+
};
|
|
157848
|
+
}
|
|
157849
|
+
}
|
|
157850
|
+
}
|
|
157851
|
+
}
|
|
157852
|
+
provide(need, data) {
|
|
157853
|
+
switch (need.kind) {
|
|
157854
|
+
case "NeedGenesisDocument": {
|
|
157855
|
+
this.#providedGenesisDocument = data;
|
|
157856
|
+
break;
|
|
157857
|
+
}
|
|
157858
|
+
case "NeedBeaconSignals": {
|
|
157859
|
+
const signals = data;
|
|
157860
|
+
for (const [service, serviceSignals] of signals) {
|
|
157861
|
+
this.#beaconServicesSignals.set(service, serviceSignals);
|
|
157862
|
+
}
|
|
157863
|
+
break;
|
|
157864
|
+
}
|
|
157865
|
+
case "NeedCASAnnouncement": {
|
|
157866
|
+
const announcement = data;
|
|
157867
|
+
this.#sidecarData.casMap.set(canonicalHash(announcement), announcement);
|
|
157868
|
+
break;
|
|
157869
|
+
}
|
|
157870
|
+
case "NeedSignedUpdate": {
|
|
157871
|
+
const update = data;
|
|
157872
|
+
this.#sidecarData.updateMap.set(canonicalHash(update), update);
|
|
157873
|
+
break;
|
|
157874
|
+
}
|
|
157875
|
+
}
|
|
157876
|
+
}
|
|
157734
157877
|
};
|
|
157735
157878
|
|
|
157736
157879
|
// src/core/types.ts
|
|
@@ -157848,7 +157991,7 @@ export {
|
|
|
157848
157991
|
Identifier,
|
|
157849
157992
|
MESSAGE_PREFIX,
|
|
157850
157993
|
NostrAdapter,
|
|
157851
|
-
|
|
157994
|
+
Resolver,
|
|
157852
157995
|
SIGNING_SESSION_STATUS,
|
|
157853
157996
|
SMTBeacon,
|
|
157854
157997
|
SMTBeaconError,
|