|
|
|
@ -25,14 +25,15 @@ const API_METHOD_CONFIG_PASSIVE_MODE = "config_passive_mode";
|
|
|
|
|
const API_METHOD_CONFIG_UNENCRYPTED_SUBJECT = "config_unencrypted_subject";
|
|
|
|
|
const API_METHOD_CONFIG_PASSPHRASE = "config_passphrase";
|
|
|
|
|
const API_METHOD_CONFIG_PASSPHRASE_FOR_NEW_KEYS = "config_passphrase_for_new_keys";
|
|
|
|
|
const API_METHOD_GET_KEY_MISTRUSTED = "key_mistrusted";
|
|
|
|
|
const API_METHOD_GET_TRUST_PERSONAL_KEY = "trust_personal_key";
|
|
|
|
|
const API_METHOD_GET_KEY_RESET_TRUST = "key_reset_trust";
|
|
|
|
|
const API_METHOD_GET_KEY_RESET_USER = "key_reset_user";
|
|
|
|
|
const API_METHOD_GET_KEY_RESET_IDENTITY = "key_reset_identity";
|
|
|
|
|
const API_METHOD_GET_KEY_RESET_ALL_OWN_KEYS = "key_reset_all_own_keys";
|
|
|
|
|
const API_METHOD_GET_IMPORT_KEY = "import_key";
|
|
|
|
|
const API_METHOD_GET_SET_OWN_KEY = "set_own_key";
|
|
|
|
|
const API_METHOD_KEY_MISTRUSTED = "key_mistrusted";
|
|
|
|
|
const API_METHOD_TRUST_PERSONAL_KEY = "trust_personal_key";
|
|
|
|
|
const API_METHOD_KEY_RESET_TRUST = "key_reset_trust";
|
|
|
|
|
const API_METHOD_KEY_RESET_USER = "key_reset_user";
|
|
|
|
|
const API_METHOD_KEY_RESET_IDENTITY = "key_reset_identity";
|
|
|
|
|
const API_METHOD_KEY_RESET_ALL_OWN_KEYS = "key_reset_all_own_keys";
|
|
|
|
|
const API_METHOD_IMPORT_KEY = "import_key";
|
|
|
|
|
const API_METHOD_SET_OWN_KEY = "set_own_key";
|
|
|
|
|
const API_METHOD_SET_COMM_PARTNER_KEY = "set_comm_partner_key";
|
|
|
|
|
|
|
|
|
|
const API_METHOD_ENABLE_IDENTITY_FOR_SYNC = "enable_identity_for_sync";
|
|
|
|
|
const API_METHOD_DISABLE_IDENTITY_FOR_SYNC = "disable_identity_for_sync";
|
|
|
|
@ -70,6 +71,13 @@ class pEpAdapter {
|
|
|
|
|
this.server = server;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
checkError(funcName, response) {
|
|
|
|
|
this.log.debug(`pEpAdapter: ${funcName}. Return value:`, response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
throw new Error(`${funcName} returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async delegateCallPepAdapter(funcType, functionName, paramsArr) {
|
|
|
|
|
let response = await this.server.callPepAdapter(funcType, functionName, paramsArr);
|
|
|
|
|
|
|
|
|
@ -93,7 +101,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async serverVersion() {
|
|
|
|
|
this.log.info("pEpAdapter.js: serverVersion()");
|
|
|
|
|
this.log.info("pEpAdapter entry: serverVersion()");
|
|
|
|
|
const params = [];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -106,7 +114,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async config_passive_mode(enable) {
|
|
|
|
|
this.log.info("pEpAdapter.js: config_passive_mode()");
|
|
|
|
|
this.log.info("pEpAdapter entry: config_passive_mode()");
|
|
|
|
|
const params = [enable];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -119,7 +127,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async config_unencrypted_subject(enable) {
|
|
|
|
|
this.log.info("pEpAdapter.js: config_unencrypted_subject()");
|
|
|
|
|
this.log.info("pEpAdapter entry: config_unencrypted_subject()");
|
|
|
|
|
const params = [enable];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -132,7 +140,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async config_passphrase(passphrase) {
|
|
|
|
|
this.log.info("pEpAdapter.js: config_passphrase()");
|
|
|
|
|
this.log.info("pEpAdapter entry: config_passphrase()");
|
|
|
|
|
const params = [passphrase];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -145,7 +153,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async config_passphrase_for_new_keys(enable, passphrase) {
|
|
|
|
|
this.log.info("pEpAdapter.js: config_passphrase_for_new_keys()");
|
|
|
|
|
this.log.info("pEpAdapter entry: config_passphrase_for_new_keys()");
|
|
|
|
|
const params = [enable, passphrase];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -158,17 +166,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async outgoing_message_rating(message, preview) {
|
|
|
|
|
this.log.info("pEpAdapter.js: outgoing_message_rating()");
|
|
|
|
|
this.log.info("pEpAdapter entry: outgoing_message_rating()");
|
|
|
|
|
const params = [message, "OUT"];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
preview ? API_METHOD_OUTGOING_MESSAGE_RATING_PREVIEW : API_METHOD_OUTGOING_MESSAGE_RATING,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: outgoing_message_rating()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(preview ? API_METHOD_OUTGOING_MESSAGE_RATING_PREVIEW : API_METHOD_OUTGOING_MESSAGE_RATING, response);
|
|
|
|
|
return response.result.outParams[0].rating;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -177,17 +182,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async outgoing_message_rating_with_partner_info(message) {
|
|
|
|
|
this.log.info("pEpAdapter.js: outgoing_message_rating_with_partner_info()");
|
|
|
|
|
this.log.info("pEpAdapter entry: outgoing_message_rating_with_partner_info()");
|
|
|
|
|
const params = [message, "OUT", "OUT"];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_OUTGOING_MESSAGE_RATING_WPI,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: outgoing_message_rating_with_partner_info()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_OUTGOING_MESSAGE_RATING_WPI, response);
|
|
|
|
|
return { rating: response.result.outParams[1].rating, onlyPEP: response.result.outParams[0] };
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -196,17 +198,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async re_evaluate_message_rating(message, keyList, oldRating) {
|
|
|
|
|
this.log.info("pEpAdapter.js: re_evaluate_message_rating()");
|
|
|
|
|
this.log.info("pEpAdapter entry: re_evaluate_message_rating()", message.from, keyList, oldRating);
|
|
|
|
|
const params = [message, keyList, { rating: oldRating }, "OUT"];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_RE_EVALUATE_MESSAGE_RATING,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: re_evaluate_message_rating()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_RE_EVALUATE_MESSAGE_RATING, response);
|
|
|
|
|
return response.result.outParams[0].rating;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -215,17 +214,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async myself(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: myself()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: myself()", identity);
|
|
|
|
|
const params = [identity];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_MYSELF,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: myself()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_MYSELF, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -234,17 +230,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async set_identity(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: set_identity()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: set_identity()", identity);
|
|
|
|
|
const params = [identity];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_SET_IDENTITY,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: set_identity()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_SET_IDENTITY, response);
|
|
|
|
|
return null;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -253,17 +246,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async update_identity(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: update_identity()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: update_identity()", identity);
|
|
|
|
|
const params = [identity];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_UPDATE_IDENTITY,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: update_identity()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_UPDATE_IDENTITY, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -272,7 +262,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async get_trustwords(identity1, identity2, language, full) {
|
|
|
|
|
this.log.info("pEpAdapter.js: get_trustwords()", identity1, identity2);
|
|
|
|
|
this.log.info("pEpAdapter entry: get_trustwords()", identity1, identity2);
|
|
|
|
|
|
|
|
|
|
const params = [identity1, identity2, language, "OUT", "OUT", full];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
@ -280,10 +270,7 @@ class pEpAdapter {
|
|
|
|
|
API_METHOD_GET_TRUSTWORDS,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: get_trustwords()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_GET_TRUSTWORDS, response);
|
|
|
|
|
return response.result.outParams[1];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
// TODO Validate length (outParams[0]) with words (outParams[1])
|
|
|
|
@ -293,7 +280,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async get_languagelist() {
|
|
|
|
|
this.log.info("pEpAdapter.js: get_languagelist()");
|
|
|
|
|
this.log.info("pEpAdapter entry: get_languagelist()");
|
|
|
|
|
|
|
|
|
|
const params = ["OUT"];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
@ -307,17 +294,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async trust_personal_key(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: trust_personal_key()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: trust_personal_key()", identity);
|
|
|
|
|
const params = [identity];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_GET_TRUST_PERSONAL_KEY,
|
|
|
|
|
API_METHOD_TRUST_PERSONAL_KEY,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: trust_personal_key()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_TRUST_PERSONAL_KEY, response);
|
|
|
|
|
return response.result.outParams;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -326,17 +310,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async key_reset_trust(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: key_reset_trust()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: key_reset_trust()", identity);
|
|
|
|
|
const params = [identity];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_GET_KEY_RESET_TRUST,
|
|
|
|
|
API_METHOD_KEY_RESET_TRUST,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: key_reset_trust()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_KEY_RESET_TRUST, response);
|
|
|
|
|
return response.result.outParams;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -345,17 +326,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async key_reset_user(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: key_reset_user()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: key_reset_user()", identity);
|
|
|
|
|
const params = [identity.user_id, identity.fpr];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_GET_KEY_RESET_USER,
|
|
|
|
|
API_METHOD_KEY_RESET_USER,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: key_reset_user()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_KEY_RESET_USER, response);
|
|
|
|
|
return response.result.outParams;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -364,17 +342,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async key_reset_identity(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: key_reset_identity()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: key_reset_identity()", identity);
|
|
|
|
|
const params = [identity, identity.fpr];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_GET_KEY_RESET_IDENTITY,
|
|
|
|
|
API_METHOD_KEY_RESET_IDENTITY,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: key_reset_identity()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_KEY_RESET_IDENTITY, response);
|
|
|
|
|
return response.result.outParams;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -383,17 +358,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async key_reset_all_own_keys() {
|
|
|
|
|
this.log.info("pEpAdapter.js: key_reset_all_own_keys()");
|
|
|
|
|
this.log.info("pEpAdapter entry: key_reset_all_own_keys()");
|
|
|
|
|
const params = [];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_GET_KEY_RESET_ALL_OWN_KEYS,
|
|
|
|
|
API_METHOD_KEY_RESET_ALL_OWN_KEYS,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: key_reset_all_own_keys()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_KEY_RESET_ALL_OWN_KEYS, response);
|
|
|
|
|
return response.result.outParams;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -402,17 +374,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async key_mistrusted(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: key_mistrusted()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: key_mistrusted()", identity);
|
|
|
|
|
const params = [identity];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_GET_KEY_MISTRUSTED,
|
|
|
|
|
API_METHOD_KEY_MISTRUSTED,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: key_mistrusted()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_KEY_MISTRUSTED, response);
|
|
|
|
|
return response.result.outParams;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -421,11 +390,11 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async import_key(keydata) {
|
|
|
|
|
this.log.info("pEpAdapter.js: import_key()", keydata);
|
|
|
|
|
this.log.info("pEpAdapter entry: import_key()", keydata);
|
|
|
|
|
const params = [keydata, keydata.length, ["OP"]];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_GET_IMPORT_KEY,
|
|
|
|
|
API_METHOD_IMPORT_KEY,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
if ((typeof (response) === "object") && response.hasOwnProperty("error")) {
|
|
|
|
@ -435,12 +404,11 @@ class pEpAdapter {
|
|
|
|
|
if (response.result.return.hasOwnProperty("status")) {
|
|
|
|
|
switch (response.result.return.status) {
|
|
|
|
|
case PEP_KEY_IMPORTED:
|
|
|
|
|
this.log.debug("callPepAdapter: 'import_key' returned with success: ", response);
|
|
|
|
|
this.log.debug("import_key returned with success: ", response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
this.log.debug("callPepAdapter: 'import_key' returned with error: ", response);
|
|
|
|
|
throw new Error(`import key error ${response.result.return.status}`);
|
|
|
|
|
this.checkError(API_METHOD_IMPORT_KEY, response);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Hmm, no error and no result?
|
|
|
|
@ -452,17 +420,30 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async set_own_key(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: set_own_key()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: set_own_key()", identity);
|
|
|
|
|
const params = [identity, identity.fpr];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_GET_SET_OWN_KEY,
|
|
|
|
|
API_METHOD_SET_OWN_KEY,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: set_own_key()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_SET_OWN_KEY, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
|
throw err;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async set_comm_partner_key(identity, fpr) {
|
|
|
|
|
this.log.info("pEpAdapter entry: set_comm_partner_key()", identity, fpr);
|
|
|
|
|
const params = [identity, fpr];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_SET_COMM_PARTNER_KEY,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.checkError(API_METHOD_SET_COMM_PARTNER_KEY, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -471,17 +452,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async is_pEp_user(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: is_pEp_user()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: is_pEp_user()", identity);
|
|
|
|
|
const params = [identity, true];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_IS_PEP_USER,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: is_pEp_user()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_IS_PEP_USER, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -490,17 +468,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async cache_mime_decode_message(message, size) {
|
|
|
|
|
this.log.info("pEpAdapter.js: cache_mime_decode_message()");
|
|
|
|
|
this.log.info("pEpAdapter entry: cache_mime_decode_message()");
|
|
|
|
|
const params = [message, size, ["OP"]];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_CACHE_MIME_DECODE_MESSAGE,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: cache_mime_decode_message()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_CACHE_MIME_DECODE_MESSAGE, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -509,7 +484,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async cache_mime_encode_message(srcDst, message, omit_fields) {
|
|
|
|
|
this.log.info("pEpAdapter.js: cache_mime_encode_message()");
|
|
|
|
|
this.log.info("pEpAdapter entry: cache_mime_encode_message()");
|
|
|
|
|
const params = [srcDst, message, omit_fields, ["OP"]];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -519,10 +494,7 @@ class pEpAdapter {
|
|
|
|
|
if ((typeof (response) === "object") && response.hasOwnProperty("error")) {
|
|
|
|
|
throw new Error(response.error.message);
|
|
|
|
|
}
|
|
|
|
|
this.log.debug("pEpAdapter.js: cache_mime_encode_message()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_CACHE_MIME_ENCODE_MESSAGE, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -531,7 +503,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async cache_release(msgID) {
|
|
|
|
|
this.log.info("pEpAdapter.js: cache_release()");
|
|
|
|
|
this.log.info("pEpAdapter entry: cache_release()");
|
|
|
|
|
const params = [msgID];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -544,7 +516,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async cache_decrypt_message(message) {
|
|
|
|
|
this.log.info("pEpAdapter.js: cache_decrypt_message()", message);
|
|
|
|
|
this.log.info("pEpAdapter entry: cache_decrypt_message()", message);
|
|
|
|
|
const params = [
|
|
|
|
|
message, // message input
|
|
|
|
|
["OP"], // message output
|
|
|
|
@ -573,7 +545,7 @@ class pEpAdapter {
|
|
|
|
|
decryptedMessage.rating = response.result.outParams[1].rating;
|
|
|
|
|
decryptedMessage.enc_format = ENC_FORMAT_DECRYPTED; // Sucessfully decrypted.
|
|
|
|
|
|
|
|
|
|
this.log.debug("callPepAdapter: 'cache_decrypt_message' returned with success: ", response);
|
|
|
|
|
this.log.debug("cache_decrypt_message returned with success:", response);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// Workaround for https://pep.foundation/jira/browse/ENGINE-756.
|
|
|
|
@ -583,13 +555,13 @@ class pEpAdapter {
|
|
|
|
|
decryptedMessage.rating = response.result.outParams[1].rating;
|
|
|
|
|
decryptedMessage.enc_format = ENC_FORMAT_DECRYPTED; // Sucessfully decrypted.
|
|
|
|
|
this.log.debug(
|
|
|
|
|
"callPepAdapter: 'cache_decrypt_message' returned with PEP_VERIFY_SIGNER_KEY_REVOKED (decrypted): ", response,
|
|
|
|
|
"cache_decrypt_message returned with PEP_VERIFY_SIGNER_KEY_REVOKED (decrypted):", response,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
decryptedMessage = response.result.outParams[4];
|
|
|
|
|
decryptedMessage.rating = response.result.outParams[1].rating;
|
|
|
|
|
this.log.debug(
|
|
|
|
|
"callPepAdapter: 'cache_decrypt_message' returned with PEP_VERIFY_SIGNER_KEY_REVOKED (NOT decrypted) status: ",
|
|
|
|
|
"cache_decrypt_message returned with PEP_VERIFY_SIGNER_KEY_REVOKED (NOT decrypted) status:",
|
|
|
|
|
response,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -601,15 +573,14 @@ class pEpAdapter {
|
|
|
|
|
decryptedMessage.rating = response.result.outParams[1].rating;
|
|
|
|
|
decryptedMessage.enc_format = ENC_FORMAT_DECRYPTED; // Sucessfully decrypted.
|
|
|
|
|
this.log.debug(
|
|
|
|
|
"callPepAdapter: 'cache_decrypt_message' returned with PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH (decrypted): ",
|
|
|
|
|
"cache_decrypt_message returned with PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH (decrypted):",
|
|
|
|
|
response,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
decryptedMessage = response.result.outParams[4];
|
|
|
|
|
decryptedMessage.rating = response.result.outParams[1].rating;
|
|
|
|
|
this.log.debug(
|
|
|
|
|
// eslint-disable-next-line max-len
|
|
|
|
|
"callPepAdapter: 'cache_decrypt_message' returned with PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH (NOT decrypted) status: ",
|
|
|
|
|
"cache_decrypt_message returned with PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH (NOT decrypted) status:",
|
|
|
|
|
response,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -619,18 +590,17 @@ class pEpAdapter {
|
|
|
|
|
decryptedMessage = response.result.outParams[4];
|
|
|
|
|
decryptedMessage.rating = response.result.outParams[1].rating;
|
|
|
|
|
decryptedMessage.enc_format = ENC_FORMAT_NONE; // This wasn't encrypted to start with.
|
|
|
|
|
this.log.debug("callPepAdapter: 'cache_decrypt_message' returned with UNENCRYPTED status: ", response);
|
|
|
|
|
this.log.debug("cache_decrypt_message returned with UNENCRYPTED status:", response);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case PEP_DECRYPT_NO_KEY:
|
|
|
|
|
decryptedMessage = response.result.outParams[4];
|
|
|
|
|
decryptedMessage.rating = response.result.outParams[1].rating;
|
|
|
|
|
this.log.debug("callPepAdapter: 'cache_decrypt_message' returned with DECRYPT_NO_KEY status: ", response);
|
|
|
|
|
this.log.debug("cache_decrypt_message returned with DECRYPT_NO_KEY status:", response);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
this.log.debug("callPepAdapter: 'cache_decrypt_message' returned with error: ", response);
|
|
|
|
|
throw new Error(`decrypt error ${response.result.return.status}`);
|
|
|
|
|
this.checkError(API_METHOD_CACHE_DECRYPT_MESSAGE, response);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -650,7 +620,7 @@ class pEpAdapter {
|
|
|
|
|
encFormat, // Encoding Format
|
|
|
|
|
0, // Flags
|
|
|
|
|
]);
|
|
|
|
|
this.log.info("pEpAdapter.js: cache_encrypt_message()", message);
|
|
|
|
|
this.log.info("pEpAdapter entry: cache_encrypt_message()", message);
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
isDraftOrTemplate ? API_METHOD_CACHE_ENCRYPT_MESSAGE_FOR_SELF : API_METHOD_CACHE_ENCRYPT_MESSAGE,
|
|
|
|
@ -666,7 +636,7 @@ class pEpAdapter {
|
|
|
|
|
switch (response.result.return.status) {
|
|
|
|
|
case PEP_STATUS_OK:
|
|
|
|
|
encryptedMessage = response.result.outParams[0];
|
|
|
|
|
this.log.debug("callPepAdapter: 'cache_encrypt_message' returned with success: ", response);
|
|
|
|
|
this.log.debug("cache_encrypt_message returned with success:", response);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// It's unclear whether anything except `PEP_UNENCRYPTED` will be returned here.
|
|
|
|
@ -677,12 +647,14 @@ class pEpAdapter {
|
|
|
|
|
case PEP_KEY_HAS_AMBIG_NAME:
|
|
|
|
|
encryptedMessage = response.result.outParams[1];
|
|
|
|
|
encryptedMessage.enc_format = ENC_FORMAT_NONE; // We couldn't encrypt, so this is unencrypted.
|
|
|
|
|
this.log.debug("callPepAdapter: 'cache_encrypt_message' returned with UNENCRYPTED status: ", response);
|
|
|
|
|
this.log.debug("cache_encrypt_message returned with UNENCRYPTED status:", response);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
this.log.debug("callPepAdapter: 'cache_encrypt_message' returned with error: ", response);
|
|
|
|
|
throw new Error(`encrypt error ${response.result.return.status}`);
|
|
|
|
|
this.checkError(
|
|
|
|
|
isDraftOrTemplate ? API_METHOD_CACHE_ENCRYPT_MESSAGE_FOR_SELF : API_METHOD_CACHE_ENCRYPT_MESSAGE,
|
|
|
|
|
response,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -694,17 +666,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async identity_rating(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: identity_rating()");
|
|
|
|
|
this.log.info("pEpAdapter entry: identity_rating()", identity);
|
|
|
|
|
const params = [identity, ["OP"]];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_IDENTITY_RATING,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: identity_rating()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_IDENTITY_RATING, response);
|
|
|
|
|
return response.result.outParams[0].rating;
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -713,17 +682,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async enable_identity_for_sync(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: enable_identity_for_sync()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: enable_identity_for_sync()", identity);
|
|
|
|
|
let params = [identity];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_ENABLE_IDENTITY_FOR_SYNC,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: enable_identity_for_sync()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_ENABLE_IDENTITY_FOR_SYNC, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -732,17 +698,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async disable_identity_for_sync(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: disable_identity_for_sync()", identity);
|
|
|
|
|
this.log.info("pEpAdapter entry: disable_identity_for_sync()", identity);
|
|
|
|
|
let params = [identity];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_DISABLE_IDENTITY_FOR_SYNC,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: disable_identity_for_sync()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_DISABLE_IDENTITY_FOR_SYNC, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -751,7 +714,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async disable_all_sync_channels() {
|
|
|
|
|
this.log.info("pEpAdapter.js: disable_all_sync_channels()");
|
|
|
|
|
this.log.info("pEpAdapter entry: disable_all_sync_channels()");
|
|
|
|
|
let params = [];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -764,17 +727,14 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async leave_device_group(identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: leave_device_group()");
|
|
|
|
|
this.log.info("pEpAdapter entry: leave_device_group()");
|
|
|
|
|
let params = [];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|
API_METHOD_LEAVE_DEVICE_GROUP,
|
|
|
|
|
params,
|
|
|
|
|
).then((response) => {
|
|
|
|
|
this.log.debug("pEpAdapter.js: leave_device_group()", response);
|
|
|
|
|
if (response.result.return.hasOwnProperty("status") && response.result.return.status != PEP_STATUS_OK) {
|
|
|
|
|
this.log.error(`returned status ${response.result.return.status}`);
|
|
|
|
|
}
|
|
|
|
|
this.checkError(API_METHOD_LEAVE_DEVICE_GROUP, response);
|
|
|
|
|
return response.result.outParams[0];
|
|
|
|
|
}).catch((err) => {
|
|
|
|
|
this.log.error(err.message);
|
|
|
|
@ -783,7 +743,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async deliverHandshakeResult(signal, identity) {
|
|
|
|
|
this.log.info("pEpAdapter.js: deliverHandshakeResult()");
|
|
|
|
|
this.log.info("pEpAdapter entry: deliverHandshakeResult()");
|
|
|
|
|
let params = [signal, [identity]];
|
|
|
|
|
return this.delegateCallPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -803,7 +763,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async startSync() {
|
|
|
|
|
this.log.info("pEpAdapter.js: startSync()");
|
|
|
|
|
this.log.info("pEpAdapter entry: startSync()");
|
|
|
|
|
let params = [];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
@ -816,7 +776,7 @@ class pEpAdapter {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async stopSync() {
|
|
|
|
|
this.log.info("pEpAdapter.js: stopSync()");
|
|
|
|
|
this.log.info("pEpAdapter entry: stopSync()");
|
|
|
|
|
let params = [];
|
|
|
|
|
return this.server.callPepAdapter(
|
|
|
|
|
SERVER_TYPE_CALL_FUNC,
|
|
|
|
|