@sparkvault/sdk-js 13.4.0 → 14.1.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
@@ -113,6 +113,8 @@ interface RequestOptions {
113
113
  /** The unsealed vault's Vault Access Token, sent as `X-Vault-Access-Token`. */
114
114
  vat?: string;
115
115
  timeout?: number;
116
+ /** Override browser cookie behavior for a credential-isolated product surface. */
117
+ credentials?: 'omit' | 'same-origin' | 'include';
116
118
  }
117
119
  /** A successful answer: its `data`, unwrapped from the `{ data, meta }` envelope. */
118
120
  interface ApiResponse<T = unknown> {
@@ -1044,9 +1046,60 @@ interface UpdateVaultUploadOptions {
1044
1046
  * | `email` | Goes out from your organization's own sender (`getEmailSender`) |
1045
1047
  * | `push`, `web_push` | Reach the devices an active member of your organization, addressed by their SparkVault user id (`usr_*`), registered with SparkVault (its phone app and browser push), titled with your organization's name first; dropped from the ladder of a recipient with none |
1046
1048
  * | `sms`, `voice`, `whatsapp`, `rcs` | Refused 403 `NOTIFY_CHANNEL_NOT_AVAILABLE`: Notify delivers no text, call or chat message |
1047
- * | `webhook`, `slack`, `teams` | Refused 403 `NOTIFY_CHANNEL_NOT_AVAILABLE`: SparkVault's own destinations only |
1049
+ *
1050
+ * A send's posts to your organization's own webhook, Slack channel or Teams
1051
+ * workflow are no channel: they are its destinations (`NotifyConfig['destinations']`).
1052
+ */
1053
+ type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs';
1054
+ /**
1055
+ * The kinds of send-level destination your organization's Notify config names,
1056
+ * at most one of each, in the order every reader lists them: a webhook of your
1057
+ * own, a Slack channel (through your organization's SparkVault Slack app) and a
1058
+ * Microsoft Teams workflow. Each receives one post of every send whose category
1059
+ * it lists, never one per recipient, and never a `security` send.
1060
+ */
1061
+ type NotifyDestinationKind = 'webhook' | 'slack' | 'teams';
1062
+ /**
1063
+ * One of a send's destinations, as its status and its history summary report it.
1064
+ *
1065
+ * - `pending` — the post has not settled yet (it is queued, or waits to be tried again).
1066
+ * - `delivered` — the destination accepted the post.
1067
+ * - `skipped` — nothing was posted, and trying again would not post it.
1068
+ * - `failed` — the post was given up on.
1069
+ * - `recalled` — the whole send was recalled before the post settled.
1070
+ * - `unknown` — the send's delivery record is gone (past its history horizon).
1071
+ */
1072
+ type NotifyDestinationState = 'pending' | 'delivered' | 'skipped' | 'failed' | 'recalled' | 'unknown';
1073
+ /**
1074
+ * Why a destination's post was skipped: the sending account was suspended or
1075
+ * is being deleted (`account_inactive`), the destination was removed
1076
+ * (`destination_removed`) or stopped listing the send's category
1077
+ * (`destination_unrouted`) before the post went out, its URL no longer
1078
+ * resolves to a public host (`unsafe_url`) or answered with a redirect, which
1079
+ * is never followed (`redirect_refused`), or Slack's own reasons: no
1080
+ * SparkVault Slack app is installed (`slack_not_installed`), it needs an
1081
+ * admin's Refresh Connection (`slack_reauthorization_required`), the channel
1082
+ * is gone (`channel_not_found`) or archived (`is_archived`), the app was
1083
+ * removed from it (`not_in_channel`: saving the destination again adds it back
1084
+ * to a public channel), the notification has no visible title or sender name
1085
+ * (`display_not_shown`), or Slack refused it with a code of no fixed form
1086
+ * (`rejected_unrecognized`).
1048
1087
  */
1049
- type NotifyChannel = 'in_app' | 'email' | 'sms' | 'push' | 'web_push' | 'voice' | 'whatsapp' | 'rcs' | 'webhook' | 'slack' | 'teams';
1088
+ type NotifyDestinationSkipReason = 'account_inactive' | 'destination_removed' | 'destination_unrouted' | 'unsafe_url' | 'redirect_refused' | 'slack_not_installed' | 'slack_reauthorization_required' | 'channel_not_found' | 'is_archived' | 'not_in_channel' | 'display_not_shown' | 'rejected_unrecognized';
1089
+ /**
1090
+ * Why a destination's post failed: it was sent and its answer was lost, so it
1091
+ * may have landed and is never tried again, since that could post it twice
1092
+ * (`possibly_delivered`), or every attempt met a fault that may clear, and
1093
+ * none was left (`attempts_exhausted`).
1094
+ */
1095
+ type NotifyDestinationFailureReason = 'possibly_delivered' | 'attempts_exhausted';
1096
+ /**
1097
+ * The `reason` beside a skipped or failed destination: a fixed reason, the
1098
+ * HTTP status a webhook or Teams workflow refused the post with
1099
+ * (`status_404`), or the error code Slack refused it with
1100
+ * (`rejected_restricted_action`).
1101
+ */
1102
+ type NotifyDestinationReason = NotifyDestinationSkipReason | NotifyDestinationFailureReason | `status_${number}` | `rejected_${string}`;
1050
1103
  /**
1051
1104
  * How a send's content reaches the recipient.
1052
1105
  * - `sealed` (default): content is sealed into a Spark behind a single-use
@@ -1617,6 +1670,27 @@ interface NotifySendStatus {
1617
1670
  type: string | null;
1618
1671
  recipients: NotifySendStatusRecipient[];
1619
1672
  counts: NotifySendStatusCounts;
1673
+ /**
1674
+ * Each of your organization's destinations the send was routed to when it
1675
+ * was accepted, in `NotifyDestinationKind` order; empty when none was.
1676
+ * Reported beside the recipients, never part of them: `status` and `counts`
1677
+ * are the recipients' alone.
1678
+ */
1679
+ destinations: NotifySendStatusDestination[];
1680
+ }
1681
+ /** One of a send status's `destinations`. */
1682
+ interface NotifySendStatusDestination {
1683
+ kind: NotifyDestinationKind;
1684
+ state: NotifyDestinationState;
1685
+ /** Epoch seconds the state was recorded; null for a post no attempt has recorded anything for yet. */
1686
+ at: number | null;
1687
+ /** Beside a `skipped` or `failed` state; null otherwise. */
1688
+ reason: NotifyDestinationReason | null;
1689
+ /**
1690
+ * Where the post went: the webhook's host, the Slack channel id, or the
1691
+ * Teams workflow's host. Null when no attempt recorded one.
1692
+ */
1693
+ target: string | null;
1620
1694
  }
1621
1695
  /**
1622
1696
  * A send's delivery state, DERIVED from its counters — the send row itself is
@@ -1689,6 +1763,18 @@ interface NotifySendSummary {
1689
1763
  */
1690
1764
  recalled_at: number | null;
1691
1765
  state: NotifySendState;
1766
+ /**
1767
+ * The state of each of your organization's destinations the send was routed
1768
+ * to, in `NotifyDestinationKind` order (empty when none was), as
1769
+ * `getSendStatus` reports it; null when the send's delivery record is gone
1770
+ * (`state: 'unknown'`).
1771
+ */
1772
+ destinations: NotifySendSummaryDestination[] | null;
1773
+ }
1774
+ /** One of a send-history summary's `destinations`. */
1775
+ interface NotifySendSummaryDestination {
1776
+ kind: NotifyDestinationKind;
1777
+ state: NotifyDestinationState;
1692
1778
  }
1693
1779
  interface ListNotifySendsOptions {
1694
1780
  /** Page size, 1-100 (server default 50). */
@@ -1896,14 +1982,22 @@ interface NotifyConfigSecurity {
1896
1982
  *
1897
1983
  * Both fields are required before anything is sent: an unsigned event is not
1898
1984
  * offered. `webhook_url` must be https on a public host (loopback, private,
1899
- * link-local, and CGNAT addresses are rejected server-side).
1985
+ * link-local, and CGNAT addresses are rejected server-side). A patch names only
1986
+ * what it changes, but a `webhook_url` on another host or port than the
1987
+ * stored one needs a new `secret` in the same patch (400 `VALIDATION_ERROR`
1988
+ * naming `events.secret`, `details.missing: ['secret']`): a secret never
1989
+ * follows its URL to a different host.
1900
1990
  *
1901
1991
  * Delivery is BEST EFFORT — one retry, then the event is dropped. Polling
1902
1992
  * (`listSends`, `getSendStatus`, `listReceipts`) remains the source of truth;
1903
1993
  * the webhook exists to make that poll rare, not to replace it.
1904
1994
  */
1905
1995
  interface NotifyConfigEvents {
1906
- /** https only, ≤2048 chars. */
1996
+ /**
1997
+ * https only, ≤2048 chars. WRITE-ONLY: a config read reports
1998
+ * `webhook_url_set` and `webhook_url_host` instead, since a catch hook's URL
1999
+ * carries its own token.
2000
+ */
1907
2001
  webhook_url?: string;
1908
2002
  /**
1909
2003
  * HMAC-SHA256 signing secret, 16-256 chars. Sent as the hex digest of the raw
@@ -1912,12 +2006,101 @@ interface NotifyConfigEvents {
1912
2006
  */
1913
2007
  secret?: string;
1914
2008
  }
1915
- /** `events` as it comes BACK from a read — the secret is never echoed. */
2009
+ /** `events` as it comes BACK from a read — neither the URL nor the secret is ever echoed. */
1916
2010
  interface NotifyConfigEventsRead {
1917
- webhook_url?: string;
2011
+ /** Whether an event webhook URL is stored. The URL itself is never returned. */
2012
+ webhook_url_set?: boolean;
2013
+ /** The stored event webhook URL's host, so an editor can say where events go. */
2014
+ webhook_url_host?: string;
1918
2015
  /** Whether a signing secret is stored. The secret itself is never returned. */
1919
2016
  secret_set?: boolean;
1920
2017
  }
2018
+ /**
2019
+ * Your own HTTPS endpoint as a destination. Each routed send is POSTed to `url`
2020
+ * once as JSON, signed like the event webhook (the hex HMAC-SHA256 of the raw
2021
+ * body under `secret`, in `X-SparkVault-Signature`); a post that may not have
2022
+ * landed is tried again with the same `delivery_id`, so drop a repeat you
2023
+ * already received. A redirect is never followed.
2024
+ */
2025
+ interface NotifyWebhookDestination {
2026
+ /**
2027
+ * https only on a public host, ≤2048 chars. WRITE-ONLY: a read reports
2028
+ * `url_set` and `url_host` instead, since a catch hook's URL carries its own
2029
+ * token.
2030
+ */
2031
+ url: string;
2032
+ /** Signing secret, 16-256 chars. WRITE-ONLY: a read reports `secret_set` instead. */
2033
+ secret: string;
2034
+ /**
2035
+ * The categories whose sends it receives one post of: 1-50, each once, each a
2036
+ * category a send can carry, never `security` (a person's security notices go
2037
+ * only to that person). A refused one is a 400 naming it in `details.category`.
2038
+ */
2039
+ categories: string[];
2040
+ }
2041
+ /** The webhook destination as a read returns it: neither its URL nor its secret is ever echoed. */
2042
+ interface NotifyWebhookDestinationRead {
2043
+ /** Whether an endpoint URL is stored. The URL itself is never returned. */
2044
+ url_set: boolean;
2045
+ /** The stored endpoint URL's host, so an editor can say which endpoint it is. */
2046
+ url_host: string;
2047
+ /** Whether a signing secret is stored. The secret itself is never returned. */
2048
+ secret_set: boolean;
2049
+ categories: string[];
2050
+ }
2051
+ /**
2052
+ * A channel in your organization's Slack workspace as a destination, posted to
2053
+ * through its SparkVault Slack app installation. A save naming `channel_id`
2054
+ * (even the one already saved) prepares the channel first: the app reads it and
2055
+ * joins a public one it is not in, and a private channel needs the app invited
2056
+ * first. A channel the app cannot post in is refused 400 with `details.reason`
2057
+ * naming why, and nothing is stored.
2058
+ */
2059
+ interface NotifySlackDestination {
2060
+ /** The channel's Slack id, as the console's channel picker lists it. */
2061
+ channel_id: string;
2062
+ /** As `NotifyWebhookDestination['categories']`. */
2063
+ categories: string[];
2064
+ }
2065
+ /** A Microsoft Teams workflow as a destination, posted to through its webhook URL. */
2066
+ interface NotifyTeamsDestination {
2067
+ /**
2068
+ * https only on a public host, ≤2048 chars. The URL is itself the credential
2069
+ * that posts to the channel. WRITE-ONLY: a read reports `webhook_url_set`
2070
+ * and `webhook_url_host` instead.
2071
+ */
2072
+ webhook_url: string;
2073
+ /** As `NotifyWebhookDestination['categories']`. */
2074
+ categories: string[];
2075
+ }
2076
+ /** The Teams destination as a read returns it: the workflow URL is never echoed. */
2077
+ interface NotifyTeamsDestinationRead {
2078
+ /** Whether a workflow URL is stored. */
2079
+ webhook_url_set: boolean;
2080
+ /** The stored workflow URL's host, so an editor can say which workflow it is. */
2081
+ webhook_url_host: string;
2082
+ categories: string[];
2083
+ }
2084
+ /** The destinations a config read returns, each present only once configured. */
2085
+ interface NotifyConfigDestinations {
2086
+ webhook?: NotifyWebhookDestinationRead;
2087
+ slack?: NotifySlackDestination;
2088
+ teams?: NotifyTeamsDestinationRead;
2089
+ }
2090
+ /**
2091
+ * A patch of the destinations: null removes the destination of its kind; an
2092
+ * object creates it, naming every field, or patches the one stored, naming
2093
+ * only what it changes (a credential it leaves out stays as stored). A webhook
2094
+ * `url` on another host or port than the stored one needs a new `secret` in
2095
+ * the same patch (400 `VALIDATION_ERROR` naming
2096
+ * `destinations.webhook.secret`, `details.missing: ['secret']`): a secret
2097
+ * never follows its URL to a different host.
2098
+ */
2099
+ interface NotifyConfigDestinationsPatch {
2100
+ webhook?: Partial<NotifyWebhookDestination> | null;
2101
+ slack?: Partial<NotifySlackDestination> | null;
2102
+ teams?: Partial<NotifyTeamsDestination> | null;
2103
+ }
1921
2104
  /** The account's effective config: secure defaults deep-merged with its overrides. */
1922
2105
  interface NotifyConfig {
1923
2106
  delivery: NotifyConfigDelivery;
@@ -1935,6 +2118,8 @@ interface NotifyConfig {
1935
2118
  email: {
1936
2119
  sending_domain: string | null;
1937
2120
  };
2121
+ /** Your organization's send-level destinations; empty until an admin configures one. */
2122
+ destinations: NotifyConfigDestinations;
1938
2123
  /** Tombstoned entries are already dropped — a deleted category is simply gone. */
1939
2124
  categories: Record<string, NotifyConfigCategory>;
1940
2125
  }
@@ -1973,15 +2158,21 @@ interface NotifyConfigPatch {
1973
2158
  email?: {
1974
2159
  sending_domain?: string | null;
1975
2160
  };
2161
+ /** Admin only. */
2162
+ destinations?: NotifyConfigDestinationsPatch;
1976
2163
  categories?: Record<string, NotifyConfigCategory | null>;
1977
2164
  }
1978
2165
  /**
1979
2166
  * The stored override delta, seeded-category tombstones included, because that is
1980
- * what a write merges onto. One value is held back: `events.secret` comes back as
1981
- * `secret_set`, never the secret — a patch never has to resend it.
2167
+ * what a write merges onto. The credentials are held back: `events.secret` and
2168
+ * the webhook destination's `secret` come back as `secret_set`, the webhook
2169
+ * destination's `url` as `url_set` and `url_host`, and `events.webhook_url` and
2170
+ * the Teams destination's `webhook_url` as `webhook_url_set` and
2171
+ * `webhook_url_host` — a patch never has to resend them.
1982
2172
  */
1983
- type NotifyConfigOverrides = Omit<NotifyConfigPatch, 'events'> & {
2173
+ type NotifyConfigOverrides = Omit<NotifyConfigPatch, 'events' | 'destinations'> & {
1984
2174
  events?: NotifyConfigEventsRead;
2175
+ destinations?: NotifyConfigDestinations;
1985
2176
  };
1986
2177
  interface NotifyConfigResponse {
1987
2178
  effective: NotifyConfig;
@@ -2308,8 +2499,12 @@ declare class NotifyProductModule {
2308
2499
  *
2309
2500
  * The `events` section configures the outbound event webhook: `webhook_url`
2310
2501
  * must be https on a public host, and `secret` (16-256 chars) signs every event
2311
- * body as `X-SparkVault-Signature: hex(HMAC-SHA256(secret, rawBody))`. The
2312
- * secret is WRITE-ONLY — reads report `events.secret_set`, never the value.
2502
+ * body as `X-SparkVault-Signature: hex(HMAC-SHA256(secret, rawBody))`. Both
2503
+ * are WRITE-ONLY — reads report `events.webhook_url_set`,
2504
+ * `events.webhook_url_host` and `events.secret_set`, never the values. A
2505
+ * `webhook_url` on another host or port needs a new `secret` in the same
2506
+ * patch (400 `VALIDATION_ERROR` naming `events.secret`), so a secret never
2507
+ * follows its URL to a different host.
2313
2508
  *
2314
2509
  * The `email` section selects a domain of your own for your Notify email to go
2315
2510
  * out from. `security`, `events` and `email` are an org admin's to change: a
@@ -2374,855 +2569,1216 @@ declare class NotifyProductModule {
2374
2569
  }
2375
2570
 
2376
2571
  /**
2377
- * Products Module
2572
+ * Folders Module Types
2378
2573
  *
2379
- * Namespace for SparkVault first-party products. Each product is a
2380
- * self-contained surface (UI + API) the account can enable independently.
2381
- * Currently exposes `identity`; future products attach here alongside it.
2574
+ * Folders organize ingots within an unsealed vault. Public domain objects are
2575
+ * camelCase; wire shapes (snake_case) stay private to the module.
2382
2576
  */
2383
2577
 
2384
- declare class ProductsModule {
2385
- /** Identity verification product (passkey, OTP, SparkLink, social). */
2386
- readonly identity: IdentityModule;
2387
- /**
2388
- * Notify product — the tenant/sender surface (send, sender-side inbox, status,
2389
- * receipts, config). Distinct from `sv.notify`, which is the signed-in
2390
- * recipient's own inbox.
2391
- */
2392
- readonly notify: NotifyProductModule;
2393
- /**
2394
- * `http` defaults to a client over the same resolved config so constructing
2395
- * this module standalone stays a one-argument call.
2396
- */
2397
- constructor(config: ResolvedConfig, http?: HttpClient);
2578
+ /** A folder within a vault. */
2579
+ interface Folder {
2580
+ /** Folder ID */
2581
+ id: string;
2582
+ /** Folder name */
2583
+ name: string;
2584
+ /** Parent folder ID, or null at the vault root */
2585
+ parentId: string | null;
2586
+ /** Whether the folder is pinned */
2587
+ pinned: boolean;
2588
+ /** Creation timestamp (Unix seconds) */
2589
+ createdAt: number;
2590
+ /** Last update timestamp (Unix seconds) */
2591
+ updatedAt: number;
2398
2592
  }
2399
-
2400
- /**
2401
- * Vault Upload Module Types
2402
- *
2403
- * Types for the embedded vault upload widget.
2404
- */
2405
- /**
2406
- * Branding configuration from vault upload info.
2407
- */
2408
- interface UploadBranding {
2409
- /** Organization name */
2410
- organizationName: string;
2411
- /** Light theme logo URL */
2412
- logoLightUrl: string | null;
2413
- /** Dark theme logo URL */
2414
- logoDarkUrl: string | null;
2593
+ /** A single hop in a folder breadcrumb trail. */
2594
+ interface FolderBreadcrumbItem {
2595
+ /** Folder ID, or null for the Root entry */
2596
+ id: string | null;
2597
+ /** Folder name */
2598
+ name: string;
2599
+ }
2600
+ /** Options for one page of a vault's folders. */
2601
+ interface ListFoldersOptions {
2602
+ /** Most folders on one page (1-500; server default 100) */
2603
+ limit?: number;
2604
+ /** A prior page's `nextPageToken` */
2605
+ pageToken?: string;
2415
2606
  }
2416
2607
  /**
2417
- * Encryption information for the vault.
2608
+ * One page of a vault's folders: at most `limit` of them, in an order that
2609
+ * holds from page to page and is not by name. A page can hold fewer, even
2610
+ * none, and still not be the last: follow `nextPageToken`, never the count,
2611
+ * and sort what you hold. To show one folder's subfolders, list its contents
2612
+ * (`ingots.listContents`), which pages them first.
2418
2613
  */
2419
- interface EncryptionInfo {
2420
- /** Encryption algorithm (e.g., 'AES-256-GCM') */
2421
- algorithm: string;
2422
- /** Key derivation method (e.g., 'Triple Zero-Trust') */
2423
- keyDerivation: string;
2424
- /** Post-quantum protection status */
2425
- postQuantum: string;
2614
+ interface FolderPage {
2615
+ /** This page's folders */
2616
+ folders: Folder[];
2617
+ /** The next page's `pageToken`; null on the last page */
2618
+ nextPageToken: string | null;
2619
+ }
2620
+ /** Options for creating a folder. */
2621
+ interface CreateFolderOptions {
2622
+ /** Folder name */
2623
+ name: string;
2624
+ /** Parent folder ID, or null/omitted for the vault root */
2625
+ parentId?: string | null;
2626
+ }
2627
+ /** Options for updating a folder. */
2628
+ interface UpdateFolderOptions {
2629
+ /** New name */
2630
+ name?: string;
2631
+ /** New parent folder ID, or null for the vault root */
2632
+ parentId?: string | null;
2633
+ /** New pinned state */
2634
+ pinned?: boolean;
2426
2635
  }
2636
+
2427
2637
  /**
2428
- * Vault upload configuration from API.
2638
+ * Ingots Module Types
2639
+ *
2640
+ * Ingot operations run against an unsealed vault: every call carries the
2641
+ * vault's short-lived Vault Access Token (VAT) via the `X-Vault-Access-Token`
2642
+ * header. Public domain objects are camelCase; wire shapes (snake_case) stay
2643
+ * private to the module.
2429
2644
  */
2430
- interface VaultUploadConfig {
2431
- /** Vault ID */
2432
- vaultId: string;
2433
- /** Vault name */
2434
- vaultName: string;
2435
- /** Maximum upload size in bytes */
2436
- maxSizeBytes: number;
2437
- /** Branding information */
2438
- branding: UploadBranding;
2439
- /** Encryption details */
2440
- encryption: EncryptionInfo;
2441
- /** Forge status */
2442
- forgeStatus: 'active' | 'inactive';
2443
- }
2645
+
2444
2646
  /**
2445
- * Options for upload().
2446
- * - Without `target`: Opens a dialog (modal)
2447
- * - With `target`: Renders inline into the specified element
2647
+ * What the server does when a create's name is already held in the target
2648
+ * folder (case-insensitive). The server decides on the holder it read before
2649
+ * writing anything, so a caller that must not replace content says so here:
2650
+ * - `upsert` (the server default): the upload replaces the holder's content.
2651
+ * - `complete_pending`: a holder whose own upload never finalized is completed
2652
+ * (`created: false`); a published holder is refused with a 409 CONFLICT whose
2653
+ * `details.reason` is `'NAME_HELD'`, and is left untouched. The details
2654
+ * describe the holder (`ingot_id`, `status`, `size_bytes`) unless another
2655
+ * app manages it or another request claimed the name first, when they carry
2656
+ * the reason alone.
2657
+ * - `refuse`: any holder, its upload finished or not, is refused with that
2658
+ * same 409 and left untouched; the create only ever mints.
2659
+ * - `new_name`: the holder is never touched; the ingot is minted under the
2660
+ * first free numbered name the server picks ("report (2).pdf"), returned as
2661
+ * the result's `name`.
2448
2662
  */
2449
- interface UploadOptions {
2450
- /** Vault ID to upload to */
2451
- vaultId: string;
2663
+ declare const NAME_CONFLICT_POLICIES: readonly ["upsert", "complete_pending", "refuse", "new_name"];
2664
+ type NameConflictPolicy = (typeof NAME_CONFLICT_POLICIES)[number];
2665
+ /** Ingot metadata as returned by list/get/contents. */
2666
+ interface Ingot {
2667
+ /** Ingot ID */
2668
+ id: string;
2669
+ /** Ingot name */
2670
+ name: string;
2452
2671
  /**
2453
- * Target element for inline rendering. Can be:
2454
- * - A CSS selector string (e.g., "#upload-container")
2455
- * - An HTMLElement reference
2456
- * - Omitted for dialog mode (default)
2672
+ * The name a download of the ingot saves under, as Forge names it: `name`,
2673
+ * kept as it is when the first word of the extension it shows (up to an
2674
+ * ASCII space, in any case) is one the MIME registry knows or holds a
2675
+ * character none of the registry's extensions is spelled with, which may
2676
+ * draw as one, and otherwise completed with the extension `contentType`'s
2677
+ * files are named with (the first the registry lists for it, or, for the
2678
+ * few types whose first is not the one desktops name their files with, the
2679
+ * one they do: `.mp3` for `audio/mpeg`, `.mov` for `video/quicktime`), never
2680
+ * one a saved copy must never open as. Save a copy under it, handed to a
2681
+ * browser as `application/octet-stream` unless `contentType` is a raster
2682
+ * image, audio, video or PDF format (never SVG, a playlist or a stream
2683
+ * redirector): a browser renames a saved copy by the type it is handed
2684
+ * (Chrome saves `Invoice` typed `application/x-msdownload` as
2685
+ * `Invoice.exe`), and completes or replaces no extension of a copy handed
2686
+ * as `application/octet-stream`.
2457
2687
  */
2458
- target?: string | HTMLElement;
2459
- /** Override backdrop blur for this dialog (uses global config if omitted) */
2460
- backdropBlur?: boolean;
2461
- /** Hide "Upload Another File" button on success screen (for single-file flows) */
2462
- hideUploadAnother?: boolean;
2688
+ downloadFilename: string;
2689
+ /** Content type (MIME) */
2690
+ contentType: string;
2691
+ /** Size in bytes */
2692
+ size: number;
2693
+ /** Lifecycle status: `uploading` until Forge activates the upload, then `active` */
2694
+ status: 'uploading' | 'active';
2695
+ /** Creation timestamp (Unix seconds) */
2696
+ createdAt: number;
2697
+ /** Containing folder ID, or null at the vault root */
2698
+ folderId: string | null;
2463
2699
  /**
2464
- * Skip the success screen entirely. On completion the SDK fires onSuccess
2465
- * and closes the dialog, so a host site can render its own post-upload UI.
2700
+ * Client-computed, vault-keyed HMAC of the plaintext (43-char base64url),
2701
+ * or null when the uploader did not supply one.
2466
2702
  */
2467
- hideSuccessScreen?: boolean;
2703
+ contentHmac: string | null;
2704
+ /** Opaque published-content revision; null for legacy/unpublished content. */
2705
+ contentVersion: string | null;
2706
+ }
2707
+ /** The discrete primitive returned by createUpload — a Forge TUS session. */
2708
+ interface IngotUpload {
2709
+ /** Ingot ID */
2710
+ id: string;
2711
+ /** The name the ingot is stored under: the server's numbered name under `new_name`. */
2712
+ name: string;
2713
+ /** Content type (MIME) */
2714
+ contentType: string;
2715
+ /** Size in bytes */
2716
+ size: number;
2717
+ /** Forge upload URL carrying the ISTK (upload session token) */
2718
+ uploadUrl: string;
2719
+ /** Upload session expiry (Unix seconds) */
2720
+ expiresAt: number;
2468
2721
  /**
2469
- * Upload this File directly, skipping the SDK's drop-zone. The host owns
2470
- * file selection (its own button, picker, or drop target) and hands the
2471
- * File to the SDK, which shows only the secure-upload progress dialog.
2722
+ * Whether the server minted this ingot (true) or staged the upload onto the
2723
+ * ingot already holding the name (false, as `onNameConflict` allowed).
2472
2724
  */
2473
- file?: File;
2725
+ created: boolean;
2474
2726
  /**
2475
- * Vault Access Token, sent only on the upload's POST, where it supplies the
2476
- * vault key in place of the System DVAK the widget setting provisions; a
2477
- * read-only VAT is refused 403. It does not lift the vault's Embedded Upload
2478
- * Widget setting: the widget opens by reading the vault's upload info, a
2479
- * request that carries no VAT and is refused (UPLOAD_SOURCE_DISABLED) while
2480
- * the setting is off.
2481
- */
2482
- token?: string;
2483
- /**
2484
- * Slash-delimited folder path within the vault (e.g. "Accounts/001xx").
2485
- * Missing path segments are find-or-created. Omitted means the vault root.
2486
- */
2487
- folder?: string;
2488
- /** Callback when upload completes successfully */
2489
- onSuccess?: (result: UploadResult) => void;
2490
- /** Callback when an error occurs */
2491
- onError?: (error: Error) => void;
2492
- /** Callback when user cancels */
2493
- onCancel?: () => void;
2494
- /** Callback for upload progress */
2495
- onProgress?: (progress: UploadProgress) => void;
2496
- /**
2497
- * Called once the widget has read the vault's upload page and shows its
2498
- * form (or, given a `file`, starts uploading it). A failure after it is the
2499
- * widget's to show, with the way on its failure leaves (the same file
2500
- * again, or another); one before it means the upload page could not load.
2727
+ * The upload the create staged onto the ingot (Core's `upload_id`): the id
2728
+ * Forge keys the upload's session by, and the `contentVersion` the ingot
2729
+ * reads once the upload publishes. Giving the upload up ends it with the
2730
+ * file the create made through this id (`endUpload`). Null when the server
2731
+ * named none.
2501
2732
  */
2502
- onReady?: () => void;
2503
- }
2504
- /** Options for attach() - binds upload to element clicks */
2505
- interface UploadAttachOptions {
2506
- /** Vault ID to upload to */
2507
- vaultId: string;
2508
- /** Callback when upload completes successfully */
2509
- onSuccess?: (result: UploadResult) => void;
2510
- /** Callback when an error occurs */
2511
- onError?: (error: Error) => void;
2512
- /** Callback when user cancels */
2513
- onCancel?: () => void;
2514
- /** Callback for upload progress */
2515
- onProgress?: (progress: UploadProgress) => void;
2733
+ uploadId: string | null;
2516
2734
  }
2517
2735
  /**
2518
- * Upload progress information.
2736
+ * What became of a given-up upload's file (`endUpload`): `deleted`, the vault
2737
+ * holds it no longer (this end deleted it, or it was already gone); `kept`,
2738
+ * this end deleted nothing, and a read of it by id (`get`) shows the file as
2739
+ * it is now.
2519
2740
  */
2520
- interface UploadProgress {
2521
- /** Bytes uploaded */
2522
- bytesUploaded: number;
2523
- /** Total bytes */
2524
- bytesTotal: number;
2525
- /** Percentage (0-100) */
2526
- percentage: number;
2527
- /** Current phase */
2528
- phase: 'uploading' | 'ceremony' | 'complete';
2741
+ type UploadEnd = 'deleted' | 'kept';
2742
+ /** A finalized ingot, returned by the high-level upload/replace flows. */
2743
+ interface CreatedIngot {
2744
+ /** Ingot ID */
2745
+ id: string;
2746
+ /** The name the ingot is stored under: the server's numbered name under `new_name`. */
2747
+ name: string;
2748
+ /** Content type (MIME) */
2749
+ contentType: string;
2750
+ /** Size in bytes */
2751
+ size: number;
2752
+ /**
2753
+ * Whether the upload minted this ingot (true) or replaced the content of an
2754
+ * existing one (false): a same-name upload the name-conflict policy staged
2755
+ * onto its holder, or any `replace`.
2756
+ */
2757
+ created: boolean;
2529
2758
  }
2530
- /**
2531
- * Successful upload result.
2532
- */
2533
- interface UploadResult {
2759
+ /** The discrete primitive returned by createDownloadLink. */
2760
+ interface IngotDownloadLink {
2761
+ /** Opaque published-content revision; null for legacy content. */
2762
+ contentVersion: string | null;
2763
+ /** Short-lived signed Forge download URL */
2764
+ downloadUrl: string;
2534
2765
  /** Ingot ID */
2535
- ingotId: string;
2536
- /** Vault ID */
2537
- vaultId: string;
2538
- /** Original filename */
2539
- filename: string;
2540
- /** File size in bytes */
2766
+ id: string;
2767
+ /** Ingot name */
2768
+ name: string;
2769
+ /** Size in bytes */
2770
+ size: number;
2771
+ /** Content type (MIME) */
2772
+ contentType: string;
2773
+ }
2774
+ /** Options for the createUpload primitive. */
2775
+ interface CreateUploadOptions {
2776
+ /** Unsealed vault the ingot belongs to */
2777
+ vault: UnsealedVault;
2778
+ /** Ingot name */
2779
+ name: string;
2780
+ /** Content type (MIME) */
2781
+ contentType: string;
2782
+ /** Declared upload size in bytes */
2541
2783
  sizeBytes: number;
2542
- /** Upload time in UTC, as "YYYY-MM-DD HH:MM:SS UTC" */
2543
- uploadTime: string;
2784
+ /** Slash-delimited folder path (find-or-created from root). */
2785
+ folder?: string;
2786
+ /** Existing folder ID to upload into. Mutually exclusive with `folder`. */
2787
+ folderId?: string;
2788
+ /** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
2789
+ contentHmac?: string;
2790
+ /** What a name already held in the target folder does; omitted means the server's `upsert`. */
2791
+ onNameConflict?: NameConflictPolicy;
2792
+ }
2793
+ /** Options for the high-level upload flow. */
2794
+ interface UploadIngotOptions {
2795
+ /** File or Blob to upload */
2796
+ file: File | Blob;
2797
+ /** Optional name (defaults to file name) */
2798
+ name?: string;
2799
+ /**
2800
+ * Content type (the file's own `type` if not provided). A file of no type is
2801
+ * sent with none, and Core stores the type the registry lists for the name's
2802
+ * extension, else `application/octet-stream`.
2803
+ */
2804
+ contentType?: string;
2805
+ /** Slash-delimited folder path (find-or-created from root). */
2806
+ folder?: string;
2807
+ /** Existing folder ID to upload into. Mutually exclusive with `folder`. */
2808
+ folderId?: string;
2809
+ /** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
2810
+ contentHmac?: string;
2811
+ /** What a name already held in the target folder does; omitted means the server's `upsert`. */
2812
+ onNameConflict?: NameConflictPolicy;
2813
+ /** Progress callback for the Forge/TUS transfer */
2814
+ onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
2544
2815
  }
2545
-
2546
- /**
2547
- * Vaults Module
2548
- *
2549
- * Create and manage encrypted vaults (the control plane). Uses Triple
2550
- * Zero-Trust encryption (SVMK + AMK + VMK). Ingot, folder, spark, and entropy
2551
- * operations live in their own modules; this module owns the vault record,
2552
- * its sharing/upload configuration, and the browser upload widget.
2553
- */
2554
-
2555
2816
  /**
2556
- * Callable upload interface with methods.
2557
- * Allows both `sv.vaults.upload(options)` and `sv.vaults.upload.attach(selector, options)`.
2817
+ * The upload session a file's bytes go to, which `sendUpload` hands over once
2818
+ * Forge opens it (`onSessionCreated`): what `resumeUpload` continues the
2819
+ * upload in. Its URL addresses the upload itself (a request to it can end the
2820
+ * upload), so keep it in memory, never in a log or a URL a person shares.
2558
2821
  */
2559
- interface UploadCallable {
2560
- (options: UploadOptions): Promise<UploadResult>;
2561
- attach(selector: string, options: UploadAttachOptions): () => void;
2562
- close(): void;
2563
- /** Open the upload widget as a popup. Equivalent to calling `upload(options)`. */
2564
- pop(options: UploadOptions): Promise<UploadResult>;
2565
- /** Render the upload widget inline. Equivalent to `upload({ ...options, target })`. */
2566
- render(options: UploadOptions): Promise<UploadResult>;
2822
+ interface UploadSession {
2823
+ /** The session's URL on Forge. */
2824
+ readonly sessionUrl: string;
2567
2825
  }
2568
- declare class VaultsModule {
2569
- private readonly http;
2570
- private readonly uploadModule;
2571
- /**
2572
- * Upload to a vault with public upload enabled.
2573
- *
2574
- * @example Dialog mode
2575
- * const result = await sv.vaults.upload({ vaultId: 'vlt_abc123' });
2576
- *
2577
- * @example Attach to clicks
2578
- * sv.vaults.upload.attach('.upload-btn', { vaultId: 'vlt_abc123' });
2579
- *
2580
- * @example Inline mode
2581
- * sv.vaults.upload({ vaultId: 'vlt_abc123', target: '#upload-area' });
2582
- */
2583
- readonly upload: UploadCallable;
2584
- constructor(config: ResolvedConfig, http: HttpClient);
2826
+ /** Options for sendUpload. */
2827
+ interface SendUploadOptions {
2828
+ /** Cancels the transfer. */
2829
+ signal?: AbortSignal;
2830
+ /** Bytes sent so far and the file size; never runs backwards. */
2831
+ onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
2585
2832
  /**
2586
- * Create a new encrypted vault.
2587
- * IMPORTANT: Store the VMK securely - it cannot be recovered!
2588
- *
2589
- * @example
2590
- * const vault = await sv.vaults.create({ name: 'My Vault' });
2591
- * console.log('Save this VMK:', vault.vmk);
2833
+ * Hands over the upload's session once Forge opens it, before the first
2834
+ * byte is sent, so the caller can `resumeUpload` the upload in it later:
2835
+ * after `upload_received_publishing`, to learn whether the server published
2836
+ * it, or after a failure, to send only the bytes the server lacks. A throw
2837
+ * here ends the transfer with that error.
2592
2838
  */
2593
- create(options: CreateVaultOptions): Promise<Vault>;
2839
+ onSessionCreated?: (session: UploadSession) => void;
2840
+ }
2841
+ /** Options for resumeUpload. */
2842
+ type ResumeUploadOptions = Omit<SendUploadOptions, 'onSessionCreated'>;
2843
+ /** Options for replacing an existing ingot's content. */
2844
+ interface ReplaceIngotOptions {
2845
+ /** File or Blob to upload as the new content */
2846
+ file: File | Blob;
2847
+ /** Optional new name (defaults to file name) */
2848
+ name?: string;
2849
+ /** Vault-keyed plaintext HMAC (43-char base64url) for the NEW content. */
2850
+ contentHmac?: string;
2594
2851
  /**
2595
- * Unseal a vault to access its contents.
2596
- * Returns a short-lived Vault Access Token (VAT).
2597
- *
2598
- * @param vaultId - The vault to unseal.
2599
- * @param key - The vault's VMK, or a DVAK token issued for it.
2600
- *
2601
- * @example
2602
- * const unsealed = await sv.vaults.unseal('vlt_abc', vmk);
2603
- * const delegated = await sv.vaults.unseal('vlt_abc', 'dvak_...');
2604
- * console.log('Token:', unsealed.vatToken);
2852
+ * Content type (the file's own `type` if not provided). A file of no type
2853
+ * keeps the type the ingot stores, which Core reads from the name by its
2854
+ * extension only when it is `application/octet-stream` or unparsable.
2605
2855
  */
2606
- unseal(vaultId: string, key: string): Promise<UnsealedVault>;
2856
+ contentType?: string;
2857
+ /** Progress callback for the Forge/TUS transfer */
2858
+ onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
2859
+ }
2860
+ /** Options for list. */
2861
+ interface ListIngotsOptions {
2862
+ /** Page size */
2863
+ limit?: number;
2864
+ /** Pagination cursor */
2865
+ cursor?: string;
2607
2866
  /**
2608
- * List vaults for the account. Results are paginated (server default 100 per
2609
- * page, max 500); follow `nextCursor` to fetch subsequent pages.
2610
- *
2611
- * @example
2612
- * let cursor: string | undefined;
2613
- * do {
2614
- * const page = await sv.vaults.list({ cursor });
2615
- * page.vaults.forEach((v) => console.log(v.name));
2616
- * cursor = page.nextCursor;
2617
- * } while (cursor);
2867
+ * Sort field (name | size | content_type | created | access_count): it
2868
+ * orders only the page answered, never the list across pages
2618
2869
  */
2619
- list(options?: ListVaultsOptions): Promise<VaultPage>;
2620
- /**
2621
- * Get a single vault's detail.
2622
- *
2623
- * @example
2624
- * const vault = await sv.vaults.get('vlt_abc');
2625
- * console.log(vault.status, vault.ingotCount);
2626
- */
2627
- get(vaultId: string): Promise<VaultDetail>;
2628
- /**
2629
- * Rename a vault.
2630
- *
2631
- * @example
2632
- * await sv.vaults.update('vlt_abc', { name: 'Renamed Vault' });
2633
- */
2634
- update(vaultId: string, options: {
2635
- name: string;
2636
- }): Promise<UpdatedVault>;
2637
- /**
2638
- * Seal a vault, revoking all active access tokens.
2639
- *
2640
- * @example
2641
- * await sv.vaults.seal('vlt_abc');
2642
- */
2643
- seal(vaultId: string): Promise<void>;
2644
- /**
2645
- * Schedule permanent deletion in seven days and immediately lock all vault access.
2646
- * Company admins only; cancelDeletion can abort this schedule before its deadline.
2647
- * A vault whose irreversible cleanup has already started answers that cleanup
2648
- * (`status: 'deleting'`) instead, which nothing can cancel.
2649
- *
2650
- * Requires the vault's exact name as confirmation, matched case-sensitively.
2651
- * The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
2652
- * named with any Unicode (emoji, CJK, the U+202F in macOS-style names) is
2653
- * deletable — an HTTP header value cannot carry non-latin1 characters.
2654
- *
2655
- * @example
2656
- * await sv.vaults.delete('vlt_abc', 'My Vault');
2657
- */
2658
- delete(vaultId: string, name: string): Promise<ScheduledVaultDeletion | StartedVaultDeletion>;
2659
- /** Cancel this exact deletion schedule before its deadline; company admins only. */
2660
- cancelDeletion(vaultId: string, deletionScheduleId: string): Promise<VaultDetail>;
2661
- /**
2662
- * Get a vault's public-sharing configuration. Every sharing write below
2663
- * answers the same configuration as that write left it.
2664
- *
2665
- * @example
2666
- * const sharing = await sv.vaults.getSharingConfig('vlt_abc');
2667
- */
2668
- getSharingConfig(vaultId: string): Promise<VaultSharingConfig>;
2669
- /**
2670
- * Enable public sharing for a vault.
2671
- *
2672
- * @example
2673
- * await sv.vaults.enableSharing('vlt_abc', vmk, { sessionLengthSeconds: 3600 });
2674
- */
2675
- enableSharing(vaultId: string, vmk: string, options?: VaultSharingOptions): Promise<VaultSharingConfig>;
2676
- /**
2677
- * Disable public sharing for a vault.
2678
- *
2679
- * @example
2680
- * await sv.vaults.disableSharing('vlt_abc');
2681
- */
2682
- disableSharing(vaultId: string): Promise<VaultSharingConfig>;
2683
- /**
2684
- * Update a vault's sharing configuration (without changing enabled state).
2685
- *
2686
- * Making every ingot public publishes each file to anyone holding its URL,
2687
- * so the API accepts `allIngotsPublic: true` only with a read-write VAT for
2688
- * the vault: pass the unsealed vault for that change.
2689
- *
2690
- * @example
2691
- * await sv.vaults.updateSharingConfig('vlt_abc', { sessionLengthSeconds: 1800 });
2692
- *
2693
- * @example Make every ingot public
2694
- * const unsealed = await sv.vaults.unseal('vlt_abc', vmk);
2695
- * await sv.vaults.updateSharingConfig('vlt_abc', { allIngotsPublic: true }, unsealed);
2696
- */
2697
- updateSharingConfig(vaultId: string, config: VaultSharingOptions, vault?: UnsealedVault): Promise<VaultSharingConfig>;
2698
- /**
2699
- * Get a vault's access-log retention window.
2700
- *
2701
- * @example
2702
- * const { retentionSeconds } = await sv.vaults.getAccessLogRetention('vlt_abc');
2703
- */
2704
- getAccessLogRetention(vaultId: string): Promise<AccessLogRetention>;
2705
- /**
2706
- * Update a vault's access-log retention window.
2707
- *
2708
- * @example
2709
- * await sv.vaults.updateAccessLogRetention('vlt_abc', 7776000);
2710
- */
2711
- updateAccessLogRetention(vaultId: string, seconds: number): Promise<AccessLogRetention>;
2712
- /**
2713
- * Get a vault's upload-channel configuration. Every upload write below
2714
- * answers the same configuration as that write left it: both channels, the
2715
- * shared settings, and the portal's URL while the portal is on.
2716
- *
2717
- * @example
2718
- * const upload = await sv.vaults.getUploadConfig('vlt_abc');
2719
- */
2720
- getUploadConfig(vaultId: string): Promise<VaultUploadSettings>;
2721
- /**
2722
- * Enable the public upload portal for a vault.
2723
- *
2724
- * @example
2725
- * await sv.vaults.enableUploadPortal('vlt_abc', vmk);
2726
- */
2727
- enableUploadPortal(vaultId: string, vmk: string): Promise<VaultUploadSettings>;
2728
- /**
2729
- * Disable the public upload portal for a vault.
2730
- *
2731
- * @example
2732
- * await sv.vaults.disableUploadPortal('vlt_abc');
2733
- */
2734
- disableUploadPortal(vaultId: string): Promise<VaultUploadSettings>;
2735
- /**
2736
- * Enable the upload widget for a vault.
2737
- *
2738
- * @example
2739
- * await sv.vaults.enableUploadWidget('vlt_abc', vmk);
2740
- */
2741
- enableUploadWidget(vaultId: string, vmk: string): Promise<VaultUploadSettings>;
2742
- /**
2743
- * Disable the upload widget for a vault.
2744
- *
2745
- * @example
2746
- * await sv.vaults.disableUploadWidget('vlt_abc');
2747
- */
2748
- disableUploadWidget(vaultId: string): Promise<VaultUploadSettings>;
2749
- /**
2750
- * Update a vault's upload settings (max size, notification email).
2751
- *
2752
- * @example
2753
- * await sv.vaults.updateUploadConfig('vlt_abc', { maxSizeBytes: 1048576 });
2754
- */
2755
- updateUploadConfig(vaultId: string, config: UpdateVaultUploadOptions): Promise<VaultUploadSettings>;
2756
- private toggleUploadChannel;
2757
- private validateCreateOptions;
2758
- }
2759
-
2760
- /**
2761
- * Folders Module Types
2762
- *
2763
- * Folders organize ingots within an unsealed vault. Public domain objects are
2764
- * camelCase; wire shapes (snake_case) stay private to the module.
2765
- */
2766
-
2767
- /** A folder within a vault. */
2768
- interface Folder {
2769
- /** Folder ID */
2770
- id: string;
2771
- /** Folder name */
2772
- name: string;
2773
- /** Parent folder ID, or null at the vault root */
2774
- parentId: string | null;
2775
- /** Whether the folder is pinned */
2776
- pinned: boolean;
2777
- /** Creation timestamp (Unix seconds) */
2778
- createdAt: number;
2779
- /** Last update timestamp (Unix seconds) */
2780
- updatedAt: number;
2781
- }
2782
- /** A single hop in a folder breadcrumb trail. */
2783
- interface FolderBreadcrumbItem {
2784
- /** Folder ID, or null for the Root entry */
2785
- id: string | null;
2786
- /** Folder name */
2787
- name: string;
2870
+ sortBy?: string;
2871
+ /** Sort direction of the page */
2872
+ sortOrder?: 'asc' | 'desc';
2788
2873
  }
2789
- /** Options for one page of a vault's folders. */
2790
- interface ListFoldersOptions {
2791
- /** Most folders on one page (1-500; server default 100) */
2874
+ /** Options for listContents. */
2875
+ interface ListContentsOptions {
2876
+ /** Folder to list (null/omitted lists the vault root) */
2877
+ folderId?: string | null;
2878
+ /** Most children on one page (1-500; server default 100) */
2792
2879
  limit?: number;
2793
- /** A prior page's `nextPageToken` */
2880
+ /** A prior page's `nextPageToken`, for the same folder and order */
2794
2881
  pageToken?: string;
2882
+ /** Ingot creation order; `desc` (newest first) by default */
2883
+ sortOrder?: 'asc' | 'desc';
2795
2884
  }
2796
2885
  /**
2797
- * One page of a vault's folders: at most `limit` of them, in an order that
2798
- * holds from page to page and is not by name. A page can hold fewer, even
2799
- * none, and still not be the last: follow `nextPageToken`, never the count,
2800
- * and sort what you hold. To show one folder's subfolders, list its contents
2801
- * (`ingots.listContents`), which pages them first.
2886
+ * One page of a folder's listing. The folder's children run as one sequence
2887
+ * across its pages: every direct subfolder first, in a stable order that is
2888
+ * not by name, then every ingot directly in the folder in creation order
2889
+ * (newest first under `desc`). A page holds at most `limit` children in all,
2890
+ * so one page can hold the last subfolders and the first ingots, and a page
2891
+ * can hold fewer than `limit`, even none, and still not be the last: follow
2892
+ * `nextPageToken`, never the count. Ordering by name, size or type is the
2893
+ * caller's, over the children it holds.
2802
2894
  */
2803
- interface FolderPage {
2804
- /** This page's folders */
2895
+ interface FolderContents {
2896
+ /** The folder listed, on every page; null at the vault root */
2897
+ folder: {
2898
+ id: string;
2899
+ name: string;
2900
+ parentId: string | null;
2901
+ } | null;
2902
+ /** Root → … → the folder listed, on every page */
2903
+ breadcrumb: FolderBreadcrumbItem[];
2904
+ /** This page's subfolders */
2805
2905
  folders: Folder[];
2906
+ /** This page's ingots */
2907
+ ingots: Ingot[];
2806
2908
  /** The next page's `pageToken`; null on the last page */
2807
2909
  nextPageToken: string | null;
2808
2910
  }
2809
- /** Options for creating a folder. */
2810
- interface CreateFolderOptions {
2811
- /** Folder name */
2812
- name: string;
2813
- /** Parent folder ID, or null/omitted for the vault root */
2814
- parentId?: string | null;
2911
+ /** Options for search. */
2912
+ interface SearchIngotsOptions {
2913
+ /**
2914
+ * A part of the ingot's file name, matched ignoring letter case, accents
2915
+ * and Unicode compatibility forms (`resume` matches `Résumé.pdf`, `strasse`
2916
+ * matches `Straße.txt`); a whole name matches too. Results come in creation
2917
+ * order, newest first unless `sortOrder` is `asc`, and a page can hold none
2918
+ * while `nextCursor` is set: follow it. Text no name can hold is refused
2919
+ * (400).
2920
+ */
2921
+ q?: string;
2922
+ /**
2923
+ * The MIME type to match, in lowercase: a family (`image`, `video`,
2924
+ * `audio`, `text`, `application`, ...), which every type under it matches,
2925
+ * or an exact type (`application/pdf`), which matches that type whatever
2926
+ * its parameters. A well-formed value no ingot carries matches none; the
2927
+ * server refuses a value that is neither.
2928
+ */
2929
+ fileType?: string;
2930
+ /** Scope the search to one folder (whole vault when omitted) */
2931
+ folderId?: string;
2932
+ /** Minimum size in bytes */
2933
+ minSize?: number;
2934
+ /** Maximum size in bytes */
2935
+ maxSize?: number;
2936
+ /** Page size */
2937
+ limit?: number;
2938
+ /** Pagination cursor */
2939
+ cursor?: string;
2940
+ /** Sort direction */
2941
+ sortOrder?: 'asc' | 'desc';
2815
2942
  }
2816
- /** Options for updating a folder. */
2817
- interface UpdateFolderOptions {
2818
- /** New name */
2819
- name?: string;
2820
- /** New parent folder ID, or null for the vault root */
2821
- parentId?: string | null;
2822
- /** New pinned state */
2823
- pinned?: boolean;
2943
+ /** A page of ingots. */
2944
+ interface IngotPage {
2945
+ /** Ingots on this page */
2946
+ ingots: Ingot[];
2947
+ /** Cursor for the next page, when more results exist */
2948
+ nextCursor?: string;
2949
+ }
2950
+ /** Ingot sharing configuration. */
2951
+ interface IngotSharingConfig {
2952
+ /** Whether the ingot is shared */
2953
+ shared: boolean;
2954
+ /** Visibility mode */
2955
+ visibility?: 'invite_only' | 'authenticated' | 'public';
2956
+ /** The share's permanent files.sv URL, the link its recipients open; null while the ingot is not shared */
2957
+ publicUrl: string | null;
2958
+ /** The share's link code (the URL's last segment); null while the ingot is not shared */
2959
+ linkCode: string | null;
2960
+ /** Whether the vault's public file sharing is on */
2961
+ sharingEnabled: boolean;
2962
+ /** Whether the vault makes every ingot public, which pins this one to public */
2963
+ vaultAllIngotsPublic: boolean;
2964
+ /** The vault's share recipient session length, in seconds */
2965
+ sessionLengthSeconds: number;
2966
+ /** Active invites */
2967
+ invites?: IngotInvite[];
2968
+ }
2969
+ /** Options for updateSharingConfig. */
2970
+ interface UpdateIngotSharingOptions {
2971
+ /** Whether the ingot is shared */
2972
+ shared?: boolean;
2973
+ /** Visibility mode */
2974
+ visibility?: 'invite_only' | 'authenticated' | 'public';
2975
+ }
2976
+ /** A sharing invite on an ingot. */
2977
+ interface IngotInvite {
2978
+ /** Invite ID */
2979
+ id: string;
2980
+ /** Invited identity (email/phone) */
2981
+ identity: string;
2982
+ /** Identity type */
2983
+ identityType: 'email' | 'phone';
2984
+ /** When this identity was invited (Unix seconds) */
2985
+ invitedAt: number;
2986
+ }
2987
+ /** An invitation addInvite made or resent. */
2988
+ interface IngotInvitation extends IngotInvite {
2989
+ /** The URL this invitee was sent: the share's files.sv URL, with their own token when the share invites several */
2990
+ shareUrl: string;
2991
+ /** Whether the invitation was delivered by email or text */
2992
+ delivered: boolean;
2824
2993
  }
2825
-
2826
- /**
2827
- * Ingots Module Types
2828
- *
2829
- * Ingot operations run against an unsealed vault: every call carries the
2830
- * vault's short-lived Vault Access Token (VAT) via the `X-Vault-Access-Token`
2831
- * header. Public domain objects are camelCase; wire shapes (snake_case) stay
2832
- * private to the module.
2833
- */
2834
-
2835
2994
  /**
2836
- * What the server does when a create's name is already held in the target
2837
- * folder (case-insensitive). The server decides on the holder it read before
2838
- * writing anything, so a caller that must not replace content says so here:
2839
- * - `upsert` (the server default): the upload replaces the holder's content.
2840
- * - `complete_pending`: a holder whose own upload never finalized is completed
2841
- * (`created: false`); a published holder is refused with a 409 CONFLICT whose
2842
- * `details.reason` is `'NAME_HELD'`, and is left untouched. The details
2843
- * describe the holder (`ingot_id`, `status`, `size_bytes`) unless another
2844
- * app manages it or another request claimed the name first, when they carry
2845
- * the reason alone.
2846
- * - `refuse`: any holder, its upload finished or not, is refused with that
2847
- * same 409 and left untouched; the create only ever mints.
2848
- * - `new_name`: the holder is never touched; the ingot is minted under the
2849
- * first free numbered name the server picks ("report (2).pdf"), returned as
2850
- * the result's `name`.
2995
+ * An ingot access-log entry: a download that delivered the file, a SparkLink
2996
+ * open of it included. The server records an access as the download that
2997
+ * delivered it, so `download` is the one action.
2851
2998
  */
2852
- declare const NAME_CONFLICT_POLICIES: readonly ["upsert", "complete_pending", "refuse", "new_name"];
2853
- type NameConflictPolicy = (typeof NAME_CONFLICT_POLICIES)[number];
2854
- /** Ingot metadata as returned by list/get/contents. */
2855
- interface Ingot {
2856
- /** Ingot ID */
2857
- id: string;
2858
- /** Ingot name */
2859
- name: string;
2860
- /**
2861
- * The name a download of the ingot saves under, as Forge names it: `name`,
2862
- * kept as it is when the first word of the extension it shows (up to an
2863
- * ASCII space, in any case) is one the MIME registry knows or holds a
2864
- * character none of the registry's extensions is spelled with, which may
2865
- * draw as one, and otherwise completed with the extension `contentType`'s
2866
- * files are named with (the first the registry lists for it, or, for the
2867
- * few types whose first is not the one desktops name their files with, the
2868
- * one they do: `.mp3` for `audio/mpeg`, `.mov` for `video/quicktime`), never
2869
- * one a saved copy must never open as. Save a copy under it, handed to a
2870
- * browser as `application/octet-stream` unless `contentType` is a raster
2871
- * image, audio, video or PDF format (never SVG, a playlist or a stream
2872
- * redirector): a browser renames a saved copy by the type it is handed
2873
- * (Chrome saves `Invoice` typed `application/x-msdownload` as
2874
- * `Invoice.exe`), and completes or replaces no extension of a copy handed
2875
- * as `application/octet-stream`.
2876
- */
2877
- downloadFilename: string;
2878
- /** Content type (MIME) */
2879
- contentType: string;
2880
- /** Size in bytes */
2881
- size: number;
2882
- /** Lifecycle status: `uploading` until Forge activates the upload, then `active` */
2883
- status: 'uploading' | 'active';
2884
- /** Creation timestamp (Unix seconds) */
2885
- createdAt: number;
2886
- /** Containing folder ID, or null at the vault root */
2887
- folderId: string | null;
2999
+ interface IngotAccessLog {
2888
3000
  /**
2889
- * Client-computed, vault-keyed HMAC of the plaintext (43-char base64url),
2890
- * or null when the uploader did not supply one.
3001
+ * The entry's time (Unix seconds) as a string. The server issues no entry id,
3002
+ * so entries in the same second share it.
2891
3003
  */
2892
- contentHmac: string | null;
2893
- /** Opaque published-content revision; null for legacy/unpublished content. */
2894
- contentVersion: string | null;
2895
- }
2896
- /** The discrete primitive returned by createUpload — a Forge TUS session. */
2897
- interface IngotUpload {
2898
- /** Ingot ID */
2899
3004
  id: string;
2900
- /** The name the ingot is stored under: the server's numbered name under `new_name`. */
3005
+ /** What the access was */
3006
+ action: 'download';
3007
+ /** Who accessed: a member's email, an API key's name, or a SparkLink visitor's identity */
3008
+ identity: string;
3009
+ /** Source IP address */
3010
+ ipAddress: string;
3011
+ /** Client user agent */
3012
+ userAgent: string;
3013
+ /** Event timestamp (Unix seconds) */
3014
+ timestamp: number;
3015
+ }
3016
+ /** A page of access logs. */
3017
+ interface IngotAccessLogPage {
3018
+ /** Log entries on this page */
3019
+ logs: IngotAccessLog[];
3020
+ /** Cursor for the next page, when more results exist */
3021
+ nextCursor?: string;
3022
+ }
3023
+ /** Options for getAccessLogs. */
3024
+ interface AccessLogsOptions {
3025
+ /** Page size */
3026
+ limit?: number;
3027
+ /** Pagination cursor */
3028
+ cursor?: string;
3029
+ }
3030
+ /** One hash-check hit: this HMAC exists on an active ingot in the vault. */
3031
+ interface HashCheckMatch {
3032
+ content_hmac: string;
3033
+ ingot_id: string;
3034
+ }
3035
+ interface HashCheckResponse {
3036
+ found: HashCheckMatch[];
3037
+ }
3038
+
3039
+ /** Customer-only help desk contracts. Response fields retain the API's names. */
3040
+ interface HelpDeskIdentityRequest {
3041
+ /** Server-generated nonce. The company backend must include it in its signed assertion. */
3042
+ nonce: string;
3043
+ audience: string;
3044
+ deskId: string;
3045
+ }
3046
+ interface HelpDeskExternalChallenge {
3047
+ nonce: string;
3048
+ /** Held only by the initiating browser; used for hosted PKCE redemption, never sent to the company. */
3049
+ verifier: string;
3050
+ expires_at: number;
3051
+ }
3052
+ interface HelpDeskExternalIdentity {
3053
+ issuer: string;
3054
+ key_id: string;
3055
+ assertion_audience: string;
3056
+ session_ttl_seconds: number;
3057
+ handoff_url?: string | null;
3058
+ sign_in_url?: string | null;
3059
+ guest_email?: boolean;
3060
+ }
3061
+ interface HelpDeskConnectOptions {
3062
+ /** The configured help desk hostname, for example support.example.com. */
3063
+ host: string;
3064
+ /** A help desk hdt_ bearer provider. Core access tokens and API keys are never used. */
3065
+ getSessionToken?: () => string | null | Promise<string | null>;
3066
+ /** Obtain a purpose-specific JWT from the signed-in company's backend. No customer consent is shown. */
3067
+ getIdentityAssertion?: (request: HelpDeskIdentityRequest) => string | null | Promise<string | null>;
3068
+ /** Same-origin backend endpoint accepting POST {nonce,audience,desk_id}; returns {assertion} or {data:{assertion}}. */
3069
+ identityEndpoint?: string;
3070
+ }
3071
+ interface HelpDeskDesk {
3072
+ kind: 'desk';
3073
+ desk_id: string;
3074
+ handle: string;
3075
+ canonical_host: string;
3076
+ sending_host: string;
3077
+ organization_name: string | null;
3078
+ branding: {
3079
+ color: string | null;
3080
+ logo_url: string | null;
3081
+ logo_dark_url: string | null;
3082
+ icon_url?: string | null;
3083
+ };
3084
+ auth_mode: 'email_pin' | 'identity' | 'identity_unavailable' | 'external_sso' | 'external_unavailable';
3085
+ identity: {
3086
+ issuer_account_id: string;
3087
+ client_id: string;
3088
+ } | null;
3089
+ external_identity?: HelpDeskExternalIdentity | null;
3090
+ customer_can_mark_resolved: boolean;
3091
+ customer_can_attach_files: boolean;
3092
+ knowledge_base_enabled: boolean;
3093
+ portal_client: string;
3094
+ }
3095
+ interface HelpDeskCustomer {
3096
+ requester_id: string;
3097
+ email: string;
3098
+ display_name: string | null;
3099
+ assurance: 'identity' | 'email_pin' | 'external_sso';
3100
+ /** Company-session mailbox proof asserted by the trusted server. False forbids update emails. */
3101
+ email_verified?: boolean;
3102
+ email_updates?: boolean;
3103
+ needs_display_name: boolean;
3104
+ }
3105
+ interface HelpDeskSession {
3106
+ token: string;
3107
+ /** Absolute expiry in Unix seconds. */
3108
+ expires_at: number;
3109
+ customer: HelpDeskCustomer;
3110
+ }
3111
+ /** Why customer-specific UI is being told to reconsider its current session. */
3112
+ interface HelpDeskSessionChange {
3113
+ source: 'provider' | 'set' | 'clear' | 'refresh' | 'external' | 'renew';
3114
+ /** Present only for a company proof verified by the server, never a decoded browser JWT. */
3115
+ requesterId?: string;
3116
+ previousRequesterId?: string;
3117
+ /** True only for a proof initiated by this client's company-provider flow. */
3118
+ automatic?: boolean;
3119
+ }
3120
+ interface HelpDeskPinChallenge {
3121
+ challenge_id: string;
3122
+ binding_secret: string;
3123
+ expires_at: number;
3124
+ }
3125
+ interface HelpDeskVerifyPinOptions {
3126
+ challengeId: string;
3127
+ bindingSecret: string;
3128
+ code: string;
3129
+ }
3130
+ interface HelpDeskCustomerPatch {
3131
+ display_name?: string;
3132
+ email_updates?: boolean;
3133
+ }
3134
+ /** Refuse a write if its customer changed while the host composed the request. */
3135
+ interface HelpDeskRequestContext {
3136
+ expectedSessionToken?: string;
3137
+ }
3138
+ interface HelpDeskDraft {
3139
+ ticket_id: string;
3140
+ }
3141
+ interface HelpDeskTicketCreated {
3142
+ ticket_id: string;
3143
+ number: number;
3144
+ }
3145
+ interface HelpDeskCreateTicketOptions {
3146
+ /** Reuse the same draft ID after a failed/uncertain send; never create another draft to retry. */
3147
+ ticketId: string;
3148
+ subject: string;
3149
+ /** Help desk safe markup, not HTML. */
3150
+ body: string;
3151
+ attachments?: string[];
3152
+ }
3153
+ interface HelpDeskTicket {
3154
+ number: number;
3155
+ subject: string;
3156
+ status: 'open' | 'waiting_on_customer' | 'on_hold' | 'closed';
3157
+ close_reason: 'resolved' | 'duplicate' | null;
3158
+ awaiting_first_response: boolean;
3159
+ created_at: number;
3160
+ last_public_activity_at: number | null;
3161
+ muted: boolean;
3162
+ can_resolve?: boolean;
3163
+ feedback?: Record<string, unknown>;
3164
+ }
3165
+ /** Customer-visible events. Internal operator notes are never included. */
3166
+ interface HelpDeskEvent {
3167
+ event_id: string;
3168
+ type: string;
3169
+ seq: number;
3170
+ created_at: number;
3171
+ actor: {
3172
+ kind: string;
3173
+ label: string | null;
3174
+ avatar_handle: string | null;
3175
+ };
3176
+ body: unknown | null;
3177
+ attachments: Array<Record<string, unknown>>;
3178
+ status?: {
3179
+ from: string | null;
3180
+ to: string | null;
3181
+ };
3182
+ merged?: {
3183
+ number: number | null;
3184
+ };
3185
+ left_out?: {
3186
+ files: Array<{
3187
+ reason: string;
3188
+ content_type: string;
3189
+ size: number;
3190
+ }>;
3191
+ count: number;
3192
+ };
3193
+ }
3194
+ interface HelpDeskListTicketsOptions {
3195
+ status?: 'open' | 'closed';
3196
+ number?: number;
3197
+ cursor?: string;
3198
+ }
3199
+ interface HelpDeskTicketList {
3200
+ items: HelpDeskTicket[];
3201
+ next_cursor: string | null;
3202
+ }
3203
+ interface HelpDeskTimeline {
3204
+ events: HelpDeskEvent[];
3205
+ next_cursor: string | null;
3206
+ }
3207
+ interface HelpDeskTicketDetail extends HelpDeskTimeline {
3208
+ ticket: HelpDeskTicket;
3209
+ }
3210
+ interface HelpDeskReplyOptions {
3211
+ body: string;
3212
+ attachments?: string[];
3213
+ }
3214
+ interface HelpDeskReplyCreated {
3215
+ event_id: string;
3216
+ }
3217
+ interface HelpDeskAttachmentInput {
2901
3218
  name: string;
2902
- /** Content type (MIME) */
2903
- contentType: string;
2904
- /** Size in bytes */
2905
3219
  size: number;
2906
- /** Forge upload URL carrying the ISTK (upload session token) */
2907
- uploadUrl: string;
2908
- /** Upload session expiry (Unix seconds) */
2909
- expiresAt: number;
2910
- /**
2911
- * Whether the server minted this ingot (true) or staged the upload onto the
2912
- * ingot already holding the name (false, as `onNameConflict` allowed).
2913
- */
2914
- created: boolean;
3220
+ }
3221
+ interface HelpDeskAttachmentUpload {
3222
+ attachment_id: string;
3223
+ ingot_id: string;
3224
+ forge_url: string;
3225
+ expires_at: number;
3226
+ max_bytes: number;
3227
+ pending_until: number;
3228
+ }
3229
+ interface HelpDeskAttachmentDownload {
3230
+ url: string;
3231
+ expires_at: number;
3232
+ disposition: string;
3233
+ }
3234
+
3235
+ /**
3236
+ * One desk's customer client. Sessions stay in memory unless a host supplies a
3237
+ * provider. A provider must supply an hdt_ token, not a website identity JWT.
3238
+ */
3239
+ declare class HelpDeskClient {
3240
+ readonly desk: Readonly<HelpDeskDesk>;
3241
+ private readonly http;
3242
+ private readonly transfers;
3243
+ private readonly provider?;
3244
+ private readonly assertionProvider?;
3245
+ private authentication;
3246
+ private verifiedRequesterId;
3247
+ private provedSession;
3248
+ private readonly renewedTokens;
3249
+ private authorityRevision;
3250
+ private readonly listeners;
3251
+ private session;
3252
+ private token;
3253
+ private revision;
3254
+ private constructor();
3255
+ /** Discover a desk by its configured host, before any customer credentials are sent. */
3256
+ static connect(config: ResolvedConfig, options: HelpDeskConnectOptions): Promise<HelpDeskClient>;
3257
+ /**
3258
+ * Install a customer session answer. A company provider verifies restored
3259
+ * sessions again before use. Null stays signed out until refreshSession()
3260
+ * or authenticate() explicitly resumes the provider.
3261
+ */
3262
+ setSession(session: HelpDeskSession | null): void;
3263
+ private installSession;
3264
+ clearSession(): void;
3265
+ /**
3266
+ * Observe identity changes and explicit clear/refresh actions. A first provider
3267
+ * discovery is distinguished from a host replacing the customer during lookup.
3268
+ */
3269
+ subscribeSession(listener: (change: HelpDeskSessionChange) => void): () => void;
3270
+ /** Explicitly refresh the host-managed session, for example after a backend handoff. */
3271
+ refreshSession(): Promise<string | null>;
3272
+ /** Whether company identity can be established without customer interaction. */
3273
+ get hasIdentityProvider(): boolean;
3274
+ /** @internal Read an installed server-proven company bearer without invoking any identity provider. */
3275
+ verifiedSessionTokenFor(requesterId: string): string | null;
3276
+ getSessionToken(): Promise<string | null>;
3277
+ private rememberToken;
3278
+ private send;
3279
+ private establish;
3280
+ /** A public, short-lived challenge from the help desk's own Entropy service. */
3281
+ startExternalChallenge(): Promise<HelpDeskExternalChallenge>;
3282
+ /** Exchange only a purpose-specific company assertion, never an ordinary website token. */
3283
+ completeExternal(options: {
3284
+ assertion: string;
3285
+ nonce: string;
3286
+ }): Promise<HelpDeskSession>;
3287
+ private exchangeExternal;
3288
+ /** Silently establish/renew a company session. Concurrent calls share one proof. */
3289
+ authenticate(): Promise<HelpDeskSession | null>;
3290
+ private acceptExternalSession;
3291
+ /** Mint an opaque hosted-portal code from an assertion binding the registered redirect challenge. */
3292
+ createExternalHandoff(options: {
3293
+ assertion: string;
3294
+ nonce: string;
3295
+ redirectOrigin: string;
3296
+ }): Promise<{
3297
+ code: string;
3298
+ expires_at: number;
3299
+ }>;
3300
+ /** Redeem a hosted code only with the initiating browser's original verifier and nonce. */
3301
+ redeemExternal(options: {
3302
+ code: string;
3303
+ nonce: string;
3304
+ verifier: string;
3305
+ }): Promise<HelpDeskSession>;
3306
+ startPin(email: string): Promise<HelpDeskPinChallenge>;
3307
+ verifyPin(options: HelpDeskVerifyPinOptions): Promise<HelpDeskSession>;
3308
+ /** Identity completion still requires a server-approved desk portal origin. */
3309
+ completeIdentity(options: {
3310
+ token: string;
3311
+ }): Promise<HelpDeskSession>;
3312
+ getMe(): Promise<HelpDeskCustomer>;
3313
+ updateMe(patch: HelpDeskCustomerPatch, context?: HelpDeskRequestContext): Promise<HelpDeskCustomer>;
3314
+ createDraft(context?: HelpDeskRequestContext): Promise<HelpDeskDraft>;
3315
+ /** Retrying the same draft ID recovers the original ticket after a lost response. */
3316
+ createTicket(options: HelpDeskCreateTicketOptions, context?: HelpDeskRequestContext): Promise<HelpDeskTicketCreated>;
3317
+ listTickets(options?: HelpDeskListTicketsOptions): Promise<HelpDeskTicketList>;
3318
+ getTicket(number: number, options?: {
3319
+ response?: string;
3320
+ }): Promise<HelpDeskTicketDetail>;
3321
+ listEvents(number: number, cursor?: string): Promise<HelpDeskTimeline>;
3322
+ /** Replies have no client idempotency key: reconcile an uncertain response before retrying. */
3323
+ replyToTicket(number: number, options: HelpDeskReplyOptions, context?: HelpDeskRequestContext): Promise<HelpDeskReplyCreated>;
3324
+ resolveTicket(number: number, context?: HelpDeskRequestContext): Promise<void>;
3325
+ muteTicket(number: number, muted: boolean, context?: HelpDeskRequestContext): Promise<void>;
3326
+ /** Send an already-issued attachment directly to Forge, resolving only after publication is confirmed. */
3327
+ sendAttachment(uploadUrl: string, file: File | Blob, options?: SendUploadOptions): Promise<void>;
3328
+ /** Check/resume the original transfer; receiving every byte alone is not proof the attachment is published. */
3329
+ resumeAttachment(session: UploadSession, file: File | Blob, options?: ResumeUploadOptions): Promise<void>;
3330
+ initiateDraftAttachment(ticketId: string, file: HelpDeskAttachmentInput, context?: HelpDeskRequestContext): Promise<HelpDeskAttachmentUpload>;
3331
+ cancelDraftAttachment(ticketId: string, attachmentId: string, context?: HelpDeskRequestContext): Promise<void>;
3332
+ initiateTicketAttachment(number: number, file: HelpDeskAttachmentInput, context?: HelpDeskRequestContext): Promise<HelpDeskAttachmentUpload>;
3333
+ cancelTicketAttachment(number: number, attachmentId: string, context?: HelpDeskRequestContext): Promise<void>;
3334
+ attachmentDownload(attachmentId: string, number: number): Promise<HelpDeskAttachmentDownload>;
3335
+ /** Revoke this bearer, clearing only the session whose logout completed. */
3336
+ logout(): Promise<void>;
3337
+ }
3338
+
3339
+ /** The injected form's state; uncertain sends keep an exact snapshot until recovered. */
3340
+ type HelpDeskFormState = 'authenticating' | 'editing' | 'verifying' | 'submitting' | 'uncertain' | 'success' | 'destroyed';
3341
+ interface HelpDeskFormOptions {
3342
+ /** The element (or selector) to replace with a ticket form. */
3343
+ target: string | HTMLElement;
3344
+ /** Optional subject to begin a new request with. */
3345
+ subject?: string;
3346
+ /** Optional safe-markup description to begin a new request with. */
3347
+ body?: string;
3348
+ /** Show the default file picker when the desk permits customer uploads. Defaults to true. */
3349
+ attachments?: boolean;
2915
3350
  /**
2916
- * The upload the create staged onto the ingot (Core's `upload_id`): the id
2917
- * Forge keys the upload's session by, and the `contentVersion` the ingot
2918
- * reads once the upload publishes. Giving the upload up ends it with the
2919
- * file the create made through this id (`endUpload`). Null when the server
2920
- * named none.
3351
+ * Ask host code for a server-issued help desk session. This callback must
3352
+ * not construct a session from a browser-supplied user ID or email address.
3353
+ * Return null to use the desk's existing verification or hosted sign-in.
2921
3354
  */
2922
- uploadId: string | null;
3355
+ onAuthRequired?: () => HelpDeskSession | null | Promise<HelpDeskSession | null>;
3356
+ /** Called only after the service confirms the ticket. Callback errors never retry it. */
3357
+ onSuccess?: (ticket: HelpDeskTicketCreated) => void;
3358
+ /** Called after a failed request; uncertain sends retain a read-only exact snapshot for recovery. */
3359
+ onError?: (error: Error) => void;
3360
+ onStateChange?: (state: HelpDeskFormState) => void;
3361
+ /** Called when the customer chooses Cancel, after the form is destroyed. */
3362
+ onCancel?: () => void;
3363
+ }
3364
+ interface HelpDeskFormHandle {
3365
+ /** Remove the form and suppress pending UI updates and callbacks; does not log out. */
3366
+ destroy(): void;
3367
+ /** Clear the completed/idle form. Ignored while a request is pending or its send outcome is uncertain. */
3368
+ reset(): void;
3369
+ getState(): HelpDeskFormState;
2923
3370
  }
3371
+
3372
+ /** Customer ticket APIs and optional UI, isolated from Core/operator credentials. */
3373
+
3374
+ /** One-call website setup. No browser secrets or identity assertions are configured here. */
3375
+ type HelpDeskMountFormOptions = HelpDeskConnectOptions & HelpDeskFormOptions;
3376
+ type HelpDeskOpenFormOptions = HelpDeskConnectOptions & Omit<HelpDeskFormOptions, 'target'>;
3377
+ declare class HelpDeskModule {
3378
+ private readonly config;
3379
+ constructor(config: ResolvedConfig);
3380
+ /** Resolve a configured desk host and obtain its customer-only, headless API. */
3381
+ connect(options: HelpDeskConnectOptions): Promise<HelpDeskClient>;
3382
+ /**
3383
+ * Inject a ticket form, including email-code verification where the desk
3384
+ * enables it. A custom onAuthRequired callback may supply a server-issued
3385
+ * help desk session. Destroy the returned handle on unmount/account change.
3386
+ */
3387
+ mountForm(options: HelpDeskMountFormOptions): Promise<HelpDeskFormHandle>;
3388
+ /** Inject a form over an already-connected client that the host also drives headlessly. */
3389
+ mountClientForm(client: HelpDeskClient, options: HelpDeskFormOptions): HelpDeskFormHandle;
3390
+ /** Open a ticket form in the SDK's accessible modal. */
3391
+ openForm(options: HelpDeskOpenFormOptions): Promise<HelpDeskFormHandle>;
3392
+ /** Open a modal over a client whose company session the host also drives headlessly. */
3393
+ openClientForm(client: HelpDeskClient, options?: Omit<HelpDeskFormOptions, 'target'>): HelpDeskFormHandle;
3394
+ /** Bind existing support buttons, including ones added later. Cleanup closes this binding's form. */
3395
+ attach(selector: string, options: HelpDeskOpenFormOptions): () => void;
3396
+ }
3397
+
2924
3398
  /**
2925
- * What became of a given-up upload's file (`endUpload`): `deleted`, the vault
2926
- * holds it no longer (this end deleted it, or it was already gone); `kept`,
2927
- * this end deleted nothing, and a read of it by id (`get`) shows the file as
2928
- * it is now.
3399
+ * Products Module
3400
+ *
3401
+ * Namespace for SparkVault first-party products. Each product is a
3402
+ * self-contained surface (UI + API) the account can enable independently.
3403
+ * Identity, Notify, and the customer-facing Help Desk attach here.
2929
3404
  */
2930
- type UploadEnd = 'deleted' | 'kept';
2931
- /** A finalized ingot, returned by the high-level upload/replace flows. */
2932
- interface CreatedIngot {
2933
- /** Ingot ID */
2934
- id: string;
2935
- /** The name the ingot is stored under: the server's numbered name under `new_name`. */
2936
- name: string;
2937
- /** Content type (MIME) */
2938
- contentType: string;
2939
- /** Size in bytes */
2940
- size: number;
3405
+
3406
+ declare class ProductsModule {
3407
+ /** Identity verification product (passkey, OTP, SparkLink, social). */
3408
+ readonly identity: IdentityModule;
2941
3409
  /**
2942
- * Whether the upload minted this ingot (true) or replaced the content of an
2943
- * existing one (false): a same-name upload the name-conflict policy staged
2944
- * onto its holder, or any `replace`.
3410
+ * Notify product — the tenant/sender surface (send, sender-side inbox, status,
3411
+ * receipts, config). Distinct from `sv.notify`, which is the signed-in
3412
+ * recipient's own inbox.
2945
3413
  */
2946
- created: boolean;
3414
+ readonly notify: NotifyProductModule;
3415
+ /** Customer-only help desk API and optional injected ticket form. */
3416
+ readonly helpDesk: HelpDeskModule;
3417
+ /**
3418
+ * `http` defaults to a client over the same resolved config so constructing
3419
+ * this module standalone stays a one-argument call.
3420
+ */
3421
+ constructor(config: ResolvedConfig, http?: HttpClient);
2947
3422
  }
2948
- /** The discrete primitive returned by createDownloadLink. */
2949
- interface IngotDownloadLink {
2950
- /** Opaque published-content revision; null for legacy content. */
2951
- contentVersion: string | null;
2952
- /** Short-lived signed Forge download URL */
2953
- downloadUrl: string;
2954
- /** Ingot ID */
2955
- id: string;
2956
- /** Ingot name */
2957
- name: string;
2958
- /** Size in bytes */
2959
- size: number;
2960
- /** Content type (MIME) */
2961
- contentType: string;
3423
+
3424
+ /**
3425
+ * Vault Upload Module Types
3426
+ *
3427
+ * Types for the embedded vault upload widget.
3428
+ */
3429
+ /**
3430
+ * Branding configuration from vault upload info.
3431
+ */
3432
+ interface UploadBranding {
3433
+ /** Organization name */
3434
+ organizationName: string;
3435
+ /** Light theme logo URL */
3436
+ logoLightUrl: string | null;
3437
+ /** Dark theme logo URL */
3438
+ logoDarkUrl: string | null;
2962
3439
  }
2963
- /** Options for the createUpload primitive. */
2964
- interface CreateUploadOptions {
2965
- /** Unsealed vault the ingot belongs to */
2966
- vault: UnsealedVault;
2967
- /** Ingot name */
2968
- name: string;
2969
- /** Content type (MIME) */
2970
- contentType: string;
2971
- /** Declared upload size in bytes */
2972
- sizeBytes: number;
2973
- /** Slash-delimited folder path (find-or-created from root). */
3440
+ /**
3441
+ * Encryption information for the vault.
3442
+ */
3443
+ interface EncryptionInfo {
3444
+ /** Encryption algorithm (e.g., 'AES-256-GCM') */
3445
+ algorithm: string;
3446
+ /** Key derivation method (e.g., 'Triple Zero-Trust') */
3447
+ keyDerivation: string;
3448
+ /** Post-quantum protection status */
3449
+ postQuantum: string;
3450
+ }
3451
+ /**
3452
+ * Vault upload configuration from API.
3453
+ */
3454
+ interface VaultUploadConfig {
3455
+ /** Vault ID */
3456
+ vaultId: string;
3457
+ /** Vault name */
3458
+ vaultName: string;
3459
+ /** Maximum upload size in bytes */
3460
+ maxSizeBytes: number;
3461
+ /** Branding information */
3462
+ branding: UploadBranding;
3463
+ /** Encryption details */
3464
+ encryption: EncryptionInfo;
3465
+ /** Forge status */
3466
+ forgeStatus: 'active' | 'inactive';
3467
+ }
3468
+ /**
3469
+ * Options for upload().
3470
+ * - Without `target`: Opens a dialog (modal)
3471
+ * - With `target`: Renders inline into the specified element
3472
+ */
3473
+ interface UploadOptions {
3474
+ /** Vault ID to upload to */
3475
+ vaultId: string;
3476
+ /**
3477
+ * Target element for inline rendering. Can be:
3478
+ * - A CSS selector string (e.g., "#upload-container")
3479
+ * - An HTMLElement reference
3480
+ * - Omitted for dialog mode (default)
3481
+ */
3482
+ target?: string | HTMLElement;
3483
+ /** Override backdrop blur for this dialog (uses global config if omitted) */
3484
+ backdropBlur?: boolean;
3485
+ /** Hide "Upload Another File" button on success screen (for single-file flows) */
3486
+ hideUploadAnother?: boolean;
3487
+ /**
3488
+ * Skip the success screen entirely. On completion the SDK fires onSuccess
3489
+ * and closes the dialog, so a host site can render its own post-upload UI.
3490
+ */
3491
+ hideSuccessScreen?: boolean;
3492
+ /**
3493
+ * Upload this File directly, skipping the SDK's drop-zone. The host owns
3494
+ * file selection (its own button, picker, or drop target) and hands the
3495
+ * File to the SDK, which shows only the secure-upload progress dialog.
3496
+ */
3497
+ file?: File;
3498
+ /**
3499
+ * Vault Access Token, sent only on the upload's POST, where it supplies the
3500
+ * vault key in place of the System DVAK the widget setting provisions; a
3501
+ * read-only VAT is refused 403. It does not lift the vault's Embedded Upload
3502
+ * Widget setting: the widget opens by reading the vault's upload info, a
3503
+ * request that carries no VAT and is refused (UPLOAD_SOURCE_DISABLED) while
3504
+ * the setting is off.
3505
+ */
3506
+ token?: string;
3507
+ /**
3508
+ * Slash-delimited folder path within the vault (e.g. "Accounts/001xx").
3509
+ * Missing path segments are find-or-created. Omitted means the vault root.
3510
+ */
2974
3511
  folder?: string;
2975
- /** Existing folder ID to upload into. Mutually exclusive with `folder`. */
2976
- folderId?: string;
2977
- /** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
2978
- contentHmac?: string;
2979
- /** What a name already held in the target folder does; omitted means the server's `upsert`. */
2980
- onNameConflict?: NameConflictPolicy;
3512
+ /** Callback when upload completes successfully */
3513
+ onSuccess?: (result: UploadResult) => void;
3514
+ /** Callback when an error occurs */
3515
+ onError?: (error: Error) => void;
3516
+ /** Callback when user cancels */
3517
+ onCancel?: () => void;
3518
+ /** Callback for upload progress */
3519
+ onProgress?: (progress: UploadProgress) => void;
3520
+ /**
3521
+ * Called once the widget has read the vault's upload page and shows its
3522
+ * form (or, given a `file`, starts uploading it). A failure after it is the
3523
+ * widget's to show, with the way on its failure leaves (the same file
3524
+ * again, or another); one before it means the upload page could not load.
3525
+ */
3526
+ onReady?: () => void;
2981
3527
  }
2982
- /** Options for the high-level upload flow. */
2983
- interface UploadIngotOptions {
2984
- /** File or Blob to upload */
2985
- file: File | Blob;
2986
- /** Optional name (defaults to file name) */
2987
- name?: string;
3528
+ /** Options for attach() - binds upload to element clicks */
3529
+ interface UploadAttachOptions {
3530
+ /** Vault ID to upload to */
3531
+ vaultId: string;
3532
+ /** Callback when upload completes successfully */
3533
+ onSuccess?: (result: UploadResult) => void;
3534
+ /** Callback when an error occurs */
3535
+ onError?: (error: Error) => void;
3536
+ /** Callback when user cancels */
3537
+ onCancel?: () => void;
3538
+ /** Callback for upload progress */
3539
+ onProgress?: (progress: UploadProgress) => void;
3540
+ }
3541
+ /**
3542
+ * Upload progress information.
3543
+ */
3544
+ interface UploadProgress {
3545
+ /** Bytes uploaded */
3546
+ bytesUploaded: number;
3547
+ /** Total bytes */
3548
+ bytesTotal: number;
3549
+ /** Percentage (0-100) */
3550
+ percentage: number;
3551
+ /** Current phase */
3552
+ phase: 'uploading' | 'ceremony' | 'complete';
3553
+ }
3554
+ /**
3555
+ * Successful upload result.
3556
+ */
3557
+ interface UploadResult {
3558
+ /** Ingot ID */
3559
+ ingotId: string;
3560
+ /** Vault ID */
3561
+ vaultId: string;
3562
+ /** Original filename */
3563
+ filename: string;
3564
+ /** File size in bytes */
3565
+ sizeBytes: number;
3566
+ /** Upload time in UTC, as "YYYY-MM-DD HH:MM:SS UTC" */
3567
+ uploadTime: string;
3568
+ }
3569
+
3570
+ /**
3571
+ * Vaults Module
3572
+ *
3573
+ * Create and manage encrypted vaults (the control plane). Uses Triple
3574
+ * Zero-Trust encryption (SVMK + AMK + VMK). Ingot, folder, spark, and entropy
3575
+ * operations live in their own modules; this module owns the vault record,
3576
+ * its sharing/upload configuration, and the browser upload widget.
3577
+ */
3578
+
3579
+ /**
3580
+ * Callable upload interface with methods.
3581
+ * Allows both `sv.vaults.upload(options)` and `sv.vaults.upload.attach(selector, options)`.
3582
+ */
3583
+ interface UploadCallable {
3584
+ (options: UploadOptions): Promise<UploadResult>;
3585
+ attach(selector: string, options: UploadAttachOptions): () => void;
3586
+ close(): void;
3587
+ /** Open the upload widget as a popup. Equivalent to calling `upload(options)`. */
3588
+ pop(options: UploadOptions): Promise<UploadResult>;
3589
+ /** Render the upload widget inline. Equivalent to `upload({ ...options, target })`. */
3590
+ render(options: UploadOptions): Promise<UploadResult>;
3591
+ }
3592
+ declare class VaultsModule {
3593
+ private readonly http;
3594
+ private readonly uploadModule;
2988
3595
  /**
2989
- * Content type (the file's own `type` if not provided). A file of no type is
2990
- * sent with none, and Core stores the type the registry lists for the name's
2991
- * extension, else `application/octet-stream`.
3596
+ * Upload to a vault with public upload enabled.
3597
+ *
3598
+ * @example Dialog mode
3599
+ * const result = await sv.vaults.upload({ vaultId: 'vlt_abc123' });
3600
+ *
3601
+ * @example Attach to clicks
3602
+ * sv.vaults.upload.attach('.upload-btn', { vaultId: 'vlt_abc123' });
3603
+ *
3604
+ * @example Inline mode
3605
+ * sv.vaults.upload({ vaultId: 'vlt_abc123', target: '#upload-area' });
3606
+ */
3607
+ readonly upload: UploadCallable;
3608
+ constructor(config: ResolvedConfig, http: HttpClient);
3609
+ /**
3610
+ * Create a new encrypted vault.
3611
+ * IMPORTANT: Store the VMK securely - it cannot be recovered!
3612
+ *
3613
+ * @example
3614
+ * const vault = await sv.vaults.create({ name: 'My Vault' });
3615
+ * console.log('Save this VMK:', vault.vmk);
3616
+ */
3617
+ create(options: CreateVaultOptions): Promise<Vault>;
3618
+ /**
3619
+ * Unseal a vault to access its contents.
3620
+ * Returns a short-lived Vault Access Token (VAT).
3621
+ *
3622
+ * @param vaultId - The vault to unseal.
3623
+ * @param key - The vault's VMK, or a DVAK token issued for it.
3624
+ *
3625
+ * @example
3626
+ * const unsealed = await sv.vaults.unseal('vlt_abc', vmk);
3627
+ * const delegated = await sv.vaults.unseal('vlt_abc', 'dvak_...');
3628
+ * console.log('Token:', unsealed.vatToken);
3629
+ */
3630
+ unseal(vaultId: string, key: string): Promise<UnsealedVault>;
3631
+ /**
3632
+ * List vaults for the account. Results are paginated (server default 100 per
3633
+ * page, max 500); follow `nextCursor` to fetch subsequent pages.
3634
+ *
3635
+ * @example
3636
+ * let cursor: string | undefined;
3637
+ * do {
3638
+ * const page = await sv.vaults.list({ cursor });
3639
+ * page.vaults.forEach((v) => console.log(v.name));
3640
+ * cursor = page.nextCursor;
3641
+ * } while (cursor);
3642
+ */
3643
+ list(options?: ListVaultsOptions): Promise<VaultPage>;
3644
+ /**
3645
+ * Get a single vault's detail.
3646
+ *
3647
+ * @example
3648
+ * const vault = await sv.vaults.get('vlt_abc');
3649
+ * console.log(vault.status, vault.ingotCount);
3650
+ */
3651
+ get(vaultId: string): Promise<VaultDetail>;
3652
+ /**
3653
+ * Rename a vault.
3654
+ *
3655
+ * @example
3656
+ * await sv.vaults.update('vlt_abc', { name: 'Renamed Vault' });
3657
+ */
3658
+ update(vaultId: string, options: {
3659
+ name: string;
3660
+ }): Promise<UpdatedVault>;
3661
+ /**
3662
+ * Seal a vault, revoking all active access tokens.
3663
+ *
3664
+ * @example
3665
+ * await sv.vaults.seal('vlt_abc');
3666
+ */
3667
+ seal(vaultId: string): Promise<void>;
3668
+ /**
3669
+ * Schedule permanent deletion in seven days and immediately lock all vault access.
3670
+ * Company admins only; cancelDeletion can abort this schedule before its deadline.
3671
+ * A vault whose irreversible cleanup has already started answers that cleanup
3672
+ * (`status: 'deleting'`) instead, which nothing can cancel.
3673
+ *
3674
+ * Requires the vault's exact name as confirmation, matched case-sensitively.
3675
+ * The name is sent base64(UTF-8) as the `X-Confirm-Name-B64` header so a vault
3676
+ * named with any Unicode (emoji, CJK, the U+202F in macOS-style names) is
3677
+ * deletable — an HTTP header value cannot carry non-latin1 characters.
3678
+ *
3679
+ * @example
3680
+ * await sv.vaults.delete('vlt_abc', 'My Vault');
3681
+ */
3682
+ delete(vaultId: string, name: string): Promise<ScheduledVaultDeletion | StartedVaultDeletion>;
3683
+ /** Cancel this exact deletion schedule before its deadline; company admins only. */
3684
+ cancelDeletion(vaultId: string, deletionScheduleId: string): Promise<VaultDetail>;
3685
+ /**
3686
+ * Get a vault's public-sharing configuration. Every sharing write below
3687
+ * answers the same configuration as that write left it.
3688
+ *
3689
+ * @example
3690
+ * const sharing = await sv.vaults.getSharingConfig('vlt_abc');
3691
+ */
3692
+ getSharingConfig(vaultId: string): Promise<VaultSharingConfig>;
3693
+ /**
3694
+ * Enable public sharing for a vault.
3695
+ *
3696
+ * @example
3697
+ * await sv.vaults.enableSharing('vlt_abc', vmk, { sessionLengthSeconds: 3600 });
3698
+ */
3699
+ enableSharing(vaultId: string, vmk: string, options?: VaultSharingOptions): Promise<VaultSharingConfig>;
3700
+ /**
3701
+ * Disable public sharing for a vault.
3702
+ *
3703
+ * @example
3704
+ * await sv.vaults.disableSharing('vlt_abc');
3705
+ */
3706
+ disableSharing(vaultId: string): Promise<VaultSharingConfig>;
3707
+ /**
3708
+ * Update a vault's sharing configuration (without changing enabled state).
3709
+ *
3710
+ * Making every ingot public publishes each file to anyone holding its URL,
3711
+ * so the API accepts `allIngotsPublic: true` only with a read-write VAT for
3712
+ * the vault: pass the unsealed vault for that change.
3713
+ *
3714
+ * @example
3715
+ * await sv.vaults.updateSharingConfig('vlt_abc', { sessionLengthSeconds: 1800 });
3716
+ *
3717
+ * @example Make every ingot public
3718
+ * const unsealed = await sv.vaults.unseal('vlt_abc', vmk);
3719
+ * await sv.vaults.updateSharingConfig('vlt_abc', { allIngotsPublic: true }, unsealed);
3720
+ */
3721
+ updateSharingConfig(vaultId: string, config: VaultSharingOptions, vault?: UnsealedVault): Promise<VaultSharingConfig>;
3722
+ /**
3723
+ * Get a vault's access-log retention window.
3724
+ *
3725
+ * @example
3726
+ * const { retentionSeconds } = await sv.vaults.getAccessLogRetention('vlt_abc');
3727
+ */
3728
+ getAccessLogRetention(vaultId: string): Promise<AccessLogRetention>;
3729
+ /**
3730
+ * Update a vault's access-log retention window.
3731
+ *
3732
+ * @example
3733
+ * await sv.vaults.updateAccessLogRetention('vlt_abc', 7776000);
2992
3734
  */
2993
- contentType?: string;
2994
- /** Slash-delimited folder path (find-or-created from root). */
2995
- folder?: string;
2996
- /** Existing folder ID to upload into. Mutually exclusive with `folder`. */
2997
- folderId?: string;
2998
- /** Vault-keyed plaintext HMAC (43-char base64url) to store on the ingot. */
2999
- contentHmac?: string;
3000
- /** What a name already held in the target folder does; omitted means the server's `upsert`. */
3001
- onNameConflict?: NameConflictPolicy;
3002
- /** Progress callback for the Forge/TUS transfer */
3003
- onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
3004
- }
3005
- /**
3006
- * The upload session a file's bytes go to, which `sendUpload` hands over once
3007
- * Forge opens it (`onSessionCreated`): what `resumeUpload` continues the
3008
- * upload in. Its URL addresses the upload itself (a request to it can end the
3009
- * upload), so keep it in memory, never in a log or a URL a person shares.
3010
- */
3011
- interface UploadSession {
3012
- /** The session's URL on Forge. */
3013
- readonly sessionUrl: string;
3014
- }
3015
- /** Options for sendUpload. */
3016
- interface SendUploadOptions {
3017
- /** Cancels the transfer. */
3018
- signal?: AbortSignal;
3019
- /** Bytes sent so far and the file size; never runs backwards. */
3020
- onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
3735
+ updateAccessLogRetention(vaultId: string, seconds: number): Promise<AccessLogRetention>;
3021
3736
  /**
3022
- * Hands over the upload's session once Forge opens it, before the first
3023
- * byte is sent, so the caller can `resumeUpload` the upload in it later:
3024
- * after `upload_received_publishing`, to learn whether the server published
3025
- * it, or after a failure, to send only the bytes the server lacks. A throw
3026
- * here ends the transfer with that error.
3737
+ * Get a vault's upload-channel configuration. Every upload write below
3738
+ * answers the same configuration as that write left it: both channels, the
3739
+ * shared settings, and the portal's URL while the portal is on.
3740
+ *
3741
+ * @example
3742
+ * const upload = await sv.vaults.getUploadConfig('vlt_abc');
3027
3743
  */
3028
- onSessionCreated?: (session: UploadSession) => void;
3029
- }
3030
- /** Options for resumeUpload. */
3031
- type ResumeUploadOptions = Omit<SendUploadOptions, 'onSessionCreated'>;
3032
- /** Options for replacing an existing ingot's content. */
3033
- interface ReplaceIngotOptions {
3034
- /** File or Blob to upload as the new content */
3035
- file: File | Blob;
3036
- /** Optional new name (defaults to file name) */
3037
- name?: string;
3038
- /** Vault-keyed plaintext HMAC (43-char base64url) for the NEW content. */
3039
- contentHmac?: string;
3744
+ getUploadConfig(vaultId: string): Promise<VaultUploadSettings>;
3040
3745
  /**
3041
- * Content type (the file's own `type` if not provided). A file of no type
3042
- * keeps the type the ingot stores, which Core reads from the name by its
3043
- * extension only when it is `application/octet-stream` or unparsable.
3746
+ * Enable the public upload portal for a vault.
3747
+ *
3748
+ * @example
3749
+ * await sv.vaults.enableUploadPortal('vlt_abc', vmk);
3044
3750
  */
3045
- contentType?: string;
3046
- /** Progress callback for the Forge/TUS transfer */
3047
- onProgress?: (bytesUploaded: number, bytesTotal: number) => void;
3048
- }
3049
- /** Options for list. */
3050
- interface ListIngotsOptions {
3051
- /** Page size */
3052
- limit?: number;
3053
- /** Pagination cursor */
3054
- cursor?: string;
3751
+ enableUploadPortal(vaultId: string, vmk: string): Promise<VaultUploadSettings>;
3055
3752
  /**
3056
- * Sort field (name | size | content_type | created | access_count): it
3057
- * orders only the page answered, never the list across pages
3753
+ * Disable the public upload portal for a vault.
3754
+ *
3755
+ * @example
3756
+ * await sv.vaults.disableUploadPortal('vlt_abc');
3058
3757
  */
3059
- sortBy?: string;
3060
- /** Sort direction of the page */
3061
- sortOrder?: 'asc' | 'desc';
3062
- }
3063
- /** Options for listContents. */
3064
- interface ListContentsOptions {
3065
- /** Folder to list (null/omitted lists the vault root) */
3066
- folderId?: string | null;
3067
- /** Most children on one page (1-500; server default 100) */
3068
- limit?: number;
3069
- /** A prior page's `nextPageToken`, for the same folder and order */
3070
- pageToken?: string;
3071
- /** Ingot creation order; `desc` (newest first) by default */
3072
- sortOrder?: 'asc' | 'desc';
3073
- }
3074
- /**
3075
- * One page of a folder's listing. The folder's children run as one sequence
3076
- * across its pages: every direct subfolder first, in a stable order that is
3077
- * not by name, then every ingot directly in the folder in creation order
3078
- * (newest first under `desc`). A page holds at most `limit` children in all,
3079
- * so one page can hold the last subfolders and the first ingots, and a page
3080
- * can hold fewer than `limit`, even none, and still not be the last: follow
3081
- * `nextPageToken`, never the count. Ordering by name, size or type is the
3082
- * caller's, over the children it holds.
3083
- */
3084
- interface FolderContents {
3085
- /** The folder listed, on every page; null at the vault root */
3086
- folder: {
3087
- id: string;
3088
- name: string;
3089
- parentId: string | null;
3090
- } | null;
3091
- /** Root → … → the folder listed, on every page */
3092
- breadcrumb: FolderBreadcrumbItem[];
3093
- /** This page's subfolders */
3094
- folders: Folder[];
3095
- /** This page's ingots */
3096
- ingots: Ingot[];
3097
- /** The next page's `pageToken`; null on the last page */
3098
- nextPageToken: string | null;
3099
- }
3100
- /** Options for search. */
3101
- interface SearchIngotsOptions {
3758
+ disableUploadPortal(vaultId: string): Promise<VaultUploadSettings>;
3102
3759
  /**
3103
- * A part of the ingot's file name, matched ignoring letter case, accents
3104
- * and Unicode compatibility forms (`resume` matches `Résumé.pdf`, `strasse`
3105
- * matches `Straße.txt`); a whole name matches too. Results come in creation
3106
- * order, newest first unless `sortOrder` is `asc`, and a page can hold none
3107
- * while `nextCursor` is set: follow it. Text no name can hold is refused
3108
- * (400).
3760
+ * Enable the upload widget for a vault.
3761
+ *
3762
+ * @example
3763
+ * await sv.vaults.enableUploadWidget('vlt_abc', vmk);
3109
3764
  */
3110
- q?: string;
3765
+ enableUploadWidget(vaultId: string, vmk: string): Promise<VaultUploadSettings>;
3111
3766
  /**
3112
- * The MIME type to match, in lowercase: a family (`image`, `video`,
3113
- * `audio`, `text`, `application`, ...), which every type under it matches,
3114
- * or an exact type (`application/pdf`), which matches that type whatever
3115
- * its parameters. A well-formed value no ingot carries matches none; the
3116
- * server refuses a value that is neither.
3767
+ * Disable the upload widget for a vault.
3768
+ *
3769
+ * @example
3770
+ * await sv.vaults.disableUploadWidget('vlt_abc');
3117
3771
  */
3118
- fileType?: string;
3119
- /** Scope the search to one folder (whole vault when omitted) */
3120
- folderId?: string;
3121
- /** Minimum size in bytes */
3122
- minSize?: number;
3123
- /** Maximum size in bytes */
3124
- maxSize?: number;
3125
- /** Page size */
3126
- limit?: number;
3127
- /** Pagination cursor */
3128
- cursor?: string;
3129
- /** Sort direction */
3130
- sortOrder?: 'asc' | 'desc';
3131
- }
3132
- /** A page of ingots. */
3133
- interface IngotPage {
3134
- /** Ingots on this page */
3135
- ingots: Ingot[];
3136
- /** Cursor for the next page, when more results exist */
3137
- nextCursor?: string;
3138
- }
3139
- /** Ingot sharing configuration. */
3140
- interface IngotSharingConfig {
3141
- /** Whether the ingot is shared */
3142
- shared: boolean;
3143
- /** Visibility mode */
3144
- visibility?: 'invite_only' | 'authenticated' | 'public';
3145
- /** The share's permanent files.sv URL, the link its recipients open; null while the ingot is not shared */
3146
- publicUrl: string | null;
3147
- /** The share's link code (the URL's last segment); null while the ingot is not shared */
3148
- linkCode: string | null;
3149
- /** Whether the vault's public file sharing is on */
3150
- sharingEnabled: boolean;
3151
- /** Whether the vault makes every ingot public, which pins this one to public */
3152
- vaultAllIngotsPublic: boolean;
3153
- /** The vault's share recipient session length, in seconds */
3154
- sessionLengthSeconds: number;
3155
- /** Active invites */
3156
- invites?: IngotInvite[];
3157
- }
3158
- /** Options for updateSharingConfig. */
3159
- interface UpdateIngotSharingOptions {
3160
- /** Whether the ingot is shared */
3161
- shared?: boolean;
3162
- /** Visibility mode */
3163
- visibility?: 'invite_only' | 'authenticated' | 'public';
3164
- }
3165
- /** A sharing invite on an ingot. */
3166
- interface IngotInvite {
3167
- /** Invite ID */
3168
- id: string;
3169
- /** Invited identity (email/phone) */
3170
- identity: string;
3171
- /** Identity type */
3172
- identityType: 'email' | 'phone';
3173
- /** When this identity was invited (Unix seconds) */
3174
- invitedAt: number;
3175
- }
3176
- /** An invitation addInvite made or resent. */
3177
- interface IngotInvitation extends IngotInvite {
3178
- /** The URL this invitee was sent: the share's files.sv URL, with their own token when the share invites several */
3179
- shareUrl: string;
3180
- /** Whether the invitation was delivered by email or text */
3181
- delivered: boolean;
3182
- }
3183
- /**
3184
- * An ingot access-log entry: a download that delivered the file, a SparkLink
3185
- * open of it included. The server records an access as the download that
3186
- * delivered it, so `download` is the one action.
3187
- */
3188
- interface IngotAccessLog {
3772
+ disableUploadWidget(vaultId: string): Promise<VaultUploadSettings>;
3189
3773
  /**
3190
- * The entry's time (Unix seconds) as a string. The server issues no entry id,
3191
- * so entries in the same second share it.
3774
+ * Update a vault's upload settings (max size, notification email).
3775
+ *
3776
+ * @example
3777
+ * await sv.vaults.updateUploadConfig('vlt_abc', { maxSizeBytes: 1048576 });
3192
3778
  */
3193
- id: string;
3194
- /** What the access was */
3195
- action: 'download';
3196
- /** Who accessed: a member's email, an API key's name, or a SparkLink visitor's identity */
3197
- identity: string;
3198
- /** Source IP address */
3199
- ipAddress: string;
3200
- /** Client user agent */
3201
- userAgent: string;
3202
- /** Event timestamp (Unix seconds) */
3203
- timestamp: number;
3204
- }
3205
- /** A page of access logs. */
3206
- interface IngotAccessLogPage {
3207
- /** Log entries on this page */
3208
- logs: IngotAccessLog[];
3209
- /** Cursor for the next page, when more results exist */
3210
- nextCursor?: string;
3211
- }
3212
- /** Options for getAccessLogs. */
3213
- interface AccessLogsOptions {
3214
- /** Page size */
3215
- limit?: number;
3216
- /** Pagination cursor */
3217
- cursor?: string;
3218
- }
3219
- /** One hash-check hit: this HMAC exists on an active ingot in the vault. */
3220
- interface HashCheckMatch {
3221
- content_hmac: string;
3222
- ingot_id: string;
3223
- }
3224
- interface HashCheckResponse {
3225
- found: HashCheckMatch[];
3779
+ updateUploadConfig(vaultId: string, config: UpdateVaultUploadOptions): Promise<VaultUploadSettings>;
3780
+ private toggleUploadChannel;
3781
+ private validateCreateOptions;
3226
3782
  }
3227
3783
 
3228
3784
  /**
@@ -4383,7 +4939,7 @@ declare const logger: {
4383
4939
  /**
4384
4940
  * SparkVault JavaScript SDK
4385
4941
  *
4386
- * A unified SDK for Identity, Vaults, Ingots, Folders, Sparks, and Entropy.
4942
+ * A unified SDK for Identity, Help Desk, Notify, Vaults, Ingots, Folders, Sparks, and Entropy.
4387
4943
  *
4388
4944
  * @example CDN Usage (Recommended)
4389
4945
  * ```html
@@ -4412,7 +4968,7 @@ declare const logger: {
4412
4968
  */
4413
4969
 
4414
4970
  declare class SparkVault {
4415
- /** First-party products (Identity verification). */
4971
+ /** First-party products: Identity, Notify, and customer-facing Help Desk. */
4416
4972
  readonly products: ProductsModule;
4417
4973
  /** Encrypted vault control plane (create, unseal, sharing, upload config). */
4418
4974
  readonly vaults: VaultsModule;
@@ -4465,5 +5021,5 @@ declare global {
4465
5021
  }
4466
5022
  }
4467
5023
 
4468
- export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UnauthorizedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
4469
- export type { AccessLogRetention, AccessLogsOptions, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifyRecipientState, NotifyReportableVerificationLevel, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusRecipient, NotifySendSummary, NotifySuppressionReason, NotifyVerificationLevel, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, Spark, SparkInviteResend, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };
5024
+ export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, HelpDeskClient, HelpDeskModule, IdentityModule, IdentityProviderError, IngotsModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UnauthorizedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
5025
+ export type { AccessLogRetention, AccessLogsOptions, CreateFolderOptions, CreateNotifySendOptions, CreateSparkOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, HealthCheckOptions, HealthCheckResult, HelpDeskAttachmentDownload, HelpDeskAttachmentInput, HelpDeskAttachmentUpload, HelpDeskConnectOptions, HelpDeskCreateTicketOptions, HelpDeskCustomer, HelpDeskCustomerPatch, HelpDeskDesk, HelpDeskDraft, HelpDeskEvent, HelpDeskExternalChallenge, HelpDeskExternalIdentity, HelpDeskFormHandle, HelpDeskFormOptions, HelpDeskFormState, HelpDeskIdentityRequest, HelpDeskListTicketsOptions, HelpDeskMountFormOptions, HelpDeskOpenFormOptions, HelpDeskPinChallenge, HelpDeskReplyCreated, HelpDeskReplyOptions, HelpDeskRequestContext, HelpDeskSession, HelpDeskSessionChange, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, AttachOptions as IdentityAttachOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownloadLink, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigDestinations, NotifyConfigDestinationsPatch, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyDestinationFailureReason, NotifyDestinationKind, NotifyDestinationReason, NotifyDestinationSkipReason, NotifyDestinationState, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifyRecipientState, NotifyReportableVerificationLevel, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusDestination, NotifySendStatusRecipient, NotifySendSummary, NotifySendSummaryDestination, NotifySlackDestination, NotifySuppressionReason, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyVerificationLevel, NotifyWebhookDestination, NotifyWebhookDestinationRead, QuotaResource, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, Spark, SparkInviteResend, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };