From 0abea32919bbc2dd18dedd6e1b62147e459643b4 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Sun, 8 Dec 2024 19:05:11 +0000 Subject: [PATCH 1/8] Update dependency dotenv to v16.4.7 --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 49f8e14..29b5b06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -800,9 +800,9 @@ } }, "node_modules/dotenv": { - "version": "16.4.5", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", - "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", "license": "BSD-2-Clause", "engines": { "node": ">=12" From 702e3e966e118ebcef977025ca27e396240a184d Mon Sep 17 00:00:00 2001 From: DaInfLoop Date: Fri, 27 Jun 2025 11:52:59 +0100 Subject: [PATCH 2/8] Remove whitelist + make changes to work with Identity Vault --- index.ts | 70 ++++++++++++++++++++++---------------------------------- 1 file changed, 27 insertions(+), 43 deletions(-) diff --git a/index.ts b/index.ts index d8196d3..be1fa04 100644 --- a/index.ts +++ b/index.ts @@ -8,20 +8,6 @@ const app = new App({ signingSecret: process.env.SLACK_SIGNING_SECRET, }); -const whitelist: string[] = (() => { - try { - return require('./whitelist.json') - } catch (e) { - return [] - } -})(); - -function checkUserOk(user: UsersInfoResponse['user']) { - if (whitelist.includes(user!.id!)) return true - - return user!.is_admin || user!.is_owner || user!.is_primary_owner -} - const eligibilityCmd = async (ctx: any) => { await ctx.ack(); @@ -33,12 +19,8 @@ const eligibilityCmd = async (ctx: any) => { const iUser = await ctx.client.users.info({ user: ctx.context.userId! }); if ((match = text.match(/\<\@(.+)\|(.+)>/))) { - if (!checkUserOk(iUser.user!)) { - matchedBy = "not allowed" - } else { - userId = match[1]; - matchedBy = "user mention" - } + userId = match[1]; + matchedBy = "user mention" } else if (text) matchedBy = "invalid input" @@ -52,30 +34,29 @@ const eligibilityCmd = async (ctx: any) => { redirect: "follow" }).then(res => res.json()) - if (res === `User ${userId} not found!`) + if (res.status === "not_found") return await ctx.respond({ response_type: 'ephemeral', - text: `${matchedBy !== "user mention" ? "You aren't" : `<@${userId}> isn't`} verified and therefore aren't eligible for rewards from your program.${matchedBy !== "user mention" ? `\nCheck out the to verify.` : ""}${matchedBy == "not allowed" ? " (Only whitelisted users can check other people's verification statuses.)" : ""}`, + text: `${matchedBy !== "user mention" ? "You aren't" : `<@${userId}> isn't`} verified. ${matchedBy !== "user mention" ? `\nCheck out the to verify.` : ""}`, unfurl_links: true }) - else if (res.status === "Insufficient") { + else if (res.status === "needs_submission") { return await ctx.respond({ response_type: 'ephemeral', - text: `${matchedBy !== "user mention" ? "You" : `<@${userId}>`} provided insufficient evidence that ${matchedBy !== "user mention" ? "you" : "they"} are a student.${matchedBy !== "user mention" ? `\nCheck out the to re-verify.` : ""}${matchedBy == "not allowed" ? " (Only whitelisted users can check other people's verification statuses.)" : ""}`, + text: `${matchedBy !== "user mention" ? "You" : `<@${userId}>`} provided insufficient evidence of who ${matchedBy !== "user mention" ? "you" : "they"} are.${matchedBy !== "user mention" ? `\nCheck out the to re-verify.` : ""}`, unfurl_links: true - }) + }) } - else if (res.status === "Unknown") { + else if (res.status === "pending") { return await ctx.respond({ response_type: 'ephemeral', - text: `${matchedBy !== "user mention" ? "Your verification" : `<@${userId}>'s verification`} has not been accepted yet.${matchedBy == "not allowed" ? " (Only whitelisted users can check other people's verification statuses.)" : ""}`, - unfurl_links: true - }) + text: `${matchedBy !== "user mention" ? "Your verification" : `<@${userId}>'s verification`} has not been accepted yet.`, + }) } - else if (res.status === "Ineligible") { + else if (res.status === "rejected") { if (matchedBy === "user mention") { return await ctx.respond({ response_type: 'ephemeral', @@ -84,11 +65,15 @@ const eligibilityCmd = async (ctx: any) => { } else { return await ctx.respond({ response_type: 'ephemeral', - text: `Your verification has been denied. If you believe this to be a mistake, please contact an admin of the program you are applying for.${matchedBy == "not allowed" ? " (Only whitelisted users can check other people's verification statuses.)" : ""},` + text: `Your verification has been denied. If you believe this to be a mistake, please send a message in <#C092833JXKK>.` }) } } + /** + * The sanctioned country status seems to have been deprecated in the Identity Vault. + * However, this piece of code is being kept for documentation purposes. + else if (res.status === "Sanctioned country") { if (matchedBy === "user mention") { return await ctx.respond({ @@ -100,22 +85,21 @@ const eligibilityCmd = async (ctx: any) => { response_type: 'ephemeral', text: `You live in a country that cannot have packages delivered to due to sanctions.${matchedBy == "not allowed" ? " (Only whitelisted users can check other people's verification statuses.)" : ""},` }) - } + } } + */ - else { + else if (res.status === "verified_eligible") { return await ctx.respond({ response_type: 'ephemeral', - text: `${matchedBy !== "user mention" ? "You have verified your" : `<@${userId}> has verified their`} student status, and ${matchedBy !== "user mention" ? "are" : "is"} ${res.status}.${matchedBy == "not allowed" ? " (Only whitelisted users can check other people's verification statuses.)" : ""}`, - blocks: [ - { - type: 'section', - text: { - type: 'mrkdwn', - text: `${matchedBy !== "user mention" ? "You have verified your" : `<@${userId}> has verified their`} student status, and ${matchedBy !== "user mention" ? "are" : "is"} *${res.status}*.${matchedBy == "not allowed" ? " (Only whitelisted users can check other people's verification statuses.)" : ""}` - } - } - ] + text: `${matchedBy !== "user mention" ? "You have verified your" : `<@${userId}> has verified their`} identity, and ${matchedBy !== "user mention" ? "are" : "is"} eligible for YSWS prizes.`, + }) + } + + else if (res.status === "verified_but_over_18") { + return await ctx.respond({ + response_type: 'ephemeral', + text: `${matchedBy !== "user mention" ? "You have verified your" : `<@${userId}> has verified their`} identity, but since ${matchedBy !== "user mention" ? "you're" : "they're"} over 18, ${matchedBy !== "user mention" ? "you're" : "they're"} ineligible for YSWS prizes.`, }) } } From 2a8af5667ad55b66b5f5fcd6d5cc7e427f14e233 Mon Sep 17 00:00:00 2001 From: DaInfLoop Date: Fri, 27 Jun 2025 12:09:35 +0100 Subject: [PATCH 3/8] i forgot to change the url --- index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.ts b/index.ts index be1fa04..1dbe6fb 100644 --- a/index.ts +++ b/index.ts @@ -16,8 +16,6 @@ const eligibilityCmd = async (ctx: any) => { let userId = ctx.context.userId; let matchedBy = "no input" - const iUser = await ctx.client.users.info({ user: ctx.context.userId! }); - if ((match = text.match(/\<\@(.+)\|(.+)>/))) { userId = match[1]; matchedBy = "user mention" @@ -25,7 +23,7 @@ const eligibilityCmd = async (ctx: any) => { matchedBy = "invalid input" - const res = await fetch("https://verify.hackclub.dev/api/status", { + const res = await fetch("https://identity.hackclub.com/api/external/check?slack_id" + userId, { method: "POST", headers: { 'content-type': 'application/json' }, body: JSON.stringify({ From 276a6ea313f95853236695a6ba8cb38742072773 Mon Sep 17 00:00:00 2001 From: DaInfLoop Date: Fri, 27 Jun 2025 12:11:34 +0100 Subject: [PATCH 4/8] i also forgot to change the request method --- index.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/index.ts b/index.ts index 1dbe6fb..71bd1e6 100644 --- a/index.ts +++ b/index.ts @@ -24,11 +24,6 @@ const eligibilityCmd = async (ctx: any) => { const res = await fetch("https://identity.hackclub.com/api/external/check?slack_id" + userId, { - method: "POST", - headers: { 'content-type': 'application/json' }, - body: JSON.stringify({ - "slack_id": userId - }), redirect: "follow" }).then(res => res.json()) From 5c3d854fdfcbf355fa812e201dea8152c2a48445 Mon Sep 17 00:00:00 2001 From: DaInfLoop Date: Fri, 27 Jun 2025 12:14:30 +0100 Subject: [PATCH 5/8] don't rush me, me --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 71bd1e6..7a08c24 100644 --- a/index.ts +++ b/index.ts @@ -23,7 +23,7 @@ const eligibilityCmd = async (ctx: any) => { matchedBy = "invalid input" - const res = await fetch("https://identity.hackclub.com/api/external/check?slack_id" + userId, { + const res = await fetch("https://identity.hackclub.com/api/external/check?slack_id=" + userId, { redirect: "follow" }).then(res => res.json()) From 8f9a4540f701b20d195772822040ff2b710868d1 Mon Sep 17 00:00:00 2001 From: DaInfLoop Date: Fri, 27 Jun 2025 12:15:42 +0100 Subject: [PATCH 6/8] add a user-agent so they know who's killing their servers :D --- index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.ts b/index.ts index 7a08c24..be544ff 100644 --- a/index.ts +++ b/index.ts @@ -24,6 +24,9 @@ const eligibilityCmd = async (ctx: any) => { const res = await fetch("https://identity.hackclub.com/api/external/check?slack_id=" + userId, { + headers: { + 'User-Agent': 'HackClubEligibilityBot/1.0 (ran by Loop / dainfloop)' + } redirect: "follow" }).then(res => res.json()) From 655633349c0cb75031b2769af0d1cc95dcf84803 Mon Sep 17 00:00:00 2001 From: DaInfLoop Date: Fri, 27 Jun 2025 12:16:34 +0100 Subject: [PATCH 7/8] the comma of pain --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index be544ff..467b783 100644 --- a/index.ts +++ b/index.ts @@ -26,7 +26,7 @@ const eligibilityCmd = async (ctx: any) => { const res = await fetch("https://identity.hackclub.com/api/external/check?slack_id=" + userId, { headers: { 'User-Agent': 'HackClubEligibilityBot/1.0 (ran by Loop / dainfloop)' - } + }, redirect: "follow" }).then(res => res.json()) From 7f2f2decc4de3db8b656fdec141253c9af268f47 Mon Sep 17 00:00:00 2001 From: DaInfLoop Date: Fri, 27 Jun 2025 12:32:23 +0100 Subject: [PATCH 8/8] using the wrong property name :sob: --- index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.ts b/index.ts index 467b783..f7e8ee2 100644 --- a/index.ts +++ b/index.ts @@ -30,14 +30,14 @@ const eligibilityCmd = async (ctx: any) => { redirect: "follow" }).then(res => res.json()) - if (res.status === "not_found") + if (res.result === "not_found") return await ctx.respond({ response_type: 'ephemeral', text: `${matchedBy !== "user mention" ? "You aren't" : `<@${userId}> isn't`} verified. ${matchedBy !== "user mention" ? `\nCheck out the to verify.` : ""}`, unfurl_links: true }) - else if (res.status === "needs_submission") { + else if (res.result === "needs_submission") { return await ctx.respond({ response_type: 'ephemeral', text: `${matchedBy !== "user mention" ? "You" : `<@${userId}>`} provided insufficient evidence of who ${matchedBy !== "user mention" ? "you" : "they"} are.${matchedBy !== "user mention" ? `\nCheck out the to re-verify.` : ""}`, @@ -45,14 +45,14 @@ const eligibilityCmd = async (ctx: any) => { }) } - else if (res.status === "pending") { + else if (res.result === "pending") { return await ctx.respond({ response_type: 'ephemeral', text: `${matchedBy !== "user mention" ? "Your verification" : `<@${userId}>'s verification`} has not been accepted yet.`, }) } - else if (res.status === "rejected") { + else if (res.result === "rejected") { if (matchedBy === "user mention") { return await ctx.respond({ response_type: 'ephemeral', @@ -85,14 +85,14 @@ const eligibilityCmd = async (ctx: any) => { } */ - else if (res.status === "verified_eligible") { + else if (res.result === "verified_eligible") { return await ctx.respond({ response_type: 'ephemeral', text: `${matchedBy !== "user mention" ? "You have verified your" : `<@${userId}> has verified their`} identity, and ${matchedBy !== "user mention" ? "are" : "is"} eligible for YSWS prizes.`, }) } - else if (res.status === "verified_but_over_18") { + else if (res.result === "verified_but_over_18") { return await ctx.respond({ response_type: 'ephemeral', text: `${matchedBy !== "user mention" ? "You have verified your" : `<@${userId}> has verified their`} identity, but since ${matchedBy !== "user mention" ? "you're" : "they're"} over 18, ${matchedBy !== "user mention" ? "you're" : "they're"} ineligible for YSWS prizes.`,