@tinycloud/share-sdk 1.2.1 → 1.3.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.
- package/README.md +5 -0
- package/dist/{addressed-publish-BnSBJ-MX.d.ts → addressed-publish-CAdGCqiX.d.ts} +4 -79
- package/dist/{addressed-publish-DtcLNG2m.d.cts → addressed-publish-Db-6rqkA.d.cts} +4 -79
- package/dist/authorization-CmP1skO8.d.cts +79 -0
- package/dist/authorization-CmP1skO8.d.ts +79 -0
- package/dist/{history-CUWDK0lE.d.cts → history-ZJFHV-IU.d.cts} +1 -1
- package/dist/{history-CyT6x8h4.d.ts → history-q0ALXTv7.d.ts} +1 -1
- package/dist/index.d.cts +10 -209
- package/dist/index.d.ts +10 -209
- package/dist/{owner-policy-BqzRlkb6.d.cts → owner-policy-CRFeEC98.d.cts} +1 -1
- package/dist/{owner-policy-BqzRlkb6.d.ts → owner-policy-CRFeEC98.d.ts} +1 -1
- package/dist/share-index.d.cts +3 -3
- package/dist/share-index.d.ts +3 -3
- package/dist/share-root.d.cts +3 -2
- package/dist/share-root.d.ts +3 -2
- package/dist/web-recipient-entry-CKA_vCi5.d.ts +206 -0
- package/dist/web-recipient-entry-D9IJEyRA.d.cts +206 -0
- package/dist/web-recipient.cjs +6307 -0
- package/dist/web-recipient.cjs.map +1 -0
- package/dist/web-recipient.d.cts +3 -0
- package/dist/web-recipient.d.ts +3 -0
- package/dist/web-recipient.js +6285 -0
- package/dist/web-recipient.js.map +1 -0
- package/package.json +7 -1
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { ShareEnvelopeV3, ShareEnvelopeV2 } from '@tinycloud/share-envelope';
|
|
2
|
+
import { a as ShareAuthorizationMethod, f as ShareAuthorizedContent, c as ShareAuthorizationAdapter } from './authorization-CmP1skO8.cjs';
|
|
3
|
+
|
|
4
|
+
type ShareErrorCode = "invalid-link" | "fetch-failed" | "max-bytes-exceeded" | "cid-mismatch" | "decrypt-failed" | "envelope-invalid" | "origin-mismatch" | "signature-invalid" | "capability-invalid" | "expired" | "unsupported-target" | "authorization-denied" | "content-integrity-failed";
|
|
5
|
+
declare const SHARE_RESULT_VERSION: 1;
|
|
6
|
+
declare const DEFAULT_MAX_SEALED_BLOB_BYTES: number;
|
|
7
|
+
declare const DEFAULT_MAX_CONTENT_BLOB_BYTES: number;
|
|
8
|
+
declare class ShareReceiveError extends Error {
|
|
9
|
+
readonly code: ShareErrorCode;
|
|
10
|
+
readonly details: {
|
|
11
|
+
readonly expiresAt?: string;
|
|
12
|
+
readonly stage?: "envelope" | "content";
|
|
13
|
+
readonly reason?: "policy-target" | "recipient-did-target" | "prefix-resource";
|
|
14
|
+
} | undefined;
|
|
15
|
+
constructor(code: ShareErrorCode, message: string, details?: {
|
|
16
|
+
readonly expiresAt?: string;
|
|
17
|
+
readonly stage?: "envelope" | "content";
|
|
18
|
+
readonly reason?: "policy-target" | "recipient-did-target" | "prefix-resource";
|
|
19
|
+
});
|
|
20
|
+
toJSON(): ShareErrorInfo;
|
|
21
|
+
}
|
|
22
|
+
interface ShareErrorInfo {
|
|
23
|
+
readonly protocol: "tinycloud-share";
|
|
24
|
+
readonly version: typeof SHARE_RESULT_VERSION;
|
|
25
|
+
readonly error: {
|
|
26
|
+
readonly code: ShareErrorCode;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
declare function toShareErrorInfo(error: unknown): ShareErrorInfo;
|
|
30
|
+
/** Policy/v3 links seal their authorization metadata in a fragment; no blob fetch adapter exists. */
|
|
31
|
+
interface ShareFetchOptions {
|
|
32
|
+
readonly expectedOrigin?: string;
|
|
33
|
+
readonly signal?: AbortSignal;
|
|
34
|
+
readonly now?: () => number;
|
|
35
|
+
readonly maxSealedBlobBytes?: number;
|
|
36
|
+
readonly maxContentBlobBytes?: number;
|
|
37
|
+
readonly onResolvedAddressedEnvelope?: (envelope: ShareEnvelopeV3, cid: string) => void;
|
|
38
|
+
}
|
|
39
|
+
interface ShareMetadata {
|
|
40
|
+
readonly protocol: "tinycloud-share";
|
|
41
|
+
readonly version: 1;
|
|
42
|
+
readonly shareId: string;
|
|
43
|
+
readonly origin: string;
|
|
44
|
+
readonly target: {
|
|
45
|
+
readonly kind: "bearer" | "recipientDid" | "email" | "emailDomain";
|
|
46
|
+
readonly origin: string;
|
|
47
|
+
readonly nodeAudience: string;
|
|
48
|
+
readonly spaceId: string;
|
|
49
|
+
};
|
|
50
|
+
readonly resource: {
|
|
51
|
+
readonly kind: "exact" | "prefix";
|
|
52
|
+
readonly path: string;
|
|
53
|
+
};
|
|
54
|
+
readonly actions: readonly string[];
|
|
55
|
+
readonly expiresAt: string;
|
|
56
|
+
readonly display: {
|
|
57
|
+
readonly senderName?: string;
|
|
58
|
+
readonly filename?: string;
|
|
59
|
+
readonly mode?: string;
|
|
60
|
+
};
|
|
61
|
+
/** Set when the share is pinned to one artifact version; the owner's signature covers it (TC-1428). */
|
|
62
|
+
readonly artifact?: {
|
|
63
|
+
readonly id: string;
|
|
64
|
+
readonly version: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
interface ShareInspection {
|
|
68
|
+
readonly metadata: ShareMetadata;
|
|
69
|
+
readonly link: {
|
|
70
|
+
readonly origin: string;
|
|
71
|
+
readonly cid: string;
|
|
72
|
+
readonly kind: "policy";
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
interface ShareReceiveAuthorizationRequired {
|
|
76
|
+
readonly state: "authorization-required";
|
|
77
|
+
readonly method: ShareAuthorizationMethod;
|
|
78
|
+
readonly continueUrl?: string;
|
|
79
|
+
readonly resumeToken?: string;
|
|
80
|
+
}
|
|
81
|
+
/** Retained as the result consumed after the node authorization ceremony. */
|
|
82
|
+
interface ShareReceiveResult extends ShareInspection {
|
|
83
|
+
readonly bytes: Uint8Array;
|
|
84
|
+
readonly text?: string;
|
|
85
|
+
}
|
|
86
|
+
type ShareReceiveOutcome = ShareReceiveResult | ShareReceiveAuthorizationRequired;
|
|
87
|
+
declare function inspectShare(link: string, options?: ShareFetchOptions): Promise<ShareInspection>;
|
|
88
|
+
/**
|
|
89
|
+
* Resolve and verify invitation metadata only. Actual content access is an
|
|
90
|
+
* invocation against the owner node and is performed by the receiver SDK.
|
|
91
|
+
*/
|
|
92
|
+
declare function receiveShare(link: string, options?: ShareFetchOptions): Promise<ShareReceiveOutcome>;
|
|
93
|
+
|
|
94
|
+
interface ShareNodeTrust {
|
|
95
|
+
readonly invitationKid: string;
|
|
96
|
+
readonly invitationPublicKey: Uint8Array;
|
|
97
|
+
}
|
|
98
|
+
interface SharePresentationMaterial {
|
|
99
|
+
readonly holderDid: string;
|
|
100
|
+
readonly credential: string;
|
|
101
|
+
readonly credentialDigest?: string;
|
|
102
|
+
readonly holderBinding: Record<string, unknown>;
|
|
103
|
+
readonly proof: Record<string, unknown>;
|
|
104
|
+
readonly sign?: (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
105
|
+
readonly email?: string;
|
|
106
|
+
/** Exact v3 credential claim returned by the verified holder ceremony. */
|
|
107
|
+
readonly claim?: Record<string, unknown>;
|
|
108
|
+
/** Exact v3 presentation returned by the verified holder ceremony. */
|
|
109
|
+
readonly presentation?: Record<string, unknown>;
|
|
110
|
+
/** Exact verified issuer envelope used by accountless v4 admission. */
|
|
111
|
+
readonly credentialEnvelope?: Record<string, unknown>;
|
|
112
|
+
/** Exact credential requirement committed by the signed policy. */
|
|
113
|
+
readonly requirement?: Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
interface SharePolicyChallenge {
|
|
116
|
+
readonly challengeId: string;
|
|
117
|
+
readonly nonce: string;
|
|
118
|
+
readonly expiresAt: string;
|
|
119
|
+
readonly enforcerDid?: string;
|
|
120
|
+
readonly action: string;
|
|
121
|
+
readonly requestBodyDigest: string;
|
|
122
|
+
readonly [key: string]: unknown;
|
|
123
|
+
}
|
|
124
|
+
interface ShareRecipientClientOptions {
|
|
125
|
+
readonly nodeOrigin: string;
|
|
126
|
+
/** Required only by the retired v2 response-proof adapter. Policy/v3 trusts its signed attested binding. */
|
|
127
|
+
readonly trustedNode?: ShareNodeTrust;
|
|
128
|
+
readonly holderDid: string;
|
|
129
|
+
readonly envelope: ShareEnvelopeV2 | ShareEnvelopeV3;
|
|
130
|
+
readonly fetchFn?: typeof fetch;
|
|
131
|
+
readonly buildPresentation?: (input: {
|
|
132
|
+
readonly challenge: SharePolicyChallenge;
|
|
133
|
+
readonly envelope: ShareEnvelopeV2 | ShareEnvelopeV3;
|
|
134
|
+
readonly policy: Record<string, unknown>;
|
|
135
|
+
}) => Promise<SharePresentationMaterial>;
|
|
136
|
+
readonly sign?: (bytes: Uint8Array) => Promise<Uint8Array>;
|
|
137
|
+
readonly signal?: AbortSignal;
|
|
138
|
+
readonly onStage?: (stage: "policy-admission" | "delegation-import" | "invocation" | "decryption") => void;
|
|
139
|
+
/**
|
|
140
|
+
* A previously admitted and imported policy session (S0), optionally with
|
|
141
|
+
* the descendants that re-delegate it, in order, down to this holder.
|
|
142
|
+
*/
|
|
143
|
+
readonly policyAuthorization?: {
|
|
144
|
+
readonly authorization: string;
|
|
145
|
+
readonly cid: string;
|
|
146
|
+
readonly descendants?: readonly SharePolicyDelegationLink[];
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/** One signed link of a policy delegation chain, as imported into the Node. */
|
|
150
|
+
interface SharePolicyDelegationLink {
|
|
151
|
+
readonly authorization: string;
|
|
152
|
+
readonly cid: string;
|
|
153
|
+
}
|
|
154
|
+
interface SharePolicySession {
|
|
155
|
+
readonly sessionId: string;
|
|
156
|
+
readonly expiresAt: string;
|
|
157
|
+
readonly actions: readonly ("read" | "list" | "edit")[];
|
|
158
|
+
readonly resource: {
|
|
159
|
+
readonly kind: "exact" | "prefix";
|
|
160
|
+
readonly path: string;
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
declare class ShareRecipientClient {
|
|
164
|
+
private readonly options;
|
|
165
|
+
private readonly fetchFn;
|
|
166
|
+
private session;
|
|
167
|
+
private signer;
|
|
168
|
+
private nativeSigner;
|
|
169
|
+
private holderProof;
|
|
170
|
+
private v3Authorization;
|
|
171
|
+
private v3NodeAudience;
|
|
172
|
+
private v3ContentKey;
|
|
173
|
+
private v3ContentEnvelope;
|
|
174
|
+
constructor(options: ShareRecipientClientOptions);
|
|
175
|
+
beginChallenge(envelope: ShareEnvelopeV2): Promise<SharePolicyChallenge>;
|
|
176
|
+
private establish;
|
|
177
|
+
authorize(envelope: ShareEnvelopeV2): Promise<ShareAuthorizedContent>;
|
|
178
|
+
establishPolicySession(): Promise<SharePolicySession>;
|
|
179
|
+
private establishV3;
|
|
180
|
+
/** Decrypt a v3 KV value through a fresh recipient-signed decrypt invocation. */
|
|
181
|
+
decryptV3Content(bytes: Uint8Array): Promise<{
|
|
182
|
+
readonly bytes: Uint8Array;
|
|
183
|
+
readonly mediaType: string;
|
|
184
|
+
}>;
|
|
185
|
+
/** Re-encrypt edited v3 content with the admitted content key. */
|
|
186
|
+
encryptV3Content(bytes: Uint8Array, mediaType: string): Promise<Uint8Array>;
|
|
187
|
+
resumeWithProof(envelope: ShareEnvelopeV2, resumeToken: string, proof: unknown): Promise<ShareAuthorizedContent>;
|
|
188
|
+
nativeInvoke(request: {
|
|
189
|
+
readonly action: string;
|
|
190
|
+
readonly resource?: Record<string, unknown>;
|
|
191
|
+
readonly body?: number[];
|
|
192
|
+
readonly bodyDigest?: number[];
|
|
193
|
+
readonly ifMatch?: string;
|
|
194
|
+
readonly contentType?: string;
|
|
195
|
+
}): Promise<Response>;
|
|
196
|
+
private nativeInvokeV3;
|
|
197
|
+
}
|
|
198
|
+
declare function createAddressedAuthorization(input: Omit<ShareRecipientClientOptions, "envelope" | "buildPresentation"> & {
|
|
199
|
+
readonly buildPresentation?: (input: {
|
|
200
|
+
readonly challenge: SharePolicyChallenge;
|
|
201
|
+
readonly envelope: ShareEnvelopeV2;
|
|
202
|
+
readonly policy: Record<string, unknown>;
|
|
203
|
+
}) => Promise<SharePresentationMaterial>;
|
|
204
|
+
}): ShareAuthorizationAdapter<ShareAuthorizedContent>;
|
|
205
|
+
|
|
206
|
+
export { DEFAULT_MAX_CONTENT_BLOB_BYTES as D, SHARE_RESULT_VERSION as S, DEFAULT_MAX_SEALED_BLOB_BYTES as a, type ShareErrorCode as b, type ShareErrorInfo as c, type ShareFetchOptions as d, type ShareInspection as e, type ShareMetadata as f, type ShareNodeTrust as g, type SharePolicyChallenge as h, type SharePolicyDelegationLink as i, type SharePolicySession as j, type SharePresentationMaterial as k, type ShareReceiveAuthorizationRequired as l, ShareReceiveError as m, type ShareReceiveOutcome as n, type ShareReceiveResult as o, ShareRecipientClient as p, type ShareRecipientClientOptions as q, createAddressedAuthorization as r, inspectShare as s, receiveShare as t, toShareErrorInfo as u };
|