@waku/rln 0.1.3 → 0.1.4-2a94244.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,438 @@
|
|
1
|
+
import { encodeUint8Array, encodingLength } from '../../../../uint8-varint/dist/src/index.js';
|
2
|
+
import { allocUnsafe } from '../../../../uint8arrays/dist/src/alloc.js';
|
3
|
+
import { fromString } from '../../../../uint8arrays/dist/src/from-string.js';
|
4
|
+
import { writeFloatLE, writeDoubleLE } from './float.js';
|
5
|
+
import { LongBits } from './longbits.js';
|
6
|
+
import pool from './pool.js';
|
7
|
+
import { length, write } from './utf8.js';
|
8
|
+
|
9
|
+
/**
|
10
|
+
* Constructs a new writer operation instance.
|
11
|
+
*
|
12
|
+
* @classdesc Scheduled writer operation
|
13
|
+
*/
|
14
|
+
class Op {
|
15
|
+
/**
|
16
|
+
* Function to call
|
17
|
+
*/
|
18
|
+
fn;
|
19
|
+
/**
|
20
|
+
* Value byte length
|
21
|
+
*/
|
22
|
+
len;
|
23
|
+
/**
|
24
|
+
* Next operation
|
25
|
+
*/
|
26
|
+
next;
|
27
|
+
/**
|
28
|
+
* Value to write
|
29
|
+
*/
|
30
|
+
val;
|
31
|
+
constructor(fn, len, val) {
|
32
|
+
this.fn = fn;
|
33
|
+
this.len = len;
|
34
|
+
this.next = undefined;
|
35
|
+
this.val = val; // type varies
|
36
|
+
}
|
37
|
+
}
|
38
|
+
/* istanbul ignore next */
|
39
|
+
function noop() { } // eslint-disable-line no-empty-function
|
40
|
+
/**
|
41
|
+
* Constructs a new writer state instance
|
42
|
+
*/
|
43
|
+
class State {
|
44
|
+
/**
|
45
|
+
* Current head
|
46
|
+
*/
|
47
|
+
head;
|
48
|
+
/**
|
49
|
+
* Current tail
|
50
|
+
*/
|
51
|
+
tail;
|
52
|
+
/**
|
53
|
+
* Current buffer length
|
54
|
+
*/
|
55
|
+
len;
|
56
|
+
/**
|
57
|
+
* Next state
|
58
|
+
*/
|
59
|
+
next;
|
60
|
+
constructor(writer) {
|
61
|
+
this.head = writer.head;
|
62
|
+
this.tail = writer.tail;
|
63
|
+
this.len = writer.len;
|
64
|
+
this.next = writer.states;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
const bufferPool = pool();
|
68
|
+
/**
|
69
|
+
* Allocates a buffer of the specified size
|
70
|
+
*/
|
71
|
+
function alloc(size) {
|
72
|
+
if (globalThis.Buffer != null) {
|
73
|
+
return allocUnsafe(size);
|
74
|
+
}
|
75
|
+
return bufferPool(size);
|
76
|
+
}
|
77
|
+
/**
|
78
|
+
* When a value is written, the writer calculates its byte length and puts it into a linked
|
79
|
+
* list of operations to perform when finish() is called. This both allows us to allocate
|
80
|
+
* buffers of the exact required size and reduces the amount of work we have to do compared
|
81
|
+
* to first calculating over objects and then encoding over objects. In our case, the encoding
|
82
|
+
* part is just a linked list walk calling operations with already prepared values.
|
83
|
+
*/
|
84
|
+
class Uint8ArrayWriter {
|
85
|
+
/**
|
86
|
+
* Current length
|
87
|
+
*/
|
88
|
+
len;
|
89
|
+
/**
|
90
|
+
* Operations head
|
91
|
+
*/
|
92
|
+
head;
|
93
|
+
/**
|
94
|
+
* Operations tail
|
95
|
+
*/
|
96
|
+
tail;
|
97
|
+
/**
|
98
|
+
* Linked forked states
|
99
|
+
*/
|
100
|
+
states;
|
101
|
+
constructor() {
|
102
|
+
this.len = 0;
|
103
|
+
this.head = new Op(noop, 0, 0);
|
104
|
+
this.tail = this.head;
|
105
|
+
this.states = null;
|
106
|
+
}
|
107
|
+
/**
|
108
|
+
* Pushes a new operation to the queue
|
109
|
+
*/
|
110
|
+
_push(fn, len, val) {
|
111
|
+
this.tail = this.tail.next = new Op(fn, len, val);
|
112
|
+
this.len += len;
|
113
|
+
return this;
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* Writes an unsigned 32 bit value as a varint
|
117
|
+
*/
|
118
|
+
uint32(value) {
|
119
|
+
// here, the call to this.push has been inlined and a varint specific Op subclass is used.
|
120
|
+
// uint32 is by far the most frequently used operation and benefits significantly from this.
|
121
|
+
this.len += (this.tail = this.tail.next = new VarintOp((value = value >>> 0) <
|
122
|
+
128
|
123
|
+
? 1
|
124
|
+
: value < 16384
|
125
|
+
? 2
|
126
|
+
: value < 2097152
|
127
|
+
? 3
|
128
|
+
: value < 268435456
|
129
|
+
? 4
|
130
|
+
: 5, value)).len;
|
131
|
+
return this;
|
132
|
+
}
|
133
|
+
/**
|
134
|
+
* Writes a signed 32 bit value as a varint`
|
135
|
+
*/
|
136
|
+
int32(value) {
|
137
|
+
return value < 0
|
138
|
+
? this._push(writeVarint64, 10, LongBits.fromNumber(value)) // 10 bytes per spec
|
139
|
+
: this.uint32(value);
|
140
|
+
}
|
141
|
+
/**
|
142
|
+
* Writes a 32 bit value as a varint, zig-zag encoded
|
143
|
+
*/
|
144
|
+
sint32(value) {
|
145
|
+
return this.uint32((value << 1 ^ value >> 31) >>> 0);
|
146
|
+
}
|
147
|
+
/**
|
148
|
+
* Writes an unsigned 64 bit value as a varint
|
149
|
+
*/
|
150
|
+
uint64(value) {
|
151
|
+
const bits = LongBits.fromBigInt(value);
|
152
|
+
return this._push(writeVarint64, bits.length(), bits);
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* Writes an unsigned 64 bit value as a varint
|
156
|
+
*/
|
157
|
+
uint64Number(value) {
|
158
|
+
return this._push(encodeUint8Array, encodingLength(value), value);
|
159
|
+
}
|
160
|
+
/**
|
161
|
+
* Writes an unsigned 64 bit value as a varint
|
162
|
+
*/
|
163
|
+
uint64String(value) {
|
164
|
+
return this.uint64(BigInt(value));
|
165
|
+
}
|
166
|
+
/**
|
167
|
+
* Writes a signed 64 bit value as a varint
|
168
|
+
*/
|
169
|
+
int64(value) {
|
170
|
+
return this.uint64(value);
|
171
|
+
}
|
172
|
+
/**
|
173
|
+
* Writes a signed 64 bit value as a varint
|
174
|
+
*/
|
175
|
+
int64Number(value) {
|
176
|
+
return this.uint64Number(value);
|
177
|
+
}
|
178
|
+
/**
|
179
|
+
* Writes a signed 64 bit value as a varint
|
180
|
+
*/
|
181
|
+
int64String(value) {
|
182
|
+
return this.uint64String(value);
|
183
|
+
}
|
184
|
+
/**
|
185
|
+
* Writes a signed 64 bit value as a varint, zig-zag encoded
|
186
|
+
*/
|
187
|
+
sint64(value) {
|
188
|
+
const bits = LongBits.fromBigInt(value).zzEncode();
|
189
|
+
return this._push(writeVarint64, bits.length(), bits);
|
190
|
+
}
|
191
|
+
/**
|
192
|
+
* Writes a signed 64 bit value as a varint, zig-zag encoded
|
193
|
+
*/
|
194
|
+
sint64Number(value) {
|
195
|
+
const bits = LongBits.fromNumber(value).zzEncode();
|
196
|
+
return this._push(writeVarint64, bits.length(), bits);
|
197
|
+
}
|
198
|
+
/**
|
199
|
+
* Writes a signed 64 bit value as a varint, zig-zag encoded
|
200
|
+
*/
|
201
|
+
sint64String(value) {
|
202
|
+
return this.sint64(BigInt(value));
|
203
|
+
}
|
204
|
+
/**
|
205
|
+
* Writes a boolish value as a varint
|
206
|
+
*/
|
207
|
+
bool(value) {
|
208
|
+
return this._push(writeByte, 1, value ? 1 : 0);
|
209
|
+
}
|
210
|
+
/**
|
211
|
+
* Writes an unsigned 32 bit value as fixed 32 bits
|
212
|
+
*/
|
213
|
+
fixed32(value) {
|
214
|
+
return this._push(writeFixed32, 4, value >>> 0);
|
215
|
+
}
|
216
|
+
/**
|
217
|
+
* Writes a signed 32 bit value as fixed 32 bits
|
218
|
+
*/
|
219
|
+
sfixed32(value) {
|
220
|
+
return this.fixed32(value);
|
221
|
+
}
|
222
|
+
/**
|
223
|
+
* Writes an unsigned 64 bit value as fixed 64 bits
|
224
|
+
*/
|
225
|
+
fixed64(value) {
|
226
|
+
const bits = LongBits.fromBigInt(value);
|
227
|
+
return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
|
228
|
+
}
|
229
|
+
/**
|
230
|
+
* Writes an unsigned 64 bit value as fixed 64 bits
|
231
|
+
*/
|
232
|
+
fixed64Number(value) {
|
233
|
+
const bits = LongBits.fromNumber(value);
|
234
|
+
return this._push(writeFixed32, 4, bits.lo)._push(writeFixed32, 4, bits.hi);
|
235
|
+
}
|
236
|
+
/**
|
237
|
+
* Writes an unsigned 64 bit value as fixed 64 bits
|
238
|
+
*/
|
239
|
+
fixed64String(value) {
|
240
|
+
return this.fixed64(BigInt(value));
|
241
|
+
}
|
242
|
+
/**
|
243
|
+
* Writes a signed 64 bit value as fixed 64 bits
|
244
|
+
*/
|
245
|
+
sfixed64(value) {
|
246
|
+
return this.fixed64(value);
|
247
|
+
}
|
248
|
+
/**
|
249
|
+
* Writes a signed 64 bit value as fixed 64 bits
|
250
|
+
*/
|
251
|
+
sfixed64Number(value) {
|
252
|
+
return this.fixed64Number(value);
|
253
|
+
}
|
254
|
+
/**
|
255
|
+
* Writes a signed 64 bit value as fixed 64 bits
|
256
|
+
*/
|
257
|
+
sfixed64String(value) {
|
258
|
+
return this.fixed64String(value);
|
259
|
+
}
|
260
|
+
/**
|
261
|
+
* Writes a float (32 bit)
|
262
|
+
*/
|
263
|
+
float(value) {
|
264
|
+
return this._push(writeFloatLE, 4, value);
|
265
|
+
}
|
266
|
+
/**
|
267
|
+
* Writes a double (64 bit float).
|
268
|
+
*
|
269
|
+
* @function
|
270
|
+
* @param {number} value - Value to write
|
271
|
+
* @returns {Writer} `this`
|
272
|
+
*/
|
273
|
+
double(value) {
|
274
|
+
return this._push(writeDoubleLE, 8, value);
|
275
|
+
}
|
276
|
+
/**
|
277
|
+
* Writes a sequence of bytes
|
278
|
+
*/
|
279
|
+
bytes(value) {
|
280
|
+
const len = value.length >>> 0;
|
281
|
+
if (len === 0) {
|
282
|
+
return this._push(writeByte, 1, 0);
|
283
|
+
}
|
284
|
+
return this.uint32(len)._push(writeBytes, len, value);
|
285
|
+
}
|
286
|
+
/**
|
287
|
+
* Writes a string
|
288
|
+
*/
|
289
|
+
string(value) {
|
290
|
+
const len = length(value);
|
291
|
+
return len !== 0
|
292
|
+
? this.uint32(len)._push(write, len, value)
|
293
|
+
: this._push(writeByte, 1, 0);
|
294
|
+
}
|
295
|
+
/**
|
296
|
+
* Forks this writer's state by pushing it to a stack.
|
297
|
+
* Calling {@link Writer#reset|reset} or {@link Writer#ldelim|ldelim} resets the writer to the previous state.
|
298
|
+
*/
|
299
|
+
fork() {
|
300
|
+
this.states = new State(this);
|
301
|
+
this.head = this.tail = new Op(noop, 0, 0);
|
302
|
+
this.len = 0;
|
303
|
+
return this;
|
304
|
+
}
|
305
|
+
/**
|
306
|
+
* Resets this instance to the last state
|
307
|
+
*/
|
308
|
+
reset() {
|
309
|
+
if (this.states != null) {
|
310
|
+
this.head = this.states.head;
|
311
|
+
this.tail = this.states.tail;
|
312
|
+
this.len = this.states.len;
|
313
|
+
this.states = this.states.next;
|
314
|
+
}
|
315
|
+
else {
|
316
|
+
this.head = this.tail = new Op(noop, 0, 0);
|
317
|
+
this.len = 0;
|
318
|
+
}
|
319
|
+
return this;
|
320
|
+
}
|
321
|
+
/**
|
322
|
+
* Resets to the last state and appends the fork state's current write length as a varint followed by its operations.
|
323
|
+
*/
|
324
|
+
ldelim() {
|
325
|
+
const head = this.head;
|
326
|
+
const tail = this.tail;
|
327
|
+
const len = this.len;
|
328
|
+
this.reset().uint32(len);
|
329
|
+
if (len !== 0) {
|
330
|
+
this.tail.next = head.next; // skip noop
|
331
|
+
this.tail = tail;
|
332
|
+
this.len += len;
|
333
|
+
}
|
334
|
+
return this;
|
335
|
+
}
|
336
|
+
/**
|
337
|
+
* Finishes the write operation
|
338
|
+
*/
|
339
|
+
finish() {
|
340
|
+
let head = this.head.next; // skip noop
|
341
|
+
const buf = alloc(this.len);
|
342
|
+
let pos = 0;
|
343
|
+
while (head != null) {
|
344
|
+
head.fn(head.val, buf, pos);
|
345
|
+
pos += head.len;
|
346
|
+
head = head.next;
|
347
|
+
}
|
348
|
+
// this.head = this.tail = null;
|
349
|
+
return buf;
|
350
|
+
}
|
351
|
+
}
|
352
|
+
function writeByte(val, buf, pos) {
|
353
|
+
buf[pos] = val & 255;
|
354
|
+
}
|
355
|
+
function writeVarint32(val, buf, pos) {
|
356
|
+
while (val > 127) {
|
357
|
+
buf[pos++] = val & 127 | 128;
|
358
|
+
val >>>= 7;
|
359
|
+
}
|
360
|
+
buf[pos] = val;
|
361
|
+
}
|
362
|
+
/**
|
363
|
+
* Constructs a new varint writer operation instance.
|
364
|
+
*
|
365
|
+
* @classdesc Scheduled varint writer operation
|
366
|
+
*/
|
367
|
+
class VarintOp extends Op {
|
368
|
+
next;
|
369
|
+
constructor(len, val) {
|
370
|
+
super(writeVarint32, len, val);
|
371
|
+
this.next = undefined;
|
372
|
+
}
|
373
|
+
}
|
374
|
+
function writeVarint64(val, buf, pos) {
|
375
|
+
while (val.hi !== 0) {
|
376
|
+
buf[pos++] = val.lo & 127 | 128;
|
377
|
+
val.lo = (val.lo >>> 7 | val.hi << 25) >>> 0;
|
378
|
+
val.hi >>>= 7;
|
379
|
+
}
|
380
|
+
while (val.lo > 127) {
|
381
|
+
buf[pos++] = val.lo & 127 | 128;
|
382
|
+
val.lo = val.lo >>> 7;
|
383
|
+
}
|
384
|
+
buf[pos++] = val.lo;
|
385
|
+
}
|
386
|
+
function writeFixed32(val, buf, pos) {
|
387
|
+
buf[pos] = val & 255;
|
388
|
+
buf[pos + 1] = val >>> 8 & 255;
|
389
|
+
buf[pos + 2] = val >>> 16 & 255;
|
390
|
+
buf[pos + 3] = val >>> 24;
|
391
|
+
}
|
392
|
+
function writeBytes(val, buf, pos) {
|
393
|
+
buf.set(val, pos);
|
394
|
+
}
|
395
|
+
if (globalThis.Buffer != null) {
|
396
|
+
Uint8ArrayWriter.prototype.bytes = function (value) {
|
397
|
+
const len = value.length >>> 0;
|
398
|
+
this.uint32(len);
|
399
|
+
if (len > 0) {
|
400
|
+
this._push(writeBytesBuffer, len, value);
|
401
|
+
}
|
402
|
+
return this;
|
403
|
+
};
|
404
|
+
Uint8ArrayWriter.prototype.string = function (value) {
|
405
|
+
const len = globalThis.Buffer.byteLength(value);
|
406
|
+
this.uint32(len);
|
407
|
+
if (len > 0) {
|
408
|
+
this._push(writeStringBuffer, len, value);
|
409
|
+
}
|
410
|
+
return this;
|
411
|
+
};
|
412
|
+
}
|
413
|
+
function writeBytesBuffer(val, buf, pos) {
|
414
|
+
buf.set(val, pos); // faster than copy (requires node >= 4 where Buffers extend Uint8Array and set is properly inherited)
|
415
|
+
// also works for plain array values
|
416
|
+
}
|
417
|
+
function writeStringBuffer(val, buf, pos) {
|
418
|
+
if (val.length < 40) {
|
419
|
+
// plain js is faster for short strings (probably due to redundant assertions)
|
420
|
+
write(val, buf, pos);
|
421
|
+
// @ts-expect-error buf isn't a Uint8Array?
|
422
|
+
}
|
423
|
+
else if (buf.utf8Write != null) {
|
424
|
+
// @ts-expect-error buf isn't a Uint8Array?
|
425
|
+
buf.utf8Write(val, pos);
|
426
|
+
}
|
427
|
+
else {
|
428
|
+
buf.set(fromString(val), pos);
|
429
|
+
}
|
430
|
+
}
|
431
|
+
/**
|
432
|
+
* Creates a new writer
|
433
|
+
*/
|
434
|
+
function createWriter() {
|
435
|
+
return new Uint8ArrayWriter();
|
436
|
+
}
|
437
|
+
|
438
|
+
export { createWriter };
|
@@ -0,0 +1,124 @@
|
|
1
|
+
/* eslint-disable no-fallthrough */
|
2
|
+
const N1 = Math.pow(2, 7);
|
3
|
+
const N2 = Math.pow(2, 14);
|
4
|
+
const N3 = Math.pow(2, 21);
|
5
|
+
const N4 = Math.pow(2, 28);
|
6
|
+
const N5 = Math.pow(2, 35);
|
7
|
+
const N6 = Math.pow(2, 42);
|
8
|
+
const N7 = Math.pow(2, 49);
|
9
|
+
/** Most significant bit of a byte */
|
10
|
+
const MSB = 0x80;
|
11
|
+
/** Rest of the bits in a byte */
|
12
|
+
const REST = 0x7f;
|
13
|
+
function encodingLength(value) {
|
14
|
+
if (value < N1) {
|
15
|
+
return 1;
|
16
|
+
}
|
17
|
+
if (value < N2) {
|
18
|
+
return 2;
|
19
|
+
}
|
20
|
+
if (value < N3) {
|
21
|
+
return 3;
|
22
|
+
}
|
23
|
+
if (value < N4) {
|
24
|
+
return 4;
|
25
|
+
}
|
26
|
+
if (value < N5) {
|
27
|
+
return 5;
|
28
|
+
}
|
29
|
+
if (value < N6) {
|
30
|
+
return 6;
|
31
|
+
}
|
32
|
+
if (value < N7) {
|
33
|
+
return 7;
|
34
|
+
}
|
35
|
+
if (Number.MAX_SAFE_INTEGER != null && value > Number.MAX_SAFE_INTEGER) {
|
36
|
+
throw new RangeError('Could not encode varint');
|
37
|
+
}
|
38
|
+
return 8;
|
39
|
+
}
|
40
|
+
function encodeUint8Array(value, buf, offset = 0) {
|
41
|
+
switch (encodingLength(value)) {
|
42
|
+
case 8: {
|
43
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
44
|
+
value /= 128;
|
45
|
+
}
|
46
|
+
case 7: {
|
47
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
48
|
+
value /= 128;
|
49
|
+
}
|
50
|
+
case 6: {
|
51
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
52
|
+
value /= 128;
|
53
|
+
}
|
54
|
+
case 5: {
|
55
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
56
|
+
value /= 128;
|
57
|
+
}
|
58
|
+
case 4: {
|
59
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
60
|
+
value >>>= 7;
|
61
|
+
}
|
62
|
+
case 3: {
|
63
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
64
|
+
value >>>= 7;
|
65
|
+
}
|
66
|
+
case 2: {
|
67
|
+
buf[offset++] = (value & 0xFF) | MSB;
|
68
|
+
value >>>= 7;
|
69
|
+
}
|
70
|
+
case 1: {
|
71
|
+
buf[offset++] = (value & 0xFF);
|
72
|
+
value >>>= 7;
|
73
|
+
break;
|
74
|
+
}
|
75
|
+
default: throw new Error('unreachable');
|
76
|
+
}
|
77
|
+
return buf;
|
78
|
+
}
|
79
|
+
function decodeUint8Array(buf, offset) {
|
80
|
+
let b = buf[offset];
|
81
|
+
let res = 0;
|
82
|
+
res += b & REST;
|
83
|
+
if (b < MSB) {
|
84
|
+
return res;
|
85
|
+
}
|
86
|
+
b = buf[offset + 1];
|
87
|
+
res += (b & REST) << 7;
|
88
|
+
if (b < MSB) {
|
89
|
+
return res;
|
90
|
+
}
|
91
|
+
b = buf[offset + 2];
|
92
|
+
res += (b & REST) << 14;
|
93
|
+
if (b < MSB) {
|
94
|
+
return res;
|
95
|
+
}
|
96
|
+
b = buf[offset + 3];
|
97
|
+
res += (b & REST) << 21;
|
98
|
+
if (b < MSB) {
|
99
|
+
return res;
|
100
|
+
}
|
101
|
+
b = buf[offset + 4];
|
102
|
+
res += (b & REST) * N4;
|
103
|
+
if (b < MSB) {
|
104
|
+
return res;
|
105
|
+
}
|
106
|
+
b = buf[offset + 5];
|
107
|
+
res += (b & REST) * N5;
|
108
|
+
if (b < MSB) {
|
109
|
+
return res;
|
110
|
+
}
|
111
|
+
b = buf[offset + 6];
|
112
|
+
res += (b & REST) * N6;
|
113
|
+
if (b < MSB) {
|
114
|
+
return res;
|
115
|
+
}
|
116
|
+
b = buf[offset + 7];
|
117
|
+
res += (b & REST) * N7;
|
118
|
+
if (b < MSB) {
|
119
|
+
return res;
|
120
|
+
}
|
121
|
+
throw new RangeError('Could not decode varint');
|
122
|
+
}
|
123
|
+
|
124
|
+
export { decodeUint8Array, encodeUint8Array, encodingLength };
|
@@ -0,0 +1,17 @@
|
|
1
|
+
/**
|
2
|
+
* Returns a `Uint8Array` of the requested size. Referenced memory will
|
3
|
+
* be initialized to 0.
|
4
|
+
*/
|
5
|
+
function alloc(size = 0) {
|
6
|
+
return new Uint8Array(size);
|
7
|
+
}
|
8
|
+
/**
|
9
|
+
* Where possible returns a Uint8Array of the requested size that references
|
10
|
+
* uninitialized memory. Only use if you are certain you will immediately
|
11
|
+
* overwrite every value in the returned `Uint8Array`.
|
12
|
+
*/
|
13
|
+
function allocUnsafe(size = 0) {
|
14
|
+
return new Uint8Array(size);
|
15
|
+
}
|
16
|
+
|
17
|
+
export { alloc, allocUnsafe };
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import BASES from './util/bases.js';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Create a `Uint8Array` from the passed string
|
5
|
+
*
|
6
|
+
* Supports `utf8`, `utf-8`, `hex`, and any encoding supported by the multiformats module.
|
7
|
+
*
|
8
|
+
* Also `ascii` which is similar to node's 'binary' encoding.
|
9
|
+
*/
|
10
|
+
function fromString(string, encoding = 'utf8') {
|
11
|
+
const base = BASES[encoding];
|
12
|
+
if (base == null) {
|
13
|
+
throw new Error(`Unsupported encoding "${encoding}"`);
|
14
|
+
}
|
15
|
+
// add multibase prefix
|
16
|
+
return base.decoder.decode(`${base.prefix}${string}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
|
17
|
+
}
|
18
|
+
|
19
|
+
export { fromString };
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { bases } from '../../../../multiformats/dist/src/basics.js';
|
2
|
+
import { allocUnsafe } from '../alloc.js';
|
3
|
+
|
4
|
+
function createCodec(name, prefix, encode, decode) {
|
5
|
+
return {
|
6
|
+
name,
|
7
|
+
prefix,
|
8
|
+
encoder: {
|
9
|
+
name,
|
10
|
+
prefix,
|
11
|
+
encode
|
12
|
+
},
|
13
|
+
decoder: {
|
14
|
+
decode
|
15
|
+
}
|
16
|
+
};
|
17
|
+
}
|
18
|
+
const string = createCodec('utf8', 'u', (buf) => {
|
19
|
+
const decoder = new TextDecoder('utf8');
|
20
|
+
return 'u' + decoder.decode(buf);
|
21
|
+
}, (str) => {
|
22
|
+
const encoder = new TextEncoder();
|
23
|
+
return encoder.encode(str.substring(1));
|
24
|
+
});
|
25
|
+
const ascii = createCodec('ascii', 'a', (buf) => {
|
26
|
+
let string = 'a';
|
27
|
+
for (let i = 0; i < buf.length; i++) {
|
28
|
+
string += String.fromCharCode(buf[i]);
|
29
|
+
}
|
30
|
+
return string;
|
31
|
+
}, (str) => {
|
32
|
+
str = str.substring(1);
|
33
|
+
const buf = allocUnsafe(str.length);
|
34
|
+
for (let i = 0; i < str.length; i++) {
|
35
|
+
buf[i] = str.charCodeAt(i);
|
36
|
+
}
|
37
|
+
return buf;
|
38
|
+
});
|
39
|
+
const BASES = {
|
40
|
+
utf8: string,
|
41
|
+
'utf-8': string,
|
42
|
+
hex: bases.base16,
|
43
|
+
latin1: ascii,
|
44
|
+
ascii,
|
45
|
+
binary: ascii,
|
46
|
+
...bases
|
47
|
+
};
|
48
|
+
|
49
|
+
export { BASES as default };
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import '../../../../../node_modules/@multiformats/multiaddr/dist/src/multiaddr.js';
|
2
|
+
import '../../../../../node_modules/@multiformats/multiaddr/dist/src/protocols-table.js';
|
3
|
+
import '../../../../../node_modules/@multiformats/multiaddr/dist/src/convert.js';
|
4
|
+
import '../../../../interfaces/dist/protocols.js';
|
5
|
+
import '../../../../interfaces/dist/connection_manager.js';
|
6
|
+
import '../../../../interfaces/dist/health_indicator.js';
|
7
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
|
8
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
|
9
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
|
10
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base256emoji.js';
|
11
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base32.js';
|
12
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base36.js';
|
13
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base58.js';
|
14
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base64.js';
|
15
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base8.js';
|
16
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/identity.js';
|
17
|
+
import '../../../../../node_modules/multiformats/dist/src/codecs/json.js';
|
18
|
+
import { Logger } from '../../../../utils/dist/logger/index.js';
|
19
|
+
import './keep_alive_manager.js';
|
20
|
+
|
21
|
+
new Logger("connection-manager");
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import '../../../../interfaces/dist/protocols.js';
|
2
|
+
import '../../../../interfaces/dist/connection_manager.js';
|
3
|
+
import '../../../../interfaces/dist/health_indicator.js';
|
4
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base10.js';
|
5
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base16.js';
|
6
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base2.js';
|
7
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base256emoji.js';
|
8
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base32.js';
|
9
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base36.js';
|
10
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base58.js';
|
11
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base64.js';
|
12
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/base8.js';
|
13
|
+
import '../../../../../node_modules/multiformats/dist/src/bases/identity.js';
|
14
|
+
import '../../../../../node_modules/multiformats/dist/src/codecs/json.js';
|
15
|
+
import { Logger } from '../../../../utils/dist/logger/index.js';
|
16
|
+
import '../message/version_0.js';
|
17
|
+
|
18
|
+
new Logger("keep-alive");
|