@krak-stack/auth 0.1.66 → 0.1.68
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/components/admin-organization-form.js +1 -1
- package/dist/components/admin-organizations.d.ts +1 -1
- package/dist/components/admin-organizations.js +3 -3
- package/dist/components/admin-users.d.ts +1 -1
- package/dist/components/admin-users.js +3 -3
- package/dist/components/api-key-edit-form.js +1 -1
- package/dist/components/auth-forms.js +1 -1
- package/dist/components/member-required.js +1 -1
- package/dist/components/organization-switcher.js +5 -5
- package/dist/components/user-button.js +4 -4
- package/dist/server/index.d.ts +1 -0
- package/dist/server/proxy.d.ts +4 -1
- package/dist/server/proxy.js +22 -4
- package/package.json +2 -1
|
@@ -5,7 +5,7 @@ import { Effect, Schema } from "effect";
|
|
|
5
5
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
6
6
|
import { useState } from "react";
|
|
7
7
|
import { toast } from "sonner";
|
|
8
|
-
import { ImageField, SingleSearchableSelectField, SubmitButton, SubmitError, TextField, } from "
|
|
8
|
+
import { ImageField, SingleSearchableSelectField, SubmitButton, SubmitError, TextField, } from "@krak-stack/registry/effect-form";
|
|
9
9
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
10
10
|
import { AdminCreateOrganizationPayload, } from "../admin/schema";
|
|
11
11
|
import { authClientApi } from "./auth-client-api";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ValidateFromPath } from "@tanstack/react-router";
|
|
2
|
-
import { type TableParams } from "
|
|
2
|
+
import { type TableParams } from "@krak-stack/registry/data-table";
|
|
3
3
|
export declare function AdminOrganizationsTable({ from, reloadKey, search, }: {
|
|
4
4
|
from?: ValidateFromPath;
|
|
5
5
|
reloadKey?: number;
|
|
@@ -5,9 +5,9 @@ import { Atom, AsyncResult } from "effect/unstable/reactivity";
|
|
|
5
5
|
import { Building2, Pencil, Trash2 } from "lucide-react";
|
|
6
6
|
import { useState } from "react";
|
|
7
7
|
import { toast } from "sonner";
|
|
8
|
-
import { DataTable, DataTableListSummary, } from "
|
|
9
|
-
import { ErrorMessage } from "
|
|
10
|
-
import { AppBrand } from "
|
|
8
|
+
import { DataTable, DataTableListSummary, } from "@krak-stack/registry/data-table";
|
|
9
|
+
import { ErrorMessage } from "@krak-stack/registry/effect-form";
|
|
10
|
+
import { AppBrand } from "@krak-stack/registry/app-brand";
|
|
11
11
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog";
|
|
12
12
|
import { AdminOrganizationForm } from "./admin-organization-form";
|
|
13
13
|
import { authClientApi } from "./auth-client-api";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ValidateFromPath } from "@tanstack/react-router";
|
|
2
|
-
import { type TableParams } from "
|
|
2
|
+
import { type TableParams } from "@krak-stack/registry/data-table";
|
|
3
3
|
export declare function AdminUsersTable({ from, reloadKey, search, }: {
|
|
4
4
|
from?: ValidateFromPath;
|
|
5
5
|
reloadKey?: number;
|
|
@@ -5,9 +5,9 @@ import {} from "@tanstack/react-table";
|
|
|
5
5
|
import { Atom, AsyncResult } from "effect/unstable/reactivity";
|
|
6
6
|
import { Ban, Building2, Loader2, ShieldOff, UserCog, UserIcon, } from "lucide-react";
|
|
7
7
|
import { useState } from "react";
|
|
8
|
-
import { DataTable, DataTableListSummary, } from "
|
|
9
|
-
import { ErrorMessage } from "
|
|
10
|
-
import { AppBrand } from "
|
|
8
|
+
import { DataTable, DataTableListSummary, } from "@krak-stack/registry/data-table";
|
|
9
|
+
import { ErrorMessage } from "@krak-stack/registry/effect-form";
|
|
10
|
+
import { AppBrand } from "@krak-stack/registry/app-brand";
|
|
11
11
|
import { Badge } from "@/components/ui/badge";
|
|
12
12
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@/components/ui/alert-dialog";
|
|
13
13
|
import { authClientApi } from "./auth-client-api";
|
|
@@ -3,7 +3,7 @@ import { useAtomSet, useAtomValue } from "@effect/atom-react";
|
|
|
3
3
|
import { FormBuilder, FormReact } from "@lucas-barake/effect-form-react";
|
|
4
4
|
import { Effect, Schema } from "effect";
|
|
5
5
|
import { useRef, useState } from "react";
|
|
6
|
-
import { CheckboxField, SubmitButton, SubmitError, TextAreaField, TextField, } from "
|
|
6
|
+
import { CheckboxField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@krak-stack/registry/effect-form";
|
|
7
7
|
import { parseApiKeyReferrers, updateApiKey } from "./api-key";
|
|
8
8
|
import { ApiKeyPermissions } from "./api-key-permissions";
|
|
9
9
|
import { apiKeyReferrers } from "./api-key-referrers";
|
|
@@ -9,7 +9,7 @@ import { KeyRound, Loader2, Mail } from "lucide-react";
|
|
|
9
9
|
import { useEffect, useState } from "react";
|
|
10
10
|
import { Button, buttonVariants } from "@/components/ui/button";
|
|
11
11
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card";
|
|
12
|
-
import { CheckboxField, ErrorMessage, SubmitError, TextField, effectFormMessages, } from "
|
|
12
|
+
import { CheckboxField, ErrorMessage, SubmitError, TextField, effectFormMessages, } from "@krak-stack/registry/effect-form";
|
|
13
13
|
import { Field, FieldLabel } from "@/components/ui/field";
|
|
14
14
|
import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, } from "@/components/ui/input-otp";
|
|
15
15
|
import { authClientApi } from "./auth-client-api";
|
|
@@ -5,7 +5,7 @@ import { Atom } from "effect/unstable/reactivity";
|
|
|
5
5
|
import { Check, Loader2, Mail, ShieldAlert } from "lucide-react";
|
|
6
6
|
import { useEffect, useState } from "react";
|
|
7
7
|
import { Button } from "@/components/ui/button";
|
|
8
|
-
import { CopyButton } from "
|
|
8
|
+
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
9
9
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card";
|
|
10
10
|
import { useKrakstackAuth } from "./auth-provider";
|
|
11
11
|
import { isInvitationExpired, useInvitationExpirationClock, } from "./invitation-expiration";
|
|
@@ -7,15 +7,15 @@ import { Effect, Option, Schema } from "effect";
|
|
|
7
7
|
import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
8
8
|
import { ArrowLeft, Building2, Check, ChevronsUpDown, Copy, KeyRound, LogOut, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
|
|
9
9
|
import { createContext, useContext, useEffect, useEffectEvent, useRef, useState, } from "react";
|
|
10
|
-
import { DataTable, DataTableRelationshipCell, } from "
|
|
11
|
-
import { ErrorMessage, ImageField, SelectField, SubmitButton, SubmitError, TextAreaField, TextField, } from "
|
|
12
|
-
import { EditingLocaleSwitcher } from "
|
|
13
|
-
import { AppBrand } from "
|
|
10
|
+
import { DataTable, DataTableRelationshipCell, } from "@krak-stack/registry/data-table";
|
|
11
|
+
import { ErrorMessage, ImageField, SelectField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@krak-stack/registry/effect-form";
|
|
12
|
+
import { EditingLocaleSwitcher } from "@krak-stack/registry/editing-locale-switcher";
|
|
13
|
+
import { AppBrand } from "@krak-stack/registry/app-brand";
|
|
14
14
|
import { Field, FieldLabel, FieldSet } from "@/components/ui/field";
|
|
15
15
|
import { Input } from "@/components/ui/input";
|
|
16
16
|
import { Badge } from "@/components/ui/badge";
|
|
17
17
|
import { Button } from "@/components/ui/button";
|
|
18
|
-
import { CopyButton } from "
|
|
18
|
+
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
19
19
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
20
20
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
21
21
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/components/ui/select";
|
|
@@ -8,12 +8,12 @@ import { AsyncResult, Atom } from "effect/unstable/reactivity";
|
|
|
8
8
|
import { ArrowLeft, Building2, KeyRound, Loader2, LogOutIcon, Pencil, Plus, ShieldCheck, StopCircle, Trash2, UserCircleIcon, Users, UserIcon, } from "lucide-react";
|
|
9
9
|
import { QRCode } from "react-qr-code";
|
|
10
10
|
import { createContext, useContext, useRef, useState, } from "react";
|
|
11
|
-
import { DataTable } from "
|
|
12
|
-
import { AppBrand } from "
|
|
13
|
-
import { effectFormMessages, ImageField, SubmitButton, SubmitError, TextAreaField, TextField, } from "
|
|
11
|
+
import { DataTable } from "@krak-stack/registry/data-table";
|
|
12
|
+
import { AppBrand } from "@krak-stack/registry/app-brand";
|
|
13
|
+
import { effectFormMessages, ImageField, SubmitButton, SubmitError, TextAreaField, TextField, } from "@krak-stack/registry/effect-form";
|
|
14
14
|
import { Badge } from "@/components/ui/badge";
|
|
15
15
|
import { Button } from "@/components/ui/button";
|
|
16
|
-
import { CopyButton } from "
|
|
16
|
+
import { CopyButton } from "@krak-stack/registry/copy-button";
|
|
17
17
|
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, } from "@/components/ui/dialog";
|
|
18
18
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
|
|
19
19
|
import { Separator } from "@/components/ui/separator";
|
package/dist/server/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export type { AuthSession, AuthSessionWithOrganization, AuthSessionWithUser, Aut
|
|
|
3
3
|
export { AuthClientConfig } from "../config";
|
|
4
4
|
export { ServerDomainsApiGroup, ServerOrganizationsApiGroup, ServerUsersApiGroup, } from "./api.group";
|
|
5
5
|
export { proxyAuthRequest } from "./proxy";
|
|
6
|
+
export type { ProxyAuthRequestOptions } from "./proxy";
|
|
6
7
|
export { ActorRequired } from "./actor";
|
|
7
8
|
export type { ActorConstraint } from "./actor";
|
|
8
9
|
export { ApiKeySecurity, AuthMiddleware, makeAuthenticationLive, } from "./middleware";
|
package/dist/server/proxy.d.ts
CHANGED
|
@@ -1 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ProxyAuthRequestOptions {
|
|
2
|
+
cookieDomain?: string;
|
|
3
|
+
}
|
|
4
|
+
export declare const proxyAuthRequest: (request: Request, baseUrl: string | URL, options?: ProxyAuthRequestOptions) => Promise<Response>;
|
package/dist/server/proxy.js
CHANGED
|
@@ -14,13 +14,31 @@ const blockedRequestHeaders = [
|
|
|
14
14
|
"cdn-loop",
|
|
15
15
|
];
|
|
16
16
|
const hostOnlyCookie = (cookie) => cookie.replace(/;\s*domain=[^;]*/gi, "");
|
|
17
|
-
const
|
|
17
|
+
const normalizedCookieDomain = (domain) => domain.trim().toLowerCase().replace(/^\.+|\.+$/g, "");
|
|
18
|
+
const sharedCookieDomain = (request, options) => {
|
|
19
|
+
if (!options?.cookieDomain)
|
|
20
|
+
return null;
|
|
21
|
+
const domain = normalizedCookieDomain(options.cookieDomain);
|
|
22
|
+
const hostname = new URL(request.url).hostname.toLowerCase();
|
|
23
|
+
if (!domain || (hostname !== domain && !hostname.endsWith(`.${domain}`))) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return domain;
|
|
27
|
+
};
|
|
28
|
+
const cookieForDomain = (cookie, domain) => {
|
|
29
|
+
const hostOnly = hostOnlyCookie(cookie);
|
|
30
|
+
if (!domain || hostOnly.startsWith("__Host-"))
|
|
31
|
+
return hostOnly;
|
|
32
|
+
return `${hostOnly}; Domain=${domain}`;
|
|
33
|
+
};
|
|
34
|
+
const proxyResponse = async (request, response, options) => {
|
|
18
35
|
const headers = new Headers(response.headers);
|
|
19
36
|
const cookies = response.headers.getSetCookie();
|
|
37
|
+
const cookieDomain = sharedCookieDomain(request, options);
|
|
20
38
|
if (cookies.length > 0) {
|
|
21
39
|
headers.delete("set-cookie");
|
|
22
40
|
for (const cookie of cookies) {
|
|
23
|
-
headers.append("set-cookie",
|
|
41
|
+
headers.append("set-cookie", cookieForDomain(cookie, cookieDomain));
|
|
24
42
|
}
|
|
25
43
|
}
|
|
26
44
|
return new Response(response.body, {
|
|
@@ -46,7 +64,7 @@ const proxyHeaders = (request) => {
|
|
|
46
64
|
headers.set("x-forwarded-proto", url.protocol.replace(":", ""));
|
|
47
65
|
return headers;
|
|
48
66
|
};
|
|
49
|
-
export const proxyAuthRequest = async (request, baseUrl) => {
|
|
67
|
+
export const proxyAuthRequest = async (request, baseUrl, options) => {
|
|
50
68
|
const target = new URL(request.url);
|
|
51
69
|
const authUrl = new URL(baseUrl);
|
|
52
70
|
const init = {
|
|
@@ -63,5 +81,5 @@ export const proxyAuthRequest = async (request, baseUrl) => {
|
|
|
63
81
|
const response = await fetch(new Request(target, init), {
|
|
64
82
|
redirect: "manual",
|
|
65
83
|
});
|
|
66
|
-
return proxyResponse(response);
|
|
84
|
+
return proxyResponse(request, response, options);
|
|
67
85
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.68",
|
|
4
4
|
"description": "Effect HttpApi clients and schemas for KrakStack Auth.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"type:check": "tsc -p tsconfig.json --noEmit"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
+
"@krak-stack/registry": "^0.1.1",
|
|
78
79
|
"react-qr-code": "^2.2.0"
|
|
79
80
|
},
|
|
80
81
|
"peerDependencies": {
|