Comparing version 1.0.0-beta to 1.1.0-beta
{ | ||
"name": "code-push", | ||
"version": "1.0.0-beta", | ||
"description": "Source code for the CodePush service SDK", | ||
"version": "1.1.0-beta", | ||
"description": "Management SDK for the CodePush service", | ||
"main": "script/index.js", | ||
@@ -13,3 +13,5 @@ "scripts": { | ||
}, | ||
"author": "Microsoft", | ||
"author": "Microsoft Corporation", | ||
"license": "MIT", | ||
"homepage": "https://microsoft.github.io/code-push", | ||
"dependencies": { | ||
@@ -23,2 +25,2 @@ "base-64": "^0.1.0", | ||
} | ||
} | ||
} |
@@ -36,12 +36,16 @@ var base64 = require("base-64"); | ||
var loginInfo = AccountManager.getLoginInfo(accessToken); | ||
if (!loginInfo || !loginInfo.providerName || !loginInfo.providerUniqueId) { | ||
reject({ message: "Invalid access key." }); | ||
return; | ||
} | ||
var req = request.post(_this.serverUrl + "/auth/login/accessToken"); | ||
_this.attachCredentials(req, request); | ||
req.type("form") | ||
.send({ identity: JSON.stringify({ providerName: loginInfo.providerName, providerUniqueId: loginInfo.providerUniqueId }) }) | ||
.send({ token: loginInfo.accessKeyName }) | ||
.end(function (err, res) { | ||
req = req.type("form"); | ||
if (loginInfo && loginInfo.providerName && loginInfo.providerUniqueId) { | ||
// Login the old way. | ||
req = req.send({ identity: JSON.stringify({ providerName: loginInfo.providerName, providerUniqueId: loginInfo.providerUniqueId }) }) | ||
.send({ token: loginInfo.accessKeyName }); | ||
} | ||
else { | ||
// Note: We can't send an empty identity string, or PassportAuth will short circuit and fail. | ||
req = req.send({ identity: "accessKey" }) | ||
.send({ token: accessToken }); | ||
} | ||
req.end(function (err, res) { | ||
if (err) { | ||
@@ -117,6 +121,6 @@ reject({ message: _this.getErrorMessage(err, res) }); | ||
}; | ||
AccountManager.prototype.addAccessKey = function (description) { | ||
AccountManager.prototype.addAccessKey = function (machine, description) { | ||
var _this = this; | ||
return Promise(function (resolve, reject, notify) { | ||
var accessKey = { id: null, name: uuid.v4(), description: description }; | ||
var accessKey = { id: null, name: uuid.v4(), createdTime: new Date().getTime(), createdBy: machine, description: description }; | ||
var requester = _this._authedAgent ? _this._authedAgent : request; | ||
@@ -803,2 +807,28 @@ var req = requester.post(_this.serverUrl + "/accessKeys/"); | ||
}; | ||
AccountManager.prototype.promotePackage = function (appId, sourceDeploymentId, destDeploymentId) { | ||
var _this = this; | ||
return Promise(function (resolve, reject, notify) { | ||
var requester = (_this._authedAgent ? _this._authedAgent : request); | ||
var req = requester.post(_this.serverUrl + "/apps/" + appId + "/deployments/" + sourceDeploymentId + "/promote/" + destDeploymentId); | ||
_this.attachCredentials(req, requester); | ||
req.end(function (err, res) { | ||
if (err) { | ||
reject({ message: _this.getErrorMessage(err, res) }); | ||
return; | ||
} | ||
if (res.ok) { | ||
resolve(null); | ||
} | ||
else { | ||
var body = tryJSON(res.text); | ||
if (body) { | ||
reject(body); | ||
} | ||
else { | ||
reject({ message: res.text, statusCode: res.status }); | ||
} | ||
} | ||
}); | ||
}); | ||
}; | ||
AccountManager.prototype.getPackage = function (appId, deploymentId) { | ||
@@ -836,4 +866,9 @@ var _this = this; | ||
AccountManager.getLoginInfo = function (accessKey) { | ||
var decoded = base64.decode(accessKey); | ||
return tryJSON(decoded); | ||
try { | ||
var decoded = base64.decode(accessKey); | ||
return tryJSON(decoded); | ||
} | ||
catch (ex) { | ||
return null; | ||
} | ||
}; | ||
@@ -840,0 +875,0 @@ AccountManager.prototype.getErrorMessage = function (error, response) { |
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
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
67181
1621
1