{"_id":"@vivocha/scopes","_rev":"50-d9bc657d63ae471f85e5dc0652551034","name":"@vivocha/scopes","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@vivocha/scopes","version":"1.0.0","keywords":["vivocha"],"author":{"url":"http://www.vivocha.com/","name":"Vivocha Dev Team","email":"dev@vivocha.com"},"license":"MIT","_id":"@vivocha/scopes@1.0.0","maintainers":[{"name":"matzori","email":"matzori@vivocha.com"},{"name":"npinna","email":"npinna@vivocha.com"},{"name":"gmflore","email":"gmflore@vivocha.com"},{"name":"apirasvvc","email":"apiras@vivocha.com"},{"name":"msiddi","email":"msiddi@vivocha.com"},{"name":"0xfede","email":"fpinna@vivocha.com"},{"name":"pintux","email":"pintus@gmail.com"},{"name":"alovicu","email":"alovicu@vivocha.com"},{"name":"gfr","email":"gfrau@vivocha.com"},{"name":"marchitos","email":"amadori.marco@gmail.com"},{"name":"fsanna","email":"fsanna@vivocha.com"},{"name":"mvigano71","email":"mvigano71@gmail.com"}],"homepage":"https://github.com/vivocha/scopes.git#readme","bugs":{"url":"https://github.com/vivocha/scopes/issues"},"nyc":{"exclude":["**/test"],"include":["dist/**/*.js","src/**/*.ts"],"reporter":["lcov","text"],"extension":[".js",".ts"],"sourceMap":true},"dist":{"shasum":"d17be8015a4314920bc1b95a581410660955eb28","tarball":"https://registry.npmjs.org/@vivocha/scopes/-/scopes-1.0.0.tgz","fileCount":5,"integrity":"sha512-YENq/wU2DzRnhbENpBT5Hp/UI1xjoWUsqqoNGRuTBQZA67xOEf7hDXacgDyBKNPJPVKAjYJJ2Y+IlzKW/NJ4Lw==","signatures":[{"sig":"MEUCIQCm1uVRH4DVIyWG8mIOPDu2PF/tU96Ps6jnrkfrLzWbEQIgEgPlDHRKX2E3prn+4SUAdqU7dW9etcoxlis78H3CyUA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":11676,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdkhtXCRA9TVsSAnZWagAAr+AQAKEWyuDOSIr/K86W+Fr9\n6FsLTb7cgBw63gCtHizWj3ZSeq2RIfiR+WiZBqZPqVNK6JvgV1OA5RQ9Oy+e\nc/2Iv53mC8LcxUg8TMC2MKQJZjTT+d4g3KfPa4qWO314jraCEATfQ07kZXY+\nRaUaIThRSir8YWINaXBXEFm71+prmbRhp3VPgc+KRRSop7XYYkHUIz+1nTJi\n/3NF8zYF4L5NjYX+Sn3U+ivUoG/UVMvZXnf465exs6Vf43IeQ6nZHMuqk7bM\nbLv/l3gtx7fzYcroUjFuu+8w2tVyeN2U6cS/2ej2v+H2U1AZASciTg65uDeY\nydxU7L7b3MO27hDUkb8Bd6GCOH2A+a+Fmc/9MfGvTL2KwCrbKoJCw8YdwsL8\ngj/CnOgAAZp2DDgWNZeeQmGhDqVkgraUrNLMllbtLYnvKu5UP9zg3D6PQsH/\nXbbo0Bvbqnw/Yrg4N4ys54nDuvfWdxVeEEwzhxABT2yDTn72L+vRn1Ik7YSG\nYkplH6qz7M9jJ9WKM3mkKG9iaBPBtfodwBN6sBaiEoEIYeCmlD8NXAM9Yzaq\nsbi8/MOVs8B24pLbjZUCNm4LH4nYT2/5UyXL4Dz52QpAYBozNzGwyoHaPf5f\nhmMOosuiIzgqmspj8wYvLZrUwd/pQ8E/Gx8nJ6/nmfrejvIs7vB/i5GQ6zRo\nRyk9\r\n=GuWi\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS","pre-commit":"npm run build && npm run cover && npm run check-coverage"}},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"gitHead":"6aa7d82bb88aeb680b886da24890dd749d2e244f","scripts":{"test":"find ./test/ts -type f -name '*.js' -delete && npm run build:all && mocha --exit --no-timeouts --recursive --reporter mochawesome --reporter-options reportDir=test-results test/**/*.test.js","build":"tsc","clean":"npx rimraf dist coverage .nyc_output test-results","cover":"nyc --reporter=lcov --reporter=text npm t","commit":"git-cz","i:lock":"npm i && npm i --package-lock-only","prebuild":"rm -rf dist","build:all":"npm run build && npm run build:tests","clean:all":"npm run clean && npx rimraf node_modules","test:debug":"find ./test/ts -type f -name '*.js' -delete && npm run build:all && mocha --exit --no-timeouts --inspect-brk --recursive test/**/*.test.js","test:watch":"nodemon -e ts --ignore dist/ --ignore 'test/ts/*.js' --exec npm run test","watch:test":"npm t -- -w","build:tests":"tsc -p test","check-coverage":"nyc check-coverage --statements 90 --branches 90 --functions 100 --lines 90","semantic-release":"semantic-release","semantic-release-dry":"semantic-release --dry-run"},"typings":"dist/index.d.ts","_npmUser":{"name":"gfr","email":"gfrau@vivocha.com"},"repository":{"url":"git+https://github.com/vivocha/scopes.git","type":"git"},"_npmVersion":"6.11.3","description":"Vivocha API Scopes Utilities","directories":{"test":"test"},"_nodeVersion":"10.16.3","dependencies":{},"publishConfig":{"access":"restricted"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^14.1.1","chai":"^4.2.0","husky":"^3.0.7","mocha":"^6.2.1","nodemon":"^1.19.3","typescript":"^3.6.3","@types/chai":"^4.2.3","@types/node":"^12.7.8","mochawesome":"^4.1.0","@types/mocha":"^5.2.7","@types/request":"^2.48.3","@commitlint/cli":"^8.2.0","chai-as-promised":"^7.1.1","semantic-release":"^15.13.24","@types/chai-as-promised":"7.1.2","cz-conventional-changelog":"^3.0.2","@types/request-promise-native":"^1.0.17","@commitlint/config-conventional":"^8.2.0"},"_npmOperationalInternal":{"tmp":"tmp/scopes_1.0.0_1569856342481_0.2958203973389433","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"@vivocha/scopes","version":"2.0.0","keywords":["vivocha"],"author":{"url":"http://www.vivocha.com/","name":"Vivocha Dev Team","email":"dev@vivocha.com"},"license":"MIT","_id":"@vivocha/scopes@2.0.0","maintainers":[{"name":"msiddi","email":"msiddi@vivocha.com"},{"name":"0xfede","email":"fpinna@vivocha.com"},{"name":"alovicu","email":"alovicu@vivocha.com"},{"name":"marchitos","email":"amadori.marco@gmail.com"},{"name":"gmflore","email":"gmflore@vivocha.com"},{"name":"matzori","email":"matzori@vivocha.com"},{"name":"esilarante","email":"andrea.montaperto@covisian.com"},{"name":"pintux","email":"pintus@gmail.com"},{"name":"mattman","email":"mmuscas@vivocha.com"},{"name":"sfois","email":"sfois@vivocha.com"},{"name":"cinzia.montis","email":"cinzia.montis@covisian.com"},{"name":"lquartesan","email":"laura.quartesan@esosphera.com"},{"name":"matteocasu","email":"matteo.casu@covisian.com"},{"name":"albertopierobon","email":"alberto.pierobon@esosphera.com"},{"name":"alberto-zanon-esosphera","email":"alberto.zanon@esosphera.com"},{"name":"andreafi","email":"andrea.fileccia@covisian.com"},{"name":"m-ricca","email":"marco.ricca@covisian.com"},{"name":"federicogallo72","email":"federico.gallo@covisian.com"},{"name":"fmoretti","email":"fmoretti@vivocha.com"},{"name":"fbertona","email":"fbertona@vivocha.com"},{"name":"domenicopresutto","email":"domenico.presutto@covisian.com"},{"name":"nicola.pinna","email":"nicola.pinna@outlook.com"},{"name":"adrianflr","email":"adrian.florea@covisian.com"},{"name":"bebob94","email":"bebo.macis@gmail.com"},{"name":"gfrau","email":"gianfranco.frau@covisian.com"},{"name":"marcodanzoeso","email":"marco.danzo@esosphera.com"},{"name":"matteo-brandolino-eso","email":"matteo.brandolino@esosphera.com"},{"name":"denis.gasparin","email":"denis.gasparin@esosphera.com"},{"name":"raff0ne","email":"raffaele.esposito@covisian.com"},{"name":"matti_93","email":"mattiacherchi93@gmail.com"},{"name":"stefanotamponi","email":"stamponi@vivocha.com"},{"name":"davide.scapin","email":"davide.scapin@esosphera.com"},{"name":"msobrino","email":"msobrino@covisian.com"},{"name":"dakeaeso","email":"daniel.keane@esosphera.com"},{"name":"arianna_eso_25","email":"arianna.toniolo@esosphera.com"},{"name":"nicolotartaggiaeso","email":"nicolo.tartaggia@esosphera.com"},{"name":"vimi-eso","email":"vittorio.milazzo@esosphera.com"}],"homepage":"https://github.com/vivocha/scopes.git#readme","bugs":{"url":"https://github.com/vivocha/scopes/issues"},"nyc":{"exclude":["**/test"],"include":["dist/**/*.js","src/**/*.ts"],"reporter":["lcov","text"],"extension":[".js",".ts"],"sourceMap":true},"dist":{"shasum":"48a0fc1171f370a39452f85d280fa27d322bfc12","tarball":"https://registry.npmjs.org/@vivocha/scopes/-/scopes-2.0.0.tgz","fileCount":5,"integrity":"sha512-kLpN7v+N4YcG6/AYD7DxK7CaAiuOPeMVB2BTqd/+bjtvYnEC4oEIBaYpH+NqfFqktVxPXR/B5cwbRtBZJuyfZA==","signatures":[{"sig":"MEUCIDfOAA3t4wG+WgxLt0SYaa8HIFePpel63wYbd6T1ebrzAiEA0+jNJIN7oitz12wBwBZAP5CX6vFzPNW0nXUCcXTdJ/Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":13720},"main":"dist/index.js","husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS","pre-commit":"npm run build && npm run cover && npm run check-coverage"}},"config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"engines":{"node":">=24.0.0"},"gitHead":"94ed9ce1516d11168f708a05ad1efaef741b90dd","scripts":{"test":"find ./test/ts -type f -name '*.js' -delete && npm run build:all && mocha --exit --no-timeouts --recursive test/**/*.test.js","build":"tsc","clean":"npx rimraf dist coverage .nyc_output test-results","cover":"nyc --reporter=lcov --reporter=text npm t","commit":"git-cz","i:lock":"npm i && npm i --package-lock-only","prebuild":"rm -rf dist","build:all":"npm run build && npm run build:tests","clean:all":"npm run clean && npx rimraf node_modules","test:debug":"find ./test/ts -type f -name '*.js' -delete && npm run build:all && mocha --exit --no-timeouts --inspect-brk --recursive test/**/*.test.js","test:watch":"nodemon -e ts --ignore dist/ --ignore 'test/ts/*.js' --exec npm run test","watch:test":"npm t -- -w","build:tests":"tsc -p test","check-coverage":"nyc check-coverage --statements 90 --branches 90 --functions 100 --lines 90","semantic-release":"semantic-release","semantic-release-dry":"semantic-release --dry-run"},"typings":"dist/index.d.ts","_npmUser":{"name":"gfrau","email":"gianfranco.frau@covisian.com"},"repository":{"url":"git+https://github.com/vivocha/scopes.git","type":"git"},"_npmVersion":"11.6.2","description":"Vivocha API Scopes Utilities","directories":{"test":"test"},"_nodeVersion":"24.11.1","publishConfig":{"access":"restricted"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^18.0.0","chai":"^4.5.0","husky":"^9.1.7","mocha":"^11.7.5","nodemon":"^3.1.14","commitizen":"^4.3.1","typescript":"^6.0.3","@types/chai":"^4.3.20","@types/node":"^22.10.6","@types/mocha":"^10.0.10","@commitlint/cli":"^20.5.3","semantic-release":"^25.0.3","cz-conventional-changelog":"^3.3.0","@commitlint/config-conventional":"^20.5.3"},"_npmOperationalInternal":{"tmp":"tmp/scopes_2.0.0_1778228763321_0.2530066377302562","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2019-09-30T15:12:22.349Z","modified":"2026-09-17T09:18:55.515Z","1.0.0":"2019-09-30T15:12:22.598Z","2.0.0":"2026-05-08T08:26:03.477Z"},"bugs":{"url":"https://github.com/vivocha/scopes/issues"},"author":{"url":"http://www.vivocha.com/","name":"Vivocha Dev Team","email":"dev@vivocha.com"},"license":"MIT","homepage":"https://github.com/vivocha/scopes.git#readme","keywords":["vivocha"],"repository":{"url":"git+https://github.com/vivocha/scopes.git","type":"git"},"description":"Vivocha API Scopes Utilities","maintainers":[{"email":"msiddi@vivocha.com","name":"msiddi"},{"email":"fpinna@vivocha.com","name":"0xfede"},{"email":"alovicu@vivocha.com","name":"alovicu"},{"email":"amadori.marco@gmail.com","name":"marchitos"},{"email":"gmflore@vivocha.com","name":"gmflore"},{"email":"matzori@vivocha.com","name":"matzori"},{"email":"andrea.montaperto@covisian.com","name":"esilarante"},{"email":"pintus@gmail.com","name":"pintux"},{"email":"mmuscas@vivocha.com","name":"mattman"},{"email":"sfois@vivocha.com","name":"sfois"},{"email":"cinzia.montis@covisian.com","name":"cinzia.montis"},{"email":"laura.quartesan@esosphera.com","name":"lquartesan"},{"email":"matteo.casu@covisian.com","name":"matteocasu"},{"email":"alberto.pierobon@esosphera.com","name":"albertopierobon"},{"email":"alberto.zanon@esosphera.com","name":"alberto-zanon-esosphera"},{"email":"andrea.fileccia@covisian.com","name":"andreafi"},{"email":"marco.ricca@covisian.com","name":"m-ricca"},{"email":"federico.gallo@covisian.com","name":"federicogallo72"},{"email":"fbertona@vivocha.com","name":"fbertona"},{"email":"domenico.presutto@covisian.com","name":"domenicopresutto"},{"email":"nicola.pinna@outlook.com","name":"nicola.pinna"},{"email":"adrian.florea@covisian.com","name":"adrianflr"},{"email":"bebo.macis@gmail.com","name":"bebob94"},{"email":"gianfranco.frau@covisian.com","name":"gfrau"},{"email":"marco.danzo@esosphera.com","name":"marcodanzoeso"},{"email":"matteo.brandolino@esosphera.com","name":"matteo-brandolino-eso"},{"email":"denis.gasparin@esosphera.com","name":"denis.gasparin"},{"email":"raffaele.esposito@covisian.com","name":"raff0ne"},{"email":"mattiacherchi93@gmail.com","name":"matti_93"},{"email":"stamponi@vivocha.com","name":"stefanotamponi"},{"email":"tiberio.marras@smile.cx","name":"tiberio.marras"},{"email":"davide.scapin@esosphera.com","name":"davide.scapin"},{"email":"msobrino@covisian.com","name":"msobrino"},{"email":"daniel.keane@esosphera.com","name":"dakeaeso"},{"email":"arianna.toniolo@esosphera.com","name":"arianna_eso_25"},{"email":"nicolo.tartaggia@esosphera.com","name":"nicolotartaggiaeso"},{"email":"vittorio.milazzo@esosphera.com","name":"vimi-eso"}],"readme":"# @vivocha/scopes\n\nUtility library to parse, match, and filter Vivocha OpenAPI scopes.\n\nScopes follow a `category.operation` format (e.g. `User.read`, `Asset.delete`).  \nThe wildcard `*` can be used in either position. A `-` prefix negates a scope.\n\n## Installation\n\n```sh\nnpm install @vivocha/scopes\n```\n\n## Scope syntax\n\n| Scope | Meaning |\n|---|---|\n| `User.read` | Allow `read` on `User` |\n| `User.*` | Allow all operations on `User` |\n| `*.read` | Allow `read` on all categories |\n| `*` or `*.*` | Allow everything |\n| `-User.create` | Deny `create` on `User` |\n\nScopes can be passed as a space-separated string or as an array of strings.\n\n## API\n\n### `new Scopes(scopes: string | string[])`\n\nParses the given scopes.\n\n```ts\nimport { Scopes } from '@vivocha/scopes';\n\nconst s = new Scopes(['User.*', '-User.create', 'Sessions.read', '*.update']);\n// or equivalently:\nconst s = new Scopes('User.* -User.create Sessions.read *.update');\n```\n\n---\n\n### `match(scopes: string | string[] | Scopes): boolean`\n\nReturns `true` if **all** of the given scopes are allowed by this instance.\n\n```ts\nconst s = new Scopes(['User.*', '-User.create', 'Sessions.read', '*.update']);\n\ns.match('User.read');      // true  — covered by User.*\ns.match('User.create');    // false — explicitly denied by -User.create\ns.match('Session.delete'); // false — not covered\ns.match('Asset.update');   // true  — covered by *.update\n```\n\nWildcard examples:\n\n```ts\nnew Scopes('*').match('User.delete');      // true\nnew Scopes('*').match('Account.update');   // true\n\nnew Scopes('*.delete').match('User.delete');    // true\nnew Scopes('*.delete').match('Account.update'); // false\n\nnew Scopes('User.*').match('User.create'); // true\nnew Scopes('User.*').match('User.read');   // true\nnew Scopes('User.*').match('Account.read'); // false\n```\n\n---\n\n### `filter(scopes: string | string[] | Scopes): Scopes`\n\nReturns a new `Scopes` instance containing only the scopes from the argument that are allowed by this instance.\n\n```ts\nconst s = new Scopes(['User.*']);\ns.filter('User.delete').toArray(); // ['User.delete']\n\nconst s2 = new Scopes(['User.*', '-User.delete', '*.read']);\ns2.filter('User.delete User.update Asset.delete Asset.update Asset.read').toArray();\n// ['User.update', 'Asset.read']\n```\n\n---\n\n### `set(category: string, operation: string, value: boolean): void`\n\nProgrammatically adds or updates a single scope entry.\n\n```ts\nconst s = new Scopes([]);\ns.set('User', 'read', true);\ns.set('User', 'delete', false);\ns.toArray(); // ['User.read', '-User.delete']\n```\n\n---\n\n### `get(category: string): Record<string, boolean> | undefined`\n### `get(category: string, operation: string): boolean | undefined`\n\nRetrieves the stored value for a category or a specific category/operation pair.\n\n```ts\nconst s = new Scopes(['User.*', '-User.delete']);\ns.get('User');           // { '*': true, delete: false }\ns.get('User', 'delete'); // false\ns.get('User', 'read');   // undefined (resolved via '*' at match time)\n```\n\n---\n\n### `toArray(): string[]`\n\nReturns the scopes as an array of strings.\n\n```ts\nconst s = new Scopes(['User.*', '-User.create', 'Sessions.read', '*.update']);\ns.toArray(); // ['User.*', '-User.create', 'Sessions.read', '*.update']\n```\n\n---\n\n### `toString(): string`\n\nReturns the scopes as a space-separated string.\n\n```ts\nconst s = new Scopes(['User.*', '-User.create', 'Sessions.read', '*.update']);\ns.toString(); // 'User.* -User.create Sessions.read *.update'\n```\n\n## License\n\n[MIT](LICENSE)\n","readmeFilename":"README.md"}