arky-sdk 0.3.3 → 0.3.4

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.d.cts CHANGED
@@ -14,8 +14,8 @@ interface HttpClientConfig {
14
14
  baseUrl: string;
15
15
  storageUrl?: string;
16
16
  businessId: string;
17
- getTokens: () => Promise<AuthTokens> | AuthTokens;
18
- setTokens: (tokens: AuthTokens) => void;
17
+ getToken: () => Promise<AuthTokens> | AuthTokens;
18
+ setToken: (tokens: AuthTokens) => void;
19
19
  autoGuest?: boolean;
20
20
  logout: () => void;
21
21
  navigate?: (path: string) => void;
@@ -214,7 +214,7 @@ declare function buildQueryString(params: QueryParams): string;
214
214
  */
215
215
  declare function appendQueryString(url: string, params: QueryParams): string;
216
216
 
217
- declare const SDK_VERSION = "0.3.3";
217
+ declare const SDK_VERSION = "0.3.4";
218
218
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
219
219
  interface ApiConfig {
220
220
  httpClient: any;
@@ -382,7 +382,7 @@ declare function createArkySDK(config: HttpClientConfig & {
382
382
  getBusinessId: () => string;
383
383
  isAuthenticated: () => boolean;
384
384
  logout: () => void;
385
- setTokens: (tokens: AuthTokens) => void;
385
+ setToken: (tokens: AuthTokens) => void;
386
386
  utils: {
387
387
  getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
388
388
  thumbnailUrl: (service: any) => string;
package/dist/index.d.ts CHANGED
@@ -14,8 +14,8 @@ interface HttpClientConfig {
14
14
  baseUrl: string;
15
15
  storageUrl?: string;
16
16
  businessId: string;
17
- getTokens: () => Promise<AuthTokens> | AuthTokens;
18
- setTokens: (tokens: AuthTokens) => void;
17
+ getToken: () => Promise<AuthTokens> | AuthTokens;
18
+ setToken: (tokens: AuthTokens) => void;
19
19
  autoGuest?: boolean;
20
20
  logout: () => void;
21
21
  navigate?: (path: string) => void;
@@ -214,7 +214,7 @@ declare function buildQueryString(params: QueryParams): string;
214
214
  */
215
215
  declare function appendQueryString(url: string, params: QueryParams): string;
216
216
 
217
- declare const SDK_VERSION = "0.3.3";
217
+ declare const SDK_VERSION = "0.3.4";
218
218
  declare const SUPPORTED_FRAMEWORKS: readonly ["astro", "react", "vue", "svelte", "vanilla"];
219
219
  interface ApiConfig {
220
220
  httpClient: any;
@@ -382,7 +382,7 @@ declare function createArkySDK(config: HttpClientConfig & {
382
382
  getBusinessId: () => string;
383
383
  isAuthenticated: () => boolean;
384
384
  logout: () => void;
385
- setTokens: (tokens: AuthTokens) => void;
385
+ setToken: (tokens: AuthTokens) => void;
386
386
  utils: {
387
387
  getImageUrl: (imageBlock: any, isBlock?: boolean) => any;
388
388
  thumbnailUrl: (service: any) => string;
package/dist/index.js CHANGED
@@ -1627,7 +1627,7 @@ function createHttpClient(cfg) {
1627
1627
  "Content-Type": "application/json",
1628
1628
  ...options?.headers || {}
1629
1629
  };
1630
- let { accessToken, refreshToken, provider, expiresAt } = await cfg.getTokens();
1630
+ let { accessToken, refreshToken, provider, expiresAt } = await cfg.getToken();
1631
1631
  const nowSec = Date.now() / 1e3;
1632
1632
  if (expiresAt && nowSec > expiresAt) {
1633
1633
  if (refreshToken) {
@@ -1638,7 +1638,7 @@ function createHttpClient(cfg) {
1638
1638
  });
1639
1639
  if (refRes.ok) {
1640
1640
  const data2 = await refRes.json();
1641
- cfg.setTokens(data2);
1641
+ cfg.setToken(data2);
1642
1642
  accessToken = data2.accessToken;
1643
1643
  } else {
1644
1644
  cfg.logout();
@@ -1701,7 +1701,7 @@ function createHttpClient(cfg) {
1701
1701
  }
1702
1702
 
1703
1703
  // src/index.ts
1704
- var SDK_VERSION = "0.3.3";
1704
+ var SDK_VERSION = "0.3.4";
1705
1705
  var SUPPORTED_FRAMEWORKS = ["astro", "react", "vue", "svelte", "vanilla"];
1706
1706
  function createArkySDK(config) {
1707
1707
  const httpClient = createHttpClient(config);
@@ -1712,8 +1712,8 @@ function createArkySDK(config) {
1712
1712
  storageUrl,
1713
1713
  baseUrl: config.baseUrl,
1714
1714
  market: config.market || "US",
1715
- setTokens: config.setTokens,
1716
- getTokens: config.getTokens
1715
+ setTokens: config.setToken,
1716
+ getTokens: config.getToken
1717
1717
  };
1718
1718
  const userApi = createUserApi(apiConfig);
1719
1719
  const autoGuest = config.autoGuest !== void 0 ? config.autoGuest : true;
@@ -1736,7 +1736,7 @@ function createArkySDK(config) {
1736
1736
  getBusinessId: () => apiConfig.businessId,
1737
1737
  isAuthenticated: config.isAuthenticated || (() => false),
1738
1738
  logout: config.logout,
1739
- setTokens: config.setTokens,
1739
+ setToken: config.setToken,
1740
1740
  utils: {
1741
1741
  getImageUrl: (imageBlock, isBlock = true) => getImageUrl(imageBlock, isBlock, storageUrl),
1742
1742
  thumbnailUrl: (service) => thumbnailUrl(service, storageUrl),
@@ -1755,7 +1755,7 @@ function createArkySDK(config) {
1755
1755
  if (autoGuest) {
1756
1756
  Promise.resolve().then(async () => {
1757
1757
  try {
1758
- const tokens = await config.getTokens();
1758
+ const tokens = await config.getToken();
1759
1759
  if (!tokens.accessToken && !tokens.refreshToken) {
1760
1760
  const guestToken = await userApi.getGuestToken({});
1761
1761
  console.log("[SDK Init] Created guest token:", guestToken ? "Success" : "Failed");