/** * Initialize from the parts of a compact serialization. * * @param array $parts * @throws \UnexpectedValueException * @return self */ public static function fromParts(array $parts) { if (count($parts) != 3) { throw new \UnexpectedValueException("Invalid JWS compact serialization."); } $header = Header::fromJSON(Base64::urlDecode($parts[0])); $b64 = $header->hasB64Payload() ? $header->B64Payload()->value() : true; $payload = $b64 ? Base64::urlDecode($parts[1]) : $parts[1]; $signature_input = $parts[0] . "." . $parts[1]; $signature = Base64::urlDecode($parts[2]); return new self($header, $payload, $signature_input, $signature); }
/** * Get the parameter value as a decoded string. * * @return string */ public function string() { return Base64::urlDecode($this->value()); }
/** * Get JWT header. * * @return JOSE */ public function header() { $header = Header::fromJSON(Base64::urlDecode($this->_parts[0])); return new JOSE($header); }
/** * Initialize from parts of compact serialization. * * @param array $parts * @throws \UnexpectedValueException * @return self */ public static function fromParts(array $parts) { if (count($parts) != 5) { throw new \UnexpectedValueException("Invalid JWE compact serialization."); } $header = Header::fromJSON(Base64::urlDecode($parts[0])); $encrypted_key = Base64::urlDecode($parts[1]); $iv = Base64::urlDecode($parts[2]); $ciphertext = Base64::urlDecode($parts[3]); $auth_tag = Base64::urlDecode($parts[4]); return new self($header, $encrypted_key, $iv, $ciphertext, $auth_tag); }
/** * Get coordinate in octet string representation. * * @return string */ public function coordinateOctets() { return Base64::urlDecode($this->_value); }
/** * Get the symmetric key. * * @return string */ public function key() { return Base64::urlDecode($this->keyValueParameter()->value()); }
/** * Get value as a number. * * @return BigInt */ public function number() { return BigInt::fromBase256(Base64::urlDecode($this->value())); }