http-client-with-recaptcha 1.2.0 → 1.4.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/esm2020/lib/http-client-with-recaptcha.module.mjs +1 -2
- package/fesm2015/http-client-with-recaptcha.mjs +0 -1
- package/fesm2015/http-client-with-recaptcha.mjs.map +1 -1
- package/fesm2020/http-client-with-recaptcha.mjs +0 -1
- package/fesm2020/http-client-with-recaptcha.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,6 @@ import * as i0 from "@angular/core";
|
|
|
6
6
|
export class HttpClientWithRecaptchaModule {
|
|
7
7
|
constructor(siteKey) {
|
|
8
8
|
this.siteKey = siteKey;
|
|
9
|
-
console.log(siteKey);
|
|
10
9
|
if (!this.siteKey) {
|
|
11
10
|
console.error('No reCAPTCHA site key provided. Please configure the RECAPTCHA_V3_KEY.');
|
|
12
11
|
}
|
|
@@ -40,4 +39,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
40
39
|
type: Inject,
|
|
41
40
|
args: [RECAPTCHA_V3_KEY]
|
|
42
41
|
}] }]; } });
|
|
43
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC1jbGllbnQtd2l0aC1yZWNhcHRjaGEubW9kdWxlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvaHR0cC1jbGllbnQtd2l0aC1yZWNhcHRjaGEvc3JjL2xpYi9odHRwLWNsaWVudC13aXRoLXJlY2FwdGNoYS5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFDLE1BQU0sRUFBRSxRQUFRLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFDL0MsT0FBTyxFQUFDLDhC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aXRlS2V5KSB7XHJcbiAgICAgIGNvbnNvbGUuZXJyb3IoJ05vIHJlQ0FQVENIQSBzaXRlIGtleSBwcm92aWRlZC4gUGxlYXNlIGNvbmZpZ3VyZSB0aGUgUkVDQVBUQ0hBX1YzX0tFWS4nKTtcclxuICAgIH1cclxuICB9XHJcbn1cclxuIl19
|
|
@@ -76,7 +76,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
76
76
|
class HttpClientWithRecaptchaModule {
|
|
77
77
|
constructor(siteKey) {
|
|
78
78
|
this.siteKey = siteKey;
|
|
79
|
-
console.log(siteKey);
|
|
80
79
|
if (!this.siteKey) {
|
|
81
80
|
console.error('No reCAPTCHA site key provided. Please configure the RECAPTCHA_V3_KEY.');
|
|
82
81
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client-with-recaptcha.mjs","sources":["../../../projects/http-client-with-recaptcha/src/lib/app-config.tokens.ts","../../../projects/http-client-with-recaptcha/src/lib/http-client-with-recaptcha.service.ts","../../../projects/http-client-with-recaptcha/src/lib/http-client-with-recaptcha.module.ts","../../../projects/http-client-with-recaptcha/src/public-api.ts","../../../projects/http-client-with-recaptcha/src/http-client-with-recaptcha.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\nexport const RECAPTCHA_HEADER_NAME = new InjectionToken<string>('reCAPTCHA Header Name', {\r\n providedIn: 'root',\r\n factory: () => 'X-Recaptcha-Token', // Default value\r\n});\r\n\r\n\r\nexport const RECAPTCHA_V3_KEY = new InjectionToken<string>('RECAPTCHA_V3_KEY', {\r\n providedIn: 'root', // You can provide it in the root or any other module depending on your need\r\n factory: () => {\r\n return 'your-site-key'; // Default value or fallback (can be overridden later)\r\n },\r\n});\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\r\nimport { ReCaptchaV3Service } from 'ng-recaptcha';\r\nimport { Observable, of } from 'rxjs';\r\nimport { switchMap, map } from 'rxjs/operators';\r\nimport { RECAPTCHA_HEADER_NAME } from './app-config.tokens';\r\n\r\n@Injectable({\r\n providedIn: 'root', // Provides the service at the root level\r\n})\r\nexport class HttpClientWithRecaptchaService {\r\n constructor(\r\n private http: HttpClient,\r\n private recaptchaV3Service: ReCaptchaV3Service,\r\n @Inject(RECAPTCHA_HEADER_NAME) private readonly headerName: string\r\n ) {}\r\n\r\n /**\r\n * Prepares headers for HTTP requests, optionally including a reCAPTCHA token.\r\n * @param action - Optional reCAPTCHA action.\r\n * @returns An Observable with the prepared HttpHeaders.\r\n */\r\n private prepareHeaders(action?: string): Observable<HttpHeaders> {\r\n if (!action) {\r\n return of(new HttpHeaders());\r\n }\r\n\r\n return this.recaptchaV3Service.execute(action).pipe(\r\n map((recaptchaToken) =>\r\n new HttpHeaders({\r\n [this.headerName]: recaptchaToken,\r\n })\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Performs a GET request with optional reCAPTCHA verification.\r\n * @param url - The endpoint URL.\r\n * @param action - Optional reCAPTCHA action.\r\n * @param options - Additional request options.\r\n * @returns An Observable of the response.\r\n */\r\n get<T>(url: string, action?: string, options = {}): Observable<T> {\r\n return this.prepareHeaders(action).pipe(\r\n switchMap((headers) =>\r\n this.http.get<T>(url, { ...options, headers })\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Performs a POST request with optional reCAPTCHA verification.\r\n * @param url - The endpoint URL.\r\n * @param action - Optional reCAPTCHA action.\r\n * @param body - The payload to send in the POST request.\r\n * @param options - Additional request options.\r\n * @returns An Observable of the response.\r\n */\r\n post<T>(url: string, body: any,action?: string, options = {}): Observable<T> {\r\n return this.prepareHeaders(action).pipe(\r\n switchMap((headers) =>\r\n this.http.post<T>(url, body, { ...options, headers })\r\n )\r\n );\r\n }\r\n}\r\n","import {Inject, NgModule} from '@angular/core';\r\nimport {HttpClientWithRecaptchaService} from \"./http-client-with-recaptcha.service\";\r\nimport {RecaptchaV3Module, RECAPTCHA_V3_SITE_KEY, ReCaptchaV3Service} from \"ng-recaptcha\";\r\nimport {RECAPTCHA_HEADER_NAME, RECAPTCHA_V3_KEY} from \"./app-config.tokens\";\r\n\r\n@NgModule({\r\n imports: [RecaptchaV3Module],\r\n exports: [],\r\n providers: [\r\n HttpClientWithRecaptchaService,\r\n ReCaptchaV3Service,\r\n {\r\n provide: RECAPTCHA_V3_SITE_KEY, // This injects the site key into ng-recaptcha\r\n useExisting: RECAPTCHA_V3_KEY, // Pass the value of your custom token to ng-recaptcha\r\n }\r\n ]\r\n})\r\nexport class HttpClientWithRecaptchaModule {\r\n\r\n constructor(@Inject(RECAPTCHA_V3_KEY) private siteKey: string) {\r\n
|
|
1
|
+
{"version":3,"file":"http-client-with-recaptcha.mjs","sources":["../../../projects/http-client-with-recaptcha/src/lib/app-config.tokens.ts","../../../projects/http-client-with-recaptcha/src/lib/http-client-with-recaptcha.service.ts","../../../projects/http-client-with-recaptcha/src/lib/http-client-with-recaptcha.module.ts","../../../projects/http-client-with-recaptcha/src/public-api.ts","../../../projects/http-client-with-recaptcha/src/http-client-with-recaptcha.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\nexport const RECAPTCHA_HEADER_NAME = new InjectionToken<string>('reCAPTCHA Header Name', {\r\n providedIn: 'root',\r\n factory: () => 'X-Recaptcha-Token', // Default value\r\n});\r\n\r\n\r\nexport const RECAPTCHA_V3_KEY = new InjectionToken<string>('RECAPTCHA_V3_KEY', {\r\n providedIn: 'root', // You can provide it in the root or any other module depending on your need\r\n factory: () => {\r\n return 'your-site-key'; // Default value or fallback (can be overridden later)\r\n },\r\n});\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\r\nimport { ReCaptchaV3Service } from 'ng-recaptcha';\r\nimport { Observable, of } from 'rxjs';\r\nimport { switchMap, map } from 'rxjs/operators';\r\nimport { RECAPTCHA_HEADER_NAME } from './app-config.tokens';\r\n\r\n@Injectable({\r\n providedIn: 'root', // Provides the service at the root level\r\n})\r\nexport class HttpClientWithRecaptchaService {\r\n constructor(\r\n private http: HttpClient,\r\n private recaptchaV3Service: ReCaptchaV3Service,\r\n @Inject(RECAPTCHA_HEADER_NAME) private readonly headerName: string\r\n ) {}\r\n\r\n /**\r\n * Prepares headers for HTTP requests, optionally including a reCAPTCHA token.\r\n * @param action - Optional reCAPTCHA action.\r\n * @returns An Observable with the prepared HttpHeaders.\r\n */\r\n private prepareHeaders(action?: string): Observable<HttpHeaders> {\r\n if (!action) {\r\n return of(new HttpHeaders());\r\n }\r\n\r\n return this.recaptchaV3Service.execute(action).pipe(\r\n map((recaptchaToken) =>\r\n new HttpHeaders({\r\n [this.headerName]: recaptchaToken,\r\n })\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Performs a GET request with optional reCAPTCHA verification.\r\n * @param url - The endpoint URL.\r\n * @param action - Optional reCAPTCHA action.\r\n * @param options - Additional request options.\r\n * @returns An Observable of the response.\r\n */\r\n get<T>(url: string, action?: string, options = {}): Observable<T> {\r\n return this.prepareHeaders(action).pipe(\r\n switchMap((headers) =>\r\n this.http.get<T>(url, { ...options, headers })\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Performs a POST request with optional reCAPTCHA verification.\r\n * @param url - The endpoint URL.\r\n * @param action - Optional reCAPTCHA action.\r\n * @param body - The payload to send in the POST request.\r\n * @param options - Additional request options.\r\n * @returns An Observable of the response.\r\n */\r\n post<T>(url: string, body: any,action?: string, options = {}): Observable<T> {\r\n return this.prepareHeaders(action).pipe(\r\n switchMap((headers) =>\r\n this.http.post<T>(url, body, { ...options, headers })\r\n )\r\n );\r\n }\r\n}\r\n","import {Inject, NgModule} from '@angular/core';\r\nimport {HttpClientWithRecaptchaService} from \"./http-client-with-recaptcha.service\";\r\nimport {RecaptchaV3Module, RECAPTCHA_V3_SITE_KEY, ReCaptchaV3Service} from \"ng-recaptcha\";\r\nimport {RECAPTCHA_HEADER_NAME, RECAPTCHA_V3_KEY} from \"./app-config.tokens\";\r\n\r\n@NgModule({\r\n imports: [RecaptchaV3Module],\r\n exports: [],\r\n providers: [\r\n HttpClientWithRecaptchaService,\r\n ReCaptchaV3Service,\r\n {\r\n provide: RECAPTCHA_V3_SITE_KEY, // This injects the site key into ng-recaptcha\r\n useExisting: RECAPTCHA_V3_KEY, // Pass the value of your custom token to ng-recaptcha\r\n }\r\n ]\r\n})\r\nexport class HttpClientWithRecaptchaModule {\r\n\r\n constructor(@Inject(RECAPTCHA_V3_KEY) private siteKey: string) {\r\n if (!this.siteKey) {\r\n console.error('No reCAPTCHA site key provided. Please configure the RECAPTCHA_V3_KEY.');\r\n }\r\n }\r\n}\r\n","/*\r\n * Public API Surface of http-client-with-recaptcha\r\n */\r\n\r\nexport * from './lib/app-config.tokens';\r\nexport * from './lib/http-client-with-recaptcha.service';\r\nexport * from './lib/http-client-with-recaptcha.module';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAEa,qBAAqB,GAAG,IAAI,cAAc,CAAS,uBAAuB,EAAE;AACvF,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,mBAAmB;AACnC,CAAA,EAAE;MAGU,gBAAgB,GAAG,IAAI,cAAc,CAAS,kBAAkB,EAAE;AAC7E,IAAA,UAAU,EAAE,MAAM;IAClB,OAAO,EAAE,MAAK;QACZ,OAAO,eAAe,CAAC;KACxB;AACF,CAAA;;MCHY,8BAA8B,CAAA;AACzC,IAAA,WAAA,CACU,IAAgB,EAChB,kBAAsC,EACE,UAAkB,EAAA;AAF1D,QAAA,IAAI,CAAA,IAAA,GAAJ,IAAI,CAAY;AAChB,QAAA,IAAkB,CAAA,kBAAA,GAAlB,kBAAkB,CAAoB;AACE,QAAA,IAAU,CAAA,UAAA,GAAV,UAAU,CAAQ;KAChE;AAEJ;;;;AAIG;AACK,IAAA,cAAc,CAAC,MAAe,EAAA;QACpC,IAAI,CAAC,MAA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AAA,EAAA,6BAA6B,EAT7B,SAAA,EAAA;QACT,8BAA8B;QAC9B,kBAAkB;AAClB,QAAA;AACE,YAAA,OAAO,EAAE,qBAAqB;YAC9B,WAAW,EAAE,gBAAgB;AAC9B,SAAA;AACF,KAAA,EAAA,OAAA,EAAA,CATS,iBAAiB,CAAA,EAAA,CAAA,CAAA;4FAWhB,6BAA6B,EAAA,UAAA,EAAA,CAAA;kBAZzC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,iBAAiB,CAAC;AAC5B,oBAAA,OAAO,EAAE,EAAE;AACX,oBAAA,SAAS,EAAE;wBACT,8BAA8B;wBAC9B,kBAAkB;AAClB,wBAAA;AACE,4BAAA,OAAO,EAAE,qBAAqB;4BAC9B,WAAW,EAAE,gBAAgB;AAC9B,yBAAA;AACF,qBAAA;iBACF,CAAA;;;8BAGc,MAAM;+BAAC,gBAAgB,CAAA;;;;ACnBtC;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -74,7 +74,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.10", ngImpo
|
|
|
74
74
|
class HttpClientWithRecaptchaModule {
|
|
75
75
|
constructor(siteKey) {
|
|
76
76
|
this.siteKey = siteKey;
|
|
77
|
-
console.log(siteKey);
|
|
78
77
|
if (!this.siteKey) {
|
|
79
78
|
console.error('No reCAPTCHA site key provided. Please configure the RECAPTCHA_V3_KEY.');
|
|
80
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client-with-recaptcha.mjs","sources":["../../../projects/http-client-with-recaptcha/src/lib/app-config.tokens.ts","../../../projects/http-client-with-recaptcha/src/lib/http-client-with-recaptcha.service.ts","../../../projects/http-client-with-recaptcha/src/lib/http-client-with-recaptcha.module.ts","../../../projects/http-client-with-recaptcha/src/public-api.ts","../../../projects/http-client-with-recaptcha/src/http-client-with-recaptcha.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\nexport const RECAPTCHA_HEADER_NAME = new InjectionToken<string>('reCAPTCHA Header Name', {\r\n providedIn: 'root',\r\n factory: () => 'X-Recaptcha-Token', // Default value\r\n});\r\n\r\n\r\nexport const RECAPTCHA_V3_KEY = new InjectionToken<string>('RECAPTCHA_V3_KEY', {\r\n providedIn: 'root', // You can provide it in the root or any other module depending on your need\r\n factory: () => {\r\n return 'your-site-key'; // Default value or fallback (can be overridden later)\r\n },\r\n});\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\r\nimport { ReCaptchaV3Service } from 'ng-recaptcha';\r\nimport { Observable, of } from 'rxjs';\r\nimport { switchMap, map } from 'rxjs/operators';\r\nimport { RECAPTCHA_HEADER_NAME } from './app-config.tokens';\r\n\r\n@Injectable({\r\n providedIn: 'root', // Provides the service at the root level\r\n})\r\nexport class HttpClientWithRecaptchaService {\r\n constructor(\r\n private http: HttpClient,\r\n private recaptchaV3Service: ReCaptchaV3Service,\r\n @Inject(RECAPTCHA_HEADER_NAME) private readonly headerName: string\r\n ) {}\r\n\r\n /**\r\n * Prepares headers for HTTP requests, optionally including a reCAPTCHA token.\r\n * @param action - Optional reCAPTCHA action.\r\n * @returns An Observable with the prepared HttpHeaders.\r\n */\r\n private prepareHeaders(action?: string): Observable<HttpHeaders> {\r\n if (!action) {\r\n return of(new HttpHeaders());\r\n }\r\n\r\n return this.recaptchaV3Service.execute(action).pipe(\r\n map((recaptchaToken) =>\r\n new HttpHeaders({\r\n [this.headerName]: recaptchaToken,\r\n })\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Performs a GET request with optional reCAPTCHA verification.\r\n * @param url - The endpoint URL.\r\n * @param action - Optional reCAPTCHA action.\r\n * @param options - Additional request options.\r\n * @returns An Observable of the response.\r\n */\r\n get<T>(url: string, action?: string, options = {}): Observable<T> {\r\n return this.prepareHeaders(action).pipe(\r\n switchMap((headers) =>\r\n this.http.get<T>(url, { ...options, headers })\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Performs a POST request with optional reCAPTCHA verification.\r\n * @param url - The endpoint URL.\r\n * @param action - Optional reCAPTCHA action.\r\n * @param body - The payload to send in the POST request.\r\n * @param options - Additional request options.\r\n * @returns An Observable of the response.\r\n */\r\n post<T>(url: string, body: any,action?: string, options = {}): Observable<T> {\r\n return this.prepareHeaders(action).pipe(\r\n switchMap((headers) =>\r\n this.http.post<T>(url, body, { ...options, headers })\r\n )\r\n );\r\n }\r\n}\r\n","import {Inject, NgModule} from '@angular/core';\r\nimport {HttpClientWithRecaptchaService} from \"./http-client-with-recaptcha.service\";\r\nimport {RecaptchaV3Module, RECAPTCHA_V3_SITE_KEY, ReCaptchaV3Service} from \"ng-recaptcha\";\r\nimport {RECAPTCHA_HEADER_NAME, RECAPTCHA_V3_KEY} from \"./app-config.tokens\";\r\n\r\n@NgModule({\r\n imports: [RecaptchaV3Module],\r\n exports: [],\r\n providers: [\r\n HttpClientWithRecaptchaService,\r\n ReCaptchaV3Service,\r\n {\r\n provide: RECAPTCHA_V3_SITE_KEY, // This injects the site key into ng-recaptcha\r\n useExisting: RECAPTCHA_V3_KEY, // Pass the value of your custom token to ng-recaptcha\r\n }\r\n ]\r\n})\r\nexport class HttpClientWithRecaptchaModule {\r\n\r\n constructor(@Inject(RECAPTCHA_V3_KEY) private siteKey: string) {\r\n
|
|
1
|
+
{"version":3,"file":"http-client-with-recaptcha.mjs","sources":["../../../projects/http-client-with-recaptcha/src/lib/app-config.tokens.ts","../../../projects/http-client-with-recaptcha/src/lib/http-client-with-recaptcha.service.ts","../../../projects/http-client-with-recaptcha/src/lib/http-client-with-recaptcha.module.ts","../../../projects/http-client-with-recaptcha/src/public-api.ts","../../../projects/http-client-with-recaptcha/src/http-client-with-recaptcha.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\r\n\r\nexport const RECAPTCHA_HEADER_NAME = new InjectionToken<string>('reCAPTCHA Header Name', {\r\n providedIn: 'root',\r\n factory: () => 'X-Recaptcha-Token', // Default value\r\n});\r\n\r\n\r\nexport const RECAPTCHA_V3_KEY = new InjectionToken<string>('RECAPTCHA_V3_KEY', {\r\n providedIn: 'root', // You can provide it in the root or any other module depending on your need\r\n factory: () => {\r\n return 'your-site-key'; // Default value or fallback (can be overridden later)\r\n },\r\n});\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport { HttpClient, HttpHeaders } from '@angular/common/http';\r\nimport { ReCaptchaV3Service } from 'ng-recaptcha';\r\nimport { Observable, of } from 'rxjs';\r\nimport { switchMap, map } from 'rxjs/operators';\r\nimport { RECAPTCHA_HEADER_NAME } from './app-config.tokens';\r\n\r\n@Injectable({\r\n providedIn: 'root', // Provides the service at the root level\r\n})\r\nexport class HttpClientWithRecaptchaService {\r\n constructor(\r\n private http: HttpClient,\r\n private recaptchaV3Service: ReCaptchaV3Service,\r\n @Inject(RECAPTCHA_HEADER_NAME) private readonly headerName: string\r\n ) {}\r\n\r\n /**\r\n * Prepares headers for HTTP requests, optionally including a reCAPTCHA token.\r\n * @param action - Optional reCAPTCHA action.\r\n * @returns An Observable with the prepared HttpHeaders.\r\n */\r\n private prepareHeaders(action?: string): Observable<HttpHeaders> {\r\n if (!action) {\r\n return of(new HttpHeaders());\r\n }\r\n\r\n return this.recaptchaV3Service.execute(action).pipe(\r\n map((recaptchaToken) =>\r\n new HttpHeaders({\r\n [this.headerName]: recaptchaToken,\r\n })\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Performs a GET request with optional reCAPTCHA verification.\r\n * @param url - The endpoint URL.\r\n * @param action - Optional reCAPTCHA action.\r\n * @param options - Additional request options.\r\n * @returns An Observable of the response.\r\n */\r\n get<T>(url: string, action?: string, options = {}): Observable<T> {\r\n return this.prepareHeaders(action).pipe(\r\n switchMap((headers) =>\r\n this.http.get<T>(url, { ...options, headers })\r\n )\r\n );\r\n }\r\n\r\n /**\r\n * Performs a POST request with optional reCAPTCHA verification.\r\n * @param url - The endpoint URL.\r\n * @param action - Optional reCAPTCHA action.\r\n * @param body - The payload to send in the POST request.\r\n * @param options - Additional request options.\r\n * @returns An Observable of the response.\r\n */\r\n post<T>(url: string, body: any,action?: string, options = {}): Observable<T> {\r\n return this.prepareHeaders(action).pipe(\r\n switchMap((headers) =>\r\n this.http.post<T>(url, body, { ...options, headers })\r\n )\r\n );\r\n }\r\n}\r\n","import {Inject, NgModule} from '@angular/core';\r\nimport {HttpClientWithRecaptchaService} from \"./http-client-with-recaptcha.service\";\r\nimport {RecaptchaV3Module, RECAPTCHA_V3_SITE_KEY, ReCaptchaV3Service} from \"ng-recaptcha\";\r\nimport {RECAPTCHA_HEADER_NAME, RECAPTCHA_V3_KEY} from \"./app-config.tokens\";\r\n\r\n@NgModule({\r\n imports: [RecaptchaV3Module],\r\n exports: [],\r\n providers: [\r\n HttpClientWithRecaptchaService,\r\n ReCaptchaV3Service,\r\n {\r\n provide: RECAPTCHA_V3_SITE_KEY, // This injects the site key into ng-recaptcha\r\n useExisting: RECAPTCHA_V3_KEY, // Pass the value of your custom token to ng-recaptcha\r\n }\r\n ]\r\n})\r\nexport class HttpClientWithRecaptchaModule {\r\n\r\n constructor(@Inject(RECAPTCHA_V3_KEY) private siteKey: string) {\r\n if (!this.siteKey) {\r\n console.error('No reCAPTCHA site key provided. Please configure the RECAPTCHA_V3_KEY.');\r\n }\r\n }\r\n}\r\n","/*\r\n * Public API Surface of http-client-with-recaptcha\r\n */\r\n\r\nexport * from './lib/app-config.tokens';\r\nexport * from './lib/http-client-with-recaptcha.service';\r\nexport * from './lib/http-client-with-recaptcha.module';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;MAEa,qBAAqB,GAAG,IAAI,cAAc,CAAS,uBAAuB,EAAE;AACvF,IAAA,UAAU,EAAE,MAAM;AAClB,IAAA,OAAO,EAAE,MAAM,mBAAmB;AACnC,CAAA,EAAE;MAGU,gBAAgB,GAAG,IAAI,cAAc,CAAS,kBAAkB,EAAE;A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