@tinycloud/sdk-core 3.0.0-beta.6 → 3.0.0-beta.8
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 +32 -60
- 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 +32 -60
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +192 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +193 -67
- 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-BdCeDExl.d.cts → recipient-types.schema-DjmM_yJu.d.cts} +37 -37
- package/dist/{recipient-types.schema-BdCeDExl.d.ts → recipient-types.schema-DjmM_yJu.d.ts} +37 -37
- package/package.json +4 -4
|
@@ -445,6 +445,43 @@ interface UnifiedPolicyV1 {
|
|
|
445
445
|
readonly value: string;
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
|
+
interface PolicyRootV3 {
|
|
449
|
+
readonly cid: string;
|
|
450
|
+
readonly authorization: string;
|
|
451
|
+
}
|
|
452
|
+
interface RegisterPolicyV3Input {
|
|
453
|
+
readonly nodeOrigin: string;
|
|
454
|
+
readonly policyCid: string;
|
|
455
|
+
readonly policy: Readonly<Record<string, unknown>>;
|
|
456
|
+
readonly policyRoot: PolicyRootV3;
|
|
457
|
+
readonly enforcementRoot: PolicyRootV3;
|
|
458
|
+
readonly contentSourceDigestHex: string;
|
|
459
|
+
readonly nativeProjectionHashHex: string;
|
|
460
|
+
readonly rootExpiresAt: string;
|
|
461
|
+
readonly enforcerDid: string;
|
|
462
|
+
readonly expectedNodeAudience: string;
|
|
463
|
+
readonly fetch?: typeof fetch;
|
|
464
|
+
readonly signal?: AbortSignal;
|
|
465
|
+
}
|
|
466
|
+
interface AttestedEnforcerBindingV2 {
|
|
467
|
+
readonly schema: "xyz.tinycloud.policy/attested-enforcer/v2";
|
|
468
|
+
readonly enforcerDid: string;
|
|
469
|
+
readonly nodeAudience: string;
|
|
470
|
+
readonly attestationBindingDigestHex: string;
|
|
471
|
+
readonly issuedAt: string;
|
|
472
|
+
readonly expiresAt: string;
|
|
473
|
+
readonly signature: {
|
|
474
|
+
readonly suite: "Ed25519";
|
|
475
|
+
readonly signerDid: string;
|
|
476
|
+
readonly value: string;
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
interface RegisterPolicyV3Receipt {
|
|
480
|
+
readonly policyCid: string;
|
|
481
|
+
readonly policyRootCid: string;
|
|
482
|
+
readonly enforcementRootCid: string;
|
|
483
|
+
readonly attestedEnforcerBinding: AttestedEnforcerBindingV2;
|
|
484
|
+
}
|
|
448
485
|
type PolicySessionUcanFactV1 = Readonly<Record<string, unknown>> & {
|
|
449
486
|
/** Present only on accountless PolicyCredentialPresentation/v4 admissions. */
|
|
450
487
|
readonly credentialIdAuditDigestHex?: string;
|
|
@@ -474,6 +511,12 @@ interface PolicyChallengeV3 {
|
|
|
474
511
|
}
|
|
475
512
|
declare function requestPolicyChallengeV3(input: {
|
|
476
513
|
readonly nodeOrigin: string;
|
|
514
|
+
/**
|
|
515
|
+
* Policy control routes are part of the recipient's TinyCloud Node. This is
|
|
516
|
+
* deliberately a path, not a second origin: applications must not send a
|
|
517
|
+
* credential presentation to a separately discovered policy service.
|
|
518
|
+
*/
|
|
519
|
+
readonly policyRuntimePath?: string;
|
|
477
520
|
readonly policyCid: string;
|
|
478
521
|
readonly recipientDid: string;
|
|
479
522
|
readonly requestedCapabilities: readonly UnifiedPolicyCapability[];
|
|
@@ -551,6 +594,12 @@ declare function projectUnifiedPolicyCapabilities(input: readonly unknown[]): Un
|
|
|
551
594
|
declare function unifiedNativeProjectionHashHex(input: readonly unknown[]): string;
|
|
552
595
|
declare function unifiedPolicyCapabilityFromNative(input: unknown): UnifiedPolicyCapability;
|
|
553
596
|
declare function contentSourceDigestHex(input: UnifiedContentSource): string;
|
|
597
|
+
/**
|
|
598
|
+
* Register a signed policy and its sibling roots with the embedded Node
|
|
599
|
+
* Policy/v3 runtime. This is intentionally application-neutral: callers
|
|
600
|
+
* supply policy material, while Node owns both transport endpoints.
|
|
601
|
+
*/
|
|
602
|
+
declare function registerPolicyV3(input: RegisterPolicyV3Input): Promise<RegisterPolicyV3Receipt>;
|
|
554
603
|
declare function policyDigestHex(policy: Omit<UnifiedPolicyV1, "policyId" | "signature">): string;
|
|
555
604
|
declare function policyIdForDigestHex(digestHex: string): string;
|
|
556
605
|
declare function policyCidFromCanonicalBytes(bytes: Uint8Array): string;
|
|
@@ -809,6 +858,8 @@ interface AdmitPolicyCredentialV3Input extends Omit<BuildPolicyCredentialPresent
|
|
|
809
858
|
readonly policyRootCid: string;
|
|
810
859
|
readonly enforcementRootCid: string;
|
|
811
860
|
readonly nodeOrigin: string;
|
|
861
|
+
/** Path to the embedded Node policy runtime. Defaults to `/policy/v3`. */
|
|
862
|
+
readonly policyRuntimePath?: string;
|
|
812
863
|
/** Root authorization CID of the recipient's active TinyCloud account session. */
|
|
813
864
|
readonly accountAuthorizationCid: string;
|
|
814
865
|
/** Recipient-owned `credentials` space covered by the account authorization. */
|
|
@@ -832,6 +883,8 @@ interface AdmitPolicyCredentialV4Input extends Omit<BuildPolicyCredentialPresent
|
|
|
832
883
|
readonly expectedNodeAudience: string;
|
|
833
884
|
readonly expectedEnforcerDid: string;
|
|
834
885
|
readonly nodeOrigin: string;
|
|
886
|
+
/** Path to the embedded Node policy runtime. Defaults to `/policy/v3`. */
|
|
887
|
+
readonly policyRuntimePath?: string;
|
|
835
888
|
readonly fetch?: typeof fetch;
|
|
836
889
|
readonly signal?: AbortSignal;
|
|
837
890
|
}
|
|
@@ -839,8 +892,10 @@ interface PolicyCredentialAdmissionV4 {
|
|
|
839
892
|
readonly challenge: PolicyChallengeV3;
|
|
840
893
|
readonly presentation: PolicyCredentialPresentationV4;
|
|
841
894
|
readonly session: PolicySessionUcanV1;
|
|
895
|
+
/** The ordinary delegation has been activated using Node's generic `/delegate`. */
|
|
896
|
+
readonly delegationImported: true;
|
|
842
897
|
}
|
|
843
898
|
/** Accountless admission. The request deliberately has no account custody fields. */
|
|
844
899
|
declare function admitPolicyCredentialV4(input: AdmitPolicyCredentialV4Input): Promise<PolicyCredentialAdmissionV4>;
|
|
845
900
|
|
|
846
|
-
export { type
|
|
901
|
+
export { type RegisterPolicyV3Receipt as $, ATTESTED_ENFORCER_BINDING_V2_SCHEMA as A, type BuildPolicyCredentialPresentationV3Input as B, CONTENT_SOURCE_V1_DOMAIN as C, type PolicyCredentialAdmissionV3 as D, ED25519_JCS_SIGNATURE_SUITE as E, type PolicyCredentialAdmissionV4 as F, type PolicyCredentialPresentationV3 as G, type PolicyCredentialPresentationV4 as H, type PolicyCredentialRequirementV1 as I, type JsonObject as J, type PolicyRootStatusV3 as K, LAST_V2_CREATE_AT as L, MAX_LEGACY_ENVELOPE_EXPIRES_AT as M, NATIVE_PROJECTION_V1_DOMAIN as N, type PolicyRootV3 as O, type PolicyEngineRecord as P, type PolicySessionUcanFactV1 as Q, type PolicySessionUcanV1 as R, type SignedObjectSigner as S, type PolicyStatus as T, type UnsignedPolicyEngineRecord as U, ROOT_REVOCATION_V1_DOMAIN as V, ROOT_REVOCATION_V1_SCHEMA as W, ROOT_STATUS_CHECKPOINT_V1_SCHEMA as X, ROOT_STATUS_RENEWAL_V1_DOMAIN as Y, ROOT_STATUS_V1_DOMAIN as Z, type RegisterPolicyV3Input as _, type Policy as a, signCompactUcanRootAuthorization as a$, type SignCompactUcanAuthorizationInput as a0, type SignCompactUcanRootAuthorizationInput as a1, SignatureMaterialError as a2, type SignatureSuite as a3, SignatureVerificationError as a4, SignedObjectCanonicalizationError as a5, SignedObjectDigestError as a6, type SignedObjectErrorCode as a7, SignedObjectIdError as a8, type SignedObjectKind as a9, canonicalizeUnifiedPolicyCapability as aA, compactAttenuationContains as aB, contentSourceDigestHex as aC, createAndSignPolicy as aD, createAndSignPolicyEngineRecord as aE, createAndSignPolicyStatus as aF, createAndSignSignedObject as aG, createCompactPolicyDescendant as aH, createCompactPolicyInvocation as aI, deriveSignedObjectMaterial as aJ, getPolicyRootStatusV3 as aK, issuedCredentialEnvelopeFromVerified as aL, mintPolicySessionV3 as aM, normalizeUnifiedPolicyCapability as aN, parseCompactUcanAuthorization as aO, parsePolicySessionUcan as aP, policyCidFromCanonicalBytes as aQ, policyDigestHex as aR, policyIdForDigestHex as aS, policyV2DigestHex as aT, projectUnifiedPolicyCapabilities as aU, projectUnifiedPolicyCapability as aV, registerPolicyV3 as aW, renewPolicyRootStatusV3 as aX, requestPolicyChallengeV3 as aY, revokePolicyRootV3 as aZ, signCompactUcanAuthorization as a_, type SignedObjectMaterial as aa, SignedObjectProfileError as ab, SignedObjectSchemaError as ac, type SignedObjectSignature as ad, type SignedObjectVerificationResult as ae, type SignedPolicyObject as af, SigningKeyBindingError as ag, type UnifiedContentSource as ah, type UnifiedEncryptionCapability as ai, type UnifiedKvCapability as aj, type UnifiedNativeCapability as ak, type UnifiedPolicyCapability as al, type UnifiedPolicyV1 as am, type UnifiedPolicyV2 as an, type UnifiedResourceSelector as ao, type UnsignedPolicy as ap, type UnsignedPolicyCredentialPresentationV4 as aq, type UnsignedPolicyObject as ar, type UnsignedPolicyStatus as as, type UnsignedUnifiedPolicyV2 as at, UnsupportedSignatureSuiteError as au, admitPolicyCredentialV3 as av, admitPolicyCredentialV4 as aw, buildPolicyCredentialPresentationV3 as ax, buildPolicyCredentialPresentationV4 as ay, canonicalizeSignedObjectUnsigned as az, type AdmitPolicyCredentialV3Input as b, signPolicyCredentialPresentationV4 as b0, signedObjectIdFor as b1, toSignedObjectError as b2, unifiedNativeProjectionHashHex as b3, unifiedPolicyCapabilityContains as b4, unifiedPolicyCapabilityDigestHex as b5, unifiedPolicyCapabilityFromNative as b6, validatePolicyCredentialRequirementV1 as b7, validatePolicyEngineRecordSigned as b8, validatePolicyEngineRecordSignedShape as b9, type CredentialClaimDescriptor as bA, type CredentialEndpointId as bB, type CredentialInputDescriptor as bC, type CredentialProgressEvent as bD, type CredentialStepDescriptor as bE, type CredentialStepType as bF, type CredentialUxState as bG, HOLDER_BINDING_DOMAIN as bH, type IssuerVerificationKey as bI, validatePolicyEngineRecordUnsigned as ba, validatePolicySigned as bb, validatePolicySignedShape as bc, validatePolicyStatusSigned as bd, validatePolicyStatusSignedShape as be, validatePolicyStatusUnsigned as bf, validatePolicyUnsigned as bg, validateUnifiedPolicyV2 as bh, verifyPolicy as bi, verifyPolicyEngineRecord as bj, verifyPolicyRootRevocationV3 as bk, verifyPolicyRootStatusCheckpointV3 as bl, verifyPolicyStatus as bm, verifySignedObject as bn, type CredentialHolderBinding as bo, type CredentialFlowDescriptor as bp, type CredentialRequirement as bq, type StoredCredentialRecord as br, type VerifiedCredential as bs, type CredentialStorageReceipt as bt, type IssuedCredentialEnvelope as bu, type CredentialIssuerMetadata as bv, CREDENTIAL_ACQUISITION_PROTOCOL as bw, CREDENTIAL_CONTRACT_VERSION as bx, CREDENTIAL_FORMAT as by, CREDENTIAL_STEP_REGISTRY_VERSION as bz, type AdmitPolicyCredentialV4Input as c, type AttestedEnforcerBindingV2 as d, type BuildPolicyCredentialPresentationV4Input as e, type CompactPolicyInvocationInput as f, type CompactUcanAuthorizationV1 as g, EIP191_JCS_SIGNATURE_SUITE as h, LAST_V2_READ_AT as i, POLICY_CAPABILITY_V1_DOMAIN as j, POLICY_CAPABILITY_V1_SCHEMA as k, POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE as l, POLICY_ENFORCEMENT_DELEGATION_V2_SCHEMA as m, POLICY_ENGINE_RECORD_SCHEMA as n, POLICY_PRESENTATION_V3_DOMAIN as o, POLICY_PRESENTATION_V3_SCHEMA as p, POLICY_PRESENTATION_V4_DOMAIN as q, POLICY_PRESENTATION_V4_SCHEMA as r, POLICY_SCHEMA as s, POLICY_SESSION_UCAN_V1_PROFILE as t, POLICY_STATUS_SCHEMA as u, POLICY_V1_DOMAIN as v, POLICY_V1_SCHEMA as w, POLICY_V2_DOMAIN as x, POLICY_V2_SCHEMA as y, type PolicyChallengeV3 as z };
|
|
@@ -445,6 +445,43 @@ interface UnifiedPolicyV1 {
|
|
|
445
445
|
readonly value: string;
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
|
+
interface PolicyRootV3 {
|
|
449
|
+
readonly cid: string;
|
|
450
|
+
readonly authorization: string;
|
|
451
|
+
}
|
|
452
|
+
interface RegisterPolicyV3Input {
|
|
453
|
+
readonly nodeOrigin: string;
|
|
454
|
+
readonly policyCid: string;
|
|
455
|
+
readonly policy: Readonly<Record<string, unknown>>;
|
|
456
|
+
readonly policyRoot: PolicyRootV3;
|
|
457
|
+
readonly enforcementRoot: PolicyRootV3;
|
|
458
|
+
readonly contentSourceDigestHex: string;
|
|
459
|
+
readonly nativeProjectionHashHex: string;
|
|
460
|
+
readonly rootExpiresAt: string;
|
|
461
|
+
readonly enforcerDid: string;
|
|
462
|
+
readonly expectedNodeAudience: string;
|
|
463
|
+
readonly fetch?: typeof fetch;
|
|
464
|
+
readonly signal?: AbortSignal;
|
|
465
|
+
}
|
|
466
|
+
interface AttestedEnforcerBindingV2 {
|
|
467
|
+
readonly schema: "xyz.tinycloud.policy/attested-enforcer/v2";
|
|
468
|
+
readonly enforcerDid: string;
|
|
469
|
+
readonly nodeAudience: string;
|
|
470
|
+
readonly attestationBindingDigestHex: string;
|
|
471
|
+
readonly issuedAt: string;
|
|
472
|
+
readonly expiresAt: string;
|
|
473
|
+
readonly signature: {
|
|
474
|
+
readonly suite: "Ed25519";
|
|
475
|
+
readonly signerDid: string;
|
|
476
|
+
readonly value: string;
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
interface RegisterPolicyV3Receipt {
|
|
480
|
+
readonly policyCid: string;
|
|
481
|
+
readonly policyRootCid: string;
|
|
482
|
+
readonly enforcementRootCid: string;
|
|
483
|
+
readonly attestedEnforcerBinding: AttestedEnforcerBindingV2;
|
|
484
|
+
}
|
|
448
485
|
type PolicySessionUcanFactV1 = Readonly<Record<string, unknown>> & {
|
|
449
486
|
/** Present only on accountless PolicyCredentialPresentation/v4 admissions. */
|
|
450
487
|
readonly credentialIdAuditDigestHex?: string;
|
|
@@ -474,6 +511,12 @@ interface PolicyChallengeV3 {
|
|
|
474
511
|
}
|
|
475
512
|
declare function requestPolicyChallengeV3(input: {
|
|
476
513
|
readonly nodeOrigin: string;
|
|
514
|
+
/**
|
|
515
|
+
* Policy control routes are part of the recipient's TinyCloud Node. This is
|
|
516
|
+
* deliberately a path, not a second origin: applications must not send a
|
|
517
|
+
* credential presentation to a separately discovered policy service.
|
|
518
|
+
*/
|
|
519
|
+
readonly policyRuntimePath?: string;
|
|
477
520
|
readonly policyCid: string;
|
|
478
521
|
readonly recipientDid: string;
|
|
479
522
|
readonly requestedCapabilities: readonly UnifiedPolicyCapability[];
|
|
@@ -551,6 +594,12 @@ declare function projectUnifiedPolicyCapabilities(input: readonly unknown[]): Un
|
|
|
551
594
|
declare function unifiedNativeProjectionHashHex(input: readonly unknown[]): string;
|
|
552
595
|
declare function unifiedPolicyCapabilityFromNative(input: unknown): UnifiedPolicyCapability;
|
|
553
596
|
declare function contentSourceDigestHex(input: UnifiedContentSource): string;
|
|
597
|
+
/**
|
|
598
|
+
* Register a signed policy and its sibling roots with the embedded Node
|
|
599
|
+
* Policy/v3 runtime. This is intentionally application-neutral: callers
|
|
600
|
+
* supply policy material, while Node owns both transport endpoints.
|
|
601
|
+
*/
|
|
602
|
+
declare function registerPolicyV3(input: RegisterPolicyV3Input): Promise<RegisterPolicyV3Receipt>;
|
|
554
603
|
declare function policyDigestHex(policy: Omit<UnifiedPolicyV1, "policyId" | "signature">): string;
|
|
555
604
|
declare function policyIdForDigestHex(digestHex: string): string;
|
|
556
605
|
declare function policyCidFromCanonicalBytes(bytes: Uint8Array): string;
|
|
@@ -809,6 +858,8 @@ interface AdmitPolicyCredentialV3Input extends Omit<BuildPolicyCredentialPresent
|
|
|
809
858
|
readonly policyRootCid: string;
|
|
810
859
|
readonly enforcementRootCid: string;
|
|
811
860
|
readonly nodeOrigin: string;
|
|
861
|
+
/** Path to the embedded Node policy runtime. Defaults to `/policy/v3`. */
|
|
862
|
+
readonly policyRuntimePath?: string;
|
|
812
863
|
/** Root authorization CID of the recipient's active TinyCloud account session. */
|
|
813
864
|
readonly accountAuthorizationCid: string;
|
|
814
865
|
/** Recipient-owned `credentials` space covered by the account authorization. */
|
|
@@ -832,6 +883,8 @@ interface AdmitPolicyCredentialV4Input extends Omit<BuildPolicyCredentialPresent
|
|
|
832
883
|
readonly expectedNodeAudience: string;
|
|
833
884
|
readonly expectedEnforcerDid: string;
|
|
834
885
|
readonly nodeOrigin: string;
|
|
886
|
+
/** Path to the embedded Node policy runtime. Defaults to `/policy/v3`. */
|
|
887
|
+
readonly policyRuntimePath?: string;
|
|
835
888
|
readonly fetch?: typeof fetch;
|
|
836
889
|
readonly signal?: AbortSignal;
|
|
837
890
|
}
|
|
@@ -839,8 +892,10 @@ interface PolicyCredentialAdmissionV4 {
|
|
|
839
892
|
readonly challenge: PolicyChallengeV3;
|
|
840
893
|
readonly presentation: PolicyCredentialPresentationV4;
|
|
841
894
|
readonly session: PolicySessionUcanV1;
|
|
895
|
+
/** The ordinary delegation has been activated using Node's generic `/delegate`. */
|
|
896
|
+
readonly delegationImported: true;
|
|
842
897
|
}
|
|
843
898
|
/** Accountless admission. The request deliberately has no account custody fields. */
|
|
844
899
|
declare function admitPolicyCredentialV4(input: AdmitPolicyCredentialV4Input): Promise<PolicyCredentialAdmissionV4>;
|
|
845
900
|
|
|
846
|
-
export { type
|
|
901
|
+
export { type RegisterPolicyV3Receipt as $, ATTESTED_ENFORCER_BINDING_V2_SCHEMA as A, type BuildPolicyCredentialPresentationV3Input as B, CONTENT_SOURCE_V1_DOMAIN as C, type PolicyCredentialAdmissionV3 as D, ED25519_JCS_SIGNATURE_SUITE as E, type PolicyCredentialAdmissionV4 as F, type PolicyCredentialPresentationV3 as G, type PolicyCredentialPresentationV4 as H, type PolicyCredentialRequirementV1 as I, type JsonObject as J, type PolicyRootStatusV3 as K, LAST_V2_CREATE_AT as L, MAX_LEGACY_ENVELOPE_EXPIRES_AT as M, NATIVE_PROJECTION_V1_DOMAIN as N, type PolicyRootV3 as O, type PolicyEngineRecord as P, type PolicySessionUcanFactV1 as Q, type PolicySessionUcanV1 as R, type SignedObjectSigner as S, type PolicyStatus as T, type UnsignedPolicyEngineRecord as U, ROOT_REVOCATION_V1_DOMAIN as V, ROOT_REVOCATION_V1_SCHEMA as W, ROOT_STATUS_CHECKPOINT_V1_SCHEMA as X, ROOT_STATUS_RENEWAL_V1_DOMAIN as Y, ROOT_STATUS_V1_DOMAIN as Z, type RegisterPolicyV3Input as _, type Policy as a, signCompactUcanRootAuthorization as a$, type SignCompactUcanAuthorizationInput as a0, type SignCompactUcanRootAuthorizationInput as a1, SignatureMaterialError as a2, type SignatureSuite as a3, SignatureVerificationError as a4, SignedObjectCanonicalizationError as a5, SignedObjectDigestError as a6, type SignedObjectErrorCode as a7, SignedObjectIdError as a8, type SignedObjectKind as a9, canonicalizeUnifiedPolicyCapability as aA, compactAttenuationContains as aB, contentSourceDigestHex as aC, createAndSignPolicy as aD, createAndSignPolicyEngineRecord as aE, createAndSignPolicyStatus as aF, createAndSignSignedObject as aG, createCompactPolicyDescendant as aH, createCompactPolicyInvocation as aI, deriveSignedObjectMaterial as aJ, getPolicyRootStatusV3 as aK, issuedCredentialEnvelopeFromVerified as aL, mintPolicySessionV3 as aM, normalizeUnifiedPolicyCapability as aN, parseCompactUcanAuthorization as aO, parsePolicySessionUcan as aP, policyCidFromCanonicalBytes as aQ, policyDigestHex as aR, policyIdForDigestHex as aS, policyV2DigestHex as aT, projectUnifiedPolicyCapabilities as aU, projectUnifiedPolicyCapability as aV, registerPolicyV3 as aW, renewPolicyRootStatusV3 as aX, requestPolicyChallengeV3 as aY, revokePolicyRootV3 as aZ, signCompactUcanAuthorization as a_, type SignedObjectMaterial as aa, SignedObjectProfileError as ab, SignedObjectSchemaError as ac, type SignedObjectSignature as ad, type SignedObjectVerificationResult as ae, type SignedPolicyObject as af, SigningKeyBindingError as ag, type UnifiedContentSource as ah, type UnifiedEncryptionCapability as ai, type UnifiedKvCapability as aj, type UnifiedNativeCapability as ak, type UnifiedPolicyCapability as al, type UnifiedPolicyV1 as am, type UnifiedPolicyV2 as an, type UnifiedResourceSelector as ao, type UnsignedPolicy as ap, type UnsignedPolicyCredentialPresentationV4 as aq, type UnsignedPolicyObject as ar, type UnsignedPolicyStatus as as, type UnsignedUnifiedPolicyV2 as at, UnsupportedSignatureSuiteError as au, admitPolicyCredentialV3 as av, admitPolicyCredentialV4 as aw, buildPolicyCredentialPresentationV3 as ax, buildPolicyCredentialPresentationV4 as ay, canonicalizeSignedObjectUnsigned as az, type AdmitPolicyCredentialV3Input as b, signPolicyCredentialPresentationV4 as b0, signedObjectIdFor as b1, toSignedObjectError as b2, unifiedNativeProjectionHashHex as b3, unifiedPolicyCapabilityContains as b4, unifiedPolicyCapabilityDigestHex as b5, unifiedPolicyCapabilityFromNative as b6, validatePolicyCredentialRequirementV1 as b7, validatePolicyEngineRecordSigned as b8, validatePolicyEngineRecordSignedShape as b9, type CredentialClaimDescriptor as bA, type CredentialEndpointId as bB, type CredentialInputDescriptor as bC, type CredentialProgressEvent as bD, type CredentialStepDescriptor as bE, type CredentialStepType as bF, type CredentialUxState as bG, HOLDER_BINDING_DOMAIN as bH, type IssuerVerificationKey as bI, validatePolicyEngineRecordUnsigned as ba, validatePolicySigned as bb, validatePolicySignedShape as bc, validatePolicyStatusSigned as bd, validatePolicyStatusSignedShape as be, validatePolicyStatusUnsigned as bf, validatePolicyUnsigned as bg, validateUnifiedPolicyV2 as bh, verifyPolicy as bi, verifyPolicyEngineRecord as bj, verifyPolicyRootRevocationV3 as bk, verifyPolicyRootStatusCheckpointV3 as bl, verifyPolicyStatus as bm, verifySignedObject as bn, type CredentialHolderBinding as bo, type CredentialFlowDescriptor as bp, type CredentialRequirement as bq, type StoredCredentialRecord as br, type VerifiedCredential as bs, type CredentialStorageReceipt as bt, type IssuedCredentialEnvelope as bu, type CredentialIssuerMetadata as bv, CREDENTIAL_ACQUISITION_PROTOCOL as bw, CREDENTIAL_CONTRACT_VERSION as bx, CREDENTIAL_FORMAT as by, CREDENTIAL_STEP_REGISTRY_VERSION as bz, type AdmitPolicyCredentialV4Input as c, type AttestedEnforcerBindingV2 as d, type BuildPolicyCredentialPresentationV4Input as e, type CompactPolicyInvocationInput as f, type CompactUcanAuthorizationV1 as g, EIP191_JCS_SIGNATURE_SUITE as h, LAST_V2_READ_AT as i, POLICY_CAPABILITY_V1_DOMAIN as j, POLICY_CAPABILITY_V1_SCHEMA as k, POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE as l, POLICY_ENFORCEMENT_DELEGATION_V2_SCHEMA as m, POLICY_ENGINE_RECORD_SCHEMA as n, POLICY_PRESENTATION_V3_DOMAIN as o, POLICY_PRESENTATION_V3_SCHEMA as p, POLICY_PRESENTATION_V4_DOMAIN as q, POLICY_PRESENTATION_V4_SCHEMA as r, POLICY_SCHEMA as s, POLICY_SESSION_UCAN_V1_PROFILE as t, POLICY_STATUS_SCHEMA as u, POLICY_V1_DOMAIN as v, POLICY_V1_SCHEMA as w, POLICY_V2_DOMAIN as x, POLICY_V2_SCHEMA as y, type PolicyChallengeV3 as z };
|
|
@@ -32,6 +32,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
32
32
|
// src/delegations/index.ts
|
|
33
33
|
var delegations_exports = {};
|
|
34
34
|
__export(delegations_exports, {
|
|
35
|
+
CREDENTIAL_INVITATION_REQUEST_DOMAIN: () => CREDENTIAL_INVITATION_REQUEST_DOMAIN,
|
|
36
|
+
DELIVERY_ADMISSION_DOMAIN: () => DELIVERY_ADMISSION_DOMAIN,
|
|
35
37
|
DelegationErrorCodes: () => DelegationErrorCodes,
|
|
36
38
|
DelegationManager: () => DelegationManager,
|
|
37
39
|
EncodedShareDataSchema: () => EncodedShareDataSchema,
|
|
@@ -46,7 +48,6 @@ __export(delegations_exports, {
|
|
|
46
48
|
MemoryShareCache: () => MemoryShareCache,
|
|
47
49
|
ReceiveOptionsSchema: () => ReceiveOptionsSchema,
|
|
48
50
|
SHARE_DELIVERY_AUTHORIZATION_DOMAIN: () => SHARE_DELIVERY_AUTHORIZATION_DOMAIN,
|
|
49
|
-
SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN: () => SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN,
|
|
50
51
|
SenderShareStore: () => SenderShareStore,
|
|
51
52
|
ShareAccessError: () => ShareAccessError,
|
|
52
53
|
ShareActionSchema: () => ShareActionSchema,
|
|
@@ -6809,40 +6810,11 @@ function shareDeliveryTrustedKid(publicKey) {
|
|
|
6809
6810
|
|
|
6810
6811
|
// src/delegations/share-delivery-v3.ts
|
|
6811
6812
|
var import_ed255198 = require("@noble/curves/ed25519");
|
|
6812
|
-
var
|
|
6813
|
-
var
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
"shareCid",
|
|
6818
|
-
"shareId",
|
|
6819
|
-
"policyCid",
|
|
6820
|
-
"policyRootCid",
|
|
6821
|
-
"enforcementRootCid",
|
|
6822
|
-
"nodeAudience",
|
|
6823
|
-
"enforcerDid",
|
|
6824
|
-
"targetOrigin",
|
|
6825
|
-
"openCredentialsAudience",
|
|
6826
|
-
"holder",
|
|
6827
|
-
"recipientMatcher",
|
|
6828
|
-
"deliveryEmail",
|
|
6829
|
-
"shareUrl",
|
|
6830
|
-
"returnOrigin",
|
|
6831
|
-
"documentName",
|
|
6832
|
-
"senderDid",
|
|
6833
|
-
"senderTrust",
|
|
6834
|
-
"contentSource",
|
|
6835
|
-
"contentSourceDigestHex",
|
|
6836
|
-
"shareExpiresAt",
|
|
6837
|
-
"issuedAt",
|
|
6838
|
-
"reportAbuseToken",
|
|
6839
|
-
"actions",
|
|
6840
|
-
"resource",
|
|
6841
|
-
"requestBodyDigest",
|
|
6842
|
-
"idempotencyKey",
|
|
6843
|
-
"expiresAt",
|
|
6844
|
-
"dataAuthority"
|
|
6845
|
-
];
|
|
6813
|
+
var import_sha2566 = require("@noble/hashes/sha256");
|
|
6814
|
+
var CREDENTIAL_INVITATION_REQUEST_DOMAIN = "xyz.tinycloud.credentials/invitation-request/v1\0";
|
|
6815
|
+
var DELIVERY_ADMISSION_DOMAIN = "xyz.tinycloud.policy/delivery-admission/v0\0";
|
|
6816
|
+
var REQUEST_KEYS = ["schema", "policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "audience", "issuedAt", "expiresAt", "nonce"];
|
|
6817
|
+
var ADMISSION_KEYS = ["schema", "policyId", "ownerDid", "recipient", "resource", "actions", "credentialType", "returnLink", "envelopeRef", "senderKeyDid", "audience", "issuedAt", "expiresAt", "nonce", "signature"];
|
|
6846
6818
|
function exactObject(value, keys, label) {
|
|
6847
6819
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
6848
6820
|
const record = value;
|
|
@@ -6862,6 +6834,12 @@ function object(value, label) {
|
|
|
6862
6834
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
6863
6835
|
return value;
|
|
6864
6836
|
}
|
|
6837
|
+
function didKeyBytes(did) {
|
|
6838
|
+
if (!did.startsWith("did:key:z") || /[#/?]/.test(did.slice("did:key:".length))) throw new Error("v3 delivery admission signer is invalid");
|
|
6839
|
+
const decoded = base58btc.decode(did.slice("did:key:".length));
|
|
6840
|
+
if (decoded.length !== 34 || decoded[0] !== 237 || decoded[1] !== 1) throw new Error("v3 delivery admission signer is invalid");
|
|
6841
|
+
return decoded.slice(2);
|
|
6842
|
+
}
|
|
6865
6843
|
function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
6866
6844
|
let parsed;
|
|
6867
6845
|
try {
|
|
@@ -6869,33 +6847,27 @@ function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
|
6869
6847
|
} catch {
|
|
6870
6848
|
throw new Error("v3 share delivery response is not valid UTF-8 JSON");
|
|
6871
6849
|
}
|
|
6872
|
-
const root = exactObject(parsed, ["
|
|
6873
|
-
const
|
|
6874
|
-
const
|
|
6850
|
+
const root = exactObject(parsed, ["request", "admission"], "v3 share delivery response");
|
|
6851
|
+
const request = exactObject(root.request, REQUEST_KEYS, "credential invitation request");
|
|
6852
|
+
const admission = exactObject(root.admission, ADMISSION_KEYS, "delivery admission");
|
|
6853
|
+
const signature = exactObject(admission.signature, ["suite", "signerDid", "value"], "delivery admission signature");
|
|
6875
6854
|
const envelope = object(expected.request.envelope, "v3 share envelope");
|
|
6876
|
-
const
|
|
6877
|
-
const
|
|
6878
|
-
const
|
|
6879
|
-
const
|
|
6880
|
-
const resource = object(envelope.resource, "v3 resource");
|
|
6855
|
+
const policy = object(envelope.policy, "v3 share policy");
|
|
6856
|
+
const requirement = object(policy.credentialRequirement, "v3 credential requirement");
|
|
6857
|
+
const credentialType = object(requirement.credentialType, "v3 credential type");
|
|
6858
|
+
const contentSource = object(envelope.contentSource, "v3 content source");
|
|
6881
6859
|
const envelopeSignature = object(envelope.signature, "v3 envelope signature");
|
|
6882
|
-
const
|
|
6883
|
-
const
|
|
6884
|
-
|
|
6885
|
-
const
|
|
6886
|
-
const
|
|
6887
|
-
if (
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
const
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
if (!Number.isFinite(issuedAt) || !Number.isFinite(expiresAt) || !Number.isFinite(shareExpiresAt) || expiresAt <= issuedAt || expiresAt - issuedAt > 5 * 6e4 || shareExpiresAt <= issuedAt || typeof authorization.holder !== "string" || !authorization.holder.startsWith("did:")) throw new Error("v3 share delivery authorization time or holder is invalid");
|
|
6894
|
-
const publicKey = expected.nodeProof.publicKey.length === 34 ? expected.nodeProof.publicKey.slice(2) : expected.nodeProof.publicKey;
|
|
6895
|
-
const signature = decodeBase64Url2(proof.signature);
|
|
6896
|
-
const signed = new TextEncoder().encode(`${SHARE_DELIVERY_AUTHORIZATION_V3_DOMAIN}${canonicalizeSignedObjectUnsigned(authorization)}`);
|
|
6897
|
-
if (publicKey.length !== 32 || signature.length !== 64 || !import_ed255198.ed25519.verify(signature, signed, publicKey)) throw new Error("v3 share delivery proof signature is invalid");
|
|
6898
|
-
return { authorization, proof };
|
|
6860
|
+
const target = object(envelope.target, "v3 target");
|
|
6861
|
+
const fields = ["policyId", "recipient", "resource", "credentialType", "returnLink", "envelopeRef", "audience", "issuedAt", "expiresAt", "nonce"];
|
|
6862
|
+
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");
|
|
6863
|
+
const issuedAt = Date.parse(String(request.issuedAt));
|
|
6864
|
+
const expiresAt = Date.parse(String(request.expiresAt));
|
|
6865
|
+
if (!Number.isFinite(issuedAt) || !Number.isFinite(expiresAt) || expiresAt <= issuedAt || expiresAt - issuedAt > 15 * 6e4) throw new Error("v3 share delivery authorization time is invalid");
|
|
6866
|
+
const admissionSignature = decodeBase64Url2(signature.value);
|
|
6867
|
+
const { signature: _signature, ...unsignedAdmission } = admission;
|
|
6868
|
+
const digest4 = (0, import_sha2566.sha256)(new TextEncoder().encode(`${DELIVERY_ADMISSION_DOMAIN}${canonicalizeSignedObjectUnsigned(unsignedAdmission)}`));
|
|
6869
|
+
if (admissionSignature.length !== 64 || !import_ed255198.ed25519.verify(admissionSignature, digest4, didKeyBytes(String(signature.signerDid)))) throw new Error("v3 share delivery admission signature is invalid");
|
|
6870
|
+
return { request, admission };
|
|
6899
6871
|
}
|
|
6900
6872
|
|
|
6901
6873
|
// src/delegations/sender-share-store.ts
|