/** * This should eventually become a trait and share the functionality with SqrlGenerate * instead of being duplicate code * * @return string */ protected function getUrl($nut) { $url = ($this->configuration->getSecure() ? 's' : '') . 'qrl://' . $this->configuration->getDomain(); if (strpos($this->configuration->getDomain(), '/') !== false) { $extension = strlen($this->configuration->getDomain()) - strpos($this->configuration->getDomain(), '/'); $url .= substr($this->generateQry($nut), $extension) . '&d=' . $extension; } else { $url .= $this->generateQry($nut); } return $url; }
/** * Formats a response to send back to a client * * @param int $code The TIF code to send back to the user * * @return string */ protected function formatResponse($code) { $resp = 'ver=' . implode(',', $this->config->getAcceptedVersions()) . "\r\n" . "nut=" . $this->sqrlGenerator->getNonce($code, $this->authenticationKey, $this->requestNut) . "\r\n" . 'tif=' . strtoupper(dechex($code)) . "\r\n" . "qry=" . $this->sqrlGenerator->generateQry() . "\r\n" . 'sfn=' . $this->config->getFriendlyName(); if (!empty($this->ask)) { $resp .= "\r\nask=" . $this->ask; } if ($this->tif & self::SQRL_DISABLED && !in_array('lock', $this->actions)) { $resp .= "\r\nsuk=" . $this->base64UrlEncode($this->store->getIdentitySUK($this->authenticationKey)); } elseif ($this->tif & self::PREVIOUS_ID_MATCH && !in_array('ident', $this->actions)) { $resp .= "\r\nsuk=" . $this->base64UrlEncode($this->store->getIdentitySUK($this->previousIdKey)); } return $this->base64UrlEncode($resp); }