@sparkvault/sdk-js 15.0.0 → 15.1.1

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.
@@ -2,7 +2,8 @@
2
2
  * Upload Renderer
3
3
  *
4
4
  * Orchestrates view state and rendering for vault upload flows.
5
- * Manages the complete upload lifecycle: form, uploading, ceremony, completion.
5
+ * Manages the complete upload lifecycle: form, uploading (the bytes moving,
6
+ * then SparkVault securing the file until it confirms the save), completion.
6
7
  */
7
8
  import type { UploadOptions, UploadResult, UploadProgress } from './types';
8
9
  import type { UploadContainer } from './container';
@@ -28,6 +29,15 @@ export declare class UploadRenderer {
28
29
  private hybridModalInitialized;
29
30
  private closed;
30
31
  private cancelled;
32
+ private uploadGeneration;
33
+ private uploadInFlight;
34
+ private ready;
35
+ /**
36
+ * A browser tab closed or reloaded mid-transfer loses the upload, so the
37
+ * tab asks first while one runs (holdPage). Each renderer holds the page
38
+ * with its own listener, so one ending never releases another's hold.
39
+ */
40
+ private readonly warnBeforeLeaving;
31
41
  constructor(container: UploadContainer, api: UploadApi, options: UploadOptions, callbacks: RendererCallbacks);
32
42
  /**
33
43
  * Start the upload flow.
@@ -46,6 +56,13 @@ export declare class UploadRenderer {
46
56
  * this renderer) must never surface as an error to the host.
47
57
  */
48
58
  cancel(): void;
59
+ /**
60
+ * The dialog's dismissals: Escape, a tap on its backdrop, and its close
61
+ * button, which the uploading view hides. While an upload runs, Escape and
62
+ * a tap are too easy to do by accident to end it, as in the dialog inline
63
+ * mode runs the upload in (renderInModal): the view's Cancel upload stops
64
+ * it, and once SparkVault secures the file nothing does.
65
+ */
49
66
  private handleClose;
50
67
  private setState;
51
68
  /**
@@ -56,16 +73,45 @@ export declare class UploadRenderer {
56
73
  private updateUploadProgress;
57
74
  private render;
58
75
  /**
59
- * Render uploading/ceremony states in a modal overlay (for inline mode).
76
+ * A redraw replaces the control the person just used, so once the widget is
77
+ * ready (this.ready) focus never drops to the page: it lands on Upload
78
+ * securely once a file is chosen, on the drop target before one is, and on
79
+ * the heading every other view leads with (tabindex -1: it takes focus
80
+ * without joining the Tab order). The loading view has nothing to focus.
81
+ */
82
+ private focusView;
83
+ /**
84
+ * Render the uploading state in a modal overlay (for inline mode).
60
85
  * This provides the full polished experience during upload.
61
86
  */
62
87
  private renderInModal;
63
88
  private renderLoading;
64
89
  private renderForm;
65
90
  private renderUploading;
66
- private renderCeremony;
67
91
  private renderComplete;
92
+ /**
93
+ * Copy the Ingot ID, saying beside it that it landed ("Copied", for
94
+ * COPIED_SHOWS_MS) or that the browser refused it, and how to take the ID
95
+ * instead. A browser without the clipboard API refuses like one that denies
96
+ * it.
97
+ */
98
+ private copyIngotId;
99
+ /**
100
+ * A file whose every byte reached SparkVault, which is still saving it and
101
+ * finishes on its own: received, never failed, so it reads as an outcome,
102
+ * with the way on to another file.
103
+ */
104
+ private renderReceived;
68
105
  private renderError;
106
+ /** The button that takes the person back to the form, with or without the chosen file. */
107
+ private recoveryButton;
108
+ /**
109
+ * Whether a file the person drops, picks, pastes or removes counts: only on
110
+ * the form, and only while no upload runs (uploadInFlight). The paste
111
+ * listener hears the whole page in every view, and a file it took mid-upload
112
+ * would start a second upload beside the first.
113
+ */
114
+ private formTakesFile;
69
115
  private handleFileSelect;
70
116
  private openFileSelector;
71
117
  private cleanupFileInput;
@@ -73,10 +119,31 @@ export declare class UploadRenderer {
73
119
  private setupPasteHandler;
74
120
  private cleanupPasteHandler;
75
121
  private startUpload;
76
- private runCeremony;
77
122
  /**
78
- * Show a failure in the error view, with the way on it offers (`action`:
79
- * none for a page that could not load), and tell the host through onError.
123
+ * Stop the upload whose bytes are moving. The stopped upload's late events
124
+ * render nothing and tell the host nothing (uploadGeneration).
125
+ *
126
+ * A file the host chose itself skipped the form, so its upload ends the
127
+ * widget through the cancel contract (cancel(): the transfer aborted with
128
+ * the session, onCancel, UserCancelledError), and the host offers its own
129
+ * way on. A file chosen on the widget returns to the form, still chosen, so
130
+ * a wrong or slow pick costs one tap: the transfer is aborted with the
131
+ * session's signal, a fresh session serves the next upload, and neither
132
+ * callback fires, since the widget stays open and the host hears of the
133
+ * next upload.
134
+ */
135
+ private cancelUpload;
136
+ /**
137
+ * Ask before the page is closed or reloaded while an upload runs
138
+ * (this.warnBeforeLeaving), or stop asking.
139
+ */
140
+ private holdPage;
141
+ /**
142
+ * Show a failure (`action`: the way on it offers, none for a page that
143
+ * could not load), and tell the host through onError. A file received whole
144
+ * and still being saved reads as received, never as a failure; the host
145
+ * still hears it through onError, with its code, which tells it never to
146
+ * upload the file again.
80
147
  */
81
148
  private handleApiError;
82
149
  }
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * SparkVault design system, product register, as the identity modal: slate
5
5
  * neutrals with Action Blue carrying interactivity, on a light card that turns
6
- * to the dark surface for the upload and security ceremony. Every color is the
7
- * design system's (ui/ds-tokens).
6
+ * to the dark surface while the upload runs. Every color is the design
7
+ * system's (ui/ds-tokens).
8
8
  */
9
9
  /**
10
10
  * Inject upload widget styles into the document head.
@@ -59,7 +59,7 @@ export interface UploadOptions {
59
59
  target?: string | HTMLElement;
60
60
  /** Override backdrop blur for this dialog (uses global config if omitted) */
61
61
  backdropBlur?: boolean;
62
- /** Hide "Upload Another File" button on success screen (for single-file flows) */
62
+ /** Hide the "Upload another file" button once a file is sent (for single-file flows) */
63
63
  hideUploadAnother?: boolean;
64
64
  /**
65
65
  * Skip the success screen entirely. On completion the SDK fires onSuccess
@@ -125,7 +125,13 @@ export interface UploadProgress {
125
125
  bytesTotal: number;
126
126
  /** Percentage (0-100) */
127
127
  percentage: number;
128
- /** Current phase */
128
+ /**
129
+ * Current phase: 'uploading' while the bytes move and while SparkVault
130
+ * secures the file (percentage 100 once every byte is sent, before the save
131
+ * is confirmed; an upload can still fail then). 'ceremony' once SparkVault
132
+ * has confirmed the save, reported once, then 'complete' as the upload
133
+ * ends. No phase runs on a timer.
134
+ */
129
135
  phase: 'uploading' | 'ceremony' | 'complete';
130
136
  }
131
137
  /**
@@ -152,30 +158,30 @@ export type UploadViewState = {
152
158
  view: 'form';
153
159
  config: VaultUploadConfig;
154
160
  error?: string;
155
- } | {
161
+ }
162
+ /** `securing`: every byte is sent, and SparkVault is saving the file. */
163
+ | {
156
164
  view: 'uploading';
157
165
  file: File;
158
166
  ingotId: string;
159
167
  requestId: string | null;
160
168
  progress: number;
161
169
  bytesUploaded: number;
162
- } | {
163
- view: 'ceremony';
164
- file: File;
165
- ingotId: string;
166
- requestId: string | null;
167
- step: number;
168
- complete: boolean;
170
+ securing: boolean;
169
171
  } | {
170
172
  view: 'complete';
171
173
  result: UploadResult;
172
174
  config: VaultUploadConfig;
175
+ }
176
+ /** A file received whole that SparkVault is still saving (RECEIVED_STILL_SAVING). */
177
+ | {
178
+ view: 'received';
179
+ message: string;
180
+ action: UploadRecovery | null;
173
181
  } | {
174
182
  view: 'error';
175
183
  title: string;
176
184
  message: string;
177
- code: string;
178
- statusCode?: number;
179
185
  action?: UploadRecovery | null;
180
186
  };
181
187
  /**
@@ -212,12 +218,3 @@ export interface InitiateUploadResponse {
212
218
  forge_url: string;
213
219
  ingot_id: string;
214
220
  }
215
- /**
216
- * Ceremony step definition.
217
- */
218
- export interface CeremonyStep {
219
- /** Display text */
220
- text: string;
221
- /** Duration in milliseconds */
222
- duration: number;
223
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkvault/sdk-js",
3
- "version": "15.0.0",
3
+ "version": "15.1.1",
4
4
  "description": "SparkVault JavaScript SDK - Identity, Secure Help Desk, Notifications and Encrypted Vaults",
5
5
  "type": "module",
6
6
  "exports": {