@lumiapassport/ui-kit 1.9.0 → 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.
- package/dist/iframe/index.html +1 -1
- package/dist/iframe/main.js +11 -19
- package/dist/iframe/main.js.map +1 -1
- package/dist/index.cjs +66 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -9
- package/dist/index.d.ts +38 -9
- package/dist/index.js +63 -27
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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:
|
|
779
|
-
const accessToken =
|
|
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:
|
|
806
|
-
const accessToken =
|
|
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:
|
|
852
|
-
const accessToken =
|
|
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
|
|
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:
|
|
1366
|
+
const allowCredentials = targetCredentialId ? [{ id: base64urlToUint8Array2(targetCredentialId), type: "public-key" }] : [];
|
|
1367
1367
|
try {
|
|
1368
1368
|
const credential = await navigator.credentials.get({
|
|
1369
1369
|
publicKey: {
|
|
@@ -2077,6 +2077,7 @@ async function verifyEmailLinkCode(email, code) {
|
|
|
2077
2077
|
if (!hasValidToken) throw new Error("No authentication token available");
|
|
2078
2078
|
const response = await (0, import_auth3.authenticatedFetch)(`${getTssUrl3()}/api/auth/link/email/verify-code`, {
|
|
2079
2079
|
method: "POST",
|
|
2080
|
+
credentials: "include",
|
|
2080
2081
|
body: JSON.stringify({ email, code })
|
|
2081
2082
|
});
|
|
2082
2083
|
if (!response.ok) {
|
|
@@ -2112,13 +2113,13 @@ async function beginPasskeyLinking() {
|
|
|
2112
2113
|
const begin2 = await res.json();
|
|
2113
2114
|
const options2 = {
|
|
2114
2115
|
rp: begin2.rp,
|
|
2115
|
-
user: { id:
|
|
2116
|
-
challenge:
|
|
2116
|
+
user: { id: base64urlToUint8Array(begin2.user.id), name: begin2.user.name, displayName: begin2.user.displayName },
|
|
2117
|
+
challenge: base64urlToUint8Array(begin2.challenge),
|
|
2117
2118
|
pubKeyCredParams: begin2.pubKeyCredParams,
|
|
2118
2119
|
timeout: begin2.timeout,
|
|
2119
2120
|
attestation: begin2.attestation,
|
|
2120
2121
|
authenticatorSelection: { ...begin2.authenticatorSelection, residentKey: begin2.authenticatorSelection?.residentKey ?? "preferred", requireResidentKey: begin2.authenticatorSelection?.requireResidentKey ?? false, userVerification: begin2.authenticatorSelection?.userVerification ?? "preferred" },
|
|
2121
|
-
excludeCredentials: begin2.excludeCredentials?.map((cred) => ({ type: cred.type, id:
|
|
2122
|
+
excludeCredentials: begin2.excludeCredentials?.map((cred) => ({ type: cred.type, id: base64urlToUint8Array(cred.id), transports: cred.transports })) || void 0
|
|
2122
2123
|
};
|
|
2123
2124
|
return { challengeId: begin2.challengeId, options: options2 };
|
|
2124
2125
|
}
|
|
@@ -2127,13 +2128,13 @@ async function beginPasskeyLinking() {
|
|
|
2127
2128
|
const begin = await res.json();
|
|
2128
2129
|
const options = {
|
|
2129
2130
|
rp: begin.rp,
|
|
2130
|
-
user: { id:
|
|
2131
|
-
challenge:
|
|
2131
|
+
user: { id: base64urlToUint8Array(begin.user.id), name: begin.user.name, displayName: begin.user.displayName },
|
|
2132
|
+
challenge: base64urlToUint8Array(begin.challenge),
|
|
2132
2133
|
pubKeyCredParams: begin.pubKeyCredParams,
|
|
2133
2134
|
timeout: begin.timeout,
|
|
2134
2135
|
attestation: begin.attestation,
|
|
2135
2136
|
authenticatorSelection: { ...begin.authenticatorSelection, residentKey: "preferred", requireResidentKey: false, userVerification: "preferred" },
|
|
2136
|
-
excludeCredentials: begin.excludeCredentials?.map((cred) => ({ type: cred.type, id:
|
|
2137
|
+
excludeCredentials: begin.excludeCredentials?.map((cred) => ({ type: cred.type, id: base64urlToUint8Array(cred.id), transports: cred.transports })) || void 0
|
|
2137
2138
|
};
|
|
2138
2139
|
return { challengeId: begin.challengeId, options };
|
|
2139
2140
|
}
|
|
@@ -2207,18 +2208,10 @@ async function linkPasskeyWithWebAuthn(optionsOverride) {
|
|
|
2207
2208
|
const cid = challengeId || "local-" + Date.now();
|
|
2208
2209
|
await completePasskeyLinking({ challengeId: cid, credential: attestationPayload });
|
|
2209
2210
|
}
|
|
2210
|
-
function base64urlToUint8Array2(base64url) {
|
|
2211
|
-
const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
2212
|
-
const pad = base64.length % 4 ? 4 - base64.length % 4 : 0;
|
|
2213
|
-
const padded = base64 + "=".repeat(pad);
|
|
2214
|
-
const binary = atob(padded);
|
|
2215
|
-
const bytes = new Uint8Array(binary.length);
|
|
2216
|
-
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
2217
|
-
return bytes;
|
|
2218
|
-
}
|
|
2219
2211
|
var init_passkey2 = __esm({
|
|
2220
2212
|
"src/internal/auth/providers/passkey.ts"() {
|
|
2221
2213
|
init_auth();
|
|
2214
|
+
init_base64url();
|
|
2222
2215
|
init_webauthn();
|
|
2223
2216
|
init_types();
|
|
2224
2217
|
}
|
|
@@ -2347,6 +2340,7 @@ __export(auth_exports, {
|
|
|
2347
2340
|
getLinkedProviders: () => getLinkedProviders,
|
|
2348
2341
|
getProviderDisplayInfo: () => getProviderDisplayInfo,
|
|
2349
2342
|
getTssUrl: () => getTssUrl3,
|
|
2343
|
+
getValidTokens: () => import_auth3.getValidTokens,
|
|
2350
2344
|
hasAvailablePasskeys: () => hasAvailablePasskeys,
|
|
2351
2345
|
hideTelegramWidget: () => hideTelegramWidget,
|
|
2352
2346
|
initTelegramWidget: () => initTelegramWidget,
|
|
@@ -2582,10 +2576,10 @@ var init_iframe_manager = __esm({
|
|
|
2582
2576
|
*/
|
|
2583
2577
|
async handleTokenRefreshRequest(message) {
|
|
2584
2578
|
try {
|
|
2585
|
-
const { jwtTokenManager:
|
|
2586
|
-
const refreshSuccess = await
|
|
2579
|
+
const { jwtTokenManager: jwtTokenManager4 } = await Promise.resolve().then(() => (init_auth(), auth_exports));
|
|
2580
|
+
const refreshSuccess = await jwtTokenManager4.refreshAccessToken();
|
|
2587
2581
|
if (refreshSuccess) {
|
|
2588
|
-
const newAccessToken =
|
|
2582
|
+
const newAccessToken = jwtTokenManager4.getAccessToken();
|
|
2589
2583
|
if (this.iframe && this.iframe.contentWindow) {
|
|
2590
2584
|
const iframeOrigin = new URL(this.iframeUrl).origin;
|
|
2591
2585
|
this.iframe.contentWindow.postMessage(
|
|
@@ -5782,6 +5776,9 @@ __export(index_exports, {
|
|
|
5782
5776
|
UserOpStatus: () => UserOpStatus,
|
|
5783
5777
|
deployAccount: () => deployAccount,
|
|
5784
5778
|
getUserProfile: () => getUserProfile,
|
|
5779
|
+
getValidTokens: () => import_auth3.getValidTokens,
|
|
5780
|
+
jwtTokenManager: () => import_auth3.jwtTokenManager,
|
|
5781
|
+
logout: () => import_auth3.logout,
|
|
5785
5782
|
lumiaBeam: () => lumiaBeam,
|
|
5786
5783
|
prepareUserOperation: () => prepareUserOperation,
|
|
5787
5784
|
queryClient: () => queryClient,
|
|
@@ -5789,6 +5786,7 @@ __export(index_exports, {
|
|
|
5789
5786
|
signTypedData: () => signTypedData,
|
|
5790
5787
|
updateUserProfile: () => updateUserProfile,
|
|
5791
5788
|
useAssets: () => useAssets,
|
|
5789
|
+
useLogout: () => useLogout,
|
|
5792
5790
|
useLumiaPassportConfig: () => useLumiaPassportConfig,
|
|
5793
5791
|
useLumiaPassportLinkedProfiles: () => useLumiaPassportLinkedProfiles,
|
|
5794
5792
|
useLumiaPassportSession: () => useLumiaPassportSession,
|
|
@@ -8703,7 +8701,7 @@ function useLumiaPassportLinkedProfiles() {
|
|
|
8703
8701
|
// package.json
|
|
8704
8702
|
var package_default = {
|
|
8705
8703
|
name: "@lumiapassport/ui-kit",
|
|
8706
|
-
version: "1.9.
|
|
8704
|
+
version: "1.9.2",
|
|
8707
8705
|
description: "React UI components and hooks for Lumia Passport authentication and Account Abstraction",
|
|
8708
8706
|
type: "module",
|
|
8709
8707
|
main: "./dist/index.cjs",
|
|
@@ -10120,9 +10118,46 @@ function useUserOpStatus(options = {}) {
|
|
|
10120
10118
|
};
|
|
10121
10119
|
}
|
|
10122
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
|
+
|
|
10123
10157
|
// src/index.ts
|
|
10124
10158
|
init_account();
|
|
10125
10159
|
init_base();
|
|
10160
|
+
init_auth();
|
|
10126
10161
|
init_profile();
|
|
10127
10162
|
init_wagmi();
|
|
10128
10163
|
|
|
@@ -10269,6 +10304,9 @@ function useSmartAccountTransactions() {
|
|
|
10269
10304
|
UserOpStatus,
|
|
10270
10305
|
deployAccount,
|
|
10271
10306
|
getUserProfile,
|
|
10307
|
+
getValidTokens,
|
|
10308
|
+
jwtTokenManager,
|
|
10309
|
+
logout,
|
|
10272
10310
|
lumiaBeam,
|
|
10273
10311
|
prepareUserOperation,
|
|
10274
10312
|
queryClient,
|
|
@@ -10276,6 +10314,7 @@ function useSmartAccountTransactions() {
|
|
|
10276
10314
|
signTypedData,
|
|
10277
10315
|
updateUserProfile,
|
|
10278
10316
|
useAssets,
|
|
10317
|
+
useLogout,
|
|
10279
10318
|
useLumiaPassportConfig,
|
|
10280
10319
|
useLumiaPassportLinkedProfiles,
|
|
10281
10320
|
useLumiaPassportSession,
|