graphcool-yml
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -6,5 +6,6 @@ import 'isomorphic-fetch'; | ||
local: boolean; | ||
private clusterToken?; | ||
constructor(name: string, baseUrl: string, token?: string, local?: boolean); | ||
readonly token: string | undefined; | ||
clusterSecret?: string; | ||
private cachedToken?; | ||
constructor(name: string, baseUrl: string, clusterSecret?: string, local?: boolean); | ||
readonly token: string; | ||
getApiEndpoint(serviceName: string, stage: string): string; | ||
@@ -11,0 +12,0 @@ getWSEndpoint(serviceName: string, stage: string): string; |
@@ -40,8 +40,9 @@ "use strict"; | ||
require("isomorphic-fetch"); | ||
var jwt = require("jsonwebtoken"); | ||
var Cluster = /** @class */ (function () { | ||
function Cluster(name, baseUrl, token, local) { | ||
function Cluster(name, baseUrl, clusterSecret, local) { | ||
if (local === void 0) { local = true; } | ||
this.name = name; | ||
this.baseUrl = baseUrl; | ||
this.clusterToken = token; | ||
this.clusterSecret = clusterSecret; | ||
this.local = local; | ||
@@ -51,3 +52,17 @@ } | ||
get: function () { | ||
return this.clusterToken; | ||
if (!this.clusterSecret) { | ||
return ''; | ||
} | ||
// public clusters just take the token | ||
if (!this.local) { | ||
return this.clusterSecret; | ||
} | ||
if (!this.cachedToken) { | ||
var grants = [{ target: "*/*/*", action: '*' }]; | ||
this.cachedToken = jwt.sign({ grants: grants }, this.clusterSecret, { | ||
expiresIn: '10 minutes', | ||
algorithm: 'RS256', | ||
}); | ||
} | ||
return this.cachedToken; | ||
}, | ||
@@ -54,0 +69,0 @@ enumerable: true, |
@@ -133,2 +133,6 @@ "use strict"; | ||
Environment.prototype.addCluster = function (cluster) { | ||
var existingClusterIndex = this.clusters.findIndex(function (c) { return c.name === cluster.name; }); | ||
if (existingClusterIndex > -1) { | ||
this.clusters.splice(existingClusterIndex, 1); | ||
} | ||
this.clusters.push(cluster); | ||
@@ -239,3 +243,3 @@ }; | ||
host: cluster.baseUrl, | ||
clusterSecret: cluster.token, | ||
clusterSecret: cluster.clusterSecret, | ||
}, _a)); | ||
@@ -242,0 +246,0 @@ var _a; |
{ | ||
"name": "graphcool-yml", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152918
2165