2.0.0 • Published 3 years ago

scratch-verify v2.0.0

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

scratch-verify

Verify the ownership of a Scratch account.

NPM Badge

Install

npm install scratch-verify

Usage

const { createCode, verifyCode } = require("scratch-verify")

// The user should go to https://scratch.mit.edu/projects/440710593 and provide `code`
const code = createCode()

// Verify if the user provided it
const isVerified = await verifyCode(username, code)

API

scratchVerify.createCode()

Generate a verification code for the user to provide at https://scratch.mit.edu/projects/440710593. This is just a convenience method - you can use any numerical code. Returns a 6-digit number.

const scratchVerify = require("scratch-verify")

console.log(scratchVerify.createCode())
//=> "435543"

scratchVerify.verifyCode(username, code, options?)

Verify whether the user is authenticated.

username

Type: string

The username to authenticate.

code

Type: string

The code to check for.

options

Type: object

completionTimeout

Type: number\ Default: Infinity

The maximum amount of milliseconds that can pass since the user provided the code before it is no longer accepted.

const scratchVerify = require("scratch-verify")

// If the user has authenticated
console.log(await scratchVerify.verify("RichieNB", "435543"))
//=> true