How to use the grpc.credentials.createInsecure function in grpc

To help you get started, we’ve selected a few grpc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kulapio / libra-core / lib / client.ts View on Github external
constructor(config: LibralLibConfig) {
    this.config = config;

    if (config.host === undefined) {
      // since only testnet for now
      this.config.host = DefaultTestnetServerHost;
    }

    if (config.port === undefined) {
      this.config.port = '80';
    }

    const connectionAddress = `${this.config.host}:${this.config.port}`;
    this.client = new AdmissionControlClient(connectionAddress, credentials.createInsecure());
  }
github creditsenseau / zeebe-client-node-js / src / lib / GRPCClient.ts View on Github external
stdout,
			taskType: tasktype,
		})
		this.packageDefinition = loadSync(protoPath, {
			defaults: options.defaults === undefined ? true : options.defaults,
			enums: options.enums === undefined ? String : options.enums,
			keepCase: options.keepCase === undefined ? true : options.keepCase,
			longs: options.longs === undefined ? String : options.longs,
			oneofs: options.oneofs === undefined ? true : options.oneofs,
		})

		const proto = loadPackageDefinition(this.packageDefinition)[packageName]
		const listMethods = this.packageDefinition[`${packageName}.${service}`]
		const channelCredentials = useTLS
			? credentials.createSsl()
			: credentials.createInsecure()
		// Options documented here: https://github.com/grpc/grpc/blob/master/include/grpc/impl/codegen/grpc_types.h
		this.client = new proto[service](host, channelCredentials, {
			/**
			 * If set to zero, disables retry behavior.
			 * Otherwise, transparent retries are enabled for all RPCs,
			 * and configurable retries are enabled when they are configured
			 * via the service config. For details, see:
			 * https://github.com/grpc/proposal/blob/master/A6-client-retries.md
			 */
			'grpc.enable_retries': 1,
			/**
			 * The time between the first and second connection attempts,
			 * in ms
			 */
			'grpc.initial_reconnect_backoff_ms': 1000,
			/**
github Tubitv / envoy-node / src / envoy-proto-decorator.ts View on Github external
constructor(address: string, ctx: EnvoyContext | Metadata | HttpHeader) {
      let envoyContext: EnvoyContext;
      if (ctx instanceof EnvoyContext) {
        envoyContext = ctx;
      } else {
        envoyContext = new EnvoyContext(ctx);
      }
      const actualAddr = envoyContext.shouldCallWithoutEnvoy(address)
        ? address
        : `${envoyContext.envoyEgressAddr}:${envoyContext.envoyEgressPort}`;
      super(actualAddr, credentials.createInsecure(), { channelFactoryOverride });
      this.originalAddress = address;
      this.envoyContext = envoyContext;
    }
  } as EnvoyClientConstructor;
github nameko / nameko-examples-grpc / gateway / src / clients.ts View on Github external
});

const productsPackageDefinition = protoLoader.loadSync(PRODUCTS_PROTO_PATH, {
  keepCase: false,
  longs: String,
  enums: String,
  defaults: true,
  oneofs: true,
});

const orders: any = loadPackageDefinition(ordersPackageDefinition).orders;
const products: any = loadPackageDefinition(productsPackageDefinition).products;

const ordersStub = new orders.orders(
  `${ORDERS_SERVICE}`,
  credentials.createInsecure(),
);
const productsStub = new products.products(
  `${PRODUCTS_SERVICE}`,
  credentials.createInsecure(),
);

const ordersGrpcClient: any = promisifyAll(ordersStub);
const productsGrpcClient: any = promisifyAll(productsStub);

export { ordersGrpcClient, productsGrpcClient };
github uw-labs / bloomrpc / app / behaviour / sendRequest.ts View on Github external
private getClient(serviceClient: any): grpc.Client {
    let creds = credentials.createInsecure();
    let options = {};

    if (this.tlsCertificate) {
      if (this.tlsCertificate.sslTargetHost) {
        options = {
          ...options,
          'grpc.ssl_target_name_override' : this.tlsCertificate.sslTargetHost,
          'grpc.default_authority': this.tlsCertificate.sslTargetHost,
        }
      }
      if(this.tlsCertificate.useServerCertificate === true) {
        creds = credentials.createSsl();
      } else {
        creds = credentials.createSsl(
            fs.readFileSync(this.tlsCertificate.rootCert.filePath),
            this.tlsCertificate.privateKey && fs.readFileSync(this.tlsCertificate.privateKey.filePath),
github kulapio / libra-core / lib / client / node.ts View on Github external
export function initAdmissionControlClient(connectionAddress: string): AdmissionControlClient {
  return new AdmissionControlClient(connectionAddress, credentials.createInsecure());
}
github nameko / nameko-examples-grpc / gateway / src / clients.ts View on Github external
longs: String,
  enums: String,
  defaults: true,
  oneofs: true,
});

const orders: any = loadPackageDefinition(ordersPackageDefinition).orders;
const products: any = loadPackageDefinition(productsPackageDefinition).products;

const ordersStub = new orders.orders(
  `${ORDERS_SERVICE}`,
  credentials.createInsecure(),
);
const productsStub = new products.products(
  `${PRODUCTS_SERVICE}`,
  credentials.createInsecure(),
);

const ordersGrpcClient: any = promisifyAll(ordersStub);
const productsGrpcClient: any = promisifyAll(productsStub);

export { ordersGrpcClient, productsGrpcClient };
github KillrVideo / killrvideo-web / src / server / utils / grpc-client.js View on Github external
    .then(hosts => new ClientConstructor(hosts[0], credentials.createInsecure()))
    .catch(err => {
github angular / universal / modules / grpc-engine / spec / index.spec.ts View on Github external
function createClient() {
  const packageDefinition = loadSync('modules/grpc-engine/grpc-engine.proto', {});
  const grpcEngineProto = loadPackageDefinition(packageDefinition).grpcengine;

  const client = new grpcEngineProto.SSR('localhost:9090', credentials.createInsecure());
  return client;
}