@delmaredigital/payload-better-auth 0.3.7 → 0.3.9
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 +12 -1
- package/dist/adapter/collections.d.ts.map +1 -1
- package/dist/adapter/collections.js +126 -88
- package/dist/adapter/collections.js.map +1 -1
- package/dist/adapter/index.js +197 -150
- package/dist/adapter/index.js.map +1 -1
- package/dist/components/BeforeLogin.d.ts +1 -1
- package/dist/components/BeforeLogin.d.ts.map +1 -1
- package/dist/components/BeforeLogin.js +15 -7
- package/dist/components/BeforeLogin.js.map +1 -1
- package/dist/components/LoginView.d.ts +2 -2
- package/dist/components/LoginView.d.ts.map +1 -1
- package/dist/components/LoginView.js +660 -218
- package/dist/components/LoginView.js.map +1 -1
- package/dist/components/LoginViewWrapper.d.ts +1 -1
- package/dist/components/LoginViewWrapper.d.ts.map +1 -1
- package/dist/components/LoginViewWrapper.js +14 -4
- package/dist/components/LoginViewWrapper.js.map +1 -1
- package/dist/components/LogoutButton.d.ts +1 -1
- package/dist/components/LogoutButton.d.ts.map +1 -1
- package/dist/components/LogoutButton.js +19 -11
- package/dist/components/LogoutButton.js.map +1 -1
- package/dist/components/PasskeyRegisterButton.d.ts +2 -2
- package/dist/components/PasskeyRegisterButton.d.ts.map +1 -1
- package/dist/components/PasskeyRegisterButton.js +20 -16
- package/dist/components/PasskeyRegisterButton.js.map +1 -1
- package/dist/components/PasskeySignInButton.d.ts +2 -2
- package/dist/components/PasskeySignInButton.d.ts.map +1 -1
- package/dist/components/PasskeySignInButton.js +14 -12
- package/dist/components/PasskeySignInButton.js.map +1 -1
- package/dist/components/auth/ForgotPasswordView.d.ts +1 -1
- package/dist/components/auth/ForgotPasswordView.d.ts.map +1 -1
- package/dist/components/auth/ForgotPasswordView.js +133 -43
- package/dist/components/auth/ForgotPasswordView.js.map +1 -1
- package/dist/components/auth/ResetPasswordView.d.ts +1 -1
- package/dist/components/auth/ResetPasswordView.d.ts.map +1 -1
- package/dist/components/auth/ResetPasswordView.js +154 -50
- package/dist/components/auth/ResetPasswordView.js.map +1 -1
- package/dist/components/auth/index.js +2 -2
- package/dist/components/auth/index.js.map +1 -1
- package/dist/components/management/ApiKeysManagementClient.d.ts +2 -2
- package/dist/components/management/ApiKeysManagementClient.d.ts.map +1 -1
- package/dist/components/management/ApiKeysManagementClient.js +539 -222
- package/dist/components/management/ApiKeysManagementClient.js.map +1 -1
- package/dist/components/management/PasskeysManagementClient.d.ts +2 -2
- package/dist/components/management/PasskeysManagementClient.d.ts.map +1 -1
- package/dist/components/management/PasskeysManagementClient.js +215 -92
- package/dist/components/management/PasskeysManagementClient.js.map +1 -1
- package/dist/components/management/SecurityNavLinks.d.ts +1 -1
- package/dist/components/management/SecurityNavLinks.d.ts.map +1 -1
- package/dist/components/management/SecurityNavLinks.js +51 -24
- package/dist/components/management/SecurityNavLinks.js.map +1 -1
- package/dist/components/management/TwoFactorManagementClient.d.ts +2 -2
- package/dist/components/management/TwoFactorManagementClient.d.ts.map +1 -1
- package/dist/components/management/TwoFactorManagementClient.js +270 -111
- package/dist/components/management/TwoFactorManagementClient.js.map +1 -1
- package/dist/components/management/index.js +2 -2
- package/dist/components/management/index.js.map +1 -1
- package/dist/components/management/views/ApiKeysView.d.ts +1 -1
- package/dist/components/management/views/ApiKeysView.d.ts.map +1 -1
- package/dist/components/management/views/ApiKeysView.js +19 -4
- package/dist/components/management/views/ApiKeysView.js.map +1 -1
- package/dist/components/management/views/PasskeysView.d.ts +1 -1
- package/dist/components/management/views/PasskeysView.d.ts.map +1 -1
- package/dist/components/management/views/PasskeysView.js +16 -4
- package/dist/components/management/views/PasskeysView.js.map +1 -1
- package/dist/components/management/views/TwoFactorView.d.ts +1 -1
- package/dist/components/management/views/TwoFactorView.d.ts.map +1 -1
- package/dist/components/management/views/TwoFactorView.js +16 -4
- package/dist/components/management/views/TwoFactorView.js.map +1 -1
- package/dist/components/management/views/index.js +2 -2
- package/dist/components/management/views/index.js.map +1 -1
- package/dist/components/twoFactor/TwoFactorSetupView.d.ts +1 -1
- package/dist/components/twoFactor/TwoFactorSetupView.d.ts.map +1 -1
- package/dist/components/twoFactor/TwoFactorSetupView.js +240 -87
- package/dist/components/twoFactor/TwoFactorSetupView.js.map +1 -1
- package/dist/components/twoFactor/TwoFactorVerifyView.d.ts +1 -1
- package/dist/components/twoFactor/TwoFactorVerifyView.d.ts.map +1 -1
- package/dist/components/twoFactor/TwoFactorVerifyView.js +108 -45
- package/dist/components/twoFactor/TwoFactorVerifyView.js.map +1 -1
- package/dist/components/twoFactor/index.js +2 -2
- package/dist/components/twoFactor/index.js.map +1 -1
- package/dist/exports/client.js +9 -10
- package/dist/exports/client.js.map +1 -1
- package/dist/exports/components.js +2 -2
- package/dist/exports/components.js.map +1 -1
- package/dist/exports/management.js +3 -3
- package/dist/exports/management.js.map +1 -1
- package/dist/exports/rsc.js +2 -2
- package/dist/exports/rsc.js.map +1 -1
- package/dist/generated-types.js +4 -2
- package/dist/generated-types.js.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.js +198 -162
- package/dist/plugin/index.js.map +1 -1
- package/dist/scripts/generate-types.js +66 -50
- package/dist/scripts/generate-types.js.map +1 -1
- package/dist/types/apiKey.js +7 -2
- package/dist/types/apiKey.js.map +1 -1
- package/dist/types/betterAuth.js +23 -2
- package/dist/types/betterAuth.js.map +1 -1
- package/dist/utils/access.js +78 -81
- package/dist/utils/access.js.map +1 -1
- package/dist/utils/apiKeyAccess.js +65 -72
- package/dist/utils/apiKeyAccess.js.map +1 -1
- package/dist/utils/betterAuthDefaults.js +8 -8
- package/dist/utils/betterAuthDefaults.js.map +1 -1
- package/dist/utils/detectAuthConfig.js +8 -11
- package/dist/utils/detectAuthConfig.js.map +1 -1
- package/dist/utils/detectEnabledPlugins.js +6 -7
- package/dist/utils/detectEnabledPlugins.js.map +1 -1
- package/dist/utils/firstUserAdmin.js +18 -20
- package/dist/utils/firstUserAdmin.js.map +1 -1
- package/dist/utils/generateScopes.js +40 -41
- package/dist/utils/generateScopes.js.map +1 -1
- package/dist/utils/session.js +8 -9
- package/dist/utils/session.js.map +1 -1
- package/package.json +27 -13
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState, useEffect } from 'react';
|
|
4
|
-
import { createPayloadAuthClient
|
|
4
|
+
import { createPayloadAuthClient } from '../../exports/client.js';
|
|
5
5
|
/**
|
|
6
6
|
* Client component for two-factor authentication management.
|
|
7
7
|
* Shows 2FA status and allows enabling/disabling.
|
|
8
|
-
*/
|
|
9
|
-
export function TwoFactorManagementClient({ authClient: providedClient, title = 'Two-Factor Authentication', } = {}) {
|
|
8
|
+
*/ export function TwoFactorManagementClient({ authClient: providedClient, title = 'Two-Factor Authentication' } = {}) {
|
|
10
9
|
const [isEnabled, setIsEnabled] = useState(false);
|
|
11
10
|
const [loading, setLoading] = useState(true);
|
|
12
11
|
const [error, setError] = useState(null);
|
|
@@ -17,10 +16,10 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
17
16
|
const [verificationCode, setVerificationCode] = useState('');
|
|
18
17
|
const [password, setPassword] = useState('');
|
|
19
18
|
const [actionLoading, setActionLoading] = useState(false);
|
|
20
|
-
const getClient = ()
|
|
21
|
-
useEffect(()
|
|
19
|
+
const getClient = ()=>providedClient ?? createPayloadAuthClient();
|
|
20
|
+
useEffect(()=>{
|
|
22
21
|
checkStatus();
|
|
23
|
-
|
|
22
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
23
|
}, []);
|
|
25
24
|
async function checkStatus() {
|
|
26
25
|
setLoading(true);
|
|
@@ -29,15 +28,12 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
29
28
|
const result = await client.getSession();
|
|
30
29
|
if (result.data?.user) {
|
|
31
30
|
setIsEnabled(result.data.user.twoFactorEnabled ?? false);
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
31
|
+
} else {
|
|
34
32
|
setIsEnabled(false);
|
|
35
33
|
}
|
|
36
|
-
}
|
|
37
|
-
catch {
|
|
34
|
+
} catch {
|
|
38
35
|
setError('Failed to check 2FA status');
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
36
|
+
} finally{
|
|
41
37
|
setLoading(false);
|
|
42
38
|
}
|
|
43
39
|
}
|
|
@@ -53,11 +49,12 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
53
49
|
setError(null);
|
|
54
50
|
try {
|
|
55
51
|
const client = getClient();
|
|
56
|
-
const result = await client.twoFactor.enable({
|
|
52
|
+
const result = await client.twoFactor.enable({
|
|
53
|
+
password
|
|
54
|
+
});
|
|
57
55
|
if (result.error) {
|
|
58
56
|
setError(result.error.message ?? 'Failed to enable 2FA');
|
|
59
|
-
}
|
|
60
|
-
else if (result.data) {
|
|
57
|
+
} else if (result.data) {
|
|
61
58
|
setTotpUri(result.data.totpURI);
|
|
62
59
|
// Secret is embedded in the totpURI, extract it for manual entry option
|
|
63
60
|
const secretMatch = result.data.totpURI.match(/secret=([A-Z2-7]+)/i);
|
|
@@ -66,11 +63,9 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
66
63
|
setPassword(''); // Clear password
|
|
67
64
|
setStep('setup');
|
|
68
65
|
}
|
|
69
|
-
}
|
|
70
|
-
catch {
|
|
66
|
+
} catch {
|
|
71
67
|
setError('Failed to enable 2FA');
|
|
72
|
-
}
|
|
73
|
-
finally {
|
|
68
|
+
} finally{
|
|
74
69
|
setActionLoading(false);
|
|
75
70
|
}
|
|
76
71
|
}
|
|
@@ -80,24 +75,22 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
80
75
|
setError(null);
|
|
81
76
|
try {
|
|
82
77
|
const client = getClient();
|
|
83
|
-
const result = await client.twoFactor.verifyTotp({
|
|
78
|
+
const result = await client.twoFactor.verifyTotp({
|
|
79
|
+
code: verificationCode
|
|
80
|
+
});
|
|
84
81
|
if (result.error) {
|
|
85
82
|
setError(result.error.message ?? 'Invalid verification code');
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
83
|
+
} else {
|
|
88
84
|
if (backupCodes.length > 0) {
|
|
89
85
|
setStep('backup');
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
86
|
+
} else {
|
|
92
87
|
setIsEnabled(true);
|
|
93
88
|
setStep('status');
|
|
94
89
|
}
|
|
95
90
|
}
|
|
96
|
-
}
|
|
97
|
-
catch {
|
|
91
|
+
} catch {
|
|
98
92
|
setError('Verification failed');
|
|
99
|
-
}
|
|
100
|
-
finally {
|
|
93
|
+
} finally{
|
|
101
94
|
setActionLoading(false);
|
|
102
95
|
}
|
|
103
96
|
}
|
|
@@ -109,18 +102,17 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
109
102
|
setError(null);
|
|
110
103
|
try {
|
|
111
104
|
const client = getClient();
|
|
112
|
-
const result = await client.twoFactor.disable({
|
|
105
|
+
const result = await client.twoFactor.disable({
|
|
106
|
+
password: ''
|
|
107
|
+
});
|
|
113
108
|
if (result.error) {
|
|
114
109
|
setError(result.error.message ?? 'Failed to disable 2FA');
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
110
|
+
} else {
|
|
117
111
|
setIsEnabled(false);
|
|
118
112
|
}
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
113
|
+
} catch {
|
|
121
114
|
setError('Failed to disable 2FA');
|
|
122
|
-
}
|
|
123
|
-
finally {
|
|
115
|
+
} finally{
|
|
124
116
|
setActionLoading(false);
|
|
125
117
|
}
|
|
126
118
|
}
|
|
@@ -129,79 +121,137 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
129
121
|
setStep('status');
|
|
130
122
|
}
|
|
131
123
|
if (loading) {
|
|
132
|
-
return
|
|
124
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
125
|
+
style: {
|
|
133
126
|
display: 'flex',
|
|
134
127
|
alignItems: 'center',
|
|
135
128
|
justifyContent: 'center',
|
|
136
|
-
padding: 'calc(var(--base) * 3)'
|
|
137
|
-
},
|
|
129
|
+
padding: 'calc(var(--base) * 3)'
|
|
130
|
+
},
|
|
131
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
132
|
+
style: {
|
|
133
|
+
color: 'var(--theme-text)',
|
|
134
|
+
opacity: 0.7
|
|
135
|
+
},
|
|
136
|
+
children: "Loading..."
|
|
137
|
+
})
|
|
138
|
+
});
|
|
138
139
|
}
|
|
139
|
-
return
|
|
140
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
141
|
+
style: {
|
|
140
142
|
maxWidth: '600px',
|
|
141
143
|
margin: '0 auto',
|
|
142
|
-
padding: 'calc(var(--base) * 2)'
|
|
143
|
-
},
|
|
144
|
+
padding: 'calc(var(--base) * 2)'
|
|
145
|
+
},
|
|
146
|
+
children: [
|
|
147
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
148
|
+
style: {
|
|
144
149
|
color: 'var(--theme-text)',
|
|
145
150
|
fontSize: 'var(--font-size-h2)',
|
|
146
151
|
fontWeight: 600,
|
|
147
|
-
margin: '0 0 calc(var(--base) * 2) 0'
|
|
148
|
-
},
|
|
152
|
+
margin: '0 0 calc(var(--base) * 2) 0'
|
|
153
|
+
},
|
|
154
|
+
children: title
|
|
155
|
+
}),
|
|
156
|
+
error && /*#__PURE__*/ _jsx("div", {
|
|
157
|
+
style: {
|
|
149
158
|
color: 'var(--theme-error-500)',
|
|
150
159
|
marginBottom: 'var(--base)',
|
|
151
160
|
fontSize: 'var(--font-size-small)',
|
|
152
161
|
padding: 'calc(var(--base) * 0.75)',
|
|
153
162
|
background: 'var(--theme-error-50)',
|
|
154
163
|
borderRadius: 'var(--style-radius-s)',
|
|
155
|
-
border: '1px solid var(--theme-error-200)'
|
|
156
|
-
},
|
|
164
|
+
border: '1px solid var(--theme-error-200)'
|
|
165
|
+
},
|
|
166
|
+
children: error
|
|
167
|
+
}),
|
|
168
|
+
step === 'status' && /*#__PURE__*/ _jsx("div", {
|
|
169
|
+
style: {
|
|
157
170
|
background: 'var(--theme-elevation-50)',
|
|
158
171
|
padding: 'calc(var(--base) * 1.5)',
|
|
159
172
|
borderRadius: 'var(--style-radius-m)',
|
|
160
|
-
border: '1px solid var(--theme-elevation-100)'
|
|
161
|
-
},
|
|
173
|
+
border: '1px solid var(--theme-elevation-100)'
|
|
174
|
+
},
|
|
175
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
176
|
+
style: {
|
|
162
177
|
display: 'flex',
|
|
163
178
|
justifyContent: 'space-between',
|
|
164
|
-
alignItems: 'center'
|
|
165
|
-
},
|
|
179
|
+
alignItems: 'center'
|
|
180
|
+
},
|
|
181
|
+
children: [
|
|
182
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
183
|
+
children: [
|
|
184
|
+
/*#__PURE__*/ _jsx("div", {
|
|
185
|
+
style: {
|
|
166
186
|
color: 'var(--theme-text)',
|
|
167
187
|
fontWeight: 500,
|
|
168
|
-
marginBottom: 'calc(var(--base) * 0.25)'
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
188
|
+
marginBottom: 'calc(var(--base) * 0.25)'
|
|
189
|
+
},
|
|
190
|
+
children: "Status"
|
|
191
|
+
}),
|
|
192
|
+
/*#__PURE__*/ _jsx("div", {
|
|
193
|
+
style: {
|
|
194
|
+
color: isEnabled ? 'var(--theme-success-500)' : 'var(--theme-elevation-600)',
|
|
195
|
+
fontSize: 'var(--font-size-small)'
|
|
196
|
+
},
|
|
197
|
+
children: isEnabled ? '✓ Enabled' : 'Not enabled'
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
}),
|
|
201
|
+
/*#__PURE__*/ _jsx("button", {
|
|
202
|
+
onClick: isEnabled ? handleDisable : handleEnableClick,
|
|
203
|
+
disabled: actionLoading,
|
|
204
|
+
style: {
|
|
175
205
|
padding: 'calc(var(--base) * 0.5) calc(var(--base) * 1)',
|
|
176
|
-
background: isEnabled
|
|
177
|
-
? 'var(--theme-error-500)'
|
|
178
|
-
: 'var(--theme-elevation-800)',
|
|
206
|
+
background: isEnabled ? 'var(--theme-error-500)' : 'var(--theme-elevation-800)',
|
|
179
207
|
border: 'none',
|
|
180
208
|
borderRadius: 'var(--style-radius-s)',
|
|
181
209
|
color: 'var(--theme-elevation-50)',
|
|
182
210
|
fontSize: 'var(--font-size-small)',
|
|
183
211
|
cursor: actionLoading ? 'not-allowed' : 'pointer',
|
|
184
|
-
opacity: actionLoading ? 0.7 : 1
|
|
185
|
-
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
212
|
+
opacity: actionLoading ? 0.7 : 1
|
|
213
|
+
},
|
|
214
|
+
children: actionLoading ? 'Loading...' : isEnabled ? 'Disable' : 'Enable'
|
|
215
|
+
})
|
|
216
|
+
]
|
|
217
|
+
})
|
|
218
|
+
}),
|
|
219
|
+
step === 'password' && /*#__PURE__*/ _jsxs("div", {
|
|
220
|
+
style: {
|
|
190
221
|
background: 'var(--theme-elevation-50)',
|
|
191
222
|
padding: 'calc(var(--base) * 2)',
|
|
192
223
|
borderRadius: 'var(--style-radius-m)',
|
|
193
|
-
border: '1px solid var(--theme-elevation-100)'
|
|
194
|
-
},
|
|
224
|
+
border: '1px solid var(--theme-elevation-100)'
|
|
225
|
+
},
|
|
226
|
+
children: [
|
|
227
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
228
|
+
style: {
|
|
195
229
|
color: 'var(--theme-text)',
|
|
196
230
|
fontSize: 'var(--font-size-h4)',
|
|
197
231
|
fontWeight: 500,
|
|
198
|
-
margin: '0 0 var(--base) 0'
|
|
199
|
-
},
|
|
232
|
+
margin: '0 0 var(--base) 0'
|
|
233
|
+
},
|
|
234
|
+
children: "Confirm Your Password"
|
|
235
|
+
}),
|
|
236
|
+
/*#__PURE__*/ _jsx("p", {
|
|
237
|
+
style: {
|
|
200
238
|
color: 'var(--theme-text)',
|
|
201
239
|
opacity: 0.7,
|
|
202
240
|
fontSize: 'var(--font-size-small)',
|
|
203
|
-
marginBottom: 'calc(var(--base) * 1.5)'
|
|
204
|
-
},
|
|
241
|
+
marginBottom: 'calc(var(--base) * 1.5)'
|
|
242
|
+
},
|
|
243
|
+
children: "Enter your password to enable two-factor authentication."
|
|
244
|
+
}),
|
|
245
|
+
/*#__PURE__*/ _jsxs("form", {
|
|
246
|
+
onSubmit: handleEnableWithPassword,
|
|
247
|
+
children: [
|
|
248
|
+
/*#__PURE__*/ _jsx("input", {
|
|
249
|
+
type: "password",
|
|
250
|
+
value: password,
|
|
251
|
+
onChange: (e)=>setPassword(e.target.value),
|
|
252
|
+
placeholder: "Enter your password",
|
|
253
|
+
required: true,
|
|
254
|
+
style: {
|
|
205
255
|
width: '100%',
|
|
206
256
|
padding: 'calc(var(--base) * 0.75)',
|
|
207
257
|
background: 'var(--theme-input-bg)',
|
|
@@ -210,8 +260,19 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
210
260
|
color: 'var(--theme-text)',
|
|
211
261
|
fontSize: 'var(--font-size-base)',
|
|
212
262
|
marginBottom: 'var(--base)',
|
|
213
|
-
boxSizing: 'border-box'
|
|
214
|
-
}
|
|
263
|
+
boxSizing: 'border-box'
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
266
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
267
|
+
style: {
|
|
268
|
+
display: 'flex',
|
|
269
|
+
gap: 'calc(var(--base) * 0.5)'
|
|
270
|
+
},
|
|
271
|
+
children: [
|
|
272
|
+
/*#__PURE__*/ _jsx("button", {
|
|
273
|
+
type: "submit",
|
|
274
|
+
disabled: actionLoading || !password,
|
|
275
|
+
style: {
|
|
215
276
|
padding: 'calc(var(--base) * 0.75) calc(var(--base) * 1.5)',
|
|
216
277
|
background: 'var(--theme-elevation-800)',
|
|
217
278
|
border: 'none',
|
|
@@ -219,44 +280,96 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
219
280
|
color: 'var(--theme-elevation-50)',
|
|
220
281
|
fontSize: 'var(--font-size-base)',
|
|
221
282
|
cursor: actionLoading || !password ? 'not-allowed' : 'pointer',
|
|
222
|
-
opacity: actionLoading || !password ? 0.7 : 1
|
|
223
|
-
},
|
|
283
|
+
opacity: actionLoading || !password ? 0.7 : 1
|
|
284
|
+
},
|
|
285
|
+
children: actionLoading ? 'Enabling...' : 'Continue'
|
|
286
|
+
}),
|
|
287
|
+
/*#__PURE__*/ _jsx("button", {
|
|
288
|
+
type: "button",
|
|
289
|
+
onClick: ()=>setStep('status'),
|
|
290
|
+
style: {
|
|
224
291
|
padding: 'calc(var(--base) * 0.75) calc(var(--base) * 1.5)',
|
|
225
292
|
background: 'transparent',
|
|
226
293
|
border: '1px solid var(--theme-elevation-200)',
|
|
227
294
|
borderRadius: 'var(--style-radius-s)',
|
|
228
295
|
color: 'var(--theme-text)',
|
|
229
296
|
fontSize: 'var(--font-size-base)',
|
|
230
|
-
cursor: 'pointer'
|
|
231
|
-
},
|
|
297
|
+
cursor: 'pointer'
|
|
298
|
+
},
|
|
299
|
+
children: "Cancel"
|
|
300
|
+
})
|
|
301
|
+
]
|
|
302
|
+
})
|
|
303
|
+
]
|
|
304
|
+
})
|
|
305
|
+
]
|
|
306
|
+
}),
|
|
307
|
+
step === 'setup' && totpUri && /*#__PURE__*/ _jsxs("div", {
|
|
308
|
+
style: {
|
|
232
309
|
background: 'var(--theme-elevation-50)',
|
|
233
310
|
padding: 'calc(var(--base) * 2)',
|
|
234
311
|
borderRadius: 'var(--style-radius-m)',
|
|
235
|
-
textAlign: 'center'
|
|
236
|
-
},
|
|
312
|
+
textAlign: 'center'
|
|
313
|
+
},
|
|
314
|
+
children: [
|
|
315
|
+
/*#__PURE__*/ _jsx("p", {
|
|
316
|
+
style: {
|
|
237
317
|
color: 'var(--theme-text)',
|
|
238
318
|
opacity: 0.7,
|
|
239
|
-
marginBottom: 'calc(var(--base) * 1.5)'
|
|
240
|
-
},
|
|
319
|
+
marginBottom: 'calc(var(--base) * 1.5)'
|
|
320
|
+
},
|
|
321
|
+
children: "Scan this QR code with your authenticator app:"
|
|
322
|
+
}),
|
|
323
|
+
/*#__PURE__*/ _jsx("img", {
|
|
324
|
+
src: `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(totpUri)}`,
|
|
325
|
+
alt: "QR Code",
|
|
326
|
+
style: {
|
|
241
327
|
width: '200px',
|
|
242
328
|
height: '200px',
|
|
243
329
|
border: '1px solid var(--theme-elevation-150)',
|
|
244
330
|
borderRadius: 'var(--style-radius-s)',
|
|
245
|
-
marginBottom: 'var(--base)'
|
|
246
|
-
}
|
|
331
|
+
marginBottom: 'var(--base)'
|
|
332
|
+
}
|
|
333
|
+
}),
|
|
334
|
+
secret && /*#__PURE__*/ _jsxs("div", {
|
|
335
|
+
style: {
|
|
336
|
+
marginBottom: 'calc(var(--base) * 1.5)'
|
|
337
|
+
},
|
|
338
|
+
children: [
|
|
339
|
+
/*#__PURE__*/ _jsx("p", {
|
|
340
|
+
style: {
|
|
247
341
|
color: 'var(--theme-text)',
|
|
248
342
|
opacity: 0.7,
|
|
249
343
|
fontSize: 'var(--font-size-small)',
|
|
250
|
-
marginBottom: 'calc(var(--base) * 0.5)'
|
|
251
|
-
},
|
|
344
|
+
marginBottom: 'calc(var(--base) * 0.5)'
|
|
345
|
+
},
|
|
346
|
+
children: "Or enter manually:"
|
|
347
|
+
}),
|
|
348
|
+
/*#__PURE__*/ _jsx("code", {
|
|
349
|
+
style: {
|
|
252
350
|
display: 'inline-block',
|
|
253
351
|
padding: 'calc(var(--base) * 0.5)',
|
|
254
352
|
background: 'var(--theme-elevation-100)',
|
|
255
353
|
borderRadius: 'var(--style-radius-s)',
|
|
256
354
|
fontFamily: 'monospace',
|
|
257
355
|
fontSize: 'var(--font-size-small)',
|
|
258
|
-
color: 'var(--theme-text)'
|
|
259
|
-
},
|
|
356
|
+
color: 'var(--theme-text)'
|
|
357
|
+
},
|
|
358
|
+
children: secret
|
|
359
|
+
})
|
|
360
|
+
]
|
|
361
|
+
}),
|
|
362
|
+
/*#__PURE__*/ _jsxs("form", {
|
|
363
|
+
onSubmit: handleVerify,
|
|
364
|
+
children: [
|
|
365
|
+
/*#__PURE__*/ _jsx("input", {
|
|
366
|
+
type: "text",
|
|
367
|
+
inputMode: "numeric",
|
|
368
|
+
pattern: "[0-9]*",
|
|
369
|
+
value: verificationCode,
|
|
370
|
+
onChange: (e)=>setVerificationCode(e.target.value.replace(/\D/g, '').slice(0, 6)),
|
|
371
|
+
placeholder: "Enter 6-digit code",
|
|
372
|
+
style: {
|
|
260
373
|
width: '100%',
|
|
261
374
|
maxWidth: '200px',
|
|
262
375
|
padding: 'calc(var(--base) * 0.75)',
|
|
@@ -269,48 +382,82 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
269
382
|
textAlign: 'center',
|
|
270
383
|
letterSpacing: '0.5em',
|
|
271
384
|
marginBottom: 'var(--base)',
|
|
272
|
-
boxSizing: 'border-box'
|
|
273
|
-
}
|
|
385
|
+
boxSizing: 'border-box'
|
|
386
|
+
}
|
|
387
|
+
}),
|
|
388
|
+
/*#__PURE__*/ _jsx("br", {}),
|
|
389
|
+
/*#__PURE__*/ _jsx("button", {
|
|
390
|
+
type: "submit",
|
|
391
|
+
disabled: actionLoading || verificationCode.length !== 6,
|
|
392
|
+
style: {
|
|
274
393
|
padding: 'calc(var(--base) * 0.75) calc(var(--base) * 2)',
|
|
275
394
|
background: 'var(--theme-elevation-800)',
|
|
276
395
|
border: 'none',
|
|
277
396
|
borderRadius: 'var(--style-radius-s)',
|
|
278
397
|
color: 'var(--theme-elevation-50)',
|
|
279
398
|
fontSize: 'var(--font-size-base)',
|
|
280
|
-
cursor: actionLoading || verificationCode.length !== 6
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
399
|
+
cursor: actionLoading || verificationCode.length !== 6 ? 'not-allowed' : 'pointer',
|
|
400
|
+
opacity: actionLoading || verificationCode.length !== 6 ? 0.7 : 1
|
|
401
|
+
},
|
|
402
|
+
children: actionLoading ? 'Verifying...' : 'Verify'
|
|
403
|
+
})
|
|
404
|
+
]
|
|
405
|
+
})
|
|
406
|
+
]
|
|
407
|
+
}),
|
|
408
|
+
step === 'backup' && /*#__PURE__*/ _jsxs("div", {
|
|
409
|
+
style: {
|
|
285
410
|
background: 'var(--theme-elevation-50)',
|
|
286
411
|
padding: 'calc(var(--base) * 2)',
|
|
287
|
-
borderRadius: 'var(--style-radius-m)'
|
|
288
|
-
},
|
|
412
|
+
borderRadius: 'var(--style-radius-m)'
|
|
413
|
+
},
|
|
414
|
+
children: [
|
|
415
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
416
|
+
style: {
|
|
289
417
|
color: 'var(--theme-text)',
|
|
290
418
|
fontSize: 'var(--font-size-h3)',
|
|
291
419
|
fontWeight: 600,
|
|
292
420
|
margin: '0 0 var(--base) 0',
|
|
293
|
-
textAlign: 'center'
|
|
294
|
-
},
|
|
421
|
+
textAlign: 'center'
|
|
422
|
+
},
|
|
423
|
+
children: "Save Your Backup Codes"
|
|
424
|
+
}),
|
|
425
|
+
/*#__PURE__*/ _jsx("p", {
|
|
426
|
+
style: {
|
|
295
427
|
color: 'var(--theme-text)',
|
|
296
428
|
opacity: 0.7,
|
|
297
429
|
fontSize: 'var(--font-size-small)',
|
|
298
430
|
textAlign: 'center',
|
|
299
|
-
marginBottom: 'calc(var(--base) * 1.5)'
|
|
300
|
-
},
|
|
431
|
+
marginBottom: 'calc(var(--base) * 1.5)'
|
|
432
|
+
},
|
|
433
|
+
children: "Store these codes safely. Use them if you lose your authenticator."
|
|
434
|
+
}),
|
|
435
|
+
/*#__PURE__*/ _jsx("div", {
|
|
436
|
+
style: {
|
|
301
437
|
background: 'var(--theme-elevation-100)',
|
|
302
438
|
padding: 'var(--base)',
|
|
303
439
|
borderRadius: 'var(--style-radius-s)',
|
|
304
440
|
marginBottom: 'var(--base)',
|
|
305
|
-
fontFamily: 'monospace'
|
|
306
|
-
},
|
|
441
|
+
fontFamily: 'monospace'
|
|
442
|
+
},
|
|
443
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
444
|
+
style: {
|
|
307
445
|
display: 'grid',
|
|
308
446
|
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
309
|
-
gap: 'calc(var(--base) * 0.5)'
|
|
310
|
-
},
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
447
|
+
gap: 'calc(var(--base) * 0.5)'
|
|
448
|
+
},
|
|
449
|
+
children: backupCodes.map((code, index)=>/*#__PURE__*/ _jsx("div", {
|
|
450
|
+
style: {
|
|
451
|
+
color: 'var(--theme-text)',
|
|
452
|
+
padding: 'calc(var(--base) * 0.25)'
|
|
453
|
+
},
|
|
454
|
+
children: code
|
|
455
|
+
}, index))
|
|
456
|
+
})
|
|
457
|
+
}),
|
|
458
|
+
/*#__PURE__*/ _jsx("button", {
|
|
459
|
+
onClick: ()=>navigator.clipboard.writeText(backupCodes.join('\n')),
|
|
460
|
+
style: {
|
|
314
461
|
width: '100%',
|
|
315
462
|
padding: 'calc(var(--base) * 0.5)',
|
|
316
463
|
background: 'var(--theme-elevation-150)',
|
|
@@ -319,8 +466,13 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
319
466
|
color: 'var(--theme-text)',
|
|
320
467
|
fontSize: 'var(--font-size-small)',
|
|
321
468
|
cursor: 'pointer',
|
|
322
|
-
marginBottom: 'var(--base)'
|
|
323
|
-
},
|
|
469
|
+
marginBottom: 'var(--base)'
|
|
470
|
+
},
|
|
471
|
+
children: "Copy to Clipboard"
|
|
472
|
+
}),
|
|
473
|
+
/*#__PURE__*/ _jsx("button", {
|
|
474
|
+
onClick: handleBackupContinue,
|
|
475
|
+
style: {
|
|
324
476
|
width: '100%',
|
|
325
477
|
padding: 'calc(var(--base) * 0.75)',
|
|
326
478
|
background: 'var(--theme-elevation-800)',
|
|
@@ -328,8 +480,15 @@ export function TwoFactorManagementClient({ authClient: providedClient, title =
|
|
|
328
480
|
borderRadius: 'var(--style-radius-s)',
|
|
329
481
|
color: 'var(--theme-elevation-50)',
|
|
330
482
|
fontSize: 'var(--font-size-base)',
|
|
331
|
-
cursor: 'pointer'
|
|
332
|
-
},
|
|
483
|
+
cursor: 'pointer'
|
|
484
|
+
},
|
|
485
|
+
children: "I've Saved My Codes"
|
|
486
|
+
})
|
|
487
|
+
]
|
|
488
|
+
})
|
|
489
|
+
]
|
|
490
|
+
});
|
|
333
491
|
}
|
|
334
492
|
export default TwoFactorManagementClient;
|
|
493
|
+
|
|
335
494
|
//# sourceMappingURL=TwoFactorManagementClient.js.map
|