diff --git a/chat/content/jar.mn b/chat/content/jar.mn index 3a26471559..cf14bbf5ba 100644 --- a/chat/content/jar.mn +++ b/chat/content/jar.mn @@ -12,3 +12,19 @@ chat.jar: * content/chat/imtooltip.xml content/chat/conversation-browser.js content/chat/conv.html + content/chat/otr-add-fingerprint.js + content/chat/otr-add-fingerprint.xul + content/chat/otr-auth.js + content/chat/otr-auth.xul + content/chat/otr-generate-key.js + content/chat/otr-generate-key.xul + content/chat/otrWorker.js + content/chat/otr-auth.dtd + content/chat/otr-auth.properties + content/chat/otr-add-finger.dtd + content/chat/otr-add-finger.properties + content/chat/otr.properties + content/chat/otr-generate-key.dtd + content/chat/otr-generate-key.properties + content/chat/otrUI.properties + content/chat/otr-chat.dtd diff --git a/chat/content/otr-add-finger.dtd b/chat/content/otr-add-finger.dtd new file mode 100644 index 0000000000..7af1713527 --- /dev/null +++ b/chat/content/otr-add-finger.dtd @@ -0,0 +1,9 @@ + + + + + + + diff --git a/chat/content/otr-add-finger.properties b/chat/content/otr-add-finger.properties new file mode 100644 index 0000000000..661e72c0b8 --- /dev/null +++ b/chat/content/otr-add-finger.properties @@ -0,0 +1,6 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# LOCALIZATION NOTE (addfinger.title): %S is the name of a chat contact person +addfinger.title=Enter the fingerprint of the OTR key used by %S diff --git a/chat/content/otr-add-fingerprint.js b/chat/content/otr-add-fingerprint.js new file mode 100644 index 0000000000..9232205372 --- /dev/null +++ b/chat/content/otr-add-fingerprint.js @@ -0,0 +1,50 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const { + XPCOMUtils, + l10nHelper, +} = ChromeUtils.import("resource:///modules/imXPCOMUtils.jsm"); +const {OTR} = ChromeUtils.import("resource:///modules/OTR.jsm"); + +XPCOMUtils.defineLazyGetter(this, "_", () => + l10nHelper("chrome://chat/content/otr-add-finger.properties") +); + +var args = window.arguments[0].wrappedJSObject; + +var otrAddFinger = { + onload() { + document.title = _("addfinger.title", args.screenname); + + document.addEventListener("dialogaccept", () => { + return this.add(); + }); + }, + + oninput(e) { + e.value = e.value.replace(/[^0-9a-fA-F]/gi, ""); + document.documentElement.getButton("accept").disabled = (e.value.length != 40); + }, + + add(e) { + let hex = document.getElementById("finger").value; + let context = OTR.getContextFromRecipient( + args.account, + args.protocol, + args.screenname + ); + let finger = OTR.addFingerprint(context, hex); + if (finger.isNull()) + return; + try { + // Ignore the return, this is just a test. + OTR.getUIConvFromContext(context); + } catch (error) { + // We expect that a conversation may not have been started. + context = null; + } + OTR.setTrust(finger, true, context); + }, +}; diff --git a/chat/content/otr-add-fingerprint.xul b/chat/content/otr-add-fingerprint.xul new file mode 100644 index 0000000000..9c7c72b04b --- /dev/null +++ b/chat/content/otr-add-fingerprint.xul @@ -0,0 +1,27 @@ + + + + + + + + + +