@beinformed/ui 1.27.0-beta.1 → 1.27.1
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 +8 -0
- package/esm/models/attributes/CaptchaAttributeModel.js +19 -0
- package/esm/models/attributes/CaptchaAttributeModel.js.map +1 -1
- package/esm/modularui/CaptchaRequest.js +25 -8
- package/esm/modularui/CaptchaRequest.js.map +1 -1
- package/lib/models/attributes/CaptchaAttributeModel.js +19 -0
- package/lib/models/attributes/CaptchaAttributeModel.js.flow +16 -0
- package/lib/models/attributes/CaptchaAttributeModel.js.map +1 -1
- package/lib/modularui/CaptchaRequest.js +25 -8
- package/lib/modularui/CaptchaRequest.js.flow +51 -10
- package/lib/modularui/CaptchaRequest.js.map +1 -1
- package/package.json +8 -8
- package/src/models/attributes/CaptchaAttributeModel.js +16 -0
- package/src/modularui/CaptchaRequest.js +51 -10
- package/types/models/attributes/CaptchaAttributeModel.d.ts +9 -0
- package/types/modularui/CaptchaRequest.d.ts +29 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.27.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.27.0...v1.27.1) (2023-01-24)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **captcha:** improve usage of captcha request ([b880306](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/b8803067cecb90c940dc8aab824615357efdf37c))
|
|
10
|
+
|
|
11
|
+
## [1.27.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.27.0-beta.1...v1.27.0) (2023-01-20)
|
|
12
|
+
|
|
5
13
|
## [1.27.0-beta.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.27.0-beta.0...v1.27.0-beta.1) (2023-01-20)
|
|
6
14
|
|
|
7
15
|
## [1.27.0-beta.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.25.6...v1.27.0-beta.0) (2023-01-20)
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
|
1
2
|
import AttributeModel from "./AttributeModel";
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Password attribute
|
|
5
6
|
*/
|
|
6
7
|
export default class CaptchaAttributeModel extends AttributeModel {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
_defineProperty(this, "_answer", "");
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
13
|
*/
|
|
9
14
|
static isApplicableModel(contributions) {
|
|
@@ -25,6 +30,20 @@ export default class CaptchaAttributeModel extends AttributeModel {
|
|
|
25
30
|
return this;
|
|
26
31
|
}
|
|
27
32
|
|
|
33
|
+
/**
|
|
34
|
+
*/
|
|
35
|
+
setAnswer(answer) {
|
|
36
|
+
this._answer = answer;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve the given answer for the captcha
|
|
41
|
+
* The value of this attribute is the token id of the captcha
|
|
42
|
+
*/
|
|
43
|
+
getAnswer() {
|
|
44
|
+
return this._answer;
|
|
45
|
+
}
|
|
46
|
+
|
|
28
47
|
/**
|
|
29
48
|
*/
|
|
30
49
|
get hasDynamicValidationData() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaAttributeModel.js","names":["AttributeModel","CaptchaAttributeModel","isApplicableModel","contributions","type","update","value","updateLastModification","inputvalue","hasDynamicValidationData"],"sources":["../../../src/models/attributes/CaptchaAttributeModel.js"],"sourcesContent":["// @flow\nimport AttributeModel from \"./AttributeModel\";\n\n/**\n * Password attribute\n */\nexport default class CaptchaAttributeModel extends AttributeModel {\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return contributions.type === \"captcha\";\n }\n\n /**\n */\n get type(): string {\n return \"captcha\";\n }\n\n /**\n * Update the attribute by name and value\n */\n update(value: string): this {\n this.updateLastModification();\n this.inputvalue = value;\n\n return this;\n }\n\n /**\n */\n get hasDynamicValidationData(): boolean {\n return false;\n }\n}\n"],"mappings":"AACA,OAAOA,cAAc,MAAM,kBAAkB;;AAE7C;AACA;AACA;AACA,eAAe,MAAMC,qBAAqB,SAASD,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"CaptchaAttributeModel.js","names":["AttributeModel","CaptchaAttributeModel","isApplicableModel","contributions","type","update","value","updateLastModification","inputvalue","setAnswer","answer","_answer","getAnswer","hasDynamicValidationData"],"sources":["../../../src/models/attributes/CaptchaAttributeModel.js"],"sourcesContent":["// @flow\nimport AttributeModel from \"./AttributeModel\";\n\n/**\n * Password attribute\n */\nexport default class CaptchaAttributeModel extends AttributeModel {\n _answer: string = \"\";\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return contributions.type === \"captcha\";\n }\n\n /**\n */\n get type(): string {\n return \"captcha\";\n }\n\n /**\n * Update the attribute by name and value\n */\n update(value: string): this {\n this.updateLastModification();\n this.inputvalue = value;\n\n return this;\n }\n\n /**\n */\n setAnswer(answer: string) {\n this._answer = answer;\n }\n\n /**\n * Retrieve the given answer for the captcha\n * The value of this attribute is the token id of the captcha\n */\n getAnswer(): string {\n return this._answer;\n }\n\n /**\n */\n get hasDynamicValidationData(): boolean {\n return false;\n }\n}\n"],"mappings":";AACA,OAAOA,cAAc,MAAM,kBAAkB;;AAE7C;AACA;AACA;AACA,eAAe,MAAMC,qBAAqB,SAASD,cAAc,CAAC;EAAA;IAAA;IAAA,iCAC9C,EAAE;EAAA;EAEpB;AACF;EACE,OAAOE,iBAAiB,CAACC,aAAqB,EAAW;IACvD,OAAOA,aAAa,CAACC,IAAI,KAAK,SAAS;EACzC;;EAEA;AACF;EACE,IAAIA,IAAI,GAAW;IACjB,OAAO,SAAS;EAClB;;EAEA;AACF;AACA;EACEC,MAAM,CAACC,KAAa,EAAQ;IAC1B,IAAI,CAACC,sBAAsB,EAAE;IAC7B,IAAI,CAACC,UAAU,GAAGF,KAAK;IAEvB,OAAO,IAAI;EACb;;EAEA;AACF;EACEG,SAAS,CAACC,MAAc,EAAE;IACxB,IAAI,CAACC,OAAO,GAAGD,MAAM;EACvB;;EAEA;AACF;AACA;AACA;EACEE,SAAS,GAAW;IAClB,OAAO,IAAI,CAACD,OAAO;EACrB;;EAEA;AACF;EACE,IAAIE,wBAAwB,GAAY;IACtC,OAAO,KAAK;EACd;AACF"}
|
|
@@ -6,19 +6,32 @@ import { getCaptchaPath, HTTP_METHODS } from "../constants";
|
|
|
6
6
|
class CaptchaRequest {
|
|
7
7
|
constructor() {
|
|
8
8
|
_defineProperty(this, "_tokenId", void 0);
|
|
9
|
+
_defineProperty(this, "_image", void 0);
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
*/
|
|
13
|
+
captchaResponse(response) {
|
|
14
|
+
this._tokenId = response.tokenId ?? this._tokenId;
|
|
15
|
+
this._image = response.image ?? this._image;
|
|
16
|
+
return {
|
|
17
|
+
tokenId: this._tokenId,
|
|
18
|
+
image: this._image,
|
|
19
|
+
valid: response.valid ?? false,
|
|
20
|
+
error: response.error ?? null
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Initiate the captcha request
|
|
26
|
+
*/
|
|
12
27
|
init() {
|
|
13
28
|
return xhr({
|
|
14
29
|
url: getCaptchaPath()
|
|
15
|
-
}).then(response =>
|
|
16
|
-
this._tokenId = response.tokenId;
|
|
17
|
-
return response;
|
|
18
|
-
});
|
|
30
|
+
}).then(response => this.captchaResponse(response));
|
|
19
31
|
}
|
|
20
32
|
|
|
21
33
|
/**
|
|
34
|
+
* Answer the captcha
|
|
22
35
|
*/
|
|
23
36
|
send(answer) {
|
|
24
37
|
return xhr({
|
|
@@ -28,10 +41,14 @@ class CaptchaRequest {
|
|
|
28
41
|
tokenId: this._tokenId ?? "",
|
|
29
42
|
answer: answer ?? ""
|
|
30
43
|
}
|
|
31
|
-
}).catch(error =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
}).then(response => this.captchaResponse(response)).catch(error => this.captchaResponse(error.response));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Reset the captcha and receive a new token and image
|
|
49
|
+
*/
|
|
50
|
+
refresh() {
|
|
51
|
+
return this.init();
|
|
35
52
|
}
|
|
36
53
|
}
|
|
37
54
|
export default CaptchaRequest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaRequest.js","names":["xhr","getCaptchaPath","HTTP_METHODS","CaptchaRequest","
|
|
1
|
+
{"version":3,"file":"CaptchaRequest.js","names":["xhr","getCaptchaPath","HTTP_METHODS","CaptchaRequest","captchaResponse","response","_tokenId","tokenId","_image","image","valid","error","init","url","then","send","answer","method","POST","data","catch","refresh"],"sources":["../../src/modularui/CaptchaRequest.js"],"sourcesContent":["// @flow\nimport xhr from \"../utils/fetch/xhr\";\nimport { getCaptchaPath, HTTP_METHODS } from \"../constants\";\n\ntype CaptchaInitialResponse = {\n tokenId: string,\n image: string,\n};\n\ntype CaptchaValidResponse = {\n valid: boolean,\n};\n\ntype CaptchaInvalidResponse = {\n tokenId: string,\n image: string,\n valid: boolean,\n error: { id: string },\n};\n\ntype CaptchaResponse = {\n tokenId: string,\n image: string,\n valid: boolean,\n error: { id: string } | null,\n};\n\n/**\n */\nclass CaptchaRequest {\n _tokenId: string;\n _image: string;\n\n /**\n */\n captchaResponse(\n response:\n | CaptchaInitialResponse\n | CaptchaValidResponse\n | CaptchaInvalidResponse\n ): CaptchaResponse {\n this._tokenId = response.tokenId ?? this._tokenId;\n this._image = response.image ?? this._image;\n\n return {\n tokenId: this._tokenId,\n image: this._image,\n valid: response.valid ?? false,\n error: response.error ?? null,\n };\n }\n\n /**\n * Initiate the captcha request\n */\n init(): Promise<CaptchaResponse> {\n return xhr({\n url: getCaptchaPath(),\n }).then((response) => this.captchaResponse(response));\n }\n\n /**\n * Answer the captcha\n */\n send(answer?: string): Promise<CaptchaResponse> {\n return xhr({\n url: getCaptchaPath(),\n method: HTTP_METHODS.POST,\n data: {\n tokenId: this._tokenId ?? \"\",\n answer: answer ?? \"\",\n },\n })\n .then((response) => this.captchaResponse(response))\n .catch((error) => this.captchaResponse(error.response));\n }\n\n /**\n * Reset the captcha and receive a new token and image\n */\n refresh(): Promise<CaptchaResponse> {\n return this.init();\n }\n}\n\nexport default CaptchaRequest;\n"],"mappings":";AACA,OAAOA,GAAG,MAAM,oBAAoB;AACpC,SAASC,cAAc,EAAEC,YAAY,QAAQ,cAAc;AAyB3D;AACA;AACA,MAAMC,cAAc,CAAC;EAAA;IAAA;IAAA;EAAA;EAInB;AACF;EACEC,eAAe,CACbC,QAG0B,EACT;IACjB,IAAI,CAACC,QAAQ,GAAGD,QAAQ,CAACE,OAAO,IAAI,IAAI,CAACD,QAAQ;IACjD,IAAI,CAACE,MAAM,GAAGH,QAAQ,CAACI,KAAK,IAAI,IAAI,CAACD,MAAM;IAE3C,OAAO;MACLD,OAAO,EAAE,IAAI,CAACD,QAAQ;MACtBG,KAAK,EAAE,IAAI,CAACD,MAAM;MAClBE,KAAK,EAAEL,QAAQ,CAACK,KAAK,IAAI,KAAK;MAC9BC,KAAK,EAAEN,QAAQ,CAACM,KAAK,IAAI;IAC3B,CAAC;EACH;;EAEA;AACF;AACA;EACEC,IAAI,GAA6B;IAC/B,OAAOZ,GAAG,CAAC;MACTa,GAAG,EAAEZ,cAAc;IACrB,CAAC,CAAC,CAACa,IAAI,CAAET,QAAQ,IAAK,IAAI,CAACD,eAAe,CAACC,QAAQ,CAAC,CAAC;EACvD;;EAEA;AACF;AACA;EACEU,IAAI,CAACC,MAAe,EAA4B;IAC9C,OAAOhB,GAAG,CAAC;MACTa,GAAG,EAAEZ,cAAc,EAAE;MACrBgB,MAAM,EAAEf,YAAY,CAACgB,IAAI;MACzBC,IAAI,EAAE;QACJZ,OAAO,EAAE,IAAI,CAACD,QAAQ,IAAI,EAAE;QAC5BU,MAAM,EAAEA,MAAM,IAAI;MACpB;IACF,CAAC,CAAC,CACCF,IAAI,CAAET,QAAQ,IAAK,IAAI,CAACD,eAAe,CAACC,QAAQ,CAAC,CAAC,CAClDe,KAAK,CAAET,KAAK,IAAK,IAAI,CAACP,eAAe,CAACO,KAAK,CAACN,QAAQ,CAAC,CAAC;EAC3D;;EAEA;AACF;AACA;EACEgB,OAAO,GAA6B;IAClC,OAAO,IAAI,CAACT,IAAI,EAAE;EACpB;AACF;AAEA,eAAeT,cAAc"}
|
|
@@ -5,11 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
8
9
|
var _AttributeModel = _interopRequireDefault(require("./AttributeModel"));
|
|
9
10
|
/**
|
|
10
11
|
* Password attribute
|
|
11
12
|
*/
|
|
12
13
|
class CaptchaAttributeModel extends _AttributeModel.default {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
(0, _defineProperty2.default)(this, "_answer", "");
|
|
17
|
+
}
|
|
13
18
|
/**
|
|
14
19
|
*/
|
|
15
20
|
static isApplicableModel(contributions) {
|
|
@@ -31,6 +36,20 @@ class CaptchaAttributeModel extends _AttributeModel.default {
|
|
|
31
36
|
return this;
|
|
32
37
|
}
|
|
33
38
|
|
|
39
|
+
/**
|
|
40
|
+
*/
|
|
41
|
+
setAnswer(answer) {
|
|
42
|
+
this._answer = answer;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Retrieve the given answer for the captcha
|
|
47
|
+
* The value of this attribute is the token id of the captcha
|
|
48
|
+
*/
|
|
49
|
+
getAnswer() {
|
|
50
|
+
return this._answer;
|
|
51
|
+
}
|
|
52
|
+
|
|
34
53
|
/**
|
|
35
54
|
*/
|
|
36
55
|
get hasDynamicValidationData() {
|
|
@@ -5,6 +5,8 @@ import AttributeModel from "./AttributeModel";
|
|
|
5
5
|
* Password attribute
|
|
6
6
|
*/
|
|
7
7
|
export default class CaptchaAttributeModel extends AttributeModel {
|
|
8
|
+
_answer: string = "";
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
*/
|
|
10
12
|
static isApplicableModel(contributions: Object): boolean {
|
|
@@ -27,6 +29,20 @@ export default class CaptchaAttributeModel extends AttributeModel {
|
|
|
27
29
|
return this;
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
/**
|
|
33
|
+
*/
|
|
34
|
+
setAnswer(answer: string) {
|
|
35
|
+
this._answer = answer;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve the given answer for the captcha
|
|
40
|
+
* The value of this attribute is the token id of the captcha
|
|
41
|
+
*/
|
|
42
|
+
getAnswer(): string {
|
|
43
|
+
return this._answer;
|
|
44
|
+
}
|
|
45
|
+
|
|
30
46
|
/**
|
|
31
47
|
*/
|
|
32
48
|
get hasDynamicValidationData(): boolean {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaAttributeModel.js","names":["CaptchaAttributeModel","AttributeModel","isApplicableModel","contributions","type","update","value","updateLastModification","inputvalue","hasDynamicValidationData"],"sources":["../../../src/models/attributes/CaptchaAttributeModel.js"],"sourcesContent":["// @flow\nimport AttributeModel from \"./AttributeModel\";\n\n/**\n * Password attribute\n */\nexport default class CaptchaAttributeModel extends AttributeModel {\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return contributions.type === \"captcha\";\n }\n\n /**\n */\n get type(): string {\n return \"captcha\";\n }\n\n /**\n * Update the attribute by name and value\n */\n update(value: string): this {\n this.updateLastModification();\n this.inputvalue = value;\n\n return this;\n }\n\n /**\n */\n get hasDynamicValidationData(): boolean {\n return false;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CaptchaAttributeModel.js","names":["CaptchaAttributeModel","AttributeModel","isApplicableModel","contributions","type","update","value","updateLastModification","inputvalue","setAnswer","answer","_answer","getAnswer","hasDynamicValidationData"],"sources":["../../../src/models/attributes/CaptchaAttributeModel.js"],"sourcesContent":["// @flow\nimport AttributeModel from \"./AttributeModel\";\n\n/**\n * Password attribute\n */\nexport default class CaptchaAttributeModel extends AttributeModel {\n _answer: string = \"\";\n\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return contributions.type === \"captcha\";\n }\n\n /**\n */\n get type(): string {\n return \"captcha\";\n }\n\n /**\n * Update the attribute by name and value\n */\n update(value: string): this {\n this.updateLastModification();\n this.inputvalue = value;\n\n return this;\n }\n\n /**\n */\n setAnswer(answer: string) {\n this._answer = answer;\n }\n\n /**\n * Retrieve the given answer for the captcha\n * The value of this attribute is the token id of the captcha\n */\n getAnswer(): string {\n return this._answer;\n }\n\n /**\n */\n get hasDynamicValidationData(): boolean {\n return false;\n }\n}\n"],"mappings":";;;;;;;;AACA;AAEA;AACA;AACA;AACe,MAAMA,qBAAqB,SAASC,uBAAc,CAAC;EAAA;IAAA;IAAA,+CAC9C,EAAE;EAAA;EAEpB;AACF;EACE,OAAOC,iBAAiB,CAACC,aAAqB,EAAW;IACvD,OAAOA,aAAa,CAACC,IAAI,KAAK,SAAS;EACzC;;EAEA;AACF;EACE,IAAIA,IAAI,GAAW;IACjB,OAAO,SAAS;EAClB;;EAEA;AACF;AACA;EACEC,MAAM,CAACC,KAAa,EAAQ;IAC1B,IAAI,CAACC,sBAAsB,EAAE;IAC7B,IAAI,CAACC,UAAU,GAAGF,KAAK;IAEvB,OAAO,IAAI;EACb;;EAEA;AACF;EACEG,SAAS,CAACC,MAAc,EAAE;IACxB,IAAI,CAACC,OAAO,GAAGD,MAAM;EACvB;;EAEA;AACF;AACA;AACA;EACEE,SAAS,GAAW;IAClB,OAAO,IAAI,CAACD,OAAO;EACrB;;EAEA;AACF;EACE,IAAIE,wBAAwB,GAAY;IACtC,OAAO,KAAK;EACd;AACF;AAAC"}
|
|
@@ -13,19 +13,32 @@ var _constants = require("../constants");
|
|
|
13
13
|
class CaptchaRequest {
|
|
14
14
|
constructor() {
|
|
15
15
|
(0, _defineProperty2.default)(this, "_tokenId", void 0);
|
|
16
|
+
(0, _defineProperty2.default)(this, "_image", void 0);
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
*/
|
|
20
|
+
captchaResponse(response) {
|
|
21
|
+
this._tokenId = response.tokenId ?? this._tokenId;
|
|
22
|
+
this._image = response.image ?? this._image;
|
|
23
|
+
return {
|
|
24
|
+
tokenId: this._tokenId,
|
|
25
|
+
image: this._image,
|
|
26
|
+
valid: response.valid ?? false,
|
|
27
|
+
error: response.error ?? null
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Initiate the captcha request
|
|
33
|
+
*/
|
|
19
34
|
init() {
|
|
20
35
|
return (0, _xhr.default)({
|
|
21
36
|
url: (0, _constants.getCaptchaPath)()
|
|
22
|
-
}).then(response =>
|
|
23
|
-
this._tokenId = response.tokenId;
|
|
24
|
-
return response;
|
|
25
|
-
});
|
|
37
|
+
}).then(response => this.captchaResponse(response));
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
/**
|
|
41
|
+
* Answer the captcha
|
|
29
42
|
*/
|
|
30
43
|
send(answer) {
|
|
31
44
|
return (0, _xhr.default)({
|
|
@@ -35,10 +48,14 @@ class CaptchaRequest {
|
|
|
35
48
|
tokenId: this._tokenId ?? "",
|
|
36
49
|
answer: answer ?? ""
|
|
37
50
|
}
|
|
38
|
-
}).catch(error =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
}).then(response => this.captchaResponse(response)).catch(error => this.captchaResponse(error.response));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Reset the captcha and receive a new token and image
|
|
56
|
+
*/
|
|
57
|
+
refresh() {
|
|
58
|
+
return this.init();
|
|
42
59
|
}
|
|
43
60
|
}
|
|
44
61
|
var _default = CaptchaRequest;
|
|
@@ -2,30 +2,65 @@
|
|
|
2
2
|
import xhr from "../utils/fetch/xhr";
|
|
3
3
|
import { getCaptchaPath, HTTP_METHODS } from "../constants";
|
|
4
4
|
|
|
5
|
+
type CaptchaInitialResponse = {
|
|
6
|
+
tokenId: string,
|
|
7
|
+
image: string,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type CaptchaValidResponse = {
|
|
11
|
+
valid: boolean,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type CaptchaInvalidResponse = {
|
|
15
|
+
tokenId: string,
|
|
16
|
+
image: string,
|
|
17
|
+
valid: boolean,
|
|
18
|
+
error: { id: string },
|
|
19
|
+
};
|
|
20
|
+
|
|
5
21
|
type CaptchaResponse = {
|
|
6
22
|
tokenId: string,
|
|
7
|
-
image:
|
|
23
|
+
image: string,
|
|
8
24
|
valid: boolean,
|
|
25
|
+
error: { id: string } | null,
|
|
9
26
|
};
|
|
10
27
|
|
|
11
28
|
/**
|
|
12
29
|
*/
|
|
13
30
|
class CaptchaRequest {
|
|
14
31
|
_tokenId: string;
|
|
32
|
+
_image: string;
|
|
15
33
|
|
|
16
34
|
/**
|
|
17
35
|
*/
|
|
36
|
+
captchaResponse(
|
|
37
|
+
response:
|
|
38
|
+
| CaptchaInitialResponse
|
|
39
|
+
| CaptchaValidResponse
|
|
40
|
+
| CaptchaInvalidResponse
|
|
41
|
+
): CaptchaResponse {
|
|
42
|
+
this._tokenId = response.tokenId ?? this._tokenId;
|
|
43
|
+
this._image = response.image ?? this._image;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
tokenId: this._tokenId,
|
|
47
|
+
image: this._image,
|
|
48
|
+
valid: response.valid ?? false,
|
|
49
|
+
error: response.error ?? null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Initiate the captcha request
|
|
55
|
+
*/
|
|
18
56
|
init(): Promise<CaptchaResponse> {
|
|
19
57
|
return xhr({
|
|
20
58
|
url: getCaptchaPath(),
|
|
21
|
-
}).then((response) =>
|
|
22
|
-
this._tokenId = response.tokenId;
|
|
23
|
-
|
|
24
|
-
return response;
|
|
25
|
-
});
|
|
59
|
+
}).then((response) => this.captchaResponse(response));
|
|
26
60
|
}
|
|
27
61
|
|
|
28
62
|
/**
|
|
63
|
+
* Answer the captcha
|
|
29
64
|
*/
|
|
30
65
|
send(answer?: string): Promise<CaptchaResponse> {
|
|
31
66
|
return xhr({
|
|
@@ -35,10 +70,16 @@ class CaptchaRequest {
|
|
|
35
70
|
tokenId: this._tokenId ?? "",
|
|
36
71
|
answer: answer ?? "",
|
|
37
72
|
},
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
73
|
+
})
|
|
74
|
+
.then((response) => this.captchaResponse(response))
|
|
75
|
+
.catch((error) => this.captchaResponse(error.response));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Reset the captcha and receive a new token and image
|
|
80
|
+
*/
|
|
81
|
+
refresh(): Promise<CaptchaResponse> {
|
|
82
|
+
return this.init();
|
|
42
83
|
}
|
|
43
84
|
}
|
|
44
85
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CaptchaRequest.js","names":["CaptchaRequest","
|
|
1
|
+
{"version":3,"file":"CaptchaRequest.js","names":["CaptchaRequest","captchaResponse","response","_tokenId","tokenId","_image","image","valid","error","init","xhr","url","getCaptchaPath","then","send","answer","method","HTTP_METHODS","POST","data","catch","refresh"],"sources":["../../src/modularui/CaptchaRequest.js"],"sourcesContent":["// @flow\nimport xhr from \"../utils/fetch/xhr\";\nimport { getCaptchaPath, HTTP_METHODS } from \"../constants\";\n\ntype CaptchaInitialResponse = {\n tokenId: string,\n image: string,\n};\n\ntype CaptchaValidResponse = {\n valid: boolean,\n};\n\ntype CaptchaInvalidResponse = {\n tokenId: string,\n image: string,\n valid: boolean,\n error: { id: string },\n};\n\ntype CaptchaResponse = {\n tokenId: string,\n image: string,\n valid: boolean,\n error: { id: string } | null,\n};\n\n/**\n */\nclass CaptchaRequest {\n _tokenId: string;\n _image: string;\n\n /**\n */\n captchaResponse(\n response:\n | CaptchaInitialResponse\n | CaptchaValidResponse\n | CaptchaInvalidResponse\n ): CaptchaResponse {\n this._tokenId = response.tokenId ?? this._tokenId;\n this._image = response.image ?? this._image;\n\n return {\n tokenId: this._tokenId,\n image: this._image,\n valid: response.valid ?? false,\n error: response.error ?? null,\n };\n }\n\n /**\n * Initiate the captcha request\n */\n init(): Promise<CaptchaResponse> {\n return xhr({\n url: getCaptchaPath(),\n }).then((response) => this.captchaResponse(response));\n }\n\n /**\n * Answer the captcha\n */\n send(answer?: string): Promise<CaptchaResponse> {\n return xhr({\n url: getCaptchaPath(),\n method: HTTP_METHODS.POST,\n data: {\n tokenId: this._tokenId ?? \"\",\n answer: answer ?? \"\",\n },\n })\n .then((response) => this.captchaResponse(response))\n .catch((error) => this.captchaResponse(error.response));\n }\n\n /**\n * Reset the captcha and receive a new token and image\n */\n refresh(): Promise<CaptchaResponse> {\n return this.init();\n }\n}\n\nexport default CaptchaRequest;\n"],"mappings":";;;;;;;;AACA;AACA;AAyBA;AACA;AACA,MAAMA,cAAc,CAAC;EAAA;IAAA;IAAA;EAAA;EAInB;AACF;EACEC,eAAe,CACbC,QAG0B,EACT;IACjB,IAAI,CAACC,QAAQ,GAAGD,QAAQ,CAACE,OAAO,IAAI,IAAI,CAACD,QAAQ;IACjD,IAAI,CAACE,MAAM,GAAGH,QAAQ,CAACI,KAAK,IAAI,IAAI,CAACD,MAAM;IAE3C,OAAO;MACLD,OAAO,EAAE,IAAI,CAACD,QAAQ;MACtBG,KAAK,EAAE,IAAI,CAACD,MAAM;MAClBE,KAAK,EAAEL,QAAQ,CAACK,KAAK,IAAI,KAAK;MAC9BC,KAAK,EAAEN,QAAQ,CAACM,KAAK,IAAI;IAC3B,CAAC;EACH;;EAEA;AACF;AACA;EACEC,IAAI,GAA6B;IAC/B,OAAO,IAAAC,YAAG,EAAC;MACTC,GAAG,EAAE,IAAAC,yBAAc;IACrB,CAAC,CAAC,CAACC,IAAI,CAAEX,QAAQ,IAAK,IAAI,CAACD,eAAe,CAACC,QAAQ,CAAC,CAAC;EACvD;;EAEA;AACF;AACA;EACEY,IAAI,CAACC,MAAe,EAA4B;IAC9C,OAAO,IAAAL,YAAG,EAAC;MACTC,GAAG,EAAE,IAAAC,yBAAc,GAAE;MACrBI,MAAM,EAAEC,uBAAY,CAACC,IAAI;MACzBC,IAAI,EAAE;QACJf,OAAO,EAAE,IAAI,CAACD,QAAQ,IAAI,EAAE;QAC5BY,MAAM,EAAEA,MAAM,IAAI;MACpB;IACF,CAAC,CAAC,CACCF,IAAI,CAAEX,QAAQ,IAAK,IAAI,CAACD,eAAe,CAACC,QAAQ,CAAC,CAAC,CAClDkB,KAAK,CAAEZ,KAAK,IAAK,IAAI,CAACP,eAAe,CAACO,KAAK,CAACN,QAAQ,CAAC,CAAC;EAC3D;;EAEA;AACF;AACA;EACEmB,OAAO,GAA6B;IAClC,OAAO,IAAI,CAACZ,IAAI,EAAE;EACpB;AACF;AAAC,eAEcT,cAAc;AAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.27.
|
|
3
|
+
"version": "1.27.1",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"styled-components": "^5.0.0"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@babel/runtime-corejs3": "^7.20.
|
|
85
|
+
"@babel/runtime-corejs3": "^7.20.13",
|
|
86
86
|
"big.js": "^6.2.1",
|
|
87
87
|
"date-fns": "^2.29.3",
|
|
88
88
|
"deepmerge": "^4.2.2",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"@commitlint/config-conventional": "^17.4.2",
|
|
114
114
|
"@testing-library/react": "^13.4.0",
|
|
115
115
|
"auditjs": "^4.0.39",
|
|
116
|
-
"babel-jest": "^29.
|
|
116
|
+
"babel-jest": "^29.4.0",
|
|
117
117
|
"babel-plugin-styled-components": "^2.0.7",
|
|
118
118
|
"cherry-pick": "^0.5.0",
|
|
119
119
|
"cross-env": "^7.0.3",
|
|
@@ -124,18 +124,18 @@
|
|
|
124
124
|
"eslint-plugin-ft-flow": "^2.0.3",
|
|
125
125
|
"eslint-plugin-import": "^2.27.5",
|
|
126
126
|
"eslint-plugin-jest": "^27.2.1",
|
|
127
|
-
"eslint-plugin-jsdoc": "^39.6.
|
|
127
|
+
"eslint-plugin-jsdoc": "^39.6.8",
|
|
128
128
|
"eslint-plugin-react": "^7.32.1",
|
|
129
129
|
"eslint-plugin-react-hooks": "^4.5.0",
|
|
130
130
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.12.0",
|
|
131
|
-
"flow-bin": "^0.
|
|
131
|
+
"flow-bin": "^0.198.1",
|
|
132
132
|
"flow-copy-source": "^2.0.9",
|
|
133
133
|
"flow-typed": "^3.8.0",
|
|
134
134
|
"glob": "^8.1.0",
|
|
135
135
|
"history": "^4.0.0",
|
|
136
136
|
"husky": "^8.0.3",
|
|
137
|
-
"jest": "^29.
|
|
138
|
-
"jest-environment-jsdom": "^29.
|
|
137
|
+
"jest": "^29.4.0",
|
|
138
|
+
"jest-environment-jsdom": "^29.4.0",
|
|
139
139
|
"jest-junit": "^15.0.0",
|
|
140
140
|
"jest-sonar-reporter": "^2.0.0",
|
|
141
141
|
"jscodeshift": "^0.14.0",
|
|
@@ -151,7 +151,7 @@
|
|
|
151
151
|
"redux": "^4.0.0",
|
|
152
152
|
"redux-mock-store": "^1.5.4",
|
|
153
153
|
"redux-thunk": "^2.4.2",
|
|
154
|
-
"rimraf": "^4.1.
|
|
154
|
+
"rimraf": "^4.1.2",
|
|
155
155
|
"standard-version": "^9.5.0",
|
|
156
156
|
"styled-components": "^5.3.6",
|
|
157
157
|
"xhr-mock": "^2.5.1"
|
|
@@ -5,6 +5,8 @@ import AttributeModel from "./AttributeModel";
|
|
|
5
5
|
* Password attribute
|
|
6
6
|
*/
|
|
7
7
|
export default class CaptchaAttributeModel extends AttributeModel {
|
|
8
|
+
_answer: string = "";
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
*/
|
|
10
12
|
static isApplicableModel(contributions: Object): boolean {
|
|
@@ -27,6 +29,20 @@ export default class CaptchaAttributeModel extends AttributeModel {
|
|
|
27
29
|
return this;
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
/**
|
|
33
|
+
*/
|
|
34
|
+
setAnswer(answer: string) {
|
|
35
|
+
this._answer = answer;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Retrieve the given answer for the captcha
|
|
40
|
+
* The value of this attribute is the token id of the captcha
|
|
41
|
+
*/
|
|
42
|
+
getAnswer(): string {
|
|
43
|
+
return this._answer;
|
|
44
|
+
}
|
|
45
|
+
|
|
30
46
|
/**
|
|
31
47
|
*/
|
|
32
48
|
get hasDynamicValidationData(): boolean {
|
|
@@ -2,30 +2,65 @@
|
|
|
2
2
|
import xhr from "../utils/fetch/xhr";
|
|
3
3
|
import { getCaptchaPath, HTTP_METHODS } from "../constants";
|
|
4
4
|
|
|
5
|
+
type CaptchaInitialResponse = {
|
|
6
|
+
tokenId: string,
|
|
7
|
+
image: string,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
type CaptchaValidResponse = {
|
|
11
|
+
valid: boolean,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
type CaptchaInvalidResponse = {
|
|
15
|
+
tokenId: string,
|
|
16
|
+
image: string,
|
|
17
|
+
valid: boolean,
|
|
18
|
+
error: { id: string },
|
|
19
|
+
};
|
|
20
|
+
|
|
5
21
|
type CaptchaResponse = {
|
|
6
22
|
tokenId: string,
|
|
7
|
-
image:
|
|
23
|
+
image: string,
|
|
8
24
|
valid: boolean,
|
|
25
|
+
error: { id: string } | null,
|
|
9
26
|
};
|
|
10
27
|
|
|
11
28
|
/**
|
|
12
29
|
*/
|
|
13
30
|
class CaptchaRequest {
|
|
14
31
|
_tokenId: string;
|
|
32
|
+
_image: string;
|
|
15
33
|
|
|
16
34
|
/**
|
|
17
35
|
*/
|
|
36
|
+
captchaResponse(
|
|
37
|
+
response:
|
|
38
|
+
| CaptchaInitialResponse
|
|
39
|
+
| CaptchaValidResponse
|
|
40
|
+
| CaptchaInvalidResponse
|
|
41
|
+
): CaptchaResponse {
|
|
42
|
+
this._tokenId = response.tokenId ?? this._tokenId;
|
|
43
|
+
this._image = response.image ?? this._image;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
tokenId: this._tokenId,
|
|
47
|
+
image: this._image,
|
|
48
|
+
valid: response.valid ?? false,
|
|
49
|
+
error: response.error ?? null,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Initiate the captcha request
|
|
55
|
+
*/
|
|
18
56
|
init(): Promise<CaptchaResponse> {
|
|
19
57
|
return xhr({
|
|
20
58
|
url: getCaptchaPath(),
|
|
21
|
-
}).then((response) =>
|
|
22
|
-
this._tokenId = response.tokenId;
|
|
23
|
-
|
|
24
|
-
return response;
|
|
25
|
-
});
|
|
59
|
+
}).then((response) => this.captchaResponse(response));
|
|
26
60
|
}
|
|
27
61
|
|
|
28
62
|
/**
|
|
63
|
+
* Answer the captcha
|
|
29
64
|
*/
|
|
30
65
|
send(answer?: string): Promise<CaptchaResponse> {
|
|
31
66
|
return xhr({
|
|
@@ -35,10 +70,16 @@ class CaptchaRequest {
|
|
|
35
70
|
tokenId: this._tokenId ?? "",
|
|
36
71
|
answer: answer ?? "",
|
|
37
72
|
},
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
73
|
+
})
|
|
74
|
+
.then((response) => this.captchaResponse(response))
|
|
75
|
+
.catch((error) => this.captchaResponse(error.response));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Reset the captcha and receive a new token and image
|
|
80
|
+
*/
|
|
81
|
+
refresh(): Promise<CaptchaResponse> {
|
|
82
|
+
return this.init();
|
|
42
83
|
}
|
|
43
84
|
}
|
|
44
85
|
|
|
@@ -2,9 +2,18 @@
|
|
|
2
2
|
* Password attribute
|
|
3
3
|
*/
|
|
4
4
|
export default class CaptchaAttributeModel extends AttributeModel {
|
|
5
|
+
_answer: string;
|
|
5
6
|
/**
|
|
6
7
|
* Update the attribute by name and value
|
|
7
8
|
*/
|
|
8
9
|
update(value: string): this;
|
|
10
|
+
/**
|
|
11
|
+
*/
|
|
12
|
+
setAnswer(answer: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Retrieve the given answer for the captcha
|
|
15
|
+
* The value of this attribute is the token id of the captcha
|
|
16
|
+
*/
|
|
17
|
+
getAnswer(): string;
|
|
9
18
|
}
|
|
10
19
|
import AttributeModel from "./AttributeModel";
|
|
@@ -3,15 +3,43 @@ export default CaptchaRequest;
|
|
|
3
3
|
*/
|
|
4
4
|
declare class CaptchaRequest {
|
|
5
5
|
_tokenId: string;
|
|
6
|
+
_image: string;
|
|
6
7
|
/**
|
|
7
8
|
*/
|
|
9
|
+
captchaResponse(response: CaptchaInitialResponse | CaptchaValidResponse | CaptchaInvalidResponse): CaptchaResponse;
|
|
10
|
+
/**
|
|
11
|
+
* Initiate the captcha request
|
|
12
|
+
*/
|
|
8
13
|
init(): Promise<CaptchaResponse>;
|
|
9
14
|
/**
|
|
15
|
+
* Answer the captcha
|
|
10
16
|
*/
|
|
11
17
|
send(answer?: string): Promise<CaptchaResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Reset the captcha and receive a new token and image
|
|
20
|
+
*/
|
|
21
|
+
refresh(): Promise<CaptchaResponse>;
|
|
12
22
|
}
|
|
23
|
+
type CaptchaInitialResponse = {
|
|
24
|
+
tokenId: string;
|
|
25
|
+
image: string;
|
|
26
|
+
};
|
|
27
|
+
type CaptchaValidResponse = {
|
|
28
|
+
valid: boolean;
|
|
29
|
+
};
|
|
30
|
+
type CaptchaInvalidResponse = {
|
|
31
|
+
tokenId: string;
|
|
32
|
+
image: string;
|
|
33
|
+
valid: boolean;
|
|
34
|
+
error: {
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
13
38
|
type CaptchaResponse = {
|
|
14
39
|
tokenId: string;
|
|
15
|
-
image:
|
|
40
|
+
image: string;
|
|
16
41
|
valid: boolean;
|
|
42
|
+
error: {
|
|
43
|
+
id: string;
|
|
44
|
+
};
|
|
17
45
|
};
|