slashtags-auth
Installation
npm install @slashtags/slashauth
Usage
HTTP
Server side
const { AuthServer } = require('@slashtags/slashauth')
const keyPair = crypto.createKeyPair()
const authz = ({ publicKey, token }) => {
return {
status: 'ok',
token: 'Bearer 123'
}
}
const magiclink = ({ publicKey }) => {
return {
status: 'ok',
ml: 'http://localhost:8000/v0.1/users/123'
}
}
const server = new SlashAuthServer({
authz,
magiclink,
keypair
})
await server.start()
const slashauthURL = server.fromatURL(token)
Client side
See https://github.com/slashtags/slashauth-client
const { AuthClient, crypto } = require('@slashtags/slashauth-client')
const keyPair = crypto.createKeyPair()
const client = new AuthClient({ keyPair, remotePublicKey })
const response = await client.authz(slashauthURL)
const link = await client.magiclik(slashauthURL)