Skip to content
This repository was archived by the owner on Nov 20, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/auth/baseexternalclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export interface BaseExternalAccountClientOptions {
client_secret?: string;
quota_project_id?: string;
workforce_pool_user_project?: string;
universe_domain?: string;
}

/**
Expand Down Expand Up @@ -137,9 +138,9 @@ export abstract class BaseExternalAccountClient extends AuthClient {
private readonly workforcePoolUserProject?: string;
public projectId: string | null;
public projectNumber: string | null;
public universeDomain?: string;
public readonly eagerRefreshThresholdMillis: number;
public readonly forceRefreshOnFailure: boolean;

/**
* Instantiate a BaseExternalAccountClient instance using the provided JSON
* object loaded from an external account credentials file.
Expand Down Expand Up @@ -205,6 +206,7 @@ export abstract class BaseExternalAccountClient extends AuthClient {
this.forceRefreshOnFailure = !!additionalOptions?.forceRefreshOnFailure;
this.projectId = null;
this.projectNumber = this.getProjectNumber(this.audience);
this.universeDomain = options.universe_domain;
}

/** The service account email to be impersonated, if available. */
Expand Down
20 changes: 20 additions & 0 deletions test/test.baseexternalclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,26 @@ describe('BaseExternalAccountClient', () => {
});
});

describe('universeDomain', () => {
it('should be undefined if not set', () => {
const client = new TestExternalAccountClient(externalAccountOptions);

assert(client.universeDomain === undefined);
});

it('should be set if provided', () => {
const universeDomain = 'universe.domain.com';
const options: BaseExternalAccountClientOptions = Object.assign(
{},
externalAccountOptions
);
options.universe_domain = universeDomain;
const client = new TestExternalAccountClient(options);

assert.equal(client.universeDomain, universeDomain);
});
});

describe('getServiceAccountEmail()', () => {
it('should return the service account email when impersonation is used', () => {
const saEmail = '[email protected]';
Expand Down