@tinycloud/sdk-core 3.0.0-beta.5 → 3.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{credential-admission-BVUC6kdw.d.cts → credential-admission-CFjUChF8.d.cts} +56 -1
- package/dist/{credential-admission-BgvwOTIV.d.ts → credential-admission-DIEPgQ0o.d.ts} +56 -1
- package/dist/delegations/index.cjs +78 -13
- package/dist/delegations/index.cjs.map +1 -1
- package/dist/delegations/index.d.cts +2 -2
- package/dist/delegations/index.d.ts +2 -2
- package/dist/delegations/index.js +78 -13
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +408 -191
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +408 -191
- package/dist/index.js.map +1 -1
- package/dist/policy/index.cjs +159 -7
- package/dist/policy/index.cjs.map +1 -1
- package/dist/policy/index.d.cts +2 -2
- package/dist/policy/index.d.ts +2 -2
- package/dist/policy/index.js +159 -7
- package/dist/policy/index.js.map +1 -1
- package/dist/{recipient-types.schema-G8NEKRoo.d.cts → recipient-types.schema-DjmM_yJu.d.cts} +64 -1
- package/dist/{recipient-types.schema-G8NEKRoo.d.ts → recipient-types.schema-DjmM_yJu.d.ts} +64 -1
- package/package.json +3 -3
|
@@ -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,
|
|
@@ -114,6 +116,7 @@ __export(delegations_exports, {
|
|
|
114
116
|
validateOwnerSharePolicyRegistrationBytes: () => validateOwnerSharePolicyRegistrationBytes,
|
|
115
117
|
validateReceiveOptions: () => validateReceiveOptions,
|
|
116
118
|
validateShareDeliveryAuthorizationBytes: () => validateShareDeliveryAuthorizationBytes,
|
|
119
|
+
validateShareDeliveryAuthorizationV3Bytes: () => validateShareDeliveryAuthorizationV3Bytes,
|
|
117
120
|
validateSharingServiceConfig: () => validateSharingServiceConfig,
|
|
118
121
|
verifyBearerEnvelope: () => import_share_sdk2.verifyBearerEnvelope,
|
|
119
122
|
verifyShareCid: () => verifyShareCid,
|
|
@@ -1493,13 +1496,13 @@ function canonicalizeRecapCaveats(caveats) {
|
|
|
1493
1496
|
}
|
|
1494
1497
|
if (Array.isArray(value)) return `[${value.map(canonicalize).join(",")}]`;
|
|
1495
1498
|
if (typeof value === "object") {
|
|
1496
|
-
const
|
|
1497
|
-
const prototype = Object.getPrototypeOf(
|
|
1499
|
+
const object2 = value;
|
|
1500
|
+
const prototype = Object.getPrototypeOf(object2);
|
|
1498
1501
|
if (prototype !== Object.prototype && prototype !== null) {
|
|
1499
1502
|
throw new Error("ReCap caveats must contain only JSON values.");
|
|
1500
1503
|
}
|
|
1501
|
-
return `{${Object.keys(
|
|
1502
|
-
(key) => `${JSON.stringify(key)}:${canonicalize(
|
|
1504
|
+
return `{${Object.keys(object2).sort().map(
|
|
1505
|
+
(key) => `${JSON.stringify(key)}:${canonicalize(object2[key])}`
|
|
1503
1506
|
).join(",")}}`;
|
|
1504
1507
|
}
|
|
1505
1508
|
throw new Error("ReCap caveats must contain only JSON values.");
|
|
@@ -2740,8 +2743,8 @@ function canonicalJson(value) {
|
|
|
2740
2743
|
}
|
|
2741
2744
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
2742
2745
|
if (typeof value === "object") {
|
|
2743
|
-
const
|
|
2744
|
-
return `{${Object.keys(
|
|
2746
|
+
const object2 = value;
|
|
2747
|
+
return `{${Object.keys(object2).sort().map((key) => `${JSON.stringify(key)}:${canonicalJson(object2[key])}`).join(",")}}`;
|
|
2745
2748
|
}
|
|
2746
2749
|
throw new ShareEnvelopeError("invalid-envelope", "unsupported JSON value");
|
|
2747
2750
|
}
|
|
@@ -4336,8 +4339,8 @@ function canonicalJsonForProof(value) {
|
|
|
4336
4339
|
}
|
|
4337
4340
|
if (Array.isArray(value)) return `[${value.map(canonicalJsonForProof).join(",")}]`;
|
|
4338
4341
|
if (typeof value === "object") {
|
|
4339
|
-
const
|
|
4340
|
-
return `{${Object.keys(
|
|
4342
|
+
const object2 = value;
|
|
4343
|
+
return `{${Object.keys(object2).sort().map((key) => `${JSON.stringify(key)}:${canonicalJsonForProof(object2[key])}`).join(",")}}`;
|
|
4341
4344
|
}
|
|
4342
4345
|
throw new ShareAccessError("SHARE_SESSION_INVALID");
|
|
4343
4346
|
}
|
|
@@ -5046,12 +5049,12 @@ var ShareRecipientClient = class {
|
|
|
5046
5049
|
this.assertDetachedProof(request.proof);
|
|
5047
5050
|
}
|
|
5048
5051
|
parseSessionCapability(value) {
|
|
5049
|
-
const
|
|
5050
|
-
if (typeof
|
|
5051
|
-
if (!Array.isArray(
|
|
5052
|
-
const resource = this.requireObject(
|
|
5052
|
+
const object2 = this.requireObject(value, "session capability");
|
|
5053
|
+
if (typeof object2.spaceId !== "string") throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability space is invalid");
|
|
5054
|
+
if (!Array.isArray(object2.actions) || object2.actions.some((action) => !["read", "list", "edit"].includes(action))) throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability actions are invalid");
|
|
5055
|
+
const resource = this.requireObject(object2.resource, "session capability resource");
|
|
5053
5056
|
if (resource.kind !== "exact" && resource.kind !== "prefix" || typeof resource.path !== "string") throw new ShareAccessError("SHARE_SESSION_INVALID", "session capability resource is invalid");
|
|
5054
|
-
return { spaceId:
|
|
5057
|
+
return { spaceId: object2.spaceId, actions: [...new Set(object2.actions)], resource: { kind: resource.kind, path: resource.path } };
|
|
5055
5058
|
}
|
|
5056
5059
|
assertProvidedPolicySession(session, envelope) {
|
|
5057
5060
|
const sessionExpiry = dateValue(session.expiresAt);
|
|
@@ -6805,6 +6808,68 @@ function shareDeliveryTrustedKid(publicKey) {
|
|
|
6805
6808
|
return `${did}#${did.slice("did:key:".length)}`;
|
|
6806
6809
|
}
|
|
6807
6810
|
|
|
6811
|
+
// src/delegations/share-delivery-v3.ts
|
|
6812
|
+
var import_ed255198 = require("@noble/curves/ed25519");
|
|
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"];
|
|
6818
|
+
function exactObject(value, keys, label) {
|
|
6819
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
6820
|
+
const record = value;
|
|
6821
|
+
if (Object.keys(record).length !== keys.length || keys.some((key) => !Object.prototype.hasOwnProperty.call(record, key))) throw new Error(`${label} has unknown or missing fields`);
|
|
6822
|
+
return record;
|
|
6823
|
+
}
|
|
6824
|
+
function decodeBase64Url2(value) {
|
|
6825
|
+
if (typeof value !== "string" || !/^[A-Za-z0-9_-]+$/.test(value)) throw new Error("share delivery value is not canonical base64url");
|
|
6826
|
+
if (typeof atob === "function") {
|
|
6827
|
+
const padded = value.replace(/-/g, "+").replace(/_/g, "/") + "=".repeat((4 - value.length % 4) % 4);
|
|
6828
|
+
return Uint8Array.from(atob(padded), (character) => character.charCodeAt(0));
|
|
6829
|
+
}
|
|
6830
|
+
if (typeof Buffer !== "undefined") return new Uint8Array(Buffer.from(value, "base64url"));
|
|
6831
|
+
throw new Error("base64url decoding is unavailable");
|
|
6832
|
+
}
|
|
6833
|
+
function object(value, label) {
|
|
6834
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`${label} is invalid`);
|
|
6835
|
+
return value;
|
|
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
|
+
}
|
|
6843
|
+
function validateShareDeliveryAuthorizationV3Bytes(bytes2, expected) {
|
|
6844
|
+
let parsed;
|
|
6845
|
+
try {
|
|
6846
|
+
parsed = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes2));
|
|
6847
|
+
} catch {
|
|
6848
|
+
throw new Error("v3 share delivery response is not valid UTF-8 JSON");
|
|
6849
|
+
}
|
|
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");
|
|
6854
|
+
const envelope = object(expected.request.envelope, "v3 share envelope");
|
|
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");
|
|
6859
|
+
const envelopeSignature = object(envelope.signature, "v3 envelope signature");
|
|
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 };
|
|
6871
|
+
}
|
|
6872
|
+
|
|
6808
6873
|
// src/delegations/sender-share-store.ts
|
|
6809
6874
|
var MemorySenderShareRecordStorage = class {
|
|
6810
6875
|
constructor() {
|