{"name":"lockfile-lint-api","version":"5.9.2","keywords":["lockfile","lock","file","lint","linter","parse","npm","yarn"],"author":{"url":"https://github.com/lirantal","name":"Liran Tal","email":"liran.tal@gmail.com"},"license":"Apache-2.0","_id":"lockfile-lint-api@5.9.2","maintainers":[{"name":"lirantal","email":"liran.tal@gmail.com"},{"name":"lirantal_bot","email":"liran.tal+npm@gmail.com"}],"homepage":"https://github.com/lirantal/lockfile-lint","bugs":{"url":"https://github.com/lirantal/lockfile-lint/issues"},"dist":{"shasum":"c9ca335d4aa46c90d8b8467a92ed6670b5db0ed9","tarball":"http://registry-npm.ywwl.com/lockfile-lint-api/download/lockfile-lint-api-5.9.2.tgz","fileCount":13,"integrity":"sha512-3QhxWxl3jT9GcMxuCnTsU8Tz5U6U1lKBlKBu2zOYOz/x3ONUoojEtky3uzoaaDgExcLqIX0Aqv2I7TZXE383CQ==","signatures":[{"sig":"MEYCIQDFQtRoRz/Dj8Snj6cPiC1VyazzRldwQrK+Nt7D6rM6pgIhAPVOqw020HPbOF2XChekGmyBlZ98oiIY79krArD1DVZH","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":42683,"size":12088,"noattachment":false,"key":"/lockfile-lint-api/-/lockfile-lint-api-5.9.2.tgz"},"jest":{"notify":true,"verbose":true,"testMatch":["**/*.test.js"],"collectCoverage":true,"testEnvironment":"node","coverageThreshold":{"global":{"lines":80,"branches":80,"functions":80,"statements":80}},"collectCoverageFrom":["index.js","src/**/*.{js,ts}"],"testPathIgnorePatterns":["/__tests__/.*/__fixtures__/.*"]},"main":"index.js","engines":{"node":">=16.0.0"},"gitHead":"b3a5d0d640d47968ba3bf154179cbcf1e82a6cf6","scripts":{"docs":"yarn run docs:code && yarn run docs:api","lint":"eslint .","test":"jest","commit":"git-cz","format":"prettier-standard \"**/*.js\"","docs:api":"doxdox *.js --layout bootstrap --output docs/index.html","lint:fix":"eslint . --fix","docs:code":"docco *.js --output docs/code","test:watch":"jest --watch","coverage:view":"open-cli coverage/lcov-report/index.html"},"_npmUser":{"name":"lirantal_bot","email":"liran.tal+npm@gmail.com"},"standard":{"env":["jest"],"ignore":["**/out/"],"parser":"babel-eslint"},"repository":{"url":"git+https://github.com/lirantal/lockfile-lint.git","type":"git","directory":"packages/lockfile-lint-api"},"_npmVersion":"10.8.2","description":"Lint an npm or yarn lockfile to analyze and detect issues","directories":{},"_nodeVersion":"18.20.8","dependencies":{"debug":"^4.3.4","object-hash":"^3.0.0","@yarnpkg/parsers":"^3.0.0-rc.48.1"},"eslintConfig":{"env":{"es6":true,"jest":true,"node":true},"rules":{"no-process-exit":"warn","object-curly-spacing":"off","jest/no-focused-tests":"error","jest/no-disabled-tests":"error","jest/no-identical-title":"error","node/no-unpublished-require":"off","space-before-function-paren":"off","node/no-unsupported-features":"off","security/detect-unsafe-regex":"error","security/detect-child-process":"error","security/detect-buffer-noassert":"error","security/detect-object-injection":"warn","security/detect-pseudoRandomBytes":"error","security/detect-non-literal-regexp":"error","security/detect-eval-with-expression":"error","security/detect-disable-mustache-escape":"error","security/detect-non-literal-fs-filename":"error","security/detect-possible-timing-attacks":"error","security/detect-no-csrf-before-method-override":"error"},"extends":["standard","plugin:node/recommended"],"plugins":["import","standard","node","security","jest"],"parserOptions":{"ecmaVersion":8,"ecmaFeatures":{"impliedStrict":true}}},"eslintIgnore":["coverage/**"],"_hasShrinkwrap":false,"devDependencies":{"jest":"29.6.2","docco":"^0.9.1","doxdox":"3.0.0","eslint":"^8.46.0","open-cli":"^7.2.0","babel-eslint":"^10.0.1","babel-preset-env":"^1.7.0","prettier-standard":"16.4.1","eslint-plugin-jest":"^27.2.3","eslint-plugin-node":"11.1.0","babel-preset-es2015":"^6.24.1","eslint-plugin-import":"^2.28.0","eslint-plugin-promise":"^6.1.1","eslint-config-standard":"^17.1.0","eslint-plugin-security":"^1.7.1","eslint-plugin-standard":"^4.1.0","babel-plugin-transform-regenerator":"^6.26.0","babel-plugin-syntax-async-functions":"^6.13.0"},"_npmOperationalInternal":{"tmp":"tmp/lockfile-lint-api_5.9.2_1745773990367_0.9894264990347772","host":"s3://npm-registry-packages-npm-production"},"readme":"<p align=\"center\"><h1 align=\"center\">\n  lockfile-lint-api\n</h1>\n\n<p align=\"center\">\n  Lint an npm or yarn lockfile to analyze and detect issues\n</p>\n\n<p align=\"center\">\n  <a href=\"https://www.npmjs.org/package/lockfile-lint-api\"><img src=\"https://badgen.net/npm/v/lockfile-lint-api\" alt=\"npm version\"/></a>\n  <a href=\"https://www.npmjs.org/package/lockfile-lint-api\"><img src=\"https://badgen.net/npm/license/lockfile-lint-api\" alt=\"license\"/></a>\n  <a href=\"https://www.npmjs.org/package/lockfile-lint-api\"><img src=\"https://badgen.net/npm/dt/lockfile-lint-api\" alt=\"downloads\"/></a>\n  <a href=\"https://travis-ci.org/lirantal/lockfile-lint\"><img src=\"https://badgen.net/travis/lirantal/lockfile-lint\" alt=\"build\"/></a>\n  <a href=\"https://codecov.io/gh/lirantal/lockfile-lint\"><img src=\"https://badgen.net/codecov/c/github/lirantal/lockfile-lint\" alt=\"codecov\"/></a>\n<a href=\"https://snyk.io/test/npm/lockfile-lint-api\"><img src=\"https://snyk.io/test/npm/lockfile-lint-api/badge.svg\" alt=\"Known Vulnerabilities\" data-canonical-src=\"https://snyk.io/test/npm/lockfile-lint-api\" style=\"max-width:100%;\"></a>\n  <a href=\"https://github.com/nodejs/security-wg/blob/main/processes/responsible_disclosure_template.md\"><img src=\"https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg\" alt=\"Security Responsible Disclosure\" /></a>\n</p>\n\n# About\n\nLints an npm or yarn lockfile to analyze and detect issues\n\n# Install\n\n```bash\nnpm install --save lockfile-lint-api\n```\n\n# Usage\n\n`lockfile-lint-api` exposes a set of validator APIs that can be used for programmatic use-cases, such as being employed by other tools and programs if needed.\n\n## Validators\n\n`ValidateIntegrity.validate({integrityStrict: true})` requires a complete\nbase64-encoded SHA-512 digest for dependencies in npm v1-v3 and Yarn Classic\nlockfiles. The default validation still only checks the hash type when present.\nFor example:\n\n```js\nconst {ParseLockfile, ValidateIntegrity} = require('lockfile-lint-api')\nconst {object: packages, format} = new ParseLockfile({lockfilePath: 'package-lock.json'}).parseSync()\nconst result = new ValidateIntegrity({packages, format}).validate({integrityStrict: true})\n```\n\nStrict mode exempts Git dependencies, local directories, workspace links and\nbundled dependencies. The parser resolves bundle ancestry before flattening and\nrecords verified bundle provenance for validation. Local `.tgz`/`.tar.gz` files\nand HTTP(S) tarballs still require integrity.\nAn SRI list is accepted if it contains a complete SHA-512 digest. Package\nexclusions use `integrityExclude` as in the default mode. You can also pass\n`{integrityStrict: true}` as the second argument to `validateSingle(packageName)`.\nThis checks metadata without fetching package contents, and does not support\nYarn Berry's different checksum format.\n\nFor npm v2/v3, bundled entries require a verified bundler ancestor. The parser\nwalks up the package path, skipping ancestors marked `inBundle`/`bundled`, to the\nnearest non-bundled ancestor. That ancestor must exist and declare\n`bundleDependencies` as a non-empty array or `true`. It must also have a complete\nSHA-512 integrity value or qualify independently as a commit-pinned Git source,\nlocal directory or workspace link. Transitive bundled dependencies are covered\neven when their names are absent from the declaration.\n\nFor npm v1, the nearest enclosing non-bundled ancestor must meet the same\nintegrity/source requirement. The v1 dependency tree does not record the parent's\n`bundleDependencies`, so the parser cannot confirm the declaration itself.\nMissing or unverified ancestors leave children subject to the integrity check;\nexcluding a parent from validation does not verify its bundle.\n\nRaw `link`, `bundled` or `inBundle` flags do not exempt HTTP(S) sources or local\n`.tgz`/`.tar.gz` files; the Git source exceptions below still apply.\n\nGit-protocol URLs and Git-host shorthands require a 7-40-character hexadecimal\ncommit fragment to qualify for an exemption. Branches, tags, semver ranges and\nmissing refs require complete SHA-512 integrity. Link/bundle flags cannot bypass\nthis pin requirement. Local file URLs are classified using their decoded path:\npercent-encoded `.tgz`/`.tar.gz` extensions still require integrity, and malformed\nURL escapes do not qualify as local directories.\n\nYarn Classic GitHub sources are also exempt when the URL is exactly\n`https://codeload.github.com/<owner>/<repo>/tar.gz/<40-hex-commit-sha>`,\nwithout a query string or fragment. Codeload URLs using tags, branches or short\nSHAs, and archive URLs that do not match this shape, still require integrity.\n\nHTTPS GitHub, GitLab and Bitbucket repository URLs of the form\n`https://<host>/<owner>/<repo>#<commit>` are exempt when the commit is 7-40\nhexadecimal characters and there is no query string. This separate Git-remote\nexception accepts abbreviated commits; archive/download paths remain subject\nto the tarball rules above.\n\nFor Yarn Berry, strict `validate()` returns one unsupported-format error without\na `package` field:\n\n```json\n{\n  \"type\": \"error\",\n  \"errors\": [\n    {\n      \"message\": \"--validate-integrity-strict does not support Yarn Berry lockfiles (which use \\\"checksum\\\" instead of \\\"integrity\\\").\",\n      \"unsupportedFormat\": true\n    }\n  ]\n}\n```\n\nConsumers can inspect `unsupportedFormat` without matching message text. Strict\n`validateSingle()` throws an `Error` with the same message and\n`unsupportedFormat: true`; for supported formats it returns a boolean.\nThe CLI exits non-zero with an unsupported-format summary. It prints\n\"security issues detected!\" only if other validators report security findings.\n\nAPI consumers should pass the parser result's `format` alongside `packages` to\n`ValidateIntegrity` so unsupported Yarn Berry input is identified. Pass the\nparsed package objects directly to preserve the parser's internal bundle\nprovenance; raw bundle flags or JSON-serialized copies alone do not establish\nverified ancestry.\n\nThe following lockfile validators are supported\n\n| Validator API        | description                                                                     | implemented |\n|----------------------|---------------------------------------------------------------------------------| ----------- |\n| ValidateHttps        | validates the use of HTTPS as protocol schema for all resources                 | ✅          |\n| ValidateHost         | validates a whitelist of allowed hosts to be used for resources in the lockfile | ✅          |\n| ValidatePackageNames | validates that the resolved URL matches the package name                        | ✅          |\n| ValidateScheme       | validates a whitelist of allowed URI schemes to be used for hosts               | ✅          |\n| ValidateIntegrity    | validates that the integrity hash type is sha512                                | ✅          |\n\n**NOTE:** package entries without a `resolved` field (for example, those installed from the local filesystem) will automatically pass all url-based validators.\n\n## Success and failures\n\nWhen validators encounter errors they will throw an exception, and on either success or failure in validating data they will always return a descriptive object for the validation task.\n\n### Successful validation\n\nWhen validation is successful the following object will be returned from the validating function:\n\n```json\n{\n  \"type\": \"success\",\n  \"errors\": []\n}\n```\n\n### Failed validation\n\nWhen validation has failed the following object will be returned from the validating function:\n\n```json\n{\n  \"type\": \"error\",\n  \"errors\": [\n    {\n      \"package\": \"@babel/cli\",\n      \"message\": \"detected invalid origin for package: @babel/cli\"\n    }\n  ]\n}\n```\n\nNotes about the returned object:\n\n- An errors object will always return an array of errors metadata, even if there's only one error associated with the validation being performed\n- All errors should always have a message\n- The availability of the `package` property and other metadata depends on the specific validators being used\n\n### Example\n\n```js\nconst validator = new ValidateHost({packages: lockfile.object})\nlet result\ntry {\n  result = validator.validate(['npm'])\n} catch (error) {\n  // something bad happened during validation and the validation\n  // process couldn't take place\n}\n\nconsole.log(result)\n/* prints\n{\n  \"type\": \"error\",\n  \"errors\": [\n    {\n      \"message\": \"detected invalid origin for package: meow\",\n      \"package\": \"meow\"\n    }\n  ]\n}\n*/\n```\n\n# Example\n\n```js\nconst {ValidateHost, ParseLockfile} = require('lockfile-lint-api')\n\n// path to the lockfile\nconst yarnLockfilePath = '/path/to/my/yarn.lock'\nconst options = {\n  lockfilePath: yarnLockfilePath\n}\n\n// instantiate a new parser with options object\nconst parser = new ParseLockfile(options)\n\n// read the file synchronously and parses it\n// providing back an object that is compatible\n// with the @yarn/lockfile library which has\n// all the packages listed in `lockfile.object`\nconst lockfile = parser.parseSync()\n\n// now instantiate a validator object with those\n// list of packages\nconst validator = new ValidateHost({packages: lockfile.object})\nlet result\ntry {\n  // validation is synchronous and is being called\n  // with 'npm' as a shortcut for the npm registry\n  // host to validate all lockfile resources are\n  // whitelisted to the npm host\n  result = validator.validate(['npm'])\n} catch (error) {\n  // couldn't process the validation\n}\n\nif (result.type === 'success') {\n  // validation succeeded\n}\n```\n\n# Contributing\n\nPlease consult [CONTRIBUTING](../../CONTRIBUTING.md) for guidelines on contributing to this project.\n\n# Author\n\n**lockfile-lint-api** © [Liran Tal](https://github.com/lirantal), Released under the [Apache-2.0](./LICENSE) License.\n","publish_time":1745773990550,"_cnpm_publish_time":1745773990550,"dist-tags":{"latest":"5.10.0"}}