0.0.1 • Published 5 years ago

ngx-trust v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

ngx-trust

CircleCI npm npm License

Because I'm tired of copying this stuff between projects. https://www.npmjs.com/package/ngx-trust

About

It's a good idea to read about the DomSanitizer and Angular Security first in order to understand the implications of bypassing the sanitizer.

This trivial library adds a few Pipes to make bypassing the DomSanitizer more convenient.

Getting Started

  1. Install via npm or yarn
npm i -S ngx-trust
//------------- OR --------------
yarn add ngx-trust
  1. Import NgxTrustModule in your application
import { NgxTrustModule } from 'ngx-trust';
@NgModule({
  ...
  imports: [NgxTrustModule],
  ...
})
export class AppModule { }

Usage

Use the Pipes as needed. For example:

<!-- Injects HTML without sanitizing -->
<div [innerHtml]="someHtml | trustHtml"></div>

<!-- Alternative Pipe syntax -->
<div [innerHtml]="someHtml | trustAs:'html'"></div>

Pipes introduces for trusting (bypassing):

  • trustHtml
  • trustResourceUrl
  • trustScript
  • trustStyle
  • trustUrl
  • trustAs (used like trustAs:'html|resourceUrl|script|style|url')

Local Development

If you wish to contribute to this repository, below are the steps for local development.

  1. Clone the repository git clone https://github.com/cf91/ngx-trust.git
  2. Run npm install to install the dependencies
  3. Run npm build to build both the library and demo app and create a link
  4. Run npm start to build and watch the demo app (opens the app at http://localhost:4200/ automatically)
  5. Run npm watch:lib to build and watch the library

Build

Run npm run build to build the library and demo app together. The build artifacts will be stored in the dist/ directory.

This step is used by CircleCI to build both library and demo app. After a succesful build, a new semantic version of library is published to npm.

Tests

Run npm run test:lib or npm run test:app to execute the unit tests via Karma.

0.0.1

5 years ago

0.0.0

5 years ago