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

v4 release #149

Merged
merged 80 commits into from
Oct 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
e460ed9
Add 'MAKE PRIMARY' note for 2FA setup
beatcracker Nov 4, 2020
fe6f164
Add "Local configuration"
beatcracker Nov 4, 2020
e351525
Support dev images and ghcr
claabs May 29, 2021
2c67c8e
Reformat notificatiers code, add telegram library and support
mikhail5555 Apr 13, 2021
05ef1e6
Rework config, make it easier to add new types and validate them acco…
mikhail5555 Apr 15, 2021
d10ddce
Rename folder to notifiers
mikhail5555 Apr 15, 2021
e6697a5
Change node version to 15, update config layout, add discord webhook …
mikhail5555 Apr 17, 2021
19537c7
Add notification reason, change messages slightly
mikhail5555 Apr 17, 2021
6ed0543
Add env variable for discord
mikhail5555 Apr 17, 2021
8cc4a98
Remove telegram library
mikhail5555 May 9, 2021
015da2c
change markdown of telegram message, rebase on newest version
mikhail5555 Jun 12, 2021
e68c582
Add placeholder for account specific notifiers
mikhail5555 Jun 12, 2021
887e589
Check if alpine chromium multiarch builds work
claabs Aug 20, 2021
b9e3eb2
Remove ARMv7
claabs Aug 20, 2021
81ab913
Remove ARMv6
claabs Aug 20, 2021
2222fda
Fix image digest workflow
claabs Aug 20, 2021
5aaa474
Stashing some stuff
claabs Aug 20, 2021
c73b2b8
Add hcaptcha accessibility token getter + cache
claabs Aug 20, 2021
7d4dba8
Initial progress on login puppeteer
claabs Aug 20, 2021
9c1f0f2
Completed untested login impl
claabs Aug 21, 2021
4397c7e
Update @type/node to 14
claabs Aug 21, 2021
3c553ab
Add PUPPETEER_SKIP_CHROMIUM_DOWNLOAD on build step
claabs Aug 21, 2021
25509a1
Begin testing hcaptcha/login
claabs Aug 22, 2021
8d9ea22
Some login progress, stuck on Epic error message
claabs Aug 28, 2021
f6c146e
More random progress. I think my IP might be banned?
claabs Aug 28, 2021
e17e3e7
Add some more humanity
claabs Aug 29, 2021
1d5a399
Finally figured out Talon evasion
claabs Aug 30, 2021
d951dde
Debug logs and gitignore files
claabs Sep 3, 2021
39f1fcd
Remove site. Update portal-plugin
claabs Sep 5, 2021
95192b4
accessibility token refactor
claabs Sep 5, 2021
51ea4d8
Fix Docker build
claabs Sep 5, 2021
31dc812
Initial progress on happy-path purchase flow
claabs Sep 14, 2021
b7d07a2
Add more efficient puppeteer purchase
claabs Sep 17, 2021
a479ac7
Add automated account creation function for enhanced testing
claabs Sep 19, 2021
e706a63
Added basic unit test
claabs Sep 19, 2021
271f3e1
Make puppeteer purchase configurable
claabs Sep 21, 2021
fcc791c
Add account deletion to tests
claabs Sep 21, 2021
2bee555
Clean up trace logging
claabs Sep 21, 2021
9e5550c
Close browser after account delete
claabs Sep 21, 2021
368c1b1
Improve login captcha detection
claabs Sep 21, 2021
0a62e9b
Remove unused deps, npm audit
claabs Sep 21, 2021
e3a9800
Remove captcha file
claabs Sep 21, 2021
8294357
Update linting/typescript stack
claabs Sep 22, 2021
66041fb
Update puppeteer/extra to latest. Add beginnings of new config library.
claabs Sep 23, 2021
2d14c86
Config2 improvements
claabs Sep 24, 2021
9581967
Remove convict config. Switch to class-validator
claabs Sep 25, 2021
32773ad
Switch to new config object
claabs Sep 26, 2021
d450ced
Improved logging, validation. Create default config when not present.…
claabs Sep 26, 2021
61f4aca
Populate email and web server environment variables. Add @env tags.
claabs Sep 26, 2021
f615555
Add typedoc for config properties documentation
claabs Sep 26, 2021
b2ecb79
Improve deprecated config doc links
claabs Sep 26, 2021
cb2c1e5
Fix spelling error
claabs Sep 27, 2021
bb14fbc
Switch away from deprecated config option
claabs Sep 27, 2021
c3f92dc
Update free game detection to latest web APIs. Resolves #129
claabs Sep 27, 2021
cb8fd0c
Merge remote-tracking branch 'telegram/Add-telegram-support' into dev…
claabs Sep 29, 2021
3b84608
Re-add login notification
claabs Sep 29, 2021
6e4e752
Update entrypoint to just use Node rather than bash. Make config dire…
claabs Sep 29, 2021
1120d42
Add error logging for entrypoint config
claabs Sep 29, 2021
0ceff81
Write temp config file rather than using stdout
claabs Sep 29, 2021
9947169
npm audit
claabs Sep 29, 2021
72490f1
Fix TOTP validation
claabs Sep 29, 2021
da97cbe
Set timezone before first run
claabs Sep 29, 2021
8d32b05
Set TZ default in TS config
claabs Sep 30, 2021
7128c6a
Set docker build target in CI
claabs Sep 30, 2021
29620a3
Remove docker manifest output
claabs Sep 30, 2021
1338479
Add version check, docker image optimizations
claabs Sep 30, 2021
522235e
Fix branch name variable
claabs Sep 30, 2021
6c170aa
Merge remote-tracking branch 'readme/readme-update' into develop
claabs Oct 1, 2021
cd0ef21
Slight changes to instructions from #42
claabs Oct 1, 2021
06599af
Documentaion improvements
claabs Oct 1, 2021
9fa5eef
Small readme typo fixes
claabs Oct 1, 2021
0a06a8a
Various chores
claabs Oct 1, 2021
4f53a25
Reorder dockerfile to hopefully optimize layer downloads
claabs Oct 1, 2021
face8e0
Update issue templates
claabs Oct 1, 2021
1d5be77
Document migration steps for deprecated options
claabs Oct 1, 2021
1f965d6
Add path-based reverse proxy support. Resolves #75
claabs Oct 1, 2021
8e29935
Resolve TODOs, add notification timeout option
claabs Oct 1, 2021
c007402
Minor notification formatting changes
claabs Oct 1, 2021
7b3cddb
Merge remote-tracking branch 'origin/master' into develop
claabs Oct 2, 2021
619316f
Add environment variables for Discord and Telegram
claabs Oct 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
!src
!package*.json
!tsconfig.json
!entrypoint.sh

src/site/public/node_modules
!entrypoint.sh
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ module.exports = {
extends: [
'airbnb-base',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended',
'plugin:jest/recommended',
],
Expand All @@ -17,7 +16,10 @@ module.exports = {
},
plugins: ['@typescript-eslint', 'jest'],
rules: {
'import/extensions': 0
'import/extensions': 0,
'import/prefer-default-export': 0,
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
},
settings: {
'import/extensions': ['.js', '.ts',],
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug-report-captcha-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ assignees: ''
<!-- Before filing a bug, make sure you're using the latest Docker image, or check the commit history to see if your issue has already been fixed -->

**Describe the bug**
A clear and concise description of what the bug is.
<!-- A clear and concise description of what the bug is. -->

**Screenshots or Logs**
Add screenshots or logs from the container and your browser's dev tools to help explain your problem. Be sure to remove any usernames, passwords, or URLs that you wouldn't like to share.
<!-- Add screenshots or logs from the container and your browser's dev tools to help explain your problem. Be sure to remove any usernames, passwords, or URLs that you wouldn't like to share. -->

**Configuration (please complete the following information):**
- Browser:
- Hosting solution [e.g. reverse proxy, HTTPS/HTTP, caching, localhost]:

**Additional context**
Add any other context about the problem here.
<!-- Add any other context about the problem here. -->
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/bug-report-item-redeem.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
name: Bug report (item redeem)
about: An issue related to redeeming a game, or finding available free games
name: Bug report (other)
about: An issue related to redeeming games, finding free games, logging in, notifications, or config validation
title: ''
labels: bug
assignees: ''
Expand All @@ -10,10 +10,10 @@ assignees: ''
<!-- Before filing a bug, make sure you're using the latest Docker image, or check the commit history to see if your issue has already been fixed -->

**Describe the bug**
A clear and concise description of what the bug is.
<!-- A clear and concise description of what the bug is. -->

**Screenshots or Logs**
Add screenshots or logs to help explain your problem. Be sure to remove any usernames, passwords, or URLs that you wouldn't like to share.
<!-- Add screenshots or logs to help explain your problem. Be sure to remove any usernames, passwords, or URLs that you wouldn't like to share. -->

**Additional context**
Add any other context about the problem here.
<!-- Add any other context about the problem here. -->
4 changes: 2 additions & 2 deletions .github/workflows/build-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ jobs:
- name: Setup Node.js for use with actions
uses: actions/setup-node@v2
with:
node-version: '12'
node-version: '14'

- name: NPM install
run: npm i
run: npm ci

# Runs a single command using the runners shell
- name: Build and lint
Expand Down
41 changes: 34 additions & 7 deletions .github/workflows/build_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- master
workflow_dispatch:
- develop

jobs:
build_multi_arch_image:
Expand All @@ -14,6 +14,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- name: Set environment variables
run: echo "GIT_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

Expand All @@ -29,15 +32,39 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push master
if: ${{ github.ref == 'refs/heads/master' }}
uses: docker/build-push-action@v2
with:
target: deploy
push: true
tags: |
charlocharlie/epicgames-freegames:${{ github.sha }}
charlocharlie/epicgames-freegames:latest
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6
charlocharlie/epicgames-freegames:${{ github.sha }}
ghcr.io/claabs/epicgames-freegames-node:latest
ghcr.io/claabs/epicgames-freegames-node:${{ github.sha }}
platforms: linux/amd64,linux/arm64
build-args: |
COMMIT_SHA=${{ github.sha }}
BRANCH=${{ env.GIT_BRANCH }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Build and push dev
if: ${{ github.ref == 'refs/heads/develop' }}
uses: docker/build-push-action@v2
with:
target: deploy
push: true
tags: |
charlocharlie/epicgames-freegames:dev
ghcr.io/claabs/epicgames-freegames-node:dev
platforms: linux/amd64,linux/arm64
build-args: |
COMMIT_SHA=${{ github.sha }}
BRANCH=${{ env.GIT_BRANCH }}
27 changes: 27 additions & 0 deletions .github/workflows/typedoc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish Typedoc to Github Pages
on:
push:
branches:
- master
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Node.js for use with actions
uses: actions/setup-node@v2
with:
node-version: '14'

- name: NPM install
run: npm ci

# Runs a single command using the runners shell
- name: Build and lint
run: npm run docs

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
hars
docs

# Logs
logs
Expand Down Expand Up @@ -108,4 +109,10 @@ dist
# Stores VSCode versions used for testing VSCode extensions
.vscode-test

config/*
config/*
test-cookies.json
test.html
test.png
test2.html

.idea
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
14
1 change: 0 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
printWidth: 100,
singleQuote: true,
trailingComma: 'es5'
}
10 changes: 5 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"[typescript]": {
"editor.formatOnSave": false,
},
"eslint.enable": true,
"typescript.tsdk": "node_modules\\typescript\\lib",
"docker.defaultRegistryPath": "charlocharlie",
"[json]": {
"files.insertFinalNewline": true
},
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.workingDirectories": [
".",
"./src/site/public"
"."
]
}
50 changes: 40 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
########
# BASE
########
FROM node:12-alpine as base
FROM node:14-alpine as base

ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1

WORKDIR /usr/app

Expand All @@ -12,10 +14,9 @@ FROM base as build

# Copy all source files
COPY package*.json tsconfig.json ./
COPY src/site/public/package*.json src/site/public/tsconfig.json ./src/site/public/

# Add dev deps
RUN npm ci && cd src/site/public && npm ci
RUN npm ci

# Copy source code
COPY src src
Expand All @@ -27,19 +28,29 @@ RUN npm run build
########
FROM base as deploy

VOLUME [ "/usr/app/config" ]

RUN apk add --no-cache \
# Chromium dependencies https://github.com/Zenika/alpine-chrome/blob/master/Dockerfile
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& echo "http://dl-cdn.alpinelinux.org/alpine/v3.12/main" >> /etc/apk/repositories \
&& apk add --no-cache \
libstdc++ \
chromium \
harfbuzz \
nss \
freetype \
ttf-freefont \
font-noto-emoji \
wqy-zenhei \
# App dependencies
jq \
tzdata
tzdata

ENV NODE_ENV production

# Copy package.json for version number
COPY package*.json ./
COPY src/site/public/package*.json src/site/public/tsconfig.json ./src/site/public/

RUN npm ci --only=production && cd src/site/public && npm ci --only=production
RUN npm ci --only=production

# Steal compiled code from build image
COPY --from=build /usr/app/dist ./dist
Expand All @@ -48,6 +59,25 @@ COPY entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# backwards compat (from https://success.docker.com/article/use-a-script-to-initialize-stateful-container-data)
RUN ln -s /usr/local/bin/docker-entrypoint.sh /

ARG COMMIT_SHA="" \
BRANCH=""

LABEL org.opencontainers.image.title="epicgames-freegames-node" \
org.opencontainers.image.url="https://github.com/claabs/epicgames-freegames-node" \
org.opencontainers.image.description="Automatically redeem free games promotions on the Epic Games store" \
org.opencontainers.image.name="epicgames-freegames-node" \
org.opencontainers.image.revision=${COMMIT_SHA} \
org.opencontainers.image.ref.name=${BRANCH} \
org.opencontainers.image.base.name="node:14-alpine" \
org.opencontainers.image.version="latest"

ENV NODE_ENV=production \
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium-browser \
COMMIT_SHA=${COMMIT_SHA} \
BRANCH=${BRANCH}

EXPOSE 3000

VOLUME [ "/usr/app/config" ]

ENTRYPOINT ["docker-entrypoint.sh"]
28 changes: 0 additions & 28 deletions Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,3 @@ A general overview of the purchase process. See the code for specifics.
1. Call order preview with the namespaceId and offerId in the body, and the purchase token in a header
1. Remember the order preview response
1. Call confirm order with essentially the contents of order preview, and the purchase token in a header

## Testing

Assuming there will always be at least one free game offer available, test account creation can be done with the following strategy:

### New Strategy

Epic does not filter out the plus-sign suffix that many email mailboxes use to reuse emails. Because of this, we can just create accounts using the same permanent email address.

### Old Strategy

1. Have a **permanent email** on a trusted domain (e.g. gmail.com) that is used to create the account.
- Epic blocks registering accounts with temp email domains. However they don't block temp email domains on the "change email" process.
1. Create the account with a random first name, last name, username, and password.
- Random 16 character alphanumeric username should work
1. Use email APIs to verify the account.
- This may not be required for what we're testing.
1. Perform the tests using this account's credentials.

Whether the tests fail or complete, we need to tear down the account:

1. Using a temp mail service's API ([like this](https://rapidapi.com/Privatix/api/temp-mail)), create a **temp email**.
2. Begin Epic's email address change process to switch from the **permanent email** to the **temp email**.
3. Confirm the email change using the security code sent to the **permanent email**.
4. *(Optional):* Delete the account.
- Not sure if deleting the account increases or reduces the attention we will recieve.

This process lets us create a fresh account for testing, repeatedly, using the same permanent email.
Loading