@internetarchive/recaptcha-manager 0.1.0 → 0.1.2-alpha.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.
Files changed (50) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +26 -26
  3. package/.husky/pre-commit +4 -4
  4. package/LICENSE +661 -661
  5. package/README.md +85 -85
  6. package/demo/app-root.ts +93 -93
  7. package/demo/index.html +21 -21
  8. package/dist/demo/app-root.d.ts +14 -14
  9. package/dist/demo/app-root.js +85 -85
  10. package/dist/demo/app-root.js.map +1 -1
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +2 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/src/recaptcha-manager.d.ts +35 -35
  15. package/dist/src/recaptcha-manager.js +52 -52
  16. package/dist/src/recaptcha-manager.js.map +1 -1
  17. package/dist/src/recaptcha-widget.d.ts +39 -39
  18. package/dist/src/recaptcha-widget.js +95 -95
  19. package/dist/src/recaptcha-widget.js.map +1 -1
  20. package/dist/test/mock-grecaptcha.d.ts +24 -24
  21. package/dist/test/mock-grecaptcha.js +61 -61
  22. package/dist/test/mock-grecaptcha.js.map +1 -1
  23. package/dist/test/mock-lazy-loader.d.ts +15 -15
  24. package/dist/test/mock-lazy-loader.js +16 -16
  25. package/dist/test/mock-lazy-loader.js.map +1 -1
  26. package/dist/test/recaptcha-manager.test.d.ts +1 -1
  27. package/dist/test/recaptcha-manager.test.js +137 -137
  28. package/dist/test/recaptcha-manager.test.js.map +1 -1
  29. package/index.ts +10 -10
  30. package/package.json +98 -97
  31. package/src/recaptcha-manager.ts +87 -87
  32. package/src/recaptcha-widget.ts +148 -148
  33. package/test/mock-grecaptcha.ts +87 -87
  34. package/test/mock-lazy-loader.ts +38 -38
  35. package/test/recaptcha-manager.test.ts +151 -151
  36. package/tsconfig.json +20 -20
  37. package/web-dev-server.config.mjs +28 -28
  38. package/web-test-runner.config.mjs +41 -41
  39. package/dist/src/recaptcha-manager copy.d.ts +0 -82
  40. package/dist/src/recaptcha-manager copy.js +0 -140
  41. package/dist/src/recaptcha-manager copy.js.map +0 -1
  42. package/dist/src/recaptcha-manager-bak.d.ts +0 -82
  43. package/dist/src/recaptcha-manager-bak.js +0 -140
  44. package/dist/src/recaptcha-manager-bak.js.map +0 -1
  45. package/dist/src/recaptcha.d.ts +0 -28
  46. package/dist/src/recaptcha.js +0 -87
  47. package/dist/src/recaptcha.js.map +0 -1
  48. package/dist/test/your-webcomponent.test.d.ts +0 -0
  49. package/dist/test/your-webcomponent.test.js +0 -4
  50. package/dist/test/your-webcomponent.test.js.map +0 -1
package/README.md CHANGED
@@ -1,85 +1,85 @@
1
- ![Build Status](https://github.com/internetarchive/iaux-recaptcha-manager/actions/workflows/ci.yml/badge.svg)
2
-
3
- # Internet Archive reCaptcha Manager
4
-
5
- A library to lazy load and interact with reCaptcha
6
-
7
- ## Installation
8
-
9
- ```shell
10
- > yarn add @internetarchive/recaptcha-manager
11
- ```
12
-
13
- ## Usage
14
-
15
- ```ts
16
- const recaptchaManager = new RecaptchaManager({
17
- defaultSiteKey: 'your-site-key',
18
- });
19
-
20
- // will load recaptcha library if it's not loaded
21
- const recaptchaWidget = await recaptchaManager.getRecaptchaWidget({
22
- recaptchaParams: {
23
- tabindex: 0,
24
- theme: 'light',
25
- type: 'image',
26
- },
27
- });
28
-
29
- const token = await recaptchaWidget.execute();
30
-
31
- // submit token with your post and validate on the backend
32
- ```
33
-
34
- For more usage examples, see `demo/app-root.ts` and `test/recaptcha-manager.test.ts`.
35
-
36
- ## Local Demo with `web-dev-server`
37
- ```bash
38
- yarn start
39
- ```
40
- To run a local development server that serves the basic demo located in `demo/index.html`
41
-
42
- ## Testing with Web Test Runner
43
- To run the suite of Web Test Runner tests, run
44
- ```bash
45
- yarn run test
46
- ```
47
-
48
- To run the tests in watch mode (for <abbr title="test driven development">TDD</abbr>, for example), run
49
-
50
- ```bash
51
- yarn run test:watch
52
- ```
53
-
54
- ## Linting with ESLint, Prettier, and Types
55
- To scan the project for linting errors, run
56
- ```bash
57
- yarn run lint
58
- ```
59
-
60
- You can lint with ESLint and Prettier individually as well
61
- ```bash
62
- yarn run lint:eslint
63
- ```
64
- ```bash
65
- yarn run lint:prettier
66
- ```
67
-
68
- To automatically fix many linting errors, run
69
- ```bash
70
- yarn run format
71
- ```
72
-
73
- You can format using ESLint and Prettier individually as well
74
- ```bash
75
- yarn run format:eslint
76
- ```
77
- ```bash
78
- yarn run format:prettier
79
- ```
80
-
81
- ## Tooling configs
82
-
83
- For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
84
-
85
- If you customize the configuration a lot, you can consider moving them to individual files.
1
+ ![Build Status](https://github.com/internetarchive/iaux-recaptcha-manager/actions/workflows/ci.yml/badge.svg)
2
+
3
+ # Internet Archive reCaptcha Manager
4
+
5
+ A library to lazy load and interact with reCaptcha
6
+
7
+ ## Installation
8
+
9
+ ```shell
10
+ > yarn add @internetarchive/recaptcha-manager
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ const recaptchaManager = new RecaptchaManager({
17
+ defaultSiteKey: 'your-site-key',
18
+ });
19
+
20
+ // will load recaptcha library if it's not loaded
21
+ const recaptchaWidget = await recaptchaManager.getRecaptchaWidget({
22
+ recaptchaParams: {
23
+ tabindex: 0,
24
+ theme: 'light',
25
+ type: 'image',
26
+ },
27
+ });
28
+
29
+ const token = await recaptchaWidget.execute();
30
+
31
+ // submit token with your post and validate on the backend
32
+ ```
33
+
34
+ For more usage examples, see `demo/app-root.ts` and `test/recaptcha-manager.test.ts`.
35
+
36
+ ## Local Demo with `web-dev-server`
37
+ ```bash
38
+ yarn start
39
+ ```
40
+ To run a local development server that serves the basic demo located in `demo/index.html`
41
+
42
+ ## Testing with Web Test Runner
43
+ To run the suite of Web Test Runner tests, run
44
+ ```bash
45
+ yarn run test
46
+ ```
47
+
48
+ To run the tests in watch mode (for <abbr title="test driven development">TDD</abbr>, for example), run
49
+
50
+ ```bash
51
+ yarn run test:watch
52
+ ```
53
+
54
+ ## Linting with ESLint, Prettier, and Types
55
+ To scan the project for linting errors, run
56
+ ```bash
57
+ yarn run lint
58
+ ```
59
+
60
+ You can lint with ESLint and Prettier individually as well
61
+ ```bash
62
+ yarn run lint:eslint
63
+ ```
64
+ ```bash
65
+ yarn run lint:prettier
66
+ ```
67
+
68
+ To automatically fix many linting errors, run
69
+ ```bash
70
+ yarn run format
71
+ ```
72
+
73
+ You can format using ESLint and Prettier individually as well
74
+ ```bash
75
+ yarn run format:eslint
76
+ ```
77
+ ```bash
78
+ yarn run format:prettier
79
+ ```
80
+
81
+ ## Tooling configs
82
+
83
+ For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
84
+
85
+ If you customize the configuration a lot, you can consider moving them to individual files.
package/demo/app-root.ts CHANGED
@@ -1,93 +1,93 @@
1
- import { html, css, LitElement } from 'lit';
2
- import { customElement, state } from 'lit/decorators.js';
3
- import { RecaptchaWidget } from '../src/recaptcha-widget';
4
- import {
5
- RecaptchaManager,
6
- RecaptchaManagerInterface,
7
- } from '../src/recaptcha-manager';
8
-
9
- @customElement('app-root')
10
- export class AppRoot extends LitElement {
11
- @state() result?: string;
12
-
13
- @state() result2?: string;
14
-
15
- private recaptchaManager: RecaptchaManagerInterface = new RecaptchaManager({
16
- defaultSiteKey: '<your-site-key>',
17
- });
18
-
19
- private recaptcha1?: RecaptchaWidget;
20
-
21
- private recaptcha2?: RecaptchaWidget;
22
-
23
- render() {
24
- return html`
25
- <p>
26
- <button @click="${this.loadRecaptcha}">Load Recaptcha</button
27
- ><button @click="${this.executeRecaptcha}">Execute Recaptcha</button>
28
- </p>
29
- ${this.result
30
- ? html`<p><strong>Token:</strong></p>
31
- <p>${this.result}</p>`
32
- : ''}
33
- <p>
34
- <button @click="${this.loadRecaptcha2}">Load Another Recaptcha</button
35
- ><button @click="${this.executeRecaptcha2}">
36
- Execute Another Recaptcha
37
- </button>
38
- </p>
39
- ${this.result2
40
- ? html`<p><strong>Token 2:</strong></p>
41
- <p>${this.result2}</p>`
42
- : ''}
43
- `;
44
- }
45
-
46
- private async loadRecaptcha() {
47
- this.recaptcha1 = await this.recaptchaManager?.getRecaptchaWidget({
48
- recaptchaParams: {
49
- tabindex: 0,
50
- theme: 'light',
51
- type: 'image',
52
- },
53
- });
54
- }
55
-
56
- private async executeRecaptcha() {
57
- if (!this.recaptcha1) {
58
- await this.loadRecaptcha();
59
- }
60
-
61
- if (!this.recaptcha1) {
62
- console.error('error loading recaptcha');
63
- return;
64
- }
65
-
66
- this.result = await this.recaptcha1.execute();
67
- }
68
-
69
- private async loadRecaptcha2() {
70
- this.recaptcha2 = await this.recaptchaManager?.getRecaptchaWidget({
71
- siteKey: '<your-site-key>',
72
- });
73
- }
74
-
75
- private async executeRecaptcha2() {
76
- if (!this.recaptcha2) {
77
- await this.loadRecaptcha();
78
- }
79
-
80
- if (!this.recaptcha2) {
81
- console.error('error loading recaptcha');
82
- return;
83
- }
84
-
85
- this.result2 = await this.recaptcha2.execute();
86
- }
87
-
88
- static styles = css`
89
- :host {
90
- display: block;
91
- }
92
- `;
93
- }
1
+ import { html, css, LitElement } from 'lit';
2
+ import { customElement, state } from 'lit/decorators.js';
3
+ import { RecaptchaWidgetInterface } from '../src/recaptcha-widget';
4
+ import {
5
+ RecaptchaManager,
6
+ RecaptchaManagerInterface,
7
+ } from '../src/recaptcha-manager';
8
+
9
+ @customElement('app-root')
10
+ export class AppRoot extends LitElement {
11
+ @state() result?: string;
12
+
13
+ @state() result2?: string;
14
+
15
+ private recaptchaManager: RecaptchaManagerInterface = new RecaptchaManager({
16
+ defaultSiteKey: '<your-site-key>',
17
+ });
18
+
19
+ private recaptcha1?: RecaptchaWidgetInterface;
20
+
21
+ private recaptcha2?: RecaptchaWidgetInterface;
22
+
23
+ render() {
24
+ return html`
25
+ <p>
26
+ <button @click="${this.loadRecaptcha}">Load Recaptcha</button
27
+ ><button @click="${this.executeRecaptcha}">Execute Recaptcha</button>
28
+ </p>
29
+ ${this.result
30
+ ? html`<p><strong>Token:</strong></p>
31
+ <p>${this.result}</p>`
32
+ : ''}
33
+ <p>
34
+ <button @click="${this.loadRecaptcha2}">Load Another Recaptcha</button
35
+ ><button @click="${this.executeRecaptcha2}">
36
+ Execute Another Recaptcha
37
+ </button>
38
+ </p>
39
+ ${this.result2
40
+ ? html`<p><strong>Token 2:</strong></p>
41
+ <p>${this.result2}</p>`
42
+ : ''}
43
+ `;
44
+ }
45
+
46
+ private async loadRecaptcha() {
47
+ this.recaptcha1 = await this.recaptchaManager?.getRecaptchaWidget({
48
+ recaptchaParams: {
49
+ tabindex: 0,
50
+ theme: 'light',
51
+ type: 'image',
52
+ },
53
+ });
54
+ }
55
+
56
+ private async executeRecaptcha() {
57
+ if (!this.recaptcha1) {
58
+ await this.loadRecaptcha();
59
+ }
60
+
61
+ if (!this.recaptcha1) {
62
+ console.error('error loading recaptcha');
63
+ return;
64
+ }
65
+
66
+ this.result = await this.recaptcha1.execute();
67
+ }
68
+
69
+ private async loadRecaptcha2() {
70
+ this.recaptcha2 = await this.recaptchaManager?.getRecaptchaWidget({
71
+ siteKey: '<your-site-key>',
72
+ });
73
+ }
74
+
75
+ private async executeRecaptcha2() {
76
+ if (!this.recaptcha2) {
77
+ await this.loadRecaptcha();
78
+ }
79
+
80
+ if (!this.recaptcha2) {
81
+ console.error('error loading recaptcha');
82
+ return;
83
+ }
84
+
85
+ this.result2 = await this.recaptcha2.execute();
86
+ }
87
+
88
+ static styles = css`
89
+ :host {
90
+ display: block;
91
+ }
92
+ `;
93
+ }
package/demo/index.html CHANGED
@@ -1,21 +1,21 @@
1
- <!doctype html>
2
- <html lang="en-GB">
3
- <head>
4
- <meta charset="utf-8">
5
- <style>
6
- html {
7
- font-size: 10px; /* This is to match petabox's base font size */
8
- }
9
-
10
- body {
11
- background: #fafafa;
12
- }
13
- </style>
14
- </head>
15
- <body>
16
- <app-root></app-root>
17
-
18
- <script type="module" src="../dist/demo/app-root.js">
19
- </script>
20
- </body>
21
- </html>
1
+ <!doctype html>
2
+ <html lang="en-GB">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <style>
6
+ html {
7
+ font-size: 10px; /* This is to match petabox's base font size */
8
+ }
9
+
10
+ body {
11
+ background: #fafafa;
12
+ }
13
+ </style>
14
+ </head>
15
+ <body>
16
+ <app-root></app-root>
17
+
18
+ <script type="module" src="../dist/demo/app-root.js">
19
+ </script>
20
+ </body>
21
+ </html>
@@ -1,14 +1,14 @@
1
- import { LitElement } from 'lit';
2
- export declare class AppRoot extends LitElement {
3
- result?: string;
4
- result2?: string;
5
- private recaptchaManager;
6
- private recaptcha1?;
7
- private recaptcha2?;
8
- render(): import("lit").TemplateResult<1>;
9
- private loadRecaptcha;
10
- private executeRecaptcha;
11
- private loadRecaptcha2;
12
- private executeRecaptcha2;
13
- static styles: import("lit").CSSResult;
14
- }
1
+ import { LitElement } from 'lit';
2
+ export declare class AppRoot extends LitElement {
3
+ result?: string;
4
+ result2?: string;
5
+ private recaptchaManager;
6
+ private recaptcha1?;
7
+ private recaptcha2?;
8
+ render(): import("lit").TemplateResult<1>;
9
+ private loadRecaptcha;
10
+ private executeRecaptcha;
11
+ private loadRecaptcha2;
12
+ private executeRecaptcha2;
13
+ static styles: import("lit").CSSResult;
14
+ }
@@ -1,86 +1,86 @@
1
- import { __decorate } from "tslib";
2
- import { html, css, LitElement } from 'lit';
3
- import { customElement, state } from 'lit/decorators.js';
4
- import { RecaptchaManager, } from '../src/recaptcha-manager';
5
- let AppRoot = class AppRoot extends LitElement {
6
- constructor() {
7
- super(...arguments);
8
- this.recaptchaManager = new RecaptchaManager({
9
- defaultSiteKey: '<your-site-key>',
10
- });
11
- }
12
- render() {
13
- return html `
14
- <p>
15
- <button @click="${this.loadRecaptcha}">Load Recaptcha</button
16
- ><button @click="${this.executeRecaptcha}">Execute Recaptcha</button>
17
- </p>
18
- ${this.result
19
- ? html `<p><strong>Token:</strong></p>
20
- <p>${this.result}</p>`
21
- : ''}
22
- <p>
23
- <button @click="${this.loadRecaptcha2}">Load Another Recaptcha</button
24
- ><button @click="${this.executeRecaptcha2}">
25
- Execute Another Recaptcha
26
- </button>
27
- </p>
28
- ${this.result2
29
- ? html `<p><strong>Token 2:</strong></p>
30
- <p>${this.result2}</p>`
31
- : ''}
32
- `;
33
- }
34
- async loadRecaptcha() {
35
- var _a;
36
- this.recaptcha1 = await ((_a = this.recaptchaManager) === null || _a === void 0 ? void 0 : _a.getRecaptchaWidget({
37
- recaptchaParams: {
38
- tabindex: 0,
39
- theme: 'light',
40
- type: 'image',
41
- },
42
- }));
43
- }
44
- async executeRecaptcha() {
45
- if (!this.recaptcha1) {
46
- await this.loadRecaptcha();
47
- }
48
- if (!this.recaptcha1) {
49
- console.error('error loading recaptcha');
50
- return;
51
- }
52
- this.result = await this.recaptcha1.execute();
53
- }
54
- async loadRecaptcha2() {
55
- var _a;
56
- this.recaptcha2 = await ((_a = this.recaptchaManager) === null || _a === void 0 ? void 0 : _a.getRecaptchaWidget({
57
- siteKey: '<your-site-key>',
58
- }));
59
- }
60
- async executeRecaptcha2() {
61
- if (!this.recaptcha2) {
62
- await this.loadRecaptcha();
63
- }
64
- if (!this.recaptcha2) {
65
- console.error('error loading recaptcha');
66
- return;
67
- }
68
- this.result2 = await this.recaptcha2.execute();
69
- }
70
- };
71
- AppRoot.styles = css `
72
- :host {
73
- display: block;
74
- }
75
- `;
76
- __decorate([
77
- state()
78
- ], AppRoot.prototype, "result", void 0);
79
- __decorate([
80
- state()
81
- ], AppRoot.prototype, "result2", void 0);
82
- AppRoot = __decorate([
83
- customElement('app-root')
84
- ], AppRoot);
85
- export { AppRoot };
1
+ import { __decorate } from "tslib";
2
+ import { html, css, LitElement } from 'lit';
3
+ import { customElement, state } from 'lit/decorators.js';
4
+ import { RecaptchaManager, } from '../src/recaptcha-manager';
5
+ let AppRoot = class AppRoot extends LitElement {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.recaptchaManager = new RecaptchaManager({
9
+ defaultSiteKey: '<your-site-key>',
10
+ });
11
+ }
12
+ render() {
13
+ return html `
14
+ <p>
15
+ <button @click="${this.loadRecaptcha}">Load Recaptcha</button
16
+ ><button @click="${this.executeRecaptcha}">Execute Recaptcha</button>
17
+ </p>
18
+ ${this.result
19
+ ? html `<p><strong>Token:</strong></p>
20
+ <p>${this.result}</p>`
21
+ : ''}
22
+ <p>
23
+ <button @click="${this.loadRecaptcha2}">Load Another Recaptcha</button
24
+ ><button @click="${this.executeRecaptcha2}">
25
+ Execute Another Recaptcha
26
+ </button>
27
+ </p>
28
+ ${this.result2
29
+ ? html `<p><strong>Token 2:</strong></p>
30
+ <p>${this.result2}</p>`
31
+ : ''}
32
+ `;
33
+ }
34
+ async loadRecaptcha() {
35
+ var _a;
36
+ this.recaptcha1 = await ((_a = this.recaptchaManager) === null || _a === void 0 ? void 0 : _a.getRecaptchaWidget({
37
+ recaptchaParams: {
38
+ tabindex: 0,
39
+ theme: 'light',
40
+ type: 'image',
41
+ },
42
+ }));
43
+ }
44
+ async executeRecaptcha() {
45
+ if (!this.recaptcha1) {
46
+ await this.loadRecaptcha();
47
+ }
48
+ if (!this.recaptcha1) {
49
+ console.error('error loading recaptcha');
50
+ return;
51
+ }
52
+ this.result = await this.recaptcha1.execute();
53
+ }
54
+ async loadRecaptcha2() {
55
+ var _a;
56
+ this.recaptcha2 = await ((_a = this.recaptchaManager) === null || _a === void 0 ? void 0 : _a.getRecaptchaWidget({
57
+ siteKey: '<your-site-key>',
58
+ }));
59
+ }
60
+ async executeRecaptcha2() {
61
+ if (!this.recaptcha2) {
62
+ await this.loadRecaptcha();
63
+ }
64
+ if (!this.recaptcha2) {
65
+ console.error('error loading recaptcha');
66
+ return;
67
+ }
68
+ this.result2 = await this.recaptcha2.execute();
69
+ }
70
+ };
71
+ AppRoot.styles = css `
72
+ :host {
73
+ display: block;
74
+ }
75
+ `;
76
+ __decorate([
77
+ state()
78
+ ], AppRoot.prototype, "result", void 0);
79
+ __decorate([
80
+ state()
81
+ ], AppRoot.prototype, "result2", void 0);
82
+ AppRoot = __decorate([
83
+ customElement('app-root')
84
+ ], AppRoot);
85
+ export { AppRoot };
86
86
  //# sourceMappingURL=app-root.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"app-root.js","sourceRoot":"","sources":["../../demo/app-root.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EACL,gBAAgB,GAEjB,MAAM,0BAA0B,CAAC;AAGlC,IAAa,OAAO,GAApB,MAAa,OAAQ,SAAQ,UAAU;IAAvC;;QAKU,qBAAgB,GAA8B,IAAI,gBAAgB,CAAC;YACzE,cAAc,EAAE,iBAAiB;SAClC,CAAC,CAAC;IA4EL,CAAC;IAtEC,MAAM;QACJ,OAAO,IAAI,CAAA;;0BAEW,IAAI,CAAC,aAAa;2BACjB,IAAI,CAAC,gBAAgB;;QAExC,IAAI,CAAC,MAAM;YACX,CAAC,CAAC,IAAI,CAAA;iBACG,IAAI,CAAC,MAAM,MAAM;YAC1B,CAAC,CAAC,EAAE;;0BAEc,IAAI,CAAC,cAAc;2BAClB,IAAI,CAAC,iBAAiB;;;;QAIzC,IAAI,CAAC,OAAO;YACZ,CAAC,CAAC,IAAI,CAAA;iBACG,IAAI,CAAC,OAAO,MAAM;YAC3B,CAAC,CAAC,EAAE;KACP,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,aAAa;;QACzB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,kBAAkB,CAAC;YAChE,eAAe,EAAE;gBACf,QAAQ,EAAE,CAAC;gBACX,KAAK,EAAE,OAAO;gBACd,IAAI,EAAE,OAAO;aACd;SACF,CAAC,CAAA,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,gBAAgB;QAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;SAC5B;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;YACzC,OAAO;SACR;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IAChD,CAAC;IAEO,KAAK,CAAC,cAAc;;QAC1B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,kBAAkB,CAAC;YAChE,OAAO,EAAE,iBAAiB;SAC3B,CAAC,CAAA,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,iBAAiB;QAC7B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;SAC5B;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;YACzC,OAAO;SACR;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IACjD,CAAC;CAOF,CAAA;AALQ,cAAM,GAAG,GAAG,CAAA;;;;GAIlB,CAAC;AAjFO;IAAR,KAAK,EAAE;uCAAiB;AAEhB;IAAR,KAAK,EAAE;wCAAkB;AAHf,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAmFnB;SAnFY,OAAO","sourcesContent":["import { html, css, LitElement } from 'lit';\nimport { customElement, state } from 'lit/decorators.js';\nimport { RecaptchaWidget } from '../src/recaptcha-widget';\nimport {\n RecaptchaManager,\n RecaptchaManagerInterface,\n} from '../src/recaptcha-manager';\n\n@customElement('app-root')\nexport class AppRoot extends LitElement {\n @state() result?: string;\n\n @state() result2?: string;\n\n private recaptchaManager: RecaptchaManagerInterface = new RecaptchaManager({\n defaultSiteKey: '<your-site-key>',\n });\n\n private recaptcha1?: RecaptchaWidget;\n\n private recaptcha2?: RecaptchaWidget;\n\n render() {\n return html`\n <p>\n <button @click=\"${this.loadRecaptcha}\">Load Recaptcha</button\n ><button @click=\"${this.executeRecaptcha}\">Execute Recaptcha</button>\n </p>\n ${this.result\n ? html`<p><strong>Token:</strong></p>\n <p>${this.result}</p>`\n : ''}\n <p>\n <button @click=\"${this.loadRecaptcha2}\">Load Another Recaptcha</button\n ><button @click=\"${this.executeRecaptcha2}\">\n Execute Another Recaptcha\n </button>\n </p>\n ${this.result2\n ? html`<p><strong>Token 2:</strong></p>\n <p>${this.result2}</p>`\n : ''}\n `;\n }\n\n private async loadRecaptcha() {\n this.recaptcha1 = await this.recaptchaManager?.getRecaptchaWidget({\n recaptchaParams: {\n tabindex: 0,\n theme: 'light',\n type: 'image',\n },\n });\n }\n\n private async executeRecaptcha() {\n if (!this.recaptcha1) {\n await this.loadRecaptcha();\n }\n\n if (!this.recaptcha1) {\n console.error('error loading recaptcha');\n return;\n }\n\n this.result = await this.recaptcha1.execute();\n }\n\n private async loadRecaptcha2() {\n this.recaptcha2 = await this.recaptchaManager?.getRecaptchaWidget({\n siteKey: '<your-site-key>',\n });\n }\n\n private async executeRecaptcha2() {\n if (!this.recaptcha2) {\n await this.loadRecaptcha();\n }\n\n if (!this.recaptcha2) {\n console.error('error loading recaptcha');\n return;\n }\n\n this.result2 = await this.recaptcha2.execute();\n }\n\n static styles = css`\n :host {\n display: block;\n }\n `;\n}\n"]}
1
+ {"version":3,"file":"app-root.js","sourceRoot":"","sources":["../../demo/app-root.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,EACL,gBAAgB,GAEjB,MAAM,0BAA0B,CAAC;AAGlC,IAAa,OAAO,GAApB,MAAa,OAAQ,SAAQ,UAAU;IAAvC;;QAKU,qBAAgB,GAA8B,IAAI,gBAAgB,CAAC;YACzE,cAAc,EAAE,iBAAiB;SAClC,CAAC,CAAC;IA4EL,CAAC;IAtEC,MAAM;QACJ,OAAO,IAAI,CAAA;;0BAEW,IAAI,CAAC,aAAa;2BACjB,IAAI,CAAC,gBAAgB;;QAExC,IAAI,CAAC,MAAM;YACX,CAAC,CAAC,IAAI,CAAA;iBACG,IAAI,CAAC,MAAM,MAAM;YAC1B,CAAC,CAAC,EAAE;;0BAEc,IAAI,CAAC,cAAc;2BAClB,IAAI,CAAC,iBAAiB;;;;QAIzC,IAAI,CAAC,OAAO;YACZ,CAAC,CAAC,IAAI,CAAA;iBACG,IAAI,CAAC,OAAO,MAAM;YAC3B,CAAC,CAAC,EAAE;KACP,CAAC;IACJ,CAAC;IAEO,KAAK,CAAC,aAAa;;QACzB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,kBAAkB,CAAC;YAChE,eAAe,EAAE;gBACf,QAAQ,EAAE,CAAC;gBACX,KAAK,EAAE,OAAO;gBACd,IAAI,EAAE,OAAO;aACd;SACF,CAAC,CAAA,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,gBAAgB;QAC5B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;SAC5B;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;YACzC,OAAO;SACR;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IAChD,CAAC;IAEO,KAAK,CAAC,cAAc;;QAC1B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA,MAAA,IAAI,CAAC,gBAAgB,0CAAE,kBAAkB,CAAC;YAChE,OAAO,EAAE,iBAAiB;SAC3B,CAAC,CAAA,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,iBAAiB;QAC7B,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;SAC5B;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;YACzC,OAAO;SACR;QAED,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IACjD,CAAC;CAOF,CAAA;AALQ,cAAM,GAAG,GAAG,CAAA;;;;GAIlB,CAAC;AAjFO;IAAR,KAAK,EAAE;uCAAiB;AAEhB;IAAR,KAAK,EAAE;wCAAkB;AAHf,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CAmFnB;SAnFY,OAAO","sourcesContent":["import { html, css, LitElement } from 'lit';\r\nimport { customElement, state } from 'lit/decorators.js';\r\nimport { RecaptchaWidgetInterface } from '../src/recaptcha-widget';\r\nimport {\r\n RecaptchaManager,\r\n RecaptchaManagerInterface,\r\n} from '../src/recaptcha-manager';\r\n\r\n@customElement('app-root')\r\nexport class AppRoot extends LitElement {\r\n @state() result?: string;\r\n\r\n @state() result2?: string;\r\n\r\n private recaptchaManager: RecaptchaManagerInterface = new RecaptchaManager({\r\n defaultSiteKey: '<your-site-key>',\r\n });\r\n\r\n private recaptcha1?: RecaptchaWidgetInterface;\r\n\r\n private recaptcha2?: RecaptchaWidgetInterface;\r\n\r\n render() {\r\n return html`\r\n <p>\r\n <button @click=\"${this.loadRecaptcha}\">Load Recaptcha</button\r\n ><button @click=\"${this.executeRecaptcha}\">Execute Recaptcha</button>\r\n </p>\r\n ${this.result\r\n ? html`<p><strong>Token:</strong></p>\r\n <p>${this.result}</p>`\r\n : ''}\r\n <p>\r\n <button @click=\"${this.loadRecaptcha2}\">Load Another Recaptcha</button\r\n ><button @click=\"${this.executeRecaptcha2}\">\r\n Execute Another Recaptcha\r\n </button>\r\n </p>\r\n ${this.result2\r\n ? html`<p><strong>Token 2:</strong></p>\r\n <p>${this.result2}</p>`\r\n : ''}\r\n `;\r\n }\r\n\r\n private async loadRecaptcha() {\r\n this.recaptcha1 = await this.recaptchaManager?.getRecaptchaWidget({\r\n recaptchaParams: {\r\n tabindex: 0,\r\n theme: 'light',\r\n type: 'image',\r\n },\r\n });\r\n }\r\n\r\n private async executeRecaptcha() {\r\n if (!this.recaptcha1) {\r\n await this.loadRecaptcha();\r\n }\r\n\r\n if (!this.recaptcha1) {\r\n console.error('error loading recaptcha');\r\n return;\r\n }\r\n\r\n this.result = await this.recaptcha1.execute();\r\n }\r\n\r\n private async loadRecaptcha2() {\r\n this.recaptcha2 = await this.recaptchaManager?.getRecaptchaWidget({\r\n siteKey: '<your-site-key>',\r\n });\r\n }\r\n\r\n private async executeRecaptcha2() {\r\n if (!this.recaptcha2) {\r\n await this.loadRecaptcha();\r\n }\r\n\r\n if (!this.recaptcha2) {\r\n console.error('error loading recaptcha');\r\n return;\r\n }\r\n\r\n this.result2 = await this.recaptcha2.execute();\r\n }\r\n\r\n static styles = css`\r\n :host {\r\n display: block;\r\n }\r\n `;\r\n}\r\n"]}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { RecaptchaManager, RecaptchaManagerInterface, } from './src/recaptcha-manager';
2
- export { RecaptchaWidget, RecaptchaWidgetInterface, RecaptchaWidgetConfig, } from './src/recaptcha-widget';
1
+ export { RecaptchaManager, RecaptchaManagerInterface, } from './src/recaptcha-manager.js';
2
+ export { RecaptchaWidget, RecaptchaWidgetInterface, RecaptchaWidgetConfig, } from './src/recaptcha-widget.js';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { RecaptchaManager, } from './src/recaptcha-manager';
2
- export { RecaptchaWidget, } from './src/recaptcha-widget';
1
+ export { RecaptchaManager, } from './src/recaptcha-manager.js';
2
+ export { RecaptchaWidget, } from './src/recaptcha-widget.js';
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,eAAe,GAGhB,MAAM,wBAAwB,CAAC","sourcesContent":["export {\n RecaptchaManager,\n RecaptchaManagerInterface,\n} from './src/recaptcha-manager';\n\nexport {\n RecaptchaWidget,\n RecaptchaWidgetInterface,\n RecaptchaWidgetConfig,\n} from './src/recaptcha-widget';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAEjB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EACL,eAAe,GAGhB,MAAM,2BAA2B,CAAC","sourcesContent":["export {\r\n RecaptchaManager,\r\n RecaptchaManagerInterface,\r\n} from './src/recaptcha-manager.js';\r\n\r\nexport {\r\n RecaptchaWidget,\r\n RecaptchaWidgetInterface,\r\n RecaptchaWidgetConfig,\r\n} from './src/recaptcha-widget.js';\r\n"]}