mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 01:16:00 +00:00
Modules
This commit is contained in:
206
node_modules/gtoken/CHANGELOG.md
generated
vendored
Normal file
206
node_modules/gtoken/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,206 @@
|
||||
# Changelog
|
||||
|
||||
[npm history][1]
|
||||
|
||||
[1]: https://www.npmjs.com/package/gtoken?activeTab=versions
|
||||
|
||||
### [4.1.4](https://www.github.com/googleapis/node-gtoken/compare/v4.1.3...v4.1.4) (2020-01-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** pin TypeScript below 3.7.0 ([f1ae7b6](https://www.github.com/googleapis/node-gtoken/commit/f1ae7b64ead1c918546ae5bbe8546dfb4ecc788a))
|
||||
* **deps:** update dependency jws to v4 ([#251](https://www.github.com/googleapis/node-gtoken/issues/251)) ([e13542f](https://www.github.com/googleapis/node-gtoken/commit/e13542f888a81ed3ced0023e9b78ed25264b1d1c))
|
||||
|
||||
### [4.1.3](https://www.github.com/googleapis/node-gtoken/compare/v4.1.2...v4.1.3) (2019-11-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** use typescript ~3.6.0 ([#246](https://www.github.com/googleapis/node-gtoken/issues/246)) ([5f725b7](https://www.github.com/googleapis/node-gtoken/commit/5f725b71f080e83058b1a23340acadc0c8704123))
|
||||
|
||||
### [4.1.2](https://www.github.com/googleapis/node-gtoken/compare/v4.1.1...v4.1.2) (2019-11-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docs:** add jsdoc-region-tag plugin ([#242](https://www.github.com/googleapis/node-gtoken/issues/242)) ([994c5cc](https://www.github.com/googleapis/node-gtoken/commit/994c5ccf92731599aa63b84c29a9d5f6b1431cc5))
|
||||
|
||||
### [4.1.1](https://www.github.com/googleapis/node-gtoken/compare/v4.1.0...v4.1.1) (2019-10-31)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** update gaxios to 2.1.0 ([#238](https://www.github.com/googleapis/node-gtoken/issues/238)) ([bb12064](https://www.github.com/googleapis/node-gtoken/commit/bb1206420388399ef8992efe54c70bdb3fdcd965))
|
||||
|
||||
## [4.1.0](https://www.github.com/googleapis/node-gtoken/compare/v4.0.0...v4.1.0) (2019-09-24)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* allow upstream libraries to force token refresh ([#229](https://www.github.com/googleapis/node-gtoken/issues/229)) ([1fd4dd1](https://www.github.com/googleapis/node-gtoken/commit/1fd4dd1))
|
||||
|
||||
## [4.0.0](https://www.github.com/googleapis/node-gtoken/compare/v3.0.2...v4.0.0) (2019-07-09)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* This commit creates multiple breaking changes. The `getToken()`
|
||||
method previously returned `Promise<string>`, where the string was the
|
||||
`access_token` returned from the response. However, the `oauth2` endpoint could
|
||||
return a variety of other fields, such as an `id_token` in special cases.
|
||||
|
||||
```js
|
||||
const token = await getToken();
|
||||
// old response: 'some.access.token'
|
||||
// new response: { access_token: 'some.access.token'}
|
||||
```
|
||||
|
||||
To further support this change, the `GoogleToken` class no longer exposes
|
||||
a `token` variable. It now exposes `rawToken`, `accessToken`, and `idToken`
|
||||
fields which can be used to access the relevant values returned in the
|
||||
response.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* expose all fields from response ([#218](https://www.github.com/googleapis/node-gtoken/issues/218)) ([d463370](https://www.github.com/googleapis/node-gtoken/commit/d463370))
|
||||
|
||||
### [3.0.2](https://www.github.com/googleapis/node-gtoken/compare/v3.0.1...v3.0.2) (2019-06-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docs:** make anchors work in jsdoc ([#215](https://www.github.com/googleapis/node-gtoken/issues/215)) ([c5f6c89](https://www.github.com/googleapis/node-gtoken/commit/c5f6c89))
|
||||
|
||||
### [3.0.1](https://www.github.com/googleapis/node-gtoken/compare/v3.0.0...v3.0.1) (2019-06-13)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **docs:** move to new client docs URL ([#212](https://www.github.com/googleapis/node-gtoken/issues/212)) ([b7a8c75](https://www.github.com/googleapis/node-gtoken/commit/b7a8c75))
|
||||
|
||||
## [3.0.0](https://www.github.com/googleapis/node-gtoken/compare/v2.3.3...v3.0.0) (2019-05-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **deps:** update dependency gaxios to v2 ([#191](https://www.github.com/googleapis/node-gtoken/issues/191)) ([da65ea7](https://www.github.com/googleapis/node-gtoken/commit/da65ea7))
|
||||
* **deps:** update dependency google-p12-pem to v2 ([#196](https://www.github.com/googleapis/node-gtoken/issues/196)) ([b510f06](https://www.github.com/googleapis/node-gtoken/commit/b510f06))
|
||||
* fs.readFile does not exist in browser ([#186](https://www.github.com/googleapis/node-gtoken/issues/186)) ([a16d8e7](https://www.github.com/googleapis/node-gtoken/commit/a16d8e7))
|
||||
|
||||
|
||||
### Build System
|
||||
|
||||
* upgrade engines field to >=8.10.0 ([#194](https://www.github.com/googleapis/node-gtoken/issues/194)) ([ee4d6c8](https://www.github.com/googleapis/node-gtoken/commit/ee4d6c8))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* upgrade engines field to >=8.10.0 (#194)
|
||||
|
||||
## v2.3.3
|
||||
|
||||
03-13-2019 14:54 PDT
|
||||
|
||||
### Bug Fixes
|
||||
- fix: propagate error message ([#173](https://github.com/google/node-gtoken/pull/173))
|
||||
|
||||
### Documentation
|
||||
- docs: update links in contrib guide ([#171](https://github.com/google/node-gtoken/pull/171))
|
||||
- docs: move CONTRIBUTING.md to root ([#166](https://github.com/google/node-gtoken/pull/166))
|
||||
- docs: add lint/fix example to contributing guide ([#164](https://github.com/google/node-gtoken/pull/164))
|
||||
|
||||
### Internal / Testing Changes
|
||||
- build: Add docuploader credentials to node publish jobs ([#176](https://github.com/google/node-gtoken/pull/176))
|
||||
- build: use node10 to run samples-test, system-test etc ([#175](https://github.com/google/node-gtoken/pull/175))
|
||||
- build: update release configuration
|
||||
- chore(deps): update dependency mocha to v6
|
||||
- build: use linkinator for docs test ([#170](https://github.com/google/node-gtoken/pull/170))
|
||||
- build: create docs test npm scripts ([#169](https://github.com/google/node-gtoken/pull/169))
|
||||
- build: test using @grpc/grpc-js in CI ([#168](https://github.com/google/node-gtoken/pull/168))
|
||||
- build: ignore googleapis.com in doc link check ([#162](https://github.com/google/node-gtoken/pull/162))
|
||||
- build: check for 404s on all docs
|
||||
|
||||
## v2.3.2
|
||||
|
||||
01-09-2019 13:40 PST
|
||||
|
||||
### Documentation
|
||||
- docs: generate docs with compodoc ([#154](https://github.com/googleapis/node-gtoken/pull/154))
|
||||
- docs: fix up the readme ([#153](https://github.com/googleapis/node-gtoken/pull/153))
|
||||
|
||||
### Internal / Testing Changes
|
||||
- build: Re-generated to pick up changes in the API or client library generator. ([#158](https://github.com/googleapis/node-gtoken/pull/158))
|
||||
- build: check broken links in generated docs ([#152](https://github.com/googleapis/node-gtoken/pull/152))
|
||||
- fix: add a system test and get it passing ([#150](https://github.com/googleapis/node-gtoken/pull/150))
|
||||
- chore(build): inject yoshi automation key ([#149](https://github.com/googleapis/node-gtoken/pull/149))
|
||||
|
||||
## v2.3.1
|
||||
|
||||
12-10-2018 15:28 PST
|
||||
|
||||
### Dependencies
|
||||
- fix(deps): update dependency pify to v4 ([#87](https://github.com/google/node-gtoken/pull/87))
|
||||
- fix(deps): use gaxios for http requests ([#125](https://github.com/google/node-gtoken/pull/125))
|
||||
|
||||
### Internal / Testing Changes
|
||||
- build: add Kokoro configs for autorelease ([#143](https://github.com/google/node-gtoken/pull/143))
|
||||
- chore: always nyc report before calling codecov ([#141](https://github.com/google/node-gtoken/pull/141))
|
||||
- chore: nyc ignore build/test by default ([#140](https://github.com/google/node-gtoken/pull/140))
|
||||
- chore: update synth metadata and templates ([#138](https://github.com/google/node-gtoken/pull/138))
|
||||
- fix(build): fix system key decryption ([#133](https://github.com/google/node-gtoken/pull/133))
|
||||
- chore(deps): update dependency typescript to ~3.2.0 ([#132](https://github.com/google/node-gtoken/pull/132))
|
||||
- chore: add a synth.metadata
|
||||
- chore(deps): update dependency gts to ^0.9.0 ([#127](https://github.com/google/node-gtoken/pull/127))
|
||||
- chore: update eslintignore config ([#126](https://github.com/google/node-gtoken/pull/126))
|
||||
- chore: use latest npm on Windows ([#124](https://github.com/google/node-gtoken/pull/124))
|
||||
- chore: update CircleCI config ([#123](https://github.com/google/node-gtoken/pull/123))
|
||||
- chore: include build in eslintignore ([#120](https://github.com/google/node-gtoken/pull/120))
|
||||
- chore: update issue templates ([#116](https://github.com/google/node-gtoken/pull/116))
|
||||
- chore: remove old issue template ([#114](https://github.com/google/node-gtoken/pull/114))
|
||||
- build: run tests on node11 ([#113](https://github.com/google/node-gtoken/pull/113))
|
||||
- chore(deps): update dependency nock to v10 ([#111](https://github.com/google/node-gtoken/pull/111))
|
||||
- chores(build): do not collect sponge.xml from windows builds ([#112](https://github.com/google/node-gtoken/pull/112))
|
||||
- chore(deps): update dependency typescript to ~3.1.0 ([#110](https://github.com/google/node-gtoken/pull/110))
|
||||
- chores(build): run codecov on continuous builds ([#109](https://github.com/google/node-gtoken/pull/109))
|
||||
- chore: update new issue template ([#108](https://github.com/google/node-gtoken/pull/108))
|
||||
- chore: update CI config ([#105](https://github.com/google/node-gtoken/pull/105))
|
||||
- Update kokoro config ([#103](https://github.com/google/node-gtoken/pull/103))
|
||||
- Update CI config ([#101](https://github.com/google/node-gtoken/pull/101))
|
||||
- Don't publish sourcemaps ([#99](https://github.com/google/node-gtoken/pull/99))
|
||||
- Update kokoro config ([#97](https://github.com/google/node-gtoken/pull/97))
|
||||
- test: remove appveyor config ([#96](https://github.com/google/node-gtoken/pull/96))
|
||||
- Update CI config ([#95](https://github.com/google/node-gtoken/pull/95))
|
||||
- Enable prefer-const in the eslint config ([#94](https://github.com/google/node-gtoken/pull/94))
|
||||
- Enable no-var in eslint ([#93](https://github.com/google/node-gtoken/pull/93))
|
||||
- Update CI config ([#92](https://github.com/google/node-gtoken/pull/92))
|
||||
- Add synth and update CI config ([#91](https://github.com/google/node-gtoken/pull/91))
|
||||
- Retry npm install in CI ([#90](https://github.com/google/node-gtoken/pull/90))
|
||||
- chore(deps): update dependency nyc to v13 ([#88](https://github.com/google/node-gtoken/pull/88))
|
||||
- chore: ignore package-log.json ([#86](https://github.com/google/node-gtoken/pull/86))
|
||||
- chore: update renovate config ([#83](https://github.com/google/node-gtoken/pull/83))
|
||||
- chore(deps): lock file maintenance ([#85](https://github.com/google/node-gtoken/pull/85))
|
||||
- chore: remove greenkeeper badge ([#82](https://github.com/google/node-gtoken/pull/82))
|
||||
- test: throw on deprecation ([#81](https://github.com/google/node-gtoken/pull/81))
|
||||
- chore(deps): update dependency typescript to v3 ([#80](https://github.com/google/node-gtoken/pull/80))
|
||||
- chore: move mocha options to mocha.opts ([#78](https://github.com/google/node-gtoken/pull/78))
|
||||
- chore(deps): lock file maintenance ([#79](https://github.com/google/node-gtoken/pull/79))
|
||||
- test: use strictEqual in tests ([#76](https://github.com/google/node-gtoken/pull/76))
|
||||
- chore(deps): lock file maintenance ([#77](https://github.com/google/node-gtoken/pull/77))
|
||||
- chore(deps): update dependency typescript to ~2.9.0 ([#75](https://github.com/google/node-gtoken/pull/75))
|
||||
- chore: Configure Renovate ([#74](https://github.com/google/node-gtoken/pull/74))
|
||||
- Update gts to the latest version 🚀 ([#73](https://github.com/google/node-gtoken/pull/73))
|
||||
- Add Code of Conduct
|
||||
- build: start testing against Node 10 ([#69](https://github.com/google/node-gtoken/pull/69))
|
||||
- chore(package): update nyc to version 12.0.2 ([#67](https://github.com/google/node-gtoken/pull/67))
|
||||
- chore(package): update @types/node to version 10.0.3 ([#65](https://github.com/google/node-gtoken/pull/65))
|
||||
|
||||
### 2.0.0
|
||||
New features:
|
||||
- API now supports callback and promise based workflows
|
||||
|
||||
Breaking changes:
|
||||
- `GoogleToken` is now a class type, and must be instantiated.
|
||||
- `GoogleToken.expires_at` renamed to `GoogleToken.expiresAt`
|
||||
- `GoogleToken.raw_token` renamed to `GoogleToken.rawToken`
|
||||
- `GoogleToken.token_expires` renamed to `GoogleToken.tokenExpires`
|
21
node_modules/gtoken/LICENSE
generated
vendored
Normal file
21
node_modules/gtoken/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Ryan Seys
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
182
node_modules/gtoken/README.md
generated
vendored
Normal file
182
node_modules/gtoken/README.md
generated
vendored
Normal file
@ -0,0 +1,182 @@
|
||||
<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"/>
|
||||
|
||||
# [node-gtoken](https://github.com/googleapis/node-gtoken)
|
||||
|
||||
[![npm version][npm-image]][npm-url]
|
||||
[![Known Vulnerabilities][snyk-image]][snyk-url]
|
||||
[![codecov][codecov-image]][codecov-url]
|
||||
[![Code Style: Google][gts-image]][gts-url]
|
||||
|
||||
> Node.js Google Authentication Service Account Tokens
|
||||
|
||||
This 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.**
|
||||
|
||||
* [gtoken API Reference][client-docs]
|
||||
* [github.com/googleapis/node-gtoken](https://github.com/googleapis/node-gtoken)
|
||||
|
||||
## Installation
|
||||
|
||||
``` sh
|
||||
npm install gtoken
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Use with a `.pem` or `.p12` key file:
|
||||
|
||||
``` js
|
||||
const { GoogleToken } = require('gtoken');
|
||||
const gtoken = new GoogleToken({
|
||||
keyFile: 'path/to/key.pem', // or path to .p12 key file
|
||||
email: 'my_service_account_email@developer.gserviceaccount.com',
|
||||
scope: ['https://scope1', 'https://scope2'] // or space-delimited string of scopes
|
||||
});
|
||||
|
||||
gtoken.getToken((err, tokens) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
console.log(tokens);
|
||||
// {
|
||||
// access_token: 'very-secret-token',
|
||||
// expires_in: 3600,
|
||||
// token_type: 'Bearer'
|
||||
// }
|
||||
});
|
||||
```
|
||||
|
||||
You can also use the async/await style API:
|
||||
|
||||
``` js
|
||||
const tokens = await gtoken.getToken()
|
||||
console.log(tokens);
|
||||
```
|
||||
|
||||
Or use promises:
|
||||
|
||||
```js
|
||||
gtoken.getToken()
|
||||
.then(tokens => {
|
||||
console.log(tokens)
|
||||
})
|
||||
.catch(console.error);
|
||||
```
|
||||
|
||||
### Use with a service account `.json` key file:
|
||||
|
||||
``` js
|
||||
const { GoogleToken } = require('gtoken');
|
||||
const gtoken = new GoogleToken({
|
||||
keyFile: 'path/to/key.json',
|
||||
scope: ['https://scope1', 'https://scope2'] // or space-delimited string of scopes
|
||||
});
|
||||
|
||||
gtoken.getToken((err, tokens) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
console.log(tokens);
|
||||
});
|
||||
```
|
||||
|
||||
### Pass the private key as a string directly:
|
||||
|
||||
``` js
|
||||
const key = '-----BEGIN RSA PRIVATE KEY-----\nXXXXXXXXXXX...';
|
||||
const { GoogleToken } = require('gtoken');
|
||||
const gtoken = new GoogleToken({
|
||||
email: 'my_service_account_email@developer.gserviceaccount.com',
|
||||
scope: ['https://scope1', 'https://scope2'], // or space-delimited string of scopes
|
||||
key: key
|
||||
});
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
> Various options that can be set when creating initializing the `gtoken` object.
|
||||
|
||||
- `options.email or options.iss`: The service account email address.
|
||||
- `options.scope`: An array of scope strings or space-delimited string of scopes.
|
||||
- `options.sub`: The email address of the user requesting delegated access.
|
||||
- `options.keyFile`: The filename of `.json` key, `.pem` key or `.p12` key.
|
||||
- `options.key`: The raw RSA private key value, in place of using `options.keyFile`.
|
||||
|
||||
### .getToken(callback)
|
||||
|
||||
> Returns the cached tokens or requests a new one and returns it.
|
||||
|
||||
``` js
|
||||
gtoken.getToken((err, token) => {
|
||||
console.log(err || token);
|
||||
// gtoken.rawToken value is also set
|
||||
});
|
||||
```
|
||||
|
||||
### .getCredentials('path/to/key.json')
|
||||
|
||||
> Given a keyfile, returns the key and (if available) the client email.
|
||||
|
||||
```js
|
||||
const creds = await gtoken.getCredentials('path/to/key.json');
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
> Various properties set on the gtoken object after call to `.getToken()`.
|
||||
|
||||
- `gtoken.idToken`: The OIDC token returned (if any).
|
||||
- `gtoken.accessToken`: The access token.
|
||||
- `gtoken.expiresAt`: The expiry date as milliseconds since 1970/01/01
|
||||
- `gtoken.key`: The raw key value.
|
||||
- `gtoken.rawToken`: Most recent raw token data received from Google.
|
||||
|
||||
### .hasExpired()
|
||||
|
||||
> Returns true if the token has expired, or token does not exist.
|
||||
|
||||
``` js
|
||||
const tokens = await gtoken.getToken();
|
||||
gtoken.hasExpired(); // false
|
||||
```
|
||||
|
||||
### .revokeToken()
|
||||
|
||||
> Revoke the token if set.
|
||||
|
||||
``` js
|
||||
await gtoken.revokeToken();
|
||||
console.log('Token revoked!');
|
||||
```
|
||||
|
||||
## Downloading your private `.p12` key from Google
|
||||
|
||||
1. Open the [Google Developer Console][gdevconsole].
|
||||
2. Open your project and under "APIs & auth", click Credentials.
|
||||
3. Generate a new `.p12` key and download it into your project.
|
||||
|
||||
## Converting your `.p12` key to a `.pem` key
|
||||
|
||||
You can just specify your `.p12` file (with `.p12` extension) as the `keyFile` and it will automatically be converted to a `.pem` on the fly, however this results in a slight performance hit. If you'd like to convert to a `.pem` for use later, use OpenSSL if you have it installed.
|
||||
|
||||
``` sh
|
||||
$ openssl pkcs12 -in key.p12 -nodes -nocerts > key.pem
|
||||
```
|
||||
|
||||
Don't forget, the passphrase when converting these files is the string `'notasecret'`
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://github.com/googleapis/node-gtoken/blob/master/LICENSE)
|
||||
|
||||
[codecov-image]: https://codecov.io/gh/googleapis/node-gtoken/branch/master/graph/badge.svg
|
||||
[codecov-url]: https://codecov.io/gh/googleapis/node-gtoken
|
||||
[gdevconsole]: https://console.developers.google.com
|
||||
[gts-image]: https://img.shields.io/badge/code%20style-google-blueviolet.svg
|
||||
[gts-url]: https://www.npmjs.com/package/gts
|
||||
[npm-image]: https://img.shields.io/npm/v/gtoken.svg
|
||||
[npm-url]: https://npmjs.org/package/gtoken
|
||||
[snyk-image]: https://snyk.io/test/github/googleapis/node-gtoken/badge.svg
|
||||
[snyk-url]: https://snyk.io/test/github/googleapis/node-gtoken
|
||||
[client-docs]: https://googleapis.dev/nodejs/gtoken/latest/
|
90
node_modules/gtoken/build/src/index.d.ts
generated
vendored
Normal file
90
node_modules/gtoken/build/src/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Distributed under MIT license.
|
||||
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
export declare type GetTokenCallback = (err: Error | null, token?: TokenData) => void;
|
||||
export interface Credentials {
|
||||
privateKey: string;
|
||||
clientEmail?: string;
|
||||
}
|
||||
export interface TokenData {
|
||||
refresh_token?: string;
|
||||
expires_in?: number;
|
||||
access_token?: string;
|
||||
token_type?: string;
|
||||
id_token?: string;
|
||||
}
|
||||
export interface TokenOptions {
|
||||
keyFile?: string;
|
||||
key?: string;
|
||||
email?: string;
|
||||
iss?: string;
|
||||
sub?: string;
|
||||
scope?: string | string[];
|
||||
additionalClaims?: {};
|
||||
}
|
||||
export interface GetTokenOptions {
|
||||
forceRefresh?: boolean;
|
||||
}
|
||||
export declare class GoogleToken {
|
||||
readonly accessToken: string | undefined;
|
||||
readonly idToken: string | undefined;
|
||||
readonly tokenType: string | undefined;
|
||||
readonly refreshToken: string | undefined;
|
||||
expiresAt?: number;
|
||||
key?: string;
|
||||
keyFile?: string;
|
||||
iss?: string;
|
||||
sub?: string;
|
||||
scope?: string;
|
||||
rawToken?: TokenData;
|
||||
tokenExpires?: number;
|
||||
email?: string;
|
||||
additionalClaims?: {};
|
||||
/**
|
||||
* Create a GoogleToken.
|
||||
*
|
||||
* @param options Configuration object.
|
||||
*/
|
||||
constructor(options?: TokenOptions);
|
||||
/**
|
||||
* Returns whether the token has expired.
|
||||
*
|
||||
* @return true if the token has expired, false otherwise.
|
||||
*/
|
||||
hasExpired(): boolean;
|
||||
/**
|
||||
* Returns a cached token or retrieves a new one from Google.
|
||||
*
|
||||
* @param callback The callback function.
|
||||
*/
|
||||
getToken(opts?: GetTokenOptions): Promise<TokenData>;
|
||||
getToken(callback: GetTokenCallback, opts?: GetTokenOptions): void;
|
||||
/**
|
||||
* Given a keyFile, extract the key and client email if available
|
||||
* @param keyFile Path to a json, pem, or p12 file that contains the key.
|
||||
* @returns an object with privateKey and clientEmail properties
|
||||
*/
|
||||
getCredentials(keyFile: string): Promise<Credentials>;
|
||||
private getTokenAsync;
|
||||
private ensureEmail;
|
||||
/**
|
||||
* Revoke the token if one is set.
|
||||
*
|
||||
* @param callback The callback function.
|
||||
*/
|
||||
revokeToken(): Promise<void>;
|
||||
revokeToken(callback: (err?: Error) => void): void;
|
||||
private revokeTokenAsync;
|
||||
/**
|
||||
* Configure the GoogleToken for re-use.
|
||||
* @param {object} options Configuration object.
|
||||
*/
|
||||
private configure;
|
||||
/**
|
||||
* Request the token from Google.
|
||||
*/
|
||||
private requestToken;
|
||||
}
|
234
node_modules/gtoken/build/src/index.js
generated
vendored
Normal file
234
node_modules/gtoken/build/src/index.js
generated
vendored
Normal file
@ -0,0 +1,234 @@
|
||||
"use strict";
|
||||
/**
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* Distributed under MIT license.
|
||||
* See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
|
||||
*/
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = require("fs");
|
||||
const gaxios_1 = require("gaxios");
|
||||
const jws = require("jws");
|
||||
const mime = require("mime");
|
||||
const util_1 = require("util");
|
||||
const readFile = fs.readFile
|
||||
? util_1.promisify(fs.readFile)
|
||||
: async () => {
|
||||
// if running in the web-browser, fs.readFile may not have been shimmed.
|
||||
throw new ErrorWithCode('use key rather than keyFile.', 'MISSING_CREDENTIALS');
|
||||
};
|
||||
const GOOGLE_TOKEN_URL = 'https://www.googleapis.com/oauth2/v4/token';
|
||||
const GOOGLE_REVOKE_TOKEN_URL = 'https://accounts.google.com/o/oauth2/revoke?token=';
|
||||
class ErrorWithCode extends Error {
|
||||
constructor(message, code) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
}
|
||||
let getPem;
|
||||
class GoogleToken {
|
||||
/**
|
||||
* Create a GoogleToken.
|
||||
*
|
||||
* @param options Configuration object.
|
||||
*/
|
||||
constructor(options) {
|
||||
this.configure(options);
|
||||
}
|
||||
get accessToken() {
|
||||
return this.rawToken ? this.rawToken.access_token : undefined;
|
||||
}
|
||||
get idToken() {
|
||||
return this.rawToken ? this.rawToken.id_token : undefined;
|
||||
}
|
||||
get tokenType() {
|
||||
return this.rawToken ? this.rawToken.token_type : undefined;
|
||||
}
|
||||
get refreshToken() {
|
||||
return this.rawToken ? this.rawToken.refresh_token : undefined;
|
||||
}
|
||||
/**
|
||||
* Returns whether the token has expired.
|
||||
*
|
||||
* @return true if the token has expired, false otherwise.
|
||||
*/
|
||||
hasExpired() {
|
||||
const now = new Date().getTime();
|
||||
if (this.rawToken && this.expiresAt) {
|
||||
return now >= this.expiresAt;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
getToken(callback, opts = {}) {
|
||||
if (typeof callback === 'object') {
|
||||
opts = callback;
|
||||
callback = undefined;
|
||||
}
|
||||
opts = Object.assign({
|
||||
forceRefresh: false,
|
||||
}, opts);
|
||||
if (callback) {
|
||||
const cb = callback;
|
||||
this.getTokenAsync(opts).then(t => cb(null, t), callback);
|
||||
return;
|
||||
}
|
||||
return this.getTokenAsync(opts);
|
||||
}
|
||||
/**
|
||||
* Given a keyFile, extract the key and client email if available
|
||||
* @param keyFile Path to a json, pem, or p12 file that contains the key.
|
||||
* @returns an object with privateKey and clientEmail properties
|
||||
*/
|
||||
async getCredentials(keyFile) {
|
||||
const mimeType = mime.getType(keyFile);
|
||||
switch (mimeType) {
|
||||
case 'application/json': {
|
||||
// *.json file
|
||||
const key = await readFile(keyFile, 'utf8');
|
||||
const body = JSON.parse(key);
|
||||
const privateKey = body.private_key;
|
||||
const clientEmail = body.client_email;
|
||||
if (!privateKey || !clientEmail) {
|
||||
throw new ErrorWithCode('private_key and client_email are required.', 'MISSING_CREDENTIALS');
|
||||
}
|
||||
return { privateKey, clientEmail };
|
||||
}
|
||||
case 'application/x-x509-ca-cert': {
|
||||
// *.pem file
|
||||
const privateKey = await readFile(keyFile, 'utf8');
|
||||
return { privateKey };
|
||||
}
|
||||
case 'application/x-pkcs12': {
|
||||
// *.p12 file
|
||||
// NOTE: The loading of `google-p12-pem` is deferred for performance
|
||||
// reasons. The `node-forge` npm module in `google-p12-pem` adds a fair
|
||||
// bit time to overall module loading, and is likely not frequently
|
||||
// used. In a future release, p12 support will be entirely removed.
|
||||
if (!getPem) {
|
||||
getPem = (await Promise.resolve().then(() => require('google-p12-pem'))).getPem;
|
||||
}
|
||||
const privateKey = await getPem(keyFile);
|
||||
return { privateKey };
|
||||
}
|
||||
default:
|
||||
throw new ErrorWithCode('Unknown certificate type. Type is determined based on file extension. ' +
|
||||
'Current supported extensions are *.json, *.pem, and *.p12.', 'UNKNOWN_CERTIFICATE_TYPE');
|
||||
}
|
||||
}
|
||||
async getTokenAsync(opts) {
|
||||
if (this.hasExpired() === false && opts.forceRefresh === false) {
|
||||
return Promise.resolve(this.rawToken);
|
||||
}
|
||||
if (!this.key && !this.keyFile) {
|
||||
throw new Error('No key or keyFile set.');
|
||||
}
|
||||
if (!this.key && this.keyFile) {
|
||||
const creds = await this.getCredentials(this.keyFile);
|
||||
this.key = creds.privateKey;
|
||||
this.iss = creds.clientEmail || this.iss;
|
||||
if (!creds.clientEmail) {
|
||||
this.ensureEmail();
|
||||
}
|
||||
}
|
||||
return this.requestToken();
|
||||
}
|
||||
ensureEmail() {
|
||||
if (!this.iss) {
|
||||
throw new ErrorWithCode('email is required.', 'MISSING_CREDENTIALS');
|
||||
}
|
||||
}
|
||||
revokeToken(callback) {
|
||||
if (callback) {
|
||||
this.revokeTokenAsync().then(() => callback(), callback);
|
||||
return;
|
||||
}
|
||||
return this.revokeTokenAsync();
|
||||
}
|
||||
async revokeTokenAsync() {
|
||||
if (!this.accessToken) {
|
||||
throw new Error('No token to revoke.');
|
||||
}
|
||||
const url = GOOGLE_REVOKE_TOKEN_URL + this.accessToken;
|
||||
await gaxios_1.request({ url });
|
||||
this.configure({
|
||||
email: this.iss,
|
||||
sub: this.sub,
|
||||
key: this.key,
|
||||
keyFile: this.keyFile,
|
||||
scope: this.scope,
|
||||
additionalClaims: this.additionalClaims,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* Configure the GoogleToken for re-use.
|
||||
* @param {object} options Configuration object.
|
||||
*/
|
||||
configure(options = {}) {
|
||||
this.keyFile = options.keyFile;
|
||||
this.key = options.key;
|
||||
this.rawToken = undefined;
|
||||
this.iss = options.email || options.iss;
|
||||
this.sub = options.sub;
|
||||
this.additionalClaims = options.additionalClaims;
|
||||
if (typeof options.scope === 'object') {
|
||||
this.scope = options.scope.join(' ');
|
||||
}
|
||||
else {
|
||||
this.scope = options.scope;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Request the token from Google.
|
||||
*/
|
||||
async requestToken() {
|
||||
const iat = Math.floor(new Date().getTime() / 1000);
|
||||
const additionalClaims = this.additionalClaims || {};
|
||||
const payload = Object.assign({
|
||||
iss: this.iss,
|
||||
scope: this.scope,
|
||||
aud: GOOGLE_TOKEN_URL,
|
||||
exp: iat + 3600,
|
||||
iat,
|
||||
sub: this.sub,
|
||||
}, additionalClaims);
|
||||
const signedJWT = jws.sign({
|
||||
header: { alg: 'RS256' },
|
||||
payload,
|
||||
secret: this.key,
|
||||
});
|
||||
try {
|
||||
const r = await gaxios_1.request({
|
||||
method: 'POST',
|
||||
url: GOOGLE_TOKEN_URL,
|
||||
data: {
|
||||
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
||||
assertion: signedJWT,
|
||||
},
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
responseType: 'json',
|
||||
});
|
||||
this.rawToken = r.data;
|
||||
this.expiresAt =
|
||||
r.data.expires_in === null || r.data.expires_in === undefined
|
||||
? undefined
|
||||
: (iat + r.data.expires_in) * 1000;
|
||||
return this.rawToken;
|
||||
}
|
||||
catch (e) {
|
||||
this.rawToken = undefined;
|
||||
this.tokenExpires = undefined;
|
||||
const body = e.response && e.response.data ? e.response.data : {};
|
||||
if (body.error) {
|
||||
const desc = body.error_description
|
||||
? `: ${body.error_description}`
|
||||
: '';
|
||||
e.message = `${body.error}${desc}`;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.GoogleToken = GoogleToken;
|
||||
//# sourceMappingURL=index.js.map
|
99
node_modules/gtoken/package.json
generated
vendored
Normal file
99
node_modules/gtoken/package.json
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
{
|
||||
"_from": "gtoken@^4.1.0",
|
||||
"_id": "gtoken@4.1.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-VxirzD0SWoFUo5p8RDP8Jt2AGyOmyYcT/pOUgDKJCK+iSw0TMqwrVfY37RXTNmoKwrzmDHSk0GMT9FsgVmnVSA==",
|
||||
"_location": "/gtoken",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "gtoken@^4.1.0",
|
||||
"name": "gtoken",
|
||||
"escapedName": "gtoken",
|
||||
"rawSpec": "^4.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^4.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/google-auth-library"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/gtoken/-/gtoken-4.1.4.tgz",
|
||||
"_shasum": "925ff1e7df3aaada06611d30ea2d2abf60fcd6a7",
|
||||
"_spec": "gtoken@^4.1.0",
|
||||
"_where": "C:\\Users\\matia\\Documents\\GitHub\\Musix-V3\\node_modules\\google-auth-library",
|
||||
"author": {
|
||||
"name": "Google, LLC"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/google/node-gtoken/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"gaxios": "^2.1.0",
|
||||
"google-p12-pem": "^2.0.0",
|
||||
"jws": "^4.0.0",
|
||||
"mime": "^2.2.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Node.js Google Authentication Service Account Tokens",
|
||||
"devDependencies": {
|
||||
"@compodoc/compodoc": "^1.1.7",
|
||||
"@types/jws": "^3.1.0",
|
||||
"@types/mime": "^2.0.0",
|
||||
"@types/mocha": "^5.0.0",
|
||||
"@types/nock": "^10.0.0",
|
||||
"@types/node": "^10.0.3",
|
||||
"c8": "^7.0.0",
|
||||
"codecov": "^3.0.2",
|
||||
"gts": "^1.0.0",
|
||||
"intelli-espower-loader": "^1.0.1",
|
||||
"js-green-licenses": "^1.0.0",
|
||||
"linkinator": "^1.5.0",
|
||||
"mocha": "^7.0.0",
|
||||
"nock": "^11.3.2",
|
||||
"source-map-support": "^0.5.6",
|
||||
"typescript": "3.6.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8.10.0"
|
||||
},
|
||||
"files": [
|
||||
"build/src",
|
||||
"!build/src/**/*.map"
|
||||
],
|
||||
"homepage": "https://github.com/google/node-gtoken#readme",
|
||||
"keywords": [
|
||||
"google",
|
||||
"service",
|
||||
"account",
|
||||
"api",
|
||||
"token",
|
||||
"api",
|
||||
"auth"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./build/src/index.js",
|
||||
"name": "gtoken",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/google/node-gtoken.git"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "gts clean",
|
||||
"compile": "tsc -p .",
|
||||
"docs": "compodoc src/",
|
||||
"docs-test": "linkinator docs",
|
||||
"fix": "gts fix",
|
||||
"lint": "gts check",
|
||||
"predocs-test": "npm run docs",
|
||||
"prepare": "npm run compile",
|
||||
"presystem-test": "npm run compile",
|
||||
"pretest": "npm run compile",
|
||||
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
|
||||
"system-test": "mocha build/system-test",
|
||||
"test": "c8 mocha build/test"
|
||||
},
|
||||
"types": "./build/src/index.d.ts",
|
||||
"version": "4.1.4"
|
||||
}
|
Reference in New Issue
Block a user