@tinycloud/share-sdk 1.2.0-beta.3 → 1.2.0-beta.4

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.
@@ -0,0 +1,180 @@
1
+ import { d as OwnerShareAction, f as OwnerShareMatcher, j as PublishedShareDeliveryMaterial, q as SignedDelegation, h as OwnerSharePolicyRegistrationReceipt, a as DelegatedShareKey, P as PublishedShare } from './owner-policy-BqzRlkb6.js';
2
+
3
+ interface EncryptedShareHistoryStorage {
4
+ put(value: Uint8Array): Promise<void>;
5
+ list(): Promise<readonly Uint8Array[]>;
6
+ clear(): Promise<void>;
7
+ }
8
+ declare class MemoryEncryptedShareHistoryStorage implements EncryptedShareHistoryStorage {
9
+ private readonly values;
10
+ put(value: Uint8Array): Promise<void>;
11
+ list(): Promise<readonly Uint8Array[]>;
12
+ clear(): Promise<void>;
13
+ }
14
+ /**
15
+ * The durable record a sender needs, after a reload, to display and manage
16
+ * a share it created. Every identity/CID here comes verbatim from the
17
+ * Node-verified {@link OwnerSharePolicyRegistrationReceipt}; nothing is
18
+ * re-derived or guessed.
19
+ */
20
+ interface SenderShareRecord {
21
+ readonly shareId: string;
22
+ readonly registrationCid?: string;
23
+ readonly policyCid?: string;
24
+ readonly ownerDelegationCid?: string;
25
+ readonly enforcementDelegationCid?: string;
26
+ readonly shareKeyDid?: string;
27
+ readonly ownerDid?: string;
28
+ readonly enforcerDid?: string;
29
+ readonly target: {
30
+ readonly origin: string;
31
+ readonly nodeAudience: string;
32
+ readonly spaceId: string;
33
+ };
34
+ readonly resource: {
35
+ readonly kind: "exact" | "prefix";
36
+ readonly path: string;
37
+ };
38
+ readonly actions: readonly OwnerShareAction[];
39
+ readonly recipientMatcher: OwnerShareMatcher;
40
+ /** The signed target discriminator, retained separately from the email matcher. */
41
+ readonly targetKind?: "bearer" | "recipientDid" | "email" | "emailDomain";
42
+ readonly registeredAt: string;
43
+ readonly expiresAt: string;
44
+ readonly revokedAt?: string;
45
+ readonly envelopeCid?: string;
46
+ readonly shareCid?: string;
47
+ /** Complete bearer links are encrypted at rest and only revealed explicitly. */
48
+ readonly link?: string;
49
+ readonly filename?: string;
50
+ /** Policy/v3 delivery material. The containing history record must remain encrypted at rest. */
51
+ readonly deliveryMaterial?: PublishedShareDeliveryMaterial;
52
+ /** Canonical mailboxes whose invitation delivery was confirmed; history is encrypted at rest. */
53
+ readonly deliveredRecipients?: readonly string[];
54
+ /**
55
+ * `migrated`: imported once from a CLI's local history by the OWNER's
56
+ * session (slice 5), at an owner-layout key `records/<shareId>`. Such a
57
+ * record is exempt from the ±1-day `registeredAt` window and nothing else:
58
+ * its chain is verified like an agent record's, it never ranks as a web
59
+ * row, and it cannot override a revocation. A record claiming `migrated`
60
+ * inside an agent subtree is rejected.
61
+ */
62
+ readonly provenance?: "migrated";
63
+ /**
64
+ * The signed chain behind every CID this record claims (TC-1432 C1), as
65
+ * exact bytes. Agent records carry it so the owner's browser can verify
66
+ * the chain without a node lookup. Policy/v3 records prove through
67
+ * `deliveryMaterial.envelope` plus `session`.
68
+ */
69
+ readonly proofs?: SenderShareRecordProofs;
70
+ }
71
+ interface SenderShareRecordProofs {
72
+ /** Owner→session SIWE CACAO (base64url DAG-CBOR) of the issuing session; absent when it is gone. */
73
+ readonly session?: string;
74
+ /** Native bearer link delegation (compact UCAN); its CID is `enforcementDelegationCid`. */
75
+ readonly link?: string;
76
+ /** Policy/v2 owner-policy chain: policy bytes (base64url), owner→share-key SIWE CACAO (base64url), enforcement delegation and node registration receipt. */
77
+ readonly ownerPolicy?: string;
78
+ readonly ownerDelegation?: string;
79
+ readonly enforcementDelegation?: SignedDelegation;
80
+ readonly registration?: OwnerSharePolicyRegistrationReceipt;
81
+ }
82
+ /** Create the durable encrypted-history shape from canonical publication receipts. */
83
+ declare function historyRecordForPublishedShare(result: PublishedShare, now?: Date): SenderShareRecord;
84
+ /**
85
+ * "direct" selects the Policy/v3 enforcement root; "ancestor" selects its
86
+ * policy-authority sibling. Addressed shares revoke that signed root through
87
+ * the Node Policy/v3 endpoint, which cuts off existing sessions as well as
88
+ * fresh admission and delivery. Bearer shares retain ordinary delegation
89
+ * revocation.
90
+ */
91
+ type SenderShareRevocationScope = "direct" | "ancestor";
92
+ interface SenderShareRecordStorage {
93
+ put(record: SenderShareRecord): Promise<void>;
94
+ /** Atomically transform the latest record, if present. Implementations that
95
+ * provide this must serialize the read and write with every other writer. */
96
+ update?(shareId: string, change: (record: SenderShareRecord) => SenderShareRecord | Promise<SenderShareRecord>): Promise<SenderShareRecord | undefined>;
97
+ list(): Promise<readonly SenderShareRecord[]>;
98
+ get(shareId: string): Promise<SenderShareRecord | undefined>;
99
+ delete(shareId: string): Promise<void>;
100
+ }
101
+ interface StoredSenderShareKey {
102
+ readonly cryptoKey: CryptoKey;
103
+ readonly publicKey: Uint8Array;
104
+ readonly extractable: boolean;
105
+ }
106
+ interface SenderShareKeyStorage {
107
+ put(shareId: string, key: StoredSenderShareKey): Promise<void>;
108
+ get(shareId: string): Promise<StoredSenderShareKey | undefined>;
109
+ delete(shareId: string): Promise<void>;
110
+ }
111
+ /** In-memory reference implementation. Real deployments back these with IndexedDB so the non-extractable `CryptoKey` survives a reload via structured clone. */
112
+ declare class MemorySenderShareRecordStorage implements SenderShareRecordStorage {
113
+ private readonly records;
114
+ private operation;
115
+ private serialize;
116
+ put(record: SenderShareRecord): Promise<void>;
117
+ update(shareId: string, change: (record: SenderShareRecord) => SenderShareRecord | Promise<SenderShareRecord>): Promise<SenderShareRecord | undefined>;
118
+ list(): Promise<readonly SenderShareRecord[]>;
119
+ get(shareId: string): Promise<SenderShareRecord | undefined>;
120
+ delete(shareId: string): Promise<void>;
121
+ }
122
+ declare class MemorySenderShareKeyStorage implements SenderShareKeyStorage {
123
+ private readonly keys;
124
+ put(shareId: string, key: StoredSenderShareKey): Promise<void>;
125
+ get(shareId: string): Promise<StoredSenderShareKey | undefined>;
126
+ delete(shareId: string): Promise<void>;
127
+ }
128
+ interface SenderShareStoreOptions {
129
+ readonly records: SenderShareRecordStorage;
130
+ readonly keys: SenderShareKeyStorage;
131
+ readonly now?: () => Date;
132
+ }
133
+ /**
134
+ * Reload-safe sender-side management for shares created through
135
+ * {@link canonicalOwnerSharePolicy} / `registerOwnerSharePolicy`. Persists
136
+ * the registration receipt's canonical identity tuple plus the ephemeral
137
+ * share key's non-extractable `CryptoKey` handle, so a sender can list,
138
+ * inspect, and revoke shares it created in an earlier session -- without
139
+ * ever re-exporting private key material.
140
+ */
141
+ declare class SenderShareStore {
142
+ private readonly records;
143
+ private readonly keys;
144
+ private readonly now;
145
+ constructor(options: SenderShareStoreOptions);
146
+ /** Persist a Node-verified registration receipt and its share key handle. */
147
+ save(receipt: OwnerSharePolicyRegistrationReceipt, key: DelegatedShareKey): Promise<SenderShareRecord>;
148
+ /** List shares created in any session, most recent first. */
149
+ list(options?: {
150
+ readonly includeRevoked?: boolean;
151
+ readonly includeExpired?: boolean;
152
+ }): Promise<readonly SenderShareRecord[]>;
153
+ get(shareId: string): Promise<SenderShareRecord | undefined>;
154
+ /** Recover a signer for the persisted share key after a reload. */
155
+ loadKey(shareId: string): Promise<DelegatedShareKey | undefined>;
156
+ /**
157
+ * The delegation CID to pass to the node's existing generic
158
+ * `tinycloud.delegation/revoke` invocation to revoke this share at the
159
+ * requested scope. Does not itself call the node -- callers invoke
160
+ * their own `revokeDelegation`/`DelegationManager.revoke` with the
161
+ * returned CID, then call {@link markRevoked} once that succeeds.
162
+ */
163
+ revocationTarget(shareId: string, scope: SenderShareRevocationScope): Promise<string>;
164
+ /** Mark a share revoked locally after the caller's node-side revoke call succeeds. */
165
+ markRevoked(shareId: string, revokedAt?: string): Promise<SenderShareRecord>;
166
+ /** Forget a share and clear its persisted key handle. */
167
+ remove(shareId: string): Promise<void>;
168
+ }
169
+ /** WebCrypto-backed persistence adapter; links and private material are absent. */
170
+ declare class EncryptedSenderShareHistory {
171
+ private readonly storage;
172
+ private readonly key;
173
+ private readonly now;
174
+ constructor(storage: EncryptedShareHistoryStorage, key: CryptoKey, now?: () => Date);
175
+ put(record: SenderShareRecord): Promise<void>;
176
+ list(): Promise<readonly SenderShareRecord[]>;
177
+ clear(): Promise<void>;
178
+ }
179
+
180
+ export { EncryptedSenderShareHistory as E, MemoryEncryptedShareHistoryStorage as M, type SenderShareRecord as S, type SenderShareRecordStorage as a, type EncryptedShareHistoryStorage as b, MemorySenderShareKeyStorage as c, MemorySenderShareRecordStorage as d, type SenderShareKeyStorage as e, type SenderShareRecordProofs as f, type SenderShareRevocationScope as g, SenderShareStore as h, historyRecordForPublishedShare as i };