implement removeLoginBlock rpc
This commit is contained in:
parent
577dea4c75
commit
cb5fa72dba
9
rpc.js
9
rpc.js
@ -1859,9 +1859,12 @@ RPC.create = function (
|
|||||||
Respond(e);
|
Respond(e);
|
||||||
});
|
});
|
||||||
case 'REMOVE_LOGIN_BLOCK':
|
case 'REMOVE_LOGIN_BLOCK':
|
||||||
return void removeLoginBlock(Env, msg, function (e) {
|
return void removeLoginBlock(Env, msg[1], function (e) {
|
||||||
// TODO handle response
|
if (e) {
|
||||||
e = e;
|
WARN(e, 'REMOVE_LOGIN_BLOCK');
|
||||||
|
return void Respond(e);
|
||||||
|
}
|
||||||
|
Respond(e);
|
||||||
});
|
});
|
||||||
default:
|
default:
|
||||||
return void Respond('UNSUPPORTED_RPC_CALL', msg);
|
return void Respond('UNSUPPORTED_RPC_CALL', msg);
|
||||||
|
|||||||
@ -240,6 +240,12 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
common.removeLoginBlock = function (data, cb) {
|
||||||
|
postMessage('REMOVE_LOGIN_BLOCK', data, function (obj) {
|
||||||
|
cb(obj);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// ANON RPC
|
// ANON RPC
|
||||||
|
|
||||||
// SFRAME: talk to anon_rpc from the iframe
|
// SFRAME: talk to anon_rpc from the iframe
|
||||||
|
|||||||
@ -13,7 +13,7 @@ define([
|
|||||||
'/common/outer/network-config.js',
|
'/common/outer/network-config.js',
|
||||||
'/customize/application_config.js',
|
'/customize/application_config.js',
|
||||||
|
|
||||||
'/bower_components/chainpad-crypto/crypto.js?v=0.1.5',
|
'/bower_components/chainpad-crypto/crypto.js',
|
||||||
'/bower_components/chainpad/chainpad.dist.js',
|
'/bower_components/chainpad/chainpad.dist.js',
|
||||||
'/bower_components/chainpad-listmap/chainpad-listmap.js',
|
'/bower_components/chainpad-listmap/chainpad-listmap.js',
|
||||||
'/bower_components/nthen/index.js',
|
'/bower_components/nthen/index.js',
|
||||||
@ -285,6 +285,15 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Store.removeLoginBlock = function (clientId, data, cb) {
|
||||||
|
store.rpc.removeLoginBlock(data, function (e, res) {
|
||||||
|
cb({
|
||||||
|
error: e,
|
||||||
|
data: res
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
Store.initRpc = function (clientId, data, cb) {
|
Store.initRpc = function (clientId, data, cb) {
|
||||||
if (store.rpc) { return void cb(account); }
|
if (store.rpc) { return void cb(account); }
|
||||||
require(['/common/pinpad.js'], function (Pinpad) {
|
require(['/common/pinpad.js'], function (Pinpad) {
|
||||||
|
|||||||
@ -75,5 +75,16 @@ define([
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Block.remove = function (keys) {
|
||||||
|
// sign the hash of the text 'DELETE_BLOCK'
|
||||||
|
var sig = Nacl.sign.detached(Nacl.hash(
|
||||||
|
Nacl.util.decodeUTF8('DELETE_BLOCK')), keys.sign.secretKey);
|
||||||
|
|
||||||
|
return {
|
||||||
|
publicKey: Nacl.util.encodeBase64(keys.sign.publicKey),
|
||||||
|
signature: Nacl.util.encodeBase64(sig),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
return Block;
|
return Block;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -24,6 +24,7 @@ define([
|
|||||||
UPLOAD_STATUS: Store.uploadStatus,
|
UPLOAD_STATUS: Store.uploadStatus,
|
||||||
UPLOAD_CANCEL: Store.uploadCancel,
|
UPLOAD_CANCEL: Store.uploadCancel,
|
||||||
WRITE_LOGIN_BLOCK: Store.writeLoginBlock,
|
WRITE_LOGIN_BLOCK: Store.writeLoginBlock,
|
||||||
|
REMOVE_LOGIN_BLOCK: Store.removeLoginBlock,
|
||||||
PIN_PADS: Store.pinPads,
|
PIN_PADS: Store.pinPads,
|
||||||
UNPIN_PADS: Store.unpinPads,
|
UNPIN_PADS: Store.unpinPads,
|
||||||
GET_DELETED_PADS: Store.getDeletedPads,
|
GET_DELETED_PADS: Store.getDeletedPads,
|
||||||
|
|||||||
@ -237,6 +237,21 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exp.removeLoginBlock = function (data, cb) {
|
||||||
|
if (!data) { return void cb('NO_DATA'); }
|
||||||
|
if (!data.publicKey || !data.signature) {
|
||||||
|
console.log(data);
|
||||||
|
return void cb("MISSING_PARAMETERS");
|
||||||
|
}
|
||||||
|
|
||||||
|
rpc.send('REMOVE_LOGIN_BLOCK', [
|
||||||
|
data.publicKey, // publicKey
|
||||||
|
data.signature, // signature
|
||||||
|
], function (e) {
|
||||||
|
cb(e);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
cb(e, exp);
|
cb(e, exp);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -647,6 +647,10 @@ define([
|
|||||||
Cryptpad.writeLoginBlock(data, cb);
|
Cryptpad.writeLoginBlock(data, cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sframeChan.on('Q_REMOVE_LOGIN_BLOCK', function (data, cb) {
|
||||||
|
Cryptpad.removeLoginBlock(data, cb);
|
||||||
|
});
|
||||||
|
|
||||||
if (cfg.addRpc) {
|
if (cfg.addRpc) {
|
||||||
cfg.addRpc(sframeChan, Cryptpad, Utils);
|
cfg.addRpc(sframeChan, Cryptpad, Utils);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,6 +77,9 @@ define({
|
|||||||
// Write/update the login block when the account password is changed
|
// Write/update the login block when the account password is changed
|
||||||
'Q_WRITE_LOGIN_BLOCK': true,
|
'Q_WRITE_LOGIN_BLOCK': true,
|
||||||
|
|
||||||
|
// Remove login blocks
|
||||||
|
'Q_REMOVE_LOGIN_BLOCK': true,
|
||||||
|
|
||||||
// Check the pin limit to determine if we can store the pad in the drive or if we should.
|
// Check the pin limit to determine if we can store the pad in the drive or if we should.
|
||||||
// display a warning
|
// display a warning
|
||||||
'Q_GET_PIN_LIMIT_STATUS': true,
|
'Q_GET_PIN_LIMIT_STATUS': true,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user