qgustavor / mega

Unofficial JavaScript SDK for MEGA
https://mega.js.org/
MIT License
159 stars 42 forks source link

Support new MEGA accounts #46

Closed ed-miller closed 5 years ago

ed-miller commented 5 years ago

Hi, when I use my old Mega Accounts and login with this API, it works fine.

When I create a new Mega Accounts and try to login with this API, error coming: EEXPIRED (-8): The upload target URL you are trying to access has expired. Please request a fresh one.

It seems that new accounts using another type of login?

qgustavor commented 5 years ago

https://github.com/megous/megatools/issues/411

Temporary fix: create an account using megareg.

I already expected changes in the login code because the old code is a bit messed (multiple rounds of AES-ECB as key derivation and non-standard RSA to authenticate). What I don't expected are they breaking third party clients.

I will check what was changed. On megatools issue seems no one explained in detail what changed.

qgustavor commented 5 years ago

The changes are in this commit. Either they changed everything in a single commit or they squash all commits in one. Most lines that changes are HTML or CSS files.

Some important changes:

What needs to be implemented:

I will try to finish implementing the mock server. At this time I think people from megatools will already have fixed issue 441. Then I can save some time by just checking what they changed and re-implementing it here.

ghost commented 5 years ago

People from megatools like your analysis of the changes. :) And it looks like that sans two factor auth, at least the login flow in megatools could be made compatible with the new API, without too many changes, and without any UI changes.

I suspect that the registration flow also changed, so that will probably not be supported in megatools anytime soon.

qgustavor commented 5 years ago

MegaApiClient (written in C#) supports new accounts since this commit. It was quite simple to implement.

I think MEGA will allow changing iteration count in future. It's quite simple to implement: just add this value to the "us0" request response on login and store iteration count when signing up or changing passwords. It will allow users make their accounts more secure at the spent of taking more time to login.

@megous Registration flow changed. Most changes are here. Other change in a later commit is that passwords with white spaces in the start or end are not allowed when signing up (here).

I'm not in a hurry to implement those changes on mega-js as megareg is still working. I don't know for how long it will keep working: MEGA might just drop support for V1 registration flow because it's "less secure".

qgustavor commented 5 years ago

For some reason I fell fixing this was easier than I expected...