@krak-stack/auth 0.1.44 → 0.1.46
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 +10 -2
- package/dist/api.d.ts +99 -10
- package/dist/api.js +1 -1
- package/dist/better-auth/api.group.d.ts +33 -1
- package/dist/better-auth/api.group.js +16 -1
- package/dist/better-auth/schema.d.ts +36 -0
- package/dist/better-auth/schema.js +56 -0
- package/dist/components/admin-users.js +60 -4
- package/dist/components/auth-client-api.d.ts +62 -5
- package/dist/components/auth-client.js +3 -1
- package/dist/components/auth-provider.d.ts +2 -0
- package/dist/components/auth-provider.js +16 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/organization-switcher.d.ts +5 -2
- package/dist/components/organization-switcher.js +64 -35
- package/dist/components/user-button.d.ts +2 -0
- package/dist/components/user-button.js +8 -3
- package/dist/extra/api.group.d.ts +4 -4
- package/dist/extra/api.group.js +19 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/roles.d.ts +10 -0
- package/dist/roles.js +31 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +2 -0
- package/dist/server/middleware.d.ts +9 -3
- package/dist/server/middleware.js +25 -2
- package/dist/service.d.ts +80 -8
- package/package.json +5 -1
|
@@ -197,7 +197,64 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
197
197
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
198
198
|
readonly memberCount: import("effect/Schema").optional<import("effect/Schema").Number>;
|
|
199
199
|
readonly createdAt: import("effect/Schema").Date;
|
|
200
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never>, false> | import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"
|
|
200
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never>, false> | import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"auth", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getSession", "GET", "/api/auth/get-session", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").NullOr<import("effect/Schema").Struct<{
|
|
201
|
+
readonly session: import("effect/Schema").Struct<{
|
|
202
|
+
readonly id: import("effect/Schema").String;
|
|
203
|
+
readonly expiresAt: import("effect/Schema").Date;
|
|
204
|
+
readonly token: import("effect/Schema").String;
|
|
205
|
+
readonly createdAt: import("effect/Schema").Date;
|
|
206
|
+
readonly updatedAt: import("effect/Schema").Date;
|
|
207
|
+
readonly ipAddress: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
208
|
+
readonly userAgent: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
209
|
+
readonly userId: import("effect/Schema").String;
|
|
210
|
+
readonly impersonatedBy: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
211
|
+
readonly impersonatedByOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
212
|
+
readonly activeOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
213
|
+
}>;
|
|
214
|
+
readonly user: import("effect/Schema").Struct<{
|
|
215
|
+
readonly id: import("effect/Schema").String;
|
|
216
|
+
readonly name: import("effect/Schema").String;
|
|
217
|
+
readonly email: import("effect/Schema").String;
|
|
218
|
+
readonly emailVerified: import("effect/Schema").Boolean;
|
|
219
|
+
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
220
|
+
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
221
|
+
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
222
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
223
|
+
readonly createdAt: import("effect/Schema").Date;
|
|
224
|
+
readonly updatedAt: import("effect/Schema").Date;
|
|
225
|
+
}>;
|
|
226
|
+
}>>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").BadRequest | typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("../better-auth/schema").TooManyRequests>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"organizationImpersonateUser", "POST", "/api/auth/organization/impersonate-user", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
227
|
+
readonly organizationId: import("effect/Schema").NonEmptyString;
|
|
228
|
+
readonly actorUserId: import("effect/Schema").NonEmptyString;
|
|
229
|
+
readonly targetUserId: import("effect/Schema").NonEmptyString;
|
|
230
|
+
readonly expiresInSeconds: import("effect/Schema").optional<import("effect/Schema").Number>;
|
|
231
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
232
|
+
readonly session: import("effect/Schema").Struct<{
|
|
233
|
+
readonly id: import("effect/Schema").String;
|
|
234
|
+
readonly expiresAt: import("effect/Schema").Date;
|
|
235
|
+
readonly token: import("effect/Schema").String;
|
|
236
|
+
readonly createdAt: import("effect/Schema").Date;
|
|
237
|
+
readonly updatedAt: import("effect/Schema").Date;
|
|
238
|
+
readonly ipAddress: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
239
|
+
readonly userAgent: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
240
|
+
readonly userId: import("effect/Schema").String;
|
|
241
|
+
readonly impersonatedBy: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
242
|
+
readonly impersonatedByOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
243
|
+
readonly activeOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
244
|
+
}>;
|
|
245
|
+
readonly user: import("effect/Schema").Struct<{
|
|
246
|
+
readonly id: import("effect/Schema").String;
|
|
247
|
+
readonly name: import("effect/Schema").String;
|
|
248
|
+
readonly email: import("effect/Schema").String;
|
|
249
|
+
readonly emailVerified: import("effect/Schema").Boolean;
|
|
250
|
+
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
251
|
+
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
252
|
+
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
253
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
254
|
+
readonly createdAt: import("effect/Schema").Date;
|
|
255
|
+
readonly updatedAt: import("effect/Schema").Date;
|
|
256
|
+
}>;
|
|
257
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").BadRequest | typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never>, false> | import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"authExtra", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createApiKey", "POST", "/api/auth/create-api-key", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
201
258
|
readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
|
|
202
259
|
readonly name: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
|
|
203
260
|
readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -205,7 +262,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
205
262
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
206
263
|
readonly id: import("effect/Schema").String;
|
|
207
264
|
readonly key: import("effect/Schema").String;
|
|
208
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra/schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getProjectPublicConfig", "GET", "/api/auth/project-config", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
265
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("../extra/schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getProjectPublicConfig", "GET", "/api/auth/project-config", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
209
266
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
210
267
|
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
211
268
|
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -228,11 +285,11 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
228
285
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
229
286
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
230
287
|
readonly ok: import("effect/Schema").Boolean;
|
|
231
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra/schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"uploadUserImage", "POST", "/api/auth/image/upload", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/unstable/httpapi/HttpApiSchema").asMultipartStream<import("effect/Schema").Struct<{
|
|
288
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("../extra/schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"uploadUserImage", "POST", "/api/auth/image/upload", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/unstable/httpapi/HttpApiSchema").asMultipartStream<import("effect/Schema").Struct<{
|
|
232
289
|
readonly file: import("effect/Schema").decodeTo<import("effect/unstable/http/Multipart").PersistedFileSchema, import("effect/Schema").$Array<import("effect/unstable/http/Multipart").PersistedFileSchema>, never, never>;
|
|
233
290
|
}>>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
234
291
|
readonly url: import("effect/Schema").String;
|
|
235
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("../extra/schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"verifyApiKey", "POST", "/api/auth/verify-api-key", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
292
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("../extra/schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"verifyApiKey", "POST", "/api/auth/verify-api-key", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
236
293
|
readonly key: import("effect/Schema").NonEmptyString;
|
|
237
294
|
readonly configId: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>>;
|
|
238
295
|
readonly permissions: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
@@ -260,4 +317,4 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
260
317
|
readonly password: import("effect/Schema").NonEmptyString;
|
|
261
318
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
262
319
|
readonly ok: import("effect/Schema").Boolean;
|
|
263
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra/schema").ExtraBadRequest>, never, never>, false>>;
|
|
320
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("../extra/schema").ExtraBadRequest>, never, never>, false>>;
|
|
@@ -6,7 +6,9 @@ export const createAuthUiClient = (baseUrl) => createAuthClient({
|
|
|
6
6
|
plugins: [
|
|
7
7
|
adminClient(),
|
|
8
8
|
emailOTPClient(),
|
|
9
|
-
lastLoginMethodClient(
|
|
9
|
+
lastLoginMethodClient({
|
|
10
|
+
cookieName: "krakstack-auth.last_used_login_method",
|
|
11
|
+
}),
|
|
10
12
|
organizationClient(),
|
|
11
13
|
twoFactorClient(),
|
|
12
14
|
apiKeyClient(),
|
|
@@ -15,6 +15,8 @@ export type KrakstackAuthContextValue = {
|
|
|
15
15
|
projectId?: string | null | undefined;
|
|
16
16
|
authClient: AuthUiClient;
|
|
17
17
|
projectConfig: ExtraProjectPublicConfig | null;
|
|
18
|
+
authRefreshVersion: number;
|
|
19
|
+
refreshAuth: () => void;
|
|
18
20
|
};
|
|
19
21
|
export declare function KrakstackAuthProvider({ children, locale, baseUrl, projectId, authClient, }: KrakstackAuthProviderProps): import("react").JSX.Element;
|
|
20
22
|
export declare const useKrakstackAuth: () => KrakstackAuthContextValue | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useAtomSuspense } from "@effect/atom-react";
|
|
3
3
|
import { useRouterState } from "@tanstack/react-router";
|
|
4
|
-
import { createContext, useContext, useEffect, useMemo, } from "react";
|
|
4
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useState, } from "react";
|
|
5
5
|
import { createAuthUiClient } from "./auth-client";
|
|
6
6
|
import { authClientApi } from "./auth-client-api";
|
|
7
7
|
const KrakstackAuthContext = createContext(null);
|
|
@@ -74,6 +74,10 @@ export function KrakstackAuthProvider({ children, locale = "en", baseUrl, projec
|
|
|
74
74
|
const resolvedProjectId = projectId ?? getSearchParam(searchString, "projectId");
|
|
75
75
|
const resolvedAuthClient = useMemo(() => authClient ?? createAuthUiClient(baseUrl), [authClient, baseUrl]);
|
|
76
76
|
const projectConfig = useProjectConfig(baseUrl, projectId);
|
|
77
|
+
const [authRefreshVersion, setAuthRefreshVersion] = useState(0);
|
|
78
|
+
const refreshAuth = useCallback(() => {
|
|
79
|
+
setAuthRefreshVersion((current) => current + 1);
|
|
80
|
+
}, []);
|
|
77
81
|
useEffect(() => {
|
|
78
82
|
setProjectContextCookie(resolvedProjectId);
|
|
79
83
|
}, [resolvedProjectId]);
|
|
@@ -83,7 +87,17 @@ export function KrakstackAuthProvider({ children, locale = "en", baseUrl, projec
|
|
|
83
87
|
locale,
|
|
84
88
|
projectId: resolvedProjectId,
|
|
85
89
|
projectConfig,
|
|
86
|
-
|
|
90
|
+
authRefreshVersion,
|
|
91
|
+
refreshAuth,
|
|
92
|
+
}), [
|
|
93
|
+
resolvedAuthClient,
|
|
94
|
+
baseUrl,
|
|
95
|
+
locale,
|
|
96
|
+
resolvedProjectId,
|
|
97
|
+
projectConfig,
|
|
98
|
+
authRefreshVersion,
|
|
99
|
+
refreshAuth,
|
|
100
|
+
]);
|
|
87
101
|
return (_jsx(KrakstackAuthContext.Provider, { value: value, children: children }));
|
|
88
102
|
}
|
|
89
103
|
export const useKrakstackAuth = () => useContext(KrakstackAuthContext);
|
|
@@ -8,6 +8,6 @@ export { AdminOrganizationForm } from "./admin-organization-form";
|
|
|
8
8
|
export { AdminUsersTable, useAdminUsersTotal } from "./admin-users";
|
|
9
9
|
export { assetUrl } from "./utils";
|
|
10
10
|
export type { KrakstackAuthContextValue, KrakstackAuthLocale, KrakstackAuthProviderProps, } from "./auth-provider";
|
|
11
|
-
export type { OrganizationSwitcherDialog } from "./organization-switcher";
|
|
11
|
+
export type { OrganizationSwitcherDialog, OrganizationSwitcherProps, } from "./organization-switcher";
|
|
12
12
|
export type { UserButtonDialog } from "./user-button";
|
|
13
13
|
export type { AuthUiClient } from "./auth-client";
|
|
@@ -53,6 +53,7 @@ declare const messages: {
|
|
|
53
53
|
readonly organization_role_admin: "Admin";
|
|
54
54
|
readonly organization_role_member: "Member";
|
|
55
55
|
readonly organization_role_owner: "Owner";
|
|
56
|
+
readonly organization_role_support: "Support";
|
|
56
57
|
readonly organization_slug: "Organization slug";
|
|
57
58
|
readonly organization_slug_description: "Leave blank to generate one from the name.";
|
|
58
59
|
readonly organization_switcher_empty: "You do not belong to any organizations yet.";
|
|
@@ -132,6 +133,7 @@ declare const messages: {
|
|
|
132
133
|
readonly organization_role_admin: "Admin";
|
|
133
134
|
readonly organization_role_member: "Membre";
|
|
134
135
|
readonly organization_role_owner: "Propriétaire";
|
|
136
|
+
readonly organization_role_support: "Support";
|
|
135
137
|
readonly organization_slug: "Slug de l'organisation";
|
|
136
138
|
readonly organization_slug_description: "Laissez vide pour en générer un à partir du nom.";
|
|
137
139
|
readonly organization_switcher_empty: "Vous n'appartenez encore à aucune organisation.";
|
|
@@ -163,13 +165,14 @@ declare const messages: {
|
|
|
163
165
|
};
|
|
164
166
|
type OrganizationSwitcherMessageKey = keyof (typeof messages)["en"];
|
|
165
167
|
export type OrganizationSwitcherMessages = Partial<Record<OrganizationSwitcherMessageKey, string>>;
|
|
166
|
-
type OrganizationSwitcherProps = {
|
|
168
|
+
export type OrganizationSwitcherProps = {
|
|
167
169
|
authClient?: AuthUiClient;
|
|
168
170
|
baseUrl?: string | undefined;
|
|
169
171
|
side?: ComponentProps<typeof DropdownMenuContent>["side"];
|
|
170
172
|
className?: string;
|
|
171
173
|
defaultDialog?: OrganizationSwitcherDialog | null;
|
|
172
174
|
hideTrigger?: boolean;
|
|
175
|
+
menuActions?: ReactNode;
|
|
173
176
|
renderUnauthenticated?: () => ReactNode;
|
|
174
177
|
locked?: boolean;
|
|
175
178
|
messages?: OrganizationSwitcherMessages;
|
|
@@ -185,5 +188,5 @@ type OrganizationSummary = {
|
|
|
185
188
|
metadata?: unknown;
|
|
186
189
|
};
|
|
187
190
|
export type OrganizationSwitcherDialog = "create" | "manage" | "members" | "apiKeys" | "invitations";
|
|
188
|
-
export declare function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side, className, defaultDialog, hideTrigger, renderUnauthenticated, locked, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }: OrganizationSwitcherProps): import("react").JSX.Element;
|
|
191
|
+
export declare function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side, className, defaultDialog, hideTrigger, menuActions, renderUnauthenticated, locked, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }: OrganizationSwitcherProps): import("react").JSX.Element;
|
|
189
192
|
export {};
|
|
@@ -5,7 +5,7 @@ import {} from "@tanstack/react-table";
|
|
|
5
5
|
import { Effect, Schema } from "effect";
|
|
6
6
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
7
7
|
import { Building2, Check, ChevronsUpDown, Copy, KeyRound, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
8
|
-
import { createContext, useContext, useEffect, useState, } from "react";
|
|
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";
|
|
11
11
|
import { AppBrand } from "@/components/ui/app-brand";
|
|
@@ -16,6 +16,7 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, }
|
|
|
16
16
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
17
17
|
import { Separator } from "@/components/ui/separator";
|
|
18
18
|
import { OrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
19
|
+
import { hasAnyRole, isOrganizationRole, normalizeOrganizationRole, normalizeOrganizationRoles, organizationRoles, } from "../roles";
|
|
19
20
|
import { authClientApi } from "./auth-client-api";
|
|
20
21
|
import { useKrakstackAuth } from "./auth-provider";
|
|
21
22
|
import { createApiKey } from "./api-key";
|
|
@@ -74,6 +75,7 @@ const messages = {
|
|
|
74
75
|
organization_role_admin: "Admin",
|
|
75
76
|
organization_role_member: "Member",
|
|
76
77
|
organization_role_owner: "Owner",
|
|
78
|
+
organization_role_support: "Support",
|
|
77
79
|
organization_slug: "Organization slug",
|
|
78
80
|
organization_slug_description: "Leave blank to generate one from the name.",
|
|
79
81
|
organization_switcher_empty: "You do not belong to any organizations yet.",
|
|
@@ -153,6 +155,7 @@ const messages = {
|
|
|
153
155
|
organization_role_admin: "Admin",
|
|
154
156
|
organization_role_member: "Membre",
|
|
155
157
|
organization_role_owner: "Propriétaire",
|
|
158
|
+
organization_role_support: "Support",
|
|
156
159
|
organization_slug: "Slug de l'organisation",
|
|
157
160
|
organization_slug_description: "Laissez vide pour en générer un à partir du nom.",
|
|
158
161
|
organization_switcher_empty: "Vous n'appartenez encore à aucune organisation.",
|
|
@@ -335,14 +338,14 @@ const organizationLogoFromForm = async (value, m, uploadImage) => {
|
|
|
335
338
|
return assetPath(value);
|
|
336
339
|
return null;
|
|
337
340
|
};
|
|
338
|
-
const organizationRoles = ["owner", "admin", "member"];
|
|
339
|
-
const normalizeOrganizationRole = (role) => role === "owner" || role === "admin" || role === "member" ? role : "member";
|
|
340
341
|
const organizationRoleLabel = (role, m) => {
|
|
341
342
|
switch (normalizeOrganizationRole(role)) {
|
|
342
343
|
case "owner":
|
|
343
344
|
return m.organization_role_owner();
|
|
344
345
|
case "admin":
|
|
345
346
|
return m.organization_role_admin();
|
|
347
|
+
case "support":
|
|
348
|
+
return m.organization_role_support();
|
|
346
349
|
case "member":
|
|
347
350
|
return m.organization_role_member();
|
|
348
351
|
}
|
|
@@ -378,7 +381,7 @@ const organizationMetadataFromForm = async (value, m, uploadImage) => {
|
|
|
378
381
|
}
|
|
379
382
|
return { translations };
|
|
380
383
|
};
|
|
381
|
-
export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side = "bottom", className, defaultDialog = null, hideTrigger = false, renderUnauthenticated, locked = false, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }) {
|
|
384
|
+
export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side = "bottom", className, defaultDialog = null, hideTrigger = false, menuActions, renderUnauthenticated, locked = false, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }) {
|
|
382
385
|
const auth = useKrakstackAuth();
|
|
383
386
|
const authClient = providedAuthClient ?? auth?.authClient;
|
|
384
387
|
if (!authClient) {
|
|
@@ -389,6 +392,7 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
389
392
|
const session = authClient.useSession();
|
|
390
393
|
const organizations = authClient.useListOrganizations();
|
|
391
394
|
const activeOrganization = authClient.useActiveOrganization();
|
|
395
|
+
const lastAuthRefreshVersion = useRef(auth?.authRefreshVersion ?? 0);
|
|
392
396
|
const [uncontrolledDialog, setUncontrolledDialog] = useState(defaultDialog);
|
|
393
397
|
const dialog = controlledDialog !== undefined ? controlledDialog : uncontrolledDialog;
|
|
394
398
|
const invitationsAtom = session.data
|
|
@@ -418,6 +422,21 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
418
422
|
onDialogChange?.(nextDialog);
|
|
419
423
|
};
|
|
420
424
|
const openCreate = () => setDialog("create");
|
|
425
|
+
const refresh = async () => {
|
|
426
|
+
await organizations.refetch();
|
|
427
|
+
await activeOrganization.refetch();
|
|
428
|
+
await session.refetch();
|
|
429
|
+
};
|
|
430
|
+
const refreshOnSessionChanged = useEffectEvent(() => {
|
|
431
|
+
void refresh();
|
|
432
|
+
});
|
|
433
|
+
useEffect(() => {
|
|
434
|
+
const version = auth?.authRefreshVersion ?? 0;
|
|
435
|
+
if (version === lastAuthRefreshVersion.current)
|
|
436
|
+
return;
|
|
437
|
+
lastAuthRefreshVersion.current = version;
|
|
438
|
+
refreshOnSessionChanged();
|
|
439
|
+
}, [auth?.authRefreshVersion]);
|
|
421
440
|
if (!session.data) {
|
|
422
441
|
return _jsx(_Fragment, { children: renderUnauthenticated?.() });
|
|
423
442
|
}
|
|
@@ -427,11 +446,6 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
427
446
|
? (organizations.data?.filter((organization) => organization.id !== active?.id) ?? [])
|
|
428
447
|
: [];
|
|
429
448
|
const hasOrganizationListItems = organizations.isPending || Boolean(organizations.error) || !locked;
|
|
430
|
-
const refresh = async () => {
|
|
431
|
-
await organizations.refetch();
|
|
432
|
-
await activeOrganization.refetch();
|
|
433
|
-
await session.refetch();
|
|
434
|
-
};
|
|
435
449
|
const refreshAfterInvitationAction = async (previousActiveId) => {
|
|
436
450
|
refreshUserInvitations();
|
|
437
451
|
await refresh();
|
|
@@ -452,7 +466,7 @@ export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl,
|
|
|
452
466
|
? { imageSrc: activeDisplay.image }
|
|
453
467
|
: {}) }), _jsx(ChevronsUpDown, { className: "text-muted-foreground size-4 shrink-0 group-data-[collapsible=icon]:hidden" })] }) }), _jsx(DropdownMenuContent, { className: "min-w-64 rounded-lg", side: side, align: "end", sideOffset: 4, children: _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: _jsx(AppBrand, { to: null, label: activeDisplay.name, subtitle: activeDisplay.subtitle, icon: Building2, variant: "sidebar", className: "px-1 py-1.5 text-left text-sm", ...(activeDisplay.image
|
|
454
468
|
? { imageSrc: activeDisplay.image }
|
|
455
|
-
: {}) }) }), hasOrganizationListItems ? _jsx(DropdownMenuSeparator, {}) : null, organizations.isPending ? (_jsx(DropdownMenuItem, { disabled: true, children: m.organization_loading() })) : null, organizations.error ? (_jsx(DropdownMenuItem, { disabled: true, children: organizations.error.message })) : null, !locked && selectableOrganizations.length ? (selectableOrganizations.map((organization) => {
|
|
469
|
+
: {}) }) }), menuActions ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), menuActions] })) : null, hasOrganizationListItems ? _jsx(DropdownMenuSeparator, {}) : null, organizations.isPending ? (_jsx(DropdownMenuItem, { disabled: true, children: m.organization_loading() })) : null, organizations.error ? (_jsx(DropdownMenuItem, { disabled: true, children: organizations.error.message })) : null, !locked && selectableOrganizations.length ? (selectableOrganizations.map((organization) => {
|
|
456
470
|
const display = organizationDisplay(organization, m, baseUrl);
|
|
457
471
|
return (_jsx(DropdownMenuItem, { onClick: async () => {
|
|
458
472
|
const result = await authClient.organization.setActive({
|
|
@@ -741,7 +755,6 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
741
755
|
const membersResult = useAtomValue(membersAtom);
|
|
742
756
|
const refreshMembers = useAtomRefresh(membersAtom);
|
|
743
757
|
const [error, setError] = useState(null);
|
|
744
|
-
const [updatingMemberId, setUpdatingMemberId] = useState(null);
|
|
745
758
|
const [cancellingInvitationId, setCancellingInvitationId] = useState(null);
|
|
746
759
|
const membersData = AsyncResult.match(membersResult, {
|
|
747
760
|
onInitial: () => ({ members: [], invitations: [] }),
|
|
@@ -750,14 +763,22 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
750
763
|
});
|
|
751
764
|
const members = membersData.members;
|
|
752
765
|
const invitations = membersData.invitations;
|
|
766
|
+
const [memberRoleOverrides, setMemberRoleOverrides] = useState({});
|
|
767
|
+
const displayedMembers = members.map((member) => ({
|
|
768
|
+
...member,
|
|
769
|
+
role: memberRoleOverrides[member.id] ?? member.role,
|
|
770
|
+
}));
|
|
753
771
|
const membersError = AsyncResult.match(membersResult, {
|
|
754
772
|
onInitial: () => null,
|
|
755
773
|
onFailure: () => m.organization_members_load_error(),
|
|
756
774
|
onSuccess: () => null,
|
|
757
775
|
});
|
|
758
776
|
const loading = membersResult._tag === "Initial";
|
|
759
|
-
const currentMemberRole =
|
|
760
|
-
const canChangeMemberRoles = currentMemberRole
|
|
777
|
+
const currentMemberRole = displayedMembers.find((member) => member.userId === currentUserId)?.role;
|
|
778
|
+
const canChangeMemberRoles = hasAnyRole(currentMemberRole, [
|
|
779
|
+
"owner",
|
|
780
|
+
"admin",
|
|
781
|
+
]);
|
|
761
782
|
const canRemoveMembers = canChangeMemberRoles;
|
|
762
783
|
const inviteForm = useAppForm({
|
|
763
784
|
defaultValues: { email: "", role: "member" },
|
|
@@ -782,28 +803,33 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
782
803
|
},
|
|
783
804
|
});
|
|
784
805
|
const updateRole = async (member, role) => {
|
|
785
|
-
setUpdatingMemberId(member.id);
|
|
786
806
|
setError(null);
|
|
807
|
+
const nextRole = Array.isArray(role)
|
|
808
|
+
? Array.from(new Set(role)).join(",")
|
|
809
|
+
: normalizeOrganizationRole(role);
|
|
810
|
+
setMemberRoleOverrides((current) => ({
|
|
811
|
+
...current,
|
|
812
|
+
[member.id]: nextRole,
|
|
813
|
+
}));
|
|
787
814
|
const result = await authClient.organization.updateMemberRole({
|
|
788
815
|
memberId: member.id,
|
|
789
|
-
role,
|
|
816
|
+
role: Array.isArray(role) ? role : normalizeOrganizationRole(role),
|
|
790
817
|
organizationId: organization.id,
|
|
791
818
|
});
|
|
792
|
-
setUpdatingMemberId(null);
|
|
793
819
|
if (result.error) {
|
|
820
|
+
setMemberRoleOverrides((current) => ({
|
|
821
|
+
...current,
|
|
822
|
+
[member.id]: member.role,
|
|
823
|
+
}));
|
|
794
824
|
setError(result.error.message ?? m.organization_member_role_error());
|
|
795
|
-
return;
|
|
796
825
|
}
|
|
797
|
-
refreshMembers();
|
|
798
826
|
};
|
|
799
827
|
const removeMember = async (member) => {
|
|
800
|
-
setUpdatingMemberId(member.id);
|
|
801
828
|
setError(null);
|
|
802
829
|
const result = await authClient.organization.removeMember({
|
|
803
830
|
memberIdOrEmail: member.id,
|
|
804
831
|
organizationId: organization.id,
|
|
805
832
|
});
|
|
806
|
-
setUpdatingMemberId(null);
|
|
807
833
|
if (result.error) {
|
|
808
834
|
setError(result.error.message ?? m.organization_member_remove_error());
|
|
809
835
|
return;
|
|
@@ -834,9 +860,8 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
834
860
|
m,
|
|
835
861
|
baseUrl,
|
|
836
862
|
canChangeRoles: canChangeMemberRoles,
|
|
837
|
-
updatingMemberId,
|
|
838
863
|
onRoleChange: updateRole,
|
|
839
|
-
}), data:
|
|
864
|
+
}), data: displayedMembers, emptyLabel: loading ? m.user_loading() : m.organization_members_empty(), exportFileName: `${organization.slug}-members.csv`, features: { gallery: false }, searchState: "local", rowActions: memberRowActions({
|
|
840
865
|
m,
|
|
841
866
|
canRemoveMembers,
|
|
842
867
|
currentUserId,
|
|
@@ -849,7 +874,7 @@ function OrganizationMembersManager({ authClient, baseUrl, organization, current
|
|
|
849
874
|
onCancel: cancelInvitation,
|
|
850
875
|
}) }) })] })] }));
|
|
851
876
|
}
|
|
852
|
-
const memberColumns = ({ m, baseUrl, canChangeRoles,
|
|
877
|
+
const memberColumns = ({ m, baseUrl, canChangeRoles, onRoleChange, }) => [
|
|
853
878
|
{
|
|
854
879
|
id: "user",
|
|
855
880
|
header: m.organization_member_user(),
|
|
@@ -863,22 +888,26 @@ const memberColumns = ({ m, baseUrl, canChangeRoles, updatingMemberId, onRoleCha
|
|
|
863
888
|
header: m.organization_member_role(),
|
|
864
889
|
cell: ({ row }) => {
|
|
865
890
|
const member = row.original;
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
|
|
891
|
+
const roles = normalizeOrganizationRoles(member.role);
|
|
892
|
+
const roleOptions = roles.map((role) => ({
|
|
893
|
+
label: organizationRoleLabel(role, m),
|
|
894
|
+
value: role,
|
|
895
|
+
}));
|
|
896
|
+
if (!canChangeRoles) {
|
|
897
|
+
return (_jsx("div", { className: "flex flex-wrap gap-1", children: roleOptions.map((role) => (_jsx(Badge, { variant: "secondary", children: role.label }, role.value))) }));
|
|
869
898
|
}
|
|
870
899
|
return (_jsx(DataTableRelationshipCell, { emptyLabel: m.organization_member_role(), manageLabel: m.organization_member_role(), options: organizationRoles.map((role) => ({
|
|
871
900
|
label: organizationRoleLabel(role, m),
|
|
872
901
|
value: role,
|
|
873
|
-
})), value:
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
902
|
+
})), value: roleOptions, onAdd: (value) => {
|
|
903
|
+
if (!isOrganizationRole(value))
|
|
904
|
+
return;
|
|
905
|
+
onRoleChange(member, Array.from(new Set([...roles, value])));
|
|
906
|
+
}, onRemove: (value) => {
|
|
907
|
+
if (!isOrganizationRole(value))
|
|
908
|
+
return;
|
|
909
|
+
const nextRoles = roles.filter((role) => role !== value);
|
|
910
|
+
onRoleChange(member, nextRoles.length > 0 ? nextRoles : ["member"]);
|
|
882
911
|
} }));
|
|
883
912
|
},
|
|
884
913
|
},
|
|
@@ -58,6 +58,7 @@ declare const messages: {
|
|
|
58
58
|
readonly user_button_admin_users_description: "Review and manage users.";
|
|
59
59
|
readonly user_button_api_keys: "API keys";
|
|
60
60
|
readonly user_button_aria_label: "Open user menu";
|
|
61
|
+
readonly user_button_impersonating: "Impersonating";
|
|
61
62
|
readonly user_button_logout: "Log out";
|
|
62
63
|
readonly user_button_security: "Security";
|
|
63
64
|
readonly user_button_stop_impersonating: "Stop impersonating";
|
|
@@ -145,6 +146,7 @@ declare const messages: {
|
|
|
145
146
|
readonly user_button_admin_users_description: "Consultez et gérez les utilisateurs.";
|
|
146
147
|
readonly user_button_api_keys: "Clés API";
|
|
147
148
|
readonly user_button_aria_label: "Ouvrir le menu utilisateur";
|
|
149
|
+
readonly user_button_impersonating: "Imitation";
|
|
148
150
|
readonly user_button_logout: "Se déconnecter";
|
|
149
151
|
readonly user_button_security: "Sécurité";
|
|
150
152
|
readonly user_button_stop_impersonating: "Arrêter l'imitation";
|
|
@@ -82,6 +82,7 @@ const messages = {
|
|
|
82
82
|
user_button_admin_users_description: "Review and manage users.",
|
|
83
83
|
user_button_api_keys: "API keys",
|
|
84
84
|
user_button_aria_label: "Open user menu",
|
|
85
|
+
user_button_impersonating: "Impersonating",
|
|
85
86
|
user_button_logout: "Log out",
|
|
86
87
|
user_button_security: "Security",
|
|
87
88
|
user_button_stop_impersonating: "Stop impersonating",
|
|
@@ -169,6 +170,7 @@ const messages = {
|
|
|
169
170
|
user_button_admin_users_description: "Consultez et gérez les utilisateurs.",
|
|
170
171
|
user_button_api_keys: "Clés API",
|
|
171
172
|
user_button_aria_label: "Ouvrir le menu utilisateur",
|
|
173
|
+
user_button_impersonating: "Imitation",
|
|
172
174
|
user_button_logout: "Se déconnecter",
|
|
173
175
|
user_button_security: "Sécurité",
|
|
174
176
|
user_button_stop_impersonating: "Arrêter l'imitation",
|
|
@@ -317,6 +319,9 @@ export const UserButton = ({ authClient: providedAuthClient, baseUrl, signOutRed
|
|
|
317
319
|
const displayEmail = session.user.email.trim();
|
|
318
320
|
const displayImage = assetUrl(session.user.image, baseUrl);
|
|
319
321
|
const isImpersonating = Boolean(session.session.impersonatedBy);
|
|
322
|
+
const isOrganizationImpersonating = Boolean(session.session.impersonatedByOrganizationId);
|
|
323
|
+
const canManageUserSettings = !isOrganizationImpersonating;
|
|
324
|
+
const canUseAdminSettings = !isOrganizationImpersonating;
|
|
320
325
|
const isAdmin = hasAdminRole(session.user);
|
|
321
326
|
const signOut = async () => {
|
|
322
327
|
const redirectUrl = signOutRedirect.startsWith("http")
|
|
@@ -357,7 +362,7 @@ export const UserButton = ({ authClient: providedAuthClient, baseUrl, signOutRed
|
|
|
357
362
|
await refetch();
|
|
358
363
|
setSettingsDialog(null);
|
|
359
364
|
};
|
|
360
|
-
return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "outline", size: "icon", children: [displayImage ? (_jsx("img", { src: displayImage, alt: displayName || displayEmail, className: "size-full rounded-md object-cover" })) : (_jsx(UserIcon, { className: "size-4.5" })), _jsx("span", { className: "sr-only", children: m.user_button_aria_label() })] }) }), _jsx(DropdownMenuContent, { className: "w-56 rounded-lg", side: side, align: "end", sideOffset: 4, children: _jsxs(DropdownMenuGroup, { children: [_jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: _jsx(AppBrand, { to: null, label: displayName || displayEmail, subtitle: displayName ? displayEmail : m.user_button_account(), icon: UserIcon, className: "px-1 py-1.5 text-left text-sm", ...(displayImage ? { imageSrc: displayImage } : {}) }) }), _jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuItem, { disabled: isPending, onClick: () => setSettingsDialog("account"), children: [_jsx(UserCircleIcon, {}), m.user_button_account()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("security"), children: [_jsx(ShieldCheck, {}), m.user_button_security()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] }), _jsx(DropdownMenuSeparator, {}), isAdmin || isImpersonating ? (_jsxs(_Fragment, { children: [isAdmin ? (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("adminUsers"), children: [_jsx(Users, {}), m.user_button_admin_users()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("adminOrganizations"), children: [_jsx(Building2, {}), m.user_button_admin_organizations()] })] })) : null, isImpersonating ? (_jsxs(DropdownMenuItem, { disabled: isStoppingImpersonation, onClick: stopImpersonating, children: [_jsx(StopCircle, {}), m.user_button_stop_impersonating()] })) : null, _jsx(DropdownMenuSeparator, {})] })) : null, _jsxs(DropdownMenuItem, { onClick: signOut, children: [_jsx(LogOutIcon, {}), m.user_button_logout()] })] }) })] })), _jsx(Dialog, { open: settingsDialog === "account", onOpenChange: (open) => {
|
|
365
|
+
return (_jsxs(UserButtonMessagesContext.Provider, { value: m, children: [hideTrigger ? null : (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { render: _jsxs(Button, { variant: "outline", size: "icon", children: [displayImage ? (_jsx("img", { src: displayImage, alt: displayName || displayEmail, className: "size-full rounded-md object-cover" })) : (_jsx(UserIcon, { className: "size-4.5" })), _jsx("span", { className: "sr-only", children: m.user_button_aria_label() })] }) }), _jsx(DropdownMenuContent, { className: "w-56 rounded-lg", side: side, align: "end", sideOffset: 4, children: _jsxs(DropdownMenuGroup, { children: [isImpersonating ? (_jsx("div", { className: "px-1 py-0.5", children: _jsx(Badge, { variant: "secondary", className: "text-xs font-normal", children: m.user_button_impersonating() }) })) : null, _jsx(DropdownMenuLabel, { className: "p-0 font-normal", children: _jsx(AppBrand, { to: null, label: displayName || displayEmail, subtitle: displayName ? displayEmail : m.user_button_account(), icon: UserIcon, className: "px-1 py-1.5 text-left text-sm", ...(displayImage ? { imageSrc: displayImage } : {}) }) }), _jsx(DropdownMenuSeparator, {}), canManageUserSettings ? (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { disabled: isPending, onClick: () => setSettingsDialog("account"), children: [_jsx(UserCircleIcon, {}), m.user_button_account()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("security"), children: [_jsx(ShieldCheck, {}), m.user_button_security()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("apiKeys"), children: [_jsx(KeyRound, {}), m.user_button_api_keys()] }), _jsx(DropdownMenuSeparator, {})] })) : null, (isAdmin && canUseAdminSettings) || isImpersonating ? (_jsxs(_Fragment, { children: [isAdmin && canUseAdminSettings ? (_jsxs(_Fragment, { children: [_jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("adminUsers"), children: [_jsx(Users, {}), m.user_button_admin_users()] }), _jsxs(DropdownMenuItem, { onClick: () => setSettingsDialog("adminOrganizations"), children: [_jsx(Building2, {}), m.user_button_admin_organizations()] })] })) : null, isImpersonating ? (_jsxs(DropdownMenuItem, { disabled: isStoppingImpersonation, onClick: stopImpersonating, children: [_jsx(StopCircle, {}), m.user_button_stop_impersonating()] })) : null, _jsx(DropdownMenuSeparator, {})] })) : null, _jsxs(DropdownMenuItem, { onClick: signOut, children: [_jsx(LogOutIcon, {}), m.user_button_logout()] })] }) })] })), _jsx(Dialog, { open: canManageUserSettings && settingsDialog === "account", onOpenChange: (open) => {
|
|
361
366
|
setSettingsDialog((current) => open ? "account" : current === "account" ? null : current);
|
|
362
367
|
}, 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_form_title() }), _jsx(DialogDescription, { children: m.user_form_description() })] }), _jsx(Separator, {}), isPending ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.user_loading() })) : (_jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(UserForm, { defaultValues: {
|
|
363
368
|
name: displayName ?? "",
|
|
@@ -371,9 +376,9 @@ export const UserButton = ({ authClient: providedAuthClient, baseUrl, signOutRed
|
|
|
371
376
|
? error.message
|
|
372
377
|
: m.user_form_update_error());
|
|
373
378
|
}
|
|
374
|
-
} }), _jsx(Separator, {}), _jsx(ConnectedAccounts, { authClient: authClient, baseUrl: baseUrl, accountCache: accountCache, googleEnabled: projectConfig?.authOptions.google ?? true, currentSiteHref: currentSiteHref, navigate: navigate })] }))] }) }), _jsx(Dialog, { open: settingsDialog === "security", onOpenChange: (open) => {
|
|
379
|
+
} }), _jsx(Separator, {}), _jsx(ConnectedAccounts, { authClient: authClient, baseUrl: baseUrl, accountCache: accountCache, googleEnabled: projectConfig?.authOptions.google ?? true, currentSiteHref: currentSiteHref, navigate: navigate })] }))] }) }), _jsx(Dialog, { open: canManageUserSettings && settingsDialog === "security", onOpenChange: (open) => {
|
|
375
380
|
setSettingsDialog((current) => open ? "security" : current === "security" ? null : current);
|
|
376
|
-
}, 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_security_title() }), _jsx(DialogDescription, { children: m.user_security_description() })] }), _jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(PasswordSettings, { authClient: authClient, baseUrl: baseUrl, accountCache: accountCache }), _jsx(Separator, {}), _jsx(AccountSecuritySettings, { authClient: authClient, accountCache: accountCache })] })] }) }), _jsx(Dialog, { open: settingsDialog === "apiKeys", onOpenChange: (open) => {
|
|
381
|
+
}, 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_security_title() }), _jsx(DialogDescription, { children: m.user_security_description() })] }), _jsx(Separator, {}), _jsxs("div", { className: "flex flex-col gap-6", children: [_jsx(PasswordSettings, { authClient: authClient, baseUrl: baseUrl, accountCache: accountCache }), _jsx(Separator, {}), _jsx(AccountSecuritySettings, { authClient: authClient, accountCache: accountCache })] })] }) }), _jsx(Dialog, { open: canManageUserSettings && settingsDialog === "apiKeys", onOpenChange: (open) => {
|
|
377
382
|
setSettingsDialog((current) => open ? "apiKeys" : current === "apiKeys" ? null : current);
|
|
378
383
|
}, 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: m.user_api_keys_description() })] }), _jsx(Separator, {}), _jsx(ApiKeyManager, { authClient: authClient, active: settingsDialog === "apiKeys", permissions: apiKeyPermissions ?? {} })] }) }), isAdmin ? (_jsxs(_Fragment, { children: [_jsx(Dialog, { open: settingsDialog === "adminUsers", onOpenChange: (open) => {
|
|
379
384
|
setSettingsDialog((current) => open ? "adminUsers" : current === "adminUsers" ? null : current);
|
|
@@ -10,7 +10,7 @@ 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 ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getProjectPublicConfig", "GET", "/auth/project-config", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
|
|
13
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getProjectPublicConfig", "GET", "/auth/project-config", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
|
|
14
14
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
15
15
|
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
16
16
|
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -33,11 +33,11 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
33
33
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
34
34
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
35
35
|
readonly ok: import("effect/Schema").Boolean;
|
|
36
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"uploadUserImage", "POST", "/auth/image/upload", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/unstable/httpapi/HttpApiSchema").asMultipartStream<import("effect/Schema").Struct<{
|
|
36
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"uploadUserImage", "POST", "/auth/image/upload", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/unstable/httpapi/HttpApiSchema").asMultipartStream<import("effect/Schema").Struct<{
|
|
37
37
|
readonly file: import("effect/Schema").decodeTo<import("effect/unstable/http/Multipart").PersistedFileSchema, import("effect/Schema").$Array<import("effect/unstable/http/Multipart").PersistedFileSchema>, never, never>;
|
|
38
38
|
}>>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
39
39
|
readonly url: import("effect/Schema").String;
|
|
40
|
-
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyApiKey", "POST", "/auth/verify-api-key", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
40
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyApiKey", "POST", "/auth/verify-api-key", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
41
41
|
readonly key: import("effect/Schema").NonEmptyString;
|
|
42
42
|
readonly configId: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>>;
|
|
43
43
|
readonly permissions: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
@@ -65,4 +65,4 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
65
65
|
readonly password: import("effect/Schema").NonEmptyString;
|
|
66
66
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
67
67
|
readonly ok: import("effect/Schema").Boolean;
|
|
68
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never>, false>;
|
|
68
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never>, false>;
|