Skip to content

Commit

Permalink
refactor: don't use overwrite cookie option by default
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 25, 2024
1 parent 0c52469 commit dfbcb94
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 0 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,6 @@ _**default value**_:
```js
{
httpOnly: true,
overwrite: true,
sameSite: 'none'
}
```
Expand Down Expand Up @@ -2124,7 +2123,6 @@ _**default value**_:
```js
{
httpOnly: true,
overwrite: true,
sameSite: 'lax'
}
```
Expand Down
2 changes: 0 additions & 2 deletions lib/helpers/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,6 @@ function makeDefaults() {
*/
long: {
httpOnly: true, // cookies are not readable by client-side javascript
overwrite: true,
sameSite: 'none',
},

Expand All @@ -767,7 +766,6 @@ function makeDefaults() {
*/
short: {
httpOnly: true, // cookies are not readable by client-side javascript
overwrite: true,
sameSite: 'lax',
},

Expand Down
11 changes: 8 additions & 3 deletions test/test_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ Object.defineProperties(Provider.prototype, {
},
});

function getSetCookies(response) {
return response.headers['set-cookie'].filter((val) => !val.includes('Thu, 01 Jan 1970 00:00:00 GMT'));
}

function readCookie(value) {
expect(value).to.exist;
const parsed = querystring.parse(value, '; ');
Expand Down Expand Up @@ -290,8 +294,9 @@ export default function testHelper(importMetaUrl, {
expect(query).to.be.null;
expect(response).to.have.nested.property('headers.set-cookie').that.is.an('array');

const uid = readCookie(response.headers['set-cookie'][0]);
expect(readCookie(response.headers['set-cookie'][0])).to.equal(readCookie(response.headers['set-cookie'][2]));
const uid = readCookie(getSetCookies(response)[0]);
expect(readCookie(getSetCookies(response)[0]))
.to.equal(readCookie(getSetCookies(response)[2]));

const interaction = TestAdapter.for('Interaction').syncFind(uid);

Expand All @@ -313,7 +318,7 @@ export default function testHelper(importMetaUrl, {

AuthorizationRequest.prototype.validateInteraction = (eName, ...eReasons) => { // eslint-disable-line arrow-body-style
return (response) => {
const uid = readCookie(response.headers['set-cookie'][0]);
const uid = readCookie(getSetCookies(response)[0]);
const { prompt: { name, reasons } } = TestAdapter.for('Interaction').syncFind(uid);
expect(name).to.equal(eName);
expect(reasons).to.contain.members(eReasons);
Expand Down

0 comments on commit dfbcb94

Please sign in to comment.