Nicely Pointed Mandibles
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

jvc-auth

0.1.1 • Public • Published

jvc-auth npm version

Authenticate jeuxvideo.com users.

Overview

This library uses antisocial-auth over jvc to allow any website to authenticate jeuxvideo.com users, being sure they own the username they claimed.

Protocol

  1. An user wants to authenticate to your application with their jeuxvideo.com username.
  2. You generate a nonce and ask them to send it in a private mesage to a bot user you own.
  3. When the user confirm they're done, check the bot private messages for the nonce.
  4. If the nonce is found, the user is authenticated.

Usage

You need to override the jvc property with a logged in instance (in a bot account) so the library can access the bot private messages.

You can use the jvc.login method to go through the login/password/captcha process. But you're encouraged to do this just once and store the cookie to reuse it. In the example below, I assume you already have a valid cookie.

const defaultAuth = require('jvc-auth')
 
const auth = defaultAuth.override({
  jvc: defaultAuth.jvc.override({ user: { cookie: 'your-bot-cookie' } }),
})

Generate a nonce

// Get nonce buffer.
const nonce = await auth.generateNonce()
 
// Nice encoding of the nonce to show to the user.
const displayNonce = auth.beautify(nonce)

Verify a message

if (await auth.checkMessage('user', nonce)) {
  // The user is authenticated.
}

Demo

See the demo directory, which contains a concrete usage example with an Express web app.

Keywords

none

install

npm i jvc-auth

Downloadsweekly downloads

0

version

0.1.1

license

Unlicense

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability