File manager - Edit - /home/opticamezl/www/newok/Jwt.tar
Back
AccessToken.php 0000604 00000005553 15174041261 0007464 0 ustar 00 <?php namespace Twilio\Jwt; use Twilio\Jwt\Grants\Grant; class AccessToken { private $signingKeySid; private $accountSid; private $secret; private $ttl; private $identity; private $nbf; /** @var Grant[] $grants */ private $grants; public function __construct($accountSid, $signingKeySid, $secret, $ttl = 3600, $identity = null) { $this->signingKeySid = $signingKeySid; $this->accountSid = $accountSid; $this->secret = $secret; $this->ttl = $ttl; if (!is_null($identity)) { $this->identity = $identity; } $this->grants = array(); } /** * Set the identity of this access token * * @param string $identity identity of the grant * * @return $this updated access token */ public function setIdentity($identity) { $this->identity = $identity; return $this; } /** * Returns the identity of the grant * * @return string the identity */ public function getIdentity() { return $this->identity; } /** * Set the nbf of this access token * * @param integer $nbf nbf in epoch seconds of the grant * * @return $this updated access token */ public function setNbf($nbf) { $this->nbf = $nbf; return $this; } /** * Returns the nbf of the grant * * @return integer the nbf in epoch seconds */ public function getNbf() { return $this->nbf; } /** * Add a grant to the access token * * @param Grant $grant to be added * * @return $this the updated access token */ public function addGrant(Grant $grant) { $this->grants[] = $grant; return $this; } public function toJWT($algorithm = 'HS256') { $header = array( 'cty' => 'twilio-fpa;v=1', 'typ' => 'JWT' ); $now = time(); $grants = array(); if ($this->identity) { $grants['identity'] = $this->identity; } foreach ($this->grants as $grant) { $payload = $grant->getPayload(); if (empty($payload)) { $payload = json_decode('{}'); } $grants[$grant->getGrantKey()] = $payload; } if (empty($grants)) { $grants = json_decode('{}'); } $payload = array( 'jti' => $this->signingKeySid . '-' . $now, 'iss' => $this->signingKeySid, 'sub' => $this->accountSid, 'exp' => $now + $this->ttl, 'grants' => $grants ); if (!is_null($this->nbf)) { $payload['nbf'] = $this->nbf; } return JWT::encode($payload, $this->secret, $algorithm, $header); } public function __toString() { return $this->toJWT(); } } Client/ScopeURI.php 0000604 00000003173 15174041261 0010125 0 ustar 00 <?php namespace Twilio\Jwt\Client; /** * Scope URI implementation * * Simple way to represent configurable privileges in an OAuth * friendly way. For our case, they look like this: * * scope:<service>:<privilege>?<params> * * For example: * scope:client:incoming?name=jonas */ class ScopeURI { public $service; public $privilege; public $params; public function __construct($service, $privilege, $params = array()) { $this->service = $service; $this->privilege = $privilege; $this->params = $params; } public function toString() { $uri = "scope:{$this->service}:{$this->privilege}"; if (count($this->params)) { $uri .= "?" . http_build_query($this->params, '', '&'); } return $uri; } /** * Parse a scope URI into a ScopeURI object * * @param string $uri The scope URI * @return ScopeURI The parsed scope uri * @throws \UnexpectedValueException */ public static function parse($uri) { if (strpos($uri, 'scope:') !== 0) { throw new \UnexpectedValueException( 'Not a scope URI according to scheme'); } $parts = explode('?', $uri, 1); $params = null; if (count($parts) > 1) { parse_str($parts[1], $params); } $parts = explode(':', $parts[0], 2); if (count($parts) != 3) { throw new \UnexpectedValueException( 'Not enough parts for scope URI'); } list($scheme, $service, $privilege) = $parts; return new ScopeURI($service, $privilege, $params); } } ClientToken.php 0000604 00000007324 15174041261 0007477 0 ustar 00 <?php namespace Twilio\Jwt; use Twilio\Jwt\Client\ScopeURI; /** * Twilio Capability Token generator */ class ClientToken { public $accountSid; public $authToken; /** @var ScopeURI[] $scopes */ public $scopes; /** * Create a new TwilioCapability with zero permissions. Next steps are to * grant access to resources by configuring this token through the * functions allowXXXX. * * @param string $accountSid the account sid to which this token is granted * access * @param string $authToken the secret key used to sign the token. Note, * this auth token is not visible to the user of the token. */ public function __construct($accountSid, $authToken) { $this->accountSid = $accountSid; $this->authToken = $authToken; $this->scopes = array(); $this->clientName = false; } /** * If the user of this token should be allowed to accept incoming * connections then configure the TwilioCapability through this method and * specify the client name. * * @param $clientName * @throws \InvalidArgumentException */ public function allowClientIncoming($clientName) { // clientName must be a non-zero length alphanumeric string if (preg_match('/\W/', $clientName)) { throw new \InvalidArgumentException( 'Only alphanumeric characters allowed in client name.'); } if (strlen($clientName) == 0) { throw new \InvalidArgumentException( 'Client name must not be a zero length string.'); } $this->clientName = $clientName; $this->allow('client', 'incoming', array('clientName' => $clientName)); } /** * Allow the user of this token to make outgoing connections. * * @param string $appSid the application to which this token grants access * @param mixed[] $appParams signed parameters that the user of this token * cannot overwrite. */ public function allowClientOutgoing($appSid, array $appParams = array()) { $this->allow('client', 'outgoing', array( 'appSid' => $appSid, 'appParams' => http_build_query($appParams, '', '&'))); } /** * Allow the user of this token to access their event stream. * * @param mixed[] $filters key/value filters to apply to the event stream */ public function allowEventStream(array $filters = array()) { $this->allow('stream', 'subscribe', array( 'path' => '/2010-04-01/Events', 'params' => http_build_query($filters, '', '&'), )); } /** * Generates a new token based on the credentials and permissions that * previously has been granted to this token. * * @param int $ttl the expiration time of the token (in seconds). Default * value is 3600 (1hr) * @return ClientToken the newly generated token that is valid for $ttl * seconds */ public function generateToken($ttl = 3600) { $payload = array( 'scope' => array(), 'iss' => $this->accountSid, 'exp' => time() + $ttl, ); $scopeStrings = array(); foreach ($this->scopes as $scope) { if ($scope->privilege == "outgoing" && $this->clientName) $scope->params["clientName"] = $this->clientName; $scopeStrings[] = $scope->toString(); } $payload['scope'] = implode(' ', $scopeStrings); return JWT::encode($payload, $this->authToken, 'HS256'); } protected function allow($service, $privilege, $params) { $this->scopes[] = new ScopeURI($service, $privilege, $params); } } JWT.php 0000604 00000012342 15174041261 0005720 0 ustar 00 <?php namespace Twilio\Jwt; /** * 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 Neuman Vong <neuman@twilio.com> */ class JWT { /** * @param string $jwt The JWT * @param string|null $key The secret key * @param bool $verify Don't skip verification process * @return object The JWT's payload as a PHP object * @throws \DomainException * @throws \UnexpectedValueException */ public static function decode($jwt, $key = null, $verify = true) { $tks = explode('.', $jwt); if (count($tks) != 3) { throw new \UnexpectedValueException('Wrong number of segments'); } list($headb64, $payloadb64, $cryptob64) = $tks; if (null === ($header = self::jsonDecode(self::urlsafeB64Decode($headb64))) ) { throw new \UnexpectedValueException('Invalid segment encoding'); } if (null === $payload = self::jsonDecode(self::urlsafeB64Decode($payloadb64)) ) { throw new \UnexpectedValueException('Invalid segment encoding'); } $sig = self::urlsafeB64Decode($cryptob64); if ($verify) { if (empty($header->alg)) { throw new \DomainException('Empty algorithm'); } if ($sig != self::sign("$headb64.$payloadb64", $key, $header->alg)) { throw new \UnexpectedValueException('Signature verification failed'); } } return $payload; } /** * @param object|array $payload PHP object or array * @param string $key The secret key * @param string $algo The signing algorithm * @param array $additionalHeaders Additional keys/values to add to the header * * @return string A JWT */ public static function encode($payload, $key, $algo = 'HS256', $additionalHeaders = array()) { $header = array('typ' => 'JWT', 'alg' => $algo); $header = $header + $additionalHeaders; $segments = array(); $segments[] = self::urlsafeB64Encode(self::jsonEncode($header)); $segments[] = self::urlsafeB64Encode(self::jsonEncode($payload)); $signing_input = implode('.', $segments); $signature = self::sign($signing_input, $key, $algo); $segments[] = self::urlsafeB64Encode($signature); return implode('.', $segments); } /** * @param string $msg The message to sign * @param string $key The secret key * @param string $method The signing algorithm * @return string An encrypted message * @throws \DomainException */ public static function sign($msg, $key, $method = 'HS256') { $methods = array( 'HS256' => 'sha256', 'HS384' => 'sha384', 'HS512' => 'sha512', ); if (empty($methods[$method])) { throw new \DomainException('Algorithm not supported'); } return hash_hmac($methods[$method], $msg, $key, true); } /** * @param string $input JSON string * @return object Object representation of JSON string * @throws \DomainException */ public static function jsonDecode($input) { $obj = json_decode($input); if (function_exists('json_last_error') && $errno = json_last_error()) { self::handleJsonError($errno); } else if ($obj === null && $input !== 'null') { throw new \DomainException('Null result with non-null input'); } return $obj; } /** * @param object|array $input A PHP object or array * @return string JSON representation of the PHP object or array * @throws \DomainException */ public static function jsonEncode($input) { $json = json_encode($input); if (function_exists('json_last_error') && $errno = json_last_error()) { self::handleJsonError($errno); } else if ($json === 'null' && $input !== null) { throw new \DomainException('Null result with non-null input'); } return $json; } /** * @param string $input A base64 encoded string * * @return string A decoded string */ public static function urlsafeB64Decode($input) { $padlen = 4 - strlen($input) % 4; $input .= str_repeat('=', $padlen); return base64_decode(strtr($input, '-_', '+/')); } /** * @param string $input Anything really * * @return string The base64 encode of what you passed in */ public static function urlsafeB64Encode($input) { return str_replace('=', '', strtr(base64_encode($input), '+/', '-_')); } /** * @param int $errno An error number from json_last_error() * * @throws \DomainException */ private static function handleJsonError($errno) { $messages = array( JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON' ); throw new \DomainException(isset($messages[$errno]) ? $messages[$errno] : 'Unknown JSON error: ' . $errno ); } } TaskRouter/WorkspaceCapability.php 0000604 00000000701 15174041261 0013313 0 ustar 00 <?php namespace Twilio\Jwt\TaskRouter; class WorkspaceCapability extends CapabilityToken { public function __construct($accountSid, $authToken, $workspaceSid, $overrideBaseUrl = null, $overrideBaseWSUrl = null) { parent::__construct($accountSid, $authToken, $workspaceSid, $workspaceSid, null, $overrideBaseUrl, $overrideBaseWSUrl); } protected function setupResource() { $this->resourceUrl = $this->baseUrl; } } TaskRouter/TaskQueueCapability.php 0000604 00000001233 15174041261 0013265 0 ustar 00 <?php namespace Twilio\Jwt\TaskRouter; /** * Twilio TaskRouter TaskQueue Capability assigner * * @author Justin Witz <justin.witz@twilio.com> * @license http://creativecommons.org/licenses/MIT/ MIT */ class TaskQueueCapability extends CapabilityToken { public function __construct($accountSid, $authToken, $workspaceSid, $taskQueueSid, $overrideBaseUrl = null, $overrideBaseWSUrl = null) { parent::__construct($accountSid, $authToken, $workspaceSid, $taskQueueSid, null, $overrideBaseUrl, $overrideBaseWSUrl); } protected function setupResource() { $this->resourceUrl = $this->baseUrl . '/TaskQueues/' . $this->channelId; } } TaskRouter/CapabilityToken.php 0000604 00000012630 15174041261 0012441 0 ustar 00 <?php namespace Twilio\Jwt\TaskRouter; use Twilio\Jwt\JWT; /** * Twilio TaskRouter Capability assigner * * @author Justin Witz <justin.witz@twilio.com> * @license http://creativecommons.org/licenses/MIT/ MIT */ class CapabilityToken { protected $accountSid; protected $authToken; private $friendlyName; /** @var Policy[] $policies */ private $policies; protected $baseUrl = 'https://taskrouter.twilio.com/v1'; protected $baseWsUrl = 'https://event-bridge.twilio.com/v1/wschannels'; protected $version = 'v1'; protected $workspaceSid; protected $channelId; protected $resourceUrl; protected $required = array("required" => true); protected $optional = array("required" => false); public function __construct($accountSid, $authToken, $workspaceSid, $channelId, $resourceUrl = null, $overrideBaseUrl = null, $overrideBaseWSUrl = null) { $this->accountSid = $accountSid; $this->authToken = $authToken; $this->friendlyName = $channelId; $this->policies = array(); $this->workspaceSid = $workspaceSid; $this->channelId = $channelId; if (isset($overrideBaseUrl)) { $this->baseUrl = $overrideBaseUrl; } if (isset($overrideBaseWSUrl)) { $this->baseWsUrl = $overrideBaseWSUrl; } $this->baseUrl = $this->baseUrl . '/Workspaces/' . $workspaceSid; $this->validateJWT(); if (!isset($resourceUrl)) { $this->setupResource(); } //add permissions to GET and POST to the event-bridge channel $this->allow($this->baseWsUrl . "/" . $this->accountSid . "/" . $this->channelId, "GET", null, null); $this->allow($this->baseWsUrl . "/" . $this->accountSid . "/" . $this->channelId, "POST", null, null); //add permissions to fetch the instance resource $this->allow($this->resourceUrl, "GET", null, null); } protected function setupResource() { } public function addPolicyDeconstructed($url, $method, $queryFilter = array(), $postFilter = array(), $allow = true) { $policy = new Policy($url, $method, $queryFilter, $postFilter, $allow); array_push($this->policies, $policy); return $policy; } public function allow($url, $method, $queryFilter = array(), $postFilter = array()) { $this->addPolicyDeconstructed($url, $method, $queryFilter, $postFilter, true); } public function deny($url, $method, $queryFilter = array(), $postFilter = array()) { $this->addPolicyDeconstructed($url, $method, $queryFilter, $postFilter, false); } private function validateJWT() { if (!isset($this->accountSid) || substr($this->accountSid, 0, 2) != 'AC') { throw new \Exception("Invalid AccountSid provided: " . $this->accountSid); } if (!isset($this->workspaceSid) || substr($this->workspaceSid, 0, 2) != 'WS') { throw new \Exception("Invalid WorkspaceSid provided: " . $this->workspaceSid); } if (!isset($this->channelId)) { throw new \Exception("ChannelId not provided"); } $prefix = substr($this->channelId, 0, 2); if ($prefix != 'WS' && $prefix != 'WK' && $prefix != 'WQ') { throw new \Exception("Invalid ChannelId provided: " . $this->channelId); } } public function allowFetchSubresources() { $method = 'GET'; $queryFilter = array(); $postFilter = array(); $this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter); } public function allowUpdates() { $method = 'POST'; $queryFilter = array(); $postFilter = array(); $this->allow($this->resourceUrl, $method, $queryFilter, $postFilter); } public function allowUpdatesSubresources() { $method = 'POST'; $queryFilter = array(); $postFilter = array(); $this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter); } public function allowDelete() { $method = 'DELETE'; $queryFilter = array(); $postFilter = array(); $this->allow($this->resourceUrl, $method, $queryFilter, $postFilter); } public function allowDeleteSubresources() { $method = 'DELETE'; $queryFilter = array(); $postFilter = array(); $this->allow($this->resourceUrl . '/**', $method, $queryFilter, $postFilter); } public function generateToken($ttl = 3600, $extraAttributes = array()) { $payload = array( 'version' => $this->version, 'friendly_name' => $this->friendlyName, 'iss' => $this->accountSid, 'exp' => time() + $ttl, 'account_sid' => $this->accountSid, 'channel' => $this->channelId, 'workspace_sid' => $this->workspaceSid ); if (substr($this->channelId, 0, 2) == 'WK') { $payload['worker_sid'] = $this->channelId; } else if (substr($this->channelId, 0, 2) == 'WQ') { $payload['taskqueue_sid'] = $this->channelId; } foreach ($extraAttributes as $key => $value) { $payload[$key] = $value; } $policyStrings = array(); foreach ($this->policies as $policy) { $policyStrings[] = $policy->toArray(); } $payload['policies'] = $policyStrings; return JWT::encode($payload, $this->authToken, 'HS256'); } } TaskRouter/WorkerCapability.php 0000604 00000003357 15174041261 0012640 0 ustar 00 <?php namespace Twilio\Jwt\TaskRouter; /** * Twilio TaskRouter Worker Capability assigner * * @author Justin Witz <justin.witz@twilio.com> * @license http://creativecommons.org/licenses/MIT/ MIT */ class WorkerCapability extends CapabilityToken { private $tasksUrl; private $workerReservationsUrl; private $activityUrl; public function __construct($accountSid, $authToken, $workspaceSid, $workerSid, $overrideBaseUrl = null, $overrideBaseWSUrl = null) { parent::__construct($accountSid, $authToken, $workspaceSid, $workerSid, null, $overrideBaseUrl, $overrideBaseWSUrl); $this->tasksUrl = $this->baseUrl . '/Tasks/**'; $this->activityUrl = $this->baseUrl . '/Activities'; $this->workerReservationsUrl = $this->resourceUrl . '/Reservations/**'; //add permissions to fetch the list of activities, tasks, and worker reservations $this->allow($this->activityUrl, "GET", null, null); $this->allow($this->tasksUrl, "GET", null, null); $this->allow($this->workerReservationsUrl, "GET", null, null); } protected function setupResource() { $this->resourceUrl = $this->baseUrl . '/Workers/' . $this->channelId; } public function allowActivityUpdates() { $method = 'POST'; $queryFilter = array(); $postFilter = array("ActivitySid" => $this->required); $this->allow($this->resourceUrl, $method, $queryFilter, $postFilter); } public function allowReservationUpdates() { $method = 'POST'; $queryFilter = array(); $postFilter = array(); $this->allow($this->tasksUrl, $method, $queryFilter, $postFilter); $this->allow($this->workerReservationsUrl, $method, $queryFilter, $postFilter); } } TaskRouter/Policy.php 0000604 00000003006 15174041261 0010613 0 ustar 00 <?php namespace Twilio\Jwt\TaskRouter; /** * Twilio API Policy constructor * * @author Justin Witz <justin.witz@twilio.com> * @license http://creativecommons.org/licenses/MIT/ MIT */ class Policy { private $url; private $method; private $queryFilter; private $postFilter; private $allow; public function __construct($url, $method, $queryFilter = array(), $postFilter = array(), $allow = true) { $this->url = $url; $this->method = $method; $this->queryFilter = $queryFilter; $this->postFilter = $postFilter; $this->allow = $allow; } public function addQueryFilter($queryFilter) { array_push($this->queryFilter, $queryFilter); } public function addPostFilter($postFilter) { array_push($this->postFilter, $postFilter); } public function toArray() { $policy_array = array('url' => $this->url, 'method' => $this->method, 'allow' => $this->allow); if (!is_null($this->queryFilter)) { if (count($this->queryFilter) > 0) { $policy_array['query_filter'] = $this->queryFilter; } else { $policy_array['query_filter'] = new \stdClass(); } } if (!is_null($this->postFilter)) { if (count($this->postFilter) > 0) { $policy_array['post_filter'] = $this->postFilter; } else { $policy_array['post_filter'] = new \stdClass(); } } return $policy_array; } } Grants/IpMessagingGrant.php 0000604 00000006057 15174041261 0011722 0 ustar 00 <?php namespace Twilio\Jwt\Grants; class IpMessagingGrant implements Grant { private $serviceSid; private $endpointId; private $deploymentRoleSid; private $pushCredentialSid; public function __construct() { trigger_error("IpMessagingGrant is deprecated, please use ChatGrant", E_USER_NOTICE); } /** * Returns the service sid * * @return string the service sid */ public function getServiceSid() { return $this->serviceSid; } /** * Set the service sid of this grant * * @param string $serviceSid service sid of the grant * * @return $this updated grant */ public function setServiceSid($serviceSid) { $this->serviceSid = $serviceSid; return $this; } /** * Returns the endpoint id of the grant * * @return string the endpoint id */ public function getEndpointId() { return $this->endpointId; } /** * Set the endpoint id of the grant * * @param string $endpointId endpoint id of the grant * * @return $this updated grant */ public function setEndpointId($endpointId) { $this->endpointId = $endpointId; return $this; } /** * Returns the deployment role sid of the grant * * @return string the deployment role sid */ public function getDeploymentRoleSid() { return $this->deploymentRoleSid; } /** * Set the role sid of the grant * * @param string $deploymentRoleSid role sid of the grant * * @return $this updated grant */ public function setDeploymentRoleSid($deploymentRoleSid) { $this->deploymentRoleSid = $deploymentRoleSid; return $this; } /** * Returns the push credential sid of the grant * * @return string the push credential sid */ public function getPushCredentialSid() { return $this->pushCredentialSid; } /** * Set the credential sid of the grant * * @param string $pushCredentialSid push credential sid of the grant * * @return $this updated grant */ public function setPushCredentialSid($pushCredentialSid) { $this->pushCredentialSid = $pushCredentialSid; return $this; } /** * Returns the grant type * * @return string type of the grant */ public function getGrantKey() { return "ip_messaging"; } /** * Returns the grant data * * @return array data of the grant */ public function getPayload() { $payload = array(); if ($this->serviceSid) { $payload['service_sid'] = $this->serviceSid; } if ($this->endpointId) { $payload['endpoint_id'] = $this->endpointId; } if ($this->deploymentRoleSid) { $payload['deployment_role_sid'] = $this->deploymentRoleSid; } if ($this->pushCredentialSid) { $payload['push_credential_sid'] = $this->pushCredentialSid; } return $payload; } } Grants/Grant.php 0000604 00000000471 15174041261 0007565 0 ustar 00 <?php namespace Twilio\Jwt\Grants; interface Grant { /** * Returns the grant type * * @return string type of the grant */ public function getGrantKey(); /** * Returns the grant data * * @return array data of the grant */ public function getPayload(); } Grants/VoiceGrant.php 0000604 00000006406 15174041261 0010557 0 ustar 00 <?php namespace Twilio\Jwt\Grants; class VoiceGrant implements Grant { private $outgoingApplicationSid; private $outgoingApplicationParams; private $pushCredentialSid; private $endpointId; /** * Returns the outgoing application sid * * @return string the outgoing application sid */ public function getOutgoingApplicationSid() { return $this->outgoingApplicationSid; } /** * Set the outgoing application sid of the grant * * @param string $outgoingApplicationSid outgoing application sid of grant * * @return $this updated grant */ public function setOutgoingApplicationSid($outgoingApplicationSid) { $this->outgoingApplicationSid = $outgoingApplicationSid; return $this; } /** * Returns the outgoing application params * * @return array the outgoing application params */ public function getOutgoingApplicationParams() { return $this->outgoingApplicationParams; } /** * Set the outgoing application of the the grant * * @param string $sid outgoing application sid of the grant * @param string $params params to pass the the application * * @return $this updated grant */ public function setOutgoingApplication($sid, $params) { $this->outgoingApplicationSid = $sid; $this->outgoingApplicationParams = $params; return $this; } /** * Returns the push credential sid * * @return string the push credential sid */ public function getPushCredentialSid() { return $this->pushCredentialSid; } /** * Set the push credential sid * * @param string $pushCredentialSid * * @return $this updated grant */ public function setPushCredentialSid($pushCredentialSid) { $this->pushCredentialSid = $pushCredentialSid; return $this; } /** * Returns the endpoint id * * @return string the endpoint id */ public function getEndpointId() { return $this->endpointId; } /** * Set the endpoint id * * @param string $endpointId endpoint id * * @return $this updated grant */ public function setEndpointId($endpointId) { $this->endpointId = $endpointId; return $this; } /** * Returns the grant type * * @return string type of the grant */ public function getGrantKey() { return "voice"; } /** * Returns the grant data * * @return array data of the grant */ public function getPayload() { $payload = array(); if ($this->outgoingApplicationSid) { $outgoing = array(); $outgoing['application_sid'] = $this->outgoingApplicationSid; if ($this->outgoingApplicationParams) { $outgoing['params'] = $this->outgoingApplicationParams; } $payload['outgoing'] = $outgoing; } if ($this->pushCredentialSid) { $payload['push_credential_sid'] = $this->pushCredentialSid; } if ($this->endpointId) { $payload['endpoint_id'] = $this->endpointId; } return $payload; } } Grants/VideoGrant.php 0000604 00000003545 15174041261 0010561 0 ustar 00 <?php namespace Twilio\Jwt\Grants; class VideoGrant implements Grant { private $configurationProfileSid; private $room; /** * Returns the configuration profile sid * * @return string the configuration profile sid */ public function getConfigurationProfileSid() { return $this->configurationProfileSid; } /** * Set the configuration profile sid of the grant * @deprecated in favor of setRoom/getRoom * * @param string $configurationProfileSid configuration profile sid of grant * * @return $this updated grant */ public function setConfigurationProfileSid($configurationProfileSid) { trigger_error('Configuration profile sid is deprecated, use room instead.', E_USER_NOTICE); $this->configurationProfileSid = $configurationProfileSid; return $this; } /** * Returns the room * * @return string room name or sid set in this grant */ public function getRoom() { return $this->room; } /** * Set the room to allow access to in the grant * * @param string $roomSidOrName room sid or name * @return $this updated grant */ public function setRoom($roomSidOrName) { $this->room = $roomSidOrName; return $this; } /** * Returns the grant type * * @return string type of the grant */ public function getGrantKey() { return "video"; } /** * Returns the grant data * * @return array data of the grant */ public function getPayload() { $payload = array(); if ($this->configurationProfileSid) { $payload['configuration_profile_sid'] = $this->configurationProfileSid; } if ($this->room) { $payload['room'] = $this->room; } return $payload; } } Grants/ConversationsGrant.php 0000604 00000002446 15174041261 0012347 0 ustar 00 <?php namespace Twilio\Jwt\Grants; class ConversationsGrant implements Grant { private $configurationProfileSid; public function __construct() { trigger_error("ConversationsGrant is deprecated, please use VideoGrant", E_USER_NOTICE); } /** * Returns the configuration profile sid * * @return string the configuration profile sid */ public function getConfigurationProfileSid() { return $this->configurationProfileSid; } /** * @param string $configurationProfileSid the configuration profile sid * we want to enable for this grant * * @return $this updated grant */ public function setConfigurationProfileSid($configurationProfileSid) { $this->configurationProfileSid = $configurationProfileSid; return $this; } /** * Returns the grant type * * @return string type of the grant */ public function getGrantKey() { return "rtc"; } /** * Returns the grant data * * @return array data of the grant */ public function getPayload() { $payload = array(); if ($this->configurationProfileSid) { $payload['configuration_profile_sid'] = $this->configurationProfileSid; } return $payload; } } Grants/SyncGrant.php 0000604 00000006050 15174041261 0010421 0 ustar 00 <?php namespace Twilio\Jwt\Grants; class SyncGrant implements Grant { private $serviceSid; private $endpointId; private $deploymentRoleSid; private $pushCredentialSid; /** * Returns the service sid * * @return string the service sid */ public function getServiceSid() { return $this->serviceSid; } /** * Set the service sid of this grant * * @param string $serviceSid service sid of the grant * * @return Services_Twilio_Auth_SyncGrant updated grant */ public function setServiceSid($serviceSid) { $this->serviceSid = $serviceSid; return $this; } /** * Returns the endpoint id of the grant * * @return string the endpoint id */ public function getEndpointId() { return $this->endpointId; } /** * Set the endpoint id of the grant * * @param string $endpointId endpoint id of the grant * * @return Services_Twilio_Auth_SyncGrant updated grant */ public function setEndpointId($endpointId) { $this->endpointId = $endpointId; return $this; } /** * Returns the deployment role sid of the grant * * @return string the deployment role sid */ public function getDeploymentRoleSid() { return $this->deploymentRoleSid; } /** * Set the role sid of the grant * * @param string $deploymentRoleSid role sid of the grant * * @return Services_Twilio_Auth_SyncGrant updated grant */ public function setDeploymentRoleSid($deploymentRoleSid) { $this->deploymentRoleSid = $deploymentRoleSid; return $this; } /** * Returns the push credential sid of the grant * * @return string the push credential sid */ public function getPushCredentialSid() { return $this->pushCredentialSid; } /** * Set the credential sid of the grant * * @param string $pushCredentialSid push credential sid of the grant * * @return Services_Twilio_Auth_SyncGrant updated grant */ public function setPushCredentialSid($pushCredentialSid) { $this->pushCredentialSid = $pushCredentialSid; return $this; } /** * Returns the grant type * * @return string type of the grant */ public function getGrantKey() { return "data_sync"; } /** * Returns the grant data * * @return array data of the grant */ public function getPayload() { $payload = array(); if ($this->serviceSid) { $payload['service_sid'] = $this->serviceSid; } if ($this->endpointId) { $payload['endpoint_id'] = $this->endpointId; } if ($this->deploymentRoleSid) { $payload['deployment_role_sid'] = $this->deploymentRoleSid; } if ($this->pushCredentialSid) { $payload['push_credential_sid'] = $this->pushCredentialSid; } return $payload; } } Grants/TaskRouterGrant.php 0000604 00000004246 15174041261 0011615 0 ustar 00 <?php namespace Twilio\Jwt\Grants; class TaskRouterGrant implements Grant { private $workspaceSid; private $workerSid; private $role; /** * Returns the workspace sid * * @return string the workspace sid */ public function getWorkspaceSid() { return $this->workspaceSid; } /** * Set the workspace sid of this grant * * @param string $workspaceSid workspace sid of the grant * * @return Services_Twilio_Auth_TaskRouterGrant updated grant */ public function setWorkspaceSid($workspaceSid) { $this->workspaceSid = $workspaceSid; return $this; } /** * Returns the worker sid * * @return string the worker sid */ public function getWorkerSid() { return $this->workerSid; } /** * Set the worker sid of this grant * * @param string $worker worker sid of the grant * * @return Services_Twilio_Auth_TaskRouterGrant updated grant */ public function setWorkerSid($workerSid) { $this->workerSid = $workerSid; return $this; } /** * Returns the role * * @return string the role */ public function getRole() { return $this->role; } /** * Set the role of this grant * * @param string $role role of the grant * * @return Services_Twilio_Auth_TaskRouterGrant updated grant */ public function setRole($role) { $this->role = $role; return $this; } /** * Returns the grant type * * @return string type of the grant */ public function getGrantKey() { return "task_router"; } /** * Returns the grant data * * @return array data of the grant */ public function getPayload() { $payload = array(); if ($this->workspaceSid) { $payload['workspace_sid'] = $this->workspaceSid; } if ($this->workerSid) { $payload['worker_sid'] = $this->workerSid; } if ($this->role) { $payload['role'] = $this->role; } return $payload; } } Grants/ChatGrant.php 0000604 00000005627 15174041261 0010375 0 ustar 00 <?php namespace Twilio\Jwt\Grants; class ChatGrant implements Grant { private $serviceSid; private $endpointId; private $deploymentRoleSid; private $pushCredentialSid; /** * Returns the service sid * * @return string the service sid */ public function getServiceSid() { return $this->serviceSid; } /** * Set the service sid of this grant * * @param string $serviceSid service sid of the grant * * @return $this updated grant */ public function setServiceSid($serviceSid) { $this->serviceSid = $serviceSid; return $this; } /** * Returns the endpoint id of the grant * * @return string the endpoint id */ public function getEndpointId() { return $this->endpointId; } /** * Set the endpoint id of the grant * * @param string $endpointId endpoint id of the grant * * @return $this updated grant */ public function setEndpointId($endpointId) { $this->endpointId = $endpointId; return $this; } /** * Returns the deployment role sid of the grant * * @return string the deployment role sid */ public function getDeploymentRoleSid() { return $this->deploymentRoleSid; } /** * Set the role sid of the grant * * @param string $deploymentRoleSid role sid of the grant * * @return $this updated grant */ public function setDeploymentRoleSid($deploymentRoleSid) { $this->deploymentRoleSid = $deploymentRoleSid; return $this; } /** * Returns the push credential sid of the grant * * @return string the push credential sid */ public function getPushCredentialSid() { return $this->pushCredentialSid; } /** * Set the credential sid of the grant * * @param string $pushCredentialSid push credential sid of the grant * * @return $this updated grant */ public function setPushCredentialSid($pushCredentialSid) { $this->pushCredentialSid = $pushCredentialSid; return $this; } /** * Returns the grant type * * @return string type of the grant */ public function getGrantKey() { return "chat"; } /** * Returns the grant data * * @return array data of the grant */ public function getPayload() { $payload = array(); if ($this->serviceSid) { $payload['service_sid'] = $this->serviceSid; } if ($this->endpointId) { $payload['endpoint_id'] = $this->endpointId; } if ($this->deploymentRoleSid) { $payload['deployment_role_sid'] = $this->deploymentRoleSid; } if ($this->pushCredentialSid) { $payload['push_credential_sid'] = $this->pushCredentialSid; } return $payload; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.23 | Generation time: 0 |
proxy
|
phpinfo
|
Settings