lhisp-oauth-client 1.0.21 → 1.0.23
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/package.json
CHANGED
|
@@ -22,7 +22,7 @@ export declare class LhispOauthClient<iAccessToken extends AccessToken = AccessT
|
|
|
22
22
|
protected tokenCreatedAt: number;
|
|
23
23
|
protected tokenExpiresIn: number;
|
|
24
24
|
protected sendAuthCredentialsOnRequestBody?: boolean;
|
|
25
|
-
protected
|
|
25
|
+
protected formatAccessToken?: (accessToken?: iAccessToken) => string;
|
|
26
26
|
constructor(params: LhispOauthClientConstructorParams);
|
|
27
27
|
getAuthHeaderValue(): string;
|
|
28
28
|
parseData({ data, contentType }: {
|
|
@@ -46,6 +46,7 @@ class LhispOauthClient {
|
|
|
46
46
|
this.authHeaderName = params.authHeaderName || lhisp_oauth_client_t_1.defaultAuthHeaderName;
|
|
47
47
|
this.tokenHeaderName = params.tokenHeaderName || lhisp_oauth_client_t_1.defaultTokenHeaderName;
|
|
48
48
|
this.sendAuthCredentialsOnRequestBody = params.sendAuthCredentialsOnRequestBody;
|
|
49
|
+
this.formatAccessToken = params.formatAccessToken;
|
|
49
50
|
}
|
|
50
51
|
getAuthHeaderValue() {
|
|
51
52
|
return `Basic ${Buffer.from(`${this.clientId}:${this.clientSecret}`).toString("base64")}`;
|
|
@@ -118,11 +119,11 @@ class LhispOauthClient {
|
|
|
118
119
|
return data;
|
|
119
120
|
}
|
|
120
121
|
getAuthToken() {
|
|
121
|
-
var _a, _b
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return `${
|
|
122
|
+
var _a, _b;
|
|
123
|
+
if (this.formatAccessToken) {
|
|
124
|
+
return this.formatAccessToken(this.accessToken);
|
|
125
|
+
}
|
|
126
|
+
return `${(_a = this.accessToken) === null || _a === void 0 ? void 0 : _a.token_type} ${(_b = this.accessToken) === null || _b === void 0 ? void 0 : _b.access_token}`;
|
|
126
127
|
}
|
|
127
128
|
executarRequest({ method, path, data, params, contentType = lhisp_oauth_client_t_1.ContentType.APPLICATION_JSON, }) {
|
|
128
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -17,7 +17,7 @@ export interface LhispOauthClientConstructorParams {
|
|
|
17
17
|
grantType?: string;
|
|
18
18
|
authContentType?: ContentType;
|
|
19
19
|
sendAuthCredentialsOnRequestBody?: boolean;
|
|
20
|
-
|
|
20
|
+
formatAccessToken?: (accessToken?: AccessToken) => string;
|
|
21
21
|
debug?: boolean;
|
|
22
22
|
}
|
|
23
23
|
export interface ExecutarRequestParams extends AxiosRequestConfig {
|