@triangular/password-checker 20.0.0 → 21.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -24,6 +24,7 @@ Supported Angular Versions
24
24
  | 18.x | 13.0.0 - 13.2.0 |
25
25
  | 19.x | 14.0.0 |
26
26
  | 20.x | 20.0.0 |
27
+ | 21.x | 21.0.0 |
27
28
 
28
29
 
29
30
  ### Step 1: Install
@@ -2,15 +2,15 @@ import { timer } from 'rxjs';
2
2
  import { switchMap, map } from 'rxjs/operators';
3
3
  import { NG_ASYNC_VALIDATORS } from '@angular/forms';
4
4
  import * as i0 from '@angular/core';
5
- import { InjectionToken, Input, Optional, Inject, Directive, NgModule } from '@angular/core';
6
- import * as i1 from '@angular/common/http';
7
- import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
5
+ import { InjectionToken, inject, Input, Directive, NgModule } from '@angular/core';
6
+ import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
8
7
 
9
8
  const PasswordCheckerConfigValue = new InjectionToken('PASSWORD_CHECKER_CONFIG');
10
9
 
11
10
  class PasswordCheckerLibDirective {
12
- constructor(http, config) {
13
- this.http = http;
11
+ constructor() {
12
+ this.http = inject(HttpClient);
13
+ let config = inject(PasswordCheckerConfigValue, { optional: true });
14
14
  if (!config) {
15
15
  // default initialization in constructor didn't work.
16
16
  // conflict with @Optional()?
@@ -45,8 +45,8 @@ class PasswordCheckerLibDirective {
45
45
  ? { pwnedPasswordOccurrence: password.count }
46
46
  : null));
47
47
  }
48
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: PasswordCheckerLibDirective, deps: [{ token: i1.HttpClient }, { token: PasswordCheckerConfigValue, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
49
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0", type: PasswordCheckerLibDirective, isStandalone: true, selector: "[pwnedPasswordValidator][formControlName], [pwnedPasswordValidator][ngModel],[pwnedPasswordValidator][formControl]", inputs: { pwnedPasswordApi: "pwnedPasswordApi", pwnedPasswordMinimumOccurrenceForError: "pwnedPasswordMinimumOccurrenceForError", pwnedPasswordApiCallDebounceTime: "pwnedPasswordApiCallDebounceTime" }, providers: [
48
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: PasswordCheckerLibDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
49
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.0", type: PasswordCheckerLibDirective, isStandalone: true, selector: "[pwnedPasswordValidator][formControlName], [pwnedPasswordValidator][ngModel],[pwnedPasswordValidator][formControl]", inputs: { pwnedPasswordApi: "pwnedPasswordApi", pwnedPasswordMinimumOccurrenceForError: "pwnedPasswordMinimumOccurrenceForError", pwnedPasswordApiCallDebounceTime: "pwnedPasswordApiCallDebounceTime" }, providers: [
50
50
  {
51
51
  provide: NG_ASYNC_VALIDATORS,
52
52
  useExisting: PasswordCheckerLibDirective,
@@ -54,7 +54,7 @@ class PasswordCheckerLibDirective {
54
54
  },
55
55
  ], ngImport: i0 }); }
56
56
  }
57
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: PasswordCheckerLibDirective, decorators: [{
57
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: PasswordCheckerLibDirective, decorators: [{
58
58
  type: Directive,
59
59
  args: [{
60
60
  // eslint-disable-next-line @angular-eslint/directive-selector
@@ -68,12 +68,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
68
68
  ],
69
69
  standalone: true
70
70
  }]
71
- }], ctorParameters: () => [{ type: i1.HttpClient }, { type: undefined, decorators: [{
72
- type: Optional
73
- }, {
74
- type: Inject,
75
- args: [PasswordCheckerConfigValue]
76
- }] }], propDecorators: { pwnedPasswordApi: [{
71
+ }], ctorParameters: () => [], propDecorators: { pwnedPasswordApi: [{
77
72
  type: Input
78
73
  }], pwnedPasswordMinimumOccurrenceForError: [{
79
74
  type: Input
@@ -93,11 +88,11 @@ class PasswordCheckerModule {
93
88
  ]
94
89
  };
95
90
  }
96
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: PasswordCheckerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
97
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.0", ngImport: i0, type: PasswordCheckerModule, imports: [PasswordCheckerLibDirective], exports: [PasswordCheckerLibDirective] }); }
98
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: PasswordCheckerModule, providers: [provideHttpClient(withInterceptorsFromDi())] }); }
91
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: PasswordCheckerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
92
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.1.0", ngImport: i0, type: PasswordCheckerModule, imports: [PasswordCheckerLibDirective], exports: [PasswordCheckerLibDirective] }); }
93
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: PasswordCheckerModule, providers: [provideHttpClient(withInterceptorsFromDi())] }); }
99
94
  }
100
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: PasswordCheckerModule, decorators: [{
95
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.0", ngImport: i0, type: PasswordCheckerModule, decorators: [{
101
96
  type: NgModule,
102
97
  args: [{ declarations: [],
103
98
  exports: [PasswordCheckerLibDirective], imports: [PasswordCheckerLibDirective], providers: [provideHttpClient(withInterceptorsFromDi())] }]
@@ -1 +1 @@
1
- {"version":3,"file":"triangular-password-checker.mjs","sources":["../../../projects/password-checker-lib/src/lib/password-checker.config.ts","../../../projects/password-checker-lib/src/lib/password-checker-lib.directive.ts","../../../projects/password-checker-lib/src/lib/password-checker-lib.module.ts","../../../projects/password-checker-lib/src/public_api.ts","../../../projects/password-checker-lib/src/triangular-password-checker.ts"],"sourcesContent":["import {InjectionToken} from '@angular/core';\n\nexport type Partial<T> = {\n [P in keyof T]?: T[P];\n};\n\nexport interface PasswordCheckerConfig {\n pwnedPasswordApi: string;\n pwnedPasswordMinimumOccurrenceForError: number;\n pwnedPasswordApiCallDebounceTime: number;\n}\n\nexport const PasswordCheckerConfigValue = new InjectionToken<Partial<PasswordCheckerConfig>>('PASSWORD_CHECKER_CONFIG');\n","import { Observable, timer } from 'rxjs';\nimport { map, switchMap } from 'rxjs/operators';\nimport { AbstractControl, AsyncValidator, NG_ASYNC_VALIDATORS, ValidationErrors } from '@angular/forms';\nimport { Directive, Inject, Input, Optional } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Partial, PasswordCheckerConfig, PasswordCheckerConfigValue } from './password-checker.config';\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector\n selector: '[pwnedPasswordValidator][formControlName], [pwnedPasswordValidator][ngModel],[pwnedPasswordValidator][formControl]',\n providers: [\n {\n provide: NG_ASYNC_VALIDATORS,\n useExisting: PasswordCheckerLibDirective,\n multi: true,\n },\n ],\n standalone: true\n})\nexport class PasswordCheckerLibDirective implements AsyncValidator {\n @Input() pwnedPasswordApi: string;\n @Input() pwnedPasswordMinimumOccurrenceForError: number;\n @Input() pwnedPasswordApiCallDebounceTime: number;\n\n constructor(\n private http: HttpClient,\n @Optional() @Inject(PasswordCheckerConfigValue) config: Partial<PasswordCheckerConfig>,\n ) {\n\n if (!config) {\n // default initialization in constructor didn't work.\n // conflict with @Optional()?\n config = {};\n }\n\n this.pwnedPasswordApi =\n config.pwnedPasswordApi\n || 'https://api.pwnedpasswords.com/range/';\n this.pwnedPasswordMinimumOccurrenceForError =\n config.pwnedPasswordMinimumOccurrenceForError\n || 1;\n this.pwnedPasswordApiCallDebounceTime =\n config.pwnedPasswordApiCallDebounceTime\n || 400;\n }\n\n validate(control: AbstractControl): Observable<ValidationErrors|null> {\n const pw = ''.concat(control.value);\n\n return timer(this.pwnedPasswordApiCallDebounceTime).pipe(\n switchMap(() => crypto.subtle.digest('SHA-1', new TextEncoder().encode(pw))),\n map((pwSha1 => Array.from(new Uint8Array(pwSha1))\n .map(v => v.toString(16).padStart(2, '0'))\n .join(''))),\n map(pwSha1 => pwSha1.toUpperCase()),\n map((pwSha1) => {\n\n return {\n firstPart: pwSha1.substring(0, 5),\n lastPart: pwSha1.substring(5),\n };\n }),\n switchMap(\n (hash) => this.http.get(\n `${this.pwnedPasswordApi}${hash.firstPart}`, { responseType: 'text' }\n ).pipe(\n map(passwords => passwords.split(/[\\r\\n]+/)),\n map(passwords => passwords.map((password) => {\n const split = password.split(':');\n\n return {\n hash: split[0],\n count: parseInt(split[1], 10),\n };\n }\n )),\n map(passwords => passwords.find(password => password.hash === hash.lastPart)),\n ),\n ),\n map(password => password && password.count >= this.pwnedPasswordMinimumOccurrenceForError\n ? { pwnedPasswordOccurrence: password.count }\n : null),\n );\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { PasswordCheckerLibDirective } from './password-checker-lib.directive';\nimport { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';\nimport { Partial, PasswordCheckerConfig, PasswordCheckerConfigValue } from './password-checker.config';\n\n@NgModule({ declarations: [],\n exports: [PasswordCheckerLibDirective], imports: [PasswordCheckerLibDirective], providers: [provideHttpClient(withInterceptorsFromDi())] })\nexport class PasswordCheckerModule {\n static forRoot(config: Partial<PasswordCheckerConfig> = {}): ModuleWithProviders<PasswordCheckerModule> {\n return {\n ngModule: PasswordCheckerModule,\n providers: [\n {\n provide: PasswordCheckerConfigValue,\n useValue: config,\n }\n ]\n };\n }\n}\n","/*\n * Public API Surface of password-checker-lib\n */\n\nexport * from './lib/password-checker-lib.directive';\nexport * from './lib/password-checker-lib.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;AAYO,MAAM,0BAA0B,GAAG,IAAI,cAAc,CAAiC,yBAAyB,CAAC;;MCO1G,2BAA2B,CAAA;IAKtC,WACU,CAAA,IAAgB,EACwB,MAAsC,EAAA;QAD9E,IAAI,CAAA,IAAA,GAAJ,IAAI;QAIZ,IAAI,CAAC,MAAM,EAAE;;;YAGX,MAAM,GAAG,EAAE;;AAGb,QAAA,IAAI,CAAC,gBAAgB;AACnB,YAAA,MAAM,CAAC;AACJ,mBAAA,uCAAuC;AAC5C,QAAA,IAAI,CAAC,sCAAsC;AACzC,YAAA,MAAM,CAAC;AACJ,mBAAA,CAAC;AACN,QAAA,IAAI,CAAC,gCAAgC;AACnC,YAAA,MAAM,CAAC;AACJ,mBAAA,GAAG;;AAGV,IAAA,QAAQ,CAAC,OAAwB,EAAA;QAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;QAEnC,OAAO,KAAK,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAC,IAAI,CACtD,SAAS,CAAC,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAC5E,GAAG,EAAE,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC;AAC7C,aAAA,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;aACxC,IAAI,CAAC,EAA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xD,OAAO;AACL,YAAA,QAAQ,EAAE,qBAAqB;AAC/B,YAAA,SAAS,EAAE;AACT,gBAAA;AACE,oBAAA,OAAO,EAAE,0BAA0B;AACnC,oBAAA,QAAQ,EAAE,MAAM;AACjB;AACF;SACF;;8GAVQ,qBAAqB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;+GAArB,qBAAqB,EAAA,OAAA,EAAA,CADoB,2BAA2B,CAAA,EAAA,OAAA,EAAA,CAAnE,2BAA2B,CAAA,EAAA,CAAA,CAAA;AAC5B,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,qBAAqB,aAD6D,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAA,CAAA,CAAA;;2FAC/H,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAFjC,QAAQ;mBAAC,EAAE,YAAY,EAAE,EAAE;oBACxB,OAAO,EAAE,CAAC,2BAA2B,CAAC,EAAE,OAAO,EAAE,CAAC,2BAA2B,CAAC,EAAE,SAAS,EAAE,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE;;;ACN9I;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"triangular-password-checker.mjs","sources":["../../../projects/password-checker-lib/src/lib/password-checker.config.ts","../../../projects/password-checker-lib/src/lib/password-checker-lib.directive.ts","../../../projects/password-checker-lib/src/lib/password-checker-lib.module.ts","../../../projects/password-checker-lib/src/public_api.ts","../../../projects/password-checker-lib/src/triangular-password-checker.ts"],"sourcesContent":["import {InjectionToken} from '@angular/core';\n\nexport type Partial<T> = {\n [P in keyof T]?: T[P];\n};\n\nexport interface PasswordCheckerConfig {\n pwnedPasswordApi: string;\n pwnedPasswordMinimumOccurrenceForError: number;\n pwnedPasswordApiCallDebounceTime: number;\n}\n\nexport const PasswordCheckerConfigValue = new InjectionToken<Partial<PasswordCheckerConfig>>('PASSWORD_CHECKER_CONFIG');\n","import { Observable, timer } from 'rxjs';\nimport { map, switchMap } from 'rxjs/operators';\nimport { AbstractControl, AsyncValidator, NG_ASYNC_VALIDATORS, ValidationErrors } from '@angular/forms';\nimport { Directive, Input, inject } from '@angular/core';\nimport { HttpClient } from '@angular/common/http';\nimport { Partial, PasswordCheckerConfig, PasswordCheckerConfigValue } from './password-checker.config';\n\n@Directive({\n // eslint-disable-next-line @angular-eslint/directive-selector\n selector: '[pwnedPasswordValidator][formControlName], [pwnedPasswordValidator][ngModel],[pwnedPasswordValidator][formControl]',\n providers: [\n {\n provide: NG_ASYNC_VALIDATORS,\n useExisting: PasswordCheckerLibDirective,\n multi: true,\n },\n ],\n standalone: true\n})\nexport class PasswordCheckerLibDirective implements AsyncValidator {\n private http = inject(HttpClient);\n\n @Input() pwnedPasswordApi: string;\n @Input() pwnedPasswordMinimumOccurrenceForError: number;\n @Input() pwnedPasswordApiCallDebounceTime: number;\n\n constructor() {\n let config = inject<Partial<PasswordCheckerConfig>>(PasswordCheckerConfigValue, { optional: true });\n\n\n if (!config) {\n // default initialization in constructor didn't work.\n // conflict with @Optional()?\n config = {};\n }\n\n this.pwnedPasswordApi =\n config.pwnedPasswordApi\n || 'https://api.pwnedpasswords.com/range/';\n this.pwnedPasswordMinimumOccurrenceForError =\n config.pwnedPasswordMinimumOccurrenceForError\n || 1;\n this.pwnedPasswordApiCallDebounceTime =\n config.pwnedPasswordApiCallDebounceTime\n || 400;\n }\n\n validate(control: AbstractControl): Observable<ValidationErrors|null> {\n const pw = ''.concat(control.value);\n\n return timer(this.pwnedPasswordApiCallDebounceTime).pipe(\n switchMap(() => crypto.subtle.digest('SHA-1', new TextEncoder().encode(pw))),\n map((pwSha1 => Array.from(new Uint8Array(pwSha1))\n .map(v => v.toString(16).padStart(2, '0'))\n .join(''))),\n map(pwSha1 => pwSha1.toUpperCase()),\n map((pwSha1) => {\n\n return {\n firstPart: pwSha1.substring(0, 5),\n lastPart: pwSha1.substring(5),\n };\n }),\n switchMap(\n (hash) => this.http.get(\n `${this.pwnedPasswordApi}${hash.firstPart}`, { responseType: 'text' }\n ).pipe(\n map(passwords => passwords.split(/[\\r\\n]+/)),\n map(passwords => passwords.map((password) => {\n const split = password.split(':');\n\n return {\n hash: split[0],\n count: parseInt(split[1], 10),\n };\n }\n )),\n map(passwords => passwords.find(password => password.hash === hash.lastPart)),\n ),\n ),\n map(password => password && password.count >= this.pwnedPasswordMinimumOccurrenceForError\n ? { pwnedPasswordOccurrence: password.count }\n : null),\n );\n }\n}\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { PasswordCheckerLibDirective } from './password-checker-lib.directive';\nimport { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';\nimport { Partial, PasswordCheckerConfig, PasswordCheckerConfigValue } from './password-checker.config';\n\n@NgModule({ declarations: [],\n exports: [PasswordCheckerLibDirective], imports: [PasswordCheckerLibDirective], providers: [provideHttpClient(withInterceptorsFromDi())] })\nexport class PasswordCheckerModule {\n static forRoot(config: Partial<PasswordCheckerConfig> = {}): ModuleWithProviders<PasswordCheckerModule> {\n return {\n ngModule: PasswordCheckerModule,\n providers: [\n {\n provide: PasswordCheckerConfigValue,\n useValue: config,\n }\n ]\n };\n }\n}\n","/*\n * Public API Surface of password-checker-lib\n */\n\nexport * from './lib/password-checker-lib.directive';\nexport * from './lib/password-checker-lib.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;AAYO,MAAM,0BAA0B,GAAG,IAAI,cAAc,CAAiC,yBAAyB,CAAC;;MCO1G,2BAA2B,CAAA;AAOtC,IAAA,WAAA,GAAA;AANQ,QAAA,IAAA,CAAA,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC;AAO/B,QAAA,IAAI,MAAM,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AA;;2FAC/H,qBAAqB,EAAA,UAAA,EAAA,CAAA;kBAFjC,QAAQ;mBAAC,EAAE,YAAY,EAAE,EAAE;oBACxB,OAAO,EAAE,CAAC,2BAA2B,CAAC,EAAE,OAAO,EAAE,CAAC,2BAA2B,CAAC,EAAE,SAAS,EAAE,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,CAAC,CAAC,EAAE;;;ACN9I;;AAEG;;ACFH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@triangular/password-checker",
3
- "version": "20.0.0",
3
+ "version": "21.0.0",
4
4
  "peerDependencies": {
5
- "@angular/common": "^20.0.0",
6
- "@angular/core": "^20.0.0"
5
+ "@angular/common": "^21.0.0",
6
+ "@angular/core": "^21.0.0"
7
7
  },
8
8
  "homepage": "https://password.akehir.com",
9
9
  "license": "MIT",
@@ -13,24 +13,24 @@
13
13
  },
14
14
  "bugs": {
15
15
  "url": "https://github.com/akehir/angular-password-checker/issues",
16
- "email": "raphael@ochsenbe.in"
16
+ "email": "raphael@akehir.com"
17
17
  },
18
18
  "author": {
19
19
  "name": "Raphael Ochsenbein",
20
- "email": "raphael@ochsenbe.in",
20
+ "email": "raphael@akehir.com",
21
21
  "url": "https://akehir.com/"
22
22
  },
23
23
  "dependencies": {
24
24
  "tslib": "^2.0.0"
25
25
  },
26
26
  "module": "fesm2022/triangular-password-checker.mjs",
27
- "typings": "index.d.ts",
27
+ "typings": "types/triangular-password-checker.d.ts",
28
28
  "exports": {
29
29
  "./package.json": {
30
30
  "default": "./package.json"
31
31
  },
32
32
  ".": {
33
- "types": "./index.d.ts",
33
+ "types": "./types/triangular-password-checker.d.ts",
34
34
  "default": "./fesm2022/triangular-password-checker.mjs"
35
35
  }
36
36
  },
@@ -1,27 +1,26 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { AsyncValidator, AbstractControl, ValidationErrors } from '@angular/forms';
3
- import { HttpClient } from '@angular/common/http';
4
3
  import * as i0 from '@angular/core';
5
4
  import { ModuleWithProviders } from '@angular/core';
6
5
 
7
- type Partial<T> = {
8
- [P in keyof T]?: T[P];
9
- };
10
- interface PasswordCheckerConfig {
6
+ declare class PasswordCheckerLibDirective implements AsyncValidator {
7
+ private http;
11
8
  pwnedPasswordApi: string;
12
9
  pwnedPasswordMinimumOccurrenceForError: number;
13
10
  pwnedPasswordApiCallDebounceTime: number;
11
+ constructor();
12
+ validate(control: AbstractControl): Observable<ValidationErrors | null>;
13
+ static ɵfac: i0.ɵɵFactoryDeclaration<PasswordCheckerLibDirective, never>;
14
+ static ɵdir: i0.ɵɵDirectiveDeclaration<PasswordCheckerLibDirective, "[pwnedPasswordValidator][formControlName], [pwnedPasswordValidator][ngModel],[pwnedPasswordValidator][formControl]", never, { "pwnedPasswordApi": { "alias": "pwnedPasswordApi"; "required": false; }; "pwnedPasswordMinimumOccurrenceForError": { "alias": "pwnedPasswordMinimumOccurrenceForError"; "required": false; }; "pwnedPasswordApiCallDebounceTime": { "alias": "pwnedPasswordApiCallDebounceTime"; "required": false; }; }, {}, never, never, true, never>;
14
15
  }
15
16
 
16
- declare class PasswordCheckerLibDirective implements AsyncValidator {
17
- private http;
17
+ type Partial<T> = {
18
+ [P in keyof T]?: T[P];
19
+ };
20
+ interface PasswordCheckerConfig {
18
21
  pwnedPasswordApi: string;
19
22
  pwnedPasswordMinimumOccurrenceForError: number;
20
23
  pwnedPasswordApiCallDebounceTime: number;
21
- constructor(http: HttpClient, config: Partial<PasswordCheckerConfig>);
22
- validate(control: AbstractControl): Observable<ValidationErrors | null>;
23
- static ɵfac: i0.ɵɵFactoryDeclaration<PasswordCheckerLibDirective, [null, { optional: true; }]>;
24
- static ɵdir: i0.ɵɵDirectiveDeclaration<PasswordCheckerLibDirective, "[pwnedPasswordValidator][formControlName], [pwnedPasswordValidator][ngModel],[pwnedPasswordValidator][formControl]", never, { "pwnedPasswordApi": { "alias": "pwnedPasswordApi"; "required": false; }; "pwnedPasswordMinimumOccurrenceForError": { "alias": "pwnedPasswordMinimumOccurrenceForError"; "required": false; }; "pwnedPasswordApiCallDebounceTime": { "alias": "pwnedPasswordApiCallDebounceTime"; "required": false; }; }, {}, never, never, true, never>;
25
24
  }
26
25
 
27
26
  declare class PasswordCheckerModule {