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