Skip to content

Commit

Permalink
Tweak schemas for entryway createAccount (#1797)
Browse files Browse the repository at this point in the history
* tweak scheams

* require email & password
  • Loading branch information
dholms committed Nov 1, 2023
1 parent a161f81 commit cf848e8
Show file tree
Hide file tree
Showing 12 changed files with 87 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lexicons/com/atproto/server/createAccount.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["handle", "email", "password"],
"required": ["handle"],
"properties": {
"email": { "type": "string" },
"handle": { "type": "string", "format": "handle" },
Expand Down
12 changes: 12 additions & 0 deletions lexicons/com/atproto/server/reserveSigningKey.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
"main": {
"type": "procedure",
"description": "Reserve a repo signing key for account creation.",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"properties": {
"did": {
"type": "string",
"description": "The did to reserve a new did:key for"
}
}
}
},
"output": {
"encoding": "application/json",
"schema": {
Expand Down
14 changes: 13 additions & 1 deletion packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,7 @@ export const schemaDict = {
encoding: 'application/json',
schema: {
type: 'object',
required: ['handle', 'email', 'password'],
required: ['handle'],
properties: {
email: {
type: 'string',
Expand Down Expand Up @@ -3170,6 +3170,18 @@ export const schemaDict = {
main: {
type: 'procedure',
description: 'Reserve a repo signing key for account creation.',
input: {
encoding: 'application/json',
schema: {
type: 'object',
properties: {
did: {
type: 'string',
description: 'The did to reserve a new did:key for',
},
},
},
},
output: {
encoding: 'application/json',
schema: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { CID } from 'multiformats/cid'
export interface QueryParams {}

export interface InputSchema {
email: string
email?: string
handle: string
did?: string
inviteCode?: string
password: string
password?: string
recoveryKey?: string
plcOp?: {}
[k: string]: unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import { CID } from 'multiformats/cid'

export interface QueryParams {}

export type InputSchema = undefined
export interface InputSchema {
/** The did to reserve a new did:key for */
did?: string
[k: string]: unknown
}

export interface OutputSchema {
/** Public signing key in the form of a did:key. */
Expand All @@ -20,6 +24,7 @@ export interface OutputSchema {
export interface CallOptions {
headers?: Headers
qp?: QueryParams
encoding: 'application/json'
}

export interface Response {
Expand Down
14 changes: 13 additions & 1 deletion packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,7 @@ export const schemaDict = {
encoding: 'application/json',
schema: {
type: 'object',
required: ['handle', 'email', 'password'],
required: ['handle'],
properties: {
email: {
type: 'string',
Expand Down Expand Up @@ -3170,6 +3170,18 @@ export const schemaDict = {
main: {
type: 'procedure',
description: 'Reserve a repo signing key for account creation.',
input: {
encoding: 'application/json',
schema: {
type: 'object',
properties: {
did: {
type: 'string',
description: 'The did to reserve a new did:key for',
},
},
},
},
output: {
encoding: 'application/json',
schema: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { HandlerAuth } from '@atproto/xrpc-server'
export interface QueryParams {}

export interface InputSchema {
email: string
email?: string
handle: string
did?: string
inviteCode?: string
password: string
password?: string
recoveryKey?: string
plcOp?: {}
[k: string]: unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@ import { HandlerAuth } from '@atproto/xrpc-server'

export interface QueryParams {}

export type InputSchema = undefined
export interface InputSchema {
/** The did to reserve a new did:key for */
did?: string
[k: string]: unknown
}

export interface OutputSchema {
/** Public signing key in the form of a did:key. */
signingKey: string
[k: string]: unknown
}

export type HandlerInput = undefined
export interface HandlerInput {
encoding: 'application/json'
body: InputSchema
}

export interface HandlerSuccess {
encoding: 'application/json'
Expand Down
6 changes: 5 additions & 1 deletion packages/pds/src/api/com/atproto/server/createAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export default function (server: Server, ctx: AppContext) {
},
handler: async ({ input, req }) => {
const { email, password, inviteCode } = input.body
if (input.body.plcOp) {
if (!email) {
throw new InvalidRequestError('Missing input: "email"')
} else if (!password) {
throw new InvalidRequestError('Missing input: "password"')
} else if (input.body.plcOp) {
throw new InvalidRequestError('Unsupported input: "plcOp"')
}

Expand Down
14 changes: 13 additions & 1 deletion packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,7 @@ export const schemaDict = {
encoding: 'application/json',
schema: {
type: 'object',
required: ['handle', 'email', 'password'],
required: ['handle'],
properties: {
email: {
type: 'string',
Expand Down Expand Up @@ -3170,6 +3170,18 @@ export const schemaDict = {
main: {
type: 'procedure',
description: 'Reserve a repo signing key for account creation.',
input: {
encoding: 'application/json',
schema: {
type: 'object',
properties: {
did: {
type: 'string',
description: 'The did to reserve a new did:key for',
},
},
},
},
output: {
encoding: 'application/json',
schema: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { HandlerAuth } from '@atproto/xrpc-server'
export interface QueryParams {}

export interface InputSchema {
email: string
email?: string
handle: string
did?: string
inviteCode?: string
password: string
password?: string
recoveryKey?: string
plcOp?: {}
[k: string]: unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,22 @@ import { HandlerAuth } from '@atproto/xrpc-server'

export interface QueryParams {}

export type InputSchema = undefined
export interface InputSchema {
/** The did to reserve a new did:key for */
did?: string
[k: string]: unknown
}

export interface OutputSchema {
/** Public signing key in the form of a did:key. */
signingKey: string
[k: string]: unknown
}

export type HandlerInput = undefined
export interface HandlerInput {
encoding: 'application/json'
body: InputSchema
}

export interface HandlerSuccess {
encoding: 'application/json'
Expand Down

0 comments on commit cf848e8

Please sign in to comment.