@forestrie/forestrie-cli 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1087 -195
- package/dist/lib/decode-receipt-labels.d.ts +7 -6
- package/dist/lib/decode-receipt-labels.d.ts.map +1 -1
- package/dist/lib/decode-receipt-labels.js +11 -10
- package/dist/lib/decode-receipt-labels.js.map +1 -1
- package/package.json +4 -4
- package/src/commands/verify-grant.ts +1 -1
- package/src/commands/verify.ts +1 -1
- package/src/lib/checkpoint-provider.ts +73 -30
- package/src/lib/complete-grant-derive.ts +1 -0
- package/src/lib/create-log-prepare.ts +3 -1
- package/src/lib/create-receipt-derive.ts +16 -0
- package/src/lib/decode-checkpoint-calldata.ts +12 -3
- package/src/lib/decode-receipt-labels.ts +11 -10
- package/src/lib/delegate-flow.ts +4 -2
- package/src/lib/http-problem.ts +53 -0
- package/src/lib/resolve-receipt-freshen.ts +9 -11
- package/src/lib/verify-anchored.ts +1 -1
- package/src/lib/verify-checkpoint-chain.ts +2 -2
- package/src/lib/verify-eventscan.ts +2 -2
- package/src/main/onboard-genesis.ts +3 -1
- package/src/main/onboard-request.ts +4 -2
- package/src/options/verify.ts +24 -18
package/dist/cli.js
CHANGED
|
@@ -1841,6 +1841,38 @@ function extractAlgFromProtected(protectedBstr) {
|
|
|
1841
1841
|
} catch {}
|
|
1842
1842
|
return null;
|
|
1843
1843
|
}
|
|
1844
|
+
function readProtectedAlg(protectedBstr) {
|
|
1845
|
+
if (protectedBstr.length === 0) {
|
|
1846
|
+
throw new ProtectedHeaderAlgError("protected header is empty, so it carries no alg (label 1)");
|
|
1847
|
+
}
|
|
1848
|
+
let decoded;
|
|
1849
|
+
try {
|
|
1850
|
+
decoded = decodeCborDeterministic(protectedBstr);
|
|
1851
|
+
} catch (err) {
|
|
1852
|
+
throw new ProtectedHeaderAlgError(`protected header is not decodable CBOR: ${err instanceof Error ? err.message : String(err)}`);
|
|
1853
|
+
}
|
|
1854
|
+
let alg;
|
|
1855
|
+
if (decoded instanceof Map) {
|
|
1856
|
+
alg = decoded.get(1);
|
|
1857
|
+
} else if (typeof decoded === "object" && decoded !== null && !Array.isArray(decoded) && !ArrayBuffer.isView(decoded)) {
|
|
1858
|
+
const obj = decoded;
|
|
1859
|
+
alg = obj[1] ?? obj["1"];
|
|
1860
|
+
} else {
|
|
1861
|
+
throw new ProtectedHeaderAlgError("protected header is not a CBOR map, so it carries no alg (label 1)");
|
|
1862
|
+
}
|
|
1863
|
+
if (typeof alg === "number") {
|
|
1864
|
+
if (!Number.isInteger(alg)) {
|
|
1865
|
+
throw new ProtectedHeaderAlgError(`protected header alg (label 1) is not an integer (got ${alg})`);
|
|
1866
|
+
}
|
|
1867
|
+
return alg;
|
|
1868
|
+
}
|
|
1869
|
+
if (typeof alg === "bigint")
|
|
1870
|
+
return Number(alg);
|
|
1871
|
+
if (alg === undefined) {
|
|
1872
|
+
throw new ProtectedHeaderAlgError("protected header carries no alg (label 1)");
|
|
1873
|
+
}
|
|
1874
|
+
throw new ProtectedHeaderAlgError("protected header alg (label 1) is not an integer");
|
|
1875
|
+
}
|
|
1844
1876
|
async function webauthnEnvelopeSignedBytes(envelope, sigStructure, signature, opts) {
|
|
1845
1877
|
if (!Array.isArray(envelope) || envelope.length !== 2) {
|
|
1846
1878
|
logVerifyFailure(opts, "webauthn_envelope_malformed", {
|
|
@@ -2005,7 +2037,7 @@ function decodeCoseSign1(coseSign1Bytes) {
|
|
|
2005
2037
|
signature: sig
|
|
2006
2038
|
};
|
|
2007
2039
|
}
|
|
2008
|
-
var COSE_ALG_ES256 = -7, COSE_ALG_KS256 = -65799, COSE_ALG_ES256_WEBAUTHN = -65800, WEBAUTHN_ENVELOPE_LABEL, AUTH_FLAG_UP = 1, AUTH_FLAG_UV = 4, AUTH_FLAG_BE = 8, AUTH_FLAG_BS = 16, AUTH_DATA_MIN_BYTES = 37, P256_N, P256_HALF_N;
|
|
2040
|
+
var COSE_ALG_ES256 = -7, COSE_ALG_KS256 = -65799, COSE_ALG_ES256_WEBAUTHN = -65800, WEBAUTHN_ENVELOPE_LABEL, AUTH_FLAG_UP = 1, AUTH_FLAG_UV = 4, AUTH_FLAG_BE = 8, AUTH_FLAG_BS = 16, AUTH_DATA_MIN_BYTES = 37, P256_N, P256_HALF_N, ProtectedHeaderAlgError;
|
|
2009
2041
|
var init_verify_cose_sign1 = __esm(() => {
|
|
2010
2042
|
init_base64url();
|
|
2011
2043
|
init_decode_cbor_deterministic();
|
|
@@ -2013,6 +2045,12 @@ var init_verify_cose_sign1 = __esm(() => {
|
|
|
2013
2045
|
WEBAUTHN_ENVELOPE_LABEL = COSE_ALG_ES256_WEBAUTHN;
|
|
2014
2046
|
P256_N = BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551");
|
|
2015
2047
|
P256_HALF_N = P256_N >> 1n;
|
|
2048
|
+
ProtectedHeaderAlgError = class ProtectedHeaderAlgError extends Error {
|
|
2049
|
+
constructor(message) {
|
|
2050
|
+
super(message);
|
|
2051
|
+
this.name = "ProtectedHeaderAlgError";
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2016
2054
|
});
|
|
2017
2055
|
|
|
2018
2056
|
// node_modules/@forestrie/encoding/dist/verify-delegate-key-voucher.js
|
|
@@ -25591,6 +25629,146 @@ var init_register4 = __esm(() => {
|
|
|
25591
25629
|
run: defineCommandRunner(parseRegisterOptions, runRegister)
|
|
25592
25630
|
});
|
|
25593
25631
|
});
|
|
25632
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/encode-cbor-deterministic.js
|
|
25633
|
+
var init_encode_cbor_deterministic2 = () => {};
|
|
25634
|
+
|
|
25635
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/decode-cbor-deterministic.js
|
|
25636
|
+
var INT64_MIN2;
|
|
25637
|
+
var init_decode_cbor_deterministic2 = __esm(() => {
|
|
25638
|
+
INT64_MIN2 = -9223372036854775808n;
|
|
25639
|
+
});
|
|
25640
|
+
|
|
25641
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/encode-sig-structure.js
|
|
25642
|
+
var init_encode_sig_structure3 = () => {};
|
|
25643
|
+
|
|
25644
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/encode-grant-request.js
|
|
25645
|
+
var init_encode_grant_request3 = () => {};
|
|
25646
|
+
|
|
25647
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/problem-details.js
|
|
25648
|
+
var init_problem_details4 = __esm(() => {
|
|
25649
|
+
init_encode_cbor_deterministic2();
|
|
25650
|
+
});
|
|
25651
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/grant-payload-canonical.js
|
|
25652
|
+
function appendCborBstr3(out, bytes) {
|
|
25653
|
+
const n = bytes.length;
|
|
25654
|
+
if (n < 24)
|
|
25655
|
+
out.push(64 | n);
|
|
25656
|
+
else if (n <= 255)
|
|
25657
|
+
out.push(88, n);
|
|
25658
|
+
else if (n <= 65535)
|
|
25659
|
+
out.push(89, n >> 8 & 255, n & 255);
|
|
25660
|
+
else
|
|
25661
|
+
out.push(90, n >>> 24 & 255, n >> 16 & 255, n >> 8 & 255, n & 255);
|
|
25662
|
+
for (let i = 0;i < n; i++)
|
|
25663
|
+
out.push(bytes[i]);
|
|
25664
|
+
}
|
|
25665
|
+
function appendCborText3(out, s) {
|
|
25666
|
+
const bytes = new TextEncoder().encode(s);
|
|
25667
|
+
const n = bytes.length;
|
|
25668
|
+
if (n < 24)
|
|
25669
|
+
out.push(96 | n);
|
|
25670
|
+
else if (n <= 255)
|
|
25671
|
+
out.push(120, n);
|
|
25672
|
+
else
|
|
25673
|
+
out.push(121, n >> 8 & 255, n & 255);
|
|
25674
|
+
for (let i = 0;i < n; i++)
|
|
25675
|
+
out.push(bytes[i]);
|
|
25676
|
+
}
|
|
25677
|
+
var init_grant_payload_canonical3 = () => {};
|
|
25678
|
+
|
|
25679
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/encode-cose-protected.js
|
|
25680
|
+
var MAX_UINT642;
|
|
25681
|
+
var init_encode_cose_protected3 = __esm(() => {
|
|
25682
|
+
init_grant_payload_canonical3();
|
|
25683
|
+
MAX_UINT642 = (1n << 64n) - 1n;
|
|
25684
|
+
});
|
|
25685
|
+
|
|
25686
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/cose-protected-tree-size.js
|
|
25687
|
+
var init_cose_protected_tree_size2 = __esm(() => {
|
|
25688
|
+
init_decode_cbor_deterministic2();
|
|
25689
|
+
});
|
|
25690
|
+
|
|
25691
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/encode-cose-sign1-statement.js
|
|
25692
|
+
var init_encode_cose_sign1_statement3 = __esm(() => {
|
|
25693
|
+
init_encode_cose_protected3();
|
|
25694
|
+
});
|
|
25695
|
+
|
|
25696
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/sign-cose-sign1-statement.js
|
|
25697
|
+
var init_sign_cose_sign1_statement3 = __esm(() => {
|
|
25698
|
+
init_encode_cose_protected3();
|
|
25699
|
+
init_encode_cose_sign1_statement3();
|
|
25700
|
+
init_encode_sig_structure3();
|
|
25701
|
+
});
|
|
25702
|
+
|
|
25703
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/base64url.js
|
|
25704
|
+
var ALPHABET3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", REVERSE3;
|
|
25705
|
+
var init_base64url3 = __esm(() => {
|
|
25706
|
+
REVERSE3 = (() => {
|
|
25707
|
+
const out = new Int8Array(128).fill(-1);
|
|
25708
|
+
for (let i = 0;i < ALPHABET3.length; i++) {
|
|
25709
|
+
out[ALPHABET3.charCodeAt(i)] = i;
|
|
25710
|
+
}
|
|
25711
|
+
return out;
|
|
25712
|
+
})();
|
|
25713
|
+
});
|
|
25714
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/verify-cose-sign1.js
|
|
25715
|
+
var P256_N3, P256_HALF_N3;
|
|
25716
|
+
var init_verify_cose_sign13 = __esm(() => {
|
|
25717
|
+
init_base64url3();
|
|
25718
|
+
init_decode_cbor_deterministic2();
|
|
25719
|
+
init_encode_sig_structure3();
|
|
25720
|
+
P256_N3 = BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551");
|
|
25721
|
+
P256_HALF_N3 = P256_N3 >> 1n;
|
|
25722
|
+
});
|
|
25723
|
+
|
|
25724
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/verify-delegate-key-voucher.js
|
|
25725
|
+
var init_verify_delegate_key_voucher3 = __esm(() => {
|
|
25726
|
+
init_decode_cbor_deterministic2();
|
|
25727
|
+
init_verify_cose_sign13();
|
|
25728
|
+
});
|
|
25729
|
+
|
|
25730
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/cose-key-thumbprint.js
|
|
25731
|
+
var init_cose_key_thumbprint3 = __esm(() => {
|
|
25732
|
+
init_base64url3();
|
|
25733
|
+
});
|
|
25734
|
+
|
|
25735
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/encode-cose-sign1-raw.js
|
|
25736
|
+
var init_encode_cose_sign1_raw3 = __esm(() => {
|
|
25737
|
+
init_encode_cbor_deterministic2();
|
|
25738
|
+
});
|
|
25739
|
+
|
|
25740
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/merge-cose-sign1-unprotected.js
|
|
25741
|
+
var init_merge_cose_sign1_unprotected3 = __esm(() => {
|
|
25742
|
+
init_verify_cose_sign13();
|
|
25743
|
+
init_encode_cose_sign1_raw3();
|
|
25744
|
+
});
|
|
25745
|
+
|
|
25746
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/grant-codec.js
|
|
25747
|
+
var init_grant_codec3 = __esm(() => {
|
|
25748
|
+
init_encode_cbor_deterministic2();
|
|
25749
|
+
init_decode_cbor_deterministic2();
|
|
25750
|
+
});
|
|
25751
|
+
|
|
25752
|
+
// node_modules/@forestrie/grant-builder/node_modules/@forestrie/encoding/dist/index.js
|
|
25753
|
+
var init_dist7 = __esm(() => {
|
|
25754
|
+
init_encode_cbor_deterministic2();
|
|
25755
|
+
init_decode_cbor_deterministic2();
|
|
25756
|
+
init_encode_sig_structure3();
|
|
25757
|
+
init_encode_grant_request3();
|
|
25758
|
+
init_problem_details4();
|
|
25759
|
+
init_encode_cose_protected3();
|
|
25760
|
+
init_cose_protected_tree_size2();
|
|
25761
|
+
init_encode_cose_sign1_statement3();
|
|
25762
|
+
init_sign_cose_sign1_statement3();
|
|
25763
|
+
init_base64url3();
|
|
25764
|
+
init_verify_cose_sign13();
|
|
25765
|
+
init_verify_delegate_key_voucher3();
|
|
25766
|
+
init_cose_key_thumbprint3();
|
|
25767
|
+
init_encode_cose_sign1_raw3();
|
|
25768
|
+
init_merge_cose_sign1_unprotected3();
|
|
25769
|
+
init_grant_codec3();
|
|
25770
|
+
init_grant_payload_canonical3();
|
|
25771
|
+
});
|
|
25594
25772
|
|
|
25595
25773
|
// node_modules/@forestrie/grant-builder/dist/grant-flags.js
|
|
25596
25774
|
function authLogBootstrapShapedFlags() {
|
|
@@ -25633,7 +25811,7 @@ function bytesToForestrieGrantBase64(bytes) {
|
|
|
25633
25811
|
|
|
25634
25812
|
// node_modules/@forestrie/grant-builder/dist/transparent-statement-assert.js
|
|
25635
25813
|
var init_transparent_statement_assert = __esm(() => {
|
|
25636
|
-
|
|
25814
|
+
init_dist7();
|
|
25637
25815
|
});
|
|
25638
25816
|
|
|
25639
25817
|
// node_modules/@forestrie/grant-builder/dist/es256-pem-grant.js
|
|
@@ -25644,10 +25822,10 @@ function sha2564(bytes) {
|
|
|
25644
25822
|
function signGrantPayloadWithEs256Pem(grantPayloadBytes, es256PrivateKeyPem) {
|
|
25645
25823
|
const payload = sha2564(grantPayloadBytes);
|
|
25646
25824
|
const sig = [132];
|
|
25647
|
-
|
|
25648
|
-
|
|
25649
|
-
|
|
25650
|
-
|
|
25825
|
+
appendCborText3(sig, "Signature1");
|
|
25826
|
+
appendCborBstr3(sig, ES256_PROTECTED_HEADER);
|
|
25827
|
+
appendCborBstr3(sig, new Uint8Array(0));
|
|
25828
|
+
appendCborBstr3(sig, payload);
|
|
25651
25829
|
const sigStructure = new Uint8Array(sig);
|
|
25652
25830
|
const key = createPrivateKey2({ key: es256PrivateKeyPem, format: "pem" });
|
|
25653
25831
|
const signature = new Uint8Array(nodeSign("sha256", Buffer.from(sigStructure), {
|
|
@@ -25658,19 +25836,19 @@ function signGrantPayloadWithEs256Pem(grantPayloadBytes, es256PrivateKeyPem) {
|
|
|
25658
25836
|
throw new Error(`ES256 signature must be ${ES256_RAW_SIG_BYTES}-byte raw r‖s; got ${signature.length}`);
|
|
25659
25837
|
}
|
|
25660
25838
|
const out = [132];
|
|
25661
|
-
|
|
25839
|
+
appendCborBstr3(out, ES256_PROTECTED_HEADER);
|
|
25662
25840
|
out.push(162);
|
|
25663
25841
|
out.push(...CBOR_KEY_IDTIMESTAMP);
|
|
25664
|
-
|
|
25842
|
+
appendCborBstr3(out, new Uint8Array(IDTIMESTAMP_BYTES));
|
|
25665
25843
|
out.push(...CBOR_KEY_FORESTRIE_GRANT_V0);
|
|
25666
|
-
|
|
25667
|
-
|
|
25668
|
-
|
|
25844
|
+
appendCborBstr3(out, grantPayloadBytes);
|
|
25845
|
+
appendCborBstr3(out, payload);
|
|
25846
|
+
appendCborBstr3(out, signature);
|
|
25669
25847
|
return new Uint8Array(out);
|
|
25670
25848
|
}
|
|
25671
25849
|
var ES256_PROTECTED_HEADER, IDTIMESTAMP_BYTES = 8, ES256_RAW_SIG_BYTES = 64, CBOR_KEY_FORESTRIE_GRANT_V0, CBOR_KEY_IDTIMESTAMP;
|
|
25672
25850
|
var init_es256_pem_grant = __esm(() => {
|
|
25673
|
-
|
|
25851
|
+
init_dist7();
|
|
25674
25852
|
ES256_PROTECTED_HEADER = new Uint8Array([161, 1, 38]);
|
|
25675
25853
|
CBOR_KEY_FORESTRIE_GRANT_V0 = [58, 0, 1, 0, 1];
|
|
25676
25854
|
CBOR_KEY_IDTIMESTAMP = [58, 0, 1, 0, 0];
|
|
@@ -25678,16 +25856,16 @@ var init_es256_pem_grant = __esm(() => {
|
|
|
25678
25856
|
|
|
25679
25857
|
// node_modules/@forestrie/grant-builder/dist/mint-es256-root-grant.js
|
|
25680
25858
|
var init_mint_es256_root_grant = __esm(() => {
|
|
25681
|
-
|
|
25682
|
-
|
|
25859
|
+
init_dist7();
|
|
25860
|
+
init_dist7();
|
|
25683
25861
|
init_es256_pem_grant();
|
|
25684
25862
|
});
|
|
25685
25863
|
|
|
25686
25864
|
// node_modules/@forestrie/grant-builder/dist/ks256-wallet-grant.js
|
|
25687
25865
|
var KS256_PROTECTED_HEADER;
|
|
25688
25866
|
var init_ks256_wallet_grant = __esm(() => {
|
|
25689
|
-
|
|
25690
|
-
|
|
25867
|
+
init_dist7();
|
|
25868
|
+
init_dist7();
|
|
25691
25869
|
KS256_PROTECTED_HEADER = new Uint8Array([
|
|
25692
25870
|
161,
|
|
25693
25871
|
1,
|
|
@@ -25700,11 +25878,11 @@ var init_ks256_wallet_grant = __esm(() => {
|
|
|
25700
25878
|
});
|
|
25701
25879
|
|
|
25702
25880
|
// node_modules/@forestrie/grant-builder/dist/index.js
|
|
25703
|
-
var
|
|
25704
|
-
|
|
25705
|
-
|
|
25706
|
-
|
|
25707
|
-
|
|
25881
|
+
var init_dist8 = __esm(() => {
|
|
25882
|
+
init_dist7();
|
|
25883
|
+
init_dist7();
|
|
25884
|
+
init_dist7();
|
|
25885
|
+
init_dist7();
|
|
25708
25886
|
init_transparent_statement_assert();
|
|
25709
25887
|
init_es256_pem_grant();
|
|
25710
25888
|
init_mint_es256_root_grant();
|
|
@@ -25783,7 +25961,7 @@ function buildGrantStatement(params) {
|
|
|
25783
25961
|
var RegisterGrantBuildError, ES256_XY_BYTES = 64;
|
|
25784
25962
|
var init_register_grant_build = __esm(() => {
|
|
25785
25963
|
init_openssl_error_queue();
|
|
25786
|
-
|
|
25964
|
+
init_dist8();
|
|
25787
25965
|
init_dist3();
|
|
25788
25966
|
RegisterGrantBuildError = class RegisterGrantBuildError extends Error {
|
|
25789
25967
|
constructor(message) {
|
|
@@ -25848,7 +26026,7 @@ function buildCreateLogGrant(params) {
|
|
|
25848
26026
|
};
|
|
25849
26027
|
}
|
|
25850
26028
|
var init_create_log_build = __esm(() => {
|
|
25851
|
-
|
|
26029
|
+
init_dist8();
|
|
25852
26030
|
init_dist3();
|
|
25853
26031
|
init_register_grant_build();
|
|
25854
26032
|
});
|
|
@@ -25869,11 +26047,45 @@ function completeGrantBase64(grantBase64, receiptBytes, entryIdHex) {
|
|
|
25869
26047
|
}
|
|
25870
26048
|
var ENTRY_ID_HEX_RE;
|
|
25871
26049
|
var init_register_grant_complete = __esm(() => {
|
|
25872
|
-
|
|
26050
|
+
init_dist8();
|
|
25873
26051
|
init_dist3();
|
|
25874
26052
|
ENTRY_ID_HEX_RE = /^[0-9a-f]{32}$/i;
|
|
25875
26053
|
});
|
|
25876
26054
|
|
|
26055
|
+
// src/lib/http-problem.ts
|
|
26056
|
+
function describe(problem) {
|
|
26057
|
+
const { title, detail } = problem;
|
|
26058
|
+
if (detail && title)
|
|
26059
|
+
return `${title}: ${detail}`;
|
|
26060
|
+
return detail ?? title;
|
|
26061
|
+
}
|
|
26062
|
+
async function responseProblemDetail(response, max = MAX_PROBLEM_DETAIL) {
|
|
26063
|
+
const contentType = (response.headers.get("content-type") ?? "").toLowerCase();
|
|
26064
|
+
let text = "";
|
|
26065
|
+
try {
|
|
26066
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
26067
|
+
if (bytes.length === 0)
|
|
26068
|
+
return "";
|
|
26069
|
+
if (contentType.includes("cbor")) {
|
|
26070
|
+
const problem = decodeProblemDetailsBytes(bytes);
|
|
26071
|
+
const described = problem && describe(problem);
|
|
26072
|
+
if (described)
|
|
26073
|
+
return described.slice(0, max);
|
|
26074
|
+
}
|
|
26075
|
+
text = new TextDecoder().decode(bytes);
|
|
26076
|
+
if (contentType.includes("json")) {
|
|
26077
|
+
const described = describe(JSON.parse(text));
|
|
26078
|
+
if (described)
|
|
26079
|
+
return described.slice(0, max);
|
|
26080
|
+
}
|
|
26081
|
+
} catch {}
|
|
26082
|
+
return text.slice(0, max);
|
|
26083
|
+
}
|
|
26084
|
+
var MAX_PROBLEM_DETAIL = 512;
|
|
26085
|
+
var init_http_problem = __esm(() => {
|
|
26086
|
+
init_dist6();
|
|
26087
|
+
});
|
|
26088
|
+
|
|
25877
26089
|
// src/lib/create-log-prepare.ts
|
|
25878
26090
|
async function prepareChildLog(params, deps = {}) {
|
|
25879
26091
|
const fetchImpl = deps.fetchImpl ?? fetch;
|
|
@@ -25883,7 +26095,7 @@ async function prepareChildLog(params, deps = {}) {
|
|
|
25883
26095
|
headers: { Authorization: `Forestrie-Grant ${params.grantBase64}` }
|
|
25884
26096
|
});
|
|
25885
26097
|
if (!res.ok) {
|
|
25886
|
-
const preview =
|
|
26098
|
+
const preview = await responseProblemDetail(res, 300);
|
|
25887
26099
|
throw new PrepareLogError(`prepare failed: HTTP ${res.status} ${preview}`, res.status);
|
|
25888
26100
|
}
|
|
25889
26101
|
let publicRoot = "ok";
|
|
@@ -25903,6 +26115,7 @@ async function prepareChildLog(params, deps = {}) {
|
|
|
25903
26115
|
}
|
|
25904
26116
|
var PrepareLogError;
|
|
25905
26117
|
var init_create_log_prepare = __esm(() => {
|
|
26118
|
+
init_http_problem();
|
|
25906
26119
|
PrepareLogError = class PrepareLogError extends Error {
|
|
25907
26120
|
httpStatus;
|
|
25908
26121
|
constructor(message, httpStatus) {
|
|
@@ -26658,7 +26871,513 @@ var init_register_grant3 = __esm(() => {
|
|
|
26658
26871
|
var DELEGATION_CONTENT_TYPE = "application/forestrie.delegation+cbor";
|
|
26659
26872
|
|
|
26660
26873
|
// node_modules/@forestrie/delegation-cose/dist/payload-labels.js
|
|
26661
|
-
var COSE_HEADER_ALG = 1, COSE_HEADER_CTY = 3, COSE_HEADER_KID = 4, PAYLOAD_LOG_ID = 1, PAYLOAD_MMR_START = 3, PAYLOAD_MMR_END = 4, PAYLOAD_DELEGATED_KEY = 5, PAYLOAD_CONSTRAINTS = 6, PAYLOAD_SCHEMA_VER = 7, PAYLOAD_ISSUED_AT = 8, PAYLOAD_EXPIRES_AT = 9, PAYLOAD_DELEGATION_ID = 10, COSE_KTY = 1, COSE_CRV = -1, COSE_X = -2, COSE_Y = -3, COSE_KTY_EC2 = 2, COSE_CRV_P256 = 1,
|
|
26874
|
+
var COSE_HEADER_ALG = 1, COSE_HEADER_CTY = 3, COSE_HEADER_KID = 4, PAYLOAD_LOG_ID = 1, PAYLOAD_MMR_START = 3, PAYLOAD_MMR_END = 4, PAYLOAD_DELEGATED_KEY = 5, PAYLOAD_CONSTRAINTS = 6, PAYLOAD_SCHEMA_VER = 7, PAYLOAD_ISSUED_AT = 8, PAYLOAD_EXPIRES_AT = 9, PAYLOAD_DELEGATION_ID = 10, COSE_KTY = 1, COSE_CRV = -1, COSE_X = -2, COSE_Y = -3, COSE_KTY_EC2 = 2, COSE_CRV_P256 = 1, COSE_ALG_ES2564 = -7, KS256_EOA_SIG_BYTES = 65, ES256_SIG_BYTES = 64;
|
|
26875
|
+
|
|
26876
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/canonical-key-order.js
|
|
26877
|
+
function compareCanonicalKeys3(a, b) {
|
|
26878
|
+
if (a.length !== b.length)
|
|
26879
|
+
return a.length - b.length;
|
|
26880
|
+
for (let i = 0;i < a.length; i++) {
|
|
26881
|
+
if (a[i] !== b[i])
|
|
26882
|
+
return a[i] - b[i];
|
|
26883
|
+
}
|
|
26884
|
+
return 0;
|
|
26885
|
+
}
|
|
26886
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/encode-cbor-deterministic.js
|
|
26887
|
+
function concat6(chunks) {
|
|
26888
|
+
let total = 0;
|
|
26889
|
+
for (const c of chunks)
|
|
26890
|
+
total += c.length;
|
|
26891
|
+
const out = new Uint8Array(total);
|
|
26892
|
+
let off = 0;
|
|
26893
|
+
for (const c of chunks) {
|
|
26894
|
+
out.set(c, off);
|
|
26895
|
+
off += c.length;
|
|
26896
|
+
}
|
|
26897
|
+
return out;
|
|
26898
|
+
}
|
|
26899
|
+
function encodeHead3(major, argument) {
|
|
26900
|
+
const mt = major << 5;
|
|
26901
|
+
const n = typeof argument === "bigint" ? argument : BigInt(argument);
|
|
26902
|
+
if (n < 0n)
|
|
26903
|
+
throw new Error("encodeHead: argument must be non-negative");
|
|
26904
|
+
if (n < 24n)
|
|
26905
|
+
return new Uint8Array([mt | Number(n)]);
|
|
26906
|
+
if (n < 0x100n)
|
|
26907
|
+
return new Uint8Array([mt | 24, Number(n)]);
|
|
26908
|
+
if (n < 0x10000n) {
|
|
26909
|
+
return new Uint8Array([mt | 25, Number(n >> 8n) & 255, Number(n) & 255]);
|
|
26910
|
+
}
|
|
26911
|
+
if (n < 0x100000000n) {
|
|
26912
|
+
return new Uint8Array([
|
|
26913
|
+
mt | 26,
|
|
26914
|
+
Number(n >> 24n & 0xffn),
|
|
26915
|
+
Number(n >> 16n & 0xffn),
|
|
26916
|
+
Number(n >> 8n & 0xffn),
|
|
26917
|
+
Number(n & 0xffn)
|
|
26918
|
+
]);
|
|
26919
|
+
}
|
|
26920
|
+
if (n < 0x10000000000000000n) {
|
|
26921
|
+
const out = new Uint8Array(9);
|
|
26922
|
+
out[0] = mt | 27;
|
|
26923
|
+
let v = n;
|
|
26924
|
+
for (let i = 8;i >= 1; i--) {
|
|
26925
|
+
out[i] = Number(v & 0xffn);
|
|
26926
|
+
v >>= 8n;
|
|
26927
|
+
}
|
|
26928
|
+
return out;
|
|
26929
|
+
}
|
|
26930
|
+
throw new Error("encodeHead: argument exceeds 64-bit range");
|
|
26931
|
+
}
|
|
26932
|
+
function encodeInteger3(v) {
|
|
26933
|
+
if (typeof v === "number" && !Number.isInteger(v)) {
|
|
26934
|
+
throw new Error(`encodeCborDeterministic: non-integer number ${v}`);
|
|
26935
|
+
}
|
|
26936
|
+
const n = typeof v === "bigint" ? v : BigInt(v);
|
|
26937
|
+
if (n >= 0n)
|
|
26938
|
+
return encodeHead3(MAJOR_UINT3, n);
|
|
26939
|
+
return encodeHead3(MAJOR_NINT3, -1n - n);
|
|
26940
|
+
}
|
|
26941
|
+
function encodeCborDeterministic4(value) {
|
|
26942
|
+
return encodeValue3(value, 0);
|
|
26943
|
+
}
|
|
26944
|
+
function encodeValue3(value, depth) {
|
|
26945
|
+
if (depth > MAX_DEPTH3) {
|
|
26946
|
+
throw new Error(`encodeCborDeterministic: nesting exceeds ${MAX_DEPTH3}`);
|
|
26947
|
+
}
|
|
26948
|
+
if (typeof value === "number" || typeof value === "bigint") {
|
|
26949
|
+
return encodeInteger3(value);
|
|
26950
|
+
}
|
|
26951
|
+
if (typeof value === "boolean") {
|
|
26952
|
+
return new Uint8Array([value ? 245 : 244]);
|
|
26953
|
+
}
|
|
26954
|
+
if (value === null) {
|
|
26955
|
+
return new Uint8Array([246]);
|
|
26956
|
+
}
|
|
26957
|
+
if (value instanceof Uint8Array) {
|
|
26958
|
+
return concat6([encodeHead3(MAJOR_BSTR3, value.length), value]);
|
|
26959
|
+
}
|
|
26960
|
+
if (value instanceof ArrayBuffer) {
|
|
26961
|
+
const bytes = new Uint8Array(value);
|
|
26962
|
+
return concat6([encodeHead3(MAJOR_BSTR3, bytes.length), bytes]);
|
|
26963
|
+
}
|
|
26964
|
+
if (typeof value === "string") {
|
|
26965
|
+
const bytes = new TextEncoder().encode(value);
|
|
26966
|
+
return concat6([encodeHead3(MAJOR_TSTR3, bytes.length), bytes]);
|
|
26967
|
+
}
|
|
26968
|
+
if (Array.isArray(value)) {
|
|
26969
|
+
const items = value.map((v) => encodeValue3(v, depth + 1));
|
|
26970
|
+
return concat6([encodeHead3(MAJOR_ARRAY3, value.length), ...items]);
|
|
26971
|
+
}
|
|
26972
|
+
if (value instanceof Map) {
|
|
26973
|
+
return encodeMap3(value.entries(), depth);
|
|
26974
|
+
}
|
|
26975
|
+
if (typeof value === "object") {
|
|
26976
|
+
const entries = Object.entries(value).filter(([, v]) => v !== undefined);
|
|
26977
|
+
return encodeMap3(entries[Symbol.iterator](), depth);
|
|
26978
|
+
}
|
|
26979
|
+
throw new Error(`encodeCborDeterministic: unsupported value type ${typeof value}`);
|
|
26980
|
+
}
|
|
26981
|
+
function encodeMap3(entries, depth) {
|
|
26982
|
+
const encoded = Array.from(entries).map(([k, v]) => {
|
|
26983
|
+
if (typeof k !== "number" && typeof k !== "bigint" && typeof k !== "string") {
|
|
26984
|
+
throw new Error(`encodeCborDeterministic: unsupported map key type ${typeof k}`);
|
|
26985
|
+
}
|
|
26986
|
+
return {
|
|
26987
|
+
keyBytes: encodeValue3(k, depth + 1),
|
|
26988
|
+
valueBytes: encodeValue3(v, depth + 1)
|
|
26989
|
+
};
|
|
26990
|
+
});
|
|
26991
|
+
encoded.sort((a, b) => compareCanonicalKeys3(a.keyBytes, b.keyBytes));
|
|
26992
|
+
for (let i = 1;i < encoded.length; i++) {
|
|
26993
|
+
if (compareCanonicalKeys3(encoded[i - 1].keyBytes, encoded[i].keyBytes) === 0) {
|
|
26994
|
+
throw new Error("encodeCborDeterministic: duplicate map key");
|
|
26995
|
+
}
|
|
26996
|
+
}
|
|
26997
|
+
const chunks = [encodeHead3(MAJOR_MAP3, encoded.length)];
|
|
26998
|
+
for (const e of encoded)
|
|
26999
|
+
chunks.push(e.keyBytes, e.valueBytes);
|
|
27000
|
+
return concat6(chunks);
|
|
27001
|
+
}
|
|
27002
|
+
var MAJOR_UINT3 = 0, MAJOR_NINT3 = 1, MAJOR_BSTR3 = 2, MAJOR_TSTR3 = 3, MAJOR_ARRAY3 = 4, MAJOR_MAP3 = 5, MAX_DEPTH3 = 64;
|
|
27003
|
+
var init_encode_cbor_deterministic3 = () => {};
|
|
27004
|
+
|
|
27005
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/decode-cbor-deterministic.js
|
|
27006
|
+
class CborTag4 {
|
|
27007
|
+
tag;
|
|
27008
|
+
value;
|
|
27009
|
+
constructor(tag, value) {
|
|
27010
|
+
this.tag = tag;
|
|
27011
|
+
this.value = value;
|
|
27012
|
+
}
|
|
27013
|
+
}
|
|
27014
|
+
|
|
27015
|
+
class CborSimple3 {
|
|
27016
|
+
value;
|
|
27017
|
+
constructor(value) {
|
|
27018
|
+
this.value = value;
|
|
27019
|
+
}
|
|
27020
|
+
}
|
|
27021
|
+
|
|
27022
|
+
class CborFloat3 {
|
|
27023
|
+
value;
|
|
27024
|
+
constructor(value) {
|
|
27025
|
+
this.value = value;
|
|
27026
|
+
}
|
|
27027
|
+
}
|
|
27028
|
+
|
|
27029
|
+
class Reader3 {
|
|
27030
|
+
buf;
|
|
27031
|
+
rejectTags;
|
|
27032
|
+
pos = 0;
|
|
27033
|
+
constructor(buf, rejectTags) {
|
|
27034
|
+
this.buf = buf;
|
|
27035
|
+
this.rejectTags = rejectTags;
|
|
27036
|
+
}
|
|
27037
|
+
need(n) {
|
|
27038
|
+
if (this.pos + n > this.buf.length) {
|
|
27039
|
+
throw new Error("decodeCbor: unexpected end of input");
|
|
27040
|
+
}
|
|
27041
|
+
}
|
|
27042
|
+
u8() {
|
|
27043
|
+
this.need(1);
|
|
27044
|
+
return this.buf[this.pos++];
|
|
27045
|
+
}
|
|
27046
|
+
bytes(n) {
|
|
27047
|
+
this.need(n);
|
|
27048
|
+
const out = this.buf.subarray(this.pos, this.pos + n);
|
|
27049
|
+
this.pos += n;
|
|
27050
|
+
return out.slice();
|
|
27051
|
+
}
|
|
27052
|
+
argument(ai) {
|
|
27053
|
+
if (ai < 24)
|
|
27054
|
+
return ai;
|
|
27055
|
+
if (ai === 24) {
|
|
27056
|
+
const v = this.u8();
|
|
27057
|
+
if (v < 24)
|
|
27058
|
+
throw this.notShortest(v);
|
|
27059
|
+
return v;
|
|
27060
|
+
}
|
|
27061
|
+
if (ai === 25) {
|
|
27062
|
+
this.need(2);
|
|
27063
|
+
const v = this.buf[this.pos] << 8 | this.buf[this.pos + 1];
|
|
27064
|
+
this.pos += 2;
|
|
27065
|
+
if (v < 256)
|
|
27066
|
+
throw this.notShortest(v);
|
|
27067
|
+
return v;
|
|
27068
|
+
}
|
|
27069
|
+
if (ai === 26) {
|
|
27070
|
+
this.need(4);
|
|
27071
|
+
const v = this.buf[this.pos] * 16777216 + (this.buf[this.pos + 1] << 16) + (this.buf[this.pos + 2] << 8) + this.buf[this.pos + 3];
|
|
27072
|
+
this.pos += 4;
|
|
27073
|
+
if (v < 65536)
|
|
27074
|
+
throw this.notShortest(v);
|
|
27075
|
+
return v;
|
|
27076
|
+
}
|
|
27077
|
+
if (ai === 27) {
|
|
27078
|
+
this.need(8);
|
|
27079
|
+
let v = 0n;
|
|
27080
|
+
for (let i = 0;i < 8; i++)
|
|
27081
|
+
v = v << 8n | BigInt(this.buf[this.pos + i]);
|
|
27082
|
+
this.pos += 8;
|
|
27083
|
+
if (v < 0x100000000n)
|
|
27084
|
+
throw this.notShortest(v);
|
|
27085
|
+
return v <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(v) : v;
|
|
27086
|
+
}
|
|
27087
|
+
throw new Error(`decodeCbor: malformed additional info ${ai}`);
|
|
27088
|
+
}
|
|
27089
|
+
notShortest(v) {
|
|
27090
|
+
return new Error(`decodeCbor: argument ${v} is not in shortest form (RFC 8949 4.2.1)`);
|
|
27091
|
+
}
|
|
27092
|
+
checkDeclaredLength(declared, itemsEach, what) {
|
|
27093
|
+
const remaining = BigInt(this.buf.length - this.pos);
|
|
27094
|
+
if (BigInt(declared) * BigInt(itemsEach) > remaining) {
|
|
27095
|
+
throw new Error(`decodeCbor: ${what} declares ${declared} but only ${remaining} byte(s) remain`);
|
|
27096
|
+
}
|
|
27097
|
+
return Number(declared);
|
|
27098
|
+
}
|
|
27099
|
+
float16() {
|
|
27100
|
+
const b = this.bytes(2);
|
|
27101
|
+
const half = b[0] << 8 | b[1];
|
|
27102
|
+
const exponent = half >> 10 & 31;
|
|
27103
|
+
const fraction = half & 1023;
|
|
27104
|
+
if (exponent === 31 && fraction !== 0 && half !== 32256) {
|
|
27105
|
+
throw notPreferredFloat2(`NaN payload f9${half.toString(16).padStart(4, "0")}`, "f97e00");
|
|
27106
|
+
}
|
|
27107
|
+
const sign2 = half & 32768 ? -1 : 1;
|
|
27108
|
+
if (exponent === 0)
|
|
27109
|
+
return sign2 * fraction * 2 ** -24;
|
|
27110
|
+
if (exponent === 31)
|
|
27111
|
+
return fraction ? NaN : sign2 * Infinity;
|
|
27112
|
+
return sign2 * (fraction + 1024) * 2 ** (exponent - 25);
|
|
27113
|
+
}
|
|
27114
|
+
float32() {
|
|
27115
|
+
const v = new DataView(this.bytes(4).buffer).getFloat32(0);
|
|
27116
|
+
if (Number.isNaN(v))
|
|
27117
|
+
throw notPreferredFloat2("NaN as fa", "f97e00");
|
|
27118
|
+
if (isFloat16Exact2(v))
|
|
27119
|
+
throw notPreferredFloat2(`single ${v}`, "half (f9)");
|
|
27120
|
+
return v;
|
|
27121
|
+
}
|
|
27122
|
+
float64() {
|
|
27123
|
+
const v = new DataView(this.bytes(8).buffer).getFloat64(0);
|
|
27124
|
+
if (Number.isNaN(v))
|
|
27125
|
+
throw notPreferredFloat2("NaN as fb", "f97e00");
|
|
27126
|
+
if (isFloat16Exact2(v))
|
|
27127
|
+
throw notPreferredFloat2(`double ${v}`, "half (f9)");
|
|
27128
|
+
if (Math.fround(v) === v) {
|
|
27129
|
+
throw notPreferredFloat2(`double ${v}`, "single (fa)");
|
|
27130
|
+
}
|
|
27131
|
+
return v;
|
|
27132
|
+
}
|
|
27133
|
+
value(depth) {
|
|
27134
|
+
if (depth > 64)
|
|
27135
|
+
throw new Error("decodeCbor: nesting too deep");
|
|
27136
|
+
const ib = this.u8();
|
|
27137
|
+
const major = ib >> 5;
|
|
27138
|
+
const ai = ib & 31;
|
|
27139
|
+
if (ai === 31) {
|
|
27140
|
+
throw new Error(major === 7 ? "decodeCbor: break code (0xff) is not a well-formed item" : "decodeCbor: indefinite lengths not allowed");
|
|
27141
|
+
}
|
|
27142
|
+
switch (major) {
|
|
27143
|
+
case 0:
|
|
27144
|
+
return this.argument(ai);
|
|
27145
|
+
case 1: {
|
|
27146
|
+
const n = this.argument(ai);
|
|
27147
|
+
return typeof n === "bigint" ? -1n - n : -1 - n;
|
|
27148
|
+
}
|
|
27149
|
+
case 2: {
|
|
27150
|
+
const len = Number(this.argument(ai));
|
|
27151
|
+
return this.bytes(len);
|
|
27152
|
+
}
|
|
27153
|
+
case 3: {
|
|
27154
|
+
const len = Number(this.argument(ai));
|
|
27155
|
+
return new TextDecoder("utf-8", {
|
|
27156
|
+
fatal: true,
|
|
27157
|
+
ignoreBOM: false
|
|
27158
|
+
}).decode(this.bytes(len));
|
|
27159
|
+
}
|
|
27160
|
+
case 4: {
|
|
27161
|
+
const len = this.checkDeclaredLength(this.argument(ai), 1, "array");
|
|
27162
|
+
const out = new Array(len);
|
|
27163
|
+
for (let i = 0;i < len; i++)
|
|
27164
|
+
out[i] = this.value(depth + 1);
|
|
27165
|
+
return out;
|
|
27166
|
+
}
|
|
27167
|
+
case 5:
|
|
27168
|
+
return this.map(ai, depth);
|
|
27169
|
+
case 6: {
|
|
27170
|
+
const tag = Number(this.argument(ai));
|
|
27171
|
+
if (this.rejectTags) {
|
|
27172
|
+
throw new Error(`decodeCbor: tag ${tag} is not allowed here`);
|
|
27173
|
+
}
|
|
27174
|
+
return new CborTag4(tag, this.value(depth + 1));
|
|
27175
|
+
}
|
|
27176
|
+
case 7: {
|
|
27177
|
+
if (ai < 20)
|
|
27178
|
+
return new CborSimple3(ai);
|
|
27179
|
+
switch (ai) {
|
|
27180
|
+
case 20:
|
|
27181
|
+
return false;
|
|
27182
|
+
case 21:
|
|
27183
|
+
return true;
|
|
27184
|
+
case 22:
|
|
27185
|
+
return null;
|
|
27186
|
+
case 23:
|
|
27187
|
+
throw new Error("decodeCbor: undefined (0xf7) is not allowed; it re-encodes as null");
|
|
27188
|
+
case 24: {
|
|
27189
|
+
const v = this.u8();
|
|
27190
|
+
if (v < 32) {
|
|
27191
|
+
throw new Error(`decodeCbor: two-byte simple value ${v} below 32 is malformed`);
|
|
27192
|
+
}
|
|
27193
|
+
return new CborSimple3(v);
|
|
27194
|
+
}
|
|
27195
|
+
case 25:
|
|
27196
|
+
return new CborFloat3(this.float16());
|
|
27197
|
+
case 26:
|
|
27198
|
+
return new CborFloat3(this.float32());
|
|
27199
|
+
case 27:
|
|
27200
|
+
return new CborFloat3(this.float64());
|
|
27201
|
+
default:
|
|
27202
|
+
throw new Error(`decodeCbor: malformed additional info ${ai} (major type 7)`);
|
|
27203
|
+
}
|
|
27204
|
+
}
|
|
27205
|
+
default:
|
|
27206
|
+
throw new Error(`decodeCbor: unsupported major type ${major}`);
|
|
27207
|
+
}
|
|
27208
|
+
}
|
|
27209
|
+
map(ai, depth) {
|
|
27210
|
+
const pairs = this.checkDeclaredLength(this.argument(ai), 2, "map");
|
|
27211
|
+
const m = new Map;
|
|
27212
|
+
let previousKey = null;
|
|
27213
|
+
for (let i = 0;i < pairs; i++) {
|
|
27214
|
+
const keyStart = this.pos;
|
|
27215
|
+
const key = this.value(depth + 1);
|
|
27216
|
+
const keyBytes = this.buf.subarray(keyStart, this.pos);
|
|
27217
|
+
checkKeyMagnitude2(key);
|
|
27218
|
+
if (previousKey !== null) {
|
|
27219
|
+
const order = compareCanonicalKeys3(previousKey, keyBytes);
|
|
27220
|
+
if (order === 0) {
|
|
27221
|
+
throw new Error(`decodeCbor: duplicate map key ${describeKey2(key)}`);
|
|
27222
|
+
}
|
|
27223
|
+
if (order > 0) {
|
|
27224
|
+
throw new Error(`decodeCbor: map key ${describeKey2(key)} is out of canonical order`);
|
|
27225
|
+
}
|
|
27226
|
+
}
|
|
27227
|
+
previousKey = keyBytes;
|
|
27228
|
+
m.set(key, this.value(depth + 1));
|
|
27229
|
+
}
|
|
27230
|
+
return m;
|
|
27231
|
+
}
|
|
27232
|
+
}
|
|
27233
|
+
function checkKeyMagnitude2(key) {
|
|
27234
|
+
if (typeof key !== "bigint")
|
|
27235
|
+
return;
|
|
27236
|
+
if (key > INT64_MAX2 || key < INT64_MIN3) {
|
|
27237
|
+
throw new Error(`decodeCbor: integer map key ${key} exceeds int64 magnitude`);
|
|
27238
|
+
}
|
|
27239
|
+
}
|
|
27240
|
+
function notPreferredFloat2(got, want) {
|
|
27241
|
+
return new Error(`decodeCbor: float ${got} is not in shortest form; it re-encodes as ${want} (RFC 8949 4.2.2)`);
|
|
27242
|
+
}
|
|
27243
|
+
function isFloat16Exact2(v) {
|
|
27244
|
+
if (v === 0)
|
|
27245
|
+
return true;
|
|
27246
|
+
if (!Number.isFinite(v))
|
|
27247
|
+
return true;
|
|
27248
|
+
const a = Math.abs(v);
|
|
27249
|
+
if (a > 65504)
|
|
27250
|
+
return false;
|
|
27251
|
+
if (a < 2 ** -24)
|
|
27252
|
+
return false;
|
|
27253
|
+
const view = new DataView(new ArrayBuffer(8));
|
|
27254
|
+
view.setFloat64(0, a);
|
|
27255
|
+
const exponent = (view.getUint32(0) >>> 20 & 2047) - 1023;
|
|
27256
|
+
const step = exponent >= -14 ? 2 ** (exponent - 10) : 2 ** -24;
|
|
27257
|
+
return a % step === 0;
|
|
27258
|
+
}
|
|
27259
|
+
function describeKey2(key) {
|
|
27260
|
+
return typeof key === "string" ? JSON.stringify(key) : String(key);
|
|
27261
|
+
}
|
|
27262
|
+
function decodeCborDeterministic4(bytes, options) {
|
|
27263
|
+
const r = new Reader3(bytes, options?.tags === "reject");
|
|
27264
|
+
const v = r.value(0);
|
|
27265
|
+
if (r.pos !== bytes.length) {
|
|
27266
|
+
throw new Error(`decodeCbor: ${bytes.length - r.pos} trailing byte(s) after item`);
|
|
27267
|
+
}
|
|
27268
|
+
return v;
|
|
27269
|
+
}
|
|
27270
|
+
var INT64_MAX2 = 9223372036854775807n, INT64_MIN3;
|
|
27271
|
+
var init_decode_cbor_deterministic3 = __esm(() => {
|
|
27272
|
+
INT64_MIN3 = -9223372036854775808n;
|
|
27273
|
+
});
|
|
27274
|
+
|
|
27275
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/encode-sig-structure.js
|
|
27276
|
+
var init_encode_sig_structure4 = () => {};
|
|
27277
|
+
|
|
27278
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/encode-grant-request.js
|
|
27279
|
+
var init_encode_grant_request4 = () => {};
|
|
27280
|
+
|
|
27281
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/problem-details.js
|
|
27282
|
+
var init_problem_details5 = __esm(() => {
|
|
27283
|
+
init_encode_cbor_deterministic3();
|
|
27284
|
+
});
|
|
27285
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/grant-payload-canonical.js
|
|
27286
|
+
var init_grant_payload_canonical4 = () => {};
|
|
27287
|
+
|
|
27288
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/encode-cose-protected.js
|
|
27289
|
+
var MAX_UINT643;
|
|
27290
|
+
var init_encode_cose_protected4 = __esm(() => {
|
|
27291
|
+
init_grant_payload_canonical4();
|
|
27292
|
+
MAX_UINT643 = (1n << 64n) - 1n;
|
|
27293
|
+
});
|
|
27294
|
+
|
|
27295
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/cose-protected-tree-size.js
|
|
27296
|
+
var init_cose_protected_tree_size3 = __esm(() => {
|
|
27297
|
+
init_decode_cbor_deterministic3();
|
|
27298
|
+
});
|
|
27299
|
+
|
|
27300
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/encode-cose-sign1-statement.js
|
|
27301
|
+
var init_encode_cose_sign1_statement4 = __esm(() => {
|
|
27302
|
+
init_encode_cose_protected4();
|
|
27303
|
+
});
|
|
27304
|
+
|
|
27305
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/sign-cose-sign1-statement.js
|
|
27306
|
+
var init_sign_cose_sign1_statement4 = __esm(() => {
|
|
27307
|
+
init_encode_cose_protected4();
|
|
27308
|
+
init_encode_cose_sign1_statement4();
|
|
27309
|
+
init_encode_sig_structure4();
|
|
27310
|
+
});
|
|
27311
|
+
|
|
27312
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/base64url.js
|
|
27313
|
+
var ALPHABET4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_", REVERSE4;
|
|
27314
|
+
var init_base64url4 = __esm(() => {
|
|
27315
|
+
REVERSE4 = (() => {
|
|
27316
|
+
const out = new Int8Array(128).fill(-1);
|
|
27317
|
+
for (let i = 0;i < ALPHABET4.length; i++) {
|
|
27318
|
+
out[ALPHABET4.charCodeAt(i)] = i;
|
|
27319
|
+
}
|
|
27320
|
+
return out;
|
|
27321
|
+
})();
|
|
27322
|
+
});
|
|
27323
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/verify-cose-sign1.js
|
|
27324
|
+
var P256_N4, P256_HALF_N4;
|
|
27325
|
+
var init_verify_cose_sign14 = __esm(() => {
|
|
27326
|
+
init_base64url4();
|
|
27327
|
+
init_decode_cbor_deterministic3();
|
|
27328
|
+
init_encode_sig_structure4();
|
|
27329
|
+
P256_N4 = BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551");
|
|
27330
|
+
P256_HALF_N4 = P256_N4 >> 1n;
|
|
27331
|
+
});
|
|
27332
|
+
|
|
27333
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/verify-delegate-key-voucher.js
|
|
27334
|
+
var init_verify_delegate_key_voucher4 = __esm(() => {
|
|
27335
|
+
init_decode_cbor_deterministic3();
|
|
27336
|
+
init_verify_cose_sign14();
|
|
27337
|
+
});
|
|
27338
|
+
|
|
27339
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/cose-key-thumbprint.js
|
|
27340
|
+
var init_cose_key_thumbprint4 = __esm(() => {
|
|
27341
|
+
init_base64url4();
|
|
27342
|
+
});
|
|
27343
|
+
|
|
27344
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/encode-cose-sign1-raw.js
|
|
27345
|
+
var init_encode_cose_sign1_raw4 = __esm(() => {
|
|
27346
|
+
init_encode_cbor_deterministic3();
|
|
27347
|
+
});
|
|
27348
|
+
|
|
27349
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/merge-cose-sign1-unprotected.js
|
|
27350
|
+
var init_merge_cose_sign1_unprotected4 = __esm(() => {
|
|
27351
|
+
init_verify_cose_sign14();
|
|
27352
|
+
init_encode_cose_sign1_raw4();
|
|
27353
|
+
});
|
|
27354
|
+
|
|
27355
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/grant-codec.js
|
|
27356
|
+
var init_grant_codec4 = __esm(() => {
|
|
27357
|
+
init_encode_cbor_deterministic3();
|
|
27358
|
+
init_decode_cbor_deterministic3();
|
|
27359
|
+
});
|
|
27360
|
+
|
|
27361
|
+
// node_modules/@forestrie/delegation-cose/node_modules/@forestrie/encoding/dist/index.js
|
|
27362
|
+
var init_dist9 = __esm(() => {
|
|
27363
|
+
init_encode_cbor_deterministic3();
|
|
27364
|
+
init_decode_cbor_deterministic3();
|
|
27365
|
+
init_encode_sig_structure4();
|
|
27366
|
+
init_encode_grant_request4();
|
|
27367
|
+
init_problem_details5();
|
|
27368
|
+
init_encode_cose_protected4();
|
|
27369
|
+
init_cose_protected_tree_size3();
|
|
27370
|
+
init_encode_cose_sign1_statement4();
|
|
27371
|
+
init_sign_cose_sign1_statement4();
|
|
27372
|
+
init_base64url4();
|
|
27373
|
+
init_verify_cose_sign14();
|
|
27374
|
+
init_verify_delegate_key_voucher4();
|
|
27375
|
+
init_cose_key_thumbprint4();
|
|
27376
|
+
init_encode_cose_sign1_raw4();
|
|
27377
|
+
init_merge_cose_sign1_unprotected4();
|
|
27378
|
+
init_grant_codec4();
|
|
27379
|
+
init_grant_payload_canonical4();
|
|
27380
|
+
});
|
|
26662
27381
|
|
|
26663
27382
|
// node_modules/@forestrie/delegation-cose/dist/bytes-utils.js
|
|
26664
27383
|
function bytesFromUnknown(value, label) {
|
|
@@ -26675,14 +27394,14 @@ function toArrayBuffer(bytes) {
|
|
|
26675
27394
|
|
|
26676
27395
|
// node_modules/@forestrie/delegation-cose/dist/encode-int-map.js
|
|
26677
27396
|
function encodeIntKeyCbor(value) {
|
|
26678
|
-
return
|
|
27397
|
+
return encodeCborDeterministic4(value);
|
|
26679
27398
|
}
|
|
26680
27399
|
var init_encode_int_map = __esm(() => {
|
|
26681
|
-
|
|
27400
|
+
init_dist9();
|
|
26682
27401
|
});
|
|
26683
27402
|
|
|
26684
27403
|
// node_modules/@forestrie/delegation-cose/dist/encode-cbor-bstr.js
|
|
26685
|
-
function
|
|
27404
|
+
function encodeCborBstr5(bytes) {
|
|
26686
27405
|
const len = bytes.length;
|
|
26687
27406
|
let header;
|
|
26688
27407
|
if (len < 24) {
|
|
@@ -26723,7 +27442,7 @@ function encodeCborTstr2(s) {
|
|
|
26723
27442
|
out.set(bytes, header.length);
|
|
26724
27443
|
return out;
|
|
26725
27444
|
}
|
|
26726
|
-
function
|
|
27445
|
+
function concat7(...arrays) {
|
|
26727
27446
|
const total = arrays.reduce((sum, a) => sum + a.length, 0);
|
|
26728
27447
|
const out = new Uint8Array(total);
|
|
26729
27448
|
let off = 0;
|
|
@@ -26733,12 +27452,12 @@ function concat6(...arrays) {
|
|
|
26733
27452
|
}
|
|
26734
27453
|
return out;
|
|
26735
27454
|
}
|
|
26736
|
-
function
|
|
27455
|
+
function encodeSigStructure5(protectedHeaderMapBytes, externalAad, payloadBstr) {
|
|
26737
27456
|
const arrayHeader = new Uint8Array([132]);
|
|
26738
27457
|
const label = encodeCborTstr2("Signature1");
|
|
26739
|
-
return
|
|
27458
|
+
return concat7(arrayHeader, label, encodeCborBstr5(protectedHeaderMapBytes), encodeCborBstr5(externalAad), encodeCborBstr5(payloadBstr));
|
|
26740
27459
|
}
|
|
26741
|
-
var
|
|
27460
|
+
var init_encode_sig_structure5 = () => {};
|
|
26742
27461
|
|
|
26743
27462
|
// node_modules/@forestrie/delegation-cose/dist/webauthn-assertion.js
|
|
26744
27463
|
var TYPE_MARKER, CHALLENGE_MARKER;
|
|
@@ -26796,11 +27515,11 @@ function buildOnchainDelegationToBeSignedWithAlg(input, alg) {
|
|
|
26796
27515
|
return {
|
|
26797
27516
|
protectedHeader,
|
|
26798
27517
|
delegationKey,
|
|
26799
|
-
sigStructureBytes:
|
|
27518
|
+
sigStructureBytes: encodeSigStructure5(protectedHeader, new Uint8Array, payload)
|
|
26800
27519
|
};
|
|
26801
27520
|
}
|
|
26802
27521
|
function buildOnchainDelegationToBeSignedEs256(input) {
|
|
26803
|
-
return buildOnchainDelegationToBeSignedWithAlg(input,
|
|
27522
|
+
return buildOnchainDelegationToBeSignedWithAlg(input, COSE_ALG_ES2564);
|
|
26804
27523
|
}
|
|
26805
27524
|
function normalizeEs256SignatureLowS(signature) {
|
|
26806
27525
|
if (signature.length !== ES256_SIG_BYTES) {
|
|
@@ -26810,10 +27529,10 @@ function normalizeEs256SignatureLowS(signature) {
|
|
|
26810
27529
|
for (let i = 32;i < 64; i++) {
|
|
26811
27530
|
s = s << 8n | BigInt(signature[i]);
|
|
26812
27531
|
}
|
|
26813
|
-
if (s <=
|
|
27532
|
+
if (s <= P256_HALF_N5) {
|
|
26814
27533
|
return signature;
|
|
26815
27534
|
}
|
|
26816
|
-
s =
|
|
27535
|
+
s = P256_N5 - s;
|
|
26817
27536
|
const out = new Uint8Array(64);
|
|
26818
27537
|
out.set(signature.slice(0, 32), 0);
|
|
26819
27538
|
for (let i = 0;i < 32; i++) {
|
|
@@ -26836,14 +27555,14 @@ async function signOnchainDelegationEs256(input, rootKeyPair) {
|
|
|
26836
27555
|
algData: []
|
|
26837
27556
|
};
|
|
26838
27557
|
}
|
|
26839
|
-
var ONCHAIN_DELEGATION_DOMAIN = "forestrie.univocity.delegation.v1",
|
|
27558
|
+
var ONCHAIN_DELEGATION_DOMAIN = "forestrie.univocity.delegation.v1", P256_N5, P256_HALF_N5;
|
|
26840
27559
|
var init_build_onchain_delegation = __esm(() => {
|
|
26841
|
-
|
|
27560
|
+
init_dist9();
|
|
26842
27561
|
init_encode_int_map();
|
|
26843
|
-
|
|
27562
|
+
init_encode_sig_structure5();
|
|
26844
27563
|
init_webauthn_assertion();
|
|
26845
|
-
|
|
26846
|
-
|
|
27564
|
+
P256_N5 = BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551");
|
|
27565
|
+
P256_HALF_N5 = P256_N5 >> 1n;
|
|
26847
27566
|
});
|
|
26848
27567
|
|
|
26849
27568
|
// node_modules/@forestrie/delegation-cose/dist/assemble-certificate.js
|
|
@@ -26908,11 +27627,11 @@ function parseDelegatedCoseKeyFromPayload(raw) {
|
|
|
26908
27627
|
return { x, y };
|
|
26909
27628
|
}
|
|
26910
27629
|
function decodeDelegatedCoseKeyFromBytes(bytes) {
|
|
26911
|
-
const raw =
|
|
27630
|
+
const raw = decodeCborDeterministic4(bytes);
|
|
26912
27631
|
return normalizeIntKeyedMap(raw);
|
|
26913
27632
|
}
|
|
26914
27633
|
function decodeCoseSign1Parts(certificate) {
|
|
26915
|
-
const cert =
|
|
27634
|
+
const cert = decodeCborDeterministic4(certificate);
|
|
26916
27635
|
if (!Array.isArray(cert) || cert.length !== 4) {
|
|
26917
27636
|
throw new Error("delegation certificate must be COSE_Sign1 array");
|
|
26918
27637
|
}
|
|
@@ -26923,7 +27642,7 @@ function decodeCoseSign1Parts(certificate) {
|
|
|
26923
27642
|
};
|
|
26924
27643
|
}
|
|
26925
27644
|
var init_parse_delegated_cose_key = __esm(() => {
|
|
26926
|
-
|
|
27645
|
+
init_dist9();
|
|
26927
27646
|
});
|
|
26928
27647
|
|
|
26929
27648
|
// node_modules/@forestrie/delegation-cose/dist/build-delegation-payload.js
|
|
@@ -26958,11 +27677,11 @@ function buildDelegationPayloadBytes(input) {
|
|
|
26958
27677
|
]));
|
|
26959
27678
|
}
|
|
26960
27679
|
function buildDelegationToBeSigned(protectedBytes, payloadBytes) {
|
|
26961
|
-
const sigStructureBytes =
|
|
27680
|
+
const sigStructureBytes = encodeSigStructure5(protectedBytes, new Uint8Array, payloadBytes);
|
|
26962
27681
|
return { protectedBytes, payloadBytes, sigStructureBytes };
|
|
26963
27682
|
}
|
|
26964
27683
|
var init_build_delegation_payload = __esm(() => {
|
|
26965
|
-
|
|
27684
|
+
init_encode_sig_structure5();
|
|
26966
27685
|
init_parse_delegated_cose_key();
|
|
26967
27686
|
init_encode_int_map();
|
|
26968
27687
|
});
|
|
@@ -26990,7 +27709,7 @@ function buildDelegationToBeSignedEs256(input, rootKid) {
|
|
|
26990
27709
|
throw new Error("ES256 root kid must be 16 bytes");
|
|
26991
27710
|
}
|
|
26992
27711
|
const protectedBytes = encodeIntKeyCbor(new Map([
|
|
26993
|
-
[COSE_HEADER_ALG,
|
|
27712
|
+
[COSE_HEADER_ALG, COSE_ALG_ES2564],
|
|
26994
27713
|
[COSE_HEADER_CTY, DELEGATION_CONTENT_TYPE],
|
|
26995
27714
|
[COSE_HEADER_KID, rootKid]
|
|
26996
27715
|
]));
|
|
@@ -27032,7 +27751,7 @@ var init_build_delegation_certificate_ks256 = __esm(() => {
|
|
|
27032
27751
|
// node_modules/@forestrie/delegation-cose/dist/parse-certificate.js
|
|
27033
27752
|
function parseDelegationCertificate(certificate) {
|
|
27034
27753
|
const { payloadBytes } = decodeCoseSign1Parts(certificate);
|
|
27035
|
-
const payloadMap = normalizeIntKeyedMap(
|
|
27754
|
+
const payloadMap = normalizeIntKeyedMap(decodeCborDeterministic4(payloadBytes));
|
|
27036
27755
|
const logIdHex32 = payloadMap.get(PAYLOAD_LOG_ID);
|
|
27037
27756
|
if (typeof logIdHex32 !== "string") {
|
|
27038
27757
|
throw new Error("payload missing log id");
|
|
@@ -27048,24 +27767,24 @@ function parseDelegationCertificate(certificate) {
|
|
|
27048
27767
|
};
|
|
27049
27768
|
}
|
|
27050
27769
|
var init_parse_certificate = __esm(() => {
|
|
27051
|
-
|
|
27770
|
+
init_dist9();
|
|
27052
27771
|
init_parse_delegated_cose_key();
|
|
27053
27772
|
});
|
|
27054
27773
|
|
|
27055
27774
|
// node_modules/@forestrie/delegation-cose/dist/verify-es256.js
|
|
27056
27775
|
var init_verify_es256 = __esm(() => {
|
|
27057
|
-
|
|
27776
|
+
init_encode_sig_structure5();
|
|
27058
27777
|
init_parse_delegated_cose_key();
|
|
27059
27778
|
});
|
|
27060
27779
|
|
|
27061
27780
|
// node_modules/@forestrie/delegation-cose/dist/verify-ks256.js
|
|
27062
27781
|
var init_verify_ks256 = __esm(() => {
|
|
27063
|
-
|
|
27782
|
+
init_encode_sig_structure5();
|
|
27064
27783
|
init_parse_delegated_cose_key();
|
|
27065
27784
|
});
|
|
27066
27785
|
|
|
27067
27786
|
// node_modules/@forestrie/delegation-cose/dist/index.js
|
|
27068
|
-
var
|
|
27787
|
+
var init_dist10 = __esm(() => {
|
|
27069
27788
|
init_build_onchain_delegation();
|
|
27070
27789
|
init_webauthn_assertion();
|
|
27071
27790
|
init_assemble_certificate();
|
|
@@ -27083,7 +27802,7 @@ var init_dist8 = __esm(() => {
|
|
|
27083
27802
|
});
|
|
27084
27803
|
|
|
27085
27804
|
// src/lib/delegate-voucher.ts
|
|
27086
|
-
function
|
|
27805
|
+
function parseRegistrarKeyXY5(raw) {
|
|
27087
27806
|
if (raw.length !== REGISTRAR_KEY_XY_BYTES)
|
|
27088
27807
|
return null;
|
|
27089
27808
|
return {
|
|
@@ -27110,7 +27829,7 @@ function toBigIntOrNull(value) {
|
|
|
27110
27829
|
return BigInt(value);
|
|
27111
27830
|
return null;
|
|
27112
27831
|
}
|
|
27113
|
-
async function
|
|
27832
|
+
async function verifyDelegateKeyVoucher5(voucherBytes, pinnedKey, expect) {
|
|
27114
27833
|
const sigOk = await verifyCoseSign1WithParsedKey(voucherBytes, pinnedKey);
|
|
27115
27834
|
if (!sigOk)
|
|
27116
27835
|
return { ok: false, reason: "signature" };
|
|
@@ -27176,7 +27895,7 @@ async function runDelegateFlow(params, deps = {}) {
|
|
|
27176
27895
|
const pendingUrl = `${params.coordinatorUrl}/api/logs/${params.logId}/pending-delegation`;
|
|
27177
27896
|
const pendingRes = await fetchImpl(pendingUrl);
|
|
27178
27897
|
if (!pendingRes.ok) {
|
|
27179
|
-
const preview =
|
|
27898
|
+
const preview = await responseProblemDetail(pendingRes, 200);
|
|
27180
27899
|
throw new DelegateFlowError(`pending-delegation fetch failed: HTTP ${pendingRes.status} ${preview}`, pendingRes.status);
|
|
27181
27900
|
}
|
|
27182
27901
|
const pending = await pendingRes.json();
|
|
@@ -27188,11 +27907,11 @@ async function runDelegateFlow(params, deps = {}) {
|
|
|
27188
27907
|
if (standing.voucher === undefined || standing.sealerId === undefined || standing.epoch === undefined) {
|
|
27189
27908
|
throw new DelegateFlowError("standing entry is missing its registrar voucher — refusing to bind");
|
|
27190
27909
|
}
|
|
27191
|
-
const pinned =
|
|
27910
|
+
const pinned = parseRegistrarKeyXY5(b64ToBytes(params.knownSealerKey));
|
|
27192
27911
|
if (pinned === null) {
|
|
27193
27912
|
throw new DelegateFlowError("known-sealer-key must be base64 x||y (64 bytes)");
|
|
27194
27913
|
}
|
|
27195
|
-
const voucherResult = await
|
|
27914
|
+
const voucherResult = await verifyDelegateKeyVoucher5(b64ToBytes(standing.voucher), pinned, {
|
|
27196
27915
|
sealerId: standing.sealerId,
|
|
27197
27916
|
epoch: standing.epoch,
|
|
27198
27917
|
publicKey: b64ToBytes(standing.delegatedPublicKey)
|
|
@@ -27239,7 +27958,7 @@ async function runDelegateFlow(params, deps = {}) {
|
|
|
27239
27958
|
})
|
|
27240
27959
|
});
|
|
27241
27960
|
if (!submitRes.ok) {
|
|
27242
|
-
const preview =
|
|
27961
|
+
const preview = await responseProblemDetail(submitRes, 200);
|
|
27243
27962
|
throw new DelegateFlowError(`certificate submit failed: HTTP ${submitRes.status} ${preview}`, submitRes.status);
|
|
27244
27963
|
}
|
|
27245
27964
|
return {
|
|
@@ -27254,9 +27973,10 @@ async function runDelegateFlow(params, deps = {}) {
|
|
|
27254
27973
|
}
|
|
27255
27974
|
var MMR_START = 0, DelegateFlowError;
|
|
27256
27975
|
var init_delegate_flow = __esm(() => {
|
|
27257
|
-
|
|
27976
|
+
init_dist10();
|
|
27258
27977
|
init_dist3();
|
|
27259
27978
|
init_delegate_voucher();
|
|
27979
|
+
init_http_problem();
|
|
27260
27980
|
DelegateFlowError = class DelegateFlowError extends Error {
|
|
27261
27981
|
httpStatus;
|
|
27262
27982
|
code;
|
|
@@ -27488,7 +28208,7 @@ function buildEs256GenesisBody(opts) {
|
|
|
27488
28208
|
[LABEL_GENESIS_VERSION, SCHEMA_V2],
|
|
27489
28209
|
[LABEL_UNIVOCITY_ADDR, hexToBytes20(opts.univocityAddress)],
|
|
27490
28210
|
[LABEL_CHAIN_ID, opts.chainId],
|
|
27491
|
-
[LABEL_GENESIS_ALG,
|
|
28211
|
+
[LABEL_GENESIS_ALG, COSE_ALG_ES2566],
|
|
27492
28212
|
[LABEL_BOOTSTRAP_KEY, opts.bootstrapKeyXy]
|
|
27493
28213
|
]));
|
|
27494
28214
|
}
|
|
@@ -27499,7 +28219,7 @@ function genesisPostUrl(baseUrl, logId, webhookUrl) {
|
|
|
27499
28219
|
function coordinatorSigningRouteUrl(coordinatorUrl, logId) {
|
|
27500
28220
|
return `${coordinatorUrl.replace(/\/$/, "")}/api/logs/${logId}/signing-route`;
|
|
27501
28221
|
}
|
|
27502
|
-
var LABEL_GENESIS_VERSION = -68009, LABEL_UNIVOCITY_ADDR = -68011, LABEL_CHAIN_ID = -68013, LABEL_GENESIS_ALG = -68014, LABEL_BOOTSTRAP_KEY = -68015, SCHEMA_V2 = 2,
|
|
28222
|
+
var LABEL_GENESIS_VERSION = -68009, LABEL_UNIVOCITY_ADDR = -68011, LABEL_CHAIN_ID = -68013, LABEL_GENESIS_ALG = -68014, LABEL_BOOTSTRAP_KEY = -68015, SCHEMA_V2 = 2, COSE_ALG_ES2566 = -7;
|
|
27503
28223
|
var init_onboard_genesis_body = __esm(() => {
|
|
27504
28224
|
init_dist3();
|
|
27505
28225
|
});
|
|
@@ -27569,7 +28289,7 @@ async function runOnboardGenesis(out, options, deps = {}) {
|
|
|
27569
28289
|
command: "onboard-genesis",
|
|
27570
28290
|
message: `genesis POST rejected: HTTP ${res.status}`,
|
|
27571
28291
|
httpStatus: res.status,
|
|
27572
|
-
detail:
|
|
28292
|
+
detail: await responseProblemDetail(res)
|
|
27573
28293
|
});
|
|
27574
28294
|
return;
|
|
27575
28295
|
}
|
|
@@ -27617,6 +28337,7 @@ var init_onboard_genesis = __esm(() => {
|
|
|
27617
28337
|
init_fsio();
|
|
27618
28338
|
init_deployment_record();
|
|
27619
28339
|
init_onboard_genesis_body();
|
|
28340
|
+
init_http_problem();
|
|
27620
28341
|
});
|
|
27621
28342
|
|
|
27622
28343
|
// src/options/onboard-genesis.ts
|
|
@@ -27751,14 +28472,14 @@ function assemble(prot, payload, signature) {
|
|
|
27751
28472
|
return encodeCborDeterministic([prot, new Map, payload, signature]);
|
|
27752
28473
|
}
|
|
27753
28474
|
async function buildOnboardAttestationEs256(key, input) {
|
|
27754
|
-
const prot = protectedBytes(
|
|
28475
|
+
const prot = protectedBytes(COSE_ALG_ES2567);
|
|
27755
28476
|
const payload = claimsBytes(input);
|
|
27756
28477
|
const sigStructure = encodeSigStructure(prot, new Uint8Array(0), payload);
|
|
27757
28478
|
const signature = new Uint8Array(await crypto.subtle.sign({ name: "ECDSA", hash: "SHA-256" }, key.privateKey, sigStructure));
|
|
27758
28479
|
return assemble(prot, payload, signature);
|
|
27759
28480
|
}
|
|
27760
28481
|
async function buildOnboardAttestationKs256(privateKeyHex, input) {
|
|
27761
|
-
const prot = protectedBytes(
|
|
28482
|
+
const prot = protectedBytes(COSE_ALG_KS2566);
|
|
27762
28483
|
const payload = claimsBytes(input);
|
|
27763
28484
|
const sigStructure = encodeSigStructure(prot, new Uint8Array(0), payload);
|
|
27764
28485
|
const hash3 = keccak256(sigStructure);
|
|
@@ -27769,7 +28490,7 @@ async function buildOnboardAttestationKs256(privateKeyHex, input) {
|
|
|
27769
28490
|
}
|
|
27770
28491
|
return assemble(prot, payload, sig);
|
|
27771
28492
|
}
|
|
27772
|
-
var ONBOARD_ATTESTATION_CONTENT_TYPE = "application/forestrie-onboard-attestation+cwt",
|
|
28493
|
+
var ONBOARD_ATTESTATION_CONTENT_TYPE = "application/forestrie-onboard-attestation+cwt", COSE_ALG_ES2567 = -7, COSE_ALG_KS2566 = -65799, CLAIM_CHAIN_BINDING = -70000, DEFAULT_ATTESTATION_WINDOW_SEC = 3600;
|
|
27773
28494
|
var init_onboard_attestation = __esm(() => {
|
|
27774
28495
|
init_accounts();
|
|
27775
28496
|
init__esm();
|
|
@@ -27942,7 +28663,7 @@ async function runOnboardRequest(out, options, deps = {}) {
|
|
|
27942
28663
|
reportError8(out, options, {
|
|
27943
28664
|
error: "create_failed",
|
|
27944
28665
|
command: "onboard-request",
|
|
27945
|
-
message: `request rejected: HTTP ${res2.status}: ${
|
|
28666
|
+
message: `request rejected: HTTP ${res2.status}: ${await responseProblemDetail(res2, 300)}`,
|
|
27946
28667
|
httpStatus: res2.status
|
|
27947
28668
|
});
|
|
27948
28669
|
return;
|
|
@@ -28018,7 +28739,7 @@ async function runOnboardRequest(out, options, deps = {}) {
|
|
|
28018
28739
|
reportError8(out, options, {
|
|
28019
28740
|
error: "redeem_failed",
|
|
28020
28741
|
command: "onboard-request",
|
|
28021
|
-
message: `redeem rejected: HTTP ${res.status}: ${
|
|
28742
|
+
message: `redeem rejected: HTTP ${res.status}: ${await responseProblemDetail(res, 300)}`,
|
|
28022
28743
|
httpStatus: res.status
|
|
28023
28744
|
});
|
|
28024
28745
|
return;
|
|
@@ -28078,6 +28799,7 @@ var init_onboard_request = __esm(() => {
|
|
|
28078
28799
|
init_onboard_attestation();
|
|
28079
28800
|
init_sign_statement_key();
|
|
28080
28801
|
init_x402_payment();
|
|
28802
|
+
init_http_problem();
|
|
28081
28803
|
});
|
|
28082
28804
|
|
|
28083
28805
|
// src/options/onboard-request.ts
|
|
@@ -28949,7 +29671,7 @@ function bitLength2(value) {
|
|
|
28949
29671
|
var init_math = () => {};
|
|
28950
29672
|
|
|
28951
29673
|
// node_modules/@forestrie/merklelog/dist/mmr/errors.js
|
|
28952
|
-
var ConsistencyShapeError, IncompleteTreeSize, ConsistencyPeakCountMismatch, ConsistencyPathLengthMismatch, ConsistencyRootMismatch, SizeMustIncrease;
|
|
29674
|
+
var ConsistencyShapeError, IncompleteTreeSize, ConsistencyPeakCountMismatch, ConsistencyPathLengthMismatch, ConsistencyRootMismatch, SizeMustIncrease, SizeNotUint64, ConsistencyPathMalformed;
|
|
28953
29675
|
var init_errors4 = __esm(() => {
|
|
28954
29676
|
ConsistencyShapeError = class ConsistencyShapeError extends Error {
|
|
28955
29677
|
constructor(message) {
|
|
@@ -29005,6 +29727,26 @@ var init_errors4 = __esm(() => {
|
|
|
29005
29727
|
this.name = "SizeMustIncrease";
|
|
29006
29728
|
}
|
|
29007
29729
|
};
|
|
29730
|
+
SizeNotUint64 = class SizeNotUint64 extends ConsistencyShapeError {
|
|
29731
|
+
which;
|
|
29732
|
+
size;
|
|
29733
|
+
constructor(which, size5) {
|
|
29734
|
+
super(`${which} (${size5}) is outside the uint64 range [0, 2^64 - 1]`);
|
|
29735
|
+
this.which = which;
|
|
29736
|
+
this.size = size5;
|
|
29737
|
+
this.name = "SizeNotUint64";
|
|
29738
|
+
}
|
|
29739
|
+
};
|
|
29740
|
+
ConsistencyPathMalformed = class ConsistencyPathMalformed extends ConsistencyShapeError {
|
|
29741
|
+
detail;
|
|
29742
|
+
index;
|
|
29743
|
+
constructor(detail, index2) {
|
|
29744
|
+
super(index2 === undefined ? `paths: ${detail}` : `path ${index2}: ${detail}`);
|
|
29745
|
+
this.detail = detail;
|
|
29746
|
+
this.index = index2;
|
|
29747
|
+
this.name = "ConsistencyPathMalformed";
|
|
29748
|
+
}
|
|
29749
|
+
};
|
|
29008
29750
|
});
|
|
29009
29751
|
|
|
29010
29752
|
// node_modules/@forestrie/merklelog/dist/utils/arrays.js
|
|
@@ -29064,6 +29806,12 @@ async function verifyInclusion(hasher, leafHash, proof, root) {
|
|
|
29064
29806
|
return arraysEqual(calculatedRoot, root);
|
|
29065
29807
|
}
|
|
29066
29808
|
async function consistentRootsForSizes(hasher, sizeFrom, sizeTo, accumulatorFrom, paths) {
|
|
29809
|
+
if (sizeFrom < 0n || sizeFrom > MAX_UINT644) {
|
|
29810
|
+
throw new SizeNotUint64("sizeFrom", sizeFrom);
|
|
29811
|
+
}
|
|
29812
|
+
if (sizeTo < 0n || sizeTo > MAX_UINT644) {
|
|
29813
|
+
throw new SizeNotUint64("sizeTo", sizeTo);
|
|
29814
|
+
}
|
|
29067
29815
|
if (sizeTo <= sizeFrom) {
|
|
29068
29816
|
throw new SizeMustIncrease(sizeFrom, sizeTo);
|
|
29069
29817
|
}
|
|
@@ -29076,9 +29824,13 @@ async function consistentRootsForSizes(hasher, sizeFrom, sizeTo, accumulatorFrom
|
|
|
29076
29824
|
if (accumulatorFrom.length !== n) {
|
|
29077
29825
|
throw new ConsistencyPeakCountMismatch(n, accumulatorFrom.length);
|
|
29078
29826
|
}
|
|
29827
|
+
if (!Array.isArray(paths)) {
|
|
29828
|
+
throw new ConsistencyPathMalformed(`not an array (got ${typeName(paths)})`);
|
|
29829
|
+
}
|
|
29079
29830
|
if (paths.length !== n) {
|
|
29080
29831
|
throw new ConsistencyPeakCountMismatch(n, paths.length);
|
|
29081
29832
|
}
|
|
29833
|
+
assertDensePaths(paths);
|
|
29082
29834
|
const nto = popcount(to);
|
|
29083
29835
|
if (n === 0) {
|
|
29084
29836
|
return { roots: [], expectedRight: nto };
|
|
@@ -29141,9 +29893,34 @@ function indexConsistencyProof(get, mmrIndexA, mmrIndexB) {
|
|
|
29141
29893
|
}
|
|
29142
29894
|
return { mmrSizeA: mmrIndexA + 1n, mmrSizeB: mmrIndexB + 1n, paths };
|
|
29143
29895
|
}
|
|
29896
|
+
function typeName(value) {
|
|
29897
|
+
if (value === null)
|
|
29898
|
+
return "null";
|
|
29899
|
+
if (Array.isArray(value))
|
|
29900
|
+
return "an array";
|
|
29901
|
+
return typeof value;
|
|
29902
|
+
}
|
|
29903
|
+
function assertDensePaths(paths) {
|
|
29904
|
+
for (let i = 0;i < paths.length; i++) {
|
|
29905
|
+
if (!(i in paths)) {
|
|
29906
|
+
throw new ConsistencyPathMalformed("missing (the array is sparse)", i);
|
|
29907
|
+
}
|
|
29908
|
+
const path2 = paths[i];
|
|
29909
|
+
if (!Array.isArray(path2)) {
|
|
29910
|
+
throw new ConsistencyPathMalformed(`not an array (got ${typeName(path2)})`, i);
|
|
29911
|
+
}
|
|
29912
|
+
for (let j = 0;j < path2.length; j++) {
|
|
29913
|
+
if (!(j in path2) || !(path2[j] instanceof Uint8Array)) {
|
|
29914
|
+
throw new ConsistencyPathMalformed(`element ${j} is not a Uint8Array (got ${typeName(path2[j])})`, i);
|
|
29915
|
+
}
|
|
29916
|
+
}
|
|
29917
|
+
}
|
|
29918
|
+
}
|
|
29919
|
+
var MAX_UINT644;
|
|
29144
29920
|
var init_algorithms = __esm(() => {
|
|
29145
29921
|
init_errors4();
|
|
29146
29922
|
init_math();
|
|
29923
|
+
MAX_UINT644 = (1n << 64n) - 1n;
|
|
29147
29924
|
});
|
|
29148
29925
|
|
|
29149
29926
|
// node_modules/@forestrie/merklelog/dist/mmr/algorithms-sync.js
|
|
@@ -29178,7 +29955,7 @@ async function createSyncHasher() {
|
|
|
29178
29955
|
}
|
|
29179
29956
|
|
|
29180
29957
|
// node_modules/@forestrie/merklelog/dist/index.js
|
|
29181
|
-
var
|
|
29958
|
+
var init_dist11 = __esm(() => {
|
|
29182
29959
|
init_massif();
|
|
29183
29960
|
init_types();
|
|
29184
29961
|
init_types();
|
|
@@ -29208,22 +29985,10 @@ function asBytesArray(v, what) {
|
|
|
29208
29985
|
}
|
|
29209
29986
|
return v;
|
|
29210
29987
|
}
|
|
29211
|
-
function
|
|
29212
|
-
const vdpRaw = unprotected.get(COSE_LABEL_VDP);
|
|
29213
|
-
if (vdpRaw === undefined || vdpRaw === null)
|
|
29214
|
-
return null;
|
|
29215
|
-
if (!(vdpRaw instanceof Map)) {
|
|
29216
|
-
throw new Error("checkpoint carries no verifiable-proofs header (396)");
|
|
29217
|
-
}
|
|
29218
|
-
const proofBstr = vdpRaw.get(VDP_CONSISTENCY_PROOF_KEY);
|
|
29219
|
-
if (proofBstr === undefined || proofBstr === null)
|
|
29220
|
-
return null;
|
|
29221
|
-
if (!(proofBstr instanceof Uint8Array)) {
|
|
29222
|
-
throw new Error("checkpoint carries no consistency proof (vdp key -2)");
|
|
29223
|
-
}
|
|
29988
|
+
function decodeOneProof(proofBstr) {
|
|
29224
29989
|
const proof = decodeCborDeterministic(proofBstr);
|
|
29225
|
-
if (!Array.isArray(proof) || proof.length
|
|
29226
|
-
throw new Error(
|
|
29990
|
+
if (!Array.isArray(proof) || proof.length !== 4) {
|
|
29991
|
+
throw new Error(`consistency proof must be [tree-size-1, tree-size-2, paths, right-peaks] (4 elements), got ${Array.isArray(proof) ? proof.length : typeof proof}`);
|
|
29227
29992
|
}
|
|
29228
29993
|
const pathsRaw = proof[2];
|
|
29229
29994
|
if (!Array.isArray(pathsRaw)) {
|
|
@@ -29253,8 +30018,50 @@ function decodeConsistencyProofFromUnprotected(unprotected) {
|
|
|
29253
30018
|
rightPeaks: asBytesArray(proof[3], "right-peaks")
|
|
29254
30019
|
};
|
|
29255
30020
|
}
|
|
30021
|
+
function decodeProofAt(proofBstr, at) {
|
|
30022
|
+
if (at === null)
|
|
30023
|
+
return decodeOneProof(proofBstr);
|
|
30024
|
+
try {
|
|
30025
|
+
return decodeOneProof(proofBstr);
|
|
30026
|
+
} catch (err) {
|
|
30027
|
+
throw new Error(`consistency-proofs entry ${at}: ${err instanceof Error ? err.message : String(err)}`);
|
|
30028
|
+
}
|
|
30029
|
+
}
|
|
30030
|
+
function decodeConsistencyProofsFromUnprotected(unprotected) {
|
|
30031
|
+
const vdpRaw = unprotected.get(COSE_LABEL_VDP);
|
|
30032
|
+
if (vdpRaw === undefined || vdpRaw === null)
|
|
30033
|
+
return null;
|
|
30034
|
+
if (!(vdpRaw instanceof Map)) {
|
|
30035
|
+
throw new Error("checkpoint carries no verifiable-proofs header (396)");
|
|
30036
|
+
}
|
|
30037
|
+
const entry = vdpRaw.get(VDP_CONSISTENCY_PROOF_KEY);
|
|
30038
|
+
if (entry === undefined || entry === null)
|
|
30039
|
+
return null;
|
|
30040
|
+
if (entry instanceof Uint8Array) {
|
|
30041
|
+
return [decodeOneProof(entry)];
|
|
30042
|
+
}
|
|
30043
|
+
if (!Array.isArray(entry)) {
|
|
30044
|
+
throw new Error("checkpoint carries no consistency proof (vdp key -2)");
|
|
30045
|
+
}
|
|
30046
|
+
if (entry.length === 0) {
|
|
30047
|
+
throw new EmptyConsistencyProofsError("consistency-proofs (vdp key -2) is empty; at least one proof is required");
|
|
30048
|
+
}
|
|
30049
|
+
return entry.map((proofBstr, i) => {
|
|
30050
|
+
if (!(proofBstr instanceof Uint8Array)) {
|
|
30051
|
+
throw new Error(`consistency-proofs entry ${i} is not a byte string (vdp key -2)`);
|
|
30052
|
+
}
|
|
30053
|
+
return decodeProofAt(proofBstr, entry.length === 1 ? null : i);
|
|
30054
|
+
});
|
|
30055
|
+
}
|
|
30056
|
+
var EmptyConsistencyProofsError;
|
|
29256
30057
|
var init_decode_checkpoint_consistency_proof = __esm(() => {
|
|
29257
30058
|
init_dist3();
|
|
30059
|
+
EmptyConsistencyProofsError = class EmptyConsistencyProofsError extends Error {
|
|
30060
|
+
constructor(message) {
|
|
30061
|
+
super(message);
|
|
30062
|
+
this.name = "EmptyConsistencyProofsError";
|
|
30063
|
+
}
|
|
30064
|
+
};
|
|
29258
30065
|
});
|
|
29259
30066
|
|
|
29260
30067
|
// node_modules/@forestrie/receipt-verify/dist/subtle-hasher.js
|
|
@@ -29375,24 +30182,15 @@ function cborBytes(value) {
|
|
|
29375
30182
|
return encodeCborDeterministic(value);
|
|
29376
30183
|
}
|
|
29377
30184
|
function sealedSizeFromCheckpoint(coseSign1, unprotected) {
|
|
29378
|
-
|
|
29379
|
-
try {
|
|
29380
|
-
declared = decodeConsistencyProofFromUnprotected(unprotected);
|
|
29381
|
-
} catch {
|
|
29382
|
-
return null;
|
|
29383
|
-
}
|
|
30185
|
+
const declared = decodeConsistencyProofsFromUnprotected(unprotected);
|
|
29384
30186
|
if (declared === null)
|
|
29385
30187
|
return null;
|
|
29386
|
-
|
|
29387
|
-
return readProtectedTreeSize2(coseSign1[0]);
|
|
29388
|
-
} catch {
|
|
29389
|
-
return null;
|
|
29390
|
-
}
|
|
30188
|
+
return readProtectedTreeSize2(coseSign1[0]);
|
|
29391
30189
|
}
|
|
29392
30190
|
var DELEGATION_CERT_LABEL = 1000;
|
|
29393
30191
|
var init_build_receipt_offline = __esm(() => {
|
|
29394
30192
|
init_dist3();
|
|
29395
|
-
|
|
30193
|
+
init_dist11();
|
|
29396
30194
|
init_parse_receipt();
|
|
29397
30195
|
init_decode_checkpoint_consistency_proof();
|
|
29398
30196
|
});
|
|
@@ -29400,40 +30198,61 @@ var init_build_receipt_offline = __esm(() => {
|
|
|
29400
30198
|
// node_modules/@forestrie/receipt-verify/dist/checkpoint-chain.js
|
|
29401
30199
|
function checkpointConsistencyProof(checkpointBytes) {
|
|
29402
30200
|
const { coseSign1, unprotected } = parseCheckpoint(checkpointBytes);
|
|
29403
|
-
|
|
30201
|
+
let alg;
|
|
30202
|
+
try {
|
|
30203
|
+
alg = readProtectedAlg(coseSign1[0]);
|
|
30204
|
+
} catch (err) {
|
|
30205
|
+
if (err instanceof ProtectedHeaderAlgError) {
|
|
30206
|
+
throw new CheckpointProtectedHeaderAlgError(`checkpoint protected header carries no integer alg (label 1): ${err.message}`);
|
|
30207
|
+
}
|
|
30208
|
+
throw err;
|
|
30209
|
+
}
|
|
29404
30210
|
const signature = coseSign1[3];
|
|
29405
30211
|
if (alg === COSE_ALG_ES256 && signature.length === 64 && !isLowS(signature)) {
|
|
29406
30212
|
throw new CheckpointHighSSignatureError("checkpoint ES256 signature is not low-s canonical (s > n/2); rejected " + "to match the univocity contract's P-256 verifier and go-merklelog");
|
|
29407
30213
|
}
|
|
29408
|
-
const
|
|
29409
|
-
if (
|
|
30214
|
+
const proofs = decodeConsistencyProofsFromUnprotected(unprotected);
|
|
30215
|
+
if (proofs === null) {
|
|
29410
30216
|
throw new Error("checkpoint carries no consistency proof (vdp key -2)");
|
|
29411
30217
|
}
|
|
30218
|
+
const last = proofs[proofs.length - 1];
|
|
29412
30219
|
const signedTreeSize2 = readProtectedTreeSize2(coseSign1[0]);
|
|
29413
30220
|
if (signedTreeSize2 === null) {
|
|
29414
30221
|
throw new Error("checkpoint protected header carries no signed tree-size-2 (-65933)");
|
|
29415
30222
|
}
|
|
29416
|
-
if (signedTreeSize2 !==
|
|
29417
|
-
throw new CheckpointSignedSizeMismatchError(`signed tree-size-2 (-65933) ${signedTreeSize2} != declared consistency-proof tree-size-2 ${
|
|
30223
|
+
if (signedTreeSize2 !== last.treeSize2) {
|
|
30224
|
+
throw new CheckpointSignedSizeMismatchError(`signed tree-size-2 (-65933) ${signedTreeSize2} != declared consistency-proof tree-size-2 ${last.treeSize2}`);
|
|
29418
30225
|
}
|
|
29419
30226
|
return {
|
|
29420
|
-
|
|
29421
|
-
|
|
29422
|
-
|
|
29423
|
-
|
|
29424
|
-
rightPeaks: declared.rightPeaks
|
|
30227
|
+
proofs,
|
|
30228
|
+
treeSize1: proofs[0].treeSize1,
|
|
30229
|
+
treeSize2: last.treeSize2,
|
|
30230
|
+
signedTreeSize2
|
|
29425
30231
|
};
|
|
29426
30232
|
}
|
|
29427
30233
|
async function computeCheckpointAccumulator(proof, accumulatorFrom, sizeFrom) {
|
|
29428
|
-
if (proof.
|
|
29429
|
-
throw new
|
|
30234
|
+
if (proof.proofs.length === 0) {
|
|
30235
|
+
throw new EmptyConsistencyProofsError("consistency proof relays no proofs (empty proofs array); at least " + "one is required to fold");
|
|
29430
30236
|
}
|
|
29431
30237
|
const hasher = new SubtleHasher;
|
|
29432
|
-
|
|
29433
|
-
|
|
29434
|
-
|
|
30238
|
+
let accumulator = accumulatorFrom;
|
|
30239
|
+
let size5 = sizeFrom;
|
|
30240
|
+
for (let i = 0;i < proof.proofs.length; i++) {
|
|
30241
|
+
const step = proof.proofs[i];
|
|
30242
|
+
if (step.treeSize1 !== size5) {
|
|
30243
|
+
throw new ConsistencyChainNotContiguousError(i === 0 ? `consistency proof base tree-size-1 ${step.treeSize1} does not match the trusted size ${size5}` : `consistency-proofs entry ${i} declares tree-size-1 ${step.treeSize1}; the previous proof reached ${size5}`);
|
|
30244
|
+
}
|
|
30245
|
+
const { roots, expectedRight } = await consistentRootsForSizes(hasher, size5, step.treeSize2, accumulator, step.paths);
|
|
30246
|
+
if (step.rightPeaks.length !== expectedRight) {
|
|
30247
|
+
throw new Error(`checkpoint supplies ${step.rightPeaks.length} right-peaks; size ${step.treeSize2} requires ${expectedRight}`);
|
|
30248
|
+
}
|
|
30249
|
+
accumulator = [...roots, ...step.rightPeaks];
|
|
30250
|
+
size5 = step.treeSize2;
|
|
30251
|
+
}
|
|
30252
|
+
if (size5 !== proof.treeSize2) {
|
|
30253
|
+
throw new ConsistencyChainNotContiguousError(`consistency proof folds to tree-size-2 ${size5}; the chain's declared tree-size-2 is ${proof.treeSize2}`);
|
|
29435
30254
|
}
|
|
29436
|
-
return
|
|
30255
|
+
return accumulator;
|
|
29437
30256
|
}
|
|
29438
30257
|
function accumulatorPayload(accumulator) {
|
|
29439
30258
|
const out = new Uint8Array(accumulator.reduce((s, p) => s + p.length, 0));
|
|
@@ -29476,6 +30295,18 @@ async function verifyCheckpointChain(opts) {
|
|
|
29476
30295
|
links
|
|
29477
30296
|
};
|
|
29478
30297
|
}
|
|
30298
|
+
for (let i = 0;i < trustedBase.accumulator.length; i++) {
|
|
30299
|
+
const peak = trustedBase.accumulator[i];
|
|
30300
|
+
if (!(peak instanceof Uint8Array) || peak.length !== 32) {
|
|
30301
|
+
return {
|
|
30302
|
+
ok: false,
|
|
30303
|
+
reason: "proof_malformed",
|
|
30304
|
+
at: 0,
|
|
30305
|
+
detail: `trusted base accumulator peak ${i} is not a 32-byte node value (${describePeak(peak)})`,
|
|
30306
|
+
links
|
|
30307
|
+
};
|
|
30308
|
+
}
|
|
30309
|
+
}
|
|
29479
30310
|
}
|
|
29480
30311
|
let accumulator = trustedBase?.accumulator ?? [];
|
|
29481
30312
|
let expectedBase = trustedBase?.size ?? 0n;
|
|
@@ -29518,7 +30349,7 @@ async function verifyCheckpointChain(opts) {
|
|
|
29518
30349
|
} catch (err) {
|
|
29519
30350
|
return {
|
|
29520
30351
|
ok: false,
|
|
29521
|
-
reason: "proof_malformed",
|
|
30352
|
+
reason: err instanceof ConsistencyChainNotContiguousError ? "size_mismatch" : "proof_malformed",
|
|
29522
30353
|
at: i,
|
|
29523
30354
|
detail: err instanceof Error ? err.message : String(err),
|
|
29524
30355
|
links
|
|
@@ -29546,12 +30377,27 @@ async function verifyCheckpointChain(opts) {
|
|
|
29546
30377
|
}
|
|
29547
30378
|
return { ok: true, links, accumulator };
|
|
29548
30379
|
}
|
|
29549
|
-
|
|
30380
|
+
function describePeak(peak) {
|
|
30381
|
+
if (peak instanceof Uint8Array)
|
|
30382
|
+
return `${peak.length} bytes`;
|
|
30383
|
+
if (peak === null)
|
|
30384
|
+
return "null";
|
|
30385
|
+
if (Array.isArray(peak))
|
|
30386
|
+
return "an array";
|
|
30387
|
+
return typeof peak;
|
|
30388
|
+
}
|
|
30389
|
+
var ConsistencyChainNotContiguousError, CheckpointSignedSizeMismatchError, CheckpointHighSSignatureError, CheckpointProtectedHeaderAlgError;
|
|
29550
30390
|
var init_checkpoint_chain = __esm(() => {
|
|
29551
30391
|
init_dist3();
|
|
29552
|
-
|
|
30392
|
+
init_dist11();
|
|
29553
30393
|
init_build_receipt_offline();
|
|
29554
30394
|
init_decode_checkpoint_consistency_proof();
|
|
30395
|
+
ConsistencyChainNotContiguousError = class ConsistencyChainNotContiguousError extends Error {
|
|
30396
|
+
constructor(message) {
|
|
30397
|
+
super(message);
|
|
30398
|
+
this.name = "ConsistencyChainNotContiguousError";
|
|
30399
|
+
}
|
|
30400
|
+
};
|
|
29555
30401
|
CheckpointSignedSizeMismatchError = class CheckpointSignedSizeMismatchError extends Error {
|
|
29556
30402
|
constructor(message) {
|
|
29557
30403
|
super(message);
|
|
@@ -29564,6 +30410,12 @@ var init_checkpoint_chain = __esm(() => {
|
|
|
29564
30410
|
this.name = "CheckpointHighSSignatureError";
|
|
29565
30411
|
}
|
|
29566
30412
|
};
|
|
30413
|
+
CheckpointProtectedHeaderAlgError = class CheckpointProtectedHeaderAlgError extends Error {
|
|
30414
|
+
constructor(message) {
|
|
30415
|
+
super(message);
|
|
30416
|
+
this.name = "CheckpointProtectedHeaderAlgError";
|
|
30417
|
+
}
|
|
30418
|
+
};
|
|
29567
30419
|
});
|
|
29568
30420
|
|
|
29569
30421
|
// node_modules/@forestrie/receipt-verify/dist/freshen-receipt.js
|
|
@@ -29604,6 +30456,12 @@ async function freshenReceipt(input) {
|
|
|
29604
30456
|
if (baseAccumulator.length !== basePeaks) {
|
|
29605
30457
|
throw new Error(`base accumulator has ${baseAccumulator.length} peaks; trusted base size ${baseSize} has ${basePeaks}`);
|
|
29606
30458
|
}
|
|
30459
|
+
for (let i = 0;i < links.length; i++) {
|
|
30460
|
+
const link = links[i];
|
|
30461
|
+
if (link.signedTreeSize2 !== link.treeSize2) {
|
|
30462
|
+
throw new CheckpointSignedSizeMismatchError(`consistency proof ${i}: signed tree-size-2 (-65933) ${link.signedTreeSize2} != declared consistency-proof tree-size-2 ${link.treeSize2}`);
|
|
30463
|
+
}
|
|
30464
|
+
}
|
|
29607
30465
|
if (firstLink.treeSize1 !== baseSize) {
|
|
29608
30466
|
throw new Error(`first consistency proof declares tree-size-1 ${firstLink.treeSize1}; the trusted base size is ${baseSize}`);
|
|
29609
30467
|
}
|
|
@@ -29641,15 +30499,15 @@ async function freshenReceipt(input) {
|
|
|
29641
30499
|
for (let k = 0;k < oldPath.length; k++) {
|
|
29642
30500
|
store.set(fullIndices[k], oldPath[k]);
|
|
29643
30501
|
}
|
|
29644
|
-
for (const
|
|
29645
|
-
if (
|
|
30502
|
+
for (const step of links.flatMap((link) => link.proofs)) {
|
|
30503
|
+
if (step.treeSize1 === 0n)
|
|
29646
30504
|
continue;
|
|
29647
|
-
const fromPeaks = peakMMRIndexes(
|
|
30505
|
+
const fromPeaks = peakMMRIndexes(step.treeSize1 - 1n);
|
|
29648
30506
|
fromPeaks.forEach((peakIndex, j) => {
|
|
29649
|
-
const climb =
|
|
30507
|
+
const climb = step.paths[j];
|
|
29650
30508
|
if (climb === undefined)
|
|
29651
30509
|
return;
|
|
29652
|
-
const climbIndices = inclusionProofPath(
|
|
30510
|
+
const climbIndices = inclusionProofPath(step.treeSize2 - 1n, peakIndex);
|
|
29653
30511
|
climbIndices.forEach((ix, e) => {
|
|
29654
30512
|
const v = climb[e];
|
|
29655
30513
|
if (v !== undefined)
|
|
@@ -29674,14 +30532,14 @@ async function freshenReceipt(input) {
|
|
|
29674
30532
|
return { receipt, sealedSize };
|
|
29675
30533
|
}
|
|
29676
30534
|
var init_freshen_receipt = __esm(() => {
|
|
29677
|
-
|
|
30535
|
+
init_dist11();
|
|
29678
30536
|
init_build_receipt_offline();
|
|
29679
30537
|
init_checkpoint_chain();
|
|
29680
30538
|
init_parse_receipt();
|
|
29681
30539
|
});
|
|
29682
30540
|
|
|
29683
30541
|
// node_modules/@forestrie/receipt-verify/dist/cose-key.js
|
|
29684
|
-
var
|
|
30542
|
+
var COSE_ALG_ES2568 = -7, COSE_KEY_KTY = 1, COSE_KEY_ALG = 3, COSE_EC2_CRV = -1, COSE_EC2_X = -2, COSE_EC2_Y = -3, COSE_KTY_EC22 = 2, COSE_CRV_P2562 = 1;
|
|
29685
30543
|
|
|
29686
30544
|
// node_modules/@forestrie/receipt-verify/dist/forest-genesis-labels.js
|
|
29687
30545
|
var FOREST_GENESIS_LABEL_GENESIS_VERSION = -68009, FOREST_GENESIS_LABEL_GENESIS_ALG = -68014, FOREST_GENESIS_LABEL_BOOTSTRAP_KEY = -68015, FOREST_GENESIS_SCHEMA_V2 = 2, FOREST_GENESIS_SCHEMA_V1 = 1, HEADER_IDTIMESTAMP2 = -65537, HEADER_FORESTRIE_GRANT_V02 = -65538;
|
|
@@ -29828,13 +30686,13 @@ async function decodeTrustRootDetailsFromGenesis(genesisCbor) {
|
|
|
29828
30686
|
const y = asGenesisUint8Array(m.get(COSE_EC2_Y));
|
|
29829
30687
|
if (kty === COSE_KTY_EC22 && crv === COSE_CRV_P2562 && x && y) {
|
|
29830
30688
|
const alg = m.get(COSE_KEY_ALG);
|
|
29831
|
-
if (alg !== undefined && alg !==
|
|
30689
|
+
if (alg !== undefined && alg !== COSE_ALG_ES2568) {
|
|
29832
30690
|
throw new Error("genesis EC2 key must be ES256");
|
|
29833
30691
|
}
|
|
29834
30692
|
const xy = new Uint8Array(64);
|
|
29835
30693
|
xy.set(x, 0);
|
|
29836
30694
|
xy.set(y, 32);
|
|
29837
|
-
const key = await decodeTrustRootCbor({ alg:
|
|
30695
|
+
const key = await decodeTrustRootCbor({ alg: COSE_ALG_ES2568, key: xy });
|
|
29838
30696
|
return { key, bootstrapKeyXy: xy };
|
|
29839
30697
|
}
|
|
29840
30698
|
if (versionRaw === FOREST_GENESIS_SCHEMA_V1 || versionRaw === undefined) {
|
|
@@ -29856,26 +30714,26 @@ var init_decode_chain_binding_from_genesis = __esm(() => {
|
|
|
29856
30714
|
});
|
|
29857
30715
|
|
|
29858
30716
|
// node_modules/@forestrie/receipt-verify/dist/uuid-bytes.js
|
|
29859
|
-
function
|
|
29860
|
-
if (bytes.length ===
|
|
30717
|
+
function toPaddedWire325(bytes) {
|
|
30718
|
+
if (bytes.length === WIRE_LOG_ID_BYTES5)
|
|
29861
30719
|
return bytes;
|
|
29862
|
-
const out = new Uint8Array(
|
|
29863
|
-
if (bytes.length >=
|
|
29864
|
-
out.set(bytes.slice(-
|
|
30720
|
+
const out = new Uint8Array(WIRE_LOG_ID_BYTES5);
|
|
30721
|
+
if (bytes.length >= WIRE_LOG_ID_BYTES5) {
|
|
30722
|
+
out.set(bytes.slice(-WIRE_LOG_ID_BYTES5));
|
|
29865
30723
|
} else {
|
|
29866
|
-
out.set(bytes,
|
|
30724
|
+
out.set(bytes, WIRE_LOG_ID_BYTES5 - bytes.length);
|
|
29867
30725
|
}
|
|
29868
30726
|
return out;
|
|
29869
30727
|
}
|
|
29870
|
-
function
|
|
30728
|
+
function fromPaddedWire325(wire) {
|
|
29871
30729
|
if (wire.length === 16)
|
|
29872
30730
|
return wire;
|
|
29873
|
-
if (wire.length !==
|
|
29874
|
-
throw new Error(`Expected ${
|
|
30731
|
+
if (wire.length !== WIRE_LOG_ID_BYTES5) {
|
|
30732
|
+
throw new Error(`Expected ${WIRE_LOG_ID_BYTES5}-byte wire log id`);
|
|
29875
30733
|
}
|
|
29876
30734
|
return wire.slice(-16);
|
|
29877
30735
|
}
|
|
29878
|
-
var
|
|
30736
|
+
var WIRE_LOG_ID_BYTES5 = 32;
|
|
29879
30737
|
|
|
29880
30738
|
// node_modules/@forestrie/receipt-verify/dist/grant-commitment.js
|
|
29881
30739
|
function u64Be(n) {
|
|
@@ -29897,11 +30755,11 @@ function grantFlags32(flags) {
|
|
|
29897
30755
|
return out;
|
|
29898
30756
|
}
|
|
29899
30757
|
function grantCommitmentPreimage(grant) {
|
|
29900
|
-
const logId =
|
|
30758
|
+
const logId = toPaddedWire325(grant.logId);
|
|
29901
30759
|
const flags32 = grantFlags32(grant.grant);
|
|
29902
30760
|
const maxHeight = grant.maxHeight ?? 0;
|
|
29903
30761
|
const minGrowth = grant.minGrowth ?? 0;
|
|
29904
|
-
const ownerLogId =
|
|
30762
|
+
const ownerLogId = toPaddedWire325(grant.ownerLogId);
|
|
29905
30763
|
const grantData = grantDataToBytes(grant.grantData ?? new Uint8Array(0));
|
|
29906
30764
|
const total = logId.length + flags32.length + U64_BYTES * 2 + ownerLogId.length + grantData.length;
|
|
29907
30765
|
const out = new Uint8Array(total);
|
|
@@ -30240,7 +31098,7 @@ async function verifyReceiptOfflineWithLeafInnerKeys(input) {
|
|
|
30240
31098
|
}
|
|
30241
31099
|
var init_verify_grant_receipt_offline = __esm(() => {
|
|
30242
31100
|
init_dist3();
|
|
30243
|
-
|
|
31101
|
+
init_dist11();
|
|
30244
31102
|
init_grant_commitment();
|
|
30245
31103
|
init_decode_trust_root_from_genesis();
|
|
30246
31104
|
init_decode_trust_root_cbor();
|
|
@@ -30274,6 +31132,14 @@ function leftPad(b, length) {
|
|
|
30274
31132
|
out.set(b, length - b.length);
|
|
30275
31133
|
return out;
|
|
30276
31134
|
}
|
|
31135
|
+
function assertNoObsoleteWireKeys(m) {
|
|
31136
|
+
const keys = m instanceof Map ? [...m.keys()] : Object.keys(m).map(Number).filter((n) => Number.isFinite(n));
|
|
31137
|
+
for (const k of keys) {
|
|
31138
|
+
if (k === 7 || k === 8) {
|
|
31139
|
+
throw new Error("Grant wire v0: obsolete CBOR keys 7 (signer) and 8 (kind) must not be present; use grantData in the commitment only.");
|
|
31140
|
+
}
|
|
31141
|
+
}
|
|
31142
|
+
}
|
|
30277
31143
|
function mapToGrant(m) {
|
|
30278
31144
|
const get = (k) => m instanceof Map ? m.get(k) : m[k];
|
|
30279
31145
|
const requireBstr = (v, minLen = 0) => {
|
|
@@ -30291,25 +31157,27 @@ function mapToGrant(m) {
|
|
|
30291
31157
|
throw new Error("Grant payload: expected uint");
|
|
30292
31158
|
};
|
|
30293
31159
|
return {
|
|
30294
|
-
logId:
|
|
30295
|
-
ownerLogId:
|
|
31160
|
+
logId: fromPaddedWire325(requireBstr(get(CBOR_KEY_LOG_ID))),
|
|
31161
|
+
ownerLogId: fromPaddedWire325(requireBstr(get(CBOR_KEY_OWNER_LOG_ID))),
|
|
30296
31162
|
grant: leftPad(requireBstr(get(CBOR_KEY_GRANT_FLAGS)), WIRE_GRANT_FLAGS_BYTES2),
|
|
30297
31163
|
maxHeight: requireUint(get(CBOR_KEY_MAX_HEIGHT)),
|
|
30298
31164
|
minGrowth: requireUint(get(CBOR_KEY_MIN_GROWTH)),
|
|
30299
31165
|
grantData: get(CBOR_KEY_GRANT_DATA) instanceof Uint8Array ? get(CBOR_KEY_GRANT_DATA) : new Uint8Array(0)
|
|
30300
31166
|
};
|
|
30301
31167
|
}
|
|
30302
|
-
function
|
|
31168
|
+
function decodeGrantPayload5(bytes) {
|
|
30303
31169
|
if (!bytes?.length)
|
|
30304
31170
|
throw new Error("Grant payload is empty");
|
|
30305
31171
|
const raw = decodeCborDeterministic(bytes);
|
|
30306
31172
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
30307
31173
|
throw new Error("Grant payload must be a CBOR map");
|
|
30308
31174
|
}
|
|
30309
|
-
|
|
31175
|
+
const m = raw;
|
|
31176
|
+
assertNoObsoleteWireKeys(m);
|
|
31177
|
+
return mapToGrant(m);
|
|
30310
31178
|
}
|
|
30311
31179
|
var CBOR_KEY_LOG_ID = 1, CBOR_KEY_OWNER_LOG_ID = 2, CBOR_KEY_GRANT_FLAGS = 3, CBOR_KEY_MAX_HEIGHT = 4, CBOR_KEY_MIN_GROWTH = 5, CBOR_KEY_GRANT_DATA = 6, WIRE_GRANT_FLAGS_BYTES2 = 8;
|
|
30312
|
-
var
|
|
31180
|
+
var init_grant_codec5 = __esm(() => {
|
|
30313
31181
|
init_dist3();
|
|
30314
31182
|
init_dist3();
|
|
30315
31183
|
});
|
|
@@ -30358,7 +31226,7 @@ function decodeForestrieGrantCose(bytes) {
|
|
|
30358
31226
|
const idtimestampVal = unprotected.get(HEADER_IDTIMESTAMP2);
|
|
30359
31227
|
const idtimestampBe8 = idtimestampVal instanceof Uint8Array && idtimestampVal.length >= IDTIMESTAMP_BYTES3 ? idtimestampVal.length === IDTIMESTAMP_BYTES3 ? idtimestampVal : idtimestampVal.slice(-IDTIMESTAMP_BYTES3) : new Uint8Array(IDTIMESTAMP_BYTES3);
|
|
30360
31228
|
return {
|
|
30361
|
-
grant:
|
|
31229
|
+
grant: decodeGrantPayload5(embedded),
|
|
30362
31230
|
idtimestampBe8: new Uint8Array(idtimestampBe8)
|
|
30363
31231
|
};
|
|
30364
31232
|
}
|
|
@@ -30366,7 +31234,7 @@ var IDTIMESTAMP_BYTES3 = 8;
|
|
|
30366
31234
|
var init_decode_forestrie_grant_cose = __esm(() => {
|
|
30367
31235
|
init_sha256();
|
|
30368
31236
|
init_dist3();
|
|
30369
|
-
|
|
31237
|
+
init_grant_codec5();
|
|
30370
31238
|
});
|
|
30371
31239
|
|
|
30372
31240
|
// node_modules/@forestrie/receipt-verify/dist/attach-transparent-statement-receipt.js
|
|
@@ -30414,7 +31282,7 @@ async function findGrantLeafInMassif(massifBytes, grant) {
|
|
|
30414
31282
|
return index2.findLeafByContentHash(inner);
|
|
30415
31283
|
}
|
|
30416
31284
|
var init_find_grant_leaf = __esm(() => {
|
|
30417
|
-
|
|
31285
|
+
init_dist11();
|
|
30418
31286
|
init_grant_commitment();
|
|
30419
31287
|
});
|
|
30420
31288
|
|
|
@@ -30489,7 +31357,7 @@ var init_erc1271_verify_hooks = __esm(() => {
|
|
|
30489
31357
|
});
|
|
30490
31358
|
|
|
30491
31359
|
// node_modules/@forestrie/chain-rpc/dist/index.js
|
|
30492
|
-
var
|
|
31360
|
+
var init_dist12 = __esm(() => {
|
|
30493
31361
|
init_substitute_env_templates();
|
|
30494
31362
|
init_supported_chains_config();
|
|
30495
31363
|
init_erc1271_verify_hooks();
|
|
@@ -30580,17 +31448,17 @@ function assertSnapshotBinding(snapshot, opts) {
|
|
|
30580
31448
|
var LABEL_VERSION = 1, LABEL_CHAIN_ID2 = 2, LABEL_UNIVOCITY = 3, LABEL_LOG_ID = 4, LABEL_SIZE = 5, LABEL_ACCUMULATOR = 6, LABEL_BLOCK_NUMBER = 7, LABEL_BLOCK_HASH = 8, SNAPSHOT_VERSION = 1;
|
|
30581
31449
|
var init_known_accumulator = __esm(() => {
|
|
30582
31450
|
init_dist3();
|
|
30583
|
-
|
|
30584
|
-
|
|
31451
|
+
init_dist11();
|
|
31452
|
+
init_dist12();
|
|
30585
31453
|
init_parse_receipt();
|
|
30586
31454
|
});
|
|
30587
31455
|
|
|
30588
31456
|
// node_modules/@forestrie/receipt-verify/dist/index.js
|
|
30589
|
-
var
|
|
31457
|
+
var init_dist13 = __esm(() => {
|
|
30590
31458
|
init_parse_receipt();
|
|
30591
31459
|
init_build_receipt_offline();
|
|
30592
31460
|
init_freshen_receipt();
|
|
30593
|
-
|
|
31461
|
+
init_dist11();
|
|
30594
31462
|
init_decode_trust_root_from_genesis();
|
|
30595
31463
|
init_decode_chain_binding_from_genesis();
|
|
30596
31464
|
init_verify_grant_receipt_offline();
|
|
@@ -30601,11 +31469,11 @@ var init_dist11 = __esm(() => {
|
|
|
30601
31469
|
init_session_key_endorsement();
|
|
30602
31470
|
init_verify_endorsed_leaf();
|
|
30603
31471
|
init_decode_forestrie_grant_cose();
|
|
30604
|
-
|
|
31472
|
+
init_grant_codec5();
|
|
30605
31473
|
init_attach_transparent_statement_receipt();
|
|
30606
31474
|
init_grant_commitment();
|
|
30607
31475
|
init_find_grant_leaf();
|
|
30608
|
-
|
|
31476
|
+
init_dist11();
|
|
30609
31477
|
init_checkpoint_chain();
|
|
30610
31478
|
init_known_accumulator();
|
|
30611
31479
|
});
|
|
@@ -30632,6 +31500,11 @@ async function deriveCheckpointReceipt(input) {
|
|
|
30632
31500
|
if (sealedSize === null || sealedSize <= 0n) {
|
|
30633
31501
|
fail3("parse", "checkpoint_missing_sealed_size", "checkpoint carries no consistency proof (cannot determine sealed size)");
|
|
30634
31502
|
}
|
|
31503
|
+
try {
|
|
31504
|
+
checkpointConsistencyProof(checkpointBytes);
|
|
31505
|
+
} catch (err) {
|
|
31506
|
+
fail3("parse", "checkpoint_consistency_invalid", `checkpoint consistency proofs do not agree with its signed size: ${errorMessage2(err)}`);
|
|
31507
|
+
}
|
|
30635
31508
|
let store;
|
|
30636
31509
|
try {
|
|
30637
31510
|
store = openMassifNodeStore(massifBytes);
|
|
@@ -30684,7 +31557,7 @@ async function deriveCheckpointReceipt(input) {
|
|
|
30684
31557
|
}
|
|
30685
31558
|
var CreateReceiptFailure;
|
|
30686
31559
|
var init_create_receipt_derive = __esm(() => {
|
|
30687
|
-
|
|
31560
|
+
init_dist13();
|
|
30688
31561
|
CreateReceiptFailure = class CreateReceiptFailure extends Error {
|
|
30689
31562
|
stage;
|
|
30690
31563
|
reason;
|
|
@@ -30782,8 +31655,8 @@ function errorMessage3(err) {
|
|
|
30782
31655
|
}
|
|
30783
31656
|
var CompleteGrantFailure;
|
|
30784
31657
|
var init_complete_grant_derive = __esm(() => {
|
|
30785
|
-
|
|
30786
|
-
|
|
31658
|
+
init_dist13();
|
|
31659
|
+
init_dist8();
|
|
30787
31660
|
init_register_grant_complete();
|
|
30788
31661
|
init_create_receipt_derive();
|
|
30789
31662
|
CompleteGrantFailure = class CompleteGrantFailure extends Error {
|
|
@@ -31041,7 +31914,7 @@ function loadCreateReceiptArtifacts(options) {
|
|
|
31041
31914
|
return { massifBytes, checkpointBytes, leaf };
|
|
31042
31915
|
}
|
|
31043
31916
|
var init_create_receipt_inputs = __esm(() => {
|
|
31044
|
-
|
|
31917
|
+
init_dist13();
|
|
31045
31918
|
});
|
|
31046
31919
|
|
|
31047
31920
|
// src/lib/verify-inputs.ts
|
|
@@ -31077,7 +31950,7 @@ function decodeGrantBytes(bytes, entryId, source) {
|
|
|
31077
31950
|
idtimestampBe8: entryId !== undefined ? entryIdHexToIdtimestampBe82(entryId) : decoded.idtimestampBe8
|
|
31078
31951
|
};
|
|
31079
31952
|
} catch {}
|
|
31080
|
-
const grant =
|
|
31953
|
+
const grant = decodeGrantPayload5(bytes);
|
|
31081
31954
|
if (entryId === undefined) {
|
|
31082
31955
|
throw new Error(`${source} is a raw grant payload (no embedded idtimestamp) — pass --entry-id`);
|
|
31083
31956
|
}
|
|
@@ -31101,7 +31974,7 @@ function loadVerifyArtifacts(options) {
|
|
|
31101
31974
|
return { genesisCbor, receiptCbor, grant, idtimestampBe8 };
|
|
31102
31975
|
}
|
|
31103
31976
|
var init_verify_inputs = __esm(() => {
|
|
31104
|
-
|
|
31977
|
+
init_dist13();
|
|
31105
31978
|
});
|
|
31106
31979
|
|
|
31107
31980
|
// src/lib/bytes.ts
|
|
@@ -31194,7 +32067,7 @@ function checkReceiptAnchoredToCheckpointChain(opts) {
|
|
|
31194
32067
|
}
|
|
31195
32068
|
var init_verify_checkpoint_chain = __esm(() => {
|
|
31196
32069
|
init_dist3();
|
|
31197
|
-
|
|
32070
|
+
init_dist13();
|
|
31198
32071
|
});
|
|
31199
32072
|
|
|
31200
32073
|
// src/lib/verify-known-accumulator.ts
|
|
@@ -31273,7 +32146,7 @@ async function checkReceiptAnchoredToSnapshot(opts) {
|
|
|
31273
32146
|
};
|
|
31274
32147
|
}
|
|
31275
32148
|
var init_verify_known_accumulator = __esm(() => {
|
|
31276
|
-
|
|
32149
|
+
init_dist13();
|
|
31277
32150
|
});
|
|
31278
32151
|
|
|
31279
32152
|
// src/lib/verify-anchored.ts
|
|
@@ -31435,10 +32308,10 @@ async function checkReceiptAnchored(opts) {
|
|
|
31435
32308
|
}
|
|
31436
32309
|
var LOG_STATE_SELECTOR = "0xeecac1b7";
|
|
31437
32310
|
var init_verify_anchored = __esm(() => {
|
|
31438
|
-
|
|
32311
|
+
init_dist12();
|
|
31439
32312
|
init_dist3();
|
|
31440
|
-
init_dist9();
|
|
31441
32313
|
init_dist11();
|
|
32314
|
+
init_dist13();
|
|
31442
32315
|
});
|
|
31443
32316
|
|
|
31444
32317
|
// src/lib/verify-eventscan.ts
|
|
@@ -31539,7 +32412,7 @@ function selectPublishedAtBlock(published, atBlock) {
|
|
|
31539
32412
|
}
|
|
31540
32413
|
var CHECKPOINT_PUBLISHED_TOPIC0 = "0x156942b408823cb05a16027962ea485fa7171d99779ee04094280b2569482426";
|
|
31541
32414
|
var init_verify_eventscan = __esm(() => {
|
|
31542
|
-
|
|
32415
|
+
init_dist12();
|
|
31543
32416
|
init_verify_anchored();
|
|
31544
32417
|
});
|
|
31545
32418
|
|
|
@@ -31582,7 +32455,8 @@ function decodePublishCheckpointCalldata(inputHex) {
|
|
|
31582
32455
|
delegationKey: hexToBytes7(receipt.delegationProof.delegationKey),
|
|
31583
32456
|
mmrStart: receipt.delegationProof.mmrStart,
|
|
31584
32457
|
mmrEnd: receipt.delegationProof.mmrEnd,
|
|
31585
|
-
signature: hexToBytes7(receipt.delegationProof.signature)
|
|
32458
|
+
signature: hexToBytes7(receipt.delegationProof.signature),
|
|
32459
|
+
algData: receipt.delegationProof.algData.map(hexToBytes7)
|
|
31586
32460
|
}
|
|
31587
32461
|
};
|
|
31588
32462
|
}
|
|
@@ -31622,7 +32496,7 @@ var init_decode_checkpoint_calldata = __esm(() => {
|
|
|
31622
32496
|
init__esm();
|
|
31623
32497
|
PUBLISH_CHECKPOINT_ABI = parseAbi([
|
|
31624
32498
|
"struct ConsistencyProof { uint64 treeSize1; uint64 treeSize2; bytes32[][] paths; bytes32[] rightPeaks; }",
|
|
31625
|
-
"struct DelegationProof { bytes protectedHeader; bytes delegationKey; uint64 mmrStart; uint64 mmrEnd; bytes signature; }",
|
|
32499
|
+
"struct DelegationProof { bytes protectedHeader; bytes delegationKey; uint64 mmrStart; uint64 mmrEnd; bytes signature; bytes[] algData; }",
|
|
31626
32500
|
"struct ConsistencyReceipt { bytes protectedHeader; bytes signature; ConsistencyProof[] consistencyProofs; DelegationProof delegationProof; }",
|
|
31627
32501
|
"struct InclusionProof { uint64 index; bytes32[] path; }",
|
|
31628
32502
|
"struct PublishGrant { bytes32 logId; uint256 grant; uint256 request; uint64 maxHeight; uint64 minGrowth; bytes32 ownerLogId; bytes grantData; }",
|
|
@@ -31631,6 +32505,14 @@ var init_decode_checkpoint_calldata = __esm(() => {
|
|
|
31631
32505
|
});
|
|
31632
32506
|
|
|
31633
32507
|
// src/lib/checkpoint-provider.ts
|
|
32508
|
+
function singleProofChain(p, signedTreeSize2 = p.treeSize2) {
|
|
32509
|
+
return {
|
|
32510
|
+
proofs: [p],
|
|
32511
|
+
treeSize1: p.treeSize1,
|
|
32512
|
+
treeSize2: p.treeSize2,
|
|
32513
|
+
signedTreeSize2
|
|
32514
|
+
};
|
|
32515
|
+
}
|
|
31634
32516
|
async function foldProofChain(proofs, opts = {}) {
|
|
31635
32517
|
let accumulator = opts.accumulatorFrom ?? [];
|
|
31636
32518
|
let expectedBase;
|
|
@@ -31648,13 +32530,16 @@ async function foldProofChain(proofs, opts = {}) {
|
|
|
31648
32530
|
if (p.treeSize1 !== expectedBase) {
|
|
31649
32531
|
throw new Error(`checkpoint chain is not contiguous at link ${i}: base ${p.treeSize1} != expected ${expectedBase}`);
|
|
31650
32532
|
}
|
|
31651
|
-
|
|
32533
|
+
const signed = opts.signedSizes?.[i];
|
|
32534
|
+
accumulator = await computeCheckpointAccumulator(singleProofChain(p, signed), accumulator, expectedBase);
|
|
31652
32535
|
const link = {
|
|
31653
32536
|
treeSize1: p.treeSize1,
|
|
31654
32537
|
treeSize2: p.treeSize2,
|
|
31655
32538
|
accumulator,
|
|
31656
32539
|
proof: p
|
|
31657
32540
|
};
|
|
32541
|
+
if (signed !== undefined)
|
|
32542
|
+
link.signedTreeSize2 = signed;
|
|
31658
32543
|
const seal = opts.seals?.[i];
|
|
31659
32544
|
if (seal !== undefined)
|
|
31660
32545
|
link.seal = seal;
|
|
@@ -31667,16 +32552,26 @@ async function foldProofChain(proofs, opts = {}) {
|
|
|
31667
32552
|
return links;
|
|
31668
32553
|
}
|
|
31669
32554
|
async function sthCheckpointChain(checkpoints, opts = {}) {
|
|
31670
|
-
const proofs =
|
|
31671
|
-
const seals =
|
|
31672
|
-
|
|
31673
|
-
|
|
31674
|
-
|
|
32555
|
+
const proofs = [];
|
|
32556
|
+
const seals = [];
|
|
32557
|
+
const sourceRefs = [];
|
|
32558
|
+
const signedSizes = [];
|
|
32559
|
+
checkpoints.forEach((bytes, i) => {
|
|
32560
|
+
const chain = checkpointConsistencyProof(bytes);
|
|
32561
|
+
chain.proofs.forEach((step, j) => {
|
|
32562
|
+
const last = j === chain.proofs.length - 1;
|
|
32563
|
+
proofs.push(step);
|
|
32564
|
+
seals.push(last ? { kind: "sth", checkpointBytes: bytes } : undefined);
|
|
32565
|
+
signedSizes.push(last ? chain.signedTreeSize2 : undefined);
|
|
32566
|
+
sourceRefs.push(opts.sourceRefs?.[i]);
|
|
32567
|
+
});
|
|
32568
|
+
});
|
|
31675
32569
|
return foldProofChain(proofs, {
|
|
31676
32570
|
seals,
|
|
32571
|
+
signedSizes,
|
|
31677
32572
|
...opts.accumulatorFrom !== undefined ? { accumulatorFrom: opts.accumulatorFrom } : {},
|
|
31678
32573
|
...opts.accumulatorFromSize !== undefined ? { accumulatorFromSize: opts.accumulatorFromSize } : {},
|
|
31679
|
-
...opts.sourceRefs !== undefined ? { sourceRefs
|
|
32574
|
+
...opts.sourceRefs !== undefined ? { sourceRefs } : {}
|
|
31680
32575
|
});
|
|
31681
32576
|
}
|
|
31682
32577
|
async function mapBounded(items, limit, fn) {
|
|
@@ -31756,7 +32651,7 @@ async function calldataCheckpointChain(opts) {
|
|
|
31756
32651
|
return links;
|
|
31757
32652
|
}
|
|
31758
32653
|
var init_checkpoint_provider = __esm(() => {
|
|
31759
|
-
|
|
32654
|
+
init_dist13();
|
|
31760
32655
|
init_verify_eventscan();
|
|
31761
32656
|
init_decode_checkpoint_calldata();
|
|
31762
32657
|
});
|
|
@@ -31774,10 +32669,7 @@ async function emitFreshened(opts) {
|
|
|
31774
32669
|
const result = await freshenReceipt({
|
|
31775
32670
|
oldReceiptBytes: opts.oldReceiptBytes,
|
|
31776
32671
|
leafValue: opts.leafValue,
|
|
31777
|
-
consistencyProofs: opts.links.map((l) => (
|
|
31778
|
-
...l.proof,
|
|
31779
|
-
signedTreeSize2: l.proof.treeSize2
|
|
31780
|
-
})),
|
|
32672
|
+
consistencyProofs: opts.links.map((l) => singleProofChain(l.proof, l.signedTreeSize2)),
|
|
31781
32673
|
latestCheckpointBytes: opts.latestCheckpointBytes
|
|
31782
32674
|
});
|
|
31783
32675
|
let knownAccumulatorMatched;
|
|
@@ -31816,7 +32708,7 @@ async function freshenFromSthChain(opts) {
|
|
|
31816
32708
|
leafValue,
|
|
31817
32709
|
links,
|
|
31818
32710
|
latestCheckpointBytes: opts.checkpoints[opts.checkpoints.length - 1],
|
|
31819
|
-
sourceRefs:
|
|
32711
|
+
sourceRefs: links.map((l) => l.sourceRef ?? ""),
|
|
31820
32712
|
knownAccumulator: opts.knownAccumulator
|
|
31821
32713
|
});
|
|
31822
32714
|
}
|
|
@@ -31841,7 +32733,7 @@ async function freshenFromCalldataChain(opts) {
|
|
|
31841
32733
|
});
|
|
31842
32734
|
}
|
|
31843
32735
|
var init_resolve_receipt_freshen = __esm(() => {
|
|
31844
|
-
|
|
32736
|
+
init_dist13();
|
|
31845
32737
|
init_checkpoint_provider();
|
|
31846
32738
|
init_verify_anchored();
|
|
31847
32739
|
});
|
|
@@ -31929,7 +32821,7 @@ async function verifyChainAnchored(input, deps = defaultDeps) {
|
|
|
31929
32821
|
}
|
|
31930
32822
|
var ChainVerifyFailure, defaultDeps;
|
|
31931
32823
|
var init_create_receipt_chain_verify = __esm(() => {
|
|
31932
|
-
|
|
32824
|
+
init_dist13();
|
|
31933
32825
|
init_verify_anchored();
|
|
31934
32826
|
ChainVerifyFailure = class ChainVerifyFailure extends Error {
|
|
31935
32827
|
stage;
|
|
@@ -32275,7 +33167,7 @@ var CHAIN_EXIT_CODE, ERROR_CODES2, CHAIN_OUTCOME_NARRATION;
|
|
|
32275
33167
|
var init_create_receipt = __esm(() => {
|
|
32276
33168
|
init_create_receipt_derive();
|
|
32277
33169
|
init_create_receipt_inputs();
|
|
32278
|
-
|
|
33170
|
+
init_dist13();
|
|
32279
33171
|
init_verify_inputs();
|
|
32280
33172
|
init_verify_checkpoint_chain();
|
|
32281
33173
|
init_verify_known_accumulator();
|
|
@@ -32700,11 +33592,11 @@ var init_decode_receipt_labels = __esm(() => {
|
|
|
32700
33592
|
[CWT_CLAIMS_LABEL, { name: "CWT claims", note: "RFC 9597" }],
|
|
32701
33593
|
[
|
|
32702
33594
|
VDS_LABEL,
|
|
32703
|
-
{ name: "verifiable data structure", note: "COSE receipts (
|
|
33595
|
+
{ name: "verifiable data structure", note: "COSE receipts (RFC 9942)" }
|
|
32704
33596
|
],
|
|
32705
33597
|
[
|
|
32706
33598
|
VERIFIABLE_PROOFS_LABEL,
|
|
32707
|
-
{ name: "verifiable proofs", note: "COSE receipts (
|
|
33599
|
+
{ name: "verifiable proofs", note: "COSE receipts (RFC 9942)" }
|
|
32708
33600
|
],
|
|
32709
33601
|
[
|
|
32710
33602
|
DELEGATION_CERT_LABEL3,
|
|
@@ -32764,7 +33656,7 @@ var init_decode_receipt_labels = __esm(() => {
|
|
|
32764
33656
|
[-65799, "KS256 (secp256k1 + Keccak-256, forestrie private-use)"],
|
|
32765
33657
|
[
|
|
32766
33658
|
-65800,
|
|
32767
|
-
"ES256-WebAuthn (forestrie private-use; delegation proofs
|
|
33659
|
+
"ES256-WebAuthn (forestrie private-use; delegation proofs, certificates " + "and session-key endorsements, never checkpoint-signing)"
|
|
32768
33660
|
]
|
|
32769
33661
|
]);
|
|
32770
33662
|
VDS_NAMES = new Map([
|
|
@@ -32977,7 +33869,7 @@ function decodeReceipt(receiptBytes) {
|
|
|
32977
33869
|
}
|
|
32978
33870
|
var DecodeReceiptError, HEX;
|
|
32979
33871
|
var init_decode_receipt_decode = __esm(() => {
|
|
32980
|
-
|
|
33872
|
+
init_dist13();
|
|
32981
33873
|
init_dist3();
|
|
32982
33874
|
init_decode_receipt_cbor();
|
|
32983
33875
|
init_decode_receipt_labels();
|
|
@@ -33427,7 +34319,7 @@ async function checkReceiptAnchoredViaConsistencyProof(opts) {
|
|
|
33427
34319
|
var LABEL_VERSION2 = 1, LABEL_FROM_SIZE = 2, LABEL_TO_SIZE = 3, LABEL_ACCUMULATOR_FROM = 4, LABEL_PATHS = 5, ARTIFACT_VERSION = 1;
|
|
33428
34320
|
var init_consistency_proof = __esm(() => {
|
|
33429
34321
|
init_dist3();
|
|
33430
|
-
|
|
34322
|
+
init_dist11();
|
|
33431
34323
|
});
|
|
33432
34324
|
|
|
33433
34325
|
// src/lib/verify-report.ts
|
|
@@ -33929,7 +34821,7 @@ async function runVerifyGrant(out, options) {
|
|
|
33929
34821
|
}
|
|
33930
34822
|
var VERIFY_ERROR_CODES;
|
|
33931
34823
|
var init_verify = __esm(() => {
|
|
33932
|
-
|
|
34824
|
+
init_dist13();
|
|
33933
34825
|
init_verify_eventscan();
|
|
33934
34826
|
init_verify_anchored();
|
|
33935
34827
|
init_verify_checkpoint_chain();
|
|
@@ -34074,7 +34966,7 @@ var init_verify3 = __esm(() => {
|
|
|
34074
34966
|
},
|
|
34075
34967
|
"known-log-key": {
|
|
34076
34968
|
type: "string",
|
|
34077
|
-
description: "Caller-known log OWNER key (the delegation issuer), base64 x||y (64 bytes) (env KNOWN_LOG_KEY). Offline signer-provenance anchor that replaces --genesis; asserts (does not prove) the key-to-log binding — --genesis
|
|
34969
|
+
description: "Caller-known log OWNER key (the delegation issuer), base64 x||y (64 bytes) (env KNOWN_LOG_KEY). Offline signer-provenance anchor that replaces --genesis; asserts (does not prove) the key-to-log binding — --genesis roots it in the forest genesis document's bootstrap key (the root log, or a delegation directly under it), while the accumulator roots (--known-accumulator / --rpc-url) supply split-view (freshness is a weaker, separate axis bearing only on coverage). See https://github.com/forestrie/protocol/blob/main/spec/receipt-trust-model.md",
|
|
34078
34970
|
valueHint: "base64"
|
|
34079
34971
|
},
|
|
34080
34972
|
receipt: {
|
|
@@ -34163,7 +35055,7 @@ var init_verify_grant = __esm(() => {
|
|
|
34163
35055
|
},
|
|
34164
35056
|
"known-log-key": {
|
|
34165
35057
|
type: "string",
|
|
34166
|
-
description: "Caller-known log OWNER key (the delegation issuer), base64 x||y (64 bytes) (env KNOWN_LOG_KEY). Offline signer-provenance anchor that replaces --genesis; asserts (does not prove) the key-to-log binding — --genesis
|
|
35058
|
+
description: "Caller-known log OWNER key (the delegation issuer), base64 x||y (64 bytes) (env KNOWN_LOG_KEY). Offline signer-provenance anchor that replaces --genesis; asserts (does not prove) the key-to-log binding — --genesis roots it in the forest genesis document's bootstrap key (the root log, or a delegation directly under it), while the accumulator roots (--known-accumulator / --rpc-url) supply split-view (freshness is a weaker, separate axis bearing only on coverage). See https://github.com/forestrie/protocol/blob/main/spec/receipt-trust-model.md",
|
|
34167
35059
|
valueHint: "base64"
|
|
34168
35060
|
},
|
|
34169
35061
|
receipt: {
|
|
@@ -34337,7 +35229,7 @@ async function runFetchAccumulator(out, options) {
|
|
|
34337
35229
|
}
|
|
34338
35230
|
var LOG_STATE_SELECTOR2 = "0xeecac1b7";
|
|
34339
35231
|
var init_fetch_accumulator = __esm(() => {
|
|
34340
|
-
|
|
35232
|
+
init_dist12();
|
|
34341
35233
|
init_verify_anchored();
|
|
34342
35234
|
init_verify_known_accumulator();
|
|
34343
35235
|
init_verify_eventscan();
|
|
@@ -34558,7 +35450,7 @@ init_dist();
|
|
|
34558
35450
|
// package.json
|
|
34559
35451
|
var package_default = {
|
|
34560
35452
|
name: "@forestrie/forestrie-cli",
|
|
34561
|
-
version: "0.
|
|
35453
|
+
version: "0.10.0",
|
|
34562
35454
|
description: "forestrie — participant CLI for forestrie transparency logs (SCITT / COSE receipts)",
|
|
34563
35455
|
keywords: [
|
|
34564
35456
|
"forestrie",
|
|
@@ -34626,10 +35518,10 @@ var package_default = {
|
|
|
34626
35518
|
"@forestrie/cli-kit": "^0.1.1",
|
|
34627
35519
|
"@forestrie/delegation-cose": "^0.3.2",
|
|
34628
35520
|
"@forestrie/deploy-core": "^0.7.1",
|
|
34629
|
-
"@forestrie/encoding": "^0.
|
|
35521
|
+
"@forestrie/encoding": "^0.9.1",
|
|
34630
35522
|
"@forestrie/grant-builder": "^0.5.0",
|
|
34631
|
-
"@forestrie/merklelog": "^0.
|
|
34632
|
-
"@forestrie/receipt-verify": "^
|
|
35523
|
+
"@forestrie/merklelog": "^0.5.0",
|
|
35524
|
+
"@forestrie/receipt-verify": "^3.0.1",
|
|
34633
35525
|
"@forestrie/scrapi-client": "^0.2.2",
|
|
34634
35526
|
citty: "^0.2.2",
|
|
34635
35527
|
viem: "^2.31.0"
|