mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-31 09:52:24 +00:00
Fix NIP-46 pairing flow
This commit is contained in:
1 parent
493a901b26
commit
56915dbb69
2 files changed
+53
-4
No files matched your search
@@ -9,7 +9,10 @@
|
||||
>
|
||||
<div class="bv-modal-backdrop" data-dismiss></div>
|
||||
|
||||
<div class="modal-sheet max-h-modal-shell overflow-hidden" tabindex="-1">
|
||||
<div
|
||||
class="modal-sheet max-h-modal-shell flex min-h-0 flex-col overflow-hidden"
|
||||
tabindex="-1"
|
||||
>
|
||||
<!-- Header with the special exit button (unchanged) -->
|
||||
<div class="modal-header">
|
||||
<h2 id="loginModalTitle" class="text-xl font-bold text-text">
|
||||
@@ -37,7 +40,10 @@
|
||||
</div>
|
||||
|
||||
<!-- Body -->
|
||||
<div id="loginModalDescription" class="modal-body space-y-6 overflow-y-auto">
|
||||
<div
|
||||
id="loginModalDescription"
|
||||
class="modal-body flex-1 space-y-6 overflow-y-auto"
|
||||
>
|
||||
<div class="space-y-2 text-left">
|
||||
<p class="text-sm text-text-muted">
|
||||
Choose how you'd like to sign in. Connect a browser extension, link a
|
||||
|
||||
+45
-2
@@ -4993,6 +4993,49 @@ export class NostrClient {
|
||||
|
||||
const waitTimeout = Number.isFinite(timeoutMs) && timeoutMs > 0 ? timeoutMs : NIP46_HANDSHAKE_TIMEOUT_MS;
|
||||
|
||||
const coerceStructuredString = (value) => {
|
||||
if (typeof value === "string") {
|
||||
return value.trim();
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
for (const entry of value) {
|
||||
const candidate = coerceStructuredString(entry);
|
||||
if (candidate) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
if (value && typeof value === "object") {
|
||||
const preferredKeys = [
|
||||
"secret",
|
||||
"message",
|
||||
"status",
|
||||
"reason",
|
||||
"detail",
|
||||
"description",
|
||||
"value",
|
||||
"result",
|
||||
"url",
|
||||
];
|
||||
for (const key of preferredKeys) {
|
||||
if (Object.prototype.hasOwnProperty.call(value, key)) {
|
||||
const candidate = coerceStructuredString(value[key]);
|
||||
if (candidate) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const entry of Object.values(value)) {
|
||||
const candidate = coerceStructuredString(entry);
|
||||
if (candidate) {
|
||||
return candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
return "";
|
||||
};
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
let settled = false;
|
||||
const cleanup = () => {
|
||||
@@ -5051,8 +5094,8 @@ export class NostrClient {
|
||||
return;
|
||||
}
|
||||
|
||||
const resultValue = typeof parsed?.result === "string" ? parsed.result.trim() : "";
|
||||
const errorValue = typeof parsed?.error === "string" ? parsed.error.trim() : "";
|
||||
const resultValue = coerceStructuredString(parsed?.result);
|
||||
const errorValue = coerceStructuredString(parsed?.error);
|
||||
|
||||
if (resultValue === "auth_url" && errorValue) {
|
||||
if (typeof onAuthUrl === "function") {
|
||||
|
||||
Reference in new issue
Block a user