{"_id":"@btapai/ng-authorisation","_rev":"1-165e9b2a63bcd3ee3885a889091644ca","name":"@btapai/ng-authorisation","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@btapai/ng-authorisation","description":"An authorisation handler library for angular applications","version":"0.0.1","author":{"name":"Balázs Tápai","email":"balazs.tapai1990+npm@gmail.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/TapaiBalazs/angular-reusables.git"},"peerDependencies":{"@angular/common":"^10.0.14","@angular/core":"^10.0.14"},"dependencies":{"tslib":"^2.0.0","rxjs":"~6.5.5","@angular/forms":"^10.0.0"},"main":"bundles/btapai-ng-authorisation.umd.js","module":"fesm2015/btapai-ng-authorisation.js","es2015":"fesm2015/btapai-ng-authorisation.js","esm2015":"esm2015/btapai-ng-authorisation.js","fesm2015":"fesm2015/btapai-ng-authorisation.js","typings":"btapai-ng-authorisation.d.ts","metadata":"btapai-ng-authorisation.metadata.json","sideEffects":false,"bugs":{"url":"https://github.com/TapaiBalazs/angular-reusables/issues"},"homepage":"https://github.com/TapaiBalazs/angular-reusables#readme","_id":"@btapai/ng-authorisation@0.0.1","_nodeVersion":"12.16.0","_npmVersion":"6.14.6","dist":{"integrity":"sha512-zaEc2QQeId/9Z5ly7kA9yqeMZT1pJwnfteZDQzEaR9N0PDuwGAzQQ9NtZs3g+shzLoFJaDYwuD4m/FYE/fnPmw==","shasum":"e63a3ab439dc11a921c9d8f2b2b9ca48ae5619d2","tarball":"https://registry.npmjs.org/@btapai/ng-authorisation/-/ng-authorisation-0.0.1.tgz","fileCount":34,"unpackedSize":53646,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfcFDsCRA9TVsSAnZWagAAFYIP/jiuIPPLopHopl2L+2wy\n2Hlirtzn2PL7/p9VsaeCQTMy5fSuwXe6e95cYPPlV8gng6E90BWkkg0WkWxD\nXqdKCofLyrD7+toJvRVT69E1jta/LjdGq+XPc7vIvPEgQBb2ZNJKZQ26mDZ2\nvEK/7HZpFnmWa64rj/gPPWeIlpzIKAIQTEtN8NWIYJy+RxNAIZ6I9aGcBs0W\nO+lZRBhEZyNS10M+XeJiV7koTtSEsdRiUaAnclWZjZotOvQ19EC+Xbr/W8JL\nWq+Cr2CiCqAZ7gWnN0oY1EL+kfPLipdpnY0antFOkkFYEvWh0Tyf4C8eH08A\nZ47cyXI4JB8Cpx/n7MgcvIxONcTj7jceXHe6LTOA3B8vRBc7Hp+A7pV21OYZ\nVup+QdAPATFpODvPdjnGB1q+o3h9k9h0h8QlSbLzUKhcv277nJQk+B5wKYmH\nEh4MQtHe+DNcRP85b/F5TtqcEQvy0aVRXAKMhbsJAHciUSxKs48uDWrgFdKF\nLBIHSN2a17lNW7FmDcNASwPU3LYEMjKK9BU74Ic8HylPWaov1LXhU55s6pOb\nsZNcaTWnkithD0vkeVxq/A6OKJWjYbai4FYa0ptiF5ZkiwJ3zFl4+eLDeCbs\n3PYA5migMbtX+WcOnxXr4Q1M/UFDGa7ouIby0HkdXsa4vW5UqSD4STWw8GGi\nutBs\r\n=XhXs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDSAyxMSKBcBkTuEk943Qa/EWvQmNAec8iW6C7bnWejtQIhAPXOZK5xLStW77FD6HsmjmQJsZBV32IUXfVtr3V3rIuF"}]},"maintainers":[{"name":"btapai","email":"balazs.tapai1990+npm@gmail.com"}],"_npmUser":{"name":"btapai","email":"balazs.tapai1990+npm@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/ng-authorisation_0.0.1_1601196268316_0.575808199018143"},"_hasShrinkwrap":false}},"time":{"created":"2020-09-27T08:44:28.273Z","0.0.1":"2020-09-27T08:44:28.443Z","modified":"2022-04-04T20:52:18.790Z"},"maintainers":[{"name":"btapai","email":"balazs.tapai1990+npm@gmail.com"}],"description":"An authorisation handler library for angular applications","homepage":"https://github.com/TapaiBalazs/angular-reusables#readme","repository":{"type":"git","url":"git+https://github.com/TapaiBalazs/angular-reusables.git"},"author":{"name":"Balázs Tápai","email":"balazs.tapai1990+npm@gmail.com"},"bugs":{"url":"https://github.com/TapaiBalazs/angular-reusables/issues"},"license":"MIT","readme":"# Authorisation\n\n## How to install\n\nInstall the package with the following script:\n\n`npm install @btapai/ng-authorisation`\n\nor\n\n`yarn add @btapai/ng-authorisation`\n\n## How to use\n\nImport the module into your main ngModule and in lazy-loaded modules where you would like to use the directive.\nInside your main ngModule, provide the `AUTHORISATION_HANDLER` injection token and use your service, which implements the\n`AuthorisationInterface` interface. If you'd like to use the extra styling functionality, you can provide the `AUTHORISATION_CLASS`\ninjection token and use your own \"unauthorised\" css class name.\n\n```typescript\nimport { BrowserModule } from '@angular/platform-browser';\nimport { NgModule } from '@angular/core';\nimport { AppComponent } from './app.component';\nimport { AuthorisationModule, AUTHORISATION_HANDLER, AUTHORISATION_CLASS } from '@btapai/ng-authorisation';\n\n@NgModule({\n  declarations: [AppComponent],\n  imports: [BrowserModule, AuthorisationModule],\n  providers: [\n    { provide: AUTHORISATION_HANDLER, useClass: YourAuthorisationService },\n    { provide: AUTHORISATION_CLASS, useValue: 'your-specific-class' },\n  ],\n  bootstrap: [AppComponent],\n})\nexport class AppModule {}\n```\n\nAdd the authorisation structural directive to your template using the asterisk (\\*) syntax, to prevent displaying components if the user\ndoes not have `READ` access.\n\n```angular2html\n<div *authorisation=\"'BIG_RED_BUTTON'\">\n  The div won't be part of the DOM if the user does not have READ access.\n</div>\n```\n\nIf you would like to disable a button, or a template-driven form input, you can use the directive's `WRITE` access checker method.\n\n```angular2html\n<div *authorisation=\"'BIG_RED_BUTTON'; let hasOnlyReadAccess\">\n  The \"hasOnlyReadAccess\" method will return the provided boolean if the user has write access,\n  otherwise, the button is disabled.\n  <button [disabled]=\"hasOnlyReadAccess(isDisabled)\">BIG RED BUTTON</button>\n</div>\n```\n\nYou can also disable reactive form controls, groups and arrays as well, passing the formControl as the control parameter\n\n```angular2html\n<div *authorisation=\"'BIG_RED_BUTTON'; control: formControl\">\n  <div>\n    <label for=\"simpleControl\">Simple FormControl bound using [formControl]</label>\n    <input id=\"simpleControl\" [formControl]=\"formControl\" />\n  </div>\n</div>\n<form *authorisation=\"'LAUNCH_CODE_INPUTS'; control: launchCodesForm\" [formGroup]=\"launchCodesForm\">\n  <label for=\"primary-high-ranking-officer\">First officer access code:</label>\n  <input id=\"primary-high-ranking-officer\" formControlName=\"firstOfficerAccessCode\" />\n\n  <label for=\"secondary-high-ranking-officer\">Second officer access code:</label>\n  <input id=\"secondary-high-ranking-officer\" formControlName=\"secondOfficerAccessCode\" />\n</form>\n\n```\n\n---\n\nThis authorisation directive might not be sufficient to your authorisation handling needs, but feel free to copy the code and make the\nnecessary changes for yourself. Please, if you do so, throw me a tweet [@TapaiBalazs](https://twitter.com/TapaiBalazs)\n","readmeFilename":"README.md"}