Boostport / mjml-go

Compile MJML to HTML directly in your Go applications!
Apache License 2.0
83 stars 5 forks source link

[ERROR] Secure random number generation... #5

Closed enac21 closed 1 year ago

enac21 commented 1 year ago

I want to format the following template but I get this error in the jsonResult (res) object at the time of making the json.Unmarshal (mjml.go line 204)

Template: `

Nav1 Nav2 Nav3 Nav4 Nav5 {{ title }} Button 1 Button 2 Button 3

`

Err: Secure random number generation is not supported by this browser. Use Chrome, Firefox or Internet Explorer 11

Im using a IDE to test it and go 1.18.2. I execute the method with these options: mjml.ToHTML(context.Background(), stringTemplate, mjml.WithFonts(mjml.Fonts{}), mjml.WithBeautify(true), mjml.WithMinify(true), mjml.WithValidationLevel("skip"))

After several tests I know that the error comes from the section that includes the navbar, it only happens when the navbar is added.

Template in online editor

Any recommendations? Is this a limitation of the package?

F21 commented 1 year ago

From the mjml-nav's source code, it looks like they use crypto.randomBytes: https://github.com/mjmlio/mjml/blob/0f13e1b91e08683ae05655db05f4cfa5e57e57dd/packages/mjml-navbar/src/Navbar.js#L108

I wonder if this is something that can be polyfilled in the wasm binary to work around this.

enac21 commented 1 year ago

They want to replace the crypto package soon. Thanks!! https://github.com/mjmlio/mjml/pull/2478

F21 commented 1 year ago

That's great news! I'll upgrade to that release as soon as it's available.

F21 commented 1 year ago

This should be fixed in v0.14.2 as it incorporates MJML v4.14.1 which contains https://github.com/mjmlio/mjml/pull/2478