@sagepilot-ai/react-native-sdk 0.4.0 → 0.4.2

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.2**. 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.d.mts CHANGED
@@ -542,6 +542,7 @@ type SagepilotPushAdapter = {
542
542
  workspaceId: string;
543
543
  channelId: string;
544
544
  sdkVersion: string;
545
+ storage?: SagepilotCacheStorage;
545
546
  owner: SagepilotPushOwner | null;
546
547
  customerId: () => string | null;
547
548
  upload: (event: SagepilotPushEvent) => Promise<unknown>;
package/dist/index.d.ts CHANGED
@@ -542,6 +542,7 @@ type SagepilotPushAdapter = {
542
542
  workspaceId: string;
543
543
  channelId: string;
544
544
  sdkVersion: string;
545
+ storage?: SagepilotCacheStorage;
545
546
  owner: SagepilotPushOwner | null;
546
547
  customerId: () => string | null;
547
548
  upload: (event: SagepilotPushEvent) => Promise<unknown>;
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.2";
58
58
 
59
59
  // src/core/config/constants.ts
60
60
  var SDK_NAME = name;
@@ -173,6 +173,7 @@ var SagepilotPush = class {
173
173
  workspaceId: this.context.workspaceId,
174
174
  channelId: this.context.channelId,
175
175
  sdkVersion: SDK_VERSION,
176
+ storage: this.config.storage,
176
177
  owner: binding?.endpointId && binding.customerId === this.context.customerId() ? { customerId: binding.customerId, endpointId: binding.endpointId } : null,
177
178
  customerId: this.context.customerId,
178
179
  upload: (event) => this.context.request("/push/events", "POST", event),
@@ -1094,6 +1095,9 @@ var SagepilotReactNativeChat = class {
1094
1095
  }
1095
1096
  /** Adds verified brand permission to the existing session; the host never manages another stored token. */
1096
1097
  async authorizePush(identityToken) {
1098
+ if (typeof identityToken !== "string" || !identityToken.trim()) {
1099
+ throw new SagepilotChatError("invalid_request", "A signed brand identity proof is required.");
1100
+ }
1097
1101
  const session = this.requireSession();
1098
1102
  if (!this.pushChannelId || !this.pushClient) throw new SagepilotChatError("invalid_config", "Configure push.channelId first.");
1099
1103
  if (this.identifyPending) throw new SagepilotChatError("invalid_request", "Another identity change is in progress.");
@@ -3475,6 +3479,7 @@ var SagepilotBrandPush = class {
3475
3479
  identify(identityToken) {
3476
3480
  return this.transition(async () => {
3477
3481
  if (!this.started) throw new Error("Call start before identify.");
3482
+ if (typeof identityToken !== "string" || !identityToken.trim()) throw new Error("A signed brand identity proof is required.");
3478
3483
  const next = await this.http.request(
3479
3484
  `${this.host}${CUSTOMER_API_PREFIX}/push/sessions`,
3480
3485
  {
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.2";
7
7
 
8
8
  // src/core/config/constants.ts
9
9
  var SDK_NAME = name;
@@ -122,6 +122,7 @@ var SagepilotPush = class {
122
122
  workspaceId: this.context.workspaceId,
123
123
  channelId: this.context.channelId,
124
124
  sdkVersion: SDK_VERSION,
125
+ storage: this.config.storage,
125
126
  owner: binding?.endpointId && binding.customerId === this.context.customerId() ? { customerId: binding.customerId, endpointId: binding.endpointId } : null,
126
127
  customerId: this.context.customerId,
127
128
  upload: (event) => this.context.request("/push/events", "POST", event),
@@ -1043,6 +1044,9 @@ var SagepilotReactNativeChat = class {
1043
1044
  }
1044
1045
  /** Adds verified brand permission to the existing session; the host never manages another stored token. */
1045
1046
  async authorizePush(identityToken) {
1047
+ if (typeof identityToken !== "string" || !identityToken.trim()) {
1048
+ throw new SagepilotChatError("invalid_request", "A signed brand identity proof is required.");
1049
+ }
1046
1050
  const session = this.requireSession();
1047
1051
  if (!this.pushChannelId || !this.pushClient) throw new SagepilotChatError("invalid_config", "Configure push.channelId first.");
1048
1052
  if (this.identifyPending) throw new SagepilotChatError("invalid_request", "Another identity change is in progress.");
@@ -3436,6 +3440,7 @@ var SagepilotBrandPush = class {
3436
3440
  identify(identityToken) {
3437
3441
  return this.transition(async () => {
3438
3442
  if (!this.started) throw new Error("Call start before identify.");
3443
+ if (typeof identityToken !== "string" || !identityToken.trim()) throw new Error("A signed brand identity proof is required.");
3439
3444
  const next = await this.http.request(
3440
3445
  `${this.host}${CUSTOMER_API_PREFIX}/push/sessions`,
3441
3446
  {
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.2",
4
4
  "description": "Sagepilot AI React Native chat SDK",
5
5
  "keywords": [
6
6
  "sagepilot",