Spaces:
Sleeping
Sleeping
File size: 557 Bytes
ad2afbf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | import { describe, expect, it } from "vitest";
import { decodeApplicationKey } from "./app-key.js";
describe("decodeApplicationKey", () => {
it("accepts only an unpadded base64url encoding of exactly 32 bytes", () => {
const encoded = Buffer.alloc(32, 7).toString("base64url");
expect(decodeApplicationKey(encoded)).toEqual(Buffer.alloc(32, 7));
expect(() => decodeApplicationKey(`${encoded}=`)).toThrow(/base64url/i);
expect(() =>
decodeApplicationKey(Buffer.alloc(31).toString("base64url")),
).toThrow(/32 bytes/i);
});
});
|