Skip to content

Commit

Permalink
Add legacy code suggested in googleapis/gaxios#44 as a hack for now
Browse files Browse the repository at this point in the history
  • Loading branch information
attaboy authored and daemon committed Mar 8, 2019
1 parent 074b44d commit 146c831
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "Growers Journal",
"exportId" : "Q-lhGNVPQtm9tII_-P6TGQ",
"exportId" : "meSL7qkeTAC8BvAVMtSL0g",
"icon" : "🗒",
"requiredAWSConfigs" : [ ],
"requiredOAuthApiConfigs" : [ ],
Expand Down
19 changes: 18 additions & 1 deletion lib/google-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@
@exportId F27x9o81SQKunXWbmDUWNw
*/
module.exports = (function() {
const url = require('url'); // legacy Node6 url
const semver = require('semver');
class Node6CompatibilityURL {
constructor(str) {
this.url = url.parse(str);
this.origin = this.url.protocol + '//';
this.pathname = this.url.pathname ? this.url.pathname : '';
this.search = this.url.search ? this.url.search : '';
this.href = this.url.href ? this.url.href : '';
}
}

if (semver.lt(process.version, '6.13.0')) {
window = {};
window.URL = Node6CompatibilityURL; // no warranty 😱
}

return function(ellipsis) {
const { JWT } = ellipsis.require('google-auth-library@2.0.2');
const { JWT } = ellipsis.require('google-auth-library@3.1.0');
return new JWT({
email: ellipsis.env.GOOGLE_SERVICE_ACCOUNT_EMAIL,
key: ellipsis.env.GOOGLE_SERVICE_ACCOUNT_PRIVATE_KEY,
Expand Down

0 comments on commit 146c831

Please sign in to comment.