{"name":"gtoken","version":"2.3.2","description":"Node.js Google Authentication Service Account Tokens","main":"./build/src/index.js","types":"./build/src/index.d.ts","engines":{"node":">=6.0.0"},"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":"nyc 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/"},"keywords":["google","service","account","api","token","api","auth"],"author":{"name":"Ryan Seys"},"license":"MIT","dependencies":{"gaxios":"^1.0.4","google-p12-pem":"^1.0.0","jws":"^3.1.5","mime":"^2.2.0","pify":"^4.0.0"},"devDependencies":{"@compodoc/compodoc":"^1.1.7","@types/jws":"^3.1.0","@types/mime":"^2.0.0","@types/mocha":"^5.0.0","@types/nock":"^9.1.2","@types/node":"^10.0.3","@types/pify":"^3.0.0","codecov":"^3.0.2","gts":"^0.9.0","intelli-espower-loader":"^1.0.1","js-green-licenses":"^0.5.0","mocha":"^5.0.1","nock":"^10.0.0","nyc":"^13.0.0","source-map-support":"^0.5.6","typescript":"~3.2.0"},"gitHead":"87ab50db013b19d38398dca3287127becfbc1984","bugs":{"url":"https://github.com/google/node-gtoken/issues"},"homepage":"https://github.com/google/node-gtoken#readme","_id":"gtoken@2.3.2","_npmVersion":"6.4.1","_nodeVersion":"8.15.0","_npmUser":{"name":"google-node-team","email":"node-team-npm@google.com"},"dist":{"integrity":"sha512-F8EObUGyC8Qd3WXTloNULZBwfUsOABoHElihB1F6zGhT/cy38iPL09wGLRY712I+hQnOyA+sYlgPFX2cOKz0qg==","shasum":"49890a866c1f44e173099be95515db5872a92151","tarball":"http://registry-npm.ywwl.com/gtoken/download/gtoken-2.3.2.tgz","fileCount":6,"unpackedSize":24539,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcN5JnCRA9TVsSAnZWagAAt7wP/2RvFWZpoJkSdc+b3Wgw\nVuQjQ6C7xNsU+6sZ0OTTeo0ZfKGLknFaKVlw8gpio7oX6/RTs5+ambY5meui\nTRQBPuUy0ip2vD3ZNLBOpGw+abvECdy7QWHHcTFuAQg8bZi71SNt+HDqTUu4\nP30lcdw4rnM9irziA9k0WG1cdMJAS+CEAgZcesS/fLx+MDeTuL5mMWDahWcY\nJgjqC71MIw7lq2ZRAqL36zz+Vkjhuz1ReHrQey+n5m1AjSD1tbEBDGRFH7tn\nEb+zP4PN+SUCRGUZGnIyEKLlwtt0TLQvBjb2HGxglZLdWXZc+r6iGqdZ8WdC\nRBSYn+GSIu+PaRvzAz70R2UFiowQ3V8XyCA7znLKf8BMuQyv0Yu3J4Nxh4kC\n5WHoSIsJki/qm8B4IrF3PaRhpIHLet6SQxj3ebNABgH2wcxUR8q+sE6C1Fsy\nHTP9YEawzDHGPfLo5zA0WsYg3edEBZCngrdmifuwtrfVGDRbm9sg1cAYg4cl\nL0Y3xqX7b2UrwZuEQN0pmRhU8dfO1lq9ZoG2XjkjD71qcYN8z1hfp25iTFAG\n3Qz9+8d3Sw8TV7S177YiTgIC4BzklaYnLVeaghJ07i3c59AiWrixQwxF4wtR\nDhT7zgpoQFbtCYIM5bAH1g8GHesb0JMzs4SJ2FB9CjsRr8YNdVYS/rvapS+4\n+Jmq\r\n=lk74\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD/tTsOgCo2k/q5BNexKKkN3/xckRu1buekljjz5/3x7QIhAImNxztsTqCQWxZEFgcPEXOHnWsWQaNilAzynry5PI1r"}],"size":7384,"noattachment":false,"key":"/gtoken/-/gtoken-2.3.2.tgz"},"maintainers":[{"email":"dominicdkramer@google.com","name":"dominicdkramer"},{"email":"node-team-npm@google.com","name":"google-node-team"},{"email":"justin.beckwith@gmail.com","name":"justinbeckwith"},{"email":"kelvinjin@google.com","name":"kjin"},{"email":"ofrobots@google.com","name":"ofrobots"},{"email":"soldair@gmail.com","name":"soldair"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gtoken_2.3.2_1547145830482_0.7902471897497423"},"_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":1547145830597,"_cnpm_publish_time":1547145830597,"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"}}