@drawboard/authagonal-login 0.1.1 → 0.1.4

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/index.html CHANGED
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Sign In — Authagonal</title>
8
- <script type="module" crossorigin src="/assets/index-Bn-ws4eD.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-B_dF6q3E.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-CDKtEFn6.css">
10
10
  </head>
11
11
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawboard/authagonal-login",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Default login UI for Authagonal — runtime-configurable via branding.json",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
package/src/branding.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  import { createContext, useContext } from 'react';
2
2
 
3
+ /** A localizable string — either a plain string or an object mapping language codes to strings. */
4
+ export type LocalizedString = string | Record<string, string> | null;
5
+
3
6
  export interface BrandingConfig {
4
7
  appName: string;
5
8
  logoUrl: string | null;
@@ -7,6 +10,8 @@ export interface BrandingConfig {
7
10
  supportEmail: string | null;
8
11
  showForgotPassword: boolean;
9
12
  customCssUrl: string | null;
13
+ welcomeTitle: LocalizedString;
14
+ welcomeSubtitle: LocalizedString;
10
15
  }
11
16
 
12
17
  const defaults: BrandingConfig = {
@@ -16,6 +21,8 @@ const defaults: BrandingConfig = {
16
21
  supportEmail: null,
17
22
  showForgotPassword: true,
18
23
  customCssUrl: null,
24
+ welcomeTitle: null,
25
+ welcomeSubtitle: null,
19
26
  };
20
27
 
21
28
  export async function loadBranding(): Promise<BrandingConfig> {
@@ -34,3 +41,11 @@ export const BrandingContext = createContext<BrandingConfig>(defaults);
34
41
  export function useBranding(): BrandingConfig {
35
42
  return useContext(BrandingContext);
36
43
  }
44
+
45
+ /** Resolve a LocalizedString to a concrete string for the given language, or null if not set. */
46
+ export function resolveLocalized(value: LocalizedString, language: string): string | null {
47
+ if (value == null) return null;
48
+ if (typeof value === 'string') return value;
49
+ // Try exact match, then base language (e.g. "en" from "en-US"), then first available
50
+ return value[language] ?? value[language.split('-')[0]] ?? Object.values(value)[0] ?? null;
51
+ }
package/src/i18n/de.json CHANGED
@@ -47,5 +47,8 @@
47
47
  "continueWith": "Weiter mit {{provider}}",
48
48
  "or": "oder",
49
49
  "signedInAs": "Angemeldet als {{name}}",
50
- "signedInMessage": "Sie sind bereits authentifiziert."
50
+ "signedInMessage": "Sie sind bereits authentifiziert.",
51
+ "welcomeTitle": "Willkommen bei {{appName}}",
52
+ "welcomeSubtitle": "Melden Sie sich an, um auf Ihr Konto zuzugreifen",
53
+ "signOut": "Abmelden"
51
54
  }
package/src/i18n/en.json CHANGED
@@ -47,5 +47,8 @@
47
47
  "continueWith": "Continue with {{provider}}",
48
48
  "or": "or",
49
49
  "signedInAs": "Signed in as {{name}}",
50
- "signedInMessage": "You are already authenticated."
50
+ "signedInMessage": "You are already authenticated.",
51
+ "welcomeTitle": "Welcome to {{appName}}",
52
+ "welcomeSubtitle": "Sign in to access your account",
53
+ "signOut": "Sign out"
51
54
  }
package/src/i18n/es.json CHANGED
@@ -47,5 +47,8 @@
47
47
  "continueWith": "Continuar con {{provider}}",
48
48
  "or": "o",
49
49
  "signedInAs": "Conectado como {{name}}",
50
- "signedInMessage": "Ya est\u00e1s autenticado."
50
+ "signedInMessage": "Ya est\u00e1s autenticado.",
51
+ "welcomeTitle": "Bienvenido a {{appName}}",
52
+ "welcomeSubtitle": "Inicia sesi\u00f3n para acceder a tu cuenta",
53
+ "signOut": "Cerrar sesi\u00f3n"
51
54
  }
package/src/i18n/fr.json CHANGED
@@ -47,5 +47,8 @@
47
47
  "continueWith": "Continuer avec {{provider}}",
48
48
  "or": "ou",
49
49
  "signedInAs": "Connect\u00e9 en tant que {{name}}",
50
- "signedInMessage": "Vous \u00eates d\u00e9j\u00e0 authentifi\u00e9."
50
+ "signedInMessage": "Vous \u00eates d\u00e9j\u00e0 authentifi\u00e9.",
51
+ "welcomeTitle": "Bienvenue sur {{appName}}",
52
+ "welcomeSubtitle": "Connectez-vous pour acc\u00e9der \u00e0 votre compte",
53
+ "signOut": "Se d\u00e9connecter"
51
54
  }
package/src/i18n/pt.json CHANGED
@@ -47,5 +47,8 @@
47
47
  "continueWith": "Continuar com {{provider}}",
48
48
  "or": "ou",
49
49
  "signedInAs": "Conectado como {{name}}",
50
- "signedInMessage": "Você já está autenticado."
50
+ "signedInMessage": "Você já está autenticado.",
51
+ "welcomeTitle": "Bem-vindo ao {{appName}}",
52
+ "welcomeSubtitle": "Entre para acessar sua conta",
53
+ "signOut": "Sair"
51
54
  }
package/src/i18n/vi.json CHANGED
@@ -47,5 +47,8 @@
47
47
  "continueWith": "Tiếp tục với {{provider}}",
48
48
  "or": "hoặc",
49
49
  "signedInAs": "Đã đăng nhập với tên {{name}}",
50
- "signedInMessage": "Bạn đã được xác thực."
50
+ "signedInMessage": "Bạn đã được xác thực.",
51
+ "welcomeTitle": "Chào mừng đến với {{appName}}",
52
+ "welcomeSubtitle": "Đăng nhập để truy cập tài khoản của bạn",
53
+ "signOut": "Đăng xuất"
51
54
  }
@@ -47,5 +47,8 @@
47
47
  "continueWith": "使用 {{provider}} 继续",
48
48
  "or": "或",
49
49
  "signedInAs": "已登录为 {{name}}",
50
- "signedInMessage": "您已通过身份验证。"
50
+ "signedInMessage": "您已通过身份验证。",
51
+ "welcomeTitle": "欢迎使用 {{appName}}",
52
+ "welcomeSubtitle": "登录以访问您的帐户",
53
+ "signOut": "退出登录"
51
54
  }
package/src/index.ts CHANGED
@@ -12,8 +12,8 @@ export { default as ForgotPasswordPage } from './pages/ForgotPasswordPage';
12
12
  export { default as ResetPasswordPage } from './pages/ResetPasswordPage';
13
13
 
14
14
  // Branding
15
- export { loadBranding, BrandingContext, useBranding } from './branding';
16
- export type { BrandingConfig } from './branding';
15
+ export { loadBranding, BrandingContext, useBranding, resolveLocalized } from './branding';
16
+ export type { BrandingConfig, LocalizedString } from './branding';
17
17
 
18
18
  // API client
19
19
  export { login, logout, forgotPassword, resetPassword, getSession, ssoCheck, getProviders, getPasswordPolicy, ApiRequestError } from './api';
@@ -1,7 +1,7 @@
1
1
  import { useState, useEffect, useRef, useCallback } from 'react';
2
2
  import { useSearchParams, Link } from 'react-router-dom';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { login, ssoCheck, getProviders, getSession, ApiRequestError } from '../api';
4
+ import { login, logout, ssoCheck, getProviders, getSession, ApiRequestError } from '../api';
5
5
  import { useBranding } from '../branding';
6
6
  import type { ExternalProvider } from '../types';
7
7
 
@@ -191,6 +191,21 @@ export default function LoginPage() {
191
191
  <div>
192
192
  <h2 className="auth-title">{t('signedInAs', { name: session.name || session.email })}</h2>
193
193
  <p style={{ textAlign: 'center', color: '#6b7280' }}>{t('signedInMessage')}</p>
194
+ <div className="form-footer" style={{ marginTop: '16px' }}>
195
+ <button
196
+ type="button"
197
+ className="btn-secondary"
198
+ onClick={() => {
199
+ logout().then(() => {
200
+ setSession(null);
201
+ }).catch(() => {
202
+ setSession(null);
203
+ });
204
+ }}
205
+ >
206
+ {t('signOut')}
207
+ </button>
208
+ </div>
194
209
  </div>
195
210
  );
196
211
  }