@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.
- package/.editorconfig +29 -29
- package/.github/workflows/ci.yml +26 -26
- package/.husky/pre-commit +4 -4
- package/LICENSE +661 -661
- package/README.md +85 -85
- package/demo/app-root.ts +93 -93
- package/demo/index.html +21 -21
- package/dist/demo/app-root.d.ts +14 -14
- package/dist/demo/app-root.js +85 -85
- package/dist/demo/app-root.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/src/recaptcha-manager.d.ts +35 -35
- package/dist/src/recaptcha-manager.js +52 -52
- package/dist/src/recaptcha-manager.js.map +1 -1
- package/dist/src/recaptcha-widget.d.ts +39 -39
- package/dist/src/recaptcha-widget.js +95 -95
- package/dist/src/recaptcha-widget.js.map +1 -1
- package/dist/test/mock-grecaptcha.d.ts +24 -24
- package/dist/test/mock-grecaptcha.js +61 -61
- package/dist/test/mock-grecaptcha.js.map +1 -1
- package/dist/test/mock-lazy-loader.d.ts +15 -15
- package/dist/test/mock-lazy-loader.js +16 -16
- package/dist/test/mock-lazy-loader.js.map +1 -1
- package/dist/test/recaptcha-manager.test.d.ts +1 -1
- package/dist/test/recaptcha-manager.test.js +137 -137
- package/dist/test/recaptcha-manager.test.js.map +1 -1
- package/index.ts +10 -10
- package/package.json +98 -97
- package/src/recaptcha-manager.ts +87 -87
- package/src/recaptcha-widget.ts +148 -148
- package/test/mock-grecaptcha.ts +87 -87
- package/test/mock-lazy-loader.ts +38 -38
- package/test/recaptcha-manager.test.ts +151 -151
- package/tsconfig.json +20 -20
- package/web-dev-server.config.mjs +28 -28
- package/web-test-runner.config.mjs +41 -41
- package/dist/src/recaptcha-manager copy.d.ts +0 -82
- package/dist/src/recaptcha-manager copy.js +0 -140
- package/dist/src/recaptcha-manager copy.js.map +0 -1
- package/dist/src/recaptcha-manager-bak.d.ts +0 -82
- package/dist/src/recaptcha-manager-bak.js +0 -140
- package/dist/src/recaptcha-manager-bak.js.map +0 -1
- package/dist/src/recaptcha.d.ts +0 -28
- package/dist/src/recaptcha.js +0 -87
- package/dist/src/recaptcha.js.map +0 -1
- package/dist/test/your-webcomponent.test.d.ts +0 -0
- package/dist/test/your-webcomponent.test.js +0 -4
- package/dist/test/your-webcomponent.test.js.map +0 -1
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
import { expect } from '@open-wc/testing';
|
|
2
|
-
import { MockGrecaptcha } from './mock-grecaptcha';
|
|
3
|
-
import { RecaptchaManager } from '../src/recaptcha-manager';
|
|
4
|
-
import { MockLazyLoaderService } from './mock-lazy-loader';
|
|
5
|
-
|
|
6
|
-
const mockLazyLoader = new MockLazyLoaderService();
|
|
7
|
-
|
|
8
|
-
describe('ReCaptcha Management', () => {
|
|
9
|
-
describe('ReCaptcha Manager', () => {
|
|
10
|
-
it('can return recaptchas', async () => {
|
|
11
|
-
const mockGrecaptcha = new MockGrecaptcha({
|
|
12
|
-
mode: 'success',
|
|
13
|
-
});
|
|
14
|
-
mockGrecaptcha.response = 'foo';
|
|
15
|
-
const recaptchaManager = new RecaptchaManager({
|
|
16
|
-
lazyLoader: mockLazyLoader,
|
|
17
|
-
grecaptchaLibrary: mockGrecaptcha,
|
|
18
|
-
defaultSiteKey: '123',
|
|
19
|
-
});
|
|
20
|
-
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
21
|
-
const result = await recaptcha.execute();
|
|
22
|
-
expect(result).to.equal('foo');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('throws an error if no site key found', async () => {
|
|
26
|
-
const mockGrecaptcha = new MockGrecaptcha({
|
|
27
|
-
mode: 'success',
|
|
28
|
-
});
|
|
29
|
-
mockGrecaptcha.response = 'foo';
|
|
30
|
-
const recaptchaManager = new RecaptchaManager({
|
|
31
|
-
lazyLoader: mockLazyLoader,
|
|
32
|
-
grecaptchaLibrary: mockGrecaptcha,
|
|
33
|
-
});
|
|
34
|
-
try {
|
|
35
|
-
await recaptchaManager.getRecaptchaWidget();
|
|
36
|
-
expect.fail('should not get here');
|
|
37
|
-
} catch (e) {
|
|
38
|
-
expect((e as Error).message).to.equal(
|
|
39
|
-
'The reCaptcha widget requires a site key'
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('returns a cached version if one already exists for a given site key', async () => {
|
|
45
|
-
const mockGrecaptcha = new MockGrecaptcha({
|
|
46
|
-
mode: 'success',
|
|
47
|
-
});
|
|
48
|
-
mockGrecaptcha.response = 'foo';
|
|
49
|
-
const recaptchaManager = new RecaptchaManager({
|
|
50
|
-
lazyLoader: mockLazyLoader,
|
|
51
|
-
grecaptchaLibrary: mockGrecaptcha,
|
|
52
|
-
defaultSiteKey: '123',
|
|
53
|
-
});
|
|
54
|
-
const recaptcha1 = await recaptchaManager.getRecaptchaWidget();
|
|
55
|
-
const recaptcha2 = await recaptchaManager.getRecaptchaWidget();
|
|
56
|
-
expect(recaptcha1).to.equal(recaptcha2);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('loads the recaptcha library if needed', async () => {
|
|
60
|
-
const recaptchaManager = new RecaptchaManager({
|
|
61
|
-
lazyLoader: mockLazyLoader,
|
|
62
|
-
defaultSiteKey: '123',
|
|
63
|
-
});
|
|
64
|
-
await recaptchaManager.getRecaptchaWidget();
|
|
65
|
-
const loadUrl = mockLazyLoader.loadScriptSrc;
|
|
66
|
-
expect(
|
|
67
|
-
loadUrl?.includes('recaptcha/api.js?onload=grecaptchaLoadedCallback')
|
|
68
|
-
).to.be.true;
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('ReCaptcha Widget', () => {
|
|
73
|
-
it('can error properly like a Promise', async () => {
|
|
74
|
-
const mockGrecaptcha = new MockGrecaptcha({
|
|
75
|
-
mode: 'error',
|
|
76
|
-
});
|
|
77
|
-
const recaptchaManager = new RecaptchaManager({
|
|
78
|
-
lazyLoader: mockLazyLoader,
|
|
79
|
-
grecaptchaLibrary: mockGrecaptcha,
|
|
80
|
-
defaultSiteKey: '123',
|
|
81
|
-
});
|
|
82
|
-
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
83
|
-
|
|
84
|
-
try {
|
|
85
|
-
await recaptcha.execute();
|
|
86
|
-
expect.fail('should not get here');
|
|
87
|
-
} catch (error) {
|
|
88
|
-
expect((error as Error).message).to.equal('error');
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('can expire properly like a Promise', async () => {
|
|
93
|
-
const mockGrecaptcha = new MockGrecaptcha({
|
|
94
|
-
mode: 'expired',
|
|
95
|
-
});
|
|
96
|
-
const recaptchaManager = new RecaptchaManager({
|
|
97
|
-
lazyLoader: mockLazyLoader,
|
|
98
|
-
grecaptchaLibrary: mockGrecaptcha,
|
|
99
|
-
defaultSiteKey: '123',
|
|
100
|
-
});
|
|
101
|
-
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
await recaptcha.execute();
|
|
105
|
-
expect.fail('should not get here');
|
|
106
|
-
} catch (error) {
|
|
107
|
-
expect((error as Error).message).to.equal('expired');
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('resets the captcha after execution', async () => {
|
|
112
|
-
const mockGrecaptcha = new MockGrecaptcha({
|
|
113
|
-
mode: 'success',
|
|
114
|
-
addDelay: true,
|
|
115
|
-
});
|
|
116
|
-
const recaptchaManager = new RecaptchaManager({
|
|
117
|
-
lazyLoader: mockLazyLoader,
|
|
118
|
-
grecaptchaLibrary: mockGrecaptcha,
|
|
119
|
-
defaultSiteKey: '123',
|
|
120
|
-
});
|
|
121
|
-
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
122
|
-
|
|
123
|
-
expect(mockGrecaptcha.resetCallCount).to.equal(0);
|
|
124
|
-
await recaptcha.execute();
|
|
125
|
-
expect(mockGrecaptcha.resetCallCount).to.equal(1);
|
|
126
|
-
await recaptcha.execute();
|
|
127
|
-
expect(mockGrecaptcha.resetCallCount).to.equal(2);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// there's no way to know if the user has dismissed the captcha so if another execution
|
|
131
|
-
// comes through while the captcha is still active, it will be reset
|
|
132
|
-
it('resets the captcha if another execution gets called', async () => {
|
|
133
|
-
const mockGrecaptcha = new MockGrecaptcha({
|
|
134
|
-
mode: 'success',
|
|
135
|
-
addDelay: true,
|
|
136
|
-
});
|
|
137
|
-
const recaptchaManager = new RecaptchaManager({
|
|
138
|
-
lazyLoader: mockLazyLoader,
|
|
139
|
-
grecaptchaLibrary: mockGrecaptcha,
|
|
140
|
-
defaultSiteKey: '123',
|
|
141
|
-
});
|
|
142
|
-
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
143
|
-
|
|
144
|
-
expect(mockGrecaptcha.resetCallCount).to.equal(0);
|
|
145
|
-
recaptcha.execute();
|
|
146
|
-
expect(mockGrecaptcha.resetCallCount).to.equal(0);
|
|
147
|
-
await recaptcha.execute();
|
|
148
|
-
expect(mockGrecaptcha.resetCallCount).to.equal(2);
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
});
|
|
1
|
+
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { MockGrecaptcha } from './mock-grecaptcha';
|
|
3
|
+
import { RecaptchaManager } from '../src/recaptcha-manager';
|
|
4
|
+
import { MockLazyLoaderService } from './mock-lazy-loader';
|
|
5
|
+
|
|
6
|
+
const mockLazyLoader = new MockLazyLoaderService();
|
|
7
|
+
|
|
8
|
+
describe('ReCaptcha Management', () => {
|
|
9
|
+
describe('ReCaptcha Manager', () => {
|
|
10
|
+
it('can return recaptchas', async () => {
|
|
11
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
12
|
+
mode: 'success',
|
|
13
|
+
});
|
|
14
|
+
mockGrecaptcha.response = 'foo';
|
|
15
|
+
const recaptchaManager = new RecaptchaManager({
|
|
16
|
+
lazyLoader: mockLazyLoader,
|
|
17
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
18
|
+
defaultSiteKey: '123',
|
|
19
|
+
});
|
|
20
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
21
|
+
const result = await recaptcha.execute();
|
|
22
|
+
expect(result).to.equal('foo');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('throws an error if no site key found', async () => {
|
|
26
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
27
|
+
mode: 'success',
|
|
28
|
+
});
|
|
29
|
+
mockGrecaptcha.response = 'foo';
|
|
30
|
+
const recaptchaManager = new RecaptchaManager({
|
|
31
|
+
lazyLoader: mockLazyLoader,
|
|
32
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
33
|
+
});
|
|
34
|
+
try {
|
|
35
|
+
await recaptchaManager.getRecaptchaWidget();
|
|
36
|
+
expect.fail('should not get here');
|
|
37
|
+
} catch (e) {
|
|
38
|
+
expect((e as Error).message).to.equal(
|
|
39
|
+
'The reCaptcha widget requires a site key'
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('returns a cached version if one already exists for a given site key', async () => {
|
|
45
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
46
|
+
mode: 'success',
|
|
47
|
+
});
|
|
48
|
+
mockGrecaptcha.response = 'foo';
|
|
49
|
+
const recaptchaManager = new RecaptchaManager({
|
|
50
|
+
lazyLoader: mockLazyLoader,
|
|
51
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
52
|
+
defaultSiteKey: '123',
|
|
53
|
+
});
|
|
54
|
+
const recaptcha1 = await recaptchaManager.getRecaptchaWidget();
|
|
55
|
+
const recaptcha2 = await recaptchaManager.getRecaptchaWidget();
|
|
56
|
+
expect(recaptcha1).to.equal(recaptcha2);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('loads the recaptcha library if needed', async () => {
|
|
60
|
+
const recaptchaManager = new RecaptchaManager({
|
|
61
|
+
lazyLoader: mockLazyLoader,
|
|
62
|
+
defaultSiteKey: '123',
|
|
63
|
+
});
|
|
64
|
+
await recaptchaManager.getRecaptchaWidget();
|
|
65
|
+
const loadUrl = mockLazyLoader.loadScriptSrc;
|
|
66
|
+
expect(
|
|
67
|
+
loadUrl?.includes('recaptcha/api.js?onload=grecaptchaLoadedCallback')
|
|
68
|
+
).to.be.true;
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('ReCaptcha Widget', () => {
|
|
73
|
+
it('can error properly like a Promise', async () => {
|
|
74
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
75
|
+
mode: 'error',
|
|
76
|
+
});
|
|
77
|
+
const recaptchaManager = new RecaptchaManager({
|
|
78
|
+
lazyLoader: mockLazyLoader,
|
|
79
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
80
|
+
defaultSiteKey: '123',
|
|
81
|
+
});
|
|
82
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
await recaptcha.execute();
|
|
86
|
+
expect.fail('should not get here');
|
|
87
|
+
} catch (error) {
|
|
88
|
+
expect((error as Error).message).to.equal('error');
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('can expire properly like a Promise', async () => {
|
|
93
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
94
|
+
mode: 'expired',
|
|
95
|
+
});
|
|
96
|
+
const recaptchaManager = new RecaptchaManager({
|
|
97
|
+
lazyLoader: mockLazyLoader,
|
|
98
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
99
|
+
defaultSiteKey: '123',
|
|
100
|
+
});
|
|
101
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
await recaptcha.execute();
|
|
105
|
+
expect.fail('should not get here');
|
|
106
|
+
} catch (error) {
|
|
107
|
+
expect((error as Error).message).to.equal('expired');
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('resets the captcha after execution', async () => {
|
|
112
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
113
|
+
mode: 'success',
|
|
114
|
+
addDelay: true,
|
|
115
|
+
});
|
|
116
|
+
const recaptchaManager = new RecaptchaManager({
|
|
117
|
+
lazyLoader: mockLazyLoader,
|
|
118
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
119
|
+
defaultSiteKey: '123',
|
|
120
|
+
});
|
|
121
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
122
|
+
|
|
123
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(0);
|
|
124
|
+
await recaptcha.execute();
|
|
125
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(1);
|
|
126
|
+
await recaptcha.execute();
|
|
127
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(2);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// there's no way to know if the user has dismissed the captcha so if another execution
|
|
131
|
+
// comes through while the captcha is still active, it will be reset
|
|
132
|
+
it('resets the captcha if another execution gets called', async () => {
|
|
133
|
+
const mockGrecaptcha = new MockGrecaptcha({
|
|
134
|
+
mode: 'success',
|
|
135
|
+
addDelay: true,
|
|
136
|
+
});
|
|
137
|
+
const recaptchaManager = new RecaptchaManager({
|
|
138
|
+
lazyLoader: mockLazyLoader,
|
|
139
|
+
grecaptchaLibrary: mockGrecaptcha,
|
|
140
|
+
defaultSiteKey: '123',
|
|
141
|
+
});
|
|
142
|
+
const recaptcha = await recaptchaManager.getRecaptchaWidget();
|
|
143
|
+
|
|
144
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(0);
|
|
145
|
+
recaptcha.execute();
|
|
146
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(0);
|
|
147
|
+
await recaptcha.execute();
|
|
148
|
+
expect(mockGrecaptcha.resetCallCount).to.equal(2);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
});
|
package/tsconfig.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "es2018",
|
|
4
|
-
"module": "esnext",
|
|
5
|
-
"moduleResolution": "node",
|
|
6
|
-
"noEmitOnError": true,
|
|
7
|
-
"lib": ["es2017", "dom"],
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": false,
|
|
10
|
-
"allowSyntheticDefaultImports": true,
|
|
11
|
-
"experimentalDecorators": true,
|
|
12
|
-
"importHelpers": true,
|
|
13
|
-
"outDir": "dist",
|
|
14
|
-
"sourceMap": true,
|
|
15
|
-
"inlineSources": true,
|
|
16
|
-
"rootDir": "./",
|
|
17
|
-
"declaration": true,
|
|
18
|
-
},
|
|
19
|
-
"include": ["**/*.ts"]
|
|
20
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"noEmitOnError": true,
|
|
7
|
+
"lib": ["es2017", "dom"],
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": false,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"experimentalDecorators": true,
|
|
12
|
+
"importHelpers": true,
|
|
13
|
+
"outDir": "dist",
|
|
14
|
+
"sourceMap": true,
|
|
15
|
+
"inlineSources": true,
|
|
16
|
+
"rootDir": "./",
|
|
17
|
+
"declaration": true,
|
|
18
|
+
},
|
|
19
|
+
"include": ["**/*.ts"]
|
|
20
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
|
|
2
|
-
|
|
3
|
-
/** Use Hot Module replacement by adding --hmr to the start command */
|
|
4
|
-
const hmr = process.argv.includes('--hmr');
|
|
5
|
-
|
|
6
|
-
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
7
|
-
nodeResolve: true,
|
|
8
|
-
open: '/demo/',
|
|
9
|
-
watch: !hmr,
|
|
10
|
-
|
|
11
|
-
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
12
|
-
// esbuildTarget: 'auto'
|
|
13
|
-
|
|
14
|
-
/** Set appIndex to enable SPA routing */
|
|
15
|
-
// appIndex: 'demo/index.html',
|
|
16
|
-
|
|
17
|
-
/** Confgure bare import resolve plugin */
|
|
18
|
-
// nodeResolve: {
|
|
19
|
-
// exportConditions: ['browser', 'development']
|
|
20
|
-
// },
|
|
21
|
-
|
|
22
|
-
plugins: [
|
|
23
|
-
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
24
|
-
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
25
|
-
],
|
|
26
|
-
|
|
27
|
-
// See documentation for all available options
|
|
28
|
-
});
|
|
1
|
+
// import { hmrPlugin, presets } from '@open-wc/dev-server-hmr';
|
|
2
|
+
|
|
3
|
+
/** Use Hot Module replacement by adding --hmr to the start command */
|
|
4
|
+
const hmr = process.argv.includes('--hmr');
|
|
5
|
+
|
|
6
|
+
export default /** @type {import('@web/dev-server').DevServerConfig} */ ({
|
|
7
|
+
nodeResolve: true,
|
|
8
|
+
open: '/demo/',
|
|
9
|
+
watch: !hmr,
|
|
10
|
+
|
|
11
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
12
|
+
// esbuildTarget: 'auto'
|
|
13
|
+
|
|
14
|
+
/** Set appIndex to enable SPA routing */
|
|
15
|
+
// appIndex: 'demo/index.html',
|
|
16
|
+
|
|
17
|
+
/** Confgure bare import resolve plugin */
|
|
18
|
+
// nodeResolve: {
|
|
19
|
+
// exportConditions: ['browser', 'development']
|
|
20
|
+
// },
|
|
21
|
+
|
|
22
|
+
plugins: [
|
|
23
|
+
/** Use Hot Module Replacement by uncommenting. Requires @open-wc/dev-server-hmr plugin */
|
|
24
|
+
// hmr && hmrPlugin({ exclude: ['**/*/node_modules/**/*'], presets: [presets.litElement] }),
|
|
25
|
+
],
|
|
26
|
+
|
|
27
|
+
// See documentation for all available options
|
|
28
|
+
});
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
// import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
2
|
-
|
|
3
|
-
const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
|
|
4
|
-
|
|
5
|
-
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
6
|
-
/** Test files to run */
|
|
7
|
-
files: 'dist/test/**/*.test.js',
|
|
8
|
-
|
|
9
|
-
/** Resolve bare module imports */
|
|
10
|
-
nodeResolve: {
|
|
11
|
-
exportConditions: ['browser', 'development'],
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
/** Filter out lit dev mode logs */
|
|
15
|
-
filterBrowserLogs(log) {
|
|
16
|
-
for (const arg of log.args) {
|
|
17
|
-
if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
25
|
-
// esbuildTarget: 'auto',
|
|
26
|
-
|
|
27
|
-
/** Amount of browsers to run concurrently */
|
|
28
|
-
// concurrentBrowsers: 2,
|
|
29
|
-
|
|
30
|
-
/** Amount of test files per browser to test concurrently */
|
|
31
|
-
// concurrency: 1,
|
|
32
|
-
|
|
33
|
-
/** Browsers to run tests on */
|
|
34
|
-
// browsers: [
|
|
35
|
-
// playwrightLauncher({ product: 'chromium' }),
|
|
36
|
-
// playwrightLauncher({ product: 'firefox' }),
|
|
37
|
-
// playwrightLauncher({ product: 'webkit' }),
|
|
38
|
-
// ],
|
|
39
|
-
|
|
40
|
-
// See documentation for all available options
|
|
41
|
-
});
|
|
1
|
+
// import { playwrightLauncher } from '@web/test-runner-playwright';
|
|
2
|
+
|
|
3
|
+
const filteredLogs = ['Running in dev mode', 'lit-html is in dev mode'];
|
|
4
|
+
|
|
5
|
+
export default /** @type {import("@web/test-runner").TestRunnerConfig} */ ({
|
|
6
|
+
/** Test files to run */
|
|
7
|
+
files: 'dist/test/**/*.test.js',
|
|
8
|
+
|
|
9
|
+
/** Resolve bare module imports */
|
|
10
|
+
nodeResolve: {
|
|
11
|
+
exportConditions: ['browser', 'development'],
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
/** Filter out lit dev mode logs */
|
|
15
|
+
filterBrowserLogs(log) {
|
|
16
|
+
for (const arg of log.args) {
|
|
17
|
+
if (typeof arg === 'string' && filteredLogs.some(l => arg.includes(l))) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return true;
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
/** Compile JS for older browsers. Requires @web/dev-server-esbuild plugin */
|
|
25
|
+
// esbuildTarget: 'auto',
|
|
26
|
+
|
|
27
|
+
/** Amount of browsers to run concurrently */
|
|
28
|
+
// concurrentBrowsers: 2,
|
|
29
|
+
|
|
30
|
+
/** Amount of test files per browser to test concurrently */
|
|
31
|
+
// concurrency: 1,
|
|
32
|
+
|
|
33
|
+
/** Browsers to run tests on */
|
|
34
|
+
// browsers: [
|
|
35
|
+
// playwrightLauncher({ product: 'chromium' }),
|
|
36
|
+
// playwrightLauncher({ product: 'firefox' }),
|
|
37
|
+
// playwrightLauncher({ product: 'webkit' }),
|
|
38
|
+
// ],
|
|
39
|
+
|
|
40
|
+
// See documentation for all available options
|
|
41
|
+
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/// <reference types="grecaptcha" />
|
|
2
|
-
import { LazyLoaderServiceInterface } from '@internetarchive/lazy-loader-service';
|
|
3
|
-
export interface RecaptchaManagerInterface {
|
|
4
|
-
/**
|
|
5
|
-
* Executes the recaptcha and returns a token
|
|
6
|
-
*
|
|
7
|
-
* Example:
|
|
8
|
-
*
|
|
9
|
-
* try {
|
|
10
|
-
* const recaptchaResult = await recaptchaManager.execute();
|
|
11
|
-
* console.log('recaptcha token:', recaptchaResult);
|
|
12
|
-
* } catch {
|
|
13
|
-
* console.error('something happened')
|
|
14
|
-
* }
|
|
15
|
-
*/
|
|
16
|
-
execute(): Promise<string>;
|
|
17
|
-
/**
|
|
18
|
-
* Create the recaptcha widget.
|
|
19
|
-
*
|
|
20
|
-
* If the `container` is not passed in, one will be created.
|
|
21
|
-
*
|
|
22
|
-
* @param options
|
|
23
|
-
*/
|
|
24
|
-
setup(options?: {
|
|
25
|
-
container?: HTMLElement;
|
|
26
|
-
tabIndex?: number;
|
|
27
|
-
theme?: ReCaptchaV2.Theme;
|
|
28
|
-
type?: ReCaptchaV2.Type;
|
|
29
|
-
size?: ReCaptchaV2.Size;
|
|
30
|
-
}): void;
|
|
31
|
-
}
|
|
32
|
-
export declare class RecaptchaManager implements RecaptchaManagerInterface {
|
|
33
|
-
/**
|
|
34
|
-
* This is a convenience initializer that also lazily loads
|
|
35
|
-
* the recaptcha library from Google.
|
|
36
|
-
*
|
|
37
|
-
* @param options
|
|
38
|
-
* @returns
|
|
39
|
-
*/
|
|
40
|
-
static getRecaptchaManager(siteKey: string, options?: {
|
|
41
|
-
lazyLoader?: LazyLoaderServiceInterface;
|
|
42
|
-
tabIndex?: number;
|
|
43
|
-
theme?: ReCaptchaV2.Theme;
|
|
44
|
-
type?: ReCaptchaV2.Type;
|
|
45
|
-
size?: ReCaptchaV2.Size;
|
|
46
|
-
}): Promise<RecaptchaManagerInterface>;
|
|
47
|
-
/**
|
|
48
|
-
* Load the Recaptch library from Google.
|
|
49
|
-
*
|
|
50
|
-
* @param options
|
|
51
|
-
* @returns
|
|
52
|
-
*/
|
|
53
|
-
static loadRecaptchaLibrary(options?: {
|
|
54
|
-
lazyLoader?: LazyLoaderServiceInterface;
|
|
55
|
-
}): Promise<ReCaptchaV2.ReCaptcha>;
|
|
56
|
-
private grecaptchaLibrary;
|
|
57
|
-
private siteKey;
|
|
58
|
-
constructor(options: {
|
|
59
|
-
grecaptchaLibrary: ReCaptchaV2.ReCaptcha;
|
|
60
|
-
siteKey: string;
|
|
61
|
-
});
|
|
62
|
-
private executionSuccessBlock?;
|
|
63
|
-
private executionExpiredBlock?;
|
|
64
|
-
private executionErrorBlock?;
|
|
65
|
-
private isExecuting;
|
|
66
|
-
private containerElement;
|
|
67
|
-
/** @inheritdoc */
|
|
68
|
-
execute(): Promise<string>;
|
|
69
|
-
/** @inheritdoc */
|
|
70
|
-
setup(options?: {
|
|
71
|
-
container?: HTMLElement;
|
|
72
|
-
tabIndex?: number;
|
|
73
|
-
theme?: ReCaptchaV2.Theme;
|
|
74
|
-
type?: ReCaptchaV2.Type;
|
|
75
|
-
size?: ReCaptchaV2.Size;
|
|
76
|
-
}): void;
|
|
77
|
-
private createContainer;
|
|
78
|
-
private finishExecution;
|
|
79
|
-
private responseHandler;
|
|
80
|
-
private expiredHandler;
|
|
81
|
-
private errorHandler;
|
|
82
|
-
}
|