vechain-sdk-js icon indicating copy to clipboard operation
vechain-sdk-js copied to clipboard

Browser compatibility

Open rodolfopietro97 opened this issue 1 year ago • 5 comments

Improve browser compatibility.

As a user I want to create browser app that use SDK as dependency.

Issues:

  • Issues with webassembly for solc compiler
  • Some libraries issues (fs,...) -> Proper configure web pack or remove exporting of this libraries

Evaluate https://github.com/browserslist/browserslist

rodolfopietro97 avatar Jan 30 '24 08:01 rodolfopietro97

Dependency on #331 and findings of #634

nwbrettski avatar Feb 23 '24 14:02 nwbrettski

Defining as

  • pure : the code agnostic if running in nodejs or in a browser without additional component to adapt runtime to nodejs.
  • secure : the code we can demonstrate algorithms are cryptographically secure and libraries passed a secure audit.

The code in the repo https://github.com/vechain/vechain-sdk-js/tree/712-derive-public-key-from-wallet-extended-public-key-without-elliptic-library is pure and secure for

  • packages/core/src/bloom/bloom.ts
  • packages/core/src/hash/blake2b256.ts
  • packages/core/src/hash/keccak256.ts
  • packages/core/src/hash/sha256.ts

lucanicoladebiasi avatar Apr 06 '24 17:04 lucanicoladebiasi

The code at https://github.com/vechain/vechain-sdk-js/tree/666-address-pure-and-secure is pure and secure for

  • packages/core/src/address/address.ts

lucanicoladebiasi avatar Apr 18 '24 17:04 lucanicoladebiasi

The code at https://github.com/vechain/vechain-sdk-js/tree/666-pure-and-secure-bip32-hdnode is pure and secure for

  • packages/core/src/hdnode/hdnode.ts
  • packages/core/src/mnemonic/mnemonic.ts

lucanicoladebiasi avatar Apr 22 '24 18:04 lucanicoladebiasi

The code at https://github.com/vechain/vechain-sdk-js/tree/666-pure-and-secure-utils-data is pure and secure for

  • packages/core/src/utils/data/data.ts

The code in packages/core/src/utils/const/data.ts substitute ZERO_BUFFER based on NodeJS Buffer with ZERO_BYTES based on pure JS Uint8Array.

lucanicoladebiasi avatar Apr 26 '24 14:04 lucanicoladebiasi

Link to polyfills potential solution https://github.com/paulmillr/noble-hashes/issues/48

nwbrettski avatar Jun 06 '24 13:06 nwbrettski

@rodolfopietro97 what are the problems you still see with NextJS?

cc @Valazan

victhorbi avatar Jun 18 '24 13:06 victhorbi

Seems that compatibility was achieved, there are residual issues to be analysed more in depth but related to the test environment (jest).

Relates to : #978

victhorbi avatar Jun 20 '24 13:06 victhorbi

Evaluate browser list in a second moment (not HP) @victhorbi

rodolfopietro97 avatar Jun 24 '24 12:06 rodolfopietro97