@krak-stack/auth 0.1.56 → 0.1.58
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/access.d.ts +93 -0
- package/dist/access.js +97 -0
- package/dist/admin/api.group.d.ts +7 -0
- package/dist/admin/api.group.js +1 -1
- package/dist/admin/schema.d.ts +2 -0
- package/dist/admin/schema.js +4 -0
- package/dist/api.d.ts +23 -0
- package/dist/components/api-key-edit-form.d.ts +20 -0
- package/dist/components/api-key-edit-form.js +50 -0
- package/dist/components/api-key-rate-limit.d.ts +18 -0
- package/dist/components/api-key-rate-limit.js +29 -0
- package/dist/components/api-key-referrers.d.ts +8 -0
- package/dist/components/api-key-referrers.js +24 -0
- package/dist/components/api-key.d.ts +1 -0
- package/dist/components/api-key.js +20 -1
- package/dist/components/auth-client-api.d.ts +15 -0
- package/dist/components/auth-provider.d.ts +11 -1
- package/dist/components/auth-provider.js +29 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +2 -1
- package/dist/components/organization-switcher.d.ts +58 -3
- package/dist/components/organization-switcher.js +253 -70
- package/dist/components/user-button.d.ts +41 -3
- package/dist/components/user-button.js +134 -33
- package/dist/extra/api.group.d.ts +112 -103
- package/dist/extra/api.group.js +20 -1
- package/dist/extra/schema.d.ts +7 -0
- package/dist/extra/schema.js +18 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +1 -0
- package/dist/service.d.ts +26 -0
- package/package.json +5 -1
|
@@ -86,6 +86,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
86
86
|
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Number>;
|
|
87
87
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
88
88
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
89
|
+
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
89
90
|
readonly createdAt: import("effect/Schema").Date;
|
|
90
91
|
readonly updatedAt: import("effect/Schema").Date;
|
|
91
92
|
}>>, 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> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"deleteDomain", "DELETE", "/api/auth/admin/domains/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
@@ -144,6 +145,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
144
145
|
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Number>;
|
|
145
146
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
146
147
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
148
|
+
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
147
149
|
readonly createdAt: import("effect/Schema").Date;
|
|
148
150
|
readonly updatedAt: import("effect/Schema").Date;
|
|
149
151
|
}>>, 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> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"enableApiKeyRateLimit", "POST", "/api/auth/admin/api-keys/:id/enable-rate-limit", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
@@ -163,6 +165,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
163
165
|
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Number>;
|
|
164
166
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
165
167
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
168
|
+
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
166
169
|
readonly createdAt: import("effect/Schema").Date;
|
|
167
170
|
readonly updatedAt: import("effect/Schema").Date;
|
|
168
171
|
}>>, 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> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getDomainRecords", "GET", "/api/auth/admin/domains/:id/records", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
@@ -188,6 +191,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
188
191
|
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Number>;
|
|
189
192
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
190
193
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
194
|
+
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
191
195
|
readonly createdAt: import("effect/Schema").Date;
|
|
192
196
|
readonly updatedAt: import("effect/Schema").Date;
|
|
193
197
|
}>>>, 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>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"listDomains", "GET", "/api/auth/admin/domains", 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").$Array<import("effect/Schema").Struct<{
|
|
@@ -298,6 +302,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
298
302
|
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Number>;
|
|
299
303
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
300
304
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
305
|
+
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
301
306
|
readonly createdAt: import("effect/Schema").Date;
|
|
302
307
|
readonly updatedAt: import("effect/Schema").Date;
|
|
303
308
|
}>>, 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> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"updateApiKey", "PATCH", "/api/auth/admin/api-keys/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
@@ -308,6 +313,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
308
313
|
readonly rateLimitEnabled: import("effect/Schema").optional<import("effect/Schema").Boolean>;
|
|
309
314
|
readonly rateLimitMax: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").Number>>;
|
|
310
315
|
readonly rateLimitTimeWindow: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").Number>>;
|
|
316
|
+
readonly referrers: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").String>>;
|
|
311
317
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
312
318
|
readonly id: import("effect/Schema").String;
|
|
313
319
|
readonly configId: import("effect/Schema").String;
|
|
@@ -323,6 +329,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
323
329
|
readonly remaining: import("effect/Schema").NullOr<import("effect/Schema").Number>;
|
|
324
330
|
readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
325
331
|
readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
|
|
332
|
+
readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
|
|
326
333
|
readonly createdAt: import("effect/Schema").Date;
|
|
327
334
|
readonly updatedAt: import("effect/Schema").Date;
|
|
328
335
|
}>>, 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> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"updateDomain", "PATCH", "/api/auth/admin/domains/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
@@ -437,6 +444,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
437
444
|
readonly name: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
|
|
438
445
|
readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
439
446
|
readonly permissions: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
447
|
+
readonly referrers: import("effect/Schema").optional<import("effect/Schema").$Array<import("effect/Schema").String>>;
|
|
440
448
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
441
449
|
readonly id: import("effect/Schema").String;
|
|
442
450
|
readonly key: import("effect/Schema").String;
|
|
@@ -516,6 +524,13 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
516
524
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
517
525
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
518
526
|
readonly ok: import("effect/Schema").Boolean;
|
|
527
|
+
}>>, 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<"updateApiKeyPermissions", "PATCH", "/api/auth/api-key/:keyId/permissions", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
528
|
+
readonly keyId: import("effect/Schema").NonEmptyString;
|
|
529
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
530
|
+
readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
|
|
531
|
+
readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
|
|
532
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
533
|
+
readonly ok: import("effect/Schema").Boolean;
|
|
519
534
|
}>>, 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<{
|
|
520
535
|
readonly file: import("effect/Schema").decodeTo<import("effect/unstable/http/Multipart").PersistedFileSchema, import("effect/Schema").$Array<import("effect/unstable/http/Multipart").PersistedFileSchema>, never, never>;
|
|
521
536
|
}>>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type AuthUiClient } from "./auth-client";
|
|
3
3
|
import type { ExtraProjectPublicConfig } from "../extra/schema";
|
|
4
|
+
import type { ProjectAccessCatalog } from "../access";
|
|
4
5
|
export type KrakstackAuthLocale = "en" | "fr";
|
|
5
6
|
export type KrakstackAuthProviderProps = {
|
|
6
7
|
children: ReactNode;
|
|
@@ -8,6 +9,7 @@ export type KrakstackAuthProviderProps = {
|
|
|
8
9
|
baseUrl?: string | undefined;
|
|
9
10
|
projectId?: string | null | undefined;
|
|
10
11
|
authClient?: AuthUiClient | undefined;
|
|
12
|
+
access?: ProjectAccessCatalog | undefined;
|
|
11
13
|
};
|
|
12
14
|
export type KrakstackAuthContextValue = {
|
|
13
15
|
locale: KrakstackAuthLocale;
|
|
@@ -15,10 +17,11 @@ export type KrakstackAuthContextValue = {
|
|
|
15
17
|
projectId?: string | null | undefined;
|
|
16
18
|
authClient: AuthUiClient;
|
|
17
19
|
projectConfig: ExtraProjectPublicConfig | null;
|
|
20
|
+
access: ProjectAccessCatalog | null;
|
|
18
21
|
authRefreshVersion: number;
|
|
19
22
|
refreshAuth: () => void;
|
|
20
23
|
};
|
|
21
|
-
export declare function KrakstackAuthProvider({ children, locale, baseUrl, projectId, authClient, }: KrakstackAuthProviderProps): import("react").JSX.Element;
|
|
24
|
+
export declare function KrakstackAuthProvider({ children, locale, baseUrl, projectId, authClient, access, }: KrakstackAuthProviderProps): import("react").JSX.Element;
|
|
22
25
|
export declare const useKrakstackAuth: () => KrakstackAuthContextValue | null;
|
|
23
26
|
export declare const useAuthClient: () => AuthUiClient;
|
|
24
27
|
export declare const useKrakstackAuthProjectConfig: () => import("effect/Schema").Struct.ReadonlySide<{
|
|
@@ -36,3 +39,10 @@ export declare const useKrakstackAuthProjectConfig: () => import("effect/Schema"
|
|
|
36
39
|
readonly signUpName: import("effect/Schema").Boolean;
|
|
37
40
|
}>;
|
|
38
41
|
}, "Type"> | null;
|
|
42
|
+
export declare const usePermissions: () => {
|
|
43
|
+
loading: boolean;
|
|
44
|
+
permissions: Set<string>;
|
|
45
|
+
can: (action: string) => boolean;
|
|
46
|
+
canAll: (required: ReadonlyArray<string>) => boolean;
|
|
47
|
+
canAny: (required: ReadonlyArray<string>) => boolean;
|
|
48
|
+
};
|
|
@@ -4,6 +4,7 @@ import { useRouterState } from "@tanstack/react-router";
|
|
|
4
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
|
+
import { parseRoleList } from "../roles";
|
|
7
8
|
const KrakstackAuthContext = createContext(null);
|
|
8
9
|
const PROJECT_CONTEXT_COOKIE = "krakstack-auth.project_context";
|
|
9
10
|
const setProjectContextCookie = (projectId) => {
|
|
@@ -67,7 +68,7 @@ const useProjectConfig = (baseUrl, providedProjectId) => {
|
|
|
67
68
|
}), { suspendOnWaiting: true });
|
|
68
69
|
return result.value;
|
|
69
70
|
};
|
|
70
|
-
export function KrakstackAuthProvider({ children, locale = "en", baseUrl, projectId, authClient, }) {
|
|
71
|
+
export function KrakstackAuthProvider({ children, locale = "en", baseUrl, projectId, authClient, access, }) {
|
|
71
72
|
const searchString = useRouterState({
|
|
72
73
|
select: (state) => state.location.searchStr,
|
|
73
74
|
});
|
|
@@ -87,6 +88,7 @@ export function KrakstackAuthProvider({ children, locale = "en", baseUrl, projec
|
|
|
87
88
|
locale,
|
|
88
89
|
projectId: resolvedProjectId,
|
|
89
90
|
projectConfig,
|
|
91
|
+
access: access ?? null,
|
|
90
92
|
authRefreshVersion,
|
|
91
93
|
refreshAuth,
|
|
92
94
|
}), [
|
|
@@ -95,6 +97,7 @@ export function KrakstackAuthProvider({ children, locale = "en", baseUrl, projec
|
|
|
95
97
|
locale,
|
|
96
98
|
resolvedProjectId,
|
|
97
99
|
projectConfig,
|
|
100
|
+
access,
|
|
98
101
|
authRefreshVersion,
|
|
99
102
|
refreshAuth,
|
|
100
103
|
]);
|
|
@@ -109,3 +112,28 @@ export const useAuthClient = () => {
|
|
|
109
112
|
return auth.authClient;
|
|
110
113
|
};
|
|
111
114
|
export const useKrakstackAuthProjectConfig = () => useKrakstackAuth()?.projectConfig ?? null;
|
|
115
|
+
export const usePermissions = () => {
|
|
116
|
+
const auth = useKrakstackAuth();
|
|
117
|
+
if (!auth) {
|
|
118
|
+
throw new Error("KrakstackAuthProvider is required to use permissions.");
|
|
119
|
+
}
|
|
120
|
+
const session = auth.authClient.useSession();
|
|
121
|
+
const activeOrganization = auth.authClient.useActiveOrganization();
|
|
122
|
+
const memberRole = activeOrganization.data?.members.find((member) => member.userId === session.data?.user.id)?.role;
|
|
123
|
+
const actions = new Set();
|
|
124
|
+
if (auth.access) {
|
|
125
|
+
for (const role of parseRoleList(memberRole)) {
|
|
126
|
+
for (const action of auth.access.roles[role] ?? [])
|
|
127
|
+
actions.add(action);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
loading: session.isPending || activeOrganization.isPending,
|
|
132
|
+
permissions: auth.access
|
|
133
|
+
? new Set(Array.from(actions, (action) => `${auth.access?.project}:${action}`))
|
|
134
|
+
: new Set(),
|
|
135
|
+
can: (action) => actions.has(action),
|
|
136
|
+
canAll: (required) => required.every((action) => actions.has(action)),
|
|
137
|
+
canAny: (required) => required.some((action) => actions.has(action)),
|
|
138
|
+
};
|
|
139
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAuthProjectConfig, } from "./auth-provider";
|
|
1
|
+
export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAuthProjectConfig, usePermissions, } from "./auth-provider";
|
|
2
2
|
export { createAuthUiClient } from "./auth-client";
|
|
3
3
|
export { OrganizationSwitcher } from "./organization-switcher";
|
|
4
4
|
export { MemberRequired } from "./member-required";
|
|
@@ -8,6 +8,8 @@ export { AdminOrganizationsTable } from "./admin-organizations";
|
|
|
8
8
|
export { AdminOrganizationForm } from "./admin-organization-form";
|
|
9
9
|
export { AdminUsersTable, useAdminUsersTotal } from "./admin-users";
|
|
10
10
|
export { assetUrl } from "./utils";
|
|
11
|
+
export { ApiKeyPermissionGrant, CurrentPrincipal, Forbidden, all, any, defineProjectAccess, permission, policy, withPolicy, } from "../access";
|
|
12
|
+
export type { ApiKeyOwner, ApiKeyPrincipal, Policy, Principal, ProjectAccessConfig, ProjectAccessCatalog, ProjectAccessDefinition, UserPrincipal, } from "../access";
|
|
11
13
|
export type { KrakstackAuthContextValue, KrakstackAuthLocale, KrakstackAuthProviderProps, } from "./auth-provider";
|
|
12
14
|
export type { OrganizationSwitcherDialog, OrganizationSwitcherFeatures, OrganizationSwitcherProps, } from "./organization-switcher";
|
|
13
15
|
export type { UserButtonDialog } from "./user-button";
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAuthProjectConfig, } from "./auth-provider";
|
|
1
|
+
export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAuthProjectConfig, usePermissions, } from "./auth-provider";
|
|
2
2
|
export { createAuthUiClient } from "./auth-client";
|
|
3
3
|
export { OrganizationSwitcher } from "./organization-switcher";
|
|
4
4
|
export { MemberRequired } from "./member-required";
|
|
@@ -8,3 +8,4 @@ export { AdminOrganizationsTable } from "./admin-organizations";
|
|
|
8
8
|
export { AdminOrganizationForm } from "./admin-organization-form";
|
|
9
9
|
export { AdminUsersTable, useAdminUsersTotal } from "./admin-users";
|
|
10
10
|
export { assetUrl } from "./utils";
|
|
11
|
+
export { ApiKeyPermissionGrant, CurrentPrincipal, Forbidden, all, any, defineProjectAccess, permission, policy, withPolicy, } from "../access";
|
|
@@ -3,7 +3,7 @@ import { DropdownMenuContent } from "@/components/ui/dropdown-menu";
|
|
|
3
3
|
import type { AuthUiClient } from "./auth-client";
|
|
4
4
|
declare const messages: {
|
|
5
5
|
readonly en: {
|
|
6
|
-
readonly
|
|
6
|
+
readonly organization_back: "Back";
|
|
7
7
|
readonly organization_contact: "Contact methods";
|
|
8
8
|
readonly organization_contact_add_email: "Add email";
|
|
9
9
|
readonly organization_contact_add_phone: "Add phone";
|
|
@@ -75,6 +75,7 @@ declare const messages: {
|
|
|
75
75
|
readonly organization_member_role_error: "Could not update the member role.";
|
|
76
76
|
readonly organization_member_user: "User";
|
|
77
77
|
readonly organization_members_description: "Review active members, update roles, and remove access when needed.";
|
|
78
|
+
readonly organization_members_dialog_description: "Manage members and invitations for {name}.";
|
|
78
79
|
readonly organization_members_empty: "No members found.";
|
|
79
80
|
readonly organization_members_heading: "Organization members";
|
|
80
81
|
readonly organization_members_load_error: "Could not load organization members.";
|
|
@@ -95,24 +96,50 @@ declare const messages: {
|
|
|
95
96
|
readonly organization_translation_name: "Name";
|
|
96
97
|
readonly organization_update_error: "Could not update the organization.";
|
|
97
98
|
readonly table_empty: "No results.";
|
|
99
|
+
readonly user_api_key_back: "Back";
|
|
100
|
+
readonly user_api_key_create_description: "Configure a new API key for this organization.";
|
|
98
101
|
readonly user_api_key_create_error: "Could not create the API key.";
|
|
102
|
+
readonly user_api_key_create_title: "Create API key";
|
|
103
|
+
readonly user_api_key_copied: "Copied";
|
|
104
|
+
readonly user_api_key_copy: "Copy";
|
|
99
105
|
readonly user_api_key_created_description: "Copy this key now. You will not be able to see it again.";
|
|
100
106
|
readonly user_api_key_created_title: "API key created";
|
|
101
107
|
readonly user_api_key_delete_error: "Could not delete the API key.";
|
|
102
108
|
readonly user_api_key_disabled: "Disabled";
|
|
109
|
+
readonly user_api_key_edit_description: "Update the key name, status, and allowed referrers.";
|
|
110
|
+
readonly user_api_key_edit_title: "Edit API key";
|
|
103
111
|
readonly user_api_key_enabled: "Enabled";
|
|
104
112
|
readonly user_api_key_hidden: "Secret hidden";
|
|
105
113
|
readonly user_api_key_name: "Key name";
|
|
114
|
+
readonly user_api_key_no_permissions: "No permissions";
|
|
115
|
+
readonly user_api_key_permissions: "Permissions";
|
|
116
|
+
readonly user_api_key_permissions_description: "Choose the project permissions this API key should receive.";
|
|
117
|
+
readonly user_api_key_rate_limit: "Rate limit";
|
|
118
|
+
readonly user_api_key_referrers: "Allowed referrers (optional)";
|
|
119
|
+
readonly user_api_key_referrers_any: "Any referrer";
|
|
120
|
+
readonly user_api_key_referrers_column: "Referrers";
|
|
121
|
+
readonly user_api_key_referrers_description: "Enter any number of URLs, separated by commas or new lines. Leave empty to allow any referrer.";
|
|
122
|
+
readonly user_api_key_referrers_error: "{referrer} is not a valid HTTP(S) URL.";
|
|
123
|
+
readonly user_api_key_referrers_placeholder: "https://app.example.com\nhttps://admin.example.com";
|
|
106
124
|
readonly user_api_key_starts_with: "Starts with {start}";
|
|
107
125
|
readonly user_api_key_status: "Status";
|
|
126
|
+
readonly user_api_key_unlimited: "Unlimited";
|
|
127
|
+
readonly user_api_key_update_error: "Could not update the API key.";
|
|
128
|
+
readonly user_api_key_usage: "API key usage";
|
|
129
|
+
readonly user_api_key_window_days: "{count}d";
|
|
130
|
+
readonly user_api_key_window_hours: "{count}h";
|
|
131
|
+
readonly user_api_key_window_minutes: "{count}m";
|
|
132
|
+
readonly user_api_key_window_none: "None";
|
|
133
|
+
readonly user_api_key_window_seconds: "{count}s";
|
|
108
134
|
readonly user_api_keys_load_error: "Could not load API keys.";
|
|
135
|
+
readonly user_api_keys_organization_description: "Create and manage API keys for {name}.";
|
|
109
136
|
readonly user_api_keys_title: "API keys";
|
|
110
137
|
readonly user_button_api_keys: "API keys";
|
|
111
138
|
readonly user_delete: "Delete";
|
|
112
139
|
readonly user_loading: "Loading...";
|
|
113
140
|
};
|
|
114
141
|
readonly fr: {
|
|
115
|
-
readonly
|
|
142
|
+
readonly organization_back: "Retour";
|
|
116
143
|
readonly organization_contact: "Moyens de contact";
|
|
117
144
|
readonly organization_contact_add_email: "Ajouter un courriel";
|
|
118
145
|
readonly organization_contact_add_phone: "Ajouter un téléphone";
|
|
@@ -184,6 +211,7 @@ declare const messages: {
|
|
|
184
211
|
readonly organization_member_role_error: "Impossible de modifier le rôle du membre.";
|
|
185
212
|
readonly organization_member_user: "Utilisateur";
|
|
186
213
|
readonly organization_members_description: "Consultez les membres actifs, modifiez les rôles et retirez les accès au besoin.";
|
|
214
|
+
readonly organization_members_dialog_description: "Gérez les membres et les invitations de {name}.";
|
|
187
215
|
readonly organization_members_empty: "Aucun membre trouvé.";
|
|
188
216
|
readonly organization_members_heading: "Membres de l'organisation";
|
|
189
217
|
readonly organization_members_load_error: "Impossible de charger les membres de l'organisation.";
|
|
@@ -204,17 +232,43 @@ declare const messages: {
|
|
|
204
232
|
readonly organization_translation_name: "Nom";
|
|
205
233
|
readonly organization_update_error: "Impossible de mettre à jour l'organisation.";
|
|
206
234
|
readonly table_empty: "Aucun résultat.";
|
|
235
|
+
readonly user_api_key_back: "Retour";
|
|
236
|
+
readonly user_api_key_create_description: "Configurez une nouvelle clé API pour cette organisation.";
|
|
207
237
|
readonly user_api_key_create_error: "Impossible de créer la clé API.";
|
|
238
|
+
readonly user_api_key_create_title: "Créer une clé API";
|
|
239
|
+
readonly user_api_key_copied: "Copié";
|
|
240
|
+
readonly user_api_key_copy: "Copier";
|
|
208
241
|
readonly user_api_key_created_description: "Copiez cette clé maintenant. Vous ne pourrez plus la voir.";
|
|
209
242
|
readonly user_api_key_created_title: "Clé API créée";
|
|
210
243
|
readonly user_api_key_delete_error: "Impossible de supprimer la clé API.";
|
|
211
244
|
readonly user_api_key_disabled: "Désactivée";
|
|
245
|
+
readonly user_api_key_edit_description: "Mettez à jour le nom, le statut et les référents autorisés de la clé.";
|
|
246
|
+
readonly user_api_key_edit_title: "Modifier la clé API";
|
|
212
247
|
readonly user_api_key_enabled: "Activée";
|
|
213
248
|
readonly user_api_key_hidden: "Secret masqué";
|
|
214
249
|
readonly user_api_key_name: "Nom de la clé";
|
|
250
|
+
readonly user_api_key_no_permissions: "Aucune autorisation";
|
|
251
|
+
readonly user_api_key_permissions: "Autorisations";
|
|
252
|
+
readonly user_api_key_permissions_description: "Choisissez les autorisations de projet à attribuer à cette clé API.";
|
|
253
|
+
readonly user_api_key_rate_limit: "Limite de débit";
|
|
254
|
+
readonly user_api_key_referrers: "Référents autorisés (facultatifs)";
|
|
255
|
+
readonly user_api_key_referrers_any: "Tout référent";
|
|
256
|
+
readonly user_api_key_referrers_column: "Référents";
|
|
257
|
+
readonly user_api_key_referrers_description: "Saisissez autant d'URL que nécessaire, séparées par des virgules ou des sauts de ligne. Laissez vide pour autoriser tout référent.";
|
|
258
|
+
readonly user_api_key_referrers_error: "{referrer} n'est pas une URL HTTP(S) valide.";
|
|
259
|
+
readonly user_api_key_referrers_placeholder: "https://app.example.com\nhttps://admin.example.com";
|
|
215
260
|
readonly user_api_key_starts_with: "Commence par {start}";
|
|
216
261
|
readonly user_api_key_status: "Statut";
|
|
262
|
+
readonly user_api_key_unlimited: "Illimitée";
|
|
263
|
+
readonly user_api_key_update_error: "Impossible de mettre à jour la clé API.";
|
|
264
|
+
readonly user_api_key_usage: "Utilisation de la clé API";
|
|
265
|
+
readonly user_api_key_window_days: "{count} j";
|
|
266
|
+
readonly user_api_key_window_hours: "{count} h";
|
|
267
|
+
readonly user_api_key_window_minutes: "{count} min";
|
|
268
|
+
readonly user_api_key_window_none: "Aucune";
|
|
269
|
+
readonly user_api_key_window_seconds: "{count} s";
|
|
217
270
|
readonly user_api_keys_load_error: "Impossible de charger les clés API.";
|
|
271
|
+
readonly user_api_keys_organization_description: "Créez et gérez les clés API de {name}.";
|
|
218
272
|
readonly user_api_keys_title: "Clés API";
|
|
219
273
|
readonly user_button_api_keys: "Clés API";
|
|
220
274
|
readonly user_delete: "Supprimer";
|
|
@@ -244,6 +298,7 @@ export type OrganizationSwitcherProps = {
|
|
|
244
298
|
onChange?: (organization: OrganizationSummary | null) => void;
|
|
245
299
|
onCreate?: (organization: OrganizationSummary) => void;
|
|
246
300
|
onDialogChange?: (dialog: OrganizationSwitcherDialog | null) => void;
|
|
301
|
+
apiKeyPermissions?: Readonly<Record<string, ReadonlyArray<string>>>;
|
|
247
302
|
};
|
|
248
303
|
type OrganizationSummary = {
|
|
249
304
|
id: string;
|
|
@@ -254,5 +309,5 @@ type OrganizationSummary = {
|
|
|
254
309
|
parentId?: string | null;
|
|
255
310
|
};
|
|
256
311
|
export type OrganizationSwitcherDialog = "create" | "manage" | "members" | "apiKeys" | "invitations";
|
|
257
|
-
export declare function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side, className, defaultDialog, features, hideTrigger, menuActions, renderUnauthenticated, allowedOrganizationIds, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }: OrganizationSwitcherProps): import("react").JSX.Element;
|
|
312
|
+
export declare function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side, className, defaultDialog, features, hideTrigger, menuActions, renderUnauthenticated, allowedOrganizationIds, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, apiKeyPermissions, }: OrganizationSwitcherProps): import("react").JSX.Element;
|
|
258
313
|
export {};
|