Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const writeSet = new common.ConfigGroup({ version: writeVersion, groups: writeGroups, values: writeValues });
// Now create the configUpdate and configUpdateEnv
const configUpdate = new common.ConfigUpdate({ channel_id: channelName, read_set: readSet, write_set: writeSet});
const configUpdateEnv= new common.ConfigUpdateEnvelope({ config_update: configUpdate.toBuffer(), signatures: [] });
// Channel header
const channelTimestamp = new google.protobuf.Timestamp({ seconds: Date.now()/1000, nanos: 0 }); // Date.now() is millis since 1970 epoch, we need seconds
const channelEpoch = 0;
const chHeader = new common.ChannelHeader({ type: common.HeaderType.CONFIG_UPDATE, version: channelObject.version, timestamp: channelTimestamp, channel_id: channelName, epoch: channelEpoch });
// Common header
const header = new common.Header({ channel_header: chHeader.toBuffer() });
// Form the payload header/data
const payload = new common.Payload({ header: header, data: configUpdateEnv.toBuffer() });
// Form and return the envelope
const envelope = new common.Envelope({ payload: payload.toBuffer() });
return envelope;
}
const writeSet = new common.ConfigGroup({ version: writeVersion, groups: writeGroups, values: writeValues });
// Now create the configUpdate and configUpdateEnv
const configUpdate = new common.ConfigUpdate({ channel_id: channelName, read_set: readSet, write_set: writeSet});
const configUpdateEnv= new common.ConfigUpdateEnvelope({ config_update: configUpdate.toBuffer(), signatures: [] });
// Channel header
const channelTimestamp = new google.protobuf.Timestamp({ seconds: Date.now()/1000, nanos: 0 }); // Date.now() is millis since 1970 epoch, we need seconds
const channelEpoch = 0;
const chHeader = new common.ChannelHeader({ type: common.HeaderType.CONFIG_UPDATE, version: channelVersion, timestamp: channelTimestamp, channel_id: channelName, epoch: channelEpoch });
// Common header
const header = new common.Header({ channel_header: chHeader.toBuffer() });
// Form the payload header/data
const payload = new common.Payload({ header: header, data: configUpdateEnv.toBuffer() });
// Form and return the envelope
const envelope = new common.Envelope({ payload: payload.toBuffer() });
return envelope;
}
function makeEnvelope(signer, type) {
const dummyPayload = new commonProto.Payload();
const cHeader = new commonProto.ChannelHeader();
cHeader.setType(type);
cHeader.setChannelId(testUtil.END2END.channel);
const sHeader = new commonProto.SignatureHeader();
sHeader.setCreator(signer.getIdentity().serialize());
sHeader.setNonce(Buffer.from('23456'));
dummyPayload.setHeader({
channel_header: cHeader.toBuffer(),
signature_header: sHeader.toBuffer()
});
dummyPayload.setData('Dummy data');
const sig = signer.getSigningIdentity().sign(dummyPayload.toBuffer());
const envelope = {