@datatechsolutions/ui 2.11.86 → 2.11.88
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/dist/billing-panel-DsHhhJqG.d.mts +18 -0
- package/dist/billing-panel-DsHhhJqG.d.ts +18 -0
- package/dist/chunk-4667D2ZT.mjs +61 -0
- package/dist/chunk-4667D2ZT.mjs.map +1 -0
- package/dist/chunk-5HXDJBVX.mjs +1330 -0
- package/dist/chunk-5HXDJBVX.mjs.map +1 -0
- package/dist/chunk-DJ33CSGJ.mjs +126 -0
- package/dist/chunk-DJ33CSGJ.mjs.map +1 -0
- package/dist/chunk-F4TOOARV.mjs +503 -0
- package/dist/chunk-F4TOOARV.mjs.map +1 -0
- package/dist/chunk-GEUGFYLO.mjs +237 -0
- package/dist/chunk-GEUGFYLO.mjs.map +1 -0
- package/dist/chunk-LBALE4JX.js +1342 -0
- package/dist/chunk-LBALE4JX.js.map +1 -0
- package/dist/chunk-MXFEU7A6.js +148 -0
- package/dist/chunk-MXFEU7A6.js.map +1 -0
- package/dist/chunk-NBCOVUQP.mjs +142 -0
- package/dist/chunk-NBCOVUQP.mjs.map +1 -0
- package/dist/chunk-P4RVGMZL.js +128 -0
- package/dist/chunk-P4RVGMZL.js.map +1 -0
- package/dist/chunk-Q2MG7S2E.js +239 -0
- package/dist/chunk-Q2MG7S2E.js.map +1 -0
- package/dist/chunk-RV555OEO.mjs +1009 -0
- package/dist/chunk-RV555OEO.mjs.map +1 -0
- package/dist/chunk-SAYVWIMJ.js +63 -0
- package/dist/chunk-SAYVWIMJ.js.map +1 -0
- package/dist/chunk-SUHNSUMH.mjs +1021 -0
- package/dist/chunk-SUHNSUMH.mjs.map +1 -0
- package/dist/chunk-TOEMSC4P.mjs +99 -0
- package/dist/chunk-TOEMSC4P.mjs.map +1 -0
- package/dist/chunk-UUHV5KHF.js +505 -0
- package/dist/chunk-UUHV5KHF.js.map +1 -0
- package/dist/chunk-UVEPTYZC.js +101 -0
- package/dist/chunk-UVEPTYZC.js.map +1 -0
- package/dist/chunk-X2KCCQPL.js +1049 -0
- package/dist/chunk-X2KCCQPL.js.map +1 -0
- package/dist/chunk-ZARCUQA6.js +1015 -0
- package/dist/chunk-ZARCUQA6.js.map +1 -0
- package/dist/platform/admin/index.d.mts +17 -0
- package/dist/platform/admin/index.d.ts +17 -0
- package/dist/platform/admin/index.js +39 -0
- package/dist/platform/admin/index.js.map +1 -0
- package/dist/platform/admin/index.mjs +10 -0
- package/dist/platform/admin/index.mjs.map +1 -0
- package/dist/platform/auth/index.d.mts +73 -0
- package/dist/platform/auth/index.d.ts +73 -0
- package/dist/platform/auth/index.js +107 -0
- package/dist/platform/auth/index.js.map +1 -0
- package/dist/platform/auth/index.mjs +10 -0
- package/dist/platform/auth/index.mjs.map +1 -0
- package/dist/platform/billing/index.d.mts +29 -0
- package/dist/platform/billing/index.d.ts +29 -0
- package/dist/platform/billing/index.js +22 -0
- package/dist/platform/billing/index.js.map +1 -0
- package/dist/platform/billing/index.mjs +9 -0
- package/dist/platform/billing/index.mjs.map +1 -0
- package/dist/platform/impersonation/index.d.mts +19 -0
- package/dist/platform/impersonation/index.d.ts +19 -0
- package/dist/platform/impersonation/index.js +17 -0
- package/dist/platform/impersonation/index.js.map +1 -0
- package/dist/platform/impersonation/index.mjs +8 -0
- package/dist/platform/impersonation/index.mjs.map +1 -0
- package/dist/platform/index.d.mts +45 -2
- package/dist/platform/index.d.ts +45 -2
- package/dist/platform/index.js +4850 -0
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/index.mjs +4716 -3
- package/dist/platform/index.mjs.map +1 -1
- package/dist/platform/settings/index.d.mts +31 -0
- package/dist/platform/settings/index.d.ts +31 -0
- package/dist/platform/settings/index.js +21 -0
- package/dist/platform/settings/index.js.map +1 -0
- package/dist/platform/settings/index.mjs +12 -0
- package/dist/platform/settings/index.mjs.map +1 -0
- package/package.json +26 -1
|
@@ -0,0 +1,1342 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var chunkMXFEU7A6_js = require('./chunk-MXFEU7A6.js');
|
|
5
|
+
var chunkKNXAOJAK_js = require('./chunk-KNXAOJAK.js');
|
|
6
|
+
var chunkUZ3CMNUJ_js = require('./chunk-UZ3CMNUJ.js');
|
|
7
|
+
var chunkYXN2K77G_js = require('./chunk-YXN2K77G.js');
|
|
8
|
+
var react = require('react');
|
|
9
|
+
var outline = require('@heroicons/react/24/outline');
|
|
10
|
+
var client = require('@datatechsolutions/windsock/client');
|
|
11
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
+
var solid = require('@heroicons/react/20/solid');
|
|
13
|
+
var react$1 = require('@headlessui/react');
|
|
14
|
+
|
|
15
|
+
function MfaChallenge({
|
|
16
|
+
mfaToken,
|
|
17
|
+
onSuccess,
|
|
18
|
+
onCancel,
|
|
19
|
+
availableMethods = ["totp", "backup"],
|
|
20
|
+
embedded = false
|
|
21
|
+
}) {
|
|
22
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
23
|
+
const { verifyMFA } = client.useAuth();
|
|
24
|
+
const [method, setMethod] = react.useState("totp");
|
|
25
|
+
const [totpCode, setTotpCode] = react.useState("");
|
|
26
|
+
const [backupCode, setBackupCode] = react.useState("");
|
|
27
|
+
const [error, setError] = react.useState(null);
|
|
28
|
+
const [isSubmitting, setIsSubmitting] = react.useState(false);
|
|
29
|
+
const [failureCount, setFailureCount] = react.useState(0);
|
|
30
|
+
const handleVerify = react.useCallback(
|
|
31
|
+
async (code) => {
|
|
32
|
+
setError(null);
|
|
33
|
+
setIsSubmitting(true);
|
|
34
|
+
chunkUZ3CMNUJ_js.triggerHaptic("light");
|
|
35
|
+
try {
|
|
36
|
+
const result = await verifyMFA(mfaToken, code);
|
|
37
|
+
if (result.success) {
|
|
38
|
+
chunkUZ3CMNUJ_js.triggerHaptic("success");
|
|
39
|
+
onSuccess?.();
|
|
40
|
+
} else if (result.error) {
|
|
41
|
+
chunkUZ3CMNUJ_js.triggerHaptic("error");
|
|
42
|
+
const count = failureCount + 1;
|
|
43
|
+
setFailureCount(count);
|
|
44
|
+
if (count >= 3) {
|
|
45
|
+
setError(t("mfa.challenge.errorLockout"));
|
|
46
|
+
} else {
|
|
47
|
+
setError(t("mfa.challenge.errorInvalidCode"));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
chunkUZ3CMNUJ_js.triggerHaptic("error");
|
|
52
|
+
setError(t("mfa.challenge.errorVerificationFailed"));
|
|
53
|
+
} finally {
|
|
54
|
+
setIsSubmitting(false);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
[verifyMFA, mfaToken, onSuccess, failureCount, t]
|
|
58
|
+
);
|
|
59
|
+
const handleTotpComplete = react.useCallback(
|
|
60
|
+
(code) => {
|
|
61
|
+
handleVerify(code);
|
|
62
|
+
},
|
|
63
|
+
[handleVerify]
|
|
64
|
+
);
|
|
65
|
+
const handleBackupSubmit = react.useCallback(() => {
|
|
66
|
+
if (backupCode.trim()) {
|
|
67
|
+
handleVerify(backupCode.trim());
|
|
68
|
+
}
|
|
69
|
+
}, [backupCode, handleVerify]);
|
|
70
|
+
const handleMethodChange = react.useCallback((value) => {
|
|
71
|
+
chunkUZ3CMNUJ_js.triggerHaptic("light");
|
|
72
|
+
setMethod(value);
|
|
73
|
+
setError(null);
|
|
74
|
+
setTotpCode("");
|
|
75
|
+
setBackupCode("");
|
|
76
|
+
}, []);
|
|
77
|
+
const segments = availableMethods.map((m) => ({
|
|
78
|
+
value: m,
|
|
79
|
+
label: m === "totp" ? t("mfa.challenge.methodTotp") : t("mfa.challenge.methodBackup")
|
|
80
|
+
}));
|
|
81
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-5", children: [
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
83
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-semibold text-gray-900 dark:text-white", children: t("mfa.challenge.title") }),
|
|
84
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-400", children: method === "totp" ? t("mfa.challenge.descriptionTotp") : t("mfa.challenge.descriptionBackup") })
|
|
85
|
+
] }),
|
|
86
|
+
availableMethods.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
87
|
+
chunkKNXAOJAK_js.SegmentedControl,
|
|
88
|
+
{
|
|
89
|
+
segments,
|
|
90
|
+
value: method,
|
|
91
|
+
onChange: handleMethodChange,
|
|
92
|
+
size: "sm"
|
|
93
|
+
}
|
|
94
|
+
) }),
|
|
95
|
+
failureCount >= 3 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-red-500/30 bg-red-500/10 px-4 py-3 text-sm text-red-600 dark:text-red-400 text-center", children: t("mfa.challenge.lockoutWarning") }),
|
|
96
|
+
method === "totp" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
97
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
98
|
+
chunkMXFEU7A6_js.OtpInput,
|
|
99
|
+
{
|
|
100
|
+
value: totpCode,
|
|
101
|
+
onChange: setTotpCode,
|
|
102
|
+
onComplete: handleTotpComplete,
|
|
103
|
+
error: error ?? void 0,
|
|
104
|
+
disabled: isSubmitting,
|
|
105
|
+
autoFocus: true
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
isSubmitting && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Spinner, {}) })
|
|
109
|
+
] }),
|
|
110
|
+
method === "backup" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
111
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
112
|
+
chunkKNXAOJAK_js.Input,
|
|
113
|
+
{
|
|
114
|
+
value: backupCode,
|
|
115
|
+
onChange: (event) => setBackupCode(event.target.value),
|
|
116
|
+
placeholder: t("mfa.challenge.backupCodePlaceholder"),
|
|
117
|
+
error: error ?? void 0,
|
|
118
|
+
disabled: isSubmitting,
|
|
119
|
+
autoFocus: true,
|
|
120
|
+
className: "font-mono text-center tracking-widest"
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
124
|
+
chunkKNXAOJAK_js.Button,
|
|
125
|
+
{
|
|
126
|
+
color: "ios-glass-blue",
|
|
127
|
+
fullWidth: true,
|
|
128
|
+
onClick: handleBackupSubmit,
|
|
129
|
+
disabled: !backupCode.trim() || isSubmitting,
|
|
130
|
+
loading: isSubmitting,
|
|
131
|
+
children: t("mfa.challenge.verifyBackupCode")
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
] }),
|
|
135
|
+
onCancel && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
136
|
+
"button",
|
|
137
|
+
{
|
|
138
|
+
type: "button",
|
|
139
|
+
onClick: () => {
|
|
140
|
+
chunkUZ3CMNUJ_js.triggerHaptic("light");
|
|
141
|
+
onCancel();
|
|
142
|
+
},
|
|
143
|
+
className: "text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors",
|
|
144
|
+
children: t("mfa.challenge.useDifferentAccount")
|
|
145
|
+
}
|
|
146
|
+
) })
|
|
147
|
+
] });
|
|
148
|
+
if (embedded) return content;
|
|
149
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Card, { variant: "glass", className: "mx-auto max-w-md p-6 sm:p-8", children: content });
|
|
150
|
+
}
|
|
151
|
+
function SignIn({
|
|
152
|
+
onSuccess,
|
|
153
|
+
onSignUp,
|
|
154
|
+
onForgotPassword,
|
|
155
|
+
onPasswordless,
|
|
156
|
+
socialProviders,
|
|
157
|
+
allowPasswordless,
|
|
158
|
+
defaultEmail = "",
|
|
159
|
+
embedded = false,
|
|
160
|
+
heroPanel
|
|
161
|
+
}) {
|
|
162
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
163
|
+
const { loginWithCredentials, loginWithProvider } = client.useAuth();
|
|
164
|
+
const discovered = client.useSocialProviders();
|
|
165
|
+
const effectiveSocialProviders = socialProviders ?? discovered.providers;
|
|
166
|
+
const [email, setEmail] = react.useState(defaultEmail);
|
|
167
|
+
const [password, setPassword] = react.useState("");
|
|
168
|
+
const [error, setError] = react.useState(null);
|
|
169
|
+
const [isSubmitting, setIsSubmitting] = react.useState(false);
|
|
170
|
+
const [mfaRequired, setMfaRequired] = react.useState(null);
|
|
171
|
+
const [socialLoading, setSocialLoading] = react.useState(null);
|
|
172
|
+
const handleSubmit = react.useCallback(
|
|
173
|
+
async (event) => {
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
setError(null);
|
|
176
|
+
setIsSubmitting(true);
|
|
177
|
+
try {
|
|
178
|
+
const result = await loginWithCredentials(email, password);
|
|
179
|
+
if (result.success) {
|
|
180
|
+
onSuccess?.();
|
|
181
|
+
} else if (result.mfaRequired && result.mfaToken) {
|
|
182
|
+
setMfaRequired({ mfaToken: result.mfaToken });
|
|
183
|
+
} else if (result.error) {
|
|
184
|
+
setError(t("signInError"));
|
|
185
|
+
}
|
|
186
|
+
} catch {
|
|
187
|
+
setError(t("signInError"));
|
|
188
|
+
} finally {
|
|
189
|
+
setIsSubmitting(false);
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
[email, password, loginWithCredentials, onSuccess, t]
|
|
193
|
+
);
|
|
194
|
+
const handleSocialLogin = react.useCallback((provider) => {
|
|
195
|
+
setSocialLoading(provider);
|
|
196
|
+
loginWithProvider(provider);
|
|
197
|
+
}, [loginWithProvider]);
|
|
198
|
+
if (mfaRequired) {
|
|
199
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
200
|
+
MfaChallenge,
|
|
201
|
+
{
|
|
202
|
+
mfaToken: mfaRequired.mfaToken,
|
|
203
|
+
onSuccess,
|
|
204
|
+
onCancel: () => setMfaRequired(null),
|
|
205
|
+
embedded
|
|
206
|
+
}
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-5", children: [
|
|
210
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
211
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white", children: t("signInTitle") }),
|
|
212
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-400", children: t("signInSubtitle") })
|
|
213
|
+
] }),
|
|
214
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl bg-red-50 dark:bg-red-900/20 px-4 py-3 text-sm text-ios-red", role: "alert", children: error }),
|
|
215
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
216
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
217
|
+
chunkKNXAOJAK_js.Input,
|
|
218
|
+
{
|
|
219
|
+
label: t("emailLabel"),
|
|
220
|
+
type: "email",
|
|
221
|
+
value: email,
|
|
222
|
+
onChange: (event) => setEmail(event.target.value),
|
|
223
|
+
placeholder: t("emailPlaceholder"),
|
|
224
|
+
autoComplete: "email",
|
|
225
|
+
disabled: isSubmitting,
|
|
226
|
+
required: true
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
230
|
+
chunkKNXAOJAK_js.PasswordInput,
|
|
231
|
+
{
|
|
232
|
+
label: t("passwordLabel"),
|
|
233
|
+
value: password,
|
|
234
|
+
onChange: (event) => setPassword(event.target.value),
|
|
235
|
+
placeholder: t("passwordPlaceholder"),
|
|
236
|
+
autoComplete: "current-password",
|
|
237
|
+
disabled: isSubmitting,
|
|
238
|
+
required: true
|
|
239
|
+
}
|
|
240
|
+
),
|
|
241
|
+
onForgotPassword && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
242
|
+
"button",
|
|
243
|
+
{
|
|
244
|
+
type: "button",
|
|
245
|
+
onClick: onForgotPassword,
|
|
246
|
+
className: "text-sm font-medium text-ios-blue hover:text-blue-700 dark:hover:text-blue-400 transition-colors",
|
|
247
|
+
children: t("forgotPassword")
|
|
248
|
+
}
|
|
249
|
+
) }),
|
|
250
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
251
|
+
chunkKNXAOJAK_js.Button,
|
|
252
|
+
{
|
|
253
|
+
type: "submit",
|
|
254
|
+
color: "ios-glass-green",
|
|
255
|
+
size: "lg",
|
|
256
|
+
fullWidth: true,
|
|
257
|
+
disabled: isSubmitting || !email || !password,
|
|
258
|
+
loading: isSubmitting,
|
|
259
|
+
children: t("signInButton")
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
] }),
|
|
263
|
+
effectiveSocialProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
264
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
265
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full border-t border-gray-200/60 dark:border-white/10" }) }),
|
|
266
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative flex justify-center text-xs", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-white/80 px-3 text-gray-400 dark:bg-gray-900/80 dark:text-gray-500", children: t("orContinueWith") }) })
|
|
267
|
+
] }),
|
|
268
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
269
|
+
chunkMXFEU7A6_js.SocialLoginButtons,
|
|
270
|
+
{
|
|
271
|
+
providers: [...effectiveSocialProviders],
|
|
272
|
+
onProviderClick: handleSocialLogin,
|
|
273
|
+
loading: socialLoading,
|
|
274
|
+
disabled: isSubmitting
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
] }),
|
|
278
|
+
allowPasswordless && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
279
|
+
chunkKNXAOJAK_js.Button,
|
|
280
|
+
{
|
|
281
|
+
type: "button",
|
|
282
|
+
color: "ios-glass-blue",
|
|
283
|
+
size: "lg",
|
|
284
|
+
fullWidth: true,
|
|
285
|
+
onClick: onPasswordless,
|
|
286
|
+
children: [
|
|
287
|
+
/* @__PURE__ */ jsxRuntime.jsx(outline.EnvelopeIcon, { className: "h-5 w-5" }),
|
|
288
|
+
t("signInPasswordless")
|
|
289
|
+
]
|
|
290
|
+
}
|
|
291
|
+
),
|
|
292
|
+
onSignUp && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-center text-sm text-gray-500 dark:text-gray-400", children: [
|
|
293
|
+
t("noAccount"),
|
|
294
|
+
" ",
|
|
295
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
296
|
+
"button",
|
|
297
|
+
{
|
|
298
|
+
type: "button",
|
|
299
|
+
onClick: onSignUp,
|
|
300
|
+
className: "font-medium text-ios-blue hover:text-blue-700 dark:hover:text-blue-400 transition-colors",
|
|
301
|
+
children: t("signUpLink")
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
] })
|
|
305
|
+
] });
|
|
306
|
+
if (embedded) return content;
|
|
307
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkMXFEU7A6_js.AuthLayout, { heroPanel, children: content });
|
|
308
|
+
}
|
|
309
|
+
var RESEND_COOLDOWN_SECONDS = 60;
|
|
310
|
+
function VerifyEmail({
|
|
311
|
+
email,
|
|
312
|
+
onSuccess,
|
|
313
|
+
onResend,
|
|
314
|
+
embedded = false
|
|
315
|
+
}) {
|
|
316
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
317
|
+
const { client: client$1 } = client.useAuth();
|
|
318
|
+
const [code, setCode] = react.useState("");
|
|
319
|
+
const [error, setError] = react.useState(null);
|
|
320
|
+
const [isSubmitting, setIsSubmitting] = react.useState(false);
|
|
321
|
+
const [isResending, setIsResending] = react.useState(false);
|
|
322
|
+
const [cooldown, setCooldown] = react.useState(RESEND_COOLDOWN_SECONDS);
|
|
323
|
+
react.useEffect(() => {
|
|
324
|
+
if (cooldown <= 0) return;
|
|
325
|
+
const timer = setInterval(() => {
|
|
326
|
+
setCooldown((previous) => {
|
|
327
|
+
if (previous <= 1) {
|
|
328
|
+
clearInterval(timer);
|
|
329
|
+
return 0;
|
|
330
|
+
}
|
|
331
|
+
return previous - 1;
|
|
332
|
+
});
|
|
333
|
+
}, 1e3);
|
|
334
|
+
return () => clearInterval(timer);
|
|
335
|
+
}, [cooldown]);
|
|
336
|
+
const handleComplete = react.useCallback(
|
|
337
|
+
async (completedCode) => {
|
|
338
|
+
setError(null);
|
|
339
|
+
setIsSubmitting(true);
|
|
340
|
+
try {
|
|
341
|
+
await client$1.verifyEmail(email, completedCode);
|
|
342
|
+
onSuccess?.();
|
|
343
|
+
} catch {
|
|
344
|
+
setError(t("verifyEmailError"));
|
|
345
|
+
setCode("");
|
|
346
|
+
} finally {
|
|
347
|
+
setIsSubmitting(false);
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
[client$1, email, onSuccess, t]
|
|
351
|
+
);
|
|
352
|
+
const handleResend = react.useCallback(async () => {
|
|
353
|
+
if (cooldown > 0 || isResending) return;
|
|
354
|
+
setIsResending(true);
|
|
355
|
+
setError(null);
|
|
356
|
+
try {
|
|
357
|
+
onResend?.();
|
|
358
|
+
setCooldown(RESEND_COOLDOWN_SECONDS);
|
|
359
|
+
} catch {
|
|
360
|
+
setError(t("resendEmailError"));
|
|
361
|
+
} finally {
|
|
362
|
+
setIsResending(false);
|
|
363
|
+
}
|
|
364
|
+
}, [cooldown, isResending, onResend, t]);
|
|
365
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
366
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
367
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-16 w-16 items-center justify-center rounded-full bg-blue-50 dark:bg-blue-500/10", children: /* @__PURE__ */ jsxRuntime.jsx(outline.EnvelopeIcon, { className: "h-8 w-8 text-ios-blue" }) }),
|
|
368
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
369
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-bold text-gray-900 dark:text-white", children: t("verifyEmailTitle") }),
|
|
370
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-400", children: t("verifyEmailSubtitle", { email }) })
|
|
371
|
+
] })
|
|
372
|
+
] }),
|
|
373
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl bg-red-50 dark:bg-red-900/20 px-4 py-3 text-sm text-ios-red text-center", role: "alert", children: error }),
|
|
374
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
375
|
+
chunkMXFEU7A6_js.OtpInput,
|
|
376
|
+
{
|
|
377
|
+
value: code,
|
|
378
|
+
onChange: setCode,
|
|
379
|
+
onComplete: handleComplete,
|
|
380
|
+
error: error ?? void 0,
|
|
381
|
+
disabled: isSubmitting,
|
|
382
|
+
autoFocus: true
|
|
383
|
+
}
|
|
384
|
+
),
|
|
385
|
+
isSubmitting && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Spinner, {}) }),
|
|
386
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center space-y-1", children: [
|
|
387
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: t("verifyEmailNoCode") }),
|
|
388
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
389
|
+
chunkKNXAOJAK_js.Button,
|
|
390
|
+
{
|
|
391
|
+
type: "button",
|
|
392
|
+
outline: true,
|
|
393
|
+
onClick: handleResend,
|
|
394
|
+
disabled: cooldown > 0 || isResending || isSubmitting,
|
|
395
|
+
loading: isResending,
|
|
396
|
+
children: cooldown > 0 ? t("resendEmailCooldown", { seconds: cooldown }) : t("resendEmailButton")
|
|
397
|
+
}
|
|
398
|
+
)
|
|
399
|
+
] })
|
|
400
|
+
] });
|
|
401
|
+
if (embedded) return content;
|
|
402
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Card, { variant: "glass", className: "mx-auto max-w-md p-6 sm:p-8", children: content });
|
|
403
|
+
}
|
|
404
|
+
function SignUp({
|
|
405
|
+
onSuccess,
|
|
406
|
+
onSignIn,
|
|
407
|
+
socialProviders,
|
|
408
|
+
passwordPolicy,
|
|
409
|
+
embedded = false,
|
|
410
|
+
heroPanel
|
|
411
|
+
}) {
|
|
412
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
413
|
+
const { client: client$1, loginWithProvider } = client.useAuth();
|
|
414
|
+
const discovered = client.useSocialProviders();
|
|
415
|
+
const effectiveSocialProviders = socialProviders ?? discovered.providers;
|
|
416
|
+
const [phase, setPhase] = react.useState("form");
|
|
417
|
+
const [registeredEmail, setRegisteredEmail] = react.useState("");
|
|
418
|
+
const [name, setName] = react.useState("");
|
|
419
|
+
const [email, setEmail] = react.useState("");
|
|
420
|
+
const [password, setPassword] = react.useState("");
|
|
421
|
+
const [termsAccepted, setTermsAccepted] = react.useState(false);
|
|
422
|
+
const [error, setError] = react.useState(null);
|
|
423
|
+
const [isSubmitting, setIsSubmitting] = react.useState(false);
|
|
424
|
+
const [socialLoading, setSocialLoading] = react.useState(null);
|
|
425
|
+
const handleSubmit = react.useCallback(
|
|
426
|
+
async (event) => {
|
|
427
|
+
event.preventDefault();
|
|
428
|
+
setError(null);
|
|
429
|
+
setIsSubmitting(true);
|
|
430
|
+
try {
|
|
431
|
+
await client$1.register({ name, email, password });
|
|
432
|
+
setRegisteredEmail(email);
|
|
433
|
+
setPhase("verify");
|
|
434
|
+
} catch {
|
|
435
|
+
setError(t("signUpError"));
|
|
436
|
+
} finally {
|
|
437
|
+
setIsSubmitting(false);
|
|
438
|
+
}
|
|
439
|
+
},
|
|
440
|
+
[client$1, name, email, password, t]
|
|
441
|
+
);
|
|
442
|
+
const handleSocialLogin = react.useCallback((provider) => {
|
|
443
|
+
setSocialLoading(provider);
|
|
444
|
+
loginWithProvider(provider);
|
|
445
|
+
}, [loginWithProvider]);
|
|
446
|
+
if (phase === "verify") {
|
|
447
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
448
|
+
VerifyEmail,
|
|
449
|
+
{
|
|
450
|
+
email: registeredEmail,
|
|
451
|
+
onSuccess,
|
|
452
|
+
embedded
|
|
453
|
+
}
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
const isFormValid = name.trim() !== "" && email.trim() !== "" && password !== "" && termsAccepted;
|
|
457
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-5", children: [
|
|
458
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
459
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white", children: t("signUpTitle") }),
|
|
460
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-400", children: t("signUpSubtitle") })
|
|
461
|
+
] }),
|
|
462
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl bg-red-50 dark:bg-red-900/20 px-4 py-3 text-sm text-ios-red", role: "alert", children: error }),
|
|
463
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
464
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
465
|
+
chunkKNXAOJAK_js.Input,
|
|
466
|
+
{
|
|
467
|
+
label: t("nameLabel"),
|
|
468
|
+
type: "text",
|
|
469
|
+
value: name,
|
|
470
|
+
onChange: (event) => setName(event.target.value),
|
|
471
|
+
placeholder: t("namePlaceholder"),
|
|
472
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(outline.UserIcon, { className: "h-5 w-5" }),
|
|
473
|
+
autoComplete: "name",
|
|
474
|
+
disabled: isSubmitting,
|
|
475
|
+
required: true
|
|
476
|
+
}
|
|
477
|
+
),
|
|
478
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
479
|
+
chunkKNXAOJAK_js.Input,
|
|
480
|
+
{
|
|
481
|
+
label: t("emailLabel"),
|
|
482
|
+
type: "email",
|
|
483
|
+
value: email,
|
|
484
|
+
onChange: (event) => setEmail(event.target.value),
|
|
485
|
+
placeholder: t("emailPlaceholder"),
|
|
486
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(outline.EnvelopeIcon, { className: "h-5 w-5" }),
|
|
487
|
+
autoComplete: "email",
|
|
488
|
+
disabled: isSubmitting,
|
|
489
|
+
required: true
|
|
490
|
+
}
|
|
491
|
+
),
|
|
492
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
493
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
494
|
+
chunkKNXAOJAK_js.PasswordInput,
|
|
495
|
+
{
|
|
496
|
+
label: t("passwordLabel"),
|
|
497
|
+
value: password,
|
|
498
|
+
onChange: (event) => setPassword(event.target.value),
|
|
499
|
+
placeholder: t("passwordPlaceholder"),
|
|
500
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(outline.LockClosedIcon, { className: "h-5 w-5" }),
|
|
501
|
+
autoComplete: "new-password",
|
|
502
|
+
disabled: isSubmitting,
|
|
503
|
+
required: true
|
|
504
|
+
}
|
|
505
|
+
),
|
|
506
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
507
|
+
chunkMXFEU7A6_js.PasswordStrengthMeter,
|
|
508
|
+
{
|
|
509
|
+
password,
|
|
510
|
+
policy: passwordPolicy,
|
|
511
|
+
showRequirements: true
|
|
512
|
+
}
|
|
513
|
+
)
|
|
514
|
+
] }),
|
|
515
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
516
|
+
chunkKNXAOJAK_js.FormCheckbox,
|
|
517
|
+
{
|
|
518
|
+
checked: termsAccepted,
|
|
519
|
+
onChange: setTermsAccepted,
|
|
520
|
+
label: t("termsLabel"),
|
|
521
|
+
description: t("termsDescription"),
|
|
522
|
+
disabled: isSubmitting
|
|
523
|
+
}
|
|
524
|
+
),
|
|
525
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
526
|
+
chunkKNXAOJAK_js.Button,
|
|
527
|
+
{
|
|
528
|
+
type: "submit",
|
|
529
|
+
color: "ios-glass-blue",
|
|
530
|
+
fullWidth: true,
|
|
531
|
+
disabled: isSubmitting || !isFormValid,
|
|
532
|
+
loading: isSubmitting,
|
|
533
|
+
children: t("signUpButton")
|
|
534
|
+
}
|
|
535
|
+
)
|
|
536
|
+
] }),
|
|
537
|
+
effectiveSocialProviders.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
538
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
539
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full border-t border-gray-200 dark:border-white/10" }) }),
|
|
540
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative flex justify-center text-xs", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-white dark:bg-gray-900 px-3 text-gray-400 dark:text-gray-500", children: t("orContinueWith") }) })
|
|
541
|
+
] }),
|
|
542
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
543
|
+
chunkMXFEU7A6_js.SocialLoginButtons,
|
|
544
|
+
{
|
|
545
|
+
providers: [...effectiveSocialProviders],
|
|
546
|
+
onProviderClick: handleSocialLogin,
|
|
547
|
+
loading: socialLoading,
|
|
548
|
+
disabled: isSubmitting
|
|
549
|
+
}
|
|
550
|
+
)
|
|
551
|
+
] }),
|
|
552
|
+
onSignIn && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-center text-sm text-gray-500 dark:text-gray-400", children: [
|
|
553
|
+
t("alreadyHaveAccount"),
|
|
554
|
+
" ",
|
|
555
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
556
|
+
"button",
|
|
557
|
+
{
|
|
558
|
+
type: "button",
|
|
559
|
+
onClick: onSignIn,
|
|
560
|
+
className: "font-medium text-ios-blue hover:text-blue-700 dark:hover:text-blue-400 transition-colors",
|
|
561
|
+
children: t("signInLink")
|
|
562
|
+
}
|
|
563
|
+
)
|
|
564
|
+
] })
|
|
565
|
+
] });
|
|
566
|
+
if (embedded) return content;
|
|
567
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkMXFEU7A6_js.AuthLayout, { heroPanel, children: content });
|
|
568
|
+
}
|
|
569
|
+
function ForgotPassword({
|
|
570
|
+
onSuccess,
|
|
571
|
+
onBack,
|
|
572
|
+
defaultEmail = "",
|
|
573
|
+
embedded = false
|
|
574
|
+
}) {
|
|
575
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
576
|
+
const { client: client$1 } = client.useAuth();
|
|
577
|
+
const [phase, setPhase] = react.useState("form");
|
|
578
|
+
const [email, setEmail] = react.useState(defaultEmail);
|
|
579
|
+
const [error, setError] = react.useState(null);
|
|
580
|
+
const [isSubmitting, setIsSubmitting] = react.useState(false);
|
|
581
|
+
const handleSubmit = react.useCallback(
|
|
582
|
+
async (event) => {
|
|
583
|
+
event.preventDefault();
|
|
584
|
+
setError(null);
|
|
585
|
+
setIsSubmitting(true);
|
|
586
|
+
try {
|
|
587
|
+
await client$1.requestPasswordReset(email);
|
|
588
|
+
setPhase("sent");
|
|
589
|
+
onSuccess?.();
|
|
590
|
+
} catch {
|
|
591
|
+
setError(t("forgotPasswordError"));
|
|
592
|
+
} finally {
|
|
593
|
+
setIsSubmitting(false);
|
|
594
|
+
}
|
|
595
|
+
},
|
|
596
|
+
[client$1, email, onSuccess, t]
|
|
597
|
+
);
|
|
598
|
+
const sentContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-5", children: [
|
|
599
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
600
|
+
chunkKNXAOJAK_js.EmptyState,
|
|
601
|
+
{
|
|
602
|
+
variant: "minimal",
|
|
603
|
+
icon: outline.CheckCircleIcon,
|
|
604
|
+
message: t("forgotPasswordSuccessTitle"),
|
|
605
|
+
description: t("forgotPasswordSuccessDescription", { email })
|
|
606
|
+
}
|
|
607
|
+
),
|
|
608
|
+
onBack && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
609
|
+
"button",
|
|
610
|
+
{
|
|
611
|
+
type: "button",
|
|
612
|
+
onClick: onBack,
|
|
613
|
+
className: "text-sm font-medium text-ios-blue hover:text-blue-700 dark:hover:text-blue-400 transition-colors",
|
|
614
|
+
children: t("backToSignIn")
|
|
615
|
+
}
|
|
616
|
+
) })
|
|
617
|
+
] });
|
|
618
|
+
const formContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-5", children: [
|
|
619
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
620
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white", children: t("forgotPasswordTitle") }),
|
|
621
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-400", children: t("forgotPasswordSubtitle") })
|
|
622
|
+
] }),
|
|
623
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl bg-red-50 dark:bg-red-900/20 px-4 py-3 text-sm text-ios-red", role: "alert", children: error }),
|
|
624
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
625
|
+
chunkKNXAOJAK_js.BaseForm,
|
|
626
|
+
{
|
|
627
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(outline.EnvelopeIcon, { className: "h-5 w-5" }),
|
|
628
|
+
iconColor: "blue",
|
|
629
|
+
title: t("forgotPasswordFormTitle"),
|
|
630
|
+
subtitle: t("forgotPasswordFormSubtitle"),
|
|
631
|
+
onSubmit: handleSubmit,
|
|
632
|
+
submitLabel: t("forgotPasswordSubmit"),
|
|
633
|
+
isLoading: isSubmitting,
|
|
634
|
+
submitDisabled: !email.trim(),
|
|
635
|
+
showHeader: false,
|
|
636
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
637
|
+
chunkKNXAOJAK_js.Input,
|
|
638
|
+
{
|
|
639
|
+
label: t("emailLabel"),
|
|
640
|
+
type: "email",
|
|
641
|
+
value: email,
|
|
642
|
+
onChange: (event) => setEmail(event.target.value),
|
|
643
|
+
placeholder: t("emailPlaceholder"),
|
|
644
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(outline.EnvelopeIcon, { className: "h-5 w-5" }),
|
|
645
|
+
autoComplete: "email",
|
|
646
|
+
disabled: isSubmitting,
|
|
647
|
+
required: true,
|
|
648
|
+
autoFocus: true
|
|
649
|
+
}
|
|
650
|
+
)
|
|
651
|
+
}
|
|
652
|
+
),
|
|
653
|
+
onBack && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
654
|
+
"button",
|
|
655
|
+
{
|
|
656
|
+
type: "button",
|
|
657
|
+
onClick: onBack,
|
|
658
|
+
className: "text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors",
|
|
659
|
+
children: t("backToSignIn")
|
|
660
|
+
}
|
|
661
|
+
) })
|
|
662
|
+
] });
|
|
663
|
+
const activeContent = phase === "sent" ? sentContent : formContent;
|
|
664
|
+
if (embedded) return activeContent;
|
|
665
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Card, { variant: "glass", className: "mx-auto max-w-md p-6 sm:p-8", children: activeContent });
|
|
666
|
+
}
|
|
667
|
+
function ResetPassword({
|
|
668
|
+
token,
|
|
669
|
+
onSuccess,
|
|
670
|
+
passwordPolicy,
|
|
671
|
+
embedded = false
|
|
672
|
+
}) {
|
|
673
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
674
|
+
const { client: client$1 } = client.useAuth();
|
|
675
|
+
const [phase, setPhase] = react.useState("form");
|
|
676
|
+
const [password, setPassword] = react.useState("");
|
|
677
|
+
const [confirmPassword, setConfirmPassword] = react.useState("");
|
|
678
|
+
const [error, setError] = react.useState(null);
|
|
679
|
+
const [isSubmitting, setIsSubmitting] = react.useState(false);
|
|
680
|
+
const passwordsMatch = password !== "" && confirmPassword !== "" && password === confirmPassword;
|
|
681
|
+
const hasPasswordMismatch = confirmPassword !== "" && password !== confirmPassword;
|
|
682
|
+
const handleSubmit = react.useCallback(
|
|
683
|
+
async (event) => {
|
|
684
|
+
event.preventDefault();
|
|
685
|
+
setError(null);
|
|
686
|
+
if (!passwordsMatch) {
|
|
687
|
+
setError(t("passwordMismatchError"));
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
setIsSubmitting(true);
|
|
691
|
+
try {
|
|
692
|
+
await client$1.resetPassword(token, password);
|
|
693
|
+
setPhase("success");
|
|
694
|
+
onSuccess?.();
|
|
695
|
+
} catch {
|
|
696
|
+
setError(t("resetPasswordError"));
|
|
697
|
+
} finally {
|
|
698
|
+
setIsSubmitting(false);
|
|
699
|
+
}
|
|
700
|
+
},
|
|
701
|
+
[client$1, token, password, passwordsMatch, onSuccess, t]
|
|
702
|
+
);
|
|
703
|
+
const successContent = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-5", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
704
|
+
chunkKNXAOJAK_js.EmptyState,
|
|
705
|
+
{
|
|
706
|
+
variant: "minimal",
|
|
707
|
+
icon: outline.CheckCircleIcon,
|
|
708
|
+
message: t("resetPasswordSuccessTitle"),
|
|
709
|
+
description: t("resetPasswordSuccessDescription")
|
|
710
|
+
}
|
|
711
|
+
) });
|
|
712
|
+
const formContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-5", children: [
|
|
713
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
714
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white", children: t("resetPasswordTitle") }),
|
|
715
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-400", children: t("resetPasswordSubtitle") })
|
|
716
|
+
] }),
|
|
717
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl bg-red-50 dark:bg-red-900/20 px-4 py-3 text-sm text-ios-red", role: "alert", children: error }),
|
|
718
|
+
/* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: handleSubmit, className: "space-y-4", children: [
|
|
719
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
720
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
721
|
+
chunkKNXAOJAK_js.PasswordInput,
|
|
722
|
+
{
|
|
723
|
+
label: t("newPasswordLabel"),
|
|
724
|
+
value: password,
|
|
725
|
+
onChange: (event) => setPassword(event.target.value),
|
|
726
|
+
placeholder: t("newPasswordPlaceholder"),
|
|
727
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(outline.LockClosedIcon, { className: "h-5 w-5" }),
|
|
728
|
+
autoComplete: "new-password",
|
|
729
|
+
disabled: isSubmitting,
|
|
730
|
+
required: true,
|
|
731
|
+
autoFocus: true
|
|
732
|
+
}
|
|
733
|
+
),
|
|
734
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
735
|
+
chunkMXFEU7A6_js.PasswordStrengthMeter,
|
|
736
|
+
{
|
|
737
|
+
password,
|
|
738
|
+
policy: passwordPolicy,
|
|
739
|
+
showRequirements: true
|
|
740
|
+
}
|
|
741
|
+
)
|
|
742
|
+
] }),
|
|
743
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
744
|
+
chunkKNXAOJAK_js.PasswordInput,
|
|
745
|
+
{
|
|
746
|
+
label: t("confirmPasswordLabel"),
|
|
747
|
+
value: confirmPassword,
|
|
748
|
+
onChange: (event) => setConfirmPassword(event.target.value),
|
|
749
|
+
placeholder: t("confirmPasswordPlaceholder"),
|
|
750
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(outline.LockClosedIcon, { className: "h-5 w-5" }),
|
|
751
|
+
autoComplete: "new-password",
|
|
752
|
+
disabled: isSubmitting,
|
|
753
|
+
error: hasPasswordMismatch ? t("passwordMismatchError") : void 0,
|
|
754
|
+
success: passwordsMatch,
|
|
755
|
+
required: true
|
|
756
|
+
}
|
|
757
|
+
),
|
|
758
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
759
|
+
chunkKNXAOJAK_js.Button,
|
|
760
|
+
{
|
|
761
|
+
type: "submit",
|
|
762
|
+
color: "ios-glass-blue",
|
|
763
|
+
fullWidth: true,
|
|
764
|
+
disabled: isSubmitting || !passwordsMatch,
|
|
765
|
+
loading: isSubmitting,
|
|
766
|
+
children: t("resetPasswordButton")
|
|
767
|
+
}
|
|
768
|
+
)
|
|
769
|
+
] })
|
|
770
|
+
] });
|
|
771
|
+
const activeContent = phase === "success" ? successContent : formContent;
|
|
772
|
+
if (embedded) return activeContent;
|
|
773
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Card, { variant: "glass", className: "mx-auto max-w-md p-6 sm:p-8", children: activeContent });
|
|
774
|
+
}
|
|
775
|
+
function PasswordlessSignIn({
|
|
776
|
+
defaultMethod = "email",
|
|
777
|
+
allowedChannels = ["email", "sms"],
|
|
778
|
+
onSuccess,
|
|
779
|
+
onBack,
|
|
780
|
+
defaultEmail = "",
|
|
781
|
+
embedded = false
|
|
782
|
+
}) {
|
|
783
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
784
|
+
const { client: client$1 } = client.useAuth();
|
|
785
|
+
const [step, setStep] = react.useState("input");
|
|
786
|
+
const [channel, setChannel] = react.useState(
|
|
787
|
+
allowedChannels.includes(defaultMethod) ? defaultMethod : allowedChannels[0] ?? "email"
|
|
788
|
+
);
|
|
789
|
+
const [identifier, setIdentifier] = react.useState(defaultEmail);
|
|
790
|
+
const [code, setCode] = react.useState("");
|
|
791
|
+
const [error, setError] = react.useState(null);
|
|
792
|
+
const [isSending, setIsSending] = react.useState(false);
|
|
793
|
+
const [isVerifying, setIsVerifying] = react.useState(false);
|
|
794
|
+
const channelSegments = allowedChannels.map((ch) => ({
|
|
795
|
+
value: ch,
|
|
796
|
+
label: ch === "email" ? t("channelEmail") : t("channelSms")
|
|
797
|
+
}));
|
|
798
|
+
const handleSendCode = react.useCallback(async () => {
|
|
799
|
+
if (!identifier.trim()) return;
|
|
800
|
+
setError(null);
|
|
801
|
+
setIsSending(true);
|
|
802
|
+
try {
|
|
803
|
+
await client$1.sendPasswordlessCode(channel, identifier.trim());
|
|
804
|
+
setStep("sent");
|
|
805
|
+
setTimeout(() => setStep("verify"), 1500);
|
|
806
|
+
} catch {
|
|
807
|
+
setError(t("passwordlessSendError"));
|
|
808
|
+
} finally {
|
|
809
|
+
setIsSending(false);
|
|
810
|
+
}
|
|
811
|
+
}, [client$1, channel, identifier, t]);
|
|
812
|
+
const handleVerifyCode = react.useCallback(
|
|
813
|
+
async (completedCode) => {
|
|
814
|
+
setError(null);
|
|
815
|
+
setIsVerifying(true);
|
|
816
|
+
try {
|
|
817
|
+
await client$1.verifyPasswordlessCode(channel, identifier.trim(), completedCode);
|
|
818
|
+
onSuccess?.();
|
|
819
|
+
} catch {
|
|
820
|
+
setError(t("passwordlessVerifyError"));
|
|
821
|
+
setCode("");
|
|
822
|
+
} finally {
|
|
823
|
+
setIsVerifying(false);
|
|
824
|
+
}
|
|
825
|
+
},
|
|
826
|
+
[client$1, channel, identifier, onSuccess, t]
|
|
827
|
+
);
|
|
828
|
+
const inputContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
829
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
830
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-2xl font-bold text-gray-900 dark:text-white", children: t("passwordlessTitle") }),
|
|
831
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-400", children: t("passwordlessSubtitle") })
|
|
832
|
+
] }),
|
|
833
|
+
allowedChannels.length > 1 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
834
|
+
chunkKNXAOJAK_js.SegmentedControl,
|
|
835
|
+
{
|
|
836
|
+
segments: channelSegments,
|
|
837
|
+
value: channel,
|
|
838
|
+
onChange: (value) => {
|
|
839
|
+
setChannel(value);
|
|
840
|
+
setIdentifier(value === "email" ? defaultEmail : "");
|
|
841
|
+
setError(null);
|
|
842
|
+
},
|
|
843
|
+
size: "sm"
|
|
844
|
+
}
|
|
845
|
+
) }),
|
|
846
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl bg-red-50 dark:bg-red-900/20 px-4 py-3 text-sm text-ios-red", role: "alert", children: error }),
|
|
847
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
848
|
+
chunkKNXAOJAK_js.Input,
|
|
849
|
+
{
|
|
850
|
+
label: channel === "email" ? t("emailLabel") : t("phoneLabel"),
|
|
851
|
+
type: channel === "email" ? "email" : "tel",
|
|
852
|
+
value: identifier,
|
|
853
|
+
onChange: (event) => setIdentifier(event.target.value),
|
|
854
|
+
placeholder: channel === "email" ? t("emailPlaceholder") : t("phonePlaceholder"),
|
|
855
|
+
icon: channel === "email" ? /* @__PURE__ */ jsxRuntime.jsx(outline.EnvelopeIcon, { className: "h-5 w-5" }) : /* @__PURE__ */ jsxRuntime.jsx(outline.DevicePhoneMobileIcon, { className: "h-5 w-5" }),
|
|
856
|
+
autoComplete: channel === "email" ? "email" : "tel",
|
|
857
|
+
disabled: isSending,
|
|
858
|
+
autoFocus: true
|
|
859
|
+
}
|
|
860
|
+
),
|
|
861
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
862
|
+
chunkKNXAOJAK_js.Button,
|
|
863
|
+
{
|
|
864
|
+
type: "button",
|
|
865
|
+
color: "ios-glass-blue",
|
|
866
|
+
fullWidth: true,
|
|
867
|
+
onClick: handleSendCode,
|
|
868
|
+
disabled: isSending || !identifier.trim(),
|
|
869
|
+
loading: isSending,
|
|
870
|
+
children: t("passwordlessSendButton")
|
|
871
|
+
}
|
|
872
|
+
),
|
|
873
|
+
onBack && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
874
|
+
"button",
|
|
875
|
+
{
|
|
876
|
+
type: "button",
|
|
877
|
+
onClick: onBack,
|
|
878
|
+
className: "text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors",
|
|
879
|
+
children: t("backToSignIn")
|
|
880
|
+
}
|
|
881
|
+
) })
|
|
882
|
+
] });
|
|
883
|
+
const sentContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
884
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
885
|
+
chunkKNXAOJAK_js.EmptyState,
|
|
886
|
+
{
|
|
887
|
+
variant: "minimal",
|
|
888
|
+
icon: outline.PaperAirplaneIcon,
|
|
889
|
+
message: t("passwordlessCodeSentTitle"),
|
|
890
|
+
description: channel === "email" ? t("passwordlessCodeSentEmailDescription", { email: identifier }) : t("passwordlessCodeSentSmsDescription", { phone: identifier })
|
|
891
|
+
}
|
|
892
|
+
),
|
|
893
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Spinner, {}) })
|
|
894
|
+
] });
|
|
895
|
+
const verifyContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
|
|
896
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
|
|
897
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-bold text-gray-900 dark:text-white", children: t("passwordlessEnterCodeTitle") }),
|
|
898
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-500 dark:text-gray-400", children: channel === "email" ? t("passwordlessEnterCodeEmailSubtitle", { email: identifier }) : t("passwordlessEnterCodeSmsSubtitle", { phone: identifier }) })
|
|
899
|
+
] }),
|
|
900
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl bg-red-50 dark:bg-red-900/20 px-4 py-3 text-sm text-ios-red text-center", role: "alert", children: error }),
|
|
901
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
902
|
+
chunkMXFEU7A6_js.OtpInput,
|
|
903
|
+
{
|
|
904
|
+
value: code,
|
|
905
|
+
onChange: setCode,
|
|
906
|
+
onComplete: handleVerifyCode,
|
|
907
|
+
error: error ?? void 0,
|
|
908
|
+
disabled: isVerifying,
|
|
909
|
+
autoFocus: true
|
|
910
|
+
}
|
|
911
|
+
),
|
|
912
|
+
isVerifying && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Spinner, {}) }),
|
|
913
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [
|
|
914
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
915
|
+
"button",
|
|
916
|
+
{
|
|
917
|
+
type: "button",
|
|
918
|
+
onClick: () => {
|
|
919
|
+
setStep("input");
|
|
920
|
+
setCode("");
|
|
921
|
+
setError(null);
|
|
922
|
+
},
|
|
923
|
+
className: "text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors",
|
|
924
|
+
children: t("passwordlessChangeIdentifier")
|
|
925
|
+
}
|
|
926
|
+
),
|
|
927
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
928
|
+
"button",
|
|
929
|
+
{
|
|
930
|
+
type: "button",
|
|
931
|
+
onClick: () => {
|
|
932
|
+
setCode("");
|
|
933
|
+
setError(null);
|
|
934
|
+
handleSendCode();
|
|
935
|
+
},
|
|
936
|
+
disabled: isSending,
|
|
937
|
+
className: "font-medium text-ios-blue hover:text-blue-700 dark:hover:text-blue-400 transition-colors disabled:opacity-50",
|
|
938
|
+
children: t("resendEmailButton")
|
|
939
|
+
}
|
|
940
|
+
)
|
|
941
|
+
] })
|
|
942
|
+
] });
|
|
943
|
+
const activeContent = step === "input" ? inputContent : step === "sent" ? sentContent : verifyContent;
|
|
944
|
+
if (embedded) return activeContent;
|
|
945
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Card, { variant: "glass", className: "mx-auto max-w-md p-6 sm:p-8", children: activeContent });
|
|
946
|
+
}
|
|
947
|
+
function ConsentScreen({
|
|
948
|
+
application,
|
|
949
|
+
scopes,
|
|
950
|
+
grantedScopes,
|
|
951
|
+
onApprove,
|
|
952
|
+
onDeny,
|
|
953
|
+
isSubmitting = false
|
|
954
|
+
}) {
|
|
955
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
956
|
+
const [checkedScopes, setCheckedScopes] = react.useState(
|
|
957
|
+
() => new Set(grantedScopes && grantedScopes.length > 0 ? grantedScopes : scopes.map((s) => s.id))
|
|
958
|
+
);
|
|
959
|
+
const handleScopeToggle = react.useCallback((scopeId, checked) => {
|
|
960
|
+
setCheckedScopes((previous) => {
|
|
961
|
+
const next = new Set(previous);
|
|
962
|
+
if (checked) {
|
|
963
|
+
next.add(scopeId);
|
|
964
|
+
} else {
|
|
965
|
+
next.delete(scopeId);
|
|
966
|
+
}
|
|
967
|
+
return next;
|
|
968
|
+
});
|
|
969
|
+
}, []);
|
|
970
|
+
const handleApprove = react.useCallback(() => {
|
|
971
|
+
chunkUZ3CMNUJ_js.triggerHaptic("light");
|
|
972
|
+
onApprove(Array.from(checkedScopes));
|
|
973
|
+
}, [checkedScopes, onApprove]);
|
|
974
|
+
const handleDeny = react.useCallback(() => {
|
|
975
|
+
chunkUZ3CMNUJ_js.triggerHaptic("light");
|
|
976
|
+
onDeny();
|
|
977
|
+
}, [onDeny]);
|
|
978
|
+
const appInitials = application.name.split(" ").map((word) => word[0]).join("").slice(0, 2).toUpperCase();
|
|
979
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkMXFEU7A6_js.AuthLayout, { children: /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Card, { variant: "glass", className: "mx-auto w-full max-w-md", children: /* @__PURE__ */ jsxRuntime.jsxs(chunkKNXAOJAK_js.CardContent, { className: "space-y-6 p-6 sm:p-8", children: [
|
|
980
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-3 text-center", children: [
|
|
981
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
982
|
+
chunkKNXAOJAK_js.Avatar,
|
|
983
|
+
{
|
|
984
|
+
src: application.logoUrl,
|
|
985
|
+
initials: appInitials,
|
|
986
|
+
alt: application.name
|
|
987
|
+
}
|
|
988
|
+
),
|
|
989
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
990
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-2", children: [
|
|
991
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-lg font-semibold text-gray-900 dark:text-white", children: application.name }),
|
|
992
|
+
application.verified ? /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Badge, { color: "green", children: t("consent.verified") }) : /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Badge, { color: "amber", children: t("consent.unverified") })
|
|
993
|
+
] }),
|
|
994
|
+
application.url && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: application.url }),
|
|
995
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600 dark:text-gray-300", children: t("consent.wantsAccess") })
|
|
996
|
+
] })
|
|
997
|
+
] }),
|
|
998
|
+
!application.verified && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start gap-3 rounded-xl border border-amber-500/30 bg-amber-500/10 p-3", children: [
|
|
999
|
+
/* @__PURE__ */ jsxRuntime.jsx(outline.ShieldExclamationIcon, { className: "mt-0.5 h-5 w-5 shrink-0 text-amber-600 dark:text-amber-400" }),
|
|
1000
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-amber-700 dark:text-amber-300", children: t("consent.unverifiedWarning", { name: application.name }) })
|
|
1001
|
+
] }),
|
|
1002
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
1003
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400", children: t("consent.permissionsLabel") }),
|
|
1004
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.ListCard, { children: scopes.map((scope) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1005
|
+
chunkKNXAOJAK_js.ListCardItem,
|
|
1006
|
+
{
|
|
1007
|
+
leading: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1008
|
+
chunkKNXAOJAK_js.FormCheckbox,
|
|
1009
|
+
{
|
|
1010
|
+
checked: checkedScopes.has(scope.id),
|
|
1011
|
+
onChange: (checked) => handleScopeToggle(scope.id, checked),
|
|
1012
|
+
label: ""
|
|
1013
|
+
}
|
|
1014
|
+
),
|
|
1015
|
+
onClick: () => handleScopeToggle(scope.id, !checkedScopes.has(scope.id)),
|
|
1016
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1017
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: scope.name }),
|
|
1018
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: scope.description })
|
|
1019
|
+
] })
|
|
1020
|
+
},
|
|
1021
|
+
scope.id
|
|
1022
|
+
)) })
|
|
1023
|
+
] }),
|
|
1024
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 sm:flex-row-reverse", children: [
|
|
1025
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1026
|
+
chunkKNXAOJAK_js.Button,
|
|
1027
|
+
{
|
|
1028
|
+
color: "ios-glass-blue",
|
|
1029
|
+
fullWidth: true,
|
|
1030
|
+
onClick: handleApprove,
|
|
1031
|
+
loading: isSubmitting,
|
|
1032
|
+
disabled: isSubmitting || checkedScopes.size === 0,
|
|
1033
|
+
children: t("consent.approveButton")
|
|
1034
|
+
}
|
|
1035
|
+
),
|
|
1036
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1037
|
+
chunkKNXAOJAK_js.Button,
|
|
1038
|
+
{
|
|
1039
|
+
outline: true,
|
|
1040
|
+
fullWidth: true,
|
|
1041
|
+
onClick: handleDeny,
|
|
1042
|
+
disabled: isSubmitting,
|
|
1043
|
+
children: t("consent.denyButton")
|
|
1044
|
+
}
|
|
1045
|
+
)
|
|
1046
|
+
] }),
|
|
1047
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-center text-xs text-gray-400 dark:text-gray-500", children: t("consent.footerNote") })
|
|
1048
|
+
] }) }) });
|
|
1049
|
+
}
|
|
1050
|
+
function SsoConnectorList({ connectors, onSelect, loading = false }) {
|
|
1051
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
1052
|
+
if (loading) {
|
|
1053
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center gap-2 py-8 text-sm text-gray-500 dark:text-gray-400", children: [
|
|
1054
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.InlineSpinner, {}),
|
|
1055
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: t("sso.connectorList.loading") })
|
|
1056
|
+
] });
|
|
1057
|
+
}
|
|
1058
|
+
if (connectors.length === 0) {
|
|
1059
|
+
return /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-6 text-center text-sm text-gray-500 dark:text-gray-400", children: t("sso.connectorList.empty") });
|
|
1060
|
+
}
|
|
1061
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.ListCard, { children: connectors.map((connector) => {
|
|
1062
|
+
const initials = connector.name.split(" ").map((word) => word[0]).join("").slice(0, 2).toUpperCase();
|
|
1063
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1064
|
+
chunkKNXAOJAK_js.ListCardItem,
|
|
1065
|
+
{
|
|
1066
|
+
leading: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1067
|
+
chunkKNXAOJAK_js.Avatar,
|
|
1068
|
+
{
|
|
1069
|
+
src: connector.logoUrl,
|
|
1070
|
+
initials,
|
|
1071
|
+
alt: connector.name
|
|
1072
|
+
}
|
|
1073
|
+
),
|
|
1074
|
+
trailing: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1075
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Badge, { color: "zinc", children: connector.type === "saml" ? t("sso.connectorList.typeSaml") : t("sso.connectorList.typeOidc") }),
|
|
1076
|
+
/* @__PURE__ */ jsxRuntime.jsx(solid.ChevronRightIcon, { className: "h-4 w-4 text-gray-400" })
|
|
1077
|
+
] }),
|
|
1078
|
+
onClick: () => onSelect(connector),
|
|
1079
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1080
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: connector.name }),
|
|
1081
|
+
connector.domain && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: connector.domain })
|
|
1082
|
+
] })
|
|
1083
|
+
},
|
|
1084
|
+
connector.id
|
|
1085
|
+
);
|
|
1086
|
+
}) });
|
|
1087
|
+
}
|
|
1088
|
+
function SsoEmailForm({
|
|
1089
|
+
onEmailSubmit,
|
|
1090
|
+
onConnectorSelect,
|
|
1091
|
+
defaultEmail = "",
|
|
1092
|
+
embedded = false
|
|
1093
|
+
}) {
|
|
1094
|
+
const t = chunkYXN2K77G_js.useTranslations("windsock");
|
|
1095
|
+
const [phase, setPhase] = react.useState("email");
|
|
1096
|
+
const [email, setEmail] = react.useState(defaultEmail);
|
|
1097
|
+
const [emailError, setEmailError] = react.useState(null);
|
|
1098
|
+
const [connectors, setConnectors] = react.useState([]);
|
|
1099
|
+
const [isSubmitting, setIsSubmitting] = react.useState(false);
|
|
1100
|
+
const [loadingConnectors, setLoadingConnectors] = react.useState(false);
|
|
1101
|
+
const validateEmail = react.useCallback(
|
|
1102
|
+
(value) => {
|
|
1103
|
+
if (!value.trim()) {
|
|
1104
|
+
setEmailError(t("sso.emailForm.errorEmailRequired"));
|
|
1105
|
+
return false;
|
|
1106
|
+
}
|
|
1107
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
|
|
1108
|
+
setEmailError(t("sso.emailForm.errorEmailInvalid"));
|
|
1109
|
+
return false;
|
|
1110
|
+
}
|
|
1111
|
+
setEmailError(null);
|
|
1112
|
+
return true;
|
|
1113
|
+
},
|
|
1114
|
+
[t]
|
|
1115
|
+
);
|
|
1116
|
+
const handleEmailSubmit = react.useCallback(async () => {
|
|
1117
|
+
if (!validateEmail(email)) return;
|
|
1118
|
+
setIsSubmitting(true);
|
|
1119
|
+
setLoadingConnectors(true);
|
|
1120
|
+
try {
|
|
1121
|
+
const discovered = await onEmailSubmit(email);
|
|
1122
|
+
setConnectors(discovered);
|
|
1123
|
+
setPhase("connectors");
|
|
1124
|
+
} catch {
|
|
1125
|
+
setEmailError(t("sso.emailForm.errorDiscoveryFailed"));
|
|
1126
|
+
} finally {
|
|
1127
|
+
setIsSubmitting(false);
|
|
1128
|
+
setLoadingConnectors(false);
|
|
1129
|
+
}
|
|
1130
|
+
}, [email, onEmailSubmit, validateEmail, t]);
|
|
1131
|
+
const handleBackToEmail = react.useCallback(() => {
|
|
1132
|
+
setPhase("email");
|
|
1133
|
+
setConnectors([]);
|
|
1134
|
+
setEmailError(null);
|
|
1135
|
+
}, []);
|
|
1136
|
+
if (phase === "connectors") {
|
|
1137
|
+
const connectorsContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
1138
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
1139
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: t("sso.emailForm.connectorsTitle") }),
|
|
1140
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: t("sso.emailForm.connectorsSubtitle", { email }) })
|
|
1141
|
+
] }),
|
|
1142
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1143
|
+
SsoConnectorList,
|
|
1144
|
+
{
|
|
1145
|
+
connectors,
|
|
1146
|
+
onSelect: onConnectorSelect,
|
|
1147
|
+
loading: loadingConnectors
|
|
1148
|
+
}
|
|
1149
|
+
),
|
|
1150
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1151
|
+
"button",
|
|
1152
|
+
{
|
|
1153
|
+
type: "button",
|
|
1154
|
+
onClick: handleBackToEmail,
|
|
1155
|
+
className: "text-sm text-gray-500 transition-colors hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",
|
|
1156
|
+
children: t("sso.emailForm.backButton")
|
|
1157
|
+
}
|
|
1158
|
+
) })
|
|
1159
|
+
] });
|
|
1160
|
+
if (embedded) return connectorsContent;
|
|
1161
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Card, { variant: "glass", className: "mx-auto w-full max-w-md", children: /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.CardContent, { className: "p-6 sm:p-8", children: connectorsContent }) });
|
|
1162
|
+
}
|
|
1163
|
+
const emailContent = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
1164
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
|
|
1165
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-white", children: t("sso.emailForm.title") }),
|
|
1166
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: t("sso.emailForm.subtitle") })
|
|
1167
|
+
] }),
|
|
1168
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkKNXAOJAK_js.BaseForm, { onSubmit: handleEmailSubmit, submitLabel: t("sso.emailForm.continueButton"), showFooter: false, children: [
|
|
1169
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1170
|
+
chunkKNXAOJAK_js.Input,
|
|
1171
|
+
{
|
|
1172
|
+
type: "email",
|
|
1173
|
+
label: t("sso.emailForm.emailLabel"),
|
|
1174
|
+
placeholder: t("sso.emailForm.emailPlaceholder"),
|
|
1175
|
+
value: email,
|
|
1176
|
+
onChange: (event) => {
|
|
1177
|
+
setEmail(event.target.value);
|
|
1178
|
+
if (emailError) setEmailError(null);
|
|
1179
|
+
},
|
|
1180
|
+
error: emailError ?? void 0,
|
|
1181
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(outline.BuildingOffice2Icon, { className: "h-5 w-5" }),
|
|
1182
|
+
disabled: isSubmitting,
|
|
1183
|
+
autoFocus: true,
|
|
1184
|
+
autoComplete: "email"
|
|
1185
|
+
}
|
|
1186
|
+
),
|
|
1187
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1188
|
+
chunkKNXAOJAK_js.Button,
|
|
1189
|
+
{
|
|
1190
|
+
type: "submit",
|
|
1191
|
+
color: "ios-glass-blue",
|
|
1192
|
+
fullWidth: true,
|
|
1193
|
+
loading: isSubmitting,
|
|
1194
|
+
disabled: isSubmitting,
|
|
1195
|
+
children: t("sso.emailForm.continueButton")
|
|
1196
|
+
}
|
|
1197
|
+
)
|
|
1198
|
+
] })
|
|
1199
|
+
] });
|
|
1200
|
+
if (embedded) return emailContent;
|
|
1201
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.Card, { variant: "glass", className: "mx-auto w-full max-w-md", children: /* @__PURE__ */ jsxRuntime.jsx(chunkKNXAOJAK_js.CardContent, { className: "p-6 sm:p-8", children: emailContent }) });
|
|
1202
|
+
}
|
|
1203
|
+
var DEFAULT_LABELS = {
|
|
1204
|
+
menuLabel: "User menu",
|
|
1205
|
+
userAlt: "User",
|
|
1206
|
+
signOut: "Sign out",
|
|
1207
|
+
signOutConfirmTitle: "Sign out?",
|
|
1208
|
+
signOutConfirmButton: "Sign out",
|
|
1209
|
+
signOutCancelButton: "Cancel"
|
|
1210
|
+
};
|
|
1211
|
+
function UserButton({ menuItems = [], onSignOut, avatarUrl, labels }) {
|
|
1212
|
+
const resolvedLabels = { ...DEFAULT_LABELS, ...labels };
|
|
1213
|
+
const { user, logout, status } = client.useAuth();
|
|
1214
|
+
const [confirmSignOut, setConfirmSignOut] = react.useState(false);
|
|
1215
|
+
if (status !== "authenticated") {
|
|
1216
|
+
return null;
|
|
1217
|
+
}
|
|
1218
|
+
const userInitials = user?.name ? user.name.split(" ").map((word) => word[0]).join("").slice(0, 2).toUpperCase() : user?.email?.slice(0, 2).toUpperCase() ?? "??";
|
|
1219
|
+
const resolvedAvatarUrl = avatarUrl ?? user?.image;
|
|
1220
|
+
const handleSignOutRequest = () => {
|
|
1221
|
+
chunkUZ3CMNUJ_js.triggerHaptic("light");
|
|
1222
|
+
setConfirmSignOut(true);
|
|
1223
|
+
};
|
|
1224
|
+
const handleSignOutConfirm = async () => {
|
|
1225
|
+
chunkUZ3CMNUJ_js.triggerHaptic("success");
|
|
1226
|
+
setConfirmSignOut(false);
|
|
1227
|
+
try {
|
|
1228
|
+
onSignOut?.();
|
|
1229
|
+
await logout("/");
|
|
1230
|
+
} catch {
|
|
1231
|
+
}
|
|
1232
|
+
};
|
|
1233
|
+
const handleSignOutCancel = () => {
|
|
1234
|
+
chunkUZ3CMNUJ_js.triggerHaptic("light");
|
|
1235
|
+
setConfirmSignOut(false);
|
|
1236
|
+
};
|
|
1237
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1238
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react$1.Menu, { as: "div", className: "relative inline-block text-left", children: [
|
|
1239
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1240
|
+
react$1.Menu.Button,
|
|
1241
|
+
{
|
|
1242
|
+
className: "flex items-center gap-2 rounded-full p-1 transition-opacity hover:opacity-80 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500",
|
|
1243
|
+
"aria-label": resolvedLabels.menuLabel,
|
|
1244
|
+
children: [
|
|
1245
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1246
|
+
chunkKNXAOJAK_js.Avatar,
|
|
1247
|
+
{
|
|
1248
|
+
src: resolvedAvatarUrl,
|
|
1249
|
+
initials: userInitials,
|
|
1250
|
+
alt: user?.name ?? user?.email ?? resolvedLabels.userAlt
|
|
1251
|
+
}
|
|
1252
|
+
),
|
|
1253
|
+
/* @__PURE__ */ jsxRuntime.jsx(solid.ChevronUpDownIcon, { className: "h-4 w-4 text-gray-500 dark:text-gray-400" })
|
|
1254
|
+
]
|
|
1255
|
+
}
|
|
1256
|
+
),
|
|
1257
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1258
|
+
react$1.Transition,
|
|
1259
|
+
{
|
|
1260
|
+
as: react.Fragment,
|
|
1261
|
+
enter: "transition ease-out duration-100",
|
|
1262
|
+
enterFrom: "transform opacity-0 scale-95",
|
|
1263
|
+
enterTo: "transform opacity-100 scale-100",
|
|
1264
|
+
leave: "transition ease-in duration-75",
|
|
1265
|
+
leaveFrom: "transform opacity-100 scale-100",
|
|
1266
|
+
leaveTo: "transform opacity-0 scale-95",
|
|
1267
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(react$1.Menu.Items, { className: "liquid-surface absolute right-0 z-50 mt-2 w-60 origin-top-right rounded-2xl shadow-lg ring-1 ring-black/5 focus:outline-none dark:ring-white/10", children: [
|
|
1268
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 border-b border-gray-200/60 px-4 py-3 dark:border-white/10", children: [
|
|
1269
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1270
|
+
chunkKNXAOJAK_js.Avatar,
|
|
1271
|
+
{
|
|
1272
|
+
src: resolvedAvatarUrl,
|
|
1273
|
+
initials: userInitials,
|
|
1274
|
+
alt: user?.name ?? user?.email ?? resolvedLabels.userAlt
|
|
1275
|
+
}
|
|
1276
|
+
),
|
|
1277
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
1278
|
+
user?.name && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-sm font-medium text-gray-900 dark:text-white", children: user.name }),
|
|
1279
|
+
user?.email && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-xs text-gray-500 dark:text-gray-400", children: user.email })
|
|
1280
|
+
] })
|
|
1281
|
+
] }),
|
|
1282
|
+
menuItems.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1283
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-1 py-1", children: menuItems.map((item, index) => /* @__PURE__ */ jsxRuntime.jsx(react$1.Menu.Item, { children: ({ active }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1284
|
+
"button",
|
|
1285
|
+
{
|
|
1286
|
+
type: "button",
|
|
1287
|
+
onClick: () => {
|
|
1288
|
+
chunkUZ3CMNUJ_js.triggerHaptic("light");
|
|
1289
|
+
item.onClick();
|
|
1290
|
+
},
|
|
1291
|
+
className: `flex w-full items-center gap-2 rounded-xl px-3 py-2 text-sm transition-colors ${active ? "bg-gray-100 text-gray-900 dark:bg-white/10 dark:text-white" : "text-gray-700 dark:text-gray-300"}`,
|
|
1292
|
+
children: [
|
|
1293
|
+
item.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "h-4 w-4 shrink-0 text-gray-400", children: item.icon }) : null,
|
|
1294
|
+
item.label
|
|
1295
|
+
]
|
|
1296
|
+
}
|
|
1297
|
+
) }, index)) }),
|
|
1298
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-gray-200/60 dark:border-white/10" })
|
|
1299
|
+
] }),
|
|
1300
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-gray-200/60 px-1 py-1 dark:border-white/10", children: /* @__PURE__ */ jsxRuntime.jsx(react$1.Menu.Item, { children: ({ active }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1301
|
+
"button",
|
|
1302
|
+
{
|
|
1303
|
+
type: "button",
|
|
1304
|
+
onClick: handleSignOutRequest,
|
|
1305
|
+
className: `flex w-full items-center gap-2 rounded-xl px-3 py-2 text-sm transition-colors ${active ? "bg-red-50 text-red-700 dark:bg-red-500/10 dark:text-red-400" : "text-red-600 dark:text-red-400"}`,
|
|
1306
|
+
children: [
|
|
1307
|
+
/* @__PURE__ */ jsxRuntime.jsx(solid.ArrowRightStartOnRectangleIcon, { className: "h-4 w-4 shrink-0" }),
|
|
1308
|
+
resolvedLabels.signOut
|
|
1309
|
+
]
|
|
1310
|
+
}
|
|
1311
|
+
) }) })
|
|
1312
|
+
] })
|
|
1313
|
+
}
|
|
1314
|
+
)
|
|
1315
|
+
] }),
|
|
1316
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1317
|
+
chunkKNXAOJAK_js.DynamicIslandConfirm,
|
|
1318
|
+
{
|
|
1319
|
+
open: confirmSignOut,
|
|
1320
|
+
onClose: handleSignOutCancel,
|
|
1321
|
+
onConfirm: handleSignOutConfirm,
|
|
1322
|
+
title: resolvedLabels.signOutConfirmTitle,
|
|
1323
|
+
confirmLabel: resolvedLabels.signOutConfirmButton,
|
|
1324
|
+
cancelLabel: resolvedLabels.signOutCancelButton
|
|
1325
|
+
}
|
|
1326
|
+
)
|
|
1327
|
+
] });
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
exports.ConsentScreen = ConsentScreen;
|
|
1331
|
+
exports.ForgotPassword = ForgotPassword;
|
|
1332
|
+
exports.MfaChallenge = MfaChallenge;
|
|
1333
|
+
exports.PasswordlessSignIn = PasswordlessSignIn;
|
|
1334
|
+
exports.ResetPassword = ResetPassword;
|
|
1335
|
+
exports.SignIn = SignIn;
|
|
1336
|
+
exports.SignUp = SignUp;
|
|
1337
|
+
exports.SsoConnectorList = SsoConnectorList;
|
|
1338
|
+
exports.SsoEmailForm = SsoEmailForm;
|
|
1339
|
+
exports.UserButton = UserButton;
|
|
1340
|
+
exports.VerifyEmail = VerifyEmail;
|
|
1341
|
+
//# sourceMappingURL=chunk-LBALE4JX.js.map
|
|
1342
|
+
//# sourceMappingURL=chunk-LBALE4JX.js.map
|