@sendoracloud/sdk-react-native 0.9.0 → 0.10.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/dist/index.cjs CHANGED
@@ -200,11 +200,14 @@ function isAuthApiResponse(v) {
200
200
  const user = r.user;
201
201
  const tokens = r.tokens;
202
202
  if (!user || typeof user.id !== "string" || user.id.length === 0) return false;
203
- if (typeof user.isAnonymous !== "boolean") return false;
204
203
  if (!tokens) return false;
205
204
  if (typeof tokens.accessToken !== "string" || tokens.accessToken.length === 0) return false;
206
205
  if (typeof tokens.refreshToken !== "string" || tokens.refreshToken.length === 0) return false;
207
206
  if (typeof tokens.expiresIn !== "number" || tokens.expiresIn <= 0) return false;
207
+ if (user.isAnonymous !== void 0 && typeof user.isAnonymous !== "boolean") return false;
208
+ if (user.email !== void 0 && user.email !== null && typeof user.email !== "string") return false;
209
+ if (user.emailVerified !== void 0 && typeof user.emailVerified !== "boolean") return false;
210
+ if (user.name !== void 0 && user.name !== null && typeof user.name !== "string") return false;
208
211
  return true;
209
212
  }
210
213
  var EmailAlreadyTakenError = class extends Error {
@@ -767,7 +770,7 @@ function decodeJwtPayload(token) {
767
770
  }
768
771
 
769
772
  // src/index.ts
770
- var SDK_VERSION = "0.4.0";
773
+ var SDK_VERSION = "0.10.1";
771
774
  var DEFAULT_API_URL = "https://api.sendoracloud.com";
772
775
  var ANON_KEY = "anon_id";
773
776
  var USER_ID_KEY = "user_id";
@@ -816,7 +819,7 @@ var SendoraSDK = class {
816
819
  }
817
820
  /** Initialize the SDK. Must be awaited at app startup before identify/track. */
818
821
  async init(config) {
819
- const rawKey = String(config.publicKey ?? "").trim();
822
+ const rawKey = String(config.apiKey ?? config.publicKey ?? "").trim();
820
823
  if (/^sk_/i.test(rawKey) || /sk_(prod|staging|dev|live|test)_/i.test(rawKey)) {
821
824
  throw new Error(
822
825
  "[sendoracloud] Secret key (sk_*) detected. The client SDK must only receive public keys (pk_*). Secret keys belong on your server."
@@ -861,6 +864,10 @@ var SendoraSDK = class {
861
864
  environment: "prod",
862
865
  consentedByDefault: true,
863
866
  ...config,
867
+ // Store rawKey on BOTH fields so any downstream reader that
868
+ // grabbed the legacy `publicKey` field keeps working, and
869
+ // future code reading `apiKey` does too.
870
+ apiKey: rawKey,
864
871
  publicKey: rawKey
865
872
  };
866
873
  this.auth = new Auth({
package/dist/index.d.cts CHANGED
@@ -241,9 +241,23 @@ declare class Auth {
241
241
  }
242
242
 
243
243
  interface SendoraConfig {
244
- /** Public API key (pk_live_... or pk_test_...). Secret keys are refused. */
245
- publicKey: string;
246
- /** Org UUID defaults to the key's bound org, but can be overridden for test harnesses. */
244
+ /**
245
+ * Public API key (`pk_live_…` or `pk_test_…`). Secret keys are refused.
246
+ * Canonical name as of 0.10.0 pre-0.10.0 callers using `publicKey`
247
+ * still work via the deprecated alias below.
248
+ */
249
+ apiKey?: string;
250
+ /**
251
+ * @deprecated Use `apiKey` instead (0.10.0+ canonical name across
252
+ * sdk-web / sdk-ios / sdk-android). Kept for back-compat — when
253
+ * both are set, `apiKey` wins.
254
+ */
255
+ publicKey?: string;
256
+ /**
257
+ * @deprecated 0.10.0 — backend now derives org from the API key
258
+ * row server-side. Kept for test harnesses that need to override
259
+ * the bound org explicitly.
260
+ */
247
261
  orgId?: string;
248
262
  /** Backend base URL. Defaults to Sendora's production API. */
249
263
  apiUrl?: string;
package/dist/index.d.ts CHANGED
@@ -241,9 +241,23 @@ declare class Auth {
241
241
  }
242
242
 
243
243
  interface SendoraConfig {
244
- /** Public API key (pk_live_... or pk_test_...). Secret keys are refused. */
245
- publicKey: string;
246
- /** Org UUID defaults to the key's bound org, but can be overridden for test harnesses. */
244
+ /**
245
+ * Public API key (`pk_live_…` or `pk_test_…`). Secret keys are refused.
246
+ * Canonical name as of 0.10.0 pre-0.10.0 callers using `publicKey`
247
+ * still work via the deprecated alias below.
248
+ */
249
+ apiKey?: string;
250
+ /**
251
+ * @deprecated Use `apiKey` instead (0.10.0+ canonical name across
252
+ * sdk-web / sdk-ios / sdk-android). Kept for back-compat — when
253
+ * both are set, `apiKey` wins.
254
+ */
255
+ publicKey?: string;
256
+ /**
257
+ * @deprecated 0.10.0 — backend now derives org from the API key
258
+ * row server-side. Kept for test harnesses that need to override
259
+ * the bound org explicitly.
260
+ */
247
261
  orgId?: string;
248
262
  /** Backend base URL. Defaults to Sendora's production API. */
249
263
  apiUrl?: string;
package/dist/index.js CHANGED
@@ -160,11 +160,14 @@ function isAuthApiResponse(v) {
160
160
  const user = r.user;
161
161
  const tokens = r.tokens;
162
162
  if (!user || typeof user.id !== "string" || user.id.length === 0) return false;
163
- if (typeof user.isAnonymous !== "boolean") return false;
164
163
  if (!tokens) return false;
165
164
  if (typeof tokens.accessToken !== "string" || tokens.accessToken.length === 0) return false;
166
165
  if (typeof tokens.refreshToken !== "string" || tokens.refreshToken.length === 0) return false;
167
166
  if (typeof tokens.expiresIn !== "number" || tokens.expiresIn <= 0) return false;
167
+ if (user.isAnonymous !== void 0 && typeof user.isAnonymous !== "boolean") return false;
168
+ if (user.email !== void 0 && user.email !== null && typeof user.email !== "string") return false;
169
+ if (user.emailVerified !== void 0 && typeof user.emailVerified !== "boolean") return false;
170
+ if (user.name !== void 0 && user.name !== null && typeof user.name !== "string") return false;
168
171
  return true;
169
172
  }
170
173
  var EmailAlreadyTakenError = class extends Error {
@@ -727,7 +730,7 @@ function decodeJwtPayload(token) {
727
730
  }
728
731
 
729
732
  // src/index.ts
730
- var SDK_VERSION = "0.4.0";
733
+ var SDK_VERSION = "0.10.1";
731
734
  var DEFAULT_API_URL = "https://api.sendoracloud.com";
732
735
  var ANON_KEY = "anon_id";
733
736
  var USER_ID_KEY = "user_id";
@@ -776,7 +779,7 @@ var SendoraSDK = class {
776
779
  }
777
780
  /** Initialize the SDK. Must be awaited at app startup before identify/track. */
778
781
  async init(config) {
779
- const rawKey = String(config.publicKey ?? "").trim();
782
+ const rawKey = String(config.apiKey ?? config.publicKey ?? "").trim();
780
783
  if (/^sk_/i.test(rawKey) || /sk_(prod|staging|dev|live|test)_/i.test(rawKey)) {
781
784
  throw new Error(
782
785
  "[sendoracloud] Secret key (sk_*) detected. The client SDK must only receive public keys (pk_*). Secret keys belong on your server."
@@ -821,6 +824,10 @@ var SendoraSDK = class {
821
824
  environment: "prod",
822
825
  consentedByDefault: true,
823
826
  ...config,
827
+ // Store rawKey on BOTH fields so any downstream reader that
828
+ // grabbed the legacy `publicKey` field keeps working, and
829
+ // future code reading `apiKey` does too.
830
+ apiKey: rawKey,
824
831
  publicKey: rawKey
825
832
  };
826
833
  this.auth = new Auth({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendoracloud/sdk-react-native",
3
- "version": "0.9.0",
3
+ "version": "0.10.1",
4
4
  "description": "Sendora Cloud React Native + Expo SDK — analytics, identity, push-token registration, auth. Expo Go compatible, no native modules beyond AsyncStorage.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",