mainmatter / ember-cookies Goto Github PK
View Code? Open in Web Editor NEWCookies abstraction for Ember.js that works both in the browser as well as with Fastboot on the server
License: MIT License
Cookies abstraction for Ember.js that works both in the browser as well as with Fastboot on the server
License: MIT License
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
package.json
files, so that was left aloneIf you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
The issue:
In our application, we first use simple-auth to authenticate and store some session info. Soon after, we read some cookies. When we are in fastboot, the first time we try to read a cookie, it is coming as undefined. After some digging, I think I can see the problem - the _cacheFastBootCookie
method is using the same object to write new fastboot cookies that _fastBootCookies
computed is using to read back fastboot cookies. That property is _fastBootCookiesCache
.
When _fastBootCookies
first computes, it checks for the existence of _fastBootCookiesCache
. If it doesn't exist, it will read _fastBoot.request.cookies
and cache those in _fastBootCookiesCache
. If simple-auth happened to have written a cookie before this computed runs, _fastBootCookiesCache
will already exist, and it will never read the _fastBoot.request.cookies
. Instead it will just read back the cookie that simple auth wrote.
So what I think is needed is for the _fastBootCookies
computed to be called before writing a fastboot cookie if that underlying _fastBootCookiesCache
doesn't exist. Thoughts?
Update: for anyone else facing this issue, a work-around you can do in your own code is to call a cookie read before doing any simple-auth work, which will cache those fastboot.request cookies before simple-auth can "lock them out" after writing its cookie.
It looks like we can already read()
all available cookies and clear()
a single cookie. For testing purposes it might make sense to have a clearAll()
method as well, to be able to start an acceptance test without any cookies.
Branch | Build failing 🚨 |
---|---|
Dependency | ember-source |
Current Version | 2.11.3 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-source is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 280 commits (ahead by 280, behind by 90).
1841cd8
Release v2.12.0
d91b748
More CHANGELOG typos [ci skip]
6568560
fix changelog typo [ci skip]
b0d527b
Typo [ci skip]
47cf31d
Prepare CHANGELOG for 2.12.0 [ci skip]
2a1b600
Update factoryManagerCache initial value to not share factoryCache
.
8fb1fb9
Adding test around factoryManager caching
b542bc5
allocate iteration structures lazily (pt. 2)
09c1218
[Fixes #15001] Remove internal EmptyObject usage
daefda7
[BUGFIX beta] [PERF] Cache FactoryManagers
25cf68a
[BUGFIX beta] only defProp the deprecated container once per prototype
756c845
allocate iteration structures lazily
bdb46eb
[DOCS beta] factoryFor docs
51d039e
Avoid a couple of redundant property loads.
c104dcd
Fix typo
There are 250 commits in total. See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
DEPRECATION: ember-getowner-polyfill is now a true polyfill. Use Ember.getOwner directly instead of importing from ember-getowner-polyfill
the package is still in the dependencies
😞
Branch | Build failing 🚨 |
---|---|
Dependency | ember-data |
Current Version | 2.11.3 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-data is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 92 commits (ahead by 92, behind by 22).
fd06e1f
Pull in loader.js from the dist directory instead of the lib directory (#4824)
0f73468
Release Ember Data 2.12.0
6395eb7
Update the changelog for the Ember Data 2.12.0 release
04cbbb5
Release Ember Data 2.12.0-beta.4
8511886
Update changelog for the 2.12.0-beta.4 release
3637db8
[Fixes #4807] realize class + factory seperation
d7fbbad
Don’t redefine findPossibleInverses for each _findInverseFor
ce95bb2
Avoid mutating model factory in _modelForMixin.
14a75bc
Release Ember Data 2.12.0-beta.3
b96685f
Update changelog for Ember Data 2.12.0-beta.3
83ca6e2
Merge pull request #4792 from runspired/2.12-beta-hotfix
d94a299
don't remove unpersisted deletes
52028db
Add a test for #4770
4a71fea
[BUGFIX beta] revert deletion of filter that removed deleted models when flushCanonical of hasMany was called
315b31c
Do not access container if Ember.getOwner exists.
There are 92 commits in total. See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
DEPRECATION: Use of `merge` has been deprecated. Please use `assign` instead. [deprecation id: ember-polyfills.deprecate-merge] See https://emberjs.com/deprecations/v3.x/#toc_ember-polyfills-deprecate-merge for more details.
"ember-source": "~3.7.0",
"ember-cookies": "0.3.1"
Branch | Build failing 🚨 |
---|---|
Dependency | mocha |
Current Version | 3.2.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
Thanks to all our contributors, maintainers, sponsors, and users! ❤️
As highlights:
--inspect-brk
on command-line (@igwejk)semistandard
directly (@kt3k)The new version differs by 89 commits0.
fb1687e
:ship: Release v3.3.0
1943e02
Add Changelog for v3.3.0
861e968
Refactor literal play-icon hex code to a var
1d3c5bc
Fix typo in karma.conf.js
9bd9389
Fix spec paths in test HTML files
0a93024
Adds tests for loading reporters w/ relative/absolute paths (#2773)
73929ad
Comment special treatment of '+' in URL query parsing
e2c9514
Merge pull request #2769 from igwejk/support_inspect_break_in_opts
038c636
Support --inspect-brk
on command-line
b4ebabd
Merge pull request #2727 from lamby/reproducible-build
882347b
Please make the build reproducible.
a2fc76c
Merge pull request #2703 from seppevs/cover_utils_some_fn_with_tests
ed61cd0
cover .some() function in utils.js with tests
f42cbf4
Merge pull request #2701 from craigtaub/landingSpec
6065242
use stubbed symbol
There are 89 commits in total.
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
I'm curious how to set this up, I'm having trouble and have read the docs. Could you give a quick snippet on say, a 48 hour expire time?
Branch | Build failing 🚨 |
---|---|
Dependency | ember-cli-dependency-checker |
Current Version | 1.3.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-cli-dependency-checker is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 12 commits .
c3c7b73
1.4.0
db5f429
Merge pull request #69 from orf/patch-2
55e9304
Update is-git-url semvar
401c83f
Merge pull request #68 from samdemaeyer/switch-packagemanagername-when-yarn-detected
47a231a
Refactor tests
7a6ca3b
switch the package managers name printed out when yarn.lock file is present
ccd0125
Merge pull request #66 from samtsai/fix-test-descriptions
193060c
Fix grammatical issue with test description
d48cb54
Merge pull request #63 from cibernox/update_dependencies
a01e762
Update to ember 2.10 family
b50bff3
Merge pull request #61 from acburdine/patch-1
b9d476c
update .npmignore for existing files
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
According to CHANGELOG.md and releases page version v0.5.0 has been released.
But https://www.npmjs.com/package/ember-cookies does not have v0.5.0
For some cookies there is null pointer exception in line.
And for this exception my sessionAuthenticated
hook in ESA failed.
The cookie cause : " swagger-editor-development-mode:true"
with no name
Hey there!
I was just trying this with the latest ember FastBoot (beta.4) and I get the following error:
TypeError: Cannot read property 'indexOf' of undefined at /Users/josemarluedke/Projects/myapp/dist/fastboot/vendor.js:75400:31 at /Users/josemarluedke/Projects/myapp/dist/fastboot/vendor.js:107107:80 at ....
The error points to this line: https://github.com/simplabs/ember-cookies/blob/e4b7cec51da57bd00986f658170e99b6d02d7239/addon/services/cookies.js#L129
Note, version used of ember-cookies was 0.0.7.
The one dependency that you are using ember-getowner-polyfill
has a newer version where it supports a new version of babel. This is needed as I am see deprecation warning in my ember app
DEPRECATION: ember-cli-babel 5.x has been deprecated. Please upgrade to at least
ember-cli-babel 6.6. Version 5.2.8 located: cf2-cli -> ember-cookies ->
ember-getowner-polyfill -> ember-cli-babel
I would make a PR but not sure that is really needed
…so styles are enforced
This needs tests.
Tests need to run both in the browser as well as in Fastboot.
Fastboot request protocol is changed to to contain a colon (https://github.com/ember-fastboot/fastboot/pull/119/files). The change should be reflected here as well.
Branch | Build failing 🚨 |
---|---|
Dependency | ember-cli-mocha |
Current Version | 0.13.2 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-cli-mocha is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
Fixed bugs:
Closed issues:
Merged pull requests:
this.options.babel
#190 (rwjblue)The new version differs by 26 commits0.
8e78be5
0.13.3
6feadca
Update CHANGELOG
acc4f81
README: Add "Compatibility" section
2a2bc51
Merge pull request #190 from ember-cli/rwjblue-patch-1
9f9106e
Prevent clobbering custom this.options.babel
8fd835e
Merge pull request #186 from ember-cli/greenkeeper/ember-load-initializers-1.0.0
a79af62
Merge pull request #187 from ember-cli/greenkeeper/ember-cli-test-loader-2.0.0
8a37a8d
fix(package): update ember-cli-test-loader to version 2.0.0
377605c
chore(package): update ember-load-initializers to version 1.0.0
9a3bcdb
Merge pull request #180 from ember-cli/greenkeeper/ember-source-2.12.0
977517c
chore(package): update ember-source to version 2.12.0
62311aa
Merge pull request #179 from ember-cli/greenkeeper/ember-resolver-3.0.0
2b21d76
chore(package): update ember-resolver to version 3.0.0
9d34c76
Merge pull request #178 from ember-cli/greenkeeper/broccoli-merge-trees-2.0.0
46d1ee9
fix(package): update broccoli-merge-trees to version 2.0.0
There are 26 commits in total.
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
This line is not working in Interner Explorer
https://github.com/simplabs/ember-cookies/blob/7a7c68d36617ad23978bb6af9481e75f0d3e08a8/addon/services/cookies.js#L9
and babel don't transform this line
https://babeljs.io/docs/plugins/transform-object-assign/#caveats
Branch | Build failing 🚨 |
---|---|
Dependency | ember-cli-fastboot |
Current Version | 1.0.0-beta.16 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-cli-fastboot is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 9 commits .
cb87f92
v1.0.0-beta.17
365c2ba
Merge pull request #371 from kratiahuja/disable-fastboot-serve
878965c
Merge pull request #373 from ryanone/master
c7dfc9e
Updated information around node-inspector
d01c3f6
Enable a way to disable fastboot serving at runtime and via environment variable.
38892b1
Merge pull request #356 from kratiahuja/serve-refactor
ecdb661
Fastboot serve refactor (unifying the experience with ember-cli)
444f7d2
Merge pull request #364 from kellyselden/redirect-to-self
e44c95f
add test coverage for noop redirects
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
It's currently not possible to use this addon without also including the FastBoot addon. Any attempt to inject the service results in Attempting to inject an unknown injection: service:fastboot
errors.
Branch | Build failing 🚨 |
---|---|
Dependency | loader.js |
Current Version | 4.2.2 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As loader.js is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 3 commits .
1075ea4
4.2.3
9c34843
Merge pull request #113 from ember-cli/check-extensibility
a1950aa
Check object extensibility before adding default property.
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
7.4.2
to 7.4.3
.This version is covered by your current version range and after updating it in your project the build failed.
ember-cli-babel is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
DEPRECATION: ember-getowner-polyfill is now a true polyfill. Use Ember.getOwner directly instead of importing from ember-getowner-polyfill [deprecation id: ember-getowner-polyfill.import]
Can a release be made so the exists method can be used when using the repo via install through npm.
Thanks!!
i try to clear user cookie in my ember app. and the cookie still there...
export default Service.extend({
cookies: Ember.inject.service(),
removeCookies() {
let cookieService = this.get('cookies');
cookieService.clear('user');
}
});
its work in chrome. but not in firefox..
whats wrong..
Branch | Build failing 🚨 |
---|---|
Dependency | eslint-plugin-ember |
Current Version | 2.1.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As eslint-plugin-ember is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | loader.js |
Current Version | 4.2.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As loader.js is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 3 commits .
52080b2
release v4.2.1
9b88633
Merge pull request #108 from ember-cli/fix-the-world
9d88818
[Fixes #106] include all the files we actually need
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
when reading cookies in with fastboot they are being uri decoded twice causing an error if the cookie contains a %
. This happens because fastboot uses the cookie package to parse the headers and add to the request object https://github.com/ember-fastboot/fastboot/blob/5a42df54ce3359a33589173d9c79a2236e619ba1/src/fastboot-request.js#L52 cookie calls decodeURIComponent
by default when parsing https://www.npmjs.com/package/cookie#decode the value is then decoded again by ember-cookies https://github.com/simplabs/ember-cookies/blob/master/addon/services/cookies.js#L207.
a simple reproduction is
if (!this.fastboot.isFastBoot) {
this.cookies.write('broken', '%')
}
this.cookies.read('broken')
I know there is a raw option i cannot use this since i'm using ember-cimple-auth. However i also don't think the current behavior is correct regardless since it would require it to be encoded on write and raw on read. I also don't think it would ever be the correct behavior to double decode something since this would change the format unexpectedly if someone intentionally double encoded something for some reason or if it similarly contained a restricted character.
I think the correct fix would be to never use decodeURIComponent
when in fastboot
I am happy to submit a PR for this if you agree with the approach
for now my workaround is
_decodeValue(value, raw) {
if (isNone(value) || raw) {
return value;
} else {
try {
return decodeURIComponent(value)
} catch (error) {
return value
}
}
}
This is obviously not great though since it overrides a private method and does not actually handle the double encoding problem but it solved my particular situation
Branch | Build failing 🚨 |
---|---|
Dependency | ember-cli-htmlbars |
Current Version | 1.3.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-cli-htmlbars is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 4 commits0.
b46eb48
v1.3.1
f0c03ec
Merge pull request #109 from ember-cli/use-non-deprecated-version-checker-api
faf7f25
Add yarn.lock.
1b27f67
Update ember-cli-version-checker use to avoid deprecated APIs.
false
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | ember-disable-prototype-extensions |
Current Version | 1.1.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-disable-prototype-extensions is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
The new version differs by 7 commits.
11e41e5
release v1.1.2 🎉
7cbd03c
release v1.1.1 🎉
e345d11
Merge pull request #10 from ember-cli/upgrade
37248ad
add travis badge
2374b13
add appveyor
07de228
upgrade
599396e
Update README.md
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | ember-cli-eslint |
Current Version | 3.0.3 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-cli-eslint is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
group
option of broccoli-lint-eslint
by default (#176)The new version differs by 50 commits0.
21be33a
3.1.0
67a0cc5
3.1.0-beta.2
5e256a0
Merge pull request #180 from Turbo87/auto-dist-tag
10465b0
CI: Use "auto-dist-tag" for deployment
2ea7d00
Merge pull request #171 from cibernox/update-to-latest-ember-cli-beta
56a3b48
Update to ember-cli 2.13
f6e86ba
3.1.0-beta.1
0ece8a2
Update CHANGELOG
1e8eeec
README: Add "Configuration" section
41962c4
Merge pull request #176 from Turbo87/group-option
4abd4c1
Use new "group" option by default
80d820a
Use new create() factory function
69e25b1
Adjust expected console output
a043763
Remove unused "js-string-escape" dependency
61fdfbc
Use built-in "broccoli-lint-eslint" test generators
There are 50 commits in total.
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Hi,
I installed ember-cookies
in a fresh project but got an error on run-time saying that lodash was not found in the cookies service. I had to manually add ember-lodash
to my project's devDependencies for it to work.
Thanks,
Jorge L
Branch | Build failing 🚨 |
---|---|
Dependency | ember-cli-babel |
Current Version | 5.2.2 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-cli-babel is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪
The new version differs by 3 commits .
8d5d130
5.2.3
ef7119b
Merge pull request #110 from babel/rwjblue-patch-1
a655d8a
Update minimum version of broccoli-babel-transpiler.
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | ember-cli-app-version |
Current Version | 2.0.1 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-cli-app-version is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
Branch | Build failing 🚨 |
---|---|
Dependency | ember-cli-shims |
Current Version | 1.0.2 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-cli-shims is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.
I recommend you give this issue a high priority. I’m sure you can resolve this 💪
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
I've been debugging an authentication issue in our app in FastBoot using ember-simple-auth
. Essentially, if you write more than one cookie in FastBoot, the FastBoot Express middleware will only return the last cookie, overwriting the previous cookie each time a new one is added. This particularly affects ember-simple-auth
, where if you set an expiration date on your auth cookie, the expiration cache cookie will overwrite your auth cookie, preventing proper authentication.
It's trivial to replicate by writing several cookies in FastBoot and checking the response. You should see a single set-cookie
header with the last cookie written.
I personally don't think ember-cookies
is doing anything wrong. The way FastBoot provides an API to append
headers vs the way it then sets them seems inconsistent. I've opened an issue with more info ember-fastboot/fastboot-express-middleware#33 to hopefully get some feedback on what the intended behaviour is.
A read/write-through cache is needed to mimic browser behavior in FastBoot so that cookies can be read after they have been written. That's not possible out of the box as in FastBoot, cookies are read from the request and written to the response so that cookies that have just been written cannot be read afterwards in the context of the same request.
In my production app RiskMap, we store a lot of cookie information. We like to store certain values in objects for the sake of tidiness, and because it's logical that all data stored in the same object should expire at the same time.
Currently, updating cookie objects is a multi-step process, parsing and stringifying back-and-forth:
let myCookie = this.get('cookies').read('my-cookie');
myCookie = Ember.Object(JSON.parse(myCookie));
myCookie.set('foo-bar', true);
myCookie = JSON.stringify(myCookie);
this.get('cookies').write('my-cookie', myCookie, { maxAge: defaultCookieMaxAge });
This is a pattern we use a lot at RiskMap, so I've extended Ember Cookies to make working with objects easier and more DRY. TL;DR, the above example becomes:
this.get('cookies').writeObjProperty('myCookie', 'fooBar', true);
@marcoow @Turbo87, I'd be interested to know whether you'd be interested in merging some of the following features into Ember Cookies:
A global way of serializing cookie name and property keys so camel cased attributes can be used in js, but cookie JSON stored in a consistent manner.
// config/environment.js
ENV['ember-cookies'] = {
serializer: 'dasherize'
}
Our user session is set to expire after 30 days. We want most of our other cookies to expire after that, too. The default value can be expressed either as defaultMaxAge
or defaultExpires
.
// config/environment.js
ENV['ember-cookies'] = {
defaultMaxAge: 60 * 60 * 24 * 30,
defaultExpires: 60 * 60 * 24 * 30
}
readObj
reads the cookie, automatically parses the object to JSON and asserts whether it is a valid object.
this.get('cookies').readObj('myCookie');
// returns Ember.Object instance || null
readObjProperty
returns the property value from the cookie object.
this.get('cookies').readObjProperty('myCookie', 'fooBar');
// => returns parsed value
Because all cookie objects are parsed into Ember Object instances, we can get deep property values using dot notation:
this.get('cookies').readObjProperty('myCookie', 'fooBaz.isGettable');
writeObj
asserts whether a POJO or Ember Object instance is passed and stringifies it as JSON before writing:
this.get('cookies').writeObj('myCookie', { fooBar: true }/*, options*/);
// "my-cookie" === { "foo-bar": true }
writeObjProperty
enables updating an individual property inside a cookie object:
this.get('cookies').writeObjProperty('myCookie', 'fooBar', false/*, options*/);
// "my-cookie" === { "foo-bar": false }
clearObj
is just an alias for clear
, for the sake of consistency.
this.get('cookies').clearObj('myCookie'/*, options*/);
// my-cookie === null
clearObjProperty
simply sets a property to null, before stringifying and writing.
this.get('cookies').clearObjProperty('myCookie', 'fooBar'/*, options*/);
// "my-cookie" === { }
With version 0.1.0 I get:
DEPRECATION: Addon files were detected in .../node_modules/ember-simple-auth/node_modules/ember-cookies/addon
, but no JavaScript preprocessors were found for ember-cookies
. Please make sure to add a preprocessor (most likely ember-cli-babel
) to in dependencies
(NOT devDependencies
) in ember-cookies
's package.json
.
Adding path=/
seems to fix the issue:
- document.cookie = `${cookieName}=; expires=${new Date(0).toUTCString()}`;
+ document.cookie = `${cookieName}=; expires=${new Date(0).toUTCString()};path=/`;
to release #49 into the wild.
The clear
method seems to be dropping any options, specifically path
, that are passed to it.
It does successfully set the expires
option and passes it on the write
method but, in my case, path
is not getting passed on to the write
method.
I am able to work around it by just calling the write
method and setting the expire
option as clear
does, and write
still accepts my desired path
; However, it would be desirable if clear
functioned as described in the documentation.
I have been having issues using the latest release, v0.4, inside an addon that is linked to another app.
Steps:
ember-cookies: 0.4
set as a dependency.yarn link
yarn link addon
ember s
in the app and get this error:Build Error (broccoli-persistent-filter:Babel > [Babel: ember-cookies]) in ember-cookies/clear-all-cookies.js
Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
What I think is happening is that another addon/dependency has Babel 6 declared as a dependency. This is causing the build to sometimes load Babel 6 and not Babel 7.
I ended up downgrading.
Any ideas what can be done?
Branch | Build failing 🚨 |
---|---|
Dependency | ember-cli-babel |
Current Version | 5.2.1 |
Type | dependency |
This version is covered by your current version range and after updating it in your project the build failed.
As ember-cli-babel is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪
The new version differs by 5 commits .
5526d86
5.2.2
cc9942a
Merge pull request #108 from babel/add-annotation
74c4723
Add more detailed annotation.
10dc1cd
Merge pull request #107 from twokul/patch-1
54db09a
Brocfile.js
-> ember-cli-build.js
See the full diff.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot 🌴
When a valid cookie is set that contains =
in the value it doesn't work. We discovered this issue because our session cookies always end in =.
document.cookie
shows that the cookie is in fact present, meanwhile…
cookies.exists('session')
returns false
cookies.read('session')
returns undefined
It looks like the issue is where it splits the cookies by "=" and asserts that the length is === 2.
https://github.com/simplabs/ember-cookies/blob/5f83b8486ee19da877cea5c164962ec33c725e5f/addon/services/cookies.js#L196
I'm not sure if there are other edge cases here, but one solution could be to use >= 2 instead. Alternatively you could manually assemble the key and value by doing something like unfilteredCookies.map(c => [c.slice(0, c.indexOf('=')), c.slice(c.indexOf('=') + 1)]).filter(...)
.
carhartl/jquery-cookie and js-cookie both provided a shortcut to expiration. If you provided expires: <Number>
, then it would assume an expiration of days. Would you be agreeable to this sort of feature in ember-cookies?
We could also enhance this significantly by supporting a String value specifying a duration and units. Maybe use the same characters as date formatting to specify units? ex: '3d'
or 50M
for 3 days or 50 minutes respectively
Thanks for the addon! Loving it and killing off a jquery plugin and bower dependency!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.