logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

mfa.js (995B)


  1. const verifyOTPCode = ({ clientId, clientSecret, instance, mfaToken, code }) => {
  2. const url = `${instance}/oauth/mfa/challenge`
  3. const form = new window.FormData()
  4. form.append('client_id', clientId)
  5. form.append('client_secret', clientSecret)
  6. form.append('mfa_token', mfaToken)
  7. form.append('code', code)
  8. form.append('challenge_type', 'totp')
  9. return window.fetch(url, {
  10. method: 'POST',
  11. body: form
  12. }).then((data) => data.json())
  13. }
  14. const verifyRecoveryCode = ({ clientId, clientSecret, instance, mfaToken, code }) => {
  15. const url = `${instance}/oauth/mfa/challenge`
  16. const form = new window.FormData()
  17. form.append('client_id', clientId)
  18. form.append('client_secret', clientSecret)
  19. form.append('mfa_token', mfaToken)
  20. form.append('code', code)
  21. form.append('challenge_type', 'recovery')
  22. return window.fetch(url, {
  23. method: 'POST',
  24. body: form
  25. }).then((data) => data.json())
  26. }
  27. const mfa = {
  28. verifyOTPCode,
  29. verifyRecoveryCode
  30. }
  31. export default mfa