Working for some time with JSON Web Signature (JWS) I came to the conclusion that many developers do not understand what it is and how it works.

JSON Web Signature (JWS) represents content secured with digital signatures or Message Authentication Codes (MACs) using JSON-based data structures.

There are two defined serializations for JWSs: a compact (described in this article) and a JSON.

The compact serialised JWS is a string…

It is easy with node-jose library when you know how to do it.
It took me some time to learn, because this information is missing in the documentation. Luckily it was in tests.

The missing example (creates a JWT with an embedded ‘jwk’):

// {input} is a String
// {key} is from jwk keystore
jose.JWS.createSign(
{
fields: {
typ: 'JWT',
},
format: 'compact',
opts: { protect: false },
},
{
key,
reference: 'jwk', // MISSING in documentation
},
).update(input, 'utf-8')
.final()
.then((result) => {
// {result} is a JSON object -- JWT using the JSON General Serialization
});

I hope I saved you some time.

Today I would like to share small hint about how to get licenses from all packages, used in your javascript project. It’s very useful to make Bill Of Materials for your legal department.

Assuming you are using yarn (if no — start right now), go to your project directory and paste this command:

yarn licenses list

To get only licensees use (for yarn 1.7.x):

yarn licenses list | awk '/^├─/ {$1=""; print $0}'

That’s all folks. I hope you will find it handy.

In one of our projects we’ve decided to use Socket.io to handle webscockets and to use a Jest to write BDD/TDD tests. Simply because on frontend we are using Jest too. And we wanted to use one test framework in all project.

This has proven to be a challenge. We cannot find any working example. Documentation did not cover our use case.

So for all of you with this problem I’ve created a boilerplate. I hope it will save you a couple of hours.

Tomasz Zwierzchoń

IT Architect. FrontEnd Team Lead. #JavaScript on #IoT #UX #Vue.js Fan. I miss having free time, especially for dancing Tango.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store