Skip to content
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

find out how to run this JavaScript code on iOS/Android #420

Open
SmartLayer opened this issue Apr 9, 2021 · 0 comments
Open

find out how to run this JavaScript code on iOS/Android #420

SmartLayer opened this issue Apr 9, 2021 · 0 comments
Assignees

Comments

@SmartLayer
Copy link

SmartLayer commented Apr 9, 2021

Go to xmldsig/js/src to play it yourself. The readme there should be enough guidance for you to run the JavaScript, providing many signed XML files (signed TokenScripts) and verify the signature of each.

(Optional) witness that xmldsig verification with JS works on commandline

Follow the instructions here:

https://github.com/TokenScript/TokenScript/tree/main/xmldsig/js

This way you can be sure the code demonstrated in https://github.com/TokenScript/TokenScript/blob/main/xmldsig/js/src/xmldsigverifier.js can verify XML signature.

Now the problem is how to make iOS/Android run this code. Android is secondary because it already can verify XMLDSIG.

How to take working node.js code to iOS is unknown to me. One thing for sure, the node.js code, in this case 16 lines https://github.com/TokenScript/TokenScript/blob/main/xmldsig/js/src/index.js is not pure JavaScript code that can run everywhere without treatment, because

  1. It has dependencies, in this case XMLDSIG
  2. It has dependencies in node "Core" modules.

Use webpack?

Webpack (before version 5) suggested that they can package core modules with polyfills.

Create a webpack. There is the instruction in README but I already created one on my PC which you can use here, saving you the trouble of running webpack.

main.js.gz

Since this webpack is created from index.js, it should contain the verify function (which is called from the said xmldsigverifier.js) but not the xmldsigverifier.js itself.

But it is a mystery how to call that verify() function theoretically included in main.js. I created one such HTML file:

<html>
        <script scr="main.js" type="text/javascript"></script>
        <script type="text/javascript">
                window.onload = function(e) {
                        console.log(verify("hello"));
                }
        </script>
</html>

I was expecting verify() to fail but I got "verify()" undefined.

Since webpack is created for web developers, there should be a way to call a function packed in a webpack?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants