Download node_modules/@aws-sdk/hash-node/dist-cjs/index.js from sweet2004/bot: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/hash-node/dist-cjs/index.js
- Command line
-
hf download hf://spaces/sweet2004/bot/node_modules/@aws-sdk/hash-node/dist-cjs/index.js
-
curl -L -o index.js https://huggingface.co/spaces/sweet2004/bot/resolve/main/node_modules/%40aws-sdk/hash-node/dist-cjs/index.js
1.34 kB
| ; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.Hash = void 0; | |
| const util_buffer_from_1 = require("@aws-sdk/util-buffer-from"); | |
| const util_utf8_1 = require("@aws-sdk/util-utf8"); | |
| const buffer_1 = require("buffer"); | |
| const crypto_1 = require("crypto"); | |
| class Hash { | |
| constructor(algorithmIdentifier, secret) { | |
| this.algorithmIdentifier = algorithmIdentifier; | |
| this.secret = secret; | |
| this.reset(); | |
| } | |
| update(toHash, encoding) { | |
| this.hash.update((0, util_utf8_1.toUint8Array)(castSourceData(toHash, encoding))); | |
| } | |
| digest() { | |
| return Promise.resolve(this.hash.digest()); | |
| } | |
| reset() { | |
| this.hash = this.secret | |
| ? (0, crypto_1.createHmac)(this.algorithmIdentifier, castSourceData(this.secret)) | |
| : (0, crypto_1.createHash)(this.algorithmIdentifier); | |
| } | |
| } | |
| exports.Hash = Hash; | |
| function castSourceData(toCast, encoding) { | |
| if (buffer_1.Buffer.isBuffer(toCast)) { | |
| return toCast; | |
| } | |
| if (typeof toCast === "string") { | |
| return (0, util_buffer_from_1.fromString)(toCast, encoding); | |
| } | |
| if (ArrayBuffer.isView(toCast)) { | |
| return (0, util_buffer_from_1.fromArrayBuffer)(toCast.buffer, toCast.byteOffset, toCast.byteLength); | |
| } | |
| return (0, util_buffer_from_1.fromArrayBuffer)(toCast); | |
| } | |