@tinycloud/sdk-core 2.11.0 → 3.0.0-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.
@@ -1,6 +1,243 @@
1
1
  import { a as JsonValue } from './capability-BjzXwtNw.js';
2
2
  import { z } from 'zod';
3
3
 
4
+ declare const CREDENTIAL_ACQUISITION_PROTOCOL: "tinycloud.credentials/acquisition/v1";
5
+ declare const HOLDER_BINDING_DOMAIN: "tinycloud.credentials/holder-binding/v1";
6
+ declare const CREDENTIAL_CONTRACT_VERSION: 1;
7
+ declare const CREDENTIAL_STEP_REGISTRY_VERSION: 1;
8
+ declare const CREDENTIAL_FORMAT: "vc+sd-jwt";
9
+ type CredentialStepType = "collect_input" | "mailbox_otp" | "holder_signature";
10
+ type CredentialEndpointId = "request" | "state" | "challenge" | "proof" | "holder_binding" | "holder_signature" | "issue" | "result";
11
+ interface CredentialClaimDescriptor {
12
+ readonly name: string;
13
+ readonly matching: "normalized_exact";
14
+ readonly selectiveDisclosure: boolean;
15
+ }
16
+ interface CredentialInputDescriptor {
17
+ readonly id: string;
18
+ readonly label: string;
19
+ readonly schema: {
20
+ readonly type: "string";
21
+ readonly minLength?: number;
22
+ readonly maxLength?: number;
23
+ readonly pattern?: string;
24
+ readonly format?: "email";
25
+ };
26
+ readonly prefill: "privacy_hint_only";
27
+ readonly autocomplete: "off";
28
+ }
29
+ interface CredentialStepDescriptor {
30
+ readonly type: CredentialStepType;
31
+ readonly version: 1;
32
+ }
33
+ /** The canonical TC-462 descriptor. Its bytes are hashed without normalization. */
34
+ interface CredentialFlowDescriptor {
35
+ readonly type: "tinycloud.credentials/descriptor/v1";
36
+ readonly contractVersion: 1;
37
+ readonly protocol: typeof CREDENTIAL_ACQUISITION_PROTOCOL;
38
+ readonly profile: string;
39
+ readonly profileVersion: 1;
40
+ readonly display: {
41
+ readonly title: string;
42
+ readonly description: string;
43
+ readonly consent: string;
44
+ readonly securityTextLocked: true;
45
+ };
46
+ readonly accessibility: {
47
+ readonly progressLabel: string;
48
+ readonly errorLiveRegion: "assertive";
49
+ };
50
+ readonly theme: {
51
+ readonly tokenVersion: "tinycloud.credentials/tokens/v1";
52
+ readonly allowed: readonly ("accentColor" | "fontFamily" | "borderRadius")[];
53
+ };
54
+ readonly issuer: {
55
+ readonly origin: string;
56
+ readonly did: string;
57
+ readonly kid: string;
58
+ };
59
+ readonly interaction: {
60
+ readonly origin: "https://credentials.org";
61
+ readonly pathTemplate: "/credentials/acquire/{requestId}";
62
+ };
63
+ readonly format: {
64
+ readonly id: typeof CREDENTIAL_FORMAT;
65
+ readonly vct: string;
66
+ };
67
+ readonly claims: readonly CredentialClaimDescriptor[];
68
+ readonly subjectRelationship: "holder_is_subject";
69
+ readonly inputs: readonly CredentialInputDescriptor[];
70
+ readonly steps: readonly CredentialStepDescriptor[];
71
+ readonly holderBinding: {
72
+ readonly required: true;
73
+ readonly alg: "EdDSA";
74
+ readonly domain: typeof HOLDER_BINDING_DOMAIN;
75
+ readonly version: 1;
76
+ };
77
+ readonly endpoints: Readonly<Record<"request" | "state" | "challenge" | "proof" | "holderBinding" | "holderSignature" | "issue" | "result", CredentialEndpointId>>;
78
+ readonly lifecycle: {
79
+ readonly requestTtlSeconds: number;
80
+ readonly challengeTtlSeconds: number;
81
+ readonly maxProofAttempts: number;
82
+ readonly challengeConsumption: "atomic_once";
83
+ readonly retry: "bounded";
84
+ };
85
+ readonly status: {
86
+ readonly type: "none";
87
+ readonly freshnessSeconds: number;
88
+ };
89
+ readonly revocation: {
90
+ readonly supported: false;
91
+ };
92
+ readonly presentation: {
93
+ readonly stateVersion: "tinycloud.credentials/ux-states/v1";
94
+ readonly states: readonly CredentialUxState[];
95
+ };
96
+ }
97
+ interface CredentialRequirement {
98
+ readonly type: "TinyCloudCredentialRequirement";
99
+ readonly version: 1;
100
+ readonly profile: {
101
+ readonly id: string;
102
+ readonly version: 1;
103
+ };
104
+ readonly credentialType: {
105
+ readonly id: string;
106
+ readonly version: 1;
107
+ };
108
+ readonly claims: Readonly<Record<string, string>>;
109
+ readonly maxAgeSeconds?: number;
110
+ }
111
+ interface CredentialHolderBinding {
112
+ readonly type: typeof HOLDER_BINDING_DOMAIN;
113
+ readonly protocol: typeof CREDENTIAL_ACQUISITION_PROTOCOL;
114
+ readonly requestId: string;
115
+ readonly profile: string;
116
+ readonly profileVersion: 1;
117
+ readonly descriptorDigest: string;
118
+ readonly requirementDigest: string;
119
+ readonly issuer: string;
120
+ readonly issuerKid: string;
121
+ readonly holderDid: string;
122
+ readonly normalizedClaimsDigest: string;
123
+ readonly challengeNonce: string;
124
+ readonly audience: string;
125
+ readonly openerOrigin: string;
126
+ readonly completionOrigin: string;
127
+ readonly completionContext: string;
128
+ readonly jti: string;
129
+ readonly issuedAt: string;
130
+ readonly expiresAt: string;
131
+ }
132
+ interface IssuerVerificationKey {
133
+ readonly kid: string;
134
+ readonly alg: "EdDSA";
135
+ readonly jwk: {
136
+ readonly kty: "OKP";
137
+ readonly crv: "Ed25519";
138
+ readonly x: string;
139
+ };
140
+ readonly validFrom: string;
141
+ readonly validUntil: string;
142
+ readonly retiredAt?: string;
143
+ }
144
+ interface CredentialIssuerMetadata {
145
+ readonly type: "OpenCredentialsIssuerMetadata";
146
+ readonly version: 1;
147
+ readonly origin: string;
148
+ readonly issuerDid: string;
149
+ readonly keys: readonly IssuerVerificationKey[];
150
+ readonly cache: {
151
+ readonly maxAgeSeconds: number;
152
+ readonly etag: string;
153
+ };
154
+ }
155
+ interface IssuedCredentialEnvelope {
156
+ readonly type: "OpenCredentialsIssuedCredential";
157
+ readonly version: 1;
158
+ readonly protocol: typeof CREDENTIAL_ACQUISITION_PROTOCOL;
159
+ readonly profile: {
160
+ readonly id: string;
161
+ readonly version: 1;
162
+ };
163
+ readonly credentialType: {
164
+ readonly id: string;
165
+ readonly version: 1;
166
+ };
167
+ readonly schema: string;
168
+ readonly format: typeof CREDENTIAL_FORMAT;
169
+ readonly issuerDid: string;
170
+ readonly issuerKid: string;
171
+ readonly subjectDid: string;
172
+ readonly holderDid: string;
173
+ readonly claims: Readonly<Record<string, string>>;
174
+ readonly claimsDigest: string;
175
+ readonly descriptorDigest: string;
176
+ readonly credentialId: string;
177
+ readonly issuedAt: string;
178
+ readonly notBefore: string;
179
+ readonly expiresAt: string;
180
+ readonly status: {
181
+ readonly method: "none";
182
+ readonly freshnessSeconds: number;
183
+ };
184
+ readonly credential: string;
185
+ }
186
+ interface VerifiedCredential extends IssuedCredentialEnvelope {
187
+ readonly verifiedAt: string;
188
+ readonly credentialDigest: string;
189
+ readonly statusCheckedAt: string;
190
+ }
191
+ interface StoredCredentialRecord {
192
+ readonly type: "TinyCloudStoredCredential";
193
+ readonly version: 1;
194
+ readonly ownerDid: string;
195
+ readonly recordId: string;
196
+ readonly requirementDigest: string;
197
+ readonly descriptorDigest: string;
198
+ readonly profile: {
199
+ readonly id: string;
200
+ readonly version: 1;
201
+ };
202
+ readonly credentialType: {
203
+ readonly id: string;
204
+ readonly version: 1;
205
+ };
206
+ readonly issuerDid: string;
207
+ readonly issuerKid: string;
208
+ readonly holderDid: string;
209
+ readonly claims: Readonly<Record<string, string>>;
210
+ readonly claimsDigest: string;
211
+ readonly credentialDigest: string;
212
+ readonly credential: string;
213
+ readonly schema: string;
214
+ readonly credentialId: string;
215
+ readonly issuedAt: string;
216
+ readonly notBefore: string;
217
+ readonly expiresAt: string;
218
+ readonly status: {
219
+ readonly method: "none";
220
+ readonly freshnessSeconds: number;
221
+ };
222
+ readonly verifiedAt: string;
223
+ readonly storedAt: string;
224
+ }
225
+ interface CredentialStorageReceipt {
226
+ readonly type: "TinyCloudCredentialStorageReceipt";
227
+ readonly version: 1;
228
+ readonly ownerDid: string;
229
+ readonly recordId: string;
230
+ readonly recordDigest: string;
231
+ readonly storedAt: string;
232
+ readonly etag?: string;
233
+ }
234
+ type CredentialUxState = "collecting" | "challenging" | "proving" | "signing" | "issuing" | "verifying" | "saving" | "success" | "recovery";
235
+ interface CredentialProgressEvent {
236
+ readonly state: CredentialUxState | "checking";
237
+ readonly stepId?: string;
238
+ readonly correlationId?: string;
239
+ }
240
+
4
241
  type SignedObjectErrorCode = "schema-invalid" | "canonicalization-mismatch" | "digest-mismatch" | "id-mismatch" | "signing-key-binding" | "signature-material-invalid" | "signature-suite-unsupported" | "signature-invalid";
5
242
  declare class SignedObjectProfileError extends Error {
6
243
  readonly code: SignedObjectErrorCode;
@@ -225,6 +462,8 @@ interface PolicyChallengeV3 {
225
462
  readonly nonce: string;
226
463
  readonly policyCid: string;
227
464
  readonly recipientDid: string;
465
+ readonly expiresAt?: string;
466
+ readonly nodeAudience?: string;
228
467
  readonly [key: string]: unknown;
229
468
  }
230
469
  declare function requestPolicyChallengeV3(input: {
@@ -393,8 +632,20 @@ interface SignCompactUcanAuthorizationInput {
393
632
  readonly nonce: string;
394
633
  readonly sign: (bytes: Uint8Array) => Promise<Uint8Array>;
395
634
  }
635
+ interface SignCompactUcanRootAuthorizationInput {
636
+ readonly issuerDid: string;
637
+ readonly audienceDid: string;
638
+ readonly attenuation: Readonly<Record<string, Readonly<Record<string, readonly unknown[]>>>>;
639
+ readonly facts: readonly [Readonly<Record<string, unknown>>];
640
+ readonly notBefore: number;
641
+ readonly expiresAt: number;
642
+ readonly nonce: string;
643
+ readonly sign: (bytes: Uint8Array) => Promise<Uint8Array>;
644
+ }
396
645
  /** Sign exact compact-UCAN bytes with a caller-owned, potentially non-extractable key. */
397
646
  declare function signCompactUcanAuthorization(input: SignCompactUcanAuthorizationInput): Promise<CompactUcanAuthorizationV1>;
647
+ /** Sign a proofless policy root without weakening the 60-second invocation profile. */
648
+ declare function signCompactUcanRootAuthorization(input: SignCompactUcanRootAuthorizationInput): Promise<CompactUcanAuthorizationV1>;
398
649
  interface CompactPolicyInvocationInput {
399
650
  readonly sessionAuthorization: string;
400
651
  readonly sessionCid: string;
@@ -426,4 +677,105 @@ declare function compactAttenuationContains(parent: Readonly<Record<string, Read
426
677
  declare function parseCompactUcanAuthorization(input: string, expectedCid?: string): CompactUcanAuthorizationV1;
427
678
  declare function parsePolicySessionUcan(authorization: string, expectedProofs?: readonly [string, string]): PolicySessionUcanV1;
428
679
 
429
- export { type UnifiedPolicyCapability as $, ATTESTED_ENFORCER_BINDING_V2_SCHEMA as A, SignedObjectCanonicalizationError as B, CONTENT_SOURCE_V1_DOMAIN as C, SignedObjectDigestError as D, ED25519_JCS_SIGNATURE_SUITE as E, type SignedObjectErrorCode as F, SignedObjectIdError as G, type SignedObjectKind as H, type SignedObjectMaterial as I, type JsonObject as J, SignedObjectProfileError as K, LAST_V2_CREATE_AT as L, MAX_LEGACY_ENVELOPE_EXPIRES_AT as M, NATIVE_PROJECTION_V1_DOMAIN as N, SignedObjectSchemaError as O, type PolicyEngineRecord as P, type SignedObjectSignature as Q, ROOT_REVOCATION_V1_DOMAIN as R, type SignedObjectSigner as S, type SignedObjectVerificationResult as T, type UnsignedPolicyEngineRecord as U, type SignedPolicyObject as V, SigningKeyBindingError as W, type UnifiedContentSource as X, type UnifiedEncryptionCapability as Y, type UnifiedKvCapability as Z, type UnifiedNativeCapability as _, type Policy as a, type UnifiedPolicyV1 as a0, type UnifiedResourceSelector as a1, type UnsignedPolicy as a2, type UnsignedPolicyObject as a3, type UnsignedPolicyStatus as a4, UnsupportedSignatureSuiteError as a5, canonicalizeSignedObjectUnsigned as a6, canonicalizeUnifiedPolicyCapability as a7, compactAttenuationContains as a8, contentSourceDigestHex as a9, unifiedPolicyCapabilityFromNative as aA, validatePolicyEngineRecordSigned as aB, validatePolicyEngineRecordSignedShape as aC, validatePolicyEngineRecordUnsigned as aD, validatePolicySigned as aE, validatePolicySignedShape as aF, validatePolicyStatusSigned as aG, validatePolicyStatusSignedShape as aH, validatePolicyStatusUnsigned as aI, validatePolicyUnsigned as aJ, verifyPolicy as aK, verifyPolicyEngineRecord as aL, verifyPolicyRootRevocationV3 as aM, verifyPolicyRootStatusCheckpointV3 as aN, verifyPolicyStatus as aO, verifySignedObject as aP, createAndSignPolicy as aa, createAndSignPolicyEngineRecord as ab, createAndSignPolicyStatus as ac, createAndSignSignedObject as ad, createCompactPolicyDescendant as ae, createCompactPolicyInvocation as af, deriveSignedObjectMaterial as ag, getPolicyRootStatusV3 as ah, mintPolicySessionV3 as ai, normalizeUnifiedPolicyCapability as aj, parseCompactUcanAuthorization as ak, parsePolicySessionUcan as al, policyCidFromCanonicalBytes as am, policyDigestHex as an, policyIdForDigestHex as ao, projectUnifiedPolicyCapabilities as ap, projectUnifiedPolicyCapability as aq, renewPolicyRootStatusV3 as ar, requestPolicyChallengeV3 as as, revokePolicyRootV3 as at, signCompactUcanAuthorization as au, signedObjectIdFor as av, toSignedObjectError as aw, unifiedNativeProjectionHashHex as ax, unifiedPolicyCapabilityContains as ay, unifiedPolicyCapabilityDigestHex as az, type CompactPolicyInvocationInput as b, type CompactUcanAuthorizationV1 as c, EIP191_JCS_SIGNATURE_SUITE as d, LAST_V2_READ_AT as e, POLICY_CAPABILITY_V1_DOMAIN as f, POLICY_CAPABILITY_V1_SCHEMA as g, POLICY_ENFORCEMENT_DELEGATION_V2_SCHEMA as h, POLICY_ENGINE_RECORD_SCHEMA as i, POLICY_SCHEMA as j, POLICY_SESSION_UCAN_V1_PROFILE as k, POLICY_STATUS_SCHEMA as l, POLICY_V1_DOMAIN as m, POLICY_V1_SCHEMA as n, type PolicyChallengeV3 as o, type PolicyRootStatusV3 as p, type PolicySessionUcanV1 as q, type PolicyStatus as r, ROOT_REVOCATION_V1_SCHEMA as s, ROOT_STATUS_CHECKPOINT_V1_SCHEMA as t, ROOT_STATUS_RENEWAL_V1_DOMAIN as u, ROOT_STATUS_V1_DOMAIN as v, type SignCompactUcanAuthorizationInput as w, SignatureMaterialError as x, type SignatureSuite as y, SignatureVerificationError as z };
680
+ declare const POLICY_V2_SCHEMA: "xyz.tinycloud.policy/policy/v2";
681
+ declare const POLICY_V2_DOMAIN = "xyz.tinycloud.policy/policy/v2\0";
682
+ declare const POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE: "TinyCloudPolicyCredentialRequirement";
683
+ declare const POLICY_PRESENTATION_V3_SCHEMA: "xyz.tinycloud.policy/presentation/v3";
684
+ declare const POLICY_PRESENTATION_V3_DOMAIN = "xyz.tinycloud.policy/Presentation/v3\0";
685
+ interface PolicyCredentialRequirementV1 {
686
+ readonly type: typeof POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE;
687
+ readonly version: 1;
688
+ readonly requirementDigest: string;
689
+ readonly descriptorDigest: string;
690
+ readonly issuerDid: string;
691
+ readonly issuerKid: string;
692
+ readonly profile: {
693
+ readonly id: string;
694
+ readonly version: 1;
695
+ };
696
+ readonly credentialType: {
697
+ readonly id: string;
698
+ readonly version: 1;
699
+ };
700
+ }
701
+ interface UnifiedPolicyV2 {
702
+ readonly schema: typeof POLICY_V2_SCHEMA;
703
+ readonly policyId: string;
704
+ readonly ownerDid: string;
705
+ readonly createdAt: string;
706
+ readonly expiresAt?: string;
707
+ readonly contentSource: UnifiedContentSource;
708
+ readonly capabilityCeiling: readonly UnifiedPolicyCapability[];
709
+ readonly credentialRequirement: PolicyCredentialRequirementV1;
710
+ readonly signature: {
711
+ readonly suite: "Ed25519";
712
+ readonly signerDid: string;
713
+ readonly value: string;
714
+ };
715
+ }
716
+ type UnsignedUnifiedPolicyV2 = Omit<UnifiedPolicyV2, "policyId" | "signature">;
717
+ interface PolicyCredentialPresentationV3 {
718
+ readonly schema: typeof POLICY_PRESENTATION_V3_SCHEMA;
719
+ readonly jti: string;
720
+ readonly challengeId: string;
721
+ readonly nonce: string;
722
+ readonly policyCid: string;
723
+ readonly nodeAudience: string;
724
+ readonly holderDid: string;
725
+ readonly subjectDid: string;
726
+ readonly credentialSpaceOwnerDid: string;
727
+ readonly credentialDigest: string;
728
+ readonly requirementDigest: string;
729
+ readonly descriptorDigest: string;
730
+ readonly requestedCapabilities: readonly UnifiedPolicyCapability[];
731
+ readonly issuedAt: string;
732
+ readonly expiresAt: string;
733
+ readonly signature: {
734
+ readonly suite: "Ed25519";
735
+ readonly signerDid: string;
736
+ readonly value: string;
737
+ };
738
+ }
739
+ declare function validatePolicyCredentialRequirementV1(value: unknown): PolicyCredentialRequirementV1;
740
+ declare function policyV2DigestHex(input: UnsignedUnifiedPolicyV2): string;
741
+ /**
742
+ * Validate the exact non-PII Policy/v2 commitment consumed by the holder.
743
+ * The caller supplies policy bytes already owner-signature verified by Share;
744
+ * Node remains the authoritative signature verifier at admission.
745
+ */
746
+ declare function validateUnifiedPolicyV2(value: unknown, expectedPolicyCid?: string): UnifiedPolicyV2;
747
+ interface BuildPolicyCredentialPresentationV3Input {
748
+ readonly policy: UnifiedPolicyV2;
749
+ readonly policyCid: string;
750
+ readonly challenge: PolicyChallengeV3;
751
+ readonly requirement: CredentialRequirement;
752
+ readonly credential: VerifiedCredential;
753
+ readonly credentialSpaceOwnerDid: string;
754
+ readonly requestedCapabilities: readonly UnifiedPolicyCapability[];
755
+ readonly sign: (digest: Uint8Array) => Promise<Uint8Array>;
756
+ readonly now?: Date;
757
+ readonly jti?: string;
758
+ }
759
+ declare function buildPolicyCredentialPresentationV3(input: BuildPolicyCredentialPresentationV3Input): Promise<PolicyCredentialPresentationV3>;
760
+ interface AdmitPolicyCredentialV3Input extends Omit<BuildPolicyCredentialPresentationV3Input, "challenge"> {
761
+ readonly policyRootCid: string;
762
+ readonly enforcementRootCid: string;
763
+ readonly nodeOrigin: string;
764
+ /** Root authorization CID of the recipient's active TinyCloud account session. */
765
+ readonly accountAuthorizationCid: string;
766
+ /** Recipient-owned `credentials` space covered by the account authorization. */
767
+ readonly credentialSpaceId: string;
768
+ readonly fetch?: typeof fetch;
769
+ }
770
+ interface PolicyCredentialAdmissionV3 {
771
+ readonly challenge: PolicyChallengeV3;
772
+ readonly presentation: PolicyCredentialPresentationV3;
773
+ readonly session: PolicySessionUcanV1;
774
+ }
775
+ /**
776
+ * Present verified TC-463 output to the Policy/v3 admission ceremony.
777
+ * Raw credential material appears only in the TLS POST body.
778
+ */
779
+ declare function admitPolicyCredentialV3(input: AdmitPolicyCredentialV3Input): Promise<PolicyCredentialAdmissionV3>;
780
+
781
+ export { type SignedObjectMaterial as $, ATTESTED_ENFORCER_BINDING_V2_SCHEMA as A, type BuildPolicyCredentialPresentationV3Input as B, CONTENT_SOURCE_V1_DOMAIN as C, type PolicyStatus as D, ED25519_JCS_SIGNATURE_SUITE as E, ROOT_REVOCATION_V1_SCHEMA as F, ROOT_STATUS_CHECKPOINT_V1_SCHEMA as G, ROOT_STATUS_RENEWAL_V1_DOMAIN as H, ROOT_STATUS_V1_DOMAIN as I, type JsonObject as J, type SignCompactUcanAuthorizationInput as K, LAST_V2_CREATE_AT as L, MAX_LEGACY_ENVELOPE_EXPIRES_AT as M, NATIVE_PROJECTION_V1_DOMAIN as N, type SignCompactUcanRootAuthorizationInput as O, type PolicyEngineRecord as P, SignatureMaterialError as Q, ROOT_REVOCATION_V1_DOMAIN as R, type SignedObjectSigner as S, type SignatureSuite as T, type UnsignedPolicyEngineRecord as U, SignatureVerificationError as V, SignedObjectCanonicalizationError as W, SignedObjectDigestError as X, type SignedObjectErrorCode as Y, SignedObjectIdError as Z, type SignedObjectKind as _, type Policy as a, validatePolicyUnsigned as a$, SignedObjectProfileError as a0, SignedObjectSchemaError as a1, type SignedObjectSignature as a2, type SignedObjectVerificationResult as a3, type SignedPolicyObject as a4, SigningKeyBindingError as a5, type UnifiedContentSource as a6, type UnifiedEncryptionCapability as a7, type UnifiedKvCapability as a8, type UnifiedNativeCapability as a9, parsePolicySessionUcan as aA, policyCidFromCanonicalBytes as aB, policyDigestHex as aC, policyIdForDigestHex as aD, policyV2DigestHex as aE, projectUnifiedPolicyCapabilities as aF, projectUnifiedPolicyCapability as aG, renewPolicyRootStatusV3 as aH, requestPolicyChallengeV3 as aI, revokePolicyRootV3 as aJ, signCompactUcanAuthorization as aK, signCompactUcanRootAuthorization as aL, signedObjectIdFor as aM, toSignedObjectError as aN, unifiedNativeProjectionHashHex as aO, unifiedPolicyCapabilityContains as aP, unifiedPolicyCapabilityDigestHex as aQ, unifiedPolicyCapabilityFromNative as aR, validatePolicyCredentialRequirementV1 as aS, validatePolicyEngineRecordSigned as aT, validatePolicyEngineRecordSignedShape as aU, validatePolicyEngineRecordUnsigned as aV, validatePolicySigned as aW, validatePolicySignedShape as aX, validatePolicyStatusSigned as aY, validatePolicyStatusSignedShape as aZ, validatePolicyStatusUnsigned as a_, type UnifiedPolicyCapability as aa, type UnifiedPolicyV1 as ab, type UnifiedPolicyV2 as ac, type UnifiedResourceSelector as ad, type UnsignedPolicy as ae, type UnsignedPolicyObject as af, type UnsignedPolicyStatus as ag, type UnsignedUnifiedPolicyV2 as ah, UnsupportedSignatureSuiteError as ai, admitPolicyCredentialV3 as aj, buildPolicyCredentialPresentationV3 as ak, canonicalizeSignedObjectUnsigned as al, canonicalizeUnifiedPolicyCapability as am, compactAttenuationContains as an, contentSourceDigestHex as ao, createAndSignPolicy as ap, createAndSignPolicyEngineRecord as aq, createAndSignPolicyStatus as ar, createAndSignSignedObject as as, createCompactPolicyDescendant as at, createCompactPolicyInvocation as au, deriveSignedObjectMaterial as av, getPolicyRootStatusV3 as aw, mintPolicySessionV3 as ax, normalizeUnifiedPolicyCapability as ay, parseCompactUcanAuthorization as az, type AdmitPolicyCredentialV3Input as b, validateUnifiedPolicyV2 as b0, verifyPolicy as b1, verifyPolicyEngineRecord as b2, verifyPolicyRootRevocationV3 as b3, verifyPolicyRootStatusCheckpointV3 as b4, verifyPolicyStatus as b5, verifySignedObject as b6, type CredentialHolderBinding as b7, type CredentialFlowDescriptor as b8, type CredentialRequirement as b9, type StoredCredentialRecord as ba, type VerifiedCredential as bb, type CredentialStorageReceipt as bc, type IssuedCredentialEnvelope as bd, type CredentialIssuerMetadata as be, CREDENTIAL_ACQUISITION_PROTOCOL as bf, CREDENTIAL_CONTRACT_VERSION as bg, CREDENTIAL_FORMAT as bh, CREDENTIAL_STEP_REGISTRY_VERSION as bi, type CredentialClaimDescriptor as bj, type CredentialEndpointId as bk, type CredentialInputDescriptor as bl, type CredentialProgressEvent as bm, type CredentialStepDescriptor as bn, type CredentialStepType as bo, type CredentialUxState as bp, HOLDER_BINDING_DOMAIN as bq, type IssuerVerificationKey as br, type CompactPolicyInvocationInput as c, type CompactUcanAuthorizationV1 as d, EIP191_JCS_SIGNATURE_SUITE as e, LAST_V2_READ_AT as f, POLICY_CAPABILITY_V1_DOMAIN as g, POLICY_CAPABILITY_V1_SCHEMA as h, POLICY_CREDENTIAL_REQUIREMENT_V1_TYPE as i, POLICY_ENFORCEMENT_DELEGATION_V2_SCHEMA as j, POLICY_ENGINE_RECORD_SCHEMA as k, POLICY_PRESENTATION_V3_DOMAIN as l, POLICY_PRESENTATION_V3_SCHEMA as m, POLICY_SCHEMA as n, POLICY_SESSION_UCAN_V1_PROFILE as o, POLICY_STATUS_SCHEMA as p, POLICY_V1_DOMAIN as q, POLICY_V1_SCHEMA as r, POLICY_V2_DOMAIN as s, POLICY_V2_SCHEMA as t, type PolicyChallengeV3 as u, type PolicyCredentialAdmissionV3 as v, type PolicyCredentialPresentationV3 as w, type PolicyCredentialRequirementV1 as x, type PolicyRootStatusV3 as y, type PolicySessionUcanV1 as z };
@@ -4169,14 +4169,14 @@ function decodeBase64Url(value) {
4169
4169
  if (!/^[A-Za-z0-9_-]+$/.test(value) || value.length % 4 === 1)
4170
4170
  throw new Error("value is not canonical base64url");
4171
4171
  const normalized = value.replace(/-/g, "+").replace(/_/g, "/");
4172
- const binary = typeof Buffer !== "undefined" ? Buffer.from(normalized, "base64").toString("binary") : atob(normalized.padEnd(Math.ceil(normalized.length / 4) * 4, "="));
4172
+ const binary = typeof atob === "function" ? atob(normalized.padEnd(Math.ceil(normalized.length / 4) * 4, "=")) : Buffer.from(normalized, "base64").toString("binary");
4173
4173
  const bytes2 = Uint8Array.from(binary, (character) => character.charCodeAt(0));
4174
- const encoded = typeof Buffer !== "undefined" ? Buffer.from(bytes2).toString("base64url") : btoa(String.fromCharCode(...bytes2)).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
4174
+ const encoded = typeof btoa === "function" ? btoa(String.fromCharCode(...bytes2)).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_") : Buffer.from(bytes2).toString("base64url");
4175
4175
  if (encoded !== value) throw new Error("value is not canonical base64url");
4176
4176
  return bytes2;
4177
4177
  }
4178
4178
  function encodeBase64Url(value) {
4179
- return typeof Buffer !== "undefined" ? Buffer.from(value).toString("base64url") : btoa(String.fromCharCode(...value)).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
4179
+ return typeof btoa === "function" ? btoa(String.fromCharCode(...value)).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_") : Buffer.from(value).toString("base64url");
4180
4180
  }
4181
4181
  function equalBytes2(left, right) {
4182
4182
  return left.length === right.length && left.every((byte, index) => byte === right[index]);
@@ -4588,9 +4588,9 @@ var ShareRecipientClient = class {
4588
4588
  const authority = Object.entries(session.att).find(([parentResource, abilities]) => {
4589
4589
  if (!(action in abilities)) return false;
4590
4590
  if (serviceName === "encryption") return parentResource.startsWith("urn:tinycloud:encryption:") && parentResource === cleanPath;
4591
- const match = /^tinycloud:\/\/[^/]+\/kv\/(.+)$/.exec(parentResource);
4592
- if (match === null) return false;
4593
- const parentPath = match[1];
4591
+ const marker = parentResource.indexOf("/kv/");
4592
+ if (marker < 1) return false;
4593
+ const parentPath = parentResource.slice(marker + 4);
4594
4594
  const caveats = abilities[action] ?? [];
4595
4595
  const prefix = caveats.some((value) => isRecord(value) && value.kind === "prefix");
4596
4596
  return cleanPath === parentPath || prefix && cleanPath.startsWith(`${parentPath}/`);
@@ -4616,10 +4616,10 @@ var ShareRecipientClient = class {
4616
4616
  policySessionProjection(delegation) {
4617
4617
  const session = parsePolicySessionUcan(delegation.delegationHeader.Authorization);
4618
4618
  if (session.cid !== delegation.cid || session.aud !== delegation.delegateDID) throw new ShareAccessError("SHARE_SESSION_INVALID");
4619
- const kvResource = Object.keys(session.att).find((resource) => /^tinycloud:\/\/[^/]+\/kv\/.+$/.test(resource));
4620
- const match = kvResource === void 0 ? void 0 : /^tinycloud:\/\/([^/]+)\/kv\/(.+)$/.exec(kvResource);
4621
- if (match === void 0 || match === null) throw new ShareAccessError("SHARE_SESSION_INVALID");
4622
- return { spaceId: match[1] };
4619
+ const kvResource = Object.keys(session.att).find((resource) => resource.indexOf("/kv/") > 0);
4620
+ const marker = kvResource?.indexOf("/kv/") ?? -1;
4621
+ if (kvResource === void 0 || marker < 1) throw new ShareAccessError("SHARE_SESSION_INVALID");
4622
+ return { spaceId: kvResource.slice(0, marker) };
4623
4623
  }
4624
4624
  createKV(origin, session, invokeOverride) {
4625
4625
  const invoke = invokeOverride ?? this.options.invoke ?? nativeInvoke;