@talken/talkenkit 2.5.1 → 2.5.3

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 (111) hide show
  1. package/README.md +8 -28
  2. package/dist/{AbcCredentialManager-5W3B7GI4.js → AbcCredentialManager-DDHLW2IH.js} +1 -1
  3. package/dist/AbcCredentialManager-JV4ZBMKF.js +7 -0
  4. package/dist/TalkenApiSingleton-TECFDCT4.js +9 -0
  5. package/dist/{abcWallet-O5IRLUXL.js → abcWallet-2BVT5XFX.js} +2 -2
  6. package/dist/abcWallet-BFCI4NEM.js +162 -0
  7. package/dist/{chunk-PN6K4CMZ.js → chunk-ALBABQ53.js} +1 -4
  8. package/dist/chunk-DNEDHHS4.js +379 -0
  9. package/dist/chunk-KOK5ZBR4.js +5447 -0
  10. package/dist/chunk-R6ZE7JAZ.js +15 -0
  11. package/dist/{chunk-UHZL3WSM.js → chunk-WPRIYR63.js} +194 -69
  12. package/dist/components/ConnectOptions/AbcWaasAuth/AbcWaasAuthFlow.d.ts +6 -32
  13. package/dist/components/ConnectOptions/AbcWaasAuth/AbcWaasAuthSections.d.ts +0 -9
  14. package/dist/components/ConnectOptions/AbcWaasAuth/hooks/useAbcWaasAuth.d.ts +3 -12
  15. package/dist/components/ConnectOptions/AbcWaasAuth/types.d.ts +1 -8
  16. package/dist/components/ConnectOptions/PinAuth/PinAuthFlow.d.ts +6 -4
  17. package/dist/components/ProfileDetails/ProfileDetails.d.ts +5 -5
  18. package/dist/hooks/useMultiChainBalances.d.ts +9 -0
  19. package/dist/index.js +1344 -1423
  20. package/dist/wallets/walletConnectors/abcWallet/AbcCredentialManager.js +2 -2
  21. package/dist/wallets/walletConnectors/abcWallet/AbcEvmAutoConnector.js +2 -2
  22. package/dist/wallets/walletConnectors/abcWallet/abcAccessKeyProvider.js +3 -3
  23. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinConnector.js +3 -3
  24. package/dist/wallets/walletConnectors/abcWallet/abcBitcoinProvider.js +3 -3
  25. package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +7 -7
  26. package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +4 -4
  27. package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +7 -7
  28. package/dist/wallets/walletConnectors/abcWallet/abcSolanaWalletAdapter.js +44 -44
  29. package/dist/wallets/walletConnectors/abcWallet/abcTronProvider.js +3 -3
  30. package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +8 -8
  31. package/dist/wallets/walletConnectors/abcWallet/api/ConfigApi.js +2 -2
  32. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.d.ts +44 -0
  33. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +3 -3
  34. package/dist/wallets/walletConnectors/abcWallet/api/TokenApi.js +2 -2
  35. package/dist/wallets/walletConnectors/abcWallet/api/WalletscanApi.js +3 -3
  36. package/dist/wallets/walletConnectors/abcWallet/api/index.js +6 -6
  37. package/dist/wallets/walletConnectors/abcWallet/constants.d.ts +3 -0
  38. package/dist/wallets/walletConnectors/abcWallet/constants.js +5 -3
  39. package/dist/wallets/walletConnectors/abcWallet/index.js +19 -19
  40. package/dist/wallets/walletConnectors/abcWallet/sessionUtils.js +2 -2
  41. package/dist/wallets/walletConnectors/abcWallet/types.d.ts +4 -0
  42. package/dist/wallets/walletConnectors/abcWallet/utils.js +2 -2
  43. package/dist/wallets/walletConnectors/abcWallet/walletGeneration.js +3 -3
  44. package/dist/wallets/walletConnectors/berasigWallet/berasigWallet.js +2 -2
  45. package/dist/wallets/walletConnectors/bifrostWallet/bifrostWallet.js +2 -2
  46. package/dist/wallets/walletConnectors/binanceWallet/binanceWallet.js +2 -2
  47. package/dist/wallets/walletConnectors/bitgetWallet/bitgetWallet.js +2 -2
  48. package/dist/wallets/walletConnectors/bybitWallet/bybitWallet.js +2 -2
  49. package/dist/wallets/walletConnectors/{chunk-4JZPP3S7.js → chunk-2N244XPQ.js} +1 -1
  50. package/dist/wallets/walletConnectors/{chunk-QKK3OPQA.js → chunk-36BJXEBA.js} +1 -1
  51. package/dist/wallets/walletConnectors/{chunk-FKI5AZVH.js → chunk-3K3KYVRN.js} +1 -1
  52. package/dist/wallets/walletConnectors/{chunk-URS2KVYK.js → chunk-5DK36WJ2.js} +1 -1
  53. package/dist/wallets/walletConnectors/chunk-5ERWBR7D.js +977 -0
  54. package/dist/wallets/walletConnectors/chunk-6KRX73ED.js +230 -0
  55. package/dist/wallets/walletConnectors/{chunk-H2AZTZMM.js → chunk-6L5G54IX.js} +1 -1
  56. package/dist/wallets/walletConnectors/chunk-6WF4SXLB.js +156 -0
  57. package/dist/wallets/walletConnectors/{chunk-PF65YS3T.js → chunk-A66MTFML.js} +1 -1
  58. package/dist/wallets/walletConnectors/{chunk-LIGH2LEU.js → chunk-ACLPF2UW.js} +1 -1
  59. package/dist/wallets/walletConnectors/{chunk-KIYXONNH.js → chunk-BHEVY4QY.js} +2 -35
  60. package/dist/wallets/walletConnectors/{chunk-YKFI6ZGM.js → chunk-BXH3GDX5.js} +1 -1
  61. package/dist/wallets/walletConnectors/{chunk-RGYZNNB6.js → chunk-C4ADBB6M.js} +1 -1
  62. package/dist/wallets/walletConnectors/chunk-CABLJOMU.js +194 -0
  63. package/dist/wallets/walletConnectors/{chunk-RX2VOIUB.js → chunk-DPTDOCWL.js} +1 -4
  64. package/dist/wallets/walletConnectors/{chunk-6TAU7OQK.js → chunk-DW36LXIV.js} +8 -7
  65. package/dist/wallets/walletConnectors/chunk-EBTKWCIS.js +224 -0
  66. package/dist/wallets/walletConnectors/{chunk-25ZDAJ3L.js → chunk-EZS3GXZN.js} +1 -1
  67. package/dist/wallets/walletConnectors/chunk-FBJ5H6PM.js +300 -0
  68. package/dist/wallets/walletConnectors/chunk-IM7DEERX.js +585 -0
  69. package/dist/wallets/walletConnectors/chunk-J3YPHDHM.js +827 -0
  70. package/dist/wallets/walletConnectors/chunk-JADQLTFW.js +194 -0
  71. package/dist/wallets/walletConnectors/{chunk-L6FCF3FH.js → chunk-L3HWFGTN.js} +2 -2
  72. package/dist/wallets/walletConnectors/chunk-L6WDO3ZN.js +445 -0
  73. package/dist/wallets/walletConnectors/chunk-MO2AXXLI.js +30 -0
  74. package/dist/wallets/walletConnectors/chunk-NLA45GHJ.js +300 -0
  75. package/dist/wallets/walletConnectors/chunk-NU3ITJNK.js +1485 -0
  76. package/dist/wallets/walletConnectors/{chunk-HWRZGGGN.js → chunk-NULM3THX.js} +1 -1
  77. package/dist/wallets/walletConnectors/chunk-OMOYFHBT.js +1485 -0
  78. package/dist/wallets/walletConnectors/{chunk-4YEALKXG.js → chunk-OOCL4OPQ.js} +29 -11
  79. package/dist/wallets/walletConnectors/chunk-PVPSVCVQ.js +96 -0
  80. package/dist/wallets/walletConnectors/chunk-VBNZ7HA3.js +241 -0
  81. package/dist/wallets/walletConnectors/chunk-VDWJ3NQ5.js +52 -0
  82. package/dist/wallets/walletConnectors/chunk-VLHDGDFH.js +273 -0
  83. package/dist/wallets/walletConnectors/chunk-VMCIDCO5.js +54 -0
  84. package/dist/wallets/walletConnectors/chunk-VNL7XEWF.js +54 -0
  85. package/dist/wallets/walletConnectors/chunk-YV6IZWGE.js +393 -0
  86. package/dist/wallets/walletConnectors/{chunk-645DT4TS.js → chunk-ZLH3W5PQ.js} +2 -2
  87. package/dist/wallets/walletConnectors/clvWallet/clvWallet.js +2 -2
  88. package/dist/wallets/walletConnectors/coin98Wallet/coin98Wallet.js +2 -2
  89. package/dist/wallets/walletConnectors/coreWallet/coreWallet.js +2 -2
  90. package/dist/wallets/walletConnectors/foxWallet/foxWallet.js +2 -2
  91. package/dist/wallets/walletConnectors/frontierWallet/frontierWallet.js +2 -2
  92. package/dist/wallets/walletConnectors/gateWallet/gateWallet.js +2 -2
  93. package/dist/wallets/walletConnectors/index.js +67 -67
  94. package/dist/wallets/walletConnectors/iopayWallet/iopayWallet.js +2 -2
  95. package/dist/wallets/walletConnectors/kaiaWallet/kaiaWallet.js +2 -2
  96. package/dist/wallets/walletConnectors/kaikasWallet/kaikasWallet.js +2 -2
  97. package/dist/wallets/walletConnectors/klipWallet/klipWallet.js +2 -2
  98. package/dist/wallets/walletConnectors/klipWallet-TBZJ5GGT.js +7 -0
  99. package/dist/wallets/walletConnectors/metaMaskWallet/metaMaskWallet.js +2 -2
  100. package/dist/wallets/walletConnectors/okxWallet/okxWallet.js +2 -2
  101. package/dist/wallets/walletConnectors/rainbowWallet/rainbowWallet.js +2 -2
  102. package/dist/wallets/walletConnectors/roninWallet/roninWallet.js +2 -2
  103. package/dist/wallets/walletConnectors/safepalWallet/safepalWallet.js +2 -2
  104. package/dist/wallets/walletConnectors/subWallet/subWallet.js +2 -2
  105. package/dist/wallets/walletConnectors/tokenPocketWallet/tokenPocketWallet.js +2 -2
  106. package/dist/wallets/walletConnectors/trustWallet/trustWallet.js +2 -2
  107. package/dist/wallets/walletConnectors/zealWallet/zealWallet.js +2 -2
  108. package/dist/wallets/walletConnectors/zerionWallet/zerionWallet.js +2 -2
  109. package/package.json +12 -11
  110. package/LICENSE +0 -9
  111. package/dist/wallets/walletConnectors/klipWallet-PPTYYB5G.js +0 -7
@@ -0,0 +1,15 @@
1
+ "use client";
2
+
3
+ // src/wallets/walletConnectors/abcWallet/api/TalkenApiSingleton.ts
4
+ var _instance;
5
+ function setTalkenApiClient(client) {
6
+ _instance = client;
7
+ }
8
+ function getTalkenApiClient() {
9
+ return _instance;
10
+ }
11
+
12
+ export {
13
+ setTalkenApiClient,
14
+ getTalkenApiClient
15
+ };
@@ -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
  }
@@ -2412,6 +2417,34 @@ var TalkenAuthModule = class {
2412
2417
  this.client.handleAuthResponse(res);
2413
2418
  return res;
2414
2419
  }
2420
+ /**
2421
+ * Server-side unified onboarding: email + OTP → access key + wallets.
2422
+ * POST /wallet/auth { action: 'ensure-user', email, otpCode, accessKeyName }
2423
+ */
2424
+ async ensureUser(email, otpCode, accessKeyName = "talkenkit") {
2425
+ const raw = await this.client.post(
2426
+ TALKEN_API_ENDPOINTS.AUTH,
2427
+ { action: "ensure-user", email, otpCode, accessKeyName },
2428
+ { skipAuth: true }
2429
+ );
2430
+ return raw.data || raw;
2431
+ }
2432
+ /**
2433
+ * Create an Access Key for delegated authentication
2434
+ * POST /agent/access-keys { name, pin, refreshToken, email, ttlSeconds }
2435
+ */
2436
+ async createAccessKey(params) {
2437
+ const raw = await this.client.post(
2438
+ TALKEN_API_ENDPOINTS.ACCESS_KEYS,
2439
+ params
2440
+ );
2441
+ const d = raw.data || raw;
2442
+ return {
2443
+ accessKey: d.accessKey,
2444
+ keyId: d.keyId,
2445
+ expiresAt: d.expiresAt
2446
+ };
2447
+ }
2415
2448
  /**
2416
2449
  * Logout (clear local session only — no server endpoint)
2417
2450
  */
@@ -2855,11 +2888,12 @@ var TalkenWalletscanModule = class {
2855
2888
  );
2856
2889
  }
2857
2890
  };
2858
- var TalkenApiClient = class {
2891
+ var TalkenApiClient = class _TalkenApiClient {
2859
2892
  constructor(config) {
2860
2893
  this.accessToken = null;
2861
2894
  this.refreshToken_ = null;
2862
2895
  this.expiresAt = null;
2896
+ this.accessKeyRaw = null;
2863
2897
  this.isRefreshing = false;
2864
2898
  this.refreshPromise = null;
2865
2899
  this.config = {
@@ -2880,6 +2914,10 @@ var TalkenApiClient = class {
2880
2914
  }
2881
2915
  // ── Session Management ──────────────────────────────────────────────
2882
2916
  restoreSession() {
2917
+ this.accessKeyRaw = loadToken("access_key_raw");
2918
+ if (this.accessKeyRaw) {
2919
+ return;
2920
+ }
2883
2921
  this.accessToken = loadToken("access_token");
2884
2922
  this.refreshToken_ = loadToken("refresh_token");
2885
2923
  const expiresAtStr = loadToken("expires_at");
@@ -2899,14 +2937,74 @@ var TalkenApiClient = class {
2899
2937
  this.accessToken = null;
2900
2938
  this.refreshToken_ = null;
2901
2939
  this.expiresAt = null;
2940
+ this.accessKeyRaw = null;
2902
2941
  removeToken("access_token");
2903
2942
  removeToken("refresh_token");
2904
2943
  removeToken("expires_at");
2944
+ removeToken("access_key_raw");
2945
+ }
2946
+ static {
2947
+ /** All known access key prefixes (any environment). */
2948
+ this.KNOWN_AK_PREFIXES = [
2949
+ "talken_live_",
2950
+ "talken_stg_",
2951
+ "talken_dev_",
2952
+ "talken_local_"
2953
+ ];
2954
+ }
2955
+ /** Validate access key format: talken_<env>_<publicId>.<secret> */
2956
+ static isValidAccessKeyFormat(key) {
2957
+ const trimmed = key.trim();
2958
+ for (const prefix of _TalkenApiClient.KNOWN_AK_PREFIXES) {
2959
+ if (trimmed.startsWith(prefix)) {
2960
+ const payload = trimmed.slice(prefix.length);
2961
+ const dot = payload.indexOf(".");
2962
+ if (dot < 1)
2963
+ return false;
2964
+ return payload.slice(0, dot).length > 0 && payload.slice(dot + 1).length > 0;
2965
+ }
2966
+ }
2967
+ return false;
2968
+ }
2969
+ /**
2970
+ * Set Access Key and switch to Access Key mode.
2971
+ * Accepts any known env prefix (talken_live_, talken_stg_, talken_dev_, talken_local_).
2972
+ */
2973
+ setAccessKey(key) {
2974
+ const trimmed = key.trim();
2975
+ if (!_TalkenApiClient.isValidAccessKeyFormat(trimmed)) {
2976
+ throw new Error(
2977
+ "Invalid access key format. Expected: talken_<env>_<publicId>.<secret>"
2978
+ );
2979
+ }
2980
+ this.accessKeyRaw = trimmed;
2981
+ saveToken("access_key_raw", trimmed);
2982
+ this.accessToken = null;
2983
+ this.refreshToken_ = null;
2984
+ this.expiresAt = null;
2985
+ removeToken("access_token");
2986
+ removeToken("refresh_token");
2987
+ removeToken("expires_at");
2988
+ }
2989
+ /**
2990
+ * Clear Access Key
2991
+ */
2992
+ clearAccessKey() {
2993
+ this.accessKeyRaw = null;
2994
+ removeToken("access_key_raw");
2995
+ }
2996
+ /**
2997
+ * Check if running in Access Key mode
2998
+ */
2999
+ isAccessKeyMode() {
3000
+ return !!this.accessKeyRaw;
2905
3001
  }
2906
3002
  /**
2907
3003
  * Check if user is authenticated (has valid access token)
2908
3004
  */
2909
3005
  isAuthenticated() {
3006
+ if (this.accessKeyRaw)
3007
+ return true;
2910
3008
  return !!this.accessToken && !this.isTokenExpired();
2911
3009
  }
2912
3010
  /**
@@ -2962,7 +3060,7 @@ var TalkenApiClient = class {
2962
3060
  */
2963
3061
  async request(endpoint, options) {
2964
3062
  const { method, body, skipAuth = false } = options;
2965
- if (!skipAuth && this.isTokenExpired() && this.refreshToken_) {
3063
+ if (!skipAuth && !this.accessKeyRaw && this.isTokenExpired() && this.refreshToken_) {
2966
3064
  await this.ensureTokenRefreshed();
2967
3065
  }
2968
3066
  const url = `${this.config.baseUrl}${endpoint}`;
@@ -2970,8 +3068,17 @@ var TalkenApiClient = class {
2970
3068
  "Content-Type": "application/json",
2971
3069
  Accept: "application/json"
2972
3070
  };
2973
- if (!skipAuth && this.accessToken) {
2974
- headers.Authorization = `Bearer ${this.accessToken}`;
3071
+ if (!skipAuth) {
3072
+ if (this.accessKeyRaw) {
3073
+ headers["X-Access-Key"] = this.accessKeyRaw;
3074
+ } else if (this.accessToken) {
3075
+ headers.Authorization = `Bearer ${this.accessToken}`;
3076
+ } else {
3077
+ const tgAk = loadTgAccessKey();
3078
+ if (tgAk) {
3079
+ headers["X-Access-Key"] = tgAk;
3080
+ }
3081
+ }
2975
3082
  }
2976
3083
  if (this.config.debug) {
2977
3084
  console.log(`[TalkenApiClient] ${method} ${url}`);
@@ -3006,18 +3113,32 @@ var TalkenApiClient = class {
3006
3113
  } else {
3007
3114
  data = { success: true };
3008
3115
  }
3009
- if (response.status === 401 && !skipAuth && this.refreshToken_) {
3010
- try {
3011
- await this.forceTokenRefresh();
3012
- return this.request(endpoint, { ...options, skipAuth: true });
3013
- } catch {
3014
- this.clearSession();
3116
+ if (response.status === 401 && !skipAuth) {
3117
+ if (this.accessKeyRaw) {
3118
+ if (typeof window !== "undefined") {
3119
+ window.dispatchEvent(
3120
+ new CustomEvent("talkenkit:access_key_expired")
3121
+ );
3122
+ }
3015
3123
  throw new TalkenApiError(
3016
- "TOKEN_EXPIRED",
3017
- "Session expired. Please login again.",
3124
+ "ACCESS_KEY_EXPIRED",
3125
+ "Access key expired. Please login again.",
3018
3126
  401
3019
3127
  );
3020
3128
  }
3129
+ if (this.refreshToken_) {
3130
+ try {
3131
+ await this.forceTokenRefresh();
3132
+ return this.request(endpoint, { ...options, skipAuth: true });
3133
+ } catch {
3134
+ this.clearSession();
3135
+ throw new TalkenApiError(
3136
+ "TOKEN_EXPIRED",
3137
+ "Session expired. Please login again.",
3138
+ 401
3139
+ );
3140
+ }
3141
+ }
3021
3142
  }
3022
3143
  if (!response.ok) {
3023
3144
  const errCode = data.error?.code || "UNKNOWN_ERROR";
@@ -3078,15 +3199,6 @@ function createTalkenApiClient(config) {
3078
3199
  return new TalkenApiClient(config);
3079
3200
  }
3080
3201
 
3081
- // src/wallets/walletConnectors/abcWallet/api/TalkenApiSingleton.ts
3082
- var _instance;
3083
- function setTalkenApiClient(client) {
3084
- _instance = client;
3085
- }
3086
- function getTalkenApiClient2() {
3087
- return _instance;
3088
- }
3089
-
3090
3202
  // src/wallets/walletConnectors/abcWallet/networkConfig.ts
3091
3203
  var SolanaNetwork = /* @__PURE__ */ ((SolanaNetwork2) => {
3092
3204
  SolanaNetwork2["Mainnet"] = "solana";
@@ -3194,16 +3306,24 @@ function abcConnector(options) {
3194
3306
  setGlobalDefaultBitcoinNetwork(config.defaultBitcoinNetwork);
3195
3307
  }
3196
3308
  return createConnector((wagmiConfig) => {
3197
- const talkenApi = getTalkenApiClient3() || createTalkenApiClient({
3309
+ const talkenApi = getTalkenApiClient2() || createTalkenApiClient({
3198
3310
  baseUrl: resolveTalkenApiUrl(config.talkenApiUrl),
3199
3311
  environment: config.environment,
3200
3312
  debug: config.environment === "development",
3201
3313
  defaultChainId: config.defaultChainId
3202
3314
  });
3203
3315
  setTalkenApiClient(talkenApi);
3204
- const isAccessKeyMode = !!config.accessKey;
3316
+ const storedAccessKey = typeof window !== "undefined" ? (() => {
3317
+ try {
3318
+ return localStorage.getItem("talken_api_access_key_raw");
3319
+ } catch {
3320
+ return null;
3321
+ }
3322
+ })() : null;
3323
+ const effectiveAccessKey = config.accessKey || storedAccessKey;
3324
+ const isAccessKeyMode = !!effectiveAccessKey;
3205
3325
  const provider = isAccessKeyMode ? new AbcAccessKeyProvider(
3206
- config.accessKey,
3326
+ effectiveAccessKey,
3207
3327
  resolveTalkenApiUrl(config.talkenApiUrl)
3208
3328
  ) : createAbcEvmProvider(talkenApi);
3209
3329
  let accountsChangedHandler;
@@ -3231,7 +3351,7 @@ function abcConnector(options) {
3231
3351
  method: "POST",
3232
3352
  headers: {
3233
3353
  "Content-Type": "application/json",
3234
- "X-Access-Key": config.accessKey
3354
+ "X-Access-Key": effectiveAccessKey
3235
3355
  },
3236
3356
  body: JSON.stringify({ action: "info" })
3237
3357
  });
@@ -3362,6 +3482,10 @@ function abcConnector(options) {
3362
3482
  }
3363
3483
  provider.clearWallet();
3364
3484
  talkenApi.auth.logout();
3485
+ try {
3486
+ localStorage.removeItem("talken_api_access_key_raw");
3487
+ } catch {
3488
+ }
3365
3489
  clearAuthState();
3366
3490
  getCredentialManager().clear();
3367
3491
  },
@@ -3398,7 +3522,7 @@ function abcConnector(options) {
3398
3522
  if (isAccessKeyMode) {
3399
3523
  if (provider.isConnected())
3400
3524
  return true;
3401
- const hasKey = !!config.accessKey || typeof localStorage !== "undefined" && !!localStorage.getItem("talken_ak");
3525
+ const hasKey = !!effectiveAccessKey || typeof localStorage !== "undefined" && (!!localStorage.getItem("talken_api_access_key_raw") || !!loadTgAccessKey());
3402
3526
  const authState2 = loadAuthState();
3403
3527
  return hasKey && !!authState2?.wallet?.address;
3404
3528
  }
@@ -3412,6 +3536,9 @@ function abcConnector(options) {
3412
3536
  if (talkenApi.isAuthenticated()) {
3413
3537
  return true;
3414
3538
  }
3539
+ if (talkenApi.isAccessKeyMode()) {
3540
+ return true;
3541
+ }
3415
3542
  const refreshToken = loadFromStorage(
3416
3543
  "refresh_token" /* REFRESH_TOKEN */
3417
3544
  );
@@ -3420,7 +3547,7 @@ function abcConnector(options) {
3420
3547
  return false;
3421
3548
  }
3422
3549
  try {
3423
- const api = getTalkenApiClient3();
3550
+ const api = getTalkenApiClient2();
3424
3551
  if (!api) {
3425
3552
  clearStorage();
3426
3553
  return false;
@@ -3512,7 +3639,7 @@ var abcWallet = (specificOptions) => ({ projectId }) => {
3512
3639
  debug: specificOptions?.environment === "development"
3513
3640
  });
3514
3641
  setTalkenApiClient2(talkenApi);
3515
- const accessKey = specificOptions?.accessKey || (typeof localStorage !== "undefined" ? localStorage.getItem("talken_ak") : null) || null;
3642
+ const accessKey = specificOptions?.accessKey || loadTgAccessKey() || null;
3516
3643
  const config = {
3517
3644
  talkenApiUrl,
3518
3645
  apiKey: specificOptions?.apiKey,
@@ -3544,13 +3671,13 @@ var abcWallet = (specificOptions) => ({ projectId }) => {
3544
3671
  };
3545
3672
 
3546
3673
  // src/wallets/walletConnectors/abcWallet/api/WalletscanApi.ts
3547
- import { getTalkenApiClient as getTalkenApiClient5, networkNameToChainKey as networkNameToChainKey2 } from "@talken/talkenkit";
3674
+ import { getTalkenApiClient as getTalkenApiClient4, networkNameToChainKey as networkNameToChainKey2 } from "@talken/talkenkit";
3548
3675
 
3549
3676
  // src/wallets/walletConnectors/abcWallet/api/TokenApi.ts
3550
- import { getTalkenApiClient as getTalkenApiClient4 } from "@talken/talkenkit";
3677
+ import { getTalkenApiClient as getTalkenApiClient3 } from "@talken/talkenkit";
3551
3678
  var TokenApi = class {
3552
3679
  async getBalances(address, chainKey) {
3553
- const api = getTalkenApiClient4();
3680
+ const api = getTalkenApiClient3();
3554
3681
  if (!api)
3555
3682
  throw new Error("TalkenApiClient not initialized");
3556
3683
  const query = new URLSearchParams({ address, chainKey }).toString();
@@ -3577,7 +3704,7 @@ var WalletscanApi = class {
3577
3704
  * Get all wallet tokens with balances via TalkenApiClient walletscan endpoint
3578
3705
  */
3579
3706
  async getWalletTokens(params) {
3580
- const api = getTalkenApiClient5();
3707
+ const api = getTalkenApiClient4();
3581
3708
  if (!api)
3582
3709
  throw new Error("TalkenApiClient not initialized");
3583
3710
  try {
@@ -3637,7 +3764,7 @@ var WalletscanApi = class {
3637
3764
  * @returns Token metadata or null if not found/failed
3638
3765
  */
3639
3766
  async getContractToken(params) {
3640
- const api = getTalkenApiClient5();
3767
+ const api = getTalkenApiClient4();
3641
3768
  if (!api)
3642
3769
  throw new Error("TalkenApiClient not initialized");
3643
3770
  try {
@@ -3686,7 +3813,7 @@ var WalletscanApi = class {
3686
3813
  * @returns Array of native coins or empty array if failed
3687
3814
  */
3688
3815
  async getNativeToken(params) {
3689
- const api = getTalkenApiClient5();
3816
+ const api = getTalkenApiClient4();
3690
3817
  if (!api)
3691
3818
  throw new Error("TalkenApiClient not initialized");
3692
3819
  const chainKey = networkNameToChainKey2(params.networks);
@@ -3757,7 +3884,7 @@ var WalletscanApi = class {
3757
3884
  * @returns Array of NFT metadata or empty array if failed
3758
3885
  */
3759
3886
  async getNFT(params) {
3760
- const api = getTalkenApiClient5();
3887
+ const api = getTalkenApiClient4();
3761
3888
  if (!api)
3762
3889
  throw new Error("TalkenApiClient not initialized");
3763
3890
  try {
@@ -3801,7 +3928,7 @@ var WalletscanApi = class {
3801
3928
  };
3802
3929
 
3803
3930
  // src/wallets/walletConnectors/abcWallet/api/GasApi.ts
3804
- import { getTalkenApiClient as getTalkenApiClient6 } from "@talken/talkenkit";
3931
+ import { getTalkenApiClient as getTalkenApiClient5 } from "@talken/talkenkit";
3805
3932
  var GasApi = class {
3806
3933
  parseGasFees(data) {
3807
3934
  return {
@@ -3816,7 +3943,7 @@ var GasApi = class {
3816
3943
  * @returns Suggested gas fees or null if failed
3817
3944
  */
3818
3945
  async getSuggestedGasFees(network) {
3819
- const api = getTalkenApiClient6();
3946
+ const api = getTalkenApiClient5();
3820
3947
  if (!api)
3821
3948
  throw new Error("TalkenApiClient not initialized");
3822
3949
  try {
@@ -3838,7 +3965,7 @@ var GasApi = class {
3838
3965
  * @returns Gas limit (hex string) or null if failed
3839
3966
  */
3840
3967
  async estimateGas(params) {
3841
- const api = getTalkenApiClient6();
3968
+ const api = getTalkenApiClient5();
3842
3969
  if (!api)
3843
3970
  throw new Error("TalkenApiClient not initialized");
3844
3971
  try {
@@ -3900,7 +4027,7 @@ var GasApi = class {
3900
4027
  };
3901
4028
 
3902
4029
  // src/wallets/walletConnectors/abcWallet/api/ConfigApi.ts
3903
- import { getTalkenApiClient as getTalkenApiClient7 } from "@talken/talkenkit";
4030
+ import { getTalkenApiClient as getTalkenApiClient6 } from "@talken/talkenkit";
3904
4031
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3905
4032
  var toStatusCode = (status) => {
3906
4033
  if (typeof status === "number")
@@ -3918,7 +4045,7 @@ var toStatusCode = (status) => {
3918
4045
  };
3919
4046
  var ConfigApi = class {
3920
4047
  async getTxStatus(chainKey, txHash) {
3921
- const api = getTalkenApiClient7();
4048
+ const api = getTalkenApiClient6();
3922
4049
  if (!api)
3923
4050
  throw new Error("TalkenApiClient not initialized");
3924
4051
  return api.get(
@@ -3944,16 +4071,16 @@ var ConfigApi = class {
3944
4071
  };
3945
4072
 
3946
4073
  // src/wallets/walletConnectors/abcWallet/api/SolanaApi.ts
3947
- import { getTalkenApiClient as getTalkenApiClient8 } from "@talken/talkenkit";
4074
+ import { getTalkenApiClient as getTalkenApiClient7 } from "@talken/talkenkit";
3948
4075
  var SolanaApi = class {
3949
4076
  async getLatestBlockhash(network) {
3950
- const api = getTalkenApiClient8();
4077
+ const api = getTalkenApiClient7();
3951
4078
  if (!api)
3952
4079
  throw new Error("TalkenApiClient not initialized");
3953
4080
  return api.solana.getLatestBlockhash(network);
3954
4081
  }
3955
4082
  async getTransactionStatus(params) {
3956
- const api = getTalkenApiClient8();
4083
+ const api = getTalkenApiClient7();
3957
4084
  if (!api)
3958
4085
  throw new Error("TalkenApiClient not initialized");
3959
4086
  return api.solana.getTransactionStatus(params);
@@ -3978,7 +4105,7 @@ var SolanaApi = class {
3978
4105
  };
3979
4106
 
3980
4107
  // src/wallets/walletConnectors/abcWallet/sessionUtils.ts
3981
- import { getTalkenApiClient as getTalkenApiClient9 } from "@talken/talkenkit";
4108
+ import { getTalkenApiClient as getTalkenApiClient8 } from "@talken/talkenkit";
3982
4109
  var SessionExpiredError = class extends Error {
3983
4110
  constructor(message = "Session expired. Please reconnect your wallet.") {
3984
4111
  super(message);
@@ -4016,7 +4143,7 @@ async function refreshAccessToken(pinCallback) {
4016
4143
  if (pinCallback) {
4017
4144
  await pinCallback();
4018
4145
  }
4019
- const api = getTalkenApiClient9();
4146
+ const api = getTalkenApiClient8();
4020
4147
  if (!api) {
4021
4148
  console.warn(
4022
4149
  "[SessionUtils] TalkenApiClient not initialized - opening connect modal"
@@ -4062,7 +4189,7 @@ async function refreshAccessToken(pinCallback) {
4062
4189
  }
4063
4190
 
4064
4191
  // src/wallets/walletConnectors/abcWallet/abcBitcoinProvider.ts
4065
- import { getTalkenApiClient as getTalkenApiClient10 } from "@talken/talkenkit";
4192
+ import { getTalkenApiClient as getTalkenApiClient9 } from "@talken/talkenkit";
4066
4193
  function isTalkenApiClient(client) {
4067
4194
  return typeof client?.bitcoin?.getUtxos === "function";
4068
4195
  }
@@ -4333,7 +4460,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4333
4460
  }
4334
4461
  try {
4335
4462
  console.log("[BitcoinProvider] \u{1F50D} Fetching UTXOs from network...");
4336
- const api = this.talkenApi || getTalkenApiClient10();
4463
+ const api = this.talkenApi || getTalkenApiClient9();
4337
4464
  const result = await api.bitcoin.getUtxos(this.network.type, address);
4338
4465
  const utxos = this.normalizeUtxos(result.utxos || []);
4339
4466
  this.utxoCache.set(address, utxos);
@@ -4370,7 +4497,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4370
4497
  */
4371
4498
  async estimateFee(targetBlocks = 6) {
4372
4499
  try {
4373
- const api = this.talkenApi || getTalkenApiClient10();
4500
+ const api = this.talkenApi || getTalkenApiClient9();
4374
4501
  const result = await api.bitcoin.getFeeRate(
4375
4502
  this.network.type,
4376
4503
  targetBlocks
@@ -4423,7 +4550,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4423
4550
  const hash1 = await crypto.subtle.digest("SHA-256", preimage);
4424
4551
  const hash2 = await crypto.subtle.digest("SHA-256", hash1);
4425
4552
  const hashHex = Array.from(new Uint8Array(hash2)).map((b) => b.toString(16).padStart(2, "0")).join("");
4426
- const api = getTalkenApiClient10();
4553
+ const api = getTalkenApiClient9();
4427
4554
  if (!api) {
4428
4555
  throw new BitcoinProviderError(
4429
4556
  BitcoinErrorCode.INTERNAL_ERROR,
@@ -4534,7 +4661,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4534
4661
  }
4535
4662
  const email = this.getRecoveryEmail();
4536
4663
  const satoshis = Math.floor(params.amount * 1e8);
4537
- const api = this.talkenApi || getTalkenApiClient10();
4664
+ const api = this.talkenApi || getTalkenApiClient9();
4538
4665
  const result = await api.bitcoin.sendTransaction({
4539
4666
  toAddress: params.toAddress,
4540
4667
  amountSats: satoshis.toString(),
@@ -4597,7 +4724,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4597
4724
  "[BitcoinProvider] \u2139\uFE0F PSBT argument provided; raw tx broadcast uses rawTransaction only via talken-api"
4598
4725
  );
4599
4726
  }
4600
- const api = this.talkenApi || getTalkenApiClient10();
4727
+ const api = this.talkenApi || getTalkenApiClient9();
4601
4728
  const result = await api.bitcoin.broadcastRawTransaction({
4602
4729
  network: this.network.type,
4603
4730
  rawTransaction
@@ -4647,7 +4774,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4647
4774
  };
4648
4775
 
4649
4776
  // src/wallets/walletConnectors/abcWallet/abcBitcoinConnector.ts
4650
- import { getTalkenApiClient as getTalkenApiClient11 } from "@talken/talkenkit";
4777
+ import { getTalkenApiClient as getTalkenApiClient10 } from "@talken/talkenkit";
4651
4778
  var AbcBitcoinConnector = class {
4652
4779
  constructor(config) {
4653
4780
  this.wallet = null;
@@ -4809,7 +4936,7 @@ var AbcBitcoinConnector = class {
4809
4936
  if (!authState.bitcoinWallet) {
4810
4937
  return false;
4811
4938
  }
4812
- const api = getTalkenApiClient11();
4939
+ const api = getTalkenApiClient10();
4813
4940
  return !!api && !api.isTokenExpired();
4814
4941
  } catch {
4815
4942
  return false;
@@ -4912,7 +5039,7 @@ function createAbcBitcoinConnector(config) {
4912
5039
  // src/wallets/walletConnectors/abcWallet/abcSolanaProvider.ts
4913
5040
  import {
4914
5041
  getShowPendingTransaction as getShowPendingTransaction2,
4915
- getTalkenApiClient as getTalkenApiClient12,
5042
+ getTalkenApiClient as getTalkenApiClient11,
4916
5043
  getUpdateTransactionResult as getUpdateTransactionResult2
4917
5044
  } from "@talken/talkenkit";
4918
5045
 
@@ -5046,7 +5173,7 @@ var AbcSolanaProvider = class extends EventEmitter4 {
5046
5173
  this.talkenApi = talkenApi;
5047
5174
  }
5048
5175
  getTalkenApiClientOrThrow() {
5049
- const api = this.talkenApi || getTalkenApiClient12();
5176
+ const api = this.talkenApi || getTalkenApiClient11();
5050
5177
  if (!api) {
5051
5178
  throw new SolanaProviderError(
5052
5179
  SolanaErrorCode.INTERNAL_ERROR,
@@ -5399,7 +5526,7 @@ var AbcSolanaProvider = class extends EventEmitter4 {
5399
5526
  // src/wallets/walletConnectors/abcWallet/abcTronProvider.ts
5400
5527
  import {
5401
5528
  getShowPendingTransaction as getShowPendingTransaction3,
5402
- getTalkenApiClient as getTalkenApiClient13,
5529
+ getTalkenApiClient as getTalkenApiClient12,
5403
5530
  getUpdateTransactionResult as getUpdateTransactionResult3
5404
5531
  } from "@talken/talkenkit";
5405
5532
  import { keccak256 } from "viem";
@@ -5551,7 +5678,7 @@ var AbcTronProvider = class extends EventEmitter5 {
5551
5678
  if (cached)
5552
5679
  return cached;
5553
5680
  try {
5554
- const api = this.talkenApi || getTalkenApiClient13();
5681
+ const api = this.talkenApi || getTalkenApiClient12();
5555
5682
  const chainKeys = this.network.type === "tron_nile" ? "tronNile" : "tron";
5556
5683
  let tokens;
5557
5684
  if (contractAddress) {
@@ -5638,7 +5765,7 @@ ${msgBytes.length}`
5638
5765
  const hash = keccak256(prefixed);
5639
5766
  const pinHash = getCredentialManager().getPinHash() || void 0;
5640
5767
  const email = getCredentialManager().getEmail() || void 0;
5641
- const api = this.talkenApi || getTalkenApiClient13();
5768
+ const api = this.talkenApi || getTalkenApiClient12();
5642
5769
  const result = await api.bitcoin.signHash({
5643
5770
  hash: hash.startsWith("0x") ? hash.slice(2) : hash,
5644
5771
  pin: pinHash || "",
@@ -5715,7 +5842,7 @@ ${msgBytes.length}`
5715
5842
  );
5716
5843
  }
5717
5844
  const email = getCredentialManager().getEmail() || void 0;
5718
- const api = this.talkenApi || getTalkenApiClient13();
5845
+ const api = this.talkenApi || getTalkenApiClient12();
5719
5846
  const request = txType === "NATIVE" ? {
5720
5847
  kind: "native",
5721
5848
  network: this.network.type,
@@ -5823,7 +5950,7 @@ ${msgBytes.length}`
5823
5950
  };
5824
5951
 
5825
5952
  // src/wallets/walletConnectors/abcWallet/walletGeneration.ts
5826
- import { getTalkenApiClient as getTalkenApiClient14 } from "@talken/talkenkit";
5953
+ import { getTalkenApiClient as getTalkenApiClient13 } from "@talken/talkenkit";
5827
5954
  async function mapApiResponseToWallets(genResponse, infoResponse, email) {
5828
5955
  const accounts = infoResponse?.accounts || [];
5829
5956
  const evmAccount = accounts[0] || infoResponse || {};
@@ -5838,7 +5965,7 @@ async function mapApiResponseToWallets(genResponse, infoResponse, email) {
5838
5965
  let trxAddress = genResponse.trxAddress || "";
5839
5966
  if ((!btcAddress || !trxAddress) && pubkey) {
5840
5967
  try {
5841
- const api = getTalkenApiClient14();
5968
+ const api = getTalkenApiClient13();
5842
5969
  if (api) {
5843
5970
  const addrResponse = await api.wallet.getAddressForChain("all");
5844
5971
  if (!btcAddress)
@@ -5912,7 +6039,7 @@ async function mapApiResponseToWallets(genResponse, infoResponse, email) {
5912
6039
  return { evmWallet, solanaWallet, bitcoinWallet, tronWallet };
5913
6040
  }
5914
6041
  async function generateMpcWallets(hashedPin, email) {
5915
- const api = getTalkenApiClient14();
6042
+ const api = getTalkenApiClient13();
5916
6043
  if (!api) {
5917
6044
  throw new AbcError(
5918
6045
  "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
@@ -5936,7 +6063,7 @@ async function generateMpcWallets(hashedPin, email) {
5936
6063
  }
5937
6064
  }
5938
6065
  async function recoverMpcWallets(hashedPin, email) {
5939
- const api = getTalkenApiClient14();
6066
+ const api = getTalkenApiClient13();
5940
6067
  if (!api) {
5941
6068
  throw new AbcError(
5942
6069
  "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
@@ -6038,8 +6165,6 @@ export {
6038
6165
  createAbcProvider,
6039
6166
  TalkenApiClient,
6040
6167
  createTalkenApiClient,
6041
- setTalkenApiClient,
6042
- getTalkenApiClient2 as getTalkenApiClient,
6043
6168
  SolanaNetwork,
6044
6169
  BitcoinNetwork,
6045
6170
  TronNetwork,