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

TypeError in getOffer #134

Closed
rickyelopez opened this issue Oct 14, 2021 · 22 comments · Fixed by #136
Closed

TypeError in getOffer #134

rickyelopez opened this issue Oct 14, 2021 · 22 comments · Fixed by #136
Labels
bug Something isn't working

Comments

@rickyelopez
Copy link

rickyelopez commented Oct 14, 2021

Actual Behavior

> node claimer.js

 2021-10-14 | 15:24:25.045 | ERROR | TypeError: Cannot read properties of null (reading 'split')
    at getOffer (/app/src/gamePromotions.js:14:54)
    at /app/src/gamePromotions.js:17:27
    at Array.map (<anonymous>)
    at freeGamesPromotions (/app/src/gamePromotions.js:16:45)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /app/claimer.js:72:30

Steps to Reproduce the Problem

  1. pull latest image from docker
  2. docker-compose run epic_free

Specifications

Running using docker-compose instructions, pulled latest image

Notes

This was working previously, stopped working today.

@stickerx
Copy link

how to fix this problem?

@rickyelopez
Copy link
Author

On a whim, I tried to generate a new device_auths.json, but it's producing this error:
image
Maybe something has changed on the Epic side?

@jackblk
Copy link
Contributor

jackblk commented Oct 14, 2021

On a whim, I tried to generate a new device_auths.json, but it's producing this error: image Maybe something has changed on the Epic side?

Maybe you're running on DeviceAuth 1.1.0? There's a fix on a fork for 1.1.1 xMistt/DeviceAuthGenerator#3 (comment)

@rickyelopez
Copy link
Author

Maybe you're running on DeviceAuth 1.1.0?

Ah, yeah didn't notice the fork. Let me give that a shot.

@stickerx
Copy link

I think the problem not from DeviceAuth problem from the epic store

@rickyelopez
Copy link
Author

Yup, the 1.1.1 release was able to generate a device_auths.json, but I'm still seeing the same error with the new credentials.

@jackblk
Copy link
Contributor

jackblk commented Oct 14, 2021

This bug is not related to device auth, just wait for a fix.

@jackblk
Copy link
Contributor

jackblk commented Oct 14, 2021

2 problems:

  • EGS now updates slug with new format, no more trailing /home
  • After I fix new slug, seems like paladins--paladins-epic-pack (this week's freebie) is kinda special. The client cannot parse the offer. Need to investigate more.

Calling API to receive info as bundle or product will both fail:

It's an addon but I cannot find the correct API for it.

@Revadike
Copy link
Owner

I think those endpoints can be replaced with https://www.epicgames.com/graphql?operationName=getMappingByPageSlug&variables=%7B%22pageSlug%22:%22paladins--paladins-epic-pack%22%7D&extensions=%7B%22persistedQuery%22:%7B%22version%22:1,%22sha256Hash%22:%225a08e9869c983776596498e0c4052c55f9e54c79e18a303cd5eb9a46be55c7d7%22%7D%7D

But here the problem is calculating the hash, which I am currently looking into.

@jackblk
Copy link
Contributor

jackblk commented Oct 14, 2021

@Revadike
Copy link
Owner

Yeah, I was thinking that too. I found it by just sniffing http traffic.

@jackblk
Copy link
Contributor

jackblk commented Oct 14, 2021

Hmm I'm also sniffing the traffic, from the addon page, but I didn't find that one. What action do you do (or visit which page) to get that one?

@Revadike
Copy link
Owner

Hmm I'm also sniffing the traffic, from the addon page, but I didn't find that one. What action do you do (or visit which page) to get that one?

When visiting https://www.epicgames.com/store/en-US/p/paladins--paladins-epic-pack

@Revadike
Copy link
Owner

Ok, so seems even epic uses different endpoints for different category types. For example, the other freebie will not return an offer:
https://www.epicgames.com/graphql?operationName=getMappingByPageSlug&variables=%7B%22pageSlug%22:%22stubbs-the-zombie-in-rebel-without-a-pulse%22%7D&extensions=%7B%22persistedQuery%22:%7B%22version%22:1,%22sha256Hash%22:%225a08e9869c983776596498e0c4052c55f9e54c79e18a303cd5eb9a46be55c7d7%22%7D%7D

When visiting the freebie page, epicgames will use the product slug endpoint.
Hence, I think the best way to handle this, add this endpoint as option in gamePromotions.js > getOffer().

@jackblk
Copy link
Contributor

jackblk commented Oct 14, 2021

Yeah, we can handle it by checking "offerType": "ADD_ON" too. If it is an addon then we do specific function for getOffer(), otherwise we just use the client getBundleForSlug and getProductForSlug like normal.

@Revadike
Copy link
Owner

Anyone want to test/review my PR?
Here is the changed file directly:
https://github.com/Revadike/epicgames-freebies-claimer/blob/766ae427192417d4105930d098a006fc795ac031/src/gamePromotions.js

@Revadike
Copy link
Owner

^

SyntaxError: Unexpected token '<' at wrapSafe (internal/modules/cjs/loader.js:1053:16) at Module._compile (internal/modules/cjs/loader.js:1101:27) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) at Module.load (internal/modules/cjs/loader.js:985:32) at Function.Module._load (internal/modules/cjs/loader.js:878:14) at Module.require (internal/modules/cjs/loader.js:1025:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (C:\Users\meow\Desktop\epicgames-freebies-claimer-master1\claimer.js:4:33) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)

It complains about a character <, but this character does not exist in claimer.js. You sure this problem is not yours only?

@stickerx
Copy link

worked after downloading V1.5.5
big thanks

@rickyelopez
Copy link
Author

When will the docker image be updated? Does it happen automatically?

@Revadike
Copy link
Owner

When will the docker image be updated? Does it happen automatically?

@jackblk is in charge of the docker image.

@jackblk
Copy link
Contributor

jackblk commented Oct 15, 2021

Docker image is updated. Sorry for the delay, it was 2AM at my timezone when v1.5.5 was released lol.

@rickyelopez
Copy link
Author

No worries! Thank you for updating it, it works perfectly now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants