Skip to content

Commit

Permalink
Lexicons: email auth factor (#2416)
Browse files Browse the repository at this point in the history
* lexicon: email auth factor

* add changeset
  • Loading branch information
devinivy committed Apr 17, 2024
1 parent cc090d2 commit 93a4a4d
Show file tree
Hide file tree
Showing 20 changed files with 103 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changeset/afraid-starfishes-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@atproto/api": patch
"@atproto/pds": patch
---

Support for email auth factor lexicons
11 changes: 8 additions & 3 deletions lexicons/com/atproto/server/createSession.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"type": "string",
"description": "Handle or other identifier supported by the server for the authenticating user."
},
"password": { "type": "string" }
"password": { "type": "string" },
"authFactorToken": { "type": "string" }
}
}
},
Expand All @@ -31,11 +32,15 @@
"did": { "type": "string", "format": "did" },
"didDoc": { "type": "unknown" },
"email": { "type": "string" },
"emailConfirmed": { "type": "boolean" }
"emailConfirmed": { "type": "boolean" },
"emailAuthFactor": { "type": "boolean" }
}
}
},
"errors": [{ "name": "AccountTakedown" }]
"errors": [
{ "name": "AccountTakedown" },
{ "name": "AuthFactorTokenRequired" }
]
}
}
}
1 change: 1 addition & 0 deletions lexicons/com/atproto/server/getSession.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"did": { "type": "string", "format": "did" },
"email": { "type": "string" },
"emailConfirmed": { "type": "boolean" },
"emailAuthFactor": { "type": "boolean" },
"didDoc": { "type": "unknown" }
}
}
Expand Down
1 change: 1 addition & 0 deletions lexicons/com/atproto/server/updateEmail.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"required": ["email"],
"properties": {
"email": { "type": "string" },
"emailAuthFactor": { "type": "boolean" },
"token": {
"type": "string",
"description": "Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed."
Expand Down
15 changes: 15 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,9 @@ export const schemaDict = {
password: {
type: 'string',
},
authFactorToken: {
type: 'string',
},
},
},
},
Expand Down Expand Up @@ -2241,13 +2244,19 @@ export const schemaDict = {
emailConfirmed: {
type: 'boolean',
},
emailAuthFactor: {
type: 'boolean',
},
},
},
},
errors: [
{
name: 'AccountTakedown',
},
{
name: 'AuthFactorTokenRequired',
},
],
},
},
Expand Down Expand Up @@ -2568,6 +2577,9 @@ export const schemaDict = {
emailConfirmed: {
type: 'boolean',
},
emailAuthFactor: {
type: 'boolean',
},
didDoc: {
type: 'unknown',
},
Expand Down Expand Up @@ -2837,6 +2849,9 @@ export const schemaDict = {
email: {
type: 'string',
},
emailAuthFactor: {
type: 'boolean',
},
token: {
type: 'string',
description:
Expand Down
10 changes: 10 additions & 0 deletions packages/api/src/client/types/com/atproto/server/createSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface InputSchema {
/** Handle or other identifier supported by the server for the authenticating user. */
identifier: string
password: string
authFactorToken?: string
[k: string]: unknown
}

Expand All @@ -24,6 +25,7 @@ export interface OutputSchema {
didDoc?: {}
email?: string
emailConfirmed?: boolean
emailAuthFactor?: boolean
[k: string]: unknown
}

Expand All @@ -45,9 +47,17 @@ export class AccountTakedownError extends XRPCError {
}
}

export class AuthFactorTokenRequiredError extends XRPCError {
constructor(src: XRPCError) {
super(src.status, src.error, src.message, src.headers)
}
}

export function toKnownErr(e: any) {
if (e instanceof XRPCError) {
if (e.error === 'AccountTakedown') return new AccountTakedownError(e)
if (e.error === 'AuthFactorTokenRequired')
return new AuthFactorTokenRequiredError(e)
}
return e
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface OutputSchema {
did: string
email?: string
emailConfirmed?: boolean
emailAuthFactor?: boolean
didDoc?: {}
[k: string]: unknown
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface QueryParams {}

export interface InputSchema {
email: string
emailAuthFactor?: boolean
/** Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed. */
token?: string
[k: string]: unknown
Expand Down
15 changes: 15 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,9 @@ export const schemaDict = {
password: {
type: 'string',
},
authFactorToken: {
type: 'string',
},
},
},
},
Expand Down Expand Up @@ -2241,13 +2244,19 @@ export const schemaDict = {
emailConfirmed: {
type: 'boolean',
},
emailAuthFactor: {
type: 'boolean',
},
},
},
},
errors: [
{
name: 'AccountTakedown',
},
{
name: 'AuthFactorTokenRequired',
},
],
},
},
Expand Down Expand Up @@ -2568,6 +2577,9 @@ export const schemaDict = {
emailConfirmed: {
type: 'boolean',
},
emailAuthFactor: {
type: 'boolean',
},
didDoc: {
type: 'unknown',
},
Expand Down Expand Up @@ -2837,6 +2849,9 @@ export const schemaDict = {
email: {
type: 'string',
},
emailAuthFactor: {
type: 'boolean',
},
token: {
type: 'string',
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface InputSchema {
/** Handle or other identifier supported by the server for the authenticating user. */
identifier: string
password: string
authFactorToken?: string
[k: string]: unknown
}

Expand All @@ -25,6 +26,7 @@ export interface OutputSchema {
didDoc?: {}
email?: string
emailConfirmed?: boolean
emailAuthFactor?: boolean
[k: string]: unknown
}

Expand All @@ -42,7 +44,7 @@ export interface HandlerSuccess {
export interface HandlerError {
status: number
message?: string
error?: 'AccountTakedown'
error?: 'AccountTakedown' | 'AuthFactorTokenRequired'
}

export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface OutputSchema {
did: string
email?: string
emailConfirmed?: boolean
emailAuthFactor?: boolean
didDoc?: {}
[k: string]: unknown
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface QueryParams {}

export interface InputSchema {
email: string
emailAuthFactor?: boolean
/** Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed. */
token?: string
[k: string]: unknown
Expand Down
15 changes: 15 additions & 0 deletions packages/ozone/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,9 @@ export const schemaDict = {
password: {
type: 'string',
},
authFactorToken: {
type: 'string',
},
},
},
},
Expand Down Expand Up @@ -2241,13 +2244,19 @@ export const schemaDict = {
emailConfirmed: {
type: 'boolean',
},
emailAuthFactor: {
type: 'boolean',
},
},
},
},
errors: [
{
name: 'AccountTakedown',
},
{
name: 'AuthFactorTokenRequired',
},
],
},
},
Expand Down Expand Up @@ -2568,6 +2577,9 @@ export const schemaDict = {
emailConfirmed: {
type: 'boolean',
},
emailAuthFactor: {
type: 'boolean',
},
didDoc: {
type: 'unknown',
},
Expand Down Expand Up @@ -2837,6 +2849,9 @@ export const schemaDict = {
email: {
type: 'string',
},
emailAuthFactor: {
type: 'boolean',
},
token: {
type: 'string',
description:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface InputSchema {
/** Handle or other identifier supported by the server for the authenticating user. */
identifier: string
password: string
authFactorToken?: string
[k: string]: unknown
}

Expand All @@ -25,6 +26,7 @@ export interface OutputSchema {
didDoc?: {}
email?: string
emailConfirmed?: boolean
emailAuthFactor?: boolean
[k: string]: unknown
}

Expand All @@ -42,7 +44,7 @@ export interface HandlerSuccess {
export interface HandlerError {
status: number
message?: string
error?: 'AccountTakedown'
error?: 'AccountTakedown' | 'AuthFactorTokenRequired'
}

export type HandlerOutput = HandlerError | HandlerSuccess | HandlerPipeThrough
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface OutputSchema {
did: string
email?: string
emailConfirmed?: boolean
emailAuthFactor?: boolean
didDoc?: {}
[k: string]: unknown
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface QueryParams {}

export interface InputSchema {
email: string
emailAuthFactor?: boolean
/** Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed. */
token?: string
[k: string]: unknown
Expand Down
15 changes: 15 additions & 0 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,9 @@ export const schemaDict = {
password: {
type: 'string',
},
authFactorToken: {
type: 'string',
},
},
},
},
Expand Down Expand Up @@ -2241,13 +2244,19 @@ export const schemaDict = {
emailConfirmed: {
type: 'boolean',
},
emailAuthFactor: {
type: 'boolean',
},
},
},
},
errors: [
{
name: 'AccountTakedown',
},
{
name: 'AuthFactorTokenRequired',
},
],
},
},
Expand Down Expand Up @@ -2568,6 +2577,9 @@ export const schemaDict = {
emailConfirmed: {
type: 'boolean',
},
emailAuthFactor: {
type: 'boolean',
},
didDoc: {
type: 'unknown',
},
Expand Down Expand Up @@ -2837,6 +2849,9 @@ export const schemaDict = {
email: {
type: 'string',
},
emailAuthFactor: {
type: 'boolean',
},
token: {
type: 'string',
description:
Expand Down

0 comments on commit 93a4a4d

Please sign in to comment.