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

Clean up other email tokens #1572

Merged
merged 21 commits into from
Sep 28, 2023
27 changes: 27 additions & 0 deletions lexicons/com/atproto/server/confirmEmail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"lexicon": 1,
"id": "com.atproto.server.confirmEmail",
"defs": {
"main": {
"type": "procedure",
"description": "Confirm an email using a token from com.atproto.server.requestEmailConfirmation.",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["email", "token"],
"properties": {
"email": { "type": "string" },
"token": { "type": "string" }
}
}
},
"errors": [
{ "name": "UserNotFound" },
{ "name": "ExpiredToken" },
{ "name": "InvalidToken" },
{ "name": "InvalidEmail" }
]
}
}
}
3 changes: 2 additions & 1 deletion lexicons/com/atproto/server/createSession.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"refreshJwt": { "type": "string" },
"handle": { "type": "string", "format": "handle" },
"did": { "type": "string", "format": "did" },
"email": { "type": "string" }
"email": { "type": "string" },
"emailConfirmed": { "type": "boolean" }
}
}
},
Expand Down
3 changes: 2 additions & 1 deletion lexicons/com/atproto/server/getSession.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"properties": {
"handle": { "type": "string", "format": "handle" },
"did": { "type": "string", "format": "did" },
"email": { "type": "string" }
"email": { "type": "string" },
"emailConfirmed": { "type": "boolean" }
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions lexicons/com/atproto/server/requestEmailConfirmation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"lexicon": 1,
"id": "com.atproto.server.requestEmailConfirmation",
"defs": {
"main": {
"type": "procedure",
"description": "Request an email with a code to confirm ownership of email"
}
}
}
20 changes: 20 additions & 0 deletions lexicons/com/atproto/server/requestEmailUpdate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"lexicon": 1,
"id": "com.atproto.server.requestEmailUpdate",
"defs": {
"main": {
"type": "procedure",
"description": "Request a token in order to update email.",
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["tokenRequired"],
"properties": {
"tokenRequired": { "type": "boolean" }
}
}
}
}
}
}
29 changes: 29 additions & 0 deletions lexicons/com/atproto/server/updateEmail.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"lexicon": 1,
"id": "com.atproto.server.updateEmail",
"defs": {
"main": {
"type": "procedure",
"description": "Update an account's email.",
"input": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["email"],
"properties": {
"email": { "type": "string" },
"token": {
"type": "string",
"description": " Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed."
}
}
}
},
"errors": [
{ "name": "ExpiredToken" },
{ "name": "InvalidToken" },
{ "name": "TokenRequired" }
]
}
}
}
52 changes: 52 additions & 0 deletions packages/api/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords
import * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord'
import * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef'
import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
import * as ComAtprotoServerConfirmEmail from './types/com/atproto/server/confirmEmail'
import * as ComAtprotoServerCreateAccount from './types/com/atproto/server/createAccount'
import * as ComAtprotoServerCreateAppPassword from './types/com/atproto/server/createAppPassword'
import * as ComAtprotoServerCreateInviteCode from './types/com/atproto/server/createInviteCode'
Expand All @@ -55,9 +56,12 @@ import * as ComAtprotoServerGetSession from './types/com/atproto/server/getSessi
import * as ComAtprotoServerListAppPasswords from './types/com/atproto/server/listAppPasswords'
import * as ComAtprotoServerRefreshSession from './types/com/atproto/server/refreshSession'
import * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/server/requestAccountDelete'
import * as ComAtprotoServerRequestEmailConfirmation from './types/com/atproto/server/requestEmailConfirmation'
import * as ComAtprotoServerRequestEmailUpdate from './types/com/atproto/server/requestEmailUpdate'
import * as ComAtprotoServerRequestPasswordReset from './types/com/atproto/server/requestPasswordReset'
import * as ComAtprotoServerResetPassword from './types/com/atproto/server/resetPassword'
import * as ComAtprotoServerRevokeAppPassword from './types/com/atproto/server/revokeAppPassword'
import * as ComAtprotoServerUpdateEmail from './types/com/atproto/server/updateEmail'
import * as ComAtprotoSyncGetBlob from './types/com/atproto/sync/getBlob'
import * as ComAtprotoSyncGetBlocks from './types/com/atproto/sync/getBlocks'
import * as ComAtprotoSyncGetCheckout from './types/com/atproto/sync/getCheckout'
Expand Down Expand Up @@ -163,6 +167,7 @@ export * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords
export * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord'
export * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef'
export * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob'
export * as ComAtprotoServerConfirmEmail from './types/com/atproto/server/confirmEmail'
export * as ComAtprotoServerCreateAccount from './types/com/atproto/server/createAccount'
export * as ComAtprotoServerCreateAppPassword from './types/com/atproto/server/createAppPassword'
export * as ComAtprotoServerCreateInviteCode from './types/com/atproto/server/createInviteCode'
Expand All @@ -177,9 +182,12 @@ export * as ComAtprotoServerGetSession from './types/com/atproto/server/getSessi
export * as ComAtprotoServerListAppPasswords from './types/com/atproto/server/listAppPasswords'
export * as ComAtprotoServerRefreshSession from './types/com/atproto/server/refreshSession'
export * as ComAtprotoServerRequestAccountDelete from './types/com/atproto/server/requestAccountDelete'
export * as ComAtprotoServerRequestEmailConfirmation from './types/com/atproto/server/requestEmailConfirmation'
export * as ComAtprotoServerRequestEmailUpdate from './types/com/atproto/server/requestEmailUpdate'
export * as ComAtprotoServerRequestPasswordReset from './types/com/atproto/server/requestPasswordReset'
export * as ComAtprotoServerResetPassword from './types/com/atproto/server/resetPassword'
export * as ComAtprotoServerRevokeAppPassword from './types/com/atproto/server/revokeAppPassword'
export * as ComAtprotoServerUpdateEmail from './types/com/atproto/server/updateEmail'
export * as ComAtprotoSyncGetBlob from './types/com/atproto/sync/getBlob'
export * as ComAtprotoSyncGetBlocks from './types/com/atproto/sync/getBlocks'
export * as ComAtprotoSyncGetCheckout from './types/com/atproto/sync/getCheckout'
Expand Down Expand Up @@ -699,6 +707,17 @@ export class ServerNS {
this._service = service
}

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

createAccount(
data?: ComAtprotoServerCreateAccount.InputSchema,
opts?: ComAtprotoServerCreateAccount.CallOptions,
Expand Down Expand Up @@ -842,6 +861,28 @@ export class ServerNS {
})
}

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

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

requestPasswordReset(
data?: ComAtprotoServerRequestPasswordReset.InputSchema,
opts?: ComAtprotoServerRequestPasswordReset.CallOptions,
Expand Down Expand Up @@ -874,6 +915,17 @@ export class ServerNS {
throw ComAtprotoServerRevokeAppPassword.toKnownErr(e)
})
}

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

export class SyncNS {
Expand Down
122 changes: 122 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,46 @@ export const schemaDict = {
},
},
},
ComAtprotoServerConfirmEmail: {
lexicon: 1,
id: 'com.atproto.server.confirmEmail',
defs: {
main: {
type: 'procedure',
description:
'Confirm an email using a token from com.atproto.server.requestEmailConfirmation.',
input: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['email', 'token'],
properties: {
email: {
type: 'string',
},
token: {
type: 'string',
},
},
},
},
errors: [
{
name: 'UserNotFound',
},
{
name: 'ExpiredToken',
},
{
name: 'InvalidToken',
},
{
name: 'InvalidEmail',
},
],
},
},
},
ComAtprotoServerCreateAccount: {
lexicon: 1,
id: 'com.atproto.server.createAccount',
Expand Down Expand Up @@ -2522,6 +2562,9 @@ export const schemaDict = {
email: {
type: 'string',
},
emailConfirmed: {
type: 'boolean',
},
},
},
},
Expand Down Expand Up @@ -2752,6 +2795,9 @@ export const schemaDict = {
email: {
type: 'string',
},
emailConfirmed: {
type: 'boolean',
},
},
},
},
Expand Down Expand Up @@ -2850,6 +2896,39 @@ export const schemaDict = {
},
},
},
ComAtprotoServerRequestEmailConfirmation: {
lexicon: 1,
id: 'com.atproto.server.requestEmailConfirmation',
defs: {
main: {
type: 'procedure',
description:
'Request an email with a code to confirm ownership of email',
},
},
},
ComAtprotoServerRequestEmailUpdate: {
lexicon: 1,
id: 'com.atproto.server.requestEmailUpdate',
defs: {
main: {
type: 'procedure',
description: 'Request a token in order to update email.',
output: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['tokenRequired'],
properties: {
tokenRequired: {
type: 'boolean',
},
},
},
},
},
},
},
ComAtprotoServerRequestPasswordReset: {
lexicon: 1,
id: 'com.atproto.server.requestPasswordReset',
Expand Down Expand Up @@ -2927,6 +3006,44 @@ export const schemaDict = {
},
},
},
ComAtprotoServerUpdateEmail: {
lexicon: 1,
id: 'com.atproto.server.updateEmail',
defs: {
main: {
type: 'procedure',
description: "Update an account's email.",
input: {
encoding: 'application/json',
schema: {
type: 'object',
required: ['email'],
properties: {
email: {
type: 'string',
},
token: {
type: 'string',
description:
" Requires a token from com.atproto.sever.requestEmailUpdate if the account's email has been confirmed.",
},
},
},
},
errors: [
{
name: 'ExpiredToken',
},
{
name: 'InvalidToken',
},
{
name: 'TokenRequired',
},
],
},
},
},
ComAtprotoSyncGetBlob: {
lexicon: 1,
id: 'com.atproto.sync.getBlob',
Expand Down Expand Up @@ -6726,6 +6843,7 @@ export const ids = {
ComAtprotoRepoPutRecord: 'com.atproto.repo.putRecord',
ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef',
ComAtprotoRepoUploadBlob: 'com.atproto.repo.uploadBlob',
ComAtprotoServerConfirmEmail: 'com.atproto.server.confirmEmail',
ComAtprotoServerCreateAccount: 'com.atproto.server.createAccount',
ComAtprotoServerCreateAppPassword: 'com.atproto.server.createAppPassword',
ComAtprotoServerCreateInviteCode: 'com.atproto.server.createInviteCode',
Expand All @@ -6742,10 +6860,14 @@ export const ids = {
ComAtprotoServerRefreshSession: 'com.atproto.server.refreshSession',
ComAtprotoServerRequestAccountDelete:
'com.atproto.server.requestAccountDelete',
ComAtprotoServerRequestEmailConfirmation:
'com.atproto.server.requestEmailConfirmation',
ComAtprotoServerRequestEmailUpdate: 'com.atproto.server.requestEmailUpdate',
ComAtprotoServerRequestPasswordReset:
'com.atproto.server.requestPasswordReset',
ComAtprotoServerResetPassword: 'com.atproto.server.resetPassword',
ComAtprotoServerRevokeAppPassword: 'com.atproto.server.revokeAppPassword',
ComAtprotoServerUpdateEmail: 'com.atproto.server.updateEmail',
ComAtprotoSyncGetBlob: 'com.atproto.sync.getBlob',
ComAtprotoSyncGetBlocks: 'com.atproto.sync.getBlocks',
ComAtprotoSyncGetCheckout: 'com.atproto.sync.getCheckout',
Expand Down
Loading