Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@adonisjs/encryption

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@adonisjs/encryption - npm Package Compare versions

Comparing version 3.0.7 to 4.0.0

2

build/adonis-typings/encryption.d.ts

@@ -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;
{
"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"
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc