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

@pluginlab/chatgpt-plugin-validator

v2.0.0

Published

A package that validates ChatGPT plugin manifests and ensure they follow the security guidelines.

Downloads

50

Readme

Want to get users and start making money out of your ChatGPT plugin? Check out pluginlab.ai !

ChatGPT Plugin Validator

A package that validates ChatGPT plugin manifests and ensure they follow the security guidelines.

Installation

Install the package:

npm install --save @pluginlab/chatgpt-plugin-validator

Migrate to V1

ESM to CJS migration

The package now gets compiled to CJS which is also supported by ESM environments. That choice was made to make it easy to get it working on nodejs-powered backends. Many frameworks are not ready to support ESM yet.

Parsing the manifest

The signature of the parseManifest method was changed to better fit javascript coding standards. Now parseManifest returns the typed manifest if it is correct or throws a ParseManifestError that contains the parsing errors otherwise.

Getting root domain

Same thing than for parsing the manifest. The signature has been rewritten in a more idiomatic way. It either returns the root domain or throws an error if the domain is not parsable for some reason.

Usage

Parse and validate a plugin manifest

import { parseManifest, ParseManifestError } from '@pluginlab/chatgpt-plugin-validator';
// assuming we are in a Node.js environment, loading the manifest from a file
import { readFileSync } from 'fs';

const manifestData = readFileSync('manifest.json', 'utf-8');
const json = JSON.parse(manifest);

try {
    const manifest = parseManifest(json);
} catch (error) {
    if (error instanceof ParseManifestError) {
        console.error(`Failed to parse manifest: ${error}`);
    }

    throw error;
}

console.log(`Successfully loaded manifest for plugin ${manifest.name_for_human}.`);

This function validates the manifest against a JSON schema that can be found in this repo. We rely on AJV for the validation work.

Validate static domain constraints

As part of their security guidelines, ChatGPT requires that plugins respect a set of constraints when it comes to the domains they use. More on that here.

This package exports a function that checks constraints that are relative to the legal_info, contact_info and api.url fields of the manifest.

It does NOT ensure that redirections are done properly as asked by the guidelines.

import { validateStaticDomainConstraints } from '@pluginlab/chatgpt-plugin-validator';

const manifestDomain = 'www.aurelienbrabant.fr';
const errors = validateStaticDomainConstraints(manifestDomain, parsedManifest);

if (errors.length > 0) {
    throw new Error(errors.map((e) => e.message).join('\n'));
}

console.log('All static domain constraints are respected.');

Getting the root domain of your plugin

As stated by OpenAI, the root domain of a plugin is the domain used to host the manifest or a slightly modified version of it. Read more about it here.

This package exports a function that, given the domain of the manifest, returns the root domain of the plugin. Most of the functions exported by this package already call this function internally, so you shouldn't need to call it yourself in most cases.

import { getRootDomain } from '@pluginlab/chatgpt-plugin-validator';

const rootDomain1 = getRootDomain('myplugin.pluginlab.ai'); // rootDomain1 should be 'myplugin.pluginlab.ai'
const rootDomain2 = getRootDomain('www.pluginlab.ai'); // rootDomain2 should be 'pluginlab.ai'