-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
port over refactors and fixes from #57
refactors (lint, split endpoints from functions, etc) make purchasing from multiple tabs harder make the transaction token a signed JWT retarget to es2018 to allow named regex capture groups add small grace period for extension logs prevent replaying bits transactions detect mobile slightly differently
- Loading branch information
Showing
44 changed files
with
1,630 additions
and
1,236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Webhooks } from "@octokit/webhooks"; | ||
import { getConfig, getRawConfigData, sendRefresh } from "."; | ||
import { app } from "../.."; | ||
import { asyncCatch } from "../../util/middleware"; | ||
|
||
const webhooks = new Webhooks({ | ||
secret: process.env.PRIVATE_API_KEY!, | ||
}); | ||
|
||
app.get( | ||
"/public/config", | ||
asyncCatch(async (req, res) => { | ||
const config = await getConfig(); | ||
res.send(JSON.stringify(config)); | ||
}) | ||
); | ||
|
||
app.post( | ||
"/webhook/refresh", | ||
asyncCatch(async (req, res) => { | ||
// github webhook | ||
const signature = req.headers["x-hub-signature-256"] as string; | ||
const body = JSON.stringify(req.body); | ||
|
||
if (!(await webhooks.verify(body, signature))) { | ||
res.sendStatus(403); | ||
return; | ||
} | ||
|
||
// only refresh if the config.json file was changed | ||
if (req.body.commits.some((commit: any) => commit.modified.includes("config.json"))) { | ||
sendRefresh(); | ||
|
||
res.status(200).send("Config refreshed."); | ||
} else { | ||
res.status(200).send("Config not refreshed."); | ||
} | ||
}) | ||
); | ||
|
||
app.get( | ||
"/private/refresh", | ||
asyncCatch(async (_, res) => { | ||
sendRefresh(); | ||
|
||
res.send(await getRawConfigData()); | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.