stephenplusplus / google-auto-auth

Making it as easy as possible to authenticate a Google API request
MIT License
34 stars 9 forks source link

fix(deps): update dependency google-auth-library to ^1.0.0 - autoclosed #44

Closed renovate[bot] closed 6 years ago

renovate[bot] commented 6 years ago

This Pull Request updates dependency google-auth-library from ^0.12.0 to ^1.0.0

Release Notes ### [`v1.0.0`](https://github.com/google/google-auth-library-nodejs/releases/v1.0.0) TL;DR - This release includes a variety of bug fixes, new features, and breaking changes. Please take care. ### New Features #### TypeScript support This library now includes a `d.ts` file by default - no @​types package needed. #### Promise & Async/Await style APIs Previous versions of the API were callback only. For every API that was callback based, there is also a Promise or Async/Await style variant. For example: ```js /** * You can use an errback style API **/ auth.getApplicationDefault(function(err, client) { if (err) { console.log('Authentication failed because of ', err); return; } // make request... }); /** * Or if you're using Babel, TypeScript, or Node.js 8+ you can use async/await **/ try { const client = await auth.getApplicationDefault(); // make request... } catch (err) { console.log('Authentication failed because of ', err); } /** * Or, you can just use promises **/ auth.getApplicationDefault() .then(client => { // make request }) .catch(err => { console.log('Authentication failed because of ', err); }); ``` #### Ability to set maxExpiry when verifying tokens The `OAuth2Client.verifyIdToken` method now accepts an optional maxExpiry field: ```js const result = await client.verifyIdToken({ idToken: , audience: , maxExpiry: }); ``` #### Support for code_verifier and code_challenge with OAuth2 The `OAuth2Client.generateAuthUrl` method has been extended to support the `code_challenge_method` and `code_challenge` fields. There is also a convenience method to generate a verifier: ```js // Generate a code_verifier and code_challenge const codes = oAuth2Client.generateCodeVerifier(); // Generate the url that will be used for the consent dialog. const authorizeUrl = oAuth2Client.generateAuthUrl({ access_type: 'offline', scope: 'https://www.googleapis.com/auth/plus.me', code_challenge_method: 'S256', code_challenge: codes.codeChallenge }); ``` ### Breaking changes There have been multiple API breaking changes with this release. Please test your code accordingly after upgrading. #### Default exports The exports on the `google-auth-library` have changed. The default export of the library was previously a reference to the `GoogleAuth` type, which was instantiated as a starting point for all consumers. Now, the module has no default export, but exports several other types common used. ```js // OLD CODE var GoogleAuth = require('google-auth-library'); var auth = new GoogleAuth(); var jwtClient = new auth.JWT(); var oAuth2Client = new auth.OAuth2(); ... // NEW CODE const gal = require('google-auth-library'); const auth = new gal.GoogleAuth(); const jwtClient = new gal.JWT(); const oAuth2Client = new gal.OAuth2Client(); ... // if you're using Node 6+, you might find this convenient: const {GoogleAuth, JWT, OAuth2Client} = require('google-auth-library'); ``` If you're using es6 imports via TypeScript or Babel, you can use es6 style as well: ```js import {GoogleAuth, OAuth2Client} from 'google-auth-library'; const auth = new GoogleAuth(); ... ``` #### Synchronous methods Several public methods were switched from asynchronous to synchronous APIs. In all cases, the APIs were not doing anything asynchronous - they were just providing errors in callback form. This has been changed. ```js // OLD CODE var auth = new GoogleAuth(); auth.fromJSON(input, function (err, client) { if (err) { console.error('Error acquiring client: ' + err); } // make request with client ... }); // NEW CODE const auth = new GoogleAuth(); const client = auth.fromJSON(input); // make request with client ... ``` This change was made with the following methods: - `GoogleAuth.fromJSON` - `GoogleAuth.fromAPIKey` - `JWTAccess. getRequestMetadata` - `JWTAccess.fromJSON` - `JWTClient.fromJSON` - `JWTClient.fromAPIKey` - `UserRefreshClient.fromJSON` #### Request -> Axios The underlying transport used for HTTP requests was changed from [`request`](https://github.com/request/request) to [`axios`](https://github.com/axios/axios). This will result in a number of breaking changes. Any calls to the `client.request(opts)` method will both accept different parameters, and have different return types. For the options passed to these methods, they are changing from a [request options object](https://github.com/request/request#requestoptions-callback) to an [axios request options object](https://github.com/axios/axios#request-config). In addition to the properties on the `opts` object changing, the signature of the callback is changing as well. The previous version of the library would return objects with a callback that reversed `request`'s default order: `function (err, body, response)`. The signature of that callback has simply been changed to `function (err, response)`, where the body of the response is available by looking at `response.data`. ```js // OLD CODE oAuth2Client.request({ uri: 'https://www.googleapis.com/plus/v1/people?query=pizza' }, function (err, body, res) { console.log('The body of the response was ' + body); }); // NEW CODE (using callbacks) oAuth2Client.request({ // note that we're using `url` instead of `uri` here, per the Axios request config. url: 'https://www.googleapis.com/plus/v1/people?query=pizza' }, function (err, res) { // The body isn't returned as part of the callback, and is available from `res.data` console.log(`The body of the response was ${res.data}`); }); // NEW CODE (using async/await) const res = await oAuth2Client.request({ url: 'https://www.googleapis.com/plus/v1/people?query=pizza' }); console.log(`The body of the response was ${res.data}`); ``` In addition to these changes - the `request` and `axios` libraries handle errors differently. `request` treats any completed request, even if it returns a non `2xx` response code, as a success. The `err` parameter will be `null` or `undefined`. `axios` treats any non `2xx` response as an *error*. Code which may have previous not worked, but also not thrown errors - may now start throwing errors. #### Parameter change for `verifyIdToken` The parameters to the `verifyIdToken` method of OAuth2Client have been changed. The function now accepts a single options object, and an optional callback. A function that used to look like this: ```js oAuth2Client.verifyIdToken(idToken, audience, callback); ``` Would now be rewritten as this: ```js oAuth2Client.verifyIdToken({ idToken: idToken, audience: audience }, callback); ``` --- ### [`v1.1.0`](https://github.com/google/google-auth-library-nodejs/releases/v1.1.0) This release includes a few new features, and a few bug fixes. #### New Features f9950b0 feat: cache JWT tokens in JWTAccess (#​254) 7e9a390 feat: Add ability to refresh token automatically before expiration. (#​242) 014ce0b feat: export static GoogleAuth (#​249) #### Fixes c3ce4f1 fix: Fix samples/jwt.js link in README (#​253) 64fb34d fix: update usage of OAuth2Client.verifyIdToken in example (#​243) 771bc6c fix: use npm link to run samples (#​245) --- ### [`v1.2.0`](https://github.com/google/google-auth-library-nodejs/releases/v1.2.0) #### New Features 0803242 feat: add IAP and additional claims support (#​268) 7d89b2c feat: add example of puppeteer (#​265) a570126 feat: Add given_name and family_name to TokenPayload interface (#​260) #### Bug Fixes 730d4b7 fix: Update GCE metadata token endpoint (#​269) 17a56a6 fix: update links in readme (#​262) --- ### [`v1.2.1`](https://github.com/google/google-auth-library-nodejs/releases/v1.2.1) This reverts #​269, which broke the auth client for Google Cloud Function users. --- ### [`v1.3.0`](https://github.com/google/google-auth-library-nodejs/releases/v1.3.0) This release has it all. Bug fixes, new features, and improved test coverage! Here are some highlights. ##### Easy mode This release includes a bunch of the features available in [google-auto-auth](https://github.com/stephenplusplus/google-auto-auth). This makes it really easy to get started with service credentials. You can easily grab and use application default credentials: ```js const { auth } = require('google-auth-library'); async function main() { const client = await auth.getClient(); const projectId = await auth.getDefaultProjectId(); const url = `https://www.googleapis.com/dns/v1/projects/${projectId}`; const res = await client.request({ url }); console.log(res.data); } main().catch(console.error); ``` Or easily use the client to authorize a request: ```js const { auth } = require('google-auth-library'); const axios = require('axios'); async function main() { const client = await auth.getClient(); const projectId = await auth.getDefaultProjectId(); const url = `https://www.googleapis.com/dns/v1/projects/${projectId}`; const opts = await auth.authorizeRequest(); const res = await axios.get(url, opts); console.log(res.data); } main().catch(console.error); ``` #### Commits in this release 64a1bd0 feat: add auto auth features (#​281) 4d0c49d chore(package): update gcp-metadata to version 0.6.0 (#​288) 60c5a1e chore: upgrade to TypeScript 2.7 (#​289) 80c439a chore: upgrade all the things (#​292) 5699b90 fix: cache GCE credentials (#​286) 12feb2c test: improve coverage (#​287) 7a951e0 fix: retry connections to gce metadata server (#​284) 78d6813 fix: do not retry if a post with readable stream (#​279) 3c9efe5 chore: use gcp-metadata (#​278) --- ### [`v1.3.1`](https://github.com/google/google-auth-library-nodejs/releases/v1.3.1) This releases fixes #​295. ---
Commits #### v1.0.0 - [`5c9c7b0`](https://github.com/google/google-auth-library-nodejs/commit/5c9c7b058d49620e9a0efb9f19577d33d6e38e51) Reland "chore: Switch from gulp to gts, TypeScript 2.6" (#​186) - [`c1c77c0`](https://github.com/google/google-auth-library-nodejs/commit/c1c77c01338265d79e796bdf8e02d60947e7f815) chore: upgrade to typed versions of jws and gtoken (#​183) - [`7be6f77`](https://github.com/google/google-auth-library-nodejs/commit/7be6f77693ab3caecb5aabd7ee1f76cf65c404c5) chore: switch to axios (#​182) - [`99b26dd`](https://github.com/google/google-auth-library-nodejs/commit/99b26dd6712a7f5855099d6010e523eade0da055) chore: remove callbacks for sync APIs (#​191) - [`af01878`](https://github.com/google/google-auth-library-nodejs/commit/af018788752862f7a94b9c08d9fce3be02e6fc76) test: add asserts on authorize (#​195) - [`b3bda6b`](https://github.com/google/google-auth-library-nodejs/commit/b3bda6ba3a86d6d917f85d60d30d613914d83f83) chore: use gcloud config-helper to get projectId (#​194) - [`7fb0bb3`](https://github.com/google/google-auth-library-nodejs/commit/7fb0bb3cf1125ae9ad809f4b42fc21af4b35b0ee) test: add typescript test (#​192) - [`0930a09`](https://github.com/google/google-auth-library-nodejs/commit/0930a09ba55a3469c6e8a106a352e6b20c3dce7a) fix: add setCredentials method back to AuthClient (#​198) - [`c9375ee`](https://github.com/google/google-auth-library-nodejs/commit/c9375ee1b33258529d12b7bbfbb2d5dd32451e47) chore: export class types and remove properties from GoogleAuth (#​202) - [`d5df378`](https://github.com/google/google-auth-library-nodejs/commit/d5df37805f2a9c0aa2747173c4f988f7a9516650) fix: use urlencoded content-type for POST (#​203) - [`d6e3585`](https://github.com/google/google-auth-library-nodejs/commit/d6e3585a7d2bdfe3b159efa733ba24ed16fd2f53) 1.0.0-alpha.1 - [`0cd813c`](https://github.com/google/google-auth-library-nodejs/commit/0cd813ca9b085b841f14f3506d55852c8a62d367) fix: retry checking isGCE (#​193) - [`b917e5d`](https://github.com/google/google-auth-library-nodejs/commit/b917e5d19863bebedfe0445d556a90955e71d110) fix: update code to support typescript@​2.6.2 (#​209) - [`de318ab`](https://github.com/google/google-auth-library-nodejs/commit/de318ab6e6428ca3439ff04e4a3b8f1f38d47add) fix: Fixes mapping of FederatedSignonCertsResponse in verifyIdTokenAsync (#​211) - [`7f0869b`](https://github.com/google/google-auth-library-nodejs/commit/7f0869b7c93cae0109f8bb56cdbc8723a87cfe96) chore: update deps to latest versions (#​210) - [`e74d66f`](https://github.com/google/google-auth-library-nodejs/commit/e74d66fc40e3fe9191d93a3bd9f0c46a205c8464) docs: add docs and samples (#​201) - [`db1a4ab`](https://github.com/google/google-auth-library-nodejs/commit/db1a4ab74a05d8c183d2d425bcc3bd3199e34042) test: add test for verifyIdToken (#​213) - [`26f6161`](https://github.com/google/google-auth-library-nodejs/commit/26f6161265964112e25901a61360bee715baae81) docs: add example and readme for using fromJSON (#​220) - [`a9ab95e`](https://github.com/google/google-auth-library-nodejs/commit/a9ab95eb62dc6ca5d1ebbdb9d505cf8f03e79a5f) docs: document proxy behavior and verify with a test (#​221) - [`bb9a74b`](https://github.com/google/google-auth-library-nodejs/commit/bb9a74bc60befc1db2747cbc6b66b48192ac4228) feat: allow passing maxExpiry to verifyIdToken (#​223) - [`92d5fc2`](https://github.com/google/google-auth-library-nodejs/commit/92d5fc2831640b00c6444fdcd154870046b2d888) chore: docs and samples for refresh token, update uris (#​215) - [`83ed61c`](https://github.com/google/google-auth-library-nodejs/commit/83ed61c87540a72f0b5b1e689666bc785c7763eb) feat: add support for code_verifier in getToken (#​218) - [`d248a00`](https://github.com/google/google-auth-library-nodejs/commit/d248a00665721b6dd4bd4bcfd9c3ef9f4cb7021e) chore: update deps (#​229) - [`c717429`](https://github.com/google/google-auth-library-nodejs/commit/c717429991798a1885484b1510dc80aa25ce415f) chore: license check as posttest (#​232) - [`a2fc08c`](https://github.com/google/google-auth-library-nodejs/commit/a2fc08c9110f4f1c8f8058b3d70141ad9fac50ff) fix: improve typing around tokens and add sample (#​219) - [`c2af227`](https://github.com/google/google-auth-library-nodejs/commit/c2af227ba4de085ba0d577c5c877f99b4571017f) chore: apply code style rules to javascript (#​233) - [`811293a`](https://github.com/google/google-auth-library-nodejs/commit/811293ac269639077292606a6578bd0641bdd1b3) fix: cache promise instead of ProjectId (#​216) - [`f388b8c`](https://github.com/google/google-auth-library-nodejs/commit/f388b8ca1582e27b3acc4f4f54ac7246938a82f3) chore(package): regen package-lock after merge - [`bc5ddd6`](https://github.com/google/google-auth-library-nodejs/commit/bc5ddd6792245c8c57aada3f8a179374393897fd) chore: accept options objects in constructors (#​230) - [`b8a47ca`](https://github.com/google/google-auth-library-nodejs/commit/b8a47ca61732baad21cd7c6abbabb89ffbb24458) chore(package): update @​types/node to version 9.3.0 (#​238) - [`0bc61e3`](https://github.com/google/google-auth-library-nodejs/commit/0bc61e383587352e9f8acfcb4e6010f850aa792e) chore: cleanup samples and readme (#​240) - [`10b4d5d`](https://github.com/google/google-auth-library-nodejs/commit/10b4d5d65ab4f3601a066082f559a60a88944341) feat: generate reference docs (#​237) - [`b6324ce`](https://github.com/google/google-auth-library-nodejs/commit/b6324ce0531120da923d06b5141cc327ed88b131) 1.0.0 #### v1.1.0 - [`771bc6c`](https://github.com/google/google-auth-library-nodejs/commit/771bc6cdcf56f7d5e0b3a754c28190476251d6f6) fix: use npm link to run samples (#​245) - [`5094b2f`](https://github.com/google/google-auth-library-nodejs/commit/5094b2fb135c7f2a6a57d47b4e91673b25d51919) chore(package): update js-green-licenses to version 0.3.1 (#​247) - [`014ce0b`](https://github.com/google/google-auth-library-nodejs/commit/014ce0bd20c86a7b0dbddc023cfb0b402d3093e2) feat: export static GoogleAuth (#​249) - [`64fb34d`](https://github.com/google/google-auth-library-nodejs/commit/64fb34d1855a799d74c385517d6403d3c6e05a16) fix: update usage of OAuth2Client.verifyIdToken in example (#​243) - [`7e9a390`](https://github.com/google/google-auth-library-nodejs/commit/7e9a3903c14340bc20ec4935138e6fb0dd8d1f8a) feat: Add ability to refresh token automatically before expiration. (#​242) - [`c3ce4f1`](https://github.com/google/google-auth-library-nodejs/commit/c3ce4f1d274326c51527ef7067f0ef90bf42ddb4) fix: Fix samples/jwt.js link in README (#​253) - [`0983b08`](https://github.com/google/google-auth-library-nodejs/commit/0983b0871dc00fc4d52afa8cb026b2bc2caf6be3) chore: Delete the changelog in favor of GitHub release notes (#​250) - [`7f4562f`](https://github.com/google/google-auth-library-nodejs/commit/7f4562f58dafd39a13ef3d9d7df5e07a9a916bc6) chore: move to CircleCI and fix codecov (#​257) - [`06f1292`](https://github.com/google/google-auth-library-nodejs/commit/06f1292cd3cea37cc20af7a539512d625d30b796) chore(package): update mocha to version 5.0.0 (#​258) - [`36fb7ae`](https://github.com/google/google-auth-library-nodejs/commit/36fb7ae393e35b9a1b77c755072bc3470d7357f5) chore(package): update js-green-licenses to version 0.4.0 (#​256) - [`f9950b0`](https://github.com/google/google-auth-library-nodejs/commit/f9950b0e6fbcda812a340180c47d9c2d83be3c87) feat: cache JWT tokens in JWTAccess (#​254) - [`3d9e26a`](https://github.com/google/google-auth-library-nodejs/commit/3d9e26ac1e2b4ff74c09fe20082edb59165d2993) chore: release v1.1.0 (#​261) #### v1.2.0 - [`c654a00`](https://github.com/google/google-auth-library-nodejs/commit/c654a00af500d08bb8061a7cf9f3a0075bae71cb) chore: remove tests from coverage (#​263) - [`17a56a6`](https://github.com/google/google-auth-library-nodejs/commit/17a56a682eb34e5bee7c0967dfe6283a616a2d2d) fix: update links in readme (#​262) - [`a570126`](https://github.com/google/google-auth-library-nodejs/commit/a570126b9b00d3fbb79447a6145637298abe7a3b) feat: Add given_name and family_name to TokenPayload interface (#​260) - [`29c6963`](https://github.com/google/google-auth-library-nodejs/commit/29c6963cc7a25d3ea62122f0822e29d92807e493) chore: update to latest version of gtoken (#​266) - [`7d89b2c`](https://github.com/google/google-auth-library-nodejs/commit/7d89b2c185188c4234a3707e357decbde1023309) chore: add example of puppeteer (#​265) - [`730d4b7`](https://github.com/google/google-auth-library-nodejs/commit/730d4b7d7de59b04862169fbc3a6feeab4d0debb) fix: Update GCE metadata token endpoint (#​269) - [`0803242`](https://github.com/google/google-auth-library-nodejs/commit/0803242ca4e2ac329b0188bcafc503be69267403) feat: add IAP and additional claims support (#​268) - [`5ab6be3`](https://github.com/google/google-auth-library-nodejs/commit/5ab6be36bed5fd2ae0031ae19363270b3a828133) chore: bump to 1.2.0 (#​271) #### v1.2.1 - [`b6db93a`](https://github.com/google/google-auth-library-nodejs/commit/b6db93a5c5d66154914e86a01539b6cacdfb9a45) chore: remove closure jsdoc types (#​272) - [`c797422`](https://github.com/google/google-auth-library-nodejs/commit/c797422129dc98c06f742ae496cecbadf3503e53) chore: improve env var mocking (#​273) - [`6d6756e`](https://github.com/google/google-auth-library-nodejs/commit/6d6756e9e2f1823aa2471608fa18a632d166d619) Revert "fix: Update GCE metadata token endpoint (#​269)" (#​276) - [`a21d244`](https://github.com/google/google-auth-library-nodejs/commit/a21d2440c1a879b3ae25aebc31232f8b6025cca7) chore: release 1.2.1 (#​277) #### v1.3.0 - [`3c9efe5`](https://github.com/google/google-auth-library-nodejs/commit/3c9efe58424685271943e9b267dde2956bdbd895) chore: use gcp-metadata (#​278) - [`78d6813`](https://github.com/google/google-auth-library-nodejs/commit/78d6813ef648b32312b01396e782f234599ed706) fix: do not retry if a post with readable stream (#​279) - [`7a951e0`](https://github.com/google/google-auth-library-nodejs/commit/7a951e05f1e35e6ff073639701e03567eb942871) fix: retry connections to gce metadata server (#​284) - [`12feb2c`](https://github.com/google/google-auth-library-nodejs/commit/12feb2ce9d97074c69ed26db8361c4110c04853c) test: improve coverage (#​287) - [`5699b90`](https://github.com/google/google-auth-library-nodejs/commit/5699b90b20ae58e89224fb492474de7c8c17f48f) fix: cache GCE credentials (#​286) - [`80c439a`](https://github.com/google/google-auth-library-nodejs/commit/80c439a5d318aa345dd311a99cdbbaeb85b584b3) chore: upgrade all the things (#​292) - [`60c5a1e`](https://github.com/google/google-auth-library-nodejs/commit/60c5a1e6062d98a67e84502465fdd0217d5953c1) chore: upgrade to TypeScript 2.7 (#​289) - [`4d0c49d`](https://github.com/google/google-auth-library-nodejs/commit/4d0c49dcbd77cbf1208b0b5a6df6fa5552a4bc30) chore(package): update gcp-metadata to version 0.6.0 (#​288) - [`64a1bd0`](https://github.com/google/google-auth-library-nodejs/commit/64a1bd04f4a573997cc48c7eb22562a941221b04) feat: add auto auth features (#​281) - [`7b85668`](https://github.com/google/google-auth-library-nodejs/commit/7b8566875c6387feac4d2a005cd3cfe77c21bf19) chore: release 1.3.0 (#​294) #### v1.3.1 - [`3533dd9`](https://github.com/google/google-auth-library-nodejs/commit/3533dd9e70582dd802cda75c7c77d1d99090d5a5) fix: move gcp-metadata to deps (#​296) - [`0ea5ee0`](https://github.com/google/google-auth-library-nodejs/commit/0ea5ee08f1c5ec981ebb784fb00f01c93e11d721) chore: release 1.3.1 (#​297)

This PR has been generated by Renovate Bot.