@sparkvault/sdk-js 14.2.3 → 15.0.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/index.cjs +24 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +98 -22
- package/dist/index.mjs +24 -10
- package/dist/index.mjs.map +1 -1
- package/dist/sparks/index.d.ts +20 -9
- package/dist/sparks/types.d.ts +82 -15
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/sparks/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sparks Module
|
|
3
3
|
*
|
|
4
|
-
* Create, read, share, and delete
|
|
5
|
-
*
|
|
4
|
+
* Create, read, share, and delete ephemeral secrets, sealed server-side under
|
|
5
|
+
* platform-held keys and read once. Sparks are account-scoped — no vault or
|
|
6
|
+
* VAT is involved.
|
|
6
7
|
*/
|
|
7
8
|
import { HttpClient } from '../http';
|
|
8
|
-
import type { Spark, CreatedSpark, ListSparksOptions, SparkPage, CreateSparkOptions, ShareSparkOptions, SparkShare, SparkInviteResend } from './types';
|
|
9
|
+
import type { Spark, CreatedSpark, ListSparksOptions, SparkPage, CreateSparkOptions, ShareSparkOptions, SparkLinkActionOptions, SparkShare, SparkInviteResend } from './types';
|
|
9
10
|
export declare class SparksModule {
|
|
10
11
|
private readonly http;
|
|
11
12
|
constructor(http: HttpClient);
|
|
@@ -42,7 +43,12 @@ export declare class SparksModule {
|
|
|
42
43
|
*/
|
|
43
44
|
delete(sparkId: string): Promise<void>;
|
|
44
45
|
/**
|
|
45
|
-
* Share a spark via a
|
|
46
|
+
* Share a spark via a SparkLink (x.sv URL). A spark already shared keeps
|
|
47
|
+
* its link: the settings are applied to it in place (`alreadyShared`), an
|
|
48
|
+
* omitted visibility keeps the current one, and `expiresInSeconds` applies
|
|
49
|
+
* to the first share only. `linkCode` names the link the change was asked
|
|
50
|
+
* of: a change asked of a link replaced or turned off since is refused
|
|
51
|
+
* (409 CONFLICT).
|
|
46
52
|
*
|
|
47
53
|
* @example
|
|
48
54
|
* const share = await sv.sparks.share('spk_abc', { visibility: 'public' });
|
|
@@ -54,12 +60,13 @@ export declare class SparksModule {
|
|
|
54
60
|
* nothing about the link: the way on from an invitation that could not be
|
|
55
61
|
* delivered (a share rejected with INVITATION_DELIVERY_FAILED leaves its
|
|
56
62
|
* link in place, and the same share again delivers nothing), or one the
|
|
57
|
-
* invitee never received.
|
|
63
|
+
* invitee never received. `linkCode` names the link the resend was asked
|
|
64
|
+
* of: a link replaced since is never delivered in its place (409 CONFLICT).
|
|
58
65
|
*
|
|
59
66
|
* @example
|
|
60
67
|
* const { identity } = await sv.sparks.resendInvite('spk_abc');
|
|
61
68
|
*/
|
|
62
|
-
resendInvite(sparkId: string): Promise<SparkInviteResend>;
|
|
69
|
+
resendInvite(sparkId: string, options?: SparkLinkActionOptions): Promise<SparkInviteResend>;
|
|
63
70
|
/**
|
|
64
71
|
* Get a spark's sharing status.
|
|
65
72
|
*
|
|
@@ -68,11 +75,15 @@ export declare class SparksModule {
|
|
|
68
75
|
*/
|
|
69
76
|
getShare(sparkId: string): Promise<SparkShare>;
|
|
70
77
|
/**
|
|
71
|
-
* Unshare a spark (delete its SparkLink).
|
|
78
|
+
* Unshare a spark (delete its SparkLink). Idempotent: a spark with no link
|
|
79
|
+
* answers `shared: false`, the link `linkCode` names included, so a retried
|
|
80
|
+
* unshare is never refused. A `linkCode` naming a link another share
|
|
81
|
+
* replaced since is refused (409 CONFLICT), so the link that took its place
|
|
82
|
+
* is never deleted.
|
|
72
83
|
*
|
|
73
84
|
* @example
|
|
74
85
|
* await sv.sparks.unshare('spk_abc');
|
|
75
86
|
*/
|
|
76
|
-
unshare(sparkId: string): Promise<SparkShare>;
|
|
87
|
+
unshare(sparkId: string, options?: SparkLinkActionOptions): Promise<SparkShare>;
|
|
77
88
|
}
|
|
78
|
-
export type { SparkSummary, Spark, CreatedSpark, ListSparksOptions, SparkPage, CreateSparkOptions, ShareSparkOptions, SparkShare, SparkInviteResend, SparkVisibility, } from './types';
|
|
89
|
+
export type { SparkSummary, Spark, CreatedSpark, ListSparksOptions, SparkPage, CreateSparkOptions, ShareSparkOptions, SparkLinkActionOptions, SparkShare, SparkInviteResend, SparkVisibility, } from './types';
|
package/dist/sparks/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Sparks Module Types
|
|
3
3
|
*
|
|
4
|
-
* Sparks are
|
|
5
|
-
*
|
|
6
|
-
* (snake_case) stay private to the module.
|
|
4
|
+
* Sparks are ephemeral secrets scoped to the account (no vault/VAT), sealed
|
|
5
|
+
* server-side under platform-held keys and read once. Public domain objects
|
|
6
|
+
* are camelCase; wire shapes (snake_case) stay private to the module.
|
|
7
7
|
*/
|
|
8
8
|
/** A spark summary as returned by list. */
|
|
9
9
|
export interface SparkSummary {
|
|
@@ -14,15 +14,21 @@ export interface SparkSummary {
|
|
|
14
14
|
/** Size in bytes */
|
|
15
15
|
size: number;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Its state when the list answers: active while its content is live (a
|
|
18
|
+
* spark a recipient is reading included), ash once a recipient read or
|
|
19
|
+
* answered it or its content was recalled (past its expiry too), expired
|
|
20
|
+
* past its expiry and never burned, deleted once its owner deleted it
|
|
21
|
+
* (never reported ash)
|
|
19
22
|
*/
|
|
20
|
-
status:
|
|
23
|
+
status: 'active' | 'ash' | 'expired' | 'deleted';
|
|
21
24
|
/** Creation timestamp (Unix seconds) */
|
|
22
25
|
createdAt: number;
|
|
23
26
|
/** Expiry timestamp (Unix seconds) */
|
|
24
27
|
expiresAt: number;
|
|
25
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* When it turned ash (Unix seconds); null for every other status, deleted
|
|
30
|
+
* included, though a delete burns the content too
|
|
31
|
+
*/
|
|
26
32
|
burnedAt: number | null;
|
|
27
33
|
/** Seconds remaining until expiry */
|
|
28
34
|
timeRemaining: number;
|
|
@@ -30,7 +36,11 @@ export interface SparkSummary {
|
|
|
30
36
|
filename?: string;
|
|
31
37
|
/** Optional kindling family ID */
|
|
32
38
|
kindling?: string;
|
|
33
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Its x.sv link, while it has one: a link spark (contentType text/uri-list)
|
|
41
|
+
* from its create, any other spark from its share until it is unshared. A
|
|
42
|
+
* deleted spark keeps the link it had, which opens nothing.
|
|
43
|
+
*/
|
|
34
44
|
linkUrl?: string;
|
|
35
45
|
}
|
|
36
46
|
/** The decrypted spark, returned by get (reading burns it). */
|
|
@@ -101,8 +111,14 @@ export interface CreatedSpark {
|
|
|
101
111
|
export interface ListSparksOptions {
|
|
102
112
|
/** Filter to a kindling family */
|
|
103
113
|
kindling?: string;
|
|
104
|
-
/**
|
|
105
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Filter by status, matching each listed spark's `status`: `active` lists
|
|
116
|
+
* the sparks whose content is live (not burned, not past its expiry; a spark
|
|
117
|
+
* mid-read included), `ash` those a recipient read, recalled or answered (a
|
|
118
|
+
* spark its owner deleted is `deleted`, in neither). The API refuses any
|
|
119
|
+
* other value.
|
|
120
|
+
*/
|
|
121
|
+
status?: 'active' | 'ash';
|
|
106
122
|
/** Page size */
|
|
107
123
|
limit?: number;
|
|
108
124
|
/** Pagination cursor */
|
|
@@ -135,14 +151,51 @@ export interface CreateSparkOptions {
|
|
|
135
151
|
}
|
|
136
152
|
/** Visibility mode for a shared spark. */
|
|
137
153
|
export type SparkVisibility = 'public' | 'authenticated' | 'invite_only';
|
|
138
|
-
/**
|
|
154
|
+
/**
|
|
155
|
+
* Options for share. A spark already shared keeps its link: the settings are
|
|
156
|
+
* applied to it in place, and its code never changes.
|
|
157
|
+
*/
|
|
139
158
|
export interface ShareSparkOptions {
|
|
140
|
-
/**
|
|
159
|
+
/**
|
|
160
|
+
* Visibility mode: public on a spark's first share; an omitted visibility
|
|
161
|
+
* keeps the link's current one.
|
|
162
|
+
*/
|
|
141
163
|
visibility?: SparkVisibility;
|
|
142
|
-
/**
|
|
164
|
+
/**
|
|
165
|
+
* The identity (an email address or a phone number) invited to an
|
|
166
|
+
* invite_only link: exactly one, which the link is delivered to. Refused
|
|
167
|
+
* with any other visibility. An omitted list keeps the link's current
|
|
168
|
+
* invitee.
|
|
169
|
+
*/
|
|
143
170
|
invites?: string[];
|
|
144
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* Link lifetime in seconds, from 60, capped at the spark's own expiry.
|
|
173
|
+
* Applies to a spark's first share only: a change to an existing link keeps
|
|
174
|
+
* its lifetime.
|
|
175
|
+
*/
|
|
145
176
|
expiresInSeconds?: number;
|
|
177
|
+
/**
|
|
178
|
+
* The link this change was asked of (its `linkCode`, as a share answered
|
|
179
|
+
* it). When it is no longer the spark's link (turned off, or replaced by
|
|
180
|
+
* another share), the change is refused with a 409 CONFLICT and changes
|
|
181
|
+
* nothing. Omitted, the change applies to the spark's link now.
|
|
182
|
+
*/
|
|
183
|
+
linkCode?: string;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Options for resendInvite and unshare, which act on a spark's existing link.
|
|
187
|
+
*/
|
|
188
|
+
export interface SparkLinkActionOptions {
|
|
189
|
+
/**
|
|
190
|
+
* The link this request was asked of (its `linkCode`, as a share answered
|
|
191
|
+
* it). A resend asked of a link that is no longer the spark's link (turned
|
|
192
|
+
* off, or replaced by another share) is refused with a 409 CONFLICT,
|
|
193
|
+
* delivering nothing. An unshare is refused only when another share
|
|
194
|
+
* replaced the link, deleting nothing; a link already turned off answers
|
|
195
|
+
* `shared: false`, so a retried unshare is never refused. Omitted, the
|
|
196
|
+
* request acts on the spark's link now.
|
|
197
|
+
*/
|
|
198
|
+
linkCode?: string;
|
|
146
199
|
}
|
|
147
200
|
/** The result of sharing a spark. */
|
|
148
201
|
export interface SparkShare {
|
|
@@ -156,6 +209,13 @@ export interface SparkShare {
|
|
|
156
209
|
visibility?: SparkVisibility;
|
|
157
210
|
/** Invited identities */
|
|
158
211
|
invites?: string[];
|
|
212
|
+
/**
|
|
213
|
+
* The link's status: active; consumed once it was opened (it opens once);
|
|
214
|
+
* or expired once a link never opened opens nothing: from its `expiresAt`
|
|
215
|
+
* on, or once its spark is burned (read by its id) or reaches its own
|
|
216
|
+
* expiry. A change or a resend is then refused (403 FORBIDDEN).
|
|
217
|
+
*/
|
|
218
|
+
status?: 'active' | 'consumed' | 'expired';
|
|
159
219
|
/** Link expiry timestamp (Unix seconds) */
|
|
160
220
|
expiresAt?: number;
|
|
161
221
|
/** Link creation timestamp (Unix seconds) */
|
|
@@ -166,6 +226,11 @@ export interface SparkShare {
|
|
|
166
226
|
* again by resendInvite.
|
|
167
227
|
*/
|
|
168
228
|
deliveredTo?: string[];
|
|
229
|
+
/**
|
|
230
|
+
* True when the spark was already shared, so the share applied its
|
|
231
|
+
* settings to the existing link in place (share only)
|
|
232
|
+
*/
|
|
233
|
+
alreadyShared?: boolean;
|
|
169
234
|
}
|
|
170
235
|
/** An invitation delivered again, as resendInvite answers it. */
|
|
171
236
|
export interface SparkInviteResend {
|
|
@@ -182,7 +247,7 @@ export interface SparkSummaryWire {
|
|
|
182
247
|
spark_id: string;
|
|
183
248
|
content_type?: string;
|
|
184
249
|
size_bytes: number;
|
|
185
|
-
status:
|
|
250
|
+
status: SparkSummary['status'];
|
|
186
251
|
created_at: number;
|
|
187
252
|
expires_at: number;
|
|
188
253
|
burned_at?: number | null;
|
|
@@ -224,9 +289,11 @@ export interface SparkShareResponse {
|
|
|
224
289
|
link_code?: string;
|
|
225
290
|
visibility?: SparkVisibility;
|
|
226
291
|
invites?: string[];
|
|
292
|
+
status?: 'active' | 'consumed' | 'expired';
|
|
227
293
|
expires_at?: number;
|
|
228
294
|
created_at?: number;
|
|
229
295
|
delivered_to?: string[];
|
|
296
|
+
already_shared?: boolean;
|
|
230
297
|
}
|
|
231
298
|
export interface SparkInviteResendResponse {
|
|
232
299
|
resent: boolean;
|