@sparkvault/sdk-js 16.12.0 → 17.0.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/README.md +49 -1
- package/dist/index.cjs +367 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +110 -12
- package/dist/index.mjs +367 -71
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/client.d.ts +50 -6
- package/dist/products/help-desk/form-types.d.ts +3 -1
- package/dist/products/help-desk/index.d.ts +13 -3
- package/dist/products/help-desk/support-types.d.ts +6 -2
- package/dist/products/help-desk/types.d.ts +38 -0
- package/dist/products/help-desk/widget-identity.d.ts +6 -2
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ResolvedConfig } from '../../config';
|
|
2
2
|
import type { ResumeUploadOptions, SendUploadOptions, UploadSession } from '../../ingots/types';
|
|
3
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, HelpDeskExternalChallenge } from './types';
|
|
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
5
|
/**
|
|
6
6
|
* One desk's customer client. Sessions stay in memory unless a host supplies a
|
|
7
7
|
* provider. A provider must supply an hdt_ token, not a website identity JWT.
|
|
@@ -32,9 +32,23 @@ export declare class HelpDeskClient {
|
|
|
32
32
|
private currentTicketPolicy;
|
|
33
33
|
/** Only this client's own sign-in ceremonies create credentials it may revoke on account switch. */
|
|
34
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;
|
|
35
45
|
private ownsSession;
|
|
46
|
+
private readonly onDiscardError?;
|
|
36
47
|
private constructor();
|
|
37
|
-
/**
|
|
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
|
+
*/
|
|
38
52
|
static connect(config: ResolvedConfig, options: HelpDeskConnectOptions): Promise<HelpDeskClient>;
|
|
39
53
|
/**
|
|
40
54
|
* Install a customer session answer the host holds, such as one restored
|
|
@@ -42,7 +56,8 @@ export declare class HelpDeskClient {
|
|
|
42
56
|
* no deadline of its own: it lasts until Core answers 401, which clears it.
|
|
43
57
|
* A company provider verifies restored sessions again before use. Null
|
|
44
58
|
* stays signed out until refreshSession() or authenticate() explicitly
|
|
45
|
-
* resumes the provider.
|
|
59
|
+
* resumes the provider. A session this client sent for revocation is
|
|
60
|
+
* refused: its bearer is ended, or will be.
|
|
46
61
|
*/
|
|
47
62
|
setSession(session: HelpDeskSession | null): void;
|
|
48
63
|
private installSession;
|
|
@@ -116,17 +131,44 @@ export declare class HelpDeskClient {
|
|
|
116
131
|
}): Promise<HelpDeskSession>;
|
|
117
132
|
/** Uninstalled result: the owning form/controller decides when the new requester becomes current. */
|
|
118
133
|
signInWidgetIdentity(options?: HelpDeskWidgetIdentityOptions): Promise<HelpDeskWidgetIdentitySession>;
|
|
134
|
+
/**
|
|
135
|
+
* End a session Core minted for this client that reaches no one: its answer
|
|
136
|
+
* was invalid, the customer changed while it was minted, or the sign-in
|
|
137
|
+
* that asked for it had ended. Nobody else holds its bearer, so a refused or
|
|
138
|
+
* lost revocation goes to `onDiscardError`, without which that bearer lasts
|
|
139
|
+
* out its lifetime. The installed session, and one already sent for
|
|
140
|
+
* revocation, are left as they are.
|
|
141
|
+
*/
|
|
142
|
+
private discardMinted;
|
|
143
|
+
/**
|
|
144
|
+
* Revoke a session this client's own sign-in redeemed that its caller will
|
|
145
|
+
* not install: the form that asked for it has gone, or it served only for
|
|
146
|
+
* its `identity_grant`. An installed session ends through `signOutSupport`
|
|
147
|
+
* or `logout`; one this client did not issue belongs to whoever lent it and
|
|
148
|
+
* is never revoked here. One already sent for revocation is not sent again.
|
|
149
|
+
*/
|
|
150
|
+
discardSession(session: HelpDeskSession): Promise<void>;
|
|
119
151
|
/** Choose a different support identity without logging out or changing the host website. */
|
|
120
152
|
switchSupportAccount(): Promise<void>;
|
|
121
153
|
/**
|
|
122
154
|
* Sign the customer out of support in this browser: revoke the session, one
|
|
123
155
|
* a provider lent included, and keep the website's identity from signing
|
|
124
|
-
* them back in until `
|
|
156
|
+
* them back in until `returnToWebsiteAccount`. The session is gone here before
|
|
125
157
|
* the revocation is answered; the host website's own sign-in is untouched.
|
|
126
158
|
*/
|
|
127
159
|
signOutSupport(): Promise<void>;
|
|
128
|
-
/**
|
|
129
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Go back to the website's identity after an explicit switch, releasing as
|
|
162
|
+
* `switchSupportAccount` releases: the session in use is gone here at once,
|
|
163
|
+
* a lent one never revoked, and `released` settles with its revocation,
|
|
164
|
+
* which never holds up the return. `resumed` settles with the session the
|
|
165
|
+
* website's identity signed support in with, or null for none, for a
|
|
166
|
+
* session the host lends, or, the website not yet asked, while a ticket
|
|
167
|
+
* gate stands (`HelpDeskWebsiteAccountReturn`). The only operation that
|
|
168
|
+
* resumes the website's configured identity provider after a switch.
|
|
169
|
+
*/
|
|
170
|
+
returnToWebsiteAccount(): HelpDeskWebsiteAccountReturn;
|
|
171
|
+
private resumeWebsiteAccount;
|
|
130
172
|
getMe(): Promise<HelpDeskCustomer>;
|
|
131
173
|
updateMe(patch: HelpDeskCustomerPatch, context?: HelpDeskRequestContext): Promise<HelpDeskCustomer>;
|
|
132
174
|
createDraft(context?: HelpDeskRequestContext): Promise<HelpDeskDraft>;
|
|
@@ -155,4 +197,6 @@ export declare class HelpDeskClient {
|
|
|
155
197
|
/** Revoke this bearer, clearing only the session whose logout completed. */
|
|
156
198
|
logout(): Promise<void>;
|
|
157
199
|
private releaseSession;
|
|
200
|
+
/** End `token`'s session and `accessToken`'s ticket access at the desk; each credential sent can revoke only itself. */
|
|
201
|
+
private revoke;
|
|
158
202
|
}
|
|
@@ -24,7 +24,9 @@ export interface HelpDeskWidgetFormIdentity {
|
|
|
24
24
|
/**
|
|
25
25
|
* Open the native sign-in window in the caller's gesture, with no hint of
|
|
26
26
|
* who signs in: the window offers the accounts this browser is signed in
|
|
27
|
-
* to, or a sign-in, and asks a missing name itself.
|
|
27
|
+
* to, or a sign-in, and asks a missing name itself. A session it answers
|
|
28
|
+
* that the form does not install, the form discards
|
|
29
|
+
* (`HelpDeskClient.discardSession`).
|
|
28
30
|
*/
|
|
29
31
|
signIn(): Promise<HelpDeskSession>;
|
|
30
32
|
/**
|
|
@@ -4,9 +4,13 @@ import { HelpDeskClient } from './client';
|
|
|
4
4
|
import type { HelpDeskConnectOptions } from './types';
|
|
5
5
|
import type { HelpDeskFormHandle, HelpDeskFormOptions } from './form-types';
|
|
6
6
|
import type { HelpDeskSupportHandle, HelpDeskSupportOptions } from './support-types';
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* One-call website setup. No browser secrets or identity assertions are
|
|
9
|
+
* configured here. The form reports a lost revocation through `onError`, as it
|
|
10
|
+
* reports its own, so these take no `onDiscardError`.
|
|
11
|
+
*/
|
|
12
|
+
export type HelpDeskMountFormOptions = Omit<HelpDeskConnectOptions, 'onDiscardError'> & HelpDeskFormOptions;
|
|
13
|
+
export type HelpDeskOpenFormOptions = Omit<HelpDeskConnectOptions, 'onDiscardError'> & Omit<HelpDeskFormOptions, 'target'>;
|
|
10
14
|
export declare class HelpDeskModule {
|
|
11
15
|
private readonly config;
|
|
12
16
|
constructor(config: ResolvedConfig);
|
|
@@ -26,6 +30,12 @@ export declare class HelpDeskModule {
|
|
|
26
30
|
openForm(options: HelpDeskOpenFormOptions): Promise<HelpDeskFormHandle>;
|
|
27
31
|
/** Open a modal over a client whose company session the host also drives headlessly. */
|
|
28
32
|
openClientForm(client: HelpDeskClient, options?: Omit<HelpDeskFormOptions, 'target'>): HelpDeskFormHandle;
|
|
33
|
+
/**
|
|
34
|
+
* Connect the client one of this module's own forms opens over: a lost
|
|
35
|
+
* revocation of a session the client let go of unused reaches the form's
|
|
36
|
+
* `onError` while the form stands, as the form reports its own.
|
|
37
|
+
*/
|
|
38
|
+
private connectForm;
|
|
29
39
|
/** Bind existing support buttons, including ones added later. Cleanup closes this binding's form. */
|
|
30
40
|
attach(selector: string, options: HelpDeskOpenFormOptions): () => void;
|
|
31
41
|
}
|
|
@@ -8,8 +8,12 @@ export interface HelpDeskSupportLauncherOptions {
|
|
|
8
8
|
right?: number;
|
|
9
9
|
bottom?: number;
|
|
10
10
|
}
|
|
11
|
-
/**
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* One support journey for a website or a hosted help desk page. Support
|
|
13
|
+
* reports a lost revocation through `onError`, as it reports its own, so it
|
|
14
|
+
* takes no `onDiscardError`.
|
|
15
|
+
*/
|
|
16
|
+
export interface HelpDeskSupportOptions extends Omit<HelpDeskConnectOptions, 'onDiscardError'> {
|
|
13
17
|
/** Render the same support journey in this page element. Omit for the floating widget. */
|
|
14
18
|
target?: string | HTMLElement;
|
|
15
19
|
/** @internal The host page already shows "Secured by SparkVault", so the contact form leaves its own out. */
|
|
@@ -25,12 +25,32 @@ export interface HelpDeskConnectOptions {
|
|
|
25
25
|
host: string;
|
|
26
26
|
/** Optionally pin the expected desk within this company (hdd_ for a named desk, acc_ for its original desk). */
|
|
27
27
|
deskId?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The desk lookup's answer for `host` (`GET /v1/hd/desks`) that the page
|
|
30
|
+
* already holds, such as the hosted portal's: connect validates it as it
|
|
31
|
+
* validates its own lookup's answer and makes no lookup of its own
|
|
32
|
+
* (`refreshTicketAccessPolicy`, which the support widget's contact calls,
|
|
33
|
+
* still asks the lookup for the current ticket access policy).
|
|
34
|
+
* `host` is then checked as a host name but not compared with the desk,
|
|
35
|
+
* since a desk serves hosts its answer does not list (its handle host
|
|
36
|
+
* besides a custom `canonical_host`): the page vouches that this is the
|
|
37
|
+
* answer for `host`.
|
|
38
|
+
*/
|
|
39
|
+
desk?: HelpDeskDesk;
|
|
28
40
|
/** A help desk hdt_ bearer provider. Core access tokens and API keys are never used. */
|
|
29
41
|
getSessionToken?: () => string | null | Promise<string | null>;
|
|
30
42
|
/** Obtain a purpose-specific JWT from the signed-in company's backend. No customer consent is shown. */
|
|
31
43
|
getIdentityAssertion?: (request: HelpDeskIdentityRequest) => string | null | Promise<string | null>;
|
|
32
44
|
/** Same-origin backend endpoint accepting POST {nonce,audience,desk_id}; returns {assertion} or {data:{assertion}}. */
|
|
33
45
|
identityEndpoint?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Hears a refused or lost revocation of a session Core opened for this
|
|
48
|
+
* client that reaches no one: its answer was invalid, the customer changed
|
|
49
|
+
* while it was opened, or the sign-in that asked for it had ended. Nobody
|
|
50
|
+
* else holds its bearer; unheard, it lasts out its lifetime. The support
|
|
51
|
+
* widget and the SDK's forms report these through their own `onError`.
|
|
52
|
+
*/
|
|
53
|
+
onDiscardError?: (error: Error) => void;
|
|
34
54
|
}
|
|
35
55
|
export interface HelpDeskDesk {
|
|
36
56
|
kind: 'desk';
|
|
@@ -98,6 +118,24 @@ export interface HelpDeskSession {
|
|
|
98
118
|
ttl_seconds: number;
|
|
99
119
|
customer: HelpDeskCustomer;
|
|
100
120
|
}
|
|
121
|
+
/** Use website account's two parts (`HelpDeskClient.returnToWebsiteAccount`). */
|
|
122
|
+
export interface HelpDeskWebsiteAccountReturn {
|
|
123
|
+
/**
|
|
124
|
+
* The released session's revocation. It rejects when the revocation is
|
|
125
|
+
* refused or lost, which leaves the return made, so handle it (await it or
|
|
126
|
+
* attach a rejection handler) or the rejection goes unhandled.
|
|
127
|
+
*/
|
|
128
|
+
released: Promise<void>;
|
|
129
|
+
/**
|
|
130
|
+
* The session the website's identity signed support in with. Null for none,
|
|
131
|
+
* for a session the host lends (`getSessionToken`), or, without asking the
|
|
132
|
+
* website, while a ticket-access gate stands (`hasTicketAccess` false, as
|
|
133
|
+
* the release leaves a password or employee gate). Once the gate opens, a
|
|
134
|
+
* company host signs back in with `authenticate()` and a host that lends
|
|
135
|
+
* its session reads it with `getSessionToken()`, as the support widget does.
|
|
136
|
+
*/
|
|
137
|
+
resumed: Promise<HelpDeskSession | null>;
|
|
138
|
+
}
|
|
101
139
|
/** Why customer-specific UI is being told to reconsider its current session. */
|
|
102
140
|
export interface HelpDeskSessionChange {
|
|
103
141
|
source: 'provider' | 'set' | 'clear' | 'refresh' | 'external' | 'renew';
|
|
@@ -24,5 +24,9 @@ export interface HelpDeskWidgetIdentitySession extends HelpDeskSession {
|
|
|
24
24
|
ttl_seconds: number;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Open synchronously inside the user's gesture, before preparing the server
|
|
29
|
+
* challenge. A session redeemed after the sign-in already ended (cancelled,
|
|
30
|
+
* expired, its window gone) reaches no caller, so it goes to `discard`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function openWidgetIdentity(options: HelpDeskWidgetIdentityOptions, prepare: () => Promise<HelpDeskWidgetIdentityChallenge>, ready: (challenge: HelpDeskWidgetIdentityChallenge) => Promise<boolean>, redeem: (challenge: HelpDeskWidgetIdentityChallenge, code?: string) => Promise<HelpDeskWidgetIdentitySession>, discard: (session: HelpDeskWidgetIdentitySession) => void, deskId: string): Promise<HelpDeskWidgetIdentitySession>;
|