b70e5b2f38
* update vite+typescript * update atproto api to latest, split out utils * add checkmark to post * add checkie to embed * revert change to example post * fix ext link color
32 lines
801 B
TypeScript
32 lines
801 B
TypeScript
import * as bsky from '../types/bsky'
|
|
|
|
export type VerificationState = {
|
|
role: 'default' | 'verifier'
|
|
isVerified: boolean
|
|
}
|
|
|
|
export function getVerificationState({
|
|
profile,
|
|
}: {
|
|
profile?: bsky.profile.AnyProfileView
|
|
}): VerificationState {
|
|
if (!profile || !profile.verification) {
|
|
return {
|
|
role: 'default',
|
|
isVerified: false,
|
|
}
|
|
}
|
|
|
|
const {verifiedStatus, trustedVerifierStatus} = profile.verification
|
|
const isVerifiedUser = ['valid', 'invalid'].includes(verifiedStatus)
|
|
const isVerifierUser = ['valid', 'invalid'].includes(trustedVerifierStatus)
|
|
const isVerified =
|
|
(isVerifiedUser && verifiedStatus === 'valid') ||
|
|
(isVerifierUser && trustedVerifierStatus === 'valid')
|
|
|
|
return {
|
|
role: isVerifierUser ? 'verifier' : 'default',
|
|
isVerified,
|
|
}
|
|
}
|