SHA256
Исправить подключение и подпись в браузерном кошельке
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const PAGE_REQUEST = 'shine-wallet-page-request';
|
||||
const PAGE_RESPONSE = 'shine-wallet-page-response';
|
||||
const PAGE_MESSAGE_TARGET_ORIGIN = '*';
|
||||
|
||||
function injectProviderBridge() {
|
||||
const root = document.head || document.documentElement;
|
||||
@@ -20,14 +21,21 @@ function respondToPage(id, ok, result, error, code) {
|
||||
result: result || null,
|
||||
error: error ? String(error) : '',
|
||||
code: code ? String(code) : '',
|
||||
}, window.location.origin);
|
||||
}, PAGE_MESSAGE_TARGET_ORIGIN);
|
||||
}
|
||||
|
||||
function sendRuntimeMessage(type, payload = {}) {
|
||||
return new Promise((resolve, reject) => {
|
||||
chrome.runtime.sendMessage({ type, payload }, (response) => {
|
||||
if (chrome.runtime.lastError) {
|
||||
reject(new Error(chrome.runtime.lastError.message || 'Runtime message failed'));
|
||||
const raw = String(chrome.runtime.lastError.message || 'Runtime message failed');
|
||||
if (/Extension context invalidated/i.test(raw)) {
|
||||
const error = new Error('Расширение было перезагружено или отключено. Обновите страницу и откройте кошелёк заново.');
|
||||
error.code = 'EXTENSION_CONTEXT_INVALIDATED';
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
reject(new Error(raw));
|
||||
return;
|
||||
}
|
||||
if (!response?.ok) {
|
||||
@@ -71,6 +79,7 @@ window.addEventListener('message', (event) => {
|
||||
publicKeyBase58: String(params?.publicKeyBase58 || '').trim(),
|
||||
transactionBase64: String(params?.transactionBase64 || '').trim(),
|
||||
comment: String(params?.comment || '').trim(),
|
||||
transactionSummary: params?.transactionSummary || null,
|
||||
});
|
||||
respondToPage(id, true, response.result || null);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user