-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from VeliovGroup/cordova-1
Cordova (v2.4.0) __Major Changes:__ - π¨βπ» `handler` option now called even if `auto` option is set to `false` - π·ββοΈ `Path=/` now is default `path` of all cookies - π¨βπ¬ Partly implemented suggested changes from #11 to provide support over Cordova platform, via `Access-Control-Allow-Credentials` and `Access-Control-Allow-Origin` headers and supplying XHR request with `withCredentials - true` option, thanks to @s-ol Other Changes: - π¨βπ» Overall security and stability enhancements - π·ββοΈ Add `onCookies` *Server* callback/hook triggered only when client invokes `.send()` method - π¦ Internal Meteor dependencies update
- Loading branch information
Showing
5 changed files
with
70 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,12 @@ | |
<img src="https://c5.patreon.com/external/logo/[email protected]" width="160"> | ||
</a> | ||
|
||
Isomorphic bulletproof cookie functions for *Client* and *Server*. | ||
Isomorphic and bulletproof πͺ cookies for `meteor.js` applications with support of *Client*, *Server*, *Browser*, *Cordova*, and other *Meteor*-supported environments. | ||
|
||
- π· __100% Tests coverage__; | ||
- π¦ No external dependencies, no `underscore`, no `jQuery`, no `Blaze`; | ||
- π₯ Works on both *Server* and *Client*; | ||
- π₯ Full support with same API on both *Server* and *Client* environments; | ||
- π± Support for *Cordova*, *Browser* and other Meteor's *Client* environments; | ||
- γοΈ With Unicode support for cookies' value; | ||
- π¨βπ» With `String`, `Array`, `Object`, and `Boolean` support as cookies' value; | ||
- βΏ IE support, thanks to [@derwok](https://github.com/derwok); | ||
|
@@ -37,7 +38,8 @@ __Server Usage Note:__ On a server Cookies implemented as a middleware. To get a | |
Create new instance of Cookies | ||
|
||
- `opts.auto` {*Boolean*} - [*Server*] Auto-bind in middleware as `req.Cookies`, by default `true` | ||
- `opts.handler` {*Function*} - [*Server*] Middleware function with one argument `cookies` as `Cookies` instance. See "Alternate Usage" section | ||
- `opts.handler` {*Function*} - [*Server*] Middleware function (e.g. hook/callback called within middleware pipeline) with single argument `cookies` as `Cookies` instance. See "Alternate Usage" section | ||
- `opts.onCookies` {*Function*} - [*Server*] Callback/hook triggered after `.send()` method called on *Client* and received by *Server*, called with single argument `cookies` as `Cookies` instance. __Note:__ this hook available only if `auto` option is `true` | ||
- `opts.TTL` {*Number*} - Default cookies expiration time (max-age) in milliseconds, by default - `session` (*no TTL*) | ||
- `opts.runOnServer` {*Boolean*} - Set to `false` to avoid server usage (by default - `true`) | ||
|
||
|
@@ -95,6 +97,7 @@ Send all current cookies to server | |
|
||
```js | ||
/* Both Client & Server */ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Cookies } from 'meteor/ostrio:cookies'; | ||
const cookies = new Cookies(); | ||
|
||
|
@@ -124,6 +127,8 @@ if (Meteor.isClient) { | |
|
||
/* Server */ | ||
if (Meteor.isServer) { | ||
const { WebApp } = require('meteor/webapp'); | ||
|
||
WebApp.connectHandlers.use((req, res, next) => { | ||
cookies = req.Cookies; | ||
|
||
|
@@ -157,6 +162,7 @@ if (Meteor.isServer) { | |
|
||
```js | ||
/* Both Client & Server */ | ||
import { Meteor } from 'meteor/meteor'; | ||
import { Cookies } from 'meteor/ostrio:cookies'; | ||
|
||
/* Client */ | ||
|
@@ -170,8 +176,10 @@ if (Meteor.isClient) { | |
|
||
/* Server */ | ||
if (Meteor.isServer) { | ||
const { WebApp } = require('meteor/webapp'); | ||
|
||
const cookie = new Cookies({ | ||
auto: false, // Do not bind as a middleware by default | ||
auto: false, // Do not bind as a middleware by default (recommended, but not required) | ||
handler(cookies) { | ||
cookies.set('gender', 'male'); //true | ||
cookies.get('gender'); //male | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters