@sparkvault/sdk-js 18.0.5 → 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/dist/index.d.ts CHANGED
@@ -3635,6 +3635,13 @@ interface HelpDeskExternalIdentity {
3635
3635
  sign_in_url?: string | null;
3636
3636
  guest_email?: boolean;
3637
3637
  }
3638
+ /** OAuth endpoints and credentials are configured server-side, never by the host page. */
3639
+ interface HelpDeskOAuthIdentity {
3640
+ issuer: string;
3641
+ session_ttl_seconds: number;
3642
+ /** Independently verified email customers can also sign in at this desk. */
3643
+ guest_email?: boolean;
3644
+ }
3638
3645
  interface HelpDeskConnectOptions {
3639
3646
  /** The configured help desk hostname, for example support.example.com. */
3640
3647
  host: string;
@@ -3692,8 +3699,9 @@ interface HelpDeskDesk {
3692
3699
  logo_dark_url: string | null;
3693
3700
  icon_url?: string | null;
3694
3701
  };
3695
- auth_mode: 'email_pin' | 'external_sso' | 'external_unavailable';
3702
+ auth_mode: 'email_pin' | 'external_sso' | 'external_unavailable' | 'oauth2';
3696
3703
  external_identity?: HelpDeskExternalIdentity | null;
3704
+ oauth_identity?: HelpDeskOAuthIdentity | null;
3697
3705
  customer_can_mark_resolved: boolean;
3698
3706
  /** Optional plain-text note shown only after a request is confirmed sent. */
3699
3707
  ticket_confirmation_message?: string | null;
@@ -4330,7 +4338,8 @@ declare class HelpDeskModule {
4330
4338
  /**
4331
4339
  * Inject a ticket form, including email-code verification where the desk
4332
4340
  * enables it. A custom onAuthRequired callback may supply a server-issued
4333
- * help desk session. Destroy the returned handle on unmount/account change.
4341
+ * help desk session. OAuth desks open their hosted portal for sign-in unless
4342
+ * a desk session is already installed. Destroy on unmount/account change.
4334
4343
  */
4335
4344
  mountForm(options: HelpDeskMountFormOptions): Promise<HelpDeskFormHandle>;
4336
4345
  /** Inject a form over an already-connected client that the host also drives headlessly. */
@@ -6683,4 +6692,4 @@ declare global {
6683
6692
  }
6684
6693
 
6685
6694
  export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, HelpDeskClient, HelpDeskModule, IdentityModule, IdentityProviderError, IngotsModule, MessagingModule, NAME_CONFLICT_POLICIES, NOTIFY_PRESETS, NetworkError, NotifyModule, NotifyProductModule, NotifyProjectsModule, NotifySubscriptionRequiredError, PlanRequiredError, PopupBlockedError, PopupSeveredError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, StructuredIngotTypesModule, StructuredIngotsModule, TimeoutError, UnauthorizedError, UsageCreditFundingReviewError, UsageCreditsExhaustedError, UserCancelledError, ValidationError, VaultsModule, buildNotifyPresetSend, SparkVault as default, fetchDownload, isReceivedUploadFailure, logger, setDebugMode };
6686
- export type { AccessLogRetention, AccessLogsOptions, BatchGetStructuredIngotsOptions, CreateFolderOptions, CreateMessagingConversationOptions, CreateNotifyProjectOptions, CreateNotifySendOptions, CreateSparkOptions, CreateStructuredIngotOptions, CreateStructuredTypeOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, DeleteIngotOptions, DeleteStructuredIngotOptions, DownloadIngotOptions, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, GetStructuredIngotOptions, HealthCheckOptions, HealthCheckResult, HelpDeskAttachmentDownload, HelpDeskAttachmentInput, HelpDeskAttachmentUpload, HelpDeskCarriedComposition, HelpDeskConnectOptions, HelpDeskCreateTicketOptions, HelpDeskCustomer, HelpDeskCustomerPatch, HelpDeskDesk, HelpDeskDraft, HelpDeskEvent, HelpDeskExternalChallenge, HelpDeskExternalIdentity, HelpDeskFormArrival, HelpDeskFormHandle, HelpDeskFormOptions, HelpDeskFormState, HelpDeskIdentityRequest, HelpDeskListTicketsOptions, HelpDeskMountFormOptions, HelpDeskOpenFormOptions, HelpDeskPinChallenge, HelpDeskReplyCreated, HelpDeskReplyOptions, HelpDeskRequestContext, HelpDeskSession, HelpDeskSessionChange, HelpDeskSupportHandle, HelpDeskSupportLauncherOptions, HelpDeskSupportOpenOptions, HelpDeskSupportOptions, HelpDeskSupportStage, HelpDeskSupportState, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, HelpDeskWebsiteAccountReturn, HelpDeskWidgetFormIdentity, HelpDeskWidgetIdentityChallenge, HelpDeskWidgetIdentityOptions, HelpDeskWidgetIdentitySession, AttachOptions as IdentityAttachOptions, ImportStructuredIngotsOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownload, IngotDownloadLink, IngotHistory, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, IngotVersion, IngotVersionDownloadLink, InitiateMessagingAttachmentOptions, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListMessagingInboxOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyProjectsResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, MessagingAttachment, MessagingAttachmentDownload, MessagingAttachmentUpload, MessagingContentMessage, MessagingConversation, MessagingConversationCreated, MessagingConversationSettings, MessagingIdentity, MessagingInboxCursor, MessagingInboxEntry, MessagingInboxPage, MessagingInviteResult, MessagingMessage, MessagingMessageReceipt, MessagingParticipant, MessagingParticipantInput, MessagingReadResult, MessagingRecalledMessage, MessagingReceiptToken, MessagingRecipientIdentity, MessagingSendResult, MessagingUnavailableMessage, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigDestinations, NotifyConfigDestinationsPatch, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigRefusalReason, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyDestinationFailureReason, NotifyDestinationKind, NotifyDestinationReason, NotifyDestinationSkipReason, NotifyDestinationState, NotifyDestinationTestReason, NotifyDestinationTestResult, NotifyDestinationTransportReason, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyProject, NotifyProjectBilling, NotifyProjectStatus, NotifyProjectSubscriptionPreview, NotifyProjectSubscriptionResponse, NotifyProjectUsage, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifyRecipientState, NotifyReportableVerificationLevel, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusDestination, NotifySendStatusRecipient, NotifySendSummary, NotifySendSummaryDestination, NotifySlackDestination, NotifySlackDestinationRead, NotifySuppressionReason, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyVerificationLevel, NotifyWebhookDestination, NotifyWebhookDestinationRead, PatchStructuredIngotOptions, PortableStructuredIngot, PortableStructuredType, PreviewNotifyProjectSubscriptionOptions, PublishStructuredTypeOptions, QuotaResource, ReadMessagingConversationOptions, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, RestoreStructuredIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendMessagingMessageOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, SigninIdentityType, Spark, SparkInviteResend, SparkLinkActionOptions, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, StructuredAccountActivity, StructuredActivity, StructuredActivityOptions, StructuredActivityPeriod, StructuredActivityTotals, StructuredActivityTotalsWire, StructuredActivityWire, StructuredBinaryPath, StructuredExportOutcome, StructuredImportOutcome, StructuredIngot, StructuredIngotHistory, StructuredIngotMutation, StructuredIngotPrecondition, StructuredIngotSummary, StructuredIngotSummaryWire, StructuredIngotVersion, StructuredIngotWire, StructuredIterateOptions, StructuredJsonValue, StructuredMutationWire, StructuredOutcome, StructuredPage, StructuredPageOptions, StructuredPageWire, StructuredReadOutcome, StructuredTypeCreation, StructuredTypeDefinition, StructuredTypeDefinitionWire, StructuredTypePin, StructuredTypePinWire, StructuredTypeSummary, StructuredTypeSummaryWire, StructuredTypeTransform, StructuredValues, StructuredVaultActivity, SubscribeNotifyProjectOptions, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealVaultOptions, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateNotifyProjectOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultResealDefaults, VaultResealSettings, VaultResealSettingsResult, VaultSessionExtension, VaultSessionTiming, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };
6695
+ export type { AccessLogRetention, AccessLogsOptions, BatchGetStructuredIngotsOptions, CreateFolderOptions, CreateMessagingConversationOptions, CreateNotifyProjectOptions, CreateNotifySendOptions, CreateSparkOptions, CreateStructuredIngotOptions, CreateStructuredTypeOptions, CreateUploadOptions, CreateVaultOptions, CreatedIngot, CreatedSpark, DeleteIngotOptions, DeleteStructuredIngotOptions, DownloadIngotOptions, EntropyFormat, EntropyResult, FetchDownloadOptions, FetchedDownload, Folder, FolderBreadcrumbItem, FolderContents, FolderPage, GenerateEntropyOptions, GetStructuredIngotOptions, HealthCheckOptions, HealthCheckResult, HelpDeskAttachmentDownload, HelpDeskAttachmentInput, HelpDeskAttachmentUpload, HelpDeskCarriedComposition, HelpDeskConnectOptions, HelpDeskCreateTicketOptions, HelpDeskCustomer, HelpDeskCustomerPatch, HelpDeskDesk, HelpDeskDraft, HelpDeskEvent, HelpDeskExternalChallenge, HelpDeskExternalIdentity, HelpDeskFormArrival, HelpDeskFormHandle, HelpDeskFormOptions, HelpDeskFormState, HelpDeskIdentityRequest, HelpDeskListTicketsOptions, HelpDeskMountFormOptions, HelpDeskOAuthIdentity, HelpDeskOpenFormOptions, HelpDeskPinChallenge, HelpDeskReplyCreated, HelpDeskReplyOptions, HelpDeskRequestContext, HelpDeskSession, HelpDeskSessionChange, HelpDeskSupportHandle, HelpDeskSupportLauncherOptions, HelpDeskSupportOpenOptions, HelpDeskSupportOptions, HelpDeskSupportStage, HelpDeskSupportState, HelpDeskTicket, HelpDeskTicketCreated, HelpDeskTicketDetail, HelpDeskTicketList, HelpDeskTimeline, HelpDeskVerifyPinOptions, HelpDeskWebsiteAccountReturn, HelpDeskWidgetFormIdentity, HelpDeskWidgetIdentityChallenge, HelpDeskWidgetIdentityOptions, HelpDeskWidgetIdentitySession, AttachOptions as IdentityAttachOptions, ImportStructuredIngotsOptions, Ingot, IngotAccessLog, IngotAccessLogPage, IngotDownload, IngotDownloadLink, IngotHistory, IngotInvitation, IngotInvite, IngotPage, IngotSharingConfig, IngotUpload, IngotVersion, IngotVersionDownloadLink, InitiateMessagingAttachmentOptions, ListContentsOptions, ListFoldersOptions, ListIngotsOptions, ListMessagingInboxOptions, ListNotificationsOptions, ListNotificationsResponse, ListNotifyInboxOptions, ListNotifyInboxResponse, ListNotifyProjectsResponse, ListNotifyReceiptsOptions, ListNotifyReceiptsResponse, ListNotifySendsOptions, ListNotifySendsResponse, ListSparksOptions, MarkAllNotificationsStateOptions, MarkAllNotificationsStateResponse, MarkAllReadResult, MarkNotificationStateOptions, MarkNotificationStateResponse, MarkNotifyInboxAllOptions, MarkNotifyInboxAllResponse, MarkNotifyInboxStateOptions, MarkNotifyInboxStateResponse, MessagingAttachment, MessagingAttachmentDownload, MessagingAttachmentUpload, MessagingContentMessage, MessagingConversation, MessagingConversationCreated, MessagingConversationSettings, MessagingIdentity, MessagingInboxCursor, MessagingInboxEntry, MessagingInboxPage, MessagingInviteResult, MessagingMessage, MessagingMessageReceipt, MessagingParticipant, MessagingParticipantInput, MessagingReadResult, MessagingRecalledMessage, MessagingReceiptToken, MessagingRecipientIdentity, MessagingSendResult, MessagingUnavailableMessage, NameConflictPolicy, NotificationBulkMarkState, NotificationInboxState, NotificationMarkState, NotificationRow, NotificationSender, NotifyCategory, NotifyChannel, NotifyConfig, NotifyConfigCategory, NotifyConfigDelivery, NotifyConfigDeliveryPatch, NotifyConfigDestinations, NotifyConfigDestinationsPatch, NotifyConfigEvents, NotifyConfigEventsRead, NotifyConfigHistory, NotifyConfigOverrides, NotifyConfigPatch, NotifyConfigRealtimeFallbackDelay, NotifyConfigRefusalReason, NotifyConfigReliability, NotifyConfigResponse, NotifyConfigSecurity, NotifyDeliveryMode, NotifyDestinationFailureReason, NotifyDestinationKind, NotifyDestinationReason, NotifyDestinationSkipReason, NotifyDestinationState, NotifyDestinationTestReason, NotifyDestinationTestResult, NotifyDestinationTransportReason, NotifyEscalation, NotifyInboxBulkMarkState, NotifyInboxMarkState, NotifyInboxRow, NotifyInboxView, NotifyIngotRef, NotifyInteraction, NotifyPreset, NotifyPresetCategory, NotifyPresetName, NotifyPresetSendOptions, NotifyProject, NotifyProjectBilling, NotifyProjectStatus, NotifyProjectSubscriptionPreview, NotifyProjectSubscriptionResponse, NotifyProjectUsage, NotifyRecallMode, NotifyReceipt, NotifyReceiptEventType, NotifyRecipient, NotifyRecipientRef, NotifyRecipientState, NotifyReportableVerificationLevel, NotifySendContent, NotifySendPolicy, NotifySendReceipt, NotifySendReceiptsResponse, NotifySendResult, NotifySendState, NotifySendStatus, NotifySendStatusCounts, NotifySendStatusDestination, NotifySendStatusRecipient, NotifySendSummary, NotifySendSummaryDestination, NotifySlackDestination, NotifySlackDestinationRead, NotifySuppressionReason, NotifyTeamsDestination, NotifyTeamsDestinationRead, NotifyVerificationLevel, NotifyWebhookDestination, NotifyWebhookDestinationRead, PatchStructuredIngotOptions, PortableStructuredIngot, PortableStructuredType, PreviewNotifyProjectSubscriptionOptions, PublishStructuredTypeOptions, QuotaResource, ReadMessagingConversationOptions, RecallNotifySendOptions, RecallNotifySendResponse, RegisterWebPushResponse, ReplaceIngotOptions, RestoreStructuredIngotOptions, ResumeUploadOptions, ScheduledVaultDeletion, SearchIngotsOptions, SendMessagingMessageOptions, SendUploadOptions, ShareSparkOptions, SignInOptions, SignInResult, SigninIdentityType, Spark, SparkInviteResend, SparkLinkActionOptions, SparkPage, SparkShare, SparkSummary, SparkVaultConfig, SparkVisibility, StartedVaultDeletion, StructuredAccountActivity, StructuredActivity, StructuredActivityOptions, StructuredActivityPeriod, StructuredActivityTotals, StructuredActivityTotalsWire, StructuredActivityWire, StructuredBinaryPath, StructuredExportOutcome, StructuredImportOutcome, StructuredIngot, StructuredIngotHistory, StructuredIngotMutation, StructuredIngotPrecondition, StructuredIngotSummary, StructuredIngotSummaryWire, StructuredIngotVersion, StructuredIngotWire, StructuredIterateOptions, StructuredJsonValue, StructuredMutationWire, StructuredOutcome, StructuredPage, StructuredPageOptions, StructuredPageWire, StructuredReadOutcome, StructuredTypeCreation, StructuredTypeDefinition, StructuredTypeDefinitionWire, StructuredTypePin, StructuredTypePinWire, StructuredTypeSummary, StructuredTypeSummaryWire, StructuredTypeTransform, StructuredValues, StructuredVaultActivity, SubscribeNotifyProjectOptions, SubscribeWebPushOptions, SubscribeWebPushResult, SubscribeWebPushStatus, TokenClaims, UnreachedAdmin, UnreadCountResponse, UnsealVaultOptions, UnsealedVault, UnsubscribeWebPushResponse, UpdateFolderOptions, UpdateIngotSharingOptions, UpdateNotifyProjectOptions, UpdateVaultUploadOptions, UpdatedVault, UploadAttachOptions, UploadBranding, UploadEnd, UploadIngotOptions, UploadOptions, UploadProgress, UploadResult, UploadSession, Vault, VaultDetail, VaultLifecycle, VaultResealDefaults, VaultResealSettings, VaultResealSettingsResult, VaultSessionExtension, VaultSessionTiming, VaultSharingConfig, VaultSharingOptions, VaultSummary, VaultUploadConfig, VaultUploadSettings, VerifyOptions, VerifyResult, WebPushKeyResponse, WebPushStatus, WebPushStatusOptions, WebPushStatusResult, WebPushSubscriptionInput };
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;
@@ -22086,7 +22086,10 @@ function companySignInUrl(value) {
22086
22086
  function mountHelpDeskForm(client, options) {
22087
22087
  const target = resolveTarget(options.target);
22088
22088
  injectHelpDeskFormStyles();
22089
- const widget = options.widgetIdentity;
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;
22090
22093
  const shell = new InlineShell(target, {
22091
22094
  containerClassName: 'svhd-container',
22092
22095
  bodyClassName: 'svhd-body',
@@ -22389,6 +22392,7 @@ function mountHelpDeskForm(client, options) {
22389
22392
  let websiteSignedOut = false;
22390
22393
  // The form is held while the secure window chooses another account: no send is under way.
22391
22394
  let switchingAccount = false;
22395
+ let portalRequired = oauth;
22392
22396
  /**
22393
22397
  * Save the request as the form holds it. Never while a sign-in is under
22394
22398
  * way: a session notification then blanks the fields until the sign-in's
@@ -22521,7 +22525,7 @@ function mountHelpDeskForm(client, options) {
22521
22525
  */
22522
22526
  function renderActions() {
22523
22527
  send.textContent = idleLabel();
22524
- send.hidden = recovery === 'external_sso' && widget !== undefined && !widget.useWebsiteAccount;
22528
+ send.hidden = portalRequired || (recovery === 'external_sso' && widget !== undefined && !widget.useWebsiteAccount);
22525
22529
  startNew.hidden = recovery === null;
22526
22530
  widgetAccount.hidden = recovery !== null || widgetAccount.childElementCount === 0;
22527
22531
  recap.hidden = recovery !== null;
@@ -22554,7 +22558,7 @@ function mountHelpDeskForm(client, options) {
22554
22558
  function setStep(next) {
22555
22559
  const changed = next !== step;
22556
22560
  step = next;
22557
- details.hidden = next !== 'details';
22561
+ details.hidden = next !== 'details' || (portalRequired && !subject.input.value && !description.input.value);
22558
22562
  if (identity)
22559
22563
  identity.hidden = next !== 'identity';
22560
22564
  if (next === 'identity') {
@@ -22634,13 +22638,13 @@ function mountHelpDeskForm(client, options) {
22634
22638
  function disable(disabled) {
22635
22639
  for (const input of [subject.input, description.input, email.input, code.input, name.input, send, cancel, changeEmail, editRequest, startNew])
22636
22640
  input.disabled = disabled;
22637
- const held = uncertainSubmission !== null || recovery !== null;
22641
+ const held = uncertainSubmission !== null || recovery !== null || portalRequired;
22638
22642
  subject.input.readOnly = held;
22639
22643
  description.input.readOnly = held;
22640
22644
  for (const button of widgetAccount.querySelectorAll('button'))
22641
22645
  button.disabled = disabled || uncertainSubmission !== null || completed;
22642
22646
  renderResend();
22643
- composer.disablePicking(disabled || recovery !== null);
22647
+ composer.disablePicking(disabled || recovery !== null || portalRequired);
22644
22648
  composer.lock(completed || uncertainSubmission !== null);
22645
22649
  }
22646
22650
  function clearCode() {
@@ -22880,7 +22884,7 @@ function mountHelpDeskForm(client, options) {
22880
22884
  pending = false;
22881
22885
  switchingAccount = false;
22882
22886
  sessionKnown = false;
22883
- if (options.widgetIdentity)
22887
+ if (widget)
22884
22888
  widgetCustomer = null;
22885
22889
  clearComposer();
22886
22890
  recovery = hidden;
@@ -22893,6 +22897,8 @@ function mountHelpDeskForm(client, options) {
22893
22897
  message('Your sign-in changed. Start a new request for the current account.');
22894
22898
  else
22895
22899
  renderActions();
22900
+ if (oauth)
22901
+ showHosted();
22896
22902
  // The request and its actions changed under the pointer: a press already
22897
22903
  // under way must not act on what replaced them.
22898
22904
  options.onScreenChange?.();
@@ -22946,6 +22952,26 @@ function mountHelpDeskForm(client, options) {
22946
22952
  focusAfter = challenge ? code.input : email.input;
22947
22953
  }
22948
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
+ }
22949
22975
  if (client.desk.auth_mode === 'external_sso' || client.desk.auth_mode === 'external_unavailable') {
22950
22976
  const url = companySignInUrl(client.desk.external_identity?.sign_in_url);
22951
22977
  hosted.hidden = url === null;
@@ -22963,6 +22989,11 @@ function mountHelpDeskForm(client, options) {
22963
22989
  async function submit() {
22964
22990
  if (pending || completed || destroyed)
22965
22991
  return;
22992
+ if (portalRequired) {
22993
+ showHosted();
22994
+ focusSettled();
22995
+ return;
22996
+ }
22966
22997
  // Sending (Enter in a field, a code's last digit) answers the discard
22967
22998
  // question: the customer kept going.
22968
22999
  closeConfirm(false);
@@ -23034,7 +23065,7 @@ function mountHelpDeskForm(client, options) {
23034
23065
  let token = await tokenFor(ownGeneration);
23035
23066
  if (!alive(ownGeneration))
23036
23067
  return;
23037
- 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')) {
23038
23069
  authenticating = true;
23039
23070
  authNotification = false;
23040
23071
  const session = await (widgetSignIn ?? options.onAuthRequired());
@@ -23459,6 +23490,8 @@ function mountHelpDeskForm(client, options) {
23459
23490
  description.input.value = composition.body;
23460
23491
  persistDraft();
23461
23492
  syncLeaveGuard();
23493
+ if (portalRequired && !pending)
23494
+ showHosted();
23462
23495
  },
23463
23496
  refill(issue) {
23464
23497
  if (destroyed || restoredDraft || recovery !== null || safeComposition() === null)
@@ -23477,11 +23510,17 @@ function mountHelpDeskForm(client, options) {
23477
23510
  recapText.textContent = subject.input.value.trim();
23478
23511
  persistDraft();
23479
23512
  syncLeaveGuard();
23513
+ if (portalRequired && !pending)
23514
+ showHosted();
23480
23515
  return true;
23481
23516
  },
23482
23517
  resumeAfterAccess() {
23483
- if (!destroyed && !pending && !completed && uncertainSubmission === null)
23484
- message('');
23518
+ if (!destroyed && !pending && !completed && uncertainSubmission === null) {
23519
+ if (portalRequired)
23520
+ showHosted();
23521
+ else
23522
+ message('');
23523
+ }
23485
23524
  },
23486
23525
  returnToRequest() {
23487
23526
  if (destroyed || step !== 'identity')
@@ -23494,6 +23533,10 @@ function mountHelpDeskForm(client, options) {
23494
23533
  focusEntry(focusOptions) {
23495
23534
  if (destroyed || form.hidden)
23496
23535
  return false;
23536
+ if (portalRequired && !hosted.hidden) {
23537
+ hosted.focus(focusOptions);
23538
+ return true;
23539
+ }
23497
23540
  if (step === 'identity' && signInStep) {
23498
23541
  (send.disabled ? signInStep.heading : send).focus(focusOptions);
23499
23542
  return true;
@@ -23545,8 +23588,8 @@ function mountHelpDeskForm(client, options) {
23545
23588
  });
23546
23589
  send.textContent = idleLabel();
23547
23590
  renderWidgetIdentity();
23548
- if (options.widgetIdentity?.customer) {
23549
- restoreDraft(options.widgetIdentity.customer);
23591
+ if (widget?.customer) {
23592
+ restoreDraft(widget.customer);
23550
23593
  disable(false);
23551
23594
  }
23552
23595
  else if (widget?.recovering) {
@@ -23576,9 +23619,42 @@ function mountHelpDeskForm(client, options) {
23576
23619
  live.announce('Step 1 of 2');
23577
23620
  syncLeaveGuard();
23578
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
+ }
23579
23655
  // Native company identity starts as the form opens, never from a Connect,
23580
23656
  // Allow, verification or submit gesture. Guest email is explicit desk policy.
23581
- if (!options.widgetIdentity && ((client.desk.auth_mode === 'external_sso' && client.hasIdentityProvider) || client.desk.auth_mode === 'external_unavailable')) {
23657
+ if (!widget && ((client.desk.auth_mode === 'external_sso' && client.hasIdentityProvider) || client.desk.auth_mode === 'external_unavailable')) {
23582
23658
  const ownGeneration = generation;
23583
23659
  nativeProofGeneration = ownGeneration;
23584
23660
  pending = true;
@@ -25218,6 +25294,7 @@ const currentVisitor = (value) => value !== null && typeof value === 'object' &&
25218
25294
  'visitor_id' in value && validVisitorId(value.visitor_id) &&
25219
25295
  'expires_at' in value && typeof value.expires_at === 'number' && Number.isSafeInteger(value.expires_at) &&
25220
25296
  value.expires_at * 1000 > Date.now() + 60000 && value.expires_at * 1000 <= Date.now() + 31 * 86400000;
25297
+ let viewSequence = 0;
25221
25298
  const invalid = () => new SparkVaultError('The help center returned an invalid answer. Try again.', 'KB_INVALID_RESPONSE');
25222
25299
  const changed = () => new SparkVaultError('The help center changed. Search again to see current answers.', 'KB_PUBLICATION_CHANGED', 409);
25223
25300
  const validPath = (value) => typeof value === 'string' && value.startsWith('/') && !value.startsWith('//') &&
@@ -25423,10 +25500,12 @@ class HelpDeskKnowledgeBaseClient {
25423
25500
  if (settings.enabled && validVisitorCookieName(settings.cookie_name)) {
25424
25501
  if (cookieEndpoint) {
25425
25502
  const endpoint = ownOrigin ? '/_sv/visitor' : new URL('/_sv/visitor', config.canonical_origin).href;
25426
- const response = await fetch(endpoint, { credentials: ownOrigin ? 'same-origin' : 'include', cache: 'no-store' });
25427
- if (!response.ok)
25428
- throw invalid();
25429
- const answer = await response.json();
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
+ });
25430
25509
  candidate = answer.visitor_id;
25431
25510
  }
25432
25511
  else {
@@ -25459,8 +25538,8 @@ class HelpDeskKnowledgeBaseClient {
25459
25538
  }
25460
25539
  /** Use the help center's browser visitor and vote receipt; ticket identity is never sent. */
25461
25540
  async vote(article, vote) {
25462
- if (article?.kind !== 'article' || typeof article.id !== 'string' || !article.id || article.id.length > 256 || !['yes', 'no'].includes(vote)) {
25463
- throw new ValidationError('Choose yes or no for a published article.');
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.');
25464
25543
  }
25465
25544
  const reference = { id: article.id, release_id: article.release_id };
25466
25545
  const previous = this.voteQueues.get(reference.id) ?? Promise.resolve();
@@ -25521,6 +25600,29 @@ class HelpDeskKnowledgeBaseClient {
25521
25600
  this.readerDocument = { ...value, body_html };
25522
25601
  return this.readerDocument;
25523
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
+ }
25524
25626
  /** Paint article text first; hydrate only approved media without replacing the reader DOM. */
25525
25627
  hydrateAssets(document, callbacks) {
25526
25628
  if (this.destroyed || this.readerDocument?.id !== document.id || this.readerDocument.release_id !== document.release_id)
@@ -26565,7 +26667,7 @@ class SupportView {
26565
26667
  this.sourceArticle.textContent = next.sourceArticle ? `Article you read: ${next.sourceArticle.title}` : '';
26566
26668
  this.sourceArticle.hidden = !next.sourceArticle;
26567
26669
  this.contactTitle.parentElement.hidden = this.contactTitle.hidden && this.contactStatus.hidden && this.contactError.hidden && this.sourceArticle.hidden;
26568
- this.feedbackStatus.textContent = next.feedbackBusy ? 'Saving your feedback...' : next.feedbackError ? '' : next.article?.kind === 'faq' ? 'We are glad that helped.' : 'Your feedback has been saved.';
26670
+ this.feedbackStatus.textContent = next.feedbackBusy ? 'Saving your feedback...' : next.feedbackError ? '' : 'Your feedback has been saved.';
26569
26671
  this.feedbackError.textContent = next.feedbackError || '';
26570
26672
  this.feedbackError.hidden = !next.feedbackError;
26571
26673
  this.retryFeedback.hidden = !next.feedbackError || !this.actions.onRetryFeedback;
@@ -27215,6 +27317,7 @@ function createHelpDeskSupport(config, options) {
27215
27317
  let attempt = null;
27216
27318
  let results = [];
27217
27319
  let requestedArticle = null;
27320
+ let displayedArticle = null;
27218
27321
  let articleRetrySearch = false;
27219
27322
  let cancelArticleAssets = null;
27220
27323
  let stopSession = null;
@@ -27315,6 +27418,12 @@ function createHelpDeskSupport(config, options) {
27315
27418
  const rebranded = change.brand !== undefined && change.brand !== state.brand;
27316
27419
  state = { ...state, ...change };
27317
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
+ }
27318
27427
  launcher?.setExpanded(state.visible);
27319
27428
  if (rebranded)
27320
27429
  launcher?.setBrand(state.brand);
@@ -27417,8 +27526,8 @@ function createHelpDeskSupport(config, options) {
27417
27526
  return;
27418
27527
  const ownFeedback = ++feedbackSequence;
27419
27528
  void attempt?.then((active) => active?.solved());
27420
- update({ stage: 'resolved', feedbackBusy: article.kind === 'article', feedbackError: undefined, reviewUrl: undefined, error: undefined });
27421
- if (article.kind !== 'article' || !kb)
27529
+ update({ stage: 'resolved', feedbackBusy: Boolean(kb), feedbackError: undefined, reviewUrl: undefined, error: undefined });
27530
+ if (!kb)
27422
27531
  return;
27423
27532
  try {
27424
27533
  const saved = await kb.vote(article, 'yes');
@@ -27849,8 +27958,8 @@ function createHelpDeskSupport(config, options) {
27849
27958
  sourceArticleId = article.id;
27850
27959
  update({ sourceArticle: { title: article.title, url: article.canonical_url } });
27851
27960
  // The article vote and assistance outcome serve different reports. Neither may block contacting the team.
27852
- if (article.kind === 'article' && kb)
27853
- void kb.vote(article, 'no').catch(() => undefined);
27961
+ if (kb)
27962
+ void kb.vote(article, 'no').catch((value) => notify(options.onError, failure(value)));
27854
27963
  }
27855
27964
  followIssue();
27856
27965
  cancelArticleAssets?.();
@@ -28202,7 +28311,8 @@ class HelpDeskModule {
28202
28311
  /**
28203
28312
  * Inject a ticket form, including email-code verification where the desk
28204
28313
  * enables it. A custom onAuthRequired callback may supply a server-issued
28205
- * help desk session. Destroy the returned handle on unmount/account change.
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.
28206
28316
  */
28207
28317
  mountForm(options) {
28208
28318
  return this.connectForm(options, (client) => mountHelpDeskForm(client, options));
@@ -32952,7 +33062,7 @@ class SparkVault {
32952
33062
  }
32953
33063
  /** Get the SDK version */
32954
33064
  static get version() {
32955
- return '18.0.5';
33065
+ return '18.0.6';
32956
33066
  }
32957
33067
  }
32958
33068
  if (typeof window !== 'undefined') {