@delmaredigital/payload-better-auth 0.3.6 → 0.3.8

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.
Files changed (164) hide show
  1. package/README.md +60 -12
  2. package/dist/adapter/collections.d.ts.map +1 -1
  3. package/dist/adapter/collections.js +126 -88
  4. package/dist/adapter/collections.js.map +1 -1
  5. package/dist/adapter/index.js +197 -150
  6. package/dist/adapter/index.js.map +1 -1
  7. package/dist/components/BeforeLogin.d.ts +1 -1
  8. package/dist/components/BeforeLogin.d.ts.map +1 -1
  9. package/dist/components/BeforeLogin.js +15 -7
  10. package/dist/components/BeforeLogin.js.map +1 -1
  11. package/dist/components/LoginView.d.ts +2 -2
  12. package/dist/components/LoginView.d.ts.map +1 -1
  13. package/dist/components/LoginView.js +660 -218
  14. package/dist/components/LoginView.js.map +1 -1
  15. package/dist/components/LoginViewWrapper.d.ts +1 -1
  16. package/dist/components/LoginViewWrapper.d.ts.map +1 -1
  17. package/dist/components/LoginViewWrapper.js +14 -4
  18. package/dist/components/LoginViewWrapper.js.map +1 -1
  19. package/dist/components/LogoutButton.d.ts +1 -1
  20. package/dist/components/LogoutButton.d.ts.map +1 -1
  21. package/dist/components/LogoutButton.js +19 -11
  22. package/dist/components/LogoutButton.js.map +1 -1
  23. package/dist/components/PasskeyRegisterButton.d.ts +2 -2
  24. package/dist/components/PasskeyRegisterButton.d.ts.map +1 -1
  25. package/dist/components/PasskeyRegisterButton.js +20 -16
  26. package/dist/components/PasskeyRegisterButton.js.map +1 -1
  27. package/dist/components/PasskeySignInButton.d.ts +2 -2
  28. package/dist/components/PasskeySignInButton.d.ts.map +1 -1
  29. package/dist/components/PasskeySignInButton.js +14 -12
  30. package/dist/components/PasskeySignInButton.js.map +1 -1
  31. package/dist/components/auth/ForgotPasswordView.d.ts +1 -1
  32. package/dist/components/auth/ForgotPasswordView.d.ts.map +1 -1
  33. package/dist/components/auth/ForgotPasswordView.js +133 -43
  34. package/dist/components/auth/ForgotPasswordView.js.map +1 -1
  35. package/dist/components/auth/ResetPasswordView.d.ts +1 -1
  36. package/dist/components/auth/ResetPasswordView.d.ts.map +1 -1
  37. package/dist/components/auth/ResetPasswordView.js +154 -50
  38. package/dist/components/auth/ResetPasswordView.js.map +1 -1
  39. package/dist/components/auth/index.js +2 -2
  40. package/dist/components/auth/index.js.map +1 -1
  41. package/dist/components/management/ApiKeysManagementClient.d.ts +2 -2
  42. package/dist/components/management/ApiKeysManagementClient.d.ts.map +1 -1
  43. package/dist/components/management/ApiKeysManagementClient.js +539 -222
  44. package/dist/components/management/ApiKeysManagementClient.js.map +1 -1
  45. package/dist/components/management/PasskeysManagementClient.d.ts +2 -2
  46. package/dist/components/management/PasskeysManagementClient.d.ts.map +1 -1
  47. package/dist/components/management/PasskeysManagementClient.js +215 -92
  48. package/dist/components/management/PasskeysManagementClient.js.map +1 -1
  49. package/dist/components/management/SecurityNavLinks.d.ts +1 -1
  50. package/dist/components/management/SecurityNavLinks.d.ts.map +1 -1
  51. package/dist/components/management/SecurityNavLinks.js +51 -24
  52. package/dist/components/management/SecurityNavLinks.js.map +1 -1
  53. package/dist/components/management/TwoFactorManagementClient.d.ts +2 -2
  54. package/dist/components/management/TwoFactorManagementClient.d.ts.map +1 -1
  55. package/dist/components/management/TwoFactorManagementClient.js +270 -111
  56. package/dist/components/management/TwoFactorManagementClient.js.map +1 -1
  57. package/dist/components/management/index.js +2 -2
  58. package/dist/components/management/index.js.map +1 -1
  59. package/dist/components/management/views/ApiKeysView.d.ts +1 -1
  60. package/dist/components/management/views/ApiKeysView.d.ts.map +1 -1
  61. package/dist/components/management/views/ApiKeysView.js +19 -4
  62. package/dist/components/management/views/ApiKeysView.js.map +1 -1
  63. package/dist/components/management/views/PasskeysView.d.ts +1 -1
  64. package/dist/components/management/views/PasskeysView.d.ts.map +1 -1
  65. package/dist/components/management/views/PasskeysView.js +16 -4
  66. package/dist/components/management/views/PasskeysView.js.map +1 -1
  67. package/dist/components/management/views/TwoFactorView.d.ts +1 -1
  68. package/dist/components/management/views/TwoFactorView.d.ts.map +1 -1
  69. package/dist/components/management/views/TwoFactorView.js +16 -4
  70. package/dist/components/management/views/TwoFactorView.js.map +1 -1
  71. package/dist/components/management/views/index.js +2 -2
  72. package/dist/components/management/views/index.js.map +1 -1
  73. package/dist/components/twoFactor/TwoFactorSetupView.d.ts +1 -1
  74. package/dist/components/twoFactor/TwoFactorSetupView.d.ts.map +1 -1
  75. package/dist/components/twoFactor/TwoFactorSetupView.js +240 -87
  76. package/dist/components/twoFactor/TwoFactorSetupView.js.map +1 -1
  77. package/dist/components/twoFactor/TwoFactorVerifyView.d.ts +1 -1
  78. package/dist/components/twoFactor/TwoFactorVerifyView.d.ts.map +1 -1
  79. package/dist/components/twoFactor/TwoFactorVerifyView.js +108 -45
  80. package/dist/components/twoFactor/TwoFactorVerifyView.js.map +1 -1
  81. package/dist/components/twoFactor/index.js +2 -2
  82. package/dist/components/twoFactor/index.js.map +1 -1
  83. package/dist/exports/client.d.ts +2356 -2
  84. package/dist/exports/client.d.ts.map +1 -1
  85. package/dist/exports/client.js +48 -8
  86. package/dist/exports/client.js.map +1 -1
  87. package/dist/exports/components.js +2 -2
  88. package/dist/exports/components.js.map +1 -1
  89. package/dist/exports/management.js +3 -3
  90. package/dist/exports/management.js.map +1 -1
  91. package/dist/exports/rsc.js +2 -2
  92. package/dist/exports/rsc.js.map +1 -1
  93. package/dist/generated-types.js +4 -2
  94. package/dist/generated-types.js.map +1 -1
  95. package/dist/index.js +6 -6
  96. package/dist/index.js.map +1 -1
  97. package/dist/plugin/index.d.ts +35 -2
  98. package/dist/plugin/index.d.ts.map +1 -1
  99. package/dist/plugin/index.js +198 -162
  100. package/dist/plugin/index.js.map +1 -1
  101. package/dist/scripts/generate-types.js +66 -50
  102. package/dist/scripts/generate-types.js.map +1 -1
  103. package/dist/types/apiKey.js +7 -2
  104. package/dist/types/apiKey.js.map +1 -1
  105. package/dist/types/betterAuth.js +23 -2
  106. package/dist/types/betterAuth.js.map +1 -1
  107. package/dist/utils/access.js +78 -81
  108. package/dist/utils/access.js.map +1 -1
  109. package/dist/utils/apiKeyAccess.js +65 -72
  110. package/dist/utils/apiKeyAccess.js.map +1 -1
  111. package/dist/utils/betterAuthDefaults.js +8 -8
  112. package/dist/utils/betterAuthDefaults.js.map +1 -1
  113. package/dist/utils/detectAuthConfig.js +8 -11
  114. package/dist/utils/detectAuthConfig.js.map +1 -1
  115. package/dist/utils/detectEnabledPlugins.js +6 -7
  116. package/dist/utils/detectEnabledPlugins.js.map +1 -1
  117. package/dist/utils/firstUserAdmin.js +18 -20
  118. package/dist/utils/firstUserAdmin.js.map +1 -1
  119. package/dist/utils/generateScopes.js +40 -41
  120. package/dist/utils/generateScopes.js.map +1 -1
  121. package/dist/utils/session.js +8 -9
  122. package/dist/utils/session.js.map +1 -1
  123. package/package.json +97 -26
  124. package/src/adapter/collections.ts +621 -0
  125. package/src/adapter/index.ts +712 -0
  126. package/src/components/BeforeLogin.tsx +39 -0
  127. package/src/components/LoginView.tsx +1516 -0
  128. package/src/components/LoginViewWrapper.tsx +35 -0
  129. package/src/components/LogoutButton.tsx +58 -0
  130. package/src/components/PasskeyRegisterButton.tsx +105 -0
  131. package/src/components/PasskeySignInButton.tsx +96 -0
  132. package/src/components/auth/ForgotPasswordView.tsx +274 -0
  133. package/src/components/auth/ResetPasswordView.tsx +331 -0
  134. package/src/components/auth/index.ts +8 -0
  135. package/src/components/management/ApiKeysManagementClient.tsx +988 -0
  136. package/src/components/management/PasskeysManagementClient.tsx +409 -0
  137. package/src/components/management/SecurityNavLinks.tsx +117 -0
  138. package/src/components/management/TwoFactorManagementClient.tsx +560 -0
  139. package/src/components/management/index.ts +20 -0
  140. package/src/components/management/views/ApiKeysView.tsx +57 -0
  141. package/src/components/management/views/PasskeysView.tsx +42 -0
  142. package/src/components/management/views/TwoFactorView.tsx +42 -0
  143. package/src/components/management/views/index.ts +10 -0
  144. package/src/components/twoFactor/TwoFactorSetupView.tsx +515 -0
  145. package/src/components/twoFactor/TwoFactorVerifyView.tsx +238 -0
  146. package/src/components/twoFactor/index.ts +8 -0
  147. package/src/exports/client.ts +77 -0
  148. package/src/exports/components.ts +30 -0
  149. package/src/exports/management.ts +25 -0
  150. package/src/exports/rsc.ts +11 -0
  151. package/src/generated-types.ts +269 -0
  152. package/src/index.ts +135 -0
  153. package/src/plugin/index.ts +834 -0
  154. package/src/scripts/generate-types.ts +269 -0
  155. package/src/types/apiKey.ts +63 -0
  156. package/src/types/betterAuth.ts +253 -0
  157. package/src/utils/access.ts +410 -0
  158. package/src/utils/apiKeyAccess.ts +443 -0
  159. package/src/utils/betterAuthDefaults.ts +102 -0
  160. package/src/utils/detectAuthConfig.ts +47 -0
  161. package/src/utils/detectEnabledPlugins.ts +69 -0
  162. package/src/utils/firstUserAdmin.ts +164 -0
  163. package/src/utils/generateScopes.ts +150 -0
  164. package/src/utils/session.ts +91 -0
@@ -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, } from '../../exports/client';
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 = () => providedClient ?? createPayloadAuthClient();
21
- useEffect(() => {
19
+ const getClient = ()=>providedClient ?? createPayloadAuthClient();
20
+ useEffect(()=>{
22
21
  checkStatus();
23
- // eslint-disable-next-line react-hooks/exhaustive-deps
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({ password });
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({ code: verificationCode });
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({ password: '' });
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 (_jsx("div", { style: {
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
- }, children: _jsx("div", { style: { color: 'var(--theme-text)', opacity: 0.7 }, children: "Loading..." }) }));
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 (_jsxs("div", { style: {
140
+ return /*#__PURE__*/ _jsxs("div", {
141
+ style: {
140
142
  maxWidth: '600px',
141
143
  margin: '0 auto',
142
- padding: 'calc(var(--base) * 2)',
143
- }, children: [_jsx("h1", { style: {
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
- }, children: title }), error && (_jsx("div", { style: {
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
- }, children: error })), step === 'status' && (_jsx("div", { style: {
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
- }, children: _jsxs("div", { style: {
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
- }, children: [_jsxs("div", { children: [_jsx("div", { style: {
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
- }, children: "Status" }), _jsx("div", { style: {
170
- color: isEnabled
171
- ? 'var(--theme-success-500)'
172
- : 'var(--theme-elevation-600)',
173
- fontSize: 'var(--font-size-small)',
174
- }, children: isEnabled ? '✓ Enabled' : 'Not enabled' })] }), _jsx("button", { onClick: isEnabled ? handleDisable : handleEnableClick, disabled: actionLoading, style: {
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
- }, children: actionLoading
186
- ? 'Loading...'
187
- : isEnabled
188
- ? 'Disable'
189
- : 'Enable' })] }) })), step === 'password' && (_jsxs("div", { style: {
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
- }, children: [_jsx("h2", { style: {
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
- }, children: "Confirm Your Password" }), _jsx("p", { style: {
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
- }, children: "Enter your password to enable two-factor authentication." }), _jsxs("form", { onSubmit: handleEnableWithPassword, children: [_jsx("input", { type: "password", value: password, onChange: (e) => setPassword(e.target.value), placeholder: "Enter your password", required: true, style: {
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
- } }), _jsxs("div", { style: { display: 'flex', gap: 'calc(var(--base) * 0.5)' }, children: [_jsx("button", { type: "submit", disabled: actionLoading || !password, style: {
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
- }, children: actionLoading ? 'Enabling...' : 'Continue' }), _jsx("button", { type: "button", onClick: () => setStep('status'), style: {
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
- }, children: "Cancel" })] })] })] })), step === 'setup' && totpUri && (_jsxs("div", { style: {
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
- }, children: [_jsx("p", { style: {
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
- }, children: "Scan this QR code with your authenticator app:" }), _jsx("img", { src: `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(totpUri)}`, alt: "QR Code", style: {
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
- } }), secret && (_jsxs("div", { style: { marginBottom: 'calc(var(--base) * 1.5)' }, children: [_jsx("p", { style: {
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
- }, children: "Or enter manually:" }), _jsx("code", { style: {
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
- }, children: secret })] })), _jsxs("form", { onSubmit: handleVerify, children: [_jsx("input", { type: "text", inputMode: "numeric", pattern: "[0-9]*", value: verificationCode, onChange: (e) => setVerificationCode(e.target.value.replace(/\D/g, '').slice(0, 6)), placeholder: "Enter 6-digit code", style: {
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
- } }), _jsx("br", {}), _jsx("button", { type: "submit", disabled: actionLoading || verificationCode.length !== 6, style: {
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
- ? 'not-allowed'
282
- : 'pointer',
283
- opacity: actionLoading || verificationCode.length !== 6 ? 0.7 : 1,
284
- }, children: actionLoading ? 'Verifying...' : 'Verify' })] })] })), step === 'backup' && (_jsxs("div", { style: {
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
- }, children: [_jsx("h2", { style: {
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
- }, children: "Save Your Backup Codes" }), _jsx("p", { style: {
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
- }, children: "Store these codes safely. Use them if you lose your authenticator." }), _jsx("div", { style: {
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
- }, children: _jsx("div", { style: {
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
- }, children: backupCodes.map((code, index) => (_jsx("div", { style: {
311
- color: 'var(--theme-text)',
312
- padding: 'calc(var(--base) * 0.25)',
313
- }, children: code }, index))) }) }), _jsx("button", { onClick: () => navigator.clipboard.writeText(backupCodes.join('\n')), style: {
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
- }, children: "Copy to Clipboard" }), _jsx("button", { onClick: handleBackupContinue, style: {
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
- }, children: "I've Saved My Codes" })] }))] }));
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