Nostr: allow setting a nip05 username

environments/review-nip05-xinwy4/deployments/4476
Alex Gleason 6 months ago
parent c24fc10c93
commit b9111719f0
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -55,6 +55,7 @@ const messages = defineMessages({
displayNamePlaceholder: { id: 'edit_profile.fields.display_name_placeholder', defaultMessage: 'Name' },
websitePlaceholder: { id: 'edit_profile.fields.website_placeholder', defaultMessage: 'Display a Link' },
locationPlaceholder: { id: 'edit_profile.fields.location_placeholder', defaultMessage: 'Location' },
nip05Placeholder: { id: 'edit_profile.fields.nip05_placeholder', defaultMessage: 'user@{domain}' },
cancel: { id: 'common.cancel', defaultMessage: 'Cancel' },
});
@ -75,6 +76,11 @@ interface AccountCredentialsSource {
sensitive?: boolean;
/** Default language to use for authored statuses. (ISO 6391) */
language?: string;
/** Nostr metadata. */
nostr?: {
/** Nostr NIP-05 identifier. */
nip05?: string;
};
}
/**
@ -120,6 +126,8 @@ interface AccountCredentials {
location?: string;
/** User's birthday. */
birthday?: string;
/** Nostr NIP-05 identifier. */
nip05?: string;
}
/** Convert an account into an update_credentials request object. */
@ -142,6 +150,7 @@ const accountToCredentials = (account: Account): AccountCredentials => {
website: account.website,
location: account.location,
birthday: account.pleroma?.birthday ?? undefined,
nip05: account.source?.nostr?.nip05 ?? '',
};
};
@ -308,6 +317,19 @@ const EditProfile: React.FC = () => {
/>
</FormGroup>
{features.nip05 && (
<FormGroup
labelText={<FormattedMessage id='edit_profile.fields.nip05_label' defaultMessage='Username' />}
>
<Input
type='text'
value={data.nip05}
onChange={handleTextChange('nip05')}
placeholder={intl.formatMessage(messages.nip05Placeholder, { domain: location.host })}
/>
</FormGroup>
)}
{features.birthdays && (
<FormGroup
labelText={<FormattedMessage id='edit_profile.fields.birthday_label' defaultMessage='Birthday' />}

@ -592,6 +592,8 @@
"edit_profile.fields.meta_fields.content_placeholder": "Content",
"edit_profile.fields.meta_fields.label_placeholder": "Label",
"edit_profile.fields.meta_fields_label": "Profile fields",
"edit_profile.fields.nip05_label": "Username",
"edit_profile.fields.nip05_placeholder": "user@{domain}",
"edit_profile.fields.stranger_notifications_label": "Block notifications from strangers",
"edit_profile.fields.website_label": "Website",
"edit_profile.fields.website_placeholder": "Display a Link",

@ -94,6 +94,9 @@ const baseAccountSchema = z.object({
discoverable: z.boolean().catch(true),
}).optional().catch(undefined),
sms_verified: z.boolean().catch(false),
nostr: z.object({
nip05: z.string().optional().catch(undefined),
}).optional().catch(undefined),
}).optional().catch(undefined),
statuses_count: z.number().catch(0),
suspended: z.boolean().catch(false),

@ -722,6 +722,12 @@ const getInstanceFeatures = (instance: Instance) => {
v.software === TAKAHE,
]),
/**
* Can set a Nostr username.
* @see PATCH /api/v1/accounts/update_credentials
*/
nip05: v.software === DITTO,
/**
* Ability to sign Nostr events over websocket.
* @see GET /api/v1/streaming?stream=nostr

Loading…
Cancel
Save