aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/names.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/names.js')
-rw-r--r--src/features/names.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/features/names.js b/src/features/names.js
index 43d4895..ea94d2a 100644
--- a/src/features/names.js
+++ b/src/features/names.js
@@ -146,6 +146,17 @@ export function namesFeature(ctx) {
const domain = DOMAIN();
try { return await claim(name, opts); }
catch (err) {
+ // Signed by the login identity, a name this WALLET's key claimed
+ // earlier (before the identity was attached) reads as someone else's —
+ // the record names the wallet key as owner and no manager. The wallet
+ // key may always update its own record, so retry with it.
+ if (opts.signer && err.message === 'name is taken') {
+ const mine = await fetch(`${REGISTRAR}/name/${encodeURIComponent(name)}?domain=${encodeURIComponent(domain)}`,
+ { signal: AbortSignal.timeout(8000), cache: 'no-store' }).then((r) => (r.ok ? r.json() : null)).catch(() => null);
+ const pk = wallet.nostrPubkey && wallet.nostrPubkey();
+ if (pk && mine?.taken && (mine.pubkey === pk || mine.manager === pk))
+ return claim(name, { ...opts, signer: undefined, manager: undefined });
+ }
if (domain === 'coinos.io' && ['name is taken', 'name is reserved'].includes(err.message)) {
try {
const r = await fetch(`${REGISTRAR}/name/${encodeURIComponent(name)}?domain=${encodeURIComponent(domain)}`,