Coder Social home page Coder Social logo

Comments (7)

ldthomas avatar ldthomas commented on September 24, 2024 3

I've just published apg-js version 4.2.0 specifically modified to address the fix that @Jonathansoufer pointed out and more. Give 4.2.0 a try and if it fixes this problem then I would assume this issue could be closed.

from siwe.

w4ll3 avatar w4ll3 commented on September 24, 2024 1

Hello, glad to have your feedback. siwe libraries require some node polyfills, I'm afraid you might be missing them. You might want to use [SSX](https://docs.ssx.id) which already includes those and also give you a lot more on top. In the same repo there are a lot of React examples not sure if they can help you out.

from siwe.

w4ll3 avatar w4ll3 commented on September 24, 2024 1

Wow, that's quite a finding. Just found a similar issue in APG's issues and will try to see if they might accept your solution. Thanks for the time.

from siwe.

Jonathansoufer avatar Jonathansoufer commented on September 24, 2024

Thank you for your quick reply. I am afraid that doesn't solve the problem. In the scenario, I'm the wallet not the dApp itself. So ssx is used by the dApp to establish with the respective backend all the SIWE flow, but as a wallet using the WalletConnect lib (https://walletconnect.com/) to connect into dApps. From that perspective I just need to parse a request and be able to identify if it's a SIWE or not and produce an object out of the string payload received. I can do it via custom implementation but seems that @spruceid/siwe-parser implements that. What am I missing to make this work with React NATIVE?

from siwe.

Jonathansoufer avatar Jonathansoufer commented on September 24, 2024

FIX Summary: It's boils down that the problem is related with the transformers.js file from a dependency called apg-js. This call thisThis.utf16le.decode returns undefined from thisThis. Referencing this reported issue https://stackoverflow.com/questions/74969277/jest-import-module-typeerror-cannot-read-properties-of-undefined-reading-utf, the fix was patching the package apg-js as follows:

diff --git a/src/apg-conv-api/transformers.js b/src/apg-conv-api/transformers.js
index 286ee809ab885035b28b206b8bb4967c47ffb849..e359a21f4b00d14e7fa7f9d13076f9320282a060 100644
--- a/src/apg-conv-api/transformers.js
+++ b/src/apg-conv-api/transformers.js
@@ -504,7 +504,7 @@ exports.utf16be = {
 };
 
 // The UTF16LE algorithms.
-exports.utf16le = {
+const utf16le = {
   encode(chars) {
     const bytes = [];
     let char;
@@ -575,6 +575,8 @@ exports.utf16le = {
   },
 };
 
+exports.utf16le = utf16le;
+
 // The UTF32BE algorithms.
 exports.utf32be = {
   encode(chars) {
@@ -795,10 +797,10 @@ exports.uint32le = {
 // Uses the node.js Buffer's native "utf16le" capabilites.
 exports.string = {
   encode(chars) {
-    return thisThis.utf16le.encode(chars).toString('utf16le');
+    return utf16le.encode(chars).toString('utf16le');
   },
   decode(str) {
-    return thisThis.utf16le.decode(Buffer.from(str, 'utf16le'), 0);
+    return utf16le.decode(Buffer.from(str, 'utf16le'), 0);
   },
 };
 

from siwe.

Jonathansoufer avatar Jonathansoufer commented on September 24, 2024

Team work!

from siwe.

luneShaoGM avatar luneShaoGM commented on September 24, 2024

Same with me

from siwe.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.