@@ -22,7 +22,7 @@ import * as querystring from 'querystring';
22
22
import * as stream from 'stream' ;
23
23
import * as formatEcdsa from 'ecdsa-sig-formatter' ;
24
24
25
- import { createCrypto , JwkCertificate , hasBrowserCrypto } from '../crypto/crypto' ;
25
+ import { createCrypto , JwkCertificate } from '../crypto/crypto' ;
26
26
import { BodyResponseCallback } from '../transporters' ;
27
27
28
28
import { AuthClient , AuthClientOptions } from './authclient' ;
@@ -64,6 +64,9 @@ export enum CodeChallengeMethod {
64
64
}
65
65
66
66
export enum CertificateFormat {
67
+ /**
68
+ * @deprecated
69
+ */
67
70
PEM = 'PEM' ,
68
71
JWK = 'JWK' ,
69
72
}
@@ -433,12 +436,12 @@ export interface OAuth2ClientEndpoints {
433
436
* The base endpoint to revoke tokens.
434
437
*
435
438
* @example
436
- * 'https://oauth2.googleapis. com/revoke'
439
+ * 'https://www.accounts.google. com/o/oauth2 /revoke'
437
440
*/
438
441
oauth2RevokeUrl : string | URL ;
439
442
440
443
/**
441
- * Sign on certificates in PEM format.
444
+ * Sign on certificates in the legacy PEM format.
442
445
*
443
446
* @example
444
447
* 'https://www.googleapis.com/oauth2/v1/certs'
@@ -534,7 +537,7 @@ export class OAuth2Client extends AuthClient {
534
537
tokenInfoUrl : 'https://oauth2.googleapis.com/tokeninfo' ,
535
538
oauth2AuthBaseUrl : 'https://accounts.google.com/o/oauth2/v2/auth' ,
536
539
oauth2TokenUrl : 'https://oauth2.googleapis.com/token' ,
537
- oauth2RevokeUrl : 'https://oauth2.googleapis. com/revoke' ,
540
+ oauth2RevokeUrl : 'https://www.accounts.google. com/o/oauth2 /revoke' ,
538
541
oauth2FederatedSignonPemCertsUrl :
539
542
'https://www.googleapis.com/oauth2/v1/certs' ,
540
543
oauth2FederatedSignonJwkCertsUrl :
@@ -854,7 +857,7 @@ export class OAuth2Client extends AuthClient {
854
857
855
858
protected async getRequestMetadataAsync (
856
859
// eslint-disable-next-line @typescript-eslint/no-unused-vars
857
- url ?: string | null
860
+ url ?: string | URL | null
858
861
) : Promise < RequestMetadataResponse > {
859
862
const thisCreds = this . credentials ;
860
863
if (
@@ -1197,11 +1200,11 @@ export class OAuth2Client extends AuthClient {
1197
1200
}
1198
1201
}
1199
1202
1200
- async getFederatedSignonCertsAsync ( ) : Promise < FederatedSignonCertsResponse > {
1203
+ async getFederatedSignonCertsAsync (
1204
+ format : CertificateFormat = CertificateFormat . JWK
1205
+ ) : Promise < FederatedSignonCertsResponse > {
1201
1206
const nowTime = new Date ( ) . getTime ( ) ;
1202
- const format = hasBrowserCrypto ( )
1203
- ? CertificateFormat . JWK
1204
- : CertificateFormat . PEM ;
1207
+
1205
1208
if (
1206
1209
this . certificateExpiry &&
1207
1210
nowTime < this . certificateExpiry . getTime ( ) &&
@@ -1210,13 +1213,13 @@ export class OAuth2Client extends AuthClient {
1210
1213
return { certs : this . certificateCache , format} ;
1211
1214
}
1212
1215
let res : GaxiosResponse ;
1213
- let url : string ;
1216
+ let url : string | URL ;
1214
1217
switch ( format ) {
1215
1218
case CertificateFormat . PEM :
1216
- url = this . endpoints . oauth2FederatedSignonPemCertsUrl . toString ( ) ;
1219
+ url = this . endpoints . oauth2FederatedSignonPemCertsUrl ;
1217
1220
break ;
1218
1221
case CertificateFormat . JWK :
1219
- url = this . endpoints . oauth2FederatedSignonJwkCertsUrl . toString ( ) ;
1222
+ url = this . endpoints . oauth2FederatedSignonJwkCertsUrl ;
1220
1223
break ;
1221
1224
default :
1222
1225
throw new Error ( `Unsupported certificate format ${ format } ` ) ;
0 commit comments