UNPKG

@pedwise/next-firebase-auth-edge

Version:

Next.js 13 Firebase Authentication for Edge and server runtimes. Dedicated for Next 13 server components. Compatible with Next.js middleware.

22 lines (17 loc) 920 B
import { RotatingCredential } from "./rotating-credential"; describe("rotating-credential", () => { it("should sign and verify string using provided keys", async () => { const credential = new RotatingCredential(["key1", "key2"]); const key = await credential.sign("some string"); expect(key).toEqual("pRUtdYSFwPukug4oJuql5qtl9Vc"); expect(await credential.verify("some string", key)).toBe(true); expect(await credential.verify("some string", "wat")).toBe(false); expect(await credential.verify("some", key)).toBe(false); }); it("should sign and verify string using different set keys where at least one matches", async () => { const credential1 = new RotatingCredential(["key1", "key2"]); const credential2 = new RotatingCredential(["key2"]); const key = await credential2.sign("some string"); expect(await credential1.verify("some string", key)).toBe(true); }); });