@ada-support/embed2 1.14.15 → 1.14.16
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AdaCluster } from "common/types";
|
|
2
2
|
export interface MessagingAuthState {
|
|
3
|
+
ownerChatterToken?: string;
|
|
3
4
|
messagingToken: string;
|
|
4
5
|
messagingTokenExpiresAt: number;
|
|
5
6
|
sessionRefreshToken: string;
|
|
@@ -13,10 +14,12 @@ export declare function buildMessagingAuthStateStorageKey({ handle, cluster, dom
|
|
|
13
14
|
domain?: string;
|
|
14
15
|
}): typeof MESSAGING_AUTH_STATE_STORAGE_KEY | null;
|
|
15
16
|
export declare function parseMessagingAuthState(value: unknown): MessagingAuthState | null;
|
|
16
|
-
export declare function
|
|
17
|
+
export declare function bindMessagingAuthStateToChatter(state: MessagingAuthState, chatterToken: string): MessagingAuthState | null;
|
|
18
|
+
export declare function readMessagingAuthStateFromStorage({ handle, cluster, domain, chatterToken, }: {
|
|
17
19
|
handle: string | null | undefined;
|
|
18
20
|
cluster?: AdaCluster;
|
|
19
21
|
domain?: string;
|
|
22
|
+
chatterToken: string | null | undefined;
|
|
20
23
|
}): MessagingAuthState | undefined;
|
|
21
24
|
export declare function writeMessagingAuthStateToStorage({ handle, cluster, domain, persistence, state, }: {
|
|
22
25
|
handle: string | null | undefined;
|
|
@@ -26,9 +29,10 @@ export declare function writeMessagingAuthStateToStorage({ handle, cluster, doma
|
|
|
26
29
|
state: MessagingAuthState | null | undefined;
|
|
27
30
|
}): boolean;
|
|
28
31
|
export declare function clearAllMessagingAuthStatesFromStorage(): void;
|
|
29
|
-
export declare function clearMessagingAuthStateFromStorage({ handle, cluster, domain, }: {
|
|
32
|
+
export declare function clearMessagingAuthStateFromStorage({ handle, cluster, domain, expectedChatterToken, }: {
|
|
30
33
|
handle: string | null | undefined;
|
|
31
34
|
cluster?: AdaCluster;
|
|
32
35
|
domain?: string;
|
|
36
|
+
expectedChatterToken?: string;
|
|
33
37
|
}): void;
|
|
34
38
|
export {};
|
package/dist/npm-entry/index.js
CHANGED
|
@@ -16125,7 +16125,7 @@ const client = new BrowserClient({
|
|
|
16125
16125
|
return event;
|
|
16126
16126
|
},
|
|
16127
16127
|
environment: "production",
|
|
16128
|
-
release: "1.14.
|
|
16128
|
+
release: "1.14.16-3d56f98",
|
|
16129
16129
|
sampleRate: 0.25,
|
|
16130
16130
|
autoSessionTracking: false,
|
|
16131
16131
|
// Integrations don't seem to work with Sentry: https://github.com/getsentry/sentry-javascript/issues/2541
|
|
@@ -16751,7 +16751,7 @@ function getEmbedURL(_ref) {
|
|
|
16751
16751
|
} else {
|
|
16752
16752
|
host = `http://${handle}.localhost:${ports.localhost.default}`;
|
|
16753
16753
|
}
|
|
16754
|
-
return `${host}/embed/${frameName}/${"
|
|
16754
|
+
return `${host}/embed/${frameName}/${"3d56f98"}/index.html`;
|
|
16755
16755
|
}
|
|
16756
16756
|
function constructQueryString(query) {
|
|
16757
16757
|
return Object.keys(query).map(key => {
|
|
@@ -17248,6 +17248,9 @@ const ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY = "ada-embed_zd-messaging-chatter
|
|
|
17248
17248
|
const CHATTER_STORAGE_KEY = (/* unused pure expression or super */ null && (CHATTER_TOKEN_STORAGE_KEY));
|
|
17249
17249
|
;// ./src/common/helpers/messaging-auth-state.ts
|
|
17250
17250
|
|
|
17251
|
+
function messaging_auth_state_ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17252
|
+
function messaging_auth_state_objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? messaging_auth_state_ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : messaging_auth_state_ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17253
|
+
|
|
17251
17254
|
|
|
17252
17255
|
// Single static key, shared verbatim with messaging + chat and disclosed by
|
|
17253
17256
|
// @ada-support/web-storage. Per-bot scoping is implicit in the bot-subdomain
|
|
@@ -17256,6 +17259,20 @@ const MESSAGING_AUTH_STATE_STORAGE_KEY = "messagingAuthState";
|
|
|
17256
17259
|
function isRecord(value) {
|
|
17257
17260
|
return typeof value === "object" && value !== null;
|
|
17258
17261
|
}
|
|
17262
|
+
function readMessagingTokenSubject(token) {
|
|
17263
|
+
const payload = token.split(".")[1];
|
|
17264
|
+
if (!payload || typeof globalThis.atob !== "function") {
|
|
17265
|
+
return null;
|
|
17266
|
+
}
|
|
17267
|
+
try {
|
|
17268
|
+
const normalized = payload.replace(/-/g, "+").replace(/_/g, "/");
|
|
17269
|
+
const padded = normalized.padEnd(normalized.length + (4 - normalized.length % 4) % 4, "=");
|
|
17270
|
+
const claims = JSON.parse(globalThis.atob(padded));
|
|
17271
|
+
return typeof claims.sub === "string" && claims.sub ? claims.sub : null;
|
|
17272
|
+
} catch (error) {
|
|
17273
|
+
return null;
|
|
17274
|
+
}
|
|
17275
|
+
}
|
|
17259
17276
|
|
|
17260
17277
|
// Typed @ada-support/web-storage wrapper for the chosen persistence provider, or
|
|
17261
17278
|
// null when persistence is disabled / there is no window. The wrapper is what
|
|
@@ -17315,20 +17332,28 @@ function parseMessagingAuthState(value) {
|
|
|
17315
17332
|
return null;
|
|
17316
17333
|
}
|
|
17317
17334
|
const {
|
|
17335
|
+
ownerChatterToken,
|
|
17318
17336
|
messagingToken,
|
|
17319
17337
|
messagingTokenExpiresAt,
|
|
17320
17338
|
sessionRefreshToken,
|
|
17321
17339
|
refreshGeneration
|
|
17322
17340
|
} = parsedValue;
|
|
17323
|
-
if (typeof messagingToken !== "string" || !messagingToken || typeof messagingTokenExpiresAt !== "number" || !Number.isFinite(messagingTokenExpiresAt) || messagingTokenExpiresAt <= 0 || typeof sessionRefreshToken !== "string" || !sessionRefreshToken || typeof refreshGeneration !== "number" || !Number.
|
|
17341
|
+
if (ownerChatterToken !== undefined && (typeof ownerChatterToken !== "string" || !ownerChatterToken) || typeof messagingToken !== "string" || !messagingToken || typeof messagingTokenExpiresAt !== "number" || !Number.isFinite(messagingTokenExpiresAt) || messagingTokenExpiresAt <= 0 || typeof sessionRefreshToken !== "string" || !sessionRefreshToken || typeof refreshGeneration !== "number" || !Number.isInteger(refreshGeneration) || refreshGeneration < 1) {
|
|
17324
17342
|
return null;
|
|
17325
17343
|
}
|
|
17326
|
-
return {
|
|
17344
|
+
return messaging_auth_state_objectSpread(messaging_auth_state_objectSpread({}, typeof ownerChatterToken === "string" ? {
|
|
17345
|
+
ownerChatterToken
|
|
17346
|
+
} : {}), {}, {
|
|
17327
17347
|
messagingToken,
|
|
17328
17348
|
messagingTokenExpiresAt,
|
|
17329
17349
|
sessionRefreshToken,
|
|
17330
17350
|
refreshGeneration
|
|
17331
|
-
};
|
|
17351
|
+
});
|
|
17352
|
+
}
|
|
17353
|
+
function bindMessagingAuthStateToChatter(state, chatterToken) {
|
|
17354
|
+
return (!state.ownerChatterToken || state.ownerChatterToken === chatterToken) && readMessagingTokenSubject(state.messagingToken) === chatterToken ? messaging_auth_state_objectSpread(messaging_auth_state_objectSpread({}, state), {}, {
|
|
17355
|
+
ownerChatterToken: chatterToken
|
|
17356
|
+
}) : null;
|
|
17332
17357
|
}
|
|
17333
17358
|
|
|
17334
17359
|
// Storage-blocked browsers can throw on the storage methods, so each access is
|
|
@@ -17341,21 +17366,32 @@ function safeReadMessagingAuthState(persistence) {
|
|
|
17341
17366
|
return null;
|
|
17342
17367
|
}
|
|
17343
17368
|
}
|
|
17369
|
+
function readHighestMessagingAuthStateForChatter(chatterToken) {
|
|
17370
|
+
return ["normal", "session"].map(persistence => safeReadMessagingAuthState(persistence)).map(candidate => candidate ? bindMessagingAuthStateToChatter(candidate, chatterToken) : null).reduce((highestState, candidate) => candidate && (!highestState || candidate.refreshGeneration > highestState.refreshGeneration) ? candidate : highestState, null);
|
|
17371
|
+
}
|
|
17372
|
+
|
|
17373
|
+
// The read is owner-bound: without a current chatter token, or when no persisted
|
|
17374
|
+
// blob binds to it, there is no state this chatter may reuse. Binding both
|
|
17375
|
+
// providers before the highest-generation reduce stops a stale higher-generation
|
|
17376
|
+
// blob left by a previous chatter from being paired with the active session.
|
|
17344
17377
|
function readMessagingAuthStateFromStorage(_ref3) {
|
|
17345
17378
|
let {
|
|
17346
17379
|
handle,
|
|
17347
17380
|
cluster,
|
|
17348
|
-
domain
|
|
17381
|
+
domain,
|
|
17382
|
+
chatterToken
|
|
17349
17383
|
} = _ref3;
|
|
17350
17384
|
if (!buildMessagingAuthStateStorageKey({
|
|
17351
17385
|
handle,
|
|
17352
17386
|
cluster,
|
|
17353
17387
|
domain
|
|
17354
|
-
})) {
|
|
17388
|
+
}) || !chatterToken) {
|
|
17355
17389
|
return undefined;
|
|
17356
17390
|
}
|
|
17357
|
-
|
|
17358
|
-
|
|
17391
|
+
return readHighestMessagingAuthStateForChatter(chatterToken) ?? undefined;
|
|
17392
|
+
}
|
|
17393
|
+
function shouldPreserveExistingAuthState(existing, candidate, targetIsVerifiedOwnerless) {
|
|
17394
|
+
return Boolean(existing && (existing.refreshGeneration > candidate.refreshGeneration || existing.refreshGeneration === candidate.refreshGeneration && !targetIsVerifiedOwnerless));
|
|
17359
17395
|
}
|
|
17360
17396
|
function writeMessagingAuthStateToStorage(_ref4) {
|
|
17361
17397
|
let {
|
|
@@ -17375,15 +17411,21 @@ function writeMessagingAuthStateToStorage(_ref4) {
|
|
|
17375
17411
|
return false;
|
|
17376
17412
|
}
|
|
17377
17413
|
try {
|
|
17378
|
-
const
|
|
17379
|
-
|
|
17380
|
-
|
|
17381
|
-
|
|
17382
|
-
|
|
17383
|
-
|
|
17414
|
+
const {
|
|
17415
|
+
ownerChatterToken
|
|
17416
|
+
} = state;
|
|
17417
|
+
const boundState = ownerChatterToken ? bindMessagingAuthStateToChatter(state, ownerChatterToken) : null;
|
|
17418
|
+
if (!boundState) {
|
|
17419
|
+
return false;
|
|
17420
|
+
}
|
|
17421
|
+
const comparableExisting = readHighestMessagingAuthStateForChatter(ownerChatterToken);
|
|
17422
|
+
const targetExisting = safeReadMessagingAuthState(persistence);
|
|
17423
|
+
const targetExistingForChatter = targetExisting ? bindMessagingAuthStateToChatter(targetExisting, ownerChatterToken) : null;
|
|
17424
|
+
const targetIsVerifiedOwnerless = Boolean(targetExistingForChatter && !(targetExisting !== null && targetExisting !== void 0 && targetExisting.ownerChatterToken));
|
|
17425
|
+
if (shouldPreserveExistingAuthState(comparableExisting, boundState, targetIsVerifiedOwnerless)) {
|
|
17384
17426
|
return false;
|
|
17385
17427
|
}
|
|
17386
|
-
storage.setItem(storageKey,
|
|
17428
|
+
storage.setItem(storageKey, boundState);
|
|
17387
17429
|
return true;
|
|
17388
17430
|
} catch (error) {
|
|
17389
17431
|
return false;
|
|
@@ -17400,15 +17442,17 @@ function clearAllMessagingAuthStatesFromStorage() {
|
|
|
17400
17442
|
});
|
|
17401
17443
|
}
|
|
17402
17444
|
|
|
17403
|
-
// Removes the messaging auth state
|
|
17404
|
-
//
|
|
17405
|
-
//
|
|
17406
|
-
//
|
|
17445
|
+
// Removes the messaging auth state from both persistence providers. Used when a bot
|
|
17446
|
+
// rotates to a new chatter. When `expectedChatterToken` is supplied, a provider is
|
|
17447
|
+
// only cleared if its persisted state binds to that chatter; state that doesn't bind
|
|
17448
|
+
// (owned by another chatter, or ownerless with a non-matching token subject) is left
|
|
17449
|
+
// intact.
|
|
17407
17450
|
function clearMessagingAuthStateFromStorage(_ref5) {
|
|
17408
17451
|
let {
|
|
17409
17452
|
handle,
|
|
17410
17453
|
cluster,
|
|
17411
|
-
domain
|
|
17454
|
+
domain,
|
|
17455
|
+
expectedChatterToken
|
|
17412
17456
|
} = _ref5;
|
|
17413
17457
|
if (!buildMessagingAuthStateStorageKey({
|
|
17414
17458
|
handle,
|
|
@@ -17420,6 +17464,10 @@ function clearMessagingAuthStateFromStorage(_ref5) {
|
|
|
17420
17464
|
["normal", "session"].forEach(persistence => {
|
|
17421
17465
|
try {
|
|
17422
17466
|
var _getMessagingAuthStor3;
|
|
17467
|
+
const persistedState = safeReadMessagingAuthState(persistence);
|
|
17468
|
+
if (expectedChatterToken && (!persistedState || !bindMessagingAuthStateToChatter(persistedState, expectedChatterToken))) {
|
|
17469
|
+
return;
|
|
17470
|
+
}
|
|
17423
17471
|
(_getMessagingAuthStor3 = getMessagingAuthStorage(persistence)) === null || _getMessagingAuthStor3 === void 0 ? void 0 : _getMessagingAuthStor3.removeItem(MESSAGING_AUTH_STATE_STORAGE_KEY);
|
|
17424
17472
|
} catch (error) {
|
|
17425
17473
|
// Storage blocked; nothing to clear.
|
|
@@ -17435,64 +17483,68 @@ function clearMessagingAuthStateFromStorage(_ref5) {
|
|
|
17435
17483
|
function getValueFromStorage(key) {
|
|
17436
17484
|
return dist/* adaLocalStorage */.BB.getItem(key) || dist/* adaSessionStorage */.ad.getItem(key);
|
|
17437
17485
|
}
|
|
17438
|
-
const getInitialState = adaSettings =>
|
|
17439
|
-
|
|
17440
|
-
|
|
17441
|
-
|
|
17442
|
-
domain: undefined,
|
|
17443
|
-
cluster: undefined,
|
|
17444
|
-
language: undefined,
|
|
17445
|
-
greeting: undefined,
|
|
17446
|
-
crossWindowPersistence: true,
|
|
17447
|
-
headless: false,
|
|
17448
|
-
enableProgrammaticControl: false,
|
|
17449
|
-
hideMask: true,
|
|
17450
|
-
metaFields: {},
|
|
17451
|
-
sensitiveMetaFields: {},
|
|
17452
|
-
parentElement: undefined,
|
|
17453
|
-
isDrawerOpen: false,
|
|
17454
|
-
drawerHasBeenOpened: false,
|
|
17455
|
-
focusIsOnAda: false,
|
|
17456
|
-
enabledLanguages: ["en"],
|
|
17457
|
-
client: undefined,
|
|
17458
|
-
isIntroShown: false,
|
|
17459
|
-
wasIntroShown: false,
|
|
17460
|
-
isButtonShown: false,
|
|
17461
|
-
introDimensions: {},
|
|
17462
|
-
unreadMessageCount: 0,
|
|
17463
|
-
initialURL: undefined,
|
|
17464
|
-
privateMode: false,
|
|
17465
|
-
rolloutOverride: undefined,
|
|
17466
|
-
chatterToken: getValueFromStorage(CHATTER_TOKEN_STORAGE_KEY) || undefined,
|
|
17467
|
-
chatterCreated: getValueFromStorage(CHATTER_CREATED_STORAGE_KEY) || undefined,
|
|
17468
|
-
sessionToken: getValueFromStorage(SESSION_AUTH_TOKEN_STORAGE_KEY) || undefined,
|
|
17469
|
-
messagingAuthState: readMessagingAuthStateFromStorage({
|
|
17486
|
+
const getInitialState = adaSettings => {
|
|
17487
|
+
const chatterToken = getValueFromStorage(CHATTER_TOKEN_STORAGE_KEY) || undefined;
|
|
17488
|
+
return {
|
|
17489
|
+
adaSettings,
|
|
17470
17490
|
handle: adaSettings.handle,
|
|
17471
|
-
|
|
17472
|
-
domain:
|
|
17473
|
-
|
|
17474
|
-
|
|
17475
|
-
|
|
17476
|
-
|
|
17477
|
-
|
|
17478
|
-
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17486
|
-
|
|
17487
|
-
|
|
17488
|
-
|
|
17489
|
-
|
|
17490
|
-
|
|
17491
|
-
|
|
17492
|
-
|
|
17493
|
-
|
|
17494
|
-
|
|
17495
|
-
|
|
17491
|
+
styles: undefined,
|
|
17492
|
+
domain: undefined,
|
|
17493
|
+
cluster: undefined,
|
|
17494
|
+
language: undefined,
|
|
17495
|
+
greeting: undefined,
|
|
17496
|
+
crossWindowPersistence: true,
|
|
17497
|
+
headless: false,
|
|
17498
|
+
enableProgrammaticControl: false,
|
|
17499
|
+
hideMask: true,
|
|
17500
|
+
metaFields: {},
|
|
17501
|
+
sensitiveMetaFields: {},
|
|
17502
|
+
parentElement: undefined,
|
|
17503
|
+
isDrawerOpen: false,
|
|
17504
|
+
drawerHasBeenOpened: false,
|
|
17505
|
+
focusIsOnAda: false,
|
|
17506
|
+
enabledLanguages: ["en"],
|
|
17507
|
+
client: undefined,
|
|
17508
|
+
isIntroShown: false,
|
|
17509
|
+
wasIntroShown: false,
|
|
17510
|
+
isButtonShown: false,
|
|
17511
|
+
introDimensions: {},
|
|
17512
|
+
unreadMessageCount: 0,
|
|
17513
|
+
initialURL: undefined,
|
|
17514
|
+
privateMode: false,
|
|
17515
|
+
rolloutOverride: undefined,
|
|
17516
|
+
chatterToken,
|
|
17517
|
+
chatterCreated: getValueFromStorage(CHATTER_CREATED_STORAGE_KEY) || undefined,
|
|
17518
|
+
sessionToken: getValueFromStorage(SESSION_AUTH_TOKEN_STORAGE_KEY) || undefined,
|
|
17519
|
+
messagingAuthState: readMessagingAuthStateFromStorage({
|
|
17520
|
+
handle: adaSettings.handle,
|
|
17521
|
+
cluster: adaSettings.cluster,
|
|
17522
|
+
domain: adaSettings.domain,
|
|
17523
|
+
chatterToken
|
|
17524
|
+
}),
|
|
17525
|
+
zdSessionId: getValueFromStorage(ZD_SESSION_STORAGE_KEY) || undefined,
|
|
17526
|
+
zdPreviousTags: getValueFromStorage(ZD_PREVIOUS_TAGS_STORAGE_KEY) || undefined,
|
|
17527
|
+
zdMessagingExternalUserId: getValueFromStorage(ZD_MESSAGING_EXTERNAL_USER_ID_STORAGE_KEY) || null,
|
|
17528
|
+
zdMessagingChatterCreated: getValueFromStorage(ZD_MESSAGING_CHATTER_CREATED_STORAGE_KEY) || null,
|
|
17529
|
+
connections: {},
|
|
17530
|
+
appConnectionState: ConnectionState.Uninitiated,
|
|
17531
|
+
testMode: false,
|
|
17532
|
+
embedStyles: undefined,
|
|
17533
|
+
notificationsPermission: browserHasNotificationSupport ? Notification.permission : undefined,
|
|
17534
|
+
browserHasNotificationSupport: browserHasNotificationSupport,
|
|
17535
|
+
preload: false,
|
|
17536
|
+
chatDimensions: undefined,
|
|
17537
|
+
isChatWebsocketConnected: false,
|
|
17538
|
+
latestCampaignKey: undefined,
|
|
17539
|
+
hasChatOpenedAfterProactiveMessagesShown: false,
|
|
17540
|
+
chatterInLiveChat: false,
|
|
17541
|
+
wasCampaignShownButNowClosed: false,
|
|
17542
|
+
proactiveCampaignHadMessages: false,
|
|
17543
|
+
proactiveEngaged: false,
|
|
17544
|
+
deviceToken: null,
|
|
17545
|
+
showFallbackOnTimeout: true
|
|
17546
|
+
};
|
|
17547
|
+
};
|
|
17496
17548
|
// EXTERNAL MODULE: ./node_modules/lodash.memoize/index.js
|
|
17497
17549
|
var lodash_memoize = __webpack_require__(7654);
|
|
17498
17550
|
var lodash_memoize_default = /*#__PURE__*/__webpack_require__.n(lodash_memoize);
|
|
@@ -17539,9 +17591,9 @@ async function log(message, extra, options) {
|
|
|
17539
17591
|
service: "embed",
|
|
17540
17592
|
env: "production",
|
|
17541
17593
|
embedVersion: 2,
|
|
17542
|
-
version: "1.14.
|
|
17594
|
+
version: "1.14.16",
|
|
17543
17595
|
isNpm: true,
|
|
17544
|
-
commitHash: "
|
|
17596
|
+
commitHash: "3d56f98"
|
|
17545
17597
|
}))
|
|
17546
17598
|
});
|
|
17547
17599
|
}
|
|
@@ -20076,22 +20128,6 @@ function storeChatterEventDataInBrowser(client, payload) {
|
|
|
20076
20128
|
const {
|
|
20077
20129
|
persistence
|
|
20078
20130
|
} = client;
|
|
20079
|
-
|
|
20080
|
-
// A new chatter resets refreshGeneration back to 1, so the generation guard in
|
|
20081
|
-
// writeMessagingAuthStateToStorage would otherwise refuse to overwrite a previous
|
|
20082
|
-
// chatter's higher-generation (now-dead) auth state — leaving the host-page copy
|
|
20083
|
-
// stuck on a refresh token the backend has rotated away. Whenever the persisted
|
|
20084
|
-
// chatter token does not match the incoming one — including when it is absent or in
|
|
20085
|
-
// the other persistence provider, leaving the auth state orphaned — drop the stale
|
|
20086
|
-
// auth state first so the new chatter's credentials persist.
|
|
20087
|
-
const previousChatter = retrieveStorage(CHATTER_TOKEN_STORAGE_KEY, client, privateMode);
|
|
20088
|
-
if (previousChatter !== chatter) {
|
|
20089
|
-
clearMessagingAuthStateFromStorage({
|
|
20090
|
-
handle: client.handle,
|
|
20091
|
-
cluster,
|
|
20092
|
-
domain
|
|
20093
|
-
});
|
|
20094
|
-
}
|
|
20095
20131
|
setBrowserStorageItem(CHATTER_TOKEN_STORAGE_KEY, chatter, persistence);
|
|
20096
20132
|
setBrowserStorageItem(CHATTER_CREATED_STORAGE_KEY, created, persistence);
|
|
20097
20133
|
if (sessionToken) {
|
|
@@ -20104,23 +20140,22 @@ function storeChatterEventDataInBrowser(client, payload) {
|
|
|
20104
20140
|
// embed-2's cross-origin XHR trips CORS preflight (see common/helpers/http.ts) — so
|
|
20105
20141
|
// the chat iframe, not embed-2, is what sends `Bearer <messagingToken>`.
|
|
20106
20142
|
const parsedAuthState = parseMessagingAuthState(messagingAuthState);
|
|
20107
|
-
|
|
20143
|
+
const hasChatterToken = typeof chatter === "string" && chatter.length > 0;
|
|
20144
|
+
const boundAuthState = parsedAuthState && hasChatterToken ? bindMessagingAuthStateToChatter(parsedAuthState, chatter) : null;
|
|
20145
|
+
if (boundAuthState) {
|
|
20108
20146
|
writeMessagingAuthStateToStorage({
|
|
20109
20147
|
handle: client.handle,
|
|
20110
20148
|
cluster,
|
|
20111
20149
|
domain,
|
|
20112
20150
|
persistence,
|
|
20113
|
-
state:
|
|
20151
|
+
state: boundAuthState
|
|
20114
20152
|
});
|
|
20115
|
-
} else {
|
|
20116
|
-
// chat published no usable auth state for this chatter (e.g. it cleared a dead
|
|
20117
|
-
// refresh token on unrecoverable invalid_refresh_token). Drop the host-side copy so
|
|
20118
|
-
// a stale token can't be resurrected on reload — a null write would otherwise no-op
|
|
20119
|
-
// and leave it in place.
|
|
20153
|
+
} else if (hasChatterToken) {
|
|
20120
20154
|
clearMessagingAuthStateFromStorage({
|
|
20121
20155
|
handle: client.handle,
|
|
20122
20156
|
cluster,
|
|
20123
|
-
domain
|
|
20157
|
+
domain,
|
|
20158
|
+
expectedChatterToken: chatter
|
|
20124
20159
|
});
|
|
20125
20160
|
}
|
|
20126
20161
|
}
|
|
@@ -20350,7 +20385,7 @@ class ChatFrame extends d {
|
|
|
20350
20385
|
log("Chat frame mount", {
|
|
20351
20386
|
handle,
|
|
20352
20387
|
chatUrl: this.url,
|
|
20353
|
-
embedVersion: "
|
|
20388
|
+
embedVersion: "3d56f98".slice(0, 7),
|
|
20354
20389
|
embedSettings: adaSettings
|
|
20355
20390
|
});
|
|
20356
20391
|
|
|
@@ -20438,7 +20473,7 @@ class ChatFrame extends d {
|
|
|
20438
20473
|
const hostPageUrlParams = new URL(window.location.href).searchParams;
|
|
20439
20474
|
const smsToken = hostPageUrlParams.get("adaSMSToken");
|
|
20440
20475
|
const queryParams = {
|
|
20441
|
-
embedVersion: "
|
|
20476
|
+
embedVersion: "3d56f98".slice(0, 7),
|
|
20442
20477
|
greeting,
|
|
20443
20478
|
language,
|
|
20444
20479
|
skipGreeting,
|
|
@@ -22431,6 +22466,13 @@ class Container extends d {
|
|
|
22431
22466
|
return;
|
|
22432
22467
|
}
|
|
22433
22468
|
const chatterInLiveChat = retrieveStorage(IN_LIVE_CHAT_STORAGE_KEY, assignedClient, privateMode);
|
|
22469
|
+
|
|
22470
|
+
// Read the chatter token fresh here, not at the top of initialize(): a
|
|
22471
|
+
// CHATTER_EVENT can rotate the chatter during this method's awaits, and a
|
|
22472
|
+
// stale token would owner-mismatch and clobber the newly stored auth state.
|
|
22473
|
+
const {
|
|
22474
|
+
chatterToken
|
|
22475
|
+
} = this.props;
|
|
22434
22476
|
try {
|
|
22435
22477
|
await setGlobalState(Container_objectSpread(Container_objectSpread({
|
|
22436
22478
|
client: assignedClient,
|
|
@@ -22449,7 +22491,8 @@ class Container extends d {
|
|
|
22449
22491
|
messagingAuthState: readMessagingAuthStateFromStorage({
|
|
22450
22492
|
handle: assignedClient.handle,
|
|
22451
22493
|
cluster: cluster,
|
|
22452
|
-
domain
|
|
22494
|
+
domain,
|
|
22495
|
+
chatterToken
|
|
22453
22496
|
}),
|
|
22454
22497
|
chatterInLiveChat
|
|
22455
22498
|
}));
|