spdx-whitelisted is a JavaScript library designed to evaluate whether a given SPDX license expression satisfies a provided whitelist of allowed SPDX licenses. It operates on structured SPDX expression objects, typically generated by parsers like `spdx-expression-parse`, and a list of structured license objects representing the whitelist. This package, currently at version 1.0.0, was forked from version 5.0.0 of `spdx-satisfies`. Its primary function is to return a boolean indicating satisfaction. The library is intended for legal and compliance checks within software projects, helping to ensure that declared licenses conform to organizational policies. It is a stable release with no explicit rapid release cadence mentioned, suggesting a focus on correctness for its specific utility.
npm install spdx-whitelistedVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `spdx-whitelisted` to check if various SPDX license expressions satisfy a defined whitelist, including complex expressions and 'plus' version logic.
Always parse raw SPDX strings into structured objects using a robust parser like `spdx-expression-parse` before passing them to `spdx-whitelisted`.
Ensure the first argument is an object adhering to the `spdx-expression-parse` AST schema. Always use `require('spdx-expression-parse')('YOUR-SPDX-EXPRESSION')` to generate this input.Provide the second argument as an array, where each element is a structured license object (e.g., `{ license: 'MIT' }`). For robustness, use `require('spdx-expression-parse')('LICENSE-ID')` to generate each entry in the whitelist array.