@sagepilot-ai/react-native-sdk 0.1.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.
@@ -0,0 +1,310 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ type SagepilotMobilePresentationStyle = "sheet" | "fullScreen" | "push";
4
+ type SagepilotMobileColorScheme = "system" | "light" | "dark";
5
+ type SagepilotChatErrorCode = "invalid_config" | "not_initialized" | "already_initialized" | "network_error" | "invalid_response" | "invalid_request" | "unauthorized" | "forbidden" | "session_not_found" | "session_expired" | "channel_not_found" | "conversation_not_found" | "message_not_found" | "contact_required" | "otp_required" | "otp_invalid" | "otp_expired" | "identity_verification_failed" | "rate_limited" | "idempotency_conflict" | "not_implemented" | "internal_error";
6
+ type SagepilotMobilePresentationConfig = {
7
+ style?: SagepilotMobilePresentationStyle;
8
+ /**
9
+ * Adds mobile=1 to the hosted widget URL. Defaults to true for React Native.
10
+ */
11
+ mobile?: boolean;
12
+ /**
13
+ * Renders a native React Native close button around the hosted WebView.
14
+ * Defaults to false so the hosted Sagepilot widget owns its close button.
15
+ */
16
+ showCloseButton?: boolean;
17
+ };
18
+ type SagepilotMobileThemeConfig = {
19
+ accentColor?: string;
20
+ logoUrl?: string;
21
+ preferredColorScheme?: SagepilotMobileColorScheme;
22
+ launcher?: SagepilotMobileLauncherConfig;
23
+ };
24
+ type SagepilotMobileLauncherConfig = {
25
+ label?: string;
26
+ buttonColor?: string;
27
+ pressedButtonColor?: string;
28
+ disabledButtonColor?: string;
29
+ borderColor?: string;
30
+ disabledBorderColor?: string;
31
+ iconColor?: string;
32
+ iconInsideColor?: string;
33
+ labelColor?: string;
34
+ disabledContentColor?: string;
35
+ unreadBadgeColor?: string;
36
+ unreadBadgeTextColor?: string;
37
+ unreadBadgeBorderColor?: string;
38
+ };
39
+ type SagepilotMobileResolvedLauncherConfig = Required<SagepilotMobileLauncherConfig>;
40
+ type SagepilotMobileThemeState = {
41
+ accentColor?: string;
42
+ logoUrl?: string;
43
+ preferredColorScheme?: SagepilotMobileColorScheme;
44
+ launcher: SagepilotMobileResolvedLauncherConfig;
45
+ };
46
+ type SagepilotMobileBehaviorConfig = {
47
+ enablePushNotifications?: boolean;
48
+ enableUnreadPolling?: boolean;
49
+ preloadWebView?: boolean;
50
+ unreadPollIntervalMs?: number;
51
+ };
52
+ type SagepilotTokenStorage = {
53
+ getItem: (key: string) => Promise<string | null>;
54
+ setItem: (key: string, value: string) => Promise<void>;
55
+ removeItem: (key: string) => Promise<void>;
56
+ };
57
+ type SagepilotCacheStorage = SagepilotTokenStorage;
58
+ type SagepilotDeviceInfo = {
59
+ deviceId?: string;
60
+ platform?: "ios" | "android" | "web" | string;
61
+ osVersion?: string;
62
+ appVersion?: string;
63
+ model?: string;
64
+ [key: string]: unknown;
65
+ };
66
+ type SagepilotDeviceInfoAdapter = {
67
+ getDeviceInfo: () => Promise<SagepilotDeviceInfo>;
68
+ };
69
+ type SagepilotBiometricsAdapter = {
70
+ isAvailable: () => Promise<boolean>;
71
+ authenticate: (prompt: string) => Promise<boolean>;
72
+ };
73
+ type SagepilotMobileConfig = {
74
+ /**
75
+ * Public Sagepilot routing key in the format "workspace_id:channel_id".
76
+ * This is not an API secret and is safe to ship in a mobile app.
77
+ */
78
+ key: string;
79
+ /**
80
+ * Optional Sagepilot public customer-manager host override.
81
+ * Defaults to the Sagepilot-hosted Customer API edge.
82
+ */
83
+ host?: string;
84
+ /**
85
+ * Optional Customer API host override. Defaults to EXPO_PUBLIC_SAGEPILOT_CUSTOMER_API_BASE_URL
86
+ * / SAGEPILOT_CUSTOMER_API_BASE_URL when present, then falls back to host.
87
+ */
88
+ apiHost?: string;
89
+ /**
90
+ * Optional explicit hosted widget host for development or dedicated widget routing.
91
+ * Most apps should omit this and use the SDK default hosted widget origin.
92
+ */
93
+ widgetHost?: string;
94
+ /**
95
+ * LocalStorage key prefix used by the hosted chat app for legacy claims JWT handoff.
96
+ * Most apps should leave this unset.
97
+ */
98
+ hostedClaimsStorageKeyPrefix?: string;
99
+ fetch?: typeof fetch;
100
+ /**
101
+ * Additional Customer API request headers.
102
+ * Do not pass server API keys or long-lived secrets from a mobile app.
103
+ */
104
+ headers?: HeadersInit;
105
+ /**
106
+ * Storage for SDK-created customer session tokens.
107
+ * Use Keychain/Keystore/SecureStore-backed storage in production apps.
108
+ */
109
+ tokenStorage?: SagepilotTokenStorage;
110
+ cacheStorage?: SagepilotCacheStorage;
111
+ deviceInfo?: SagepilotDeviceInfoAdapter;
112
+ biometrics?: SagepilotBiometricsAdapter;
113
+ presentation?: SagepilotMobilePresentationConfig;
114
+ theme?: SagepilotMobileThemeConfig;
115
+ behavior?: SagepilotMobileBehaviorConfig;
116
+ anonymousId?: string;
117
+ metadata?: Record<string, unknown>;
118
+ };
119
+ type SagepilotBootstrapChannelResponse = {
120
+ channel_id: string;
121
+ workspace_id: string;
122
+ name: string | null;
123
+ theme: Record<string, unknown> & {
124
+ ui?: {
125
+ accent_color?: string;
126
+ button_text?: string;
127
+ position?: "left" | "right";
128
+ bottom_padding?: number;
129
+ show_welcome_popup?: boolean;
130
+ show_image_cards?: boolean;
131
+ show_link_pills?: boolean;
132
+ logo?: string;
133
+ greeting_message?: string;
134
+ };
135
+ };
136
+ features: {
137
+ contact_form: boolean;
138
+ otp_auth: boolean;
139
+ attachments: boolean;
140
+ csat: boolean;
141
+ realtime: boolean;
142
+ };
143
+ auth?: {
144
+ mode: string;
145
+ methods: string[];
146
+ };
147
+ business_hours?: {
148
+ is_within_business_hours: boolean;
149
+ timezone: string;
150
+ current_time: string;
151
+ next_available: string | null;
152
+ } | null;
153
+ };
154
+ type SagepilotSessionState = {
155
+ session_id: string;
156
+ customer_id: string | null;
157
+ conversation_id: string | null;
158
+ authenticated?: boolean;
159
+ updated_at?: string;
160
+ };
161
+ type SagepilotIdentity = {
162
+ userId?: string;
163
+ user_id?: string;
164
+ email?: string;
165
+ name?: string;
166
+ phone?: string;
167
+ customProperties?: Record<string, unknown>;
168
+ custom_properties?: Record<string, unknown>;
169
+ /**
170
+ * Optional server-generated identity verification hash.
171
+ * Never generate this in the mobile app with a signing secret.
172
+ */
173
+ userHash?: string;
174
+ user_hash?: string;
175
+ };
176
+ type SagepilotIdentifyResponse = {
177
+ customer_id: string;
178
+ conversation_id: string | null;
179
+ session_token: string;
180
+ legacy_jwt?: string;
181
+ identity_verified: boolean;
182
+ customer: {
183
+ id: string;
184
+ external_user_id: string;
185
+ email: string | null;
186
+ name: string | null;
187
+ } & Record<string, unknown>;
188
+ };
189
+ type SagepilotIdentifyResult = Omit<SagepilotIdentifyResponse, "session_token" | "legacy_jwt"> & {
190
+ success: true;
191
+ };
192
+ type SagepilotLogoutResponse = {
193
+ success: true;
194
+ session_id: string;
195
+ };
196
+ type SagepilotIdentityState = {
197
+ identified: boolean;
198
+ customer: Record<string, unknown> | null;
199
+ pending: boolean;
200
+ };
201
+ type SagepilotUnreadState = {
202
+ count: number;
203
+ isOpen: boolean;
204
+ };
205
+ type SagepilotLifecycleState = {
206
+ isOpen: boolean;
207
+ unreadCount: number;
208
+ };
209
+ type SagepilotMobileConfigureResult = {
210
+ channel: SagepilotBootstrapChannelResponse;
211
+ session: SagepilotSessionState;
212
+ };
213
+ type SagepilotMobileState = SagepilotLifecycleState & {
214
+ configured: boolean;
215
+ identity: SagepilotIdentityState;
216
+ theme: SagepilotMobileThemeState;
217
+ };
218
+ type SagepilotMobileSubscription = () => void;
219
+ type SagepilotChatHookState = {
220
+ configured: boolean;
221
+ isPresented: boolean;
222
+ unreadCount: number;
223
+ identity: SagepilotIdentityState;
224
+ theme: SagepilotMobileThemeState;
225
+ present: () => boolean;
226
+ presentMessages: () => boolean;
227
+ presentMessageComposer: (message?: string) => boolean;
228
+ dismiss: () => boolean;
229
+ hide: () => boolean;
230
+ toggle: () => boolean;
231
+ identify: (identity: SagepilotIdentity) => Promise<SagepilotIdentifyResult>;
232
+ logout: () => Promise<SagepilotLogoutResponse>;
233
+ getUnreadCount: () => Promise<number>;
234
+ };
235
+ type SagepilotChatProviderProps = {
236
+ children?: ReactNode;
237
+ closeLabel?: string;
238
+ loadingLabel?: string;
239
+ };
240
+
241
+ type Callback<T> = (value: T) => void;
242
+ declare const SagepilotChat: {
243
+ configure: (config: SagepilotMobileConfig) => Promise<SagepilotMobileConfigureResult>;
244
+ getSession: () => Promise<SagepilotSessionState>;
245
+ identify: (identity: SagepilotIdentity) => Promise<SagepilotIdentifyResult>;
246
+ logout: () => Promise<SagepilotLogoutResponse>;
247
+ getIdentityState: () => {
248
+ identified: boolean;
249
+ customer: Record<string, unknown> | null;
250
+ pending: boolean;
251
+ };
252
+ onIdentify: (callback: Callback<SagepilotIdentifyResult>) => SagepilotMobileSubscription;
253
+ getUnreadCount: () => Promise<number>;
254
+ onUnreadChange: (callback: Callback<SagepilotUnreadState>) => SagepilotMobileSubscription;
255
+ startUnreadPolling: (intervalMs?: number) => () => void;
256
+ stopUnreadPolling: () => void;
257
+ present: () => boolean;
258
+ presentMessages: () => boolean;
259
+ presentMessageComposer: (message?: string) => boolean;
260
+ dismiss: () => boolean;
261
+ hide: () => boolean;
262
+ toggle: () => boolean;
263
+ isPresented: () => boolean;
264
+ onReady: (callback: Callback<SagepilotLifecycleState>) => SagepilotMobileSubscription;
265
+ onPresent: (callback: Callback<SagepilotLifecycleState>) => SagepilotMobileSubscription;
266
+ onDismiss: (callback: Callback<SagepilotLifecycleState>) => SagepilotMobileSubscription;
267
+ onError: (callback: Callback<unknown>) => SagepilotMobileSubscription;
268
+ onStateChange: (callback: Callback<SagepilotMobileState>) => SagepilotMobileSubscription;
269
+ getState: () => SagepilotMobileState;
270
+ getSessionState: () => SagepilotSessionState | null;
271
+ getChannel: () => SagepilotBootstrapChannelResponse | null;
272
+ destroy: () => void;
273
+ };
274
+
275
+ declare class SagepilotChatError extends Error {
276
+ readonly code: SagepilotChatErrorCode;
277
+ readonly status?: number;
278
+ readonly requestId?: string;
279
+ readonly details?: Record<string, unknown>;
280
+ readonly cause?: unknown;
281
+ constructor(code: SagepilotChatErrorCode, message: string, options?: {
282
+ status?: number;
283
+ requestId?: string;
284
+ details?: Record<string, unknown>;
285
+ cause?: unknown;
286
+ });
287
+ }
288
+
289
+ type SagepilotKeychainLike = {
290
+ getGenericPassword: (options?: Record<string, unknown>) => Promise<false | {
291
+ username: string;
292
+ password: string;
293
+ }>;
294
+ setGenericPassword: (username: string, password: string, options?: Record<string, unknown>) => Promise<unknown>;
295
+ resetGenericPassword: (options?: Record<string, unknown>) => Promise<unknown>;
296
+ };
297
+ declare function createKeychainTokenStorage(keychain: SagepilotKeychainLike, options?: Record<string, unknown>): SagepilotTokenStorage;
298
+
299
+ type SagepilotAsyncStorageLike = {
300
+ getItem: (key: string) => Promise<string | null>;
301
+ setItem: (key: string, value: string) => Promise<void>;
302
+ removeItem: (key: string) => Promise<void>;
303
+ };
304
+ declare function createAsyncStorageCacheStorage(asyncStorage: SagepilotAsyncStorageLike): SagepilotCacheStorage;
305
+
306
+ declare function SagepilotChatProvider({ children, closeLabel, loadingLabel }: SagepilotChatProviderProps): ReactNode;
307
+
308
+ declare function useSagepilotChat(): SagepilotChatHookState;
309
+
310
+ export { type SagepilotBiometricsAdapter, type SagepilotBootstrapChannelResponse, type SagepilotCacheStorage, SagepilotChat, SagepilotChatError, type SagepilotChatErrorCode, type SagepilotChatHookState, SagepilotChatProvider, type SagepilotChatProviderProps, type SagepilotDeviceInfo, type SagepilotDeviceInfoAdapter, type SagepilotIdentifyResult, type SagepilotIdentity, type SagepilotIdentityState, type SagepilotLifecycleState, type SagepilotLogoutResponse, type SagepilotMobileBehaviorConfig, type SagepilotMobileColorScheme, type SagepilotMobileConfig, type SagepilotMobileConfigureResult, type SagepilotMobileLauncherConfig, type SagepilotMobilePresentationConfig, type SagepilotMobilePresentationStyle, type SagepilotMobileResolvedLauncherConfig, type SagepilotMobileState, type SagepilotMobileSubscription, type SagepilotMobileThemeConfig, type SagepilotMobileThemeState, type SagepilotSessionState, type SagepilotTokenStorage, type SagepilotUnreadState, createAsyncStorageCacheStorage, createKeychainTokenStorage, useSagepilotChat };
@@ -0,0 +1,310 @@
1
+ import { ReactNode } from 'react';
2
+
3
+ type SagepilotMobilePresentationStyle = "sheet" | "fullScreen" | "push";
4
+ type SagepilotMobileColorScheme = "system" | "light" | "dark";
5
+ type SagepilotChatErrorCode = "invalid_config" | "not_initialized" | "already_initialized" | "network_error" | "invalid_response" | "invalid_request" | "unauthorized" | "forbidden" | "session_not_found" | "session_expired" | "channel_not_found" | "conversation_not_found" | "message_not_found" | "contact_required" | "otp_required" | "otp_invalid" | "otp_expired" | "identity_verification_failed" | "rate_limited" | "idempotency_conflict" | "not_implemented" | "internal_error";
6
+ type SagepilotMobilePresentationConfig = {
7
+ style?: SagepilotMobilePresentationStyle;
8
+ /**
9
+ * Adds mobile=1 to the hosted widget URL. Defaults to true for React Native.
10
+ */
11
+ mobile?: boolean;
12
+ /**
13
+ * Renders a native React Native close button around the hosted WebView.
14
+ * Defaults to false so the hosted Sagepilot widget owns its close button.
15
+ */
16
+ showCloseButton?: boolean;
17
+ };
18
+ type SagepilotMobileThemeConfig = {
19
+ accentColor?: string;
20
+ logoUrl?: string;
21
+ preferredColorScheme?: SagepilotMobileColorScheme;
22
+ launcher?: SagepilotMobileLauncherConfig;
23
+ };
24
+ type SagepilotMobileLauncherConfig = {
25
+ label?: string;
26
+ buttonColor?: string;
27
+ pressedButtonColor?: string;
28
+ disabledButtonColor?: string;
29
+ borderColor?: string;
30
+ disabledBorderColor?: string;
31
+ iconColor?: string;
32
+ iconInsideColor?: string;
33
+ labelColor?: string;
34
+ disabledContentColor?: string;
35
+ unreadBadgeColor?: string;
36
+ unreadBadgeTextColor?: string;
37
+ unreadBadgeBorderColor?: string;
38
+ };
39
+ type SagepilotMobileResolvedLauncherConfig = Required<SagepilotMobileLauncherConfig>;
40
+ type SagepilotMobileThemeState = {
41
+ accentColor?: string;
42
+ logoUrl?: string;
43
+ preferredColorScheme?: SagepilotMobileColorScheme;
44
+ launcher: SagepilotMobileResolvedLauncherConfig;
45
+ };
46
+ type SagepilotMobileBehaviorConfig = {
47
+ enablePushNotifications?: boolean;
48
+ enableUnreadPolling?: boolean;
49
+ preloadWebView?: boolean;
50
+ unreadPollIntervalMs?: number;
51
+ };
52
+ type SagepilotTokenStorage = {
53
+ getItem: (key: string) => Promise<string | null>;
54
+ setItem: (key: string, value: string) => Promise<void>;
55
+ removeItem: (key: string) => Promise<void>;
56
+ };
57
+ type SagepilotCacheStorage = SagepilotTokenStorage;
58
+ type SagepilotDeviceInfo = {
59
+ deviceId?: string;
60
+ platform?: "ios" | "android" | "web" | string;
61
+ osVersion?: string;
62
+ appVersion?: string;
63
+ model?: string;
64
+ [key: string]: unknown;
65
+ };
66
+ type SagepilotDeviceInfoAdapter = {
67
+ getDeviceInfo: () => Promise<SagepilotDeviceInfo>;
68
+ };
69
+ type SagepilotBiometricsAdapter = {
70
+ isAvailable: () => Promise<boolean>;
71
+ authenticate: (prompt: string) => Promise<boolean>;
72
+ };
73
+ type SagepilotMobileConfig = {
74
+ /**
75
+ * Public Sagepilot routing key in the format "workspace_id:channel_id".
76
+ * This is not an API secret and is safe to ship in a mobile app.
77
+ */
78
+ key: string;
79
+ /**
80
+ * Optional Sagepilot public customer-manager host override.
81
+ * Defaults to the Sagepilot-hosted Customer API edge.
82
+ */
83
+ host?: string;
84
+ /**
85
+ * Optional Customer API host override. Defaults to EXPO_PUBLIC_SAGEPILOT_CUSTOMER_API_BASE_URL
86
+ * / SAGEPILOT_CUSTOMER_API_BASE_URL when present, then falls back to host.
87
+ */
88
+ apiHost?: string;
89
+ /**
90
+ * Optional explicit hosted widget host for development or dedicated widget routing.
91
+ * Most apps should omit this and use the SDK default hosted widget origin.
92
+ */
93
+ widgetHost?: string;
94
+ /**
95
+ * LocalStorage key prefix used by the hosted chat app for legacy claims JWT handoff.
96
+ * Most apps should leave this unset.
97
+ */
98
+ hostedClaimsStorageKeyPrefix?: string;
99
+ fetch?: typeof fetch;
100
+ /**
101
+ * Additional Customer API request headers.
102
+ * Do not pass server API keys or long-lived secrets from a mobile app.
103
+ */
104
+ headers?: HeadersInit;
105
+ /**
106
+ * Storage for SDK-created customer session tokens.
107
+ * Use Keychain/Keystore/SecureStore-backed storage in production apps.
108
+ */
109
+ tokenStorage?: SagepilotTokenStorage;
110
+ cacheStorage?: SagepilotCacheStorage;
111
+ deviceInfo?: SagepilotDeviceInfoAdapter;
112
+ biometrics?: SagepilotBiometricsAdapter;
113
+ presentation?: SagepilotMobilePresentationConfig;
114
+ theme?: SagepilotMobileThemeConfig;
115
+ behavior?: SagepilotMobileBehaviorConfig;
116
+ anonymousId?: string;
117
+ metadata?: Record<string, unknown>;
118
+ };
119
+ type SagepilotBootstrapChannelResponse = {
120
+ channel_id: string;
121
+ workspace_id: string;
122
+ name: string | null;
123
+ theme: Record<string, unknown> & {
124
+ ui?: {
125
+ accent_color?: string;
126
+ button_text?: string;
127
+ position?: "left" | "right";
128
+ bottom_padding?: number;
129
+ show_welcome_popup?: boolean;
130
+ show_image_cards?: boolean;
131
+ show_link_pills?: boolean;
132
+ logo?: string;
133
+ greeting_message?: string;
134
+ };
135
+ };
136
+ features: {
137
+ contact_form: boolean;
138
+ otp_auth: boolean;
139
+ attachments: boolean;
140
+ csat: boolean;
141
+ realtime: boolean;
142
+ };
143
+ auth?: {
144
+ mode: string;
145
+ methods: string[];
146
+ };
147
+ business_hours?: {
148
+ is_within_business_hours: boolean;
149
+ timezone: string;
150
+ current_time: string;
151
+ next_available: string | null;
152
+ } | null;
153
+ };
154
+ type SagepilotSessionState = {
155
+ session_id: string;
156
+ customer_id: string | null;
157
+ conversation_id: string | null;
158
+ authenticated?: boolean;
159
+ updated_at?: string;
160
+ };
161
+ type SagepilotIdentity = {
162
+ userId?: string;
163
+ user_id?: string;
164
+ email?: string;
165
+ name?: string;
166
+ phone?: string;
167
+ customProperties?: Record<string, unknown>;
168
+ custom_properties?: Record<string, unknown>;
169
+ /**
170
+ * Optional server-generated identity verification hash.
171
+ * Never generate this in the mobile app with a signing secret.
172
+ */
173
+ userHash?: string;
174
+ user_hash?: string;
175
+ };
176
+ type SagepilotIdentifyResponse = {
177
+ customer_id: string;
178
+ conversation_id: string | null;
179
+ session_token: string;
180
+ legacy_jwt?: string;
181
+ identity_verified: boolean;
182
+ customer: {
183
+ id: string;
184
+ external_user_id: string;
185
+ email: string | null;
186
+ name: string | null;
187
+ } & Record<string, unknown>;
188
+ };
189
+ type SagepilotIdentifyResult = Omit<SagepilotIdentifyResponse, "session_token" | "legacy_jwt"> & {
190
+ success: true;
191
+ };
192
+ type SagepilotLogoutResponse = {
193
+ success: true;
194
+ session_id: string;
195
+ };
196
+ type SagepilotIdentityState = {
197
+ identified: boolean;
198
+ customer: Record<string, unknown> | null;
199
+ pending: boolean;
200
+ };
201
+ type SagepilotUnreadState = {
202
+ count: number;
203
+ isOpen: boolean;
204
+ };
205
+ type SagepilotLifecycleState = {
206
+ isOpen: boolean;
207
+ unreadCount: number;
208
+ };
209
+ type SagepilotMobileConfigureResult = {
210
+ channel: SagepilotBootstrapChannelResponse;
211
+ session: SagepilotSessionState;
212
+ };
213
+ type SagepilotMobileState = SagepilotLifecycleState & {
214
+ configured: boolean;
215
+ identity: SagepilotIdentityState;
216
+ theme: SagepilotMobileThemeState;
217
+ };
218
+ type SagepilotMobileSubscription = () => void;
219
+ type SagepilotChatHookState = {
220
+ configured: boolean;
221
+ isPresented: boolean;
222
+ unreadCount: number;
223
+ identity: SagepilotIdentityState;
224
+ theme: SagepilotMobileThemeState;
225
+ present: () => boolean;
226
+ presentMessages: () => boolean;
227
+ presentMessageComposer: (message?: string) => boolean;
228
+ dismiss: () => boolean;
229
+ hide: () => boolean;
230
+ toggle: () => boolean;
231
+ identify: (identity: SagepilotIdentity) => Promise<SagepilotIdentifyResult>;
232
+ logout: () => Promise<SagepilotLogoutResponse>;
233
+ getUnreadCount: () => Promise<number>;
234
+ };
235
+ type SagepilotChatProviderProps = {
236
+ children?: ReactNode;
237
+ closeLabel?: string;
238
+ loadingLabel?: string;
239
+ };
240
+
241
+ type Callback<T> = (value: T) => void;
242
+ declare const SagepilotChat: {
243
+ configure: (config: SagepilotMobileConfig) => Promise<SagepilotMobileConfigureResult>;
244
+ getSession: () => Promise<SagepilotSessionState>;
245
+ identify: (identity: SagepilotIdentity) => Promise<SagepilotIdentifyResult>;
246
+ logout: () => Promise<SagepilotLogoutResponse>;
247
+ getIdentityState: () => {
248
+ identified: boolean;
249
+ customer: Record<string, unknown> | null;
250
+ pending: boolean;
251
+ };
252
+ onIdentify: (callback: Callback<SagepilotIdentifyResult>) => SagepilotMobileSubscription;
253
+ getUnreadCount: () => Promise<number>;
254
+ onUnreadChange: (callback: Callback<SagepilotUnreadState>) => SagepilotMobileSubscription;
255
+ startUnreadPolling: (intervalMs?: number) => () => void;
256
+ stopUnreadPolling: () => void;
257
+ present: () => boolean;
258
+ presentMessages: () => boolean;
259
+ presentMessageComposer: (message?: string) => boolean;
260
+ dismiss: () => boolean;
261
+ hide: () => boolean;
262
+ toggle: () => boolean;
263
+ isPresented: () => boolean;
264
+ onReady: (callback: Callback<SagepilotLifecycleState>) => SagepilotMobileSubscription;
265
+ onPresent: (callback: Callback<SagepilotLifecycleState>) => SagepilotMobileSubscription;
266
+ onDismiss: (callback: Callback<SagepilotLifecycleState>) => SagepilotMobileSubscription;
267
+ onError: (callback: Callback<unknown>) => SagepilotMobileSubscription;
268
+ onStateChange: (callback: Callback<SagepilotMobileState>) => SagepilotMobileSubscription;
269
+ getState: () => SagepilotMobileState;
270
+ getSessionState: () => SagepilotSessionState | null;
271
+ getChannel: () => SagepilotBootstrapChannelResponse | null;
272
+ destroy: () => void;
273
+ };
274
+
275
+ declare class SagepilotChatError extends Error {
276
+ readonly code: SagepilotChatErrorCode;
277
+ readonly status?: number;
278
+ readonly requestId?: string;
279
+ readonly details?: Record<string, unknown>;
280
+ readonly cause?: unknown;
281
+ constructor(code: SagepilotChatErrorCode, message: string, options?: {
282
+ status?: number;
283
+ requestId?: string;
284
+ details?: Record<string, unknown>;
285
+ cause?: unknown;
286
+ });
287
+ }
288
+
289
+ type SagepilotKeychainLike = {
290
+ getGenericPassword: (options?: Record<string, unknown>) => Promise<false | {
291
+ username: string;
292
+ password: string;
293
+ }>;
294
+ setGenericPassword: (username: string, password: string, options?: Record<string, unknown>) => Promise<unknown>;
295
+ resetGenericPassword: (options?: Record<string, unknown>) => Promise<unknown>;
296
+ };
297
+ declare function createKeychainTokenStorage(keychain: SagepilotKeychainLike, options?: Record<string, unknown>): SagepilotTokenStorage;
298
+
299
+ type SagepilotAsyncStorageLike = {
300
+ getItem: (key: string) => Promise<string | null>;
301
+ setItem: (key: string, value: string) => Promise<void>;
302
+ removeItem: (key: string) => Promise<void>;
303
+ };
304
+ declare function createAsyncStorageCacheStorage(asyncStorage: SagepilotAsyncStorageLike): SagepilotCacheStorage;
305
+
306
+ declare function SagepilotChatProvider({ children, closeLabel, loadingLabel }: SagepilotChatProviderProps): ReactNode;
307
+
308
+ declare function useSagepilotChat(): SagepilotChatHookState;
309
+
310
+ export { type SagepilotBiometricsAdapter, type SagepilotBootstrapChannelResponse, type SagepilotCacheStorage, SagepilotChat, SagepilotChatError, type SagepilotChatErrorCode, type SagepilotChatHookState, SagepilotChatProvider, type SagepilotChatProviderProps, type SagepilotDeviceInfo, type SagepilotDeviceInfoAdapter, type SagepilotIdentifyResult, type SagepilotIdentity, type SagepilotIdentityState, type SagepilotLifecycleState, type SagepilotLogoutResponse, type SagepilotMobileBehaviorConfig, type SagepilotMobileColorScheme, type SagepilotMobileConfig, type SagepilotMobileConfigureResult, type SagepilotMobileLauncherConfig, type SagepilotMobilePresentationConfig, type SagepilotMobilePresentationStyle, type SagepilotMobileResolvedLauncherConfig, type SagepilotMobileState, type SagepilotMobileSubscription, type SagepilotMobileThemeConfig, type SagepilotMobileThemeState, type SagepilotSessionState, type SagepilotTokenStorage, type SagepilotUnreadState, createAsyncStorageCacheStorage, createKeychainTokenStorage, useSagepilotChat };