@avalabs/avacloud-waas-react 1.0.8 → 1.0.10

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 (3) hide show
  1. package/dist/index.js +13 -135
  2. package/dist/index.mjs +13 -135
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -142,14 +142,10 @@ function usePostMessage({
142
142
  const isExpired = Date.now() - timestamp > 30 * 60 * 1e3;
143
143
  if (!isExpired) {
144
144
  const { _timestamp, ...configWithoutTimestamp } = cachedConfig;
145
- console.log("Using cached org config:", configWithoutTimestamp);
146
145
  onOrgConfigUpdate(configWithoutTimestamp);
147
- } else {
148
- console.log("Cached org config expired, will fetch fresh data");
149
146
  }
150
147
  }
151
148
  } catch (error) {
152
- console.error("Error loading cached org config:", error);
153
149
  }
154
150
  }
155
151
  }, [orgId, environment, onOrgConfigUpdate]);
@@ -158,12 +154,10 @@ function usePostMessage({
158
154
  try {
159
155
  if (message.type === "SIGNUP_REQUEST") {
160
156
  if (globalAuthState.signupInProgress) {
161
- console.log("Global signup already in progress, ignoring duplicate request");
162
157
  return;
163
158
  }
164
159
  const now = Date.now();
165
160
  if (now - globalAuthState.lastSignupTimestamp < 3e3) {
166
- console.log("Ignoring duplicate signup attempt (global debounce)");
167
161
  return;
168
162
  }
169
163
  globalAuthState.signupInProgress = true;
@@ -187,18 +181,15 @@ function usePostMessage({
187
181
  if ("requestId" in messageToSend && messageToSend.requestId) {
188
182
  globalAuthState.processingMessageIds.add(messageToSend.requestId);
189
183
  }
190
- console.log("Sending message to auth iframe:", messageToSend);
191
184
  iframe.contentWindow.postMessage(messageToSend, authServiceUrl);
192
185
  return;
193
186
  }
194
187
  if (message.type === "LOGIN_REQUEST") {
195
188
  if (globalAuthState.loginInProgress) {
196
- console.log("Global login already in progress, ignoring duplicate request");
197
189
  return;
198
190
  }
199
191
  const now = Date.now();
200
192
  if (now - globalAuthState.lastLoginTimestamp < 3e3) {
201
- console.log("Ignoring duplicate login attempt (global debounce)");
202
193
  return;
203
194
  }
204
195
  globalAuthState.loginInProgress = true;
@@ -213,14 +204,11 @@ function usePostMessage({
213
204
  if (finalMessage.requestId) {
214
205
  globalAuthState.processingMessageIds.add(finalMessage.requestId);
215
206
  }
216
- console.log("Sending message to auth iframe:", finalMessage);
217
207
  iframe.contentWindow.postMessage(finalMessage, authServiceUrl);
218
208
  return;
219
209
  }
220
- console.log("Sending message to auth iframe:", message);
221
210
  iframe.contentWindow.postMessage(message, authServiceUrl);
222
211
  } catch (error) {
223
- console.error("Error sending message to iframe:", error);
224
212
  if (message.type === "SIGNUP_REQUEST") {
225
213
  globalAuthState.signupInProgress = false;
226
214
  }
@@ -228,15 +216,12 @@ function usePostMessage({
228
216
  globalAuthState.loginInProgress = false;
229
217
  }
230
218
  }
231
- } else {
232
- console.error("No iframe available to send message");
233
219
  }
234
220
  }, [iframe, authServiceUrl]);
235
221
  (0, import_react.useEffect)(() => {
236
222
  const handleMessage = async (event) => {
237
223
  var _a, _b, _c, _d, _e, _f, _g;
238
224
  if (isHandlingMessageRef.current) {
239
- console.log("Already handling a message, skipping");
240
225
  return;
241
226
  }
242
227
  if (event.origin !== new URL(authServiceUrl).origin) {
@@ -246,12 +231,10 @@ function usePostMessage({
246
231
  return;
247
232
  }
248
233
  if (event.data.requestId && globalAuthState.processingMessageIds.has(event.data.requestId)) {
249
- console.log(`Already processed message with requestId: ${event.data.requestId}, ignoring duplicate`);
250
234
  return;
251
235
  }
252
236
  try {
253
237
  isHandlingMessageRef.current = true;
254
- console.log("Received message from iframe:", event.data);
255
238
  if (event.data.type === "ERROR") {
256
239
  globalAuthState.signupInProgress = false;
257
240
  globalAuthState.loginInProgress = false;
@@ -265,19 +248,14 @@ function usePostMessage({
265
248
  }
266
249
  switch (event.data.type) {
267
250
  case "IFRAME_READY":
268
- console.log("Iframe ready message received, setting isIframeReady to true");
269
- console.log("\u2705 Connection established: Parent received IFRAME_READY from auth service.");
270
251
  setIsIframeReady(true);
271
252
  break;
272
253
  case "RECEIVE_OIDC":
273
- console.log("Received OIDC token payload:", event.data.payload);
274
254
  if (typeof ((_b = event.data.payload) == null ? void 0 : _b.idToken) === "string") {
275
255
  const oidcToken = event.data.payload.idToken;
276
- console.log("Triggering onOidcReceived callback with token...");
277
256
  hasRequestedOidcRef.current = false;
278
257
  onOidcReceived == null ? void 0 : onOidcReceived(oidcToken);
279
258
  } else {
280
- console.warn("RECEIVE_OIDC message missing idToken in payload.");
281
259
  hasRequestedOidcRef.current = false;
282
260
  }
283
261
  break;
@@ -290,7 +268,6 @@ function usePostMessage({
290
268
  }
291
269
  const authStateChanged = lastAuthStateRef.current.isAuthenticated !== newIsAuthenticated || lastAuthStateRef.current.userId !== newUserId;
292
270
  if (authStateChanged) {
293
- console.log("Auth status changed:", { newIsAuthenticated, newUserId });
294
271
  setIsAuthenticated(newIsAuthenticated);
295
272
  if (event.data.user) {
296
273
  const userInfo = {
@@ -300,11 +277,9 @@ function usePostMessage({
300
277
  displayName: event.data.user.nickname || event.data.user.name || ((_e = event.data.user.email) == null ? void 0 : _e.split("@")[0]) || "User",
301
278
  rawUserData: event.data.user
302
279
  };
303
- console.log("Setting user info:", userInfo);
304
280
  setUser(userInfo);
305
281
  if (newIsAuthenticated && !cubistClient && !hasRequestedOidcRef.current) {
306
282
  hasRequestedOidcRef.current = true;
307
- console.log("User newly authenticated, sending GET_OIDC message");
308
283
  sendMessage({ type: "GET_OIDC" });
309
284
  return;
310
285
  }
@@ -329,7 +304,6 @@ function usePostMessage({
329
304
  }
330
305
  }
331
306
  if (event.data.orgConfig && onOrgConfigUpdate) {
332
- console.log("Received organization config:", event.data.orgConfig);
333
307
  onOrgConfigUpdate(event.data.orgConfig);
334
308
  if (orgId) {
335
309
  try {
@@ -339,9 +313,7 @@ function usePostMessage({
339
313
  _timestamp: Date.now()
340
314
  };
341
315
  localStorage.setItem(cachedConfigKey, JSON.stringify(configWithTimestamp));
342
- console.log("Cached organization config for future use");
343
316
  } catch (error) {
344
- console.error("Error caching org config:", error);
345
317
  }
346
318
  }
347
319
  }
@@ -351,12 +323,10 @@ function usePostMessage({
351
323
  break;
352
324
  }
353
325
  case "REGISTER_SUCCESS": {
354
- console.log("Registration successful:", event.data.payload);
355
326
  const userId = (_f = event.data.payload) == null ? void 0 : _f.userId;
356
327
  if (userId) {
357
328
  localStorage.setItem(CUBIST_USER_ID_KEY, userId);
358
329
  if (!hasRequestedOidcRef.current) {
359
- console.log("Registration complete, sending GET_OIDC message");
360
330
  hasRequestedOidcRef.current = true;
361
331
  sendMessage({ type: "GET_OIDC" });
362
332
  }
@@ -365,11 +335,9 @@ function usePostMessage({
365
335
  }
366
336
  case "ERROR":
367
337
  if (event.data.error === "User not authenticated in iframe") {
368
- console.log("Ignoring expected auth iframe error:", event.data.error);
369
338
  isHandlingMessageRef.current = false;
370
339
  return;
371
340
  }
372
- console.error("Error from auth service:", event.data.error);
373
341
  onAuthError == null ? void 0 : onAuthError(new Error((_g = event.data.error) != null ? _g : "Unknown error"));
374
342
  setIsLoading(false);
375
343
  break;
@@ -397,7 +365,6 @@ function usePostMessage({
397
365
  ]);
398
366
  (0, import_react.useEffect)(() => {
399
367
  if (isIframeReady && (iframe == null ? void 0 : iframe.contentWindow)) {
400
- console.log("\u23F3 Connection attempt: Parent sending CHECK_AUTH_STATUS to auth service.");
401
368
  sendMessage({
402
369
  type: "CHECK_AUTH_STATUS",
403
370
  payload: {
@@ -437,6 +404,10 @@ function PoweredByAvaCloud() {
437
404
  ] });
438
405
  }
439
406
 
407
+ // src/constants/legal.ts
408
+ var TERMS_OF_SERVICE_URL = "https://app.avacloud.io/legal/waas/user-terms";
409
+ var PRIVACY_POLICY_URL = "https://www.avalabs.org/privacy-policy";
410
+
440
411
  // src/components/SignInContent.tsx
441
412
  var import_jsx_runtime2 = require("react/jsx-runtime");
442
413
  function SignInContent({
@@ -521,7 +492,6 @@ function SignInContent({
521
492
  onEmailSignup(email, password);
522
493
  };
523
494
  const handleForgotPassword = () => {
524
- console.log("Forgot password clicked");
525
495
  };
526
496
  const handleToggleSignup = () => {
527
497
  setIsSignupMode(!isSignupMode);
@@ -663,7 +633,7 @@ function SignInContent({
663
633
  {
664
634
  variant: "text",
665
635
  component: "a",
666
- href: "https://avacloud.io/terms",
636
+ href: TERMS_OF_SERVICE_URL,
667
637
  target: "_blank",
668
638
  rel: "noopener noreferrer",
669
639
  sx: {
@@ -689,7 +659,7 @@ function SignInContent({
689
659
  {
690
660
  variant: "text",
691
661
  component: "a",
692
- href: "https://avacloud.io/privacy",
662
+ href: PRIVACY_POLICY_URL,
693
663
  target: "_blank",
694
664
  rel: "noopener noreferrer",
695
665
  sx: {
@@ -806,14 +776,14 @@ function SignInContent({
806
776
  }
807
777
  },
808
778
  children: [
809
- "By connecting, you agree to the",
779
+ "By continuing, you agree to our",
810
780
  " ",
811
781
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
812
782
  import_core_k2_components2.Button,
813
783
  {
814
784
  variant: "text",
815
785
  component: "a",
816
- href: "https://app.avacloud.io/legal/generalterms/",
786
+ href: TERMS_OF_SERVICE_URL,
817
787
  target: "_blank",
818
788
  rel: "noopener noreferrer",
819
789
  sx: {
@@ -828,7 +798,7 @@ function SignInContent({
828
798
  backgroundColor: "transparent"
829
799
  }
830
800
  },
831
- children: "Terms of Service"
801
+ children: "Terms of Use"
832
802
  }
833
803
  ),
834
804
  " ",
@@ -839,7 +809,7 @@ function SignInContent({
839
809
  {
840
810
  variant: "text",
841
811
  component: "a",
842
- href: "https://www.avalabs.org/privacy-policy",
812
+ href: PRIVACY_POLICY_URL,
843
813
  target: "_blank",
844
814
  rel: "noopener noreferrer",
845
815
  sx: {
@@ -971,7 +941,7 @@ function SignInContent({
971
941
  {
972
942
  variant: "text",
973
943
  component: "a",
974
- href: "https://app.avacloud.io/legal/generalterms/",
944
+ href: TERMS_OF_SERVICE_URL,
975
945
  target: "_blank",
976
946
  rel: "noopener noreferrer",
977
947
  sx: {
@@ -997,7 +967,7 @@ function SignInContent({
997
967
  {
998
968
  variant: "text",
999
969
  component: "a",
1000
- href: "https://www.avalabs.org/privacy-policy",
970
+ href: PRIVACY_POLICY_URL,
1001
971
  target: "_blank",
1002
972
  rel: "noopener noreferrer",
1003
973
  sx: {
@@ -1038,14 +1008,8 @@ function LoginModal({ open, onClose }) {
1038
1008
  if (!event.data || typeof event.data.type !== "string") {
1039
1009
  return;
1040
1010
  }
1041
- console.log(
1042
- "Modal received message from iframe:",
1043
- event.data.type,
1044
- event.data.payload ? "has payload" : "no payload"
1045
- );
1046
1011
  if (event.data.type === "ERROR") {
1047
1012
  if (event.data.payload === "User not authenticated in iframe") {
1048
- console.log("Ignoring transient auth error during signup process");
1049
1013
  return;
1050
1014
  }
1051
1015
  setError(event.data.payload);
@@ -1056,7 +1020,6 @@ function LoginModal({ open, onClose }) {
1056
1020
  timeoutIdRef.current = null;
1057
1021
  }
1058
1022
  } else if (event.data.type === "AUTH_STATUS" && event.data.isAuthenticated) {
1059
- console.log("Auth successful, resetting state and closing modal");
1060
1023
  setIsSubmitting(false);
1061
1024
  signupInProgressRef.current = false;
1062
1025
  requestInProgress = false;
@@ -1083,11 +1046,9 @@ function LoginModal({ open, onClose }) {
1083
1046
  var _a2;
1084
1047
  setError("");
1085
1048
  if (!iframe) {
1086
- console.error("Auth service iframe not found");
1087
1049
  setError("Authentication service not available");
1088
1050
  return;
1089
1051
  }
1090
- console.log(`Sending LOGIN_REQUEST to auth service iframe with ${provider} connection`);
1091
1052
  (_a2 = iframe.contentWindow) == null ? void 0 : _a2.postMessage({
1092
1053
  type: "LOGIN_REQUEST",
1093
1054
  connection: provider,
@@ -1100,7 +1061,6 @@ function LoginModal({ open, onClose }) {
1100
1061
  setError("");
1101
1062
  setIsSubmitting(true);
1102
1063
  if (!iframe) {
1103
- console.error("Auth service iframe not found");
1104
1064
  setError("Authentication service not available");
1105
1065
  setIsSubmitting(false);
1106
1066
  return;
@@ -1109,7 +1069,6 @@ function LoginModal({ open, onClose }) {
1109
1069
  clearTimeout(timeoutIdRef.current);
1110
1070
  timeoutIdRef.current = null;
1111
1071
  }
1112
- console.log("Sending email/password LOGIN_REQUEST to auth service iframe");
1113
1072
  (_a2 = iframe.contentWindow) == null ? void 0 : _a2.postMessage({
1114
1073
  type: "LOGIN_REQUEST",
1115
1074
  email,
@@ -1117,7 +1076,6 @@ function LoginModal({ open, onClose }) {
1117
1076
  requestId: `login-${Date.now()}`
1118
1077
  }, "*");
1119
1078
  timeoutIdRef.current = setTimeout(() => {
1120
- console.log("No response received from auth service iframe");
1121
1079
  setError("Authentication service timed out");
1122
1080
  setIsSubmitting(false);
1123
1081
  timeoutIdRef.current = null;
@@ -1125,12 +1083,10 @@ function LoginModal({ open, onClose }) {
1125
1083
  };
1126
1084
  const handleEmailSignup = (email, password) => {
1127
1085
  if (signupInProgressRef.current) {
1128
- console.log("Signup already in progress, ignoring duplicate request");
1129
1086
  return;
1130
1087
  }
1131
1088
  const now = Date.now();
1132
1089
  if (now - lastSignupAttemptRef.current < 2e3) {
1133
- console.log("Ignoring duplicate signup attempt (debounce)");
1134
1090
  return;
1135
1091
  }
1136
1092
  lastSignupAttemptRef.current = now;
@@ -1144,14 +1100,12 @@ function LoginModal({ open, onClose }) {
1144
1100
  try {
1145
1101
  signup(email, password);
1146
1102
  } catch (error2) {
1147
- console.error("Error initiating signup:", error2);
1148
1103
  setError("Failed to initiate signup");
1149
1104
  setIsSubmitting(false);
1150
1105
  signupInProgressRef.current = false;
1151
1106
  return;
1152
1107
  }
1153
1108
  timeoutIdRef.current = setTimeout(() => {
1154
- console.log("No response received from auth service iframe");
1155
1109
  setError("Authentication service timed out");
1156
1110
  setIsSubmitting(false);
1157
1111
  signupInProgressRef.current = false;
@@ -1646,7 +1600,7 @@ var queryClient = new import_react_query2.QueryClient({
1646
1600
  }
1647
1601
  });
1648
1602
  function getCubistEnv(environment) {
1649
- return environment === "production" ? import_cubesigner_sdk.envs.prod : import_cubesigner_sdk.envs.gamma;
1603
+ return environment === "gamma" || environment === "development" ? import_cubesigner_sdk.envs.gamma : import_cubesigner_sdk.envs.prod;
1650
1604
  }
1651
1605
  function ViemProviderWrapper({ children, chainId }) {
1652
1606
  const { data: blockchain } = useBlockchain(chainId.toString());
@@ -1694,32 +1648,25 @@ function AvaCloudWalletProvider({
1694
1648
  try {
1695
1649
  const sessionKeys = await client.sessionKeys();
1696
1650
  if (!sessionKeys.length) {
1697
- console.log("[getWalletInfo] No session keys found");
1698
1651
  return null;
1699
1652
  }
1700
1653
  const key = sessionKeys[0];
1701
1654
  const address = key.materialId;
1702
1655
  if (!(orgConfig == null ? void 0 : orgConfig.walletProviderOrgID)) {
1703
- console.error("[getWalletInfo] Missing walletProviderOrgID in organization config");
1704
1656
  throw new Error("Missing required walletProviderOrgID in organization configuration");
1705
1657
  }
1706
- console.log("[getWalletInfo] Returning wallet info with address:", address);
1707
1658
  return {
1708
1659
  address,
1709
1660
  sessionId,
1710
1661
  orgId: orgConfig.walletProviderOrgID
1711
1662
  };
1712
1663
  } catch (err) {
1713
- console.error("[getWalletInfo] Error:", err);
1714
1664
  setCubistError(err instanceof Error ? err : new Error("Failed to get wallet info"));
1715
1665
  return null;
1716
1666
  }
1717
1667
  }, [orgConfig]);
1718
1668
  const loginWithCubist = (0, import_react9.useCallback)(async (oidcToken) => {
1719
- console.log("[loginWithCubist] Starting...");
1720
- console.log("[loginWithCubist] Current orgConfig:", orgConfig);
1721
1669
  if (!orgConfig || !orgConfig.walletProviderOrgID) {
1722
- console.error("[loginWithCubist] PREVENTED: Missing walletProviderOrgID in organization config");
1723
1670
  const error = new Error("Missing required walletProviderOrgID in organization configuration");
1724
1671
  setCubistError(error);
1725
1672
  onAuthError == null ? void 0 : onAuthError(error);
@@ -1730,15 +1677,12 @@ function AvaCloudWalletProvider({
1730
1677
  setIsCubistLoading(true);
1731
1678
  setCubistError(null);
1732
1679
  if (!(orgConfig == null ? void 0 : orgConfig.walletProviderOrgID)) {
1733
- console.error("[loginWithCubist] Missing walletProviderOrgID in organization config");
1734
1680
  throw new Error("Missing required walletProviderOrgID in organization configuration");
1735
1681
  }
1736
1682
  let accessToken;
1737
1683
  if (oidcToken) {
1738
- console.log("[loginWithCubist] Using provided OIDC token.");
1739
1684
  accessToken = oidcToken;
1740
1685
  } else {
1741
- console.log("[loginWithCubist] Attempting to get OIDC token from localStorage.");
1742
1686
  const tokens = localStorage.getItem(AUTH_TOKENS_KEY);
1743
1687
  if (!tokens) {
1744
1688
  throw new Error("No authentication tokens found in localStorage");
@@ -1747,7 +1691,6 @@ function AvaCloudWalletProvider({
1747
1691
  accessToken = parsed.access_token;
1748
1692
  }
1749
1693
  try {
1750
- console.log(`[loginWithCubist] Attempting CubeSignerClient.createOidcSession for Org: ${orgConfig.walletProviderOrgID}`);
1751
1694
  const resp = await import_cubesigner_sdk2.CubeSignerClient.createOidcSession(
1752
1695
  getCubistEnv(environment),
1753
1696
  orgConfig.walletProviderOrgID,
@@ -1762,39 +1705,27 @@ function AvaCloudWalletProvider({
1762
1705
  // 90 days
1763
1706
  }
1764
1707
  );
1765
- console.log("[loginWithCubist] createOidcSession response received.");
1766
1708
  if (resp.requiresMfa()) {
1767
- console.warn("[loginWithCubist] MFA required, aborting.");
1768
1709
  throw new Error("MFA required for Cubist login");
1769
1710
  }
1770
1711
  const sessionData = resp.data();
1771
- console.log("[loginWithCubist] Session data obtained, attempting CubeSignerClient.create");
1772
1712
  const newClient = await import_cubesigner_sdk2.CubeSignerClient.create(sessionData);
1773
1713
  const sessionId = sessionData.session_info.session_id;
1774
- console.log(`[loginWithCubist] CubeSignerClient created successfully. Session ID: ${sessionId}`);
1775
- console.log("[loginWithCubist] Attempting getWalletInfo");
1776
1714
  const cubistWallet = await getWalletInfo(newClient, sessionId);
1777
- console.log("[loginWithCubist] getWalletInfo result:", cubistWallet);
1778
- console.log("[loginWithCubist] Setting cubistClient state.");
1779
1715
  setCubistClient(newClient);
1780
1716
  if (cubistWallet) {
1781
- console.log("[loginWithCubist] Setting wallet state with cubistWallet.");
1782
1717
  setWallet((prev) => ({
1783
1718
  ...prev,
1784
1719
  address: cubistWallet.address,
1785
1720
  cubistWallet
1786
1721
  }));
1787
- console.log("[loginWithCubist] Calling onWalletUpdate callback.");
1788
1722
  onWalletUpdate == null ? void 0 : onWalletUpdate({
1789
1723
  ...wallet,
1790
1724
  // Use current wallet state potentially
1791
1725
  cubistWallet
1792
1726
  });
1793
- } else {
1794
- console.warn("[loginWithCubist] cubistWallet is null, not updating wallet state further.");
1795
1727
  }
1796
1728
  } catch (error) {
1797
- console.error("[loginWithCubist] Error during Cubist session creation/wallet info:", error);
1798
1729
  localStorage.removeItem(AUTH_TOKENS_KEY);
1799
1730
  localStorage.removeItem(AUTH0_STORAGE_KEYS.IS_AUTHENTICATED);
1800
1731
  setIsAuthenticated(false);
@@ -1804,11 +1735,9 @@ function AvaCloudWalletProvider({
1804
1735
  }
1805
1736
  } catch (error) {
1806
1737
  const err = error instanceof Error ? error : new Error("Failed to create Cubist session");
1807
- console.error("[loginWithCubist] Final catch block error:", err);
1808
1738
  setCubistError(err);
1809
1739
  onAuthError == null ? void 0 : onAuthError(err);
1810
1740
  } finally {
1811
- console.log("[loginWithCubist] Setting isCubistLoading to false.");
1812
1741
  setIsCubistLoading(false);
1813
1742
  }
1814
1743
  }, [wallet, onWalletUpdate, onAuthError, getWalletInfo, orgConfig, environment]);
@@ -1819,62 +1748,46 @@ function AvaCloudWalletProvider({
1819
1748
  iframe,
1820
1749
  isIframeReady,
1821
1750
  onAuthSuccess: () => {
1822
- console.log("[onAuthSuccess] Called");
1823
1751
  if (user) {
1824
1752
  if (wallet.address) {
1825
- console.log("[onAuthSuccess] Calling onAuthSuccess callback with user");
1826
1753
  onAuthSuccess == null ? void 0 : onAuthSuccess(user);
1827
- } else {
1828
- console.log("[onAuthSuccess] Not calling callback yet, waiting for wallet");
1829
1754
  }
1830
- } else {
1831
- console.log("[onAuthSuccess] No user available");
1832
1755
  }
1833
1756
  },
1834
1757
  onAuthError: (error) => {
1835
- console.log("[onAuthError] Called with error:", error);
1836
1758
  const errorMessage = (error == null ? void 0 : error.message) || "";
1837
1759
  if (errorMessage === "User not authenticated in iframe" || errorMessage === "Unknown error" || // Generic error that often appears during signup
1838
1760
  errorMessage.includes("OIDC user not found")) {
1839
- console.log("[onAuthError] Ignoring expected error during auth flow:", errorMessage);
1840
1761
  return;
1841
1762
  }
1842
1763
  setIsCubistLoading(false);
1843
1764
  onAuthError == null ? void 0 : onAuthError(error);
1844
1765
  },
1845
1766
  onWalletUpdate: (newWallet) => {
1846
- console.log("[onWalletUpdate] Called with wallet:", newWallet);
1847
1767
  setWallet(newWallet);
1848
1768
  if (user && isAuthenticated) {
1849
- console.log("[onWalletUpdate] Calling onAuthSuccess callback");
1850
1769
  onAuthSuccess == null ? void 0 : onAuthSuccess(user);
1851
1770
  }
1852
1771
  queryClient.invalidateQueries({ queryKey: ["wallet"] });
1853
1772
  onWalletUpdate == null ? void 0 : onWalletUpdate(newWallet);
1854
1773
  },
1855
1774
  onOidcReceived: (token) => {
1856
- console.log("[onOidcReceived] Received OIDC token - storing in state only");
1857
1775
  setIsCubistLoading(true);
1858
1776
  setPendingOidcToken(token);
1859
- console.log("[onOidcReceived] Current orgConfig:", orgConfig);
1860
1777
  const originalLoginWithCubist = loginWithCubist;
1861
1778
  window.___tempSafeguard_loginWithCubist = (oidcToken) => {
1862
1779
  if (!(orgConfig == null ? void 0 : orgConfig.walletProviderOrgID)) {
1863
- console.error("[SAFEGUARD] Prevented direct call to loginWithCubist without orgConfig");
1864
1780
  return Promise.reject(new Error("Missing required walletProviderOrgID in organization configuration"));
1865
1781
  }
1866
1782
  return originalLoginWithCubist(oidcToken);
1867
1783
  };
1868
1784
  },
1869
1785
  onOrgConfigUpdate: (config) => {
1870
- console.log("[onOrgConfigUpdate] Received org config with walletProviderOrgID:", config == null ? void 0 : config.walletProviderOrgID);
1871
- console.log("[onOrgConfigUpdate] Current pendingOidcToken:", !!pendingOidcToken);
1872
1786
  setOrgConfig(config);
1873
1787
  },
1874
1788
  setIsAuthenticated,
1875
1789
  setUser,
1876
1790
  setIsLoading: (isLoading2) => {
1877
- console.log("[setIsLoading] Setting isLoading to:", isLoading2);
1878
1791
  setIsLoading(isLoading2);
1879
1792
  },
1880
1793
  setIsIframeReady,
@@ -1882,16 +1795,12 @@ function AvaCloudWalletProvider({
1882
1795
  cubistClient
1883
1796
  });
1884
1797
  const login = (0, import_react9.useCallback)(() => {
1885
- console.log("[login] Called");
1886
1798
  if (iframe == null ? void 0 : iframe.contentWindow) {
1887
1799
  setIsCubistLoading(true);
1888
1800
  sendMessage({ type: "LOGIN_REQUEST" });
1889
- } else {
1890
- console.error("[login] No iframe available for login");
1891
1801
  }
1892
1802
  }, [iframe, sendMessage]);
1893
1803
  const signup = (0, import_react9.useCallback)((email, password) => {
1894
- console.log("[signup] Called with email:", email);
1895
1804
  if (iframe == null ? void 0 : iframe.contentWindow) {
1896
1805
  setIsCubistLoading(true);
1897
1806
  sendMessage({
@@ -1902,12 +1811,9 @@ function AvaCloudWalletProvider({
1902
1811
  },
1903
1812
  requestId: `signup-${Date.now()}`
1904
1813
  });
1905
- } else {
1906
- console.error("[signup] No iframe available for signup");
1907
1814
  }
1908
1815
  }, [iframe, sendMessage]);
1909
1816
  const logout = (0, import_react9.useCallback)(() => {
1910
- console.log("[logout] Called");
1911
1817
  sendMessage({ type: "LOGOUT_REQUEST" });
1912
1818
  setUser(null);
1913
1819
  setWallet({ address: null });
@@ -1928,7 +1834,6 @@ function AvaCloudWalletProvider({
1928
1834
  setPendingOidcToken(null);
1929
1835
  }, [sendMessage, orgId, env]);
1930
1836
  const addAccount = (0, import_react9.useCallback)(async (accountIndex) => {
1931
- console.log("[addAccount] Called with accountIndex:", accountIndex);
1932
1837
  if (!isAuthenticated || !user || !wallet.mnemonicId) {
1933
1838
  throw new Error("User must be authenticated and have a wallet to add an account");
1934
1839
  }
@@ -1949,19 +1854,13 @@ function AvaCloudWalletProvider({
1949
1854
  });
1950
1855
  }, [sendMessage, isAuthenticated, user, wallet.mnemonicId]);
1951
1856
  (0, import_react9.useEffect)(() => {
1952
- console.log("[useEffect Auth] Running effect with dependencies...");
1953
- console.log("[useEffect Auth] pendingOidcToken:", !!pendingOidcToken);
1954
- console.log("[useEffect Auth] orgConfig?.walletProviderOrgID:", orgConfig == null ? void 0 : orgConfig.walletProviderOrgID);
1955
1857
  const hasOrgConfig = !!(orgConfig == null ? void 0 : orgConfig.walletProviderOrgID);
1956
1858
  const hasOidcToken = !!pendingOidcToken;
1957
- console.log(`[useEffect Auth] Checking conditions - hasOrgConfig: ${hasOrgConfig}, hasOidcToken: ${hasOidcToken}`);
1958
1859
  if (hasOrgConfig && hasOidcToken && pendingOidcToken) {
1959
- console.log("[useEffect Auth] Both orgConfig and oidcToken are available, calling loginWithCubist");
1960
1860
  const doLogin = async () => {
1961
1861
  try {
1962
1862
  await loginWithCubist(pendingOidcToken);
1963
1863
  } catch (error) {
1964
- console.error("[useEffect Auth] Error in loginWithCubist:", error);
1965
1864
  onAuthError == null ? void 0 : onAuthError(error instanceof Error ? error : new Error("Failed to create Cubist session"));
1966
1865
  } finally {
1967
1866
  setIsCubistLoading(false);
@@ -1972,7 +1871,6 @@ function AvaCloudWalletProvider({
1972
1871
  }
1973
1872
  }, [orgConfig, pendingOidcToken, loginWithCubist, onAuthError]);
1974
1873
  (0, import_react9.useEffect)(() => {
1975
- console.log("[useEffect Iframe] Setting up iframe...");
1976
1874
  if (typeof window === "undefined" || typeof document === "undefined") {
1977
1875
  return;
1978
1876
  }
@@ -1989,9 +1887,7 @@ function AvaCloudWalletProvider({
1989
1887
  document.body.appendChild(frame);
1990
1888
  iframeRef.current = frame;
1991
1889
  setIframe(frame);
1992
- console.log("[useEffect Iframe] Iframe created and added to DOM");
1993
1890
  const timeoutId = setTimeout(() => {
1994
- console.log("[useEffect Iframe] Timeout reached, setting isCubistLoading to false");
1995
1891
  setIsCubistLoading(false);
1996
1892
  }, 5e3);
1997
1893
  return () => {
@@ -1999,7 +1895,6 @@ function AvaCloudWalletProvider({
1999
1895
  if (iframeRef.current) {
2000
1896
  iframeRef.current.remove();
2001
1897
  iframeRef.current = null;
2002
- console.log("[useEffect Iframe] Iframe removed in cleanup");
2003
1898
  }
2004
1899
  };
2005
1900
  }, [authServiceUrl]);
@@ -2013,7 +1908,6 @@ function AvaCloudWalletProvider({
2013
1908
  }
2014
1909
  const existingOidcToken = sessionStorage.getItem(OIDC_TOKEN_KEY);
2015
1910
  if (existingOidcToken) {
2016
- console.log("[useEffect Init] Found existing OIDC token in sessionStorage");
2017
1911
  setPendingOidcToken(existingOidcToken);
2018
1912
  } else {
2019
1913
  try {
@@ -2021,13 +1915,11 @@ function AvaCloudWalletProvider({
2021
1915
  if (tokensJson) {
2022
1916
  const tokens = JSON.parse(tokensJson);
2023
1917
  if (tokens.access_token) {
2024
- console.log("[useEffect Init] Using access_token from localStorage as OIDC token");
2025
1918
  sessionStorage.setItem(OIDC_TOKEN_KEY, tokens.access_token);
2026
1919
  setPendingOidcToken(tokens.access_token);
2027
1920
  }
2028
1921
  }
2029
1922
  } catch (error) {
2030
- console.error("[useEffect Init] Error parsing tokens from localStorage:", error);
2031
1923
  }
2032
1924
  }
2033
1925
  }, []);
@@ -2212,7 +2104,6 @@ function useTransferTokens() {
2212
2104
  const actualBaseFee = (0, import_viem2.formatEther)(baseFeePerGas * receipt.gasUsed);
2213
2105
  const actualPriorityFee = (0, import_viem2.formatEther)(effectivePriorityFee * receipt.gasUsed);
2214
2106
  const actualTotalFee = (0, import_viem2.formatEther)(receipt.effectiveGasPrice * receipt.gasUsed);
2215
- console.log("Transaction confirmed:", receipt);
2216
2107
  if ((wallet == null ? void 0 : wallet.address) && ((_a = publicClient.chain) == null ? void 0 : _a.id)) {
2217
2108
  const chainId = publicClient.chain.id.toString();
2218
2109
  queryClient2.invalidateQueries({
@@ -2227,7 +2118,6 @@ function useTransferTokens() {
2227
2118
  actualTotalFee: Number(actualTotalFee).toFixed(6)
2228
2119
  }));
2229
2120
  } catch (err) {
2230
- console.error("Failed to send transaction:", err);
2231
2121
  setState((prev) => ({
2232
2122
  ...prev,
2233
2123
  error: err instanceof Error ? err.message : "Failed to send transaction",
@@ -2305,7 +2195,6 @@ function useTransferTokens() {
2305
2195
  const actualBaseFee = (0, import_viem2.formatEther)(baseFeePerGas * receipt.gasUsed);
2306
2196
  const actualPriorityFee = (0, import_viem2.formatEther)(effectivePriorityFee * receipt.gasUsed);
2307
2197
  const actualTotalFee = (0, import_viem2.formatEther)(receipt.effectiveGasPrice * receipt.gasUsed);
2308
- console.log("Transaction confirmed:", receipt);
2309
2198
  if ((wallet == null ? void 0 : wallet.address) && ((_a = publicClient.chain) == null ? void 0 : _a.id)) {
2310
2199
  const chainId = publicClient.chain.id.toString();
2311
2200
  queryClient2.invalidateQueries({
@@ -2323,7 +2212,6 @@ function useTransferTokens() {
2323
2212
  actualTotalFee: Number(actualTotalFee).toFixed(6)
2324
2213
  }));
2325
2214
  } catch (err) {
2326
- console.error("Failed to send transaction:", err);
2327
2215
  setState((prev) => ({
2328
2216
  ...prev,
2329
2217
  error: err instanceof Error ? err.message : "Failed to send transaction",
@@ -2413,7 +2301,6 @@ function useGasEstimation() {
2413
2301
  totalWithAmount
2414
2302
  }));
2415
2303
  } catch (err) {
2416
- console.error("Failed to estimate gas:", err);
2417
2304
  setState((prev) => ({
2418
2305
  ...prev,
2419
2306
  error: err instanceof Error ? err.message : "Failed to estimate gas",
@@ -3387,7 +3274,6 @@ function ExportView({ onBack }) {
3387
3274
  };
3388
3275
  window.addEventListener("message", handleResponse);
3389
3276
  } catch (err) {
3390
- console.error("Export failed:", err);
3391
3277
  setError("Failed to export private key. Please try again.");
3392
3278
  }
3393
3279
  };
@@ -4540,12 +4426,6 @@ function useSignTransaction() {
4540
4426
  }, []);
4541
4427
  const signTransaction = (0, import_react25.useCallback)(async (transaction) => {
4542
4428
  var _a, _b, _c, _d;
4543
- console.log("Signing transaction with:", {
4544
- wallet: wallet == null ? void 0 : wallet.address,
4545
- hasClient: !!cubistClient,
4546
- hasPublicClient: !!publicClient,
4547
- chain: publicClient == null ? void 0 : publicClient.chain
4548
- });
4549
4429
  if (!(wallet == null ? void 0 : wallet.address)) {
4550
4430
  setState((prev) => ({
4551
4431
  ...prev,
@@ -4590,7 +4470,6 @@ function useSignTransaction() {
4590
4470
  maxPriorityFeePerGas: (_d = transaction.maxPriorityFeePerGas) == null ? void 0 : _d.toString()
4591
4471
  }
4592
4472
  };
4593
- console.log("Signing request:", signReq);
4594
4473
  const sig = await key.signEvm(signReq);
4595
4474
  const signedTx = sig.data().rlp_signed_tx;
4596
4475
  setState((prev) => ({
@@ -4598,7 +4477,6 @@ function useSignTransaction() {
4598
4477
  signedTransaction: signedTx
4599
4478
  }));
4600
4479
  } catch (err) {
4601
- console.error("Error signing transaction:", err);
4602
4480
  setState((prev) => ({
4603
4481
  ...prev,
4604
4482
  error: err instanceof Error ? err.message : "Failed to sign transaction"