axioma-recaptcha 6.0.117 → 6.0.118
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, inject, DOCUMENT, Injectable } from '@angular/core';
|
|
3
|
-
import { ReplaySubject, mergeMap, of, Observable
|
|
3
|
+
import { ReplaySubject, mergeMap, of, Observable } from 'rxjs';
|
|
4
4
|
|
|
5
5
|
const RECAPTCHA_CONFIG_LOADER = new InjectionToken('RECAPTCHA_CONFIG_LOADER');
|
|
6
6
|
|
|
@@ -17,10 +17,8 @@ class RecaptchaService {
|
|
|
17
17
|
}
|
|
18
18
|
this.init(config.siteKey);
|
|
19
19
|
return this.recaptcha$.pipe(mergeMap(r => new Observable(observer => r.ready(() => {
|
|
20
|
-
|
|
21
|
-
let promise = r.execute(config, { action });
|
|
20
|
+
let promise = r.execute(config.siteKey, { action });
|
|
22
21
|
promise.then(token => {
|
|
23
|
-
console.log('Recaptcha token received');
|
|
24
22
|
observer.next(token);
|
|
25
23
|
observer.complete();
|
|
26
24
|
}).catch(err => {
|
|
@@ -28,7 +26,7 @@ class RecaptchaService {
|
|
|
28
26
|
observer.next('');
|
|
29
27
|
observer.complete();
|
|
30
28
|
});
|
|
31
|
-
})))
|
|
29
|
+
}))));
|
|
32
30
|
}));
|
|
33
31
|
}
|
|
34
32
|
init(key) {
|
|
@@ -41,7 +39,6 @@ class RecaptchaService {
|
|
|
41
39
|
script.async = true;
|
|
42
40
|
script.defer = true;
|
|
43
41
|
script.addEventListener('load', () => {
|
|
44
|
-
console.log('Recaptcha loaded');
|
|
45
42
|
this.recaptcha$.next(window.grecaptcha);
|
|
46
43
|
});
|
|
47
44
|
this.document.body.appendChild(script);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axioma-recaptcha.mjs","sources":["../../../projects/recaptcha/src/lib/recaptcha.token.ts","../../../projects/recaptcha/src/lib/recaptcha.service.ts","../../../projects/recaptcha/src/public-api.ts","../../../projects/recaptcha/src/axioma-recaptcha.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\nimport { RecaptchaConfigLoader } from \"./recaptcha-config-loader\";\n\nexport const RECAPTCHA_CONFIG_LOADER = new InjectionToken<RecaptchaConfigLoader>('RECAPTCHA_CONFIG_LOADER');","import { inject, Injectable, DOCUMENT } from '@angular/core';\nimport { Observable, of, ReplaySubject, mergeMap
|
|
1
|
+
{"version":3,"file":"axioma-recaptcha.mjs","sources":["../../../projects/recaptcha/src/lib/recaptcha.token.ts","../../../projects/recaptcha/src/lib/recaptcha.service.ts","../../../projects/recaptcha/src/public-api.ts","../../../projects/recaptcha/src/axioma-recaptcha.ts"],"sourcesContent":["import { InjectionToken } from \"@angular/core\";\nimport { RecaptchaConfigLoader } from \"./recaptcha-config-loader\";\n\nexport const RECAPTCHA_CONFIG_LOADER = new InjectionToken<RecaptchaConfigLoader>('RECAPTCHA_CONFIG_LOADER');","import { inject, Injectable, DOCUMENT } from '@angular/core';\nimport { Observable, of, ReplaySubject, mergeMap } from 'rxjs';\nimport { RECAPTCHA_CONFIG_LOADER } from './recaptcha.token';\n\n\n@Injectable({\n providedIn: 'root'\n})\nexport class RecaptchaService {\n private configLoader = inject(RECAPTCHA_CONFIG_LOADER);\n private initialized = false;\n private document = inject<Document>(DOCUMENT);\n private recaptcha$ = new ReplaySubject<any>(1);\n execute(action: string): Observable<string> {\n return this.configLoader.load().pipe(mergeMap(config => {\n if (!config.enabled) {\n console.warn('Recaptcha is disabled');\n return of('');\n }\n this.init(config.siteKey);\n return this.recaptcha$.pipe(mergeMap(r =>\n new Observable<string>(observer =>\n r.ready(() => {\n let promise = r.execute(config.siteKey, { action }) as Promise<string>;\n promise.then(token => {\n observer.next(token);\n observer.complete();\n }).catch(err => {\n console.error('Recaptcha execution error:', err);\n observer.next('');\n observer.complete();\n });\n })\n ))\n );\n }));\n }\n private init(key: string): void {\n if (this.initialized) {\n return;\n }\n this.initialized = true;\n let script = this.document.createElement('script');\n script.src = `https://www.google.com/recaptcha/api.js?render=${key}`;\n script.async = true;\n script.defer = true;\n script.addEventListener('load', () => {\n this.recaptcha$.next((<any>window).grecaptcha);\n });\n this.document.body.appendChild(script);\n }\n constructor() {\n\n }\n}\n","/*\n * Public API Surface of the library\n */\n\nexport * from './lib/recaptcha.service';\nexport * from './lib/recaptcha.token';\nexport * from './lib/recaptcha-config-loader';","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAGa,uBAAuB,GAAG,IAAI,cAAc,CAAwB,yBAAyB;;MCK7F,gBAAgB,CAAA;AACnB,IAAA,YAAY,GAAG,MAAM,CAAC,uBAAuB,CAAC;IAC9C,WAAW,GAAG,KAAK;AACnB,IAAA,QAAQ,GAAG,MAAM,CAAW,QAAQ,CAAC;AACrC,IAAA,UAAU,GAAG,IAAI,aAAa,CAAM,CAAC,CAAC;AAC9C,IAAA,OAAO,CAAC,MAAc,EAAA;AACpB,QAAA,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAG;AACrD,YAAA,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;AACnB,gBAAA,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC;AACrC,gBAAA,OAAO,EAAE,CAAC,EAAE,CAAC;;AAEf,YAAA,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YACzB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IACpC,IAAI,UAAU,CAAS,QAAQ,IAC7B,CAAC,CAAC,KAAK,CAAC,MAAK;AACX,gBAAA,IAAI,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAoB;AACtE,gBAAA,OAAO,CAAC,IAAI,CA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