@sparkvault/sdk-mobile 8.0.2 → 8.0.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.
package/README.md CHANGED
@@ -73,7 +73,7 @@ The SDK depends on `tweetnacl` for Ed25519 Identity JWT verification and declare
73
73
  - `folders`: Folder CRUD, lookup by path (`findByPath`), breadcrumbs, folder moves, and ingot moves.
74
74
  - `ingots`: List/search/get, URI streaming upload/replace, rename/delete/move, sharing, read-only audit logs, SDK-managed file downloads, and the discrete `createUpload` (Forge upload URL + token) / `createDownloadLink` primitives.
75
75
  - `health`: Root API availability checks.
76
- - `sparks`: SparkSync ephemeral secrets — list/get/create/delete and SparkLink sharing (`share`/`getShare`/`unshare`, and `resendInvite` for an invite-only link's invitation).
76
+ - `sparks`: SparkSync ephemeral secrets — list/get/create/delete (a link spark, `contentType` `text/uri-list`, is created and listed with its x.sv link, `link_url`, and a read answers the name its payload saves under, `download_filename`) and SparkLink sharing (`share`/`getShare`/`unshare`, and `resendInvite` for an invite-only link's invitation).
77
77
  - `entropy`: HSM-backed entropy generation (`generate`, `generateBytes`), and `drawFirstParty` for the signed-in app's own working values (`POST /v1/entropy/first-party`: a SparkVault session's draw, never plan- or bandwidth-gated or recorded as the account's usage).
78
78
  - `notify`: The signed-in user's metadata-only notifications inbox (`getInbox`, `getUnreadCount`, `markState`, `markAllState`, `markAllRead`) and Expo device push registration (`registerDevice`, `unregisterDeviceToken`, `unregisterDevice`).
79
79
  - `billing`: Subscription status and usage, and native in-app purchase receipt validation.
package/dist/sparks.d.ts CHANGED
@@ -3,8 +3,21 @@ import type { ResendSparkInviteResponse, ShareSparkResponse, SparkShareStatus, U
3
3
  /** A Spark as GET /sparks lists it: never its payload, which only `get` reads. */
4
4
  export interface Spark {
5
5
  spark_id: string;
6
- status: string;
7
- content_type?: string;
6
+ account_id: string;
7
+ content_type: string;
8
+ size_bytes: number;
9
+ /** `ash` once read or recalled, `expired` past its TTL, `deleted` once its owner deleted it. */
10
+ status: 'active' | 'ash' | 'expired' | 'deleted';
11
+ created_at: number;
12
+ expires_at: number;
13
+ /** When it was read or recalled; null while unread, and for a deleted Spark. */
14
+ burned_at: number | null;
15
+ /** Seconds left before it expires, 0 once it has. */
16
+ time_remaining: number;
17
+ filename?: string;
18
+ kindling?: string;
19
+ /** A link spark (content_type text/uri-list) only: its x.sv link. */
20
+ link_url?: string;
8
21
  }
9
22
  export interface ListSparksOptions {
10
23
  kindling?: string;
@@ -15,11 +28,25 @@ export interface ListSparksResponse {
15
28
  sparks: Spark[];
16
29
  next_cursor?: string;
17
30
  }
31
+ /** A Spark as GET /sparks/:id reads it: reading a read-once Spark burns it. */
18
32
  export interface SparkResponse {
19
33
  spark_id: string;
20
34
  payload: string;
21
- content_type?: string;
22
- status?: string;
35
+ content_type: string;
36
+ /**
37
+ * The name the payload saves under, as Core completes it from the MIME
38
+ * registry, which no client carries: `filename` with its type's extension
39
+ * when it shows none, or the one fallback name for a Spark with none.
40
+ */
41
+ download_filename: string;
42
+ size_bytes: number;
43
+ /** `ash` once this read burned it; `active` when the read left it readable. */
44
+ status: 'active' | 'ash';
45
+ created_at: number;
46
+ /** The burn this read made; null when the read left the Spark readable. */
47
+ burned_at: number | null;
48
+ was_active: true;
49
+ filename?: string;
23
50
  }
24
51
  export interface CreateSparkOptions {
25
52
  payload: string;
@@ -33,6 +60,22 @@ export interface CreateSparkOptions {
33
60
  }
34
61
  export interface CreateSparkResponse {
35
62
  spark_id: string;
63
+ size_bytes: number;
64
+ status: 'active';
65
+ created_at: number;
66
+ expires_at: number;
67
+ ttl_minutes: number;
68
+ /** The filename as the Spark stores it, when it has one. */
69
+ filename?: string;
70
+ kindling?: string;
71
+ /**
72
+ * A link spark (contentType text/uri-list, the payload its destination URL)
73
+ * only: its x.sv link, minted with the Spark, which opens once and goes on
74
+ * to the payload's URL.
75
+ */
76
+ link_url?: string;
77
+ /** A link spark only: the code in `link_url`. */
78
+ link_code?: string;
36
79
  }
37
80
  export interface ShareSparkOptions {
38
81
  /** Link visibility. Defaults to public server-side. */
@@ -47,6 +90,7 @@ export declare class MobileSparksClient {
47
90
  constructor(http: MobileHttpClient);
48
91
  list(options?: ListSparksOptions): Promise<ListSparksResponse>;
49
92
  get(sparkId: string): Promise<SparkResponse>;
93
+ /** Create a Spark. A link spark (contentType text/uri-list) is answered with its x.sv link, `link_url`. */
50
94
  create(options: CreateSparkOptions): Promise<CreateSparkResponse>;
51
95
  /** Burn a spark before its natural expiry. An already-burned spark resolves (the server returns 204); a missing spark rejects with a 404. */
52
96
  delete(sparkId: string): Promise<void>;
package/dist/sparks.js CHANGED
@@ -15,6 +15,7 @@ export class MobileSparksClient {
15
15
  const response = await this.http.get(apiPath `/sparks/${sparkId}`);
16
16
  return response.data;
17
17
  }
18
+ /** Create a Spark. A link spark (contentType text/uri-list) is answered with its x.sv link, `link_url`. */
18
19
  async create(options) {
19
20
  const response = await this.http.post(apiPath `/sparks`, {
20
21
  payload: options.payload,
@@ -1 +1 @@
1
- {"version":3,"file":"sparks.js","sourceRoot":"","sources":["../src/sparks.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAmDrD,MAAM,OAAO,kBAAkB;IAG7B,YAAY,IAAsB;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,UAA6B,EAAE;QACxC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAqB,OAAO,CAAA,SAAS,EAAE;YACzE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE;SACjG,CAAC,CAAC;QACH,OAAO,QAAQ,CAAC,IAAI,C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AAC,OAAe;QAC3B,kBAAkB,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CACrC,OAAO,CAAA,WAAW,OAAO,QAAQ,CAClC,CAAC;QACF,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Spark wire-contract assertions: COMPILE-TIME ONLY.
3
+ *
4
+ * The sparks client returns each response body as it arrives, so a unit test
5
+ * can never catch these types drifting from the server and every assertion
6
+ * would pass. `tsc --noEmit` (`pnpm typecheck`) is the gate instead. It is
7
+ * deliberately NOT a `*.test.ts`, which tsconfig excludes.
8
+ *
9
+ * Mirrored server sources: apps/api/src/sparks/create.js (`createSpark`: a
10
+ * link spark, content_type text/uri-list, answers its minted x.sv `link_url`
11
+ * and `link_code` beside the spark), apps/api/src/sparks/list.js (each listed
12
+ * spark, a link spark's `link_url` included) and apps/api/src/sparks/readCore.js
13
+ * (`buildReadResponse`: the payload and the name it saves under,
14
+ * `download_filename`). A field the server sends that a type leaves out is
15
+ * one a typed caller cannot reach: a link spark's caller has no link to send.
16
+ */
17
+ import type { CreateSparkResponse, Spark, SparkResponse } from './sparks.js';
18
+ /** Fails to compile unless `T` resolves to exactly `true`. */
19
+ type Assert<T extends true> = T;
20
+ /** Invariant type equality: the SAME type, not merely mutually assignable. */
21
+ type Equals<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false;
22
+ export type SparksWireContract = [
23
+ Assert<Equals<keyof CreateSparkResponse, 'spark_id' | 'size_bytes' | 'status' | 'created_at' | 'expires_at' | 'ttl_minutes' | 'filename' | 'kindling' | 'link_url' | 'link_code'>>,
24
+ Assert<Equals<CreateSparkResponse['link_url'], string | undefined>>,
25
+ Assert<Equals<CreateSparkResponse['link_code'], string | undefined>>,
26
+ Assert<Equals<keyof Spark, 'spark_id' | 'account_id' | 'content_type' | 'size_bytes' | 'status' | 'created_at' | 'expires_at' | 'burned_at' | 'time_remaining' | 'filename' | 'kindling' | 'link_url'>>,
27
+ Assert<Equals<Spark['link_url'], string | undefined>>,
28
+ Assert<Equals<Spark['status'], 'active' | 'ash' | 'expired' | 'deleted'>>,
29
+ Assert<Equals<Spark['burned_at'], number | null>>,
30
+ Assert<Equals<keyof SparkResponse, 'spark_id' | 'payload' | 'content_type' | 'download_filename' | 'size_bytes' | 'status' | 'created_at' | 'burned_at' | 'was_active' | 'filename'>>,
31
+ Assert<Equals<SparkResponse['download_filename'], string>>,
32
+ Assert<Equals<SparkResponse['status'], 'active' | 'ash'>>,
33
+ Assert<Equals<SparkResponse['burned_at'], number | null>>
34
+ ];
35
+ export {};
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Spark wire-contract assertions: COMPILE-TIME ONLY.
3
+ *
4
+ * The sparks client returns each response body as it arrives, so a unit test
5
+ * can never catch these types drifting from the server and every assertion
6
+ * would pass. `tsc --noEmit` (`pnpm typecheck`) is the gate instead. It is
7
+ * deliberately NOT a `*.test.ts`, which tsconfig excludes.
8
+ *
9
+ * Mirrored server sources: apps/api/src/sparks/create.js (`createSpark`: a
10
+ * link spark, content_type text/uri-list, answers its minted x.sv `link_url`
11
+ * and `link_code` beside the spark), apps/api/src/sparks/list.js (each listed
12
+ * spark, a link spark's `link_url` included) and apps/api/src/sparks/readCore.js
13
+ * (`buildReadResponse`: the payload and the name it saves under,
14
+ * `download_filename`). A field the server sends that a type leaves out is
15
+ * one a typed caller cannot reach: a link spark's caller has no link to send.
16
+ */
17
+ export {};
18
+ //# sourceMappingURL=sparks.test-d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparks.test-d.js","sourceRoot":"","sources":["../src/sparks.test-d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
package/dist/types.d.ts CHANGED
@@ -618,10 +618,12 @@ export interface Ingot {
618
618
  * kept as it is when the first word of the extension it shows (up to an
619
619
  * ASCII space, in any case) is one the MIME registry knows or holds a
620
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.
621
+ * draw as one, and otherwise completed with the extension `content_type`'s
622
+ * files are named with (the first the registry lists for it, or, for the
623
+ * few types whose first is not the one desktops name their files with, the
624
+ * one they do: `.mp3` for `audio/mpeg`, `.mov` for `video/quicktime`), never
625
+ * one a saved copy must never open as. Every ingot Core answers carries it;
626
+ * a row the app builds before Core answers (a queued upload's) has none.
625
627
  */
626
628
  download_filename?: string;
627
629
  content_type: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkvault/sdk-mobile",
3
- "version": "8.0.2",
3
+ "version": "8.0.4",
4
4
  "description": "Mobile SDK for SparkVault Identity, vault, folder, and ingot workflows",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Spark wire-contract assertions: COMPILE-TIME ONLY.
3
+ *
4
+ * The sparks client returns each response body as it arrives, so a unit test
5
+ * can never catch these types drifting from the server and every assertion
6
+ * would pass. `tsc --noEmit` (`pnpm typecheck`) is the gate instead. It is
7
+ * deliberately NOT a `*.test.ts`, which tsconfig excludes.
8
+ *
9
+ * Mirrored server sources: apps/api/src/sparks/create.js (`createSpark`: a
10
+ * link spark, content_type text/uri-list, answers its minted x.sv `link_url`
11
+ * and `link_code` beside the spark), apps/api/src/sparks/list.js (each listed
12
+ * spark, a link spark's `link_url` included) and apps/api/src/sparks/readCore.js
13
+ * (`buildReadResponse`: the payload and the name it saves under,
14
+ * `download_filename`). A field the server sends that a type leaves out is
15
+ * one a typed caller cannot reach: a link spark's caller has no link to send.
16
+ */
17
+
18
+ import type { CreateSparkResponse, Spark, SparkResponse } from './sparks.js';
19
+
20
+ /** Fails to compile unless `T` resolves to exactly `true`. */
21
+ type Assert<T extends true> = T;
22
+
23
+ /** Invariant type equality: the SAME type, not merely mutually assignable. */
24
+ type Equals<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2
25
+ ? true
26
+ : false;
27
+
28
+ export type SparksWireContract = [
29
+ // Exactly the fields createSpark answers.
30
+ Assert<
31
+ Equals<
32
+ keyof CreateSparkResponse,
33
+ | 'spark_id'
34
+ | 'size_bytes'
35
+ | 'status'
36
+ | 'created_at'
37
+ | 'expires_at'
38
+ | 'ttl_minutes'
39
+ | 'filename'
40
+ | 'kindling'
41
+ | 'link_url'
42
+ | 'link_code'
43
+ >
44
+ >,
45
+ // A link spark alone carries its x.sv link and the code in it.
46
+ Assert<Equals<CreateSparkResponse['link_url'], string | undefined>>,
47
+ Assert<Equals<CreateSparkResponse['link_code'], string | undefined>>,
48
+ // Exactly the fields the list answers for each spark, never its payload.
49
+ Assert<
50
+ Equals<
51
+ keyof Spark,
52
+ | 'spark_id'
53
+ | 'account_id'
54
+ | 'content_type'
55
+ | 'size_bytes'
56
+ | 'status'
57
+ | 'created_at'
58
+ | 'expires_at'
59
+ | 'burned_at'
60
+ | 'time_remaining'
61
+ | 'filename'
62
+ | 'kindling'
63
+ | 'link_url'
64
+ >
65
+ >,
66
+ Assert<Equals<Spark['link_url'], string | undefined>>,
67
+ Assert<Equals<Spark['status'], 'active' | 'ash' | 'expired' | 'deleted'>>,
68
+ Assert<Equals<Spark['burned_at'], number | null>>,
69
+ // Exactly the fields a read answers: the payload, and the name it saves under.
70
+ Assert<
71
+ Equals<
72
+ keyof SparkResponse,
73
+ | 'spark_id'
74
+ | 'payload'
75
+ | 'content_type'
76
+ | 'download_filename'
77
+ | 'size_bytes'
78
+ | 'status'
79
+ | 'created_at'
80
+ | 'burned_at'
81
+ | 'was_active'
82
+ | 'filename'
83
+ >
84
+ >,
85
+ Assert<Equals<SparkResponse['download_filename'], string>>,
86
+ Assert<Equals<SparkResponse['status'], 'active' | 'ash'>>,
87
+ Assert<Equals<SparkResponse['burned_at'], number | null>>,
88
+ ];
package/src/sparks.ts CHANGED
@@ -11,8 +11,21 @@ import { validateResourceId } from './validation.js';
11
11
  /** A Spark as GET /sparks lists it: never its payload, which only `get` reads. */
12
12
  export interface Spark {
13
13
  spark_id: string;
14
- status: string;
15
- content_type?: string;
14
+ account_id: string;
15
+ content_type: string;
16
+ size_bytes: number;
17
+ /** `ash` once read or recalled, `expired` past its TTL, `deleted` once its owner deleted it. */
18
+ status: 'active' | 'ash' | 'expired' | 'deleted';
19
+ created_at: number;
20
+ expires_at: number;
21
+ /** When it was read or recalled; null while unread, and for a deleted Spark. */
22
+ burned_at: number | null;
23
+ /** Seconds left before it expires, 0 once it has. */
24
+ time_remaining: number;
25
+ filename?: string;
26
+ kindling?: string;
27
+ /** A link spark (content_type text/uri-list) only: its x.sv link. */
28
+ link_url?: string;
16
29
  }
17
30
 
18
31
  export interface ListSparksOptions {
@@ -26,11 +39,25 @@ export interface ListSparksResponse {
26
39
  next_cursor?: string;
27
40
  }
28
41
 
42
+ /** A Spark as GET /sparks/:id reads it: reading a read-once Spark burns it. */
29
43
  export interface SparkResponse {
30
44
  spark_id: string;
31
45
  payload: string;
32
- content_type?: string;
33
- status?: string;
46
+ content_type: string;
47
+ /**
48
+ * The name the payload saves under, as Core completes it from the MIME
49
+ * registry, which no client carries: `filename` with its type's extension
50
+ * when it shows none, or the one fallback name for a Spark with none.
51
+ */
52
+ download_filename: string;
53
+ size_bytes: number;
54
+ /** `ash` once this read burned it; `active` when the read left it readable. */
55
+ status: 'active' | 'ash';
56
+ created_at: number;
57
+ /** The burn this read made; null when the read left the Spark readable. */
58
+ burned_at: number | null;
59
+ was_active: true;
60
+ filename?: string;
34
61
  }
35
62
 
36
63
  export interface CreateSparkOptions {
@@ -46,6 +73,22 @@ export interface CreateSparkOptions {
46
73
 
47
74
  export interface CreateSparkResponse {
48
75
  spark_id: string;
76
+ size_bytes: number;
77
+ status: 'active';
78
+ created_at: number;
79
+ expires_at: number;
80
+ ttl_minutes: number;
81
+ /** The filename as the Spark stores it, when it has one. */
82
+ filename?: string;
83
+ kindling?: string;
84
+ /**
85
+ * A link spark (contentType text/uri-list, the payload its destination URL)
86
+ * only: its x.sv link, minted with the Spark, which opens once and goes on
87
+ * to the payload's URL.
88
+ */
89
+ link_url?: string;
90
+ /** A link spark only: the code in `link_url`. */
91
+ link_code?: string;
49
92
  }
50
93
 
51
94
  export interface ShareSparkOptions {
@@ -77,6 +120,7 @@ export class MobileSparksClient {
77
120
  return response.data;
78
121
  }
79
122
 
123
+ /** Create a Spark. A link spark (contentType text/uri-list) is answered with its x.sv link, `link_url`. */
80
124
  async create(options: CreateSparkOptions): Promise<CreateSparkResponse> {
81
125
  const response = await this.http.post<CreateSparkResponse>(apiPath`/sparks`, {
82
126
  payload: options.payload,
package/src/types.ts CHANGED
@@ -699,10 +699,12 @@ export interface Ingot {
699
699
  * kept as it is when the first word of the extension it shows (up to an
700
700
  * ASCII space, in any case) is one the MIME registry knows or holds a
701
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.
702
+ * draw as one, and otherwise completed with the extension `content_type`'s
703
+ * files are named with (the first the registry lists for it, or, for the
704
+ * few types whose first is not the one desktops name their files with, the
705
+ * one they do: `.mp3` for `audio/mpeg`, `.mov` for `video/quicktime`), never
706
+ * one a saved copy must never open as. Every ingot Core answers carries it;
707
+ * a row the app builds before Core answers (a queued upload's) has none.
706
708
  */
707
709
  download_filename?: string;
708
710
  content_type: string;