@adonisjs/encryption
Advanced tools
Comparing version 3.0.7 to 4.0.0
@@ -6,3 +6,3 @@ /** | ||
declare module '@ioc:Adonis/Core/Encryption' { | ||
import { base64 } from '@poppinss/utils'; | ||
import { base64 } from '@poppinss/utils/build/helpers'; | ||
/** | ||
@@ -9,0 +9,0 @@ * Config accepted by the encryption |
@@ -20,3 +20,3 @@ "use strict"; | ||
this.app.container.singleton('Adonis/Core/Encryption', () => { | ||
const Config = this.app.container.use('Adonis/Core/Config'); | ||
const Config = this.app.container.resolveBinding('Adonis/Core/Config'); | ||
const { Encryption } = require('../src/Encryption'); | ||
@@ -23,0 +23,0 @@ return new Encryption({ secret: Config.get('app.appKey') }); |
/// <reference path="../../adonis-typings/encryption.d.ts" /> | ||
import { EncryptionContract, EncryptionOptions } from '@ioc:Adonis/Core/Encryption'; | ||
import { base64 as utilsBase64 } from '@poppinss/utils'; | ||
import { base64 as utilsBase64 } from '@poppinss/utils/build/helpers'; | ||
import { MessageVerifier } from '../MessageVerifier'; | ||
@@ -5,0 +5,0 @@ /** |
@@ -13,4 +13,5 @@ "use strict"; | ||
/// <reference path="../../adonis-typings/encryption.ts" /> | ||
const utils_1 = require("@poppinss/utils"); | ||
const crypto_1 = require("crypto"); | ||
const utils_1 = require("@poppinss/utils"); | ||
const helpers_1 = require("@poppinss/utils/build/helpers"); | ||
const Hmac_1 = require("../Hmac"); | ||
@@ -36,3 +37,3 @@ const MessageVerifier_1 = require("../MessageVerifier"); | ||
*/ | ||
this.base64 = utils_1.base64; | ||
this.base64 = helpers_1.base64; | ||
/** | ||
@@ -64,3 +65,3 @@ * The algorithm in use | ||
*/ | ||
const iv = utils_1.randomString(16); | ||
const iv = helpers_1.string.generateRandom(16); | ||
/** | ||
@@ -73,7 +74,7 @@ * Creating chiper | ||
*/ | ||
const encodedValue = new utils_1.MessageBuilder().build(value, expiresAt, purpose); | ||
const encodedValue = new helpers_1.MessageBuilder().build(value, expiresAt, purpose); | ||
/** | ||
* Set final to the cipher instance and encrypt it | ||
*/ | ||
const encrypted = Buffer.concat([cipher.update(encodedValue, 'utf8'), cipher.final()]); | ||
const encrypted = Buffer.concat([cipher.update(encodedValue, 'utf-8'), cipher.final()]); | ||
/** | ||
@@ -108,3 +109,3 @@ * Concatenate `encrypted value` and `iv` by urlEncoding them. The concatenation is required | ||
*/ | ||
const encrypted = this.base64.urlDecode(encryptedEncoded, 'binary'); | ||
const encrypted = this.base64.urlDecode(encryptedEncoded, 'base64'); | ||
if (!encrypted) { | ||
@@ -134,4 +135,4 @@ return null; | ||
const decipher = crypto_1.createDecipheriv(this.algorithm, this.cryptoKey, iv); | ||
const decrypted = decipher.update(encrypted, 'binary', 'utf8') + decipher.final('utf8'); | ||
return new utils_1.MessageBuilder().verify(decrypted, purpose); | ||
const decrypted = decipher.update(encrypted, 'base64', 'utf8') + decipher.final('utf8'); | ||
return new helpers_1.MessageBuilder().verify(decrypted, purpose); | ||
} | ||
@@ -138,0 +139,0 @@ catch (error) { |
@@ -13,3 +13,3 @@ "use strict"; | ||
const crypto_1 = require("crypto"); | ||
const utils_1 = require("@poppinss/utils"); | ||
const helpers_1 = require("@poppinss/utils/build/helpers"); | ||
/** | ||
@@ -27,3 +27,3 @@ * A generic class for generating SHA-256 Hmac for verifying the value | ||
generate(value) { | ||
return utils_1.base64.urlEncode(crypto_1.createHmac('sha256', this.key).update(value).digest()); | ||
return helpers_1.base64.urlEncode(crypto_1.createHmac('sha256', this.key).update(value).digest()); | ||
} | ||
@@ -34,5 +34,5 @@ /** | ||
compare(value, existingHmac) { | ||
return utils_1.safeEqual(this.generate(value), existingHmac); | ||
return helpers_1.safeEqual(this.generate(value), existingHmac); | ||
} | ||
} | ||
exports.Hmac = Hmac; |
@@ -15,2 +15,3 @@ "use strict"; | ||
const utils_1 = require("@poppinss/utils"); | ||
const helpers_1 = require("@poppinss/utils/build/helpers"); | ||
const Hmac_1 = require("../Hmac"); | ||
@@ -48,3 +49,3 @@ /** | ||
} | ||
const encoded = utils_1.base64.urlEncode(new utils_1.MessageBuilder().build(value, expiresAt, purpose)); | ||
const encoded = helpers_1.base64.urlEncode(new helpers_1.MessageBuilder().build(value, expiresAt, purpose)); | ||
return `${encoded}${this.separator}${new Hmac_1.Hmac(this.cryptoKey).generate(encoded)}`; | ||
@@ -69,3 +70,3 @@ } | ||
*/ | ||
const decoded = utils_1.base64.urlDecode(encoded); | ||
const decoded = helpers_1.base64.urlDecode(encoded); | ||
if (!decoded) { | ||
@@ -75,5 +76,5 @@ return null; | ||
const isValid = new Hmac_1.Hmac(this.cryptoKey).compare(encoded, hash); | ||
return isValid ? new utils_1.MessageBuilder().verify(decoded, purpose) : null; | ||
return isValid ? new helpers_1.MessageBuilder().verify(decoded, purpose) : null; | ||
} | ||
} | ||
exports.MessageVerifier = MessageVerifier; |
194
package.json
{ | ||
"name": "@adonisjs/encryption", | ||
"version": "3.0.7", | ||
"description": "Encryption provider for AdonisJs", | ||
"main": "build/providers/EncryptionProvider.js", | ||
"files": [ | ||
"build/adonis-typings", | ||
"build/providers", | ||
"build/src", | ||
"build/standalone.d.ts", | ||
"build/standalone.js", | ||
"build/exceptions.json" | ||
], | ||
"scripts": { | ||
"mrm": "mrm --preset=@adonisjs/mrm-preset", | ||
"pretest": "npm run lint", | ||
"test": "node japaFile.js", | ||
"clean": "del build", | ||
"compile": "npm run lint && npm run clean && tsc", | ||
"build": "npm run compile", | ||
"commit": "git-cz", | ||
"release": "np", | ||
"version": "npm run build", | ||
"format": "prettier --write .", | ||
"prepublishOnly": "npm run build", | ||
"lint": "eslint . --ext=.ts", | ||
"sync-labels": "github-label-sync --labels ./node_modules/@adonisjs/mrm-preset/gh-labels.json adonisjs/encryption" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/adonisjs/encryption.git" | ||
}, | ||
"keywords": [ | ||
"encryption" | ||
], | ||
"author": "virk,adonisjs", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/adonisjs/encryption/issues" | ||
}, | ||
"homepage": "https://github.com/adonisjs/encryption#readme", | ||
"devDependencies": { | ||
"@adonisjs/application": "^3.0.21", | ||
"@adonisjs/mrm-preset": "^2.4.0", | ||
"@adonisjs/require-ts": "^1.1.0", | ||
"@poppinss/dev-utils": "^1.0.11", | ||
"@types/node": "^14.14.9", | ||
"commitizen": "^4.2.2", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"del-cli": "^3.0.1", | ||
"eslint": "^7.14.0", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-adonis": "^1.0.15", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"github-label-sync": "^2.0.0", | ||
"husky": "^4.3.0", | ||
"japa": "^3.1.1", | ||
"mrm": "^2.5.12", | ||
"np": "^7.0.0", | ||
"npm-audit-html": "^1.5.0", | ||
"prettier": "^2.2.0", | ||
"typescript": "^4.1.2" | ||
}, | ||
"nyc": { | ||
"exclude": [ | ||
"test" | ||
], | ||
"extension": [ | ||
".ts" | ||
] | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "npm audit --production --json | ./node_modules/.bin/npm-audit-html && git add npm-audit.html", | ||
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js" | ||
} | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "cz-conventional-changelog" | ||
} | ||
}, | ||
"dependencies": { | ||
"@poppinss/utils": "^2.5.9" | ||
}, | ||
"peerDependencies": { | ||
"@adonisjs/application": "^3.0.0" | ||
}, | ||
"np": { | ||
"contents": ".", | ||
"anyBranch": false | ||
}, | ||
"adonisjs": { | ||
"exceptions": "./build/exceptions.json" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"tag": "latest" | ||
} | ||
"name": "@adonisjs/encryption", | ||
"version": "4.0.0", | ||
"description": "Encryption provider for AdonisJs", | ||
"main": "build/providers/EncryptionProvider.js", | ||
"files": [ | ||
"build/adonis-typings", | ||
"build/providers", | ||
"build/src", | ||
"build/standalone.d.ts", | ||
"build/standalone.js", | ||
"build/exceptions.json" | ||
], | ||
"scripts": { | ||
"mrm": "mrm --preset=@adonisjs/mrm-preset", | ||
"pretest": "npm run lint", | ||
"test": "node japaFile.js", | ||
"clean": "del build", | ||
"compile": "npm run lint && npm run clean && tsc", | ||
"build": "npm run compile", | ||
"commit": "git-cz", | ||
"release": "np", | ||
"version": "npm run build", | ||
"format": "prettier --write .", | ||
"prepublishOnly": "npm run build", | ||
"lint": "eslint . --ext=.ts", | ||
"sync-labels": "github-label-sync --labels ./node_modules/@adonisjs/mrm-preset/gh-labels.json adonisjs/encryption" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/adonisjs/encryption.git" | ||
}, | ||
"keywords": [ | ||
"encryption" | ||
], | ||
"author": "virk,adonisjs", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/adonisjs/encryption/issues" | ||
}, | ||
"homepage": "https://github.com/adonisjs/encryption#readme", | ||
"devDependencies": { | ||
"@adonisjs/application": "^4.0.2", | ||
"@adonisjs/mrm-preset": "^3.0.0", | ||
"@adonisjs/require-ts": "^2.0.2", | ||
"@poppinss/dev-utils": "^1.1.0", | ||
"@types/node": "^14.14.25", | ||
"commitizen": "^4.2.3", | ||
"cz-conventional-changelog": "^3.3.0", | ||
"del-cli": "^3.0.1", | ||
"eslint": "^7.19.0", | ||
"eslint-config-prettier": "^7.2.0", | ||
"eslint-plugin-adonis": "^1.2.0", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"github-label-sync": "^2.0.0", | ||
"husky": "^5.0.9", | ||
"japa": "^3.1.1", | ||
"mrm": "^2.5.18", | ||
"np": "^7.3.0", | ||
"prettier": "^2.2.1", | ||
"typescript": "^4.1.4" | ||
}, | ||
"nyc": { | ||
"exclude": [ | ||
"test" | ||
], | ||
"extension": [ | ||
".ts" | ||
] | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "node ./node_modules/@adonisjs/mrm-preset/validateCommit/conventional/validate.js" | ||
} | ||
}, | ||
"config": { | ||
"commitizen": { | ||
"path": "cz-conventional-changelog" | ||
} | ||
}, | ||
"dependencies": { | ||
"@poppinss/utils": "^3.0.2" | ||
}, | ||
"peerDependencies": { | ||
"@adonisjs/application": "^4.0.0" | ||
}, | ||
"np": { | ||
"contents": ".", | ||
"anyBranch": false | ||
}, | ||
"adonisjs": { | ||
"exceptions": "./build/exceptions.json" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"tag": "latest" | ||
} | ||
} |
@@ -16,3 +16,3 @@ <div align="center"> | ||
[![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] [![audit-report-image]][audit-report-url] | ||
[![circleci-image]][circleci-url] [![npm-image]][npm-url] ![][typescript-image] [![license-image]][license-url] [![synk-image]][synk-url] | ||
@@ -53,3 +53,3 @@ </div> | ||
[audit-report-image]: https://img.shields.io/badge/-Audit%20Report-blueviolet?style=for-the-badge | ||
[audit-report-url]: https://htmlpreview.github.io/?https://github.com/adonisjs/encryption/blob/develop/npm-audit.html "audit-report" | ||
[synk-image]: https://img.shields.io/snyk/vulnerabilities/github/adonisjs/encryption?label=Synk%20Vulnerabilities&style=for-the-badge | ||
[synk-url]: https://snyk.io/test/github/adonisjs/encryption?targetFile=package.json "synk" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26532
19
593
+ Added@adonisjs/application@4.0.4(transitive)
+ Added@adonisjs/config@3.0.9(transitive)
+ Added@adonisjs/env@3.0.9(transitive)
+ Added@adonisjs/fold@8.2.0(transitive)
+ Added@adonisjs/logger@4.1.6(transitive)
+ Added@adonisjs/profiler@6.0.9(transitive)
+ Added@poppinss/file-generator@1.0.2(transitive)
+ Added@poppinss/utils@3.3.14.0.45.0.0(transitive)
+ Added@types/bytes@3.1.4(transitive)
+ Added@types/he@1.2.3(transitive)
+ Addedbytes@3.1.2(transitive)
+ Addedcamel-case@4.1.2(transitive)
+ Addedcapital-case@1.0.4(transitive)
+ Addedchange-case@4.1.2(transitive)
+ Addedconstant-case@3.0.4(transitive)
+ Addeddot-case@3.0.4(transitive)
+ Addeddotenv@16.4.5(transitive)
+ Addedflattie@1.1.1(transitive)
+ Addedhe@1.2.0(transitive)
+ Addedheader-case@2.0.4(transitive)
+ Addedjest-worker@27.5.1(transitive)
+ Addedkind-of@6.0.3(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlower-case@2.0.2(transitive)
+ Addedno-case@3.0.4(transitive)
+ Addedparam-case@3.0.4(transitive)
+ Addedpascal-case@3.1.2(transitive)
+ Addedpath-case@3.0.4(transitive)
+ Addedpluralize@8.0.0(transitive)
+ Addedsentence-case@3.0.4(transitive)
+ Addedslugify@1.6.6(transitive)
+ Addedsnake-case@3.0.4(transitive)
+ Addedsupports-color@8.1.1(transitive)
+ Addedtruncatise@0.0.8(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedupper-case@2.0.2(transitive)
+ Addedupper-case-first@2.0.2(transitive)
- Removed@adonisjs/application@3.0.21(transitive)
- Removed@adonisjs/config@2.0.3(transitive)
- Removed@adonisjs/env@2.0.9(transitive)
- Removed@adonisjs/fold@7.0.9(transitive)
- Removed@adonisjs/logger@3.0.4(transitive)
- Removed@adonisjs/profiler@5.0.4(transitive)
- Removed@poppinss/utils@2.5.10(transitive)
- Removeddotenv@8.6.0(transitive)
- Removedjest-worker@26.6.2(transitive)
- Removedklona@2.0.6(transitive)
- Removedsupports-color@7.2.0(transitive)
Updated@poppinss/utils@^3.0.2