diff options
| author | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-06-12 20:16:55 +0000 |
|---|---|---|
| committer | HJ <30-hj@users.noreply.git.pleroma.social> | 2019-06-12 20:16:55 +0000 |
| commit | e53f11c30fb2eedd0a437d3cfe9592c555de6a95 (patch) | |
| tree | 560ecc4d370fda07c5da8cde5c60c679fa9c7862 /src/services/new_api/mfa.js | |
| parent | 9df99c5205b1cb560bb25c0dd81cc90acbde4d7f (diff) | |
| parent | 77eceedbf7a5b53948d7d91b3d228aa303c02081 (diff) | |
Merge branch 'feature/2fa' into 'develop'
adds 2FA/two_factor_authentication support
See merge request pleroma/pleroma-fe!556
Diffstat (limited to 'src/services/new_api/mfa.js')
| -rw-r--r-- | src/services/new_api/mfa.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/services/new_api/mfa.js b/src/services/new_api/mfa.js new file mode 100644 index 00000000..ddf90e6b --- /dev/null +++ b/src/services/new_api/mfa.js @@ -0,0 +1,38 @@ +const verifyOTPCode = ({app, instance, mfaToken, code}) => { + const url = `${instance}/oauth/mfa/challenge` + const form = new window.FormData() + + form.append('client_id', app.client_id) + form.append('client_secret', app.client_secret) + form.append('mfa_token', mfaToken) + form.append('code', code) + form.append('challenge_type', 'totp') + + return window.fetch(url, { + method: 'POST', + body: form + }).then((data) => data.json()) +} + +const verifyRecoveryCode = ({app, instance, mfaToken, code}) => { + const url = `${instance}/oauth/mfa/challenge` + const form = new window.FormData() + + form.append('client_id', app.client_id) + form.append('client_secret', app.client_secret) + form.append('mfa_token', mfaToken) + form.append('code', code) + form.append('challenge_type', 'recovery') + + return window.fetch(url, { + method: 'POST', + body: form + }).then((data) => data.json()) +} + +const mfa = { + verifyOTPCode, + verifyRecoveryCode +} + +export default mfa |
