Socket
Socket
Sign inDemoInstall

gtoken

Package Overview
Dependencies
Maintainers
4
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gtoken - npm Package Compare versions

Comparing version 6.1.2 to 7.0.0

2

build/src/index.d.ts

@@ -11,3 +11,3 @@ /**

}
export declare type GetTokenCallback = (err: Error | null, token?: TokenData) => void;
export type GetTokenCallback = (err: Error | null, token?: TokenData) => void;
export interface Credentials {

@@ -14,0 +14,0 @@ privateKey: string;

@@ -29,15 +29,3 @@ "use strict";

}
let getPem;
class GoogleToken {
/**
* Create a GoogleToken.
*
* @param options Configuration object.
*/
constructor(options) {
this.transporter = {
request: opts => (0, gaxios_1.request)(opts),
};
this.configure(options);
}
get accessToken() {

@@ -56,2 +44,13 @@ return this.rawToken ? this.rawToken.access_token : undefined;

/**
* Create a GoogleToken.
*
* @param options Configuration object.
*/
constructor(options) {
this.transporter = {
request: opts => (0, gaxios_1.request)(opts),
};
this.configure(options);
}
/**
* Returns whether the token has expired.

@@ -127,15 +126,8 @@ *

case '.pfx': {
// 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 };
throw new ErrorWithCode('*.p12 certificates are not supported after v6.1.2. ' +
'Consider utilizing *.json format or converting *.p12 to *.pem using the OpenSSL CLI.', 'UNKNOWN_CERTIFICATE_TYPE');
}
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');
'Current supported extensions are *.json, and *.pem.', 'UNKNOWN_CERTIFICATE_TYPE');
}

@@ -142,0 +134,0 @@ }

@@ -7,2 +7,19 @@ # Changelog

## [7.0.0](https://github.com/googleapis/node-gtoken/compare/v6.1.2...v7.0.0) (2023-07-11)
### ⚠ BREAKING CHANGES
* move to node 14 as minimum version ([#457](https://github.com/googleapis/node-gtoken/issues/457))
* remove support for conversion of *.p12 to *.pem ([#452](https://github.com/googleapis/node-gtoken/issues/452))
### Features
* Remove support for conversion of *.p12 to *.pem ([#452](https://github.com/googleapis/node-gtoken/issues/452)) ([522a96d](https://github.com/googleapis/node-gtoken/commit/522a96dd38ad5d486e9337f72efdf1a5523fded4))
### Miscellaneous Chores
* Move to node 14 as minimum version ([#457](https://github.com/googleapis/node-gtoken/issues/457)) ([429df81](https://github.com/googleapis/node-gtoken/commit/429df814cd4224d5eacce72cfe8e924e53cc7f30))
## [6.1.2](https://github.com/googleapis/node-gtoken/compare/v6.1.1...v6.1.2) (2022-08-23)

@@ -9,0 +26,0 @@

{
"name": "gtoken",
"version": "6.1.2",
"version": "7.0.0",
"description": "Node.js Google Authentication Service Account Tokens",

@@ -8,3 +8,3 @@ "main": "./build/src/index.js",

"engines": {
"node": ">=12.0.0"
"node": ">=14.0.0"
},

@@ -44,16 +44,16 @@ "repository": "google/node-gtoken",

"gaxios": "^5.0.1",
"google-p12-pem": "^4.0.0",
"jws": "^4.0.0"
},
"devDependencies": {
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@compodoc/compodoc": "^1.1.7",
"@types/jws": "^3.1.0",
"@types/mocha": "^9.0.0",
"@types/node": "^16.0.0",
"c8": "^7.0.0",
"gts": "^3.0.0",
"@types/node": "^18.0.0",
"c8": "^8.0.0",
"gts": "^3.1.1",
"linkinator": "^4.0.0",
"mocha": "^9.2.2",
"nock": "^13.0.0",
"typescript": "^4.6.4"
"typescript": "^5.1.6"
},

@@ -60,0 +60,0 @@ "files": [

@@ -25,3 +25,3 @@ <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"/>

### Use with a `.pem` or `.p12` key file:
### Use with a `.pem` or `.json` key file:

@@ -31,3 +31,3 @@ ``` js

const gtoken = new GoogleToken({
keyFile: 'path/to/key.pem', // or path to .p12 key file
keyFile: 'path/to/key.pem', // or path to .json key file
email: 'my_service_account_email@developer.gserviceaccount.com',

@@ -108,3 +108,3 @@ scope: ['https://scope1', 'https://scope2'], // 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.keyFile`: The filename of `.json` key or `.pem` key.
- `options.key`: The raw RSA private key value, in place of using `options.keyFile`.

@@ -161,11 +161,11 @@ - `options.additionalClaims`: Additional claims to include in the JWT when requesting a token.

## Downloading your private `.p12` key from Google
## Downloading your private `.json` 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.
3. Generate a new `.json` 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.
If you'd like to convert to a `.pem` for use later, use OpenSSL if you have it installed.

@@ -172,0 +172,0 @@ ``` sh

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc