diff --git a/keyserver/package.json b/keyserver/package.json --- a/keyserver/package.json +++ b/keyserver/package.json @@ -41,6 +41,7 @@ "dependencies": { "@babel/runtime": "^7.13.10", "@grpc/grpc-js": "^1.7.1", + "@grpc/proto-loader": "^0.7.3", "@matrix-org/olm": "3.2.4", "@parse/node-apn": "^3.2.0", "@vingle/bmp-js": "^0.2.5", diff --git a/keyserver/src/grpc/grpc_client.js b/keyserver/src/grpc/grpc_client.js new file mode 100644 --- /dev/null +++ b/keyserver/src/grpc/grpc_client.js @@ -0,0 +1,22 @@ +// @flow + +import * as grpc from '@grpc/grpc-js'; +import * as protoLoader from '@grpc/proto-loader'; + +import type { IdentityServiceClient } from 'lib/types/grpc-types'; + +const PROTO_PATH = '../shared/protos/identity.proto'; +const packageDefinition = protoLoader.loadSync(PROTO_PATH, { + keepCase: true, + longs: String, + enums: String, + defaults: true, + oneofs: true, +}); +const identity = grpc.loadPackageDefinition(packageDefinition).identity; +const identityClient: IdentityServiceClient = new identity.IdentityService( + 'localhost:50051', + grpc.credentials.createInsecure(), +); + +export { identityClient }; diff --git a/yarn.lock b/yarn.lock --- a/yarn.lock +++ b/yarn.lock @@ -2477,7 +2477,7 @@ protobufjs "^6.10.0" yargs "^16.2.0" -"@grpc/proto-loader@^0.7.0": +"@grpc/proto-loader@^0.7.0", "@grpc/proto-loader@^0.7.3": version "0.7.3" resolved "https://registry.yarnpkg.com/@grpc/proto-loader/-/proto-loader-0.7.3.tgz#75a6f95b51b85c5078ac7394da93850c32d36bb8" integrity sha512-5dAvoZwna2Py3Ef96Ux9jIkp3iZ62TUsV00p3wVBPNX5K178UbNi8Q7gQVqwXT1Yq9RejIGG9G2IPEo93T6RcA==