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/util-stream

Package Overview
Dependencies
Maintainers
3
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/util-stream - npm Package Compare versions

Comparing version
4.5.8
to
4.5.9
+20
-9
dist-cjs/getAwsChunkedEncodingStream.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAwsChunkedEncodingStream = void 0;
const stream_1 = require("stream");
const getAwsChunkedEncodingStream = (readableStream, options) => {
exports.getAwsChunkedEncodingStream = getAwsChunkedEncodingStream;
const node_stream_1 = require("node:stream");
const getAwsChunkedEncodingStream_browser_1 = require("./getAwsChunkedEncodingStream.browser");
const stream_type_check_1 = require("./stream-type-check");
function getAwsChunkedEncodingStream(stream, options) {
const readable = stream;
const readableStream = stream;
if ((0, stream_type_check_1.isReadableStream)(readableStream)) {
return (0, getAwsChunkedEncodingStream_browser_1.getAwsChunkedEncodingStream)(readableStream, options);
}
const { base64Encoder, bodyLengthChecker, checksumAlgorithmFn, checksumLocationName, streamHasher } = options;

@@ -11,6 +18,11 @@ const checksumRequired = base64Encoder !== undefined &&

streamHasher !== undefined;
const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : undefined;
const awsChunkedEncodingStream = new stream_1.Readable({ read: () => { } });
readableStream.on("data", (data) => {
const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readable) : undefined;
const awsChunkedEncodingStream = new node_stream_1.Readable({
read: () => { },
});
readable.on("data", (data) => {
const length = bodyLengthChecker(data) || 0;
if (length === 0) {
return;
}
awsChunkedEncodingStream.push(`${length.toString(16)}\r\n`);

@@ -20,3 +32,3 @@ awsChunkedEncodingStream.push(data);

});
readableStream.on("end", async () => {
readable.on("end", async () => {
awsChunkedEncodingStream.push(`0\r\n`);

@@ -31,3 +43,2 @@ if (checksumRequired) {

return awsChunkedEncodingStream;
};
exports.getAwsChunkedEncodingStream = getAwsChunkedEncodingStream;
}

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

Object.defineProperty(exports, "isBlob", {
enumerable: true,
get: function () { return streamTypeCheck.isBlob; }
});
Object.defineProperty(exports, "isReadableStream", {
enumerable: true,
get: function () { return streamTypeCheck.isReadableStream; }
});
exports.Uint8ArrayBlobAdapter = Uint8ArrayBlobAdapter;

@@ -80,7 +88,1 @@ Object.keys(ChecksumStream).forEach(function (k) {

});
Object.keys(streamTypeCheck).forEach(function (k) {
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
enumerable: true,
get: function () { return streamTypeCheck[k]; }
});
});

@@ -1,3 +0,10 @@

import { Readable } from "stream";
export const getAwsChunkedEncodingStream = (readableStream, options) => {
import { Readable } from "node:stream";
import { getAwsChunkedEncodingStream as getAwsChunkedEncodingStreamBrowser } from "./getAwsChunkedEncodingStream.browser";
import { isReadableStream } from "./stream-type-check";
export function getAwsChunkedEncodingStream(stream, options) {
const readable = stream;
const readableStream = stream;
if (isReadableStream(readableStream)) {
return getAwsChunkedEncodingStreamBrowser(readableStream, options);
}
const { base64Encoder, bodyLengthChecker, checksumAlgorithmFn, checksumLocationName, streamHasher } = options;

@@ -8,6 +15,11 @@ const checksumRequired = base64Encoder !== undefined &&

streamHasher !== undefined;
const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : undefined;
const awsChunkedEncodingStream = new Readable({ read: () => { } });
readableStream.on("data", (data) => {
const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readable) : undefined;
const awsChunkedEncodingStream = new Readable({
read: () => { },
});
readable.on("data", (data) => {
const length = bodyLengthChecker(data) || 0;
if (length === 0) {
return;
}
awsChunkedEncodingStream.push(`${length.toString(16)}\r\n`);

@@ -17,3 +29,3 @@ awsChunkedEncodingStream.push(data);

});
readableStream.on("end", async () => {
readable.on("end", async () => {
awsChunkedEncodingStream.push(`0\r\n`);

@@ -28,2 +40,2 @@ if (checksumRequired) {

return awsChunkedEncodingStream;
};
}

@@ -9,2 +9,2 @@ export * from "./blob/Uint8ArrayBlobAdapter";

export * from "./splitStream";
export * from "./stream-type-check";
export { isReadableStream, isBlob } from "./stream-type-check";

@@ -30,7 +30,6 @@ import type { Checksum, Encoder } from "@smithy/types";

/**
* @internal
*
* Wrapper for throwing checksum errors for streams without
* buffering the stream.
*
* @internal
*/

@@ -45,18 +44,19 @@ export declare class ChecksumStream extends Duplex {

/**
* @internal do not call this directly.
* Do not call this directly.
* @internal
*/
_read(size: number): void;
/**
* @internal do not call this directly.
*
* When the upstream source flows data to this stream,
* calculate a step update of the checksum.
* Do not call this directly.
* @internal
*/
_write(chunk: Buffer, encoding: string, callback: (err?: Error) => void): void;
/**
* @internal do not call this directly.
*
* When the upstream source finishes, perform the checksum comparison.
* Do not call this directly.
* @internal
*/
_final(callback: (err?: Error) => void): Promise<void>;
}
import type { ChecksumStreamInit } from "./ChecksumStream.browser";
/**
* @internal
* Alias prevents compiler from turning
* ReadableStream into ReadableStream<any>, which is incompatible
* with the NodeJS.ReadableStream global type.
* @internal
*/
export type ReadableStreamType = ReadableStream;
/**
* @internal
*
* Creates a stream adapter for throwing checksum errors for streams without
* buffering the stream.
* @internal
*/
export declare const createChecksumStream: ({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }: ChecksumStreamInit) => ReadableStreamType;

@@ -5,8 +5,10 @@ import type { Readable } from "stream";

/**
* @internal
*
* Creates a stream mirroring the input stream's interface, but
* performs checksumming when reading to the end of the stream.
* @internal
*/
export declare function createChecksumStream(init: ChecksumStreamInit<ReadableStreamType>): ReadableStreamType;
/**
* @internal
*/
export declare function createChecksumStream(init: ChecksumStreamInit<Readable>): Readable;

@@ -7,3 +7,3 @@ import type { Logger } from "@smithy/types";

* @param size - byte or character length minimum. Buffering occurs when a chunk fails to meet this value.
* @param onBuffer - for emitting warnings when buffering occurs.
* @param logger - for emitting warnings when buffering occurs.
* @returns another stream of the same data and stream class, but buffers chunks until

@@ -13,2 +13,5 @@ * the minimum size is met, except for the last chunk.

export declare function createBufferedReadable(upstream: Readable, size: number, logger?: Logger): Readable;
/**
* @internal
*/
export declare function createBufferedReadable(upstream: ReadableStream, size: number, logger?: Logger): ReadableStream;

@@ -1,6 +0,10 @@

import type { GetAwsChunkedEncodingStream } from "@smithy/types";
import { Readable } from "stream";
import type { GetAwsChunkedEncodingStreamOptions } from "@smithy/types";
import { Readable } from "node:stream";
/**
* @internal
*/
export declare const getAwsChunkedEncodingStream: GetAwsChunkedEncodingStream<Readable>;
export declare function getAwsChunkedEncodingStream(stream: Readable, options: GetAwsChunkedEncodingStreamOptions): Readable;
/**
* @internal
*/
export declare function getAwsChunkedEncodingStream(stream: ReadableStream, options: GetAwsChunkedEncodingStreamOptions): ReadableStream;
/**
* Caution: the input stream must be destroyed separately, this function does not do so.
* @internal
* @param stream
* @param bytes - read head bytes from the stream and discard the rest of it.
*
* Caution: the input stream must be destroyed separately, this function does not do so.
*/
export declare function headStream(stream: ReadableStream, bytes: number): Promise<Uint8Array>;
import type { Readable } from "stream";
/**
* Caution: the input stream must be destroyed separately, this function does not do so.
*
* @internal
* @param stream - to be read.
* @param bytes - read head bytes from the stream and discard the rest of it.
*
* Caution: the input stream must be destroyed separately, this function does not do so.
*/
export declare const headStream: (stream: Readable | ReadableStream, bytes: number) => Promise<Uint8Array>;

@@ -9,2 +9,5 @@ export * from "./blob/Uint8ArrayBlobAdapter";

export * from "./splitStream";
export * from "./stream-type-check";
/**
* @internal
*/
export { isReadableStream, isBlob } from "./stream-type-check";

@@ -8,2 +8,5 @@ import type { Readable } from "stream";

export declare function splitStream(stream: Readable): Promise<[Readable, Readable]>;
/**
* @internal
*/
export declare function splitStream(stream: ReadableStream): Promise<[ReadableStream, ReadableStream]>;
/**
* @internal
* Alias prevents compiler from turning
* ReadableStream into ReadableStream<any>, which is incompatible
* with the NodeJS.ReadableStream global type.
*
* @internal
*/

@@ -7,0 +8,0 @@ type ReadableStreamType = ReadableStream;

@@ -30,7 +30,6 @@ import { Checksum, Encoder } from "@smithy/types";

/**
* @internal
*
* Wrapper for throwing checksum errors for streams without
* buffering the stream.
*
* @internal
*/

@@ -45,18 +44,19 @@ export declare class ChecksumStream extends Duplex {

/**
* @internal do not call this directly.
* Do not call this directly.
* @internal
*/
_read(size: number): void;
/**
* @internal do not call this directly.
*
* When the upstream source flows data to this stream,
* calculate a step update of the checksum.
* Do not call this directly.
* @internal
*/
_write(chunk: Buffer, encoding: string, callback: (err?: Error) => void): void;
/**
* @internal do not call this directly.
*
* When the upstream source finishes, perform the checksum comparison.
* Do not call this directly.
* @internal
*/
_final(callback: (err?: Error) => void): Promise<void>;
}
import { ChecksumStreamInit } from "./ChecksumStream.browser";
/**
* @internal
* Alias prevents compiler from turning
* ReadableStream into ReadableStream<any>, which is incompatible
* with the NodeJS.ReadableStream global type.
* @internal
*/
export type ReadableStreamType = ReadableStream;
/**
* @internal
*
* Creates a stream adapter for throwing checksum errors for streams without
* buffering the stream.
* @internal
*/
export declare const createChecksumStream: ({ expectedChecksum, checksum, source, checksumSourceLocation, base64Encoder, }: ChecksumStreamInit) => ReadableStreamType;

@@ -5,8 +5,10 @@ import { Readable } from "stream";

/**
* @internal
*
* Creates a stream mirroring the input stream's interface, but
* performs checksumming when reading to the end of the stream.
* @internal
*/
export declare function createChecksumStream(init: ChecksumStreamInit<ReadableStreamType>): ReadableStreamType;
/**
* @internal
*/
export declare function createChecksumStream(init: ChecksumStreamInit<Readable>): Readable;

@@ -7,3 +7,3 @@ import { Logger } from "@smithy/types";

* @param size - byte or character length minimum. Buffering occurs when a chunk fails to meet this value.
* @param onBuffer - for emitting warnings when buffering occurs.
* @param logger - for emitting warnings when buffering occurs.
* @returns another stream of the same data and stream class, but buffers chunks until

@@ -13,2 +13,5 @@ * the minimum size is met, except for the last chunk.

export declare function createBufferedReadable(upstream: Readable, size: number, logger?: Logger): Readable;
/**
* @internal
*/
export declare function createBufferedReadable(upstream: ReadableStream, size: number, logger?: Logger): ReadableStream;

@@ -1,6 +0,10 @@

import { GetAwsChunkedEncodingStream } from "@smithy/types";
import { Readable } from "stream";
import { GetAwsChunkedEncodingStreamOptions } from "@smithy/types";
import { Readable } from "node:stream";
/**
* @internal
*/
export declare const getAwsChunkedEncodingStream: GetAwsChunkedEncodingStream<Readable>;
export declare function getAwsChunkedEncodingStream(stream: Readable, options: GetAwsChunkedEncodingStreamOptions): Readable;
/**
* @internal
*/
export declare function getAwsChunkedEncodingStream(stream: ReadableStream, options: GetAwsChunkedEncodingStreamOptions): ReadableStream;
/**
* Caution: the input stream must be destroyed separately, this function does not do so.
* @internal
* @param stream
* @param bytes - read head bytes from the stream and discard the rest of it.
*
* Caution: the input stream must be destroyed separately, this function does not do so.
*/
export declare function headStream(stream: ReadableStream, bytes: number): Promise<Uint8Array>;
import { Readable } from "stream";
/**
* Caution: the input stream must be destroyed separately, this function does not do so.
*
* @internal
* @param stream - to be read.
* @param bytes - read head bytes from the stream and discard the rest of it.
*
* Caution: the input stream must be destroyed separately, this function does not do so.
*/
export declare const headStream: (stream: Readable | ReadableStream, bytes: number) => Promise<Uint8Array>;

@@ -9,2 +9,5 @@ export * from "./blob/Uint8ArrayBlobAdapter";

export * from "./splitStream";
export * from "./stream-type-check";
/**
* @internal
*/
export { isReadableStream, isBlob } from "./stream-type-check";

@@ -11,2 +11,5 @@ import { Readable } from "stream";

]>;
/**
* @internal
*/
export declare function splitStream(stream: ReadableStream): Promise<[

@@ -13,0 +16,0 @@ ReadableStream,

/**
* @internal
* Alias prevents compiler from turning
* ReadableStream into ReadableStream<any>, which is incompatible
* with the NodeJS.ReadableStream global type.
*
* @internal
*/

@@ -7,0 +8,0 @@ type ReadableStreamType = ReadableStream;

{
"name": "@smithy/util-stream",
"version": "4.5.8",
"version": "4.5.9",
"scripts": {

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

"downlevel-dts": "0.10.1",
"rimraf": "3.0.2",
"rimraf": "5.0.10",
"typedoc": "0.23.23"

@@ -49,0 +49,0 @@ },