@lumiapassport/ui-kit 1.9.1 → 1.9.2

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.9.1</title>
18
+ <title>Lumia Passport Secure Wallet - iframe version 1.9.2</title>
19
19
 
20
20
  <!-- Styles will be injected by build process -->
21
21
  <style>
@@ -3947,7 +3947,7 @@ var BackupManager = class {
3947
3947
  };
3948
3948
 
3949
3949
  // src/iframe/main.ts
3950
- var IFRAME_VERSION = "1.9.1";
3950
+ var IFRAME_VERSION = "1.9.2";
3951
3951
  var IframeWallet = class {
3952
3952
  constructor() {
3953
3953
  console.log("=".repeat(60));
package/dist/index.cjs CHANGED
@@ -775,8 +775,8 @@ async function ensureDkgAndGetOwner(userId, _clientSeedHex) {
775
775
  };
776
776
  }
777
777
  await iframeManager.authenticate(userId);
778
- const { jwtTokenManager: jwtTokenManager3 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
779
- const accessToken = jwtTokenManager3.getAccessToken();
778
+ const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
779
+ const accessToken = jwtTokenManager4.getAccessToken();
780
780
  if (!accessToken) {
781
781
  throw new Error("No access token available for DKG");
782
782
  }
@@ -802,8 +802,8 @@ async function signDigestWithMpc(userId, digest32, userOpDetails) {
802
802
  };
803
803
  try {
804
804
  const iframeManager = getIframeManager();
805
- const { jwtTokenManager: jwtTokenManager3 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
806
- const accessToken = jwtTokenManager3.getAccessToken();
805
+ const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
806
+ const accessToken = jwtTokenManager4.getAccessToken();
807
807
  if (!accessToken) {
808
808
  throw new Error("No access token available for signing");
809
809
  }
@@ -848,8 +848,8 @@ async function signTypedDataWithMpc(userId, digest32, typedData) {
848
848
  digest32
849
849
  });
850
850
  const iframeManager = getIframeManager();
851
- const { jwtTokenManager: jwtTokenManager3 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
852
- const accessToken = jwtTokenManager3.getAccessToken();
851
+ const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
852
+ const accessToken = jwtTokenManager4.getAccessToken();
853
853
  if (!accessToken) {
854
854
  console.error("[signTypedDataWithMpc] No access token available");
855
855
  throw new Error("No access token available for signing");
@@ -1351,7 +1351,7 @@ async function deleteShare() {
1351
1351
  async function deriveKEKFromPasskey(userId, requiredCredentialId) {
1352
1352
  const challengeString = `lumia-kek:${userId}`;
1353
1353
  const challenge = new TextEncoder().encode(challengeString);
1354
- function base64urlToUint8Array3(base64url) {
1354
+ function base64urlToUint8Array2(base64url) {
1355
1355
  const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
1356
1356
  const pad = base64.length % 4 ? 4 - base64.length % 4 : 0;
1357
1357
  const padded = base64 + "=".repeat(pad);
@@ -1363,7 +1363,7 @@ async function deriveKEKFromPasskey(userId, requiredCredentialId) {
1363
1363
  return bytes;
1364
1364
  }
1365
1365
  const targetCredentialId = requiredCredentialId || createPasskeyHelpers(userId).getCredId();
1366
- const allowCredentials = targetCredentialId ? [{ id: base64urlToUint8Array3(targetCredentialId), type: "public-key" }] : [];
1366
+ const allowCredentials = targetCredentialId ? [{ id: base64urlToUint8Array2(targetCredentialId), type: "public-key" }] : [];
1367
1367
  try {
1368
1368
  const credential = await navigator.credentials.get({
1369
1369
  publicKey: {
@@ -2113,13 +2113,13 @@ async function beginPasskeyLinking() {
2113
2113
  const begin2 = await res.json();
2114
2114
  const options2 = {
2115
2115
  rp: begin2.rp,
2116
- user: { id: base64urlToUint8Array2(begin2.user.id), name: begin2.user.name, displayName: begin2.user.displayName },
2117
- challenge: base64urlToUint8Array2(begin2.challenge),
2116
+ user: { id: base64urlToUint8Array(begin2.user.id), name: begin2.user.name, displayName: begin2.user.displayName },
2117
+ challenge: base64urlToUint8Array(begin2.challenge),
2118
2118
  pubKeyCredParams: begin2.pubKeyCredParams,
2119
2119
  timeout: begin2.timeout,
2120
2120
  attestation: begin2.attestation,
2121
2121
  authenticatorSelection: { ...begin2.authenticatorSelection, residentKey: begin2.authenticatorSelection?.residentKey ?? "preferred", requireResidentKey: begin2.authenticatorSelection?.requireResidentKey ?? false, userVerification: begin2.authenticatorSelection?.userVerification ?? "preferred" },
2122
- excludeCredentials: begin2.excludeCredentials?.map((cred) => ({ type: cred.type, id: base64urlToUint8Array2(cred.id), transports: cred.transports })) || void 0
2122
+ excludeCredentials: begin2.excludeCredentials?.map((cred) => ({ type: cred.type, id: base64urlToUint8Array(cred.id), transports: cred.transports })) || void 0
2123
2123
  };
2124
2124
  return { challengeId: begin2.challengeId, options: options2 };
2125
2125
  }
@@ -2128,13 +2128,13 @@ async function beginPasskeyLinking() {
2128
2128
  const begin = await res.json();
2129
2129
  const options = {
2130
2130
  rp: begin.rp,
2131
- user: { id: base64urlToUint8Array2(begin.user.id), name: begin.user.name, displayName: begin.user.displayName },
2132
- challenge: base64urlToUint8Array2(begin.challenge),
2131
+ user: { id: base64urlToUint8Array(begin.user.id), name: begin.user.name, displayName: begin.user.displayName },
2132
+ challenge: base64urlToUint8Array(begin.challenge),
2133
2133
  pubKeyCredParams: begin.pubKeyCredParams,
2134
2134
  timeout: begin.timeout,
2135
2135
  attestation: begin.attestation,
2136
2136
  authenticatorSelection: { ...begin.authenticatorSelection, residentKey: "preferred", requireResidentKey: false, userVerification: "preferred" },
2137
- excludeCredentials: begin.excludeCredentials?.map((cred) => ({ type: cred.type, id: base64urlToUint8Array2(cred.id), transports: cred.transports })) || void 0
2137
+ excludeCredentials: begin.excludeCredentials?.map((cred) => ({ type: cred.type, id: base64urlToUint8Array(cred.id), transports: cred.transports })) || void 0
2138
2138
  };
2139
2139
  return { challengeId: begin.challengeId, options };
2140
2140
  }
@@ -2208,18 +2208,10 @@ async function linkPasskeyWithWebAuthn(optionsOverride) {
2208
2208
  const cid = challengeId || "local-" + Date.now();
2209
2209
  await completePasskeyLinking({ challengeId: cid, credential: attestationPayload });
2210
2210
  }
2211
- function base64urlToUint8Array2(base64url) {
2212
- const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
2213
- const pad = base64.length % 4 ? 4 - base64.length % 4 : 0;
2214
- const padded = base64 + "=".repeat(pad);
2215
- const binary = atob(padded);
2216
- const bytes = new Uint8Array(binary.length);
2217
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
2218
- return bytes;
2219
- }
2220
2211
  var init_passkey2 = __esm({
2221
2212
  "src/internal/auth/providers/passkey.ts"() {
2222
2213
  init_auth();
2214
+ init_base64url();
2223
2215
  init_webauthn();
2224
2216
  init_types();
2225
2217
  }
@@ -2348,6 +2340,7 @@ __export(auth_exports, {
2348
2340
  getLinkedProviders: () => getLinkedProviders,
2349
2341
  getProviderDisplayInfo: () => getProviderDisplayInfo,
2350
2342
  getTssUrl: () => getTssUrl3,
2343
+ getValidTokens: () => import_auth3.getValidTokens,
2351
2344
  hasAvailablePasskeys: () => hasAvailablePasskeys,
2352
2345
  hideTelegramWidget: () => hideTelegramWidget,
2353
2346
  initTelegramWidget: () => initTelegramWidget,
@@ -2583,10 +2576,10 @@ var init_iframe_manager = __esm({
2583
2576
  */
2584
2577
  async handleTokenRefreshRequest(message) {
2585
2578
  try {
2586
- const { jwtTokenManager: jwtTokenManager3 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
2587
- const refreshSuccess = await jwtTokenManager3.refreshAccessToken();
2579
+ const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
2580
+ const refreshSuccess = await jwtTokenManager4.refreshAccessToken();
2588
2581
  if (refreshSuccess) {
2589
- const newAccessToken = jwtTokenManager3.getAccessToken();
2582
+ const newAccessToken = jwtTokenManager4.getAccessToken();
2590
2583
  if (this.iframe && this.iframe.contentWindow) {
2591
2584
  const iframeOrigin = new URL(this.iframeUrl).origin;
2592
2585
  this.iframe.contentWindow.postMessage(
@@ -5783,6 +5776,9 @@ __export(index_exports, {
5783
5776
  UserOpStatus: () => UserOpStatus,
5784
5777
  deployAccount: () => deployAccount,
5785
5778
  getUserProfile: () => getUserProfile,
5779
+ getValidTokens: () => import_auth3.getValidTokens,
5780
+ jwtTokenManager: () => import_auth3.jwtTokenManager,
5781
+ logout: () => import_auth3.logout,
5786
5782
  lumiaBeam: () => lumiaBeam,
5787
5783
  prepareUserOperation: () => prepareUserOperation,
5788
5784
  queryClient: () => queryClient,
@@ -5790,6 +5786,7 @@ __export(index_exports, {
5790
5786
  signTypedData: () => signTypedData,
5791
5787
  updateUserProfile: () => updateUserProfile,
5792
5788
  useAssets: () => useAssets,
5789
+ useLogout: () => useLogout,
5793
5790
  useLumiaPassportConfig: () => useLumiaPassportConfig,
5794
5791
  useLumiaPassportLinkedProfiles: () => useLumiaPassportLinkedProfiles,
5795
5792
  useLumiaPassportSession: () => useLumiaPassportSession,
@@ -8704,7 +8701,7 @@ function useLumiaPassportLinkedProfiles() {
8704
8701
  // package.json
8705
8702
  var package_default = {
8706
8703
  name: "@lumiapassport/ui-kit",
8707
- version: "1.9.1",
8704
+ version: "1.9.2",
8708
8705
  description: "React UI components and hooks for Lumia Passport authentication and Account Abstraction",
8709
8706
  type: "module",
8710
8707
  main: "./dist/index.cjs",
@@ -10121,9 +10118,46 @@ function useUserOpStatus(options = {}) {
10121
10118
  };
10122
10119
  }
10123
10120
 
10121
+ // src/hooks/useLogout.ts
10122
+ var import_react22 = require("react");
10123
+ var import_auth10 = require("@lumiapassport/core/auth");
10124
+ init_LumiaPassportContext();
10125
+ function useLogout() {
10126
+ const { setSession, setAddress, setStatus, setError, address } = useLumiaPassportSession();
10127
+ const { callbacks } = useLumiaPassportConfig();
10128
+ const logout2 = (0, import_react22.useCallback)(async () => {
10129
+ const prevAddress = address;
10130
+ let userId = null;
10131
+ try {
10132
+ userId = import_auth10.jwtTokenManager.getUserId() || null;
10133
+ } catch (error) {
10134
+ console.warn("[useLogout] Could not get userId:", error);
10135
+ }
10136
+ try {
10137
+ await (0, import_auth10.logout)();
10138
+ } catch (error) {
10139
+ console.warn("[useLogout] Core logout failed:", error);
10140
+ }
10141
+ setSession(null);
10142
+ setAddress(null);
10143
+ setStatus("idle");
10144
+ setError(null);
10145
+ try {
10146
+ callbacks?.onLumiaPassportDisconnect?.({
10147
+ address: prevAddress,
10148
+ userId
10149
+ });
10150
+ } catch (error) {
10151
+ console.warn("[useLogout] Callback error:", error);
10152
+ }
10153
+ }, [address, setAddress, setError, setSession, setStatus, callbacks]);
10154
+ return { logout: logout2 };
10155
+ }
10156
+
10124
10157
  // src/index.ts
10125
10158
  init_account();
10126
10159
  init_base();
10160
+ init_auth();
10127
10161
  init_profile();
10128
10162
  init_wagmi();
10129
10163
 
@@ -10270,6 +10304,9 @@ function useSmartAccountTransactions() {
10270
10304
  UserOpStatus,
10271
10305
  deployAccount,
10272
10306
  getUserProfile,
10307
+ getValidTokens,
10308
+ jwtTokenManager,
10309
+ logout,
10273
10310
  lumiaBeam,
10274
10311
  prepareUserOperation,
10275
10312
  queryClient,
@@ -10277,6 +10314,7 @@ function useSmartAccountTransactions() {
10277
10314
  signTypedData,
10278
10315
  updateUserProfile,
10279
10316
  useAssets,
10317
+ useLogout,
10280
10318
  useLumiaPassportConfig,
10281
10319
  useLumiaPassportLinkedProfiles,
10282
10320
  useLumiaPassportSession,