MCPcopy Create free account
hub / github.com/block/buzz / importMockIdentity

Function importMockIdentity

desktop/src/testing/e2eBridge.ts:2646–2676  ·  view source on GitHub ↗
(nsec: string)

Source from the content-addressed store, hash-verified

2644}
2645
2646function importMockIdentity(nsec: string) {
2647 const decoded = decode(nsec.trim());
2648 if (decoded.type !== "nsec") {
2649 throw new Error("Invalid Nostr private key.");
2650 }
2651
2652 const privateKey = bytesToHex(decoded.data);
2653 const pubkey = getPublicKey(decoded.data);
2654 const username = mockDisplayNames.get(pubkey) ?? "";
2655 const identity = {
2656 privateKey,
2657 pubkey,
2658 username,
2659 };
2660 writeStoredIdentityOverride(identity);
2661 if (!mockProfiles.has(pubkey)) {
2662 mockProfiles.set(pubkey, {
2663 pubkey,
2664 display_name: username || null,
2665 avatar_url: null,
2666 about: null,
2667 nip05_handle: null,
2668 owner_pubkey: null,
2669 });
2670 }
2671
2672 return {
2673 pubkey,
2674 display_name: username,
2675 };
2676}
2677
2678function isRelayMode(config: E2eConfig | undefined): boolean {
2679 return config?.mode === "relay";

Callers 1

handleMockCommandFunction · 0.85

Calls 5

decodeFunction · 0.85
hasMethod · 0.80
setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected