commit f9061bab5631699fff65bf0a2d8a9d2328dc10a5
parent b724635e74628c6c0d0a9a1f262b1257b7d3a4c8
Author: triesap <137732411+triesap@users.noreply.github.com>
Date: Sun, 27 Apr 2025 03:44:10 +0000
utils-nostr: add/edit utils
Diffstat:
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/utils-nostr/src/lib/relay.ts b/utils-nostr/src/lib/relay.ts
@@ -30,3 +30,16 @@ export const lib_nostr_relay_parse_information_document = (data: any): NostrRela
limitation_restricted_writes: obj.limitation && typeof obj.limitation === 'object' && typeof obj.limitation.restricted_writes === 'boolean' ? obj.limitation.restricted_writes : undefined,
};
};
+
+export const lib_nostr_relay_build_information_document = (data: any): NostrRelayInformationDocumentFields | undefined => {
+ const doc = lib_nostr_relay_parse_information_document(data);
+ if (!doc) return;
+ const result: Partial<NostrRelayInformationDocumentFields> = {};
+ Object.entries(doc).forEach(([key, value]) => {
+ if (typeof value === 'boolean') result[key as keyof NostrRelayInformationDocument] = value ? '1' : '0';
+ else if (Array.isArray(value)) result[key as keyof NostrRelayInformationDocument] = value.join(', ');
+ else if (value === null || value === undefined) result[key as keyof NostrRelayInformationDocument] = '';
+ else result[key as keyof NostrRelayInformationDocument] = String(value);
+ });
+ return result;
+};
+\ No newline at end of file
diff --git a/utils-nostr/src/services/keys/lib.ts b/utils-nostr/src/services/keys/lib.ts
@@ -57,7 +57,6 @@ export class NostrKeyService implements INostrKeyService {
*/
public npub_decode(npub: string): string {
const decode = nip19.decode(npub);
- console.log(`decode `, decode)
if (decode && decode.type === `npub` && decode.data) return decode.data
return ``;
}