Skip to content

Commit

Permalink
preparing v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasonny83 committed Jun 15, 2016
1 parent ba0f762 commit 44d7da2
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 77 deletions.
35 changes: 35 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# polymer-cookie Changelog

## 1.1.0 - 2016.06.15

* introducing Domain
* introducing HttpOnly
* path and domain set as optional values
* minor code refactoring and documentation update

## 1.0.4 - 2016.06.02

* minor code refactoring
* documentation updated
* cookie expiration time bug fixed when time is set to '-1'
* demo page introduced

## 1.0.3 - 2016.02.12

* autoSet implementation
* fixes createCookie
* removes encodeURIComponent
* fixes readCookie declaration
* documentation updated

## 0.1.2 - 2015.29.01

* Implemented reflectToAttribute capability

## 0.1.1 - 2015.07.01

* first stable version

## 0.1.0 - 2015.06.30

* initial commit
120 changes: 65 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# polymer-cookie

<img src="http://benschwarz.github.io/bower-badges/[email protected]" width="130" height="30">
> Cookie Web Component for Polymer 1.x
[![Bower version](https://badge.fury.io/bo/polymer-cookie.svg)](https://badge.fury.io/bo/polymer-cookie)

![](http://benschwarz.github.io/bower-badges/[email protected])

Cookie Web Component for Polymer 1.0

```html
Expand All @@ -29,49 +31,63 @@ Note: The `params` attribute must be double quoted JSON.

Add the library using the Javascript package manager [Bower](http://bower.io/):

```
bower install --save polymer-cookie
```shell
$ bower install --save polymer-cookie
```

Or clone this repository inside your project folder using Git:

```
git clone https://github.com/andreasonny83/polymer-cookie.git
```shell
$ git clone https://github.com/andreasonny83/polymer-cookie.git
```

## Properties

### name

Type: String

Default value: 'polymer-cookie'

Set the cookie name

### value

type: String

Default value: ''

The cookie value

### path

type: String
Default value: '/'

The cookie path
Default value: ''

The cookie path.

The path must be absolute.
If not specified, defaults to the current path of the current document location.

### domain

type: String

Default value: ''

The cookie domain
The cookie domain.

(e.g., 'example.com' or 'subdomain.example.com').
If not specified, defaults to the host portion of the current document location
(but not including subdomains). Contrary to earlier specifications,
leading dots in domain names are ignored. If a domain is specified,
subdomains are always included.

### time

type: Number

Default value: 1

The expiration time related to the 'format' value.
Expand All @@ -80,6 +96,7 @@ Set to -1 to never expire the cookie
### format

type: String

Default value: 'd'

The expiration format time
Expand All @@ -89,9 +106,28 @@ The expiration format time
* 'h' : hours
* 'd' : days

### secure

type: Boolean

Default value: false

Cookie to only be transmitted over secure protocol as https

### http-only

type: Boolean

Default value: false

The HTTPOnly cookie attribute can help to mitigate this attack by
preventing access to cookie value through Javascript. Read more about
[Cookies and Security](https://www.nczonline.net/blog/2009/05/12/cookies-and-security/).

### auto-set

type: Boolean

Default value: false

If set, creates the cookie as the element is rendered on the page without
Expand All @@ -103,7 +139,7 @@ the need of manually invoking createCookie

Write the cookie

```
```js
var cookie = Polymer.dom(document).querySelector('#user_cookie');
cookie.createCookie();
```
Expand All @@ -112,7 +148,7 @@ cookie.createCookie();

Read the cookie if any, and the returns its value

```
```js
var cookie = Polymer.dom(document).querySelector('#user_cookie');
var cookie_value = cookie.readCookie();
```
Expand All @@ -121,19 +157,19 @@ var cookie_value = cookie.readCookie();

Destroy the cookie

```
```js
var cookie = Polymer.dom(document).querySelector('#user_cookie');
cookie.eraseCookie();
```

## Rendering in a demo page

### Install Polymer CLI.
### Install Polymer CLI

Install the Polymer CLI to serve the demo locally with:

```
npm install -g polymer-cli
```shell
$ npm install -g polymer-cli
```

### Run the demo
Expand All @@ -142,8 +178,8 @@ To run the element demo:

Run polymer serve from the repo directory:

```
polymer serve
```shell
$ polymer serve
```

Then open localhost:8080/components/polymer-cookie/demo/ in your browser.
Expand All @@ -156,52 +192,26 @@ For more information about Polymer CLI have a look at the
A special thanks to [Cameron](https://github.com/cameronwp)
and [Pascal](https://github.com/MeTaNoV) for their contributions.

1. Fork it!
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -m 'Add some feature'`
3. Commit your changes: `git commit -m 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D
5. Submit a pull request :D

## Contributors

## License
A special thanks to our contributors:

[MIT License](https://github.com/andreasonny83/polymer-cookie/blob/master/LICENSE) © Andrea SonnY
* [@cameronwp](https://github.com/cameronwp)
* [@MeTaNoV](https://github.com/MeTaNoV)
* [@ymahnovskyy](https://github.com/ymahnovskyy)
* [@web-padawan](https://github.com/web-padawan)

## Changelog

### 1.0.4

* minor code refactoring
* documentation updated
* cookie expiration time bug fixed when time is set to '-1'
* demo page introduced

2016.06.02
Changelog available [here](https://github.com/andreasonny83/polymer-cookie/blob/master/CHANGELOG.md)

### 1.0.3

* autoSet implementation
* fixes createCookie
* removes encodeURIComponent
* fixes readCookie declaration
* documentation updated

2016.02.12

### 0.1.2

* Implemented reflectToAttribute capability

2015.29.01

### 0.1.1

* first stable version

2015.07.01

### 0.1.0

* initial commit
## License

2015.06.30
[MIT License](https://github.com/andreasonny83/polymer-cookie/blob/master/LICENSE)
© Andrea SonnY
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "polymer-cookie",
"version": "1.0.4",
"homepage": "https://github.com/andreasonny83/polymer-cookie",
"authors": [
"Andrea Sonny <[email protected]>"
],
"description": "Cookie Web Component for Polymer 1.0",
"description": "Cookie Web Component for Polymer 1.x",
"main": "polymer-cookie.html",
"keywords": [
"web-components",
"polymer"
"polymer",
"cookie"
],
"license": "MIT",
"ignore": [
Expand Down
18 changes: 6 additions & 12 deletions demo/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
<!doctype html>
<html>
<head>
<title>polymer-cookie demo page</title>
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script>
/*
window.Polymer = window.Polymer || {};
window.Polymer.dom = 'shadow';
*/
</script>
<link rel="import" href="../polymer-cookie.html">
</head>
<body>
Expand All @@ -16,13 +11,12 @@ <h1>polymer-cookie</h1>
id="test_cookie"
name="test_cookie"
value="hello world"
time="3"
auto-set
format="s">
time="10"
format="s"
auto-set>
</polymer-cookie>

<p>
Open your browser's code inspector to see the cookie status
</p>
<p>Open your browser's code inspector to see the cookie status.</p>
<p>This 'test_cookie' will expire in 10 seconds.</p>
</body>
</html>
26 changes: 19 additions & 7 deletions polymer-cookie.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
*/
path: {
type: String,
value: '/',
value: '',
reflectToAttribute: true
},

Expand Down Expand Up @@ -117,6 +117,17 @@
reflectToAttribute: true
},

/**
* HttpOnly
*
* @type [Boolean]
*/
httpOnly: {
type: Boolean,
value: false,
reflectToAttribute: true
},

/**
* Create the cookie automatically as the element is rendered on the DOM
* @type [Boolean]
Expand Down Expand Up @@ -160,14 +171,15 @@

expires = this.time === -1 ? FOREVER : date.toUTCString();

return (document.cookie = [
document.cookie = [
this.name, '=', this.value,
'; expires=' + expires,
this.path && '; path=' + this.path,
this.domain && "; domain=" + this.domain,
this.secure ? '; secure' : '',
';expires=' + expires,
!!this.path && ';path=' + this.path,
!!this.domain && ";domain=" + this.domain,
this.secure ? ';secure' : '',
this.httpOnly ? ';HttpOnly' : '',
';'
].join(''));
].join('');
},

/**
Expand Down

0 comments on commit 44d7da2

Please sign in to comment.