added logs

This commit is contained in:
PhilReact 2024-07-06 09:06:17 +03:00
parent 30c6a8b024
commit 5dde455a9c
2 changed files with 10 additions and 6 deletions

View File

@ -63,6 +63,7 @@ document.addEventListener('qortalExtensionRequests', async (event) => {
} }
}); });
} else if (type === 'REQUEST_OAUTH') { } else if (type === 'REQUEST_OAUTH') {
console.log('oauth enter')
const hostname = window.location.hostname const hostname = window.location.hostname
const res = await connection(hostname) const res = await connection(hostname)
if(!res){ if(!res){
@ -73,10 +74,12 @@ document.addEventListener('qortalExtensionRequests', async (event) => {
})); }));
return return
} }
console.log('oauth enter2')
chrome.runtime.sendMessage({ action: "oauth", payload: { chrome.runtime.sendMessage({ action: "oauth", payload: {
nodeBaseUrl, nodeBaseUrl: payload.nodeBaseUrl,
senderAddress, senderAddress: payload.senderAddress,
senderPublicKey, timestamp senderPublicKey: payload.senderPublicKey, timestamp: payload.timestamp
}}, (response) => { }}, (response) => {
if (response.error) { if (response.error) {
document.dispatchEvent(new CustomEvent('qortalExtensionResponses', { document.dispatchEvent(new CustomEvent('qortalExtensionResponses', {

View File

@ -263,8 +263,9 @@ function fetchMessages(apiCall) {
try { try {
const response = await fetch(apiCall); const response = await fetch(apiCall);
console.log({response})
const data = await response.json(); const data = await response.json();
console.log({data})
if (data && data.length > 0) { if (data && data.length > 0) {
resolve(data); // Resolve the promise when data is found resolve(data); // Resolve the promise when data is found
} else { } else {
@ -296,7 +297,7 @@ async function listenForChatMessage({ nodeBaseUrl, senderAddress, senderPublicKe
const address = wallet.address0; const address = wallet.address0;
const before = timestamp + 5000 const before = timestamp + 5000
const after = timestamp - 5000 const after = timestamp - 5000
const apiCall = `${validApi}/chat/messages?involving=${senderAddress}&involving=${address}&reverse=true&limit=1&before=${before}&after=${after}}`; const apiCall = `${validApi}/chat/messages?involving=${senderAddress}&involving=${address}&reverse=true&limit=1&before=${before}&after=${after}`;
const encodedMessageObj = await fetchMessages(apiCall) const encodedMessageObj = await fetchMessages(apiCall)
console.log({encodedMessageObj}) console.log({encodedMessageObj})
const response = await decryptStoredWallet(password, wallet); const response = await decryptStoredWallet(password, wallet);
@ -389,7 +390,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
case "oauth": { case "oauth": {
const { nodeBaseUrl, senderAddress, senderPublicKey, timestamp } = request.payload; const { nodeBaseUrl, senderAddress, senderPublicKey, timestamp } = request.payload;
console.log('sup', nodeBaseUrl, senderAddress, senderPublicKey, timestamp)
listenForChatMessage({ nodeBaseUrl, senderAddress, senderPublicKey, timestamp }) listenForChatMessage({ nodeBaseUrl, senderAddress, senderPublicKey, timestamp })
.then(({ secretCode }) => { .then(({ secretCode }) => {
sendResponse(secretCode); sendResponse(secretCode);