package.dist.src.internal.webhook-client.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sdk Show documentation
Show all versions of sdk Show documentation
Client SDK for Momento services
The newest version!
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WebhookClient = void 0;
const generated_types_1 = require("@gomomento/generated-types");
var grpcWebhook = generated_types_1.webhook.webhook;
const sdk_core_1 = require("@gomomento/sdk-core");
const grpc_js_1 = require("@grpc/grpc-js");
const headers_interceptor_1 = require("./grpc/headers-interceptor");
const package_json_1 = require("../../package.json");
const cache_service_error_mapper_1 = require("../errors/cache-service-error-mapper");
const utils_1 = require("@gomomento/sdk-core/dist/src/internal/utils");
const retry_interceptor_1 = require("./grpc/retry-interceptor");
const utils_2 = require("@gomomento/sdk-core/dist/src/utils");
class WebhookClient {
/**
* @param {TopicClientProps} props
*/
constructor(props) {
this.credentialProvider = props.credentialProvider;
this.logger = props.configuration.getLoggerFactory().getLogger(this);
this.cacheServiceErrorMapper = new cache_service_error_mapper_1.CacheServiceErrorMapper(props.configuration.getThrowOnErrors());
const headers = [
new headers_interceptor_1.Header('Authorization', props.credentialProvider.getAuthToken()),
new headers_interceptor_1.Header('agent', `nodejs:webhook:${package_json_1.version}`),
new headers_interceptor_1.Header('runtime-version', `nodejs:${process.versions.node}`),
];
this.unaryInterceptors = [
headers_interceptor_1.HeaderInterceptor.createHeadersInterceptor(headers),
retry_interceptor_1.RetryInterceptor.createRetryInterceptor({
clientName: 'WebhookClient',
loggerFactory: props.configuration.getLoggerFactory(),
overallRequestTimeoutMs: WebhookClient.DEFAULT_REQUEST_TIMEOUT_MS,
}),
];
this.webhookClient = new generated_types_1.webhook.webhook.WebhookClient(props.credentialProvider.getControlEndpoint(), props.credentialProvider.isControlEndpointSecure()
? grpc_js_1.ChannelCredentials.createSsl()
: grpc_js_1.ChannelCredentials.createInsecure());
}
async deleteWebhook(id) {
try {
(0, utils_1.validateCacheName)(id.cacheName);
}
catch (err) {
return this.cacheServiceErrorMapper.returnOrThrowError(err, err => new sdk_core_1.DeleteWebhook.Error(err));
}
const request = new grpcWebhook._DeleteWebhookRequest({
webhook_id: new grpcWebhook._WebhookId({
cache_name: id.cacheName,
webhook_name: id.webhookName,
}),
});
this.logger.debug('issuing "DeleteWebhook" request');
return await new Promise((resolve, reject) => {
this.webhookClient.DeleteWebhook(request, { interceptors: this.unaryInterceptors }, (err, _resp) => {
if (err) {
this.cacheServiceErrorMapper.resolveOrRejectError({
err: err,
errorResponseFactoryFn: e => new sdk_core_1.DeleteWebhook.Error(e),
resolveFn: resolve,
rejectFn: reject,
});
}
else {
resolve(new sdk_core_1.DeleteWebhook.Success());
}
});
});
}
async listWebhooks(cache) {
try {
(0, utils_1.validateCacheName)(cache);
}
catch (err) {
return this.cacheServiceErrorMapper.returnOrThrowError(err, err => new sdk_core_1.ListWebhooks.Error(err));
}
const request = new grpcWebhook._ListWebhookRequest({ cache_name: cache });
this.logger.debug('issuing "ListWebhooks" request');
return await new Promise((resolve, reject) => {
this.webhookClient.ListWebhooks(request, { interceptors: this.unaryInterceptors }, (err, resp) => {
if (err || !resp) {
this.cacheServiceErrorMapper.resolveOrRejectError({
err: err,
errorResponseFactoryFn: e => new sdk_core_1.ListWebhooks.Error(e),
resolveFn: resolve,
rejectFn: reject,
});
}
else {
const webhooks = resp.webhook.map(wh => {
const webhook = {
id: {
cacheName: wh.webhook_id.cache_name,
webhookName: wh.webhook_id.webhook_name,
},
topicName: wh.topic_name,
destination: new sdk_core_1.PostUrlWebhookDestination(wh.destination.post_url),
};
return webhook;
});
resolve(new sdk_core_1.ListWebhooks.Success(webhooks));
}
});
});
}
async putWebhook(webhook) {
try {
(0, utils_1.validateCacheName)(webhook.id.cacheName);
(0, utils_1.validateTopicName)(webhook.topicName);
(0, utils_1.validateWebhookName)(webhook.id.webhookName);
}
catch (err) {
return this.cacheServiceErrorMapper.returnOrThrowError(err, err => new sdk_core_1.PutWebhook.Error(err));
}
const request = new grpcWebhook._PutWebhookRequest({
webhook: new grpcWebhook._Webhook({
webhook_id: new grpcWebhook._WebhookId({
cache_name: webhook.id.cacheName,
webhook_name: webhook.id.webhookName,
}),
destination: new grpcWebhook._WebhookDestination({
post_url: webhook.destination.url(),
}),
topic_name: webhook.topicName,
}),
});
this.logger.debug('issuing "PutWebhook" request');
return await new Promise((resolve, reject) => {
this.webhookClient.PutWebhook(request, { interceptors: this.unaryInterceptors }, (err, resp) => {
if (err || !resp) {
this.cacheServiceErrorMapper.resolveOrRejectError({
err: err,
errorResponseFactoryFn: e => new sdk_core_1.PutWebhook.Error(e),
resolveFn: resolve,
rejectFn: reject,
});
}
else {
resolve(new sdk_core_1.PutWebhook.Success(resp.secret_string));
}
});
});
}
async getWebhookSecret(id) {
try {
(0, utils_1.validateCacheName)(id.cacheName);
(0, utils_1.validateWebhookName)(id.webhookName);
}
catch (err) {
return this.cacheServiceErrorMapper.returnOrThrowError(err, err => new sdk_core_1.GetWebhookSecret.Error(err));
}
const request = new grpcWebhook._GetWebhookSecretRequest({
webhook_name: id.webhookName,
cache_name: id.cacheName,
});
this.logger.debug('issuing "GetWebhookSecret" request');
return await new Promise((resolve, reject) => {
this.webhookClient.GetWebhookSecret(request, { interceptors: this.unaryInterceptors }, (err, resp) => {
if (err || !resp) {
this.cacheServiceErrorMapper.resolveOrRejectError({
err: err,
errorResponseFactoryFn: e => new sdk_core_1.GetWebhookSecret.Error(e),
resolveFn: resolve,
rejectFn: reject,
});
}
else {
resolve(new sdk_core_1.GetWebhookSecret.Success({
secret: resp.secret_string,
webhookName: resp.webhook_name,
cacheName: resp.cache_name,
}));
}
});
});
}
async rotateWebhookSecret(id) {
try {
(0, utils_1.validateCacheName)(id.cacheName);
(0, utils_1.validateWebhookName)(id.webhookName);
}
catch (err) {
return this.cacheServiceErrorMapper.returnOrThrowError(err, err => new sdk_core_1.RotateWebhookSecret.Error(err));
}
const webhookId = grpcWebhook._WebhookId.fromObject({
webhook_name: id.webhookName,
cache_name: id.cacheName,
});
const request = new grpcWebhook._RotateWebhookSecretRequest({
webhook_id: webhookId,
});
this.logger.debug('issuing "RotateWebhookSecret" request');
return await new Promise((resolve, reject) => {
this.webhookClient.RotateWebhookSecret(request, { interceptors: this.unaryInterceptors }, (err, resp) => {
if (err || !resp) {
this.cacheServiceErrorMapper.resolveOrRejectError({
err: err,
errorResponseFactoryFn: e => new sdk_core_1.RotateWebhookSecret.Error(e),
resolveFn: resolve,
rejectFn: reject,
});
}
else {
resolve(new sdk_core_1.RotateWebhookSecret.Success({
secret: resp.secret_string,
webhookName: id.webhookName,
cacheName: id.cacheName,
}));
}
});
});
}
}
exports.WebhookClient = WebhookClient;
WebhookClient.DEFAULT_REQUEST_TIMEOUT_MS = (0, utils_2.secondsToMilliseconds)(5);
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2ViaG9vay1jbGllbnQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvaW50ZXJuYWwvd2ViaG9vay1jbGllbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEsZ0VBQW1EO0FBQ25ELElBQU8sV0FBVyxHQUFHLHlCQUFPLENBQUMsT0FBTyxDQUFDO0FBQ3JDLGtEQVc2QjtBQUM3QiwyQ0FBOEQ7QUFFOUQsb0VBQXFFO0FBQ3JFLHFEQUEyQztBQUMzQyxxRkFBNkU7QUFDN0UsdUVBSXFEO0FBQ3JELGdFQUEwRDtBQUUxRCw4REFBeUU7QUFFekUsTUFBYSxhQUFhO0lBU3hCOztPQUVHO0lBQ0gsWUFBWSxLQUEwQjtRQUNwQyxJQUFJLENBQUMsa0JBQWtCLEdBQUcsS0FBSyxDQUFDLGtCQUFrQixDQUFDO1FBQ25ELElBQUksQ0FBQyxNQUFNLEdBQUcsS0FBSyxDQUFDLGFBQWEsQ0FBQyxnQkFBZ0IsRUFBRSxDQUFDLFNBQVMsQ0FBQyxJQUFJLENBQUMsQ0FBQ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mhvb2tzKFxuICAgICAgICByZXF1ZXN0LFxuICAgICAgICB7aW50ZXJjZXB0b3JzOiB0aGlzLnVuYXJ5SW50ZXJjZXB0b3JzfSxcbiAgICAgICAgKGVyciwgcmVzcCkgPT4ge1xuICAgICAgICAgIGlmIChlcnIgfHwgIXJlc3ApIHtcbiAgICAgICAgICAgIHRoaXMuY2FjaGVTZXJ2aWNlRXJyb3JNYXBwZXIucmVzb2x2ZU9yUmVqZWN0RXJyb3Ioe1xuICAgICAgICAgICAgICBlcnI6IGVycixcbiAgICAgICAgICAgICAgZXJyb3JSZXNwb25zZUZhY3RvcnlGbjogZSA9PiBuZXcgTGlzdFdlYmhvb2tzLkVycm9yKGUpLFxuICAgICAgICAgICAgICByZXNvbHZlRm46IHJlc29sdmUsXG4gICAgICAgICAgICAgIHJlamVjdEZuOiByZWplY3QsXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uc3Qgd2ViaG9va3MgPSByZXNwLndlYmhvb2subWFwKHdoID0+IHtcbiAgICAgICAgICAgICAgY29uc3Qgd2ViaG9vazogV2ViaG9vayA9IHtcbiAgICAgICAgICAgICAgICBpZDoge1xuICAgICAgICAgICAgICAgICAgY2FjaGVOYW1lOiB3aC53ZWJob29rX2lkLmNhY2hlX25hbWUsXG4gICAgICAgICAgICAgICAgICB3ZWJob29rTmFtZTogd2gud2ViaG9va19pZC53ZWJob29rX25hbWUsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB0b3BpY05hbWU6IHdoLnRvcGljX25hbWUsXG4gICAgICAgICAgICAgICAgZGVzdGluYXRpb246IG5ldyBQb3N0VXJsV2ViaG9va0Rlc3RpbmF0aW9uKFxuICAgICAgICAgICAgICAgICAgd2guZGVzdGluYXRpb24ucG9zdF91cmxcbiAgICAgICAgICAgICAgICApLFxuICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICByZXR1cm4gd2ViaG9vaztcbiAgICAgICA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0X3VybDogd2ViaG9vay5kZXN0aW5hdGlvbi51cmwoKSxcbiAgICAgICAgfSksXG4gICAgICAgIHRvcGljX25hbWU6IHdlYmhvb2sudG9waWNOYW1lLFxuICAgICAgfSksXG4gICAgfSk7XG4gICAgdGhpcy5sb2dnZXIuZGVidWcoJ2lzc3VpbmcgXCJQdXRXZWJob29rXCIgcmVxdWVzdCcpO1xuXG4gICAgcmV0dXJuIGF3YWl0IG5ldyBQcm9taXNlPFB1dFdlYmhvb2suUmVzcG9uc2U+KChyZXNvbHZlLCByZWplY3QpID0+IHtcbiAgICAgIHRoaXMud2ViaG9va0NsaWVudC5QdXRXZWJob29rKFxuICAgICAgICByZXF1ZXN0LFxuICAgICAgICB7aW50ZXJjZXB0b3JzOiB0aGlzLnVuYXJ5SW50ZXJjZXB0b3JzfSxcbiAgICAgICAgKGVyciwgcmVzcCkgPT4ge1xuICAgICAgICAgIGlmIChlcnIgfHwgIXJlc3ApIHtcbiAgICAgICAgICAgIHRoaXMuY2FjaGVTZXJ2aWNlRXJyb3JNYXBwZXIucmVzb2x2ZU9yUmVqZWN0RXJyb3Ioe1xuICAgICAgICAgICAgICBlcnI6IGVycixcbiAgICAgICAgICAgICAgZXJyb3JSZXNwb25zZUZhY3RvcnlGbjogZSA9PiBuZXcgUHV0V2ViaG9vay5FcnJvcihlKSxcbiAgICAgICAgICAgICAgcmVzb2x2ZUZuOiByZXNvbHZlLFxuICAgICAgICAgICAgICByZWplY3RGbjogcmVqZWN0LFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJlc29sdmUobmV3IFB1dFdlYmhvb2suU3VjY2VzcyhyZXNwLnNlY3JldF9zdHJpbmcpKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICk7XG4gICAgfSk7XG4gIH1cblxuICBhc3luYyBnZXRXZWJob29rU2VjcmV0KGlkOiBXZWJob29rSWQpOiBQcm9taXNlPEdldFdlYmhvb2tTZWN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lcnI6IGVycixcbiAgICAgICAgICAgICAgZXJyb3JSZXNwb25zZUZhY3RvcnlGbjogZSA9PiBuZXcgR2V0V2ViaG9va1NlY3JldC5FcnJvcihlKSxcbiAgICAgICAgICAgICAgcmVzb2x2ZUZuOiByZXNvbHZlLFxuICAgICAgICAgICAgICByZWplY3RGbjogcmVqZWN0LFxuICAgICAgICAgICAgfSk7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJlc29sdmUoXG4gICAgICAgICAgICAgIG5ldyBHZXRXZWJob29rU2VjcmV0LlN1Y2Nlc3Moe1xuICAgICAgICAgICAgICAgIHNlY3JldDogcmVzcC5zZWNyZXRfc3RyaW5nLFxuICAgICAgICAgICAgICAgIHdlYmhvb2tOYW1lOiByZXNwLndlYmhvb2tfbmFtZSxcbiAgICAgICAgICAgICAgICBjYWNoZU5hbWU6IHJlc3AuY2FjaGVfbmFtZSxcbiAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICApO1xuICAgIH0pO1xuICB9XG5cbiAgYXN5bmMgcm90YXRlV2ViaG9va1NlY3JldChcbiAgICBpZDogV2ViaG9va0lkXG4gICk6IFByb21pc2U8Um90YXRlV2ViaG9va1NlY3JldC5SZXNwb25zZT4ge1xuICAgIHRyeSB7XG4gICAgICB2YWxpZGF0ZUNhY2hlTmFtZShpZC5jYWNoZU5hbWUpO1xuICAgICAgdmFsaWRhdGVXZWJob29rTmFtZShpZC53ZWJob29rTmFtZSk7XG4gICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICByZXR1cm4gdGhpcy5jYWNoZVNlcnZpY2VFcnJvck1hcHBlci5yZXR1cm5PclRocm93RXJyb3IoXG4gICAgICAgIGVyciBhcyBFcnJvcixcbiAgICAgICAgZXJyID0+IG5ldyBSb3RhdGVXZWJob29rU2VjcmV0LkVycm9yKGVycilcbiAgICAgICk7XG4gICAgfVxuXG4gICAgY29uc3Qgd2Vi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pO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgcmVzb2x2ZShcbiAgICAgICAgICAgICAgICBuZXcgUm90YXRlV2ViaG9va1NlY3JldC5TdWNjZXNzKHtcbiAgICAgICAgICAgICAgICAgIHNlY3JldDogcmVzcC5zZWNyZXRfc3RyaW5nLFxuICAgICAgICAgICAgICAgICAgd2ViaG9va05hbWU6IGlkLndlYmhvb2tOYW1lLFxuICAgICAgICAgICAgICAgICAgY2FjaGVOYW1lOiBpZC5jYWNoZU5hbWUsXG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICk7XG4gICAgICB9XG4gICAgKTtcbiAgfVxufVxuIl19
© 2015 - 2025 Weber Informatics LLC | Privacy Policy