|
|
@ -820,7 +820,7 @@ var clearOwnedChannel = function (Env, channelId, unsafeKey, cb) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var removeOwnedBlob = function (Env, blobId, unsafeKey, cb) { // FIXME deletion
|
|
|
|
var removeOwnedBlob = function (Env, blobId, unsafeKey, cb) {
|
|
|
|
var safeKey = escapeKeyCharacters(unsafeKey);
|
|
|
|
var safeKey = escapeKeyCharacters(unsafeKey);
|
|
|
|
var safeKeyPrefix = safeKey.slice(0,3);
|
|
|
|
var safeKeyPrefix = safeKey.slice(0,3);
|
|
|
|
var blobPrefix = blobId.slice(0,2);
|
|
|
|
var blobPrefix = blobId.slice(0,2);
|
|
|
@ -858,6 +858,11 @@ var removeOwnedBlob = function (Env, blobId, unsafeKey, cb) { // FIXME deletion
|
|
|
|
// Delete the blob
|
|
|
|
// Delete the blob
|
|
|
|
/*:: if (typeof(blobPath) !== 'string') { throw new Error('should never happen'); } */
|
|
|
|
/*:: if (typeof(blobPath) !== 'string') { throw new Error('should never happen'); } */
|
|
|
|
Fs.unlink(blobPath, w(function (e) { // TODO move to cold storage
|
|
|
|
Fs.unlink(blobPath, w(function (e) { // TODO move to cold storage
|
|
|
|
|
|
|
|
Log.info('DELETION_OWNED_FILE_BY_OWNER_RPC', {
|
|
|
|
|
|
|
|
safeKey: safeKey,
|
|
|
|
|
|
|
|
blobPath: blobPath,
|
|
|
|
|
|
|
|
status: e? String(e): 'SUCCESS',
|
|
|
|
|
|
|
|
});
|
|
|
|
if (e) {
|
|
|
|
if (e) {
|
|
|
|
w.abort();
|
|
|
|
w.abort();
|
|
|
|
return void cb(e.code);
|
|
|
|
return void cb(e.code);
|
|
|
@ -866,12 +871,17 @@ var removeOwnedBlob = function (Env, blobId, unsafeKey, cb) { // FIXME deletion
|
|
|
|
}).nThen(function () {
|
|
|
|
}).nThen(function () {
|
|
|
|
// Delete the proof of ownership
|
|
|
|
// Delete the proof of ownership
|
|
|
|
Fs.unlink(ownPath, function (e) {
|
|
|
|
Fs.unlink(ownPath, function (e) {
|
|
|
|
|
|
|
|
Log.info('DELETION_OWNED_FILE_PROOF_BY_OWNER_RPC', {
|
|
|
|
|
|
|
|
safeKey: safeKey,
|
|
|
|
|
|
|
|
proofPath: ownPath,
|
|
|
|
|
|
|
|
status: e? String(e): 'SUCCESS',
|
|
|
|
|
|
|
|
});
|
|
|
|
cb(e && e.code);
|
|
|
|
cb(e && e.code);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var removeOwnedChannel = function (Env, channelId, unsafeKey, cb) { // FIXME deletion
|
|
|
|
var removeOwnedChannel = function (Env, channelId, unsafeKey, cb) {
|
|
|
|
if (typeof(channelId) !== 'string' || !isValidId(channelId)) {
|
|
|
|
if (typeof(channelId) !== 'string' || !isValidId(channelId)) {
|
|
|
|
return cb('INVALID_ARGUMENTS');
|
|
|
|
return cb('INVALID_ARGUMENTS');
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -891,6 +901,11 @@ var removeOwnedChannel = function (Env, channelId, unsafeKey, cb) { // FIXME del
|
|
|
|
return void cb('INSUFFICIENT_PERMISSIONS');
|
|
|
|
return void cb('INSUFFICIENT_PERMISSIONS');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return void Env.msgStore.removeChannel(channelId, function (e) {
|
|
|
|
return void Env.msgStore.removeChannel(channelId, function (e) {
|
|
|
|
|
|
|
|
Log.info('DELETION_CHANNEL_BY_OWNER_RPC', {
|
|
|
|
|
|
|
|
unsafeKey: unsafeKey,
|
|
|
|
|
|
|
|
channelId: channelId,
|
|
|
|
|
|
|
|
status: e? String(e): 'SUCCESS',
|
|
|
|
|
|
|
|
});
|
|
|
|
cb(e);
|
|
|
|
cb(e);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -898,11 +913,16 @@ var removeOwnedChannel = function (Env, channelId, unsafeKey, cb) { // FIXME del
|
|
|
|
|
|
|
|
|
|
|
|
/* Users should be able to clear their own pin log with an authenticated RPC
|
|
|
|
/* Users should be able to clear their own pin log with an authenticated RPC
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
var removePins = function (Env, safeKey, cb) { // FIXME deletion
|
|
|
|
var removePins = function (Env, safeKey, cb) {
|
|
|
|
if (typeof(Env.pinStore.removeChannel) !== 'function') {
|
|
|
|
if (typeof(Env.pinStore.removeChannel) !== 'function') {
|
|
|
|
return void cb("E_NOT_IMPLEMENTED");
|
|
|
|
return void cb("E_NOT_IMPLEMENTED");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Env.pinStore.removeChannel(safeKey, function (err) {
|
|
|
|
Env.pinStore.removeChannel(safeKey, function (err) {
|
|
|
|
|
|
|
|
Log.info('DELETION_PIN_BY_OWNER_RPC', {
|
|
|
|
|
|
|
|
safeKey: safeKey,
|
|
|
|
|
|
|
|
status: err? String(err): 'SUCCESS',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
cb(err);
|
|
|
|
cb(err);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -1400,7 +1420,6 @@ var removeLoginBlock = function (Env, msg, cb) {
|
|
|
|
var signature = msg[1];
|
|
|
|
var signature = msg[1];
|
|
|
|
var block = Nacl.util.decodeUTF8('DELETE_BLOCK'); // clients and the server will have to agree on this constant
|
|
|
|
var block = Nacl.util.decodeUTF8('DELETE_BLOCK'); // clients and the server will have to agree on this constant
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME deletion
|
|
|
|
|
|
|
|
validateLoginBlock(Env, publicKey, signature, block, function (e /*::, validatedBlock */) {
|
|
|
|
validateLoginBlock(Env, publicKey, signature, block, function (e /*::, validatedBlock */) {
|
|
|
|
if (e) { return void cb(e); }
|
|
|
|
if (e) { return void cb(e); }
|
|
|
|
// derive the filepath
|
|
|
|
// derive the filepath
|
|
|
@ -1412,6 +1431,12 @@ var removeLoginBlock = function (Env, msg, cb) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Fs.unlink(path, function (err) {
|
|
|
|
Fs.unlink(path, function (err) {
|
|
|
|
|
|
|
|
Log.info('DELETION_BLOCK_BY_OWNER_RPC', {
|
|
|
|
|
|
|
|
publicKey: publicKey,
|
|
|
|
|
|
|
|
path: path,
|
|
|
|
|
|
|
|
status: err? String(err): 'SUCCESS',
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (err) { return void cb(err); }
|
|
|
|
if (err) { return void cb(err); }
|
|
|
|
cb();
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
});
|
|
|
|