31 lines
1 KiB
JavaScript
31 lines
1 KiB
JavaScript
import { AlgorithmId } from "@smithy/types";
|
|
export { AlgorithmId };
|
|
export const getChecksumConfiguration = (runtimeConfig) => {
|
|
const checksumAlgorithms = [];
|
|
for (const id in AlgorithmId) {
|
|
const algorithmId = AlgorithmId[id];
|
|
if (runtimeConfig[algorithmId] === undefined) {
|
|
continue;
|
|
}
|
|
checksumAlgorithms.push({
|
|
algorithmId: () => algorithmId,
|
|
checksumConstructor: () => runtimeConfig[algorithmId],
|
|
});
|
|
}
|
|
return {
|
|
_checksumAlgorithms: checksumAlgorithms,
|
|
addChecksumAlgorithm(algo) {
|
|
this._checksumAlgorithms.push(algo);
|
|
},
|
|
checksumAlgorithms() {
|
|
return this._checksumAlgorithms;
|
|
},
|
|
};
|
|
};
|
|
export const resolveChecksumRuntimeConfig = (clientConfig) => {
|
|
const runtimeConfig = {};
|
|
clientConfig.checksumAlgorithms().forEach((checksumAlgorithm) => {
|
|
runtimeConfig[checksumAlgorithm.algorithmId()] = checksumAlgorithm.checksumConstructor();
|
|
});
|
|
return runtimeConfig;
|
|
};
|