diff --git a/packages/app/src/Element/Nip5Service.tsx b/packages/app/src/Element/Nip5Service.tsx
index 4106d9441..209627831 100644
--- a/packages/app/src/Element/Nip5Service.tsx
+++ b/packages/app/src/Element/Nip5Service.tsx
@@ -21,6 +21,7 @@ import { useUserProfile } from "Hooks/useUserProfile";
import useEventPublisher from "Feed/EventPublisher";
import { debounce } from "Util";
import useLogin from "Hooks/useLogin";
+import SnortServiceProvider from "Nip05/SnortServiceProvider";
import messages from "./messages";
@@ -31,6 +32,7 @@ type Nip05ServiceProps = {
link: string;
supportLink: string;
helpText?: boolean;
+ forSubscription?: string;
onChange?(h: string): void;
onSuccess?(h: string): void;
};
@@ -188,6 +190,22 @@ export default function Nip5Service(props: Nip05ServiceProps) {
}
}
+ async function claimForSubscription(handle: string, domain: string, sub: string) {
+ if (!pubkey || !publisher) {
+ return;
+ }
+
+ const svcEx = new SnortServiceProvider(publisher, props.service);
+ const rsp = await svcEx.registerForSubscription(handle, domain, sub);
+ if ("error" in rsp) {
+ setError(rsp);
+ } else {
+ if (props.onSuccess) {
+ const nip05 = `${handle}@${domain}`;
+ props.onSuccess(nip05);
+ }
+ }
+ }
async function updateProfile(handle: string, domain: string) {
if (user && publisher) {
const nip05 = `${handle}@${domain}`;
@@ -245,16 +263,27 @@ export default function Nip5Service(props: Nip05ServiceProps) {
)}
{availabilityResponse?.available && !registerStatus && (
-
-
-
- {availabilityResponse.quote?.data.type}
-
-
startBuy(handle, domain)}>
-
+ {!props.forSubscription && (
+
+
+
+ {availabilityResponse.quote?.data.type}
+
+ )}
+
+ props.forSubscription
+ ? claimForSubscription(handle, domain, props.forSubscription)
+ : startBuy(handle, domain)
+ }>
+ {props.forSubscription ? (
+
+ ) : (
+
+ )}
)}
diff --git a/packages/app/src/Nip05/SnortServiceProvider.ts b/packages/app/src/Nip05/SnortServiceProvider.ts
index 4fcc6d360..c4d58a1d4 100644
--- a/packages/app/src/Nip05/SnortServiceProvider.ts
+++ b/packages/app/src/Nip05/SnortServiceProvider.ts
@@ -42,6 +42,15 @@ export default class SnortServiceProvider extends ServiceProvider {
return this.getJsonAuthd