Skip to content

feat: implement XMLHttpRequest.withCredentials#721

Merged
saghul merged 12 commits intosaghul:masterfrom
KawaiiZapic:feat/cookies
Sep 1, 2025
Merged

feat: implement XMLHttpRequest.withCredentials#721
saghul merged 12 commits intosaghul:masterfrom
KawaiiZapic:feat/cookies

Conversation

@KawaiiZapic
Copy link
Copy Markdown
Contributor

Implemented XHR.withCredentials with cURL's cookies jar
Also fixed #720

@saghul
Copy link
Copy Markdown
Owner

saghul commented Aug 26, 2025

Thank you!

@saghul
Copy link
Copy Markdown
Owner

saghul commented Aug 26, 2025

Could you tame the linter please?

@KawaiiZapic
Copy link
Copy Markdown
Contributor Author

KawaiiZapic commented Aug 26, 2025

Could you tame the linter please?

Sorry for that, now I have run the linter for C and JS

@KawaiiZapic
Copy link
Copy Markdown
Contributor Author

Could you tame the linter please?

Maybe there is some difference of clang-format between Homebrew version and Linux version, I have re-formatted it manually, according the output log of workflow

@saghul
Copy link
Copy Markdown
Owner

saghul commented Aug 28, 2025

The test failures seem related.

@KawaiiZapic
Copy link
Copy Markdown
Contributor Author

KawaiiZapic commented Aug 28, 2025

The test failures seem related.

It seems some limitations of GitHub Action are preventing cURL from saving cookies to $HOME/.tjs, I downloaded the binary which failed to pass tests and it just works fine on my machine, all tests are passed.

I can't figure out why this is happening, so I make $TJS_HOME point to /tmp when testing cookies, and it works fine.

https://github.com/KawaiiZapic/txiki.js/blob/4a11f0e5be186b2fca6a9e09ae28959357370a56/tests/test-xhr-credentials.js#L40-L48
I don't think this is the best solution for this problem. Is this acceptable?

@saghul
Copy link
Copy Markdown
Owner

saghul commented Aug 28, 2025

Perhaps use spawn to run the test in a nested environment? Or use tjs.homeDir as the jar path?

@KawaiiZapic
Copy link
Copy Markdown
Contributor Author

Perhaps use spawn to run the test in a nested environment? Or use tjs.homeDir as the jar path?

I've fixed them in the latest commit and test in my fork repo, please approve this workflow run to test it works or not

Copy link
Copy Markdown
Owner

@saghul saghul left a comment

Choose a reason for hiding this comment

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

Almost there!

const path = globalThis[Symbol.for('tjs.internal.modules.path')];
const TJS_HOME = tjs.env.TJS_HOME ?? path.join(tjs.homeDir, '.tjs');

mkdirSync(TJS_HOME, { recursive: true });
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you perhaps add a flag so we only do this initialization once?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think is a good idea to handle the creation of TJS_HOME in a global initialize process, that will reduce duplicate code in storage and XHR, but I don't think this should be done in this PR.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Agreed, let's do that afterwards 👍

@saghul saghul merged commit 903bf1d into saghul:master Sep 1, 2025
17 of 19 checks passed
@saghul
Copy link
Copy Markdown
Owner

saghul commented Sep 1, 2025

Cheers!

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.

Typo in XHR.withCredentials

2 participants