@uploadista/core 0.0.2
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/.turbo/turbo-build.log +5 -0
- package/.turbo/turbo-check.log +231 -0
- package/.turbo/turbo-format.log +5 -0
- package/LICENSE +21 -0
- package/README.md +1120 -0
- package/dist/chunk-CUT6urMc.cjs +1 -0
- package/dist/debounce-C2SeqcxD.js +2 -0
- package/dist/debounce-C2SeqcxD.js.map +1 -0
- package/dist/debounce-LZK7yS7Z.cjs +1 -0
- package/dist/errors/index.cjs +1 -0
- package/dist/errors/index.d.cts +3 -0
- package/dist/errors/index.d.ts +3 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +2 -0
- package/dist/errors/uploadista-error.d.ts +209 -0
- package/dist/errors/uploadista-error.d.ts.map +1 -0
- package/dist/errors/uploadista-error.js +322 -0
- package/dist/errors-8i_aMxOE.js +1 -0
- package/dist/errors-CRm1FHHT.cjs +0 -0
- package/dist/flow/edge.d.ts +47 -0
- package/dist/flow/edge.d.ts.map +1 -0
- package/dist/flow/edge.js +40 -0
- package/dist/flow/event.d.ts +206 -0
- package/dist/flow/event.d.ts.map +1 -0
- package/dist/flow/event.js +53 -0
- package/dist/flow/flow-server.d.ts +223 -0
- package/dist/flow/flow-server.d.ts.map +1 -0
- package/dist/flow/flow-server.js +614 -0
- package/dist/flow/flow.d.ts +238 -0
- package/dist/flow/flow.d.ts.map +1 -0
- package/dist/flow/flow.js +629 -0
- package/dist/flow/index.cjs +1 -0
- package/dist/flow/index.d.cts +6 -0
- package/dist/flow/index.d.ts +24 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +24 -0
- package/dist/flow/node.d.ts +136 -0
- package/dist/flow/node.d.ts.map +1 -0
- package/dist/flow/node.js +153 -0
- package/dist/flow/nodes/index.d.ts +8 -0
- package/dist/flow/nodes/index.d.ts.map +1 -0
- package/dist/flow/nodes/index.js +7 -0
- package/dist/flow/nodes/input-node.d.ts +78 -0
- package/dist/flow/nodes/input-node.d.ts.map +1 -0
- package/dist/flow/nodes/input-node.js +233 -0
- package/dist/flow/nodes/storage-node.d.ts +67 -0
- package/dist/flow/nodes/storage-node.d.ts.map +1 -0
- package/dist/flow/nodes/storage-node.js +94 -0
- package/dist/flow/nodes/streaming-input-node.d.ts +69 -0
- package/dist/flow/nodes/streaming-input-node.d.ts.map +1 -0
- package/dist/flow/nodes/streaming-input-node.js +156 -0
- package/dist/flow/nodes/transform-node.d.ts +85 -0
- package/dist/flow/nodes/transform-node.d.ts.map +1 -0
- package/dist/flow/nodes/transform-node.js +107 -0
- package/dist/flow/parallel-scheduler.d.ts +175 -0
- package/dist/flow/parallel-scheduler.d.ts.map +1 -0
- package/dist/flow/parallel-scheduler.js +193 -0
- package/dist/flow/plugins/credential-provider.d.ts +47 -0
- package/dist/flow/plugins/credential-provider.d.ts.map +1 -0
- package/dist/flow/plugins/credential-provider.js +24 -0
- package/dist/flow/plugins/image-ai-plugin.d.ts +61 -0
- package/dist/flow/plugins/image-ai-plugin.d.ts.map +1 -0
- package/dist/flow/plugins/image-ai-plugin.js +21 -0
- package/dist/flow/plugins/image-plugin.d.ts +52 -0
- package/dist/flow/plugins/image-plugin.d.ts.map +1 -0
- package/dist/flow/plugins/image-plugin.js +22 -0
- package/dist/flow/plugins/types/describe-image-node.d.ts +16 -0
- package/dist/flow/plugins/types/describe-image-node.d.ts.map +1 -0
- package/dist/flow/plugins/types/describe-image-node.js +9 -0
- package/dist/flow/plugins/types/index.d.ts +9 -0
- package/dist/flow/plugins/types/index.d.ts.map +1 -0
- package/dist/flow/plugins/types/index.js +8 -0
- package/dist/flow/plugins/types/optimize-node.d.ts +20 -0
- package/dist/flow/plugins/types/optimize-node.d.ts.map +1 -0
- package/dist/flow/plugins/types/optimize-node.js +11 -0
- package/dist/flow/plugins/types/remove-background-node.d.ts +16 -0
- package/dist/flow/plugins/types/remove-background-node.d.ts.map +1 -0
- package/dist/flow/plugins/types/remove-background-node.js +9 -0
- package/dist/flow/plugins/types/resize-node.d.ts +21 -0
- package/dist/flow/plugins/types/resize-node.d.ts.map +1 -0
- package/dist/flow/plugins/types/resize-node.js +16 -0
- package/dist/flow/plugins/zip-plugin.d.ts +62 -0
- package/dist/flow/plugins/zip-plugin.d.ts.map +1 -0
- package/dist/flow/plugins/zip-plugin.js +21 -0
- package/dist/flow/typed-flow.d.ts +90 -0
- package/dist/flow/typed-flow.d.ts.map +1 -0
- package/dist/flow/typed-flow.js +59 -0
- package/dist/flow/types/flow-file.d.ts +45 -0
- package/dist/flow/types/flow-file.d.ts.map +1 -0
- package/dist/flow/types/flow-file.js +27 -0
- package/dist/flow/types/flow-job.d.ts +118 -0
- package/dist/flow/types/flow-job.d.ts.map +1 -0
- package/dist/flow/types/flow-job.js +11 -0
- package/dist/flow/types/flow-types.d.ts +321 -0
- package/dist/flow/types/flow-types.d.ts.map +1 -0
- package/dist/flow/types/flow-types.js +52 -0
- package/dist/flow/types/index.d.ts +4 -0
- package/dist/flow/types/index.d.ts.map +1 -0
- package/dist/flow/types/index.js +3 -0
- package/dist/flow/types/run-args.d.ts +38 -0
- package/dist/flow/types/run-args.d.ts.map +1 -0
- package/dist/flow/types/run-args.js +30 -0
- package/dist/flow/types/type-validator.d.ts +26 -0
- package/dist/flow/types/type-validator.d.ts.map +1 -0
- package/dist/flow/types/type-validator.js +134 -0
- package/dist/flow/utils/resolve-upload-metadata.d.ts +11 -0
- package/dist/flow/utils/resolve-upload-metadata.d.ts.map +1 -0
- package/dist/flow/utils/resolve-upload-metadata.js +28 -0
- package/dist/flow-2zXnEiWL.cjs +1 -0
- package/dist/flow-CRaKy7Vj.js +2 -0
- package/dist/flow-CRaKy7Vj.js.map +1 -0
- package/dist/generate-id-Dm-Vboxq.d.ts +34 -0
- package/dist/generate-id-Dm-Vboxq.d.ts.map +1 -0
- package/dist/generate-id-LjJRLD6N.d.cts +34 -0
- package/dist/generate-id-LjJRLD6N.d.cts.map +1 -0
- package/dist/generate-id-xHp_Z7Cl.cjs +1 -0
- package/dist/generate-id-yohS1ZDk.js +2 -0
- package/dist/generate-id-yohS1ZDk.js.map +1 -0
- package/dist/index-BO8GZlbD.d.cts +1040 -0
- package/dist/index-BO8GZlbD.d.cts.map +1 -0
- package/dist/index-BoGG5KAY.d.ts +1 -0
- package/dist/index-BtBZHVmz.d.cts +1 -0
- package/dist/index-D-CoVpkZ.d.ts +1004 -0
- package/dist/index-D-CoVpkZ.d.ts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/logger/logger.cjs +1 -0
- package/dist/logger/logger.d.cts +8 -0
- package/dist/logger/logger.d.cts.map +1 -0
- package/dist/logger/logger.d.ts +5 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.js +10 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/semaphore-0ZwjVpyF.js +2 -0
- package/dist/semaphore-0ZwjVpyF.js.map +1 -0
- package/dist/semaphore-BHprIjFI.d.cts +37 -0
- package/dist/semaphore-BHprIjFI.d.cts.map +1 -0
- package/dist/semaphore-DThupBkc.d.ts +37 -0
- package/dist/semaphore-DThupBkc.d.ts.map +1 -0
- package/dist/semaphore-DVrONiAV.cjs +1 -0
- package/dist/stream-limiter-CoWKv39w.js +2 -0
- package/dist/stream-limiter-CoWKv39w.js.map +1 -0
- package/dist/stream-limiter-JgOwmkMa.cjs +1 -0
- package/dist/streams/multi-stream.cjs +1 -0
- package/dist/streams/multi-stream.d.cts +91 -0
- package/dist/streams/multi-stream.d.cts.map +1 -0
- package/dist/streams/multi-stream.d.ts +86 -0
- package/dist/streams/multi-stream.d.ts.map +1 -0
- package/dist/streams/multi-stream.js +149 -0
- package/dist/streams/multi-stream.js.map +1 -0
- package/dist/streams/stream-limiter.cjs +1 -0
- package/dist/streams/stream-limiter.d.cts +36 -0
- package/dist/streams/stream-limiter.d.cts.map +1 -0
- package/dist/streams/stream-limiter.d.ts +27 -0
- package/dist/streams/stream-limiter.d.ts.map +1 -0
- package/dist/streams/stream-limiter.js +49 -0
- package/dist/streams/stream-splitter.cjs +1 -0
- package/dist/streams/stream-splitter.d.cts +68 -0
- package/dist/streams/stream-splitter.d.cts.map +1 -0
- package/dist/streams/stream-splitter.d.ts +51 -0
- package/dist/streams/stream-splitter.d.ts.map +1 -0
- package/dist/streams/stream-splitter.js +175 -0
- package/dist/streams/stream-splitter.js.map +1 -0
- package/dist/types/data-store-registry.d.ts +13 -0
- package/dist/types/data-store-registry.d.ts.map +1 -0
- package/dist/types/data-store-registry.js +4 -0
- package/dist/types/data-store.d.ts +316 -0
- package/dist/types/data-store.d.ts.map +1 -0
- package/dist/types/data-store.js +157 -0
- package/dist/types/event-broadcaster.d.ts +28 -0
- package/dist/types/event-broadcaster.d.ts.map +1 -0
- package/dist/types/event-broadcaster.js +6 -0
- package/dist/types/event-emitter.d.ts +378 -0
- package/dist/types/event-emitter.d.ts.map +1 -0
- package/dist/types/event-emitter.js +223 -0
- package/dist/types/index.cjs +1 -0
- package/dist/types/index.d.cts +6 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +9 -0
- package/dist/types/input-file.d.ts +104 -0
- package/dist/types/input-file.d.ts.map +1 -0
- package/dist/types/input-file.js +27 -0
- package/dist/types/kv-store.d.ts +281 -0
- package/dist/types/kv-store.d.ts.map +1 -0
- package/dist/types/kv-store.js +234 -0
- package/dist/types/middleware.d.ts +17 -0
- package/dist/types/middleware.d.ts.map +1 -0
- package/dist/types/middleware.js +21 -0
- package/dist/types/upload-event.d.ts +105 -0
- package/dist/types/upload-event.d.ts.map +1 -0
- package/dist/types/upload-event.js +71 -0
- package/dist/types/upload-file.d.ts +136 -0
- package/dist/types/upload-file.d.ts.map +1 -0
- package/dist/types/upload-file.js +34 -0
- package/dist/types/websocket.d.ts +144 -0
- package/dist/types/websocket.d.ts.map +1 -0
- package/dist/types/websocket.js +40 -0
- package/dist/types-BT-cvi7T.cjs +1 -0
- package/dist/types-DhU2j-XF.js +2 -0
- package/dist/types-DhU2j-XF.js.map +1 -0
- package/dist/upload/convert-to-stream.d.ts +38 -0
- package/dist/upload/convert-to-stream.d.ts.map +1 -0
- package/dist/upload/convert-to-stream.js +43 -0
- package/dist/upload/convert-upload-to-flow-file.d.ts +14 -0
- package/dist/upload/convert-upload-to-flow-file.d.ts.map +1 -0
- package/dist/upload/convert-upload-to-flow-file.js +21 -0
- package/dist/upload/create-upload.d.ts +68 -0
- package/dist/upload/create-upload.d.ts.map +1 -0
- package/dist/upload/create-upload.js +157 -0
- package/dist/upload/index.cjs +1 -0
- package/dist/upload/index.d.cts +6 -0
- package/dist/upload/index.d.ts +4 -0
- package/dist/upload/index.d.ts.map +1 -0
- package/dist/upload/index.js +3 -0
- package/dist/upload/mime.d.ts +24 -0
- package/dist/upload/mime.d.ts.map +1 -0
- package/dist/upload/mime.js +351 -0
- package/dist/upload/upload-chunk.d.ts +58 -0
- package/dist/upload/upload-chunk.d.ts.map +1 -0
- package/dist/upload/upload-chunk.js +277 -0
- package/dist/upload/upload-server.d.ts +221 -0
- package/dist/upload/upload-server.d.ts.map +1 -0
- package/dist/upload/upload-server.js +181 -0
- package/dist/upload/upload-strategy-negotiator.d.ts +148 -0
- package/dist/upload/upload-strategy-negotiator.d.ts.map +1 -0
- package/dist/upload/upload-strategy-negotiator.js +217 -0
- package/dist/upload/upload-url.d.ts +68 -0
- package/dist/upload/upload-url.d.ts.map +1 -0
- package/dist/upload/upload-url.js +142 -0
- package/dist/upload/write-to-store.d.ts +77 -0
- package/dist/upload/write-to-store.d.ts.map +1 -0
- package/dist/upload/write-to-store.js +147 -0
- package/dist/upload-DLuICjpP.cjs +1 -0
- package/dist/upload-DaXO34dE.js +2 -0
- package/dist/upload-DaXO34dE.js.map +1 -0
- package/dist/uploadista-error-BB-Wdiz9.cjs +22 -0
- package/dist/uploadista-error-BVsVxqvz.js +23 -0
- package/dist/uploadista-error-BVsVxqvz.js.map +1 -0
- package/dist/uploadista-error-CwxYs4EB.d.ts +52 -0
- package/dist/uploadista-error-CwxYs4EB.d.ts.map +1 -0
- package/dist/uploadista-error-kKlhLRhY.d.cts +52 -0
- package/dist/uploadista-error-kKlhLRhY.d.cts.map +1 -0
- package/dist/utils/checksum.d.ts +22 -0
- package/dist/utils/checksum.d.ts.map +1 -0
- package/dist/utils/checksum.js +49 -0
- package/dist/utils/debounce.cjs +1 -0
- package/dist/utils/debounce.d.cts +38 -0
- package/dist/utils/debounce.d.cts.map +1 -0
- package/dist/utils/debounce.d.ts +36 -0
- package/dist/utils/debounce.d.ts.map +1 -0
- package/dist/utils/debounce.js +73 -0
- package/dist/utils/generate-id.cjs +1 -0
- package/dist/utils/generate-id.d.cts +2 -0
- package/dist/utils/generate-id.d.ts +32 -0
- package/dist/utils/generate-id.d.ts.map +1 -0
- package/dist/utils/generate-id.js +23 -0
- package/dist/utils/md5.cjs +1 -0
- package/dist/utils/md5.d.cts +73 -0
- package/dist/utils/md5.d.cts.map +1 -0
- package/dist/utils/md5.d.ts +71 -0
- package/dist/utils/md5.d.ts.map +1 -0
- package/dist/utils/md5.js +417 -0
- package/dist/utils/md5.js.map +1 -0
- package/dist/utils/once.cjs +1 -0
- package/dist/utils/once.d.cts +25 -0
- package/dist/utils/once.d.cts.map +1 -0
- package/dist/utils/once.d.ts +21 -0
- package/dist/utils/once.d.ts.map +1 -0
- package/dist/utils/once.js +54 -0
- package/dist/utils/once.js.map +1 -0
- package/dist/utils/semaphore.cjs +1 -0
- package/dist/utils/semaphore.d.cts +3 -0
- package/dist/utils/semaphore.d.ts +78 -0
- package/dist/utils/semaphore.d.ts.map +1 -0
- package/dist/utils/semaphore.js +134 -0
- package/dist/utils/throttle.cjs +1 -0
- package/dist/utils/throttle.d.cts +24 -0
- package/dist/utils/throttle.d.cts.map +1 -0
- package/dist/utils/throttle.d.ts +18 -0
- package/dist/utils/throttle.d.ts.map +1 -0
- package/dist/utils/throttle.js +20 -0
- package/dist/utils/throttle.js.map +1 -0
- package/docs/PARALLEL_EXECUTION.md +206 -0
- package/docs/PARALLEL_EXECUTION_QUICKSTART.md +142 -0
- package/docs/PARALLEL_EXECUTION_REFACTOR.md +184 -0
- package/package.json +80 -0
- package/src/errors/__tests__/uploadista-error.test.ts +251 -0
- package/src/errors/index.ts +2 -0
- package/src/errors/uploadista-error.ts +394 -0
- package/src/flow/README.md +352 -0
- package/src/flow/edge.test.ts +146 -0
- package/src/flow/edge.ts +60 -0
- package/src/flow/event.ts +229 -0
- package/src/flow/flow-server.ts +1089 -0
- package/src/flow/flow.ts +1050 -0
- package/src/flow/index.ts +28 -0
- package/src/flow/node.ts +249 -0
- package/src/flow/nodes/index.ts +8 -0
- package/src/flow/nodes/input-node.ts +296 -0
- package/src/flow/nodes/storage-node.ts +128 -0
- package/src/flow/nodes/transform-node.ts +154 -0
- package/src/flow/parallel-scheduler.ts +259 -0
- package/src/flow/plugins/credential-provider.ts +48 -0
- package/src/flow/plugins/image-ai-plugin.ts +66 -0
- package/src/flow/plugins/image-plugin.ts +60 -0
- package/src/flow/plugins/types/describe-image-node.ts +16 -0
- package/src/flow/plugins/types/index.ts +9 -0
- package/src/flow/plugins/types/optimize-node.ts +18 -0
- package/src/flow/plugins/types/remove-background-node.ts +18 -0
- package/src/flow/plugins/types/resize-node.ts +26 -0
- package/src/flow/plugins/zip-plugin.ts +69 -0
- package/src/flow/typed-flow.ts +279 -0
- package/src/flow/types/flow-file.ts +51 -0
- package/src/flow/types/flow-job.ts +138 -0
- package/src/flow/types/flow-types.ts +353 -0
- package/src/flow/types/index.ts +6 -0
- package/src/flow/types/run-args.ts +40 -0
- package/src/flow/types/type-validator.ts +204 -0
- package/src/flow/utils/resolve-upload-metadata.ts +48 -0
- package/src/index.ts +5 -0
- package/src/logger/logger.ts +14 -0
- package/src/streams/stream-limiter.test.ts +150 -0
- package/src/streams/stream-limiter.ts +75 -0
- package/src/types/data-store.ts +427 -0
- package/src/types/event-broadcaster.ts +39 -0
- package/src/types/event-emitter.ts +349 -0
- package/src/types/index.ts +9 -0
- package/src/types/input-file.ts +107 -0
- package/src/types/kv-store.ts +375 -0
- package/src/types/middleware.ts +54 -0
- package/src/types/upload-event.ts +75 -0
- package/src/types/upload-file.ts +139 -0
- package/src/types/websocket.ts +65 -0
- package/src/upload/convert-to-stream.ts +48 -0
- package/src/upload/create-upload.ts +214 -0
- package/src/upload/index.ts +3 -0
- package/src/upload/mime.ts +436 -0
- package/src/upload/upload-chunk.ts +364 -0
- package/src/upload/upload-server.ts +390 -0
- package/src/upload/upload-strategy-negotiator.ts +316 -0
- package/src/upload/upload-url.ts +173 -0
- package/src/upload/write-to-store.ts +211 -0
- package/src/utils/checksum.ts +61 -0
- package/src/utils/debounce.test.ts +126 -0
- package/src/utils/debounce.ts +89 -0
- package/src/utils/generate-id.ts +35 -0
- package/src/utils/md5.ts +475 -0
- package/src/utils/once.test.ts +83 -0
- package/src/utils/once.ts +63 -0
- package/src/utils/throttle.test.ts +101 -0
- package/src/utils/throttle.ts +29 -0
- package/tsconfig.json +20 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.ts +25 -0
- package/vitest.config.ts +15 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/utils/md5.d.ts
|
|
2
|
+
type HasherState = {
|
|
3
|
+
buffer: string;
|
|
4
|
+
buflen: number;
|
|
5
|
+
length: number;
|
|
6
|
+
state: number[];
|
|
7
|
+
};
|
|
8
|
+
declare class Md5 {
|
|
9
|
+
/**
|
|
10
|
+
* Hash a UTF-8 string on the spot
|
|
11
|
+
* @param str String to hash
|
|
12
|
+
* @param raw Whether to return the value as an `Int32Array`
|
|
13
|
+
*/
|
|
14
|
+
static hashStr(str: string, raw?: false): string;
|
|
15
|
+
static hashStr(str: string, raw: true): Int32Array;
|
|
16
|
+
/**
|
|
17
|
+
* Hash a ASCII string on the spot
|
|
18
|
+
* @param str String to hash
|
|
19
|
+
* @param raw Whether to return the value as an `Int32Array`
|
|
20
|
+
*/
|
|
21
|
+
static hashAsciiStr(str: string, raw?: false): string;
|
|
22
|
+
static hashAsciiStr(str: string, raw: true): Int32Array;
|
|
23
|
+
private static stateIdentity;
|
|
24
|
+
private static buffer32Identity;
|
|
25
|
+
private static hexChars;
|
|
26
|
+
private static hexOut;
|
|
27
|
+
private static onePassHasher;
|
|
28
|
+
private static _hex;
|
|
29
|
+
private static _md5cycle;
|
|
30
|
+
private _dataLength;
|
|
31
|
+
private _bufferLength;
|
|
32
|
+
private _state;
|
|
33
|
+
private _buffer;
|
|
34
|
+
private _buffer8;
|
|
35
|
+
private _buffer32;
|
|
36
|
+
constructor();
|
|
37
|
+
/**
|
|
38
|
+
* Initialise buffer to be hashed
|
|
39
|
+
*/
|
|
40
|
+
start(): this;
|
|
41
|
+
/**
|
|
42
|
+
* Append a UTF-8 string to the hash buffer
|
|
43
|
+
* @param str String to append
|
|
44
|
+
*/
|
|
45
|
+
appendStr(str: string): this;
|
|
46
|
+
/**
|
|
47
|
+
* Append an ASCII string to the hash buffer
|
|
48
|
+
* @param str String to append
|
|
49
|
+
*/
|
|
50
|
+
appendAsciiStr(str: string): this;
|
|
51
|
+
/**
|
|
52
|
+
* Append a byte array to the hash buffer
|
|
53
|
+
* @param input array to append
|
|
54
|
+
*/
|
|
55
|
+
appendByteArray(input: Uint8Array): this;
|
|
56
|
+
/**
|
|
57
|
+
* Get the state of the hash buffer
|
|
58
|
+
*/
|
|
59
|
+
getState(): HasherState;
|
|
60
|
+
/**
|
|
61
|
+
* Override the current state of the hash buffer
|
|
62
|
+
* @param state New hash buffer state
|
|
63
|
+
*/
|
|
64
|
+
setState(state: HasherState): void;
|
|
65
|
+
/**
|
|
66
|
+
* Hash the current state of the hash buffer and return the result
|
|
67
|
+
* @param raw Whether to return the value as an `Int32Array`
|
|
68
|
+
*/
|
|
69
|
+
end(raw?: boolean): string | Int32Array<ArrayBufferLike> | undefined;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { Md5 };
|
|
73
|
+
//# sourceMappingURL=md5.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md5.d.cts","names":[],"sources":["../../src/utils/md5.ts"],"sourcesContent":[],"mappings":";KAkDK,WAAA;EAAA,MAAA,EAAA,MAAW;EAOH,MAAG,EAAA,MAAA;EAAA,MAAA,EAAA,MAAA;OAOiC,EAAA,MAAA,EAAA;;AAgTjB,cAvTnB,GAAA,CAuTmB;;;;;;;0CAhTiB;;;;;;;+CAWK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAqStB;;;;cA0BX;;;;;kBAeI;;;;;+BAsBD,WAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
type HasherState = {
|
|
2
|
+
buffer: string;
|
|
3
|
+
buflen: number;
|
|
4
|
+
length: number;
|
|
5
|
+
state: number[];
|
|
6
|
+
};
|
|
7
|
+
export declare class Md5 {
|
|
8
|
+
/**
|
|
9
|
+
* Hash a UTF-8 string on the spot
|
|
10
|
+
* @param str String to hash
|
|
11
|
+
* @param raw Whether to return the value as an `Int32Array`
|
|
12
|
+
*/
|
|
13
|
+
static hashStr(str: string, raw?: false): string;
|
|
14
|
+
static hashStr(str: string, raw: true): Int32Array;
|
|
15
|
+
/**
|
|
16
|
+
* Hash a ASCII string on the spot
|
|
17
|
+
* @param str String to hash
|
|
18
|
+
* @param raw Whether to return the value as an `Int32Array`
|
|
19
|
+
*/
|
|
20
|
+
static hashAsciiStr(str: string, raw?: false): string;
|
|
21
|
+
static hashAsciiStr(str: string, raw: true): Int32Array;
|
|
22
|
+
private static stateIdentity;
|
|
23
|
+
private static buffer32Identity;
|
|
24
|
+
private static hexChars;
|
|
25
|
+
private static hexOut;
|
|
26
|
+
private static onePassHasher;
|
|
27
|
+
private static _hex;
|
|
28
|
+
private static _md5cycle;
|
|
29
|
+
private _dataLength;
|
|
30
|
+
private _bufferLength;
|
|
31
|
+
private _state;
|
|
32
|
+
private _buffer;
|
|
33
|
+
private _buffer8;
|
|
34
|
+
private _buffer32;
|
|
35
|
+
constructor();
|
|
36
|
+
/**
|
|
37
|
+
* Initialise buffer to be hashed
|
|
38
|
+
*/
|
|
39
|
+
start(): this;
|
|
40
|
+
/**
|
|
41
|
+
* Append a UTF-8 string to the hash buffer
|
|
42
|
+
* @param str String to append
|
|
43
|
+
*/
|
|
44
|
+
appendStr(str: string): this;
|
|
45
|
+
/**
|
|
46
|
+
* Append an ASCII string to the hash buffer
|
|
47
|
+
* @param str String to append
|
|
48
|
+
*/
|
|
49
|
+
appendAsciiStr(str: string): this;
|
|
50
|
+
/**
|
|
51
|
+
* Append a byte array to the hash buffer
|
|
52
|
+
* @param input array to append
|
|
53
|
+
*/
|
|
54
|
+
appendByteArray(input: Uint8Array): this;
|
|
55
|
+
/**
|
|
56
|
+
* Get the state of the hash buffer
|
|
57
|
+
*/
|
|
58
|
+
getState(): HasherState;
|
|
59
|
+
/**
|
|
60
|
+
* Override the current state of the hash buffer
|
|
61
|
+
* @param state New hash buffer state
|
|
62
|
+
*/
|
|
63
|
+
setState(state: HasherState): void;
|
|
64
|
+
/**
|
|
65
|
+
* Hash the current state of the hash buffer and return the result
|
|
66
|
+
* @param raw Whether to return the value as an `Int32Array`
|
|
67
|
+
*/
|
|
68
|
+
end(raw?: boolean): string | Int32Array<ArrayBufferLike> | undefined;
|
|
69
|
+
}
|
|
70
|
+
export {};
|
|
71
|
+
//# sourceMappingURL=md5.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md5.d.ts","sourceRoot":"","sources":["../../src/utils/md5.ts"],"names":[],"mappings":"AAkDA,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,C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
3
|
+
TypeScript Md5
|
|
4
|
+
==============
|
|
5
|
+
|
|
6
|
+
Based on work by
|
|
7
|
+
* Joseph Myers: http://www.myersdaily.org/joseph/javascript/md5-text.html
|
|
8
|
+
* André Cruz: https://github.com/satazor/SparkMD5
|
|
9
|
+
* Raymond Hill: https://github.com/gorhill/yamd5.js
|
|
10
|
+
|
|
11
|
+
Effectively a TypeScrypt re-write of Raymond Hill JS Library
|
|
12
|
+
|
|
13
|
+
The MIT License (MIT)
|
|
14
|
+
|
|
15
|
+
Copyright (C) 2014 Raymond Hill
|
|
16
|
+
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
18
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
19
|
+
in the Software without restriction, including without limitation the rights
|
|
20
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
21
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
22
|
+
furnished to do so, subject to the following conditions:
|
|
23
|
+
|
|
24
|
+
The above copyright notice and this permission notice shall be included in
|
|
25
|
+
all copies or substantial portions of the Software.
|
|
26
|
+
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
28
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
29
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
30
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
31
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
32
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
33
|
+
THE SOFTWARE.
|
|
34
|
+
|
|
35
|
+
DO WHAT YOU WANT TO PUBLIC LICENSE
|
|
36
|
+
Version 2, December 2004
|
|
37
|
+
|
|
38
|
+
Copyright (C) 2015 André Cruz <amdfcruz@gmail.com>
|
|
39
|
+
|
|
40
|
+
Everyone is permitted to copy and distribute verbatim or modified
|
|
41
|
+
copies of this license document, and changing it is allowed as long
|
|
42
|
+
as the name is changed.
|
|
43
|
+
|
|
44
|
+
DO WHAT YOU WANT TO PUBLIC LICENSE
|
|
45
|
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
46
|
+
|
|
47
|
+
0. You just DO WHAT YOU WANT TO.
|
|
48
|
+
|
|
49
|
+
*/
|
|
50
|
+
export class Md5 {
|
|
51
|
+
static hashStr(str, raw = false) {
|
|
52
|
+
return Md5.onePassHasher.start().appendStr(str).end(raw);
|
|
53
|
+
}
|
|
54
|
+
static hashAsciiStr(str, raw = false) {
|
|
55
|
+
return Md5.onePassHasher.start().appendAsciiStr(str).end(raw);
|
|
56
|
+
}
|
|
57
|
+
// Private Static Variables
|
|
58
|
+
static stateIdentity = new Int32Array([
|
|
59
|
+
1732584193, -271733879, -1732584194, 271733878,
|
|
60
|
+
]);
|
|
61
|
+
static buffer32Identity = new Int32Array([
|
|
62
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
63
|
+
]);
|
|
64
|
+
static hexChars = "0123456789abcdef";
|
|
65
|
+
static hexOut = [];
|
|
66
|
+
// Permanent instance is to use for one-call hashing
|
|
67
|
+
static onePassHasher = new Md5();
|
|
68
|
+
static _hex(x) {
|
|
69
|
+
const hc = Md5.hexChars;
|
|
70
|
+
const ho = Md5.hexOut;
|
|
71
|
+
let n;
|
|
72
|
+
let offset;
|
|
73
|
+
let j;
|
|
74
|
+
let i;
|
|
75
|
+
for (i = 0; i < 4; i += 1) {
|
|
76
|
+
offset = i * 8;
|
|
77
|
+
n = x[i] ?? 0;
|
|
78
|
+
for (j = 0; j < 8; j += 2) {
|
|
79
|
+
ho[offset + 1 + j] = hc.charAt(n & 0x0f);
|
|
80
|
+
n >>>= 4;
|
|
81
|
+
ho[offset + 0 + j] = hc.charAt(n & 0x0f);
|
|
82
|
+
n >>>= 4;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return ho.join("");
|
|
86
|
+
}
|
|
87
|
+
static _md5cycle(x, k) {
|
|
88
|
+
let a = x[0] ?? 0;
|
|
89
|
+
let b = x[1] ?? 0;
|
|
90
|
+
let c = x[2] ?? 0;
|
|
91
|
+
let d = x[3] ?? 0;
|
|
92
|
+
// ff()
|
|
93
|
+
a += (((b & c) | (~b & d)) + (k[0] ?? 0) - 680876936) | 0;
|
|
94
|
+
a = (((a << 7) | (a >>> 25)) + b) | 0;
|
|
95
|
+
d += (((a & b) | (~a & c)) + (k[1] ?? 0) - 389564586) | 0;
|
|
96
|
+
d = (((d << 12) | (d >>> 20)) + a) | 0;
|
|
97
|
+
c += (((d & a) | (~d & b)) + (k[2] ?? 0) + 606105819) | 0;
|
|
98
|
+
c = (((c << 17) | (c >>> 15)) + d) | 0;
|
|
99
|
+
b += (((c & d) | (~c & a)) + (k[3] ?? 0) - 1044525330) | 0;
|
|
100
|
+
b = (((b << 22) | (b >>> 10)) + c) | 0;
|
|
101
|
+
a += (((b & c) | (~b & d)) + (k[4] ?? 0) - 176418897) | 0;
|
|
102
|
+
a = (((a << 7) | (a >>> 25)) + b) | 0;
|
|
103
|
+
d += (((a & b) | (~a & c)) + (k[5] ?? 0) + 1200080426) | 0;
|
|
104
|
+
d = (((d << 12) | (d >>> 20)) + a) | 0;
|
|
105
|
+
c += (((d & a) | (~d & b)) + (k[6] ?? 0) - 1473231341) | 0;
|
|
106
|
+
c = (((c << 17) | (c >>> 15)) + d) | 0;
|
|
107
|
+
b += (((c & d) | (~c & a)) + (k[7] ?? 0) - 45705983) | 0;
|
|
108
|
+
b = (((b << 22) | (b >>> 10)) + c) | 0;
|
|
109
|
+
a += (((b & c) | (~b & d)) + (k[8] ?? 0) + 1770035416) | 0;
|
|
110
|
+
a = (((a << 7) | (a >>> 25)) + b) | 0;
|
|
111
|
+
d += (((a & b) | (~a & c)) + (k[9] ?? 0) - 1958414417) | 0;
|
|
112
|
+
d = (((d << 12) | (d >>> 20)) + a) | 0;
|
|
113
|
+
c += (((d & a) | (~d & b)) + (k[10] ?? 0) - 42063) | 0;
|
|
114
|
+
c = (((c << 17) | (c >>> 15)) + d) | 0;
|
|
115
|
+
b += (((c & d) | (~c & a)) + (k[11] ?? 0) - 1990404162) | 0;
|
|
116
|
+
b = (((b << 22) | (b >>> 10)) + c) | 0;
|
|
117
|
+
a += (((b & c) | (~b & d)) + (k[12] ?? 0) + 1804603682) | 0;
|
|
118
|
+
a = (((a << 7) | (a >>> 25)) + b) | 0;
|
|
119
|
+
d += (((a & b) | (~a & c)) + (k[13] ?? 0) - 40341101) | 0;
|
|
120
|
+
d = (((d << 12) | (d >>> 20)) + a) | 0;
|
|
121
|
+
c += (((d & a) | (~d & b)) + (k[14] ?? 0) - 1502002290) | 0;
|
|
122
|
+
c = (((c << 17) | (c >>> 15)) + d) | 0;
|
|
123
|
+
b += (((c & d) | (~c & a)) + (k[15] ?? 0) + 1236535329) | 0;
|
|
124
|
+
b = (((b << 22) | (b >>> 10)) + c) | 0;
|
|
125
|
+
// gg()
|
|
126
|
+
a += (((b & d) | (c & ~d)) + (k[1] ?? 0) - 165796510) | 0;
|
|
127
|
+
a = (((a << 5) | (a >>> 27)) + b) | 0;
|
|
128
|
+
d += (((a & c) | (b & ~c)) + (k[6] ?? 0) - 1069501632) | 0;
|
|
129
|
+
d = (((d << 9) | (d >>> 23)) + a) | 0;
|
|
130
|
+
c += (((d & b) | (a & ~b)) + (k[11] ?? 0) + 643717713) | 0;
|
|
131
|
+
c = (((c << 14) | (c >>> 18)) + d) | 0;
|
|
132
|
+
b += (((c & a) | (d & ~a)) + (k[0] ?? 0) - 373897302) | 0;
|
|
133
|
+
b = (((b << 20) | (b >>> 12)) + c) | 0;
|
|
134
|
+
a += (((b & d) | (c & ~d)) + (k[5] ?? 0) - 701558691) | 0;
|
|
135
|
+
a = (((a << 5) | (a >>> 27)) + b) | 0;
|
|
136
|
+
d += (((a & c) | (b & ~c)) + (k[10] ?? 0) + 38016083) | 0;
|
|
137
|
+
d = (((d << 9) | (d >>> 23)) + a) | 0;
|
|
138
|
+
c += (((d & b) | (a & ~b)) + (k[15] ?? 0) - 660478335) | 0;
|
|
139
|
+
c = (((c << 14) | (c >>> 18)) + d) | 0;
|
|
140
|
+
b += (((c & a) | (d & ~a)) + (k[4] ?? 0) - 405537848) | 0;
|
|
141
|
+
b = (((b << 20) | (b >>> 12)) + c) | 0;
|
|
142
|
+
a += (((b & d) | (c & ~d)) + (k[9] ?? 0) + 568446438) | 0;
|
|
143
|
+
a = (((a << 5) | (a >>> 27)) + b) | 0;
|
|
144
|
+
d += (((a & c) | (b & ~c)) + (k[14] ?? 0) - 1019803690) | 0;
|
|
145
|
+
d = (((d << 9) | (d >>> 23)) + a) | 0;
|
|
146
|
+
c += (((d & b) | (a & ~b)) + (k[3] ?? 0) - 187363961) | 0;
|
|
147
|
+
c = (((c << 14) | (c >>> 18)) + d) | 0;
|
|
148
|
+
b += (((c & a) | (d & ~a)) + (k[8] ?? 0) + 1163531501) | 0;
|
|
149
|
+
b = (((b << 20) | (b >>> 12)) + c) | 0;
|
|
150
|
+
a += (((b & d) | (c & ~d)) + (k[13] ?? 0) - 1444681467) | 0;
|
|
151
|
+
a = (((a << 5) | (a >>> 27)) + b) | 0;
|
|
152
|
+
d += (((a & c) | (b & ~c)) + (k[2] ?? 0) - 51403784) | 0;
|
|
153
|
+
d = (((d << 9) | (d >>> 23)) + a) | 0;
|
|
154
|
+
c += (((d & b) | (a & ~b)) + (k[7] ?? 0) + 1735328473) | 0;
|
|
155
|
+
c = (((c << 14) | (c >>> 18)) + d) | 0;
|
|
156
|
+
b += (((c & a) | (d & ~a)) + (k[12] ?? 0) - 1926607734) | 0;
|
|
157
|
+
b = (((b << 20) | (b >>> 12)) + c) | 0;
|
|
158
|
+
// hh()
|
|
159
|
+
a += ((b ^ c ^ d) + (k[5] ?? 0) - 378558) | 0;
|
|
160
|
+
a = (((a << 4) | (a >>> 28)) + b) | 0;
|
|
161
|
+
d += ((a ^ b ^ c) + (k[8] ?? 0) - 2022574463) | 0;
|
|
162
|
+
d = (((d << 11) | (d >>> 21)) + a) | 0;
|
|
163
|
+
c += ((d ^ a ^ b) + (k[11] ?? 0) + 1839030562) | 0;
|
|
164
|
+
c = (((c << 16) | (c >>> 16)) + d) | 0;
|
|
165
|
+
b += ((c ^ d ^ a) + (k[14] ?? 0) - 35309556) | 0;
|
|
166
|
+
b = (((b << 23) | (b >>> 9)) + c) | 0;
|
|
167
|
+
a += ((b ^ c ^ d) + (k[1] ?? 0) - 1530992060) | 0;
|
|
168
|
+
a = (((a << 4) | (a >>> 28)) + b) | 0;
|
|
169
|
+
d += ((a ^ b ^ c) + (k[4] ?? 0) + 1272893353) | 0;
|
|
170
|
+
d = (((d << 11) | (d >>> 21)) + a) | 0;
|
|
171
|
+
c += ((d ^ a ^ b) + (k[7] ?? 0) - 155497632) | 0;
|
|
172
|
+
c = (((c << 16) | (c >>> 16)) + d) | 0;
|
|
173
|
+
b += ((c ^ d ^ a) + (k[10] ?? 0) - 1094730640) | 0;
|
|
174
|
+
b = (((b << 23) | (b >>> 9)) + c) | 0;
|
|
175
|
+
a += ((b ^ c ^ d) + (k[13] ?? 0) + 681279174) | 0;
|
|
176
|
+
a = (((a << 4) | (a >>> 28)) + b) | 0;
|
|
177
|
+
d += ((a ^ b ^ c) + (k[0] ?? 0) - 358537222) | 0;
|
|
178
|
+
d = (((d << 11) | (d >>> 21)) + a) | 0;
|
|
179
|
+
c += ((d ^ a ^ b) + (k[3] ?? 0) - 722521979) | 0;
|
|
180
|
+
c = (((c << 16) | (c >>> 16)) + d) | 0;
|
|
181
|
+
b += ((c ^ d ^ a) + (k[6] ?? 0) + 76029189) | 0;
|
|
182
|
+
b = (((b << 23) | (b >>> 9)) + c) | 0;
|
|
183
|
+
a += ((b ^ c ^ d) + (k[9] ?? 0) - 640364487) | 0;
|
|
184
|
+
a = (((a << 4) | (a >>> 28)) + b) | 0;
|
|
185
|
+
d += ((a ^ b ^ c) + (k[12] ?? 0) - 421815835) | 0;
|
|
186
|
+
d = (((d << 11) | (d >>> 21)) + a) | 0;
|
|
187
|
+
c += ((d ^ a ^ b) + (k[15] ?? 0) + 530742520) | 0;
|
|
188
|
+
c = (((c << 16) | (c >>> 16)) + d) | 0;
|
|
189
|
+
b += ((c ^ d ^ a) + (k[2] ?? 0) - 995338651) | 0;
|
|
190
|
+
b = (((b << 23) | (b >>> 9)) + c) | 0;
|
|
191
|
+
// ii()
|
|
192
|
+
a += ((c ^ (b | ~d)) + (k[0] ?? 0) - 198630844) | 0;
|
|
193
|
+
a = (((a << 6) | (a >>> 26)) + b) | 0;
|
|
194
|
+
d += ((b ^ (a | ~c)) + (k[7] ?? 0) + 1126891415) | 0;
|
|
195
|
+
d = (((d << 10) | (d >>> 22)) + a) | 0;
|
|
196
|
+
c += ((a ^ (d | ~b)) + (k[14] ?? 0) - 1416354905) | 0;
|
|
197
|
+
c = (((c << 15) | (c >>> 17)) + d) | 0;
|
|
198
|
+
b += ((d ^ (c | ~a)) + (k[5] ?? 0) - 57434055) | 0;
|
|
199
|
+
b = (((b << 21) | (b >>> 11)) + c) | 0;
|
|
200
|
+
a += ((c ^ (b | ~d)) + (k[12] ?? 0) + 1700485571) | 0;
|
|
201
|
+
a = (((a << 6) | (a >>> 26)) + b) | 0;
|
|
202
|
+
d += ((b ^ (a | ~c)) + (k[3] ?? 0) - 1894986606) | 0;
|
|
203
|
+
d = (((d << 10) | (d >>> 22)) + a) | 0;
|
|
204
|
+
c += ((a ^ (d | ~b)) + (k[10] ?? 0) - 1051523) | 0;
|
|
205
|
+
c = (((c << 15) | (c >>> 17)) + d) | 0;
|
|
206
|
+
b += ((d ^ (c | ~a)) + (k[1] ?? 0) - 2054922799) | 0;
|
|
207
|
+
b = (((b << 21) | (b >>> 11)) + c) | 0;
|
|
208
|
+
a += ((c ^ (b | ~d)) + (k[8] ?? 0) + 1873313359) | 0;
|
|
209
|
+
a = (((a << 6) | (a >>> 26)) + b) | 0;
|
|
210
|
+
d += ((b ^ (a | ~c)) + (k[15] ?? 0) - 30611744) | 0;
|
|
211
|
+
d = (((d << 10) | (d >>> 22)) + a) | 0;
|
|
212
|
+
c += ((a ^ (d | ~b)) + (k[6] ?? 0) - 1560198380) | 0;
|
|
213
|
+
c = (((c << 15) | (c >>> 17)) + d) | 0;
|
|
214
|
+
b += ((d ^ (c | ~a)) + (k[13] ?? 0) + 1309151649) | 0;
|
|
215
|
+
b = (((b << 21) | (b >>> 11)) + c) | 0;
|
|
216
|
+
a += ((c ^ (b | ~d)) + (k[4] ?? 0) - 145523070) | 0;
|
|
217
|
+
a = (((a << 6) | (a >>> 26)) + b) | 0;
|
|
218
|
+
d += ((b ^ (a | ~c)) + (k[11] ?? 0) - 1120210379) | 0;
|
|
219
|
+
d = (((d << 10) | (d >>> 22)) + a) | 0;
|
|
220
|
+
c += ((a ^ (d | ~b)) + (k[2] ?? 0) + 718787259) | 0;
|
|
221
|
+
c = (((c << 15) | (c >>> 17)) + d) | 0;
|
|
222
|
+
b += ((d ^ (c | ~a)) + (k[9] ?? 0) - 343485551) | 0;
|
|
223
|
+
b = (((b << 21) | (b >>> 11)) + c) | 0;
|
|
224
|
+
x[0] = (a + (x[0] ?? 0)) | 0;
|
|
225
|
+
x[1] = (b + (x[1] ?? 0)) | 0;
|
|
226
|
+
x[2] = (c + (x[2] ?? 0)) | 0;
|
|
227
|
+
x[3] = (d + (x[3] ?? 0)) | 0;
|
|
228
|
+
}
|
|
229
|
+
_dataLength = 0;
|
|
230
|
+
_bufferLength = 0;
|
|
231
|
+
_state = new Int32Array(4);
|
|
232
|
+
_buffer = new ArrayBuffer(68);
|
|
233
|
+
_buffer8;
|
|
234
|
+
_buffer32;
|
|
235
|
+
constructor() {
|
|
236
|
+
this._buffer8 = new Uint8Array(this._buffer, 0, 68);
|
|
237
|
+
this._buffer32 = new Uint32Array(this._buffer, 0, 17);
|
|
238
|
+
this.start();
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Initialise buffer to be hashed
|
|
242
|
+
*/
|
|
243
|
+
start() {
|
|
244
|
+
this._dataLength = 0;
|
|
245
|
+
this._bufferLength = 0;
|
|
246
|
+
this._state.set(Md5.stateIdentity);
|
|
247
|
+
return this;
|
|
248
|
+
}
|
|
249
|
+
// Char to code point to to array conversion:
|
|
250
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt
|
|
251
|
+
// #Example.3A_Fixing_charCodeAt_to_handle_non-Basic-Multilingual-Plane_characters_if_their_presence_earlier_in_the_string_is_unknown
|
|
252
|
+
/**
|
|
253
|
+
* Append a UTF-8 string to the hash buffer
|
|
254
|
+
* @param str String to append
|
|
255
|
+
*/
|
|
256
|
+
appendStr(str) {
|
|
257
|
+
const buf8 = this._buffer8;
|
|
258
|
+
const buf32 = this._buffer32;
|
|
259
|
+
let bufLen = this._bufferLength;
|
|
260
|
+
let code;
|
|
261
|
+
let i;
|
|
262
|
+
for (i = 0; i < str.length; i += 1) {
|
|
263
|
+
code = str.charCodeAt(i);
|
|
264
|
+
if (code < 128) {
|
|
265
|
+
buf8[bufLen++] = code;
|
|
266
|
+
}
|
|
267
|
+
else if (code < 0x800) {
|
|
268
|
+
buf8[bufLen++] = (code >>> 6) + 0xc0;
|
|
269
|
+
buf8[bufLen++] = (code & 0x3f) | 0x80;
|
|
270
|
+
}
|
|
271
|
+
else if (code < 0xd800 || code > 0xdbff) {
|
|
272
|
+
buf8[bufLen++] = (code >>> 12) + 0xe0;
|
|
273
|
+
buf8[bufLen++] = ((code >>> 6) & 0x3f) | 0x80;
|
|
274
|
+
buf8[bufLen++] = (code & 0x3f) | 0x80;
|
|
275
|
+
}
|
|
276
|
+
else {
|
|
277
|
+
code =
|
|
278
|
+
(code - 0xd800) * 0x400 + (str.charCodeAt(++i) - 0xdc00) + 0x10000;
|
|
279
|
+
if (code > 0x10ffff) {
|
|
280
|
+
throw new Error("Unicode standard supports code points up to U+10FFFF");
|
|
281
|
+
}
|
|
282
|
+
buf8[bufLen++] = (code >>> 18) + 0xf0;
|
|
283
|
+
buf8[bufLen++] = ((code >>> 12) & 0x3f) | 0x80;
|
|
284
|
+
buf8[bufLen++] = ((code >>> 6) & 0x3f) | 0x80;
|
|
285
|
+
buf8[bufLen++] = (code & 0x3f) | 0x80;
|
|
286
|
+
}
|
|
287
|
+
if (bufLen >= 64) {
|
|
288
|
+
this._dataLength += 64;
|
|
289
|
+
Md5._md5cycle(this._state, buf32);
|
|
290
|
+
bufLen -= 64;
|
|
291
|
+
buf32[0] = buf32[16] ?? 0;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
this._bufferLength = bufLen;
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Append an ASCII string to the hash buffer
|
|
299
|
+
* @param str String to append
|
|
300
|
+
*/
|
|
301
|
+
appendAsciiStr(str) {
|
|
302
|
+
const buf8 = this._buffer8;
|
|
303
|
+
const buf32 = this._buffer32;
|
|
304
|
+
let bufLen = this._bufferLength;
|
|
305
|
+
let i;
|
|
306
|
+
let j = 0;
|
|
307
|
+
for (;;) {
|
|
308
|
+
i = Math.min(str.length - j, 64 - bufLen);
|
|
309
|
+
while (i--) {
|
|
310
|
+
buf8[bufLen++] = str.charCodeAt(j++);
|
|
311
|
+
}
|
|
312
|
+
if (bufLen < 64) {
|
|
313
|
+
break;
|
|
314
|
+
}
|
|
315
|
+
this._dataLength += 64;
|
|
316
|
+
Md5._md5cycle(this._state, buf32);
|
|
317
|
+
bufLen = 0;
|
|
318
|
+
}
|
|
319
|
+
this._bufferLength = bufLen;
|
|
320
|
+
return this;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Append a byte array to the hash buffer
|
|
324
|
+
* @param input array to append
|
|
325
|
+
*/
|
|
326
|
+
appendByteArray(input) {
|
|
327
|
+
const buf8 = this._buffer8;
|
|
328
|
+
const buf32 = this._buffer32;
|
|
329
|
+
let bufLen = this._bufferLength;
|
|
330
|
+
let i;
|
|
331
|
+
let j = 0;
|
|
332
|
+
for (;;) {
|
|
333
|
+
i = Math.min(input.length - j, 64 - bufLen);
|
|
334
|
+
while (i--) {
|
|
335
|
+
buf8[bufLen++] = input[j++] ?? 0;
|
|
336
|
+
}
|
|
337
|
+
if (bufLen < 64) {
|
|
338
|
+
break;
|
|
339
|
+
}
|
|
340
|
+
this._dataLength += 64;
|
|
341
|
+
Md5._md5cycle(this._state, buf32);
|
|
342
|
+
bufLen = 0;
|
|
343
|
+
}
|
|
344
|
+
this._bufferLength = bufLen;
|
|
345
|
+
return this;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Get the state of the hash buffer
|
|
349
|
+
*/
|
|
350
|
+
getState() {
|
|
351
|
+
const s = this._state;
|
|
352
|
+
return {
|
|
353
|
+
buffer: String.fromCharCode.apply(null, Array.from(this._buffer8)),
|
|
354
|
+
buflen: this._bufferLength,
|
|
355
|
+
length: this._dataLength,
|
|
356
|
+
state: [s[0] ?? 0, s[1] ?? 0, s[2] ?? 0, s[3] ?? 0],
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Override the current state of the hash buffer
|
|
361
|
+
* @param state New hash buffer state
|
|
362
|
+
*/
|
|
363
|
+
setState(state) {
|
|
364
|
+
const buf = state.buffer;
|
|
365
|
+
const x = state.state;
|
|
366
|
+
const s = this._state;
|
|
367
|
+
let i;
|
|
368
|
+
this._dataLength = state.length;
|
|
369
|
+
this._bufferLength = state.buflen;
|
|
370
|
+
s[0] = x[0] ?? 0;
|
|
371
|
+
s[1] = x[1] ?? 0;
|
|
372
|
+
s[2] = x[2] ?? 0;
|
|
373
|
+
s[3] = x[3] ?? 0;
|
|
374
|
+
for (i = 0; i < buf.length; i += 1) {
|
|
375
|
+
this._buffer8[i] = buf.charCodeAt(i);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Hash the current state of the hash buffer and return the result
|
|
380
|
+
* @param raw Whether to return the value as an `Int32Array`
|
|
381
|
+
*/
|
|
382
|
+
end(raw = false) {
|
|
383
|
+
const bufLen = this._bufferLength;
|
|
384
|
+
const buf8 = this._buffer8;
|
|
385
|
+
const buf32 = this._buffer32;
|
|
386
|
+
const i = (bufLen >> 2) + 1;
|
|
387
|
+
this._dataLength += bufLen;
|
|
388
|
+
const dataBitsLen = this._dataLength * 8;
|
|
389
|
+
buf8[bufLen] = 0x80;
|
|
390
|
+
buf8[bufLen + 1] = buf8[bufLen + 2] = buf8[bufLen + 3] = 0;
|
|
391
|
+
buf32.set(Md5.buffer32Identity.subarray(i), i);
|
|
392
|
+
if (bufLen > 55) {
|
|
393
|
+
Md5._md5cycle(this._state, buf32);
|
|
394
|
+
buf32.set(Md5.buffer32Identity);
|
|
395
|
+
}
|
|
396
|
+
// Do the final computation based on the tail and length
|
|
397
|
+
// Beware that the final length may not fit in 32 bits so we take care of that
|
|
398
|
+
if (dataBitsLen <= 0xffffffff) {
|
|
399
|
+
buf32[14] = dataBitsLen;
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
const matches = dataBitsLen.toString(16).match(/(.*?)(.{0,8})$/);
|
|
403
|
+
if (matches === null) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
const lo = Number.parseInt(matches[2] ?? "", 16);
|
|
407
|
+
const hi = Number.parseInt(matches[1] ?? "", 16) || 0;
|
|
408
|
+
buf32[14] = lo;
|
|
409
|
+
buf32[15] = hi;
|
|
410
|
+
}
|
|
411
|
+
Md5._md5cycle(this._state, buf32);
|
|
412
|
+
return raw ? this._state : Md5._hex(this._state);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (Md5.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592") {
|
|
416
|
+
throw new Error("Md5 self test failed.");
|
|
417
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"md5.js","names":["n: number","offset: number","j: number","i: number","a: number","b: number","c: number","d: number","code: number"],"sources":["../../src/utils/md5.ts"],"sourcesContent":["/*\n\nTypeScript Md5\n==============\n\nBased on work by\n* Joseph Myers: http://www.myersdaily.org/joseph/javascript/md5-text.html\n* André Cruz: https://github.com/satazor/SparkMD5\n* Raymond Hill: https://github.com/gorhill/yamd5.js\n\nEffectively a TypeScrypt re-write of Raymond Hill JS Library\n\nThe MIT License (MIT)\n\nCopyright (C) 2014 Raymond Hill\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n\n DO WHAT YOU WANT TO PUBLIC LICENSE\n Version 2, December 2004\n\n Copyright (C) 2015 André Cruz <amdfcruz@gmail.com>\n\n Everyone is permitted to copy and distribute verbatim or modified\n copies of this license document, and changing it is allowed as long\n as the name is changed.\n\n DO WHAT YOU WANT TO PUBLIC LICENSE\n TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n 0. You just DO WHAT YOU WANT TO.\n\n*/\n\ntype HasherState = {\n buffer: string;\n buflen: number;\n length: number;\n state: number[];\n};\n\nexport class Md5 {\n /**\n * Hash a UTF-8 string on the spot\n * @param str String to hash\n * @param raw Whether to return the value as an `Int32Array`\n */\n public static hashStr(str: string, raw?: false): string;\n public static hashStr(str: string, raw: true): Int32Array;\n public static hashStr(str: string, raw = false) {\n return Md5.onePassHasher.start().appendStr(str).end(raw);\n }\n\n /**\n * Hash a ASCII string on the spot\n * @param str String to hash\n * @param raw Whether to return the value as an `Int32Array`\n */\n public static hashAsciiStr(str: string, raw?: false): string;\n public static hashAsciiStr(str: string, raw: true): Int32Array;\n public static hashAsciiStr(str: string, raw = false) {\n return Md5.onePassHasher.start().appendAsciiStr(str).end(raw);\n }\n\n // Private Static Variables\n private static stateIdentity = new Int32Array([\n 1732584193, -271733879, -1732584194, 271733878,\n ]);\n\n private static buffer32Identity = new Int32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n ]);\n\n private static hexChars = \"0123456789abcdef\";\n private static hexOut: string[] = [];\n\n // Permanent instance is to use for one-call hashing\n private static onePassHasher = new Md5();\n\n private static _hex(x: Int32Array): string {\n const hc = Md5.hexChars;\n const ho = Md5.hexOut;\n let n: number;\n let offset: number;\n let j: number;\n let i: number;\n\n for (i = 0; i < 4; i += 1) {\n offset = i * 8;\n n = x[i] ?? 0;\n for (j = 0; j < 8; j += 2) {\n ho[offset + 1 + j] = hc.charAt(n & 0x0f);\n n >>>= 4;\n ho[offset + 0 + j] = hc.charAt(n & 0x0f);\n n >>>= 4;\n }\n }\n return ho.join(\"\");\n }\n\n private static _md5cycle(\n x: Int32Array | Uint32Array,\n k: Int32Array | Uint32Array,\n ) {\n let a: number = x[0] ?? 0;\n let b: number = x[1] ?? 0;\n let c: number = x[2] ?? 0;\n let d: number = x[3] ?? 0;\n // ff()\n a += (((b & c) | (~b & d)) + (k[0] ?? 0) - 680876936) | 0;\n a = (((a << 7) | (a >>> 25)) + b) | 0;\n d += (((a & b) | (~a & c)) + (k[1] ?? 0) - 389564586) | 0;\n d = (((d << 12) | (d >>> 20)) + a) | 0;\n c += (((d & a) | (~d & b)) + (k[2] ?? 0) + 606105819) | 0;\n c = (((c << 17) | (c >>> 15)) + d) | 0;\n b += (((c & d) | (~c & a)) + (k[3] ?? 0) - 1044525330) | 0;\n b = (((b << 22) | (b >>> 10)) + c) | 0;\n a += (((b & c) | (~b & d)) + (k[4] ?? 0) - 176418897) | 0;\n a = (((a << 7) | (a >>> 25)) + b) | 0;\n d += (((a & b) | (~a & c)) + (k[5] ?? 0) + 1200080426) | 0;\n d = (((d << 12) | (d >>> 20)) + a) | 0;\n c += (((d & a) | (~d & b)) + (k[6] ?? 0) - 1473231341) | 0;\n c = (((c << 17) | (c >>> 15)) + d) | 0;\n b += (((c & d) | (~c & a)) + (k[7] ?? 0) - 45705983) | 0;\n b = (((b << 22) | (b >>> 10)) + c) | 0;\n a += (((b & c) | (~b & d)) + (k[8] ?? 0) + 1770035416) | 0;\n a = (((a << 7) | (a >>> 25)) + b) | 0;\n d += (((a & b) | (~a & c)) + (k[9] ?? 0) - 1958414417) | 0;\n d = (((d << 12) | (d >>> 20)) + a) | 0;\n c += (((d & a) | (~d & b)) + (k[10] ?? 0) - 42063) | 0;\n c = (((c << 17) | (c >>> 15)) + d) | 0;\n b += (((c & d) | (~c & a)) + (k[11] ?? 0) - 1990404162) | 0;\n b = (((b << 22) | (b >>> 10)) + c) | 0;\n a += (((b & c) | (~b & d)) + (k[12] ?? 0) + 1804603682) | 0;\n a = (((a << 7) | (a >>> 25)) + b) | 0;\n d += (((a & b) | (~a & c)) + (k[13] ?? 0) - 40341101) | 0;\n d = (((d << 12) | (d >>> 20)) + a) | 0;\n c += (((d & a) | (~d & b)) + (k[14] ?? 0) - 1502002290) | 0;\n c = (((c << 17) | (c >>> 15)) + d) | 0;\n b += (((c & d) | (~c & a)) + (k[15] ?? 0) + 1236535329) | 0;\n b = (((b << 22) | (b >>> 10)) + c) | 0;\n // gg()\n a += (((b & d) | (c & ~d)) + (k[1] ?? 0) - 165796510) | 0;\n a = (((a << 5) | (a >>> 27)) + b) | 0;\n d += (((a & c) | (b & ~c)) + (k[6] ?? 0) - 1069501632) | 0;\n d = (((d << 9) | (d >>> 23)) + a) | 0;\n c += (((d & b) | (a & ~b)) + (k[11] ?? 0) + 643717713) | 0;\n c = (((c << 14) | (c >>> 18)) + d) | 0;\n b += (((c & a) | (d & ~a)) + (k[0] ?? 0) - 373897302) | 0;\n b = (((b << 20) | (b >>> 12)) + c) | 0;\n a += (((b & d) | (c & ~d)) + (k[5] ?? 0) - 701558691) | 0;\n a = (((a << 5) | (a >>> 27)) + b) | 0;\n d += (((a & c) | (b & ~c)) + (k[10] ?? 0) + 38016083) | 0;\n d = (((d << 9) | (d >>> 23)) + a) | 0;\n c += (((d & b) | (a & ~b)) + (k[15] ?? 0) - 660478335) | 0;\n c = (((c << 14) | (c >>> 18)) + d) | 0;\n b += (((c & a) | (d & ~a)) + (k[4] ?? 0) - 405537848) | 0;\n b = (((b << 20) | (b >>> 12)) + c) | 0;\n a += (((b & d) | (c & ~d)) + (k[9] ?? 0) + 568446438) | 0;\n a = (((a << 5) | (a >>> 27)) + b) | 0;\n d += (((a & c) | (b & ~c)) + (k[14] ?? 0) - 1019803690) | 0;\n d = (((d << 9) | (d >>> 23)) + a) | 0;\n c += (((d & b) | (a & ~b)) + (k[3] ?? 0) - 187363961) | 0;\n c = (((c << 14) | (c >>> 18)) + d) | 0;\n b += (((c & a) | (d & ~a)) + (k[8] ?? 0) + 1163531501) | 0;\n b = (((b << 20) | (b >>> 12)) + c) | 0;\n a += (((b & d) | (c & ~d)) + (k[13] ?? 0) - 1444681467) | 0;\n a = (((a << 5) | (a >>> 27)) + b) | 0;\n d += (((a & c) | (b & ~c)) + (k[2] ?? 0) - 51403784) | 0;\n d = (((d << 9) | (d >>> 23)) + a) | 0;\n c += (((d & b) | (a & ~b)) + (k[7] ?? 0) + 1735328473) | 0;\n c = (((c << 14) | (c >>> 18)) + d) | 0;\n b += (((c & a) | (d & ~a)) + (k[12] ?? 0) - 1926607734) | 0;\n b = (((b << 20) | (b >>> 12)) + c) | 0;\n // hh()\n a += ((b ^ c ^ d) + (k[5] ?? 0) - 378558) | 0;\n a = (((a << 4) | (a >>> 28)) + b) | 0;\n d += ((a ^ b ^ c) + (k[8] ?? 0) - 2022574463) | 0;\n d = (((d << 11) | (d >>> 21)) + a) | 0;\n c += ((d ^ a ^ b) + (k[11] ?? 0) + 1839030562) | 0;\n c = (((c << 16) | (c >>> 16)) + d) | 0;\n b += ((c ^ d ^ a) + (k[14] ?? 0) - 35309556) | 0;\n b = (((b << 23) | (b >>> 9)) + c) | 0;\n a += ((b ^ c ^ d) + (k[1] ?? 0) - 1530992060) | 0;\n a = (((a << 4) | (a >>> 28)) + b) | 0;\n d += ((a ^ b ^ c) + (k[4] ?? 0) + 1272893353) | 0;\n d = (((d << 11) | (d >>> 21)) + a) | 0;\n c += ((d ^ a ^ b) + (k[7] ?? 0) - 155497632) | 0;\n c = (((c << 16) | (c >>> 16)) + d) | 0;\n b += ((c ^ d ^ a) + (k[10] ?? 0) - 1094730640) | 0;\n b = (((b << 23) | (b >>> 9)) + c) | 0;\n a += ((b ^ c ^ d) + (k[13] ?? 0) + 681279174) | 0;\n a = (((a << 4) | (a >>> 28)) + b) | 0;\n d += ((a ^ b ^ c) + (k[0] ?? 0) - 358537222) | 0;\n d = (((d << 11) | (d >>> 21)) + a) | 0;\n c += ((d ^ a ^ b) + (k[3] ?? 0) - 722521979) | 0;\n c = (((c << 16) | (c >>> 16)) + d) | 0;\n b += ((c ^ d ^ a) + (k[6] ?? 0) + 76029189) | 0;\n b = (((b << 23) | (b >>> 9)) + c) | 0;\n a += ((b ^ c ^ d) + (k[9] ?? 0) - 640364487) | 0;\n a = (((a << 4) | (a >>> 28)) + b) | 0;\n d += ((a ^ b ^ c) + (k[12] ?? 0) - 421815835) | 0;\n d = (((d << 11) | (d >>> 21)) + a) | 0;\n c += ((d ^ a ^ b) + (k[15] ?? 0) + 530742520) | 0;\n c = (((c << 16) | (c >>> 16)) + d) | 0;\n b += ((c ^ d ^ a) + (k[2] ?? 0) - 995338651) | 0;\n b = (((b << 23) | (b >>> 9)) + c) | 0;\n // ii()\n a += ((c ^ (b | ~d)) + (k[0] ?? 0) - 198630844) | 0;\n a = (((a << 6) | (a >>> 26)) + b) | 0;\n d += ((b ^ (a | ~c)) + (k[7] ?? 0) + 1126891415) | 0;\n d = (((d << 10) | (d >>> 22)) + a) | 0;\n c += ((a ^ (d | ~b)) + (k[14] ?? 0) - 1416354905) | 0;\n c = (((c << 15) | (c >>> 17)) + d) | 0;\n b += ((d ^ (c | ~a)) + (k[5] ?? 0) - 57434055) | 0;\n b = (((b << 21) | (b >>> 11)) + c) | 0;\n a += ((c ^ (b | ~d)) + (k[12] ?? 0) + 1700485571) | 0;\n a = (((a << 6) | (a >>> 26)) + b) | 0;\n d += ((b ^ (a | ~c)) + (k[3] ?? 0) - 1894986606) | 0;\n d = (((d << 10) | (d >>> 22)) + a) | 0;\n c += ((a ^ (d | ~b)) + (k[10] ?? 0) - 1051523) | 0;\n c = (((c << 15) | (c >>> 17)) + d) | 0;\n b += ((d ^ (c | ~a)) + (k[1] ?? 0) - 2054922799) | 0;\n b = (((b << 21) | (b >>> 11)) + c) | 0;\n a += ((c ^ (b | ~d)) + (k[8] ?? 0) + 1873313359) | 0;\n a = (((a << 6) | (a >>> 26)) + b) | 0;\n d += ((b ^ (a | ~c)) + (k[15] ?? 0) - 30611744) | 0;\n d = (((d << 10) | (d >>> 22)) + a) | 0;\n c += ((a ^ (d | ~b)) + (k[6] ?? 0) - 1560198380) | 0;\n c = (((c << 15) | (c >>> 17)) + d) | 0;\n b += ((d ^ (c | ~a)) + (k[13] ?? 0) + 1309151649) | 0;\n b = (((b << 21) | (b >>> 11)) + c) | 0;\n a += ((c ^ (b | ~d)) + (k[4] ?? 0) - 145523070) | 0;\n a = (((a << 6) | (a >>> 26)) + b) | 0;\n d += ((b ^ (a | ~c)) + (k[11] ?? 0) - 1120210379) | 0;\n d = (((d << 10) | (d >>> 22)) + a) | 0;\n c += ((a ^ (d | ~b)) + (k[2] ?? 0) + 718787259) | 0;\n c = (((c << 15) | (c >>> 17)) + d) | 0;\n b += ((d ^ (c | ~a)) + (k[9] ?? 0) - 343485551) | 0;\n b = (((b << 21) | (b >>> 11)) + c) | 0;\n\n x[0] = (a + (x[0] ?? 0)) | 0;\n x[1] = (b + (x[1] ?? 0)) | 0;\n x[2] = (c + (x[2] ?? 0)) | 0;\n x[3] = (d + (x[3] ?? 0)) | 0;\n }\n\n private _dataLength = 0;\n private _bufferLength = 0;\n\n private _state: Int32Array = new Int32Array(4);\n private _buffer: ArrayBuffer = new ArrayBuffer(68);\n private _buffer8: Uint8Array;\n private _buffer32: Uint32Array;\n\n constructor() {\n this._buffer8 = new Uint8Array(this._buffer, 0, 68);\n this._buffer32 = new Uint32Array(this._buffer, 0, 17);\n this.start();\n }\n\n /**\n * Initialise buffer to be hashed\n */\n public start() {\n this._dataLength = 0;\n this._bufferLength = 0;\n this._state.set(Md5.stateIdentity);\n return this;\n }\n\n // Char to code point to to array conversion:\n // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt\n // #Example.3A_Fixing_charCodeAt_to_handle_non-Basic-Multilingual-Plane_characters_if_their_presence_earlier_in_the_string_is_unknown\n\n /**\n * Append a UTF-8 string to the hash buffer\n * @param str String to append\n */\n public appendStr(str: string) {\n const buf8 = this._buffer8;\n const buf32 = this._buffer32;\n let bufLen = this._bufferLength;\n let code: number;\n let i: number;\n\n for (i = 0; i < str.length; i += 1) {\n code = str.charCodeAt(i);\n if (code < 128) {\n buf8[bufLen++] = code;\n } else if (code < 0x800) {\n buf8[bufLen++] = (code >>> 6) + 0xc0;\n buf8[bufLen++] = (code & 0x3f) | 0x80;\n } else if (code < 0xd800 || code > 0xdbff) {\n buf8[bufLen++] = (code >>> 12) + 0xe0;\n buf8[bufLen++] = ((code >>> 6) & 0x3f) | 0x80;\n buf8[bufLen++] = (code & 0x3f) | 0x80;\n } else {\n code =\n (code - 0xd800) * 0x400 + (str.charCodeAt(++i) - 0xdc00) + 0x10000;\n if (code > 0x10ffff) {\n throw new Error(\n \"Unicode standard supports code points up to U+10FFFF\",\n );\n }\n buf8[bufLen++] = (code >>> 18) + 0xf0;\n buf8[bufLen++] = ((code >>> 12) & 0x3f) | 0x80;\n buf8[bufLen++] = ((code >>> 6) & 0x3f) | 0x80;\n buf8[bufLen++] = (code & 0x3f) | 0x80;\n }\n if (bufLen >= 64) {\n this._dataLength += 64;\n Md5._md5cycle(this._state, buf32);\n bufLen -= 64;\n buf32[0] = buf32[16] ?? 0;\n }\n }\n this._bufferLength = bufLen;\n return this;\n }\n\n /**\n * Append an ASCII string to the hash buffer\n * @param str String to append\n */\n public appendAsciiStr(str: string) {\n const buf8 = this._buffer8;\n const buf32 = this._buffer32;\n let bufLen = this._bufferLength;\n let i: number;\n let j = 0;\n\n for (;;) {\n i = Math.min(str.length - j, 64 - bufLen);\n while (i--) {\n buf8[bufLen++] = str.charCodeAt(j++);\n }\n if (bufLen < 64) {\n break;\n }\n this._dataLength += 64;\n Md5._md5cycle(this._state, buf32);\n bufLen = 0;\n }\n this._bufferLength = bufLen;\n return this;\n }\n\n /**\n * Append a byte array to the hash buffer\n * @param input array to append\n */\n public appendByteArray(input: Uint8Array) {\n const buf8 = this._buffer8;\n const buf32 = this._buffer32;\n let bufLen = this._bufferLength;\n let i: number;\n let j = 0;\n\n for (;;) {\n i = Math.min(input.length - j, 64 - bufLen);\n while (i--) {\n buf8[bufLen++] = input[j++] ?? 0;\n }\n if (bufLen < 64) {\n break;\n }\n this._dataLength += 64;\n Md5._md5cycle(this._state, buf32);\n bufLen = 0;\n }\n this._bufferLength = bufLen;\n return this;\n }\n\n /**\n * Get the state of the hash buffer\n */\n public getState(): HasherState {\n const s = this._state;\n\n return {\n buffer: String.fromCharCode.apply(null, Array.from(this._buffer8)),\n buflen: this._bufferLength,\n length: this._dataLength,\n state: [s[0] ?? 0, s[1] ?? 0, s[2] ?? 0, s[3] ?? 0],\n };\n }\n\n /**\n * Override the current state of the hash buffer\n * @param state New hash buffer state\n */\n public setState(state: HasherState) {\n const buf = state.buffer;\n const x = state.state;\n const s = this._state;\n let i: number;\n\n this._dataLength = state.length;\n this._bufferLength = state.buflen;\n s[0] = x[0] ?? 0;\n s[1] = x[1] ?? 0;\n s[2] = x[2] ?? 0;\n s[3] = x[3] ?? 0;\n\n for (i = 0; i < buf.length; i += 1) {\n this._buffer8[i] = buf.charCodeAt(i);\n }\n }\n\n /**\n * Hash the current state of the hash buffer and return the result\n * @param raw Whether to return the value as an `Int32Array`\n */\n public end(raw = false) {\n const bufLen = this._bufferLength;\n const buf8 = this._buffer8;\n const buf32 = this._buffer32;\n const i = (bufLen >> 2) + 1;\n\n this._dataLength += bufLen;\n const dataBitsLen = this._dataLength * 8;\n\n buf8[bufLen] = 0x80;\n buf8[bufLen + 1] = buf8[bufLen + 2] = buf8[bufLen + 3] = 0;\n buf32.set(Md5.buffer32Identity.subarray(i), i);\n\n if (bufLen > 55) {\n Md5._md5cycle(this._state, buf32);\n buf32.set(Md5.buffer32Identity);\n }\n\n // Do the final computation based on the tail and length\n // Beware that the final length may not fit in 32 bits so we take care of that\n if (dataBitsLen <= 0xffffffff) {\n buf32[14] = dataBitsLen;\n } else {\n const matches = dataBitsLen.toString(16).match(/(.*?)(.{0,8})$/);\n if (matches === null) {\n return;\n }\n\n const lo = Number.parseInt(matches[2] ?? \"\", 16);\n const hi = Number.parseInt(matches[1] ?? \"\", 16) || 0;\n\n buf32[14] = lo;\n buf32[15] = hi;\n }\n\n Md5._md5cycle(this._state, buf32);\n\n return raw ? this._state : Md5._hex(this._state);\n }\n}\n\nif (Md5.hashStr(\"hello\") !== \"5d41402abc4b2a76b9719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,EAAI,QAAQ,QAAQ,GAAK,mCAC3B,MAAU,MAAM,wBAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../chunk-CUT6urMc.cjs`),t=require(`../uploadista-error-BB-Wdiz9.cjs`);let n=require(`effect`);n=e.__toESM(n);function r(e){let t=!1,n;return function(...r){if(t){if(n)return n;throw Error(`Function called more than once`)}return t=!0,n=e.apply(this,r),n}}const i={make:e=>{let r,i=!1;return n.Effect.gen(function*(){if(i){if(r!==void 0)return r;yield*new t.UploadistaError({code:`UNKNOWN_ERROR`,status:500,body:`Effect called more than once with undefined result`}).toEffect()}return i=!0,r=yield*e,r})},legacy:r};exports.OnceEffect=i,exports.once=r;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { UploadistaError } from "../uploadista-error-kKlhLRhY.cjs";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
|
|
4
|
+
//#region src/utils/once.d.ts
|
|
5
|
+
declare function once<T, A extends unknown[], Return>(fn: (this: T, ...args: A) => Return): (this: T, ...args: A) => Return;
|
|
6
|
+
/**
|
|
7
|
+
* Effect-based once utilities
|
|
8
|
+
*/
|
|
9
|
+
declare const OnceEffect: {
|
|
10
|
+
/**
|
|
11
|
+
* Creates an Effect-based once function that only executes once
|
|
12
|
+
* @param effect - The effect to execute only once
|
|
13
|
+
* @returns Effect that caches the result after first execution
|
|
14
|
+
*/
|
|
15
|
+
make: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E | UploadistaError, R>;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a legacy once function wrapper
|
|
18
|
+
* @param fn - Function to wrap
|
|
19
|
+
* @returns Once-wrapped function
|
|
20
|
+
*/
|
|
21
|
+
legacy: typeof once;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { OnceEffect, once };
|
|
25
|
+
//# sourceMappingURL=once.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"once.d.cts","names":[],"sources":["../../src/utils/once.ts"],"sourcesContent":[],"mappings":";;;;iBAIgB,gDACH,YAAY,MAAM,gBAIH,YAAY,MAAI;;AAL5C;;AACa,cAqBA,UArBA,EAAA;;;;;;EAIqC,IAAA,EAAA,CAAA,CAAA,EAAA,CAAA,EAAA,CAAA,CAAA,CAAA,MAAA,EAwBtC,MAAA,CAAO,MAxB+B,CAwBxB,CAxBwB,EAwBrB,CAxBqB,EAwBlB,CAxBkB,CAAA,EAAA,GAyB7C,MAAA,CAAO,MAzBsC,CAyB/B,CAzB+B,EAyB5B,CAzB4B,GAyBxB,eAzBwB,EAyBP,CAzBO,CAAA;EAiBrC;;;;;QAOD,EAAA,WAAO"}
|