@krak-stack/auth 0.2.17 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/admin/api.group.d.ts +19 -13
- package/dist/admin/api.group.js +1 -1
- package/dist/admin/schema.d.ts +9 -7
- package/dist/admin/schema.js +1 -2
- package/dist/api.d.ts +161 -155
- package/dist/api.js +1 -1
- package/dist/auth/api.group.d.ts +1 -1
- package/dist/auth/api.group.js +1 -1
- package/dist/auth/schema.js +1 -1
- package/dist/components/admin-organization-form.js +1 -1
- package/dist/components/admin-organizations.js +5 -25
- package/dist/components/admin-users.js +5 -25
- package/dist/components/associated-projects-notice.js +1 -1
- package/dist/components/auth-atoms.d.ts +1 -1
- package/dist/components/auth-atoms.js +1 -1
- package/dist/components/auth-client-api.d.ts +117 -111
- package/dist/components/auth-client-api.js +3 -3
- package/dist/components/auth-forms.js +2 -2
- package/dist/components/auth-provider.d.ts +1 -1
- package/dist/components/auth-provider.js +2 -2
- package/dist/components/member-required.js +1 -1
- package/dist/components/organization-switcher.js +1 -1
- package/dist/components/user-button.js +1 -1
- package/dist/config.js +2 -2
- package/dist/extra/api.group.d.ts +3 -3
- package/dist/extra/api.group.js +2 -2
- package/dist/extra/schema.d.ts +2 -2
- package/dist/extra/schema.js +2 -2
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/server/actor.d.ts +1 -1
- package/dist/server/actor.js +1 -1
- package/dist/server/api.group.d.ts +1 -1
- package/dist/server/api.group.js +2 -2
- package/dist/server/middleware.d.ts +2 -2
- package/dist/server/middleware.js +2 -2
- package/dist/server/proxy.d.ts +4 -2
- package/dist/server/proxy.js +12 -3
- package/dist/service.d.ts +141 -141
- package/dist/service.js +3 -3
- package/package.json +7 -11
- package/patches/@lucas-barake%2Feffect-form-react@0.26.0-beta.5.patch +66 -0
- package/patches/@lucas-barake%2Feffect-form@0.25.0-beta.6.patch +86 -0
- package/patches/README.md +31 -0
- package/dist/query.d.ts +0 -49
- package/dist/query.js +0 -114
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Effect } from "effect";
|
|
2
|
-
import { FetchHttpClient, HttpClient, HttpClientRequest
|
|
3
|
-
import { AtomHttpApi } from "effect/
|
|
4
|
-
import { HttpApi, HttpApiClient } from "effect/
|
|
2
|
+
import { FetchHttpClient, HttpClient, HttpClientRequest } from "effect/http";
|
|
3
|
+
import { AtomHttpApi } from "effect/reactivity";
|
|
4
|
+
import { HttpApi, HttpApiClient } from "effect/http-api";
|
|
5
5
|
import { AuthClientApi } from "../api.js";
|
|
6
6
|
import { defaultBaseUrl } from "../config.js";
|
|
7
7
|
const authClientApiUrl = (baseUrl) => {
|
|
@@ -3,8 +3,8 @@ import { useAtomSet, useAtomSuspense, useAtomValue } from "@effect/atom-react";
|
|
|
3
3
|
import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
|
|
4
4
|
import { Link, useNavigate, useRouter, useRouterState, } from "@tanstack/react-router";
|
|
5
5
|
import { Effect, Option, Schema } from "effect";
|
|
6
|
-
import { Atom, AsyncResult } from "effect/
|
|
7
|
-
import { HttpClientError } from "effect/
|
|
6
|
+
import { Atom, AsyncResult } from "effect/reactivity";
|
|
7
|
+
import { HttpClientError } from "effect/http";
|
|
8
8
|
import { REGEXP_ONLY_DIGITS } from "input-otp";
|
|
9
9
|
import { KeyRound, Loader2, Mail } from "lucide-react";
|
|
10
10
|
import { useEffect, useRef, useState } from "react";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Cause, Schema } from "effect";
|
|
2
|
-
import { AsyncResult } from "effect/
|
|
2
|
+
import { AsyncResult } from "effect/reactivity";
|
|
3
3
|
import { type ReactNode } from "react";
|
|
4
4
|
import type { ExtraProjectPublicConfig } from "../extra/schema.js";
|
|
5
5
|
import type { ProjectAccessCatalog, ProjectAccessLabelCatalog } from "../access.js";
|
|
@@ -2,8 +2,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useAtomValue } from "@effect/atom-react";
|
|
3
3
|
import { useRouterState } from "@tanstack/react-router";
|
|
4
4
|
import { Cause, Option, Schema } from "effect";
|
|
5
|
-
import { HttpApiError } from "effect/
|
|
6
|
-
import { AsyncResult, Atom } from "effect/
|
|
5
|
+
import { HttpApiError } from "effect/http-api";
|
|
6
|
+
import { AsyncResult, Atom } from "effect/reactivity";
|
|
7
7
|
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
8
8
|
import { createContext, useContext, useEffect, useMemo, useRef, } from "react";
|
|
9
9
|
import { activeAuthOrganizationAtom, authSessionAtom } from "./auth-atoms.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useAtomSet, useAtomSuspense } from "@effect/atom-react";
|
|
3
3
|
import { Effect, Schema } from "effect";
|
|
4
|
-
import { Atom } from "effect/
|
|
4
|
+
import { Atom } from "effect/reactivity";
|
|
5
5
|
import { Check, Loader2, Mail, ShieldAlert } from "lucide-react";
|
|
6
6
|
import { useState } from "react";
|
|
7
7
|
import { Button } from "@/components/ui/button";
|
|
@@ -2,7 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { useAtomRefresh, useAtomSet, useAtomValue } from "@effect/atom-react";
|
|
3
3
|
import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
|
|
4
4
|
import { Effect, Option, Predicate, Schema } from "effect";
|
|
5
|
-
import { AsyncResult, Atom } from "effect/
|
|
5
|
+
import { AsyncResult, Atom } from "effect/reactivity";
|
|
6
6
|
import { ArrowLeft, Building2, Check, ChevronsUpDown, Copy, KeyRound, LogOut, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
7
7
|
import { createContext, useContext, useEffect, useRef, useState, } from "react";
|
|
8
8
|
import { DataTable, DataTableListSummary, DataTableListCell, } from "@krak-stack/registry/data-table";
|
|
@@ -3,7 +3,7 @@ import { RegistryContext, useAtomRefresh, useAtomSet, useAtomValue, } from "@eff
|
|
|
3
3
|
import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
|
|
4
4
|
import { useNavigate, useRouterState, } from "@tanstack/react-router";
|
|
5
5
|
import { Effect, Option, Predicate, Schema } from "effect";
|
|
6
|
-
import { AsyncResult, Atom, AtomRegistry } from "effect/
|
|
6
|
+
import { AsyncResult, Atom, AtomRegistry } from "effect/reactivity";
|
|
7
7
|
import { ArrowLeft, Building2, KeyRound, Loader2, LogOutIcon, Mail, Pencil, Plus, ShieldCheck, StopCircle, Trash2, UserCircleIcon, Users, UserIcon, } from "lucide-react";
|
|
8
8
|
import { QRCode } from "react-qr-code";
|
|
9
9
|
import { createContext, useContext, useRef, useEffect, useState, } from "react";
|
package/dist/config.js
CHANGED
|
@@ -10,9 +10,9 @@ export class AuthClientConfig extends Context.Service()("@krak-stack/auth/AuthCl
|
|
|
10
10
|
make: (options = {}) => Effect.gen(function* () {
|
|
11
11
|
const baseUrl = options.baseUrl ??
|
|
12
12
|
process.env.KRAKSTACK_AUTH_URL ??
|
|
13
|
-
(yield* Config.
|
|
13
|
+
(yield* Config.String("VITE_KRAKSTACK_AUTH_URL"));
|
|
14
14
|
const apiKey = options.apiKey ??
|
|
15
|
-
(yield* Config.
|
|
15
|
+
(yield* Config.Redacted("KRAKSTACK_AUTH_SERVICE_API_KEY"));
|
|
16
16
|
return {
|
|
17
17
|
baseUrl: normalizeBaseUrl(baseUrl),
|
|
18
18
|
apiKey,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/
|
|
2
|
+
import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/http-api";
|
|
3
3
|
import { ExtraBadRequest } from "./schema.js";
|
|
4
4
|
export * from "./schema.js";
|
|
5
5
|
export type { Organization, OrganizationMetadata } from "../schema.js";
|
|
@@ -101,8 +101,8 @@ export declare const ExtraApiGroup: HttpApiGroup.HttpApiGroup<"authExtra", HttpA
|
|
|
101
101
|
readonly referrers: Schema.optional<Schema.$Array<Schema.String>>;
|
|
102
102
|
}>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
103
103
|
readonly ok: Schema.Boolean;
|
|
104
|
-
}>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"uploadUserImage", "POST", "/auth/image/upload", never, never, Schema.toCodecJson<import("effect/
|
|
105
|
-
readonly file: Schema.decodeTo<import("effect/
|
|
104
|
+
}>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"uploadUserImage", "POST", "/auth/image/upload", never, never, Schema.toCodecJson<import("effect/http-api/HttpApiSchema").asMultipartStream<Schema.Struct<{
|
|
105
|
+
readonly file: Schema.decodeTo<import("effect/http/Multipart").PersistedFileSchema, Schema.$Array<import("effect/http/Multipart").PersistedFileSchema>, never, never>;
|
|
106
106
|
}>>>, never, Schema.toCodecJson<Schema.Struct<{
|
|
107
107
|
readonly url: Schema.String;
|
|
108
108
|
}>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError | typeof ExtraBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"verifyApiKey", "POST", "/auth/verify-api-key", never, never, Schema.toCodecJson<Schema.Struct<{
|
package/dist/extra/api.group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { OpenApi } from "effect/
|
|
3
|
-
import { HttpApiEndpoint, HttpApiError, HttpApiGroup
|
|
2
|
+
import { OpenApi } from "effect/http-api";
|
|
3
|
+
import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/http-api";
|
|
4
4
|
import { ExtraBadRequest, ExtraAssociatedProjects, ExtraAssociatedProjectsQuery, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraOrganizationPublicProfile, ExtraOrganizationPublicProfileQuery, ExtraProjectPublicConfig, ExtraProjectPublicConfigQuery, ExtraSetPasswordPayload, ExtraUpdateApiKeyPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema.js";
|
|
5
5
|
export * from "./schema.js";
|
|
6
6
|
export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
package/dist/extra/schema.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { Multipart } from "effect/
|
|
3
|
-
import { HttpApiSchema } from "effect/
|
|
2
|
+
import { Multipart } from "effect/http";
|
|
3
|
+
import { HttpApiSchema } from "effect/http-api";
|
|
4
4
|
export declare const ExtraImageUploadPayload: Schema.Struct<{
|
|
5
5
|
readonly file: Schema.decodeTo<Multipart.PersistedFileSchema, Schema.$Array<Multipart.PersistedFileSchema>, never, never>;
|
|
6
6
|
}>;
|
package/dist/extra/schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
import { Multipart } from "effect/
|
|
3
|
-
import { HttpApiSchema } from "effect/
|
|
2
|
+
import { Multipart } from "effect/http";
|
|
3
|
+
import { HttpApiSchema } from "effect/http-api";
|
|
4
4
|
import { OrganizationEmail, OrganizationLocale, OrganizationPhone, OrganizationSocial, OrganizationWebsite, FormattedOrganizationAddress, } from "../schema.js";
|
|
5
5
|
export const ExtraImageUploadPayload = Schema.Struct({
|
|
6
6
|
file: Multipart.SingleFileSchema,
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/server/actor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
import { HttpApiError, HttpApiMiddleware } from "effect/
|
|
2
|
+
import { HttpApiError, HttpApiMiddleware } from "effect/http-api";
|
|
3
3
|
import { CurrentActor, type ProjectAccessDefinition } from "../access.js";
|
|
4
4
|
import { AuthService } from "../service.js";
|
|
5
5
|
declare const AnyActorRequired_base: HttpApiMiddleware.ServiceClass<AnyActorRequired, "@krak-stack/auth/ActorRequired", {
|
package/dist/server/actor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Layer, Schema } from "effect";
|
|
2
|
-
import { HttpApiError, HttpApiMiddleware } from "effect/
|
|
2
|
+
import { HttpApiError, HttpApiMiddleware } from "effect/http-api";
|
|
3
3
|
import { ApiKeyPermissionGrant, CurrentActor, } from "../access.js";
|
|
4
4
|
import { parseRoleList } from "../roles.js";
|
|
5
5
|
import { AuthService } from "../service.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/
|
|
1
|
+
import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/http-api";
|
|
2
2
|
export declare const ServerUsersApiGroup: HttpApiGroup.HttpApiGroup<"users", HttpApiEndpoint.HttpApiEndpoint<"getUser", "GET", "/users/:id", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
|
|
3
3
|
readonly id: import("effect/Schema").NonEmptyString;
|
|
4
4
|
}>>, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
|
package/dist/server/api.group.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { OpenApi } from "effect/
|
|
2
|
-
import { HttpApiEndpoint, HttpApiError, HttpApiGroup
|
|
1
|
+
import { OpenApi } from "effect/http-api";
|
|
2
|
+
import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/http-api";
|
|
3
3
|
import { Member, Organization, User } from "../schema.js";
|
|
4
4
|
import { ServerActiveOrganization, ServerCreateDomainPayload, ServerDomain, ServerDomainHostParams, ServerDomainIdParams, ServerDomainRecordsResponse, ServerIdParams, ServerIdsQuery, ServerMemberParams, ServerMembersResponse, ServerOrganizationChildrenResponse, ServerOrganizationIdParams, ServerOrganizationsQuery, ServerOrganizationsResponse, ServerUserIdParams, ServerUsersResponse, } from "./schema.js";
|
|
5
5
|
export const ServerUsersApiGroup = HttpApiGroup.make("users")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
import { HttpServerRequest } from "effect/
|
|
3
|
-
import { HttpApiError, HttpApiMiddleware, HttpApiSecurity } from "effect/
|
|
2
|
+
import { HttpServerRequest } from "effect/http";
|
|
3
|
+
import { HttpApiError, HttpApiMiddleware, HttpApiSecurity } from "effect/http-api";
|
|
4
4
|
import { AuthService, type AuthServiceLayerOptions } from "../service.js";
|
|
5
5
|
export declare const ApiKeySecurity: HttpApiSecurity.ApiKey;
|
|
6
6
|
declare const AuthMiddleware_base: HttpApiMiddleware.ServiceClass<AuthMiddleware, "@krak-stack/auth/AuthMiddleware", {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cause, Effect, Layer, Redacted } from "effect";
|
|
2
|
-
import { HttpServerRequest } from "effect/
|
|
3
|
-
import { HttpApiError, HttpApiMiddleware, HttpApiSecurity, } from "effect/
|
|
2
|
+
import { HttpServerRequest } from "effect/http";
|
|
3
|
+
import { HttpApiError, HttpApiMiddleware, HttpApiSecurity, } from "effect/http-api";
|
|
4
4
|
import { AuthService } from "../service.js";
|
|
5
5
|
export const ApiKeySecurity = HttpApiSecurity.apiKey({
|
|
6
6
|
key: "x-api-key",
|
package/dist/server/proxy.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Effect, type Redacted } from "effect";
|
|
2
|
-
import { HttpClient, HttpServerRequest, HttpServerResponse } from "effect/
|
|
2
|
+
import { HttpClient, HttpServerRequest, HttpServerResponse } from "effect/http";
|
|
3
3
|
import { AuthProxyError } from "./proxy-origin.js";
|
|
4
4
|
export interface ProxyAuthRequestOptions {
|
|
5
5
|
cookieDomain?: string;
|
|
6
6
|
apiKey?: Redacted.Redacted<string>;
|
|
7
|
+
/** For proxyAuthHttpEffect only; enable behind an ingress that overwrites x-forwarded-proto. */
|
|
8
|
+
trustForwardedProto?: boolean;
|
|
7
9
|
}
|
|
8
10
|
export declare const proxyAuthRequest: (request: Request, baseUrl: string | URL, options?: ProxyAuthRequestOptions) => Promise<Response>;
|
|
9
11
|
export declare const proxyAuthRequestEffect: (request: Request, baseUrl: string | URL, options?: ProxyAuthRequestOptions) => Effect.Effect<HttpServerResponse.HttpServerResponse, AuthProxyError, HttpClient.HttpClient>;
|
|
10
|
-
export declare const proxyAuthHttpEffect: (baseUrl: string | URL, options?: ProxyAuthRequestOptions) => Effect.Effect<HttpServerResponse.HttpServerResponse, AuthProxyError | import("effect/
|
|
12
|
+
export declare const proxyAuthHttpEffect: (baseUrl: string | URL, options?: ProxyAuthRequestOptions) => Effect.Effect<HttpServerResponse.HttpServerResponse, AuthProxyError | import("effect/http/HttpServerError").RequestError, HttpClient.HttpClient | HttpServerRequest.HttpServerRequest>;
|
package/dist/server/proxy.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
2
|
-
import { Cookies, FetchHttpClient, Headers as HttpHeaders, HttpClient, HttpClientRequest, HttpServerRequest, HttpServerResponse, } from "effect/
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
import { Cookies, FetchHttpClient, Headers as HttpHeaders, HttpClient, HttpClientRequest, HttpServerRequest, HttpServerResponse, } from "effect/http";
|
|
3
3
|
import { AuthProxyError, authProxyKeyHeader, proxyOriginHeaders, } from "./proxy-origin.js";
|
|
4
|
+
import { AuthProxyOrigin } from "./schema.js";
|
|
4
5
|
const blockedRequestHeaders = [
|
|
5
6
|
"accept-encoding",
|
|
6
7
|
"b3",
|
|
@@ -128,5 +129,13 @@ export const proxyAuthRequestEffect = (request, baseUrl, options) => Effect.gen(
|
|
|
128
129
|
export const proxyAuthHttpEffect = (baseUrl, options) => Effect.gen(function* () {
|
|
129
130
|
const request = yield* HttpServerRequest.HttpServerRequest;
|
|
130
131
|
const webRequest = yield* HttpServerRequest.toWeb(request);
|
|
131
|
-
|
|
132
|
+
if (!options?.trustForwardedProto) {
|
|
133
|
+
return yield* proxyAuthRequestEffect(webRequest, baseUrl, options);
|
|
134
|
+
}
|
|
135
|
+
// toWeb can return the original Web Request with the internal HTTP URL.
|
|
136
|
+
// Trust only the configured ingress protocol, never forwarded host headers.
|
|
137
|
+
const url = new URL(webRequest.url);
|
|
138
|
+
const protocol = yield* Schema.decodeUnknownEffect(AuthProxyOrigin.fields.protocol)(request.headers["x-forwarded-proto"] ?? url.protocol.slice(0, -1)).pipe(Effect.mapError(() => new AuthProxyError({ reason: "invalid" })));
|
|
139
|
+
url.protocol = `${protocol}:`;
|
|
140
|
+
return yield* proxyAuthRequestEffect(new Request(url, webRequest), baseUrl, options);
|
|
132
141
|
});
|