Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@smithy/core

Package Overview
Dependencies
Maintainers
3
Versions
121
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.22.1
to
3.23.0
+13
-10
dist-cjs/submodules/cbor/index.js

@@ -993,4 +993,4 @@ 'use strict';

deserializer = this.codec.createDeserializer();
constructor({ defaultNamespace }) {
super({ defaultNamespace });
constructor({ defaultNamespace, errorTypeRegistries, }) {
super({ defaultNamespace, errorTypeRegistries });
}

@@ -1039,2 +1039,6 @@ getShapeId() {

const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
const errorMetadata = {
$metadata: metadata,
$fault: response.statusCode <= 500 ? "client" : "server",
};
let namespace = this.options.defaultNamespace;

@@ -1044,7 +1048,5 @@ if (errorName.includes("#")) {

}
const errorMetadata = {
$metadata: metadata,
$fault: response.statusCode <= 500 ? "client" : "server",
};
const registry = schema.TypeRegistry.for(namespace);
const registry = this.compositeErrorRegistry;
const nsRegistry = schema.TypeRegistry.for(namespace);
registry.copyFrom(nsRegistry);
let errorSchema;

@@ -1058,6 +1060,7 @@ try {

}
const synthetic = schema.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
const baseExceptionSchema = synthetic.getBaseException();
const syntheticRegistry = schema.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
registry.copyFrom(syntheticRegistry);
const baseExceptionSchema = registry.getBaseException();
if (baseExceptionSchema) {
const ErrorCtor = synthetic.getErrorCtor(baseExceptionSchema);
const ErrorCtor = registry.getErrorCtor(baseExceptionSchema);
throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);

@@ -1064,0 +1067,0 @@ }

@@ -36,5 +36,10 @@ 'use strict';

options;
compositeErrorRegistry;
constructor(options) {
super();
this.options = options;
this.compositeErrorRegistry = schema.TypeRegistry.for(options.defaultNamespace);
for (const etr of options.errorTypeRegistries ?? []) {
this.compositeErrorRegistry.copyFrom(etr);
}
}

@@ -41,0 +46,0 @@ getRequestType() {

@@ -569,6 +569,20 @@ 'use strict';

}
copyFrom(other) {
const { schemas, exceptions } = this;
for (const [k, v] of other.schemas) {
if (!schemas.has(k)) {
schemas.set(k, v);
}
}
for (const [k, v] of other.exceptions) {
if (!exceptions.has(k)) {
exceptions.set(k, v);
}
}
}
register(shapeId, schema) {
const qualifiedName = this.normalizeShapeId(shapeId);
const registry = TypeRegistry.for(qualifiedName.split("#")[0]);
registry.schemas.set(qualifiedName, schema);
for (const r of [this, TypeRegistry.for(qualifiedName.split("#")[0])]) {
r.schemas.set(qualifiedName, schema);
}
}

@@ -584,8 +598,13 @@ getSchema(shapeId) {

const $error = es;
const registry = TypeRegistry.for($error[1]);
registry.schemas.set($error[1] + "#" + $error[2], $error);
registry.exceptions.set($error, ctor);
const ns = $error[1];
for (const r of [this, TypeRegistry.for(ns)]) {
r.schemas.set(ns + "#" + $error[2], $error);
r.exceptions.set($error, ctor);
}
}
getErrorCtor(es) {
const $error = es;
if (this.exceptions.has($error)) {
return this.exceptions.get($error);
}
const registry = TypeRegistry.for($error[1]);

@@ -592,0 +611,0 @@ return registry.exceptions.get($error);

import { RpcProtocol } from "@smithy/core/protocols";
import { deref, NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
import { TypeRegistry } from "@smithy/core/schema";
import { deref, NormalizedSchema } from "@smithy/core/schema";
import { getSmithyContext } from "@smithy/util-middleware";

@@ -10,4 +11,4 @@ import { CborCodec } from "./CborCodec";

deserializer = this.codec.createDeserializer();
constructor({ defaultNamespace }) {
super({ defaultNamespace });
constructor({ defaultNamespace, errorTypeRegistries, }) {
super({ defaultNamespace, errorTypeRegistries });
}

@@ -56,2 +57,6 @@ getShapeId() {

const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
const errorMetadata = {
$metadata: metadata,
$fault: response.statusCode <= 500 ? "client" : "server",
};
let namespace = this.options.defaultNamespace;

@@ -61,7 +66,5 @@ if (errorName.includes("#")) {

}
const errorMetadata = {
$metadata: metadata,
$fault: response.statusCode <= 500 ? "client" : "server",
};
const registry = TypeRegistry.for(namespace);
const registry = this.compositeErrorRegistry;
const nsRegistry = TypeRegistry.for(namespace);
registry.copyFrom(nsRegistry);
let errorSchema;

@@ -75,6 +78,7 @@ try {

}
const synthetic = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
const baseExceptionSchema = synthetic.getBaseException();
const syntheticRegistry = TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace);
registry.copyFrom(syntheticRegistry);
const baseExceptionSchema = registry.getBaseException();
if (baseExceptionSchema) {
const ErrorCtor = synthetic.getErrorCtor(baseExceptionSchema);
const ErrorCtor = registry.getErrorCtor(baseExceptionSchema);
throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);

@@ -81,0 +85,0 @@ }

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

import { NormalizedSchema, translateTraits } from "@smithy/core/schema";
import { NormalizedSchema, translateTraits, TypeRegistry } from "@smithy/core/schema";
import { HttpRequest, HttpResponse } from "@smithy/protocol-http";

@@ -6,5 +6,10 @@ import { SerdeContext } from "./SerdeContext";

options;
compositeErrorRegistry;
constructor(options) {
super();
this.options = options;
this.compositeErrorRegistry = TypeRegistry.for(options.defaultNamespace);
for (const etr of options.errorTypeRegistries ?? []) {
this.compositeErrorRegistry.copyFrom(etr);
}
}

@@ -11,0 +16,0 @@ getRequestType() {

@@ -17,6 +17,20 @@ export class TypeRegistry {

}
copyFrom(other) {
const { schemas, exceptions } = this;
for (const [k, v] of other.schemas) {
if (!schemas.has(k)) {
schemas.set(k, v);
}
}
for (const [k, v] of other.exceptions) {
if (!exceptions.has(k)) {
exceptions.set(k, v);
}
}
}
register(shapeId, schema) {
const qualifiedName = this.normalizeShapeId(shapeId);
const registry = TypeRegistry.for(qualifiedName.split("#")[0]);
registry.schemas.set(qualifiedName, schema);
for (const r of [this, TypeRegistry.for(qualifiedName.split("#")[0])]) {
r.schemas.set(qualifiedName, schema);
}
}

@@ -32,8 +46,13 @@ getSchema(shapeId) {

const $error = es;
const registry = TypeRegistry.for($error[1]);
registry.schemas.set($error[1] + "#" + $error[2], $error);
registry.exceptions.set($error, ctor);
const ns = $error[1];
for (const r of [this, TypeRegistry.for(ns)]) {
r.schemas.set(ns + "#" + $error[2], $error);
r.exceptions.set($error, ctor);
}
}
getErrorCtor(es) {
const $error = es;
if (this.exceptions.has($error)) {
return this.exceptions.get($error);
}
const registry = TypeRegistry.for($error[1]);

@@ -40,0 +59,0 @@ return registry.exceptions.get($error);

import { RpcProtocol } from "@smithy/core/protocols";
import { TypeRegistry } from "@smithy/core/schema";
import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions } from "@smithy/types";

@@ -10,7 +11,12 @@ import { CborCodec } from "./CborCodec";

export declare class SmithyRpcV2CborProtocol extends RpcProtocol {
/**
* @override
*/
protected compositeErrorRegistry: TypeRegistry;
private codec;
protected serializer: import("./CborCodec").CborShapeSerializer;
protected deserializer: import("./CborCodec").CborShapeDeserializer;
constructor({ defaultNamespace }: {
constructor({ defaultNamespace, errorTypeRegistries, }: {
defaultNamespace: string;
errorTypeRegistries?: TypeRegistry[];
});

@@ -17,0 +23,0 @@ getShapeId(): string;

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

import { NormalizedSchema } from "@smithy/core/schema";
import { type TypeRegistry, NormalizedSchema } from "@smithy/core/schema";
import { HttpRequest } from "@smithy/protocol-http";

@@ -12,2 +12,6 @@ import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, Schema, SerdeFunctions } from "@smithy/types";

export declare abstract class HttpBindingProtocol extends HttpProtocol {
/**
* @override
*/
protected compositeErrorRegistry: TypeRegistry;
serializeRequest<Input extends object>(operationSchema: OperationSchema, _input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;

@@ -14,0 +18,0 @@ protected serializeQuery(ns: NormalizedSchema, data: any, query: HttpRequest["query"]): void;

import type { EventStreamSerde } from "@smithy/core/event-streams";
import { NormalizedSchema } from "@smithy/core/schema";
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
import type { ClientProtocol, Codec, Endpoint, EndpointBearer, EndpointV2, EventStreamMarshaller, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";

@@ -13,7 +13,20 @@ import { SerdeContext } from "./SerdeContext";

defaultNamespace: string;
errorTypeRegistries?: TypeRegistry[];
};
/**
* An error registry having the namespace of the modeled service,
* but combining all error schemas found within the service closure.
*
* Used to look up error schema during deserialization.
*/
protected compositeErrorRegistry: TypeRegistry;
protected abstract serializer: ShapeSerializer<string | Uint8Array>;
protected abstract deserializer: ShapeDeserializer<string | Uint8Array>;
/**
* @param options.defaultNamespace - used by various implementing classes.
* @param options.errorTypeRegistries - registry instances that contribute to error deserialization.
*/
protected constructor(options: {
defaultNamespace: string;
errorTypeRegistries?: TypeRegistry[];
});

@@ -20,0 +33,0 @@ abstract getShapeId(): string;

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

import { type TypeRegistry } from "@smithy/core/schema";
import type { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, SerdeFunctions } from "@smithy/types";

@@ -9,4 +10,8 @@ import { HttpProtocol } from "./HttpProtocol";

export declare abstract class RpcProtocol extends HttpProtocol {
/**
* @override
*/
protected compositeErrorRegistry: TypeRegistry;
serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
}

@@ -20,4 +20,11 @@ import type { Schema as ISchema, StaticErrorSchema } from "@smithy/types";

/**
* Adds the given schema to a type registry with the same namespace.
* Copies entries from another instance without changing the namespace of self.
* The composition is additive but non-destructive and will not overwrite existing entries.
*
* @param other - another TypeRegistry.
*/
copyFrom(other: TypeRegistry): void;
/**
* Adds the given schema to a type registry with the same namespace, and this registry.
*
* @param shapeId - to be registered.

@@ -24,0 +31,0 @@ * @param schema - to be registered.

import { RpcProtocol } from "@smithy/core/protocols";
import { TypeRegistry } from "@smithy/core/schema";
import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, SerdeFunctions } from "@smithy/types";

@@ -10,7 +11,12 @@ import { CborCodec } from "./CborCodec";

export declare class SmithyRpcV2CborProtocol extends RpcProtocol {
/**
* @override
*/
protected compositeErrorRegistry: TypeRegistry;
private codec;
protected serializer: import("./CborCodec").CborShapeSerializer;
protected deserializer: import("./CborCodec").CborShapeDeserializer;
constructor({ defaultNamespace }: {
constructor({ defaultNamespace, errorTypeRegistries, }: {
defaultNamespace: string;
errorTypeRegistries?: TypeRegistry[];
});

@@ -17,0 +23,0 @@ getShapeId(): string;

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

import { NormalizedSchema } from "@smithy/core/schema";
import { TypeRegistry, NormalizedSchema } from "@smithy/core/schema";
import { HttpRequest } from "@smithy/protocol-http";

@@ -12,2 +12,6 @@ import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, Schema, SerdeFunctions } from "@smithy/types";

export declare abstract class HttpBindingProtocol extends HttpProtocol {
/**
* @override
*/
protected compositeErrorRegistry: TypeRegistry;
serializeRequest<Input extends object>(operationSchema: OperationSchema, _input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;

@@ -14,0 +18,0 @@ protected serializeQuery(ns: NormalizedSchema, data: any, query: HttpRequest["query"]): void;

import { EventStreamSerde } from "@smithy/core/event-streams";
import { NormalizedSchema } from "@smithy/core/schema";
import { NormalizedSchema, TypeRegistry } from "@smithy/core/schema";
import { ClientProtocol, Codec, Endpoint, EndpointBearer, EndpointV2, EventStreamMarshaller, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, ResponseMetadata, Schema, SerdeFunctions, ShapeDeserializer, ShapeSerializer } from "@smithy/types";

@@ -13,7 +13,20 @@ import { SerdeContext } from "./SerdeContext";

defaultNamespace: string;
errorTypeRegistries?: TypeRegistry[];
};
/**
* An error registry having the namespace of the modeled service,
* but combining all error schemas found within the service closure.
*
* Used to look up error schema during deserialization.
*/
protected compositeErrorRegistry: TypeRegistry;
protected abstract serializer: ShapeSerializer<string | Uint8Array>;
protected abstract deserializer: ShapeDeserializer<string | Uint8Array>;
/**
* @param options.defaultNamespace - used by various implementing classes.
* @param options.errorTypeRegistries - registry instances that contribute to error deserialization.
*/
protected constructor(options: {
defaultNamespace: string;
errorTypeRegistries?: TypeRegistry[];
});

@@ -20,0 +33,0 @@ abstract getShapeId(): string;

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

import { TypeRegistry } from "@smithy/core/schema";
import { EndpointBearer, HandlerExecutionContext, HttpRequest as IHttpRequest, HttpResponse as IHttpResponse, MetadataBearer, OperationSchema, SerdeFunctions } from "@smithy/types";

@@ -9,4 +10,8 @@ import { HttpProtocol } from "./HttpProtocol";

export declare abstract class RpcProtocol extends HttpProtocol {
/**
* @override
*/
protected compositeErrorRegistry: TypeRegistry;
serializeRequest<Input extends object>(operationSchema: OperationSchema, input: Input, context: HandlerExecutionContext & SerdeFunctions & EndpointBearer): Promise<IHttpRequest>;
deserializeResponse<Output extends MetadataBearer>(operationSchema: OperationSchema, context: HandlerExecutionContext & SerdeFunctions, response: IHttpResponse): Promise<Output>;
}

@@ -20,4 +20,11 @@ import { Schema as ISchema, StaticErrorSchema } from "@smithy/types";

/**
* Adds the given schema to a type registry with the same namespace.
* Copies entries from another instance without changing the namespace of self.
* The composition is additive but non-destructive and will not overwrite existing entries.
*
* @param other - another TypeRegistry.
*/
copyFrom(other: TypeRegistry): void;
/**
* Adds the given schema to a type registry with the same namespace, and this registry.
*
* @param shapeId - to be registered.

@@ -24,0 +31,0 @@ * @param schema - to be registered.

{
"name": "@smithy/core",
"version": "3.22.1",
"version": "3.23.0",
"scripts": {

@@ -88,3 +88,3 @@ "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",

"@smithy/util-middleware": "^4.2.8",
"@smithy/util-stream": "^4.5.11",
"@smithy/util-stream": "^4.5.12",
"@smithy/util-utf8": "^4.2.0",

@@ -91,0 +91,0 @@ "@smithy/uuid": "^1.1.0",