Files
radicle-desktop/src/lib/roles.ts
T
2024-10-25 10:46:53 +02:00

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
);
}