orbital-ds 0.28.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/AGENTS.md +303 -273
  2. package/components.manifest.json +526 -12
  3. package/dist/hooks/use-ds-messages.d.ts +205 -0
  4. package/dist/lib/auth-better-auth.d.ts +29 -0
  5. package/dist/lib/auth-better-auth.js +60 -0
  6. package/dist/lib/auth-flow.d.ts +83 -0
  7. package/dist/lib/auth-flow.js +152 -0
  8. package/dist/lib/auth-providers.d.ts +194 -0
  9. package/dist/lib/auth-providers.js +64 -0
  10. package/dist/lib/auth.d.ts +68 -0
  11. package/dist/lib/auth.js +110 -0
  12. package/dist/lib/header-control.d.ts +4 -0
  13. package/dist/lib/header-control.js +14 -0
  14. package/dist/lib/i18n.d.ts +205 -0
  15. package/dist/lib/i18n.js +624 -3
  16. package/dist/ui/app-bar.d.ts +10 -0
  17. package/dist/ui/app-bar.js +51 -0
  18. package/dist/ui/attachment.js +1 -1
  19. package/dist/ui/auth-backdrop.d.ts +20 -0
  20. package/dist/ui/auth-backdrop.js +137 -0
  21. package/dist/ui/auth-form.d.ts +111 -0
  22. package/dist/ui/auth-form.js +531 -0
  23. package/dist/ui/auth-layout.d.ts +70 -0
  24. package/dist/ui/auth-layout.js +283 -0
  25. package/dist/ui/auth-parts.d.ts +43 -0
  26. package/dist/ui/auth-parts.js +159 -0
  27. package/dist/ui/auth-status.d.ts +23 -0
  28. package/dist/ui/auth-status.js +99 -0
  29. package/dist/ui/badge.js +2 -2
  30. package/dist/ui/button.js +1 -1
  31. package/dist/ui/connected-accounts.d.ts +25 -0
  32. package/dist/ui/connected-accounts.js +89 -0
  33. package/dist/ui/content-card.d.ts +6 -2
  34. package/dist/ui/content-card.js +27 -3
  35. package/dist/ui/dropzone.js +1 -1
  36. package/dist/ui/empty-state.d.ts +10 -1
  37. package/dist/ui/empty-state.js +28 -7
  38. package/dist/ui/error-page.d.ts +10 -1
  39. package/dist/ui/error-page.js +74 -28
  40. package/dist/ui/icon-tile.d.ts +1 -1
  41. package/dist/ui/input-otp.js +2 -1
  42. package/dist/ui/item.js +1 -1
  43. package/dist/ui/legend.js +1 -1
  44. package/dist/ui/locale-switcher.d.ts +19 -0
  45. package/dist/ui/locale-switcher.js +54 -0
  46. package/dist/ui/menubar.js +1 -1
  47. package/dist/ui/message-scroller.js +1 -1
  48. package/dist/ui/mfa-challenge.d.ts +33 -0
  49. package/dist/ui/mfa-challenge.js +214 -0
  50. package/dist/ui/mfa-setup.d.ts +29 -0
  51. package/dist/ui/mfa-setup.js +196 -0
  52. package/dist/ui/navigation-menu.js +2 -2
  53. package/dist/ui/notice-review.d.ts +1 -0
  54. package/dist/ui/notifications.d.ts +12 -2
  55. package/dist/ui/notifications.js +28 -5
  56. package/dist/ui/oauth-consent.d.ts +54 -0
  57. package/dist/ui/oauth-consent.js +208 -0
  58. package/dist/ui/passkey-list.d.ts +17 -0
  59. package/dist/ui/passkey-list.js +112 -0
  60. package/dist/ui/password-input.d.ts +5 -0
  61. package/dist/ui/password-input.js +77 -0
  62. package/dist/ui/session-list.d.ts +19 -0
  63. package/dist/ui/session-list.js +70 -0
  64. package/dist/ui/session-timeout.d.ts +13 -0
  65. package/dist/ui/session-timeout.js +87 -0
  66. package/dist/ui/sidebar.d.ts +27 -5
  67. package/dist/ui/sidebar.js +56 -11
  68. package/dist/ui/sign-out-dialog.d.ts +17 -0
  69. package/dist/ui/sign-out-dialog.js +82 -0
  70. package/dist/ui/stat-group.d.ts +1 -1
  71. package/dist/ui/stat-group.js +6 -2
  72. package/dist/ui/stat.d.ts +24 -5
  73. package/dist/ui/stat.js +124 -19
  74. package/dist/ui/status-badge.d.ts +1 -1
  75. package/dist/ui/theme-toggle.d.ts +14 -0
  76. package/dist/ui/theme-toggle.js +112 -0
  77. package/dist/ui/toggle.js +2 -2
  78. package/dist/ui/week-strip.js +1 -1
  79. package/docs/CONTRACT.md +1 -1
  80. package/docs/designer/patrones.md +27 -0
  81. package/docs/designer/revision.md +8 -0
  82. package/package.json +3 -2
  83. package/scripts/brand-core.d.mts +2 -0
  84. package/scripts/brand-core.mjs +21 -1
  85. package/scripts/cli.mjs +452 -452
  86. package/scripts/doctor.mjs +3 -0
  87. package/scripts/init.mjs +7 -3
  88. package/dist/motion.css +0 -146
  89. package/dist/styles.css +0 -1240
  90. package/dist/themes/fractalia.css +0 -549
  91. package/dist/themes/fractalia.fonts.css +0 -3
  92. package/dist/themes/fractalia.guide.md +0 -86
  93. package/dist/themes/fractalia.meta.json +0 -112
  94. package/dist/themes/fractalia.scoped.css +0 -549
  95. package/dist/themes/fractalia.tokens.json +0 -39
  96. package/dist/themes/friendly.css +0 -367
  97. package/dist/themes/friendly.fonts.css +0 -2
  98. package/dist/themes/friendly.guide.md +0 -38
  99. package/dist/themes/friendly.meta.json +0 -82
  100. package/dist/themes/friendly.scoped.css +0 -367
  101. package/dist/themes/friendly.tokens.json +0 -45
  102. package/dist/themes/lagoon.css +0 -348
  103. package/dist/themes/lagoon.fonts.css +0 -2
  104. package/dist/themes/lagoon.guide.md +0 -47
  105. package/dist/themes/lagoon.meta.json +0 -84
  106. package/dist/themes/lagoon.scoped.css +0 -348
  107. package/dist/themes/lagoon.tokens.json +0 -49
  108. package/dist/themes/liquid.css +0 -502
  109. package/dist/themes/liquid.fonts.css +0 -7
  110. package/dist/themes/liquid.guide.md +0 -82
  111. package/dist/themes/liquid.meta.json +0 -134
  112. package/dist/themes/liquid.scoped.css +0 -502
  113. package/dist/themes/liquid.tokens.json +0 -47
  114. package/dist/themes/qratia.css +0 -260
  115. package/dist/themes/qratia.fonts.css +0 -2
  116. package/dist/themes/qratia.guide.md +0 -34
  117. package/dist/themes/qratia.meta.json +0 -49
  118. package/dist/themes/qratia.scoped.css +0 -260
  119. package/dist/themes/qratia.tokens.json +0 -49
  120. package/dist/themes/tactile.css +0 -588
  121. package/dist/themes/tactile.fonts.css +0 -3
  122. package/dist/themes/tactile.guide.md +0 -82
  123. package/dist/themes/tactile.meta.json +0 -182
  124. package/dist/themes/tactile.scoped.css +0 -588
  125. package/dist/themes/tactile.tokens.json +0 -42
  126. package/dist/themes/twitter.css +0 -357
  127. package/dist/themes/twitter.fonts.css +0 -6
  128. package/dist/themes/twitter.guide.md +0 -35
  129. package/dist/themes/twitter.meta.json +0 -90
  130. package/dist/themes/twitter.scoped.css +0 -357
  131. package/dist/themes/twitter.tokens.json +0 -45
  132. package/dist/themes/zyro.css +0 -434
  133. package/dist/themes/zyro.fonts.css +0 -2
  134. package/dist/themes/zyro.guide.md +0 -33
  135. package/dist/themes/zyro.meta.json +0 -74
  136. package/dist/themes/zyro.scoped.css +0 -434
  137. package/dist/themes/zyro.tokens.json +0 -46
@@ -30,6 +30,11 @@ declare const DsMessagesContext: React.Context<{
30
30
  sidebarToggle: string;
31
31
  sidebarTitle: string;
32
32
  sidebarDescription: string;
33
+ themeToggleLabel: string;
34
+ themeLight: string;
35
+ themeDark: string;
36
+ themeSystem: string;
37
+ localeSwitcherLabel: string;
33
38
  questionnairePrevious: string;
34
39
  questionnaireSkip: string;
35
40
  questionnaireNext: string;
@@ -126,6 +131,7 @@ declare const DsMessagesContext: React.Context<{
126
131
  statIncrease: string;
127
132
  statDecrease: string;
128
133
  statNoChange: string;
134
+ statOfTarget: string;
129
135
  notificationsForYou: string;
130
136
  notificationsGeneral: string;
131
137
  notificationsHistory: string;
@@ -175,6 +181,205 @@ declare const DsMessagesContext: React.Context<{
175
181
  weekLabel: string;
176
182
  weekPrevious: string;
177
183
  weekNext: string;
184
+ authOr: string;
185
+ authContinueWith: string;
186
+ authLastUsed: string;
187
+ authPasskey: string;
188
+ authShowPassword: string;
189
+ authHidePassword: string;
190
+ authCapsLock: string;
191
+ authSignInTitle: string;
192
+ authSignInDescription: string;
193
+ authSignUpTitle: string;
194
+ authSignUpDescription: string;
195
+ authMagicLinkTitle: string;
196
+ authMagicLinkDescription: string;
197
+ authEmailCodeTitle: string;
198
+ authEmailCodeDescription: string;
199
+ authSsoTitle: string;
200
+ authSsoDescription: string;
201
+ authSsoOrgDescription: string;
202
+ authForgotTitle: string;
203
+ authForgotDescription: string;
204
+ authResetTitle: string;
205
+ authResetDescription: string;
206
+ authSignInSubmit: string;
207
+ authSignUpSubmit: string;
208
+ authSendLink: string;
209
+ authSendCode: string;
210
+ authSsoSubmit: string;
211
+ authSendReset: string;
212
+ authResetSubmit: string;
213
+ authContinue: string;
214
+ authEmail: string;
215
+ authUsername: string;
216
+ authEmailOrUsername: string;
217
+ authName: string;
218
+ authPassword: string;
219
+ authNewPassword: string;
220
+ authConfirmPassword: string;
221
+ authWorkEmail: string;
222
+ authOrganization: string;
223
+ authRemember: string;
224
+ authForgotLink: string;
225
+ authTermsAccept: string;
226
+ authTermsLink: string;
227
+ authAnd: string;
228
+ authPrivacyLink: string;
229
+ authRequired: string;
230
+ authInvalidEmail: string;
231
+ authPasswordMismatch: string;
232
+ authTermsRequired: string;
233
+ authPasswordRules: string;
234
+ authRuleMinLength: string;
235
+ authRuleLowercase: string;
236
+ authRuleUppercase: string;
237
+ authRuleNumber: string;
238
+ authRuleSymbol: string;
239
+ authRuleMet: string;
240
+ authRulePending: string;
241
+ authCheckEmailTitle: string;
242
+ authLinkSentBody: string;
243
+ authResetSentBody: string;
244
+ authCodeSentBody: string;
245
+ authResend: string;
246
+ authResendIn: string;
247
+ authUseDifferentEmail: string;
248
+ authCode: string;
249
+ authVerify: string;
250
+ authChooseOrganization: string;
251
+ authSsoRedirecting: string;
252
+ authChange: string;
253
+ authUseSso: string;
254
+ authBackToSignIn: string;
255
+ authNoAccount: string;
256
+ authSignUpLink: string;
257
+ authNoAccess: string;
258
+ authRequestAccessLink: string;
259
+ authAudienceMixed: string;
260
+ authAudienceInternal: string;
261
+ authAccessInternal: string;
262
+ authAccessExternal: string;
263
+ authHaveAccount: string;
264
+ authSignInLink: string;
265
+ authMfaTitle: string;
266
+ authMfaTotpBody: string;
267
+ authMfaSmsBody: string;
268
+ authMfaEmailBody: string;
269
+ authMfaBackupBody: string;
270
+ authMfaPasskeyBody: string;
271
+ authMfaPasskeyAction: string;
272
+ authMfaTrustDevice: string;
273
+ authMfaTryAnother: string;
274
+ authMfaMethodTotp: string;
275
+ authMfaMethodSms: string;
276
+ authMfaMethodEmail: string;
277
+ authMfaMethodBackup: string;
278
+ authMfaMethodPasskey: string;
279
+ authBackupCode: string;
280
+ authBack: string;
281
+ authCancel: string;
282
+ authMfaBackupTitle: string;
283
+ authMfaBackupSetupBody: string;
284
+ authCopyAll: string;
285
+ authDownload: string;
286
+ authMfaBackupConfirm: string;
287
+ authDone: string;
288
+ authMfaSetupTotpTitle: string;
289
+ authMfaSetupTotpStep1: string;
290
+ authMfaSetupManual: string;
291
+ authMfaSetupTotpStep2: string;
292
+ authActivate: string;
293
+ authMfaSetupSmsTitle: string;
294
+ authMfaSetupSmsBody: string;
295
+ authPhone: string;
296
+ authSignedOutTitle: string;
297
+ authSignedOutBody: string;
298
+ authSignInAgain: string;
299
+ authSessionExpiredTitle: string;
300
+ authSessionExpiredBody: string;
301
+ authVerifyEmailTitle: string;
302
+ authVerifyEmailBody: string;
303
+ authEmailVerifiedTitle: string;
304
+ authEmailVerifiedBody: string;
305
+ authPasswordChangedTitle: string;
306
+ authPasswordChangedBody: string;
307
+ authAccountLockedTitle: string;
308
+ authAccountLockedBody: string;
309
+ authResetPasswordAction: string;
310
+ authLinkExpiredTitle: string;
311
+ authLinkExpiredBody: string;
312
+ authRequestNewLink: string;
313
+ authAccessDeniedTitle: string;
314
+ authAccessDeniedBody: string;
315
+ authBackHome: string;
316
+ authSignOutTitle: string;
317
+ authSignOutBody: string;
318
+ authSignOutAllDevices: string;
319
+ authSignOut: string;
320
+ authSessionTimeoutTitle: string;
321
+ authSessionTimeoutBody: string;
322
+ authSessionTimeoutLeft: string;
323
+ authSocialDescription: string;
324
+ authContinueWithEmail: string;
325
+ authOauthTitle: string;
326
+ authOauthBody: string;
327
+ authOauthMcpTitle: string;
328
+ authOauthMcpBody: string;
329
+ authOauthDeviceTitle: string;
330
+ authOauthDeviceBody: string;
331
+ authOauthDeviceCode: string;
332
+ authOauthDeviceConfirm: string;
333
+ authOauthVerified: string;
334
+ authOauthSwitchAccount: string;
335
+ authOauthUnverified: string;
336
+ authOauthPermissions: string;
337
+ authOauthSensitive: string;
338
+ authOauthAllow: string;
339
+ authOauthDeny: string;
340
+ authOauthRedirect: string;
341
+ authOauthRevokeNote: string;
342
+ authConnConnected: string;
343
+ authConnExpired: string;
344
+ authConnError: string;
345
+ authConnNotConnected: string;
346
+ authConnConnect: string;
347
+ authConnPending: string;
348
+ authConnReconnect: string;
349
+ authConnDisconnect: string;
350
+ authConnLastMethod: string;
351
+ authSessionActiveNow: string;
352
+ authSessionLastActive: string;
353
+ authSessionUnknownDevice: string;
354
+ authSessionCurrent: string;
355
+ authSessionRevoke: string;
356
+ authSessionRevokeOthers: string;
357
+ authPasskeysAdd: string;
358
+ authPasskeysEmptyTitle: string;
359
+ authPasskeysEmptyBody: string;
360
+ authPasskeysCreated: string;
361
+ authPasskeysLastUsed: string;
362
+ authPasskeysName: string;
363
+ authPasskeysSave: string;
364
+ authPasskeysRename: string;
365
+ authPasskeysDelete: string;
366
+ authPasskeysSynced: string;
367
+ authStaySignedIn: string;
368
+ authErrorInvalidCredentials: string;
369
+ authErrorAccountLocked: string;
370
+ authErrorTooManyAttempts: string;
371
+ authErrorEmailNotVerified: string;
372
+ authErrorEmailTaken: string;
373
+ authErrorWeakPassword: string;
374
+ authErrorPasswordReused: string;
375
+ authErrorInvalidCode: string;
376
+ authErrorExpiredCode: string;
377
+ authErrorLinkExpired: string;
378
+ authErrorSessionExpired: string;
379
+ authErrorProviderFailed: string;
380
+ authErrorPasskeyFailed: string;
381
+ authErrorNetwork: string;
382
+ authErrorUnknown: string;
178
383
  }>;
179
384
  /** Textos de los componentes en el idioma activo. */
180
385
  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,83 @@
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
+ /** Por qué puerta entra una persona: plantilla de la organización o gente de fuera. */
11
+ type AuthAccessKind = "internal" | "external";
12
+ type AuthAccessRule = {
13
+ methods: AuthSignInMethod[];
14
+ mfaRequired: boolean;
15
+ signUp: AuthSignUp;
16
+ };
17
+ type AuthFlowConfig = {
18
+ preset: AuthFlowPreset;
19
+ /** Para quién es la puerta: plantilla (internal), gente de fuera (external) o las dos (mixed). */
20
+ audience: AuthAudience;
21
+ /** Métodos ofrecidos para entrar, en orden de preferencia. */
22
+ methods: AuthSignInMethod[];
23
+ /** Proveedores sociales (ids de Better Auth). */
24
+ providers: AuthProviderId[];
25
+ /** Preset de AuthForm para la pantalla de entrada. */
26
+ signIn: "sign-in" | "social" | "magic-link" | "email-code" | "sso";
27
+ /** Identificador primero (home realm discovery). */
28
+ identifierFirst: boolean;
29
+ /** Dominios de la plantilla (sin @): su correo va al SSO corporativo. Obligatorio en `mixed`. */
30
+ internalDomains: string[];
31
+ /** Cómo se crean las cuentas: registro abierto, por invitación o desde el directorio (SSO). */
32
+ signUp: AuthSignUp;
33
+ mfa: {
34
+ required: boolean;
35
+ methods: MfaMethod[];
36
+ };
37
+ /** Reglas por tipo de persona; lo que falte se deduce del flujo (ver `resolveAuthAccess`). */
38
+ access?: {
39
+ internal?: Partial<AuthAccessRule>;
40
+ external?: Partial<AuthAccessRule>;
41
+ };
42
+ /** Props de AuthLayout. */
43
+ layout: {
44
+ preset?: "centered" | "split" | "cover" | "banner" | "minimal";
45
+ surface?: "solid" | "glass" | "elevated" | "plain";
46
+ shape?: "rounded" | "soft" | "sharp";
47
+ backdrop?: "none" | "dots" | "grid" | "aurora" | "mesh" | "glow" | "rings" | "beams" | "image";
48
+ /** Cristal esmerilado sobre el fondo («mesh + glass»). */
49
+ backdropGlass?: boolean;
50
+ motion?: "full" | "entrance" | "off";
51
+ mediaTint?: "none" | "brand" | "duotone";
52
+ };
53
+ };
54
+ type FlowDefaults = Omit<AuthFlowConfig, "preset">;
55
+ declare const AUTH_FLOW_PRESETS: Record<AuthFlowPreset, FlowDefaults>;
56
+ /** Flujo a partir de un preset; cualquier valor explícito lo sobrescribe. */
57
+ declare function defineAuthFlow(preset: AuthFlowPreset, overrides?: Partial<Omit<AuthFlowConfig, "preset">>): AuthFlowConfig;
58
+ /** ¿Es de la plantilla? Compara el dominio del correo (y sus subdominios) con `internalDomains`. */
59
+ declare function isInternalIdentifier(flow: Pick<AuthFlowConfig, "internalDomains">, identifier: string): boolean;
60
+ type AccessFlow = Pick<AuthFlowConfig, "audience" | "methods" | "internalDomains" | "signUp" | "mfa" | "access">;
61
+ /** Regla efectiva de cada puerta: lo explícito de `access` manda; el resto se deduce del flujo. */
62
+ declare function authAccessRule(flow: AccessFlow, kind: AuthAccessKind): AuthAccessRule;
63
+ /**
64
+ * ¿Por qué puerta entra este correo y qué se le exigirá? `internal` si el flujo es interno o el dominio es de
65
+ * la plantilla; `external` en el resto. Devuelve la regla de esa puerta y el método con el que seguir.
66
+ */
67
+ declare function resolveAuthAccess(flow: AccessFlow, identifier: string): AuthAccessRule & {
68
+ kind: AuthAccessKind;
69
+ method: AuthSignInMethod;
70
+ };
71
+ /**
72
+ * Ruta por defecto para `AuthForm onIdentify`: la plantilla (o una puerta interna) va al SSO; el
73
+ * resto, al primer método de cuenta propia del flujo. Para dominios de clientes con su propio SSO
74
+ * (enterprise, partner), la app consulta antes a su proveedor y cae aquí si no lo encuentra.
75
+ */
76
+ declare function routeAuthIdentifier(flow: Pick<AuthFlowConfig, "audience" | "methods" | "internalDomains"> & Partial<Pick<AuthFlowConfig, "signUp" | "mfa" | "access">>, identifier: string): {
77
+ method: "password" | "sso" | "passkey" | "email-code" | "magic-link";
78
+ access: AuthAccessKind;
79
+ };
80
+ /** Problemas de un flujo (vacío = válido). Mensajes en inglés, como `dsWarn`. */
81
+ declare function validateAuthFlow(flow: AuthFlowConfig): string[];
82
+
83
+ export { AUTH_FLOW_PRESETS, type AuthAccessKind, type AuthAccessRule, type AuthAudience, type AuthFlowConfig, type AuthFlowPreset, type AuthSignInMethod, type AuthSignUp, authAccessRule, defineAuthFlow, isInternalIdentifier, resolveAuthAccess, routeAuthIdentifier, validateAuthFlow };
@@ -0,0 +1,152 @@
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
+ access: { internal: { ...overrides.access?.internal }, external: { ...overrides.access?.external } },
88
+ layout: { ...base.layout, ...overrides.layout }
89
+ };
90
+ }
91
+ function isInternalIdentifier(flow, identifier) {
92
+ const domain = identifier.trim().toLowerCase().split("@")[1];
93
+ if (!domain) return false;
94
+ return flow.internalDomains.some((d) => {
95
+ const base = d.trim().toLowerCase().replace(/^@/, "");
96
+ return domain === base || domain.endsWith(`.${base}`);
97
+ });
98
+ }
99
+ function authAccessRule(flow, kind) {
100
+ const own = flow.methods.filter((m) => m !== "sso");
101
+ const sso = flow.methods.includes("sso");
102
+ const base = kind === "internal" ? { methods: sso ? ["sso"] : own, mfaRequired: sso ? false : flow.mfa.required, signUp: "none" } : { methods: own.length ? own : flow.methods, mfaRequired: flow.mfa.required, signUp: flow.signUp };
103
+ return { ...base, ...flow.access?.[kind] };
104
+ }
105
+ function resolveAuthAccess(flow, identifier) {
106
+ const kind = flow.audience === "internal" || flow.audience === "mixed" && isInternalIdentifier(flow, identifier) ? "internal" : "external";
107
+ const rule = authAccessRule(flow, kind);
108
+ return { ...rule, kind, method: rule.methods[0] ?? "password" };
109
+ }
110
+ function routeAuthIdentifier(flow, identifier) {
111
+ const r = resolveAuthAccess({ signUp: "open", mfa: { required: false, methods: [] }, ...flow }, identifier);
112
+ if (r.methods.includes("sso") && r.kind === "internal") return { method: "sso", access: r.kind };
113
+ const own = r.methods.find(
114
+ (m) => m === "password" || m === "email-code" || m === "magic-link" || m === "passkey"
115
+ );
116
+ return { method: own ?? "sso", access: r.kind };
117
+ }
118
+ function validateAuthFlow(flow) {
119
+ const issues = [];
120
+ const has = (m) => flow.methods.includes(m);
121
+ const ownAccount = has("password") || has("email-code") || has("magic-link") || has("social") || has("passkey");
122
+ if (!flow.methods.length) issues.push("No sign-in method.");
123
+ if (has("social") && !flow.providers.length) issues.push('"social" method without `providers`.');
124
+ if (flow.signIn === "social" && !has("social") && !has("passkey")) issues.push('signIn "social" needs the "social" or "passkey" method.');
125
+ if (flow.signIn === "sso" && !has("sso")) issues.push('signIn "sso" needs the "sso" method.');
126
+ if (flow.identifierFirst && flow.methods.length < 2) issues.push("identifierFirst only makes sense with two or more methods.");
127
+ if (flow.mfa.required && !flow.mfa.methods.length) issues.push("MFA required without `mfa.methods`.");
128
+ if (flow.mfa.required && !flow.mfa.methods.includes("backup-code")) issues.push("MFA required without backup codes: people could be locked out.");
129
+ if (flow.signUp !== "none" && flow.methods.length === 1 && has("sso")) issues.push("Sign-up with SSO only: accounts come from the identity provider.");
130
+ if (flow.audience === "internal" && flow.signUp === "open") issues.push("Internal audience with open sign-up: staff accounts come from the directory.");
131
+ if (flow.audience === "internal" && !has("sso")) issues.push('Internal audience without the "sso" method.');
132
+ if (flow.audience === "external" && !ownAccount) issues.push("External audience with SSO only: outside people rarely have your identity provider.");
133
+ if (flow.audience === "mixed") {
134
+ if (!has("sso")) issues.push('Mixed audience without the "sso" method for staff.');
135
+ if (!ownAccount) issues.push("Mixed audience without a method for external people.");
136
+ if (!flow.internalDomains.length) issues.push("Mixed audience without `internalDomains`: staff cannot be routed to SSO.");
137
+ if (!flow.identifierFirst) issues.push("Mixed audience works best with identifierFirst: the email decides the door.");
138
+ }
139
+ if (flow.access?.internal?.signUp && flow.access.internal.signUp !== "none") issues.push('`access.internal.signUp` should be "none": staff accounts come from the directory.');
140
+ if (flow.access?.external?.methods?.includes("sso") && flow.audience !== "external") issues.push('`access.external.methods` with "sso": SSO is the staff door; external SSO goes through `onIdentify` (their own company).');
141
+ if (flow.audience === "external" && flow.internalDomains.length) issues.push('`internalDomains` on an external audience: use "mixed" if staff also sign in here.');
142
+ return issues;
143
+ }
144
+ export {
145
+ AUTH_FLOW_PRESETS,
146
+ authAccessRule,
147
+ defineAuthFlow,
148
+ isInternalIdentifier,
149
+ resolveAuthAccess,
150
+ routeAuthIdentifier,
151
+ validateAuthFlow
152
+ };