replicas-engine 0.1.141 → 0.1.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/chunk-5V5ZNFZK.js +178 -0
- package/dist/src/chunk-7RS3TOFT.js +5862 -0
- package/dist/src/chunk-ERL3EC7G.js +44 -0
- package/dist/src/chunk-J3WZZOOL.js +1316 -0
- package/dist/src/chunk-JFXVYYQY.js +242 -0
- package/dist/src/chunk-MCYTXPBZ.js +29 -0
- package/dist/src/chunk-N2BGF5AZ.js +14 -0
- package/dist/src/chunk-NPXMDMPW.js +175 -0
- package/dist/src/chunk-TY2FR253.js +590 -0
- package/dist/src/chunk-WCAERHFE.js +62 -0
- package/dist/src/chunk-XCFRYWEV.js +164 -0
- package/dist/src/chunk-YDW6RZI2.js +39 -0
- package/dist/src/chunk-ZDZBYCXV.js +52 -0
- package/dist/src/dist-es-3LYC7DO3.js +169 -0
- package/dist/src/dist-es-7DTYZ3KD.js +489 -0
- package/dist/src/dist-es-BNJQGHZR.js +88 -0
- package/dist/src/dist-es-EVINFDC2.js +46 -0
- package/dist/src/dist-es-KHBICPEM.js +380 -0
- package/dist/src/dist-es-UV765YRF.js +324 -0
- package/dist/src/dist-es-YWO2URNL.js +70 -0
- package/dist/src/event-streams-IFAW3KBX.js +244 -0
- package/dist/src/event-streams-XS4D2DFO.js +252 -0
- package/dist/src/index.js +12 -4
- package/dist/src/loadSso-ZRFAKENS.js +590 -0
- package/dist/src/signin-PNR24U2H.js +702 -0
- package/dist/src/sso-oidc-O55BGCVQ.js +827 -0
- package/dist/src/sts-MRC7OH6Z.js +3876 -0
- package/package.json +1 -1
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getProfileName.js
|
|
4
|
+
var ENV_PROFILE = "AWS_PROFILE";
|
|
5
|
+
var DEFAULT_PROFILE = "default";
|
|
6
|
+
var getProfileName = (init) => init.profile || process.env[ENV_PROFILE] || DEFAULT_PROFILE;
|
|
7
|
+
|
|
8
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigFilepath.js
|
|
9
|
+
import { join } from "path";
|
|
10
|
+
|
|
11
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getHomeDir.js
|
|
12
|
+
import { homedir } from "os";
|
|
13
|
+
import { sep } from "path";
|
|
14
|
+
var homeDirCache = {};
|
|
15
|
+
var getHomeDirCacheKey = () => {
|
|
16
|
+
if (process && process.geteuid) {
|
|
17
|
+
return `${process.geteuid()}`;
|
|
18
|
+
}
|
|
19
|
+
return "DEFAULT";
|
|
20
|
+
};
|
|
21
|
+
var getHomeDir = () => {
|
|
22
|
+
const { HOME, USERPROFILE, HOMEPATH, HOMEDRIVE = `C:${sep}` } = process.env;
|
|
23
|
+
if (HOME)
|
|
24
|
+
return HOME;
|
|
25
|
+
if (USERPROFILE)
|
|
26
|
+
return USERPROFILE;
|
|
27
|
+
if (HOMEPATH)
|
|
28
|
+
return `${HOMEDRIVE}${HOMEPATH}`;
|
|
29
|
+
const homeDirCacheKey = getHomeDirCacheKey();
|
|
30
|
+
if (!homeDirCache[homeDirCacheKey])
|
|
31
|
+
homeDirCache[homeDirCacheKey] = homedir();
|
|
32
|
+
return homeDirCache[homeDirCacheKey];
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigFilepath.js
|
|
36
|
+
var ENV_CONFIG_PATH = "AWS_CONFIG_FILE";
|
|
37
|
+
var getConfigFilepath = () => process.env[ENV_CONFIG_PATH] || join(getHomeDir(), ".aws", "config");
|
|
38
|
+
|
|
39
|
+
// ../node_modules/.bun/@smithy+types@4.14.1/node_modules/@smithy/types/dist-es/profile.js
|
|
40
|
+
var IniSectionType;
|
|
41
|
+
(function(IniSectionType2) {
|
|
42
|
+
IniSectionType2["PROFILE"] = "profile";
|
|
43
|
+
IniSectionType2["SSO_SESSION"] = "sso-session";
|
|
44
|
+
IniSectionType2["SERVICES"] = "services";
|
|
45
|
+
})(IniSectionType || (IniSectionType = {}));
|
|
46
|
+
|
|
47
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js
|
|
48
|
+
import { join as join3 } from "path";
|
|
49
|
+
|
|
50
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/constants.js
|
|
51
|
+
var CONFIG_PREFIX_SEPARATOR = ".";
|
|
52
|
+
|
|
53
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getConfigData.js
|
|
54
|
+
var getConfigData = (data) => Object.entries(data).filter(([key]) => {
|
|
55
|
+
const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
|
|
56
|
+
if (indexOfSeparator === -1) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
return Object.values(IniSectionType).includes(key.substring(0, indexOfSeparator));
|
|
60
|
+
}).reduce((acc, [key, value]) => {
|
|
61
|
+
const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
|
|
62
|
+
const updatedKey = key.substring(0, indexOfSeparator) === IniSectionType.PROFILE ? key.substring(indexOfSeparator + 1) : key;
|
|
63
|
+
acc[updatedKey] = value;
|
|
64
|
+
return acc;
|
|
65
|
+
}, {
|
|
66
|
+
...data.default && { default: data.default }
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getCredentialsFilepath.js
|
|
70
|
+
import { join as join2 } from "path";
|
|
71
|
+
var ENV_CREDENTIALS_PATH = "AWS_SHARED_CREDENTIALS_FILE";
|
|
72
|
+
var getCredentialsFilepath = () => process.env[ENV_CREDENTIALS_PATH] || join2(getHomeDir(), ".aws", "credentials");
|
|
73
|
+
|
|
74
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/parseIni.js
|
|
75
|
+
var prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
|
|
76
|
+
var profileNameBlockList = ["__proto__", "profile __proto__"];
|
|
77
|
+
var parseIni = (iniData) => {
|
|
78
|
+
const map = {};
|
|
79
|
+
let currentSection;
|
|
80
|
+
let currentSubSection;
|
|
81
|
+
for (const iniLine of iniData.split(/\r?\n/)) {
|
|
82
|
+
const trimmedLine = iniLine.split(/(^|\s)[;#]/)[0].trim();
|
|
83
|
+
const isSection = trimmedLine[0] === "[" && trimmedLine[trimmedLine.length - 1] === "]";
|
|
84
|
+
if (isSection) {
|
|
85
|
+
currentSection = void 0;
|
|
86
|
+
currentSubSection = void 0;
|
|
87
|
+
const sectionName = trimmedLine.substring(1, trimmedLine.length - 1);
|
|
88
|
+
const matches = prefixKeyRegex.exec(sectionName);
|
|
89
|
+
if (matches) {
|
|
90
|
+
const [, prefix, , name] = matches;
|
|
91
|
+
if (Object.values(IniSectionType).includes(prefix)) {
|
|
92
|
+
currentSection = [prefix, name].join(CONFIG_PREFIX_SEPARATOR);
|
|
93
|
+
}
|
|
94
|
+
} else {
|
|
95
|
+
currentSection = sectionName;
|
|
96
|
+
}
|
|
97
|
+
if (profileNameBlockList.includes(sectionName)) {
|
|
98
|
+
throw new Error(`Found invalid profile name "${sectionName}"`);
|
|
99
|
+
}
|
|
100
|
+
} else if (currentSection) {
|
|
101
|
+
const indexOfEqualsSign = trimmedLine.indexOf("=");
|
|
102
|
+
if (![0, -1].includes(indexOfEqualsSign)) {
|
|
103
|
+
const [name, value] = [
|
|
104
|
+
trimmedLine.substring(0, indexOfEqualsSign).trim(),
|
|
105
|
+
trimmedLine.substring(indexOfEqualsSign + 1).trim()
|
|
106
|
+
];
|
|
107
|
+
if (value === "") {
|
|
108
|
+
currentSubSection = name;
|
|
109
|
+
} else {
|
|
110
|
+
if (currentSubSection && iniLine.trimStart() === iniLine) {
|
|
111
|
+
currentSubSection = void 0;
|
|
112
|
+
}
|
|
113
|
+
map[currentSection] = map[currentSection] || {};
|
|
114
|
+
const key = currentSubSection ? [currentSubSection, name].join(CONFIG_PREFIX_SEPARATOR) : name;
|
|
115
|
+
map[currentSection][key] = value;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return map;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/readFile.js
|
|
124
|
+
import { readFile as fsReadFile } from "fs/promises";
|
|
125
|
+
var filePromises = {};
|
|
126
|
+
var fileIntercept = {};
|
|
127
|
+
var readFile = (path, options) => {
|
|
128
|
+
if (fileIntercept[path] !== void 0) {
|
|
129
|
+
return fileIntercept[path];
|
|
130
|
+
}
|
|
131
|
+
if (!filePromises[path] || options?.ignoreCache) {
|
|
132
|
+
filePromises[path] = fsReadFile(path, "utf8");
|
|
133
|
+
}
|
|
134
|
+
return filePromises[path];
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSharedConfigFiles.js
|
|
138
|
+
var swallowError = () => ({});
|
|
139
|
+
var loadSharedConfigFiles = async (init = {}) => {
|
|
140
|
+
const { filepath = getCredentialsFilepath(), configFilepath = getConfigFilepath() } = init;
|
|
141
|
+
const homeDir = getHomeDir();
|
|
142
|
+
const relativeHomeDirPrefix = "~/";
|
|
143
|
+
let resolvedFilepath = filepath;
|
|
144
|
+
if (filepath.startsWith(relativeHomeDirPrefix)) {
|
|
145
|
+
resolvedFilepath = join3(homeDir, filepath.slice(2));
|
|
146
|
+
}
|
|
147
|
+
let resolvedConfigFilepath = configFilepath;
|
|
148
|
+
if (configFilepath.startsWith(relativeHomeDirPrefix)) {
|
|
149
|
+
resolvedConfigFilepath = join3(homeDir, configFilepath.slice(2));
|
|
150
|
+
}
|
|
151
|
+
const parsedFiles = await Promise.all([
|
|
152
|
+
readFile(resolvedConfigFilepath, {
|
|
153
|
+
ignoreCache: init.ignoreCache
|
|
154
|
+
}).then(parseIni).then(getConfigData).catch(swallowError),
|
|
155
|
+
readFile(resolvedFilepath, {
|
|
156
|
+
ignoreCache: init.ignoreCache
|
|
157
|
+
}).then(parseIni).catch(swallowError)
|
|
158
|
+
]);
|
|
159
|
+
return {
|
|
160
|
+
configFile: parsedFiles[0],
|
|
161
|
+
credentialsFile: parsedFiles[1]
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getSsoSessionData.js
|
|
166
|
+
var getSsoSessionData = (data) => Object.entries(data).filter(([key]) => key.startsWith(IniSectionType.SSO_SESSION + CONFIG_PREFIX_SEPARATOR)).reduce((acc, [key, value]) => ({ ...acc, [key.substring(key.indexOf(CONFIG_PREFIX_SEPARATOR) + 1)]: value }), {});
|
|
167
|
+
|
|
168
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/loadSsoSessionData.js
|
|
169
|
+
var swallowError2 = () => ({});
|
|
170
|
+
var loadSsoSessionData = async (init = {}) => readFile(init.configFilepath ?? getConfigFilepath()).then(parseIni).then(getSsoSessionData).catch(swallowError2);
|
|
171
|
+
|
|
172
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/mergeConfigFiles.js
|
|
173
|
+
var mergeConfigFiles = (...files) => {
|
|
174
|
+
const merged = {};
|
|
175
|
+
for (const file of files) {
|
|
176
|
+
for (const [key, values] of Object.entries(file)) {
|
|
177
|
+
if (merged[key] !== void 0) {
|
|
178
|
+
Object.assign(merged[key], values);
|
|
179
|
+
} else {
|
|
180
|
+
merged[key] = values;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return merged;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/parseKnownFiles.js
|
|
188
|
+
var parseKnownFiles = async (init) => {
|
|
189
|
+
const parsedFiles = await loadSharedConfigFiles(init);
|
|
190
|
+
return mergeConfigFiles(parsedFiles.configFile, parsedFiles.credentialsFile);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFromFile.js
|
|
194
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
195
|
+
|
|
196
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFilepath.js
|
|
197
|
+
import { createHash } from "crypto";
|
|
198
|
+
import { join as join4 } from "path";
|
|
199
|
+
var getSSOTokenFilepath = (id) => {
|
|
200
|
+
const hasher = createHash("sha1");
|
|
201
|
+
const cacheName = hasher.update(id).digest("hex");
|
|
202
|
+
return join4(getHomeDir(), ".aws", "sso", "cache", `${cacheName}.json`);
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/getSSOTokenFromFile.js
|
|
206
|
+
var tokenIntercept = {};
|
|
207
|
+
var getSSOTokenFromFile = async (id) => {
|
|
208
|
+
if (tokenIntercept[id]) {
|
|
209
|
+
return tokenIntercept[id];
|
|
210
|
+
}
|
|
211
|
+
const ssoTokenFilepath = getSSOTokenFilepath(id);
|
|
212
|
+
const ssoTokenText = await readFile2(ssoTokenFilepath, "utf8");
|
|
213
|
+
return JSON.parse(ssoTokenText);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
// ../node_modules/.bun/@smithy+shared-ini-file-loader@4.4.7/node_modules/@smithy/shared-ini-file-loader/dist-es/externalDataInterceptor.js
|
|
217
|
+
var externalDataInterceptor = {
|
|
218
|
+
getFileRecord() {
|
|
219
|
+
return fileIntercept;
|
|
220
|
+
},
|
|
221
|
+
interceptFile(path, contents) {
|
|
222
|
+
fileIntercept[path] = Promise.resolve(contents);
|
|
223
|
+
},
|
|
224
|
+
getTokenRecord() {
|
|
225
|
+
return tokenIntercept;
|
|
226
|
+
},
|
|
227
|
+
interceptToken(id, contents) {
|
|
228
|
+
tokenIntercept[id] = contents;
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export {
|
|
233
|
+
getProfileName,
|
|
234
|
+
getSSOTokenFilepath,
|
|
235
|
+
getSSOTokenFromFile,
|
|
236
|
+
CONFIG_PREFIX_SEPARATOR,
|
|
237
|
+
readFile,
|
|
238
|
+
loadSharedConfigFiles,
|
|
239
|
+
loadSsoSessionData,
|
|
240
|
+
parseKnownFiles,
|
|
241
|
+
externalDataInterceptor
|
|
242
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
ProviderError
|
|
4
|
+
} from "./chunk-YDW6RZI2.js";
|
|
5
|
+
|
|
6
|
+
// ../node_modules/.bun/@smithy+property-provider@4.2.12/node_modules/@smithy/property-provider/dist-es/chain.js
|
|
7
|
+
var chain = (...providers) => async () => {
|
|
8
|
+
if (providers.length === 0) {
|
|
9
|
+
throw new ProviderError("No providers in chain");
|
|
10
|
+
}
|
|
11
|
+
let lastProviderError;
|
|
12
|
+
for (const provider of providers) {
|
|
13
|
+
try {
|
|
14
|
+
const credentials = await provider();
|
|
15
|
+
return credentials;
|
|
16
|
+
} catch (err) {
|
|
17
|
+
lastProviderError = err;
|
|
18
|
+
if (err?.tryNextLink) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
throw err;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
throw lastProviderError;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
chain
|
|
29
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// ../node_modules/.bun/@aws-sdk+core@3.973.26/node_modules/@aws-sdk/core/dist-es/submodules/client/setCredentialFeature.js
|
|
4
|
+
function setCredentialFeature(credentials, feature, value) {
|
|
5
|
+
if (!credentials.$source) {
|
|
6
|
+
credentials.$source = {};
|
|
7
|
+
}
|
|
8
|
+
credentials.$source[feature] = value;
|
|
9
|
+
return credentials;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export {
|
|
13
|
+
setCredentialFeature
|
|
14
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
fromBase64,
|
|
4
|
+
streamCollector,
|
|
5
|
+
toBase64,
|
|
6
|
+
toHex
|
|
7
|
+
} from "./chunk-TY2FR253.js";
|
|
8
|
+
import {
|
|
9
|
+
fromArrayBuffer,
|
|
10
|
+
toUtf8
|
|
11
|
+
} from "./chunk-ERL3EC7G.js";
|
|
12
|
+
|
|
13
|
+
// ../node_modules/.bun/@smithy+util-stream@4.5.21/node_modules/@smithy/util-stream/dist-es/sdk-stream-mixin.js
|
|
14
|
+
import { Readable } from "stream";
|
|
15
|
+
|
|
16
|
+
// ../node_modules/.bun/@smithy+fetch-http-handler@5.3.15/node_modules/@smithy/fetch-http-handler/dist-es/stream-collector.js
|
|
17
|
+
var streamCollector2 = async (stream) => {
|
|
18
|
+
if (typeof Blob === "function" && stream instanceof Blob || stream.constructor?.name === "Blob") {
|
|
19
|
+
if (Blob.prototype.arrayBuffer !== void 0) {
|
|
20
|
+
return new Uint8Array(await stream.arrayBuffer());
|
|
21
|
+
}
|
|
22
|
+
return collectBlob(stream);
|
|
23
|
+
}
|
|
24
|
+
return collectStream(stream);
|
|
25
|
+
};
|
|
26
|
+
async function collectBlob(blob) {
|
|
27
|
+
const base64 = await readToBase64(blob);
|
|
28
|
+
const arrayBuffer = fromBase64(base64);
|
|
29
|
+
return new Uint8Array(arrayBuffer);
|
|
30
|
+
}
|
|
31
|
+
async function collectStream(stream) {
|
|
32
|
+
const chunks = [];
|
|
33
|
+
const reader = stream.getReader();
|
|
34
|
+
let isDone = false;
|
|
35
|
+
let length = 0;
|
|
36
|
+
while (!isDone) {
|
|
37
|
+
const { done, value } = await reader.read();
|
|
38
|
+
if (value) {
|
|
39
|
+
chunks.push(value);
|
|
40
|
+
length += value.length;
|
|
41
|
+
}
|
|
42
|
+
isDone = done;
|
|
43
|
+
}
|
|
44
|
+
const collected = new Uint8Array(length);
|
|
45
|
+
let offset = 0;
|
|
46
|
+
for (const chunk of chunks) {
|
|
47
|
+
collected.set(chunk, offset);
|
|
48
|
+
offset += chunk.length;
|
|
49
|
+
}
|
|
50
|
+
return collected;
|
|
51
|
+
}
|
|
52
|
+
function readToBase64(blob) {
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
const reader = new FileReader();
|
|
55
|
+
reader.onloadend = () => {
|
|
56
|
+
if (reader.readyState !== 2) {
|
|
57
|
+
return reject(new Error("Reader aborted too early"));
|
|
58
|
+
}
|
|
59
|
+
const result = reader.result ?? "";
|
|
60
|
+
const commaIndex = result.indexOf(",");
|
|
61
|
+
const dataOffset = commaIndex > -1 ? commaIndex + 1 : result.length;
|
|
62
|
+
resolve(result.substring(dataOffset));
|
|
63
|
+
};
|
|
64
|
+
reader.onabort = () => reject(new Error("Read aborted"));
|
|
65
|
+
reader.onerror = () => reject(reader.error);
|
|
66
|
+
reader.readAsDataURL(blob);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ../node_modules/.bun/@smithy+util-stream@4.5.21/node_modules/@smithy/util-stream/dist-es/stream-type-check.js
|
|
71
|
+
var isReadableStream = (stream) => typeof ReadableStream === "function" && (stream?.constructor?.name === ReadableStream.name || stream instanceof ReadableStream);
|
|
72
|
+
|
|
73
|
+
// ../node_modules/.bun/@smithy+util-stream@4.5.21/node_modules/@smithy/util-stream/dist-es/sdk-stream-mixin.browser.js
|
|
74
|
+
var ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED = "The stream has already been transformed.";
|
|
75
|
+
var sdkStreamMixin = (stream) => {
|
|
76
|
+
if (!isBlobInstance(stream) && !isReadableStream(stream)) {
|
|
77
|
+
const name = stream?.__proto__?.constructor?.name || stream;
|
|
78
|
+
throw new Error(`Unexpected stream implementation, expect Blob or ReadableStream, got ${name}`);
|
|
79
|
+
}
|
|
80
|
+
let transformed = false;
|
|
81
|
+
const transformToByteArray = async () => {
|
|
82
|
+
if (transformed) {
|
|
83
|
+
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
|
84
|
+
}
|
|
85
|
+
transformed = true;
|
|
86
|
+
return await streamCollector2(stream);
|
|
87
|
+
};
|
|
88
|
+
const blobToWebStream = (blob) => {
|
|
89
|
+
if (typeof blob.stream !== "function") {
|
|
90
|
+
throw new Error("Cannot transform payload Blob to web stream. Please make sure the Blob.stream() is polyfilled.\nIf you are using React Native, this API is not yet supported, see: https://react-native.canny.io/feature-requests/p/fetch-streaming-body");
|
|
91
|
+
}
|
|
92
|
+
return blob.stream();
|
|
93
|
+
};
|
|
94
|
+
return Object.assign(stream, {
|
|
95
|
+
transformToByteArray,
|
|
96
|
+
transformToString: async (encoding) => {
|
|
97
|
+
const buf = await transformToByteArray();
|
|
98
|
+
if (encoding === "base64") {
|
|
99
|
+
return toBase64(buf);
|
|
100
|
+
} else if (encoding === "hex") {
|
|
101
|
+
return toHex(buf);
|
|
102
|
+
} else if (encoding === void 0 || encoding === "utf8" || encoding === "utf-8") {
|
|
103
|
+
return toUtf8(buf);
|
|
104
|
+
} else if (typeof TextDecoder === "function") {
|
|
105
|
+
return new TextDecoder(encoding).decode(buf);
|
|
106
|
+
} else {
|
|
107
|
+
throw new Error("TextDecoder is not available, please make sure polyfill is provided.");
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
transformToWebStream: () => {
|
|
111
|
+
if (transformed) {
|
|
112
|
+
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED);
|
|
113
|
+
}
|
|
114
|
+
transformed = true;
|
|
115
|
+
if (isBlobInstance(stream)) {
|
|
116
|
+
return blobToWebStream(stream);
|
|
117
|
+
} else if (isReadableStream(stream)) {
|
|
118
|
+
return stream;
|
|
119
|
+
} else {
|
|
120
|
+
throw new Error(`Cannot transform payload to web stream, got ${stream}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
var isBlobInstance = (stream) => typeof Blob === "function" && stream instanceof Blob;
|
|
126
|
+
|
|
127
|
+
// ../node_modules/.bun/@smithy+util-stream@4.5.21/node_modules/@smithy/util-stream/dist-es/sdk-stream-mixin.js
|
|
128
|
+
var ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED2 = "The stream has already been transformed.";
|
|
129
|
+
var sdkStreamMixin2 = (stream) => {
|
|
130
|
+
if (!(stream instanceof Readable)) {
|
|
131
|
+
try {
|
|
132
|
+
return sdkStreamMixin(stream);
|
|
133
|
+
} catch (e) {
|
|
134
|
+
const name = stream?.__proto__?.constructor?.name || stream;
|
|
135
|
+
throw new Error(`Unexpected stream implementation, expect Stream.Readable instance, got ${name}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let transformed = false;
|
|
139
|
+
const transformToByteArray = async () => {
|
|
140
|
+
if (transformed) {
|
|
141
|
+
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED2);
|
|
142
|
+
}
|
|
143
|
+
transformed = true;
|
|
144
|
+
return await streamCollector(stream);
|
|
145
|
+
};
|
|
146
|
+
return Object.assign(stream, {
|
|
147
|
+
transformToByteArray,
|
|
148
|
+
transformToString: async (encoding) => {
|
|
149
|
+
const buf = await transformToByteArray();
|
|
150
|
+
if (encoding === void 0 || Buffer.isEncoding(encoding)) {
|
|
151
|
+
return fromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength).toString(encoding);
|
|
152
|
+
} else {
|
|
153
|
+
const decoder = new TextDecoder(encoding);
|
|
154
|
+
return decoder.decode(buf);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
transformToWebStream: () => {
|
|
158
|
+
if (transformed) {
|
|
159
|
+
throw new Error(ERR_MSG_STREAM_HAS_BEEN_TRANSFORMED2);
|
|
160
|
+
}
|
|
161
|
+
if (stream.readableFlowing !== null) {
|
|
162
|
+
throw new Error("The stream has been consumed by other callbacks.");
|
|
163
|
+
}
|
|
164
|
+
if (typeof Readable.toWeb !== "function") {
|
|
165
|
+
throw new Error("Readable.toWeb() is not supported. Please ensure a polyfill is available.");
|
|
166
|
+
}
|
|
167
|
+
transformed = true;
|
|
168
|
+
return Readable.toWeb(stream);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
sdkStreamMixin2 as sdkStreamMixin
|
|
175
|
+
};
|