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

instaparty

v0.0.39

Published

> Instant Private Party Creator

Downloads

52

Readme

Instaparty

Instant Private Party Creator

Instaparty lets you instantly create crypto wallet authorized websites.

Usage

Create a project folder and initialize:

instaparty <role> <NPM package>

This will:

  1. create a folder named <role>
  2. attach the <NPM package> auth engine to the <role>
  3. create a route named /<role>, where the site will be available

If no <NPM package> is specified, this role will allow anyone to login. Example:

instaparty user

will create a /user route and allow anyone to log in and access the route.

Tutorial

1. Access list based authorization

The following command will:

  1. create a route at /members
  2. this route will be protected by listparty module
mkdir my-app
cd my-app
instaparty members listparty

open members/members.txt and paste a line separated list of addreses. For example:

0x00192fb10df37c9fb26829eb2cc623cd1bf599e8
0x372d427b85d00538fb6512a6ef76c62b9664949b

Test by running npm run dev and going to http://localhost:3000/members

You should see the default webpage. To use your own website, just paste all your website files into the members/instaparty folder and run npm run start

2. NFT based authorization

The following command will:

  1. create a route at /holders
  2. this route will be protected by nftparty module
mkdir my-app
cd my-app
instaparty holders nftparty

open holders/config.yaml and customize. For example:

ADDRESS: "0xf7d134224a66c6a4ddeb7dee714a280b99044805"
BALANCE: 1
RPC: "https://eth-mainnet.alchemyapi.io/v2/N3VL8CEuBmuDK9bezhh2FxHIEO8aZM4z"

where:

  • ADDRESS: is the contract address for the NFT collection
  • BALANCE: is the minimum balance required to access the route
  • RPC: is the JSON RPC endpoint url for getting the blockchain state (for example Alchemy, Quicknode, etc.)

3. Multiple roles and routes

You can have multiple routes. Let's try combining the two examples above:

mkdir my-app
cd my-app
instaparty holders nftparty
instaparty members guestparty

This will:

  1. create two folders: holders and members
  2. create two routes /holders and /members
  3. The /holders route will be protected with the nftparty module
  4. The /members route will be protected with the guestparty module

Building and publishing Party modules

You can easily write Instaparty auth modules. Start by initializing an empty Instaparty template:

instaparty

This will create 2 things:

  1. an index.js file
  2. a defaults folder

Let's take a look at a PPPM module with allow list authorization:

1. customize index.js

The index.js file contains the authorization logic. The default file will look like this:

module.exports = {
  authorize: async (req, account) => {
    
  }
}

Now let's add some logic to the authorize() function:

const { members } = require('./members.json')
module.exports = {
  authorize: async (req, account) => {
    if (members.includes(account)) {
      return { member: true }
    } else {
      throw new Error("not a member")
    }
  }
}

Here's how it works:

  1. Imports the members.json file (covered in the next section)
  2. Checks if the authenticated account is part of the members.json array.
  3. The authorization succeeds if true, otherwise throws an error (no login)

2. customize defaults folder

The template files are automatically copied to the project folder when a user runs pppm install <package_name>.

Often you want to make it easy for the users by automatically initializing their project folder with some default files, which they can modify to customize their configuration (instead of writing those files from scratch).

In this case we want to provide a default members.json file. When a user runs pppm install, this will be copied to their project folder, and they can modify it to customize.

Now let's write a default members.json file:

{
  "members: []
}

3. customize README.md

This part is optional, but you may want to add a README.md file to the folder, which you can use to explain how to use the module.

The README.md file will be printed when

  • a user first installs the module with pppm install
  • a user calls pppm help

You may also want to add a README.md file that will be printed ahen

4. publish to NPM

At this point, your folder structure for the module would look like this:

.
├── README.md
├── defaults
│   └── members.json
├── index.js
└── package.json

Open package.json and update the package name to whatever you want. In this case let's say we want to publish it as accessparty. The final package.json may look like this:

{
  "name": "accessparty",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "author": "",
  "license": "MIT"
}

To publish, run:

npm publish

5. use

Now that we've published the module to NPM, how do we use it?

Let's say we named this package accessparty. We can now use this with:

pppm init
pppm install accessparty

This will create the following folder structure:

.
├── members.json
├── index.js
└── package.json
[
  "0xFb7b2717F7a2a30B42e21CEf03Dd0fC76Ef761E9",
  "0x00192fb10df37c9fb26829eb2cc623cd1bf599e8",
  "0x372d427b85d00538fb6512a6ef76c62b9664949b"
]