@talken/talkenkit 2.5.2 → 2.5.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.
Files changed (71) hide show
  1. package/dist/{AbcCredentialManager-5W3B7GI4.js → AbcCredentialManager-JV4ZBMKF.js} +1 -1
  2. package/dist/TalkenApiSingleton-TECFDCT4.js +9 -0
  3. package/dist/{abcWallet-HRNBHY5Q.js → abcWallet-QJ5BKEXW.js} +3 -2
  4. package/dist/{chunk-PN6K4CMZ.js → chunk-DNEDHHS4.js} +23 -1
  5. package/dist/chunk-R6ZE7JAZ.js +15 -0
  6. package/dist/{chunk-VCQZZ6SN.js → chunk-YORGXWYS.js} +218 -80
  7. package/dist/components/ConnectOptions/AbcWaasAuth/AbcWaasAuthFlow.d.ts +6 -32
  8. package/dist/components/ConnectOptions/AbcWaasAuth/AbcWaasAuthSections.d.ts +0 -9
  9. package/dist/components/ConnectOptions/AbcWaasAuth/hooks/useAbcWaasAuth.d.ts +3 -12
  10. package/dist/components/ConnectOptions/AbcWaasAuth/types.d.ts +1 -8
  11. package/dist/components/ConnectOptions/PinAuth/PinAuthFlow.d.ts +6 -4
  12. package/dist/components/ProfileDetails/ProfileDetails.d.ts +5 -5
  13. package/dist/hooks/useMultiChainBalances.d.ts +9 -0
  14. package/dist/index.js +1420 -1466
  15. package/dist/klipWallet-TBZJ5GGT.js +7 -0
  16. package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.js +2 -2
  17. package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +2 -2
  18. package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.d.ts +4 -0
  19. package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.js +3 -3
  20. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +3 -3
  21. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +3 -3
  22. package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +7 -7
  23. package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +4 -4
  24. package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +7 -7
  25. package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +44 -45
  26. package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +3 -3
  27. package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +8 -8
  28. package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.js +2 -2
  29. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +44 -0
  30. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +3 -3
  31. package/dist/wallets/walletConnectors/abcWallet/api/TokenApi.js +2 -2
  32. package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.js +3 -3
  33. package/dist/wallets/walletConnectors/abcWallet/api/index.js +6 -6
  34. package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +3 -0
  35. package/dist/wallets/walletConnectors/abcWallet/constants.js +5 -3
  36. package/dist/wallets/walletConnectors/abcWallet/index.js +31 -31
  37. package/dist/wallets/walletConnectors/abcWallet/sessionUtils.js +2 -2
  38. package/dist/wallets/walletConnectors/abcWallet/types.d.ts +4 -0
  39. package/dist/wallets/walletConnectors/abcWallet/utils.js +2 -2
  40. package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +3 -3
  41. package/dist/wallets/walletConnectors/{chunk-QKK3OPQA.js → chunk-36BJXEBA.js} +1 -1
  42. package/dist/wallets/walletConnectors/{chunk-FKI5AZVH.js → chunk-3K3KYVRN.js} +1 -1
  43. package/dist/wallets/walletConnectors/{chunk-URS2KVYK.js → chunk-5DK36WJ2.js} +1 -1
  44. package/dist/wallets/walletConnectors/{chunk-ASYCOXE6.js → chunk-5ERWBR7D.js} +132 -28
  45. package/dist/wallets/walletConnectors/{chunk-RX2VOIUB.js → chunk-6KRX73ED.js} +25 -3
  46. package/dist/wallets/walletConnectors/{chunk-H2AZTZMM.js → chunk-6L5G54IX.js} +1 -1
  47. package/dist/wallets/walletConnectors/{chunk-RGYZNNB6.js → chunk-C4ADBB6M.js} +1 -1
  48. package/dist/wallets/walletConnectors/{chunk-4JZPP3S7.js → chunk-E6ZG77AF.js} +27 -1
  49. package/dist/wallets/walletConnectors/{chunk-PF65YS3T.js → chunk-EBTKWCIS.js} +3 -2
  50. package/dist/wallets/walletConnectors/{chunk-25ZDAJ3L.js → chunk-EZS3GXZN.js} +1 -1
  51. package/dist/wallets/walletConnectors/{chunk-WKP53WWR.js → chunk-G6SV7RAS.js} +8 -7
  52. package/dist/wallets/walletConnectors/chunk-HKMJ67FD.js +37 -0
  53. package/dist/wallets/walletConnectors/{chunk-L6FCF3FH.js → chunk-L3HWFGTN.js} +2 -2
  54. package/dist/wallets/walletConnectors/{chunk-LIGH2LEU.js → chunk-PVPSVCVQ.js} +1 -1
  55. package/dist/wallets/walletConnectors/{chunk-2A5XTST5.js → chunk-SDRE2D5I.js} +29 -11
  56. package/dist/wallets/walletConnectors/{chunk-HWRZGGGN.js → chunk-VBNZ7HA3.js} +1 -1
  57. package/dist/wallets/walletConnectors/{chunk-YKFI6ZGM.js → chunk-VLHDGDFH.js} +1 -1
  58. package/dist/wallets/walletConnectors/{chunk-645DT4TS.js → chunk-ZLH3W5PQ.js} +2 -2
  59. package/dist/wallets/walletConnectors/index.d.ts +2 -1
  60. package/dist/wallets/walletConnectors/index.js +57 -53
  61. package/dist/wallets/walletConnectors/klipWallet/klipWallet.js +3 -63
  62. package/dist/wallets/walletConnectors/klipWallet-TBZJ5GGT.js +7 -0
  63. package/package.json +1 -1
  64. package/dist/wallets/walletConnectors/chunk-4PDTJS5L.js +0 -57
  65. package/dist/wallets/walletConnectors/chunk-BRXYKYKT.js +0 -360
  66. package/dist/wallets/walletConnectors/chunk-IPH3SIC3.js +0 -57
  67. package/dist/wallets/walletConnectors/chunk-JBOKTW2Q.js +0 -360
  68. package/dist/wallets/walletConnectors/chunk-MIX4TRKO.js +0 -194
  69. package/dist/wallets/walletConnectors/chunk-NP5PWUVU.js +0 -873
  70. package/dist/wallets/walletConnectors/chunk-TVZHPWFR.js +0 -843
  71. package/dist/wallets/walletConnectors/klipWallet-PPTYYB5G.js +0 -7
@@ -6,14 +6,18 @@ import {
6
6
  STORAGE_PREFIX,
7
7
  TALKEN_API_ENDPOINTS,
8
8
  TOKEN_EXPIRY,
9
- getCredentialManager
10
- } from "./chunk-PN6K4CMZ.js";
9
+ getCredentialManager,
10
+ loadTgAccessKey
11
+ } from "./chunk-DNEDHHS4.js";
12
+ import {
13
+ setTalkenApiClient
14
+ } from "./chunk-R6ZE7JAZ.js";
11
15
 
12
16
  // src/wallets/walletConnectors/abcWallet/abcWallet.ts
13
17
  import { setTalkenApiClient as setTalkenApiClient2 } from "@talken/talkenkit";
14
18
 
15
19
  // src/wallets/walletConnectors/abcWallet/abcConnector.ts
16
- import { getTalkenApiClient as getTalkenApiClient3 } from "@talken/talkenkit";
20
+ import { getTalkenApiClient as getTalkenApiClient2 } from "@talken/talkenkit";
17
21
  import { createConnector } from "wagmi";
18
22
 
19
23
  // src/config/networks.ts
@@ -1005,7 +1009,8 @@ function hydrateAuthStateFromIndividualStorage(state) {
1005
1009
  function loadAuthState() {
1006
1010
  const state = loadFromStorage("auth_state" /* AUTH_STATE */);
1007
1011
  if (state) {
1008
- if (state.accessToken && isTokenExpired(state.expiresAt)) {
1012
+ const isExpired = state.accessKeyMode ? state.accessKeyExpiresAt && Date.now() >= new Date(state.accessKeyExpiresAt).getTime() : state.accessToken && isTokenExpired(state.expiresAt);
1013
+ if (isExpired) {
1009
1014
  clearStorage();
1010
1015
  return null;
1011
1016
  }
@@ -1112,6 +1117,20 @@ var AbcAccessKeyProvider = class extends EventEmitter {
1112
1117
  this.accessKey = accessKey;
1113
1118
  this.apiBaseUrl = apiBaseUrl || (typeof window !== "undefined" ? window.__TALKEN_API_URL__ || "" : "");
1114
1119
  }
1120
+ setRequestInterceptor(interceptor) {
1121
+ this.requestInterceptor = interceptor;
1122
+ }
1123
+ async callInterceptor(method, params) {
1124
+ if (!this.requestInterceptor)
1125
+ return void 0;
1126
+ const request = {
1127
+ method,
1128
+ params,
1129
+ chainId: this.chainId,
1130
+ address: this.wallet?.address || ""
1131
+ };
1132
+ return this.requestInterceptor(request);
1133
+ }
1115
1134
  // ── Wallet management ─────────────────────────────────────
1116
1135
  setWallet(wallet) {
1117
1136
  this.wallet = wallet;
@@ -1204,6 +1223,16 @@ var AbcAccessKeyProvider = class extends EventEmitter {
1204
1223
  "Contract deployment (missing `to`) is not supported in access-key mode"
1205
1224
  );
1206
1225
  }
1226
+ const resolved = await this.callInterceptor(
1227
+ "eth_sendTransaction",
1228
+ params
1229
+ );
1230
+ if (resolved) {
1231
+ if (resolved.data)
1232
+ tx.data = resolved.data;
1233
+ if (resolved.gasLimit)
1234
+ tx.gas = resolved.gasLimit;
1235
+ }
1207
1236
  const chainKey = getChainKey(this.chainId);
1208
1237
  const hexValue = tx.value || "0x0";
1209
1238
  const amountWei = BigInt(hexValue).toString();
@@ -1241,6 +1270,7 @@ var AbcAccessKeyProvider = class extends EventEmitter {
1241
1270
  `Address mismatch: requested ${address}, connected ${wallet.address}`
1242
1271
  );
1243
1272
  }
1273
+ await this.callInterceptor("personal_sign", p);
1244
1274
  const network = getNetworkName(this.chainId);
1245
1275
  const result = await this.apiPost("/wallet/sign/evm/personal", {
1246
1276
  network,
@@ -1269,6 +1299,7 @@ var AbcAccessKeyProvider = class extends EventEmitter {
1269
1299
  `Address mismatch: requested ${address}, connected ${wallet.address}`
1270
1300
  );
1271
1301
  }
1302
+ await this.callInterceptor("eth_signTypedData_v4", p);
1272
1303
  const network = getNetworkName(this.chainId);
1273
1304
  const result = await this.apiPost("/wallet/sign/evm/typed", {
1274
1305
  network,
@@ -2412,6 +2443,34 @@ var TalkenAuthModule = class {
2412
2443
  this.client.handleAuthResponse(res);
2413
2444
  return res;
2414
2445
  }
2446
+ /**
2447
+ * Server-side unified onboarding: email + OTP → access key + wallets.
2448
+ * POST /wallet/auth { action: 'ensure-user', email, otpCode, accessKeyName }
2449
+ */
2450
+ async ensureUser(email, otpCode, accessKeyName = "talkenkit") {
2451
+ const raw = await this.client.post(
2452
+ TALKEN_API_ENDPOINTS.AUTH,
2453
+ { action: "ensure-user", email, otpCode, accessKeyName },
2454
+ { skipAuth: true }
2455
+ );
2456
+ return raw.data || raw;
2457
+ }
2458
+ /**
2459
+ * Create an Access Key for delegated authentication
2460
+ * POST /agent/access-keys { name, pin, refreshToken, email, ttlSeconds }
2461
+ */
2462
+ async createAccessKey(params) {
2463
+ const raw = await this.client.post(
2464
+ TALKEN_API_ENDPOINTS.ACCESS_KEYS,
2465
+ params
2466
+ );
2467
+ const d = raw.data || raw;
2468
+ return {
2469
+ accessKey: d.accessKey,
2470
+ keyId: d.keyId,
2471
+ expiresAt: d.expiresAt
2472
+ };
2473
+ }
2415
2474
  /**
2416
2475
  * Logout (clear local session only — no server endpoint)
2417
2476
  */
@@ -2855,11 +2914,12 @@ var TalkenWalletscanModule = class {
2855
2914
  );
2856
2915
  }
2857
2916
  };
2858
- var TalkenApiClient = class {
2917
+ var TalkenApiClient = class _TalkenApiClient {
2859
2918
  constructor(config) {
2860
2919
  this.accessToken = null;
2861
2920
  this.refreshToken_ = null;
2862
2921
  this.expiresAt = null;
2922
+ this.accessKeyRaw = null;
2863
2923
  this.isRefreshing = false;
2864
2924
  this.refreshPromise = null;
2865
2925
  this.config = {
@@ -2880,6 +2940,10 @@ var TalkenApiClient = class {
2880
2940
  }
2881
2941
  // ── Session Management ──────────────────────────────────────────────
2882
2942
  restoreSession() {
2943
+ this.accessKeyRaw = loadToken("access_key_raw");
2944
+ if (this.accessKeyRaw) {
2945
+ return;
2946
+ }
2883
2947
  this.accessToken = loadToken("access_token");
2884
2948
  this.refreshToken_ = loadToken("refresh_token");
2885
2949
  const expiresAtStr = loadToken("expires_at");
@@ -2899,14 +2963,74 @@ var TalkenApiClient = class {
2899
2963
  this.accessToken = null;
2900
2964
  this.refreshToken_ = null;
2901
2965
  this.expiresAt = null;
2966
+ this.accessKeyRaw = null;
2902
2967
  removeToken("access_token");
2903
2968
  removeToken("refresh_token");
2904
2969
  removeToken("expires_at");
2970
+ removeToken("access_key_raw");
2971
+ }
2972
+ static {
2973
+ /** All known access key prefixes (any environment). */
2974
+ this.KNOWN_AK_PREFIXES = [
2975
+ "talken_live_",
2976
+ "talken_stg_",
2977
+ "talken_dev_",
2978
+ "talken_local_"
2979
+ ];
2980
+ }
2981
+ /** Validate access key format: talken_<env>_<publicId>.<secret> */
2982
+ static isValidAccessKeyFormat(key) {
2983
+ const trimmed = key.trim();
2984
+ for (const prefix of _TalkenApiClient.KNOWN_AK_PREFIXES) {
2985
+ if (trimmed.startsWith(prefix)) {
2986
+ const payload = trimmed.slice(prefix.length);
2987
+ const dot = payload.indexOf(".");
2988
+ if (dot < 1)
2989
+ return false;
2990
+ return payload.slice(0, dot).length > 0 && payload.slice(dot + 1).length > 0;
2991
+ }
2992
+ }
2993
+ return false;
2994
+ }
2995
+ /**
2996
+ * Set Access Key and switch to Access Key mode.
2997
+ * Accepts any known env prefix (talken_live_, talken_stg_, talken_dev_, talken_local_).
2998
+ */
2999
+ setAccessKey(key) {
3000
+ const trimmed = key.trim();
3001
+ if (!_TalkenApiClient.isValidAccessKeyFormat(trimmed)) {
3002
+ throw new Error(
3003
+ "Invalid access key format. Expected: talken_<env>_<publicId>.<secret>"
3004
+ );
3005
+ }
3006
+ this.accessKeyRaw = trimmed;
3007
+ saveToken("access_key_raw", trimmed);
3008
+ this.accessToken = null;
3009
+ this.refreshToken_ = null;
3010
+ this.expiresAt = null;
3011
+ removeToken("access_token");
3012
+ removeToken("refresh_token");
3013
+ removeToken("expires_at");
3014
+ }
3015
+ /**
3016
+ * Clear Access Key
3017
+ */
3018
+ clearAccessKey() {
3019
+ this.accessKeyRaw = null;
3020
+ removeToken("access_key_raw");
3021
+ }
3022
+ /**
3023
+ * Check if running in Access Key mode
3024
+ */
3025
+ isAccessKeyMode() {
3026
+ return !!this.accessKeyRaw;
2905
3027
  }
2906
3028
  /**
2907
3029
  * Check if user is authenticated (has valid access token)
2908
3030
  */
2909
3031
  isAuthenticated() {
3032
+ if (this.accessKeyRaw)
3033
+ return true;
2910
3034
  return !!this.accessToken && !this.isTokenExpired();
2911
3035
  }
2912
3036
  /**
@@ -2962,7 +3086,7 @@ var TalkenApiClient = class {
2962
3086
  */
2963
3087
  async request(endpoint, options) {
2964
3088
  const { method, body, skipAuth = false } = options;
2965
- if (!skipAuth && this.isTokenExpired() && this.refreshToken_) {
3089
+ if (!skipAuth && !this.accessKeyRaw && this.isTokenExpired() && this.refreshToken_) {
2966
3090
  await this.ensureTokenRefreshed();
2967
3091
  }
2968
3092
  const url = `${this.config.baseUrl}${endpoint}`;
@@ -2970,20 +3094,16 @@ var TalkenApiClient = class {
2970
3094
  "Content-Type": "application/json",
2971
3095
  Accept: "application/json"
2972
3096
  };
2973
- if (!skipAuth && this.accessToken) {
2974
- headers.Authorization = `Bearer ${this.accessToken}`;
2975
- } else if (!skipAuth) {
2976
- const ak = loadToken("access_key_raw");
2977
- const tgAk = !ak && typeof window !== "undefined" ? (() => {
2978
- try {
2979
- return localStorage.getItem("talken_ak");
2980
- } catch {
2981
- return null;
3097
+ if (!skipAuth) {
3098
+ if (this.accessKeyRaw) {
3099
+ headers["X-Access-Key"] = this.accessKeyRaw;
3100
+ } else if (this.accessToken) {
3101
+ headers.Authorization = `Bearer ${this.accessToken}`;
3102
+ } else {
3103
+ const tgAk = loadTgAccessKey();
3104
+ if (tgAk) {
3105
+ headers["X-Access-Key"] = tgAk;
2982
3106
  }
2983
- })() : null;
2984
- const effectiveAk = ak || tgAk;
2985
- if (effectiveAk) {
2986
- headers["X-Access-Key"] = effectiveAk;
2987
3107
  }
2988
3108
  }
2989
3109
  if (this.config.debug) {
@@ -3019,18 +3139,32 @@ var TalkenApiClient = class {
3019
3139
  } else {
3020
3140
  data = { success: true };
3021
3141
  }
3022
- if (response.status === 401 && !skipAuth && this.refreshToken_) {
3023
- try {
3024
- await this.forceTokenRefresh();
3025
- return this.request(endpoint, { ...options, skipAuth: true });
3026
- } catch {
3027
- this.clearSession();
3142
+ if (response.status === 401 && !skipAuth) {
3143
+ if (this.accessKeyRaw) {
3144
+ if (typeof window !== "undefined") {
3145
+ window.dispatchEvent(
3146
+ new CustomEvent("talkenkit:access_key_expired")
3147
+ );
3148
+ }
3028
3149
  throw new TalkenApiError(
3029
- "TOKEN_EXPIRED",
3030
- "Session expired. Please login again.",
3150
+ "ACCESS_KEY_EXPIRED",
3151
+ "Access key expired. Please login again.",
3031
3152
  401
3032
3153
  );
3033
3154
  }
3155
+ if (this.refreshToken_) {
3156
+ try {
3157
+ await this.forceTokenRefresh();
3158
+ return this.request(endpoint, { ...options, skipAuth: true });
3159
+ } catch {
3160
+ this.clearSession();
3161
+ throw new TalkenApiError(
3162
+ "TOKEN_EXPIRED",
3163
+ "Session expired. Please login again.",
3164
+ 401
3165
+ );
3166
+ }
3167
+ }
3034
3168
  }
3035
3169
  if (!response.ok) {
3036
3170
  const errCode = data.error?.code || "UNKNOWN_ERROR";
@@ -3091,15 +3225,6 @@ function createTalkenApiClient(config) {
3091
3225
  return new TalkenApiClient(config);
3092
3226
  }
3093
3227
 
3094
- // src/wallets/walletConnectors/abcWallet/api/TalkenApiSingleton.ts
3095
- var _instance;
3096
- function setTalkenApiClient(client) {
3097
- _instance = client;
3098
- }
3099
- function getTalkenApiClient2() {
3100
- return _instance;
3101
- }
3102
-
3103
3228
  // src/wallets/walletConnectors/abcWallet/networkConfig.ts
3104
3229
  var SolanaNetwork = /* @__PURE__ */ ((SolanaNetwork2) => {
3105
3230
  SolanaNetwork2["Mainnet"] = "solana";
@@ -3207,16 +3332,24 @@ function abcConnector(options) {
3207
3332
  setGlobalDefaultBitcoinNetwork(config.defaultBitcoinNetwork);
3208
3333
  }
3209
3334
  return createConnector((wagmiConfig) => {
3210
- const talkenApi = getTalkenApiClient3() || createTalkenApiClient({
3335
+ const talkenApi = getTalkenApiClient2() || createTalkenApiClient({
3211
3336
  baseUrl: resolveTalkenApiUrl(config.talkenApiUrl),
3212
3337
  environment: config.environment,
3213
3338
  debug: config.environment === "development",
3214
3339
  defaultChainId: config.defaultChainId
3215
3340
  });
3216
3341
  setTalkenApiClient(talkenApi);
3217
- const isAccessKeyMode = !!config.accessKey;
3342
+ const storedAccessKey = typeof window !== "undefined" ? (() => {
3343
+ try {
3344
+ return localStorage.getItem("talken_api_access_key_raw");
3345
+ } catch {
3346
+ return null;
3347
+ }
3348
+ })() : null;
3349
+ const effectiveAccessKey = config.accessKey || storedAccessKey;
3350
+ const isAccessKeyMode = !!effectiveAccessKey;
3218
3351
  const provider = isAccessKeyMode ? new AbcAccessKeyProvider(
3219
- config.accessKey,
3352
+ effectiveAccessKey,
3220
3353
  resolveTalkenApiUrl(config.talkenApiUrl)
3221
3354
  ) : createAbcEvmProvider(talkenApi);
3222
3355
  let accountsChangedHandler;
@@ -3244,7 +3377,7 @@ function abcConnector(options) {
3244
3377
  method: "POST",
3245
3378
  headers: {
3246
3379
  "Content-Type": "application/json",
3247
- "X-Access-Key": config.accessKey
3380
+ "X-Access-Key": effectiveAccessKey
3248
3381
  },
3249
3382
  body: JSON.stringify({ action: "info" })
3250
3383
  });
@@ -3375,6 +3508,10 @@ function abcConnector(options) {
3375
3508
  }
3376
3509
  provider.clearWallet();
3377
3510
  talkenApi.auth.logout();
3511
+ try {
3512
+ localStorage.removeItem("talken_api_access_key_raw");
3513
+ } catch {
3514
+ }
3378
3515
  clearAuthState();
3379
3516
  getCredentialManager().clear();
3380
3517
  },
@@ -3411,7 +3548,7 @@ function abcConnector(options) {
3411
3548
  if (isAccessKeyMode) {
3412
3549
  if (provider.isConnected())
3413
3550
  return true;
3414
- const hasKey = !!config.accessKey || typeof localStorage !== "undefined" && !!localStorage.getItem("talken_ak");
3551
+ const hasKey = !!effectiveAccessKey || typeof localStorage !== "undefined" && (!!localStorage.getItem("talken_api_access_key_raw") || !!loadTgAccessKey());
3415
3552
  const authState2 = loadAuthState();
3416
3553
  return hasKey && !!authState2?.wallet?.address;
3417
3554
  }
@@ -3425,6 +3562,9 @@ function abcConnector(options) {
3425
3562
  if (talkenApi.isAuthenticated()) {
3426
3563
  return true;
3427
3564
  }
3565
+ if (talkenApi.isAccessKeyMode()) {
3566
+ return true;
3567
+ }
3428
3568
  const refreshToken = loadFromStorage(
3429
3569
  "refresh_token" /* REFRESH_TOKEN */
3430
3570
  );
@@ -3433,7 +3573,7 @@ function abcConnector(options) {
3433
3573
  return false;
3434
3574
  }
3435
3575
  try {
3436
- const api = getTalkenApiClient3();
3576
+ const api = getTalkenApiClient2();
3437
3577
  if (!api) {
3438
3578
  clearStorage();
3439
3579
  return false;
@@ -3525,7 +3665,7 @@ var abcWallet = (specificOptions) => ({ projectId }) => {
3525
3665
  debug: specificOptions?.environment === "development"
3526
3666
  });
3527
3667
  setTalkenApiClient2(talkenApi);
3528
- const accessKey = specificOptions?.accessKey || (typeof localStorage !== "undefined" ? localStorage.getItem("talken_ak") : null) || null;
3668
+ const accessKey = specificOptions?.accessKey || loadTgAccessKey() || null;
3529
3669
  const config = {
3530
3670
  talkenApiUrl,
3531
3671
  apiKey: specificOptions?.apiKey,
@@ -3557,13 +3697,13 @@ var abcWallet = (specificOptions) => ({ projectId }) => {
3557
3697
  };
3558
3698
 
3559
3699
  // src/wallets/walletConnectors/abcWallet/api/WalletscanApi.ts
3560
- import { getTalkenApiClient as getTalkenApiClient5, networkNameToChainKey as networkNameToChainKey2 } from "@talken/talkenkit";
3700
+ import { getTalkenApiClient as getTalkenApiClient4, networkNameToChainKey as networkNameToChainKey2 } from "@talken/talkenkit";
3561
3701
 
3562
3702
  // src/wallets/walletConnectors/abcWallet/api/TokenApi.ts
3563
- import { getTalkenApiClient as getTalkenApiClient4 } from "@talken/talkenkit";
3703
+ import { getTalkenApiClient as getTalkenApiClient3 } from "@talken/talkenkit";
3564
3704
  var TokenApi = class {
3565
3705
  async getBalances(address, chainKey) {
3566
- const api = getTalkenApiClient4();
3706
+ const api = getTalkenApiClient3();
3567
3707
  if (!api)
3568
3708
  throw new Error("TalkenApiClient not initialized");
3569
3709
  const query = new URLSearchParams({ address, chainKey }).toString();
@@ -3590,7 +3730,7 @@ var WalletscanApi = class {
3590
3730
  * Get all wallet tokens with balances via TalkenApiClient walletscan endpoint
3591
3731
  */
3592
3732
  async getWalletTokens(params) {
3593
- const api = getTalkenApiClient5();
3733
+ const api = getTalkenApiClient4();
3594
3734
  if (!api)
3595
3735
  throw new Error("TalkenApiClient not initialized");
3596
3736
  try {
@@ -3650,7 +3790,7 @@ var WalletscanApi = class {
3650
3790
  * @returns Token metadata or null if not found/failed
3651
3791
  */
3652
3792
  async getContractToken(params) {
3653
- const api = getTalkenApiClient5();
3793
+ const api = getTalkenApiClient4();
3654
3794
  if (!api)
3655
3795
  throw new Error("TalkenApiClient not initialized");
3656
3796
  try {
@@ -3699,7 +3839,7 @@ var WalletscanApi = class {
3699
3839
  * @returns Array of native coins or empty array if failed
3700
3840
  */
3701
3841
  async getNativeToken(params) {
3702
- const api = getTalkenApiClient5();
3842
+ const api = getTalkenApiClient4();
3703
3843
  if (!api)
3704
3844
  throw new Error("TalkenApiClient not initialized");
3705
3845
  const chainKey = networkNameToChainKey2(params.networks);
@@ -3770,7 +3910,7 @@ var WalletscanApi = class {
3770
3910
  * @returns Array of NFT metadata or empty array if failed
3771
3911
  */
3772
3912
  async getNFT(params) {
3773
- const api = getTalkenApiClient5();
3913
+ const api = getTalkenApiClient4();
3774
3914
  if (!api)
3775
3915
  throw new Error("TalkenApiClient not initialized");
3776
3916
  try {
@@ -3814,7 +3954,7 @@ var WalletscanApi = class {
3814
3954
  };
3815
3955
 
3816
3956
  // src/wallets/walletConnectors/abcWallet/api/GasApi.ts
3817
- import { getTalkenApiClient as getTalkenApiClient6 } from "@talken/talkenkit";
3957
+ import { getTalkenApiClient as getTalkenApiClient5 } from "@talken/talkenkit";
3818
3958
  var GasApi = class {
3819
3959
  parseGasFees(data) {
3820
3960
  return {
@@ -3829,7 +3969,7 @@ var GasApi = class {
3829
3969
  * @returns Suggested gas fees or null if failed
3830
3970
  */
3831
3971
  async getSuggestedGasFees(network) {
3832
- const api = getTalkenApiClient6();
3972
+ const api = getTalkenApiClient5();
3833
3973
  if (!api)
3834
3974
  throw new Error("TalkenApiClient not initialized");
3835
3975
  try {
@@ -3851,7 +3991,7 @@ var GasApi = class {
3851
3991
  * @returns Gas limit (hex string) or null if failed
3852
3992
  */
3853
3993
  async estimateGas(params) {
3854
- const api = getTalkenApiClient6();
3994
+ const api = getTalkenApiClient5();
3855
3995
  if (!api)
3856
3996
  throw new Error("TalkenApiClient not initialized");
3857
3997
  try {
@@ -3913,7 +4053,7 @@ var GasApi = class {
3913
4053
  };
3914
4054
 
3915
4055
  // src/wallets/walletConnectors/abcWallet/api/ConfigApi.ts
3916
- import { getTalkenApiClient as getTalkenApiClient7 } from "@talken/talkenkit";
4056
+ import { getTalkenApiClient as getTalkenApiClient6 } from "@talken/talkenkit";
3917
4057
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3918
4058
  var toStatusCode = (status) => {
3919
4059
  if (typeof status === "number")
@@ -3931,7 +4071,7 @@ var toStatusCode = (status) => {
3931
4071
  };
3932
4072
  var ConfigApi = class {
3933
4073
  async getTxStatus(chainKey, txHash) {
3934
- const api = getTalkenApiClient7();
4074
+ const api = getTalkenApiClient6();
3935
4075
  if (!api)
3936
4076
  throw new Error("TalkenApiClient not initialized");
3937
4077
  return api.get(
@@ -3957,16 +4097,16 @@ var ConfigApi = class {
3957
4097
  };
3958
4098
 
3959
4099
  // src/wallets/walletConnectors/abcWallet/api/SolanaApi.ts
3960
- import { getTalkenApiClient as getTalkenApiClient8 } from "@talken/talkenkit";
4100
+ import { getTalkenApiClient as getTalkenApiClient7 } from "@talken/talkenkit";
3961
4101
  var SolanaApi = class {
3962
4102
  async getLatestBlockhash(network) {
3963
- const api = getTalkenApiClient8();
4103
+ const api = getTalkenApiClient7();
3964
4104
  if (!api)
3965
4105
  throw new Error("TalkenApiClient not initialized");
3966
4106
  return api.solana.getLatestBlockhash(network);
3967
4107
  }
3968
4108
  async getTransactionStatus(params) {
3969
- const api = getTalkenApiClient8();
4109
+ const api = getTalkenApiClient7();
3970
4110
  if (!api)
3971
4111
  throw new Error("TalkenApiClient not initialized");
3972
4112
  return api.solana.getTransactionStatus(params);
@@ -3991,7 +4131,7 @@ var SolanaApi = class {
3991
4131
  };
3992
4132
 
3993
4133
  // src/wallets/walletConnectors/abcWallet/sessionUtils.ts
3994
- import { getTalkenApiClient as getTalkenApiClient9 } from "@talken/talkenkit";
4134
+ import { getTalkenApiClient as getTalkenApiClient8 } from "@talken/talkenkit";
3995
4135
  var SessionExpiredError = class extends Error {
3996
4136
  constructor(message = "Session expired. Please reconnect your wallet.") {
3997
4137
  super(message);
@@ -4029,7 +4169,7 @@ async function refreshAccessToken(pinCallback) {
4029
4169
  if (pinCallback) {
4030
4170
  await pinCallback();
4031
4171
  }
4032
- const api = getTalkenApiClient9();
4172
+ const api = getTalkenApiClient8();
4033
4173
  if (!api) {
4034
4174
  console.warn(
4035
4175
  "[SessionUtils] TalkenApiClient not initialized - opening connect modal"
@@ -4075,7 +4215,7 @@ async function refreshAccessToken(pinCallback) {
4075
4215
  }
4076
4216
 
4077
4217
  // src/wallets/walletConnectors/abcWallet/abcBitcoinProvider.ts
4078
- import { getTalkenApiClient as getTalkenApiClient10 } from "@talken/talkenkit";
4218
+ import { getTalkenApiClient as getTalkenApiClient9 } from "@talken/talkenkit";
4079
4219
  function isTalkenApiClient(client) {
4080
4220
  return typeof client?.bitcoin?.getUtxos === "function";
4081
4221
  }
@@ -4346,7 +4486,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4346
4486
  }
4347
4487
  try {
4348
4488
  console.log("[BitcoinProvider] \u{1F50D} Fetching UTXOs from network...");
4349
- const api = this.talkenApi || getTalkenApiClient10();
4489
+ const api = this.talkenApi || getTalkenApiClient9();
4350
4490
  const result = await api.bitcoin.getUtxos(this.network.type, address);
4351
4491
  const utxos = this.normalizeUtxos(result.utxos || []);
4352
4492
  this.utxoCache.set(address, utxos);
@@ -4383,7 +4523,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4383
4523
  */
4384
4524
  async estimateFee(targetBlocks = 6) {
4385
4525
  try {
4386
- const api = this.talkenApi || getTalkenApiClient10();
4526
+ const api = this.talkenApi || getTalkenApiClient9();
4387
4527
  const result = await api.bitcoin.getFeeRate(
4388
4528
  this.network.type,
4389
4529
  targetBlocks
@@ -4436,7 +4576,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4436
4576
  const hash1 = await crypto.subtle.digest("SHA-256", preimage);
4437
4577
  const hash2 = await crypto.subtle.digest("SHA-256", hash1);
4438
4578
  const hashHex = Array.from(new Uint8Array(hash2)).map((b) => b.toString(16).padStart(2, "0")).join("");
4439
- const api = getTalkenApiClient10();
4579
+ const api = getTalkenApiClient9();
4440
4580
  if (!api) {
4441
4581
  throw new BitcoinProviderError(
4442
4582
  BitcoinErrorCode.INTERNAL_ERROR,
@@ -4547,7 +4687,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4547
4687
  }
4548
4688
  const email = this.getRecoveryEmail();
4549
4689
  const satoshis = Math.floor(params.amount * 1e8);
4550
- const api = this.talkenApi || getTalkenApiClient10();
4690
+ const api = this.talkenApi || getTalkenApiClient9();
4551
4691
  const result = await api.bitcoin.sendTransaction({
4552
4692
  toAddress: params.toAddress,
4553
4693
  amountSats: satoshis.toString(),
@@ -4610,7 +4750,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4610
4750
  "[BitcoinProvider] \u2139\uFE0F PSBT argument provided; raw tx broadcast uses rawTransaction only via talken-api"
4611
4751
  );
4612
4752
  }
4613
- const api = this.talkenApi || getTalkenApiClient10();
4753
+ const api = this.talkenApi || getTalkenApiClient9();
4614
4754
  const result = await api.bitcoin.broadcastRawTransaction({
4615
4755
  network: this.network.type,
4616
4756
  rawTransaction
@@ -4660,7 +4800,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4660
4800
  };
4661
4801
 
4662
4802
  // src/wallets/walletConnectors/abcWallet/abcBitcoinConnector.ts
4663
- import { getTalkenApiClient as getTalkenApiClient11 } from "@talken/talkenkit";
4803
+ import { getTalkenApiClient as getTalkenApiClient10 } from "@talken/talkenkit";
4664
4804
  var AbcBitcoinConnector = class {
4665
4805
  constructor(config) {
4666
4806
  this.wallet = null;
@@ -4822,7 +4962,7 @@ var AbcBitcoinConnector = class {
4822
4962
  if (!authState.bitcoinWallet) {
4823
4963
  return false;
4824
4964
  }
4825
- const api = getTalkenApiClient11();
4965
+ const api = getTalkenApiClient10();
4826
4966
  return !!api && !api.isTokenExpired();
4827
4967
  } catch {
4828
4968
  return false;
@@ -4925,7 +5065,7 @@ function createAbcBitcoinConnector(config) {
4925
5065
  // src/wallets/walletConnectors/abcWallet/abcSolanaProvider.ts
4926
5066
  import {
4927
5067
  getShowPendingTransaction as getShowPendingTransaction2,
4928
- getTalkenApiClient as getTalkenApiClient12,
5068
+ getTalkenApiClient as getTalkenApiClient11,
4929
5069
  getUpdateTransactionResult as getUpdateTransactionResult2
4930
5070
  } from "@talken/talkenkit";
4931
5071
 
@@ -5059,7 +5199,7 @@ var AbcSolanaProvider = class extends EventEmitter4 {
5059
5199
  this.talkenApi = talkenApi;
5060
5200
  }
5061
5201
  getTalkenApiClientOrThrow() {
5062
- const api = this.talkenApi || getTalkenApiClient12();
5202
+ const api = this.talkenApi || getTalkenApiClient11();
5063
5203
  if (!api) {
5064
5204
  throw new SolanaProviderError(
5065
5205
  SolanaErrorCode.INTERNAL_ERROR,
@@ -5412,7 +5552,7 @@ var AbcSolanaProvider = class extends EventEmitter4 {
5412
5552
  // src/wallets/walletConnectors/abcWallet/abcTronProvider.ts
5413
5553
  import {
5414
5554
  getShowPendingTransaction as getShowPendingTransaction3,
5415
- getTalkenApiClient as getTalkenApiClient13,
5555
+ getTalkenApiClient as getTalkenApiClient12,
5416
5556
  getUpdateTransactionResult as getUpdateTransactionResult3
5417
5557
  } from "@talken/talkenkit";
5418
5558
  import { keccak256 } from "viem";
@@ -5564,7 +5704,7 @@ var AbcTronProvider = class extends EventEmitter5 {
5564
5704
  if (cached)
5565
5705
  return cached;
5566
5706
  try {
5567
- const api = this.talkenApi || getTalkenApiClient13();
5707
+ const api = this.talkenApi || getTalkenApiClient12();
5568
5708
  const chainKeys = this.network.type === "tron_nile" ? "tronNile" : "tron";
5569
5709
  let tokens;
5570
5710
  if (contractAddress) {
@@ -5651,7 +5791,7 @@ ${msgBytes.length}`
5651
5791
  const hash = keccak256(prefixed);
5652
5792
  const pinHash = getCredentialManager().getPinHash() || void 0;
5653
5793
  const email = getCredentialManager().getEmail() || void 0;
5654
- const api = this.talkenApi || getTalkenApiClient13();
5794
+ const api = this.talkenApi || getTalkenApiClient12();
5655
5795
  const result = await api.bitcoin.signHash({
5656
5796
  hash: hash.startsWith("0x") ? hash.slice(2) : hash,
5657
5797
  pin: pinHash || "",
@@ -5728,7 +5868,7 @@ ${msgBytes.length}`
5728
5868
  );
5729
5869
  }
5730
5870
  const email = getCredentialManager().getEmail() || void 0;
5731
- const api = this.talkenApi || getTalkenApiClient13();
5871
+ const api = this.talkenApi || getTalkenApiClient12();
5732
5872
  const request = txType === "NATIVE" ? {
5733
5873
  kind: "native",
5734
5874
  network: this.network.type,
@@ -5836,7 +5976,7 @@ ${msgBytes.length}`
5836
5976
  };
5837
5977
 
5838
5978
  // src/wallets/walletConnectors/abcWallet/walletGeneration.ts
5839
- import { getTalkenApiClient as getTalkenApiClient14 } from "@talken/talkenkit";
5979
+ import { getTalkenApiClient as getTalkenApiClient13 } from "@talken/talkenkit";
5840
5980
  async function mapApiResponseToWallets(genResponse, infoResponse, email) {
5841
5981
  const accounts = infoResponse?.accounts || [];
5842
5982
  const evmAccount = accounts[0] || infoResponse || {};
@@ -5851,7 +5991,7 @@ async function mapApiResponseToWallets(genResponse, infoResponse, email) {
5851
5991
  let trxAddress = genResponse.trxAddress || "";
5852
5992
  if ((!btcAddress || !trxAddress) && pubkey) {
5853
5993
  try {
5854
- const api = getTalkenApiClient14();
5994
+ const api = getTalkenApiClient13();
5855
5995
  if (api) {
5856
5996
  const addrResponse = await api.wallet.getAddressForChain("all");
5857
5997
  if (!btcAddress)
@@ -5925,7 +6065,7 @@ async function mapApiResponseToWallets(genResponse, infoResponse, email) {
5925
6065
  return { evmWallet, solanaWallet, bitcoinWallet, tronWallet };
5926
6066
  }
5927
6067
  async function generateMpcWallets(hashedPin, email) {
5928
- const api = getTalkenApiClient14();
6068
+ const api = getTalkenApiClient13();
5929
6069
  if (!api) {
5930
6070
  throw new AbcError(
5931
6071
  "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
@@ -5949,7 +6089,7 @@ async function generateMpcWallets(hashedPin, email) {
5949
6089
  }
5950
6090
  }
5951
6091
  async function recoverMpcWallets(hashedPin, email) {
5952
- const api = getTalkenApiClient14();
6092
+ const api = getTalkenApiClient13();
5953
6093
  if (!api) {
5954
6094
  throw new AbcError(
5955
6095
  "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
@@ -6051,8 +6191,6 @@ export {
6051
6191
  createAbcProvider,
6052
6192
  TalkenApiClient,
6053
6193
  createTalkenApiClient,
6054
- setTalkenApiClient,
6055
- getTalkenApiClient2 as getTalkenApiClient,
6056
6194
  SolanaNetwork,
6057
6195
  BitcoinNetwork,
6058
6196
  TronNetwork,