@talken/talkenkit 2.5.2 → 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-HRNBHY5Q.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-VCQZZ6SN.js → chunk-WPRIYR63.js} +192 -80
  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 +31 -31
  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-NP5PWUVU.js → chunk-BHEVY4QY.js} +2 -48
  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-MIX4TRKO.js → chunk-CABLJOMU.js} +1 -1
  63. package/dist/wallets/walletConnectors/{chunk-RX2VOIUB.js → chunk-DPTDOCWL.js} +1 -4
  64. package/dist/wallets/walletConnectors/{chunk-IPH3SIC3.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-JBOKTW2Q.js → chunk-FBJ5H6PM.js} +19 -79
  68. package/dist/wallets/walletConnectors/chunk-IM7DEERX.js +585 -0
  69. package/dist/wallets/walletConnectors/{chunk-ASYCOXE6.js → chunk-J3YPHDHM.js} +2 -48
  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-BRXYKYKT.js → chunk-NLA45GHJ.js} +17 -77
  75. package/dist/wallets/walletConnectors/{chunk-TVZHPWFR.js → chunk-NU3ITJNK.js} +736 -94
  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-2A5XTST5.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-WKP53WWR.js → chunk-VMCIDCO5.js} +4 -7
  84. package/dist/wallets/walletConnectors/{chunk-4PDTJS5L.js → chunk-VNL7XEWF.js} +4 -7
  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 +61 -61
  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,20 +3068,16 @@ 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}`;
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;
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;
2982
3080
  }
2983
- })() : null;
2984
- const effectiveAk = ak || tgAk;
2985
- if (effectiveAk) {
2986
- headers["X-Access-Key"] = effectiveAk;
2987
3081
  }
2988
3082
  }
2989
3083
  if (this.config.debug) {
@@ -3019,18 +3113,32 @@ var TalkenApiClient = class {
3019
3113
  } else {
3020
3114
  data = { success: true };
3021
3115
  }
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();
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
+ }
3028
3123
  throw new TalkenApiError(
3029
- "TOKEN_EXPIRED",
3030
- "Session expired. Please login again.",
3124
+ "ACCESS_KEY_EXPIRED",
3125
+ "Access key expired. Please login again.",
3031
3126
  401
3032
3127
  );
3033
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
+ }
3034
3142
  }
3035
3143
  if (!response.ok) {
3036
3144
  const errCode = data.error?.code || "UNKNOWN_ERROR";
@@ -3091,15 +3199,6 @@ function createTalkenApiClient(config) {
3091
3199
  return new TalkenApiClient(config);
3092
3200
  }
3093
3201
 
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
3202
  // src/wallets/walletConnectors/abcWallet/networkConfig.ts
3104
3203
  var SolanaNetwork = /* @__PURE__ */ ((SolanaNetwork2) => {
3105
3204
  SolanaNetwork2["Mainnet"] = "solana";
@@ -3207,16 +3306,24 @@ function abcConnector(options) {
3207
3306
  setGlobalDefaultBitcoinNetwork(config.defaultBitcoinNetwork);
3208
3307
  }
3209
3308
  return createConnector((wagmiConfig) => {
3210
- const talkenApi = getTalkenApiClient3() || createTalkenApiClient({
3309
+ const talkenApi = getTalkenApiClient2() || createTalkenApiClient({
3211
3310
  baseUrl: resolveTalkenApiUrl(config.talkenApiUrl),
3212
3311
  environment: config.environment,
3213
3312
  debug: config.environment === "development",
3214
3313
  defaultChainId: config.defaultChainId
3215
3314
  });
3216
3315
  setTalkenApiClient(talkenApi);
3217
- 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;
3218
3325
  const provider = isAccessKeyMode ? new AbcAccessKeyProvider(
3219
- config.accessKey,
3326
+ effectiveAccessKey,
3220
3327
  resolveTalkenApiUrl(config.talkenApiUrl)
3221
3328
  ) : createAbcEvmProvider(talkenApi);
3222
3329
  let accountsChangedHandler;
@@ -3244,7 +3351,7 @@ function abcConnector(options) {
3244
3351
  method: "POST",
3245
3352
  headers: {
3246
3353
  "Content-Type": "application/json",
3247
- "X-Access-Key": config.accessKey
3354
+ "X-Access-Key": effectiveAccessKey
3248
3355
  },
3249
3356
  body: JSON.stringify({ action: "info" })
3250
3357
  });
@@ -3375,6 +3482,10 @@ function abcConnector(options) {
3375
3482
  }
3376
3483
  provider.clearWallet();
3377
3484
  talkenApi.auth.logout();
3485
+ try {
3486
+ localStorage.removeItem("talken_api_access_key_raw");
3487
+ } catch {
3488
+ }
3378
3489
  clearAuthState();
3379
3490
  getCredentialManager().clear();
3380
3491
  },
@@ -3411,7 +3522,7 @@ function abcConnector(options) {
3411
3522
  if (isAccessKeyMode) {
3412
3523
  if (provider.isConnected())
3413
3524
  return true;
3414
- 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());
3415
3526
  const authState2 = loadAuthState();
3416
3527
  return hasKey && !!authState2?.wallet?.address;
3417
3528
  }
@@ -3425,6 +3536,9 @@ function abcConnector(options) {
3425
3536
  if (talkenApi.isAuthenticated()) {
3426
3537
  return true;
3427
3538
  }
3539
+ if (talkenApi.isAccessKeyMode()) {
3540
+ return true;
3541
+ }
3428
3542
  const refreshToken = loadFromStorage(
3429
3543
  "refresh_token" /* REFRESH_TOKEN */
3430
3544
  );
@@ -3433,7 +3547,7 @@ function abcConnector(options) {
3433
3547
  return false;
3434
3548
  }
3435
3549
  try {
3436
- const api = getTalkenApiClient3();
3550
+ const api = getTalkenApiClient2();
3437
3551
  if (!api) {
3438
3552
  clearStorage();
3439
3553
  return false;
@@ -3525,7 +3639,7 @@ var abcWallet = (specificOptions) => ({ projectId }) => {
3525
3639
  debug: specificOptions?.environment === "development"
3526
3640
  });
3527
3641
  setTalkenApiClient2(talkenApi);
3528
- const accessKey = specificOptions?.accessKey || (typeof localStorage !== "undefined" ? localStorage.getItem("talken_ak") : null) || null;
3642
+ const accessKey = specificOptions?.accessKey || loadTgAccessKey() || null;
3529
3643
  const config = {
3530
3644
  talkenApiUrl,
3531
3645
  apiKey: specificOptions?.apiKey,
@@ -3557,13 +3671,13 @@ var abcWallet = (specificOptions) => ({ projectId }) => {
3557
3671
  };
3558
3672
 
3559
3673
  // src/wallets/walletConnectors/abcWallet/api/WalletscanApi.ts
3560
- import { getTalkenApiClient as getTalkenApiClient5, networkNameToChainKey as networkNameToChainKey2 } from "@talken/talkenkit";
3674
+ import { getTalkenApiClient as getTalkenApiClient4, networkNameToChainKey as networkNameToChainKey2 } from "@talken/talkenkit";
3561
3675
 
3562
3676
  // src/wallets/walletConnectors/abcWallet/api/TokenApi.ts
3563
- import { getTalkenApiClient as getTalkenApiClient4 } from "@talken/talkenkit";
3677
+ import { getTalkenApiClient as getTalkenApiClient3 } from "@talken/talkenkit";
3564
3678
  var TokenApi = class {
3565
3679
  async getBalances(address, chainKey) {
3566
- const api = getTalkenApiClient4();
3680
+ const api = getTalkenApiClient3();
3567
3681
  if (!api)
3568
3682
  throw new Error("TalkenApiClient not initialized");
3569
3683
  const query = new URLSearchParams({ address, chainKey }).toString();
@@ -3590,7 +3704,7 @@ var WalletscanApi = class {
3590
3704
  * Get all wallet tokens with balances via TalkenApiClient walletscan endpoint
3591
3705
  */
3592
3706
  async getWalletTokens(params) {
3593
- const api = getTalkenApiClient5();
3707
+ const api = getTalkenApiClient4();
3594
3708
  if (!api)
3595
3709
  throw new Error("TalkenApiClient not initialized");
3596
3710
  try {
@@ -3650,7 +3764,7 @@ var WalletscanApi = class {
3650
3764
  * @returns Token metadata or null if not found/failed
3651
3765
  */
3652
3766
  async getContractToken(params) {
3653
- const api = getTalkenApiClient5();
3767
+ const api = getTalkenApiClient4();
3654
3768
  if (!api)
3655
3769
  throw new Error("TalkenApiClient not initialized");
3656
3770
  try {
@@ -3699,7 +3813,7 @@ var WalletscanApi = class {
3699
3813
  * @returns Array of native coins or empty array if failed
3700
3814
  */
3701
3815
  async getNativeToken(params) {
3702
- const api = getTalkenApiClient5();
3816
+ const api = getTalkenApiClient4();
3703
3817
  if (!api)
3704
3818
  throw new Error("TalkenApiClient not initialized");
3705
3819
  const chainKey = networkNameToChainKey2(params.networks);
@@ -3770,7 +3884,7 @@ var WalletscanApi = class {
3770
3884
  * @returns Array of NFT metadata or empty array if failed
3771
3885
  */
3772
3886
  async getNFT(params) {
3773
- const api = getTalkenApiClient5();
3887
+ const api = getTalkenApiClient4();
3774
3888
  if (!api)
3775
3889
  throw new Error("TalkenApiClient not initialized");
3776
3890
  try {
@@ -3814,7 +3928,7 @@ var WalletscanApi = class {
3814
3928
  };
3815
3929
 
3816
3930
  // src/wallets/walletConnectors/abcWallet/api/GasApi.ts
3817
- import { getTalkenApiClient as getTalkenApiClient6 } from "@talken/talkenkit";
3931
+ import { getTalkenApiClient as getTalkenApiClient5 } from "@talken/talkenkit";
3818
3932
  var GasApi = class {
3819
3933
  parseGasFees(data) {
3820
3934
  return {
@@ -3829,7 +3943,7 @@ var GasApi = class {
3829
3943
  * @returns Suggested gas fees or null if failed
3830
3944
  */
3831
3945
  async getSuggestedGasFees(network) {
3832
- const api = getTalkenApiClient6();
3946
+ const api = getTalkenApiClient5();
3833
3947
  if (!api)
3834
3948
  throw new Error("TalkenApiClient not initialized");
3835
3949
  try {
@@ -3851,7 +3965,7 @@ var GasApi = class {
3851
3965
  * @returns Gas limit (hex string) or null if failed
3852
3966
  */
3853
3967
  async estimateGas(params) {
3854
- const api = getTalkenApiClient6();
3968
+ const api = getTalkenApiClient5();
3855
3969
  if (!api)
3856
3970
  throw new Error("TalkenApiClient not initialized");
3857
3971
  try {
@@ -3913,7 +4027,7 @@ var GasApi = class {
3913
4027
  };
3914
4028
 
3915
4029
  // src/wallets/walletConnectors/abcWallet/api/ConfigApi.ts
3916
- import { getTalkenApiClient as getTalkenApiClient7 } from "@talken/talkenkit";
4030
+ import { getTalkenApiClient as getTalkenApiClient6 } from "@talken/talkenkit";
3917
4031
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
3918
4032
  var toStatusCode = (status) => {
3919
4033
  if (typeof status === "number")
@@ -3931,7 +4045,7 @@ var toStatusCode = (status) => {
3931
4045
  };
3932
4046
  var ConfigApi = class {
3933
4047
  async getTxStatus(chainKey, txHash) {
3934
- const api = getTalkenApiClient7();
4048
+ const api = getTalkenApiClient6();
3935
4049
  if (!api)
3936
4050
  throw new Error("TalkenApiClient not initialized");
3937
4051
  return api.get(
@@ -3957,16 +4071,16 @@ var ConfigApi = class {
3957
4071
  };
3958
4072
 
3959
4073
  // src/wallets/walletConnectors/abcWallet/api/SolanaApi.ts
3960
- import { getTalkenApiClient as getTalkenApiClient8 } from "@talken/talkenkit";
4074
+ import { getTalkenApiClient as getTalkenApiClient7 } from "@talken/talkenkit";
3961
4075
  var SolanaApi = class {
3962
4076
  async getLatestBlockhash(network) {
3963
- const api = getTalkenApiClient8();
4077
+ const api = getTalkenApiClient7();
3964
4078
  if (!api)
3965
4079
  throw new Error("TalkenApiClient not initialized");
3966
4080
  return api.solana.getLatestBlockhash(network);
3967
4081
  }
3968
4082
  async getTransactionStatus(params) {
3969
- const api = getTalkenApiClient8();
4083
+ const api = getTalkenApiClient7();
3970
4084
  if (!api)
3971
4085
  throw new Error("TalkenApiClient not initialized");
3972
4086
  return api.solana.getTransactionStatus(params);
@@ -3991,7 +4105,7 @@ var SolanaApi = class {
3991
4105
  };
3992
4106
 
3993
4107
  // src/wallets/walletConnectors/abcWallet/sessionUtils.ts
3994
- import { getTalkenApiClient as getTalkenApiClient9 } from "@talken/talkenkit";
4108
+ import { getTalkenApiClient as getTalkenApiClient8 } from "@talken/talkenkit";
3995
4109
  var SessionExpiredError = class extends Error {
3996
4110
  constructor(message = "Session expired. Please reconnect your wallet.") {
3997
4111
  super(message);
@@ -4029,7 +4143,7 @@ async function refreshAccessToken(pinCallback) {
4029
4143
  if (pinCallback) {
4030
4144
  await pinCallback();
4031
4145
  }
4032
- const api = getTalkenApiClient9();
4146
+ const api = getTalkenApiClient8();
4033
4147
  if (!api) {
4034
4148
  console.warn(
4035
4149
  "[SessionUtils] TalkenApiClient not initialized - opening connect modal"
@@ -4075,7 +4189,7 @@ async function refreshAccessToken(pinCallback) {
4075
4189
  }
4076
4190
 
4077
4191
  // src/wallets/walletConnectors/abcWallet/abcBitcoinProvider.ts
4078
- import { getTalkenApiClient as getTalkenApiClient10 } from "@talken/talkenkit";
4192
+ import { getTalkenApiClient as getTalkenApiClient9 } from "@talken/talkenkit";
4079
4193
  function isTalkenApiClient(client) {
4080
4194
  return typeof client?.bitcoin?.getUtxos === "function";
4081
4195
  }
@@ -4346,7 +4460,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4346
4460
  }
4347
4461
  try {
4348
4462
  console.log("[BitcoinProvider] \u{1F50D} Fetching UTXOs from network...");
4349
- const api = this.talkenApi || getTalkenApiClient10();
4463
+ const api = this.talkenApi || getTalkenApiClient9();
4350
4464
  const result = await api.bitcoin.getUtxos(this.network.type, address);
4351
4465
  const utxos = this.normalizeUtxos(result.utxos || []);
4352
4466
  this.utxoCache.set(address, utxos);
@@ -4383,7 +4497,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4383
4497
  */
4384
4498
  async estimateFee(targetBlocks = 6) {
4385
4499
  try {
4386
- const api = this.talkenApi || getTalkenApiClient10();
4500
+ const api = this.talkenApi || getTalkenApiClient9();
4387
4501
  const result = await api.bitcoin.getFeeRate(
4388
4502
  this.network.type,
4389
4503
  targetBlocks
@@ -4436,7 +4550,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4436
4550
  const hash1 = await crypto.subtle.digest("SHA-256", preimage);
4437
4551
  const hash2 = await crypto.subtle.digest("SHA-256", hash1);
4438
4552
  const hashHex = Array.from(new Uint8Array(hash2)).map((b) => b.toString(16).padStart(2, "0")).join("");
4439
- const api = getTalkenApiClient10();
4553
+ const api = getTalkenApiClient9();
4440
4554
  if (!api) {
4441
4555
  throw new BitcoinProviderError(
4442
4556
  BitcoinErrorCode.INTERNAL_ERROR,
@@ -4547,7 +4661,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4547
4661
  }
4548
4662
  const email = this.getRecoveryEmail();
4549
4663
  const satoshis = Math.floor(params.amount * 1e8);
4550
- const api = this.talkenApi || getTalkenApiClient10();
4664
+ const api = this.talkenApi || getTalkenApiClient9();
4551
4665
  const result = await api.bitcoin.sendTransaction({
4552
4666
  toAddress: params.toAddress,
4553
4667
  amountSats: satoshis.toString(),
@@ -4610,7 +4724,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4610
4724
  "[BitcoinProvider] \u2139\uFE0F PSBT argument provided; raw tx broadcast uses rawTransaction only via talken-api"
4611
4725
  );
4612
4726
  }
4613
- const api = this.talkenApi || getTalkenApiClient10();
4727
+ const api = this.talkenApi || getTalkenApiClient9();
4614
4728
  const result = await api.bitcoin.broadcastRawTransaction({
4615
4729
  network: this.network.type,
4616
4730
  rawTransaction
@@ -4660,7 +4774,7 @@ var AbcBitcoinProvider = class extends EventEmitter3 {
4660
4774
  };
4661
4775
 
4662
4776
  // src/wallets/walletConnectors/abcWallet/abcBitcoinConnector.ts
4663
- import { getTalkenApiClient as getTalkenApiClient11 } from "@talken/talkenkit";
4777
+ import { getTalkenApiClient as getTalkenApiClient10 } from "@talken/talkenkit";
4664
4778
  var AbcBitcoinConnector = class {
4665
4779
  constructor(config) {
4666
4780
  this.wallet = null;
@@ -4822,7 +4936,7 @@ var AbcBitcoinConnector = class {
4822
4936
  if (!authState.bitcoinWallet) {
4823
4937
  return false;
4824
4938
  }
4825
- const api = getTalkenApiClient11();
4939
+ const api = getTalkenApiClient10();
4826
4940
  return !!api && !api.isTokenExpired();
4827
4941
  } catch {
4828
4942
  return false;
@@ -4925,7 +5039,7 @@ function createAbcBitcoinConnector(config) {
4925
5039
  // src/wallets/walletConnectors/abcWallet/abcSolanaProvider.ts
4926
5040
  import {
4927
5041
  getShowPendingTransaction as getShowPendingTransaction2,
4928
- getTalkenApiClient as getTalkenApiClient12,
5042
+ getTalkenApiClient as getTalkenApiClient11,
4929
5043
  getUpdateTransactionResult as getUpdateTransactionResult2
4930
5044
  } from "@talken/talkenkit";
4931
5045
 
@@ -5059,7 +5173,7 @@ var AbcSolanaProvider = class extends EventEmitter4 {
5059
5173
  this.talkenApi = talkenApi;
5060
5174
  }
5061
5175
  getTalkenApiClientOrThrow() {
5062
- const api = this.talkenApi || getTalkenApiClient12();
5176
+ const api = this.talkenApi || getTalkenApiClient11();
5063
5177
  if (!api) {
5064
5178
  throw new SolanaProviderError(
5065
5179
  SolanaErrorCode.INTERNAL_ERROR,
@@ -5412,7 +5526,7 @@ var AbcSolanaProvider = class extends EventEmitter4 {
5412
5526
  // src/wallets/walletConnectors/abcWallet/abcTronProvider.ts
5413
5527
  import {
5414
5528
  getShowPendingTransaction as getShowPendingTransaction3,
5415
- getTalkenApiClient as getTalkenApiClient13,
5529
+ getTalkenApiClient as getTalkenApiClient12,
5416
5530
  getUpdateTransactionResult as getUpdateTransactionResult3
5417
5531
  } from "@talken/talkenkit";
5418
5532
  import { keccak256 } from "viem";
@@ -5564,7 +5678,7 @@ var AbcTronProvider = class extends EventEmitter5 {
5564
5678
  if (cached)
5565
5679
  return cached;
5566
5680
  try {
5567
- const api = this.talkenApi || getTalkenApiClient13();
5681
+ const api = this.talkenApi || getTalkenApiClient12();
5568
5682
  const chainKeys = this.network.type === "tron_nile" ? "tronNile" : "tron";
5569
5683
  let tokens;
5570
5684
  if (contractAddress) {
@@ -5651,7 +5765,7 @@ ${msgBytes.length}`
5651
5765
  const hash = keccak256(prefixed);
5652
5766
  const pinHash = getCredentialManager().getPinHash() || void 0;
5653
5767
  const email = getCredentialManager().getEmail() || void 0;
5654
- const api = this.talkenApi || getTalkenApiClient13();
5768
+ const api = this.talkenApi || getTalkenApiClient12();
5655
5769
  const result = await api.bitcoin.signHash({
5656
5770
  hash: hash.startsWith("0x") ? hash.slice(2) : hash,
5657
5771
  pin: pinHash || "",
@@ -5728,7 +5842,7 @@ ${msgBytes.length}`
5728
5842
  );
5729
5843
  }
5730
5844
  const email = getCredentialManager().getEmail() || void 0;
5731
- const api = this.talkenApi || getTalkenApiClient13();
5845
+ const api = this.talkenApi || getTalkenApiClient12();
5732
5846
  const request = txType === "NATIVE" ? {
5733
5847
  kind: "native",
5734
5848
  network: this.network.type,
@@ -5836,7 +5950,7 @@ ${msgBytes.length}`
5836
5950
  };
5837
5951
 
5838
5952
  // src/wallets/walletConnectors/abcWallet/walletGeneration.ts
5839
- import { getTalkenApiClient as getTalkenApiClient14 } from "@talken/talkenkit";
5953
+ import { getTalkenApiClient as getTalkenApiClient13 } from "@talken/talkenkit";
5840
5954
  async function mapApiResponseToWallets(genResponse, infoResponse, email) {
5841
5955
  const accounts = infoResponse?.accounts || [];
5842
5956
  const evmAccount = accounts[0] || infoResponse || {};
@@ -5851,7 +5965,7 @@ async function mapApiResponseToWallets(genResponse, infoResponse, email) {
5851
5965
  let trxAddress = genResponse.trxAddress || "";
5852
5966
  if ((!btcAddress || !trxAddress) && pubkey) {
5853
5967
  try {
5854
- const api = getTalkenApiClient14();
5968
+ const api = getTalkenApiClient13();
5855
5969
  if (api) {
5856
5970
  const addrResponse = await api.wallet.getAddressForChain("all");
5857
5971
  if (!btcAddress)
@@ -5925,7 +6039,7 @@ async function mapApiResponseToWallets(genResponse, infoResponse, email) {
5925
6039
  return { evmWallet, solanaWallet, bitcoinWallet, tronWallet };
5926
6040
  }
5927
6041
  async function generateMpcWallets(hashedPin, email) {
5928
- const api = getTalkenApiClient14();
6042
+ const api = getTalkenApiClient13();
5929
6043
  if (!api) {
5930
6044
  throw new AbcError(
5931
6045
  "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
@@ -5949,7 +6063,7 @@ async function generateMpcWallets(hashedPin, email) {
5949
6063
  }
5950
6064
  }
5951
6065
  async function recoverMpcWallets(hashedPin, email) {
5952
- const api = getTalkenApiClient14();
6066
+ const api = getTalkenApiClient13();
5953
6067
  if (!api) {
5954
6068
  throw new AbcError(
5955
6069
  "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */,
@@ -6051,8 +6165,6 @@ export {
6051
6165
  createAbcProvider,
6052
6166
  TalkenApiClient,
6053
6167
  createTalkenApiClient,
6054
- setTalkenApiClient,
6055
- getTalkenApiClient2 as getTalkenApiClient,
6056
6168
  SolanaNetwork,
6057
6169
  BitcoinNetwork,
6058
6170
  TronNetwork,