Bug 1730847 - Backend for chat buddy verification. r=clokep
Differential Revision: https://phabricator.services.mozilla.com/D126265 --HG-- extra : amend_source : 96dc3f86cf6c214de19ba7b04cf5cc94ae20cba4
This commit is contained in:
Родитель
222918c812
Коммит
89c3479bcf
|
@ -52,7 +52,7 @@ interface imIContactsService: nsISupports {
|
|||
void forgetAccount(in unsigned long aId);
|
||||
};
|
||||
|
||||
/*
|
||||
/**
|
||||
* An imIContact represents a person, e.g. our friend Alice. This person might
|
||||
* have multiple means of contacting them.
|
||||
*
|
||||
|
@ -154,7 +154,7 @@ interface imIContact: imIStatusInfo {
|
|||
[optional] in wstring aData);
|
||||
};
|
||||
|
||||
/*
|
||||
/**
|
||||
* An imIBuddy represents a person's account on a particular network. Note that
|
||||
* what a network is depends on the implementation of the prpl, e.g. for AIM
|
||||
* there is only a single network, but both GTalk and XMPP are the same network.
|
||||
|
@ -218,7 +218,7 @@ interface imIBuddy: imIStatusInfo {
|
|||
[optional] in wstring aData);
|
||||
};
|
||||
|
||||
/*
|
||||
/**
|
||||
* A prplIAccountBuddy represents the connection on a network between one of the
|
||||
* current user's accounts and a persons's account. E.g. if we're logged into
|
||||
* the Foo network as BobbyBoy91 and want to talk to Alice, there may be two
|
||||
|
@ -265,6 +265,21 @@ interface prplIAccountBuddy: imIStatusInfo {
|
|||
readonly attribute AUTF8String normalizedName;
|
||||
attribute AUTF8String serverAlias;
|
||||
|
||||
/** Whether we can verify the identity of this buddy. */
|
||||
readonly attribute boolean canVerifyIdentity;
|
||||
|
||||
/**
|
||||
* True if we trust the encryption with this buddy in E2EE conversations. Can
|
||||
* only be true if |canVerifyIdentity| is true.
|
||||
*/
|
||||
readonly attribute boolean identityVerified;
|
||||
|
||||
/**
|
||||
* Initialize identity verification with this buddy.
|
||||
* @returns {Promise<imISessionVerification>}
|
||||
*/
|
||||
Promise verifyIdentity();
|
||||
|
||||
// remove the buddy from the buddy list of this account.
|
||||
void remove();
|
||||
|
||||
|
|
|
@ -13,10 +13,11 @@ interface imIMessage;
|
|||
interface nsIURI;
|
||||
interface prplIChatRoomFieldValues;
|
||||
|
||||
/*
|
||||
* This is the XPCOM purple conversation component, a proxy for PurpleConversation.
|
||||
/**
|
||||
* This interface represents a conversation as implemented by a protocol. It
|
||||
* contains the properties and methods shared between direct (IM) and multi
|
||||
* user (chat) conversations.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(f71c58d6-2c47-4468-934b-b1c61462c01a)]
|
||||
interface prplIConversation: nsISupports {
|
||||
|
||||
|
@ -152,7 +153,7 @@ interface prplIConvIM: prplIConversation {
|
|||
readonly attribute short typingState;
|
||||
};
|
||||
|
||||
/* This represents a participant in a chat room */
|
||||
/** This represents a participant in a chat room */
|
||||
[scriptable, uuid(b0e9177b-40f6-420b-9918-04bbbb9ce44f)]
|
||||
interface prplIConvChatBuddy: nsISupports {
|
||||
|
||||
|
@ -181,6 +182,21 @@ interface prplIConvChatBuddy: nsISupports {
|
|||
|
||||
/* Whether the participant is currently typing. */
|
||||
readonly attribute boolean typing;
|
||||
|
||||
/** Whether we can verify the identity of this participant. */
|
||||
readonly attribute boolean canVerifyIdentity;
|
||||
|
||||
/**
|
||||
* True if we trust the encryption with this participant in E2EE chats. Can
|
||||
* only be true if |canVerifyIdentity| is true.
|
||||
*/
|
||||
readonly attribute boolean identityVerified;
|
||||
|
||||
/**
|
||||
* Initialize identity verification with this participant.
|
||||
* @returns {Promise<imISessionVerification>}
|
||||
*/
|
||||
Promise verifyIdentity();
|
||||
};
|
||||
|
||||
[scriptable, uuid(72c17398-639f-4141-a19c-78cbdeb39fba)]
|
||||
|
|
|
@ -564,6 +564,51 @@ var GenericAccountBuddyPrototype = {
|
|||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method called to start verification of the buddy. Same signature as
|
||||
* _startVerification of GenericSessionPrototype. If the property is not a
|
||||
* function, |canVerifyIdentity| is false.
|
||||
*
|
||||
* @type {() => {challenge: string, challengeDescription: string?, handleResult: (boolean) => void, cancel: () => void, cancelPromise: Promise}?}
|
||||
*/
|
||||
_startVerification: null,
|
||||
get canVerifyIdentity() {
|
||||
return typeof this._startVerification === "function";
|
||||
},
|
||||
_identityVerified: false,
|
||||
get identityVerified() {
|
||||
return this.canVerifyIdentity && this._identityVerified;
|
||||
},
|
||||
verifyIdentity() {
|
||||
if (!this.canVerifyIdentity) {
|
||||
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
if (this.identityVerified) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return this._startVerification().then(
|
||||
({
|
||||
challenge,
|
||||
challengeDescription,
|
||||
handleResult,
|
||||
cancel,
|
||||
cancelPromise,
|
||||
}) => {
|
||||
const verifier = new SessionVerification(
|
||||
challenge,
|
||||
this.userName,
|
||||
challengeDescription
|
||||
);
|
||||
verifier.completePromise.then(
|
||||
result => handleResult(result),
|
||||
() => cancel()
|
||||
);
|
||||
cancelPromise.then(() => verifier.cancel());
|
||||
return verifier;
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
remove() {
|
||||
Services.contacts.accountBuddyRemoved(this);
|
||||
},
|
||||
|
@ -1112,6 +1157,51 @@ var GenericConvChatBuddyPrototype = {
|
|||
admin: false,
|
||||
founder: false,
|
||||
typing: false,
|
||||
|
||||
/**
|
||||
* Method called to start verification of the buddy. Same signature as
|
||||
* _startVerification of GenericSessionPrototype. If the property is not a
|
||||
* function, |canVerifyIdentity| is false.
|
||||
*
|
||||
* @type {() => {challenge: string, challengeDescription: string?, handleResult: (boolean) => void, cancel: () => void, cancelPromise: Promise}?}
|
||||
*/
|
||||
_startVerification: null,
|
||||
get canVerifyIdentity() {
|
||||
return typeof this._startVerification === "function";
|
||||
},
|
||||
_identityVerified: false,
|
||||
get identityVerified() {
|
||||
return this.canVerifyIdentity && this._identityVerified;
|
||||
},
|
||||
verifyIdentity() {
|
||||
if (!this.canVerifyIdentity) {
|
||||
throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
if (this.identityVerified) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return this._startVerification().then(
|
||||
({
|
||||
challenge,
|
||||
challengeDescription,
|
||||
handleResult,
|
||||
cancel,
|
||||
cancelPromise,
|
||||
}) => {
|
||||
const verifier = new SessionVerification(
|
||||
challenge,
|
||||
this.name,
|
||||
challengeDescription
|
||||
);
|
||||
verifier.completePromise.then(
|
||||
result => handleResult(result),
|
||||
() => cancel()
|
||||
);
|
||||
cancelPromise.then(() => verifier.cancel());
|
||||
return verifier;
|
||||
}
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
function TooltipInfo(aLabel, aValue, aType = Ci.prplITooltipInfo.pair) {
|
||||
|
@ -1509,7 +1599,9 @@ var GenericSessionPrototype = {
|
|||
* The cancel callback will be called when the cancel promise resolves.
|
||||
*/
|
||||
_startVerification() {
|
||||
return Promise.reject(Components.Exception(Cr.NS_ERROR_NOT_IMPLEMENTED));
|
||||
return Promise.reject(
|
||||
Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED)
|
||||
);
|
||||
},
|
||||
verify() {
|
||||
if (this.trusted) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче