bkper-js 2.35.1 → 2.35.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bkper.min.js +1 -1
- package/dist/bkper.min.js.map +3 -3
- package/lib/index.d.ts +4 -0
- package/lib/service/http-api-request.js +4 -4
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -2446,6 +2446,10 @@ export declare interface Config {
|
|
|
2446
2446
|
apiKeyProvider?: () => Promise<string>;
|
|
2447
2447
|
/**
|
|
2448
2448
|
* Issue a valid OAuth2 access token with **https://www.googleapis.com/auth/userinfo.email** scope authorized.
|
|
2449
|
+
*
|
|
2450
|
+
* If omitted or if it returns undefined, requests are sent without an Authorization header.
|
|
2451
|
+
* This supports environments where authentication is injected outside bkper-js, such as
|
|
2452
|
+
* Bkper Platform outbound for server-side app routes.
|
|
2449
2453
|
*/
|
|
2450
2454
|
oauthTokenProvider?: () => Promise<string | undefined>;
|
|
2451
2455
|
/**
|
|
@@ -37,7 +37,10 @@ export class HttpApiRequest extends HttpRequest {
|
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
38
|
this.addCustomHeaders();
|
|
39
39
|
yield this.addAgentIdHeader();
|
|
40
|
-
|
|
40
|
+
const accessToken = yield this.getAccessToken();
|
|
41
|
+
if (accessToken) {
|
|
42
|
+
this.setHeader("Authorization", `Bearer ${accessToken}`);
|
|
43
|
+
}
|
|
41
44
|
yield this.addApiKeyHeader();
|
|
42
45
|
try {
|
|
43
46
|
let resp = yield _super.execute.call(this);
|
|
@@ -200,9 +203,6 @@ export class HttpApiRequest extends HttpRequest {
|
|
|
200
203
|
if (effectiveConfig.oauthTokenProvider) {
|
|
201
204
|
token = yield effectiveConfig.oauthTokenProvider();
|
|
202
205
|
}
|
|
203
|
-
else {
|
|
204
|
-
console.warn(`Token provider NOT configured!`);
|
|
205
|
-
}
|
|
206
206
|
if (token) {
|
|
207
207
|
token = token.replace("Bearer ", "");
|
|
208
208
|
token = token.replace("bearer ", "");
|