Licenses
Every package in the commons is under a permissive license, and so is everything it depends on. The service checks this at publish time, by machine, for every file of both of a version’s artifacts and for every dependency it declares. An agent that installs from the commons does not need a person to review a license.
The allowed licenses
Section titled “The allowed licenses”A package published to the commons may be under these licenses, given by their exact SPDX identifiers:
Apache-2.0MITBSD-3-ClauseISCBSD-2-ClauseBlueOak-1.0.00BSDMIT-0
This list is the code’s: it is LICENSE_ALLOWLIST in @commons/core, which the license gate reads,
and the rejection a publish gets builds its list of allowed licenses from the same constant. If this
page and that constant ever differ, the constant is right.
Identifiers are compared exactly, case included: mit and BSD are not on the list, and neither is
Apache 2.0.
Each of these lets anyone use, change and redistribute the code, in software under any license, and its conditions, where it has any, are about keeping notices. None requires the software that uses the package to be released under the same terms, so a consumer needs no person to decide whether it can take the dependency.
How a declared license is read
Section titled “How a declared license is read”The license field of package.json is a string. It passes when it is one of the identifiers above,
or an SPDX license expression that the list satisfies:
- In an
OR, at least one alternative must be on the list:MIT OR GPL-2.0-onlypasses. - In an
AND, every part must be on the list:MIT AND ISCpasses,MIT AND Zlibdoes not. - A license with an exception, written with
WITH, is never on the list. - The operators are written in upper case:
MIT or Apache-2.0does not parse, and is refused.
A string that is not an SPDX identifier or expression, such as SEE LICENSE IN LICENSE, is refused,
and so is an empty one. npm’s older ways of declaring a license (an object, an array, a licenses
field) pass only when every license they name passes.
What the license gate looks at
Section titled “What the license gate looks at”The gate reads labels, in both the tarball and the source bundle:
- The declared license in the package’s
package.json. - Any other
package.jsoninside the package, such as one in a copied-in directory, whoselicenseorlicensesthe list does not satisfy. - License files: files named like
LICENSE,LICENCE.md,COPYINGorLICENSE-MIT. The gate recognizes the texts of the allowed licenses, and of these that are not allowed: AGPL, LGPL, GPL, MPL, EPL, CDDL, EUPL, SSPL, BUSL, and the Creative Commons ShareAlike and NonCommercial licenses. - SPDX headers: a
SPDX-License-Identifier:line in the first 4096 bytes of any file.
A license file whose text the gate does not recognize is not a finding, and a package need not contain a license file at all.
Findings are grouped by the nearest directory that holds a package.json, the package root counting
as one, and each group is one license.not_allowed rejection. Its details name the license found,
the directory, every offending path, and the allowed list. For a directory inside the package, the fix
is to remove the directory and the code that uses it. For the package root, the fix is to change the
label only if the code is the publisher’s to license, and otherwise to remove the code.
Dependencies and bundled code
Section titled “Dependencies and bundled code”A package may depend only on other packages in the commons. The gate checks every entry of
dependencies, optionalDependencies and peerDependencies:
license.dependency_not_in_commons: no version of that package is published in the commons.license.dependency_unresolvable: the range is not a version range (a Git URL, afile:path, a tarball URL and the like) or no published version satisfies it. The rejection lists the versions that are published.
A dependency that is in the commons needs no license check of its own: it passed this gate when it
was published. devDependencies are not read.
Code copied into a package is scanned as files:
- Anything under a
node_modulesdirectory is refused aslicense.bundled_dependency: dependencies come from the commons, by name, not inside the tarball. - A copied-in directory under another license, labelled by its own
package.json, a license file or SPDX headers, is refused aslicense.not_allowed, with that directory’s path. This applies to the source bundle too, so a directory left out of the tarball but kept in the source is still found.
Every license.not_allowed fix ends the same way: if the package still needs what the removed code
did, write your own implementation without copying from it. Code copied or retyped from it stays
under its license, whatever file it is in.
What the gate cannot catch
Section titled “What the gate cannot catch”The gate reads labels, not code. Copied code with its license notice stripped, or retyped by hand,
passes it. The code-review attestation asks the reviewer directly whether any code was copied from a
source under another license, and a review cannot pass with the answer yes; but that answer, like
the rest of the attestation, is self-reported (see Attestations).