MegaApiClient
MegaApiClient copied to clipboard
Contacts and shared folders support? Usage of owner IDs? Errors with attribute deserialization!
Hello, I've been looking to implement the ability to get shared folders and files from those shared folders from contacts that any Mega.io user can have in my own app, similar to how Mega does it on their website:
I noticed that these files are most probably appearing anyway using GetNodes(), mainly because the Owner for them is different than all the other files. However, there seems to be an issue with these Nodes that make it hard to exactly identify:
There's an exception in the Name field for these kind of files. Also, I've been wondering - is there any use for the Owner ID? I've searched the repo but didn't find any on my own. Most ideally I would wish to use it to get more information about the owner of that file, like their e-mail address or maybe even name since Mega does display this information on their website. Is it possible using the "g.api.mega.co.nz"?
I've debugged using dnSpy what's happening inside Node in OnDeserialized function. It seems the key for decrypting the attributes before they're about to be deserialized is wrong for files and folders shared from a different owner. The "SerializedKey" property (which in mega.nz's JSON response is "k") for my own files are always structured like this: "(Owner):(Key)", as opposed to these files from a different owner, where the key ("k") is structured like this: "(ParentId):(Key)". It doesn't seem to matter in code because there's a substring after the ":" char anyway, but I thought maybe something about it could help in fixing this issue of not being able to deserialize attributes properly.
Maybe the SharedKey has to be used?
EDIT: I just noticed that in Node class, SharedKey is supposed to be deserialized from the field named "sk" in mega.nz's JSON response. However, there is not a single "sk" present in that response - none of the Nodes have a SharedKey (it's all null).