feat(web): WebAuthn relying-party helper (host-derived rpID/origin)
This commit is contained in:
parent
7a6569800e
commit
380e86b885
21
web/lib/auth-rp.ts
Normal file
21
web/lib/auth-rp.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import "server-only";
|
||||
import { headers } from "next/headers";
|
||||
|
||||
export type RpInfo = {
|
||||
rpID: string;
|
||||
origin: string;
|
||||
rpName: string;
|
||||
};
|
||||
|
||||
export async function getRpInfo(): Promise<RpInfo> {
|
||||
const hdrs = await headers();
|
||||
const host = hdrs.get("x-forwarded-host") ?? hdrs.get("host") ?? "localhost:8010";
|
||||
const rpID = host.split(":")[0];
|
||||
const proto = hdrs.get("x-forwarded-proto") ?? "http";
|
||||
const origin = `${proto}://${host}`;
|
||||
return {
|
||||
rpID,
|
||||
origin,
|
||||
rpName: "CM Bot V2",
|
||||
};
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user