@tinycloud/sdk-core 3.0.0-beta.5 → 3.0.0-beta.7
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/{credential-admission-BVUC6kdw.d.cts → credential-admission-CFjUChF8.d.cts} +56 -1
- package/dist/{credential-admission-BgvwOTIV.d.ts → credential-admission-DIEPgQ0o.d.ts} +56 -1
- package/dist/delegations/index.cjs +78 -13
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.d.cts +2 -2
- package/dist/delegations/index.d.ts +2 -2
- package/dist/delegations/index.js +78 -13
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +408 -191
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +408 -191
- package/dist/index.js.map +1 -1
- package/dist/policy/index.cjs +159 -7
- package/dist/policy/index.cjs.map +1 -1
- package/dist/policy/index.d.cts +2 -2
- package/dist/policy/index.d.ts +2 -2
- package/dist/policy/index.js +159 -7
- package/dist/policy/index.js.map +1 -1
- package/dist/{recipient-types.schema-G8NEKRoo.d.cts → recipient-types.schema-DjmM_yJu.d.cts} +64 -1
- package/dist/{recipient-types.schema-G8NEKRoo.d.ts → recipient-types.schema-DjmM_yJu.d.ts} +64 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1790,16 +1790,16 @@ function policyCapabilityContains(authority, request) {
|
|
|
1790
1790
|
return caveatsContain(auth.caveats, req.caveats);
|
|
1791
1791
|
}
|
|
1792
1792
|
function normalizePolicyCapabilityWithOptions(input, options2) {
|
|
1793
|
-
const
|
|
1794
|
-
assertExactKeys(
|
|
1795
|
-
const service = requiredString(
|
|
1793
|
+
const object4 = expectObject(input, "$");
|
|
1794
|
+
assertExactKeys(object4, ["service", "space", "path", "actions", "caveats"], "$");
|
|
1795
|
+
const service = requiredString(object4, "service", "$", "policy-capability-malformed-service");
|
|
1796
1796
|
if (!CEILING_SERVICES.has(service)) {
|
|
1797
1797
|
throw new PolicyCapabilityError(
|
|
1798
1798
|
"policy-capability-malformed-service",
|
|
1799
1799
|
"$.service is outside the frozen permissionsCeiling vocabulary"
|
|
1800
1800
|
);
|
|
1801
1801
|
}
|
|
1802
|
-
const space = requiredString(
|
|
1802
|
+
const space = requiredString(object4, "space", "$", "policy-capability-malformed-space");
|
|
1803
1803
|
validateConcreteSpace(space);
|
|
1804
1804
|
const canonicalSpace = space.normalize("NFC");
|
|
1805
1805
|
if (options2.requireCanonical && canonicalSpace !== space) {
|
|
@@ -1808,7 +1808,7 @@ function normalizePolicyCapabilityWithOptions(input, options2) {
|
|
|
1808
1808
|
"$.space must already be canonical NFC"
|
|
1809
1809
|
);
|
|
1810
1810
|
}
|
|
1811
|
-
const rawPath = requiredString(
|
|
1811
|
+
const rawPath = requiredString(object4, "path", "$", "policy-capability-malformed-path");
|
|
1812
1812
|
validateRawPath(rawPath, options2);
|
|
1813
1813
|
const path = normalizePath(rawPath);
|
|
1814
1814
|
if (options2.requireCanonical && path !== rawPath) {
|
|
@@ -1819,7 +1819,7 @@ function normalizePolicyCapabilityWithOptions(input, options2) {
|
|
|
1819
1819
|
}
|
|
1820
1820
|
validateRawPath(path, options2);
|
|
1821
1821
|
const actions = normalizeActions(
|
|
1822
|
-
requiredArray(
|
|
1822
|
+
requiredArray(object4, "actions", "$", "policy-capability-malformed-action"),
|
|
1823
1823
|
service,
|
|
1824
1824
|
options2
|
|
1825
1825
|
);
|
|
@@ -1828,9 +1828,9 @@ function normalizePolicyCapabilityWithOptions(input, options2) {
|
|
|
1828
1828
|
output.space = canonicalSpace;
|
|
1829
1829
|
output.path = path;
|
|
1830
1830
|
output.actions = actions;
|
|
1831
|
-
if (hasOwn(
|
|
1831
|
+
if (hasOwn(object4, "caveats")) {
|
|
1832
1832
|
output.caveats = validateCaveats(
|
|
1833
|
-
requiredValue(
|
|
1833
|
+
requiredValue(object4, "caveats", "$", "policy-capability-malformed-caveats"),
|
|
1834
1834
|
output.service
|
|
1835
1835
|
);
|
|
1836
1836
|
}
|
|
@@ -1853,9 +1853,9 @@ function expectObject(input, path) {
|
|
|
1853
1853
|
);
|
|
1854
1854
|
}
|
|
1855
1855
|
}
|
|
1856
|
-
function assertExactKeys(
|
|
1856
|
+
function assertExactKeys(object4, allowed, path) {
|
|
1857
1857
|
const allowedSet = new Set(allowed);
|
|
1858
|
-
for (const key of Object.keys(
|
|
1858
|
+
for (const key of Object.keys(object4)) {
|
|
1859
1859
|
if (!allowedSet.has(key)) {
|
|
1860
1860
|
throw new PolicyCapabilityError(
|
|
1861
1861
|
key === "id" || key === "scope" ? "policy-capability-malformed" : "policy-capability-unknown-key",
|
|
@@ -1864,21 +1864,21 @@ function assertExactKeys(object3, allowed, path) {
|
|
|
1864
1864
|
}
|
|
1865
1865
|
}
|
|
1866
1866
|
}
|
|
1867
|
-
function requiredValue(
|
|
1868
|
-
if (!hasOwn(
|
|
1867
|
+
function requiredValue(object4, key, path, code3) {
|
|
1868
|
+
if (!hasOwn(object4, key)) {
|
|
1869
1869
|
throw new PolicyCapabilityError(code3, `${path}.${key} is required`);
|
|
1870
1870
|
}
|
|
1871
|
-
return
|
|
1871
|
+
return object4[key];
|
|
1872
1872
|
}
|
|
1873
|
-
function requiredString(
|
|
1874
|
-
const value = requiredValue(
|
|
1873
|
+
function requiredString(object4, key, path, code3) {
|
|
1874
|
+
const value = requiredValue(object4, key, path, code3);
|
|
1875
1875
|
if (typeof value !== "string" || value.length === 0) {
|
|
1876
1876
|
throw new PolicyCapabilityError(code3, `${path}.${key} must be a non-empty string`);
|
|
1877
1877
|
}
|
|
1878
1878
|
return value;
|
|
1879
1879
|
}
|
|
1880
|
-
function requiredArray(
|
|
1881
|
-
const value = requiredValue(
|
|
1880
|
+
function requiredArray(object4, key, path, code3) {
|
|
1881
|
+
const value = requiredValue(object4, key, path, code3);
|
|
1882
1882
|
if (!Array.isArray(value)) {
|
|
1883
1883
|
throw new PolicyCapabilityError(code3, `${path}.${key} must be an array`);
|
|
1884
1884
|
}
|
|
@@ -2023,11 +2023,11 @@ function validateSqlStatement(input, path) {
|
|
|
2023
2023
|
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
2024
2024
|
throw new PolicyCapabilityError("policy-capability-malformed-caveats", `${path} must be an object`);
|
|
2025
2025
|
}
|
|
2026
|
-
const
|
|
2027
|
-
assertCaveatKeys(
|
|
2028
|
-
caveatString(
|
|
2029
|
-
caveatString(
|
|
2030
|
-
const fixedParams = requiredCaveat(
|
|
2026
|
+
const object4 = input;
|
|
2027
|
+
assertCaveatKeys(object4, ["name", "sql", "fixedParams"], path);
|
|
2028
|
+
caveatString(object4, "name", path);
|
|
2029
|
+
caveatString(object4, "sql", path);
|
|
2030
|
+
const fixedParams = requiredCaveat(object4, "fixedParams", path);
|
|
2031
2031
|
if (!Array.isArray(fixedParams)) {
|
|
2032
2032
|
throw new PolicyCapabilityError(
|
|
2033
2033
|
"policy-capability-malformed-caveats",
|
|
@@ -2042,20 +2042,20 @@ function validateFixedParam(input, path) {
|
|
|
2042
2042
|
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
2043
2043
|
throw new PolicyCapabilityError("policy-capability-malformed-caveats", `${path} must be an object`);
|
|
2044
2044
|
}
|
|
2045
|
-
const
|
|
2046
|
-
assertCaveatKeys(
|
|
2047
|
-
const index = requiredCaveat(
|
|
2045
|
+
const object4 = input;
|
|
2046
|
+
assertCaveatKeys(object4, ["index", "value"], path);
|
|
2047
|
+
const index = requiredCaveat(object4, "index", path);
|
|
2048
2048
|
if (typeof index !== "number" || !Number.isSafeInteger(index) || index < 0) {
|
|
2049
2049
|
throw new PolicyCapabilityError(
|
|
2050
2050
|
"policy-capability-malformed-caveats",
|
|
2051
2051
|
`${path}.index must be a non-negative integer`
|
|
2052
2052
|
);
|
|
2053
2053
|
}
|
|
2054
|
-
requiredCaveat(
|
|
2054
|
+
requiredCaveat(object4, "value", path);
|
|
2055
2055
|
}
|
|
2056
|
-
function assertCaveatKeys(
|
|
2056
|
+
function assertCaveatKeys(object4, allowed, path) {
|
|
2057
2057
|
const allowedSet = new Set(allowed);
|
|
2058
|
-
for (const key of Object.keys(
|
|
2058
|
+
for (const key of Object.keys(object4)) {
|
|
2059
2059
|
if (!allowedSet.has(key)) {
|
|
2060
2060
|
throw new PolicyCapabilityError(
|
|
2061
2061
|
"policy-capability-malformed-caveats",
|
|
@@ -2064,17 +2064,17 @@ function assertCaveatKeys(object3, allowed, path) {
|
|
|
2064
2064
|
}
|
|
2065
2065
|
}
|
|
2066
2066
|
}
|
|
2067
|
-
function requiredCaveat(
|
|
2068
|
-
if (!hasOwn(
|
|
2067
|
+
function requiredCaveat(object4, key, path) {
|
|
2068
|
+
if (!hasOwn(object4, key)) {
|
|
2069
2069
|
throw new PolicyCapabilityError(
|
|
2070
2070
|
"policy-capability-malformed-caveats",
|
|
2071
2071
|
`${path}.${key} is required`
|
|
2072
2072
|
);
|
|
2073
2073
|
}
|
|
2074
|
-
return
|
|
2074
|
+
return object4[key];
|
|
2075
2075
|
}
|
|
2076
|
-
function caveatString(
|
|
2077
|
-
const value = requiredCaveat(
|
|
2076
|
+
function caveatString(object4, key, path) {
|
|
2077
|
+
const value = requiredCaveat(object4, key, path);
|
|
2078
2078
|
if (typeof value !== "string" || value.length === 0) {
|
|
2079
2079
|
throw new PolicyCapabilityError(
|
|
2080
2080
|
"policy-capability-malformed-caveats",
|
|
@@ -2105,8 +2105,8 @@ function caveatsContain(authority, request) {
|
|
|
2105
2105
|
(statement) => authorityStatements.some((candidate) => jcsCanonicalize(candidate) === jcsCanonicalize(statement))
|
|
2106
2106
|
);
|
|
2107
2107
|
}
|
|
2108
|
-
function hasOwn(
|
|
2109
|
-
return objectHasOwn2(
|
|
2108
|
+
function hasOwn(object4, key) {
|
|
2109
|
+
return objectHasOwn2(object4, key);
|
|
2110
2110
|
}
|
|
2111
2111
|
|
|
2112
2112
|
// src/policy/signed-object.ts
|
|
@@ -2434,17 +2434,17 @@ async function createAndSignSignedObject(input, signer) {
|
|
|
2434
2434
|
}
|
|
2435
2435
|
function createAndSignPolicy(input, signer) {
|
|
2436
2436
|
return createAndSignSignedObject(input, signer).then(
|
|
2437
|
-
(
|
|
2437
|
+
(object4) => validatePolicySignedShape(object4)
|
|
2438
2438
|
);
|
|
2439
2439
|
}
|
|
2440
2440
|
function createAndSignPolicyStatus(input, signer) {
|
|
2441
2441
|
return createAndSignSignedObject(input, signer).then(
|
|
2442
|
-
(
|
|
2442
|
+
(object4) => validatePolicyStatusSignedShape(object4)
|
|
2443
2443
|
);
|
|
2444
2444
|
}
|
|
2445
2445
|
function createAndSignPolicyEngineRecord(input, signer) {
|
|
2446
2446
|
return createAndSignSignedObject(input, signer).then(
|
|
2447
|
-
(
|
|
2447
|
+
(object4) => validatePolicyEngineRecordSignedShape(object4)
|
|
2448
2448
|
);
|
|
2449
2449
|
}
|
|
2450
2450
|
async function verifySignedObject(input) {
|
|
@@ -2548,9 +2548,9 @@ function validateUnsignedForDescriptor(input, descriptor) {
|
|
|
2548
2548
|
}
|
|
2549
2549
|
}
|
|
2550
2550
|
function validatePolicyShape(input, signed) {
|
|
2551
|
-
const
|
|
2551
|
+
const object4 = expectJsonObject(normalizeJson(input), "$");
|
|
2552
2552
|
assertExactKeys2(
|
|
2553
|
-
|
|
2553
|
+
object4,
|
|
2554
2554
|
signed ? [
|
|
2555
2555
|
"schema",
|
|
2556
2556
|
"policyId",
|
|
@@ -2578,30 +2578,30 @@ function validatePolicyShape(input, signed) {
|
|
|
2578
2578
|
],
|
|
2579
2579
|
"$"
|
|
2580
2580
|
);
|
|
2581
|
-
expectConst(requiredString2(
|
|
2581
|
+
expectConst(requiredString2(object4, "schema", "$"), POLICY_SCHEMA, "$.schema");
|
|
2582
2582
|
if (signed) {
|
|
2583
|
-
requiredString2(
|
|
2584
|
-
validateSignature(requiredValue2(
|
|
2583
|
+
requiredString2(object4, "policyId", "$");
|
|
2584
|
+
validateSignature(requiredValue2(object4, "signature", "$"));
|
|
2585
2585
|
}
|
|
2586
|
-
requiredString2(
|
|
2587
|
-
requiredString2(
|
|
2588
|
-
requiredDateString(
|
|
2589
|
-
optionalDateString(
|
|
2590
|
-
validatePolicyResource(requiredValue2(
|
|
2591
|
-
validateExpression(requiredValue2(
|
|
2592
|
-
validateGrant(requiredValue2(
|
|
2593
|
-
if (hasOwn2(
|
|
2594
|
-
validateDisclosure(requiredValue2(
|
|
2586
|
+
requiredString2(object4, "ownerDid", "$");
|
|
2587
|
+
requiredString2(object4, "signingKeyDid", "$");
|
|
2588
|
+
requiredDateString(object4, "createdAt", "$");
|
|
2589
|
+
optionalDateString(object4, "expiresAt", "$");
|
|
2590
|
+
validatePolicyResource(requiredValue2(object4, "resource", "$"), "$.resource");
|
|
2591
|
+
validateExpression(requiredValue2(object4, "when", "$"), "$.when");
|
|
2592
|
+
validateGrant(requiredValue2(object4, "grant", "$"), "$.grant");
|
|
2593
|
+
if (hasOwn2(object4, "disclosure")) {
|
|
2594
|
+
validateDisclosure(requiredValue2(object4, "disclosure", "$"), "$.disclosure");
|
|
2595
2595
|
}
|
|
2596
|
-
if (hasOwn2(
|
|
2597
|
-
validateAudit(requiredValue2(
|
|
2596
|
+
if (hasOwn2(object4, "audit")) {
|
|
2597
|
+
validateAudit(requiredValue2(object4, "audit", "$"), "$.audit");
|
|
2598
2598
|
}
|
|
2599
|
-
return
|
|
2599
|
+
return object4;
|
|
2600
2600
|
}
|
|
2601
2601
|
function validatePolicyStatusShape(input, signed) {
|
|
2602
|
-
const
|
|
2602
|
+
const object4 = expectJsonObject(normalizeJson(input), "$");
|
|
2603
2603
|
assertExactKeys2(
|
|
2604
|
-
|
|
2604
|
+
object4,
|
|
2605
2605
|
signed ? [
|
|
2606
2606
|
"schema",
|
|
2607
2607
|
"statusId",
|
|
@@ -2625,28 +2625,28 @@ function validatePolicyStatusShape(input, signed) {
|
|
|
2625
2625
|
],
|
|
2626
2626
|
"$"
|
|
2627
2627
|
);
|
|
2628
|
-
expectConst(requiredString2(
|
|
2628
|
+
expectConst(requiredString2(object4, "schema", "$"), POLICY_STATUS_SCHEMA, "$.schema");
|
|
2629
2629
|
if (signed) {
|
|
2630
|
-
requiredString2(
|
|
2631
|
-
validateSignature(requiredValue2(
|
|
2630
|
+
requiredString2(object4, "statusId", "$");
|
|
2631
|
+
validateSignature(requiredValue2(object4, "signature", "$"));
|
|
2632
2632
|
}
|
|
2633
|
-
requiredString2(
|
|
2634
|
-
requiredString2(
|
|
2635
|
-
requiredInteger(
|
|
2636
|
-
expectOneOf(requiredString2(
|
|
2633
|
+
requiredString2(object4, "policyId", "$");
|
|
2634
|
+
requiredString2(object4, "ownerDid", "$");
|
|
2635
|
+
requiredInteger(object4, "sequence", "$", 0);
|
|
2636
|
+
expectOneOf(requiredString2(object4, "disposition", "$"), [
|
|
2637
2637
|
"active",
|
|
2638
2638
|
"suspended",
|
|
2639
2639
|
"revoked"
|
|
2640
2640
|
], "$.disposition");
|
|
2641
|
-
requiredDateString(
|
|
2642
|
-
optionalString(
|
|
2643
|
-
requiredString2(
|
|
2644
|
-
return
|
|
2641
|
+
requiredDateString(object4, "effectiveAt", "$");
|
|
2642
|
+
optionalString(object4, "reasonCode", "$");
|
|
2643
|
+
requiredString2(object4, "signingKeyDid", "$");
|
|
2644
|
+
return object4;
|
|
2645
2645
|
}
|
|
2646
2646
|
function validatePolicyEngineRecordShape(input, signed) {
|
|
2647
|
-
const
|
|
2647
|
+
const object4 = expectJsonObject(normalizeJson(input), "$");
|
|
2648
2648
|
assertExactKeys2(
|
|
2649
|
-
|
|
2649
|
+
object4,
|
|
2650
2650
|
signed ? [
|
|
2651
2651
|
"schema",
|
|
2652
2652
|
"engineRecordId",
|
|
@@ -2671,44 +2671,44 @@ function validatePolicyEngineRecordShape(input, signed) {
|
|
|
2671
2671
|
"$"
|
|
2672
2672
|
);
|
|
2673
2673
|
expectConst(
|
|
2674
|
-
requiredString2(
|
|
2674
|
+
requiredString2(object4, "schema", "$"),
|
|
2675
2675
|
POLICY_ENGINE_RECORD_SCHEMA,
|
|
2676
2676
|
"$.schema"
|
|
2677
2677
|
);
|
|
2678
2678
|
if (signed) {
|
|
2679
|
-
requiredString2(
|
|
2680
|
-
validateSignature(requiredValue2(
|
|
2679
|
+
requiredString2(object4, "engineRecordId", "$");
|
|
2680
|
+
validateSignature(requiredValue2(object4, "signature", "$"));
|
|
2681
2681
|
}
|
|
2682
|
-
requiredString2(
|
|
2683
|
-
requiredString2(
|
|
2684
|
-
requiredString2(
|
|
2682
|
+
requiredString2(object4, "ownerDid", "$");
|
|
2683
|
+
requiredString2(object4, "endpoint", "$");
|
|
2684
|
+
requiredString2(object4, "audience", "$");
|
|
2685
2685
|
requiredStringArray(
|
|
2686
|
-
|
|
2686
|
+
object4,
|
|
2687
2687
|
"supportedPolicyVersions",
|
|
2688
2688
|
"$",
|
|
2689
2689
|
(value, path) => expectConst(value, "v0", path)
|
|
2690
2690
|
);
|
|
2691
|
-
requiredStringArray(
|
|
2692
|
-
requiredString2(
|
|
2693
|
-
requiredDateString(
|
|
2694
|
-
return
|
|
2691
|
+
requiredStringArray(object4, "supportedEvidenceVerifiers", "$");
|
|
2692
|
+
requiredString2(object4, "grantIssuerDid", "$");
|
|
2693
|
+
requiredDateString(object4, "expiresAt", "$");
|
|
2694
|
+
return object4;
|
|
2695
2695
|
}
|
|
2696
2696
|
function validateSignature(input) {
|
|
2697
|
-
const
|
|
2698
|
-
assertExactKeys2(
|
|
2699
|
-
const suite = requiredString2(
|
|
2697
|
+
const object4 = expectJsonObject(input, "$.signature");
|
|
2698
|
+
assertExactKeys2(object4, ["suite", "signerDid", "value"], "$.signature");
|
|
2699
|
+
const suite = requiredString2(object4, "suite", "$.signature");
|
|
2700
2700
|
assertSupportedSignatureSuite(suite);
|
|
2701
|
-
const signerDid = requiredString2(
|
|
2702
|
-
const value = requiredString2(
|
|
2701
|
+
const signerDid = requiredString2(object4, "signerDid", "$.signature");
|
|
2702
|
+
const value = requiredString2(object4, "value", "$.signature");
|
|
2703
2703
|
decodeSignatureValue(value, suite);
|
|
2704
2704
|
return { suite, signerDid, value };
|
|
2705
2705
|
}
|
|
2706
2706
|
function validatePolicyResource(input, path) {
|
|
2707
|
-
const
|
|
2708
|
-
assertExactKeys2(
|
|
2709
|
-
requiredString2(
|
|
2710
|
-
requiredString2(
|
|
2711
|
-
const ceiling = requiredArray2(
|
|
2707
|
+
const object4 = expectJsonObject(input, path);
|
|
2708
|
+
assertExactKeys2(object4, ["resourceType", "resourceId", "permissionsCeiling"], path);
|
|
2709
|
+
requiredString2(object4, "resourceType", path);
|
|
2710
|
+
requiredString2(object4, "resourceId", path);
|
|
2711
|
+
const ceiling = requiredArray2(object4, "permissionsCeiling", path, 1);
|
|
2712
2712
|
for (let index = 0; index < ceiling.length; index++) {
|
|
2713
2713
|
validatePolicyCapability(ceiling[index], `${path}.permissionsCeiling[${index}]`);
|
|
2714
2714
|
}
|
|
@@ -2724,10 +2724,10 @@ function validatePolicyPermissionsCeilingForSigning(input) {
|
|
|
2724
2724
|
}
|
|
2725
2725
|
}
|
|
2726
2726
|
function validatePolicyCapability(input, path) {
|
|
2727
|
-
const
|
|
2727
|
+
const object4 = expectJsonObject(input, path);
|
|
2728
2728
|
try {
|
|
2729
|
-
const canonical = canonicalizePolicyCapability(
|
|
2730
|
-
if (jcsCanonicalize(
|
|
2729
|
+
const canonical = canonicalizePolicyCapability(object4);
|
|
2730
|
+
if (jcsCanonicalize(object4) !== jcsCanonicalize(canonical)) {
|
|
2731
2731
|
throw new SignedObjectSchemaError(`${path} must be canonical PolicyCapability JSON`);
|
|
2732
2732
|
}
|
|
2733
2733
|
} catch (error) {
|
|
@@ -2740,10 +2740,10 @@ function validatePolicyCapability(input, path) {
|
|
|
2740
2740
|
}
|
|
2741
2741
|
}
|
|
2742
2742
|
function validatePolicyCapabilityForSigning(input, path) {
|
|
2743
|
-
const
|
|
2743
|
+
const object4 = expectJsonObject(input, path);
|
|
2744
2744
|
try {
|
|
2745
|
-
const canonical = normalizePolicyCapability(
|
|
2746
|
-
if (jcsCanonicalize(
|
|
2745
|
+
const canonical = normalizePolicyCapability(object4);
|
|
2746
|
+
if (jcsCanonicalize(object4) !== jcsCanonicalize(canonical)) {
|
|
2747
2747
|
throw new SignedObjectSchemaError(`${path} must be strict canonical PolicyCapability JSON`);
|
|
2748
2748
|
}
|
|
2749
2749
|
} catch (error) {
|
|
@@ -2756,43 +2756,43 @@ function validatePolicyCapabilityForSigning(input, path) {
|
|
|
2756
2756
|
}
|
|
2757
2757
|
}
|
|
2758
2758
|
function validateExpression(input, path) {
|
|
2759
|
-
const
|
|
2760
|
-
const keys = Object.keys(
|
|
2759
|
+
const object4 = expectJsonObject(input, path);
|
|
2760
|
+
const keys = Object.keys(object4);
|
|
2761
2761
|
if (keys.length !== 1) {
|
|
2762
2762
|
throw new SignedObjectSchemaError(`${path} must have exactly one expression key`);
|
|
2763
2763
|
}
|
|
2764
2764
|
const key = keys[0];
|
|
2765
2765
|
if (key === "allOf" || key === "anyOf") {
|
|
2766
|
-
const values = requiredArray2(
|
|
2766
|
+
const values = requiredArray2(object4, key, path, 1);
|
|
2767
2767
|
for (let index = 0; index < values.length; index++) {
|
|
2768
2768
|
validateExpression(values[index], `${path}.${key}[${index}]`);
|
|
2769
2769
|
}
|
|
2770
2770
|
return;
|
|
2771
2771
|
}
|
|
2772
2772
|
if (key === "subject") {
|
|
2773
|
-
const subject = expectJsonObject(requiredValue2(
|
|
2773
|
+
const subject = expectJsonObject(requiredValue2(object4, "subject", path), `${path}.subject`);
|
|
2774
2774
|
assertExactKeys2(subject, ["did"], `${path}.subject`);
|
|
2775
2775
|
requiredString2(subject, "did", `${path}.subject`);
|
|
2776
2776
|
return;
|
|
2777
2777
|
}
|
|
2778
2778
|
if (key === "evidence") {
|
|
2779
|
-
validateEvidenceRequirement(requiredValue2(
|
|
2779
|
+
validateEvidenceRequirement(requiredValue2(object4, "evidence", path), `${path}.evidence`);
|
|
2780
2780
|
return;
|
|
2781
2781
|
}
|
|
2782
2782
|
throw new SignedObjectSchemaError(`${path} has unknown expression key ${key}`);
|
|
2783
2783
|
}
|
|
2784
2784
|
function validateEvidenceRequirement(input, path) {
|
|
2785
|
-
const
|
|
2785
|
+
const object4 = expectJsonObject(input, path);
|
|
2786
2786
|
assertExactKeys2(
|
|
2787
|
-
|
|
2787
|
+
object4,
|
|
2788
2788
|
["requirementId", "verifier", "requirements", "authority", "freshness"],
|
|
2789
2789
|
path
|
|
2790
2790
|
);
|
|
2791
|
-
requiredString2(
|
|
2792
|
-
requiredString2(
|
|
2793
|
-
requiredValue2(
|
|
2794
|
-
if (hasOwn2(
|
|
2795
|
-
const authority = expectJsonObject(requiredValue2(
|
|
2791
|
+
requiredString2(object4, "requirementId", path);
|
|
2792
|
+
requiredString2(object4, "verifier", path);
|
|
2793
|
+
requiredValue2(object4, "requirements", path);
|
|
2794
|
+
if (hasOwn2(object4, "authority")) {
|
|
2795
|
+
const authority = expectJsonObject(requiredValue2(object4, "authority", path), `${path}.authority`);
|
|
2796
2796
|
assertExactKeys2(
|
|
2797
2797
|
authority,
|
|
2798
2798
|
["profile", "acceptedIssuers", "allowOwnerAuthorizedIssuer"],
|
|
@@ -2804,35 +2804,35 @@ function validateEvidenceRequirement(input, path) {
|
|
|
2804
2804
|
}
|
|
2805
2805
|
optionalBoolean(authority, "allowOwnerAuthorizedIssuer", `${path}.authority`);
|
|
2806
2806
|
}
|
|
2807
|
-
if (hasOwn2(
|
|
2808
|
-
const freshness = expectJsonObject(requiredValue2(
|
|
2807
|
+
if (hasOwn2(object4, "freshness")) {
|
|
2808
|
+
const freshness = expectJsonObject(requiredValue2(object4, "freshness", path), `${path}.freshness`);
|
|
2809
2809
|
assertExactKeys2(freshness, ["maxStatusAgeSeconds"], `${path}.freshness`);
|
|
2810
2810
|
requiredInteger(freshness, "maxStatusAgeSeconds", `${path}.freshness`, 0);
|
|
2811
2811
|
}
|
|
2812
2812
|
}
|
|
2813
2813
|
function validateGrant(input, path) {
|
|
2814
|
-
const
|
|
2815
|
-
assertExactKeys2(
|
|
2816
|
-
expectConst(requiredString2(
|
|
2817
|
-
requiredInteger(
|
|
2818
|
-
expectOneOf(requiredString2(
|
|
2814
|
+
const object4 = expectJsonObject(input, path);
|
|
2815
|
+
assertExactKeys2(object4, ["output", "maxTtlSeconds", "delegationMode", "revocation"], path);
|
|
2816
|
+
expectConst(requiredString2(object4, "output", path), "portable-delegation", `${path}.output`);
|
|
2817
|
+
requiredInteger(object4, "maxTtlSeconds", path, 1);
|
|
2818
|
+
expectOneOf(requiredString2(object4, "delegationMode", path), [
|
|
2819
2819
|
"terminal",
|
|
2820
2820
|
"attenuable"
|
|
2821
2821
|
], `${path}.delegationMode`);
|
|
2822
|
-
expectOneOf(requiredString2(
|
|
2822
|
+
expectOneOf(requiredString2(object4, "revocation", path), [
|
|
2823
2823
|
"refresh_only",
|
|
2824
2824
|
"active_cutoff"
|
|
2825
2825
|
], `${path}.revocation`);
|
|
2826
2826
|
}
|
|
2827
2827
|
function validateDisclosure(input, path) {
|
|
2828
|
-
const
|
|
2829
|
-
assertExactKeys2(
|
|
2830
|
-
expectOneOf(requiredString2(
|
|
2828
|
+
const object4 = expectJsonObject(input, path);
|
|
2829
|
+
assertExactKeys2(object4, ["denial"], path);
|
|
2830
|
+
expectOneOf(requiredString2(object4, "denial", path), ["none", "code", "debug"], `${path}.denial`);
|
|
2831
2831
|
}
|
|
2832
2832
|
function validateAudit(input, path) {
|
|
2833
|
-
const
|
|
2834
|
-
assertExactKeys2(
|
|
2835
|
-
expectOneOf(requiredString2(
|
|
2833
|
+
const object4 = expectJsonObject(input, path);
|
|
2834
|
+
assertExactKeys2(object4, ["issuance"], path);
|
|
2835
|
+
expectOneOf(requiredString2(object4, "issuance", path), ["off", "security", "full"], `${path}.issuance`);
|
|
2836
2836
|
}
|
|
2837
2837
|
function materialForUnsigned(unsigned, descriptor) {
|
|
2838
2838
|
const jcs = jcsCanonicalize(unsigned);
|
|
@@ -2981,9 +2981,9 @@ function encodeSignatureValue(value, suite) {
|
|
|
2981
2981
|
decodeSignatureValue(encoded, suite);
|
|
2982
2982
|
return encoded;
|
|
2983
2983
|
}
|
|
2984
|
-
function stripOwnIdAndSignature(
|
|
2984
|
+
function stripOwnIdAndSignature(object4, descriptor) {
|
|
2985
2985
|
const output = /* @__PURE__ */ Object.create(null);
|
|
2986
|
-
for (const [key, value] of Object.entries(
|
|
2986
|
+
for (const [key, value] of Object.entries(object4)) {
|
|
2987
2987
|
if (key === descriptor.idField || key === "signature") {
|
|
2988
2988
|
continue;
|
|
2989
2989
|
}
|
|
@@ -2992,8 +2992,8 @@ function stripOwnIdAndSignature(object3, descriptor) {
|
|
|
2992
2992
|
return output;
|
|
2993
2993
|
}
|
|
2994
2994
|
function descriptorForUnsigned(input) {
|
|
2995
|
-
const
|
|
2996
|
-
return descriptorForSchema(requiredString2(
|
|
2995
|
+
const object4 = expectJsonObject(normalizeJson(input), "$");
|
|
2996
|
+
return descriptorForSchema(requiredString2(object4, "schema", "$"));
|
|
2997
2997
|
}
|
|
2998
2998
|
function descriptorForSchema(schema) {
|
|
2999
2999
|
if (schema === POLICY_SCHEMA) return DESCRIPTORS.Policy;
|
|
@@ -3007,28 +3007,28 @@ function expectJsonObject(input, path) {
|
|
|
3007
3007
|
}
|
|
3008
3008
|
return input;
|
|
3009
3009
|
}
|
|
3010
|
-
function assertExactKeys2(
|
|
3010
|
+
function assertExactKeys2(object4, allowed, path) {
|
|
3011
3011
|
const allowedSet = new Set(allowed);
|
|
3012
|
-
for (const key of Object.keys(
|
|
3012
|
+
for (const key of Object.keys(object4)) {
|
|
3013
3013
|
if (!allowedSet.has(key)) {
|
|
3014
3014
|
throw new SignedObjectSchemaError(`${path} has unknown field ${key}`);
|
|
3015
3015
|
}
|
|
3016
3016
|
}
|
|
3017
3017
|
}
|
|
3018
|
-
function requiredValue2(
|
|
3019
|
-
if (!hasOwn2(
|
|
3018
|
+
function requiredValue2(object4, key, path) {
|
|
3019
|
+
if (!hasOwn2(object4, key)) {
|
|
3020
3020
|
throw new SignedObjectSchemaError(`${path}.${key} is required`);
|
|
3021
3021
|
}
|
|
3022
|
-
return
|
|
3022
|
+
return object4[key];
|
|
3023
3023
|
}
|
|
3024
|
-
function requiredString2(
|
|
3025
|
-
return requireStringType(requiredValue2(
|
|
3024
|
+
function requiredString2(object4, key, path) {
|
|
3025
|
+
return requireStringType(requiredValue2(object4, key, path), `${path}.${key}`);
|
|
3026
3026
|
}
|
|
3027
|
-
function optionalString(
|
|
3028
|
-
if (!hasOwn2(
|
|
3027
|
+
function optionalString(object4, key, path) {
|
|
3028
|
+
if (!hasOwn2(object4, key)) {
|
|
3029
3029
|
return;
|
|
3030
3030
|
}
|
|
3031
|
-
requireStringType(requiredValue2(
|
|
3031
|
+
requireStringType(requiredValue2(object4, key, path), `${path}.${key}`);
|
|
3032
3032
|
}
|
|
3033
3033
|
function requireStringType(value, path) {
|
|
3034
3034
|
if (typeof value !== "string" || value.length === 0) {
|
|
@@ -3036,16 +3036,16 @@ function requireStringType(value, path) {
|
|
|
3036
3036
|
}
|
|
3037
3037
|
return value;
|
|
3038
3038
|
}
|
|
3039
|
-
function optionalBoolean(
|
|
3040
|
-
if (!hasOwn2(
|
|
3039
|
+
function optionalBoolean(object4, key, path) {
|
|
3040
|
+
if (!hasOwn2(object4, key)) {
|
|
3041
3041
|
return;
|
|
3042
3042
|
}
|
|
3043
|
-
if (typeof requiredValue2(
|
|
3043
|
+
if (typeof requiredValue2(object4, key, path) !== "boolean") {
|
|
3044
3044
|
throw new SignedObjectSchemaError(`${path}.${key} must be a boolean`);
|
|
3045
3045
|
}
|
|
3046
3046
|
}
|
|
3047
|
-
function requiredInteger(
|
|
3048
|
-
const value = requiredValue2(
|
|
3047
|
+
function requiredInteger(object4, key, path, minimum) {
|
|
3048
|
+
const value = requiredValue2(object4, key, path);
|
|
3049
3049
|
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < minimum) {
|
|
3050
3050
|
throw new SignedObjectSchemaError(
|
|
3051
3051
|
`${path}.${key} must be an integer >= ${minimum}`
|
|
@@ -3053,8 +3053,8 @@ function requiredInteger(object3, key, path, minimum) {
|
|
|
3053
3053
|
}
|
|
3054
3054
|
return value;
|
|
3055
3055
|
}
|
|
3056
|
-
function requiredArray2(
|
|
3057
|
-
const value = requiredValue2(
|
|
3056
|
+
function requiredArray2(object4, key, path, minimum) {
|
|
3057
|
+
const value = requiredValue2(object4, key, path);
|
|
3058
3058
|
if (!Array.isArray(value) || value.length < minimum) {
|
|
3059
3059
|
throw new SignedObjectSchemaError(
|
|
3060
3060
|
`${path}.${key} must be an array with at least ${minimum} item(s)`
|
|
@@ -3062,22 +3062,22 @@ function requiredArray2(object3, key, path, minimum) {
|
|
|
3062
3062
|
}
|
|
3063
3063
|
return value;
|
|
3064
3064
|
}
|
|
3065
|
-
function requiredStringArray(
|
|
3066
|
-
const values = requiredArray2(
|
|
3065
|
+
function requiredStringArray(object4, key, path, check) {
|
|
3066
|
+
const values = requiredArray2(object4, key, path, 0);
|
|
3067
3067
|
for (let index = 0; index < values.length; index++) {
|
|
3068
3068
|
const itemPath = `${path}.${key}[${index}]`;
|
|
3069
3069
|
const value = requireStringType(values[index], itemPath);
|
|
3070
3070
|
check?.(value, itemPath);
|
|
3071
3071
|
}
|
|
3072
3072
|
}
|
|
3073
|
-
function requiredDateString(
|
|
3074
|
-
assertRfc3339(requiredString2(
|
|
3073
|
+
function requiredDateString(object4, key, path) {
|
|
3074
|
+
assertRfc3339(requiredString2(object4, key, path), `${path}.${key}`);
|
|
3075
3075
|
}
|
|
3076
|
-
function optionalDateString(
|
|
3077
|
-
if (!hasOwn2(
|
|
3076
|
+
function optionalDateString(object4, key, path) {
|
|
3077
|
+
if (!hasOwn2(object4, key)) {
|
|
3078
3078
|
return;
|
|
3079
3079
|
}
|
|
3080
|
-
assertRfc3339(requiredString2(
|
|
3080
|
+
assertRfc3339(requiredString2(object4, key, path), `${path}.${key}`);
|
|
3081
3081
|
}
|
|
3082
3082
|
function assertRfc3339(value, path) {
|
|
3083
3083
|
const match = value.match(
|
|
@@ -3109,8 +3109,8 @@ function expectOneOf(actual, allowed, path) {
|
|
|
3109
3109
|
}
|
|
3110
3110
|
throw new SignedObjectSchemaError(`${path} has unsupported value ${actual}`);
|
|
3111
3111
|
}
|
|
3112
|
-
function hasOwn2(
|
|
3113
|
-
return objectHasOwn3(
|
|
3112
|
+
function hasOwn2(object4, key) {
|
|
3113
|
+
return objectHasOwn3(object4, key);
|
|
3114
3114
|
}
|
|
3115
3115
|
function assertSupportedSignatureSuite(suite) {
|
|
3116
3116
|
if (suite !== ED25519_JCS_SIGNATURE_SUITE && suite !== EIP191_JCS_SIGNATURE_SUITE) {
|
|
@@ -3337,9 +3337,9 @@ function expectObject2(input, path, code3) {
|
|
|
3337
3337
|
);
|
|
3338
3338
|
}
|
|
3339
3339
|
}
|
|
3340
|
-
function assertExactKeys3(
|
|
3340
|
+
function assertExactKeys3(object4, allowed, path) {
|
|
3341
3341
|
const allowedSet = new Set(allowed);
|
|
3342
|
-
for (const key of Object.keys(
|
|
3342
|
+
for (const key of Object.keys(object4)) {
|
|
3343
3343
|
if (!allowedSet.has(key)) {
|
|
3344
3344
|
throw new PolicyAuthoringError(
|
|
3345
3345
|
"policy-authoring-unknown-key",
|
|
@@ -3348,17 +3348,17 @@ function assertExactKeys3(object3, allowed, path) {
|
|
|
3348
3348
|
}
|
|
3349
3349
|
}
|
|
3350
3350
|
}
|
|
3351
|
-
function requiredValue3(
|
|
3352
|
-
if (!hasOwn3(
|
|
3351
|
+
function requiredValue3(object4, key, path) {
|
|
3352
|
+
if (!hasOwn3(object4, key)) {
|
|
3353
3353
|
throw new PolicyAuthoringError(
|
|
3354
3354
|
"policy-authoring-malformed",
|
|
3355
3355
|
`${path}.${key} is required`
|
|
3356
3356
|
);
|
|
3357
3357
|
}
|
|
3358
|
-
return
|
|
3358
|
+
return object4[key];
|
|
3359
3359
|
}
|
|
3360
|
-
function requiredString3(
|
|
3361
|
-
const value = requiredValue3(
|
|
3360
|
+
function requiredString3(object4, key, path) {
|
|
3361
|
+
const value = requiredValue3(object4, key, path);
|
|
3362
3362
|
if (typeof value !== "string" || value.length === 0) {
|
|
3363
3363
|
throw new PolicyAuthoringError(
|
|
3364
3364
|
"policy-authoring-malformed",
|
|
@@ -3367,11 +3367,11 @@ function requiredString3(object3, key, path) {
|
|
|
3367
3367
|
}
|
|
3368
3368
|
return value;
|
|
3369
3369
|
}
|
|
3370
|
-
function fieldString(
|
|
3371
|
-
if (!hasOwn3(
|
|
3370
|
+
function fieldString(object4, key, path, code3) {
|
|
3371
|
+
if (!hasOwn3(object4, key)) {
|
|
3372
3372
|
throw new PolicyAuthoringError(code3, `${path}.${key} is required`);
|
|
3373
3373
|
}
|
|
3374
|
-
const value =
|
|
3374
|
+
const value = object4[key];
|
|
3375
3375
|
if (typeof value !== "string" || value.length === 0) {
|
|
3376
3376
|
throw new PolicyAuthoringError(
|
|
3377
3377
|
code3,
|
|
@@ -3409,8 +3409,8 @@ function parseStrictRfc3339(value, path) {
|
|
|
3409
3409
|
var objectHasOwn4 = Object.hasOwn ?? Object.prototype.hasOwnProperty.call.bind(
|
|
3410
3410
|
Object.prototype.hasOwnProperty
|
|
3411
3411
|
);
|
|
3412
|
-
function hasOwn3(
|
|
3413
|
-
return objectHasOwn4(
|
|
3412
|
+
function hasOwn3(object4, key) {
|
|
3413
|
+
return objectHasOwn4(object4, key);
|
|
3414
3414
|
}
|
|
3415
3415
|
|
|
3416
3416
|
// src/policy/unified.ts
|
|
@@ -3437,7 +3437,8 @@ var MAX_LEGACY_ENVELOPE_EXPIRES_AT = "2026-12-29T00:00:00Z";
|
|
|
3437
3437
|
var LAST_V2_READ_AT = "2027-01-05T00:00:00Z";
|
|
3438
3438
|
async function requestPolicyChallengeV3(input) {
|
|
3439
3439
|
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
3440
|
-
const
|
|
3440
|
+
const policyRuntimePath = policyRuntimeBasePath(input.policyRuntimePath);
|
|
3441
|
+
const response = await fetchFn(new URL(`${policyRuntimePath}/challenges`, input.nodeOrigin), {
|
|
3441
3442
|
method: "POST",
|
|
3442
3443
|
redirect: "error",
|
|
3443
3444
|
signal: input.signal,
|
|
@@ -3450,6 +3451,13 @@ async function requestPolicyChallengeV3(input) {
|
|
|
3450
3451
|
throw new Error("policy challenge binding is invalid");
|
|
3451
3452
|
return value;
|
|
3452
3453
|
}
|
|
3454
|
+
function policyRuntimeBasePath(value) {
|
|
3455
|
+
const path = value ?? "/policy/v3";
|
|
3456
|
+
if (!/^\/policy(?:\/[a-z0-9-]+)*$/.test(path)) {
|
|
3457
|
+
throw new Error("policy runtime path is invalid");
|
|
3458
|
+
}
|
|
3459
|
+
return path;
|
|
3460
|
+
}
|
|
3453
3461
|
function compactAttenuationForPolicyCapabilities(input) {
|
|
3454
3462
|
const attenuation = {};
|
|
3455
3463
|
for (const raw of input) {
|
|
@@ -3495,7 +3503,7 @@ function verifyPolicyRootStatusCheckpointV3(input) {
|
|
|
3495
3503
|
}
|
|
3496
3504
|
async function getPolicyRootStatusV3(input) {
|
|
3497
3505
|
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
3498
|
-
const response = await fetchFn(new URL(`/
|
|
3506
|
+
const response = await fetchFn(new URL(`/policy/v3/status/${encodeURIComponent(input.rootCid)}`, input.nodeOrigin), {
|
|
3499
3507
|
method: "GET",
|
|
3500
3508
|
redirect: "error",
|
|
3501
3509
|
headers: { accept: "application/json" }
|
|
@@ -3554,7 +3562,7 @@ async function renewPolicyRootStatusV3(input) {
|
|
|
3554
3562
|
};
|
|
3555
3563
|
const signature = await input.sign(sha2564(new TextEncoder().encode(ROOT_STATUS_RENEWAL_V1_DOMAIN + jcsCanonicalize(unsigned))));
|
|
3556
3564
|
if (signature.length !== 64) throw new Error("policy root renewal signature must be Ed25519");
|
|
3557
|
-
const response = await fetchFn(new URL("/
|
|
3565
|
+
const response = await fetchFn(new URL("/policy/v3/status", input.nodeOrigin), {
|
|
3558
3566
|
method: "POST",
|
|
3559
3567
|
redirect: "error",
|
|
3560
3568
|
headers: { accept: "application/json", "content-type": "application/json" },
|
|
@@ -3809,6 +3817,133 @@ function contentSourceDigestHex(input) {
|
|
|
3809
3817
|
)
|
|
3810
3818
|
);
|
|
3811
3819
|
}
|
|
3820
|
+
function exactObject(value, keys, label) {
|
|
3821
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
3822
|
+
throw new Error(`${label} is invalid`);
|
|
3823
|
+
}
|
|
3824
|
+
const record2 = value;
|
|
3825
|
+
if (Object.keys(record2).length !== keys.length || keys.some((key) => !Object.prototype.hasOwnProperty.call(record2, key))) {
|
|
3826
|
+
throw new Error(`${label} is invalid`);
|
|
3827
|
+
}
|
|
3828
|
+
return record2;
|
|
3829
|
+
}
|
|
3830
|
+
function didKeyEd25519PublicKey(value) {
|
|
3831
|
+
const principal = value.split("#", 1)[0];
|
|
3832
|
+
if (!principal.startsWith("did:key:")) {
|
|
3833
|
+
throw new Error("policy enforcer binding signer is invalid");
|
|
3834
|
+
}
|
|
3835
|
+
const material = base58btc.decode(principal.slice("did:key:".length));
|
|
3836
|
+
if (material.length !== 34 || material[0] !== 237 || material[1] !== 1) {
|
|
3837
|
+
throw new Error("policy enforcer binding signer is invalid");
|
|
3838
|
+
}
|
|
3839
|
+
return material.slice(2);
|
|
3840
|
+
}
|
|
3841
|
+
async function registerPolicyV3(input) {
|
|
3842
|
+
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
3843
|
+
const rootExpiresAt = new Date(input.rootExpiresAt);
|
|
3844
|
+
const canonicalRootExpiresAt = new Date(
|
|
3845
|
+
Math.floor(rootExpiresAt.getTime() / 1e3) * 1e3
|
|
3846
|
+
).toISOString().replace(/\.000Z$/, "Z");
|
|
3847
|
+
if (!Number.isFinite(rootExpiresAt.getTime()) || canonicalRootExpiresAt !== input.rootExpiresAt || rootExpiresAt.getTime() <= Date.now()) {
|
|
3848
|
+
throw new Error("policy root expiry is invalid");
|
|
3849
|
+
}
|
|
3850
|
+
const bindingResponse = await fetchFn(
|
|
3851
|
+
new URL("/policy/v3/enforcer-bindings", input.nodeOrigin),
|
|
3852
|
+
{
|
|
3853
|
+
method: "POST",
|
|
3854
|
+
redirect: "error",
|
|
3855
|
+
signal: input.signal,
|
|
3856
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
3857
|
+
body: JSON.stringify({
|
|
3858
|
+
rootExpiresAt: input.rootExpiresAt,
|
|
3859
|
+
enforcerDid: input.enforcerDid
|
|
3860
|
+
})
|
|
3861
|
+
}
|
|
3862
|
+
);
|
|
3863
|
+
if (!bindingResponse.ok) {
|
|
3864
|
+
throw new Error(`policy enforcer binding rejected (${bindingResponse.status})`);
|
|
3865
|
+
}
|
|
3866
|
+
const binding = exactObject(
|
|
3867
|
+
await bindingResponse.json(),
|
|
3868
|
+
[
|
|
3869
|
+
"schema",
|
|
3870
|
+
"enforcerDid",
|
|
3871
|
+
"nodeAudience",
|
|
3872
|
+
"attestationBindingDigestHex",
|
|
3873
|
+
"issuedAt",
|
|
3874
|
+
"expiresAt",
|
|
3875
|
+
"signature"
|
|
3876
|
+
],
|
|
3877
|
+
"policy enforcer binding"
|
|
3878
|
+
);
|
|
3879
|
+
const signature = exactObject(
|
|
3880
|
+
binding.signature,
|
|
3881
|
+
["suite", "signerDid", "value"],
|
|
3882
|
+
"policy enforcer binding signature"
|
|
3883
|
+
);
|
|
3884
|
+
const expectedBindingDigestHex = hex(
|
|
3885
|
+
sha2564(
|
|
3886
|
+
new TextEncoder().encode(
|
|
3887
|
+
jcsCanonicalize({
|
|
3888
|
+
enforcerDid: input.enforcerDid,
|
|
3889
|
+
nodeAudience: input.expectedNodeAudience
|
|
3890
|
+
})
|
|
3891
|
+
)
|
|
3892
|
+
)
|
|
3893
|
+
);
|
|
3894
|
+
if (binding.schema !== ATTESTED_ENFORCER_BINDING_V2_SCHEMA || binding.enforcerDid !== input.enforcerDid || binding.nodeAudience !== input.expectedNodeAudience || binding.attestationBindingDigestHex !== expectedBindingDigestHex || binding.expiresAt !== input.rootExpiresAt || typeof binding.issuedAt !== "string" || Date.parse(binding.issuedAt) > Date.now() || signature.suite !== "Ed25519" || signature.signerDid !== input.expectedNodeAudience || typeof signature.value !== "string") {
|
|
3895
|
+
throw new Error("policy enforcer binding is invalid");
|
|
3896
|
+
}
|
|
3897
|
+
const { signature: _signature, ...unsignedBinding } = binding;
|
|
3898
|
+
const signedBinding = sha2564(
|
|
3899
|
+
new TextEncoder().encode(
|
|
3900
|
+
`xyz.tinycloud.policy/AttestedEnforcerBinding/v2\0${jcsCanonicalize(unsignedBinding)}`
|
|
3901
|
+
)
|
|
3902
|
+
);
|
|
3903
|
+
if (!ed255193.verify(
|
|
3904
|
+
decodeBase64Url2(signature.value),
|
|
3905
|
+
signedBinding,
|
|
3906
|
+
didKeyEd25519PublicKey(input.expectedNodeAudience),
|
|
3907
|
+
{ zip215: false }
|
|
3908
|
+
)) {
|
|
3909
|
+
throw new Error("policy enforcer binding signature is invalid");
|
|
3910
|
+
}
|
|
3911
|
+
const response = await fetchFn(
|
|
3912
|
+
new URL("/policy/v3/policies", input.nodeOrigin),
|
|
3913
|
+
{
|
|
3914
|
+
method: "POST",
|
|
3915
|
+
redirect: "error",
|
|
3916
|
+
signal: input.signal,
|
|
3917
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
3918
|
+
body: JSON.stringify({
|
|
3919
|
+
policyCid: input.policyCid,
|
|
3920
|
+
policy: input.policy,
|
|
3921
|
+
policyRoot: input.policyRoot.authorization.replace(/^Bearer\s+/i, ""),
|
|
3922
|
+
enforcementRoot: input.enforcementRoot.authorization.replace(/^Bearer\s+/i, ""),
|
|
3923
|
+
contentSourceDigestHex: input.contentSourceDigestHex,
|
|
3924
|
+
nativeProjectionHashHex: input.nativeProjectionHashHex,
|
|
3925
|
+
attestedEnforcerBinding: binding
|
|
3926
|
+
})
|
|
3927
|
+
}
|
|
3928
|
+
);
|
|
3929
|
+
if (!response.ok) {
|
|
3930
|
+
throw new Error(`policy registration rejected (${response.status})`);
|
|
3931
|
+
}
|
|
3932
|
+
const receipt = exactObject(
|
|
3933
|
+
await response.json(),
|
|
3934
|
+
["policyCid", "policyRootCid", "enforcementRootCid"],
|
|
3935
|
+
"policy registration response"
|
|
3936
|
+
);
|
|
3937
|
+
if (receipt.policyCid !== input.policyCid || receipt.policyRootCid !== input.policyRoot.cid || receipt.enforcementRootCid !== input.enforcementRoot.cid) {
|
|
3938
|
+
throw new Error("policy registration response binding is invalid");
|
|
3939
|
+
}
|
|
3940
|
+
return {
|
|
3941
|
+
policyCid: input.policyCid,
|
|
3942
|
+
policyRootCid: input.policyRoot.cid,
|
|
3943
|
+
enforcementRootCid: input.enforcementRoot.cid,
|
|
3944
|
+
attestedEnforcerBinding: binding
|
|
3945
|
+
};
|
|
3946
|
+
}
|
|
3812
3947
|
function policyDigestHex(policy) {
|
|
3813
3948
|
const canonicalPolicy = {
|
|
3814
3949
|
...policy,
|
|
@@ -4425,6 +4560,7 @@ async function admitPolicyCredentialV3(input) {
|
|
|
4425
4560
|
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
4426
4561
|
const challenge = await requestPolicyChallengeV3({
|
|
4427
4562
|
nodeOrigin,
|
|
4563
|
+
policyRuntimePath: input.policyRuntimePath,
|
|
4428
4564
|
policyCid: input.policyCid,
|
|
4429
4565
|
recipientDid: input.credential.holderDid,
|
|
4430
4566
|
requestedCapabilities: input.requestedCapabilities,
|
|
@@ -4437,7 +4573,7 @@ async function admitPolicyCredentialV3(input) {
|
|
|
4437
4573
|
challenge
|
|
4438
4574
|
});
|
|
4439
4575
|
const response = await fetchFn(
|
|
4440
|
-
new URL(
|
|
4576
|
+
new URL(`${policyRuntimeBasePath2(input.policyRuntimePath)}/delegations`, nodeOrigin),
|
|
4441
4577
|
{
|
|
4442
4578
|
method: "POST",
|
|
4443
4579
|
redirect: "error",
|
|
@@ -4482,6 +4618,7 @@ async function admitPolicyCredentialV4(input) {
|
|
|
4482
4618
|
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
4483
4619
|
const challenge = await requestPolicyChallengeV3({
|
|
4484
4620
|
nodeOrigin,
|
|
4621
|
+
policyRuntimePath: input.policyRuntimePath,
|
|
4485
4622
|
policyCid: input.policyCid,
|
|
4486
4623
|
recipientDid: input.credential.holderDid,
|
|
4487
4624
|
requestedCapabilities: input.requestedCapabilities,
|
|
@@ -4493,7 +4630,7 @@ async function admitPolicyCredentialV4(input) {
|
|
|
4493
4630
|
policy,
|
|
4494
4631
|
challenge
|
|
4495
4632
|
});
|
|
4496
|
-
const response = await fetchFn(new URL(
|
|
4633
|
+
const response = await fetchFn(new URL(`${policyRuntimeBasePath2(input.policyRuntimePath)}/delegations`, nodeOrigin), {
|
|
4497
4634
|
method: "POST",
|
|
4498
4635
|
redirect: "error",
|
|
4499
4636
|
signal: input.signal,
|
|
@@ -4520,8 +4657,22 @@ async function admitPolicyCredentialV4(input) {
|
|
|
4520
4657
|
enforcerDid: input.expectedEnforcerDid
|
|
4521
4658
|
});
|
|
4522
4659
|
if (session.cid !== value.sessionCid || session.aud !== input.credential.holderDid || session.fact.policyCid !== input.policyCid || session.fact.recipientDid !== input.credential.holderDid || session.fact.policyDelegationCid !== input.policyRootCid || session.fact.enforcementDelegationCid !== input.enforcementRootCid || jcsCanonicalize(session.att) !== jcsCanonicalize(expectedAttenuation)) throw new Error("policy delegation signed binding is invalid");
|
|
4660
|
+
const importResponse = await fetchFn(new URL("/delegate", nodeOrigin), {
|
|
4661
|
+
method: "POST",
|
|
4662
|
+
redirect: "error",
|
|
4663
|
+
signal: input.signal,
|
|
4664
|
+
headers: { Authorization: session.authorization }
|
|
4665
|
+
});
|
|
4666
|
+
if (!importResponse.ok) throw new Error(`delegation import rejected (${importResponse.status})`);
|
|
4523
4667
|
input.signal?.throwIfAborted();
|
|
4524
|
-
return Object.freeze({ challenge, presentation, session });
|
|
4668
|
+
return Object.freeze({ challenge, presentation, session, delegationImported: true });
|
|
4669
|
+
}
|
|
4670
|
+
function policyRuntimeBasePath2(value) {
|
|
4671
|
+
const path = value ?? "/policy/v3";
|
|
4672
|
+
if (!/^\/policy(?:\/[a-z0-9-]+)*$/.test(path)) {
|
|
4673
|
+
throw new Error("policy runtime path is invalid");
|
|
4674
|
+
}
|
|
4675
|
+
return path;
|
|
4525
4676
|
}
|
|
4526
4677
|
|
|
4527
4678
|
// src/requester/index.ts
|
|
@@ -7929,13 +8080,13 @@ function canonicalizeRecapCaveats(caveats) {
|
|
|
7929
8080
|
}
|
|
7930
8081
|
if (Array.isArray(value)) return `[${value.map(canonicalize).join(",")}]`;
|
|
7931
8082
|
if (typeof value === "object") {
|
|
7932
|
-
const
|
|
7933
|
-
const prototype = Object.getPrototypeOf(
|
|
8083
|
+
const object4 = value;
|
|
8084
|
+
const prototype = Object.getPrototypeOf(object4);
|
|
7934
8085
|
if (prototype !== Object.prototype && prototype !== null) {
|
|
7935
8086
|
throw new Error("ReCap caveats must contain only JSON values.");
|
|
7936
8087
|
}
|
|
7937
|
-
return `{${Object.keys(
|
|
7938
|
-
(key) => `${JSON.stringify(key)}:${canonicalize(
|
|
8088
|
+
return `{${Object.keys(object4).sort().map(
|
|
8089
|
+
(key) => `${JSON.stringify(key)}:${canonicalize(object4[key])}`
|
|
7939
8090
|
).join(",")}}`;
|
|
7940
8091
|
}
|
|
7941
8092
|
throw new Error("ReCap caveats must contain only JSON values.");
|
|
@@ -8070,8 +8221,8 @@ function canonicalJson(value) {
|
|
|
8070
8221
|
}
|
|
8071
8222
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
8072
8223
|
if (typeof value === "object") {
|
|
8073
|
-
const
|
|
8074
|
-
return `{${Object.keys(
|
|
8224
|
+
const object4 = value;
|
|
8225
|
+
return `{${Object.keys(object4).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(object4[key])}`).join(",")}}`;
|
|
8075
8226
|
}
|
|
8076
8227
|
throw new ShareEnvelopeError("invalid-envelope", "unsupported JSON value");
|
|
8077
8228
|
}
|
|
@@ -9253,8 +9404,8 @@ function canonicalJsonForProof(value) {
|
|
|
9253
9404
|
}
|
|
9254
9405
|
if (Array.isArray(value)) return `[${value.map(canonicalJsonForProof).join(",")}]`;
|
|
9255
9406
|
if (typeof value === "object") {
|
|
9256
|
-
const
|
|
9257
|
-
return `{${Object.keys(
|
|
9407
|
+
const object4 = value;
|
|
9408
|
+
return `{${Object.keys(object4).sort().map((key) => `${JSON.stringify(key)}:${canonicalJsonForProof(object4[key])}`).join(",")}}`;
|
|
9258
9409
|
}
|
|
9259
9410
|
throw new ShareAccessError("SHARE_SESSION_INVALID");
|
|
9260
9411
|
}
|
|
@@ -9963,12 +10114,12 @@ var ShareRecipientClient = class {
|
|
|
9963
10114
|
this.assertDetachedProof(request.proof);
|
|
9964
10115
|
}
|
|
9965
10116
|
parseSessionCapability(value) {
|
|
9966
|
-
const
|
|
9967
|
-
if (typeof
|
|
9968
|
-
if (!Array.isArray(
|
|
9969
|
-
const resource = this.requireObject(
|
|
10117
|
+
const object4 = this.requireObject(value, "session capability");
|
|
10118
|
+
if (typeof object4.spaceId !== "string") throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability space is invalid");
|
|
10119
|
+
if (!Array.isArray(object4.actions) || object4.actions.some((action) => !["read", "list", "edit"].includes(action))) throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability actions are invalid");
|
|
10120
|
+
const resource = this.requireObject(object4.resource, "session capability resource");
|
|
9970
10121
|
if (resource.kind !== "exact" && resource.kind !== "prefix" || typeof resource.path !== "string") throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability resource is invalid");
|
|
9971
|
-
return { spaceId:
|
|
10122
|
+
return { spaceId: object4.spaceId, actions: [...new Set(object4.actions)], resource: { kind: resource.kind, path: resource.path } };
|
|
9972
10123
|
}
|
|
9973
10124
|
assertProvidedPolicySession(session, envelope) {
|
|
9974
10125
|
const sessionExpiry = dateValue(session.expiresAt);
|
|
@@ -11709,6 +11860,68 @@ function shareDeliveryTrustedKid(publicKey) {
|
|
|
11709
11860
|
return `${did}#${did.slice("did:key:".length)}`;
|
|
11710
11861
|
}
|
|
11711
11862
|
|
|
11863
|
+
// src/delegations/share-delivery-v3.ts
|
|
11864
|
+
import { ed25519 as ed2551910 } from "@noble/curves/ed25519";
|
|
11865
|
+
import { sha256 as sha25611 } from "@noble/hashes/sha256";
|
|
11866
|
+
var CREDENTIAL_INVITATION_REQUEST_DOMAIN = "xyz.tinycloud.credentials/invitation-request/v1\0";
|
|
11867
|
+
var DELIVERY_ADMISSION_DOMAIN = "xyz.tinycloud.policy/delivery-admission/v0\0";
|
|
11868
|
+
var REQUEST_KEYS = ["schema", "policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "audience", "issuedAt", "expiresAt", "nonce"];
|
|
11869
|
+
var ADMISSION_KEYS = ["schema", "policyId", "ownerDid", "recipient", "resource", "actions", "credentialType", "returnLink", "envelopeRef", "senderKeyDid", "audience", "issuedAt", "expiresAt", "nonce", "signature"];
|
|
11870
|
+
function exactObject2(value, keys, label) {
|
|
11871
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
11872
|
+
const record2 = value;
|
|
11873
|
+
if (Object.keys(record2).length !== keys.length || keys.some((key) => !Object.prototype.hasOwnProperty.call(record2, key))) throw new Error(`${label} has unknown or missing fields`);
|
|
11874
|
+
return record2;
|
|
11875
|
+
}
|
|
11876
|
+
function decodeBase64Url3(value) {
|
|
11877
|
+
if (typeof value !== "string" || !/^[A-Za-z0-9_-]+$/.test(value)) throw new Error("share delivery value is not canonical base64url");
|
|
11878
|
+
if (typeof atob === "function") {
|
|
11879
|
+
const padded = value.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - value.length % 4) % 4);
|
|
11880
|
+
return Uint8Array.from(atob(padded), (character) => character.charCodeAt(0));
|
|
11881
|
+
}
|
|
11882
|
+
if (typeof Buffer !== "undefined") return new Uint8Array(Buffer.from(value, "base64url"));
|
|
11883
|
+
throw new Error("base64url decoding is unavailable");
|
|
11884
|
+
}
|
|
11885
|
+
function object3(value, label) {
|
|
11886
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
11887
|
+
return value;
|
|
11888
|
+
}
|
|
11889
|
+
function didKeyBytes2(did) {
|
|
11890
|
+
if (!did.startsWith("did:key:z") || /[#/?]/.test(did.slice("did:key:".length))) throw new Error("v3 delivery admission signer is invalid");
|
|
11891
|
+
const decoded = base58btc.decode(did.slice("did:key:".length));
|
|
11892
|
+
if (decoded.length !== 34 || decoded[0] !== 237 || decoded[1] !== 1) throw new Error("v3 delivery admission signer is invalid");
|
|
11893
|
+
return decoded.slice(2);
|
|
11894
|
+
}
|
|
11895
|
+
function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
11896
|
+
let parsed;
|
|
11897
|
+
try {
|
|
11898
|
+
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes2));
|
|
11899
|
+
} catch {
|
|
11900
|
+
throw new Error("v3 share delivery response is not valid UTF-8 JSON");
|
|
11901
|
+
}
|
|
11902
|
+
const root = exactObject2(parsed, ["request", "admission"], "v3 share delivery response");
|
|
11903
|
+
const request = exactObject2(root.request, REQUEST_KEYS, "credential invitation request");
|
|
11904
|
+
const admission = exactObject2(root.admission, ADMISSION_KEYS, "delivery admission");
|
|
11905
|
+
const signature = exactObject2(admission.signature, ["suite", "signerDid", "value"], "delivery admission signature");
|
|
11906
|
+
const envelope = object3(expected.request.envelope, "v3 share envelope");
|
|
11907
|
+
const policy = object3(envelope.policy, "v3 share policy");
|
|
11908
|
+
const requirement = object3(policy.credentialRequirement, "v3 credential requirement");
|
|
11909
|
+
const credentialType = object3(requirement.credentialType, "v3 credential type");
|
|
11910
|
+
const contentSource = object3(envelope.contentSource, "v3 content source");
|
|
11911
|
+
const envelopeSignature = object3(envelope.signature, "v3 envelope signature");
|
|
11912
|
+
const target = object3(envelope.target, "v3 target");
|
|
11913
|
+
const fields = ["policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "audience", "issuedAt", "expiresAt", "nonce"];
|
|
11914
|
+
if (request.schema !== "xyz.tinycloud.credentials/invitation-request/v1" || admission.schema !== "xyz.tinycloud.policy/delivery-admission/v0" || fields.some((field) => request[field] !== admission[field]) || request.policyId !== envelope.policyCid || request.recipient !== expected.request.recipientEmail || request.resource !== contentSource.kvResource || request.credentialType !== credentialType.id || request.credentialType !== "opencredentials.email/v1" || request.returnLink !== expected.request.shareUrl || request.envelopeRef !== expected.request.shareCid || request.audience !== expected.credentialsAudience || request.expiresAt !== expected.request.expiresAt || request.nonce !== expected.request.jti || admission.ownerDid !== envelopeSignature.signerDid || admission.senderKeyDid !== expected.senderKeyDid || canonicalizeSignedObjectUnsigned(admission.actions) !== canonicalizeSignedObjectUnsigned(["tinycloud.kv/get"]) || signature.suite !== "eddsa-ed25519-sha256-jcs-v1" || signature.signerDid !== target.nodeAudience) throw new Error("v3 share delivery authorization is not bound to the submitted request");
|
|
11915
|
+
const issuedAt = Date.parse(String(request.issuedAt));
|
|
11916
|
+
const expiresAt = Date.parse(String(request.expiresAt));
|
|
11917
|
+
if (!Number.isFinite(issuedAt) || !Number.isFinite(expiresAt) || expiresAt <= issuedAt || expiresAt - issuedAt > 15 * 6e4) throw new Error("v3 share delivery authorization time is invalid");
|
|
11918
|
+
const admissionSignature = decodeBase64Url3(signature.value);
|
|
11919
|
+
const { signature: _signature, ...unsignedAdmission } = admission;
|
|
11920
|
+
const digest4 = sha25611(new TextEncoder().encode(`${DELIVERY_ADMISSION_DOMAIN}${canonicalizeSignedObjectUnsigned(unsignedAdmission)}`));
|
|
11921
|
+
if (admissionSignature.length !== 64 || !ed2551910.verify(admissionSignature, digest4, didKeyBytes2(String(signature.signerDid)))) throw new Error("v3 share delivery admission signature is invalid");
|
|
11922
|
+
return { request, admission };
|
|
11923
|
+
}
|
|
11924
|
+
|
|
11712
11925
|
// src/delegations/sender-share-store.ts
|
|
11713
11926
|
var MemorySenderShareRecordStorage = class {
|
|
11714
11927
|
constructor() {
|
|
@@ -14469,8 +14682,8 @@ function stableJson(value) {
|
|
|
14469
14682
|
if (Array.isArray(value)) {
|
|
14470
14683
|
return `[${value.map(stableJson).join(",")}]`;
|
|
14471
14684
|
}
|
|
14472
|
-
const
|
|
14473
|
-
return `{${Object.keys(
|
|
14685
|
+
const object4 = value;
|
|
14686
|
+
return `{${Object.keys(object4).sort().map((key) => `${JSON.stringify(key)}:${stableJson(object4[key])}`).join(",")}}`;
|
|
14474
14687
|
}
|
|
14475
14688
|
function indexedDelegationFromRow(row) {
|
|
14476
14689
|
const [
|
|
@@ -17475,7 +17688,7 @@ function portForProtocol(protocol) {
|
|
|
17475
17688
|
}
|
|
17476
17689
|
|
|
17477
17690
|
// src/location.ts
|
|
17478
|
-
import { ed25519 as
|
|
17691
|
+
import { ed25519 as ed2551911 } from "@noble/curves/ed25519";
|
|
17479
17692
|
import { verifyMessage as verifyMessage2 } from "viem";
|
|
17480
17693
|
var DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL = "https://registry.tinycloud.xyz";
|
|
17481
17694
|
var DEFAULT_TINYCLOUD_FALLBACK_HOST = "https://node.tinycloud.xyz";
|
|
@@ -18041,13 +18254,13 @@ async function verifyPkhSignature(did, payload, signature) {
|
|
|
18041
18254
|
}
|
|
18042
18255
|
function verifyDidKeySignature(did, payload, signature) {
|
|
18043
18256
|
const publicKey = ed25519PublicKeyFromDidKey2(did);
|
|
18044
|
-
const signatureBytes =
|
|
18257
|
+
const signatureBytes = decodeBase64Url4(signature);
|
|
18045
18258
|
if (signatureBytes.length !== 64) {
|
|
18046
18259
|
throw new LocationRecordValidationError(
|
|
18047
18260
|
"did:key signature must be a base64url Ed25519 signature"
|
|
18048
18261
|
);
|
|
18049
18262
|
}
|
|
18050
|
-
return
|
|
18263
|
+
return ed2551911.verify(
|
|
18051
18264
|
signatureBytes,
|
|
18052
18265
|
new TextEncoder().encode(payload),
|
|
18053
18266
|
publicKey
|
|
@@ -18055,7 +18268,7 @@ function verifyDidKeySignature(did, payload, signature) {
|
|
|
18055
18268
|
}
|
|
18056
18269
|
function verifyDidKeyEd25519Signature(did, payload, signature) {
|
|
18057
18270
|
const publicKey = ed25519PublicKeyFromDidKey2(did);
|
|
18058
|
-
return
|
|
18271
|
+
return ed2551911.verify(signature, payload, publicKey);
|
|
18059
18272
|
}
|
|
18060
18273
|
function ed25519PublicKeyFromDidKey2(did) {
|
|
18061
18274
|
const identifier = did.slice("did:key:".length);
|
|
@@ -18094,7 +18307,7 @@ function base64UrlEncode3(bytes2) {
|
|
|
18094
18307
|
}
|
|
18095
18308
|
return output;
|
|
18096
18309
|
}
|
|
18097
|
-
function
|
|
18310
|
+
function decodeBase64Url4(value) {
|
|
18098
18311
|
const alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
|
18099
18312
|
const bytes2 = [];
|
|
18100
18313
|
let buffer = 0;
|
|
@@ -18141,6 +18354,7 @@ export {
|
|
|
18141
18354
|
CREDENTIAL_CONTRACT_VERSION,
|
|
18142
18355
|
CREDENTIAL_ERROR_CODES,
|
|
18143
18356
|
CREDENTIAL_FORMAT,
|
|
18357
|
+
CREDENTIAL_INVITATION_REQUEST_DOMAIN,
|
|
18144
18358
|
CREDENTIAL_ACQUISITION_PROTOCOL as CREDENTIAL_PROTOCOL,
|
|
18145
18359
|
CREDENTIAL_STEP_REGISTRY_VERSION,
|
|
18146
18360
|
CapabilityKeyRegistry,
|
|
@@ -18164,6 +18378,7 @@ export {
|
|
|
18164
18378
|
DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
|
|
18165
18379
|
DEFAULT_TINYCLOUD_FALLBACK_HOST,
|
|
18166
18380
|
DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL,
|
|
18381
|
+
DELIVERY_ADMISSION_DOMAIN,
|
|
18167
18382
|
DUCKDB,
|
|
18168
18383
|
DataVaultService,
|
|
18169
18384
|
DatabaseHandle,
|
|
@@ -18469,6 +18684,7 @@ export {
|
|
|
18469
18684
|
projectUnifiedPolicyCapabilities,
|
|
18470
18685
|
projectUnifiedPolicyCapability,
|
|
18471
18686
|
recapCaveatsEqual,
|
|
18687
|
+
registerPolicyV3,
|
|
18472
18688
|
renewPolicyRootStatusV3,
|
|
18473
18689
|
requestTinyCloudManageKeyScope,
|
|
18474
18690
|
resolveCloudLocation,
|
|
@@ -18524,6 +18740,7 @@ export {
|
|
|
18524
18740
|
validatePolicyStatusUnsigned,
|
|
18525
18741
|
validatePolicyUnsigned,
|
|
18526
18742
|
validateShareDeliveryAuthorizationBytes,
|
|
18743
|
+
validateShareDeliveryAuthorizationV3Bytes,
|
|
18527
18744
|
validateUnifiedPolicyV2,
|
|
18528
18745
|
verifyDecryptResponse,
|
|
18529
18746
|
verifyDidKeyEd25519Signature,
|