mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
28 lines
802 B
TypeScript
28 lines
802 B
TypeScript
import { Conf } from '@/config.ts';
|
|
import { Storages } from '@/storages.ts';
|
|
import { getInstanceMetadata } from '@/utils/instance.ts';
|
|
|
|
/** NIP-46 client-connect metadata. */
|
|
interface ConnectMetadata {
|
|
name: string;
|
|
description: string;
|
|
url: string;
|
|
}
|
|
|
|
/** Get NIP-46 `nostrconnect://` URI for the Ditto server. */
|
|
export async function getClientConnectUri(signal?: AbortSignal): Promise<string> {
|
|
const uri = new URL('nostrconnect://');
|
|
const { name, tagline } = await getInstanceMetadata(await Storages.db(), signal);
|
|
|
|
const metadata: ConnectMetadata = {
|
|
name,
|
|
description: tagline,
|
|
url: Conf.localDomain,
|
|
};
|
|
|
|
uri.host = Conf.pubkey;
|
|
uri.searchParams.set('relay', Conf.relay);
|
|
uri.searchParams.set('metadata', JSON.stringify(metadata));
|
|
|
|
return uri.toString();
|
|
}
|