From ff9a107a299e3978e05bbe25ace66cddac07e80e Mon Sep 17 00:00:00 2001 From: ehuggett Date: Thu, 21 Dec 2017 15:54:19 +0000 Subject: [PATCH 1/2] API changes to accommodate 3rd party clients --- server/routes/exists.js | 7 +++++-- server/routes/metadata.js | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/routes/exists.js b/server/routes/exists.js index e22bf21f..fa683e0d 100644 --- a/server/routes/exists.js +++ b/server/routes/exists.js @@ -11,8 +11,11 @@ module.exports = async (req, res) => { } try { - await storage.exists(id); - res.sendStatus(200); + const meta = await storage.metadata(id); + res.set('WWW-Authenticate', `send-v1 ${meta.nonce}`); + res.send({ + password: meta.pwd + }); } catch (e) { res.sendStatus(404); } diff --git a/server/routes/metadata.js b/server/routes/metadata.js index 558e6a7b..6bf75071 100644 --- a/server/routes/metadata.js +++ b/server/routes/metadata.js @@ -29,6 +29,8 @@ module.exports = async function(req, res) { const ttl = await storage.ttl(id); res.send({ metadata: meta.metadata, + dtotal: meta.dl, + dlimit: meta.dlimit, size, ttl }); From ebbf06787c969cae2cf59fa295b12d148b7f5dd7 Mon Sep 17 00:00:00 2001 From: ehuggett Date: Sat, 23 Dec 2017 05:09:06 +0000 Subject: [PATCH 2/2] changes requested in review --- server/routes/exists.js | 2 +- server/routes/metadata.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/routes/exists.js b/server/routes/exists.js index fa683e0d..4268e673 100644 --- a/server/routes/exists.js +++ b/server/routes/exists.js @@ -14,7 +14,7 @@ module.exports = async (req, res) => { const meta = await storage.metadata(id); res.set('WWW-Authenticate', `send-v1 ${meta.nonce}`); res.send({ - password: meta.pwd + password: meta.pwd !== '0' }); } catch (e) { res.sendStatus(404); diff --git a/server/routes/metadata.js b/server/routes/metadata.js index 6bf75071..60e38c58 100644 --- a/server/routes/metadata.js +++ b/server/routes/metadata.js @@ -29,8 +29,8 @@ module.exports = async function(req, res) { const ttl = await storage.ttl(id); res.send({ metadata: meta.metadata, - dtotal: meta.dl, - dlimit: meta.dlimit, + dtotal: +meta.dl, + dlimit: +meta.dlimit, size, ttl });