Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Fix empty payload serialization.

### Deprecated

* Deprecate `Config::$version`, will be removed in `0.5.0`.

## [0.3.0] 2025-10-23

### Added
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"amphp/socket": "^2.3.1",
"cuyz/valinor": "^1.15 || ^2.3",
"revolt/event-loop": "^1.0.7",
"thesis/package-version": "^0.1.2",
"thesis/time-span": "^0.2.3"
},
"require-dev": {
Expand Down
7 changes: 5 additions & 2 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
private const int DEFAULT_MAX_PINGS = 5;
private const string DEFAULT_CLIENT_NAME = 'thesis/nats';

/** @var non-empty-string */
/**
* @var non-empty-string
* @deprecated will be removed in 0.5.0
*/
public string $version;

/**
Expand Down Expand Up @@ -52,7 +55,7 @@ public function __construct(
public ?string $jetStreamDomain = null,
public string $clientName = self::DEFAULT_CLIENT_NAME,
) {
$this->version = '0.1.x'; // TODO: replace with actual version.
$this->version = '0.1.x';
}

public static function default(): self
Expand Down
5 changes: 4 additions & 1 deletion src/Internal/Connection/SocketConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@
use Thesis\Nats\Internal\Hooks;
use Thesis\Nats\Internal\Nkey\Signer;
use Thesis\Nats\Internal\Protocol;
use function Thesis\Package\version;

/**
* @internal
*/
final class SocketConnection implements Connection
{
private const string PACKAGE_NAME = 'thesis/nats';

private readonly Framer $framer;

/** @var \SplQueue<DeferredFuture<Protocol\Frame>> */
Expand Down Expand Up @@ -71,7 +74,7 @@ public function startup(): void
pedantic: $this->config->pedantic,
tlsRequired: false,
name: $this->config->clientName,
version: $this->config->version,
version: version(self::PACKAGE_NAME),
user: $this->config->user,
pass: $this->config->password,
sig: $this->generateSignature($frame->nonce, $this->config->nkey),
Expand Down
13 changes: 7 additions & 6 deletions tests/Internal/Connection/SocketConnectionJwtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Thesis\Nats\Config;
use Thesis\Nats\Internal\Nkey\Signer;
use Thesis\Nats\Internal\Protocol\Connect;
use function Thesis\Package\version;

#[CoversClass(Connect::class)]
#[CoversClass(Signer::class)]
Expand All @@ -26,7 +27,7 @@ public function testConnectProtocolCreationWithJwtOnly(): void
pedantic: $config->pedantic,
tlsRequired: false,
name: 'thesis/nats',
version: $config->version,
version: version('thesis/nats'),
user: $config->user,
pass: $config->password,
sig: null,
Expand Down Expand Up @@ -59,7 +60,7 @@ public function testConnectProtocolCreationWithNkeyOnly(): void
pedantic: $config->pedantic,
tlsRequired: false,
name: 'thesis/nats',
version: $config->version,
version: version('thesis/nats'),
user: $config->user,
pass: $config->password,
sig: $signature,
Expand Down Expand Up @@ -94,7 +95,7 @@ public function testConnectProtocolCreationWithBothJwtAndNkey(): void
pedantic: $config->pedantic,
tlsRequired: false,
name: 'thesis/nats',
version: $config->version,
version: version('thesis/nats'),
user: $config->user,
pass: $config->password,
sig: $signature,
Expand Down Expand Up @@ -122,7 +123,7 @@ public function testConnectProtocolCreationWithoutJwtAndNkey(): void
pedantic: $config->pedantic,
tlsRequired: false,
name: 'thesis/nats',
version: $config->version,
version: version('thesis/nats'),
user: $config->user,
pass: $config->password,
sig: null,
Expand Down Expand Up @@ -168,7 +169,7 @@ public function testConfigBackwardCompatibility(): void
pedantic: $config->pedantic,
tlsRequired: false,
name: 'thesis/nats',
version: $config->version,
version: version('thesis/nats'),
authToken: null,
user: $config->user,
pass: $config->password,
Expand Down Expand Up @@ -202,7 +203,7 @@ public function testJwtAndNkeyPrecedenceOverUserPassword(): void
pedantic: $config->pedantic,
tlsRequired: false,
name: 'thesis/nats',
version: $config->version,
version: version('thesis/nats'),
user: $config->user,
pass: $config->password,
sig: $signature,
Expand Down