Skip to content

Commit

Permalink
Add email auth factor tools to API (#2419)
Browse files Browse the repository at this point in the history
* Add authFactorToken to session object

* Add changeset
  • Loading branch information
pfrazee authored Apr 18, 2024
1 parent 32c97d4 commit 3424a17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-boxes-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/api": patch
---

Add authFactorToken to session objects
4 changes: 4 additions & 0 deletions packages/api/src/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export class AtpAgent {
did: res.data.did,
email: opts.email,
emailConfirmed: false,
emailAuthFactor: false,
}
this._updateApiEndpoint(res.data.didDoc)
return res
Expand All @@ -173,6 +174,7 @@ export class AtpAgent {
const res = await this.api.com.atproto.server.createSession({
identifier: opts.identifier,
password: opts.password,
authFactorToken: opts.authFactorToken,
})
this.session = {
accessJwt: res.data.accessJwt,
Expand All @@ -181,6 +183,7 @@ export class AtpAgent {
did: res.data.did,
email: res.data.email,
emailConfirmed: res.data.emailConfirmed,
emailAuthFactor: res.data.emailAuthFactor,
}
this._updateApiEndpoint(res.data.didDoc)
return res
Expand Down Expand Up @@ -215,6 +218,7 @@ export class AtpAgent {
this.session.email = res.data.email
this.session.handle = res.data.handle
this.session.emailConfirmed = res.data.emailConfirmed
this.session.emailAuthFactor = res.data.emailAuthFactor
this._updateApiEndpoint(res.data.didDoc)
this._persistSession?.('update', this.session)
return res
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export interface AtpSessionData {
did: string
email?: string
emailConfirmed?: boolean
emailAuthFactor?: boolean
}

/**
Expand All @@ -50,6 +51,7 @@ export interface AtpAgentOpts {
export interface AtpAgentLoginOpts {
identifier: string
password: string
authFactorToken?: string | undefined
}

/**
Expand Down

0 comments on commit 3424a17

Please sign in to comment.