@livechatta/sdk 0.0.0-stage → 1.0.1
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 +228 -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 +7259 -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 +7078 -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 +7263 -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 +274 -4
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import 'livechatta_http_api.dart';
|
|
2
|
+
import 'livechatta_json.dart';
|
|
3
|
+
import 'livechatta_models.dart';
|
|
4
|
+
|
|
5
|
+
LiveChattaMessage? _message(dynamic v) {
|
|
6
|
+
final o = LcJson.object(v);
|
|
7
|
+
return o == null ? null : LiveChattaMessage.fromJson(o);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
LiveChattaOwnerMeeting? _meeting(dynamic v) {
|
|
11
|
+
final o = LcJson.object(v);
|
|
12
|
+
return o == null ? null : LiveChattaOwnerMeeting.fromJson(o);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
LiveChattaActivityNotification? _activity(dynamic v) {
|
|
16
|
+
final o = LcJson.object(v);
|
|
17
|
+
return o == null ? null : LiveChattaActivityNotification.fromJson(o);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
LiveChattaSharedChannelView? _sharedChannel(dynamic v) {
|
|
21
|
+
final o = LcJson.object(v);
|
|
22
|
+
return o == null ? null : LiveChattaSharedChannelView.fromJson(o);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/// Typed twins of the map-based calls: they take and return models instead of maps.
|
|
26
|
+
extension LiveChattaTypedApi on LiveChattaHttpAPI {
|
|
27
|
+
/// Typed twin of the deprecated sendMessage: the server sets senderId from the API key.
|
|
28
|
+
Future<LiveChattaMessage> sendMessageTyped(LiveChattaSendMessagePayload payload) async {
|
|
29
|
+
final body = payload.toJson();
|
|
30
|
+
if (payload.senderId.isEmpty) body.remove('senderId');
|
|
31
|
+
// ignore: deprecated_member_use_from_same_package
|
|
32
|
+
return LiveChattaMessage.fromJson(await sendMessage(body));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// Typed twin of the deprecated listSentMessages (conversationId is sent as chatMessageByConversationIds).
|
|
36
|
+
Future<LiveChattaPaginatedResult<LiveChattaMessage>> listSentMessagesTyped([LiveChattaSentMessagesQuery? query]) async {
|
|
37
|
+
final q = <String, String>{
|
|
38
|
+
if (query?.conversationId != null) 'chatMessageByConversationIds': query!.conversationId!,
|
|
39
|
+
if (query?.nextCursor != null) 'nextCursor': query!.nextCursor!,
|
|
40
|
+
if (query?.prevCursor != null) 'prevCursor': query!.prevCursor!,
|
|
41
|
+
if (query?.limit != null) 'limit': query!.limit!,
|
|
42
|
+
};
|
|
43
|
+
// ignore: deprecated_member_use_from_same_package
|
|
44
|
+
final res = await listSentMessages(query: q);
|
|
45
|
+
return LiveChattaPaginatedResult.fromJson<LiveChattaMessage>(res, _message);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/// A link's meetings (owner token).
|
|
49
|
+
Future<LiveChattaPaginatedResult<LiveChattaOwnerMeeting>> listMeetingsTyped(String linkId, {String? status, int? limit, String? nextCursor}) async {
|
|
50
|
+
final res = await listMeetings(linkId, status: status, limit: limit, nextCursor: nextCursor);
|
|
51
|
+
return LiveChattaPaginatedResult.fromJson<LiveChattaOwnerMeeting>(res, _meeting);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/// Schedule a meeting from a typed request (owner token); the same idempotencyKey replays the first result.
|
|
55
|
+
Future<LiveChattaScheduledOwnerMeeting> scheduleMeetingTyped(LiveChattaScheduleOwnerMeetingPayload payload, {String? idempotencyKey}) async =>
|
|
56
|
+
LiveChattaScheduledOwnerMeeting.fromJson(await scheduleMeeting(payload.toJson(), idempotencyKey: idempotencyKey));
|
|
57
|
+
|
|
58
|
+
/// Cancel a meeting (owner token); repeating it is safe.
|
|
59
|
+
Future<LiveChattaOwnerMeetingCancelResult> cancelMeetingTyped(String meetingId, {String? reason}) async =>
|
|
60
|
+
LiveChattaOwnerMeetingCancelResult.fromJson(await cancelMeeting(meetingId, reason: reason));
|
|
61
|
+
|
|
62
|
+
/// A link's meetings with the API key (/external/meetings).
|
|
63
|
+
Future<LiveChattaPaginatedResult<LiveChattaOwnerMeeting>> listMeetingsWithKeyTyped(String linkId, {String? status, int? limit, String? nextCursor}) async {
|
|
64
|
+
final res = await listMeetingsWithKey(linkId, status: status, limit: limit, nextCursor: nextCursor);
|
|
65
|
+
return LiveChattaPaginatedResult.fromJson<LiveChattaOwnerMeeting>(res, _meeting);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/// Schedule a meeting with the API key (/external/meetings).
|
|
69
|
+
Future<LiveChattaScheduledOwnerMeeting> scheduleMeetingWithKeyTyped(LiveChattaScheduleOwnerMeetingPayload payload, {String? idempotencyKey}) async =>
|
|
70
|
+
LiveChattaScheduledOwnerMeeting.fromJson(await scheduleMeetingWithKey(payload.toJson(), idempotencyKey: idempotencyKey));
|
|
71
|
+
|
|
72
|
+
/// Cancel a meeting with the API key (/external/meetings).
|
|
73
|
+
Future<LiveChattaOwnerMeetingCancelResult> cancelMeetingWithKeyTyped(String meetingId, {String? reason}) async =>
|
|
74
|
+
LiveChattaOwnerMeetingCancelResult.fromJson(await cancelMeetingWithKey(meetingId, reason: reason));
|
|
75
|
+
|
|
76
|
+
/// Deliveries kept while you listen to a webhook (owner token).
|
|
77
|
+
Future<LiveChattaWebhookCaptureView> readWebhookCaptureTyped(String webhookId, {int after = 0}) async =>
|
|
78
|
+
LiveChattaWebhookCaptureView.fromJson(await readWebhookCapture(webhookId, after: after));
|
|
79
|
+
|
|
80
|
+
/// Your links as a typed page (member token).
|
|
81
|
+
Future<LiveChattaMyChatLinksPage> listMyChatLinksTyped({Map<String, String>? query}) async =>
|
|
82
|
+
LiveChattaMyChatLinksPage.fromJson(await listMyChatLinks(query: query));
|
|
83
|
+
|
|
84
|
+
/// Your calendar sync status as a typed model (member token).
|
|
85
|
+
Future<LiveChattaCalendarSyncStatus> getCalendarSyncStatusTyped() async =>
|
|
86
|
+
LiveChattaCalendarSyncStatus.fromJson(await getCalendarSyncStatus());
|
|
87
|
+
|
|
88
|
+
/// Busy blocks of members who share their calendar, as a typed model (member token).
|
|
89
|
+
Future<LiveChattaCalendarBusy> getCalendarBusyTyped(List<String> userIds, String from, String to) async =>
|
|
90
|
+
LiveChattaCalendarBusy.fromJson(await getCalendarBusy(userIds, from, to));
|
|
91
|
+
|
|
92
|
+
/// Mentions and reactions as a typed page (member or owner token).
|
|
93
|
+
Future<LiveChattaPaginatedResult<LiveChattaActivityNotification>> listActivityTyped({Map<String, String>? query}) async =>
|
|
94
|
+
LiveChattaPaginatedResult.fromJson<LiveChattaActivityNotification>(await listActivity(query: query), _activity);
|
|
95
|
+
|
|
96
|
+
/// GIF picker settings as a typed model (member or owner token; enabled=false when GIF search is off).
|
|
97
|
+
Future<LiveChattaGifConfigView> getGifConfigTyped() async =>
|
|
98
|
+
LiveChattaGifConfigView.fromJson(await getGifConfig());
|
|
99
|
+
|
|
100
|
+
/// Search GIFs as a typed page; the LiveChatta pack answers when no provider is set; `source` is livechatta or provider (member or owner token).
|
|
101
|
+
Future<LiveChattaGifPage> searchGifsTyped({String? q, String? nextCursor, String? source}) async =>
|
|
102
|
+
LiveChattaGifPage.fromJson(await searchGifs(q: q, nextCursor: nextCursor, source: source));
|
|
103
|
+
|
|
104
|
+
/// Trending GIFs as a typed page (member or owner token).
|
|
105
|
+
Future<LiveChattaGifPage> trendingGifsTyped({String? nextCursor, String? source}) async =>
|
|
106
|
+
LiveChattaGifPage.fromJson(await trendingGifs(nextCursor: nextCursor, source: source));
|
|
107
|
+
|
|
108
|
+
/// Tell the provider a GIF was sent, as a typed result (member or owner token).
|
|
109
|
+
Future<LiveChattaGifShareResult> registerGifShareTyped(String provider, String id, {String? q}) async =>
|
|
110
|
+
LiveChattaGifShareResult.fromJson(await registerGifShare(provider, id, q: q));
|
|
111
|
+
|
|
112
|
+
/// The incoming webhooks of a group or channel, as a typed page (API key).
|
|
113
|
+
Future<LiveChattaIncomingWebhookPage> listIncomingWebhooksTyped(String conversationId, {String? status, int? limit, String? nextCursor}) async =>
|
|
114
|
+
LiveChattaIncomingWebhookPage.fromJson(await listIncomingWebhooks(conversationId, status: status, limit: limit, nextCursor: nextCursor));
|
|
115
|
+
|
|
116
|
+
/// Make an incoming webhook, as a typed result: the one-time `url` is in it (API key).
|
|
117
|
+
Future<LiveChattaIncomingWebhook> createIncomingWebhookTyped(String conversationId, LiveChattaCreateIncomingWebhookPayload payload) async =>
|
|
118
|
+
LiveChattaIncomingWebhook.fromJson(await createIncomingWebhook(conversationId, payload.toJson()));
|
|
119
|
+
|
|
120
|
+
/// Rename an incoming webhook, as a typed result (API key).
|
|
121
|
+
Future<LiveChattaIncomingWebhook> updateIncomingWebhookTyped(String conversationId, String hookId, LiveChattaUpdateIncomingWebhookPayload payload) async =>
|
|
122
|
+
LiveChattaIncomingWebhook.fromJson(await updateIncomingWebhook(conversationId, hookId, payload.toJson()));
|
|
123
|
+
|
|
124
|
+
/// Swap an incoming webhook's secret, as a typed result: the new one-time `url` is in it (API key).
|
|
125
|
+
Future<LiveChattaIncomingWebhook> regenerateIncomingWebhookTyped(String conversationId, String hookId) async =>
|
|
126
|
+
LiveChattaIncomingWebhook.fromJson(await regenerateIncomingWebhook(conversationId, hookId));
|
|
127
|
+
|
|
128
|
+
/// Revoke an incoming webhook, as a typed result (API key).
|
|
129
|
+
Future<LiveChattaIncomingWebhook> revokeIncomingWebhookTyped(String conversationId, String hookId) async =>
|
|
130
|
+
LiveChattaIncomingWebhook.fromJson(await revokeIncomingWebhook(conversationId, hookId));
|
|
131
|
+
|
|
132
|
+
/// Fold the no-email guest this device held into the signed-in member, as a typed result (member token).
|
|
133
|
+
Future<LiveChattaClaimGuestResult> claimGuestTyped(String guestToken) async =>
|
|
134
|
+
LiveChattaClaimGuestResult.fromJson(await claimGuest(guestToken));
|
|
135
|
+
|
|
136
|
+
/// Report a GIF, as a typed result (member or owner token).
|
|
137
|
+
Future<LiveChattaGifReportResult> reportGifTyped(String provider, String id, String reason, {String? note, String? messageId}) async =>
|
|
138
|
+
LiveChattaGifReportResult.fromJson(await reportGif(provider, id, reason, note: note, messageId: messageId));
|
|
139
|
+
|
|
140
|
+
/// Invite another workspace to a channel, as a typed result: the single-use token is in it once (member token).
|
|
141
|
+
Future<LiveChattaSharedChannelInviteResult> inviteSharedChannelTyped(String chatLinkId, String conversationId, {String? partnerLinkCode, int? expiresInHours}) async =>
|
|
142
|
+
LiveChattaSharedChannelInviteResult.fromJson(await inviteSharedChannel(chatLinkId, conversationId, partnerLinkCode: partnerLinkCode, expiresInHours: expiresInHours));
|
|
143
|
+
|
|
144
|
+
/// Shares of your workspace as a typed page (member token).
|
|
145
|
+
Future<LiveChattaSharedChannelPage> listSharedChannelsTyped(String chatLinkId, {String? nextCursor}) async =>
|
|
146
|
+
LiveChattaSharedChannelPage.fromJson(await listSharedChannels(chatLinkId, nextCursor: nextCursor));
|
|
147
|
+
|
|
148
|
+
/// What an invite link holds, as a typed model; looking does not use it up (member token).
|
|
149
|
+
Future<LiveChattaSharedChannelPreview> previewSharedChannelInviteTyped(String token) async =>
|
|
150
|
+
LiveChattaSharedChannelPreview.fromJson(await previewSharedChannelInvite(token));
|
|
151
|
+
|
|
152
|
+
/// People of your workspace to pick for a shared channel, as a typed page: name and handle only (member token).
|
|
153
|
+
Future<LiveChattaSharedChannelMembersPage> listSharedChannelMembersTyped(String chatLinkId, {String? q, String? sharedChannelId, String? nextCursor}) async =>
|
|
154
|
+
LiveChattaSharedChannelMembersPage.fromJson(await listSharedChannelMembers(chatLinkId, q: q, sharedChannelId: sharedChannelId, nextCursor: nextCursor));
|
|
155
|
+
|
|
156
|
+
/// The shares of one of your channels as a typed page (member token).
|
|
157
|
+
Future<LiveChattaPaginatedResult<LiveChattaSharedChannelView>> getConversationSharedChannelsTyped(String conversationId, String chatLinkId) async =>
|
|
158
|
+
LiveChattaPaginatedResult.fromJson<LiveChattaSharedChannelView>(await getConversationSharedChannels(conversationId, chatLinkId), _sharedChannel);
|
|
159
|
+
|
|
160
|
+
/// What your workspace may do in a shared channel, as a typed model (member token).
|
|
161
|
+
Future<LiveChattaSharedConversationPermissions> getSharedChannelPermissionsTyped(String conversationId, String chatLinkId) async =>
|
|
162
|
+
LiveChattaSharedConversationPermissions.fromJson(await getSharedChannelPermissions(conversationId, chatLinkId));
|
|
163
|
+
|
|
164
|
+
/// Accept an invite sent to your link code, as a typed share (member token).
|
|
165
|
+
Future<LiveChattaSharedChannelView> acceptSharedChannelTyped(String sharedChannelId, String chatLinkId, String audience, {List<String>? memberIds}) async =>
|
|
166
|
+
LiveChattaSharedChannelView.fromJson(await acceptSharedChannel(sharedChannelId, chatLinkId, audience, memberIds: memberIds));
|
|
167
|
+
|
|
168
|
+
/// Accept a single-use invite link with its token, as a typed share (member token).
|
|
169
|
+
Future<LiveChattaSharedChannelView> acceptSharedChannelByTokenTyped(String token, String chatLinkId, String audience, {List<String>? memberIds}) async =>
|
|
170
|
+
LiveChattaSharedChannelView.fromJson(await acceptSharedChannelByToken(token, chatLinkId, audience, memberIds: memberIds));
|
|
171
|
+
|
|
172
|
+
/// End a share (remove the partner, leave, cancel or decline), as a typed share (member token).
|
|
173
|
+
Future<LiveChattaSharedChannelView> endSharedChannelTyped(String sharedChannelId, String chatLinkId) async =>
|
|
174
|
+
LiveChattaSharedChannelView.fromJson(await endSharedChannel(sharedChannelId, chatLinkId));
|
|
175
|
+
|
|
176
|
+
/// Change who has the channel on the partner side, as a typed share (member token).
|
|
177
|
+
Future<LiveChattaSharedChannelView> updateSharedChannelMembersTyped(String sharedChannelId, String chatLinkId, String audience, {List<String>? memberIds}) async =>
|
|
178
|
+
LiveChattaSharedChannelView.fromJson(await updateSharedChannelMembers(sharedChannelId, chatLinkId, audience, memberIds: memberIds));
|
|
179
|
+
|
|
180
|
+
/// Your workspace's activity log for one share, as a typed page (member token).
|
|
181
|
+
Future<LiveChattaSharedChannelAuditPage> getSharedChannelAuditTyped(String sharedChannelId, String chatLinkId, {String? nextCursor}) async =>
|
|
182
|
+
LiveChattaSharedChannelAuditPage.fromJson(await getSharedChannelAudit(sharedChannelId, chatLinkId, nextCursor: nextCursor));
|
|
183
|
+
|
|
184
|
+
/// Open a direct message with a partner workspace's person, as a typed result (member token).
|
|
185
|
+
Future<LiveChattaSharedDirectResult> openSharedDirectTyped(String chatLinkId, String conversationId, String memberId) async =>
|
|
186
|
+
LiveChattaSharedDirectResult.fromJson(await openSharedDirect(chatLinkId, conversationId, memberId));
|
|
187
|
+
|
|
188
|
+
/// Host removes one partner member, as a typed share (member token).
|
|
189
|
+
Future<LiveChattaSharedChannelView> removeSharedChannelMemberTyped(String chatLinkId, String conversationId, String memberId) async =>
|
|
190
|
+
LiveChattaSharedChannelView.fromJson(await removeSharedChannelMember(chatLinkId, conversationId, memberId));
|
|
191
|
+
|
|
192
|
+
/// Wipe a message in a shared channel for everyone, as a typed result (member token).
|
|
193
|
+
Future<LiveChattaRemoveSharedMessageResult> removeSharedChannelMessageTyped(String chatLinkId, String conversationId, String messageId) async =>
|
|
194
|
+
LiveChattaRemoveSharedMessageResult.fromJson(await removeSharedChannelMessage(chatLinkId, conversationId, messageId));
|
|
195
|
+
|
|
196
|
+
/// Bind a verified teammate to their chat user, as a typed result (owner token).
|
|
197
|
+
Future<LiveChattaLinkChatUserToAccountResult> linkChatUserToAccountTyped(String accountId, String chatUserId) async =>
|
|
198
|
+
LiveChattaLinkChatUserToAccountResult.fromJson(await linkChatUserToAccount(accountId, chatUserId));
|
|
199
|
+
|
|
200
|
+
/// The app's store versions, typed; `platforms` is null on older servers.
|
|
201
|
+
Future<LiveChattaAppVersionInfo> getAppVersionTyped() async => LiveChattaAppVersionInfo.fromJson(await getAppVersion());
|
|
202
|
+
|
|
203
|
+
/// Rate a resolved support conversation, as a typed result (member token, the customer).
|
|
204
|
+
Future<LiveChattaCsatRating> submitCsatTyped(String conversationId, LiveChattaSubmitCsatPayload payload) async =>
|
|
205
|
+
LiveChattaCsatRating.fromJson(await submitCsat(conversationId, payload.toJson()));
|
|
206
|
+
|
|
207
|
+
/// Satisfaction ratings, as a typed page (API key).
|
|
208
|
+
Future<LiveChattaCsatRatingPage> listCsatRatingsTyped({Map<String, String>? query}) async =>
|
|
209
|
+
LiveChattaCsatRatingPage.fromJson(await listCsatRatings(query: query));
|
|
210
|
+
|
|
211
|
+
/// Satisfaction summary, typed (API key).
|
|
212
|
+
Future<LiveChattaCsatSummary> getCsatSummaryTyped({Map<String, String>? query}) async =>
|
|
213
|
+
LiveChattaCsatSummary.fromJson(await getCsatSummary(query: query));
|
|
214
|
+
|
|
215
|
+
/// Satisfaction ratings, as a typed page (owner token).
|
|
216
|
+
Future<LiveChattaCsatRatingPage> listCsatRatingsAsOwnerTyped({Map<String, String>? query}) async =>
|
|
217
|
+
LiveChattaCsatRatingPage.fromJson(await listCsatRatingsAsOwner(query: query));
|
|
218
|
+
|
|
219
|
+
/// Satisfaction summary, typed (owner token).
|
|
220
|
+
Future<LiveChattaCsatSummary> getCsatSummaryAsOwnerTyped({Map<String, String>? query}) async =>
|
|
221
|
+
LiveChattaCsatSummary.fromJson(await getCsatSummaryAsOwner(query: query));
|
|
222
|
+
|
|
223
|
+
/// The owner Members list of a link, as a typed page.
|
|
224
|
+
Future<LiveChattaLinkMemberPage> getLinkMemberListTyped(String linkId, {Map<String, String>? query}) async =>
|
|
225
|
+
LiveChattaLinkMemberPage.fromJson(await getLinkMemberList(linkId, query: query));
|
|
226
|
+
|
|
227
|
+
/// Take someone off an invite-only link's list, as a typed result (owner token).
|
|
228
|
+
Future<LiveChattaRevokeLinkInviteResult> revokeLinkInviteTyped(String linkId, String memberId) async =>
|
|
229
|
+
LiveChattaRevokeLinkInviteResult.fromJson(await revokeLinkInvite(linkId, memberId));
|
|
230
|
+
|
|
231
|
+
/// A call recording's download link, typed (member token).
|
|
232
|
+
Future<LiveChattaRecordingDownloadLink> getRecordingDownloadLinkTyped(String messageId) async =>
|
|
233
|
+
LiveChattaRecordingDownloadLink.fromJson(await getRecordingDownloadLink(messageId));
|
|
234
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/// LiveChatta Flutter WebView embed (webview_flutter ^4; pointycastle ^3.7 optional for RSA).
|
|
2
|
+
/// Colours are sent only when set (link theme / Signal #D2400B otherwise; '6C5CE7' = no brand).
|
|
3
|
+
/// `theme`: 'light' | 'dark' | 'system'. Usage and the RSA snippet: README "Flutter (Dart)".
|
|
4
|
+
import 'dart:convert';
|
|
5
|
+
import 'package:flutter/material.dart';
|
|
6
|
+
import 'package:webview_flutter/webview_flutter.dart';
|
|
7
|
+
|
|
8
|
+
// Optional RSA: import 'package:pointycastle/export.dart'; then implement _encryptRSA (README).
|
|
9
|
+
|
|
10
|
+
class LiveChattaWebView extends StatefulWidget {
|
|
11
|
+
final String linkCode;
|
|
12
|
+
final String apiKey;
|
|
13
|
+
final String? publicKey;
|
|
14
|
+
final String chatUsername;
|
|
15
|
+
final String baseUrl;
|
|
16
|
+
/// Brand colour without '#'. Null = link theme, else Signal D2400B.
|
|
17
|
+
final String? primaryColor;
|
|
18
|
+
/// Secondary colour without '#'. Null = link theme, else Signal lagoon 0B6E66.
|
|
19
|
+
final String? secondaryColor;
|
|
20
|
+
final String? primaryLight;
|
|
21
|
+
final String? primaryDark;
|
|
22
|
+
final String? primaryBg;
|
|
23
|
+
final String? bg;
|
|
24
|
+
final String? bgDark;
|
|
25
|
+
final String? textColor;
|
|
26
|
+
final String? textLight;
|
|
27
|
+
final String? textMuted;
|
|
28
|
+
final String? borderColor;
|
|
29
|
+
final String? borderLight;
|
|
30
|
+
final String? fontFamily;
|
|
31
|
+
final String? logoUrl;
|
|
32
|
+
final String theme;
|
|
33
|
+
/// 'bubbles' | 'lines'. Null = the link's setting.
|
|
34
|
+
final String? layout;
|
|
35
|
+
final Function(Map<String, dynamic>)? onMessage;
|
|
36
|
+
final Function(String)? onError;
|
|
37
|
+
|
|
38
|
+
const LiveChattaWebView({
|
|
39
|
+
super.key,
|
|
40
|
+
required this.linkCode,
|
|
41
|
+
required this.apiKey,
|
|
42
|
+
this.publicKey,
|
|
43
|
+
required this.chatUsername,
|
|
44
|
+
this.baseUrl = 'https://api.livechatta.com',
|
|
45
|
+
this.primaryColor,
|
|
46
|
+
this.secondaryColor,
|
|
47
|
+
this.primaryLight,
|
|
48
|
+
this.primaryDark,
|
|
49
|
+
this.primaryBg,
|
|
50
|
+
this.bg,
|
|
51
|
+
this.bgDark,
|
|
52
|
+
this.textColor,
|
|
53
|
+
this.textLight,
|
|
54
|
+
this.textMuted,
|
|
55
|
+
this.borderColor,
|
|
56
|
+
this.borderLight,
|
|
57
|
+
this.fontFamily,
|
|
58
|
+
this.logoUrl,
|
|
59
|
+
this.theme = 'light',
|
|
60
|
+
this.layout,
|
|
61
|
+
this.onMessage,
|
|
62
|
+
this.onError,
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
@override
|
|
66
|
+
State<LiveChattaWebView> createState() => _LiveChattaWebViewState();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/// Pre-Signal default primary; treated as "no brand".
|
|
70
|
+
const String _legacyBrand = '6C5CE7';
|
|
71
|
+
|
|
72
|
+
class _LiveChattaWebViewState extends State<LiveChattaWebView> {
|
|
73
|
+
late final WebViewController _controller;
|
|
74
|
+
bool _isLoading = true;
|
|
75
|
+
|
|
76
|
+
@override
|
|
77
|
+
void initState() {
|
|
78
|
+
super.initState();
|
|
79
|
+
_controller = WebViewController()
|
|
80
|
+
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
|
81
|
+
..setNavigationDelegate(
|
|
82
|
+
NavigationDelegate(
|
|
83
|
+
onPageStarted: (_) => setState(() => _isLoading = true),
|
|
84
|
+
onPageFinished: (_) => setState(() => _isLoading = false),
|
|
85
|
+
onWebResourceError: (error) {
|
|
86
|
+
widget.onError?.call(error.description);
|
|
87
|
+
},
|
|
88
|
+
),
|
|
89
|
+
)
|
|
90
|
+
..addJavaScriptChannel(
|
|
91
|
+
'LiveChattaBridge',
|
|
92
|
+
onMessageReceived: (message) {
|
|
93
|
+
try {
|
|
94
|
+
final data = jsonDecode(message.message) as Map<String, dynamic>;
|
|
95
|
+
final type = data['type'] as String? ?? '';
|
|
96
|
+
if (type == 'error') {
|
|
97
|
+
widget.onError?.call(data['message']?.toString() ?? 'Unknown error');
|
|
98
|
+
} else {
|
|
99
|
+
widget.onMessage?.call(data);
|
|
100
|
+
}
|
|
101
|
+
} catch (_) {
|
|
102
|
+
// Non-JSON message, ignore
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
_loadUrl();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
Future<void> _loadUrl() async {
|
|
111
|
+
final token = await _buildToken();
|
|
112
|
+
final encodedToken = Uri.encodeComponent(token);
|
|
113
|
+
final buf = StringBuffer(
|
|
114
|
+
'${widget.baseUrl}/in/${widget.linkCode}/embed/chat'
|
|
115
|
+
'?token=$encodedToken'
|
|
116
|
+
'&theme=${const ['light', 'dark', 'system'].contains(widget.theme) ? widget.theme : 'light'}');
|
|
117
|
+
|
|
118
|
+
final primary = widget.primaryColor?.replaceAll('#', '');
|
|
119
|
+
if (primary != null && primary.isNotEmpty && primary.toUpperCase() != _legacyBrand) {
|
|
120
|
+
buf.write('&primaryColor=$primary');
|
|
121
|
+
}
|
|
122
|
+
final secondary = widget.secondaryColor?.replaceAll('#', '');
|
|
123
|
+
if (secondary != null && secondary.isNotEmpty) buf.write('&secondaryColor=$secondary');
|
|
124
|
+
if (widget.layout == 'bubbles' || widget.layout == 'lines') buf.write('&layout=${widget.layout}');
|
|
125
|
+
|
|
126
|
+
// Optional theme overrides
|
|
127
|
+
final optionalColors = <String, String?>{
|
|
128
|
+
'primaryLight': widget.primaryLight,
|
|
129
|
+
'primaryDark': widget.primaryDark,
|
|
130
|
+
'primaryBg': widget.primaryBg,
|
|
131
|
+
'bg': widget.bg,
|
|
132
|
+
'bgDark': widget.bgDark,
|
|
133
|
+
'textColor': widget.textColor,
|
|
134
|
+
'textLight': widget.textLight,
|
|
135
|
+
'textMuted': widget.textMuted,
|
|
136
|
+
'borderColor': widget.borderColor,
|
|
137
|
+
'borderLight': widget.borderLight,
|
|
138
|
+
};
|
|
139
|
+
for (final entry in optionalColors.entries) {
|
|
140
|
+
if (entry.value != null) buf.write('&${entry.key}=${entry.value}');
|
|
141
|
+
}
|
|
142
|
+
if (widget.fontFamily != null) {
|
|
143
|
+
buf.write('&fontFamily=${Uri.encodeComponent(widget.fontFamily!)}');
|
|
144
|
+
}
|
|
145
|
+
if (widget.logoUrl != null) {
|
|
146
|
+
buf.write('&logoUrl=${Uri.encodeComponent(widget.logoUrl!)}');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
_controller.loadRequest(Uri.parse(buf.toString()));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
Future<String> _buildToken() async {
|
|
153
|
+
final payload = <String, dynamic>{
|
|
154
|
+
'apiKey': widget.apiKey,
|
|
155
|
+
'linkCode': widget.linkCode,
|
|
156
|
+
'chatUsername': widget.chatUsername,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
if (widget.publicKey != null) {
|
|
160
|
+
try {
|
|
161
|
+
return _encryptRSA(widget.publicKey!, jsonEncode(payload));
|
|
162
|
+
} catch (_) {
|
|
163
|
+
// Fallback to raw API key
|
|
164
|
+
return widget.apiKey;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return widget.apiKey;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/// RSA-OAEP SHA-256 via pointycastle (see README "Flutter (Dart)" for the implementation).
|
|
172
|
+
/// Throws until implemented, so _buildToken falls back to the raw apiKey.
|
|
173
|
+
String _encryptRSA(String pemPublicKey, String data) {
|
|
174
|
+
throw UnimplementedError(
|
|
175
|
+
'RSA encryption requires pointycastle package. '
|
|
176
|
+
'Add pointycastle: ^3.7.0 to pubspec.yaml and implement _encryptRSA (see README).',
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
@override
|
|
181
|
+
Widget build(BuildContext context) {
|
|
182
|
+
return Stack(
|
|
183
|
+
children: [
|
|
184
|
+
WebViewWidget(controller: _controller),
|
|
185
|
+
if (_isLoading)
|
|
186
|
+
const Center(child: CircularProgressIndicator()),
|
|
187
|
+
],
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|