@sendoracloud/sdk-react-native 1.7.0 → 1.8.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
@@ -222,7 +222,7 @@ async function request(opts, method, path, body, extraHeaders, reqOpts) {
222
222
  // package.json
223
223
  var package_default = {
224
224
  name: "@sendoracloud/sdk-react-native",
225
- version: "1.7.0",
225
+ version: "1.8.1",
226
226
  description: "Sendora Cloud React Native + Expo SDK \u2014 analytics, identity, push-token registration, auth, deep links (Branch / Firebase Dynamic Links parity). Auth + analytics + deep links work in Expo Go; push token registration requires a Dev Client (EAS Build or `npx expo prebuild`).",
227
227
  type: "module",
228
228
  main: "./dist/index.cjs",
@@ -857,6 +857,53 @@ var Auth = class {
857
857
  this.bearerHeaders()
858
858
  );
859
859
  }
860
+ /**
861
+ * Delete the signed-in user's account (Apple App Store Guideline 5.1.1(v)).
862
+ * Honors the project's configured grace period:
863
+ * - `"purged"` — hard-deleted immediately (grace = 0).
864
+ * - `"pending"` — deactivated + all sessions revoked now; hard-deleted at
865
+ * `scheduledPurgeAt`. The user can CANCEL by signing back in before then.
866
+ * Either outcome wipes local identity (the server has already revoked the
867
+ * session). Requires a signed-in user. Throws on a non-2xx response.
868
+ *
869
+ * Resolves a FRESH access token via `getAccessToken()` first (refreshing if
870
+ * the cached one expired) — unlike the other Bearer calls this is a one-shot
871
+ * destructive action, so a 401 from a stale token would silently strand the
872
+ * user with an undeleted account. A stale `this.accessToken` was the cause of
873
+ * the 401s seen in prod when a user tapped "delete" after the app sat idle.
874
+ */
875
+ async deleteAccount() {
876
+ const token = await this.getAccessToken();
877
+ if (!token) {
878
+ throw new AuthError("NOT_SIGNED_IN", "Sign in before deleting your account");
879
+ }
880
+ const res = await del(
881
+ { apiUrl: this.hooks.apiUrl, publicKey: this.hooks.publicKey, debug: this.hooks.debug },
882
+ "/api/v1/auth-service/me",
883
+ { Authorization: `Bearer ${token}` }
884
+ );
885
+ if (!res || !res.ok) {
886
+ throw new Error(`deleteAccount failed${res ? ` (HTTP ${res.status})` : " (network error)"}`);
887
+ }
888
+ let out = {
889
+ status: "pending",
890
+ scheduledPurgeAt: null,
891
+ graceDays: 0
892
+ };
893
+ try {
894
+ const parsed = await res.json();
895
+ if (parsed.data?.status) {
896
+ out = {
897
+ status: parsed.data.status,
898
+ scheduledPurgeAt: parsed.data.scheduledPurgeAt ?? null,
899
+ graceDays: parsed.data.graceDays ?? 0
900
+ };
901
+ }
902
+ } catch {
903
+ }
904
+ await this.wipeLocalIdentity();
905
+ return out;
906
+ }
860
907
  // ============================================================
861
908
  // OIDC SSO
862
909
  // ============================================================
package/dist/index.d.cts CHANGED
@@ -345,6 +345,26 @@ declare class Auth {
345
345
  }>>;
346
346
  revokeSession(sessionId: string): Promise<void>;
347
347
  revokeAllSessions(): Promise<void>;
348
+ /**
349
+ * Delete the signed-in user's account (Apple App Store Guideline 5.1.1(v)).
350
+ * Honors the project's configured grace period:
351
+ * - `"purged"` — hard-deleted immediately (grace = 0).
352
+ * - `"pending"` — deactivated + all sessions revoked now; hard-deleted at
353
+ * `scheduledPurgeAt`. The user can CANCEL by signing back in before then.
354
+ * Either outcome wipes local identity (the server has already revoked the
355
+ * session). Requires a signed-in user. Throws on a non-2xx response.
356
+ *
357
+ * Resolves a FRESH access token via `getAccessToken()` first (refreshing if
358
+ * the cached one expired) — unlike the other Bearer calls this is a one-shot
359
+ * destructive action, so a 401 from a stale token would silently strand the
360
+ * user with an undeleted account. A stale `this.accessToken` was the cause of
361
+ * the 401s seen in prod when a user tapped "delete" after the app sat idle.
362
+ */
363
+ deleteAccount(): Promise<{
364
+ status: "purged" | "pending";
365
+ scheduledPurgeAt: string | null;
366
+ graceDays: number;
367
+ }>;
348
368
  /**
349
369
  * Start OIDC sign-in. Returns the IdP's authorization URL — caller
350
370
  * opens it via React Native's `Linking.openURL()` (or
package/dist/index.d.ts CHANGED
@@ -345,6 +345,26 @@ declare class Auth {
345
345
  }>>;
346
346
  revokeSession(sessionId: string): Promise<void>;
347
347
  revokeAllSessions(): Promise<void>;
348
+ /**
349
+ * Delete the signed-in user's account (Apple App Store Guideline 5.1.1(v)).
350
+ * Honors the project's configured grace period:
351
+ * - `"purged"` — hard-deleted immediately (grace = 0).
352
+ * - `"pending"` — deactivated + all sessions revoked now; hard-deleted at
353
+ * `scheduledPurgeAt`. The user can CANCEL by signing back in before then.
354
+ * Either outcome wipes local identity (the server has already revoked the
355
+ * session). Requires a signed-in user. Throws on a non-2xx response.
356
+ *
357
+ * Resolves a FRESH access token via `getAccessToken()` first (refreshing if
358
+ * the cached one expired) — unlike the other Bearer calls this is a one-shot
359
+ * destructive action, so a 401 from a stale token would silently strand the
360
+ * user with an undeleted account. A stale `this.accessToken` was the cause of
361
+ * the 401s seen in prod when a user tapped "delete" after the app sat idle.
362
+ */
363
+ deleteAccount(): Promise<{
364
+ status: "purged" | "pending";
365
+ scheduledPurgeAt: string | null;
366
+ graceDays: number;
367
+ }>;
348
368
  /**
349
369
  * Start OIDC sign-in. Returns the IdP's authorization URL — caller
350
370
  * opens it via React Native's `Linking.openURL()` (or
package/dist/index.js CHANGED
@@ -179,7 +179,7 @@ async function request(opts, method, path, body, extraHeaders, reqOpts) {
179
179
  // package.json
180
180
  var package_default = {
181
181
  name: "@sendoracloud/sdk-react-native",
182
- version: "1.7.0",
182
+ version: "1.8.1",
183
183
  description: "Sendora Cloud React Native + Expo SDK \u2014 analytics, identity, push-token registration, auth, deep links (Branch / Firebase Dynamic Links parity). Auth + analytics + deep links work in Expo Go; push token registration requires a Dev Client (EAS Build or `npx expo prebuild`).",
184
184
  type: "module",
185
185
  main: "./dist/index.cjs",
@@ -814,6 +814,53 @@ var Auth = class {
814
814
  this.bearerHeaders()
815
815
  );
816
816
  }
817
+ /**
818
+ * Delete the signed-in user's account (Apple App Store Guideline 5.1.1(v)).
819
+ * Honors the project's configured grace period:
820
+ * - `"purged"` — hard-deleted immediately (grace = 0).
821
+ * - `"pending"` — deactivated + all sessions revoked now; hard-deleted at
822
+ * `scheduledPurgeAt`. The user can CANCEL by signing back in before then.
823
+ * Either outcome wipes local identity (the server has already revoked the
824
+ * session). Requires a signed-in user. Throws on a non-2xx response.
825
+ *
826
+ * Resolves a FRESH access token via `getAccessToken()` first (refreshing if
827
+ * the cached one expired) — unlike the other Bearer calls this is a one-shot
828
+ * destructive action, so a 401 from a stale token would silently strand the
829
+ * user with an undeleted account. A stale `this.accessToken` was the cause of
830
+ * the 401s seen in prod when a user tapped "delete" after the app sat idle.
831
+ */
832
+ async deleteAccount() {
833
+ const token = await this.getAccessToken();
834
+ if (!token) {
835
+ throw new AuthError("NOT_SIGNED_IN", "Sign in before deleting your account");
836
+ }
837
+ const res = await del(
838
+ { apiUrl: this.hooks.apiUrl, publicKey: this.hooks.publicKey, debug: this.hooks.debug },
839
+ "/api/v1/auth-service/me",
840
+ { Authorization: `Bearer ${token}` }
841
+ );
842
+ if (!res || !res.ok) {
843
+ throw new Error(`deleteAccount failed${res ? ` (HTTP ${res.status})` : " (network error)"}`);
844
+ }
845
+ let out = {
846
+ status: "pending",
847
+ scheduledPurgeAt: null,
848
+ graceDays: 0
849
+ };
850
+ try {
851
+ const parsed = await res.json();
852
+ if (parsed.data?.status) {
853
+ out = {
854
+ status: parsed.data.status,
855
+ scheduledPurgeAt: parsed.data.scheduledPurgeAt ?? null,
856
+ graceDays: parsed.data.graceDays ?? 0
857
+ };
858
+ }
859
+ } catch {
860
+ }
861
+ await this.wipeLocalIdentity();
862
+ return out;
863
+ }
817
864
  // ============================================================
818
865
  // OIDC SSO
819
866
  // ============================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendoracloud/sdk-react-native",
3
- "version": "1.7.0",
3
+ "version": "1.8.1",
4
4
  "description": "Sendora Cloud React Native + Expo SDK — analytics, identity, push-token registration, auth, deep links (Branch / Firebase Dynamic Links parity). Auth + analytics + deep links work in Expo Go; push token registration requires a Dev Client (EAS Build or `npx expo prebuild`).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",