Skip to content

Instantly share code, notes, and snippets.

@ohAitch
Last active August 3, 2016 18:38
Show Gist options
  • Select an option

  • Save ohAitch/13488b9de2c7fd9dbc0b7bf2439dd46c to your computer and use it in GitHub Desktop.

Select an option

Save ohAitch/13488b9de2c7fd9dbc0b7bf2439dd46c to your computer and use it in GitHub Desktop.
Minimal urb.js protocol authenticator in node, sends a test |hi
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