@sparkvault/sdk-mobile 10.2.2 → 10.4.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/app-sdk/vault-reseal.d.ts +42 -0
- package/dist/app-sdk/vault-reseal.js +51 -0
- package/dist/app-sdk/vault-reseal.js.map +1 -0
- package/dist/client.d.ts +2 -1
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -1
- package/dist/http.d.ts +15 -0
- package/dist/http.js +27 -0
- package/dist/http.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/ingots.d.ts +4 -0
- package/dist/ingots.js +3 -2
- package/dist/ingots.js.map +1 -1
- package/dist/sparks.d.ts +70 -14
- package/dist/sparks.js +18 -8
- package/dist/sparks.js.map +1 -1
- package/dist/sparks.test-d.d.ts +17 -3
- package/dist/sparks.test-d.js +6 -2
- package/dist/sparks.test-d.js.map +1 -1
- package/dist/types.d.ts +53 -6
- package/dist/vaults.d.ts +5 -1
- package/dist/vaults.js +12 -0
- package/dist/vaults.js.map +1 -1
- package/package.json +1 -1
- package/src/app-sdk/vault-reseal.js +51 -0
- package/src/client.ts +5 -1
- package/src/http.ts +38 -0
- package/src/index.ts +3 -0
- package/src/ingots.ts +7 -2
- package/src/sparks.test-d.ts +32 -2
- package/src/sparks.ts +76 -15
- package/src/types.ts +52 -6
- package/src/vaults.ts +17 -0
package/src/sparks.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type {
|
|
|
3
3
|
ResendSparkInviteResponse,
|
|
4
4
|
ShareSparkResponse,
|
|
5
5
|
SparkShareStatus,
|
|
6
|
+
SparkShareVisibility,
|
|
6
7
|
UnshareSparkResponse,
|
|
7
8
|
} from './types.js';
|
|
8
9
|
import { apiPath } from './request-path.js';
|
|
@@ -14,17 +15,30 @@ export interface Spark {
|
|
|
14
15
|
account_id: string;
|
|
15
16
|
content_type: string;
|
|
16
17
|
size_bytes: number;
|
|
17
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Its state when the list answers: `active` while its content is live (a
|
|
20
|
+
* Spark a recipient is reading included), `ash` once a recipient read or
|
|
21
|
+
* answered it or its content was recalled (past `expires_at` too),
|
|
22
|
+
* `expired` past `expires_at` and never burned, `deleted` once its owner
|
|
23
|
+
* deleted it (never reported `ash`).
|
|
24
|
+
*/
|
|
18
25
|
status: 'active' | 'ash' | 'expired' | 'deleted';
|
|
19
26
|
created_at: number;
|
|
20
27
|
expires_at: number;
|
|
21
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* When it turned `ash`; null for every other `status`, `deleted` included,
|
|
30
|
+
* though a delete burns the content too.
|
|
31
|
+
*/
|
|
22
32
|
burned_at: number | null;
|
|
23
33
|
/** Seconds left before it expires, 0 once it has. */
|
|
24
34
|
time_remaining: number;
|
|
25
35
|
filename?: string;
|
|
26
36
|
kindling?: string;
|
|
27
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* Its x.sv link, while it has one: a link spark (content_type
|
|
39
|
+
* text/uri-list) from its create, any other spark from its share until it
|
|
40
|
+
* is unshared. A deleted Spark keeps the link it had, which opens nothing.
|
|
41
|
+
*/
|
|
28
42
|
link_url?: string;
|
|
29
43
|
}
|
|
30
44
|
|
|
@@ -91,13 +105,49 @@ export interface CreateSparkResponse {
|
|
|
91
105
|
link_code?: string;
|
|
92
106
|
}
|
|
93
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Options for share. A spark already shared keeps its link: the settings are
|
|
110
|
+
* applied to it in place, and its code never changes.
|
|
111
|
+
*/
|
|
94
112
|
export interface ShareSparkOptions {
|
|
95
|
-
/**
|
|
96
|
-
|
|
97
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Link visibility: public on a spark's first share; an omitted visibility
|
|
115
|
+
* keeps the link's current one.
|
|
116
|
+
*/
|
|
117
|
+
visibility?: SparkShareVisibility;
|
|
118
|
+
/**
|
|
119
|
+
* For invite_only visibility: the one identity (an email address or a phone
|
|
120
|
+
* number) the link is delivered to. Refused with any other visibility; an
|
|
121
|
+
* omitted list keeps the link's current invitee.
|
|
122
|
+
*/
|
|
98
123
|
invites?: string[];
|
|
99
|
-
/**
|
|
124
|
+
/**
|
|
125
|
+
* Link expiration TTL in seconds (server minimum 60, capped at the spark's
|
|
126
|
+
* own expiry). Applies to a spark's first share only: a change to an
|
|
127
|
+
* existing link keeps its lifetime.
|
|
128
|
+
*/
|
|
100
129
|
expiresInSeconds?: number;
|
|
130
|
+
/**
|
|
131
|
+
* The link this change was asked of (its `link_code`, as a share answered
|
|
132
|
+
* it). When it is no longer the spark's link (turned off, or replaced by
|
|
133
|
+
* another share), the change is refused with a 409 CONFLICT and changes
|
|
134
|
+
* nothing. Omitted, the change applies to the spark's link now.
|
|
135
|
+
*/
|
|
136
|
+
linkCode?: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** Options for resendInvite and unshare, which act on a spark's existing link. */
|
|
140
|
+
export interface SparkLinkActionOptions {
|
|
141
|
+
/**
|
|
142
|
+
* The link this request was asked of (its `link_code`, as a share answered
|
|
143
|
+
* it). A resend asked of a link that is no longer the spark's link (turned
|
|
144
|
+
* off, or replaced by another share) is refused with a 409 CONFLICT,
|
|
145
|
+
* delivering nothing. An unshare is refused only when another share
|
|
146
|
+
* replaced the link, deleting nothing; a link already turned off answers
|
|
147
|
+
* `shared: false`, so a retried unshare is never refused. Omitted, the
|
|
148
|
+
* request acts on the spark's link now.
|
|
149
|
+
*/
|
|
150
|
+
linkCode?: string;
|
|
101
151
|
}
|
|
102
152
|
|
|
103
153
|
export class MobileSparksClient {
|
|
@@ -138,9 +188,10 @@ export class MobileSparksClient {
|
|
|
138
188
|
}
|
|
139
189
|
|
|
140
190
|
/**
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
191
|
+
* Share a spark via a SparkLink, yielding a shareable `https://x.sv/...` URL:
|
|
192
|
+
* created on the first share; on a spark already shared, the requested
|
|
193
|
+
* settings are applied to the existing link in place (`already_shared`).
|
|
194
|
+
* Only active, non-expired sparks can be shared.
|
|
144
195
|
*/
|
|
145
196
|
async share(sparkId: string, options: ShareSparkOptions = {}): Promise<ShareSparkResponse> {
|
|
146
197
|
validateResourceId(sparkId, 'spark ID', 'sparkId');
|
|
@@ -148,6 +199,7 @@ export class MobileSparksClient {
|
|
|
148
199
|
if (options.visibility) body.visibility = options.visibility;
|
|
149
200
|
if (options.invites) body.invites = options.invites;
|
|
150
201
|
if (options.expiresInSeconds !== undefined) body.expires_in_seconds = options.expiresInSeconds;
|
|
202
|
+
if (options.linkCode !== undefined) body.link_code = options.linkCode;
|
|
151
203
|
|
|
152
204
|
const response = await this.http.patch<ShareSparkResponse>(
|
|
153
205
|
apiPath`/sparks/${sparkId}/share`,
|
|
@@ -161,11 +213,14 @@ export class MobileSparksClient {
|
|
|
161
213
|
* nothing about the link: the way on from an invitation that could not be
|
|
162
214
|
* delivered (a share rejected with 502 INVITATION_DELIVERY_FAILED leaves
|
|
163
215
|
* its link in place, and the same share again delivers nothing).
|
|
216
|
+
* `linkCode` names the link the resend was asked of: a link replaced since
|
|
217
|
+
* is never delivered in its place (409 CONFLICT).
|
|
164
218
|
*/
|
|
165
|
-
async resendInvite(sparkId: string): Promise<ResendSparkInviteResponse> {
|
|
219
|
+
async resendInvite(sparkId: string, options: SparkLinkActionOptions = {}): Promise<ResendSparkInviteResponse> {
|
|
166
220
|
validateResourceId(sparkId, 'spark ID', 'sparkId');
|
|
167
221
|
const response = await this.http.post<ResendSparkInviteResponse>(
|
|
168
|
-
apiPath`/sparks/${sparkId}/share/resend
|
|
222
|
+
apiPath`/sparks/${sparkId}/share/resend`,
|
|
223
|
+
options.linkCode === undefined ? undefined : { link_code: options.linkCode }
|
|
169
224
|
);
|
|
170
225
|
return response.data;
|
|
171
226
|
}
|
|
@@ -179,11 +234,17 @@ export class MobileSparksClient {
|
|
|
179
234
|
return response.data;
|
|
180
235
|
}
|
|
181
236
|
|
|
182
|
-
/**
|
|
183
|
-
|
|
237
|
+
/**
|
|
238
|
+
* Revoke a spark's SparkLink. Resolves whether or not a link existed, the
|
|
239
|
+
* link `linkCode` names included, so a retried unshare is never refused. A
|
|
240
|
+
* `linkCode` naming a link another share replaced since is refused (409
|
|
241
|
+
* CONFLICT), so the link that took its place is never deleted.
|
|
242
|
+
*/
|
|
243
|
+
async unshare(sparkId: string, options: SparkLinkActionOptions = {}): Promise<UnshareSparkResponse> {
|
|
184
244
|
validateResourceId(sparkId, 'spark ID', 'sparkId');
|
|
185
245
|
const response = await this.http.delete<UnshareSparkResponse>(
|
|
186
|
-
apiPath`/sparks/${sparkId}/share
|
|
246
|
+
apiPath`/sparks/${sparkId}/share`,
|
|
247
|
+
{ query: { link_code: options.linkCode } }
|
|
187
248
|
);
|
|
188
249
|
return response.data;
|
|
189
250
|
}
|
package/src/types.ts
CHANGED
|
@@ -594,6 +594,21 @@ export interface Vault {
|
|
|
594
594
|
created_at: number;
|
|
595
595
|
last_unsealed_at?: number;
|
|
596
596
|
unseal_count?: number;
|
|
597
|
+
/** Null inherits the system default; zero disables inactivity resealing. */
|
|
598
|
+
reseal_idle_seconds?: number | null;
|
|
599
|
+
/** Null inherits the system default; never more than 24 hours. */
|
|
600
|
+
reseal_max_seconds?: number | null;
|
|
601
|
+
reseal_defaults?: { idle_seconds: number; max_seconds: number };
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
export interface VaultResealSettings {
|
|
605
|
+
reseal_idle_seconds: number | null;
|
|
606
|
+
reseal_max_seconds: number | null;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
export interface VaultResealSettingsResponse extends VaultResealSettings {
|
|
610
|
+
vault_id: string;
|
|
611
|
+
reseal_defaults: { idle_seconds: number; max_seconds: number };
|
|
597
612
|
}
|
|
598
613
|
|
|
599
614
|
/** The vault's deletion schedule: a company admin can cancel it until `deletion_scheduled_for`. */
|
|
@@ -669,6 +684,18 @@ export interface UnsealVaultResponse {
|
|
|
669
684
|
issued_at: number;
|
|
670
685
|
expires_at: number;
|
|
671
686
|
ttl_seconds: number;
|
|
687
|
+
hard_expires_at?: number;
|
|
688
|
+
idle_timeout_seconds?: number;
|
|
689
|
+
can_extend?: boolean;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
export interface ExtendVaultSessionResponse {
|
|
693
|
+
vault_id: string;
|
|
694
|
+
expires_at: number;
|
|
695
|
+
hard_expires_at: number;
|
|
696
|
+
idle_timeout_seconds: number;
|
|
697
|
+
ttl_seconds: number;
|
|
698
|
+
can_extend: boolean;
|
|
672
699
|
}
|
|
673
700
|
|
|
674
701
|
/** One page of GET /v1/vaults. */
|
|
@@ -1214,17 +1241,37 @@ export interface UploadProgressCallback {
|
|
|
1214
1241
|
(bytesUploaded: number, bytesTotal: number): void;
|
|
1215
1242
|
}
|
|
1216
1243
|
|
|
1217
|
-
/**
|
|
1244
|
+
/** Who may open a spark's SparkLink. */
|
|
1245
|
+
export type SparkShareVisibility = 'public' | 'authenticated' | 'invite_only';
|
|
1246
|
+
|
|
1247
|
+
/**
|
|
1248
|
+
* A spark's SparkLink status, as every share route answers it: 'active';
|
|
1249
|
+
* 'consumed' once it was opened (it opens once); or 'expired' once a link
|
|
1250
|
+
* never opened opens nothing: from its `expires_at` on, or once its spark is
|
|
1251
|
+
* burned (read by its id) or reaches its own expiry. A change or a resend is
|
|
1252
|
+
* then refused (403 FORBIDDEN).
|
|
1253
|
+
*/
|
|
1254
|
+
export type SparkShareLinkStatus = 'active' | 'consumed' | 'expired';
|
|
1255
|
+
|
|
1256
|
+
/**
|
|
1257
|
+
* Result of sharing a spark: its SparkLink, created on the first share, or the
|
|
1258
|
+
* existing one with the requested settings applied to it in place.
|
|
1259
|
+
*/
|
|
1218
1260
|
export interface ShareSparkResponse {
|
|
1219
1261
|
shared: true;
|
|
1262
|
+
spark_id: string;
|
|
1220
1263
|
/** Public `https://x.sv/{code}` URL for the SparkLink. */
|
|
1221
1264
|
share_url: string;
|
|
1222
1265
|
link_code: string;
|
|
1223
|
-
visibility:
|
|
1266
|
+
visibility: SparkShareVisibility;
|
|
1224
1267
|
invites?: string[];
|
|
1268
|
+
status: SparkShareLinkStatus;
|
|
1225
1269
|
expires_at?: number;
|
|
1226
1270
|
created_at?: number;
|
|
1227
|
-
/**
|
|
1271
|
+
/**
|
|
1272
|
+
* True when a SparkLink already existed: the requested settings were
|
|
1273
|
+
* applied to it in place, and its code is unchanged.
|
|
1274
|
+
*/
|
|
1228
1275
|
already_shared?: boolean;
|
|
1229
1276
|
/**
|
|
1230
1277
|
* The invitees this share delivered the link to: none for a share that
|
|
@@ -1256,10 +1303,9 @@ export type SparkShareStatus =
|
|
|
1256
1303
|
spark_id: string;
|
|
1257
1304
|
share_url: string;
|
|
1258
1305
|
link_code: string;
|
|
1259
|
-
visibility:
|
|
1306
|
+
visibility: SparkShareVisibility;
|
|
1260
1307
|
invites: string[];
|
|
1261
|
-
|
|
1262
|
-
status: string;
|
|
1308
|
+
status: SparkShareLinkStatus;
|
|
1263
1309
|
expires_at?: number;
|
|
1264
1310
|
created_at?: number;
|
|
1265
1311
|
};
|
package/src/vaults.ts
CHANGED
|
@@ -23,6 +23,9 @@ import type {
|
|
|
23
23
|
VaultSharingConfig,
|
|
24
24
|
VaultSharingOptions,
|
|
25
25
|
VaultThumbnails,
|
|
26
|
+
VaultResealSettings,
|
|
27
|
+
VaultResealSettingsResponse,
|
|
28
|
+
ExtendVaultSessionResponse,
|
|
26
29
|
} from './types.js';
|
|
27
30
|
import { validateVaultId } from './validation.js';
|
|
28
31
|
import { base64EncodeUtf8 } from './encoding.js';
|
|
@@ -79,6 +82,13 @@ export class MobileVaultsClient {
|
|
|
79
82
|
return response.data;
|
|
80
83
|
}
|
|
81
84
|
|
|
85
|
+
/** Set this vault's reseal times (organization admins); applies on the next unseal. */
|
|
86
|
+
async updateResealSettings(vaultId: string, settings: VaultResealSettings): Promise<VaultResealSettingsResponse> {
|
|
87
|
+
validateVaultId(vaultId);
|
|
88
|
+
const response = await this.http.put<VaultResealSettingsResponse>(apiPath`/vaults/${vaultId}/reseal-settings`, settings);
|
|
89
|
+
return response.data;
|
|
90
|
+
}
|
|
91
|
+
|
|
82
92
|
/**
|
|
83
93
|
* Schedule deletion in seven days and lock the vault immediately. Requires the vault's exact name as
|
|
84
94
|
* confirmation (case-sensitive). Answers the schedule, or, for a vault whose irreversible cleanup has
|
|
@@ -119,6 +129,13 @@ export class MobileVaultsClient {
|
|
|
119
129
|
return response.data;
|
|
120
130
|
}
|
|
121
131
|
|
|
132
|
+
/** Explicitly extend the held session's inactivity window, within its original hard maximum. */
|
|
133
|
+
async extendSession(vaultId: string, vat: string): Promise<ExtendVaultSessionResponse> {
|
|
134
|
+
validateVaultId(vaultId);
|
|
135
|
+
const response = await this.http.post<ExtendVaultSessionResponse>(apiPath`/vaults/${vaultId}/session/extend`, undefined, { vat });
|
|
136
|
+
return response.data;
|
|
137
|
+
}
|
|
138
|
+
|
|
122
139
|
/**
|
|
123
140
|
* Seal the vault: end every session of it, so every VAT minted for it stops
|
|
124
141
|
* working, whoever holds it. To end only the caller's own session, use
|