Revadike / epicgames-freebies-claimer

Claim available free game promotions from the Epic Games Store.
MIT License
2.23k stars 361 forks source link

TypeError in getOffer #134

Closed rickyelopez closed 2 years ago

rickyelopez commented 2 years ago

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 commented 2 years ago

how to fix this problem?

rickyelopez commented 2 years ago

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 commented 2 years ago

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 https://github.com/xMistt/DeviceAuthGenerator/issues/3#issuecomment-924350309

rickyelopez commented 2 years ago

Maybe you're running on DeviceAuth 1.1.0?

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

stickerx commented 2 years ago

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

rickyelopez commented 2 years ago

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 commented 2 years ago

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

jackblk commented 2 years ago

2 problems:

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 commented 2 years ago

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 commented 2 years ago

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.

Nice find. I don't think we need to calculate the hash, try another addon:

https://www.epicgames.com/graphql?operationName=getMappingByPageSlug&variables={"pageSlug":"horizon-chase-turbo--horizon-chase-turbo-rookie-series"}&extensions={"persistedQuery":{"version":1,"sha256Hash":"5a08e9869c983776596498e0c4052c55f9e54c79e18a303cd5eb9a46be55c7d7"}}

This is for https://www.epicgames.com/store/en-US/p/horizon-chase-turbo--horizon-chase-turbo-rookie-series

I think the hash is for the query itself, so we can reuse the hash. Btw how did you find this query lol.

Revadike commented 2 years ago

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

jackblk commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

^

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 commented 2 years ago

worked after downloading V1.5.5 big thanks

rickyelopez commented 2 years ago

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

Revadike commented 2 years ago

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

@jackblk is in charge of the docker image.

jackblk commented 2 years ago

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

rickyelopez commented 2 years ago

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