mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
22 lines
969 B
JavaScript
22 lines
969 B
JavaScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { resolveVerifiedBitloginPubkey } from "../js/ui/bitloginModalIntegration.js";
|
|
|
|
const PUBKEY = "a".repeat(64);
|
|
|
|
test("BitLogin accepts a login identity only when the event and widget worker agree", async () => {
|
|
const widget = { getPublicKey: async () => PUBKEY.toUpperCase() };
|
|
assert.equal(await resolveVerifiedBitloginPubkey(widget, PUBKEY), PUBKEY);
|
|
});
|
|
|
|
test("BitLogin rejects a forged event pubkey even when its claimed account has access", async () => {
|
|
const widget = { getPublicKey: async () => "b".repeat(64) };
|
|
assert.equal(await resolveVerifiedBitloginPubkey(widget, PUBKEY), "");
|
|
});
|
|
|
|
test("BitLogin rejects malformed claims and widgets without a worker-backed public key", async () => {
|
|
assert.equal(await resolveVerifiedBitloginPubkey({}, PUBKEY), "");
|
|
assert.equal(await resolveVerifiedBitloginPubkey({ getPublicKey: async () => PUBKEY }, "npub1nope"), "");
|
|
});
|