angular-captcha
Advanced tools
Comparing version 1.2.2 to 1.3.0
@@ -7,2 +7,4 @@ "use strict"; | ||
exports.CaptchaComponent = captcha_component_1.CaptchaComponent; | ||
var captcha_settings_interface_1 = require("./src/captcha-settings.interface"); | ||
exports.CaptchaSettings = captcha_settings_interface_1.CaptchaSettings; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./src/botdetect-captcha.module","export":["BotDetectCaptchaModule"]},{"from":"./src/captcha.component","export":["CaptchaComponent"]},{"from":"./src/captcha-settings.interface","export":["CaptchaSettings"]}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./src/botdetect-captcha.module","export":["BotDetectCaptchaModule"]},{"from":"./src/captcha.component","export":["CaptchaComponent"]},{"from":"./src/captcha-settings.interface","export":["CaptchaSettings"]}]}] | ||
[{"__symbolic":"module","version":4,"metadata":{},"exports":[{"from":"./src/botdetect-captcha.module","export":["BotDetectCaptchaModule"]},{"from":"./src/captcha.component","export":["CaptchaComponent"]},{"from":"./src/captcha-settings.interface","export":["CaptchaSettings"]}]}] |
{ | ||
"name": "angular-captcha", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "BotDetect Captcha Angular Module (TypeScript / Angular 2+)", | ||
@@ -22,3 +22,5 @@ "scripts": { | ||
"captcha", | ||
"angular", | ||
"angular-captcha", | ||
"captcha-generator", | ||
"angular-module", | ||
"botdetect" | ||
@@ -29,16 +31,16 @@ ], | ||
"devDependencies": { | ||
"@angular/common": "^4.0.0", | ||
"@angular/compiler": "^4.0.0", | ||
"@angular/compiler-cli": "^4.0.0", | ||
"@angular/core": "^4.0.0", | ||
"@angular/forms": "^4.0.0", | ||
"@angular/http": "^4.0.0", | ||
"@angular/platform-browser": "^4.0.0", | ||
"codelyzer": "^3.0.0", | ||
"rimraf": "^2.6.1", | ||
"rxjs": "^5.3.0", | ||
"@angular/common": "^5.0.0", | ||
"@angular/compiler": "^5.0.0", | ||
"@angular/compiler-cli": "^5.0.0", | ||
"@angular/core": "^5.0.0", | ||
"@angular/forms": "^5.0.0", | ||
"@angular/http": "^5.0.0", | ||
"@angular/platform-browser": "^5.0.0", | ||
"codelyzer": "^3.2.0", | ||
"rimraf": "^2.6.2", | ||
"rxjs": "^5.5.2", | ||
"tslint": "^5.1.0", | ||
"typescript": "^2.2.0", | ||
"zone.js": "^0.8.8" | ||
"typescript": "^2.4.2", | ||
"zone.js": "^0.8.14" | ||
} | ||
} |
@@ -10,4 +10,5 @@ "use strict"; | ||
var captcha_endpoint_pipe_1 = require("./captcha-endpoint.pipe"); | ||
var captcha_settings_interface_1 = require("./captcha-settings.interface"); | ||
var config_1 = require("./config"); | ||
var BotDetectCaptchaModule = (function () { | ||
var BotDetectCaptchaModule = /** @class */ (function () { | ||
function BotDetectCaptchaModule() { | ||
@@ -29,20 +30,2 @@ } | ||
}()); | ||
BotDetectCaptchaModule.decorators = [ | ||
{ type: core_1.NgModule, args: [{ | ||
imports: [ | ||
http_1.HttpModule | ||
], | ||
declarations: [ | ||
captcha_endpoint_pipe_1.CaptchaEndpointPipe, | ||
captcha_component_1.CaptchaComponent, | ||
correct_captcha_directive_1.CorrectCaptchaDirective | ||
], | ||
exports: [ | ||
captcha_component_1.CaptchaComponent, | ||
correct_captcha_directive_1.CorrectCaptchaDirective | ||
] | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
BotDetectCaptchaModule.ctorParameters = function () { return []; }; | ||
exports.BotDetectCaptchaModule = BotDetectCaptchaModule; | ||
@@ -49,0 +32,0 @@ function provideBotDetectCaptcha(config) { |
@@ -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"}],"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":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"}]}}},{"__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"}],"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":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"}]}}}] | ||
[{"__symbolic":"module","version":4,"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"}],"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":"reference","module":"./captcha-endpoint.pipe","name":"CaptchaEndpointPipe"},{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"}]}}}] |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var CaptchaEndpointPipe = (function () { | ||
var CaptchaEndpointPipe = /** @class */ (function () { | ||
function CaptchaEndpointPipe() { | ||
@@ -10,3 +10,9 @@ } | ||
*/ | ||
CaptchaEndpointPipe.prototype.transform = function (value) { | ||
/** | ||
* Strip '/' character from the end of the given path. | ||
*/ | ||
CaptchaEndpointPipe.prototype.transform = /** | ||
* Strip '/' character from the end of the given path. | ||
*/ | ||
function (value) { | ||
return value.trim().replace(/\/+$/g, ''); | ||
@@ -16,8 +22,3 @@ }; | ||
}()); | ||
CaptchaEndpointPipe.decorators = [ | ||
{ type: core_1.Pipe, args: [{ name: 'captchaEndpoint' },] }, | ||
]; | ||
/** @nocollapse */ | ||
CaptchaEndpointPipe.ctorParameters = function () { return []; }; | ||
exports.CaptchaEndpointPipe = CaptchaEndpointPipe; | ||
//# sourceMappingURL=captcha-endpoint.pipe.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"CaptchaEndpointPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"captchaEndpoint"}]}],"members":{"transform":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"CaptchaEndpointPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"captchaEndpoint"}]}],"members":{"transform":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"CaptchaEndpointPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"captchaEndpoint"}]}],"members":{"transform":[{"__symbolic":"method"}]}}}}] |
@@ -0,12 +1,6 @@ | ||
import { Http } from '@angular/http'; | ||
export declare class CaptchaHelperService { | ||
private document; | ||
constructor(document: any); | ||
/** | ||
* Build url with parameters. | ||
*/ | ||
buildUrl(url: string, params: any): string; | ||
/** | ||
* Create script include element. | ||
*/ | ||
scriptInclude(url: string, className: string): any; | ||
private http; | ||
constructor(http: Http); | ||
getScript(url: string, onLoadSuccess: () => void): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var platform_browser_1 = require("@angular/platform-browser"); | ||
var CaptchaHelperService = (function () { | ||
function CaptchaHelperService(document) { | ||
this.document = document; | ||
var http_1 = require("@angular/http"); | ||
var CaptchaHelperService = /** @class */ (function () { | ||
function CaptchaHelperService(http) { | ||
this.http = http; | ||
} | ||
/** | ||
* Build url with parameters. | ||
*/ | ||
CaptchaHelperService.prototype.buildUrl = function (url, params) { | ||
var p = []; | ||
for (var key in params) { | ||
if (typeof key === 'string') { | ||
p.push(key + '=' + params[key]); | ||
} | ||
} | ||
var hasParamsPattern = /\?+/g; | ||
return hasParamsPattern.test(url) ? (url + '&' + p.join('&')) : (url + '?' + p.join('&')); | ||
// get script and execute it immediately | ||
// get script and execute it immediately | ||
CaptchaHelperService.prototype.getScript = | ||
// get script and execute it immediately | ||
function (url, onLoadSuccess) { | ||
this.http.get(url) | ||
.map(function (response) { return response.text(); }) | ||
.subscribe(function (scriptString) { | ||
var f = new Function(scriptString); | ||
f(); | ||
onLoadSuccess(); | ||
}); | ||
}; | ||
/** | ||
* Create script include element. | ||
*/ | ||
CaptchaHelperService.prototype.scriptInclude = function (url, className) { | ||
var script = this.document.createElement('script'); | ||
script.src = url; | ||
script.className = className; | ||
return script; | ||
}; | ||
return CaptchaHelperService; | ||
}()); | ||
CaptchaHelperService.decorators = [ | ||
{ type: core_1.Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
CaptchaHelperService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: core_1.Inject, args: [platform_browser_1.DOCUMENT,] },] }, | ||
]; }; | ||
exports.CaptchaHelperService = CaptchaHelperService; | ||
//# sourceMappingURL=captcha-helper.service.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"CaptchaHelperService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"@angular/platform-browser","name":"DOCUMENT"}]}]],"parameters":[{"__symbolic":"reference","name":"any"}]}],"buildUrl":[{"__symbolic":"method"}],"scriptInclude":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"CaptchaHelperService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"@angular/platform-browser","name":"DOCUMENT"}]}]],"parameters":[{"__symbolic":"reference","name":"any"}]}],"buildUrl":[{"__symbolic":"method"}],"scriptInclude":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"CaptchaHelperService":{"__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"}]}],"getScript":[{"__symbolic":"method"}]}}}}] |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"CaptchaSettings":{"__symbolic":"interface"}}},{"__symbolic":"module","version":1,"metadata":{"CaptchaSettings":{"__symbolic":"interface"}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"CaptchaSettings":{"__symbolic":"interface"}}}] |
@@ -1,2 +0,2 @@ | ||
import { OnInit, ElementRef, Renderer } from '@angular/core'; | ||
import { OnInit, ElementRef } from '@angular/core'; | ||
import { CaptchaService } from './captcha.service'; | ||
@@ -6,32 +6,11 @@ import { CaptchaHelperService } from './captcha-helper.service'; | ||
private elementRef; | ||
private renderer; | ||
private captchaService; | ||
private captchaHelper; | ||
private document; | ||
styleName: string; | ||
constructor(elementRef: ElementRef, renderer: Renderer, captchaService: CaptchaService, captchaHelper: CaptchaHelperService, document: any); | ||
/** | ||
* The current captcha id, which will be used for validation purpose. | ||
*/ | ||
constructor(elementRef: ElementRef, captchaService: CaptchaService, captchaHelper: CaptchaHelperService); | ||
readonly captchaId: string; | ||
/** | ||
* Display captcha html markup on component initialize. | ||
*/ | ||
ngOnInit(): void; | ||
/** | ||
* Display captcha html markup in the <botdetect-captcha> tag. | ||
*/ | ||
showHtml(): void; | ||
/** | ||
* Reload a new captcha image for the current captcha instance. | ||
*/ | ||
reloadImage(): void; | ||
/** | ||
* Add BotDetect client-side script include to body element. | ||
*/ | ||
private addScriptToBody(); | ||
/** | ||
* Add BotDetect init script include to body element. | ||
*/ | ||
private addInitScriptToBody(); | ||
loadScriptIncludes(): void; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var platform_browser_1 = require("@angular/platform-browser"); | ||
var captcha_service_1 = require("./captcha.service"); | ||
var captcha_helper_service_1 = require("./captcha-helper.service"); | ||
var CaptchaComponent = (function () { | ||
function CaptchaComponent(elementRef, renderer, captchaService, captchaHelper, document) { | ||
var CaptchaComponent = /** @class */ (function () { | ||
function CaptchaComponent(elementRef, captchaService, captchaHelper) { | ||
this.elementRef = elementRef; | ||
this.renderer = renderer; | ||
this.captchaService = captchaService; | ||
this.captchaHelper = captchaHelper; | ||
this.document = document; | ||
} | ||
Object.defineProperty(CaptchaComponent.prototype, "captchaId", { | ||
/** | ||
* The current captcha id, which will be used for validation purpose. | ||
*/ | ||
get: function () { | ||
// The current captcha id, which will be used for validation purpose. | ||
get: | ||
// The current captcha id, which will be used for validation purpose. | ||
function () { | ||
return this.captchaService.botdetectInstance.captchaId; | ||
@@ -25,6 +22,7 @@ }, | ||
}); | ||
/** | ||
* Display captcha html markup on component initialize. | ||
*/ | ||
CaptchaComponent.prototype.ngOnInit = function () { | ||
// Display captcha html markup on component initialization. | ||
// Display captcha html markup on component initialization. | ||
CaptchaComponent.prototype.ngOnInit = | ||
// Display captcha html markup on component initialization. | ||
function () { | ||
// if styleName is not specified, the styleName will be 'defaultCaptcha' | ||
@@ -37,14 +35,18 @@ if (!this.styleName) { | ||
// display captcha html markup on view | ||
this.addScriptToBody(); | ||
this.showHtml(); | ||
}; | ||
/** | ||
* Display captcha html markup in the <botdetect-captcha> tag. | ||
*/ | ||
CaptchaComponent.prototype.showHtml = function () { | ||
// Display captcha html markup in the <botdetect-captcha> tag. | ||
// Display captcha html markup in the <botdetect-captcha> tag. | ||
CaptchaComponent.prototype.showHtml = | ||
// Display captcha html markup in the <botdetect-captcha> tag. | ||
function () { | ||
var _this = this; | ||
this.captchaService.getHtml() | ||
.subscribe(function (captchaHtml) { | ||
// display captcha html markup | ||
// display captcha html markup | ||
_this.elementRef.nativeElement.innerHTML = captchaHtml; | ||
_this.addInitScriptToBody(); | ||
// load botdetect scripts | ||
// load botdetect scripts | ||
_this.loadScriptIncludes(); | ||
}, function (error) { | ||
@@ -54,64 +56,25 @@ throw new Error(error); | ||
}; | ||
/** | ||
* Reload a new captcha image for the current captcha instance. | ||
*/ | ||
CaptchaComponent.prototype.reloadImage = function () { | ||
// Reload a new captcha image. | ||
// Reload a new captcha image. | ||
CaptchaComponent.prototype.reloadImage = | ||
// Reload a new captcha image. | ||
function () { | ||
this.captchaService.botdetectInstance.reloadImage(); | ||
}; | ||
/** | ||
* Add BotDetect client-side script include to body element. | ||
*/ | ||
CaptchaComponent.prototype.addScriptToBody = function () { | ||
if (this.document.getElementsByClassName('BDC_ScriptInclude').length !== 0) { | ||
// BotDetect client-side script is already added | ||
return; | ||
} | ||
// build BotDetect client-side script include url | ||
var url = this.captchaHelper.buildUrl(this.captchaService.captchaEndpoint, { | ||
get: 'script-include' | ||
// Load BotDetect scripts. | ||
// Load BotDetect scripts. | ||
CaptchaComponent.prototype.loadScriptIncludes = | ||
// Load BotDetect scripts. | ||
function () { | ||
var scriptIncludeUrl = this.captchaService.captchaEndpoint + '?get=script-include'; | ||
var self = this; | ||
this.captchaHelper.getScript(scriptIncludeUrl, function () { | ||
var captchaId = self.elementRef.nativeElement.querySelector('#BDC_VCID_' + self.styleName).value; | ||
var initScriptIncludeUrl = self.captchaService.captchaEndpoint + '?get=init-script-include&c=' + self.styleName + '&t=' + captchaId + '&cs=201'; | ||
self.captchaHelper.getScript(initScriptIncludeUrl, function () { }); | ||
}); | ||
this.document.body.appendChild(this.captchaHelper.scriptInclude(url, 'BDC_ScriptInclude')); | ||
}; | ||
/** | ||
* Add BotDetect init script include to body element. | ||
*/ | ||
CaptchaComponent.prototype.addInitScriptToBody = function () { | ||
// remove included BotDetect init script if it exists | ||
var initScriptIncluded = this.document.getElementsByClassName('BDC_InitScriptInclude'); | ||
if (initScriptIncluded.length !== 0) { | ||
this.renderer.invokeElementMethod(initScriptIncluded[0], 'remove'); | ||
} | ||
var captchaId = this.elementRef.nativeElement.querySelector('#BDC_VCID_' + this.styleName); | ||
if (!captchaId) { | ||
return; | ||
} | ||
// build BotDetect init script include url. | ||
var initScriptIncludeUrl = this.captchaHelper.buildUrl(this.captchaService.captchaEndpoint, { | ||
get: 'init-script-include', | ||
c: this.styleName, | ||
t: captchaId.value, | ||
cs: '201' | ||
}); | ||
this.document.body.appendChild(this.captchaHelper.scriptInclude(initScriptIncludeUrl, 'BDC_InitScriptInclude')); | ||
}; | ||
return CaptchaComponent; | ||
}()); | ||
CaptchaComponent.decorators = [ | ||
{ type: core_1.Component, args: [{ | ||
selector: 'botdetect-captcha', | ||
template: '' | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
CaptchaComponent.ctorParameters = function () { return [ | ||
{ type: core_1.ElementRef, }, | ||
{ type: core_1.Renderer, }, | ||
{ type: captcha_service_1.CaptchaService, }, | ||
{ type: captcha_helper_service_1.CaptchaHelperService, }, | ||
{ type: undefined, decorators: [{ type: core_1.Inject, args: [platform_browser_1.DOCUMENT,] },] }, | ||
]; }; | ||
CaptchaComponent.propDecorators = { | ||
'styleName': [{ type: core_1.Input },], | ||
}; | ||
exports.CaptchaComponent = CaptchaComponent; | ||
//# sourceMappingURL=captcha.component.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"CaptchaComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"botdetect-captcha","template":""}]}],"members":{"styleName":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"@angular/platform-browser","name":"DOCUMENT"}]}]],"parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer"},{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"},{"__symbolic":"reference","name":"any"}]}],"ngOnInit":[{"__symbolic":"method"}],"showHtml":[{"__symbolic":"method"}],"reloadImage":[{"__symbolic":"method"}],"addScriptToBody":[{"__symbolic":"method"}],"addInitScriptToBody":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"CaptchaComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"botdetect-captcha","template":""}]}],"members":{"styleName":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,null,null,null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"@angular/platform-browser","name":"DOCUMENT"}]}]],"parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"@angular/core","name":"Renderer"},{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"},{"__symbolic":"reference","name":"any"}]}],"ngOnInit":[{"__symbolic":"method"}],"showHtml":[{"__symbolic":"method"}],"reloadImage":[{"__symbolic":"method"}],"addScriptToBody":[{"__symbolic":"method"}],"addInitScriptToBody":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"CaptchaComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component"},"arguments":[{"selector":"botdetect-captcha","template":""}]}],"members":{"styleName":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef"},{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"},{"__symbolic":"reference","module":"./captcha-helper.service","name":"CaptchaHelperService"}]}],"ngOnInit":[{"__symbolic":"method"}],"showHtml":[{"__symbolic":"method"}],"reloadImage":[{"__symbolic":"method"}],"loadScriptIncludes":[{"__symbolic":"method"}]}}}}] |
import { Http } from '@angular/http'; | ||
import { Observable } from 'rxjs/Rx'; | ||
import { CaptchaEndpointPipe } from './captcha-endpoint.pipe'; | ||
import { CaptchaHelperService } from './captcha-helper.service'; | ||
import { CaptchaSettings } from './captcha-settings.interface'; | ||
@@ -9,23 +8,10 @@ export declare class CaptchaService { | ||
private captchaEndpointPipe; | ||
private captchaHelper; | ||
private config; | ||
private _styleName; | ||
constructor(http: Http, captchaEndpointPipe: CaptchaEndpointPipe, captchaHelper: CaptchaHelperService, config: CaptchaSettings); | ||
constructor(http: Http, captchaEndpointPipe: CaptchaEndpointPipe, config: CaptchaSettings); | ||
styleName: string; | ||
/** | ||
* The captcha handler url for BotDetect requests. | ||
*/ | ||
readonly captchaEndpoint: string; | ||
/** | ||
* Get BotDetect instance, which is provided by BotDetect script. | ||
*/ | ||
readonly botdetectInstance: any; | ||
/** | ||
* Get captcha html markup from BotDetect API. | ||
*/ | ||
getHtml(): Observable<string>; | ||
/** | ||
* UI validate captcha. | ||
*/ | ||
validate(captchaCode: string): Observable<string>; | ||
} |
@@ -7,9 +7,8 @@ "use strict"; | ||
var captcha_endpoint_pipe_1 = require("./captcha-endpoint.pipe"); | ||
var captcha_helper_service_1 = require("./captcha-helper.service"); | ||
var captcha_settings_interface_1 = require("./captcha-settings.interface"); | ||
var config_1 = require("./config"); | ||
var CaptchaService = (function () { | ||
function CaptchaService(http, captchaEndpointPipe, captchaHelper, config) { | ||
var CaptchaService = /** @class */ (function () { | ||
function CaptchaService(http, captchaEndpointPipe, config) { | ||
this.http = http; | ||
this.captchaEndpointPipe = captchaEndpointPipe; | ||
this.captchaHelper = captchaHelper; | ||
this.config = config; | ||
@@ -28,6 +27,6 @@ } | ||
Object.defineProperty(CaptchaService.prototype, "captchaEndpoint", { | ||
/** | ||
* The captcha handler url for BotDetect requests. | ||
*/ | ||
get: function () { | ||
// The captcha endpoint for BotDetect requests. | ||
get: | ||
// The captcha endpoint for BotDetect requests. | ||
function () { | ||
return this.captchaEndpointPipe.transform(this.config.captchaEndpoint); | ||
@@ -39,6 +38,6 @@ }, | ||
Object.defineProperty(CaptchaService.prototype, "botdetectInstance", { | ||
/** | ||
* Get BotDetect instance, which is provided by BotDetect script. | ||
*/ | ||
get: function () { | ||
// Get BotDetect instance, which is provided by BotDetect script. | ||
get: | ||
// Get BotDetect instance, which is provided by BotDetect script. | ||
function () { | ||
if (!this.styleName) { | ||
@@ -52,10 +51,8 @@ return null; | ||
}); | ||
/** | ||
* Get captcha html markup from BotDetect API. | ||
*/ | ||
CaptchaService.prototype.getHtml = function () { | ||
var url = this.captchaHelper.buildUrl(this.captchaEndpoint, { | ||
get: 'html', | ||
c: this.styleName | ||
}); | ||
// Get captcha html markup from BotDetect API. | ||
// Get captcha html markup from BotDetect API. | ||
CaptchaService.prototype.getHtml = | ||
// Get captcha html markup from BotDetect API. | ||
function () { | ||
var url = this.captchaEndpoint + '?get=html&c=' + this.styleName; | ||
return this.http.get(url) | ||
@@ -65,12 +62,11 @@ .map(function (response) { return response.text().replace(/<script.*<\/script>/g, ''); }) | ||
}; | ||
/** | ||
* UI validate captcha. | ||
*/ | ||
CaptchaService.prototype.validate = function (captchaCode) { | ||
// UI validate captcha. | ||
// UI validate captcha. | ||
CaptchaService.prototype.validate = | ||
// UI validate captcha. | ||
function (captchaCode) { | ||
if (!this.botdetectInstance) { | ||
throw new Error('BotDetect instance does not exist.'); | ||
} | ||
var url = this.captchaHelper.buildUrl(this.botdetectInstance.validationUrl, { | ||
i: captchaCode | ||
}); | ||
var url = this.botdetectInstance.validationUrl + '&i=' + captchaCode; | ||
return this.http.get(url) | ||
@@ -82,13 +78,3 @@ .map(function (response) { return response.json(); }) | ||
}()); | ||
CaptchaService.decorators = [ | ||
{ type: core_1.Injectable }, | ||
]; | ||
/** @nocollapse */ | ||
CaptchaService.ctorParameters = function () { return [ | ||
{ type: http_1.Http, }, | ||
{ type: captcha_endpoint_pipe_1.CaptchaEndpointPipe, }, | ||
{ type: captcha_helper_service_1.CaptchaHelperService, }, | ||
{ type: undefined, decorators: [{ type: core_1.Inject, args: [config_1.CAPTCHA_SETTINGS,] },] }, | ||
]; }; | ||
exports.CaptchaService = CaptchaService; | ||
//# sourceMappingURL=captcha.service.js.map |
@@ -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","parameterDecorators":[null,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-helper.service","name":"CaptchaHelperService"},{"__symbolic":"reference","module":"./captcha-settings.interface","name":"CaptchaSettings"}]}],"getHtml":[{"__symbolic":"method"}],"validate":[{"__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,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-helper.service","name":"CaptchaHelperService"},{"__symbolic":"reference","module":"./captcha-settings.interface","name":"CaptchaSettings"}]}],"getHtml":[{"__symbolic":"method"}],"validate":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":4,"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"}],"validate":[{"__symbolic":"method"}]}}}}] |
@@ -1,2 +0,3 @@ | ||
import { OpaqueToken } from '@angular/core'; | ||
export declare const CAPTCHA_SETTINGS: OpaqueToken; | ||
import { InjectionToken } from '@angular/core'; | ||
import { CaptchaSettings } from './captcha-settings.interface'; | ||
export declare let CAPTCHA_SETTINGS: InjectionToken<CaptchaSettings>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
exports.CAPTCHA_SETTINGS = new core_1.OpaqueToken('captcha.settings'); | ||
var captcha_settings_interface_1 = require("./captcha-settings.interface"); | ||
exports.CAPTCHA_SETTINGS = new core_1.InjectionToken('captcha.settings'); | ||
//# sourceMappingURL=config.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"CAPTCHA_SETTINGS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"OpaqueToken"},"arguments":["captcha.settings"]}}},{"__symbolic":"module","version":1,"metadata":{"CAPTCHA_SETTINGS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"OpaqueToken"},"arguments":["captcha.settings"]}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"CAPTCHA_SETTINGS":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken"},"arguments":["captcha.settings"]}}}] |
@@ -5,5 +5,2 @@ import { AbstractControl, Validator } from '@angular/forms'; | ||
private captchaService; | ||
/** | ||
* Cached captcha input control. | ||
*/ | ||
control: AbstractControl; | ||
@@ -10,0 +7,0 @@ constructor(captchaService: CaptchaService); |
@@ -6,3 +6,3 @@ "use strict"; | ||
var captcha_service_1 = require("./captcha.service"); | ||
var CorrectCaptchaDirective = (function () { | ||
var CorrectCaptchaDirective = /** @class */ (function () { | ||
function CorrectCaptchaDirective(captchaService) { | ||
@@ -28,2 +28,3 @@ this.captchaService = captchaService; | ||
// ui captcha validation failed | ||
// ui captcha validation failed | ||
_this.captchaService.botdetectInstance.reloadImage(); | ||
@@ -34,2 +35,3 @@ _this.control = null; | ||
// ui captcha validation passed | ||
// ui captcha validation passed | ||
_this.control.setErrors(null); | ||
@@ -49,22 +51,3 @@ } | ||
}()); | ||
CorrectCaptchaDirective.decorators = [ | ||
{ type: core_1.Directive, args: [{ | ||
selector: '[correctCaptcha][formControlName],[correctCaptcha][formControl],[correctCaptcha][ngModel]', | ||
providers: [ | ||
{ | ||
provide: forms_1.NG_ASYNC_VALIDATORS, | ||
useExisting: core_1.forwardRef(function () { return CorrectCaptchaDirective; }), | ||
multi: true | ||
} | ||
] | ||
},] }, | ||
]; | ||
/** @nocollapse */ | ||
CorrectCaptchaDirective.ctorParameters = function () { return [ | ||
{ type: captcha_service_1.CaptchaService, }, | ||
]; }; | ||
CorrectCaptchaDirective.propDecorators = { | ||
'onBlur': [{ type: core_1.HostListener, args: ['blur',] },], | ||
}; | ||
exports.CorrectCaptchaDirective = CorrectCaptchaDirective; | ||
//# sourceMappingURL=correct-captcha.directive.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"CorrectCaptchaDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[correctCaptcha][formControlName],[correctCaptcha][formControl],[correctCaptcha][ngModel]","providers":[{"provide":{"__symbolic":"reference","module":"@angular/forms","name":"NG_ASYNC_VALIDATORS"},"useExisting":{"__symbolic":"reference","name":"CorrectCaptchaDirective"},"multi":true}]}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"}]}],"validate":[{"__symbolic":"method"}],"onBlur":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener"},"arguments":["blur"]}]}]}}}},{"__symbolic":"module","version":1,"metadata":{"CorrectCaptchaDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[correctCaptcha][formControlName],[correctCaptcha][formControl],[correctCaptcha][ngModel]","providers":[{"provide":{"__symbolic":"reference","module":"@angular/forms","name":"NG_ASYNC_VALIDATORS"},"useExisting":{"__symbolic":"reference","name":"CorrectCaptchaDirective"},"multi":true}]}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"}]}],"validate":[{"__symbolic":"method"}],"onBlur":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener"},"arguments":["blur"]}]}]}}}}] | ||
[{"__symbolic":"module","version":4,"metadata":{"CorrectCaptchaDirective":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[correctCaptcha][formControlName],[correctCaptcha][formControl],[correctCaptcha][ngModel]","providers":[{"provide":{"__symbolic":"reference","module":"@angular/forms","name":"NG_ASYNC_VALIDATORS"},"useExisting":{"__symbolic":"reference","name":"CorrectCaptchaDirective"},"multi":true}]}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"./captcha.service","name":"CaptchaService"}]}],"validate":[{"__symbolic":"method"}],"onBlur":[{"__symbolic":"method","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"HostListener"},"arguments":["blur"]}]}]}}}}] |
@@ -0,0 +0,0 @@ { |
@@ -21,3 +21,3 @@ { | ||
true, | ||
140 | ||
160 | ||
], | ||
@@ -24,0 +24,0 @@ "member-access": false, |
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
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
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
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
34466
495
1