@lumiapassport/ui-kit 1.6.3 → 1.8.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.cjs CHANGED
@@ -438,6 +438,7 @@ async function beginPasskeyAuthentication(username) {
438
438
  {
439
439
  method: "POST",
440
440
  headers: { "Content-Type": "application/json" },
441
+ credentials: "include",
441
442
  body: JSON.stringify({ username })
442
443
  }
443
444
  );
@@ -481,6 +482,7 @@ async function completePasskeyAuthentication(challengeId, credential, options) {
481
482
  {
482
483
  method: "POST",
483
484
  headers: { "Content-Type": "application/json" },
485
+ credentials: "include",
484
486
  body: JSON.stringify({ challengeId, credential: credentialData })
485
487
  }
486
488
  );
@@ -510,6 +512,7 @@ async function beginPasskeyRegistration(username) {
510
512
  {
511
513
  method: "POST",
512
514
  headers: { "Content-Type": "application/json" },
515
+ credentials: "include",
513
516
  body: JSON.stringify({ username })
514
517
  }
515
518
  );
@@ -553,6 +556,7 @@ async function completePasskeyRegistration(challengeId, credential, options) {
553
556
  {
554
557
  method: "POST",
555
558
  headers: { "Content-Type": "application/json" },
559
+ credentials: "include",
556
560
  body: JSON.stringify({ challengeId, credential: credentialData })
557
561
  }
558
562
  );
@@ -805,7 +809,7 @@ async function signDigestWithMpc(userId, digest32, userOpDetails) {
805
809
  }
806
810
  const transaction = {
807
811
  to: userOpDetails?.callTarget || "0x0000000000000000000000000000000000000000",
808
- value: "0",
812
+ value: userOpDetails?.value || "0",
809
813
  data: userOpDetails?.callData || "0x",
810
814
  digest32,
811
815
  // Pre-computed digest - DO NOT recompute!
@@ -831,6 +835,47 @@ async function signDigestWithMpc(userId, digest32, userOpDetails) {
831
835
  return null;
832
836
  }
833
837
  }
838
+ async function signTypedDataWithMpc(userId, digest32, typedData) {
839
+ const startTime = performance.now();
840
+ currentSigningStats = {
841
+ startTime,
842
+ rounds: []
843
+ };
844
+ try {
845
+ console.log("[signTypedDataWithMpc] Starting EIP712 signature request:", {
846
+ userId,
847
+ primaryType: typedData?.primaryType,
848
+ digest32
849
+ });
850
+ const iframeManager = getIframeManager();
851
+ const { jwtTokenManager: jwtTokenManager3 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
852
+ const accessToken = jwtTokenManager3.getAccessToken();
853
+ if (!accessToken) {
854
+ console.error("[signTypedDataWithMpc] No access token available");
855
+ throw new Error("No access token available for signing");
856
+ }
857
+ console.log("[signTypedDataWithMpc] Calling iframeManager.signTypedData...");
858
+ const signature = await iframeManager.signTypedData(userId, typedData, digest32, accessToken);
859
+ console.log("[signTypedDataWithMpc] Signature received:", signature);
860
+ const endTime = performance.now();
861
+ currentSigningStats.endTime = endTime;
862
+ currentSigningStats.totalDurationMs = endTime - startTime;
863
+ return signature;
864
+ } catch (error) {
865
+ console.error("[signTypedDataWithMpc] Error occurred:", error);
866
+ (0, import_error_tracking.logSdkError)(
867
+ error instanceof Error ? error : new Error("EIP712 MPC signing failed"),
868
+ { userId, primaryType: typedData?.primaryType },
869
+ "iframe-mpc"
870
+ );
871
+ const endTime = performance.now();
872
+ if (currentSigningStats) {
873
+ currentSigningStats.endTime = endTime;
874
+ currentSigningStats.totalDurationMs = endTime - startTime;
875
+ }
876
+ return null;
877
+ }
878
+ }
834
879
  async function checkKeyshare(userId) {
835
880
  try {
836
881
  const iframeManager = getIframeManager();
@@ -884,7 +929,9 @@ var init_httpClient = __esm({
884
929
  }
885
930
  const requestConfig = {
886
931
  method,
887
- headers: requestHeaders
932
+ headers: requestHeaders,
933
+ credentials: "include"
934
+ // Enable cookies for cross-origin requests
888
935
  };
889
936
  if (body && method !== "GET") {
890
937
  requestConfig.body = typeof body === "string" ? body : JSON.stringify(body);
@@ -1145,7 +1192,8 @@ var init_cloudStorage = __esm({
1145
1192
  const searchResponse = await fetch(
1146
1193
  `https://www.googleapis.com/drive/v3/files?q=name='${folderName}' and mimeType='application/vnd.google-apps.folder' and trashed=false`,
1147
1194
  {
1148
- headers: { Authorization: `Bearer ${this.accessToken}` }
1195
+ headers: { Authorization: `Bearer ${this.accessToken}` },
1196
+ credentials: "include"
1149
1197
  }
1150
1198
  );
1151
1199
  if (!searchResponse.ok) {
@@ -1161,6 +1209,7 @@ var init_cloudStorage = __esm({
1161
1209
  Authorization: `Bearer ${this.accessToken}`,
1162
1210
  "Content-Type": "application/json"
1163
1211
  },
1212
+ credentials: "include",
1164
1213
  body: JSON.stringify({
1165
1214
  name: folderName,
1166
1215
  mimeType: "application/vnd.google-apps.folder"
@@ -1183,6 +1232,7 @@ var init_cloudStorage = __esm({
1183
1232
  headers: {
1184
1233
  Authorization: `Bearer ${this.accessToken}`
1185
1234
  },
1235
+ credentials: "include",
1186
1236
  body: form
1187
1237
  }
1188
1238
  );
@@ -1266,7 +1316,7 @@ async function getShareVaultToken(scopes) {
1266
1316
  async function getShareRecoveryStats() {
1267
1317
  try {
1268
1318
  const token = await getShareVaultToken(["share:get"]);
1269
- const response = await fetch(`${getShareVaultUrl()}/v1/shares/me/recovery/stats`, { method: "GET", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json" } });
1319
+ const response = await fetch(`${getShareVaultUrl()}/v1/shares/me/recovery/stats`, { method: "GET", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json" }, credentials: "include" });
1270
1320
  if (response.status === 404) return null;
1271
1321
  if (!response.ok) return null;
1272
1322
  return await response.json();
@@ -1276,26 +1326,26 @@ async function getShareRecoveryStats() {
1276
1326
  }
1277
1327
  async function getShare() {
1278
1328
  const token = await getShareVaultToken(["share:get"]);
1279
- const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "GET", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json" } });
1329
+ const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "GET", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json" }, credentials: "include" });
1280
1330
  if (response.status === 404) return null;
1281
1331
  if (!response.ok) throw new Error(`Failed to fetch share: ${response.status} ${response.statusText}`);
1282
1332
  return await response.json();
1283
1333
  }
1284
1334
  async function uploadShare(share, idempotencyKey) {
1285
1335
  const token = await getShareVaultToken(["share:put"]);
1286
- const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "PUT", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey }, body: JSON.stringify(share) });
1336
+ const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "PUT", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey }, credentials: "include", body: JSON.stringify(share) });
1287
1337
  if (!response.ok) throw new Error(`Failed to upload share: ${response.status} ${response.statusText}`);
1288
1338
  return await response.json();
1289
1339
  }
1290
1340
  async function rewrapShare(payload, idempotencyKey) {
1291
1341
  const token = await getShareVaultToken(["share:rewrap"]);
1292
- const response = await fetch(`${getShareVaultUrl()}/v1/shares/me/rewrap`, { method: "POST", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey }, body: JSON.stringify(payload) });
1342
+ const response = await fetch(`${getShareVaultUrl()}/v1/shares/me/rewrap`, { method: "POST", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json", "Idempotency-Key": idempotencyKey }, credentials: "include", body: JSON.stringify(payload) });
1293
1343
  if (!response.ok) throw new Error(`Failed to rewrap share: ${response.status} ${response.statusText}`);
1294
1344
  return await response.json();
1295
1345
  }
1296
1346
  async function deleteShare() {
1297
1347
  const token = await getShareVaultToken(["share:delete"]);
1298
- const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "DELETE", headers: { Authorization: `Bearer ${token.token}` } });
1348
+ const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "DELETE", headers: { Authorization: `Bearer ${token.token}` }, credentials: "include" });
1299
1349
  if (!response.ok && response.status !== 404) throw new Error(`Failed to delete share: ${response.status} ${response.statusText}`);
1300
1350
  }
1301
1351
  async function deriveKEKFromPasskey(userId, requiredCredentialId) {
@@ -1472,7 +1522,7 @@ function clearBackupStatus(userId) {
1472
1522
  async function checkServerBackupAvailability() {
1473
1523
  try {
1474
1524
  const token = await getShareVaultToken(["share:get"]);
1475
- const response = await fetch(`${getShareVaultUrl()}/v1/shares/me/recovery/stats`, { method: "GET", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json" } });
1525
+ const response = await fetch(`${getShareVaultUrl()}/v1/shares/me/recovery/stats`, { method: "GET", headers: { Authorization: `Bearer ${token.token}`, "Content-Type": "application/json" }, credentials: "include" });
1476
1526
  if (response.status === 404) return { hasBackup: false, serviceAvailable: true };
1477
1527
  if (!response.ok) return { hasBackup: false, serviceAvailable: false };
1478
1528
  return { hasBackup: true, serviceAvailable: true };
@@ -1482,14 +1532,14 @@ async function checkServerBackupAvailability() {
1482
1532
  }
1483
1533
  async function uploadShareToVault(envelope, token) {
1484
1534
  const idempotencyKey = crypto.randomUUID ? crypto.randomUUID() : `backup-${Date.now()}`;
1485
- const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "PUT", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, "Idempotency-Key": idempotencyKey }, body: JSON.stringify(envelope) });
1535
+ const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "PUT", headers: { "Content-Type": "application/json", Authorization: `Bearer ${token}`, "Idempotency-Key": idempotencyKey }, credentials: "include", body: JSON.stringify(envelope) });
1486
1536
  if (!response.ok) {
1487
1537
  const errorText = await response.text();
1488
1538
  throw new Error(`Failed to upload share: ${response.status} ${response.statusText} - ${errorText}`);
1489
1539
  }
1490
1540
  }
1491
1541
  async function downloadShareFromVault(token) {
1492
- const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "GET", headers: { Authorization: `Bearer ${token}`, "X-Client-Device-Id": "lumia-ui-kit", "X-Client-Device-Name": "Lumia UI Kit" } });
1542
+ const response = await fetch(`${getShareVaultUrl()}/v1/shares/me`, { method: "GET", headers: { Authorization: `Bearer ${token}`, "X-Client-Device-Id": "lumia-ui-kit", "X-Client-Device-Name": "Lumia UI Kit" }, credentials: "include" });
1493
1543
  if (!response.ok) {
1494
1544
  if (response.status === 404) throw new Error("No backup found on server for this user");
1495
1545
  const errorText = await response.text();
@@ -2726,6 +2776,32 @@ var init_iframe_manager = __esm({
2726
2776
  }
2727
2777
  throw new Error("Transaction signing failed");
2728
2778
  }
2779
+ /**
2780
+ * Sign EIP712 typed data
2781
+ */
2782
+ async signTypedData(userId, typedData, digest32, accessToken) {
2783
+ console.log("[IframeManager] signTypedData: Sending SIGN_TYPED_DATA message", {
2784
+ userId,
2785
+ primaryType: typedData.primaryType,
2786
+ digest32
2787
+ });
2788
+ const response = await this.sendMessage("SIGN_TYPED_DATA", {
2789
+ userId,
2790
+ projectId: this.projectId,
2791
+ typedData,
2792
+ digest32,
2793
+ accessToken
2794
+ // Pass access token for TSS API authentication
2795
+ });
2796
+ console.log("[IframeManager] signTypedData: Response received", {
2797
+ type: response.type,
2798
+ hasSignature: !!response.signature
2799
+ });
2800
+ if (response.type === "LUMIA_PASSPORT_EIP712_SIGNATURE") {
2801
+ return response.signature;
2802
+ }
2803
+ throw new Error("EIP712 signing failed");
2804
+ }
2729
2805
  /**
2730
2806
  * Get user's wallet address
2731
2807
  */
@@ -4300,6 +4376,7 @@ var init_AuthModal = __esm({
4300
4376
  headers: {
4301
4377
  "Content-Type": "application/json"
4302
4378
  },
4379
+ credentials: "include",
4303
4380
  body: JSON.stringify({
4304
4381
  email,
4305
4382
  purpose: "login"
@@ -4417,6 +4494,7 @@ var init_AuthModal = __esm({
4417
4494
  headers: {
4418
4495
  "Content-Type": "application/json"
4419
4496
  },
4497
+ credentials: "include",
4420
4498
  body: JSON.stringify({
4421
4499
  email,
4422
4500
  purpose: "login"
@@ -5241,8 +5319,10 @@ async function sendUserOperation(session, callTarget, amountWei, innerData = "0x
5241
5319
  paymaster: userOp.paymaster,
5242
5320
  factory: userOp.factory,
5243
5321
  factoryData: userOp.factoryData,
5244
- callTarget
5322
+ callTarget,
5245
5323
  // Add callTarget so iframe can display "To" address
5324
+ value: amountWei
5325
+ // Add value so iframe can display transaction amount
5246
5326
  });
5247
5327
  if (!mpcSig) throw new Error("MPC signing failed");
5248
5328
  signature = mpcSig;
@@ -5491,6 +5571,61 @@ async function getEntryPointDeposit(address, entryPointVersion = "v0.7") {
5491
5571
  const depositAbi = [{ type: "function", name: "balanceOf", stateMutability: "view", inputs: [{ name: "account", type: "address" }], outputs: [{ name: "", type: "uint256" }] }];
5492
5572
  return await publicClient.readContract({ address: entryPointAddress, abi: depositAbi, functionName: "balanceOf", args: [address] });
5493
5573
  }
5574
+ async function signTypedData(session, params) {
5575
+ const { domain, types, primaryType, message } = params;
5576
+ const digest = (0, import_viem3.hashTypedData)({
5577
+ domain,
5578
+ types,
5579
+ primaryType,
5580
+ message
5581
+ });
5582
+ const serializeForIframe = (obj) => {
5583
+ if (typeof obj === "bigint") {
5584
+ return obj.toString();
5585
+ }
5586
+ if (Array.isArray(obj)) {
5587
+ return obj.map(serializeForIframe);
5588
+ }
5589
+ if (obj !== null && typeof obj === "object") {
5590
+ const result = {};
5591
+ for (const key in obj) {
5592
+ result[key] = serializeForIframe(obj[key]);
5593
+ }
5594
+ return result;
5595
+ }
5596
+ return obj;
5597
+ };
5598
+ let signature;
5599
+ if (session.mpcUserId) {
5600
+ const mpcSig = await signTypedDataWithMpc(
5601
+ session.mpcUserId,
5602
+ digest,
5603
+ {
5604
+ domain: {
5605
+ name: domain.name,
5606
+ version: domain.version,
5607
+ chainId: domain.chainId,
5608
+ verifyingContract: domain.verifyingContract,
5609
+ salt: domain.salt
5610
+ },
5611
+ types,
5612
+ primaryType,
5613
+ message: serializeForIframe(message)
5614
+ }
5615
+ );
5616
+ if (!mpcSig) {
5617
+ throw new Error("MPC signing failed");
5618
+ }
5619
+ signature = mpcSig;
5620
+ } else if (session.ownerPrivateKey) {
5621
+ const account = (0, import_accounts.privateKeyToAccount)(session.ownerPrivateKey);
5622
+ const rawSig = await account.sign({ hash: digest });
5623
+ signature = normalizeSignature(rawSig);
5624
+ } else {
5625
+ throw new Error("No signing method available");
5626
+ }
5627
+ return signature;
5628
+ }
5494
5629
  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
5630
  var init_account = __esm({
5496
5631
  "src/internal/clients/account.ts"() {
@@ -5588,6 +5723,7 @@ __export(clients_exports, {
5588
5723
  sendDemoUserOp: () => sendDemoUserOp,
5589
5724
  sendLumiaUserOp: () => sendLumiaUserOp,
5590
5725
  sendUserOperation: () => sendUserOperation,
5726
+ signTypedData: () => signTypedData,
5591
5727
  viemBundlerClient: () => viemBundlerClient
5592
5728
  });
5593
5729
  var init_clients = __esm({
@@ -5620,6 +5756,7 @@ __export(index_exports, {
5620
5756
  prepareUserOperation: () => prepareUserOperation,
5621
5757
  queryClient: () => queryClient,
5622
5758
  sendUserOperation: () => sendUserOperation,
5759
+ signTypedData: () => signTypedData,
5623
5760
  updateUserProfile: () => updateUserProfile,
5624
5761
  useAssets: () => useAssets,
5625
5762
  useLumiaPassportConfig: () => useLumiaPassportConfig,
@@ -7124,7 +7261,7 @@ var TransactionsModal = ({ open, onOpenChange, onBack }) => {
7124
7261
  const explorerUrl = getExplorerUrl();
7125
7262
  const baseUrl = explorerUrl.replace(/\/$/, "");
7126
7263
  const apiUrl = `${baseUrl}/api/v2/addresses/${address}/transactions?items_count=20`;
7127
- const response = await fetch(apiUrl);
7264
+ const response = await fetch(apiUrl, { credentials: "include" });
7128
7265
  if (!response.ok) {
7129
7266
  throw new Error(`Failed to fetch transactions: ${response.status}`);
7130
7267
  }
@@ -7771,6 +7908,7 @@ var UserOpStatus = ({
7771
7908
  const res = await fetch(getBundlerUrl(), {
7772
7909
  method: "POST",
7773
7910
  headers: { "content-type": "application/json" },
7911
+ credentials: "include",
7774
7912
  body: JSON.stringify(body)
7775
7913
  });
7776
7914
  const json = await res.json();
@@ -8536,7 +8674,7 @@ function useLumiaPassportLinkedProfiles() {
8536
8674
  // package.json
8537
8675
  var package_default = {
8538
8676
  name: "@lumiapassport/ui-kit",
8539
- version: "1.6.3",
8677
+ version: "1.8.0",
8540
8678
  description: "React UI components and hooks for Lumia Passport authentication and Account Abstraction",
8541
8679
  type: "module",
8542
8680
  main: "./dist/index.cjs",
@@ -9654,7 +9792,7 @@ var TransactionsList = ({
9654
9792
  const baseUrl = explorerUrl.replace(/\/$/, "");
9655
9793
  const apiUrl = `${baseUrl}/api/v2/addresses/${address}/transactions?items_count=${itemsCount}`;
9656
9794
  console.log("[TransactionsList] Fetching from:", apiUrl);
9657
- const response = await fetch(apiUrl);
9795
+ const response = await fetch(apiUrl, { credentials: "include" });
9658
9796
  if (!response.ok) {
9659
9797
  throw new Error(`Failed to fetch transactions: ${response.status}`);
9660
9798
  }
@@ -9798,6 +9936,7 @@ function useUserOpStatus(options = {}) {
9798
9936
  const res = await fetch(getBundlerUrl(), {
9799
9937
  method: "POST",
9800
9938
  headers: { "content-type": "application/json" },
9939
+ credentials: "include",
9801
9940
  body: JSON.stringify(body)
9802
9941
  });
9803
9942
  const json = await res.json();
@@ -10105,6 +10244,7 @@ function useSmartAccountTransactions() {
10105
10244
  prepareUserOperation,
10106
10245
  queryClient,
10107
10246
  sendUserOperation,
10247
+ signTypedData,
10108
10248
  updateUserProfile,
10109
10249
  useAssets,
10110
10250
  useLumiaPassportConfig,