@krak-stack/auth 0.1.46 → 0.1.48
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/admin/api.group.d.ts +121 -3
- package/dist/admin/api.group.js +84 -1
- package/dist/admin/schema.d.ts +30 -0
- package/dist/admin/schema.js +70 -0
- package/dist/api.d.ts +143 -5
- package/dist/components/admin-organization-form.js +0 -1
- package/dist/components/admin-organizations.js +0 -1
- package/dist/components/admin-required.d.ts +43 -0
- package/dist/components/admin-required.js +183 -0
- package/dist/components/admin-users.js +0 -1
- package/dist/components/auth-client-api.d.ts +132 -4
- package/dist/components/auth-client.d.ts +24 -55
- package/dist/components/auth-client.js +23 -12
- package/dist/components/auth-forms.js +15 -12
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +1 -0
- package/dist/components/organization-switcher.d.ts +4 -0
- package/dist/components/organization-switcher.js +69 -26
- package/dist/extra/api.group.d.ts +11 -1
- package/dist/extra/api.group.js +10 -1
- package/dist/extra/schema.d.ts +14 -0
- package/dist/extra/schema.js +32 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/server/proxy.js +1 -13
- package/dist/service.d.ts +28 -0
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
// @ts-nocheck
|
|
3
2
|
import { useAtomSuspense } from "@effect/atom-react";
|
|
4
3
|
import { Link, useNavigate, useRouterState } from "@tanstack/react-router";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
5
|
import { Atom, AsyncResult } from "effect/unstable/reactivity";
|
|
6
6
|
import { REGEXP_ONLY_DIGITS } from "input-otp";
|
|
7
7
|
import { KeyRound, Mail } from "lucide-react";
|
|
@@ -14,6 +14,7 @@ import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, } from "@/com
|
|
|
14
14
|
import { authClientApi } from "./auth-client-api";
|
|
15
15
|
import { useKrakstackAuth } from "./auth-provider";
|
|
16
16
|
import { cn } from "./utils";
|
|
17
|
+
import { ExtraProjectPublicConfig as ExtraProjectPublicConfigSchema, } from "../extra/schema";
|
|
17
18
|
const EMAIL_OTP_RESEND_COOLDOWN_SECONDS = 60;
|
|
18
19
|
const defaultMessages = {
|
|
19
20
|
en: {
|
|
@@ -157,7 +158,9 @@ const useAuthProjectConfig = (baseUrl, searchString, projectConfig) => {
|
|
|
157
158
|
})
|
|
158
159
|
: Atom.make(AsyncResult.success(projectConfig));
|
|
159
160
|
const result = useAtomSuspense(atom, { suspendOnWaiting: true });
|
|
160
|
-
return result.value
|
|
161
|
+
return result.value === null
|
|
162
|
+
? null
|
|
163
|
+
: Schema.decodeUnknownSync(ExtraProjectPublicConfigSchema)(result.value);
|
|
161
164
|
};
|
|
162
165
|
const text = (value, params) => Object.entries(params ?? {}).reduce((current, [key, replacement]) => current.replace(`{${key}}`, replacement), value);
|
|
163
166
|
const authLinkClassName = cn(buttonVariants({ variant: "link" }), "h-auto px-0 align-baseline");
|
|
@@ -173,14 +176,14 @@ export function Signin(props) {
|
|
|
173
176
|
const redirectTarget = getRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
|
|
174
177
|
const socialRedirectTarget = getSocialRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
|
|
175
178
|
const oauthQuery = getOAuthQuery(searchString);
|
|
176
|
-
const authOptions = projectConfig?.authOptions
|
|
179
|
+
const authOptions = projectConfig?.authOptions;
|
|
177
180
|
const onNavigate = (target) => navigateTarget(target, navigate);
|
|
178
181
|
const onTwoFactorRedirect = (href) => navigate({ href });
|
|
179
182
|
const options = {
|
|
180
|
-
emailPassword: authOptions
|
|
181
|
-
emailOtp: authOptions
|
|
182
|
-
google: authOptions
|
|
183
|
-
signUp: authOptions
|
|
183
|
+
emailPassword: authOptions?.emailPassword ?? true,
|
|
184
|
+
emailOtp: authOptions?.emailOtp ?? true,
|
|
185
|
+
google: authOptions?.google ?? true,
|
|
186
|
+
signUp: authOptions?.signUp ?? true,
|
|
184
187
|
};
|
|
185
188
|
const [emailSubmitted, setEmailSubmitted] = useState(false);
|
|
186
189
|
const [authMethod, setAuthMethod] = useState(() => lastLoginMethodToAuthMethod(authClient.getLastUsedLoginMethod?.()));
|
|
@@ -373,13 +376,13 @@ export function Signup(props) {
|
|
|
373
376
|
});
|
|
374
377
|
const projectConfig = useAuthProjectConfig(baseUrl, searchString, providedProjectConfig);
|
|
375
378
|
const redirectTarget = getRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
|
|
376
|
-
const authOptions = projectConfig?.authOptions
|
|
379
|
+
const authOptions = projectConfig?.authOptions;
|
|
377
380
|
const onNavigate = (target) => navigate({ href: target });
|
|
378
381
|
const onVerifyEmail = (email) => navigate({ to: "/verify-email", search: { email } });
|
|
379
382
|
const options = {
|
|
380
|
-
google: authOptions
|
|
381
|
-
signUp: authOptions
|
|
382
|
-
signUpName: authOptions
|
|
383
|
+
google: authOptions?.google ?? true,
|
|
384
|
+
signUp: authOptions?.signUp ?? true,
|
|
385
|
+
signUpName: authOptions?.signUpName ?? true,
|
|
383
386
|
};
|
|
384
387
|
const form = useAppForm({
|
|
385
388
|
defaultValues: { name: "", email: "", password: "" },
|
|
@@ -566,7 +569,7 @@ export function TwoFactor(props) {
|
|
|
566
569
|
}
|
|
567
570
|
const OtpInput = ({ field, label }) => {
|
|
568
571
|
const invalid = !field.state.meta.isValid;
|
|
569
|
-
return (_jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: field.name, children: label }), _jsxs(InputOTP, { id: field.name, name: field.name, maxLength: 6, value: field.state.value ?? "", onChange: (value) => field.handleChange(value), onBlur: field.handleBlur, autoComplete: "one-time-code", inputMode: "numeric", pattern: REGEXP_ONLY_DIGITS, required: true, children: [_jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 0, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 1, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 2, "aria-invalid": invalid })] }), _jsx(InputOTPSeparator, {}), _jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 3, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 4, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 5, "aria-invalid": invalid })] })] }), _jsx(FieldError, { errors: field.getMeta().errors })] }));
|
|
572
|
+
return (_jsxs(Field, { "data-invalid": invalid, children: [_jsx(FieldLabel, { htmlFor: field.name, children: label }), _jsxs(InputOTP, { id: field.name, name: field.name, maxLength: 6, value: field.state.value ?? "", onChange: (value) => field.handleChange(value), onBlur: field.handleBlur, autoComplete: "one-time-code", inputMode: "numeric", pattern: REGEXP_ONLY_DIGITS, required: true, children: [_jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 0, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 1, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 2, "aria-invalid": invalid })] }), _jsx(InputOTPSeparator, {}), _jsxs(InputOTPGroup, { children: [_jsx(InputOTPSlot, { index: 3, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 4, "aria-invalid": invalid }), _jsx(InputOTPSlot, { index: 5, "aria-invalid": invalid })] })] }), _jsx(FieldError, { errors: field.getMeta().errors ?? [] })] }));
|
|
570
573
|
};
|
|
571
574
|
const Divider = ({ label }) => (_jsxs("div", { className: "text-muted-foreground flex items-center gap-3 text-xs", children: [_jsx("span", { className: "bg-border h-px flex-1" }), label, _jsx("span", { className: "bg-border h-px flex-1" })] }));
|
|
572
575
|
const GoogleLogo = () => (_jsxs("svg", { "aria-hidden": "true", className: "size-[18px]", viewBox: "0 0 18 18", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M17.64 9.204c0-.638-.057-1.252-.164-1.84H9v3.481h4.844a4.14 4.14 0 0 1-1.796 2.716v2.259h2.908c1.702-1.567 2.684-3.874 2.684-6.616Z", fill: "#4285F4" }), _jsx("path", { d: "M9 18c2.43 0 4.467-.806 5.956-2.18l-2.908-2.259c-.806.54-1.837.86-3.048.86-2.344 0-4.328-1.583-5.036-3.711H.957v2.332A8.997 8.997 0 0 0 9 18Z", fill: "#34A853" }), _jsx("path", { d: "M3.964 10.71A5.41 5.41 0 0 1 3.682 9c0-.593.102-1.17.282-1.71V4.958H.957A8.996 8.996 0 0 0 0 9c0 1.452.348 2.827.957 4.042l3.007-2.332Z", fill: "#FBBC05" }), _jsx("path", { d: "M9 3.58c1.321 0 2.508.454 3.44 1.346l2.582-2.58C13.463.891 11.426 0 9 0A8.997 8.997 0 0 0 .957 4.958L3.964 7.29C4.672 5.162 6.656 3.58 9 3.58Z", fill: "#EA4335" })] }));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAuthProjectConfig, } from "./auth-provider";
|
|
2
2
|
export { createAuthUiClient } from "./auth-client";
|
|
3
3
|
export { OrganizationSwitcher } from "./organization-switcher";
|
|
4
|
+
export { AdminRequired } from "./admin-required";
|
|
4
5
|
export { ResetPassword, Signin, Signup, TwoFactor } from "./auth-forms";
|
|
5
6
|
export { UserButton } from "./user-button";
|
|
6
7
|
export { AdminOrganizationsTable } from "./admin-organizations";
|
|
@@ -11,3 +12,4 @@ export type { KrakstackAuthContextValue, KrakstackAuthLocale, KrakstackAuthProvi
|
|
|
11
12
|
export type { OrganizationSwitcherDialog, OrganizationSwitcherProps, } from "./organization-switcher";
|
|
12
13
|
export type { UserButtonDialog } from "./user-button";
|
|
13
14
|
export type { AuthUiClient } from "./auth-client";
|
|
15
|
+
export type { AdminRequiredMessages, AdminRequiredProps } from "./admin-required";
|
package/dist/components/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAuthProjectConfig, } from "./auth-provider";
|
|
2
2
|
export { createAuthUiClient } from "./auth-client";
|
|
3
3
|
export { OrganizationSwitcher } from "./organization-switcher";
|
|
4
|
+
export { AdminRequired } from "./admin-required";
|
|
4
5
|
export { ResetPassword, Signin, Signup, TwoFactor } from "./auth-forms";
|
|
5
6
|
export { UserButton } from "./user-button";
|
|
6
7
|
export { AdminOrganizationsTable } from "./admin-organizations";
|
|
@@ -39,6 +39,8 @@ declare const messages: {
|
|
|
39
39
|
readonly organization_logo_upload_error: "Could not upload the organization logo.";
|
|
40
40
|
readonly organization_member_email: "Email";
|
|
41
41
|
readonly organization_member_joined: "Joined";
|
|
42
|
+
readonly organization_member_leave: "Leave organization";
|
|
43
|
+
readonly organization_member_leave_error: "Could not leave the organization.";
|
|
42
44
|
readonly organization_member_remove: "Remove member";
|
|
43
45
|
readonly organization_member_remove_error: "Could not remove the member.";
|
|
44
46
|
readonly organization_member_role: "Role";
|
|
@@ -119,6 +121,8 @@ declare const messages: {
|
|
|
119
121
|
readonly organization_logo_upload_error: "Impossible de téléverser le logo de l'organisation.";
|
|
120
122
|
readonly organization_member_email: "Courriel";
|
|
121
123
|
readonly organization_member_joined: "Arrivée";
|
|
124
|
+
readonly organization_member_leave: "Quitter l'organisation";
|
|
125
|
+
readonly organization_member_leave_error: "Impossible de quitter l'organisation.";
|
|
122
126
|
readonly organization_member_remove: "Retirer le membre";
|
|
123
127
|
readonly organization_member_remove_error: "Impossible de retirer le membre.";
|
|
124
128
|
readonly organization_member_role: "Rôle";
|
|
@@ -4,7 +4,7 @@ import { useStore } from "@tanstack/react-form";
|
|
|
4
4
|
import {} from "@tanstack/react-table";
|
|
5
5
|
import { Effect, Schema } from "effect";
|
|
6
6
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
7
|
-
import { Building2, Check, ChevronsUpDown, Copy, KeyRound, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
7
|
+
import { Building2, Check, ChevronsUpDown, Copy, KeyRound, LogOut, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
8
8
|
import { createContext, useContext, useEffect, useEffectEvent, useRef, useState, } from "react";
|
|
9
9
|
import { DataTable, DataTableRelationshipCell, } from "@/components/ui/data-table";
|
|
10
10
|
import { EditingLocaleSwitcher } from "@/components/ui/editing-locale-switcher";
|
|
@@ -61,6 +61,8 @@ const messages = {
|
|
|
61
61
|
organization_logo_upload_error: "Could not upload the organization logo.",
|
|
62
62
|
organization_member_email: "Email",
|
|
63
63
|
organization_member_joined: "Joined",
|
|
64
|
+
organization_member_leave: "Leave organization",
|
|
65
|
+
organization_member_leave_error: "Could not leave the organization.",
|
|
64
66
|
organization_member_remove: "Remove member",
|
|
65
67
|
organization_member_remove_error: "Could not remove the member.",
|
|
66
68
|
organization_member_role: "Role",
|
|
@@ -141,6 +143,8 @@ const messages = {
|
|
|
141
143
|
organization_logo_upload_error: "Impossible de téléverser le logo de l'organisation.",
|
|
142
144
|
organization_member_email: "Courriel",
|
|
143
145
|
organization_member_joined: "Arrivée",
|
|
146
|
+
organization_member_leave: "Quitter l'organisation",
|
|
147
|
+
organization_member_leave_error: "Impossible de quitter l'organisation.",
|
|
144
148
|
organization_member_remove: "Retirer le membre",
|
|
145
149
|
organization_member_remove_error: "Impossible de retirer le membre.",
|
|
146
150
|
organization_member_role: "Rôle",
|
|
@@ -204,6 +208,10 @@ const organizationMessageFns = (labels) => new Proxy({}, {
|
|
|
204
208
|
});
|
|
205
209
|
const OrganizationMessagesContext = createContext(organizationMessageFns(organizationSwitcherMessages()));
|
|
206
210
|
const useOrganizationMessages = () => useContext(OrganizationMessagesContext);
|
|
211
|
+
const normalizeInvitationRole = (role) => {
|
|
212
|
+
const normalized = normalizeOrganizationRole(role);
|
|
213
|
+
return normalized === "support" ? "member" : normalized;
|
|
214
|
+
};
|
|
207
215
|
const userInvitationsAtom = Atom.family((authClient) => Atom.keepAlive(Atom.make(Effect.tryPromise({
|
|
208
216
|
try: async () => {
|
|
209
217
|
const result = await authClient.organization.listUserInvitations({});
|
|
@@ -215,7 +223,10 @@ const userInvitationsAtom = Atom.family((authClient) => Atom.keepAlive(Atom.make
|
|
|
215
223
|
},
|
|
216
224
|
catch: (error) => error,
|
|
217
225
|
}))));
|
|
218
|
-
const emptyUserInvitationsAtom = Atom.make(Effect.
|
|
226
|
+
const emptyUserInvitationsAtom = Atom.make(Effect.try({
|
|
227
|
+
try: () => [],
|
|
228
|
+
catch: (error) => error,
|
|
229
|
+
}));
|
|
219
230
|
const organizationMembersAtom = Atom.family((authClient) => Atom.family((organizationId) => Atom.keepAlive(Atom.make(Effect.tryPromise({
|
|
220
231
|
try: async () => {
|
|
221
232
|
const [membersResult, invitationsResult] = await Promise.all([
|
|
@@ -413,6 +424,7 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
413
424
|
const loadingUserInvitations = invitationsResult._tag === "Initial";
|
|
414
425
|
const activeMemberRole = normalizeOrganizationRole(activeOrganization.data?.members.find((member) => member.userId === session.data?.user.id)?.role);
|
|
415
426
|
const canManageApiKeys = activeMemberRole === "owner" || activeMemberRole === "admin";
|
|
427
|
+
const canUpdateOrganization = canManageApiKeys;
|
|
416
428
|
const setDialog = (next) => {
|
|
417
429
|
const nextDialog = typeof next === "function" ? next(dialog) : next;
|
|
418
430
|
if (nextDialog === dialog)
|
|
@@ -481,9 +493,12 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
481
493
|
? m.organization_switcher_no_other_organizations()
|
|
482
494
|
: m.organization_switcher_empty() })) : null, !locked ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { onClick: openCreate, children: [_jsx(Plus, {}), m.organization_create_title()] }), _jsxs(DropdownMenuItem, { onClick: () => {
|
|
483
495
|
setDialog("invitations");
|
|
484
|
-
}, children: [_jsx(Mail, {}), _jsxs("span", { className: "flex flex-1 items-center justify-between gap-3", children: [m.organization_user_invitations_title(), userInvitations.length ? (_jsx(Badge, { variant: "secondary", children: userInvitations.length })) : null] })] })] })) : null, activeOrganization.data ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}),
|
|
485
|
-
|
|
486
|
-
|
|
496
|
+
}, children: [_jsx(Mail, {}), _jsxs("span", { className: "flex flex-1 items-center justify-between gap-3", children: [m.organization_user_invitations_title(), userInvitations.length ? (_jsx(Badge, { variant: "secondary", children: userInvitations.length })) : null] })] })] })) : null, activeOrganization.data ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), (() => {
|
|
497
|
+
const organizationId = activeOrganization.data.id;
|
|
498
|
+
return (_jsxs(DropdownMenuItem, { onClick: () => {
|
|
499
|
+
void navigator.clipboard.writeText(organizationId);
|
|
500
|
+
}, children: [_jsx(Copy, {}), m.organization_copy_id()] }));
|
|
501
|
+
})(), canUpdateOrganization ? (_jsxs(DropdownMenuItem, { onClick: () => setDialog("manage"), children: [_jsx(PencilIcon, {}), m.organization_switcher_manage()] })) : null, _jsxs(DropdownMenuItem, { onClick: () => setDialog("members"), children: [_jsx(Users, {}), m.organization_members_title()] }), canManageApiKeys ? (_jsxs(DropdownMenuItem, { onClick: () => setDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] })) : null] })) : null] }) })] })), _jsx(Dialog, { open: dialog === "create", onOpenChange: (open) => {
|
|
487
502
|
setDialog((current) => open ? "create" : current === "create" ? null : current);
|
|
488
503
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_create_title() }), _jsx(DialogDescription, { children: m.organization_create_description() })] }), _jsx(Separator, {}), _jsx(CreateOrganizationSection, { authClient: authClient, baseUrl: baseUrl, onCreated: async (organization) => {
|
|
489
504
|
setDialog(null);
|
|
@@ -495,15 +510,22 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
495
510
|
onCreate?.(organization);
|
|
496
511
|
onChange?.(organization);
|
|
497
512
|
}
|
|
498
|
-
} })] }) }), _jsx(Dialog, { open: dialog === "manage", onOpenChange: (open) => {
|
|
513
|
+
} })] }) }), _jsx(Dialog, { open: dialog === "manage" && canUpdateOrganization, onOpenChange: (open) => {
|
|
499
514
|
setDialog((current) => open ? "manage" : current === "manage" ? null : current);
|
|
500
|
-
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(EditOrganizationSection, { authClient: authClient, baseUrl: baseUrl, organization: activeOrganization.data, onUpdated: refresh })) : null] }) }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
|
|
515
|
+
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_switcher_manage() }), _jsx(DialogDescription, { children: m.organization_edit_description() })] }), _jsx(Separator, {}), activeOrganization.data && canUpdateOrganization ? (_jsx(EditOrganizationSection, { authClient: authClient, baseUrl: baseUrl, organization: activeOrganization.data, onUpdated: refresh })) : null] }) }), _jsx(Dialog, { open: dialog === "members", onOpenChange: (open) => {
|
|
501
516
|
setDialog((current) => open ? "members" : current === "members" ? null : current);
|
|
502
|
-
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_members_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationMembersManager, { authClient: authClient, baseUrl: baseUrl, organization: activeOrganization.data, currentUserId: session.data.user.id, active: dialog === "members"
|
|
517
|
+
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_members_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationMembersManager, { authClient: authClient, baseUrl: baseUrl, organization: activeOrganization.data, currentUserId: session.data.user.id, active: dialog === "members", onLeft: async () => {
|
|
518
|
+
setDialog(null);
|
|
519
|
+
auth?.refreshAuth();
|
|
520
|
+
await refresh();
|
|
521
|
+
onChange?.(null);
|
|
522
|
+
} })) : null] }) }), _jsx(Dialog, { open: dialog === "apiKeys" && canManageApiKeys, onOpenChange: (open) => {
|
|
503
523
|
setDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
504
524
|
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-3xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.user_api_keys_title() }), _jsx(DialogDescription, { children: activeOrganization.data?.name })] }), _jsx(Separator, {}), activeOrganization.data ? (_jsx(OrganizationApiKeyManager, { authClient: authClient, organization: activeOrganization.data, active: dialog === "apiKeys" && canManageApiKeys })) : null] }) }), _jsx(Dialog, { open: dialog === "invitations" && !locked, onOpenChange: (open) => {
|
|
505
525
|
setDialog((current) => open ? "invitations" : current === "invitations" ? null : current);
|
|
506
|
-
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_user_invitations_title() }), _jsx(DialogDescription, { children: m.organization_user_invitations_description() })] }), _jsx(Separator, {}), _jsx(UserInvitationsManager, { authClient: authClient, invitations: userInvitations, loading: loadingUserInvitations, error: userInvitationsError,
|
|
526
|
+
}, children: _jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto sm:max-w-4xl", children: [_jsxs(DialogHeader, { children: [_jsx(DialogTitle, { className: "text-2xl", children: m.organization_user_invitations_title() }), _jsx(DialogDescription, { children: m.organization_user_invitations_description() })] }), _jsx(Separator, {}), _jsx(UserInvitationsManager, { authClient: authClient, invitations: userInvitations, loading: loadingUserInvitations, error: userInvitationsError, ...(activeOrganization.data
|
|
527
|
+
? { activeOrganizationId: activeOrganization.data.id }
|
|
528
|
+
: {}), onActionComplete: refreshAfterInvitationAction })] }) })] }));
|
|
507
529
|
}
|
|
508
530
|
function UserInvitationsManager({ authClient, invitations, loading, error, activeOrganizationId, onActionComplete, }) {
|
|
509
531
|
const m = useOrganizationMessages();
|
|
@@ -647,16 +669,6 @@ function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated,
|
|
|
647
669
|
suggestedHeight: 512,
|
|
648
670
|
} })) }), _jsx(form.AppField, { name: "frContactEmail", children: (field) => (_jsx(field.TextField, { label: m.organization_contact_email(), placeholder: "team@example.com", type: "email" })) }), _jsx(form.AppField, { name: "frLocation", children: (field) => (_jsx(field.TextField, { label: m.organization_location() })) })] })), _jsx(form.FormError, {}), _jsx(form.SubmitButton, {})] }) }) }));
|
|
649
671
|
}
|
|
650
|
-
function CreateOrganizationSlugAutoFill({ form, }) {
|
|
651
|
-
const name = useStore(form.store, (state) => state.values.name);
|
|
652
|
-
const slugIsDirty = useStore(form.store, (state) => state.fieldMeta.slug?.isDirty ?? false);
|
|
653
|
-
useEffect(() => {
|
|
654
|
-
if (!slugIsDirty) {
|
|
655
|
-
form.setFieldValue("slug", slugify(name), { dontUpdateMeta: true });
|
|
656
|
-
}
|
|
657
|
-
}, [form, name, slugIsDirty]);
|
|
658
|
-
return null;
|
|
659
|
-
}
|
|
660
672
|
function CreateOrganizationSection({ authClient, baseUrl, onCreated, }) {
|
|
661
673
|
const m = useOrganizationMessages();
|
|
662
674
|
const uploadImage = useAtomSet(authClientApi(baseUrl).mutation("authExtra", "uploadUserImage"), { mode: "promise" });
|
|
@@ -713,11 +725,18 @@ function CreateOrganizationSection({ authClient, baseUrl, onCreated, }) {
|
|
|
713
725
|
}
|
|
714
726
|
},
|
|
715
727
|
});
|
|
728
|
+
const name = useStore(form.store, (state) => state.values.name);
|
|
729
|
+
const slugIsDirty = useStore(form.store, (state) => state.fieldMeta.slug?.isDirty ?? false);
|
|
730
|
+
useEffect(() => {
|
|
731
|
+
if (!slugIsDirty) {
|
|
732
|
+
form.setFieldValue("slug", slugify(name), { dontUpdateMeta: true });
|
|
733
|
+
}
|
|
734
|
+
}, [form, name, slugIsDirty]);
|
|
716
735
|
return (_jsx("section", { className: "flex flex-col gap-4", children: _jsx(form.AppForm, { children: _jsxs("form", { className: "flex max-w-xl flex-col gap-4", onSubmit: (event) => {
|
|
717
736
|
event.preventDefault();
|
|
718
737
|
event.stopPropagation();
|
|
719
738
|
form.handleSubmit();
|
|
720
|
-
}, children: [_jsx(form.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.organization_name(), required: true })) }), _jsx(form.AppField, { name: "slug", children: (field) => (_jsx(field.TextField, { label: m.organization_slug(), description: m.organization_slug_description() })) }), _jsx(
|
|
739
|
+
}, children: [_jsx(form.AppField, { name: "name", children: (field) => (_jsx(field.TextField, { label: m.organization_name(), required: true })) }), _jsx(form.AppField, { name: "slug", children: (field) => (_jsx(field.TextField, { label: m.organization_slug(), description: m.organization_slug_description() })) }), _jsx(Separator, { className: "my-2" }), editingLocale === "en" ? (_jsxs(_Fragment, { children: [_jsx(OrganizationTranslationHeader, { locale: "en", editingLocale: editingLocale, onEditingLocaleChange: setEditingLocale }), _jsx(form.AppField, { name: "enName", children: (field) => (_jsx(field.TextField, { label: m.organization_translation_name(), required: true })) }), _jsx(form.AppField, { name: "enLogo", children: (field) => (_jsx(field.ImageField, { label: m.organization_logo(), size: {
|
|
721
740
|
width: 175,
|
|
722
741
|
height: 50,
|
|
723
742
|
suggestedWidth: 350,
|
|
@@ -746,7 +765,7 @@ function OrganizationTranslationHeader({ locale, editingLocale, onEditingLocaleC
|
|
|
746
765
|
: m.organization_translation_french();
|
|
747
766
|
return (_jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: title }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_translation_description() })] }), _jsx(EditingLocaleSwitcher, { value: editingLocale, onValueChange: onEditingLocaleChange })] }));
|
|
748
767
|
}
|
|
749
|
-
function OrganizationMembersManager({ authClient, baseUrl, organization, currentUserId, active, }) {
|
|
768
|
+
function OrganizationMembersManager({ authClient, baseUrl, organization, currentUserId, active, onLeft, }) {
|
|
750
769
|
const m = useOrganizationMessages();
|
|
751
770
|
const hasOpened = useOpenedOnce(active);
|
|
752
771
|
const membersAtom = hasOpened
|
|
@@ -756,6 +775,7 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
756
775
|
const refreshMembers = useAtomRefresh(membersAtom);
|
|
757
776
|
const [error, setError] = useState(null);
|
|
758
777
|
const [cancellingInvitationId, setCancellingInvitationId] = useState(null);
|
|
778
|
+
const [leavingOrganization, setLeavingOrganization] = useState(false);
|
|
759
779
|
const membersData = AsyncResult.match(membersResult, {
|
|
760
780
|
onInitial: () => ({ members: [], invitations: [] }),
|
|
761
781
|
onFailure: () => ({ members: [], invitations: [] }),
|
|
@@ -779,6 +799,7 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
779
799
|
"owner",
|
|
780
800
|
"admin",
|
|
781
801
|
]);
|
|
802
|
+
const canInviteMembers = canChangeMemberRoles;
|
|
782
803
|
const canRemoveMembers = canChangeMemberRoles;
|
|
783
804
|
const inviteForm = useAppForm({
|
|
784
805
|
defaultValues: { email: "", role: "member" },
|
|
@@ -786,7 +807,7 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
786
807
|
formApi.setErrorMap({ onSubmit: undefined });
|
|
787
808
|
const result = await authClient.organization.inviteMember({
|
|
788
809
|
email: value.email.trim(),
|
|
789
|
-
role:
|
|
810
|
+
role: normalizeInvitationRole(value.role),
|
|
790
811
|
organizationId: organization.id,
|
|
791
812
|
});
|
|
792
813
|
if (result.error) {
|
|
@@ -836,6 +857,19 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
836
857
|
}
|
|
837
858
|
refreshMembers();
|
|
838
859
|
};
|
|
860
|
+
const leaveOrganization = async () => {
|
|
861
|
+
setLeavingOrganization(true);
|
|
862
|
+
setError(null);
|
|
863
|
+
const result = await authClient.organization.leave({
|
|
864
|
+
organizationId: organization.id,
|
|
865
|
+
});
|
|
866
|
+
setLeavingOrganization(false);
|
|
867
|
+
if (result.error) {
|
|
868
|
+
setError(result.error.message ?? m.organization_member_leave_error());
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
await onLeft();
|
|
872
|
+
};
|
|
839
873
|
const cancelInvitation = async (invitation) => {
|
|
840
874
|
setCancellingInvitationId(invitation.id);
|
|
841
875
|
setError(null);
|
|
@@ -849,14 +883,14 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
849
883
|
}
|
|
850
884
|
refreshMembers();
|
|
851
885
|
};
|
|
852
|
-
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-5", children: [_jsx(inviteForm.AppForm, { children: _jsxs("form", { className: "grid gap-4 rounded-lg border p-4 sm:grid-cols-[minmax(0,1fr)_12rem_auto] sm:items-end", onSubmit: (event) => {
|
|
886
|
+
return (_jsxs("div", { className: "flex min-w-0 flex-col gap-5", children: [canInviteMembers ? (_jsx(inviteForm.AppForm, { children: _jsxs("form", { className: "grid gap-4 rounded-lg border p-4 sm:grid-cols-[minmax(0,1fr)_12rem_auto] sm:items-end", onSubmit: (event) => {
|
|
853
887
|
event.preventDefault();
|
|
854
888
|
event.stopPropagation();
|
|
855
889
|
inviteForm.handleSubmit();
|
|
856
890
|
}, children: [_jsxs("div", { className: "sm:col-span-3", children: [_jsxs("div", { className: "flex items-center gap-2 font-medium", children: [_jsx(UserPlus, { className: "size-4" }), m.organization_invite_member_title()] }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invite_member_description() })] }), _jsx(inviteForm.AppField, { name: "email", children: (field) => (_jsx(field.TextField, { label: m.organization_member_email(), placeholder: "teammate@example.com", type: "email", required: true })) }), _jsx(inviteForm.AppField, { name: "role", children: (field) => (_jsx(field.SelectField, { label: m.organization_member_role(), options: organizationRoles.map((role) => ({
|
|
857
891
|
label: organizationRoleLabel(role, m),
|
|
858
892
|
value: role,
|
|
859
|
-
})) })) }), _jsx("div", { className: "self-end", children: _jsx(inviteForm.SubmitButton, {}) }), _jsx(inviteForm.FormError, {})] }) }), membersError ? (_jsx("p", { className: "text-destructive text-sm", children: membersError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_members_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_members_description() })] }), _jsx("div", { className: "-m-1 min-w-0 overflow-x-auto p-1", children: _jsx(DataTable, { columns: memberColumns({
|
|
893
|
+
})) })) }), _jsx("div", { className: "self-end", children: _jsx(inviteForm.SubmitButton, {}) }), _jsx(inviteForm.FormError, {})] }) })) : null, membersError ? (_jsx("p", { className: "text-destructive text-sm", children: membersError })) : null, error ? _jsx("p", { className: "text-destructive text-sm", children: error }) : null, _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_members_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_members_description() })] }), _jsx("div", { className: "-m-1 min-w-0 overflow-x-auto p-1", children: _jsx(DataTable, { columns: memberColumns({
|
|
860
894
|
m,
|
|
861
895
|
baseUrl,
|
|
862
896
|
canChangeRoles: canChangeMemberRoles,
|
|
@@ -865,6 +899,8 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
865
899
|
m,
|
|
866
900
|
canRemoveMembers,
|
|
867
901
|
currentUserId,
|
|
902
|
+
leavingOrganization,
|
|
903
|
+
onLeave: leaveOrganization,
|
|
868
904
|
onRemove: removeMember,
|
|
869
905
|
}) }) })] }), _jsxs("section", { className: "flex min-w-0 flex-col gap-3", children: [_jsxs("div", { children: [_jsx("h3", { className: "font-medium", children: m.organization_invitations_heading() }), _jsx("p", { className: "text-muted-foreground text-sm", children: m.organization_invitations_description() })] }), _jsx("div", { className: "-m-1 min-w-0 overflow-x-auto p-1", children: _jsx(DataTable, { columns: invitationColumns({
|
|
870
906
|
m,
|
|
@@ -899,7 +935,7 @@ const memberColumns = ({ m, baseUrl, canChangeRoles, onRoleChange, }) => [
|
|
|
899
935
|
return (_jsx(DataTableRelationshipCell, { emptyLabel: m.organization_member_role(), manageLabel: m.organization_member_role(), options: organizationRoles.map((role) => ({
|
|
900
936
|
label: organizationRoleLabel(role, m),
|
|
901
937
|
value: role,
|
|
902
|
-
})), value: roleOptions, onAdd: (value) => {
|
|
938
|
+
})), value: roleOptions, from: "/", onAdd: (value) => {
|
|
903
939
|
if (!isOrganizationRole(value))
|
|
904
940
|
return;
|
|
905
941
|
onRoleChange(member, Array.from(new Set([...roles, value])));
|
|
@@ -917,7 +953,14 @@ const memberColumns = ({ m, baseUrl, canChangeRoles, onRoleChange, }) => [
|
|
|
917
953
|
cell: ({ row }) => (_jsx("span", { className: "text-muted-foreground text-sm", children: formatOrganizationDate(row.original.createdAt) })),
|
|
918
954
|
},
|
|
919
955
|
];
|
|
920
|
-
const memberRowActions = ({ m, canRemoveMembers, currentUserId, onRemove, }) => [
|
|
956
|
+
const memberRowActions = ({ m, canRemoveMembers, currentUserId, leavingOrganization, onLeave, onRemove, }) => [
|
|
957
|
+
{
|
|
958
|
+
name: m.organization_member_leave(),
|
|
959
|
+
icon: _jsx(LogOut, {}),
|
|
960
|
+
variant: "destructive",
|
|
961
|
+
visible: (member) => member.userId === currentUserId && !leavingOrganization,
|
|
962
|
+
onClick: onLeave,
|
|
963
|
+
},
|
|
921
964
|
{
|
|
922
965
|
name: m.organization_member_remove(),
|
|
923
966
|
icon: _jsx(Trash2, {}),
|
|
@@ -10,7 +10,17 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
10
10
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
11
11
|
readonly id: import("effect/Schema").String;
|
|
12
12
|
readonly key: import("effect/Schema").String;
|
|
13
|
-
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
13
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getOrganizationPublicProfile", "GET", "/auth/organization-profile", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
|
|
14
|
+
readonly organizationId: import("effect/Schema").String;
|
|
15
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
16
|
+
readonly id: import("effect/Schema").String;
|
|
17
|
+
readonly name: import("effect/Schema").String;
|
|
18
|
+
readonly slug: import("effect/Schema").String;
|
|
19
|
+
readonly displayName: import("effect/Schema").String;
|
|
20
|
+
readonly contactEmail: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
21
|
+
readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
22
|
+
readonly icon: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
23
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getProjectPublicConfig", "GET", "/auth/project-config", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
|
|
14
24
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
15
25
|
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
16
26
|
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
package/dist/extra/api.group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenApi } from "effect/unstable/httpapi";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup, } from "effect/unstable/httpapi";
|
|
3
|
-
import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraProjectPublicConfig, ExtraProjectPublicConfigQuery, ExtraSetPasswordPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema";
|
|
3
|
+
import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraOrganizationPublicProfile, ExtraOrganizationPublicProfileQuery, ExtraProjectPublicConfig, ExtraProjectPublicConfigQuery, ExtraSetPasswordPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema";
|
|
4
4
|
export * from "./schema";
|
|
5
5
|
export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
6
6
|
.add(HttpApiEndpoint.get("getProjectPublicConfig", "/auth/project-config", {
|
|
@@ -11,6 +11,15 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
11
11
|
title: "Get project public config",
|
|
12
12
|
summary: "Get host-aware project white-label config",
|
|
13
13
|
description: "Returns resolved public branding and authentication options through the proxied auth API.",
|
|
14
|
+
})))
|
|
15
|
+
.add(HttpApiEndpoint.get("getOrganizationPublicProfile", "/auth/organization-profile", {
|
|
16
|
+
query: ExtraOrganizationPublicProfileQuery,
|
|
17
|
+
success: ExtraOrganizationPublicProfile,
|
|
18
|
+
error: [HttpApiError.NotFound, HttpApiError.InternalServerError],
|
|
19
|
+
}).annotateMerge(OpenApi.annotations({
|
|
20
|
+
title: "Get organization public profile",
|
|
21
|
+
summary: "Get public organization display metadata",
|
|
22
|
+
description: "Returns public organization metadata used by access and invitation screens.",
|
|
14
23
|
})))
|
|
15
24
|
.add(HttpApiEndpoint.post("setPassword", "/auth/set-password", {
|
|
16
25
|
payload: ExtraSetPasswordPayload,
|
package/dist/extra/schema.d.ts
CHANGED
|
@@ -97,6 +97,18 @@ export declare const ExtraProjectPublicConfig: Schema.Struct<{
|
|
|
97
97
|
readonly signUpName: Schema.Boolean;
|
|
98
98
|
}>;
|
|
99
99
|
}>;
|
|
100
|
+
export declare const ExtraOrganizationPublicProfileQuery: Schema.Struct<{
|
|
101
|
+
readonly organizationId: Schema.String;
|
|
102
|
+
}>;
|
|
103
|
+
export declare const ExtraOrganizationPublicProfile: Schema.Struct<{
|
|
104
|
+
readonly id: Schema.String;
|
|
105
|
+
readonly name: Schema.String;
|
|
106
|
+
readonly slug: Schema.String;
|
|
107
|
+
readonly displayName: Schema.String;
|
|
108
|
+
readonly contactEmail: Schema.NullOr<Schema.String>;
|
|
109
|
+
readonly logo: Schema.NullOr<Schema.String>;
|
|
110
|
+
readonly icon: Schema.NullOr<Schema.String>;
|
|
111
|
+
}>;
|
|
100
112
|
export declare const ExtraOkResponse: Schema.Struct<{
|
|
101
113
|
readonly ok: Schema.Boolean;
|
|
102
114
|
}>;
|
|
@@ -119,5 +131,7 @@ export type ExtraVerifyApiKeyPayload = typeof ExtraVerifyApiKeyPayload.Type;
|
|
|
119
131
|
export type ExtraVerifyApiKeyResponse = typeof ExtraVerifyApiKeyResponse.Type;
|
|
120
132
|
export type ExtraProjectPublicConfigQuery = typeof ExtraProjectPublicConfigQuery.Type;
|
|
121
133
|
export type ExtraProjectPublicConfig = typeof ExtraProjectPublicConfig.Type;
|
|
134
|
+
export type ExtraOrganizationPublicProfileQuery = typeof ExtraOrganizationPublicProfileQuery.Type;
|
|
135
|
+
export type ExtraOrganizationPublicProfile = typeof ExtraOrganizationPublicProfile.Type;
|
|
122
136
|
export type ExtraOkResponse = typeof ExtraOkResponse.Type;
|
|
123
137
|
export {};
|
package/dist/extra/schema.js
CHANGED
|
@@ -203,6 +203,38 @@ export const ExtraProjectPublicConfig = Schema.Struct({
|
|
|
203
203
|
},
|
|
204
204
|
],
|
|
205
205
|
});
|
|
206
|
+
export const ExtraOrganizationPublicProfileQuery = Schema.Struct({
|
|
207
|
+
organizationId: Schema.String,
|
|
208
|
+
}).annotate({
|
|
209
|
+
identifier: "ExtraOrganizationPublicProfileQuery",
|
|
210
|
+
title: "Extra organization public profile query",
|
|
211
|
+
description: "Organization ID used to resolve public organization display metadata.",
|
|
212
|
+
examples: [{ organizationId: "org_1" }],
|
|
213
|
+
});
|
|
214
|
+
export const ExtraOrganizationPublicProfile = Schema.Struct({
|
|
215
|
+
id: Schema.String,
|
|
216
|
+
name: Schema.String,
|
|
217
|
+
slug: Schema.String,
|
|
218
|
+
displayName: Schema.String,
|
|
219
|
+
contactEmail: Schema.NullOr(Schema.String),
|
|
220
|
+
logo: Schema.NullOr(Schema.String),
|
|
221
|
+
icon: Schema.NullOr(Schema.String),
|
|
222
|
+
}).annotate({
|
|
223
|
+
identifier: "ExtraOrganizationPublicProfile",
|
|
224
|
+
title: "Extra organization public profile",
|
|
225
|
+
description: "Public organization display metadata used for access and invitation screens.",
|
|
226
|
+
examples: [
|
|
227
|
+
{
|
|
228
|
+
id: "org_1",
|
|
229
|
+
name: "Krak",
|
|
230
|
+
slug: "krak",
|
|
231
|
+
displayName: "Krak",
|
|
232
|
+
contactEmail: null,
|
|
233
|
+
logo: null,
|
|
234
|
+
icon: null,
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
});
|
|
206
238
|
export const ExtraOkResponse = Schema.Struct({
|
|
207
239
|
ok: Schema.Boolean,
|
|
208
240
|
}).annotate({
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { AuthClientApi, AuthServiceApi } from "./api";
|
|
|
5
5
|
export { AuthService, type AuthServiceLayerOptions } from "./service";
|
|
6
6
|
export { AuthClientConfig } from "./config";
|
|
7
7
|
export { proxyAuthRequest } from "./server/proxy";
|
|
8
|
-
export { OrganizationSwitcher, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type OrganizationSwitcherProps, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
8
|
+
export { OrganizationSwitcher, AdminRequired, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type AdminRequiredMessages, type AdminRequiredProps, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type OrganizationSwitcherProps, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
9
9
|
export * as BetterAuth from "./better-auth/api.group";
|
|
10
10
|
export * as Extra from "./extra/api.group";
|
|
11
11
|
export * as Server from "./server";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ export { AuthClientApi, AuthServiceApi } from "./api";
|
|
|
5
5
|
export { AuthService } from "./service";
|
|
6
6
|
export { AuthClientConfig } from "./config";
|
|
7
7
|
export { proxyAuthRequest } from "./server/proxy";
|
|
8
|
-
export { OrganizationSwitcher, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
8
|
+
export { OrganizationSwitcher, AdminRequired, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
9
9
|
export * as BetterAuth from "./better-auth/api.group";
|
|
10
10
|
export * as Extra from "./extra/api.group";
|
|
11
11
|
export * as Server from "./server";
|
package/dist/server/proxy.js
CHANGED
|
@@ -12,20 +12,8 @@ const blockedRequestHeaders = [
|
|
|
12
12
|
"upgrade",
|
|
13
13
|
"cdn-loop",
|
|
14
14
|
];
|
|
15
|
-
const parseUrl = (value) => {
|
|
16
|
-
if (!value)
|
|
17
|
-
return null;
|
|
18
|
-
try {
|
|
19
|
-
return new URL(value);
|
|
20
|
-
}
|
|
21
|
-
catch {
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
15
|
const forwardedUrl = (request) => {
|
|
26
|
-
return (
|
|
27
|
-
parseUrl(request.headers.get("referer")) ??
|
|
28
|
-
new URL(request.url));
|
|
16
|
+
return new URL(request.url);
|
|
29
17
|
};
|
|
30
18
|
const proxyHeaders = (request) => {
|
|
31
19
|
const headers = new Headers(request.headers);
|
package/dist/service.d.ts
CHANGED
|
@@ -117,6 +117,20 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
117
117
|
readonly id: import("effect/Schema").String;
|
|
118
118
|
readonly key: import("effect/Schema").String;
|
|
119
119
|
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | HttpApiError.Forbidden | HttpApiError.InternalServerError | import("effect/Schema").SchemaError | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
|
|
120
|
+
readonly getOrganizationPublicProfile: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
121
|
+
readonly query: import("effect/Schema").Struct.ReadonlySide<{
|
|
122
|
+
readonly organizationId: import("effect/Schema").String;
|
|
123
|
+
}, "Type">;
|
|
124
|
+
readonly responseMode?: Mode;
|
|
125
|
+
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
126
|
+
readonly id: import("effect/Schema").String;
|
|
127
|
+
readonly name: import("effect/Schema").String;
|
|
128
|
+
readonly slug: import("effect/Schema").String;
|
|
129
|
+
readonly displayName: import("effect/Schema").String;
|
|
130
|
+
readonly contactEmail: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
131
|
+
readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
132
|
+
readonly icon: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
133
|
+
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : HttpApiError.InternalServerError | HttpApiError.NotFound | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
120
134
|
readonly getProjectPublicConfig: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
121
135
|
readonly query: {
|
|
122
136
|
readonly projectId?: string | undefined;
|
|
@@ -529,6 +543,20 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
529
543
|
readonly id: import("effect/Schema").String;
|
|
530
544
|
readonly key: import("effect/Schema").String;
|
|
531
545
|
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | HttpApiError.Forbidden | HttpApiError.InternalServerError | import("effect/Schema").SchemaError | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
|
|
546
|
+
readonly getOrganizationPublicProfile: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
547
|
+
readonly query: import("effect/Schema").Struct.ReadonlySide<{
|
|
548
|
+
readonly organizationId: import("effect/Schema").String;
|
|
549
|
+
}, "Type">;
|
|
550
|
+
readonly responseMode?: Mode;
|
|
551
|
+
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
552
|
+
readonly id: import("effect/Schema").String;
|
|
553
|
+
readonly name: import("effect/Schema").String;
|
|
554
|
+
readonly slug: import("effect/Schema").String;
|
|
555
|
+
readonly displayName: import("effect/Schema").String;
|
|
556
|
+
readonly contactEmail: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
557
|
+
readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
558
|
+
readonly icon: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
559
|
+
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : HttpApiError.InternalServerError | HttpApiError.NotFound | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
532
560
|
readonly getProjectPublicConfig: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
533
561
|
readonly query: {
|
|
534
562
|
readonly projectId?: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
4
4
|
"description": "Effect HttpApi clients and schemas for KrakStack Auth.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
|
-
"build": "rm -rf dist && tsc -p tsconfig.json",
|
|
64
|
-
"build:watch": "rm -rf dist && tsc -p tsconfig.json --watch --preserveWatchOutput",
|
|
63
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
64
|
+
"build:watch": "rm -rf dist && tsc -p tsconfig.build.json --watch --preserveWatchOutput",
|
|
65
65
|
"dev": "bun run build:watch",
|
|
66
66
|
"prepack": "bun run build",
|
|
67
67
|
"type:check": "tsc -p tsconfig.json --noEmit"
|