Skip to content

Commit

Permalink
parse new threat signatures field from repo view
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Oct 30, 2024
1 parent 67d6a14 commit 24ed941
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
35 changes: 29 additions & 6 deletions components/repositories/AccountView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
AppBskyActorGetProfile as GetProfile,
ToolsOzoneModerationGetRepo as GetRepo,
AppBskyActorDefs,
ComAtprotoAdminDefs,
} from '@atproto/api'
import {
ArrowTopRightOnSquareIcon,
Expand Down Expand Up @@ -517,12 +518,10 @@ function Details({
const deactivatedAt = repo.deactivatedAt
? dateFormatter.format(new Date(repo.deactivatedAt))
: ''
const registrationIp = typeof repo.ip === 'string' ? repo.ip : undefined
const lastSigninIp =
typeof repo.lastSignin === 'string' ? repo.lastSignin : undefined
const hcapDetail = Array.isArray(repo.hcaptchaDetails)
? (repo.hcaptchaDetails as { property: string; value: string }[])
: undefined

const { registrationIp, lastSigninIp, lastSigninTime, hcapDetail } =
parseThreatSigs(repo.threatSignatures)

return (
<div className="mx-auto mt-6 max-w-5xl px-4 sm:px-6 lg:px-8">
<dl className="grid grid-cols-1 gap-x-4 gap-y-8 sm:grid-cols-2 mb-10">
Expand Down Expand Up @@ -559,6 +558,11 @@ function Details({
>
<MagnifyingGlassIcon className="h-3 w-3 inline" />
</Link>
{lastSigninTime && (
<div className="text-gray-400">
{new Date(lastSigninTime).toLocaleString()}
</div>
)}
</DataField>
)}
{hcapDetail && (
Expand Down Expand Up @@ -888,3 +892,22 @@ function obscureIp(ip: string) {
if (parts.length !== 4) return '***.***.***.***'
return `${parts[0]}.${parts[1]}.***.***`
}

function parseThreatSigs(sigs?: ComAtprotoAdminDefs.ThreatSignature[]) {
const registrationIp = sigs?.find(
(sig) => sig.property === 'registrationIp',
)?.value
const lastSigninIp = sigs?.find(
(sig) => sig.property === 'lastSigninIp',
)?.value
const lastSigninTime = sigs?.find(
(sig) => sig.property === 'lastSigninTime',
)?.value
const hcapDetail = sigs?.filter(
(sig) =>
!['registrationIp', 'lastSigninIp', 'lastSigninTime'].includes(
sig.property,
),
)
return { registrationIp, lastSigninIp, lastSigninTime, hcapDetail }
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"e2e:run": "$(yarn bin)/cypress run --browser chrome"
},
"dependencies": {
"@atproto/api": "^0.13.12",
"@atproto/api": "^0.13.14",
"@atproto/oauth-client-browser": "^0.2.0",
"@atproto/oauth-types": "^0.1.4",
"@atproto/xrpc": "^0.6.1",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
resolved "https://registry.yarnpkg.com/@atproto-labs/simple-store/-/simple-store-0.1.1.tgz#e743a2722b5d8732166f0a72aca8bd10e9bff106"
integrity sha512-WKILW2b3QbAYKh+w5U2x6p5FqqLl0nAeLwGeDY+KjX01K4Dq3vQTR9b/qNp0jZm48CabPQVrqCv0PPU9LgRRRg==

"@atproto/api@^0.13.12":
version "0.13.12"
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.12.tgz#e7bfe42fcd530219f4e1dafc42dd397bc0850d6c"
integrity sha512-U/qimbjlX0MA4MsR+GDuAnFtmdFuGi7eMQZm51s9gbDUw6y4RARL6gaZ0Ju9fBZpS45sI+ShlUHzIoEiBaRvkg==
"@atproto/api@^0.13.14":
version "0.13.14"
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.13.14.tgz#3a74f0dbb19a8813d45bcf645dcc25b7e2623aca"
integrity sha512-CG5UpjI1WwSasSJTGadmr07EwWvl5JV658YZHcwIIg+Psk5sDloQOUJckuo1MP6wke1z6p/BUoPL4lxAATzMzA==
dependencies:
"@atproto/common-web" "^0.3.1"
"@atproto/lexicon" "^0.4.2"
Expand Down

0 comments on commit 24ed941

Please sign in to comment.