Fix signals and offline mode for js/wasm by hslatman · Pull Request #683 · smallstep/cli
Changes in this PR include the things I needed to change in the CLI to make it compile to js/wasm.
Had to move around and refactor some code to fix import cycles and such. I'm not completely happy with the structure yet, but it's a start.
The js/wasm build is not fully functional. There are things that are not supported in a browser environment, so these functions can't be used. Using mTLS (easily) is one of them. There are also things that aren't fully implemented yet, like the --offline mode. Currently this functionality is stubbed, so that the js/wasm build can at least compile. It would be cool to support this in the future, though, as this would allow running an offline instance of step-ca in memory in a browser.
Running GOOS=js GOARCH=wasm go build -o ./html/test.wasm -tags nobadger,nobbolt cmd/step/main.go will not result in a Wasm module yet. There are still some changes in dependencies to be completed:
# github.com/chzyer/readline vendor/github.com/chzyer/readline/utils.go:81:29: undefined: State vendor/github.com/chzyer/readline/utils.go:241:9: undefined: State vendor/github.com/chzyer/readline/operation.go:234:4: undefined: ClearScreen vendor/github.com/chzyer/readline/readline.go:129:20: undefined: GetScreenWidth vendor/github.com/chzyer/readline/readline.go:132:22: undefined: DefaultIsTerminal vendor/github.com/chzyer/readline/readline.go:142:26: undefined: DefaultOnWidthChanged vendor/github.com/chzyer/readline/remote.go:324:2: undefined: DefaultOnWidthChanged vendor/github.com/chzyer/readline/remote.go:346:17: undefined: GetScreenWidth vendor/github.com/chzyer/readline/remote.go:362:16: undefined: DefaultIsTerminal vendor/github.com/chzyer/readline/terminal.go:51:2: undefined: SuspendMe vendor/github.com/chzyer/readline/terminal.go:51:2: too many errors # github.com/newrelic/go-agent/internal/sysinfo vendor/github.com/newrelic/go-agent/internal/sysinfo/usage_posix.go:17:17: undefined: syscall.Getrusage vendor/github.com/newrelic/go-agent/internal/sysinfo/usage_posix.go:17:35: undefined: syscall.RUSAGE_SELF # github.com/smallstep/zcrypto/x509 vendor/github.com/smallstep/zcrypto/x509/cert_pool.go:38:9: undefined: loadSystemRoots vendor/github.com/smallstep/zcrypto/x509/root.go:21:32: undefined: loadSystemRoots
In my POC repo, using forks of those with dirty hacks, the Wasm compiles with the changes from this PR.