
Product
Introducing Socket Scanning for OpenVSX Extensions
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.
@ministryofjustice/fb-user
Advanced tools
Form Builder User Data Store, User File Store, and JSON Web Token Clients (for Node)
Base client for requests to endpoints which require a JSON Web Token for authentication.
// require the client class
const FBJWTClient = require('@ministryofjustice/fb-user/jwt/client')
// create a client instance
const jwtClient = new FBJWTClient(serviceSecret, serviceToken, serviceSlug, microserviceUrl, [errorClass])
serviceSecretA serviceSecret is required.
The constructor will throw an error if no serviceSecret is provided.
serviceTokenA serviceToken is required.
The constructor will throw an error if no serviceToken is provided.
serviceSlugA serviceSlug is required.
The constructor will throw an error if no serviceSlug is provided.
microserviceUrlA microserviceUrl is required.
The constructor will throw an error if no microserviceUrl is provided.
errorClassAn errorClass is optional.
// extend base class
class FBMyClient extends FBJWTClient {
constructor (serviceSecret, serviceToken, serviceSlug, microserviceUrl, myVar) {
super(serviceSecret, serviceToken, serviceSlug, microserviceUrl)
// do something with additional constructor argument
this.myVar = myVar
}
}
const myClient = new FBMyClient('service_secret', 'service_token', 'myservice', 'http://myservice', 'my var')
// extend base class with custom error
class FBAnotherClient extends FBJWTClient {
constructor (serviceSecret, serviceToken, serviceSlug, microserviceUrl) {
// create custom error class
class FBAnotherClientError extends FBJWTClient.prototype.ErrorClass {}
super(serviceSecret, serviceToken, serviceSlug, microserviceUrl, FBAnotherClientError)
}
}
generateAccessToken
Generate a JWT access token
createEndpointUrl
Create the URL for an endpoint
sendGet
Dispatch GET requests to an endpoint
sendPost
Dispatch POST requests to an endpoint
encrypt
Encrypt data with AES 256
decrypt
Decrypt data
encryptUserIdAndToken
Encrypt the user ID and token using the service secret
decryptUserIdAndToken
Decrypt the user ID and token using the service secret
handleRequestError
This function will be invoked with an error an argument when the transaction fails
createRequestOptions
Create request options, whether GET or POST
throwRequestError
This function can be invoked to throw request errors
Client for requests to datastore endpoints.
// load client
const FBUserDataStoreClient = require('@ministryofjustice/fb-user/datastore/client')
// initialise client
const userDataStoreClient = new FBUserDataStoreClient(serviceSecret, serviceToken, serviceSlug, userDataStoreUrl)
// fetch user data
const userData = await userDataStoreClient.getData(userId, userToken)
// store user data
await userDataStoreClient.setData(userId, userToken, userData)
Client for requests to filestore endpoints.
// load client
const FBUserFileStoreClient = require('@ministryofjustice/fb-user/filestore/client')
// initialise client
const userFileStoreClient = new FBUserFileStoreClient(serviceSecret, serviceToken, serviceSlug, userFileStoreUrl)
// fetch user file
const userFile = await userFileStoreClient.fetch(userId, userToken, fingerprint)
// userFile => { file }
// With the policy defined
const policy = { [max_size], [expires], [allowed_types] }
let uploadDetails
// Either
// store user file
uploadDetails = await userFileStoreClient.store(userId, userToken, file, policy)
// uploadDetails => { fingerpint, url, size, type, date }
// Or
// store user file from file path
uploadDetails = await userFileStoreClient.storeFromPath(userId, userToken, filePath, policy)
FAQs
Form Builder User Data Store, User File Store, and JSON Web Token Clients (for Node)
We found that @ministryofjustice/fb-user demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 12 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.

Product
Bringing supply chain security to the next generation of JavaScript package managers

Product
A safer, faster way to eliminate vulnerabilities without updating dependencies