Skip to content

Commit b937ab8

Browse files
authored
Release v
## Release Notes ### What's Changed - Bug fixes and improvements ### Breaking Changes - None ### Dependencies - Updated dependencies to latest stable versions
1 parent a023eaa commit b937ab8

37 files changed

Lines changed: 1750 additions & 1040 deletions

.gitignore

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
/nbproject/private/
2-
Tests/vendor
3-
Tests/composer.lock
4-
/simpletest
5-
/.vs
1+
# Composer
2+
/vendor/
3+
composer.phar
4+
5+
# IDE files
6+
.idea/
7+
.vscode/
8+
*.swp
9+
*.swo
10+
11+
# OS files
12+
.DS_Store
13+
Thumbs.db
14+
15+
# Logs
16+
*.log
17+
18+
# Environment files
19+
.env
20+
.env.local
21+
22+
# PHPUnit cache
23+
.phpunit.result.cache

README-internal.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Internal README: Project Setup & Testing
2+
3+
## Project Requirements
4+
5+
- PHP 7.4 or higher
6+
- Composer
7+
8+
## Setup Instructions
9+
10+
1. **Clone or copy the repository** to your local machine.
11+
2. **Install dependencies**:
12+
13+
```shell
14+
composer install
15+
```
16+
17+
3. **Run the test suite**:
18+
19+
```shell
20+
composer test
21+
```
22+
23+
- This will execute all tests in the `tests/` directory using PHPUnit and display readable output in TestDox format.
24+
25+
## Project Structure
26+
27+
- **Source code:** `src/`
28+
- **Tests:** `tests/`
29+
- **Configuration:**
30+
- Composer: `composer.json`
31+
- PHPUnit: `phpunit.xml`
32+
33+
## Adding and Running Tests
34+
35+
- Place new test files in the appropriate subfolder under `tests/`.
36+
- Run all tests with:
37+
38+
```shell
39+
composer test
40+
```
41+
42+
## Additional Notes
43+
44+
- If you need to run PHPUnit directly, use:
45+
46+
```shell
47+
vendor\bin\phpunit tests --testdox
48+
```
49+
50+
- For code coverage, you can use:
51+
52+
```shell
53+
vendor\bin\phpunit --coverage-html coverage
54+
```
55+
56+
(Requires Xdebug or PCOV extension)
57+
58+
---
59+
This file is for internal use and documents the setup and test process for developers working on this project.

README.md

Lines changed: 94 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,94 @@
1-
2-
# Queue-it Queue Token SDK for PHP
3-
4-
The Queue-it Queue Token SDK is used to ensure that end users cannot enter the queue without a valid token and to be a container which can carry sensitive user information from integrating system into the queue.
5-
6-
## The Token
7-
8-
The token consists of two parts. Firstly, a header containing non-sensitive metadata. Secondly the payload of the token.
9-
Both header and payload are in JSON format.
10-
11-
### Token Header
12-
13-
```json
14-
{
15-
"typ": "QT1",
16-
"enc": "AES256",
17-
"iss": 1526464517,
18-
"exp": 1526524517,
19-
"ti": "159aba3e-55e1-4f54-b6ee-e5b943d7e885",
20-
"c": "ticketania",
21-
"e": "demoevent",
22-
"ip": "75.86.129.4",
23-
"xff": "45.67.2.4,34.56.3.2"
24-
}
25-
```
26-
27-
- `typ`: The type of the token. Value must be "QT1". Required.
28-
- `enc`: Payload encryption algorithm. Value must be "AES256". Required.
29-
- `iss`: NumericDate of when token was issued. Required.
30-
- `exp`: NumericDate of when token expires. Optional.
31-
- `ti`: Unique Token ID (e.g. uuid). Used to uniquely identify tokens and restrict replay attacks. Required.
32-
- `c`: The Customer ID of the issuer. Token will only be valid on events on this account. Required.
33-
- `e`: The Event ID. If provided, token will only be valid on this event. Optional.
34-
- `ip`: The IP address of user the token is issued for. If provided, the IP address in the token is validated against the client IP before issuing a new Queue id. Optional.
35-
- `xff`: The X-Forwarded-For header of the request when the token is issued. Only used for logging. Optional.
36-
37-
### Token Payload
38-
39-
```json
40-
{
41-
"r": 0.4578,
42-
"k": "XKDI42W",
43-
"cd": { "size": "medium" }
44-
}
45-
```
46-
47-
- `r`: The relative quality of the key. Must be a decimal value. Used for determining the quality of the token. Optional
48-
- `k`: A unique key that holds value to the integrating system (e.g. email or user id). Used to restrict users from issuing multiple queue ids. Optional.
49-
- `cd`: Any custom data of the user. This is a set of key-value pairs. Optional
50-
51-
## Usage
52-
53-
```javascript
54-
const secretKey = '...';
55-
const token = Token
56-
.Enqueue("ticketania")
57-
.WithPayload(Payload
58-
.Enqueue()
59-
.WithKey("XKDI42W")
60-
.WithRelativeQuality(0.4578)
61-
.WithCustomData("size", "medium")
62-
.Generate())
63-
.WithEventId("demoevent")
64-
.WithIpAddress("75.86.129.4", "45.67.2.4,34.56.3.2")
65-
.WithValidity(60000)
66-
.Generate(secretKey);
67-
68-
const tokenValue = token.Token;
69-
```
70-
71-
### Specifying token identifier prefix
72-
73-
A prefix for the token identifier can optionally be provided to restrict the user session after getting through the queue to the one used before entering the queue. Once the user is through the queue the token identifier is provided to the target application in the Known User token. The format of the token identifier is then `[YOUR PREFIX]~[GUID]`, e.g: AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb~e937ef0d-48ec-4ff7-866e-52033273cb3d.
74-
75-
```javascript
76-
const tokenIdentifierPrefix = "AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb";
77-
const token = Token
78-
.Enqueue("ticketania", tokenIdentifierPrefix)
79-
.Generate(secretKey);
80-
81-
const tokenIdentifier = token.TokenIdentifier;
82-
// tokenIdentifier example: AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb~e937ef0d-48ec-4ff7-866e-52033273cb3d
83-
```
84-
85-
## Serialized Token
86-
87-
> eyJ0eXAiOiJRVDEiLCJlbmMiOiJBRVMyNTYiLCJpc3MiOjE1MzQ3MjMyMDAwMDAsImV4cCI6MTUzOTEyOTYwMDAwMCwidGkiOiJhMjFkNDIzYS00M2ZkLTQ4MjEtODRmYS00MzkwZjZhMmZkM2UiLCJjIjoidGlja2V0YW5pYSIsImUiOiJteWV2ZW50In0.0rDlI69F1Dx4Twps5qD4cQrbXbCRiezBd6fH1PVm6CnVY456FALkAhN3rgVrh_PGCJHcEXN5zoqFg65MH8WZc_CQdD63hJre3Sedu0-9zIs.aZgzkJm57etFaXjjME_-9LjOgPNTTqkp1aJ057HuEiU
88-
89-
The format of the token is [header].[payload].[hash] where each part is Base64Url encoded.
90-
The payload is AES 256 encrypted with the secret key supplied in the `.Generate(secretKey)` method.
91-
If the "e" key is provided in the header, the secret key on the event must be used.
92-
If no "e" key is provided the default key on the customer account must be used.
93-
The token is signed with SHA 256 using the same secret key.
1+
# Queue-it Queue Token SDK for PHP
2+
3+
The `Queue-it` Queue Token SDK is used to ensure that end users cannot enter the queue without a valid token and to be a container which can carry sensitive user information from integrating system into the queue.
4+
5+
## The Token
6+
7+
The token consists of two parts. Firstly, a header containing non-sensitive metadata. Secondly the payload of the token.
8+
Both header and payload are in JSON format.
9+
10+
### Token Header
11+
12+
```json
13+
{
14+
"typ": "QT1",
15+
"enc": "AES256",
16+
"iss": 1526464517,
17+
"exp": 1526524517,
18+
"ti": "159aba3e-55e1-4f54-b6ee-e5b943d7e885",
19+
"c": "ticketania",
20+
"e": "demoevent",
21+
"ip": "75.86.129.4",
22+
"xff": "45.67.2.4,34.56.3.2"
23+
}
24+
```
25+
26+
- `typ`: The type of the token. Value must be "QT1". Required.
27+
- `enc`: Payload encryption algorithm. Value must be "AES256". Required.
28+
- `iss`: NumericDate of when token was issued. Required.
29+
- `exp`: NumericDate of when token expires. Optional.
30+
- `ti`: Unique Token ID (e.g. uuid). Used to uniquely identify tokens and restrict replay attacks. Required.
31+
- `c`: The Customer ID of the issuer. Token will only be valid on events on this account. Required.
32+
- `e`: The Event ID. If provided, token will only be valid on this event. Optional.
33+
- `ip`: The IP address of user the token is issued for. If provided, the IP address in the token is validated against the client IP before issuing a new Queue id. Optional.
34+
- `xff`: The X-Forwarded-For header of the request when the token is issued. Only used for logging. Optional.
35+
36+
### Token Payload
37+
38+
```json
39+
{
40+
"r": 0.4578,
41+
"k": "XKDI42W",
42+
"cd": { "size": "medium" },
43+
"o": ""
44+
}
45+
```
46+
47+
- `r`: The relative quality of the key. Must be a decimal value. Used for determining the quality of the token. Optional
48+
- `k`: A unique key that holds value to the integrating system (e.g. email or user id). Used to restrict users from issuing multiple queue ids. Optional.
49+
- `cd`: Any custom data of the user. This is a set of key-value pairs. Optional
50+
- `o`: Origin. A string representing he origin who is using this EnqueueToken. Optional
51+
52+
## Usage
53+
54+
```php
55+
const secretKey = '...';
56+
const token = Token
57+
.enqueue("ticketania")
58+
.withPayload(Payload
59+
.enqueue()
60+
.withKey("XKDI42W")
61+
.withRelativeQuality(0.4578)
62+
.withCustomData("size", "medium")
63+
.generate())
64+
.withEventId("demoevent")
65+
.withIpAddress("75.86.129.4", "45.67.2.4,34.56.3.2")
66+
.withValidity(60000)
67+
.generate(secretKey);
68+
69+
const tokenValue = token.Token;
70+
```
71+
72+
### Specifying token identifier prefix
73+
74+
A prefix for the token identifier can optionally be provided to restrict the user session after getting through the queue to the one used before entering the queue. Once the user is through the queue the token identifier is provided to the target application in the Known User token. The format of the token identifier is then `[YOUR PREFIX]~[GUID]`, e.g: AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb~e937ef0d-48ec-4ff7-866e-52033273cb3d.
75+
76+
```php
77+
const tokenIdentifierPrefix = "AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb";
78+
const token = Token
79+
.enqueue("ticketania", tokenIdentifierPrefix)
80+
.generate(secretKey);
81+
82+
const tokenIdentifier = token.TokenIdentifier;
83+
// tokenIdentifier example: AnfTDnpwazllYmnmgaCJ8tErV80YHv77ni5NgqQNhfWwxNqrNcHb~e937ef0d-48ec-4ff7-866e-52033273cb3d
84+
```
85+
86+
## Serialized Token
87+
88+
> eyJ0eXAiOiJRVDEiLCJlbmMiOiJBRVMyNTYiLCJpc3MiOjE1MzQ3MjMyMDAwMDAsImV4cCI6MTUzOTEyOTYwMDAwMCwidGkiOiJhMjFkNDIzYS00M2ZkLTQ4MjEtODRmYS00MzkwZjZhMmZkM2UiLCJjIjoidGlja2V0YW5pYSIsImUiOiJteWV2ZW50In0.0rDlI69F1Dx4Twps5qD4cQrbXbCRiezBd6fH1PVm6CnVY456FALkAhN3rgVrh_PGCJHcEXN5zoqFg65MH8WZc_CQdD63hJre3Sedu0-9zIs.aZgzkJm57etFaXjjME_-9LjOgPNTTqkp1aJ057HuEiU
89+
90+
The format of the token is [header].[payload].[hash] where each part is Base64Url encoded.
91+
The payload is AES 256 encrypted with the secret key supplied in the `.Generate(secretKey)` method.
92+
If the "e" key is provided in the header, the secret key on the event must be used.
93+
If no "e" key is provided the default key on the customer account must be used.
94+
The token is signed with SHA 256 using the same secret key.

composer.json

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,47 @@
11
{
2-
"require-dev": {
3-
"phpunit/phpunit": "^11.4"
4-
},
5-
"autoload": {
6-
"psr-4": {
7-
"QueueIT\\": "src/"
2+
"name": "queueit/queuetoken-v1-php",
3+
"version": "",
4+
"description": "Queue-it PHP queue token library for managing enqueue tokens",
5+
"type": "library",
6+
"keywords": [
7+
"queue",
8+
"queueit",
9+
"queue-token",
10+
"enqueue-token",
11+
"traffic-management"
12+
],
13+
"homepage": "https://queue-it.com",
14+
"license": "LGPL-3.0",
15+
"authors": [
16+
{
17+
"name": "Queue-it",
18+
"email": "support@queue-it.com"
819
}
9-
},
20+
],
1021
"require": {
22+
"php": ">=7.4",
1123
"ext-json": "*",
1224
"ext-openssl": "*"
25+
},
26+
"require-dev": {
27+
"phpunit/phpunit": "^9.5"
28+
},
29+
"autoload": {
30+
"psr-4": {
31+
"QueueIT\\QueueToken\\": "src/"
32+
}
33+
},
34+
"autoload-dev": {
35+
"psr-4": {
36+
"QueueIT\\QueueToken\\Tests\\": "tests/"
37+
}
38+
},
39+
"extra": {
40+
"branch-alias": {
41+
"dev-main": "1.x-dev"
42+
}
43+
},
44+
"scripts": {
45+
"test": "vendor\\bin\\phpunit tests --testdox"
1346
}
1447
}

0 commit comments

Comments
 (0)