@lumiapassport/ui-kit 1.6.2 → 1.7.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.
package/dist/index.d.cts CHANGED
@@ -229,6 +229,66 @@ declare function prepareUserOperation(session: AccountSession$1, callTarget: `0x
229
229
  userOp: UserOperationV07 | UserOperationV06;
230
230
  userOpHash: `0x${string}`;
231
231
  }>;
232
+ /**
233
+ * EIP712 Domain descriptor
234
+ */
235
+ interface TypedDataDomain {
236
+ name?: string;
237
+ version?: string;
238
+ chainId?: number;
239
+ verifyingContract?: `0x${string}`;
240
+ salt?: `0x${string}`;
241
+ }
242
+ /**
243
+ * EIP712 Type definition
244
+ */
245
+ interface TypedDataField {
246
+ name: string;
247
+ type: string;
248
+ }
249
+ /**
250
+ * Parameters for signing typed data (EIP712)
251
+ */
252
+ interface SignTypedDataParams {
253
+ domain: TypedDataDomain;
254
+ types: Record<string, TypedDataField[]>;
255
+ primaryType: string;
256
+ message: Record<string, any>;
257
+ }
258
+ /**
259
+ * Sign typed data according to EIP712 standard.
260
+ * This method computes the EIP712 hash and signs it using MPC.
261
+ *
262
+ * @param session - Account session with signing credentials
263
+ * @param params - EIP712 typed data parameters (domain, types, primaryType, message)
264
+ * @returns Hex-encoded signature
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * const signature = await signTypedData(session, {
269
+ * domain: {
270
+ * name: 'MyApp',
271
+ * version: '1',
272
+ * chainId: 994,
273
+ * verifyingContract: '0x...'
274
+ * },
275
+ * types: {
276
+ * Order: [
277
+ * { name: 'tokenIds', type: 'uint256[]' },
278
+ * { name: 'price', type: 'uint256' },
279
+ * { name: 'deadline', type: 'uint256' }
280
+ * ]
281
+ * },
282
+ * primaryType: 'Order',
283
+ * message: {
284
+ * tokenIds: [1n, 2n, 3n],
285
+ * price: 1000000000000000000n,
286
+ * deadline: 1735689600n
287
+ * }
288
+ * });
289
+ * ```
290
+ */
291
+ declare function signTypedData(session: AccountSession$1, params: SignTypedDataParams): Promise<`0x${string}`>;
232
292
 
233
293
  type AccountSession = AccountSession$1;
234
294
  interface SessionState {
@@ -901,4 +961,4 @@ interface WalletReadyStatus {
901
961
  timestamp: number;
902
962
  }
903
963
 
904
- export { type AccountSession$1 as AccountSession, Address, type AddressProps, type Asset, ConnectWalletButton, type ConnectWalletButtonProps, Hash, type HashProps, KeyshareBackup, LUMIA_EXPLORER_URL, LumiaLogo, type LumiaPassportCallbacks, type LumiaPassportConfig, LumiaPassportProvider, type LumiaPassportProviderProps, LumiaPassportSessionProvider, type LumiaPassportSessionProviderProps, LumiaRainbowKitProvider, type LumiaRainbowKitProviderProps, LumiaSessionProvider, type LumiaSessionProviderProps, LumiaWagmiProvider, type ProviderDetail, type SendTransactionParams, type SendTransactionResult, type Theme, ThemeToggle, type TokenBalance, type Transaction, TransactionsList, type UpdateProfileRequest, type UseSendTransactionReturn, type UseUserOpStatusOptions, type UseUserOpStatusReturn, type UserOpMempool, type UserOpReceipt, type SendTransactionParams$1 as UserOpSendTransactionParams, type UserOpState, UserOpStatus, type UserOpStatusProps, type UserOperation, type UserProfile, type WalletReadyStatus, getUserProfile, lumiaBeam, prepareUserOperation, queryClient, sendUserOperation, updateUserProfile, useAssets, useLumiaPassportConfig, useLumiaPassportLinkedProfiles, useLumiaPassportSession, useLumiaSession, useSendTransaction, useSmartAccountTransactions, useTheme, useTokenBalance, useTokenInfo, useTransactions, useUserOpStatus, wagmiConfig };
964
+ export { type AccountSession$1 as AccountSession, Address, type AddressProps, type Asset, ConnectWalletButton, type ConnectWalletButtonProps, Hash, type HashProps, KeyshareBackup, LUMIA_EXPLORER_URL, LumiaLogo, type LumiaPassportCallbacks, type LumiaPassportConfig, LumiaPassportProvider, type LumiaPassportProviderProps, LumiaPassportSessionProvider, type LumiaPassportSessionProviderProps, LumiaRainbowKitProvider, type LumiaRainbowKitProviderProps, LumiaSessionProvider, type LumiaSessionProviderProps, LumiaWagmiProvider, type ProviderDetail, type SendTransactionParams, type SendTransactionResult, type SignTypedDataParams, type Theme, ThemeToggle, type TokenBalance, type Transaction, TransactionsList, type TypedDataDomain, type TypedDataField, type UpdateProfileRequest, type UseSendTransactionReturn, type UseUserOpStatusOptions, type UseUserOpStatusReturn, type UserOpMempool, type UserOpReceipt, type SendTransactionParams$1 as UserOpSendTransactionParams, type UserOpState, UserOpStatus, type UserOpStatusProps, type UserOperation, type UserProfile, type WalletReadyStatus, getUserProfile, lumiaBeam, prepareUserOperation, queryClient, sendUserOperation, signTypedData, updateUserProfile, useAssets, useLumiaPassportConfig, useLumiaPassportLinkedProfiles, useLumiaPassportSession, useLumiaSession, useSendTransaction, useSmartAccountTransactions, useTheme, useTokenBalance, useTokenInfo, useTransactions, useUserOpStatus, wagmiConfig };
package/dist/index.d.ts CHANGED
@@ -229,6 +229,66 @@ declare function prepareUserOperation(session: AccountSession$1, callTarget: `0x
229
229
  userOp: UserOperationV07 | UserOperationV06;
230
230
  userOpHash: `0x${string}`;
231
231
  }>;
232
+ /**
233
+ * EIP712 Domain descriptor
234
+ */
235
+ interface TypedDataDomain {
236
+ name?: string;
237
+ version?: string;
238
+ chainId?: number;
239
+ verifyingContract?: `0x${string}`;
240
+ salt?: `0x${string}`;
241
+ }
242
+ /**
243
+ * EIP712 Type definition
244
+ */
245
+ interface TypedDataField {
246
+ name: string;
247
+ type: string;
248
+ }
249
+ /**
250
+ * Parameters for signing typed data (EIP712)
251
+ */
252
+ interface SignTypedDataParams {
253
+ domain: TypedDataDomain;
254
+ types: Record<string, TypedDataField[]>;
255
+ primaryType: string;
256
+ message: Record<string, any>;
257
+ }
258
+ /**
259
+ * Sign typed data according to EIP712 standard.
260
+ * This method computes the EIP712 hash and signs it using MPC.
261
+ *
262
+ * @param session - Account session with signing credentials
263
+ * @param params - EIP712 typed data parameters (domain, types, primaryType, message)
264
+ * @returns Hex-encoded signature
265
+ *
266
+ * @example
267
+ * ```typescript
268
+ * const signature = await signTypedData(session, {
269
+ * domain: {
270
+ * name: 'MyApp',
271
+ * version: '1',
272
+ * chainId: 994,
273
+ * verifyingContract: '0x...'
274
+ * },
275
+ * types: {
276
+ * Order: [
277
+ * { name: 'tokenIds', type: 'uint256[]' },
278
+ * { name: 'price', type: 'uint256' },
279
+ * { name: 'deadline', type: 'uint256' }
280
+ * ]
281
+ * },
282
+ * primaryType: 'Order',
283
+ * message: {
284
+ * tokenIds: [1n, 2n, 3n],
285
+ * price: 1000000000000000000n,
286
+ * deadline: 1735689600n
287
+ * }
288
+ * });
289
+ * ```
290
+ */
291
+ declare function signTypedData(session: AccountSession$1, params: SignTypedDataParams): Promise<`0x${string}`>;
232
292
 
233
293
  type AccountSession = AccountSession$1;
234
294
  interface SessionState {
@@ -901,4 +961,4 @@ interface WalletReadyStatus {
901
961
  timestamp: number;
902
962
  }
903
963
 
904
- export { type AccountSession$1 as AccountSession, Address, type AddressProps, type Asset, ConnectWalletButton, type ConnectWalletButtonProps, Hash, type HashProps, KeyshareBackup, LUMIA_EXPLORER_URL, LumiaLogo, type LumiaPassportCallbacks, type LumiaPassportConfig, LumiaPassportProvider, type LumiaPassportProviderProps, LumiaPassportSessionProvider, type LumiaPassportSessionProviderProps, LumiaRainbowKitProvider, type LumiaRainbowKitProviderProps, LumiaSessionProvider, type LumiaSessionProviderProps, LumiaWagmiProvider, type ProviderDetail, type SendTransactionParams, type SendTransactionResult, type Theme, ThemeToggle, type TokenBalance, type Transaction, TransactionsList, type UpdateProfileRequest, type UseSendTransactionReturn, type UseUserOpStatusOptions, type UseUserOpStatusReturn, type UserOpMempool, type UserOpReceipt, type SendTransactionParams$1 as UserOpSendTransactionParams, type UserOpState, UserOpStatus, type UserOpStatusProps, type UserOperation, type UserProfile, type WalletReadyStatus, getUserProfile, lumiaBeam, prepareUserOperation, queryClient, sendUserOperation, updateUserProfile, useAssets, useLumiaPassportConfig, useLumiaPassportLinkedProfiles, useLumiaPassportSession, useLumiaSession, useSendTransaction, useSmartAccountTransactions, useTheme, useTokenBalance, useTokenInfo, useTransactions, useUserOpStatus, wagmiConfig };
964
+ export { type AccountSession$1 as AccountSession, Address, type AddressProps, type Asset, ConnectWalletButton, type ConnectWalletButtonProps, Hash, type HashProps, KeyshareBackup, LUMIA_EXPLORER_URL, LumiaLogo, type LumiaPassportCallbacks, type LumiaPassportConfig, LumiaPassportProvider, type LumiaPassportProviderProps, LumiaPassportSessionProvider, type LumiaPassportSessionProviderProps, LumiaRainbowKitProvider, type LumiaRainbowKitProviderProps, LumiaSessionProvider, type LumiaSessionProviderProps, LumiaWagmiProvider, type ProviderDetail, type SendTransactionParams, type SendTransactionResult, type SignTypedDataParams, type Theme, ThemeToggle, type TokenBalance, type Transaction, TransactionsList, type TypedDataDomain, type TypedDataField, type UpdateProfileRequest, type UseSendTransactionReturn, type UseUserOpStatusOptions, type UseUserOpStatusReturn, type UserOpMempool, type UserOpReceipt, type SendTransactionParams$1 as UserOpSendTransactionParams, type UserOpState, UserOpStatus, type UserOpStatusProps, type UserOperation, type UserProfile, type WalletReadyStatus, getUserProfile, lumiaBeam, prepareUserOperation, queryClient, sendUserOperation, signTypedData, updateUserProfile, useAssets, useLumiaPassportConfig, useLumiaPassportLinkedProfiles, useLumiaPassportSession, useLumiaSession, useSendTransaction, useSmartAccountTransactions, useTheme, useTokenBalance, useTokenInfo, useTransactions, useUserOpStatus, wagmiConfig };
package/dist/index.js CHANGED
@@ -794,7 +794,7 @@ async function signDigestWithMpc(userId, digest32, userOpDetails) {
794
794
  }
795
795
  const transaction = {
796
796
  to: userOpDetails?.callTarget || "0x0000000000000000000000000000000000000000",
797
- value: "0",
797
+ value: userOpDetails?.value || "0",
798
798
  data: userOpDetails?.callData || "0x",
799
799
  digest32,
800
800
  // Pre-computed digest - DO NOT recompute!
@@ -820,6 +820,47 @@ async function signDigestWithMpc(userId, digest32, userOpDetails) {
820
820
  return null;
821
821
  }
822
822
  }
823
+ async function signTypedDataWithMpc(userId, digest32, typedData) {
824
+ const startTime = performance.now();
825
+ currentSigningStats = {
826
+ startTime,
827
+ rounds: []
828
+ };
829
+ try {
830
+ console.log("[signTypedDataWithMpc] Starting EIP712 signature request:", {
831
+ userId,
832
+ primaryType: typedData?.primaryType,
833
+ digest32
834
+ });
835
+ const iframeManager = getIframeManager();
836
+ const { jwtTokenManager: jwtTokenManager3 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
837
+ const accessToken = jwtTokenManager3.getAccessToken();
838
+ if (!accessToken) {
839
+ console.error("[signTypedDataWithMpc] No access token available");
840
+ throw new Error("No access token available for signing");
841
+ }
842
+ console.log("[signTypedDataWithMpc] Calling iframeManager.signTypedData...");
843
+ const signature = await iframeManager.signTypedData(userId, typedData, digest32, accessToken);
844
+ console.log("[signTypedDataWithMpc] Signature received:", signature);
845
+ const endTime = performance.now();
846
+ currentSigningStats.endTime = endTime;
847
+ currentSigningStats.totalDurationMs = endTime - startTime;
848
+ return signature;
849
+ } catch (error) {
850
+ console.error("[signTypedDataWithMpc] Error occurred:", error);
851
+ logSdkError(
852
+ error instanceof Error ? error : new Error("EIP712 MPC signing failed"),
853
+ { userId, primaryType: typedData?.primaryType },
854
+ "iframe-mpc"
855
+ );
856
+ const endTime = performance.now();
857
+ if (currentSigningStats) {
858
+ currentSigningStats.endTime = endTime;
859
+ currentSigningStats.totalDurationMs = endTime - startTime;
860
+ }
861
+ return null;
862
+ }
863
+ }
823
864
  async function checkKeyshare(userId) {
824
865
  try {
825
866
  const iframeManager = getIframeManager();
@@ -2727,6 +2768,32 @@ var init_iframe_manager = __esm({
2727
2768
  }
2728
2769
  throw new Error("Transaction signing failed");
2729
2770
  }
2771
+ /**
2772
+ * Sign EIP712 typed data
2773
+ */
2774
+ async signTypedData(userId, typedData, digest32, accessToken) {
2775
+ console.log("[IframeManager] signTypedData: Sending SIGN_TYPED_DATA message", {
2776
+ userId,
2777
+ primaryType: typedData.primaryType,
2778
+ digest32
2779
+ });
2780
+ const response = await this.sendMessage("SIGN_TYPED_DATA", {
2781
+ userId,
2782
+ projectId: this.projectId,
2783
+ typedData,
2784
+ digest32,
2785
+ accessToken
2786
+ // Pass access token for TSS API authentication
2787
+ });
2788
+ console.log("[IframeManager] signTypedData: Response received", {
2789
+ type: response.type,
2790
+ hasSignature: !!response.signature
2791
+ });
2792
+ if (response.type === "LUMIA_PASSPORT_EIP712_SIGNATURE") {
2793
+ return response.signature;
2794
+ }
2795
+ throw new Error("EIP712 signing failed");
2796
+ }
2730
2797
  /**
2731
2798
  * Get user's wallet address
2732
2799
  */
@@ -5001,7 +5068,7 @@ var init_akHelpers = __esm({
5001
5068
  });
5002
5069
 
5003
5070
  // src/internal/clients/account.ts
5004
- import { parseEther, encodeFunctionData, createWalletClient, http as http3 } from "viem";
5071
+ import { parseEther, encodeFunctionData, createWalletClient, http as http3, hashTypedData } from "viem";
5005
5072
  import { entryPoint07Abi } from "viem/account-abstraction";
5006
5073
  import { privateKeyToAccount } from "viem/accounts";
5007
5074
  import {
@@ -5248,8 +5315,10 @@ async function sendUserOperation(session, callTarget, amountWei, innerData = "0x
5248
5315
  paymaster: userOp.paymaster,
5249
5316
  factory: userOp.factory,
5250
5317
  factoryData: userOp.factoryData,
5251
- callTarget
5318
+ callTarget,
5252
5319
  // Add callTarget so iframe can display "To" address
5320
+ value: amountWei
5321
+ // Add value so iframe can display transaction amount
5253
5322
  });
5254
5323
  if (!mpcSig) throw new Error("MPC signing failed");
5255
5324
  signature = mpcSig;
@@ -5498,6 +5567,61 @@ async function getEntryPointDeposit(address, entryPointVersion = "v0.7") {
5498
5567
  const depositAbi = [{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "account", type: "address" }], outputs: [{ name: "", type: "uint256" }] }];
5499
5568
  return await publicClient.readContract({ address: entryPointAddress, abi: depositAbi, functionName: "balanceOf", args: [address] });
5500
5569
  }
5570
+ async function signTypedData(session, params) {
5571
+ const { domain, types, primaryType, message } = params;
5572
+ const digest = hashTypedData({
5573
+ domain,
5574
+ types,
5575
+ primaryType,
5576
+ message
5577
+ });
5578
+ const serializeForIframe = (obj) => {
5579
+ if (typeof obj === "bigint") {
5580
+ return obj.toString();
5581
+ }
5582
+ if (Array.isArray(obj)) {
5583
+ return obj.map(serializeForIframe);
5584
+ }
5585
+ if (obj !== null && typeof obj === "object") {
5586
+ const result = {};
5587
+ for (const key in obj) {
5588
+ result[key] = serializeForIframe(obj[key]);
5589
+ }
5590
+ return result;
5591
+ }
5592
+ return obj;
5593
+ };
5594
+ let signature;
5595
+ if (session.mpcUserId) {
5596
+ const mpcSig = await signTypedDataWithMpc(
5597
+ session.mpcUserId,
5598
+ digest,
5599
+ {
5600
+ domain: {
5601
+ name: domain.name,
5602
+ version: domain.version,
5603
+ chainId: domain.chainId,
5604
+ verifyingContract: domain.verifyingContract,
5605
+ salt: domain.salt
5606
+ },
5607
+ types,
5608
+ primaryType,
5609
+ message: serializeForIframe(message)
5610
+ }
5611
+ );
5612
+ if (!mpcSig) {
5613
+ throw new Error("MPC signing failed");
5614
+ }
5615
+ signature = mpcSig;
5616
+ } else if (session.ownerPrivateKey) {
5617
+ const account = privateKeyToAccount(session.ownerPrivateKey);
5618
+ const rawSig = await account.sign({ hash: digest });
5619
+ signature = normalizeSignature(rawSig);
5620
+ } else {
5621
+ throw new Error("No signing method available");
5622
+ }
5623
+ return signature;
5624
+ }
5501
5625
  var PAYMASTER_VERIFICATION_GAS_LIMIT, PAYMASTER_POSTOP_GAS_LIMIT, MAX_BUNDLER_VERIFICATION_GAS, PAYMASTER_VERIFICATION_GAS, executeAbi;
5502
5626
  var init_account = __esm({
5503
5627
  "src/internal/clients/account.ts"() {
@@ -5590,6 +5714,7 @@ __export(clients_exports, {
5590
5714
  sendDemoUserOp: () => sendDemoUserOp,
5591
5715
  sendLumiaUserOp: () => sendLumiaUserOp,
5592
5716
  sendUserOperation: () => sendUserOperation,
5717
+ signTypedData: () => signTypedData,
5593
5718
  viemBundlerClient: () => viemBundlerClient
5594
5719
  });
5595
5720
  var init_clients = __esm({
@@ -8508,7 +8633,7 @@ function useLumiaPassportLinkedProfiles() {
8508
8633
  // package.json
8509
8634
  var package_default = {
8510
8635
  name: "@lumiapassport/ui-kit",
8511
- version: "1.6.2",
8636
+ version: "1.7.0",
8512
8637
  description: "React UI components and hooks for Lumia Passport authentication and Account Abstraction",
8513
8638
  type: "module",
8514
8639
  main: "./dist/index.cjs",
@@ -10076,6 +10201,7 @@ export {
10076
10201
  prepareUserOperation,
10077
10202
  queryClient,
10078
10203
  sendUserOperation,
10204
+ signTypedData,
10079
10205
  updateUserProfile,
10080
10206
  useAssets,
10081
10207
  useLumiaPassportConfig,