Last active
August 3, 2016 18:38
-
-
Save ohAitch/13488b9de2c7fd9dbc0b7bf2439dd46c to your computer and use it in GitHub Desktop.
Minimal urb.js protocol authenticator in node, sends a test |hi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| request = require \request-promise-json | |
| prompt = require \inquirer .createPromptModule! | |
| port = process.env.URB_PORT or 8443 | |
| host = "http://localhost:#port" | |
| message = {appl:'hood', mark:'helm-hi', data: 'auth-test'} | |
| getCode = (ship, cb)-> | |
| code = process.env.URB_CODE | |
| if code => cb {code} | |
| else prompt [name: 'code' message: "Enter code for ~#ship"] .then cb | |
| all = do | |
| {oryx, ship} <- request.get "#host/~/auth.json" .then | |
| {code} <- getCode ship | |
| {oryx} <- request.put "#host/~/auth.json" {code, ship, oryx} .then | |
| {appl, mark, data} = message | |
| res <- request.post "#host/~/to/#appl/#mark.json?wire=/&oryx=#oryx" data .then | |
| console.log res | |
| all.catch -> console.error it |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment