@neuctra/authix 1.1.72 → 1.1.75

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.
@@ -1811,7 +1811,7 @@ class ui {
1811
1811
  const { name: r, email: s, password: i } = e;
1812
1812
  if (!r || !s || !i)
1813
1813
  throw new Error("signup: 'name', 'email', and 'password' are required");
1814
- return this.request("POST", "/users/signup", e, {}, !0);
1814
+ return await this.request("POST", "/users/signup", e, {}, !0);
1815
1815
  }
1816
1816
  /**
1817
1817
  * Login a user
@@ -1822,7 +1822,7 @@ class ui {
1822
1822
  if (!r || !s)
1823
1823
  throw new Error("login: 'email' and 'password' are required");
1824
1824
  try {
1825
- return this.request(
1825
+ return await this.request(
1826
1826
  "POST",
1827
1827
  "/users/login",
1828
1828
  { email: r, password: s },
@@ -1844,7 +1844,7 @@ class ui {
1844
1844
  throw new Error(
1845
1845
  "changePassword: both 'currentPassword' and 'newPassword' are required"
1846
1846
  );
1847
- return this.request(
1847
+ return await this.request(
1848
1848
  "PUT",
1849
1849
  `/users/change-password/${r}`,
1850
1850
  { currentPassword: s, newPassword: i },
@@ -1869,7 +1869,7 @@ class ui {
1869
1869
  status: 400
1870
1870
  };
1871
1871
  try {
1872
- return this.request(
1872
+ return await this.request(
1873
1873
  "POST",
1874
1874
  `/users/send-verify-otp/${encodeURIComponent(r)}`,
1875
1875
  { email: s },
@@ -1892,7 +1892,7 @@ class ui {
1892
1892
  if (!r) throw new Error("verifyEmail: 'email' is required");
1893
1893
  if (!s) throw new Error("verifyEmail: 'otp' is required");
1894
1894
  try {
1895
- return this.request(
1895
+ return await this.request(
1896
1896
  "POST",
1897
1897
  "/users/verify-email",
1898
1898
  { email: r, otp: s },
@@ -1914,7 +1914,7 @@ class ui {
1914
1914
  if (typeof window > "u")
1915
1915
  return { authenticated: !1 };
1916
1916
  try {
1917
- return this.request(
1917
+ return await this.request(
1918
1918
  "GET",
1919
1919
  "/users/session",
1920
1920
  void 0,
@@ -1932,7 +1932,7 @@ class ui {
1932
1932
  async updateUser(e) {
1933
1933
  const { userId: r } = e;
1934
1934
  if (!r) throw new Error("updateUser: 'userId' is required");
1935
- return this.request(
1935
+ return await this.request(
1936
1936
  "PUT",
1937
1937
  `/users/update/${r}`,
1938
1938
  { ...e },
@@ -1947,7 +1947,13 @@ class ui {
1947
1947
  async deleteUser(e) {
1948
1948
  const { userId: r } = e;
1949
1949
  if (!r) throw new Error("deleteUser: 'userId' is required");
1950
- return this.request("DELETE", `/users/delete/${r}`, {}, {}, !0);
1950
+ return await this.request(
1951
+ "DELETE",
1952
+ `/users/delete/${r}`,
1953
+ {},
1954
+ {},
1955
+ !0
1956
+ );
1951
1957
  }
1952
1958
  /**
1953
1959
  * Get the profile of a user for a specific app
@@ -1958,7 +1964,7 @@ class ui {
1958
1964
  if (!r)
1959
1965
  throw new Error("getProfile: 'userId' and 'appId' are required");
1960
1966
  try {
1961
- return this.request("POST", "/users/profile", { userId: r }, {}, !0);
1967
+ return await this.request("POST", "/users/profile", { userId: r }, {}, !0);
1962
1968
  } catch (s) {
1963
1969
  throw {
1964
1970
  message: s.message || "Failed to fetch profile",
@@ -1974,7 +1980,7 @@ class ui {
1974
1980
  async requestResetUserPasswordOTP(e) {
1975
1981
  const { email: r } = e;
1976
1982
  if (!r) throw new Error("forgotPassword: 'email' is required");
1977
- return this.request("POST", "/users/forgot-password", {
1983
+ return await this.request("POST", "/users/forgot-password", {
1978
1984
  email: r
1979
1985
  });
1980
1986
  }
@@ -1988,7 +1994,7 @@ class ui {
1988
1994
  throw new Error(
1989
1995
  "resetPassword: 'email', 'otp' and 'newPassword' are required"
1990
1996
  );
1991
- return this.request("POST", "/users/reset-password", {
1997
+ return await this.request("POST", "/users/reset-password", {
1992
1998
  email: r,
1993
1999
  otp: s,
1994
2000
  newPassword: i
@@ -2002,7 +2008,7 @@ class ui {
2002
2008
  async checkIfUserExists(e) {
2003
2009
  if (!e)
2004
2010
  throw new Error("checkUser: 'userId' is required");
2005
- return this.request(
2011
+ return await this.request(
2006
2012
  "GET",
2007
2013
  `/users/check-user/${e}?appId=${this.appId}`
2008
2014
  );
@@ -2012,7 +2018,7 @@ class ui {
2012
2018
  const { userId: r, ...s } = e;
2013
2019
  if (!r) throw new Error("userId required");
2014
2020
  const i = new URLSearchParams(s).toString();
2015
- return this.request(
2021
+ return await this.request(
2016
2022
  "GET",
2017
2023
  `/users/${r}/data/search?${i}`,
2018
2024
  void 0,
@@ -2042,7 +2048,7 @@ class ui {
2042
2048
  {}
2043
2049
  )
2044
2050
  ).toString();
2045
- return this.request(
2051
+ return await this.request(
2046
2052
  "GET",
2047
2053
  `/users/${r}/data/searchbyref?${i}`,
2048
2054
  void 0,
@@ -2058,7 +2064,7 @@ class ui {
2058
2064
  async getUserData(e) {
2059
2065
  const { userId: r } = e;
2060
2066
  if (!r) throw new Error("getUserData: 'userId' is required");
2061
- return this.request(
2067
+ return await this.request(
2062
2068
  "GET",
2063
2069
  `/users/${r}/data`,
2064
2070
  void 0,
@@ -2075,7 +2081,7 @@ class ui {
2075
2081
  const { userId: r, dataId: s } = e;
2076
2082
  if (!r || !s)
2077
2083
  throw new Error("getSingleUserData: 'userId' and 'dataId' are required");
2078
- return this.request(
2084
+ return await this.request(
2079
2085
  "GET",
2080
2086
  `/users/${r}/data/${s}`,
2081
2087
  void 0,
@@ -2094,7 +2100,7 @@ class ui {
2094
2100
  if (!s)
2095
2101
  throw new Error("addUserData: 'dataCategory' is required");
2096
2102
  if (!i) throw new Error("addUserData: 'data' is required");
2097
- return this.request(
2103
+ return await this.request(
2098
2104
  "POST",
2099
2105
  `/users/${r}/data`,
2100
2106
  {
@@ -2115,7 +2121,7 @@ class ui {
2115
2121
  if (!r || !s)
2116
2122
  throw new Error("updateUserData: 'userId' and 'dataId' are required");
2117
2123
  if (!i) throw new Error("updateUserData: 'data' is required");
2118
- return this.request(
2124
+ return await this.request(
2119
2125
  "PUT",
2120
2126
  `/users/${r}/data/${s}`,
2121
2127
  i,
@@ -2132,7 +2138,7 @@ class ui {
2132
2138
  const { userId: r, dataId: s } = e;
2133
2139
  if (!r || !s)
2134
2140
  throw new Error("deleteUserData: 'userId' and 'dataId' are required");
2135
- return this.request(
2141
+ return await this.request(
2136
2142
  "DELETE",
2137
2143
  `/users/${r}/data/${s}`,
2138
2144
  void 0,
@@ -2150,10 +2156,14 @@ class ui {
2150
2156
  const r = this.appId;
2151
2157
  if (!r) throw new Error("getAppData: 'appId' is required");
2152
2158
  const s = e ? `?category=${encodeURIComponent(e)}` : "";
2153
- return (await this.request(
2159
+ return await this.request(
2154
2160
  "GET",
2155
- `/app/${r}/data${s}`
2156
- ))?.data || [];
2161
+ `/app/${r}/data${s}`,
2162
+ void 0,
2163
+ {},
2164
+ !1
2165
+ // ✅ include credentials
2166
+ );
2157
2167
  }
2158
2168
  /**
2159
2169
  * Get a single data item from app.appData[] by id
@@ -2163,35 +2173,29 @@ class ui {
2163
2173
  if (!r) throw new Error("getSingleAppData: 'appId' is required");
2164
2174
  if (!e.dataId)
2165
2175
  throw new Error("getSingleAppData: 'dataId' is required");
2166
- return (await this.request(
2176
+ return await this.request(
2167
2177
  "GET",
2168
- `/app/${r}/data/${e.dataId}`
2169
- ))?.data;
2178
+ `/app/${r}/data/${e.dataId}`,
2179
+ void 0,
2180
+ {},
2181
+ !1
2182
+ );
2170
2183
  }
2171
2184
  /**
2172
2185
  * 🔍 Search app data items by dynamic keys (BODY based)
2173
- * @example
2174
- * sdk.searchAppDataByKeys({
2175
- * dataCategory: "order",
2176
- * buyerId: "user123",
2177
- * status: "Processing",
2178
- * q: "iphone"
2179
- * })
2180
2186
  */
2181
2187
  async searchAppDataByKeys(e) {
2182
2188
  const r = this.appId;
2183
- if (!r)
2184
- throw new Error("searchAppDataByKeys: 'appId' is required");
2189
+ if (!r) throw new Error("searchAppDataByKeys: 'appId' is required");
2185
2190
  if (!e || typeof e != "object")
2186
2191
  throw new Error("searchAppDataByKeys: params object is required");
2187
- return (await this.request(
2192
+ return await this.request(
2188
2193
  "POST",
2189
- // ✅ FIX: POST (body-based search)
2190
2194
  `/app/${encodeURIComponent(r)}/data/search/bykeys`,
2191
- // ✅ FIX: correct route
2192
- e
2193
- // ✅ BODY
2194
- ))?.data || [];
2195
+ e,
2196
+ {},
2197
+ !1
2198
+ );
2195
2199
  }
2196
2200
  /**
2197
2201
  * Add a new item to app.appData[] under a specific category
@@ -2204,14 +2208,13 @@ class ui {
2204
2208
  throw new Error("addAppData: 'dataCategory' is required");
2205
2209
  if (!i || typeof i != "object")
2206
2210
  throw new Error("addAppData: 'data' is required");
2207
- return (await this.request(
2211
+ return await this.request(
2208
2212
  "POST",
2209
2213
  `/app/${r}/data/${encodeURIComponent(s)}`,
2210
- {
2211
- item: i
2212
- // ✅ matches controller
2213
- }
2214
- ))?.data;
2214
+ { item: i },
2215
+ {},
2216
+ !1
2217
+ );
2215
2218
  }
2216
2219
  /**
2217
2220
  * Update an item in app.appData[] by id
@@ -2221,11 +2224,13 @@ class ui {
2221
2224
  if (!r) throw new Error("updateAppData: 'appId' is required");
2222
2225
  if (!e.dataId) throw new Error("updateAppData: 'dataId' is required");
2223
2226
  if (!e.data) throw new Error("updateAppData: 'data' is required");
2224
- return (await this.request(
2227
+ return await this.request(
2225
2228
  "PATCH",
2226
2229
  `/app/${r}/data/${e.dataId}`,
2227
- e.data
2228
- ))?.data;
2230
+ e.data,
2231
+ {},
2232
+ !1
2233
+ );
2229
2234
  }
2230
2235
  /**
2231
2236
  * Delete an item from app.appData[] by id
@@ -2234,10 +2239,13 @@ class ui {
2234
2239
  const r = this.appId;
2235
2240
  if (!r) throw new Error("deleteAppData: 'appId' is required");
2236
2241
  if (!e.dataId) throw new Error("deleteAppData: 'dataId' is required");
2237
- return (await this.request(
2242
+ return await this.request(
2238
2243
  "DELETE",
2239
- `/app/${r}/data/${e.dataId}`
2240
- ))?.data;
2244
+ `/app/${r}/data/${e.dataId}`,
2245
+ void 0,
2246
+ {},
2247
+ !1
2248
+ );
2241
2249
  }
2242
2250
  }
2243
2251
  var _e = { exports: {} }, Ee = {};
@@ -4252,106 +4260,42 @@ const qs = [
4252
4260
  );
4253
4261
  }, hi = ({
4254
4262
  children: t,
4255
- fallback: e = null,
4256
- loading: r = null
4263
+ fallback: e = null
4257
4264
  }) => {
4258
- const s = ue(), [i, o] = R(!1), [a, c] = R(null);
4265
+ const r = ue(), [s, i] = R(!1), [o, a] = R(null);
4259
4266
  if (te(() => {
4260
- o(!0), (async () => {
4267
+ i(!0);
4268
+ const p = document.cookie.split(";").map((m) => m.trim()).some((m) => m.startsWith("authix_session="));
4269
+ a(!!p), (async () => {
4261
4270
  try {
4262
- const m = await s.checkUserSession();
4263
- c(!!m?.authenticated);
4271
+ const m = await r.checkUserSession();
4272
+ a(!!m?.authenticated);
4264
4273
  } catch {
4265
- c(!1);
4274
+ a(!1);
4266
4275
  }
4267
4276
  })();
4268
- }, [s]), !i) return null;
4269
- const h = (d) => typeof d == "function" ? d() : d, p = /* @__PURE__ */ n.jsxs(
4270
- "div",
4271
- {
4272
- style: {
4273
- position: "fixed",
4274
- display: "flex",
4275
- justifyContent: "center",
4276
- alignItems: "center",
4277
- width: "100%",
4278
- height: "100%"
4279
- },
4280
- children: [
4281
- /* @__PURE__ */ n.jsx(
4282
- "div",
4283
- {
4284
- style: {
4285
- border: "4px solid rgba(0,0,0,0.1)",
4286
- borderTop: "4px solid #3498db",
4287
- borderRadius: "50%",
4288
- width: "36px",
4289
- height: "36px",
4290
- animation: "spin 1s linear infinite"
4291
- }
4292
- }
4293
- ),
4294
- /* @__PURE__ */ n.jsx("style", { children: `
4295
- @keyframes spin {
4296
- 0% { transform: rotate(0deg); }
4297
- 100% { transform: rotate(360deg); }
4298
- }
4299
- ` })
4300
- ]
4301
- }
4302
- );
4303
- return a === null ? h(r) ?? p : a ? /* @__PURE__ */ n.jsx(n.Fragment, { children: t }) : h(e);
4277
+ }, [r]), !s) return null;
4278
+ const c = (h) => typeof h == "function" ? h() : h;
4279
+ return o === null ? c(e) ?? null : o ? /* @__PURE__ */ n.jsx(n.Fragment, { children: t }) : c(e);
4304
4280
  }, mi = ({
4305
4281
  children: t,
4306
- fallback: e = null,
4307
- loading: r = null
4282
+ fallback: e = null
4308
4283
  }) => {
4309
- const s = ue(), [i, o] = R(!1), [a, c] = R(null);
4284
+ const r = ue(), [s, i] = R(!1), [o, a] = R(null);
4310
4285
  if (te(() => {
4311
- o(!0), (async () => {
4286
+ i(!0);
4287
+ const p = document.cookie.split(";").map((m) => m.trim()).some((m) => m.startsWith("authix_session="));
4288
+ a(!p), (async () => {
4312
4289
  try {
4313
- const m = await s.checkUserSession();
4314
- c(!m?.authenticated);
4290
+ const m = await r.checkUserSession();
4291
+ a(!m?.authenticated);
4315
4292
  } catch {
4316
- c(!0);
4293
+ a(!0);
4317
4294
  }
4318
4295
  })();
4319
- }, [s]), !i) return null;
4320
- const h = (d) => typeof d == "function" ? d() : d, p = /* @__PURE__ */ n.jsxs(
4321
- "div",
4322
- {
4323
- style: {
4324
- position: "fixed",
4325
- display: "flex",
4326
- justifyContent: "center",
4327
- alignItems: "center",
4328
- width: "100%",
4329
- height: "100%"
4330
- },
4331
- children: [
4332
- /* @__PURE__ */ n.jsx(
4333
- "div",
4334
- {
4335
- style: {
4336
- border: "4px solid rgba(0,0,0,0.1)",
4337
- borderTop: "4px solid #e74c3c",
4338
- borderRadius: "50%",
4339
- width: "36px",
4340
- height: "36px",
4341
- animation: "spin 1s linear infinite"
4342
- }
4343
- }
4344
- ),
4345
- /* @__PURE__ */ n.jsx("style", { children: `
4346
- @keyframes spin {
4347
- 0% { transform: rotate(0deg); }
4348
- 100% { transform: rotate(360deg); }
4349
- }
4350
- ` })
4351
- ]
4352
- }
4353
- );
4354
- return a === null ? h(r) ?? p : a ? /* @__PURE__ */ n.jsx(n.Fragment, { children: t }) : h(e);
4296
+ }, [r]), !s) return null;
4297
+ const c = (h) => typeof h == "function" ? h() : h;
4298
+ return o === null ? c(e) ?? null : o ? /* @__PURE__ */ n.jsx(n.Fragment, { children: t }) : c(e);
4355
4299
  }, Ms = ({
4356
4300
  isOpen: t,
4357
4301
  onClose: e,