From cf848e87ab5166a73a4803d0f46e4d529cde34fd Mon Sep 17 00:00:00 2001 From: Daniel Holmgren Date: Wed, 1 Nov 2023 14:56:57 -0500 Subject: [PATCH] Tweak schemas for entryway createAccount (#1797) * tweak scheams * require email & password --- lexicons/com/atproto/server/createAccount.json | 2 +- lexicons/com/atproto/server/reserveSigningKey.json | 12 ++++++++++++ packages/api/src/client/lexicons.ts | 14 +++++++++++++- .../types/com/atproto/server/createAccount.ts | 4 ++-- .../types/com/atproto/server/reserveSigningKey.ts | 7 ++++++- packages/bsky/src/lexicon/lexicons.ts | 14 +++++++++++++- .../types/com/atproto/server/createAccount.ts | 4 ++-- .../types/com/atproto/server/reserveSigningKey.ts | 11 +++++++++-- .../src/api/com/atproto/server/createAccount.ts | 6 +++++- packages/pds/src/lexicon/lexicons.ts | 14 +++++++++++++- .../types/com/atproto/server/createAccount.ts | 4 ++-- .../types/com/atproto/server/reserveSigningKey.ts | 11 +++++++++-- 12 files changed, 87 insertions(+), 16 deletions(-) diff --git a/lexicons/com/atproto/server/createAccount.json b/lexicons/com/atproto/server/createAccount.json index d9549624741..8d927163951 100644 --- a/lexicons/com/atproto/server/createAccount.json +++ b/lexicons/com/atproto/server/createAccount.json @@ -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" }, diff --git a/lexicons/com/atproto/server/reserveSigningKey.json b/lexicons/com/atproto/server/reserveSigningKey.json index 27fb0597b0a..3a67ad0a3c8 100644 --- a/lexicons/com/atproto/server/reserveSigningKey.json +++ b/lexicons/com/atproto/server/reserveSigningKey.json @@ -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": { diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index 4030fea961a..d9de1551bcc 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -2489,7 +2489,7 @@ export const schemaDict = { encoding: 'application/json', schema: { type: 'object', - required: ['handle', 'email', 'password'], + required: ['handle'], properties: { email: { type: 'string', @@ -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: { diff --git a/packages/api/src/client/types/com/atproto/server/createAccount.ts b/packages/api/src/client/types/com/atproto/server/createAccount.ts index b5fb32fe90b..7631727ef19 100644 --- a/packages/api/src/client/types/com/atproto/server/createAccount.ts +++ b/packages/api/src/client/types/com/atproto/server/createAccount.ts @@ -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 diff --git a/packages/api/src/client/types/com/atproto/server/reserveSigningKey.ts b/packages/api/src/client/types/com/atproto/server/reserveSigningKey.ts index e6f4f7a618a..f5e515ff5cf 100644 --- a/packages/api/src/client/types/com/atproto/server/reserveSigningKey.ts +++ b/packages/api/src/client/types/com/atproto/server/reserveSigningKey.ts @@ -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. */ @@ -20,6 +24,7 @@ export interface OutputSchema { export interface CallOptions { headers?: Headers qp?: QueryParams + encoding: 'application/json' } export interface Response { diff --git a/packages/bsky/src/lexicon/lexicons.ts b/packages/bsky/src/lexicon/lexicons.ts index 4030fea961a..d9de1551bcc 100644 --- a/packages/bsky/src/lexicon/lexicons.ts +++ b/packages/bsky/src/lexicon/lexicons.ts @@ -2489,7 +2489,7 @@ export const schemaDict = { encoding: 'application/json', schema: { type: 'object', - required: ['handle', 'email', 'password'], + required: ['handle'], properties: { email: { type: 'string', @@ -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: { diff --git a/packages/bsky/src/lexicon/types/com/atproto/server/createAccount.ts b/packages/bsky/src/lexicon/types/com/atproto/server/createAccount.ts index f82fe9ed82a..109d34cf202 100644 --- a/packages/bsky/src/lexicon/types/com/atproto/server/createAccount.ts +++ b/packages/bsky/src/lexicon/types/com/atproto/server/createAccount.ts @@ -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 diff --git a/packages/bsky/src/lexicon/types/com/atproto/server/reserveSigningKey.ts b/packages/bsky/src/lexicon/types/com/atproto/server/reserveSigningKey.ts index 495b87dc03c..ad5a5a8758c 100644 --- a/packages/bsky/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +++ b/packages/bsky/src/lexicon/types/com/atproto/server/reserveSigningKey.ts @@ -10,7 +10,11 @@ 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. */ @@ -18,7 +22,10 @@ export interface OutputSchema { [k: string]: unknown } -export type HandlerInput = undefined +export interface HandlerInput { + encoding: 'application/json' + body: InputSchema +} export interface HandlerSuccess { encoding: 'application/json' diff --git a/packages/pds/src/api/com/atproto/server/createAccount.ts b/packages/pds/src/api/com/atproto/server/createAccount.ts index f1343b3c4e2..e747eb4e9cc 100644 --- a/packages/pds/src/api/com/atproto/server/createAccount.ts +++ b/packages/pds/src/api/com/atproto/server/createAccount.ts @@ -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"') } diff --git a/packages/pds/src/lexicon/lexicons.ts b/packages/pds/src/lexicon/lexicons.ts index 4030fea961a..d9de1551bcc 100644 --- a/packages/pds/src/lexicon/lexicons.ts +++ b/packages/pds/src/lexicon/lexicons.ts @@ -2489,7 +2489,7 @@ export const schemaDict = { encoding: 'application/json', schema: { type: 'object', - required: ['handle', 'email', 'password'], + required: ['handle'], properties: { email: { type: 'string', @@ -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: { diff --git a/packages/pds/src/lexicon/types/com/atproto/server/createAccount.ts b/packages/pds/src/lexicon/types/com/atproto/server/createAccount.ts index f82fe9ed82a..109d34cf202 100644 --- a/packages/pds/src/lexicon/types/com/atproto/server/createAccount.ts +++ b/packages/pds/src/lexicon/types/com/atproto/server/createAccount.ts @@ -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 diff --git a/packages/pds/src/lexicon/types/com/atproto/server/reserveSigningKey.ts b/packages/pds/src/lexicon/types/com/atproto/server/reserveSigningKey.ts index 495b87dc03c..ad5a5a8758c 100644 --- a/packages/pds/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +++ b/packages/pds/src/lexicon/types/com/atproto/server/reserveSigningKey.ts @@ -10,7 +10,11 @@ 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. */ @@ -18,7 +22,10 @@ export interface OutputSchema { [k: string]: unknown } -export type HandlerInput = undefined +export interface HandlerInput { + encoding: 'application/json' + body: InputSchema +} export interface HandlerSuccess { encoding: 'application/json'