Initial MultiPay project
This commit is contained in:
commit
91abad4066
488 files changed
+76727
No files matched your search
@@ -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);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user