Skip to content

Commit

Permalink
Merge branch 'main' into al-8
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbankhead authored Jan 26, 2024
2 parents 7c55642 + bcefe96 commit 899d2b1
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@

[1]: https://www.npmjs.com/package/google-auth-library?activeTab=versions

## [9.5.0](https://github.com/googleapis/google-auth-library-nodejs/compare/v9.4.2...v9.5.0) (2024-01-25)


### Features

* Improve Universe Domain Ergonomics ([#1732](https://github.com/googleapis/google-auth-library-nodejs/issues/1732)) ([eec82f5](https://github.com/googleapis/google-auth-library-nodejs/commit/eec82f5f48a250744b5c3200ef247c3eae184e2f))


### Bug Fixes

* **deps:** Update dependency @googleapis/iam to v14 ([#1725](https://github.com/googleapis/google-auth-library-nodejs/issues/1725)) ([594bf2c](https://github.com/googleapis/google-auth-library-nodejs/commit/594bf2cc808c03733274d6b08d92f1d4b12dd630))
* Typos in samples ([#1728](https://github.com/googleapis/google-auth-library-nodejs/issues/1728)) ([058a503](https://github.com/googleapis/google-auth-library-nodejs/commit/058a5035e3e4df35663c6b3adef2dda617271849))

## [9.4.2](https://github.com/googleapis/google-auth-library-nodejs/compare/v9.4.1...v9.4.2) (2024-01-04)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "google-auth-library",
"version": "9.4.2",
"version": "9.5.0",
"author": "Google Inc.",
"description": "Google APIs Authentication Client Library for Node.js",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion samples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"dependencies": {
"@google-cloud/storage": "^7.0.0",
"@googleapis/iam": "^14.0.0",
"google-auth-library": "^9.4.2",
"google-auth-library": "^9.5.0",
"node-fetch": "^2.3.0",
"opn": "^5.3.0",
"server-destroy": "^1.0.1"
Expand Down
17 changes: 15 additions & 2 deletions src/auth/googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ export interface GoogleAuthOptions<T extends AuthClient = JSONClient> {
* Your project ID.
*/
projectId?: string;

/**
* The default service domain for a given Cloud universe.
*
* This is an ergonomic equivalent to {@link clientOptions}'s `universeDomain`
* property and will be set for all generated {@link AuthClient}s.
*/
universeDomain?: string;
}

export const CLOUD_SDK_CLIENT_ID =
Expand Down Expand Up @@ -175,7 +183,7 @@ export class GoogleAuth<T extends AuthClient = JSONClient> {
defaultScopes?: string | string[];
private keyFilename?: string;
private scopes?: string | string[];
private clientOptions?: AuthClientOptions;
private clientOptions: AuthClientOptions = {};

/**
* The cached universe domain.
Expand Down Expand Up @@ -208,7 +216,12 @@ export class GoogleAuth<T extends AuthClient = JSONClient> {
this.keyFilename = opts.keyFilename || opts.keyFile;
this.scopes = opts.scopes;
this.jsonContent = opts.credentials || null;
this.clientOptions = opts.clientOptions;
this.clientOptions = opts.clientOptions || {};

if (opts.universeDomain) {
this.clientOptions.universeDomain = opts.universeDomain;
this.#universeDomain = opts.universeDomain;
}
}

// GAPIC client libraries should always use self-signed JWTs. The following
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {GoogleAuth} from './auth/googleauth';

export * as gcpMetadata from 'gcp-metadata';

export {AuthClient} from './auth/authclient';
export {AuthClient, DEFAULT_UNIVERSE} from './auth/authclient';
export {Compute, ComputeOptions} from './auth/computeclient';
export {
CredentialBody,
Expand Down
7 changes: 7 additions & 0 deletions test/test.googleauth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1551,6 +1551,13 @@ describe('googleauth', () => {
});

describe('getUniverseDomain', () => {
it('should prefer `universeDomain` > metadata service when available', async () => {
const universeDomain = 'my.universe.com';
const auth = new GoogleAuth({universeDomain});

assert.equal(await auth.getUniverseDomain(), universeDomain);
});

it('should prefer `clientOptions` > metadata service when available', async () => {
const universeDomain = 'my.universe.com';
const auth = new GoogleAuth({clientOptions: {universeDomain}});
Expand Down

0 comments on commit 899d2b1

Please sign in to comment.