@krak-stack/auth 0.1.30 → 0.1.31
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/api.d.ts +19 -1
- package/dist/components/auth-api-client.d.ts +19 -1
- package/dist/components/auth-forms.d.ts +7 -8
- package/dist/components/auth-forms.js +30 -7
- package/dist/extra/api.d.ts +38 -2
- package/dist/extra/api.js +10 -1
- package/dist/extra/index.d.ts +19 -1
- package/dist/extra/schema.d.ts +29 -0
- package/dist/extra/schema.js +66 -0
- package/dist/service.d.ts +44 -0
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -31,7 +31,25 @@ export declare const AuthApi: HttpApi.HttpApi<"AuthApi", import("effect/unstable
|
|
|
31
31
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
32
32
|
readonly id: import("effect/Schema").String;
|
|
33
33
|
readonly key: import("effect/Schema").String;
|
|
34
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./extra").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"
|
|
34
|
+
}>>, 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<{
|
|
35
|
+
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
36
|
+
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
37
|
+
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
38
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
39
|
+
readonly projectKey: import("effect/Schema").String;
|
|
40
|
+
readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
41
|
+
readonly logoUrl: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
42
|
+
readonly authDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
43
|
+
readonly rootDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
44
|
+
readonly themeCss: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
45
|
+
readonly authOptions: import("effect/Schema").Struct<{
|
|
46
|
+
readonly emailPassword: import("effect/Schema").Boolean;
|
|
47
|
+
readonly emailOtp: import("effect/Schema").Boolean;
|
|
48
|
+
readonly google: import("effect/Schema").Boolean;
|
|
49
|
+
readonly signUp: import("effect/Schema").Boolean;
|
|
50
|
+
readonly signUpName: import("effect/Schema").Boolean;
|
|
51
|
+
}>;
|
|
52
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"setPassword", "POST", "/api/auth/set-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<{
|
|
35
53
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
36
54
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
37
55
|
readonly ok: import("effect/Schema").Boolean;
|
|
@@ -31,7 +31,25 @@ export declare const authApiClient: (baseUrl?: string | undefined) => AtomHttpAp
|
|
|
31
31
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
32
32
|
readonly id: import("effect/Schema").String;
|
|
33
33
|
readonly key: import("effect/Schema").String;
|
|
34
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"
|
|
34
|
+
}>>, 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<{
|
|
35
|
+
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
36
|
+
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
37
|
+
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
38
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
39
|
+
readonly projectKey: import("effect/Schema").String;
|
|
40
|
+
readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
41
|
+
readonly logoUrl: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
42
|
+
readonly authDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
43
|
+
readonly rootDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
44
|
+
readonly themeCss: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
45
|
+
readonly authOptions: import("effect/Schema").Struct<{
|
|
46
|
+
readonly emailPassword: import("effect/Schema").Boolean;
|
|
47
|
+
readonly emailOtp: import("effect/Schema").Boolean;
|
|
48
|
+
readonly google: import("effect/Schema").Boolean;
|
|
49
|
+
readonly signUp: import("effect/Schema").Boolean;
|
|
50
|
+
readonly signUpName: import("effect/Schema").Boolean;
|
|
51
|
+
}>;
|
|
52
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"setPassword", "POST", "/api/auth/set-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<{
|
|
35
53
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
36
54
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
37
55
|
readonly ok: import("effect/Schema").Boolean;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { AuthUiClient } from "./auth-client";
|
|
2
|
-
|
|
2
|
+
type AuthFormProps = {
|
|
3
3
|
authClient: AuthUiClient;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}): import("react").JSX.Element;
|
|
4
|
+
baseUrl?: string | undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare function Signin({ authClient, baseUrl }: AuthFormProps): import("react").JSX.Element;
|
|
7
|
+
export declare function Signup({ authClient, baseUrl }: AuthFormProps): import("react").JSX.Element;
|
|
8
8
|
export declare function ResetPassword({ authClient }: {
|
|
9
9
|
authClient: AuthUiClient;
|
|
10
10
|
}): import("react").JSX.Element;
|
|
11
|
-
export declare function TwoFactor({ authClient }:
|
|
12
|
-
|
|
13
|
-
}): import("react").JSX.Element;
|
|
11
|
+
export declare function TwoFactor({ authClient, baseUrl }: AuthFormProps): import("react").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// @ts-nocheck
|
|
3
|
+
import { useAtomSuspense } from "@effect/atom-react";
|
|
3
4
|
import { useNavigate, useRouterState } from "@tanstack/react-router";
|
|
4
5
|
import { REGEXP_ONLY_DIGITS } from "input-otp";
|
|
5
6
|
import { KeyRound, Mail } from "lucide-react";
|
|
@@ -10,7 +11,7 @@ import { Field, FieldLabel } from "@/components/ui/field";
|
|
|
10
11
|
import { FieldError, useAppForm } from "@/components/ui/form";
|
|
11
12
|
import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, } from "@/components/ui/input-otp";
|
|
12
13
|
import { cn } from "@/lib/utils";
|
|
13
|
-
import {
|
|
14
|
+
import { authApiClient } from "./auth-api-client";
|
|
14
15
|
const EMAIL_OTP_RESEND_COOLDOWN_SECONDS = 60;
|
|
15
16
|
const defaultMessages = {
|
|
16
17
|
en: {
|
|
@@ -119,17 +120,38 @@ const defaultMessages = {
|
|
|
119
120
|
const labels = () => ({
|
|
120
121
|
...defaultMessages[currentLocale()],
|
|
121
122
|
});
|
|
123
|
+
const useAuthProjectConfig = (baseUrl, searchString) => {
|
|
124
|
+
const projectId = getSearchParam(searchString, "projectId");
|
|
125
|
+
const clientId = getSearchParam(searchString, "client_id");
|
|
126
|
+
const host = getBrowserAuthHost();
|
|
127
|
+
const result = useAtomSuspense(authApiClient(baseUrl).query("authExtra", "getProjectPublicConfig", {
|
|
128
|
+
query: {
|
|
129
|
+
...(projectId ? { projectId } : {}),
|
|
130
|
+
...(clientId ? { clientId } : {}),
|
|
131
|
+
...(host ? { host } : {}),
|
|
132
|
+
},
|
|
133
|
+
timeToLive: "5 minutes",
|
|
134
|
+
reactivityKeys: [
|
|
135
|
+
"project-public-config",
|
|
136
|
+
...(projectId ? [`project:${projectId}`] : []),
|
|
137
|
+
...(clientId ? [`client:${clientId}`] : []),
|
|
138
|
+
...(host ? [`host:${host}`] : []),
|
|
139
|
+
],
|
|
140
|
+
serializationKey: `project-public-config:${projectId ?? ""}:${clientId ?? ""}:${host ?? ""}`,
|
|
141
|
+
}), { suspendOnWaiting: true });
|
|
142
|
+
return result.value;
|
|
143
|
+
};
|
|
122
144
|
const currentLocale = () => typeof navigator !== "undefined" &&
|
|
123
145
|
navigator.language.toLowerCase().startsWith("fr")
|
|
124
146
|
? "fr"
|
|
125
147
|
: "en";
|
|
126
148
|
const text = (value, params) => Object.entries(params ?? {}).reduce((current, [key, replacement]) => current.replace(`{${key}}`, replacement), value);
|
|
127
|
-
export function Signin({ authClient }) {
|
|
149
|
+
export function Signin({ authClient, baseUrl }) {
|
|
128
150
|
const navigate = useNavigate();
|
|
129
151
|
const searchString = useRouterState({
|
|
130
152
|
select: (state) => state.location.searchStr,
|
|
131
153
|
});
|
|
132
|
-
const projectConfig =
|
|
154
|
+
const projectConfig = useAuthProjectConfig(baseUrl, searchString);
|
|
133
155
|
const redirectTarget = getRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
|
|
134
156
|
const socialRedirectTarget = getSocialRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
|
|
135
157
|
const oauthQuery = getOAuthQuery(searchString);
|
|
@@ -321,12 +343,12 @@ export function Signin({ authClient }) {
|
|
|
321
343
|
? m.sign_in_email_otp_verify
|
|
322
344
|
: m.auth_sign_in }) })] }) })) : null, options.google && !emailSubmitted ? (_jsxs("div", { className: "mt-4 flex flex-col gap-3", children: [hasPrimaryAuth ? (_jsx(Divider, { label: m.auth_or_continue_with })) : null, _jsxs(Button, { type: "button", variant: "outline", className: "w-full", onClick: signInWithGoogle, children: [_jsx(GoogleLogo, {}), m.auth_continue_with_google] })] })) : null, !hasPrimaryAuth && !options.google ? (_jsx("p", { className: "text-muted-foreground text-sm", children: m.oauth_client_no_auth_methods })) : null, options.signUp ? (_jsxs("p", { className: "text-muted-foreground mt-6 text-center text-sm", children: [m.sign_in_need_account, " ", _jsx("a", { className: cn(buttonVariants({ variant: "link" }), "h-auto px-0"), href: `/sign-up${searchString}`, children: m.auth_sign_up })] })) : null] })] }));
|
|
323
345
|
}
|
|
324
|
-
export function Signup({ authClient }) {
|
|
346
|
+
export function Signup({ authClient, baseUrl }) {
|
|
325
347
|
const navigate = useNavigate();
|
|
326
348
|
const searchString = useRouterState({
|
|
327
349
|
select: (state) => state.location.searchStr,
|
|
328
350
|
});
|
|
329
|
-
const projectConfig =
|
|
351
|
+
const projectConfig = useAuthProjectConfig(baseUrl, searchString);
|
|
330
352
|
const redirectTarget = getRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
|
|
331
353
|
const authOptions = projectConfig?.authOptions ?? {};
|
|
332
354
|
const onNavigate = (target) => navigate({ href: target });
|
|
@@ -445,12 +467,12 @@ export function ResetPassword({ authClient }) {
|
|
|
445
467
|
form.handleSubmit();
|
|
446
468
|
}, children: [_jsx(form.AppField, { name: "password", children: (field) => (_jsx(field.TextField, { label: m.reset_password_new_password, type: "password", autoComplete: "new-password", minLength: 8, required: true })) }), _jsx(form.FormError, {}), _jsx(form.SubmitButton, {})] }) }) })] }));
|
|
447
469
|
}
|
|
448
|
-
export function TwoFactor({ authClient }) {
|
|
470
|
+
export function TwoFactor({ authClient, baseUrl }) {
|
|
449
471
|
const navigate = useNavigate();
|
|
450
472
|
const searchString = useRouterState({
|
|
451
473
|
select: (state) => state.location.searchStr,
|
|
452
474
|
});
|
|
453
|
-
const projectConfig =
|
|
475
|
+
const projectConfig = useAuthProjectConfig(baseUrl, searchString);
|
|
454
476
|
const redirectTarget = getRedirectTarget(searchString, projectConfig?.authDomain, projectConfig?.rootDomain);
|
|
455
477
|
const oauthQuery = getOAuthQuery(searchString);
|
|
456
478
|
const onNavigate = (target) => navigateTarget(target, navigate);
|
|
@@ -621,6 +643,7 @@ const normalizeAuthHost = (value) => {
|
|
|
621
643
|
}
|
|
622
644
|
};
|
|
623
645
|
const getSearchParam = (searchString, key) => new URLSearchParams(searchString).get(key);
|
|
646
|
+
const getBrowserAuthHost = () => typeof window === "undefined" ? null : window.location.host;
|
|
624
647
|
const navigateTarget = (target, navigate) => {
|
|
625
648
|
if (shouldUseDocumentRedirect(target)) {
|
|
626
649
|
navigate({ href: target });
|
package/dist/extra/api.d.ts
CHANGED
|
@@ -9,7 +9,25 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
9
9
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
10
10
|
readonly id: import("effect/Schema").String;
|
|
11
11
|
readonly key: import("effect/Schema").String;
|
|
12
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
12
|
+
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getProjectPublicConfig", "GET", "/auth/project-config", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
|
|
13
|
+
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
14
|
+
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
15
|
+
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
16
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
17
|
+
readonly projectKey: import("effect/Schema").String;
|
|
18
|
+
readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
19
|
+
readonly logoUrl: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
20
|
+
readonly authDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
21
|
+
readonly rootDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
22
|
+
readonly themeCss: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
23
|
+
readonly authOptions: import("effect/Schema").Struct<{
|
|
24
|
+
readonly emailPassword: import("effect/Schema").Boolean;
|
|
25
|
+
readonly emailOtp: import("effect/Schema").Boolean;
|
|
26
|
+
readonly google: import("effect/Schema").Boolean;
|
|
27
|
+
readonly signUp: import("effect/Schema").Boolean;
|
|
28
|
+
readonly signUpName: import("effect/Schema").Boolean;
|
|
29
|
+
}>;
|
|
30
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"setPassword", "POST", "/auth/set-password", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
13
31
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
14
32
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
15
33
|
readonly ok: import("effect/Schema").Boolean;
|
|
@@ -58,7 +76,25 @@ export declare const ExtraApi: HttpApi.HttpApi<"ExtraApi", HttpApiGroup.HttpApiG
|
|
|
58
76
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
59
77
|
readonly id: import("effect/Schema").String;
|
|
60
78
|
readonly key: import("effect/Schema").String;
|
|
61
|
-
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"
|
|
79
|
+
}>>, HttpApiEndpoint.Json<typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getProjectPublicConfig", "GET", "/api/auth/project-config", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<import("effect/Schema").Struct<{
|
|
80
|
+
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
81
|
+
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
82
|
+
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
83
|
+
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
84
|
+
readonly projectKey: import("effect/Schema").String;
|
|
85
|
+
readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
86
|
+
readonly logoUrl: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
87
|
+
readonly authDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
88
|
+
readonly rootDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
89
|
+
readonly themeCss: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
90
|
+
readonly authOptions: import("effect/Schema").Struct<{
|
|
91
|
+
readonly emailPassword: import("effect/Schema").Boolean;
|
|
92
|
+
readonly emailOtp: import("effect/Schema").Boolean;
|
|
93
|
+
readonly google: import("effect/Schema").Boolean;
|
|
94
|
+
readonly signUp: import("effect/Schema").Boolean;
|
|
95
|
+
readonly signUpName: import("effect/Schema").Boolean;
|
|
96
|
+
}>;
|
|
97
|
+
}>>, HttpApiEndpoint.Json<typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"setPassword", "POST", "/api/auth/set-password", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
62
98
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
63
99
|
}>>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").Struct<{
|
|
64
100
|
readonly ok: import("effect/Schema").Boolean;
|
package/dist/extra/api.js
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { HttpApi, OpenApi } from "effect/unstable/httpapi";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup, } from "effect/unstable/httpapi";
|
|
3
|
-
import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraSetPasswordPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema";
|
|
3
|
+
import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraProjectPublicConfig, ExtraProjectPublicConfigQuery, ExtraSetPasswordPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema";
|
|
4
4
|
export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
5
|
+
.add(HttpApiEndpoint.get("getProjectPublicConfig", "/auth/project-config", {
|
|
6
|
+
query: ExtraProjectPublicConfigQuery,
|
|
7
|
+
success: ExtraProjectPublicConfig,
|
|
8
|
+
error: [HttpApiError.InternalServerError],
|
|
9
|
+
}).annotateMerge(OpenApi.annotations({
|
|
10
|
+
title: "Get project public config",
|
|
11
|
+
summary: "Get host-aware project white-label config",
|
|
12
|
+
description: "Returns resolved public branding and authentication options through the proxied auth API.",
|
|
13
|
+
})))
|
|
5
14
|
.add(HttpApiEndpoint.post("setPassword", "/auth/set-password", {
|
|
6
15
|
payload: ExtraSetPasswordPayload,
|
|
7
16
|
success: ExtraOkResponse,
|
package/dist/extra/index.d.ts
CHANGED
|
@@ -7,7 +7,25 @@ declare const ExtraApiClient_base: AtomHttpApi.AtomHttpApiClient<ExtraApiClient,
|
|
|
7
7
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
8
8
|
readonly id: import("effect/Schema").String;
|
|
9
9
|
readonly key: import("effect/Schema").String;
|
|
10
|
-
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./schema").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"
|
|
10
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("./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<{
|
|
11
|
+
readonly projectId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
12
|
+
readonly clientId: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
13
|
+
readonly host: import("effect/Schema").optional<import("effect/Schema").String>;
|
|
14
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
15
|
+
readonly projectKey: import("effect/Schema").String;
|
|
16
|
+
readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
17
|
+
readonly logoUrl: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
18
|
+
readonly authDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
19
|
+
readonly rootDomain: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
20
|
+
readonly themeCss: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
21
|
+
readonly authOptions: import("effect/Schema").Struct<{
|
|
22
|
+
readonly emailPassword: import("effect/Schema").Boolean;
|
|
23
|
+
readonly emailOtp: import("effect/Schema").Boolean;
|
|
24
|
+
readonly google: import("effect/Schema").Boolean;
|
|
25
|
+
readonly signUp: import("effect/Schema").Boolean;
|
|
26
|
+
readonly signUpName: import("effect/Schema").Boolean;
|
|
27
|
+
}>;
|
|
28
|
+
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"setPassword", "POST", "/api/auth/set-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<{
|
|
11
29
|
readonly newPassword: import("effect/Schema").NonEmptyString;
|
|
12
30
|
}>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
|
|
13
31
|
readonly ok: import("effect/Schema").Boolean;
|
package/dist/extra/schema.d.ts
CHANGED
|
@@ -69,6 +69,33 @@ export declare const ExtraVerifyApiKeyResponse: Schema.Struct<{
|
|
|
69
69
|
readonly metadata: Schema.NullOr<Schema.Unknown>;
|
|
70
70
|
}>>;
|
|
71
71
|
}>;
|
|
72
|
+
export declare const ExtraProjectPublicConfigQuery: Schema.Struct<{
|
|
73
|
+
readonly projectId: Schema.optional<Schema.String>;
|
|
74
|
+
readonly clientId: Schema.optional<Schema.String>;
|
|
75
|
+
readonly host: Schema.optional<Schema.String>;
|
|
76
|
+
}>;
|
|
77
|
+
export declare const ExtraProjectAuthOptions: Schema.Struct<{
|
|
78
|
+
readonly emailPassword: Schema.Boolean;
|
|
79
|
+
readonly emailOtp: Schema.Boolean;
|
|
80
|
+
readonly google: Schema.Boolean;
|
|
81
|
+
readonly signUp: Schema.Boolean;
|
|
82
|
+
readonly signUpName: Schema.Boolean;
|
|
83
|
+
}>;
|
|
84
|
+
export declare const ExtraProjectPublicConfig: Schema.Struct<{
|
|
85
|
+
readonly projectKey: Schema.String;
|
|
86
|
+
readonly name: Schema.NullOr<Schema.String>;
|
|
87
|
+
readonly logoUrl: Schema.NullOr<Schema.String>;
|
|
88
|
+
readonly authDomain: Schema.NullOr<Schema.String>;
|
|
89
|
+
readonly rootDomain: Schema.NullOr<Schema.String>;
|
|
90
|
+
readonly themeCss: Schema.NullOr<Schema.String>;
|
|
91
|
+
readonly authOptions: Schema.Struct<{
|
|
92
|
+
readonly emailPassword: Schema.Boolean;
|
|
93
|
+
readonly emailOtp: Schema.Boolean;
|
|
94
|
+
readonly google: Schema.Boolean;
|
|
95
|
+
readonly signUp: Schema.Boolean;
|
|
96
|
+
readonly signUpName: Schema.Boolean;
|
|
97
|
+
}>;
|
|
98
|
+
}>;
|
|
72
99
|
export declare const ExtraOkResponse: Schema.Struct<{
|
|
73
100
|
readonly ok: Schema.Boolean;
|
|
74
101
|
}>;
|
|
@@ -89,5 +116,7 @@ export type ExtraCreateApiKeyPayload = typeof ExtraCreateApiKeyPayload.Type;
|
|
|
89
116
|
export type ExtraCreateApiKeyResponse = typeof ExtraCreateApiKeyResponse.Type;
|
|
90
117
|
export type ExtraVerifyApiKeyPayload = typeof ExtraVerifyApiKeyPayload.Type;
|
|
91
118
|
export type ExtraVerifyApiKeyResponse = typeof ExtraVerifyApiKeyResponse.Type;
|
|
119
|
+
export type ExtraProjectPublicConfigQuery = typeof ExtraProjectPublicConfigQuery.Type;
|
|
120
|
+
export type ExtraProjectPublicConfig = typeof ExtraProjectPublicConfig.Type;
|
|
92
121
|
export type ExtraOkResponse = typeof ExtraOkResponse.Type;
|
|
93
122
|
export {};
|
package/dist/extra/schema.js
CHANGED
|
@@ -135,6 +135,72 @@ export const ExtraVerifyApiKeyResponse = Schema.Struct({
|
|
|
135
135
|
title: "Extra verify API key response",
|
|
136
136
|
description: "Result of verifying a remote API key.",
|
|
137
137
|
});
|
|
138
|
+
export const ExtraProjectPublicConfigQuery = Schema.Struct({
|
|
139
|
+
projectId: Schema.optional(Schema.String),
|
|
140
|
+
clientId: Schema.optional(Schema.String),
|
|
141
|
+
host: Schema.optional(Schema.String),
|
|
142
|
+
}).annotate({
|
|
143
|
+
identifier: "ExtraProjectPublicConfigQuery",
|
|
144
|
+
title: "Extra project public config query",
|
|
145
|
+
description: "Optional project ID, auth host, and OAuth client ID used to resolve public project branding through the proxied auth API.",
|
|
146
|
+
examples: [
|
|
147
|
+
{
|
|
148
|
+
projectId: "project-id",
|
|
149
|
+
host: "auth.example.com",
|
|
150
|
+
clientId: "oauth-client-id",
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
});
|
|
154
|
+
export const ExtraProjectAuthOptions = Schema.Struct({
|
|
155
|
+
emailPassword: Schema.Boolean,
|
|
156
|
+
emailOtp: Schema.Boolean,
|
|
157
|
+
google: Schema.Boolean,
|
|
158
|
+
signUp: Schema.Boolean,
|
|
159
|
+
signUpName: Schema.Boolean,
|
|
160
|
+
}).annotate({
|
|
161
|
+
identifier: "ExtraProjectAuthOptions",
|
|
162
|
+
title: "Extra project authentication options",
|
|
163
|
+
description: "Resolved authentication methods visible for auth pages.",
|
|
164
|
+
examples: [
|
|
165
|
+
{
|
|
166
|
+
emailPassword: true,
|
|
167
|
+
emailOtp: true,
|
|
168
|
+
google: true,
|
|
169
|
+
signUp: true,
|
|
170
|
+
signUpName: true,
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
});
|
|
174
|
+
export const ExtraProjectPublicConfig = Schema.Struct({
|
|
175
|
+
projectKey: Schema.String,
|
|
176
|
+
name: Schema.NullOr(Schema.String),
|
|
177
|
+
logoUrl: Schema.NullOr(Schema.String),
|
|
178
|
+
authDomain: Schema.NullOr(Schema.String),
|
|
179
|
+
rootDomain: Schema.NullOr(Schema.String),
|
|
180
|
+
themeCss: Schema.NullOr(Schema.String),
|
|
181
|
+
authOptions: ExtraProjectAuthOptions,
|
|
182
|
+
}).annotate({
|
|
183
|
+
identifier: "ExtraProjectPublicConfig",
|
|
184
|
+
title: "Extra project public config",
|
|
185
|
+
description: "Public white-label configuration used by auth pages for a project.",
|
|
186
|
+
examples: [
|
|
187
|
+
{
|
|
188
|
+
projectKey: "auth.example.com",
|
|
189
|
+
name: "Example project",
|
|
190
|
+
logoUrl: "https://example.com/logo.svg",
|
|
191
|
+
authDomain: "auth.example.com",
|
|
192
|
+
rootDomain: "example.com",
|
|
193
|
+
themeCss: '[data-project-theme="auth.example.com"] { --primary: oklch(0.5 0.1 240); }',
|
|
194
|
+
authOptions: {
|
|
195
|
+
emailPassword: true,
|
|
196
|
+
emailOtp: true,
|
|
197
|
+
google: true,
|
|
198
|
+
signUp: false,
|
|
199
|
+
signUpName: true,
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
});
|
|
138
204
|
export const ExtraOkResponse = Schema.Struct({
|
|
139
205
|
ok: Schema.Boolean,
|
|
140
206
|
}).annotate({
|
package/dist/service.d.ts
CHANGED
|
@@ -48,6 +48,28 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
48
48
|
readonly id: string;
|
|
49
49
|
readonly key: string;
|
|
50
50
|
}, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra").ExtraBadRequest | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
51
|
+
readonly getProjectPublicConfig: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
52
|
+
readonly query: {
|
|
53
|
+
readonly projectId?: string | undefined;
|
|
54
|
+
readonly clientId?: string | undefined;
|
|
55
|
+
readonly host?: string | undefined;
|
|
56
|
+
};
|
|
57
|
+
readonly responseMode?: Mode;
|
|
58
|
+
}) => Effect.Effect<HttpApiClient.Client.Response<{
|
|
59
|
+
readonly projectKey: string;
|
|
60
|
+
readonly name: string | null;
|
|
61
|
+
readonly logoUrl: string | null;
|
|
62
|
+
readonly authDomain: string | null;
|
|
63
|
+
readonly rootDomain: string | null;
|
|
64
|
+
readonly themeCss: string | null;
|
|
65
|
+
readonly authOptions: {
|
|
66
|
+
readonly emailPassword: boolean;
|
|
67
|
+
readonly emailOtp: boolean;
|
|
68
|
+
readonly google: boolean;
|
|
69
|
+
readonly signUp: boolean;
|
|
70
|
+
readonly signUpName: boolean;
|
|
71
|
+
};
|
|
72
|
+
}, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("effect/unstable/httpapi/HttpApiError").InternalServerError | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
51
73
|
readonly setPassword: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
52
74
|
readonly payload: {
|
|
53
75
|
readonly newPassword: string;
|
|
@@ -381,6 +403,28 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
381
403
|
readonly id: string;
|
|
382
404
|
readonly key: string;
|
|
383
405
|
}, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra").ExtraBadRequest | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
406
|
+
readonly getProjectPublicConfig: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
407
|
+
readonly query: {
|
|
408
|
+
readonly projectId?: string | undefined;
|
|
409
|
+
readonly clientId?: string | undefined;
|
|
410
|
+
readonly host?: string | undefined;
|
|
411
|
+
};
|
|
412
|
+
readonly responseMode?: Mode;
|
|
413
|
+
}) => Effect.Effect<HttpApiClient.Client.Response<{
|
|
414
|
+
readonly projectKey: string;
|
|
415
|
+
readonly name: string | null;
|
|
416
|
+
readonly logoUrl: string | null;
|
|
417
|
+
readonly authDomain: string | null;
|
|
418
|
+
readonly rootDomain: string | null;
|
|
419
|
+
readonly themeCss: string | null;
|
|
420
|
+
readonly authOptions: {
|
|
421
|
+
readonly emailPassword: boolean;
|
|
422
|
+
readonly emailOtp: boolean;
|
|
423
|
+
readonly google: boolean;
|
|
424
|
+
readonly signUp: boolean;
|
|
425
|
+
readonly signUpName: boolean;
|
|
426
|
+
};
|
|
427
|
+
}, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("effect/unstable/httpapi/HttpApiError").InternalServerError | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
384
428
|
readonly setPassword: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
385
429
|
readonly payload: {
|
|
386
430
|
readonly newPassword: string;
|