@authagonal/login 0.3.2 → 0.3.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.d.ts CHANGED
@@ -13,11 +13,14 @@ export { default as ForgotPasswordPage } from './pages/ForgotPasswordPage';
13
13
  export { default as ResetPasswordPage } from './pages/ResetPasswordPage';
14
14
  export { default as MfaChallengePage } from './pages/MfaChallengePage';
15
15
  export { default as MfaSetupPage } from './pages/MfaSetupPage';
16
+ export { default as ConsentPage } from './pages/ConsentPage';
17
+ export { default as DevicePage } from './pages/DevicePage';
18
+ export { default as GrantsPage } from './pages/GrantsPage';
16
19
  export { default as App } from './App';
17
20
  export { loadBranding, BrandingContext, useBranding, resolveLocalized } from './branding';
18
21
  export type { BrandingConfig, LocalizedString } from './branding';
19
- export { login, logout, forgotPassword, resetPassword, getSession, ssoCheck, getProviders, getPasswordPolicy, mfaVerify, mfaStatus, mfaTotpSetup, mfaTotpConfirm, mfaWebAuthnSetup, mfaWebAuthnConfirm, mfaRecoveryGenerate, mfaDeleteCredential, ApiRequestError } from './api';
20
- export type { LoginResponse, ApiError, SessionResponse, SsoCheckResponse, ExternalProvider, ProvidersResponse, PasswordPolicyRule, PasswordPolicyResponse, MfaLoginResponse, MfaVerifyResponse, MfaStatusResponse, MfaMethod, MfaTotpSetupResponse, MfaRecoveryGenerateResponse, MfaWebAuthnSetupResponse, MfaWebAuthnConfirmResponse } from './types';
22
+ export { login, register, logout, forgotPassword, resetPassword, getSession, ssoCheck, getProviders, getPasswordPolicy, mfaVerify, mfaStatus, mfaTotpSetup, mfaTotpConfirm, mfaWebAuthnSetup, mfaWebAuthnConfirm, mfaRecoveryGenerate, mfaDeleteCredential, ApiRequestError } from './api';
23
+ export type { LoginResponse, RegisterResponse, ApiError, SessionResponse, SsoCheckResponse, ExternalProvider, ProvidersResponse, PasswordPolicyRule, PasswordPolicyResponse, MfaLoginResponse, MfaVerifyResponse, MfaStatusResponse, MfaMethod, MfaTotpSetupResponse, MfaRecoveryGenerateResponse, MfaWebAuthnSetupResponse, MfaWebAuthnConfirmResponse } from './types';
21
24
  export { default as i18n } from './i18n';
22
25
  export { useTranslation } from 'react-i18next';
23
26
  import './styles.css';
package/dist/index.js CHANGED
@@ -5979,9 +5979,121 @@ function Di() {
5979
5979
  ] });
5980
5980
  }
5981
5981
  //#endregion
5982
- //#region src/pages/DevicePage.tsx
5983
- var Oi = "";
5982
+ //#region src/pages/ConsentPage.tsx
5983
+ var Oi = {
5984
+ openid: "consent.scopeOpenid",
5985
+ profile: "consent.scopeProfile",
5986
+ email: "consent.scopeEmail",
5987
+ offline_access: "consent.scopeOfflineAccess",
5988
+ address: "consent.scopeAddress",
5989
+ phone: "consent.scopePhone"
5990
+ };
5984
5991
  function ki() {
5992
+ let { t: e } = L(), [t] = _(), n = t.get("client_id") ?? "", r = t.get("scope") ?? "openid", i = t.get("returnUrl") ?? "/", [o, c] = s(null), [d, f] = s(!0), [p, m] = s(!1), [h, g] = s("");
5993
+ a(() => {
5994
+ fetch(`/consent/info?client_id=${encodeURIComponent(n)}&scope=${encodeURIComponent(r)}`).then(async (e) => {
5995
+ if (!e.ok) throw Error("Failed to load");
5996
+ c(await e.json());
5997
+ }).catch(() => g(e("consent.loadError"))).finally(() => f(!1));
5998
+ }, [
5999
+ n,
6000
+ r,
6001
+ e
6002
+ ]);
6003
+ async function v(t) {
6004
+ m(!0), g("");
6005
+ try {
6006
+ let e = await (await fetch("/consent", {
6007
+ method: "POST",
6008
+ headers: { "Content-Type": "application/json" },
6009
+ body: JSON.stringify({
6010
+ clientId: n,
6011
+ decision: t,
6012
+ scopes: o?.scopes ?? r.split(" "),
6013
+ returnUrl: i
6014
+ })
6015
+ })).json();
6016
+ e.redirect && (window.location.href = e.redirect);
6017
+ } catch {
6018
+ g(e("consent.submitError")), m(!1);
6019
+ }
6020
+ }
6021
+ return d ? /* @__PURE__ */ l(Rr, { children: /* @__PURE__ */ l("p", {
6022
+ className: "text-sm text-gray-500 dark:text-gray-400 text-center",
6023
+ children: e("consent.loading")
6024
+ }) }) : /* @__PURE__ */ u(Rr, { children: [
6025
+ o?.logoUri && /* @__PURE__ */ l("div", {
6026
+ className: "flex justify-center mb-4",
6027
+ children: /* @__PURE__ */ l("img", {
6028
+ src: o.logoUri,
6029
+ alt: o.clientName,
6030
+ className: "h-12 w-12 rounded-lg object-contain",
6031
+ onError: (e) => {
6032
+ e.currentTarget.style.display = "none";
6033
+ }
6034
+ })
6035
+ }),
6036
+ /* @__PURE__ */ l(W, { children: e("consent.title", { appName: o?.clientName ?? n }) }),
6037
+ /* @__PURE__ */ l("p", {
6038
+ className: "text-sm text-gray-500 dark:text-gray-400 mb-4",
6039
+ children: e("consent.subtitle", { appName: o?.clientName ?? n })
6040
+ }),
6041
+ o?.description && /* @__PURE__ */ l("p", {
6042
+ className: "text-sm text-gray-600 dark:text-gray-300 mb-4",
6043
+ children: o.description
6044
+ }),
6045
+ o?.clientUri && /* @__PURE__ */ l("p", {
6046
+ className: "text-xs text-gray-500 dark:text-gray-400 mb-4",
6047
+ children: /* @__PURE__ */ l("a", {
6048
+ href: o.clientUri,
6049
+ target: "_blank",
6050
+ rel: "noopener noreferrer",
6051
+ className: "text-primary hover:underline",
6052
+ children: o.clientUri
6053
+ })
6054
+ }),
6055
+ h && /* @__PURE__ */ l(Q, {
6056
+ variant: "error",
6057
+ children: h
6058
+ }),
6059
+ /* @__PURE__ */ l("div", {
6060
+ className: "space-y-2 mb-6",
6061
+ children: (o?.scopes ?? r.split(" ")).map((t) => {
6062
+ let n = Oi[t];
6063
+ return /* @__PURE__ */ u("div", {
6064
+ className: "flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800/60 rounded-lg",
6065
+ children: [/* @__PURE__ */ l("div", { className: "w-2 h-2 bg-primary rounded-full shrink-0" }), /* @__PURE__ */ l("span", {
6066
+ className: "text-sm text-gray-700 dark:text-gray-300",
6067
+ children: n ? e(n) : t
6068
+ })]
6069
+ }, t);
6070
+ })
6071
+ }),
6072
+ /* @__PURE__ */ u("div", {
6073
+ className: "flex gap-3",
6074
+ children: [/* @__PURE__ */ l(Y, {
6075
+ onClick: () => v("allow"),
6076
+ loading: p,
6077
+ className: "flex-1",
6078
+ children: e("consent.allow")
6079
+ }), /* @__PURE__ */ l(Y, {
6080
+ variant: "secondary",
6081
+ onClick: () => v("deny"),
6082
+ disabled: p,
6083
+ className: "flex-1",
6084
+ children: e("consent.deny")
6085
+ })]
6086
+ }),
6087
+ /* @__PURE__ */ l(G, { children: /* @__PURE__ */ l("p", {
6088
+ className: "text-xs text-gray-400 dark:text-gray-500",
6089
+ children: e("consent.hint")
6090
+ }) })
6091
+ ] });
6092
+ }
6093
+ //#endregion
6094
+ //#region src/pages/DevicePage.tsx
6095
+ var Ai = "";
6096
+ function ji() {
5985
6097
  let e = g(), [t] = _(), [n, r] = s(t.get("user_code") || ""), [i, o] = s(!1), [c, d] = s(!0), [f, p] = s(!1), [m, h] = s(!1), [v, y] = s("");
5986
6098
  a(() => {
5987
6099
  $r().then((e) => {
@@ -5996,7 +6108,7 @@ function ki() {
5996
6108
  return;
5997
6109
  }
5998
6110
  try {
5999
- let e = await fetch(`${Oi}/api/auth/device/approve`, {
6111
+ let e = await fetch(`${Ai}/api/auth/device/approve`, {
6000
6112
  method: "POST",
6001
6113
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
6002
6114
  credentials: "include",
@@ -6110,118 +6222,6 @@ function ki() {
6110
6222
  ] });
6111
6223
  }
6112
6224
  //#endregion
6113
- //#region src/pages/ConsentPage.tsx
6114
- var Ai = {
6115
- openid: "consent.scopeOpenid",
6116
- profile: "consent.scopeProfile",
6117
- email: "consent.scopeEmail",
6118
- offline_access: "consent.scopeOfflineAccess",
6119
- address: "consent.scopeAddress",
6120
- phone: "consent.scopePhone"
6121
- };
6122
- function ji() {
6123
- let { t: e } = L(), [t] = _(), n = t.get("client_id") ?? "", r = t.get("scope") ?? "openid", i = t.get("returnUrl") ?? "/", [o, c] = s(null), [d, f] = s(!0), [p, m] = s(!1), [h, g] = s("");
6124
- a(() => {
6125
- fetch(`/consent/info?client_id=${encodeURIComponent(n)}&scope=${encodeURIComponent(r)}`).then(async (e) => {
6126
- if (!e.ok) throw Error("Failed to load");
6127
- c(await e.json());
6128
- }).catch(() => g(e("consent.loadError"))).finally(() => f(!1));
6129
- }, [
6130
- n,
6131
- r,
6132
- e
6133
- ]);
6134
- async function v(t) {
6135
- m(!0), g("");
6136
- try {
6137
- let e = await (await fetch("/consent", {
6138
- method: "POST",
6139
- headers: { "Content-Type": "application/json" },
6140
- body: JSON.stringify({
6141
- clientId: n,
6142
- decision: t,
6143
- scopes: o?.scopes ?? r.split(" "),
6144
- returnUrl: i
6145
- })
6146
- })).json();
6147
- e.redirect && (window.location.href = e.redirect);
6148
- } catch {
6149
- g(e("consent.submitError")), m(!1);
6150
- }
6151
- }
6152
- return d ? /* @__PURE__ */ l(Rr, { children: /* @__PURE__ */ l("p", {
6153
- className: "text-sm text-gray-500 dark:text-gray-400 text-center",
6154
- children: e("consent.loading")
6155
- }) }) : /* @__PURE__ */ u(Rr, { children: [
6156
- o?.logoUri && /* @__PURE__ */ l("div", {
6157
- className: "flex justify-center mb-4",
6158
- children: /* @__PURE__ */ l("img", {
6159
- src: o.logoUri,
6160
- alt: o.clientName,
6161
- className: "h-12 w-12 rounded-lg object-contain",
6162
- onError: (e) => {
6163
- e.currentTarget.style.display = "none";
6164
- }
6165
- })
6166
- }),
6167
- /* @__PURE__ */ l(W, { children: e("consent.title", { appName: o?.clientName ?? n }) }),
6168
- /* @__PURE__ */ l("p", {
6169
- className: "text-sm text-gray-500 dark:text-gray-400 mb-4",
6170
- children: e("consent.subtitle", { appName: o?.clientName ?? n })
6171
- }),
6172
- o?.description && /* @__PURE__ */ l("p", {
6173
- className: "text-sm text-gray-600 dark:text-gray-300 mb-4",
6174
- children: o.description
6175
- }),
6176
- o?.clientUri && /* @__PURE__ */ l("p", {
6177
- className: "text-xs text-gray-500 dark:text-gray-400 mb-4",
6178
- children: /* @__PURE__ */ l("a", {
6179
- href: o.clientUri,
6180
- target: "_blank",
6181
- rel: "noopener noreferrer",
6182
- className: "text-primary hover:underline",
6183
- children: o.clientUri
6184
- })
6185
- }),
6186
- h && /* @__PURE__ */ l(Q, {
6187
- variant: "error",
6188
- children: h
6189
- }),
6190
- /* @__PURE__ */ l("div", {
6191
- className: "space-y-2 mb-6",
6192
- children: (o?.scopes ?? r.split(" ")).map((t) => {
6193
- let n = Ai[t];
6194
- return /* @__PURE__ */ u("div", {
6195
- className: "flex items-center gap-3 p-3 bg-gray-50 dark:bg-gray-800/60 rounded-lg",
6196
- children: [/* @__PURE__ */ l("div", { className: "w-2 h-2 bg-primary rounded-full shrink-0" }), /* @__PURE__ */ l("span", {
6197
- className: "text-sm text-gray-700 dark:text-gray-300",
6198
- children: n ? e(n) : t
6199
- })]
6200
- }, t);
6201
- })
6202
- }),
6203
- /* @__PURE__ */ u("div", {
6204
- className: "flex gap-3",
6205
- children: [/* @__PURE__ */ l(Y, {
6206
- onClick: () => v("allow"),
6207
- loading: p,
6208
- className: "flex-1",
6209
- children: e("consent.allow")
6210
- }), /* @__PURE__ */ l(Y, {
6211
- variant: "secondary",
6212
- onClick: () => v("deny"),
6213
- disabled: p,
6214
- className: "flex-1",
6215
- children: e("consent.deny")
6216
- })]
6217
- }),
6218
- /* @__PURE__ */ l(G, { children: /* @__PURE__ */ l("p", {
6219
- className: "text-xs text-gray-400 dark:text-gray-500",
6220
- children: e("consent.hint")
6221
- }) })
6222
- ] });
6223
- }
6224
- //#endregion
6225
6225
  //#region src/pages/GrantsPage.tsx
6226
6226
  function Mi() {
6227
6227
  let { t: e } = L(), [t, n] = s([]), [r, i] = s(!0), [o, c] = s(""), [d, f] = s("");
@@ -6317,11 +6317,11 @@ function Ni() {
6317
6317
  }),
6318
6318
  /* @__PURE__ */ l(m, {
6319
6319
  path: "/device",
6320
- element: /* @__PURE__ */ l(ki, {})
6320
+ element: /* @__PURE__ */ l(ji, {})
6321
6321
  }),
6322
6322
  /* @__PURE__ */ l(m, {
6323
6323
  path: "/consent",
6324
- element: /* @__PURE__ */ l(ji, {})
6324
+ element: /* @__PURE__ */ l(ki, {})
6325
6325
  }),
6326
6326
  /* @__PURE__ */ l(m, {
6327
6327
  path: "/grants",
@@ -6337,4 +6337,4 @@ function Ni() {
6337
6337
  ] }) }) });
6338
6338
  }
6339
6339
  //#endregion
6340
- export { Q as Alert, Kr as ApiRequestError, Ni as App, Rr as AuthLayout, R as BrandingContext, Y as Button, Lt as Card, Bt as CardContent, zt as CardDescription, G as CardFooter, Rt as CardHeader, W as CardTitle, hi as ForgotPasswordPage, X as Input, Z as Label, pi as LoginPage, Ci as MfaChallengePage, Di as MfaSetupPage, mi as RegisterPage, yi as ResetPasswordPage, Wr as Separator, U as cn, Zr as forgotPassword, ni as getPasswordPolicy, ti as getProviders, $r as getSession, Pr as i18n, oe as loadBranding, Jr as login, Xr as logout, ui as mfaDeleteCredential, si as mfaRecoveryGenerate, ii as mfaStatus, oi as mfaTotpConfirm, ai as mfaTotpSetup, ri as mfaVerify, li as mfaWebAuthnConfirm, ci as mfaWebAuthnSetup, Qr as resetPassword, ce as resolveLocalized, ei as ssoCheck, se as useBranding, L as useTranslation };
6340
+ export { Q as Alert, Kr as ApiRequestError, Ni as App, Rr as AuthLayout, R as BrandingContext, Y as Button, Lt as Card, Bt as CardContent, zt as CardDescription, G as CardFooter, Rt as CardHeader, W as CardTitle, ki as ConsentPage, ji as DevicePage, hi as ForgotPasswordPage, Mi as GrantsPage, X as Input, Z as Label, pi as LoginPage, Ci as MfaChallengePage, Di as MfaSetupPage, mi as RegisterPage, yi as ResetPasswordPage, Wr as Separator, U as cn, Zr as forgotPassword, ni as getPasswordPolicy, ti as getProviders, $r as getSession, Pr as i18n, oe as loadBranding, Jr as login, Xr as logout, ui as mfaDeleteCredential, si as mfaRecoveryGenerate, ii as mfaStatus, oi as mfaTotpConfirm, ai as mfaTotpSetup, ri as mfaVerify, li as mfaWebAuthnConfirm, ci as mfaWebAuthnSetup, Yr as register, Qr as resetPassword, ce as resolveLocalized, ei as ssoCheck, se as useBranding, L as useTranslation };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authagonal/login",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "Default login UI for Authagonal — runtime-configurable via branding.json",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -21,6 +21,9 @@ export { default as ForgotPasswordPage } from './pages/ForgotPasswordPage';
21
21
  export { default as ResetPasswordPage } from './pages/ResetPasswordPage';
22
22
  export { default as MfaChallengePage } from './pages/MfaChallengePage';
23
23
  export { default as MfaSetupPage } from './pages/MfaSetupPage';
24
+ export { default as ConsentPage } from './pages/ConsentPage';
25
+ export { default as DevicePage } from './pages/DevicePage';
26
+ export { default as GrantsPage } from './pages/GrantsPage';
24
27
 
25
28
  // App — standalone SPA with routing (for consumers that want the full app)
26
29
  export { default as App } from './App';
@@ -30,10 +33,10 @@ export { loadBranding, BrandingContext, useBranding, resolveLocalized } from './
30
33
  export type { BrandingConfig, LocalizedString } from './branding';
31
34
 
32
35
  // API client
33
- export { login, logout, forgotPassword, resetPassword, getSession, ssoCheck, getProviders, getPasswordPolicy, mfaVerify, mfaStatus, mfaTotpSetup, mfaTotpConfirm, mfaWebAuthnSetup, mfaWebAuthnConfirm, mfaRecoveryGenerate, mfaDeleteCredential, ApiRequestError } from './api';
36
+ export { login, register, logout, forgotPassword, resetPassword, getSession, ssoCheck, getProviders, getPasswordPolicy, mfaVerify, mfaStatus, mfaTotpSetup, mfaTotpConfirm, mfaWebAuthnSetup, mfaWebAuthnConfirm, mfaRecoveryGenerate, mfaDeleteCredential, ApiRequestError } from './api';
34
37
 
35
38
  // Types
36
- export type { LoginResponse, ApiError, SessionResponse, SsoCheckResponse, ExternalProvider, ProvidersResponse, PasswordPolicyRule, PasswordPolicyResponse, MfaLoginResponse, MfaVerifyResponse, MfaStatusResponse, MfaMethod, MfaTotpSetupResponse, MfaRecoveryGenerateResponse, MfaWebAuthnSetupResponse, MfaWebAuthnConfirmResponse } from './types';
39
+ export type { LoginResponse, RegisterResponse, ApiError, SessionResponse, SsoCheckResponse, ExternalProvider, ProvidersResponse, PasswordPolicyRule, PasswordPolicyResponse, MfaLoginResponse, MfaVerifyResponse, MfaStatusResponse, MfaMethod, MfaTotpSetupResponse, MfaRecoveryGenerateResponse, MfaWebAuthnSetupResponse, MfaWebAuthnConfirmResponse } from './types';
37
40
 
38
41
  // i18n — re-export so consumers use the same react-i18next instance
39
42
  export { default as i18n } from './i18n';