Files
martbost 3620a72338 Wallet diagnostics: a check page, and an error that names the signer
Two sign-in failures with different causes and no way to tell them apart from
the outside, so stop guessing and get the data off the member's device.

/wallet-check reports what the page can actually see: whether window.ethereum
exists, which wallet flags are set, which EIP-6963 wallets announced, the
accounts and chain the wallet returns — and critically, any CSP violation.
Our script-src is 'self' with no 'unsafe-inline', and a wallet browser that
injects its provider via a script tag would be blocked silently, producing
symptoms identical to "no wallet installed". The company dApp sends no CSP at
all, which is a plausible reason it connects where we do not. This page will
confirm or kill that theory rather than us theorising further.

"Signature does not match this wallet" was true but useless — it never said
WHICH wallet signed. It now names both the address the page asked for and the
address that actually signed, which identifies the classic multi-account case
(wallet signs with the selected account, not the one the page picked up) in
one glance.

Verified for the case in hand: 0x20E0…2248 IS the wallet registered to
position #52 on-chain, so ownership was never the problem.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-29 05:53:34 -05:00

81 lines
3.6 KiB
JavaScript

// Diagnostic page for wallet sign-in failures. Reports what the page can
// actually see, from the member's own device, instead of us guessing.
//
// It captures the one thing we cannot infer from the outside: whether a CSP
// violation is firing when the wallet tries to inject its provider. Our
// script-src is 'self' with no 'unsafe-inline', and wallet browsers that inject
// via a <script> tag would be blocked silently — no error the member could see,
// and identical symptoms to "no wallet installed".
(function () {
'use strict';
var violations = [];
window.addEventListener('securitypolicyviolation', function (e) {
violations.push(e.violatedDirective + ' blocked ' + (e.blockedURI || '(inline)') +
(e.sourceFile ? ' from ' + e.sourceFile : ''));
render();
});
function row(k, v, good) {
return '<div class="row"><div class="k">' + k + '</div><div class="v ' +
(good === true ? 'yes' : good === false ? 'no' : '') + '">' + v + '</div></div>';
}
function esc(s) {
return String(s == null ? '' : s).replace(/[&<>"']/g, function (c) {
return { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c];
});
}
var announced = [];
window.addEventListener('eip6963:announceProvider', function (e) {
try { announced.push(e.detail.info.name + ' (' + e.detail.info.rdns + ')'); } catch (x) {}
render();
});
try { window.dispatchEvent(new Event('eip6963:requestProvider')); } catch (x) {}
function render() {
var eth = window.ethereum;
var flags = [];
if (eth) {
['isMetaMask', 'isTrust', 'isTrustWallet', 'isCoinbaseWallet', 'isSafePal', 'isPhantom', 'isRabby']
.forEach(function (f) { if (eth[f]) flags.push(f); });
if (eth.providers && eth.providers.length) flags.push('providers[' + eth.providers.length + ']');
}
var html = '';
html += row('window.ethereum present', eth ? 'YES' : 'NO', !!eth);
html += row('wallet flags', flags.length ? esc(flags.join(', ')) : '(none)');
html += row('EIP-6963 wallets announced', announced.length ? esc(announced.join(' · ')) : '(none)');
html += row('CSP violations seen', violations.length ? esc(violations.join(' | ')) : 'none', violations.length ? false : true);
html += row('page address', esc(location.href));
document.getElementById('rows').innerHTML = html;
document.getElementById('dump').textContent =
'UA: ' + navigator.userAgent + '\n' +
'ethereum: ' + (eth ? 'yes' : 'no') + '\n' +
'flags: ' + (flags.join(',') || '-') + '\n' +
'eip6963: ' + (announced.join(',') || '-') + '\n' +
'csp: ' + (violations.join(' | ') || 'none') + '\n' +
'href: ' + location.href;
}
document.getElementById('ask').addEventListener('click', async function () {
var out = document.getElementById('askOut');
out.innerHTML = '';
try {
var eth = await window.RMCWallet.pick();
if (!eth) { out.innerHTML = row('result', 'No provider found — the page cannot see a wallet', false); return; }
var accs = await eth.request({ method: 'eth_requestAccounts' });
var chain = await eth.request({ method: 'eth_chainId' });
out.innerHTML = row('accounts returned', esc(JSON.stringify(accs))) +
row('first account', esc(accs && accs[0] || '(none)')) +
row('selectedAddress', esc(eth.selectedAddress || '(not exposed)')) +
row('chain id', esc(chain) + (chain === '0x89' ? ' — Polygon ✓' : ' — NOT Polygon'), chain === '0x89');
} catch (e) {
out.innerHTML = row('error', esc(e && (e.message || e.code || String(e))), false);
}
render();
});
setTimeout(render, 400);
render();
})();