JSPM

scratch-verify

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q32068F
  • License MIT

Verify the ownership of a Scratch account.

Package Exports

  • scratch-verify

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (scratch-verify) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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