Initial MultiPay project

This commit is contained in:
Alex committed 2026-11-02 09:50:37 +08:00
commit 91abad4066
488 files changed
+76727

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
import { describe, expect, test } from "bun:test";
import { decryptJson, encryptJson, hmacHex, safeEqual } from "../src/security";
describe("security helpers", () => {
test("encrypts and decrypts gateway configuration", () => {
const value = { appId: "demo", privateKey: "secret" };
const encrypted = encryptJson(value);
expect(encrypted).not.toContain("secret");
expect(decryptJson(encrypted)).toEqual(value);
});
test("creates deterministic HMAC and constant-time comparison", () => {
const signature = hmacHex("key", "message");
expect(signature).toHaveLength(64);
expect(safeEqual(signature, signature)).toBe(true);
expect(safeEqual(signature, signature.slice(1))).toBe(false);
});
});