@livechatta/sdk 0.0.0-stage → 1.0.0
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/CHANGELOG.md +218 -0
- package/LICENSE +21 -0
- package/README.md +2558 -2
- package/bin/chatta.mjs +7 -0
- package/bin/lib/cli.d.mts +46 -0
- package/bin/lib/cli.mjs +2088 -0
- package/dist/cjs/livechatta.cjs.js +7258 -0
- package/dist/cjs/livechatta.cjs.js.map +1 -0
- package/dist/cjs/livechatta.cjs.min.js +2 -0
- package/dist/cjs/livechatta.cjs.min.js.map +1 -0
- package/dist/esm/livechatta.esm.js +7077 -0
- package/dist/esm/livechatta.esm.js.map +1 -0
- package/dist/esm/livechatta.esm.min.js +2 -0
- package/dist/esm/livechatta.esm.min.js.map +1 -0
- package/dist/platforms/android/LiveChattaClient.kt +367 -0
- package/dist/platforms/android/LiveChattaHttpAPI.kt +2630 -0
- package/dist/platforms/android/LiveChattaJson.kt +83 -0
- package/dist/platforms/android/LiveChattaModels.kt +22805 -0
- package/dist/platforms/android/LiveChattaSentFrom.kt +30 -0
- package/dist/platforms/android/LiveChattaSocketAPI.kt +2113 -0
- package/dist/platforms/android/LiveChattaTyped.kt +239 -0
- package/dist/platforms/android/LiveChattaWebView.kt +158 -0
- package/dist/platforms/angular/livechatta-bridge.service.d.ts +35 -0
- package/dist/platforms/angular/livechatta-bridge.service.js +1 -0
- package/dist/platforms/angular/livechatta-bridge.service.js.map +1 -0
- package/dist/platforms/angular/livechatta-embed.component.d.ts +46 -0
- package/dist/platforms/angular/livechatta-embed.component.js +1 -0
- package/dist/platforms/angular/livechatta-embed.component.js.map +1 -0
- package/dist/platforms/angular/livechatta.service.d.ts +66 -0
- package/dist/platforms/angular/livechatta.service.js +1 -0
- package/dist/platforms/angular/livechatta.service.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorBridge.d.ts +27 -0
- package/dist/platforms/capacitor/CapacitorBridge.js +1 -0
- package/dist/platforms/capacitor/CapacitorBridge.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorDeepLinks.d.ts +23 -0
- package/dist/platforms/capacitor/CapacitorDeepLinks.js +1 -0
- package/dist/platforms/capacitor/CapacitorDeepLinks.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorPermissions.d.ts +29 -0
- package/dist/platforms/capacitor/CapacitorPermissions.js +1 -0
- package/dist/platforms/capacitor/CapacitorPermissions.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorPush.d.ts +33 -0
- package/dist/platforms/capacitor/CapacitorPush.js +1 -0
- package/dist/platforms/capacitor/CapacitorPush.js.map +1 -0
- package/dist/platforms/capacitor/index.d.ts +24 -0
- package/dist/platforms/capacitor/index.js +1 -0
- package/dist/platforms/capacitor/index.js.map +1 -0
- package/dist/platforms/flutter/livechatta_client.dart +359 -0
- package/dist/platforms/flutter/livechatta_http_api.dart +1942 -0
- package/dist/platforms/flutter/livechatta_json.dart +57 -0
- package/dist/platforms/flutter/livechatta_models.dart +23531 -0
- package/dist/platforms/flutter/livechatta_sent_from.dart +35 -0
- package/dist/platforms/flutter/livechatta_socket_api.dart +1504 -0
- package/dist/platforms/flutter/livechatta_typed.dart +234 -0
- package/dist/platforms/flutter/livechatta_webview.dart +190 -0
- package/dist/platforms/ios/LiveChattaClient.swift +374 -0
- package/dist/platforms/ios/LiveChattaHttpAPI.swift +2431 -0
- package/dist/platforms/ios/LiveChattaJSON.swift +84 -0
- package/dist/platforms/ios/LiveChattaModels.swift +27050 -0
- package/dist/platforms/ios/LiveChattaSentFrom.swift +32 -0
- package/dist/platforms/ios/LiveChattaSocketAPI.swift +1446 -0
- package/dist/platforms/ios/LiveChattaTyped.swift +268 -0
- package/dist/platforms/ios/LiveChattaWebView.swift +191 -0
- package/dist/platforms/nuxt/LiveChattaView.d.ts +1 -0
- package/dist/platforms/nuxt/LiveChattaView.js +1 -0
- package/dist/platforms/nuxt/LiveChattaView.js.map +1 -0
- package/dist/platforms/nuxt/useChattaBridge.d.ts +9 -0
- package/dist/platforms/nuxt/useChattaBridge.js +1 -0
- package/dist/platforms/nuxt/useChattaBridge.js.map +1 -0
- package/dist/platforms/nuxt/useLiveChatta.d.ts +63 -0
- package/dist/platforms/nuxt/useLiveChatta.js +1 -0
- package/dist/platforms/nuxt/useLiveChatta.js.map +1 -0
- package/dist/platforms/react/LiveChattaView.d.ts +58 -0
- package/dist/platforms/react/LiveChattaView.js +1 -0
- package/dist/platforms/react/LiveChattaView.js.map +1 -0
- package/dist/platforms/react/useChattaBridge.d.ts +1 -0
- package/dist/platforms/react/useChattaBridge.js +1 -0
- package/dist/platforms/react/useChattaBridge.js.map +1 -0
- package/dist/platforms/react/useChattaDeepLink.d.ts +2 -0
- package/dist/platforms/react/useChattaDeepLink.js +1 -0
- package/dist/platforms/react/useChattaDeepLink.js.map +1 -0
- package/dist/platforms/react/useChattaPermissions.d.ts +9 -0
- package/dist/platforms/react/useChattaPermissions.js +1 -0
- package/dist/platforms/react/useChattaPermissions.js.map +1 -0
- package/dist/platforms/react/useChattaUnread.d.ts +1 -0
- package/dist/platforms/react/useChattaUnread.js +1 -0
- package/dist/platforms/react/useChattaUnread.js.map +1 -0
- package/dist/platforms/react/useLiveChatta.d.ts +29 -0
- package/dist/platforms/react/useLiveChatta.js +1 -0
- package/dist/platforms/react/useLiveChatta.js.map +1 -0
- package/dist/platforms/react-native/LiveChattaView.d.ts +52 -0
- package/dist/platforms/react-native/LiveChattaView.js +1 -0
- package/dist/platforms/react-native/LiveChattaView.js.map +1 -0
- package/dist/platforms/react-native/useChattaBridge.d.ts +12 -0
- package/dist/platforms/react-native/useChattaBridge.js +1 -0
- package/dist/platforms/react-native/useChattaBridge.js.map +1 -0
- package/dist/platforms/react-native/useLiveChatta.d.ts +29 -0
- package/dist/platforms/react-native/useLiveChatta.js +1 -0
- package/dist/platforms/react-native/useLiveChatta.js.map +1 -0
- package/dist/platforms/svelte/LiveChattaEmbed.d.ts +54 -0
- package/dist/platforms/svelte/LiveChattaEmbed.js +1 -0
- package/dist/platforms/svelte/LiveChattaEmbed.js.map +1 -0
- package/dist/platforms/svelte/chattaBridgeStore.d.ts +19 -0
- package/dist/platforms/svelte/chattaBridgeStore.js +1 -0
- package/dist/platforms/svelte/chattaBridgeStore.js.map +1 -0
- package/dist/platforms/svelte/useLiveChatta.d.ts +61 -0
- package/dist/platforms/svelte/useLiveChatta.js +1 -0
- package/dist/platforms/svelte/useLiveChatta.js.map +1 -0
- package/dist/platforms/tauri/TauriBridge.d.ts +34 -0
- package/dist/platforms/tauri/TauriBridge.js +1 -0
- package/dist/platforms/tauri/TauriBridge.js.map +1 -0
- package/dist/platforms/tauri/TauriDeepLinks.d.ts +29 -0
- package/dist/platforms/tauri/TauriDeepLinks.js +1 -0
- package/dist/platforms/tauri/TauriDeepLinks.js.map +1 -0
- package/dist/platforms/tauri/TauriPermissions.d.ts +21 -0
- package/dist/platforms/tauri/TauriPermissions.js +1 -0
- package/dist/platforms/tauri/TauriPermissions.js.map +1 -0
- package/dist/platforms/tauri/TauriUpdater.d.ts +31 -0
- package/dist/platforms/tauri/TauriUpdater.js +1 -0
- package/dist/platforms/tauri/TauriUpdater.js.map +1 -0
- package/dist/platforms/tauri/index.d.ts +22 -0
- package/dist/platforms/tauri/index.js +1 -0
- package/dist/platforms/tauri/index.js.map +1 -0
- package/dist/platforms/vue/LiveChattaView.d.ts +1 -0
- package/dist/platforms/vue/LiveChattaView.js +1 -0
- package/dist/platforms/vue/LiveChattaView.js.map +1 -0
- package/dist/platforms/vue/useChattaBridge.d.ts +11 -0
- package/dist/platforms/vue/useChattaBridge.js +1 -0
- package/dist/platforms/vue/useChattaBridge.js.map +1 -0
- package/dist/platforms/vue/useChattaDeepLink.d.ts +2 -0
- package/dist/platforms/vue/useChattaDeepLink.js +1 -0
- package/dist/platforms/vue/useChattaDeepLink.js.map +1 -0
- package/dist/platforms/vue/useChattaPermissions.d.ts +9 -0
- package/dist/platforms/vue/useChattaPermissions.js +1 -0
- package/dist/platforms/vue/useChattaPermissions.js.map +1 -0
- package/dist/platforms/vue/useChattaUnread.d.ts +8 -0
- package/dist/platforms/vue/useChattaUnread.js +1 -0
- package/dist/platforms/vue/useChattaUnread.js.map +1 -0
- package/dist/platforms/vue/useLiveChatta.d.ts +58 -0
- package/dist/platforms/vue/useLiveChatta.js +1 -0
- package/dist/platforms/vue/useLiveChatta.js.map +1 -0
- package/dist/platforms/web/LiveChattaEmbed.d.ts +94 -0
- package/dist/platforms/web/LiveChattaEmbed.js +1 -0
- package/dist/platforms/web/LiveChattaEmbed.js.map +1 -0
- package/dist/platforms/web/bridge.d.ts +8 -0
- package/dist/platforms/web/bridge.js +1 -0
- package/dist/platforms/web/bridge.js.map +1 -0
- package/dist/platforms/web/permissions.d.ts +8 -0
- package/dist/platforms/web/permissions.js +1 -0
- package/dist/platforms/web/permissions.js.map +1 -0
- package/dist/types/billing.d.ts +355 -0
- package/dist/types/billing.js +53 -0
- package/dist/types/billing.js.map +1 -0
- package/dist/types/calendar.d.ts +132 -0
- package/dist/types/calendar.js +15 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/types/chat-core.d.ts +901 -0
- package/dist/types/chat-core.js +98 -0
- package/dist/types/chat-core.js.map +1 -0
- package/dist/types/chat-features.d.ts +775 -0
- package/dist/types/chat-features.js +50 -0
- package/dist/types/chat-features.js.map +1 -0
- package/dist/types/content.d.ts +138 -0
- package/dist/types/content.js +2 -0
- package/dist/types/content.js.map +1 -0
- package/dist/types/core/AutoRefresh.d.ts +68 -0
- package/dist/types/core/Bridge.d.ts +124 -0
- package/dist/types/core/Config.d.ts +26 -0
- package/dist/types/core/DeepLinks.d.ts +38 -0
- package/dist/types/core/EventBus.d.ts +15 -0
- package/dist/types/core/GrantStore.d.ts +29 -0
- package/dist/types/core/LiveChatta.d.ts +128 -0
- package/dist/types/core/Permissions.d.ts +34 -0
- package/dist/types/core/TokenManager.d.ts +25 -0
- package/dist/types/core/events.d.ts +140 -0
- package/dist/types/csat.d.ts +110 -0
- package/dist/types/csat.js +12 -0
- package/dist/types/csat.js.map +1 -0
- package/dist/types/events.d.ts +242 -0
- package/dist/types/events.js +275 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/extras.d.ts +353 -0
- package/dist/types/extras.js +31 -0
- package/dist/types/extras.js.map +1 -0
- package/dist/types/http/HttpAPI.d.ts +944 -0
- package/dist/types/http/HttpTransport.d.ts +66 -0
- package/dist/types/http/incomingWebhook.d.ts +17 -0
- package/dist/types/incoming-webhooks.d.ts +78 -0
- package/dist/types/incoming-webhooks.js +16 -0
- package/dist/types/incoming-webhooks.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/liveflex.d.ts +578 -0
- package/dist/types/liveflex.js +7 -0
- package/dist/types/liveflex.js.map +1 -0
- package/dist/types/models.d.ts +1753 -0
- package/dist/types/models.js +148 -0
- package/dist/types/models.js.map +1 -0
- package/dist/types/options.d.ts +190 -0
- package/dist/types/options.js +43 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/shared-channels.d.ts +236 -0
- package/dist/types/shared-channels.js +50 -0
- package/dist/types/shared-channels.js.map +1 -0
- package/dist/types/socket/SocketAPI.d.ts +1026 -0
- package/dist/types/socket/SocketTransport.d.ts +44 -0
- package/dist/types/types/billing.d.ts +355 -0
- package/dist/types/types/calendar.d.ts +132 -0
- package/dist/types/types/chat-core.d.ts +901 -0
- package/dist/types/types/chat-features.d.ts +775 -0
- package/dist/types/types/content.d.ts +138 -0
- package/dist/types/types/csat.d.ts +110 -0
- package/dist/types/types/events.d.ts +242 -0
- package/dist/types/types/extras.d.ts +353 -0
- package/dist/types/types/incoming-webhooks.d.ts +78 -0
- package/dist/types/types/index.d.ts +15 -0
- package/dist/types/types/liveflex.d.ts +578 -0
- package/dist/types/types/models.d.ts +1753 -0
- package/dist/types/types/options.d.ts +190 -0
- package/dist/types/types/shared-channels.d.ts +236 -0
- package/dist/types/types/workspace-gifs.d.ts +95 -0
- package/dist/types/types/workspace.d.ts +390 -0
- package/dist/types/ui/EmbedConfig.d.ts +38 -0
- package/dist/types/ui/EmbedUI.d.ts +44 -0
- package/dist/types/ui/Launcher.d.ts +122 -0
- package/dist/types/ui/brand.d.ts +27 -0
- package/dist/types/ui/embedMessages.d.ts +23 -0
- package/dist/types/ui/hours.d.ts +35 -0
- package/dist/types/ui/prechat.d.ts +35 -0
- package/dist/types/ui/widgetConfig.d.ts +4 -0
- package/dist/types/utils/crypto.d.ts +6 -0
- package/dist/types/utils/hmac.d.ts +40 -0
- package/dist/types/utils/permissions.d.ts +5 -0
- package/dist/types/utils/platform.d.ts +18 -0
- package/dist/types/utils/visitor.d.ts +2 -0
- package/dist/types/workspace-gifs.d.ts +95 -0
- package/dist/types/workspace-gifs.js +3 -0
- package/dist/types/workspace-gifs.js.map +1 -0
- package/dist/types/workspace.d.ts +390 -0
- package/dist/types/workspace.js +13 -0
- package/dist/types/workspace.js.map +1 -0
- package/dist/umd/livechatta.umd.js +7262 -0
- package/dist/umd/livechatta.umd.js.map +1 -0
- package/dist/umd/livechatta.umd.min.js +2 -0
- package/dist/umd/livechatta.umd.min.js.map +1 -0
- package/package.json +278 -4
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** "forever" is stored as this far-future date. */
|
|
2
|
+
export const MUTE_FOREVER_AT = '9999-12-31T23:59:59.000Z';
|
|
3
|
+
/** Older conversations have no permissions; treat missing values as these. */
|
|
4
|
+
export const DEFAULT_CONVERSATION_PERMISSIONS = Object.freeze({
|
|
5
|
+
membersCanSend: true,
|
|
6
|
+
membersCanAddPeople: false,
|
|
7
|
+
membersCanStartCalls: true,
|
|
8
|
+
membersCanShareMedia: true,
|
|
9
|
+
membersCanPin: true,
|
|
10
|
+
membersCanManageWebhooks: false,
|
|
11
|
+
slowModeSeconds: 0,
|
|
12
|
+
});
|
|
13
|
+
export const TRANSCRIBE_ERROR_CODES = [
|
|
14
|
+
'OUT_OF_AI_CREDITS', 'NOT_AVAILABLE', 'NO_MEDIA', 'TOO_LONG', 'PROVIDER_FAILED',
|
|
15
|
+
];
|
|
16
|
+
/** Every `SentFrom` value, for validation and pickers. */
|
|
17
|
+
export const SENT_FROM_VALUES = ['ios-app', 'android-app', 'desktop-app', 'mobile-web', 'web', 'api', 'bot', 'automation'];
|
|
18
|
+
const SENT_FROM_TEXT = {
|
|
19
|
+
'ios-app': 'iPhone app',
|
|
20
|
+
'android-app': 'Android app',
|
|
21
|
+
'desktop-app': 'Desktop app',
|
|
22
|
+
'mobile-web': 'Mobile web',
|
|
23
|
+
web: 'Web',
|
|
24
|
+
api: 'API',
|
|
25
|
+
bot: 'Bot',
|
|
26
|
+
automation: 'Automation',
|
|
27
|
+
};
|
|
28
|
+
/** "iPhone app", "API", … for a message's `sentFrom`; '' when it has none (older messages) or an unknown value. */
|
|
29
|
+
export function sentFromLabel(value) {
|
|
30
|
+
return typeof value === 'string' && Object.prototype.hasOwnProperty.call(SENT_FROM_TEXT, value) ? SENT_FROM_TEXT[value] : '';
|
|
31
|
+
}
|
|
32
|
+
export const INTERNAL_NOTE_MAX_LENGTH = 3000;
|
|
33
|
+
export const CONVERSATION_NOTE_MAX_LENGTH = 2000;
|
|
34
|
+
export const INBOX_TOPIC_MAX = 8;
|
|
35
|
+
/** Catch-up summaries need at least this many unread messages. */
|
|
36
|
+
export const CATCH_UP_MIN_UNREAD = 8;
|
|
37
|
+
// ── Account profile preferences (PATCH /users/me, owner token) ─────────────
|
|
38
|
+
export const SOUND_PRESETS = ['default', 'gentle', 'chime', 'pop', 'none'];
|
|
39
|
+
export const PREFERENCE_LANGUAGES = ['en', 'fr', 'es', 'ar', 'pt', 'de', 'yo', 'ha', 'ig', 'sw', 'zh', 'hi'];
|
|
40
|
+
export const MESSAGE_LAYOUT_PREFS = ['auto', 'bubbles', 'lines'];
|
|
41
|
+
export const TEXT_SIZE_PREFS = ['s', 'm', 'l', 'xl'];
|
|
42
|
+
/** Waiting tune for a caller or host who is alone in a call; `off` is no tune (unset plays `drift`). */
|
|
43
|
+
export const CALL_WAITING_TUNES = ['drift', 'pebble', 'lantern', 'tide', 'meadow', 'off'];
|
|
44
|
+
/** Keys `settings` accepts on link create / update (chatta #408); others are dropped and PATCH merges key by key. */
|
|
45
|
+
export const CHAT_LINK_SETTINGS_KEYS = [
|
|
46
|
+
'maxMembers', 'allowAttachments', 'allowVoiceMessages', 'allowVideoMessages', 'allowMemberInvite',
|
|
47
|
+
'welcomeMessage', 'defaultLayout', 'hideRunsOn', 'allowMemberStart', 'allowHopCalls', 'allowScreenshots', 'retentionDays', 'allowLiveFlex', 'editHistoryAdminsOnly', 'allowSharedDms', 'isolated',
|
|
48
|
+
'allowRecordingDownload',
|
|
49
|
+
];
|
|
50
|
+
//# sourceMappingURL=chat-features.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-features.js","sourceRoot":"","sources":["../../src/types/chat-features.ts"],"names":[],"mappings":"AA6DA,mDAAmD;AACnD,MAAM,CAAC,MAAM,eAAe,GAAG,0BAA0B,CAAC;AA+J1D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gCAAgC,GAAsC,MAAM,CAAC,MAAM,CAAC;IAC/F,cAAc,EAAE,IAAI;IACpB,mBAAmB,EAAE,KAAK;IAC1B,oBAAoB,EAAE,IAAI;IAC1B,oBAAoB,EAAE,IAAI;IAC1B,aAAa,EAAE,IAAI;IACnB,wBAAwB,EAAE,KAAK;IAC/B,eAAe,EAAE,CAAC;CACnB,CAAC,CAAC;AA0DH,MAAM,CAAC,MAAM,sBAAsB,GAAmC;IACpE,mBAAmB,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,iBAAiB;CAChF,CAAC;AAkNF,0DAA0D;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAwB,CAAC,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC;AAEhJ,MAAM,cAAc,GAA6B;IAC/C,SAAS,EAAE,YAAY;IACvB,aAAa,EAAE,aAAa;IAC5B,aAAa,EAAE,aAAa;IAC5B,YAAY,EAAE,YAAY;IAC1B,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,UAAU,EAAE,YAAY;CACzB,CAAC;AAEF,mHAAmH;AACnH,MAAM,UAAU,aAAa,CAAC,KAAgC;IAC5D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,KAAiB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3I,CAAC;AAID,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAC7C,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AACjD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AACjC,kEAAkE;AAClE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAqLrC,8EAA8E;AAE9E,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAU,CAAC;AAoBpF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAsFtH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAU,CAAC;AAE1E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAU,CAAC;AAE9D,wGAAwG;AACxG,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AAwBnG,qHAAqH;AACrH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,YAAY,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,mBAAmB;IACjG,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,eAAe,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,UAAU;IACjM,wBAAwB;CAChB,CAAC"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import type { PaginationQuery } from './options';
|
|
2
|
+
import type { AttachmentInput, PostType, StoryBackground } from './models';
|
|
3
|
+
export type CustomEmojiKind = 'emoji' | 'sticker';
|
|
4
|
+
/** Owner-console item (`/chats/links/:linkId/emojis`). */
|
|
5
|
+
export interface CustomEmoji {
|
|
6
|
+
_id: string;
|
|
7
|
+
kind: CustomEmojiKind;
|
|
8
|
+
/** `[a-z0-9_]{2,32}`, unique per link across both kinds. */
|
|
9
|
+
shortcode: string;
|
|
10
|
+
url: string;
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
animated: boolean;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
mimeType: string;
|
|
16
|
+
sizeBytes: number;
|
|
17
|
+
createdAt: string;
|
|
18
|
+
updatedAt: string;
|
|
19
|
+
}
|
|
20
|
+
/** Body for `createLinkEmoji`. Emoji: 16–128 px, ≤256 KB; sticker: 64–512 px, ≤512 KB. */
|
|
21
|
+
export interface CreateCustomEmojiPayload {
|
|
22
|
+
kind: CustomEmojiKind;
|
|
23
|
+
/** Trimmed + lower-cased server-side; `:Party_Parrot:` becomes `party_parrot`. */
|
|
24
|
+
shortcode: string;
|
|
25
|
+
/** Base64 data URI of a PNG, GIF or WebP (`data:image/png;base64,…`). */
|
|
26
|
+
image: string;
|
|
27
|
+
}
|
|
28
|
+
export interface UpdateCustomEmojiPayload {
|
|
29
|
+
shortcode?: string;
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface CustomEmojiQuery extends PaginationQuery {
|
|
33
|
+
kind?: CustomEmojiKind;
|
|
34
|
+
/** '1' = enabled only, '0' = disabled only. */
|
|
35
|
+
enabled?: '0' | '1';
|
|
36
|
+
}
|
|
37
|
+
export interface DeleteCustomEmojiResult {
|
|
38
|
+
deleted: true;
|
|
39
|
+
id: string;
|
|
40
|
+
}
|
|
41
|
+
/** Member-facing pack entry (`GET /in/:linkCode/emoji-pack`). */
|
|
42
|
+
export interface EmojiPackItem {
|
|
43
|
+
id: string;
|
|
44
|
+
shortcode: string;
|
|
45
|
+
url: string;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
animated: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** Enabled items only, sorted by shortcode; empty when the owner's plan lacks the feature. */
|
|
51
|
+
export interface EmojiPack {
|
|
52
|
+
linkId: string;
|
|
53
|
+
emojis: EmojiPackItem[];
|
|
54
|
+
stickers: EmojiPackItem[];
|
|
55
|
+
}
|
|
56
|
+
/** `Post.status`: DRAFT → SCHEDULED → ACTIVE (published) → ARCHIVED (expired). */
|
|
57
|
+
export type PostStatusValue = 'DRAFT' | 'SCHEDULED' | 'ACTIVE' | 'ARCHIVED' | 'DELETED';
|
|
58
|
+
/** Lower-case lifecycle used in analytics. */
|
|
59
|
+
export type PostLifecycle = 'draft' | 'scheduled' | 'published' | 'expired';
|
|
60
|
+
/** FOLLOWERS: only the author's followers in the post's link. */
|
|
61
|
+
export type PostVisibilityValue = 'LINK_MEMBERS' | 'PUBLIC' | 'FOLLOWERS';
|
|
62
|
+
/** Body for owner `POST /posts` (backend `CreatePostDto`). */
|
|
63
|
+
export interface CreateOwnerPostPayload {
|
|
64
|
+
type: PostType;
|
|
65
|
+
content?: string;
|
|
66
|
+
caption?: string;
|
|
67
|
+
attachments?: AttachmentInput[];
|
|
68
|
+
/** PROMOTION only. */
|
|
69
|
+
cta?: {
|
|
70
|
+
label: string;
|
|
71
|
+
url: string;
|
|
72
|
+
};
|
|
73
|
+
memberId?: string;
|
|
74
|
+
chatLinkCode?: string;
|
|
75
|
+
expiresAt?: string;
|
|
76
|
+
visibility?: PostVisibilityValue;
|
|
77
|
+
/** ISO date 1 minute to 1 year ahead; creates a SCHEDULED post (wins over asDraft). */
|
|
78
|
+
scheduledAt?: string;
|
|
79
|
+
/** Save as DRAFT. */
|
|
80
|
+
asDraft?: boolean;
|
|
81
|
+
/** Default true; false = only the author can reply. */
|
|
82
|
+
allowReplies?: boolean;
|
|
83
|
+
/** STORY only. */
|
|
84
|
+
background?: StoryBackground;
|
|
85
|
+
}
|
|
86
|
+
export interface SchedulePostPayload {
|
|
87
|
+
/** ISO date 1 minute to 1 year ahead. */
|
|
88
|
+
scheduledAt: string;
|
|
89
|
+
/** ISO date after scheduledAt (stories default to 24 h after go-live). */
|
|
90
|
+
expiresAt?: string;
|
|
91
|
+
}
|
|
92
|
+
/** Returned by `schedulePost` and `cancelPostSchedule`. */
|
|
93
|
+
export interface PostScheduleResult {
|
|
94
|
+
_id: string;
|
|
95
|
+
type: PostType;
|
|
96
|
+
status: PostStatusValue;
|
|
97
|
+
scheduledAt?: string | null;
|
|
98
|
+
publishedAt?: string | null;
|
|
99
|
+
expiresAt?: string | null;
|
|
100
|
+
createdAt: string;
|
|
101
|
+
updatedAt: string;
|
|
102
|
+
}
|
|
103
|
+
export interface OwnerPostQuery extends PaginationQuery {
|
|
104
|
+
/** One of DRAFT, SCHEDULED, ACTIVE, ARCHIVED. Default ACTIVE. */
|
|
105
|
+
postByStatuses?: PostStatusValue;
|
|
106
|
+
postByTypes?: PostType;
|
|
107
|
+
postByMemberId?: string;
|
|
108
|
+
}
|
|
109
|
+
/** `POST /promos/:postId/click` — call first, then open `url`. */
|
|
110
|
+
export interface PromoClickResult {
|
|
111
|
+
counted: boolean;
|
|
112
|
+
/** First click for this visitor this UTC day. */
|
|
113
|
+
unique: boolean;
|
|
114
|
+
url: string;
|
|
115
|
+
}
|
|
116
|
+
export interface PromoStatTotals {
|
|
117
|
+
impressions: number;
|
|
118
|
+
clicks: number;
|
|
119
|
+
uniqueClicks: number;
|
|
120
|
+
/** uniqueClicks / impressions, 0–1, 4 decimals (0 with no impressions). */
|
|
121
|
+
ctr: number;
|
|
122
|
+
}
|
|
123
|
+
export interface PromoStatDay extends PromoStatTotals {
|
|
124
|
+
/** `yyyy-MM-dd` (UTC). */
|
|
125
|
+
day: string;
|
|
126
|
+
}
|
|
127
|
+
export interface PromoAnalytics {
|
|
128
|
+
postId: string;
|
|
129
|
+
status: PostStatusValue;
|
|
130
|
+
lifecycle: PostLifecycle;
|
|
131
|
+
windowDays: number;
|
|
132
|
+
from: string;
|
|
133
|
+
to: string;
|
|
134
|
+
totals: PromoStatTotals;
|
|
135
|
+
lifetime: PromoStatTotals;
|
|
136
|
+
/** Oldest first, zero-filled, `windowDays` entries. */
|
|
137
|
+
days: PromoStatDay[];
|
|
138
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/types/content.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token auto-refresh loop. Mirrors the 60-second tick the official
|
|
3
|
+
* mobile shell runs in `libraries/chatta-apps/chatta-mobile/src/app.js`.
|
|
4
|
+
*
|
|
5
|
+
* The shell owns the refresh schedule (because it survives across
|
|
6
|
+
* iframe reloads) and pushes new tokens INTO the chat via
|
|
7
|
+
* `bridge.send('restoreSession', { ... })`. Use this when you're
|
|
8
|
+
* building your own native shell that wraps `LiveChatta.ui()` —
|
|
9
|
+
* call `start()` once and the SDK keeps tokens fresh.
|
|
10
|
+
*/
|
|
11
|
+
import type { Bridge } from './Bridge';
|
|
12
|
+
export interface AutoRefreshConfig {
|
|
13
|
+
/** Tick interval in ms. Default: 60_000 (60s). */
|
|
14
|
+
intervalMs?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Refresh when remaining lifetime drops below this fraction of the
|
|
17
|
+
* total lifetime. Default: 0.2 (20% — i.e. when 80% of the token's
|
|
18
|
+
* lifetime has elapsed).
|
|
19
|
+
*/
|
|
20
|
+
threshold?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Async function that performs the refresh. Returns the new tokens
|
|
23
|
+
* (or `null` when refresh failed / no refresh token available).
|
|
24
|
+
*/
|
|
25
|
+
refresh: (oldRefreshToken: string) => Promise<{
|
|
26
|
+
accessToken: string;
|
|
27
|
+
refreshToken?: string;
|
|
28
|
+
expireInSeconds?: number;
|
|
29
|
+
} | null>;
|
|
30
|
+
/** Source-of-truth getter for the current tokens. */
|
|
31
|
+
getTokens: () => {
|
|
32
|
+
accessToken: string | null;
|
|
33
|
+
refreshToken: string | null;
|
|
34
|
+
tokenIssuedAt: number | null;
|
|
35
|
+
tokenExpiresAt: number | null;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Called with the new tokens after a successful refresh — host should
|
|
39
|
+
* persist them and (optionally) push into the iframe via `bridge.send('restoreSession', ...)`.
|
|
40
|
+
*/
|
|
41
|
+
onRefreshed: (tokens: {
|
|
42
|
+
accessToken: string;
|
|
43
|
+
refreshToken?: string;
|
|
44
|
+
expireInSeconds?: number;
|
|
45
|
+
}) => void;
|
|
46
|
+
}
|
|
47
|
+
export declare class AutoRefresh {
|
|
48
|
+
private readonly cfg;
|
|
49
|
+
private timer;
|
|
50
|
+
private inflight;
|
|
51
|
+
constructor(cfg: AutoRefreshConfig);
|
|
52
|
+
start(): void;
|
|
53
|
+
stop(): void;
|
|
54
|
+
/** True when the current access token is past its refresh threshold. */
|
|
55
|
+
shouldRefresh(): boolean;
|
|
56
|
+
/** Force a refresh attempt right now (regardless of the threshold). */
|
|
57
|
+
refreshNow(): Promise<void>;
|
|
58
|
+
private tick;
|
|
59
|
+
/**
|
|
60
|
+
* Convenience — push the refreshed tokens straight into a `Bridge` so
|
|
61
|
+
* the embedded chat re-authenticates on the WebSocket immediately.
|
|
62
|
+
*/
|
|
63
|
+
static pushToBridge(bridge: Bridge, tokens: {
|
|
64
|
+
accessToken: string;
|
|
65
|
+
refreshToken?: string;
|
|
66
|
+
expireInSeconds?: number;
|
|
67
|
+
}): void;
|
|
68
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { RuntimeInfo } from '../utils/platform';
|
|
2
|
+
import type { LinkUnavailablePayload } from '../types/chat-core';
|
|
3
|
+
import type { InboundEventMap, NativeCallAction } from './events';
|
|
4
|
+
/** Frozen webview contract payload (docs/webview-theme.md in chatta). */
|
|
5
|
+
export interface ThemeLoadedPayload {
|
|
6
|
+
/** Chat-link brand colour (legacy field, kept). */
|
|
7
|
+
primaryColor: string;
|
|
8
|
+
secondaryColor?: string;
|
|
9
|
+
/** Effective theme the frame rendered. */
|
|
10
|
+
mode?: 'light' | 'dark';
|
|
11
|
+
/** User preference. */
|
|
12
|
+
themeMode?: 'light' | 'dark' | 'system';
|
|
13
|
+
}
|
|
14
|
+
type BridgeListener = (payload: any) => void;
|
|
15
|
+
export interface BridgeMessage<T = any> {
|
|
16
|
+
type: string;
|
|
17
|
+
payload?: T;
|
|
18
|
+
callId?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class Bridge {
|
|
21
|
+
private iframe;
|
|
22
|
+
private allowedOrigin;
|
|
23
|
+
private warned;
|
|
24
|
+
private listeners;
|
|
25
|
+
private boundMessageHandler;
|
|
26
|
+
private nextCallId;
|
|
27
|
+
private pendingCalls;
|
|
28
|
+
readonly runtime: RuntimeInfo;
|
|
29
|
+
/** `allowedOrigin` is the chat's origin (a base URL is reduced to its origin). Without one, nothing is sent and nothing is accepted. */
|
|
30
|
+
constructor(opts: {
|
|
31
|
+
allowedOrigin?: string;
|
|
32
|
+
});
|
|
33
|
+
/** Bind to an iframe — start listening for inbound CHATTA_APP messages. */
|
|
34
|
+
attach(iframe: HTMLIFrameElement): void;
|
|
35
|
+
detach(): void;
|
|
36
|
+
/** Listen for an outbound message from the chat (without the `CHATTA_APP:` prefix). */
|
|
37
|
+
on(method: string, listener: BridgeListener): () => void;
|
|
38
|
+
/** One developer warning per bridge, so a misconfiguration is visible without flooding the console. */
|
|
39
|
+
private warnOnce;
|
|
40
|
+
/**
|
|
41
|
+
* The only address a message may go to: the origin of the iframe's own `src`, and only when it is the allowed origin.
|
|
42
|
+
* Never '*'. null (and no message) when the iframe, the allowed origin or a matching src is missing.
|
|
43
|
+
*/
|
|
44
|
+
private targetOrigin;
|
|
45
|
+
/** Send a message INTO the chat (e.g. `restoreSession`, `hopInvite`). Returns false when it was not sent. */
|
|
46
|
+
send(method: string, payload?: any): boolean;
|
|
47
|
+
/** Called when the chat asks the shell to open the workspace drawer. */
|
|
48
|
+
onOpenWorkspaceDrawer(cb: () => void): () => void;
|
|
49
|
+
/** Called when the chat reports a new unread-message count. */
|
|
50
|
+
onUnreadChange(cb: (payload: {
|
|
51
|
+
count: number;
|
|
52
|
+
}) => void): () => void;
|
|
53
|
+
/** Called when the chat user successfully logs in — provides fresh tokens. */
|
|
54
|
+
onLoginSuccess(cb: (payload: {
|
|
55
|
+
accessToken: string;
|
|
56
|
+
refreshToken: string;
|
|
57
|
+
expireInSeconds: number;
|
|
58
|
+
}) => void): () => void;
|
|
59
|
+
/** Called when the chat user logs out — shell should drop stored tokens. */
|
|
60
|
+
onLogout(cb: () => void): () => void;
|
|
61
|
+
/** Called when the chat loads its theme so the shell can tint its chrome. */
|
|
62
|
+
onThemeLoaded(cb: (payload: ThemeLoadedPayload) => void): () => void;
|
|
63
|
+
/** Called when the chat requests OS-level screenshot protection be toggled. */
|
|
64
|
+
onScreenshotProtection(cb: (payload: {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
}) => void): () => void;
|
|
67
|
+
/** Called when the chat asks the shell to deliver a push notification. */
|
|
68
|
+
onNotify(cb: (payload: {
|
|
69
|
+
title: string;
|
|
70
|
+
body: string;
|
|
71
|
+
conversationId?: string;
|
|
72
|
+
}) => void): () => void;
|
|
73
|
+
/** Called when a hop (voice/video) call starts. */
|
|
74
|
+
onHopStartCall(cb: (payload: {
|
|
75
|
+
sessionId: string;
|
|
76
|
+
}) => void): () => void;
|
|
77
|
+
/** Called when a hop call ends. */
|
|
78
|
+
onHopEndCall(cb: () => void): () => void;
|
|
79
|
+
/** Mic state changed in the call: mirror it on CallKit / Telecom. */
|
|
80
|
+
onHopMuteChanged(cb: (payload: {
|
|
81
|
+
sessionId: string;
|
|
82
|
+
muted: boolean;
|
|
83
|
+
}) => void): () => void;
|
|
84
|
+
/** Called when the link is expired, disabled or archived (chat route answered 410). */
|
|
85
|
+
onLinkUnavailable(cb: (payload: LinkUnavailablePayload) => void): () => void;
|
|
86
|
+
/**
|
|
87
|
+
* Send refreshed tokens into the chat iframe after a background token refresh.
|
|
88
|
+
* Mirrors the Capacitor / Tauri `CHATTA_APP:restoreSession` message so the
|
|
89
|
+
* embedded chat re-authenticates without a page reload.
|
|
90
|
+
*/
|
|
91
|
+
restoreSession(tokens: {
|
|
92
|
+
accessToken: string;
|
|
93
|
+
refreshToken: string;
|
|
94
|
+
expireInSeconds: number;
|
|
95
|
+
}): void;
|
|
96
|
+
/**
|
|
97
|
+
* Forward an incoming hop call invite into the chat iframe.
|
|
98
|
+
* Call this when your shell receives a push notification for an incoming call.
|
|
99
|
+
*/
|
|
100
|
+
sendHopInvite(payload: {
|
|
101
|
+
sessionId: string;
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
}): void;
|
|
104
|
+
/**
|
|
105
|
+
* Notify the chat that an app update is ready for install.
|
|
106
|
+
* The chat can display an in-app banner/prompt to the user.
|
|
107
|
+
*/
|
|
108
|
+
notifyUpdateReady(payload: {
|
|
109
|
+
version: string;
|
|
110
|
+
notes?: string;
|
|
111
|
+
}): void;
|
|
112
|
+
/** Tell the chat the shell rings calls natively (send once after load, with any `shortcuts`). */
|
|
113
|
+
sendInit(payload: InboundEventMap['init']): void;
|
|
114
|
+
/** Native call UI event for `sessionId` (ids are `[A-Za-z0-9_-]{1,64}`); false when not sent. */
|
|
115
|
+
sendNativeCall(action: NativeCallAction, sessionId: string): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Share files into the open conversation's composer (`CHATTA_APP:shareFiles`). Keeps the first 10 `File`s
|
|
118
|
+
* and 4000 chars of `text`; the link's upload rules apply. Needs an allowed origin; false when not sent. */
|
|
119
|
+
shareFiles(files: File[], text?: string): boolean;
|
|
120
|
+
/** Send a request and await a `CHATTA_APP:response` matching the callId. */
|
|
121
|
+
request<T = any>(method: string, payload?: any, timeoutMs?: number): Promise<T>;
|
|
122
|
+
private handleIncoming;
|
|
123
|
+
}
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { InitOptions } from '../types';
|
|
2
|
+
export declare class Config {
|
|
3
|
+
readonly linkCode: string;
|
|
4
|
+
readonly apiKey: string;
|
|
5
|
+
readonly baseUrl: string;
|
|
6
|
+
readonly chatUsername?: string;
|
|
7
|
+
readonly publicKey: string;
|
|
8
|
+
readonly enableSocket: boolean;
|
|
9
|
+
readonly enableHttp: boolean;
|
|
10
|
+
readonly debug: boolean;
|
|
11
|
+
readonly ownerToken?: string;
|
|
12
|
+
readonly memberToken?: string;
|
|
13
|
+
constructor(options: InitOptions);
|
|
14
|
+
/** Build the WebSocket URL */
|
|
15
|
+
get wsUrl(): string;
|
|
16
|
+
/** Build the REST API base URL */
|
|
17
|
+
get apiUrl(): string;
|
|
18
|
+
/** Server root (for `/in/*` public routes). */
|
|
19
|
+
get rootUrl(): string;
|
|
20
|
+
/** Build the external API base URL */
|
|
21
|
+
get externalUrl(): string;
|
|
22
|
+
/** Build the web embed/chat UI URL — `/in/:linkCode/embed/chat`. */
|
|
23
|
+
get embedUrl(): string;
|
|
24
|
+
/** Build the native-app embed/chat UI URL — `/in/:linkCode/app/embed/chat`. */
|
|
25
|
+
get appEmbedUrl(): string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep-link parser + dispatcher.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors `parseDeepLink()` in `libraries/chatta-app-shared/deeplink-router.js`
|
|
5
|
+
* so SDK consumers can route URLs the same way the official LiveChatta
|
|
6
|
+
* shells do without re-implementing the parser per platform.
|
|
7
|
+
*
|
|
8
|
+
* Supported schemes:
|
|
9
|
+
* chatta://open/<linkCode>
|
|
10
|
+
* chatta://chat/<linkCode>/<conversationId>
|
|
11
|
+
* chatta://reset/<token>
|
|
12
|
+
* https://livechatta.com/in/<linkCode>(/chat|/embed/chat|/app/embed/chat)?[?conv=<id>]
|
|
13
|
+
*/
|
|
14
|
+
export interface DeepLinkPayload {
|
|
15
|
+
kind: 'open' | 'chat' | 'reset' | 'unknown';
|
|
16
|
+
linkCode?: string;
|
|
17
|
+
conversationId?: string;
|
|
18
|
+
resetToken?: string;
|
|
19
|
+
/** Original URL string the parser ran against. */
|
|
20
|
+
raw: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parse a deep-link URL into a structured payload. Returns `kind: 'unknown'`
|
|
24
|
+
* when no recognised pattern matches — caller should fall back to default
|
|
25
|
+
* navigation in that case.
|
|
26
|
+
*/
|
|
27
|
+
export declare function parseDeepLink(url: string): DeepLinkPayload;
|
|
28
|
+
export type DeepLinkListener = (payload: DeepLinkPayload) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Pluggable dispatcher. Platform adapters (Capacitor `App.appUrlOpen`,
|
|
31
|
+
* Tauri `deep-link://new-url`, web `window.location`) call `dispatch(url)`,
|
|
32
|
+
* subscribers added via `on(cb)` get the parsed payload.
|
|
33
|
+
*/
|
|
34
|
+
export declare class DeepLinks {
|
|
35
|
+
private listeners;
|
|
36
|
+
on(cb: DeepLinkListener): () => void;
|
|
37
|
+
dispatch(url: string): DeepLinkPayload;
|
|
38
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Listener = (...args: any[]) => void;
|
|
2
|
+
/**
|
|
3
|
+
* Lightweight, zero-dependency event emitter for SDK lifecycle events.
|
|
4
|
+
* Works in browser, Node.js, React Native, and all JS runtimes.
|
|
5
|
+
*/
|
|
6
|
+
export declare class EventBus {
|
|
7
|
+
private listeners;
|
|
8
|
+
private onceListeners;
|
|
9
|
+
on(event: string, fn: Listener): this;
|
|
10
|
+
once(event: string, fn: Listener): this;
|
|
11
|
+
off(event: string, fn?: Listener): this;
|
|
12
|
+
emit(event: string, ...args: any[]): this;
|
|
13
|
+
removeAllListeners(): this;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform persistent store for permission grants.
|
|
3
|
+
* - Capacitor → @capacitor/preferences
|
|
4
|
+
* - Tauri → tauri-plugin-store (via host-supplied invoke)
|
|
5
|
+
* - Web / Node → localStorage (web) or in-memory (node)
|
|
6
|
+
*
|
|
7
|
+
* Mirrors the `chatta-bridge-grants` localStorage key the official mobile
|
|
8
|
+
* shell already writes; the SDK stores under the same key so a host that
|
|
9
|
+
* upgrades from raw bridge code to the SDK keeps existing user grants.
|
|
10
|
+
*/
|
|
11
|
+
export type GrantMap = Record<string, boolean>;
|
|
12
|
+
interface StorageBackend {
|
|
13
|
+
load(): Promise<GrantMap>;
|
|
14
|
+
save(grants: GrantMap): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare class GrantStore {
|
|
17
|
+
private backend;
|
|
18
|
+
private cache;
|
|
19
|
+
constructor(backend?: StorageBackend);
|
|
20
|
+
/** Use the Capacitor backend (only call when running inside Capacitor). */
|
|
21
|
+
static withCapacitor(): GrantStore;
|
|
22
|
+
/** In-memory backend — useful for tests and Node SSR. */
|
|
23
|
+
static inMemory(): GrantStore;
|
|
24
|
+
getAll(): Promise<GrantMap>;
|
|
25
|
+
get(kind: string): Promise<boolean>;
|
|
26
|
+
set(kind: string, granted: boolean): Promise<void>;
|
|
27
|
+
clear(): Promise<void>;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Config } from './Config';
|
|
2
|
+
import { Permissions } from './Permissions';
|
|
3
|
+
import { SocketAPI } from '../socket/SocketAPI';
|
|
4
|
+
import { HttpAPI } from '../http/HttpAPI';
|
|
5
|
+
import { ConnectionState } from '../types/models';
|
|
6
|
+
import { SDKEvent } from '../types/events';
|
|
7
|
+
import { type AppSignature } from '../utils/hmac';
|
|
8
|
+
import { type RuntimeInfo } from '../utils/platform';
|
|
9
|
+
import type { InitOptions, UIOptions, ThemeOptions } from '../types/options';
|
|
10
|
+
import type { Bridge } from './Bridge';
|
|
11
|
+
declare class LiveChattaSDK {
|
|
12
|
+
private config;
|
|
13
|
+
private tokenManager;
|
|
14
|
+
private eventBus;
|
|
15
|
+
private socketTransport;
|
|
16
|
+
private socketAPI;
|
|
17
|
+
private httpTransport;
|
|
18
|
+
private httpAPI;
|
|
19
|
+
private embedUI;
|
|
20
|
+
private permissionsApi;
|
|
21
|
+
private initialized;
|
|
22
|
+
/**
|
|
23
|
+
* Initialize the SDK with connection options.
|
|
24
|
+
* Must be called before using sock(), api(), or ui().
|
|
25
|
+
*/
|
|
26
|
+
init(options: InitOptions): this;
|
|
27
|
+
/**
|
|
28
|
+
* Connect the WebSocket transport.
|
|
29
|
+
* Call this after init() when you're ready to establish a live connection.
|
|
30
|
+
*/
|
|
31
|
+
connect(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Disconnect the WebSocket transport.
|
|
34
|
+
*/
|
|
35
|
+
disconnect(): void;
|
|
36
|
+
/**
|
|
37
|
+
* Get the Socket API for real-time messaging.
|
|
38
|
+
* Provides emitters (sendMessage, typing, etc.) and listeners (onMessage, onTyping, etc.)
|
|
39
|
+
*/
|
|
40
|
+
sock(): SocketAPI;
|
|
41
|
+
/**
|
|
42
|
+
* Get the HTTP API for RESTful operations.
|
|
43
|
+
* All methods are async and return typed responses.
|
|
44
|
+
*/
|
|
45
|
+
api(): HttpAPI;
|
|
46
|
+
/**
|
|
47
|
+
* Mount the embedded chat UI — inline into `container`, or as a floating launcher with
|
|
48
|
+
* `floating: true`. Resolves with the iframe (async: the embed token is encrypted first). */
|
|
49
|
+
ui(options: UIOptions): Promise<HTMLIFrameElement>;
|
|
50
|
+
/**
|
|
51
|
+
* Unmount the embedded chat UI.
|
|
52
|
+
*/
|
|
53
|
+
unmountUI(): void;
|
|
54
|
+
/** Update the embedded UI theme at runtime (colours, font, logo, `theme` light/dark/system). */
|
|
55
|
+
updateTheme(options: Partial<ThemeOptions>): Promise<void>;
|
|
56
|
+
/** Open the floating chat panel (no-op for inline embeds). */
|
|
57
|
+
open(): void;
|
|
58
|
+
/** Close the floating chat panel and return focus to the launcher. */
|
|
59
|
+
close(): void;
|
|
60
|
+
/** Toggle the floating chat panel. */
|
|
61
|
+
toggle(): void;
|
|
62
|
+
/** Whether the floating chat panel is open. */
|
|
63
|
+
isOpen(): boolean;
|
|
64
|
+
/** Set the launcher unread badge yourself (0 hides it); the chat frame also reports it. */
|
|
65
|
+
setUnread(count: number): void;
|
|
66
|
+
/**
|
|
67
|
+
* Register a listener for SDK lifecycle events.
|
|
68
|
+
* Events: 'sdk:connected', 'sdk:disconnected', 'sdk:reconnecting', 'sdk:reconnected', 'sdk:error'
|
|
69
|
+
*/
|
|
70
|
+
on(event: SDKEvent | string, callback: (...args: any[]) => void): this;
|
|
71
|
+
/**
|
|
72
|
+
* Remove a listener for SDK lifecycle events.
|
|
73
|
+
*/
|
|
74
|
+
off(event: SDKEvent | string, callback?: (...args: any[]) => void): this;
|
|
75
|
+
/**
|
|
76
|
+
* Check if the SDK has been initialized.
|
|
77
|
+
*/
|
|
78
|
+
isInitialized(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Check if the socket is connected.
|
|
81
|
+
*/
|
|
82
|
+
isConnected(): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Get the current WebSocket connection state.
|
|
85
|
+
*/
|
|
86
|
+
getConnectionState(): ConnectionState;
|
|
87
|
+
/**
|
|
88
|
+
* Get the current configuration (read-only).
|
|
89
|
+
*/
|
|
90
|
+
getConfig(): Config | null;
|
|
91
|
+
/**
|
|
92
|
+
* HMAC proof that a request comes from a LiveChatta-built native app, for the `x-chatta-app`
|
|
93
|
+
* header or `?_app_sig=`. Uses init()'s apiKey + linkCode; pass platform + version. */
|
|
94
|
+
signAppRequest(opts: {
|
|
95
|
+
platform: string;
|
|
96
|
+
version: string;
|
|
97
|
+
}): Promise<AppSignature>;
|
|
98
|
+
/**
|
|
99
|
+
* Encrypted auto-login token for `?token=` when building your own embed URL (most callers
|
|
100
|
+
* should use ui()). Defaults to init()'s chatUsername; overrides allowed. */
|
|
101
|
+
buildUserToken(overrides?: {
|
|
102
|
+
chatUsername?: string;
|
|
103
|
+
conversationId?: string;
|
|
104
|
+
}): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* postMessage bridge into the mounted iframe: chat → host events (drawer, unread, notify…)
|
|
107
|
+
* and host → chat (restoreSession, hopInvite). Null until ui() has been called. */
|
|
108
|
+
get bridge(): Bridge | null;
|
|
109
|
+
/**
|
|
110
|
+
* Per-platform media + notification permission helpers. Available
|
|
111
|
+
* even before `ui()` is mounted so callers can pre-warm permissions
|
|
112
|
+
* during onboarding (e.g. before showing a "Start call" button).
|
|
113
|
+
*/
|
|
114
|
+
get permissions(): Permissions;
|
|
115
|
+
/**
|
|
116
|
+
* Detected runtime info (kind + platform + isAppShell). Useful for
|
|
117
|
+
* branching UI when you want different behaviour in the web vs an app.
|
|
118
|
+
*/
|
|
119
|
+
get runtime(): RuntimeInfo;
|
|
120
|
+
/**
|
|
121
|
+
* Destroy the SDK instance — disconnect, unmount, and clean up.
|
|
122
|
+
*/
|
|
123
|
+
destroy(): void;
|
|
124
|
+
private assertInitialized;
|
|
125
|
+
}
|
|
126
|
+
/** Singleton instance */
|
|
127
|
+
declare const LiveChatta: LiveChattaSDK;
|
|
128
|
+
export { LiveChatta, LiveChattaSDK };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permissions — per-platform media/notification permission helpers.
|
|
3
|
+
* Same shape across web, Capacitor, Tauri, React Native — so app code
|
|
4
|
+
* never has to branch on runtime to ask "can I record audio?".
|
|
5
|
+
*
|
|
6
|
+
* Shell-side capability mirroring (Rule 61): every permission flow we
|
|
7
|
+
* add to a LiveChatta-shipped shell (Capacitor `HopBridge.requestPermissions`,
|
|
8
|
+
* Tauri Info.plist + entitlements, Android Manifest) gets reflected here
|
|
9
|
+
* so external integrators get the same auto-prompt behaviour.
|
|
10
|
+
*/
|
|
11
|
+
export type PermissionState = 'granted' | 'denied' | 'prompt' | 'unsupported';
|
|
12
|
+
export interface MediaPermissionResult {
|
|
13
|
+
granted: boolean;
|
|
14
|
+
mic: PermissionState;
|
|
15
|
+
cam: PermissionState;
|
|
16
|
+
}
|
|
17
|
+
export declare class Permissions {
|
|
18
|
+
/**
|
|
19
|
+
* Ask the OS for microphone (and optionally camera) capture.
|
|
20
|
+
* On Capacitor: drives `HopBridge.requestPermissions()` so the
|
|
21
|
+
* Android runtime dialog fires before the iframe's `getUserMedia`.
|
|
22
|
+
* On web / Tauri / RN: probes `getUserMedia` directly to surface
|
|
23
|
+
* the native browser/WKWebView prompt.
|
|
24
|
+
*/
|
|
25
|
+
requestMedia(opts?: {
|
|
26
|
+
audio?: boolean;
|
|
27
|
+
video?: boolean;
|
|
28
|
+
}): Promise<MediaPermissionResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Ask the OS for notification permission (web Notifications API or
|
|
31
|
+
* Capacitor LocalNotifications/PushNotifications). Returns the granted state.
|
|
32
|
+
*/
|
|
33
|
+
requestNotifications(): Promise<PermissionState>;
|
|
34
|
+
}
|