You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-1Lines changed: 39 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -422,7 +422,29 @@ controller.abort();
422
422
To list a specific event type, call the `readEventType` function with the event type as an argument. The function returns the detailed event type, which includes the schema:
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:
431
+
432
+
```typescript
433
+
event.VerifyHash();
434
+
```
435
+
436
+
*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.*
437
+
438
+
### Verifying an Event's Signature
439
+
440
+
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.
441
+
442
+
The function first verifies the event's hash, and then checks the signature. If any verification step fails, it returns an error:
443
+
444
+
```typescript
445
+
const verificationKey =// an ed25519 public key
446
+
447
+
event.verifySignature(verificationKey);
426
448
```
427
449
428
450
### Using Testcontainers
@@ -465,6 +487,22 @@ const container = new Container()
465
487
.withApiToken('secret');
466
488
```
467
489
490
+
If you want to sign events, call the `withSigningKey` function. This generates a new signing and verification key pair inside the container:
491
+
492
+
```typescript
493
+
const container =newContainer()
494
+
.withSigningKey();
495
+
```
496
+
497
+
You can retrieve the private key (for signing) and the public key (for verifying signatures) once the container has been started:
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.
505
+
468
506
#### Configuring the Client Manually
469
507
470
508
In case you need to set up the client yourself, use the following functions to get details on the container:
0 commit comments