@basetime/a2w-api-ts
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -5,2 +5,5 @@ import { Authed } from './Authed'; | ||
* Authenticates the with the a2w API. | ||
* | ||
* Used to make authentication requests to a2w in order to obtain tokens. The | ||
* tokens will be used for future requests to the API. | ||
*/ | ||
@@ -12,3 +15,3 @@ export default class Auth { | ||
/** | ||
* The last authentication. | ||
* The successful last authentication. | ||
*/ | ||
@@ -36,4 +39,7 @@ private authed?; | ||
/** | ||
* Retreives the last authentication. | ||
* Returns the last authentication. | ||
* | ||
* This method is used to retrieve the last successful authentication. In | ||
* includes the id token, refresh token, and the expiration time. | ||
* | ||
* @returns The last authentication. | ||
@@ -45,5 +51,9 @@ */ | ||
* | ||
* This method will authenticate with the a2w API and return the id token. It | ||
* stores the response in the `authed` property. Use the getAuthed method to | ||
* retrieve the last successful authentication. | ||
* | ||
* @returns The id token. | ||
*/ | ||
getBearerToken: () => Promise<string>; | ||
authenticate: () => Promise<string>; | ||
} |
@@ -11,10 +11,2 @@ import Auth from './Auth'; | ||
/** | ||
* Base URL for the production environment. | ||
*/ | ||
static readonly baseProd = "https://app.addtowallet.io/api/v1"; | ||
/** | ||
* Base URL for the dev environment. | ||
*/ | ||
static readonly baseDev = "https://local.addtowallet.io:5009/api/v1"; | ||
/** | ||
* The base URL. | ||
@@ -21,0 +13,0 @@ */ |
@@ -37,3 +37,3 @@ // src/NoopLogger.ts | ||
/** | ||
* The last authentication. | ||
* The successful last authentication. | ||
*/ | ||
@@ -54,4 +54,7 @@ authed; | ||
/** | ||
* Retreives the last authentication. | ||
* Returns the last authentication. | ||
* | ||
* This method is used to retrieve the last successful authentication. In | ||
* includes the id token, refresh token, and the expiration time. | ||
* | ||
* @returns The last authentication. | ||
@@ -65,6 +68,10 @@ */ | ||
* | ||
* This method will authenticate with the a2w API and return the id token. It | ||
* stores the response in the `authed` property. Use the getAuthed method to | ||
* retrieve the last successful authentication. | ||
* | ||
* @returns The id token. | ||
*/ | ||
getBearerToken = async () => { | ||
if (this.authed && this.authed.expiresAt > Date.now()) { | ||
authenticate = async () => { | ||
if (this.authed && this.authed.expiresAt > Date.now() / 1e3) { | ||
return this.authed.idToken; | ||
@@ -245,13 +252,5 @@ } | ||
/** | ||
* Base URL for the production environment. | ||
*/ | ||
static baseProd = "https://app.addtowallet.io/api/v1"; | ||
/** | ||
* Base URL for the dev environment. | ||
*/ | ||
static baseDev = "https://local.addtowallet.io:5009/api/v1"; | ||
/** | ||
* The base URL. | ||
*/ | ||
static baseUrl = _Client.baseProd; | ||
static baseUrl = "https://app.addtowallet.io/api/v1"; | ||
/** | ||
@@ -327,3 +326,3 @@ * The authentication object. | ||
this.logger.debug(`Sending request: ${(options == null ? void 0 : options.method) || "GET"} ${url}`); | ||
const bearerToken = await this.auth.getBearerToken(); | ||
const bearerToken = await this.auth.authenticate(); | ||
const headers = options.headers ? new Headers(options.headers) : new Headers(); | ||
@@ -330,0 +329,0 @@ headers.set("Authorization", `Bearer ${bearerToken}`); |
{ | ||
"name": "@basetime/a2w-api-ts", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "description": "Client library that communicates with the addtowallet API.", |
Sorry, the diff of this file is not supported yet
61565
1774