@sparkvault/sdk-js 14.2.2 → 14.3.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.
@@ -18,15 +18,24 @@ export declare class HelpDeskClient {
18
18
  private authorityRevision;
19
19
  private readonly listeners;
20
20
  private session;
21
+ /**
22
+ * When the installed session ends on this device's clock, in seconds: set
23
+ * from `ttl_seconds` as an answer lands from Core. Null for a session whose
24
+ * landing this client did not see (setSession), which ends at Core's 401.
25
+ */
26
+ private deadline;
21
27
  private token;
22
28
  private revision;
23
29
  private constructor();
24
30
  /** Discover a desk by its configured host, before any customer credentials are sent. */
25
31
  static connect(config: ResolvedConfig, options: HelpDeskConnectOptions): Promise<HelpDeskClient>;
26
32
  /**
27
- * Install a customer session answer. A company provider verifies restored
28
- * sessions again before use. Null stays signed out until refreshSession()
29
- * or authenticate() explicitly resumes the provider.
33
+ * Install a customer session answer the host holds, such as one restored
34
+ * from its own storage. Its landing time is unknown, so this client sets it
35
+ * no deadline of its own: it lasts until Core answers 401, which clears it.
36
+ * A company provider verifies restored sessions again before use. Null
37
+ * stays signed out until refreshSession() or authenticate() explicitly
38
+ * resumes the provider.
30
39
  */
31
40
  setSession(session: HelpDeskSession | null): void;
32
41
  private installSession;
@@ -46,7 +55,11 @@ export declare class HelpDeskClient {
46
55
  private rememberToken;
47
56
  private send;
48
57
  private establish;
49
- /** A public, short-lived challenge from the help desk's own Entropy service. */
58
+ /**
59
+ * A public, short-lived challenge from the help desk's own Entropy service.
60
+ * Core refuses a nonce past its `expires_at` on its own clock, so this
61
+ * device's clock never judges it.
62
+ */
50
63
  startExternalChallenge(): Promise<HelpDeskExternalChallenge>;
51
64
  /** Exchange only a purpose-specific company assertion, never an ordinary website token. */
52
65
  completeExternal(options: {
@@ -56,6 +69,7 @@ export declare class HelpDeskClient {
56
69
  private exchangeExternal;
57
70
  /** Silently establish/renew a company session. Concurrent calls share one proof. */
58
71
  authenticate(): Promise<HelpDeskSession | null>;
72
+ /** Install a company session answer that just landed from Core, timed from its `ttl_seconds`. */
59
73
  private acceptExternalSession;
60
74
  /** Mint an opaque hosted-portal code from an assertion binding the registered redirect challenge. */
61
75
  createExternalHandoff(options: {
@@ -8,6 +8,7 @@ export declare function createFormAttachments(client: HelpDeskClient, prefix: st
8
8
  element: HTMLDivElement;
9
9
  readonly attachmentIds: string[];
10
10
  readonly unresolved: boolean;
11
+ readonly hasEntries: boolean;
11
12
  readonly busy: boolean;
12
13
  start(): Promise<void>;
13
14
  lock(value: boolean): void;
@@ -1,8 +1,27 @@
1
1
  import type { HelpDeskClient } from './client';
2
2
  import type { HelpDeskFormHandle, HelpDeskFormOptions } from './form-types';
3
+ /**
4
+ * The form's handle and the one dismissal every close control and the SDK's
5
+ * modal route through. Internal: the package's public API hands out only
6
+ * HelpDeskFormHandle.
7
+ */
8
+ export interface HelpDeskFormController extends HelpDeskFormHandle {
9
+ /**
10
+ * Close at once when nothing is unsent. Otherwise ask whether to discard
11
+ * the request, and a second request while that question shows keeps
12
+ * editing.
13
+ */
14
+ requestDismiss(): void;
15
+ }
3
16
  /**
4
17
  * Inject a ticket form using only the requester's customer API. Authentication
5
18
  * is the desk's email-code flow or an explicit host-provided customer session.
6
19
  * Files use the same direct resumable Forge ceremony as the hosted portal.
20
+ *
21
+ * A check the form makes itself (an empty subject, a short code) and the
22
+ * server's refusal of a code read under the field they concern; the status
23
+ * line carries the flow (a code sent, a send in progress or uncertain, a
24
+ * changed sign-in, a server error). Closing with unsent work asks first.
25
+ * A confirmed send replaces the form with its confirmation.
7
26
  */
8
- export declare function mountHelpDeskForm(client: HelpDeskClient, options: HelpDeskFormOptions): HelpDeskFormHandle;
27
+ export declare function mountHelpDeskForm(client: HelpDeskClient, options: HelpDeskFormOptions): HelpDeskFormController;
@@ -66,8 +66,10 @@ export interface HelpDeskCustomer {
66
66
  }
67
67
  export interface HelpDeskSession {
68
68
  token: string;
69
- /** Absolute expiry in Unix seconds. */
69
+ /** When Core ends the session at the latest, in Unix seconds on Core's clock. Never compared with this device's clock, which may run apart from Core's. */
70
70
  expires_at: number;
71
+ /** The session's lifetime in seconds from when its answer lands; the client times a fresh answer on this device's clock from it. */
72
+ ttl_seconds: number;
71
73
  customer: HelpDeskCustomer;
72
74
  }
73
75
  /** Why customer-specific UI is being told to reconsider its current session. */
@@ -1,11 +1,12 @@
1
1
  /**
2
2
  * Sparks Module
3
3
  *
4
- * Create, read, share, and delete end-to-end encrypted, read-once ephemeral
5
- * secrets. Sparks are account-scoped — no vault or VAT is involved.
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 public SparkLink (x.sv URL).
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';
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Sparks Module Types
3
3
  *
4
- * Sparks are end-to-end encrypted, read-once ephemeral secrets scoped to the
5
- * account (no vault/VAT). Public domain objects are camelCase; wire shapes
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
- * Lifecycle status: active, expired, ash (a recipient read it, and it
18
- * burned) or deleted (its owner deleted it, which burns its content too)
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: string;
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
- /** The read's burn timestamp (Unix seconds), or null if not read (a deleted spark's included) */
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
- /** A link spark (contentType text/uri-list) only: its x.sv link */
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,7 +111,13 @@ export interface CreatedSpark {
101
111
  export interface ListSparksOptions {
102
112
  /** Filter to a kindling family */
103
113
  kindling?: string;
104
- /** Filter by status */
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
+ */
105
121
  status?: string;
106
122
  /** Page size */
107
123
  limit?: number;
@@ -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
- /** Options for share. */
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
- /** Visibility mode. Defaults to public. */
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
- /** Invited identities (emails/phones) */
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
- /** Link lifetime in seconds */
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: string;
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;