JSON Web Token implementation

Minimum implementation used by Realtime auth, based on this spec: http://self-issued.info/docs/draft-jones-json-web-token-01.html.

author Aleksey Korzun
package Library
subpackage Twilio\Utility\Capability

 Methods

Decode payload

decode(string $jwt, string | null $key, bool $verify) : object
Static

Parameters

$jwt

string

the JWT

$key

stringnull

the secret key

$verify

bool

don't skip verification process

Exceptions

\UnexpectedValueException
\DomainException

Returns

objectJSON Web Token implementation as PHP object

Encode payload

encode(object | array $payload, string $key, string $algorithm) : string
Static

Parameters

$payload

objectarray

PHP object or array

$key

string

the secret key

$algorithm

string

the signing algorithm

Returns

stringJSON Web Token implementation

Decode previously encoded JSON

jsonDecode(string $input) : object | string[]
Static

Parameters

$input

string

JSON string

Exceptions

\DomainException

Returns

objectstring[]object representation of JSON string

Encode input in JSON

jsonEncode(object | string[] $input) : string
Static

Parameters

$input

objectstring[]

a PHP object or array

Exceptions

\DomainException

Returns

stringJSON representation of the PHP object or array

Securily sign a message

sign(string $message, string $key, string $method) : string
Static

Parameters

$message

string

the message to sign

$key

string

the secret key

$method

string

the signing algorithm

Returns

stringan encrypted message

Decode previously encoded input

urlsafeB64Decode(string $input) : string
Static

Parameters

$input

string

a base64 encoded string

Returns

stringa decoded string

Base64 encode URL's

urlsafeB64Encode(string $input) : string
Static

Parameters

$input

string

anything really

Returns

stringthe base64 encode of what you passed in

Handle JSON error

handleJsonError(int $error) 
Static

Parameters

$error

int

an error number from json_last_error()

Exceptions

\DomainException