@sparkvault/sdk-mobile 7.2.2 → 7.2.4

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.
@@ -7,6 +7,17 @@
7
7
  * @returns {boolean}
8
8
  */
9
9
  export function hasControlOrBidiCharacter(text: string): boolean;
10
+ /**
11
+ * `name` without the trailing dots and white space a save drops: "page.html."
12
+ * and "page.html " are "page.html", "notes. ." is "notes", and a name of only
13
+ * dots and white space is ''. lastExtension reads the extension in front of
14
+ * them, and Forge completes a saved name after them (./media-type-node.js
15
+ * withMediaTypeExtension: "notes." under text/plain saves as "notes.txt").
16
+ *
17
+ * @param {string} name
18
+ * @returns {string}
19
+ */
20
+ export function trimDroppedTrailing(name: string): string;
10
21
  /**
11
22
  * What stops `name` from being stored as a file name, or null when nothing
12
23
  * does. Length and emptiness are the storing runtime's own limits.
@@ -24,7 +35,13 @@ export function storableFilenameProblem(name: string): string | null;
24
35
  export function toSavedFilename(name: string): string;
25
36
  /**
26
37
  * The name a download is saved under: the file's own name by the saved-name
27
- * rule (toSavedFilename), or SAVED_FILENAME_FALLBACK when it has none.
38
+ * rule (toSavedFilename), or SAVED_FILENAME_FALLBACK when it has none, or one
39
+ * of only dots or spaces, invisible characters among them
40
+ * (isOnlyDotsOrSpaces): such a name, completed for its type
41
+ * (./media-type-node.js downloadFilename), would be an extension alone, which
42
+ * a browser saves without its leading dots (`...` completed for a text file
43
+ * is `.txt`, which saves as `txt`, and `..<U+034F>` is `..<U+034F>.txt`,
44
+ * which saves as `<U+034F>.txt` and shows as `.txt`).
28
45
  *
29
46
  * @param {string|null|undefined} name
30
47
  * @returns {string}
@@ -53,22 +70,11 @@ export function splitExtension(name: string): {
53
70
  extension: string;
54
71
  };
55
72
  /**
56
- * `name` without the trailing dots and white space a save drops: "page.html."
57
- * and "page.html " are "page.html", "notes. ." is "notes", and a name of only
58
- * dots and white space is ''. lastExtension reads the extension in front of
59
- * them, and Forge completes a saved name after them (./media-type-node.js
60
- * withMediaTypeExtension: "notes." under text/plain saves as "notes.txt").
61
- *
62
- * @param {string} name
63
- * @returns {string}
64
- */
65
- export function trimDroppedTrailing(name: string): string;
66
- /**
67
- * The extension `name` shows, lowercase and without its dot: what follows its
68
- * last dot once its invisible characters are read past and the
69
- * trailing dots and white space a save drops are trimmed
70
- * (trimDroppedTrailing). It is the extension a saved copy opens as wherever
71
- * the name holds no invisible character: "invoice.note.html" and
73
+ * The extension `name` shows, lowercase and without its dot: what follows the
74
+ * last dot of what the name shows once saved (nameAsShown: read past its
75
+ * invisible characters, without the trailing dots and white space a save
76
+ * drops). It is the extension a saved copy opens as wherever the name holds
77
+ * no invisible character: "invoice.note.html" and
72
78
  * "page.html." open as 'html', "logs.tar.gz" as 'gz', ".html" as 'html'
73
79
  * (Windows reads a leading dot's extension), and a name with no dot as ''.
74
80
  * "Invoice.pdf<U+034F>" shows 'pdf', so no rule completes it with a second
@@ -119,7 +125,9 @@ export const SAVED_FILENAME_FALLBACK: "download";
119
125
  * that cannot import an ES module (the x.sv reveal page): it declares
120
126
  * `savedFilename` and everything it reads at the script's top level, built
121
127
  * from the functions and constants above, so the page runs this rule, not a
122
- * copy. A new module-scope binding the rule reads must be added here.
128
+ * copy. A new module-scope binding the rule reads must be added here. Marked
129
+ * pure so a bundle that never reads it (the console's, the help desk portal's)
130
+ * drops it.
123
131
  */
124
132
  export const SAVED_FILENAME_SCRIPT: string;
125
133
  /** The longest name an ingot stores, in UTF-16 code units. */
@@ -44,13 +44,70 @@ export function hasControlOrBidiCharacter(text) {
44
44
  }
45
45
  /** Characters the file systems a name is saved to refuse. */
46
46
  const NON_PORTABLE_FILENAME_CHARACTERS = /[:*?"<>|]/;
47
+ /**
48
+ * A character a save drops from a name's end. Windows drops trailing dots and
49
+ * spaces from a name it saves ("page.html." is saved as "page.html"); any
50
+ * other trailing white space is dropped alike, so a name never hides the
51
+ * extension a saved copy could open as.
52
+ */
53
+ const DROPPED_TRAILING_CHARACTER = /[\s.]/u;
54
+ /**
55
+ * `name` without the trailing dots and white space a save drops: "page.html."
56
+ * and "page.html " are "page.html", "notes. ." is "notes", and a name of only
57
+ * dots and white space is ''. lastExtension reads the extension in front of
58
+ * them, and Forge completes a saved name after them (./media-type-node.js
59
+ * withMediaTypeExtension: "notes." under text/plain saves as "notes.txt").
60
+ *
61
+ * @param {string} name
62
+ * @returns {string}
63
+ */
64
+ export function trimDroppedTrailing(name) {
65
+ let end = name.length;
66
+ while (end > 0 && DROPPED_TRAILING_CHARACTER.test(name[end - 1]))
67
+ end -= 1;
68
+ return name.slice(0, end);
69
+ }
70
+ /**
71
+ * Invisible characters (Unicode's Default_Ignorable_Code_Point): the joiners,
72
+ * variation selectors, tags and bidirectional controls, which display as
73
+ * nothing, and the Hangul fillers, which display as blank space. None shows
74
+ * in a name, and a save keeps several (`Invoice.pdf<U+034F>` saves as itself
75
+ * in Chromium and Firefox, and shows as `Invoice.pdf`).
76
+ */
77
+ const INVISIBLE_CHARACTERS = /\p{Default_Ignorable_Code_Point}/gu;
78
+ /**
79
+ * What `name` shows once saved: the name read past its invisible characters
80
+ * (INVISIBLE_CHARACTERS), without the trailing dots and white space a save
81
+ * drops (trimDroppedTrailing). The extension a name shows is read in it
82
+ * (lastExtension), and a name it leaves nothing of is one of only dots or
83
+ * spaces (isOnlyDotsOrSpaces).
84
+ *
85
+ * @param {string} name
86
+ * @returns {string}
87
+ */
88
+ function nameAsShown(name) {
89
+ return trimDroppedTrailing(name.replace(INVISIBLE_CHARACTERS, ''));
90
+ }
47
91
  /** Why a name cannot be stored, as storableFilenameProblem reports it. */
48
92
  export const FILENAME_PROBLEMS = Object.freeze({
49
93
  UNSAFE_CHARACTER: 'unsafe_character',
50
94
  NON_PORTABLE_CHARACTER: 'non_portable_character',
51
95
  ONLY_DOTS_OR_SPACES: 'only_dots_or_spaces'
52
96
  });
53
- const ONLY_DOTS_OR_SPACES = /^[\s.]+$/;
97
+ /**
98
+ * Whether `name` is one of only dots or spaces: a name that is not empty yet
99
+ * shows nothing once saved (nameAsShown), every character in it a dot, white
100
+ * space or an invisible character (`...` and ` . `, and `..<U+034F>` and
101
+ * `.<U+200B>.`, which show as `..`). No such name is stored
102
+ * (storableFilenameProblem), and a file that has one saves under the
103
+ * fallback name (savedFilename).
104
+ *
105
+ * @param {string} name
106
+ * @returns {boolean}
107
+ */
108
+ function isOnlyDotsOrSpaces(name) {
109
+ return name !== '' && nameAsShown(name) === '';
110
+ }
54
111
  /**
55
112
  * What stops `name` from being stored as a file name, or null when nothing
56
113
  * does. Length and emptiness are the storing runtime's own limits.
@@ -63,7 +120,7 @@ export function storableFilenameProblem(name) {
63
120
  return FILENAME_PROBLEMS.UNSAFE_CHARACTER;
64
121
  if (NON_PORTABLE_FILENAME_CHARACTERS.test(name))
65
122
  return FILENAME_PROBLEMS.NON_PORTABLE_CHARACTER;
66
- if (ONLY_DOTS_OR_SPACES.test(name))
123
+ if (isOnlyDotsOrSpaces(name))
67
124
  return FILENAME_PROBLEMS.ONLY_DOTS_OR_SPACES;
68
125
  return null;
69
126
  }
@@ -80,24 +137,39 @@ export function toSavedFilename(name) {
80
137
  export const SAVED_FILENAME_FALLBACK = 'download';
81
138
  /**
82
139
  * The name a download is saved under: the file's own name by the saved-name
83
- * rule (toSavedFilename), or SAVED_FILENAME_FALLBACK when it has none.
140
+ * rule (toSavedFilename), or SAVED_FILENAME_FALLBACK when it has none, or one
141
+ * of only dots or spaces, invisible characters among them
142
+ * (isOnlyDotsOrSpaces): such a name, completed for its type
143
+ * (./media-type-node.js downloadFilename), would be an extension alone, which
144
+ * a browser saves without its leading dots (`...` completed for a text file
145
+ * is `.txt`, which saves as `txt`, and `..<U+034F>` is `..<U+034F>.txt`,
146
+ * which saves as `<U+034F>.txt` and shows as `.txt`).
84
147
  *
85
148
  * @param {string|null|undefined} name
86
149
  * @returns {string}
87
150
  */
88
151
  export function savedFilename(name) {
89
- return typeof name === 'string' && name !== '' ? toSavedFilename(name) : SAVED_FILENAME_FALLBACK;
152
+ return typeof name === 'string' && name !== '' && !isOnlyDotsOrSpaces(name)
153
+ ? toSavedFilename(name)
154
+ : SAVED_FILENAME_FALLBACK;
90
155
  }
91
156
  /**
92
157
  * The saved-name rule as the source of a classic browser script, for a page
93
158
  * that cannot import an ES module (the x.sv reveal page): it declares
94
159
  * `savedFilename` and everything it reads at the script's top level, built
95
160
  * from the functions and constants above, so the page runs this rule, not a
96
- * copy. A new module-scope binding the rule reads must be added here.
161
+ * copy. A new module-scope binding the rule reads must be added here. Marked
162
+ * pure so a bundle that never reads it (the console's, the help desk portal's)
163
+ * drops it.
97
164
  */
98
- export const SAVED_FILENAME_SCRIPT = [
165
+ export const SAVED_FILENAME_SCRIPT = /* @__PURE__ */ [
99
166
  `var UNSAFE_FILENAME_CHARACTERS = ${UNSAFE_FILENAME_CHARACTERS};`,
167
+ `var DROPPED_TRAILING_CHARACTER = ${DROPPED_TRAILING_CHARACTER};`,
168
+ `var INVISIBLE_CHARACTERS = ${INVISIBLE_CHARACTERS};`,
100
169
  `var SAVED_FILENAME_FALLBACK = ${JSON.stringify(SAVED_FILENAME_FALLBACK)};`,
170
+ trimDroppedTrailing,
171
+ nameAsShown,
172
+ isOnlyDotsOrSpaces,
101
173
  toSavedFilename,
102
174
  savedFilename
103
175
  ].join('\n');
@@ -145,42 +217,11 @@ export function splitExtension(name) {
145
217
  : { stem: name, extension: '' };
146
218
  }
147
219
  /**
148
- * A character a save drops from a name's end. Windows drops trailing dots and
149
- * spaces from a name it saves ("page.html." is saved as "page.html"); any
150
- * other trailing white space is dropped alike, so a name never hides the
151
- * extension a saved copy could open as.
152
- */
153
- const DROPPED_TRAILING_CHARACTER = /[\s.]/u;
154
- /**
155
- * `name` without the trailing dots and white space a save drops: "page.html."
156
- * and "page.html " are "page.html", "notes. ." is "notes", and a name of only
157
- * dots and white space is ''. lastExtension reads the extension in front of
158
- * them, and Forge completes a saved name after them (./media-type-node.js
159
- * withMediaTypeExtension: "notes." under text/plain saves as "notes.txt").
160
- *
161
- * @param {string} name
162
- * @returns {string}
163
- */
164
- export function trimDroppedTrailing(name) {
165
- let end = name.length;
166
- while (end > 0 && DROPPED_TRAILING_CHARACTER.test(name[end - 1]))
167
- end -= 1;
168
- return name.slice(0, end);
169
- }
170
- /**
171
- * Invisible characters (Unicode's Default_Ignorable_Code_Point): the joiners,
172
- * variation selectors, tags and bidirectional controls, which display as
173
- * nothing, and the Hangul fillers, which display as blank space. None shows
174
- * in a name, and a save keeps several (`Invoice.pdf<U+034F>` saves as itself
175
- * in Chromium and Firefox, and shows as `Invoice.pdf`).
176
- */
177
- const INVISIBLE_CHARACTERS = /\p{Default_Ignorable_Code_Point}/gu;
178
- /**
179
- * The extension `name` shows, lowercase and without its dot: what follows its
180
- * last dot once its invisible characters are read past and the
181
- * trailing dots and white space a save drops are trimmed
182
- * (trimDroppedTrailing). It is the extension a saved copy opens as wherever
183
- * the name holds no invisible character: "invoice.note.html" and
220
+ * The extension `name` shows, lowercase and without its dot: what follows the
221
+ * last dot of what the name shows once saved (nameAsShown: read past its
222
+ * invisible characters, without the trailing dots and white space a save
223
+ * drops). It is the extension a saved copy opens as wherever the name holds
224
+ * no invisible character: "invoice.note.html" and
184
225
  * "page.html." open as 'html', "logs.tar.gz" as 'gz', ".html" as 'html'
185
226
  * (Windows reads a leading dot's extension), and a name with no dot as ''.
186
227
  * "Invoice.pdf<U+034F>" shows 'pdf', so no rule completes it with a second
@@ -199,9 +240,9 @@ const INVISIBLE_CHARACTERS = /\p{Default_Ignorable_Code_Point}/gu;
199
240
  * @returns {string}
200
241
  */
201
242
  export function lastExtension(name) {
202
- const kept = trimDroppedTrailing(name.replace(INVISIBLE_CHARACTERS, ''));
203
- const dot = kept.lastIndexOf('.');
204
- return dot === -1 ? '' : kept.slice(dot + 1).toLowerCase();
243
+ const shown = nameAsShown(name);
244
+ const dot = shown.lastIndexOf('.');
245
+ return dot === -1 ? '' : shown.slice(dot + 1).toLowerCase();
205
246
  }
206
247
  /**
207
248
  * The longest prefix of `text` within `maxLength` UTF-16 units that splits no
@@ -1 +1 @@
1
- {"version":3,"file":"filename.js","sourceRoot":"","sources":["../../src/app-sdk/filename.js"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,oDAAoD;AACpD,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;GAIG;AACH,MAAM,2BAA2B,GAAG,MAAM,CAAC,GAAG,CAAA,oDAAoD,CAAC;AAEnG,2EAA2E;AAC3E,MAAM,0BAA0B,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA,OAAO,2BAA2B,GAAG,EAAE,GAAG,CAAC,CAAC;AAEpG,MAAM,yBAAyB,GAAG,IAAI,MAAM,CAAC,IAAI,2BAA2B,GAAG,EAAE,GAAG,CAAC,CAAC;AAEtF;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAI;IAC5C,OAAO,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED,6DAA6D;AAC7D,MAAM,gCAAgC,GAAG,WAAW,CAAC;AAErD,0EAA0E;AAC1E,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC7C,gBAAgB,EAAE,kBAAkB;IACpC,sBAAsB,EAAE,wBAAwB;IAChD,mBAAmB,EAAE,qBAAqB;CAC3C,CAAC,CAAC;AAEH,MAAM,mBAAmB,GAAG,UAAU,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAI;IAC1C,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,iBAAiB,CAAC,gBAAgB,CAAC;IACrF,IAAI,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,iBAAiB,CAAC,sBAAsB,CAAC;IACjG,IAAI,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,iBAAiB,CAAC,mBAAmB,CAAC;I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an
3
+ * ingot (a non-empty string, the upload id its activation stamped), or null
4
+ * for content published without one. A transfer token that records one — a
5
+ * read-modify-write replacement's base, the publication a reusable decrypt
6
+ * token serves — records exactly this, and a record holding anything else is
7
+ * malformed.
8
+ *
9
+ * @param {*} value
10
+ * @returns {boolean}
11
+ */
12
+ export function isContentVersion(value: any): boolean;
13
+ /**
14
+ * The content version an ingot row names: the upload id its activation
15
+ * stamped as `stats_activation_reference_id`, or null for a row published
16
+ * without one. It is the `content_version` Core reports and records on a
17
+ * reusable decrypt token, the strong ETag Forge serves the row's bytes under,
18
+ * and the publication a replacement conditioned on content is decided against,
19
+ * so Core and Forge read a row's publication by this one rule.
20
+ *
21
+ * @param {{ stats_activation_reference_id?: * }|null|undefined} row - An ingot row
22
+ * @returns {string|null}
23
+ */
24
+ export function ingotContentVersion(row: {
25
+ stats_activation_reference_id?: any;
26
+ } | null | undefined): string | null;
1
27
  /**
2
28
  * The ledger reference of an upload's transfer charge,
3
29
  * `forge_ingot_transfer_upload_<first 24 ISTK chars>`: every charge of one
@@ -22,8 +48,9 @@ export function uploadTransferReference(istk: string): string;
22
48
  export function uploadTokenRevocationReason(record: Object | null | undefined): string | null;
23
49
  /**
24
50
  * The upload publication contract between Forge and Core's activation, and
25
- * the facts of a transfer token both services spell: its shape, and Core's
26
- * revocation of an upload's token.
51
+ * the facts of a transfer token both services spell: its shape, the
52
+ * publication it is bound to (a content version, and the one an ingot row
53
+ * names), and Core's revocation of an upload's token.
27
54
  *
28
55
  * Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
29
56
  * and on the final state it hands Core's activation (POST
@@ -3,8 +3,9 @@
3
3
  // Regenerate with: pnpm --filter @sparkvault/sdk-mobile build
4
4
  /**
5
5
  * The upload publication contract between Forge and Core's activation, and
6
- * the facts of a transfer token both services spell: its shape, and Core's
7
- * revocation of an upload's token.
6
+ * the facts of a transfer token both services spell: its shape, the
7
+ * publication it is bound to (a content version, and the one an ingot row
8
+ * names), and Core's revocation of an upload's token.
8
9
  *
9
10
  * Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
10
11
  * and on the final state it hands Core's activation (POST
@@ -30,6 +31,35 @@ export const UPLOAD_PUBLICATION_PROTOCOL = 2;
30
31
  * the session's id.
31
32
  */
32
33
  export const UPLOAD_ID_PATTERN = /^tus_[0-9a-f]{32}$/;
34
+ /**
35
+ * Whether a value is a content version: the identity of one publication of an
36
+ * ingot (a non-empty string, the upload id its activation stamped), or null
37
+ * for content published without one. A transfer token that records one — a
38
+ * read-modify-write replacement's base, the publication a reusable decrypt
39
+ * token serves — records exactly this, and a record holding anything else is
40
+ * malformed.
41
+ *
42
+ * @param {*} value
43
+ * @returns {boolean}
44
+ */
45
+ export function isContentVersion(value) {
46
+ return value === null || (typeof value === 'string' && value.length > 0);
47
+ }
48
+ /**
49
+ * The content version an ingot row names: the upload id its activation
50
+ * stamped as `stats_activation_reference_id`, or null for a row published
51
+ * without one. It is the `content_version` Core reports and records on a
52
+ * reusable decrypt token, the strong ETag Forge serves the row's bytes under,
53
+ * and the publication a replacement conditioned on content is decided against,
54
+ * so Core and Forge read a row's publication by this one rule.
55
+ *
56
+ * @param {{ stats_activation_reference_id?: * }|null|undefined} row - An ingot row
57
+ * @returns {string|null}
58
+ */
59
+ export function ingotContentVersion(row) {
60
+ const reference = row?.stats_activation_reference_id;
61
+ return typeof reference === 'string' && reference.length > 0 ? reference : null;
62
+ }
33
63
  /** The random bytes an ISTK, the bearer token of one Forge transfer, is spelled from. */
34
64
  export const ISTK_BYTES = 32;
35
65
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"upload-publication.js","sourceRoot":"","sources":["../../src/app-sdk/upload-publication.js"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,8DAA8D;AAC9D,8DAA8D;AAE9D;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC;AAE7C;;;;;;GAMG;AACH,MAAM,CAAC,M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S;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;QACrB,iBAAiB,EAAE,oBAAoB,CAAC,iBAAiB;QACzD,aAAa,EAAE,eAAe;KAC/B,CAAC;CACH,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,CAAC,OAAO,CAAC,CAAC;AAE1E;;;;;;;GAOG;AACH,MAAM,UAAU,2BAA2B,CAAC,MAAM;IAChD,IAAI,MAAM,EAAE,MAAM,KAAK,uBAAuB,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACnE,OAAO,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3F,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC"}
@@ -25,6 +25,6 @@ export type IngotsWireContract = [
25
25
  Assert<Equals<IngotSharingConfig['link_code'], string | null>>,
26
26
  Assert<Equals<IngotSharingConfig['visibility'], 'invite_only' | 'authenticated' | 'public' | null>>,
27
27
  Assert<Equals<keyof ListIngotsResponse, 'ingots' | 'count' | 'has_more' | 'next_cursor'>>,
28
- Assert<Equals<keyof Ingot, 'ingot_id' | 'name' | 'content_type' | 'size_bytes' | 'status' | 'folder_id' | 'managed_by' | 'created_at' | 'access_count' | 'content_hmac' | 'content_version'>>
28
+ Assert<Equals<keyof Ingot, 'ingot_id' | 'name' | 'download_filename' | 'content_type' | 'size_bytes' | 'status' | 'folder_id' | 'managed_by' | 'created_at' | 'access_count' | 'content_hmac' | 'content_version'>>
29
29
  ];
30
30
  export {};
package/dist/types.d.ts CHANGED
@@ -613,6 +613,17 @@ export interface UploadConfigUpdate {
613
613
  export interface Ingot {
614
614
  ingot_id: string;
615
615
  name: string;
616
+ /**
617
+ * The name a download of the ingot saves under, as Forge names it: `name`,
618
+ * kept as it is when the first word of the extension it shows (up to an
619
+ * ASCII space, in any case) is one the MIME registry knows or holds a
620
+ * character none of the registry's extensions is spelled with, which may
621
+ * draw as one, and otherwise completed with the first extension the
622
+ * registry lists for `content_type`, never one a saved copy must never open
623
+ * as. Every ingot Core answers carries it; a row the app builds before Core
624
+ * answers (a queued upload's) has none.
625
+ */
626
+ download_filename?: string;
616
627
  content_type: string;
617
628
  size_bytes: number;
618
629
  /** `uploading` until Forge activates the upload, then `active`. */
@@ -21,6 +21,9 @@ export declare function validateFolderId(folderId: string): void;
21
21
  * can climb a directory, so a `..` inside a name is kept. On top of the rule,
22
22
  * for the device's file system: leading dots are stripped (a hidden file) and
23
23
  * Windows reserved names are prefixed. Falls back to the platform's one
24
- * fallback name (SAVED_FILENAME_FALLBACK) when nothing remains.
24
+ * fallback name (SAVED_FILENAME_FALLBACK) when nothing remains, or nothing
25
+ * but dots and spaces (storableFilenameProblem's ONLY_DOTS_OR_SPACES, which
26
+ * reads a name past its invisible characters): `. .` and `..<U+034F>` show
27
+ * nothing a device can name a file by.
25
28
  */
26
29
  export declare function sanitizeFilename(filename: string): string;
@@ -1,6 +1,6 @@
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 { FILENAME_PROBLEMS, SAVED_FILENAME_FALLBACK, storableFilenameProblem, toStorableFilename, } from './app-sdk/filename.js';
4
4
  /** Whether a value is a well-formed SparkVault resource id (the platform's one rule). */
5
5
  export { isResourceId as isSafeId };
6
6
  /**
@@ -39,7 +39,10 @@ const WINDOWS_RESERVED_NAMES = new Set([
39
39
  * can climb a directory, so a `..` inside a name is kept. On top of the rule,
40
40
  * for the device's file system: leading dots are stripped (a hidden file) and
41
41
  * Windows reserved names are prefixed. Falls back to the platform's one
42
- * fallback name (SAVED_FILENAME_FALLBACK) when nothing remains.
42
+ * fallback name (SAVED_FILENAME_FALLBACK) when nothing remains, or nothing
43
+ * but dots and spaces (storableFilenameProblem's ONLY_DOTS_OR_SPACES, which
44
+ * reads a name past its invisible characters): `. .` and `..<U+034F>` show
45
+ * nothing a device can name a file by.
43
46
  */
44
47
  export function sanitizeFilename(filename) {
45
48
  let sanitized = toStorableFilename(filename)
@@ -49,6 +52,8 @@ export function sanitizeFilename(filename) {
49
52
  if (WINDOWS_RESERVED_NAMES.has(baseName)) {
50
53
  sanitized = `_${sanitized}`;
51
54
  }
52
- return sanitized || SAVED_FILENAME_FALLBACK;
55
+ return sanitized === '' || storableFilenameProblem(sanitized) === FILENAME_PROBLEMS.ONLY_DOTS_OR_SPACES
56
+ ? SAVED_FILENAME_FALLBACK
57
+ : sanitized;
53
58
  }
54
59
  //# sourceMappingURL=validation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAEpF,yFAAyF;AACzF,OAAO,EAAE,YAAY,IAAI,QAAQ,EAAE,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc,EAAE,KAAa,EAAE,KAAa;IAC7E,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,yBAAyB,CAAC,WAAW,KAAK,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IACrF,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACrD,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,OAAe;IAC7C,kBAAkB,CAAC,OAAO,EAAE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GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACvD,IAAI,sBAAsB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzC,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO,SAAS,KAAK,EAAE,IAAI,uBAAuB,CAAC,SAAS,CAAC,KAAK,iBAAiB,CAAC,mBAAmB;QACrG,CAAC,CAAC,uBAAuB;QACzB,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkvault/sdk-mobile",
3
- "version": "7.2.2",
3
+ "version": "7.2.4",
4
4
  "description": "Mobile SDK for SparkVault Identity, vault, folder, and ingot workflows",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -51,6 +51,53 @@ export function hasControlOrBidiCharacter(text) {
51
51
  /** Characters the file systems a name is saved to refuse. */
52
52
  const NON_PORTABLE_FILENAME_CHARACTERS = /[:*?"<>|]/;
53
53
 
54
+ /**
55
+ * A character a save drops from a name's end. Windows drops trailing dots and
56
+ * spaces from a name it saves ("page.html." is saved as "page.html"); any
57
+ * other trailing white space is dropped alike, so a name never hides the
58
+ * extension a saved copy could open as.
59
+ */
60
+ const DROPPED_TRAILING_CHARACTER = /[\s.]/u;
61
+
62
+ /**
63
+ * `name` without the trailing dots and white space a save drops: "page.html."
64
+ * and "page.html " are "page.html", "notes. ." is "notes", and a name of only
65
+ * dots and white space is ''. lastExtension reads the extension in front of
66
+ * them, and Forge completes a saved name after them (./media-type-node.js
67
+ * withMediaTypeExtension: "notes." under text/plain saves as "notes.txt").
68
+ *
69
+ * @param {string} name
70
+ * @returns {string}
71
+ */
72
+ export function trimDroppedTrailing(name) {
73
+ let end = name.length;
74
+ while (end > 0 && DROPPED_TRAILING_CHARACTER.test(name[end - 1])) end -= 1;
75
+ return name.slice(0, end);
76
+ }
77
+
78
+ /**
79
+ * Invisible characters (Unicode's Default_Ignorable_Code_Point): the joiners,
80
+ * variation selectors, tags and bidirectional controls, which display as
81
+ * nothing, and the Hangul fillers, which display as blank space. None shows
82
+ * in a name, and a save keeps several (`Invoice.pdf<U+034F>` saves as itself
83
+ * in Chromium and Firefox, and shows as `Invoice.pdf`).
84
+ */
85
+ const INVISIBLE_CHARACTERS = /\p{Default_Ignorable_Code_Point}/gu;
86
+
87
+ /**
88
+ * What `name` shows once saved: the name read past its invisible characters
89
+ * (INVISIBLE_CHARACTERS), without the trailing dots and white space a save
90
+ * drops (trimDroppedTrailing). The extension a name shows is read in it
91
+ * (lastExtension), and a name it leaves nothing of is one of only dots or
92
+ * spaces (isOnlyDotsOrSpaces).
93
+ *
94
+ * @param {string} name
95
+ * @returns {string}
96
+ */
97
+ function nameAsShown(name) {
98
+ return trimDroppedTrailing(name.replace(INVISIBLE_CHARACTERS, ''));
99
+ }
100
+
54
101
  /** Why a name cannot be stored, as storableFilenameProblem reports it. */
55
102
  export const FILENAME_PROBLEMS = Object.freeze({
56
103
  UNSAFE_CHARACTER: 'unsafe_character',
@@ -58,7 +105,20 @@ export const FILENAME_PROBLEMS = Object.freeze({
58
105
  ONLY_DOTS_OR_SPACES: 'only_dots_or_spaces'
59
106
  });
60
107
 
61
- const ONLY_DOTS_OR_SPACES = /^[\s.]+$/;
108
+ /**
109
+ * Whether `name` is one of only dots or spaces: a name that is not empty yet
110
+ * shows nothing once saved (nameAsShown), every character in it a dot, white
111
+ * space or an invisible character (`...` and ` . `, and `..<U+034F>` and
112
+ * `.<U+200B>.`, which show as `..`). No such name is stored
113
+ * (storableFilenameProblem), and a file that has one saves under the
114
+ * fallback name (savedFilename).
115
+ *
116
+ * @param {string} name
117
+ * @returns {boolean}
118
+ */
119
+ function isOnlyDotsOrSpaces(name) {
120
+ return name !== '' && nameAsShown(name) === '';
121
+ }
62
122
 
63
123
  /**
64
124
  * What stops `name` from being stored as a file name, or null when nothing
@@ -70,7 +130,7 @@ const ONLY_DOTS_OR_SPACES = /^[\s.]+$/;
70
130
  export function storableFilenameProblem(name) {
71
131
  if (UNSAFE_FILENAME_CHARACTERS.test(name)) return FILENAME_PROBLEMS.UNSAFE_CHARACTER;
72
132
  if (NON_PORTABLE_FILENAME_CHARACTERS.test(name)) return FILENAME_PROBLEMS.NON_PORTABLE_CHARACTER;
73
- if (ONLY_DOTS_OR_SPACES.test(name)) return FILENAME_PROBLEMS.ONLY_DOTS_OR_SPACES;
133
+ if (isOnlyDotsOrSpaces(name)) return FILENAME_PROBLEMS.ONLY_DOTS_OR_SPACES;
74
134
  return null;
75
135
  }
76
136
 
@@ -89,13 +149,21 @@ export const SAVED_FILENAME_FALLBACK = 'download';
89
149
 
90
150
  /**
91
151
  * The name a download is saved under: the file's own name by the saved-name
92
- * rule (toSavedFilename), or SAVED_FILENAME_FALLBACK when it has none.
152
+ * rule (toSavedFilename), or SAVED_FILENAME_FALLBACK when it has none, or one
153
+ * of only dots or spaces, invisible characters among them
154
+ * (isOnlyDotsOrSpaces): such a name, completed for its type
155
+ * (./media-type-node.js downloadFilename), would be an extension alone, which
156
+ * a browser saves without its leading dots (`...` completed for a text file
157
+ * is `.txt`, which saves as `txt`, and `..<U+034F>` is `..<U+034F>.txt`,
158
+ * which saves as `<U+034F>.txt` and shows as `.txt`).
93
159
  *
94
160
  * @param {string|null|undefined} name
95
161
  * @returns {string}
96
162
  */
97
163
  export function savedFilename(name) {
98
- return typeof name === 'string' && name !== '' ? toSavedFilename(name) : SAVED_FILENAME_FALLBACK;
164
+ return typeof name === 'string' && name !== '' && !isOnlyDotsOrSpaces(name)
165
+ ? toSavedFilename(name)
166
+ : SAVED_FILENAME_FALLBACK;
99
167
  }
100
168
 
101
169
  /**
@@ -103,11 +171,18 @@ export function savedFilename(name) {
103
171
  * that cannot import an ES module (the x.sv reveal page): it declares
104
172
  * `savedFilename` and everything it reads at the script's top level, built
105
173
  * from the functions and constants above, so the page runs this rule, not a
106
- * copy. A new module-scope binding the rule reads must be added here.
174
+ * copy. A new module-scope binding the rule reads must be added here. Marked
175
+ * pure so a bundle that never reads it (the console's, the help desk portal's)
176
+ * drops it.
107
177
  */
108
- export const SAVED_FILENAME_SCRIPT = [
178
+ export const SAVED_FILENAME_SCRIPT = /* @__PURE__ */ [
109
179
  `var UNSAFE_FILENAME_CHARACTERS = ${UNSAFE_FILENAME_CHARACTERS};`,
180
+ `var DROPPED_TRAILING_CHARACTER = ${DROPPED_TRAILING_CHARACTER};`,
181
+ `var INVISIBLE_CHARACTERS = ${INVISIBLE_CHARACTERS};`,
110
182
  `var SAVED_FILENAME_FALLBACK = ${JSON.stringify(SAVED_FILENAME_FALLBACK)};`,
183
+ trimDroppedTrailing,
184
+ nameAsShown,
185
+ isOnlyDotsOrSpaces,
111
186
  toSavedFilename,
112
187
  savedFilename
113
188
  ].join('\n');
@@ -164,44 +239,11 @@ export function splitExtension(name) {
164
239
  }
165
240
 
166
241
  /**
167
- * A character a save drops from a name's end. Windows drops trailing dots and
168
- * spaces from a name it saves ("page.html." is saved as "page.html"); any
169
- * other trailing white space is dropped alike, so a name never hides the
170
- * extension a saved copy could open as.
171
- */
172
- const DROPPED_TRAILING_CHARACTER = /[\s.]/u;
173
-
174
- /**
175
- * `name` without the trailing dots and white space a save drops: "page.html."
176
- * and "page.html " are "page.html", "notes. ." is "notes", and a name of only
177
- * dots and white space is ''. lastExtension reads the extension in front of
178
- * them, and Forge completes a saved name after them (./media-type-node.js
179
- * withMediaTypeExtension: "notes." under text/plain saves as "notes.txt").
180
- *
181
- * @param {string} name
182
- * @returns {string}
183
- */
184
- export function trimDroppedTrailing(name) {
185
- let end = name.length;
186
- while (end > 0 && DROPPED_TRAILING_CHARACTER.test(name[end - 1])) end -= 1;
187
- return name.slice(0, end);
188
- }
189
-
190
- /**
191
- * Invisible characters (Unicode's Default_Ignorable_Code_Point): the joiners,
192
- * variation selectors, tags and bidirectional controls, which display as
193
- * nothing, and the Hangul fillers, which display as blank space. None shows
194
- * in a name, and a save keeps several (`Invoice.pdf<U+034F>` saves as itself
195
- * in Chromium and Firefox, and shows as `Invoice.pdf`).
196
- */
197
- const INVISIBLE_CHARACTERS = /\p{Default_Ignorable_Code_Point}/gu;
198
-
199
- /**
200
- * The extension `name` shows, lowercase and without its dot: what follows its
201
- * last dot once its invisible characters are read past and the
202
- * trailing dots and white space a save drops are trimmed
203
- * (trimDroppedTrailing). It is the extension a saved copy opens as wherever
204
- * the name holds no invisible character: "invoice.note.html" and
242
+ * The extension `name` shows, lowercase and without its dot: what follows the
243
+ * last dot of what the name shows once saved (nameAsShown: read past its
244
+ * invisible characters, without the trailing dots and white space a save
245
+ * drops). It is the extension a saved copy opens as wherever the name holds
246
+ * no invisible character: "invoice.note.html" and
205
247
  * "page.html." open as 'html', "logs.tar.gz" as 'gz', ".html" as 'html'
206
248
  * (Windows reads a leading dot's extension), and a name with no dot as ''.
207
249
  * "Invoice.pdf<U+034F>" shows 'pdf', so no rule completes it with a second
@@ -220,9 +262,9 @@ const INVISIBLE_CHARACTERS = /\p{Default_Ignorable_Code_Point}/gu;
220
262
  * @returns {string}
221
263
  */
222
264
  export function lastExtension(name) {
223
- const kept = trimDroppedTrailing(name.replace(INVISIBLE_CHARACTERS, ''));
224
- const dot = kept.lastIndexOf('.');
225
- return dot === -1 ? '' : kept.slice(dot + 1).toLowerCase();
265
+ const shown = nameAsShown(name);
266
+ const dot = shown.lastIndexOf('.');
267
+ return dot === -1 ? '' : shown.slice(dot + 1).toLowerCase();
226
268
  }
227
269
 
228
270
  /**
@@ -4,8 +4,9 @@
4
4
 
5
5
  /**
6
6
  * The upload publication contract between Forge and Core's activation, and
7
- * the facts of a transfer token both services spell: its shape, and Core's
8
- * revocation of an upload's token.
7
+ * the facts of a transfer token both services spell: its shape, the
8
+ * publication it is bound to (a content version, and the one an ingot row
9
+ * names), and Core's revocation of an upload's token.
9
10
  *
10
11
  * Forge stamps UPLOAD_PUBLICATION_PROTOCOL on every upload session it creates
11
12
  * and on the final state it hands Core's activation (POST
@@ -34,6 +35,37 @@ export const UPLOAD_PUBLICATION_PROTOCOL = 2;
34
35
  */
35
36
  export const UPLOAD_ID_PATTERN = /^tus_[0-9a-f]{32}$/;
36
37
 
38
+ /**
39
+ * Whether a value is a content version: the identity of one publication of an
40
+ * ingot (a non-empty string, the upload id its activation stamped), or null
41
+ * for content published without one. A transfer token that records one — a
42
+ * read-modify-write replacement's base, the publication a reusable decrypt
43
+ * token serves — records exactly this, and a record holding anything else is
44
+ * malformed.
45
+ *
46
+ * @param {*} value
47
+ * @returns {boolean}
48
+ */
49
+ export function isContentVersion(value) {
50
+ return value === null || (typeof value === 'string' && value.length > 0);
51
+ }
52
+
53
+ /**
54
+ * The content version an ingot row names: the upload id its activation
55
+ * stamped as `stats_activation_reference_id`, or null for a row published
56
+ * without one. It is the `content_version` Core reports and records on a
57
+ * reusable decrypt token, the strong ETag Forge serves the row's bytes under,
58
+ * and the publication a replacement conditioned on content is decided against,
59
+ * so Core and Forge read a row's publication by this one rule.
60
+ *
61
+ * @param {{ stats_activation_reference_id?: * }|null|undefined} row - An ingot row
62
+ * @returns {string|null}
63
+ */
64
+ export function ingotContentVersion(row) {
65
+ const reference = row?.stats_activation_reference_id;
66
+ return typeof reference === 'string' && reference.length > 0 ? reference : null;
67
+ }
68
+
37
69
  /** The random bytes an ISTK, the bearer token of one Forge transfer, is spelled from. */
38
70
  export const ISTK_BYTES = 32;
39
71
 
@@ -55,6 +55,7 @@ export type IngotsWireContract = [
55
55
  keyof Ingot,
56
56
  | 'ingot_id'
57
57
  | 'name'
58
+ | 'download_filename'
58
59
  | 'content_type'
59
60
  | 'size_bytes'
60
61
  | 'status'
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`. */
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
  }