| 67 | namespace { |
| 68 | #ifndef __EMSCRIPTEN__ |
| 69 | std::string encodeBase64(const std::vector<uint8_t>& bytes) { |
| 70 | const size_t count = modp_b64_encode_len(bytes.size()); |
| 71 | std::string result(count, 0); |
| 72 | const size_t actualLength = modp_b64_encode( |
| 73 | result.data(), |
| 74 | reinterpret_cast<const char*>(bytes.data()), |
| 75 | bytes.size()); |
| 76 | result.resize(actualLength); |
| 77 | |
| 78 | // Convert to a URL-friendly form of Base64 according to the algorithm |
| 79 | // in [RFC7636 Appendix A](https://tools.ietf.org/html/rfc7636#appendix-A) |
| 80 | const size_t firstPaddingIndex = result.find('='); |
| 81 | if (firstPaddingIndex != std::string::npos) { |
| 82 | result.erase(result.begin() + ptrdiff_t(firstPaddingIndex), result.end()); |
| 83 | } |
| 84 | std::replace(result.begin(), result.end(), '+', '-'); |
| 85 | std::replace(result.begin(), result.end(), '/', '_'); |
| 86 | |
| 87 | return result; |
| 88 | } |
| 89 | |
| 90 | std::string createSuccessHtml(const std::string& applicationName) { |
| 91 | return fmt::format( |