@kindly-ai/react-native 1.0.13 → 1.0.15

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.
Files changed (44) hide show
  1. package/README.md +54 -1
  2. package/android/src/main/java/com/kindlyai/reactnative/KindlyReactNativeModule.kt +73 -1
  3. package/ios/Frameworks/Kindly.xcframework/_CodeSignature/CodeDirectory +0 -0
  4. package/ios/Frameworks/Kindly.xcframework/_CodeSignature/CodeResources +52 -172
  5. package/ios/Frameworks/Kindly.xcframework/_CodeSignature/CodeSignature +0 -0
  6. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/Assets.car +0 -0
  7. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/ConfirmationWindow.nib +0 -0
  8. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/Headers/Kindly-Swift.h +72 -7
  9. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/Info.plist +0 -0
  10. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/Kindly +0 -0
  11. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/Modules/Kindly.swiftmodule/arm64-apple-ios.abi.json +598 -432
  12. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/Modules/Kindly.swiftmodule/arm64-apple-ios.private.swiftinterface +4 -4
  13. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/Modules/Kindly.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  14. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/Modules/Kindly.swiftmodule/arm64-apple-ios.swiftinterface +3 -4
  15. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/Modules/module.modulemap +0 -1
  16. package/ios/Frameworks/Kindly.xcframework/ios-arm64/Kindly.framework/_CodeSignature/CodeResources +17 -17
  17. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Assets.car +0 -0
  18. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/ConfirmationWindow.nib +0 -0
  19. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Headers/Kindly-Swift.h +146 -16
  20. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Info.plist +0 -0
  21. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Kindly +0 -0
  22. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Modules/Kindly.swiftmodule/arm64-apple-ios-simulator.abi.json +598 -432
  23. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Modules/Kindly.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +4 -4
  24. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Modules/Kindly.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  25. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Modules/Kindly.swiftmodule/arm64-apple-ios-simulator.swiftinterface +3 -4
  26. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Modules/Kindly.swiftmodule/x86_64-apple-ios-simulator.abi.json +598 -432
  27. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Modules/Kindly.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +4 -4
  28. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Modules/Kindly.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  29. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Modules/Kindly.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +3 -4
  30. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/Modules/module.modulemap +0 -1
  31. package/ios/Frameworks/Kindly.xcframework/ios-arm64_x86_64-simulator/Kindly.framework/_CodeSignature/CodeResources +25 -25
  32. package/ios/KindlyReactNative.mm +24 -6
  33. package/ios/KindlyReactNativeImpl.swift +91 -3
  34. package/lib/module/NativeKindlyReactNative.js.map +1 -1
  35. package/lib/module/index.js +67 -1
  36. package/lib/module/index.js.map +1 -1
  37. package/lib/typescript/src/NativeKindlyReactNative.d.ts +6 -1
  38. package/lib/typescript/src/NativeKindlyReactNative.d.ts.map +1 -1
  39. package/lib/typescript/src/index.d.ts +75 -0
  40. package/lib/typescript/src/index.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/NativeKindlyReactNative.ts +8 -1
  43. package/src/index.tsx +113 -1
  44. package/ios/Frameworks/Kindly.xcframework/_CodeSignature/CodeRequirements-1 +0 -0
@@ -10,6 +10,53 @@
10
10
  * anonymous.
11
11
  */
12
12
  export type AuthTokenCallback = (chatId: string) => Promise<string | null>;
13
+ /**
14
+ * Credentials the host app hands the SDK to authenticate a chat.
15
+ *
16
+ * The Kindly platform verifies an authenticated chat in one of three ways: a
17
+ * JWT your own backend signs, a JWT from your identity provider (optionally
18
+ * paired with an access token), or an opaque bearer token validated by
19
+ * introspection. This one type covers all of them.
20
+ */
21
+ export interface KindlyAuthCredentials {
22
+ /**
23
+ * The OIDC id token, when your provider issues one.
24
+ *
25
+ * Optional. It is the *preferred* bearer, not a mandatory field. Set at least
26
+ * one of `idToken` / `accessToken`; credentials carrying neither cannot
27
+ * authenticate and the chat stays anonymous.
28
+ */
29
+ idToken?: string | null;
30
+ /**
31
+ * The access token, when your provider issues one.
32
+ *
33
+ * Its role depends on what else is set. Alongside an `idToken` it is the
34
+ * companion, sent as `X-Access-Token`. On its own it becomes the bearer,
35
+ * which is a normal, supported case. The Kindly JWT strategy ignores the
36
+ * companion form.
37
+ */
38
+ accessToken?: string | null;
39
+ /**
40
+ * Identity provider issuer, sent as `X-Auth-Issuer`. Required for bots with
41
+ * more than one provider configured, and for any opaque token.
42
+ */
43
+ issuer?: string | null;
44
+ /**
45
+ * When the credentials expire, in Unix **seconds**. Worth supplying for an
46
+ * opaque token. The SDK reads `exp` off a JWT itself, but an opaque token
47
+ * tells it nothing, and credentials with no known expiry are never
48
+ * proactively refreshed.
49
+ */
50
+ expiresAt?: number | null;
51
+ }
52
+ /**
53
+ * Callback invoked by the SDK when it needs fresh auth credentials.
54
+ *
55
+ * Use instead of {@link AuthTokenCallback} when your identity provider issues
56
+ * more than a single JWT. Return `null` if credentials can't be provided, and
57
+ * the SDK treats the chat as anonymous.
58
+ */
59
+ export type AuthCredentialsCallback = (chatId: string) => Promise<KindlyAuthCredentials | null>;
13
60
  /** Callback invoked when a handover to a human agent is initiated. */
14
61
  export type HandoverCallback = () => void;
15
62
  /**
@@ -82,7 +129,35 @@ export declare class KindlySDK {
82
129
  market: string;
83
130
  languageCode?: string;
84
131
  authTokenCallback?: AuthTokenCallback;
132
+ /**
133
+ * Use instead of `authTokenCallback` when your identity provider issues more
134
+ * than a single JWT. Takes precedence when both are given.
135
+ */
136
+ authCredentialsCallback?: AuthCredentialsCallback;
85
137
  }): void;
138
+ /**
139
+ * Re-authenticate the live chat, asking your callback for fresh credentials.
140
+ *
141
+ * For when the *identity* changed rather than the token: the user signed in,
142
+ * or switched account, while the chat was already open. Expiry is handled by
143
+ * the SDK on its own.
144
+ *
145
+ * The chat, its history and its socket are all kept. Rejects if the callback
146
+ * failed or the backend refused the credentials.
147
+ */
148
+ static authenticate(): Promise<void>;
149
+ /**
150
+ * Sign the user out of the chat without ending it.
151
+ *
152
+ * Unbinds the identity on the backend and forgets the stored credentials. The
153
+ * chat carries on anonymously with its history intact. Use `endChat()` when
154
+ * the conversation itself should end.
155
+ *
156
+ * Safe to call when already anonymous. The local credentials are cleared even
157
+ * if the backend call fails, but the promise still rejects so you know the
158
+ * backend did not hear about it.
159
+ */
160
+ static deauthenticate(): Promise<void>;
86
161
  /** Show the chat UI. */
87
162
  static displayChat(args?: {
88
163
  languageCode?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAcA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;AAE3E,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACxC,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAClC,OAAO,EAAE,KAAK,CAAC;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC,KACvC,IAAI,CAAC;AAEV;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;AAEnE;;;;GAIG;AACH,MAAM,MAAM,mCAAmC,GAAG,CAAC,YAAY,EAAE;IAC/D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,KAAK,OAAO,CAAC;AAEd,qEAAqE;AACrE,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAA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oB,IAAI,IAAI;IAInC,0EAA0E;IAC1E,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI/C,4CAA4C;IAC5C,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAMrD,oFAAoF;IACpF,MAAM,CAAC,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAI1C,kCAAkC;IAClC,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIhD,yDAAyD;IACzD,MAAM,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIhD;;;;;OAKG;IACH,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAInD;;;OAGG;IACH,MAAM,CAAC,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIzD;;;OAGG;IACH,MAAM,CAAC,0BAA0B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAMzD;;;;OAIG;IACH,MAAM,CAAC,8BAA8B,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAM7D;;;;;;;OAOG;IACH,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE;QACvB,eAAe,CAAC,EAAE,2BAA2B,CAAC;QAC9C,gBAAgB,CAAC,EAAE,2BAA2B,CAAC;QAC/C,wBAAwB,CAAC,EAAE,mCAAmC,CAAC;KAChE,GAAG,IAAI;IAaR,wDAAwD;IACxD,MAAM,CAAC,aAAa,IAAI,IAAI;CAM7B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kindly-ai/react-native",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Kindly chat SDK for React Native",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -23,13 +23,16 @@ export interface Spec extends TurboModule {
23
23
  botKey: string,
24
24
  languageCode: string | null,
25
25
  market: string,
26
- hasAuthCallback: boolean
26
+ hasAuthCallback: boolean,
27
+ hasAuthCredentialsCallback: boolean
27
28
  ): void;
28
29
  displayChat(languageCode: string | null, triggerDialogueId: string | null): void;
29
30
  launchChat(triggerDialogueId: string | null): void;
30
31
  closeChat(): void;
31
32
  endChat(): Promise<void>;
32
33
  kill(): Promise<void>;
34
+ authenticate(): Promise<void>;
35
+ deauthenticate(): Promise<void>;
33
36
  setLanguage(languageCode: string): Promise<void>;
34
37
 
35
38
  // Messaging — newContext map shape: { [key: string]: string }
@@ -75,6 +78,10 @@ export interface Spec extends TurboModule {
75
78
  // Map<requestId, Deferred> with a 5-second timeout, falling back to a
76
79
  // safe default if JS is silent.
77
80
  respondToAuthToken(requestId: string, token: string | null): void;
81
+ respondToAuthCredentials(
82
+ requestId: string,
83
+ credentials: { [key: string]: unknown } | null
84
+ ): void;
78
85
  respondToShouldHandle(requestId: string, value: boolean): void;
79
86
 
80
87
  // Delegate gating — flips on/off the bridge-level routing for each callback.
package/src/index.tsx CHANGED
@@ -25,6 +25,57 @@ import NativeKindly from './NativeKindlyReactNative';
25
25
  */
26
26
  export type AuthTokenCallback = (chatId: string) => Promise<string | null>;
27
27
 
28
+ /**
29
+ * Credentials the host app hands the SDK to authenticate a chat.
30
+ *
31
+ * The Kindly platform verifies an authenticated chat in one of three ways: a
32
+ * JWT your own backend signs, a JWT from your identity provider (optionally
33
+ * paired with an access token), or an opaque bearer token validated by
34
+ * introspection. This one type covers all of them.
35
+ */
36
+ export interface KindlyAuthCredentials {
37
+ /**
38
+ * The OIDC id token, when your provider issues one.
39
+ *
40
+ * Optional. It is the *preferred* bearer, not a mandatory field. Set at least
41
+ * one of `idToken` / `accessToken`; credentials carrying neither cannot
42
+ * authenticate and the chat stays anonymous.
43
+ */
44
+ idToken?: string | null;
45
+ /**
46
+ * The access token, when your provider issues one.
47
+ *
48
+ * Its role depends on what else is set. Alongside an `idToken` it is the
49
+ * companion, sent as `X-Access-Token`. On its own it becomes the bearer,
50
+ * which is a normal, supported case. The Kindly JWT strategy ignores the
51
+ * companion form.
52
+ */
53
+ accessToken?: string | null;
54
+ /**
55
+ * Identity provider issuer, sent as `X-Auth-Issuer`. Required for bots with
56
+ * more than one provider configured, and for any opaque token.
57
+ */
58
+ issuer?: string | null;
59
+ /**
60
+ * When the credentials expire, in Unix **seconds**. Worth supplying for an
61
+ * opaque token. The SDK reads `exp` off a JWT itself, but an opaque token
62
+ * tells it nothing, and credentials with no known expiry are never
63
+ * proactively refreshed.
64
+ */
65
+ expiresAt?: number | null;
66
+ }
67
+
68
+ /**
69
+ * Callback invoked by the SDK when it needs fresh auth credentials.
70
+ *
71
+ * Use instead of {@link AuthTokenCallback} when your identity provider issues
72
+ * more than a single JWT. Return `null` if credentials can't be provided, and
73
+ * the SDK treats the chat as anonymous.
74
+ */
75
+ export type AuthCredentialsCallback = (
76
+ chatId: string
77
+ ) => Promise<KindlyAuthCredentials | null>;
78
+
28
79
  /** Callback invoked when a handover to a human agent is initiated. */
29
80
  export type HandoverCallback = () => void;
30
81
 
@@ -109,6 +160,7 @@ const eventEmitter = new NativeEventEmitter(
109
160
  );
110
161
 
111
162
  let authTokenCallback: AuthTokenCallback | null = null;
163
+ let authCredentialsCallback: AuthCredentialsCallback | null = null;
112
164
  let handoverCallback: HandoverCallback | null = null;
113
165
  let onButtonPressed: KindlyButtonPressedCallback | null = null;
114
166
  let shouldHandleLink: KindlyLinkInterceptCallback | null = null;
@@ -137,6 +189,30 @@ function attachListeners(): void {
137
189
  }
138
190
  });
139
191
 
192
+ eventEmitter.addListener('KindlyGetAuthCredentials', async (raw: unknown) => {
193
+ const event = raw as { requestId: string; chatId: string };
194
+ if (authCredentialsCallback == null) {
195
+ NativeKindly.respondToAuthCredentials(event.requestId, null);
196
+ return;
197
+ }
198
+ try {
199
+ const credentials = await authCredentialsCallback(event.chatId);
200
+ NativeKindly.respondToAuthCredentials(
201
+ event.requestId,
202
+ credentials == null
203
+ ? null
204
+ : {
205
+ idToken: credentials.idToken ?? null,
206
+ accessToken: credentials.accessToken ?? null,
207
+ issuer: credentials.issuer ?? null,
208
+ expiresAt: credentials.expiresAt ?? null,
209
+ }
210
+ );
211
+ } catch {
212
+ NativeKindly.respondToAuthCredentials(event.requestId, null);
213
+ }
214
+ });
215
+
140
216
  eventEmitter.addListener('KindlyOnHandover', () => {
141
217
  handoverCallback?.();
142
218
  });
@@ -190,17 +266,53 @@ export class KindlySDK {
190
266
  market: string;
191
267
  languageCode?: string;
192
268
  authTokenCallback?: AuthTokenCallback;
269
+ /**
270
+ * Use instead of `authTokenCallback` when your identity provider issues more
271
+ * than a single JWT. Takes precedence when both are given.
272
+ */
273
+ authCredentialsCallback?: AuthCredentialsCallback;
193
274
  }): void {
194
275
  attachListeners();
195
276
  authTokenCallback = args.authTokenCallback ?? null;
277
+ authCredentialsCallback = args.authCredentialsCallback ?? null;
196
278
  NativeKindly.start(
197
279
  args.botKey,
198
280
  args.languageCode ?? null,
199
281
  args.market,
200
- args.authTokenCallback != null
282
+ args.authTokenCallback != null,
283
+ args.authCredentialsCallback != null
201
284
  );
202
285
  }
203
286
 
287
+ /**
288
+ * Re-authenticate the live chat, asking your callback for fresh credentials.
289
+ *
290
+ * For when the *identity* changed rather than the token: the user signed in,
291
+ * or switched account, while the chat was already open. Expiry is handled by
292
+ * the SDK on its own.
293
+ *
294
+ * The chat, its history and its socket are all kept. Rejects if the callback
295
+ * failed or the backend refused the credentials.
296
+ */
297
+ static authenticate(): Promise<void> {
298
+ return NativeKindly.authenticate();
299
+ }
300
+
301
+ /**
302
+ * Sign the user out of the chat without ending it.
303
+ *
304
+ * Unbinds the identity on the backend and forgets the stored credentials. The
305
+ * chat carries on anonymously with its history intact. Use `endChat()` when
306
+ * the conversation itself should end.
307
+ *
308
+ * Safe to call when already anonymous. The local credentials are cleared even
309
+ * if the backend call fails, but the promise still rejects so you know the
310
+ * backend did not hear about it.
311
+ */
312
+ static deauthenticate(): Promise<void> {
313
+ return NativeKindly.deauthenticate();
314
+ }
315
+
204
316
  /** Show the chat UI. */
205
317
  static displayChat(
206
318
  args: { languageCode?: string; triggerDialogueId?: string } = {}