Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lexicons: email auth factor #2416

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading
Loading