Skip to content

Commit 8dd1e35

Browse files
committed
chore: type fix
1 parent ff13e27 commit 8dd1e35

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/auth/oauth2client.ts

+15-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import * as querystring from 'querystring';
2222
import * as stream from 'stream';
2323
import * as formatEcdsa from 'ecdsa-sig-formatter';
2424

25-
import {createCrypto, JwkCertificate, hasBrowserCrypto} from '../crypto/crypto';
25+
import {createCrypto, JwkCertificate} from '../crypto/crypto';
2626
import {BodyResponseCallback} from '../transporters';
2727

2828
import {AuthClient, AuthClientOptions} from './authclient';
@@ -64,6 +64,9 @@ export enum CodeChallengeMethod {
6464
}
6565

6666
export enum CertificateFormat {
67+
/**
68+
* @deprecated
69+
*/
6770
PEM = 'PEM',
6871
JWK = 'JWK',
6972
}
@@ -433,12 +436,12 @@ export interface OAuth2ClientEndpoints {
433436
* The base endpoint to revoke tokens.
434437
*
435438
* @example
436-
* 'https://oauth2.googleapis.com/revoke'
439+
* 'https://www.accounts.google.com/o/oauth2/revoke'
437440
*/
438441
oauth2RevokeUrl: string | URL;
439442

440443
/**
441-
* Sign on certificates in PEM format.
444+
* Sign on certificates in the legacy PEM format.
442445
*
443446
* @example
444447
* 'https://www.googleapis.com/oauth2/v1/certs'
@@ -534,7 +537,7 @@ export class OAuth2Client extends AuthClient {
534537
tokenInfoUrl: 'https://oauth2.googleapis.com/tokeninfo',
535538
oauth2AuthBaseUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
536539
oauth2TokenUrl: 'https://oauth2.googleapis.com/token',
537-
oauth2RevokeUrl: 'https://oauth2.googleapis.com/revoke',
540+
oauth2RevokeUrl: 'https://www.accounts.google.com/o/oauth2/revoke',
538541
oauth2FederatedSignonPemCertsUrl:
539542
'https://www.googleapis.com/oauth2/v1/certs',
540543
oauth2FederatedSignonJwkCertsUrl:
@@ -854,7 +857,7 @@ export class OAuth2Client extends AuthClient {
854857

855858
protected async getRequestMetadataAsync(
856859
// eslint-disable-next-line @typescript-eslint/no-unused-vars
857-
url?: string | null
860+
url?: string | URL | null
858861
): Promise<RequestMetadataResponse> {
859862
const thisCreds = this.credentials;
860863
if (
@@ -1197,11 +1200,11 @@ export class OAuth2Client extends AuthClient {
11971200
}
11981201
}
11991202

1200-
async getFederatedSignonCertsAsync(): Promise<FederatedSignonCertsResponse> {
1203+
async getFederatedSignonCertsAsync(
1204+
format: CertificateFormat = CertificateFormat.JWK
1205+
): Promise<FederatedSignonCertsResponse> {
12011206
const nowTime = new Date().getTime();
1202-
const format = hasBrowserCrypto()
1203-
? CertificateFormat.JWK
1204-
: CertificateFormat.PEM;
1207+
12051208
if (
12061209
this.certificateExpiry &&
12071210
nowTime < this.certificateExpiry.getTime() &&
@@ -1210,13 +1213,13 @@ export class OAuth2Client extends AuthClient {
12101213
return {certs: this.certificateCache, format};
12111214
}
12121215
let res: GaxiosResponse;
1213-
let url: string;
1216+
let url: string | URL;
12141217
switch (format) {
12151218
case CertificateFormat.PEM:
1216-
url = this.endpoints.oauth2FederatedSignonPemCertsUrl.toString();
1219+
url = this.endpoints.oauth2FederatedSignonPemCertsUrl;
12171220
break;
12181221
case CertificateFormat.JWK:
1219-
url = this.endpoints.oauth2FederatedSignonJwkCertsUrl.toString();
1222+
url = this.endpoints.oauth2FederatedSignonJwkCertsUrl;
12201223
break;
12211224
default:
12221225
throw new Error(`Unsupported certificate format ${format}`);

0 commit comments

Comments
 (0)