@mtkruto/node 0.1.0 → 0.1.101
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/esm/0_deps.d.ts +4 -3
- package/esm/0_deps.js +4 -3
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/0_message.js +3 -9
- package/esm/client/3_types.d.ts +2 -0
- package/esm/client/4_client.d.ts +19 -3
- package/esm/client/4_client.js +209 -68
- package/esm/connection/1_connection_web_socket.js +5 -2
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.js +1 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.d.ts +2 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.js +24 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.d.ts +2 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.js +27 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/mod.d.ts +1 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/mod.js +21 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/util.d.ts +13 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_fnv/util.js +48 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.d.ts +125 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.js +3337 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/mod.d.ts +12 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/_wasm/mod.js +39 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/crypto.d.ts +157 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/crypto.js +266 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/keystack.d.ts +4 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/keystack.js +6 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/mod.d.ts +12 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/mod.js +14 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.d.ts +28 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.js +54 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/to_hash_string.d.ts +19 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/to_hash_string.js +31 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/unstable/keystack.d.ts +46 -0
- package/esm/deps/deno.land/std@0.203.0/crypto/unstable/keystack.js +149 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/_util.d.ts +1 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/_util.js +26 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/base64.d.ts +23 -0
- package/{script/deps/deno.land/std@0.201.0 → esm/deps/deno.land/std@0.203.0}/encoding/base64.js +23 -18
- package/esm/deps/deno.land/std@0.203.0/encoding/base64url.d.ts +24 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/base64url.js +80 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/hex.d.ts +18 -0
- package/esm/deps/deno.land/std@0.203.0/encoding/hex.js +115 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.js +1 -1
- package/{script/deps/deno.land/x/tgcrypto@0.2.1 → esm/deps/deno.land/x/tgcrypto@0.3.3}/mod.d.ts +2 -6
- package/esm/deps/deno.land/x/tgcrypto@0.3.3/mod.js +164 -0
- package/esm/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +324 -0
- package/esm/transport/0_obfuscation.js +1 -1
- package/esm/transport/0_transport.js +2 -2
- package/esm/types/3_message.js +1 -1
- package/esm/utilities/0_bigint.d.ts +1 -0
- package/esm/utilities/0_bigint.js +1 -0
- package/esm/utilities/0_crypto.d.ts +1 -2
- package/esm/utilities/0_crypto.js +3 -12
- package/esm/utilities/0_queue.js +1 -1
- package/package.json +1 -1
- package/script/0_deps.d.ts +4 -3
- package/script/0_deps.js +7 -6
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/0_message.js +2 -8
- package/script/client/3_types.d.ts +2 -0
- package/script/client/4_client.d.ts +19 -3
- package/script/client/4_client.js +208 -66
- package/script/connection/1_connection_web_socket.js +5 -2
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.js +1 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.d.ts +2 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv32.js +29 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.d.ts +2 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/fnv64.js +32 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/mod.d.ts +1 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/mod.js +25 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/util.d.ts +13 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_fnv/util.js +54 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.d.ts +125 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_wasm/lib/deno_std_wasm_crypto.generated.js +3345 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_wasm/mod.d.ts +12 -0
- package/script/deps/deno.land/std@0.203.0/crypto/_wasm/mod.js +44 -0
- package/script/deps/deno.land/std@0.203.0/crypto/crypto.d.ts +157 -0
- package/script/deps/deno.land/std@0.203.0/crypto/crypto.js +292 -0
- package/script/deps/deno.land/std@0.203.0/crypto/keystack.d.ts +4 -0
- package/script/deps/deno.land/std@0.203.0/crypto/keystack.js +22 -0
- package/script/deps/deno.land/std@0.203.0/crypto/mod.d.ts +12 -0
- package/script/deps/deno.land/std@0.203.0/crypto/mod.js +30 -0
- package/script/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.d.ts +28 -0
- package/script/deps/deno.land/std@0.203.0/crypto/timing_safe_equal.js +58 -0
- package/script/deps/deno.land/std@0.203.0/crypto/to_hash_string.d.ts +19 -0
- package/script/deps/deno.land/std@0.203.0/crypto/to_hash_string.js +35 -0
- package/script/deps/deno.land/std@0.203.0/crypto/unstable/keystack.d.ts +46 -0
- package/script/deps/deno.land/std@0.203.0/crypto/unstable/keystack.js +176 -0
- package/script/deps/deno.land/std@0.203.0/encoding/_util.d.ts +1 -0
- package/script/deps/deno.land/std@0.203.0/encoding/_util.js +30 -0
- package/script/deps/deno.land/std@0.203.0/encoding/base64.d.ts +23 -0
- package/{esm/deps/deno.land/std@0.201.0 → script/deps/deno.land/std@0.203.0}/encoding/base64.js +28 -13
- package/script/deps/deno.land/std@0.203.0/encoding/base64url.d.ts +24 -0
- package/script/deps/deno.land/std@0.203.0/encoding/base64url.js +108 -0
- package/script/deps/deno.land/std@0.203.0/encoding/hex.d.ts +18 -0
- package/script/deps/deno.land/std@0.203.0/encoding/hex.js +122 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.js +1 -1
- package/{esm/deps/deno.land/x/tgcrypto@0.2.1 → script/deps/deno.land/x/tgcrypto@0.3.3}/mod.d.ts +2 -6
- package/script/deps/deno.land/x/tgcrypto@0.3.3/mod.js +177 -0
- package/script/deps/deno.land/x/tgcrypto@0.3.3/tgcrypto.js +326 -0
- package/script/transport/0_obfuscation.js +1 -1
- package/script/transport/0_transport.js +2 -2
- package/script/types/3_message.js +1 -1
- package/script/utilities/0_bigint.d.ts +1 -0
- package/script/utilities/0_bigint.js +1 -0
- package/script/utilities/0_crypto.d.ts +1 -2
- package/script/utilities/0_crypto.js +2 -11
- package/script/utilities/0_queue.js +1 -1
- package/esm/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
- package/esm/deps/deno.land/x/tgcrypto@0.2.1/mod.js +0 -81
- package/esm/deps/deno.land/x/tgcrypto@0.2.1/tgcrypto.js +0 -991
- package/script/deps/deno.land/std@0.201.0/encoding/base64.d.ts +0 -11
- package/script/deps/deno.land/x/tgcrypto@0.2.1/mod.js +0 -95
- package/script/deps/deno.land/x/tgcrypto@0.2.1/tgcrypto.js +0 -993
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.d.ts +1 -1
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.d.ts +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.js +0 -0
- package/esm/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.d.ts +0 -0
- package/esm/deps/deno.land/x/{tgcrypto@0.2.1 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_constants.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_diff.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/_format.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_almost_equals.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_array_includes.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_equals.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.d.ts +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_exists.js +0 -0
- package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_false.d.ts +1 -1
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_greater_or_equal.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_instance_of.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_is_error.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_less_or_equal.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_match.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_equals.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_instance_of.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_match.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_not_strict_equals.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_object_match.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_rejects.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_strict_equals.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_string_includes.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assert_throws.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/assertion_error.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/equal.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/fail.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/mod.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unimplemented.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.d.ts +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/assert/unreachable.js +0 -0
- /package/script/deps/deno.land/{std@0.201.0 → std@0.203.0}/fmt/colors.d.ts +0 -0
- /package/script/deps/deno.land/x/{tgcrypto@0.2.1 → tgcrypto@0.3.3}/tgcrypto.d.ts +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { DigestContext, instantiate as instantiateWasm, } from "./lib/deno_std_wasm_crypto.generated.js";
|
|
2
|
+
/**
|
|
3
|
+
* All cryptographic hash/digest algorithms supported by std/crypto/_wasm.
|
|
4
|
+
*
|
|
5
|
+
* For algorithms that are supported by WebCrypto, the name here must match the
|
|
6
|
+
* one used by WebCrypto. Otherwise we should prefer the formatting used in the
|
|
7
|
+
* official specification. All names are uppercase to facilitate case-insensitive
|
|
8
|
+
* comparisons required by the WebCrypto spec.
|
|
9
|
+
*/
|
|
10
|
+
export declare const digestAlgorithms: readonly ["BLAKE2B-224", "BLAKE2B-256", "BLAKE2B-384", "BLAKE2B", "BLAKE2S", "BLAKE3", "KECCAK-224", "KECCAK-256", "KECCAK-384", "KECCAK-512", "SHA-384", "SHA3-224", "SHA3-256", "SHA3-384", "SHA3-512", "SHAKE128", "SHAKE256", "TIGER", "RIPEMD-160", "SHA-224", "SHA-256", "SHA-512", "MD4", "MD5", "SHA-1"];
|
|
11
|
+
/** An algorithm name supported by std/crypto/_wasm. */
|
|
12
|
+
export type DigestAlgorithm = typeof digestAlgorithms[number];
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.digestAlgorithms = exports.instantiateWasm = exports.DigestContext = void 0;
|
|
4
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
5
|
+
var deno_std_wasm_crypto_generated_js_1 = require("./lib/deno_std_wasm_crypto.generated.js");
|
|
6
|
+
Object.defineProperty(exports, "DigestContext", { enumerable: true, get: function () { return deno_std_wasm_crypto_generated_js_1.DigestContext; } });
|
|
7
|
+
Object.defineProperty(exports, "instantiateWasm", { enumerable: true, get: function () { return deno_std_wasm_crypto_generated_js_1.instantiate; } });
|
|
8
|
+
/**
|
|
9
|
+
* All cryptographic hash/digest algorithms supported by std/crypto/_wasm.
|
|
10
|
+
*
|
|
11
|
+
* For algorithms that are supported by WebCrypto, the name here must match the
|
|
12
|
+
* one used by WebCrypto. Otherwise we should prefer the formatting used in the
|
|
13
|
+
* official specification. All names are uppercase to facilitate case-insensitive
|
|
14
|
+
* comparisons required by the WebCrypto spec.
|
|
15
|
+
*/
|
|
16
|
+
exports.digestAlgorithms = [
|
|
17
|
+
"BLAKE2B-224",
|
|
18
|
+
"BLAKE2B-256",
|
|
19
|
+
"BLAKE2B-384",
|
|
20
|
+
"BLAKE2B",
|
|
21
|
+
"BLAKE2S",
|
|
22
|
+
"BLAKE3",
|
|
23
|
+
"KECCAK-224",
|
|
24
|
+
"KECCAK-256",
|
|
25
|
+
"KECCAK-384",
|
|
26
|
+
"KECCAK-512",
|
|
27
|
+
"SHA-384",
|
|
28
|
+
"SHA3-224",
|
|
29
|
+
"SHA3-256",
|
|
30
|
+
"SHA3-384",
|
|
31
|
+
"SHA3-512",
|
|
32
|
+
"SHAKE128",
|
|
33
|
+
"SHAKE256",
|
|
34
|
+
"TIGER",
|
|
35
|
+
// insecure (length-extendable):
|
|
36
|
+
"RIPEMD-160",
|
|
37
|
+
"SHA-224",
|
|
38
|
+
"SHA-256",
|
|
39
|
+
"SHA-512",
|
|
40
|
+
// insecure (collidable and length-extendable):
|
|
41
|
+
"MD4",
|
|
42
|
+
"MD5",
|
|
43
|
+
"SHA-1",
|
|
44
|
+
];
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensions to the
|
|
3
|
+
* [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
|
|
4
|
+
* supporting additional encryption APIs, but also delegating to the built-in
|
|
5
|
+
* APIs when possible.
|
|
6
|
+
*
|
|
7
|
+
* Provides additional digest algorithms that are not part of the WebCrypto
|
|
8
|
+
* standard as well as a `subtle.digest` and `subtle.digestSync` methods. It
|
|
9
|
+
* also provides a `subtle.timingSafeEqual()` method to compare array buffers
|
|
10
|
+
* or data views in a way that isn't prone to timing based attacks.
|
|
11
|
+
*
|
|
12
|
+
* The "polyfill" delegates to `WebCrypto` where possible.
|
|
13
|
+
*
|
|
14
|
+
* The {@linkcode KeyStack} export implements the {@linkcode KeyRing} interface
|
|
15
|
+
* for managing rotatable keys for signing data to prevent tampering, like with
|
|
16
|
+
* HTTP cookies.
|
|
17
|
+
*
|
|
18
|
+
* ## Supported algorithms
|
|
19
|
+
*
|
|
20
|
+
* Here is a list of supported algorithms. If the algorithm name in WebCrypto
|
|
21
|
+
* and Wasm/Rust is the same, this library prefers to use algorithms that are
|
|
22
|
+
* supported by WebCrypto.
|
|
23
|
+
*
|
|
24
|
+
* WebCrypto
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* // https://deno.land/std/crypto/crypto.ts
|
|
28
|
+
* const webCryptoDigestAlgorithms = [
|
|
29
|
+
* "SHA-384",
|
|
30
|
+
* "SHA-256",
|
|
31
|
+
* "SHA-512",
|
|
32
|
+
* // insecure (length-extendable and collidable):
|
|
33
|
+
* "SHA-1",
|
|
34
|
+
* ] as const;
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* Wasm/Rust
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* // https://deno.land/std/crypto/_wasm/mod.ts
|
|
41
|
+
* export const digestAlgorithms = [
|
|
42
|
+
* "BLAKE2B-224",
|
|
43
|
+
* "BLAKE2B-256",
|
|
44
|
+
* "BLAKE2B-384",
|
|
45
|
+
* "BLAKE2B",
|
|
46
|
+
* "BLAKE2S",
|
|
47
|
+
* "BLAKE3",
|
|
48
|
+
* "KECCAK-224",
|
|
49
|
+
* "KECCAK-256",
|
|
50
|
+
* "KECCAK-384",
|
|
51
|
+
* "KECCAK-512",
|
|
52
|
+
* "SHA-384",
|
|
53
|
+
* "SHA3-224",
|
|
54
|
+
* "SHA3-256",
|
|
55
|
+
* "SHA3-384",
|
|
56
|
+
* "SHA3-512",
|
|
57
|
+
* "SHAKE128",
|
|
58
|
+
* "SHAKE256",
|
|
59
|
+
* "TIGER",
|
|
60
|
+
* // insecure (length-extendable):
|
|
61
|
+
* "RIPEMD-160",
|
|
62
|
+
* "SHA-224",
|
|
63
|
+
* "SHA-256",
|
|
64
|
+
* "SHA-512",
|
|
65
|
+
* // insecure (collidable and length-extendable):
|
|
66
|
+
* "MD4",
|
|
67
|
+
* "MD5",
|
|
68
|
+
* "SHA-1",
|
|
69
|
+
* ] as const;
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* import { crypto } from "https://deno.land/std@$STD_VERSION/crypto/mod.ts";
|
|
75
|
+
*
|
|
76
|
+
* // This will delegate to the runtime's WebCrypto implementation.
|
|
77
|
+
* console.log(
|
|
78
|
+
* new Uint8Array(
|
|
79
|
+
* await crypto.subtle.digest(
|
|
80
|
+
* "SHA-384",
|
|
81
|
+
* new TextEncoder().encode("hello world"),
|
|
82
|
+
* ),
|
|
83
|
+
* ),
|
|
84
|
+
* );
|
|
85
|
+
*
|
|
86
|
+
* // This will use a bundled Wasm/Rust implementation.
|
|
87
|
+
* console.log(
|
|
88
|
+
* new Uint8Array(
|
|
89
|
+
* await crypto.subtle.digest(
|
|
90
|
+
* "BLAKE3",
|
|
91
|
+
* new TextEncoder().encode("hello world"),
|
|
92
|
+
* ),
|
|
93
|
+
* ),
|
|
94
|
+
* );
|
|
95
|
+
* ```
|
|
96
|
+
*
|
|
97
|
+
* @example Convert hash to a string
|
|
98
|
+
*
|
|
99
|
+
* ```ts
|
|
100
|
+
* import {
|
|
101
|
+
* crypto,
|
|
102
|
+
* toHashString,
|
|
103
|
+
* } from "https://deno.land/std@$STD_VERSION/crypto/mod.ts";
|
|
104
|
+
*
|
|
105
|
+
* const hash = await crypto.subtle.digest(
|
|
106
|
+
* "SHA-384",
|
|
107
|
+
* new TextEncoder().encode("You hear that Mr. Anderson?"),
|
|
108
|
+
* );
|
|
109
|
+
*
|
|
110
|
+
* // Hex encoding by default
|
|
111
|
+
* console.log(toHashString(hash));
|
|
112
|
+
*
|
|
113
|
+
* // Or with base64 encoding
|
|
114
|
+
* console.log(toHashString(hash, "base64"));
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @module
|
|
118
|
+
*/
|
|
119
|
+
import * as dntShim from "../../../../_dnt.shims.js";
|
|
120
|
+
import { DigestAlgorithm as WasmDigestAlgorithm } from "./_wasm/mod.js";
|
|
121
|
+
/** Extensions to the web standard `SubtleCrypto` interface. */
|
|
122
|
+
export interface StdSubtleCrypto extends dntShim.SubtleCrypto {
|
|
123
|
+
/**
|
|
124
|
+
* Returns a new `Promise` object that will digest `data` using the specified
|
|
125
|
+
* `AlgorithmIdentifier`.
|
|
126
|
+
*/
|
|
127
|
+
digest(algorithm: DigestAlgorithm, data: dntShim.BufferSource | AsyncIterable<dntShim.BufferSource> | Iterable<dntShim.BufferSource>): Promise<ArrayBuffer>;
|
|
128
|
+
/**
|
|
129
|
+
* Returns a ArrayBuffer with the result of digesting `data` using the
|
|
130
|
+
* specified `AlgorithmIdentifier`.
|
|
131
|
+
*/
|
|
132
|
+
digestSync(algorithm: DigestAlgorithm, data: dntShim.BufferSource | Iterable<dntShim.BufferSource>): ArrayBuffer;
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated (will be removed in 0.207.0) Import from `std/crypto/timing_safe_equal.ts` instead
|
|
135
|
+
*
|
|
136
|
+
* Compare to array buffers or data views in a way that timing based attacks
|
|
137
|
+
* cannot gain information about the platform. */
|
|
138
|
+
timingSafeEqual(a: ArrayBufferLike | DataView, b: ArrayBufferLike | DataView): boolean;
|
|
139
|
+
}
|
|
140
|
+
/** Extensions to the Web {@linkcode Crypto} interface. */
|
|
141
|
+
export interface StdCrypto extends dntShim.Crypto {
|
|
142
|
+
readonly subtle: StdSubtleCrypto;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* An wrapper for WebCrypto adding support for additional non-standard
|
|
146
|
+
* algorithms, but delegating to the runtime WebCrypto implementation whenever
|
|
147
|
+
* possible.
|
|
148
|
+
*/
|
|
149
|
+
declare const stdCrypto: StdCrypto;
|
|
150
|
+
export type FNVAlgorithms = "FNV32" | "FNV32A" | "FNV64" | "FNV64A";
|
|
151
|
+
export type DigestAlgorithmName = WasmDigestAlgorithm | FNVAlgorithms;
|
|
152
|
+
export type DigestAlgorithmObject = {
|
|
153
|
+
name: DigestAlgorithmName;
|
|
154
|
+
length?: number;
|
|
155
|
+
};
|
|
156
|
+
export type DigestAlgorithm = DigestAlgorithmName | DigestAlgorithmObject;
|
|
157
|
+
export { stdCrypto as crypto };
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
+
}) : function(o, v) {
|
|
18
|
+
o["default"] = v;
|
|
19
|
+
});
|
|
20
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
21
|
+
if (mod && mod.__esModule) return mod;
|
|
22
|
+
var result = {};
|
|
23
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
24
|
+
__setModuleDefault(result, mod);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.crypto = void 0;
|
|
29
|
+
/**
|
|
30
|
+
* Extensions to the
|
|
31
|
+
* [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
|
|
32
|
+
* supporting additional encryption APIs, but also delegating to the built-in
|
|
33
|
+
* APIs when possible.
|
|
34
|
+
*
|
|
35
|
+
* Provides additional digest algorithms that are not part of the WebCrypto
|
|
36
|
+
* standard as well as a `subtle.digest` and `subtle.digestSync` methods. It
|
|
37
|
+
* also provides a `subtle.timingSafeEqual()` method to compare array buffers
|
|
38
|
+
* or data views in a way that isn't prone to timing based attacks.
|
|
39
|
+
*
|
|
40
|
+
* The "polyfill" delegates to `WebCrypto` where possible.
|
|
41
|
+
*
|
|
42
|
+
* The {@linkcode KeyStack} export implements the {@linkcode KeyRing} interface
|
|
43
|
+
* for managing rotatable keys for signing data to prevent tampering, like with
|
|
44
|
+
* HTTP cookies.
|
|
45
|
+
*
|
|
46
|
+
* ## Supported algorithms
|
|
47
|
+
*
|
|
48
|
+
* Here is a list of supported algorithms. If the algorithm name in WebCrypto
|
|
49
|
+
* and Wasm/Rust is the same, this library prefers to use algorithms that are
|
|
50
|
+
* supported by WebCrypto.
|
|
51
|
+
*
|
|
52
|
+
* WebCrypto
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* // https://deno.land/std/crypto/crypto.ts
|
|
56
|
+
* const webCryptoDigestAlgorithms = [
|
|
57
|
+
* "SHA-384",
|
|
58
|
+
* "SHA-256",
|
|
59
|
+
* "SHA-512",
|
|
60
|
+
* // insecure (length-extendable and collidable):
|
|
61
|
+
* "SHA-1",
|
|
62
|
+
* ] as const;
|
|
63
|
+
* ```
|
|
64
|
+
*
|
|
65
|
+
* Wasm/Rust
|
|
66
|
+
*
|
|
67
|
+
* ```ts
|
|
68
|
+
* // https://deno.land/std/crypto/_wasm/mod.ts
|
|
69
|
+
* export const digestAlgorithms = [
|
|
70
|
+
* "BLAKE2B-224",
|
|
71
|
+
* "BLAKE2B-256",
|
|
72
|
+
* "BLAKE2B-384",
|
|
73
|
+
* "BLAKE2B",
|
|
74
|
+
* "BLAKE2S",
|
|
75
|
+
* "BLAKE3",
|
|
76
|
+
* "KECCAK-224",
|
|
77
|
+
* "KECCAK-256",
|
|
78
|
+
* "KECCAK-384",
|
|
79
|
+
* "KECCAK-512",
|
|
80
|
+
* "SHA-384",
|
|
81
|
+
* "SHA3-224",
|
|
82
|
+
* "SHA3-256",
|
|
83
|
+
* "SHA3-384",
|
|
84
|
+
* "SHA3-512",
|
|
85
|
+
* "SHAKE128",
|
|
86
|
+
* "SHAKE256",
|
|
87
|
+
* "TIGER",
|
|
88
|
+
* // insecure (length-extendable):
|
|
89
|
+
* "RIPEMD-160",
|
|
90
|
+
* "SHA-224",
|
|
91
|
+
* "SHA-256",
|
|
92
|
+
* "SHA-512",
|
|
93
|
+
* // insecure (collidable and length-extendable):
|
|
94
|
+
* "MD4",
|
|
95
|
+
* "MD5",
|
|
96
|
+
* "SHA-1",
|
|
97
|
+
* ] as const;
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```ts
|
|
102
|
+
* import { crypto } from "https://deno.land/std@$STD_VERSION/crypto/mod.ts";
|
|
103
|
+
*
|
|
104
|
+
* // This will delegate to the runtime's WebCrypto implementation.
|
|
105
|
+
* console.log(
|
|
106
|
+
* new Uint8Array(
|
|
107
|
+
* await crypto.subtle.digest(
|
|
108
|
+
* "SHA-384",
|
|
109
|
+
* new TextEncoder().encode("hello world"),
|
|
110
|
+
* ),
|
|
111
|
+
* ),
|
|
112
|
+
* );
|
|
113
|
+
*
|
|
114
|
+
* // This will use a bundled Wasm/Rust implementation.
|
|
115
|
+
* console.log(
|
|
116
|
+
* new Uint8Array(
|
|
117
|
+
* await crypto.subtle.digest(
|
|
118
|
+
* "BLAKE3",
|
|
119
|
+
* new TextEncoder().encode("hello world"),
|
|
120
|
+
* ),
|
|
121
|
+
* ),
|
|
122
|
+
* );
|
|
123
|
+
* ```
|
|
124
|
+
*
|
|
125
|
+
* @example Convert hash to a string
|
|
126
|
+
*
|
|
127
|
+
* ```ts
|
|
128
|
+
* import {
|
|
129
|
+
* crypto,
|
|
130
|
+
* toHashString,
|
|
131
|
+
* } from "https://deno.land/std@$STD_VERSION/crypto/mod.ts";
|
|
132
|
+
*
|
|
133
|
+
* const hash = await crypto.subtle.digest(
|
|
134
|
+
* "SHA-384",
|
|
135
|
+
* new TextEncoder().encode("You hear that Mr. Anderson?"),
|
|
136
|
+
* );
|
|
137
|
+
*
|
|
138
|
+
* // Hex encoding by default
|
|
139
|
+
* console.log(toHashString(hash));
|
|
140
|
+
*
|
|
141
|
+
* // Or with base64 encoding
|
|
142
|
+
* console.log(toHashString(hash, "base64"));
|
|
143
|
+
* ```
|
|
144
|
+
*
|
|
145
|
+
* @module
|
|
146
|
+
*/
|
|
147
|
+
const dntShim = __importStar(require("../../../../_dnt.shims.js"));
|
|
148
|
+
const mod_js_1 = require("./_wasm/mod.js");
|
|
149
|
+
const timing_safe_equal_js_1 = require("./timing_safe_equal.js");
|
|
150
|
+
const mod_js_2 = require("./_fnv/mod.js");
|
|
151
|
+
/**
|
|
152
|
+
* A copy of the global WebCrypto interface, with methods bound so they're
|
|
153
|
+
* safe to re-export.
|
|
154
|
+
*/
|
|
155
|
+
const webCrypto = ((crypto) => ({
|
|
156
|
+
getRandomValues: crypto.getRandomValues?.bind(crypto),
|
|
157
|
+
randomUUID: crypto.randomUUID?.bind(crypto),
|
|
158
|
+
subtle: {
|
|
159
|
+
decrypt: crypto.subtle?.decrypt?.bind(crypto.subtle),
|
|
160
|
+
deriveBits: crypto.subtle?.deriveBits?.bind(crypto.subtle),
|
|
161
|
+
deriveKey: crypto.subtle?.deriveKey?.bind(crypto.subtle),
|
|
162
|
+
digest: crypto.subtle?.digest?.bind(crypto.subtle),
|
|
163
|
+
encrypt: crypto.subtle?.encrypt?.bind(crypto.subtle),
|
|
164
|
+
exportKey: crypto.subtle?.exportKey?.bind(crypto.subtle),
|
|
165
|
+
generateKey: crypto.subtle?.generateKey?.bind(crypto.subtle),
|
|
166
|
+
importKey: crypto.subtle?.importKey?.bind(crypto.subtle),
|
|
167
|
+
sign: crypto.subtle?.sign?.bind(crypto.subtle),
|
|
168
|
+
unwrapKey: crypto.subtle?.unwrapKey?.bind(crypto.subtle),
|
|
169
|
+
verify: crypto.subtle?.verify?.bind(crypto.subtle),
|
|
170
|
+
wrapKey: crypto.subtle?.wrapKey?.bind(crypto.subtle),
|
|
171
|
+
},
|
|
172
|
+
}))(dntShim.dntGlobalThis.crypto);
|
|
173
|
+
const bufferSourceBytes = (data) => {
|
|
174
|
+
let bytes;
|
|
175
|
+
if (data instanceof Uint8Array) {
|
|
176
|
+
bytes = data;
|
|
177
|
+
}
|
|
178
|
+
else if (ArrayBuffer.isView(data)) {
|
|
179
|
+
bytes = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
180
|
+
}
|
|
181
|
+
else if (data instanceof ArrayBuffer) {
|
|
182
|
+
bytes = new Uint8Array(data);
|
|
183
|
+
}
|
|
184
|
+
return bytes;
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* An wrapper for WebCrypto adding support for additional non-standard
|
|
188
|
+
* algorithms, but delegating to the runtime WebCrypto implementation whenever
|
|
189
|
+
* possible.
|
|
190
|
+
*/
|
|
191
|
+
const stdCrypto = ((x) => x)({
|
|
192
|
+
...webCrypto,
|
|
193
|
+
subtle: {
|
|
194
|
+
...webCrypto.subtle,
|
|
195
|
+
/**
|
|
196
|
+
* Polyfills stream support until the Web Crypto API does so:
|
|
197
|
+
* @see {@link https://github.com/wintercg/proposal-webcrypto-streams}
|
|
198
|
+
*/
|
|
199
|
+
async digest(algorithm, data) {
|
|
200
|
+
const { name, length } = normalizeAlgorithm(algorithm);
|
|
201
|
+
const bytes = bufferSourceBytes(data);
|
|
202
|
+
if (FNVAlgorithms.includes(name)) {
|
|
203
|
+
return (0, mod_js_2.fnv)(name, bytes);
|
|
204
|
+
}
|
|
205
|
+
// We delegate to WebCrypto whenever possible,
|
|
206
|
+
if (
|
|
207
|
+
// if the algorithm is supported by the WebCrypto standard,
|
|
208
|
+
webCryptoDigestAlgorithms.includes(name) &&
|
|
209
|
+
// and the data is a single buffer,
|
|
210
|
+
bytes) {
|
|
211
|
+
return webCrypto.subtle.digest(algorithm, bytes);
|
|
212
|
+
}
|
|
213
|
+
else if (mod_js_1.digestAlgorithms.includes(name)) {
|
|
214
|
+
if (bytes) {
|
|
215
|
+
// Otherwise, we use our bundled Wasm implementation via digestSync
|
|
216
|
+
// if it supports the algorithm.
|
|
217
|
+
return stdCrypto.subtle.digestSync(algorithm, bytes);
|
|
218
|
+
}
|
|
219
|
+
else if (data[Symbol.iterator]) {
|
|
220
|
+
return stdCrypto.subtle.digestSync(algorithm, data);
|
|
221
|
+
}
|
|
222
|
+
else if (data[Symbol.asyncIterator]) {
|
|
223
|
+
const wasmCrypto = (0, mod_js_1.instantiateWasm)();
|
|
224
|
+
const context = new wasmCrypto.DigestContext(name);
|
|
225
|
+
for await (const chunk of data) {
|
|
226
|
+
const chunkBytes = bufferSourceBytes(chunk);
|
|
227
|
+
if (!chunkBytes) {
|
|
228
|
+
throw new TypeError("data contained chunk of the wrong type");
|
|
229
|
+
}
|
|
230
|
+
context.update(chunkBytes);
|
|
231
|
+
}
|
|
232
|
+
return context.digestAndDrop(length).buffer;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
throw new TypeError("data must be a BufferSource or [Async]Iterable<BufferSource>");
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else if (webCrypto.subtle?.digest) {
|
|
239
|
+
// (TypeScript type definitions prohibit this case.) If they're trying
|
|
240
|
+
// to call an algorithm we don't recognize, pass it along to WebCrypto
|
|
241
|
+
// in case it's a non-standard algorithm supported by the the runtime
|
|
242
|
+
// they're using.
|
|
243
|
+
return webCrypto.subtle.digest(algorithm, data);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
throw new TypeError(`unsupported digest algorithm: ${algorithm}`);
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
digestSync(algorithm, data) {
|
|
250
|
+
algorithm = normalizeAlgorithm(algorithm);
|
|
251
|
+
const bytes = bufferSourceBytes(data);
|
|
252
|
+
if (FNVAlgorithms.includes(algorithm.name)) {
|
|
253
|
+
return (0, mod_js_2.fnv)(algorithm.name, bytes);
|
|
254
|
+
}
|
|
255
|
+
const wasmCrypto = (0, mod_js_1.instantiateWasm)();
|
|
256
|
+
if (bytes) {
|
|
257
|
+
return wasmCrypto.digest(algorithm.name, bytes, algorithm.length)
|
|
258
|
+
.buffer;
|
|
259
|
+
}
|
|
260
|
+
else if (data[Symbol.iterator]) {
|
|
261
|
+
const context = new wasmCrypto.DigestContext(algorithm.name);
|
|
262
|
+
for (const chunk of data) {
|
|
263
|
+
const chunkBytes = bufferSourceBytes(chunk);
|
|
264
|
+
if (!chunkBytes) {
|
|
265
|
+
throw new TypeError("data contained chunk of the wrong type");
|
|
266
|
+
}
|
|
267
|
+
context.update(chunkBytes);
|
|
268
|
+
}
|
|
269
|
+
return context.digestAndDrop(algorithm.length).buffer;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
throw new TypeError("data must be a BufferSource or Iterable<BufferSource>");
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
// TODO(@kitsonk): rework when https://github.com/w3c/webcrypto/issues/270 resolved
|
|
276
|
+
timingSafeEqual: timing_safe_equal_js_1.timingSafeEqual,
|
|
277
|
+
},
|
|
278
|
+
});
|
|
279
|
+
exports.crypto = stdCrypto;
|
|
280
|
+
const FNVAlgorithms = ["FNV32", "FNV32A", "FNV64", "FNV64A"];
|
|
281
|
+
/** Digest algorithms supported by WebCrypto. */
|
|
282
|
+
const webCryptoDigestAlgorithms = [
|
|
283
|
+
"SHA-384",
|
|
284
|
+
"SHA-256",
|
|
285
|
+
"SHA-512",
|
|
286
|
+
// insecure (length-extendable and collidable):
|
|
287
|
+
"SHA-1",
|
|
288
|
+
];
|
|
289
|
+
const normalizeAlgorithm = (algorithm) => ((typeof algorithm === "string") ? { name: algorithm.toUpperCase() } : {
|
|
290
|
+
...algorithm,
|
|
291
|
+
name: algorithm.name.toUpperCase(),
|
|
292
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated (will be removed after 0.209.0) Import from `std/crypto/unstable/keystack.ts` instead.
|
|
21
|
+
*/
|
|
22
|
+
__exportStar(require("./unstable/keystack.js"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extensions to the
|
|
3
|
+
* [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
|
|
4
|
+
* supporting additional encryption APIs, but also delegating to the built-in
|
|
5
|
+
* APIs when possible.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export * from "./crypto.js";
|
|
10
|
+
export * from "./keystack.js";
|
|
11
|
+
export * from "./timing_safe_equal.js";
|
|
12
|
+
export * from "./to_hash_string.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
/**
|
|
20
|
+
* Extensions to the
|
|
21
|
+
* [Web Crypto](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API)
|
|
22
|
+
* supporting additional encryption APIs, but also delegating to the built-in
|
|
23
|
+
* APIs when possible.
|
|
24
|
+
*
|
|
25
|
+
* @module
|
|
26
|
+
*/
|
|
27
|
+
__exportStar(require("./crypto.js"), exports);
|
|
28
|
+
__exportStar(require("./keystack.js"), exports);
|
|
29
|
+
__exportStar(require("./timing_safe_equal.js"), exports);
|
|
30
|
+
__exportStar(require("./to_hash_string.js"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When checking the values of cryptographic hashes are equal, default
|
|
3
|
+
* comparisons can be susceptible to timing based attacks, where attacker is
|
|
4
|
+
* able to find out information about the host system by repeatedly checking
|
|
5
|
+
* response times to equality comparisons of values.
|
|
6
|
+
*
|
|
7
|
+
* It is likely some form of timing safe equality will make its way to the
|
|
8
|
+
* WebCrypto standard (see:
|
|
9
|
+
* [w3c/webcrypto#270](https://github.com/w3c/webcrypto/issues/270)), but until
|
|
10
|
+
* that time, `timingSafeEqual()` is provided:
|
|
11
|
+
*
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { timingSafeEqual } from "https://deno.land/std@$STD_VERSION/crypto/timing_safe_equal.ts";
|
|
14
|
+
* import { assert } from "https://deno.land/std@$STD_VERSION/assert/assert.ts";
|
|
15
|
+
*
|
|
16
|
+
* const a = await crypto.subtle.digest(
|
|
17
|
+
* "SHA-384",
|
|
18
|
+
* new TextEncoder().encode("hello world"),
|
|
19
|
+
* );
|
|
20
|
+
* const b = await crypto.subtle.digest(
|
|
21
|
+
* "SHA-384",
|
|
22
|
+
* new TextEncoder().encode("hello world"),
|
|
23
|
+
* );
|
|
24
|
+
*
|
|
25
|
+
* assert(timingSafeEqual(a, b));
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function timingSafeEqual(a: ArrayBufferView | ArrayBufferLike | DataView, b: ArrayBufferView | ArrayBufferLike | DataView): boolean;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.timingSafeEqual = void 0;
|
|
6
|
+
const assert_js_1 = require("../assert/assert.js");
|
|
7
|
+
/**
|
|
8
|
+
* When checking the values of cryptographic hashes are equal, default
|
|
9
|
+
* comparisons can be susceptible to timing based attacks, where attacker is
|
|
10
|
+
* able to find out information about the host system by repeatedly checking
|
|
11
|
+
* response times to equality comparisons of values.
|
|
12
|
+
*
|
|
13
|
+
* It is likely some form of timing safe equality will make its way to the
|
|
14
|
+
* WebCrypto standard (see:
|
|
15
|
+
* [w3c/webcrypto#270](https://github.com/w3c/webcrypto/issues/270)), but until
|
|
16
|
+
* that time, `timingSafeEqual()` is provided:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { timingSafeEqual } from "https://deno.land/std@$STD_VERSION/crypto/timing_safe_equal.ts";
|
|
20
|
+
* import { assert } from "https://deno.land/std@$STD_VERSION/assert/assert.ts";
|
|
21
|
+
*
|
|
22
|
+
* const a = await crypto.subtle.digest(
|
|
23
|
+
* "SHA-384",
|
|
24
|
+
* new TextEncoder().encode("hello world"),
|
|
25
|
+
* );
|
|
26
|
+
* const b = await crypto.subtle.digest(
|
|
27
|
+
* "SHA-384",
|
|
28
|
+
* new TextEncoder().encode("hello world"),
|
|
29
|
+
* );
|
|
30
|
+
*
|
|
31
|
+
* assert(timingSafeEqual(a, b));
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
function timingSafeEqual(a, b) {
|
|
35
|
+
if (a.byteLength !== b.byteLength) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
if (!(a instanceof DataView)) {
|
|
39
|
+
a = ArrayBuffer.isView(a)
|
|
40
|
+
? new DataView(a.buffer, a.byteOffset, a.byteLength)
|
|
41
|
+
: new DataView(a);
|
|
42
|
+
}
|
|
43
|
+
if (!(b instanceof DataView)) {
|
|
44
|
+
b = ArrayBuffer.isView(b)
|
|
45
|
+
? new DataView(b.buffer, b.byteOffset, b.byteLength)
|
|
46
|
+
: new DataView(b);
|
|
47
|
+
}
|
|
48
|
+
(0, assert_js_1.assert)(a instanceof DataView);
|
|
49
|
+
(0, assert_js_1.assert)(b instanceof DataView);
|
|
50
|
+
const length = a.byteLength;
|
|
51
|
+
let out = 0;
|
|
52
|
+
let i = -1;
|
|
53
|
+
while (++i < length) {
|
|
54
|
+
out |= a.getUint8(i) ^ b.getUint8(i);
|
|
55
|
+
}
|
|
56
|
+
return out === 0;
|
|
57
|
+
}
|
|
58
|
+
exports.timingSafeEqual = timingSafeEqual;
|