@tinycloud/sdk-core 3.0.0-beta.1 → 3.0.0-beta.11
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-C_cO1QqB.d.cts → credential-admission-CFjUChF8.d.cts} +122 -2
- package/dist/{credential-admission-cvHe-HUC.d.ts → credential-admission-DIEPgQ0o.d.ts} +122 -2
- package/dist/delegations/index.cjs +80 -133
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.d.cts +3 -3
- package/dist/delegations/index.d.ts +3 -3
- package/dist/delegations/index.js +81 -138
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +758 -306
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -8
- package/dist/index.d.ts +67 -8
- package/dist/index.js +760 -311
- package/dist/index.js.map +1 -1
- package/dist/policy/index.cjs +324 -8
- 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 +324 -8
- package/dist/policy/index.js.map +1 -1
- package/dist/{recipient-types.schema-G8NEKRoo.d.cts → recipient-types.schema-Cz5zJzED.d.cts} +50 -77
- package/dist/{recipient-types.schema-G8NEKRoo.d.ts → recipient-types.schema-Cz5zJzED.d.ts} +50 -77
- package/package.json +4 -4
package/dist/policy/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PolicyEngineRecord, S as SignedObjectSigner, a as Policy, U as UnsignedPolicyEngineRecord } from '../credential-admission-
|
|
2
|
-
export { A as ATTESTED_ENFORCER_BINDING_V2_SCHEMA, b as AdmitPolicyCredentialV3Input, B as BuildPolicyCredentialPresentationV3Input, C as CONTENT_SOURCE_V1_DOMAIN,
|
|
1
|
+
import { P as PolicyEngineRecord, S as SignedObjectSigner, a as Policy, U as UnsignedPolicyEngineRecord } from '../credential-admission-CFjUChF8.cjs';
|
|
2
|
+
export { A as ATTESTED_ENFORCER_BINDING_V2_SCHEMA, b as AdmitPolicyCredentialV3Input, c as AdmitPolicyCredentialV4Input, d as AttestedEnforcerBindingV2, B as BuildPolicyCredentialPresentationV3Input, e as BuildPolicyCredentialPresentationV4Input, C as CONTENT_SOURCE_V1_DOMAIN, f as CompactPolicyInvocationInput, g as CompactUcanAuthorizationV1, E as ED25519_JCS_SIGNATURE_SUITE, h as EIP191_JCS_SIGNATURE_SUITE, J as JsonObject, L as LAST_V2_CREATE_AT, i as LAST_V2_READ_AT, M as MAX_LEGACY_ENVELOPE_EXPIRES_AT, N as NATIVE_PROJECTION_V1_DOMAIN, j as POLICY_CAPABILITY_V1_DOMAIN, k as POLICY_CAPABILITY_V1_SCHEMA, l as POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE, m as POLICY_ENFORCEMENT_DELEGATION_V2_SCHEMA, n as POLICY_ENGINE_RECORD_SCHEMA, o as POLICY_PRESENTATION_V3_DOMAIN, p as POLICY_PRESENTATION_V3_SCHEMA, q as POLICY_PRESENTATION_V4_DOMAIN, r as POLICY_PRESENTATION_V4_SCHEMA, s as POLICY_SCHEMA, t as POLICY_SESSION_UCAN_V1_PROFILE, u as POLICY_STATUS_SCHEMA, v as POLICY_V1_DOMAIN, w as POLICY_V1_SCHEMA, x as POLICY_V2_DOMAIN, y as POLICY_V2_SCHEMA, z as PolicyChallengeV3, D as PolicyCredentialAdmissionV3, F as PolicyCredentialAdmissionV4, G as PolicyCredentialPresentationV3, H as PolicyCredentialPresentationV4, I as PolicyCredentialRequirementV1, K as PolicyRootStatusV3, O as PolicyRootV3, Q as PolicySessionUcanFactV1, R as PolicySessionUcanV1, T as PolicyStatus, V as ROOT_REVOCATION_V1_DOMAIN, W as ROOT_REVOCATION_V1_SCHEMA, X as ROOT_STATUS_CHECKPOINT_V1_SCHEMA, Y as ROOT_STATUS_RENEWAL_V1_DOMAIN, Z as ROOT_STATUS_V1_DOMAIN, _ as RegisterPolicyV3Input, $ as RegisterPolicyV3Receipt, a0 as SignCompactUcanAuthorizationInput, a1 as SignCompactUcanRootAuthorizationInput, a2 as SignatureMaterialError, a3 as SignatureSuite, a4 as SignatureVerificationError, a5 as SignedObjectCanonicalizationError, a6 as SignedObjectDigestError, a7 as SignedObjectErrorCode, a8 as SignedObjectIdError, a9 as SignedObjectKind, aa as SignedObjectMaterial, ab as SignedObjectProfileError, ac as SignedObjectSchemaError, ad as SignedObjectSignature, ae as SignedObjectVerificationResult, af as SignedPolicyObject, ag as SigningKeyBindingError, ah as UnifiedContentSource, ai as UnifiedEncryptionCapability, aj as UnifiedKvCapability, ak as UnifiedNativeCapability, al as UnifiedPolicyCapability, am as UnifiedPolicyV1, an as UnifiedPolicyV2, ao as UnifiedResourceSelector, ap as UnsignedPolicy, aq as UnsignedPolicyCredentialPresentationV4, ar as UnsignedPolicyObject, as as UnsignedPolicyStatus, at as UnsignedUnifiedPolicyV2, au as UnsupportedSignatureSuiteError, av as admitPolicyCredentialV3, aw as admitPolicyCredentialV4, ax as buildPolicyCredentialPresentationV3, ay as buildPolicyCredentialPresentationV4, az as canonicalizeSignedObjectUnsigned, aA as canonicalizeUnifiedPolicyCapability, aB as compactAttenuationContains, aC as contentSourceDigestHex, aD as createAndSignPolicy, aE as createAndSignPolicyEngineRecord, aF as createAndSignPolicyStatus, aG as createAndSignSignedObject, aH as createCompactPolicyDescendant, aI as createCompactPolicyInvocation, aJ as deriveSignedObjectMaterial, aK as getPolicyRootStatusV3, aL as issuedCredentialEnvelopeFromVerified, aM as mintPolicySessionV3, aN as normalizeUnifiedPolicyCapability, aO as parseCompactUcanAuthorization, aP as parsePolicySessionUcan, aQ as policyCidFromCanonicalBytes, aR as policyDigestHex, aS as policyIdForDigestHex, aT as policyV2DigestHex, aU as projectUnifiedPolicyCapabilities, aV as projectUnifiedPolicyCapability, aW as registerPolicyV3, aX as renewPolicyRootStatusV3, aY as requestPolicyChallengeV3, aZ as revokePolicyRootV3, a_ as signCompactUcanAuthorization, a$ as signCompactUcanRootAuthorization, b0 as signPolicyCredentialPresentationV4, b1 as signedObjectIdFor, b2 as toSignedObjectError, b3 as unifiedNativeProjectionHashHex, b4 as unifiedPolicyCapabilityContains, b5 as unifiedPolicyCapabilityDigestHex, b6 as unifiedPolicyCapabilityFromNative, b7 as validatePolicyCredentialRequirementV1, b8 as validatePolicyEngineRecordSigned, b9 as validatePolicyEngineRecordSignedShape, ba as validatePolicyEngineRecordUnsigned, bb as validatePolicySigned, bc as validatePolicySignedShape, bd as validatePolicyStatusSigned, be as validatePolicyStatusSignedShape, bf as validatePolicyStatusUnsigned, bg as validatePolicyUnsigned, bh as validateUnifiedPolicyV2, bi as verifyPolicy, bj as verifyPolicyEngineRecord, bk as verifyPolicyRootRevocationV3, bl as verifyPolicyRootStatusCheckpointV3, bm as verifyPolicyStatus, bn as verifySignedObject } from '../credential-admission-CFjUChF8.cjs';
|
|
3
3
|
import { J as JsonObject, P as PolicyCapabilityError } from '../capability-BjzXwtNw.cjs';
|
|
4
4
|
export { a as JsonValue, b as PolicyCapability, c as PolicyCapabilityErrorCode, d as canonicalizePolicyCapability, j as jcsCanonicalize, n as normalizeJson, e as normalizePolicyCapability, p as policyCapabilityContains, f as policyCapabilityDigestHex, s as serializeJcsJson } from '../capability-BjzXwtNw.cjs';
|
|
5
5
|
import 'zod';
|
package/dist/policy/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PolicyEngineRecord, S as SignedObjectSigner, a as Policy, U as UnsignedPolicyEngineRecord } from '../credential-admission-
|
|
2
|
-
export { A as ATTESTED_ENFORCER_BINDING_V2_SCHEMA, b as AdmitPolicyCredentialV3Input, B as BuildPolicyCredentialPresentationV3Input, C as CONTENT_SOURCE_V1_DOMAIN,
|
|
1
|
+
import { P as PolicyEngineRecord, S as SignedObjectSigner, a as Policy, U as UnsignedPolicyEngineRecord } from '../credential-admission-DIEPgQ0o.js';
|
|
2
|
+
export { A as ATTESTED_ENFORCER_BINDING_V2_SCHEMA, b as AdmitPolicyCredentialV3Input, c as AdmitPolicyCredentialV4Input, d as AttestedEnforcerBindingV2, B as BuildPolicyCredentialPresentationV3Input, e as BuildPolicyCredentialPresentationV4Input, C as CONTENT_SOURCE_V1_DOMAIN, f as CompactPolicyInvocationInput, g as CompactUcanAuthorizationV1, E as ED25519_JCS_SIGNATURE_SUITE, h as EIP191_JCS_SIGNATURE_SUITE, J as JsonObject, L as LAST_V2_CREATE_AT, i as LAST_V2_READ_AT, M as MAX_LEGACY_ENVELOPE_EXPIRES_AT, N as NATIVE_PROJECTION_V1_DOMAIN, j as POLICY_CAPABILITY_V1_DOMAIN, k as POLICY_CAPABILITY_V1_SCHEMA, l as POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE, m as POLICY_ENFORCEMENT_DELEGATION_V2_SCHEMA, n as POLICY_ENGINE_RECORD_SCHEMA, o as POLICY_PRESENTATION_V3_DOMAIN, p as POLICY_PRESENTATION_V3_SCHEMA, q as POLICY_PRESENTATION_V4_DOMAIN, r as POLICY_PRESENTATION_V4_SCHEMA, s as POLICY_SCHEMA, t as POLICY_SESSION_UCAN_V1_PROFILE, u as POLICY_STATUS_SCHEMA, v as POLICY_V1_DOMAIN, w as POLICY_V1_SCHEMA, x as POLICY_V2_DOMAIN, y as POLICY_V2_SCHEMA, z as PolicyChallengeV3, D as PolicyCredentialAdmissionV3, F as PolicyCredentialAdmissionV4, G as PolicyCredentialPresentationV3, H as PolicyCredentialPresentationV4, I as PolicyCredentialRequirementV1, K as PolicyRootStatusV3, O as PolicyRootV3, Q as PolicySessionUcanFactV1, R as PolicySessionUcanV1, T as PolicyStatus, V as ROOT_REVOCATION_V1_DOMAIN, W as ROOT_REVOCATION_V1_SCHEMA, X as ROOT_STATUS_CHECKPOINT_V1_SCHEMA, Y as ROOT_STATUS_RENEWAL_V1_DOMAIN, Z as ROOT_STATUS_V1_DOMAIN, _ as RegisterPolicyV3Input, $ as RegisterPolicyV3Receipt, a0 as SignCompactUcanAuthorizationInput, a1 as SignCompactUcanRootAuthorizationInput, a2 as SignatureMaterialError, a3 as SignatureSuite, a4 as SignatureVerificationError, a5 as SignedObjectCanonicalizationError, a6 as SignedObjectDigestError, a7 as SignedObjectErrorCode, a8 as SignedObjectIdError, a9 as SignedObjectKind, aa as SignedObjectMaterial, ab as SignedObjectProfileError, ac as SignedObjectSchemaError, ad as SignedObjectSignature, ae as SignedObjectVerificationResult, af as SignedPolicyObject, ag as SigningKeyBindingError, ah as UnifiedContentSource, ai as UnifiedEncryptionCapability, aj as UnifiedKvCapability, ak as UnifiedNativeCapability, al as UnifiedPolicyCapability, am as UnifiedPolicyV1, an as UnifiedPolicyV2, ao as UnifiedResourceSelector, ap as UnsignedPolicy, aq as UnsignedPolicyCredentialPresentationV4, ar as UnsignedPolicyObject, as as UnsignedPolicyStatus, at as UnsignedUnifiedPolicyV2, au as UnsupportedSignatureSuiteError, av as admitPolicyCredentialV3, aw as admitPolicyCredentialV4, ax as buildPolicyCredentialPresentationV3, ay as buildPolicyCredentialPresentationV4, az as canonicalizeSignedObjectUnsigned, aA as canonicalizeUnifiedPolicyCapability, aB as compactAttenuationContains, aC as contentSourceDigestHex, aD as createAndSignPolicy, aE as createAndSignPolicyEngineRecord, aF as createAndSignPolicyStatus, aG as createAndSignSignedObject, aH as createCompactPolicyDescendant, aI as createCompactPolicyInvocation, aJ as deriveSignedObjectMaterial, aK as getPolicyRootStatusV3, aL as issuedCredentialEnvelopeFromVerified, aM as mintPolicySessionV3, aN as normalizeUnifiedPolicyCapability, aO as parseCompactUcanAuthorization, aP as parsePolicySessionUcan, aQ as policyCidFromCanonicalBytes, aR as policyDigestHex, aS as policyIdForDigestHex, aT as policyV2DigestHex, aU as projectUnifiedPolicyCapabilities, aV as projectUnifiedPolicyCapability, aW as registerPolicyV3, aX as renewPolicyRootStatusV3, aY as requestPolicyChallengeV3, aZ as revokePolicyRootV3, a_ as signCompactUcanAuthorization, a$ as signCompactUcanRootAuthorization, b0 as signPolicyCredentialPresentationV4, b1 as signedObjectIdFor, b2 as toSignedObjectError, b3 as unifiedNativeProjectionHashHex, b4 as unifiedPolicyCapabilityContains, b5 as unifiedPolicyCapabilityDigestHex, b6 as unifiedPolicyCapabilityFromNative, b7 as validatePolicyCredentialRequirementV1, b8 as validatePolicyEngineRecordSigned, b9 as validatePolicyEngineRecordSignedShape, ba as validatePolicyEngineRecordUnsigned, bb as validatePolicySigned, bc as validatePolicySignedShape, bd as validatePolicyStatusSigned, be as validatePolicyStatusSignedShape, bf as validatePolicyStatusUnsigned, bg as validatePolicyUnsigned, bh as validateUnifiedPolicyV2, bi as verifyPolicy, bj as verifyPolicyEngineRecord, bk as verifyPolicyRootRevocationV3, bl as verifyPolicyRootStatusCheckpointV3, bm as verifyPolicyStatus, bn as verifySignedObject } from '../credential-admission-DIEPgQ0o.js';
|
|
3
3
|
import { J as JsonObject, P as PolicyCapabilityError } from '../capability-BjzXwtNw.js';
|
|
4
4
|
export { a as JsonValue, b as PolicyCapability, c as PolicyCapabilityErrorCode, d as canonicalizePolicyCapability, j as jcsCanonicalize, n as normalizeJson, e as normalizePolicyCapability, p as policyCapabilityContains, f as policyCapabilityDigestHex, s as serializeJcsJson } from '../capability-BjzXwtNw.js';
|
|
5
5
|
import 'zod';
|
package/dist/policy/index.js
CHANGED
|
@@ -3210,9 +3210,11 @@ var MAX_LEGACY_ENVELOPE_EXPIRES_AT = "2026-12-29T00:00:00Z";
|
|
|
3210
3210
|
var LAST_V2_READ_AT = "2027-01-05T00:00:00Z";
|
|
3211
3211
|
async function requestPolicyChallengeV3(input) {
|
|
3212
3212
|
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
3213
|
-
const
|
|
3213
|
+
const policyRuntimePath = policyRuntimeBasePath(input.policyRuntimePath);
|
|
3214
|
+
const response = await fetchFn(new URL(`${policyRuntimePath}/challenges`, input.nodeOrigin), {
|
|
3214
3215
|
method: "POST",
|
|
3215
3216
|
redirect: "error",
|
|
3217
|
+
signal: input.signal,
|
|
3216
3218
|
headers: { accept: "application/json", "content-type": "application/json" },
|
|
3217
3219
|
body: JSON.stringify({ policyCid: input.policyCid, recipientDid: input.recipientDid, requestedCapabilities: input.requestedCapabilities.map(normalizeUnifiedPolicyCapability) })
|
|
3218
3220
|
});
|
|
@@ -3222,14 +3224,22 @@ async function requestPolicyChallengeV3(input) {
|
|
|
3222
3224
|
throw new Error("policy challenge binding is invalid");
|
|
3223
3225
|
return value;
|
|
3224
3226
|
}
|
|
3227
|
+
function policyRuntimeBasePath(value) {
|
|
3228
|
+
const path = value ?? "/policy/v3";
|
|
3229
|
+
if (!/^\/policy(?:\/[a-z0-9-]+)*$/.test(path)) {
|
|
3230
|
+
throw new Error("policy runtime path is invalid");
|
|
3231
|
+
}
|
|
3232
|
+
return path;
|
|
3233
|
+
}
|
|
3225
3234
|
async function mintPolicySessionV3(input) {
|
|
3226
3235
|
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
3227
3236
|
const challenge = input.challenge ?? await requestPolicyChallengeV3(input);
|
|
3228
3237
|
if (challenge.policyCid !== input.policyCid || challenge.recipientDid !== input.recipientDid)
|
|
3229
3238
|
throw new Error("policy challenge binding is invalid");
|
|
3230
|
-
const response = await fetchFn(new URL("/
|
|
3239
|
+
const response = await fetchFn(new URL("/policy/v3/delegations", input.nodeOrigin), {
|
|
3231
3240
|
method: "POST",
|
|
3232
3241
|
redirect: "error",
|
|
3242
|
+
signal: input.signal,
|
|
3233
3243
|
headers: { accept: "application/json", "content-type": "application/json" },
|
|
3234
3244
|
body: JSON.stringify({ policyCid: input.policyCid, challengeId: challenge.challengeId, nonce: challenge.nonce, claim: input.claim, presentation: input.presentation })
|
|
3235
3245
|
});
|
|
@@ -3288,7 +3298,7 @@ function verifyPolicyRootStatusCheckpointV3(input) {
|
|
|
3288
3298
|
}
|
|
3289
3299
|
async function getPolicyRootStatusV3(input) {
|
|
3290
3300
|
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
3291
|
-
const response = await fetchFn(new URL(`/
|
|
3301
|
+
const response = await fetchFn(new URL(`/policy/v3/status/${encodeURIComponent(input.rootCid)}`, input.nodeOrigin), {
|
|
3292
3302
|
method: "GET",
|
|
3293
3303
|
redirect: "error",
|
|
3294
3304
|
headers: { accept: "application/json" }
|
|
@@ -3347,7 +3357,7 @@ async function renewPolicyRootStatusV3(input) {
|
|
|
3347
3357
|
};
|
|
3348
3358
|
const signature = await input.sign(sha2564(new TextEncoder().encode(ROOT_STATUS_RENEWAL_V1_DOMAIN + jcsCanonicalize(unsigned))));
|
|
3349
3359
|
if (signature.length !== 64) throw new Error("policy root renewal signature must be Ed25519");
|
|
3350
|
-
const response = await fetchFn(new URL("/
|
|
3360
|
+
const response = await fetchFn(new URL("/policy/v3/status", input.nodeOrigin), {
|
|
3351
3361
|
method: "POST",
|
|
3352
3362
|
redirect: "error",
|
|
3353
3363
|
headers: { accept: "application/json", "content-type": "application/json" },
|
|
@@ -3403,6 +3413,11 @@ var POLICY_SESSION_FACT_KEYS = [
|
|
|
3403
3413
|
"issuanceAuditDigestHex",
|
|
3404
3414
|
"remainingRedelegationDepth"
|
|
3405
3415
|
];
|
|
3416
|
+
var POLICY_SESSION_V4_AUDIT_FACT_KEYS = [
|
|
3417
|
+
"credentialIdAuditDigestHex",
|
|
3418
|
+
"presentationJtiAuditDigestHex"
|
|
3419
|
+
];
|
|
3420
|
+
var LOWER_SHA256_HEX = /^[0-9a-f]{64}$/;
|
|
3406
3421
|
var KV_ACTIONS = /* @__PURE__ */ new Set([
|
|
3407
3422
|
"tinycloud.kv/get",
|
|
3408
3423
|
"tinycloud.kv/list",
|
|
@@ -3597,6 +3612,133 @@ function contentSourceDigestHex(input) {
|
|
|
3597
3612
|
)
|
|
3598
3613
|
);
|
|
3599
3614
|
}
|
|
3615
|
+
function exactObject(value, keys, label) {
|
|
3616
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
3617
|
+
throw new Error(`${label} is invalid`);
|
|
3618
|
+
}
|
|
3619
|
+
const record2 = value;
|
|
3620
|
+
if (Object.keys(record2).length !== keys.length || keys.some((key) => !Object.prototype.hasOwnProperty.call(record2, key))) {
|
|
3621
|
+
throw new Error(`${label} is invalid`);
|
|
3622
|
+
}
|
|
3623
|
+
return record2;
|
|
3624
|
+
}
|
|
3625
|
+
function didKeyEd25519PublicKey(value) {
|
|
3626
|
+
const principal = value.split("#", 1)[0];
|
|
3627
|
+
if (!principal.startsWith("did:key:")) {
|
|
3628
|
+
throw new Error("policy enforcer binding signer is invalid");
|
|
3629
|
+
}
|
|
3630
|
+
const material = base58btc.decode(principal.slice("did:key:".length));
|
|
3631
|
+
if (material.length !== 34 || material[0] !== 237 || material[1] !== 1) {
|
|
3632
|
+
throw new Error("policy enforcer binding signer is invalid");
|
|
3633
|
+
}
|
|
3634
|
+
return material.slice(2);
|
|
3635
|
+
}
|
|
3636
|
+
async function registerPolicyV3(input) {
|
|
3637
|
+
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
3638
|
+
const rootExpiresAt = new Date(input.rootExpiresAt);
|
|
3639
|
+
const canonicalRootExpiresAt = new Date(
|
|
3640
|
+
Math.floor(rootExpiresAt.getTime() / 1e3) * 1e3
|
|
3641
|
+
).toISOString().replace(/\.000Z$/, "Z");
|
|
3642
|
+
if (!Number.isFinite(rootExpiresAt.getTime()) || canonicalRootExpiresAt !== input.rootExpiresAt || rootExpiresAt.getTime() <= Date.now()) {
|
|
3643
|
+
throw new Error("policy root expiry is invalid");
|
|
3644
|
+
}
|
|
3645
|
+
const bindingResponse = await fetchFn(
|
|
3646
|
+
new URL("/policy/v3/enforcer-bindings", input.nodeOrigin),
|
|
3647
|
+
{
|
|
3648
|
+
method: "POST",
|
|
3649
|
+
redirect: "error",
|
|
3650
|
+
signal: input.signal,
|
|
3651
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
3652
|
+
body: JSON.stringify({
|
|
3653
|
+
rootExpiresAt: input.rootExpiresAt,
|
|
3654
|
+
enforcerDid: input.enforcerDid
|
|
3655
|
+
})
|
|
3656
|
+
}
|
|
3657
|
+
);
|
|
3658
|
+
if (!bindingResponse.ok) {
|
|
3659
|
+
throw new Error(`policy enforcer binding rejected (${bindingResponse.status})`);
|
|
3660
|
+
}
|
|
3661
|
+
const binding = exactObject(
|
|
3662
|
+
await bindingResponse.json(),
|
|
3663
|
+
[
|
|
3664
|
+
"schema",
|
|
3665
|
+
"enforcerDid",
|
|
3666
|
+
"nodeAudience",
|
|
3667
|
+
"attestationBindingDigestHex",
|
|
3668
|
+
"issuedAt",
|
|
3669
|
+
"expiresAt",
|
|
3670
|
+
"signature"
|
|
3671
|
+
],
|
|
3672
|
+
"policy enforcer binding"
|
|
3673
|
+
);
|
|
3674
|
+
const signature = exactObject(
|
|
3675
|
+
binding.signature,
|
|
3676
|
+
["suite", "signerDid", "value"],
|
|
3677
|
+
"policy enforcer binding signature"
|
|
3678
|
+
);
|
|
3679
|
+
const expectedBindingDigestHex = hex(
|
|
3680
|
+
sha2564(
|
|
3681
|
+
new TextEncoder().encode(
|
|
3682
|
+
jcsCanonicalize({
|
|
3683
|
+
enforcerDid: input.enforcerDid,
|
|
3684
|
+
nodeAudience: input.expectedNodeAudience
|
|
3685
|
+
})
|
|
3686
|
+
)
|
|
3687
|
+
)
|
|
3688
|
+
);
|
|
3689
|
+
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") {
|
|
3690
|
+
throw new Error("policy enforcer binding is invalid");
|
|
3691
|
+
}
|
|
3692
|
+
const { signature: _signature, ...unsignedBinding } = binding;
|
|
3693
|
+
const signedBinding = sha2564(
|
|
3694
|
+
new TextEncoder().encode(
|
|
3695
|
+
`xyz.tinycloud.policy/AttestedEnforcerBinding/v2\0${jcsCanonicalize(unsignedBinding)}`
|
|
3696
|
+
)
|
|
3697
|
+
);
|
|
3698
|
+
if (!ed255192.verify(
|
|
3699
|
+
decodeBase64Url(signature.value),
|
|
3700
|
+
signedBinding,
|
|
3701
|
+
didKeyEd25519PublicKey(input.expectedNodeAudience),
|
|
3702
|
+
{ zip215: false }
|
|
3703
|
+
)) {
|
|
3704
|
+
throw new Error("policy enforcer binding signature is invalid");
|
|
3705
|
+
}
|
|
3706
|
+
const response = await fetchFn(
|
|
3707
|
+
new URL("/policy/v3/policies", input.nodeOrigin),
|
|
3708
|
+
{
|
|
3709
|
+
method: "POST",
|
|
3710
|
+
redirect: "error",
|
|
3711
|
+
signal: input.signal,
|
|
3712
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
3713
|
+
body: JSON.stringify({
|
|
3714
|
+
policyCid: input.policyCid,
|
|
3715
|
+
policy: input.policy,
|
|
3716
|
+
policyRoot: input.policyRoot.authorization.replace(/^Bearer\s+/i, ""),
|
|
3717
|
+
enforcementRoot: input.enforcementRoot.authorization.replace(/^Bearer\s+/i, ""),
|
|
3718
|
+
contentSourceDigestHex: input.contentSourceDigestHex,
|
|
3719
|
+
nativeProjectionHashHex: input.nativeProjectionHashHex,
|
|
3720
|
+
attestedEnforcerBinding: binding
|
|
3721
|
+
})
|
|
3722
|
+
}
|
|
3723
|
+
);
|
|
3724
|
+
if (!response.ok) {
|
|
3725
|
+
throw new Error(`policy registration rejected (${response.status})`);
|
|
3726
|
+
}
|
|
3727
|
+
const receipt = exactObject(
|
|
3728
|
+
await response.json(),
|
|
3729
|
+
["policyCid", "policyRootCid", "enforcementRootCid"],
|
|
3730
|
+
"policy registration response"
|
|
3731
|
+
);
|
|
3732
|
+
if (receipt.policyCid !== input.policyCid || receipt.policyRootCid !== input.policyRoot.cid || receipt.enforcementRootCid !== input.enforcementRoot.cid) {
|
|
3733
|
+
throw new Error("policy registration response binding is invalid");
|
|
3734
|
+
}
|
|
3735
|
+
return {
|
|
3736
|
+
policyCid: input.policyCid,
|
|
3737
|
+
policyRootCid: input.policyRoot.cid,
|
|
3738
|
+
enforcementRootCid: input.enforcementRoot.cid,
|
|
3739
|
+
attestedEnforcerBinding: binding
|
|
3740
|
+
};
|
|
3741
|
+
}
|
|
3600
3742
|
function policyDigestHex(policy) {
|
|
3601
3743
|
const canonicalPolicy = {
|
|
3602
3744
|
...policy,
|
|
@@ -3795,9 +3937,13 @@ function parsePolicySessionUcan(authorization, expectedProofs) {
|
|
|
3795
3937
|
if (expectedProofs !== void 0 && (parsed.payload.prf[0] !== expectedProofs[0] || parsed.payload.prf[1] !== expectedProofs[1]))
|
|
3796
3938
|
throw new Error("policy session UCAN ordered proofs do not match");
|
|
3797
3939
|
const factKeys = Object.keys(fact);
|
|
3798
|
-
|
|
3940
|
+
const hasLegacyFactShape = factKeys.length === POLICY_SESSION_FACT_KEYS.length && factKeys.every((key) => POLICY_SESSION_FACT_KEYS.includes(key)) && POLICY_SESSION_FACT_KEYS.every((key) => key in fact);
|
|
3941
|
+
const hasV4AuditFactShape = factKeys.length === POLICY_SESSION_FACT_KEYS.length + POLICY_SESSION_V4_AUDIT_FACT_KEYS.length && factKeys.every((key) => POLICY_SESSION_FACT_KEYS.includes(key) || POLICY_SESSION_V4_AUDIT_FACT_KEYS.includes(key)) && POLICY_SESSION_FACT_KEYS.every((key) => key in fact) && POLICY_SESSION_V4_AUDIT_FACT_KEYS.every((key) => key in fact);
|
|
3942
|
+
if (!hasLegacyFactShape && !hasV4AuditFactShape)
|
|
3799
3943
|
throw new Error("policy session UCAN fact is incomplete");
|
|
3800
|
-
if (
|
|
3944
|
+
if (hasV4AuditFactShape && (!LOWER_SHA256_HEX.test(fact.credentialIdAuditDigestHex) || !LOWER_SHA256_HEX.test(fact.presentationJtiAuditDigestHex)))
|
|
3945
|
+
throw new Error("policy session UCAN v4 audit facts are invalid");
|
|
3946
|
+
if (fact.profile !== POLICY_SESSION_UCAN_V1_PROFILE || typeof fact.remainingRedelegationDepth !== "number" || !Number.isInteger(fact.remainingRedelegationDepth) || fact.remainingRedelegationDepth < 0 || fact.remainingRedelegationDepth > 8 || parsed.payload.exp - parsed.payload.nbf > 60 || parsed.payload.iss.split("#", 1)[0] !== fact.nodeAudience || parsed.payload.aud !== fact.recipientDid)
|
|
3801
3947
|
throw new Error("policy session UCAN fact is invalid");
|
|
3802
3948
|
return {
|
|
3803
3949
|
authorization,
|
|
@@ -3878,6 +4024,7 @@ var RECOVERABLE = /* @__PURE__ */ new Set([
|
|
|
3878
4024
|
"ISSUER_UNREADY",
|
|
3879
4025
|
"OFFLINE",
|
|
3880
4026
|
"POPUP_BLOCKED",
|
|
4027
|
+
"PROOF_REJECTED",
|
|
3881
4028
|
"REQUEST_EXPIRED",
|
|
3882
4029
|
"SIGNATURE_REJECTED",
|
|
3883
4030
|
"UNSUPPORTED_PROFILE",
|
|
@@ -3925,6 +4072,8 @@ var POLICY_V2_DOMAIN = "xyz.tinycloud.policy/policy/v2\0";
|
|
|
3925
4072
|
var POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE = "TinyCloudPolicyCredentialRequirement";
|
|
3926
4073
|
var POLICY_PRESENTATION_V3_SCHEMA = "xyz.tinycloud.policy/presentation/v3";
|
|
3927
4074
|
var POLICY_PRESENTATION_V3_DOMAIN = "xyz.tinycloud.policy/Presentation/v3\0";
|
|
4075
|
+
var POLICY_PRESENTATION_V4_SCHEMA = "xyz.tinycloud.policy/presentation/v4";
|
|
4076
|
+
var POLICY_PRESENTATION_V4_DOMAIN = "xyz.tinycloud.policy/Presentation/v4\0";
|
|
3928
4077
|
function record(value, label) {
|
|
3929
4078
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
3930
4079
|
throw new Error(`${label} must be an object`);
|
|
@@ -4099,6 +4248,97 @@ function envelopeFromVerified(verified) {
|
|
|
4099
4248
|
} = verified;
|
|
4100
4249
|
return envelope;
|
|
4101
4250
|
}
|
|
4251
|
+
function issuedCredentialEnvelopeFromVerified(verified) {
|
|
4252
|
+
return envelopeFromVerified(verified);
|
|
4253
|
+
}
|
|
4254
|
+
async function signPolicyCredentialPresentationV4(value, sign) {
|
|
4255
|
+
const item = record(value, "Policy presentation v4");
|
|
4256
|
+
exactKeys2(item, [
|
|
4257
|
+
"schema",
|
|
4258
|
+
"jti",
|
|
4259
|
+
"challengeId",
|
|
4260
|
+
"nonce",
|
|
4261
|
+
"policyCid",
|
|
4262
|
+
"nodeAudience",
|
|
4263
|
+
"holderDid",
|
|
4264
|
+
"subjectDid",
|
|
4265
|
+
"credentialDigest",
|
|
4266
|
+
"requirementDigest",
|
|
4267
|
+
"descriptorDigest",
|
|
4268
|
+
"requestedCapabilities",
|
|
4269
|
+
"issuedAt",
|
|
4270
|
+
"expiresAt"
|
|
4271
|
+
], "Policy presentation v4");
|
|
4272
|
+
if (item.schema !== POLICY_PRESENTATION_V4_SCHEMA || item.holderDid !== item.subjectDid || !Array.isArray(item.requestedCapabilities)) throw new Error("Policy presentation v4 is invalid");
|
|
4273
|
+
const holderDid = nonEmpty(item.holderDid, "Policy presentation v4 holder DID");
|
|
4274
|
+
didKeyBytes(holderDid);
|
|
4275
|
+
const unsigned = Object.freeze({
|
|
4276
|
+
schema: POLICY_PRESENTATION_V4_SCHEMA,
|
|
4277
|
+
jti: nonEmpty(item.jti, "Policy presentation v4 jti"),
|
|
4278
|
+
challengeId: nonEmpty(item.challengeId, "Policy presentation v4 challenge"),
|
|
4279
|
+
nonce: nonEmpty(item.nonce, "Policy presentation v4 nonce"),
|
|
4280
|
+
policyCid: nonEmpty(item.policyCid, "Policy presentation v4 policy CID"),
|
|
4281
|
+
nodeAudience: nonEmpty(item.nodeAudience, "Policy presentation v4 audience"),
|
|
4282
|
+
holderDid,
|
|
4283
|
+
subjectDid: holderDid,
|
|
4284
|
+
credentialDigest: nonEmpty(item.credentialDigest, "Policy presentation v4 credential digest"),
|
|
4285
|
+
requirementDigest: nonEmpty(item.requirementDigest, "Policy presentation v4 requirement digest"),
|
|
4286
|
+
descriptorDigest: nonEmpty(item.descriptorDigest, "Policy presentation v4 descriptor digest"),
|
|
4287
|
+
// The low-level signer preserves the frozen wire bytes exactly. The
|
|
4288
|
+
// policy-aware builder performs capability normalization and containment.
|
|
4289
|
+
requestedCapabilities: Object.freeze(item.requestedCapabilities),
|
|
4290
|
+
issuedAt: date(item.issuedAt, "Policy presentation v4 issuedAt"),
|
|
4291
|
+
expiresAt: date(item.expiresAt, "Policy presentation v4 expiresAt")
|
|
4292
|
+
});
|
|
4293
|
+
const digest2 = sha2565(new TextEncoder().encode(
|
|
4294
|
+
POLICY_PRESENTATION_V4_DOMAIN + jcsCanonicalize(unsigned)
|
|
4295
|
+
));
|
|
4296
|
+
const signature = await sign(digest2);
|
|
4297
|
+
if (signature.length !== 64 || !ed255193.verify(signature, digest2, didKeyBytes(holderDid))) throw new Error("policy presentation signature is invalid");
|
|
4298
|
+
return Object.freeze({
|
|
4299
|
+
...unsigned,
|
|
4300
|
+
signature: Object.freeze({
|
|
4301
|
+
suite: "Ed25519",
|
|
4302
|
+
signerDid: holderDid,
|
|
4303
|
+
value: encodeBase64Url2(signature)
|
|
4304
|
+
})
|
|
4305
|
+
});
|
|
4306
|
+
}
|
|
4307
|
+
async function buildPolicyCredentialPresentationV4(input) {
|
|
4308
|
+
const policy = validateUnifiedPolicyV2(input.policy, input.policyCid);
|
|
4309
|
+
const requirement = validateCredentialRequirement(input.requirement);
|
|
4310
|
+
const commitment = policy.credentialRequirement;
|
|
4311
|
+
const requirementDigest = await credentialRequirementDigest(requirement);
|
|
4312
|
+
const credentialDigest = await sha256Base64Url(input.credential.credential);
|
|
4313
|
+
if (requirementDigest !== commitment.requirementDigest || input.credential.descriptorDigest !== commitment.descriptorDigest || input.credential.credentialDigest !== credentialDigest || input.credential.issuerDid !== commitment.issuerDid || input.credential.issuerKid !== commitment.issuerKid || jcsCanonicalize(input.credential.profile) !== jcsCanonicalize(commitment.profile) || jcsCanonicalize(input.credential.credentialType) !== jcsCanonicalize(commitment.credentialType)) throw new Error("credential does not match the signed Policy/v2 requirement");
|
|
4314
|
+
const requestedCapabilities = input.requestedCapabilities.map(normalizeUnifiedPolicyCapability);
|
|
4315
|
+
if (requestedCapabilities.length === 0 || requestedCapabilities.some((requested) => !policy.capabilityCeiling.some((authority) => unifiedPolicyCapabilityContains(authority, requested)))) throw new Error("requested capabilities exceed the signed Policy/v2 ceiling");
|
|
4316
|
+
const holderDid = input.credential.holderDid;
|
|
4317
|
+
if (input.challenge.policyCid !== input.policyCid || input.challenge.recipientDid !== holderDid || input.credential.subjectDid !== holderDid || typeof input.challenge.nodeAudience !== "string" || input.challenge.nodeAudience.length === 0 || typeof input.challenge.expiresAt !== "string" || !Number.isFinite(Date.parse(input.challenge.expiresAt))) throw new Error("policy challenge binding is invalid");
|
|
4318
|
+
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
4319
|
+
const expiresAtMs = Math.min(
|
|
4320
|
+
now.getTime() + 6e4,
|
|
4321
|
+
Date.parse(input.challenge.expiresAt),
|
|
4322
|
+
Date.parse(input.credential.expiresAt)
|
|
4323
|
+
);
|
|
4324
|
+
if (expiresAtMs <= now.getTime()) throw new Error("policy challenge is expired");
|
|
4325
|
+
return signPolicyCredentialPresentationV4(Object.freeze({
|
|
4326
|
+
schema: POLICY_PRESENTATION_V4_SCHEMA,
|
|
4327
|
+
jti: input.jti ?? encodeBase64Url2(crypto.getRandomValues(new Uint8Array(16))),
|
|
4328
|
+
challengeId: input.challenge.challengeId,
|
|
4329
|
+
nonce: input.challenge.nonce,
|
|
4330
|
+
policyCid: input.policyCid,
|
|
4331
|
+
nodeAudience: input.challenge.nodeAudience,
|
|
4332
|
+
holderDid,
|
|
4333
|
+
subjectDid: holderDid,
|
|
4334
|
+
credentialDigest,
|
|
4335
|
+
requirementDigest,
|
|
4336
|
+
descriptorDigest: input.credential.descriptorDigest,
|
|
4337
|
+
requestedCapabilities: Object.freeze(requestedCapabilities),
|
|
4338
|
+
issuedAt: rfc3339Seconds(now),
|
|
4339
|
+
expiresAt: rfc3339Seconds(new Date(expiresAtMs))
|
|
4340
|
+
}), input.sign);
|
|
4341
|
+
}
|
|
4102
4342
|
async function buildPolicyCredentialPresentationV3(input) {
|
|
4103
4343
|
const policy = validateUnifiedPolicyV2(input.policy, input.policyCid);
|
|
4104
4344
|
const requirement = validateCredentialRequirement(input.requirement);
|
|
@@ -4185,10 +4425,12 @@ async function admitPolicyCredentialV3(input) {
|
|
|
4185
4425
|
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
4186
4426
|
const challenge = await requestPolicyChallengeV3({
|
|
4187
4427
|
nodeOrigin,
|
|
4428
|
+
policyRuntimePath: input.policyRuntimePath,
|
|
4188
4429
|
policyCid: input.policyCid,
|
|
4189
4430
|
recipientDid: input.credential.holderDid,
|
|
4190
4431
|
requestedCapabilities: input.requestedCapabilities,
|
|
4191
|
-
fetch: fetchFn
|
|
4432
|
+
fetch: fetchFn,
|
|
4433
|
+
signal: input.signal
|
|
4192
4434
|
});
|
|
4193
4435
|
const presentation = await buildPolicyCredentialPresentationV3({
|
|
4194
4436
|
...input,
|
|
@@ -4196,10 +4438,11 @@ async function admitPolicyCredentialV3(input) {
|
|
|
4196
4438
|
challenge
|
|
4197
4439
|
});
|
|
4198
4440
|
const response = await fetchFn(
|
|
4199
|
-
new URL(
|
|
4441
|
+
new URL(`${policyRuntimeBasePath2(input.policyRuntimePath)}/delegations`, nodeOrigin),
|
|
4200
4442
|
{
|
|
4201
4443
|
method: "POST",
|
|
4202
4444
|
redirect: "error",
|
|
4445
|
+
signal: input.signal,
|
|
4203
4446
|
headers: { accept: "application/json", "content-type": "application/json" },
|
|
4204
4447
|
body: JSON.stringify({
|
|
4205
4448
|
policyCid: input.policyCid,
|
|
@@ -4228,8 +4471,74 @@ async function admitPolicyCredentialV3(input) {
|
|
|
4228
4471
|
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)) {
|
|
4229
4472
|
throw new Error("policy delegation signed binding is invalid");
|
|
4230
4473
|
}
|
|
4474
|
+
input.signal?.throwIfAborted();
|
|
4231
4475
|
return Object.freeze({ challenge, presentation, session });
|
|
4232
4476
|
}
|
|
4477
|
+
function validatePolicyCredentialAdmissionV4Authority(session, expected) {
|
|
4478
|
+
if (session.iss.split("#", 1)[0] !== expected.nodeAudience || session.fact.nodeAudience !== expected.nodeAudience || session.fact.enforcerDid !== expected.enforcerDid) throw new Error("policy delegation authority binding is invalid");
|
|
4479
|
+
}
|
|
4480
|
+
async function admitPolicyCredentialV4(input) {
|
|
4481
|
+
const policy = validateUnifiedPolicyV2(input.policy, input.policyCid);
|
|
4482
|
+
const nodeOrigin = policyNodeOrigin(input.nodeOrigin);
|
|
4483
|
+
const fetchFn = input.fetch ?? globalThis.fetch.bind(globalThis);
|
|
4484
|
+
const challenge = await requestPolicyChallengeV3({
|
|
4485
|
+
nodeOrigin,
|
|
4486
|
+
policyRuntimePath: input.policyRuntimePath,
|
|
4487
|
+
policyCid: input.policyCid,
|
|
4488
|
+
recipientDid: input.credential.holderDid,
|
|
4489
|
+
requestedCapabilities: input.requestedCapabilities,
|
|
4490
|
+
fetch: fetchFn,
|
|
4491
|
+
signal: input.signal
|
|
4492
|
+
});
|
|
4493
|
+
const presentation = await buildPolicyCredentialPresentationV4({
|
|
4494
|
+
...input,
|
|
4495
|
+
policy,
|
|
4496
|
+
challenge
|
|
4497
|
+
});
|
|
4498
|
+
const response = await fetchFn(new URL(`${policyRuntimeBasePath2(input.policyRuntimePath)}/delegations`, nodeOrigin), {
|
|
4499
|
+
method: "POST",
|
|
4500
|
+
redirect: "error",
|
|
4501
|
+
signal: input.signal,
|
|
4502
|
+
headers: { accept: "application/json", "content-type": "application/json" },
|
|
4503
|
+
body: JSON.stringify({
|
|
4504
|
+
policyCid: input.policyCid,
|
|
4505
|
+
challengeId: challenge.challengeId,
|
|
4506
|
+
nonce: challenge.nonce,
|
|
4507
|
+
requirement: validateCredentialRequirement(input.requirement),
|
|
4508
|
+
credential: envelopeFromVerified(input.credential),
|
|
4509
|
+
presentation
|
|
4510
|
+
})
|
|
4511
|
+
});
|
|
4512
|
+
if (!response.ok) throw new Error(`policy delegation rejected (${response.status})`);
|
|
4513
|
+
const value = record(await response.json(), "policy delegation");
|
|
4514
|
+
if (value.admitted !== true || typeof value.sessionCid !== "string" || typeof value.authorization !== "string") throw new Error("policy delegation response is invalid");
|
|
4515
|
+
const session = parsePolicySessionUcan(value.authorization, [
|
|
4516
|
+
input.policyRootCid,
|
|
4517
|
+
input.enforcementRootCid
|
|
4518
|
+
]);
|
|
4519
|
+
const expectedAttenuation = compactAttenuationForPolicyCapabilities(input.requestedCapabilities);
|
|
4520
|
+
validatePolicyCredentialAdmissionV4Authority(session, {
|
|
4521
|
+
nodeAudience: input.expectedNodeAudience,
|
|
4522
|
+
enforcerDid: input.expectedEnforcerDid
|
|
4523
|
+
});
|
|
4524
|
+
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");
|
|
4525
|
+
const importResponse = await fetchFn(new URL("/delegate", nodeOrigin), {
|
|
4526
|
+
method: "POST",
|
|
4527
|
+
redirect: "error",
|
|
4528
|
+
signal: input.signal,
|
|
4529
|
+
headers: { Authorization: session.authorization }
|
|
4530
|
+
});
|
|
4531
|
+
if (!importResponse.ok) throw new Error(`delegation import rejected (${importResponse.status})`);
|
|
4532
|
+
input.signal?.throwIfAborted();
|
|
4533
|
+
return Object.freeze({ challenge, presentation, session, delegationImported: true });
|
|
4534
|
+
}
|
|
4535
|
+
function policyRuntimeBasePath2(value) {
|
|
4536
|
+
const path = value ?? "/policy/v3";
|
|
4537
|
+
if (!/^\/policy(?:\/[a-z0-9-]+)*$/.test(path)) {
|
|
4538
|
+
throw new Error("policy runtime path is invalid");
|
|
4539
|
+
}
|
|
4540
|
+
return path;
|
|
4541
|
+
}
|
|
4233
4542
|
export {
|
|
4234
4543
|
ATTESTED_ENFORCER_BINDING_V2_SCHEMA,
|
|
4235
4544
|
CONTENT_SOURCE_V1_DOMAIN,
|
|
@@ -4247,6 +4556,8 @@ export {
|
|
|
4247
4556
|
POLICY_ENGINE_RECORD_SCHEMA,
|
|
4248
4557
|
POLICY_PRESENTATION_V3_DOMAIN,
|
|
4249
4558
|
POLICY_PRESENTATION_V3_SCHEMA,
|
|
4559
|
+
POLICY_PRESENTATION_V4_DOMAIN,
|
|
4560
|
+
POLICY_PRESENTATION_V4_SCHEMA,
|
|
4250
4561
|
POLICY_SCHEMA,
|
|
4251
4562
|
POLICY_SESSION_UCAN_V1_PROFILE,
|
|
4252
4563
|
POLICY_STATUS_SCHEMA,
|
|
@@ -4274,7 +4585,9 @@ export {
|
|
|
4274
4585
|
UnsupportedSignatureSuiteError,
|
|
4275
4586
|
W3C_VC_CREDENTIAL_VERIFIER,
|
|
4276
4587
|
admitPolicyCredentialV3,
|
|
4588
|
+
admitPolicyCredentialV4,
|
|
4277
4589
|
buildPolicyCredentialPresentationV3,
|
|
4590
|
+
buildPolicyCredentialPresentationV4,
|
|
4278
4591
|
canonicalizePolicyCapability,
|
|
4279
4592
|
canonicalizeSignedObjectUnsigned,
|
|
4280
4593
|
canonicalizeUnifiedPolicyCapability,
|
|
@@ -4292,6 +4605,7 @@ export {
|
|
|
4292
4605
|
createUnsignedPolicyEngineRecord,
|
|
4293
4606
|
deriveSignedObjectMaterial,
|
|
4294
4607
|
getPolicyRootStatusV3,
|
|
4608
|
+
issuedCredentialEnvelopeFromVerified,
|
|
4295
4609
|
jcsCanonicalize,
|
|
4296
4610
|
mintPolicySessionV3,
|
|
4297
4611
|
normalizeJson,
|
|
@@ -4307,12 +4621,14 @@ export {
|
|
|
4307
4621
|
policyV2DigestHex,
|
|
4308
4622
|
projectUnifiedPolicyCapabilities,
|
|
4309
4623
|
projectUnifiedPolicyCapability,
|
|
4624
|
+
registerPolicyV3,
|
|
4310
4625
|
renewPolicyRootStatusV3,
|
|
4311
4626
|
requestPolicyChallengeV3,
|
|
4312
4627
|
revokePolicyRootV3,
|
|
4313
4628
|
serialize as serializeJcsJson,
|
|
4314
4629
|
signCompactUcanAuthorization,
|
|
4315
4630
|
signCompactUcanRootAuthorization,
|
|
4631
|
+
signPolicyCredentialPresentationV4,
|
|
4316
4632
|
signedObjectIdFor,
|
|
4317
4633
|
toSignedObjectError,
|
|
4318
4634
|
unifiedNativeProjectionHashHex,
|