@passkeyme/react-auth 2.0.10 → 2.0.11
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 -16
- package/dist/index.esm.js +405 -263
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +405 -263
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ function App() {
|
|
|
36
36
|
<PasskeymeProvider
|
|
37
37
|
config={{
|
|
38
38
|
appId: "your-passkeyme-app-id",
|
|
39
|
-
redirectUri: "http://localhost
|
|
39
|
+
redirectUri: "http://localhost/auth/callback",
|
|
40
40
|
debug: process.env.NODE_ENV === "development", // Enable debug logging in development
|
|
41
41
|
}}
|
|
42
42
|
>
|
|
@@ -130,14 +130,13 @@ The main provider component that manages authentication state.
|
|
|
130
130
|
<PasskeymeProvider
|
|
131
131
|
config={{
|
|
132
132
|
appId: "your-app-id",
|
|
133
|
-
baseUrl: "https://auth.passkeyme.com",
|
|
134
133
|
redirectUri: "http://localhost:3000/callback",
|
|
135
134
|
debug: true, // Enable debug logging for development
|
|
136
135
|
}}
|
|
137
136
|
loadingComponent={<div>Loading...</div>}
|
|
138
|
-
errorComponent={
|
|
139
|
-
onAuthChange={
|
|
140
|
-
onError={
|
|
137
|
+
errorComponent={error => <div>Error: {error}</div>}
|
|
138
|
+
onAuthChange={user => console.log("User changed:", user)}
|
|
139
|
+
onError={error => console.error("Auth error:", error)}
|
|
141
140
|
>
|
|
142
141
|
<App />
|
|
143
142
|
</PasskeymeProvider>
|
|
@@ -263,8 +262,8 @@ Passkey authentication button.
|
|
|
263
262
|
username="user@example.com" // Optional username hint
|
|
264
263
|
variant="default"
|
|
265
264
|
size="medium"
|
|
266
|
-
onSuccess={
|
|
267
|
-
onError={
|
|
265
|
+
onSuccess={user => console.log("Success:", user)}
|
|
266
|
+
onError={error => console.log("Error:", error)}
|
|
268
267
|
>
|
|
269
268
|
Sign in with Passkey
|
|
270
269
|
</PasskeymeButton>
|
|
@@ -296,7 +295,7 @@ Protect content for authenticated users.
|
|
|
296
295
|
fallback={<LoginPage />}
|
|
297
296
|
redirectTo="/login"
|
|
298
297
|
requiredRoles={["admin", "user"]}
|
|
299
|
-
hasAccess={
|
|
298
|
+
hasAccess={user => user.emailVerified}
|
|
300
299
|
>
|
|
301
300
|
<SecretContent />
|
|
302
301
|
</PasskeymeProtectedRoute>
|
|
@@ -328,13 +327,13 @@ triggerPasskeymeAuth();
|
|
|
328
327
|
triggerPasskeymeAuth({
|
|
329
328
|
username: "user@example.com",
|
|
330
329
|
onSuccess: (user, method) => console.log(`Authenticated via ${method}`, user),
|
|
331
|
-
onError:
|
|
330
|
+
onError: error => console.error("Auth failed:", error),
|
|
332
331
|
});
|
|
333
332
|
|
|
334
333
|
// Inline mode - developer controls OAuth UI
|
|
335
334
|
triggerPasskeymeAuth({
|
|
336
335
|
mode: "inline",
|
|
337
|
-
onOAuthRequired:
|
|
336
|
+
onOAuthRequired: providers => {
|
|
338
337
|
// Show your custom OAuth UI
|
|
339
338
|
setShowOAuthModal(true);
|
|
340
339
|
setAvailableProviders(providers);
|
|
@@ -348,7 +347,7 @@ triggerPasskeymeAuth({
|
|
|
348
347
|
// Passkey-only (no fallback)
|
|
349
348
|
triggerPasskeymeAuth({
|
|
350
349
|
forcePasskeyOnly: true,
|
|
351
|
-
onError:
|
|
350
|
+
onError: error => alert("Passkey authentication failed"),
|
|
352
351
|
});
|
|
353
352
|
```
|
|
354
353
|
|
|
@@ -370,7 +369,7 @@ function CustomAuthFlow() {
|
|
|
370
369
|
const handleLogin = () => {
|
|
371
370
|
triggerPasskeymeAuth({
|
|
372
371
|
mode: "inline",
|
|
373
|
-
onOAuthRequired:
|
|
372
|
+
onOAuthRequired: availableProviders => {
|
|
374
373
|
setProviders(availableProviders);
|
|
375
374
|
setShowOAuth(true);
|
|
376
375
|
},
|
|
@@ -388,7 +387,7 @@ function CustomAuthFlow() {
|
|
|
388
387
|
{showOAuth && (
|
|
389
388
|
<div className="oauth-modal">
|
|
390
389
|
<h3>Choose OAuth Provider</h3>
|
|
391
|
-
{providers.map(
|
|
390
|
+
{providers.map(provider => (
|
|
392
391
|
<PasskeymeOAuthButton key={provider} provider={provider}>
|
|
393
392
|
Login with {provider}
|
|
394
393
|
</PasskeymeOAuthButton>
|
|
@@ -430,7 +429,7 @@ function CustomLoginForm() {
|
|
|
430
429
|
const [email, setEmail] = useState("");
|
|
431
430
|
const [password, setPassword] = useState("");
|
|
432
431
|
|
|
433
|
-
const handleSubmit = async
|
|
432
|
+
const handleSubmit = async e => {
|
|
434
433
|
e.preventDefault();
|
|
435
434
|
try {
|
|
436
435
|
await loginWithPassword(email, password);
|
|
@@ -443,13 +442,13 @@ function CustomLoginForm() {
|
|
|
443
442
|
<form onSubmit={handleSubmit}>
|
|
444
443
|
<input
|
|
445
444
|
value={email}
|
|
446
|
-
onChange={
|
|
445
|
+
onChange={e => setEmail(e.target.value)}
|
|
447
446
|
placeholder="Email"
|
|
448
447
|
/>
|
|
449
448
|
<input
|
|
450
449
|
type="password"
|
|
451
450
|
value={password}
|
|
452
|
-
onChange={
|
|
451
|
+
onChange={e => setPassword(e.target.value)}
|
|
453
452
|
placeholder="Password"
|
|
454
453
|
/>
|
|
455
454
|
<button type="submit" disabled={loading}>
|