google-auth-library
Advanced tools
Comparing version 8.2.0 to 8.3.0
@@ -18,2 +18,3 @@ /** | ||
import { AuthClient } from './authclient'; | ||
import { IdTokenProvider } from './idtokenclient'; | ||
export interface ImpersonatedOptions extends RefreshOptions { | ||
@@ -50,3 +51,14 @@ /** | ||
} | ||
export declare class Impersonated extends OAuth2Client { | ||
export interface FetchIdTokenOptions { | ||
/** | ||
* Include the service account email in the token. | ||
* If set to `true`, the token will contain `email` and `email_verified` claims. | ||
*/ | ||
includeEmail: boolean; | ||
} | ||
export interface FetchIdTokenResponse { | ||
/** The OpenId Connect ID token. */ | ||
token: string; | ||
} | ||
export declare class Impersonated extends OAuth2Client implements IdTokenProvider { | ||
private sourceClient; | ||
@@ -96,2 +108,12 @@ private targetPrincipal; | ||
protected refreshToken(refreshToken?: string | null): Promise<GetTokenResponse>; | ||
/** | ||
* Generates an OpenID Connect ID token for a service account. | ||
* | ||
* {@link https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateIdToken Reference Documentation} | ||
* | ||
* @param targetAudience the audience for the fetched ID token. | ||
* @param options the for the request | ||
* @return an OpenID Connect ID token | ||
*/ | ||
fetchIdToken(targetAudience: string, options?: FetchIdTokenOptions): Promise<string>; | ||
} |
@@ -116,4 +116,30 @@ "use strict"; | ||
} | ||
/** | ||
* Generates an OpenID Connect ID token for a service account. | ||
* | ||
* {@link https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/generateIdToken Reference Documentation} | ||
* | ||
* @param targetAudience the audience for the fetched ID token. | ||
* @param options the for the request | ||
* @return an OpenID Connect ID token | ||
*/ | ||
async fetchIdToken(targetAudience, options) { | ||
var _a; | ||
await this.sourceClient.getAccessToken(); | ||
const name = `projects/-/serviceAccounts/${this.targetPrincipal}`; | ||
const u = `${this.endpoint}/v1/${name}:generateIdToken`; | ||
const body = { | ||
delegates: this.delegates, | ||
audience: targetAudience, | ||
includeEmail: (_a = options === null || options === void 0 ? void 0 : options.includeEmail) !== null && _a !== void 0 ? _a : true, | ||
}; | ||
const res = await this.sourceClient.request({ | ||
url: u, | ||
data: body, | ||
method: 'POST', | ||
}); | ||
return res.data.token; | ||
} | ||
} | ||
exports.Impersonated = Impersonated; | ||
//# sourceMappingURL=impersonated.js.map |
{ | ||
"name": "google-auth-library", | ||
"version": "8.2.0", | ||
"version": "8.3.0", | ||
"author": "Google Inc.", | ||
@@ -5,0 +5,0 @@ "description": "Google APIs Authentication Client Library for Node.js", |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
474448
8149