mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-11-16 00:20:37 +08:00
27 lines
563 B
TypeScript
27 lines
563 B
TypeScript
import { publicKeyFromDid } from "@app/lib/utils";
|
|
|
|
export function isDelegate(
|
|
publicKey: string | undefined,
|
|
delegates: string[],
|
|
): true | undefined {
|
|
if (!publicKey) {
|
|
return undefined;
|
|
}
|
|
return (
|
|
delegates.some(delegate => publicKeyFromDid(delegate) === publicKey) ||
|
|
undefined
|
|
);
|
|
}
|
|
|
|
export function isDelegateOrAuthor(
|
|
publicKey: string | undefined,
|
|
delegates: string[],
|
|
author: string,
|
|
): true | undefined {
|
|
return (
|
|
isDelegate(publicKey, delegates) ||
|
|
publicKey === publicKeyFromDid(author) ||
|
|
undefined
|
|
);
|
|
}
|