mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 16:53:34 +00:00
12 lines
352 B
TypeScript
12 lines
352 B
TypeScript
import { parse } from "tldts";
|
|
|
|
export function isValidRpId(rpId: string, origin: string) {
|
|
const parsedOrigin = parse(origin, { allowPrivateDomains: true });
|
|
const parsedRpId = parse(rpId, { allowPrivateDomains: true });
|
|
|
|
return (
|
|
parsedOrigin.domain === parsedRpId.domain &&
|
|
parsedOrigin.subdomain.endsWith(parsedRpId.subdomain)
|
|
);
|
|
}
|