Skip to content

Commit

Permalink
chore: release v0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ayZagen committed Sep 20, 2021
1 parent 703af9a commit 67f4c33
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 59 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
## [0.0.2](https://github.com/ayZagen/secure-cookie/compare/v0.0.1...v0.0.2) (2021-09-20)


### Bug Fixes

* padding ignored for encryption without iv ([703af9a](https://github.com/ayZagen/secure-cookie/commit/703af9aa9e2aaa5d5df96a832a2360e4c3a738fd))

## 0.0.1 (2021-09-20)

21 changes: 12 additions & 9 deletions dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* secure-cookie v0.0.1
* secure-cookie v0.0.2
* (c) Ismail H. Ayaz
* Released under the MIT License.
*/
Expand Down Expand Up @@ -233,10 +233,12 @@ var KeyStore = /** @class */ (function () {
if (typeof authTag === "string") {
authTag = Buffer.from(authTag, encoding);
}
if (!iv) {
iv = dataBuff.slice(0, cipherInfo.ivLength);
if (cipherInfo.ivLength !== undefined) {
if (!iv) {
iv = dataBuff.slice(0, cipherInfo.ivLength);
}
dataBuff = dataBuff.slice(cipherInfo.ivLength, dataBuff.length);
}
dataBuff = dataBuff.slice(cipherInfo.ivLength, dataBuff.length);
if (AUTH_TAG_REQUIRED.test(algorithm)) {
if (!authTag) {
authTag = dataBuff.slice(0, authTagLength);
Expand All @@ -252,19 +254,20 @@ var KeyStore = /** @class */ (function () {
};
KeyStore.doDecrypt = function (data, options) {
var algorithm = options.algorithm, key = options.key, iv = options.iv, authTagLength = options.authTagLength, authTag = options.authTag;
var decipher = crypto__default['default'].createDecipheriv(algorithm, key, iv, { authTagLength: authTagLength });
var decipher = crypto__default['default'].createDecipheriv(algorithm, key, iv || null, { authTagLength: authTagLength });
if (authTag) {
decipher.setAuthTag(authTag);
}
var plainText = decipher.update(data);
var final;
try {
decipher.final();
final = decipher.final();
}
catch (_a) {
catch (e) {
// authentication failed
return null;
}
return plainText.toString('utf-8');
return Buffer.concat([plainText, final]).toString('utf-8');
};
KeyStore.prototype.sign = function (data, key) {
if (!data) {
Expand Down Expand Up @@ -380,8 +383,8 @@ var Cookies = /** @class */ (function () {
}
var cookie = new Cookie(name, value, opts);
var signed = opts && opts.signed !== undefined ? opts.signed : this.signed;
/* istanbul ignore next */
if (typeof headers == 'string') {
/* istanbul ignore next */
headers = [headers];
}
if (!secure && opts && opts.secure) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.cjs.map

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions dist/index.esm.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.esm.js.map

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions dist/index.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* secure-cookie v0.0.1
* secure-cookie v0.0.2
* (c) Ismail H. Ayaz
* Released under the MIT License.
*/
Expand Down Expand Up @@ -223,10 +223,12 @@ var KeyStore = /** @class */ (function () {
if (typeof authTag === "string") {
authTag = Buffer.from(authTag, encoding);
}
if (!iv) {
iv = dataBuff.slice(0, cipherInfo.ivLength);
if (cipherInfo.ivLength !== undefined) {
if (!iv) {
iv = dataBuff.slice(0, cipherInfo.ivLength);
}
dataBuff = dataBuff.slice(cipherInfo.ivLength, dataBuff.length);
}
dataBuff = dataBuff.slice(cipherInfo.ivLength, dataBuff.length);
if (AUTH_TAG_REQUIRED.test(algorithm)) {
if (!authTag) {
authTag = dataBuff.slice(0, authTagLength);
Expand All @@ -242,19 +244,20 @@ var KeyStore = /** @class */ (function () {
};
KeyStore.doDecrypt = function (data, options) {
var algorithm = options.algorithm, key = options.key, iv = options.iv, authTagLength = options.authTagLength, authTag = options.authTag;
var decipher = crypto.createDecipheriv(algorithm, key, iv, { authTagLength: authTagLength });
var decipher = crypto.createDecipheriv(algorithm, key, iv || null, { authTagLength: authTagLength });
if (authTag) {
decipher.setAuthTag(authTag);
}
var plainText = decipher.update(data);
var final;
try {
decipher.final();
final = decipher.final();
}
catch (_a) {
catch (e) {
// authentication failed
return null;
}
return plainText.toString('utf-8');
return Buffer.concat([plainText, final]).toString('utf-8');
};
KeyStore.prototype.sign = function (data, key) {
if (!data) {
Expand Down Expand Up @@ -370,8 +373,8 @@ var Cookies = /** @class */ (function () {
}
var cookie = new Cookie(name, value, opts);
var signed = opts && opts.signed !== undefined ? opts.signed : this.signed;
/* istanbul ignore next */
if (typeof headers == 'string') {
/* istanbul ignore next */
headers = [headers];
}
if (!secure && opts && opts.secure) {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ secure-cookie

#### Defined in

[cookies.ts:8](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L8)
[cookies.ts:8](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L8)

___

Expand All @@ -42,7 +42,7 @@ ___

#### Defined in

[cookies.ts:39](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L39)
[cookies.ts:39](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L39)

___

Expand All @@ -52,4 +52,4 @@ ___

#### Defined in

[cookies.ts:38](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L38)
[cookies.ts:38](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L38)
28 changes: 14 additions & 14 deletions docs/classes/Cookies.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

#### Defined in

[cookies.ts:56](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L56)
[cookies.ts:56](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L56)

## Properties

Expand All @@ -53,7 +53,7 @@

#### Defined in

[cookies.ts:45](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L45)
[cookies.ts:45](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L45)

___

Expand All @@ -63,7 +63,7 @@ ___

#### Defined in

[cookies.ts:49](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L49)
[cookies.ts:49](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L49)

___

Expand All @@ -73,7 +73,7 @@ ___

#### Defined in

[cookies.ts:53](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L53)
[cookies.ts:53](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L53)

___

Expand All @@ -83,7 +83,7 @@ ___

#### Defined in

[cookies.ts:54](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L54)
[cookies.ts:54](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L54)

___

Expand All @@ -93,7 +93,7 @@ ___

#### Defined in

[cookies.ts:43](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L43)
[cookies.ts:43](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L43)

___

Expand All @@ -103,7 +103,7 @@ ___

#### Defined in

[cookies.ts:51](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L51)
[cookies.ts:51](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L51)

___

Expand All @@ -113,7 +113,7 @@ ___

#### Defined in

[cookies.ts:47](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L47)
[cookies.ts:47](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L47)

___

Expand Down Expand Up @@ -151,7 +151,7 @@ ___

#### Defined in

[cookies.ts:185](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L185)
[cookies.ts:185](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L185)

___

Expand Down Expand Up @@ -189,7 +189,7 @@ ___

#### Defined in

[cookies.ts:186](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L186)
[cookies.ts:186](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L186)

## Methods

Expand Down Expand Up @@ -227,7 +227,7 @@ If both `signed` and `encrypted` options are provided, signature check will be a

#### Defined in

[cookies.ts:87](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L87)
[cookies.ts:87](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L87)

___

Expand All @@ -251,7 +251,7 @@ This sets the given cookie in the response and returns the current context to al

#### Defined in

[cookies.ts:136](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L136)
[cookies.ts:136](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L136)

___

Expand Down Expand Up @@ -284,7 +284,7 @@ ___

#### Defined in

[cookies.ts:187](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L187)
[cookies.ts:187](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L187)

___

Expand Down Expand Up @@ -318,4 +318,4 @@ ___

#### Defined in

[cookies.ts:180](https://github.com/ayZagen/secure-cookie/blob/bb7d3ba/src/cookies.ts#L180)
[cookies.ts:180](https://github.com/ayZagen/secure-cookie/blob/703af9a/src/cookies.ts#L180)
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 67f4c33

Please sign in to comment.