Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return __awaiter(this, void 0, void 0, function* () {
const protoDefinition = yield protobuf.load(protoFile);
const protoDefinitionObject = yield protoDefinition.toJSON();
const packagePaths = packageName.split('.');
for (let i = 0; i < packagePaths.length; i += 2) {
packagePaths.splice(i, 0, 'nested');
}
return _.get(protoDefinitionObject, packagePaths.join('.'));
});
}
static async init() {
if (proto) {
return;
}
proto = await load(path.resolve(__dirname, 'mcs.proto'));
}
const protobuf = require("protobufjs");
const fs = require("fs");
protobuf.load("../bytecode.proto", function(err, root) {
if (err) throw err;
const Bytecode = root.lookupType('Bytecode');
const bytecodeData = {
version: {magic: 42, major: 0, minor: 1},
path: "com.example",
imports: [],
modules: [{
path: "HelloWorld",
valueModule: {
type: {
simpleType: root.lookupEnum("Type.SimpleType").values.Top
},
expression: {
literal: {
stringLiteral: "Hello, world!"
let newColors: RgbColors | undefined;
if (options.colors !== undefined) {
if (!this.supportsColors()) {
throw new Error('Changing colors is not supported by this device');
}
newColors = {
red: Math.round(this.parseValueAsNumber('red color', options.colors.red, 255)),
green: Math.round(this.parseValueAsNumber('green color', options.colors.green, 255)),
blue: Math.round(this.parseValueAsNumber('blue color', options.colors.blue, 255))
};
log.verbose('LightBulb.setState', 'Colors:', JSON.stringify(newColors));
}
const proto = await protobuf.load(`${__dirname}/lakeside.proto`);
let message: Message = {
sequence: await this.getSequence(),
code: this.code
};
let packetType: protobuf.Type;
if (isWhiteLightBulb(this.model)) {
log.verbose('LightBulb.setState', 'Treat as white light bulb (T1012Packet)');
packetType = proto.lookupType('lakeside.T1012Packet');
message.bulbinfo = {
type: 0,
packet: {
unknown1: 100,
bulbset: {
command: 7
async function main() {
if (typeof(argv.cfg)!=='undefined') {
cfgData = toml.parse(fs.readFileSync(argv.cfg,'utf8'));
var servers = [];
Object.keys(cfgData["server"]).forEach((name) => {
servers.push(cfgData["server"][name]);
});
for (let item of servers) {
if (item.service) {
let root = await protobuf.load(item.proto);
const apiData = api(root,item.service, wsProto);
var generatedApi = apiData["output"];
var methodNames = apiData["methods"];
var proto = grpc.load(item.proto);
var stub=null;
eval("stub = proto." + item.pkg);
var service = { cfg:item, api:generatedApi,methods:methodNames,remote:stub, grpc:item.grpc};
services[item.service] = service;
apiText+=generatedApi;
}
}
}
app.use(require('helmet')());
if (typeof(argv.webroot)=='undefined')
private async getState(): Promise {
log.verbose('LightBulb.getState', 'Loading current device state');
const proto = await protobuf.load(`${__dirname}/lakeside.proto`);
const packetType = proto.lookupType('lakeside.T1012Packet');
const packet = packetType.encode({
sequence: await this.getSequence(),
code: this.code,
bulbInfo: {
type: 1
}
}).finish();
log.verbose('LightBulb.getState', 'Sending request to device');
return await this.sendPacketWithResponse(packet);
}
function loadProtoFile() {
return protobuf.load(
path.join(__dirname, '..', 'src', 'client', 'mcs.proto')
);
}
async function loadProtoFile() {
if (root) {
return;
}
root = await protobuf.load(path.join(__dirname, 'checkin.proto'));
return root;
}
function loadProtoFile() {
return protobuf.load(path.join(__dirname, 'mcs.proto'));
}