Skip to content

Commit a5df3bf

Browse files
committed
refactor: revert accidental changes from another branch
1 parent 8dd1e35 commit a5df3bf

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/auth/oauth2client.ts

Lines changed: 11 additions & 14 deletions
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} from '../crypto/crypto';
25+
import {createCrypto, JwkCertificate, hasBrowserCrypto} from '../crypto/crypto';
2626
import {BodyResponseCallback} from '../transporters';
2727

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

6666
export enum CertificateFormat {
67-
/**
68-
* @deprecated
69-
*/
7067
PEM = 'PEM',
7168
JWK = 'JWK',
7269
}
@@ -436,12 +433,12 @@ export interface OAuth2ClientEndpoints {
436433
* The base endpoint to revoke tokens.
437434
*
438435
* @example
439-
* 'https://www.accounts.google.com/o/oauth2/revoke'
436+
* 'https://oauth2.googleapis.com/revoke'
440437
*/
441438
oauth2RevokeUrl: string | URL;
442439

443440
/**
444-
* Sign on certificates in the legacy PEM format.
441+
* Sign on certificates in PEM format.
445442
*
446443
* @example
447444
* 'https://www.googleapis.com/oauth2/v1/certs'
@@ -537,7 +534,7 @@ export class OAuth2Client extends AuthClient {
537534
tokenInfoUrl: 'https://oauth2.googleapis.com/tokeninfo',
538535
oauth2AuthBaseUrl: 'https://accounts.google.com/o/oauth2/v2/auth',
539536
oauth2TokenUrl: 'https://oauth2.googleapis.com/token',
540-
oauth2RevokeUrl: 'https://www.accounts.google.com/o/oauth2/revoke',
537+
oauth2RevokeUrl: 'https://oauth2.googleapis.com/revoke',
541538
oauth2FederatedSignonPemCertsUrl:
542539
'https://www.googleapis.com/oauth2/v1/certs',
543540
oauth2FederatedSignonJwkCertsUrl:
@@ -1200,11 +1197,11 @@ export class OAuth2Client extends AuthClient {
12001197
}
12011198
}
12021199

1203-
async getFederatedSignonCertsAsync(
1204-
format: CertificateFormat = CertificateFormat.JWK
1205-
): Promise<FederatedSignonCertsResponse> {
1200+
async getFederatedSignonCertsAsync(): Promise<FederatedSignonCertsResponse> {
12061201
const nowTime = new Date().getTime();
1207-
1202+
const format = hasBrowserCrypto()
1203+
? CertificateFormat.JWK
1204+
: CertificateFormat.PEM;
12081205
if (
12091206
this.certificateExpiry &&
12101207
nowTime < this.certificateExpiry.getTime() &&
@@ -1213,13 +1210,13 @@ export class OAuth2Client extends AuthClient {
12131210
return {certs: this.certificateCache, format};
12141211
}
12151212
let res: GaxiosResponse;
1216-
let url: string | URL;
1213+
let url: string;
12171214
switch (format) {
12181215
case CertificateFormat.PEM:
1219-
url = this.endpoints.oauth2FederatedSignonPemCertsUrl;
1216+
url = this.endpoints.oauth2FederatedSignonPemCertsUrl.toString();
12201217
break;
12211218
case CertificateFormat.JWK:
1222-
url = this.endpoints.oauth2FederatedSignonJwkCertsUrl;
1219+
url = this.endpoints.oauth2FederatedSignonJwkCertsUrl.toString();
12231220
break;
12241221
default:
12251222
throw new Error(`Unsupported certificate format ${format}`);

0 commit comments

Comments
 (0)