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

did-jwt

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

did-jwt - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

lib/__tests__/__snapshots__/SimpleSigner-test.js.snap

6

lib/__tests__/SignerAlgorithm-test.js

@@ -31,2 +31,4 @@ 'use strict';

var _Digest = require('../Digest');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -128,3 +130,3 @@

expect(kp.verify((0, _SignerAlgorithm.sha256)('hello'), (0, _VerifierAlgorithm.toSignatureObject)(signature))).toBeTruthy();
expect(kp.verify((0, _Digest.sha256)('hello'), (0, _VerifierAlgorithm.toSignatureObject)(signature))).toBeTruthy();

@@ -213,3 +215,3 @@ case 4:

expect(kp.verify((0, _SignerAlgorithm.sha256)('hello'), (0, _VerifierAlgorithm.toSignatureObject)(signature, true))).toBeTruthy();
expect(kp.verify((0, _Digest.sha256)('hello'), (0, _VerifierAlgorithm.toSignatureObject)(signature, true))).toBeTruthy();

@@ -216,0 +218,0 @@ case 4:

@@ -19,7 +19,2 @@ 'use strict';

var signer = (0, _SimpleSigner2.default)(privateKey);
var signature = {
r: 'dd8369e9a435ce784dc2a881aef04851251133fc4d66aa74a951a780ee0b60f8',
s: '4eb3807bd179295aa65b18c4d9c34cc0fe026dc03bd9ecbdaeb1f1b0893befa7',
recoveryParam: 1
};
it('signs data', (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee() {

@@ -32,3 +27,3 @@ var plaintext;

plaintext = 'thequickbrownfoxjumpedoverthelazyprogrammer';
return _context.abrupt('return', expect(signer(plaintext)).resolves.toEqual(signature));
return _context.abrupt('return', expect(signer(plaintext)).resolves.toMatchSnapshot());

@@ -35,0 +30,0 @@ case 2:

@@ -17,4 +17,2 @@ 'use strict';

var _Digest = require('./Digest');
var _base64url = require('base64url');

@@ -52,3 +50,3 @@

_context.next = 2;
return signer((0, _Digest.sha256)(payload));
return signer(payload);

@@ -82,3 +80,2 @@ case 2:

}
SignerAlgorithm.sha256 = _Digest.sha256;
module.exports = SignerAlgorithm;

@@ -13,2 +13,4 @@ 'use strict';

var _Digest = require('./Digest');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -50,3 +52,3 @@

case 0:
_privateKey$sign = privateKey.sign(data), r = _privateKey$sign.r, s = _privateKey$sign.s, recoveryParam = _privateKey$sign.recoveryParam;
_privateKey$sign = privateKey.sign((0, _Digest.sha256)(data)), r = _privateKey$sign.r, s = _privateKey$sign.s, recoveryParam = _privateKey$sign.recoveryParam;
return _context.abrupt('return', {

@@ -53,0 +55,0 @@ r: leftpad(r.toString('hex')),

{
"name": "did-jwt",
"version": "0.0.6",
"version": "0.0.7",
"description": "Library for Signing and Verifying JWTs compatible uPort and DID standards",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -158,3 +158,3 @@ # did-jwt

```js
function mySigner (hash) {
function mySigner (data) {
return new Promise((resolve, reject) => {

@@ -171,3 +171,3 @@ const signature = /// sign it

---- | ----------- | --------
`hash` | [Buffer](https://nodejs.org/api/buffer.html) containing hash of data to be signed | yes
`data` | String or [Buffer](https://nodejs.org/api/buffer.html) containing data to be signed | yes

@@ -174,0 +174,0 @@ #### Promise Return Value

@@ -1,2 +0,2 @@

import SignerAlgorithm, { sha256 } from '../SignerAlgorithm'
import SignerAlgorithm from '../SignerAlgorithm'
import { toSignatureObject } from '../VerifierAlgorithm'

@@ -6,2 +6,3 @@ import SimpleSigner from '../SimpleSigner'

import { ec as EC } from 'elliptic'
import { sha256 } from '../Digest'
const secp256k1 = new EC('secp256k1')

@@ -8,0 +9,0 @@ const privateKey = '278a5de700e29faae8e40e366ec5012b5ec63d36ec77e8a241154cc1d25383f'

@@ -5,10 +5,5 @@ import SimpleSigner from '../SimpleSigner'

const signer = SimpleSigner(privateKey)
const signature = {
r: 'dd8369e9a435ce784dc2a881aef04851251133fc4d66aa74a951a780ee0b60f8',
s: '4eb3807bd179295aa65b18c4d9c34cc0fe026dc03bd9ecbdaeb1f1b0893befa7',
recoveryParam: 1
}
it('signs data', async () => {
const plaintext = 'thequickbrownfoxjumpedoverthelazyprogrammer'
return expect(signer(plaintext)).resolves.toEqual(signature)
return expect(signer(plaintext)).resolves.toMatchSnapshot()
})

@@ -1,2 +0,1 @@

import { sha256 } from './Digest'
import base64url from 'base64url'

@@ -17,3 +16,3 @@

return async function sign (payload, signer) {
const signature = await signer(sha256(payload))
const signature = await signer(payload)
return toJose(signature)

@@ -30,3 +29,2 @@ }

}
SignerAlgorithm.sha256 = sha256
module.exports = SignerAlgorithm
import { ec as EC } from 'elliptic'
import { sha256 } from './Digest'

@@ -26,3 +27,3 @@ const secp256k1 = new EC('secp256k1')

return async (data) => {
const {r, s, recoveryParam} = privateKey.sign(data)
const {r, s, recoveryParam} = privateKey.sign(sha256(data))
return {

@@ -29,0 +30,0 @@ r: leftpad(r.toString('hex')),

Sorry, the diff of this file is too big to display

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