Skip to content

Commit

Permalink
Wrong typing of the Grant Token endpoint (#108)
Browse files Browse the repository at this point in the history
* Wrong typing of the Grant Token endpoint

* linter fixes

* fix errors and bump pubnub.yml

* Add organization prefix to gh actions

* fix typo in pubnub.yaml and bump php in test matrix

* PubNub SDK 7.0.2 release.

---------

Co-authored-by: PubNub Release Bot <[email protected]>
  • Loading branch information
seba-aln and pubnub-release-bot authored Oct 22, 2024
1 parent 41bb532 commit f7cdc63
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
max-parallel: 1
fail-fast: true
matrix:
php: [8.0, 8.1, 8.2]
php: [8.1, 8.2, 8.3]
env:
PUBLISH_KEY: ${{ secrets.SDK_PUB_KEY }}
SUBSCRIBE_KEY: ${{ secrets.SDK_SUB_KEY }}
Expand Down
103 changes: 46 additions & 57 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
name: php
version: 7.0.1
version: 7.0.2
schema: 1
scm: github.com/pubnub/php
changelog:
- date: 2024-10-22
version: 7.0.2
changes:
- type: bug
text: "Fixed wrong type annotation for grant token response value."
- type: improvement
text: "Updated compatibility list."
- date: 2024-07-10
version: 7.0.1
changes:
Expand Down Expand Up @@ -319,25 +326,21 @@ sdks:
supported-operating-systems:
macOS:
runtime-version:
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 8.1
- PHP 8.2
- PHP 8.3
minimum-os-version:
- Mac OS X 10.8
maximum-os-version:
- macOS 11.2.3
- macOS 15.0.1
target-architecture:
- arm64
- x86-64
Windows:
runtime-version:
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 8.1
- PHP 8.2
- PHP 8.3
minimum-os-version:
- Windows 7 Professional
- Windows 7 Enterprise
Expand All @@ -350,15 +353,13 @@ sdks:
- x86-64
Linux:
runtime-version:
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 8.1
- PHP 8.2
- PHP 8.3
minimum-os-version:
- Ubuntu 16.04 LTS
- Ubuntu 20.04 LTS
maximum-os-version:
- Ubuntu 18.04 LTS
- Ubuntu 24.04.1 LTS
target-architecture:
- x86
- x86-64
Expand Down Expand Up @@ -387,25 +388,21 @@ sdks:
supported-operating-systems:
macOS:
runtime-version:
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 8.1
- PHP 8.2
- PHP 8.3
minimum-os-version:
- Mac OS X 10.8
maximum-os-version:
- macOS 11.2.3
- macOS 15.0.1
target-architecture:
- arm64
- x86-64
Windows:
runtime-version:
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 8.1
- PHP 8.2
- PHP 8.3
minimum-os-version:
- Windows 7 Professional
- Windows 7 Enterprise
Expand All @@ -418,22 +415,20 @@ sdks:
- x86-64
Linux:
runtime-version:
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 8.1
- PHP 8.2
- PHP 8.3
minimum-os-version:
- Ubuntu 16.04 LTS
- Ubuntu 20.04 LTS
maximum-os-version:
- Ubuntu 18.04 LTS
- Ubuntu 24.04.1 LTS
target-architecture:
- x86
- x86-64
- distribution-type: library
distribution-repository: GitHub release
package-name: php-7.0.1.zip
location: https://github.com/pubnub/php/releases/tag/7.0.1
package-name: php-7.0.2.zip
location: https://github.com/pubnub/php/releases/tag/7.0.2
requires:
- name: rmccue/requests
min-version: 1.0.0
Expand All @@ -455,25 +450,21 @@ sdks:
supported-operating-systems:
macOS:
runtime-version:
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 8.1
- PHP 8.2
- PHP 8.3
minimum-os-version:
- Mac OS X 10.8
maximum-os-version:
- macOS 11.2.3
- macOS 15.0.1
target-architecture:
- arm64
- x86-64
Windows:
runtime-version:
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 8.1
- PHP 8.2
- PHP 8.3
minimum-os-version:
- Windows 7 Professional
- Windows 7 Enterprise
Expand All @@ -486,15 +477,13 @@ sdks:
- x86-64
Linux:
runtime-version:
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3
- PHP 8.1
- PHP 8.2
- PHP 8.3
minimum-os-version:
- Ubuntu 16.04 LTS
- Ubuntu 20.04 LTS
maximum-os-version:
- Ubuntu 18.04 LTS
- Ubuntu 24.04.1 LTS
target-architecture:
- x86
- x86-64
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 7.0.2
October 22 2024

#### Fixed
- Fixed wrong type annotation for grant token response value.

#### Modified
- Updated compatibility list.

## 7.0.1
July 10 2024

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your
{
"require": {
<!-- include the latest version from the badge at the top -->
"pubnub/pubnub": "7.0.1"
"pubnub/pubnub": "7.0.2"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords": ["api", "real-time", "realtime", "real time", "ajax", "push"],
"homepage": "http://www.pubnub.com/",
"license": "proprietary",
"version": "7.0.1",
"version": "7.0.2",
"authors": [
{
"name": "PubNub",
Expand Down
32 changes: 17 additions & 15 deletions examples/GrantToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@

require_once __DIR__ . '/../vendor/autoload.php';

use PubNub\Models\Access\Permissions;
use PubNub\Models\Consumer\AccessManager\PNAccessManagerTokenResult;


$pnconfig = new \PubNub\PNConfiguration();
$pnconfig->setPublishKey('my-publish-key');
$pnconfig->setSubscribeKey('my-subscribe-key');
$pnconfig->setSecretKey('my-secret-key');
$pnconfig->setPublishKey(getenv("PUBLISH_PAM_KEY"));
$pnconfig->setSubscribeKey(getenv("SUBSCRIBE_PAM_KEY"));
$pnconfig->setSecretKey(getenv("SECRET_PAM_KEY"));
$pnconfig->setUuid('example-uuid');

$pubnub = new \PubNub\PubNub($pnconfig);

try {
$token = $pubnub->grantToken()
->ttl(30)
->authorizedUuid('my-uuid')
->authorizedUuid('example-uuid')
->addChannelResources([
'my-channel' => ['read' => true]
])
->sync();

/** @var PNAccessManagerTokenResult */
$parsedToken = $pubnub->parseToken($token);
$parsedToken->getTtl();
$parsedToken->getChannelResource('my-channel')
->hasRead();
print("Token granted: $token\n");

/** @var PNAccessManagerTokenResult */
$parsedToken = $pubnub->parseToken($token);

$tokensTTL = $parsedToken->getTtl();
$tokensMyChannelRead = $parsedToken->getChannelResource('my-channel')->hasRead();
$tokensMyChannelWrite = $parsedToken->getChannelResource('my-channel')->hasWrite();

print("Token TTL: $tokensTTL\n");
print("Token My Channel Read: " . (int)$tokensMyChannelRead . "\n");
print("Token My Channel Write: " . (int)$tokensMyChannelWrite . "\n");
} catch (\PubNub\Exceptions\PubNubServerException $e) {
var_dump($e->getBody());
}

var_dump(
$pubnub->parseToken($token)->toArray()
); die;
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,6 @@ parameters:
count: 1
path: src/PubNub/Endpoints/Access/GrantToken.php

-
message: "#^PHPDoc tag @return has invalid value \\(\\: PNAccessManagerGrantResult\\)\\: Unexpected token \"\\:\", expected type at offset 47$#"
count: 1
path: src/PubNub/Endpoints/Access/GrantToken.php

-
message: "#^Property PubNub\\\\Endpoints\\\\Access\\\\GrantToken\\:\\:\\$channels has no type specified\\.$#"
count: 1
Expand Down
9 changes: 4 additions & 5 deletions src/PubNub/Endpoints/Access/GrantToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use PubNub\Endpoints\Endpoint;
use PubNub\Exceptions\PubNubValidationException;
use PubNub\Models\Consumer\AccessManager\PNAccessManagerGrantResult;
use PubNub\PubNubUtil;
use PubNub\Enums\PNHttpMethod;
use PubNub\Enums\PNOperationType;
Expand Down Expand Up @@ -237,18 +236,18 @@ public function buildPath()
}

/**
* @return PNAccessManagerGrantResult
* @return string
*/
public function sync(): PNAccessManagerGrantResult
public function sync(): string
{
return parent::sync();
}

/**
* @param string $token
* @return : PNAccessManagerGrantResult
* @return string
*/
public function createResponse($response): PNAccessManagerGrantResult
public function createResponse($response): string
{
return $response['data']['token'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/PubNub/PubNub.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

class PubNub implements LoggerAwareInterface
{
protected const SDK_VERSION = "7.0.1";
protected const SDK_VERSION = "7.0.2";
protected const SDK_NAME = "PubNub-PHP";

public static $MAX_SEQUENCE = 65535;
Expand Down

0 comments on commit f7cdc63

Please sign in to comment.