Skip to content

Support client side (react-script) #159

Open
@0x0ece

Description

@0x0ece

Would you consider support for client side?

Right now, if I try to use the lib in a react app, I get this errors:

Module not found: Error: Can't resolve 'crypto' in '/path/to/node_modules/.pnpm/http-message-signatures@1.0.1/node_modules/http-message-signatures/lib/algorithm'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
	- install 'crypto-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "crypto": false }
ERROR in ./node_modules/.pnpm/http-message-signatures@1.0.1/node_modules/http-message-signatures/lib/algorithm/index.js 8:20-40
Module not found: Error: Can't resolve 'constants' in '/path/to/.pnpm/http-message-signatures@1.0.1/node_modules/http-message-signatures/lib/algorithm'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "constants": require.resolve("constants-browserify") }'
	- install 'constants-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "constants": false }

Unfortunately react-script is a little bit of its own beast... it uses webpack 5 but has a very complex internal config, that makes it practically impossible to override it. So, the solution "add resolve.fallback" is not straightforward in a real/new react application (and most workaround you can find on google just work for a limited amount of time, then people stop maintaining them).

In summary, the solution would be to make it possible to just link the relevant parts of the library without direct dependency on node's crypto and constants.

For additional context, I'm signing requests on the client side (react app) using two types of signers:

  1. ed25519 using https://github.com/paulmillr/noble-curves
  2. webauthn, ed25519 or es256

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions