Skip to content

Commit

Permalink
Phone verification schemas (#2056)
Browse files Browse the repository at this point in the history
* add phone verification schemas

* lint

* codegen

* changset
  • Loading branch information
dholms authored Jan 18, 2024
1 parent 7a4486d commit e43396a
Show file tree
Hide file tree
Showing 24 changed files with 339 additions and 78 deletions.
5 changes: 5 additions & 0 deletions .changeset/moody-kings-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@atproto/api': patch
---

Added phone verification methods/schemas to agent.
2 changes: 2 additions & 0 deletions lexicons/com/atproto/server/createAccount.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"handle": { "type": "string", "format": "handle" },
"did": { "type": "string", "format": "did" },
"inviteCode": { "type": "string" },
"verificationCode": { "type": "string" },
"verificationPhone": { "type": "string" },
"password": { "type": "string" },
"recoveryKey": { "type": "string" },
"plcOp": { "type": "unknown" }
Expand Down
1 change: 1 addition & 0 deletions lexicons/com/atproto/server/describeServer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"required": ["availableUserDomains"],
"properties": {
"inviteCodeRequired": { "type": "boolean" },
"phoneVerificationRequired": { "type": "boolean" },
"availableUserDomains": {
"type": "array",
"items": { "type": "string" }
Expand Down
20 changes: 20 additions & 0 deletions lexicons/com/atproto/temp/requestPhoneVerification.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"lexicon": 1,
"id": "com.atproto.temp.requestPhoneVerification",
"defs": {
"main": {
"type": "procedure",
"description": "Request a verification code to be sent to the supplied phone number",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["phoneNumber"],
"properties": {
"phoneNumber": { "type": "string" }
}
}
}
}
}
}
13 changes: 13 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscrib
import * as ComAtprotoTempFetchLabels from './types/com/atproto/temp/fetchLabels'
import * as ComAtprotoTempImportRepo from './types/com/atproto/temp/importRepo'
import * as ComAtprotoTempPushBlob from './types/com/atproto/temp/pushBlob'
import * as ComAtprotoTempRequestPhoneVerification from './types/com/atproto/temp/requestPhoneVerification'
import * as ComAtprotoTempTransferAccount from './types/com/atproto/temp/transferAccount'
import * as AppBskyActorDefs from './types/app/bsky/actor/defs'
import * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
Expand Down Expand Up @@ -219,6 +220,7 @@ export * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscrib
export * as ComAtprotoTempFetchLabels from './types/com/atproto/temp/fetchLabels'
export * as ComAtprotoTempImportRepo from './types/com/atproto/temp/importRepo'
export * as ComAtprotoTempPushBlob from './types/com/atproto/temp/pushBlob'
export * as ComAtprotoTempRequestPhoneVerification from './types/com/atproto/temp/requestPhoneVerification'
export * as ComAtprotoTempTransferAccount from './types/com/atproto/temp/transferAccount'
export * as AppBskyActorDefs from './types/app/bsky/actor/defs'
export * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
Expand Down Expand Up @@ -1162,6 +1164,17 @@ export class TempNS {
})
}

requestPhoneVerification(
data?: ComAtprotoTempRequestPhoneVerification.InputSchema,
opts?: ComAtprotoTempRequestPhoneVerification.CallOptions,
): Promise<ComAtprotoTempRequestPhoneVerification.Response> {
return this._service.xrpc
.call('com.atproto.temp.requestPhoneVerification', opts?.qp, data, opts)
.catch((e) => {
throw ComAtprotoTempRequestPhoneVerification.toKnownErr(e)
})
}

transferAccount(
data?: ComAtprotoTempTransferAccount.InputSchema,
opts?: ComAtprotoTempTransferAccount.CallOptions,
Expand Down
34 changes: 34 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,12 @@ export const schemaDict = {
inviteCode: {
type: 'string',
},
verificationCode: {
type: 'string',
},
verificationPhone: {
type: 'string',
},
password: {
type: 'string',
},
Expand Down Expand Up @@ -3068,6 +3074,9 @@ export const schemaDict = {
inviteCodeRequired: {
type: 'boolean',
},
phoneVerificationRequired: {
type: 'boolean',
},
availableUserDomains: {
type: 'array',
items: {
Expand Down Expand Up @@ -4140,6 +4149,29 @@ export const schemaDict = {
},
},
},
ComAtprotoTempRequestPhoneVerification: {
lexicon: 1,
id: 'com.atproto.temp.requestPhoneVerification',
defs: {
main: {
type: 'procedure',
description:
'Request a verification code to be sent to the supplied phone number',
input: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['phoneNumber'],
properties: {
phoneNumber: {
type: 'string',
},
},
},
},
},
},
},
ComAtprotoTempTransferAccount: {
lexicon: 1,
id: 'com.atproto.temp.transferAccount',
Expand Down Expand Up @@ -7944,6 +7976,8 @@ export const ids = {
ComAtprotoTempFetchLabels: 'com.atproto.temp.fetchLabels',
ComAtprotoTempImportRepo: 'com.atproto.temp.importRepo',
ComAtprotoTempPushBlob: 'com.atproto.temp.pushBlob',
ComAtprotoTempRequestPhoneVerification:
'com.atproto.temp.requestPhoneVerification',
ComAtprotoTempTransferAccount: 'com.atproto.temp.transferAccount',
AppBskyActorDefs: 'app.bsky.actor.defs',
AppBskyActorGetPreferences: 'app.bsky.actor.getPreferences',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface InputSchema {
handle: string
did?: string
inviteCode?: string
verificationCode?: string
verificationPhone?: string
password?: string
recoveryKey?: string
plcOp?: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type InputSchema = undefined

export interface OutputSchema {
inviteCodeRequired?: boolean
phoneVerificationRequired?: boolean
availableUserDomains: string[]
links?: Links
[k: string]: unknown
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* GENERATED CODE - DO NOT MODIFY
*/
import { Headers, XRPCError } from '@atproto/xrpc'
import { ValidationResult, BlobRef } from '@atproto/lexicon'
import { isObj, hasProp } from '../../../../util'
import { lexicons } from '../../../../lexicons'
import { CID } from 'multiformats/cid'

export interface QueryParams {}

export interface InputSchema {
phoneNumber: string
[k: string]: unknown
}

export interface CallOptions {
headers?: Headers
qp?: QueryParams
encoding: 'application/json'
}

export interface Response {
success: boolean
headers: Headers
}

export function toKnownErr(e: any) {
if (e instanceof XRPCError) {
}
return e
}
12 changes: 12 additions & 0 deletions packages/bsky/src/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscrib
import * as ComAtprotoTempFetchLabels from './types/com/atproto/temp/fetchLabels'
import * as ComAtprotoTempImportRepo from './types/com/atproto/temp/importRepo'
import * as ComAtprotoTempPushBlob from './types/com/atproto/temp/pushBlob'
import * as ComAtprotoTempRequestPhoneVerification from './types/com/atproto/temp/requestPhoneVerification'
import * as ComAtprotoTempTransferAccount from './types/com/atproto/temp/transferAccount'
import * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
import * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
Expand Down Expand Up @@ -1003,6 +1004,17 @@ export class TempNS {
return this._server.xrpc.method(nsid, cfg)
}

requestPhoneVerification<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
ComAtprotoTempRequestPhoneVerification.Handler<ExtractAuth<AV>>,
ComAtprotoTempRequestPhoneVerification.HandlerReqCtx<ExtractAuth<AV>>
>,
) {
const nsid = 'com.atproto.temp.requestPhoneVerification' // @ts-ignore
return this._server.xrpc.method(nsid, cfg)
}

transferAccount<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down
34 changes: 34 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2664,6 +2664,12 @@ export const schemaDict = {
inviteCode: {
type: 'string',
},
verificationCode: {
type: 'string',
},
verificationPhone: {
type: 'string',
},
password: {
type: 'string',
},
Expand Down Expand Up @@ -3068,6 +3074,9 @@ export const schemaDict = {
inviteCodeRequired: {
type: 'boolean',
},
phoneVerificationRequired: {
type: 'boolean',
},
availableUserDomains: {
type: 'array',
items: {
Expand Down Expand Up @@ -4140,6 +4149,29 @@ export const schemaDict = {
},
},
},
ComAtprotoTempRequestPhoneVerification: {
lexicon: 1,
id: 'com.atproto.temp.requestPhoneVerification',
defs: {
main: {
type: 'procedure',
description:
'Request a verification code to be sent to the supplied phone number',
input: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['phoneNumber'],
properties: {
phoneNumber: {
type: 'string',
},
},
},
},
},
},
},
ComAtprotoTempTransferAccount: {
lexicon: 1,
id: 'com.atproto.temp.transferAccount',
Expand Down Expand Up @@ -7944,6 +7976,8 @@ export const ids = {
ComAtprotoTempFetchLabels: 'com.atproto.temp.fetchLabels',
ComAtprotoTempImportRepo: 'com.atproto.temp.importRepo',
ComAtprotoTempPushBlob: 'com.atproto.temp.pushBlob',
ComAtprotoTempRequestPhoneVerification:
'com.atproto.temp.requestPhoneVerification',
ComAtprotoTempTransferAccount: 'com.atproto.temp.transferAccount',
AppBskyActorDefs: 'app.bsky.actor.defs',
AppBskyActorGetPreferences: 'app.bsky.actor.getPreferences',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface InputSchema {
handle: string
did?: string
inviteCode?: string
verificationCode?: string
verificationPhone?: string
password?: string
recoveryKey?: string
plcOp?: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type InputSchema = undefined

export interface OutputSchema {
inviteCodeRequired?: boolean
phoneVerificationRequired?: boolean
availableUserDomains: string[]
links?: Links
[k: string]: unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,25 @@ import { lexicons } from '../../../../lexicons'
import { isObj, hasProp } from '../../../../util'
import { CID } from 'multiformats/cid'
import { HandlerAuth } from '@atproto/xrpc-server'
import * as AppBskyFeedDefs from '../feed/defs'

export interface QueryParams {
includeNsfw: boolean
limit: number
cursor?: string
}

export type InputSchema = undefined
export interface QueryParams {}

export interface OutputSchema {
cursor?: string
feed: AppBskyFeedDefs.FeedViewPost[]
export interface InputSchema {
phoneNumber: string
[k: string]: unknown
}

export type HandlerInput = undefined

export interface HandlerSuccess {
export interface HandlerInput {
encoding: 'application/json'
body: OutputSchema
headers?: { [key: string]: string }
body: InputSchema
}

export interface HandlerError {
status: number
message?: string
}

export type HandlerOutput = HandlerError | HandlerSuccess
export type HandlerOutput = HandlerError | void
export type HandlerReqCtx<HA extends HandlerAuth = never> = {
auth: HA
params: QueryParams
Expand Down
24 changes: 12 additions & 12 deletions packages/ozone/src/lexicon/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscrib
import * as ComAtprotoTempFetchLabels from './types/com/atproto/temp/fetchLabels'
import * as ComAtprotoTempImportRepo from './types/com/atproto/temp/importRepo'
import * as ComAtprotoTempPushBlob from './types/com/atproto/temp/pushBlob'
import * as ComAtprotoTempRequestPhoneVerification from './types/com/atproto/temp/requestPhoneVerification'
import * as ComAtprotoTempTransferAccount from './types/com/atproto/temp/transferAccount'
import * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences'
import * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile'
Expand Down Expand Up @@ -118,7 +119,6 @@ import * as AppBskyNotificationGetUnreadCount from './types/app/bsky/notificatio
import * as AppBskyNotificationListNotifications from './types/app/bsky/notification/listNotifications'
import * as AppBskyNotificationRegisterPush from './types/app/bsky/notification/registerPush'
import * as AppBskyNotificationUpdateSeen from './types/app/bsky/notification/updateSeen'
import * as AppBskyUnspeccedGetPopular from './types/app/bsky/unspecced/getPopular'
import * as AppBskyUnspeccedGetPopularFeedGenerators from './types/app/bsky/unspecced/getPopularFeedGenerators'
import * as AppBskyUnspeccedGetTimelineSkeleton from './types/app/bsky/unspecced/getTimelineSkeleton'
import * as AppBskyUnspeccedSearchActorsSkeleton from './types/app/bsky/unspecced/searchActorsSkeleton'
Expand Down Expand Up @@ -1004,6 +1004,17 @@ export class TempNS {
return this._server.xrpc.method(nsid, cfg)
}

requestPhoneVerification<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
ComAtprotoTempRequestPhoneVerification.Handler<ExtractAuth<AV>>,
ComAtprotoTempRequestPhoneVerification.HandlerReqCtx<ExtractAuth<AV>>
>,
) {
const nsid = 'com.atproto.temp.requestPhoneVerification' // @ts-ignore
return this._server.xrpc.method(nsid, cfg)
}

transferAccount<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down Expand Up @@ -1543,17 +1554,6 @@ export class UnspeccedNS {
this._server = server
}

getPopular<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
AppBskyUnspeccedGetPopular.Handler<ExtractAuth<AV>>,
AppBskyUnspeccedGetPopular.HandlerReqCtx<ExtractAuth<AV>>
>,
) {
const nsid = 'app.bsky.unspecced.getPopular' // @ts-ignore
return this._server.xrpc.method(nsid, cfg)
}

getPopularFeedGenerators<AV extends AuthVerifier>(
cfg: ConfigOf<
AV,
Expand Down
Loading

0 comments on commit e43396a

Please sign in to comment.