mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
server api changes: encoding is gone (payload guaranteed to be utf-8 now), payload is guaranteed to be json so no need to wrap in an array to encode; change crypto object to place encrypted data in a 'cyphertext' property inside the payload, instead of replacing the payload
This commit is contained in:
parent
a422bdb9b3
commit
a001a3f564
@ -70,17 +70,30 @@ CryptoWrapper.prototype = {
|
||||
// FIXME: this will add a json filter, meaning our payloads will be json
|
||||
// encoded, even though they are already a string
|
||||
this._WBORec_init(uri, authenticator);
|
||||
this.data.encryption = "";
|
||||
this.data.payload = "";
|
||||
this.data.payload = {
|
||||
encryption: "",
|
||||
cleartext: null,
|
||||
ciphertext: null
|
||||
};
|
||||
},
|
||||
|
||||
// FIXME: we make no attempt to ensure cleartext is in sync
|
||||
// with the encrypted payload
|
||||
cleartext: null,
|
||||
|
||||
get encryption() this.data.encryption,
|
||||
get encryption() this.payload.encryption,
|
||||
set encryption(value) {
|
||||
this.data.encryption = value;
|
||||
this.payload.encryption = value;
|
||||
},
|
||||
|
||||
get cleartext() this.payload.cleartext,
|
||||
set cleartext(value) {
|
||||
this.payload.cleartext = value;
|
||||
},
|
||||
|
||||
get ciphertext() this.payload.ciphertext,
|
||||
set ciphertext(value) {
|
||||
this.payload.ciphertext = value;
|
||||
},
|
||||
|
||||
_encrypt: function CryptoWrap__encrypt(passphrase) {
|
||||
@ -92,9 +105,7 @@ CryptoWrapper.prototype = {
|
||||
let meta = yield CryptoMetas.get(self.cb, this.encryption);
|
||||
let symkey = yield meta.getKey(self.cb, privkey, passphrase);
|
||||
|
||||
// note: we wrap the cleartext payload in an array because
|
||||
// when it's a simple string nsIJSON returns null
|
||||
this.payload = crypto.encrypt(json.encode([this.cleartext]), symkey, meta.bulkIV);
|
||||
this.ciphertext = crypto.encrypt(json.encode([this.cleartext]), symkey, meta.bulkIV);
|
||||
|
||||
self.done();
|
||||
},
|
||||
@ -112,7 +123,7 @@ CryptoWrapper.prototype = {
|
||||
let symkey = yield meta.getKey(self.cb, privkey, passphrase);
|
||||
|
||||
// note: payload is wrapped in an array, see _encrypt
|
||||
this.cleartext = json.decode(crypto.decrypt(this.payload, symkey, meta.bulkIV))[0];
|
||||
this.cleartext = json.decode(crypto.decrypt(this.ciphertext, symkey, meta.bulkIV))[0];
|
||||
|
||||
self.done(this.cleartext);
|
||||
},
|
||||
|
@ -59,7 +59,6 @@ WBORecord.prototype = {
|
||||
this.pushFilter(new WBOFilter());
|
||||
this.pushFilter(new JsonFilter());
|
||||
this.data = {
|
||||
// modified: "2454725.98283", // FIXME
|
||||
payload: {}
|
||||
};
|
||||
},
|
||||
@ -82,18 +81,10 @@ WBORecord.prototype = {
|
||||
this.data.modified = value;
|
||||
},
|
||||
|
||||
get encoding() this.data.encoding,
|
||||
set encoding(value) {
|
||||
this.data.encoding = value;
|
||||
},
|
||||
|
||||
get payload() this.data.payload,
|
||||
set payload(value) {
|
||||
this.data.payload = value;
|
||||
}
|
||||
|
||||
// note: encryption is part of the CryptoWrapper object, which uses
|
||||
// a string (encrypted) payload instead of an object
|
||||
};
|
||||
|
||||
// fixme: global, ugh
|
||||
@ -105,14 +96,14 @@ WBOFilter.prototype = {
|
||||
let self = yield;
|
||||
let foo = wbo.uri.spec.split('/');
|
||||
data.id = decodeURI(foo[foo.length-1]);
|
||||
data.payload = json.encode([data.payload]);
|
||||
data.payload = json.encode(data.payload);
|
||||
self.done(data);
|
||||
},
|
||||
afterGET: function(data, wbo) {
|
||||
let self = yield;
|
||||
let foo = wbo.uri.spec.split('/');
|
||||
data.id = decodeURI(foo[foo.length-1]);
|
||||
data.payload = json.decode(data.payload)[0];
|
||||
data.payload = json.decode(data.payload);
|
||||
self.done(data);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user