diff --git a/plugins/c9.core/ext.js b/plugins/c9.core/ext.js index 5768c28a..b110b6c5 100644 --- a/plugins/c9.core/ext.js +++ b/plugins/c9.core/ext.js @@ -575,51 +575,6 @@ define(function(require, exports, module) { } } - function setAPIKey(apikey){ - // Validate Key - if (!apikey || !apikey.match(/^.{27}=$/)) - throw new Error("Invalid API key"); - - return { - getPersistentData: getPersistentData.bind(this, apikey), - setPersistentData: setPersistentData.bind(this, apikey) - }; - } - - function getPersistentData(apiKey, context, callback){ - var type; - - if (!apiKey) - throw new Error("API Key not set. Please call plugin.setAPIKey(options.key);"); - - if (context == "user") type = "user"; - else if (context == "workspace") type = "project"; - else throw new Error("Unsupported context: " + context); - - api[type].get("persistent/" + apiKey, function(err, data){ - if (err) return callback(err); - try { callback(null, JSON.parse(data)); } - catch(e){ return callback(e); } - }); - } - - function setPersistentData(apiKey, context, data, callback){ - var type; - - if (!apiKey) - throw new Error("API Key not set. Please call plugin.setAPIKey(options.key);"); - - if (context == "user") type = "user"; - else if (context == "workspace") type = "project"; - else throw new Error("Unsupported context: " + context); - - api[type].put("persistent/" + apiKey, { - body: { - data: JSON.stringify(data) - } - }, callback); - } - /***** Register and define API *****/ this.baseclass(); @@ -886,11 +841,6 @@ define(function(require, exports, module) { */ cleanUp: cleanUp, - /** - * - */ - setAPIKey: setAPIKey, - /** * Adds an event handler to this plugin. Note that unlike the * event implementation you know from the browser, you are diff --git a/plugins/c9.vfs.standalone/standalone.js b/plugins/c9.vfs.standalone/standalone.js index 8270e02e..7470c8ab 100644 --- a/plugins/c9.vfs.standalone/standalone.js +++ b/plugins/c9.vfs.standalone/standalone.js @@ -223,54 +223,6 @@ function plugin(options, imports, register) { api.get("/api.json", {name: "api"}, frontdoor.middleware.describeApi(api)); - api.get("/api/project/:pid/persistent/:apikey", { - params: { - pid: { type: "number" }, - apikey: { type: "string" } - } - }, persistentDataApiMock); - api.put("/api/project/:pid/persistent/:apikey", { - params: { - data: { type: "string", source: "body" }, - pid: { type: "number" }, - apikey: { type: "string" }, - } - }, persistentDataApiMock); - api.get("/api/user/persistent/:apikey", { - params: { - apikey: { type: "string" } - } - }, persistentDataApiMock); - api.put("/api/user/persistent/:apikey", { - params: { - data: { type: "string", source: "body" }, - apikey: { type: "string" }, - } - }, persistentDataApiMock); - - function persistentDataApiMock(req, res, next) { - var name = (req.params.pid || 0) + "-" + req.params.apikey; - var data = req.params.data; - console.log(name, data) - if (/[^\w+=\-]/.test(name)) - return next(new Error("Invalid apikey")); - var path = join(options.installPath, ".c9", "persistent"); - var method = req.method.toLowerCase() - if (method == "get") { - res.writeHead(200, {"Content-Type": "application/octet-stream"}); - var stream = fs.createReadStream(path + "/" + name); - stream.pipe(res); - } else if (method == "put") { - require("mkdirp")(path, function(e) { - fs.writeFile(path + "/" + name, data, "", function(err) { - if (err) return next(err); - res.writeHead(200, {"Content-Type": "application/octet-stream"}); - res.end(""); - }); - }); - } - } - // fake authentication api.authenticate = api.authenticate || function() { return function(req, res, next) {