I am trying to update an old Firefox add-on that was based on XUL & XPCOM and re-implement it in a WebExtention. This new add-on will use a firefox sync server 1.1 to exchange some info securely, based on this. I cannot use firefox sync server 1.5 as this doesn't use J-PAKE. I have been able to talk to the server fine, but now stumbling on the second step of the protocol.
Mobile/Desktop generates PIN from random weak secret (4 characters a-z0-9) and the channel ID, computes and uploads J-PAKE msg 1. New for v2: To prevent double uploads in case of retries, the If-None-Match: * header is specified. This makes sure that the message is only uploaded if the channel is empty. If it is not then the request will fail with a 412 Precondition Failed which should be considered the same as 200 OK. The 412 will also contain the Etag of the data was the client just uploaded.
C: PUT /a7id HTTP/1.1
C: If-None-Match: *
C:
C: {
C: 'type': 'receiver1',
C: 'payload': {
C: 'gx1': '45...9b',
C: 'zkp_x1': {
C: 'b': '09e22607ead737150b1a6e528d0c589cb6faa54a',
C: 'gr': '58...7a'
C: 'id': 'receiver',
C: }
C: 'gx2': 'be...93',
C: 'zkp_x2': {
C: 'b': '222069aabbc777dc988abcc56547cd944f056b4c',
C: 'gr': '5c...23'
C: 'id': 'receiver',
C: }
C: }
C: }
The problem is the old implementation used XPCOM objects:
var jpake = Component.Classes["@mozilla.org/services-crypto/sync-jpake;1"].createInstance(Ci.nsISyncJPAKE);
and allows to use the function described here and implemented here
jpake.round1(singerId, gx1, gv1, r1, gx2, gv2, r2)
which took care of generating: gx1, gv1, r1, gx2, gv2 and r2.
Is there a way to use the XPCOM objects in WebExtentions? Or am I forced to use Add-on SDK, with XPCOM low-level API?
I have tried to use curve25519.js to emulate the values from here, but with no success.
Any help is welcome, Thanks
This is the email that was sent on the dev channel where you can use a WebExt forom inside a classic addon, it meant for transition purposes, I'm not sure of how permanent it is: