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,56 @@
|
|
|
1
|
+
import { getStrConverter as p } from "./converters.js";
|
|
2
|
+
import { H_full as d, H_trunc as F, K_sha2 as m, TWO_PWR_32 as M, jsSHABase as C, parseInputOption as b, sha_variant_error as w } from "./common.js";
|
|
3
|
+
import { ch_32 as y, gamma0_32 as z, gamma1_32 as E, maj_32 as K, safeAdd_32_2 as r, safeAdd_32_4 as T, safeAdd_32_5 as V, sigma0_32 as j, sigma1_32 as v } from "./primitives_32.js";
|
|
4
|
+
function A(i) {
|
|
5
|
+
let t;
|
|
6
|
+
return i === "SHA-224" ? t = F.slice() : t = d.slice(), t;
|
|
7
|
+
}
|
|
8
|
+
function g(i, t) {
|
|
9
|
+
let u, e, c, n, o, a, l, h, _, S, s;
|
|
10
|
+
const f = [];
|
|
11
|
+
for (u = t[0], e = t[1], c = t[2], n = t[3], o = t[4], a = t[5], l = t[6], h = t[7], s = 0; s < 64; s += 1)
|
|
12
|
+
s < 16 ? f[s] = i[s] : f[s] = T(E(f[s - 2]), f[s - 7], z(f[s - 15]), f[s - 16]), _ = V(h, v(o), y(o, a, l), m[s], f[s]), S = r(j(u), K(u, e, c)), h = l, l = a, a = o, o = r(n, _), n = c, c = e, e = u, u = r(_, S);
|
|
13
|
+
return t[0] = r(u, t[0]), t[1] = r(e, t[1]), t[2] = r(c, t[2]), t[3] = r(n, t[3]), t[4] = r(o, t[4]), t[5] = r(a, t[5]), t[6] = r(l, t[6]), t[7] = r(h, t[7]), t;
|
|
14
|
+
}
|
|
15
|
+
function O(i, t, u, e, c) {
|
|
16
|
+
let n, o;
|
|
17
|
+
const a = (t + 65 >>> 9 << 4) + 15, l = 16, h = t + u;
|
|
18
|
+
for (; i.length <= a; ) i.push(0);
|
|
19
|
+
for (i[t >>> 5] |= 128 << 24 - t % 32, i[a] = h & 4294967295, i[a - 1] = h / M | 0, n = 0; n < i.length; n += l) e = g(i.slice(n, n + l), e);
|
|
20
|
+
return c === "SHA-224" ? o = [
|
|
21
|
+
e[0],
|
|
22
|
+
e[1],
|
|
23
|
+
e[2],
|
|
24
|
+
e[3],
|
|
25
|
+
e[4],
|
|
26
|
+
e[5],
|
|
27
|
+
e[6]
|
|
28
|
+
] : o = e, o;
|
|
29
|
+
}
|
|
30
|
+
var B = class extends C {
|
|
31
|
+
intermediateState;
|
|
32
|
+
variantBlockSize;
|
|
33
|
+
bigEndianMod;
|
|
34
|
+
outputBinLen;
|
|
35
|
+
isVariableLen;
|
|
36
|
+
HMACSupported;
|
|
37
|
+
converterFunc;
|
|
38
|
+
roundFunc;
|
|
39
|
+
finalizeFunc;
|
|
40
|
+
stateCloneFunc;
|
|
41
|
+
newStateFunc;
|
|
42
|
+
getMAC;
|
|
43
|
+
constructor(i, t, u) {
|
|
44
|
+
if (!(i === "SHA-224" || i === "SHA-256")) throw new Error(w);
|
|
45
|
+
super(i, t, u);
|
|
46
|
+
const e = u || {};
|
|
47
|
+
this.getMAC = this._getHMAC, this.HMACSupported = !0, this.bigEndianMod = -1, this.converterFunc = p(this.inputFormat, this.utfType, this.bigEndianMod), this.roundFunc = g, this.stateCloneFunc = function(c) {
|
|
48
|
+
return c.slice();
|
|
49
|
+
}, this.newStateFunc = A, this.finalizeFunc = function(c, n, o, a) {
|
|
50
|
+
return O(c, n, o, a, i);
|
|
51
|
+
}, this.intermediateState = A(i), this.variantBlockSize = 512, this.outputBinLen = i === "SHA-224" ? 224 : 256, this.isVariableLen = !1, e.hmacKey && this._setHMACKey(b("hmacKey", e.hmacKey, this.bigEndianMod));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
B as default
|
|
56
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsSHABase } from
|
|
2
|
-
import type { CSHAKEOptionsEncodingType, CSHAKEOptionsNoEncodingType, FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, KMACOptionsEncodingType, KMACOptionsNoEncodingType, SHAKEOptionsEncodingType, SHAKEOptionsNoEncodingType, packedValue } from
|
|
3
|
-
import { Int_64 } from
|
|
1
|
+
import { jsSHABase } from "./common.js";
|
|
2
|
+
import type { CSHAKEOptionsEncodingType, CSHAKEOptionsNoEncodingType, FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, KMACOptionsEncodingType, KMACOptionsNoEncodingType, SHAKEOptionsEncodingType, SHAKEOptionsNoEncodingType, packedValue } from "./custom_types.js";
|
|
3
|
+
import { Int_64 } from "./primitives_64.js";
|
|
4
4
|
type FixedLengthVariantType = 'SHA3-224' | 'SHA3-256' | 'SHA3-384' | 'SHA3-512' | 'SHAKE128' | 'SHAKE256';
|
|
5
5
|
type VariantType = FixedLengthVariantType | 'SHAKE128' | 'SHAKE256' | 'CSHAKE128' | 'CSHAKE256' | 'KMAC128' | 'KMAC256';
|
|
6
6
|
export default class jsSHA extends jsSHABase<Int_64[][], VariantType> {
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { getStrConverter as g } from "./converters.js";
|
|
2
|
+
import { TWO_PWR_32 as M, jsSHABase as b, mac_rounds_error as z, packedLEConcat as A, parseInputOption as S, sha_variant_error as L } from "./common.js";
|
|
3
|
+
import { Int_64 as r, rotl_64 as v, xor_64_2 as f, xor_64_5 as K } from "./primitives_64.js";
|
|
4
|
+
var k = [
|
|
5
|
+
new r(0, 1),
|
|
6
|
+
new r(0, 32898),
|
|
7
|
+
new r(2147483648, 32906),
|
|
8
|
+
new r(2147483648, 2147516416),
|
|
9
|
+
new r(0, 32907),
|
|
10
|
+
new r(0, 2147483649),
|
|
11
|
+
new r(2147483648, 2147516545),
|
|
12
|
+
new r(2147483648, 32777),
|
|
13
|
+
new r(0, 138),
|
|
14
|
+
new r(0, 136),
|
|
15
|
+
new r(0, 2147516425),
|
|
16
|
+
new r(0, 2147483658),
|
|
17
|
+
new r(0, 2147516555),
|
|
18
|
+
new r(2147483648, 139),
|
|
19
|
+
new r(2147483648, 32905),
|
|
20
|
+
new r(2147483648, 32771),
|
|
21
|
+
new r(2147483648, 32770),
|
|
22
|
+
new r(2147483648, 128),
|
|
23
|
+
new r(0, 32778),
|
|
24
|
+
new r(2147483648, 2147483658),
|
|
25
|
+
new r(2147483648, 2147516545),
|
|
26
|
+
new r(2147483648, 32896),
|
|
27
|
+
new r(0, 2147483649),
|
|
28
|
+
new r(2147483648, 2147516424)
|
|
29
|
+
], B = [
|
|
30
|
+
[
|
|
31
|
+
0,
|
|
32
|
+
36,
|
|
33
|
+
3,
|
|
34
|
+
41,
|
|
35
|
+
18
|
|
36
|
+
],
|
|
37
|
+
[
|
|
38
|
+
1,
|
|
39
|
+
44,
|
|
40
|
+
10,
|
|
41
|
+
45,
|
|
42
|
+
2
|
|
43
|
+
],
|
|
44
|
+
[
|
|
45
|
+
62,
|
|
46
|
+
6,
|
|
47
|
+
43,
|
|
48
|
+
15,
|
|
49
|
+
61
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
28,
|
|
53
|
+
55,
|
|
54
|
+
25,
|
|
55
|
+
21,
|
|
56
|
+
56
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
27,
|
|
60
|
+
20,
|
|
61
|
+
39,
|
|
62
|
+
8,
|
|
63
|
+
14
|
|
64
|
+
]
|
|
65
|
+
];
|
|
66
|
+
function w(n) {
|
|
67
|
+
let t;
|
|
68
|
+
const s = [];
|
|
69
|
+
for (t = 0; t < 5; t += 1) s[t] = [
|
|
70
|
+
new r(0, 0),
|
|
71
|
+
new r(0, 0),
|
|
72
|
+
new r(0, 0),
|
|
73
|
+
new r(0, 0),
|
|
74
|
+
new r(0, 0)
|
|
75
|
+
];
|
|
76
|
+
return s;
|
|
77
|
+
}
|
|
78
|
+
function y(n) {
|
|
79
|
+
let t;
|
|
80
|
+
const s = [];
|
|
81
|
+
for (t = 0; t < 5; t += 1) s[t] = n[t].slice();
|
|
82
|
+
return s;
|
|
83
|
+
}
|
|
84
|
+
function p(n, t) {
|
|
85
|
+
let s, e, i, a;
|
|
86
|
+
const u = [], o = [];
|
|
87
|
+
if (n != null) for (e = 0; e < n.length; e += 2) t[(e >>> 1) % 5][(e >>> 1) / 5 | 0] = f(t[(e >>> 1) % 5][(e >>> 1) / 5 | 0], new r(n[e + 1], n[e]));
|
|
88
|
+
for (s = 0; s < 24; s += 1) {
|
|
89
|
+
for (a = w("SHA3-384"), e = 0; e < 5; e += 1) u[e] = K(t[e][0], t[e][1], t[e][2], t[e][3], t[e][4]);
|
|
90
|
+
for (e = 0; e < 5; e += 1) o[e] = f(u[(e + 4) % 5], v(u[(e + 1) % 5], 1));
|
|
91
|
+
for (e = 0; e < 5; e += 1) for (i = 0; i < 5; i += 1) t[e][i] = f(t[e][i], o[e]);
|
|
92
|
+
for (e = 0; e < 5; e += 1) for (i = 0; i < 5; i += 1) a[i][(2 * e + 3 * i) % 5] = v(t[e][i], B[e][i]);
|
|
93
|
+
for (e = 0; e < 5; e += 1) for (i = 0; i < 5; i += 1) t[e][i] = f(a[e][i], new r(~a[(e + 1) % 5][i].highOrder & a[(e + 2) % 5][i].highOrder, ~a[(e + 1) % 5][i].lowOrder & a[(e + 2) % 5][i].lowOrder));
|
|
94
|
+
t[0][0] = f(t[0][0], k[s]);
|
|
95
|
+
}
|
|
96
|
+
return t;
|
|
97
|
+
}
|
|
98
|
+
function E(n, t, s, e, i, a, u) {
|
|
99
|
+
let o, h = 0, l;
|
|
100
|
+
const c = [], d = i >>> 5, H = t >>> 5;
|
|
101
|
+
for (o = 0; o < H && t >= i; o += d)
|
|
102
|
+
e = p(n.slice(o, o + d), e), t -= i;
|
|
103
|
+
for (n = n.slice(o), t = t % i; n.length < d; ) n.push(0);
|
|
104
|
+
for (o = t >>> 3, n[o >> 2] ^= a << 8 * (o % 4), n[d - 1] ^= 2147483648, e = p(n, e); c.length * 32 < u && (l = e[h % 5][h / 5 | 0], c.push(l.lowOrder), !(c.length * 32 >= u)); )
|
|
105
|
+
c.push(l.highOrder), h += 1, h * 64 % i === 0 && (p(null, e), h = 0);
|
|
106
|
+
return c;
|
|
107
|
+
}
|
|
108
|
+
function m(n) {
|
|
109
|
+
let t, s, e = 0;
|
|
110
|
+
const i = [0, 0], a = [n & 4294967295, n / M & 2097151];
|
|
111
|
+
for (t = 6; t >= 0; t--)
|
|
112
|
+
s = a[t >> 2] >>> 8 * t & 255, (s !== 0 || e !== 0) && (i[e + 1 >> 2] |= s << (e + 1) * 8, e += 1);
|
|
113
|
+
return e = e !== 0 ? e : 1, i[0] |= e, {
|
|
114
|
+
value: e + 1 > 4 ? i : [i[0]],
|
|
115
|
+
binLen: 8 + e * 8
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
function O(n) {
|
|
119
|
+
let t, s, e = 0;
|
|
120
|
+
const i = [0, 0], a = [n & 4294967295, n / M & 2097151];
|
|
121
|
+
for (t = 6; t >= 0; t--)
|
|
122
|
+
s = a[t >> 2] >>> 8 * t & 255, (s !== 0 || e !== 0) && (i[e >> 2] |= s << e * 8, e += 1);
|
|
123
|
+
return e = e !== 0 ? e : 1, i[e >> 2] |= e << e * 8, {
|
|
124
|
+
value: e + 1 > 4 ? i : [i[0]],
|
|
125
|
+
binLen: 8 + e * 8
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function C(n) {
|
|
129
|
+
return A(m(n.binLen), n);
|
|
130
|
+
}
|
|
131
|
+
function _(n, t) {
|
|
132
|
+
let s = m(t), e;
|
|
133
|
+
s = A(s, n);
|
|
134
|
+
const i = t >>> 2, a = (i - s.value.length % i) % i;
|
|
135
|
+
for (e = 0; e < a; e++) s.value.push(0);
|
|
136
|
+
return s.value;
|
|
137
|
+
}
|
|
138
|
+
function F(n) {
|
|
139
|
+
const t = n || {};
|
|
140
|
+
return {
|
|
141
|
+
funcName: S("funcName", t.funcName, 1, {
|
|
142
|
+
value: [],
|
|
143
|
+
binLen: 0
|
|
144
|
+
}),
|
|
145
|
+
customization: S("Customization", t.customization, 1, {
|
|
146
|
+
value: [],
|
|
147
|
+
binLen: 0
|
|
148
|
+
})
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
function V(n) {
|
|
152
|
+
const t = n || {};
|
|
153
|
+
return {
|
|
154
|
+
kmacKey: S("kmacKey", t.kmacKey, 1),
|
|
155
|
+
funcName: {
|
|
156
|
+
value: [1128353099],
|
|
157
|
+
binLen: 32
|
|
158
|
+
},
|
|
159
|
+
customization: S("Customization", t.customization, 1, {
|
|
160
|
+
value: [],
|
|
161
|
+
binLen: 0
|
|
162
|
+
})
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
var R = class extends b {
|
|
166
|
+
intermediateState;
|
|
167
|
+
variantBlockSize;
|
|
168
|
+
bigEndianMod;
|
|
169
|
+
outputBinLen;
|
|
170
|
+
isVariableLen;
|
|
171
|
+
HMACSupported;
|
|
172
|
+
converterFunc;
|
|
173
|
+
roundFunc;
|
|
174
|
+
finalizeFunc;
|
|
175
|
+
stateCloneFunc;
|
|
176
|
+
newStateFunc;
|
|
177
|
+
getMAC;
|
|
178
|
+
constructor(n, t, s) {
|
|
179
|
+
let e = 6, i = 0;
|
|
180
|
+
super(n, t, s);
|
|
181
|
+
const a = s || {};
|
|
182
|
+
if (this.numRounds !== 1) {
|
|
183
|
+
if (a.kmacKey || a.hmacKey) throw new Error(z);
|
|
184
|
+
if (this.shaVariant === "CSHAKE128" || this.shaVariant === "CSHAKE256") throw new Error("Cannot set numRounds for CSHAKE variants");
|
|
185
|
+
}
|
|
186
|
+
switch (this.bigEndianMod = 1, this.converterFunc = g(this.inputFormat, this.utfType, this.bigEndianMod), this.roundFunc = p, this.stateCloneFunc = y, this.newStateFunc = w, this.intermediateState = w(n), this.isVariableLen = !1, n) {
|
|
187
|
+
case "SHA3-224":
|
|
188
|
+
this.variantBlockSize = i = 1152, this.outputBinLen = 224, this.HMACSupported = !0, this.getMAC = this._getHMAC;
|
|
189
|
+
break;
|
|
190
|
+
case "SHA3-256":
|
|
191
|
+
this.variantBlockSize = i = 1088, this.outputBinLen = 256, this.HMACSupported = !0, this.getMAC = this._getHMAC;
|
|
192
|
+
break;
|
|
193
|
+
case "SHA3-384":
|
|
194
|
+
this.variantBlockSize = i = 832, this.outputBinLen = 384, this.HMACSupported = !0, this.getMAC = this._getHMAC;
|
|
195
|
+
break;
|
|
196
|
+
case "SHA3-512":
|
|
197
|
+
this.variantBlockSize = i = 576, this.outputBinLen = 512, this.HMACSupported = !0, this.getMAC = this._getHMAC;
|
|
198
|
+
break;
|
|
199
|
+
case "SHAKE128":
|
|
200
|
+
e = 31, this.variantBlockSize = i = 1344, this.outputBinLen = -1, this.isVariableLen = !0, this.HMACSupported = !1, this.getMAC = null;
|
|
201
|
+
break;
|
|
202
|
+
case "SHAKE256":
|
|
203
|
+
e = 31, this.variantBlockSize = i = 1088, this.outputBinLen = -1, this.isVariableLen = !0, this.HMACSupported = !1, this.getMAC = null;
|
|
204
|
+
break;
|
|
205
|
+
case "KMAC128":
|
|
206
|
+
e = 4, this.variantBlockSize = i = 1344, this._initializeKMAC(s), this.outputBinLen = -1, this.isVariableLen = !0, this.HMACSupported = !1, this.getMAC = this._getKMAC;
|
|
207
|
+
break;
|
|
208
|
+
case "KMAC256":
|
|
209
|
+
e = 4, this.variantBlockSize = i = 1088, this._initializeKMAC(s), this.outputBinLen = -1, this.isVariableLen = !0, this.HMACSupported = !1, this.getMAC = this._getKMAC;
|
|
210
|
+
break;
|
|
211
|
+
case "CSHAKE128":
|
|
212
|
+
this.variantBlockSize = i = 1344, e = this._initializeCSHAKE(s), this.outputBinLen = -1, this.isVariableLen = !0, this.HMACSupported = !1, this.getMAC = null;
|
|
213
|
+
break;
|
|
214
|
+
case "CSHAKE256":
|
|
215
|
+
this.variantBlockSize = i = 1088, e = this._initializeCSHAKE(s), this.outputBinLen = -1, this.isVariableLen = !0, this.HMACSupported = !1, this.getMAC = null;
|
|
216
|
+
break;
|
|
217
|
+
default:
|
|
218
|
+
throw new Error(L);
|
|
219
|
+
}
|
|
220
|
+
this.finalizeFunc = function(u, o, h, l, c) {
|
|
221
|
+
return E(u, o, h, l, i, e, c);
|
|
222
|
+
}, a.hmacKey && this._setHMACKey(S("hmacKey", a.hmacKey, this.bigEndianMod));
|
|
223
|
+
}
|
|
224
|
+
_initializeCSHAKE(n, t) {
|
|
225
|
+
const s = F(n || {});
|
|
226
|
+
t && (s.funcName = t);
|
|
227
|
+
const e = A(C(s.funcName), C(s.customization));
|
|
228
|
+
if (s.customization.binLen !== 0 || s.funcName.binLen !== 0) {
|
|
229
|
+
const i = _(e, this.variantBlockSize >>> 3);
|
|
230
|
+
for (let a = 0; a < i.length; a += this.variantBlockSize >>> 5)
|
|
231
|
+
this.intermediateState = this.roundFunc(i.slice(a, a + (this.variantBlockSize >>> 5)), this.intermediateState), this.processedLen += this.variantBlockSize;
|
|
232
|
+
return 4;
|
|
233
|
+
} else return 31;
|
|
234
|
+
}
|
|
235
|
+
_initializeKMAC(n) {
|
|
236
|
+
const t = V(n || {});
|
|
237
|
+
this._initializeCSHAKE(n, t.funcName);
|
|
238
|
+
const s = _(C(t.kmacKey), this.variantBlockSize >>> 3);
|
|
239
|
+
for (let e = 0; e < s.length; e += this.variantBlockSize >>> 5)
|
|
240
|
+
this.intermediateState = this.roundFunc(s.slice(e, e + (this.variantBlockSize >>> 5)), this.intermediateState), this.processedLen += this.variantBlockSize;
|
|
241
|
+
this.macKeySet = !0;
|
|
242
|
+
}
|
|
243
|
+
_getKMAC(n) {
|
|
244
|
+
const t = A({
|
|
245
|
+
value: this.remainder.slice(),
|
|
246
|
+
binLen: this.remainderLen
|
|
247
|
+
}, O(n.outputLen));
|
|
248
|
+
return this.finalizeFunc(t.value, t.binLen, this.processedLen, this.stateCloneFunc(this.intermediateState), n.outputLen);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
export {
|
|
252
|
+
R as default
|
|
253
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsSHABase } from
|
|
2
|
-
import type { FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, packedValue } from
|
|
3
|
-
import { Int_64 } from
|
|
1
|
+
import { jsSHABase } from "./common.js";
|
|
2
|
+
import type { FixedLengthOptionsEncodingType, FixedLengthOptionsNoEncodingType, FormatNoTextType, packedValue } from "./custom_types.js";
|
|
3
|
+
import { Int_64 } from "./primitives_64.js";
|
|
4
4
|
type VariantType = 'SHA-384' | 'SHA-512';
|
|
5
5
|
export default class jsSHA extends jsSHABase<Int_64[], VariantType> {
|
|
6
6
|
intermediateState: Int_64[];
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { getStrConverter as m } from "./converters.js";
|
|
2
|
+
import { H_full as c, H_trunc as g, K_sha2 as n, TWO_PWR_32 as M, jsSHABase as C, parseInputOption as b, sha_variant_error as y } from "./common.js";
|
|
3
|
+
import { Int_64 as e, ch_64 as K, gamma0_64 as z, gamma1_64 as E, maj_64 as v, safeAdd_64_2 as u, safeAdd_64_4 as T, safeAdd_64_5 as j, sigma0_64 as I, sigma1_64 as V } from "./primitives_64.js";
|
|
4
|
+
var W = [
|
|
5
|
+
new e(n[0], 3609767458),
|
|
6
|
+
new e(n[1], 602891725),
|
|
7
|
+
new e(n[2], 3964484399),
|
|
8
|
+
new e(n[3], 2173295548),
|
|
9
|
+
new e(n[4], 4081628472),
|
|
10
|
+
new e(n[5], 3053834265),
|
|
11
|
+
new e(n[6], 2937671579),
|
|
12
|
+
new e(n[7], 3664609560),
|
|
13
|
+
new e(n[8], 2734883394),
|
|
14
|
+
new e(n[9], 1164996542),
|
|
15
|
+
new e(n[10], 1323610764),
|
|
16
|
+
new e(n[11], 3590304994),
|
|
17
|
+
new e(n[12], 4068182383),
|
|
18
|
+
new e(n[13], 991336113),
|
|
19
|
+
new e(n[14], 633803317),
|
|
20
|
+
new e(n[15], 3479774868),
|
|
21
|
+
new e(n[16], 2666613458),
|
|
22
|
+
new e(n[17], 944711139),
|
|
23
|
+
new e(n[18], 2341262773),
|
|
24
|
+
new e(n[19], 2007800933),
|
|
25
|
+
new e(n[20], 1495990901),
|
|
26
|
+
new e(n[21], 1856431235),
|
|
27
|
+
new e(n[22], 3175218132),
|
|
28
|
+
new e(n[23], 2198950837),
|
|
29
|
+
new e(n[24], 3999719339),
|
|
30
|
+
new e(n[25], 766784016),
|
|
31
|
+
new e(n[26], 2566594879),
|
|
32
|
+
new e(n[27], 3203337956),
|
|
33
|
+
new e(n[28], 1034457026),
|
|
34
|
+
new e(n[29], 2466948901),
|
|
35
|
+
new e(n[30], 3758326383),
|
|
36
|
+
new e(n[31], 168717936),
|
|
37
|
+
new e(n[32], 1188179964),
|
|
38
|
+
new e(n[33], 1546045734),
|
|
39
|
+
new e(n[34], 1522805485),
|
|
40
|
+
new e(n[35], 2643833823),
|
|
41
|
+
new e(n[36], 2343527390),
|
|
42
|
+
new e(n[37], 1014477480),
|
|
43
|
+
new e(n[38], 1206759142),
|
|
44
|
+
new e(n[39], 344077627),
|
|
45
|
+
new e(n[40], 1290863460),
|
|
46
|
+
new e(n[41], 3158454273),
|
|
47
|
+
new e(n[42], 3505952657),
|
|
48
|
+
new e(n[43], 106217008),
|
|
49
|
+
new e(n[44], 3606008344),
|
|
50
|
+
new e(n[45], 1432725776),
|
|
51
|
+
new e(n[46], 1467031594),
|
|
52
|
+
new e(n[47], 851169720),
|
|
53
|
+
new e(n[48], 3100823752),
|
|
54
|
+
new e(n[49], 1363258195),
|
|
55
|
+
new e(n[50], 3750685593),
|
|
56
|
+
new e(n[51], 3785050280),
|
|
57
|
+
new e(n[52], 3318307427),
|
|
58
|
+
new e(n[53], 3812723403),
|
|
59
|
+
new e(n[54], 2003034995),
|
|
60
|
+
new e(n[55], 3602036899),
|
|
61
|
+
new e(n[56], 1575990012),
|
|
62
|
+
new e(n[57], 1125592928),
|
|
63
|
+
new e(n[58], 2716904306),
|
|
64
|
+
new e(n[59], 442776044),
|
|
65
|
+
new e(n[60], 593698344),
|
|
66
|
+
new e(n[61], 3733110249),
|
|
67
|
+
new e(n[62], 2999351573),
|
|
68
|
+
new e(n[63], 3815920427),
|
|
69
|
+
new e(3391569614, 3928383900),
|
|
70
|
+
new e(3515267271, 566280711),
|
|
71
|
+
new e(3940187606, 3454069534),
|
|
72
|
+
new e(4118630271, 4000239992),
|
|
73
|
+
new e(116418474, 1914138554),
|
|
74
|
+
new e(174292421, 2731055270),
|
|
75
|
+
new e(289380356, 3203993006),
|
|
76
|
+
new e(460393269, 320620315),
|
|
77
|
+
new e(685471733, 587496836),
|
|
78
|
+
new e(852142971, 1086792851),
|
|
79
|
+
new e(1017036298, 365543100),
|
|
80
|
+
new e(1126000580, 2618297676),
|
|
81
|
+
new e(1288033470, 3409855158),
|
|
82
|
+
new e(1501505948, 4234509866),
|
|
83
|
+
new e(1607167915, 987167468),
|
|
84
|
+
new e(1816402316, 1246189591)
|
|
85
|
+
];
|
|
86
|
+
function p(t) {
|
|
87
|
+
return t === "SHA-384" ? [
|
|
88
|
+
new e(3418070365, g[0]),
|
|
89
|
+
new e(1654270250, g[1]),
|
|
90
|
+
new e(2438529370, g[2]),
|
|
91
|
+
new e(355462360, g[3]),
|
|
92
|
+
new e(1731405415, g[4]),
|
|
93
|
+
new e(41048885895, g[5]),
|
|
94
|
+
new e(3675008525, g[6]),
|
|
95
|
+
new e(1203062813, g[7])
|
|
96
|
+
] : [
|
|
97
|
+
new e(c[0], 4089235720),
|
|
98
|
+
new e(c[1], 2227873595),
|
|
99
|
+
new e(c[2], 4271175723),
|
|
100
|
+
new e(c[3], 1595750129),
|
|
101
|
+
new e(c[4], 2917565137),
|
|
102
|
+
new e(c[5], 725511199),
|
|
103
|
+
new e(c[6], 4215389547),
|
|
104
|
+
new e(c[7], 327033209)
|
|
105
|
+
];
|
|
106
|
+
}
|
|
107
|
+
function F(t, r) {
|
|
108
|
+
let s, w, d, h, o, l, a, O, _, A, i, S;
|
|
109
|
+
const f = [];
|
|
110
|
+
for (s = r[0], w = r[1], d = r[2], h = r[3], o = r[4], l = r[5], a = r[6], O = r[7], i = 0; i < 80; i += 1)
|
|
111
|
+
i < 16 ? (S = i * 2, f[i] = new e(t[S], t[S + 1])) : f[i] = T(E(f[i - 2]), f[i - 7], z(f[i - 15]), f[i - 16]), _ = j(O, V(o), K(o, l, a), W[i], f[i]), A = u(I(s), v(s, w, d)), O = a, a = l, l = o, o = u(h, _), h = d, d = w, w = s, s = u(_, A);
|
|
112
|
+
return r[0] = u(s, r[0]), r[1] = u(w, r[1]), r[2] = u(d, r[2]), r[3] = u(h, r[3]), r[4] = u(o, r[4]), r[5] = u(l, r[5]), r[6] = u(a, r[6]), r[7] = u(O, r[7]), r;
|
|
113
|
+
}
|
|
114
|
+
function x(t, r, s, w, d) {
|
|
115
|
+
let h, o;
|
|
116
|
+
const l = (r + 129 >>> 10 << 5) + 31, a = 32, O = r + s;
|
|
117
|
+
for (; t.length <= l; ) t.push(0);
|
|
118
|
+
for (t[r >>> 5] |= 128 << 24 - r % 32, t[l] = O & 4294967295, t[l - 1] = O / M | 0, h = 0; h < t.length; h += a) w = F(t.slice(h, h + a), w);
|
|
119
|
+
return d === "SHA-384" ? (w = w, o = [
|
|
120
|
+
w[0].highOrder,
|
|
121
|
+
w[0].lowOrder,
|
|
122
|
+
w[1].highOrder,
|
|
123
|
+
w[1].lowOrder,
|
|
124
|
+
w[2].highOrder,
|
|
125
|
+
w[2].lowOrder,
|
|
126
|
+
w[3].highOrder,
|
|
127
|
+
w[3].lowOrder,
|
|
128
|
+
w[4].highOrder,
|
|
129
|
+
w[4].lowOrder,
|
|
130
|
+
w[5].highOrder,
|
|
131
|
+
w[5].lowOrder
|
|
132
|
+
]) : o = [
|
|
133
|
+
w[0].highOrder,
|
|
134
|
+
w[0].lowOrder,
|
|
135
|
+
w[1].highOrder,
|
|
136
|
+
w[1].lowOrder,
|
|
137
|
+
w[2].highOrder,
|
|
138
|
+
w[2].lowOrder,
|
|
139
|
+
w[3].highOrder,
|
|
140
|
+
w[3].lowOrder,
|
|
141
|
+
w[4].highOrder,
|
|
142
|
+
w[4].lowOrder,
|
|
143
|
+
w[5].highOrder,
|
|
144
|
+
w[5].lowOrder,
|
|
145
|
+
w[6].highOrder,
|
|
146
|
+
w[6].lowOrder,
|
|
147
|
+
w[7].highOrder,
|
|
148
|
+
w[7].lowOrder
|
|
149
|
+
], o;
|
|
150
|
+
}
|
|
151
|
+
var N = class extends C {
|
|
152
|
+
intermediateState;
|
|
153
|
+
variantBlockSize;
|
|
154
|
+
bigEndianMod;
|
|
155
|
+
outputBinLen;
|
|
156
|
+
isVariableLen;
|
|
157
|
+
HMACSupported;
|
|
158
|
+
converterFunc;
|
|
159
|
+
roundFunc;
|
|
160
|
+
finalizeFunc;
|
|
161
|
+
stateCloneFunc;
|
|
162
|
+
newStateFunc;
|
|
163
|
+
getMAC;
|
|
164
|
+
constructor(t, r, s) {
|
|
165
|
+
if (!(t === "SHA-384" || t === "SHA-512")) throw new Error(y);
|
|
166
|
+
super(t, r, s);
|
|
167
|
+
const w = s || {};
|
|
168
|
+
this.getMAC = this._getHMAC, this.HMACSupported = !0, this.bigEndianMod = -1, this.converterFunc = m(this.inputFormat, this.utfType, this.bigEndianMod), this.roundFunc = F, this.stateCloneFunc = function(d) {
|
|
169
|
+
return d.slice();
|
|
170
|
+
}, this.newStateFunc = p, this.finalizeFunc = function(d, h, o, l) {
|
|
171
|
+
return x(d, h, o, l, t);
|
|
172
|
+
}, this.intermediateState = p(t), this.variantBlockSize = 1024, this.outputBinLen = t === "SHA-384" ? 384 : 512, this.isVariableLen = !1, w.hmacKey && this._setHMACKey(b("hmacKey", w.hmacKey, this.bigEndianMod));
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
export {
|
|
176
|
+
N as default
|
|
177
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import d from "./sha/sha.js";
|
|
2
|
+
var p = class {
|
|
3
|
+
static generate(t, o) {
|
|
4
|
+
const e = {
|
|
5
|
+
digits: 6,
|
|
6
|
+
algorithm: "SHA-1",
|
|
7
|
+
period: 30,
|
|
8
|
+
timestamp: Date.now(),
|
|
9
|
+
...o
|
|
10
|
+
}, n = Math.floor(e.timestamp / 1e3), a = this.leftpad(this.dec2hex(Math.floor(n / e.period)), 16, "0"), i = new d(e.algorithm, "HEX");
|
|
11
|
+
i.setHMACKey(this.base32tohex(t), "HEX"), i.update(a);
|
|
12
|
+
const s = i.getHMAC("HEX"), h = this.hex2dec(s.substring(s.length - 1));
|
|
13
|
+
let r = (this.hex2dec(s.slice(h * 2, h * 2 + 8)) & this.hex2dec("7fffffff")) + "";
|
|
14
|
+
const c = Math.max(r.length - e.digits, 0);
|
|
15
|
+
r = r.substring(c, c + e.digits);
|
|
16
|
+
const l = Math.ceil((e.timestamp + 1) / (e.period * 1e3)) * e.period * 1e3;
|
|
17
|
+
return {
|
|
18
|
+
otp: r,
|
|
19
|
+
expires: l
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
static hex2dec(t) {
|
|
23
|
+
return parseInt(t, 16);
|
|
24
|
+
}
|
|
25
|
+
static dec2hex(t) {
|
|
26
|
+
return (t < 15.5 ? "0" : "") + Math.round(t).toString(16);
|
|
27
|
+
}
|
|
28
|
+
static base32tohex(t) {
|
|
29
|
+
const o = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
|
30
|
+
let e = "", n = "";
|
|
31
|
+
const a = t.endsWith("=") ? t.slice(0, t.lastIndexOf("=")) : t;
|
|
32
|
+
for (let i = 0; i < a.length; i++) {
|
|
33
|
+
const s = o.indexOf(t.charAt(i).toUpperCase());
|
|
34
|
+
if (s === -1) throw new Error("Invalid base32 character in key");
|
|
35
|
+
e += this.leftpad(s.toString(2), 5, "0");
|
|
36
|
+
}
|
|
37
|
+
for (let i = 0; i + 8 <= e.length; i += 8) {
|
|
38
|
+
const s = e.slice(i, i + 8);
|
|
39
|
+
n = n + this.leftpad(parseInt(s, 2).toString(16), 2, "0");
|
|
40
|
+
}
|
|
41
|
+
return n;
|
|
42
|
+
}
|
|
43
|
+
static leftpad(t, o, e) {
|
|
44
|
+
return o + 1 >= t.length && (t = Array(o + 1 - t.length).join(e) + t), t;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
p as TOTP
|
|
49
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var i = {
|
|
2
|
+
easeIn: function(n, r, u, e) {
|
|
3
|
+
return n >= e && (n = e), u * (n /= e) * n + r;
|
|
4
|
+
},
|
|
5
|
+
easeOut: function(n, r, u, e) {
|
|
6
|
+
return n >= e && (n = e), -u * (n /= e) * (n - 2) + r;
|
|
7
|
+
}
|
|
8
|
+
}, a = {
|
|
9
|
+
easeIn: function(n, r, u, e) {
|
|
10
|
+
return n >= e && (n = e), u * (n /= e) * n * n + r;
|
|
11
|
+
},
|
|
12
|
+
easeOut: function(n, r, u, e) {
|
|
13
|
+
return n >= e && (n = e), u * ((n = n / e - 1) * n * n + 1) + r;
|
|
14
|
+
}
|
|
15
|
+
}, f = {
|
|
16
|
+
easeIn: function(n, r, u, e) {
|
|
17
|
+
return n >= e && (n = e), u * (n /= e) * n * n * n + r;
|
|
18
|
+
},
|
|
19
|
+
easeOut: function(n, r, u, e) {
|
|
20
|
+
return n >= e && (n = e), -u * ((n = n / e - 1) * n * n * n - 1) + r;
|
|
21
|
+
}
|
|
22
|
+
}, o = {
|
|
23
|
+
easeIn: function(n, r, u, e) {
|
|
24
|
+
return n >= e && (n = e), u * (n /= e) * n * n * n * n + r;
|
|
25
|
+
},
|
|
26
|
+
easeOut: function(n, r, u, e) {
|
|
27
|
+
return n >= e && (n = e), u * ((n = n / e - 1) * n * n * n * n + 1) + r;
|
|
28
|
+
}
|
|
29
|
+
}, s = {
|
|
30
|
+
easeIn: function(n, r, u, e) {
|
|
31
|
+
return n >= e && (n = e), -u * Math.cos(n / e * (Math.PI / 2)) + u + r;
|
|
32
|
+
},
|
|
33
|
+
easeOut: function(n, r, u, e) {
|
|
34
|
+
return n >= e && (n = e), u * Math.sin(n / e * (Math.PI / 2)) + r;
|
|
35
|
+
}
|
|
36
|
+
}, c = {
|
|
37
|
+
easeIn: function(n, r, u, e) {
|
|
38
|
+
return n >= e && (n = e), n === 0 ? r : u * Math.pow(2, 10 * (n / e - 1)) + r;
|
|
39
|
+
},
|
|
40
|
+
easeOut: function(n, r, u, e) {
|
|
41
|
+
return n >= e && (n = e), n === e ? r + u : u * (-Math.pow(2, -10 * n / e) + 1) + r;
|
|
42
|
+
}
|
|
43
|
+
}, I = {
|
|
44
|
+
easeIn: function(n, r, u, e) {
|
|
45
|
+
return n >= e && (n = e), -u * (Math.sqrt(1 - (n /= e) * n) - 1) + r;
|
|
46
|
+
},
|
|
47
|
+
easeOut: function(n, r, u, e) {
|
|
48
|
+
return n >= e && (n = e), u * Math.sqrt(1 - (n = n / e - 1) * n) + r;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
I as circ,
|
|
53
|
+
a as cubic,
|
|
54
|
+
c as expo,
|
|
55
|
+
i as quad,
|
|
56
|
+
f as quart,
|
|
57
|
+
o as quint,
|
|
58
|
+
s as sine
|
|
59
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Container } from
|
|
2
|
-
import { EventSystem } from
|
|
3
|
-
import type { Filter } from
|
|
4
|
-
import type { IApplicationOptions } from
|
|
1
|
+
import { Container } from "./vertex/container.js";
|
|
2
|
+
import { EventSystem } from "./event/index.js";
|
|
3
|
+
import type { Filter } from "./render/filter.js";
|
|
4
|
+
import type { IApplicationOptions } from "./types.js";
|
|
5
5
|
export declare class Application {
|
|
6
6
|
private readonly renderer;
|
|
7
7
|
readonly stage: Container;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { getRenderer as i } from "./render/index.js";
|
|
2
|
+
import { Container as n } from "./vertex/container.js";
|
|
3
|
+
import { EventSystem as a } from "./event/event.js";
|
|
4
|
+
var c = class r {
|
|
5
|
+
renderer;
|
|
6
|
+
stage;
|
|
7
|
+
view;
|
|
8
|
+
animationFrameId;
|
|
9
|
+
eventSystem;
|
|
10
|
+
constructor(e) {
|
|
11
|
+
const { view: t = document.createElement("canvas") } = e;
|
|
12
|
+
this.view = t, this.renderer = i({
|
|
13
|
+
...e,
|
|
14
|
+
view: t
|
|
15
|
+
}), this.stage = new n(), this.eventSystem = new a(this.view, this.stage);
|
|
16
|
+
}
|
|
17
|
+
static async create(e) {
|
|
18
|
+
const t = new r(e);
|
|
19
|
+
return await t.renderer.init(), t;
|
|
20
|
+
}
|
|
21
|
+
get filters() {
|
|
22
|
+
return this.renderer.filters;
|
|
23
|
+
}
|
|
24
|
+
set filters(e) {
|
|
25
|
+
this.renderer.filters = e;
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
this.renderer.render(this.stage);
|
|
29
|
+
}
|
|
30
|
+
start() {
|
|
31
|
+
const e = () => {
|
|
32
|
+
this.render(), this.animationFrameId = requestAnimationFrame(e);
|
|
33
|
+
};
|
|
34
|
+
e();
|
|
35
|
+
}
|
|
36
|
+
stop() {
|
|
37
|
+
this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = void 0);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
export {
|
|
41
|
+
c as Application
|
|
42
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var n = /* @__PURE__ */ (function(r) {
|
|
2
|
+
return r.RECTANGLE = "rectangle", r.POLYGON = "polygon", r.CIRCLE = "circle", r.ELLIPSE = "ellipse", r.ROUNDED_RECTANGLE = "rounded rectangle", r;
|
|
3
|
+
})({}), e = /* @__PURE__ */ (function(r) {
|
|
4
|
+
return r.BUTT = "butt", r.ROUND = "round", r.SQUARE = "square", r;
|
|
5
|
+
})({}), a = /* @__PURE__ */ (function(r) {
|
|
6
|
+
return r.MITER = "miter", r.BEVEL = "bevel", r.ROUND = "round", r;
|
|
7
|
+
})({}), t = /* @__PURE__ */ (function(r) {
|
|
8
|
+
return r.WEB_GL = "webgl", r.CANVAS = "canvas", r.WEB_GPU = "webgpu", r;
|
|
9
|
+
})({}), u = 65536, c = 12, o = "container", v = "graphics";
|
|
10
|
+
export {
|
|
11
|
+
c as BYTES_PER_VERTEX,
|
|
12
|
+
o as CONTAINER,
|
|
13
|
+
v as GRAPHICS,
|
|
14
|
+
e as LINE_CAP,
|
|
15
|
+
a as LINE_JOIN,
|
|
16
|
+
u as MAX_VERTEX_COUNT,
|
|
17
|
+
t as RENDERER_TYPE,
|
|
18
|
+
n as SHAPE_TYPE
|
|
19
|
+
};
|