@lumiapassport/ui-kit 1.5.3 → 1.6.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 +15 -62
- package/dist/iframe/index.html +1 -1
- package/dist/iframe/main.js +1 -1
- package/dist/index.cjs +33 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -3
- package/dist/index.d.ts +15 -3
- package/dist/index.js +31 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -241,56 +241,28 @@ That's it! The `ConnectWalletButton` provides a complete authentication UI with
|
|
|
241
241
|
|
|
242
242
|
## Using Hooks
|
|
243
243
|
|
|
244
|
-
|
|
244
|
+
> **Note:** The old `useLumiaSession` and `LumiaSessionProvider` names are deprecated but still supported for backward compatibility. They will show a console warning and will be removed in v2.0.0. Please migrate to the new names: `useLumiaPassportSession` and `LumiaPassportSessionProvider`.
|
|
245
|
+
|
|
246
|
+
### useLumiaPassportSession - Authentication and Session State
|
|
245
247
|
|
|
246
248
|
```tsx
|
|
247
|
-
import {
|
|
249
|
+
import { useLumiaPassportSession } from '@lumiapassport/ui-kit';
|
|
248
250
|
|
|
249
251
|
function MyComponent() {
|
|
250
|
-
const {
|
|
251
|
-
user, // Current user info
|
|
252
|
-
isAuthenticated, // Auth status
|
|
253
|
-
login, // Login function
|
|
254
|
-
logout, // Logout function
|
|
255
|
-
loading, // Loading state
|
|
256
|
-
} = useAuth();
|
|
257
|
-
|
|
258
|
-
if (loading) return <div>Loading...</div>;
|
|
259
|
-
|
|
260
|
-
if (!isAuthenticated) {
|
|
261
|
-
return <button onClick={() => login()}>Sign In</button>;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return (
|
|
265
|
-
<div>
|
|
266
|
-
<p>Welcome, {user.userId}</p>
|
|
267
|
-
<button onClick={() => logout()}>Sign Out</button>
|
|
268
|
-
</div>
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
```
|
|
252
|
+
const { session, isLoading } = useLumiaPassportSession();
|
|
272
253
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
```tsx
|
|
276
|
-
import { useWallet } from '@lumiapassport/ui-kit';
|
|
254
|
+
if (isLoading) return <div>Loading...</div>;
|
|
277
255
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
const handleSend = async () => {
|
|
282
|
-
const hash = await sendTransaction({
|
|
283
|
-
to: '0x...',
|
|
284
|
-
value: '0.1', // ETH amount
|
|
285
|
-
});
|
|
286
|
-
console.log('Transaction hash:', hash);
|
|
287
|
-
};
|
|
256
|
+
if (!session) {
|
|
257
|
+
return <div>Not authenticated. Please connect your wallet.</div>;
|
|
258
|
+
}
|
|
288
259
|
|
|
289
260
|
return (
|
|
290
261
|
<div>
|
|
291
|
-
<p>
|
|
292
|
-
<p>
|
|
293
|
-
<
|
|
262
|
+
<p>Welcome!</p>
|
|
263
|
+
<p>User ID: {session.userId}</p>
|
|
264
|
+
<p>Wallet Address: {session.ownerAddress}</p>
|
|
265
|
+
<p>Smart Account: {session.accountAddress}</p>
|
|
294
266
|
</div>
|
|
295
267
|
);
|
|
296
268
|
}
|
|
@@ -330,10 +302,10 @@ function TransactionExample() {
|
|
|
330
302
|
### prepareUserOperation - Prepare for Backend Submission
|
|
331
303
|
|
|
332
304
|
```tsx
|
|
333
|
-
import { prepareUserOperation,
|
|
305
|
+
import { prepareUserOperation, useLumiaPassportSession } from '@lumiapassport/ui-kit';
|
|
334
306
|
|
|
335
307
|
function BackendSubmissionExample() {
|
|
336
|
-
const { session } =
|
|
308
|
+
const { session } = useLumiaPassportSession();
|
|
337
309
|
|
|
338
310
|
const handlePrepare = async () => {
|
|
339
311
|
if (!session) return;
|
|
@@ -428,25 +400,6 @@ Pre-built button with authentication modal.
|
|
|
428
400
|
/>
|
|
429
401
|
```
|
|
430
402
|
|
|
431
|
-
### Custom Authentication Flow
|
|
432
|
-
|
|
433
|
-
```tsx
|
|
434
|
-
import { AuthModal, useAuthModal } from '@lumiapassport/ui-kit';
|
|
435
|
-
|
|
436
|
-
function CustomAuth() {
|
|
437
|
-
const { openAuth } = useAuthModal();
|
|
438
|
-
|
|
439
|
-
return (
|
|
440
|
-
<div>
|
|
441
|
-
<button onClick={() => openAuth()}>
|
|
442
|
-
Custom Sign In
|
|
443
|
-
</button>
|
|
444
|
-
<AuthModal />
|
|
445
|
-
</div>
|
|
446
|
-
);
|
|
447
|
-
}
|
|
448
|
-
```
|
|
449
|
-
|
|
450
403
|
## Authentication Methods
|
|
451
404
|
|
|
452
405
|
### Email OTP
|
package/dist/iframe/index.html
CHANGED
|
@@ -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.
|
|
18
|
+
<title>Lumia Passport Secure Wallet - iframe version 1.6.0</title>
|
|
19
19
|
|
|
20
20
|
<!-- Styles will be injected by build process -->
|
|
21
21
|
<style>
|
package/dist/iframe/main.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -5608,6 +5608,7 @@ __export(index_exports, {
|
|
|
5608
5608
|
LUMIA_EXPLORER_URL: () => LUMIA_EXPLORER_URL,
|
|
5609
5609
|
LumiaLogo: () => LumiaLogo2,
|
|
5610
5610
|
LumiaPassportProvider: () => LumiaPassportProvider,
|
|
5611
|
+
LumiaPassportSessionProvider: () => LumiaPassportSessionProvider,
|
|
5611
5612
|
LumiaRainbowKitProvider: () => LumiaRainbowKitProvider,
|
|
5612
5613
|
LumiaSessionProvider: () => LumiaSessionProvider,
|
|
5613
5614
|
LumiaWagmiProvider: () => LumiaWagmiProvider,
|
|
@@ -5623,6 +5624,7 @@ __export(index_exports, {
|
|
|
5623
5624
|
useAssets: () => useAssets,
|
|
5624
5625
|
useLumiaPassportConfig: () => useLumiaPassportConfig,
|
|
5625
5626
|
useLumiaPassportLinkedProfiles: () => useLumiaPassportLinkedProfiles,
|
|
5627
|
+
useLumiaPassportSession: () => useLumiaPassportSession,
|
|
5626
5628
|
useLumiaSession: () => useLumiaSession,
|
|
5627
5629
|
useSendTransaction: () => useSendTransaction,
|
|
5628
5630
|
useSmartAccountTransactions: () => useSmartAccountTransactions,
|
|
@@ -5644,8 +5646,8 @@ init_LumiaPassportContext();
|
|
|
5644
5646
|
// src/context/LumiaPassportSessionContext.tsx
|
|
5645
5647
|
var import_react2 = __toESM(require("react"), 1);
|
|
5646
5648
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
5647
|
-
var
|
|
5648
|
-
var
|
|
5649
|
+
var LumiaPassportSessionContext = import_react2.default.createContext(void 0);
|
|
5650
|
+
var LumiaPassportSessionProvider = ({ children }) => {
|
|
5649
5651
|
const [session, setSession] = import_react2.default.useState(null);
|
|
5650
5652
|
const [address, setAddress] = import_react2.default.useState(null);
|
|
5651
5653
|
const [status, setStatus] = import_react2.default.useState("idle");
|
|
@@ -5666,13 +5668,29 @@ var LumiaSessionProvider = ({ children }) => {
|
|
|
5666
5668
|
setRecoveryUserId,
|
|
5667
5669
|
setIsRecoveryModalOpen
|
|
5668
5670
|
}), [session, address, status, error, recoveryUserId, isRecoveryModalOpen]);
|
|
5669
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
5671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LumiaPassportSessionContext.Provider, { value, children });
|
|
5670
5672
|
};
|
|
5671
|
-
function
|
|
5672
|
-
const ctx = import_react2.default.useContext(
|
|
5673
|
-
if (!ctx) throw new Error("
|
|
5673
|
+
function useLumiaPassportSession() {
|
|
5674
|
+
const ctx = import_react2.default.useContext(LumiaPassportSessionContext);
|
|
5675
|
+
if (!ctx) throw new Error("useLumiaPassportSession must be used within LumiaPassportSessionProvider");
|
|
5674
5676
|
return ctx;
|
|
5675
5677
|
}
|
|
5678
|
+
function useLumiaSession() {
|
|
5679
|
+
if (typeof window !== "undefined") {
|
|
5680
|
+
console.warn(
|
|
5681
|
+
"[Lumia Passport] DEPRECATED: useLumiaSession is deprecated and will be removed in v2.0.0. Please use useLumiaPassportSession instead."
|
|
5682
|
+
);
|
|
5683
|
+
}
|
|
5684
|
+
return useLumiaPassportSession();
|
|
5685
|
+
}
|
|
5686
|
+
var LumiaSessionProvider = ({ children }) => {
|
|
5687
|
+
if (typeof window !== "undefined") {
|
|
5688
|
+
console.warn(
|
|
5689
|
+
"[Lumia Passport] DEPRECATED: LumiaSessionProvider is deprecated and will be removed in v2.0.0. Please use LumiaPassportSessionProvider instead."
|
|
5690
|
+
);
|
|
5691
|
+
}
|
|
5692
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LumiaPassportSessionProvider, { children });
|
|
5693
|
+
};
|
|
5676
5694
|
|
|
5677
5695
|
// src/index.ts
|
|
5678
5696
|
init_WagmiContext();
|
|
@@ -7092,7 +7110,7 @@ init_LumiaPassportContext();
|
|
|
7092
7110
|
init_useTheme();
|
|
7093
7111
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
7094
7112
|
var TransactionsModal = ({ open, onOpenChange, onBack }) => {
|
|
7095
|
-
const { address } =
|
|
7113
|
+
const { address } = useLumiaPassportSession();
|
|
7096
7114
|
const [transactions, setTransactions] = import_react13.default.useState([]);
|
|
7097
7115
|
const [loading, setLoading] = import_react13.default.useState(false);
|
|
7098
7116
|
const [error, setError] = import_react13.default.useState(null);
|
|
@@ -7426,7 +7444,7 @@ init_LumiaPassportContext();
|
|
|
7426
7444
|
init_useTheme();
|
|
7427
7445
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
7428
7446
|
var ViewAssetsModal = ({ open, onOpenChange, onBack }) => {
|
|
7429
|
-
const { address } =
|
|
7447
|
+
const { address } = useLumiaPassportSession();
|
|
7430
7448
|
const { assets, refreshBalances, isLoading } = useAssets(address);
|
|
7431
7449
|
const [copied, setCopied] = import_react15.default.useState(null);
|
|
7432
7450
|
const { config } = useLumiaPassportConfig();
|
|
@@ -7563,7 +7581,7 @@ var import_react16 = require("react");
|
|
|
7563
7581
|
var import_viem5 = require("viem");
|
|
7564
7582
|
init_account();
|
|
7565
7583
|
function useSendTransaction() {
|
|
7566
|
-
const { session, address } =
|
|
7584
|
+
const { session, address } = useLumiaPassportSession();
|
|
7567
7585
|
const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
|
|
7568
7586
|
const [error, setError] = (0, import_react16.useState)(null);
|
|
7569
7587
|
const [userOpHash, setUserOpHash] = (0, import_react16.useState)(null);
|
|
@@ -8006,7 +8024,7 @@ var SendModal = ({
|
|
|
8006
8024
|
recipientAddress: initialRecipient = "",
|
|
8007
8025
|
amount: initialAmount = ""
|
|
8008
8026
|
}) => {
|
|
8009
|
-
const { address } =
|
|
8027
|
+
const { address } = useLumiaPassportSession();
|
|
8010
8028
|
const { assets } = useAssets(address);
|
|
8011
8029
|
const { config } = useLumiaPassportConfig();
|
|
8012
8030
|
const { isDark, classes: theme } = useTheme(config.ui.theme, config.ui.colors);
|
|
@@ -8262,7 +8280,7 @@ var ReceiveModal = ({
|
|
|
8262
8280
|
onOpenChange,
|
|
8263
8281
|
onBack
|
|
8264
8282
|
}) => {
|
|
8265
|
-
const { address } =
|
|
8283
|
+
const { address } = useLumiaPassportSession();
|
|
8266
8284
|
const [qrCodeUrl, setQrCodeUrl] = (0, import_react18.useState)("");
|
|
8267
8285
|
const { config } = useLumiaPassportConfig();
|
|
8268
8286
|
const { isDark, classes: theme } = useTheme(config.ui.theme, config.ui.colors);
|
|
@@ -8518,7 +8536,7 @@ function useLumiaPassportLinkedProfiles() {
|
|
|
8518
8536
|
// package.json
|
|
8519
8537
|
var package_default = {
|
|
8520
8538
|
name: "@lumiapassport/ui-kit",
|
|
8521
|
-
version: "1.
|
|
8539
|
+
version: "1.6.0",
|
|
8522
8540
|
description: "React UI components and hooks for Lumia Passport authentication and Account Abstraction",
|
|
8523
8541
|
type: "module",
|
|
8524
8542
|
main: "./dist/index.cjs",
|
|
@@ -8643,7 +8661,7 @@ var ConnectWalletButton = ({
|
|
|
8643
8661
|
setError,
|
|
8644
8662
|
setRecoveryUserId,
|
|
8645
8663
|
setIsRecoveryModalOpen
|
|
8646
|
-
} =
|
|
8664
|
+
} = useLumiaPassportSession();
|
|
8647
8665
|
const { profiles, isLoading: profilesLoading } = useLumiaPassportLinkedProfiles();
|
|
8648
8666
|
const [isAuthModalOpen, setIsAuthModalOpen] = import_react19.default.useState(false);
|
|
8649
8667
|
const tssManagerRef = import_react19.default.useRef(null);
|
|
@@ -10075,6 +10093,7 @@ function useSmartAccountTransactions() {
|
|
|
10075
10093
|
LUMIA_EXPLORER_URL,
|
|
10076
10094
|
LumiaLogo,
|
|
10077
10095
|
LumiaPassportProvider,
|
|
10096
|
+
LumiaPassportSessionProvider,
|
|
10078
10097
|
LumiaRainbowKitProvider,
|
|
10079
10098
|
LumiaSessionProvider,
|
|
10080
10099
|
LumiaWagmiProvider,
|
|
@@ -10090,6 +10109,7 @@ function useSmartAccountTransactions() {
|
|
|
10090
10109
|
useAssets,
|
|
10091
10110
|
useLumiaPassportConfig,
|
|
10092
10111
|
useLumiaPassportLinkedProfiles,
|
|
10112
|
+
useLumiaPassportSession,
|
|
10093
10113
|
useLumiaSession,
|
|
10094
10114
|
useSendTransaction,
|
|
10095
10115
|
useSmartAccountTransactions,
|