@ciright/ngx-fido

This is a ciright fido card connection library working with Angular 10+.

Usage no npm install needed!

<script type="module">
  import cirightNgxFido from 'https://cdn.skypack.dev/@ciright/ngx-fido';
</script>

README

ngx-fido

Ciright Logo

Description

This is a ciright fido card connection library working with Angular 10+.

Installation

Install the library into your project via npm

npm i --save @ciright/ngx-fido

Usage

  • Import NgxFidoModule and provide global config variables
// app.module.ts
import { NgxFidoModule } from '@ciright/ngx-fido';
import { AppComponent } from './app.component';

@NgModule({
    imports: [
        BrowserModule,
        NgxFidoModule.forRoot({
            url: 'YOUR_CIRIGHT_ENDPOINT--THIS_IS_OPTIONAL',
            token: 'YOUR_AUTH_TOKEN'
        })
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule {}
  • Register New User
    • Import the NgxFidoService in your component.
// app.component.ts
import { NgxFidoService } from '@ciright/ngx-fido';

@Component({...})
export class YourComponent {
    constructor(private fidoService: NgxFidoService) {}

    registerUser() {
        this.fidoService.registerUser(this.username, (err, result) => {
            if (err) {
                console.log(err);
            } else {
                console.log(result);
            }
        });
    }
}
  • Authenticate User
    • Import the NgxFidoService in your component.
// app.component.ts
import { NgxFidoService } from '@ciright/ngx-fido';

@Component({...})
export class YourComponent {
    constructor(private fidoService: NgxFidoService) {}

    authenticateUser() {
        this.fidoService.authenticateUser(this.username, (err, result) => {
            if (err) {
                console.log(err);
            } else {
                console.log(result);
            }
        });
    }
}