@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.mjs
CHANGED
|
@@ -18550,7 +18550,7 @@ class HelpDeskClient {
|
|
|
18550
18550
|
this.rememberToken(null, 'refresh', true);
|
|
18551
18551
|
}
|
|
18552
18552
|
/** Whether company identity can be established without customer interaction. */
|
|
18553
|
-
get hasIdentityProvider() { return typeof this.assertionProvider === 'function'; }
|
|
18553
|
+
get hasIdentityProvider() { return this.desk.auth_mode !== 'oauth2' && typeof this.assertionProvider === 'function'; }
|
|
18554
18554
|
/** The independent ticket gate must be met before rendering authenticated ticket UI. */
|
|
18555
18555
|
get hasTicketAccess() {
|
|
18556
18556
|
const policy = this.currentTicketPolicy;
|
|
@@ -19573,6 +19573,8 @@ const HELP_DESK_COLORS = Object.freeze({
|
|
|
19573
19573
|
fillStrong: `var(--hd-fill-strong,${LIGHT['--color-slate-200']})`,
|
|
19574
19574
|
/** A field's and a secondary action's edge. */
|
|
19575
19575
|
lineStrong: `var(--hd-line-strong,${LIGHT['--color-slate-300']})`,
|
|
19576
|
+
/** A modal's scrim stays dark in either scheme; the alpha belongs to the surface. */
|
|
19577
|
+
modalBackdrop: `var(--hd-modal-backdrop,${LIGHT['--ink']})`,
|
|
19576
19578
|
ink: `var(--hd-ink,${LIGHT['--ink']})`,
|
|
19577
19579
|
body: `var(--hd-text-body,${LIGHT['--text-body']})`,
|
|
19578
19580
|
muted: `var(--hd-text-muted,${LIGHT['--text-muted']})`,
|
|
@@ -19712,7 +19714,6 @@ function injectHelpDeskFormStyles() {
|
|
|
19712
19714
|
.svhd-hint{font-size:13px;color:${HELP_DESK_COLORS.body};margin:0}
|
|
19713
19715
|
.svhd-step{display:grid;gap:16px;min-width:0}
|
|
19714
19716
|
.svhd-step-head{display:grid;gap:4px;margin-bottom:4px}
|
|
19715
|
-
.svhd-step-label{margin:0;font-size:13px;font-weight:600;line-height:1.4;color:${HELP_DESK_COLORS.body}}
|
|
19716
19717
|
.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}
|
|
19717
19718
|
.svhd-text-button:not(:disabled):hover{text-decoration-thickness:2px}
|
|
19718
19719
|
.svhd-text-button:focus-visible{outline:3px solid ${HELP_DESK_FOCUS};outline-offset:2px}
|
|
@@ -20261,7 +20262,7 @@ function acceptedKindsCopy(kinds) {
|
|
|
20261
20262
|
/**
|
|
20262
20263
|
* The files a ticket accepts, in the one phrase every surface names them by,
|
|
20263
20264
|
* built from the policy's own list (ACCEPTED_ATTACHMENT_KINDS): the help desk
|
|
20264
|
-
* composer's
|
|
20265
|
+
* composer's refusal dialog reads it, and so do the API reference
|
|
20265
20266
|
* (apps/api/openapi/overlay.mjs) and the help desk's page on the site
|
|
20266
20267
|
* (apps/www/_data/helpDeskAttachments.js). A refused file's sentence names
|
|
20267
20268
|
* only that its type can't be attached.
|
|
@@ -20269,10 +20270,9 @@ function acceptedKindsCopy(kinds) {
|
|
|
20269
20270
|
const ACCEPTED_ATTACHMENTS_COPY = acceptedKindsCopy(ACCEPTED_ATTACHMENT_KINDS);
|
|
20270
20271
|
|
|
20271
20272
|
/**
|
|
20272
|
-
*
|
|
20273
|
-
*
|
|
20274
|
-
*
|
|
20275
|
-
* Attach.
|
|
20273
|
+
* The attachment rules shown after a refusal: what to add, how many files a
|
|
20274
|
+
* message takes and how large each may be. The help desk composer's
|
|
20275
|
+
* validation dialog reads this without adding prose to accepted uploads.
|
|
20276
20276
|
*/
|
|
20277
20277
|
const CUSTOMER_ATTACHMENTS_HINT =
|
|
20278
20278
|
`Add screenshots, documents or recordings. Up to ${MAX_ATTACHMENTS_PER_MESSAGE} files, ${formatBytes(CUSTOMER_ATTACHMENT_MAX_BYTES)} each.`;
|
|
@@ -20346,6 +20346,386 @@ function refusalCopy(refusal, maxBytes) {
|
|
|
20346
20346
|
return REFUSAL_COPY[refusal] ?? "This file can't be attached.";
|
|
20347
20347
|
}
|
|
20348
20348
|
|
|
20349
|
+
/**
|
|
20350
|
+
* Strict single-value media type (MIME) parsing.
|
|
20351
|
+
*
|
|
20352
|
+
* The one parser for a stored ingot or spark `content_type`: Core validates
|
|
20353
|
+
* every ingested value with it, Forge derives both the served Content-Type and
|
|
20354
|
+
* the inline-render decision from it, the display rules the web console and
|
|
20355
|
+
* the x.sv pages share (display-content-type.js), the Spark payload rule
|
|
20356
|
+
* (`isTextMediaType`) and the server's registry readings (media-type-node.js)
|
|
20357
|
+
* read the essence through it, so no two readers can disagree about what a
|
|
20358
|
+
* value means. A page that cannot import an ES module runs this module's own
|
|
20359
|
+
* source (MEDIA_TYPE_SCRIPT).
|
|
20360
|
+
*
|
|
20361
|
+
* Grammar (RFC 9110 §8.3.1): `type "/" subtype *( OWS ";" OWS [ parameter ] )`
|
|
20362
|
+
* where type, subtype and parameter names are tokens and parameter values are
|
|
20363
|
+
* tokens or quoted-strings, ASCII only. One deliberate tightening: a comma
|
|
20364
|
+
* anywhere rejects the value. Browsers read Content-Type as a comma-separated
|
|
20365
|
+
* list and keep the LAST valid type (WHATWG Fetch "extract a MIME type"), so a
|
|
20366
|
+
* value that this parser would classify by its first type can render in a
|
|
20367
|
+
* browser as another: `image/png, text/html` executes as HTML.
|
|
20368
|
+
*
|
|
20369
|
+
* BROWSER-SAFE: pure string handling, no Node built-ins.
|
|
20370
|
+
*/
|
|
20371
|
+
|
|
20372
|
+
/** Longest accepted value; RFC 6838 caps type and subtype at 127 chars each. */
|
|
20373
|
+
const MAX_MEDIA_TYPE_LENGTH = 255;
|
|
20374
|
+
const TOKEN_CHAR = /[!#$%&'*+.^_`|~0-9A-Za-z-]/;
|
|
20375
|
+
/** qdtext: HTAB, SP and visible ASCII except `"` and backslash. */
|
|
20376
|
+
const QUOTED_TEXT_CHAR = /[\t\x20\x21\x23-\x5b\x5d-\x7e]/;
|
|
20377
|
+
/** The character after the backslash of a quoted-pair: HTAB, SP or visible ASCII. */
|
|
20378
|
+
const QUOTED_PAIR_CHAR = /[\t\x20-\x7e]/;
|
|
20379
|
+
|
|
20380
|
+
/** Index just past the token starting at `start` (=== start when there is none). */
|
|
20381
|
+
function tokenEnd(value, start) {
|
|
20382
|
+
let end = start;
|
|
20383
|
+
while (end < value.length && TOKEN_CHAR.test(value[end])) end += 1;
|
|
20384
|
+
return end;
|
|
20385
|
+
}
|
|
20386
|
+
|
|
20387
|
+
/** Index just past the optional whitespace (SP / HTAB) starting at `start`. */
|
|
20388
|
+
function owsEnd(value, start) {
|
|
20389
|
+
let end = start;
|
|
20390
|
+
while (value[end] === ' ' || value[end] === '\t') end += 1;
|
|
20391
|
+
return end;
|
|
20392
|
+
}
|
|
20393
|
+
|
|
20394
|
+
/**
|
|
20395
|
+
* Read the quoted-string whose opening quote is at `start`.
|
|
20396
|
+
* @returns {{end: number, text: string} | null} The index past the closing
|
|
20397
|
+
* quote and the unescaped content; null when malformed or unterminated.
|
|
20398
|
+
*/
|
|
20399
|
+
function readQuotedString(value, start) {
|
|
20400
|
+
let text = '';
|
|
20401
|
+
let index = start + 1;
|
|
20402
|
+
while (index < value.length) {
|
|
20403
|
+
const char = value[index];
|
|
20404
|
+
if (char === '"') return { end: index + 1, text };
|
|
20405
|
+
if (char === '\\') {
|
|
20406
|
+
const escaped = value[index + 1];
|
|
20407
|
+
if (escaped === undefined || !QUOTED_PAIR_CHAR.test(escaped)) return null;
|
|
20408
|
+
text += escaped;
|
|
20409
|
+
index += 2;
|
|
20410
|
+
} else if (QUOTED_TEXT_CHAR.test(char)) {
|
|
20411
|
+
text += char;
|
|
20412
|
+
index += 1;
|
|
20413
|
+
} else {
|
|
20414
|
+
return null;
|
|
20415
|
+
}
|
|
20416
|
+
}
|
|
20417
|
+
return null;
|
|
20418
|
+
}
|
|
20419
|
+
|
|
20420
|
+
/**
|
|
20421
|
+
* Parse one media type value.
|
|
20422
|
+
*
|
|
20423
|
+
* A single left-to-right scan: every character is examined a bounded number
|
|
20424
|
+
* of times, so the cost is linear in the (already length-capped) input. Core
|
|
20425
|
+
* runs this on untrusted request bodies, where a backtracking grammar would
|
|
20426
|
+
* let one crafted value stall the process.
|
|
20427
|
+
*
|
|
20428
|
+
* @param {unknown} value - A stored or submitted content type
|
|
20429
|
+
* @returns {{
|
|
20430
|
+
* type: string,
|
|
20431
|
+
* subtype: string,
|
|
20432
|
+
* essence: string,
|
|
20433
|
+
* parameters: Map<string, string>
|
|
20434
|
+
* } | null} Lowercased type/subtype/essence and parameter names, unquoted
|
|
20435
|
+
* parameter values (the first occurrence of a name wins); null when the
|
|
20436
|
+
* value is not exactly one well-formed media type.
|
|
20437
|
+
*/
|
|
20438
|
+
function parseMediaType(value) {
|
|
20439
|
+
if (typeof value !== 'string' || value.length > MAX_MEDIA_TYPE_LENGTH || value.includes(',')) {
|
|
20440
|
+
return null;
|
|
20441
|
+
}
|
|
20442
|
+
|
|
20443
|
+
const typeEnd = tokenEnd(value, 0);
|
|
20444
|
+
if (typeEnd === 0 || value[typeEnd] !== '/') return null;
|
|
20445
|
+
const subtypeEnd = tokenEnd(value, typeEnd + 1);
|
|
20446
|
+
if (subtypeEnd === typeEnd + 1) return null;
|
|
20447
|
+
|
|
20448
|
+
const type = value.slice(0, typeEnd).toLowerCase();
|
|
20449
|
+
const subtype = value.slice(typeEnd + 1, subtypeEnd).toLowerCase();
|
|
20450
|
+
const parameters = new Map();
|
|
20451
|
+
|
|
20452
|
+
// parameters = *( OWS ";" OWS [ parameter ] )
|
|
20453
|
+
let index = subtypeEnd;
|
|
20454
|
+
while (index < value.length) {
|
|
20455
|
+
index = owsEnd(value, index);
|
|
20456
|
+
if (value[index] !== ';') return null;
|
|
20457
|
+
index = owsEnd(value, index + 1);
|
|
20458
|
+
if (index === value.length || value[index] === ';') continue; // empty slot
|
|
20459
|
+
|
|
20460
|
+
const nameEnd = tokenEnd(value, index);
|
|
20461
|
+
if (nameEnd === index || value[nameEnd] !== '=') return null;
|
|
20462
|
+
const name = value.slice(index, nameEnd).toLowerCase();
|
|
20463
|
+
|
|
20464
|
+
let parameterValue;
|
|
20465
|
+
if (value[nameEnd + 1] === '"') {
|
|
20466
|
+
const quoted = readQuotedString(value, nameEnd + 1);
|
|
20467
|
+
if (!quoted) return null;
|
|
20468
|
+
parameterValue = quoted.text;
|
|
20469
|
+
index = quoted.end;
|
|
20470
|
+
} else {
|
|
20471
|
+
const valueEnd = tokenEnd(value, nameEnd + 1);
|
|
20472
|
+
if (valueEnd === nameEnd + 1) return null;
|
|
20473
|
+
parameterValue = value.slice(nameEnd + 1, valueEnd);
|
|
20474
|
+
index = valueEnd;
|
|
20475
|
+
}
|
|
20476
|
+
|
|
20477
|
+
if (!parameters.has(name)) parameters.set(name, parameterValue);
|
|
20478
|
+
}
|
|
20479
|
+
|
|
20480
|
+
return { type, subtype, essence: `${type}/${subtype}`, parameters };
|
|
20481
|
+
}
|
|
20482
|
+
|
|
20483
|
+
/**
|
|
20484
|
+
* The essence of a content type: its lowercased `type/subtype`, parameters
|
|
20485
|
+
* dropped (`application/json` of `Application/JSON; charset=utf-8`). An exact
|
|
20486
|
+
* type filter matches an ingot on it.
|
|
20487
|
+
*
|
|
20488
|
+
* The x.sv page runs this function's source (MEDIA_TYPE_SCRIPT), so it keeps
|
|
20489
|
+
* to the ECMAScript 2018 the page parses as (docs/GOTCHAS.md).
|
|
20490
|
+
*
|
|
20491
|
+
* @param {unknown} value
|
|
20492
|
+
* @returns {string|null} null when the value is not exactly one well-formed
|
|
20493
|
+
* media type
|
|
20494
|
+
*/
|
|
20495
|
+
function mediaTypeEssence(value) {
|
|
20496
|
+
const mediaType = parseMediaType(value);
|
|
20497
|
+
return mediaType === null ? null : mediaType.essence;
|
|
20498
|
+
}
|
|
20499
|
+
|
|
20500
|
+
/**
|
|
20501
|
+
* Sound formats platforms type outside the audio tree, each an essence: the
|
|
20502
|
+
* Ogg container, as Firefox types every `.ogg` file (any other platform's
|
|
20503
|
+
* audio/ogg), and WMA as Chrome on macOS types a `.wma` file (Firefox's
|
|
20504
|
+
* audio/x-ms-wma). Each is filed with the audio (mediaTypeFamily), and is
|
|
20505
|
+
* the audio kind's (./ingot-kind.js), so a file's icon and the type filter
|
|
20506
|
+
* that lists it agree.
|
|
20507
|
+
*/
|
|
20508
|
+
const SOUND_TYPES_OUTSIDE_AUDIO = Object.freeze(['application/ogg', 'video/x-ms-wma']);
|
|
20509
|
+
|
|
20510
|
+
new Set(SOUND_TYPES_OUTSIDE_AUDIO);
|
|
20511
|
+
|
|
20512
|
+
/**
|
|
20513
|
+
* Content-type policy for vault and spark bytes a browser page displays or
|
|
20514
|
+
* saves.
|
|
20515
|
+
*
|
|
20516
|
+
* Every display blob becomes a blob: URL in the displaying page's own origin,
|
|
20517
|
+
* and a viewer can open one as a top-level document ("Open image in new tab",
|
|
20518
|
+
* dragging a thumbnail to the tab bar). A stored content_type is caller-supplied
|
|
20519
|
+
* (the public upload portal and any spark creator included), so a blob typed
|
|
20520
|
+
* image/svg+xml, text/html or any XML type would run that caller's script as
|
|
20521
|
+
* the page. Only types every browser renders inertly may therefore reach one,
|
|
20522
|
+
* decided by allowlist so an unknown or malformed type fails closed: the
|
|
20523
|
+
* essence is read by the platform's one media-type parser, and a declared value
|
|
20524
|
+
* that is not exactly one well-formed media type matches no entry.
|
|
20525
|
+
*
|
|
20526
|
+
* A save hands the browser a blob too, and a browser renames a saved copy by
|
|
20527
|
+
* the blob's type, by its own MIME table, refused extensions included:
|
|
20528
|
+
* Firefox saves `Invoice` handed as `application/x-javascript` as
|
|
20529
|
+
* `Invoice.js`, and `Invoice.pdf` handed as `image/svg+xml` as `Invoice.svg`,
|
|
20530
|
+
* and Chromium completes a name that has no extension from a blob's type
|
|
20531
|
+
* alike. Neither completes or replaces an extension by the type of a name
|
|
20532
|
+
* handed as application/octet-stream (docs/GOTCHAS.md). The name a file
|
|
20533
|
+
* saves under is completed by the MIME registry, which only the server
|
|
20534
|
+
* carries (Core answers it as `download_filename`, by ./media-type-node.js
|
|
20535
|
+
* downloadFilename), so a save hands the browser the display-safe type as
|
|
20536
|
+
* well: an inert type keeps its own, from which a browser completes a name
|
|
20537
|
+
* the registry left bare (`Recording` under `audio/flac` saves as
|
|
20538
|
+
* `Recording.flac`), and every other type goes as opaque bytes.
|
|
20539
|
+
*
|
|
20540
|
+
* The one rule for every surface that does this: the web console consumes these
|
|
20541
|
+
* functions directly (its file display path retypes through withDisplaySafeType,
|
|
20542
|
+
* as the one blob save does, saveBlob in ./browser-download.js), the x.sv pages
|
|
20543
|
+
* run this module's own source (DISPLAY_CONTENT_TYPE_SCRIPT), and Forge serves a
|
|
20544
|
+
* response inline on its own origin only when isInertDocumentType says so
|
|
20545
|
+
* (apps/forge/src/routes/decrypt.js). Forge and every client save hand an
|
|
20546
|
+
* inert type to the browser under its own type whatever the file's name, since
|
|
20547
|
+
* a browser renames a download by the type it is handed: an inert type is an
|
|
20548
|
+
* image, audio, video or PDF format, so whatever extension a browser gives its
|
|
20549
|
+
* copy opens it as what it is.
|
|
20550
|
+
*
|
|
20551
|
+
* BROWSER-SAFE: string handling and the platform's Blob, no Node built-ins.
|
|
20552
|
+
*/
|
|
20553
|
+
|
|
20554
|
+
/**
|
|
20555
|
+
* Raster formats: decoded as pixels by <img>, never parsed as a document that
|
|
20556
|
+
* could carry script. HEIC/HEIF stay listed for the case where on-the-fly JPEG
|
|
20557
|
+
* conversion fails and the original bytes are shown as-is.
|
|
20558
|
+
*/
|
|
20559
|
+
const INERT_IMAGE_TYPES = Object.freeze([
|
|
20560
|
+
'image/jpeg',
|
|
20561
|
+
'image/jpg',
|
|
20562
|
+
'image/pjpeg',
|
|
20563
|
+
'image/png',
|
|
20564
|
+
'image/x-png',
|
|
20565
|
+
'image/apng',
|
|
20566
|
+
'image/gif',
|
|
20567
|
+
'image/webp',
|
|
20568
|
+
'image/avif',
|
|
20569
|
+
'image/jxl',
|
|
20570
|
+
'image/bmp',
|
|
20571
|
+
'image/x-ms-bmp',
|
|
20572
|
+
'image/x-icon',
|
|
20573
|
+
'image/vnd.microsoft.icon',
|
|
20574
|
+
'image/tiff',
|
|
20575
|
+
'image/heic',
|
|
20576
|
+
'image/heif'
|
|
20577
|
+
]);
|
|
20578
|
+
|
|
20579
|
+
new Set(INERT_IMAGE_TYPES);
|
|
20580
|
+
|
|
20581
|
+
/**
|
|
20582
|
+
* The platform's one essence reader (./media-type.js), bound in this module's
|
|
20583
|
+
* own scope. The functions DISPLAY_CONTENT_TYPE_SCRIPT carries read it by this
|
|
20584
|
+
* name, which the page binds to the reader MEDIA_TYPE_SCRIPT declares, never
|
|
20585
|
+
* by its imported name: a module transform rewrites an imported name inside a
|
|
20586
|
+
* function's source (vitest's, which every suite runs this module under, turns
|
|
20587
|
+
* `mediaTypeEssence` into `__vite_ssr_import_0__.mediaTypeEssence`), a name no
|
|
20588
|
+
* page declares.
|
|
20589
|
+
*/
|
|
20590
|
+
const essenceOf = mediaTypeEssence;
|
|
20591
|
+
|
|
20592
|
+
/*
|
|
20593
|
+
* Audio and video formats, each under the types the MIME registry files it
|
|
20594
|
+
* under and the ones browsers and Apple's platforms report for it
|
|
20595
|
+
* (`audio/flac`, `audio/vnd.wave`, `audio/aiff`, Chromium's `video/matroska`
|
|
20596
|
+
* and `audio/matroska`, Firefox's `application/ogg` for a `.ogg` file, and,
|
|
20597
|
+
* where Chromium asks the platform: on macOS `video/avi` for a `.avi` file,
|
|
20598
|
+
* `video/x-ms-wma` for a `.wma` one and `audio/x-m4r` for an iPhone ringtone,
|
|
20599
|
+
* and on Windows `audio/vnd.dlna.adts` for a `.aac` one):
|
|
20600
|
+
* encoded sound and pictures, which a browser plays in its own player, never
|
|
20601
|
+
* as a scriptable document, or downloads under the extension its table names
|
|
20602
|
+
* for the type (`.mp3`, `.mov`, `.avi`, `.ogg`), which a desktop opens in a
|
|
20603
|
+
* media player.
|
|
20604
|
+
*
|
|
20605
|
+
* Never a playlist or a stream redirector (`audio/x-mpegurl`,
|
|
20606
|
+
* `audio/x-scpls`, `video/x-ms-asx`, `audio/x-pn-realaudio`): it names media
|
|
20607
|
+
* a player then fetches, and a browser downloads it whatever name it is
|
|
20608
|
+
* handed, saving it as `.m3u`, `.pls`, `.asx` (which Outlook blocks) or
|
|
20609
|
+
* `.ram`; nor `video/x-ms-asf`, under which the registry files the `.asx`
|
|
20610
|
+
* redirector too. An allowlist, so an audio or video type no entry names
|
|
20611
|
+
* fails closed, one with a structured-syntax suffix among them (`video/x+xml`,
|
|
20612
|
+
* which a navigated browser renders as an XML document, script included).
|
|
20613
|
+
*/
|
|
20614
|
+
|
|
20615
|
+
/** The audio formats: sound, which a browser plays in its player. */
|
|
20616
|
+
const INERT_AUDIO_TYPES = Object.freeze([
|
|
20617
|
+
'audio/3gpp',
|
|
20618
|
+
'audio/aac',
|
|
20619
|
+
'audio/x-aac',
|
|
20620
|
+
'audio/vnd.dlna.adts',
|
|
20621
|
+
'audio/aiff',
|
|
20622
|
+
'audio/x-aiff',
|
|
20623
|
+
'audio/amr',
|
|
20624
|
+
'audio/basic',
|
|
20625
|
+
'audio/flac',
|
|
20626
|
+
'audio/x-flac',
|
|
20627
|
+
'audio/matroska',
|
|
20628
|
+
'audio/x-matroska',
|
|
20629
|
+
'audio/midi',
|
|
20630
|
+
'audio/mp3',
|
|
20631
|
+
'audio/mpeg',
|
|
20632
|
+
'audio/mp4',
|
|
20633
|
+
'audio/x-m4a',
|
|
20634
|
+
'audio/x-m4r',
|
|
20635
|
+
'audio/ogg',
|
|
20636
|
+
'audio/wav',
|
|
20637
|
+
'audio/wave',
|
|
20638
|
+
'audio/vnd.wave',
|
|
20639
|
+
'audio/x-wav',
|
|
20640
|
+
'audio/webm',
|
|
20641
|
+
'audio/x-caf',
|
|
20642
|
+
'audio/x-ms-wma',
|
|
20643
|
+
'video/x-ms-wma'
|
|
20644
|
+
]);
|
|
20645
|
+
|
|
20646
|
+
/**
|
|
20647
|
+
* The Ogg container, as Firefox types a `.ogg` file: the one inert type that
|
|
20648
|
+
* does not say whether its files hold sound alone or pictures too. It renders
|
|
20649
|
+
* as a video, whose player plays either.
|
|
20650
|
+
*/
|
|
20651
|
+
const OGG_CONTAINER_TYPE = 'application/ogg';
|
|
20652
|
+
|
|
20653
|
+
/**
|
|
20654
|
+
* The video formats: pictures and sound, which a browser plays in its player,
|
|
20655
|
+
* the Ogg container among them (OGG_CONTAINER_TYPE).
|
|
20656
|
+
*/
|
|
20657
|
+
const INERT_VIDEO_TYPES = Object.freeze([
|
|
20658
|
+
'video/3gpp',
|
|
20659
|
+
'video/3gpp2',
|
|
20660
|
+
'video/matroska',
|
|
20661
|
+
'video/x-matroska',
|
|
20662
|
+
'video/mp2t',
|
|
20663
|
+
'video/mp4',
|
|
20664
|
+
'video/x-m4v',
|
|
20665
|
+
'video/mpeg',
|
|
20666
|
+
'video/ogg',
|
|
20667
|
+
OGG_CONTAINER_TYPE,
|
|
20668
|
+
'video/quicktime',
|
|
20669
|
+
'video/webm',
|
|
20670
|
+
'video/x-flv',
|
|
20671
|
+
'video/x-msvideo',
|
|
20672
|
+
'video/avi',
|
|
20673
|
+
'video/x-ms-wmv'
|
|
20674
|
+
]);
|
|
20675
|
+
|
|
20676
|
+
const PDF_TYPE = 'application/pdf';
|
|
20677
|
+
|
|
20678
|
+
/**
|
|
20679
|
+
* How each inert type renders as a top-level document, by essence
|
|
20680
|
+
* (inertRendering). The x.sv pages read it through
|
|
20681
|
+
* DISPLAY_CONTENT_TYPE_SCRIPT, which serializes it.
|
|
20682
|
+
*/
|
|
20683
|
+
const INERT_RENDERING = new Map([
|
|
20684
|
+
...INERT_IMAGE_TYPES.map((type) => [type, 'image']),
|
|
20685
|
+
...INERT_AUDIO_TYPES.map((type) => [type, 'audio']),
|
|
20686
|
+
...INERT_VIDEO_TYPES.map((type) => [type, 'video']),
|
|
20687
|
+
[PDF_TYPE, 'pdf']
|
|
20688
|
+
]);
|
|
20689
|
+
|
|
20690
|
+
/**
|
|
20691
|
+
* Every type a browser renders inertly as a top-level document, as an essence:
|
|
20692
|
+
* a raster image (INERT_IMAGE_TYPES), an audio or video format, or a PDF,
|
|
20693
|
+
* which the browser's own PDF viewer renders.
|
|
20694
|
+
*/
|
|
20695
|
+
Object.freeze([...INERT_RENDERING.keys()]);
|
|
20696
|
+
|
|
20697
|
+
const OPAQUE_CONTENT_TYPE = 'application/octet-stream';
|
|
20698
|
+
|
|
20699
|
+
/** isInertDocumentType over an essence already read (essenceOf), null for a value that is no media type. */
|
|
20700
|
+
function isInertDocumentEssence(type) {
|
|
20701
|
+
return INERT_RENDERING.has(type);
|
|
20702
|
+
}
|
|
20703
|
+
|
|
20704
|
+
/**
|
|
20705
|
+
* The type a blob a page hands the browser, to display or to save, may carry:
|
|
20706
|
+
* its own essence when the browser renders it inertly, otherwise
|
|
20707
|
+
* application/octet-stream, which a navigated blob URL downloads instead of
|
|
20708
|
+
* rendering and which no browser completes a saved name from.
|
|
20709
|
+
* @param {string|null|undefined} contentType
|
|
20710
|
+
* @returns {string}
|
|
20711
|
+
*/
|
|
20712
|
+
function displaySafeContentType(contentType) {
|
|
20713
|
+
const type = essenceOf(contentType);
|
|
20714
|
+
return isInertDocumentEssence(type) ? type : OPAQUE_CONTENT_TYPE;
|
|
20715
|
+
}
|
|
20716
|
+
|
|
20717
|
+
/**
|
|
20718
|
+
* A blob as a page hands it to the browser, to display or to save: retyped to
|
|
20719
|
+
* displaySafeContentType of its own type, or the blob itself when it already
|
|
20720
|
+
* carries that type. slice() retypes without copying the bytes.
|
|
20721
|
+
* @param {Blob} blob
|
|
20722
|
+
* @returns {Blob}
|
|
20723
|
+
*/
|
|
20724
|
+
function withDisplaySafeType(blob) {
|
|
20725
|
+
const safeType = displaySafeContentType(blob.type);
|
|
20726
|
+
return blob.type === safeType ? blob : blob.slice(0, blob.size, safeType);
|
|
20727
|
+
}
|
|
20728
|
+
|
|
20349
20729
|
/**
|
|
20350
20730
|
* Files brought to a message's composer by drag, drop and paste, handled
|
|
20351
20731
|
* alike by every composer that takes them: the console's reply composer and
|
|
@@ -20547,6 +20927,7 @@ const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
|
20547
20927
|
|
|
20548
20928
|
const PATHS = Object.freeze({
|
|
20549
20929
|
back: 'm14.5 6-6 6 6 6',
|
|
20930
|
+
arrowRight: 'M4 12h16m-6-6 6 6-6 6',
|
|
20550
20931
|
close: 'm6 6 12 12M18 6 6 18',
|
|
20551
20932
|
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',
|
|
20552
20933
|
check: 'm5 12 4 4L19 6',
|
|
@@ -20603,10 +20984,10 @@ function helpDeskIcon(name) {
|
|
|
20603
20984
|
* takes no files from its customers is refused in words
|
|
20604
20985
|
* (NO_CUSTOMER_FILES_COPY), and one brought while files cannot join is
|
|
20605
20986
|
* never the browser's to open in place of the unsent message.
|
|
20606
|
-
* - **
|
|
20607
|
-
*
|
|
20608
|
-
*
|
|
20609
|
-
*
|
|
20987
|
+
* - **Requirements.** A rejected file opens one modal with its reason and
|
|
20988
|
+
* the attachment rules. A selection shares that modal, and dismissing it
|
|
20989
|
+
* leaves later refusals from the same selection in their chips. Accepted
|
|
20990
|
+
* images have local previews, including while waiting for sign-in.
|
|
20610
20991
|
* - **Uploading.** The browser's check (attachmentRefusal) first, then the
|
|
20611
20992
|
* host's transport: its target (the request a reply belongs to, or the
|
|
20612
20993
|
* draft a new request uploads to, which may not exist yet: the file then
|
|
@@ -20671,21 +21052,27 @@ const COMPOSER_CSS = `
|
|
|
20671
21052
|
.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}
|
|
20672
21053
|
.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}}
|
|
20673
21054
|
.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}
|
|
20674
|
-
.svhd-composer .svhd-composer-attach:hover
|
|
21055
|
+
.svhd-composer .svhd-composer-attach:hover{background:${HELP_DESK_COLORS.fill};color:${HELP_DESK_COLORS.ink}}
|
|
20675
21056
|
.svhd-composer .svhd-composer-attach:disabled{opacity:.6;cursor:default}
|
|
20676
21057
|
.svhd-composer .svhd-composer-attach svg{display:block;width:18px;height:18px}
|
|
20677
|
-
.svhd-composer .svhd-composer-
|
|
20678
|
-
.svhd-composer .svhd-composer-
|
|
20679
|
-
.svhd-composer .svhd-composer-
|
|
20680
|
-
.svhd-composer .svhd-composer-
|
|
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-
|
|
21058
|
+
.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}
|
|
21059
|
+
.svhd-composer .svhd-composer-validation-dialog::backdrop{background:color-mix(in srgb,${HELP_DESK_COLORS.modalBackdrop} 60%,transparent)}
|
|
21060
|
+
.svhd-composer .svhd-composer-validation-header{display:flex;align-items:center;gap:12px;padding:16px 16px 8px 24px}
|
|
21061
|
+
.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}
|
|
21062
|
+
.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}
|
|
21063
|
+
.svhd-composer .svhd-composer-validation-close:hover,.svhd-composer .svhd-attachment-remove:hover{background:${HELP_DESK_COLORS.fillStrong};color:${HELP_DESK_COLORS.ink}}
|
|
21064
|
+
.svhd-composer .svhd-composer-validation-close svg,.svhd-composer .svhd-attachment-remove svg{display:block;width:16px;height:16px}
|
|
21065
|
+
.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}
|
|
21066
|
+
.svhd-composer .svhd-composer-refusals strong{display:block;margin-bottom:2px;color:${HELP_DESK_COLORS.ink};font-weight:600}
|
|
21067
|
+
.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}
|
|
21068
|
+
.svhd-composer .svhd-composer-requirements h3{margin:0 0 8px;color:${HELP_DESK_COLORS.ink};font-family:inherit;font-size:14px;font-weight:600}
|
|
21069
|
+
.svhd-composer .svhd-composer-requirements p{margin:0}
|
|
21070
|
+
.svhd-composer .svhd-composer-requirements p+p{margin-top:8px}
|
|
20686
21071
|
.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}}
|
|
20687
21072
|
.svhd-composer .svhd-attachment-chips:empty{display:none}
|
|
20688
21073
|
.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}
|
|
21074
|
+
.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}
|
|
21075
|
+
.svhd-composer .svhd-attachment-preview-unavailable{grid-column:1/-1;margin:8px 8px 0 0;color:${HELP_DESK_COLORS.muted};font-size:12px}
|
|
20689
21076
|
.svhd-composer .svhd-attachment-name{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600;color:${HELP_DESK_COLORS.ink}}
|
|
20690
21077
|
.svhd-composer .svhd-attachment-status{grid-column:1;padding-right:8px;color:${HELP_DESK_COLORS.body};font-size:12px;overflow-wrap:anywhere}
|
|
20691
21078
|
.svhd-composer .svhd-attachment-status.svhd-composer-problem{color:${HELP_DESK_COLORS.error}}
|
|
@@ -20693,7 +21080,7 @@ const COMPOSER_CSS = `
|
|
|
20693
21080
|
.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}
|
|
20694
21081
|
.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}
|
|
20695
21082
|
.svhd-composer .svhd-attachment-remove:disabled,.svhd-composer .svhd-attachment-retry:disabled{opacity:.6;cursor:default}
|
|
20696
|
-
.svhd-composer .svhd-composer-attach:focus-visible,.svhd-composer .svhd-composer-
|
|
21083
|
+
.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}}
|
|
20697
21084
|
.svhd-composer-notice{margin:0;color:${HELP_DESK_COLORS.error};font-size:14px;line-height:1.5}
|
|
20698
21085
|
.svhd-composer [hidden],.svhd-composer-notice[hidden]{display:none!important}
|
|
20699
21086
|
`;
|
|
@@ -20730,8 +21117,8 @@ const RECEIVED_COPY = 'File received. Waiting for storage confirmation.';
|
|
|
20730
21117
|
const UPLOAD_FAILED_COPY = "This file couldn't be uploaded. Try again or remove it.";
|
|
20731
21118
|
const UPLOADING_COPY = 'Uploading';
|
|
20732
21119
|
const VERIFYING_COPY = 'Verifying stored file';
|
|
20733
|
-
/**
|
|
20734
|
-
const
|
|
21120
|
+
/** Requirements appear only after a file is refused. */
|
|
21121
|
+
const VALIDATION_TITLE = 'Unable to attach files';
|
|
20735
21122
|
const ACCEPTED_KINDS_COPY = `You can attach ${ACCEPTED_ATTACHMENTS_COPY}.`;
|
|
20736
21123
|
|
|
20737
21124
|
/** What a message's files still need before it can be sent, from the most pressing. */
|
|
@@ -20870,9 +21257,7 @@ function createHelpDeskComposer(options) {
|
|
|
20870
21257
|
const zone = dropZone ?? frame;
|
|
20871
21258
|
const fields = [textarea, ...pasteFields];
|
|
20872
21259
|
|
|
20873
|
-
// The
|
|
20874
|
-
// extensions a request takes first, never the check), and its (?) tip,
|
|
20875
|
-
// whose limits also describe Attach.
|
|
21260
|
+
// The chooser filters names; the canonical attachment check decides.
|
|
20876
21261
|
const input = document.createElement('input');
|
|
20877
21262
|
input.type = 'file';
|
|
20878
21263
|
input.name = 'attachments';
|
|
@@ -20880,40 +21265,13 @@ function createHelpDeskComposer(options) {
|
|
|
20880
21265
|
input.accept = ATTACHMENT_INPUT_ACCEPT;
|
|
20881
21266
|
input.hidden = true;
|
|
20882
21267
|
input.tabIndex = -1;
|
|
20883
|
-
const hint = document.createElement('p');
|
|
20884
|
-
hint.id = `${textarea.id}-attachment-hint`;
|
|
20885
|
-
hint.textContent = CUSTOMER_ATTACHMENTS_HINT;
|
|
20886
|
-
const kinds = document.createElement('p');
|
|
20887
|
-
kinds.textContent = ACCEPTED_KINDS_COPY;
|
|
20888
21268
|
const attach = button$1('svhd-composer-attach', 'Attach files');
|
|
20889
|
-
attach.setAttribute('aria-describedby', hint.id);
|
|
20890
21269
|
const attachText = document.createElement('span');
|
|
20891
21270
|
attachText.textContent = 'Attach';
|
|
20892
21271
|
attach.append(helpDeskIcon('paperclip'), attachText);
|
|
20893
|
-
const helpPanel = document.createElement('div');
|
|
20894
|
-
helpPanel.id = `${textarea.id}-attachment-help`;
|
|
20895
|
-
helpPanel.className = 'svhd-composer-help-panel';
|
|
20896
|
-
helpPanel.setAttribute('role', 'region');
|
|
20897
|
-
helpPanel.setAttribute('aria-label', HELP_TITLE);
|
|
20898
|
-
helpPanel.hidden = true;
|
|
20899
|
-
const helpCopy = document.createElement('div');
|
|
20900
|
-
helpCopy.className = 'svhd-composer-help-copy';
|
|
20901
|
-
helpCopy.append(hint, kinds);
|
|
20902
|
-
const helpClose = button$1('svhd-composer-help-close', 'Close');
|
|
20903
|
-
helpClose.title = 'Close';
|
|
20904
|
-
helpClose.append(helpDeskIcon('close'));
|
|
20905
|
-
helpPanel.append(helpCopy, helpClose);
|
|
20906
|
-
const helpTrigger = button$1('svhd-composer-help', `Help: ${HELP_TITLE}`);
|
|
20907
|
-
helpTrigger.setAttribute('aria-expanded', 'false');
|
|
20908
|
-
helpTrigger.setAttribute('aria-controls', helpPanel.id);
|
|
20909
|
-
const glyph = document.createElement('span');
|
|
20910
|
-
glyph.className = 'svhd-composer-help-glyph';
|
|
20911
|
-
glyph.setAttribute('aria-hidden', 'true');
|
|
20912
|
-
glyph.textContent = '?';
|
|
20913
|
-
helpTrigger.append(glyph);
|
|
20914
21272
|
const toolbar = document.createElement('div');
|
|
20915
21273
|
toolbar.className = 'svhd-composer-toolbar';
|
|
20916
|
-
toolbar.append(attach,
|
|
21274
|
+
toolbar.append(attach, input);
|
|
20917
21275
|
const list = document.createElement('ul');
|
|
20918
21276
|
list.className = 'svhd-attachment-chips';
|
|
20919
21277
|
list.setAttribute('aria-label', 'Attached files');
|
|
@@ -20925,10 +21283,151 @@ function createHelpDeskComposer(options) {
|
|
|
20925
21283
|
let locked = false;
|
|
20926
21284
|
let pickingDisabled = false;
|
|
20927
21285
|
let destroyed = false;
|
|
21286
|
+
let validation = null;
|
|
20928
21287
|
const accepting = () => transport !== null && !locked && !pickingDisabled && !destroyed;
|
|
20929
21288
|
const current = (entry, ownRevision) =>
|
|
20930
21289
|
!destroyed && revision === ownRevision && entries.includes(entry) && !entry.controller?.signal.aborted;
|
|
20931
21290
|
|
|
21291
|
+
/** A selection keeps its refusal lifecycle even when its files settle at different times. */
|
|
21292
|
+
const selection = () => ({
|
|
21293
|
+
dismissed: false,
|
|
21294
|
+
returnFocus: document.activeElement instanceof HTMLElement && document.activeElement !== document.body
|
|
21295
|
+
? document.activeElement : textarea
|
|
21296
|
+
});
|
|
21297
|
+
|
|
21298
|
+
function dismissValidation() {
|
|
21299
|
+
const shown = validation;
|
|
21300
|
+
if (!shown) return;
|
|
21301
|
+
validation = null;
|
|
21302
|
+
for (const batch of shown.batches) batch.dismissed = true;
|
|
21303
|
+
if (shown.dialog.open) shown.dialog.close();
|
|
21304
|
+
shown.dialog.remove();
|
|
21305
|
+
document.documentElement.style.overflow = shown.overflow;
|
|
21306
|
+
if (!destroyed) {
|
|
21307
|
+
const target = shown.returnFocus.isConnected && !shown.returnFocus.disabled ? shown.returnFocus : textarea;
|
|
21308
|
+
target.focus();
|
|
21309
|
+
}
|
|
21310
|
+
}
|
|
21311
|
+
|
|
21312
|
+
/** Exact refusals share one top-layer dialog; later files never steal focus from its reader. */
|
|
21313
|
+
function reportRefusal(batch, key, filename, copy) {
|
|
21314
|
+
if (destroyed || batch.dismissed) return;
|
|
21315
|
+
let shown = validation;
|
|
21316
|
+
if (!shown) {
|
|
21317
|
+
const dialog = document.createElement('dialog');
|
|
21318
|
+
dialog.className = 'svhd-composer-validation-dialog';
|
|
21319
|
+
const title = document.createElement('h2');
|
|
21320
|
+
title.id = `${textarea.id}-attachment-validation-title`;
|
|
21321
|
+
title.className = 'svhd-composer-validation-title';
|
|
21322
|
+
title.textContent = VALIDATION_TITLE;
|
|
21323
|
+
dialog.setAttribute('aria-labelledby', title.id);
|
|
21324
|
+
const close = button$1('svhd-composer-validation-close', 'Close');
|
|
21325
|
+
close.title = 'Close';
|
|
21326
|
+
close.append(helpDeskIcon('close'));
|
|
21327
|
+
const header = document.createElement('div');
|
|
21328
|
+
header.className = 'svhd-composer-validation-header';
|
|
21329
|
+
header.append(title, close);
|
|
21330
|
+
const reasons = document.createElement('ul');
|
|
21331
|
+
reasons.className = 'svhd-composer-refusals';
|
|
21332
|
+
reasons.id = `${textarea.id}-attachment-refusals`;
|
|
21333
|
+
dialog.setAttribute('aria-describedby', reasons.id);
|
|
21334
|
+
reasons.setAttribute('aria-live', 'polite');
|
|
21335
|
+
const requirements = document.createElement('div');
|
|
21336
|
+
requirements.className = 'svhd-composer-requirements';
|
|
21337
|
+
const heading = document.createElement('h3');
|
|
21338
|
+
heading.textContent = 'What you can attach';
|
|
21339
|
+
const limits = document.createElement('p');
|
|
21340
|
+
limits.textContent = deskRefusesFiles ? NO_CUSTOMER_FILES_COPY : CUSTOMER_ATTACHMENTS_HINT;
|
|
21341
|
+
requirements.append(heading, limits);
|
|
21342
|
+
if (!deskRefusesFiles) {
|
|
21343
|
+
const kinds = document.createElement('p');
|
|
21344
|
+
kinds.textContent = ACCEPTED_KINDS_COPY;
|
|
21345
|
+
requirements.append(kinds);
|
|
21346
|
+
}
|
|
21347
|
+
dialog.append(header, reasons, requirements);
|
|
21348
|
+
shown = { dialog, reasons, close, issues: new Map(), batches: new Set(), returnFocus: batch.returnFocus, overflow: document.documentElement.style.overflow };
|
|
21349
|
+
validation = shown;
|
|
21350
|
+
close.addEventListener('click', () => dismissValidation());
|
|
21351
|
+
dialog.addEventListener('cancel', (event) => { event.preventDefault(); event.stopPropagation(); dismissValidation(); });
|
|
21352
|
+
dialog.addEventListener('close', () => { if (validation === shown) dismissValidation(); });
|
|
21353
|
+
dialog.addEventListener('keydown', (event) => {
|
|
21354
|
+
if (event.key === 'Escape') {
|
|
21355
|
+
event.preventDefault();
|
|
21356
|
+
event.stopPropagation();
|
|
21357
|
+
dismissValidation();
|
|
21358
|
+
} else if (event.key === 'Tab') {
|
|
21359
|
+
// Close is this dialog's one focusable control; keep keyboard focus with it.
|
|
21360
|
+
event.preventDefault();
|
|
21361
|
+
close.focus();
|
|
21362
|
+
}
|
|
21363
|
+
});
|
|
21364
|
+
const outside = (event) => {
|
|
21365
|
+
if (event.target !== dialog) return false;
|
|
21366
|
+
const bounds = dialog.getBoundingClientRect();
|
|
21367
|
+
return event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom;
|
|
21368
|
+
};
|
|
21369
|
+
let backdropPress = false;
|
|
21370
|
+
dialog.addEventListener('pointerdown', (event) => { backdropPress = outside(event); });
|
|
21371
|
+
dialog.addEventListener('click', (event) => { if (backdropPress && outside(event)) dismissValidation(); backdropPress = false; });
|
|
21372
|
+
frame.append(dialog);
|
|
21373
|
+
}
|
|
21374
|
+
shown.batches.add(batch);
|
|
21375
|
+
let reason = shown.issues.get(key);
|
|
21376
|
+
if (!reason) {
|
|
21377
|
+
reason = document.createElement('li');
|
|
21378
|
+
shown.issues.set(key, reason);
|
|
21379
|
+
shown.reasons.append(reason);
|
|
21380
|
+
}
|
|
21381
|
+
const text = document.createElement('span');
|
|
21382
|
+
text.textContent = copy;
|
|
21383
|
+
reason.replaceChildren();
|
|
21384
|
+
if (filename) {
|
|
21385
|
+
const name = document.createElement('strong');
|
|
21386
|
+
name.textContent = filename;
|
|
21387
|
+
reason.append(name);
|
|
21388
|
+
}
|
|
21389
|
+
reason.append(text);
|
|
21390
|
+
if (!shown.dialog.open) {
|
|
21391
|
+
shown.dialog.showModal();
|
|
21392
|
+
document.documentElement.style.overflow = 'hidden';
|
|
21393
|
+
shown.close.focus();
|
|
21394
|
+
}
|
|
21395
|
+
}
|
|
21396
|
+
|
|
21397
|
+
function releasePreview(entry) {
|
|
21398
|
+
if (!entry.previewUrl) return;
|
|
21399
|
+
URL.revokeObjectURL(entry.previewUrl);
|
|
21400
|
+
entry.previewUrl = null;
|
|
21401
|
+
}
|
|
21402
|
+
|
|
21403
|
+
/** Local validated images need no transfer; every blob is inert even if its declared MIME is hostile. */
|
|
21404
|
+
function preview(entry) {
|
|
21405
|
+
if (entry.previewAttempted || !ACCEPTED_ATTACHMENT_KINDS.images.includes(lastExtension(entry.file.name))) return;
|
|
21406
|
+
entry.previewAttempted = true;
|
|
21407
|
+
const image = document.createElement('img');
|
|
21408
|
+
image.className = 'svhd-attachment-thumbnail';
|
|
21409
|
+
image.alt = `Preview of ${entry.file.name}`;
|
|
21410
|
+
image.decoding = 'async';
|
|
21411
|
+
const unavailable = () => {
|
|
21412
|
+
releasePreview(entry);
|
|
21413
|
+
image.remove();
|
|
21414
|
+
if (destroyed || !entries.includes(entry)) return;
|
|
21415
|
+
const fallback = document.createElement('span');
|
|
21416
|
+
fallback.className = 'svhd-attachment-preview-unavailable';
|
|
21417
|
+
fallback.textContent = 'Preview unavailable';
|
|
21418
|
+
entry.row.prepend(fallback);
|
|
21419
|
+
};
|
|
21420
|
+
image.addEventListener('error', unavailable, { once: true });
|
|
21421
|
+
try {
|
|
21422
|
+
entry.previewUrl = URL.createObjectURL(withDisplaySafeType(entry.file));
|
|
21423
|
+
image.src = entry.previewUrl;
|
|
21424
|
+
entry.row.prepend(image);
|
|
21425
|
+
} catch {
|
|
21426
|
+
// A browser that cannot create a preview still uploads the original file.
|
|
21427
|
+
unavailable();
|
|
21428
|
+
}
|
|
21429
|
+
}
|
|
21430
|
+
|
|
20932
21431
|
// A refusal of files is an alert only while it shows, as a field's error is.
|
|
20933
21432
|
function setNotice(text) {
|
|
20934
21433
|
notice.textContent = text ?? '';
|
|
@@ -20989,9 +21488,12 @@ function createHelpDeskComposer(options) {
|
|
|
20989
21488
|
if (!stillCurrent()) return;
|
|
20990
21489
|
if (refusal) {
|
|
20991
21490
|
entry.retryable = false;
|
|
20992
|
-
|
|
21491
|
+
const copy = refusalCopy(refusal, CUSTOMER_ATTACHMENT_MAX_BYTES);
|
|
21492
|
+
show(entry, FILE_STATE.REFUSED, copy);
|
|
21493
|
+
reportRefusal(entry.batch, entry, entry.file.name, copy);
|
|
20993
21494
|
return;
|
|
20994
21495
|
}
|
|
21496
|
+
preview(entry);
|
|
20995
21497
|
request = 'host';
|
|
20996
21498
|
const target = await transport.target();
|
|
20997
21499
|
if (!stillCurrent()) return;
|
|
@@ -21037,7 +21539,9 @@ function createHelpDeskComposer(options) {
|
|
|
21037
21539
|
entry.attachmentId = upload.attachment_id;
|
|
21038
21540
|
if (Number.isSafeInteger(upload.max_bytes) && upload.max_bytes > 0 && entry.file.size > upload.max_bytes) {
|
|
21039
21541
|
entry.retryable = false;
|
|
21040
|
-
|
|
21542
|
+
const copy = tooLargeCopy(upload.max_bytes);
|
|
21543
|
+
show(entry, FILE_STATE.FAILED, copy);
|
|
21544
|
+
reportRefusal(entry.batch, entry, entry.file.name, copy);
|
|
21041
21545
|
return;
|
|
21042
21546
|
}
|
|
21043
21547
|
entry.progress.value = 0;
|
|
@@ -21070,6 +21574,7 @@ function createHelpDeskComposer(options) {
|
|
|
21070
21574
|
const problem = uploadProblem(refusalOf(request, error), organization);
|
|
21071
21575
|
entry.retryable = problem.retryable;
|
|
21072
21576
|
show(entry, FILE_STATE.FAILED, problem.copy);
|
|
21577
|
+
if (!problem.retryable) reportRefusal(entry.batch, entry, entry.file.name, problem.copy);
|
|
21073
21578
|
} finally {
|
|
21074
21579
|
if (entry.controller === controller) entry.controller = null;
|
|
21075
21580
|
if (entry.operation === operation) entry.operation = null;
|
|
@@ -21102,6 +21607,7 @@ function createHelpDeskComposer(options) {
|
|
|
21102
21607
|
const refocus = document.activeElement === entry.remove;
|
|
21103
21608
|
const index = entries.indexOf(entry);
|
|
21104
21609
|
entry.controller?.abort();
|
|
21610
|
+
releasePreview(entry);
|
|
21105
21611
|
entries = entries.filter((candidate) => candidate !== entry);
|
|
21106
21612
|
entry.row.remove();
|
|
21107
21613
|
setNotice(null);
|
|
@@ -21111,13 +21617,14 @@ function createHelpDeskComposer(options) {
|
|
|
21111
21617
|
if (refocus) (entries[Math.min(index, entries.length - 1)]?.remove ?? attach).focus();
|
|
21112
21618
|
}
|
|
21113
21619
|
|
|
21114
|
-
function add(files) {
|
|
21620
|
+
function add(files, batch = selection()) {
|
|
21115
21621
|
if (!accepting()) return;
|
|
21116
21622
|
const incoming = Array.from(files);
|
|
21117
21623
|
if (incoming.length === 0) return;
|
|
21118
21624
|
const counted = entries.filter((entry) => entry.state !== FILE_STATE.REFUSED).length;
|
|
21119
21625
|
const room = Math.max(0, MAX_ATTACHMENTS_PER_MESSAGE - counted);
|
|
21120
21626
|
setNotice(incoming.length > room ? LIMIT_COPY : null);
|
|
21627
|
+
if (incoming.length > room) reportRefusal(batch, batch, null, LIMIT_COPY);
|
|
21121
21628
|
for (const file of incoming.slice(0, room)) {
|
|
21122
21629
|
const row = document.createElement('li');
|
|
21123
21630
|
row.className = 'svhd-attachment-chip';
|
|
@@ -21144,11 +21651,14 @@ function createHelpDeskComposer(options) {
|
|
|
21144
21651
|
const entry = {
|
|
21145
21652
|
file, row, status, progress, remove: removeButton, retry,
|
|
21146
21653
|
state: FILE_STATE.QUEUED, retryable: false, controller: null, operation: null,
|
|
21147
|
-
target: null, attachmentId: null, sessionUrl: null
|
|
21654
|
+
target: null, attachmentId: null, sessionUrl: null, batch, previewUrl: null, previewAttempted: false
|
|
21148
21655
|
};
|
|
21149
21656
|
removeButton.addEventListener('click', () => remove(entry));
|
|
21150
21657
|
retry.addEventListener('click', () => {
|
|
21151
|
-
if (!locked && entry.retryable)
|
|
21658
|
+
if (!locked && entry.retryable) {
|
|
21659
|
+
entry.batch = selection();
|
|
21660
|
+
void run(entry);
|
|
21661
|
+
}
|
|
21152
21662
|
});
|
|
21153
21663
|
row.append(name, removeButton, status, retry, progress);
|
|
21154
21664
|
list.append(row);
|
|
@@ -21172,13 +21682,18 @@ function createHelpDeskComposer(options) {
|
|
|
21172
21682
|
drop.hidden = !value;
|
|
21173
21683
|
}
|
|
21174
21684
|
function refuseFiles() {
|
|
21175
|
-
if (!notice.hidden && notice.textContent === NO_CUSTOMER_FILES_COPY) return;
|
|
21176
21685
|
setNotice(NO_CUSTOMER_FILES_COPY);
|
|
21686
|
+
const batch = selection();
|
|
21687
|
+
reportRefusal(batch, batch, null, NO_CUSTOMER_FILES_COPY);
|
|
21177
21688
|
}
|
|
21178
21689
|
// A dropped folder is left out, and said so beside any refusal the files with it met.
|
|
21179
21690
|
function attachBrought(files, folders) {
|
|
21180
|
-
|
|
21181
|
-
if (
|
|
21691
|
+
const batch = selection();
|
|
21692
|
+
if (files.length > 0) add(files, batch);
|
|
21693
|
+
if (folders > 0) {
|
|
21694
|
+
setNotice(files.length > 0 && !notice.hidden ? `${FOLDER_REFUSAL_COPY} ${notice.textContent}` : FOLDER_REFUSAL_COPY);
|
|
21695
|
+
reportRefusal(batch, 'folders', null, FOLDER_REFUSAL_COPY);
|
|
21696
|
+
}
|
|
21182
21697
|
}
|
|
21183
21698
|
const fileEvents = composerFileEvents({
|
|
21184
21699
|
action: fileAction,
|
|
@@ -21189,33 +21704,6 @@ function createHelpDeskComposer(options) {
|
|
|
21189
21704
|
refuse: refuseFiles
|
|
21190
21705
|
});
|
|
21191
21706
|
|
|
21192
|
-
// The (?) tip: a disclosure that closes by its trigger, Escape, its close
|
|
21193
|
-
// button (focus back on the trigger), a press outside it, or focus leaving it.
|
|
21194
|
-
const inTip = (node) => node instanceof Node && (helpTrigger.contains(node) || helpPanel.contains(node));
|
|
21195
|
-
function setHelpOpen(open) {
|
|
21196
|
-
helpPanel.hidden = !open;
|
|
21197
|
-
helpTrigger.setAttribute('aria-expanded', String(open));
|
|
21198
|
-
if (open) document.addEventListener('pointerdown', onPressOutsideHelp);
|
|
21199
|
-
else document.removeEventListener('pointerdown', onPressOutsideHelp);
|
|
21200
|
-
}
|
|
21201
|
-
function onPressOutsideHelp(event) {
|
|
21202
|
-
if (!inTip(event.target)) setHelpOpen(false);
|
|
21203
|
-
}
|
|
21204
|
-
const onHelpToggle = () => setHelpOpen(helpPanel.hidden);
|
|
21205
|
-
const onHelpClose = () => {
|
|
21206
|
-
setHelpOpen(false);
|
|
21207
|
-
helpTrigger.focus();
|
|
21208
|
-
};
|
|
21209
|
-
// Escape is the tip's alone while it is open: a dialog the form sits in leaves a handled key alone.
|
|
21210
|
-
const onHelpKey = (event) => {
|
|
21211
|
-
if (event.key !== 'Escape' || helpPanel.hidden) return;
|
|
21212
|
-
event.preventDefault();
|
|
21213
|
-
onHelpClose();
|
|
21214
|
-
};
|
|
21215
|
-
const onHelpFocusOut = (event) => {
|
|
21216
|
-
if (!helpPanel.hidden && event.relatedTarget && !inTip(event.relatedTarget)) setHelpOpen(false);
|
|
21217
|
-
};
|
|
21218
|
-
|
|
21219
21707
|
// A desk's refusal of files gives way once the customer writes on.
|
|
21220
21708
|
const onInput = () => {
|
|
21221
21709
|
if (!transport) setNotice(null);
|
|
@@ -21239,19 +21727,15 @@ function createHelpDeskComposer(options) {
|
|
|
21239
21727
|
}
|
|
21240
21728
|
input.addEventListener('change', onChoose);
|
|
21241
21729
|
attach.addEventListener('click', onAttach);
|
|
21242
|
-
helpTrigger.addEventListener('click', onHelpToggle);
|
|
21243
|
-
helpClose.addEventListener('click', onHelpClose);
|
|
21244
|
-
for (const part of [helpTrigger, helpPanel]) {
|
|
21245
|
-
part.addEventListener('keydown', onHelpKey);
|
|
21246
|
-
part.addEventListener('focusout', onHelpFocusOut);
|
|
21247
|
-
}
|
|
21248
21730
|
|
|
21249
21731
|
function clear(keepAttached = false) {
|
|
21250
21732
|
revision += 1;
|
|
21733
|
+
dismissValidation();
|
|
21251
21734
|
const previous = entries;
|
|
21252
21735
|
entries = [];
|
|
21253
21736
|
for (const entry of previous) {
|
|
21254
21737
|
entry.controller?.abort();
|
|
21738
|
+
releasePreview(entry);
|
|
21255
21739
|
if (!keepAttached || entry.state !== FILE_STATE.COMPLETE) void cancel(entry.target, entry.attachmentId);
|
|
21256
21740
|
}
|
|
21257
21741
|
list.replaceChildren();
|
|
@@ -21299,7 +21783,6 @@ function createHelpDeskComposer(options) {
|
|
|
21299
21783
|
destroy(keepAttached = false) {
|
|
21300
21784
|
destroyed = true;
|
|
21301
21785
|
clear(keepAttached);
|
|
21302
|
-
setHelpOpen(false);
|
|
21303
21786
|
zone.removeEventListener('dragenter', fileEvents.dragOver);
|
|
21304
21787
|
zone.removeEventListener('dragover', fileEvents.dragOver);
|
|
21305
21788
|
zone.removeEventListener('dragleave', fileEvents.dragLeave);
|
|
@@ -21310,12 +21793,6 @@ function createHelpDeskComposer(options) {
|
|
|
21310
21793
|
}
|
|
21311
21794
|
input.removeEventListener('change', onChoose);
|
|
21312
21795
|
attach.removeEventListener('click', onAttach);
|
|
21313
|
-
helpTrigger.removeEventListener('click', onHelpToggle);
|
|
21314
|
-
helpClose.removeEventListener('click', onHelpClose);
|
|
21315
|
-
for (const part of [helpTrigger, helpPanel]) {
|
|
21316
|
-
part.removeEventListener('keydown', onHelpKey);
|
|
21317
|
-
part.removeEventListener('focusout', onHelpFocusOut);
|
|
21318
|
-
}
|
|
21319
21796
|
}
|
|
21320
21797
|
};
|
|
21321
21798
|
}
|
|
@@ -21463,6 +21940,7 @@ function saveFormDraft(deskId, requesterId, value) {
|
|
|
21463
21940
|
catch { /* Storage is optional; the live form keeps its composition. */ }
|
|
21464
21941
|
}
|
|
21465
21942
|
|
|
21943
|
+
const HELP_DESK_FORM_TITLE = 'Open a Support Ticket';
|
|
21466
21944
|
let formSequence = 0;
|
|
21467
21945
|
/**
|
|
21468
21946
|
* The desk API's refusal of a file's draft or upload, as the composer reads
|
|
@@ -21601,15 +22079,17 @@ function companySignInUrl(value) {
|
|
|
21601
22079
|
* A confirmed send replaces the form with its confirmation.
|
|
21602
22080
|
*
|
|
21603
22081
|
* The request is a summary and optional details, in a composer that also
|
|
21604
|
-
* takes files. A signed-out widget customer writes it
|
|
21605
|
-
*
|
|
21606
|
-
*
|
|
21607
|
-
* beside the request.
|
|
22082
|
+
* takes files. A signed-out widget customer writes it before continuing to
|
|
22083
|
+
* sign-in, where one button opens the native sign-in window and sends it. A
|
|
22084
|
+
* signed-in customer can switch account or sign out beside the request.
|
|
21608
22085
|
*/
|
|
21609
22086
|
function mountHelpDeskForm(client, options) {
|
|
21610
22087
|
const target = resolveTarget(options.target);
|
|
21611
22088
|
injectHelpDeskFormStyles();
|
|
21612
|
-
|
|
22089
|
+
// OAuth sign-in belongs to the hosted desk. A native Identity ceremony or
|
|
22090
|
+
// company assertion on this host cannot stand in for that configured login.
|
|
22091
|
+
const oauth = client.desk.auth_mode === 'oauth2';
|
|
22092
|
+
const widget = oauth ? undefined : options.widgetIdentity;
|
|
21613
22093
|
const shell = new InlineShell(target, {
|
|
21614
22094
|
containerClassName: 'svhd-container',
|
|
21615
22095
|
bodyClassName: 'svhd-body',
|
|
@@ -21622,22 +22102,16 @@ function mountHelpDeskForm(client, options) {
|
|
|
21622
22102
|
form.className = 'svhd-form';
|
|
21623
22103
|
form.noValidate = true;
|
|
21624
22104
|
shell.body.append(form);
|
|
21625
|
-
/** A step's heading
|
|
21626
|
-
function stepHead(id, title
|
|
22105
|
+
/** A step's heading takes focus when the customer enters it. */
|
|
22106
|
+
function stepHead(id, title) {
|
|
21627
22107
|
const head = document.createElement('div');
|
|
21628
22108
|
head.className = 'svhd-step-head';
|
|
21629
|
-
const stepLabel = label === null ? null : document.createElement('p');
|
|
21630
|
-
if (stepLabel) {
|
|
21631
|
-
stepLabel.className = 'svhd-step-label';
|
|
21632
|
-
stepLabel.textContent = label;
|
|
21633
|
-
head.append(stepLabel);
|
|
21634
|
-
}
|
|
21635
22109
|
const stepHeading = document.createElement('h2');
|
|
21636
22110
|
stepHeading.id = id;
|
|
21637
22111
|
stepHeading.tabIndex = -1;
|
|
21638
22112
|
stepHeading.textContent = title;
|
|
21639
22113
|
head.append(stepHeading);
|
|
21640
|
-
return { head, heading: stepHeading
|
|
22114
|
+
return { head, heading: stepHeading };
|
|
21641
22115
|
}
|
|
21642
22116
|
function stepContainer(step) {
|
|
21643
22117
|
const container = document.createElement('div');
|
|
@@ -21645,7 +22119,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21645
22119
|
container.dataset.contactStep = step;
|
|
21646
22120
|
return container;
|
|
21647
22121
|
}
|
|
21648
|
-
const request = stepHead(`${prefix}-heading`,
|
|
22122
|
+
const request = stepHead(`${prefix}-heading`, HELP_DESK_FORM_TITLE);
|
|
21649
22123
|
const heading = request.heading;
|
|
21650
22124
|
form.setAttribute('aria-labelledby', heading.id);
|
|
21651
22125
|
const details = stepContainer('details');
|
|
@@ -21792,7 +22266,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21792
22266
|
const widgetAccount = document.createElement('div');
|
|
21793
22267
|
widgetAccount.className = 'svhd-widget-account';
|
|
21794
22268
|
let widgetCustomer = widget?.customer ?? null;
|
|
21795
|
-
const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request'
|
|
22269
|
+
const signInStep = widget ? stepHead(`${prefix}-signin-heading`, 'Sign in to send your request') : null;
|
|
21796
22270
|
const identity = widget ? stepContainer('identity') : null;
|
|
21797
22271
|
const recap = document.createElement('div');
|
|
21798
22272
|
recap.className = 'svhd-recap';
|
|
@@ -21918,6 +22392,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
21918
22392
|
let websiteSignedOut = false;
|
|
21919
22393
|
// The form is held while the secure window chooses another account: no send is under way.
|
|
21920
22394
|
let switchingAccount = false;
|
|
22395
|
+
let portalRequired = oauth;
|
|
21921
22396
|
/**
|
|
21922
22397
|
* Save the request as the form holds it. Never while a sign-in is under
|
|
21923
22398
|
* way: a session notification then blanks the fields until the sign-in's
|
|
@@ -22006,13 +22481,12 @@ function mountHelpDeskForm(client, options) {
|
|
|
22006
22481
|
* The signed-in widget customer writes and sends in one step, posting as
|
|
22007
22482
|
* the account named under it, beside Switch account and, but for a website
|
|
22008
22483
|
* account's session, which the website ends, Sign out; a signed-out one
|
|
22009
|
-
* writes the request
|
|
22484
|
+
* writes the request before continuing to sign-in. Either way the form
|
|
22485
|
+
* shows the request.
|
|
22010
22486
|
*/
|
|
22011
22487
|
function renderWidgetIdentity() {
|
|
22012
22488
|
if (!widget)
|
|
22013
22489
|
return;
|
|
22014
|
-
if (request.label)
|
|
22015
|
-
request.label.hidden = widgetCustomer !== null;
|
|
22016
22490
|
auth.hidden = true;
|
|
22017
22491
|
code.wrapper.hidden = true;
|
|
22018
22492
|
name.wrapper.hidden = true;
|
|
@@ -22051,7 +22525,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
22051
22525
|
*/
|
|
22052
22526
|
function renderActions() {
|
|
22053
22527
|
send.textContent = idleLabel();
|
|
22054
|
-
send.hidden = recovery === 'external_sso' && widget !== undefined && !widget.useWebsiteAccount;
|
|
22528
|
+
send.hidden = portalRequired || (recovery === 'external_sso' && widget !== undefined && !widget.useWebsiteAccount);
|
|
22055
22529
|
startNew.hidden = recovery === null;
|
|
22056
22530
|
widgetAccount.hidden = recovery !== null || widgetAccount.childElementCount === 0;
|
|
22057
22531
|
recap.hidden = recovery !== null;
|
|
@@ -22084,7 +22558,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
22084
22558
|
function setStep(next) {
|
|
22085
22559
|
const changed = next !== step;
|
|
22086
22560
|
step = next;
|
|
22087
|
-
details.hidden = next !== 'details';
|
|
22561
|
+
details.hidden = next !== 'details' || (portalRequired && !subject.input.value && !description.input.value);
|
|
22088
22562
|
if (identity)
|
|
22089
22563
|
identity.hidden = next !== 'identity';
|
|
22090
22564
|
if (next === 'identity') {
|
|
@@ -22164,13 +22638,13 @@ function mountHelpDeskForm(client, options) {
|
|
|
22164
22638
|
function disable(disabled) {
|
|
22165
22639
|
for (const input of [subject.input, description.input, email.input, code.input, name.input, send, cancel, changeEmail, editRequest, startNew])
|
|
22166
22640
|
input.disabled = disabled;
|
|
22167
|
-
const held = uncertainSubmission !== null || recovery !== null;
|
|
22641
|
+
const held = uncertainSubmission !== null || recovery !== null || portalRequired;
|
|
22168
22642
|
subject.input.readOnly = held;
|
|
22169
22643
|
description.input.readOnly = held;
|
|
22170
22644
|
for (const button of widgetAccount.querySelectorAll('button'))
|
|
22171
22645
|
button.disabled = disabled || uncertainSubmission !== null || completed;
|
|
22172
22646
|
renderResend();
|
|
22173
|
-
composer.disablePicking(disabled || recovery !== null);
|
|
22647
|
+
composer.disablePicking(disabled || recovery !== null || portalRequired);
|
|
22174
22648
|
composer.lock(completed || uncertainSubmission !== null);
|
|
22175
22649
|
}
|
|
22176
22650
|
function clearCode() {
|
|
@@ -22410,7 +22884,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
22410
22884
|
pending = false;
|
|
22411
22885
|
switchingAccount = false;
|
|
22412
22886
|
sessionKnown = false;
|
|
22413
|
-
if (
|
|
22887
|
+
if (widget)
|
|
22414
22888
|
widgetCustomer = null;
|
|
22415
22889
|
clearComposer();
|
|
22416
22890
|
recovery = hidden;
|
|
@@ -22423,6 +22897,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
22423
22897
|
message('Your sign-in changed. Start a new request for the current account.');
|
|
22424
22898
|
else
|
|
22425
22899
|
renderActions();
|
|
22900
|
+
if (oauth)
|
|
22901
|
+
showHosted();
|
|
22426
22902
|
// The request and its actions changed under the pointer: a press already
|
|
22427
22903
|
// under way must not act on what replaced them.
|
|
22428
22904
|
options.onScreenChange?.();
|
|
@@ -22476,6 +22952,26 @@ function mountHelpDeskForm(client, options) {
|
|
|
22476
22952
|
focusAfter = challenge ? code.input : email.input;
|
|
22477
22953
|
}
|
|
22478
22954
|
function showHosted() {
|
|
22955
|
+
if (oauth) {
|
|
22956
|
+
portalRequired = true;
|
|
22957
|
+
persistDraft();
|
|
22958
|
+
// Leave existing text available to copy, without putting a draft or
|
|
22959
|
+
// credentials in the destination URL or claiming it was transferred.
|
|
22960
|
+
const hasDraft = Boolean(subject.input.value || description.input.value);
|
|
22961
|
+
details.hidden = !hasDraft;
|
|
22962
|
+
auth.hidden = true;
|
|
22963
|
+
hosted.hidden = newRequestUrl === null;
|
|
22964
|
+
if (newRequestUrl)
|
|
22965
|
+
hosted.href = newRequestUrl;
|
|
22966
|
+
hosted.textContent = 'Open help desk in a new tab';
|
|
22967
|
+
send.hidden = true;
|
|
22968
|
+
disable(pending);
|
|
22969
|
+
message(hasDraft
|
|
22970
|
+
? '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.'
|
|
22971
|
+
: 'Open the help desk to sign in and write your request.');
|
|
22972
|
+
focusAfter = hosted.hidden ? null : hosted;
|
|
22973
|
+
return;
|
|
22974
|
+
}
|
|
22479
22975
|
if (client.desk.auth_mode === 'external_sso' || client.desk.auth_mode === 'external_unavailable') {
|
|
22480
22976
|
const url = companySignInUrl(client.desk.external_identity?.sign_in_url);
|
|
22481
22977
|
hosted.hidden = url === null;
|
|
@@ -22493,6 +22989,11 @@ function mountHelpDeskForm(client, options) {
|
|
|
22493
22989
|
async function submit() {
|
|
22494
22990
|
if (pending || completed || destroyed)
|
|
22495
22991
|
return;
|
|
22992
|
+
if (portalRequired) {
|
|
22993
|
+
showHosted();
|
|
22994
|
+
focusSettled();
|
|
22995
|
+
return;
|
|
22996
|
+
}
|
|
22496
22997
|
// Sending (Enter in a field, a code's last digit) answers the discard
|
|
22497
22998
|
// question: the customer kept going.
|
|
22498
22999
|
closeConfirm(false);
|
|
@@ -22564,7 +23065,7 @@ function mountHelpDeskForm(client, options) {
|
|
|
22564
23065
|
let token = await tokenFor(ownGeneration);
|
|
22565
23066
|
if (!alive(ownGeneration))
|
|
22566
23067
|
return;
|
|
22567
|
-
if (widgetSignIn || (!token && options.onAuthRequired && client.desk.auth_mode !== 'external_sso' && client.desk.auth_mode !== 'external_unavailable')) {
|
|
23068
|
+
if (widgetSignIn || (!token && options.onAuthRequired && !oauth && client.desk.auth_mode !== 'external_sso' && client.desk.auth_mode !== 'external_unavailable')) {
|
|
22568
23069
|
authenticating = true;
|
|
22569
23070
|
authNotification = false;
|
|
22570
23071
|
const session = await (widgetSignIn ?? options.onAuthRequired());
|
|
@@ -22989,6 +23490,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
22989
23490
|
description.input.value = composition.body;
|
|
22990
23491
|
persistDraft();
|
|
22991
23492
|
syncLeaveGuard();
|
|
23493
|
+
if (portalRequired && !pending)
|
|
23494
|
+
showHosted();
|
|
22992
23495
|
},
|
|
22993
23496
|
refill(issue) {
|
|
22994
23497
|
if (destroyed || restoredDraft || recovery !== null || safeComposition() === null)
|
|
@@ -23007,11 +23510,17 @@ function mountHelpDeskForm(client, options) {
|
|
|
23007
23510
|
recapText.textContent = subject.input.value.trim();
|
|
23008
23511
|
persistDraft();
|
|
23009
23512
|
syncLeaveGuard();
|
|
23513
|
+
if (portalRequired && !pending)
|
|
23514
|
+
showHosted();
|
|
23010
23515
|
return true;
|
|
23011
23516
|
},
|
|
23012
23517
|
resumeAfterAccess() {
|
|
23013
|
-
if (!destroyed && !pending && !completed && uncertainSubmission === null)
|
|
23014
|
-
|
|
23518
|
+
if (!destroyed && !pending && !completed && uncertainSubmission === null) {
|
|
23519
|
+
if (portalRequired)
|
|
23520
|
+
showHosted();
|
|
23521
|
+
else
|
|
23522
|
+
message('');
|
|
23523
|
+
}
|
|
23015
23524
|
},
|
|
23016
23525
|
returnToRequest() {
|
|
23017
23526
|
if (destroyed || step !== 'identity')
|
|
@@ -23024,6 +23533,10 @@ function mountHelpDeskForm(client, options) {
|
|
|
23024
23533
|
focusEntry(focusOptions) {
|
|
23025
23534
|
if (destroyed || form.hidden)
|
|
23026
23535
|
return false;
|
|
23536
|
+
if (portalRequired && !hosted.hidden) {
|
|
23537
|
+
hosted.focus(focusOptions);
|
|
23538
|
+
return true;
|
|
23539
|
+
}
|
|
23027
23540
|
if (step === 'identity' && signInStep) {
|
|
23028
23541
|
(send.disabled ? signInStep.heading : send).focus(focusOptions);
|
|
23029
23542
|
return true;
|
|
@@ -23075,8 +23588,8 @@ function mountHelpDeskForm(client, options) {
|
|
|
23075
23588
|
});
|
|
23076
23589
|
send.textContent = idleLabel();
|
|
23077
23590
|
renderWidgetIdentity();
|
|
23078
|
-
if (
|
|
23079
|
-
restoreDraft(
|
|
23591
|
+
if (widget?.customer) {
|
|
23592
|
+
restoreDraft(widget.customer);
|
|
23080
23593
|
disable(false);
|
|
23081
23594
|
}
|
|
23082
23595
|
else if (widget?.recovering) {
|
|
@@ -23106,9 +23619,42 @@ function mountHelpDeskForm(client, options) {
|
|
|
23106
23619
|
live.announce('Step 1 of 2');
|
|
23107
23620
|
syncLeaveGuard();
|
|
23108
23621
|
notify$1(options.onStateChange, state);
|
|
23622
|
+
if (oauth) {
|
|
23623
|
+
// Read an already-established desk session before exposing the composer.
|
|
23624
|
+
// The hosted OAuth flow establishes new sessions; this module never does.
|
|
23625
|
+
const ownGeneration = generation;
|
|
23626
|
+
pending = true;
|
|
23627
|
+
details.hidden = true;
|
|
23628
|
+
send.hidden = true;
|
|
23629
|
+
disable(true);
|
|
23630
|
+
message('Loading support');
|
|
23631
|
+
void tokenFor(ownGeneration).then((token) => {
|
|
23632
|
+
if (!alive(ownGeneration))
|
|
23633
|
+
return;
|
|
23634
|
+
if (!token) {
|
|
23635
|
+
showHosted();
|
|
23636
|
+
return;
|
|
23637
|
+
}
|
|
23638
|
+
portalRequired = false;
|
|
23639
|
+
details.hidden = false;
|
|
23640
|
+
hosted.hidden = true;
|
|
23641
|
+
message('');
|
|
23642
|
+
renderActions();
|
|
23643
|
+
}, (failure) => {
|
|
23644
|
+
if (!alive(ownGeneration))
|
|
23645
|
+
return;
|
|
23646
|
+
showHosted();
|
|
23647
|
+
notify$1(options.onError, failure instanceof Error ? failure : new Error('Support could not be loaded.'));
|
|
23648
|
+
}).finally(() => {
|
|
23649
|
+
if (alive(ownGeneration)) {
|
|
23650
|
+
pending = false;
|
|
23651
|
+
disable(false);
|
|
23652
|
+
}
|
|
23653
|
+
});
|
|
23654
|
+
}
|
|
23109
23655
|
// Native company identity starts as the form opens, never from a Connect,
|
|
23110
23656
|
// Allow, verification or submit gesture. Guest email is explicit desk policy.
|
|
23111
|
-
if (!
|
|
23657
|
+
if (!widget && ((client.desk.auth_mode === 'external_sso' && client.hasIdentityProvider) || client.desk.auth_mode === 'external_unavailable')) {
|
|
23112
23658
|
const ownGeneration = generation;
|
|
23113
23659
|
nativeProofGeneration = ownGeneration;
|
|
23114
23660
|
pending = true;
|
|
@@ -23219,7 +23765,7 @@ function openHelpDeskForm(client, options = {}) {
|
|
|
23219
23765
|
header.className = 'svhd-modal-header';
|
|
23220
23766
|
const title = document.createElement('span');
|
|
23221
23767
|
title.id = `${prefix}-title`;
|
|
23222
|
-
title.textContent =
|
|
23768
|
+
title.textContent = HELP_DESK_FORM_TITLE;
|
|
23223
23769
|
title.hidden = true;
|
|
23224
23770
|
const close = document.createElement('button');
|
|
23225
23771
|
close.type = 'button';
|
|
@@ -24748,6 +25294,7 @@ const currentVisitor = (value) => value !== null && typeof value === 'object' &&
|
|
|
24748
25294
|
'visitor_id' in value && validVisitorId(value.visitor_id) &&
|
|
24749
25295
|
'expires_at' in value && typeof value.expires_at === 'number' && Number.isSafeInteger(value.expires_at) &&
|
|
24750
25296
|
value.expires_at * 1000 > Date.now() + 60000 && value.expires_at * 1000 <= Date.now() + 31 * 86400000;
|
|
25297
|
+
let viewSequence = 0;
|
|
24751
25298
|
const invalid = () => new SparkVaultError('The help center returned an invalid answer. Try again.', 'KB_INVALID_RESPONSE');
|
|
24752
25299
|
const changed = () => new SparkVaultError('The help center changed. Search again to see current answers.', 'KB_PUBLICATION_CHANGED', 409);
|
|
24753
25300
|
const validPath = (value) => typeof value === 'string' && value.startsWith('/') && !value.startsWith('//') &&
|
|
@@ -24953,10 +25500,12 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
24953
25500
|
if (settings.enabled && validVisitorCookieName(settings.cookie_name)) {
|
|
24954
25501
|
if (cookieEndpoint) {
|
|
24955
25502
|
const endpoint = ownOrigin ? '/_sv/visitor' : new URL('/_sv/visitor', config.canonical_origin).href;
|
|
24956
|
-
const
|
|
24957
|
-
|
|
24958
|
-
|
|
24959
|
-
|
|
25503
|
+
const answer = await exchange(endpoint, { credentials: ownOrigin ? 'same-origin' : 'include', cache: 'no-store', redirect: 'error' }, {
|
|
25504
|
+
timeoutMs: this.sdkConfig.timeout, closeSignal: this.close.signal,
|
|
25505
|
+
read: async (response) => { if (!response.ok)
|
|
25506
|
+
throw invalid(); return await response.json(); },
|
|
25507
|
+
fail: failure => failure === 'timeout' ? new TimeoutError() : new NetworkError('Visitor identification could not be reached. Try again.')
|
|
25508
|
+
});
|
|
24960
25509
|
candidate = answer.visitor_id;
|
|
24961
25510
|
}
|
|
24962
25511
|
else {
|
|
@@ -24989,8 +25538,8 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
24989
25538
|
}
|
|
24990
25539
|
/** Use the help center's browser visitor and vote receipt; ticket identity is never sent. */
|
|
24991
25540
|
async vote(article, vote) {
|
|
24992
|
-
if (article
|
|
24993
|
-
throw new ValidationError('Choose yes or no for a published
|
|
25541
|
+
if (!['article', 'faq'].includes(article?.kind) || typeof article.id !== 'string' || !article.id || article.id.length > 256 || !['yes', 'no'].includes(vote)) {
|
|
25542
|
+
throw new ValidationError('Choose yes or no for a published answer.');
|
|
24994
25543
|
}
|
|
24995
25544
|
const reference = { id: article.id, release_id: article.release_id };
|
|
24996
25545
|
const previous = this.voteQueues.get(reference.id) ?? Promise.resolve();
|
|
@@ -25051,6 +25600,29 @@ class HelpDeskKnowledgeBaseClient {
|
|
|
25051
25600
|
this.readerDocument = { ...value, body_html };
|
|
25052
25601
|
return this.readerDocument;
|
|
25053
25602
|
}
|
|
25603
|
+
/** Record only a displayed reader document; access is checked again by the event endpoint. */
|
|
25604
|
+
async view(document) {
|
|
25605
|
+
const config = this.config;
|
|
25606
|
+
if (!config?.authorized || !config.available || this.readerDocument !== document || config.release_id !== document.release_id)
|
|
25607
|
+
throw changed();
|
|
25608
|
+
if (!visitorCookieSettings(config.visitor_identifier).enabled)
|
|
25609
|
+
return;
|
|
25610
|
+
const eventId = `${Date.now()}-${++viewSequence}`;
|
|
25611
|
+
const visitor = await this.visitor(config);
|
|
25612
|
+
const body = { visitor_id: visitor.visitor_id, release_id: document.release_id, event_id: eventId, type: 'view', article_id: document.id };
|
|
25613
|
+
let result;
|
|
25614
|
+
try {
|
|
25615
|
+
result = await this.request('events', { body });
|
|
25616
|
+
}
|
|
25617
|
+
catch (error) {
|
|
25618
|
+
if (!(error instanceof NetworkError || error instanceof TimeoutError || error instanceof SparkVaultError && (error.statusCode ?? 0) >= 500))
|
|
25619
|
+
throw error;
|
|
25620
|
+
// A lost acknowledgement retries the same receipt so an open is counted once.
|
|
25621
|
+
result = await this.request('events', { body });
|
|
25622
|
+
}
|
|
25623
|
+
if (typeof result?.recorded !== 'boolean')
|
|
25624
|
+
throw invalid();
|
|
25625
|
+
}
|
|
25054
25626
|
/** Paint article text first; hydrate only approved media without replacing the reader DOM. */
|
|
25055
25627
|
hydrateAssets(document, callbacks) {
|
|
25056
25628
|
if (this.destroyed || this.readerDocument?.id !== document.id || this.readerDocument.release_id !== document.release_id)
|
|
@@ -25942,11 +26514,12 @@ class SupportView {
|
|
|
25942
26514
|
results.prepend(queryLine);
|
|
25943
26515
|
results.append(this.resultList, this.resultStatus, this.resultError);
|
|
25944
26516
|
this.resultError.setAttribute('role', 'alert');
|
|
25945
|
-
this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a ticket', () => {
|
|
26517
|
+
this.contactResults = button('svhs-secondary svhs-full', 'Still need help? Open a support ticket', () => {
|
|
25946
26518
|
if (this.state?.busy)
|
|
25947
26519
|
return;
|
|
25948
26520
|
this.actions.onContact(['locked', 'unavailable'].includes(this.state?.kbState || '') ? 'direct' : this.state?.results?.length ? 'none_match' : 'no_results');
|
|
25949
26521
|
});
|
|
26522
|
+
this.contactResults.append(helpDeskIcon('arrowRight'));
|
|
25950
26523
|
this.contactNote.id = `${this.prefix}-contact-note`;
|
|
25951
26524
|
this.contactNote.hidden = true;
|
|
25952
26525
|
this.resultsFooter = this.footer('results');
|
|
@@ -26094,7 +26667,7 @@ class SupportView {
|
|
|
26094
26667
|
this.sourceArticle.textContent = next.sourceArticle ? `Article you read: ${next.sourceArticle.title}` : '';
|
|
26095
26668
|
this.sourceArticle.hidden = !next.sourceArticle;
|
|
26096
26669
|
this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden && this.sourceArticle.hidden;
|
|
26097
|
-
this.feedbackStatus.textContent = next.feedbackBusy ? 'Saving your feedback...' : next.feedbackError ? '' :
|
|
26670
|
+
this.feedbackStatus.textContent = next.feedbackBusy ? 'Saving your feedback...' : next.feedbackError ? '' : 'Your feedback has been saved.';
|
|
26098
26671
|
this.feedbackError.textContent = next.feedbackError || '';
|
|
26099
26672
|
this.feedbackError.hidden = !next.feedbackError;
|
|
26100
26673
|
this.retryFeedback.hidden = !next.feedbackError || !this.actions.onRetryFeedback;
|
|
@@ -26744,6 +27317,7 @@ function createHelpDeskSupport(config, options) {
|
|
|
26744
27317
|
let attempt = null;
|
|
26745
27318
|
let results = [];
|
|
26746
27319
|
let requestedArticle = null;
|
|
27320
|
+
let displayedArticle = null;
|
|
26747
27321
|
let articleRetrySearch = false;
|
|
26748
27322
|
let cancelArticleAssets = null;
|
|
26749
27323
|
let stopSession = null;
|
|
@@ -26844,6 +27418,12 @@ function createHelpDeskSupport(config, options) {
|
|
|
26844
27418
|
const rebranded = change.brand !== undefined && change.brand !== state.brand;
|
|
26845
27419
|
state = { ...state, ...change };
|
|
26846
27420
|
view.render(state);
|
|
27421
|
+
if (kb && state.visible && state.stage === 'article' && state.article && state.article !== displayedArticle) {
|
|
27422
|
+
displayedArticle = state.article;
|
|
27423
|
+
// A read can finish while minimized. Count the answer only after it is displayed.
|
|
27424
|
+
void kb.view(state.article).catch(value => { if (!destroyed)
|
|
27425
|
+
notify(options.onError, failure(value)); });
|
|
27426
|
+
}
|
|
26847
27427
|
launcher?.setExpanded(state.visible);
|
|
26848
27428
|
if (rebranded)
|
|
26849
27429
|
launcher?.setBrand(state.brand);
|
|
@@ -26946,8 +27526,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
26946
27526
|
return;
|
|
26947
27527
|
const ownFeedback = ++feedbackSequence;
|
|
26948
27528
|
void attempt?.then((active) => active?.solved());
|
|
26949
|
-
update({ stage: 'resolved', feedbackBusy:
|
|
26950
|
-
if (
|
|
27529
|
+
update({ stage: 'resolved', feedbackBusy: Boolean(kb), feedbackError: undefined, reviewUrl: undefined, error: undefined });
|
|
27530
|
+
if (!kb)
|
|
26951
27531
|
return;
|
|
26952
27532
|
try {
|
|
26953
27533
|
const saved = await kb.vote(article, 'yes');
|
|
@@ -27378,8 +27958,8 @@ function createHelpDeskSupport(config, options) {
|
|
|
27378
27958
|
sourceArticleId = article.id;
|
|
27379
27959
|
update({ sourceArticle: { title: article.title, url: article.canonical_url } });
|
|
27380
27960
|
// The article vote and assistance outcome serve different reports. Neither may block contacting the team.
|
|
27381
|
-
if (
|
|
27382
|
-
void kb.vote(article, 'no').catch(() =>
|
|
27961
|
+
if (kb)
|
|
27962
|
+
void kb.vote(article, 'no').catch((value) => notify(options.onError, failure(value)));
|
|
27383
27963
|
}
|
|
27384
27964
|
followIssue();
|
|
27385
27965
|
cancelArticleAssets?.();
|
|
@@ -27731,7 +28311,8 @@ class HelpDeskModule {
|
|
|
27731
28311
|
/**
|
|
27732
28312
|
* Inject a ticket form, including email-code verification where the desk
|
|
27733
28313
|
* enables it. A custom onAuthRequired callback may supply a server-issued
|
|
27734
|
-
* help desk session.
|
|
28314
|
+
* help desk session. OAuth desks open their hosted portal for sign-in unless
|
|
28315
|
+
* a desk session is already installed. Destroy on unmount/account change.
|
|
27735
28316
|
*/
|
|
27736
28317
|
mountForm(options) {
|
|
27737
28318
|
return this.connectForm(options, (client) => mountHelpDeskForm(client, options));
|
|
@@ -32481,7 +33062,7 @@ class SparkVault {
|
|
|
32481
33062
|
}
|
|
32482
33063
|
/** Get the SDK version */
|
|
32483
33064
|
static get version() {
|
|
32484
|
-
return '18.0.
|
|
33065
|
+
return '18.0.6';
|
|
32485
33066
|
}
|
|
32486
33067
|
}
|
|
32487
33068
|
if (typeof window !== 'undefined') {
|