@rapharacing/auth-utils
v0.0.3
Published
Auth Utils
Downloads
1
Readme
Rapha Auth Utilities
Auth Utils
Installation
yarn add @rapharacing/auth-utils
How to use
import * as utils from "@rapharacing/auth-utils";
import { getHeaders } from "@rapharacing/auth-utils";
License
Design tokens are freely distributable under the terms of the MIT license.
API
Table of Contents
- buildIAMPolicy
- getUserTokens
- setUserToken
- updateUserToken
- decodeJWT
- verifyJWT
- formatAuthorizationToken
- getHeaders
- authorizeUser
buildIAMPolicy
Returns an IAM policy document for a given user and resource.
Parameters
username
String usernameeffect
String allow / denyresource
String resource ARNcontext
Object response context
Returns Object policyDocument
getUserTokens
Returns tokens from key value store
Parameters
Returns Object tokens
setUserToken
Sets tokens in key value store by uid and client
Parameters
db
DynamoDB dbtable
String tableuid
String uidclient
String clientdata
Object data to set as the value in the store
updateUserToken
Updates a users tokens in the key value store
Parameters
db
DynamoDB dbtable
String tableuid
String uidclient
String clientdata
Object data to set as the value in the store
decodeJWT
Returns decoded user data from JWT
Parameters
Returns Object token
verifyJWT
Returns verified user data from JWT
Parameters
Returns Object token
formatAuthorizationToken
Formats the Authorization Token
Parameters
token
String jwt token
Returns String token
getHeaders
Get common headers depending on environment
Parameters
Returns Object headers
authorizeUser
Returns a boolean whether or not a user is allowed to call a particular method
Parameters
Returns Boolean