diff --git a/packages/binding-http/src/credential.ts b/packages/binding-http/src/credential.ts index 5388466a5..5d5a9500d 100644 --- a/packages/binding-http/src/credential.ts +++ b/packages/binding-http/src/credential.ts @@ -163,6 +163,18 @@ export interface TuyaCustomBearerCredentialConfiguration { secret: string; } +interface TokenResponse { + success?: boolean; + result?: { + // eslint-disable-next-line camelcase + access_token?: string; + // eslint-disable-next-line camelcase + refresh_token?: string; + // eslint-disable-next-line camelcase + expire_time?: number; + }; +} + export class TuyaCustomBearer extends Credential { protected key: string; protected secret: string; @@ -201,17 +213,7 @@ export class TuyaCustomBearer extends Credential { if (refresh) { url = `${this.baseUri}/token/${this.refreshToken}`; } - const data: { - success?: boolean; - result?: { - // eslint-disable-next-line camelcase - access_token?: string; - // eslint-disable-next-line camelcase - refresh_token?: string; - // eslint-disable-next-line camelcase - expire_time?: number; - }; - } = await (await fetch(url, request)).json(); + const data: TokenResponse = await (await fetch(url, request)).json(); if (data.success === true) { this.token = data.result?.access_token; this.refreshToken = data.result?.refresh_token;