@sagepilot-ai/react-native-sdk 0.4.0 → 0.4.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/README.md CHANGED
@@ -16,7 +16,7 @@ For full integration docs, see [React Native SDK docs](https://docs.sagepilot.ai
16
16
 
17
17
  ## Install
18
18
 
19
- The base SDK, camera add-on and push add-on share release **0.4.0**. Install matching versions of the add-ons your app uses; chat-only apps do not need either add-on.
19
+ The base SDK, camera add-on and push add-on share release **0.4.1**. Install matching versions of the add-ons your app uses; chat-only apps do not need either add-on.
20
20
 
21
21
  ```bash
22
22
  npm install @sagepilot-ai/react-native-sdk@latest react-native-webview
@@ -241,10 +241,12 @@ Full API reference: [SDK API reference](https://docs.sagepilot.ai/sdks/react-nat
241
241
 
242
242
  MIT
243
243
 
244
- ## Brand push notifications — unreleased 0.3.7
244
+ ## Brand push notifications (0.4.0)
245
245
 
246
246
  For apps using chat and push, use **one customer session** with the optional `@sagepilot-ai/react-native-push-addon`. The add-on owns native display, images, analytics buffering/retry/upload. The base SDK owns identity, installation/preferences and authenticated transport.
247
247
 
248
+ **Using Firebase/provider display still enables Sagepilot push analytics.** Connect Firebase methods with `createFirebasePushAdapter`, wrap it with `createSagepilotNativePushAdapter` as below, and complete the add-on's callback/native forwarding setup. The add-on uploads available receipt and open events for Sagepilot-sent notifications to journey/campaign reports. Token registration alone does not report engagement; destination success requires `push.track('destination_opened', ...)` after the screen loads.
249
+
248
250
  ```ts
249
251
  import { SagepilotChat, createFirebasePushAdapter } from '@sagepilot-ai/react-native-sdk';
250
252
  import { createSagepilotNativePushAdapter } from '@sagepilot-ai/react-native-push-addon';
@@ -271,7 +273,9 @@ await SagepilotChat.push.track('destination_opened', notificationMessage);
271
273
  await SagepilotChat.logout();
272
274
  ```
273
275
 
274
- The host backend authenticates its user, resolves the Sagepilot customer UUID and signs an HS256 proof with the brand channel's server-only `config.identity_verification.secret`. Required claims: `aud: "sagepilot-brand-push"`, `channel_id`, `customer_id`, `iat`, `exp`; maximum 300 seconds. Verification must be enabled on the brand channel. Never accept an arbitrary customer UUID from a client or embed the signing secret in an app.
276
+ The host backend authenticates its user and signs an HS256 proof with the brand channel's server-only `config.identity_verification.secret`. Required claims: `aud: "sagepilot-brand-push"`, `channel_id`, `client_customer_id` (or existing internal `customer_id`), `iat`, `exp`; maximum 300 seconds. A signed proof is always required for shared and standalone SDK push. There is no verification-off mode. Never accept an arbitrary customer UUID from a client or embed the signing secret in an app.
277
+
278
+ `authorizePush(proof)` and standalone `brand.identify(proof)` require a nonempty proof string. Missing proofs and plain identity objects fail locally without sending a request, changing the stored session or revoking its installation. Your app can fetch the proof automatically from its authenticated backend after sign-in.
275
279
 
276
280
  `authorizePush` upgrades the existing encrypted session with a verified brand grant. Workspace/customer must match; chat session/channel/conversation stay intact. The SDK stores and uses one token for both. Identify clears previous brand permission; authorize again afterwards. A same-customer hosted-chat token refresh preserves the grant's original expiry. Fresh proof is needed after 24 hours for registration/preferences; revocation and signed historical event uploads remain possible after proof freshness expires.
277
281
 
package/dist/index.js CHANGED
@@ -54,7 +54,7 @@ var import_react_native2 = require("react-native");
54
54
 
55
55
  // package.json
56
56
  var name = "@sagepilot-ai/react-native-sdk";
57
- var version = "0.4.0";
57
+ var version = "0.4.1";
58
58
 
59
59
  // src/core/config/constants.ts
60
60
  var SDK_NAME = name;
@@ -1094,6 +1094,9 @@ var SagepilotReactNativeChat = class {
1094
1094
  }
1095
1095
  /** Adds verified brand permission to the existing session; the host never manages another stored token. */
1096
1096
  async authorizePush(identityToken) {
1097
+ if (typeof identityToken !== "string" || !identityToken.trim()) {
1098
+ throw new SagepilotChatError("invalid_request", "A signed brand identity proof is required.");
1099
+ }
1097
1100
  const session = this.requireSession();
1098
1101
  if (!this.pushChannelId || !this.pushClient) throw new SagepilotChatError("invalid_config", "Configure push.channelId first.");
1099
1102
  if (this.identifyPending) throw new SagepilotChatError("invalid_request", "Another identity change is in progress.");
@@ -3475,6 +3478,7 @@ var SagepilotBrandPush = class {
3475
3478
  identify(identityToken) {
3476
3479
  return this.transition(async () => {
3477
3480
  if (!this.started) throw new Error("Call start before identify.");
3481
+ if (typeof identityToken !== "string" || !identityToken.trim()) throw new Error("A signed brand identity proof is required.");
3478
3482
  const next = await this.http.request(
3479
3483
  `${this.host}${CUSTOMER_API_PREFIX}/push/sessions`,
3480
3484
  {
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { AppState as AppState2, Platform } from "react-native";
3
3
 
4
4
  // package.json
5
5
  var name = "@sagepilot-ai/react-native-sdk";
6
- var version = "0.4.0";
6
+ var version = "0.4.1";
7
7
 
8
8
  // src/core/config/constants.ts
9
9
  var SDK_NAME = name;
@@ -1043,6 +1043,9 @@ var SagepilotReactNativeChat = class {
1043
1043
  }
1044
1044
  /** Adds verified brand permission to the existing session; the host never manages another stored token. */
1045
1045
  async authorizePush(identityToken) {
1046
+ if (typeof identityToken !== "string" || !identityToken.trim()) {
1047
+ throw new SagepilotChatError("invalid_request", "A signed brand identity proof is required.");
1048
+ }
1046
1049
  const session = this.requireSession();
1047
1050
  if (!this.pushChannelId || !this.pushClient) throw new SagepilotChatError("invalid_config", "Configure push.channelId first.");
1048
1051
  if (this.identifyPending) throw new SagepilotChatError("invalid_request", "Another identity change is in progress.");
@@ -3436,6 +3439,7 @@ var SagepilotBrandPush = class {
3436
3439
  identify(identityToken) {
3437
3440
  return this.transition(async () => {
3438
3441
  if (!this.started) throw new Error("Call start before identify.");
3442
+ if (typeof identityToken !== "string" || !identityToken.trim()) throw new Error("A signed brand identity proof is required.");
3439
3443
  const next = await this.http.request(
3440
3444
  `${this.host}${CUSTOMER_API_PREFIX}/push/sessions`,
3441
3445
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sagepilot-ai/react-native-sdk",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Sagepilot AI React Native chat SDK",
5
5
  "keywords": [
6
6
  "sagepilot",