(nsec: string)
| 2644 | } |
| 2645 | |
| 2646 | function 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 | |
| 2678 | function isRelayMode(config: E2eConfig | undefined): boolean { |
| 2679 | return config?.mode === "relay"; |
no test coverage detected