Skip to content

Commit

Permalink
Merge pull request #1 from CyberAndrii/dev
Browse files Browse the repository at this point in the history
Fix time offset, try to login with generated code in test
  • Loading branch information
CyberAndrii authored Aug 27, 2020
2 parents d6ab45b + 87e8dea commit 93b8908
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 10 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test

on:
push:
branches: [ master ]
branches: [ master, dev ]
paths-ignore:
- '**.md'
pull_request:
Expand All @@ -20,6 +20,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: CyberAndrii/setup-steamcmd@v1
# Login only on 1 OS because same code can't be used 2 times.
if: matrix.os == 'ubuntu-latest'

- name: Generate auth code
id: generate
uses: ./
Expand All @@ -31,3 +35,9 @@ jobs:
code=${{ steps.generate.outputs.code }}
[ ${#code} -ge 5 ] || exit 1
shell: bash

- name: Login
run: steamcmd +login ${{ secrets.STEAM_USERNAME }} ${{ secrets.STEAM_PASSWORD }} ${{ steps.generate.outputs.code }} +quit
shell: bash
# Login only on 1 OS because same code can't be used 2 times.
if: matrix.os == 'ubuntu-latest'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/
steamcmd/
secrets
16 changes: 12 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions scripts/run_act.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ act \
--platform ubuntu-latest=nektos/act-environments-ubuntu:18.04 \
--platform ubuntu-18.04=nektos/act-environments-ubuntu:18.04 \
"$@"

# Created when using act with --bind arg.
rm steamcmd/ --recursive --force
16 changes: 12 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@ function run()
try
{
const sharedSecret = core.getInput('shared_secret', { required: true });
const timeOffset = core.getInput('time_offset');
const timeOffset = parseInt(core.getInput('time_offset'));

if(sharedSecret.length !== 28 || !sharedSecret.endsWith('='))
{
throw Error('Invalid shared secret.')
throw Error('Invalid shared secret.');
}

const code = totp.generateAuthCode(sharedSecret, timeOffset);
core.setOutput('code', code);
totp.getTimeOffset((error, offset, latency) =>
{
if(error)
{
throw error;
}

const code = totp.generateAuthCode(sharedSecret, offset + timeOffset);
core.setOutput('code', code);
});
}
catch (error)
{
Expand Down

0 comments on commit 93b8908

Please sign in to comment.