From 81615744fb00ad153dfd63a9aedd0d9758abc734 Mon Sep 17 00:00:00 2001 From: Seya <31957516+sglkc@users.noreply.github.com> Date: Tue, 3 Feb 2026 21:43:24 +0700 Subject: [PATCH 1/8] fixed login by adding request sign header --- index.js | 78 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 2001e5e..d736251 100755 --- a/index.js +++ b/index.js @@ -5,7 +5,10 @@ * Simple script for automated daily attendance via SKPort API */ -const creds = process.env.CRED.split('\n').map(s => s.trim()).filter(Boolean) +import crypto from 'crypto' + +const creds = (process.env.CRED || "").split('\n').map(s => s.trim()).filter(Boolean) +const tokens = (process.env.TOKEN || "").split('\n').map(s => s.trim()).filter(Boolean) const discordWebhook = process.env.DISCORD_WEBHOOK const discordUser = process.env.DISCORD_USER @@ -17,9 +20,21 @@ const messages = [] let hasErrors = false /** - * Build headers for SKPort API + * Resolve token for account index. If tokens list has one entry, use it for all accounts. */ -function buildHeaders(cred, gameRole = null) { +function resolveTokenForIndex(index) { + if (!tokens || tokens.length === 0) return undefined + if (tokens.length === 1) return tokens[0] + return tokens[index] || undefined +} + +/** + * Build headers for SKPort API + * Accepts optional timestamp so the same timestamp can be used in the sign computation. + */ +function buildHeaders(cred, gameRole = null, timestamp = null) { + const ts = timestamp || Math.floor(Date.now() / 1000).toString() + const headers = { 'accept': 'application/json, text/plain, */*', 'content-type': 'application/json', @@ -28,7 +43,7 @@ function buildHeaders(cred, gameRole = null) { 'cred': cred, 'platform': '3', 'sk-language': 'en', - 'timestamp': Math.floor(Date.now() / 1000).toString(), + 'timestamp': ts, 'vname': '1.0.0', 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36', } @@ -41,11 +56,32 @@ function buildHeaders(cred, gameRole = null) { } /** - * Fetch player binding to get all roles - * Returns array of roles with gameRole formatted + * Compute V2-style sign header: MD5(HMAC-SHA256(path + timestamp + headers_json, token)) + * token = secret salt (from TOKENS env) */ -async function getPlayerRoles(cred) { - const headers = buildHeaders(cred) +function signHeader(path, timestamp, platform, vName, token) { + if (!token) return null + const headerJson = JSON.stringify({ platform, timestamp, dId: "", vName }) + const s = `${path}${timestamp}${headerJson}` + const hmac = crypto.createHmac("sha256", token).update(s).digest("hex") + return crypto.createHash("md5").update(hmac).digest("hex") +} + +/** + * Fetch player binding to get all roles + * Accepts token used to sign the binding request (if available) + */ +async function getPlayerRoles(cred, token) { + const path = '/api/v1/game/player/binding' + const timestamp = Math.floor(Date.now() / 1000).toString() + const headers = buildHeaders(cred, null, timestamp) + + // Add sign header if token provided + if (token) { + const sign = signHeader(path, timestamp, '3', '1.0.0', token) + if (sign) headers['sign'] = sign + } + const res = await fetch(BINDING_URL, { method: 'GET', headers }) const json = await res.json() @@ -87,6 +123,7 @@ async function getPlayerRoles(cred) { /** * Check if already signed in today + * (headers should already include timestamp and sign if desired) */ async function checkAttendance(headers) { const res = await fetch(ATTENDANCE_URL, { method: 'GET', headers }) @@ -104,6 +141,7 @@ async function checkAttendance(headers) { /** * Claim daily attendance + * (headers should already include timestamp and sign if desired) */ async function claimAttendance(headers) { const res = await fetch(ATTENDANCE_URL, { method: 'POST', headers, body: null }) @@ -130,9 +168,18 @@ async function claimAttendance(headers) { /** * Run check-in for a single role + * token is the secret salt token used for signing (if available) */ -async function checkInRole(cred, role) { - const headers = buildHeaders(cred, role.gameRole) +async function checkInRole(cred, role, token) { + const path = '/web/v1/game/endfield/attendance' + const timestamp = Math.floor(Date.now() / 1000).toString() + const headers = buildHeaders(cred, role.gameRole, timestamp) + + // Add sign header when token provided + if (token) { + const sign = signHeader(path, timestamp, '3', '1.0.0', token) + if (sign) headers['sign'] = sign + } // Check status const status = await checkAttendance(headers) @@ -150,13 +197,13 @@ async function checkInRole(cred, role) { /** * Run check-in for a single account (all roles) */ -async function run(cred, accountIndex) { +async function run(cred, token, accountIndex) { log('debug', `\n----- CHECKING IN FOR ACCOUNT ${accountIndex} -----`) try { - // Step 1: Get all player roles + // Step 1: Get all player roles (include sign if token present) log('debug', 'Fetching player binding...') - const roles = await getPlayerRoles(cred) + const roles = await getPlayerRoles(cred, token) log('info', `Account ${accountIndex}:`, `Found ${roles.length} role(s)`) @@ -165,7 +212,7 @@ async function run(cred, accountIndex) { const roleLabel = `${role.nickname} (Lv.${role.level}) [${role.server}]` try { - const result = await checkInRole(cred, role) + const result = await checkInRole(cred, role, token) if (result.alreadyClaimed) { log('info', ` → ${roleLabel}:`, 'Already checked in today') @@ -243,7 +290,8 @@ if (!creds || !creds.length) { } for (const index in creds) { - await run(creds[index], Number(index) + 1) + const token = resolveTokenForIndex(Number(index)) + await run(creds[index], token, Number(index) + 1) // Delay between accounts if (index < creds.length - 1) { From 56b3c69a8bf39ac66ed4f408943eccad3b06311f Mon Sep 17 00:00:00 2001 From: Seya <31957516+sglkc@users.noreply.github.com> Date: Tue, 3 Feb 2026 21:59:44 +0700 Subject: [PATCH 2/8] update README with new environment variables --- README.md | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a0fb65b..84f0aab 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,10 @@ Repository version: - [Getting your auth token](#getting-your-auth-token) - [Usage](#usage) -- [Multiple Accounts](#multiple-accounts) - [Discord Webhook](#discord-webhook) - [FAQ](#faq) - [Is this safe?](#is-this-safe) - [How to update my (fork) repository version?](#how-to-update-my-fork-repository-version) - - [Error not logged in](#error-not-logged-in) - [I have other issues](#i-have-other-issues) ## Getting your auth token @@ -31,16 +29,16 @@ You have to check in manually first to get your auth token, follow these steps ( 4.
For Chromium users, click on the Application tab. If not found, click on the arrow. - image + image
For Firefox/Gecko-based browsers, click on the Storage tab. - image + image
5.
- Just like the screenshot above, click on Local Storage and look for `SK_OAUTH_CRED_KEY` - image + Just like the screenshot above, click on Local Storage and look for SK_OAUTH_CRED_KEY and SK_TOKEN_CACHE_KEY. Copy both! + image
6.
@@ -48,7 +46,7 @@ You have to check in manually first to get your auth token, follow these steps ( image
-7. That's your auth token, keep it save and do NOT share it with anyone! +7. That's your auth credentials and token, keep it save and do NOT share it with anyone! ## Usage @@ -61,12 +59,20 @@ You have to check in manually first to get your auth token, follow these steps ( 5.
- Insert name with CRED and secret with - your token, then click Add secret. You can input as many accounts, separate it with a new line (Enter). + Insert both SK_OAUTH_CRED_KEY and SK_TOKEN_CACHE_KEY then click Add secret. You can input as many accounts, separate it with a new line (Enter). - image + image + image
+6.
+ + Here is the example for multiple accounts and your environments should now look like this. + + image + image +
+ 7.
For the first day, you have to trigger this manually. From 79ba5040cfbaaacd7cf982979e121ab69896adb7 Mon Sep 17 00:00:00 2001 From: Seya <31957516+sglkc@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:00:07 +0700 Subject: [PATCH 3/8] bump version --- index.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index d736251..97528d4 100755 --- a/index.js +++ b/index.js @@ -7,8 +7,8 @@ import crypto from 'crypto' -const creds = (process.env.CRED || "").split('\n').map(s => s.trim()).filter(Boolean) -const tokens = (process.env.TOKEN || "").split('\n').map(s => s.trim()).filter(Boolean) +const creds = (process.env.SK_OAUTH_CRED_KEY || "").split('\n').map(s => s.trim()).filter(Boolean) +const tokens = (process.env.SK_TOKEN_CACHE_KEY || "").split('\n').map(s => s.trim()).filter(Boolean) const discordWebhook = process.env.DISCORD_WEBHOOK const discordUser = process.env.DISCORD_USER diff --git a/package.json b/package.json index 965d705..8f6caa9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "endfield-auto-daily", - "version": "1.0.0", + "version": "2.0.0", "description": "Easiest, full free, and no BS SKPORT Arknights: Endfield daily check-in using GitHub Actions", "private": true, "main": "index.js", From 742612e335de19cefd59099fd2e2f824d9a6dcbc Mon Sep 17 00:00:00 2001 From: Seya <31957516+sglkc@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:02:03 +0700 Subject: [PATCH 4/8] fix new environments not defined --- .github/workflows/login.yml | 3 ++- index.js | 6 +++++- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/login.yml b/.github/workflows/login.yml index 43af522..59a775a 100644 --- a/.github/workflows/login.yml +++ b/.github/workflows/login.yml @@ -20,7 +20,8 @@ jobs: - name: Check In run: node index.js env: - CRED: ${{ secrets.CRED }} + SK_OAUTH_CRED_KEY: ${{ secrets.SK_OAUTH_CRED_KEY }} + SK_TOKEN_CACHE_KEY: ${{ secrets.SK_TOKEN_CACHE_KEY }} DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} DISCORD_USER: ${{ secrets.DISCORD_USER }} workflow-keepalive: diff --git a/index.js b/index.js index 97528d4..16da39b 100755 --- a/index.js +++ b/index.js @@ -286,7 +286,11 @@ async function discordWebhookSend() { // Main execution if (!creds || !creds.length) { - throw new Error('CRED environment variable not set!') + throw new Error('SK_OAUTH_CRED_KEY environment variable not set!') +} + +if (!tokens || !tokens.length) { + throw new Error('SK_TOKEN_CACHE_KEY environment variable not set!') } for (const index in creds) { diff --git a/package.json b/package.json index 8f6caa9..36c6718 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "endfield-auto-daily", - "version": "2.0.0", + "version": "2.0.1", "description": "Easiest, full free, and no BS SKPORT Arknights: Endfield daily check-in using GitHub Actions", "private": true, "main": "index.js", From 631238fbccf6ddf0020ea1741536112f4aaa89c3 Mon Sep 17 00:00:00 2001 From: Seya <31957516+sglkc@users.noreply.github.com> Date: Tue, 3 Feb 2026 22:03:37 +0700 Subject: [PATCH 5/8] minor README formatting --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 84f0aab..965d639 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ You have to check in manually first to get your auth token, follow these steps ( Insert both SK_OAUTH_CRED_KEY and SK_TOKEN_CACHE_KEY then click Add secret. You can input as many accounts, separate it with a new line (Enter). - image - image + image + image
6.
From 5690e7c4761406df4c52c778302b0bc6e155f79d Mon Sep 17 00:00:00 2001 From: Seya <31957516+sglkc@users.noreply.github.com> Date: Wed, 4 Feb 2026 07:22:57 +0700 Subject: [PATCH 6/8] update login flow, again, to refresh tokens --- index.js | 287 ++++++++++++++++++++++++------------------------------- 1 file changed, 123 insertions(+), 164 deletions(-) diff --git a/index.js b/index.js index 16da39b..6fc4ae5 100755 --- a/index.js +++ b/index.js @@ -7,101 +7,138 @@ import crypto from 'crypto' -const creds = (process.env.SK_OAUTH_CRED_KEY || "").split('\n').map(s => s.trim()).filter(Boolean) -const tokens = (process.env.SK_TOKEN_CACHE_KEY || "").split('\n').map(s => s.trim()).filter(Boolean) +const accountTokens = (process.env.ACCOUNT_TOKEN || "").split('\n').map(s => s.trim()).filter(Boolean) const discordWebhook = process.env.DISCORD_WEBHOOK const discordUser = process.env.DISCORD_USER const BINDING_URL = 'https://zonai.skport.com/api/v1/game/player/binding' const ATTENDANCE_URL = 'https://zonai.skport.com/web/v1/game/endfield/attendance' +const GENERATE_CRED_URL = 'https://zonai.skport.com/web/v1/user/auth/generate_cred_by_code' +const OAUTH_GRANT_URL = 'https://as.gryphline.com/user/oauth2/v2/grant' +const BASIC_INFO_URL = 'https://as.gryphline.com/user/info/v1/basic' const ENDFIELD_GAME_ID = '3' +const APP_CODE = '6eb76d4e13aa36e6' +const VNAME = '1.0.0' +const PLATFORM = '3' const messages = [] let hasErrors = false -/** - * Resolve token for account index. If tokens list has one entry, use it for all accounts. - */ -function resolveTokenForIndex(index) { - if (!tokens || tokens.length === 0) return undefined - if (tokens.length === 1) return tokens[0] - return tokens[index] || undefined +function sleep(ms) { return new Promise(r => setTimeout(r, ms)) } + +function log(type, ...data) { + console[type](...data) + switch (type) { + case 'debug': return + case 'error': hasErrors = true + } + const string = data.map(v => typeof v === 'object' ? JSON.stringify(v, null, 2) : v).join(' ') + messages.push({ type, string }) } /** - * Build headers for SKPort API - * Accepts optional timestamp so the same timestamp can be used in the sign computation. + * Exchange ACCOUNT_TOKEN -> cred + salt via OAuth flow (3 steps) + */ +async function performOAuthFlow(accountToken) { + if (!accountToken) throw new Error('No account token supplied for OAuth flow') + + // Step 1: basic info (validate token) + const infoUrl = `${BASIC_INFO_URL}?token=${encodeURIComponent(accountToken)}` + const infoRes = await fetch(infoUrl, { method: 'GET', headers: { 'Accept': 'application/json' } }) + const infoData = await infoRes.json() + if (infoData.status !== 0) { + throw new Error(`OAuth Step 1 Failed: ${infoData.msg || JSON.stringify(infoData)}`) + } + + // Step 2: grant OAuth code + const grantRes = await fetch(OAUTH_GRANT_URL, { + method: 'POST', + headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, + body: JSON.stringify({ token: accountToken, appCode: APP_CODE, type: 0 }) + }) + const grantData = await grantRes.json() + if (grantData.status !== 0 || !grantData.data?.code) { + throw new Error(`OAuth Step 2 Failed: ${grantData.msg || JSON.stringify(grantData)}`) + } + + // Step 3: exchange code for cred (+ token) + const credRes = await fetch(GENERATE_CRED_URL, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Accept': 'application/json', + 'platform': PLATFORM, + 'Referer': 'https://www.skport.com/', + 'Origin': 'https://www.skport.com' + }, + body: JSON.stringify({ code: grantData.data.code, kind: 1 }) + }) + const credData = await credRes.json() + if (credData.code !== 0 || !credData.data?.cred) { + throw new Error(`OAuth Step 3 Failed: ${credData.message || JSON.stringify(credData)}`) + } + + return { + cred: credData.data.cred, + salt: credData.data.token, + userId: credData.data.userId, + } +} + +/** + * Build headers for SKPort API (uses provided timestamp to match sign) */ function buildHeaders(cred, gameRole = null, timestamp = null) { const ts = timestamp || Math.floor(Date.now() / 1000).toString() - const headers = { 'accept': 'application/json, text/plain, */*', 'content-type': 'application/json', 'origin': 'https://game.skport.com', 'referer': 'https://game.skport.com/', 'cred': cred, - 'platform': '3', + 'platform': PLATFORM, 'sk-language': 'en', 'timestamp': ts, - 'vname': '1.0.0', - 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36', + 'vname': VNAME, + 'User-Agent': 'Skport/0.7.0 (com.gryphline.skport; build:700089; Android 33; ) Okhttp/5.1.0' } - - if (gameRole) { - headers['sk-game-role'] = gameRole - } - + if (gameRole) headers['sk-game-role'] = gameRole return headers } /** - * Compute V2-style sign header: MD5(HMAC-SHA256(path + timestamp + headers_json, token)) - * token = secret salt (from TOKENS env) + * Compute V2 sign: MD5( HMAC-SHA256( path + timestamp + headers_json, salt ) ) */ -function signHeader(path, timestamp, platform, vName, token) { - if (!token) return null - const headerJson = JSON.stringify({ platform, timestamp, dId: "", vName }) +function computeSignV2(path, timestamp, salt) { + if (!salt) return null + const headerJson = JSON.stringify({ platform: PLATFORM, timestamp, dId: "", vName: VNAME }) const s = `${path}${timestamp}${headerJson}` - const hmac = crypto.createHmac("sha256", token).update(s).digest("hex") - return crypto.createHash("md5").update(hmac).digest("hex") + const hmac = crypto.createHmac('sha256', salt).update(s).digest('hex') + return crypto.createHash('md5').update(hmac).digest('hex') } /** - * Fetch player binding to get all roles - * Accepts token used to sign the binding request (if available) + * Get all player roles via binding endpoint (signed with salt) */ -async function getPlayerRoles(cred, token) { +async function getPlayerRoles(cred, salt) { const path = '/api/v1/game/player/binding' const timestamp = Math.floor(Date.now() / 1000).toString() const headers = buildHeaders(cred, null, timestamp) - // Add sign header if token provided - if (token) { - const sign = signHeader(path, timestamp, '3', '1.0.0', token) - if (sign) headers['sign'] = sign - } + const sign = computeSignV2(path, timestamp, salt) + if (!sign) throw new Error('Missing salt for V2 signing (binding required)') + headers['sign'] = sign const res = await fetch(BINDING_URL, { method: 'GET', headers }) const json = await res.json() + if (json.code !== 0) throw new Error(json.message || `Binding API error: ${json.code}`) - if (json.code !== 0) { - throw new Error(json.message || `Binding API error: ${json.code}`) - } - - // Find endfield binding const endfieldApp = json.data?.list?.find(app => app.appCode === 'endfield') + if (!endfieldApp || !endfieldApp.bindingList?.length) throw new Error('No Endfield account binding found') - if (!endfieldApp || !endfieldApp.bindingList?.length) { - throw new Error('No Endfield account binding found') - } - - // Collect all roles from all bindings const allRoles = [] - for (const binding of endfieldApp.bindingList) { const roles = binding.roles || [] - for (const role of roles) { allRoles.push({ gameRole: `${ENDFIELD_GAME_ID}_${role.roleId}_${role.serverId}`, @@ -113,201 +150,123 @@ async function getPlayerRoles(cred, token) { }) } } - - if (!allRoles.length) { - throw new Error('No roles found in binding') - } - + if (!allRoles.length) throw new Error('No roles found in binding') return allRoles } -/** - * Check if already signed in today - * (headers should already include timestamp and sign if desired) - */ async function checkAttendance(headers) { const res = await fetch(ATTENDANCE_URL, { method: 'GET', headers }) const json = await res.json() - - if (json.code !== 0) { - throw new Error(json.message || `API error code: ${json.code}`) - } - + if (json.code !== 0) throw new Error(json.message || `Attendance status check failed: ${json.code}`) return { hasToday: json.data?.hasToday ?? false, totalSignIns: json.data?.records?.length ?? 0 } } -/** - * Claim daily attendance - * (headers should already include timestamp and sign if desired) - */ async function claimAttendance(headers) { const res = await fetch(ATTENDANCE_URL, { method: 'POST', headers, body: null }) const json = await res.json() - - if (json.code !== 0) { - throw new Error(json.message || `API error code: ${json.code}`) - } - - // Parse rewards + if (json.code !== 0) throw new Error(json.message || `Claim failed: ${json.code}`) const rewards = [] const awardIds = json.data?.awardIds ?? [] const resourceMap = json.data?.resourceInfoMap ?? {} - for (const award of awardIds) { const info = resourceMap[award.id] - if (info) { - rewards.push(`${info.name} x${info.count}`) - } + if (info) rewards.push(`${info.name} x${info.count}`) } - return { rewards } } /** - * Run check-in for a single role - * token is the secret salt token used for signing (if available) + * Check-in for a single role (uses cred + salt to sign) */ -async function checkInRole(cred, role, token) { +async function checkInRole(cred, role, salt) { const path = '/web/v1/game/endfield/attendance' const timestamp = Math.floor(Date.now() / 1000).toString() const headers = buildHeaders(cred, role.gameRole, timestamp) - // Add sign header when token provided - if (token) { - const sign = signHeader(path, timestamp, '3', '1.0.0', token) - if (sign) headers['sign'] = sign - } + const sign = computeSignV2(path, timestamp, salt) + if (!sign) throw new Error('Missing salt for V2 signing (attendance requires sign)') + headers['sign'] = sign - // Check status const status = await checkAttendance(headers) - - if (status.hasToday) { - return { success: true, alreadyClaimed: true } - } - - // Claim if not signed in + if (status.hasToday) return { success: true, alreadyClaimed: true } const result = await claimAttendance(headers) - return { success: true, alreadyClaimed: false, rewards: result.rewards } } /** - * Run check-in for a single account (all roles) + * Process one ACCOUNT_TOKEN: get cred+salt, fetch roles, check-in all roles */ -async function run(cred, token, accountIndex) { +async function runAccount(accountToken, accountIndex) { log('debug', `\n----- CHECKING IN FOR ACCOUNT ${accountIndex} -----`) - try { - // Step 1: Get all player roles (include sign if token present) - log('debug', 'Fetching player binding...') - const roles = await getPlayerRoles(cred, token) + const oauth = await performOAuthFlow(accountToken) + const { cred, salt } = oauth + log('info', `Account ${accountIndex}: obtained cred and salt`) - log('info', `Account ${accountIndex}:`, `Found ${roles.length} role(s)`) + const roles = await getPlayerRoles(cred, salt) + log('info', `Account ${accountIndex}: Found ${roles.length} role(s)`) - // Step 2: Check in for each role for (const role of roles) { const roleLabel = `${role.nickname} (Lv.${role.level}) [${role.server}]` - try { - const result = await checkInRole(cred, role, token) - + const result = await checkInRole(cred, role, salt) if (result.alreadyClaimed) { - log('info', ` → ${roleLabel}:`, 'Already checked in today') + log('info', ` → ${roleLabel}: Already checked in today`) } else if (result.rewards?.length > 0) { - log('info', ` → ${roleLabel}:`, `Checked in! Rewards: ${result.rewards.join(', ')}`) + log('info', ` → ${roleLabel}: Checked in! Rewards: ${result.rewards.join(', ')}`) } else { - log('info', ` → ${roleLabel}:`, 'Successfully checked in!') + log('info', ` → ${roleLabel}: Successfully checked in!`) } - } catch (error) { - log('error', ` → ${roleLabel}:`, error.message) + } catch (err) { + log('error', ` → ${roleLabel}:`, err.message) } - - // Small delay between roles to avoid rate limiting - await new Promise(resolve => setTimeout(resolve, 500)) + await sleep(500) } - - } catch (error) { - log('error', `Account ${accountIndex}:`, error.message) + } catch (err) { + log('error', `Account ${accountIndex}:`, err.message) } } /** - * Custom log function to store messages - */ -function log(type, ...data) { - console[type](...data) - - switch (type) { - case 'debug': return - case 'error': hasErrors = true - } - - const string = data - .map(value => typeof value === 'object' ? JSON.stringify(value, null, 2) : value) - .join(' ') - - messages.push({ type, string }) -} - -/** - * Send results to Discord webhook + * Send Discord notification (optional) */ async function discordWebhookSend() { log('debug', '\n----- DISCORD WEBHOOK -----') - - if (!discordWebhook.toLowerCase().trim().startsWith('https://discord.com/api/webhooks/')) { - log('error', 'DISCORD_WEBHOOK is not a Discord webhook URL') + if (!discordWebhook || !discordWebhook.toLowerCase().trim().startsWith('https://discord.com/api/webhooks/')) { + log('debug', 'No valid DISCORD_WEBHOOK configured, skipping webhook send') return } - let discordMsg = '' - if (discordUser) { - discordMsg = `<@${discordUser}>\n` - } + if (discordUser) discordMsg = `<@${discordUser}>\n` discordMsg += '**Endfield Daily Check-in**\n' discordMsg += messages.map(msg => `(${msg.type.toUpperCase()}) ${msg.string}`).join('\n') - const res = await fetch(discordWebhook, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ content: discordMsg }) }) - - if (res.status === 204) { - log('info', 'Successfully sent message to Discord webhook!') - return - } - + if (res.status === 204) { log('info', 'Successfully sent message to Discord webhook!'); return } log('error', 'Error sending message to Discord webhook') } -// Main execution -if (!creds || !creds.length) { - throw new Error('SK_OAUTH_CRED_KEY environment variable not set!') +// Main +if (!accountTokens || accountTokens.length === 0) { + throw new Error('ACCOUNT_TOKEN environment variable is required (one or more tokens separated by newlines)') } -if (!tokens || !tokens.length) { - throw new Error('SK_TOKEN_CACHE_KEY environment variable not set!') +for (let i = 0; i < accountTokens.length; i++) { + await runAccount(accountTokens[i], i + 1) + if (i < accountTokens.length - 1) await sleep(1000) } -for (const index in creds) { - const token = resolveTokenForIndex(Number(index)) - await run(creds[index], token, Number(index) + 1) - - // Delay between accounts - if (index < creds.length - 1) { - await new Promise(resolve => setTimeout(resolve, 1000)) - } -} - -if (discordWebhook && URL.canParse(discordWebhook)) { +if (discordWebhook) { await discordWebhookSend() } if (hasErrors) { console.log('') - throw new Error('Error(s) occurred.') + throw new Error('One or more errors occurred.') } From 31ea5fbce1ca2644235563f685ccb8491c85a249 Mon Sep 17 00:00:00 2001 From: Seya <31957516+sglkc@users.noreply.github.com> Date: Wed, 4 Feb 2026 07:39:55 +0700 Subject: [PATCH 7/8] update docs for new login flow --- .github/workflows/login.yml | 3 +-- README.md | 44 +++++++++++++++---------------------- index.js | 2 +- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/.github/workflows/login.yml b/.github/workflows/login.yml index 59a775a..5087cbc 100644 --- a/.github/workflows/login.yml +++ b/.github/workflows/login.yml @@ -20,8 +20,7 @@ jobs: - name: Check In run: node index.js env: - SK_OAUTH_CRED_KEY: ${{ secrets.SK_OAUTH_CRED_KEY }} - SK_TOKEN_CACHE_KEY: ${{ secrets.SK_TOKEN_CACHE_KEY }} + ACCOUNT_TOKEN: ${{ secrets.ACCOUNT_TOKEN }} DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} DISCORD_USER: ${{ secrets.DISCORD_USER }} workflow-keepalive: diff --git a/README.md b/README.md index 965d639..b8ae377 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,13 @@ Today's check in status: Repository version: [![Do your setup!](../../actions/workflows/version.yml/badge.svg)](../../actions/workflows/version.yml) +> [!NOTE] +> The script might stop working after a few months, there is currently no way of knowing when it will definitely break. +> If the status failed several times, try to redo your setup again before reporting it as an issue. + ## Table of Contents -- [Getting your auth token](#getting-your-auth-token) +- [Getting your account token](#getting-your-account-token) - [Usage](#usage) - [Discord Webhook](#discord-webhook) - [FAQ](#faq) @@ -16,9 +20,9 @@ Repository version: - [How to update my (fork) repository version?](#how-to-update-my-fork-repository-version) - [I have other issues](#i-have-other-issues) -## Getting your auth token +## Getting your account token -You have to check in manually first to get your auth token, follow these steps (click to open screenshot): +You have to check in manually first to get your account token, follow these steps (click to open screenshot): 1. Open [SKPORT Arknights: Endfield Daily Sign In](https://game.skport.com/endfield/sign-in) and login if you haven't (obviously) @@ -28,25 +32,15 @@ You have to check in manually first to get your auth token, follow these steps (
4.
- For Chromium users, click on the Application tab. If not found, click on the arrow. - image + For Chromium users, click on the Application tab -> Cookies, click on ACCOUNT_TOKEN, and check Show URL-encoded. + image
- For Firefox/Gecko-based browsers, click on the Storage tab. - image + For Firefox/Gecko-based browsers, click on the Storage tab -> Cookies, and copy ACCOUNT_TOKEN value. + image
-5.
- Just like the screenshot above, click on Local Storage and look for SK_OAUTH_CRED_KEY and SK_TOKEN_CACHE_KEY. Copy both! - image -
- -6.
- Copy the value by clicking on it, then selecting the text below. Or just double-click and Ctrl+C - image -
- -7. That's your auth credentials and token, keep it save and do NOT share it with anyone! +5. That's your account token, keep it save and do NOT share it with anyone! ## Usage @@ -59,20 +53,18 @@ You have to check in manually first to get your auth token, follow these steps ( 5.
- Insert both SK_OAUTH_CRED_KEY and SK_TOKEN_CACHE_KEY then click Add secret. You can input as many accounts, separate it with a new line (Enter). + Insert the name ACCOUNT_TOKEN and the secret of your account token from before, then click Add secret. You can input as many accounts, separate it with a new line (Enter). - image - image -
+ image + 6.
- Here is the example for multiple accounts and your environments should now look like this. + Here is the example secret value for multiple accounts. - image - image + image
- + 7.
For the first day, you have to trigger this manually. diff --git a/index.js b/index.js index 6fc4ae5..d5aea37 100755 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ import crypto from 'crypto' -const accountTokens = (process.env.ACCOUNT_TOKEN || "").split('\n').map(s => s.trim()).filter(Boolean) +const accountTokens = (process.env.ACCOUNT_TOKEN || "").split('\n').map(s => decodeURIComponent(s.trim())).filter(Boolean) const discordWebhook = process.env.DISCORD_WEBHOOK const discordUser = process.env.DISCORD_USER From af3ce2901c16f701666d79229af9c9221ed050e4 Mon Sep 17 00:00:00 2001 From: Seya <31957516+sglkc@users.noreply.github.com> Date: Wed, 4 Feb 2026 07:42:36 +0700 Subject: [PATCH 8/8] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 36c6718..c3b17b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "endfield-auto-daily", - "version": "2.0.1", + "version": "3.0.0", "description": "Easiest, full free, and no BS SKPORT Arknights: Endfield daily check-in using GitHub Actions", "private": true, "main": "index.js",