orbital-ds 0.28.0 → 0.29.1
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/AGENTS.md +289 -273
- package/components.manifest.json +410 -7
- package/dist/hooks/use-ds-messages.d.ts +196 -0
- package/dist/lib/auth-better-auth.d.ts +29 -0
- package/dist/lib/auth-better-auth.js +60 -0
- package/dist/lib/auth-flow.d.ts +59 -0
- package/dist/lib/auth-flow.js +135 -0
- package/dist/lib/auth-providers.d.ts +194 -0
- package/dist/lib/auth-providers.js +64 -0
- package/dist/lib/auth.d.ts +68 -0
- package/dist/lib/auth.js +110 -0
- package/dist/lib/i18n.d.ts +196 -0
- package/dist/lib/i18n.js +597 -3
- package/dist/styles.css +419 -3
- package/dist/themes/lagoon.css +8 -8
- package/dist/themes/lagoon.meta.json +3 -2
- package/dist/themes/lagoon.scoped.css +8 -8
- package/dist/ui/auth-backdrop.d.ts +20 -0
- package/dist/ui/auth-backdrop.js +137 -0
- package/dist/ui/auth-form.d.ts +107 -0
- package/dist/ui/auth-form.js +526 -0
- package/dist/ui/auth-layout.d.ts +70 -0
- package/dist/ui/auth-layout.js +283 -0
- package/dist/ui/auth-parts.d.ts +43 -0
- package/dist/ui/auth-parts.js +159 -0
- package/dist/ui/auth-status.d.ts +23 -0
- package/dist/ui/auth-status.js +99 -0
- package/dist/ui/connected-accounts.d.ts +25 -0
- package/dist/ui/connected-accounts.js +89 -0
- package/dist/ui/empty-state.d.ts +10 -1
- package/dist/ui/empty-state.js +28 -7
- package/dist/ui/error-page.d.ts +10 -1
- package/dist/ui/error-page.js +74 -28
- package/dist/ui/icon-tile.d.ts +1 -1
- package/dist/ui/input-otp.js +2 -1
- package/dist/ui/mfa-challenge.d.ts +33 -0
- package/dist/ui/mfa-challenge.js +214 -0
- package/dist/ui/mfa-setup.d.ts +29 -0
- package/dist/ui/mfa-setup.js +196 -0
- package/dist/ui/oauth-consent.d.ts +54 -0
- package/dist/ui/oauth-consent.js +208 -0
- package/dist/ui/passkey-list.d.ts +17 -0
- package/dist/ui/passkey-list.js +112 -0
- package/dist/ui/password-input.d.ts +5 -0
- package/dist/ui/password-input.js +77 -0
- package/dist/ui/session-list.d.ts +19 -0
- package/dist/ui/session-list.js +70 -0
- package/dist/ui/session-timeout.d.ts +13 -0
- package/dist/ui/session-timeout.js +87 -0
- package/dist/ui/sidebar.d.ts +12 -4
- package/dist/ui/sidebar.js +35 -5
- package/dist/ui/sign-out-dialog.d.ts +17 -0
- package/dist/ui/sign-out-dialog.js +82 -0
- package/dist/ui/stat-group.d.ts +1 -1
- package/dist/ui/stat-group.js +6 -2
- package/dist/ui/stat.d.ts +24 -5
- package/dist/ui/stat.js +124 -19
- package/dist/ui/status-badge.d.ts +1 -1
- package/docs/designer/patrones.md +21 -0
- package/docs/designer/revision.md +8 -0
- package/package.json +187 -187
- package/scripts/brand-core.d.mts +2 -0
- package/scripts/brand-core.mjs +21 -1
- package/scripts/doctor.mjs +3 -0
- package/scripts/init.mjs +7 -3
|
@@ -126,6 +126,7 @@ declare const DsMessagesContext: React.Context<{
|
|
|
126
126
|
statIncrease: string;
|
|
127
127
|
statDecrease: string;
|
|
128
128
|
statNoChange: string;
|
|
129
|
+
statOfTarget: string;
|
|
129
130
|
notificationsForYou: string;
|
|
130
131
|
notificationsGeneral: string;
|
|
131
132
|
notificationsHistory: string;
|
|
@@ -175,6 +176,201 @@ declare const DsMessagesContext: React.Context<{
|
|
|
175
176
|
weekLabel: string;
|
|
176
177
|
weekPrevious: string;
|
|
177
178
|
weekNext: string;
|
|
179
|
+
authOr: string;
|
|
180
|
+
authContinueWith: string;
|
|
181
|
+
authLastUsed: string;
|
|
182
|
+
authPasskey: string;
|
|
183
|
+
authShowPassword: string;
|
|
184
|
+
authHidePassword: string;
|
|
185
|
+
authCapsLock: string;
|
|
186
|
+
authSignInTitle: string;
|
|
187
|
+
authSignInDescription: string;
|
|
188
|
+
authSignUpTitle: string;
|
|
189
|
+
authSignUpDescription: string;
|
|
190
|
+
authMagicLinkTitle: string;
|
|
191
|
+
authMagicLinkDescription: string;
|
|
192
|
+
authEmailCodeTitle: string;
|
|
193
|
+
authEmailCodeDescription: string;
|
|
194
|
+
authSsoTitle: string;
|
|
195
|
+
authSsoDescription: string;
|
|
196
|
+
authSsoOrgDescription: string;
|
|
197
|
+
authForgotTitle: string;
|
|
198
|
+
authForgotDescription: string;
|
|
199
|
+
authResetTitle: string;
|
|
200
|
+
authResetDescription: string;
|
|
201
|
+
authSignInSubmit: string;
|
|
202
|
+
authSignUpSubmit: string;
|
|
203
|
+
authSendLink: string;
|
|
204
|
+
authSendCode: string;
|
|
205
|
+
authSsoSubmit: string;
|
|
206
|
+
authSendReset: string;
|
|
207
|
+
authResetSubmit: string;
|
|
208
|
+
authContinue: string;
|
|
209
|
+
authEmail: string;
|
|
210
|
+
authUsername: string;
|
|
211
|
+
authEmailOrUsername: string;
|
|
212
|
+
authName: string;
|
|
213
|
+
authPassword: string;
|
|
214
|
+
authNewPassword: string;
|
|
215
|
+
authConfirmPassword: string;
|
|
216
|
+
authWorkEmail: string;
|
|
217
|
+
authOrganization: string;
|
|
218
|
+
authRemember: string;
|
|
219
|
+
authForgotLink: string;
|
|
220
|
+
authTermsAccept: string;
|
|
221
|
+
authTermsLink: string;
|
|
222
|
+
authAnd: string;
|
|
223
|
+
authPrivacyLink: string;
|
|
224
|
+
authRequired: string;
|
|
225
|
+
authInvalidEmail: string;
|
|
226
|
+
authPasswordMismatch: string;
|
|
227
|
+
authTermsRequired: string;
|
|
228
|
+
authPasswordRules: string;
|
|
229
|
+
authRuleMinLength: string;
|
|
230
|
+
authRuleLowercase: string;
|
|
231
|
+
authRuleUppercase: string;
|
|
232
|
+
authRuleNumber: string;
|
|
233
|
+
authRuleSymbol: string;
|
|
234
|
+
authRuleMet: string;
|
|
235
|
+
authRulePending: string;
|
|
236
|
+
authCheckEmailTitle: string;
|
|
237
|
+
authLinkSentBody: string;
|
|
238
|
+
authResetSentBody: string;
|
|
239
|
+
authCodeSentBody: string;
|
|
240
|
+
authResend: string;
|
|
241
|
+
authResendIn: string;
|
|
242
|
+
authUseDifferentEmail: string;
|
|
243
|
+
authCode: string;
|
|
244
|
+
authVerify: string;
|
|
245
|
+
authChooseOrganization: string;
|
|
246
|
+
authSsoRedirecting: string;
|
|
247
|
+
authChange: string;
|
|
248
|
+
authUseSso: string;
|
|
249
|
+
authBackToSignIn: string;
|
|
250
|
+
authNoAccount: string;
|
|
251
|
+
authSignUpLink: string;
|
|
252
|
+
authNoAccess: string;
|
|
253
|
+
authRequestAccessLink: string;
|
|
254
|
+
authHaveAccount: string;
|
|
255
|
+
authSignInLink: string;
|
|
256
|
+
authMfaTitle: string;
|
|
257
|
+
authMfaTotpBody: string;
|
|
258
|
+
authMfaSmsBody: string;
|
|
259
|
+
authMfaEmailBody: string;
|
|
260
|
+
authMfaBackupBody: string;
|
|
261
|
+
authMfaPasskeyBody: string;
|
|
262
|
+
authMfaPasskeyAction: string;
|
|
263
|
+
authMfaTrustDevice: string;
|
|
264
|
+
authMfaTryAnother: string;
|
|
265
|
+
authMfaMethodTotp: string;
|
|
266
|
+
authMfaMethodSms: string;
|
|
267
|
+
authMfaMethodEmail: string;
|
|
268
|
+
authMfaMethodBackup: string;
|
|
269
|
+
authMfaMethodPasskey: string;
|
|
270
|
+
authBackupCode: string;
|
|
271
|
+
authBack: string;
|
|
272
|
+
authCancel: string;
|
|
273
|
+
authMfaBackupTitle: string;
|
|
274
|
+
authMfaBackupSetupBody: string;
|
|
275
|
+
authCopyAll: string;
|
|
276
|
+
authDownload: string;
|
|
277
|
+
authMfaBackupConfirm: string;
|
|
278
|
+
authDone: string;
|
|
279
|
+
authMfaSetupTotpTitle: string;
|
|
280
|
+
authMfaSetupTotpStep1: string;
|
|
281
|
+
authMfaSetupManual: string;
|
|
282
|
+
authMfaSetupTotpStep2: string;
|
|
283
|
+
authActivate: string;
|
|
284
|
+
authMfaSetupSmsTitle: string;
|
|
285
|
+
authMfaSetupSmsBody: string;
|
|
286
|
+
authPhone: string;
|
|
287
|
+
authSignedOutTitle: string;
|
|
288
|
+
authSignedOutBody: string;
|
|
289
|
+
authSignInAgain: string;
|
|
290
|
+
authSessionExpiredTitle: string;
|
|
291
|
+
authSessionExpiredBody: string;
|
|
292
|
+
authVerifyEmailTitle: string;
|
|
293
|
+
authVerifyEmailBody: string;
|
|
294
|
+
authEmailVerifiedTitle: string;
|
|
295
|
+
authEmailVerifiedBody: string;
|
|
296
|
+
authPasswordChangedTitle: string;
|
|
297
|
+
authPasswordChangedBody: string;
|
|
298
|
+
authAccountLockedTitle: string;
|
|
299
|
+
authAccountLockedBody: string;
|
|
300
|
+
authResetPasswordAction: string;
|
|
301
|
+
authLinkExpiredTitle: string;
|
|
302
|
+
authLinkExpiredBody: string;
|
|
303
|
+
authRequestNewLink: string;
|
|
304
|
+
authAccessDeniedTitle: string;
|
|
305
|
+
authAccessDeniedBody: string;
|
|
306
|
+
authBackHome: string;
|
|
307
|
+
authSignOutTitle: string;
|
|
308
|
+
authSignOutBody: string;
|
|
309
|
+
authSignOutAllDevices: string;
|
|
310
|
+
authSignOut: string;
|
|
311
|
+
authSessionTimeoutTitle: string;
|
|
312
|
+
authSessionTimeoutBody: string;
|
|
313
|
+
authSessionTimeoutLeft: string;
|
|
314
|
+
authSocialDescription: string;
|
|
315
|
+
authContinueWithEmail: string;
|
|
316
|
+
authOauthTitle: string;
|
|
317
|
+
authOauthBody: string;
|
|
318
|
+
authOauthMcpTitle: string;
|
|
319
|
+
authOauthMcpBody: string;
|
|
320
|
+
authOauthDeviceTitle: string;
|
|
321
|
+
authOauthDeviceBody: string;
|
|
322
|
+
authOauthDeviceCode: string;
|
|
323
|
+
authOauthDeviceConfirm: string;
|
|
324
|
+
authOauthVerified: string;
|
|
325
|
+
authOauthSwitchAccount: string;
|
|
326
|
+
authOauthUnverified: string;
|
|
327
|
+
authOauthPermissions: string;
|
|
328
|
+
authOauthSensitive: string;
|
|
329
|
+
authOauthAllow: string;
|
|
330
|
+
authOauthDeny: string;
|
|
331
|
+
authOauthRedirect: string;
|
|
332
|
+
authOauthRevokeNote: string;
|
|
333
|
+
authConnConnected: string;
|
|
334
|
+
authConnExpired: string;
|
|
335
|
+
authConnError: string;
|
|
336
|
+
authConnNotConnected: string;
|
|
337
|
+
authConnConnect: string;
|
|
338
|
+
authConnPending: string;
|
|
339
|
+
authConnReconnect: string;
|
|
340
|
+
authConnDisconnect: string;
|
|
341
|
+
authConnLastMethod: string;
|
|
342
|
+
authSessionActiveNow: string;
|
|
343
|
+
authSessionLastActive: string;
|
|
344
|
+
authSessionUnknownDevice: string;
|
|
345
|
+
authSessionCurrent: string;
|
|
346
|
+
authSessionRevoke: string;
|
|
347
|
+
authSessionRevokeOthers: string;
|
|
348
|
+
authPasskeysAdd: string;
|
|
349
|
+
authPasskeysEmptyTitle: string;
|
|
350
|
+
authPasskeysEmptyBody: string;
|
|
351
|
+
authPasskeysCreated: string;
|
|
352
|
+
authPasskeysLastUsed: string;
|
|
353
|
+
authPasskeysName: string;
|
|
354
|
+
authPasskeysSave: string;
|
|
355
|
+
authPasskeysRename: string;
|
|
356
|
+
authPasskeysDelete: string;
|
|
357
|
+
authPasskeysSynced: string;
|
|
358
|
+
authStaySignedIn: string;
|
|
359
|
+
authErrorInvalidCredentials: string;
|
|
360
|
+
authErrorAccountLocked: string;
|
|
361
|
+
authErrorTooManyAttempts: string;
|
|
362
|
+
authErrorEmailNotVerified: string;
|
|
363
|
+
authErrorEmailTaken: string;
|
|
364
|
+
authErrorWeakPassword: string;
|
|
365
|
+
authErrorPasswordReused: string;
|
|
366
|
+
authErrorInvalidCode: string;
|
|
367
|
+
authErrorExpiredCode: string;
|
|
368
|
+
authErrorLinkExpired: string;
|
|
369
|
+
authErrorSessionExpired: string;
|
|
370
|
+
authErrorProviderFailed: string;
|
|
371
|
+
authErrorPasskeyFailed: string;
|
|
372
|
+
authErrorNetwork: string;
|
|
373
|
+
authErrorUnknown: string;
|
|
178
374
|
}>;
|
|
179
375
|
/** Textos de los componentes en el idioma activo. */
|
|
180
376
|
declare function useDsMessages(): DsMessages;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { AuthErrorCode } from './auth.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import './i18n.js';
|
|
4
|
+
|
|
5
|
+
/** Error tal como lo devuelve Better Auth (cliente o API). */
|
|
6
|
+
type BetterAuthError = {
|
|
7
|
+
code?: string;
|
|
8
|
+
message?: string;
|
|
9
|
+
status?: number;
|
|
10
|
+
statusText?: string;
|
|
11
|
+
} | null | undefined;
|
|
12
|
+
/** Traduce un error de Better Auth a `AuthErrorCode` (desconocido → `unknown`). */
|
|
13
|
+
declare function betterAuthErrorCode(error: BetterAuthError): AuthErrorCode;
|
|
14
|
+
/**
|
|
15
|
+
* Convierte una respuesta `{ data, error }` en lo que esperan los callbacks de orbital-ds:
|
|
16
|
+
* sin error → `undefined` (el componente sigue su flujo); con error → `{ error: AuthErrorCode }`.
|
|
17
|
+
* Si la cuenta tiene 2FA, Better Auth responde `twoFactorRedirect`: llévala a MfaChallenge.
|
|
18
|
+
*/
|
|
19
|
+
declare function fromBetterAuth(result: {
|
|
20
|
+
error?: BetterAuthError;
|
|
21
|
+
} | null | undefined): {
|
|
22
|
+
error: AuthErrorCode;
|
|
23
|
+
} | undefined;
|
|
24
|
+
/** ¿Pide Better Auth el segundo factor? (`data.twoFactorRedirect`). */
|
|
25
|
+
declare function needsTwoFactor(result: {
|
|
26
|
+
data?: unknown;
|
|
27
|
+
} | null | undefined): boolean;
|
|
28
|
+
|
|
29
|
+
export { type BetterAuthError, betterAuthErrorCode, fromBetterAuth, needsTwoFactor };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const CODES = {
|
|
2
|
+
INVALID_EMAIL_OR_PASSWORD: "invalid-credentials",
|
|
3
|
+
INVALID_USERNAME_OR_PASSWORD: "invalid-credentials",
|
|
4
|
+
INVALID_PASSWORD: "invalid-credentials",
|
|
5
|
+
INVALID_EMAIL: "invalid-credentials",
|
|
6
|
+
USER_NOT_FOUND: "invalid-credentials",
|
|
7
|
+
CREDENTIAL_ACCOUNT_NOT_FOUND: "invalid-credentials",
|
|
8
|
+
USER_ALREADY_EXISTS: "email-taken",
|
|
9
|
+
USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL: "email-taken",
|
|
10
|
+
USERNAME_IS_ALREADY_TAKEN: "email-taken",
|
|
11
|
+
EMAIL_NOT_VERIFIED: "email-not-verified",
|
|
12
|
+
PASSWORD_TOO_SHORT: "weak-password",
|
|
13
|
+
PASSWORD_TOO_LONG: "weak-password",
|
|
14
|
+
PASSWORD_COMPROMISED: "weak-password",
|
|
15
|
+
BANNED_USER: "account-locked",
|
|
16
|
+
USER_BANNED: "account-locked",
|
|
17
|
+
INVALID_TOKEN: "link-expired",
|
|
18
|
+
TOKEN_EXPIRED: "link-expired",
|
|
19
|
+
INVALID_CODE: "invalid-code",
|
|
20
|
+
INVALID_OTP: "invalid-code",
|
|
21
|
+
INVALID_TWO_FACTOR_CODE: "invalid-code",
|
|
22
|
+
INVALID_BACKUP_CODE: "invalid-code",
|
|
23
|
+
OTP_EXPIRED: "expired-code",
|
|
24
|
+
TOO_MANY_ATTEMPTS: "too-many-attempts",
|
|
25
|
+
TOO_MANY_ATTEMPTS_REQUEST_NEW_CODE: "too-many-attempts",
|
|
26
|
+
SESSION_EXPIRED: "session-expired",
|
|
27
|
+
FAILED_TO_GET_SESSION: "session-expired",
|
|
28
|
+
PROVIDER_NOT_FOUND: "provider-failed",
|
|
29
|
+
FAILED_TO_GET_USER_INFO: "provider-failed",
|
|
30
|
+
SOCIAL_ACCOUNT_ALREADY_LINKED: "provider-failed",
|
|
31
|
+
ACCOUNT_NOT_LINKED: "provider-failed",
|
|
32
|
+
SSO_PROVIDER_NOT_FOUND: "provider-failed",
|
|
33
|
+
AUTHENTICATION_FAILED: "passkey-failed",
|
|
34
|
+
CHALLENGE_NOT_FOUND: "passkey-failed",
|
|
35
|
+
PASSKEY_NOT_FOUND: "passkey-failed",
|
|
36
|
+
FAILED_TO_VERIFY_REGISTRATION: "passkey-failed"
|
|
37
|
+
};
|
|
38
|
+
function betterAuthErrorCode(error) {
|
|
39
|
+
if (!error) return "unknown";
|
|
40
|
+
if (error.status === 429) return "too-many-attempts";
|
|
41
|
+
const code = error.code?.toUpperCase();
|
|
42
|
+
if (code && CODES[code]) return CODES[code];
|
|
43
|
+
if (code?.includes("PASSKEY")) return "passkey-failed";
|
|
44
|
+
if (code?.includes("OTP") || code?.includes("CODE")) return "invalid-code";
|
|
45
|
+
if (error.status === 401) return "invalid-credentials";
|
|
46
|
+
if (error.status === 0 || error.status === void 0 && !code) return "network";
|
|
47
|
+
return "unknown";
|
|
48
|
+
}
|
|
49
|
+
function fromBetterAuth(result) {
|
|
50
|
+
return result?.error ? { error: betterAuthErrorCode(result.error) } : void 0;
|
|
51
|
+
}
|
|
52
|
+
function needsTwoFactor(result) {
|
|
53
|
+
const data = result?.data;
|
|
54
|
+
return !!data?.twoFactorRedirect;
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
betterAuthErrorCode,
|
|
58
|
+
fromBetterAuth,
|
|
59
|
+
needsTwoFactor
|
|
60
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AuthProviderId } from './auth-providers.js';
|
|
2
|
+
import { MfaMethod } from './auth.js';
|
|
3
|
+
import 'react';
|
|
4
|
+
import './i18n.js';
|
|
5
|
+
|
|
6
|
+
type AuthFlowPreset = "standard" | "social" | "passwordless" | "partner" | "enterprise" | "hybrid" | "sso-only";
|
|
7
|
+
type AuthAudience = "internal" | "external" | "mixed";
|
|
8
|
+
type AuthSignUp = "open" | "invite" | "none";
|
|
9
|
+
type AuthSignInMethod = "password" | "social" | "passkey" | "magic-link" | "email-code" | "sso";
|
|
10
|
+
type AuthFlowConfig = {
|
|
11
|
+
preset: AuthFlowPreset;
|
|
12
|
+
/** Para quién es la puerta: plantilla (internal), gente de fuera (external) o las dos (mixed). */
|
|
13
|
+
audience: AuthAudience;
|
|
14
|
+
/** Métodos ofrecidos para entrar, en orden de preferencia. */
|
|
15
|
+
methods: AuthSignInMethod[];
|
|
16
|
+
/** Proveedores sociales (ids de Better Auth). */
|
|
17
|
+
providers: AuthProviderId[];
|
|
18
|
+
/** Preset de AuthForm para la pantalla de entrada. */
|
|
19
|
+
signIn: "sign-in" | "social" | "magic-link" | "email-code" | "sso";
|
|
20
|
+
/** Identificador primero (home realm discovery). */
|
|
21
|
+
identifierFirst: boolean;
|
|
22
|
+
/** Dominios de la plantilla (sin @): su correo va al SSO corporativo. Obligatorio en `mixed`. */
|
|
23
|
+
internalDomains: string[];
|
|
24
|
+
/** Cómo se crean las cuentas: registro abierto, por invitación o desde el directorio (SSO). */
|
|
25
|
+
signUp: AuthSignUp;
|
|
26
|
+
mfa: {
|
|
27
|
+
required: boolean;
|
|
28
|
+
methods: MfaMethod[];
|
|
29
|
+
};
|
|
30
|
+
/** Props de AuthLayout. */
|
|
31
|
+
layout: {
|
|
32
|
+
preset?: "centered" | "split" | "cover" | "banner" | "minimal";
|
|
33
|
+
surface?: "solid" | "glass" | "elevated" | "plain";
|
|
34
|
+
shape?: "rounded" | "soft" | "sharp";
|
|
35
|
+
backdrop?: "none" | "dots" | "grid" | "aurora" | "mesh" | "glow" | "rings" | "beams" | "image";
|
|
36
|
+
/** Cristal esmerilado sobre el fondo («mesh + glass»). */
|
|
37
|
+
backdropGlass?: boolean;
|
|
38
|
+
motion?: "full" | "entrance" | "off";
|
|
39
|
+
mediaTint?: "none" | "brand" | "duotone";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type FlowDefaults = Omit<AuthFlowConfig, "preset">;
|
|
43
|
+
declare const AUTH_FLOW_PRESETS: Record<AuthFlowPreset, FlowDefaults>;
|
|
44
|
+
/** Flujo a partir de un preset; cualquier valor explícito lo sobrescribe. */
|
|
45
|
+
declare function defineAuthFlow(preset: AuthFlowPreset, overrides?: Partial<Omit<AuthFlowConfig, "preset">>): AuthFlowConfig;
|
|
46
|
+
/** ¿Es de la plantilla? Compara el dominio del correo (y sus subdominios) con `internalDomains`. */
|
|
47
|
+
declare function isInternalIdentifier(flow: Pick<AuthFlowConfig, "internalDomains">, identifier: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Ruta por defecto para `AuthForm onIdentify`: la plantilla (o una puerta interna) va al SSO; el
|
|
50
|
+
* resto, al primer método de cuenta propia del flujo. Para dominios de clientes con su propio SSO
|
|
51
|
+
* (enterprise, partner), la app consulta antes a su proveedor y cae aquí si no lo encuentra.
|
|
52
|
+
*/
|
|
53
|
+
declare function routeAuthIdentifier(flow: Pick<AuthFlowConfig, "audience" | "methods" | "internalDomains">, identifier: string): {
|
|
54
|
+
method: "password" | "sso" | "passkey" | "email-code" | "magic-link";
|
|
55
|
+
};
|
|
56
|
+
/** Problemas de un flujo (vacío = válido). Mensajes en inglés, como `dsWarn`. */
|
|
57
|
+
declare function validateAuthFlow(flow: AuthFlowConfig): string[];
|
|
58
|
+
|
|
59
|
+
export { AUTH_FLOW_PRESETS, type AuthAudience, type AuthFlowConfig, type AuthFlowPreset, type AuthSignInMethod, type AuthSignUp, defineAuthFlow, isInternalIdentifier, routeAuthIdentifier, validateAuthFlow };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
const AUTH_FLOW_PRESETS = {
|
|
2
|
+
standard: {
|
|
3
|
+
audience: "external",
|
|
4
|
+
methods: ["password", "social", "passkey"],
|
|
5
|
+
providers: ["google", "microsoft"],
|
|
6
|
+
signIn: "sign-in",
|
|
7
|
+
identifierFirst: false,
|
|
8
|
+
internalDomains: [],
|
|
9
|
+
signUp: "open",
|
|
10
|
+
mfa: { required: false, methods: ["totp", "passkey", "backup-code"] },
|
|
11
|
+
layout: { preset: "centered", surface: "solid", backdrop: "glow", motion: "full" }
|
|
12
|
+
},
|
|
13
|
+
social: {
|
|
14
|
+
audience: "external",
|
|
15
|
+
methods: ["social", "passkey", "email-code"],
|
|
16
|
+
providers: ["google", "apple", "microsoft"],
|
|
17
|
+
signIn: "social",
|
|
18
|
+
identifierFirst: false,
|
|
19
|
+
internalDomains: [],
|
|
20
|
+
signUp: "open",
|
|
21
|
+
mfa: { required: false, methods: ["passkey"] },
|
|
22
|
+
layout: { preset: "split", surface: "plain", motion: "full" }
|
|
23
|
+
},
|
|
24
|
+
passwordless: {
|
|
25
|
+
audience: "external",
|
|
26
|
+
methods: ["email-code", "passkey", "social"],
|
|
27
|
+
providers: ["google"],
|
|
28
|
+
signIn: "email-code",
|
|
29
|
+
identifierFirst: false,
|
|
30
|
+
internalDomains: [],
|
|
31
|
+
signUp: "open",
|
|
32
|
+
mfa: { required: false, methods: ["passkey"] },
|
|
33
|
+
layout: { preset: "centered", surface: "glass", backdrop: "aurora", motion: "full" }
|
|
34
|
+
},
|
|
35
|
+
partner: {
|
|
36
|
+
audience: "external",
|
|
37
|
+
methods: ["email-code", "password", "passkey", "sso"],
|
|
38
|
+
providers: [],
|
|
39
|
+
signIn: "sign-in",
|
|
40
|
+
identifierFirst: true,
|
|
41
|
+
internalDomains: [],
|
|
42
|
+
signUp: "invite",
|
|
43
|
+
mfa: { required: true, methods: ["totp", "passkey", "backup-code"] },
|
|
44
|
+
layout: { preset: "centered", surface: "elevated", backdrop: "dots", motion: "entrance" }
|
|
45
|
+
},
|
|
46
|
+
enterprise: {
|
|
47
|
+
audience: "external",
|
|
48
|
+
methods: ["sso", "passkey", "password"],
|
|
49
|
+
providers: [],
|
|
50
|
+
signIn: "sign-in",
|
|
51
|
+
identifierFirst: true,
|
|
52
|
+
internalDomains: [],
|
|
53
|
+
signUp: "none",
|
|
54
|
+
mfa: { required: true, methods: ["totp", "passkey", "backup-code"] },
|
|
55
|
+
layout: { preset: "split", surface: "plain", motion: "entrance" }
|
|
56
|
+
},
|
|
57
|
+
hybrid: {
|
|
58
|
+
audience: "mixed",
|
|
59
|
+
methods: ["sso", "email-code", "password", "passkey"],
|
|
60
|
+
providers: [],
|
|
61
|
+
signIn: "sign-in",
|
|
62
|
+
identifierFirst: true,
|
|
63
|
+
internalDomains: [],
|
|
64
|
+
signUp: "invite",
|
|
65
|
+
mfa: { required: true, methods: ["totp", "passkey", "backup-code"] },
|
|
66
|
+
layout: { preset: "split", surface: "plain", motion: "entrance" }
|
|
67
|
+
},
|
|
68
|
+
"sso-only": {
|
|
69
|
+
audience: "internal",
|
|
70
|
+
methods: ["sso"],
|
|
71
|
+
providers: [],
|
|
72
|
+
signIn: "sso",
|
|
73
|
+
identifierFirst: false,
|
|
74
|
+
internalDomains: [],
|
|
75
|
+
signUp: "none",
|
|
76
|
+
mfa: { required: false, methods: [] },
|
|
77
|
+
layout: { preset: "minimal", surface: "plain", motion: "entrance" }
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
function defineAuthFlow(preset, overrides = {}) {
|
|
81
|
+
const base = AUTH_FLOW_PRESETS[preset];
|
|
82
|
+
return {
|
|
83
|
+
...base,
|
|
84
|
+
...overrides,
|
|
85
|
+
preset,
|
|
86
|
+
mfa: { ...base.mfa, ...overrides.mfa },
|
|
87
|
+
layout: { ...base.layout, ...overrides.layout }
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function isInternalIdentifier(flow, identifier) {
|
|
91
|
+
const domain = identifier.trim().toLowerCase().split("@")[1];
|
|
92
|
+
if (!domain) return false;
|
|
93
|
+
return flow.internalDomains.some((d) => {
|
|
94
|
+
const base = d.trim().toLowerCase().replace(/^@/, "");
|
|
95
|
+
return domain === base || domain.endsWith(`.${base}`);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
function routeAuthIdentifier(flow, identifier) {
|
|
99
|
+
if (flow.methods.includes("sso") && (flow.audience === "internal" || isInternalIdentifier(flow, identifier))) return { method: "sso" };
|
|
100
|
+
const own = flow.methods.find(
|
|
101
|
+
(m) => m === "password" || m === "email-code" || m === "magic-link" || m === "passkey"
|
|
102
|
+
);
|
|
103
|
+
return { method: own ?? "sso" };
|
|
104
|
+
}
|
|
105
|
+
function validateAuthFlow(flow) {
|
|
106
|
+
const issues = [];
|
|
107
|
+
const has = (m) => flow.methods.includes(m);
|
|
108
|
+
const ownAccount = has("password") || has("email-code") || has("magic-link") || has("social") || has("passkey");
|
|
109
|
+
if (!flow.methods.length) issues.push("No sign-in method.");
|
|
110
|
+
if (has("social") && !flow.providers.length) issues.push('"social" method without `providers`.');
|
|
111
|
+
if (flow.signIn === "social" && !has("social") && !has("passkey")) issues.push('signIn "social" needs the "social" or "passkey" method.');
|
|
112
|
+
if (flow.signIn === "sso" && !has("sso")) issues.push('signIn "sso" needs the "sso" method.');
|
|
113
|
+
if (flow.identifierFirst && flow.methods.length < 2) issues.push("identifierFirst only makes sense with two or more methods.");
|
|
114
|
+
if (flow.mfa.required && !flow.mfa.methods.length) issues.push("MFA required without `mfa.methods`.");
|
|
115
|
+
if (flow.mfa.required && !flow.mfa.methods.includes("backup-code")) issues.push("MFA required without backup codes: people could be locked out.");
|
|
116
|
+
if (flow.signUp !== "none" && flow.methods.length === 1 && has("sso")) issues.push("Sign-up with SSO only: accounts come from the identity provider.");
|
|
117
|
+
if (flow.audience === "internal" && flow.signUp === "open") issues.push("Internal audience with open sign-up: staff accounts come from the directory.");
|
|
118
|
+
if (flow.audience === "internal" && !has("sso")) issues.push('Internal audience without the "sso" method.');
|
|
119
|
+
if (flow.audience === "external" && !ownAccount) issues.push("External audience with SSO only: outside people rarely have your identity provider.");
|
|
120
|
+
if (flow.audience === "mixed") {
|
|
121
|
+
if (!has("sso")) issues.push('Mixed audience without the "sso" method for staff.');
|
|
122
|
+
if (!ownAccount) issues.push("Mixed audience without a method for external people.");
|
|
123
|
+
if (!flow.internalDomains.length) issues.push("Mixed audience without `internalDomains`: staff cannot be routed to SSO.");
|
|
124
|
+
if (!flow.identifierFirst) issues.push("Mixed audience works best with identifierFirst: the email decides the door.");
|
|
125
|
+
}
|
|
126
|
+
if (flow.audience === "external" && flow.internalDomains.length) issues.push('`internalDomains` on an external audience: use "mixed" if staff also sign in here.');
|
|
127
|
+
return issues;
|
|
128
|
+
}
|
|
129
|
+
export {
|
|
130
|
+
AUTH_FLOW_PRESETS,
|
|
131
|
+
defineAuthFlow,
|
|
132
|
+
isInternalIdentifier,
|
|
133
|
+
routeAuthIdentifier,
|
|
134
|
+
validateAuthFlow
|
|
135
|
+
};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { AuthProviderOption } from './auth.js';
|
|
3
|
+
import './i18n.js';
|
|
4
|
+
|
|
5
|
+
type AuthProviderKind = "social" | "enterprise";
|
|
6
|
+
type AuthProviderInfo = {
|
|
7
|
+
/** Identificador de Better Auth. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** Nombre propio de la marca (no se traduce). */
|
|
10
|
+
label: string;
|
|
11
|
+
kind: AuthProviderKind;
|
|
12
|
+
};
|
|
13
|
+
/** Proveedores sociales de Better Auth (`socialProviders`). */
|
|
14
|
+
declare const AUTH_SOCIAL_PROVIDERS: readonly [{
|
|
15
|
+
readonly id: "google";
|
|
16
|
+
readonly label: "Google";
|
|
17
|
+
readonly kind: "social";
|
|
18
|
+
}, {
|
|
19
|
+
readonly id: "microsoft";
|
|
20
|
+
readonly label: "Microsoft";
|
|
21
|
+
readonly kind: "social";
|
|
22
|
+
}, {
|
|
23
|
+
readonly id: "apple";
|
|
24
|
+
readonly label: "Apple";
|
|
25
|
+
readonly kind: "social";
|
|
26
|
+
}, {
|
|
27
|
+
readonly id: "github";
|
|
28
|
+
readonly label: "GitHub";
|
|
29
|
+
readonly kind: "social";
|
|
30
|
+
}, {
|
|
31
|
+
readonly id: "gitlab";
|
|
32
|
+
readonly label: "GitLab";
|
|
33
|
+
readonly kind: "social";
|
|
34
|
+
}, {
|
|
35
|
+
readonly id: "facebook";
|
|
36
|
+
readonly label: "Facebook";
|
|
37
|
+
readonly kind: "social";
|
|
38
|
+
}, {
|
|
39
|
+
readonly id: "twitter";
|
|
40
|
+
readonly label: "X";
|
|
41
|
+
readonly kind: "social";
|
|
42
|
+
}, {
|
|
43
|
+
readonly id: "linkedin";
|
|
44
|
+
readonly label: "LinkedIn";
|
|
45
|
+
readonly kind: "social";
|
|
46
|
+
}, {
|
|
47
|
+
readonly id: "discord";
|
|
48
|
+
readonly label: "Discord";
|
|
49
|
+
readonly kind: "social";
|
|
50
|
+
}, {
|
|
51
|
+
readonly id: "slack";
|
|
52
|
+
readonly label: "Slack";
|
|
53
|
+
readonly kind: "social";
|
|
54
|
+
}, {
|
|
55
|
+
readonly id: "atlassian";
|
|
56
|
+
readonly label: "Atlassian";
|
|
57
|
+
readonly kind: "social";
|
|
58
|
+
}, {
|
|
59
|
+
readonly id: "notion";
|
|
60
|
+
readonly label: "Notion";
|
|
61
|
+
readonly kind: "social";
|
|
62
|
+
}, {
|
|
63
|
+
readonly id: "linear";
|
|
64
|
+
readonly label: "Linear";
|
|
65
|
+
readonly kind: "social";
|
|
66
|
+
}, {
|
|
67
|
+
readonly id: "figma";
|
|
68
|
+
readonly label: "Figma";
|
|
69
|
+
readonly kind: "social";
|
|
70
|
+
}, {
|
|
71
|
+
readonly id: "salesforce";
|
|
72
|
+
readonly label: "Salesforce";
|
|
73
|
+
readonly kind: "social";
|
|
74
|
+
}, {
|
|
75
|
+
readonly id: "dropbox";
|
|
76
|
+
readonly label: "Dropbox";
|
|
77
|
+
readonly kind: "social";
|
|
78
|
+
}, {
|
|
79
|
+
readonly id: "zoom";
|
|
80
|
+
readonly label: "Zoom";
|
|
81
|
+
readonly kind: "social";
|
|
82
|
+
}, {
|
|
83
|
+
readonly id: "spotify";
|
|
84
|
+
readonly label: "Spotify";
|
|
85
|
+
readonly kind: "social";
|
|
86
|
+
}, {
|
|
87
|
+
readonly id: "twitch";
|
|
88
|
+
readonly label: "Twitch";
|
|
89
|
+
readonly kind: "social";
|
|
90
|
+
}, {
|
|
91
|
+
readonly id: "tiktok";
|
|
92
|
+
readonly label: "TikTok";
|
|
93
|
+
readonly kind: "social";
|
|
94
|
+
}, {
|
|
95
|
+
readonly id: "reddit";
|
|
96
|
+
readonly label: "Reddit";
|
|
97
|
+
readonly kind: "social";
|
|
98
|
+
}, {
|
|
99
|
+
readonly id: "paypal";
|
|
100
|
+
readonly label: "PayPal";
|
|
101
|
+
readonly kind: "social";
|
|
102
|
+
}, {
|
|
103
|
+
readonly id: "huggingface";
|
|
104
|
+
readonly label: "Hugging Face";
|
|
105
|
+
readonly kind: "social";
|
|
106
|
+
}, {
|
|
107
|
+
readonly id: "vercel";
|
|
108
|
+
readonly label: "Vercel";
|
|
109
|
+
readonly kind: "social";
|
|
110
|
+
}, {
|
|
111
|
+
readonly id: "cognito";
|
|
112
|
+
readonly label: "Amazon Cognito";
|
|
113
|
+
readonly kind: "social";
|
|
114
|
+
}, {
|
|
115
|
+
readonly id: "roblox";
|
|
116
|
+
readonly label: "Roblox";
|
|
117
|
+
readonly kind: "social";
|
|
118
|
+
}, {
|
|
119
|
+
readonly id: "kick";
|
|
120
|
+
readonly label: "Kick";
|
|
121
|
+
readonly kind: "social";
|
|
122
|
+
}, {
|
|
123
|
+
readonly id: "vk";
|
|
124
|
+
readonly label: "VK";
|
|
125
|
+
readonly kind: "social";
|
|
126
|
+
}, {
|
|
127
|
+
readonly id: "kakao";
|
|
128
|
+
readonly label: "Kakao";
|
|
129
|
+
readonly kind: "social";
|
|
130
|
+
}, {
|
|
131
|
+
readonly id: "naver";
|
|
132
|
+
readonly label: "Naver";
|
|
133
|
+
readonly kind: "social";
|
|
134
|
+
}, {
|
|
135
|
+
readonly id: "line";
|
|
136
|
+
readonly label: "LINE";
|
|
137
|
+
readonly kind: "social";
|
|
138
|
+
}];
|
|
139
|
+
/**
|
|
140
|
+
* Proveedores de identidad de empresa (Better Auth `sso` con OIDC o SAML, o `genericOAuth`).
|
|
141
|
+
* En el formulario van por la vista SSO (correo de trabajo u organización), no como botones
|
|
142
|
+
* sueltos; se listan como botón solo si la app tiene un único IdP conocido.
|
|
143
|
+
*/
|
|
144
|
+
declare const AUTH_ENTERPRISE_PROVIDERS: readonly [{
|
|
145
|
+
readonly id: "entra-id";
|
|
146
|
+
readonly label: "Microsoft Entra ID";
|
|
147
|
+
readonly kind: "enterprise";
|
|
148
|
+
}, {
|
|
149
|
+
readonly id: "google-workspace";
|
|
150
|
+
readonly label: "Google Workspace";
|
|
151
|
+
readonly kind: "enterprise";
|
|
152
|
+
}, {
|
|
153
|
+
readonly id: "okta";
|
|
154
|
+
readonly label: "Okta";
|
|
155
|
+
readonly kind: "enterprise";
|
|
156
|
+
}, {
|
|
157
|
+
readonly id: "auth0";
|
|
158
|
+
readonly label: "Auth0";
|
|
159
|
+
readonly kind: "enterprise";
|
|
160
|
+
}, {
|
|
161
|
+
readonly id: "keycloak";
|
|
162
|
+
readonly label: "Keycloak";
|
|
163
|
+
readonly kind: "enterprise";
|
|
164
|
+
}, {
|
|
165
|
+
readonly id: "onelogin";
|
|
166
|
+
readonly label: "OneLogin";
|
|
167
|
+
readonly kind: "enterprise";
|
|
168
|
+
}, {
|
|
169
|
+
readonly id: "jumpcloud";
|
|
170
|
+
readonly label: "JumpCloud";
|
|
171
|
+
readonly kind: "enterprise";
|
|
172
|
+
}, {
|
|
173
|
+
readonly id: "ping";
|
|
174
|
+
readonly label: "Ping Identity";
|
|
175
|
+
readonly kind: "enterprise";
|
|
176
|
+
}, {
|
|
177
|
+
readonly id: "adfs";
|
|
178
|
+
readonly label: "AD FS";
|
|
179
|
+
readonly kind: "enterprise";
|
|
180
|
+
}];
|
|
181
|
+
/** Ids conocidos (autocompletado); se acepta cualquier otro texto. */
|
|
182
|
+
type AuthProviderId = (typeof AUTH_SOCIAL_PROVIDERS)[number]["id"] | (typeof AUTH_ENTERPRISE_PROVIDERS)[number]["id"] | (string & {});
|
|
183
|
+
/** Ficha de un proveedor (o `undefined` si no está en el catálogo). */
|
|
184
|
+
declare function authProviderInfo(id: string): AuthProviderInfo | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* Lista de opciones para `AuthForm`/`AuthProviders` en el orden pedido. `icons` y `labels` los
|
|
187
|
+
* pone la app; `disabled` desactiva algunos (p. ej. mientras no hay credenciales en ese entorno).
|
|
188
|
+
*/
|
|
189
|
+
declare function authProviders(ids: readonly AuthProviderId[], icons?: Partial<Record<string, React.ReactNode>>, options?: {
|
|
190
|
+
labels?: Partial<Record<string, string>>;
|
|
191
|
+
disabled?: readonly string[];
|
|
192
|
+
}): AuthProviderOption[];
|
|
193
|
+
|
|
194
|
+
export { AUTH_ENTERPRISE_PROVIDERS, AUTH_SOCIAL_PROVIDERS, type AuthProviderId, type AuthProviderInfo, type AuthProviderKind, authProviderInfo, authProviders };
|