npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@iocaptcha/server

v0.0.2

Published

ES6/TS server for https://iocaptcha.com - Where security reigns, yet privacy remains.

Downloads

15

Readme

TS / ES6 iocaptcha server. Where security reigns, yet privacy remains.

image

iocaptcha server

Installing

image build CI

npm install @iocaptcha/server

Usage

ES6

Verifying user-submitted tokens

import { Api } from '@iocaptcha/server';

// specify your endpoint's public & private keys here */
const iocaptcha = new Api({
  endpoint_public_key: "AAAA",
  endpoint_private_key: "BBBB",
});

// check if authentication passes
let success = await iocaptcha.authenticate();

if (success) {
  console.log("iocaptcha authenticated!");
} else {
  throw new Error("iocaptcha authentication failed! check your keys.");
}

let token = "..." // get token from user
// check token
let result = await iocaptcha.validate(token);

if (result.pass) {
  // ... allow the user
} else {
  // ... deny the user
}

iocaptcha.validate() returned response structure:

// 
var resp = {
  "error": null, // whether any errors occured (if so, pass will be false)
  "flags": [ // enterprise only flags, https://iocaptcha.com/enterprise
    "UnavailableEnterpriseOnlyFeature"
  ],
  "ip_match": true, // whether the IP address matches the token
  "pass": true, // whether the token passed as judged by the endpoint's score threshold
  "score": 0.9285714285714286, // the token's human score (0.0 = bot, 1.0 = human)
  "ua_match": true, // whether the user agent matches the token
  "action": "login", // the action the token was generated for
  "sess_start_ts": 1699495076840, // the timestamp the session started
  "sess_finish_ts": 1699495071635, // the timestamp the session ended
  "sess_type": "sess_type" // the type of session ('iocaptcha', 'iosec', or 'ioshield')
}

Verifying user-submitted tokens, and their IP adress and User-Agent

You can send the user's IP address and User-Agent to the validate() function for extra verification. This is recommended, and will lower the score shall it find a mismatch, and also return the ip_match and ua_match flags as specified above.

let result = await iocaptcha.validate({
  token: ..token,
  user_ip: ..ip,
  user_useragent: ..useragent
})

Skipping invalidation

Invalidation is a process where when you make a request to our API, or use the invalidate() function, the token is marked as used and cannot be used again. This is done to prevent replay attacks, however if you want to avoid this behaviour, such as when you want to make multiple requests with the same token, you can use the invalidation option.

This is not recommended, and should only be used when you know what you're doing.

let result = await iocaptcha.validate({
  token: ..token,
  invalidate: false
})