user.js 671 B

1234567891011121314151617181920212223242526
  1. /* global Android */
  2. import User from '../app/user';
  3. import { deriveFileListKey } from '../app/fxa';
  4. export default class AndroidUser extends User {
  5. constructor(storage) {
  6. super(storage);
  7. }
  8. async login() {
  9. Android.beginOAuthFlow();
  10. }
  11. async finishLogin(accountInfo) {
  12. const jwks = JSON.parse(accountInfo.keys);
  13. const ikm = jwks['https://identity.mozilla.com/apps/send'].k;
  14. const profile = {
  15. displayName: accountInfo.displayName,
  16. email: accountInfo.email,
  17. avatar: accountInfo.avatar,
  18. access_token: accountInfo.accessToken
  19. };
  20. profile.fileListKey = await deriveFileListKey(ikm);
  21. this.info = profile;
  22. }
  23. }