@tinycloud/sdk-core 3.0.0-beta.17 → 3.0.0-beta.19
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-CFjUChF8.d.cts → credential-admission-BxpkckU0.d.cts} +23 -3
- package/dist/{credential-admission-DIEPgQ0o.d.ts → credential-admission-CO9WMtGs.d.ts} +23 -3
- package/dist/delegations/index.cjs +64 -44
- 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 +64 -44
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +122 -69
- 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 +122 -69
- package/dist/index.js.map +1 -1
- package/dist/policy/index.cjs +79 -35
- 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 +79 -35
- package/dist/policy/index.js.map +1 -1
- package/dist/{recipient-types.schema-lAKNQlxx.d.cts → recipient-types.schema-D9AI8tjN.d.cts} +34 -8
- package/dist/{recipient-types.schema-lAKNQlxx.d.ts → recipient-types.schema-D9AI8tjN.d.ts} +34 -8
- package/package.json +2 -2
|
@@ -718,17 +718,28 @@ interface CompactPolicyInvocationInput {
|
|
|
718
718
|
}
|
|
719
719
|
/** Sign a fresh one-parent ordinary invocation; S0 itself is never a bearer. */
|
|
720
720
|
declare function createCompactPolicyInvocation(input: CompactPolicyInvocationInput): CompactUcanAuthorizationV1;
|
|
721
|
-
|
|
721
|
+
interface CompactPolicyDescendantInput {
|
|
722
722
|
readonly parentAuthorization: string;
|
|
723
723
|
readonly parentCid: string;
|
|
724
724
|
readonly issuerDid: string;
|
|
725
725
|
readonly audienceDid: string;
|
|
726
726
|
readonly attenuation: Readonly<Record<string, Readonly<Record<string, readonly unknown[]>>>>;
|
|
727
|
-
|
|
727
|
+
/** Start of the window; defaults to one second after the parent's start. */
|
|
728
728
|
readonly now?: number;
|
|
729
|
+
/** Defaults to the longest window the parent allows: one second inside it. */
|
|
729
730
|
readonly expiresAt?: number;
|
|
730
731
|
readonly nonce?: string;
|
|
732
|
+
}
|
|
733
|
+
declare function createCompactPolicyDescendant(input: CompactPolicyDescendantInput & {
|
|
734
|
+
readonly privateKey: Uint8Array;
|
|
731
735
|
}): CompactUcanAuthorizationV1;
|
|
736
|
+
/**
|
|
737
|
+
* The same descendant, signed by a caller-owned key that may be
|
|
738
|
+
* non-extractable. The result is verified against the issuer DID.
|
|
739
|
+
*/
|
|
740
|
+
declare function signCompactPolicyDescendant(input: CompactPolicyDescendantInput & {
|
|
741
|
+
readonly sign: (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
742
|
+
}): Promise<CompactUcanAuthorizationV1>;
|
|
732
743
|
/** Byte-independent semantic containment shared by S0, descendants and mint requests. */
|
|
733
744
|
declare function compactAttenuationContains(parent: Readonly<Record<string, Readonly<Record<string, readonly unknown[]>>>>, child: Readonly<Record<string, Readonly<Record<string, readonly unknown[]>>>>): boolean;
|
|
734
745
|
declare function parseCompactUcanAuthorization(input: string, expectedCid?: string): CompactUcanAuthorizationV1;
|
|
@@ -864,6 +875,8 @@ interface AdmitPolicyCredentialV3Input extends Omit<BuildPolicyCredentialPresent
|
|
|
864
875
|
readonly accountAuthorizationCid: string;
|
|
865
876
|
/** Recipient-owned `credentials` space covered by the account authorization. */
|
|
866
877
|
readonly credentialSpaceId: string;
|
|
878
|
+
/** See {@link AdmitPolicyCredentialV4Input.requestedExpiresAt}. */
|
|
879
|
+
readonly requestedExpiresAt?: string | null;
|
|
867
880
|
readonly fetch?: typeof fetch;
|
|
868
881
|
readonly signal?: AbortSignal;
|
|
869
882
|
}
|
|
@@ -885,6 +898,13 @@ interface AdmitPolicyCredentialV4Input extends Omit<BuildPolicyCredentialPresent
|
|
|
885
898
|
readonly nodeOrigin: string;
|
|
886
899
|
/** Path to the embedded Node policy runtime. Defaults to `/policy/v3`. */
|
|
887
900
|
readonly policyRuntimePath?: string;
|
|
901
|
+
/**
|
|
902
|
+
* How long the minted session should last. Defaults to the policy's own
|
|
903
|
+
* expiry, the longest the Node will grant; it caps the session at the
|
|
904
|
+
* policy, its roots and any account authorization. `null` asks for the
|
|
905
|
+
* legacy 60-second session.
|
|
906
|
+
*/
|
|
907
|
+
readonly requestedExpiresAt?: string | null;
|
|
888
908
|
readonly fetch?: typeof fetch;
|
|
889
909
|
readonly signal?: AbortSignal;
|
|
890
910
|
}
|
|
@@ -898,4 +918,4 @@ interface PolicyCredentialAdmissionV4 {
|
|
|
898
918
|
/** Accountless admission. The request deliberately has no account custody fields. */
|
|
899
919
|
declare function admitPolicyCredentialV4(input: AdmitPolicyCredentialV4Input): Promise<PolicyCredentialAdmissionV4>;
|
|
900
920
|
|
|
901
|
-
export { type
|
|
921
|
+
export { type RegisterPolicyV3Input as $, ATTESTED_ENFORCER_BINDING_V2_SCHEMA as A, type BuildPolicyCredentialPresentationV3Input as B, CONTENT_SOURCE_V1_DOMAIN as C, type PolicyChallengeV3 as D, ED25519_JCS_SIGNATURE_SUITE as E, type PolicyCredentialAdmissionV3 as F, type PolicyCredentialAdmissionV4 as G, type PolicyCredentialPresentationV3 as H, type PolicyCredentialPresentationV4 as I, type JsonObject as J, type PolicyCredentialRequirementV1 as K, LAST_V2_CREATE_AT as L, MAX_LEGACY_ENVELOPE_EXPIRES_AT as M, NATIVE_PROJECTION_V1_DOMAIN as N, type PolicyRootStatusV3 as O, type PolicyEngineRecord as P, type PolicyRootV3 as Q, type PolicySessionUcanFactV1 as R, type SignedObjectSigner as S, type PolicySessionUcanV1 as T, type UnsignedPolicyEngineRecord as U, type PolicyStatus as V, ROOT_REVOCATION_V1_DOMAIN as W, ROOT_REVOCATION_V1_SCHEMA as X, ROOT_STATUS_CHECKPOINT_V1_SCHEMA as Y, ROOT_STATUS_RENEWAL_V1_DOMAIN as Z, ROOT_STATUS_V1_DOMAIN as _, type Policy as a, signCompactPolicyDescendant as a$, type RegisterPolicyV3Receipt as a0, type SignCompactUcanAuthorizationInput as a1, type SignCompactUcanRootAuthorizationInput as a2, SignatureMaterialError as a3, type SignatureSuite as a4, SignatureVerificationError as a5, SignedObjectCanonicalizationError as a6, SignedObjectDigestError as a7, type SignedObjectErrorCode as a8, SignedObjectIdError as a9, canonicalizeSignedObjectUnsigned as aA, canonicalizeUnifiedPolicyCapability as aB, compactAttenuationContains as aC, contentSourceDigestHex as aD, createAndSignPolicy as aE, createAndSignPolicyEngineRecord as aF, createAndSignPolicyStatus as aG, createAndSignSignedObject as aH, createCompactPolicyDescendant as aI, createCompactPolicyInvocation as aJ, deriveSignedObjectMaterial as aK, getPolicyRootStatusV3 as aL, issuedCredentialEnvelopeFromVerified as aM, mintPolicySessionV3 as aN, normalizeUnifiedPolicyCapability as aO, parseCompactUcanAuthorization as aP, parsePolicySessionUcan as aQ, policyCidFromCanonicalBytes as aR, policyDigestHex as aS, policyIdForDigestHex as aT, policyV2DigestHex as aU, projectUnifiedPolicyCapabilities as aV, projectUnifiedPolicyCapability as aW, registerPolicyV3 as aX, renewPolicyRootStatusV3 as aY, requestPolicyChallengeV3 as aZ, revokePolicyRootV3 as a_, type SignedObjectKind as aa, type SignedObjectMaterial as ab, SignedObjectProfileError as ac, SignedObjectSchemaError as ad, type SignedObjectSignature as ae, type SignedObjectVerificationResult as af, type SignedPolicyObject as ag, SigningKeyBindingError as ah, type UnifiedContentSource as ai, type UnifiedEncryptionCapability as aj, type UnifiedKvCapability as ak, type UnifiedNativeCapability as al, type UnifiedPolicyCapability as am, type UnifiedPolicyV1 as an, type UnifiedPolicyV2 as ao, type UnifiedResourceSelector as ap, type UnsignedPolicy as aq, type UnsignedPolicyCredentialPresentationV4 as ar, type UnsignedPolicyObject as as, type UnsignedPolicyStatus as at, type UnsignedUnifiedPolicyV2 as au, UnsupportedSignatureSuiteError as av, admitPolicyCredentialV3 as aw, admitPolicyCredentialV4 as ax, buildPolicyCredentialPresentationV3 as ay, buildPolicyCredentialPresentationV4 as az, type AdmitPolicyCredentialV3Input as b, signCompactUcanAuthorization as b0, signCompactUcanRootAuthorization as b1, signPolicyCredentialPresentationV4 as b2, signedObjectIdFor as b3, toSignedObjectError as b4, unifiedNativeProjectionHashHex as b5, unifiedPolicyCapabilityContains as b6, unifiedPolicyCapabilityDigestHex as b7, unifiedPolicyCapabilityFromNative as b8, validatePolicyCredentialRequirementV1 as b9, CREDENTIAL_FORMAT as bA, CREDENTIAL_STEP_REGISTRY_VERSION as bB, type CredentialClaimDescriptor as bC, type CredentialEndpointId as bD, type CredentialInputDescriptor as bE, type CredentialProgressEvent as bF, type CredentialStepDescriptor as bG, type CredentialStepType as bH, type CredentialUxState as bI, HOLDER_BINDING_DOMAIN as bJ, type IssuerVerificationKey as bK, validatePolicyEngineRecordSigned as ba, validatePolicyEngineRecordSignedShape as bb, validatePolicyEngineRecordUnsigned as bc, validatePolicySigned as bd, validatePolicySignedShape as be, validatePolicyStatusSigned as bf, validatePolicyStatusSignedShape as bg, validatePolicyStatusUnsigned as bh, validatePolicyUnsigned as bi, validateUnifiedPolicyV2 as bj, verifyPolicy as bk, verifyPolicyEngineRecord as bl, verifyPolicyRootRevocationV3 as bm, verifyPolicyRootStatusCheckpointV3 as bn, verifyPolicyStatus as bo, verifySignedObject as bp, type CredentialHolderBinding as bq, type CredentialFlowDescriptor as br, type CredentialRequirement as bs, type StoredCredentialRecord as bt, type VerifiedCredential as bu, type CredentialStorageReceipt as bv, type IssuedCredentialEnvelope as bw, type CredentialIssuerMetadata as bx, CREDENTIAL_ACQUISITION_PROTOCOL as by, CREDENTIAL_CONTRACT_VERSION as bz, type AdmitPolicyCredentialV4Input as c, type AttestedEnforcerBindingV2 as d, type BuildPolicyCredentialPresentationV4Input as e, type CompactPolicyDescendantInput as f, type CompactPolicyInvocationInput as g, type CompactUcanAuthorizationV1 as h, EIP191_JCS_SIGNATURE_SUITE as i, LAST_V2_READ_AT as j, POLICY_CAPABILITY_V1_DOMAIN as k, POLICY_CAPABILITY_V1_SCHEMA as l, POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE as m, POLICY_ENFORCEMENT_DELEGATION_V2_SCHEMA as n, POLICY_ENGINE_RECORD_SCHEMA as o, POLICY_PRESENTATION_V3_DOMAIN as p, POLICY_PRESENTATION_V3_SCHEMA as q, POLICY_PRESENTATION_V4_DOMAIN as r, POLICY_PRESENTATION_V4_SCHEMA as s, POLICY_SCHEMA as t, POLICY_SESSION_UCAN_V1_PROFILE as u, POLICY_STATUS_SCHEMA as v, POLICY_V1_DOMAIN as w, POLICY_V1_SCHEMA as x, POLICY_V2_DOMAIN as y, POLICY_V2_SCHEMA as z };
|
|
@@ -718,17 +718,28 @@ interface CompactPolicyInvocationInput {
|
|
|
718
718
|
}
|
|
719
719
|
/** Sign a fresh one-parent ordinary invocation; S0 itself is never a bearer. */
|
|
720
720
|
declare function createCompactPolicyInvocation(input: CompactPolicyInvocationInput): CompactUcanAuthorizationV1;
|
|
721
|
-
|
|
721
|
+
interface CompactPolicyDescendantInput {
|
|
722
722
|
readonly parentAuthorization: string;
|
|
723
723
|
readonly parentCid: string;
|
|
724
724
|
readonly issuerDid: string;
|
|
725
725
|
readonly audienceDid: string;
|
|
726
726
|
readonly attenuation: Readonly<Record<string, Readonly<Record<string, readonly unknown[]>>>>;
|
|
727
|
-
|
|
727
|
+
/** Start of the window; defaults to one second after the parent's start. */
|
|
728
728
|
readonly now?: number;
|
|
729
|
+
/** Defaults to the longest window the parent allows: one second inside it. */
|
|
729
730
|
readonly expiresAt?: number;
|
|
730
731
|
readonly nonce?: string;
|
|
732
|
+
}
|
|
733
|
+
declare function createCompactPolicyDescendant(input: CompactPolicyDescendantInput & {
|
|
734
|
+
readonly privateKey: Uint8Array;
|
|
731
735
|
}): CompactUcanAuthorizationV1;
|
|
736
|
+
/**
|
|
737
|
+
* The same descendant, signed by a caller-owned key that may be
|
|
738
|
+
* non-extractable. The result is verified against the issuer DID.
|
|
739
|
+
*/
|
|
740
|
+
declare function signCompactPolicyDescendant(input: CompactPolicyDescendantInput & {
|
|
741
|
+
readonly sign: (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
742
|
+
}): Promise<CompactUcanAuthorizationV1>;
|
|
732
743
|
/** Byte-independent semantic containment shared by S0, descendants and mint requests. */
|
|
733
744
|
declare function compactAttenuationContains(parent: Readonly<Record<string, Readonly<Record<string, readonly unknown[]>>>>, child: Readonly<Record<string, Readonly<Record<string, readonly unknown[]>>>>): boolean;
|
|
734
745
|
declare function parseCompactUcanAuthorization(input: string, expectedCid?: string): CompactUcanAuthorizationV1;
|
|
@@ -864,6 +875,8 @@ interface AdmitPolicyCredentialV3Input extends Omit<BuildPolicyCredentialPresent
|
|
|
864
875
|
readonly accountAuthorizationCid: string;
|
|
865
876
|
/** Recipient-owned `credentials` space covered by the account authorization. */
|
|
866
877
|
readonly credentialSpaceId: string;
|
|
878
|
+
/** See {@link AdmitPolicyCredentialV4Input.requestedExpiresAt}. */
|
|
879
|
+
readonly requestedExpiresAt?: string | null;
|
|
867
880
|
readonly fetch?: typeof fetch;
|
|
868
881
|
readonly signal?: AbortSignal;
|
|
869
882
|
}
|
|
@@ -885,6 +898,13 @@ interface AdmitPolicyCredentialV4Input extends Omit<BuildPolicyCredentialPresent
|
|
|
885
898
|
readonly nodeOrigin: string;
|
|
886
899
|
/** Path to the embedded Node policy runtime. Defaults to `/policy/v3`. */
|
|
887
900
|
readonly policyRuntimePath?: string;
|
|
901
|
+
/**
|
|
902
|
+
* How long the minted session should last. Defaults to the policy's own
|
|
903
|
+
* expiry, the longest the Node will grant; it caps the session at the
|
|
904
|
+
* policy, its roots and any account authorization. `null` asks for the
|
|
905
|
+
* legacy 60-second session.
|
|
906
|
+
*/
|
|
907
|
+
readonly requestedExpiresAt?: string | null;
|
|
888
908
|
readonly fetch?: typeof fetch;
|
|
889
909
|
readonly signal?: AbortSignal;
|
|
890
910
|
}
|
|
@@ -898,4 +918,4 @@ interface PolicyCredentialAdmissionV4 {
|
|
|
898
918
|
/** Accountless admission. The request deliberately has no account custody fields. */
|
|
899
919
|
declare function admitPolicyCredentialV4(input: AdmitPolicyCredentialV4Input): Promise<PolicyCredentialAdmissionV4>;
|
|
900
920
|
|
|
901
|
-
export { type
|
|
921
|
+
export { type RegisterPolicyV3Input as $, ATTESTED_ENFORCER_BINDING_V2_SCHEMA as A, type BuildPolicyCredentialPresentationV3Input as B, CONTENT_SOURCE_V1_DOMAIN as C, type PolicyChallengeV3 as D, ED25519_JCS_SIGNATURE_SUITE as E, type PolicyCredentialAdmissionV3 as F, type PolicyCredentialAdmissionV4 as G, type PolicyCredentialPresentationV3 as H, type PolicyCredentialPresentationV4 as I, type JsonObject as J, type PolicyCredentialRequirementV1 as K, LAST_V2_CREATE_AT as L, MAX_LEGACY_ENVELOPE_EXPIRES_AT as M, NATIVE_PROJECTION_V1_DOMAIN as N, type PolicyRootStatusV3 as O, type PolicyEngineRecord as P, type PolicyRootV3 as Q, type PolicySessionUcanFactV1 as R, type SignedObjectSigner as S, type PolicySessionUcanV1 as T, type UnsignedPolicyEngineRecord as U, type PolicyStatus as V, ROOT_REVOCATION_V1_DOMAIN as W, ROOT_REVOCATION_V1_SCHEMA as X, ROOT_STATUS_CHECKPOINT_V1_SCHEMA as Y, ROOT_STATUS_RENEWAL_V1_DOMAIN as Z, ROOT_STATUS_V1_DOMAIN as _, type Policy as a, signCompactPolicyDescendant as a$, type RegisterPolicyV3Receipt as a0, type SignCompactUcanAuthorizationInput as a1, type SignCompactUcanRootAuthorizationInput as a2, SignatureMaterialError as a3, type SignatureSuite as a4, SignatureVerificationError as a5, SignedObjectCanonicalizationError as a6, SignedObjectDigestError as a7, type SignedObjectErrorCode as a8, SignedObjectIdError as a9, canonicalizeSignedObjectUnsigned as aA, canonicalizeUnifiedPolicyCapability as aB, compactAttenuationContains as aC, contentSourceDigestHex as aD, createAndSignPolicy as aE, createAndSignPolicyEngineRecord as aF, createAndSignPolicyStatus as aG, createAndSignSignedObject as aH, createCompactPolicyDescendant as aI, createCompactPolicyInvocation as aJ, deriveSignedObjectMaterial as aK, getPolicyRootStatusV3 as aL, issuedCredentialEnvelopeFromVerified as aM, mintPolicySessionV3 as aN, normalizeUnifiedPolicyCapability as aO, parseCompactUcanAuthorization as aP, parsePolicySessionUcan as aQ, policyCidFromCanonicalBytes as aR, policyDigestHex as aS, policyIdForDigestHex as aT, policyV2DigestHex as aU, projectUnifiedPolicyCapabilities as aV, projectUnifiedPolicyCapability as aW, registerPolicyV3 as aX, renewPolicyRootStatusV3 as aY, requestPolicyChallengeV3 as aZ, revokePolicyRootV3 as a_, type SignedObjectKind as aa, type SignedObjectMaterial as ab, SignedObjectProfileError as ac, SignedObjectSchemaError as ad, type SignedObjectSignature as ae, type SignedObjectVerificationResult as af, type SignedPolicyObject as ag, SigningKeyBindingError as ah, type UnifiedContentSource as ai, type UnifiedEncryptionCapability as aj, type UnifiedKvCapability as ak, type UnifiedNativeCapability as al, type UnifiedPolicyCapability as am, type UnifiedPolicyV1 as an, type UnifiedPolicyV2 as ao, type UnifiedResourceSelector as ap, type UnsignedPolicy as aq, type UnsignedPolicyCredentialPresentationV4 as ar, type UnsignedPolicyObject as as, type UnsignedPolicyStatus as at, type UnsignedUnifiedPolicyV2 as au, UnsupportedSignatureSuiteError as av, admitPolicyCredentialV3 as aw, admitPolicyCredentialV4 as ax, buildPolicyCredentialPresentationV3 as ay, buildPolicyCredentialPresentationV4 as az, type AdmitPolicyCredentialV3Input as b, signCompactUcanAuthorization as b0, signCompactUcanRootAuthorization as b1, signPolicyCredentialPresentationV4 as b2, signedObjectIdFor as b3, toSignedObjectError as b4, unifiedNativeProjectionHashHex as b5, unifiedPolicyCapabilityContains as b6, unifiedPolicyCapabilityDigestHex as b7, unifiedPolicyCapabilityFromNative as b8, validatePolicyCredentialRequirementV1 as b9, CREDENTIAL_FORMAT as bA, CREDENTIAL_STEP_REGISTRY_VERSION as bB, type CredentialClaimDescriptor as bC, type CredentialEndpointId as bD, type CredentialInputDescriptor as bE, type CredentialProgressEvent as bF, type CredentialStepDescriptor as bG, type CredentialStepType as bH, type CredentialUxState as bI, HOLDER_BINDING_DOMAIN as bJ, type IssuerVerificationKey as bK, validatePolicyEngineRecordSigned as ba, validatePolicyEngineRecordSignedShape as bb, validatePolicyEngineRecordUnsigned as bc, validatePolicySigned as bd, validatePolicySignedShape as be, validatePolicyStatusSigned as bf, validatePolicyStatusSignedShape as bg, validatePolicyStatusUnsigned as bh, validatePolicyUnsigned as bi, validateUnifiedPolicyV2 as bj, verifyPolicy as bk, verifyPolicyEngineRecord as bl, verifyPolicyRootRevocationV3 as bm, verifyPolicyRootStatusCheckpointV3 as bn, verifyPolicyStatus as bo, verifySignedObject as bp, type CredentialHolderBinding as bq, type CredentialFlowDescriptor as br, type CredentialRequirement as bs, type StoredCredentialRecord as bt, type VerifiedCredential as bu, type CredentialStorageReceipt as bv, type IssuedCredentialEnvelope as bw, type CredentialIssuerMetadata as bx, CREDENTIAL_ACQUISITION_PROTOCOL as by, CREDENTIAL_CONTRACT_VERSION as bz, type AdmitPolicyCredentialV4Input as c, type AttestedEnforcerBindingV2 as d, type BuildPolicyCredentialPresentationV4Input as e, type CompactPolicyDescendantInput as f, type CompactPolicyInvocationInput as g, type CompactUcanAuthorizationV1 as h, EIP191_JCS_SIGNATURE_SUITE as i, LAST_V2_READ_AT as j, POLICY_CAPABILITY_V1_DOMAIN as k, POLICY_CAPABILITY_V1_SCHEMA as l, POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE as m, POLICY_ENFORCEMENT_DELEGATION_V2_SCHEMA as n, POLICY_ENGINE_RECORD_SCHEMA as o, POLICY_PRESENTATION_V3_DOMAIN as p, POLICY_PRESENTATION_V3_SCHEMA as q, POLICY_PRESENTATION_V4_DOMAIN as r, POLICY_PRESENTATION_V4_SCHEMA as s, POLICY_SCHEMA as t, POLICY_SESSION_UCAN_V1_PROFILE as u, POLICY_STATUS_SCHEMA as v, POLICY_V1_DOMAIN as w, POLICY_V1_SCHEMA as x, POLICY_V2_DOMAIN as y, POLICY_V2_SCHEMA as z };
|
|
@@ -4005,6 +4005,7 @@ var CompactPayloadSchema = import_zod4.z.object({
|
|
|
4005
4005
|
nnc: import_zod4.z.string().min(1),
|
|
4006
4006
|
prf: import_zod4.z.array(import_zod4.z.string().min(1))
|
|
4007
4007
|
}).strict();
|
|
4008
|
+
var MAX_POLICY_ROOT_SECONDS = 31 * 24 * 60 * 60;
|
|
4008
4009
|
function createCompactPolicyInvocation(input) {
|
|
4009
4010
|
const session = parsePolicySessionUcan(input.sessionAuthorization);
|
|
4010
4011
|
if (session.cid !== input.sessionCid || session.aud !== input.recipientDid)
|
|
@@ -4036,7 +4037,7 @@ function createCompactPolicyInvocation(input) {
|
|
|
4036
4037
|
const signature = import_ed255192.ed25519.sign(signingInput, input.privateKey);
|
|
4037
4038
|
return parseCompactUcanAuthorization(`${protectedSegment}.${payloadSegment}.${encodeBase64Url(signature)}`);
|
|
4038
4039
|
}
|
|
4039
|
-
function
|
|
4040
|
+
function compactPolicyDescendantClaims(input) {
|
|
4040
4041
|
const parent = parseCompactUcanAuthorization(input.parentAuthorization, input.parentCid);
|
|
4041
4042
|
if (parent.payload.aud !== input.issuerDid) throw new Error("policy descendant issuer is not the parent audience");
|
|
4042
4043
|
const parentFact = parent.payload.fct[0];
|
|
@@ -4044,23 +4045,33 @@ function createCompactPolicyDescendant(input) {
|
|
|
4044
4045
|
if (!Number.isInteger(depth) || depth <= 0) throw new Error("policy descendant depth is exhausted");
|
|
4045
4046
|
if (!compactAttenuationContains(parent.payload.att, input.attenuation))
|
|
4046
4047
|
throw new Error("policy descendant exceeds the parent attenuation");
|
|
4048
|
+
const now = Math.max(input.now ?? parent.payload.nbf + 1, parent.payload.nbf + 1);
|
|
4049
|
+
const exp = Math.min(input.expiresAt ?? parent.payload.exp - 1, parent.payload.exp - 1);
|
|
4050
|
+
if (exp <= now) throw new Error("policy parent has no strictly narrower validity window");
|
|
4051
|
+
return {
|
|
4052
|
+
parentCid: parent.cid,
|
|
4053
|
+
fact: { ...parentFact, remainingRedelegationDepth: depth - 1 },
|
|
4054
|
+
notBefore: now,
|
|
4055
|
+
expiresAt: exp,
|
|
4056
|
+
nonce: input.nonce ?? encodeBase64Url(crypto.getRandomValues(new Uint8Array(16)))
|
|
4057
|
+
};
|
|
4058
|
+
}
|
|
4059
|
+
function createCompactPolicyDescendant(input) {
|
|
4060
|
+
const claims = compactPolicyDescendantClaims(input);
|
|
4047
4061
|
const principal = input.issuerDid.split("#", 1)[0];
|
|
4048
4062
|
const didMaterial = base58btc.decode(principal.slice("did:key:".length));
|
|
4049
4063
|
const publicKey = import_ed255192.ed25519.getPublicKey(input.privateKey);
|
|
4050
4064
|
if (didMaterial.length !== 34 || !equalBytes2(publicKey, didMaterial.slice(2))) throw new Error("policy descendant signer does not bind issuer DID");
|
|
4051
|
-
const now = Math.max(input.now ?? Math.floor(Date.now() / 1e3), parent.payload.nbf + 1);
|
|
4052
|
-
const exp = Math.min(input.expiresAt ?? now + 60, now + 60, parent.payload.exp - 1);
|
|
4053
|
-
if (exp <= now) throw new Error("policy parent has no strictly narrower validity window");
|
|
4054
4065
|
const header = { alg: "EdDSA", jwk: { alg: "EdDSA", crv: "Ed25519", kty: "OKP", x: encodeBase64Url(publicKey) }, typ: "JWT", ucv: "0.10.0" };
|
|
4055
4066
|
const payload = {
|
|
4056
4067
|
att: input.attenuation,
|
|
4057
4068
|
aud: input.audienceDid,
|
|
4058
|
-
exp,
|
|
4059
|
-
fct: [
|
|
4069
|
+
exp: claims.expiresAt,
|
|
4070
|
+
fct: [claims.fact],
|
|
4060
4071
|
iss: input.issuerDid.includes("#") ? input.issuerDid : `${principal}#${principal.slice("did:key:".length)}`,
|
|
4061
|
-
nbf:
|
|
4062
|
-
nnc:
|
|
4063
|
-
prf: [
|
|
4072
|
+
nbf: claims.notBefore,
|
|
4073
|
+
nnc: claims.nonce,
|
|
4074
|
+
prf: [claims.parentCid]
|
|
4064
4075
|
};
|
|
4065
4076
|
const protectedSegment = encodeBase64Url(new TextEncoder().encode(jcsCanonicalize(header)));
|
|
4066
4077
|
const payloadSegment = encodeBase64Url(new TextEncoder().encode(jcsCanonicalize(payload)));
|
|
@@ -4136,7 +4147,7 @@ function parsePolicySessionUcan(authorization, expectedProofs) {
|
|
|
4136
4147
|
throw new Error("policy session UCAN fact is incomplete");
|
|
4137
4148
|
if (hasV4AuditFactShape && (!LOWER_SHA256_HEX.test(fact.credentialIdAuditDigestHex) || !LOWER_SHA256_HEX.test(fact.presentationJtiAuditDigestHex)))
|
|
4138
4149
|
throw new Error("policy session UCAN v4 audit facts are invalid");
|
|
4139
|
-
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 >
|
|
4150
|
+
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 > MAX_POLICY_ROOT_SECONDS || parsed.payload.iss.split("#", 1)[0] !== fact.nodeAudience || parsed.payload.aud !== fact.recipientDid)
|
|
4140
4151
|
throw new Error("policy session UCAN fact is invalid");
|
|
4141
4152
|
return {
|
|
4142
4153
|
authorization,
|
|
@@ -5599,11 +5610,11 @@ var SharingService = class {
|
|
|
5599
5610
|
}
|
|
5600
5611
|
return result;
|
|
5601
5612
|
};
|
|
5602
|
-
const canSatisfyFromRegistry = this.
|
|
5613
|
+
const canSatisfyFromRegistry = this.classifyDelegationAuthority(
|
|
5603
5614
|
fullPath,
|
|
5604
5615
|
actions,
|
|
5605
5616
|
requestedExpiry
|
|
5606
|
-
);
|
|
5617
|
+
) === "ok";
|
|
5607
5618
|
if (canSatisfyFromRegistry) {
|
|
5608
5619
|
const delegationResult = await this.createSessionDelegation(plainDID, fullPath, actions, expiry);
|
|
5609
5620
|
const childDelegationActiveError = this.retiredGraphError();
|
|
@@ -5673,49 +5684,58 @@ var SharingService = class {
|
|
|
5673
5684
|
return { ok: true, data: shareLink };
|
|
5674
5685
|
}
|
|
5675
5686
|
/**
|
|
5676
|
-
*
|
|
5677
|
-
*
|
|
5678
|
-
*
|
|
5679
|
-
*
|
|
5680
|
-
*
|
|
5681
|
-
*
|
|
5687
|
+
* Report, without side effects, whether this session's registry authority
|
|
5688
|
+
* can issue the child delegation {@link generate} would create for the same
|
|
5689
|
+
* `path`, `actions` and `expiry` (defaults and `pathPrefix` applied the
|
|
5690
|
+
* same way):
|
|
5691
|
+
*
|
|
5692
|
+
* - `"ok"`: an uncaveated entry covers it.
|
|
5693
|
+
* - `"caveated"`: only caveated entries cover it. SharingService cannot
|
|
5694
|
+
* carry signed ReCap caveats into a child delegation.
|
|
5695
|
+
* - `"not-covered"`: no entry covers it, or there is no session.
|
|
5696
|
+
*
|
|
5697
|
+
* It does not consult `onRootDelegationNeeded`, so a signer-backed session
|
|
5698
|
+
* may still generate when this is not `"ok"`.
|
|
5699
|
+
*/
|
|
5700
|
+
preflightGenerate(params) {
|
|
5701
|
+
if (!this.session || !params.path) return "not-covered";
|
|
5702
|
+
const fullPath = this.pathPrefix ? `${this.pathPrefix}/${params.path}`.replace(/\/+/g, "/") : params.path;
|
|
5703
|
+
return this.classifyDelegationAuthority(
|
|
5704
|
+
fullPath,
|
|
5705
|
+
params.actions ?? DEFAULT_READ_ACTIONS,
|
|
5706
|
+
params.expiry ?? new Date(Date.now() + DEFAULT_EXPIRY_MS)
|
|
5707
|
+
);
|
|
5708
|
+
}
|
|
5709
|
+
/**
|
|
5710
|
+
* Classify the registry's authority for a child delegation. An entry
|
|
5711
|
+
* satisfies it when it is in the session space, valid, lasts at least until
|
|
5712
|
+
* `requestedExpiry`, allows sub-delegation, covers `path` (exact or parent)
|
|
5713
|
+
* and grants every action. Satisfying entries with caveats are unusable.
|
|
5682
5714
|
* @internal
|
|
5683
5715
|
*/
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
for (const key of
|
|
5687
|
-
const
|
|
5688
|
-
for (const delegation of delegations) {
|
|
5716
|
+
classifyDelegationAuthority(path, actions, requestedExpiry) {
|
|
5717
|
+
let coveredOnlyByCaveated = false;
|
|
5718
|
+
for (const key of this.registry.getAllKeys()) {
|
|
5719
|
+
for (const delegation of this.registry.getDelegationsForKey(key.id)) {
|
|
5689
5720
|
if (delegation.spaceId === void 0 || !spaceIdsEqual(delegation.spaceId, this.session?.spaceId ?? "")) {
|
|
5690
5721
|
continue;
|
|
5691
5722
|
}
|
|
5692
|
-
if ((delegation
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
if (!this.
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
if (delegation.expiry < requestedExpiry) {
|
|
5699
|
-
continue;
|
|
5700
|
-
}
|
|
5701
|
-
if (delegation.allowSubDelegation === false) {
|
|
5702
|
-
continue;
|
|
5703
|
-
}
|
|
5704
|
-
const delegationPath = delegation.path || "";
|
|
5705
|
-
if (!this.pathMatches(delegationPath, path)) {
|
|
5723
|
+
if (!this.registry.isDelegationValid(delegation)) continue;
|
|
5724
|
+
if (delegation.expiry < requestedExpiry) continue;
|
|
5725
|
+
if (delegation.allowSubDelegation === false) continue;
|
|
5726
|
+
if (!this.pathMatches(delegation.path || "", path)) continue;
|
|
5727
|
+
const delegationActions = delegation.actions || [];
|
|
5728
|
+
if (!actions.every((action) => delegationActions.includes(action) || delegationActions.includes("*"))) {
|
|
5706
5729
|
continue;
|
|
5707
5730
|
}
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
(action) => delegationActions.includes(action) || delegationActions.includes("*")
|
|
5711
|
-
);
|
|
5712
|
-
if (!hasAllActions) {
|
|
5731
|
+
if ((delegation.caveats?.length ?? 0) > 0) {
|
|
5732
|
+
coveredOnlyByCaveated = true;
|
|
5713
5733
|
continue;
|
|
5714
5734
|
}
|
|
5715
|
-
return
|
|
5735
|
+
return "ok";
|
|
5716
5736
|
}
|
|
5717
5737
|
}
|
|
5718
|
-
return
|
|
5738
|
+
return coveredOnlyByCaveated ? "caveated" : "not-covered";
|
|
5719
5739
|
}
|
|
5720
5740
|
retiredGraphError() {
|
|
5721
5741
|
try {
|