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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mostajs/licence-guard

v0.2.1

Published

La licence d'une application entre deux démarrages : range le document signé, rend un verdict HORS LIGNE, et ne coupe jamais rien. Complète @mostajs/licensing, qui ne persiste rien.

Downloads

275

Readme

@mostajs/licence-guard

Auteur : Dr Hamid MADANI [email protected] · AGPL-3.0-or-later

La licence d'une application entre deux démarrages.

@mostajs/licensing fait déjà tout le dialogue avec le serveur de licences — demander, télécharger, vérifier la signature RSA, contrôler le projet et l'échéance, notifier l'activation. Il le dit lui-même : « Ne persiste rien (à la charge de l'appelant). »

C'est cet appelant qui manquait. Sans lui, une instance activée redémarre en « non activée » : le droit est valide, le document est signé, et il a disparu avec le processus. Une université coupée du réseau ne pourrait plus jamais prouver le sien.

Ce module range la licence signée, rend un verdict hors ligne, et n'invente aucune règle : le verdict est celui de checkLicense, donc du code que le serveur utilise lui-même.

Il ne peut pas couper l'application

Il rend un état. Il ne lève pas pour bloquer, ne quitte pas le processus, n'intercepte aucune route. enforce n'est qu'un champ de cet état, que l'interface affiche — jamais un comportement d'ici. Une garde qui pourrait couper finirait un jour par couper : une instance installée dans une université porte des dossiers d'étudiants et des actes officiels, et l'arrêter pour un différend administratif punirait l'étudiant.

Les trois gardes

1. On ne range jamais un document mal signé. Sans cela, un serveur usurpé (DNS détourné, faux certificat) ou simplement en panne remplacerait un cache valide par un refus — et l'instance resterait dessus, indéfiniment, y compris hors ligne. Un déni de service durable, obtenu sans casser la moindre signature.

2. Une révocation signée, elle, entre. Elle est re-signée par l'autorité, donc elle passe la garde n°1. C'est toute la différence entre « le serveur dit non » et « l'autorité a signé un non » — seul le second est opposable hors ligne.

3. Serveur injoignable ⇒ le cache reste en vigueur. Une coupure réseau n'est pas une perte de droit, et le message le dit au lieu de laisser croire le contraire.

Emploi

import { createLicenceGuard } from '@mostajs/licence-guard';
import { fileCache } from '@mostajs/licence-guard/file-cache';

const licence = createLicenceGuard({
  baseUrl: process.env.LICENCE_SERVER,        // https://licences.amia.fr
  project: process.env.LICENCE_PROJECT,       // le `project` SIGNÉ — la casse compte
  publicKeyPem: readFileSync(process.env.LICENCE_PUBLIC_KEY_FILE, 'utf8'),
  cache: fileCache('data/licence.signed.json'),
  machineId: hostname(),
});

licence.status();            // { valid, status, reason, expiresAt, daysLeft, source, enforce, key, company }
await licence.activate(code) // télécharge, vérifie, range, notifie
await licence.refresh()      // redemande le même document — c'est par là qu'une révocation arrive
licence.key()                // la clé d'activation, pour s'authentifier auprès d'un central

L'état a exactement la forme qu'attend @mostajs/licensing-ui-html (licenseStatusView, licenseBadge).

Le cache est un port, pas node:fs : le cœur du module n'écrit rien sur le disque, si bien qu'aucun test ne peut hériter du fichier d'un autre. L'adaptateur disque est un point d'entrée séparé — et il écrit atomiquement (fichier temporaire puis rename), parce qu'une coupure de courant pendant l'écriture laisserait un demi-document, et l'instance repartirait en « aucune licence » avec un droit pourtant intact.

npm test      # 12 tests (@mostajs/mjs-unit)