arky-sdk 0.3.152 → 0.3.153

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
@@ -46,14 +46,14 @@ function buildQueryString(params) {
46
46
 
47
47
  // src/services/createHttpClient.ts
48
48
  function createHttpClient(cfg) {
49
- const refreshEndpoint = `${cfg.baseUrl}/v1/accounts/refresh-access-token`;
49
+ const refreshEndpoint = `${cfg.baseUrl}/v1/auth/refresh`;
50
50
  let refreshPromise = null;
51
51
  async function ensureFreshToken() {
52
52
  if (refreshPromise) {
53
53
  return refreshPromise;
54
54
  }
55
55
  refreshPromise = (async () => {
56
- const { refreshToken, provider } = await cfg.getToken();
56
+ const { refreshToken } = await cfg.getToken();
57
57
  if (!refreshToken) {
58
58
  cfg.logout();
59
59
  const err = new Error("No refresh token available");
@@ -64,7 +64,7 @@ function createHttpClient(cfg) {
64
64
  const refRes = await fetch(refreshEndpoint, {
65
65
  method: "POST",
66
66
  headers: { Accept: "application/json", "Content-Type": "application/json" },
67
- body: JSON.stringify({ provider, refreshToken })
67
+ body: JSON.stringify({ refreshToken })
68
68
  });
69
69
  if (!refRes.ok) {
70
70
  cfg.logout();
@@ -247,20 +247,6 @@ var createAccountApi = (apiConfig) => {
247
247
  async setRole(params, options) {
248
248
  return apiConfig.httpClient.put("/v1/accounts/set-role", params, options);
249
249
  },
250
- // ===== AUTHENTICATION =====
251
- async login(params, options) {
252
- return apiConfig.httpClient.post("/v1/accounts/login", params, options);
253
- },
254
- async logout(params, options) {
255
- return apiConfig.httpClient.post("/v1/accounts/logout", {}, options);
256
- },
257
- // ===== MAGIC LINK =====
258
- async requestMagicLink(params, options) {
259
- return apiConfig.httpClient.post("/v1/accounts/magic-link/request", params, options);
260
- },
261
- async verifyMagicLink(params, options) {
262
- return apiConfig.httpClient.post("/v1/accounts/magic-link/verify", params, options);
263
- },
264
250
  // ===== SUBSCRIPTION =====
265
251
  async subscribe(params, options) {
266
252
  return apiConfig.httpClient.post("/v1/accounts/subscribe", params, options);
@@ -268,6 +254,40 @@ var createAccountApi = (apiConfig) => {
268
254
  };
269
255
  };
270
256
 
257
+ // src/api/auth.ts
258
+ var createAuthApi = (apiConfig) => {
259
+ return {
260
+ /**
261
+ * Create a guest session (anonymous user)
262
+ * POST /auth/session
263
+ */
264
+ async session(options) {
265
+ return apiConfig.httpClient.post("/v1/auth/session", {}, options);
266
+ },
267
+ /**
268
+ * Request a magic link to be sent to email
269
+ * POST /auth/magic-link
270
+ */
271
+ async magicLink(params, options) {
272
+ return apiConfig.httpClient.post("/v1/auth/magic-link", params, options);
273
+ },
274
+ /**
275
+ * Verify magic link token and get auth tokens
276
+ * POST /auth/verify
277
+ */
278
+ async verify(params, options) {
279
+ return apiConfig.httpClient.post("/v1/auth/verify", params, options);
280
+ },
281
+ /**
282
+ * Refresh access token
283
+ * POST /auth/refresh
284
+ */
285
+ async refresh(params, options) {
286
+ return apiConfig.httpClient.post("/v1/auth/refresh", params, options);
287
+ }
288
+ };
289
+ };
290
+
271
291
  // src/api/business.ts
272
292
  var createBusinessApi = (apiConfig) => {
273
293
  return {
@@ -1899,7 +1919,7 @@ function nameToKey(name) {
1899
1919
  }
1900
1920
 
1901
1921
  // src/index.ts
1902
- var SDK_VERSION = "0.3.145";
1922
+ var SDK_VERSION = "0.3.153";
1903
1923
  var SUPPORTED_FRAMEWORKS = [
1904
1924
  "astro",
1905
1925
  "react",
@@ -1920,14 +1940,13 @@ async function createArkySDK(config) {
1920
1940
  getToken: config.getToken
1921
1941
  };
1922
1942
  const accountApi = createAccountApi(apiConfig);
1943
+ const authApi = createAuthApi(apiConfig);
1923
1944
  const autoGuest = config.autoGuest !== void 0 ? config.autoGuest : true;
1924
1945
  if (autoGuest) {
1925
1946
  try {
1926
1947
  const tokens = await config.getToken();
1927
1948
  if (!tokens.accessToken && !tokens.refreshToken) {
1928
- const result = await httpClient.post("/v1/accounts/login", {
1929
- provider: "GUEST"
1930
- });
1949
+ const result = await httpClient.post("/v1/auth/session", {});
1931
1950
  const token = result.accessToken || result.token || "";
1932
1951
  if (token) {
1933
1952
  config.setToken(result);
@@ -1937,6 +1956,7 @@ async function createArkySDK(config) {
1937
1956
  }
1938
1957
  }
1939
1958
  const sdk = {
1959
+ auth: authApi,
1940
1960
  account: accountApi,
1941
1961
  business: createBusinessApi(apiConfig),
1942
1962
  media: createMediaApi(apiConfig),