Socket
Socket
Sign inDemoInstall

jose

Package Overview
Dependencies
Maintainers
1
Versions
210
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jose - npm Package Compare versions

Comparing version 1.11.0 to 1.12.0

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Change Log

# [1.12.0](https://github.com/panva/jose/compare/v1.11.0...v1.12.0) (2019-11-05)
### Features
* add JWS.verify encoding and parsing options ([6bb66d4](https://github.com/panva/jose/commit/6bb66d4f0b4c96f2da8ac5f14fda6bc4f53f2994))
# [1.11.0](https://github.com/panva/jose/compare/v1.10.2...v1.11.0) (2019-11-03)

@@ -7,0 +16,0 @@

14

lib/help/base64url.js

@@ -29,4 +29,4 @@ const { JOSEInvalidEncoding } = require('../errors')

const decode = (input) => {
return decodeToBuffer(input).toString('utf8')
const decode = (input, encoding = 'utf8') => {
return decodeToBuffer(input).toString(encoding)
}

@@ -38,12 +38,12 @@

},
decode: (input) => {
return JSON.parse(decode(input))
decode: (input, encoding = 'utf8') => {
return JSON.parse(decode(input, encoding))
}
}
b64uJSON.decode.try = (input) => {
b64uJSON.decode.try = (input, encoding = 'utf8') => {
try {
return b64uJSON.decode(input)
return b64uJSON.decode(input, encoding)
} catch (err) {
return decode(input)
return decode(input, encoding)
}

@@ -50,0 +50,0 @@ }

@@ -17,3 +17,3 @@ const base64url = require('../help/base64url')

*/
const jwsVerify = (skipDisjointCheck, serialization, jws, key, { crit = [], complete = false, algorithms } = {}) => {
const jwsVerify = (skipDisjointCheck, serialization, jws, key, { crit = [], complete = false, algorithms, parse = true, encoding = 'utf8' } = {}) => {
if (!(key instanceof Key) && !(key instanceof KeyStore)) {

@@ -108,3 +108,3 @@ throw new TypeError('key must be an instance of a key instantiated by JWK.asKey or a JWKS.KeyStore')

try {
return jwsVerify(true, serialization, jws, key, { crit, complete, algorithms: algorithms ? [...algorithms] : undefined })
return jwsVerify(true, serialization, jws, key, { crit, complete, encoding, parse, algorithms: algorithms ? [...algorithms] : undefined })
} catch (err) {

@@ -132,3 +132,7 @@ errs.push(err)

if (!combinedHeader.crit || !combinedHeader.crit.includes('b64') || combinedHeader.b64) {
payload = base64url.JSON.decode.try(payload)
if (parse) {
payload = base64url.JSON.decode.try(payload, encoding)
} else {
payload = base64url.decodeToBuffer(payload)
}
}

@@ -151,3 +155,3 @@

try {
return jwsVerify(false, 'flattened', { ...root, ...recipient }, key, { crit, complete, algorithms: algorithms ? [...algorithms] : undefined })
return jwsVerify(false, 'flattened', { ...root, ...recipient }, key, { crit, complete, encoding, parse, algorithms: algorithms ? [...algorithms] : undefined })
} catch (err) {

@@ -154,0 +158,0 @@ errs.push(err)

{
"name": "jose",
"version": "1.11.0",
"version": "1.12.0",
"description": "JSON Web Almost Everything - JWA, JWS, JWE, JWK, JWT, JWKS for Node.js with minimal dependencies",

@@ -5,0 +5,0 @@ "keywords": [

@@ -253,4 +253,6 @@ /// <reference types="node" />

interface VerifyOptions<komplet> {
interface VerifyOptions<komplet = false, parse = true> {
complete?: komplet;
parse?: parse;
encoding?: BufferEncoding;
crit?: string[];

@@ -260,4 +262,4 @@ algorithms?: string[];

interface completeVerification {
payload: string | object;
interface completeVerification<T> {
payload: T;
key: JWK.Key;

@@ -268,4 +270,6 @@ protected?: object;

function verify(jws: string | FlattenedJWS | GeneralJWS, key: JWK.Key | JWKS.KeyStore, options?: VerifyOptions<false>): string | object;
function verify(jws: string | FlattenedJWS | GeneralJWS, key: JWK.Key | JWKS.KeyStore, options?: VerifyOptions<true>): completeVerification;
function verify(jws: string | FlattenedJWS | GeneralJWS, key: JWK.Key | JWKS.KeyStore, options?: VerifyOptions): string | object;
function verify(jws: string | FlattenedJWS | GeneralJWS, key: JWK.Key | JWKS.KeyStore, options?: VerifyOptions<false, false>): Buffer;
function verify(jws: string | FlattenedJWS | GeneralJWS, key: JWK.Key | JWKS.KeyStore, options?: VerifyOptions<true>): completeVerification<string | object>;
function verify(jws: string | FlattenedJWS | GeneralJWS, key: JWK.Key | JWKS.KeyStore, options?: VerifyOptions<true, false>): completeVerification<Buffer>;
}

@@ -272,0 +276,0 @@

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