0.1.0 • Published 12 years ago

auth-stream v0.1.0

Weekly downloads
2
License
-
Repository
github
Last release
12 years ago

auth-strream

Authorize access before exposing a stream

Example Server

var Auth = require("auth-stream")
    , net = require("net")
    , through = require("through")

net.createServer(function (stream) {
    var secret = through(function (data) {
            console.log("[SERVER]", data)
            this.emit("data", "secret")
        })
        , auth = Auth(secret, function (user, pass) {
            if (user === "steve" && pass === "jones") {
                return true
            }
        })

    stream.pipe(auth).pipe(stream)
}).listen(8080)

Example Client

var Auth = require("auth-stream")
    , net = require("net")

var stream = net.connect(8080)
    , auth = Auth()

stream.pipe(auth).pipe(stream)

stream.on("data", function (data) {
    console.log("[CLIENT]", data)
})

stream.write("anything")

// login(user, pass)
auth.login("steve", "jones")

Installation

npm install auth-strream

Contributors

  • Raynos

MIT Licenced

0.1.0

12 years ago

0.0.1

12 years ago