Skip to content

Commit dabd1f8

Browse files
authored
Features/importmap (#409)
1 parent f705754 commit dabd1f8

31 files changed

+274
-118
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
* text=auto
22

33
/.github export-ignore
4+
/bin export-ignore
45
/tests export-ignore
56
/.editorconfig export-ignore
67
/.gitattributes export-ignore

.github/workflows/tweet.yml

-23
This file was deleted.

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: mu
22
mu: vendor ## Mutation tests
3-
vendor/bin/infection -s --threads=$$(nproc) --min-msi=30 --min-covered-msi=50
3+
vendor/bin/infection -v -s --threads=$$(nproc) --min-msi=45 --min-covered-msi=60
44

55
.PHONY: tests
66
tests: vendor ## Run all tests
@@ -36,7 +36,7 @@ st: vendor ## Run static analyse
3636

3737
.PHONY: ci-mu
3838
ci-mu: vendor ## Mutation tests (for CI/CD only)
39-
vendor/bin/infection --logger-github -s --threads=$$(nproc) --min-msi=30 --min-covered-msi=50
39+
vendor/bin/infection --logger-github -s --threads=$$(nproc) --min-msi=45 --min-covered-msi=60
4040

4141
.PHONY: ci-cc
4242
ci-cc: vendor ## Show test coverage rates (for CI/CD only)

babel.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
presets: [
33
['@babel/preset-env', {targets: {node: 'current'}}],
4-
['@babel/preset-typescript', {allowDeclareFields: true}],
4+
'@babel/react',
5+
['@babel/preset-typescript', { allowDeclareFields: true }]
56
],
67
};

bin/build_javascript.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* This file is used to compile the TypeScript files in the assets/src directory
3+
* of each package.
4+
*
5+
* It allows each package to spawn its own rollup process, which is necessary
6+
* to keep memory usage down.
7+
*/
8+
const { spawnSync } = require('child_process');
9+
const glob = require('glob');
10+
11+
const files = [
12+
...glob.sync('src/*/assets/src/*controller.ts'),
13+
];
14+
15+
files.forEach((file) => {
16+
const result = spawnSync('node', [
17+
'node_modules/.bin/rollup',
18+
'-c',
19+
'--environment',
20+
`INPUT_FILE:${file}`,
21+
], {
22+
stdio: 'inherit',
23+
shell: true
24+
});
25+
26+
if (result.error) {
27+
console.error(`Error compiling ${file}:`, result.error);
28+
}
29+
});

bin/build_styles.js

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Script to "build" the source CSS files to their final destination.
3+
*/
4+
5+
const glob = require('glob');
6+
const { exec } = require('child_process');
7+
const path = require('path');
8+
const fs = require('fs');
9+
10+
let pattern = 'src/*/assets/package.json';
11+
12+
// Use glob to find all matching package.json files
13+
glob(pattern, function (err, files) {
14+
if (err) {
15+
console.error('Error while finding package.json files:', err);
16+
process.exit(1);
17+
}
18+
19+
// Loop over all files
20+
files.forEach(file => {
21+
// Read the package.json file
22+
const pkg = JSON.parse(fs.readFileSync(file, 'utf-8'));
23+
24+
// Get the css source
25+
const cssSourceRelative = pkg.config && pkg.config.css_source;
26+
27+
if (!cssSourceRelative) {
28+
return;
29+
}
30+
// Construct the output path
31+
const cssSource = path.join(path.dirname(file), cssSourceRelative);
32+
const outputDir = path.join(path.dirname(file), 'dist');
33+
const outputFilename = path.basename(cssSource, '.css') + '.min.css';
34+
const output = path.join(outputDir, outputFilename);
35+
36+
// Run the clean-css-cli command
37+
exec(`yarn run cleancss -o ${output} ${cssSource}`, function (err) {
38+
if (err) {
39+
console.error(`Error while minifying ${cssSource}:`, err);
40+
return;
41+
}
42+
43+
console.log(`Minified ${cssSource} to ${output}`);
44+
});
45+
});
46+
});

composer.json

+9-2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"psr-4": {
2020
"Webauthn\\": "src/webauthn/src/",
2121
"Webauthn\\Bundle\\": "src/symfony/src/",
22+
"Webauthn\\Stimulus\\": "src/stimulus/src/",
2223
"Webauthn\\MetadataService\\": "src/metadata-service/src/"
2324
}
2425
},
@@ -87,7 +88,6 @@
8788
"web-token/jwt-signature-algorithm-eddsa": "Recommended for the AndroidSafetyNet Attestation Statement support"
8889
},
8990
"require-dev": {
90-
"doctrine/annotations": "^1.13 || ^2.0",
9191
"doctrine/dbal": "^3.4",
9292
"doctrine/doctrine-bundle": "^2.7",
9393
"doctrine/orm": "^2.13",
@@ -105,8 +105,9 @@
105105
"phpunit/phpunit": "^10.1",
106106
"psr/log": "^3.0",
107107
"qossmic/deptrac-shim": "^1.0",
108-
"rector/rector": "^0.16",
108+
"rector/rector": "^0.17",
109109
"roave/security-advisories": "dev-latest",
110+
"symfony/asset-mapper": "^6.3",
110111
"symfony/browser-kit": "^6.1",
111112
"symfony/filesystem": "^6.1",
112113
"symfony/finder": "^6.1",
@@ -119,5 +120,11 @@
119120
"web-token/jwt-signature-algorithm-ecdsa": "^3.1",
120121
"web-token/jwt-signature-algorithm-eddsa": "^3.1",
121122
"web-token/jwt-signature-algorithm-rsa": "^3.1"
123+
},
124+
"extra": {
125+
"thanks": {
126+
"name": "web-auth/webauthn-framework",
127+
"url": "https://github.com/web-auth/webauthn-framework"
128+
}
122129
}
123130
}

deptrac.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ parameters:
3333
ruleset:
3434
MetadataService:
3535
- 'Vendors'
36-
UX: ~
36+
UX:
37+
- 'Vendors'
3738
Webauthn:
3839
- 'Vendors'
3940
- 'MetadataService'
4041
SymfonyBundle:
4142
- 'Vendors'
4243
- 'Webauthn'
4344
- 'MetadataService'
45+
StimulusBundle:
4446
skip_violations:
4547
Webauthn\Bundle\Service\AuthenticatorAssertionResponseValidator:
4648
- Webauthn\Util\CoseSignatureFixer

jest.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ module.exports = {
1111
path.join(__dirname, 'tests/setup.js'),
1212
],
1313
transform: {
14-
'\\.(j|t)s$': ['babel-jest', {configFile: path.join(__dirname, './babel.config.js')}]
14+
'\\.(j|t)s$': ['babel-jest', { configFile: path.join(__dirname, './babel.config.js') }]
1515
},
1616
"transformIgnorePatterns": [
1717
"node_modules/(?!@ngrx|(?!deck.gl)|ng-dynamic)"
1818
]
19-
}
19+
};

package.json

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"private": true,
33
"workspaces": [
4-
"src/**/Resources/assets"
4+
"src/*/assets"
55
],
66
"scripts": {
7-
"build": "yarn rollup -c",
7+
"build": "node bin/build_javascript.js && node bin/build_styles.js",
88
"test": "yarn workspaces run jest",
99
"lint": "yarn workspaces run eslint src test",
10-
"format": "prettier src/*/Resources/assets/src/*.ts src/*/Resources/assets/test/*.js {,src/*/}*.{json,md} --write",
10+
"format": "prettier src/*/assets/src/*.ts src/*/assets/test/*.js {,src/*/}*.{json,md} --write",
1111
"check-lint": "yarn lint --no-fix",
1212
"check-format": "yarn format --no-write --check"
1313
},
@@ -16,21 +16,23 @@
1616
"@babel/preset-env": "^7.15.8",
1717
"@babel/preset-react": "^7.15.8",
1818
"@babel/preset-typescript": "^7.15.8",
19+
"@rollup/plugin-commonjs": "^25.0.0",
1920
"@rollup/plugin-node-resolve": "^15.0.0",
20-
"@rollup/plugin-typescript": "^10.0.0",
21+
"@rollup/plugin-typescript": "^11.0.0",
2122
"@symfony/stimulus-testing": "^2.0.1",
2223
"@typescript-eslint/eslint-plugin": "^5.2.0",
2324
"@typescript-eslint/parser": "^5.2.0",
2425
"babel-jest": "^29.0",
26+
"clean-css-cli": "^5.6.2",
2527
"eslint": "^8.1.0",
2628
"eslint-config-prettier": "^8.0.0",
27-
"eslint-plugin-jest": "^27.0",
28-
"jest": "^29.0",
29+
"eslint-plugin-jest": "^27.0.0",
30+
"jest": "^29.0.0",
2931
"jest-environment-jsdom": "^29.0",
3032
"prettier": "^2.2.1",
3133
"rollup": "^3.7.0",
3234
"tslib": "^2.3.1",
33-
"typescript": "^4.4.4"
35+
"typescript": "^5.0.0"
3436
},
3537
"eslintConfig": {
3638
"root": true,
@@ -59,7 +61,7 @@
5961
"overrides": [
6062
{
6163
"files": [
62-
"src/*/Resources/assets/test/**/*.ts"
64+
"src/*/assets/test/**/*.ts"
6365
],
6466
"extends": [
6567
"plugin:jest/recommended"

phpstan-baseline.neon

+20-10
Original file line numberDiff line numberDiff line change
@@ -588,16 +588,6 @@ parameters:
588588
count: 1
589589
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
590590

591-
-
592-
message: "#^Method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:createAuthenticator\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
593-
count: 1
594-
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
595-
596-
-
597-
message: "#^Method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:createListeners\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
598-
count: 1
599-
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
600-
601591
-
602592
message: "#^Method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:getAssertionOptionsBuilderId\\(\\) has parameter \\$config with no value type specified in iterable type array\\.$#"
603593
count: 1
@@ -643,6 +633,16 @@ parameters:
643633
count: 1
644634
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
645635

636+
-
637+
message: "#^Parameter \\#4 \\$successHandlerId of method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:createAuthenticatorService\\(\\) expects string, mixed given\\.$#"
638+
count: 1
639+
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
640+
641+
-
642+
message: "#^Parameter \\#5 \\$failureHandlerId of method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:createAuthenticatorService\\(\\) expects string, mixed given\\.$#"
643+
count: 1
644+
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
645+
646646
-
647647
message: "#^Parameter \\#5 \\$host of method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:createAssertionRequestControllerAndRoute\\(\\) expects string\\|null, mixed given\\.$#"
648648
count: 1
@@ -673,6 +673,11 @@ parameters:
673673
count: 1
674674
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
675675

676+
-
677+
message: "#^Parameter \\#7 \\$optionsStorageId of method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:createAuthenticatorService\\(\\) expects string, mixed given\\.$#"
678+
count: 1
679+
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
680+
676681
-
677682
message: "#^Parameter \\#8 \\$optionsHandlerId of method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:createAssertionRequestControllerAndRoute\\(\\) expects string, mixed given\\.$#"
678683
count: 1
@@ -683,6 +688,11 @@ parameters:
683688
count: 1
684689
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
685690

691+
-
692+
message: "#^Parameter \\#8 \\$securedRpIds of method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:createAuthenticatorService\\(\\) expects array\\<string\\>, mixed given\\.$#"
693+
count: 1
694+
path: src/symfony/src/DependencyInjection/Factory/Security/WebauthnFactory.php
695+
686696
-
687697
message: "#^Parameter \\#9 \\$failureHandlerId of method Webauthn\\\\Bundle\\\\DependencyInjection\\\\Factory\\\\Security\\\\WebauthnFactory\\:\\:createAssertionRequestControllerAndRoute\\(\\) expects string, mixed given\\.$#"
688698
count: 1

phpunit.xml.dist

+4-16
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,29 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
55
bootstrap="tests/bootstrap.php"
6+
colors="true"
67
>
78
<coverage/>
89
<testsuites>
910
<testsuite name="all">
1011
<directory>tests/</directory>
1112
</testsuite>
12-
<testsuite name="symfony">
13-
<directory>tests/symfony</directory>
14-
</testsuite>
15-
<testsuite name="mds">
16-
<directory>tests/MDS</directory>
17-
</testsuite>
18-
<testsuite name="framework">
19-
<directory>tests/framework</directory>
20-
</testsuite>
2113
</testsuites>
2214
<php>
2315
<ini name="display_errors" value="1"/>
2416
<ini name="error_reporting" value="-1"/>
2517
<server name="APP_ENV" value="test" force="true"/>
2618
<server name="SHELL_VERBOSITY" value="-1"/>
2719
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
28-
<server name="SYMFONY_PHPUNIT_VERSION" value="9"/>
29-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[total]=999999"/>
20+
<server name="SYMFONY_PHPUNIT_VERSION" value="10.1"/>
21+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
3022
<env name="APP_DEBUG" value="true"/>
3123
<server name="KERNEL_CLASS" value="Webauthn\Tests\Bundle\Functional\AppKernel"/>
3224
<ini name="memory_limit" value="-1"/>
3325
</php>
3426
<source>
3527
<include>
36-
<directory>src</directory>
28+
<directory>src/</directory>
3729
</include>
38-
<exclude>
39-
<file>./src/Kernel.php</file>
40-
<file>./src/Controller/SecurityController.php</file>
41-
</exclude>
4230
</source>
4331
</phpunit>

0 commit comments

Comments
 (0)