@sparkvault/sdk-js 19.0.0 → 19.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.
Files changed (132) hide show
  1. package/README.md +26 -4
  2. package/dist/npm/chunks/index-BnP-2w0t.cjs +13025 -0
  3. package/dist/npm/chunks/index-BnP-2w0t.cjs.map +1 -0
  4. package/dist/npm/chunks/index-CgR08uMG.mjs +12960 -0
  5. package/dist/npm/chunks/index-CgR08uMG.mjs.map +1 -0
  6. package/dist/npm/identity.cjs +23 -0
  7. package/dist/npm/identity.cjs.map +1 -0
  8. package/dist/npm/identity.mjs +12 -0
  9. package/dist/npm/identity.mjs.map +1 -0
  10. package/dist/{index.cjs → npm/index.cjs} +799 -13755
  11. package/dist/npm/index.cjs.map +1 -0
  12. package/dist/{index.mjs → npm/index.mjs} +200 -13155
  13. package/dist/npm/index.mjs.map +1 -0
  14. package/dist/sparkvault-identity.js +2 -0
  15. package/dist/sparkvault-identity.js.map +1 -0
  16. package/dist/sparkvault.js +1 -1
  17. package/dist/types/identity.d.ts +8 -0
  18. package/dist/{index.d.ts → types/index.d.ts} +4 -790
  19. package/dist/types/shared/errors-C-gjmGBs.d.ts +800 -0
  20. package/package.json +20 -9
  21. package/dist/api-base.d.ts +0 -116
  22. package/dist/auto-init.d.ts +0 -32
  23. package/dist/config.d.ts +0 -79
  24. package/dist/entropy/index.d.ts +0 -35
  25. package/dist/entropy/types.d.ts +0 -32
  26. package/dist/errors.d.ts +0 -146
  27. package/dist/folders/index.d.ts +0 -102
  28. package/dist/folders/types.d.ts +0 -91
  29. package/dist/health.d.ts +0 -18
  30. package/dist/http.d.ts +0 -46
  31. package/dist/index.cjs.map +0 -1
  32. package/dist/index.mjs.map +0 -1
  33. package/dist/ingots/fetch-download.d.ts +0 -78
  34. package/dist/ingots/history.d.ts +0 -4
  35. package/dist/ingots/index.d.ts +0 -388
  36. package/dist/ingots/revision.d.ts +0 -4
  37. package/dist/ingots/types.d.ts +0 -556
  38. package/dist/logger.d.ts +0 -32
  39. package/dist/notify/index.d.ts +0 -154
  40. package/dist/notify/types.d.ts +0 -232
  41. package/dist/products/help-desk/client.d.ts +0 -198
  42. package/dist/products/help-desk/desk-id.d.ts +0 -2
  43. package/dist/products/help-desk/form-draft.d.ts +0 -37
  44. package/dist/products/help-desk/form-types.d.ts +0 -123
  45. package/dist/products/help-desk/form.d.ts +0 -83
  46. package/dist/products/help-desk/index.d.ts +0 -47
  47. package/dist/products/help-desk/kb-client.d.ts +0 -48
  48. package/dist/products/help-desk/kb-types.d.ts +0 -59
  49. package/dist/products/help-desk/modal.d.ts +0 -8
  50. package/dist/products/help-desk/styles.d.ts +0 -9
  51. package/dist/products/help-desk/support-analytics-types.d.ts +0 -32
  52. package/dist/products/help-desk/support-analytics.d.ts +0 -3
  53. package/dist/products/help-desk/support-brand.d.ts +0 -49
  54. package/dist/products/help-desk/support-controller.d.ts +0 -4
  55. package/dist/products/help-desk/support-history.d.ts +0 -38
  56. package/dist/products/help-desk/support-launcher.d.ts +0 -12
  57. package/dist/products/help-desk/support-styles.d.ts +0 -14
  58. package/dist/products/help-desk/support-types.d.ts +0 -66
  59. package/dist/products/help-desk/support-view.d.ts +0 -173
  60. package/dist/products/help-desk/types.d.ts +0 -285
  61. package/dist/products/help-desk/widget-identity.d.ts +0 -32
  62. package/dist/products/identity/api.d.ts +0 -237
  63. package/dist/products/identity/container.d.ts +0 -44
  64. package/dist/products/identity/dialog-launcher.d.ts +0 -133
  65. package/dist/products/identity/federation-flow.d.ts +0 -31
  66. package/dist/products/identity/handlers/otp-handler.d.ts +0 -69
  67. package/dist/products/identity/handlers/passkey-handler.d.ts +0 -105
  68. package/dist/products/identity/handlers/sparklink-handler.d.ts +0 -34
  69. package/dist/products/identity/index.d.ts +0 -296
  70. package/dist/products/identity/inline-container.d.ts +0 -53
  71. package/dist/products/identity/methods.d.ts +0 -19
  72. package/dist/products/identity/modal.d.ts +0 -51
  73. package/dist/products/identity/pending-signin.d.ts +0 -102
  74. package/dist/products/identity/popup-launcher.d.ts +0 -73
  75. package/dist/products/identity/renderer.d.ts +0 -525
  76. package/dist/products/identity/state.d.ts +0 -84
  77. package/dist/products/identity/styles.d.ts +0 -31
  78. package/dist/products/identity/types.d.ts +0 -561
  79. package/dist/products/identity/utils/cooldown-timer.d.ts +0 -73
  80. package/dist/products/identity/utils.d.ts +0 -85
  81. package/dist/products/identity/views/backup-verify.d.ts +0 -42
  82. package/dist/products/identity/views/base.d.ts +0 -51
  83. package/dist/products/identity/views/error.d.ts +0 -65
  84. package/dist/products/identity/views/icons.d.ts +0 -41
  85. package/dist/products/identity/views/identity-input.d.ts +0 -80
  86. package/dist/products/identity/views/index.d.ts +0 -20
  87. package/dist/products/identity/views/loading.d.ts +0 -23
  88. package/dist/products/identity/views/method-button.d.ts +0 -14
  89. package/dist/products/identity/views/method-select.d.ts +0 -42
  90. package/dist/products/identity/views/origin-not-allowed.d.ts +0 -25
  91. package/dist/products/identity/views/otp-verify.d.ts +0 -58
  92. package/dist/products/identity/views/passkey-auto.d.ts +0 -22
  93. package/dist/products/identity/views/passkey-prompt.d.ts +0 -25
  94. package/dist/products/identity/views/passkey.d.ts +0 -38
  95. package/dist/products/identity/views/product-not-configured.d.ts +0 -21
  96. package/dist/products/identity/views/service-unavailable.d.ts +0 -21
  97. package/dist/products/identity/views/sms-consent.d.ts +0 -16
  98. package/dist/products/identity/views/sparklink-waiting.d.ts +0 -40
  99. package/dist/products/identity/views/two-factor.d.ts +0 -37
  100. package/dist/products/index.d.ts +0 -51
  101. package/dist/products/messaging/index.d.ts +0 -38
  102. package/dist/products/messaging/types.d.ts +0 -162
  103. package/dist/products/notify/index.d.ts +0 -436
  104. package/dist/products/notify/project-types.d.ts +0 -44
  105. package/dist/products/notify/projects.d.ts +0 -15
  106. package/dist/products/notify/types.d.ts +0 -1327
  107. package/dist/products/structured-ingots/index.d.ts +0 -31
  108. package/dist/products/structured-ingots/types-client.d.ts +0 -19
  109. package/dist/products/structured-ingots/types.d.ts +0 -293
  110. package/dist/products/structured-ingots/validation.d.ts +0 -25
  111. package/dist/request-path.d.ts +0 -44
  112. package/dist/sparks/index.d.ts +0 -91
  113. package/dist/sparks/types.d.ts +0 -304
  114. package/dist/ui/chrome.d.ts +0 -16
  115. package/dist/ui/ds-tokens.d.ts +0 -59
  116. package/dist/ui/inline-shell.d.ts +0 -19
  117. package/dist/ui/live-region.d.ts +0 -15
  118. package/dist/ui/modal-shell.d.ts +0 -67
  119. package/dist/ui/target.d.ts +0 -6
  120. package/dist/utils/dom.d.ts +0 -26
  121. package/dist/vault-session.d.ts +0 -2
  122. package/dist/vaults/index.d.ts +0 -254
  123. package/dist/vaults/types.d.ts +0 -368
  124. package/dist/vaults/upload/api.d.ts +0 -310
  125. package/dist/vaults/upload/chrome.d.ts +0 -21
  126. package/dist/vaults/upload/container.d.ts +0 -37
  127. package/dist/vaults/upload/index.d.ts +0 -76
  128. package/dist/vaults/upload/inline-container.d.ts +0 -41
  129. package/dist/vaults/upload/modal.d.ts +0 -55
  130. package/dist/vaults/upload/renderer.d.ts +0 -150
  131. package/dist/vaults/upload/styles.d.ts +0 -14
  132. package/dist/vaults/upload/types.d.ts +0 -220
@@ -1,154 +0,0 @@
1
- /**
2
- * Notify Module
3
- *
4
- * SparkVault's first-party Notify surface: the metadata-only inbox of a user
5
- * signed in to SparkVault itself (a Core session JWT; an API key or an
6
- * identity-only token is refused), holding the notifications SparkVault and the
7
- * organization they signed in to delivered to them `in_app`, plus this browser's
8
- * Web Push registration. It is
9
- * not a tenant's inbox for its own end users: a tenant reads its recipients'
10
- * feeds with `sv.products.notify.getInbox`. The recipient is ALWAYS derived
11
- * from the session on the server: no method takes a `recipient_id`, and any
12
- * account/recipient a caller might try to supply is ignored. This mirrors
13
- * `@sparkvault/sdk-mobile`'s notify client; device push registration is
14
- * intentionally omitted (Expo-only on mobile).
15
- */
16
- import { HttpClient } from '../http';
17
- import type { ListNotificationsOptions, ListNotificationsResponse, UnreadCountResponse, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, WebPushKeyResponse, WebPushSubscriptionInput, RegisterWebPushResponse, UnsubscribeWebPushResponse, SubscribeWebPushOptions, SubscribeWebPushResult, WebPushStatusOptions, WebPushStatusResult } from './types';
18
- export declare class NotifyModule {
19
- private readonly http;
20
- constructor(http: HttpClient);
21
- /**
22
- * The caller's own inbox feed (newest first). Follow `cursor` to page: a
23
- * page can come back short of `limit` yet still carry a non-null cursor.
24
- *
25
- * @example
26
- * const { notifications, cursor } = await sv.notify.getInbox({ state: 'unread' });
27
- */
28
- getInbox(options?: ListNotificationsOptions): Promise<ListNotificationsResponse>;
29
- /**
30
- * Bounded unseen badge count for the caller's own inbox. `capped` true means
31
- * the true count is at/beyond the ceiling: render "N+".
32
- *
33
- * @example
34
- * const { unread_count, capped } = await sv.notify.getUnreadCount();
35
- */
36
- getUnreadCount(): Promise<UnreadCountResponse>;
37
- /**
38
- * Apply a terminal display state to one of the caller's own rows (idempotent).
39
- * `createdAt` MUST be the row's own `created_at` (round-tripped from the list
40
- * row); the id alone cannot address the row.
41
- *
42
- * @example
43
- * await sv.notify.markState('ntf_abc', { createdAt: row.created_at, state: 'read' });
44
- */
45
- markState(notificationId: string, options: MarkNotificationStateOptions): Promise<MarkNotificationStateResponse>;
46
- /**
47
- * Bulk-mark ONE bounded page of the caller's inbox and return the server's
48
- * payload verbatim. `cursor` comes back non-null while rows remain: thread it
49
- * into the next call. `archived` is per-row only (no GSI to page over), so the
50
- * bulk states are `seen` and `read`.
51
- *
52
- * Prefer `markAllRead()` unless the caller needs to own the paging.
53
- *
54
- * @example
55
- * let page = await sv.notify.markAllState({ state: 'seen' });
56
- * while (page.cursor) page = await sv.notify.markAllState({ state: 'seen', cursor: page.cursor });
57
- */
58
- markAllState(options: MarkAllNotificationsStateOptions): Promise<MarkAllNotificationsStateResponse>;
59
- /**
60
- * Drain the caller's whole inbox to read: loop `markAllState` on the returned
61
- * cursor until it comes back null, and return the total marked. Marking read
62
- * clears the unseen marker too, so the badge zeroes with it. Idempotent.
63
- *
64
- * `complete` is false when the loop stopped at the page bound with rows still
65
- * unmarked: an inbox deeper than the bound finishes on a second call. Without
66
- * it a truncated drain looks exactly like a finished one.
67
- *
68
- * An error mid-drain propagates: the pages already marked stay marked, and a
69
- * re-run picks up the remainder.
70
- *
71
- * @example
72
- * let { updated, complete } = await sv.notify.markAllRead();
73
- * while (!complete) ({ complete } = await sv.notify.markAllRead());
74
- */
75
- markAllRead(): Promise<MarkAllReadResult>;
76
- /**
77
- * Whether this environment can do Web Push (service worker + Push API +
78
- * Notifications). Feature-detect before showing an enable-notifications UI.
79
- */
80
- isWebPushSupported(): boolean;
81
- /**
82
- * The platform VAPID public key for `pushManager.subscribe()`. `configured`
83
- * is false until the server-side VAPID keypair is provisioned: hide the
84
- * enable-notifications affordance while false.
85
- */
86
- getWebPushKey(): Promise<WebPushKeyResponse>;
87
- /**
88
- * The VAPID public key the server signs every push with, as the bytes a
89
- * browser subscription is bound to; null while no keypair is provisioned.
90
- */
91
- private serverKey;
92
- /**
93
- * This browser's Web Push state, read without prompting, subscribing or
94
- * registering anything: `subscribed` only when the browser holds a
95
- * subscription made for the key the server signs with now. One made for
96
- * another key reads `not_subscribed`: its push service refuses every push
97
- * signed with the current key, and `subscribeWebPush` replaces it. Read it to
98
- * show whether this browser's notifications are on.
99
- *
100
- * @example
101
- * const registration = await navigator.serviceWorker.getRegistration();
102
- * const { status } = await sv.notify.getWebPushStatus({ serviceWorkerRegistration: registration });
103
- */
104
- getWebPushStatus(options?: WebPushStatusOptions): Promise<WebPushStatusResult>;
105
- /**
106
- * Register (or refresh) a browser push subscription for the signed-in user.
107
- * Accepts a live PushSubscription or its JSON shape.
108
- */
109
- registerWebPushSubscription(subscription: PushSubscription | WebPushSubscriptionInput): Promise<RegisterWebPushResponse>;
110
- /** Remove a browser push subscription for the signed-in user, by endpoint. */
111
- unsubscribeWebPushEndpoint(endpoint: string): Promise<UnsubscribeWebPushResponse>;
112
- /**
113
- * End-to-end enable ceremony: feature-detect, fetch the VAPID key, ensure
114
- * Notification permission, subscribe via the caller's service worker, and
115
- * register the subscription with the server. Returns a typed status instead
116
- * of throwing on the expected declines so a host can branch on the outcome:
117
- * unsupported, not configured, `permission_denied` (the person blocked
118
- * notifications for the site, now or before, so only the browser's site
119
- * settings can allow them) and `permission_dismissed` (the person closed the
120
- * prompt without answering: the site still asks, so enabling again shows the
121
- * prompt again). Call it from a user gesture (permission prompts require one).
122
- *
123
- * A subscription the browser holds for the current key is kept
124
- * (`already_subscribed`); one made for a previous key can never deliver
125
- * again, so it is removed and replaced (`subscribed`). Enabling again is
126
- * therefore how a browser recovers after the platform's key changes, and
127
- * `getWebPushStatus` reads such a browser as `not_subscribed` until it does.
128
- *
129
- * @example
130
- * const reg = await navigator.serviceWorker.register('/sw.js');
131
- * const { status } = await sv.notify.subscribeWebPush({ serviceWorkerRegistration: reg });
132
- */
133
- subscribeWebPush(options: SubscribeWebPushOptions): Promise<SubscribeWebPushResult>;
134
- /**
135
- * Retire a browser subscription bound to a key the server no longer signs
136
- * with: the server forgets its endpoint first (still authenticated, and the
137
- * push service would otherwise refuse that endpoint's every push without it
138
- * ever being pruned), then the browser drops it, which a subscribe against the
139
- * new key needs. A failure stops here with nothing half-done, so enabling
140
- * again starts from the same state.
141
- *
142
- * `unsubscribe()` resolves false only when the subscription is already gone
143
- * (another tab dropped it first), which leaves the browser as a subscribe
144
- * needs it; a browser that kept one refuses that subscribe outright
145
- * (InvalidStateError), so a kept subscription is never reused unseen.
146
- */
147
- private dropDeadSubscription;
148
- /**
149
- * Disable Web Push on this device: unsubscribe the browser subscription and
150
- * remove it server-side. Safe to call when not subscribed (returns false).
151
- */
152
- unsubscribeWebPush(options: SubscribeWebPushOptions): Promise<boolean>;
153
- }
154
- export type { NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, ListNotificationsOptions, ListNotificationsResponse, UnreadCountResponse, MarkNotificationStateOptions, MarkNotificationStateResponse, NotificationBulkMarkState, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, WebPushKeyResponse, WebPushSubscriptionInput, RegisterWebPushResponse, UnsubscribeWebPushResponse, SubscribeWebPushStatus, SubscribeWebPushOptions, SubscribeWebPushResult, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, } from './types';
@@ -1,232 +0,0 @@
1
- /**
2
- * Notify Module Types
3
- *
4
- * A signed-in SparkVault user's own feed: the notifications SparkVault itself
5
- * delivered `in_app` to them and those their own organization's Notify did, as
6
- * one feed, each row saying which (`from`). Unlike Entropy/Sparks, notification
7
- * ROWS are NOT remapped to camelCase: their fields mirror the wire, and a tenant's
8
- * sender-side feed (`sv.products.notify.getInbox`) returns the same row without
9
- * `from`, since it reads one sending account's inbox. A row carries
10
- * its cleartext part (`title`, and for a cleartext send a short `body`) natively;
11
- * a SECURE send's content is never carried here: it lives behind the SparkLink
12
- * `sparklink_code`. Keeping the wire shape verbatim is the single source of truth
13
- * shared with `@sparkvault/sdk-mobile` and the first-party console, so do not
14
- * "camelCase" these rows. Only the input option `createdAt` is camelCase for call
15
- * ergonomics (mapped to `created_at` on the wire).
16
- */
17
- /** Inbox views the feed can be filtered to. `all` excludes archived rows. */
18
- export type NotificationInboxState = 'all' | 'unseen' | 'unread' | 'archived';
19
- /** Terminal display states the recipient can apply to one of their rows. */
20
- export type NotificationMarkState = 'seen' | 'read' | 'archived';
21
- /**
22
- * Who a row of the person's own feed is from: SparkVault itself, or their own
23
- * organization by its name. `name` is null when the organization has no name the
24
- * feed can show (none, or one that reads as SparkVault's): label such a row
25
- * generically, never as SparkVault's.
26
- */
27
- export type NotificationSender = {
28
- type: 'sparkvault';
29
- } | {
30
- type: 'organization';
31
- name: string | null;
32
- /** Present for a named project's notifications. */
33
- project_id?: string;
34
- project_name?: string | null;
35
- };
36
- /**
37
- * An inbox row in the two-part notification model, as one sending account's
38
- * inbox read (`sv.products.notify.getInbox`) returns it: no `from`, since the
39
- * sender reading its own inbox is who sent every row in it. The `title` (and,
40
- * for a cleartext send, the short `body`) is the NON-sensitive cleartext part,
41
- * shown natively. A SECURE send's content lives behind the SparkLink
42
- * (`sparklink_code`) and is never carried here; open the pointer to reveal it.
43
- * Timestamps are epoch SECONDS.
44
- */
45
- export interface NotifyInboxRow {
46
- notification_id: string;
47
- /** Named project attribution; absent on Default's legacy rows. */
48
- notify_project_id?: string;
49
- send_id: string;
50
- created_at: number;
51
- title: string;
52
- /**
53
- * The row's visible cleartext line, shown natively: a plaintext send's inline
54
- * body, or a SEALED send's non-secret `instructions`. A sealed row can and
55
- * normally should carry one: it is the readable line above the reveal. Never
56
- * the sealed content itself. Absent when the sender set neither.
57
- */
58
- body?: string;
59
- category: string;
60
- type: string;
61
- seen_at: number | null;
62
- read_at: number | null;
63
- archived_at: number | null;
64
- /**
65
- * The grant to open. Present only while a live reveal stands behind it, meaning a
66
- * SEALED (secure) send whose grant still opens: not yet opened (on a send that
67
- * asks for an answer, not yet answered), not expired, not gone and not
68
- * recalled. A cleartext send delivers its content inline in the channel and
69
- * mints no grant; once the reveal no longer opens, the pointer is withheld
70
- * rather than echoed.
71
- */
72
- sparklink_code?: string;
73
- /**
74
- * Where the grant opens: the URL every Notify channel carries for it, built by
75
- * the server. Present exactly when `sparklink_code` is; open this rather than
76
- * building a URL from the code.
77
- */
78
- pointer_url?: string;
79
- /**
80
- * True for a SEALED send's row, for good, whether or not its reveal still
81
- * opens. A row is plain text, its `body` the whole message, only when
82
- * `sealed` is false and it is not `recalled`; a sealed row's `body` is its
83
- * sender's instructions about the reveal.
84
- */
85
- sealed: boolean;
86
- /**
87
- * True only when there is a secure part left to reveal, exactly when
88
- * `sparklink_code` is present. `false` does NOT mean "cleartext row": a
89
- * `sealed` row whose reveal no longer opens (opened, answered, expired or
90
- * gone) is unlocked too, and so is a recalled one, with nothing behind it.
91
- * Show such a sealed row as no longer available rather than its
92
- * instructions, which describe a link that opens nothing.
93
- */
94
- locked: boolean;
95
- /**
96
- * The sender took this notification back. The grant is revoked and
97
- * `sparklink_code` is withheld, so render "no longer available" rather than a
98
- * tap-to-reveal that opens nothing.
99
- */
100
- recalled: boolean;
101
- }
102
- /**
103
- * A row of the person's own feed: an inbox row, and who sent it. Show `from` on
104
- * every row: an organization's title alone could read as SparkVault's own.
105
- */
106
- export interface NotificationRow extends NotifyInboxRow {
107
- from: NotificationSender;
108
- }
109
- export interface ListNotificationsOptions {
110
- state?: NotificationInboxState;
111
- /** Page size, 1-100 (server default 50). */
112
- limit?: number;
113
- /** Opaque cursor from a prior response. */
114
- cursor?: string;
115
- }
116
- export interface ListNotificationsResponse {
117
- notifications: NotificationRow[];
118
- /**
119
- * Next-page cursor, or null on the last page. A page can be SHORT of `limit`
120
- * yet still carry a non-null cursor (the state/sender filter is applied after
121
- * the key query), so follow the cursor; never treat a short page as the end.
122
- */
123
- cursor: string | null;
124
- }
125
- export interface UnreadCountResponse {
126
- unread_count: number;
127
- /** True when the true count is at/beyond the badge ceiling (render "N+"). */
128
- capped: boolean;
129
- }
130
- export interface MarkNotificationStateOptions {
131
- /** The row's `created_at` (epoch seconds), round-tripped from the list row. Required. */
132
- createdAt: number;
133
- state: NotificationMarkState;
134
- }
135
- export interface MarkNotificationStateResponse {
136
- notification_id: string;
137
- state: NotificationMarkState;
138
- updated_at: number;
139
- }
140
- /**
141
- * States a BULK drain can apply. `archived` is per-row only: it has no GSI for
142
- * the server to page over, so the bulk endpoint rejects it.
143
- */
144
- export type NotificationBulkMarkState = 'seen' | 'read';
145
- export interface MarkAllNotificationsStateOptions {
146
- state: NotificationBulkMarkState;
147
- /** Cursor from the prior page's response; omit to start at the newest page. */
148
- cursor?: string;
149
- }
150
- export interface MarkAllNotificationsStateResponse {
151
- /** Rows marked by THIS page; the server marks one bounded page per call. */
152
- updated: number;
153
- /** Cursor for the next page, or null once the inbox is drained. */
154
- cursor: string | null;
155
- }
156
- /** Total across a full `markAllRead()` drain. */
157
- export interface MarkAllReadResult {
158
- updated: number;
159
- /**
160
- * True when the drain reached the end of the inbox (the server returned a null
161
- * cursor). False when it stopped at the page bound with rows still unmarked:
162
- * call again to continue. Without this a truncated drain is indistinguishable
163
- * from a completed one.
164
- */
165
- complete: boolean;
166
- }
167
- /** The platform VAPID public key needed for pushManager.subscribe(). */
168
- export interface WebPushKeyResponse {
169
- /** False until the VAPID keypair is provisioned server-side: hide the UI. */
170
- configured: boolean;
171
- /** base64url VAPID application server key, or null when not configured. */
172
- vapid_public_key: string | null;
173
- /** The VAPID `sub` contact (mailto:/https), or null when not configured. */
174
- subject: string | null;
175
- }
176
- /** RFC 8030 subscription shape sent to the server (a PushSubscription's JSON). */
177
- export interface WebPushSubscriptionInput {
178
- endpoint: string;
179
- keys: {
180
- p256dh: string;
181
- auth: string;
182
- };
183
- }
184
- export interface RegisterWebPushResponse {
185
- success: boolean;
186
- created: boolean;
187
- refreshed: boolean;
188
- }
189
- export interface UnsubscribeWebPushResponse {
190
- success: boolean;
191
- deleted: boolean;
192
- }
193
- /**
194
- * Terminal outcomes of the end-to-end subscribeWebPush ceremony.
195
- * `permission_denied`: notifications are blocked for the site (the person
196
- * chose Block, now or before), so only the browser's site settings can allow
197
- * them. `permission_dismissed`: the person closed the permission prompt
198
- * without answering, so the site still asks and calling again prompts again.
199
- */
200
- export type SubscribeWebPushStatus = 'subscribed' | 'already_subscribed' | 'not_supported' | 'not_configured' | 'permission_denied' | 'permission_dismissed';
201
- export interface SubscribeWebPushOptions {
202
- /**
203
- * The caller's service-worker registration (the app owns the worker file and
204
- * its lifecycle). Web Push requires a service worker to receive push events.
205
- */
206
- serviceWorkerRegistration: ServiceWorkerRegistration;
207
- }
208
- export interface SubscribeWebPushResult {
209
- status: SubscribeWebPushStatus;
210
- /** The live PushSubscription on 'subscribed'/'already_subscribed'. */
211
- subscription?: PushSubscription;
212
- }
213
- /**
214
- * This browser's Web Push state, as getWebPushStatus reads it. `subscribed`
215
- * means the browser holds a subscription made for the key the server signs
216
- * with now; one made for another key can never deliver, so it reads
217
- * `not_subscribed`.
218
- */
219
- export type WebPushStatus = 'subscribed' | 'not_subscribed' | 'not_supported' | 'not_configured';
220
- export interface WebPushStatusOptions {
221
- /**
222
- * The page's service-worker registration
223
- * (`navigator.serviceWorker.getRegistration()`), when it has one: a page
224
- * with no registration holds no subscription.
225
- */
226
- serviceWorkerRegistration?: ServiceWorkerRegistration;
227
- }
228
- export interface WebPushStatusResult {
229
- status: WebPushStatus;
230
- /** The live PushSubscription, on 'subscribed' only. */
231
- subscription?: PushSubscription;
232
- }
@@ -1,198 +0,0 @@
1
- import type { ResolvedConfig } from '../../config';
2
- import type { ResumeUploadOptions, SendUploadOptions, UploadSession } from '../../ingots/types';
3
- import { type HelpDeskWidgetIdentityOptions, type HelpDeskWidgetIdentitySession } from './widget-identity';
4
- import type { HelpDeskAttachmentDownload, HelpDeskAttachmentInput, HelpDeskAttachmentUpload, HelpDeskConnectOptions, HelpDeskCreateTicketOptions, HelpDeskCustomer, HelpDeskCustomerPatch, HelpDeskDesk, HelpDeskDraft, HelpDeskListTicketsOptions, HelpDeskPinChallenge, HelpDeskReplyCreated, HelpDeskReplyOptions, HelpDeskRequestContext, HelpDeskSession, HelpDeskSessionChange, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, HelpDeskWebsiteAccountReturn, HelpDeskExternalChallenge } from './types';
5
- /**
6
- * One desk's customer client. Sessions stay in memory unless a host supplies a
7
- * provider. A provider must supply an hdt_ token, not a website identity JWT.
8
- */
9
- export declare class HelpDeskClient {
10
- readonly desk: Readonly<HelpDeskDesk>;
11
- private readonly http;
12
- private readonly transfers;
13
- private readonly provider?;
14
- private readonly assertionProvider?;
15
- private authentication;
16
- private verifiedRequesterId;
17
- private provedSession;
18
- private readonly renewedTokens;
19
- private authorityRevision;
20
- private readonly listeners;
21
- private session;
22
- /**
23
- * When the installed session ends on this device's clock, in seconds: set
24
- * from `ttl_seconds` as an answer lands from Core. Null for a session whose
25
- * landing this client did not see (setSession), which ends at Core's 401.
26
- */
27
- private deadline;
28
- private token;
29
- private revision;
30
- private websiteAccountSuppressed;
31
- private ticketAccess;
32
- private currentTicketPolicy;
33
- /** Only this client's own sign-in ceremonies create credentials it may revoke on account switch. */
34
- private readonly issuedSessions;
35
- /**
36
- * Every bearer this client revoked or discarded, each with whether a host
37
- * lending it back has heard it ends. It grows by one bearer per release
38
- * (Switch account, Sign out, Use website account, logout) or discarded
39
- * session over one client's life. A host that keeps the session `onSession`
40
- * reports may lend one back through `getSessionToken`: it lends none then,
41
- * and the first such answer per bearer is cleared aloud so that the host
42
- * drops it. None of them is ever installed again.
43
- */
44
- private readonly releasedTokens;
45
- private ownsSession;
46
- private readonly onDiscardError?;
47
- private constructor();
48
- /**
49
- * Discover a desk by its configured host, before any customer credentials
50
- * are sent, or take the lookup's answer the page already holds (`desk`).
51
- */
52
- static connect(config: ResolvedConfig, options: HelpDeskConnectOptions): Promise<HelpDeskClient>;
53
- /**
54
- * Install a customer session answer the host holds, such as one restored
55
- * from its own storage. Its landing time is unknown, so this client sets it
56
- * no deadline of its own: it lasts until Core answers 401, which clears it.
57
- * A company provider verifies restored sessions again before use. Null
58
- * stays signed out until refreshSession() or authenticate() explicitly
59
- * resumes the provider. A session this client sent for revocation is
60
- * refused: its bearer is ended, or will be.
61
- */
62
- setSession(session: HelpDeskSession | null): void;
63
- private installSession;
64
- clearSession(): void;
65
- /**
66
- * Observe identity changes and explicit clear/refresh actions. A first provider
67
- * discovery is distinguished from a host replacing the customer during lookup.
68
- */
69
- subscribeSession(listener: (change: HelpDeskSessionChange) => void): () => void;
70
- /** Explicitly refresh the host-managed session, for example after a backend handoff. */
71
- refreshSession(): Promise<string | null>;
72
- /** Resume provider authority without starting its proof before an independent access gate. */
73
- private resetProviderSession;
74
- /** Whether company identity can be established without customer interaction. */
75
- get hasIdentityProvider(): boolean;
76
- /** The independent ticket gate must be met before rendering authenticated ticket UI. */
77
- get hasTicketAccess(): boolean;
78
- clearTicketAccess(): void;
79
- get ticketAccessPolicy(): HelpDeskDesk['ticket_access_control'];
80
- /** Refresh network/policy hints without replacing requester state or composition. */
81
- refreshTicketAccessPolicy(): Promise<void>;
82
- unlockTicketAccess(options: {
83
- password?: string;
84
- identityGrant?: string;
85
- }): Promise<{
86
- token: string;
87
- ttl_seconds: number;
88
- }>;
89
- /** @internal Read an installed server-proven company bearer without invoking any identity provider. */
90
- verifiedSessionTokenFor(requesterId: string): string | null;
91
- getSessionToken(): Promise<string | null>;
92
- private rememberToken;
93
- private send;
94
- private establish;
95
- /**
96
- * A public, short-lived challenge from the help desk's own Entropy service.
97
- * Core refuses a nonce past its `expires_at` on its own clock, so this
98
- * device's clock never judges it.
99
- */
100
- startExternalChallenge(): Promise<HelpDeskExternalChallenge>;
101
- /** Exchange only a purpose-specific company assertion, never an ordinary website token. */
102
- completeExternal(options: {
103
- assertion: string;
104
- nonce: string;
105
- }): Promise<HelpDeskSession>;
106
- private exchangeExternal;
107
- /** Silently establish/renew a company session. Concurrent calls share one proof. */
108
- authenticate(): Promise<HelpDeskSession | null>;
109
- /** Install a company session answer that just landed from Core, timed from its `ttl_seconds`. */
110
- private acceptExternalSession;
111
- /** Mint an opaque hosted-portal code from an assertion binding the registered redirect challenge. */
112
- createExternalHandoff(options: {
113
- assertion: string;
114
- nonce: string;
115
- redirectOrigin: string;
116
- }): Promise<{
117
- code: string;
118
- expires_at: number;
119
- }>;
120
- /** Redeem a hosted code only with the initiating browser's original verifier and nonce. */
121
- redeemExternal(options: {
122
- code: string;
123
- nonce: string;
124
- verifier: string;
125
- }): Promise<HelpDeskSession>;
126
- startPin(email: string): Promise<HelpDeskPinChallenge>;
127
- verifyPin(options: HelpDeskVerifyPinOptions): Promise<HelpDeskSession>;
128
- /** Uninstalled result: the owning form/controller decides when the new requester becomes current. */
129
- signInWidgetIdentity(options?: HelpDeskWidgetIdentityOptions): Promise<HelpDeskWidgetIdentitySession>;
130
- /**
131
- * End a session Core minted for this client that reaches no one: its answer
132
- * was invalid, the customer changed while it was minted, or the sign-in
133
- * that asked for it had ended. Nobody else holds its bearer, so a refused or
134
- * lost revocation goes to `onDiscardError`, without which that bearer lasts
135
- * out its lifetime. The installed session, and one already sent for
136
- * revocation, are left as they are.
137
- */
138
- private discardMinted;
139
- /**
140
- * Revoke a session this client's own sign-in redeemed that its caller will
141
- * not install: the form that asked for it has gone, or it served only for
142
- * its `identity_grant`. An installed session ends through `signOutSupport`
143
- * or `logout`; one this client did not issue belongs to whoever lent it and
144
- * is never revoked here. One already sent for revocation is not sent again.
145
- */
146
- discardSession(session: HelpDeskSession): Promise<void>;
147
- /** Choose a different support identity without logging out or changing the host website. */
148
- switchSupportAccount(): Promise<void>;
149
- /**
150
- * Sign the customer out of support in this browser: revoke the session, one
151
- * a provider lent included, and keep the website's identity from signing
152
- * them back in until `returnToWebsiteAccount`. The session is gone here before
153
- * the revocation is answered; the host website's own sign-in is untouched.
154
- */
155
- signOutSupport(): Promise<void>;
156
- /**
157
- * Go back to the website's identity after an explicit switch, releasing as
158
- * `switchSupportAccount` releases: the session in use is gone here at once,
159
- * a lent one never revoked, and `released` settles with its revocation,
160
- * which never holds up the return. `resumed` settles with the session the
161
- * website's identity signed support in with, or null for none, for a
162
- * session the host lends, or, the website not yet asked, while a ticket
163
- * gate stands (`HelpDeskWebsiteAccountReturn`). The only operation that
164
- * resumes the website's configured identity provider after a switch.
165
- */
166
- returnToWebsiteAccount(): HelpDeskWebsiteAccountReturn;
167
- private resumeWebsiteAccount;
168
- getMe(): Promise<HelpDeskCustomer>;
169
- updateMe(patch: HelpDeskCustomerPatch, context?: HelpDeskRequestContext): Promise<HelpDeskCustomer>;
170
- createDraft(context?: HelpDeskRequestContext): Promise<HelpDeskDraft>;
171
- /** Retrying the same draft ID recovers the original ticket after a lost response. */
172
- createTicket(options: HelpDeskCreateTicketOptions, context?: HelpDeskRequestContext): Promise<HelpDeskTicketCreated>;
173
- listTickets(options?: HelpDeskListTicketsOptions): Promise<HelpDeskTicketList>;
174
- getTicket(number: number, options?: {
175
- response?: string;
176
- }): Promise<HelpDeskTicketDetail>;
177
- listEvents(number: number, cursor?: string): Promise<HelpDeskTimeline>;
178
- /** A new id for one composed reply, sent as `HelpDeskReplyOptions.eventId` with every send of it while it stands unchanged. */
179
- newReplyId(): string;
180
- /** A reply sent under an `eventId` an earlier send of it posted answers that reply, posting nothing again. */
181
- replyToTicket(number: number, options: HelpDeskReplyOptions, context?: HelpDeskRequestContext): Promise<HelpDeskReplyCreated>;
182
- resolveTicket(number: number, context?: HelpDeskRequestContext): Promise<void>;
183
- muteTicket(number: number, muted: boolean, context?: HelpDeskRequestContext): Promise<void>;
184
- /** Send an already-issued attachment directly to Forge, resolving only after publication is confirmed. */
185
- sendAttachment(uploadUrl: string, file: File | Blob, options?: SendUploadOptions): Promise<void>;
186
- /** Check/resume the original transfer; receiving every byte alone is not proof the attachment is published. */
187
- resumeAttachment(session: UploadSession, file: File | Blob, options?: ResumeUploadOptions): Promise<void>;
188
- initiateDraftAttachment(ticketId: string, file: HelpDeskAttachmentInput, context?: HelpDeskRequestContext): Promise<HelpDeskAttachmentUpload>;
189
- cancelDraftAttachment(ticketId: string, attachmentId: string, context?: HelpDeskRequestContext): Promise<void>;
190
- initiateTicketAttachment(number: number, file: HelpDeskAttachmentInput, context?: HelpDeskRequestContext): Promise<HelpDeskAttachmentUpload>;
191
- cancelTicketAttachment(number: number, attachmentId: string, context?: HelpDeskRequestContext): Promise<void>;
192
- attachmentDownload(attachmentId: string, number: number): Promise<HelpDeskAttachmentDownload>;
193
- /** Revoke this bearer, clearing only the session whose logout completed. */
194
- logout(): Promise<void>;
195
- private releaseSession;
196
- /** End `token`'s session and `accessToken`'s ticket access at the desk; each credential sent can revoke only itself. */
197
- private revoke;
198
- }
@@ -1,2 +0,0 @@
1
- /** The original desk uses its account ID; additional desks have their own ID. */
2
- export { isHelpDeskId as validHelpDeskId } from '@sparkvault/app-sdk/help-desk-contract';
@@ -1,37 +0,0 @@
1
- /** The existing hosted draft format, also used by the shared form. Never stores credentials or file bytes. */
2
- export interface HelpDeskFormDraft {
3
- subject: string;
4
- body: string;
5
- ticketId: string | null;
6
- uncertain: {
7
- ticketId: string;
8
- subject: string;
9
- body: string;
10
- attachments: string[];
11
- source_article_id?: string;
12
- } | null;
13
- hadFiles: boolean;
14
- }
15
- type Composition = {
16
- subject: string;
17
- body: string;
18
- };
19
- /** A signed-out customer's request saved before a reload, with the support question it was filled from: '' for one filled from none. */
20
- export interface AnonymousFormDraft extends Composition {
21
- composedFrom: string;
22
- }
23
- /** The question before sign-in is tab-local and contains no customer identity. */
24
- export declare function clearSupportIssue(deskId: string): void;
25
- export declare function readSupportIssue(deskId: string): string | null;
26
- export declare function readAnonymousFormDraft(deskId: string): AnonymousFormDraft | null;
27
- export declare function saveSupportIssue(deskId: string, issue: string): void;
28
- /**
29
- * Save a signed-out customer's request beside the tab's question, with the
30
- * question it was filled from when the support wizard filled it. A question
31
- * too long to keep is left out, so the request reads as the customer's own.
32
- */
33
- export declare function saveAnonymousFormDraft(deskId: string, composition: Composition, composedFrom?: string): void;
34
- export declare function removeFormDraft(deskId: string, requesterId: string): void;
35
- export declare function readFormDraft(deskId: string, requesterId: string): HelpDeskFormDraft | null;
36
- export declare function saveFormDraft(deskId: string, requesterId: string, value: HelpDeskFormDraft): void;
37
- export {};