@sparkvault/sdk-js 1.24.6 → 1.25.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.d.ts CHANGED
@@ -486,6 +486,17 @@ interface UploadOptions {
486
486
  backdropBlur?: boolean;
487
487
  /** Hide "Upload Another File" button on success screen (for single-file flows) */
488
488
  hideUploadAnother?: boolean;
489
+ /**
490
+ * Vault Access Token. When provided, the upload is authorized by the VAT
491
+ * (no public-upload flag required). When omitted, the public upload flow
492
+ * is used (hosted VMK/DVAK), which requires public upload to be enabled.
493
+ */
494
+ token?: string;
495
+ /**
496
+ * Slash-delimited folder path within the vault (e.g. "Accounts/001xx").
497
+ * Missing path segments are find-or-created. Omitted means the vault root.
498
+ */
499
+ folder?: string;
489
500
  /** Callback when upload completes successfully (if omitted, uses server-configured redirect) */
490
501
  onSuccess?: (result: UploadResult) => void;
491
502
  /** Callback when an error occurs (if omitted, uses server-configured redirect) */
@@ -6782,15 +6782,20 @@ class UploadApi extends SparkVaultApi {
6782
6782
  /**
6783
6783
  * Initiate an upload to get Forge URL and ingot ID.
6784
6784
  */
6785
- async initiateUpload(vaultId, filename, sizeBytes, contentType) {
6785
+ async initiateUpload(vaultId, filename, sizeBytes, contentType, token, folder) {
6786
6786
  const url = `${this.config.apiBaseUrl}/v1/files/in/${vaultId}/upload`;
6787
+ const body = {
6788
+ filename,
6789
+ size_bytes: sizeBytes,
6790
+ content_type: contentType,
6791
+ };
6792
+ if (folder) {
6793
+ body.folder_path = folder;
6794
+ }
6787
6795
  const response = await this.request(url, {
6788
6796
  method: 'POST',
6789
- body: JSON.stringify({
6790
- filename,
6791
- size_bytes: sizeBytes,
6792
- content_type: contentType,
6793
- }),
6797
+ body: JSON.stringify(body),
6798
+ headers: token ? { 'X-Vault-Access-Token': token } : undefined,
6794
6799
  });
6795
6800
  if (!isInitiateUploadResponse(response.data)) {
6796
6801
  throw new UploadApiError('Invalid initiate upload response from server', 'invalid_response', response.status);
@@ -9117,7 +9122,7 @@ class UploadRenderer {
9117
9122
  div.className = 'svu-error-view';
9118
9123
  div.innerHTML = `
9119
9124
  <div class="svu-error-icon">
9120
- <svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
9125
+ <svg width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
9121
9126
  <circle cx="12" cy="12" r="10"/>
9122
9127
  <path d="M12 8v4M12 16h.01"/>
9123
9128
  </svg>
@@ -9199,7 +9204,7 @@ class UploadRenderer {
9199
9204
  const requestId = generateRequestId();
9200
9205
  try {
9201
9206
  // Initiate upload
9202
- const { forgeUrl, ingotId } = await this.api.initiateUpload(config.vaultId, file.name, file.size, file.type || 'application/octet-stream');
9207
+ const { forgeUrl, ingotId } = await this.api.initiateUpload(config.vaultId, file.name, file.size, file.type || 'application/octet-stream', this.options.token, this.options.folder);
9203
9208
  // Show uploading state
9204
9209
  this.setState({
9205
9210
  view: 'uploading',