toolcraft 0.0.749 → 0.0.751
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/composition.json +23 -3
- package/dist/composition.json +23 -3
- package/dist/human-in-loop/approvals-commands.d.ts +1 -1
- package/dist/index.d.ts +1 -262
- package/dist/index.js +1 -573
- package/dist/runtime-platform.d.ts +2 -0
- package/dist/runtime-platform.js +2 -0
- package/dist/runtime-platform.workerd.d.ts +3 -0
- package/dist/runtime-platform.workerd.js +10 -0
- package/dist/runtime.d.ts +262 -0
- package/dist/runtime.js +576 -0
- package/node_modules/@noble/hashes/LICENSE +21 -0
- package/node_modules/@noble/hashes/README.md +478 -0
- package/node_modules/@noble/hashes/_blake.d.ts +20 -0
- package/node_modules/@noble/hashes/_blake.js +59 -0
- package/node_modules/@noble/hashes/_md.d.ts +95 -0
- package/node_modules/@noble/hashes/_md.js +209 -0
- package/node_modules/@noble/hashes/_u64.d.ts +36 -0
- package/node_modules/@noble/hashes/_u64.js +77 -0
- package/node_modules/@noble/hashes/argon2.d.ts +148 -0
- package/node_modules/@noble/hashes/argon2.js +577 -0
- package/node_modules/@noble/hashes/blake1.d.ts +162 -0
- package/node_modules/@noble/hashes/blake1.js +630 -0
- package/node_modules/@noble/hashes/blake2.d.ts +203 -0
- package/node_modules/@noble/hashes/blake2.js +573 -0
- package/node_modules/@noble/hashes/blake3.d.ts +68 -0
- package/node_modules/@noble/hashes/blake3.js +310 -0
- package/node_modules/@noble/hashes/eskdf.d.ts +91 -0
- package/node_modules/@noble/hashes/eskdf.js +225 -0
- package/node_modules/@noble/hashes/hkdf.d.ts +70 -0
- package/node_modules/@noble/hashes/hkdf.js +152 -0
- package/node_modules/@noble/hashes/hmac.d.ts +50 -0
- package/node_modules/@noble/hashes/hmac.js +93 -0
- package/node_modules/@noble/hashes/index.d.ts +1 -0
- package/node_modules/@noble/hashes/index.js +34 -0
- package/node_modules/@noble/hashes/legacy.d.ts +107 -0
- package/node_modules/@noble/hashes/legacy.js +348 -0
- package/node_modules/@noble/hashes/package.json +91 -0
- package/node_modules/@noble/hashes/pbkdf2.d.ts +66 -0
- package/node_modules/@noble/hashes/pbkdf2.js +176 -0
- package/node_modules/@noble/hashes/scrypt.d.ts +98 -0
- package/node_modules/@noble/hashes/scrypt.js +304 -0
- package/node_modules/@noble/hashes/sha2.d.ts +176 -0
- package/node_modules/@noble/hashes/sha2.js +446 -0
- package/node_modules/@noble/hashes/sha3-addons.d.ts +533 -0
- package/node_modules/@noble/hashes/sha3-addons.js +973 -0
- package/node_modules/@noble/hashes/sha3.d.ts +208 -0
- package/node_modules/@noble/hashes/sha3.js +475 -0
- package/node_modules/@noble/hashes/src/_blake.ts +67 -0
- package/node_modules/@noble/hashes/src/_md.ts +227 -0
- package/node_modules/@noble/hashes/src/_u64.ts +111 -0
- package/node_modules/@noble/hashes/src/argon2.ts +693 -0
- package/node_modules/@noble/hashes/src/blake1.ts +677 -0
- package/node_modules/@noble/hashes/src/blake2.ts +648 -0
- package/node_modules/@noble/hashes/src/blake3.ts +344 -0
- package/node_modules/@noble/hashes/src/eskdf.ts +265 -0
- package/node_modules/@noble/hashes/src/hkdf.ts +161 -0
- package/node_modules/@noble/hashes/src/hmac.ts +130 -0
- package/node_modules/@noble/hashes/src/index.ts +33 -0
- package/node_modules/@noble/hashes/src/legacy.ts +361 -0
- package/node_modules/@noble/hashes/src/pbkdf2.ts +219 -0
- package/node_modules/@noble/hashes/src/scrypt.ts +375 -0
- package/node_modules/@noble/hashes/src/sha2.ts +486 -0
- package/node_modules/@noble/hashes/src/sha3-addons.ts +1157 -0
- package/node_modules/@noble/hashes/src/sha3.ts +525 -0
- package/node_modules/@noble/hashes/src/utils.ts +978 -0
- package/node_modules/@noble/hashes/src/webcrypto.ts +283 -0
- package/node_modules/@noble/hashes/utils.d.ts +560 -0
- package/node_modules/@noble/hashes/utils.js +687 -0
- package/node_modules/@noble/hashes/webcrypto.d.ts +121 -0
- package/node_modules/@noble/hashes/webcrypto.js +228 -0
- package/node_modules/@poe-code/agent-mcp-config/dist/apply.js +23 -9
- package/node_modules/@poe-code/config-mutations/README.md +2 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +4 -5
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +3 -4
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +3 -3
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +1 -1
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +2 -2
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +3 -6
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +4 -2
- package/node_modules/@poe-code/process-runner/README.md +2 -1
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.d.ts +1 -0
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.js +1 -0
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.d.ts +2 -0
- package/node_modules/@poe-code/process-runner/dist/transfer-filesystem.workerd.js +1 -0
- package/node_modules/@poe-code/process-runner/dist/types.d.ts +1 -1
- package/node_modules/@poe-code/process-runner/dist/workspace-transfer.d.ts +6 -5
- package/node_modules/@poe-code/process-runner/dist/workspace-transfer.js +67 -29
- package/node_modules/@poe-code/process-runner/package.json +13 -0
- package/node_modules/@poe-code/safe-fs/LICENSE +21 -0
- package/node_modules/@poe-code/safe-fs/PROVENANCE.json +428 -0
- package/node_modules/@poe-code/safe-fs/README.md +411 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/confinement.js +171 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.d.ts +93 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/filesystem.js +453 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/index.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/index.js +19 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/stats.d.ts +4 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/stats.js +37 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/types.d.ts +81 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/types.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/values.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/bridge/values.js +65 -0
- package/node_modules/@poe-code/safe-fs/dist/config/memory.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/config/memory.js +7 -0
- package/node_modules/@poe-code/safe-fs/dist/config/real.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/config/real.js +16 -0
- package/node_modules/@poe-code/safe-fs/dist/config/registry.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/config/registry.js +15 -0
- package/node_modules/@poe-code/safe-fs/dist/config.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/config.js +46 -0
- package/node_modules/@poe-code/safe-fs/dist/config.node.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/config.node.js +11 -0
- package/node_modules/@poe-code/safe-fs/dist/config.portable.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/config.portable.js +9 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/abort.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/abort.js +34 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/cleanup.js +9 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.d.ts +38 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/descriptor.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/errors.d.ts +53 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/errors.js +99 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.d.ts +379 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/filesystem.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/index.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/index.js +6 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/io.d.ts +12 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/io.js +321 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/object.d.ts +134 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/object.js +97 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/path.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/path.js +2 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.d.ts +21 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/portable-path.js +78 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/contracts/virtual-path.js +162 -0
- package/node_modules/@poe-code/safe-fs/dist/core.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/core.js +17 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.d.ts +10 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/capabilities.js +216 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/conditional-chmod.js +19 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.d.ts +21 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/descriptor.js +279 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.d.ts +59 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/index.js +875 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/path.js +250 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/devices/stream.js +136 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/directory-admission.js +14 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.d.ts +11 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/atomic-view.js +13 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.d.ts +186 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/index.js +3771 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.d.ts +26 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/ledger.js +96 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.d.ts +13 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/limits.js +26 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/memory/missing-target.js +144 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/comparison.js +118 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.d.ts +6 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/identity.js +29 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.d.ts +74 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/mount/index.js +1291 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.d.ts +27 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-authority.js +287 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.d.ts +45 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/object-publication/index.js +531 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.d.ts +87 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/index.js +1185 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.d.ts +42 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/overlay/memory-publication.js +558 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.d.ts +4 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/path-namespace.js +63 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.d.ts +12 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/quota/index.js +520 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.d.ts +37 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/readonly/index.js +208 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/allocation.js +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/index.d.ts +105 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/real/index.js +1259 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.d.ts +7 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/authority.js +38 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.d.ts +130 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/filesystem.js +1137 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/bytes.js +9 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/index.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-fetch.js +74 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.d.ts +4 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request-node.js +111 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.d.ts +17 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/request.js +89 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.d.ts +20 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/signature.js +76 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/transport.js +478 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.d.ts +30 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/types.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.d.ts +14 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/http/xml.js +192 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/index.js +4 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/key-order.js +11 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/manifest-admission.js +167 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.d.ts +48 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/mock.js +249 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.d.ts +13 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/namespace.js +400 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.d.ts +10 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/registry.js +73 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.d.ts +103 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/s3/transport.js +28 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/scoped.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/scoped.js +663 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-ancestry.js +115 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/staging-cleanup.js +63 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/index.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.d.ts +18 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/resource-id.js +109 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.d.ts +141 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/webdav.js +1377 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/fs/webdav/xml.js +59 -0
- package/node_modules/@poe-code/safe-fs/dist/index.d.ts +25 -0
- package/node_modules/@poe-code/safe-fs/dist/index.js +21 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/linux-x64-glibc.node +0 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.d.ts +5 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/loader.mjs +120 -0
- package/node_modules/@poe-code/safe-fs/dist/native/fs-seek/manifest.json +46 -0
- package/node_modules/@poe-code/safe-fs/dist/node/filesystem.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/node/filesystem.js +30 -0
- package/node_modules/@poe-code/safe-fs/dist/node/host.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/node/host.js +78 -0
- package/node_modules/@poe-code/safe-fs/dist/node/index.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/node/index.js +2 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek-unavailable.js +5 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/node/native-seek.js +54 -0
- package/node_modules/@poe-code/safe-fs/dist/node/stats.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/stats.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/values.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node/values.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-host.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-host.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-unavailable.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/node-unavailable.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/package.json +29 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser-path.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser.d.ts +26 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/browser.js +58 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node-path.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node-path.js +1 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node.d.ts +26 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/node.js +64 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.d.ts +9 -0
- package/node_modules/@poe-code/safe-fs/dist/platform/transport-budget.js +17 -0
- package/node_modules/@poe-code/safe-fs/dist/python/emscripten.d.ts +15 -0
- package/node_modules/@poe-code/safe-fs/dist/python/emscripten.js +357 -0
- package/node_modules/@poe-code/safe-fs/dist/python/filesystem.d.ts +51 -0
- package/node_modules/@poe-code/safe-fs/dist/python/filesystem.js +243 -0
- package/node_modules/@poe-code/safe-fs/dist/python/flags.d.ts +3 -0
- package/node_modules/@poe-code/safe-fs/dist/python/flags.js +14 -0
- package/node_modules/@poe-code/safe-fs/dist/python/index.d.ts +9 -0
- package/node_modules/@poe-code/safe-fs/dist/python/index.js +5 -0
- package/node_modules/@poe-code/safe-fs/dist/python/native.d.ts +18 -0
- package/node_modules/@poe-code/safe-fs/dist/python/native.js +446 -0
- package/node_modules/@poe-code/safe-fs/dist/python/request.d.ts +2 -0
- package/node_modules/@poe-code/safe-fs/dist/python/request.js +61 -0
- package/node_modules/@poe-code/safe-fs/dist/python/stat.d.ts +8 -0
- package/node_modules/@poe-code/safe-fs/dist/python/stat.js +34 -0
- package/node_modules/@poe-code/safe-fs/dist/runtime-core.d.ts +27 -0
- package/node_modules/@poe-code/safe-fs/dist/runtime-core.js +57 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.d.ts +16 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/atomic-filesystem.js +496 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.d.ts +23 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-control.js +39 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.d.ts +31 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-io-metrics.js +143 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.d.ts +19 -0
- package/node_modules/@poe-code/safe-fs/dist/testing/object-publication.js +209 -0
- package/node_modules/@poe-code/safe-fs/dist/xml.d.ts +1 -0
- package/node_modules/@poe-code/safe-fs/dist/xml.js +1 -0
- package/node_modules/@poe-code/safe-fs/package.json +189 -0
- package/node_modules/@poe-code/task-list/README.md +2 -0
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.d.ts +1 -1
- package/node_modules/@poe-code/task-list/dist/backends/gh-issues-client.js +11 -4
- package/node_modules/@poe-code/task-list/dist/backends/markdown-dir.js +2 -2
- package/node_modules/@poe-code/task-list/dist/backends/utils.js +5 -7
- package/node_modules/@poe-code/task-list/dist/backends/yaml-file.js +1 -1
- package/node_modules/@poe-code/task-list/dist/default-host.d.ts +2 -0
- package/node_modules/@poe-code/task-list/dist/default-host.js +2 -0
- package/node_modules/@poe-code/task-list/dist/default-host.workerd.d.ts +4 -0
- package/node_modules/@poe-code/task-list/dist/default-host.workerd.js +6 -0
- package/node_modules/@poe-code/task-list/dist/filesystem.d.ts +3 -0
- package/node_modules/@poe-code/task-list/dist/filesystem.js +32 -0
- package/node_modules/@poe-code/task-list/dist/move.js +3 -3
- package/node_modules/@poe-code/task-list/dist/open.js +2 -5
- package/node_modules/@poe-code/task-list/dist/paths.d.ts +12 -0
- package/node_modules/@poe-code/task-list/dist/paths.js +7 -0
- package/node_modules/@poe-code/task-list/dist/types.d.ts +6 -5
- package/node_modules/@poe-code/task-list/package.json +9 -0
- package/node_modules/@poe-code/terminal-text/LICENSE +21 -0
- package/node_modules/@poe-code/terminal-text/README.md +12 -0
- package/node_modules/@poe-code/terminal-text/dist/index.d.ts +2 -0
- package/node_modules/@poe-code/terminal-text/dist/index.js +20 -0
- package/node_modules/@poe-code/terminal-text/package.json +22 -0
- package/node_modules/@poe-code/xml-ast/LICENSE +21 -0
- package/node_modules/@poe-code/xml-ast/README.md +28 -0
- package/node_modules/@poe-code/xml-ast/dist/index.d.ts +47 -0
- package/node_modules/@poe-code/xml-ast/dist/index.js +635 -0
- package/node_modules/@poe-code/xml-ast/package.json +25 -0
- package/node_modules/auth-store/README.md +35 -0
- package/node_modules/auth-store/dist/index.browser.d.ts +4 -0
- package/node_modules/auth-store/dist/index.browser.js +2 -0
- package/node_modules/auth-store/dist/provider-store.d.ts +1 -1
- package/node_modules/auth-store/dist/safe-fs-secret-store.d.ts +21 -0
- package/node_modules/auth-store/dist/safe-fs-secret-store.js +119 -0
- package/node_modules/auth-store/dist/secret-store.d.ts +12 -0
- package/node_modules/auth-store/dist/secret-store.js +1 -0
- package/node_modules/auth-store/dist/transaction-lock.d.ts +2 -4
- package/node_modules/auth-store/dist/types.d.ts +2 -9
- package/node_modules/auth-store/package.json +16 -2
- package/node_modules/tiny-http-mcp-server/dist/composition.json +16 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/README.md +25 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/authorization-state.js +4 -4
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +6 -40
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.d.ts +10 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/oauth-form.js +20 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/pkce.js +4 -3
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.d.ts +14 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/register-client.js +53 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.d.ts +16 -2
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/resumable.js +29 -9
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.d.ts +12 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/revoke-token.js +23 -0
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/client/token-endpoint.js +6 -19
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/http-fetch.js +1 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.d.ts +6 -2
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.browser.js +5 -1
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.d.ts +5 -2
- package/node_modules/tiny-http-mcp-server/node_modules/mcp-oauth/dist/index.js +4 -1
- package/node_modules/tiny-http-mcp-server/package.json +4 -4
- package/node_modules/tiny-mcp-client/README.md +2 -0
- package/node_modules/tiny-mcp-client/dist/index.browser.d.ts +25 -23
- package/node_modules/tiny-mcp-client/dist/index.browser.js +116 -1
- package/node_modules/tiny-mcp-client/dist/index.d.ts +25 -23
- package/node_modules/tiny-mcp-client/dist/index.js +1034 -561
- package/node_modules/tiny-mcp-client/package.json +15 -0
- package/node_modules/tiny-stdio-mcp-server/dist/composition.json +1 -1
- package/node_modules/toolcraft-design/dist/components/table.js +6 -0
- package/node_modules/toolcraft-design/dist/escape-terminal-text.d.ts +1 -2
- package/node_modules/toolcraft-design/dist/escape-terminal-text.js +1 -20
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser/frontmatter.js +2 -1
- package/node_modules/toolcraft-design/dist/terminal-markdown/parser.js +2 -1
- package/node_modules/toolcraft-schema/dist/json-schema/utils.js +3 -0
- package/node_modules/toolcraft-schema/package.json +1 -1
- package/package.json +32 -7
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
# noble-hashes
|
|
2
|
+
|
|
3
|
+
Audited & minimal JS implementation of hash functions, MACs and KDFs.
|
|
4
|
+
|
|
5
|
+
- 🔒 [**Audited**](#security) by an independent security firm
|
|
6
|
+
- 🪶 Minimal: 2.8KB (gzipped) sha256, unused code is excluded from your builds
|
|
7
|
+
- 🏎 Fast: hand-optimized for caveats of JS engines
|
|
8
|
+
- 🔍 Reliable: chained / ACVP tests ensure correctness
|
|
9
|
+
- 🔁 No unrolled loops: makes it easier to verify and reduces source code size up to 5x
|
|
10
|
+
- 🦘 Includes SHA, RIPEMD, BLAKE, HMAC, HKDF, PBKDF, Scrypt, Argon2
|
|
11
|
+
- 🥈 Wrapper with identical API over native WebCrypto
|
|
12
|
+
|
|
13
|
+
The library's initial development was funded by [Ethereum Foundation](https://ethereum.org/).
|
|
14
|
+
|
|
15
|
+
### This library belongs to _noble_ cryptography
|
|
16
|
+
|
|
17
|
+
> **noble cryptography** — high-security, easily auditable set of contained cryptographic libraries and tools.
|
|
18
|
+
|
|
19
|
+
- Zero or minimal dependencies
|
|
20
|
+
- Highly readable TypeScript / JS code
|
|
21
|
+
- PGP-signed releases and transparent NPM builds
|
|
22
|
+
- All libraries:
|
|
23
|
+
[ciphers](https://github.com/paulmillr/noble-ciphers),
|
|
24
|
+
[curves](https://github.com/paulmillr/noble-curves),
|
|
25
|
+
[hashes](https://github.com/paulmillr/noble-hashes),
|
|
26
|
+
[post-quantum](https://github.com/paulmillr/noble-post-quantum),
|
|
27
|
+
5kb [secp256k1](https://github.com/paulmillr/noble-secp256k1) /
|
|
28
|
+
[ed25519](https://github.com/paulmillr/noble-ed25519)
|
|
29
|
+
- WASM version: [awasm-noble](https://github.com/paulmillr/awasm-noble)
|
|
30
|
+
- [Check out the homepage](https://paulmillr.com/noble/)
|
|
31
|
+
for reading resources, documentation, and apps built with noble
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
> `npm install @noble/hashes`
|
|
36
|
+
|
|
37
|
+
> `deno add jsr:@noble/hashes`
|
|
38
|
+
|
|
39
|
+
We support all major platforms and runtimes.
|
|
40
|
+
For React Native, you may need a [polyfill for getRandomValues](https://github.com/LinusU/react-native-get-random-values).
|
|
41
|
+
A standalone file [noble-hashes.js](https://github.com/paulmillr/noble-hashes/releases) is also available.
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
// import * from '@noble/hashes'; // Error: use sub-imports, to ensure small app size
|
|
45
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
46
|
+
const hash = sha256(Uint8Array.from([0xca, 0xfe, 0x01, 0x23]));
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
- [sha2: sha256, sha384, sha512](#sha2-sha256-sha384-sha512-and-others)
|
|
50
|
+
- [sha3: FIPS, SHAKE, Keccak](#sha3-fips-shake-keccak)
|
|
51
|
+
- [sha3-addons: cSHAKE, KMAC, KT128, TurboSHAKE](#sha3-addons-cshake-kmac-kt128-turboshake)
|
|
52
|
+
- [blake1, blake2, blake3](#blake1-blake2-blake3)
|
|
53
|
+
- [legacy: sha1, md5, ripemd160](#legacy-sha1-md5-ripemd160)
|
|
54
|
+
- MACs: [hmac](#hmac) | [kmac](#sha3-addons-cshake-kmac-kt128-turboshake) | [blake3 key mode](#blake1-blake2-blake3)
|
|
55
|
+
- KDFs: [hkdf](#hkdf) | [pbkdf2](#pbkdf2) | [scrypt](#scrypt) | [argon2](#argon2) | [eskdf](#eskdf)
|
|
56
|
+
- [webcrypto: friendly wrapper](#webcrypto-friendly-wrapper)
|
|
57
|
+
- [utils](#utils)
|
|
58
|
+
- [Security](#security) | [Speed](#speed) | [Contributing & testing](#contributing--testing) | [License](#license)
|
|
59
|
+
|
|
60
|
+
### Implementations
|
|
61
|
+
|
|
62
|
+
Hash functions:
|
|
63
|
+
|
|
64
|
+
- `sha256()`: receive & return `Uint8Array`
|
|
65
|
+
- `sha256.create().update(a).update(b).digest()`: support partial updates
|
|
66
|
+
- `blake3.create({ context: 'e', dkLen: 32 })`: can have options
|
|
67
|
+
- support little-endian architecture; also experimentally big-endian
|
|
68
|
+
- can hash up to 4GB per chunk, with any amount of chunks
|
|
69
|
+
|
|
70
|
+
#### sha2: sha256, sha384, sha512 and others
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import { sha224, sha256, sha384, sha512, sha512_224, sha512_256 } from '@noble/hashes/sha2.js';
|
|
74
|
+
const res = sha256(Uint8Array.from([0xbc]));
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
#### sha3: FIPS, SHAKE, Keccak
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import {
|
|
82
|
+
sha3_224, sha3_256, sha3_384, sha3_512,
|
|
83
|
+
keccak_224, keccak_256, keccak_384, keccak_512,
|
|
84
|
+
shake128, shake256,
|
|
85
|
+
} from '@noble/hashes/sha3.js';
|
|
86
|
+
const s = sha3_256(Uint8Array.from([0x10, 0x20, 0x30]));
|
|
87
|
+
const shka = shake128(Uint8Array.from([0x10]), { dkLen: 512 });
|
|
88
|
+
const shkb = shake256(Uint8Array.from([0x30]), { dkLen: 512 });
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### sha3-addons: cSHAKE, KMAC, KT128, TurboSHAKE
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import {
|
|
95
|
+
cshake128, cshake256, kt128, kt256,
|
|
96
|
+
keccakprg, kmac128, kmac256,
|
|
97
|
+
parallelhash256, tuplehash256,
|
|
98
|
+
turboshake128, turboshake256,
|
|
99
|
+
} from '@noble/hashes/sha3-addons.js';
|
|
100
|
+
const data = Uint8Array.from([0x10, 0x20, 0x30]);
|
|
101
|
+
const ec = cshake128(data, { personalization: new TextEncoder().encode('def') });
|
|
102
|
+
const et = turboshake256(data, { D: 0x05 });
|
|
103
|
+
// tuplehash(['ab', 'c']) !== tuplehash(['a', 'bc']) !== tuplehash([data])
|
|
104
|
+
const eu = tuplehash256([new TextEncoder().encode('ab'), new TextEncoder().encode('c')]);
|
|
105
|
+
// Not parallel in JS (similar to blake3 / kt128), added for compat
|
|
106
|
+
const ep = parallelhash256(data, { blockLen: 8 });
|
|
107
|
+
const ek = kmac256(Uint8Array.from([0xca]), data);
|
|
108
|
+
const ekt = kt128(data);
|
|
109
|
+
const p = keccakprg(254);
|
|
110
|
+
p.addEntropy();
|
|
111
|
+
const rand1b = p.randomBytes(32);
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
#### blake1, blake2, blake3
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import { blake224, blake256, blake384, blake512 } from '@noble/hashes/blake1.js';
|
|
118
|
+
import { blake2b, blake2s } from '@noble/hashes/blake2.js';
|
|
119
|
+
import { blake3 } from '@noble/hashes/blake3.js';
|
|
120
|
+
const ab = Uint8Array.from([0x01]);
|
|
121
|
+
blake256(ab);
|
|
122
|
+
|
|
123
|
+
// blake2 advanced usage
|
|
124
|
+
const txt = new TextEncoder();
|
|
125
|
+
blake2s(ab, { key: new Uint8Array(32) }); // blake2b keys can be 64 bytes
|
|
126
|
+
blake2s(ab, { personalization: txt.encode('pers1234') }); // 16 bytes for blake2b
|
|
127
|
+
blake2s(ab, { salt: txt.encode('salt1234') }); // 16 bytes for blake2b
|
|
128
|
+
|
|
129
|
+
// blake3 advanced usage
|
|
130
|
+
blake3(ab, { dkLen: 256 });
|
|
131
|
+
blake3(ab, { key: new Uint8Array(32) });
|
|
132
|
+
blake3(ab, { context: txt.encode('application-name') });
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### legacy: sha1, md5, ripemd160
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { md5, ripemd160, sha1 } from '@noble/hashes/legacy.js';
|
|
139
|
+
const h = sha1(Uint8Array.from([0x10, 0x20, 0x30]));
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
#### hmac
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { hmac } from '@noble/hashes/hmac.js';
|
|
146
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
147
|
+
const key = new Uint8Array(32).fill(1);
|
|
148
|
+
const msg = new Uint8Array(32).fill(2);
|
|
149
|
+
const mac1 = hmac(sha256, key, msg);
|
|
150
|
+
const mac2 = hmac.create(sha256, key).update(msg).digest();
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
#### hkdf
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
import { hkdf } from '@noble/hashes/hkdf.js';
|
|
157
|
+
import { randomBytes } from '@noble/hashes/utils.js';
|
|
158
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
159
|
+
const inputKey = randomBytes(32);
|
|
160
|
+
const salt = randomBytes(32);
|
|
161
|
+
const info = new TextEncoder().encode('application-key');
|
|
162
|
+
const hk1 = hkdf(sha256, inputKey, salt, info, 32);
|
|
163
|
+
|
|
164
|
+
// == same as
|
|
165
|
+
import { extract, expand } from '@noble/hashes/hkdf.js';
|
|
166
|
+
const prk = extract(sha256, inputKey, salt);
|
|
167
|
+
const hk2 = expand(sha256, prk, info, 32);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
#### pbkdf2
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { pbkdf2, pbkdf2Async } from '@noble/hashes/pbkdf2.js';
|
|
174
|
+
import { sha256 } from '@noble/hashes/sha2.js';
|
|
175
|
+
const pbkey1 = pbkdf2(sha256, 'password', 'salt', { c: 524288, dkLen: 32 });
|
|
176
|
+
const pbkey2 = await pbkdf2Async(sha256, 'password', 'salt', { c: 524288, dkLen: 32 });
|
|
177
|
+
const pbkey3 = await pbkdf2Async(sha256, Uint8Array.from([1, 2, 3]), Uint8Array.from([4, 5, 6]), {
|
|
178
|
+
c: 524288,
|
|
179
|
+
dkLen: 32,
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### scrypt
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { scrypt, scryptAsync } from '@noble/hashes/scrypt.js';
|
|
187
|
+
const scr1 = scrypt('password', 'salt', { N: 2 ** 16, r: 8, p: 1, dkLen: 32 });
|
|
188
|
+
const scr2 = await scryptAsync('password', 'salt', { N: 2 ** 16, r: 8, p: 1, dkLen: 32 });
|
|
189
|
+
const scr3 = await scryptAsync(Uint8Array.from([1, 2, 3]), Uint8Array.from([4, 5, 6]), {
|
|
190
|
+
N: 2 ** 17,
|
|
191
|
+
r: 8,
|
|
192
|
+
p: 1,
|
|
193
|
+
dkLen: 32,
|
|
194
|
+
onProgress(percentage) {
|
|
195
|
+
console.log('progress', percentage);
|
|
196
|
+
},
|
|
197
|
+
// maxmem: 128 * 8 * (2 ** 17 + 1 + 1), // 128 * r * (N + p + 1)
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- `N, r, p` are work factors. It is common to only adjust N, while keeping `r: 8, p: 1`.
|
|
202
|
+
See [the blog post](https://blog.filippo.io/the-scrypt-parameters/).
|
|
203
|
+
JS doesn't support parallelization, making increasing `p` meaningless.
|
|
204
|
+
- `dkLen` is the length of output bytes e.g. `32` or `64`
|
|
205
|
+
- `onProgress` can be used with async version of the function to report progress to a user.
|
|
206
|
+
- `maxmem` prevents DoS and defaults to `1GiB + 2KiB` (`2**30 + 2**11`), enough for `N: 2**20, r: 8, p: 1`. It can be adjusted using formula: `128 * r * (N + p + 1)`
|
|
207
|
+
|
|
208
|
+
On Apple M4, `N: 2**16` takes 0.1s and 64MB RAM; each increment of N doubles both,
|
|
209
|
+
up to `N: 2**24` at 27s and 16GB. Mobile phones can be 1x-4x slower.
|
|
210
|
+
|
|
211
|
+
> [!NOTE]
|
|
212
|
+
> We support N larger than `2**20` where available, however,
|
|
213
|
+
> not all JS engines support >= 2GB ArrayBuffer-s.
|
|
214
|
+
> When using such N, you'll need to manually adjust `maxmem`, using formula above.
|
|
215
|
+
> Other JS implementations don't support large N-s.
|
|
216
|
+
|
|
217
|
+
#### argon2
|
|
218
|
+
|
|
219
|
+
```ts
|
|
220
|
+
import { argon2d, argon2i, argon2id } from '@noble/hashes/argon2.js';
|
|
221
|
+
// Defaults to t=3, m=1GiB (specified in KiB), p=1, and a 1GiB maxmem limit.
|
|
222
|
+
const arg1 = argon2id('password', 'saltsalt');
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
> [!WARNING]
|
|
226
|
+
> Argon2 can't be fast in JS, because there is no fast Uint64Array.
|
|
227
|
+
> It is suggested to use [Scrypt](#scrypt) instead.
|
|
228
|
+
> Being 5x slower than native code means brute-forcing attackers have bigger advantage.
|
|
229
|
+
|
|
230
|
+
#### eskdf
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
import { eskdf } from '@noble/hashes/eskdf.js';
|
|
234
|
+
const kdf = await eskdf('example-university', 'beginning-new-example');
|
|
235
|
+
console.log(kdf.fingerprint);
|
|
236
|
+
const key = kdf.deriveChildKey('aes', 0);
|
|
237
|
+
kdf.expire();
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Experimental KDF for deriving application-specific child keys from a username + password pair,
|
|
241
|
+
built on scrypt, pbkdf2 and hkdf with fixed work factors.
|
|
242
|
+
Non-standard: prefer [scrypt](#scrypt) or [argon2](#argon2) for new designs.
|
|
243
|
+
|
|
244
|
+
#### webcrypto: friendly wrapper
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
import { sha256, sha384, sha512, hmac, hkdf, pbkdf2 } from '@noble/hashes/webcrypto.js';
|
|
248
|
+
import { randomBytes } from '@noble/hashes/utils.js';
|
|
249
|
+
const whash = await sha256(Uint8Array.from([0xca, 0xfe, 0x01, 0x23]));
|
|
250
|
+
|
|
251
|
+
const key = new Uint8Array(32).fill(1);
|
|
252
|
+
const msg = new Uint8Array(32).fill(2);
|
|
253
|
+
const wmac = await hmac(sha256, key, msg);
|
|
254
|
+
|
|
255
|
+
const inputKey = randomBytes(32);
|
|
256
|
+
const salt = randomBytes(32);
|
|
257
|
+
const info = new TextEncoder().encode('application-key');
|
|
258
|
+
const hk1 = await hkdf(sha256, inputKey, salt, info, 32);
|
|
259
|
+
|
|
260
|
+
const pbkey1 = await pbkdf2(sha256, 'password', 'salt', { c: 524288, dkLen: 32 });
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
A thin wrapper over built-in `crypto.subtle`, mirroring the noble-hashes API and validating
|
|
264
|
+
inputs, in just 30+ lines of code. Webcrypto methods are always async.
|
|
265
|
+
|
|
266
|
+
#### utils
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
import { bytesToHex as toHex, randomBytes } from '@noble/hashes/utils.js';
|
|
270
|
+
console.log(toHex(randomBytes(32)));
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
- `bytesToHex` will convert `Uint8Array` to a hex string
|
|
274
|
+
- `randomBytes(bytes)` will produce cryptographically secure random `Uint8Array` of length `bytes`
|
|
275
|
+
|
|
276
|
+
### Specs
|
|
277
|
+
|
|
278
|
+
- SHA2: [RFC 6234](https://datatracker.ietf.org/doc/html/rfc6234)
|
|
279
|
+
- SHA2-512/256: [pdf](https://eprint.iacr.org/2010/548.pdf)
|
|
280
|
+
- SHA3: [FIPS-202](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf)
|
|
281
|
+
- SHA3-addons: [NIST SP 800-185](https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf)
|
|
282
|
+
- SHA3-addons KT128 (KangarooTwelve 🦘, K12) / TurboSHAKE: [RFC 9861](https://datatracker.ietf.org/doc/rfc9861/)
|
|
283
|
+
- BLAKE1: [pdf](https://www.aumasson.jp/blake/blake.pdf)
|
|
284
|
+
- BLAKE2: [RFC 7693](https://datatracker.ietf.org/doc/html/rfc7693)
|
|
285
|
+
- BLAKE3: [site](https://blake3.io)
|
|
286
|
+
- SHA1: [RFC 3174](https://datatracker.ietf.org/doc/html/rfc3174)
|
|
287
|
+
- MD5: [RFC 1321](https://datatracker.ietf.org/doc/html/rfc1321)
|
|
288
|
+
- RIPEMD160 (ISO/IEC 10118-3)
|
|
289
|
+
- HMAC: [RFC 2104](https://datatracker.ietf.org/doc/html/rfc2104)
|
|
290
|
+
- HKDF: [RFC 5869](https://datatracker.ietf.org/doc/html/rfc5869)
|
|
291
|
+
- PBKDF2: [RFC 8018](https://datatracker.ietf.org/doc/html/rfc8018)
|
|
292
|
+
- Scrypt: [RFC 7914](https://datatracker.ietf.org/doc/html/rfc7914)
|
|
293
|
+
- Argon2: [RFC 9106](https://datatracker.ietf.org/doc/html/rfc9106)
|
|
294
|
+
|
|
295
|
+
## Security
|
|
296
|
+
|
|
297
|
+
The library has been audited:
|
|
298
|
+
|
|
299
|
+
- at version 1.0.0, in Jan 2022, independently, by [Cure53](https://cure53.de)
|
|
300
|
+
- PDFs: [website](https://cure53.de/pentest-report_hashing-libs.pdf), [in-repo](./audit/2022-01-05-cure53-audit-nbl2.pdf)
|
|
301
|
+
- Scope: everything, besides `blake3`, `sha3-addons`, `sha1` and `argon2`, which have not been audited
|
|
302
|
+
- The audit has been funded by [Ethereum Foundation](https://ethereum.org/en/) with help of [Nomic Labs](https://nomiclabs.io)
|
|
303
|
+
|
|
304
|
+
We've started regular AI-assisted self-audits in Apr 2026.
|
|
305
|
+
|
|
306
|
+
It is tested against official (ACVP / KAT) vectors, cross-library chained hashing,
|
|
307
|
+
sliding-window length sweeps and property-based tests (fast-check),
|
|
308
|
+
and is being fuzzed in CI.
|
|
309
|
+
|
|
310
|
+
If you see anything unusual: investigate and report.
|
|
311
|
+
|
|
312
|
+
### Constant-timeness
|
|
313
|
+
|
|
314
|
+
We're targetting algorithmic constant time. _JIT-compiler_ and _Garbage Collector_ make "constant time"
|
|
315
|
+
extremely hard to achieve [timing attack](https://en.wikipedia.org/wiki/Timing_attack) resistance
|
|
316
|
+
in a scripting language. Which means _any other JS library can't have
|
|
317
|
+
constant-timeness_. Even statically typed Rust, a language without GC,
|
|
318
|
+
[makes it harder to achieve constant-time](https://www.chosenplaintext.ca/open-source/rust-timing-shield/security)
|
|
319
|
+
for some cases. If your goal is absolute security, don't use any JS lib — including bindings to native ones.
|
|
320
|
+
Use low-level libraries & languages.
|
|
321
|
+
|
|
322
|
+
### Memory dumping
|
|
323
|
+
|
|
324
|
+
The library shares state buffers between hash function calls. Library-owned working buffers are
|
|
325
|
+
zeroed after use, including mutable UTF-8 copies created from password-KDF string inputs.
|
|
326
|
+
However, if an attacker can read application memory, you are doomed in any case:
|
|
327
|
+
|
|
328
|
+
- JS strings are immutable and can't be overwritten with zeros — e.g. a password passed
|
|
329
|
+
to `scrypt(password, salt)` as a string stays in memory
|
|
330
|
+
- Inputs & outputs are re-used across the application and stay in file buffers / memory anyway
|
|
331
|
+
- `await anything()` writes all internal variables (including numbers) to memory, with no
|
|
332
|
+
guarantee of when they get overwritten — plenty of time for an attacker to read them
|
|
333
|
+
|
|
334
|
+
### Supply chain security
|
|
335
|
+
|
|
336
|
+
- **Commits** are signed with PGP keys to prevent forgery. Be sure to verify the commit signatures
|
|
337
|
+
- **Releases** are made transparently through token-less GitHub CI and Trusted Publishing. Be sure to verify the [provenance logs](https://docs.npmjs.com/generating-provenance-statements) for authenticity.
|
|
338
|
+
- **Rare releasing** is practiced to minimize the need for re-audits by end-users.
|
|
339
|
+
- **Dependencies** are minimized, strictly pinned, and changes are checked with npm-diff.
|
|
340
|
+
- **Dev dependencies** are excluded from end-user installs; they’re only used for development and build steps.
|
|
341
|
+
|
|
342
|
+
For this package, there are 0 dependencies; and a few dev dependencies:
|
|
343
|
+
|
|
344
|
+
- jsbt contains helpers for building, benchmarking & testing secure JS apps. It is developed by the same author
|
|
345
|
+
- prettier, fast-check and typescript are used for code quality / test generation / ts compilation
|
|
346
|
+
|
|
347
|
+
### Randomness
|
|
348
|
+
|
|
349
|
+
We rely on the built-in
|
|
350
|
+
[`crypto.getRandomValues`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues),
|
|
351
|
+
which is considered a cryptographically secure PRNG.
|
|
352
|
+
|
|
353
|
+
Browsers have had weaknesses in the past - and could again - but implementing a userspace CSPRNG is even worse, as there’s no reliable userspace source of high-quality entropy.
|
|
354
|
+
|
|
355
|
+
### Quantum computers
|
|
356
|
+
|
|
357
|
+
Cryptographically relevant quantum computer, if built, will allow to
|
|
358
|
+
utilize Grover's algorithm to break hashes in 2^n/2 operations, instead of 2^n.
|
|
359
|
+
|
|
360
|
+
This means SHA256 should be replaced with SHA512, SHA3-256 with SHA3-512, SHAKE128 with SHAKE256 etc.
|
|
361
|
+
|
|
362
|
+
Australian ASD prohibits SHA256 and similar hashes [after 2030](https://www.cyber.gov.au/resources-business-and-government/essential-cyber-security/ism/cyber-security-guidelines/guidelines-cryptography).
|
|
363
|
+
|
|
364
|
+
## Upgrading
|
|
365
|
+
|
|
366
|
+
Supported node.js versions:
|
|
367
|
+
|
|
368
|
+
- v2: v20.19+ (ESM-only)
|
|
369
|
+
- v1: v14.21+ (ESM & CJS)
|
|
370
|
+
|
|
371
|
+
v2.0 changelog:
|
|
372
|
+
|
|
373
|
+
- The package is now ESM-only. ESM can finally be loaded from common.js on node v20.19+
|
|
374
|
+
- `.js` extension must be used for all modules
|
|
375
|
+
- Old: `@noble/hashes/sha3`
|
|
376
|
+
- New: `@noble/hashes/sha3.js`
|
|
377
|
+
- This simplifies working in browsers natively without transpilers
|
|
378
|
+
- Only allow Uint8Array as hash inputs, prohibit `string`
|
|
379
|
+
- Strict validation checks improve security
|
|
380
|
+
- To replicate previous behavior, use `utils.utf8ToBytes`
|
|
381
|
+
- Rename / remove some modules for consistency. Previously, sha384 resided in sha512, which was weird
|
|
382
|
+
- `sha256`, `sha512` => `sha2.js` (consistent with `sha3.js`)
|
|
383
|
+
- `blake2b`, `blake2s` => `blake2.js` (consistent with `blake3.js`, `blake1.js`)
|
|
384
|
+
- `ripemd160`, `sha1`, `md5` => `legacy.js` (all low-security hashes are there)
|
|
385
|
+
- `_assert` => `utils.js`
|
|
386
|
+
- `crypto` internal module got removed: use built-in WebCrypto instead
|
|
387
|
+
- Improve typescript types & option autocomplete
|
|
388
|
+
- Bump compilation target from es2020 to es2022
|
|
389
|
+
|
|
390
|
+
## Contributing & testing
|
|
391
|
+
|
|
392
|
+
`npm install && npm run build && npm test` will build the code and run tests.
|
|
393
|
+
|
|
394
|
+
There are **additional** slow suites: timing-based DoS tests `npm run test:dos`,
|
|
395
|
+
multi-hour large-input tests `npm run test:slow`, ACVP LDT vectors `npm run test:acvp`,
|
|
396
|
+
and memory-intensive KDF tests `npm run test:ultra`. The 9–17GiB scrypt cases require an
|
|
397
|
+
explicitly provisioned machine and run separately with `npm run test:ultra:scrypt`.
|
|
398
|
+
|
|
399
|
+
`test/misc` directory contains unrolled implementations (sha3, argon2) and misc helper scripts.
|
|
400
|
+
|
|
401
|
+
Some hashes are outside of scope of the library:
|
|
402
|
+
- [Pedersen in micro-zk-proofs](https://github.com/paulmillr/micro-zk-proofs/blob/1ed5ce1253583b2e540eef7f3477fb52bf5344ff/src/pedersen.ts)
|
|
403
|
+
- [Poseidon in noble-curves](https://github.com/paulmillr/noble-curves/blob/3d124dd3ecec8b6634cc0b2ba1c183aded5304f9/src/abstract/poseidon.ts)
|
|
404
|
+
- [Poly1305 & GHash in noble-ciphers](https://github.com/paulmillr/noble-ciphers)
|
|
405
|
+
|
|
406
|
+
See [paulmillr.com/noble](https://paulmillr.com/noble/) for useful resources, articles, documentation and demos related to the library.
|
|
407
|
+
|
|
408
|
+
## Speed
|
|
409
|
+
|
|
410
|
+
```sh
|
|
411
|
+
npm run benchmark
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
Benchmarks measured on Apple M4.
|
|
415
|
+
|
|
416
|
+
The library could be 3x faster by utilizing loop unrolling. It isn't used because
|
|
417
|
+
unrolling a) would increase bundle size b) make lib un-readable c) current perf is "fast enough"
|
|
418
|
+
for most use-cases.
|
|
419
|
+
|
|
420
|
+
If you need truly exemplar performance, switch to [awasm-noble](https://github.com/paulmillr/awasm-noble),
|
|
421
|
+
which does unrolling in an auditable way and allows to achieve 10GB/s BLAKE3.
|
|
422
|
+
|
|
423
|
+
```
|
|
424
|
+
# 32B
|
|
425
|
+
sha256 438 ns
|
|
426
|
+
sha512 1219 ns
|
|
427
|
+
sha3_256 1853 ns
|
|
428
|
+
sha3_512 1864 ns
|
|
429
|
+
kt128 1380 ns
|
|
430
|
+
kt256 1370 ns
|
|
431
|
+
turboshake128 1191 ns
|
|
432
|
+
blake256 1335 ns
|
|
433
|
+
blake2b 2186 ns
|
|
434
|
+
blake2s 1055 ns
|
|
435
|
+
blake3 981 ns
|
|
436
|
+
ripemd160 563 ns
|
|
437
|
+
md5 449 ns
|
|
438
|
+
sha1 507 ns
|
|
439
|
+
hmac(sha256) 1955 ns
|
|
440
|
+
hmac(sha512) 5126 ns
|
|
441
|
+
kmac256 6653 ns
|
|
442
|
+
blake3(key) 1120 ns
|
|
443
|
+
|
|
444
|
+
# 1MB
|
|
445
|
+
sha256 x 297 mib/sec
|
|
446
|
+
sha512 x 130 mib/sec
|
|
447
|
+
sha3_256 x 78.1 mib/sec
|
|
448
|
+
sha3_512 x 41.9 mib/sec
|
|
449
|
+
kt128 x 184 mib/sec
|
|
450
|
+
kt256 x 147 mib/sec
|
|
451
|
+
turboshake128 x 186 mib/sec
|
|
452
|
+
blake256 x 56.7 mib/sec
|
|
453
|
+
blake2b x 66.2 mib/sec
|
|
454
|
+
blake2s x 62.9 mib/sec
|
|
455
|
+
blake3 x 90 mib/sec
|
|
456
|
+
ripemd160 x 179 mib/sec
|
|
457
|
+
md5 x 275 mib/sec
|
|
458
|
+
sha1 x 417 mib/sec
|
|
459
|
+
hmac(sha256) x 290 mib/sec
|
|
460
|
+
hmac(sha512) x 129 mib/sec
|
|
461
|
+
kmac256 x 78.4 mib/sec
|
|
462
|
+
blake3(key) x 90.5 mib/sec
|
|
463
|
+
|
|
464
|
+
# KDF
|
|
465
|
+
hkdf(sha256) x 249,100 ops/sec @ 4015 ns/op
|
|
466
|
+
blake3(context) x 480,400 ops/sec @ 2081 ns/op
|
|
467
|
+
pbkdf2(sha256, c: 2 ** 18) x 5 ops/sec @ 199 ms/op
|
|
468
|
+
scrypt(n: 2 ** 19, r: 8, p: 1) x 1 ops/sec @ 751 ms/op
|
|
469
|
+
argon2id(t: 1, m: 128MB) x 3 ops/sec @ 276 ms/op
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
## License
|
|
473
|
+
|
|
474
|
+
The MIT License (MIT)
|
|
475
|
+
|
|
476
|
+
Copyright (c) 2022 Paul Miller [(https://paulmillr.com)](https://paulmillr.com)
|
|
477
|
+
|
|
478
|
+
See LICENSE file.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal helpers for blake hash.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import { type TRet } from './utils.ts';
|
|
6
|
+
/**
|
|
7
|
+
* Internal blake permutation table.
|
|
8
|
+
* Rows `0..9` serve BLAKE2s, rows `0..11` serve BLAKE2b with `10..11 = 0..1`, and Blake1 also
|
|
9
|
+
* reuses the later rows shown below. Blake1 expands rounds `10..15` as `SIGMA[i % 10]`, so rows
|
|
10
|
+
* `10..15` intentionally repeat rows `0..5` for the 14-round (256) and 16-round (512) variants.
|
|
11
|
+
*/
|
|
12
|
+
export declare const BSIGMA: TRet<Uint8Array>;
|
|
13
|
+
export type Num4 = {
|
|
14
|
+
a: number;
|
|
15
|
+
b: number;
|
|
16
|
+
c: number;
|
|
17
|
+
d: number;
|
|
18
|
+
};
|
|
19
|
+
export declare function G1s(a: number, b: number, c: number, d: number, x: number): Num4;
|
|
20
|
+
export declare function G2s(a: number, b: number, c: number, d: number, x: number): Num4;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal helpers for blake hash.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
import { rotr } from "./utils.js";
|
|
6
|
+
// Unrealized speed-up: a file-local copy of rotr measured ~1-2% faster blake2s/blake256/blake3
|
|
7
|
+
// on Node 24 (V8 does not inline it into G1s/G2s across the module boundary). Reused from
|
|
8
|
+
// utils for deduplication.
|
|
9
|
+
/**
|
|
10
|
+
* Internal blake permutation table.
|
|
11
|
+
* Rows `0..9` serve BLAKE2s, rows `0..11` serve BLAKE2b with `10..11 = 0..1`, and Blake1 also
|
|
12
|
+
* reuses the later rows shown below. Blake1 expands rounds `10..15` as `SIGMA[i % 10]`, so rows
|
|
13
|
+
* `10..15` intentionally repeat rows `0..5` for the 14-round (256) and 16-round (512) variants.
|
|
14
|
+
*/
|
|
15
|
+
// prettier-ignore
|
|
16
|
+
export const BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
17
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
18
|
+
14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3,
|
|
19
|
+
11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4,
|
|
20
|
+
7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8,
|
|
21
|
+
9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13,
|
|
22
|
+
2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9,
|
|
23
|
+
12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11,
|
|
24
|
+
13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10,
|
|
25
|
+
6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5,
|
|
26
|
+
10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0,
|
|
27
|
+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
|
28
|
+
14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3,
|
|
29
|
+
// Blake1, unused in others
|
|
30
|
+
11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4,
|
|
31
|
+
7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8,
|
|
32
|
+
9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13,
|
|
33
|
+
2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9,
|
|
34
|
+
]);
|
|
35
|
+
// Unrealized speed-up: G1s/G2s return a fresh {a,b,c,d} per call (160×/blake2s block), which
|
|
36
|
+
// V8's escape analysis does not eliminate when G stays a real call. Writing into one reused
|
|
37
|
+
// module-level slot instead measured +4-6% blake2s/blake256 1MB throughput on Node 24 — but
|
|
38
|
+
// ~2% slower blake3 (whose profile inlines G and scalar-replaces the fresh object) and no
|
|
39
|
+
// difference on 32-byte inputs. Kept simple.
|
|
40
|
+
// 32-bit / BLAKE2s first half of G, with the fixed `(16, 12)` rotation pair.
|
|
41
|
+
// Parameter `x` is the RFC 7693 first-half message word, or Blake1's pre-mixed
|
|
42
|
+
// `m[sigma[r][2i]] ^ u[sigma[r][2i+1]]` addend in the 32-bit path.
|
|
43
|
+
export function G1s(a, b, c, d, x) {
|
|
44
|
+
a = (a + b + x) | 0;
|
|
45
|
+
d = rotr(d ^ a, 16);
|
|
46
|
+
c = (c + d) | 0;
|
|
47
|
+
b = rotr(b ^ c, 12);
|
|
48
|
+
return { a, b, c, d };
|
|
49
|
+
}
|
|
50
|
+
// 32-bit / BLAKE2s second half of G.
|
|
51
|
+
// Parameter `x` is the RFC 7693 second-half (`y`) message word, or Blake1's pre-mixed
|
|
52
|
+
// `m[sigma[r][2i + 1]] ^ u[sigma[r][2i]]` addend in the 32-bit path.
|
|
53
|
+
export function G2s(a, b, c, d, x) {
|
|
54
|
+
a = (a + b + x) | 0;
|
|
55
|
+
d = rotr(d ^ a, 8);
|
|
56
|
+
c = (c + d) | 0;
|
|
57
|
+
b = rotr(b ^ c, 7);
|
|
58
|
+
return { a, b, c, d };
|
|
59
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type Hash, type TArg, type TRet } from './utils.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Shared 32-bit conditional boolean primitive reused by SHA-256, SHA-1, and MD5 `F`.
|
|
4
|
+
* Returns bits from `b` when `a` is set, otherwise from `c`.
|
|
5
|
+
* The XOR form is equivalent to MD5's `F(X,Y,Z) = XY v not(X)Z` because the masked terms never
|
|
6
|
+
* set the same bit.
|
|
7
|
+
* @param a - selector word
|
|
8
|
+
* @param b - word chosen when selector bit is set
|
|
9
|
+
* @param c - word chosen when selector bit is clear
|
|
10
|
+
* @returns Mixed 32-bit word.
|
|
11
|
+
* @example
|
|
12
|
+
* Combine three words with the shared 32-bit choice primitive.
|
|
13
|
+
* ```ts
|
|
14
|
+
* Chi(0xffffffff, 0x12345678, 0x87654321);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare function Chi(a: number, b: number, c: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Shared 32-bit majority primitive reused by SHA-256 and SHA-1.
|
|
20
|
+
* Returns bits shared by at least two inputs.
|
|
21
|
+
* @param a - first input word
|
|
22
|
+
* @param b - second input word
|
|
23
|
+
* @param c - third input word
|
|
24
|
+
* @returns Mixed 32-bit word.
|
|
25
|
+
* @example
|
|
26
|
+
* Combine three words with the shared 32-bit majority primitive.
|
|
27
|
+
* ```ts
|
|
28
|
+
* Maj(0xffffffff, 0x12345678, 0x87654321);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function Maj(a: number, b: number, c: number): number;
|
|
32
|
+
/**
|
|
33
|
+
* Merkle-Damgard hash construction base class.
|
|
34
|
+
* Could be used to create MD5, RIPEMD, SHA1, SHA2.
|
|
35
|
+
* Accepts only byte-aligned `Uint8Array` input, even when the underlying spec describes bit
|
|
36
|
+
* strings with partial-byte tails.
|
|
37
|
+
* @param blockLen - internal block size in bytes
|
|
38
|
+
* @param outputLen - digest size in bytes
|
|
39
|
+
* @param padOffset - trailing length field size in bytes
|
|
40
|
+
* @param isLE - whether length and state words are encoded in little-endian
|
|
41
|
+
* @example
|
|
42
|
+
* Use a concrete subclass to get the shared Merkle-Damgard update/digest flow.
|
|
43
|
+
* ```ts
|
|
44
|
+
* import { _SHA1 } from '@noble/hashes/legacy.js';
|
|
45
|
+
* const hash = new _SHA1();
|
|
46
|
+
* hash.update(new Uint8Array([97, 98, 99]));
|
|
47
|
+
* hash.digest();
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare abstract class HashMD<T extends HashMD<T>> implements Hash<T> {
|
|
51
|
+
protected abstract process(buf: DataView, offset: number): void;
|
|
52
|
+
protected abstract get(): number[];
|
|
53
|
+
protected abstract set(...args: number[]): void;
|
|
54
|
+
abstract _cloneInto(to?: T): T;
|
|
55
|
+
abstract destroy(): void;
|
|
56
|
+
protected abstract roundClean(): void;
|
|
57
|
+
readonly blockLen: number;
|
|
58
|
+
readonly outputLen: number;
|
|
59
|
+
readonly canXOF = false;
|
|
60
|
+
readonly padOffset: number;
|
|
61
|
+
readonly isLE: boolean;
|
|
62
|
+
protected buffer: Uint8Array;
|
|
63
|
+
protected view: DataView;
|
|
64
|
+
protected finished: boolean;
|
|
65
|
+
protected length: number;
|
|
66
|
+
protected pos: number;
|
|
67
|
+
protected destroyed: boolean;
|
|
68
|
+
constructor(blockLen: number, outputLen: number, padOffset: number, isLE: boolean);
|
|
69
|
+
update(data: TArg<Uint8Array>): this;
|
|
70
|
+
digestInto(out: TArg<Uint8Array>): void;
|
|
71
|
+
digest(): TRet<Uint8Array>;
|
|
72
|
+
protected _cloneIntoMeta(to: T): T;
|
|
73
|
+
clone(): T;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Initial SHA-2 state: fractional parts of square roots of first 16 primes 2..53.
|
|
77
|
+
* Check out `test/misc/sha2-gen-iv.js` for recomputation guide.
|
|
78
|
+
*/
|
|
79
|
+
/** Initial SHA256 state from RFC 6234 §6.1: the first 32 bits of the fractional parts of the
|
|
80
|
+
* square roots of the first eight prime numbers. Exported as a shared table; callers must treat
|
|
81
|
+
* it as read-only because constructors copy words from it by index. */
|
|
82
|
+
export declare const SHA256_IV: TRet<Uint32Array>;
|
|
83
|
+
/** Initial SHA224 state `H(0)` from RFC 6234 §6.1. Exported as a shared table; callers must
|
|
84
|
+
* treat it as read-only because constructors copy words from it by index. */
|
|
85
|
+
export declare const SHA224_IV: TRet<Uint32Array>;
|
|
86
|
+
/** Initial SHA384 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
|
|
87
|
+
* big-endian 32-bit halves. Derived from the fractional parts of the square roots of the ninth
|
|
88
|
+
* through sixteenth prime numbers. Exported as a shared table; callers must treat it as read-only
|
|
89
|
+
* because constructors copy halves from it by index. */
|
|
90
|
+
export declare const SHA384_IV: TRet<Uint32Array>;
|
|
91
|
+
/** Initial SHA512 state from RFC 6234 §6.3: eight RFC 64-bit `H(0)` words stored as sixteen
|
|
92
|
+
* big-endian 32-bit halves. Derived from the fractional parts of the square roots of the first
|
|
93
|
+
* eight prime numbers. Exported as a shared table; callers must treat it as read-only because
|
|
94
|
+
* constructors copy halves from it by index. */
|
|
95
|
+
export declare const SHA512_IV: TRet<Uint32Array>;
|