🚀 DAY 4 OF LAUNCH WEEK:Introducing Socket Scanning for OpenVSX Extensions.Learn more →
Socket
Book a DemoInstallSign in
Socket

@postnord/uas-sdk

Package Overview
Dependencies
Maintainers
32
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@postnord/uas-sdk

An SDK to implement the APIs offered by User Authority Service

Source
npmnpm
Version
0.3.7
Version published
Maintainers
32
Created
Source

An SDK to interact with v2 of the User Authority service. Typescript-friendly.

Installation

npm i @postnord/uas-sdk

Usage

import UAS from '@postnord/uas-sdk'
const uasService = new UAS({ isStaging: !!process.env.IS_STAGING })

const run = async () => {
  // Call the getUser function with either an IAM accessToken, a Unified Login token or a JWT already issued by the UAS service

  const user = await uasService.getUser({ accessToken: '' } )
  // OR
  const user = await uasService.getUser({ jwtToken: '' } )
  // OR
  const user = await uasService.getUser({ unifiedLoginToken: '' } )

  if (!user) { /* is not a business user thus does not exist in UAS */ }


  // returns a boolean indicating whether the user has the specified authority on the specified customer number
  user.verifyUserAccess({ authorityNumber: '3', customerNumber: '20137458' }) 

  // verify that the user is a Postnord admin and has the authority specified in the argument
  user.verifyAdminAccess({ authorityNumber: '19' })

  // returns the unflattened view of the token object. See TS types.
  user.getDecodedToken() 

  // returns the full JWT string
  user.getSignedToken() 

  // returns a boolean indicating whether or not the issued JWT is expired
  user.isExpired() 

  // This will call UAS with the returned token to verify the signature
  await user.verifyTokenSignature() 

  // Organization utlity functions

  // returns an organizations object containing organization utility functions 
  const orgs = user.organizations()

  // return true if either of the organizations includes the given authority
  orgs.containAuthority('3')
  // return true if either of the organizations includes atleast one of given authorities
  orgs.containAnyAuthorities(['3','19'])
  // return true if all of the given authorities exists in either of the organizations
  orgs.containAllAuthorities(['3','19'])
}

API documentation

See accompanied types

Feature requests

Hit us up at the #customerportal-user Slack channel

FAQs

Package last updated on 11 Jan 2022

Did you know?

Socket

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.

Install

Related posts