@talken/talkenkit 2.8.1 → 2.8.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 (40) hide show
  1. package/dist/{abcWallet-TMP56C3B.js → abcWallet-7ZZXHG7O.js} +1 -1
  2. package/dist/{chunk-WEQ3DKBC.js → chunk-HX6JUKSS.js} +0 -6
  3. package/dist/gasless/types.d.ts +33 -2
  4. package/dist/gasless/utils/fiatFormatter.d.ts +32 -0
  5. package/dist/index.css +13 -13
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.js +341 -211
  8. package/dist/wallets/walletConnectors/abcWallet/abcConnector.js +4 -4
  9. package/dist/wallets/walletConnectors/abcWallet/abcProvider.js +1 -1
  10. package/dist/wallets/walletConnectors/abcWallet/abcSolanaProvider.js +2 -2
  11. package/dist/wallets/walletConnectors/abcWallet/abcWallet.js +5 -5
  12. package/dist/wallets/walletConnectors/abcWallet/api/TalkenApiClient.js +2 -2
  13. package/dist/wallets/walletConnectors/abcWallet/api/index.js +2 -2
  14. package/dist/wallets/walletConnectors/abcWallet/index.js +8 -8
  15. package/dist/wallets/walletConnectors/abcWallet/kakaoAuth.d.ts +10 -21
  16. package/dist/wallets/walletConnectors/abcWallet/kakaoAuth.js +118 -141
  17. package/dist/wallets/walletConnectors/chunk-4K2V7RCL.js +96 -0
  18. package/dist/wallets/walletConnectors/chunk-76M232IF.js +101 -0
  19. package/dist/wallets/walletConnectors/{chunk-73ENA2TK.js → chunk-7DLZKN46.js} +1 -1
  20. package/dist/wallets/walletConnectors/chunk-CTAFZ5RQ.js +71 -0
  21. package/dist/wallets/walletConnectors/chunk-FE2BFYJB.js +73 -0
  22. package/dist/wallets/walletConnectors/chunk-GNF5CHDQ.js +102 -0
  23. package/dist/wallets/walletConnectors/chunk-GZPGNUNF.js +94 -0
  24. package/dist/wallets/walletConnectors/{chunk-DKWXI7IR.js → chunk-HM73RD2O.js} +0 -6
  25. package/dist/wallets/walletConnectors/chunk-KNNHGFKJ.js +98 -0
  26. package/dist/wallets/walletConnectors/chunk-KQROIRBW.js +27 -0
  27. package/dist/wallets/walletConnectors/chunk-LKNK2KKU.js +76 -0
  28. package/dist/wallets/walletConnectors/{chunk-R3SLVZUQ.js → chunk-M4YGDOD5.js} +1 -1
  29. package/dist/wallets/walletConnectors/chunk-NM7YUGLV.js +186 -0
  30. package/dist/wallets/walletConnectors/chunk-U5UPCM5V.js +66 -0
  31. package/dist/wallets/walletConnectors/chunk-WZMFQQ6R.js +108 -0
  32. package/dist/wallets/walletConnectors/chunk-XSJUQHR7.js +95 -0
  33. package/dist/wallets/walletConnectors/index.js +56 -56
  34. package/package.json +12 -11
  35. package/LICENSE +0 -9
  36. package/dist/wallets/walletConnectors/chunk-24AEUYOZ.js +0 -58
  37. package/dist/wallets/walletConnectors/chunk-2DROHKQL.js +0 -341
  38. package/dist/wallets/walletConnectors/chunk-I7QLXYSA.js +0 -341
  39. package/dist/wallets/walletConnectors/chunk-L7ZETI2T.js +0 -58
  40. package/dist/wallets/walletConnectors/chunk-PYIAXFRD.js +0 -370
@@ -1,14 +1,14 @@
1
1
  "use client";
2
2
  import {
3
3
  abcConnector
4
- } from "../chunk-2DROHKQL.js";
5
- import "../chunk-DKWXI7IR.js";
6
- import "../chunk-PYIAXFRD.js";
4
+ } from "../chunk-7DLZKN46.js";
5
+ import "../chunk-HM73RD2O.js";
6
+ import "../chunk-CXWASK7L.js";
7
7
  import "../chunk-XDNFWX2X.js";
8
8
  import "../chunk-4Y7YP4IR.js";
9
9
  import "../chunk-ICGK5DGY.js";
10
- import "../chunk-TYJR3KGY.js";
11
10
  import "../chunk-3NWM24MH.js";
11
+ import "../chunk-TYJR3KGY.js";
12
12
  import "../chunk-2LOET2LX.js";
13
13
  import "../chunk-2LH53QET.js";
14
14
  import "../chunk-ZOBSRU6L.js";
@@ -3,7 +3,7 @@ import {
3
3
  AbcEvmProvider,
4
4
  createAbcEvmProvider,
5
5
  createAbcProvider
6
- } from "../chunk-DKWXI7IR.js";
6
+ } from "../chunk-HM73RD2O.js";
7
7
  import "../chunk-YNE2UX2Z.js";
8
8
  import "../chunk-3DHUDD4U.js";
9
9
  import "../chunk-R6ZE7JAZ.js";
@@ -8,12 +8,12 @@ import "../chunk-2OHHFQQ7.js";
8
8
  import "../chunk-OTLZVWY7.js";
9
9
  import "../chunk-S6XEM7RM.js";
10
10
  import "../chunk-FWX2HD26.js";
11
- import "../chunk-PYIAXFRD.js";
11
+ import "../chunk-CXWASK7L.js";
12
12
  import "../chunk-XDNFWX2X.js";
13
13
  import "../chunk-4Y7YP4IR.js";
14
14
  import "../chunk-ICGK5DGY.js";
15
- import "../chunk-TYJR3KGY.js";
16
15
  import "../chunk-3NWM24MH.js";
16
+ import "../chunk-TYJR3KGY.js";
17
17
  import "../chunk-2LOET2LX.js";
18
18
  import "../chunk-2LH53QET.js";
19
19
  import "../chunk-ZOBSRU6L.js";
@@ -1,15 +1,15 @@
1
1
  "use client";
2
2
  import {
3
3
  abcWallet
4
- } from "../chunk-24AEUYOZ.js";
5
- import "../chunk-2DROHKQL.js";
6
- import "../chunk-DKWXI7IR.js";
7
- import "../chunk-PYIAXFRD.js";
4
+ } from "../chunk-M4YGDOD5.js";
5
+ import "../chunk-7DLZKN46.js";
6
+ import "../chunk-HM73RD2O.js";
7
+ import "../chunk-CXWASK7L.js";
8
8
  import "../chunk-XDNFWX2X.js";
9
9
  import "../chunk-4Y7YP4IR.js";
10
10
  import "../chunk-ICGK5DGY.js";
11
- import "../chunk-TYJR3KGY.js";
12
11
  import "../chunk-3NWM24MH.js";
12
+ import "../chunk-TYJR3KGY.js";
13
13
  import "../chunk-2LOET2LX.js";
14
14
  import "../chunk-2LH53QET.js";
15
15
  import "../chunk-ZOBSRU6L.js";
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  TalkenApiClient,
4
4
  createTalkenApiClient
5
- } from "../../chunk-PYIAXFRD.js";
5
+ } from "../../chunk-CXWASK7L.js";
6
6
  import "../../chunk-XDNFWX2X.js";
7
7
  import "../../chunk-4Y7YP4IR.js";
8
8
  import "../../chunk-ICGK5DGY.js";
9
- import "../../chunk-TYJR3KGY.js";
10
9
  import "../../chunk-3NWM24MH.js";
10
+ import "../../chunk-TYJR3KGY.js";
11
11
  import "../../chunk-2LOET2LX.js";
12
12
  import "../../chunk-2LH53QET.js";
13
13
  import "../../chunk-ZOBSRU6L.js";
@@ -18,12 +18,12 @@ import {
18
18
  import {
19
19
  TalkenApiClient,
20
20
  createTalkenApiClient
21
- } from "../../chunk-PYIAXFRD.js";
21
+ } from "../../chunk-CXWASK7L.js";
22
22
  import "../../chunk-XDNFWX2X.js";
23
23
  import "../../chunk-4Y7YP4IR.js";
24
24
  import "../../chunk-ICGK5DGY.js";
25
- import "../../chunk-TYJR3KGY.js";
26
25
  import "../../chunk-3NWM24MH.js";
26
+ import "../../chunk-TYJR3KGY.js";
27
27
  import "../../chunk-2LOET2LX.js";
28
28
  import "../../chunk-2LH53QET.js";
29
29
  import "../../chunk-ZOBSRU6L.js";
@@ -39,13 +39,13 @@ import {
39
39
  import {
40
40
  TokenApi
41
41
  } from "../chunk-FWX2HD26.js";
42
- import {
43
- hashPin
44
- } from "../chunk-OSTBVN45.js";
45
42
  import {
46
43
  AbcTronProvider,
47
44
  TRON_NETWORKS
48
45
  } from "../chunk-4BG6V5TZ.js";
46
+ import {
47
+ hashPin
48
+ } from "../chunk-OSTBVN45.js";
49
49
  import {
50
50
  AbcXrplProvider,
51
51
  XRPL_NETWORKS
@@ -56,24 +56,24 @@ import {
56
56
  } from "../chunk-4DGLNUHL.js";
57
57
  import {
58
58
  abcWallet
59
- } from "../chunk-24AEUYOZ.js";
59
+ } from "../chunk-M4YGDOD5.js";
60
60
  import {
61
61
  abcConnector
62
- } from "../chunk-2DROHKQL.js";
62
+ } from "../chunk-7DLZKN46.js";
63
63
  import {
64
64
  AbcEvmProvider,
65
65
  createAbcEvmProvider,
66
66
  createAbcProvider
67
- } from "../chunk-DKWXI7IR.js";
67
+ } from "../chunk-HM73RD2O.js";
68
68
  import {
69
69
  TalkenApiClient,
70
70
  createTalkenApiClient
71
- } from "../chunk-PYIAXFRD.js";
71
+ } from "../chunk-CXWASK7L.js";
72
72
  import "../chunk-XDNFWX2X.js";
73
73
  import "../chunk-4Y7YP4IR.js";
74
74
  import "../chunk-ICGK5DGY.js";
75
- import "../chunk-TYJR3KGY.js";
76
75
  import "../chunk-3NWM24MH.js";
76
+ import "../chunk-TYJR3KGY.js";
77
77
  import "../chunk-2LOET2LX.js";
78
78
  import "../chunk-2LH53QET.js";
79
79
  import "../chunk-ZOBSRU6L.js";
@@ -1,27 +1,16 @@
1
- /**
2
- * Kakao OAuth Authentication Handler (Pure REST + OIDC)
3
- *
4
- * No Kakao JS SDK dependency. All API calls use REST endpoints:
5
- * - kauth.kakao.com/oauth/authorize (auth code via popup, scope: openid,account_email)
6
- * - kauth.kakao.com/oauth/token (code → access_token + id_token)
7
- *
8
- * Email is extracted from id_token (JWT) — no /v2/user/me call needed.
9
- * ABC WaaS snsLogin receives the id_token.
10
- */
1
+ /** Kakao code exchange is performed by the host's same-origin server. */
11
2
  export interface KakaoAuthResult {
12
3
  email: string;
13
4
  idToken: string;
14
5
  service: 'kakao';
15
6
  }
16
- /**
17
- * Perform Kakao OAuth login (Pure REST + OIDC, popup-based)
18
- *
19
- * Flow:
20
- * 1. Check stored token validity → reuse if valid
21
- * 2. Open popup → authorize with openid,account_email scope
22
- * 3. Exchange code for access_token + id_token
23
- * 4. Decode id_token (JWT) to extract email
24
- * 5. Store tokens in sessionStorage
25
- * 6. Return { email, idToken (JWT), service: 'kakao' }
26
- */
7
+ export interface KakaoAuthConfig {
8
+ /** Root-relative endpoint implementing POST /start/ and POST /exchange/. */
9
+ serverEndpoint: string;
10
+ /** Exact final popup path if the host canonicalizes its registered redirect. */
11
+ callbackPath?: string;
12
+ }
13
+ /** Configure before rendering TalkenKit. The endpoint cannot be cross-origin. */
14
+ export declare function configureKakaoAuth(config: KakaoAuthConfig): void;
15
+ /** Returns the existing SNS login credential without persisting provider tokens. */
27
16
  export declare function kakaoLogin(): Promise<KakaoAuthResult | null>;
@@ -1,49 +1,61 @@
1
1
  "use client";
2
- import {
3
- createLogger
4
- } from "../chunk-2DFJ6LEN.js";
5
2
 
6
3
  // src/wallets/walletConnectors/abcWallet/kakaoAuth.ts
7
- var logger = createLogger("KakaoAuth");
8
- var KAKAO_TOKEN_KEY = "kakao_access_token";
9
- var KAKAO_ID_TOKEN_KEY = "kakao_id_token";
10
- var KAKAO_EMAIL_KEY = "kakao_email";
11
- var KAKAO_EXPIRES_AT_KEY = "kakao_expires_at";
4
+ var POPUP_TIMEOUT_MS = 3 * 60 * 1e3;
5
+ var REQUEST_TIMEOUT_MS = 15 * 1e3;
6
+ var serverEndpoint;
7
+ var configuredCallbackPath;
12
8
  var isKakaoLoginInProgress = false;
13
- function decodeJwtPayload(jwt) {
14
- const parts = jwt.split(".");
15
- if (parts.length !== 3) {
16
- throw new Error("Invalid JWT format");
9
+ function configureKakaoAuth(config) {
10
+ const endpoint = config.serverEndpoint.replace(/\/$/, "");
11
+ if (!/^\/(?:[a-zA-Z0-9_-]+\/)*[a-zA-Z0-9_-]+$/.test(endpoint)) {
12
+ throw new Error("Kakao serverEndpoint must be a root-relative path");
17
13
  }
18
- const payload = parts[1];
19
- const decoded = atob(payload.replace(/-/g, "+").replace(/_/g, "/"));
20
- return JSON.parse(decoded);
14
+ if (config.callbackPath !== void 0 && (config.callbackPath.length > 256 || !/^\/(?:[a-zA-Z0-9_-]+\/)*[a-zA-Z0-9_-]+\/?$/.test(config.callbackPath))) {
15
+ throw new Error("Kakao callbackPath must be a root-relative path");
16
+ }
17
+ serverEndpoint = endpoint;
18
+ configuredCallbackPath = config.callbackPath;
21
19
  }
22
- function getAuthCodeViaPopup(redirectUri) {
23
- return new Promise((resolve, reject) => {
24
- const restApiKey = process.env.NEXT_PUBLIC_KAKAO_REST_API_KEY;
25
- if (!restApiKey) {
26
- reject(new Error("NEXT_PUBLIC_KAKAO_REST_API_KEY is not configured"));
27
- return;
28
- }
29
- const authUrl = `https://kauth.kakao.com/oauth/authorize?client_id=${restApiKey}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=openid,account_email`;
30
- const popup = window.open(
31
- authUrl,
32
- "kakao_login",
33
- "width=500,height=700,scrollbars=yes"
34
- );
35
- if (!popup) {
36
- reject(
37
- new Error(
38
- "Popup blocked by browser. Please allow popups and try again."
39
- )
40
- );
41
- return;
20
+ async function requestServer(endpoint, action, body) {
21
+ const controller = new AbortController();
22
+ const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
23
+ try {
24
+ const response = await fetch(`${endpoint}/${action}/`, {
25
+ method: "POST",
26
+ credentials: "same-origin",
27
+ cache: "no-store",
28
+ redirect: "error",
29
+ headers: { "Content-Type": "application/json" },
30
+ body: JSON.stringify(body),
31
+ signal: controller.signal
32
+ });
33
+ if (!response.ok)
34
+ throw new Error("Kakao authentication failed. Please try again.");
35
+ const data = await response.json();
36
+ if (!data || typeof data !== "object" || Array.isArray(data)) {
37
+ throw new Error("Invalid Kakao server response");
42
38
  }
43
- const POPUP_TIMEOUT = 3 * 60 * 1e3;
39
+ return data;
40
+ } finally {
41
+ clearTimeout(timeout);
42
+ }
43
+ }
44
+ function getAuthCodeViaPopup(popup, authorizationUrl, redirectUri, state, callbackPath) {
45
+ const redirect = new URL(redirectUri);
46
+ const expectedCallback = new URL(
47
+ callbackPath ?? redirect.pathname,
48
+ window.location.origin
49
+ );
50
+ const authorize = new URL(authorizationUrl);
51
+ if (redirect.protocol !== "https:" || redirect.origin !== window.location.origin || redirect.username || redirect.password || redirect.search || redirect.hash || authorize.origin !== "https://kauth.kakao.com" || authorize.pathname !== "/oauth/authorize" || authorize.searchParams.get("state") !== state || authorize.searchParams.get("redirect_uri") !== redirectUri) {
52
+ throw new Error("Invalid Kakao authorization configuration");
53
+ }
54
+ popup.location.href = authorizationUrl;
55
+ return new Promise((resolve, reject) => {
44
56
  const startTime = Date.now();
45
57
  const timer = setInterval(() => {
46
- if (Date.now() - startTime > POPUP_TIMEOUT) {
58
+ if (Date.now() - startTime >= POPUP_TIMEOUT_MS) {
47
59
  clearInterval(timer);
48
60
  popup.close();
49
61
  reject(new Error("KAKAO_TIMEOUT"));
@@ -54,129 +66,94 @@ function getAuthCodeViaPopup(redirectUri) {
54
66
  reject(new Error("KAKAO_CANCELLED"));
55
67
  return;
56
68
  }
69
+ let callback;
57
70
  try {
58
- if (popup.location.href?.startsWith(redirectUri)) {
59
- clearInterval(timer);
60
- const url = new URL(popup.location.href);
61
- const code = url.searchParams.get("code");
62
- const error = url.searchParams.get("error");
63
- popup.close();
64
- if (error) {
65
- reject(
66
- new Error(error === "access_denied" ? "KAKAO_CANCELLED" : error)
67
- );
68
- } else if (code) {
69
- resolve(code);
70
- } else {
71
- reject(new Error("No authorization code received"));
72
- }
73
- }
74
- } catch (_e) {
71
+ callback = new URL(popup.location.href);
72
+ } catch {
73
+ return;
74
+ }
75
+ if (callback.origin !== redirect.origin || callback.pathname !== expectedCallback.pathname)
76
+ return;
77
+ clearInterval(timer);
78
+ popup.close();
79
+ if (callback.searchParams.getAll("state").length !== 1 || callback.searchParams.get("state") !== state) {
80
+ reject(new Error("Invalid Kakao authorization state"));
81
+ } else if (callback.searchParams.has("error")) {
82
+ reject(
83
+ new Error(
84
+ callback.searchParams.get("error") === "access_denied" ? "KAKAO_CANCELLED" : "Kakao authorization failed"
85
+ )
86
+ );
87
+ } else if (callback.searchParams.getAll("code").length === 1 && callback.searchParams.get("code")) {
88
+ resolve(callback.searchParams.get("code"));
89
+ } else {
90
+ reject(new Error("No Kakao authorization code received"));
75
91
  }
76
92
  }, 500);
77
93
  });
78
94
  }
79
- async function exchangeCodeForTokens(code, redirectUri) {
80
- const restApiKey = process.env.NEXT_PUBLIC_KAKAO_REST_API_KEY;
81
- if (!restApiKey) {
82
- throw new Error("NEXT_PUBLIC_KAKAO_REST_API_KEY is not configured");
83
- }
84
- const response = await fetch("https://kauth.kakao.com/oauth/token", {
85
- method: "POST",
86
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
87
- body: new URLSearchParams({
88
- grant_type: "authorization_code",
89
- client_id: restApiKey,
90
- redirect_uri: redirectUri,
91
- code,
92
- ...process.env.NEXT_PUBLIC_KAKAO_CLIENT_SECRET ? { client_secret: process.env.NEXT_PUBLIC_KAKAO_CLIENT_SECRET } : {}
93
- })
94
- });
95
- if (!response.ok) {
96
- const err = await response.json().catch(() => ({}));
97
- throw new Error(err.error_description || "Failed to get access token");
98
- }
99
- const data = await response.json();
100
- if (!data.id_token) {
101
- throw new Error("No id_token received. Ensure openid scope is enabled.");
102
- }
103
- return {
104
- accessToken: data.access_token,
105
- idToken: data.id_token,
106
- expiresIn: data.expires_in || 21600
107
- };
108
- }
109
- function tryExistingToken() {
110
- const storedIdToken = sessionStorage.getItem(KAKAO_ID_TOKEN_KEY);
111
- const storedEmail = sessionStorage.getItem(KAKAO_EMAIL_KEY);
112
- const expiresAt = sessionStorage.getItem(KAKAO_EXPIRES_AT_KEY);
113
- if (!storedIdToken || !storedEmail || !expiresAt) {
114
- return null;
115
- }
116
- if (Date.now() >= Number(expiresAt)) {
117
- clearStoredTokens();
118
- return null;
119
- }
120
- return {
121
- email: storedEmail,
122
- idToken: storedIdToken,
123
- service: "kakao"
124
- };
125
- }
126
- function clearStoredTokens() {
127
- sessionStorage.removeItem(KAKAO_TOKEN_KEY);
128
- sessionStorage.removeItem(KAKAO_ID_TOKEN_KEY);
129
- sessionStorage.removeItem(KAKAO_EMAIL_KEY);
130
- sessionStorage.removeItem(KAKAO_EXPIRES_AT_KEY);
131
- }
132
95
  async function kakaoLogin() {
133
- if (isKakaoLoginInProgress) {
96
+ if (isKakaoLoginInProgress)
134
97
  return null;
135
- }
98
+ if (!serverEndpoint)
99
+ throw new Error(
100
+ "Configure a Kakao server authentication endpoint before login"
101
+ );
102
+ const endpoint = serverEndpoint;
103
+ const callbackPath = configuredCallbackPath;
136
104
  isKakaoLoginInProgress = true;
105
+ let popup = null;
137
106
  try {
138
- const existing = tryExistingToken();
139
- if (existing) {
140
- return existing;
141
- }
142
- const redirectUri = `${window.location.origin}/auth/kakao/callback`;
143
- const code = await getAuthCodeViaPopup(redirectUri);
144
- const { accessToken, idToken, expiresIn } = await exchangeCodeForTokens(
145
- code,
146
- redirectUri
107
+ popup = window.open(
108
+ "about:blank",
109
+ "kakao_login",
110
+ "width=500,height=700,scrollbars=yes"
147
111
  );
148
- const payload = decodeJwtPayload(idToken);
149
- const email = payload.email;
150
- if (!email) {
151
- throw new Error(
152
- "No email found in id_token. Please ensure email permission is granted."
153
- );
112
+ if (!popup)
113
+ throw new Error("KAKAO_POPUP_BLOCKED");
114
+ for (const key of [
115
+ "kakao_access_token",
116
+ "kakao_id_token",
117
+ "kakao_email",
118
+ "kakao_expires_at"
119
+ ]) {
120
+ try {
121
+ sessionStorage.removeItem(key);
122
+ } catch {
123
+ }
154
124
  }
155
- sessionStorage.setItem(KAKAO_TOKEN_KEY, accessToken);
156
- sessionStorage.setItem(KAKAO_ID_TOKEN_KEY, idToken);
157
- sessionStorage.setItem(KAKAO_EMAIL_KEY, email);
158
- sessionStorage.setItem(
159
- KAKAO_EXPIRES_AT_KEY,
160
- String(Date.now() + expiresIn * 1e3)
125
+ const start = await requestServer(endpoint, "start", {});
126
+ if (typeof start.authorizationUrl !== "string" || typeof start.redirectUri !== "string" || typeof start.state !== "string" || !/^[a-zA-Z0-9_-]{43}$/.test(start.state))
127
+ throw new Error("Invalid Kakao server response");
128
+ const code = await getAuthCodeViaPopup(
129
+ popup,
130
+ start.authorizationUrl,
131
+ start.redirectUri,
132
+ start.state,
133
+ callbackPath
161
134
  );
162
- return {
163
- email,
164
- idToken,
165
- service: "kakao"
166
- };
135
+ const result = await requestServer(endpoint, "exchange", {
136
+ code,
137
+ state: start.state
138
+ });
139
+ if (typeof result.email !== "string" || !result.email || result.email.length > 320 || typeof result.idToken !== "string" || result.idToken.length > 16 * 1024 || result.idToken.split(".").length !== 3)
140
+ throw new Error("Invalid Kakao server response");
141
+ return { email: result.email, idToken: result.idToken, service: "kakao" };
167
142
  } catch (error) {
168
- if (error?.message === "KAKAO_CANCELLED") {
143
+ if (error instanceof Error && error.message === "KAKAO_CANCELLED")
169
144
  return null;
170
- }
171
- if (error?.message === "KAKAO_TIMEOUT") {
145
+ if (error instanceof Error && error.message === "KAKAO_TIMEOUT")
172
146
  throw new Error("Login timed out. Please try again.");
173
- }
174
- logger.error("Kakao sign-in failed:", error.message || error);
175
- throw error;
147
+ if (error instanceof Error && error.message === "KAKAO_POPUP_BLOCKED")
148
+ throw new Error("Please allow popups and try again.");
149
+ throw new Error("Kakao authentication failed. Please try again.");
176
150
  } finally {
151
+ if (popup && !popup.closed)
152
+ popup.close();
177
153
  isKakaoLoginInProgress = false;
178
154
  }
179
155
  }
180
156
  export {
157
+ configureKakaoAuth,
181
158
  kakaoLogin
182
159
  };
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import {
3
+ getInjectedConnector,
4
+ hasInjectedProvider
5
+ } from "./chunk-PONHGUSY.js";
6
+ import {
7
+ isAndroid
8
+ } from "./chunk-RETKWSKD.js";
9
+ import {
10
+ getWalletConnectConnector
11
+ } from "./chunk-PODFK4OS.js";
12
+
13
+ // src/wallets/walletConnectors/okxWallet/okxWallet.ts
14
+ var okxWallet = ({
15
+ projectId,
16
+ walletConnectParameters
17
+ }) => {
18
+ const isOKXInjected = hasInjectedProvider({ namespace: "okxwallet" });
19
+ const shouldUseWalletConnect = !isOKXInjected;
20
+ return {
21
+ id: "okx",
22
+ name: "OKX Wallet",
23
+ rdns: "com.okex.wallet",
24
+ iconUrl: async () => (await import("./okxWallet-GJMKZIND.js")).default,
25
+ iconAccent: "#000",
26
+ iconBackground: "#000",
27
+ downloadUrls: {
28
+ android: "https://play.google.com/store/apps/details?id=com.okinc.okex.gp",
29
+ ios: "https://itunes.apple.com/app/id1327268470?mt=8",
30
+ mobile: "https://okx.com/download",
31
+ qrCode: "https://okx.com/download",
32
+ chrome: "https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge",
33
+ edge: "https://microsoftedge.microsoft.com/addons/detail/okx-wallet/pbpjkcldjiffchgbbndmhojiacbgflha",
34
+ firefox: "https://addons.mozilla.org/firefox/addon/okexwallet/",
35
+ browserExtension: "https://okx.com/download"
36
+ },
37
+ mobile: {
38
+ getUri: shouldUseWalletConnect ? (uri) => {
39
+ return isAndroid() ? uri : `okex://main/wc?uri=${encodeURIComponent(uri)}`;
40
+ } : void 0
41
+ },
42
+ qrCode: shouldUseWalletConnect ? {
43
+ getUri: (uri) => uri,
44
+ instructions: {
45
+ learnMoreUrl: "https://okx.com/web3/",
46
+ steps: [
47
+ {
48
+ description: "wallet_connectors.okx.qr_code.step1.description",
49
+ step: "install",
50
+ title: "wallet_connectors.okx.qr_code.step1.title"
51
+ },
52
+ {
53
+ description: "wallet_connectors.okx.qr_code.step2.description",
54
+ step: "create",
55
+ title: "wallet_connectors.okx.qr_code.step2.title"
56
+ },
57
+ {
58
+ description: "wallet_connectors.okx.qr_code.step3.description",
59
+ step: "scan",
60
+ title: "wallet_connectors.okx.qr_code.step3.title"
61
+ }
62
+ ]
63
+ }
64
+ } : void 0,
65
+ extension: {
66
+ instructions: {
67
+ learnMoreUrl: "https://okx.com/web3/",
68
+ steps: [
69
+ {
70
+ description: "wallet_connectors.okx.extension.step1.description",
71
+ step: "install",
72
+ title: "wallet_connectors.okx.extension.step1.title"
73
+ },
74
+ {
75
+ description: "wallet_connectors.okx.extension.step2.description",
76
+ step: "create",
77
+ title: "wallet_connectors.okx.extension.step2.title"
78
+ },
79
+ {
80
+ description: "wallet_connectors.okx.extension.step3.description",
81
+ step: "refresh",
82
+ title: "wallet_connectors.okx.extension.step3.title"
83
+ }
84
+ ]
85
+ }
86
+ },
87
+ createConnector: shouldUseWalletConnect ? getWalletConnectConnector({
88
+ projectId,
89
+ walletConnectParameters
90
+ }) : getInjectedConnector({ namespace: "okxwallet" })
91
+ };
92
+ };
93
+
94
+ export {
95
+ okxWallet
96
+ };