Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
a766032
chore: Add .idea to .gitignore
Jul 15, 2025
ca127a4
chore: rectorphp was implemented and the following adjustments
Jul 18, 2025
6c0326e
chore: remove .idea from .gitignore and clean up configuration files
Jul 18, 2025
28b7de2
chore: ractor config adjustement - skip SimplifyUselessVariableRector
Jul 18, 2025
3e9b132
Merge branch 'thenativeweb:main' into main
wundii Jul 19, 2025
1db4811
Merge branch 'thenativeweb:main' into main
wundii Jul 20, 2025
5b7d8fe
Merge branch 'thenativeweb:main' into main
wundii Jul 20, 2025
2553030
Merge branch 'thenativeweb:main' into main
wundii Jul 22, 2025
8b8739d
Merge branch 'thenativeweb:main' into main
wundii Jul 23, 2025
2e7c771
Merge branch 'thenativeweb:main' into main
wundii Jul 23, 2025
b636c85
Merge branch 'thenativeweb:main' into main
wundii Jul 23, 2025
5bfa6bd
refactor: update classes to final and readonly, enhance container sta…
Jul 23, 2025
3458d2e
Merge remote-tracking branch 'origin/main'
Jul 23, 2025
33580dd
docs: update README to include iterator_to_array usage examples for w…
Jul 25, 2025
3c4cd49
docs: update README to include iterator_to_array usage examples for w…
Jul 26, 2025
be405de
refactor: change writeEvents return type to array and update usage in…
Jul 26, 2025
2f015bb
Merge branch 'thenativeweb:main' into main
wundii Jul 27, 2025
2db57ec
Merge branch 'thenativeweb:main' into main
wundii Jul 27, 2025
7589e75
Merge branch 'thenativeweb:main' into main
wundii Jul 28, 2025
0ce4195
Merge branch 'thenativeweb:main' into main
wundii Jul 29, 2025
513a796
Merge branch 'thenativeweb:main' into main
wundii Jul 30, 2025
542ca4e
Merge branch 'thenativeweb:main' into main
wundii Aug 2, 2025
5dd2180
Merge branch 'thenativeweb:main' into main
wundii Sep 1, 2025
bbcefae
feat: Add support for signatures and verification
Sep 2, 2025
8d89604
chore: fix README example for verifySignature method
Sep 2, 2025
93f758a
Merge remote-tracking branch 'origin/main'
Sep 15, 2025
032ca1f
feat: Add support for signatures and verification
Sep 15, 2025
6be3145
chore: Remove symfony/http-client dependency and update php-http/disc…
Sep 15, 2025
a11695d
chore: Enhance signature handling and improve error messages
Sep 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,29 @@ To list a specific event type, call the `readEventType` function with the event
$eventType = $client->readEventType('io.eventsourcingdb.library.book-acquired');
```

### Verifying an Event's Hash

To verify the integrity of an event, call the `verifyHash` function on the event instance. This recomputes the event's hash locally and compares it to the hash stored in the event. If the hashes differ, the function returns an error:

```php
$event->verifyHash();
```

*Note that this only verifies the hash. If you also want to verify the signature, you can skip this step and call `verifySignature` directly, which performs a hash verification internally.*

### Verifying an Event's Signature

To verify the authenticity of an event, call the `verifySignature` function on the event instance. This requires the public key that matches the private key used for signing on the server.

The function first verifies the event's hash, and then checks the signature. If any verification step fails, it returns an error:

```php
$verificationKey = // an ed25519 public key

$event->verifySignature($verificationKey);
```


### Using Testcontainers

Import the `Container` class, call the `start` function to run a test container, get a client, run your test code, and finally call the `stop` function to stop the test container:
Expand Down Expand Up @@ -504,6 +527,22 @@ $container = new Container()
->withApiToken('secret');
```

If you want to sign events, call the `withSigningKey` function. This generates a new signing and verification key pair inside the container:

```php
$container = new Container()
->withSigningKey();
```

You can retrieve the private key (for signing) and the public key (for verifying signatures) once the container has been started:

```php
$signingKey = $container->getSigningKey();
$verificationKey = $container->getVerificationKey();
```

The `signingKey` can be used when configuring the container to sign outgoing events. The `verificationKey` can be passed to `verifySignature` when verifying events read from the database.

#### Configuring the Client Manually

In case you need to set up the client yourself, use the following functions to get details on the container:
Expand Down
13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@
"minimum-stability": "stable",
"require": {
"php": ">=8.2",
"ext-curl": "*"
"ext-curl": "*",
"ext-openssl": "*",
"ext-sodium": "*",
"testcontainers/testcontainers": "1.0.3"
},
"require-dev": {
"phpstan/phpstan": "2.1.25",
"phpunit/phpunit": "11.5.21",
"rector/rector": "2.1.7",
"symfony/http-client": "7.3.3",
"symplify/easy-coding-standard": "12.6.0",
"testcontainers/testcontainers": "1.0.3"
"symplify/easy-coding-standard": "12.6.0"
},
"scripts": {
"analyze": [
Expand All @@ -45,7 +46,7 @@
"vendor/bin/rector process",
"vendor/bin/ecs check --fix"
],
"stan": "vendor/bin/phpstan analyze",
"stan": "vendor/bin/phpstan analyze --memory-limit 512M",
"qa": [
"@analyze",
"@test"
Expand All @@ -57,7 +58,7 @@
},
"config": {
"allow-plugins": {
"php-http/discovery": true
"php-http/discovery": false
},
"sort-packages": true
}
Expand Down
Loading