feat(WAProto): Optimize protobuf generation for 80%+ bundle size reduction (#1665)
* chore: remove comments and veirfy from generated proto files (improve size) * refactor: replace fromObject with create for proto message instantiation and flag no beautiful * chore: lint issues
This commit is contained in:
committed by
GitHub
parent
9e04cce8d3
commit
4d4339dae6
@@ -1,13 +1,6 @@
|
||||
import { proto } from '../../../WAProto/index.js'
|
||||
import { CiphertextMessage } from './ciphertext-message'
|
||||
|
||||
interface SenderKeyDistributionMessageStructure {
|
||||
id: number
|
||||
iteration: number
|
||||
chainKey: string | Uint8Array
|
||||
signingKey: string | Uint8Array
|
||||
}
|
||||
|
||||
export class SenderKeyDistributionMessage extends CiphertextMessage {
|
||||
private readonly id: number
|
||||
private readonly iteration: number
|
||||
@@ -27,9 +20,7 @@ export class SenderKeyDistributionMessage extends CiphertextMessage {
|
||||
if (serialized) {
|
||||
try {
|
||||
const message = serialized.slice(1)
|
||||
const distributionMessage = proto.SenderKeyDistributionMessage.decode(
|
||||
message
|
||||
).toJSON() as SenderKeyDistributionMessageStructure
|
||||
const distributionMessage = proto.SenderKeyDistributionMessage.decode(message)
|
||||
|
||||
this.serialized = serialized
|
||||
this.id = distributionMessage.id
|
||||
|
||||
@@ -3,12 +3,6 @@ import { calculateSignature, verifySignature } from 'libsignal/src/curve'
|
||||
import { proto } from '../../../WAProto/index.js'
|
||||
import { CiphertextMessage } from './ciphertext-message'
|
||||
|
||||
interface SenderKeyMessageStructure {
|
||||
id: number
|
||||
iteration: number
|
||||
ciphertext: string | Buffer
|
||||
}
|
||||
|
||||
export class SenderKeyMessage extends CiphertextMessage {
|
||||
private readonly SIGNATURE_LENGTH = 64
|
||||
private readonly messageVersion: number
|
||||
@@ -31,7 +25,7 @@ export class SenderKeyMessage extends CiphertextMessage {
|
||||
const version = serialized[0]!
|
||||
const message = serialized.slice(1, serialized.length - this.SIGNATURE_LENGTH)
|
||||
const signature = serialized.slice(-1 * this.SIGNATURE_LENGTH)
|
||||
const senderKeyMessage = proto.SenderKeyMessage.decode(message).toJSON() as SenderKeyMessageStructure
|
||||
const senderKeyMessage = proto.SenderKeyMessage.decode(message)
|
||||
|
||||
this.serialized = serialized
|
||||
this.messageVersion = (version & 0xff) >> 4
|
||||
|
||||
Reference in New Issue
Block a user