Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

EOSJS v21.0.2 Release Notes

Compare
Choose a tag to compare
@blockone-devops blockone-devops released this 14 Jul 20:25
· 705 commits to master since this release
203e13e

Note: Since this release promotes EOSJS v21.0.2-rc3 to v21.0.2 (stable), using the @latest tag will now automatically cause an upgrade from v20.0.x to v21.0.2.

Switch to elliptic cryptography library

eosjs-ecc has been replaced with the elliptic cryptographic library. The eosjs public API has been maintained; this is only a change to the internals.

Conversion Helpers To/From elliptic lib's Format

elliptic stores keys and signatures differently than eosjs-ecc. For ease of use, conversion functions have been added. These are primarily located in src/eosjs-key-conversions.ts as well as re-exported in src/eosjs-jssig.ts. Usage examples of each can be found in src/tests/eosjs-jssig.test.ts. A glimpse of the functions follows:

// Private Key from EOSIO PUB_K1_ string format to `elliptic` and back
const privEllipticKey = PrivateKey.fromString(eosioK1PrivateKeyAsString).toElliptic();
const finalEosioKeyAsK1String = PrivateKey.fromElliptic(privEllipticKey).toString();

// Public Key from EOSIO PUB_K1_ string format to Elliptic and back
const ellipticPubKey = PublicKey.fromString(eosioK1PubKeyAsString).toElliptic();
const finalEosioKeyAsK1String = PublicKey.fromElliptic(ellipticPubKey).toString();

// Signature from EOS string format to `elliptic` and back
const ellipticSig = Signature.fromString(eosioSignatureAsString).toElliptic();
const finalEosioSignatureAsString = Signature.fromElliptic(ellipticSig).toString();

// Perform digest of data
digestFromSerializedData()  // wraps the construction of a digest from the data being digested

Additional Helpers with elliptic

elliptic has methods to sign, verify, and recover keys and signatures. For ease of use, helper functions that perform the conversion and operation of those methods have been added. These are added to PublicKey, PrivateKey, and Signature classes located in src/eosjs-key-conversions.ts as well as re-exported in src/eosjs-jssig.ts. Usage examples of each can be found in src/tests/eosjs-jssig.test.ts. Additionally, sha256 and generateKeyPair are available in src/eosjs-key-conversions.ts. A glimpse of the functions follows:

// Create a message digest with sha256
const digest = sha256(message);

// Generate a Key Pair with specified curve key type.  Intended for non-browser environments or development
const { publicKey, privateKey } = generateKeyPair(KeyType.k1);

// Export private key as Legacy EOSIO-format private key
const privateKey = PrivateKey.fromString(eosioK1PrivateKeyAsString);
const legacyPrivateKey = privateKey.getLegacyString();

// Export public key as Legacy EOSIO-format public key
const publicKey = PublicKey.fromString(eosioK1PubKeyAsString);
const legacyPublicKey = publicKey.getLegacyString();

// Retrieve the public key from a private key
const privateKey = PrivateKey.fromString(eosioK1PrivateKeyAsString);
const publicKey = privateKey.getPublicKey();

// Sign a message digest with private key
const digest = sha256(message); // optional, setting shouldHash to true will hash the message
const privateKey = PrivateKey.fromString(eosioK1PrivateKeyAsString);
const signature = privateKey.sign(digest, false);

// Validate a private key
const privateKey = PrivateKey.fromString(eosioK1PrivateKeyAsString);
const valid = publicKey.isValid();

// Validate a public key
const publicKey = PublicKey.fromString(eosioK1PubKeyAsString);
const valid = publicKey.isValid();

// Verify a signature with a message digest and public key
const digest = sha256(message); // optional, setting shouldHash to true will hash the message
const publicKey = PublicKey.fromString(eosioK1PubKeyAsString);
const signature = Signature.fromString(eosioSignatureAsString);
const verified = signature.verify(digest, publicKey, false);

// Recover a public key from a message digest and signature
const digest = sha256(message); // optional, setting shouldHash to true will hash the message
const signature = Signature.fromString(eosioSignatureAsString);
const publicKey = signature.recover(digest, false);

eosjs-ecc Migration Guide

In an effort to make migration easier from eosjs-ecc, a new module from eosjs-ecc-migration.ts is available that provides many of the eosjs-ecc methods. These methods are available to be used for easy migration to this new version but additionally as guides to how to convert code to use the new elliptic helper methods and new key formats. This module will be removed at a later release.

React Native Support

There was a problem using EOSJS v20 with React Native that stemmed from an eosjs-ecc dependency only being compatible with IE11, Chrome, and Safari. Now that eosjs-ecc has been removed, React Native is now fully supported in eosjs.

Context-free Actions Support

Context-free actions are now supported in eosjs.

WebAuthn Support

Read more about WebAuthn support in the EOSIO 2.0 Medium article. For technical details, see the PR.

We have updated the Tropical Example app to demonstrate a use of Webauthn.

BREAKING CHANGE: /v1/chain/get_table_rows table_key parameter deprecated

table_key has been deprecated on the chain_plugin. Replace usages of table_key with index_position and use the position of the index where 1 is your primary (first), 2 is your secondary index (in order defined by multi_index), 3 is third index, etc

BREAKING CHANGE: Minified file convention

yarn build-web command will create both debug and minified files in the dist-web location. Please use the minified *.min.js files in production and only use the debug files for development as they are over 10 times as large as the minified versions, and importing the debug versions will increase loading times for the end user.

Transaction compression and useLastIrreversible

Adding the compression argument to transaction methods will use compression for the transaction. Adding the useLastIrreversible argument to transaciton methods will use the last irreversible block number for the transaction TAPOS headers.

Other Changes

  • (#534) Add get_scheduled_transactions to jsonrpc
  • (#535) Handle context-free data
  • (#536) Support context-free actions
  • (#545) Add support for send_transaction JSON RPC
  • (#552) Update README.md
  • (#556) Fix tapos check
  • (#562) trimmed off final slash from endpoint with regex
  • (#566) adds webhook for metrics collection
  • (#568) Update README.md
  • (#569) Minor bugfix for invalid example json in documentation
  • (#577) web-authn support
  • (#579) Replace eosjs-ecc with elliptic
  • (#582) replace get_block with get_block_header_state
  • (#586) Bump mixin-deep from 1.3.1 to 1.3.2
  • (#587) Get block header fallback
  • (#588) Missing how-to guides + docs setup
  • (#591) Fix Issue #390
  • (#597) Add conversion helpers for to/from elliptic lib
  • (#600) Fix Issue #450: Removing babel-cli removes need for babel-polyfill
  • (#601) Fix #372: Added license, version, and build passing badges
  • (#605) Fixing sign() method
  • (#606) * fix hash() misuse
  • (#609) bugfix. Changing wasmFilePath to wasmHexString in full code example
  • (#621) Merging issues fixed on V20.0 branch into develop for eventual release as part of v21
  • (#622) Merging V20.0 fixes into develop in prep for next release
  • (#626) Cleanup for release
  • (#627) bump version
  • (#628) bump
  • (#629) Accept number equal to 1 or 0 while checking data type of bool.
  • (#634) Elliptic p256 compatibility support
  • (#639) Fix security issues
  • (#641) JsonToRawAbi, inverse of rawAbiToJson
  • (#645) V20 merge
  • (#647) Bump version to 21-rc1
  • (#648) Merge pull request #648 from EOSIO/lock-versions
  • (#654) Sign, recover, verify, and validate functions (release/21.0.x branch)
  • (#655) Remove warnings
  • (#657) Removing the latest deploy from .travis.yml (release/21.0.x branch)
  • (#667) Release 21.0.x validate symbol
  • (#668) Zero padding Signature r-value/s-value to 32 bytes (release/21.0.x branch)
  • (#673) Readme Changes (release/21.0.x branch)
  • (#678) Removing usages of deprecated table_key (release/21.0.x branch)
  • (#679) Minified file convention (release/21.0.x branch)
  • (#681) Rename of basic-usage was missed in doc
  • (#682) adjustments to 21.0.0 docs
  • (#684) Version bump for RC2
  • (#687) Backwards/currently compatible fetch
  • (#692) Switching to browser compatible .toArrayLike (release/21.0.x branch)
  • (#695) Fix broken link to intro page
  • (#709) eosjs-ecc methods and migration (release/21.0.x branch)
  • (#715) Added false for shouldHash to sign() usages (release/21.0.x branch)
  • (#730) 2020 License
  • (#744) Resolving deprecation of new Buffer() (release/21.0.x branch)
  • (#745) Adds functionality to use the last irreversible block for transactions (release/21.0.x branch)
  • (#746) Supporting transaction compression (release/21.0.x branch)
  • (#747) Remove unnecessary call to get_block_header_state (release/21.0.x branch)
  • (#748) Adding regex to validate name during serialization (release/21.0.x branch)
  • (#749) Adding an alternative option for browser to generate key pairs (release/21.0.x branch)
  • (#750) New CI/CD Utilizing GitHub Actions (release/21.0.x branch)
  • (#751) Fix R1 Signatures (release/21.0.x branch)
  • (#752) Migrating from tslint to eslint (release/21.0.x branch)
  • (#753) Bumping versions or removing unused dependencies (release/21.0.x branch)
  • (#754) Resolves differences missed in merging
  • (#756) Updating CI/CD to check for protected branch and use token so workflow re-runs (release/21.0.x branch)
  • (#766) Version Bump
  • (#768) Bump elliptic - v21
  • (#769) Bump RC version

Thanks!

Special thanks to the community contributors that submitted patches for this release:

Disclaimer: All repositories and other materials are provided subject to this IMPORTANT notice and you must familiarize yourself with its terms. The notice contains important information, limitations and restrictions relating to our software, publications, trademarks, third-party resources, and forward-looking statements. By accessing any of our repositories and other materials, you accept and agree to the terms of the notice.