-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Burtey
committed
Sep 17, 2023
1 parent
4ad04ee
commit db15975
Showing
9 changed files
with
116 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
- rate limits | ||
- proper link of .gql (instead of copy) | ||
- Tilt setup | ||
- next-apisation? |
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
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
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,59 @@ | ||
import express from "express" | ||
|
||
import { boltcardRouter } from "./router" | ||
import { fetchByCardId, fetchByOneTimeCode } from "./knex" | ||
import { AES_DECRYPT_KEY } from "./config" | ||
|
||
boltcardRouter.get( | ||
"/wipeboltcard", | ||
async (req: express.Request, res: express.Response) => { | ||
// should be pass with POST? not sure if this would be compatible | ||
// with the wallet that can create cards | ||
const cardId = req.query.cardId | ||
const oneTimeCode = req.query.a | ||
|
||
if (!cardId && !oneTimeCode) { | ||
res.status(400).send({ status: "ERROR", reason: "cardId missing" }) | ||
return | ||
} | ||
// TODO authorization | ||
|
||
// TODO may be both on CardInit and Card table | ||
let card | ||
if (cardId) { | ||
if (typeof cardId !== "string") { | ||
res.status(400).send({ status: "ERROR", reason: "cardId is not a string" }) | ||
return | ||
} | ||
|
||
card = await fetchByCardId(cardId) | ||
} else { | ||
if (typeof oneTimeCode !== "string") { | ||
res.status(400).send({ status: "ERROR", reason: "oneTimeCode is not a string" }) | ||
return | ||
} | ||
|
||
card = await fetchByOneTimeCode(oneTimeCode) | ||
} | ||
|
||
if (!card) { | ||
res.status(400).send({ status: "ERROR", reason: "card not found" }) | ||
return | ||
} | ||
|
||
res.json({ | ||
status: "OK", | ||
action: "wipe", | ||
k0: card.k0AuthKey, | ||
k1: AES_DECRYPT_KEY, | ||
k2: card.k2CmacKey, | ||
k3: card.k3, | ||
k4: card.k4, | ||
uid: card.uid, | ||
version: 1, | ||
}) | ||
}, | ||
) | ||
|
||
const wipe = "" | ||
export { wipe } |