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

cloudevents-sdk

Package Overview
Dependencies
Maintainers
2
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cloudevents-sdk - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

19

CHANGELOG.md

@@ -5,2 +5,21 @@ # Changelog

### [2.0.2](https://github.com/cloudevents/sdk-javascript/compare/v2.0.1...v2.0.2) (2020-06-08)
### Bug Fixes
* add correct types to improve TypeScript behavior ([#202](https://github.com/cloudevents/sdk-javascript/issues/202)) ([da365e0](https://github.com/cloudevents/sdk-javascript/commit/da365e09ebcb493f63e6962800230899f1b978ad))
* fix references to constants - remove .js extension ([#200](https://github.com/cloudevents/sdk-javascript/issues/200)) ([c757a2b](https://github.com/cloudevents/sdk-javascript/commit/c757a2bce1e5432c420db7a4ae4755058964cff7))
* use /lib in gitignore so src/lib is not ignored ([#199](https://github.com/cloudevents/sdk-javascript/issues/199)) ([fba3294](https://github.com/cloudevents/sdk-javascript/commit/fba3294ce04a30be0e5ab551a1fa01727dc8d1f8))
### Documentation
* **README:** fix example typo ([#208](https://github.com/cloudevents/sdk-javascript/issues/208)) ([9857eda](https://github.com/cloudevents/sdk-javascript/commit/9857eda5ef85e64898f7c742e1ffabb714236d6a)), closes [#173](https://github.com/cloudevents/sdk-javascript/issues/173)
### Miscellaneous
* ts formatter ([#210](https://github.com/cloudevents/sdk-javascript/issues/210)) ([90782a9](https://github.com/cloudevents/sdk-javascript/commit/90782a9e17dbd293d379f0ec134cf7fb06d0f36f))
### [2.0.1](https://github.com/cloudevents/sdk-javascript/compare/v2.0.0...v2.0.1) (2020-06-01)

@@ -7,0 +26,0 @@

2

lib/bindings/http/emitter_binary.js

@@ -14,3 +14,3 @@ "use strict";

const EmitterV3 = require("./v03").BinaryEmitter;
const { HEADERS, BINARY_HEADERS_03, BINARY_HEADERS_1, HEADER_CONTENT_TYPE, DEFAULT_CONTENT_TYPE, DATA_ATTRIBUTE, SPEC_V1, SPEC_V03 } = require("./constants.js");
const { HEADERS, BINARY_HEADERS_03, BINARY_HEADERS_1, HEADER_CONTENT_TYPE, DEFAULT_CONTENT_TYPE, DATA_ATTRIBUTE, SPEC_V1, SPEC_V03 } = require("./constants");
const defaults = {

@@ -17,0 +17,0 @@ [HEADERS]: {

@@ -13,3 +13,3 @@ "use strict";

/** @typedef {import("../../cloudevent")} CloudEvent */
const { DATA_ATTRIBUTE, DEFAULT_CE_CONTENT_TYPE, HEADERS, HEADER_CONTENT_TYPE } = require("./constants.js");
const { DATA_ATTRIBUTE, DEFAULT_CE_CONTENT_TYPE, HEADERS, HEADER_CONTENT_TYPE } = require("./constants");
const defaults = {

@@ -16,0 +16,0 @@ [HEADERS]: {

@@ -1,2 +0,2 @@

import { CloudEvent } from "../../cloudevent.js";
import { CloudEvent } from "../../cloudevent";
/**

@@ -10,3 +10,3 @@ * A class which is capable of sending binary and structured events using

export declare class HTTPEmitter {
url: URL | undefined;
url: URL | string;
binary: any;

@@ -24,4 +24,4 @@ structured: any;

*/
constructor({ url, version }?: {
url: undefined;
constructor({ url, version }: {
url?: string | undefined;
version?: any;

@@ -45,5 +45,5 @@ });

send(event: CloudEvent, { url, mode, ...httpOpts }?: {
url: undefined;
url?: string | undefined;
mode?: string | undefined;
}): any;
}

@@ -38,3 +38,3 @@ "use strict";

*/
constructor({ url, version = SPEC_V1 } = { url: undefined }) {
constructor({ url = "", version = SPEC_V1 }) {
if (version !== SPEC_V03 && version !== SPEC_V1) {

@@ -65,4 +65,4 @@ throw new TypeError(`Unknown CloudEvent specification version: ${version}`);

*/
send(event, _a = { url: undefined }) {
var { url, mode = "binary" } = _a, httpOpts = __rest(_a, ["url", "mode"]);
send(event, _a = {}) {
var { url = "", mode = "binary" } = _a, httpOpts = __rest(_a, ["url", "mode"]);
// @ts-ignore Type 'URL | undefined' is not assignable to type 'undefined'. Type 'URL' is not assignable to type 'undefined'.ts(2322)

@@ -69,0 +69,0 @@ if (!url) {

@@ -0,1 +1,2 @@

import { CloudEvent } from "../../cloudevent.js";
/** @typedef {import("../../cloudevent")} CloudEvent */

@@ -30,5 +31,3 @@ /**

*/
accept(headers: {}, body: {
specversion: string;
}): any;
accept(headers: {}, body: {}): CloudEvent;
}
"use strict";
const ReceiverV1 = require("./v1/receiver_binary_1.js");
const ReceiverV3 = require("./v03/receiver_binary_0_3.js");
const { SPEC_V03, SPEC_V1 } = require("./constants.js");
const { SPEC_V03, SPEC_V1 } = require("./constants");
const { check, parse } = require("./validation/binary.js");

@@ -6,0 +6,0 @@ /** @typedef {import("../../cloudevent")} CloudEvent */

"use strict";
const ReceiverV1 = require("./v1/receiver_structured_1.js");
const ReceiverV3 = require("./v03/receiver_structured_0_3.js");
const { SPEC_V03, SPEC_V1 } = require("./constants.js");
const { SPEC_V03, SPEC_V1 } = require("./constants");
const { check, parse } = require("./validation/structured.js");

@@ -6,0 +6,0 @@ /** @typedef {import("../../cloudevent")} CloudEvent */

"use strict";
const { HEADER_CONTENT_TYPE, BINARY_HEADERS_03: { CONTENT_ENCODING, SUBJECT, TYPE, SPEC_VERSION, SOURCE, ID, TIME, SCHEMA_URL } } = require("../constants.js");
const { HEADER_CONTENT_TYPE, BINARY_HEADERS_03: { CONTENT_ENCODING, SUBJECT, TYPE, SPEC_VERSION, SOURCE, ID, TIME, SCHEMA_URL } } = require("../constants");
function parser(header, parser = (v) => v) {

@@ -4,0 +4,0 @@ return { headerName: header, parse: parser };

@@ -5,15 +5,9 @@ export = Receiver;

[x: number]: {
[x: number]: import("../../../formats/json/parser.js") | {
parse(payload: any): any;
};
[x: number]: any;
};
null: {
[x: number]: import("../../../formats/json/parser.js") | {
parse(payload: any): any;
};
[x: number]: any;
};
undefined: {
[x: number]: import("../../../formats/json/parser.js") | {
parse(payload: any): any;
};
[x: number]: any;
};

@@ -31,4 +25,4 @@ };

specversion: any;
Spec: typeof import("./spec_0_3.js");
spec: import("./spec_0_3.js");
Spec: typeof import("./spec_0_3");
spec: import("./spec_0_3");
}
"use strict";
const { SPEC_V03, MIME_JSON, MIME_OCTET_STREAM, ENCODING_BASE64, HEADER_CONTENT_TYPE, BINARY_HEADERS_03 } = require("../constants.js");
const { SPEC_V03, MIME_JSON, MIME_OCTET_STREAM, ENCODING_BASE64, HEADER_CONTENT_TYPE, BINARY_HEADERS_03 } = require("../constants");
const Spec = require("./spec_0_3.js");

@@ -4,0 +4,0 @@ const JSONParser = require("../../../formats/json/parser.js");

export = Receiver;
declare class Receiver {
parserByMime: {
[x: number]: import("../../../formats/json/parser.js");
[x: number]: any;
};
parserMap: Map<any, any>;
allowedContentTypes: any[];
Spec: typeof import("./spec_0_3.js");
spec: import("./spec_0_3.js");
Spec: typeof import("./spec_0_3");
spec: import("./spec_0_3");
}
"use strict";
const { MIME_JSON, MIME_CE_JSON, STRUCTURED_ATTRS_03: { TYPE, SPEC_VERSION, SOURCE, ID, TIME, SCHEMA_URL, CONTENT_ENCODING, CONTENT_TYPE, SUBJECT, DATA } } = require("../constants.js");
const { MIME_JSON, MIME_CE_JSON, STRUCTURED_ATTRS_03: { TYPE, SPEC_VERSION, SOURCE, ID, TIME, SCHEMA_URL, CONTENT_ENCODING, CONTENT_TYPE, SUBJECT, DATA } } = require("../constants");
const Spec = require("./spec_0_3.js");

@@ -4,0 +4,0 @@ const JSONParser = require("../../../formats/json/parser.js");

"use strict";
const { HEADER_CONTENT_TYPE, BINARY_HEADERS_1: { SUBJECT, TYPE, SPEC_VERSION, SOURCE, ID, TIME, DATA_SCHEMA } } = require("../constants.js");
const { HEADER_CONTENT_TYPE, BINARY_HEADERS_1: { SUBJECT, TYPE, SPEC_VERSION, SOURCE, ID, TIME, DATA_SCHEMA } } = require("../constants");
function parser(header, parser = (v) => v) {

@@ -4,0 +4,0 @@ return { headerName: header, parse: parser };

export = Receiver;
declare class Receiver {
parserByType: {
[x: number]: import("../../../formats/json/parser") | {
parse(payload: any): any;
};
[x: number]: any;
};
parsersByEncoding: {
[x: number]: {
[x: number]: import("../../../formats/json/parser") | {
parse(payload: any): any;
};
[x: number]: any;
};
null: {
[x: number]: import("../../../formats/json/parser") | {
parse(payload: any): any;
};
[x: number]: any;
};
undefined: {
[x: number]: import("../../../formats/json/parser") | {
parse(payload: any): any;
};
[x: number]: any;
};

@@ -24,0 +16,0 @@ };

export = Receiver;
declare class Receiver {
parserByMime: {
[x: number]: import("../../../formats/json/parser.js");
[x: number]: any;
};
parserMap: Map<any, any>;
allowedContentTypes: any[];
Spec: typeof import("./spec_1.js");
spec: import("./spec_1.js");
Spec: typeof import("./spec_1");
spec: import("./spec_1");
}
"use strict";
const { MIME_CE_JSON, STRUCTURED_ATTRS_1: { TYPE, SPEC_VERSION, SOURCE, ID, TIME, DATA_SCHEMA, CONTENT_TYPE, SUBJECT, DATA, DATA_BASE64, MIME_JSON } } = require("../constants.js");
const { MIME_CE_JSON, STRUCTURED_ATTRS_1: { TYPE, SPEC_VERSION, SOURCE, ID, TIME, DATA_SCHEMA, CONTENT_TYPE, SUBJECT, DATA, DATA_BASE64, MIME_JSON } } = require("../constants");
const Spec = require("./spec_1.js");

@@ -4,0 +4,0 @@ const JSONParser = require("../../../formats/json/parser.js");

@@ -5,3 +5,3 @@ "use strict";

const ValidationError = require("./validation_error.js");
const { HEADER_CONTENT_TYPE, MIME_JSON, DEFAULT_SPEC_VERSION_HEADER } = require("../constants.js");
const { HEADER_CONTENT_TYPE, MIME_JSON, DEFAULT_SPEC_VERSION_HEADER } = require("../constants");
const { isString, isObject, isBase64 } = require("./fun.js");

@@ -8,0 +8,0 @@ function check(payload, headers, receiver) {

"use strict";
const ValidationError = require("./validation_error.js");
const Constants = require("../constants.js");
const Constants = require("../constants");
const { isDefinedOrThrow, isStringOrObjectOrThrow } = require("./fun.js");

@@ -5,0 +5,0 @@ // Specific sanity for content-type header

@@ -5,3 +5,3 @@ "use strict";

const { sanityAndClone, validateArgs } = require("./commons.js");
const { HEADER_CONTENT_TYPE } = require("../constants.js");
const { HEADER_CONTENT_TYPE } = require("../constants");
function check(payload, headers, receiver) {

@@ -8,0 +8,0 @@ validateArgs(payload, headers);

@@ -11,3 +11,3 @@ "use strict";

const fun_js_1 = require("./bindings/http/validation/fun.js");
const { SPEC_V1, SPEC_V03 } = require("./bindings/http/constants.js");
const { SPEC_V1, SPEC_V03 } = require("./bindings/http/constants");
/**

@@ -74,3 +74,3 @@ * A CloudEvent describes event data in common formats to provide

this.formatter = new formatter_js_1.default();
this.extensions = [];
this.extensions = {};
}

@@ -77,0 +77,0 @@ /**

@@ -1,6 +0,5 @@

export = Base64Parser;
declare class Base64Parser {
decorator: any;
constructor(decorator: any);
decorator: any;
parse(payload: any): string;
parse(payload: any): any;
}

@@ -1,2 +0,1 @@

export = JSONFormatter;
declare class JSONFormatter {

@@ -6,1 +5,2 @@ format(payload: any): any;

}
export default JSONFormatter;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
class JSONFormatter {

@@ -14,2 +15,2 @@ /*

}
module.exports = JSONFormatter;
exports.default = JSONFormatter;

@@ -1,5 +0,9 @@

export = JSONParser;
declare const isString: any, isDefinedOrThrow: any, isStringOrObjectOrThrow: any;
declare const ValidationError: any;
declare const invalidPayloadTypeError: any;
declare const nullOrUndefinedPayload: any;
declare const asJSON: (v: object | string) => any;
declare class JSONParser {
constructor(decorator: any);
decorator: any;
constructor(decorator: Base64Parser);
/**

@@ -10,3 +14,3 @@ * Parses the payload with an optional decorator

*/
parse(payload: object | string): object;
parse(payload: object | string): any;
}
"use strict";
const { isString, isDefinedOrThrow, isStringOrObjectOrThrow } = require("../../bindings/http/validation/fun.js");
const { isString, isDefinedOrThrow, isStringOrObjectOrThrow } = require("../../bindings/http/validation/fun");
const ValidationError = require("../../bindings/http/validation/validation_error.js");

@@ -4,0 +4,0 @@ const invalidPayloadTypeError = new ValidationError("invalid payload type, allowed are: string or object");

{
"name": "cloudevents-sdk",
"version": "2.0.1",
"version": "2.0.2",
"description": "CloudEvents SDK for JavaScript",

@@ -12,7 +12,8 @@ "main": "index.js",

"fix": "standardx --fix",
"pretest": "npm run lint",
"pretest": "npm run lint && npm run test:ts",
"test": "mocha test/**/*.js",
"test:ts": "mocha --require ts-node/register ./test-ts/**/*.ts",
"coverage": "nyc --reporter=lcov --reporter=text npm run test",
"coverage-publish": "wget -qO - https://coverage.codacy.com/get.sh | bash -s report -l JavaScript -r coverage/lcov.info",
"generate-docs": "typedoc --tsconfig ./tsconfig.json src",
"generate-docs": "typedoc --tsconfig ./tsconfig.json --plugin typedoc-plugin-markdown src",
"release": "standard-version",

@@ -105,5 +106,6 @@ "prepublish": "npm run build"

"devDependencies": {
"@paztis/typedoc": "^0.1.6",
"@types/ajv": "^1.0.0",
"@types/axios": "^0.14.0",
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/node": "^13.13.9",

@@ -119,2 +121,5 @@ "chai": "~4.2.0",

"standardx": "^5.0.0",
"ts-node": "^8.10.2",
"typedoc": "^0.17.7",
"typedoc-plugin-markdown": "^2.2.17",
"typescript": "^3.8.3"

@@ -121,0 +126,0 @@ },

@@ -8,28 +8,15 @@ # JavaScript SDK for CloudEvents

[![vulnerabilities](https://snyk.io/test/github/cloudevents/sdk-javascript/badge.svg)](https://snyk.io/test/github/cloudevents/sdk-javascript)
[![licence](https://img.shields.io/github/license/cloudevents/sdk-javascript)](http://www.apache.org/licenses/LICENSE-2.0)
The CloudEvents SDK for JavaScript.
This module will help you to:
## Features
* Represent CloudEvents in memory
* Use [Event Formats](https://github.com/cloudevents/spec/blob/v1.0/spec.md#event-format) to serialize/deserialize CloudEvents
* Use [Protocol Bindings](https://github.com/cloudevents/spec/blob/v1.0/spec.md#protocol-binding) to send/receive CloudEvents
* Serialize and deserialize CloudEvents in different [event formats](https://github.com/cloudevents/spec/blob/v1.0/spec.md#event-format).
* Send and recieve CloudEvents with via different [protocol bindings](https://github.com/cloudevents/spec/blob/v1.0/spec.md#protocol-binding).
_Note:_ Supported
[CloudEvents specification](https://github.com/cloudevents/spec): 0.3, 1.0
_Note:_ Supports CloudEvent versions 0.3, 1.0
### A Note on Versioning
## Installation
The CloudEvents protocol version is distinct from this module's version number.
For example, this module may be versioned as v2.0.0 but support the v0.3 and v1.0
versions of the CloudEvent specification.
## Usage
**See the full working example: [here](./examples/express-ex).**
### Installation
The CloudEvents SDK requires a current LTS version of Node.js. At the moment

@@ -39,3 +26,3 @@ those are Node.js 10.x and Node.js 12.x. To install in your Node.js project:

```console
npm install --save cloudevents-sdk
npm install cloudevents-sdk
```

@@ -54,3 +41,3 @@

CloudEvent,
HTTPReceiever
HTTPReceiver
} = require("cloudevents-sdk");

@@ -57,0 +44,0 @@

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