🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@smithy/core

Package Overview
Dependencies
Maintainers
2
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/core - npm Package Compare versions

Comparing version
3.29.6
to
3.29.7
+34
-11
dist-cjs/submodules/event-streams/index.browser.js
const { Crc32 } = require("@smithy/core/checksum");
const { toHex, fromHex, toUtf8, fromUtf8 } = require("@smithy/core/serde");
const { TypeRegistry } = require("@smithy/core/schema");

@@ -594,3 +595,4 @@ class Int64 {

defaultContentType;
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }) {
compositeErrorRegistry;
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, compositeErrorRegistry, }) {
this.marshaller = marshaller;

@@ -601,2 +603,3 @@ this.serializer = serializer;

this.defaultContentType = defaultContentType;
this.compositeErrorRegistry = compositeErrorRegistry;
}

@@ -717,12 +720,5 @@ async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {

}
if (hasBindings) {
return {
[unionMember]: out,
};
}
if (body.byteLength === 0) {
return {
[unionMember]: {},
};
}
return {
[unionMember]: await this.readEventMember(eventStreamSchema, body, hasBindings, out),
};
}

@@ -767,2 +763,29 @@ return {

}
async readEventMember(eventStreamSchema, body, hasBindings, out) {
let ErrCtor;
const staticStructuralSchema = eventStreamSchema.getSchema();
if (Array.isArray(staticStructuralSchema) && staticStructuralSchema[0] === -3) {
const namespace = staticStructuralSchema[1];
const nsRegistry = TypeRegistry.for(namespace);
this.compositeErrorRegistry?.copyFrom(nsRegistry);
ErrCtor = (this.compositeErrorRegistry ?? nsRegistry)?.getErrorCtor(staticStructuralSchema);
}
const dataObject = hasBindings
? out
: body.byteLength === 0
? {}
: await this.deserializer.read(eventStreamSchema, body);
if (ErrCtor) {
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
const metadata = {};
const $fault = eventStreamSchema.getMergedTraits().error;
if ($fault) {
metadata.$fault = $fault;
}
return Object.assign(new ErrCtor({}), metadata, {
message,
}, dataObject);
}
return dataObject;
}
writeEventBody(unionMember, unionSchema, event) {

@@ -769,0 +792,0 @@ const serializer = this.serializer;

const { Crc32 } = require("@smithy/core/checksum");
const { toHex, fromHex, toUtf8, fromUtf8 } = require("@smithy/core/serde");
const { Readable } = require("node:stream");
const { TypeRegistry } = require("@smithy/core/schema");

@@ -619,3 +620,4 @@ class Int64 {

defaultContentType;
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }) {
compositeErrorRegistry;
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, compositeErrorRegistry, }) {
this.marshaller = marshaller;

@@ -626,2 +628,3 @@ this.serializer = serializer;

this.defaultContentType = defaultContentType;
this.compositeErrorRegistry = compositeErrorRegistry;
}

@@ -742,12 +745,5 @@ async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {

}
if (hasBindings) {
return {
[unionMember]: out,
};
}
if (body.byteLength === 0) {
return {
[unionMember]: {},
};
}
return {
[unionMember]: await this.readEventMember(eventStreamSchema, body, hasBindings, out),
};
}

@@ -792,2 +788,29 @@ return {

}
async readEventMember(eventStreamSchema, body, hasBindings, out) {
let ErrCtor;
const staticStructuralSchema = eventStreamSchema.getSchema();
if (Array.isArray(staticStructuralSchema) && staticStructuralSchema[0] === -3) {
const namespace = staticStructuralSchema[1];
const nsRegistry = TypeRegistry.for(namespace);
this.compositeErrorRegistry?.copyFrom(nsRegistry);
ErrCtor = (this.compositeErrorRegistry ?? nsRegistry)?.getErrorCtor(staticStructuralSchema);
}
const dataObject = hasBindings
? out
: body.byteLength === 0
? {}
: await this.deserializer.read(eventStreamSchema, body);
if (ErrCtor) {
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
const metadata = {};
const $fault = eventStreamSchema.getMergedTraits().error;
if ($fault) {
metadata.$fault = $fault;
}
return Object.assign(new ErrCtor({}), metadata, {
message,
}, dataObject);
}
return dataObject;
}
writeEventBody(unionMember, unionSchema, event) {

@@ -794,0 +817,0 @@ const serializer = this.serializer;

@@ -158,2 +158,3 @@ const { Uint8ArrayBlobAdapter, sdkStreamMixin, splitEvery, splitHeader, fromBase64, _parseEpochTimestamp, _parseRfc7231DateTime, _parseRfc3339DateTimeWithOffset, LazyJsonString, NumericValue, toUtf8, fromUtf8, generateIdempotencyToken, toBase64, dateToUtcString, quoteHeader } = require("@smithy/core/serde");

defaultContentType: this.getDefaultContentType(),
compositeErrorRegistry: this.compositeErrorRegistry,
});

@@ -160,0 +161,0 @@ }

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

import { TypeRegistry } from "@smithy/core/schema";
import { fromUtf8, toUtf8 } from "@smithy/core/serde";

@@ -8,3 +9,4 @@ export class EventStreamSerde {

defaultContentType;
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }) {
compositeErrorRegistry;
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, compositeErrorRegistry, }) {
this.marshaller = marshaller;

@@ -15,2 +17,3 @@ this.serializer = serializer;

this.defaultContentType = defaultContentType;
this.compositeErrorRegistry = compositeErrorRegistry;
}

@@ -131,12 +134,5 @@ async serializeEventStream({ eventStream, requestSchema, initialRequest, }) {

}
if (hasBindings) {
return {
[unionMember]: out,
};
}
if (body.byteLength === 0) {
return {
[unionMember]: {},
};
}
return {
[unionMember]: await this.readEventMember(eventStreamSchema, body, hasBindings, out),
};
}

@@ -181,2 +177,29 @@ return {

}
async readEventMember(eventStreamSchema, body, hasBindings, out) {
let ErrCtor;
const staticStructuralSchema = eventStreamSchema.getSchema();
if (Array.isArray(staticStructuralSchema) && staticStructuralSchema[0] === -3) {
const namespace = staticStructuralSchema[1];
const nsRegistry = TypeRegistry.for(namespace);
this.compositeErrorRegistry?.copyFrom(nsRegistry);
ErrCtor = (this.compositeErrorRegistry ?? nsRegistry)?.getErrorCtor(staticStructuralSchema);
}
const dataObject = hasBindings
? out
: body.byteLength === 0
? {}
: await this.deserializer.read(eventStreamSchema, body);
if (ErrCtor) {
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
const metadata = {};
const $fault = eventStreamSchema.getMergedTraits().error;
if ($fault) {
metadata.$fault = $fault;
}
return Object.assign(new ErrCtor({}), metadata, {
message,
}, dataObject);
}
return dataObject;
}
writeEventBody(unionMember, unionSchema, event) {

@@ -183,0 +206,0 @@ const serializer = this.serializer;

@@ -126,2 +126,3 @@ import { NormalizedSchema, TypeRegistry, translateTraits } from "@smithy/core/schema";

defaultContentType: this.getDefaultContentType(),
compositeErrorRegistry: this.compositeErrorRegistry,
});

@@ -128,0 +129,0 @@ }

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

import type { NormalizedSchema } from "@smithy/core/schema";
import { type NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
import type { EventStreamMarshaller, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";

@@ -15,6 +15,7 @@ /**

private readonly defaultContentType;
private readonly compositeErrorRegistry?;
/**
* Properties are injected by the HttpProtocol.
*/
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }: {
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, compositeErrorRegistry, }: {
marshaller: EventStreamMarshaller;

@@ -25,2 +26,3 @@ serializer: ShapeSerializer<string | Uint8Array>;

defaultContentType: string;
compositeErrorRegistry?: TypeRegistry;
});

@@ -55,2 +57,8 @@ /**

/**
* Reads and returns an event member. For error schemas, resolves the registered
* error constructor from the TypeRegistry and wraps the deserialized value
* so that it can be thrown as a typed exception instance by the caller.
*/
private readEventMember;
/**
* @param unionMember - member name within the structure that contains an event stream union.

@@ -57,0 +65,0 @@ * @param unionSchema - schema of the union.

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

import { NormalizedSchema } from "@smithy/core/schema";
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
import { EventStreamMarshaller, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";

@@ -15,6 +15,7 @@ /**

private readonly defaultContentType;
private readonly compositeErrorRegistry?;
/**
* Properties are injected by the HttpProtocol.
*/
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, }: {
constructor({ marshaller, serializer, deserializer, serdeContext, defaultContentType, compositeErrorRegistry, }: {
marshaller: EventStreamMarshaller;

@@ -25,2 +26,3 @@ serializer: ShapeSerializer<string | Uint8Array>;

defaultContentType: string;
compositeErrorRegistry?: TypeRegistry;
});

@@ -55,2 +57,8 @@ /**

/**
* Reads and returns an event member. For error schemas, resolves the registered
* error constructor from the TypeRegistry and wraps the deserialized value
* so that it can be thrown as a typed exception instance by the caller.
*/
private readEventMember;
/**
* @param unionMember - member name within the structure that contains an event stream union.

@@ -57,0 +65,0 @@ * @param unionSchema - schema of the union.

{
"name": "@smithy/core",
"version": "3.29.6",
"version": "3.29.7",
"homepage": "https://github.com/smithy-lang/smithy-typescript/tree/main/packages/core",

@@ -5,0 +5,0 @@ "license": "Apache-2.0",