Skip to content

Comments

Fix the issue where reading the cookies from a different domains#16

Merged
marija04 merged 3 commits intomainfrom
fix/get-cookies-for-the-known-domain
May 9, 2025
Merged

Fix the issue where reading the cookies from a different domains#16
marija04 merged 3 commits intomainfrom
fix/get-cookies-for-the-known-domain

Conversation

@marija04
Copy link
Contributor

@marija04 marija04 commented May 9, 2025

No description provided.

@marija04 marija04 requested a review from erik-beus May 9, 2025 10:43
Copy link
Contributor

@erik-beus erik-beus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see suggestions/questions

Comment on lines 83 to 99
chrome.webNavigation
.getFrame({
documentId: info.parentDocumentId,
frameId: info.parentFrameId,
})
.then((parentFrame) => {
if (!parentFrame) {
return undefined
}

const parentUrl = new URL(parentFrame.url)
if (
parentUrl.host.endsWith('toddle.dev') === false &&
parentUrl.host.endsWith('nordcraft.com') === false
) {
return undefined
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic seems to be a duplicate of the code on line 17->36? Consider moving this to a separate function to make it easier to maintain - especially when (soon) need to remove 'toddle.dev' as a valid domain for the parent frame.

}
},
removeCookie: async (cookie, domain) => {
await chrome.cookies.remove(cookie)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this one also take a domain as argument?

@marija04 marija04 requested a review from erik-beus May 9, 2025 11:10
Copy link
Contributor

@erik-beus erik-beus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small questions

Comment on lines 66 to 69
if (info.parentFrameId < 0) {
return
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (info.parentFrameId < 0) {
return
}

}

// check the parent frame so we only override cookies if we are on nordcraft.com
nordcraftIsParentFrame({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make the event listener asynchronous on line 65 so you can use await here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, I wasn't able to do it async so that's why I did it like this.

await chrome.cookies.set(cookie)

const parsedUrl = new URL(cookie.url)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

})
}

export async function nordcraftIsParentFrame({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you do something similar for Firefox as well?

@marija04 marija04 requested a review from erik-beus May 9, 2025 12:59
@marija04 marija04 merged commit 9ffa105 into main May 9, 2025
1 check passed
@marija04 marija04 deleted the fix/get-cookies-for-the-known-domain branch May 9, 2025 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants