mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Wire up NIP-04 in the BitLogin adapter, flip capabilities.nip04 to true
bitlogin's widget now implements NIP-04 (nip04Encrypt/nip04Decrypt), closing the one gap left relative to a real NIP-07 extension. bitvid's own nip07Adapter/nsecAdapter/nip46Adapter all already wire this up and report it via signerCapabilities.nip04 -- BitLogin's adapter was the one exception, hardcoded to nip04: false because the widget genuinely didn't support it before. js/nostr/client.js's DM encrypt/decrypt path only offers NIP-04 to a caller when that capability flag is true, so a BitLogin-signed-in user previously had no working legacy-DM path at all. Re-vendored the widget bundle (bitlogin's CHANGELOG.md, 2026-07-21 entry, third one) and updated the one test that hardcoded the old (now-incorrect) capabilities shape. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01DY9UMTuF43Ekc2U4E1eDwX
This commit is contained in:
1 parent
ca7b711b8a
commit
f2d390ff18
5 files changed
+1095
-793
No files matched your search
@@ -102,7 +102,7 @@ describe("BitLogin auth provider", () => {
|
||||
});
|
||||
|
||||
describe("createBitloginAdapter", () => {
|
||||
it("delegates signing and NIP-44 calls to the live widget element, never window.nostr", async () => {
|
||||
it("delegates signing and NIP-44/NIP-04 calls to the live widget element, never window.nostr", async () => {
|
||||
const calls = [];
|
||||
const fakeWidget = {
|
||||
signEvent: async (event) => {
|
||||
@@ -117,6 +117,14 @@ describe("createBitloginAdapter", () => {
|
||||
calls.push(["nip44Decrypt", peer, payload]);
|
||||
return "plaintext";
|
||||
},
|
||||
nip04Encrypt: async (peer, plaintext) => {
|
||||
calls.push(["nip04Encrypt", peer, plaintext]);
|
||||
return "legacy-ciphertext";
|
||||
},
|
||||
nip04Decrypt: async (peer, payload) => {
|
||||
calls.push(["nip04Decrypt", peer, payload]);
|
||||
return "legacy-plaintext";
|
||||
},
|
||||
logout: async () => {
|
||||
calls.push(["logout"]);
|
||||
},
|
||||
@@ -127,19 +135,25 @@ describe("createBitloginAdapter", () => {
|
||||
assert.equal(adapter.type, "bitlogin");
|
||||
assert.equal(adapter.pubkey, HEX_PUBKEY);
|
||||
assert.equal(adapter.canSign(), true);
|
||||
assert.deepEqual(adapter.capabilities, { sign: true, nip44: true, nip04: false });
|
||||
// NIP-04 is real, load-bearing capability info: js/nostr/client.js only offers a
|
||||
// nip04Encrypt/Decrypt code path to callers when signerCapabilities.nip04 is true.
|
||||
assert.deepEqual(adapter.capabilities, { sign: true, nip44: true, nip04: true });
|
||||
|
||||
const signed = await adapter.signEvent({ kind: 1, content: "hi" });
|
||||
assert.equal(signed.id, "signed");
|
||||
|
||||
await adapter.nip44Encrypt("peer-pubkey", "hello");
|
||||
await adapter.nip44Decrypt("peer-pubkey", "ciphertext");
|
||||
await adapter.nip04Encrypt("peer-pubkey", "hello");
|
||||
await adapter.nip04Decrypt("peer-pubkey", "legacy-ciphertext");
|
||||
await adapter.destroy();
|
||||
|
||||
assert.deepEqual(calls, [
|
||||
["signEvent", { kind: 1, content: "hi" }],
|
||||
["nip44Encrypt", "peer-pubkey", "hello"],
|
||||
["nip44Decrypt", "peer-pubkey", "ciphertext"],
|
||||
["nip04Encrypt", "peer-pubkey", "hello"],
|
||||
["nip04Decrypt", "peer-pubkey", "legacy-ciphertext"],
|
||||
["logout"],
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user