ranuts 0.4.1-alpha.2 → 0.5.0
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/CLAUDE.md +23 -16
- package/README.de.md +62 -0
- package/README.es.md +62 -0
- package/README.fa.md +62 -0
- package/README.ja.md +62 -0
- package/README.ko.md +62 -0
- package/README.md +35 -92
- package/README.pt.md +62 -0
- package/README.zh-CN.md +35 -91
- package/dist/iife/index.iife.js +4 -0
- package/dist/iife/utils.iife.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +306 -1
- package/dist/src/_virtual/_rolldown/runtime/index.js +12 -0
- package/dist/src/conversation/engine.d.ts +1 -1
- package/dist/src/conversation/engine.js +101 -0
- package/dist/src/conversation/index.d.ts +3 -3
- package/dist/src/conversation/index.js +4 -1
- package/dist/src/stream/accumulator.d.ts +1 -1
- package/dist/src/stream/accumulator.js +79 -0
- package/dist/src/stream/budget.d.ts +1 -1
- package/dist/src/stream/budget.js +45 -0
- package/dist/src/stream/index.d.ts +7 -7
- package/dist/src/stream/index.js +11 -1
- package/dist/src/stream/sse.d.ts +1 -1
- package/dist/src/stream/sse.js +61 -0
- package/dist/src/sw/index.js +52 -1
- package/dist/src/utils/async.js +49 -0
- package/dist/src/utils/audioRecorder.js +1121 -0
- package/dist/src/utils/behavior.js +9 -0
- package/dist/src/utils/binary.js +89 -0
- package/dist/src/utils/bom.d.ts +31 -9
- package/dist/src/utils/bom.js +165 -0
- package/dist/src/utils/bridge.js +310 -0
- package/dist/src/utils/canvas.js +103 -0
- package/dist/src/utils/chain.js +76 -0
- package/dist/src/utils/color.d.ts +0 -1
- package/dist/src/utils/color.js +312 -0
- package/dist/src/utils/compose.js +22 -0
- package/dist/src/utils/console.js +22 -0
- package/dist/src/utils/debounce.js +18 -0
- package/dist/src/utils/device.d.ts +0 -9
- package/dist/src/utils/device.js +31 -0
- package/dist/src/utils/diff.js +110 -0
- package/dist/src/utils/dom.d.ts +1 -1
- package/dist/src/utils/dom.js +89 -0
- package/dist/src/utils/error.js +11 -0
- package/dist/src/utils/event.d.ts +3 -3
- package/dist/src/utils/event.js +39 -0
- package/dist/src/utils/file.js +14 -0
- package/dist/src/utils/func.js +4 -0
- package/dist/src/utils/i18n/index.js +79 -1
- package/dist/src/utils/idb.js +177 -0
- package/dist/src/utils/img.d.ts +1 -1
- package/dist/src/utils/img.js +68 -0
- package/dist/src/utils/index.d.ts +80 -80
- package/dist/src/utils/index.js +306 -1
- package/dist/src/utils/lang.d.ts +23 -6
- package/dist/src/utils/lang.js +42 -0
- package/dist/src/utils/localePath.js +48 -0
- package/dist/src/utils/memoize.d.ts +1 -7
- package/dist/src/utils/memoize.js +16 -0
- package/dist/src/utils/mimeType.js +841 -0
- package/dist/src/utils/monitor.js +84 -0
- package/dist/src/utils/network.js +117 -0
- package/dist/src/utils/noop.js +5 -0
- package/dist/src/utils/number.js +185 -0
- package/dist/src/utils/obj.d.ts +2 -2
- package/dist/src/utils/obj.js +140 -0
- package/dist/src/utils/paginate.js +93 -0
- package/dist/src/utils/performance.js +26 -0
- package/dist/src/utils/placement.js +37 -0
- package/dist/src/utils/prefetch.js +69 -0
- package/dist/src/utils/queue.js +46 -0
- package/dist/src/utils/report.js +44 -0
- package/dist/src/utils/request.js +35 -0
- package/dist/src/utils/script.d.ts +1 -1
- package/dist/src/utils/script.js +46 -0
- package/dist/src/utils/scroll.js +62 -0
- package/dist/src/utils/secure.js +36 -0
- package/dist/src/utils/segment.js +43 -0
- package/dist/src/utils/signal.d.ts +1 -1
- package/dist/src/utils/signal.js +13 -0
- package/dist/src/utils/speech.js +59 -0
- package/dist/src/utils/storage.js +53 -0
- package/dist/src/utils/str.d.ts +0 -6
- package/dist/src/utils/str.js +395 -0
- package/dist/src/utils/style.js +29 -0
- package/dist/src/utils/subscribe.js +58 -0
- package/dist/src/utils/throttle.js +17 -0
- package/dist/src/utils/time.d.ts +0 -21
- package/dist/src/utils/time.js +97 -0
- package/dist/src/utils/totp/sha/common.d.ts +1 -1
- package/dist/src/utils/totp/sha/common.js +201 -0
- package/dist/src/utils/totp/sha/converters.d.ts +1 -1
- package/dist/src/utils/totp/sha/converters.js +188 -0
- package/dist/src/utils/totp/sha/primitives_32.js +55 -0
- package/dist/src/utils/totp/sha/primitives_64.js +85 -0
- package/dist/src/utils/totp/sha/sha.d.ts +1 -1
- package/dist/src/utils/totp/sha/sha.js +30 -0
- package/dist/src/utils/totp/sha/sha1.d.ts +2 -2
- package/dist/src/utils/totp/sha/sha1.js +51 -0
- package/dist/src/utils/totp/sha/sha256.d.ts +2 -2
- package/dist/src/utils/totp/sha/sha256.js +56 -0
- package/dist/src/utils/totp/sha/sha3.d.ts +3 -3
- package/dist/src/utils/totp/sha/sha3.js +253 -0
- package/dist/src/utils/totp/sha/sha512.d.ts +3 -3
- package/dist/src/utils/totp/sha/sha512.js +177 -0
- package/dist/src/utils/totp/totp.js +49 -0
- package/dist/src/utils/tween.js +59 -0
- package/dist/src/utils/visual/application.d.ts +4 -4
- package/dist/src/utils/visual/application.js +42 -0
- package/dist/src/utils/visual/enums.js +19 -0
- package/dist/src/utils/visual/event/boundary.d.ts +2 -2
- package/dist/src/utils/visual/event/boundary.js +93 -0
- package/dist/src/utils/visual/event/event.d.ts +1 -1
- package/dist/src/utils/visual/event/event.js +34 -0
- package/dist/src/utils/visual/event/index.d.ts +4 -4
- package/dist/src/utils/visual/event/types.d.ts +2 -2
- package/dist/src/utils/visual/event/types.js +23 -0
- package/dist/src/utils/visual/graphics/graphics.d.ts +8 -8
- package/dist/src/utils/visual/graphics/graphics.js +168 -0
- package/dist/src/utils/visual/graphics/graphicsData.d.ts +3 -3
- package/dist/src/utils/visual/graphics/graphicsData.js +12 -0
- package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +7 -7
- package/dist/src/utils/visual/graphics/graphicsGeometry.js +39 -0
- package/dist/src/utils/visual/graphics/index.d.ts +3 -3
- package/dist/src/utils/visual/index.d.ts +8 -8
- package/dist/src/utils/visual/index.js +20 -1
- package/dist/src/utils/visual/math/bezier.js +15 -0
- package/dist/src/utils/visual/math/enums.js +6 -0
- package/dist/src/utils/visual/math/index.d.ts +4 -4
- package/dist/src/utils/visual/math/matrix.d.ts +1 -1
- package/dist/src/utils/visual/math/matrix.js +59 -0
- package/dist/src/utils/visual/math/transform.d.ts +2 -2
- package/dist/src/utils/visual/math/transform.js +50 -0
- package/dist/src/utils/visual/render/batchRenderer.d.ts +4 -4
- package/dist/src/utils/visual/render/batchRenderer.js +59 -0
- package/dist/src/utils/visual/render/canvasRenderer.d.ts +3 -3
- package/dist/src/utils/visual/render/canvasRenderer.js +17 -0
- package/dist/src/utils/visual/render/filter.d.ts +1 -1
- package/dist/src/utils/visual/render/filter.js +92 -0
- package/dist/src/utils/visual/render/index.d.ts +2 -2
- package/dist/src/utils/visual/render/index.js +20 -0
- package/dist/src/utils/visual/render/render.d.ts +4 -4
- package/dist/src/utils/visual/render/render.js +19 -0
- package/dist/src/utils/visual/render/renderTarget.js +28 -0
- package/dist/src/utils/visual/render/utils/batch/index.d.ts +4 -4
- package/dist/src/utils/visual/render/utils/batch/index.js +88 -0
- package/dist/src/utils/visual/render/utils/earcut.js +328 -0
- package/dist/src/utils/visual/render/utils/float.js +65 -0
- package/dist/src/utils/visual/render/utils/index.js +50 -0
- package/dist/src/utils/visual/render/utils/verticy.d.ts +2 -2
- package/dist/src/utils/visual/render/utils/verticy.js +162 -0
- package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +1 -1
- package/dist/src/utils/visual/render/utils/webgl/initShader.js +31 -0
- package/dist/src/utils/visual/render/utils/webgl/shaders.js +22 -0
- package/dist/src/utils/visual/render/utils/webgpu/shaders.js +32 -0
- package/dist/src/utils/visual/render/webGPURenderer.d.ts +2 -2
- package/dist/src/utils/visual/render/webGPURenderer.js +185 -0
- package/dist/src/utils/visual/render/webGlRenderer.d.ts +2 -2
- package/dist/src/utils/visual/render/webGlRenderer.js +88 -0
- package/dist/src/utils/visual/shape/circle.d.ts +3 -3
- package/dist/src/utils/visual/shape/circle.js +17 -0
- package/dist/src/utils/visual/shape/ellipse.d.ts +3 -3
- package/dist/src/utils/visual/shape/ellipse.js +18 -0
- package/dist/src/utils/visual/shape/index.d.ts +6 -6
- package/dist/src/utils/visual/shape/polygon.d.ts +3 -3
- package/dist/src/utils/visual/shape/polygon.js +29 -0
- package/dist/src/utils/visual/shape/rectangle.d.ts +3 -3
- package/dist/src/utils/visual/shape/rectangle.js +18 -0
- package/dist/src/utils/visual/shape/roundedRectangle.d.ts +3 -3
- package/dist/src/utils/visual/shape/roundedRectangle.js +32 -0
- package/dist/src/utils/visual/shape/shape.d.ts +2 -2
- package/dist/src/utils/visual/shape/shape.js +5 -0
- package/dist/src/utils/visual/style/fill.js +18 -0
- package/dist/src/utils/visual/style/index.d.ts +2 -2
- package/dist/src/utils/visual/style/line.d.ts +2 -2
- package/dist/src/utils/visual/style/line.js +18 -0
- package/dist/src/utils/visual/types.d.ts +1 -1
- package/dist/src/utils/visual/vertex/container.d.ts +5 -5
- package/dist/src/utils/visual/vertex/container.js +54 -0
- package/dist/src/utils/visual/vertex/point.js +37 -0
- package/dist/src/utils/visual/vertex/vertex.d.ts +7 -7
- package/dist/src/utils/visual/vertex/vertex.js +76 -0
- package/dist/src/utils/worker.js +89 -0
- package/dist/src/utils/zip.js +161 -0
- package/dist/src/vnode/h.d.ts +1 -1
- package/dist/src/vnode/h.js +22 -0
- package/dist/src/vnode/hooks.d.ts +1 -1
- package/dist/src/vnode/htmlDomApi.js +94 -0
- package/dist/src/vnode/index.d.ts +16 -16
- package/dist/src/vnode/index.js +28 -1
- package/dist/src/vnode/init.d.ts +1 -1
- package/dist/src/vnode/init.js +104 -0
- package/dist/src/vnode/is.d.ts +1 -1
- package/dist/src/vnode/is.js +20 -0
- package/dist/src/vnode/modules/attributes.d.ts +1 -1
- package/dist/src/vnode/modules/attributes.js +21 -0
- package/dist/src/vnode/modules/class.d.ts +1 -1
- package/dist/src/vnode/modules/class.js +18 -0
- package/dist/src/vnode/modules/index.js +15 -0
- package/dist/src/vnode/modules/listeners.d.ts +1 -1
- package/dist/src/vnode/modules/listeners.js +36 -0
- package/dist/src/vnode/modules/props.d.ts +1 -1
- package/dist/src/vnode/modules/props.js +17 -0
- package/dist/src/vnode/modules/style.d.ts +1 -1
- package/dist/src/vnode/modules/style.js +52 -0
- package/dist/src/vnode/vnode.d.ts +6 -6
- package/dist/src/vnode/vnode.js +13 -0
- package/dist/third-party/jschardet/LICENSE.txt +504 -0
- package/dist/third-party/jschardet/NOTICE.txt +33 -0
- package/docs/API.md +8 -64
- package/package.json +12 -16
- package/dist/bin/generate-api-docs.d.ts +0 -1
- package/dist/build/build.es.d.ts +0 -2
- package/dist/build/build.umd.d.ts +0 -2
- package/dist/build/build.umd.node.d.ts +0 -2
- package/dist/build/build.umd.utils.d.ts +0 -2
- package/dist/chain-CTywmh_H.js +0 -1
- package/dist/color-BTvZUuf-.js +0 -1
- package/dist/enums-BAgbyGdH.js +0 -1
- package/dist/examples/clone-deep-example.d.ts +0 -1
- package/dist/examples/is-equal-example.d.ts +0 -1
- package/dist/i18n-DW21b_DJ.js +0 -1
- package/dist/plugins/vite-plugins-banner.d.ts +0 -2
- package/dist/rolldown-runtime-I3TIJKkN.js +0 -1
- package/dist/src/node/appendFile.d.ts +0 -7
- package/dist/src/node/body.d.ts +0 -9
- package/dist/src/node/color.d.ts +0 -7
- package/dist/src/node/command.d.ts +0 -8
- package/dist/src/node/ctx2req.d.ts +0 -5
- package/dist/src/node/fileInfo.d.ts +0 -7
- package/dist/src/node/fs.d.ts +0 -7
- package/dist/src/node/get.d.ts +0 -10
- package/dist/src/node/getIPAdress.d.ts +0 -1
- package/dist/src/node/index.d.ts +0 -25
- package/dist/src/node/index.js +0 -1
- package/dist/src/node/isColorSupported.d.ts +0 -2
- package/dist/src/node/paresUrl.d.ts +0 -19
- package/dist/src/node/readDir.d.ts +0 -6
- package/dist/src/node/readFile.d.ts +0 -9
- package/dist/src/node/router.d.ts +0 -42
- package/dist/src/node/send.d.ts +0 -7
- package/dist/src/node/server.d.ts +0 -18
- package/dist/src/node/startTask.d.ts +0 -2
- package/dist/src/node/stream.d.ts +0 -15
- package/dist/src/node/taskEnd.d.ts +0 -2
- package/dist/src/node/traverse.d.ts +0 -17
- package/dist/src/node/watchFile.d.ts +0 -8
- package/dist/src/node/writeFile.d.ts +0 -8
- package/dist/src/node/ws.d.ts +0 -8
- package/dist/src/utils/visual/render/utils/batch/index.test.d.ts +0 -1
- package/dist/src/utils/visual/render/utils/index.test.d.ts +0 -1
- package/dist/test/binary.test.d.ts +0 -1
- package/dist/test/bridge.test.d.ts +0 -1
- package/dist/test/budget.test.d.ts +0 -1
- package/dist/test/canvas.test.d.ts +0 -1
- package/dist/test/clearBr.test.d.ts +0 -1
- package/dist/test/cloneDeep.test.d.ts +0 -1
- package/dist/test/color.test.d.ts +0 -1
- package/dist/test/command.test.d.ts +0 -1
- package/dist/test/conversation.test.d.ts +0 -1
- package/dist/test/diff.test.d.ts +0 -1
- package/dist/test/encodeUrl.test.d.ts +0 -1
- package/dist/test/escapeHtml.test.d.ts +0 -1
- package/dist/test/formatBytes.test.d.ts +0 -1
- package/dist/test/is-equal.test.d.ts +0 -1
- package/dist/test/mimeType.test.d.ts +0 -1
- package/dist/test/package-exports.test.d.ts +0 -1
- package/dist/test/scroll.test.d.ts +0 -1
- package/dist/test/server.test.d.ts +0 -1
- package/dist/test/status.test.d.ts +0 -1
- package/dist/test/stream.test.d.ts +0 -1
- package/dist/test/sw.test.d.ts +0 -1
- package/dist/test/totp.test.d.ts +0 -1
- package/dist/test/tween.test.d.ts +0 -1
- package/dist/test/utils/async.test.d.ts +0 -1
- package/dist/test/utils/autosize.test.d.ts +0 -1
- package/dist/test/utils/color-grade.test.d.ts +0 -1
- package/dist/test/utils/compose.test.d.ts +0 -1
- package/dist/test/utils/event.test.d.ts +0 -1
- package/dist/test/utils/file-read.test.d.ts +0 -1
- package/dist/test/utils/format.test.d.ts +0 -1
- package/dist/test/utils/i18n.test.d.ts +0 -1
- package/dist/test/utils/idb-collection.test.d.ts +0 -1
- package/dist/test/utils/idb.test.d.ts +0 -1
- package/dist/test/utils/instrumentation.test.d.ts +0 -1
- package/dist/test/utils/interp.test.d.ts +0 -1
- package/dist/test/utils/lang.test.d.ts +0 -1
- package/dist/test/utils/locale-path.test.d.ts +0 -1
- package/dist/test/utils/media-query.test.d.ts +0 -1
- package/dist/test/utils/mergeObj.test.d.ts +0 -1
- package/dist/test/utils/number-parse.test.d.ts +0 -1
- package/dist/test/utils/paginate.test.d.ts +0 -1
- package/dist/test/utils/placement.test.d.ts +0 -1
- package/dist/test/utils/prefetch.test.d.ts +0 -1
- package/dist/test/utils/query-storage.test.d.ts +0 -1
- package/dist/test/utils/queue.test.d.ts +0 -1
- package/dist/test/utils/report-config.test.d.ts +0 -1
- package/dist/test/utils/report-image.test.d.ts +0 -1
- package/dist/test/utils/secure.test.d.ts +0 -1
- package/dist/test/utils/segment.test.d.ts +0 -1
- package/dist/test/utils/signal-once.test.d.ts +0 -1
- package/dist/test/utils/single-flight.test.d.ts +0 -1
- package/dist/test/utils/speech.test.d.ts +0 -1
- package/dist/test/utils/text-boundary.test.d.ts +0 -1
- package/dist/test/utils/time.test.d.ts +0 -1
- package/dist/test/utils/timing.test.d.ts +0 -1
- package/dist/test/utils/truncate.test.d.ts +0 -1
- package/dist/test/utils/visual/filter.test.d.ts +0 -1
- package/dist/test/utils/worker-client.test.d.ts +0 -1
- package/dist/test/utils/worker-serve.test.d.ts +0 -1
- package/dist/test/utils/zip.test.d.ts +0 -1
- package/dist/test/visual/math.test.d.ts +0 -1
- package/dist/test/visual-application.test.d.ts +0 -1
- package/dist/test/visual-batch.test.d.ts +0 -1
- package/dist/test/visual-math.test.d.ts +0 -1
- package/dist/test/vnode/index.d.ts +0 -1
- package/dist/test/vnode/server.d.ts +0 -2
- package/dist/test/vnode/vnode.d.ts +0 -1
- package/dist/test/vnode.test.d.ts +0 -1
- package/dist/test/websocket.test.d.ts +0 -1
- package/dist/test/writeFile.test.d.ts +0 -1
- package/dist/umd/index.umd.cjs +0 -1
- package/dist/umd/node/node.umd.cjs +0 -1
- package/dist/umd/utils/utils.umd.cjs +0 -1
- package/dist/utils-B4FnyUzW.js +0 -1
- package/dist/vite.config.d.ts +0 -8
- package/dist/vitest.config.d.ts +0 -2
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { getOutputConverter as o, getStrConverter as d } from "./converters.js";
|
|
2
|
+
var c = 4294967296, f = [
|
|
3
|
+
1116352408,
|
|
4
|
+
1899447441,
|
|
5
|
+
3049323471,
|
|
6
|
+
3921009573,
|
|
7
|
+
961987163,
|
|
8
|
+
1508970993,
|
|
9
|
+
2453635748,
|
|
10
|
+
2870763221,
|
|
11
|
+
3624381080,
|
|
12
|
+
310598401,
|
|
13
|
+
607225278,
|
|
14
|
+
1426881987,
|
|
15
|
+
1925078388,
|
|
16
|
+
2162078206,
|
|
17
|
+
2614888103,
|
|
18
|
+
3248222580,
|
|
19
|
+
3835390401,
|
|
20
|
+
4022224774,
|
|
21
|
+
264347078,
|
|
22
|
+
604807628,
|
|
23
|
+
770255983,
|
|
24
|
+
1249150122,
|
|
25
|
+
1555081692,
|
|
26
|
+
1996064986,
|
|
27
|
+
2554220882,
|
|
28
|
+
2821834349,
|
|
29
|
+
2952996808,
|
|
30
|
+
3210313671,
|
|
31
|
+
3336571891,
|
|
32
|
+
3584528711,
|
|
33
|
+
113926993,
|
|
34
|
+
338241895,
|
|
35
|
+
666307205,
|
|
36
|
+
773529912,
|
|
37
|
+
1294757372,
|
|
38
|
+
1396182291,
|
|
39
|
+
1695183700,
|
|
40
|
+
1986661051,
|
|
41
|
+
2177026350,
|
|
42
|
+
2456956037,
|
|
43
|
+
2730485921,
|
|
44
|
+
2820302411,
|
|
45
|
+
3259730800,
|
|
46
|
+
3345764771,
|
|
47
|
+
3516065817,
|
|
48
|
+
3600352804,
|
|
49
|
+
4094571909,
|
|
50
|
+
275423344,
|
|
51
|
+
430227734,
|
|
52
|
+
506948616,
|
|
53
|
+
659060556,
|
|
54
|
+
883997877,
|
|
55
|
+
958139571,
|
|
56
|
+
1322822218,
|
|
57
|
+
1537002063,
|
|
58
|
+
1747873779,
|
|
59
|
+
1955562222,
|
|
60
|
+
2024104815,
|
|
61
|
+
2227730452,
|
|
62
|
+
2361852424,
|
|
63
|
+
2428436474,
|
|
64
|
+
2756734187,
|
|
65
|
+
3204031479,
|
|
66
|
+
3329325298
|
|
67
|
+
], m = [
|
|
68
|
+
3238371032,
|
|
69
|
+
914150663,
|
|
70
|
+
812702999,
|
|
71
|
+
4144912697,
|
|
72
|
+
4290775857,
|
|
73
|
+
1750603025,
|
|
74
|
+
1694076839,
|
|
75
|
+
3204075428
|
|
76
|
+
], L = [
|
|
77
|
+
1779033703,
|
|
78
|
+
3144134277,
|
|
79
|
+
1013904242,
|
|
80
|
+
2773480762,
|
|
81
|
+
1359893119,
|
|
82
|
+
2600822924,
|
|
83
|
+
528734635,
|
|
84
|
+
1541459225
|
|
85
|
+
], v = "Chosen SHA variant is not supported", p = "Cannot set numRounds with MAC";
|
|
86
|
+
function w(e, t) {
|
|
87
|
+
let n, i;
|
|
88
|
+
const r = e.binLen >>> 3, s = t.binLen >>> 3, a = r << 3, u = 4 - r << 3;
|
|
89
|
+
if (r % 4 !== 0) {
|
|
90
|
+
for (n = 0; n < s; n += 4)
|
|
91
|
+
i = r + n >>> 2, e.value[i] |= t.value[n >>> 2] << a, e.value.push(0), e.value[i + 1] |= t.value[n >>> 2] >>> u;
|
|
92
|
+
return (e.value.length << 2) - 4 >= s + r && e.value.pop(), {
|
|
93
|
+
value: e.value,
|
|
94
|
+
binLen: e.binLen + t.binLen
|
|
95
|
+
};
|
|
96
|
+
} else return {
|
|
97
|
+
value: e.value.concat(t.value),
|
|
98
|
+
binLen: e.binLen + t.binLen
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function h(e) {
|
|
102
|
+
const t = {
|
|
103
|
+
outputUpper: !1,
|
|
104
|
+
b64Pad: "=",
|
|
105
|
+
outputLen: -1
|
|
106
|
+
}, n = e || {}, i = "Output length must be a multiple of 8";
|
|
107
|
+
if (t.outputUpper = n.outputUpper || !1, n.b64Pad && (t.b64Pad = n.b64Pad), n.outputLen) {
|
|
108
|
+
if (n.outputLen % 8 !== 0) throw new Error(i);
|
|
109
|
+
t.outputLen = n.outputLen;
|
|
110
|
+
} else if (n.shakeLen) {
|
|
111
|
+
if (n.shakeLen % 8 !== 0) throw new Error(i);
|
|
112
|
+
t.outputLen = n.shakeLen;
|
|
113
|
+
}
|
|
114
|
+
if (typeof t.outputUpper != "boolean") throw new Error("Invalid outputUpper formatting option");
|
|
115
|
+
if (typeof t.b64Pad != "string") throw new Error("Invalid b64Pad formatting option");
|
|
116
|
+
return t;
|
|
117
|
+
}
|
|
118
|
+
function S(e, t, n, i) {
|
|
119
|
+
const r = e + " must include a value and format";
|
|
120
|
+
if (!t) {
|
|
121
|
+
if (!i) throw new Error(r);
|
|
122
|
+
return i;
|
|
123
|
+
}
|
|
124
|
+
if (typeof t.value > "u" || !t.format) throw new Error(r);
|
|
125
|
+
return d(t.format, t.encoding || "UTF8", n)(t.value);
|
|
126
|
+
}
|
|
127
|
+
var C = class {
|
|
128
|
+
shaVariant;
|
|
129
|
+
inputFormat;
|
|
130
|
+
utfType;
|
|
131
|
+
numRounds;
|
|
132
|
+
keyWithIPad;
|
|
133
|
+
keyWithOPad;
|
|
134
|
+
remainder;
|
|
135
|
+
remainderLen;
|
|
136
|
+
updateCalled;
|
|
137
|
+
processedLen;
|
|
138
|
+
macKeySet;
|
|
139
|
+
constructor(e, t, n) {
|
|
140
|
+
const i = n || {};
|
|
141
|
+
if (this.inputFormat = t, this.utfType = i.encoding || "UTF8", this.numRounds = i.numRounds || 1, isNaN(this.numRounds) || this.numRounds !== parseInt(this.numRounds, 10) || 1 > this.numRounds) throw new Error("numRounds must a integer >= 1");
|
|
142
|
+
this.shaVariant = e, this.remainder = [], this.remainderLen = 0, this.updateCalled = !1, this.processedLen = 0, this.macKeySet = !1, this.keyWithIPad = [], this.keyWithOPad = [];
|
|
143
|
+
}
|
|
144
|
+
update(e) {
|
|
145
|
+
let t, n = 0;
|
|
146
|
+
const i = this.variantBlockSize >>> 5, r = this.converterFunc(e, this.remainder, this.remainderLen), s = r.binLen, a = r.value, u = s >>> 5;
|
|
147
|
+
for (t = 0; t < u; t += i) n + this.variantBlockSize <= s && (this.intermediateState = this.roundFunc(a.slice(t, t + i), this.intermediateState), n += this.variantBlockSize);
|
|
148
|
+
return this.processedLen += n, this.remainder = a.slice(n >>> 5), this.remainderLen = s % this.variantBlockSize, this.updateCalled = !0, this;
|
|
149
|
+
}
|
|
150
|
+
getHash(e, t) {
|
|
151
|
+
let n, i, r = this.outputBinLen;
|
|
152
|
+
const s = h(t);
|
|
153
|
+
if (this.isVariableLen) {
|
|
154
|
+
if (s.outputLen === -1) throw new Error("Output length must be specified in options");
|
|
155
|
+
r = s.outputLen;
|
|
156
|
+
}
|
|
157
|
+
const a = o(e, r, this.bigEndianMod, s);
|
|
158
|
+
if (this.macKeySet && this.getMAC) return a(this.getMAC(s));
|
|
159
|
+
for (i = this.finalizeFunc(this.remainder.slice(), this.remainderLen, this.processedLen, this.stateCloneFunc(this.intermediateState), r), n = 1; n < this.numRounds; n += 1)
|
|
160
|
+
this.isVariableLen && r % 32 !== 0 && (i[i.length - 1] &= 16777215 >>> 24 - r % 32), i = this.finalizeFunc(i, r, 0, this.newStateFunc(this.shaVariant), r);
|
|
161
|
+
return a(i);
|
|
162
|
+
}
|
|
163
|
+
setHMACKey(e, t, n) {
|
|
164
|
+
if (!this.HMACSupported) throw new Error("Variant does not support HMAC");
|
|
165
|
+
if (this.updateCalled) throw new Error("Cannot set MAC key after calling update");
|
|
166
|
+
const i = d(t, (n || {}).encoding || "UTF8", this.bigEndianMod);
|
|
167
|
+
this._setHMACKey(i(e));
|
|
168
|
+
}
|
|
169
|
+
_setHMACKey(e) {
|
|
170
|
+
const t = this.variantBlockSize >>> 3, n = t / 4 - 1;
|
|
171
|
+
let i;
|
|
172
|
+
if (this.numRounds !== 1) throw new Error(p);
|
|
173
|
+
if (this.macKeySet) throw new Error("MAC key already set");
|
|
174
|
+
for (t < e.binLen / 8 && (e.value = this.finalizeFunc(e.value, e.binLen, 0, this.newStateFunc(this.shaVariant), this.outputBinLen)); e.value.length <= n; ) e.value.push(0);
|
|
175
|
+
for (i = 0; i <= n; i += 1)
|
|
176
|
+
this.keyWithIPad[i] = e.value[i] ^ 909522486, this.keyWithOPad[i] = e.value[i] ^ 1549556828;
|
|
177
|
+
this.intermediateState = this.roundFunc(this.keyWithIPad, this.intermediateState), this.processedLen = this.variantBlockSize, this.macKeySet = !0;
|
|
178
|
+
}
|
|
179
|
+
getHMAC(e, t) {
|
|
180
|
+
const n = h(t);
|
|
181
|
+
return o(e, this.outputBinLen, this.bigEndianMod, n)(this._getHMAC());
|
|
182
|
+
}
|
|
183
|
+
_getHMAC() {
|
|
184
|
+
let e;
|
|
185
|
+
if (!this.macKeySet) throw new Error("Cannot call getHMAC without first setting MAC key");
|
|
186
|
+
const t = this.finalizeFunc(this.remainder.slice(), this.remainderLen, this.processedLen, this.stateCloneFunc(this.intermediateState), this.outputBinLen);
|
|
187
|
+
return e = this.roundFunc(this.keyWithOPad, this.newStateFunc(this.shaVariant)), e = this.finalizeFunc(t, this.outputBinLen, this.variantBlockSize, e, this.outputBinLen), e;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
export {
|
|
191
|
+
L as H_full,
|
|
192
|
+
m as H_trunc,
|
|
193
|
+
f as K_sha2,
|
|
194
|
+
c as TWO_PWR_32,
|
|
195
|
+
h as getOutputOpts,
|
|
196
|
+
C as jsSHABase,
|
|
197
|
+
p as mac_rounds_error,
|
|
198
|
+
w as packedLEConcat,
|
|
199
|
+
S as parseInputOption,
|
|
200
|
+
v as sha_variant_error
|
|
201
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EncodingType, FormatType, packedValue } from
|
|
1
|
+
import type { EncodingType, FormatType, packedValue } from "./custom_types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Function that takes an input format and UTF encoding and returns the appropriate function used to convert the input.
|
|
4
4
|
*
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
var y = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
2
|
+
function R(n, h, f, r, e) {
|
|
3
|
+
let t, u, c = 0, s, o, l, i, a, w;
|
|
4
|
+
r = r || 0;
|
|
5
|
+
const p = f || [0], A = r >>> 3;
|
|
6
|
+
if (h === "UTF8")
|
|
7
|
+
for (a = e === -1 ? 3 : 0, s = 0; s < n.length; s += 1)
|
|
8
|
+
for (t = n.charCodeAt(s), u = [], 128 > t ? u.push(t) : 2048 > t ? (u.push(192 | t >>> 6), u.push(128 | t & 63)) : 55296 > t || 57344 <= t ? u.push(224 | t >>> 12, 128 | t >>> 6 & 63, 128 | t & 63) : (s += 1, t = 65536 + ((t & 1023) << 10 | n.charCodeAt(s) & 1023), u.push(240 | t >>> 18, 128 | t >>> 12 & 63, 128 | t >>> 6 & 63, 128 | t & 63)), o = 0; o < u.length; o += 1) {
|
|
9
|
+
for (i = c + A, l = i >>> 2; p.length <= l; ) p.push(0);
|
|
10
|
+
p[l] |= u[o] << 8 * (a + e * (i % 4)), c += 1;
|
|
11
|
+
}
|
|
12
|
+
else
|
|
13
|
+
for (a = e === -1 ? 2 : 0, w = h === "UTF16LE" && e !== 1 || h !== "UTF16LE" && e === 1, s = 0; s < n.length; s += 1) {
|
|
14
|
+
for (t = n.charCodeAt(s), w === !0 && (o = t & 255, t = o << 8 | t >>> 8), i = c + A, l = i >>> 2; p.length <= l; ) p.push(0);
|
|
15
|
+
p[l] |= t << 8 * (a + e * (i % 4)), c += 2;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
value: p,
|
|
19
|
+
binLen: c * 8 + r
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function B(n, h, f, r) {
|
|
23
|
+
let e, t, u, c;
|
|
24
|
+
if (n.length % 2 !== 0) throw new Error("String of HEX type must be in byte increments");
|
|
25
|
+
f = f || 0;
|
|
26
|
+
const s = h || [0], o = f >>> 3, l = r === -1 ? 3 : 0;
|
|
27
|
+
for (e = 0; e < n.length; e += 2) {
|
|
28
|
+
if (t = parseInt(n.substr(e, 2), 16), isNaN(t))
|
|
29
|
+
throw new Error("String of HEX type contains invalid characters");
|
|
30
|
+
for (c = (e >>> 1) + o, u = c >>> 2; s.length <= u; ) s.push(0);
|
|
31
|
+
s[u] |= t << 8 * (l + r * (c % 4));
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
value: s,
|
|
35
|
+
binLen: n.length * 4 + f
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function T(n, h, f, r) {
|
|
39
|
+
let e, t, u, c;
|
|
40
|
+
f = f || 0;
|
|
41
|
+
const s = h || [0], o = f >>> 3, l = r === -1 ? 3 : 0;
|
|
42
|
+
for (t = 0; t < n.length; t += 1)
|
|
43
|
+
e = n.charCodeAt(t), c = t + o, u = c >>> 2, s.length <= u && s.push(0), s[u] |= e << 8 * (l + r * (c % 4));
|
|
44
|
+
return {
|
|
45
|
+
value: s,
|
|
46
|
+
binLen: n.length * 8 + f
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function F(n, h, f, r) {
|
|
50
|
+
let e = 0, t, u, c, s, o, l, i;
|
|
51
|
+
f = f || 0;
|
|
52
|
+
const a = h || [0], w = f >>> 3, p = r === -1 ? 3 : 0, A = n.indexOf("=");
|
|
53
|
+
if (n.search(/^[a-z\d=+/]+$/i) === -1) throw new Error("Invalid character in base-64 string");
|
|
54
|
+
if (n = n.replace(/=/g, ""), A !== -1 && A < n.length) throw new Error("Invalid '=' found in base-64 string");
|
|
55
|
+
for (u = 0; u < n.length; u += 4) {
|
|
56
|
+
for (o = n.substr(u, 4), s = 0, c = 0; c < o.length; c += 1)
|
|
57
|
+
t = y.indexOf(o.charAt(c)), s |= t << 18 - 6 * c;
|
|
58
|
+
for (c = 0; c < o.length - 1; c += 1) {
|
|
59
|
+
for (i = e + w, l = i >>> 2; a.length <= l; ) a.push(0);
|
|
60
|
+
a[l] |= (s >>> 16 - c * 8 & 255) << 8 * (p + r * (i % 4)), e += 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
value: a,
|
|
65
|
+
binLen: e * 8 + f
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function U(n, h, f, r) {
|
|
69
|
+
let e, t, u;
|
|
70
|
+
f = f || 0;
|
|
71
|
+
const c = h || [0], s = f >>> 3, o = r === -1 ? 3 : 0;
|
|
72
|
+
for (e = 0; e < n.length; e += 1)
|
|
73
|
+
u = e + s, t = u >>> 2, c.length <= t && c.push(0), c[t] |= n[e] << 8 * (o + r * (u % 4));
|
|
74
|
+
return {
|
|
75
|
+
value: c,
|
|
76
|
+
binLen: n.length * 8 + f
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function O(n, h, f, r) {
|
|
80
|
+
return U(new Uint8Array(n), h, f, r);
|
|
81
|
+
}
|
|
82
|
+
function I(n, h, f) {
|
|
83
|
+
switch (h) {
|
|
84
|
+
case "UTF8":
|
|
85
|
+
case "UTF16BE":
|
|
86
|
+
case "UTF16LE":
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE");
|
|
90
|
+
}
|
|
91
|
+
switch (n) {
|
|
92
|
+
case "HEX":
|
|
93
|
+
return function(r, e, t) {
|
|
94
|
+
return B(r, e, t, f);
|
|
95
|
+
};
|
|
96
|
+
case "TEXT":
|
|
97
|
+
return function(r, e, t) {
|
|
98
|
+
return R(r, h, e, t, f);
|
|
99
|
+
};
|
|
100
|
+
case "B64":
|
|
101
|
+
return function(r, e, t) {
|
|
102
|
+
return F(r, e, t, f);
|
|
103
|
+
};
|
|
104
|
+
case "BYTES":
|
|
105
|
+
return function(r, e, t) {
|
|
106
|
+
return T(r, e, t, f);
|
|
107
|
+
};
|
|
108
|
+
case "ARRAYBUFFER":
|
|
109
|
+
return function(r, e, t) {
|
|
110
|
+
return O(r, e, t, f);
|
|
111
|
+
};
|
|
112
|
+
case "UINT8ARRAY":
|
|
113
|
+
return function(r, e, t) {
|
|
114
|
+
return U(r, e, t, f);
|
|
115
|
+
};
|
|
116
|
+
default:
|
|
117
|
+
throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function Y(n, h, f, r) {
|
|
121
|
+
const e = "0123456789abcdef";
|
|
122
|
+
let t = "", u, c;
|
|
123
|
+
const s = h / 8, o = f === -1 ? 3 : 0;
|
|
124
|
+
for (u = 0; u < s; u += 1)
|
|
125
|
+
c = n[u >>> 2] >>> 8 * (o + f * (u % 4)), t += e.charAt(c >>> 4 & 15) + e.charAt(c & 15);
|
|
126
|
+
return r.outputUpper ? t.toUpperCase() : t;
|
|
127
|
+
}
|
|
128
|
+
function v(n, h, f, r) {
|
|
129
|
+
let e = "", t, u, c, s, o;
|
|
130
|
+
const l = h / 8, i = f === -1 ? 3 : 0;
|
|
131
|
+
for (t = 0; t < l; t += 3)
|
|
132
|
+
for (s = t + 1 < l ? n[t + 1 >>> 2] : 0, o = t + 2 < l ? n[t + 2 >>> 2] : 0, c = (n[t >>> 2] >>> 8 * (i + f * (t % 4)) & 255) << 16 | (s >>> 8 * (i + f * ((t + 1) % 4)) & 255) << 8 | o >>> 8 * (i + f * ((t + 2) % 4)) & 255, u = 0; u < 4; u += 1) t * 8 + u * 6 <= h ? e += y.charAt(c >>> 6 * (3 - u) & 63) : e += r.b64Pad;
|
|
133
|
+
return e;
|
|
134
|
+
}
|
|
135
|
+
function C(n, h, f) {
|
|
136
|
+
let r = "", e, t;
|
|
137
|
+
const u = h / 8, c = f === -1 ? 3 : 0;
|
|
138
|
+
for (e = 0; e < u; e += 1)
|
|
139
|
+
t = n[e >>> 2] >>> 8 * (c + f * (e % 4)) & 255, r += String.fromCharCode(t);
|
|
140
|
+
return r;
|
|
141
|
+
}
|
|
142
|
+
function m(n, h, f) {
|
|
143
|
+
let r;
|
|
144
|
+
const e = h / 8, t = new ArrayBuffer(e), u = new Uint8Array(t), c = f === -1 ? 3 : 0;
|
|
145
|
+
for (r = 0; r < e; r += 1) u[r] = n[r >>> 2] >>> 8 * (c + f * (r % 4)) & 255;
|
|
146
|
+
return t;
|
|
147
|
+
}
|
|
148
|
+
function b(n, h, f) {
|
|
149
|
+
let r;
|
|
150
|
+
const e = h / 8, t = f === -1 ? 3 : 0, u = new Uint8Array(e);
|
|
151
|
+
for (r = 0; r < e; r += 1) u[r] = n[r >>> 2] >>> 8 * (t + f * (r % 4)) & 255;
|
|
152
|
+
return u;
|
|
153
|
+
}
|
|
154
|
+
function S(n, h, f, r) {
|
|
155
|
+
switch (n) {
|
|
156
|
+
case "HEX":
|
|
157
|
+
return function(e) {
|
|
158
|
+
return Y(e, h, f, r);
|
|
159
|
+
};
|
|
160
|
+
case "B64":
|
|
161
|
+
return function(e) {
|
|
162
|
+
return v(e, h, f, r);
|
|
163
|
+
};
|
|
164
|
+
case "BYTES":
|
|
165
|
+
return function(e) {
|
|
166
|
+
return C(e, h, f);
|
|
167
|
+
};
|
|
168
|
+
case "ARRAYBUFFER":
|
|
169
|
+
return function(e) {
|
|
170
|
+
return m(e, h, f);
|
|
171
|
+
};
|
|
172
|
+
case "UINT8ARRAY":
|
|
173
|
+
return function(e) {
|
|
174
|
+
return b(e, h, f);
|
|
175
|
+
};
|
|
176
|
+
default:
|
|
177
|
+
throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
export {
|
|
181
|
+
S as getOutputConverter,
|
|
182
|
+
I as getStrConverter,
|
|
183
|
+
m as packed2arraybuffer,
|
|
184
|
+
v as packed2b64,
|
|
185
|
+
C as packed2bytes,
|
|
186
|
+
Y as packed2hex,
|
|
187
|
+
b as packed2uint8array
|
|
188
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function _(n, t) {
|
|
2
|
+
return n << t | n >>> 32 - t;
|
|
3
|
+
}
|
|
4
|
+
function u(n, t) {
|
|
5
|
+
return n >>> t | n << 32 - t;
|
|
6
|
+
}
|
|
7
|
+
function i(n, t) {
|
|
8
|
+
return n >>> t;
|
|
9
|
+
}
|
|
10
|
+
function c(n, t, r) {
|
|
11
|
+
return n ^ t ^ r;
|
|
12
|
+
}
|
|
13
|
+
function s(n, t, r) {
|
|
14
|
+
return n & t ^ ~n & r;
|
|
15
|
+
}
|
|
16
|
+
function a(n, t, r) {
|
|
17
|
+
return n & t ^ n & r ^ t & r;
|
|
18
|
+
}
|
|
19
|
+
function m(n) {
|
|
20
|
+
return u(n, 2) ^ u(n, 13) ^ u(n, 22);
|
|
21
|
+
}
|
|
22
|
+
function d(n, t) {
|
|
23
|
+
const r = (n & 65535) + (t & 65535);
|
|
24
|
+
return ((n >>> 16) + (t >>> 16) + (r >>> 16) & 65535) << 16 | r & 65535;
|
|
25
|
+
}
|
|
26
|
+
function g(n, t, r, o) {
|
|
27
|
+
const e = (n & 65535) + (t & 65535) + (r & 65535) + (o & 65535);
|
|
28
|
+
return ((n >>> 16) + (t >>> 16) + (r >>> 16) + (o >>> 16) + (e >>> 16) & 65535) << 16 | e & 65535;
|
|
29
|
+
}
|
|
30
|
+
function l(n, t, r, o, e) {
|
|
31
|
+
const f = (n & 65535) + (t & 65535) + (r & 65535) + (o & 65535) + (e & 65535);
|
|
32
|
+
return ((n >>> 16) + (t >>> 16) + (r >>> 16) + (o >>> 16) + (e >>> 16) + (f >>> 16) & 65535) << 16 | f & 65535;
|
|
33
|
+
}
|
|
34
|
+
function w(n) {
|
|
35
|
+
return u(n, 17) ^ u(n, 19) ^ i(n, 10);
|
|
36
|
+
}
|
|
37
|
+
function A(n) {
|
|
38
|
+
return u(n, 7) ^ u(n, 18) ^ i(n, 3);
|
|
39
|
+
}
|
|
40
|
+
function h(n) {
|
|
41
|
+
return u(n, 6) ^ u(n, 11) ^ u(n, 25);
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
s as ch_32,
|
|
45
|
+
A as gamma0_32,
|
|
46
|
+
w as gamma1_32,
|
|
47
|
+
a as maj_32,
|
|
48
|
+
c as parity_32,
|
|
49
|
+
_ as rotl_32,
|
|
50
|
+
d as safeAdd_32_2,
|
|
51
|
+
g as safeAdd_32_4,
|
|
52
|
+
l as safeAdd_32_5,
|
|
53
|
+
m as sigma0_32,
|
|
54
|
+
h as sigma1_32
|
|
55
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var o = class {
|
|
2
|
+
highOrder;
|
|
3
|
+
lowOrder;
|
|
4
|
+
constructor(r, e) {
|
|
5
|
+
this.highOrder = r, this.lowOrder = e;
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
function s(r, e) {
|
|
9
|
+
let h;
|
|
10
|
+
return e > 32 ? (h = 64 - e, new o(r.lowOrder << e | r.highOrder >>> h, r.highOrder << e | r.lowOrder >>> h)) : e !== 0 ? (h = 32 - e, new o(r.highOrder << e | r.lowOrder >>> h, r.lowOrder << e | r.highOrder >>> h)) : r;
|
|
11
|
+
}
|
|
12
|
+
function w(r, e) {
|
|
13
|
+
let h;
|
|
14
|
+
return e < 32 ? (h = 32 - e, new o(r.highOrder >>> e | r.lowOrder << h, r.lowOrder >>> e | r.highOrder << h)) : (h = 64 - e, new o(r.lowOrder >>> e | r.highOrder << h, r.highOrder >>> e | r.lowOrder << h));
|
|
15
|
+
}
|
|
16
|
+
function t(r, e) {
|
|
17
|
+
return new o(r.highOrder >>> e, r.lowOrder >>> e | r.highOrder << 32 - e);
|
|
18
|
+
}
|
|
19
|
+
function u(r, e, h) {
|
|
20
|
+
return new o(r.highOrder & e.highOrder ^ ~r.highOrder & h.highOrder, r.lowOrder & e.lowOrder ^ ~r.lowOrder & h.lowOrder);
|
|
21
|
+
}
|
|
22
|
+
function c(r, e, h) {
|
|
23
|
+
return new o(r.highOrder & e.highOrder ^ r.highOrder & h.highOrder ^ e.highOrder & h.highOrder, r.lowOrder & e.lowOrder ^ r.lowOrder & h.lowOrder ^ e.lowOrder & h.lowOrder);
|
|
24
|
+
}
|
|
25
|
+
function f(r) {
|
|
26
|
+
const e = w(r, 28), h = w(r, 34), O = w(r, 39);
|
|
27
|
+
return new o(e.highOrder ^ h.highOrder ^ O.highOrder, e.lowOrder ^ h.lowOrder ^ O.lowOrder);
|
|
28
|
+
}
|
|
29
|
+
function _(r, e) {
|
|
30
|
+
let h, O;
|
|
31
|
+
h = (r.lowOrder & 65535) + (e.lowOrder & 65535), O = (r.lowOrder >>> 16) + (e.lowOrder >>> 16) + (h >>> 16);
|
|
32
|
+
const d = (O & 65535) << 16 | h & 65535;
|
|
33
|
+
h = (r.highOrder & 65535) + (e.highOrder & 65535) + (O >>> 16), O = (r.highOrder >>> 16) + (e.highOrder >>> 16) + (h >>> 16);
|
|
34
|
+
const i = (O & 65535) << 16 | h & 65535;
|
|
35
|
+
return new o(i, d);
|
|
36
|
+
}
|
|
37
|
+
function m(r, e, h, O) {
|
|
38
|
+
let d, i;
|
|
39
|
+
d = (r.lowOrder & 65535) + (e.lowOrder & 65535) + (h.lowOrder & 65535) + (O.lowOrder & 65535), i = (r.lowOrder >>> 16) + (e.lowOrder >>> 16) + (h.lowOrder >>> 16) + (O.lowOrder >>> 16) + (d >>> 16);
|
|
40
|
+
const l = (i & 65535) << 16 | d & 65535;
|
|
41
|
+
d = (r.highOrder & 65535) + (e.highOrder & 65535) + (h.highOrder & 65535) + (O.highOrder & 65535) + (i >>> 16), i = (r.highOrder >>> 16) + (e.highOrder >>> 16) + (h.highOrder >>> 16) + (O.highOrder >>> 16) + (d >>> 16);
|
|
42
|
+
const g = (i & 65535) << 16 | d & 65535;
|
|
43
|
+
return new o(g, l);
|
|
44
|
+
}
|
|
45
|
+
function a(r, e, h, O, d) {
|
|
46
|
+
let i, l;
|
|
47
|
+
i = (r.lowOrder & 65535) + (e.lowOrder & 65535) + (h.lowOrder & 65535) + (O.lowOrder & 65535) + (d.lowOrder & 65535), l = (r.lowOrder >>> 16) + (e.lowOrder >>> 16) + (h.lowOrder >>> 16) + (O.lowOrder >>> 16) + (d.lowOrder >>> 16) + (i >>> 16);
|
|
48
|
+
const g = (l & 65535) << 16 | i & 65535;
|
|
49
|
+
i = (r.highOrder & 65535) + (e.highOrder & 65535) + (h.highOrder & 65535) + (O.highOrder & 65535) + (d.highOrder & 65535) + (l >>> 16), l = (r.highOrder >>> 16) + (e.highOrder >>> 16) + (h.highOrder >>> 16) + (O.highOrder >>> 16) + (d.highOrder >>> 16) + (i >>> 16);
|
|
50
|
+
const n = (l & 65535) << 16 | i & 65535;
|
|
51
|
+
return new o(n, g);
|
|
52
|
+
}
|
|
53
|
+
function p(r, e) {
|
|
54
|
+
return new o(r.highOrder ^ e.highOrder, r.lowOrder ^ e.lowOrder);
|
|
55
|
+
}
|
|
56
|
+
function A(r, e, h, O, d) {
|
|
57
|
+
return new o(r.highOrder ^ e.highOrder ^ h.highOrder ^ O.highOrder ^ d.highOrder, r.lowOrder ^ e.lowOrder ^ h.lowOrder ^ O.lowOrder ^ d.lowOrder);
|
|
58
|
+
}
|
|
59
|
+
function j(r) {
|
|
60
|
+
const e = w(r, 19), h = w(r, 61), O = t(r, 6);
|
|
61
|
+
return new o(e.highOrder ^ h.highOrder ^ O.highOrder, e.lowOrder ^ h.lowOrder ^ O.lowOrder);
|
|
62
|
+
}
|
|
63
|
+
function v(r) {
|
|
64
|
+
const e = w(r, 1), h = w(r, 8), O = t(r, 7);
|
|
65
|
+
return new o(e.highOrder ^ h.highOrder ^ O.highOrder, e.lowOrder ^ h.lowOrder ^ O.lowOrder);
|
|
66
|
+
}
|
|
67
|
+
function I(r) {
|
|
68
|
+
const e = w(r, 14), h = w(r, 18), O = w(r, 41);
|
|
69
|
+
return new o(e.highOrder ^ h.highOrder ^ O.highOrder, e.lowOrder ^ h.lowOrder ^ O.lowOrder);
|
|
70
|
+
}
|
|
71
|
+
export {
|
|
72
|
+
o as Int_64,
|
|
73
|
+
u as ch_64,
|
|
74
|
+
v as gamma0_64,
|
|
75
|
+
j as gamma1_64,
|
|
76
|
+
c as maj_64,
|
|
77
|
+
s as rotl_64,
|
|
78
|
+
_ as safeAdd_64_2,
|
|
79
|
+
m as safeAdd_64_4,
|
|
80
|
+
a as safeAdd_64_5,
|
|
81
|
+
f as sigma0_64,
|
|
82
|
+
I as sigma1_64,
|
|
83
|
+
p as xor_64_2,
|
|
84
|
+
A as xor_64_5
|
|
85
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CSHAKEOptionsEncodingType, CSHAKEOptionsNoEncodingType, EncodingType, FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, KMACOptionsEncodingType, KMACOptionsNoEncodingType, SHAKEOptionsEncodingType, SHAKEOptionsNoEncodingType } from
|
|
1
|
+
import type { CSHAKEOptionsEncodingType, CSHAKEOptionsNoEncodingType, EncodingType, FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, KMACOptionsEncodingType, KMACOptionsNoEncodingType, SHAKEOptionsEncodingType, SHAKEOptionsNoEncodingType } from "./custom_types.js";
|
|
2
2
|
type FixedLengthVariantType = 'SHA-1' | 'SHA-224' | 'SHA-256' | 'SHA-384' | 'SHA-512' | 'SHA3-224' | 'SHA3-256' | 'SHA3-384' | 'SHA3-512';
|
|
3
3
|
export default class jsSHA {
|
|
4
4
|
private readonly shaObj;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { sha_variant_error as H } from "./common.js";
|
|
2
|
+
import h from "./sha1.js";
|
|
3
|
+
import S from "./sha256.js";
|
|
4
|
+
import j from "./sha512.js";
|
|
5
|
+
import f from "./sha3.js";
|
|
6
|
+
var o = class {
|
|
7
|
+
shaObj;
|
|
8
|
+
constructor(s, e, A) {
|
|
9
|
+
if (s === "SHA-1") this.shaObj = new h(s, e, A);
|
|
10
|
+
else if (s === "SHA-224" || s === "SHA-256") this.shaObj = new S(s, e, A);
|
|
11
|
+
else if (s === "SHA-384" || s === "SHA-512") this.shaObj = new j(s, e, A);
|
|
12
|
+
else if (s === "SHA3-224" || s === "SHA3-256" || s === "SHA3-384" || s === "SHA3-512" || s === "SHAKE128" || s === "SHAKE256" || s === "CSHAKE128" || s === "CSHAKE256" || s === "KMAC128" || s === "KMAC256") this.shaObj = new f(s, e, A);
|
|
13
|
+
else throw new Error(H);
|
|
14
|
+
}
|
|
15
|
+
update(s) {
|
|
16
|
+
return this.shaObj.update(s), this;
|
|
17
|
+
}
|
|
18
|
+
getHash(s, e) {
|
|
19
|
+
return this.shaObj.getHash(s, e);
|
|
20
|
+
}
|
|
21
|
+
setHMACKey(s, e, A) {
|
|
22
|
+
this.shaObj.setHMACKey(s, e, A);
|
|
23
|
+
}
|
|
24
|
+
getHMAC(s, e) {
|
|
25
|
+
return this.shaObj.getHMAC(s, e);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
o as default
|
|
30
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsSHABase } from
|
|
2
|
-
import type { FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, packedValue } from
|
|
1
|
+
import { jsSHABase } from "./common.js";
|
|
2
|
+
import type { FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, packedValue } from "./custom_types.js";
|
|
3
3
|
export default class jsSHA extends jsSHABase<number[], 'SHA-1'> {
|
|
4
4
|
intermediateState: number[];
|
|
5
5
|
variantBlockSize: number;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getStrConverter as d } from "./converters.js";
|
|
2
|
+
import { TWO_PWR_32 as A, jsSHABase as g, parseInputOption as F, sha_variant_error as M } from "./common.js";
|
|
3
|
+
import { ch_32 as C, maj_32 as b, parity_32 as p, rotl_32 as c, safeAdd_32_2 as l, safeAdd_32_5 as f } from "./primitives_32.js";
|
|
4
|
+
function S(s) {
|
|
5
|
+
return [
|
|
6
|
+
1732584193,
|
|
7
|
+
4023233417,
|
|
8
|
+
2562383102,
|
|
9
|
+
271733878,
|
|
10
|
+
3285377520
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
function _(s, t) {
|
|
14
|
+
let o, n, i, u, r, h, e;
|
|
15
|
+
const a = [];
|
|
16
|
+
for (o = t[0], n = t[1], i = t[2], u = t[3], r = t[4], e = 0; e < 80; e += 1)
|
|
17
|
+
e < 16 ? a[e] = s[e] : a[e] = c(a[e - 3] ^ a[e - 8] ^ a[e - 14] ^ a[e - 16], 1), e < 20 ? h = f(c(o, 5), C(n, i, u), r, 1518500249, a[e]) : e < 40 ? h = f(c(o, 5), p(n, i, u), r, 1859775393, a[e]) : e < 60 ? h = f(c(o, 5), b(n, i, u), r, 2400959708, a[e]) : h = f(c(o, 5), p(n, i, u), r, 3395469782, a[e]), r = u, u = i, i = c(n, 30), n = o, o = h;
|
|
18
|
+
return t[0] = l(o, t[0]), t[1] = l(n, t[1]), t[2] = l(i, t[2]), t[3] = l(u, t[3]), t[4] = l(r, t[4]), t;
|
|
19
|
+
}
|
|
20
|
+
function v(s, t, o, n) {
|
|
21
|
+
let i;
|
|
22
|
+
const u = (t + 65 >>> 9 << 4) + 15, r = t + o;
|
|
23
|
+
for (; s.length <= u; ) s.push(0);
|
|
24
|
+
for (s[t >>> 5] |= 128 << 24 - t % 32, s[u] = r & 4294967295, s[u - 1] = r / A | 0, i = 0; i < s.length; i += 16) n = _(s.slice(i, i + 16), n);
|
|
25
|
+
return n;
|
|
26
|
+
}
|
|
27
|
+
var E = class extends g {
|
|
28
|
+
intermediateState;
|
|
29
|
+
variantBlockSize;
|
|
30
|
+
bigEndianMod;
|
|
31
|
+
outputBinLen;
|
|
32
|
+
isVariableLen;
|
|
33
|
+
HMACSupported;
|
|
34
|
+
converterFunc;
|
|
35
|
+
roundFunc;
|
|
36
|
+
finalizeFunc;
|
|
37
|
+
stateCloneFunc;
|
|
38
|
+
newStateFunc;
|
|
39
|
+
getMAC;
|
|
40
|
+
constructor(s, t, o) {
|
|
41
|
+
if (s !== "SHA-1") throw new Error(M);
|
|
42
|
+
super(s, t, o);
|
|
43
|
+
const n = o || {};
|
|
44
|
+
this.HMACSupported = !0, this.getMAC = this._getHMAC, this.bigEndianMod = -1, this.converterFunc = d(this.inputFormat, this.utfType, this.bigEndianMod), this.roundFunc = _, this.stateCloneFunc = function(i) {
|
|
45
|
+
return i.slice();
|
|
46
|
+
}, this.newStateFunc = S, this.finalizeFunc = v, this.intermediateState = S(s), this.variantBlockSize = 512, this.outputBinLen = 160, this.isVariableLen = !1, n.hmacKey && this._setHMACKey(F("hmacKey", n.hmacKey, this.bigEndianMod));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
E as default
|
|
51
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsSHABase } from
|
|
2
|
-
import type { FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, packedValue } from
|
|
1
|
+
import { jsSHABase } from "./common.js";
|
|
2
|
+
import type { FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, packedValue } from "./custom_types.js";
|
|
3
3
|
type VariantType = 'SHA-224' | 'SHA-256';
|
|
4
4
|
export default class jsSHA extends jsSHABase<number[], VariantType> {
|
|
5
5
|
intermediateState: number[];
|