@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/dist/app-sdk/filename.d.ts +26 -18
- package/dist/app-sdk/filename.js +86 -45
- package/dist/app-sdk/filename.js.map +1 -1
- package/dist/app-sdk/transfer-retry.d.ts +25 -20
- package/dist/app-sdk/transfer-retry.js +62 -32
- package/dist/app-sdk/transfer-retry.js.map +1 -1
- package/dist/app-sdk/upload-publication.d.ts +31 -5
- package/dist/app-sdk/upload-publication.js +31 -5
- package/dist/app-sdk/upload-publication.js.map +1 -1
- package/dist/errors.d.ts +18 -7
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -1
- package/dist/ingots.test-d.d.ts +1 -1
- package/dist/tus.d.ts +25 -19
- package/dist/tus.js +39 -26
- package/dist/tus.js.map +1 -1
- package/dist/types.d.ts +13 -2
- package/dist/validation.d.ts +4 -1
- package/dist/validation.js +8 -3
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
- package/src/app-sdk/filename.js +89 -47
- package/src/app-sdk/transfer-retry.js +63 -31
- package/src/app-sdk/upload-publication.js +34 -5
- package/src/errors.ts +19 -7
- package/src/ingots.test-d.ts +1 -0
- package/src/tus.ts +45 -26
- package/src/types.ts +13 -2
- package/src/validation.ts +13 -3
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
|
|
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 {
|
|
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 ||
|
|
69
|
+
return sanitized === '' || storableFilenameProblem(sanitized) === FILENAME_PROBLEMS.ONLY_DOTS_OR_SPACES
|
|
70
|
+
? SAVED_FILENAME_FALLBACK
|
|
71
|
+
: sanitized;
|
|
62
72
|
}
|