{"name":"gtoken","version":"5.3.0","description":"Node.js Google Authentication Service Account Tokens","main":"./build/src/index.js","types":"./build/src/index.d.ts","engines":{"node":">=10"},"repository":{"type":"git","url":"git+https://github.com/google/node-gtoken.git"},"scripts":{"lint":"gts check","clean":"gts clean","fix":"gts fix","compile":"tsc -p .","test":"c8 mocha build/test","prepare":"npm run compile","pretest":"npm run compile","presystem-test":"npm run compile","system-test":"mocha build/system-test","samples-test":"cd samples/ && npm link ../ && npm test && cd ../","docs":"compodoc src/","docs-test":"linkinator docs","predocs-test":"npm run docs","prelint":"cd samples; npm link ../; npm install","precompile":"gts clean","api-extractor":"api-extractor run --local","api-documenter":"api-documenter yaml --input-folder=temp"},"keywords":["google","service","account","api","token","api","auth"],"author":{"name":"Google, LLC"},"license":"MIT","dependencies":{"gaxios":"^4.0.0","google-p12-pem":"^3.0.3","jws":"^4.0.0"},"devDependencies":{"@compodoc/compodoc":"^1.1.7","@types/jws":"^3.1.0","@types/mocha":"^8.0.0","@types/node":"^14.0.0","c8":"^7.0.0","gts":"^3.0.0","linkinator":"^2.0.0","mocha":"^8.0.0","nock":"^13.0.0","typescript":"^3.8.3","@microsoft/api-documenter":"^7.8.10","@microsoft/api-extractor":"^7.8.10"},"gitHead":"4746054f6ff50875ea33aee4821288c17fb5b960","bugs":{"url":"https://github.com/google/node-gtoken/issues"},"homepage":"https://github.com/google/node-gtoken#readme","_id":"gtoken@5.3.0","_nodeVersion":"12.22.0","_npmVersion":"6.14.11","dist":{"integrity":"sha512-mCcISYiaRZrJpfqOs0QWa6lfEM/C1V9ASkzFmuz43XBb5s1Vynh+CZy1ECeeJXVGx2PRByjYzb4Y4/zr1byr0w==","shasum":"6536eb2880d9829f0b9d78f756795d4d9064b217","tarball":"http://registry-npm.ywwl.com/gtoken/download/gtoken-5.3.0.tgz","fileCount":6,"unpackedSize":35995,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgwWYUCRA9TVsSAnZWagAAc4AP/2KqzD+GZHYPohkkQTWv\n/Utqn4m/fraZqSxHI9W1H8uJaY5Kr41zVpY2Y2GBzVUoNWoEiHN/8ZkWDx0h\n0jSlxFOOSov/h1KC2aF+hXLvMtdTXRmjIGTD5J1/qD4/00xSXqYk9lXCBKYc\nnp0GB/BXIwGpr1WVVwVLQVZToiv7FnbN9TPbANk2PVcb1S3FKXWRC8w+kYkq\nfZtlufS6LGiLIzZd0o0geSsncIGZYzssfC7F4ktV8x+CqueO5uT8ZrnDpM0z\ntqKqoAjTrJ60KmF9MYhLo4YjRb6QVenWtFYSye1f+1QM0VwI3NkB1LeP586H\n4x0+Ypr6S/a+8llC80DiaEgnzn16l2M49kqFJ4obmtmdAdpzig1J1NkXdU5H\n0ONSvFzKcQGWWR+mo3iWt2rdBZHOPqE9KYH4eDvg8lXTM4tYpzaA6z6iE+i7\nb8Tek8kgO0s4AiCJHXC7o1VVF7VOiPqzsNWJiTjP0W9bwKyh0LivlpOQr98d\n7oXyZtRphjpREY6r622s/KCCmhkFtUvVWkDhh5fxjwfEzUDYOmogMFHFLbdd\nXuvNcG5cIFIvC5sHOPJDY3nbHaYHiq70pCgEWzA/5BtamXp1Fv05/GiL+ivB\nuOzkG8rXsYMecCANTOyAjw5BH9Hos0653OMS8wgAYw/o1JV90xtbI5lwXNTm\nElWk\r\n=avaB\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDFDNGD5eVJD9LqwZ9gaWtEi3imilNnNzK7emA6GZy/JgIgN0DAOjy4Znlplth/zJhPWCCtJnQ8Tm2QZ90QQEpnHak="}],"size":10630,"noattachment":false,"key":"/gtoken/-/gtoken-5.3.0.tgz"},"_npmUser":{"name":"google-wombot","email":"node-team-npm+wombot@google.com"},"directories":{},"maintainers":[{"name":"ofrobots","email":"ofrobots@google.com"},{"name":"google-node-team","email":"node-team-npm@google.com"},{"name":"soldair","email":"soldair@gmail.com"},{"name":"google-wombot","email":"node-team-npm+wombot@google.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gtoken_5.3.0_1623287316622_0.25591609554278505"},"_hasShrinkwrap":false,"readme":"<img src=\"https://avatars2.githubusercontent.com/u/2810941?v=3&s=96\" alt=\"Google Cloud Platform logo\" title=\"Google Cloud Platform\" align=\"right\" height=\"96\" width=\"96\"/>\n\n# [node-gtoken](https://github.com/googleapis/node-gtoken)\n\n[![npm version][npm-image]][npm-url]\n[![Known Vulnerabilities][snyk-image]][snyk-url]\n[![codecov][codecov-image]][codecov-url]\n[![Code Style: Google][gts-image]][gts-url]\n\n> Node.js Google Authentication Service Account Tokens\n\nThis is a low level utility library used to interact with Google Authentication services.  **In most cases, you probably want to use the [google-auth-library](https://github.com/googleapis/google-auth-library-nodejs) instead.**\n\n* [gtoken API Reference][client-docs]\n* [github.com/googleapis/node-gtoken](https://github.com/googleapis/node-gtoken)\n\n## Installation\n\n``` sh\nnpm install gtoken\n```\n\n## Usage\n\n### Use with a `.pem` or `.json` key file:\n\n``` js\nconst { GoogleToken } = require('gtoken');\nconst gtoken = new GoogleToken({\n  keyFile: 'path/to/key.pem', // or path to .json key file\n  email: 'my_service_account_email@developer.gserviceaccount.com',\n  scope: ['https://scope1', 'https://scope2'], // or space-delimited string of scopes\n  eagerRefreshThresholdMillis: 5 * 60 * 1000\n});\n\ngtoken.getToken((err, tokens) => {\n  if (err) {\n    console.log(err);\n    return;\n  }\n  console.log(tokens);\n  // {\n  //   access_token: 'very-secret-token',\n  //   expires_in: 3600,\n  //   token_type: 'Bearer'\n  // }\n});\n```\n\nYou can also use the async/await style API:\n\n``` js\nconst tokens = await gtoken.getToken()\nconsole.log(tokens);\n```\n\nOr use promises:\n\n```js\ngtoken.getToken()\n  .then(tokens => {\n    console.log(tokens)\n  })\n  .catch(console.error);\n```\n\n### Use with a service account `.json` key file:\n\n``` js\nconst { GoogleToken } = require('gtoken');\nconst gtoken = new GoogleToken({\n  keyFile: 'path/to/key.json',\n  scope: ['https://scope1', 'https://scope2'], // or space-delimited string of scopes\n  eagerRefreshThresholdMillis: 5 * 60 * 1000\n});\n\ngtoken.getToken((err, tokens) => {\n  if (err) {\n    console.log(err);\n    return;\n  }\n  console.log(tokens);\n});\n```\n\n### Pass the private key as a string directly:\n\n``` js\nconst key = '-----BEGIN RSA PRIVATE KEY-----\\nXXXXXXXXXXX...';\nconst { GoogleToken } = require('gtoken');\nconst gtoken = new GoogleToken({\n  email: 'my_service_account_email@developer.gserviceaccount.com',\n  scope: ['https://scope1', 'https://scope2'], // or space-delimited string of scopes\n  key: key,\n  eagerRefreshThresholdMillis: 5 * 60 * 1000\n});\n```\n\n## Options\n\n> Various options that can be set when creating initializing the `gtoken` object.\n\n- `options.email or options.iss`: The service account email address.\n- `options.scope`: An array of scope strings or space-delimited string of scopes.\n- `options.sub`: The email address of the user requesting delegated access.\n- `options.keyFile`: The filename of `.json` key or `.pem` key.\n- `options.key`: The raw RSA private key value, in place of using `options.keyFile`.\n- `options.additionalClaims`: Additional claims to include in the JWT when requesting a token.\n- `options.eagerRefreshThresholdMillis`: How long must a token be valid for in order to return it from the cache. Defaults to 0.\n\n### .getToken(callback)\n\n> Returns the cached tokens or requests a new one and returns it.\n\n``` js\ngtoken.getToken((err, token) => {\n  console.log(err || token);\n  // gtoken.rawToken value is also set\n});\n```\n\n### .getCredentials('path/to/key.json')\n\n> Given a keyfile, returns the key and (if available) the client email.\n\n```js\nconst creds = await gtoken.getCredentials('path/to/key.json');\n```\n\n### Properties\n\n> Various properties set on the gtoken object after call to `.getToken()`.\n\n- `gtoken.idToken`: The OIDC token returned (if any).\n- `gtoken.accessToken`: The access token.\n- `gtoken.expiresAt`: The expiry date as milliseconds since 1970/01/01\n- `gtoken.key`: The raw key value.\n- `gtoken.rawToken`: Most recent raw token data received from Google.\n\n### .hasExpired()\n\n> Returns true if the token has expired, or token does not exist.\n\n``` js\nconst tokens = await gtoken.getToken();\ngtoken.hasExpired(); // false\n```\n\n### .revokeToken()\n\n> Revoke the token if set.\n\n``` js\nawait gtoken.revokeToken();\nconsole.log('Token revoked!');\n```\n\n## Downloading your private `.json` key from Google\n\n1. Open the [Google Developer Console][gdevconsole].\n2. Open your project and under \"APIs & auth\", click Credentials.\n3. Generate a new `.json` key and download it into your project.\n\n## Converting your `.p12` key to a `.pem` key\n\nIf you'd like to convert to a `.pem` for use later, use OpenSSL if you have it installed.\n\n``` sh\n$ openssl pkcs12 -in key.p12 -nodes -nocerts > key.pem\n```\n\nDon't forget, the passphrase when converting these files is the string `'notasecret'`\n\n## License\n\n[MIT](https://github.com/googleapis/node-gtoken/blob/main/LICENSE)\n\n[codecov-image]: https://codecov.io/gh/googleapis/node-gtoken/branch/main/graph/badge.svg\n[codecov-url]: https://codecov.io/gh/googleapis/node-gtoken\n[gdevconsole]: https://console.developers.google.com\n[gts-image]: https://img.shields.io/badge/code%20style-google-blueviolet.svg\n[gts-url]: https://www.npmjs.com/package/gts\n[npm-image]: https://img.shields.io/npm/v/gtoken.svg\n[npm-url]: https://npmjs.org/package/gtoken\n[snyk-image]: https://snyk.io/test/github/googleapis/node-gtoken/badge.svg\n[snyk-url]: https://snyk.io/test/github/googleapis/node-gtoken\n[client-docs]: https://googleapis.dev/nodejs/gtoken/latest/\n","publish_time":1623287316787,"_cnpm_publish_time":1623287316787,"dist-tags":{"experimental":"8.0.1-experimental","latest":"8.0.0","legacy-10":"5.3.2","legacy-12":"6.1.2","legacy-14":"7.1.0","legacy-8":"4.1.4","rc":"8.0.0-rc.1"}}