@octoguide/auth-utils

<dl> <dt><a href="#isAuthenticated">isAuthenticated</a></dt> <dd><p>check if the session user is authenticated</p> </dd> <dt><a href="#setStorageItem">setStorageItem</a></dt> <dd><p>generic set storage item - works in a dom context</p> </dd> <dt><a href="

Usage no npm install needed!

<script type="module">
  import octoguideAuthUtils from 'https://cdn.skypack.dev/@octoguide/auth-utils';
</script>

README

Constants

isAuthenticated

check if the session user is authenticated

setStorageItem

generic set storage item - works in a dom context

getStorageItem

generic get storage item - works in a dom context

removeStorageItem

generic remove storage item - works in a dom context

getAuth

get the auth storage item value - works in a dom context

setAuth

set the auth item in storage - works in a dom context

setIdentity

set the identity item in storage - works in a dom context

getIdentityRole

get the identity item role value - works in a dom context

getIdentityId

get the identity item id value - works in a dom context

getIdentityOrgId

get the identity item orgid value - works in a dom context

getIdentityName

get the identity item role name - works in a dom context

getSelectedPortfolio

get the identity item portfolio value - works in a dom context

invalidateSession

clear all session values, big reset - works in a dom context

isTokenExpired

checks if the token has expired checking against the current datetime

extractTokenId

when the id is returned from post requests - extract the id to put back into the payload

isSuperUser

checks if the current identity role is super user

isAdmin

checks if the current identity role is admin

isOrg

checks if the current identity id is the organaisation - not an employee

getRoleName

gets the current identity role

generateGuid

generate a unique record uid

getBasicAuthorizationHeader

generate a basic auth header

isAuthenticated

check if the session user is authenticated

Kind: global constant

setStorageItem

generic set storage item - works in a dom context

Kind: global constant

Param Type Description
item string the storage item to set
value string the storage item value

getStorageItem

generic get storage item - works in a dom context

Kind: global constant

Param Type Description
item string the storage item to get

removeStorageItem

generic remove storage item - works in a dom context

Kind: global constant

Param Type Description
item string the storage item to remove

getAuth

get the auth storage item value - works in a dom context

Kind: global constant

setAuth

set the auth item in storage - works in a dom context

Kind: global constant

Param Type Description
auth Object the storage object to set

setIdentity

set the identity item in storage - works in a dom context

Kind: global constant

Param Type Description
identity Object the storage object to set

getIdentityRole

get the identity item role value - works in a dom context

Kind: global constant

getIdentityId

get the identity item id value - works in a dom context

Kind: global constant

getIdentityOrgId

get the identity item orgid value - works in a dom context

Kind: global constant

getIdentityName

get the identity item role name - works in a dom context

Kind: global constant

getSelectedPortfolio

get the identity item portfolio value - works in a dom context

Kind: global constant

invalidateSession

clear all session values, big reset - works in a dom context

Kind: global constant

isTokenExpired

checks if the token has expired checking against the current datetime

Kind: global constant

Param Type Description
token Object the token to validate

extractTokenId

when the id is returned from post requests - extract the id to put back into the payload

Kind: global constant

isSuperUser

checks if the current identity role is super user

Kind: global constant

isAdmin

checks if the current identity role is admin

Kind: global constant

isOrg

checks if the current identity id is the organaisation - not an employee

Kind: global constant

getRoleName

gets the current identity role

Kind: global constant

generateGuid

generate a unique record uid

Kind: global constant

getBasicAuthorizationHeader

generate a basic auth header

Kind: global constant

Param Type Description
username string the username to use
password string the password to use