/** * Add the auth response * * @param Connection $connection * @param Identity $identity * @param string $challengeData * @return NodeInterface */ protected function createAuthResponseNode(Connection $connection, Identity $identity, $challengeData) { $resp = $this->getAuthData($connection, $identity, $challengeData); $respHash = []; $respHash["xmlns"] = "urn:ietf:params:xml:ns:xmpp-sasl"; $node = Node::fromArray(['name' => 'response', 'attributes' => $respHash, 'data' => $resp]); return $node; }
/** * @return \Tmv\WhatsApi\Message\Node\NodeInterface|null */ protected function nextTreeInternal() { $token = $this->readInt8(); $size = $this->readListSize($token); $token = $this->readInt8(); if ($token == 1) { $attributes = $this->readAttributes($size); return Node::fromArray(array('name' => 'start', 'attributes' => $attributes)); } elseif ($token == 2) { return null; } $tag = $this->readString($token); $attributes = $this->readAttributes($size); if ($size % 2 == 1) { return Node::fromArray(array('name' => $tag, 'attributes' => $attributes)); } $token = $this->readInt8(); if ($this->isListTag($token)) { $children = $this->readList($token); return Node::fromArray(array('name' => $tag, 'attributes' => $attributes, 'children' => is_array($children) ? $children : array())); } return Node::fromArray(array('name' => $tag, 'attributes' => $attributes, 'data' => $this->readString($token))); }
/** * @param NodeInterface|array $child * @return $this * @throws InvalidArgumentException */ public function addChild($child) { if (is_array($child)) { $child = Node::fromArray($child); } if (!$child instanceof NodeInterface) { throw new InvalidArgumentException("Argument passed is not an instance of NodeInterface"); } $this->children[] = $child; return $this; }
/** * Add the authentication nodes. * * @return NodeInterface * Return itself. */ protected function createAuthNode() { $authHash = []; $authHash["xmlns"] = "urn:ietf:params:xml:ns:xmpp-sasl"; $authHash["mechanism"] = "WAUTH-2"; $authHash["user"] = $this->getIdentity()->getPhone()->getPhoneNumber(); $data = $this->createAuthBlob(); $node = Node::fromArray(['name' => 'auth', 'attributes' => $authHash, 'data' => $data]); return $node; }