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

@aws-sdk/eventstream-marshaller

Package Overview
Dependencies
Maintainers
6
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/eventstream-marshaller - npm Package Compare versions

Comparing version 3.118.1 to 3.120.0

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

# [3.120.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.119.0...v3.120.0) (2022-06-29)
**Note:** Version bump only for package @aws-sdk/eventstream-marshaller
## [3.118.1](https://github.com/aws/aws-sdk-js-v3/compare/v3.118.0...v3.118.1) (2022-06-27)

@@ -8,0 +16,0 @@

26

dist-cjs/EventStreamMarshaller.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventStreamMarshaller = void 0;
const crc32_1 = require("@aws-crypto/crc32");
const HeaderMarshaller_1 = require("./HeaderMarshaller");
const splitMessage_1 = require("./splitMessage");
const eventstream_codec_1 = require("@aws-sdk/eventstream-codec");
class EventStreamMarshaller {
constructor(toUtf8, fromUtf8) {
this.headerMarshaller = new HeaderMarshaller_1.HeaderMarshaller(toUtf8, fromUtf8);
this.codec = new eventstream_codec_1.EventStreamCodec(toUtf8, fromUtf8);
}
marshall({ headers: rawHeaders, body }) {
const headers = this.headerMarshaller.format(rawHeaders);
const length = headers.byteLength + body.byteLength + 16;
const out = new Uint8Array(length);
const view = new DataView(out.buffer, out.byteOffset, out.byteLength);
const checksum = new crc32_1.Crc32();
view.setUint32(0, length, false);
view.setUint32(4, headers.byteLength, false);
view.setUint32(8, checksum.update(out.subarray(0, 8)).digest(), false);
out.set(headers, 12);
out.set(body, headers.byteLength + 12);
view.setUint32(length - 4, checksum.update(out.subarray(8, length - 4)).digest(), false);
return out;
marshall(message) {
return this.codec.encode(message);
}
unmarshall(message) {
const { headers, body } = (0, splitMessage_1.splitMessage)(message);
return { headers: this.headerMarshaller.parse(headers), body };
return this.codec.decode(message);
}
formatHeaders(rawHeaders) {
return this.headerMarshaller.format(rawHeaders);
return this.codec.formatHeaders(rawHeaders);
}
}
exports.EventStreamMarshaller = EventStreamMarshaller;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Int64 = void 0;
const util_hex_encoding_1 = require("@aws-sdk/util-hex-encoding");
class Int64 {
constructor(bytes) {
this.bytes = bytes;
if (bytes.byteLength !== 8) {
throw new Error("Int64 buffers must be exactly 8 bytes");
}
}
static fromNumber(number) {
if (number > 9223372036854775807 || number < -9223372036854775808) {
throw new Error(`${number} is too large (or, if negative, too small) to represent as an Int64`);
}
const bytes = new Uint8Array(8);
for (let i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
bytes[i] = remaining;
}
if (number < 0) {
negate(bytes);
}
return new Int64(bytes);
}
valueOf() {
const bytes = this.bytes.slice(0);
const negative = bytes[0] & 0b10000000;
if (negative) {
negate(bytes);
}
return parseInt((0, util_hex_encoding_1.toHex)(bytes), 16) * (negative ? -1 : 1);
}
toString() {
return String(this.valueOf());
}
}
exports.Int64 = Int64;
function negate(bytes) {
for (let i = 0; i < 8; i++) {
bytes[i] ^= 0xff;
}
for (let i = 7; i > -1; i--) {
bytes[i]++;
if (bytes[i] !== 0)
break;
}
}
var eventstream_codec_1 = require("@aws-sdk/eventstream-codec");
Object.defineProperty(exports, "Int64", { enumerable: true, get: function () { return eventstream_codec_1.Int64; } });

@@ -1,29 +0,14 @@

import { Crc32 } from "@aws-crypto/crc32";
import { HeaderMarshaller } from "./HeaderMarshaller";
import { splitMessage } from "./splitMessage";
import { EventStreamCodec } from "@aws-sdk/eventstream-codec";
var EventStreamMarshaller = (function () {
function EventStreamMarshaller(toUtf8, fromUtf8) {
this.headerMarshaller = new HeaderMarshaller(toUtf8, fromUtf8);
this.codec = new EventStreamCodec(toUtf8, fromUtf8);
}
EventStreamMarshaller.prototype.marshall = function (_a) {
var rawHeaders = _a.headers, body = _a.body;
var headers = this.headerMarshaller.format(rawHeaders);
var length = headers.byteLength + body.byteLength + 16;
var out = new Uint8Array(length);
var view = new DataView(out.buffer, out.byteOffset, out.byteLength);
var checksum = new Crc32();
view.setUint32(0, length, false);
view.setUint32(4, headers.byteLength, false);
view.setUint32(8, checksum.update(out.subarray(0, 8)).digest(), false);
out.set(headers, 12);
out.set(body, headers.byteLength + 12);
view.setUint32(length - 4, checksum.update(out.subarray(8, length - 4)).digest(), false);
return out;
EventStreamMarshaller.prototype.marshall = function (message) {
return this.codec.encode(message);
};
EventStreamMarshaller.prototype.unmarshall = function (message) {
var _a = splitMessage(message), headers = _a.headers, body = _a.body;
return { headers: this.headerMarshaller.parse(headers), body: body };
return this.codec.decode(message);
};
EventStreamMarshaller.prototype.formatHeaders = function (rawHeaders) {
return this.headerMarshaller.format(rawHeaders);
return this.codec.formatHeaders(rawHeaders);
};

@@ -30,0 +15,0 @@ return EventStreamMarshaller;

@@ -1,45 +0,1 @@

import { toHex } from "@aws-sdk/util-hex-encoding";
var Int64 = (function () {
function Int64(bytes) {
this.bytes = bytes;
if (bytes.byteLength !== 8) {
throw new Error("Int64 buffers must be exactly 8 bytes");
}
}
Int64.fromNumber = function (number) {
if (number > 9223372036854775807 || number < -9223372036854775808) {
throw new Error("".concat(number, " is too large (or, if negative, too small) to represent as an Int64"));
}
var bytes = new Uint8Array(8);
for (var i = 7, remaining = Math.abs(Math.round(number)); i > -1 && remaining > 0; i--, remaining /= 256) {
bytes[i] = remaining;
}
if (number < 0) {
negate(bytes);
}
return new Int64(bytes);
};
Int64.prototype.valueOf = function () {
var bytes = this.bytes.slice(0);
var negative = bytes[0] & 128;
if (negative) {
negate(bytes);
}
return parseInt(toHex(bytes), 16) * (negative ? -1 : 1);
};
Int64.prototype.toString = function () {
return String(this.valueOf());
};
return Int64;
}());
export { Int64 };
function negate(bytes) {
for (var i = 0; i < 8; i++) {
bytes[i] ^= 0xff;
}
for (var i = 7; i > -1; i--) {
bytes[i]++;
if (bytes[i] !== 0)
break;
}
}
export { Int64 } from "@aws-sdk/eventstream-codec";

@@ -6,21 +6,11 @@ import { Message, MessageHeaders } from "@aws-sdk/types";

* JavaScript objects and back again into their binary format.
*
* @deprecated Use EventStreamCodec from @aws-sdk/eventstream-codec instead.
*/
export declare class EventStreamMarshaller {
private readonly headerMarshaller;
private readonly codec;
constructor(toUtf8: Encoder, fromUtf8: Decoder);
/**
* Convert a structured JavaScript object with tagged headers into a binary
* event stream message.
*/
marshall({ headers: rawHeaders, body }: Message): Uint8Array;
/**
* Convert a binary event stream message into a JavaScript object with an
* opaque, binary body and tagged, parsed headers.
*/
marshall(message: Message): Uint8Array;
unmarshall(message: ArrayBufferView): Message;
/**
* Convert a structured JavaScript object with tagged headers into a binary
* event stream message header.
*/
formatHeaders(rawHeaders: MessageHeaders): Uint8Array;
}

@@ -1,20 +0,1 @@

import { Int64 as IInt64 } from "@aws-sdk/types";
export interface Int64 extends IInt64 {
}
/**
* A lossless representation of a signed, 64-bit integer. Instances of this
* class may be used in arithmetic expressions as if they were numeric
* primitives, but the binary representation will be preserved unchanged as the
* `bytes` property of the object. The bytes should be encoded as big-endian,
* two's complement integers.
*/
export declare class Int64 {
readonly bytes: Uint8Array;
constructor(bytes: Uint8Array);
static fromNumber(number: number): Int64;
/**
* Called implicitly by infix arithmetic operators.
*/
valueOf(): number;
toString(): string;
}
export { Int64 } from "@aws-sdk/eventstream-codec";

@@ -1,26 +0,1 @@

import { Int64 } from "./Int64";
/**
* An event stream message. The headers and body properties will always be
* defined, with empty headers represented as an object with no keys and an
* empty body represented as a zero-length Uint8Array.
*/
export interface Message {
headers: MessageHeaders;
body: Uint8Array;
}
export declare type MessageHeaders = Record<string, MessageHeaderValue>;
declare type HeaderValue<K extends string, V> = {
type: K;
value: V;
};
export declare type BooleanHeaderValue = HeaderValue<"boolean", boolean>;
export declare type ByteHeaderValue = HeaderValue<"byte", number>;
export declare type ShortHeaderValue = HeaderValue<"short", number>;
export declare type IntegerHeaderValue = HeaderValue<"integer", number>;
export declare type LongHeaderValue = HeaderValue<"long", Int64>;
export declare type BinaryHeaderValue = HeaderValue<"binary", Uint8Array>;
export declare type StringHeaderValue = HeaderValue<"string", string>;
export declare type TimestampHeaderValue = HeaderValue<"timestamp", Date>;
export declare type UuidHeaderValue = HeaderValue<"uuid", string>;
export declare type MessageHeaderValue = BooleanHeaderValue | ByteHeaderValue | ShortHeaderValue | IntegerHeaderValue | LongHeaderValue | BinaryHeaderValue | StringHeaderValue | TimestampHeaderValue | UuidHeaderValue;
export {};
export { Message, MessageHeaders, BooleanHeaderValue, ByteHeaderValue, ShortHeaderValue, IntegerHeaderValue, LongHeaderValue, BinaryHeaderValue, StringHeaderValue, TimestampHeaderValue, UuidHeaderValue, MessageHeaderValue, } from "@aws-sdk/eventstream-codec";

@@ -5,10 +5,7 @@ import { Message, MessageHeaders } from "@aws-sdk/types";

export declare class EventStreamMarshaller {
private readonly headerMarshaller;
private readonly codec;
constructor(toUtf8: Encoder, fromUtf8: Decoder);
marshall({ headers: rawHeaders, body }: Message): Uint8Array;
marshall(message: Message): Uint8Array;
unmarshall(message: ArrayBufferView): Message;
formatHeaders(rawHeaders: MessageHeaders): Uint8Array;
}

@@ -1,12 +0,1 @@

import { Int64 as IInt64 } from "@aws-sdk/types";
export interface Int64 extends IInt64 {
}
export declare class Int64 {
readonly bytes: Uint8Array;
constructor(bytes: Uint8Array);
static fromNumber(number: number): Int64;
valueOf(): number;
toString(): string;
}
export { Int64 } from "@aws-sdk/eventstream-codec";

@@ -1,22 +0,1 @@

import { Int64 } from "./Int64";
export interface Message {
headers: MessageHeaders;
body: Uint8Array;
}
export declare type MessageHeaders = Record<string, MessageHeaderValue>;
declare type HeaderValue<K extends string, V> = {
type: K;
value: V;
};
export declare type BooleanHeaderValue = HeaderValue<"boolean", boolean>;
export declare type ByteHeaderValue = HeaderValue<"byte", number>;
export declare type ShortHeaderValue = HeaderValue<"short", number>;
export declare type IntegerHeaderValue = HeaderValue<"integer", number>;
export declare type LongHeaderValue = HeaderValue<"long", Int64>;
export declare type BinaryHeaderValue = HeaderValue<"binary", Uint8Array>;
export declare type StringHeaderValue = HeaderValue<"string", string>;
export declare type TimestampHeaderValue = HeaderValue<"timestamp", Date>;
export declare type UuidHeaderValue = HeaderValue<"uuid", string>;
export declare type MessageHeaderValue = BooleanHeaderValue | ByteHeaderValue | ShortHeaderValue | IntegerHeaderValue | LongHeaderValue | BinaryHeaderValue | StringHeaderValue | TimestampHeaderValue | UuidHeaderValue;
export {};
export { Message, MessageHeaders, BooleanHeaderValue, ByteHeaderValue, ShortHeaderValue, IntegerHeaderValue, LongHeaderValue, BinaryHeaderValue, StringHeaderValue, TimestampHeaderValue, UuidHeaderValue, MessageHeaderValue, } from "@aws-sdk/eventstream-codec";
{
"name": "@aws-sdk/eventstream-marshaller",
"version": "3.118.1",
"version": "3.120.0",
"scripts": {

@@ -22,10 +22,7 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",

"dependencies": {
"@aws-crypto/crc32": "2.0.0",
"@aws-sdk/eventstream-codec": "3.119.0",
"@aws-sdk/types": "3.110.0",
"@aws-sdk/util-hex-encoding": "3.109.0",
"tslib": "^2.3.1"
},
"devDependencies": {
"@aws-sdk/util-utf8-browser": "3.109.0",
"@aws-sdk/util-utf8-node": "3.109.0",
"@tsconfig/recommended": "1.0.1",

@@ -39,8 +36,2 @@ "@types/node": "^10.0.0",

},
"browser": {
"@aws-sdk/util-utf8-node": "@aws-sdk/util-utf8-browser"
},
"react-native": {
"@aws-sdk/util-utf8-node": "@aws-sdk/util-utf8-browser"
},
"typesVersions": {

@@ -47,0 +38,0 @@ "<4.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