From df14df522bb7986e56ee1f6a0f5d862e1ea6f4d5 Mon Sep 17 00:00:00 2001 From: Daniel Holmgren Date: Thu, 3 Oct 2024 14:00:12 -0500 Subject: [PATCH] Ozone signature methods (#2855) * lexicons * fix typo & add proxy routes * changeset --- .changeset/flat-actors-clap.md | 6 + lexicons/tools/ozone/signature/defs.json | 14 ++ .../ozone/signature/findCorrelation.json | 39 ++++ .../ozone/signature/findRelatedAccounts.json | 61 ++++++ .../tools/ozone/signature/searchAccounts.json | 46 +++++ packages/api/src/client/index.ts | 54 ++++++ packages/api/src/client/lexicons.ts | 180 ++++++++++++++++++ .../types/tools/ozone/signature/defs.ts | 25 +++ .../tools/ozone/signature/findCorrelation.ts | 35 ++++ .../ozone/signature/findRelatedAccounts.ts | 60 ++++++ .../tools/ozone/signature/searchAccounts.ts | 38 ++++ packages/ozone/src/api/proxied.ts | 51 +++++ packages/ozone/src/lexicon/index.ts | 46 +++++ packages/ozone/src/lexicon/lexicons.ts | 180 ++++++++++++++++++ .../types/tools/ozone/signature/defs.ts | 25 +++ .../tools/ozone/signature/findCorrelation.ts | 46 +++++ .../ozone/signature/findRelatedAccounts.ts | 71 +++++++ .../tools/ozone/signature/searchAccounts.ts | 49 +++++ packages/pds/src/lexicon/index.ts | 46 +++++ packages/pds/src/lexicon/lexicons.ts | 180 ++++++++++++++++++ .../types/tools/ozone/signature/defs.ts | 25 +++ .../tools/ozone/signature/findCorrelation.ts | 46 +++++ .../ozone/signature/findRelatedAccounts.ts | 71 +++++++ .../tools/ozone/signature/searchAccounts.ts | 49 +++++ 24 files changed, 1443 insertions(+) create mode 100644 .changeset/flat-actors-clap.md create mode 100644 lexicons/tools/ozone/signature/defs.json create mode 100644 lexicons/tools/ozone/signature/findCorrelation.json create mode 100644 lexicons/tools/ozone/signature/findRelatedAccounts.json create mode 100644 lexicons/tools/ozone/signature/searchAccounts.json create mode 100644 packages/api/src/client/types/tools/ozone/signature/defs.ts create mode 100644 packages/api/src/client/types/tools/ozone/signature/findCorrelation.ts create mode 100644 packages/api/src/client/types/tools/ozone/signature/findRelatedAccounts.ts create mode 100644 packages/api/src/client/types/tools/ozone/signature/searchAccounts.ts create mode 100644 packages/ozone/src/lexicon/types/tools/ozone/signature/defs.ts create mode 100644 packages/ozone/src/lexicon/types/tools/ozone/signature/findCorrelation.ts create mode 100644 packages/ozone/src/lexicon/types/tools/ozone/signature/findRelatedAccounts.ts create mode 100644 packages/ozone/src/lexicon/types/tools/ozone/signature/searchAccounts.ts create mode 100644 packages/pds/src/lexicon/types/tools/ozone/signature/defs.ts create mode 100644 packages/pds/src/lexicon/types/tools/ozone/signature/findCorrelation.ts create mode 100644 packages/pds/src/lexicon/types/tools/ozone/signature/findRelatedAccounts.ts create mode 100644 packages/pds/src/lexicon/types/tools/ozone/signature/searchAccounts.ts diff --git a/.changeset/flat-actors-clap.md b/.changeset/flat-actors-clap.md new file mode 100644 index 00000000000..01830bbb86c --- /dev/null +++ b/.changeset/flat-actors-clap.md @@ -0,0 +1,6 @@ +--- +"@atproto/ozone": patch +"@atproto/api": patch +--- + +Add tools.ozone.signature lexicons diff --git a/lexicons/tools/ozone/signature/defs.json b/lexicons/tools/ozone/signature/defs.json new file mode 100644 index 00000000000..6c7297ebabd --- /dev/null +++ b/lexicons/tools/ozone/signature/defs.json @@ -0,0 +1,14 @@ +{ + "lexicon": 1, + "id": "tools.ozone.signature.defs", + "defs": { + "sigDetail": { + "type": "object", + "required": ["property", "value"], + "properties": { + "property": { "type": "string" }, + "value": { "type": "string" } + } + } + } +} diff --git a/lexicons/tools/ozone/signature/findCorrelation.json b/lexicons/tools/ozone/signature/findCorrelation.json new file mode 100644 index 00000000000..f803f25cd3b --- /dev/null +++ b/lexicons/tools/ozone/signature/findCorrelation.json @@ -0,0 +1,39 @@ +{ + "lexicon": 1, + "id": "tools.ozone.signature.findCorrelation", + "defs": { + "main": { + "type": "query", + "description": "Find all correlated threat signatures between 2 or more accounts.", + "parameters": { + "type": "params", + "required": ["dids"], + "properties": { + "dids": { + "type": "array", + "items": { + "type": "string", + "format": "did" + } + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["details"], + "properties": { + "details": { + "type": "array", + "items": { + "type": "ref", + "ref": "tools.ozone.signature.defs#sigDetail" + } + } + } + } + } + } + } +} diff --git a/lexicons/tools/ozone/signature/findRelatedAccounts.json b/lexicons/tools/ozone/signature/findRelatedAccounts.json new file mode 100644 index 00000000000..f5e4c7b057c --- /dev/null +++ b/lexicons/tools/ozone/signature/findRelatedAccounts.json @@ -0,0 +1,61 @@ +{ + "lexicon": 1, + "id": "tools.ozone.signature.findRelatedAccounts", + "defs": { + "main": { + "type": "query", + "description": "Get accounts that share some matching threat signatures with the root account.", + "parameters": { + "type": "params", + "required": ["did"], + "properties": { + "did": { + "type": "string", + "format": "did" + }, + "cursor": { "type": "string" }, + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 50 + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["accounts"], + "properties": { + "cursor": { "type": "string" }, + "accounts": { + "type": "array", + "items": { + "type": "ref", + "ref": "#relatedAccount" + } + } + } + } + } + }, + "relatedAccount": { + "type": "object", + "required": ["account"], + "properties": { + "account": { + "type": "ref", + "ref": "com.atproto.admin.defs#accountView" + }, + "similarities": { + "type": "array", + "items": { + "type": "ref", + "ref": "tools.ozone.signature.defs#sigDetail" + } + } + } + } + } +} diff --git a/lexicons/tools/ozone/signature/searchAccounts.json b/lexicons/tools/ozone/signature/searchAccounts.json new file mode 100644 index 00000000000..328d7787696 --- /dev/null +++ b/lexicons/tools/ozone/signature/searchAccounts.json @@ -0,0 +1,46 @@ +{ + "lexicon": 1, + "id": "tools.ozone.signature.searchAccounts", + "defs": { + "main": { + "type": "query", + "description": "Search for accounts that match one or more threat signature values.", + "parameters": { + "type": "params", + "required": ["values"], + "properties": { + "values": { + "type": "array", + "items": { + "type": "string" + } + }, + "cursor": { "type": "string" }, + "limit": { + "type": "integer", + "minimum": 1, + "maximum": 100, + "default": 50 + } + } + }, + "output": { + "encoding": "application/json", + "schema": { + "type": "object", + "required": ["accounts"], + "properties": { + "cursor": { "type": "string" }, + "accounts": { + "type": "array", + "items": { + "type": "ref", + "ref": "com.atproto.admin.defs#accountView" + } + } + } + } + } + } + } +} diff --git a/packages/api/src/client/index.ts b/packages/api/src/client/index.ts index 54261756229..ef839da17d8 100644 --- a/packages/api/src/client/index.ts +++ b/packages/api/src/client/index.ts @@ -206,6 +206,10 @@ import * as ToolsOzoneModerationQueryEvents from './types/tools/ozone/moderation import * as ToolsOzoneModerationQueryStatuses from './types/tools/ozone/moderation/queryStatuses' import * as ToolsOzoneModerationSearchRepos from './types/tools/ozone/moderation/searchRepos' import * as ToolsOzoneServerGetConfig from './types/tools/ozone/server/getConfig' +import * as ToolsOzoneSignatureDefs from './types/tools/ozone/signature/defs' +import * as ToolsOzoneSignatureFindCorrelation from './types/tools/ozone/signature/findCorrelation' +import * as ToolsOzoneSignatureFindRelatedAccounts from './types/tools/ozone/signature/findRelatedAccounts' +import * as ToolsOzoneSignatureSearchAccounts from './types/tools/ozone/signature/searchAccounts' import * as ToolsOzoneTeamAddMember from './types/tools/ozone/team/addMember' import * as ToolsOzoneTeamDefs from './types/tools/ozone/team/defs' import * as ToolsOzoneTeamDeleteMember from './types/tools/ozone/team/deleteMember' @@ -414,6 +418,10 @@ export * as ToolsOzoneModerationQueryEvents from './types/tools/ozone/moderation export * as ToolsOzoneModerationQueryStatuses from './types/tools/ozone/moderation/queryStatuses' export * as ToolsOzoneModerationSearchRepos from './types/tools/ozone/moderation/searchRepos' export * as ToolsOzoneServerGetConfig from './types/tools/ozone/server/getConfig' +export * as ToolsOzoneSignatureDefs from './types/tools/ozone/signature/defs' +export * as ToolsOzoneSignatureFindCorrelation from './types/tools/ozone/signature/findCorrelation' +export * as ToolsOzoneSignatureFindRelatedAccounts from './types/tools/ozone/signature/findRelatedAccounts' +export * as ToolsOzoneSignatureSearchAccounts from './types/tools/ozone/signature/searchAccounts' export * as ToolsOzoneTeamAddMember from './types/tools/ozone/team/addMember' export * as ToolsOzoneTeamDefs from './types/tools/ozone/team/defs' export * as ToolsOzoneTeamDeleteMember from './types/tools/ozone/team/deleteMember' @@ -3396,6 +3404,7 @@ export class ToolsOzoneNS { communication: ToolsOzoneCommunicationNS moderation: ToolsOzoneModerationNS server: ToolsOzoneServerNS + signature: ToolsOzoneSignatureNS team: ToolsOzoneTeamNS constructor(client: XrpcClient) { @@ -3403,6 +3412,7 @@ export class ToolsOzoneNS { this.communication = new ToolsOzoneCommunicationNS(client) this.moderation = new ToolsOzoneModerationNS(client) this.server = new ToolsOzoneServerNS(client) + this.signature = new ToolsOzoneSignatureNS(client) this.team = new ToolsOzoneTeamNS(client) } } @@ -3594,6 +3604,50 @@ export class ToolsOzoneServerNS { } } +export class ToolsOzoneSignatureNS { + _client: XrpcClient + + constructor(client: XrpcClient) { + this._client = client + } + + findCorrelation( + params?: ToolsOzoneSignatureFindCorrelation.QueryParams, + opts?: ToolsOzoneSignatureFindCorrelation.CallOptions, + ): Promise { + return this._client.call( + 'tools.ozone.signature.findCorrelation', + params, + undefined, + opts, + ) + } + + findRelatedAccounts( + params?: ToolsOzoneSignatureFindRelatedAccounts.QueryParams, + opts?: ToolsOzoneSignatureFindRelatedAccounts.CallOptions, + ): Promise { + return this._client.call( + 'tools.ozone.signature.findRelatedAccounts', + params, + undefined, + opts, + ) + } + + searchAccounts( + params?: ToolsOzoneSignatureSearchAccounts.QueryParams, + opts?: ToolsOzoneSignatureSearchAccounts.CallOptions, + ): Promise { + return this._client.call( + 'tools.ozone.signature.searchAccounts', + params, + undefined, + opts, + ) + } +} + export class ToolsOzoneTeamNS { _client: XrpcClient diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index 7d81b9cad81..7b373bca624 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -12139,6 +12139,181 @@ export const schemaDict = { }, }, }, + ToolsOzoneSignatureDefs: { + lexicon: 1, + id: 'tools.ozone.signature.defs', + defs: { + sigDetail: { + type: 'object', + required: ['property', 'value'], + properties: { + property: { + type: 'string', + }, + value: { + type: 'string', + }, + }, + }, + }, + }, + ToolsOzoneSignatureFindCorrelation: { + lexicon: 1, + id: 'tools.ozone.signature.findCorrelation', + defs: { + main: { + type: 'query', + description: + 'Find all correlated threat signatures between 2 or more accounts.', + parameters: { + type: 'params', + required: ['dids'], + properties: { + dids: { + type: 'array', + items: { + type: 'string', + format: 'did', + }, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['details'], + properties: { + details: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:tools.ozone.signature.defs#sigDetail', + }, + }, + }, + }, + }, + }, + }, + }, + ToolsOzoneSignatureFindRelatedAccounts: { + lexicon: 1, + id: 'tools.ozone.signature.findRelatedAccounts', + defs: { + main: { + type: 'query', + description: + 'Get accounts that share some matching threat signatures with the root account.', + parameters: { + type: 'params', + required: ['did'], + properties: { + did: { + type: 'string', + format: 'did', + }, + cursor: { + type: 'string', + }, + limit: { + type: 'integer', + minimum: 1, + maximum: 100, + default: 50, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['accounts'], + properties: { + cursor: { + type: 'string', + }, + accounts: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:tools.ozone.signature.findRelatedAccounts#relatedAccount', + }, + }, + }, + }, + }, + }, + relatedAccount: { + type: 'object', + required: ['account'], + properties: { + account: { + type: 'ref', + ref: 'lex:com.atproto.admin.defs#accountView', + }, + similarities: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:tools.ozone.signature.defs#sigDetail', + }, + }, + }, + }, + }, + }, + ToolsOzoneSignatureSearchAccounts: { + lexicon: 1, + id: 'tools.ozone.signature.searchAccounts', + defs: { + main: { + type: 'query', + description: + 'Search for accounts that match one or more threat signature values.', + parameters: { + type: 'params', + required: ['values'], + properties: { + values: { + type: 'array', + items: { + type: 'string', + }, + }, + cursor: { + type: 'string', + }, + limit: { + type: 'integer', + minimum: 1, + maximum: 100, + default: 50, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['accounts'], + properties: { + cursor: { + type: 'string', + }, + accounts: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:com.atproto.admin.defs#accountView', + }, + }, + }, + }, + }, + }, + }, + }, ToolsOzoneTeamAddMember: { lexicon: 1, id: 'tools.ozone.team.addMember', @@ -12589,6 +12764,11 @@ export const ids = { ToolsOzoneModerationQueryStatuses: 'tools.ozone.moderation.queryStatuses', ToolsOzoneModerationSearchRepos: 'tools.ozone.moderation.searchRepos', ToolsOzoneServerGetConfig: 'tools.ozone.server.getConfig', + ToolsOzoneSignatureDefs: 'tools.ozone.signature.defs', + ToolsOzoneSignatureFindCorrelation: 'tools.ozone.signature.findCorrelation', + ToolsOzoneSignatureFindRelatedAccounts: + 'tools.ozone.signature.findRelatedAccounts', + ToolsOzoneSignatureSearchAccounts: 'tools.ozone.signature.searchAccounts', ToolsOzoneTeamAddMember: 'tools.ozone.team.addMember', ToolsOzoneTeamDefs: 'tools.ozone.team.defs', ToolsOzoneTeamDeleteMember: 'tools.ozone.team.deleteMember', diff --git a/packages/api/src/client/types/tools/ozone/signature/defs.ts b/packages/api/src/client/types/tools/ozone/signature/defs.ts new file mode 100644 index 00000000000..1ab8f12a45b --- /dev/null +++ b/packages/api/src/client/types/tools/ozone/signature/defs.ts @@ -0,0 +1,25 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { isObj, hasProp } from '../../../../util' +import { lexicons } from '../../../../lexicons' +import { CID } from 'multiformats/cid' + +export interface SigDetail { + property: string + value: string + [k: string]: unknown +} + +export function isSigDetail(v: unknown): v is SigDetail { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'tools.ozone.signature.defs#sigDetail' + ) +} + +export function validateSigDetail(v: unknown): ValidationResult { + return lexicons.validate('tools.ozone.signature.defs#sigDetail', v) +} diff --git a/packages/api/src/client/types/tools/ozone/signature/findCorrelation.ts b/packages/api/src/client/types/tools/ozone/signature/findCorrelation.ts new file mode 100644 index 00000000000..f04a5c735d2 --- /dev/null +++ b/packages/api/src/client/types/tools/ozone/signature/findCorrelation.ts @@ -0,0 +1,35 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { HeadersMap, XRPCError } from '@atproto/xrpc' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { isObj, hasProp } from '../../../../util' +import { lexicons } from '../../../../lexicons' +import { CID } from 'multiformats/cid' +import * as ToolsOzoneSignatureDefs from './defs' + +export interface QueryParams { + dids: string[] +} + +export type InputSchema = undefined + +export interface OutputSchema { + details: ToolsOzoneSignatureDefs.SigDetail[] + [k: string]: unknown +} + +export interface CallOptions { + signal?: AbortSignal + headers?: HeadersMap +} + +export interface Response { + success: boolean + headers: HeadersMap + data: OutputSchema +} + +export function toKnownErr(e: any) { + return e +} diff --git a/packages/api/src/client/types/tools/ozone/signature/findRelatedAccounts.ts b/packages/api/src/client/types/tools/ozone/signature/findRelatedAccounts.ts new file mode 100644 index 00000000000..b817bbef60e --- /dev/null +++ b/packages/api/src/client/types/tools/ozone/signature/findRelatedAccounts.ts @@ -0,0 +1,60 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { HeadersMap, XRPCError } from '@atproto/xrpc' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { isObj, hasProp } from '../../../../util' +import { lexicons } from '../../../../lexicons' +import { CID } from 'multiformats/cid' +import * as ComAtprotoAdminDefs from '../../../com/atproto/admin/defs' +import * as ToolsOzoneSignatureDefs from './defs' + +export interface QueryParams { + did: string + cursor?: string + limit?: number +} + +export type InputSchema = undefined + +export interface OutputSchema { + cursor?: string + accounts: RelatedAccount[] + [k: string]: unknown +} + +export interface CallOptions { + signal?: AbortSignal + headers?: HeadersMap +} + +export interface Response { + success: boolean + headers: HeadersMap + data: OutputSchema +} + +export function toKnownErr(e: any) { + return e +} + +export interface RelatedAccount { + account: ComAtprotoAdminDefs.AccountView + similarities?: ToolsOzoneSignatureDefs.SigDetail[] + [k: string]: unknown +} + +export function isRelatedAccount(v: unknown): v is RelatedAccount { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'tools.ozone.signature.findRelatedAccounts#relatedAccount' + ) +} + +export function validateRelatedAccount(v: unknown): ValidationResult { + return lexicons.validate( + 'tools.ozone.signature.findRelatedAccounts#relatedAccount', + v, + ) +} diff --git a/packages/api/src/client/types/tools/ozone/signature/searchAccounts.ts b/packages/api/src/client/types/tools/ozone/signature/searchAccounts.ts new file mode 100644 index 00000000000..70e37b77458 --- /dev/null +++ b/packages/api/src/client/types/tools/ozone/signature/searchAccounts.ts @@ -0,0 +1,38 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { HeadersMap, XRPCError } from '@atproto/xrpc' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { isObj, hasProp } from '../../../../util' +import { lexicons } from '../../../../lexicons' +import { CID } from 'multiformats/cid' +import * as ComAtprotoAdminDefs from '../../../com/atproto/admin/defs' + +export interface QueryParams { + values: string[] + cursor?: string + limit?: number +} + +export type InputSchema = undefined + +export interface OutputSchema { + cursor?: string + accounts: ComAtprotoAdminDefs.AccountView[] + [k: string]: unknown +} + +export interface CallOptions { + signal?: AbortSignal + headers?: HeadersMap +} + +export interface Response { + success: boolean + headers: HeadersMap + data: OutputSchema +} + +export function toKnownErr(e: any) { + return e +} diff --git a/packages/ozone/src/api/proxied.ts b/packages/ozone/src/api/proxied.ts index 2b55a0c499a..ddea67b186d 100644 --- a/packages/ozone/src/api/proxied.ts +++ b/packages/ozone/src/api/proxied.ts @@ -160,6 +160,57 @@ export default function (server: Server, ctx: AppContext) { }, }) + server.tools.ozone.signature.findRelatedAccounts({ + auth: ctx.authVerifier.moderator, + handler: async (request) => { + if (!ctx.pdsAgent) { + throw new Error('PDS not configured') + } + const res = await ctx.pdsAgent.tools.ozone.signature.findRelatedAccounts( + request.params, + await ctx.pdsAuth(ids.ToolsOzoneSignatureFindRelatedAccounts), + ) + return { + encoding: 'application/json', + body: res.data, + } + }, + }) + + server.tools.ozone.signature.searchAccounts({ + auth: ctx.authVerifier.moderator, + handler: async (request) => { + if (!ctx.pdsAgent) { + throw new Error('PDS not configured') + } + const res = await ctx.pdsAgent.tools.ozone.signature.searchAccounts( + request.params, + await ctx.pdsAuth(ids.ToolsOzoneSignatureSearchAccounts), + ) + return { + encoding: 'application/json', + body: res.data, + } + }, + }) + + server.tools.ozone.signature.findCorrelation({ + auth: ctx.authVerifier.moderator, + handler: async (request) => { + if (!ctx.pdsAgent) { + throw new Error('PDS not configured') + } + const res = await ctx.pdsAgent.tools.ozone.signature.findCorrelation( + request.params, + await ctx.pdsAuth(ids.ToolsOzoneSignatureFindCorrelation), + ) + return { + encoding: 'application/json', + body: res.data, + } + }, + }) + server.app.bsky.graph.getStarterPack({ auth: ctx.authVerifier.moderator, handler: async (request) => { diff --git a/packages/ozone/src/lexicon/index.ts b/packages/ozone/src/lexicon/index.ts index 09b0832fdf9..97c1a3b9f35 100644 --- a/packages/ozone/src/lexicon/index.ts +++ b/packages/ozone/src/lexicon/index.ts @@ -173,6 +173,9 @@ import * as ToolsOzoneModerationQueryEvents from './types/tools/ozone/moderation import * as ToolsOzoneModerationQueryStatuses from './types/tools/ozone/moderation/queryStatuses' import * as ToolsOzoneModerationSearchRepos from './types/tools/ozone/moderation/searchRepos' import * as ToolsOzoneServerGetConfig from './types/tools/ozone/server/getConfig' +import * as ToolsOzoneSignatureFindCorrelation from './types/tools/ozone/signature/findCorrelation' +import * as ToolsOzoneSignatureFindRelatedAccounts from './types/tools/ozone/signature/findRelatedAccounts' +import * as ToolsOzoneSignatureSearchAccounts from './types/tools/ozone/signature/searchAccounts' import * as ToolsOzoneTeamAddMember from './types/tools/ozone/team/addMember' import * as ToolsOzoneTeamDeleteMember from './types/tools/ozone/team/deleteMember' import * as ToolsOzoneTeamListMembers from './types/tools/ozone/team/listMembers' @@ -2161,6 +2164,7 @@ export class ToolsOzoneNS { communication: ToolsOzoneCommunicationNS moderation: ToolsOzoneModerationNS server: ToolsOzoneServerNS + signature: ToolsOzoneSignatureNS team: ToolsOzoneTeamNS constructor(server: Server) { @@ -2168,6 +2172,7 @@ export class ToolsOzoneNS { this.communication = new ToolsOzoneCommunicationNS(server) this.moderation = new ToolsOzoneModerationNS(server) this.server = new ToolsOzoneServerNS(server) + this.signature = new ToolsOzoneSignatureNS(server) this.team = new ToolsOzoneTeamNS(server) } } @@ -2350,6 +2355,47 @@ export class ToolsOzoneServerNS { } } +export class ToolsOzoneSignatureNS { + _server: Server + + constructor(server: Server) { + this._server = server + } + + findCorrelation( + cfg: ConfigOf< + AV, + ToolsOzoneSignatureFindCorrelation.Handler>, + ToolsOzoneSignatureFindCorrelation.HandlerReqCtx> + >, + ) { + const nsid = 'tools.ozone.signature.findCorrelation' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + + findRelatedAccounts( + cfg: ConfigOf< + AV, + ToolsOzoneSignatureFindRelatedAccounts.Handler>, + ToolsOzoneSignatureFindRelatedAccounts.HandlerReqCtx> + >, + ) { + const nsid = 'tools.ozone.signature.findRelatedAccounts' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + + searchAccounts( + cfg: ConfigOf< + AV, + ToolsOzoneSignatureSearchAccounts.Handler>, + ToolsOzoneSignatureSearchAccounts.HandlerReqCtx> + >, + ) { + const nsid = 'tools.ozone.signature.searchAccounts' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } +} + export class ToolsOzoneTeamNS { _server: Server diff --git a/packages/ozone/src/lexicon/lexicons.ts b/packages/ozone/src/lexicon/lexicons.ts index 7d81b9cad81..7b373bca624 100644 --- a/packages/ozone/src/lexicon/lexicons.ts +++ b/packages/ozone/src/lexicon/lexicons.ts @@ -12139,6 +12139,181 @@ export const schemaDict = { }, }, }, + ToolsOzoneSignatureDefs: { + lexicon: 1, + id: 'tools.ozone.signature.defs', + defs: { + sigDetail: { + type: 'object', + required: ['property', 'value'], + properties: { + property: { + type: 'string', + }, + value: { + type: 'string', + }, + }, + }, + }, + }, + ToolsOzoneSignatureFindCorrelation: { + lexicon: 1, + id: 'tools.ozone.signature.findCorrelation', + defs: { + main: { + type: 'query', + description: + 'Find all correlated threat signatures between 2 or more accounts.', + parameters: { + type: 'params', + required: ['dids'], + properties: { + dids: { + type: 'array', + items: { + type: 'string', + format: 'did', + }, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['details'], + properties: { + details: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:tools.ozone.signature.defs#sigDetail', + }, + }, + }, + }, + }, + }, + }, + }, + ToolsOzoneSignatureFindRelatedAccounts: { + lexicon: 1, + id: 'tools.ozone.signature.findRelatedAccounts', + defs: { + main: { + type: 'query', + description: + 'Get accounts that share some matching threat signatures with the root account.', + parameters: { + type: 'params', + required: ['did'], + properties: { + did: { + type: 'string', + format: 'did', + }, + cursor: { + type: 'string', + }, + limit: { + type: 'integer', + minimum: 1, + maximum: 100, + default: 50, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['accounts'], + properties: { + cursor: { + type: 'string', + }, + accounts: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:tools.ozone.signature.findRelatedAccounts#relatedAccount', + }, + }, + }, + }, + }, + }, + relatedAccount: { + type: 'object', + required: ['account'], + properties: { + account: { + type: 'ref', + ref: 'lex:com.atproto.admin.defs#accountView', + }, + similarities: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:tools.ozone.signature.defs#sigDetail', + }, + }, + }, + }, + }, + }, + ToolsOzoneSignatureSearchAccounts: { + lexicon: 1, + id: 'tools.ozone.signature.searchAccounts', + defs: { + main: { + type: 'query', + description: + 'Search for accounts that match one or more threat signature values.', + parameters: { + type: 'params', + required: ['values'], + properties: { + values: { + type: 'array', + items: { + type: 'string', + }, + }, + cursor: { + type: 'string', + }, + limit: { + type: 'integer', + minimum: 1, + maximum: 100, + default: 50, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['accounts'], + properties: { + cursor: { + type: 'string', + }, + accounts: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:com.atproto.admin.defs#accountView', + }, + }, + }, + }, + }, + }, + }, + }, ToolsOzoneTeamAddMember: { lexicon: 1, id: 'tools.ozone.team.addMember', @@ -12589,6 +12764,11 @@ export const ids = { ToolsOzoneModerationQueryStatuses: 'tools.ozone.moderation.queryStatuses', ToolsOzoneModerationSearchRepos: 'tools.ozone.moderation.searchRepos', ToolsOzoneServerGetConfig: 'tools.ozone.server.getConfig', + ToolsOzoneSignatureDefs: 'tools.ozone.signature.defs', + ToolsOzoneSignatureFindCorrelation: 'tools.ozone.signature.findCorrelation', + ToolsOzoneSignatureFindRelatedAccounts: + 'tools.ozone.signature.findRelatedAccounts', + ToolsOzoneSignatureSearchAccounts: 'tools.ozone.signature.searchAccounts', ToolsOzoneTeamAddMember: 'tools.ozone.team.addMember', ToolsOzoneTeamDefs: 'tools.ozone.team.defs', ToolsOzoneTeamDeleteMember: 'tools.ozone.team.deleteMember', diff --git a/packages/ozone/src/lexicon/types/tools/ozone/signature/defs.ts b/packages/ozone/src/lexicon/types/tools/ozone/signature/defs.ts new file mode 100644 index 00000000000..2c9d9604aaa --- /dev/null +++ b/packages/ozone/src/lexicon/types/tools/ozone/signature/defs.ts @@ -0,0 +1,25 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' + +export interface SigDetail { + property: string + value: string + [k: string]: unknown +} + +export function isSigDetail(v: unknown): v is SigDetail { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'tools.ozone.signature.defs#sigDetail' + ) +} + +export function validateSigDetail(v: unknown): ValidationResult { + return lexicons.validate('tools.ozone.signature.defs#sigDetail', v) +} diff --git a/packages/ozone/src/lexicon/types/tools/ozone/signature/findCorrelation.ts b/packages/ozone/src/lexicon/types/tools/ozone/signature/findCorrelation.ts new file mode 100644 index 00000000000..c3eced05a5e --- /dev/null +++ b/packages/ozone/src/lexicon/types/tools/ozone/signature/findCorrelation.ts @@ -0,0 +1,46 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import * as ToolsOzoneSignatureDefs from './defs' + +export interface QueryParams { + dids: string[] +} + +export type InputSchema = undefined + +export interface OutputSchema { + details: ToolsOzoneSignatureDefs.SigDetail[] + [k: string]: unknown +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/ozone/src/lexicon/types/tools/ozone/signature/findRelatedAccounts.ts b/packages/ozone/src/lexicon/types/tools/ozone/signature/findRelatedAccounts.ts new file mode 100644 index 00000000000..821d5c6c080 --- /dev/null +++ b/packages/ozone/src/lexicon/types/tools/ozone/signature/findRelatedAccounts.ts @@ -0,0 +1,71 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import * as ComAtprotoAdminDefs from '../../../com/atproto/admin/defs' +import * as ToolsOzoneSignatureDefs from './defs' + +export interface QueryParams { + did: string + cursor?: string + limit: number +} + +export type InputSchema = undefined + +export interface OutputSchema { + cursor?: string + accounts: RelatedAccount[] + [k: string]: unknown +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput + +export interface RelatedAccount { + account: ComAtprotoAdminDefs.AccountView + similarities?: ToolsOzoneSignatureDefs.SigDetail[] + [k: string]: unknown +} + +export function isRelatedAccount(v: unknown): v is RelatedAccount { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'tools.ozone.signature.findRelatedAccounts#relatedAccount' + ) +} + +export function validateRelatedAccount(v: unknown): ValidationResult { + return lexicons.validate( + 'tools.ozone.signature.findRelatedAccounts#relatedAccount', + v, + ) +} diff --git a/packages/ozone/src/lexicon/types/tools/ozone/signature/searchAccounts.ts b/packages/ozone/src/lexicon/types/tools/ozone/signature/searchAccounts.ts new file mode 100644 index 00000000000..4e37745aa4a --- /dev/null +++ b/packages/ozone/src/lexicon/types/tools/ozone/signature/searchAccounts.ts @@ -0,0 +1,49 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import * as ComAtprotoAdminDefs from '../../../com/atproto/admin/defs' + +export interface QueryParams { + values: string[] + cursor?: string + limit: number +} + +export type InputSchema = undefined + +export interface OutputSchema { + cursor?: string + accounts: ComAtprotoAdminDefs.AccountView[] + [k: string]: unknown +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/pds/src/lexicon/index.ts b/packages/pds/src/lexicon/index.ts index 09b0832fdf9..97c1a3b9f35 100644 --- a/packages/pds/src/lexicon/index.ts +++ b/packages/pds/src/lexicon/index.ts @@ -173,6 +173,9 @@ import * as ToolsOzoneModerationQueryEvents from './types/tools/ozone/moderation import * as ToolsOzoneModerationQueryStatuses from './types/tools/ozone/moderation/queryStatuses' import * as ToolsOzoneModerationSearchRepos from './types/tools/ozone/moderation/searchRepos' import * as ToolsOzoneServerGetConfig from './types/tools/ozone/server/getConfig' +import * as ToolsOzoneSignatureFindCorrelation from './types/tools/ozone/signature/findCorrelation' +import * as ToolsOzoneSignatureFindRelatedAccounts from './types/tools/ozone/signature/findRelatedAccounts' +import * as ToolsOzoneSignatureSearchAccounts from './types/tools/ozone/signature/searchAccounts' import * as ToolsOzoneTeamAddMember from './types/tools/ozone/team/addMember' import * as ToolsOzoneTeamDeleteMember from './types/tools/ozone/team/deleteMember' import * as ToolsOzoneTeamListMembers from './types/tools/ozone/team/listMembers' @@ -2161,6 +2164,7 @@ export class ToolsOzoneNS { communication: ToolsOzoneCommunicationNS moderation: ToolsOzoneModerationNS server: ToolsOzoneServerNS + signature: ToolsOzoneSignatureNS team: ToolsOzoneTeamNS constructor(server: Server) { @@ -2168,6 +2172,7 @@ export class ToolsOzoneNS { this.communication = new ToolsOzoneCommunicationNS(server) this.moderation = new ToolsOzoneModerationNS(server) this.server = new ToolsOzoneServerNS(server) + this.signature = new ToolsOzoneSignatureNS(server) this.team = new ToolsOzoneTeamNS(server) } } @@ -2350,6 +2355,47 @@ export class ToolsOzoneServerNS { } } +export class ToolsOzoneSignatureNS { + _server: Server + + constructor(server: Server) { + this._server = server + } + + findCorrelation( + cfg: ConfigOf< + AV, + ToolsOzoneSignatureFindCorrelation.Handler>, + ToolsOzoneSignatureFindCorrelation.HandlerReqCtx> + >, + ) { + const nsid = 'tools.ozone.signature.findCorrelation' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + + findRelatedAccounts( + cfg: ConfigOf< + AV, + ToolsOzoneSignatureFindRelatedAccounts.Handler>, + ToolsOzoneSignatureFindRelatedAccounts.HandlerReqCtx> + >, + ) { + const nsid = 'tools.ozone.signature.findRelatedAccounts' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } + + searchAccounts( + cfg: ConfigOf< + AV, + ToolsOzoneSignatureSearchAccounts.Handler>, + ToolsOzoneSignatureSearchAccounts.HandlerReqCtx> + >, + ) { + const nsid = 'tools.ozone.signature.searchAccounts' // @ts-ignore + return this._server.xrpc.method(nsid, cfg) + } +} + export class ToolsOzoneTeamNS { _server: Server diff --git a/packages/pds/src/lexicon/lexicons.ts b/packages/pds/src/lexicon/lexicons.ts index 7d81b9cad81..7b373bca624 100644 --- a/packages/pds/src/lexicon/lexicons.ts +++ b/packages/pds/src/lexicon/lexicons.ts @@ -12139,6 +12139,181 @@ export const schemaDict = { }, }, }, + ToolsOzoneSignatureDefs: { + lexicon: 1, + id: 'tools.ozone.signature.defs', + defs: { + sigDetail: { + type: 'object', + required: ['property', 'value'], + properties: { + property: { + type: 'string', + }, + value: { + type: 'string', + }, + }, + }, + }, + }, + ToolsOzoneSignatureFindCorrelation: { + lexicon: 1, + id: 'tools.ozone.signature.findCorrelation', + defs: { + main: { + type: 'query', + description: + 'Find all correlated threat signatures between 2 or more accounts.', + parameters: { + type: 'params', + required: ['dids'], + properties: { + dids: { + type: 'array', + items: { + type: 'string', + format: 'did', + }, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['details'], + properties: { + details: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:tools.ozone.signature.defs#sigDetail', + }, + }, + }, + }, + }, + }, + }, + }, + ToolsOzoneSignatureFindRelatedAccounts: { + lexicon: 1, + id: 'tools.ozone.signature.findRelatedAccounts', + defs: { + main: { + type: 'query', + description: + 'Get accounts that share some matching threat signatures with the root account.', + parameters: { + type: 'params', + required: ['did'], + properties: { + did: { + type: 'string', + format: 'did', + }, + cursor: { + type: 'string', + }, + limit: { + type: 'integer', + minimum: 1, + maximum: 100, + default: 50, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['accounts'], + properties: { + cursor: { + type: 'string', + }, + accounts: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:tools.ozone.signature.findRelatedAccounts#relatedAccount', + }, + }, + }, + }, + }, + }, + relatedAccount: { + type: 'object', + required: ['account'], + properties: { + account: { + type: 'ref', + ref: 'lex:com.atproto.admin.defs#accountView', + }, + similarities: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:tools.ozone.signature.defs#sigDetail', + }, + }, + }, + }, + }, + }, + ToolsOzoneSignatureSearchAccounts: { + lexicon: 1, + id: 'tools.ozone.signature.searchAccounts', + defs: { + main: { + type: 'query', + description: + 'Search for accounts that match one or more threat signature values.', + parameters: { + type: 'params', + required: ['values'], + properties: { + values: { + type: 'array', + items: { + type: 'string', + }, + }, + cursor: { + type: 'string', + }, + limit: { + type: 'integer', + minimum: 1, + maximum: 100, + default: 50, + }, + }, + }, + output: { + encoding: 'application/json', + schema: { + type: 'object', + required: ['accounts'], + properties: { + cursor: { + type: 'string', + }, + accounts: { + type: 'array', + items: { + type: 'ref', + ref: 'lex:com.atproto.admin.defs#accountView', + }, + }, + }, + }, + }, + }, + }, + }, ToolsOzoneTeamAddMember: { lexicon: 1, id: 'tools.ozone.team.addMember', @@ -12589,6 +12764,11 @@ export const ids = { ToolsOzoneModerationQueryStatuses: 'tools.ozone.moderation.queryStatuses', ToolsOzoneModerationSearchRepos: 'tools.ozone.moderation.searchRepos', ToolsOzoneServerGetConfig: 'tools.ozone.server.getConfig', + ToolsOzoneSignatureDefs: 'tools.ozone.signature.defs', + ToolsOzoneSignatureFindCorrelation: 'tools.ozone.signature.findCorrelation', + ToolsOzoneSignatureFindRelatedAccounts: + 'tools.ozone.signature.findRelatedAccounts', + ToolsOzoneSignatureSearchAccounts: 'tools.ozone.signature.searchAccounts', ToolsOzoneTeamAddMember: 'tools.ozone.team.addMember', ToolsOzoneTeamDefs: 'tools.ozone.team.defs', ToolsOzoneTeamDeleteMember: 'tools.ozone.team.deleteMember', diff --git a/packages/pds/src/lexicon/types/tools/ozone/signature/defs.ts b/packages/pds/src/lexicon/types/tools/ozone/signature/defs.ts new file mode 100644 index 00000000000..2c9d9604aaa --- /dev/null +++ b/packages/pds/src/lexicon/types/tools/ozone/signature/defs.ts @@ -0,0 +1,25 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' + +export interface SigDetail { + property: string + value: string + [k: string]: unknown +} + +export function isSigDetail(v: unknown): v is SigDetail { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'tools.ozone.signature.defs#sigDetail' + ) +} + +export function validateSigDetail(v: unknown): ValidationResult { + return lexicons.validate('tools.ozone.signature.defs#sigDetail', v) +} diff --git a/packages/pds/src/lexicon/types/tools/ozone/signature/findCorrelation.ts b/packages/pds/src/lexicon/types/tools/ozone/signature/findCorrelation.ts new file mode 100644 index 00000000000..c3eced05a5e --- /dev/null +++ b/packages/pds/src/lexicon/types/tools/ozone/signature/findCorrelation.ts @@ -0,0 +1,46 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import * as ToolsOzoneSignatureDefs from './defs' + +export interface QueryParams { + dids: string[] +} + +export type InputSchema = undefined + +export interface OutputSchema { + details: ToolsOzoneSignatureDefs.SigDetail[] + [k: string]: unknown +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput diff --git a/packages/pds/src/lexicon/types/tools/ozone/signature/findRelatedAccounts.ts b/packages/pds/src/lexicon/types/tools/ozone/signature/findRelatedAccounts.ts new file mode 100644 index 00000000000..821d5c6c080 --- /dev/null +++ b/packages/pds/src/lexicon/types/tools/ozone/signature/findRelatedAccounts.ts @@ -0,0 +1,71 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import * as ComAtprotoAdminDefs from '../../../com/atproto/admin/defs' +import * as ToolsOzoneSignatureDefs from './defs' + +export interface QueryParams { + did: string + cursor?: string + limit: number +} + +export type InputSchema = undefined + +export interface OutputSchema { + cursor?: string + accounts: RelatedAccount[] + [k: string]: unknown +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput + +export interface RelatedAccount { + account: ComAtprotoAdminDefs.AccountView + similarities?: ToolsOzoneSignatureDefs.SigDetail[] + [k: string]: unknown +} + +export function isRelatedAccount(v: unknown): v is RelatedAccount { + return ( + isObj(v) && + hasProp(v, '$type') && + v.$type === 'tools.ozone.signature.findRelatedAccounts#relatedAccount' + ) +} + +export function validateRelatedAccount(v: unknown): ValidationResult { + return lexicons.validate( + 'tools.ozone.signature.findRelatedAccounts#relatedAccount', + v, + ) +} diff --git a/packages/pds/src/lexicon/types/tools/ozone/signature/searchAccounts.ts b/packages/pds/src/lexicon/types/tools/ozone/signature/searchAccounts.ts new file mode 100644 index 00000000000..4e37745aa4a --- /dev/null +++ b/packages/pds/src/lexicon/types/tools/ozone/signature/searchAccounts.ts @@ -0,0 +1,49 @@ +/** + * GENERATED CODE - DO NOT MODIFY + */ +import express from 'express' +import { ValidationResult, BlobRef } from '@atproto/lexicon' +import { lexicons } from '../../../../lexicons' +import { isObj, hasProp } from '../../../../util' +import { CID } from 'multiformats/cid' +import { HandlerAuth, HandlerPipeThrough } from '@atproto/xrpc-server' +import * as ComAtprotoAdminDefs from '../../../com/atproto/admin/defs' + +export interface QueryParams { + values: string[] + cursor?: string + limit: number +} + +export type InputSchema = undefined + +export interface OutputSchema { + cursor?: string + accounts: ComAtprotoAdminDefs.AccountView[] + [k: string]: unknown +} + +export type HandlerInput = undefined + +export interface HandlerSuccess { + encoding: 'application/json' + body: OutputSchema + headers?: { [key: string]: string } +} + +export interface HandlerError { + status: number + message?: string +} + +export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough +export type HandlerReqCtx = { + auth: HA + params: QueryParams + input: HandlerInput + req: express.Request + res: express.Response +} +export type Handler = ( + ctx: HandlerReqCtx, +) => Promise | HandlerOutput