Browse Source

sign each message and parse on other end, get pubkey from sig

feature/dockerfile-arm
Evan Feenstra 5 years ago
parent
commit
0831e2380d
  1. 1
      api/grpc/index.ts
  2. 10
      api/helpers.ts
  3. 4
      api/utils/lightning.ts
  4. 2
      dist/api/grpc/index.js
  5. 2
      dist/api/grpc/index.js.map
  6. 7
      dist/api/helpers.js
  7. 2
      dist/api/helpers.js.map
  8. 4
      dist/api/utils/lightning.js
  9. 2
      dist/api/utils/lightning.js.map

1
api/grpc/index.ts

@ -16,7 +16,6 @@ async function parseAndVerifyPayload(data){
try {
payload = JSON.parse(msg)
if(payload) {
if(!sig) return payload // REMOVE THIS LINE (here for backward compat)
const v = await verifyAscii(msg, sig)
if(v && v.valid && v.pubkey) {
payload.sender = payload.sender||{}

10
api/helpers.ts

@ -229,10 +229,10 @@ function newmsg(type, chat, sender, message){
...chat.members && { members: chat.members },
},
message: message,
sender: {
pub_key: sender.publicKey,
// ...sender.contactKey && {contact_key: sender.contactKey}
}
// sender: {
// pub_key: sender.publicKey,
// // ...sender.contactKey && {contact_key: sender.contactKey}
// }
}
}
@ -240,7 +240,7 @@ function newkeyexchangemsg(type, sender){
return {
type: type,
sender: {
pub_key: sender.publicKey,
// pub_key: sender.publicKey,
contact_key: sender.contactKey,
...sender.alias && {alias: sender.alias},
// ...sender.photoUrl && {photoUrl: sender.photoUrl}

4
api/utils/lightning.ts

@ -140,8 +140,8 @@ async function keysendMessage(opts) {
return reject('string plz')
}
// SIGN HERE and append sig
// const sig = await signAscii(opts.data)
// opts.data = opts.data + sig
const sig = await signAscii(opts.data)
opts.data = opts.data + sig
if(opts.data.length<MAX_MSG_LENGTH){
try {

2
dist/api/grpc/index.js

@ -26,8 +26,6 @@ function parseAndVerifyPayload(data) {
try {
payload = JSON.parse(msg);
if (payload) {
if (!sig)
return payload; // REMOVE THIS LINE (here for backward compat)
const v = yield lightning_1.verifyAscii(msg, sig);
if (v && v.valid && v.pubkey) {
payload.sender = payload.sender || {};

2
dist/api/grpc/index.js.map

File diff suppressed because one or more lines are too long

7
dist/api/helpers.js

@ -227,15 +227,14 @@ function newmsg(type, chat, sender, message) {
type: type,
chat: Object.assign(Object.assign(Object.assign({ uuid: chat.uuid }, chat.name && { name: chat.name }), chat.type && { type: chat.type }), chat.members && { members: chat.members }),
message: message,
sender: {
pub_key: sender.publicKey,
}
};
}
function newkeyexchangemsg(type, sender) {
return {
type: type,
sender: Object.assign({ pub_key: sender.publicKey, contact_key: sender.contactKey }, sender.alias && { alias: sender.alias })
sender: Object.assign({
// pub_key: sender.publicKey,
contact_key: sender.contactKey }, sender.alias && { alias: sender.alias })
};
}
//# sourceMappingURL=helpers.js.map

2
dist/api/helpers.js.map

File diff suppressed because one or more lines are too long

4
dist/api/utils/lightning.js

@ -154,8 +154,8 @@ function keysendMessage(opts) {
return reject('string plz');
}
// SIGN HERE and append sig
// const sig = await signAscii(opts.data)
// opts.data = opts.data + sig
const sig = yield signAscii(opts.data);
opts.data = opts.data + sig;
if (opts.data.length < MAX_MSG_LENGTH) {
try {
const res = yield keysend(opts);

2
dist/api/utils/lightning.js.map

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save