@emblemvault/emblem-auth-react 1.0.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 ADDED
@@ -0,0 +1,132 @@
1
+ # @emblemvault/emblem-auth-react
2
+
3
+ React hooks and components for Emblem wallet authentication.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @emblemvault/emblem-auth-react
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```tsx
14
+ import {
15
+ EmblemAuthProvider,
16
+ ConnectButton,
17
+ useEmblemAuth,
18
+ } from '@emblemvault/emblem-auth-react';
19
+
20
+ function App() {
21
+ return (
22
+ <EmblemAuthProvider appId="your-app-id">
23
+ <Header />
24
+ <Content />
25
+ </EmblemAuthProvider>
26
+ );
27
+ }
28
+
29
+ function Header() {
30
+ return <ConnectButton showVaultInfo />;
31
+ }
32
+
33
+ function Content() {
34
+ const { isAuthenticated, walletAddress, vaultId } = useEmblemAuth();
35
+
36
+ if (!isAuthenticated) {
37
+ return <p>Please connect to continue</p>;
38
+ }
39
+
40
+ return (
41
+ <div>
42
+ <p>Wallet: {walletAddress}</p>
43
+ <p>Vault: {vaultId}</p>
44
+ </div>
45
+ );
46
+ }
47
+ ```
48
+
49
+ ## API Reference
50
+
51
+ ### EmblemAuthProvider
52
+
53
+ Wrap your app to provide authentication context.
54
+
55
+ ```tsx
56
+ <EmblemAuthProvider
57
+ appId="your-app-id"
58
+ apiUrl="https://api.emblemvault.ai" // optional
59
+ modalUrl="https://auth.emblemvault.ai/connect" // optional
60
+ >
61
+ {children}
62
+ </EmblemAuthProvider>
63
+ ```
64
+
65
+ ### useEmblemAuth
66
+
67
+ Access auth state and actions.
68
+
69
+ ```tsx
70
+ const {
71
+ // State
72
+ isAuthenticated, // boolean
73
+ isLoading, // boolean
74
+ error, // Error | null
75
+ session, // AuthSession | null
76
+ walletAddress, // string | null
77
+ vaultId, // string | null
78
+ authSDK, // EmblemAuthSDK instance
79
+
80
+ // Actions
81
+ openAuthModal, // () => Promise<void>
82
+ logout, // () => void
83
+ refreshSession, // () => Promise<void>
84
+ } = useEmblemAuth();
85
+ ```
86
+
87
+ ### useEmblemAuthOptional
88
+
89
+ Same as `useEmblemAuth` but returns `null` when used outside provider (instead of throwing).
90
+
91
+ ```tsx
92
+ const auth = useEmblemAuthOptional();
93
+ if (!auth) {
94
+ return <p>Auth not available</p>;
95
+ }
96
+ ```
97
+
98
+ ### ConnectButton
99
+
100
+ Pre-styled connect/disconnect button.
101
+
102
+ ```tsx
103
+ <ConnectButton
104
+ showVaultInfo // Show vault dropdown when connected
105
+ className="" // Additional CSS classes
106
+ />
107
+ ```
108
+
109
+ ### AuthStatus
110
+
111
+ Display authentication status.
112
+
113
+ ```tsx
114
+ <AuthStatus
115
+ showVaultInfo // Show vault ID
116
+ showLogout // Show logout button
117
+ />
118
+ ```
119
+
120
+ ## Underlying SDK
121
+
122
+ This package wraps [emblem-auth-sdk](https://github.com/nicktaylor-/emblem-auth-sdk) for React. The SDK handles:
123
+
124
+ - JWT lifecycle and token refresh
125
+ - Wallet connection modal
126
+ - Session management
127
+
128
+ For advanced usage, access the SDK directly via `useEmblemAuth().authSDK`.
129
+
130
+ ## License
131
+
132
+ MIT