@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/README.md +73 -0
- package/dist/iframe/index.html +220 -1
- package/dist/iframe/main.js +238 -4
- package/dist/iframe/main.js.map +1 -1
- package/dist/index.cjs +130 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -1
- package/dist/index.d.ts +61 -1
- package/dist/index.js +130 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -805,7 +805,7 @@ async function signDigestWithMpc(userId, digest32, userOpDetails) {
|
|
|
805
805
|
}
|
|
806
806
|
const transaction = {
|
|
807
807
|
to: userOpDetails?.callTarget || "0x0000000000000000000000000000000000000000",
|
|
808
|
-
value: "0",
|
|
808
|
+
value: userOpDetails?.value || "0",
|
|
809
809
|
data: userOpDetails?.callData || "0x",
|
|
810
810
|
digest32,
|
|
811
811
|
// Pre-computed digest - DO NOT recompute!
|
|
@@ -831,6 +831,47 @@ async function signDigestWithMpc(userId, digest32, userOpDetails) {
|
|
|
831
831
|
return null;
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
|
+
async function signTypedDataWithMpc(userId, digest32, typedData) {
|
|
835
|
+
const startTime = performance.now();
|
|
836
|
+
currentSigningStats = {
|
|
837
|
+
startTime,
|
|
838
|
+
rounds: []
|
|
839
|
+
};
|
|
840
|
+
try {
|
|
841
|
+
console.log("[signTypedDataWithMpc] Starting EIP712 signature request:", {
|
|
842
|
+
userId,
|
|
843
|
+
primaryType: typedData?.primaryType,
|
|
844
|
+
digest32
|
|
845
|
+
});
|
|
846
|
+
const iframeManager = getIframeManager();
|
|
847
|
+
const { jwtTokenManager: jwtTokenManager3 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
848
|
+
const accessToken = jwtTokenManager3.getAccessToken();
|
|
849
|
+
if (!accessToken) {
|
|
850
|
+
console.error("[signTypedDataWithMpc] No access token available");
|
|
851
|
+
throw new Error("No access token available for signing");
|
|
852
|
+
}
|
|
853
|
+
console.log("[signTypedDataWithMpc] Calling iframeManager.signTypedData...");
|
|
854
|
+
const signature = await iframeManager.signTypedData(userId, typedData, digest32, accessToken);
|
|
855
|
+
console.log("[signTypedDataWithMpc] Signature received:", signature);
|
|
856
|
+
const endTime = performance.now();
|
|
857
|
+
currentSigningStats.endTime = endTime;
|
|
858
|
+
currentSigningStats.totalDurationMs = endTime - startTime;
|
|
859
|
+
return signature;
|
|
860
|
+
} catch (error) {
|
|
861
|
+
console.error("[signTypedDataWithMpc] Error occurred:", error);
|
|
862
|
+
(0, import_error_tracking.logSdkError)(
|
|
863
|
+
error instanceof Error ? error : new Error("EIP712 MPC signing failed"),
|
|
864
|
+
{ userId, primaryType: typedData?.primaryType },
|
|
865
|
+
"iframe-mpc"
|
|
866
|
+
);
|
|
867
|
+
const endTime = performance.now();
|
|
868
|
+
if (currentSigningStats) {
|
|
869
|
+
currentSigningStats.endTime = endTime;
|
|
870
|
+
currentSigningStats.totalDurationMs = endTime - startTime;
|
|
871
|
+
}
|
|
872
|
+
return null;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
834
875
|
async function checkKeyshare(userId) {
|
|
835
876
|
try {
|
|
836
877
|
const iframeManager = getIframeManager();
|
|
@@ -2726,6 +2767,32 @@ var init_iframe_manager = __esm({
|
|
|
2726
2767
|
}
|
|
2727
2768
|
throw new Error("Transaction signing failed");
|
|
2728
2769
|
}
|
|
2770
|
+
/**
|
|
2771
|
+
* Sign EIP712 typed data
|
|
2772
|
+
*/
|
|
2773
|
+
async signTypedData(userId, typedData, digest32, accessToken) {
|
|
2774
|
+
console.log("[IframeManager] signTypedData: Sending SIGN_TYPED_DATA message", {
|
|
2775
|
+
userId,
|
|
2776
|
+
primaryType: typedData.primaryType,
|
|
2777
|
+
digest32
|
|
2778
|
+
});
|
|
2779
|
+
const response = await this.sendMessage("SIGN_TYPED_DATA", {
|
|
2780
|
+
userId,
|
|
2781
|
+
projectId: this.projectId,
|
|
2782
|
+
typedData,
|
|
2783
|
+
digest32,
|
|
2784
|
+
accessToken
|
|
2785
|
+
// Pass access token for TSS API authentication
|
|
2786
|
+
});
|
|
2787
|
+
console.log("[IframeManager] signTypedData: Response received", {
|
|
2788
|
+
type: response.type,
|
|
2789
|
+
hasSignature: !!response.signature
|
|
2790
|
+
});
|
|
2791
|
+
if (response.type === "LUMIA_PASSPORT_EIP712_SIGNATURE") {
|
|
2792
|
+
return response.signature;
|
|
2793
|
+
}
|
|
2794
|
+
throw new Error("EIP712 signing failed");
|
|
2795
|
+
}
|
|
2729
2796
|
/**
|
|
2730
2797
|
* Get user's wallet address
|
|
2731
2798
|
*/
|
|
@@ -5241,8 +5308,10 @@ async function sendUserOperation(session, callTarget, amountWei, innerData = "0x
|
|
|
5241
5308
|
paymaster: userOp.paymaster,
|
|
5242
5309
|
factory: userOp.factory,
|
|
5243
5310
|
factoryData: userOp.factoryData,
|
|
5244
|
-
callTarget
|
|
5311
|
+
callTarget,
|
|
5245
5312
|
// Add callTarget so iframe can display "To" address
|
|
5313
|
+
value: amountWei
|
|
5314
|
+
// Add value so iframe can display transaction amount
|
|
5246
5315
|
});
|
|
5247
5316
|
if (!mpcSig) throw new Error("MPC signing failed");
|
|
5248
5317
|
signature = mpcSig;
|
|
@@ -5491,6 +5560,61 @@ async function getEntryPointDeposit(address, entryPointVersion = "v0.7") {
|
|
|
5491
5560
|
const depositAbi = [{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "account", type: "address" }], outputs: [{ name: "", type: "uint256" }] }];
|
|
5492
5561
|
return await publicClient.readContract({ address: entryPointAddress, abi: depositAbi, functionName: "balanceOf", args: [address] });
|
|
5493
5562
|
}
|
|
5563
|
+
async function signTypedData(session, params) {
|
|
5564
|
+
const { domain, types, primaryType, message } = params;
|
|
5565
|
+
const digest = (0, import_viem3.hashTypedData)({
|
|
5566
|
+
domain,
|
|
5567
|
+
types,
|
|
5568
|
+
primaryType,
|
|
5569
|
+
message
|
|
5570
|
+
});
|
|
5571
|
+
const serializeForIframe = (obj) => {
|
|
5572
|
+
if (typeof obj === "bigint") {
|
|
5573
|
+
return obj.toString();
|
|
5574
|
+
}
|
|
5575
|
+
if (Array.isArray(obj)) {
|
|
5576
|
+
return obj.map(serializeForIframe);
|
|
5577
|
+
}
|
|
5578
|
+
if (obj !== null && typeof obj === "object") {
|
|
5579
|
+
const result = {};
|
|
5580
|
+
for (const key in obj) {
|
|
5581
|
+
result[key] = serializeForIframe(obj[key]);
|
|
5582
|
+
}
|
|
5583
|
+
return result;
|
|
5584
|
+
}
|
|
5585
|
+
return obj;
|
|
5586
|
+
};
|
|
5587
|
+
let signature;
|
|
5588
|
+
if (session.mpcUserId) {
|
|
5589
|
+
const mpcSig = await signTypedDataWithMpc(
|
|
5590
|
+
session.mpcUserId,
|
|
5591
|
+
digest,
|
|
5592
|
+
{
|
|
5593
|
+
domain: {
|
|
5594
|
+
name: domain.name,
|
|
5595
|
+
version: domain.version,
|
|
5596
|
+
chainId: domain.chainId,
|
|
5597
|
+
verifyingContract: domain.verifyingContract,
|
|
5598
|
+
salt: domain.salt
|
|
5599
|
+
},
|
|
5600
|
+
types,
|
|
5601
|
+
primaryType,
|
|
5602
|
+
message: serializeForIframe(message)
|
|
5603
|
+
}
|
|
5604
|
+
);
|
|
5605
|
+
if (!mpcSig) {
|
|
5606
|
+
throw new Error("MPC signing failed");
|
|
5607
|
+
}
|
|
5608
|
+
signature = mpcSig;
|
|
5609
|
+
} else if (session.ownerPrivateKey) {
|
|
5610
|
+
const account = (0, import_accounts.privateKeyToAccount)(session.ownerPrivateKey);
|
|
5611
|
+
const rawSig = await account.sign({ hash: digest });
|
|
5612
|
+
signature = normalizeSignature(rawSig);
|
|
5613
|
+
} else {
|
|
5614
|
+
throw new Error("No signing method available");
|
|
5615
|
+
}
|
|
5616
|
+
return signature;
|
|
5617
|
+
}
|
|
5494
5618
|
var import_viem3, import_account_abstraction2, import_accounts, import_bundler, import_meta, PAYMASTER_VERIFICATION_GAS_LIMIT, PAYMASTER_POSTOP_GAS_LIMIT, MAX_BUNDLER_VERIFICATION_GAS, PAYMASTER_VERIFICATION_GAS, executeAbi;
|
|
5495
5619
|
var init_account = __esm({
|
|
5496
5620
|
"src/internal/clients/account.ts"() {
|
|
@@ -5588,6 +5712,7 @@ __export(clients_exports, {
|
|
|
5588
5712
|
sendDemoUserOp: () => sendDemoUserOp,
|
|
5589
5713
|
sendLumiaUserOp: () => sendLumiaUserOp,
|
|
5590
5714
|
sendUserOperation: () => sendUserOperation,
|
|
5715
|
+
signTypedData: () => signTypedData,
|
|
5591
5716
|
viemBundlerClient: () => viemBundlerClient
|
|
5592
5717
|
});
|
|
5593
5718
|
var init_clients = __esm({
|
|
@@ -5620,6 +5745,7 @@ __export(index_exports, {
|
|
|
5620
5745
|
prepareUserOperation: () => prepareUserOperation,
|
|
5621
5746
|
queryClient: () => queryClient,
|
|
5622
5747
|
sendUserOperation: () => sendUserOperation,
|
|
5748
|
+
signTypedData: () => signTypedData,
|
|
5623
5749
|
updateUserProfile: () => updateUserProfile,
|
|
5624
5750
|
useAssets: () => useAssets,
|
|
5625
5751
|
useLumiaPassportConfig: () => useLumiaPassportConfig,
|
|
@@ -8536,7 +8662,7 @@ function useLumiaPassportLinkedProfiles() {
|
|
|
8536
8662
|
// package.json
|
|
8537
8663
|
var package_default = {
|
|
8538
8664
|
name: "@lumiapassport/ui-kit",
|
|
8539
|
-
version: "1.
|
|
8665
|
+
version: "1.7.0",
|
|
8540
8666
|
description: "React UI components and hooks for Lumia Passport authentication and Account Abstraction",
|
|
8541
8667
|
type: "module",
|
|
8542
8668
|
main: "./dist/index.cjs",
|
|
@@ -10105,6 +10231,7 @@ function useSmartAccountTransactions() {
|
|
|
10105
10231
|
prepareUserOperation,
|
|
10106
10232
|
queryClient,
|
|
10107
10233
|
sendUserOperation,
|
|
10234
|
+
signTypedData,
|
|
10108
10235
|
updateUserProfile,
|
|
10109
10236
|
useAssets,
|
|
10110
10237
|
useLumiaPassportConfig,
|