@tinycloud/share-sdk 1.2.0-beta.2 → 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.
- package/dist/addressed-publish-BDaGyQA9.d.ts +240 -0
- package/dist/addressed-publish-DVvTlGog.d.cts +240 -0
- package/dist/history-CUWDK0lE.d.cts +180 -0
- package/dist/history-CyT6x8h4.d.ts +180 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -153
- package/dist/index.d.ts +6 -153
- package/dist/index.js.map +1 -1
- package/dist/owner-policy-BqzRlkb6.d.cts +297 -0
- package/dist/owner-policy-BqzRlkb6.d.ts +297 -0
- package/dist/share-index.cjs +8694 -0
- package/dist/share-index.cjs.map +1 -0
- package/dist/share-index.d.cts +1063 -0
- package/dist/share-index.d.ts +1063 -0
- package/dist/share-index.js +8622 -0
- package/dist/share-index.js.map +1 -0
- package/dist/share-root.cjs +667 -294
- package/dist/share-root.cjs.map +1 -1
- package/dist/share-root.d.cts +342 -195
- package/dist/share-root.d.ts +342 -195
- package/dist/share-root.js +656 -287
- package/dist/share-root.js.map +1 -1
- package/package.json +7 -1
- package/dist/addressed-publish-CsUS7-SI.d.cts +0 -535
- package/dist/addressed-publish-CsUS7-SI.d.ts +0 -535
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { ShareEnvelopeV2, UnifiedPolicyCapability, ShareAction, UnifiedContentSource, PolicyCredentialRequirementV1 } from '@tinycloud/share-envelope';
|
|
2
|
+
import { p as SharePublishTarget, P as PublishedShare, o as SharePublishOptions, d as OwnerShareAction, j as PublishedShareDeliveryMaterial } from './owner-policy-BqzRlkb6.js';
|
|
3
|
+
|
|
4
|
+
/** The only interactive boundary exposed by the headless SDK. */
|
|
5
|
+
type ShareAuthorizationMethod = "openkey-device" | "email-claim" | "email-otp";
|
|
6
|
+
interface ShareAuthorizationRequired {
|
|
7
|
+
readonly state: "authorization-required";
|
|
8
|
+
readonly method: ShareAuthorizationMethod;
|
|
9
|
+
/** A browser-safe continuation location. It must never contain a claim secret. */
|
|
10
|
+
readonly continueUrl?: string;
|
|
11
|
+
/** An opaque, short-lived, nonce-bound handle. It is not a bearer credential. */
|
|
12
|
+
readonly resumeToken?: string;
|
|
13
|
+
}
|
|
14
|
+
interface ShareAuthorizationDenied {
|
|
15
|
+
readonly state: "denied";
|
|
16
|
+
readonly reason: "rejected" | "expired" | "revoked" | "unsupported";
|
|
17
|
+
}
|
|
18
|
+
interface ShareAuthorizationReady<T> {
|
|
19
|
+
readonly state: "ready";
|
|
20
|
+
readonly value: T;
|
|
21
|
+
}
|
|
22
|
+
type ShareAuthorizationResult<T> = ShareAuthorizationReady<T> | ShareAuthorizationRequired | ShareAuthorizationDenied;
|
|
23
|
+
interface ShareAuthorizationAdapter<T> {
|
|
24
|
+
begin(input: {
|
|
25
|
+
readonly envelope: ShareEnvelopeV2;
|
|
26
|
+
readonly method: ShareAuthorizationMethod;
|
|
27
|
+
}): Promise<ShareAuthorizationResult<T>>;
|
|
28
|
+
resume(input: {
|
|
29
|
+
readonly envelope: ShareEnvelopeV2;
|
|
30
|
+
readonly method: ShareAuthorizationMethod;
|
|
31
|
+
readonly resumeToken: string;
|
|
32
|
+
readonly proof?: unknown;
|
|
33
|
+
}): Promise<ShareAuthorizationResult<T>>;
|
|
34
|
+
/** Verify the detached node proof against a pinned authority trust bundle. */
|
|
35
|
+
readonly verifyResult?: (input: {
|
|
36
|
+
readonly envelope: ShareEnvelopeV2;
|
|
37
|
+
readonly value: T;
|
|
38
|
+
readonly proof: unknown;
|
|
39
|
+
}) => Promise<boolean>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A node-authorized addressed read. Returning plaintext alone is not an
|
|
43
|
+
* authorization result: the caller must also return the signed response
|
|
44
|
+
* binding and digest that the node produced for that exact share.
|
|
45
|
+
*/
|
|
46
|
+
interface ShareAuthorizedContent {
|
|
47
|
+
readonly bytes: Uint8Array;
|
|
48
|
+
readonly bodyDigest: string;
|
|
49
|
+
readonly contentSourceDigest: string;
|
|
50
|
+
readonly binding: {
|
|
51
|
+
readonly shareId: string;
|
|
52
|
+
readonly delegationCid: string;
|
|
53
|
+
readonly authorityMaterialHandle: string;
|
|
54
|
+
readonly authorityMaterialDigest: string;
|
|
55
|
+
readonly resource: {
|
|
56
|
+
readonly kind: "exact" | "prefix";
|
|
57
|
+
readonly path: string;
|
|
58
|
+
};
|
|
59
|
+
readonly action?: string;
|
|
60
|
+
};
|
|
61
|
+
/** A detached node proof; self-reported bytes and digests are not authorization. */
|
|
62
|
+
readonly proof: unknown;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Start or continue a target authorization without ever guessing a device,
|
|
66
|
+
* claim, or delegation secret. Adapters own their protocol and are expected
|
|
67
|
+
* to bind their resume token to a server challenge and expiry.
|
|
68
|
+
*/
|
|
69
|
+
declare function authorizeShare<T>(input: {
|
|
70
|
+
readonly envelope: ShareEnvelopeV2;
|
|
71
|
+
readonly method: ShareAuthorizationMethod;
|
|
72
|
+
readonly adapter: ShareAuthorizationAdapter<T>;
|
|
73
|
+
readonly resumeToken?: string;
|
|
74
|
+
readonly proof?: unknown;
|
|
75
|
+
}): Promise<ShareAuthorizationResult<T>>;
|
|
76
|
+
declare function authorizationMethodForTarget(target: {
|
|
77
|
+
readonly kind: string;
|
|
78
|
+
}): ShareAuthorizationMethod | undefined;
|
|
79
|
+
|
|
80
|
+
type ShareTarget = SharePublishTarget;
|
|
81
|
+
interface TargetPublishInput {
|
|
82
|
+
readonly source: Uint8Array;
|
|
83
|
+
readonly filename: string;
|
|
84
|
+
readonly mediaType?: string;
|
|
85
|
+
/** Additional files for a prefix resource; source remains the first file for compatibility. */
|
|
86
|
+
readonly files?: readonly {
|
|
87
|
+
readonly bytes: Uint8Array;
|
|
88
|
+
readonly filename: string;
|
|
89
|
+
readonly mediaType?: string;
|
|
90
|
+
}[];
|
|
91
|
+
readonly target: ShareTarget;
|
|
92
|
+
readonly expiresAt: Date;
|
|
93
|
+
readonly expiryWasExplicit?: boolean;
|
|
94
|
+
readonly origin: string;
|
|
95
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
96
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
97
|
+
readonly notify?: boolean;
|
|
98
|
+
/** Publish as the next write-once version of this artifact and pin the share to it (TC-1428). */
|
|
99
|
+
readonly artifact?: {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
readonly note?: string;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
|
|
105
|
+
interface TargetPublishAdapter {
|
|
106
|
+
publish(input: TargetPublishInput): Promise<TargetPublishOutcome>;
|
|
107
|
+
}
|
|
108
|
+
declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
|
|
109
|
+
declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
|
|
110
|
+
/** Route every share through the authenticated TinyCloud authority adapter. */
|
|
111
|
+
declare function publishTargetShare(input: SharePublishOptions & {
|
|
112
|
+
readonly target: ShareTarget;
|
|
113
|
+
readonly notify?: boolean;
|
|
114
|
+
readonly targetAdapter?: TargetPublishAdapter;
|
|
115
|
+
readonly files?: readonly {
|
|
116
|
+
readonly bytes: Uint8Array;
|
|
117
|
+
readonly filename: string;
|
|
118
|
+
readonly mediaType?: string;
|
|
119
|
+
}[];
|
|
120
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
121
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
122
|
+
}): Promise<TargetPublishOutcome>;
|
|
123
|
+
|
|
124
|
+
interface AddressedOwnerRootInput {
|
|
125
|
+
readonly ownerDid: string;
|
|
126
|
+
readonly role: "policy-authority" | "policy-enforcement";
|
|
127
|
+
readonly audienceDid: string;
|
|
128
|
+
readonly policyId: string;
|
|
129
|
+
readonly policyDigestHex: string;
|
|
130
|
+
readonly policyCid: string;
|
|
131
|
+
readonly contentSourceDigestHex: string;
|
|
132
|
+
readonly capabilityCeilingHashHex: string;
|
|
133
|
+
readonly nativeProjectionHashHex: string;
|
|
134
|
+
readonly notBefore: Date;
|
|
135
|
+
readonly expiresAt: Date;
|
|
136
|
+
readonly nodeAudience: string;
|
|
137
|
+
readonly capabilities: readonly UnifiedPolicyCapability[];
|
|
138
|
+
}
|
|
139
|
+
interface AddressedOwnerRootReceipt {
|
|
140
|
+
readonly cid: string;
|
|
141
|
+
readonly delegationHeader: {
|
|
142
|
+
readonly Authorization: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
interface AddressedPolicyRegistrationInput {
|
|
146
|
+
readonly policyCid: string;
|
|
147
|
+
readonly policy: Readonly<Record<string, unknown>>;
|
|
148
|
+
readonly policyRoot: {
|
|
149
|
+
readonly cid: string;
|
|
150
|
+
readonly authorization: string;
|
|
151
|
+
};
|
|
152
|
+
readonly enforcementRoot: {
|
|
153
|
+
readonly cid: string;
|
|
154
|
+
readonly authorization: string;
|
|
155
|
+
};
|
|
156
|
+
readonly contentSourceDigestHex: string;
|
|
157
|
+
readonly nativeProjectionHashHex: string;
|
|
158
|
+
readonly rootExpiresAt: string;
|
|
159
|
+
readonly enforcerDid: string;
|
|
160
|
+
readonly expectedNodeAudience: string;
|
|
161
|
+
}
|
|
162
|
+
interface AddressedPolicyRegistrationReceipt {
|
|
163
|
+
readonly policyCid: string;
|
|
164
|
+
readonly policyRootCid: string;
|
|
165
|
+
readonly enforcementRootCid: string;
|
|
166
|
+
readonly attestedEnforcerBinding: {
|
|
167
|
+
readonly schema: "xyz.tinycloud.policy/attested-enforcer/v2";
|
|
168
|
+
readonly enforcerDid: string;
|
|
169
|
+
readonly nodeAudience: string;
|
|
170
|
+
readonly attestationBindingDigestHex: string;
|
|
171
|
+
readonly issuedAt: string;
|
|
172
|
+
readonly expiresAt: string;
|
|
173
|
+
readonly signature: {
|
|
174
|
+
readonly suite: "Ed25519";
|
|
175
|
+
readonly signerDid: string;
|
|
176
|
+
readonly value: string;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/** App-neutral owner authority. Node SDK owns all Policy/v3 transport. */
|
|
181
|
+
interface AddressedPublishAuthority {
|
|
182
|
+
readonly ownerDid: string;
|
|
183
|
+
createOwnerRoot(input: AddressedOwnerRootInput): Promise<AddressedOwnerRootReceipt>;
|
|
184
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
185
|
+
registerPolicy(input: AddressedPolicyRegistrationInput): Promise<AddressedPolicyRegistrationReceipt>;
|
|
186
|
+
}
|
|
187
|
+
interface AddressedSharePublishOptions {
|
|
188
|
+
readonly shareId: string;
|
|
189
|
+
readonly shareOrigin: string;
|
|
190
|
+
readonly nodeOrigin: string;
|
|
191
|
+
readonly nodeAudience: string;
|
|
192
|
+
readonly enforcerDid: string;
|
|
193
|
+
readonly spaceId: string;
|
|
194
|
+
readonly target: Exclude<ShareTarget, {
|
|
195
|
+
readonly kind: "bearer";
|
|
196
|
+
}>;
|
|
197
|
+
readonly resource: {
|
|
198
|
+
readonly kind: "exact" | "prefix";
|
|
199
|
+
readonly path: string;
|
|
200
|
+
};
|
|
201
|
+
readonly actions: readonly ShareAction[];
|
|
202
|
+
readonly policyActions: readonly OwnerShareAction[];
|
|
203
|
+
readonly contentSource: UnifiedContentSource;
|
|
204
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
205
|
+
readonly filename: string;
|
|
206
|
+
readonly mediaType: string;
|
|
207
|
+
readonly byteLength: number;
|
|
208
|
+
readonly artifact?: "html";
|
|
209
|
+
readonly deliveryEmail?: string;
|
|
210
|
+
readonly expiresAt: Date;
|
|
211
|
+
/** Sender-history material required by Node's Policy/v3 delivery authorization. */
|
|
212
|
+
readonly onDeliveryMaterial?: (input: PublishedShareDeliveryMaterial) => void;
|
|
213
|
+
readonly authority: AddressedPublishAuthority;
|
|
214
|
+
}
|
|
215
|
+
type MailboxTarget = Extract<ShareTarget, {
|
|
216
|
+
readonly kind: "email" | "emailDomain";
|
|
217
|
+
}>;
|
|
218
|
+
/** The Policy/v2 credential commitment a share addressed to `target` must carry. */
|
|
219
|
+
declare function addressedCredentialRequirement(target: MailboxTarget): PolicyCredentialRequirementV1;
|
|
220
|
+
/** Facts every addressed-share check needs, available before any side effect. */
|
|
221
|
+
type AddressedShareRequest = Pick<AddressedSharePublishOptions, "target" | "actions" | "policyActions" | "filename" | "deliveryEmail">;
|
|
222
|
+
interface PreparedAddressedShare {
|
|
223
|
+
/** The canonical target the envelope's recipient matcher will carry. */
|
|
224
|
+
readonly target: Exclude<ShareTarget, {
|
|
225
|
+
readonly kind: "bearer";
|
|
226
|
+
}>;
|
|
227
|
+
/** Present for mailbox targets: the Policy/v2 commitment to pass to `publishAddressedShare`. */
|
|
228
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Runs every argument and target check of `publishAddressedShare` that does
|
|
232
|
+
* not depend on stored content, and derives the credential commitment. It has
|
|
233
|
+
* no side effects, so senders call it before uploading content or publishing
|
|
234
|
+
* a location record; a refused share then leaves nothing behind.
|
|
235
|
+
*/
|
|
236
|
+
declare function prepareAddressedShare(request: AddressedShareRequest): PreparedAddressedShare;
|
|
237
|
+
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
238
|
+
declare function publishAddressedShare(input: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
239
|
+
|
|
240
|
+
export { type AddressedOwnerRootInput as A, type PreparedAddressedShare as P, type ShareAuthorizationMethod as S, type TargetPublishOutcome as T, type ShareAuthorizedContent as a, type ShareAuthorizationAdapter as b, type TargetPublishInput as c, type ShareAuthorizationResult as d, type ShareTarget as e, type AddressedOwnerRootReceipt as f, type AddressedPolicyRegistrationInput as g, type AddressedPolicyRegistrationReceipt as h, type AddressedPublishAuthority as i, type AddressedSharePublishOptions as j, type AddressedShareRequest as k, type ShareAuthorizationDenied as l, type ShareAuthorizationReady as m, type ShareAuthorizationRequired as n, type TargetPublishAdapter as o, addressedCredentialRequirement as p, authorizationMethodForTarget as q, authorizeShare as r, normalizeShareTarget as s, prepareAddressedShare as t, publishAddressedShare as u, publishTargetShare as v, targetAuthorizationMethod as w };
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { ShareEnvelopeV2, UnifiedPolicyCapability, ShareAction, UnifiedContentSource, PolicyCredentialRequirementV1 } from '@tinycloud/share-envelope';
|
|
2
|
+
import { p as SharePublishTarget, P as PublishedShare, o as SharePublishOptions, d as OwnerShareAction, j as PublishedShareDeliveryMaterial } from './owner-policy-BqzRlkb6.cjs';
|
|
3
|
+
|
|
4
|
+
/** The only interactive boundary exposed by the headless SDK. */
|
|
5
|
+
type ShareAuthorizationMethod = "openkey-device" | "email-claim" | "email-otp";
|
|
6
|
+
interface ShareAuthorizationRequired {
|
|
7
|
+
readonly state: "authorization-required";
|
|
8
|
+
readonly method: ShareAuthorizationMethod;
|
|
9
|
+
/** A browser-safe continuation location. It must never contain a claim secret. */
|
|
10
|
+
readonly continueUrl?: string;
|
|
11
|
+
/** An opaque, short-lived, nonce-bound handle. It is not a bearer credential. */
|
|
12
|
+
readonly resumeToken?: string;
|
|
13
|
+
}
|
|
14
|
+
interface ShareAuthorizationDenied {
|
|
15
|
+
readonly state: "denied";
|
|
16
|
+
readonly reason: "rejected" | "expired" | "revoked" | "unsupported";
|
|
17
|
+
}
|
|
18
|
+
interface ShareAuthorizationReady<T> {
|
|
19
|
+
readonly state: "ready";
|
|
20
|
+
readonly value: T;
|
|
21
|
+
}
|
|
22
|
+
type ShareAuthorizationResult<T> = ShareAuthorizationReady<T> | ShareAuthorizationRequired | ShareAuthorizationDenied;
|
|
23
|
+
interface ShareAuthorizationAdapter<T> {
|
|
24
|
+
begin(input: {
|
|
25
|
+
readonly envelope: ShareEnvelopeV2;
|
|
26
|
+
readonly method: ShareAuthorizationMethod;
|
|
27
|
+
}): Promise<ShareAuthorizationResult<T>>;
|
|
28
|
+
resume(input: {
|
|
29
|
+
readonly envelope: ShareEnvelopeV2;
|
|
30
|
+
readonly method: ShareAuthorizationMethod;
|
|
31
|
+
readonly resumeToken: string;
|
|
32
|
+
readonly proof?: unknown;
|
|
33
|
+
}): Promise<ShareAuthorizationResult<T>>;
|
|
34
|
+
/** Verify the detached node proof against a pinned authority trust bundle. */
|
|
35
|
+
readonly verifyResult?: (input: {
|
|
36
|
+
readonly envelope: ShareEnvelopeV2;
|
|
37
|
+
readonly value: T;
|
|
38
|
+
readonly proof: unknown;
|
|
39
|
+
}) => Promise<boolean>;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* A node-authorized addressed read. Returning plaintext alone is not an
|
|
43
|
+
* authorization result: the caller must also return the signed response
|
|
44
|
+
* binding and digest that the node produced for that exact share.
|
|
45
|
+
*/
|
|
46
|
+
interface ShareAuthorizedContent {
|
|
47
|
+
readonly bytes: Uint8Array;
|
|
48
|
+
readonly bodyDigest: string;
|
|
49
|
+
readonly contentSourceDigest: string;
|
|
50
|
+
readonly binding: {
|
|
51
|
+
readonly shareId: string;
|
|
52
|
+
readonly delegationCid: string;
|
|
53
|
+
readonly authorityMaterialHandle: string;
|
|
54
|
+
readonly authorityMaterialDigest: string;
|
|
55
|
+
readonly resource: {
|
|
56
|
+
readonly kind: "exact" | "prefix";
|
|
57
|
+
readonly path: string;
|
|
58
|
+
};
|
|
59
|
+
readonly action?: string;
|
|
60
|
+
};
|
|
61
|
+
/** A detached node proof; self-reported bytes and digests are not authorization. */
|
|
62
|
+
readonly proof: unknown;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Start or continue a target authorization without ever guessing a device,
|
|
66
|
+
* claim, or delegation secret. Adapters own their protocol and are expected
|
|
67
|
+
* to bind their resume token to a server challenge and expiry.
|
|
68
|
+
*/
|
|
69
|
+
declare function authorizeShare<T>(input: {
|
|
70
|
+
readonly envelope: ShareEnvelopeV2;
|
|
71
|
+
readonly method: ShareAuthorizationMethod;
|
|
72
|
+
readonly adapter: ShareAuthorizationAdapter<T>;
|
|
73
|
+
readonly resumeToken?: string;
|
|
74
|
+
readonly proof?: unknown;
|
|
75
|
+
}): Promise<ShareAuthorizationResult<T>>;
|
|
76
|
+
declare function authorizationMethodForTarget(target: {
|
|
77
|
+
readonly kind: string;
|
|
78
|
+
}): ShareAuthorizationMethod | undefined;
|
|
79
|
+
|
|
80
|
+
type ShareTarget = SharePublishTarget;
|
|
81
|
+
interface TargetPublishInput {
|
|
82
|
+
readonly source: Uint8Array;
|
|
83
|
+
readonly filename: string;
|
|
84
|
+
readonly mediaType?: string;
|
|
85
|
+
/** Additional files for a prefix resource; source remains the first file for compatibility. */
|
|
86
|
+
readonly files?: readonly {
|
|
87
|
+
readonly bytes: Uint8Array;
|
|
88
|
+
readonly filename: string;
|
|
89
|
+
readonly mediaType?: string;
|
|
90
|
+
}[];
|
|
91
|
+
readonly target: ShareTarget;
|
|
92
|
+
readonly expiresAt: Date;
|
|
93
|
+
readonly expiryWasExplicit?: boolean;
|
|
94
|
+
readonly origin: string;
|
|
95
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
96
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
97
|
+
readonly notify?: boolean;
|
|
98
|
+
/** Publish as the next write-once version of this artifact and pin the share to it (TC-1428). */
|
|
99
|
+
readonly artifact?: {
|
|
100
|
+
readonly id: string;
|
|
101
|
+
readonly note?: string;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
type TargetPublishOutcome = PublishedShare | ShareAuthorizationRequired;
|
|
105
|
+
interface TargetPublishAdapter {
|
|
106
|
+
publish(input: TargetPublishInput): Promise<TargetPublishOutcome>;
|
|
107
|
+
}
|
|
108
|
+
declare function normalizeShareTarget(target: ShareTarget): ShareTarget;
|
|
109
|
+
declare function targetAuthorizationMethod(target: ShareTarget): ShareAuthorizationMethod | undefined;
|
|
110
|
+
/** Route every share through the authenticated TinyCloud authority adapter. */
|
|
111
|
+
declare function publishTargetShare(input: SharePublishOptions & {
|
|
112
|
+
readonly target: ShareTarget;
|
|
113
|
+
readonly notify?: boolean;
|
|
114
|
+
readonly targetAdapter?: TargetPublishAdapter;
|
|
115
|
+
readonly files?: readonly {
|
|
116
|
+
readonly bytes: Uint8Array;
|
|
117
|
+
readonly filename: string;
|
|
118
|
+
readonly mediaType?: string;
|
|
119
|
+
}[];
|
|
120
|
+
readonly resourceKind?: "exact" | "prefix";
|
|
121
|
+
readonly actions?: readonly ("read" | "list" | "edit")[];
|
|
122
|
+
}): Promise<TargetPublishOutcome>;
|
|
123
|
+
|
|
124
|
+
interface AddressedOwnerRootInput {
|
|
125
|
+
readonly ownerDid: string;
|
|
126
|
+
readonly role: "policy-authority" | "policy-enforcement";
|
|
127
|
+
readonly audienceDid: string;
|
|
128
|
+
readonly policyId: string;
|
|
129
|
+
readonly policyDigestHex: string;
|
|
130
|
+
readonly policyCid: string;
|
|
131
|
+
readonly contentSourceDigestHex: string;
|
|
132
|
+
readonly capabilityCeilingHashHex: string;
|
|
133
|
+
readonly nativeProjectionHashHex: string;
|
|
134
|
+
readonly notBefore: Date;
|
|
135
|
+
readonly expiresAt: Date;
|
|
136
|
+
readonly nodeAudience: string;
|
|
137
|
+
readonly capabilities: readonly UnifiedPolicyCapability[];
|
|
138
|
+
}
|
|
139
|
+
interface AddressedOwnerRootReceipt {
|
|
140
|
+
readonly cid: string;
|
|
141
|
+
readonly delegationHeader: {
|
|
142
|
+
readonly Authorization: string;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
interface AddressedPolicyRegistrationInput {
|
|
146
|
+
readonly policyCid: string;
|
|
147
|
+
readonly policy: Readonly<Record<string, unknown>>;
|
|
148
|
+
readonly policyRoot: {
|
|
149
|
+
readonly cid: string;
|
|
150
|
+
readonly authorization: string;
|
|
151
|
+
};
|
|
152
|
+
readonly enforcementRoot: {
|
|
153
|
+
readonly cid: string;
|
|
154
|
+
readonly authorization: string;
|
|
155
|
+
};
|
|
156
|
+
readonly contentSourceDigestHex: string;
|
|
157
|
+
readonly nativeProjectionHashHex: string;
|
|
158
|
+
readonly rootExpiresAt: string;
|
|
159
|
+
readonly enforcerDid: string;
|
|
160
|
+
readonly expectedNodeAudience: string;
|
|
161
|
+
}
|
|
162
|
+
interface AddressedPolicyRegistrationReceipt {
|
|
163
|
+
readonly policyCid: string;
|
|
164
|
+
readonly policyRootCid: string;
|
|
165
|
+
readonly enforcementRootCid: string;
|
|
166
|
+
readonly attestedEnforcerBinding: {
|
|
167
|
+
readonly schema: "xyz.tinycloud.policy/attested-enforcer/v2";
|
|
168
|
+
readonly enforcerDid: string;
|
|
169
|
+
readonly nodeAudience: string;
|
|
170
|
+
readonly attestationBindingDigestHex: string;
|
|
171
|
+
readonly issuedAt: string;
|
|
172
|
+
readonly expiresAt: string;
|
|
173
|
+
readonly signature: {
|
|
174
|
+
readonly suite: "Ed25519";
|
|
175
|
+
readonly signerDid: string;
|
|
176
|
+
readonly value: string;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
/** App-neutral owner authority. Node SDK owns all Policy/v3 transport. */
|
|
181
|
+
interface AddressedPublishAuthority {
|
|
182
|
+
readonly ownerDid: string;
|
|
183
|
+
createOwnerRoot(input: AddressedOwnerRootInput): Promise<AddressedOwnerRootReceipt>;
|
|
184
|
+
sign(bytes: Uint8Array): Promise<Uint8Array>;
|
|
185
|
+
registerPolicy(input: AddressedPolicyRegistrationInput): Promise<AddressedPolicyRegistrationReceipt>;
|
|
186
|
+
}
|
|
187
|
+
interface AddressedSharePublishOptions {
|
|
188
|
+
readonly shareId: string;
|
|
189
|
+
readonly shareOrigin: string;
|
|
190
|
+
readonly nodeOrigin: string;
|
|
191
|
+
readonly nodeAudience: string;
|
|
192
|
+
readonly enforcerDid: string;
|
|
193
|
+
readonly spaceId: string;
|
|
194
|
+
readonly target: Exclude<ShareTarget, {
|
|
195
|
+
readonly kind: "bearer";
|
|
196
|
+
}>;
|
|
197
|
+
readonly resource: {
|
|
198
|
+
readonly kind: "exact" | "prefix";
|
|
199
|
+
readonly path: string;
|
|
200
|
+
};
|
|
201
|
+
readonly actions: readonly ShareAction[];
|
|
202
|
+
readonly policyActions: readonly OwnerShareAction[];
|
|
203
|
+
readonly contentSource: UnifiedContentSource;
|
|
204
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
205
|
+
readonly filename: string;
|
|
206
|
+
readonly mediaType: string;
|
|
207
|
+
readonly byteLength: number;
|
|
208
|
+
readonly artifact?: "html";
|
|
209
|
+
readonly deliveryEmail?: string;
|
|
210
|
+
readonly expiresAt: Date;
|
|
211
|
+
/** Sender-history material required by Node's Policy/v3 delivery authorization. */
|
|
212
|
+
readonly onDeliveryMaterial?: (input: PublishedShareDeliveryMaterial) => void;
|
|
213
|
+
readonly authority: AddressedPublishAuthority;
|
|
214
|
+
}
|
|
215
|
+
type MailboxTarget = Extract<ShareTarget, {
|
|
216
|
+
readonly kind: "email" | "emailDomain";
|
|
217
|
+
}>;
|
|
218
|
+
/** The Policy/v2 credential commitment a share addressed to `target` must carry. */
|
|
219
|
+
declare function addressedCredentialRequirement(target: MailboxTarget): PolicyCredentialRequirementV1;
|
|
220
|
+
/** Facts every addressed-share check needs, available before any side effect. */
|
|
221
|
+
type AddressedShareRequest = Pick<AddressedSharePublishOptions, "target" | "actions" | "policyActions" | "filename" | "deliveryEmail">;
|
|
222
|
+
interface PreparedAddressedShare {
|
|
223
|
+
/** The canonical target the envelope's recipient matcher will carry. */
|
|
224
|
+
readonly target: Exclude<ShareTarget, {
|
|
225
|
+
readonly kind: "bearer";
|
|
226
|
+
}>;
|
|
227
|
+
/** Present for mailbox targets: the Policy/v2 commitment to pass to `publishAddressedShare`. */
|
|
228
|
+
readonly credentialRequirement?: PolicyCredentialRequirementV1;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Runs every argument and target check of `publishAddressedShare` that does
|
|
232
|
+
* not depend on stored content, and derives the credential commitment. It has
|
|
233
|
+
* no side effects, so senders call it before uploading content or publishing
|
|
234
|
+
* a location record; a refused share then leaves nothing behind.
|
|
235
|
+
*/
|
|
236
|
+
declare function prepareAddressedShare(request: AddressedShareRequest): PreparedAddressedShare;
|
|
237
|
+
/** Canonical application-neutral Policy/v3 addressed publisher shared by browser and CLI. */
|
|
238
|
+
declare function publishAddressedShare(input: AddressedSharePublishOptions): Promise<PublishedShare>;
|
|
239
|
+
|
|
240
|
+
export { type AddressedOwnerRootInput as A, type PreparedAddressedShare as P, type ShareAuthorizationMethod as S, type TargetPublishOutcome as T, type ShareAuthorizedContent as a, type ShareAuthorizationAdapter as b, type TargetPublishInput as c, type ShareAuthorizationResult as d, type ShareTarget as e, type AddressedOwnerRootReceipt as f, type AddressedPolicyRegistrationInput as g, type AddressedPolicyRegistrationReceipt as h, type AddressedPublishAuthority as i, type AddressedSharePublishOptions as j, type AddressedShareRequest as k, type ShareAuthorizationDenied as l, type ShareAuthorizationReady as m, type ShareAuthorizationRequired as n, type TargetPublishAdapter as o, addressedCredentialRequirement as p, authorizationMethodForTarget as q, authorizeShare as r, normalizeShareTarget as s, prepareAddressedShare as t, publishAddressedShare as u, publishTargetShare as v, targetAuthorizationMethod as w };
|
|
@@ -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.cjs';
|
|
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 };
|