lemma-sdk 0.2.42 → 0.2.43
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/README.md +1 -1
- package/dist/react/AuthGuard.d.ts +2 -1
- package/dist/react/AuthGuard.js +7 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -444,7 +444,7 @@ Useful helpers:
|
|
|
444
444
|
- `setTestingToken(...)`
|
|
445
445
|
- `clearTestingToken()`
|
|
446
446
|
|
|
447
|
-
When `client.podId` is set and the signed-in user is not a pod member, `AuthGuard` checks membership through the pod-member lookup endpoint and renders an interactive request-access flow. It can create a pod join request, show a pending request, retry access checks, and then render the app once the user is a member.
|
|
447
|
+
When `client.podId` is set and the signed-in user is not a pod member, `AuthGuard` checks membership through the pod-member lookup endpoint and renders an interactive request-access flow. Pass `appName` to label the default auth screens with your app's name. It can create a pod join request, show a pending request, retry access checks, and then render the app once the user is a member.
|
|
448
448
|
|
|
449
449
|
`usePodAccess` exposes the same membership/request-access state as a hook for custom UI.
|
|
450
450
|
|
|
@@ -3,8 +3,9 @@ import type { LemmaClient } from "../client.js";
|
|
|
3
3
|
export interface AuthGuardProps {
|
|
4
4
|
client: LemmaClient;
|
|
5
5
|
children: ReactNode;
|
|
6
|
+
appName?: string;
|
|
6
7
|
loadingFallback?: ReactNode;
|
|
7
8
|
unauthenticatedFallback?: ReactNode;
|
|
8
9
|
accessRequestFallback?: ReactNode;
|
|
9
10
|
}
|
|
10
|
-
export declare function AuthGuard({ client, children, loadingFallback, unauthenticatedFallback, accessRequestFallback, }: AuthGuardProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare function AuthGuard({ client, children, appName, loadingFallback, unauthenticatedFallback, accessRequestFallback, }: AuthGuardProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/react/AuthGuard.js
CHANGED
|
@@ -88,10 +88,10 @@ function StatusPill({ status }) {
|
|
|
88
88
|
marginBottom: "16px",
|
|
89
89
|
}, children: label }));
|
|
90
90
|
}
|
|
91
|
-
function DefaultSignInPage({ onSignIn }) {
|
|
92
|
-
return (_jsx("div", { style: pageStyle, children: _jsxs("div", { style: panelStyle, children: [_jsx("p", { style: eyebrowStyle, children:
|
|
91
|
+
function DefaultSignInPage({ appName, onSignIn, }) {
|
|
92
|
+
return (_jsx("div", { style: pageStyle, children: _jsxs("div", { style: panelStyle, children: [_jsx("p", { style: eyebrowStyle, children: appName }), _jsx("h1", { style: titleStyle, children: "Sign in to continue" }), _jsx("p", { style: bodyStyle, children: "Sign in with Lemma to open this workspace." }), _jsx("div", { style: buttonRowStyle, children: _jsx("button", { onClick: onSignIn, style: buttonStyle("primary"), children: "Sign in" }) })] }) }));
|
|
93
93
|
}
|
|
94
|
-
function DefaultRequestAccessPage({ status, isSubmitting, signedInAs, error, onRequestAccess, onRetry, }) {
|
|
94
|
+
function DefaultRequestAccessPage({ appName, status, isSubmitting, signedInAs, error, onRequestAccess, onRetry, }) {
|
|
95
95
|
const isPending = status === "pending";
|
|
96
96
|
const isError = status === "error";
|
|
97
97
|
const title = isPending
|
|
@@ -102,7 +102,7 @@ function DefaultRequestAccessPage({ status, isSubmitting, signedInAs, error, onR
|
|
|
102
102
|
const message = isPending
|
|
103
103
|
? "An admin can approve your request from pod settings. You can refresh this screen after they add you."
|
|
104
104
|
: "You are signed in, but this pod is gated to members. Send an access request and an admin can let you in.";
|
|
105
|
-
return (_jsx("div", { style: pageStyle, children: _jsxs("div", { style: panelStyle, children: [_jsx(StatusPill, { status: status }), _jsx("h1", { style: titleStyle, children: title }), _jsx("p", { style: bodyStyle, children: message }), signedInAs ? (_jsxs("p", { style: {
|
|
105
|
+
return (_jsx("div", { style: pageStyle, children: _jsxs("div", { style: panelStyle, children: [_jsx("p", { style: eyebrowStyle, children: appName }), _jsx(StatusPill, { status: status }), _jsx("h1", { style: titleStyle, children: title }), _jsx("p", { style: bodyStyle, children: message }), signedInAs ? (_jsxs("p", { style: {
|
|
106
106
|
margin: "18px 0 0",
|
|
107
107
|
borderRadius: "10px",
|
|
108
108
|
backgroundColor: "#f5f7fb",
|
|
@@ -111,7 +111,7 @@ function DefaultRequestAccessPage({ status, isSubmitting, signedInAs, error, onR
|
|
|
111
111
|
fontSize: "13px",
|
|
112
112
|
}, children: ["Signed in as ", _jsx("strong", { style: { color: "#172033" }, children: signedInAs })] })) : null, error ? (_jsx("p", { style: { margin: "14px 0 0", color: "#b42318", fontSize: "13px", lineHeight: 1.45 }, children: error.message })) : null, _jsxs("div", { style: buttonRowStyle, children: [_jsx("button", { onClick: onRequestAccess, disabled: isSubmitting || isPending, style: buttonStyle("primary", isSubmitting || isPending), children: isSubmitting ? "Sending..." : isPending ? "Request sent" : "Request access" }), _jsx("button", { onClick: onRetry, style: buttonStyle("secondary"), children: isError ? "Try again" : "Refresh" })] })] }) }));
|
|
113
113
|
}
|
|
114
|
-
export function AuthGuard({ client, children, loadingFallback = null, unauthenticatedFallback, accessRequestFallback, }) {
|
|
114
|
+
export function AuthGuard({ client, children, appName = "App", loadingFallback = null, unauthenticatedFallback, accessRequestFallback, }) {
|
|
115
115
|
const { isLoading, isAuthenticated, redirectToAuth } = useAuth(client);
|
|
116
116
|
const hasPodScope = Boolean(client.podId);
|
|
117
117
|
const podAccess = usePodAccess({
|
|
@@ -132,7 +132,7 @@ export function AuthGuard({ client, children, loadingFallback = null, unauthenti
|
|
|
132
132
|
if (unauthenticatedFallback !== undefined) {
|
|
133
133
|
return _jsx(_Fragment, { children: unauthenticatedFallback });
|
|
134
134
|
}
|
|
135
|
-
return _jsx(DefaultSignInPage, { onSignIn: redirectToAuth });
|
|
135
|
+
return _jsx(DefaultSignInPage, { appName: appName, onSignIn: redirectToAuth });
|
|
136
136
|
}
|
|
137
137
|
if (!hasPodScope || podAccess.hasAccess) {
|
|
138
138
|
return _jsx(_Fragment, { children: children });
|
|
@@ -142,5 +142,5 @@ export function AuthGuard({ client, children, loadingFallback = null, unauthenti
|
|
|
142
142
|
}
|
|
143
143
|
const fullName = [podAccess.user?.first_name, podAccess.user?.last_name].filter(Boolean).join(" ");
|
|
144
144
|
const signedInAs = podAccess.user?.email ?? (fullName.length > 0 ? fullName : podAccess.user?.id ?? null);
|
|
145
|
-
return (_jsx(DefaultRequestAccessPage, { status: podAccess.status, isSubmitting: podAccess.isRequestingAccess, signedInAs: signedInAs, error: podAccess.error, onRequestAccess: handleRequestAccess, onRetry: handleRetry }));
|
|
145
|
+
return (_jsx(DefaultRequestAccessPage, { appName: appName, status: podAccess.status, isSubmitting: podAccess.isRequestingAccess, signedInAs: signedInAs, error: podAccess.error, onRequestAccess: handleRequestAccess, onRetry: handleRetry }));
|
|
146
146
|
}
|