remove node_modules and .gitignore them
This commit is contained in:
-22
@@ -1,22 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Uint8ArrayBlobAdapter = void 0;
|
||||
const transforms_1 = require("./transforms");
|
||||
class Uint8ArrayBlobAdapter extends Uint8Array {
|
||||
static fromString(source, encoding = "utf-8") {
|
||||
switch (typeof source) {
|
||||
case "string":
|
||||
return (0, transforms_1.transformFromString)(source, encoding);
|
||||
default:
|
||||
throw new Error(`Unsupported conversion from ${typeof source} to Uint8ArrayBlobAdapter.`);
|
||||
}
|
||||
}
|
||||
static mutate(source) {
|
||||
Object.setPrototypeOf(source, Uint8ArrayBlobAdapter.prototype);
|
||||
return source;
|
||||
}
|
||||
transformToString(encoding = "utf-8") {
|
||||
return (0, transforms_1.transformToString)(this, encoding);
|
||||
}
|
||||
}
|
||||
exports.Uint8ArrayBlobAdapter = Uint8ArrayBlobAdapter;
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.transformFromString = exports.transformToString = void 0;
|
||||
const util_base64_1 = require("@smithy/util-base64");
|
||||
const util_utf8_1 = require("@smithy/util-utf8");
|
||||
const Uint8ArrayBlobAdapter_1 = require("./Uint8ArrayBlobAdapter");
|
||||
function transformToString(payload, encoding = "utf-8") {
|
||||
if (encoding === "base64") {
|
||||
return (0, util_base64_1.toBase64)(payload);
|
||||
}
|
||||
return (0, util_utf8_1.toUtf8)(payload);
|
||||
}
|
||||
exports.transformToString = transformToString;
|
||||
function transformFromString(str, encoding) {
|
||||
if (encoding === "base64") {
|
||||
return Uint8ArrayBlobAdapter_1.Uint8ArrayBlobAdapter.mutate((0, util_base64_1.fromBase64)(str));
|
||||
}
|
||||
return Uint8ArrayBlobAdapter_1.Uint8ArrayBlobAdapter.mutate((0, util_utf8_1.fromUtf8)(str));
|
||||
}
|
||||
exports.transformFromString = transformFromString;
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAwsChunkedEncodingStream = void 0;
|
||||
const getAwsChunkedEncodingStream = (readableStream, options) => {
|
||||
const { base64Encoder, bodyLengthChecker, checksumAlgorithmFn, checksumLocationName, streamHasher } = options;
|
||||
const checksumRequired = base64Encoder !== undefined &&
|
||||
bodyLengthChecker !== undefined &&
|
||||
checksumAlgorithmFn !== undefined &&
|
||||
checksumLocationName !== undefined &&
|
||||
streamHasher !== undefined;
|
||||
const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : undefined;
|
||||
const reader = readableStream.getReader();
|
||||
return new ReadableStream({
|
||||
async pull(controller) {
|
||||
const { value, done } = await reader.read();
|
||||
if (done) {
|
||||
controller.enqueue(`0\r\n`);
|
||||
if (checksumRequired) {
|
||||
const checksum = base64Encoder(await digest);
|
||||
controller.enqueue(`${checksumLocationName}:${checksum}\r\n`);
|
||||
controller.enqueue(`\r\n`);
|
||||
}
|
||||
controller.close();
|
||||
}
|
||||
else {
|
||||
controller.enqueue(`${(bodyLengthChecker(value) || 0).toString(16)}\r\n${value}\r\n`);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
exports.getAwsChunkedEncodingStream = getAwsChunkedEncodingStream;
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getAwsChunkedEncodingStream = void 0;
|
||||
const stream_1 = require("stream");
|
||||
const getAwsChunkedEncodingStream = (readableStream, options) => {
|
||||
const { base64Encoder, bodyLengthChecker, checksumAlgorithmFn, checksumLocationName, streamHasher } = options;
|
||||
const checksumRequired = base64Encoder !== undefined &&
|
||||
checksumAlgorithmFn !== undefined &&
|
||||
checksumLocationName !== undefined &&
|
||||
streamHasher !== undefined;
|
||||
const digest = checksumRequired ? streamHasher(checksumAlgorithmFn, readableStream) : undefined;
|
||||
const awsChunkedEncodingStream = new stream_1.Readable({ read: () => { } });
|
||||
readableStream.on("data", (data) => {
|
||||
const length = bodyLengthChecker(data) || 0;
|
||||
awsChunkedEncodingStream.push(`${length.toString(16)}\r\n`);
|
||||
awsChunkedEncodingStream.push(data);
|
||||
awsChunkedEncodingStream.push("\r\n");
|
||||
});
|
||||
readableStream.on("end", async () => {
|
||||
awsChunkedEncodingStream.push(`0\r\n`);
|
||||
if (checksumRequired) {
|
||||
const checksum = base64Encoder(await digest);
|
||||
awsChunkedEncodingStream.push(`${checksumLocationName}:${checksum}\r\n`);
|
||||
awsChunkedEncodingStream.push(`\r\n`);
|
||||
}
|
||||
awsChunkedEncodingStream.push(null);
|
||||
});
|
||||
return awsChunkedEncodingStream;
|
||||
};
|
||||
exports.getAwsChunkedEncodingStream = getAwsChunkedEncodingStream;
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./blob/Uint8ArrayBlobAdapter"), exports);
|
||||
tslib_1.__exportStar(require("./getAwsChunkedEncodingStream"), exports);
|
||||
tslib_1.__exportStar(require("./sdk-stream-mixin"), exports);
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sdkStreamMixin = void 0;
|
||||
const fetch_http_handler_1 = require("@smithy/fetch-http-handler");
|
||||
const util_base64_1 = require("@smithy/util-base64");
|
||||
const util_hex_encoding_1 = require("@smithy/util-hex-encoding");
|
||||
const util_utf8_1 = require("@smithy/util-utf8");
|
||||
const ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed.";
|
||||
const sdkStreamMixin = (stream) => {
|
||||
var _a, _b;
|
||||
if (!isBlobInstance(stream) && !isReadableStreamInstance(stream)) {
|
||||
const name = ((_b = (_a = stream === null || stream === void 0 ? void 0 : stream.__proto__) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) || stream;
|
||||
throw new Error(`Unexpected stream implementation, expect Blob or ReadableStream, got ${name}`);
|
||||
}
|
||||
let transformed = false;
|
||||
const transformToByteArray = async () => {
|
||||
if (transformed) {
|
||||
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
||||
}
|
||||
transformed = true;
|
||||
return await (0, fetch_http_handler_1.streamCollector)(stream);
|
||||
};
|
||||
const blobToWebStream = (blob) => {
|
||||
if (typeof blob.stream !== "function") {
|
||||
throw new Error("Cannot transform payload Blob to web stream. Please make sure the Blob.stream() is polyfilled.\n" +
|
||||
"If you are using React Native, this API is not yet supported, see: https://react-native.canny.io/feature-requests/p/fetch-streaming-body");
|
||||
}
|
||||
return blob.stream();
|
||||
};
|
||||
return Object.assign(stream, {
|
||||
transformToByteArray: transformToByteArray,
|
||||
transformToString: async (encoding) => {
|
||||
const buf = await transformToByteArray();
|
||||
if (encoding === "base64") {
|
||||
return (0, util_base64_1.toBase64)(buf);
|
||||
}
|
||||
else if (encoding === "hex") {
|
||||
return (0, util_hex_encoding_1.toHex)(buf);
|
||||
}
|
||||
else if (encoding === undefined || encoding === "utf8" || encoding === "utf-8") {
|
||||
return (0, util_utf8_1.toUtf8)(buf);
|
||||
}
|
||||
else if (typeof TextDecoder === "function") {
|
||||
return new TextDecoder(encoding).decode(buf);
|
||||
}
|
||||
else {
|
||||
throw new Error("TextDecoder is not available, please make sure polyfill is provided.");
|
||||
}
|
||||
},
|
||||
transformToWebStream: () => {
|
||||
if (transformed) {
|
||||
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
||||
}
|
||||
transformed = true;
|
||||
if (isBlobInstance(stream)) {
|
||||
return blobToWebStream(stream);
|
||||
}
|
||||
else if (isReadableStreamInstance(stream)) {
|
||||
return stream;
|
||||
}
|
||||
else {
|
||||
throw new Error(`Cannot transform payload to web stream, got ${stream}`);
|
||||
}
|
||||
},
|
||||
});
|
||||
};
|
||||
exports.sdkStreamMixin = sdkStreamMixin;
|
||||
const isBlobInstance = (stream) => typeof Blob === "function" && stream instanceof Blob;
|
||||
const isReadableStreamInstance = (stream) => typeof ReadableStream === "function" && stream instanceof ReadableStream;
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.sdkStreamMixin = void 0;
|
||||
const node_http_handler_1 = require("@smithy/node-http-handler");
|
||||
const util_buffer_from_1 = require("@smithy/util-buffer-from");
|
||||
const stream_1 = require("stream");
|
||||
const util_1 = require("util");
|
||||
const ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed.";
|
||||
const sdkStreamMixin = (stream) => {
|
||||
var _a, _b;
|
||||
if (!(stream instanceof stream_1.Readable)) {
|
||||
const name = ((_b = (_a = stream === null || stream === void 0 ? void 0 : stream.__proto__) === null || _a === void 0 ? void 0 : _a.constructor) === null || _b === void 0 ? void 0 : _b.name) || stream;
|
||||
throw new Error(`Unexpected stream implementation, expect Stream.Readable instance, got ${name}`);
|
||||
}
|
||||
let transformed = false;
|
||||
const transformToByteArray = async () => {
|
||||
if (transformed) {
|
||||
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
||||
}
|
||||
transformed = true;
|
||||
return await (0, node_http_handler_1.streamCollector)(stream);
|
||||
};
|
||||
return Object.assign(stream, {
|
||||
transformToByteArray,
|
||||
transformToString: async (encoding) => {
|
||||
const buf = await transformToByteArray();
|
||||
if (encoding === undefined || Buffer.isEncoding(encoding)) {
|
||||
return (0, util_buffer_from_1.fromArrayBuffer)(buf.buffer, buf.byteOffset, buf.byteLength).toString(encoding);
|
||||
}
|
||||
else {
|
||||
const decoder = new util_1.TextDecoder(encoding);
|
||||
return decoder.decode(buf);
|
||||
}
|
||||
},
|
||||
transformToWebStream: () => {
|
||||
if (transformed) {
|
||||
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
||||
}
|
||||
if (stream.readableFlowing !== null) {
|
||||
throw new Error("The stream has been consumed by other callbacks.");
|
||||
}
|
||||
if (typeof stream_1.Readable.toWeb !== "function") {
|
||||
throw new Error("Readable.toWeb() is not supported. Please make sure you are using Node.js >= 17.0.0, or polyfill is available.");
|
||||
}
|
||||
transformed = true;
|
||||
return stream_1.Readable.toWeb(stream);
|
||||
},
|
||||
});
|
||||
};
|
||||
exports.sdkStreamMixin = sdkStreamMixin;
|
||||
Reference in New Issue
Block a user