-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support client side (react-script) #159
Comments
I would be prepared to support client-side, yes - but I don't have a real-world use-case for it, so I wouldn't be putting it through any battle hardening, which can be fairly important for reliable libraries. As I understand it, the 2 areas that would need to be addressed would be:
In my opinion, there is little value in using this package on the client side for signing because the secret signing key will have to be available to the browser - possibly verifying is also not very useful because if the client is communicating with a compromised server (that has been able to break SSL, etc, then they can just turn off the message signing and even just change the secret, etc). But, I can see from #156 that there is value in being able to use it in stripped down JS environments that may not have access to NodeJS packages, but they do have access to the web APIs. |
Right - I think I see the problem. We have the |
Yes, you got all the points. As for the keys, we use webauthn so the key is actually stored in a separated device, whether it's a hardware security key or a mobile phone (passkey). Webauthn requires user interaction for every signature, therefore for better ux we: 1) generate an ephemeral ed25519 key in the browser, 2) issue a signed-with-webauthn api request to register this session cred, 3) use this cred to sign all following api requests. The server only ever stores public keys. The custom signer is great, and I don't see many issues managing keys and signatures. The big advantage for me personally is to use your lib for all the serialization part, as the standard is pretty complex :) |
Would you be prepared to provide a PR for a side-by-side node/browser implementation/build? |
I gave it a try but I got stuck :/ First a good news, changing the types from Buffer -> Uint8Array is kind of smooth, at least algorithm/index.ts seems to remain valid because Buffer implements Uint8Array. (assuming algorithm will only be used/available for node). It remains to replace Buffer.from in various places, essentially handling conversions from string and/or base64. For string, for example, the common way is |
Actually I spoke too early, it seems I was able to do the trick: #160. Assuming the change Buffer -> Uint8Array is good (or anyway we can discuss any additional tweak/fix in the PR), the other thing that remains to do is to "remove" algorithms. I'm not entirely sure how to do that. In my tests I simply commented out algorithms and so far it's compiling. Next I'll do some additional tests to verify I can properly sign on the client. |
Would you consider support for client side?
Right now, if I try to use the lib in a react app, I get this errors:
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:
The text was updated successfully, but these errors were encountered: