@cellarnode/auth 0.11.0 → 0.12.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.
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react/unauthorized.d.ts +35 -1
- package/dist/react/unauthorized.d.ts.map +1 -1
- package/dist/react/unauthorized.js +6 -4
- package/dist/react/unauthorized.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { LoginForm, type LoginFormProps } from "./login-form.js";
|
|
2
2
|
export { RegisterForm, type RegisterFormProps } from "./register-form.js";
|
|
3
|
-
export { UnauthorizedPage, type UnauthorizedPageProps, } from "./unauthorized.js";
|
|
3
|
+
export { UnauthorizedPage, type UnauthorizedPageProps, type UnauthorizedPageLabels, } from "./unauthorized.js";
|
|
4
4
|
export type { DashboardLink } from "../types.js";
|
|
5
5
|
export { SquircleShift, type SquircleShiftProps } from "./squircle-shift.js";
|
|
6
6
|
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator, type InputOTPProps, } from "./input-otp-slots.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EACL,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,KAAK,aAAa,GACnB,MAAM,sBAAsB,CAAC"}
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAuB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAuB,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,gBAAgB,GAGjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,aAAa,EAA2B,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EACL,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,iBAAiB,GAElB,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,9 +1,43 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
import type { DashboardLink } from "../types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Localizable copy for {@link UnauthorizedPage}. Every omitted field falls
|
|
5
|
+
* back to its English default, so existing consumers are unaffected
|
|
6
|
+
* (CEL-918; mirrors the labels pattern of @cellarnode/ui).
|
|
7
|
+
*/
|
|
8
|
+
export interface UnauthorizedPageLabels {
|
|
9
|
+
/** Heading of the wrong-portal view. Default "Wrong Portal". */
|
|
10
|
+
wrongPortalTitle?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Full description under the wrong-portal heading. Overrides the composed
|
|
13
|
+
* English default ("You're signed in as a {userType}. This dashboard is
|
|
14
|
+
* for {expectedRole}.") — pass a fully-translated node (e.g. a <Trans>).
|
|
15
|
+
*/
|
|
16
|
+
wrongPortalDescription?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* CTA text for the matching dashboard link. Receives the link's label.
|
|
19
|
+
* Default: `Go to ${linkLabel}`.
|
|
20
|
+
*/
|
|
21
|
+
goToDashboard?: (linkLabel: string) => ReactNode;
|
|
22
|
+
/** Default "Sign in with a different account". */
|
|
23
|
+
switchAccount?: string;
|
|
24
|
+
/** Heading of the generic view. Default "Access Denied". */
|
|
25
|
+
accessDeniedTitle?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Full description under the access-denied heading. Overrides the composed
|
|
28
|
+
* English default ("This dashboard is for {expectedRole} only. …").
|
|
29
|
+
*/
|
|
30
|
+
accessDeniedDescription?: ReactNode;
|
|
31
|
+
/** Default "Back to Login". */
|
|
32
|
+
backToLogin?: string;
|
|
33
|
+
}
|
|
2
34
|
export interface UnauthorizedPageProps {
|
|
3
35
|
expectedRole: string;
|
|
4
36
|
onNavigateLogin: () => void | Promise<void>;
|
|
5
37
|
authenticatedUserType?: string | null;
|
|
6
38
|
dashboardLinks?: DashboardLink[];
|
|
39
|
+
/** Optional label overrides; each omitted field uses its English default. */
|
|
40
|
+
labels?: UnauthorizedPageLabels;
|
|
7
41
|
}
|
|
8
|
-
export declare function UnauthorizedPage({ expectedRole, onNavigateLogin, authenticatedUserType, dashboardLinks, }: UnauthorizedPageProps): import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
export declare function UnauthorizedPage({ expectedRole, onNavigateLogin, authenticatedUserType, dashboardLinks, labels, }: UnauthorizedPageProps): import("react/jsx-runtime").JSX.Element;
|
|
9
43
|
//# sourceMappingURL=unauthorized.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../src/react/unauthorized.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../src/react/unauthorized.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,SAAS,CAAC;IACnC;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,SAAS,CAAC;IACjD,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,uBAAuB,CAAC,EAAE,SAAS,CAAC;IACpC,+BAA+B;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,qBAAqB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,cAAc,CAAC,EAAE,aAAa,EAAE,CAAC;IACjC,6EAA6E;IAC7E,MAAM,CAAC,EAAE,sBAAsB,CAAC;CACjC;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,MAAM,GACP,EAAE,qBAAqB,2CA2EvB"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ShieldX, ArrowLeftRight, ExternalLink } from "lucide-react";
|
|
4
|
-
export function UnauthorizedPage({ expectedRole, onNavigateLogin, authenticatedUserType, dashboardLinks, }) {
|
|
4
|
+
export function UnauthorizedPage({ expectedRole, onNavigateLogin, authenticatedUserType, dashboardLinks, labels, }) {
|
|
5
5
|
const matchingLink = authenticatedUserType && dashboardLinks
|
|
6
6
|
? dashboardLinks.find((l) => l.userType === authenticatedUserType)
|
|
7
7
|
: undefined;
|
|
8
8
|
// Portal-aware view: user is authenticated but on the wrong dashboard
|
|
9
9
|
if (matchingLink) {
|
|
10
|
-
return (_jsx("div", { className: "flex min-h-dvh items-center justify-center p-4", children: _jsxs("div", { className: "mx-auto w-full max-w-md rounded-xl border border-border bg-card p-8 text-center shadow-sm", children: [_jsx("div", { className: "mx-auto mb-4 flex size-12 items-center justify-center rounded-full bg-amber-500/10", children: _jsx(ArrowLeftRight, { className: "size-6 text-amber-600" }) }), _jsx("h1", { className: "text-2xl font-semibold", children: "Wrong Portal" }),
|
|
10
|
+
return (_jsx("div", { className: "flex min-h-dvh items-center justify-center p-4", children: _jsxs("div", { className: "mx-auto w-full max-w-md rounded-xl border border-border bg-card p-8 text-center shadow-sm", children: [_jsx("div", { className: "mx-auto mb-4 flex size-12 items-center justify-center rounded-full bg-amber-500/10", children: _jsx(ArrowLeftRight, { className: "size-6 text-amber-600" }) }), _jsx("h1", { className: "text-2xl font-semibold", children: labels?.wrongPortalTitle ?? "Wrong Portal" }), _jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: labels?.wrongPortalDescription ?? (_jsxs(_Fragment, { children: ["You're signed in as a", " ", _jsx("span", { className: "font-medium text-foreground", children: authenticatedUserType }), ". This dashboard is for ", expectedRole, "."] })) }), _jsxs("a", { href: matchingLink.url, className: "mt-6 inline-flex h-10 w-full items-center justify-center gap-2 rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground shadow-xs hover:bg-primary/90 transition-colors", children: [labels?.goToDashboard
|
|
11
|
+
? labels.goToDashboard(matchingLink.label)
|
|
12
|
+
: `Go to ${matchingLink.label}`, _jsx(ExternalLink, { className: "size-4" })] }), _jsx("button", { onClick: onNavigateLogin, className: "mt-3 text-sm text-primary transition-colors hover:text-primary/80", children: labels?.switchAccount ?? "Sign in with a different account" })] }) }));
|
|
11
13
|
}
|
|
12
14
|
// Fallback: generic access denied (backward compat + admin userType + no props)
|
|
13
|
-
return (_jsx("div", { className: "flex min-h-dvh items-center justify-center p-4", children: _jsxs("div", { className: "mx-auto w-full max-w-md rounded-xl border border-border bg-card p-8 text-center shadow-sm", children: [_jsx("div", { className: "mx-auto mb-4 flex size-12 items-center justify-center rounded-full bg-destructive/10", children: _jsx(ShieldX, { className: "size-6 text-destructive" }) }), _jsx("h1", { className: "text-2xl font-semibold", children: "Access Denied" }),
|
|
15
|
+
return (_jsx("div", { className: "flex min-h-dvh items-center justify-center p-4", children: _jsxs("div", { className: "mx-auto w-full max-w-md rounded-xl border border-border bg-card p-8 text-center shadow-sm", children: [_jsx("div", { className: "mx-auto mb-4 flex size-12 items-center justify-center rounded-full bg-destructive/10", children: _jsx(ShieldX, { className: "size-6 text-destructive" }) }), _jsx("h1", { className: "text-2xl font-semibold", children: labels?.accessDeniedTitle ?? "Access Denied" }), _jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: labels?.accessDeniedDescription ?? (_jsxs(_Fragment, { children: ["This dashboard is for ", expectedRole, " only. If you believe this is an error, please contact support."] })) }), _jsx("button", { onClick: onNavigateLogin, className: "mt-6 inline-flex h-10 w-full items-center justify-center rounded-md bg-primary px-4 text-sm font-medium text-primary-foreground shadow-xs hover:bg-primary/90 transition-colors", children: labels?.backToLogin ?? "Back to Login" })] }) }));
|
|
14
16
|
}
|
|
15
17
|
//# sourceMappingURL=unauthorized.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauthorized.js","sourceRoot":"","sources":["../../src/react/unauthorized.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"unauthorized.js","sourceRoot":"","sources":["../../src/react/unauthorized.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AA6CrE,MAAM,UAAU,gBAAgB,CAAC,EAC/B,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,cAAc,EACd,MAAM,GACgB;IACtB,MAAM,YAAY,GAChB,qBAAqB,IAAI,cAAc;QACrC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,qBAAqB,CAAC;QAClE,CAAC,CAAC,SAAS,CAAC;IAEhB,sEAAsE;IACtE,IAAI,YAAY,EAAE,CAAC;QACjB,OAAO,CACL,cAAK,SAAS,EAAC,gDAAgD,YAC7D,eAAK,SAAS,EAAC,2FAA2F,aACxG,cAAK,SAAS,EAAC,oFAAoF,YACjG,KAAC,cAAc,IAAC,SAAS,EAAC,uBAAuB,GAAG,GAChD,EACN,aAAI,SAAS,EAAC,wBAAwB,YACnC,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