@waku/rln 0.1.3-f6d5deb → 0.1.4-29a4c3f.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -186
- package/bundle/_virtual/__node-resolve_empty.js +6 -0
- package/bundle/_virtual/_assert.js +3 -0
- package/bundle/_virtual/_commonjs-dynamic-modules.js +5 -0
- package/bundle/_virtual/_commonjsHelpers.js +32 -0
- package/bundle/_virtual/_node-resolve_empty.js +3 -0
- package/bundle/_virtual/_sha2.js +3 -0
- package/bundle/_virtual/_u64.js +3 -0
- package/bundle/_virtual/aes.js +3 -0
- package/bundle/_virtual/bn.js +3 -0
- package/bundle/_virtual/browser.js +3 -0
- package/bundle/_virtual/checksum.js +3 -0
- package/bundle/_virtual/cipher.js +3 -0
- package/bundle/_virtual/class.js +3 -0
- package/bundle/_virtual/common.js +3 -0
- package/bundle/_virtual/common2.js +3 -0
- package/bundle/_virtual/cryptoBrowser.js +3 -0
- package/bundle/_virtual/functional.js +3 -0
- package/bundle/_virtual/hash.js +3 -0
- package/bundle/_virtual/hmac.js +3 -0
- package/bundle/_virtual/index.js +3 -0
- package/bundle/_virtual/index2.js +6 -0
- package/bundle/_virtual/inherits_browser.js +3 -0
- package/bundle/_virtual/kdf.js +3 -0
- package/bundle/_virtual/lodash.js +3 -0
- package/bundle/_virtual/password.js +3 -0
- package/bundle/_virtual/pbkdf2.js +3 -0
- package/bundle/_virtual/pbkdf22.js +3 -0
- package/bundle/_virtual/random.js +3 -0
- package/bundle/_virtual/ripemd.js +3 -0
- package/bundle/_virtual/schema-validation-generated.js +3 -0
- package/bundle/_virtual/schema-validation.js +3 -0
- package/bundle/_virtual/scrypt.js +3 -0
- package/bundle/_virtual/scrypt2.js +3 -0
- package/bundle/_virtual/sha.js +3 -0
- package/bundle/_virtual/sha256.js +3 -0
- package/bundle/_virtual/sha2562.js +3 -0
- package/bundle/_virtual/sha3.js +3 -0
- package/bundle/_virtual/sha512.js +3 -0
- package/bundle/_virtual/types.js +3 -0
- package/bundle/_virtual/utils.js +3 -0
- package/bundle/_virtual/utils2.js +3 -0
- package/bundle/_virtual/utils3.js +3 -0
- package/bundle/index.js +12 -74804
- package/bundle/node_modules/@ethersproject/abi/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/abi-coder.js +96 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/abstract-coder.js +148 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/address.js +26 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/anonymous.js +20 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/array.js +210 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/boolean.js +18 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/bytes.js +30 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/fixed-bytes.js +26 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/null.js +22 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/number.js +43 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/string.js +19 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/coders/tuple.js +58 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/fragments.js +854 -0
- package/bundle/node_modules/@ethersproject/abi/lib.esm/interface.js +609 -0
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/abstract-provider/lib.esm/index.js +66 -0
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/abstract-signer/lib.esm/index.js +302 -0
- package/bundle/node_modules/@ethersproject/address/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/address/lib.esm/index.js +110 -0
- package/bundle/node_modules/@ethersproject/base64/lib.esm/base64.js +20 -0
- package/bundle/node_modules/@ethersproject/basex/lib.esm/index.js +120 -0
- package/bundle/node_modules/@ethersproject/bignumber/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/bignumber/lib.esm/bignumber.js +287 -0
- package/bundle/node_modules/@ethersproject/bytes/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/bytes/lib.esm/index.js +402 -0
- package/bundle/node_modules/@ethersproject/constants/lib.esm/addresses.js +3 -0
- package/bundle/node_modules/@ethersproject/constants/lib.esm/bignumbers.js +8 -0
- package/bundle/node_modules/@ethersproject/constants/lib.esm/hashes.js +3 -0
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/contracts/lib.esm/index.js +893 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/decoder.js +256 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/include.js +36 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/ens-normalize/lib.js +135 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/id.js +8 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/namehash.js +64 -0
- package/bundle/node_modules/@ethersproject/hash/lib.esm/typed-data.js +443 -0
- package/bundle/node_modules/@ethersproject/keccak256/lib.esm/index.js +8 -0
- package/bundle/node_modules/@ethersproject/keccak256/node_modules/js-sha3/src/sha3.js +660 -0
- package/bundle/node_modules/@ethersproject/logger/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/logger/lib.esm/index.js +352 -0
- package/bundle/node_modules/@ethersproject/networks/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/networks/lib.esm/index.js +248 -0
- package/bundle/node_modules/@ethersproject/properties/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/properties/lib.esm/index.js +127 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/base-provider.js +2007 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/formatter.js +422 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/json-rpc-provider.js +674 -0
- package/bundle/node_modules/@ethersproject/providers/lib.esm/web3-provider.js +132 -0
- package/bundle/node_modules/@ethersproject/rlp/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/rlp/lib.esm/index.js +120 -0
- package/bundle/node_modules/@ethersproject/sha2/lib.esm/sha2.js +8 -0
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/elliptic.js +2430 -0
- package/bundle/node_modules/@ethersproject/signing-key/lib.esm/index.js +76 -0
- package/bundle/node_modules/@ethersproject/strings/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/strings/lib.esm/utf8.js +219 -0
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/transactions/lib.esm/index.js +279 -0
- package/bundle/node_modules/@ethersproject/web/lib.esm/_version.js +3 -0
- package/bundle/node_modules/@ethersproject/web/lib.esm/geturl.js +69 -0
- package/bundle/node_modules/@ethersproject/web/lib.esm/index.js +404 -0
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/convert.js +15 -0
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/multiaddr.js +20 -0
- package/bundle/node_modules/@multiformats/multiaddr/dist/src/protocols-table.js +92 -0
- package/bundle/node_modules/@noble/hashes/esm/_assert.js +37 -0
- package/bundle/node_modules/@noble/hashes/esm/_md.js +132 -0
- package/bundle/node_modules/@noble/hashes/esm/_u64.js +29 -0
- package/bundle/node_modules/@noble/hashes/esm/sha256.js +113 -0
- package/bundle/node_modules/@noble/hashes/esm/sha3.js +210 -0
- package/bundle/node_modules/@noble/hashes/esm/utils.js +144 -0
- package/bundle/node_modules/@waku/zerokit-rln-wasm/rln_wasm.js +756 -0
- package/bundle/node_modules/bech32/index.js +187 -0
- package/bundle/node_modules/bn.js/lib/bn.js +3361 -0
- package/bundle/node_modules/debug/src/browser.js +283 -0
- package/bundle/node_modules/debug/src/common.js +295 -0
- package/bundle/node_modules/ethereum-cryptography/esm/keccak.js +10 -0
- package/bundle/node_modules/ethereum-cryptography/esm/sha256.js +6 -0
- package/bundle/node_modules/ethereum-cryptography/esm/utils.js +24 -0
- package/bundle/node_modules/hash.js/lib/hash/common.js +97 -0
- package/bundle/node_modules/hash.js/lib/hash/hmac.js +51 -0
- package/bundle/node_modules/hash.js/lib/hash/ripemd.js +152 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/1.js +81 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/224.js +33 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/256.js +113 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/384.js +39 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/512.js +336 -0
- package/bundle/node_modules/hash.js/lib/hash/sha/common.js +53 -0
- package/bundle/node_modules/hash.js/lib/hash/sha.js +14 -0
- package/bundle/node_modules/hash.js/lib/hash/utils.js +282 -0
- package/bundle/node_modules/hash.js/lib/hash.js +33 -0
- package/bundle/node_modules/inherits/inherits_browser.js +33 -0
- package/bundle/node_modules/it-length-prefixed/dist/src/decode.js +6 -0
- package/bundle/node_modules/lodash/lodash.js +17207 -0
- package/bundle/node_modules/minimalistic-assert/index.js +13 -0
- package/bundle/node_modules/ms/index.js +172 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base.js +205 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base10.js +9 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base16.js +16 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base2.js +10 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base256emoji.js +41 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base32.js +58 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base36.js +14 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base58.js +14 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base64.js +28 -0
- package/bundle/node_modules/multiformats/dist/src/bases/base8.js +10 -0
- package/bundle/node_modules/multiformats/dist/src/bases/identity.js +11 -0
- package/bundle/node_modules/multiformats/dist/src/basics.js +15 -0
- package/bundle/node_modules/multiformats/dist/src/bytes.js +18 -0
- package/bundle/node_modules/multiformats/dist/src/codecs/json.js +2 -0
- package/bundle/node_modules/multiformats/dist/src/vendor/base-x.js +170 -0
- package/bundle/node_modules/protons-runtime/dist/src/codec.js +20 -0
- package/bundle/node_modules/protons-runtime/dist/src/codecs/enum.js +24 -0
- package/bundle/node_modules/protons-runtime/dist/src/codecs/message.js +7 -0
- package/bundle/node_modules/protons-runtime/dist/src/decode.js +8 -0
- package/bundle/node_modules/protons-runtime/dist/src/encode.js +11 -0
- package/bundle/node_modules/protons-runtime/dist/src/index.js +30 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/float.js +54 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/longbits.js +175 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/pool.js +28 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/reader.js +367 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/utf8.js +99 -0
- package/bundle/node_modules/protons-runtime/dist/src/utils/writer.js +438 -0
- package/bundle/node_modules/uint8-varint/dist/src/index.js +124 -0
- package/bundle/node_modules/uint8arrays/dist/src/alloc.js +17 -0
- package/bundle/node_modules/uint8arrays/dist/src/from-string.js +19 -0
- package/bundle/node_modules/uint8arrays/dist/src/util/bases.js +49 -0
- package/bundle/packages/core/dist/lib/connection_manager/connection_manager.js +21 -0
- package/bundle/packages/core/dist/lib/connection_manager/keep_alive_manager.js +18 -0
- package/bundle/packages/core/dist/lib/filter/filter.js +27 -0
- package/bundle/packages/core/dist/lib/light_push/light_push.js +27 -0
- package/bundle/packages/core/dist/lib/message/version_0.js +154 -0
- package/bundle/packages/core/dist/lib/metadata/metadata.js +27 -0
- package/bundle/packages/core/dist/lib/store/store.js +27 -0
- package/bundle/packages/interfaces/dist/connection_manager.js +19 -0
- package/bundle/packages/interfaces/dist/constants.js +6 -0
- package/bundle/packages/interfaces/dist/health_indicator.js +12 -0
- package/bundle/packages/interfaces/dist/protocols.js +92 -0
- package/bundle/packages/proto/dist/generated/filter.js +445 -0
- package/bundle/packages/proto/dist/generated/filter_v2.js +424 -0
- package/bundle/packages/proto/dist/generated/light_push.js +389 -0
- package/bundle/packages/proto/dist/generated/message.js +213 -0
- package/bundle/packages/proto/dist/generated/metadata.js +130 -0
- package/bundle/packages/proto/dist/generated/peer_exchange.js +209 -0
- package/bundle/packages/proto/dist/generated/sds_message.js +105 -0
- package/bundle/packages/proto/dist/generated/store_v3.js +490 -0
- package/bundle/packages/proto/dist/generated/topic_only_message.js +61 -0
- package/bundle/packages/rln/dist/codec.js +93 -0
- package/bundle/packages/rln/dist/contract/abi.js +394 -0
- package/bundle/packages/rln/dist/contract/constants.js +27 -0
- package/bundle/packages/rln/dist/contract/rln_contract.js +438 -0
- package/bundle/packages/rln/dist/create.js +9 -0
- package/bundle/packages/rln/dist/identity.js +30 -0
- package/bundle/packages/rln/dist/keystore/cipher.js +31 -0
- package/bundle/packages/rln/dist/keystore/credential_validation_generated.js +119 -0
- package/bundle/packages/rln/dist/keystore/keystore.js +223 -0
- package/bundle/packages/rln/dist/keystore/keystore_validation_generated.js +74 -0
- package/bundle/packages/rln/dist/keystore/schema_validator.js +20 -0
- package/bundle/packages/rln/dist/message.js +51 -0
- package/bundle/packages/rln/dist/proof.js +54 -0
- package/bundle/packages/rln/dist/resources/verification_key.js +112 -0
- package/bundle/packages/rln/dist/resources/witness_calculator.js +330 -0
- package/bundle/packages/rln/dist/rln.js +220 -0
- package/bundle/packages/rln/dist/root_tracker.js +76 -0
- package/bundle/packages/rln/dist/utils/bytes.js +65 -0
- package/bundle/packages/rln/dist/utils/epoch.js +39 -0
- package/bundle/packages/rln/dist/utils/hash.js +10 -0
- package/bundle/packages/rln/dist/utils/metamask.js +14 -0
- package/bundle/packages/rln/dist/zerokit.js +128 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/checksum.js +52 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/cipher.js +65 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/class.js +99 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/functional.js +103 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/index.js +28 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/kdf.js +78 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/password.js +17 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation-generated.js +1253 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/schema-validation.js +40 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/lib/types.js +5 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/aes.js +103 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/pbkdf2.js +41 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/random.js +17 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/scrypt.js +23 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/sha256.js +12 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/ethereum-cryptography/utils.js +77 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/index.js +9 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/md5.js +215 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/nil.js +3 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/parse.js +35 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/regex.js +3 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/rng.js +21 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/sha1.js +96 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/stringify.js +31 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v1.js +96 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v3.js +6 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v35.js +66 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v4.js +24 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/v5.js +6 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/validate.js +7 -0
- package/bundle/packages/rln/node_modules/@chainsafe/bls-keystore/node_modules/uuid/dist/esm-browser/version.js +11 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/_assert.js +52 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/_sha2.js +124 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/_u64.js +71 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/cryptoBrowser.js +10 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/hmac.js +88 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/pbkdf2.js +99 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/scrypt.js +233 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/sha256.js +133 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/sha512.js +243 -0
- package/bundle/packages/rln/node_modules/@noble/hashes/utils.js +167 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/native.js +4 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/rng.js +13 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/stringify.js +28 -0
- package/bundle/packages/rln/node_modules/uuid/dist/esm-browser/v4.js +19 -0
- package/bundle/packages/utils/dist/bytes/index.js +44 -0
- package/bundle/packages/utils/dist/common/sharding/index.js +91 -0
- package/bundle/packages/utils/dist/logger/index.js +31 -0
- package/bundle/resources/verification_key.d.ts +13 -0
- package/bundle/resources/verification_key.js +112 -0
- package/bundle/resources/witness_calculator.d.ts +11 -0
- package/bundle/resources/witness_calculator.js +328 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/codec.d.ts +5 -5
- package/dist/codec.js +6 -6
- package/dist/codec.js.map +1 -1
- package/dist/contract/abi.d.ts +42 -0
- package/dist/contract/abi.js +393 -0
- package/dist/contract/abi.js.map +1 -0
- package/dist/contract/constants.d.ts +59 -3
- package/dist/contract/constants.js +21 -63
- package/dist/contract/constants.js.map +1 -1
- package/dist/contract/rln_contract.d.ts +98 -17
- package/dist/contract/rln_contract.js +292 -71
- package/dist/contract/rln_contract.js.map +1 -1
- package/dist/identity.js +5 -2
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/keystore/cipher.js +3 -3
- package/dist/keystore/cipher.js.map +1 -1
- package/dist/keystore/credential_validation_generated.js.map +1 -1
- package/dist/keystore/keystore.js +4 -4
- package/dist/keystore/keystore.js.map +1 -1
- package/dist/keystore/keystore_validation_generated.js.map +1 -1
- package/dist/message.js +3 -3
- package/dist/message.js.map +1 -1
- package/dist/proof.js +3 -2
- package/dist/proof.js.map +1 -1
- package/dist/resources/verification_key.d.ts +12 -11
- package/dist/resources/verification_key.js +103 -103
- package/dist/resources/witness_calculator.d.ts +10 -15
- package/dist/resources/witness_calculator.js +302 -265
- package/dist/rln.d.ts +5 -1
- package/dist/rln.js +56 -28
- package/dist/rln.js.map +1 -1
- package/dist/root_tracker.js.map +1 -1
- package/dist/utils/epoch.js +5 -5
- package/dist/utils/epoch.js.map +1 -1
- package/dist/zerokit.d.ts +13 -9
- package/dist/zerokit.js +40 -20
- package/dist/zerokit.js.map +1 -1
- package/package.json +1 -146
- package/src/codec.ts +26 -22
- package/src/contract/abi.ts +392 -0
- package/src/contract/constants.ts +28 -0
- package/src/contract/index.ts +2 -0
- package/src/contract/rln_contract.ts +686 -0
- package/src/identity.ts +8 -4
- package/src/index.ts +4 -9
- package/src/keystore/cipher.ts +54 -0
- package/src/keystore/credential_validation_generated.ts +7 -0
- package/src/keystore/index.ts +5 -0
- package/src/keystore/keystore.ts +330 -0
- package/src/keystore/keystore_validation_generated.ts +7 -0
- package/src/keystore/schema_validator.ts +34 -0
- package/src/keystore/types.ts +36 -0
- package/src/message.ts +10 -10
- package/src/proof.ts +13 -11
- package/src/resources/verification_key.d.ts +13 -0
- package/src/resources/witness_calculator.d.ts +11 -0
- package/src/rln.ts +76 -31
- package/src/root_tracker.ts +7 -6
- package/src/utils/bytes.ts +84 -0
- package/src/utils/epoch.ts +30 -0
- package/src/utils/hash.ts +15 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/metamask.ts +17 -0
- package/src/zerokit.ts +95 -33
- package/bundle/assets/rln_wasm_bg-a503e304.wasm +0 -0
- package/dist/resources/verification_key.js.map +0 -1
- package/dist/resources/witness_calculator.js.map +0 -1
- /package/bundle/{assets/rln-6ded2896.wasm → resources/rln.wasm} +0 -0
- /package/bundle/{assets/rln_final-8b299152.zkey → resources/rln_final.zkey} +0 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
import { __exports as schemaValidation } from '../../../../../../_virtual/schema-validation.js';
|
2
|
+
import './schema-validation-generated.js';
|
3
|
+
import { __exports as schemaValidationGenerated } from '../../../../../../_virtual/schema-validation-generated.js';
|
4
|
+
|
5
|
+
Object.defineProperty(schemaValidation, "__esModule", { value: true });
|
6
|
+
schemaValidation.isValidKeystore = schemaValidation.validateKeystore = schemaValidation.schemaValidationErrors = undefined;
|
7
|
+
const schema_validation_generated_1 = schemaValidationGenerated;
|
8
|
+
// Redeclare generated function with the proper type
|
9
|
+
const _validateKeystore = schema_validation_generated_1.Keystore;
|
10
|
+
/**
|
11
|
+
* Return schema validation errors for a potential keystore object
|
12
|
+
*/
|
13
|
+
// This function wraps the generated code weirdness
|
14
|
+
function schemaValidationErrors(data) {
|
15
|
+
const validated = _validateKeystore(data);
|
16
|
+
if (validated) {
|
17
|
+
return null;
|
18
|
+
}
|
19
|
+
return _validateKeystore.errors;
|
20
|
+
}
|
21
|
+
schemaValidation.schemaValidationErrors = schemaValidationErrors;
|
22
|
+
/**
|
23
|
+
* Validate an unknown object as a valid keystore, throws on invalid keystore
|
24
|
+
*/
|
25
|
+
function validateKeystore(keystore) {
|
26
|
+
const errors = schemaValidationErrors(keystore);
|
27
|
+
if (errors) {
|
28
|
+
throw new Error(errors.map((error) => `${error.instancePath}: ${error.message}`).join('\n'));
|
29
|
+
}
|
30
|
+
}
|
31
|
+
schemaValidation.validateKeystore = validateKeystore;
|
32
|
+
/**
|
33
|
+
* Predicate for validating an unknown object as a valid keystore
|
34
|
+
*/
|
35
|
+
function isValidKeystore(keystore) {
|
36
|
+
return !schemaValidationErrors(keystore);
|
37
|
+
}
|
38
|
+
schemaValidation.isValidKeystore = isValidKeystore;
|
39
|
+
|
40
|
+
export { schemaValidation as default };
|
@@ -0,0 +1,103 @@
|
|
1
|
+
import { __exports as aes } from '../../../../../../../_virtual/aes.js';
|
2
|
+
import '../../../../@noble/hashes/cryptoBrowser.js';
|
3
|
+
import { u as utilsExports } from './utils.js';
|
4
|
+
import { __exports as cryptoBrowser } from '../../../../../../../_virtual/cryptoBrowser.js';
|
5
|
+
|
6
|
+
Object.defineProperty(aes, "__esModule", { value: true });
|
7
|
+
aes.decrypt = aes.encrypt = undefined;
|
8
|
+
const crypto_1 = cryptoBrowser;
|
9
|
+
const utils_1 = utilsExports;
|
10
|
+
function validateOpt(key, iv, mode) {
|
11
|
+
if (!mode.startsWith("aes-")) {
|
12
|
+
throw new Error(`AES submodule doesn't support mode ${mode}`);
|
13
|
+
}
|
14
|
+
if (iv.length !== 16) {
|
15
|
+
throw new Error("AES: wrong IV length");
|
16
|
+
}
|
17
|
+
if ((mode.startsWith("aes-128") && key.length !== 16) ||
|
18
|
+
(mode.startsWith("aes-256") && key.length !== 32)) {
|
19
|
+
throw new Error("AES: wrong key length");
|
20
|
+
}
|
21
|
+
}
|
22
|
+
async function getBrowserKey(mode, key, iv) {
|
23
|
+
if (!crypto_1.crypto.web) {
|
24
|
+
throw new Error("Browser crypto not available.");
|
25
|
+
}
|
26
|
+
let keyMode;
|
27
|
+
if (["aes-128-cbc", "aes-256-cbc"].includes(mode)) {
|
28
|
+
keyMode = "cbc";
|
29
|
+
}
|
30
|
+
if (["aes-128-ctr", "aes-256-ctr"].includes(mode)) {
|
31
|
+
keyMode = "ctr";
|
32
|
+
}
|
33
|
+
if (!keyMode) {
|
34
|
+
throw new Error("AES: unsupported mode");
|
35
|
+
}
|
36
|
+
const wKey = await crypto_1.crypto.web.subtle.importKey("raw", key, { name: `AES-${keyMode.toUpperCase()}`, length: key.length * 8 }, true, ["encrypt", "decrypt"]);
|
37
|
+
// node.js uses whole 128 bit as a counter, without nonce, instead of 64 bit
|
38
|
+
// recommended by NIST SP800-38A
|
39
|
+
return [wKey, { name: `aes-${keyMode}`, iv, counter: iv, length: 128 }];
|
40
|
+
}
|
41
|
+
async function encrypt(msg, key, iv, mode = "aes-128-ctr", pkcs7PaddingEnabled = true) {
|
42
|
+
validateOpt(key, iv, mode);
|
43
|
+
if (crypto_1.crypto.web) {
|
44
|
+
const [wKey, wOpt] = await getBrowserKey(mode, key, iv);
|
45
|
+
const cipher = await crypto_1.crypto.web.subtle.encrypt(wOpt, wKey, msg);
|
46
|
+
// Remove PKCS7 padding on cbc mode by stripping end of message
|
47
|
+
let res = new Uint8Array(cipher);
|
48
|
+
if (!pkcs7PaddingEnabled && wOpt.name === "aes-cbc" && !(msg.length % 16)) {
|
49
|
+
res = res.slice(0, -16);
|
50
|
+
}
|
51
|
+
return res;
|
52
|
+
}
|
53
|
+
else if (crypto_1.crypto.node) {
|
54
|
+
const cipher = crypto_1.crypto.node.createCipheriv(mode, key, iv);
|
55
|
+
cipher.setAutoPadding(pkcs7PaddingEnabled);
|
56
|
+
return (0, utils_1.concatBytes)(cipher.update(msg), cipher.final());
|
57
|
+
}
|
58
|
+
else {
|
59
|
+
throw new Error("The environment doesn't have AES module");
|
60
|
+
}
|
61
|
+
}
|
62
|
+
aes.encrypt = encrypt;
|
63
|
+
async function getPadding(cypherText, key, iv, mode) {
|
64
|
+
const lastBlock = cypherText.slice(-16);
|
65
|
+
for (let i = 0; i < 16; i++) {
|
66
|
+
// Undo xor of iv and fill with lastBlock ^ padding (16)
|
67
|
+
lastBlock[i] ^= iv[i] ^ 16;
|
68
|
+
}
|
69
|
+
const res = await encrypt(lastBlock, key, iv, mode);
|
70
|
+
return res.slice(0, 16);
|
71
|
+
}
|
72
|
+
async function decrypt(cypherText, key, iv, mode = "aes-128-ctr", pkcs7PaddingEnabled = true) {
|
73
|
+
validateOpt(key, iv, mode);
|
74
|
+
if (crypto_1.crypto.web) {
|
75
|
+
const [wKey, wOpt] = await getBrowserKey(mode, key, iv);
|
76
|
+
// Add empty padding so Chrome will correctly decrypt message
|
77
|
+
if (!pkcs7PaddingEnabled && wOpt.name === "aes-cbc") {
|
78
|
+
const padding = await getPadding(cypherText, key, iv, mode);
|
79
|
+
cypherText = (0, utils_1.concatBytes)(cypherText, padding);
|
80
|
+
}
|
81
|
+
const msg = await crypto_1.crypto.web.subtle.decrypt(wOpt, wKey, cypherText);
|
82
|
+
const msgBytes = new Uint8Array(msg);
|
83
|
+
// Safari always ignores padding (if no padding -> broken message)
|
84
|
+
if (wOpt.name === "aes-cbc") {
|
85
|
+
const encrypted = await encrypt(msgBytes, key, iv, mode);
|
86
|
+
if (!(0, utils_1.equalsBytes)(encrypted, cypherText)) {
|
87
|
+
throw new Error("AES: wrong padding");
|
88
|
+
}
|
89
|
+
}
|
90
|
+
return msgBytes;
|
91
|
+
}
|
92
|
+
else if (crypto_1.crypto.node) {
|
93
|
+
const decipher = crypto_1.crypto.node.createDecipheriv(mode, key, iv);
|
94
|
+
decipher.setAutoPadding(pkcs7PaddingEnabled);
|
95
|
+
return (0, utils_1.concatBytes)(decipher.update(cypherText), decipher.final());
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
throw new Error("The environment doesn't have AES module");
|
99
|
+
}
|
100
|
+
}
|
101
|
+
aes.decrypt = decrypt;
|
102
|
+
|
103
|
+
export { aes as default };
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { __exports as pbkdf2$1 } from '../../../../../../../_virtual/pbkdf2.js';
|
2
|
+
import '../../../../@noble/hashes/pbkdf2.js';
|
3
|
+
import '../../../../@noble/hashes/sha256.js';
|
4
|
+
import '../../../../@noble/hashes/sha512.js';
|
5
|
+
import { u as utilsExports } from './utils.js';
|
6
|
+
import { __exports as pbkdf2$2 } from '../../../../../../../_virtual/pbkdf22.js';
|
7
|
+
import { __exports as sha256 } from '../../../../../../../_virtual/sha2562.js';
|
8
|
+
import { __exports as sha512 } from '../../../../../../../_virtual/sha512.js';
|
9
|
+
|
10
|
+
Object.defineProperty(pbkdf2$1, "__esModule", { value: true });
|
11
|
+
pbkdf2$1.pbkdf2Sync = pbkdf2$1.pbkdf2 = undefined;
|
12
|
+
const pbkdf2_1 = pbkdf2$2;
|
13
|
+
const sha256_1 = sha256;
|
14
|
+
const sha512_1 = sha512;
|
15
|
+
const utils_1 = utilsExports;
|
16
|
+
async function pbkdf2(password, salt, iterations, keylen, digest) {
|
17
|
+
if (!["sha256", "sha512"].includes(digest)) {
|
18
|
+
throw new Error("Only sha256 and sha512 are supported");
|
19
|
+
}
|
20
|
+
(0, utils_1.assertBytes)(password);
|
21
|
+
(0, utils_1.assertBytes)(salt);
|
22
|
+
return (0, pbkdf2_1.pbkdf2Async)(digest === "sha256" ? sha256_1.sha256 : sha512_1.sha512, password, salt, {
|
23
|
+
c: iterations,
|
24
|
+
dkLen: keylen
|
25
|
+
});
|
26
|
+
}
|
27
|
+
pbkdf2$1.pbkdf2 = pbkdf2;
|
28
|
+
function pbkdf2Sync(password, salt, iterations, keylen, digest) {
|
29
|
+
if (!["sha256", "sha512"].includes(digest)) {
|
30
|
+
throw new Error("Only sha256 and sha512 are supported");
|
31
|
+
}
|
32
|
+
(0, utils_1.assertBytes)(password);
|
33
|
+
(0, utils_1.assertBytes)(salt);
|
34
|
+
return (0, pbkdf2_1.pbkdf2)(digest === "sha256" ? sha256_1.sha256 : sha512_1.sha512, password, salt, {
|
35
|
+
c: iterations,
|
36
|
+
dkLen: keylen
|
37
|
+
});
|
38
|
+
}
|
39
|
+
pbkdf2$1.pbkdf2Sync = pbkdf2Sync;
|
40
|
+
|
41
|
+
export { pbkdf2$1 as default };
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { __exports as random } from '../../../../../../../_virtual/random.js';
|
2
|
+
import '../../../../@noble/hashes/utils.js';
|
3
|
+
import { __exports as utils } from '../../../../../../../_virtual/utils.js';
|
4
|
+
|
5
|
+
Object.defineProperty(random, "__esModule", { value: true });
|
6
|
+
random.getRandomBytes = random.getRandomBytesSync = undefined;
|
7
|
+
const utils_1 = utils;
|
8
|
+
function getRandomBytesSync(bytes) {
|
9
|
+
return (0, utils_1.randomBytes)(bytes);
|
10
|
+
}
|
11
|
+
random.getRandomBytesSync = getRandomBytesSync;
|
12
|
+
async function getRandomBytes(bytes) {
|
13
|
+
return (0, utils_1.randomBytes)(bytes);
|
14
|
+
}
|
15
|
+
random.getRandomBytes = getRandomBytes;
|
16
|
+
|
17
|
+
export { random as default };
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { __exports as scrypt$1 } from '../../../../../../../_virtual/scrypt.js';
|
2
|
+
import '../../../../@noble/hashes/scrypt.js';
|
3
|
+
import { u as utilsExports } from './utils.js';
|
4
|
+
import { __exports as scrypt$2 } from '../../../../../../../_virtual/scrypt2.js';
|
5
|
+
|
6
|
+
Object.defineProperty(scrypt$1, "__esModule", { value: true });
|
7
|
+
scrypt$1.scryptSync = scrypt$1.scrypt = undefined;
|
8
|
+
const scrypt_1 = scrypt$2;
|
9
|
+
const utils_1 = utilsExports;
|
10
|
+
async function scrypt(password, salt, n, p, r, dkLen, onProgress) {
|
11
|
+
(0, utils_1.assertBytes)(password);
|
12
|
+
(0, utils_1.assertBytes)(salt);
|
13
|
+
return (0, scrypt_1.scryptAsync)(password, salt, { N: n, r, p, dkLen, onProgress });
|
14
|
+
}
|
15
|
+
scrypt$1.scrypt = scrypt;
|
16
|
+
function scryptSync(password, salt, n, p, r, dkLen, onProgress) {
|
17
|
+
(0, utils_1.assertBytes)(password);
|
18
|
+
(0, utils_1.assertBytes)(salt);
|
19
|
+
return (0, scrypt_1.scrypt)(password, salt, { N: n, r, p, dkLen, onProgress });
|
20
|
+
}
|
21
|
+
scrypt$1.scryptSync = scryptSync;
|
22
|
+
|
23
|
+
export { scrypt$1 as default };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { __exports as sha256 } from '../../../../../../../_virtual/sha256.js';
|
2
|
+
import '../../../../@noble/hashes/sha256.js';
|
3
|
+
import { u as utilsExports } from './utils.js';
|
4
|
+
import { __exports as sha256$1 } from '../../../../../../../_virtual/sha2562.js';
|
5
|
+
|
6
|
+
Object.defineProperty(sha256, "__esModule", { value: true });
|
7
|
+
sha256.sha256 = undefined;
|
8
|
+
const sha256_1 = sha256$1;
|
9
|
+
const utils_1 = utilsExports;
|
10
|
+
sha256.sha256 = (0, utils_1.wrapHash)(sha256_1.sha256);
|
11
|
+
|
12
|
+
export { sha256 as default };
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import { commonjsGlobal } from '../../../../../../../_virtual/_commonjsHelpers.js';
|
2
|
+
import { commonjsRequire } from '../../../../../../../_virtual/_commonjs-dynamic-modules.js';
|
3
|
+
import { __module as utils } from '../../../../../../../_virtual/utils2.js';
|
4
|
+
import '../../../../@noble/hashes/_assert.js';
|
5
|
+
import '../../../../@noble/hashes/utils.js';
|
6
|
+
import { __exports as _assert } from '../../../../../../../_virtual/_assert.js';
|
7
|
+
import { __exports as utils$1 } from '../../../../../../../_virtual/utils.js';
|
8
|
+
|
9
|
+
utils.exports;
|
10
|
+
|
11
|
+
(function (module, exports) {
|
12
|
+
var __importDefault = (commonjsGlobal && commonjsGlobal.__importDefault) || function (mod) {
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
14
|
+
};
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
16
|
+
exports.crypto = exports.wrapHash = exports.equalsBytes = exports.hexToBytes = exports.bytesToUtf8 = exports.utf8ToBytes = exports.createView = exports.concatBytes = exports.toHex = exports.bytesToHex = exports.assertBytes = exports.assertBool = undefined;
|
17
|
+
// buf.toString('hex') -> toHex(buf)
|
18
|
+
const _assert_1 = __importDefault(_assert);
|
19
|
+
const utils_1 = utils$1;
|
20
|
+
const assertBool = _assert_1.default.bool;
|
21
|
+
exports.assertBool = assertBool;
|
22
|
+
const assertBytes = _assert_1.default.bytes;
|
23
|
+
exports.assertBytes = assertBytes;
|
24
|
+
var utils_2 = utils$1;
|
25
|
+
Object.defineProperty(exports, "bytesToHex", { enumerable: true, get: function () { return utils_2.bytesToHex; } });
|
26
|
+
Object.defineProperty(exports, "toHex", { enumerable: true, get: function () { return utils_2.bytesToHex; } });
|
27
|
+
Object.defineProperty(exports, "concatBytes", { enumerable: true, get: function () { return utils_2.concatBytes; } });
|
28
|
+
Object.defineProperty(exports, "createView", { enumerable: true, get: function () { return utils_2.createView; } });
|
29
|
+
Object.defineProperty(exports, "utf8ToBytes", { enumerable: true, get: function () { return utils_2.utf8ToBytes; } });
|
30
|
+
// buf.toString('utf8') -> bytesToUtf8(buf)
|
31
|
+
function bytesToUtf8(data) {
|
32
|
+
if (!(data instanceof Uint8Array)) {
|
33
|
+
throw new TypeError(`bytesToUtf8 expected Uint8Array, got ${typeof data}`);
|
34
|
+
}
|
35
|
+
return new TextDecoder().decode(data);
|
36
|
+
}
|
37
|
+
exports.bytesToUtf8 = bytesToUtf8;
|
38
|
+
function hexToBytes(data) {
|
39
|
+
const sliced = data.startsWith("0x") ? data.substring(2) : data;
|
40
|
+
return (0, utils_1.hexToBytes)(sliced);
|
41
|
+
}
|
42
|
+
exports.hexToBytes = hexToBytes;
|
43
|
+
// buf.equals(buf2) -> equalsBytes(buf, buf2)
|
44
|
+
function equalsBytes(a, b) {
|
45
|
+
if (a.length !== b.length) {
|
46
|
+
return false;
|
47
|
+
}
|
48
|
+
for (let i = 0; i < a.length; i++) {
|
49
|
+
if (a[i] !== b[i]) {
|
50
|
+
return false;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
return true;
|
54
|
+
}
|
55
|
+
exports.equalsBytes = equalsBytes;
|
56
|
+
// Internal utils
|
57
|
+
function wrapHash(hash) {
|
58
|
+
return (msg) => {
|
59
|
+
_assert_1.default.bytes(msg);
|
60
|
+
return hash(msg);
|
61
|
+
};
|
62
|
+
}
|
63
|
+
exports.wrapHash = wrapHash;
|
64
|
+
exports.crypto = (() => {
|
65
|
+
const webCrypto = typeof self === "object" && "crypto" in self ? self.crypto : undefined;
|
66
|
+
const nodeRequire = typeof commonjsRequire === "function" &&
|
67
|
+
commonjsRequire.bind(module);
|
68
|
+
return {
|
69
|
+
node: nodeRequire && !webCrypto ? nodeRequire("crypto") : undefined,
|
70
|
+
web: webCrypto
|
71
|
+
};
|
72
|
+
})();
|
73
|
+
} (utils, utils.exports));
|
74
|
+
|
75
|
+
var utilsExports = utils.exports;
|
76
|
+
|
77
|
+
export { utilsExports as u };
|
@@ -0,0 +1,9 @@
|
|
1
|
+
export { default as v1 } from './v1.js';
|
2
|
+
export { default as v3 } from './v3.js';
|
3
|
+
export { default as v4 } from './v4.js';
|
4
|
+
export { default as v5 } from './v5.js';
|
5
|
+
export { default as NIL } from './nil.js';
|
6
|
+
export { default as version } from './version.js';
|
7
|
+
export { default as validate } from './validate.js';
|
8
|
+
export { default as stringify } from './stringify.js';
|
9
|
+
export { default as parse } from './parse.js';
|
@@ -0,0 +1,215 @@
|
|
1
|
+
/*
|
2
|
+
* Browser-compatible JavaScript MD5
|
3
|
+
*
|
4
|
+
* Modification of JavaScript MD5
|
5
|
+
* https://github.com/blueimp/JavaScript-MD5
|
6
|
+
*
|
7
|
+
* Copyright 2011, Sebastian Tschan
|
8
|
+
* https://blueimp.net
|
9
|
+
*
|
10
|
+
* Licensed under the MIT license:
|
11
|
+
* https://opensource.org/licenses/MIT
|
12
|
+
*
|
13
|
+
* Based on
|
14
|
+
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
|
15
|
+
* Digest Algorithm, as defined in RFC 1321.
|
16
|
+
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
|
17
|
+
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
18
|
+
* Distributed under the BSD License
|
19
|
+
* See http://pajhome.org.uk/crypt/md5 for more info.
|
20
|
+
*/
|
21
|
+
function md5(bytes) {
|
22
|
+
if (typeof bytes === 'string') {
|
23
|
+
var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
24
|
+
|
25
|
+
bytes = new Uint8Array(msg.length);
|
26
|
+
|
27
|
+
for (var i = 0; i < msg.length; ++i) {
|
28
|
+
bytes[i] = msg.charCodeAt(i);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
|
33
|
+
}
|
34
|
+
/*
|
35
|
+
* Convert an array of little-endian words to an array of bytes
|
36
|
+
*/
|
37
|
+
|
38
|
+
|
39
|
+
function md5ToHexEncodedArray(input) {
|
40
|
+
var output = [];
|
41
|
+
var length32 = input.length * 32;
|
42
|
+
var hexTab = '0123456789abcdef';
|
43
|
+
|
44
|
+
for (var i = 0; i < length32; i += 8) {
|
45
|
+
var x = input[i >> 5] >>> i % 32 & 0xff;
|
46
|
+
var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
|
47
|
+
output.push(hex);
|
48
|
+
}
|
49
|
+
|
50
|
+
return output;
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* Calculate output length with padding and bit length
|
54
|
+
*/
|
55
|
+
|
56
|
+
|
57
|
+
function getOutputLength(inputLength8) {
|
58
|
+
return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
|
59
|
+
}
|
60
|
+
/*
|
61
|
+
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
62
|
+
*/
|
63
|
+
|
64
|
+
|
65
|
+
function wordsToMd5(x, len) {
|
66
|
+
/* append padding */
|
67
|
+
x[len >> 5] |= 0x80 << len % 32;
|
68
|
+
x[getOutputLength(len) - 1] = len;
|
69
|
+
var a = 1732584193;
|
70
|
+
var b = -271733879;
|
71
|
+
var c = -1732584194;
|
72
|
+
var d = 271733878;
|
73
|
+
|
74
|
+
for (var i = 0; i < x.length; i += 16) {
|
75
|
+
var olda = a;
|
76
|
+
var oldb = b;
|
77
|
+
var oldc = c;
|
78
|
+
var oldd = d;
|
79
|
+
a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
80
|
+
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
81
|
+
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
82
|
+
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
83
|
+
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
84
|
+
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
85
|
+
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
86
|
+
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
87
|
+
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
88
|
+
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
89
|
+
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
90
|
+
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
91
|
+
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
92
|
+
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
93
|
+
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
94
|
+
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
95
|
+
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
96
|
+
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
97
|
+
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
98
|
+
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
99
|
+
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
100
|
+
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
101
|
+
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
102
|
+
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
103
|
+
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
104
|
+
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
105
|
+
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
106
|
+
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
107
|
+
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
108
|
+
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
109
|
+
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
110
|
+
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
111
|
+
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
112
|
+
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
113
|
+
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
114
|
+
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
115
|
+
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
116
|
+
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
117
|
+
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
118
|
+
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
119
|
+
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
120
|
+
d = md5hh(d, a, b, c, x[i], 11, -358537222);
|
121
|
+
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
122
|
+
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
123
|
+
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
124
|
+
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
125
|
+
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
126
|
+
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
127
|
+
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
128
|
+
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
129
|
+
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
130
|
+
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
131
|
+
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
132
|
+
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
133
|
+
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
134
|
+
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
135
|
+
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
136
|
+
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
137
|
+
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
138
|
+
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
139
|
+
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
140
|
+
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
141
|
+
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
142
|
+
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
143
|
+
a = safeAdd(a, olda);
|
144
|
+
b = safeAdd(b, oldb);
|
145
|
+
c = safeAdd(c, oldc);
|
146
|
+
d = safeAdd(d, oldd);
|
147
|
+
}
|
148
|
+
|
149
|
+
return [a, b, c, d];
|
150
|
+
}
|
151
|
+
/*
|
152
|
+
* Convert an array bytes to an array of little-endian words
|
153
|
+
* Characters >255 have their high-byte silently ignored.
|
154
|
+
*/
|
155
|
+
|
156
|
+
|
157
|
+
function bytesToWords(input) {
|
158
|
+
if (input.length === 0) {
|
159
|
+
return [];
|
160
|
+
}
|
161
|
+
|
162
|
+
var length8 = input.length * 8;
|
163
|
+
var output = new Uint32Array(getOutputLength(length8));
|
164
|
+
|
165
|
+
for (var i = 0; i < length8; i += 8) {
|
166
|
+
output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
|
167
|
+
}
|
168
|
+
|
169
|
+
return output;
|
170
|
+
}
|
171
|
+
/*
|
172
|
+
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
173
|
+
* to work around bugs in some JS interpreters.
|
174
|
+
*/
|
175
|
+
|
176
|
+
|
177
|
+
function safeAdd(x, y) {
|
178
|
+
var lsw = (x & 0xffff) + (y & 0xffff);
|
179
|
+
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
180
|
+
return msw << 16 | lsw & 0xffff;
|
181
|
+
}
|
182
|
+
/*
|
183
|
+
* Bitwise rotate a 32-bit number to the left.
|
184
|
+
*/
|
185
|
+
|
186
|
+
|
187
|
+
function bitRotateLeft(num, cnt) {
|
188
|
+
return num << cnt | num >>> 32 - cnt;
|
189
|
+
}
|
190
|
+
/*
|
191
|
+
* These functions implement the four basic operations the algorithm uses.
|
192
|
+
*/
|
193
|
+
|
194
|
+
|
195
|
+
function md5cmn(q, a, b, x, s, t) {
|
196
|
+
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
197
|
+
}
|
198
|
+
|
199
|
+
function md5ff(a, b, c, d, x, s, t) {
|
200
|
+
return md5cmn(b & c | ~b & d, a, b, x, s, t);
|
201
|
+
}
|
202
|
+
|
203
|
+
function md5gg(a, b, c, d, x, s, t) {
|
204
|
+
return md5cmn(b & d | c & ~d, a, b, x, s, t);
|
205
|
+
}
|
206
|
+
|
207
|
+
function md5hh(a, b, c, d, x, s, t) {
|
208
|
+
return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
209
|
+
}
|
210
|
+
|
211
|
+
function md5ii(a, b, c, d, x, s, t) {
|
212
|
+
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
213
|
+
}
|
214
|
+
|
215
|
+
export { md5 as default };
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import validate from './validate.js';
|
2
|
+
|
3
|
+
function parse(uuid) {
|
4
|
+
if (!validate(uuid)) {
|
5
|
+
throw TypeError('Invalid UUID');
|
6
|
+
}
|
7
|
+
|
8
|
+
var v;
|
9
|
+
var arr = new Uint8Array(16); // Parse ########-....-....-....-............
|
10
|
+
|
11
|
+
arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
12
|
+
arr[1] = v >>> 16 & 0xff;
|
13
|
+
arr[2] = v >>> 8 & 0xff;
|
14
|
+
arr[3] = v & 0xff; // Parse ........-####-....-....-............
|
15
|
+
|
16
|
+
arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
17
|
+
arr[5] = v & 0xff; // Parse ........-....-####-....-............
|
18
|
+
|
19
|
+
arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
20
|
+
arr[7] = v & 0xff; // Parse ........-....-....-####-............
|
21
|
+
|
22
|
+
arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
23
|
+
arr[9] = v & 0xff; // Parse ........-....-....-....-############
|
24
|
+
// (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
|
25
|
+
|
26
|
+
arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
|
27
|
+
arr[11] = v / 0x100000000 & 0xff;
|
28
|
+
arr[12] = v >>> 24 & 0xff;
|
29
|
+
arr[13] = v >>> 16 & 0xff;
|
30
|
+
arr[14] = v >>> 8 & 0xff;
|
31
|
+
arr[15] = v & 0xff;
|
32
|
+
return arr;
|
33
|
+
}
|
34
|
+
|
35
|
+
export { parse as default };
|
@@ -0,0 +1,21 @@
|
|
1
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
2
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
3
|
+
// generators (like Math.random()).
|
4
|
+
var getRandomValues;
|
5
|
+
var rnds8 = new Uint8Array(16);
|
6
|
+
function rng() {
|
7
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
8
|
+
if (!getRandomValues) {
|
9
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
|
10
|
+
// find the complete implementation of crypto (msCrypto) on IE11.
|
11
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
|
12
|
+
|
13
|
+
if (!getRandomValues) {
|
14
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
return getRandomValues(rnds8);
|
19
|
+
}
|
20
|
+
|
21
|
+
export { rng as default };
|