ng-recaptcha-2 14.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/CHANGELOG.md +530 -0
- package/LICENSE +21 -0
- package/README.md +647 -0
- package/esm2022/index.mjs +15 -0
- package/esm2022/lib/load-script.mjs +28 -0
- package/esm2022/lib/recaptcha-common.module.mjs +16 -0
- package/esm2022/lib/recaptcha-forms.module.mjs +19 -0
- package/esm2022/lib/recaptcha-loader.service.mjs +104 -0
- package/esm2022/lib/recaptcha-settings.mjs +2 -0
- package/esm2022/lib/recaptcha-v3.module.mjs +16 -0
- package/esm2022/lib/recaptcha-v3.service.mjs +106 -0
- package/esm2022/lib/recaptcha-value-accessor.directive.mjs +68 -0
- package/esm2022/lib/recaptcha.component.mjs +171 -0
- package/esm2022/lib/recaptcha.module.mjs +19 -0
- package/esm2022/lib/tokens.mjs +14 -0
- package/esm2022/ng-recaptcha-2.mjs +5 -0
- package/fesm2022/ng-recaptcha-2.mjs +536 -0
- package/fesm2022/ng-recaptcha-2.mjs.map +1 -0
- package/index.d.ts +9 -0
- package/lib/load-script.d.ts +27 -0
- package/lib/recaptcha-common.module.d.ts +7 -0
- package/lib/recaptcha-forms.module.d.ts +9 -0
- package/lib/recaptcha-loader.service.d.ts +28 -0
- package/lib/recaptcha-settings.d.ts +8 -0
- package/lib/recaptcha-v3.module.d.ts +6 -0
- package/lib/recaptcha-v3.service.d.ts +70 -0
- package/lib/recaptcha-value-accessor.directive.d.ts +18 -0
- package/lib/recaptcha.component.d.ts +64 -0
- package/lib/recaptcha.module.d.ts +8 -0
- package/lib/tokens.d.ts +116 -0
- package/package.json +40 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { NgModule } from "@angular/core";
|
|
2
|
+
import { RecaptchaCommonModule } from "./recaptcha-common.module";
|
|
3
|
+
import { RecaptchaLoaderService } from "./recaptcha-loader.service";
|
|
4
|
+
import { RecaptchaComponent } from "./recaptcha.component";
|
|
5
|
+
import * as i0 from "@angular/core";
|
|
6
|
+
export class RecaptchaModule {
|
|
7
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
8
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaModule, imports: [RecaptchaCommonModule], exports: [RecaptchaComponent] }); }
|
|
9
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaModule, providers: [RecaptchaLoaderService], imports: [RecaptchaCommonModule] }); }
|
|
10
|
+
}
|
|
11
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaModule, decorators: [{
|
|
12
|
+
type: NgModule,
|
|
13
|
+
args: [{
|
|
14
|
+
exports: [RecaptchaComponent],
|
|
15
|
+
imports: [RecaptchaCommonModule],
|
|
16
|
+
providers: [RecaptchaLoaderService],
|
|
17
|
+
}]
|
|
18
|
+
}] });
|
|
19
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjYXB0Y2hhLm1vZHVsZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL25nLXJlY2FwdGNoYS9zcmMvbGliL3JlY2FwdGNoYS5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUV6QyxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNsRSxPQUFPLEVBQUUsc0JBQXNCLEVBQUUsTUFBTSw0QkFBNEIsQ0FBQztBQUNwRSxP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`LOADER_OPTIONS` instead. See `RecaptchaLoaderOptions.onBeforeLoad` */
|
|
3
|
+
export const RECAPTCHA_LANGUAGE = new InjectionToken("recaptcha-language");
|
|
4
|
+
/** @deprecated Use `LOADER_OPTIONS` instead. See `RecaptchaLoaderOptions.onBeforeLoad` */
|
|
5
|
+
export const RECAPTCHA_BASE_URL = new InjectionToken("recaptcha-base-url");
|
|
6
|
+
/** @deprecated Use `LOADER_OPTIONS` instead. See `RecaptchaLoaderOptions.onBeforeLoad` */
|
|
7
|
+
export const RECAPTCHA_NONCE = new InjectionToken("recaptcha-nonce-tag");
|
|
8
|
+
export const RECAPTCHA_SETTINGS = new InjectionToken("recaptcha-settings");
|
|
9
|
+
export const RECAPTCHA_V3_SITE_KEY = new InjectionToken("recaptcha-v3-site-key");
|
|
10
|
+
/**
|
|
11
|
+
* See the documentation for `RecaptchaLoaderOptions`.
|
|
12
|
+
*/
|
|
13
|
+
export const RECAPTCHA_LOADER_OPTIONS = new InjectionToken("recaptcha-loader-options");
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9rZW5zLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vcHJvamVjdHMvbmctcmVjYXB0Y2hhL3NyYy9saWIvdG9rZW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFJL0MsMEZBQTBGO0FBQzFGLE1BQU0sQ0FBQyxNQUFNLGtCQUFrQixHQUFHLElBQUksY0FBYyxDQUFTLG9CQUFvQixDQUFDLENBQUM7QUFDbkYsMEZBQTBGO0FBQzFGLE1BQU0sQ0FBQyxNQUFNLGtCQUFrQixHQUFHLElBQUksY0FBYyxDQUFTLG9CQUFvQixDQUFDLENBQUM7QUFDbkYsMEZBQTBGO0FBQzFGLE1BQU0sQ0FBQyxNQUFN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biAgICpcbiAgICogICAgICAgIHJldHVybiB7XG4gICAqICAgICAgICAgIHVybDogcmVjYXB0Y2hhRW50ZXJwcmlzZVVybCxcbiAgICogICAgICAgIH1cbiAgICogICAgICB9LFxuICAgKiAgICAgIG9uTG9hZGVkKHJlY2FwdGNoYSkge1xuICAgKiAgICAgICAgcmV0dXJuIHJlY2FwdGNoYS5lbnRlcnByaXNlO1xuICAgKiAgICAgIH1cbiAgICogICAgfVxuICAgKiB9XG4gICAqIGBgYFxuICAgKi9cbiAgb25Mb2FkZWQ/KHJlY2FwdGNoYTogUmVDYXB0Y2hhVjIuUmVDYXB0Y2hhKTogUmVDYXB0Y2hhVjIuUmVDYXB0Y2hhO1xufTtcblxuLyoqXG4gKiBTZWUgdGhlIGRvY3VtZW50YXRpb24gZm9yIGBSZWNhcHRjaGFMb2FkZXJPcHRpb25zYC5cbiAqL1xuZXhwb3J0IGNvbnN0IFJFQ0FQVENIQV9MT0FERVJfT1BUSU9OUyA9IG5ldyBJbmplY3Rpb25Ub2tlbjxSZWNhcHRjaGFMb2FkZXJPcHRpb25zPihcInJlY2FwdGNoYS1sb2FkZXItb3B0aW9uc1wiKTtcbiJdfQ==
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated bundle index. Do not edit.
|
|
3
|
+
*/
|
|
4
|
+
export * from './index';
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmctcmVjYXB0Y2hhLTIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9wcm9qZWN0cy9uZy1yZWNhcHRjaGEvc3JjL25nLXJlY2FwdGNoYS0yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBRUgsY0FBYyxTQUFTLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vaW5kZXgnO1xuIl19
|
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, PLATFORM_ID, Injectable, Inject, Optional, EventEmitter, Component, Input, HostBinding, Output, NgModule, forwardRef, Directive, HostListener } from '@angular/core';
|
|
3
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
4
|
+
import { of, BehaviorSubject, Subject } from 'rxjs';
|
|
5
|
+
import { filter } from 'rxjs/operators';
|
|
6
|
+
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
|
|
7
|
+
|
|
8
|
+
/** @deprecated Use `LOADER_OPTIONS` instead. See `RecaptchaLoaderOptions.onBeforeLoad` */
|
|
9
|
+
const RECAPTCHA_LANGUAGE = new InjectionToken("recaptcha-language");
|
|
10
|
+
/** @deprecated Use `LOADER_OPTIONS` instead. See `RecaptchaLoaderOptions.onBeforeLoad` */
|
|
11
|
+
const RECAPTCHA_BASE_URL = new InjectionToken("recaptcha-base-url");
|
|
12
|
+
/** @deprecated Use `LOADER_OPTIONS` instead. See `RecaptchaLoaderOptions.onBeforeLoad` */
|
|
13
|
+
const RECAPTCHA_NONCE = new InjectionToken("recaptcha-nonce-tag");
|
|
14
|
+
const RECAPTCHA_SETTINGS = new InjectionToken("recaptcha-settings");
|
|
15
|
+
const RECAPTCHA_V3_SITE_KEY = new InjectionToken("recaptcha-v3-site-key");
|
|
16
|
+
/**
|
|
17
|
+
* See the documentation for `RecaptchaLoaderOptions`.
|
|
18
|
+
*/
|
|
19
|
+
const RECAPTCHA_LOADER_OPTIONS = new InjectionToken("recaptcha-loader-options");
|
|
20
|
+
|
|
21
|
+
function loadScript(renderMode, onBeforeLoad, onLoaded, { url, lang, nonce } = {}) {
|
|
22
|
+
window.ng2recaptchaloaded = () => {
|
|
23
|
+
onLoaded(grecaptcha);
|
|
24
|
+
};
|
|
25
|
+
const script = document.createElement("script");
|
|
26
|
+
script.innerHTML = "";
|
|
27
|
+
const { url: baseUrl, nonce: onBeforeLoadNonce } = onBeforeLoad(new URL(url || "https://www.google.com/recaptcha/api.js"));
|
|
28
|
+
baseUrl.searchParams.set("render", renderMode === "explicit" ? renderMode : renderMode.key);
|
|
29
|
+
baseUrl.searchParams.set("onload", "ng2recaptchaloaded");
|
|
30
|
+
baseUrl.searchParams.set("trustedtypes", "true");
|
|
31
|
+
if (lang) {
|
|
32
|
+
baseUrl.searchParams.set("hl", lang);
|
|
33
|
+
}
|
|
34
|
+
script.src = baseUrl.href;
|
|
35
|
+
const nonceValue = onBeforeLoadNonce || nonce;
|
|
36
|
+
if (nonceValue) {
|
|
37
|
+
script.setAttribute("nonce", nonceValue);
|
|
38
|
+
}
|
|
39
|
+
script.async = true;
|
|
40
|
+
script.defer = true;
|
|
41
|
+
document.head.appendChild(script);
|
|
42
|
+
}
|
|
43
|
+
function newLoadScript({ v3SiteKey, onBeforeLoad, onLoaded, }) {
|
|
44
|
+
const renderMode = v3SiteKey ? { key: v3SiteKey } : "explicit";
|
|
45
|
+
loader.loadScript(renderMode, onBeforeLoad, onLoaded);
|
|
46
|
+
}
|
|
47
|
+
const loader = { loadScript, newLoadScript };
|
|
48
|
+
|
|
49
|
+
function toNonNullObservable(subject) {
|
|
50
|
+
return subject.asObservable().pipe(filter((value) => value !== null));
|
|
51
|
+
}
|
|
52
|
+
class RecaptchaLoaderService {
|
|
53
|
+
/**
|
|
54
|
+
* @internal
|
|
55
|
+
* @nocollapse
|
|
56
|
+
*/
|
|
57
|
+
static { this.ready = null; }
|
|
58
|
+
constructor(
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
60
|
+
platformId,
|
|
61
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
62
|
+
language,
|
|
63
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
64
|
+
baseUrl,
|
|
65
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
66
|
+
nonce, v3SiteKey, options) {
|
|
67
|
+
this.platformId = platformId;
|
|
68
|
+
this.language = language;
|
|
69
|
+
this.baseUrl = baseUrl;
|
|
70
|
+
this.nonce = nonce;
|
|
71
|
+
this.v3SiteKey = v3SiteKey;
|
|
72
|
+
this.options = options;
|
|
73
|
+
const subject = this.init();
|
|
74
|
+
this.ready = subject ? toNonNullObservable(subject) : of();
|
|
75
|
+
}
|
|
76
|
+
/** @internal */
|
|
77
|
+
init() {
|
|
78
|
+
if (RecaptchaLoaderService.ready) {
|
|
79
|
+
return RecaptchaLoaderService.ready;
|
|
80
|
+
}
|
|
81
|
+
if (!isPlatformBrowser(this.platformId)) {
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
const subject = new BehaviorSubject(null);
|
|
85
|
+
RecaptchaLoaderService.ready = subject;
|
|
86
|
+
loader.newLoadScript({
|
|
87
|
+
v3SiteKey: this.v3SiteKey,
|
|
88
|
+
onBeforeLoad: (url) => {
|
|
89
|
+
if (this.options?.onBeforeLoad) {
|
|
90
|
+
return this.options.onBeforeLoad(url);
|
|
91
|
+
}
|
|
92
|
+
const newUrl = new URL(this.baseUrl ?? url);
|
|
93
|
+
if (this.language) {
|
|
94
|
+
newUrl.searchParams.set("hl", this.language);
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
url: newUrl,
|
|
98
|
+
nonce: this.nonce,
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
onLoaded: (recaptcha) => {
|
|
102
|
+
let value = recaptcha;
|
|
103
|
+
if (this.options?.onLoaded) {
|
|
104
|
+
value = this.options.onLoaded(recaptcha);
|
|
105
|
+
}
|
|
106
|
+
subject.next(value);
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
return subject;
|
|
110
|
+
}
|
|
111
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaLoaderService, deps: [{ token: PLATFORM_ID }, { token: RECAPTCHA_LANGUAGE, optional: true }, { token: RECAPTCHA_BASE_URL, optional: true }, { token: RECAPTCHA_NONCE, optional: true }, { token: RECAPTCHA_V3_SITE_KEY, optional: true }, { token: RECAPTCHA_LOADER_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
112
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaLoaderService }); }
|
|
113
|
+
}
|
|
114
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaLoaderService, decorators: [{
|
|
115
|
+
type: Injectable
|
|
116
|
+
}], ctorParameters: () => [{ type: Object, decorators: [{
|
|
117
|
+
type: Inject,
|
|
118
|
+
args: [PLATFORM_ID]
|
|
119
|
+
}] }, { type: undefined, decorators: [{
|
|
120
|
+
type: Optional
|
|
121
|
+
}, {
|
|
122
|
+
type: Inject,
|
|
123
|
+
args: [RECAPTCHA_LANGUAGE]
|
|
124
|
+
}] }, { type: undefined, decorators: [{
|
|
125
|
+
type: Optional
|
|
126
|
+
}, {
|
|
127
|
+
type: Inject,
|
|
128
|
+
args: [RECAPTCHA_BASE_URL]
|
|
129
|
+
}] }, { type: undefined, decorators: [{
|
|
130
|
+
type: Optional
|
|
131
|
+
}, {
|
|
132
|
+
type: Inject,
|
|
133
|
+
args: [RECAPTCHA_NONCE]
|
|
134
|
+
}] }, { type: undefined, decorators: [{
|
|
135
|
+
type: Optional
|
|
136
|
+
}, {
|
|
137
|
+
type: Inject,
|
|
138
|
+
args: [RECAPTCHA_V3_SITE_KEY]
|
|
139
|
+
}] }, { type: undefined, decorators: [{
|
|
140
|
+
type: Optional
|
|
141
|
+
}, {
|
|
142
|
+
type: Inject,
|
|
143
|
+
args: [RECAPTCHA_LOADER_OPTIONS]
|
|
144
|
+
}] }] });
|
|
145
|
+
|
|
146
|
+
let nextId = 0;
|
|
147
|
+
class RecaptchaComponent {
|
|
148
|
+
constructor(elementRef, loader, zone, settings) {
|
|
149
|
+
this.elementRef = elementRef;
|
|
150
|
+
this.loader = loader;
|
|
151
|
+
this.zone = zone;
|
|
152
|
+
this.id = `ngrecaptcha-${nextId++}`;
|
|
153
|
+
this.errorMode = "default";
|
|
154
|
+
this.resolved = new EventEmitter();
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated `(error) output will be removed in the next major version. Use (errored) instead
|
|
157
|
+
*/
|
|
158
|
+
// eslint-disable-next-line @angular-eslint/no-output-native
|
|
159
|
+
this.error = new EventEmitter();
|
|
160
|
+
this.errored = new EventEmitter();
|
|
161
|
+
if (settings) {
|
|
162
|
+
this.siteKey = settings.siteKey;
|
|
163
|
+
this.theme = settings.theme;
|
|
164
|
+
this.type = settings.type;
|
|
165
|
+
this.size = settings.size;
|
|
166
|
+
this.badge = settings.badge;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
ngAfterViewInit() {
|
|
170
|
+
this.subscription = this.loader.ready.subscribe((grecaptcha) => {
|
|
171
|
+
if (grecaptcha != null && grecaptcha.render instanceof Function) {
|
|
172
|
+
this.grecaptcha = grecaptcha;
|
|
173
|
+
this.renderRecaptcha();
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
ngOnDestroy() {
|
|
178
|
+
// reset the captcha to ensure it does not leave anything behind
|
|
179
|
+
// after the component is no longer needed
|
|
180
|
+
this.grecaptchaReset();
|
|
181
|
+
if (this.subscription) {
|
|
182
|
+
this.subscription.unsubscribe();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Executes the invisible recaptcha.
|
|
187
|
+
* Does nothing if component's size is not set to "invisible".
|
|
188
|
+
*/
|
|
189
|
+
execute() {
|
|
190
|
+
if (this.size !== "invisible") {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (this.widget != null) {
|
|
194
|
+
void this.grecaptcha.execute(this.widget);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
// delay execution of recaptcha until it actually renders
|
|
198
|
+
this.executeRequested = true;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
reset() {
|
|
202
|
+
if (this.widget != null) {
|
|
203
|
+
if (this.grecaptcha.getResponse(this.widget)) {
|
|
204
|
+
// Only emit an event in case if something would actually change.
|
|
205
|
+
// That way we do not trigger "touching" of the control if someone does a "reset"
|
|
206
|
+
// on a non-resolved captcha.
|
|
207
|
+
this.resolved.emit(null);
|
|
208
|
+
}
|
|
209
|
+
this.grecaptchaReset();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* ⚠️ Warning! Use this property at your own risk!
|
|
214
|
+
*
|
|
215
|
+
* While this member is `public`, it is not a part of the component's public API.
|
|
216
|
+
* The semantic versioning guarantees _will not be honored_! Thus, you might find that this property behavior changes in incompatible ways in minor or even patch releases.
|
|
217
|
+
* You are **strongly advised** against using this property.
|
|
218
|
+
* Instead, use more idiomatic ways to get reCAPTCHA value, such as `resolved` EventEmitter, or form-bound methods (ngModel, formControl, and the likes).å
|
|
219
|
+
*/
|
|
220
|
+
get __unsafe_widgetValue() {
|
|
221
|
+
return this.widget != null ? this.grecaptcha.getResponse(this.widget) : null;
|
|
222
|
+
}
|
|
223
|
+
/** @internal */
|
|
224
|
+
expired() {
|
|
225
|
+
this.resolved.emit(null);
|
|
226
|
+
}
|
|
227
|
+
/** @internal */
|
|
228
|
+
onError(args) {
|
|
229
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
230
|
+
this.error.emit(args);
|
|
231
|
+
this.errored.emit(args);
|
|
232
|
+
}
|
|
233
|
+
/** @internal */
|
|
234
|
+
captchaResponseCallback(response) {
|
|
235
|
+
this.resolved.emit(response);
|
|
236
|
+
}
|
|
237
|
+
/** @internal */
|
|
238
|
+
grecaptchaReset() {
|
|
239
|
+
if (this.widget != null) {
|
|
240
|
+
this.zone.runOutsideAngular(() => this.grecaptcha.reset(this.widget));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
/** @internal */
|
|
244
|
+
renderRecaptcha() {
|
|
245
|
+
// This `any` can be removed after @types/grecaptcha get updated
|
|
246
|
+
const renderOptions = {
|
|
247
|
+
badge: this.badge,
|
|
248
|
+
callback: (response) => {
|
|
249
|
+
this.zone.run(() => this.captchaResponseCallback(response));
|
|
250
|
+
},
|
|
251
|
+
"expired-callback": () => {
|
|
252
|
+
this.zone.run(() => this.expired());
|
|
253
|
+
},
|
|
254
|
+
sitekey: this.siteKey,
|
|
255
|
+
size: this.size,
|
|
256
|
+
tabindex: this.tabIndex,
|
|
257
|
+
theme: this.theme,
|
|
258
|
+
type: this.type,
|
|
259
|
+
};
|
|
260
|
+
if (this.errorMode === "handled") {
|
|
261
|
+
renderOptions["error-callback"] = (...args) => {
|
|
262
|
+
this.zone.run(() => this.onError(args));
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
this.widget = this.grecaptcha.render(this.elementRef.nativeElement, renderOptions);
|
|
266
|
+
if (this.executeRequested === true) {
|
|
267
|
+
this.executeRequested = false;
|
|
268
|
+
this.execute();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaComponent, deps: [{ token: i0.ElementRef }, { token: RecaptchaLoaderService }, { token: i0.NgZone }, { token: RECAPTCHA_SETTINGS, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
272
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.0.1", type: RecaptchaComponent, selector: "re-captcha", inputs: { id: "id", siteKey: "siteKey", theme: "theme", type: "type", size: "size", tabIndex: "tabIndex", badge: "badge", errorMode: "errorMode" }, outputs: { resolved: "resolved", error: "error", errored: "errored" }, host: { properties: { "attr.id": "this.id" } }, exportAs: ["reCaptcha"], ngImport: i0, template: ``, isInline: true }); }
|
|
273
|
+
}
|
|
274
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaComponent, decorators: [{
|
|
275
|
+
type: Component,
|
|
276
|
+
args: [{
|
|
277
|
+
exportAs: "reCaptcha",
|
|
278
|
+
selector: "re-captcha",
|
|
279
|
+
template: ``,
|
|
280
|
+
}]
|
|
281
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: RecaptchaLoaderService }, { type: i0.NgZone }, { type: undefined, decorators: [{
|
|
282
|
+
type: Optional
|
|
283
|
+
}, {
|
|
284
|
+
type: Inject,
|
|
285
|
+
args: [RECAPTCHA_SETTINGS]
|
|
286
|
+
}] }], propDecorators: { id: [{
|
|
287
|
+
type: Input
|
|
288
|
+
}, {
|
|
289
|
+
type: HostBinding,
|
|
290
|
+
args: ["attr.id"]
|
|
291
|
+
}], siteKey: [{
|
|
292
|
+
type: Input
|
|
293
|
+
}], theme: [{
|
|
294
|
+
type: Input
|
|
295
|
+
}], type: [{
|
|
296
|
+
type: Input
|
|
297
|
+
}], size: [{
|
|
298
|
+
type: Input
|
|
299
|
+
}], tabIndex: [{
|
|
300
|
+
type: Input
|
|
301
|
+
}], badge: [{
|
|
302
|
+
type: Input
|
|
303
|
+
}], errorMode: [{
|
|
304
|
+
type: Input
|
|
305
|
+
}], resolved: [{
|
|
306
|
+
type: Output
|
|
307
|
+
}], error: [{
|
|
308
|
+
type: Output
|
|
309
|
+
}], errored: [{
|
|
310
|
+
type: Output
|
|
311
|
+
}] } });
|
|
312
|
+
|
|
313
|
+
class RecaptchaCommonModule {
|
|
314
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaCommonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
315
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaCommonModule, declarations: [RecaptchaComponent], exports: [RecaptchaComponent] }); }
|
|
316
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaCommonModule }); }
|
|
317
|
+
}
|
|
318
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaCommonModule, decorators: [{
|
|
319
|
+
type: NgModule,
|
|
320
|
+
args: [{
|
|
321
|
+
declarations: [RecaptchaComponent],
|
|
322
|
+
exports: [RecaptchaComponent],
|
|
323
|
+
}]
|
|
324
|
+
}] });
|
|
325
|
+
|
|
326
|
+
class RecaptchaModule {
|
|
327
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
328
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaModule, imports: [RecaptchaCommonModule], exports: [RecaptchaComponent] }); }
|
|
329
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaModule, providers: [RecaptchaLoaderService], imports: [RecaptchaCommonModule] }); }
|
|
330
|
+
}
|
|
331
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaModule, decorators: [{
|
|
332
|
+
type: NgModule,
|
|
333
|
+
args: [{
|
|
334
|
+
exports: [RecaptchaComponent],
|
|
335
|
+
imports: [RecaptchaCommonModule],
|
|
336
|
+
providers: [RecaptchaLoaderService],
|
|
337
|
+
}]
|
|
338
|
+
}] });
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* The main service for working with reCAPTCHA v3 APIs.
|
|
342
|
+
*
|
|
343
|
+
* Use the `execute` method for executing a single action, and
|
|
344
|
+
* `onExecute` observable for listening to all actions at once.
|
|
345
|
+
*/
|
|
346
|
+
class ReCaptchaV3Service {
|
|
347
|
+
constructor(zone, recaptchaLoader, siteKey) {
|
|
348
|
+
this.recaptchaLoader = recaptchaLoader;
|
|
349
|
+
this.zone = zone;
|
|
350
|
+
this.siteKey = siteKey;
|
|
351
|
+
this.init();
|
|
352
|
+
}
|
|
353
|
+
get onExecute() {
|
|
354
|
+
if (!this.onExecuteSubject) {
|
|
355
|
+
this.onExecuteSubject = new Subject();
|
|
356
|
+
this.onExecuteObservable = this.onExecuteSubject.asObservable();
|
|
357
|
+
}
|
|
358
|
+
return this.onExecuteObservable;
|
|
359
|
+
}
|
|
360
|
+
get onExecuteError() {
|
|
361
|
+
if (!this.onExecuteErrorSubject) {
|
|
362
|
+
this.onExecuteErrorSubject = new Subject();
|
|
363
|
+
this.onExecuteErrorObservable = this.onExecuteErrorSubject.asObservable();
|
|
364
|
+
}
|
|
365
|
+
return this.onExecuteErrorObservable;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Executes the provided `action` with reCAPTCHA v3 API.
|
|
369
|
+
* Use the emitted token value for verification purposes on the backend.
|
|
370
|
+
*
|
|
371
|
+
* For more information about reCAPTCHA v3 actions and tokens refer to the official documentation at
|
|
372
|
+
* https://developers.google.com/recaptcha/docs/v3.
|
|
373
|
+
*
|
|
374
|
+
* @param {string} action the action to execute
|
|
375
|
+
* @returns {Observable<string>} an `Observable` that will emit the reCAPTCHA v3 string `token` value whenever ready.
|
|
376
|
+
* The returned `Observable` completes immediately after emitting a value.
|
|
377
|
+
*/
|
|
378
|
+
execute(action) {
|
|
379
|
+
const subject = new Subject();
|
|
380
|
+
if (!this.grecaptcha) {
|
|
381
|
+
if (!this.actionBacklog) {
|
|
382
|
+
this.actionBacklog = [];
|
|
383
|
+
}
|
|
384
|
+
this.actionBacklog.push([action, subject]);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
this.executeActionWithSubject(action, subject);
|
|
388
|
+
}
|
|
389
|
+
return subject.asObservable();
|
|
390
|
+
}
|
|
391
|
+
/** @internal */
|
|
392
|
+
executeActionWithSubject(action, subject) {
|
|
393
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
394
|
+
const onError = (error) => {
|
|
395
|
+
this.zone.run(() => {
|
|
396
|
+
subject.error(error);
|
|
397
|
+
if (this.onExecuteErrorSubject) {
|
|
398
|
+
// We don't know any better at this point, unfortunately, so have to resort to `any`
|
|
399
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
400
|
+
this.onExecuteErrorSubject.next({ action, error });
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
};
|
|
404
|
+
this.zone.runOutsideAngular(() => {
|
|
405
|
+
try {
|
|
406
|
+
this.grecaptcha.execute(this.siteKey, { action }).then((token) => {
|
|
407
|
+
this.zone.run(() => {
|
|
408
|
+
subject.next(token);
|
|
409
|
+
subject.complete();
|
|
410
|
+
if (this.onExecuteSubject) {
|
|
411
|
+
this.onExecuteSubject.next({ action, token });
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}, onError);
|
|
415
|
+
}
|
|
416
|
+
catch (e) {
|
|
417
|
+
onError(e);
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
/** @internal */
|
|
422
|
+
init() {
|
|
423
|
+
this.recaptchaLoader.ready.subscribe((value) => {
|
|
424
|
+
this.grecaptcha = value;
|
|
425
|
+
if (this.actionBacklog && this.actionBacklog.length > 0) {
|
|
426
|
+
this.actionBacklog.forEach(([action, subject]) => this.executeActionWithSubject(action, subject));
|
|
427
|
+
this.actionBacklog = undefined;
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ReCaptchaV3Service, deps: [{ token: i0.NgZone }, { token: RecaptchaLoaderService }, { token: RECAPTCHA_V3_SITE_KEY }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
432
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ReCaptchaV3Service }); }
|
|
433
|
+
}
|
|
434
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: ReCaptchaV3Service, decorators: [{
|
|
435
|
+
type: Injectable
|
|
436
|
+
}], ctorParameters: () => [{ type: i0.NgZone }, { type: RecaptchaLoaderService }, { type: undefined, decorators: [{
|
|
437
|
+
type: Inject,
|
|
438
|
+
args: [RECAPTCHA_V3_SITE_KEY]
|
|
439
|
+
}] }] });
|
|
440
|
+
|
|
441
|
+
class RecaptchaV3Module {
|
|
442
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaV3Module, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
443
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaV3Module }); }
|
|
444
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaV3Module, providers: [ReCaptchaV3Service, RecaptchaLoaderService] }); }
|
|
445
|
+
}
|
|
446
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaV3Module, decorators: [{
|
|
447
|
+
type: NgModule,
|
|
448
|
+
args: [{
|
|
449
|
+
providers: [ReCaptchaV3Service, RecaptchaLoaderService],
|
|
450
|
+
}]
|
|
451
|
+
}] });
|
|
452
|
+
|
|
453
|
+
class RecaptchaValueAccessorDirective {
|
|
454
|
+
constructor(host) {
|
|
455
|
+
this.host = host;
|
|
456
|
+
this.requiresControllerReset = false;
|
|
457
|
+
}
|
|
458
|
+
writeValue(value) {
|
|
459
|
+
if (!value) {
|
|
460
|
+
this.host.reset();
|
|
461
|
+
}
|
|
462
|
+
else {
|
|
463
|
+
// In this case, it is most likely that a form controller has requested to write a specific value into the component.
|
|
464
|
+
// This isn't really a supported case - reCAPTCHA values are single-use, and, in a sense, readonly.
|
|
465
|
+
// What this means is that the form controller has recaptcha control state of X, while reCAPTCHA itself can't "restore"
|
|
466
|
+
// to that state. In order to make form controller aware of this discrepancy, and to fix the said misalignment,
|
|
467
|
+
// we'll be telling the controller to "reset" the value back to null.
|
|
468
|
+
if (this.host.__unsafe_widgetValue !== value && Boolean(this.host.__unsafe_widgetValue) === false) {
|
|
469
|
+
this.requiresControllerReset = true;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
registerOnChange(fn) {
|
|
474
|
+
this.onChange = fn;
|
|
475
|
+
if (this.requiresControllerReset) {
|
|
476
|
+
this.requiresControllerReset = false;
|
|
477
|
+
this.onChange(null);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
registerOnTouched(fn) {
|
|
481
|
+
this.onTouched = fn;
|
|
482
|
+
}
|
|
483
|
+
onResolve($event) {
|
|
484
|
+
if (this.onChange) {
|
|
485
|
+
this.onChange($event);
|
|
486
|
+
}
|
|
487
|
+
if (this.onTouched) {
|
|
488
|
+
this.onTouched();
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaValueAccessorDirective, deps: [{ token: RecaptchaComponent }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
492
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.0.1", type: RecaptchaValueAccessorDirective, selector: "re-captcha[formControlName],re-captcha[formControl],re-captcha[ngModel]", host: { listeners: { "resolved": "onResolve($event)" } }, providers: [
|
|
493
|
+
{
|
|
494
|
+
multi: true,
|
|
495
|
+
provide: NG_VALUE_ACCESSOR,
|
|
496
|
+
useExisting: forwardRef(() => RecaptchaValueAccessorDirective),
|
|
497
|
+
},
|
|
498
|
+
], ngImport: i0 }); }
|
|
499
|
+
}
|
|
500
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaValueAccessorDirective, decorators: [{
|
|
501
|
+
type: Directive,
|
|
502
|
+
args: [{
|
|
503
|
+
providers: [
|
|
504
|
+
{
|
|
505
|
+
multi: true,
|
|
506
|
+
provide: NG_VALUE_ACCESSOR,
|
|
507
|
+
useExisting: forwardRef(() => RecaptchaValueAccessorDirective),
|
|
508
|
+
},
|
|
509
|
+
],
|
|
510
|
+
selector: "re-captcha[formControlName],re-captcha[formControl],re-captcha[ngModel]",
|
|
511
|
+
}]
|
|
512
|
+
}], ctorParameters: () => [{ type: RecaptchaComponent }], propDecorators: { onResolve: [{
|
|
513
|
+
type: HostListener,
|
|
514
|
+
args: ["resolved", ["$event"]]
|
|
515
|
+
}] } });
|
|
516
|
+
|
|
517
|
+
class RecaptchaFormsModule {
|
|
518
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaFormsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
519
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaFormsModule, declarations: [RecaptchaValueAccessorDirective], imports: [FormsModule, RecaptchaCommonModule], exports: [RecaptchaValueAccessorDirective] }); }
|
|
520
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaFormsModule, imports: [FormsModule, RecaptchaCommonModule] }); }
|
|
521
|
+
}
|
|
522
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.1", ngImport: i0, type: RecaptchaFormsModule, decorators: [{
|
|
523
|
+
type: NgModule,
|
|
524
|
+
args: [{
|
|
525
|
+
declarations: [RecaptchaValueAccessorDirective],
|
|
526
|
+
exports: [RecaptchaValueAccessorDirective],
|
|
527
|
+
imports: [FormsModule, RecaptchaCommonModule],
|
|
528
|
+
}]
|
|
529
|
+
}] });
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Generated bundle index. Do not edit.
|
|
533
|
+
*/
|
|
534
|
+
|
|
535
|
+
export { RECAPTCHA_BASE_URL, RECAPTCHA_LANGUAGE, RECAPTCHA_LOADER_OPTIONS, RECAPTCHA_NONCE, RECAPTCHA_SETTINGS, RECAPTCHA_V3_SITE_KEY, ReCaptchaV3Service, RecaptchaComponent, RecaptchaFormsModule, RecaptchaLoaderService, RecaptchaModule, RecaptchaV3Module, RecaptchaValueAccessorDirective };
|
|
536
|
+
//# sourceMappingURL=ng-recaptcha-2.mjs.map
|