@krak-stack/auth 0.1.41 → 0.1.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/{api.d.ts → api.group.d.ts} +1 -0
- package/dist/admin/{api.js → api.group.js} +1 -0
- package/dist/api.d.ts +233 -241
- package/dist/api.js +5 -5
- package/dist/better-auth/{index.d.ts → api.group.d.ts} +6 -8
- package/dist/better-auth/{api.js → api.group.js} +2 -4
- package/dist/components/admin-organization-form.js +1 -1
- package/dist/components/auth-client-api.d.ts +16 -20
- package/dist/components/auth-client.d.ts +50 -4
- package/dist/components/auth-client.js +15 -1
- package/dist/components/auth-provider.d.ts +2 -1
- package/dist/components/auth-provider.js +8 -15
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +3 -1
- package/dist/components/organization-switcher.d.ts +2 -2
- package/dist/components/organization-switcher.js +17 -14
- package/dist/components/user-button.d.ts +2 -2
- package/dist/components/user-button.js +6 -3
- package/dist/extra/api.group.d.ts +68 -0
- package/dist/extra/{api.js → api.group.js} +5 -17
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/server/{api.d.ts → api.group.d.ts} +0 -196
- package/dist/server/{api.js → api.group.js} +1 -6
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/service.d.ts +12 -24
- package/package.json +11 -10
- package/dist/admin/index.d.ts +0 -2
- package/dist/admin/index.js +0 -2
- package/dist/better-auth/api.d.ts +0 -55
- package/dist/better-auth/index.js +0 -12
- package/dist/extra/api.d.ts +0 -139
- package/dist/extra/index.d.ts +0 -76
- package/dist/extra/index.js +0 -14
package/dist/api.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HttpApi, OpenApi } from "effect/unstable/httpapi";
|
|
2
|
-
import { AdminApiGroup } from "./admin/api";
|
|
3
|
-
import { BetterAuthApiGroup } from "./better-auth/api";
|
|
4
|
-
import { ExtraApiGroup } from "./extra/api";
|
|
5
|
-
import { ServerDomainsApiGroup, ServerOrganizationsApiGroup, ServerUsersApiGroup, } from "./server/api";
|
|
2
|
+
import { AdminApiGroup } from "./admin/api.group";
|
|
3
|
+
import { BetterAuthApiGroup } from "./better-auth/api.group";
|
|
4
|
+
import { ExtraApiGroup } from "./extra/api.group";
|
|
5
|
+
import { ServerDomainsApiGroup, ServerOrganizationsApiGroup, ServerUsersApiGroup, } from "./server/api.group";
|
|
6
6
|
export const AuthServiceApi = HttpApi.make("AuthServiceApi")
|
|
7
7
|
.annotateMerge(OpenApi.annotations({
|
|
8
8
|
title: "KrakStack Auth Service API",
|
|
@@ -17,5 +17,5 @@ export const AuthClientApi = HttpApi.make("AuthClientApi")
|
|
|
17
17
|
version: "1.0.0",
|
|
18
18
|
description: "Browser-facing API used by KrakStack Auth React components.",
|
|
19
19
|
}))
|
|
20
|
-
.add(ExtraApiGroup, AdminApiGroup)
|
|
20
|
+
.add(ExtraApiGroup, AdminApiGroup.prefix("/auth"))
|
|
21
21
|
.prefix("/api");
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/unstable/httpapi";
|
|
2
|
+
import { TooManyRequests } from "./schema";
|
|
3
|
+
export * from "./schema";
|
|
4
|
+
export type { Session, User } from "../schema";
|
|
5
|
+
export declare const BetterAuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndpoint.HttpApiEndpoint<"getSession", "GET", "/get-session", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").NullOr<import("effect/Schema").Struct<{
|
|
3
6
|
readonly session: import("effect/Schema").Struct<{
|
|
4
7
|
readonly id: import("effect/Schema").String;
|
|
5
8
|
readonly expiresAt: import("effect/Schema").Date;
|
|
@@ -24,9 +27,4 @@ declare const BetterAuthApiClient_base: AtomHttpApi.AtomHttpApiClient<BetterAuth
|
|
|
24
27
|
readonly createdAt: import("effect/Schema").Date;
|
|
25
28
|
readonly updatedAt: import("effect/Schema").Date;
|
|
26
29
|
}>;
|
|
27
|
-
}>>>,
|
|
28
|
-
export declare class BetterAuthApiClient extends BetterAuthApiClient_base {
|
|
29
|
-
}
|
|
30
|
-
export { BetterAuthApi, BetterAuthApiGroup } from "./api";
|
|
31
|
-
export * from "./schema";
|
|
32
|
-
export type { Session, User } from "../schema";
|
|
30
|
+
}>>>, HttpApiEndpoint.Json<typeof HttpApiError.BadRequest | typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError | typeof TooManyRequests>, never, never>, false>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OpenApi } from "effect/unstable/httpapi";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup, } from "effect/unstable/httpapi";
|
|
3
3
|
import { GetSessionResponse, TooManyRequests } from "./schema";
|
|
4
|
+
export * from "./schema";
|
|
4
5
|
export const BetterAuthApiGroup = HttpApiGroup.make("auth")
|
|
5
6
|
.add(HttpApiEndpoint.get("getSession", "/get-session", {
|
|
6
7
|
success: GetSessionResponse,
|
|
@@ -21,6 +22,3 @@ export const BetterAuthApiGroup = HttpApiGroup.make("auth")
|
|
|
21
22
|
title: "Better Auth",
|
|
22
23
|
description: "Better Auth-owned browser session endpoints.",
|
|
23
24
|
}));
|
|
24
|
-
export const BetterAuthApi = HttpApi.make("BetterAuthApi")
|
|
25
|
-
.add(BetterAuthApiGroup)
|
|
26
|
-
.prefix("/api/auth");
|
|
@@ -65,7 +65,7 @@ export function AdminOrganizationForm({ organization, onClose, onSaved, }) {
|
|
|
65
65
|
const baseUrl = auth?.baseUrl;
|
|
66
66
|
const createOrganization = useAtomSet(authClientApi(baseUrl).mutation("admin", "createOrganization"), { mode: "promise" });
|
|
67
67
|
const updateOrganization = useAtomSet(authClientApi(baseUrl).mutation("admin", "updateOrganization"), { mode: "promise" });
|
|
68
|
-
const uploadLogo = useAtomSet(authClientApi(baseUrl).mutation("authExtra", "
|
|
68
|
+
const uploadLogo = useAtomSet(authClientApi(baseUrl).mutation("authExtra", "uploadUserImage"), { mode: "promise" });
|
|
69
69
|
const [error, setError] = useState("");
|
|
70
70
|
const isEditing = Boolean(organization);
|
|
71
71
|
const form = useAppForm({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AtomHttpApi } from "effect/unstable/reactivity";
|
|
2
|
-
export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpApi.AtomHttpApiClient<object, `AuthClientApi:${string}`, import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"admin", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createDomain", "POST", "/api/admin/domains", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
2
|
+
export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpApi.AtomHttpApiClient<object, `AuthClientApi:${string}`, import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"admin", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createDomain", "POST", "/api/auth/admin/domains", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
3
3
|
readonly hostname: import("effect/Schema").NonEmptyString;
|
|
4
4
|
readonly rootHostname: import("effect/Schema").NonEmptyString;
|
|
5
5
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
@@ -20,7 +20,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
20
20
|
readonly active: import("effect/Schema").Boolean;
|
|
21
21
|
readonly createdAt: import("effect/Schema").Date;
|
|
22
22
|
readonly updatedAt: import("effect/Schema").Date;
|
|
23
|
-
}>>, 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").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createOrganization", "POST", "/api/admin/organizations", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
23
|
+
}>>, 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").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createOrganization", "POST", "/api/auth/admin/organizations", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
24
24
|
readonly name: import("effect/Schema").NonEmptyString;
|
|
25
25
|
readonly slug: import("effect/Schema").NonEmptyString;
|
|
26
26
|
readonly logo: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -31,7 +31,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
31
31
|
readonly logo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
32
32
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
33
33
|
readonly createdAt: import("effect/Schema").Date;
|
|
34
|
-
}>>, 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<"dashboardStats", "GET", "/api/admin/dashboard-stats", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
34
|
+
}>>, 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<"dashboardStats", "GET", "/api/auth/admin/dashboard-stats", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
35
35
|
readonly days: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"7">, import("effect/Schema").Literal<"14">, import("effect/Schema").Literal<"30">, import("effect/Schema").Literal<"90">]>>;
|
|
36
36
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
37
37
|
readonly totalUsers: import("effect/Schema").Number;
|
|
@@ -55,7 +55,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
55
55
|
readonly users: import("effect/Schema").Number;
|
|
56
56
|
readonly organizations: import("effect/Schema").Number;
|
|
57
57
|
}>>;
|
|
58
|
-
}>>, 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<"deleteDomain", "DELETE", "/api/admin/domains/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
58
|
+
}>>, 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<"deleteDomain", "DELETE", "/api/auth/admin/domains/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
59
59
|
readonly id: import("effect/Schema").NonEmptyString;
|
|
60
60
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
61
61
|
readonly id: import("effect/Schema").String;
|
|
@@ -72,7 +72,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
72
72
|
readonly active: import("effect/Schema").Boolean;
|
|
73
73
|
readonly createdAt: import("effect/Schema").Date;
|
|
74
74
|
readonly updatedAt: import("effect/Schema").Date;
|
|
75
|
-
}>>, 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<"deleteOrganization", "DELETE", "/api/admin/organizations/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
75
|
+
}>>, 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<"deleteOrganization", "DELETE", "/api/auth/admin/organizations/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
76
76
|
readonly id: import("effect/Schema").String;
|
|
77
77
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
78
78
|
readonly id: import("effect/Schema").String;
|
|
@@ -81,7 +81,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
81
81
|
readonly logo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
82
82
|
readonly metadata: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
83
83
|
readonly createdAt: import("effect/Schema").Date;
|
|
84
|
-
}>>, 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/admin/domains/:id/records", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
84
|
+
}>>, 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<{
|
|
85
85
|
readonly id: import("effect/Schema").NonEmptyString;
|
|
86
86
|
}>>, 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<{
|
|
87
87
|
readonly required: import("effect/Schema").Boolean;
|
|
@@ -89,7 +89,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
89
89
|
readonly type: import("effect/Schema").String;
|
|
90
90
|
readonly name: import("effect/Schema").String;
|
|
91
91
|
readonly value: import("effect/Schema").String;
|
|
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<"listDomains", "GET", "/api/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<{
|
|
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<"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<{
|
|
93
93
|
readonly id: import("effect/Schema").String;
|
|
94
94
|
readonly hostname: import("effect/Schema").String;
|
|
95
95
|
readonly rootHostname: import("effect/Schema").String;
|
|
@@ -104,7 +104,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
104
104
|
readonly active: import("effect/Schema").Boolean;
|
|
105
105
|
readonly createdAt: import("effect/Schema").Date;
|
|
106
106
|
readonly updatedAt: import("effect/Schema").Date;
|
|
107
|
-
}>>>, 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<"listOrganizations", "GET", "/api/admin/organizations", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
107
|
+
}>>>, 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<"listOrganizations", "GET", "/api/auth/admin/organizations", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
108
108
|
readonly page: import("effect/Schema").Int;
|
|
109
109
|
readonly pageSize: import("effect/Schema").Int;
|
|
110
110
|
readonly globalFilter: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -128,7 +128,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
128
128
|
readonly total: import("effect/Schema").Int;
|
|
129
129
|
readonly pageCount: import("effect/Schema").Int;
|
|
130
130
|
}>;
|
|
131
|
-
}>>, 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<"listUsers", "GET", "/api/admin/users", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
131
|
+
}>>, 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<"listUsers", "GET", "/api/auth/admin/users", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
132
132
|
readonly page: import("effect/Schema").Int;
|
|
133
133
|
readonly pageSize: import("effect/Schema").Int;
|
|
134
134
|
readonly globalFilter: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -156,7 +156,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
156
156
|
readonly total: import("effect/Schema").Int;
|
|
157
157
|
readonly pageCount: import("effect/Schema").Int;
|
|
158
158
|
}>;
|
|
159
|
-
}>>, 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<"updateDomain", "PATCH", "/api/admin/domains/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
159
|
+
}>>, 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<"updateDomain", "PATCH", "/api/auth/admin/domains/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
160
160
|
readonly id: import("effect/Schema").NonEmptyString;
|
|
161
161
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
162
162
|
readonly hostname: import("effect/Schema").NonEmptyString;
|
|
@@ -179,7 +179,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
179
179
|
readonly active: import("effect/Schema").Boolean;
|
|
180
180
|
readonly createdAt: import("effect/Schema").Date;
|
|
181
181
|
readonly updatedAt: import("effect/Schema").Date;
|
|
182
|
-
}>>, 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<"updateOrganization", "PATCH", "/api/admin/organizations/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
182
|
+
}>>, 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<"updateOrganization", "PATCH", "/api/auth/admin/organizations/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
|
|
183
183
|
readonly id: import("effect/Schema").String;
|
|
184
184
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
185
185
|
readonly name: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
|
|
@@ -200,7 +200,7 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
200
200
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
201
201
|
readonly id: import("effect/Schema").String;
|
|
202
202
|
readonly key: import("effect/Schema").String;
|
|
203
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra").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<{
|
|
203
|
+
}>>, 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<{
|
|
204
204
|
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
205
205
|
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
206
206
|
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
@@ -223,15 +223,11 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
223
223
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
224
224
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
225
225
|
readonly ok: import("effect/Schema").Boolean;
|
|
226
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"
|
|
226
|
+
}>>, 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<{
|
|
227
227
|
readonly file: import("effect/Schema").decodeTo<import("effect/unstable/http/Multipart").PersistedFileSchema, import("effect/Schema").$Array<import("effect/unstable/http/Multipart").PersistedFileSchema>, never, never>;
|
|
228
228
|
}>>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
229
229
|
readonly url: import("effect/Schema").String;
|
|
230
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").
|
|
231
|
-
readonly file: import("effect/Schema").decodeTo<import("effect/unstable/http/Multipart").PersistedFileSchema, import("effect/Schema").$Array<import("effect/unstable/http/Multipart").PersistedFileSchema>, never, never>;
|
|
232
|
-
}>>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
233
|
-
readonly url: import("effect/Schema").String;
|
|
234
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("../extra").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<{
|
|
230
|
+
}>>, 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<{
|
|
235
231
|
readonly key: import("effect/Schema").NonEmptyString;
|
|
236
232
|
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">]>>;
|
|
237
233
|
readonly permissions: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
@@ -255,8 +251,8 @@ export declare const authClientApi: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
255
251
|
readonly permissions: import("effect/Schema").NullOr<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
|
|
256
252
|
readonly metadata: import("effect/Schema").NullOr<import("effect/Schema").Unknown>;
|
|
257
253
|
}>>;
|
|
258
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"verifyPassword", "POST", "/api/auth/verify-password", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
254
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra/schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"verifyPassword", "POST", "/api/auth/verify-password", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
259
255
|
readonly password: import("effect/Schema").NonEmptyString;
|
|
260
256
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
261
257
|
readonly ok: import("effect/Schema").Boolean;
|
|
262
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra").ExtraBadRequest>, never, never>, false>>;
|
|
258
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra/schema").ExtraBadRequest>, never, never>, false>>;
|
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { apiKeyClient } from "@better-auth/api-key/client";
|
|
2
|
+
import { adminClient, emailOTPClient, genericOAuthClient, lastLoginMethodClient, organizationClient, twoFactorClient } from "better-auth/client/plugins";
|
|
3
|
+
import { createAuthClient } from "better-auth/react";
|
|
4
|
+
type Session = {
|
|
5
|
+
session: {
|
|
6
|
+
activeOrganizationId?: string | null | undefined;
|
|
7
|
+
impersonatedBy?: string | null | undefined;
|
|
8
|
+
};
|
|
9
|
+
user: {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
email: string;
|
|
13
|
+
image?: string | null | undefined;
|
|
14
|
+
role?: string | null | undefined;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
type Query<T> = {
|
|
18
|
+
data: T | null | undefined;
|
|
19
|
+
isPending: boolean;
|
|
20
|
+
refetch: () => Promise<unknown>;
|
|
21
|
+
};
|
|
22
|
+
type BaseAuthUiClient = ReturnType<typeof createAuthClient<{
|
|
5
23
|
plugins: [
|
|
6
24
|
ReturnType<typeof adminClient>,
|
|
7
25
|
ReturnType<typeof emailOTPClient>,
|
|
@@ -12,3 +30,31 @@ export type AuthUiClient = ReturnType<typeof createAuthClient<{
|
|
|
12
30
|
ReturnType<typeof genericOAuthClient>
|
|
13
31
|
];
|
|
14
32
|
}>>;
|
|
33
|
+
export type AuthUiClient = Omit<BaseAuthUiClient, "getSession" | "organization" | "useSession" | "useActiveOrganization" | "useActiveMemberRole"> & {
|
|
34
|
+
getSession: () => Promise<{
|
|
35
|
+
data: Session | null;
|
|
36
|
+
error: unknown;
|
|
37
|
+
}>;
|
|
38
|
+
organization: {
|
|
39
|
+
setActive: (input: {
|
|
40
|
+
organizationId: string;
|
|
41
|
+
}) => Promise<{
|
|
42
|
+
data: unknown;
|
|
43
|
+
error: unknown;
|
|
44
|
+
}>;
|
|
45
|
+
};
|
|
46
|
+
useSession: () => Query<Session>;
|
|
47
|
+
useActiveOrganization: () => Query<{
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
slug: string;
|
|
51
|
+
createdAt: Date | string;
|
|
52
|
+
members: unknown[];
|
|
53
|
+
invitations: unknown[];
|
|
54
|
+
}>;
|
|
55
|
+
useActiveMemberRole: () => Query<{
|
|
56
|
+
role: string;
|
|
57
|
+
}>;
|
|
58
|
+
};
|
|
59
|
+
export declare const createAuthUiClient: (baseUrl?: string | undefined) => AuthUiClient;
|
|
60
|
+
export {};
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { apiKeyClient } from "@better-auth/api-key/client";
|
|
2
|
+
import { adminClient, emailOTPClient, genericOAuthClient, lastLoginMethodClient, organizationClient, twoFactorClient, } from "better-auth/client/plugins";
|
|
3
|
+
import { createAuthClient } from "better-auth/react";
|
|
4
|
+
export const createAuthUiClient = (baseUrl) => createAuthClient({
|
|
5
|
+
...(baseUrl ? { baseURL: baseUrl } : {}),
|
|
6
|
+
plugins: [
|
|
7
|
+
adminClient(),
|
|
8
|
+
emailOTPClient(),
|
|
9
|
+
lastLoginMethodClient(),
|
|
10
|
+
organizationClient(),
|
|
11
|
+
twoFactorClient(),
|
|
12
|
+
apiKeyClient(),
|
|
13
|
+
genericOAuthClient(),
|
|
14
|
+
],
|
|
15
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import type
|
|
2
|
+
import { type AuthUiClient } from "./auth-client";
|
|
3
3
|
import type { ExtraProjectPublicConfig } from "../extra/schema";
|
|
4
4
|
export type KrakstackAuthLocale = "en" | "fr";
|
|
5
5
|
export type KrakstackAuthProviderProps = {
|
|
@@ -18,6 +18,7 @@ export type KrakstackAuthContextValue = {
|
|
|
18
18
|
};
|
|
19
19
|
export declare function KrakstackAuthProvider({ children, locale, baseUrl, projectId, authClient, }: KrakstackAuthProviderProps): import("react").JSX.Element;
|
|
20
20
|
export declare const useKrakstackAuth: () => KrakstackAuthContextValue | null;
|
|
21
|
+
export declare const useAuthClient: () => AuthUiClient;
|
|
21
22
|
export declare const useKrakstackAuthProjectConfig: () => import("effect/Schema").Struct.ReadonlySide<{
|
|
22
23
|
readonly projectKey: import("effect/Schema").String;
|
|
23
24
|
readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { apiKeyClient } from "@better-auth/api-key/client";
|
|
3
2
|
import { useAtomSuspense } from "@effect/atom-react";
|
|
4
3
|
import { useRouterState } from "@tanstack/react-router";
|
|
5
|
-
import { adminClient, emailOTPClient, genericOAuthClient, lastLoginMethodClient, organizationClient, twoFactorClient, } from "better-auth/client/plugins";
|
|
6
|
-
import { createAuthClient } from "better-auth/react";
|
|
7
4
|
import { createContext, useContext, useEffect, useMemo, } from "react";
|
|
5
|
+
import { createAuthUiClient } from "./auth-client";
|
|
8
6
|
import { authClientApi } from "./auth-client-api";
|
|
9
7
|
const KrakstackAuthContext = createContext(null);
|
|
10
8
|
const PROJECT_CONTEXT_COOKIE = "krakstack-auth.project_context";
|
|
@@ -18,18 +16,6 @@ const setProjectContextCookie = (projectId) => {
|
|
|
18
16
|
}
|
|
19
17
|
document.cookie = `${PROJECT_CONTEXT_COOKIE}=${encodeURIComponent(projectId)}; Path=/; Max-Age=600; SameSite=Lax${secure}`;
|
|
20
18
|
};
|
|
21
|
-
const createAuthUiClient = (baseUrl) => createAuthClient({
|
|
22
|
-
...(baseUrl ? { baseURL: baseUrl } : {}),
|
|
23
|
-
plugins: [
|
|
24
|
-
adminClient(),
|
|
25
|
-
emailOTPClient(),
|
|
26
|
-
lastLoginMethodClient(),
|
|
27
|
-
organizationClient(),
|
|
28
|
-
twoFactorClient(),
|
|
29
|
-
apiKeyClient(),
|
|
30
|
-
genericOAuthClient(),
|
|
31
|
-
],
|
|
32
|
-
});
|
|
33
19
|
const getSearchParam = (searchString, key) => {
|
|
34
20
|
if (!searchString)
|
|
35
21
|
return null;
|
|
@@ -101,4 +87,11 @@ export function KrakstackAuthProvider({ children, locale = "en", baseUrl, projec
|
|
|
101
87
|
return (_jsx(KrakstackAuthContext.Provider, { value: value, children: children }));
|
|
102
88
|
}
|
|
103
89
|
export const useKrakstackAuth = () => useContext(KrakstackAuthContext);
|
|
90
|
+
export const useAuthClient = () => {
|
|
91
|
+
const auth = useKrakstackAuth();
|
|
92
|
+
if (!auth?.authClient) {
|
|
93
|
+
throw new Error("KrakstackAuthProvider is required to use authClient.");
|
|
94
|
+
}
|
|
95
|
+
return auth.authClient;
|
|
96
|
+
};
|
|
104
97
|
export const useKrakstackAuthProjectConfig = () => useKrakstackAuth()?.projectConfig ?? null;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
export { KrakstackAuthProvider, useKrakstackAuth, useKrakstackAuthProjectConfig, } from "./auth-provider";
|
|
1
|
+
export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAuthProjectConfig, } from "./auth-provider";
|
|
2
|
+
export { createAuthUiClient } from "./auth-client";
|
|
2
3
|
export { OrganizationSwitcher } from "./organization-switcher";
|
|
3
4
|
export { ResetPassword, Signin, Signup, TwoFactor } from "./auth-forms";
|
|
4
5
|
export { UserButton } from "./user-button";
|
|
5
6
|
export { AdminOrganizationsTable } from "./admin-organizations";
|
|
6
7
|
export { AdminOrganizationForm } from "./admin-organization-form";
|
|
7
8
|
export { AdminUsersTable, useAdminUsersTotal } from "./admin-users";
|
|
9
|
+
export { assetUrl } from "./utils";
|
|
8
10
|
export type { KrakstackAuthContextValue, KrakstackAuthLocale, KrakstackAuthProviderProps, } from "./auth-provider";
|
|
9
11
|
export type { OrganizationSwitcherDialog } from "./organization-switcher";
|
|
10
12
|
export type { UserButtonDialog } from "./user-button";
|
package/dist/components/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
export { KrakstackAuthProvider, useKrakstackAuth, useKrakstackAuthProjectConfig, } from "./auth-provider";
|
|
1
|
+
export { KrakstackAuthProvider, useAuthClient, useKrakstackAuth, useKrakstackAuthProjectConfig, } from "./auth-provider";
|
|
2
|
+
export { createAuthUiClient } from "./auth-client";
|
|
2
3
|
export { OrganizationSwitcher } from "./organization-switcher";
|
|
3
4
|
export { ResetPassword, Signin, Signup, TwoFactor } from "./auth-forms";
|
|
4
5
|
export { UserButton } from "./user-button";
|
|
5
6
|
export { AdminOrganizationsTable } from "./admin-organizations";
|
|
6
7
|
export { AdminOrganizationForm } from "./admin-organization-form";
|
|
7
8
|
export { AdminUsersTable, useAdminUsersTotal } from "./admin-users";
|
|
9
|
+
export { assetUrl } from "./utils";
|
|
@@ -164,7 +164,7 @@ declare const messages: {
|
|
|
164
164
|
type OrganizationSwitcherMessageKey = keyof (typeof messages)["en"];
|
|
165
165
|
export type OrganizationSwitcherMessages = Partial<Record<OrganizationSwitcherMessageKey, string>>;
|
|
166
166
|
type OrganizationSwitcherProps = {
|
|
167
|
-
authClient
|
|
167
|
+
authClient?: AuthUiClient;
|
|
168
168
|
baseUrl?: string | undefined;
|
|
169
169
|
side?: ComponentProps<typeof DropdownMenuContent>["side"];
|
|
170
170
|
className?: string;
|
|
@@ -185,5 +185,5 @@ type OrganizationSummary = {
|
|
|
185
185
|
metadata?: unknown;
|
|
186
186
|
};
|
|
187
187
|
export type OrganizationSwitcherDialog = "create" | "manage" | "members" | "apiKeys" | "invitations";
|
|
188
|
-
export declare function OrganizationSwitcher({ authClient, baseUrl, side, className, defaultDialog, hideTrigger, renderUnauthenticated, locked, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }: OrganizationSwitcherProps): import("react").JSX.Element;
|
|
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;
|
|
189
189
|
export {};
|
|
@@ -18,6 +18,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "
|
|
|
18
18
|
import { Separator } from "@/components/ui/separator";
|
|
19
19
|
import { OrganizationMetadata, } from "@krak-stack/auth/schema";
|
|
20
20
|
import { authClientApi } from "./auth-client-api";
|
|
21
|
+
import { useAuthClient } from "./auth-provider";
|
|
21
22
|
import { createApiKey } from "./api-key";
|
|
22
23
|
import { useOpenedOnce } from "./hooks";
|
|
23
24
|
import { ExtraUploadedAsset } from "../extra/schema";
|
|
@@ -270,11 +271,11 @@ const isOrganizationSlugConflict = (error) => {
|
|
|
270
271
|
};
|
|
271
272
|
const nullableString = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
272
273
|
const decodeUploadedAsset = Schema.decodeUnknownPromise(ExtraUploadedAsset);
|
|
273
|
-
const
|
|
274
|
+
const uploadImageAsset = async (file, m, uploadImage) => {
|
|
274
275
|
const payload = new FormData();
|
|
275
276
|
payload.append("file", file);
|
|
276
277
|
try {
|
|
277
|
-
const uploaded = await decodeUploadedAsset(await
|
|
278
|
+
const uploaded = await decodeUploadedAsset(await uploadImage({ payload }));
|
|
278
279
|
return assetPath(uploaded.url);
|
|
279
280
|
}
|
|
280
281
|
catch {
|
|
@@ -328,9 +329,9 @@ const organizationFormDefaults = (organization, baseUrl) => {
|
|
|
328
329
|
frLocation: fr?.location ?? "",
|
|
329
330
|
};
|
|
330
331
|
};
|
|
331
|
-
const organizationLogoFromForm = async (value, m,
|
|
332
|
+
const organizationLogoFromForm = async (value, m, uploadImage) => {
|
|
332
333
|
if (value instanceof File)
|
|
333
|
-
return await
|
|
334
|
+
return await uploadImageAsset(value, m, uploadImage);
|
|
334
335
|
if (typeof value === "string")
|
|
335
336
|
return assetPath(value);
|
|
336
337
|
return null;
|
|
@@ -348,14 +349,14 @@ const organizationRoleLabel = (role, m) => {
|
|
|
348
349
|
}
|
|
349
350
|
};
|
|
350
351
|
const formatOrganizationDate = (date) => new Intl.DateTimeFormat(getLocale(), { dateStyle: "medium" }).format(new Date(date));
|
|
351
|
-
const organizationMetadataFromForm = async (value, m,
|
|
352
|
+
const organizationMetadataFromForm = async (value, m, uploadImage) => {
|
|
352
353
|
const translations = [];
|
|
353
354
|
const enName = value.enName.trim() || value.name.trim();
|
|
354
355
|
const frName = value.frName.trim();
|
|
355
|
-
const enLogo = await organizationLogoFromForm(value.enLogo, m,
|
|
356
|
-
const enIcon = await organizationLogoFromForm(value.enIcon, m,
|
|
357
|
-
const frLogo = await organizationLogoFromForm(value.frLogo, m,
|
|
358
|
-
const frIcon = await organizationLogoFromForm(value.frIcon, m,
|
|
356
|
+
const enLogo = await organizationLogoFromForm(value.enLogo, m, uploadImage);
|
|
357
|
+
const enIcon = await organizationLogoFromForm(value.enIcon, m, uploadImage);
|
|
358
|
+
const frLogo = await organizationLogoFromForm(value.frLogo, m, uploadImage);
|
|
359
|
+
const frIcon = await organizationLogoFromForm(value.frIcon, m, uploadImage);
|
|
359
360
|
if (enName) {
|
|
360
361
|
translations.push({
|
|
361
362
|
locale: "en",
|
|
@@ -378,7 +379,9 @@ const organizationMetadataFromForm = async (value, m, uploadOrganizationLogo) =>
|
|
|
378
379
|
}
|
|
379
380
|
return { translations };
|
|
380
381
|
};
|
|
381
|
-
export function OrganizationSwitcher({ authClient, baseUrl, side = "bottom", className, defaultDialog = null, hideTrigger = false, renderUnauthenticated, locked = false, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }) {
|
|
382
|
+
export function OrganizationSwitcher({ authClient: providedAuthClient, baseUrl, side = "bottom", className, defaultDialog = null, hideTrigger = false, renderUnauthenticated, locked = false, messages, dialog: controlledDialog, onChange, onCreate, onDialogChange, }) {
|
|
383
|
+
const contextAuthClient = useAuthClient();
|
|
384
|
+
const authClient = providedAuthClient ?? contextAuthClient;
|
|
382
385
|
const labels = organizationSwitcherMessages(messages);
|
|
383
386
|
const m = organizationMessageFns(labels);
|
|
384
387
|
const session = authClient.useSession();
|
|
@@ -562,7 +565,7 @@ const userInvitationRowActions = ({ m, actingInvitationId, onAccept, onReject, }
|
|
|
562
565
|
];
|
|
563
566
|
function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated, }) {
|
|
564
567
|
const m = useOrganizationMessages();
|
|
565
|
-
const
|
|
568
|
+
const uploadImage = useAtomSet(authClientApi(baseUrl).mutation("authExtra", "uploadUserImage"), { mode: "promise" });
|
|
566
569
|
const [editingLocale, setEditingLocale] = useState(currentOrganizationLocale());
|
|
567
570
|
const defaultValues = organizationFormDefaults(organization, baseUrl);
|
|
568
571
|
const form = useAppForm({
|
|
@@ -572,7 +575,7 @@ function EditOrganizationSection({ authClient, baseUrl, organization, onUpdated,
|
|
|
572
575
|
try {
|
|
573
576
|
const name = value.name.trim();
|
|
574
577
|
const slug = value.slug.trim().toLowerCase();
|
|
575
|
-
const metadata = await organizationMetadataFromForm(value, m,
|
|
578
|
+
const metadata = await organizationMetadataFromForm(value, m, uploadImage);
|
|
576
579
|
const result = await authClient.organization.update({
|
|
577
580
|
organizationId: organization.id,
|
|
578
581
|
data: { name, slug, metadata },
|
|
@@ -638,7 +641,7 @@ function CreateOrganizationSlugAutoFill({ form, }) {
|
|
|
638
641
|
}
|
|
639
642
|
function CreateOrganizationSection({ authClient, baseUrl, onCreated, }) {
|
|
640
643
|
const m = useOrganizationMessages();
|
|
641
|
-
const
|
|
644
|
+
const uploadImage = useAtomSet(authClientApi(baseUrl).mutation("authExtra", "uploadUserImage"), { mode: "promise" });
|
|
642
645
|
const [editingLocale, setEditingLocale] = useState(currentOrganizationLocale());
|
|
643
646
|
const defaultValues = organizationFormDefaults(undefined, baseUrl);
|
|
644
647
|
const form = useAppForm({
|
|
@@ -652,7 +655,7 @@ function CreateOrganizationSection({ authClient, baseUrl, onCreated, }) {
|
|
|
652
655
|
...value,
|
|
653
656
|
name,
|
|
654
657
|
slug,
|
|
655
|
-
}, m,
|
|
658
|
+
}, m, uploadImage);
|
|
656
659
|
const result = await authClient.organization.create({
|
|
657
660
|
name,
|
|
658
661
|
slug,
|
|
@@ -180,7 +180,7 @@ declare const messages: {
|
|
|
180
180
|
type UserButtonMessageKey = keyof (typeof messages)["en"];
|
|
181
181
|
export type UserButtonMessages = Partial<Record<UserButtonMessageKey, string>>;
|
|
182
182
|
type UserDropdownProps = {
|
|
183
|
-
authClient
|
|
183
|
+
authClient?: AuthUiClient;
|
|
184
184
|
baseUrl?: string | undefined;
|
|
185
185
|
signOutRedirect?: string;
|
|
186
186
|
side?: ComponentProps<typeof DropdownMenuContent>["side"];
|
|
@@ -193,5 +193,5 @@ type UserDropdownProps = {
|
|
|
193
193
|
onDialogChange?: (dialog: UserButtonDialog | null) => void;
|
|
194
194
|
};
|
|
195
195
|
export type UserButtonDialog = "account" | "security" | "apiKeys" | "adminUsers" | "adminOrganizations";
|
|
196
|
-
export declare const UserButton: ({ authClient, baseUrl, signOutRedirect, side, defaultDialog, hideTrigger, renderUnauthenticated, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }: UserDropdownProps) => import("react").JSX.Element;
|
|
196
|
+
export declare const UserButton: ({ authClient: providedAuthClient, baseUrl, signOutRedirect, side, defaultDialog, hideTrigger, renderUnauthenticated, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }: UserDropdownProps) => import("react").JSX.Element;
|
|
197
197
|
export {};
|
|
@@ -18,7 +18,7 @@ import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLeg
|
|
|
18
18
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
19
19
|
import { Separator } from "@/components/ui/separator";
|
|
20
20
|
import { authClientApi } from "./auth-client-api";
|
|
21
|
-
import {
|
|
21
|
+
import { useAuthClient, useKrakstackAuth } from "./auth-provider";
|
|
22
22
|
import { createApiKey } from "./api-key";
|
|
23
23
|
import { useOpenedOnce } from "./hooks";
|
|
24
24
|
import { ExtraUploadedAsset } from "../extra/schema";
|
|
@@ -268,10 +268,13 @@ const userApiKeysAtom = Atom.family((authClient) => Atom.keepAlive(Atom.make(Eff
|
|
|
268
268
|
catch: (error) => error,
|
|
269
269
|
}))));
|
|
270
270
|
const emptyApiKeysAtom = Atom.make(Effect.succeed([]));
|
|
271
|
-
export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side = "bottom", defaultDialog = null, hideTrigger = false, renderUnauthenticated, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }) => {
|
|
271
|
+
export const UserButton = ({ authClient: providedAuthClient, baseUrl, signOutRedirect = "/", side = "bottom", defaultDialog = null, hideTrigger = false, renderUnauthenticated, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }) => {
|
|
272
|
+
const auth = useKrakstackAuth();
|
|
273
|
+
const contextAuthClient = useAuthClient();
|
|
274
|
+
const authClient = providedAuthClient ?? contextAuthClient;
|
|
272
275
|
const labels = userButtonMessages(messages);
|
|
273
276
|
const m = userButtonMessageFns(labels);
|
|
274
|
-
const projectConfig =
|
|
277
|
+
const projectConfig = auth?.projectConfig ?? null;
|
|
275
278
|
const navigate = useNavigate();
|
|
276
279
|
const currentSiteHref = useRouterState({
|
|
277
280
|
select: (state) => `${import.meta.env.VITE_SITE_URL}${state.location.href}`,
|