Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cord-sdk/server

Package Overview
Dependencies
Maintainers
13
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cord-sdk/server - npm Package Compare versions

Comparing version 1.36.2-canary.1 to 1.36.2-canary.2

21

dist/cjs/index.js

@@ -111,2 +111,22 @@ 'use strict';

}
/**
* Takes a request payload, and returns a typed object for handling
* Cord webhook notifications.
* @param requestPayload Request payload from a webhook request. Should have
* a similar structure to express style request object.
* @returns A typed object to support handling webhook events. See:
* https://docs.cord.com/reference/events-webhook
*/
function parseEventPayload(requestPayload) {
switch (requestPayload.body.type) {
case 'thread-message-added':
return requestPayload.body;
case 'notification-created':
return requestPayload.body;
case 'url-verification':
return requestPayload.body;
default:
throw 'unknown webhook request type.';
}
}

@@ -117,4 +137,5 @@ exports.getApplicationManagementAuthToken = getApplicationManagementAuthToken;

exports.getServerAuthToken = getServerAuthToken;
exports.parseEventPayload = parseEventPayload;
exports.tryValidateWebhookSignature = tryValidateWebhookSignature;
exports.validateWebhookSignature = validateWebhookSignature;
//# sourceMappingURL=index.js.map

22

dist/mjs/index.js

@@ -87,4 +87,24 @@ import { createHmac } from 'crypto';

}
/**
* Takes a request payload, and returns a typed object for handling
* Cord webhook notifications.
* @param requestPayload Request payload from a webhook request. Should have
* a similar structure to express style request object.
* @returns A typed object to support handling webhook events. See:
* https://docs.cord.com/reference/events-webhook
*/
function parseEventPayload(requestPayload) {
switch (requestPayload.body.type) {
case 'thread-message-added':
return requestPayload.body;
case 'notification-created':
return requestPayload.body;
case 'url-verification':
return requestPayload.body;
default:
throw 'unknown webhook request type.';
}
}
export { getApplicationManagementAuthToken, getClientAuthToken, getProjectManagementAuthToken, getServerAuthToken, tryValidateWebhookSignature, validateWebhookSignature };
export { getApplicationManagementAuthToken, getClientAuthToken, getProjectManagementAuthToken, getServerAuthToken, parseEventPayload, tryValidateWebhookSignature, validateWebhookSignature };
//# sourceMappingURL=index.js.map
import * as jwt from 'jsonwebtoken';
import type { ClientAuthTokenData } from '@cord-sdk/types';
import type { ClientAuthTokenData, ThreadMessageAddedWebhookPayload, NotificationCreatedWebhookPayload, URLVerificationWebhookPayload } from '@cord-sdk/types';
export type { ClientAuthTokenData };

@@ -13,5 +13,8 @@ export type CommonAuthTokenOptions = {

export type GetApplicationManagementAuthTokenOptions = CommonAuthTokenOptions;
export type WebhookPayload = ThreadMessageAddedWebhookPayload | NotificationCreatedWebhookPayload | URLVerificationWebhookPayload;
export type WebhookRequest = {
header(name: string): string;
body: string;
body: {
type: string;
};
};

@@ -50,1 +53,10 @@ export declare function getClientAuthToken(project_id: string, project_secret: string, payload: Omit<ClientAuthTokenData, 'app_id' | 'project_id'>, options?: GetClientAuthTokenOptions): string;

export declare function tryValidateWebhookSignature(requestPayload: WebhookRequest, clientSecret: string): boolean;
/**
* Takes a request payload, and returns a typed object for handling
* Cord webhook notifications.
* @param requestPayload Request payload from a webhook request. Should have
* a similar structure to express style request object.
* @returns A typed object to support handling webhook events. See:
* https://docs.cord.com/reference/events-webhook
*/
export declare function parseEventPayload(requestPayload: WebhookRequest): WebhookPayload;

4

package.json
{
"name": "@cord-sdk/server",
"description": "Server-side portion of the Cord SDK",
"version": "1.36.2-canary.1",
"version": "1.36.2-canary.2",
"homepage": "https://docs.cord.com/",

@@ -25,3 +25,3 @@ "license": "MIT",

"devDependencies": {
"@cord-sdk/types": "1.36.2-canary.1",
"@cord-sdk/types": "1.36.2-canary.2",
"@types/jsonwebtoken": "^8.5.9",

@@ -28,0 +28,0 @@ "typescript": "~5.1.6"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc