diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..886012d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,101 @@ +name: CI + +on: + push: + pull_request: + schedule: + # Nightly build to publish fresh translations from Crowdin + - cron: '0 2 * * *' + workflow_dispatch: + +permissions: + contents: write + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + + - name: Install dependencies + run: npm ci + + - name: Generate source UI strings + run: npm run write-translations -- --locale ru --override + + - name: Push and pull strings from the Crowdin + uses: crowdin/github-action@v2 + if: github.ref == 'refs/heads/master' + with: + upload_sources: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }} + upload_translations: false + download_translations: true + push_translations: false + env: + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + + - name: Fix permissions to the i18n dir + if: github.ref == 'refs/heads/master' + run: sudo chown -R "$USER:$USER" i18n + + - name: Detect locales to publish + if: github.ref == 'refs/heads/master' + run: echo "DOCS_LOCALES=$(node scripts/crowdin-locales.mjs)" >> "$GITHUB_ENV" + env: + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} + + - name: Typecheck + run: npm run typecheck + + - name: Build docs + run: npm run build + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build + path: build + include-hidden-files: true + retention-days: 7 + + - id: detect-diffs + name: Detect diffs + if: github.event_name == 'schedule' + run: | + git fetch origin + if [[ -z "$(git ls-remote --heads origin gh-pages)" ]]; then + echo "::warning::gh-pages branch doesn't exist" + echo "should-continue=false" >> "$GITHUB_OUTPUT" + exit + fi + + tmp_dir=$(mktemp -du) + git worktree add "$tmp_dir" origin/gh-pages + + if diff -qrbB --exclude=.git build "$tmp_dir" > /dev/null; then + echo "should-continue=false" >> "$GITHUB_OUTPUT" + else + echo "should-continue=true" >> "$GITHUB_OUTPUT" + fi + + - name: Deploy to the GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + if: | + (github.event_name == 'push' && github.ref == 'refs/heads/master') || + (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master') || + (github.event_name == 'schedule' && steps.detect-diffs.outputs.should-continue == 'true') + with: + branch: gh-pages + folder: build + single-commit: true diff --git a/.gitignore b/.gitignore index b2d6de3..5156488 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,7 @@ npm-debug.log* yarn-debug.log* yarn-error.log* + +# Translations are downloaded from Crowdin during the CI build and the Russian UI source strings are generated +# by "npm run write-translations -- --locale ru --override" +/i18n/ diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 0000000..02dd1e2 --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,25 @@ +# Russian is the source language. Translations to other languages are downloaded during the CI build. +# The Russian UI strings (navbar, footer) must be generated before uploading the sources: +# npm run write-translations -- --locale ru --override +base_url: https://ely.crowdin.com +project_id: 2 +api_token_env: CROWDIN_PERSONAL_TOKEN +preserve_hierarchy: true + +files: + # Documentation pages + - source: /docs/**/* + translation: /i18n/%two_letters_code%/docusaurus-plugin-content-docs/current/**/%original_file_name% + # Crowdin language => Docusaurus locale (i18n directory name). Must match the localeConfigs + # in docusaurus.config.ts and LOCALES_MAPPING in scripts/crowdin-locales.mjs + languages_mapping: &languages_mapping + two_letters_code: + zh-CN: zh-Hans + + # UI strings: navbar, footer, etc. + - source: /i18n/ru/**/*.json + translation: /i18n/%two_letters_code%/**/%original_file_name% + languages_mapping: *languages_mapping + ignore: + # Strings of the Docusaurus theme itself, they already have translations to most languages + - /i18n/ru/code.json diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 6cb5618..2e09e6c 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -1,9 +1,39 @@ import {themes as prismThemes} from 'prism-react-renderer'; -import type {Config} from '@docusaurus/types'; +import type {Config, I18nLocaleConfig} from '@docusaurus/types'; import type * as Preset from '@docusaurus/preset-classic'; // This runs in Node.js - Don't use client-side code here (browser APIs, JSX...) +// All locales the documentation can be built for. Translations are downloaded from Crowdin during the CI build +const localeConfigs: Record> = { + ru: { + baseUrl: '/ru/', + }, + en: { + baseUrl: '/en/', + }, + 'zh-Hans': { + baseUrl: '/zh/', + htmlLang: 'zh-CN', + }, +}; + +// Locales to build. CI publishes only translations with enough progress (see scripts/crowdin-locales.mjs) +// and passes them via the DOCS_LOCALES env variable, e.g. "ru,en,zh-Hans" +const locales = process.env.DOCS_LOCALES + ? process.env.DOCS_LOCALES.split(',').map((locale) => locale.trim()).filter(Boolean) + : ['ru', 'en']; + +for (const locale of locales) { + if (!(locale in localeConfigs)) { + throw new Error(`Unknown locale "${locale}" in DOCS_LOCALES. Add it to the localeConfigs in docusaurus.config.ts`); + } +} + +if (!locales.includes('ru')) { + locales.unshift('ru'); +} + const config: Config = { title: 'Документация Ely.by', tagline: 'Документация публичных проектов Ely.by', @@ -31,22 +61,12 @@ const config: Config = { }, }, - // Even if you don't use internationalization, you can use this field to set - // useful metadata like html lang. For example, if your site is Chinese, you - // may want to replace "en" with "zh-Hans". i18n: { defaultLocale: 'ru', - locales: ['en', 'ru'], + locales: locales as [string, ...string[]], // Each locale lives under its own prefix to preserve the URLs of the old documentation. // The site root is assembled by the "postbuild" script (see scripts/postbuild.mjs) - localeConfigs: { - ru: { - baseUrl: '/ru/', - }, - en: { - baseUrl: '/en/', - }, - }, + localeConfigs: Object.fromEntries(locales.map((locale) => [locale, localeConfigs[locale]])), }, presets: [ diff --git a/i18n/en/code.json b/i18n/en/code.json deleted file mode 100644 index e99d6cb..0000000 --- a/i18n/en/code.json +++ /dev/null @@ -1,313 +0,0 @@ -{ - "theme.ErrorPageContent.title": { - "message": "This page crashed.", - "description": "The title of the fallback page when the page crashed" - }, - "theme.blog.archive.title": { - "message": "Archive", - "description": "The page & hero title of the blog archive page" - }, - "theme.blog.archive.description": { - "message": "Archive", - "description": "The page & hero description of the blog archive page" - }, - "theme.BackToTopButton.buttonAriaLabel": { - "message": "Scroll back to top", - "description": "The ARIA label for the back to top button" - }, - "theme.blog.paginator.navAriaLabel": { - "message": "Blog list page navigation", - "description": "The ARIA label for the blog pagination" - }, - "theme.blog.paginator.newerEntries": { - "message": "Newer entries", - "description": "The label used to navigate to the newer blog posts page (previous page)" - }, - "theme.blog.paginator.olderEntries": { - "message": "Older entries", - "description": "The label used to navigate to the older blog posts page (next page)" - }, - "theme.blog.post.paginator.navAriaLabel": { - "message": "Blog post page navigation", - "description": "The ARIA label for the blog posts pagination" - }, - "theme.blog.post.paginator.newerPost": { - "message": "Newer post", - "description": "The blog post button label to navigate to the newer/previous post" - }, - "theme.blog.post.paginator.olderPost": { - "message": "Older post", - "description": "The blog post button label to navigate to the older/next post" - }, - "theme.tags.tagsPageLink": { - "message": "View all tags", - "description": "The label of the link targeting the tag list page" - }, - "theme.colorToggle.ariaLabel": { - "message": "Switch between dark and light mode (currently {mode})", - "description": "The ARIA label for the navbar color mode toggle" - }, - "theme.colorToggle.ariaLabel.mode.dark": { - "message": "dark mode", - "description": "The name for the dark color mode" - }, - "theme.colorToggle.ariaLabel.mode.light": { - "message": "light mode", - "description": "The name for the light color mode" - }, - "theme.docs.breadcrumbs.navAriaLabel": { - "message": "Breadcrumbs", - "description": "The ARIA label for the breadcrumbs" - }, - "theme.docs.DocCard.categoryDescription.plurals": { - "message": "1 item|{count} items", - "description": "The default description for a category card in the generated index about how many items this category includes" - }, - "theme.docs.paginator.navAriaLabel": { - "message": "Docs pages", - "description": "The ARIA label for the docs pagination" - }, - "theme.docs.paginator.previous": { - "message": "Previous", - "description": "The label used to navigate to the previous doc" - }, - "theme.docs.paginator.next": { - "message": "Next", - "description": "The label used to navigate to the next doc" - }, - "theme.docs.tagDocListPageTitle.nDocsTagged": { - "message": "One doc tagged|{count} docs tagged", - "description": "Pluralized label for \"{count} docs tagged\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" - }, - "theme.docs.tagDocListPageTitle": { - "message": "{nDocsTagged} with \"{tagName}\"", - "description": "The title of the page for a docs tag" - }, - "theme.docs.versionBadge.label": { - "message": "Version: {versionLabel}" - }, - "theme.docs.versions.unreleasedVersionLabel": { - "message": "This is unreleased documentation for {siteTitle} {versionLabel} version.", - "description": "The label used to tell the user that he's browsing an unreleased doc version" - }, - "theme.docs.versions.unmaintainedVersionLabel": { - "message": "This is documentation for {siteTitle} {versionLabel}, which is no longer actively maintained.", - "description": "The label used to tell the user that he's browsing an unmaintained doc version" - }, - "theme.docs.versions.latestVersionSuggestionLabel": { - "message": "For up-to-date documentation, see the {latestVersionLink} ({versionLabel}).", - "description": "The label used to tell the user to check the latest version" - }, - "theme.docs.versions.latestVersionLinkLabel": { - "message": "latest version", - "description": "The label used for the latest version suggestion link label" - }, - "theme.common.editThisPage": { - "message": "Edit this page", - "description": "The link label to edit the current page" - }, - "theme.common.headingLinkTitle": { - "message": "Direct link to {heading}", - "description": "Title for link to heading" - }, - "theme.lastUpdated.atDate": { - "message": " on {date}", - "description": "The words used to describe on which date a page has been last updated" - }, - "theme.lastUpdated.byUser": { - "message": " by {user}", - "description": "The words used to describe by who the page has been last updated" - }, - "theme.lastUpdated.lastUpdatedAtBy": { - "message": "Last updated{atDate}{byUser}", - "description": "The sentence used to display when a page has been last updated, and by who" - }, - "theme.navbar.mobileVersionsDropdown.label": { - "message": "Versions", - "description": "The label for the navbar versions dropdown on mobile view" - }, - "theme.NotFound.title": { - "message": "Page Not Found", - "description": "The title of the 404 page" - }, - "theme.tags.tagsListLabel": { - "message": "Tags:", - "description": "The label alongside a tag list" - }, - "theme.admonition.caution": { - "message": "caution", - "description": "The default label used for the Caution admonition (:::caution)" - }, - "theme.admonition.danger": { - "message": "danger", - "description": "The default label used for the Danger admonition (:::danger)" - }, - "theme.admonition.info": { - "message": "info", - "description": "The default label used for the Info admonition (:::info)" - }, - "theme.admonition.note": { - "message": "note", - "description": "The default label used for the Note admonition (:::note)" - }, - "theme.admonition.tip": { - "message": "tip", - "description": "The default label used for the Tip admonition (:::tip)" - }, - "theme.admonition.warning": { - "message": "warning", - "description": "The default label used for the Warning admonition (:::warning)" - }, - "theme.AnnouncementBar.closeButtonAriaLabel": { - "message": "Close", - "description": "The ARIA label for close button of announcement bar" - }, - "theme.blog.sidebar.navAriaLabel": { - "message": "Blog recent posts navigation", - "description": "The ARIA label for recent posts in the blog sidebar" - }, - "theme.CodeBlock.copied": { - "message": "Copied", - "description": "The copied button label on code blocks" - }, - "theme.CodeBlock.copyButtonAriaLabel": { - "message": "Copy code to clipboard", - "description": "The ARIA label for copy code blocks button" - }, - "theme.CodeBlock.copy": { - "message": "Copy", - "description": "The copy button label on code blocks" - }, - "theme.CodeBlock.wordWrapToggle": { - "message": "Toggle word wrap", - "description": "The title attribute for toggle word wrapping button of code block lines" - }, - "theme.DocSidebarItem.expandCategoryAriaLabel": { - "message": "Expand sidebar category '{label}'", - "description": "The ARIA label to expand the sidebar category" - }, - "theme.DocSidebarItem.collapseCategoryAriaLabel": { - "message": "Collapse sidebar category '{label}'", - "description": "The ARIA label to collapse the sidebar category" - }, - "theme.NavBar.navAriaLabel": { - "message": "Main", - "description": "The ARIA label for the main navigation" - }, - "theme.navbar.mobileLanguageDropdown.label": { - "message": "Languages", - "description": "The label for the mobile language switcher dropdown" - }, - "theme.NotFound.p1": { - "message": "We could not find what you were looking for.", - "description": "The first paragraph of the 404 page" - }, - "theme.NotFound.p2": { - "message": "Please contact the owner of the site that linked you to the original URL and let them know their link is broken.", - "description": "The 2nd paragraph of the 404 page" - }, - "theme.TOCCollapsible.toggleButtonLabel": { - "message": "On this page", - "description": "The label used by the button on the collapsible TOC component" - }, - "theme.blog.post.readMore": { - "message": "Read more", - "description": "The label used in blog post item excerpts to link to full blog posts" - }, - "theme.blog.post.readMoreLabel": { - "message": "Read more about {title}", - "description": "The ARIA label for the link to full blog posts from excerpts" - }, - "theme.blog.post.readingTime.plurals": { - "message": "One min read|{readingTime} min read", - "description": "Pluralized label for \"{readingTime} min read\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" - }, - "theme.docs.breadcrumbs.home": { - "message": "Home page", - "description": "The ARIA label for the home page in the breadcrumbs" - }, - "theme.docs.sidebar.collapseButtonTitle": { - "message": "Collapse sidebar", - "description": "The title attribute for collapse button of doc sidebar" - }, - "theme.docs.sidebar.collapseButtonAriaLabel": { - "message": "Collapse sidebar", - "description": "The title attribute for collapse button of doc sidebar" - }, - "theme.docs.sidebar.navAriaLabel": { - "message": "Docs sidebar", - "description": "The ARIA label for the sidebar navigation" - }, - "theme.docs.sidebar.closeSidebarButtonAriaLabel": { - "message": "Close navigation bar", - "description": "The ARIA label for close button of mobile sidebar" - }, - "theme.navbar.mobileSidebarSecondaryMenu.backButtonLabel": { - "message": "← Back to main menu", - "description": "The label of the back button to return to main menu, inside the mobile navbar sidebar secondary menu (notably used to display the docs sidebar)" - }, - "theme.docs.sidebar.toggleSidebarButtonAriaLabel": { - "message": "Toggle navigation bar", - "description": "The ARIA label for hamburger menu button of mobile navigation" - }, - "theme.docs.sidebar.expandButtonTitle": { - "message": "Expand sidebar", - "description": "The ARIA label and title attribute for expand button of doc sidebar" - }, - "theme.docs.sidebar.expandButtonAriaLabel": { - "message": "Expand sidebar", - "description": "The ARIA label and title attribute for expand button of doc sidebar" - }, - "theme.blog.post.plurals": { - "message": "One post|{count} posts", - "description": "Pluralized label for \"{count} posts\". Use as much plural forms (separated by \"|\") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)" - }, - "theme.blog.tagTitle": { - "message": "{nPosts} tagged with \"{tagName}\"", - "description": "The title of the page for a blog tag" - }, - "theme.blog.author.pageTitle": { - "message": "{authorName} - {nPosts}", - "description": "The title of the page for a blog author" - }, - "theme.blog.authorsList.pageTitle": { - "message": "Authors", - "description": "The title of the authors page" - }, - "theme.blog.authorsList.viewAll": { - "message": "View all authors", - "description": "The label of the link targeting the blog authors page" - }, - "theme.blog.author.noPosts": { - "message": "This author has not written any posts yet.", - "description": "The text for authors with 0 blog post" - }, - "theme.contentVisibility.unlistedBanner.title": { - "message": "Unlisted page", - "description": "The unlisted content banner title" - }, - "theme.contentVisibility.unlistedBanner.message": { - "message": "This page is unlisted. Search engines will not index it, and only users having a direct link can access it.", - "description": "The unlisted content banner message" - }, - "theme.contentVisibility.draftBanner.title": { - "message": "Draft page", - "description": "The draft content banner title" - }, - "theme.contentVisibility.draftBanner.message": { - "message": "This page is a draft. It will only be visible in dev and be excluded from the production build.", - "description": "The draft content banner message" - }, - "theme.ErrorPageContent.tryAgain": { - "message": "Try again", - "description": "The label of the button to try again rendering when the React error boundary captures an error" - }, - "theme.common.skipToMainContent": { - "message": "Skip to main content", - "description": "The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation" - }, - "theme.tags.tagsPageTitle": { - "message": "Tags", - "description": "The title of the tag list page" - } -} diff --git a/i18n/en/docusaurus-plugin-content-docs/current.json b/i18n/en/docusaurus-plugin-content-docs/current.json deleted file mode 100644 index dd30528..0000000 --- a/i18n/en/docusaurus-plugin-content-docs/current.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "version.label": { - "message": "Next", - "description": "The label for version current" - } -} diff --git a/i18n/en/docusaurus-plugin-content-docs/current/api.md b/i18n/en/docusaurus-plugin-content-docs/current/api.md deleted file mode 100644 index aa650aa..0000000 --- a/i18n/en/docusaurus-plugin-content-docs/current/api.md +++ /dev/null @@ -1,111 +0,0 @@ -# Ely.by API (Mojang API simulation) {#ely-by-api-mojang-api} - -This article contains information about the API compatible with the [Mojang API](http://wiki.vg/Mojang_API) functionality. Please note that this is not a full-fledged API of Ely.by, but only a set of additional requests implemented based on our `[authorization server](./minecraft-auth.mdx)`. - -## Requests {#requests} -:::note -The API has no rate limit. We just have a configured fail2ban that will ban especially annoying clients. That’s the way. -::: - -This section will describe the requests and their corresponding variants for Mojang API. Base URL for requests is `https://authserver.ely.by`. - - - -### UUID by username at a time {#uuid-by-username} -This request allows you to find out the UUID of a user by their username at a specified point in time. The time is specified via GET parameter at as a Unix timestamp. - -> **GET /api/users/profiles/minecraft/\{username\}** -> -> Where `{username}` is the searched username. It can be passed in any case (in the Mojang API, only strict match). -> Note that the legacy and demo params will never be returned, as these parameters have no alternative in Ely and are specific only for Mojang services. - -In case of a successful request you will receive the following response: -```json -{ - "id": "ffc8fdc95824509e8a57c99b940fb996", - "name": "ErickSkrauch" -} -``` - -When the passed username isn’t found, you will receive a response with `204` status code and an empty body. - -### Username by UUID + history of changes {#username-by-uuid} -This request allows you to find out all usernames used by a user by their UUID. - -> **GET /api/user/profiles/\{uuid\}/names** -> -> Where `{uuid}` is a valid UUID. UUID might be written with or without hyphens. If an invalid string is passed, [IllegalArgumentException](#illegal-argument-exception) will be returned with the message `"Invalid uuid format."`. - -In case of a successful request you will receive the following response: -```json -[ - { - "name": "Admin" - }, - { - "name": "ErickSkrauch", - "changedToAt": 1440707723000 - } -] -``` - -:::note -Since Ely.by doesn’t store the moment of username change only 1 username will always be returned. We may add full support for remembering when a username was changed in the future. -::: - -When the passed UUID isn’t found, you will receive a response with `204` status code and an empty body. - -### Usernames list to their UUIDs {#usernames-to-uuids} -This request allows you to query a list of users’ UUIDs by their usernames. - -> **POST /api/profiles/minecraft** -> -> In the request body or POST parameters you need to pass a valid JSON array of the searched usernames. -> -> The array must contain no more than 100 usernames, otherwise [IllegalArgumentException](#illegal-argument-exception) will be returned with the message `"Not more than that 100 profile names per call is allowed."`. In case the passed string is an invalid JSON object, the same exception will be returned, but with the text `"Passed array of profile names is an invalid JSON string."`. -> -> Example of a request body: -> ```json -> ["ErickSkrauch", "EnoTiK", "KmotherfuckerF"] -> ``` - -In case of a successful request you will receive the following response: -```json -[ - { - "id": "ffc8fdc95824509e8a57c99b940fb996", - "name": "ErickSkrauch" - }, - { - "id": "b8407ae8218658ef96bb0cb3813acdfd", - "name": "EnoTiK" - }, - { - "id": "39f42ba723de56d98867eabafc5e8e91", - "name": "KmotherfuckerF" - } -] -``` - -The data is returned in the same order they were requested. - -If one of the passed usernames isn’t found in the database, no value will be returned for it (it will be skipped). Keep this in mind when parsing the response. - -### Profile info by UUID {#profile-by-uuid} -See the `[profile request for the authorization server](./minecraft-auth.mdx#profile-request)`. - -## Possible errors {#possible-errors} - - - -### IllegalArgumentException {#illegal-argument-exception} -This error occurs when attempting to send data to the server in an incorrect format. - -An error example: -```json -{ - "error": "IllegalArgumentException", - "errorMessage": "Invalid uuid format." -} -``` -The `errorMessage` is not always matches Mojang’s strings, but the differences are only apparent to Ely-specific errors. The original requests and the errors expected from them repeat Mojang texts. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/authlib-injector.md b/i18n/en/docusaurus-plugin-content-docs/current/authlib-injector.md deleted file mode 100644 index 01e9375..0000000 --- a/i18n/en/docusaurus-plugin-content-docs/current/authlib-injector.md +++ /dev/null @@ -1,59 +0,0 @@ -# Authlib-Injector {#authlib-injector} -**authlib-injector** is a library that allows you to spoof authorization and session server addresses in the Authlib without modifying the library itself. It’s designed as an javaagent. - -This library significantly simplifies the installation of an alternative authorization service in the game client and server, since transformation occurs during application bootstrap process. - -You can download the latest version from the [releases page on GitHub](https://github.com/yushijinhun/authlib-injector/releases/latest). - -Here is the documentation of the key aspects of installing and using the library. For more information, see the [original documentation in Chinese](https://github.com/yushijinhun/authlib-injector/wiki). - -## Installing in a game client {#client} -:::warning -This section describes how to install the **authlib-injector** into the game. The game launcher still needs to implement the authorization flow itself in order to pass the `accessToken` to the game. -::: - -To install the library, you need to specify it as a javaagent for the game. You can do this by prepending the line `-javaagent:/path/to/file/authlib-injector.jar=ely.by` as a game launching param. As the result, the launch command should look like this: -```bash -java -javaagent:/path/to/authlib-injector.jar=ely.by -jar minecraft.jar -``` -If you run the game via launcher, then in “settings” you need to find a field for specifying additional JVM arguments, where you need to insert the line above. - -![Minecraft Launcher settings with -javaagent... argument in the JVM Arguments field](/img/launcher-jvm-options.png) - -## Installing on a server {#server} -Just as in the case with the game client, the library must be specified as javaagent. [Download the library](https://github.com/yushijinhun/authlib-injector/releases/latest) and put in the server’s directory. Then add the javaagent call to the server launch command: -```bash -# Before -java -jar minecraft_server.jar -# After -java -javaagent:authlib-injector.jar=ely.by -jar minecraft_server.jar -``` -During server startup you should see a message about the activation of the authlib-injector: - -![Authlib-injector log strings at the server startup](/img/server-startup-messages.png) - -### BungeeCord {#bungeecord} -The authlib-injector must be installed directly on the BungeeCord itself, as well as **on all backends** behind it. Note the configuration of the online-mode parameter: -* The BungeeCord’s configuration (`config.yml`) should contain `online_mode=true`. -* The servers behind the proxy must contain in their configuration (`server.properties`) the value `online-mode=false`. - -Using such configuration authorization will work for all logging in players and the internal servers will correctly display player skins. - -### LaunchHelper {#launchhelper} -Not all game hostings allow direct modifications of launch arguments. To get around this limitation, you can use a special server that runs the game server by mixing authlib-injector into it. To install, follow these instructions: - -1. Download the corresponding LaunchHelper for your operating system from the [releases page](https://github.com/Codex-in-somnio/LaunchHelper/releases/latest). -1. Upload this file and the `authlib-injector.jar` file to the server folder on your hosting site. -1. Also create a `launchhelper.properties` file and put the following contents into it: - ```properties - javaAgentJarPath=authlib-injector.jar - javaAgentOptions=ely.by - execJarPath=minecraft_server.jar - ``` - Where `javaAgentJarPath` contains the path to the `authlib-injector.jar` file and `execJarPath` contains the name of the server file. -1. In the hosting control panel, specify the `LaunchHelper.jar` as the server file. -If you can’t change the executable file, you should rename the `LaunchHelper.jar` file to match your hosting requirements (usually, `server.jar`). In this case, you should have the following file structure: - * `server.jar` - the LaunchHelper file. - * `minecraft_server.jar` - your server core. - * `authlib-injector.jar` - the authlib-injector file. - * `launchhelper.properties` - the configuration file for the LaunchHelper. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/intro.md b/i18n/en/docusaurus-plugin-content-docs/current/intro.md deleted file mode 100644 index 61125fe..0000000 --- a/i18n/en/docusaurus-plugin-content-docs/current/intro.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -slug: / ---- -# Welcome to the Ely.by documentation! {#welcome} - -In this documentation you will find information about the public services of the Ely.by project, using which you’ll be able to integrate your projects with the Ely.by services. - -You are free to improve this documentation in the documentation’s repository. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/minecraft-auth.mdx b/i18n/en/docusaurus-plugin-content-docs/current/minecraft-auth.mdx deleted file mode 100644 index d7c8605..0000000 --- a/i18n/en/docusaurus-plugin-content-docs/current/minecraft-auth.mdx +++ /dev/null @@ -1,330 +0,0 @@ -# Authentication for Minecraft {#minecraft} -This article contains information on authentication in Minecraft launchers and servers via the Ely.by authorization service. - -The authentication protocol is implemented as similar as possible to the [original Mojang authentication protocol](http://wiki.vg/Authentication), but this documentation describes all features specific to the Ely.by service. - -## General Provisions {#definitions} -* All requests must be sent to `https://authserver.ely.by`. -* A successful response will have a `200` status code. Any other code indicates an error. -* The server always responds with JSON data, except for system errors and legacy requests. Use this to display proper error messages. -* Standard error response format: - ```json - { - "error": "Short error description", - "errorMessage": "Detailed error message in English for user display." - } - ``` - -### Expected Errors {#errors} -Unlike the original protocol, Ely.by uses a simplified set of errors: - -#### IllegalArgumentException {#illegal-argument-exception} -**Cause**: Incomplete or incorrect request parameters. -**Solution**: Verify the request against the documentation. - -#### ForbiddenOperationException {#forbidden-operation-exception} -**Cause**: Invalid user input or developer-provided data. -**Solution**: Prompt the user to correct their input. - -#### Not Found {#not-found} -Indicated by a `404` status response. - -## Authentication in the Launcher {#launcher} -This section describes obtaining an `accessToken` for the Minecraft client. Successful authentication returns a **JWT token** with the `minecraft_server_session` [scope](./oauth.md#available-scopes). - -:::warning -We recommend using the [OAuth 2.0 protocol](./oauth.md) with the `minecraft_server_session` scope for better security and user experience. -::: - -### User Authentication {#auth-authenticate} -Direct authentication using username/email, password, and optional 2FA token. - -> **POST /auth/authenticate** -> -> **Parameters**: -> * **username** (*string*): User's nickname or email (preferred). -> * **password** (*string*): Password or `password:token` combination for 2FA. -> * **clientToken** (*string*): Unique launcher identifier. -> * **requestUser** (*bool*): Include `user` field in response if `true`. - -The Ely.by accounts system supports additional user security with two-factor authentication. The Mojang’s authentication protocol doesn’t provide the possibility to pass TOTP tokens. To solve this problem and maintain compatibility with Yggdrasil’s server implementation, we suggest passing the token in the password field as password:token. - -Unfortunately, not all users are aware of this feature, so it would be better to explicitly request the user’s token and concatenate it in the code when receiving an error about the user’s account being protected by two-factor authentication. - -The logic is as follows: -1. If the account has 2FA enabled, a `401` error is returned: - ```json - { - "error": "ForbiddenOperationException", - "errorMessage": "Account protected with two factor auth." - } - ``` -2. Upon receiving this error, you should ask the user to enter a TOTP token, and then repeat the authentication request with the same credentials, adding a postfix to the password in the form `:token`, where token is the value entered by the user. -If the user’s password was “password123” and the token was “123456”, the `password` field value will become “password123:123456” after concatenating. -3. If as a result of these actions you get a response with `401` status and `errorMessage` “Invalid credentials. Invalid email or password.”, it will indicate that the token passed is incorrect and must be re-requested from the user. - -If all data is passed correctly, you will receive the following response: -```json -{ - "accessToken": "long_access_token_string", - "clientToken": "provided_client_token", - "availableProfiles": [ - { - "id": "user_uuid_without_dashes", - "name": "current_username" - } - ], - "selectedProfile": { - "id": "user_uuid_without_dashes", - "name": "current_username" - }, - "user": { /* Included if requestUser is set */ - "id": "user_uuid_without_dashes", - "username": "current_username", - "properties": [ - { - "name": "preferredLanguage", - "value": "ru" - } - ] - } -} -``` - -### Token Refresh {#auth-refresh} -Renew a valid `accessToken` without requiring the user's password. - -> **POST /auth/refresh** -> -> **Parameters**: -> * **accessToken** (*string*): Current access token. -> * **clientToken** (*string*): Client identifier. -> * **requestUser** (*bool*): Include `user` field in response if `true`. - -:::note -The original protocol also passes the value of `selectedProfile`, but in Mojang’s implementation it doesn’t affect anything. Our authentication server implementation ignores this parameter and relies on `accessToken` and `clientToken` values. -::: - -If you receive any of the provided errors, you should re-request the user password and perform normal authentication. - -Successful response: -```json -{ - "accessToken": "new_access_token_string", - "clientToken": "provided_client_token", - "selectedProfile": { - "id": "user_uuid_without_dashes", - "name": "current_username" - }, - "user": { /* Included if requestUser=true */ - "id": "user_uuid_without_dashes", - "username": "current_username", - "properties": [ - { - "name": "preferredLanguage", - "value": "ru" - } - ] - } -} -``` - -### Token Validation {#auth-validate} -This request allows you to check whether the specified accessToken is valid or not. This request does not update the token or its lifetime, but only makes sure that it is still valid. - -> **POST /auth/validate** -> -> **Parameters**: -> * **accessToken** (*string*): The access token received after authentication. - -AA successful response will be an empty body. An error will result in a `400` or `401` status. Example of server response when sending an expired token: -```json -{ - "error": "ForbiddenOperationException", - "errorMessage": "Token expired." -} -``` - -### Invalidate All User Tokens {#auth-signout} -Invalidate all tokens issued to a user. - -> **POST /auth/signout** -> -> **Parameters**: -> * **username** (*string*): User's username or email (preferred). -> * **password** (*string*): User's password. - -A successful response will be an empty body. Refer to the `error` field in the response body. - -### Invalidate Specific Token {#auth-invalidate} -The request allows you to invalidate the **accessToken**. In case the passed token cannot be found in the token store, **no error will be generated** and you will receive a successful response. - -> **POST /auth/invalidate** -> -> **Parameters**: -> * **accessToken** (*string*): A unique key obtained after authentication. -> * **clientToken** (*string*): The unique identifier of the client with respect to which the accessToken was received. - -A successful response will be an empty body. Refer to the `error` field in the response body. - -## Server Authentication {#server} -These requests are executed directly by the client and server using internal code or the authlib library (since version 1.7.2). They are only relevant if you have already authorized and run the game with a valid accessToken. You only need to replace the paths inside the game/library with the paths below. - -Since you cannot directly change anything in authlib or the game, the values passed and server responses are not given here. If necessary, you can find this information yourself on the internet. - -### Via Authlib {#authlib} -:::info -This part of the documentation describes the requests executed via authlib in game version 1.7.2+. For older versions, see [the section below](#legacy). -::: - -All requests in this category are executed on the `/session` sublayer. Each request is preceded by the type of request to be sent. - -> **POST /session/join** -> -> A request to this URL is sent by the client at the time of connection to the server that has online-mode=true. - -> **GET /session/hasJoined** -> -> The request to this URL is sent by the server that has online-mode=true after the client tries to connect to it completes the join request. The textures will be signed with the Ely.by key. - -:::tip -The signature verification key can be obtained from the [skins system](./skins-system.md#signature-verification-key-request). -:::danger -In rare cases the `signature` property will have the value `Cg==`. If the signature field has such value, there is no need to verify it, because it will always be incorrect. -::: - -### For older versions {#legacy} -:::info -This part of the documentation describes requests sent by older versions of Minecraft where the Authlib library wasn’t used. These include all versions below 1.7.2. -::: - -All requests in this category are executed on the `/session/legacy` sublayer. Each request is preceded by the type of request to be sent. - -The principle of processing these requests is the same as for **the authlib**, the only difference is in the input parameters and return values. - -> **GET /session/legacy/join** -> -> A request to this URL is sent by the client at the time of connection to the server that has online-mode=true. - -> **GET /session/legacy/hasJoined?user=** -> -> The request to this URL is sent by the server that has online-mode=true after the client trying to connect to it successfully completes the join request. - -It is important not to forget the GET parameter ?user= at the end of both requests to get the following URLs: `http://minecraft.ely.by/session/legacy/hasJoined?user=`. - -## Single Player {#singleplayer} -In essence, a single-player game is a local server created for a single player. At least it has been so since version 1.6, in which the local server mechanism was introduced. - -However, the following request is relevant only for Minecraft 1.7.6+, when Authlib started to be used for loading skins. - -### Profile Request {#profile-request} -> **GET /session/profile/\{uuid\}** -> -> A request to this URL is sent by the client in a single-player game on a local server (created through the game itself). The UUID of the user with whom the client was launched is passed to the URL, and the response is information about the player’s textures in the same format as the `hasJoined` request. - -## Prebuilt Authlib Libraries {#premade-authlib} -:::tip -Ely.by supports the authlib-injector library. This is the simplest and most universal way to install the authentication system in the game and its servers. For details, see [the corresponding documentation section](./authlib-injector.md). -::: - -Since manual implementation has difficulties in finding sources, connecting dependencies and finally compiling the result, on the [download page of our skin system](https://ely.by/load) you can download pre-built libraries with all necessary modifications. Select the desired version from the drop-down list and follow the installation instructions on the same page below. - -In earlier versions of the game, the skin system was inside the game client, so the libraries below only provide authentication: -- Minecraft 1.7.5: [authlib 1.3.1](/authlib/authlib-1.3.1.jar) -- Minecraft 1.7.2: [authlib 1.3](/authlib/authlib-1.3.jar) - -To install, you need to replace the original library located at `/libraries/com/mojang/authlib/`. Make sure that the versions of the already present and replacement files match. -:::warning -Many launchers and server startup scripts check the integrity of the game files at startup and may not allow such modification -::: - - - -### Installing Authlib on a server {#authlib-server} -The server also uses **authlib** to perform player authentication, so the appropriate changes should be applied to it as well. Below are instructions on how to install **authlib** for different Minecraft server implementations. - - - -### Vanilla Server {#authlib-server-vanilla} -Use an archiver to open the server file `minecraft_server.VERSION.jar`. In the same way, open the archive with authlib for the corresponding server version. You will see two windows in front of you: one with the server files, the other with the authlib files. You need to “drag and drop” all files and folders from the authlib archive, **except for the META-INF** directory, and confirm the replacement. -
-![Installing Authlib](/img/authlib-install.png) -
Please note: you should “drag and drop” the content below the server folders (into the .class file area).
-
-After these steps, you can close both windows and set `online-mode=true` in the `server.properties` file. - - - -### Bukkit/Spigot {#authlib-server-spigot} -First perform the installation as described for the [original server](#authlib-server-vanilla). Then download the libraries [commons-io](https://repo1.maven.org/maven2/commons-io/commons-io/2.5/commons-io-2.5.jar) and [commons-lang3](https://repo1.maven.org/maven2/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar), and then move the contents of the downloaded archives into the server files in the same way as authlib - - - -### Forge/Sponge {#authlib-server-forge} -Before performing the installation, it is necessary to determine which file is to be modified: -- **≥1.16**: Modify `libraries/net/minecraft/server/VERSION-DIGITS/server-VERSION-DIGITS-extra.jar`. -- **1.13-1.15**: Modify `libraries/net/minecraft/server/VERSION/server-VERSION-extra.jar`. -- **\≤1.12**: Modify `minecraft_server.VERSION.jar`. - -When the required file is found, perform an authlib installation for it, similar to [original server](#authlib-server-vanilla). - - - -### Paper (PaperSpigot) {#authlib-server-paper} -Installation is done similarly to [Bukkit/Spigot](#authlib-server-spigot) into the `cache/patched-VERSION.jar` file. After making changes, the server must be started via the jar file from the cache directory, because otherwise Paper will restore the original state of the file: -```bash -# Before -java -jar paper-ВЕРСИЯ-БИЛД.jar -# After -java -jar cache/patched-ВЕРСИЯ.jar -``` - - - -### BungeeCord {#authlib-server-bungeecord} -:::tip -You can use the [authlib-injector](./authlib-injector.md) library to install the authentication system without modifying the server internals. -::: - -Although BungeeCord is a proxy server, it performs player authentication on its own. Unfortunately, BungeeCord does not rely on Authlib, but implements the authentication process by itself, so you will need to modify the compiled `.class` files to install the Ely.by authentication system. - -Follow the instructions below to install: -1. Download the InClassTranslator program (we don’t give direct links, but it’s easy to find). -2. Use an archiver to open the `BungeeCord.jar` file. -3. Go to the path `net/md_5/bungee/connection` and find there the file `InitialHandler.class` (without any $ symbols). -4. Unpack this file. In the simplest case you can do it by simply “pulling” it out of the archiver window. -5. Open the extracted file in the InClassTranslator program and replace the line `https://sessionserver.mojang.com/session/minecraft/hasJoined?username=` with `https://authserver.ely.by/session/hasJoined?username=` as shown in the figure below: - ![Replacing the string using InClassTranslator](/img/bungeecord_inclasstranslator.png) -6. Save the changes and drag the modified file back into the server archive. Confirm the replacement. - ![Packing class-file into the jar file](/img/bungeecord_move.png) - -After performing these steps, you can specify the value `online_mode=true` in the BungeeCord configuration file (`config.yml`). - -:::info -We also recommend performing an Authlib installation on all servers behind BungeeCord. This may be necessary for plugins that use the Mojang API. Instructions for installing on proxied servers are given [above](#authlib-server). - -All servers must have `online-mode=false` in their configuration (`server.properties`), since users are already authorized by BungeeCord. -::: - -## Installation on versions below 1.7.2 {#install-legacy} -For older versions there are quite a large variety of different cases, and it is not possible to cover them in this documentation. The whole setup consists of replacing certain strings in certain classes via **InClassTranslator**. - -There is a [great post](http://www.rubukkit.org/threads/spisok-klassov-i-klientov-dlja-mcp.25108/#post-303710) (warning: in Russian, use any translator!) on the RuBukkit forum, which contains all the necessary information on class names on different versions of Minecraft. There is no point in retyping it here, so just go to its page and find the right version - -### Installation example {#install-legacy-example} -Suppose you want to install authentication on a server with version **1.5.2**. - -First you follow the link above, select the version you want (1.5.2) and see the list of classes: -* `bdk.class` - path to `joinserver` -* `jg.class` - path to `checkserver` - -Then you have to take the .jar file of the client and open it with any archiver. After that you need to find the **bdk.class** file. For this purpose it is convenient to use search. -Once you have found the file, you need to extract it from the archive - just drag and drop it from there to a convenient dirctory. -Next, run **InClassTranslator** and open this class in it. On the left will be a list of lines found in the file, which you can change. You only need to change the line responsible for the request to connect to the server: - -![](/img/installing_by_inclasstranslator.png) -After that, you need to put the modified .class back into the game’s .jar file. - -You need to perform the same operation with the server, only replace the reference with `hasJoined`. - -After these actions you need to enable `online-mode=true` in the settings and the server will allow only those players who will be authorized through Ely.by. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/oauth.md b/i18n/en/docusaurus-plugin-content-docs/current/oauth.md deleted file mode 100644 index 6a92d75..0000000 --- a/i18n/en/docusaurus-plugin-content-docs/current/oauth.md +++ /dev/null @@ -1,264 +0,0 @@ -# Authorization via OAuth2 protocol {#oauth2} -On this page you’ll find how to implement OAuth2 authorization on your project through the Ely.by Accounts service. The implementation of this protocol will allow your users to authorize using their Ely.by account. - -## Application registration {#app-registration} -First you need to [create a new application](https://account.ely.by/dev/applications/new). Select **Website** as the application type. For the Redirect URI you can get away with just specifying the domain, but to increase security it’s advised to use the full redirect path. Here are examples of valid addresses: -* `https://example.com` -* `https://example.com/oauth/ely` -* `https://example.com/oauth.php?provider=ely` - -After a successful creation of an application, you’ll be taken to the page containing a list of all your applications. If you click on the name of an application you’ll see its `clientId` identifier and its `clientSecret` secret. They’ll become important in later steps. - -## Authorization initiation {#auth-init} -To initiate the authorization flow, you’ll have to redirect the user to the following URL: -```url -https://account.ely.by/oauth2/v1?client_id=&redirect_uri=&response_type=code&scope= -``` - -After creating the link, place it in your template: -```html -Login using Ely.by -``` -After clicking on the URL a user will be redirected to our login page after which they’ll be redirected back to the address specified in the `redirect_uri` parameter. - -Reverse redirection returns as `?code=&state=` for a successful authorization and `?error=&error_message=` for a failed one. - -Examples of successful and unsuccessful redirects: -```url -https://example.com/oauth/ely.php?code=dkpEEVtXBdIcgdQWak4SOPEpTJIvYa8KIq5cW9GJ&state=ajckasdcjasndckbsadc -https://example.com/oauth/ely.php?error=access_denied&error_message=The+resource+owner+or+authorization+server+denied+the+request. -``` - -### Valid query parameters {#auth-init-params} -| **Parameter** | **Example value** | **Description** | -|--------------------|-----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| *clientId* | `ely` | **Required**. ClientId that was received during registration. | -| *redirect_uri* | `http://site.com/oauth.php` | **Required**. Return-forwarding address, which matches the address specified during the application registration. приложения. | -| *response_type* | `code` | **Required**. Response type. At the moment, only `code` is supported. | -| *scope* | `account_info account_email` | **Required**. The list of permissions that you want to access, separated by spaces. See all available permissions in the [section below](#available-scopes). | -| *state* | `isfvubuysdboinsbdfvit` | Randomly generated string. Used as a session identifier to increase security. Will be returned unchanged after authorization is completed. | -| *description* | `यो अनुप्रयोग विवरण` | If your application is available in several languages, you can use this field to override the default description in accordance with user’s preferred language. | -| *prompt* | `consent` или `select_account` | Forcibly display the request for permissions (`consent`) or forcibly request an account selection (`select_account`). | -| *login_hint* | `erickskrauch` или `erickskrauch@ely.by` | If a user has several accounts, then specifying username or user email in this parameter will automatically select corresponding account. This is useful in a case of re-login after the token has expired. | - -### List of available scopes {#available-scopes} - -| **Scope** | **Description** | -|------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| **account_info** | Get user information. | -| **account_email** | Response to a request for user information will also contain user’s E-mail address. | -| **offline_access** | With an access_token you will also recieve a refresh_token. See more at [the corresponding section](#refresh-token). | -| **minecraft_server_session** | It will be possible to use `access_token` as a session identifier for the Minecraft. | - - - -## Exchange auth code for a access key {#access_key} -After receiving an authorization code (`auth_code`), you’ll need to exchange it for an authorization key (`access_key`). To do this, you must perform a POST request to the URL: -```url -https://account.ely.by/api/oauth2/v1/token -``` -And pass in following parameters: -* **client_id**: ClientID that was received during registration. -* **client_secret**: ClientSecret that was received during application registration. -* **redirect_uri**: The exact URI that was used for user redirection. -* **grant_type**: In this case, `authorization_code` should be used. -* **code**: Authorization code received in GET params after successful redirect. - -```php title="An example of the exchange in PHP" - 'ely', // Your ClientId received during registration. - 'client_secret' => 'Pk4uCtZw5WVlSUpvteJuTZkVqHXZ6aNtTaLPXa7X', // Your ClientSecret received at registration. - 'redirect_uri' => 'http://someresource.by/oauth/some.php', // The address you expect to get the user back to (current url). - 'grant_type' => 'authorization_code', -]; - -// If an error occurs, abort the script execution. -if (isset($_GET['error'])) { - echo $_GET['error_message']; - return; -} - -// Execute the code below only if the authorization code is received. -if (!is_null($_GET['code'])) { - $oauthParams['code'] = $_GET['code']; - - $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, 'https://account.ely.by/api/oauth2/v1/token'); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - curl_setopt($curl, CURLOPT_POST, true); - curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($oauthParams)); - $out = json_decode(curl_exec($curl), true); - curl_close($curl); -} -``` -:::info[Notes to the code] -First, we declare the `$oauthParams` variable which will store the values that we got after registering the application. -Then we check if there was an error. In which case, we immediately stop the execution. -Then we create a POST request to exchange the `code` for an `access_token`, passing all required fields in the process. -Then we execute the request, get the answer and parse it from JSON into the associative array. -::: - - - -### Server response {#access_key_result} -In case of a successful request, the response body will contain the result of exchanging the authorization code for an `access_token`. Data is a JSON document and can be easily interpreted by tools of a used programming language. -The JSON document body will contain the following fields: -```json -{ - "access_token": "4qlktsEiwgspKEAotazem0APA99Ee7E6jNryVBrZ", - "refresh_token": "m0APA99Ee7E6jNryVBrZ4qlktsEiwgspKEAotaze", // Presented only in case of a request with offline_access rights - "token_type": "Bearer", - "expires_in": 86400 // Number of seconds for which the token is issued -} -``` -At this process authorization procedure is over. The resulting `access_token` can be used to obtain user information and to interact with our API. - -## Getting user information {#get-user-info} -If the received token has the `account_info` scope, then you can request information about the user’s account. To do it, you have to send a request to the URL: -```url -https://account.ely.by/api/account/v1/info -``` -To send `access_token`, the `Authorization` header is used with the value of `Bearer {access_token}`. - -```php title="An example of getting user information in PHP" - - -## Refreshing access token {#refresh-token} -If you have requested the scope `offline_access` during authorization, then along with your `access_token` you’ll also get `refresh_token`. This token doesn’t expire and can be used to obtain a new access token when that one expires. - -To perform a token update, you have to send a POST request to the same URL that was used for exchanging the auth code for an access token, but with the next parameters: - -| **Parameter** | **Description** | -|-----------------|-----------------------------------------------------------------------------------------------------------------------------------------| -| `client_id` | ClientID that was received during registration. | -| `client_secret` | ClientSecret that was received during application registration. | -| `scope` | The same scopes that were obtained for the initial access token. An attempt to extend this list will cause an error. | -| `refresh_token` | The token itself that was obtained along with the access token. | - -```php title="Example of a token refreshing in PHP" - 'ely', // Your ClientId received during registration - 'client_secret' => 'Pk4uCtZw5WVlSUpvteJuTZkVqHXZ6aNtTaLPXa7X', // Your ClientSecret received at registration - 'scope' => 'account_info account_email', - 'refresh_token' => $refreshToken, - 'grant_type' => 'refresh_token', -]; - -$curl = curl_init(); -curl_setopt($curl, CURLOPT_URL, 'https://account.ely.by/api/oauth2/v1/token'); -curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); -curl_setopt($curl, CURLOPT_POST, true); -curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($requestParams)); -$result = json_decode(curl_exec($curl), true); -curl_close($curl); -``` -The answer will have exactly the same body as the result of [exchanging auto code for an access token](#access_key_result). The `refresh_token` field will be absent. - -## Available libraries {#libraries} -A simpler way is to use a ready-made library, to which you’ll only have to provide registration parameters. Listed below are libraries for various programming languages. You can extend this list by providing your own library. -* **PHP**: - * [Official] https://github.com/elyby/league-oauth2-provider -* **Ruby**: - * [Official] https://github.com/elyby/omniauth-ely - -## Possible errors {#errors} -Below are the typical errors that you may receive after transmitting incorrect data to the authorization server. If you encounter an error that is not described in this documentation, please report it via [feedback form](https://ely.by/site/contact). - - - -### Errors during authorization initiation {#errors-init-auth} -This section describes the errors displayed when a user is redirected from your site to our authorization initiation page. - -``` -Invalid request ({parameter} required). -``` -This error means that you did not pass all the required parameters. To solve this error just add the missing parameter. - -``` -Invalid response type '{invalid_response_type_value}'. -``` -This error indicates that you passed an unsupported type of response_type. Currently, the only supported value is `code`. - -``` -Invalid scope '{invalid_scope}'. -``` -The error indicates that an unknown `scope` was requested. Make sure you request [supported scopes](#available-scopes). - -``` -Can not find application you are trying to authorize. -``` -This error indicates that the passed parameters do not correspond to any of the registered applications. To solve the problem, fix your `client_id` and `redirect_uri` values. - -### Errors when exchanging code for a key {#issue-token-errors} -If an error occurs, instead of the expected response with the `200` status, you will receive a `40x` code and the following 2 fields: -```json -{ - "error": "invalid_request", - "error_description": "The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. Check the \"code\" parameter." -} -``` -The `error` field contains the system error identifier, and `error_description` describes the error in English language. - -#### Possible error values {#issue-token-error-values} -* `invalid_request`: Not all the required request parameters were passed or the `code` value was not found in the issued codes database. -* `unsupported_grant_type`: This error indicates that you tried to authorize using an unknown for our OAuth2 server Grant-type. -* `invalid_client`: This error occurs when the trio of values `client_id`, `client_secret` and `redirect_uri` didn’t match with any of the registered applications. - -### Errors when requesting user information {#errors-request-user} -Response status `401` indicates that the `Authorization` header is not present in the request or its value formed incorrectly. The response body will be as follows: -```json -{ - "name": "Unauthorized", - "status": 401, - "message": "Your request was made with invalid credentials." -} -``` - -A response with the `403` status indicates that the token transferred in the `Authorization` header does not contain the `account_info` scope or it has expired. The response will be in the following format: -```json -{ - "name": "Forbidden", - "status": 403, - "message": "You are not allowed to perform this action." -} -``` - -### Errors while updating access token {#errors-renewing-token} -When updating the access token you may encounter the same errors from [exchanging auth code for an access token](#issue-token-errors), as well as several new ones: -* `invalid_request`: Not all the required request parameters were passed or the `refresh_token` value wasn’t found in the issued tokens database. -* `invalid_scope`: The unsupported scope was listed or requested more scopes than the original token had. diff --git a/i18n/en/docusaurus-plugin-content-docs/current/skins-system.md b/i18n/en/docusaurus-plugin-content-docs/current/skins-system.md deleted file mode 100644 index a8a9594..0000000 --- a/i18n/en/docusaurus-plugin-content-docs/current/skins-system.md +++ /dev/null @@ -1,147 +0,0 @@ -# Skins system {#skins-system} - -On this page you’ll find information about available endpoints of Ely.by’s skins system service. You can use any of them as an secondary or primary source of skins for your project. - -Ely.by’s skins system service provides [proxying of textures from Minecraft premium users](#textures-proxy), which means that using this service, your players will see both premium Minecraft users’ skins and Ely.by users’ skins. - -We strive to comply with the official skins system and do not support ears and HD-skins. The system supports capes, but doesn’t allow players to wear them on their own. - -If you have suggestions for improving the existing functionality, please [create a new Issue](https://github.com/elyby/chrly/issues/new) at the [Chrly project repository](https://github.com/elyby/chrly). - -:::note -You can find more detailed information about the implementation of the skins system server in the [Chrly project repository](https://github.com/elyby/chrly). -::: - -## Requests URLs {#url} -The skins system is located at the `http://skinsystem.ely.by` domain. -In all queries, the `nickname` param must be replaced by the player’s name. The value is case-insensitive. - -### Skin request {#skin-request} -> **GET /skins/\{nickname\}.png** - -URL for downloading a skin texture. The `.png` extension can be omitted. If textures aren’t found, the server will return a `404` status response. - -### Cloak request {#cape-request} -> **GET /cloaks/\{nickname\}.png** - -URL for downloading a cape texture. The `.png` extension can be omitted. If textures aren’t found, the server will return a `404` status response. - -### Textures request {#textures-request} -> **GET /textures/\{nickname\}** - -Via this URL you can get textures in the format specified in the `textures` field of JSON property with the same name in response to [request for signed textures](https://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape): -```json -{ - "SKIN": { - "url": "http://example.com/skin.png", - "metadata": { - "model": "slim" - } - }, - "CAPE": { - "url": "http://example.com/cape.png" - } -} -``` -Depending on the availability of textures for the player, fields `SKIN` or `CAPE` may be absent. Unless the skin model is `slim`, the `metadata` field will be omitted. - -The server will return an empty response with `204` status, if textures aren’t found. - -### Profile request {#profile-request} -> **GET /profile/\{nickname\}** - -This endpoint is an analog of the [player profile query in the Mojang’s API](https://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape), but instead of UUID user is queried by his nickname. Just like in the Mojang’s API, you can append `?unsigned=false` to the URL to get textures with a signature. The response will also include an additional property with `name` ely. - -If the user has no textures, they’ll be requested through the Mojang’s API, but the Mojang’s signature will be discarded and textures will be re-signed using [our signature key](#signature-verification-key-request). -```json -{ - "id": "ffc8fdc95824509e8a57c99b940fb996", - "name": "ErickSkrauch", - "properties": [ - { - "name": "textures", - "signature": "eks3dLJWzod92dLfWH6Z8uc6l3+IvrZtTj3zjwnj0AdVt44ODKoL50N+RabYxf7zF3C7tlJwT1oAtydONrxXUarqUlpVeQzLlfsuqUKBLi0L+/Y9yQLG3AciNqzEWq3hYaOsJrsaJday/hQmKFnpXEFCThTMpSuZhoAZIiH4VG48NhP70U93ejyXF9b1nPYnXP6k7BVB8LYSzcjZfdqY88jQJbbvRzOyX14ZSD0Ma92jceLNKmkTVc2UfRLUNXtQKtVSFUzlAjCXPJW89IIOZTRqLg65qstWwBvn6VuikyUB5EIxM8vuCh7zTkrMOx1v2Q0xIj8YSFcbnBH2bo87SYOIe1bOK57ZEeUJqY6uSgMlWs7dI5D3nmhFptErm72hg55Axdo1xbG4mvnmLYF7SA4yMDSytPPL+kA+sw3pafnvU2IZo38gqJSDOOpkOpdhUoHx85fzRJL8AcLSJiFlCZDl4pSi3cVuKy/xY5ohT/fJ6GEqpbZp3gACymn47zzI42VSh6j1DQnx2wnhqalTv0kE3qpAFpK/htSboQkFCW/bULO3b+vgU87XPlReT7UtH4yGLtixgs5GC8AzBraN8vOMv8TZCX9ab6mBBjOoDJjXa8Tq637TC75GxRHlpAN2jRHYvyp2zJwjUrML3u4eD4osHW+VBfl8D2l3nLJuemQ=", - "value": "eyJ0aW1lc3RhbXAiOjE2MTQ5MzczMjc0MzcsInByb2ZpbGVJZCI6ImZmYzhmZGM5NTgyNDUwOWU4YTU3Yzk5Yjk0MGZiOTk2IiwicHJvZmlsZU5hbWUiOiJFcmlja1NrcmF1Y2giLCJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly9lbHkuYnkvc3RvcmFnZS9za2lucy82OWM2NzQwZDI5OTNlNWQ2ZjZhN2ZjOTI0MjBlZmMyOS5wbmcifX19" - }, - { - "name": "ely", - "value": "but why are you asking?" - } - ] -} -``` -The server will return an empty response with `204` status if the nickname wasn’t found locally nor via the Mojang’s API. - -### Public Key Request {#signature-verification-key-request} -> **GET /signature-verification-key.der** - -This endpoint returns a public key that can be used to verify a texture’s signature. The key is provided in `DER` format, so it can be used directly in the Authlib, without modifying the signature checking algorithm. - -> **GET /signature-verification-key.pem** - -The same endpoint as the previous one, except that it returns the key in `PEM` format. - -### Signed Textures Request {#signed-textures-request} -> **GET /textures/signed/\{nickname\}** - -This request is used in our [server skins system plugin](https://ely.by/server-skins-system) to load textures with the original Mojang’s signature. The textures received this way can be transferred to an unmodified game client without any changes. The answer will also include additional property with `name` equal to **ely**. -```json -{ - "id": "ffc8fdc95824509e8a57c99b940fb996", - "name": "ErickSkrauch", - "properties": [ - { - "name": "textures", - "signature": "QH+1rlQJYk8tW+8WlSJnzxZZUL5RIkeOO33dq84cgNoxwCkzL95Zy5pbPMFhoiMXXablqXeqyNRZDQa+OewgDBSZxm0BmkNmwdTLzCPHgnlNYhwbO4sirg3hKjCZ82ORZ2q7VP2NQIwNvc3befiCakhDlMWUuhjxe7p/HKNtmKA7a/JjzmzwW7BWMv8b88ZaQaMaAc7puFQcu2E54G2Zk2kyv3T1Bm7bV4m7ymbL8McOmQc6Ph7C95/EyqIK1a5gRBUHPEFIEj0I06YKTHsCRFU1U/hJpk98xXHzHuULJobpajqYXuVJ8QEVgF8k8dn9VkS8BMbXcjzfbb6JJ36v7YIV6Rlt75wwTk2wr3C3P0ij55y0iXth1HjwcEKsg54n83d9w8yQbkUCiTpMbOqxTEOOS7G2O0ZDBJDXAKQ4n5qCiCXKZ4febv4+dWVQtgfZHnpGJUD3KdduDKslMePnECOXMjGSAOQou//yze2EkL2rBpJtAAiOtvBlm/aWnDZpij5cQk+pWmeHWZIf0LSSlsYRUWRDk/VKBvUTEAO9fqOxWqmSgQRUY2Ea56u0ZsBb4vEa1UY6mlJj3+PNZaWu5aP2E9Unh0DIawV96eW8eFQgenlNXHMmXd4aOra4sz2eeOnY53JnJP+eVE4cB1hlq8RA2mnwTtcy3lahzZonOWc=", - "value": "eyJ0aW1lc3RhbXAiOjE0ODYzMzcyNTQ4NzIsInByb2ZpbGVJZCI6ImM0ZjFlNTZmNjFkMTQwYTc4YzMyOGQ5MTY2ZWVmOWU3IiwicHJvZmlsZU5hbWUiOiJXaHlZb3VSZWFkVGhpcyIsInRleHR1cmVzIjp7IlNLSU4iOnsidXJsIjoiaHR0cDovL3RleHR1cmVzLm1pbmVjcmFmdC5uZXQvdGV4dHVyZS83Mzk1NmE4ZTY0ZWU2ZDhlYzY1NmFkYmI0NDA0ZjhlYmZmMzQxMWIwY2I5MGIzMWNiNDc2ZWNiOTk2ZDNiOCJ9fX0=" - }, - { - "name": "ely", - "value": "but why are you asking?" - } - ] -} -``` -By default textures proxying isn’t used for this query. To enable it, add an additional GET parameter `?proxy=true`. - -The server will return an empty response with `204` status, if textures aren’t found. - -### Additional parameters {#additional-parameters} -You can also pass a range of additional **GET** parameters while making any of the above requests. They will be used to analyze the usage of the service by different versions of the game. - -* `version`: The version of the protocol by which skins will be requested. The current version is `2`, i.e. you need to specify `version=2`. -* `minecraft_version`: The version of Minecraft that the request is made from. -* `authlib_version`: The version of the Authlib used. This option is relevant for Minecraft versions 1.7.6+, where a separate library is used to load skins instead of in-game code. - -Here is an example of a textures request with parameters described above: -```url -http://skinsystem.ely.by/textures/erickskrauch?version=2&minecraft_version=1.14.0&authlib_version=1.5.25 -``` - -### Additional URLs {#auxiliary-urls} -You can also perform a skin and cape request by passing the nickname through the GET parameter. This feature is used to pass analytical parameters of game versions up to 1.5.2, where the nickname is simply appended to the end of the line. To do this, the entire string is arranged in such a way that the last parameter is `name`, after appending a nickname to which you get a full request string for textures. - -> **GET /skins?name=\{nickname\}.png** - -See the [skin request](#skin-request). - -> **GET /cloaks?name=\{nickname\}.png** - -See the [cape request](#cape-request). - -```url title="Examples of requests for textures with parameters from above" -http://skinsystem.ely.by/skins?version=2&minecraft_version=1.5.2&name=erickskrauch.png -http://skinsystem.ely.by/cloaks?version=2&minecraft_version=1.4.7&name=notch -``` - -## Textures proxying {#textures-proxy} -Ely.by’s skins system service obtains textures from the official skin system in a case where no information about textures for the requested username was found in the database. The request will also be proxied if a skin entry is found, but it’s default. - -To improve the throughput of the proxying algorithm, information about textures is cached in 2 stages: -* Player’s names and UUIDs matches are stored [for 30 days](https://help.minecraft.net/hc/en-us/articles/360034636712-Minecraft-Usernames#article-container:~:text=How%20often%20can%20I%20change%20my%20username%3F). -* Information about textures isn’t updated more often than [once a minute](https://wiki.vg/Mojang_API#UUID_-.3E_Profile_.2B_Skin.2FCape:~:text=You%20can%20request%20the%20same%20profile%20once%20per%20minute). - -If you own a Minecraft premium account, but your nickname is busy, please contact our [support team](https://ely.by/site/contact) and after a short check we’ll pass the nickname on to you. - -## Ready-made implementations {#implementations} -Ready-made patch implementations and installation instructions can be found at the [download section of the main Ely.by website](https://ely.by/load). diff --git a/i18n/en/docusaurus-theme-classic/footer.json b/i18n/en/docusaurus-theme-classic/footer.json deleted file mode 100644 index 7a49468..0000000 --- a/i18n/en/docusaurus-theme-classic/footer.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "link.title.Проекты": { - "message": "Projects", - "description": "The title of the footer links column with title=Проекты in the footer" - }, - "link.title.Сообщество": { - "message": "Community", - "description": "The title of the footer links column with title=Сообщество in the footer" - }, - "link.item.label.Система скинов Ely.by": { - "message": "Ely.by Skin System", - "description": "The label of footer link with label=Система скинов Ely.by linking to https://ely.by" - }, - "link.item.label.Аккаунты Ely.by": { - "message": "Ely.by Accounts", - "description": "The label of footer link with label=Аккаунты Ely.by linking to https://account.ely.by" - }, - "link.item.label.X (Twitter)": { - "message": "X (Twitter)", - "description": "The label of footer link with label=X (Twitter) linking to https://x.com/erickskrauch" - }, - "link.item.label.YouTube": { - "message": "YouTube", - "description": "The label of footer link with label=YouTube linking to https://www.youtube.com/c/ElyByOfficial" - }, - "link.item.label.VK": { - "message": "VK", - "description": "The label of footer link with label=VK linking to https://vk.com/elyby" - }, - "link.item.label.Discord": { - "message": "Discord", - "description": "The label of footer link with label=Discord linking to https://ely.by" - }, - "link.item.label.GitHub": { - "message": "GitHub", - "description": "The label of footer link with label=GitHub linking to https://github.com/elyby" - }, - "copyright": { - "message": "Copyright © 2024 Ely.by. Built with Docusaurus.", - "description": "The footer copyright" - } -} diff --git a/i18n/en/docusaurus-theme-classic/navbar.json b/i18n/en/docusaurus-theme-classic/navbar.json deleted file mode 100644 index a05ea00..0000000 --- a/i18n/en/docusaurus-theme-classic/navbar.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "title": { - "message": "Документация Ely.by", - "description": "The title in the navbar" - }, - "logo.alt": { - "message": "Логотип Ely.by", - "description": "The alt text of navbar logo" - } -} diff --git a/root/index.html b/root/index.html deleted file mode 100644 index a53565d..0000000 --- a/root/index.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - Ely.by Documentation - - - - - - - - - diff --git a/root/robots.txt b/root/robots.txt deleted file mode 100644 index ef8ff4a..0000000 --- a/root/robots.txt +++ /dev/null @@ -1,5 +0,0 @@ -User-agent: * -Allow: / - -Sitemap: https://docs.ely.by/ru/sitemap.xml -Sitemap: https://docs.ely.by/en/sitemap.xml diff --git a/scripts/crowdin-locales.mjs b/scripts/crowdin-locales.mjs new file mode 100644 index 0000000..9db49ca --- /dev/null +++ b/scripts/crowdin-locales.mjs @@ -0,0 +1,42 @@ +// Prints the comma-separated list of locales to publish (the DOCS_LOCALES env variable for the build). +// Russian (the source language) and English (also stored in the repository) are always published, +// other languages only when their translation progress in Crowdin reaches MIN_PROGRESS. +// +// Requires the CROWDIN_PERSONAL_TOKEN env variable. + +const API_URL = 'https://ely.api.crowdin.com/api/v2'; +const PROJECT_ID = 2; +const MIN_PROGRESS = 60; +const ALWAYS_PUBLISHED = ['ru', 'en']; + +// Crowdin language id => Docusaurus locale. Must match "languages_mapping" in crowdin.yml +// and the localeConfigs in docusaurus.config.ts +const LOCALES_MAPPING = { + 'zh-CN': 'zh-Hans', +}; + +const token = process.env.CROWDIN_PERSONAL_TOKEN; +if (!token) { + console.error('The CROWDIN_PERSONAL_TOKEN env variable is not set'); + process.exit(1); +} + +const response = await fetch(`${API_URL}/projects/${PROJECT_ID}/languages/progress?limit=500`, { + headers: {Authorization: `Bearer ${token}`}, +}); +if (!response.ok) { + console.error(`Crowdin API responded with ${response.status}: ${await response.text()}`); + process.exit(1); +} + +const locales = [...ALWAYS_PUBLISHED]; +for (const {data: progress} of (await response.json()).data) { + const locale = LOCALES_MAPPING[progress.languageId] ?? progress.languageId; + const published = progress.translationProgress >= MIN_PROGRESS; + console.error(`${progress.languageId} (${locale}): ${progress.translationProgress}%${published ? '' : `, less than ${MIN_PROGRESS}%, skipping`}`); + if (published && !locales.includes(locale)) { + locales.push(locale); + } +} + +console.log(locales.join(',')); diff --git a/scripts/postbuild.mjs b/scripts/postbuild.mjs index 7213f32..11afe50 100644 --- a/scripts/postbuild.mjs +++ b/scripts/postbuild.mjs @@ -1,24 +1,91 @@ // Assembles the site root after "docusaurus build". -// Every locale is built into its own build// directory (see i18n.localeConfigs in +// Every locale is built into its own build// directory (see i18n.localeConfigs in // docusaurus.config.ts), so files that must live in the site root are placed here. -import {cpSync, copyFileSync, existsSync} from 'node:fs'; +import {cpSync, copyFileSync, existsSync, readdirSync, readFileSync, writeFileSync} from 'node:fs'; import {dirname, join} from 'node:path'; import {fileURLToPath} from 'node:url'; +const SITE_URL = 'https://docs.ely.by'; +const DEFAULT_PREFIX = 'ru'; +// Browser languages, whose speakers are more likely to understand Russian than English +const RUSSIAN_SPEAKING = ['ru', 'be', 'uk', 'kk']; + const projectDir = join(dirname(fileURLToPath(import.meta.url)), '..'); const buildDir = join(projectDir, 'build'); -const defaultLocale = 'ru'; -if (!existsSync(join(buildDir, defaultLocale))) { +if (!existsSync(join(buildDir, DEFAULT_PREFIX, 'index.html'))) { // Partial build (e.g. "docusaurus build --locale en"): there is nothing to assemble - console.warn(`[postbuild] build/${defaultLocale} not found, skipping the site root assembly`); + console.warn(`[postbuild] build/${DEFAULT_PREFIX} not found, skipping the site root assembly`); process.exit(0); } -// CNAME, .nojekyll, robots.txt and the language-detecting index.html +// Collect built locales: { prefix: "zh", lang: "zh-CN" } +const locales = readdirSync(buildDir, {withFileTypes: true}) + .filter((entry) => entry.isDirectory() && existsSync(join(buildDir, entry.name, 'index.html'))) + .map(({name: prefix}) => { + const html = readFileSync(join(buildDir, prefix, 'index.html'), 'utf8'); + const lang = html.match(/]*\slang="([^"]+)"/)?.[1] ?? prefix; + + return {prefix, lang}; + }); + +// Language name in the language itself: "русский", "English", "中文(中国)" +function languageName(lang) { + const name = new Intl.DisplayNames([lang], {type: 'language'}).of(lang) ?? lang; + + return name.charAt(0).toLocaleUpperCase(lang) + name.slice(1); +} + +// CNAME and .nojekyll cpSync(join(projectDir, 'root'), buildDir, {recursive: true}); // GitHub Pages only serves the 404.html from the site root -copyFileSync(join(buildDir, defaultLocale, '404.html'), join(buildDir, '404.html')); +copyFileSync(join(buildDir, DEFAULT_PREFIX, '404.html'), join(buildDir, '404.html')); -console.log('[postbuild] Site root assembled'); +// The site root redirects to the documentation in the browser's language +const languagesMap = Object.fromEntries([ + ...RUSSIAN_SPEAKING.map((lang) => [lang, DEFAULT_PREFIX]), + ...locales.map(({prefix, lang}) => [lang.toLowerCase().split('-')[0], prefix]), +]); +const fallbackPrefix = locales.some(({prefix}) => prefix === 'en') ? 'en' : DEFAULT_PREFIX; + +writeFileSync(join(buildDir, 'index.html'), ` + + + + + Ely.by Documentation +${locales.map(({prefix, lang}) => ` `).join('\n')} + + + + + + + +`); + +writeFileSync(join(buildDir, 'robots.txt'), `User-agent: * +Allow: / + +${locales.filter(({prefix}) => existsSync(join(buildDir, prefix, 'sitemap.xml'))).map(({prefix}) => `Sitemap: ${SITE_URL}/${prefix}/sitemap.xml`).join('\n')} +`); + +console.log(`[postbuild] Site root assembled for locales: ${locales.map(({prefix}) => prefix).join(', ')}`);