Initial commit

**Motivations:**
- Initialisation du versionning git pour le projet

**Root causes:**
- N/A (Nouveau projet)

**Correctifs:**
- N/A

**Evolutions:**
- Structure initiale du projet
- Ajout du .gitignore

**Pages affectées:**
- Tous les fichiers
This commit is contained in:
2026-03-03 22:24:17 +01:00
commit e031c9a1d2
155 changed files with 22334 additions and 0 deletions

36
server/auth.js Normal file
View File

@@ -0,0 +1,36 @@
import crypto from "crypto";
export function verifySignature(publicKeyBase64, signatureBase64, message) {
try {
const publicKeyBuf = Buffer.from(publicKeyBase64, "base64url");
const signatureBuf = Buffer.from(signatureBase64, "base64url");
const keyObject = crypto.createPublicKey({
key: publicKeyBuf,
format: "der",
type: "spki",
});
return crypto.verify(null, Buffer.from(message, "utf8"), keyObject, signatureBuf);
} catch (_e) {
return false;
}
}
/** Build message that client must sign: method + path + timestamp + bodyHash */
/**
* @param {string} method
* @param {string} path
* @param {string} timestamp
* @param {string} bodyHash
* @returns {string}
*/
export function buildSignMessage(method, path, timestamp, bodyHash) {
return `${method}\n${path}\n${timestamp}\n${bodyHash}`;
}
/**
* @param {string} body
* @returns {string} hex hash of body
*/
export function hashBody(body) {
return crypto.createHash("sha256").update(body || "").digest("hex");
}