@tinycloud/sdk-core 3.0.0-beta.9 → 3.0.1-beta.0
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 +90 -79
- 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 +90 -79
- package/dist/delegations/index.js.map +1 -1
- package/dist/index.cjs +185 -108
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.js +185 -108
- package/dist/index.js.map +1 -1
- package/dist/policy/index.cjs +82 -36
- 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 +82 -36
- package/dist/policy/index.js.map +1 -1
- package/dist/{recipient-types.schema-C0igQ1kA.d.cts → recipient-types.schema-D9AI8tjN.d.cts} +39 -8
- package/dist/{recipient-types.schema-C0igQ1kA.d.ts → recipient-types.schema-D9AI8tjN.d.ts} +39 -8
- package/package.json +4 -4
|
@@ -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 };
|
|
@@ -170,6 +170,7 @@ var DelegationErrorSchema = import_zod.z.object({
|
|
|
170
170
|
});
|
|
171
171
|
var DelegationErrorCodes = {
|
|
172
172
|
AUTH_REQUIRED: "AUTH_REQUIRED",
|
|
173
|
+
AUTH_UNAUTHORIZED: "AUTH_UNAUTHORIZED",
|
|
173
174
|
AUTH_EXPIRED: "AUTH_EXPIRED",
|
|
174
175
|
NOT_INITIALIZED: "NOT_INITIALIZED",
|
|
175
176
|
NOT_FOUND: "NOT_FOUND",
|
|
@@ -534,7 +535,7 @@ var CreateDelegationWasmResultSchema = import_zod.z.object({
|
|
|
534
535
|
// src/expiry.ts
|
|
535
536
|
var EPHEMERAL_MS = 60 * 60 * 1e3;
|
|
536
537
|
var SIGNED_READ_URL_MS = 5 * 60 * 1e3;
|
|
537
|
-
var SESSION_MS =
|
|
538
|
+
var SESSION_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
538
539
|
var SHARE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
539
540
|
var APP_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
540
541
|
var MAX_MS = 10 * 365 * 24 * 60 * 60 * 1e3;
|
|
@@ -2689,7 +2690,6 @@ var import_ed25519 = require("@noble/curves/ed25519");
|
|
|
2689
2690
|
var import_blake3 = require("@noble/hashes/blake3");
|
|
2690
2691
|
var import_sha256 = require("@noble/hashes/sha256");
|
|
2691
2692
|
var ENVELOPE_SCHEMA = "xyz.tinycloud.share/envelope";
|
|
2692
|
-
var INLINE_PREFIX = "tc2:";
|
|
2693
2693
|
var RAW_CID_CODEC = 85;
|
|
2694
2694
|
var BLAKE3_256_CODE = 30;
|
|
2695
2695
|
var DEFAULT_MAX_INLINE_BYTES = 256 * 1024;
|
|
@@ -3395,31 +3395,6 @@ function parsePublishedShareLink(link, options = {}) {
|
|
|
3395
3395
|
const origin = normalizeOrigin(url.origin);
|
|
3396
3396
|
if (options.trustedOrigins !== void 0 && !options.trustedOrigins.map(normalizeOrigin).includes(origin)) throw new ShareEnvelopeError("origin-mismatch", "share link origin is not trusted");
|
|
3397
3397
|
if (url.username !== "" || url.password !== "") throw new ShareEnvelopeError("invalid-link", "share link is not canonical");
|
|
3398
|
-
if (url.pathname === "/viewer") {
|
|
3399
|
-
const secretPayload = url.search === "" && url.hash.startsWith("#tc2=") ? url.hash.slice("#tc2=".length) : void 0;
|
|
3400
|
-
const publicPayload = url.hash === "" && url.searchParams.size === 1 ? url.searchParams.get("tc2") ?? void 0 : void 0;
|
|
3401
|
-
if (secretPayload === void 0 && publicPayload === void 0) throw new ShareEnvelopeError("invalid-link", "published share link is invalid");
|
|
3402
|
-
if (publicPayload !== void 0 && url.search !== `?tc2=${publicPayload}`) throw new ShareEnvelopeError("invalid-link", "published share link is not canonical");
|
|
3403
|
-
let payload;
|
|
3404
|
-
try {
|
|
3405
|
-
const bytes2 = base64UrlToBytes(secretPayload ?? publicPayload);
|
|
3406
|
-
if (bytes2.length > (options.maxInlineBytes ?? DEFAULT_MAX_INLINE_BYTES) * 2) throw new Error("inline payload too large");
|
|
3407
|
-
const text = new TextDecoder("utf-8", { fatal: true }).decode(bytes2);
|
|
3408
|
-
const value = JSON.parse(text);
|
|
3409
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error("inline payload shape");
|
|
3410
|
-
if (canonicalJson(value) !== text) throw new Error("inline payload is not canonical JSON");
|
|
3411
|
-
payload = value;
|
|
3412
|
-
} catch (error) {
|
|
3413
|
-
throw new ShareEnvelopeError("invalid-link", error instanceof Error ? error.message : "invalid inline payload");
|
|
3414
|
-
}
|
|
3415
|
-
const payloadKeys = Object.keys(payload);
|
|
3416
|
-
if (payload.v !== 2 || typeof payload.c !== "string" || typeof payload.cid !== "string" || payload.k !== void 0 && typeof payload.k !== "string" || payloadKeys.some((key3) => !["v", "c", "cid", "k"].includes(key3)) || publicPayload !== void 0 && (payloadKeys.length !== 3 || payload.k !== void 0)) throw new ShareEnvelopeError("invalid-link", "inline payload fields are invalid");
|
|
3417
|
-
const sealed = base64UrlToBytes(payload.c);
|
|
3418
|
-
if (!verifyPublishedShareCid(payload.cid, sealed)) throw new ShareEnvelopeError("cid-mismatch", "inline payload CID does not match");
|
|
3419
|
-
const key2 = payload.k === void 0 ? void 0 : base64UrlToBytes(payload.k);
|
|
3420
|
-
if (key2 !== void 0 && key2.length !== 32) throw new ShareEnvelopeError("invalid-link", "inline payload key is invalid");
|
|
3421
|
-
return { origin, cid: payload.cid, ...key2 === void 0 ? {} : { key: key2 }, sealed };
|
|
3422
|
-
}
|
|
3423
3398
|
if (url.search !== "") throw new ShareEnvelopeError("invalid-link", "share link is not canonical");
|
|
3424
3399
|
const match = /^\/s\/([a-z2-7]+)$/.exec(url.pathname);
|
|
3425
3400
|
if (match === null || !url.hash.startsWith("#k=")) throw new ShareEnvelopeError("invalid-link", "published share link is invalid");
|
|
@@ -3442,10 +3417,7 @@ function parseShareUrl(link, options = {}) {
|
|
|
3442
3417
|
}
|
|
3443
3418
|
const origin = normalizeOrigin(url.origin);
|
|
3444
3419
|
if (options.trustedOrigins !== void 0 && !options.trustedOrigins.map(normalizeOrigin).includes(origin)) throw new ShareEnvelopeError("origin-mismatch", "share link origin is not trusted");
|
|
3445
|
-
if (url.pathname === "/viewer"
|
|
3446
|
-
const published = parsePublishedShareLink(link, options);
|
|
3447
|
-
return { kind: "inline", origin, cid: published.cid, key: published.key, url: `${url.origin}${url.pathname}`, protocol: "share-envelope-v2" };
|
|
3448
|
-
}
|
|
3420
|
+
if (url.pathname === "/viewer") throw new ShareEnvelopeError("invalid-link", "retired viewer links are not accepted");
|
|
3449
3421
|
if (url.search !== "") throw new ShareEnvelopeError("invalid-link", "share links must not contain query parameters");
|
|
3450
3422
|
const match = url.pathname.match(/^\/s\/(i\/)?([^/]+)$/);
|
|
3451
3423
|
if (!match) throw new ShareEnvelopeError("invalid-link", "share link path is invalid");
|
|
@@ -3470,9 +3442,9 @@ function parseShareUrl(link, options = {}) {
|
|
|
3470
3442
|
function isV2ShareLink(link) {
|
|
3471
3443
|
try {
|
|
3472
3444
|
const url = new URL(link);
|
|
3473
|
-
return url.pathname.startsWith("/s/")
|
|
3445
|
+
return url.search === "" && url.pathname.startsWith("/s/");
|
|
3474
3446
|
} catch {
|
|
3475
|
-
return
|
|
3447
|
+
return false;
|
|
3476
3448
|
}
|
|
3477
3449
|
}
|
|
3478
3450
|
async function encryptShareBytes(bytes2, key) {
|
|
@@ -4033,6 +4005,7 @@ var CompactPayloadSchema = import_zod4.z.object({
|
|
|
4033
4005
|
nnc: import_zod4.z.string().min(1),
|
|
4034
4006
|
prf: import_zod4.z.array(import_zod4.z.string().min(1))
|
|
4035
4007
|
}).strict();
|
|
4008
|
+
var MAX_POLICY_ROOT_SECONDS = 31 * 24 * 60 * 60;
|
|
4036
4009
|
function createCompactPolicyInvocation(input) {
|
|
4037
4010
|
const session = parsePolicySessionUcan(input.sessionAuthorization);
|
|
4038
4011
|
if (session.cid !== input.sessionCid || session.aud !== input.recipientDid)
|
|
@@ -4064,7 +4037,7 @@ function createCompactPolicyInvocation(input) {
|
|
|
4064
4037
|
const signature = import_ed255192.ed25519.sign(signingInput, input.privateKey);
|
|
4065
4038
|
return parseCompactUcanAuthorization(`${protectedSegment}.${payloadSegment}.${encodeBase64Url(signature)}`);
|
|
4066
4039
|
}
|
|
4067
|
-
function
|
|
4040
|
+
function compactPolicyDescendantClaims(input) {
|
|
4068
4041
|
const parent = parseCompactUcanAuthorization(input.parentAuthorization, input.parentCid);
|
|
4069
4042
|
if (parent.payload.aud !== input.issuerDid) throw new Error("policy descendant issuer is not the parent audience");
|
|
4070
4043
|
const parentFact = parent.payload.fct[0];
|
|
@@ -4072,23 +4045,33 @@ function createCompactPolicyDescendant(input) {
|
|
|
4072
4045
|
if (!Number.isInteger(depth) || depth <= 0) throw new Error("policy descendant depth is exhausted");
|
|
4073
4046
|
if (!compactAttenuationContains(parent.payload.att, input.attenuation))
|
|
4074
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);
|
|
4075
4061
|
const principal = input.issuerDid.split("#", 1)[0];
|
|
4076
4062
|
const didMaterial = base58btc.decode(principal.slice("did:key:".length));
|
|
4077
4063
|
const publicKey = import_ed255192.ed25519.getPublicKey(input.privateKey);
|
|
4078
4064
|
if (didMaterial.length !== 34 || !equalBytes2(publicKey, didMaterial.slice(2))) throw new Error("policy descendant signer does not bind issuer DID");
|
|
4079
|
-
const now = Math.max(input.now ?? Math.floor(Date.now() / 1e3), parent.payload.nbf + 1);
|
|
4080
|
-
const exp = Math.min(input.expiresAt ?? now + 60, now + 60, parent.payload.exp - 1);
|
|
4081
|
-
if (exp <= now) throw new Error("policy parent has no strictly narrower validity window");
|
|
4082
4065
|
const header = { alg: "EdDSA", jwk: { alg: "EdDSA", crv: "Ed25519", kty: "OKP", x: encodeBase64Url(publicKey) }, typ: "JWT", ucv: "0.10.0" };
|
|
4083
4066
|
const payload = {
|
|
4084
4067
|
att: input.attenuation,
|
|
4085
4068
|
aud: input.audienceDid,
|
|
4086
|
-
exp,
|
|
4087
|
-
fct: [
|
|
4069
|
+
exp: claims.expiresAt,
|
|
4070
|
+
fct: [claims.fact],
|
|
4088
4071
|
iss: input.issuerDid.includes("#") ? input.issuerDid : `${principal}#${principal.slice("did:key:".length)}`,
|
|
4089
|
-
nbf:
|
|
4090
|
-
nnc:
|
|
4091
|
-
prf: [
|
|
4072
|
+
nbf: claims.notBefore,
|
|
4073
|
+
nnc: claims.nonce,
|
|
4074
|
+
prf: [claims.parentCid]
|
|
4092
4075
|
};
|
|
4093
4076
|
const protectedSegment = encodeBase64Url(new TextEncoder().encode(jcsCanonicalize(header)));
|
|
4094
4077
|
const payloadSegment = encodeBase64Url(new TextEncoder().encode(jcsCanonicalize(payload)));
|
|
@@ -4164,7 +4147,7 @@ function parsePolicySessionUcan(authorization, expectedProofs) {
|
|
|
4164
4147
|
throw new Error("policy session UCAN fact is incomplete");
|
|
4165
4148
|
if (hasV4AuditFactShape && (!LOWER_SHA256_HEX.test(fact.credentialIdAuditDigestHex) || !LOWER_SHA256_HEX.test(fact.presentationJtiAuditDigestHex)))
|
|
4166
4149
|
throw new Error("policy session UCAN v4 audit facts are invalid");
|
|
4167
|
-
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)
|
|
4168
4151
|
throw new Error("policy session UCAN fact is invalid");
|
|
4169
4152
|
return {
|
|
4170
4153
|
authorization,
|
|
@@ -5385,6 +5368,13 @@ var ShareRecipientClient = class {
|
|
|
5385
5368
|
};
|
|
5386
5369
|
|
|
5387
5370
|
// src/delegations/SharingService.ts
|
|
5371
|
+
function spaceIdsEqual(left, right) {
|
|
5372
|
+
const normalizeOwnerAddress = (space) => {
|
|
5373
|
+
const match = /^(tinycloud:pkh:eip155:\d+:)(0x[0-9a-fA-F]{40})(:.+)$/.exec(space);
|
|
5374
|
+
return match === null ? space : `${match[1]}${match[2].toLowerCase()}${match[3]}`;
|
|
5375
|
+
};
|
|
5376
|
+
return normalizeOwnerAddress(left) === normalizeOwnerAddress(right);
|
|
5377
|
+
}
|
|
5388
5378
|
function inferShortServiceFromActionUrns(actions) {
|
|
5389
5379
|
let short;
|
|
5390
5380
|
for (const action of actions) {
|
|
@@ -5620,11 +5610,11 @@ var SharingService = class {
|
|
|
5620
5610
|
}
|
|
5621
5611
|
return result;
|
|
5622
5612
|
};
|
|
5623
|
-
const canSatisfyFromRegistry = this.
|
|
5613
|
+
const canSatisfyFromRegistry = this.classifyDelegationAuthority(
|
|
5624
5614
|
fullPath,
|
|
5625
5615
|
actions,
|
|
5626
5616
|
requestedExpiry
|
|
5627
|
-
);
|
|
5617
|
+
) === "ok";
|
|
5628
5618
|
if (canSatisfyFromRegistry) {
|
|
5629
5619
|
const delegationResult = await this.createSessionDelegation(plainDID, fullPath, actions, expiry);
|
|
5630
5620
|
const childDelegationActiveError = this.retiredGraphError();
|
|
@@ -5694,49 +5684,58 @@ var SharingService = class {
|
|
|
5694
5684
|
return { ok: true, data: shareLink };
|
|
5695
5685
|
}
|
|
5696
5686
|
/**
|
|
5697
|
-
*
|
|
5698
|
-
*
|
|
5699
|
-
*
|
|
5700
|
-
*
|
|
5701
|
-
*
|
|
5702
|
-
*
|
|
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.
|
|
5703
5714
|
* @internal
|
|
5704
5715
|
*/
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
for (const key of
|
|
5708
|
-
const
|
|
5709
|
-
|
|
5710
|
-
if (delegation.spaceId !== this.session?.spaceId) {
|
|
5711
|
-
continue;
|
|
5712
|
-
}
|
|
5713
|
-
if ((delegation.caveats?.length ?? 0) > 0) {
|
|
5714
|
-
continue;
|
|
5715
|
-
}
|
|
5716
|
-
if (!this.registry.isDelegationValid(delegation)) {
|
|
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)) {
|
|
5720
|
+
if (delegation.spaceId === void 0 || !spaceIdsEqual(delegation.spaceId, this.session?.spaceId ?? "")) {
|
|
5717
5721
|
continue;
|
|
5718
5722
|
}
|
|
5719
|
-
if (delegation
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
if (delegation.
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
const delegationPath = delegation.path || "";
|
|
5726
|
-
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("*"))) {
|
|
5727
5729
|
continue;
|
|
5728
5730
|
}
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
(action) => delegationActions.includes(action) || delegationActions.includes("*")
|
|
5732
|
-
);
|
|
5733
|
-
if (!hasAllActions) {
|
|
5731
|
+
if ((delegation.caveats?.length ?? 0) > 0) {
|
|
5732
|
+
coveredOnlyByCaveated = true;
|
|
5734
5733
|
continue;
|
|
5735
5734
|
}
|
|
5736
|
-
return
|
|
5735
|
+
return "ok";
|
|
5737
5736
|
}
|
|
5738
5737
|
}
|
|
5739
|
-
return
|
|
5738
|
+
return coveredOnlyByCaveated ? "caveated" : "not-covered";
|
|
5740
5739
|
}
|
|
5741
5740
|
retiredGraphError() {
|
|
5742
5741
|
try {
|
|
@@ -5835,11 +5834,23 @@ var SharingService = class {
|
|
|
5835
5834
|
const errorText = await registerRes.text();
|
|
5836
5835
|
const registrationTextActiveError = this.retiredGraphError();
|
|
5837
5836
|
if (registrationTextActiveError) return { ok: false, error: registrationTextActiveError };
|
|
5837
|
+
const message = `Failed to register delegation with server: ${registerRes.status} ${errorText}`;
|
|
5838
|
+
if (registerRes.status === 401 || registerRes.status === 403) {
|
|
5839
|
+
return {
|
|
5840
|
+
ok: false,
|
|
5841
|
+
error: createError2(
|
|
5842
|
+
DelegationErrorCodes.AUTH_UNAUTHORIZED,
|
|
5843
|
+
message,
|
|
5844
|
+
void 0,
|
|
5845
|
+
{ status: registerRes.status }
|
|
5846
|
+
)
|
|
5847
|
+
};
|
|
5848
|
+
}
|
|
5838
5849
|
return {
|
|
5839
5850
|
ok: false,
|
|
5840
5851
|
error: createError2(
|
|
5841
5852
|
DelegationErrorCodes.CREATION_FAILED,
|
|
5842
|
-
|
|
5853
|
+
message
|
|
5843
5854
|
)
|
|
5844
5855
|
};
|
|
5845
5856
|
}
|