angular-captcha
Advanced tools
Comparing version 2.6.0 to 2.7.0
{ | ||
"name": "angular-captcha", | ||
"version": "2.6.0", | ||
"version": "2.7.0", | ||
"description": "BotDetect Captcha Angular Module (TypeScript: Angular 2/4/5/6/7/8+)", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -47,3 +47,10 @@ "use strict"; | ||
captcha_helper_service_1.CaptchaHelperService, | ||
captcha_endpoint_pipe_1.CaptchaEndpointPipe | ||
captcha_endpoint_pipe_1.CaptchaEndpointPipe, | ||
{ | ||
// we need this provide CAPTCHA_SETTINGS declaration | ||
// since we have added support for the captchaEndpoint | ||
// setting in component | ||
provide: config_1.CAPTCHA_SETTINGS, | ||
useValue: null | ||
} | ||
], | ||
@@ -60,4 +67,2 @@ exports: [ | ||
function provideBotDetectCaptcha(config) { | ||
captcha_service_1.CaptchaService.captchaEndpoint = config.captchaEndpoint; | ||
// we need to keep the below dependency providers for backward compatibility | ||
return [ | ||
@@ -64,0 +69,0 @@ { |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"BotDetectCaptchaModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"declarations":[{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"__symbolic":"reference","module":"./captcha.component","name":"CaptchaComponent"},{"__symbolic":"reference","module":"./correct-captcha.directive","name":"CorrectCaptchaDirective"}],"providers":[{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"},{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"}],"exports":[{"__symbolic":"reference","module":"./captcha.component","name":"CaptchaComponent"},{"__symbolic":"reference","module":"./correct-captcha.directive","name":"CorrectCaptchaDirective"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"BotDetectCaptchaModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideBotDetectCaptcha"},"arguments":[{"__symbolic":"reference","name":"config"}]}]}},"forChild":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"BotDetectCaptchaModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideBotDetectCaptcha"},"arguments":[{"__symbolic":"reference","name":"config"}]}]}}}},"provideBotDetectCaptcha":{"__symbolic":"function"}}},{"__symbolic":"module","version":1,"metadata":{"BotDetectCaptchaModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"declarations":[{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"__symbolic":"reference","module":"./captcha.component","name":"CaptchaComponent"},{"__symbolic":"reference","module":"./correct-captcha.directive","name":"CorrectCaptchaDirective"}],"providers":[{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"},{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"}],"exports":[{"__symbolic":"reference","module":"./captcha.component","name":"CaptchaComponent"},{"__symbolic":"reference","module":"./correct-captcha.directive","name":"CorrectCaptchaDirective"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"BotDetectCaptchaModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideBotDetectCaptcha"},"arguments":[{"__symbolic":"reference","name":"config"}]}]}},"forChild":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"BotDetectCaptchaModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideBotDetectCaptcha"},"arguments":[{"__symbolic":"reference","name":"config"}]}]}}}},"provideBotDetectCaptcha":{"__symbolic":"function"}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"BotDetectCaptchaModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"declarations":[{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"__symbolic":"reference","module":"./captcha.component","name":"CaptchaComponent"},{"__symbolic":"reference","module":"./correct-captcha.directive","name":"CorrectCaptchaDirective"}],"providers":[{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"},{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"provide":{"__symbolic":"reference","module":"./config","name":"CAPTCHA_SETTINGS"},"useValue":null}],"exports":[{"__symbolic":"reference","module":"./captcha.component","name":"CaptchaComponent"},{"__symbolic":"reference","module":"./correct-captcha.directive","name":"CorrectCaptchaDirective"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"BotDetectCaptchaModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideBotDetectCaptcha"},"arguments":[{"__symbolic":"reference","name":"config"}]}]}},"forChild":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"BotDetectCaptchaModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideBotDetectCaptcha"},"arguments":[{"__symbolic":"reference","name":"config"}]}]}}}},"provideBotDetectCaptcha":{"__symbolic":"function","parameters":["config"],"value":[{"provide":{"__symbolic":"reference","module":"./config","name":"CAPTCHA_SETTINGS"},"useValue":{"__symbolic":"reference","name":"config"}}]}}},{"__symbolic":"module","version":1,"metadata":{"BotDetectCaptchaModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/http","name":"HttpModule"}],"declarations":[{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"__symbolic":"reference","module":"./captcha.component","name":"CaptchaComponent"},{"__symbolic":"reference","module":"./correct-captcha.directive","name":"CorrectCaptchaDirective"}],"providers":[{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"},{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"provide":{"__symbolic":"reference","module":"./config","name":"CAPTCHA_SETTINGS"},"useValue":null}],"exports":[{"__symbolic":"reference","module":"./captcha.component","name":"CaptchaComponent"},{"__symbolic":"reference","module":"./correct-captcha.directive","name":"CorrectCaptchaDirective"}]}]}],"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"BotDetectCaptchaModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideBotDetectCaptcha"},"arguments":[{"__symbolic":"reference","name":"config"}]}]}},"forChild":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"BotDetectCaptchaModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideBotDetectCaptcha"},"arguments":[{"__symbolic":"reference","name":"config"}]}]}}}},"provideBotDetectCaptcha":{"__symbolic":"function","parameters":["config"],"value":[{"provide":{"__symbolic":"reference","module":"./config","name":"CAPTCHA_SETTINGS"},"useValue":{"__symbolic":"reference","name":"config"}}]}}}] |
@@ -24,3 +24,3 @@ "use strict"; | ||
set: function (captchaEndpoint) { | ||
captcha_service_1.CaptchaService.captchaEndpoint = captchaEndpoint; | ||
this.captchaService.captchaEndpoint = captchaEndpoint; | ||
}, | ||
@@ -27,0 +27,0 @@ enumerable: true, |
import { Http } from '@angular/http'; | ||
import { Observable } from 'rxjs/Rx'; | ||
import { CaptchaEndpointPipe } from './captcha-endpoint.pipe'; | ||
import { CaptchaSettings } from './captcha-settings.interface'; | ||
export declare class CaptchaService { | ||
private http; | ||
private captchaEndpointPipe; | ||
private config; | ||
private _captchaStyleName; | ||
private static _captchaEndpoint; | ||
constructor(http: Http, captchaEndpointPipe: CaptchaEndpointPipe); | ||
private _captchaEndpoint; | ||
constructor(http: Http, captchaEndpointPipe: CaptchaEndpointPipe, config: CaptchaSettings); | ||
captchaStyleName: string; | ||
static captchaEndpoint: string; | ||
readonly captchaEndpoint: string; | ||
captchaEndpoint: string; | ||
readonly botdetectInstance: any; | ||
isCaptchaEndpointValid(): boolean; | ||
getHtml(): Observable<string>; | ||
validateUnsafe(captchaCode: string): any; | ||
} |
@@ -11,2 +11,5 @@ "use strict"; | ||
}; | ||
var __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -17,8 +20,9 @@ var core_1 = require("@angular/core"); | ||
var captcha_endpoint_pipe_1 = require("./captcha-endpoint.pipe"); | ||
var config_1 = require("./config"); | ||
var CaptchaService = /** @class */ (function () { | ||
function CaptchaService(http, captchaEndpointPipe) { | ||
function CaptchaService(http, captchaEndpointPipe, config) { | ||
this.http = http; | ||
this.captchaEndpointPipe = captchaEndpointPipe; | ||
this.config = config; | ||
} | ||
CaptchaService_1 = CaptchaService; | ||
Object.defineProperty(CaptchaService.prototype, "captchaStyleName", { | ||
@@ -34,14 +38,14 @@ get: function () { | ||
}); | ||
Object.defineProperty(CaptchaService, "captchaEndpoint", { | ||
set: function (captchaEndpoint) { | ||
CaptchaService_1._captchaEndpoint = captchaEndpoint; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(CaptchaService.prototype, "captchaEndpoint", { | ||
// the captcha endpoint for botdetect requests. | ||
get: function () { | ||
return this.captchaEndpointPipe.transform(CaptchaService_1._captchaEndpoint); | ||
var captchaEndpoint = this._captchaEndpoint; | ||
if (this.config && this.config.captchaEndpoint) { | ||
captchaEndpoint = this.config.captchaEndpoint; | ||
} | ||
return this.captchaEndpointPipe.transform(captchaEndpoint); | ||
}, | ||
set: function (captchaEndpoint) { | ||
this._captchaEndpoint = captchaEndpoint; | ||
}, | ||
enumerable: true, | ||
@@ -58,11 +62,5 @@ configurable: true | ||
}); | ||
// check if configured captchaEndpoint is valid or not. | ||
CaptchaService.prototype.isCaptchaEndpointValid = function () { | ||
return ((this.captchaEndpoint !== undefined) | ||
&& (this.captchaEndpoint !== null) | ||
&& (this.captchaEndpoint !== '')); | ||
}; | ||
// get captcha html markup from botdetect api. | ||
CaptchaService.prototype.getHtml = function () { | ||
if (!this.isCaptchaEndpointValid()) { | ||
if (!this.captchaEndpoint) { | ||
var errorMessage = "captchaEndpoint property is not set!\n The Angular Captcha Module requires the \"this.captchaComponent.captchaEndpoint\" property to be set.\n For example: \n ngOnInit(): void {\n this.captchaComponent.captchaEndpoint = 'https://your-app-backend-hostname.your-domain.com/simple-captcha-endpoint-path';\n }\n "; | ||
@@ -86,7 +84,7 @@ throw new Error(errorMessage); | ||
}; | ||
var CaptchaService_1; | ||
CaptchaService = CaptchaService_1 = __decorate([ | ||
CaptchaService = __decorate([ | ||
core_1.Injectable(), | ||
__param(2, core_1.Inject(config_1.CAPTCHA_SETTINGS)), | ||
__metadata("design:paramtypes", [http_1.Http, | ||
captcha_endpoint_pipe_1.CaptchaEndpointPipe]) | ||
captcha_endpoint_pipe_1.CaptchaEndpointPipe, Object]) | ||
], CaptchaService); | ||
@@ -93,0 +91,0 @@ return CaptchaService; |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"CaptchaService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"},{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"}]}],"isCaptchaEndpointValid":[{"__symbolic":"method"}],"getHtml":[{"__symbolic":"method"}],"validateUnsafe":[{"__symbolic":"method"}]},"statics":{"_captchaEndpoint":{"__symbolic":"error","message":"Variable not initialized","line":12,"character":17},"captchaEndpoint":{"__symbolic":"error","message":"Variable not initialized","line":27,"character":13}}}}},{"__symbolic":"module","version":1,"metadata":{"CaptchaService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"},{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"}]}],"isCaptchaEndpointValid":[{"__symbolic":"method"}],"getHtml":[{"__symbolic":"method"}],"validateUnsafe":[{"__symbolic":"method"}]},"statics":{"_captchaEndpoint":{"__symbolic":"error","message":"Variable not initialized","line":12,"character":17},"captchaEndpoint":{"__symbolic":"error","message":"Variable not initialized","line":27,"character":13}}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"CaptchaService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"./config","name":"CAPTCHA_SETTINGS"}]}]],"parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"},{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"__symbolic":"reference","module":"./captcha-settings.interface","name":"CaptchaSettings"}]}],"getHtml":[{"__symbolic":"method"}],"validateUnsafe":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"CaptchaService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"./config","name":"CAPTCHA_SETTINGS"}]}]],"parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"},{"__symbolic":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"__symbolic":"reference","module":"./captcha-settings.interface","name":"CaptchaSettings"}]}],"getHtml":[{"__symbolic":"method"}],"validateUnsafe":[{"__symbolic":"method"}]}}}}] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
69101
699