@lumiapassport/ui-kit 1.14.25 → 1.15.0

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.
@@ -15,7 +15,7 @@
15
15
  <meta http-equiv="X-Content-Type-Options" content="nosniff" />
16
16
  <meta http-equiv="Referrer-Policy" content="strict-origin-when-cross-origin" />
17
17
 
18
- <title>Lumia Passport Secure Wallet - iframe version 1.14.25</title>
18
+ <title>Lumia Passport Secure Wallet - iframe version 1.15.0</title>
19
19
 
20
20
  <!-- Styles will be injected by build process -->
21
21
  <style>
@@ -4402,7 +4402,7 @@ var SigningManager = class extends TokenRefreshApiClient {
4402
4402
  };
4403
4403
 
4404
4404
  // src/iframe/main.ts
4405
- var IFRAME_VERSION = "1.14.25";
4405
+ var IFRAME_VERSION = "1.15.0";
4406
4406
  var IframeWallet = class {
4407
4407
  constructor() {
4408
4408
  console.log("=".repeat(60));
package/dist/index.cjs CHANGED
@@ -3738,6 +3738,11 @@ async function createAccountSession(params = {}) {
3738
3738
  }
3739
3739
  const saltZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
3740
3740
  const smartAccountAddress = await predictCompatAddress(ownerAddress, factoryAddress, saltZero);
3741
+ if (mpcUserId) {
3742
+ registerSmartAccountAddress(smartAccountAddress).catch((error) => {
3743
+ console.warn("[Account] Background Smart Account registration failed:", error);
3744
+ });
3745
+ }
3741
3746
  return { ownerAddress, smartAccountAddress, factoryAddress, ownerPrivateKey, mpcUserId: privateKey ? void 0 : mpcUserId, usePaymaster, kind: "lumia", address: smartAccountAddress };
3742
3747
  }
3743
3748
  async function predictCompatAddress(owner, factory, salt) {
@@ -3749,6 +3754,47 @@ async function predictCompatAddress(owner, factory, salt) {
3749
3754
  throw new Error(`Failed to predict account address: ${error}`);
3750
3755
  }
3751
3756
  }
3757
+ async function registerSmartAccountAddress(smartAccountAddress) {
3758
+ const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
3759
+ const accessToken = jwtTokenManager4.getAccessToken();
3760
+ if (!accessToken) {
3761
+ console.warn("[Account] No access token available for Smart Account registration");
3762
+ return { success: true, smartAccountAddress, alreadySet: false };
3763
+ }
3764
+ const tssUrl = getTssUrl2();
3765
+ try {
3766
+ const response = await fetch(`${tssUrl}/api/tss/wallet/smart-account`, {
3767
+ method: "POST",
3768
+ headers: {
3769
+ "Authorization": `Bearer ${accessToken}`,
3770
+ "Content-Type": "application/json"
3771
+ },
3772
+ body: JSON.stringify({ smartAccountAddress })
3773
+ });
3774
+ if (!response.ok) {
3775
+ const errorData = await response.json().catch(() => ({}));
3776
+ if (response.status === 409) {
3777
+ console.warn("[Account] Smart Account address conflict:", errorData.error);
3778
+ return { success: true, smartAccountAddress, alreadySet: true };
3779
+ }
3780
+ if (response.status === 404) {
3781
+ console.warn("[Account] DKG not completed on server:", errorData.error);
3782
+ return { success: false, smartAccountAddress, alreadySet: false };
3783
+ }
3784
+ console.warn("[Account] Failed to register Smart Account:", errorData.error || response.statusText);
3785
+ return { success: false, smartAccountAddress, alreadySet: false };
3786
+ }
3787
+ const result = await response.json();
3788
+ console.log("[Account] Smart Account registered:", {
3789
+ address: result.smartAccountAddress,
3790
+ alreadySet: result.alreadySet
3791
+ });
3792
+ return result;
3793
+ } catch (error) {
3794
+ console.warn("[Account] Error registering Smart Account address:", error);
3795
+ return { success: false, smartAccountAddress, alreadySet: false };
3796
+ }
3797
+ }
3752
3798
  async function sendUserOperation(session, callTarget, amountWei, innerData = "0x", feeType = "standard", entryPointVersion = "v0.7") {
3753
3799
  const entryPointAddress = entryPointVersion === "v0.6" ? ENTRYPOINT_V06 : ENTRYPOINT_V07;
3754
3800
  const amountWeiBigInt = BigInt(amountWei);
@@ -4335,8 +4381,9 @@ async function changeNickname(handle) {
4335
4381
  }
4336
4382
  async function checkNicknameAvailability(handle) {
4337
4383
  const normalizedHandle = handle.toLowerCase().replace(/^@/, "");
4338
- const response = await tssClient.get(
4339
- `/api/auth/nicknames/${encodeURIComponent(normalizedHandle)}/check`,
4384
+ const response = await tssClient.post(
4385
+ "/api/auth/nicknames/check",
4386
+ { handle: normalizedHandle },
4340
4387
  false
4341
4388
  // Public endpoint, no auth required
4342
4389
  );
@@ -4348,14 +4395,15 @@ async function checkNicknameAvailability(handle) {
4348
4395
  }
4349
4396
  async function resolveNickname(handle) {
4350
4397
  const normalizedHandle = handle.toLowerCase().replace(/^@/, "");
4351
- const response = await tssClient.get(
4352
- `/api/auth/nicknames/${encodeURIComponent(normalizedHandle)}/resolve`,
4398
+ const response = await tssClient.post(
4399
+ "/api/auth/nicknames/resolve",
4400
+ { handle: normalizedHandle },
4353
4401
  false
4354
4402
  // Public endpoint, no auth required
4355
4403
  );
4356
4404
  if (!response.success || !response.data) {
4357
- const errorData = response.data;
4358
- if (errorData?.code === "NICKNAME_NOT_FOUND") {
4405
+ const errorData = response.data || {};
4406
+ if (errorData.code === "NICKNAME_NOT_FOUND") {
4359
4407
  const error = new Error("Nickname not found");
4360
4408
  error.code = "NICKNAME_NOT_FOUND";
4361
4409
  throw error;
@@ -5505,7 +5553,7 @@ function Header() {
5505
5553
  // package.json
5506
5554
  var package_default = {
5507
5555
  name: "@lumiapassport/ui-kit",
5508
- version: "1.14.25",
5556
+ version: "1.15.0",
5509
5557
  description: "React UI components and hooks for Lumia Passport authentication and Account Abstraction",
5510
5558
  type: "module",
5511
5559
  main: "./dist/index.cjs",
@@ -5948,12 +5996,21 @@ function useBackupStatusChanges() {
5948
5996
  const { mutate: handleBackupStatusChanged } = (0, import_react_query6.useMutation)({
5949
5997
  mutationFn: async (event) => {
5950
5998
  const customEvent = event;
5951
- return await getShareRecoveryStats();
5999
+ console.log("[BACKUP STATUS] changed:", customEvent?.detail);
6000
+ return { stats: await getShareRecoveryStats(), detail: customEvent?.detail };
5952
6001
  },
5953
- onSuccess: (stats) => {
6002
+ onSuccess: ({ stats, detail }) => {
5954
6003
  const hasRecoveryData = stats && (!!stats.created || !!stats?.devices?.length);
5955
6004
  if (!!hasRecoveryData) {
6005
+ console.log(
6006
+ "[BACKUP STATUS] Recovery data found after backup status change.\n Redirect to main menu:",
6007
+ detail?.navigateToMainMenu
6008
+ );
5956
6009
  setHasServerVault(true);
6010
+ if (!!detail?.navigateToMainMenu) {
6011
+ setTimeout(() => setPage("main-menu" /* MAIN_MENU */), 1e3);
6012
+ }
6013
+ console.info("[BACKUP STATUS] Recovery data found in vault, marking as has-server-vault");
5957
6014
  } else {
5958
6015
  setHasServerVault(false);
5959
6016
  setPage("keysare-backup" /* KEYSARE_BACKUP */);
@@ -8368,6 +8425,9 @@ Switch.displayName = "Switch";
8368
8425
  var import_lucide_react18 = require("lucide-react");
8369
8426
  var import_react28 = require("react");
8370
8427
 
8428
+ // src/internal/components/KeyshareRestoreMenu/hooks/useOnRestoreSuccess.ts
8429
+ var import_react25 = require("react");
8430
+
8371
8431
  // src/internal/components/KeyshareRestoreMenu/hooks/useRestoreStore.ts
8372
8432
  var import_zustand4 = require("zustand");
8373
8433
  var useRestoreStore = (0, import_zustand4.create)((set) => ({
@@ -8396,7 +8456,6 @@ var useRestoreStore = (0, import_zustand4.create)((set) => ({
8396
8456
  }));
8397
8457
 
8398
8458
  // src/internal/components/KeyshareRestoreMenu/hooks/useOnRestoreSuccess.ts
8399
- var import_react25 = require("react");
8400
8459
  function useOnRestoreSuccess() {
8401
8460
  const { config, callbacks } = useLumiaPassportConfig();
8402
8461
  const setIsDialogForced = useLayoutStore((st) => st.setIsDialogForced);
@@ -8534,20 +8593,25 @@ function useCreateBackup() {
8534
8593
  if (!usePasskey && !restorePassword) {
8535
8594
  throw new Error("Please provide a password for the backup");
8536
8595
  }
8537
- return await iframeManager.createBackup(
8538
- passportUserId,
8539
- { method: "server", password: restorePassword },
8540
- jwt.accessToken
8541
- );
8596
+ const navigateToMainMenu = jwt.isNewUser || !hasServerVault;
8597
+ console.log("[BACKUP STATUS] is new user:", jwt.isNewUser, !hasServerVault);
8598
+ return {
8599
+ response: await iframeManager.createBackup(
8600
+ passportUserId,
8601
+ { method: "server", password: restorePassword },
8602
+ jwt.accessToken
8603
+ ),
8604
+ navigateToMainMenu
8605
+ };
8542
8606
  },
8543
- onSuccess: async (response) => {
8607
+ onSuccess: async ({ response, navigateToMainMenu }) => {
8544
8608
  qc.invalidateQueries({ queryKey: [CHECK_BACKUP_QUERY_KEY, address] });
8545
8609
  if (response.success) {
8546
8610
  setSuccess("Successfully created server backup");
8547
8611
  if (typeof window !== "undefined") {
8548
8612
  window.dispatchEvent(
8549
8613
  new CustomEvent("lumia-passport-backup-status-changed", {
8550
- detail: { method: "server", success: true }
8614
+ detail: { method: "server", success: true, navigateToMainMenu }
8551
8615
  })
8552
8616
  );
8553
8617
  }
@@ -9598,6 +9662,12 @@ function KeyshareBackupMenu() {
9598
9662
  (0, import_react33.useEffect)(() => {
9599
9663
  setMainPageHeight(DEFAULT_SETTINGS_MENU_HEIGHT);
9600
9664
  return () => {
9665
+ setSuccess(null);
9666
+ setError(null);
9667
+ setRestoreFile(null);
9668
+ setRestorePassword("");
9669
+ setShowPassword(false);
9670
+ setUsePasskey(false);
9601
9671
  setMethod(null);
9602
9672
  };
9603
9673
  }, []);