Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cookieDuration): add cookieDuration support #61

Merged
merged 3 commits into from
Dec 14, 2018

Conversation

tkrugg
Copy link
Contributor

@tkrugg tkrugg commented Dec 14, 2018

This PR:

  • adds cookieDuration param to init
  • check it's a valid integer
  • and uses it to computed the expire date of the cookie

@tkrugg tkrugg changed the title Feat/cookie duration feat(cookieDuration): add cookieDuration support Dec 14, 2018
@tkrugg tkrugg changed the title feat(cookieDuration): add cookieDuration support WIP feat(cookieDuration): add cookieDuration support Dec 14, 2018
@tkrugg tkrugg force-pushed the feat/cookie-duration branch from 2660d1f to 044069d Compare December 14, 2018 15:41
const credentials = {
apiKey: "test",
applicationID: "test"
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

was unsused.
I will check tslint config to make sure this doesn't occur more: #62


/**
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I moved createUUID outside so I can mock it in the tests. It's generic enough that it can belong inside utils/index.ts


const cookieDuration = options.cookieDuration
? options.cookieDuration
: 6 * MONTH;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

by default cookieDuration is 6 months


describe("createUUID", () => {
it("should return a string composed of valid hex characters or dashes `-`", () => {
expect(createUUID()).toMatch(/^[0-9a-f\-]+$/);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to test this more. We don't actually care that this is a valid uuid. What's important is that:

  • it's random
  • it contains only hex characters so that they don't get encoded when used in a cookie.

@tkrugg tkrugg changed the title WIP feat(cookieDuration): add cookieDuration support feat(cookieDuration): add cookieDuration support Dec 14, 2018
@tkrugg tkrugg force-pushed the feat/cookie-duration branch from 044069d to 4368c2f Compare December 14, 2018 15:56
- remove cookie reuinitialization at each init
- move createUUID outside cookie methods for easier testing
- add tests for createUUID
@tkrugg tkrugg force-pushed the feat/cookie-duration branch from 4368c2f to babb1ad Compare December 14, 2018 15:57
@tkrugg tkrugg merged commit 66a4a69 into develop Dec 14, 2018
@samouss samouss deleted the feat/cookie-duration branch December 17, 2018 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant