npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@userdocks/nodejs-server-sdk

v0.3.0

Published

The Node.js server SDK for userdocks. Verify access and id tokens on your server.

Downloads

9

Readme

@userdocks/nodejs-server-sdk

npm GitHub Workflow Status Coveralls branch NPM

The Node.js server SDK for userdocks. Verify access and id tokens on your server.

Table of Contents

Install

npm i @userdocks/nodejs-server-sdk

Methods

Documentation of all the functions and methods this SDK exposes.

getUserdocks

This method returns an object (TUserdocks) that exposes the verify method.

Syntax

Returns a new object.

const userdocks = getUserdocks(options);

Parameters

  • options <object>: an object holding two key value pairs
    • app <object>: an object holding three key value pairs
      • publicKey <string | undefined>: the publicKey of the userdocks application, if already cached on the server (optional)
      • readOnlyApiKey <string>: the read only api key of the userdocks application (required)
      • id <string>: the UUID of the userdocks application (required)
    • authServer <object | undefined>: an object holding three key value pairs (optional)
      • id <string | undefined>: the UUID of the authentication server (optional)
      • apiUri <string | undefined>: the api uri of the authetication server (optional)
      • publicKeyPath <string | undefined>: the pathname to the publicKey ressource on the authetication server (optional)

Return Value

  • userdocks <object>: an object holding one key value pair
    • verify <function>: a method that returns a promise that should resolve a boolean

userdocks.verify

Returns a promise that should resolve a new boolean indicating if a token is valid or not.

Syntax

Returns a promise that should resolve a new boolean.

const userdocks = getUserdocks(options);

const payload = await userdocks.verify(token, tokenType);

Parameters:

  • token <string>: the JSON Web Token you want to verify
  • tokenType <"access" | "id">: the type of the token as string

Return Value:

  • payload: a promise that should resolve the payload of the token including a boolean value valid indicating if the provided token is valid or not

Usage

import getUserdocks from '@userdocks/nodejs-server-sdk';

const token = '<a-json-web-token>';

const userdocks = getUserdocks({
  app: {
    readOnlyApiKey: '<a-read-only-api-key-of-an-userdocks-application>',
    id: '<a-uuid-of-an-userdocks-application>',
  },
});

const payload = await userdocks.verify(token, 'access');

Usage for Development

Start the watcher and link the package locally:

npm run watch
npm run link

Link the package in the project where it will be used:

# if you run "npm i" in your project you need to re-run this command
npm link @userdocks/nodejs-server-sdk

To use this module with typescript and with npm link add the follwing to your tsconfig.json:

{
  "compilerOptions": {
    "paths": {
      "@userdocks/nodejs-server-sdk": [
        "./node_modules/@userdocks/nodejs-server-sdk"
      ]
    }
  }
}