@sparkvault/sdk-js 18.0.4 → 18.0.6
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 +21 -7
- package/dist/index.cjs +729 -148
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +12 -3
- package/dist/index.mjs +729 -148
- package/dist/index.mjs.map +1 -1
- package/dist/products/help-desk/form.d.ts +4 -4
- package/dist/products/help-desk/index.d.ts +2 -1
- package/dist/products/help-desk/kb-client.d.ts +2 -0
- package/dist/products/help-desk/types.d.ts +9 -1
- package/dist/sparkvault.js +1 -1
- package/dist/sparkvault.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -18554,7 +18554,7 @@ class HelpDeskClient {
|
|
|
18554
18554
|
this.rememberToken(null, 'refresh', true);
|
|
18555
18555
|
}
|
|
18556
18556
|
/** Whether company identity can be established without customer interaction. */
|
|
18557
|
-
get hasIdentityProvider() { return typeof this.assertionProvider === 'function'; }
|
|
18557
|
+
get hasIdentityProvider() { return this.desk.auth_mode !== 'oauth2' && typeof this.assertionProvider === 'function'; }
|
|
18558
18558
|
/** The independent ticket gate must be met before rendering authenticated ticket UI. */
|
|
18559
18559
|
get hasTicketAccess() {
|
|
18560
18560
|
const policy = this.currentTicketPolicy;
|
|
@@ -19577,6 +19577,8 @@ const HELP_DESK_COLORS = Object.freeze({
|
|
|
19577
19577
|
fillStrong: `var(--hd-fill-strong,${LIGHT['--color-slate-200']})`,
|
|
19578
19578
|
/** A field's and a secondary action's edge. */
|
|
19579
19579
|
lineStrong: `var(--hd-line-strong,${LIGHT['--color-slate-300']})`,
|
|
19580
|
+
/** A modal's scrim stays dark in either scheme; the alpha belongs to the surface. */
|
|
19581
|
+
modalBackdrop: `var(--hd-modal-backdrop,${LIGHT['--ink']})`,
|
|
19580
19582
|
ink: `var(--hd-ink,${LIGHT['--ink']})`,
|
|
19581
19583
|
body: `var(--hd-text-body,${LIGHT['--text-body']})`,
|
|
19582
19584
|
muted: `var(--hd-text-muted,${LIGHT['--text-muted']})`,
|
|
@@ -19716,7 +19718,6 @@ function injectHelpDeskFormStyles() {
|
|
|
19716
19718
|
.svhd-hint{font-size:13px;color:${HELP_DESK_COLORS.body};margin:0}
|
|
19717
19719
|
.svhd-step{display:grid;gap:16px;min-width:0}
|
|
19718
19720
|
.svhd-step-head{display:grid;gap:4px;margin-bottom:4px}
|
|
19719
|
-
.svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${HELP_DESK_COLORS.body}}
|
|
19720
19721
|
.svhd-text-button{display:inline-flex;align-items:center;min-height:44px;padding:0 4px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_ACCENT.ink};font:inherit;font-size:14px;font-weight:600;text-decoration:underline;text-underline-offset:2px;cursor:pointer}
|
|
19721
19722
|
.svhd-text-button:not(:disabled):hover{text-decoration-thickness:2px}
|
|
19722
19723
|
.svhd-text-button:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
@@ -20265,7 +20266,7 @@ function acceptedKindsCopy(kinds) {
|
|
|
20265
20266
|
/**
|
|
20266
20267
|
* The files a ticket accepts, in the one phrase every surface names them by,
|
|
20267
20268
|
* built from the policy's own list (ACCEPTED_ATTACHMENT_KINDS): the help desk
|
|
20268
|
-
* composer's
|
|
20269
|
+
* composer's refusal dialog reads it, and so do the API reference
|
|
20269
20270
|
* (apps/api/openapi/overlay.mjs) and the help desk's page on the site
|
|
20270
20271
|
* (apps/www/_data/helpDeskAttachments.js). A refused file's sentence names
|
|
20271
20272
|
* only that its type can't be attached.
|
|
@@ -20273,10 +20274,9 @@ function acceptedKindsCopy(kinds) {
|
|
|
20273
20274
|
const ACCEPTED_ATTACHMENTS_COPY = acceptedKindsCopy(ACCEPTED_ATTACHMENT_KINDS);
|
|
20274
20275
|
|
|
20275
20276
|
/**
|
|
20276
|
-
*
|
|
20277
|
-
*
|
|
20278
|
-
*
|
|
20279
|
-
* Attach.
|
|
20277
|
+
* The attachment rules shown after a refusal: what to add, how many files a
|
|
20278
|
+
* message takes and how large each may be. The help desk composer's
|
|
20279
|
+
* validation dialog reads this without adding prose to accepted uploads.
|
|
20280
20280
|
*/
|
|
20281
20281
|
const CUSTOMER_ATTACHMENTS_HINT =
|
|
20282
20282
|
`Add screenshots, documents or recordings. Up to ${MAX_ATTACHMENTS_PER_MESSAGE} files, ${formatBytes(CUSTOMER_ATTACHMENT_MAX_BYTES)} each.`;
|
|
@@ -20350,6 +20350,386 @@ function refusalCopy(refusal, maxBytes) {
|
|
|
20350
20350
|
return REFUSAL_COPY[refusal] ?? "This file can't be attached.";
|
|
20351
20351
|
}
|
|
20352
20352
|
|
|
20353
|
+
/**
|
|
20354
|
+
* Strict single-value media type (MIME) parsing.
|
|
20355
|
+
*
|
|
20356
|
+
* The one parser for a stored ingot or spark `content_type`: Core validates
|
|
20357
|
+
* every ingested value with it, Forge derives both the served Content-Type and
|
|
20358
|
+
* the inline-render decision from it, the display rules the web console and
|
|
20359
|
+
* the x.sv pages share (display-content-type.js), the Spark payload rule
|
|
20360
|
+
* (`isTextMediaType`) and the server's registry readings (media-type-node.js)
|
|
20361
|
+
* read the essence through it, so no two readers can disagree about what a
|
|
20362
|
+
* value means. A page that cannot import an ES module runs this module's own
|
|
20363
|
+
* source (MEDIA_TYPE_SCRIPT).
|
|
20364
|
+
*
|
|
20365
|
+
* Grammar (RFC 9110 §8.3.1): `type "/" subtype *( OWS ";" OWS [ parameter ] )`
|
|
20366
|
+
* where type, subtype and parameter names are tokens and parameter values are
|
|
20367
|
+
* tokens or quoted-strings, ASCII only. One deliberate tightening: a comma
|
|
20368
|
+
* anywhere rejects the value. Browsers read Content-Type as a comma-separated
|
|
20369
|
+
* list and keep the LAST valid type (WHATWG Fetch "extract a MIME type"), so a
|
|
20370
|
+
* value that this parser would classify by its first type can render in a
|
|
20371
|
+
* browser as another: `image/png, text/html` executes as HTML.
|
|
20372
|
+
*
|
|
20373
|
+
* BROWSER-SAFE: pure string handling, no Node built-ins.
|
|
20374
|
+
*/
|
|
20375
|
+
|
|
20376
|
+
/** Longest accepted value; RFC 6838 caps type and subtype at 127 chars each. */
|
|
20377
|
+
const MAX_MEDIA_TYPE_LENGTH = 255;
|
|
20378
|
+
const TOKEN_CHAR = /[!#$%&'*+.^_`|~0-9A-Za-z-]/;
|
|
20379
|
+
/** qdtext: HTAB, SP and visible ASCII except `"` and backslash. */
|
|
20380
|
+
const QUOTED_TEXT_CHAR = /[\t\x20\x21\x23-\x5b\x5d-\x7e]/;
|
|
20381
|
+
/** The character after the backslash of a quoted-pair: HTAB, SP or visible ASCII. */
|
|
20382
|
+
const QUOTED_PAIR_CHAR = /[\t\x20-\x7e]/;
|
|
20383
|
+
|
|
20384
|
+
/** Index just past the token starting at `start` (=== start when there is none). */
|
|
20385
|
+
function tokenEnd(value, start) {
|
|
20386
|
+
let end = start;
|
|
20387
|
+
while (end < value.length && TOKEN_CHAR.test(value[end])) end += 1;
|
|
20388
|
+
return end;
|
|
20389
|
+
}
|
|
20390
|
+
|
|
20391
|
+
/** Index just past the optional whitespace (SP / HTAB) starting at `start`. */
|
|
20392
|
+
function owsEnd(value, start) {
|
|
20393
|
+
let end = start;
|
|
20394
|
+
while (value[end] === ' ' || value[end] === '\t') end += 1;
|
|
20395
|
+
return end;
|
|
20396
|
+
}
|
|
20397
|
+
|
|
20398
|
+
/**
|
|
20399
|
+
* Read the quoted-string whose opening quote is at `start`.
|
|
20400
|
+
* @returns {{end: number, text: string} | null} The index past the closing
|
|
20401
|
+
* quote and the unescaped content; null when malformed or unterminated.
|
|
20402
|
+
*/
|
|
20403
|
+
function readQuotedString(value, start) {
|
|
20404
|
+
let text = '';
|
|
20405
|
+
let index = start + 1;
|
|
20406
|
+
while (index < value.length) {
|
|
20407
|
+
const char = value[index];
|
|
20408
|
+
if (char === '"') return { end: index + 1, text };
|
|
20409
|
+
if (char === '\\') {
|
|
20410
|
+
const escaped = value[index + 1];
|
|
20411
|
+
if (escaped === undefined || !QUOTED_PAIR_CHAR.test(escaped)) return null;
|
|
20412
|
+
text += escaped;
|
|
20413
|
+
index += 2;
|
|
20414
|
+
} else if (QUOTED_TEXT_CHAR.test(char)) {
|
|
20415
|
+
text += char;
|
|
20416
|
+
index += 1;
|
|
20417
|
+
} else {
|
|
20418
|
+
return null;
|
|
20419
|
+
}
|
|
20420
|
+
}
|
|
20421
|
+
return null;
|
|
20422
|
+
}
|
|
20423
|
+
|
|
20424
|
+
/**
|
|
20425
|
+
* Parse one media type value.
|
|
20426
|
+
*
|
|
20427
|
+
* A single left-to-right scan: every character is examined a bounded number
|
|
20428
|
+
* of times, so the cost is linear in the (already length-capped) input. Core
|
|
20429
|
+
* runs this on untrusted request bodies, where a backtracking grammar would
|
|
20430
|
+
* let one crafted value stall the process.
|
|
20431
|
+
*
|
|
20432
|
+
* @param {unknown} value - A stored or submitted content type
|
|
20433
|
+
* @returns {{
|
|
20434
|
+
* type: string,
|
|
20435
|
+
* subtype: string,
|
|
20436
|
+
* essence: string,
|
|
20437
|
+
* parameters: Map<string, string>
|
|
20438
|
+
* } | null} Lowercased type/subtype/essence and parameter names, unquoted
|
|
20439
|
+
* parameter values (the first occurrence of a name wins); null when the
|
|
20440
|
+
* value is not exactly one well-formed media type.
|
|
20441
|
+
*/
|
|
20442
|
+
function parseMediaType(value) {
|
|
20443
|
+
if (typeof value !== 'string' || value.length > MAX_MEDIA_TYPE_LENGTH || value.includes(',')) {
|
|
20444
|
+
return null;
|
|
20445
|
+
}
|
|
20446
|
+
|
|
20447
|
+
const typeEnd = tokenEnd(value, 0);
|
|
20448
|
+
if (typeEnd === 0 || value[typeEnd] !== '/') return null;
|
|
20449
|
+
const subtypeEnd = tokenEnd(value, typeEnd + 1);
|
|
20450
|
+
if (subtypeEnd === typeEnd + 1) return null;
|
|
20451
|
+
|
|
20452
|
+
const type = value.slice(0, typeEnd).toLowerCase();
|
|
20453
|
+
const subtype = value.slice(typeEnd + 1, subtypeEnd).toLowerCase();
|
|
20454
|
+
const parameters = new Map();
|
|
20455
|
+
|
|
20456
|
+
// parameters = *( OWS ";" OWS [ parameter ] )
|
|
20457
|
+
let index = subtypeEnd;
|
|
20458
|
+
while (index < value.length) {
|
|
20459
|
+
index = owsEnd(value, index);
|
|
20460
|
+
if (value[index] !== ';') return null;
|
|
20461
|
+
index = owsEnd(value, index + 1);
|
|
20462
|
+
if (index === value.length || value[index] === ';') continue; // empty slot
|
|
20463
|
+
|
|
20464
|
+
const nameEnd = tokenEnd(value, index);
|
|
20465
|
+
if (nameEnd === index || value[nameEnd] !== '=') return null;
|
|
20466
|
+
const name = value.slice(index, nameEnd).toLowerCase();
|
|
20467
|
+
|
|
20468
|
+
let parameterValue;
|
|
20469
|
+
if (value[nameEnd + 1] === '"') {
|
|
20470
|
+
const quoted = readQuotedString(value, nameEnd + 1);
|
|
20471
|
+
if (!quoted) return null;
|
|
20472
|
+
parameterValue = quoted.text;
|
|
20473
|
+
index = quoted.end;
|
|
20474
|
+
} else {
|
|
20475
|
+
const valueEnd = tokenEnd(value, nameEnd + 1);
|
|
20476
|
+
if (valueEnd === nameEnd + 1) return null;
|
|
20477
|
+
parameterValue = value.slice(nameEnd + 1, valueEnd);
|
|
20478
|
+
index = valueEnd;
|
|
20479
|
+
}
|
|
20480
|
+
|
|
20481
|
+
if (!parameters.has(name)) parameters.set(name, parameterValue);
|
|
20482
|
+
}
|
|
20483
|
+
|
|
20484
|
+
return { type, subtype, essence: `${type}/${subtype}`, parameters };
|
|
20485
|
+
}
|
|
20486
|
+
|
|
20487
|
+
/**
|
|
20488
|
+
* The essence of a content type: its lowercased `type/subtype`, parameters
|
|
20489
|
+
* dropped (`application/json` of `Application/JSON; charset=utf-8`). An exact
|
|
20490
|
+
* type filter matches an ingot on it.
|
|
20491
|
+
*
|
|
20492
|
+
* The x.sv page runs this function's source (MEDIA_TYPE_SCRIPT), so it keeps
|
|
20493
|
+
* to the ECMAScript 2018 the page parses as (docs/GOTCHAS.md).
|
|
20494
|
+
*
|
|
20495
|
+
* @param {unknown} value
|
|
20496
|
+
* @returns {string|null} null when the value is not exactly one well-formed
|
|
20497
|
+
* media type
|
|
20498
|
+
*/
|
|
20499
|
+
function mediaTypeEssence(value) {
|
|
20500
|
+
const mediaType = parseMediaType(value);
|
|
20501
|
+
return mediaType === null ? null : mediaType.essence;
|
|
20502
|
+
}
|
|
20503
|
+
|
|
20504
|
+
/**
|
|
20505
|
+
* Sound formats platforms type outside the audio tree, each an essence: the
|
|
20506
|
+
* Ogg container, as Firefox types every `.ogg` file (any other platform's
|
|
20507
|
+
* audio/ogg), and WMA as Chrome on macOS types a `.wma` file (Firefox's
|
|
20508
|
+
* audio/x-ms-wma). Each is filed with the audio (mediaTypeFamily), and is
|
|
20509
|
+
* the audio kind's (./ingot-kind.js), so a file's icon and the type filter
|
|
20510
|
+
* that lists it agree.
|
|
20511
|
+
*/
|
|
20512
|
+
const SOUND_TYPES_OUTSIDE_AUDIO = Object.freeze(['application/ogg', 'video/x-ms-wma']);
|
|
20513
|
+
|
|
20514
|
+
new Set(SOUND_TYPES_OUTSIDE_AUDIO);
|
|
20515
|
+
|
|
20516
|
+
/**
|
|
20517
|
+
* Content-type policy for vault and spark bytes a browser page displays or
|
|
20518
|
+
* saves.
|
|
20519
|
+
*
|
|
20520
|
+
* Every display blob becomes a blob: URL in the displaying page's own origin,
|
|
20521
|
+
* and a viewer can open one as a top-level document ("Open image in new tab",
|
|
20522
|
+
* dragging a thumbnail to the tab bar). A stored content_type is caller-supplied
|
|
20523
|
+
* (the public upload portal and any spark creator included), so a blob typed
|
|
20524
|
+
* image/svg+xml, text/html or any XML type would run that caller's script as
|
|
20525
|
+
* the page. Only types every browser renders inertly may therefore reach one,
|
|
20526
|
+
* decided by allowlist so an unknown or malformed type fails closed: the
|
|
20527
|
+
* essence is read by the platform's one media-type parser, and a declared value
|
|
20528
|
+
* that is not exactly one well-formed media type matches no entry.
|
|
20529
|
+
*
|
|
20530
|
+
* A save hands the browser a blob too, and a browser renames a saved copy by
|
|
20531
|
+
* the blob's type, by its own MIME table, refused extensions included:
|
|
20532
|
+
* Firefox saves `Invoice` handed as `application/x-javascript` as
|
|
20533
|
+
* `Invoice.js`, and `Invoice.pdf` handed as `image/svg+xml` as `Invoice.svg`,
|
|
20534
|
+
* and Chromium completes a name that has no extension from a blob's type
|
|
20535
|
+
* alike. Neither completes or replaces an extension by the type of a name
|
|
20536
|
+
* handed as application/octet-stream (docs/GOTCHAS.md). The name a file
|
|
20537
|
+
* saves under is completed by the MIME registry, which only the server
|
|
20538
|
+
* carries (Core answers it as `download_filename`, by ./media-type-node.js
|
|
20539
|
+
* downloadFilename), so a save hands the browser the display-safe type as
|
|
20540
|
+
* well: an inert type keeps its own, from which a browser completes a name
|
|
20541
|
+
* the registry left bare (`Recording` under `audio/flac` saves as
|
|
20542
|
+
* `Recording.flac`), and every other type goes as opaque bytes.
|
|
20543
|
+
*
|
|
20544
|
+
* The one rule for every surface that does this: the web console consumes these
|
|
20545
|
+
* functions directly (its file display path retypes through withDisplaySafeType,
|
|
20546
|
+
* as the one blob save does, saveBlob in ./browser-download.js), the x.sv pages
|
|
20547
|
+
* run this module's own source (DISPLAY_CONTENT_TYPE_SCRIPT), and Forge serves a
|
|
20548
|
+
* response inline on its own origin only when isInertDocumentType says so
|
|
20549
|
+
* (apps/forge/src/routes/decrypt.js). Forge and every client save hand an
|
|
20550
|
+
* inert type to the browser under its own type whatever the file's name, since
|
|
20551
|
+
* a browser renames a download by the type it is handed: an inert type is an
|
|
20552
|
+
* image, audio, video or PDF format, so whatever extension a browser gives its
|
|
20553
|
+
* copy opens it as what it is.
|
|
20554
|
+
*
|
|
20555
|
+
* BROWSER-SAFE: string handling and the platform's Blob, no Node built-ins.
|
|
20556
|
+
*/
|
|
20557
|
+
|
|
20558
|
+
/**
|
|
20559
|
+
* Raster formats: decoded as pixels by <img>, never parsed as a document that
|
|
20560
|
+
* could carry script. HEIC/HEIF stay listed for the case where on-the-fly JPEG
|
|
20561
|
+
* conversion fails and the original bytes are shown as-is.
|
|
20562
|
+
*/
|
|
20563
|
+
const INERT_IMAGE_TYPES = Object.freeze([
|
|
20564
|
+
'image/jpeg',
|
|
20565
|
+
'image/jpg',
|
|
20566
|
+
'image/pjpeg',
|
|
20567
|
+
'image/png',
|
|
20568
|
+
'image/x-png',
|
|
20569
|
+
'image/apng',
|
|
20570
|
+
'image/gif',
|
|
20571
|
+
'image/webp',
|
|
20572
|
+
'image/avif',
|
|
20573
|
+
'image/jxl',
|
|
20574
|
+
'image/bmp',
|
|
20575
|
+
'image/x-ms-bmp',
|
|
20576
|
+
'image/x-icon',
|
|
20577
|
+
'image/vnd.microsoft.icon',
|
|
20578
|
+
'image/tiff',
|
|
20579
|
+
'image/heic',
|
|
20580
|
+
'image/heif'
|
|
20581
|
+
]);
|
|
20582
|
+
|
|
20583
|
+
new Set(INERT_IMAGE_TYPES);
|
|
20584
|
+
|
|
20585
|
+
/**
|
|
20586
|
+
* The platform's one essence reader (./media-type.js), bound in this module's
|
|
20587
|
+
* own scope. The functions DISPLAY_CONTENT_TYPE_SCRIPT carries read it by this
|
|
20588
|
+
* name, which the page binds to the reader MEDIA_TYPE_SCRIPT declares, never
|
|
20589
|
+
* by its imported name: a module transform rewrites an imported name inside a
|
|
20590
|
+
* function's source (vitest's, which every suite runs this module under, turns
|
|
20591
|
+
* `mediaTypeEssence` into `__vite_ssr_import_0__.mediaTypeEssence`), a name no
|
|
20592
|
+
* page declares.
|
|
20593
|
+
*/
|
|
20594
|
+
const essenceOf = mediaTypeEssence;
|
|
20595
|
+
|
|
20596
|
+
/*
|
|
20597
|
+
* Audio and video formats, each under the types the MIME registry files it
|
|
20598
|
+
* under and the ones browsers and Apple's platforms report for it
|
|
20599
|
+
* (`audio/flac`, `audio/vnd.wave`, `audio/aiff`, Chromium's `video/matroska`
|
|
20600
|
+
* and `audio/matroska`, Firefox's `application/ogg` for a `.ogg` file, and,
|
|
20601
|
+
* where Chromium asks the platform: on macOS `video/avi` for a `.avi` file,
|
|
20602
|
+
* `video/x-ms-wma` for a `.wma` one and `audio/x-m4r` for an iPhone ringtone,
|
|
20603
|
+
* and on Windows `audio/vnd.dlna.adts` for a `.aac` one):
|
|
20604
|
+
* encoded sound and pictures, which a browser plays in its own player, never
|
|
20605
|
+
* as a scriptable document, or downloads under the extension its table names
|
|
20606
|
+
* for the type (`.mp3`, `.mov`, `.avi`, `.ogg`), which a desktop opens in a
|
|
20607
|
+
* media player.
|
|
20608
|
+
*
|
|
20609
|
+
* Never a playlist or a stream redirector (`audio/x-mpegurl`,
|
|
20610
|
+
* `audio/x-scpls`, `video/x-ms-asx`, `audio/x-pn-realaudio`): it names media
|
|
20611
|
+
* a player then fetches, and a browser downloads it whatever name it is
|
|
20612
|
+
* handed, saving it as `.m3u`, `.pls`, `.asx` (which Outlook blocks) or
|
|
20613
|
+
* `.ram`; nor `video/x-ms-asf`, under which the registry files the `.asx`
|
|
20614
|
+
* redirector too. An allowlist, so an audio or video type no entry names
|
|
20615
|
+
* fails closed, one with a structured-syntax suffix among them (`video/x+xml`,
|
|
20616
|
+
* which a navigated browser renders as an XML document, script included).
|
|
20617
|
+
*/
|
|
20618
|
+
|
|
20619
|
+
/** The audio formats: sound, which a browser plays in its player. */
|
|
20620
|
+
const INERT_AUDIO_TYPES = Object.freeze([
|
|
20621
|
+
'audio/3gpp',
|
|
20622
|
+
'audio/aac',
|
|
20623
|
+
'audio/x-aac',
|
|
20624
|
+
'audio/vnd.dlna.adts',
|
|
20625
|
+
'audio/aiff',
|
|
20626
|
+
'audio/x-aiff',
|
|
20627
|
+
'audio/amr',
|
|
20628
|
+
'audio/basic',
|
|
20629
|
+
'audio/flac',
|
|
20630
|
+
'audio/x-flac',
|
|
20631
|
+
'audio/matroska',
|
|
20632
|
+
'audio/x-matroska',
|
|
20633
|
+
'audio/midi',
|
|
20634
|
+
'audio/mp3',
|
|
20635
|
+
'audio/mpeg',
|
|
20636
|
+
'audio/mp4',
|
|
20637
|
+
'audio/x-m4a',
|
|
20638
|
+
'audio/x-m4r',
|
|
20639
|
+
'audio/ogg',
|
|
20640
|
+
'audio/wav',
|
|
20641
|
+
'audio/wave',
|
|
20642
|
+
'audio/vnd.wave',
|
|
20643
|
+
'audio/x-wav',
|
|
20644
|
+
'audio/webm',
|
|
20645
|
+
'audio/x-caf',
|
|
20646
|
+
'audio/x-ms-wma',
|
|
20647
|
+
'video/x-ms-wma'
|
|
20648
|
+
]);
|
|
20649
|
+
|
|
20650
|
+
/**
|
|
20651
|
+
* The Ogg container, as Firefox types a `.ogg` file: the one inert type that
|
|
20652
|
+
* does not say whether its files hold sound alone or pictures too. It renders
|
|
20653
|
+
* as a video, whose player plays either.
|
|
20654
|
+
*/
|
|
20655
|
+
const OGG_CONTAINER_TYPE = 'application/ogg';
|
|
20656
|
+
|
|
20657
|
+
/**
|
|
20658
|
+
* The video formats: pictures and sound, which a browser plays in its player,
|
|
20659
|
+
* the Ogg container among them (OGG_CONTAINER_TYPE).
|
|
20660
|
+
*/
|
|
20661
|
+
const INERT_VIDEO_TYPES = Object.freeze([
|
|
20662
|
+
'video/3gpp',
|
|
20663
|
+
'video/3gpp2',
|
|
20664
|
+
'video/matroska',
|
|
20665
|
+
'video/x-matroska',
|
|
20666
|
+
'video/mp2t',
|
|
20667
|
+
'video/mp4',
|
|
20668
|
+
'video/x-m4v',
|
|
20669
|
+
'video/mpeg',
|
|
20670
|
+
'video/ogg',
|
|
20671
|
+
OGG_CONTAINER_TYPE,
|
|
20672
|
+
'video/quicktime',
|
|
20673
|
+
'video/webm',
|
|
20674
|
+
'video/x-flv',
|
|
20675
|
+
'video/x-msvideo',
|
|
20676
|
+
'video/avi',
|
|
20677
|
+
'video/x-ms-wmv'
|
|
20678
|
+
]);
|
|
20679
|
+
|
|
20680
|
+
const PDF_TYPE = 'application/pdf';
|
|
20681
|
+
|
|
20682
|
+
/**
|
|
20683
|
+
* How each inert type renders as a top-level document, by essence
|
|
20684
|
+
* (inertRendering). The x.sv pages read it through
|
|
20685
|
+
* DISPLAY_CONTENT_TYPE_SCRIPT, which serializes it.
|
|
20686
|
+
*/
|
|
20687
|
+
const INERT_RENDERING = new Map([
|
|
20688
|
+
...INERT_IMAGE_TYPES.map((type) => [type, 'image']),
|
|
20689
|
+
...INERT_AUDIO_TYPES.map((type) => [type, 'audio']),
|
|
20690
|
+
...INERT_VIDEO_TYPES.map((type) => [type, 'video']),
|
|
20691
|
+
[PDF_TYPE, 'pdf']
|
|
20692
|
+
]);
|
|
20693
|
+
|
|
20694
|
+
/**
|
|
20695
|
+
* Every type a browser renders inertly as a top-level document, as an essence:
|
|
20696
|
+
* a raster image (INERT_IMAGE_TYPES), an audio or video format, or a PDF,
|
|
20697
|
+
* which the browser's own PDF viewer renders.
|
|
20698
|
+
*/
|
|
20699
|
+
Object.freeze([...INERT_RENDERING.keys()]);
|
|
20700
|
+
|
|
20701
|
+
const OPAQUE_CONTENT_TYPE = 'application/octet-stream';
|
|
20702
|
+
|
|
20703
|
+
/** isInertDocumentType over an essence already read (essenceOf), null for a value that is no media type. */
|
|
20704
|
+
function isInertDocumentEssence(type) {
|
|
20705
|
+
return INERT_RENDERING.has(type);
|
|
20706
|
+
}
|
|
20707
|
+
|
|
20708
|
+
/**
|
|
20709
|
+
* The type a blob a page hands the browser, to display or to save, may carry:
|
|
20710
|
+
* its own essence when the browser renders it inertly, otherwise
|
|
20711
|
+
* application/octet-stream, which a navigated blob URL downloads instead of
|
|
20712
|
+
* rendering and which no browser completes a saved name from.
|
|
20713
|
+
* @param {string|null|undefined} contentType
|
|
20714
|
+
* @returns {string}
|
|
20715
|
+
*/
|
|
20716
|
+
function displaySafeContentType(contentType) {
|
|
20717
|
+
const type = essenceOf(contentType);
|
|
20718
|
+
return isInertDocumentEssence(type) ? type : OPAQUE_CONTENT_TYPE;
|
|
20719
|
+
}
|
|
20720
|
+
|
|
20721
|
+
/**
|
|
20722
|
+
* A blob as a page hands it to the browser, to display or to save: retyped to
|
|
20723
|
+
* displaySafeContentType of its own type, or the blob itself when it already
|
|
20724
|
+
* carries that type. slice() retypes without copying the bytes.
|
|
20725
|
+
* @param {Blob} blob
|
|
20726
|
+
* @returns {Blob}
|
|
20727
|
+
*/
|
|
20728
|
+
function withDisplaySafeType(blob) {
|
|
20729
|
+
const safeType = displaySafeContentType(blob.type);
|
|
20730
|
+
return blob.type === safeType ? blob : blob.slice(0, blob.size, safeType);
|
|
20731
|
+
}
|
|
20732
|
+
|
|
20353
20733
|
/**
|
|
20354
20734
|
* Files brought to a message's composer by drag, drop and paste, handled
|
|
20355
20735
|
* alike by every composer that takes them: the console's reply composer and
|
|
@@ -20551,6 +20931,7 @@ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
|
20551
20931
|
|
|
20552
20932
|
const PATHS = Object.freeze({
|
|
20553
20933
|
back: 'm14.5 6-6 6 6 6',
|
|
20934
|
+
arrowRight: 'M4 12h16m-6-6 6 6-6 6',
|
|
20554
20935
|
close: 'm6 6 12 12M18 6 6 18',
|
|
20555
20936
|
external: 'M14 4h6v6m0-6L10 14M11 5H5a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1v-6',
|
|
20556
20937
|
check: 'm5 12 4 4L19 6',
|
|
@@ -20607,10 +20988,10 @@ function helpDeskIcon(name) {
|
|
|
20607
20988
|
* takes no files from its customers is refused in words
|
|
20608
20989
|
* (NO_CUSTOMER_FILES_COPY), and one brought while files cannot join is
|
|
20609
20990
|
* never the browser's to open in place of the unsent message.
|
|
20610
|
-
* - **
|
|
20611
|
-
*
|
|
20612
|
-
*
|
|
20613
|
-
*
|
|
20991
|
+
* - **Requirements.** A rejected file opens one modal with its reason and
|
|
20992
|
+
* the attachment rules. A selection shares that modal, and dismissing it
|
|
20993
|
+
* leaves later refusals from the same selection in their chips. Accepted
|
|
20994
|
+
* images have local previews, including while waiting for sign-in.
|
|
20614
20995
|
* - **Uploading.** The browser's check (attachmentRefusal) first, then the
|
|
20615
20996
|
* host's transport: its target (the request a reply belongs to, or the
|
|
20616
20997
|
* draft a new request uploads to, which may not exist yet: the file then
|
|
@@ -20675,21 +21056,27 @@ const COMPOSER_CSS = `
|
|
|
20675
21056
|
.svhd-composer .svhd-composer-drop{position:absolute;inset:0;z-index:1;display:flex;align-items:center;justify-content:center;margin:0;padding:12px;border-radius:5px;background:${HELP_DESK_COLORS.selection};color:${HELP_DESK_ACCENT.ink};font-size:15px;font-weight:600;line-height:1.4;text-align:center;pointer-events:none}
|
|
20676
21057
|
.svhd-composer .svhd-composer-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:0 4px;padding:0 4px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
|
|
20677
21058
|
.svhd-composer .svhd-composer-attach{display:inline-flex;align-items:center;gap:6px;min-height:44px;margin:0;padding:0 8px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};font-family:inherit;font-size:14px;font-weight:600;line-height:1.4;cursor:pointer}
|
|
20678
|
-
.svhd-composer .svhd-composer-attach:hover
|
|
21059
|
+
.svhd-composer .svhd-composer-attach:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
|
|
20679
21060
|
.svhd-composer .svhd-composer-attach:disabled{opacity:.6;cursor:default}
|
|
20680
21061
|
.svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
|
|
20681
|
-
.svhd-composer .svhd-composer-
|
|
20682
|
-
.svhd-composer .svhd-composer-
|
|
20683
|
-
.svhd-composer .svhd-composer-
|
|
20684
|
-
.svhd-composer .svhd-composer-
|
|
20685
|
-
.svhd-composer .svhd-composer-
|
|
20686
|
-
.svhd-composer .svhd-composer-
|
|
20687
|
-
.svhd-composer .svhd-composer-
|
|
20688
|
-
.svhd-composer .svhd-composer-
|
|
20689
|
-
.svhd-composer .svhd-composer-
|
|
21062
|
+
.svhd-composer .svhd-composer-validation-dialog{position:fixed;inset:0;width:min(480px,calc(100vw - 32px));max-height:calc(100dvh - 32px);margin:auto;padding:0;overflow:auto;border:1px solid ${HELP_DESK_COLORS.lineStrong};border-radius:12px;background:${HELP_DESK_COLORS.surface};color:${HELP_DESK_COLORS.ink};font:400 15px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;text-align:left;overscroll-behavior:contain}
|
|
21063
|
+
.svhd-composer .svhd-composer-validation-dialog::backdrop{background:color-mix(in srgb,${HELP_DESK_COLORS.modalBackdrop} 60%,transparent)}
|
|
21064
|
+
.svhd-composer .svhd-composer-validation-header{display:flex;align-items:center;gap:12px;padding:16px 16px 8px 24px}
|
|
21065
|
+
.svhd-composer .svhd-composer-validation-title{flex:1;min-width:0;margin:0;font-family:inherit;font-size:20px;font-weight:600;line-height:1.3;overflow-wrap:anywhere}
|
|
21066
|
+
.svhd-composer .svhd-composer-validation-close{display:grid;place-items:center;flex:none;width:44px;height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer}
|
|
21067
|
+
.svhd-composer .svhd-composer-validation-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${HELP_DESK_COLORS.fillStrong};color:${HELP_DESK_COLORS.ink}}
|
|
21068
|
+
.svhd-composer .svhd-composer-validation-close svg,.svhd-composer .svhd-attachment-remove svg{display:block;width:16px;height:16px}
|
|
21069
|
+
.svhd-composer .svhd-composer-refusals{display:grid;gap:12px;margin:0;padding:0 24px 24px;list-style:none;color:${HELP_DESK_COLORS.body};overflow-wrap:anywhere}
|
|
21070
|
+
.svhd-composer .svhd-composer-refusals strong{display:block;margin-bottom:2px;color:${HELP_DESK_COLORS.ink};font-weight:600}
|
|
21071
|
+
.svhd-composer .svhd-composer-requirements{padding:20px 24px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong};background:${HELP_DESK_COLORS.canvas};color:${HELP_DESK_COLORS.body};font-size:13px;line-height:1.5}
|
|
21072
|
+
.svhd-composer .svhd-composer-requirements h3{margin:0 0 8px;color:${HELP_DESK_COLORS.ink};font-family:inherit;font-size:14px;font-weight:600}
|
|
21073
|
+
.svhd-composer .svhd-composer-requirements p{margin:0}
|
|
21074
|
+
.svhd-composer .svhd-composer-requirements p+p{margin-top:8px}
|
|
20690
21075
|
.svhd-composer .svhd-attachment-chips{display:flex;flex-wrap:wrap;gap:8px;list-style:none;margin:0;padding:8px;border-top:1px solid ${HELP_DESK_COLORS.fillStrong}}
|
|
20691
21076
|
.svhd-composer .svhd-attachment-chips:empty{display:none}
|
|
20692
21077
|
.svhd-composer .svhd-attachment-chip{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;align-content:start;flex:0 1 280px;min-width:0;max-width:100%;margin:0;padding:0 0 8px 10px;border:1px solid ${HELP_DESK_COLORS.fillStrong};border-radius:6px;background:${HELP_DESK_COLORS.canvas};font-size:13px;line-height:1.4}
|
|
21078
|
+
.svhd-composer .svhd-attachment-thumbnail{grid-column:1/-1;display:block;width:100%;height:96px;object-fit:contain;margin:8px 0;background:${HELP_DESK_COLORS.field};border-radius:4px}
|
|
21079
|
+
.svhd-composer .svhd-attachment-preview-unavailable{grid-column:1/-1;margin:8px 8px 0 0;color:${HELP_DESK_COLORS.muted};font-size:12px}
|
|
20693
21080
|
.svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${HELP_DESK_COLORS.ink}}
|
|
20694
21081
|
.svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${HELP_DESK_COLORS.body};font-size:12px;overflow-wrap:anywhere}
|
|
20695
21082
|
.svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${HELP_DESK_COLORS.error}}
|
|
@@ -20697,7 +21084,7 @@ const COMPOSER_CSS = `
|
|
|
20697
21084
|
.svhd-composer .svhd-attachment-remove{display:grid;place-items:center;width:44px;height:44px;min-height:44px;margin:0;padding:0;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_COLORS.body};cursor:pointer}
|
|
20698
21085
|
.svhd-composer .svhd-attachment-retry{grid-column:2;min-height:44px;margin:0;padding:0 10px;border:0;border-radius:6px;background:transparent;color:${HELP_DESK_ACCENT.ink};font-family:inherit;font-size:13px;font-weight:600;line-height:1.4;text-decoration:underline;cursor:pointer}
|
|
20699
21086
|
.svhd-composer .svhd-attachment-remove:disabled,.svhd-composer .svhd-attachment-retry:disabled{opacity:.6;cursor:default}
|
|
20700
|
-
.svhd-composer .svhd-composer-attach:focus-visible,.svhd-composer .svhd-composer-
|
|
21087
|
+
.svhd-composer .svhd-composer-attach:focus-visible,.svhd-composer .svhd-composer-validation-close:focus-visible,.svhd-composer .svhd-attachment-remove:focus-visible,.svhd-composer .svhd-attachment-retry:focus-visible{${INSET_RING}}
|
|
20701
21088
|
.svhd-composer-notice{margin:0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5}
|
|
20702
21089
|
.svhd-composer [hidden],.svhd-composer-notice[hidden]{display:none!important}
|
|
20703
21090
|
`;
|
|
@@ -20734,8 +21121,8 @@ const RECEIVED_COPY = 'File received. Waiting for storage confirmation.';
|
|
|
20734
21121
|
const UPLOAD_FAILED_COPY = "This file couldn't be uploaded. Try again or remove it.";
|
|
20735
21122
|
const UPLOADING_COPY = 'Uploading';
|
|
20736
21123
|
const VERIFYING_COPY = 'Verifying stored file';
|
|
20737
|
-
/**
|
|
20738
|
-
const
|
|
21124
|
+
/** Requirements appear only after a file is refused. */
|
|
21125
|
+
const VALIDATION_TITLE = 'Unable to attach files';
|
|
20739
21126
|
const ACCEPTED_KINDS_COPY = `You can attach ${ACCEPTED_ATTACHMENTS_COPY}.`;
|
|
20740
21127
|
|
|
20741
21128
|
/** What a message's files still need before it can be sent, from the most pressing. */
|
|
@@ -20874,9 +21261,7 @@ function createHelpDeskComposer(options) {
|
|
|
20874
21261
|
const zone = dropZone ?? frame;
|
|
20875
21262
|
const fields = [textarea, ...pasteFields];
|
|
20876
21263
|
|
|
20877
|
-
// The
|
|
20878
|
-
// extensions a request takes first, never the check), and its (?) tip,
|
|
20879
|
-
// whose limits also describe Attach.
|
|
21264
|
+
// The chooser filters names; the canonical attachment check decides.
|
|
20880
21265
|
const input = document.createElement('input');
|
|
20881
21266
|
input.type = 'file';
|
|
20882
21267
|
input.name = 'attachments';
|
|
@@ -20884,40 +21269,13 @@ function createHelpDeskComposer(options) {
|
|
|
20884
21269
|
input.accept = ATTACHMENT_INPUT_ACCEPT;
|
|
20885
21270
|
input.hidden = true;
|
|
20886
21271
|
input.tabIndex = -1;
|
|
20887
|
-
const hint = document.createElement('p');
|
|
20888
|
-
hint.id = `${textarea.id}-attachment-hint`;
|
|
20889
|
-
hint.textContent = CUSTOMER_ATTACHMENTS_HINT;
|
|
20890
|
-
const kinds = document.createElement('p');
|
|
20891
|
-
kinds.textContent = ACCEPTED_KINDS_COPY;
|
|
20892
21272
|
const attach = button$1('svhd-composer-attach', 'Attach files');
|
|
20893
|
-
attach.setAttribute('aria-describedby', hint.id);
|
|
20894
21273
|
const attachText = document.createElement('span');
|
|
20895
21274
|
attachText.textContent = 'Attach';
|
|
20896
21275
|
attach.append(helpDeskIcon('paperclip'), attachText);
|
|
20897
|
-
const helpPanel = document.createElement('div');
|
|
20898
|
-
helpPanel.id = `${textarea.id}-attachment-help`;
|
|
20899
|
-
helpPanel.className = 'svhd-composer-help-panel';
|
|
20900
|
-
helpPanel.setAttribute('role', 'region');
|
|
20901
|
-
helpPanel.setAttribute('aria-label', HELP_TITLE);
|
|
20902
|
-
helpPanel.hidden = true;
|
|
20903
|
-
const helpCopy = document.createElement('div');
|
|
20904
|
-
helpCopy.className = 'svhd-composer-help-copy';
|
|
20905
|
-
helpCopy.append(hint, kinds);
|
|
20906
|
-
const helpClose = button$1('svhd-composer-help-close', 'Close');
|
|
20907
|
-
helpClose.title = 'Close';
|
|
20908
|
-
helpClose.append(helpDeskIcon('close'));
|
|
20909
|
-
helpPanel.append(helpCopy, helpClose);
|
|
20910
|
-
const helpTrigger = button$1('svhd-composer-help', `Help: ${HELP_TITLE}`);
|
|
20911
|
-
helpTrigger.setAttribute('aria-expanded', 'false');
|
|
20912
|
-
helpTrigger.setAttribute('aria-controls', helpPanel.id);
|
|
20913
|
-
const glyph = document.createElement('span');
|
|
20914
|
-
glyph.className = 'svhd-composer-help-glyph';
|
|
20915
|
-
glyph.setAttribute('aria-hidden', 'true');
|
|
20916
|
-
glyph.textContent = '?';
|
|
20917
|
-
helpTrigger.append(glyph);
|
|
20918
21276
|
const toolbar = document.createElement('div');
|
|
20919
21277
|
toolbar.className = 'svhd-composer-toolbar';
|
|
20920
|
-
toolbar.append(attach,
|
|
21278
|
+
toolbar.append(attach, input);
|
|
20921
21279
|
const list = document.createElement('ul');
|
|
20922
21280
|
list.className = 'svhd-attachment-chips';
|
|
20923
21281
|
list.setAttribute('aria-label', 'Attached files');
|
|
@@ -20929,10 +21287,151 @@ function createHelpDeskComposer(options) {
|
|
|
20929
21287
|
let locked = false;
|
|
20930
21288
|
let pickingDisabled = false;
|
|
20931
21289
|
let destroyed = false;
|
|
21290
|
+
let validation = null;
|
|
20932
21291
|
const accepting = () => transport !== null && !locked && !pickingDisabled && !destroyed;
|
|
20933
21292
|
const current = (entry, ownRevision) =>
|
|
20934
21293
|
!destroyed && revision === ownRevision && entries.includes(entry) && !entry.controller?.signal.aborted;
|
|
20935
21294
|
|
|
21295
|
+
/** A selection keeps its refusal lifecycle even when its files settle at different times. */
|
|
21296
|
+
const selection = () => ({
|
|
21297
|
+
dismissed: false,
|
|
21298
|
+
returnFocus: document.activeElement instanceof HTMLElement && document.activeElement !== document.body
|
|
21299
|
+
? document.activeElement : textarea
|
|
21300
|
+
});
|
|
21301
|
+
|
|
21302
|
+
function dismissValidation() {
|
|
21303
|
+
const shown = validation;
|
|
21304
|
+
if (!shown) return;
|
|
21305
|
+
validation = null;
|
|
21306
|
+
for (const batch of shown.batches) batch.dismissed = true;
|
|
21307
|
+
if (shown.dialog.open) shown.dialog.close();
|
|
21308
|
+
shown.dialog.remove();
|
|
21309
|
+
document.documentElement.style.overflow = shown.overflow;
|
|
21310
|
+
if (!destroyed) {
|
|
21311
|
+
const target = shown.returnFocus.isConnected && !shown.returnFocus.disabled ? shown.returnFocus : textarea;
|
|
21312
|
+
target.focus();
|
|
21313
|
+
}
|
|
21314
|
+
}
|
|
21315
|
+
|
|
21316
|
+
/** Exact refusals share one top-layer dialog; later files never steal focus from its reader. */
|
|
21317
|
+
function reportRefusal(batch, key, filename, copy) {
|
|
21318
|
+
if (destroyed || batch.dismissed) return;
|
|
21319
|
+
let shown = validation;
|
|
21320
|
+
if (!shown) {
|
|
21321
|
+
const dialog = document.createElement('dialog');
|
|
21322
|
+
dialog.className = 'svhd-composer-validation-dialog';
|
|
21323
|
+
const title = document.createElement('h2');
|
|
21324
|
+
title.id = `${textarea.id}-attachment-validation-title`;
|
|
21325
|
+
title.className = 'svhd-composer-validation-title';
|
|
21326
|
+
title.textContent = VALIDATION_TITLE;
|
|
21327
|
+
dialog.setAttribute('aria-labelledby', title.id);
|
|
21328
|
+
const close = button$1('svhd-composer-validation-close', 'Close');
|
|
21329
|
+
close.title = 'Close';
|
|
21330
|
+
close.append(helpDeskIcon('close'));
|
|
21331
|
+
const header = document.createElement('div');
|
|
21332
|
+
header.className = 'svhd-composer-validation-header';
|
|
21333
|
+
header.append(title, close);
|
|
21334
|
+
const reasons = document.createElement('ul');
|
|
21335
|
+
reasons.className = 'svhd-composer-refusals';
|
|
21336
|
+
reasons.id = `${textarea.id}-attachment-refusals`;
|
|
21337
|
+
dialog.setAttribute('aria-describedby', reasons.id);
|
|
21338
|
+
reasons.setAttribute('aria-live', 'polite');
|
|
21339
|
+
const requirements = document.createElement('div');
|
|
21340
|
+
requirements.className = 'svhd-composer-requirements';
|
|
21341
|
+
const heading = document.createElement('h3');
|
|
21342
|
+
heading.textContent = 'What you can attach';
|
|
21343
|
+
const limits = document.createElement('p');
|
|
21344
|
+
limits.textContent = deskRefusesFiles ? NO_CUSTOMER_FILES_COPY : CUSTOMER_ATTACHMENTS_HINT;
|
|
21345
|
+
requirements.append(heading, limits);
|
|
21346
|
+
if (!deskRefusesFiles) {
|
|
21347
|
+
const kinds = document.createElement('p');
|
|
21348
|
+
kinds.textContent = ACCEPTED_KINDS_COPY;
|
|
21349
|
+
requirements.append(kinds);
|
|
21350
|
+
}
|
|
21351
|
+
dialog.append(header, reasons, requirements);
|
|
21352
|
+
shown = { dialog, reasons, close, issues: new Map(), batches: new Set(), returnFocus: batch.returnFocus, overflow: document.documentElement.style.overflow };
|
|
21353
|
+
validation = shown;
|
|
21354
|
+
close.addEventListener('click', () => dismissValidation());
|
|
21355
|
+
dialog.addEventListener('cancel', (event) => { event.preventDefault(); event.stopPropagation(); dismissValidation(); });
|
|
21356
|
+
dialog.addEventListener('close', () => { if (validation === shown) dismissValidation(); });
|
|
21357
|
+
dialog.addEventListener('keydown', (event) => {
|
|
21358
|
+
if (event.key === 'Escape') {
|
|
21359
|
+
event.preventDefault();
|
|
21360
|
+
event.stopPropagation();
|
|
21361
|
+
dismissValidation();
|
|
21362
|
+
} else if (event.key === 'Tab') {
|
|
21363
|
+
// Close is this dialog's one focusable control; keep keyboard focus with it.
|
|
21364
|
+
event.preventDefault();
|
|
21365
|
+
close.focus();
|
|
21366
|
+
}
|
|
21367
|
+
});
|
|
21368
|
+
const outside = (event) => {
|
|
21369
|
+
if (event.target !== dialog) return false;
|
|
21370
|
+
const bounds = dialog.getBoundingClientRect();
|
|
21371
|
+
return event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom;
|
|
21372
|
+
};
|
|
21373
|
+
let backdropPress = false;
|
|
21374
|
+
dialog.addEventListener('pointerdown', (event) => { backdropPress = outside(event); });
|
|
21375
|
+
dialog.addEventListener('click', (event) => { if (backdropPress && outside(event)) dismissValidation(); backdropPress = false; });
|
|
21376
|
+
frame.append(dialog);
|
|
21377
|
+
}
|
|
21378
|
+
shown.batches.add(batch);
|
|
21379
|
+
let reason = shown.issues.get(key);
|
|
21380
|
+
if (!reason) {
|
|
21381
|
+
reason = document.createElement('li');
|
|
21382
|
+
shown.issues.set(key, reason);
|
|
21383
|
+
shown.reasons.append(reason);
|
|
21384
|
+
}
|
|
21385
|
+
const text = document.createElement('span');
|
|
21386
|
+
text.textContent = copy;
|
|
21387
|
+
reason.replaceChildren();
|
|
21388
|
+
if (filename) {
|
|
21389
|
+
const name = document.createElement('strong');
|
|
21390
|
+
name.textContent = filename;
|
|
21391
|
+
reason.append(name);
|
|
21392
|
+
}
|
|
21393
|
+
reason.append(text);
|
|
21394
|
+
if (!shown.dialog.open) {
|
|
21395
|
+
shown.dialog.showModal();
|
|
21396
|
+
document.documentElement.style.overflow = 'hidden';
|
|
21397
|
+
shown.close.focus();
|
|
21398
|
+
}
|
|
21399
|
+
}
|
|
21400
|
+
|
|
21401
|
+
function releasePreview(entry) {
|
|
21402
|
+
if (!entry.previewUrl) return;
|
|
21403
|
+
URL.revokeObjectURL(entry.previewUrl);
|
|
21404
|
+
entry.previewUrl = null;
|
|
21405
|
+
}
|
|
21406
|
+
|
|
21407
|
+
/** Local validated images need no transfer; every blob is inert even if its declared MIME is hostile. */
|
|
21408
|
+
function preview(entry) {
|
|
21409
|
+
if (entry.previewAttempted || !ACCEPTED_ATTACHMENT_KINDS.images.includes(lastExtension(entry.file.name))) return;
|
|
21410
|
+
entry.previewAttempted = true;
|
|
21411
|
+
const image = document.createElement('img');
|
|
21412
|
+
image.className = 'svhd-attachment-thumbnail';
|
|
21413
|
+
image.alt = `Preview of ${entry.file.name}`;
|
|
21414
|
+
image.decoding = 'async';
|
|
21415
|
+
const unavailable = () => {
|
|
21416
|
+
releasePreview(entry);
|
|
21417
|
+
image.remove();
|
|
21418
|
+
if (destroyed || !entries.includes(entry)) return;
|
|
21419
|
+
const fallback = document.createElement('span');
|
|
21420
|
+
fallback.className = 'svhd-attachment-preview-unavailable';
|
|
21421
|
+
fallback.textContent = 'Preview unavailable';
|
|
21422
|
+
entry.row.prepend(fallback);
|
|
21423
|
+
};
|
|
21424
|
+
image.addEventListener('error', unavailable, { once: true });
|
|
21425
|
+
try {
|
|
21426
|
+
entry.previewUrl = URL.createObjectURL(withDisplaySafeType(entry.file));
|
|
21427
|
+
image.src = entry.previewUrl;
|
|
21428
|
+
entry.row.prepend(image);
|
|
21429
|
+
} catch {
|
|
21430
|
+
// A browser that cannot create a preview still uploads the original file.
|
|
21431
|
+
unavailable();
|
|
21432
|
+
}
|
|
21433
|
+
}
|
|
21434
|
+
|
|
20936
21435
|
// A refusal of files is an alert only while it shows, as a field's error is.
|
|
20937
21436
|
function setNotice(text) {
|
|
20938
21437
|
notice.textContent = text ?? '';
|
|
@@ -20993,9 +21492,12 @@ function createHelpDeskComposer(options) {
|
|
|
20993
21492
|
if (!stillCurrent()) return;
|
|
20994
21493
|
if (refusal) {
|
|
20995
21494
|
entry.retryable = false;
|
|
20996
|
-
|
|
21495
|
+
const copy = refusalCopy(refusal, CUSTOMER_ATTACHMENT_MAX_BYTES);
|
|
21496
|
+
show(entry, FILE_STATE.REFUSED, copy);
|
|
21497
|
+
reportRefusal(entry.batch, entry, entry.file.name, copy);
|
|
20997
21498
|
return;
|
|
20998
21499
|
}
|
|
21500
|
+
preview(entry);
|
|
20999
21501
|
request = 'host';
|
|
21000
21502
|
const target = await transport.target();
|
|
21001
21503
|
if (!stillCurrent()) return;
|
|
@@ -21041,7 +21543,9 @@ function createHelpDeskComposer(options) {
|
|
|
21041
21543
|
entry.attachmentId = upload.attachment_id;
|
|
21042
21544
|
if (Number.isSafeInteger(upload.max_bytes) && upload.max_bytes > 0 && entry.file.size > upload.max_bytes) {
|
|
21043
21545
|
entry.retryable = false;
|
|
21044
|
-
|
|
21546
|
+
const copy = tooLargeCopy(upload.max_bytes);
|
|
21547
|
+
show(entry, FILE_STATE.FAILED, copy);
|
|
21548
|
+
reportRefusal(entry.batch, entry, entry.file.name, copy);
|
|
21045
21549
|
return;
|
|
21046
21550
|
}
|
|
21047
21551
|
entry.progress.value = 0;
|
|
@@ -21074,6 +21578,7 @@ function createHelpDeskComposer(options) {
|
|
|
21074
21578
|
const problem = uploadProblem(refusalOf(request, error), organization);
|
|
21075
21579
|
entry.retryable = problem.retryable;
|
|
21076
21580
|
show(entry, FILE_STATE.FAILED, problem.copy);
|
|
21581
|
+
if (!problem.retryable) reportRefusal(entry.batch, entry, entry.file.name, problem.copy);
|
|
21077
21582
|
} finally {
|
|
21078
21583
|
if (entry.controller === controller) entry.controller = null;
|
|
21079
21584
|
if (entry.operation === operation) entry.operation = null;
|
|
@@ -21106,6 +21611,7 @@ function createHelpDeskComposer(options) {
|
|
|
21106
21611
|
const refocus = document.activeElement === entry.remove;
|
|
21107
21612
|
const index = entries.indexOf(entry);
|
|
21108
21613
|
entry.controller?.abort();
|
|
21614
|
+
releasePreview(entry);
|
|
21109
21615
|
entries = entries.filter((candidate) => candidate !== entry);
|
|
21110
21616
|
entry.row.remove();
|
|
21111
21617
|
setNotice(null);
|
|
@@ -21115,13 +21621,14 @@ function createHelpDeskComposer(options) {
|
|
|
21115
21621
|
if (refocus) (entries[Math.min(index, entries.length - 1)]?.remove ?? attach).focus();
|
|
21116
21622
|
}
|
|
21117
21623
|
|
|
21118
|
-
function add(files) {
|
|
21624
|
+
function add(files, batch = selection()) {
|
|
21119
21625
|
if (!accepting()) return;
|
|
21120
21626
|
const incoming = Array.from(files);
|
|
21121
21627
|
if (incoming.length === 0) return;
|
|
21122
21628
|
const counted = entries.filter((entry) => entry.state !== FILE_STATE.REFUSED).length;
|
|
21123
21629
|
const room = Math.max(0, MAX_ATTACHMENTS_PER_MESSAGE - counted);
|
|
21124
21630
|
setNotice(incoming.length > room ? LIMIT_COPY : null);
|
|
21631
|
+
if (incoming.length > room) reportRefusal(batch, batch, null, LIMIT_COPY);
|
|
21125
21632
|
for (const file of incoming.slice(0, room)) {
|
|
21126
21633
|
const row = document.createElement('li');
|
|
21127
21634
|
row.className = 'svhd-attachment-chip';
|
|
@@ -21148,11 +21655,14 @@ function createHelpDeskComposer(options) {
|
|
|
21148
21655
|
const entry = {
|
|
21149
21656
|
file, row, status, progress, remove: removeButton, retry,
|
|
21150
21657
|
state: FILE_STATE.QUEUED, retryable: false, controller: null, operation: null,
|
|
21151
|
-
target: null, attachmentId: null, sessionUrl: null
|
|
21658
|
+
target: null, attachmentId: null, sessionUrl: null, batch, previewUrl: null, previewAttempted: false
|
|
21152
21659
|
};
|
|
21153
21660
|
removeButton.addEventListener('click', () => remove(entry));
|
|
21154
21661
|
retry.addEventListener('click', () => {
|
|
21155
|
-
if (!locked && entry.retryable)
|
|
21662
|
+
if (!locked && entry.retryable) {
|
|
21663
|
+
entry.batch = selection();
|
|
21664
|
+
void run(entry);
|
|
21665
|
+
}
|
|
21156
21666
|
});
|
|
21157
21667
|
row.append(name, removeButton, status, retry, progress);
|
|
21158
21668
|
list.append(row);
|
|
@@ -21176,13 +21686,18 @@ function createHelpDeskComposer(options) {
|
|
|
21176
21686
|
drop.hidden = !value;
|
|
21177
21687
|
}
|
|
21178
21688
|
function refuseFiles() {
|
|
21179
|
-
if (!notice.hidden && notice.textContent === NO_CUSTOMER_FILES_COPY) return;
|
|
21180
21689
|
setNotice(NO_CUSTOMER_FILES_COPY);
|
|
21690
|
+
const batch = selection();
|
|
21691
|
+
reportRefusal(batch, batch, null, NO_CUSTOMER_FILES_COPY);
|
|
21181
21692
|
}
|
|
21182
21693
|
// A dropped folder is left out, and said so beside any refusal the files with it met.
|
|
21183
21694
|
function attachBrought(files, folders) {
|
|
21184
|
-
|
|
21185
|
-
if (
|
|
21695
|
+
const batch = selection();
|
|
21696
|
+
if (files.length > 0) add(files, batch);
|
|
21697
|
+
if (folders > 0) {
|
|
21698
|
+
setNotice(files.length > 0 && !notice.hidden ? `${FOLDER_REFUSAL_COPY} ${notice.textContent}` : FOLDER_REFUSAL_COPY);
|
|
21699
|
+
reportRefusal(batch, 'folders', null, FOLDER_REFUSAL_COPY);
|
|
21700
|
+
}
|
|
21186
21701
|
}
|
|
21187
21702
|
const fileEvents = composerFileEvents({
|
|
21188
21703
|
action: fileAction,
|
|
@@ -21193,33 +21708,6 @@ function createHelpDeskComposer(options) {
|
|
|
21193
21708
|
refuse: refuseFiles
|
|
21194
21709
|
});
|
|
21195
21710
|
|
|
21196
|
-
// The (?) tip: a disclosure that closes by its trigger, Escape, its close
|
|
21197
|
-
// button (focus back on the trigger), a press outside it, or focus leaving it.
|
|
21198
|
-
const inTip = (node) => node instanceof Node && (helpTrigger.contains(node) || helpPanel.contains(node));
|
|
21199
|
-
function setHelpOpen(open) {
|
|
21200
|
-
helpPanel.hidden = !open;
|
|
21201
|
-
helpTrigger.setAttribute('aria-expanded', String(open));
|
|
21202
|
-
if (open) document.addEventListener('pointerdown', onPressOutsideHelp);
|
|
21203
|
-
else document.removeEventListener('pointerdown', onPressOutsideHelp);
|
|
21204
|
-
}
|
|
21205
|
-
function onPressOutsideHelp(event) {
|
|
21206
|
-
if (!inTip(event.target)) setHelpOpen(false);
|
|
21207
|
-
}
|
|
21208
|
-
const onHelpToggle = () => setHelpOpen(helpPanel.hidden);
|
|
21209
|
-
const onHelpClose = () => {
|
|
21210
|
-
setHelpOpen(false);
|
|
21211
|
-
helpTrigger.focus();
|
|
21212
|
-
};
|
|
21213
|
-
// Escape is the tip's alone while it is open: a dialog the form sits in leaves a handled key alone.
|
|
21214
|
-
const onHelpKey = (event) => {
|
|
21215
|
-
if (event.key !== 'Escape' || helpPanel.hidden) return;
|
|
21216
|
-
event.preventDefault();
|
|
21217
|
-
onHelpClose();
|
|
21218
|
-
};
|
|
21219
|
-
const onHelpFocusOut = (event) => {
|
|
21220
|
-
if (!helpPanel.hidden && event.relatedTarget && !inTip(event.relatedTarget)) setHelpOpen(false);
|
|
21221
|
-
};
|
|
21222
|
-
|
|
21223
21711
|
// A desk's refusal of files gives way once the customer writes on.
|
|
21224
21712
|
const onInput = () => {
|
|
21225
21713
|
if (!transport) setNotice(null);
|
|
@@ -21243,19 +21731,15 @@ function createHelpDeskComposer(options) {
|
|
|
21243
21731
|
}
|
|
21244
21732
|
input.addEventListener('change', onChoose);
|
|
21245
21733
|
attach.addEventListener('click', onAttach);
|
|
21246
|
-
helpTrigger.addEventListener('click', onHelpToggle);
|
|
21247
|
-
helpClose.addEventListener('click', onHelpClose);
|
|
21248
|
-
for (const part of [helpTrigger, helpPanel]) {
|
|
21249
|
-
part.addEventListener('keydown', onHelpKey);
|
|
21250
|
-
part.addEventListener('focusout', onHelpFocusOut);
|
|
21251
|
-
}
|
|
21252
21734
|
|
|
21253
21735
|
function clear(keepAttached = false) {
|
|
21254
21736
|
revision += 1;
|
|
21737
|
+
dismissValidation();
|
|
21255
21738
|
const previous = entries;
|
|
21256
21739
|
entries = [];
|
|
21257
21740
|
for (const entry of previous) {
|
|
21258
21741
|
entry.controller?.abort();
|
|
21742
|
+
releasePreview(entry);
|
|
21259
21743
|
if (!keepAttached || entry.state !== FILE_STATE.COMPLETE) void cancel(entry.target, entry.attachmentId);
|
|
21260
21744
|
}
|
|
21261
21745
|
list.replaceChildren();
|
|
@@ -21303,7 +21787,6 @@ function createHelpDeskComposer(options) {
|
|
|
21303
21787
|
destroy(keepAttached = false) {
|
|
21304
21788
|
destroyed = true;
|
|
21305
21789
|
clear(keepAttached);
|
|
21306
|
-
setHelpOpen(false);
|
|
21307
21790
|
zone.removeEventListener('dragenter', fileEvents.dragOver);
|
|
21308
21791
|
zone.removeEventListener('dragover', fileEvents.dragOver);
|
|
21309
21792
|
zone.removeEventListener('dragleave', fileEvents.dragLeave);
|
|
@@ -21314,12 +21797,6 @@ function createHelpDeskComposer(options) {
|
|
|
21314
21797
|
}
|
|
21315
21798
|
input.removeEventListener('change', onChoose);
|
|
21316
21799
|
attach.removeEventListener('click', onAttach);
|
|
21317
|
-
helpTrigger.removeEventListener('click', onHelpToggle);
|
|
21318
|
-
helpClose.removeEventListener('click', onHelpClose);
|
|
21319
|
-
for (const part of [helpTrigger, helpPanel]) {
|
|
21320
|
-
part.removeEventListener('keydown', onHelpKey);
|
|
21321
|
-
part.removeEventListener('focusout', onHelpFocusOut);
|
|
21322
|
-
}
|
|
21323
21800
|
}
|
|
21324
21801
|
};
|
|
21325
21802
|
}
|
|
@@ -21467,6 +21944,7 @@ function saveFormDraft(deskId, requesterId, value) {
|
|
|
21467
21944
|
catch { /* Storage is optional; the live form keeps its composition. */ }
|
|
21468
21945
|
}
|
|
21469
21946
|
|
|
21947
|
+
const HELP_DESK_FORM_TITLE = 'Open a Support Ticket';
|
|
21470
21948
|
let formSequence = 0;
|
|
21471
21949
|
/**
|
|
21472
21950
|
* The desk API's refusal of a file's draft or upload, as the composer reads
|
|
@@ -21605,15 +22083,17 @@ function companySignInUrl(value) {
|
|
|
21605
22083
|
* A confirmed send replaces the form with its confirmation.
|
|
21606
22084
|
*
|
|
21607
22085
|
* The request is a summary and optional details, in a composer that also
|
|
21608
|
-
* takes files. A signed-out widget customer writes it
|
|
21609
|
-
*
|
|
21610
|
-
*
|
|
21611
|
-
* beside the request.
|
|
22086
|
+
* takes files. A signed-out widget customer writes it before continuing to
|
|
22087
|
+
* sign-in, where one button opens the native sign-in window and sends it. A
|
|
22088
|
+
* signed-in customer can switch account or sign out beside the request.
|
|
21612
22089
|
*/
|
|
21613
22090
|
function mountHelpDeskForm(client, options) {
|
|
21614
22091
|
const target = resolveTarget(options.target);
|
|
21615
22092
|
injectHelpDeskFormStyles();
|
|
21616
|
-
|
|
22093
|
+
// OAuth sign-in belongs to the hosted desk. A native Identity ceremony or
|
|
22094
|
+
// company assertion on this host cannot stand in for that configured login.
|
|
22095
|
+
const oauth = client.desk.auth_mode === 'oauth2';
|
|
22096
|
+
const widget = oauth ? undefined : options.widgetIdentity;
|
|
21617
22097
|
const shell = new InlineShell(target, {
|
|
21618
22098
|
containerClassName: 'svhd-container',
|
|
21619
22099
|
bodyClassName: 'svhd-body',
|
|
@@ -21626,22 +22106,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
21626
22106
|
form.className = 'svhd-form';
|
|
21627
22107
|
form.noValidate = true;
|
|
21628
22108
|
shell.body.append(form);
|
|
21629
|
-
/** A step's heading
|
|
21630
|
-
function stepHead(id, title
|
|
22109
|
+
/** A step's heading takes focus when the customer enters it. */
|
|
22110
|
+
function stepHead(id, title) {
|
|
21631
22111
|
const head = document.createElement('div');
|
|
21632
22112
|
head.className = 'svhd-step-head';
|
|
21633
|
-
const stepLabel = label === null ? null : document.createElement('p');
|
|
21634
|
-
if (stepLabel) {
|
|
21635
|
-
stepLabel.className = 'svhd-step-label';
|
|
21636
|
-
stepLabel.textContent = label;
|
|
21637
|
-
head.append(stepLabel);
|
|
21638
|
-
}
|
|
21639
22113
|
const stepHeading = document.createElement('h2');
|
|
21640
22114
|
stepHeading.id = id;
|
|
21641
22115
|
stepHeading.tabIndex = -1;
|
|
21642
22116
|
stepHeading.textContent = title;
|
|
21643
22117
|
head.append(stepHeading);
|
|
21644
|
-
return { head, heading: stepHeading
|
|
22118
|
+
return { head, heading: stepHeading };
|
|
21645
22119
|
}
|
|
21646
22120
|
function stepContainer(step) {
|
|
21647
22121
|
const container = document.createElement('div');
|
|
@@ -21649,7 +22123,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21649
22123
|
container.dataset.contactStep = step;
|
|
21650
22124
|
return container;
|
|
21651
22125
|
}
|
|
21652
|
-
const request = stepHead(`${prefix}-heading`,
|
|
22126
|
+
const request = stepHead(`${prefix}-heading`, HELP_DESK_FORM_TITLE);
|
|
21653
22127
|
const heading = request.heading;
|
|
21654
22128
|
form.setAttribute('aria-labelledby', heading.id);
|
|
21655
22129
|
const details = stepContainer('details');
|
|
@@ -21796,7 +22270,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21796
22270
|
const widgetAccount = document.createElement('div');
|
|
21797
22271
|
widgetAccount.className = 'svhd-widget-account';
|
|
21798
22272
|
let widgetCustomer = widget?.customer ?? null;
|
|
21799
|
-
const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request'
|
|
22273
|
+
const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request') : null;
|
|
21800
22274
|
const identity = widget ? stepContainer('identity') : null;
|
|
21801
22275
|
const recap = document.createElement('div');
|
|
21802
22276
|
recap.className = 'svhd-recap';
|
|
@@ -21922,6 +22396,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21922
22396
|
let websiteSignedOut = false;
|
|
21923
22397
|
// The form is held while the secure window chooses another account: no send is under way.
|
|
21924
22398
|
let switchingAccount = false;
|
|
22399
|
+
let portalRequired = oauth;
|
|
21925
22400
|
/**
|
|
21926
22401
|
* Save the request as the form holds it. Never while a sign-in is under
|
|
21927
22402
|
* way: a session notification then blanks the fields until the sign-in's
|
|
@@ -22010,13 +22485,12 @@ function mountHelpDeskForm(client, options) {
|
|
|
22010
22485
|
* The signed-in widget customer writes and sends in one step, posting as
|
|
22011
22486
|
* the account named under it, beside Switch account and, but for a website
|
|
22012
22487
|
* account's session, which the website ends, Sign out; a signed-out one
|
|
22013
|
-
* writes the request
|
|
22488
|
+
* writes the request before continuing to sign-in. Either way the form
|
|
22489
|
+
* shows the request.
|
|
22014
22490
|
*/
|
|
22015
22491
|
function renderWidgetIdentity() {
|
|
22016
22492
|
if (!widget)
|
|
22017
22493
|
return;
|
|
22018
|
-
if (request.label)
|
|
22019
|
-
request.label.hidden = widgetCustomer !== null;
|
|
22020
22494
|
auth.hidden = true;
|
|
22021
22495
|
code.wrapper.hidden = true;
|
|
22022
22496
|
name.wrapper.hidden = true;
|
|
@@ -22055,7 +22529,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
22055
22529
|
*/
|
|
22056
22530
|
function renderActions() {
|
|
22057
22531
|
send.textContent = idleLabel();
|
|
22058
|
-
send.hidden = recovery === 'external_sso' && widget !== undefined && !widget.useWebsiteAccount;
|
|
22532
|
+
send.hidden = portalRequired || (recovery === 'external_sso' && widget !== undefined && !widget.useWebsiteAccount);
|
|
22059
22533
|
startNew.hidden = recovery === null;
|
|
22060
22534
|
widgetAccount.hidden = recovery !== null || widgetAccount.childElementCount === 0;
|
|
22061
22535
|
recap.hidden = recovery !== null;
|
|
@@ -22088,7 +22562,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
22088
22562
|
function setStep(next) {
|
|
22089
22563
|
const changed = next !== step;
|
|
22090
22564
|
step = next;
|
|
22091
|
-
details.hidden = next !== 'details';
|
|
22565
|
+
details.hidden = next !== 'details' || (portalRequired && !subject.input.value && !description.input.value);
|
|
22092
22566
|
if (identity)
|
|
22093
22567
|
identity.hidden = next !== 'identity';
|
|
22094
22568
|
if (next === 'identity') {
|
|
@@ -22168,13 +22642,13 @@ function mountHelpDeskForm(client, options) {
|
|
|
22168
22642
|
function disable(disabled) {
|
|
22169
22643
|
for (const input of [subject.input, description.input, email.input, code.input, name.input, send, cancel, changeEmail, editRequest, startNew])
|
|
22170
22644
|
input.disabled = disabled;
|
|
22171
|
-
const held = uncertainSubmission !== null || recovery !== null;
|
|
22645
|
+
const held = uncertainSubmission !== null || recovery !== null || portalRequired;
|
|
22172
22646
|
subject.input.readOnly = held;
|
|
22173
22647
|
description.input.readOnly = held;
|
|
22174
22648
|
for (const button of widgetAccount.querySelectorAll('button'))
|
|
22175
22649
|
button.disabled = disabled || uncertainSubmission !== null || completed;
|
|
22176
22650
|
renderResend();
|
|
22177
|
-
composer.disablePicking(disabled || recovery !== null);
|
|
22651
|
+
composer.disablePicking(disabled || recovery !== null || portalRequired);
|
|
22178
22652
|
composer.lock(completed || uncertainSubmission !== null);
|
|
22179
22653
|
}
|
|
22180
22654
|
function clearCode() {
|
|
@@ -22414,7 +22888,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
22414
22888
|
pending = false;
|
|
22415
22889
|
switchingAccount = false;
|
|
22416
22890
|
sessionKnown = false;
|
|
22417
|
-
if (
|
|
22891
|
+
if (widget)
|
|
22418
22892
|
widgetCustomer = null;
|
|
22419
22893
|
clearComposer();
|
|
22420
22894
|
recovery = hidden;
|
|
@@ -22427,6 +22901,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
22427
22901
|
message('Your sign-in changed. Start a new request for the current account.');
|
|
22428
22902
|
else
|
|
22429
22903
|
renderActions();
|
|
22904
|
+
if (oauth)
|
|
22905
|
+
showHosted();
|
|
22430
22906
|
// The request and its actions changed under the pointer: a press already
|
|
22431
22907
|
// under way must not act on what replaced them.
|
|
22432
22908
|
options.onScreenChange?.();
|
|
@@ -22480,6 +22956,26 @@ function mountHelpDeskForm(client, options) {
|
|
|
22480
22956
|
focusAfter = challenge ? code.input : email.input;
|
|
22481
22957
|
}
|
|
22482
22958
|
function showHosted() {
|
|
22959
|
+
if (oauth) {
|
|
22960
|
+
portalRequired = true;
|
|
22961
|
+
persistDraft();
|
|
22962
|
+
// Leave existing text available to copy, without putting a draft or
|
|
22963
|
+
// credentials in the destination URL or claiming it was transferred.
|
|
22964
|
+
const hasDraft = Boolean(subject.input.value || description.input.value);
|
|
22965
|
+
details.hidden = !hasDraft;
|
|
22966
|
+
auth.hidden = true;
|
|
22967
|
+
hosted.hidden = newRequestUrl === null;
|
|
22968
|
+
if (newRequestUrl)
|
|
22969
|
+
hosted.href = newRequestUrl;
|
|
22970
|
+
hosted.textContent = 'Open help desk in a new tab';
|
|
22971
|
+
send.hidden = true;
|
|
22972
|
+
disable(pending);
|
|
22973
|
+
message(hasDraft
|
|
22974
|
+
? 'Continue in the help desk to sign in and send your request. Your draft stays on this page; copy it into the help desk to continue.'
|
|
22975
|
+
: 'Open the help desk to sign in and write your request.');
|
|
22976
|
+
focusAfter = hosted.hidden ? null : hosted;
|
|
22977
|
+
return;
|
|
22978
|
+
}
|
|
22483
22979
|
if (client.desk.auth_mode === 'external_sso' || client.desk.auth_mode === 'external_unavailable') {
|
|
22484
22980
|
const url = companySignInUrl(client.desk.external_identity?.sign_in_url);
|
|
22485
22981
|
hosted.hidden = url === null;
|
|
@@ -22497,6 +22993,11 @@ function mountHelpDeskForm(client, options) {
|
|
|
22497
22993
|
async function submit() {
|
|
22498
22994
|
if (pending || completed || destroyed)
|
|
22499
22995
|
return;
|
|
22996
|
+
if (portalRequired) {
|
|
22997
|
+
showHosted();
|
|
22998
|
+
focusSettled();
|
|
22999
|
+
return;
|
|
23000
|
+
}
|
|
22500
23001
|
// Sending (Enter in a field, a code's last digit) answers the discard
|
|
22501
23002
|
// question: the customer kept going.
|
|
22502
23003
|
closeConfirm(false);
|
|
@@ -22568,7 +23069,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
22568
23069
|
let token = await tokenFor(ownGeneration);
|
|
22569
23070
|
if (!alive(ownGeneration))
|
|
22570
23071
|
return;
|
|
22571
|
-
if (widgetSignIn || (!token && options.onAuthRequired && client.desk.auth_mode !== 'external_sso' && client.desk.auth_mode !== 'external_unavailable')) {
|
|
23072
|
+
if (widgetSignIn || (!token && options.onAuthRequired && !oauth && client.desk.auth_mode !== 'external_sso' && client.desk.auth_mode !== 'external_unavailable')) {
|
|
22572
23073
|
authenticating = true;
|
|
22573
23074
|
authNotification = false;
|
|
22574
23075
|
const session = await (widgetSignIn ?? options.onAuthRequired());
|
|
@@ -22993,6 +23494,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
22993
23494
|
description.input.value = composition.body;
|
|
22994
23495
|
persistDraft();
|
|
22995
23496
|
syncLeaveGuard();
|
|
23497
|
+
if (portalRequired && !pending)
|
|
23498
|
+
showHosted();
|
|
22996
23499
|
},
|
|
22997
23500
|
refill(issue) {
|
|
22998
23501
|
if (destroyed || restoredDraft || recovery !== null || safeComposition() === null)
|
|
@@ -23011,11 +23514,17 @@ function mountHelpDeskForm(client, options) {
|
|
|
23011
23514
|
recapText.textContent = subject.input.value.trim();
|
|
23012
23515
|
persistDraft();
|
|
23013
23516
|
syncLeaveGuard();
|
|
23517
|
+
if (portalRequired && !pending)
|
|
23518
|
+
showHosted();
|
|
23014
23519
|
return true;
|
|
23015
23520
|
},
|
|
23016
23521
|
resumeAfterAccess() {
|
|
23017
|
-
if (!destroyed && !pending && !completed && uncertainSubmission === null)
|
|
23018
|
-
|
|
23522
|
+
if (!destroyed && !pending && !completed && uncertainSubmission === null) {
|
|
23523
|
+
if (portalRequired)
|
|
23524
|
+
showHosted();
|
|
23525
|
+
else
|
|
23526
|
+
message('');
|
|
23527
|
+
}
|
|
23019
23528
|
},
|
|
23020
23529
|
returnToRequest() {
|
|
23021
23530
|
if (destroyed || step !== 'identity')
|
|
@@ -23028,6 +23537,10 @@ function mountHelpDeskForm(client, options) {
|
|
|
23028
23537
|
focusEntry(focusOptions) {
|
|
23029
23538
|
if (destroyed || form.hidden)
|
|
23030
23539
|
return false;
|
|
23540
|
+
if (portalRequired && !hosted.hidden) {
|
|
23541
|
+
hosted.focus(focusOptions);
|
|
23542
|
+
return true;
|
|
23543
|
+
}
|
|
23031
23544
|
if (step === 'identity' && signInStep) {
|
|
23032
23545
|
(send.disabled ? signInStep.heading : send).focus(focusOptions);
|
|
23033
23546
|
return true;
|
|
@@ -23079,8 +23592,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
23079
23592
|
});
|
|
23080
23593
|
send.textContent = idleLabel();
|
|
23081
23594
|
renderWidgetIdentity();
|
|
23082
|
-
if (
|
|
23083
|
-
restoreDraft(
|
|
23595
|
+
if (widget?.customer) {
|
|
23596
|
+
restoreDraft(widget.customer);
|
|
23084
23597
|
disable(false);
|
|
23085
23598
|
}
|
|
23086
23599
|
else if (widget?.recovering) {
|
|
@@ -23110,9 +23623,42 @@ function mountHelpDeskForm(client, options) {
|
|
|
23110
23623
|
live.announce('Step 1 of 2');
|
|
23111
23624
|
syncLeaveGuard();
|
|
23112
23625
|
notify$1(options.onStateChange, state);
|
|
23626
|
+
if (oauth) {
|
|
23627
|
+
// Read an already-established desk session before exposing the composer.
|
|
23628
|
+
// The hosted OAuth flow establishes new sessions; this module never does.
|
|
23629
|
+
const ownGeneration = generation;
|
|
23630
|
+
pending = true;
|
|
23631
|
+
details.hidden = true;
|
|
23632
|
+
send.hidden = true;
|
|
23633
|
+
disable(true);
|
|
23634
|
+
message('Loading support');
|
|
23635
|
+
void tokenFor(ownGeneration).then((token) => {
|
|
23636
|
+
if (!alive(ownGeneration))
|
|
23637
|
+
return;
|
|
23638
|
+
if (!token) {
|
|
23639
|
+
showHosted();
|
|
23640
|
+
return;
|
|
23641
|
+
}
|
|
23642
|
+
portalRequired = false;
|
|
23643
|
+
details.hidden = false;
|
|
23644
|
+
hosted.hidden = true;
|
|
23645
|
+
message('');
|
|
23646
|
+
renderActions();
|
|
23647
|
+
}, (failure) => {
|
|
23648
|
+
if (!alive(ownGeneration))
|
|
23649
|
+
return;
|
|
23650
|
+
showHosted();
|
|
23651
|
+
notify$1(options.onError, failure instanceof Error ? failure : new Error('Support could not be loaded.'));
|
|
23652
|
+
}).finally(() => {
|
|
23653
|
+
if (alive(ownGeneration)) {
|
|
23654
|
+
pending = false;
|
|
23655
|
+
disable(false);
|
|
23656
|
+
}
|
|
23657
|
+
});
|
|
23658
|
+
}
|
|
23113
23659
|
// Native company identity starts as the form opens, never from a Connect,
|
|
23114
23660
|
// Allow, verification or submit gesture. Guest email is explicit desk policy.
|
|
23115
|
-
if (!
|
|
23661
|
+
if (!widget && ((client.desk.auth_mode === 'external_sso' && client.hasIdentityProvider) || client.desk.auth_mode === 'external_unavailable')) {
|
|
23116
23662
|
const ownGeneration = generation;
|
|
23117
23663
|
nativeProofGeneration = ownGeneration;
|
|
23118
23664
|
pending = true;
|
|
@@ -23223,7 +23769,7 @@ function openHelpDeskForm(client, options = {}) {
|
|
|
23223
23769
|
header.className = 'svhd-modal-header';
|
|
23224
23770
|
const title = document.createElement('span');
|
|
23225
23771
|
title.id = `${prefix}-title`;
|
|
23226
|
-
title.textContent =
|
|
23772
|
+
title.textContent = HELP_DESK_FORM_TITLE;
|
|
23227
23773
|
title.hidden = true;
|
|
23228
23774
|
const close = document.createElement('button');
|
|
23229
23775
|
close.type = 'button';
|
|
@@ -24752,6 +25298,7 @@ const currentVisitor = (value) => value !== null && typeof value === 'object' &&
|
|
|
24752
25298
|
'visitor_id' in value && validVisitorId(value.visitor_id) &&
|
|
24753
25299
|
'expires_at' in value && typeof value.expires_at === 'number' && Number.isSafeInteger(value.expires_at) &&
|
|
24754
25300
|
value.expires_at * 1000 > Date.now() + 60000 && value.expires_at * 1000 <= Date.now() + 31 * 86400000;
|
|
25301
|
+
let viewSequence = 0;
|
|
24755
25302
|
const invalid = () => new SparkVaultError('The help center returned an invalid answer. Try again.', 'KB_INVALID_RESPONSE');
|
|
24756
25303
|
const changed = () => new SparkVaultError('The help center changed. Search again to see current answers.', 'KB_PUBLICATION_CHANGED', 409);
|
|
24757
25304
|
const validPath = (value) => typeof value === 'string' && value.startsWith('/') && !value.startsWith('//') &&
|
|
@@ -24957,10 +25504,12 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
24957
25504
|
if (settings.enabled && validVisitorCookieName(settings.cookie_name)) {
|
|
24958
25505
|
if (cookieEndpoint) {
|
|
24959
25506
|
const endpoint = ownOrigin ? '/_sv/visitor' : new URL('/_sv/visitor', config.canonical_origin).href;
|
|
24960
|
-
const
|
|
24961
|
-
|
|
24962
|
-
|
|
24963
|
-
|
|
25507
|
+
const answer = await exchange(endpoint, { credentials: ownOrigin ? 'same-origin' : 'include', cache: 'no-store', redirect: 'error' }, {
|
|
25508
|
+
timeoutMs: this.sdkConfig.timeout, closeSignal: this.close.signal,
|
|
25509
|
+
read: async (response) => { if (!response.ok)
|
|
25510
|
+
throw invalid(); return await response.json(); },
|
|
25511
|
+
fail: failure => failure === 'timeout' ? new TimeoutError() : new NetworkError('Visitor identification could not be reached. Try again.')
|
|
25512
|
+
});
|
|
24964
25513
|
candidate = answer.visitor_id;
|
|
24965
25514
|
}
|
|
24966
25515
|
else {
|
|
@@ -24993,8 +25542,8 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
24993
25542
|
}
|
|
24994
25543
|
/** Use the help center's browser visitor and vote receipt; ticket identity is never sent. */
|
|
24995
25544
|
async vote(article, vote) {
|
|
24996
|
-
if (article
|
|
24997
|
-
throw new ValidationError('Choose yes or no for a published
|
|
25545
|
+
if (!['article', 'faq'].includes(article?.kind) || typeof article.id !== 'string' || !article.id || article.id.length > 256 || !['yes', 'no'].includes(vote)) {
|
|
25546
|
+
throw new ValidationError('Choose yes or no for a published answer.');
|
|
24998
25547
|
}
|
|
24999
25548
|
const reference = { id: article.id, release_id: article.release_id };
|
|
25000
25549
|
const previous = this.voteQueues.get(reference.id) ?? Promise.resolve();
|
|
@@ -25055,6 +25604,29 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
25055
25604
|
this.readerDocument = { ...value, body_html };
|
|
25056
25605
|
return this.readerDocument;
|
|
25057
25606
|
}
|
|
25607
|
+
/** Record only a displayed reader document; access is checked again by the event endpoint. */
|
|
25608
|
+
async view(document) {
|
|
25609
|
+
const config = this.config;
|
|
25610
|
+
if (!config?.authorized || !config.available || this.readerDocument !== document || config.release_id !== document.release_id)
|
|
25611
|
+
throw changed();
|
|
25612
|
+
if (!visitorCookieSettings(config.visitor_identifier).enabled)
|
|
25613
|
+
return;
|
|
25614
|
+
const eventId = `${Date.now()}-${++viewSequence}`;
|
|
25615
|
+
const visitor = await this.visitor(config);
|
|
25616
|
+
const body = { visitor_id: visitor.visitor_id, release_id: document.release_id, event_id: eventId, type: 'view', article_id: document.id };
|
|
25617
|
+
let result;
|
|
25618
|
+
try {
|
|
25619
|
+
result = await this.request('events', { body });
|
|
25620
|
+
}
|
|
25621
|
+
catch (error) {
|
|
25622
|
+
if (!(error instanceof NetworkError || error instanceof TimeoutError || error instanceof SparkVaultError && (error.statusCode ?? 0) >= 500))
|
|
25623
|
+
throw error;
|
|
25624
|
+
// A lost acknowledgement retries the same receipt so an open is counted once.
|
|
25625
|
+
result = await this.request('events', { body });
|
|
25626
|
+
}
|
|
25627
|
+
if (typeof result?.recorded !== 'boolean')
|
|
25628
|
+
throw invalid();
|
|
25629
|
+
}
|
|
25058
25630
|
/** Paint article text first; hydrate only approved media without replacing the reader DOM. */
|
|
25059
25631
|
hydrateAssets(document, callbacks) {
|
|
25060
25632
|
if (this.destroyed || this.readerDocument?.id !== document.id || this.readerDocument.release_id !== document.release_id)
|
|
@@ -25946,11 +26518,12 @@ class SupportView {
|
|
|
25946
26518
|
results.prepend(queryLine);
|
|
25947
26519
|
results.append(this.resultList, this.resultStatus, this.resultError);
|
|
25948
26520
|
this.resultError.setAttribute('role', 'alert');
|
|
25949
|
-
this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a ticket', () => {
|
|
26521
|
+
this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a support ticket', () => {
|
|
25950
26522
|
if (this.state?.busy)
|
|
25951
26523
|
return;
|
|
25952
26524
|
this.actions.onContact(['locked', 'unavailable'].includes(this.state?.kbState || '') ? 'direct' : this.state?.results?.length ? 'none_match' : 'no_results');
|
|
25953
26525
|
});
|
|
26526
|
+
this.contactResults.append(helpDeskIcon('arrowRight'));
|
|
25954
26527
|
this.contactNote.id = `${this.prefix}-contact-note`;
|
|
25955
26528
|
this.contactNote.hidden = true;
|
|
25956
26529
|
this.resultsFooter = this.footer('results');
|
|
@@ -26098,7 +26671,7 @@ class SupportView {
|
|
|
26098
26671
|
this.sourceArticle.textContent = next.sourceArticle ? `Article you read: ${next.sourceArticle.title}` : '';
|
|
26099
26672
|
this.sourceArticle.hidden = !next.sourceArticle;
|
|
26100
26673
|
this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden && this.sourceArticle.hidden;
|
|
26101
|
-
this.feedbackStatus.textContent = next.feedbackBusy ? 'Saving your feedback...' : next.feedbackError ? '' :
|
|
26674
|
+
this.feedbackStatus.textContent = next.feedbackBusy ? 'Saving your feedback...' : next.feedbackError ? '' : 'Your feedback has been saved.';
|
|
26102
26675
|
this.feedbackError.textContent = next.feedbackError || '';
|
|
26103
26676
|
this.feedbackError.hidden = !next.feedbackError;
|
|
26104
26677
|
this.retryFeedback.hidden = !next.feedbackError || !this.actions.onRetryFeedback;
|
|
@@ -26748,6 +27321,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26748
27321
|
let attempt = null;
|
|
26749
27322
|
let results = [];
|
|
26750
27323
|
let requestedArticle = null;
|
|
27324
|
+
let displayedArticle = null;
|
|
26751
27325
|
let articleRetrySearch = false;
|
|
26752
27326
|
let cancelArticleAssets = null;
|
|
26753
27327
|
let stopSession = null;
|
|
@@ -26848,6 +27422,12 @@ function createHelpDeskSupport(config, options) {
|
|
|
26848
27422
|
const rebranded = change.brand !== undefined && change.brand !== state.brand;
|
|
26849
27423
|
state = { ...state, ...change };
|
|
26850
27424
|
view.render(state);
|
|
27425
|
+
if (kb && state.visible && state.stage === 'article' && state.article && state.article !== displayedArticle) {
|
|
27426
|
+
displayedArticle = state.article;
|
|
27427
|
+
// A read can finish while minimized. Count the answer only after it is displayed.
|
|
27428
|
+
void kb.view(state.article).catch(value => { if (!destroyed)
|
|
27429
|
+
notify(options.onError, failure(value)); });
|
|
27430
|
+
}
|
|
26851
27431
|
launcher?.setExpanded(state.visible);
|
|
26852
27432
|
if (rebranded)
|
|
26853
27433
|
launcher?.setBrand(state.brand);
|
|
@@ -26950,8 +27530,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
26950
27530
|
return;
|
|
26951
27531
|
const ownFeedback = ++feedbackSequence;
|
|
26952
27532
|
void attempt?.then((active) => active?.solved());
|
|
26953
|
-
update({ stage: 'resolved', feedbackBusy:
|
|
26954
|
-
if (
|
|
27533
|
+
update({ stage: 'resolved', feedbackBusy: Boolean(kb), feedbackError: undefined, reviewUrl: undefined, error: undefined });
|
|
27534
|
+
if (!kb)
|
|
26955
27535
|
return;
|
|
26956
27536
|
try {
|
|
26957
27537
|
const saved = await kb.vote(article, 'yes');
|
|
@@ -27382,8 +27962,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
27382
27962
|
sourceArticleId = article.id;
|
|
27383
27963
|
update({ sourceArticle: { title: article.title, url: article.canonical_url } });
|
|
27384
27964
|
// The article vote and assistance outcome serve different reports. Neither may block contacting the team.
|
|
27385
|
-
if (
|
|
27386
|
-
void kb.vote(article, 'no').catch(() =>
|
|
27965
|
+
if (kb)
|
|
27966
|
+
void kb.vote(article, 'no').catch((value) => notify(options.onError, failure(value)));
|
|
27387
27967
|
}
|
|
27388
27968
|
followIssue();
|
|
27389
27969
|
cancelArticleAssets?.();
|
|
@@ -27735,7 +28315,8 @@ class HelpDeskModule {
|
|
|
27735
28315
|
/**
|
|
27736
28316
|
* Inject a ticket form, including email-code verification where the desk
|
|
27737
28317
|
* enables it. A custom onAuthRequired callback may supply a server-issued
|
|
27738
|
-
* help desk session.
|
|
28318
|
+
* help desk session. OAuth desks open their hosted portal for sign-in unless
|
|
28319
|
+
* a desk session is already installed. Destroy on unmount/account change.
|
|
27739
28320
|
*/
|
|
27740
28321
|
mountForm(options) {
|
|
27741
28322
|
return this.connectForm(options, (client) => mountHelpDeskForm(client, options));
|
|
@@ -32485,7 +33066,7 @@ class SparkVault {
|
|
|
32485
33066
|
}
|
|
32486
33067
|
/** Get the SDK version */
|
|
32487
33068
|
static get version() {
|
|
32488
|
-
return '18.0.
|
|
33069
|
+
return '18.0.6';
|
|
32489
33070
|
}
|
|
32490
33071
|
}
|
|
32491
33072
|
if (typeof window !== 'undefined') {
|