arky-sdk 0.7.106 → 0.7.108

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/admin.cjs CHANGED
@@ -2102,6 +2102,14 @@ function getFirstAvailableFCId(variant, quantity = 1) {
2102
2102
  return inv?.location_id;
2103
2103
  }
2104
2104
 
2105
+ // src/utils/session.ts
2106
+ function getPaymentConfig(store, market) {
2107
+ const provider = store?.payment ?? null;
2108
+ const methods = market?.payment_methods || [];
2109
+ const hasCreditCard = methods.some((m) => m.id === "credit_card");
2110
+ return { provider, enabled: hasCreditCard && !!provider };
2111
+ }
2112
+
2105
2113
  // src/index.ts
2106
2114
  function createUtilitySurface(apiConfig) {
2107
2115
  return {
@@ -2121,6 +2129,7 @@ function createUtilitySurface(apiConfig) {
2121
2129
  formatMinor,
2122
2130
  getCurrencySymbol,
2123
2131
  getCurrencyName,
2132
+ getPaymentConfig,
2124
2133
  validatePhoneNumber,
2125
2134
  tzGroups,
2126
2135
  findTimeZone,
@@ -2174,12 +2183,19 @@ function createAdmin(config) {
2174
2183
  }
2175
2184
  }
2176
2185
  const updateSession = (updater) => {
2186
+ if (config.apiToken) return;
2177
2187
  const prev = readAdminSession();
2178
2188
  const next = updater(prev);
2179
2189
  writeAdminSession(next);
2180
2190
  emit();
2181
2191
  };
2182
- const authStorage = {
2192
+ const authStorage = config.apiToken ? {
2193
+ getTokens: () => ({ access_token: config.apiToken }),
2194
+ onTokensRefreshed: () => {
2195
+ },
2196
+ onForcedLogout: () => {
2197
+ }
2198
+ } : {
2183
2199
  getTokens() {
2184
2200
  const s = readAdminSession();
2185
2201
  if (!s) return null;
@@ -2395,10 +2411,12 @@ function createAdmin(config) {
2395
2411
  apiConfig.locale = locale2;
2396
2412
  },
2397
2413
  getLocale: () => apiConfig.locale,
2398
- get currentSession() {
2414
+ get session() {
2415
+ if (config.apiToken) return null;
2399
2416
  return toPublic(readAdminSession());
2400
2417
  },
2401
2418
  get isAuthenticated() {
2419
+ if (config.apiToken) return true;
2402
2420
  return readAdminSession() !== null;
2403
2421
  },
2404
2422
  onAuthStateChanged(listener) {
@@ -2413,6 +2431,7 @@ function createAdmin(config) {
2413
2431
  };
2414
2432
  },
2415
2433
  async logout() {
2434
+ if (config.apiToken) return;
2416
2435
  updateSession(() => null);
2417
2436
  },
2418
2437
  extractBlockValues,