@ministryofjustice/fb-jwt-client-node
Advanced tools
Comparing version 0.0.11 to 0.0.12
@@ -43,3 +43,3 @@ const FBJWTClient = require('./fb-jwt-client') | ||
/** | ||
* Encrypt user ID and token using service token | ||
* Encrypt user ID and token using service secret | ||
* | ||
@@ -64,3 +64,3 @@ * Guaranteed to return the same value | ||
/** | ||
* Decrypt user ID and token using service token | ||
* Decrypt user ID and token using service secret | ||
* | ||
@@ -67,0 +67,0 @@ * @param {string} encryptedData |
{ | ||
"name": "@ministryofjustice/fb-jwt-client-node", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "Form Builder JSON Web Token Client (Node)", | ||
"main": "lib/fb-jwt-client.js", | ||
"main": "index.js", | ||
"repository": { | ||
@@ -7,0 +7,0 @@ "type": "git", |
@@ -15,25 +15,29 @@ # Form Builder JSON Web Token client (Node) | ||
### Loading and initialising | ||
### Loading and initialising basic client | ||
``` javascript | ||
// load client class | ||
const FBJWTClient = require('@ministryofjustice/fb-jwt-client-node') | ||
const {FBJWTClient} = require('@ministryofjustice/fb-jwt-client-node') | ||
// initialise client | ||
const jwtClient = new FBJWTClient(serviceToken, serviceUrl, [errorClass]) | ||
const jwtClient = new FBJWTClient(serviceToken, serviceSlug, microserviceUrl, [errorClass]) | ||
``` | ||
### `serviceToken` | ||
#### `serviceToken` | ||
Constructor will throw an error if no service token is passed | ||
### `serviceUrl` | ||
#### `serviceSlug` | ||
Constructor will throw an error if no service slug is passed | ||
#### `microserviceUrl` | ||
Constructor will throw an error if no service url is passed | ||
### `errorClass` | ||
#### `errorClass` | ||
By default, uses FB | ||
By default, uses FBJWTClientError | ||
## Extending | ||
### Extending | ||
@@ -43,4 +47,4 @@ ``` javascript | ||
class FBMyClient extends FBJWTClient { | ||
constructor (serviceToken, serviceUrl, myVar) { | ||
super(serviceToken) | ||
constructor (serviceToken, serviceSlug, microserviceUrl, myVar) { | ||
super(serviceToken, serviceSlug, microserviceUrl) | ||
// do something with additional constructor argument | ||
@@ -51,3 +55,3 @@ this.myVar = myVar | ||
const myClient = new FBMyClient('service token', 'http://myservice', 'my var') | ||
const myClient = new FBMyClient('service token', 'myservice', 'http://myservice', 'my var') | ||
``` | ||
@@ -58,7 +62,6 @@ | ||
class FBAnotherClient extends FBJWTClient { | ||
constructor (serviceToken, serviceUrl) { | ||
constructor (serviceToken, serviceSlug, microserviceUrl) { | ||
// create custom error class | ||
class FBAnotherClientError extends FBJWTClient.prototype.ErrorClass {} | ||
super(serviceToken, serviceUrl, FBAnotherClientError) | ||
super(serviceToken) | ||
super(serviceToken, serviceSlug, microserviceUrl, FBAnotherClientError) | ||
} | ||
@@ -68,3 +71,3 @@ } | ||
## Methods | ||
### Methods | ||
@@ -107,2 +110,24 @@ - generateAccessToken | ||
### Loading and initialising client with secret and associated methods | ||
``` javascript | ||
// load client class | ||
const {FBJWTClientWithSecret} = require('@ministryofjustice/fb-jwt-client-node') | ||
// initialise client | ||
const jwtClientWithSecret = new FBJWTClientWithSecret(serviceSecret, serviceToken, serviceSlug, microserviceUrl, [errorClass]) | ||
``` | ||
#### Methods | ||
- encryptUserIdAndToken | ||
Encrypt user ID and token using service secret | ||
- decryptUserIdAndToken | ||
Decrypt user ID and token using service secret | ||
## Further details | ||
See documentation in code for further details and `fb-user-datastore-client-node` and `fb-submitter-client-node` for examples. |
37142
12
937
127