## OauthStorageKeys Oauth Storage Keys ## AccessTokenKey Type: [String][1] ## RefreshTokenKey Type: [String][1] ## AccessScopeKey Type: [String][1] ## TokenTypeKey Type: [String][1] ## ExpiresInKey Type: [String][1] ## CurrentStateKey Type: [String][1] ## OauthStorage OAuth Default Storage * localstorage for persistant storage * sessionstorage for temporary storage ## OauthUtils Common Utils Functions ### parseJWT Check if token is a JWT token and return claims if so #### Parameters * `token` **[String][1]** * `type` **[String][1]** "header" | "claims" | "signature". Default "claims" (optional, default `'claims'`) Returns **[String][1]** ### hasJWTExpired Check if JWT Token has expired #### Parameters * `token` **[String][1]** Returns **[boolean][2]** ### hasExpired Check given timestamp has expired #### Parameters * `exp` **[Number][3]** * `buffer` **[Number][3]** Buffer time in seconds to account for any unexpected delays e.g network latency (optional, default `5`) Returns **[boolean][2]** ### safeString Get a safe form of string to store, eliminating null and 'undefined' #### Parameters * `item` **[String][1]** Returns **[String][1]** ### safeInt Get a safe form of stIntring to store, eliminating null and 'undefined' #### Parameters * `item` **[Number][3]** Returns **[Number][3]** ### assertAvailable Check if item is nut null, undefined or empty eliminating null and 'undefined' #### Parameters * `item` **any** Returns **[boolean][2]** ### count Count Object array #### Parameters * `obj` **[Object][4]** Returns **[Number][3]** ### mergeObj Merge Object with another #### Parameters * `obj` **[Object][4]** * `src` **[Object][4]** Returns **[Object][4]** ### urlEncodeObject Encode Object content to url string #### Parameters * `myData` **[Object][4]** Object Returns **[String][1]** ### parseJson Parse Json string to object #### Parameters * `json` **[String][1]** string Returns **any** ### getUrlParam Get Url param \#source [http://www.netlobo.com/url_query_string_javascript.html][5] #### Parameters * `name` **[String][1]** * `url` **[String][1]** Returns **[String][1]** ### stripUrlParams Return url without it's url parameters #### Parameters * `url` **[String][1]** Url to strip Returns **[String][1]** ### generateKey Generate Random value #### Parameters * `length` **[Number][3]** Returns **[String][1]** ## constructor ### Parameters * `data` **[Object][4]** * `data.clientId` **[String][1]** Your Application's Client ID * `data.clientSecret` **[String][1]** Your Application's Client Secret * `data.authorizeUrl` **[String][1]** \[GET] Url endpoint to authorize or request access * `data.tokenUrl` **[String][1]** Url endpoint to obtain token * `data.verifyTokenUrl` **[String][1]** \[GET] Url endpoint to verify token * `data.storage` **OauthStorageInterface<[string][1]>** Handle custom storage - Default storage = browser localStorage or sessionStorage ## saveAccess Save Access data to Local storage ### Parameters * `accessData` **[OauthTokenResponse][6]** ## clearAccess Clear all access data from session ## authorizeAccess Authorize Access to the app. This will check for and validate existing access token. If no access was previously granted, it will then proceed to request one with the details given. If token has expired and a refresh token exists, it will then proceed to refresh the expired token ### Parameters * `params` **[Object][4]** * `params.grant_type` **[OauthGrantType][7]** Default - client_credentials grantType * `params.allowed_grant_types` **[Array][8]<[OauthGrantType][7]>** grant_type(s) to ignore if {OauthGrantType.Auto} selected * `params.redirect_uri` **[String][1]** For authorization_code grant_type default -> current url * `params.user_id` **[String][1]** For authorization_code grant_type * `params.username` **[String][1]** For password grant_type * `params.password` **[String][1]** For password grant_type ## hasExpired Check if authorization or token has expired ### Parameters * `token` **[String][1]** Returns **[Promise][9]<[boolean][2]>** ## oauthAuthorize Oauth Authorization ### Parameters * `scope` **[Array][8]<[string][1]>** * `redirect_url` **[String][1]** * `user_id` **[String][1]** * `state` **[String][1]** * `callback` ## oauthAuthorizeWithEmail Oauth Authorization ### Parameters * `scope` **[Array][8]<[string][1]>** * `redirect_url` **[String][1]** * `email` **[String][1]** * `state` **[String][1]** * `callback` ## oauthAuthorizeImplicit Oauth Authorization ### Parameters * `scope` **[Array][8]<[string][1]>** * `redirect_url` **[String][1]** * `user_id` **[String][1]** * `state` **[String][1]** * `callback` ## oauthTokenWithClientCredentials Get oauth token with Client credentials ### Parameters * `scope` **[Array][8]<[string][1]>** * `callback` ## oauthTokenWithUserCredentials Get oauth token with Client credentials ### Parameters * `username` **[String][1]** * `password` **[String][1]** * `scope` **[Array][8]<[string][1]>** * `callback` ## oauthTokenWithAuthorizationCode Get oauth token with Client credentials ### Parameters * `code` **[String][1]** * `redirect_uri` **[String][1]** * `callback` ## oauthRefreshToken Get oauth Refresh Token with Client credentials ### Parameters * `refresh_token` **[String][1]** * `callback` ## oauthVerifyToken Get oauth Refresh Token with Client credentials ### Parameters * `access_token` **[String][1]** * `callback` ## getNewOauthToken Get New Token ## token Ajax Response callback ### Parameters * `token` **[OauthTokenResponse][6]** ## token Ajax Response callback ### Parameters * `token` **[OauthTokenResponse][6]** ## token Ajax Response callback ### Parameters * `token` **[OauthTokenResponse][6]** ## token Ajax Response callback ### Parameters * `token` **[OauthTokenResponse][6]** ## refreshOauthToken Refresh Existing Token ### Parameters * `refreshToken` **[String][1]** String ## OauthGrantType Grant Types ## Client_Credentials Type: [String][1] ## Authorization_Code Type: [String][1] ## User_Credentials Type: [String][1] ## Refresh_Token Type: [String][1] ## Auto Type: [String][1] ## OauthRequestMethod Http Request Method ## GET Type: [String][1] ## POST Type: [String][1] ## PUT Type: [String][1] ## DELETE Type: [String][1] ## OauthRequest Make Oauth Http requests ### Parameters * `method` **[OauthRequestMethod][10]** (optional, default `OauthRequestMethod.GET`) * `data` **OauthRequestParams** ### request Make Http requests #### Parameters * `data` **OauthRequestParams\** Returns **[Promise][9]\** ### get Make GET Requests #### Parameters * `data` **OauthRequestParams** Returns **[Promise][9]\** ### post Make POST Requests #### Parameters * `data` **OauthRequestParams** Returns **[Promise][9]\** ### put Make PUT Requests #### Parameters * `data` **OauthRequestParams** Returns **[Promise][9]\** ### delete Make DELETE Requests #### Parameters * `data` **OauthRequestParams** Returns **[Promise][9]\** ## OauthResponse Oauth Response ### parseVerificationResponse #### Parameters * `result` **[String][1]** json result Returns **[OauthVerificationResponse][11]** ### parseAuthorizationResponse #### Parameters * `result` **[String][1]** json result Returns **[OauthAuthorizationResponse][12]** ### parseTokenResponse #### Parameters * `result` **[String][1]** json result Returns **[OauthTokenResponse][6]** ## OauthVerificationResponse Verification Response ### Parameters * `data` **[Object][4]** ## OauthAuthorizationResponse Authorization Respons ### Parameters * `data` **[Object][4]** ## OauthTokenResponse Token Response ### Parameters * `data` **[Object][4]** [1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String [2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object [5]: http://www.netlobo.com/url_query_string_javascript.html [6]: #oauthtokenresponse [7]: #oauthgranttype [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array [9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise [10]: #oauthrequestmethod [11]: #oauthverificationresponse [12]: #oauthauthorizationresponse