@aikaara/chat-sdk 0.8.2 → 0.8.4
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/MountTenant-BCjKRkD8.cjs +978 -0
- package/dist/MountTenant-CxO7hJgs.mjs +14978 -0
- package/dist/cdn/aikaara-chat.iife.js +62 -62
- package/dist/headless.cjs +1 -1
- package/dist/headless.d.ts +330 -4
- package/dist/headless.mjs +19 -16
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +330 -4
- package/dist/index.mjs +29 -26
- package/dist/ui.cjs +1 -1
- package/dist/ui.mjs +1 -1
- package/package.json +1 -1
- package/dist/MountTenant-DvmiAoZ_.cjs +0 -978
- package/dist/MountTenant-DzNgBTiU.mjs +0 -14736
package/dist/headless.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MountTenant-BCjKRkD8.cjs");class s extends e.EventEmitter{registration=null;pendingEdits=[];constructor(t){super(),this.setupListeners(t)}registerForm(t){this.registration=t;const i=this.pendingEdits.filter(r=>r.entity_type===t.entityType&&String(r.entity_id)===String(t.entityId));if(i.length>0){for(const r of i)t.onFieldUpdate(r.fields),this.emit("edit:applied",{entityType:r.entity_type,entityId:r.entity_id,fields:r.fields});this.pendingEdits=this.pendingEdits.filter(r=>!(r.entity_type===t.entityType&&String(r.entity_id)===String(t.entityId)))}}unregisterForm(t,i){this.registration?.entityType===t&&String(this.registration?.entityId)===String(i)&&(this.registration=null)}get currentForm(){return this.registration}pushFieldUpdates(t,i,r){this.registration&&this.registration.entityType===t&&String(this.registration.entityId)===String(i)?(this.registration.onFieldUpdate(r),this.emit("edit:applied",{entityType:t,entityId:i,fields:r})):(this.pendingEdits.push({action:"edit_entity",entity_type:t,entity_id:i,fields:r}),this.emit("edit:pending",{entityType:t,entityId:i,fields:r}))}async requestSave(){if(!this.registration)return{success:!1,error:"No form registered"};try{return await this.registration.onSave(),this.emit("save:success",{entityType:this.registration.entityType,entityId:this.registration.entityId}),{success:!0}}catch(t){const i=t instanceof Error?t.message:"Save failed";return this.emit("save:error",{entityType:this.registration.entityType,entityId:this.registration.entityId,error:i}),{success:!1,error:i}}}async requestTest(t){if(!this.registration?.onTest)return{success:!1,error:"Current form does not support testing"};try{return await this.registration.onTest(t),{success:!0}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Test failed"}}}setupListeners(t){t.on("action:edit_entity",i=>{this.pushFieldUpdates(i.entity_type,i.entity_id,i.fields)}),t.on("action:save_entity",i=>{this.requestSave()}),t.on("action:test_tool",i=>{this.emit("test:triggered",{toolId:i.tool_id,parameters:i.parameters}),this.requestTest(i.parameters)})}}exports.ActionCableClient=e.ActionCableClient;exports.AikaaraChatClient=e.AikaaraChatClient;exports.ApiClient=e.ApiClient;exports.ChannelSubscription=e.ChannelSubscription;exports.ConnectionManager=e.ConnectionManager;exports.ConversationManager=e.ConversationManager;exports.EventEmitter=e.EventEmitter;exports.MessageStore=e.MessageStore;exports.SessionAuthAdapter=e.SessionAuthAdapter;exports.SsoExchangeAdapter=e.SsoExchangeAdapter;exports.TiledeskTransport=e.TiledeskTransport;exports.TokenDiscoveryError=e.TokenDiscoveryError;exports.TokenDiscoveryReader=e.TokenDiscoveryReader;exports.clearPersistedConversationId=e.clearPersistedConversationId;exports.collectSsoCredentials=e.collectSsoCredentials;exports.createFetchUploadAdapter=e.createFetchUploadAdapter;exports.createPresigned3StepUploadAdapter=e.createPresigned3StepUploadAdapter;exports.createTiledeskHistoryAdapter=e.createTiledeskHistoryAdapter;exports.discoverToken=e.discoverToken;exports.extractTiledeskFileEnvelope=e.extractTiledeskFileEnvelope;exports.inferTiledeskRole=e.inferTiledeskRole;exports.isTiledeskSelfEcho=e.isTiledeskSelfEcho;exports.mountFromSlug=e.mountFromSlug;exports.mountTenantWidget=e.mount;exports.parseTiledeskTemplate=e.parseTiledeskTemplate;exports.FormBridge=s;
|
package/dist/headless.d.ts
CHANGED
|
@@ -223,7 +223,17 @@ export declare class ApiClient {
|
|
|
223
223
|
private apiKey?;
|
|
224
224
|
private authToken?;
|
|
225
225
|
protected userToken: string;
|
|
226
|
+
private refreshHook;
|
|
226
227
|
constructor(baseUrl: string, userToken: string, apiKey?: string, authToken?: string);
|
|
228
|
+
/**
|
|
229
|
+
* Install a refresh hook. When a request returns 401 the client invokes
|
|
230
|
+
* the hook, replaces its in-memory `authToken`, and retries exactly once.
|
|
231
|
+
*/
|
|
232
|
+
setAuthRefreshHook(hook: AuthRefreshHook | null): void;
|
|
233
|
+
/** Surface the current bearer (e.g. for upload adapters that share it). */
|
|
234
|
+
getAuthToken(): string | undefined;
|
|
235
|
+
/** Replace the bearer used by subsequent requests. */
|
|
236
|
+
setAuthToken(next: string | undefined): void;
|
|
227
237
|
createConversation(params: {
|
|
228
238
|
systemPromptId?: number;
|
|
229
239
|
channel?: string;
|
|
@@ -234,8 +244,17 @@ export declare class ApiClient {
|
|
|
234
244
|
getMessages(conversationId: string): Promise<Message[]>;
|
|
235
245
|
private mapMessage;
|
|
236
246
|
private request;
|
|
247
|
+
private fetchWithHeaders;
|
|
237
248
|
}
|
|
238
249
|
|
|
250
|
+
export declare type ApiPanelFieldFormat = 'text' | 'currency' | 'date' | 'number';
|
|
251
|
+
|
|
252
|
+
export declare type ApiPanelRefresh = 'load' | 'assistant' | 'interval' | '30s' | '5m' | 'manual';
|
|
253
|
+
|
|
254
|
+
export declare type ApiPanelRender = 'fields' | 'steps';
|
|
255
|
+
|
|
256
|
+
export declare type ApiPanelSource = 'api' | 'paste';
|
|
257
|
+
|
|
239
258
|
export declare interface AppContext {
|
|
240
259
|
/** Current page/route path in the host app (e.g., '/products/42') */
|
|
241
260
|
currentPage: string;
|
|
@@ -266,6 +285,30 @@ declare interface AppContext_2 {
|
|
|
266
285
|
custom?: Record<string, unknown>;
|
|
267
286
|
}
|
|
268
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Static page metadata written by the dashboard's App Layout tab.
|
|
290
|
+
* The hosted-shell renders top/bottom nav from this list; SDK code
|
|
291
|
+
* doesn't consume it.
|
|
292
|
+
*/
|
|
293
|
+
export declare interface AppPageDef {
|
|
294
|
+
id: string;
|
|
295
|
+
name: string;
|
|
296
|
+
/** Icon name from the shell's icon set (Chat, Sparkle, Book, …). */
|
|
297
|
+
icon?: string;
|
|
298
|
+
/** `"chat"` (default surface) or `"static"` (placeholder). */
|
|
299
|
+
kind?: 'chat' | 'static';
|
|
300
|
+
hint?: string;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Hook the API client uses to recover from a 401. Wired up by the higher
|
|
305
|
+
* level mount when `descriptor.sso.autoRefresh === true`: the discovered
|
|
306
|
+
* partner token is re-read, exchanged for a fresh chat JWT, and the
|
|
307
|
+
* `authToken` field below is updated in place so the retry sends the new
|
|
308
|
+
* bearer. Returning `null` (or throwing) lets the original 401 propagate.
|
|
309
|
+
*/
|
|
310
|
+
declare type AuthRefreshHook = () => Promise<string | null>;
|
|
311
|
+
|
|
269
312
|
export declare class ChannelSubscription {
|
|
270
313
|
readonly identifier: string;
|
|
271
314
|
private callbacks;
|
|
@@ -523,6 +566,16 @@ export declare class ConversationManager {
|
|
|
523
566
|
private saveToStorage;
|
|
524
567
|
}
|
|
525
568
|
|
|
569
|
+
export declare interface CookieSourceConfig {
|
|
570
|
+
/** Cookie name. */
|
|
571
|
+
name?: string;
|
|
572
|
+
/**
|
|
573
|
+
* Informational only. The browser enforces the actual domain scope; we
|
|
574
|
+
* surface this so dashboards can document intent.
|
|
575
|
+
*/
|
|
576
|
+
domain?: string;
|
|
577
|
+
}
|
|
578
|
+
|
|
526
579
|
declare interface CreateConversationResponse {
|
|
527
580
|
id: string;
|
|
528
581
|
status: string;
|
|
@@ -536,6 +589,23 @@ export declare function createTiledeskHistoryAdapter(config: TiledeskHistoryAdap
|
|
|
536
589
|
|
|
537
590
|
export declare type CredentialProviders = Record<string, () => string | Promise<string>>;
|
|
538
591
|
|
|
592
|
+
export declare interface DiscoveredToken {
|
|
593
|
+
/** The raw partner token. */
|
|
594
|
+
token: string;
|
|
595
|
+
/** Echoed so callers can log + alert when the source changes mid-flow. */
|
|
596
|
+
source: TokenSourceKind;
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Dispatcher. Resolves the partner token according to
|
|
601
|
+
* `descriptor.tokenSource`. Returns a Promise so async-only sources
|
|
602
|
+
* (`postmsg`, `global`) share the same surface as synchronous ones.
|
|
603
|
+
*
|
|
604
|
+
* Throws when the token can't be found — callers decide whether to
|
|
605
|
+
* fall back to a login screen (per `descriptor.fallback`).
|
|
606
|
+
*/
|
|
607
|
+
export declare function discoverToken(opts: TokenDiscoveryOptions): Promise<DiscoveredToken>;
|
|
608
|
+
|
|
539
609
|
export declare interface EditEntityAction {
|
|
540
610
|
action: 'edit_entity';
|
|
541
611
|
entity_type: string;
|
|
@@ -734,8 +804,25 @@ export declare interface FormRegistration {
|
|
|
734
804
|
getCurrentValues: () => Record<string, unknown>;
|
|
735
805
|
}
|
|
736
806
|
|
|
807
|
+
export declare interface GlobalSourceConfig {
|
|
808
|
+
/** Dot-path into `window` (e.g. `"PartnerSDK.session.token"`). */
|
|
809
|
+
path?: string;
|
|
810
|
+
/** Max poll time in ms (default 2000). */
|
|
811
|
+
timeoutMs?: number;
|
|
812
|
+
/** Poll interval in ms (default 100). */
|
|
813
|
+
intervalMs?: number;
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
export declare interface HashSourceConfig {
|
|
817
|
+
/** Hash key (after `#…&key=value&…`). Default `"token"`. */
|
|
818
|
+
key?: string;
|
|
819
|
+
}
|
|
820
|
+
|
|
737
821
|
export declare function inferTiledeskRole(message: TiledeskMessage, cfg: TiledeskRoleConfig): TiledeskRole;
|
|
738
822
|
|
|
823
|
+
export declare interface InitSourceConfig {
|
|
824
|
+
}
|
|
825
|
+
|
|
739
826
|
/**
|
|
740
827
|
* Self-echo detector — Tiledesk fans the user's outgoing publish back
|
|
741
828
|
* as a `clientadded` event on the same connection. UI must dedupe against
|
|
@@ -899,6 +986,21 @@ declare interface NavigateAction_2 {
|
|
|
899
986
|
|
|
900
987
|
export declare function parseTiledeskTemplate(message: TiledeskMessage): TiledeskParsedTemplate;
|
|
901
988
|
|
|
989
|
+
export declare interface PostMsgSourceConfig {
|
|
990
|
+
/** Message envelope `type` field that gates which postMessage we accept. */
|
|
991
|
+
type?: string;
|
|
992
|
+
/** Property inside `event.data` carrying the token. Default `"token"`. */
|
|
993
|
+
key?: string;
|
|
994
|
+
/**
|
|
995
|
+
* Allowed origins (comma-separated or single string). When set, messages
|
|
996
|
+
* from any other origin are ignored. When unset every origin is accepted
|
|
997
|
+
* — partners are encouraged to set this in production.
|
|
998
|
+
*/
|
|
999
|
+
origins?: string;
|
|
1000
|
+
/** Milliseconds to wait before rejecting. Default 30_000. */
|
|
1001
|
+
timeoutMs?: number;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
902
1004
|
/**
|
|
903
1005
|
* One HTTP call run by the SDK before auth. Failure of `soft: true` steps
|
|
904
1006
|
* is logged and ignored; failure of strict steps aborts the mount.
|
|
@@ -948,12 +1050,17 @@ export declare interface Presigned3StepAdapterConfig {
|
|
|
948
1050
|
extraHeaders?: Record<string, string>;
|
|
949
1051
|
}
|
|
950
1052
|
|
|
1053
|
+
export declare interface QuerySourceConfig {
|
|
1054
|
+
/** Query-string parameter name. Default `"token"`. */
|
|
1055
|
+
key?: string;
|
|
1056
|
+
}
|
|
1057
|
+
|
|
951
1058
|
/**
|
|
952
1059
|
* One slot's component pointer. The `kind` discriminator picks which
|
|
953
1060
|
* loader runs. Both kinds resolve to a `Promise<HTMLElement>` after load,
|
|
954
1061
|
* which the runtime appends into the slot anchor.
|
|
955
1062
|
*/
|
|
956
|
-
declare type RemoteComponent = {
|
|
1063
|
+
export declare type RemoteComponent = {
|
|
957
1064
|
kind: 'iife-element';
|
|
958
1065
|
/** URL of an IIFE bundle that calls `customElements.define(tag, …)`. */
|
|
959
1066
|
scriptUrl: string;
|
|
@@ -994,7 +1101,7 @@ declare type RemoteComponent = {
|
|
|
994
1101
|
* `redirectIfFails` lets a guard send the user to another route id
|
|
995
1102
|
* instead of erroring. Useful for `'authed'` failing → redirect to login.
|
|
996
1103
|
*/
|
|
997
|
-
declare interface RouteDef {
|
|
1104
|
+
export declare interface RouteDef {
|
|
998
1105
|
path: string;
|
|
999
1106
|
component: string;
|
|
1000
1107
|
guards?: string[];
|
|
@@ -1069,6 +1176,41 @@ export declare interface SessionAuthDescriptor {
|
|
|
1069
1176
|
|
|
1070
1177
|
export declare type SessionTokenProvider = string | (() => string | Promise<string>);
|
|
1071
1178
|
|
|
1179
|
+
export declare interface SidePanelDef {
|
|
1180
|
+
enabled?: boolean;
|
|
1181
|
+
type: SidePanelType;
|
|
1182
|
+
title?: string;
|
|
1183
|
+
mobile?: SidePanelMobile;
|
|
1184
|
+
steps?: Array<{
|
|
1185
|
+
name: string;
|
|
1186
|
+
hint?: string;
|
|
1187
|
+
}>;
|
|
1188
|
+
emptyText?: string;
|
|
1189
|
+
allowUpload?: boolean;
|
|
1190
|
+
summaryFields?: string[];
|
|
1191
|
+
supportPhone?: string;
|
|
1192
|
+
supportHours?: string;
|
|
1193
|
+
showHumanHandoff?: boolean;
|
|
1194
|
+
source?: ApiPanelSource;
|
|
1195
|
+
endpoint?: string;
|
|
1196
|
+
sampleJson?: string;
|
|
1197
|
+
refresh?: ApiPanelRefresh;
|
|
1198
|
+
intervalSec?: number;
|
|
1199
|
+
render?: ApiPanelRender;
|
|
1200
|
+
fields?: Array<{
|
|
1201
|
+
label: string;
|
|
1202
|
+
path: string;
|
|
1203
|
+
format?: ApiPanelFieldFormat;
|
|
1204
|
+
}>;
|
|
1205
|
+
stepsPath?: string;
|
|
1206
|
+
stepStatusKey?: string;
|
|
1207
|
+
customUrl?: string;
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
export declare type SidePanelMobile = 'drawer' | 'hidden';
|
|
1211
|
+
|
|
1212
|
+
export declare type SidePanelType = 'steps' | 'files' | 'summary' | 'support' | 'api' | 'custom';
|
|
1213
|
+
|
|
1072
1214
|
export declare interface SlugMountedWidget extends MountedTenantWidget {
|
|
1073
1215
|
fullName: string;
|
|
1074
1216
|
/** Resolved descriptor (fallback ⊕ fetched ⊕ overrides). Host reads
|
|
@@ -1076,6 +1218,13 @@ export declare interface SlugMountedWidget extends MountedTenantWidget {
|
|
|
1076
1218
|
descriptor: WidgetConfigDescriptor;
|
|
1077
1219
|
/** Force a fresh /chatbuddy/auth-style refetch (clears cached requestId). */
|
|
1078
1220
|
refreshAuth(): Promise<void>;
|
|
1221
|
+
/**
|
|
1222
|
+
* Re-discover the partner token (per `descriptor.sso.tokenSource`) and
|
|
1223
|
+
* re-exchange for a fresh chat JWT. Returns the new bearer or null when
|
|
1224
|
+
* discovery fails. Only available when `descriptor.sso.autoRefresh` is
|
|
1225
|
+
* `true`; returns `null` immediately otherwise.
|
|
1226
|
+
*/
|
|
1227
|
+
refreshPartnerAuth(): Promise<string | null>;
|
|
1079
1228
|
}
|
|
1080
1229
|
|
|
1081
1230
|
export declare interface SlugMountOptions {
|
|
@@ -1119,6 +1268,13 @@ export declare interface SlugMountOptions {
|
|
|
1119
1268
|
* without host code per call.
|
|
1120
1269
|
*/
|
|
1121
1270
|
identity?: Record<string, string | undefined>;
|
|
1271
|
+
/**
|
|
1272
|
+
* Partner token supplied directly by the embedding host. Used by
|
|
1273
|
+
* `descriptor.sso.tokenSource === "init"` (v2 sign-in flow) — every
|
|
1274
|
+
* other source kind discovers the token from the page itself
|
|
1275
|
+
* (query / hash / cookie / storage / postMessage / global).
|
|
1276
|
+
*/
|
|
1277
|
+
partnerToken?: string;
|
|
1122
1278
|
};
|
|
1123
1279
|
/** Optional escape hatches; merge over descriptor-driven defaults. */
|
|
1124
1280
|
hooks?: {
|
|
@@ -1179,8 +1335,51 @@ export declare interface SsoDescriptor {
|
|
|
1179
1335
|
apiKey?: string;
|
|
1180
1336
|
/** Extra static headers attached to the exchange POST. */
|
|
1181
1337
|
headers?: Record<string, string>;
|
|
1182
|
-
/**
|
|
1183
|
-
|
|
1338
|
+
/**
|
|
1339
|
+
* Legacy v1 shape — explicit list of credential sources the browser
|
|
1340
|
+
* reads + posts to the exchange endpoint. Still supported for the
|
|
1341
|
+
* bandhan-itr / myfinancials cohort that shipped before the v2
|
|
1342
|
+
* sign-in tab. Mutually exclusive with `tokenSource` (v2).
|
|
1343
|
+
*/
|
|
1344
|
+
collect?: SsoCollectSpec[];
|
|
1345
|
+
/** Provider family. `"partner"` is the only value today. */
|
|
1346
|
+
provider?: string;
|
|
1347
|
+
/** Recipe id paired with this descriptor (e.g. `partner_token_to_backend_jwt`). */
|
|
1348
|
+
flow?: string;
|
|
1349
|
+
/** Skip the login screen entirely — read token, exchange, mount chat. */
|
|
1350
|
+
skipLogin?: boolean;
|
|
1351
|
+
/** Re-read the token source on any request that 401s. */
|
|
1352
|
+
autoRefresh?: boolean;
|
|
1353
|
+
/** Selects which token reader runs at boot. */
|
|
1354
|
+
tokenSource?: TokenSourceKind;
|
|
1355
|
+
/** Per-source config (only the matching block is emitted by the dashboard). */
|
|
1356
|
+
tokenSourceConfig?: TokenSourceConfig;
|
|
1357
|
+
/** What to do when token-discovery fails — show a fallback screen. */
|
|
1358
|
+
fallback?: {
|
|
1359
|
+
enabled?: boolean;
|
|
1360
|
+
method?: 'phone' | 'email';
|
|
1361
|
+
};
|
|
1362
|
+
/** Dot-paths into the partner identity payload returned by `auth`. */
|
|
1363
|
+
map?: {
|
|
1364
|
+
id?: string;
|
|
1365
|
+
email?: string;
|
|
1366
|
+
name?: string;
|
|
1367
|
+
phone?: string;
|
|
1368
|
+
};
|
|
1369
|
+
/**
|
|
1370
|
+
* Name of the field inside the `{credentials: {...}}` body posted to
|
|
1371
|
+
* `/sso_exchange`. Default `"credential"`. Set to match what the partner's
|
|
1372
|
+
* `/auth` leg expects — e.g. `"idToken"` for legacy Google flows, `"token"`
|
|
1373
|
+
* for partner JWTs.
|
|
1374
|
+
*/
|
|
1375
|
+
credentialFieldName?: string;
|
|
1376
|
+
/**
|
|
1377
|
+
* Key under `user.properties` that the sso_exchange response carries the
|
|
1378
|
+
* tenant session token in. Set by `user_provisioning.response_map.properties`
|
|
1379
|
+
* server-side. Default `"partner_token"`. The browser uses this token as
|
|
1380
|
+
* the Bearer for `descriptor.auth.endpoint` (e.g. `chatbuddy/auth`).
|
|
1381
|
+
*/
|
|
1382
|
+
tenantTokenProperty?: string;
|
|
1184
1383
|
}
|
|
1185
1384
|
|
|
1186
1385
|
export declare class SsoExchangeAdapter {
|
|
@@ -1240,6 +1439,15 @@ export declare interface SsoIdentity {
|
|
|
1240
1439
|
*/
|
|
1241
1440
|
export declare type SsoSourceKind = 'cookie' | 'localStorage' | 'sessionStorage' | 'url_param' | 'header_meta' | 'callback';
|
|
1242
1441
|
|
|
1442
|
+
export declare interface StorageSourceConfig {
|
|
1443
|
+
/** `"local"` (default) or `"session"`. */
|
|
1444
|
+
store?: 'local' | 'session';
|
|
1445
|
+
/** Storage key. */
|
|
1446
|
+
key?: string;
|
|
1447
|
+
/** Optional dot-path. When set the value is JSON.parsed and walked. */
|
|
1448
|
+
path?: string;
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1243
1451
|
declare type SubscriptionCallback = (data: unknown) => void;
|
|
1244
1452
|
|
|
1245
1453
|
declare interface TemplateMessageEvent {
|
|
@@ -1628,6 +1836,102 @@ declare interface TiledeskTransportConfig_2 {
|
|
|
1628
1836
|
debug?: boolean;
|
|
1629
1837
|
}
|
|
1630
1838
|
|
|
1839
|
+
export declare interface TokenDiscoveryDescriptor {
|
|
1840
|
+
/** `"partner"` today; reserved for future SSO families. */
|
|
1841
|
+
provider?: string;
|
|
1842
|
+
/** Recipe id the backend pairs with this descriptor. */
|
|
1843
|
+
flow?: string;
|
|
1844
|
+
/** When true the embedded SDK skips the login UI entirely. */
|
|
1845
|
+
skipLogin?: boolean;
|
|
1846
|
+
/** When true the SDK re-reads the source on 401 retries. */
|
|
1847
|
+
autoRefresh?: boolean;
|
|
1848
|
+
/** One of the seven supported source kinds. */
|
|
1849
|
+
tokenSource: TokenSourceKind;
|
|
1850
|
+
/** Source-specific config; only the matching block is read. */
|
|
1851
|
+
tokenSourceConfig?: TokenSourceConfig;
|
|
1852
|
+
/** Fallback (e.g. show a phone OTP screen) when discovery fails. */
|
|
1853
|
+
fallback?: {
|
|
1854
|
+
enabled?: boolean;
|
|
1855
|
+
method?: 'phone' | 'email';
|
|
1856
|
+
};
|
|
1857
|
+
/** Dot-paths into the partner identity payload returned by the auth call. */
|
|
1858
|
+
map?: {
|
|
1859
|
+
id?: string;
|
|
1860
|
+
email?: string;
|
|
1861
|
+
name?: string;
|
|
1862
|
+
phone?: string;
|
|
1863
|
+
};
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1866
|
+
export declare class TokenDiscoveryError extends Error {
|
|
1867
|
+
readonly source: string;
|
|
1868
|
+
constructor(source: string, msg: string);
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
export declare interface TokenDiscoveryOptions {
|
|
1872
|
+
/** Descriptor from `widget_configs/:slug` (`configurations.sso`). */
|
|
1873
|
+
descriptor: TokenDiscoveryDescriptor;
|
|
1874
|
+
/**
|
|
1875
|
+
* Initial token explicitly passed to the SDK by the parent caller. Used
|
|
1876
|
+
* by the `init` source kind; ignored by every other.
|
|
1877
|
+
*/
|
|
1878
|
+
initToken?: string;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* Thin wrapper that re-runs `discoverToken` on demand. Used by
|
|
1883
|
+
* `ApiClient` when a request 401s and `descriptor.sso.autoRefresh` is set.
|
|
1884
|
+
*
|
|
1885
|
+
* The first call caches the token; `.refresh()` forces a re-read of the
|
|
1886
|
+
* source. `init` mode can't be refreshed (the partner already gave us the
|
|
1887
|
+
* single token) — callers should fall through to fallback there.
|
|
1888
|
+
*/
|
|
1889
|
+
export declare class TokenDiscoveryReader {
|
|
1890
|
+
private readonly opts;
|
|
1891
|
+
private cached;
|
|
1892
|
+
constructor(opts: TokenDiscoveryOptions);
|
|
1893
|
+
get descriptor(): TokenDiscoveryDescriptor;
|
|
1894
|
+
/** Resolve the token. Returns cache if present. */
|
|
1895
|
+
get(): Promise<DiscoveredToken>;
|
|
1896
|
+
/**
|
|
1897
|
+
* Re-evaluate the source. For `init` mode (where the SDK has no way to
|
|
1898
|
+
* re-read) this returns the cached token unchanged — callers should
|
|
1899
|
+
* treat repeated 401s after a refresh attempt as terminal.
|
|
1900
|
+
*/
|
|
1901
|
+
refresh(): Promise<DiscoveredToken>;
|
|
1902
|
+
}
|
|
1903
|
+
|
|
1904
|
+
export declare type TokenSourceConfig = InitSourceConfig | QuerySourceConfig | HashSourceConfig | PostMsgSourceConfig | CookieSourceConfig | StorageSourceConfig | GlobalSourceConfig;
|
|
1905
|
+
|
|
1906
|
+
/**
|
|
1907
|
+
* Partner-token discovery dispatcher (v2 sign-in flow).
|
|
1908
|
+
*
|
|
1909
|
+
* The dashboard's Sign-in tab writes a `descriptor.sso` block that names
|
|
1910
|
+
* one of seven token-source modes plus a per-mode config block. At runtime
|
|
1911
|
+
* the SDK reads the descriptor, dispatches to the matching reader, and
|
|
1912
|
+
* returns the raw partner token. When `descriptor.sso.skipLogin === true`
|
|
1913
|
+
* the host shell uses the token directly to do the auth exchange; when
|
|
1914
|
+
* `descriptor.sso.autoRefresh === true` the reader is re-evaluated on any
|
|
1915
|
+
* request that returned 401 (see {@link ApiClient}).
|
|
1916
|
+
*
|
|
1917
|
+
* Reading flows:
|
|
1918
|
+
* - `init` — supplied at construction (e.g. `Aikaara.init({token})`).
|
|
1919
|
+
* - `query` — `URLSearchParams(location.search).get(cfg.key)`.
|
|
1920
|
+
* - `hash` — `location.hash` parsed as URLSearchParams; cfg.key wins.
|
|
1921
|
+
* - `postmsg` — `window.addEventListener('message')` filtered by
|
|
1922
|
+
* `cfg.type` + `cfg.key`; origins allowlist optional.
|
|
1923
|
+
* - `cookie` — `document.cookie` parsed; domain scope is informational
|
|
1924
|
+
* (browser already enforces it for the running page).
|
|
1925
|
+
* - `storage` — `(localStorage|sessionStorage).getItem(cfg.key)`; when
|
|
1926
|
+
* `cfg.path` is set, parsed as JSON + dot-path resolved.
|
|
1927
|
+
* - `global` — `window[cfg.path]` resolved via dot-path; polled for
|
|
1928
|
+
* up to 2 seconds for late-loading partner SDKs.
|
|
1929
|
+
*
|
|
1930
|
+
* The dispatcher is intentionally side-effect-free apart from
|
|
1931
|
+
* `postmsg` (which has to attach a listener). Callers control caching.
|
|
1932
|
+
*/
|
|
1933
|
+
export declare type TokenSourceKind = 'init' | 'query' | 'hash' | 'postmsg' | 'cookie' | 'storage' | 'global';
|
|
1934
|
+
|
|
1631
1935
|
export declare interface ToolCall {
|
|
1632
1936
|
id: string;
|
|
1633
1937
|
type: 'function';
|
|
@@ -1960,6 +2264,28 @@ export declare interface WidgetConfigDescriptor {
|
|
|
1960
2264
|
defaultRoute: string;
|
|
1961
2265
|
/** Map of route id → definition. */
|
|
1962
2266
|
routes: Record<string, RouteDef>;
|
|
2267
|
+
/**
|
|
2268
|
+
* Static page list rendered by the hosted-shell's top/bottom nav. The
|
|
2269
|
+
* dashboard's App Layout tab writes this; the SDK doesn't read it.
|
|
2270
|
+
* Surfaced here so descriptor consumers get a typed view.
|
|
2271
|
+
*/
|
|
2272
|
+
pages?: AppPageDef[];
|
|
2273
|
+
/** Side panels wrapping the chat — see {@link SidePanelDef}. */
|
|
2274
|
+
panels?: {
|
|
2275
|
+
left?: SidePanelDef;
|
|
2276
|
+
right?: SidePanelDef;
|
|
2277
|
+
};
|
|
2278
|
+
};
|
|
2279
|
+
/**
|
|
2280
|
+
* Tenant-side API config consumed by the side-panel runtime. Right now
|
|
2281
|
+
* only the `api`-type panel uses this — it prefixes `panel.endpoint`
|
|
2282
|
+
* with `api.baseUrl` and sends the chat JWT as `Authorization`. Other
|
|
2283
|
+
* descriptor blocks (`upload`, `historyApiBase`, etc.) keep their own
|
|
2284
|
+
* fields for backwards compatibility.
|
|
2285
|
+
*/
|
|
2286
|
+
api?: {
|
|
2287
|
+
/** Absolute base URL for tenant API calls. No trailing slash. */
|
|
2288
|
+
baseUrl?: string;
|
|
1963
2289
|
};
|
|
1964
2290
|
/**
|
|
1965
2291
|
* Unified slot map. Supersedes `templates` and the bespoke
|
package/dist/headless.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { E as s } from "./MountTenant-
|
|
2
|
-
import { A as p, b as l, k as g, C as
|
|
1
|
+
import { E as s } from "./MountTenant-CxO7hJgs.mjs";
|
|
2
|
+
import { A as p, b as l, k as g, C as c, l as h, m as y, M as u, S as m, n as f, T, o as S, p as _, q as v, s as E, t as C, u as F, v as k, w as A, x as I, y as x, z as U, B as q, D as M, F as b } from "./MountTenant-CxO7hJgs.mjs";
|
|
3
3
|
class a extends s {
|
|
4
4
|
registration = null;
|
|
5
5
|
pendingEdits = [];
|
|
@@ -96,24 +96,27 @@ export {
|
|
|
96
96
|
p as ActionCableClient,
|
|
97
97
|
l as AikaaraChatClient,
|
|
98
98
|
g as ApiClient,
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
c as ChannelSubscription,
|
|
100
|
+
h as ConnectionManager,
|
|
101
101
|
y as ConversationManager,
|
|
102
102
|
s as EventEmitter,
|
|
103
103
|
a as FormBridge,
|
|
104
104
|
u as MessageStore,
|
|
105
105
|
m as SessionAuthAdapter,
|
|
106
106
|
f as SsoExchangeAdapter,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
_ as
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
C as
|
|
113
|
-
F as
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
I as
|
|
117
|
-
x as
|
|
118
|
-
U as
|
|
107
|
+
T as TiledeskTransport,
|
|
108
|
+
S as TokenDiscoveryError,
|
|
109
|
+
_ as TokenDiscoveryReader,
|
|
110
|
+
v as clearPersistedConversationId,
|
|
111
|
+
E as collectSsoCredentials,
|
|
112
|
+
C as createFetchUploadAdapter,
|
|
113
|
+
F as createPresigned3StepUploadAdapter,
|
|
114
|
+
k as createTiledeskHistoryAdapter,
|
|
115
|
+
A as discoverToken,
|
|
116
|
+
I as extractTiledeskFileEnvelope,
|
|
117
|
+
x as inferTiledeskRole,
|
|
118
|
+
U as isTiledeskSelfEcho,
|
|
119
|
+
q as mountFromSlug,
|
|
120
|
+
M as mountTenantWidget,
|
|
121
|
+
b as parseTiledeskTemplate
|
|
119
122
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MountTenant-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./MountTenant-BCjKRkD8.cjs"),s=require("./headless.cjs");function l(a){e.registerComponents();const t=document.createElement("aikaara-chat-widget"),i={baseUrl:"base-url",userToken:"user-token",apiKey:"api-key",title:"title",subtitle:"subtitle",theme:"theme",primaryColor:"primary-color",position:"position",width:"width",height:"height",placeholder:"placeholder",welcomeMessage:"welcome-message",avatarUrl:"avatar-url"};for(const[o,n]of Object.entries(i)){const r=a[o];r!=null&&t.setAttribute(n,String(r))}return t.configure(a),document.body.appendChild(t),t}function d(){const a=document.querySelector("aikaara-chat-widget");a&&a.remove()}exports.ActionCableClient=e.ActionCableClient;exports.AikaaraChatBubble=e.AikaaraChatBubble;exports.AikaaraChatClient=e.AikaaraChatClient;exports.AikaaraChatHeader=e.AikaaraChatHeader;exports.AikaaraChatInput=e.AikaaraChatInput;exports.AikaaraChatWidget=e.AikaaraChatWidget;exports.AikaaraErrorBanner=e.AikaaraErrorBanner;exports.AikaaraMessageBubble=e.AikaaraMessageBubble;exports.AikaaraMessageList=e.AikaaraMessageList;exports.AikaaraStreamingMessage=e.AikaaraStreamingMessage;exports.AikaaraTypingIndicator=e.AikaaraTypingIndicator;exports.ApiClient=e.ApiClient;exports.ChannelSubscription=e.ChannelSubscription;exports.ConnectionManager=e.ConnectionManager;exports.ConversationManager=e.ConversationManager;exports.EventEmitter=e.EventEmitter;exports.MessageStore=e.MessageStore;exports.SessionAuthAdapter=e.SessionAuthAdapter;exports.SsoExchangeAdapter=e.SsoExchangeAdapter;exports.TiledeskTransport=e.TiledeskTransport;exports.TokenDiscoveryError=e.TokenDiscoveryError;exports.TokenDiscoveryReader=e.TokenDiscoveryReader;exports.clearPersistedConversationId=e.clearPersistedConversationId;exports.collectSsoCredentials=e.collectSsoCredentials;exports.createFetchUploadAdapter=e.createFetchUploadAdapter;exports.createPresigned3StepUploadAdapter=e.createPresigned3StepUploadAdapter;exports.createTiledeskHistoryAdapter=e.createTiledeskHistoryAdapter;exports.discoverToken=e.discoverToken;exports.extractTiledeskFileEnvelope=e.extractTiledeskFileEnvelope;exports.inferTiledeskRole=e.inferTiledeskRole;exports.isTiledeskSelfEcho=e.isTiledeskSelfEcho;exports.mountFromSlug=e.mountFromSlug;exports.mountTenantWidget=e.mount;exports.parseTiledeskTemplate=e.parseTiledeskTemplate;exports.registerComponents=e.registerComponents;exports.FormBridge=s.FormBridge;exports.mount=l;exports.unmount=d;
|