UNPKG

web-otp-angular

Version:

Angular library to automatically detect OTP from mobile device (Both mobile web site and Desktop)

1 lines 3.61 kB
{"version":3,"file":"web-otp-angular.mjs","sources":["../../../projects/web-otp-angular/src/lib/web-otp.directive.ts","../../../projects/web-otp-angular/src/lib/web-otp-angular.module.ts","../../../projects/web-otp-angular/src/public-api.ts","../../../projects/web-otp-angular/src/web-otp-angular.ts"],"sourcesContent":["import { Directive, ElementRef, Input, OnDestroy, OnInit } from '@angular/core';\ninterface CredentialRequestOptions {\n otp: any;\n signal: any;\n}\n\n@Directive({\n selector: '[appWebOtp]',\n})\nexport class WebOtpDirective implements OnInit, OnDestroy {\n private ac = new AbortController();\n private timer: NodeJS.Timeout | null = null;\n constructor(private el: ElementRef) { };\n\n @Input('timeout') timeout?: number;\n\n ngOnInit(): void {\n const options: CredentialRequestOptions = {\n otp: { transport: ['sms'] },\n signal: this.ac.signal\n }\n navigator.credentials.get(options).then((otp: any) => {\n this.el.nativeElement.value = otp.code;\n }).catch(err => {\n console.log(err);\n });\n if (this.timeout) {\n this.timer = setTimeout(() => {\n this.ac.abort();\n }, this.timeout)\n }\n }\n ngOnDestroy(): void {\n this.ac.abort();\n if (this.timer) {\n clearTimeout(this.timer);\n }\n }\n}\n","import { NgModule } from '@angular/core';\nimport { WebOtpDirective } from './web-otp.directive';\n\n\n\n@NgModule({\n declarations: [\n WebOtpDirective,\n ],\n imports: [\n ],\n exports: [\n WebOtpDirective,\n ]\n})\nexport class WebOtpAngularModule { }\n","/*\n * Public API Surface of web-otp-angular\n */\n\nexport * from './lib/web-otp.directive';\nexport * from './lib/web-otp-angular.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;MASa,eAAe,CAAA;AAG1B,IAAA,WAAA,CAAoB,EAAc,EAAA;QAAd,IAAE,CAAA,EAAA,GAAF,EAAE,CAAY;AAF1B,QAAA,IAAA,CAAA,EAAE,GAAG,IAAI,eAAe,EAAE,CAAC;QAC3B,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