@sparkvault/sdk-mobile 7.2.3 → 7.2.5

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/src/types.ts CHANGED
@@ -694,6 +694,17 @@ export interface UploadConfigUpdate {
694
694
  export interface Ingot {
695
695
  ingot_id: string;
696
696
  name: string;
697
+ /**
698
+ * The name a download of the ingot saves under, as Forge names it: `name`,
699
+ * kept as it is when the first word of the extension it shows (up to an
700
+ * ASCII space, in any case) is one the MIME registry knows or holds a
701
+ * character none of the registry's extensions is spelled with, which may
702
+ * draw as one, and otherwise completed with the first extension the
703
+ * registry lists for `content_type`, never one a saved copy must never open
704
+ * as. Every ingot Core answers carries it; a row the app builds before Core
705
+ * answers (a queued upload's) has none.
706
+ */
707
+ download_filename?: string;
697
708
  content_type: string;
698
709
  size_bytes: number;
699
710
  /** `uploading` until Forge activates the upload, then `active`. */
@@ -1004,8 +1015,8 @@ export interface BackgroundTransferJob {
1004
1015
  * Why an OS transfer ended without reaching the final offset: the engine's
1005
1016
  * own failure kinds plus `cancelled`, which only the app adapter produces
1006
1017
  * for the caller's own abort (the engine never reports a cancel it was asked
1007
- * for). `http` carries Forge's status and body (the SDK maps gates and lost
1008
- * sessions from them); `interrupted` is the OS ending the task without being
1018
+ * for). `http` carries Forge's status, body and `X-Upload-Refusal` (the SDK
1019
+ * maps gates, lost sessions and Core's refusals from them); `interrupted` is the OS ending the task without being
1009
1020
  * asked (a relaunch, a system cancel); `stalled` is a 2xx whose offset did
1010
1021
  * not advance; `file` is a source the engine could not read.
1011
1022
  */
package/src/validation.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { isResourceId } from './app-sdk/ids.js';
2
2
  import { SparkVaultValidationError } from './errors.js';
3
- import { SAVED_FILENAME_FALLBACK, toStorableFilename } from './app-sdk/filename.js';
3
+ import {
4
+ FILENAME_PROBLEMS,
5
+ SAVED_FILENAME_FALLBACK,
6
+ storableFilenameProblem,
7
+ toStorableFilename,
8
+ } from './app-sdk/filename.js';
4
9
 
5
10
  /** Whether a value is a well-formed SparkVault resource id (the platform's one rule). */
6
11
  export { isResourceId as isSafeId };
@@ -46,7 +51,10 @@ const WINDOWS_RESERVED_NAMES = new Set([
46
51
  * can climb a directory, so a `..` inside a name is kept. On top of the rule,
47
52
  * for the device's file system: leading dots are stripped (a hidden file) and
48
53
  * Windows reserved names are prefixed. Falls back to the platform's one
49
- * fallback name (SAVED_FILENAME_FALLBACK) when nothing remains.
54
+ * fallback name (SAVED_FILENAME_FALLBACK) when nothing remains, or nothing
55
+ * but dots and spaces (storableFilenameProblem's ONLY_DOTS_OR_SPACES, which
56
+ * reads a name past its invisible characters): `. .` and `..<U+034F>` show
57
+ * nothing a device can name a file by.
50
58
  */
51
59
  export function sanitizeFilename(filename: string): string {
52
60
  let sanitized = toStorableFilename(filename)
@@ -58,5 +66,7 @@ export function sanitizeFilename(filename: string): string {
58
66
  sanitized = `_${sanitized}`;
59
67
  }
60
68
 
61
- return sanitized || SAVED_FILENAME_FALLBACK;
69
+ return sanitized === '' || storableFilenameProblem(sanitized) === FILENAME_PROBLEMS.ONLY_DOTS_OR_SPACES
70
+ ? SAVED_FILENAME_FALLBACK
71
+ : sanitized;
62
72
  }