Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function makeServerStreamingEchoRequest() {
const req = new ServerStreamingEchoRequest();
req.setMessageCount(5);
var interval = new Duration();
interval.setSeconds(1);
req.setMessageInterval(interval);
req.setMessage("test");
const srv = client.serverStreamingEcho(req, {});
srv.on("data", function(msg: ServerStreamingEchoResponse) {
console.log("Streaming success");
console.log("Message:", msg.getMessage());
});
srv.on("error", function(err: grpcWeb.Error) {
console.log("Server stream errored!");
console.log("Error:", err.message);
console.log("Code:", err.code);
});
srv.on("end", function() {
console.log("Server stream finished");
});
function makeServerStreamingEchoAbortRequest() {
const req = new ServerStreamingEchoRequest();
req.setMessageCount(5);
var interval = new Duration();
interval.setSeconds(1);
req.setMessageInterval(interval);
req.setMessage("test");
const srv = client.serverStreamingEchoAbort(req);
srv.on("data", function (msg: ServerStreamingEchoResponse) {
console.log("Streaming success");
console.log("Message:", msg.getMessage());
});
srv.on("end", function () {
console.log("Server stream finished");
});
srv.on("status", function (status: Status) {
if (status.code != grpc.Code.OK) {
console.log("Got streaming error (as expected)");
console.log("Error:", status.details);
console.log("Code:", status.code);
it("should allow setting and getting a Duration field", () => {
const msg = new WellKnownMessage();
const myDuration = new Duration();
myDuration.setSeconds(1000);
msg.setMyDuration(myDuration);
assert.strictEqual(msg.getMyDuration()!.getSeconds() as number, 1000);
});
function makeServerStreamingEchoAbortRequest() {
const req = new ServerStreamingEchoRequest();
req.setMessageCount(5);
var interval = new Duration();
interval.setSeconds(1);
req.setMessageInterval(interval);
req.setMessage("test");
const srv = client.serverStreamingEchoAbort(req, {});
srv.on("data", function(msg: ServerStreamingEchoResponse) {
console.log("Streaming success");
console.log("Message:", msg.getMessage());
});
srv.on("error", function(err: grpcWeb.Error) {
console.log("Server stream errored (as expected)");
console.log("Error:", err.message);
console.log("Code:", err.code);
});
srv.on("end", function() {
console.log("Server stream finished");
});
function makeServerStreamingEchoRequest() {
const req = new ServerStreamingEchoRequest();
req.setMessageCount(5);
var interval = new Duration();
interval.setSeconds(1);
req.setMessageInterval(interval);
req.setMessage("test");
const srv = client.serverStreamingEcho(req);
srv.on("data", function(msg: ServerStreamingEchoResponse) {
console.log("Streaming success");
console.log("Message:", msg.getMessage());
});
srv.on("end", function() {
console.log("Server stream finished");
});
srv.on("status", function(status: Status) {
if (status.code != grpc.Code.OK) {
console.log("Got streaming error");
console.log("Error:", status.details);
console.log("Code:", status.code);
function makeServerStreamingEchoAbortRequest() {
const req = new ServerStreamingEchoRequest();
req.setMessageCount(5);
var interval = new Duration();
interval.setSeconds(1);
req.setMessageInterval(interval);
req.setMessage("test");
const srv = client.serverStreamingEchoAbort(req);
srv.on("data", function(msg: ServerStreamingEchoResponse) {
console.log("Streaming success");
console.log("Message:", msg.getMessage());
});
srv.on("end", function() {
console.log("Server stream finished");
});
srv.on("status", function(status: Status) {
if (status.code != grpc.Code.OK) {
console.log("Got streaming error (as expected)");
console.log("Error:", status.details);
console.log("Code:", status.code);
function makeServerStreamingEchoRequest() {
const req = new ServerStreamingEchoRequest();
req.setMessageCount(5);
var interval = new Duration();
interval.setSeconds(1);
req.setMessageInterval(interval);
req.setMessage("test");
const srv = client.serverStreamingEcho(req);
srv.on("data", function (msg: ServerStreamingEchoResponse) {
console.log("Streaming success");
console.log("Message:", msg.getMessage());
});
srv.on("end", function () {
console.log("Server stream finished");
});
srv.on("status", function (status: Status) {
if (status.code != grpc.Code.OK) {
console.log("Got streaming error");
console.log("Error:", status.details);
console.log("Code:", status.code);
const req = new OIDCConfigUpdate();
req.setProjectId(this.projectId);
req.setApplicationId(this.app.id);
req.setRedirectUrisList(this.app.oidcConfig.redirectUrisList);
req.setResponseTypesList(this.app.oidcConfig.responseTypesList);
req.setAuthMethodType(this.app.oidcConfig.authMethodType);
req.setPostLogoutRedirectUrisList(this.app.oidcConfig.postLogoutRedirectUrisList);
req.setGrantTypesList(this.app.oidcConfig.grantTypesList);
req.setApplicationType(this.app.oidcConfig.applicationType);
req.setDevMode(this.app.oidcConfig.devMode);
req.setAccessTokenType(this.app.oidcConfig.accessTokenType);
req.setAccessTokenRoleAssertion(this.app.oidcConfig.accessTokenRoleAssertion);
req.setIdTokenRoleAssertion(this.app.oidcConfig.idTokenRoleAssertion);
req.setIdTokenUserinfoAssertion(this.app.oidcConfig.idTokenUserinfoAssertion);
if (this.clockSkewSeconds?.value) {
const dur = new Duration();
dur.setSeconds(Math.floor(this.clockSkewSeconds?.value));
dur.setNanos((Math.floor(this.clockSkewSeconds?.value % 1) * 10000));
req.setClockSkew(dur);
}
this.mgmtService
.UpdateOIDCAppConfig(req)
.then(() => {
if (this.app.oidcConfig) {
this.currentAuthMethod = this.authMethodFromPartialConfig(this.app.oidcConfig);
}
this.toast.showInfo('APP.TOAST.OIDCUPDATED', true);
})
.catch(error => {
this.toast.showError(error);
});
}
const req = new UpdateOIDCAppConfigRequest();
req.setProjectId(this.projectId);
req.setAppId(this.app.id);
req.setRedirectUrisList(this.app.oidcConfig.redirectUrisList);
req.setResponseTypesList(this.app.oidcConfig.responseTypesList);
req.setAuthMethodType(this.app.oidcConfig.authMethodType);
req.setPostLogoutRedirectUrisList(this.app.oidcConfig.postLogoutRedirectUrisList);
req.setGrantTypesList(this.app.oidcConfig.grantTypesList);
req.setAppType(this.app.oidcConfig.appType);
req.setDevMode(this.app.oidcConfig.devMode);
req.setAccessTokenType(this.app.oidcConfig.accessTokenType);
req.setAccessTokenRoleAssertion(this.app.oidcConfig.accessTokenRoleAssertion);
req.setIdTokenRoleAssertion(this.app.oidcConfig.idTokenRoleAssertion);
req.setIdTokenUserinfoAssertion(this.app.oidcConfig.idTokenUserinfoAssertion);
if (this.clockSkewSeconds?.value) {
const dur = new Duration();
dur.setSeconds(Math.floor(this.clockSkewSeconds?.value));
dur.setNanos((Math.floor(this.clockSkewSeconds?.value % 1) * 10000));
req.setClockSkew(dur);
}
this.mgmtService
.updateOIDCAppConfig(req)
.then(() => {
if (this.app.oidcConfig) {
const config = { oidc: this.app.oidcConfig };
this.currentAuthMethod = this.authMethodFromPartialConfig(config);
}
this.toast.showInfo('APP.TOAST.OIDCUPDATED', true);
})
.catch(error => {
this.toast.showError(error);
});