Skip to content

Commit

Permalink
feat: fix MFA endpoint by adding cookie (#48)
Browse files Browse the repository at this point in the history
* feat: Sms, Email, Refresh token

Added sms, email and refresh token implementation

* Added email and sms interfaces

* Fixed format

* Implemented set password

* removed console log

* Removed one more log

* feat: MFA endpoints

* bug: fixed enable mfa

* Fixed by prettier
  • Loading branch information
dshilovprpl authored Feb 15, 2024
1 parent 9036f1d commit db0c701
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/mfa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,22 @@ export class MfaSDK {
payload.append('passcode', passcode)
return (await this.request.post('mfa/setup/verify', payload, {
headers: payload.getHeaders(),
withCredentials: true,
})) as unknown as Promise<AxiosResponse<{ data: string }>>
}

public async enable(data: MfaData) {
public async enable(data: MfaData, cookie: any = null) {
if (!this.request) {
throw new Error('request init failed')
}

const payload = this.prepareMfaPayload(data)
console.log(payload)
const headers = payload.getHeaders()
if (cookie) headers.Cookie = cookie

return (await this.request.post('mfa/setup/enable', payload, {
headers: payload.getHeaders(),
headers: headers,
withCredentials: true,
})) as unknown as Promise<AxiosResponse<{ data: string }>>
}

Expand Down
4 changes: 2 additions & 2 deletions src/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ export class SDK {
return await this.mfaSDK.verify(data, passcode)
}

public async enableMfa(data: MfaData) {
return await this.mfaSDK.enable(data)
public async enableMfa(data: MfaData, cookie: any = null) {
return await this.mfaSDK.enable(data, cookie)
}

public async setPreferredMfa(data: MfaData) {
Expand Down

0 comments on commit db0c701

Please sign in to comment.