Skip to content

Commit

Permalink
feat(API): remove setFlash
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
- req.session.setFlash was removed, if you were using this please comment on
  GitHub

fixes #53
  • Loading branch information
vvo committed May 1, 2020
1 parent 5b7c3d1 commit 3320ccd
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 32 deletions.
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ The seal stored on the client contains the session data, not your server, making
The seal is signed and encrypted using [@hapi/iron](https://github.com/hapijs/iron), [iron-store](https://github.com/vvo/iron-store/) is used behind the scenes.
This method of storing session data is the same technique used by **frameworks like [Ruby On Rails](https://guides.rubyonrails.org/security.html#session-storage)**.

**⚡️ Flash session data is supported**. It means you can store some data which will be deleted when read. This is useful for temporary data, redirects or notices on your UI.

**♻️ Password rotation is supported**. It allows you to change the password used to sign and encrypt sessions while still being able to decrypt sessions that were created with a previous password.

**By default the cookie has an ⏰ expiration time of 15 days**, set via [`maxAge`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#Directives). After that, even if someone tries to reuse the cookie, `next-iron-session` will not accept the underlying seal because the expiration is part of the seal value. See https://hapi.dev/family/iron for more information on @hapi/iron mechanisms.

**Next.js's** 🗿 [Static generation](https://nextjs.org/docs/basic-features/pages#static-generation-recommended) (SG) and ⚙️ [Server-side Rendering](https://nextjs.org/docs/basic-features/pages#server-side-rendering) (SSG) are both supported.

**There's a Connect middleware available** so you can use this library in any Connect compatible framework like Express.

**By default the cookie has an ⏰ expiration time of 15 days**, set via [`maxAge`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#Directives). After that, even if someone tries to reuse the cookie, `next-iron-session` will not accept the underlying seal because the expiration is part of the seal value. See https://hapi.dev/family/iron for more information on @hapi/iron mechanisms.

_Table of contents:_

- [Installation](#installation)
Expand All @@ -39,7 +37,6 @@ _Table of contents:_
- [async applySession(req, res, { password, cookieName, [ttl], [cookieOptions] })](#async-applysessionreq-res--password-cookiename-ttl-cookieoptions-)
- [req.session.set(name, value)](#reqsessionsetname-value)
- [req.session.get(name)](#reqsessiongetname)
- [req.session.setFlash(name, value)](#reqsessionsetflashname-value)
- [req.session.unset(name)](#reqsessionunsetname)
- [req.session.destroy()](#reqsessiondestroy)
- [FAQ](#faq)
Expand Down Expand Up @@ -285,8 +282,6 @@ await applySession(req, res, options);

### req.session.get(name)

### req.session.setFlash(name, value)

### req.session.unset(name)

### req.session.destroy()
Expand Down
1 change: 0 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export async function applySession(
const session = {
set: store.set,
get: store.get,
setFlash: store.setFlash,
unset: store.unset,
async save() {
const seal = await store.seal();
Expand Down
24 changes: 0 additions & 24 deletions lib/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ test("withSession((req, res) => {}, {password, cookieName})", () => {
"get": [Function],
"save": [Function],
"set": [Function],
"setFlash": [Function],
"unset": [Function],
},
}
Expand Down Expand Up @@ -78,7 +77,6 @@ test("withSession(({req, res}) => {}, {password, cookieName})", () => {
"get": [Function],
"save": [Function],
"set": [Function],
"setFlash": [Function],
"unset": [Function],
},
}
Expand Down Expand Up @@ -118,26 +116,6 @@ test("req.session.set", () => {
});
});

test("req.session.setFlash", () => {
return new Promise((done) => {
const handler = (req) => {
req.session.setFlash("state", "dfsafsalfk21lkf12lkf21");
expect(req.session.get("state")).toMatchInlineSnapshot(
`"dfsafsalfk21lkf12lkf21"`,
);
expect(req.session.get("state")).toMatchInlineSnapshot(`undefined`);
done();
};
const wrappedHandler = withIronSession(handler, { password, cookieName });
wrappedHandler(
{
headers: { cookie: "" },
},
{},
);
});
});

test("req.session.unset", () => {
return new Promise((done) => {
const handler = (req) => {
Expand Down Expand Up @@ -515,7 +493,6 @@ test("Connect middleware ironSession({password, cookieName})", () => {
"get": [Function],
"save": [Function],
"set": [Function],
"setFlash": [Function],
"unset": [Function],
},
}
Expand Down Expand Up @@ -571,7 +548,6 @@ test("applySession(req, res, {password, cookieName})", async () => {
"get": [Function],
"save": [Function],
"set": [Function],
"setFlash": [Function],
"unset": [Function],
},
}
Expand Down

2 comments on commit 3320ccd

@vercel
Copy link

@vercel vercel bot commented on 3320ccd May 1, 2020

Choose a reason for hiding this comment

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

Deployment failed with the following error:

The provided path “/tmp/7CyMBWRR6n3siIBUuW7vwqGp/repo/example” does not exist. To change your project settings, go to https://zeit.co/codeagain/next-iron-session-example/settings

@vercel
Copy link

@vercel vercel bot commented on 3320ccd May 1, 2020

Choose a reason for hiding this comment

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

Deployment failed with the following error:

The provided path “/tmp/wQ70JxfYHeNfEu0MCeH8cRXN/repo/example” does not exist. To change your project settings, go to https://zeit.co/codeagain/next-iron-session-example/settings

Please sign in to comment.