Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to login #2

Open
johntdyer opened this issue Nov 16, 2023 · 14 comments
Open

Fails to login #2

johntdyer opened this issue Nov 16, 2023 · 14 comments

Comments

@johntdyer
Copy link

johntdyer commented Nov 16, 2023

I am trying to log in and I'm getting the following error when running the UI

╰─ ENABLE_UI=true yarn start                                                                                     ─╯

yarn run v1.22.19
$ node index.js
(node:49527) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
HCTB-API is listening on port 8080 :)
[Info] Browser instance started
[Info] Opened a new page
[Info] Logging in to Here Comes The Bus
[Info] Parsing cookie
/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:271
        throw new Error('Evaluation failed: ' + (0, util_js_1.getExceptionMessage)(exceptionDetails));
              ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'value')
    at pptr://__puppeteer_evaluation_script__:2:72
    at ExecutionContext._ExecutionContext_evaluate (/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:271:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:118:16)
    at async JSHandle.evaluate (/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/JSHandle.js:91:16)
    at async ElementHandle.$$eval (/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ElementHandle.js:192:24)
    at async /Users/jdyer/Project/hctb-api/index.js:99:19

Node.js v21.2.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@johntdyer johntdyer changed the title Fais to Fais to login Nov 16, 2023
@johntdyer
Copy link
Author

Also I tried using POST and got the same error

╭─    ~/Projects/hctb-api    main !1 ?1    INT ✘  ▼  Project   03:00:41 PM  ─╮
╰─ curl -X POST -d '{}' 'http://127.0.0.1:8080/api/login?user=xxxxxxxx%40gmail.com&pass=xxxxxxxxxx%23&code=12345'
curl: (52) Empty reply from server
╭─    ~/Projects/hctb-api    main !1 ?1 
╰─
$ node index.js
(node:50031) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
HCTB-API is listening on port 8080 :)
[Info] Browser instance started
[Info] Opened a new page
[Info] Logging in to Here Comes The Bus
[Info] Parsing cookie
/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:271
        throw new Error('Evaluation failed: ' + (0, util_js_1.getExceptionMessage)(exceptionDetails));
              ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'value')
    at pptr://__puppeteer_evaluation_script__:2:72
    at ExecutionContext._ExecutionContext_evaluate (/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:271:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:118:16)
    at async JSHandle.evaluate (/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/JSHandle.js:91:16)
    at async ElementHandle.$$eval (/Users/jdyer/Project/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ElementHandle.js:192:24)
    at async /Users/jdyer/Project/hctb-api/index.js:99:19

Node.js v21.2.0
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
╭─    ~/Projects/hctb-api    main !1 ?1 

Thanks again, Super love the idea of this !!!!

@djuntgen
Copy link

Running into the same problem

HCTB-API is listening on port 8080 :)
[Info] Browser instance started
[Info] Opened a new page
[Info] Logging in to Here Comes The Bus
[Info] Parsing cookie
/opt/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:271
        throw new Error('Evaluation failed: ' + (0, util_js_1.getExceptionMessage)(exceptionDetails));
              ^

Error: Evaluation failed: TypeError: Cannot read properties of undefined (reading 'value')
    at pptr://__puppeteer_evaluation_script__:2:72
    at ExecutionContext._ExecutionContext_evaluate (/opt/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:271:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ExecutionContext.evaluate (/opt/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:118:16)
    at async JSHandle.evaluate (/opt/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/JSHandle.js:91:16)
    at async ElementHandle.$$eval (/opt/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/ElementHandle.js:192:24)
    at async /opt/hctb-api/index.js:99:19

Node.js v18.13.0
root@debian:/opt/hctb-api#

@dispherical dispherical changed the title Fais to login Fails to login Nov 20, 2023
@dispherical
Copy link
Owner

That’s quite odd, I was working on adding Home Assistant integration and it was working just fine.

I’m currently away from my laptop until tomorrow night so I can’t diagnose the problem further at the moment so I apologise. From what it seems, some accounts may not have the ability to get the information described on line 99.

I only have access to a phone right now so I can’t do much. Deploying from the quickfix-20nov branch will help, but will make /api/session inoperable as it will no longer get the data required.

https://github.com/aboutdavid/hctb-api/tree/quickfix-20nov

@djuntgen
Copy link

Gave it a try, different / new error. I think its great that you are thinking about HA integration!

HCTB-API is listening on port 8080 :)
[Info] Browser instance started
[Info] Opened a new page
[Info] Logging in to Here Comes The Bus
[Info] Parsing cookie
/opt/hctb-api/index.js:133
      legacyID: value.person,
                ^

ReferenceError: value is not defined
    at /opt/hctb-api/index.js:133:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Node.js v18.13.0
root@debian:/opt/hctb-api#

@dispherical
Copy link
Owner

dispherical commented Nov 21, 2023

That’s super odd. Could you try starting it with a head and see if it successfully logs into the dashboard?

https://github.com/aboutdavid/hctb-api/blob/b229ae47b578b7d9f034dc840ce4e3157a3df267/index.js#L60
Try and see if you can give it a head here by setting headless to false

If you can’t, that’s fine, I just think there could either be different account types or it could just fail to notice that you’re not logged in or something else

@dispherical
Copy link
Owner

I've managed to somehow spin up a service and used mine and a couple of friend's logins and I can't reproduce this issue. I think the theory of different account types could be true. By the way, are there multiple people associated with your account? As in multiple students connected to one account?

@johntdyer
Copy link
Author

johntdyer commented Nov 21, 2023 via email

@dispherical
Copy link
Owner

Ah, I think I know the issue. Also, I don't think it would be wise to send credentials to anybody, even if they are changed, as malicious people roam everywhere on the internet. I made this with one person only in my account, so I wasn't able to test all of the edge cases. I'll attempt to fix this later this week once I have stable internet.

@djuntgen
Copy link

djuntgen commented Nov 21, 2023

I have 2 different bus routes as well. Added headless: false to puppeterr.

root@debian:/opt/hctb-api# vi index.js 
root@debian:/opt/hctb-api# ENABLE_UI=true npm start

> hctbb-api@2.0.0 start
> node index.js

HCTB-API is listening on port 8080 :)
/opt/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/util.js:317
    const timeoutError = new Errors_js_1.TimeoutError(`waiting for ${taskName} failed: timeout ${timeout}ms exceeded`);
                         ^

TimeoutError: waiting for target failed: timeout 30000ms exceeded
    at waitWithTimeout (/opt/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/util.js:317:26)
    at Browser.waitForTarget (/opt/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/common/Browser.js:405:56)
    at ChromeLauncher.launch (/opt/hctb-api/node_modules/puppeteer/lib/cjs/puppeteer/node/ChromeLauncher.js:100:31)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /opt/hctb-api/index.js:60:19

Node.js v18.13.0
root@debian:/opt/hctb-api# 

UPDATE

  • I ran {headless: false} on my Macbook vs. Proxmox LXC to launch Chromium. Good news is that the login does work, and defaults it to the first bus route. Bad news that it times out. I think the issue here is with multiple bus routes under one account. The "API" will need a way to identify which bus route.
Screenshot 2023-11-20 at 10 17 18 PM

I think you'll need to add a passenger field/value somewhere in login credientails.
Screenshot 2023-11-20 at 10 22 55 PM

@dispherical
Copy link
Owner

Hi, I recently got around to trying to make this work. I'll push out an update when I am finished with my finals.

@jrittenh
Copy link

jrittenh commented Jan 31, 2024

Just a ping from 2024 as someone else hitting this error with two bus routes.

@dispherical
Copy link
Owner

dispherical commented Mar 20, 2024

I think I might have a solution. I will try and add a new method (/api/passengers), which should return with a list of names and UUIDs. It will also return a "cookie" so you can skip straight to /api/session.

@dispherical
Copy link
Owner

{
    "success": true,
    "cookie": ".ASPXFORMSAUTH=... ",
    "passengers": [
        {
            "text": "David",
            "value": "..."
        }
    ]
}

I'm unsure if every passenger has a different time UUID, however. I could attempt to omit that and just use the names of the times instead of the UUID.

@dispherical
Copy link
Owner

I think a temporary solution would be commenting out this section:

const value = await page.$$eval('option[selected="selected"]', (el) => {
  return { name: el[1].innerHTML, person: el[1].value, time: el[2].value };
});

Although, that makes /api/session pretty much useless. For now, I'll push an API change which allows for the disabling of this via the query selectors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants