mirror of
https://github.com/Luzifer/wasm-openssl.git
synced 2024-11-08 14:50:10 +00:00
Fix: If opensslLoaded function is undefined don't call it
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
d58104a492
commit
a8cdcde89a
2 changed files with 5 additions and 2 deletions
|
@ -35,7 +35,7 @@ Afterwards in your HTML you can include the `wasm_exec.js` and load the binary:
|
|||
</html>
|
||||
```
|
||||
|
||||
Be sure to have a top-level function `opensslLoaded()` defined as this will be called in the initialization of the `openssl.wasm`. This serves as a notification you do have now access to the top-level functions `encrypt` and `decrypt`:
|
||||
If you have a top-level function `opensslLoaded()` defined, this will be called in the initialization of the `openssl.wasm`. This serves as a notification you do have now access to the top-level functions `encrypt` and `decrypt`:
|
||||
|
||||
```javascript
|
||||
function decrypt(ciphertext, passphrase, callback) {}
|
||||
|
|
5
main.go
5
main.go
|
@ -12,7 +12,10 @@ func main() {
|
|||
js.Global().Set("encrypt", js.NewCallback(encrypt))
|
||||
|
||||
// Trigger custom "event"
|
||||
js.Global().Call("opensslLoaded")
|
||||
if js.Global().Get("opensslLoaded").Type() == js.TypeFunction {
|
||||
js.Global().Call("opensslLoaded")
|
||||
}
|
||||
|
||||
<-make(chan struct{}, 0)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue