From 8b4676456deec6246011960e73a4511026e33f93 Mon Sep 17 00:00:00 2001 From: Artem Zakharchenko Date: Thu, 17 Nov 2022 18:29:25 +0100 Subject: [PATCH 1/4] fix(Request): support custom "credentials" value (#21) --- packages/fetch/src/request.js | 4 +++- packages/fetch/test/request.js | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/fetch/src/request.js b/packages/fetch/src/request.js index 482882c..8752dca 100644 --- a/packages/fetch/src/request.js +++ b/packages/fetch/src/request.js @@ -37,6 +37,7 @@ const isRequest = object => { * @property {string} method * @property {RequestRedirect} redirect * @property {globalThis.Headers} headers + * @property {RequestCredentials} credentials * @property {URL} parsedURL * @property {AbortSignal|null} signal * @@ -125,6 +126,7 @@ export default class Request extends Body { method, redirect: init.redirect || input.redirect || 'follow', headers, + credentials: init.credentials || 'same-origin', parsedURL, signal: signal || null }; @@ -159,7 +161,7 @@ export default class Request extends Body { */ get credentials() { - return "same-origin" + return this[INTERNALS].credentials } /** diff --git a/packages/fetch/test/request.js b/packages/fetch/test/request.js index 9fa8cdc..a615be7 100644 --- a/packages/fetch/test/request.js +++ b/packages/fetch/test/request.js @@ -111,6 +111,16 @@ describe('Request', () => { expect(derivedRequest.signal).to.equal(null); }); + it('should default to "same-origin" as credentials', () => { + const request = new Request(base) + expect(request.credentials).to.equal('same-origin'); + }) + + it('should respect custom credentials value', () => { + expect(new Request(base, { credentials: 'omit'})).to.have.property('credentials', 'omit'); + expect(new Request(base, { credentials: 'include'})).to.have.property('credentials', 'include'); + }) + it('should throw error with GET/HEAD requests with body', () => { expect(() => new Request(base, {body: ''})) .to.throw(TypeError); From f5a3a69842226e8f498c61bc167e805ab51b72ef Mon Sep 17 00:00:00 2001 From: Jacob Ebey Date: Thu, 17 Nov 2022 09:33:07 -0800 Subject: [PATCH 2/4] Create soft-gorillas-travel.md --- .changeset/soft-gorillas-travel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/soft-gorillas-travel.md diff --git a/.changeset/soft-gorillas-travel.md b/.changeset/soft-gorillas-travel.md new file mode 100644 index 0000000..c4bfc86 --- /dev/null +++ b/.changeset/soft-gorillas-travel.md @@ -0,0 +1,5 @@ +--- + "@remix-run/web-fetch": patch + --- + + Add support for custom "credentials" value. Nothing is done with them at the moment but they pass through for the consumer of the request to access if needed. From c3644375418b45ca5ca4b1cd79fad36c85a3dac2 Mon Sep 17 00:00:00 2001 From: Jacob Ebey Date: Thu, 17 Nov 2022 09:33:32 -0800 Subject: [PATCH 3/4] Update soft-gorillas-travel.md --- .changeset/soft-gorillas-travel.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/soft-gorillas-travel.md b/.changeset/soft-gorillas-travel.md index c4bfc86..a6e2c5f 100644 --- a/.changeset/soft-gorillas-travel.md +++ b/.changeset/soft-gorillas-travel.md @@ -1,5 +1,5 @@ --- - "@remix-run/web-fetch": patch - --- +"@remix-run/web-fetch": patch +--- Add support for custom "credentials" value. Nothing is done with them at the moment but they pass through for the consumer of the request to access if needed. From de665a2bb6f7493690f8258cf2460aee1866a09c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sat, 26 Aug 2023 19:27:56 +0200 Subject: [PATCH 4/4] chore: fix changeset --- .changeset/soft-gorillas-travel.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/soft-gorillas-travel.md b/.changeset/soft-gorillas-travel.md index a6e2c5f..6eca2a6 100644 --- a/.changeset/soft-gorillas-travel.md +++ b/.changeset/soft-gorillas-travel.md @@ -1,5 +1,5 @@ --- -"@remix-run/web-fetch": patch +"@web-std/fetch": feat --- - Add support for custom "credentials" value. Nothing is done with them at the moment but they pass through for the consumer of the request to access if needed. +Add support for custom `credentials` value. Nothing is done with them at the moment but they pass through for the consumer of the request to access if needed.