LiterateInk/Pawnote

Cannot use 'in' operator to search for '_Signature_' in undefined` when calling functions

niicojs opened this issue · 7 comments

Describe the bug
I'm getting Uncaught TypeError TypeError: Cannot use 'in' operator to search for '_Signature_' in undefined when calling functions.

To Reproduce
Steps to reproduce the behavior :

  1. Login using previous token (from a previous run or from the first pin + qrcode login)*
  2. Trying to get homework or grades

Expected behavior
Either getting the result or getting a proper error
After looking at the request I see that the reponse from pronote is:

{
  "Erreur": {
    "G": 3,
    "Titre": "Accès refusé",
    "Message": ""
  }
}

The library should parse the error and throwing a "Access Denied" rather than the cryptic error.
My related issue is why do I get this error?

What I'm seeing in the request is that signature is kind of empty compared to what I can see in the real browser app:

    "_Signature_": {
      "onglet": 88
    },

In the browser I can see a "member" field in the _Signature with some data. Could it be related?

Hello !

I just pushed a fix for the error not handled (c58b193).

Now the real issue is why are you getting this access denied.
Can you please show the code you used to get your assignments (I guess that's what you did since you're sending tab 88) ?

Here it is:

const session = createSessionHandle();
const refresh = await loginToken(session, {
  kind: login.kind,
  url: login.url,
  username: login.username,
  token: login.token,
  deviceUUID: login.deviceUUID,
});

// saving refresh and deviceid for next time

const devoirs = await assignmentsFromIntervals(
  session,
  startOfWeek(new Date()),
  endOfWeek(addDays(new Date(), 7))
);

I can't reproduce the issue sadly, let's dig...

What do you see in the member field in _Signature_ in your browser ?

Also, are you using the STUDENT account kind ?

I'm using a parent account, so that may be it.
In the browser, the signature has a membre field:

"membre": {
    "N": "(encrypted stuff?)",
    "G": 4
}

If I remember correctly, parent accounts are not fully supported yet.

I see, that's why.

Parents accounts are (for now) only available to authenticate (using all possible methods, even with 2FA), that's all.

They can't do more operations because for now we're trying to stabilize the students APIs.
I know a lot of parents API requests are "almost" identical to students API requests but I have to look into them and I haven't yet.

Hope this helps, I guess I'll close this issue as completed because I fixed the issue you mentioned in the title but if you still want to track parents support, please open a new issue and I'll post updates in there.