{"id":18317938,"url":"https://github.com/idiocc/mailru","last_synced_at":"2025-06-27T07:35:08.965Z","repository":{"id":57117475,"uuid":"168292230","full_name":"idiocc/mailru","owner":"idiocc","description":"Mail.Ru OAuth Routes.","archived":false,"fork":false,"pushed_at":"2019-01-30T09:38:57.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-13T10:07:33.248Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://idio.cc","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idiocc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-30T06:36:31.000Z","updated_at":"2019-01-30T09:38:58.000Z","dependencies_parsed_at":"2022-08-22T13:00:14.269Z","dependency_job_id":null,"html_url":"https://github.com/idiocc/mailru","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/idiocc/mailru","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fmailru","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fmailru/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fmailru/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fmailru/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idiocc","download_url":"https://codeload.github.com/idiocc/mailru/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idiocc%2Fmailru/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262213091,"owners_count":23276044,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T18:07:56.594Z","updated_at":"2025-06-27T07:35:08.926Z","avatar_url":"https://github.com/idiocc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# \u003cimg src=\"https://raw.github.com/idiocc/mailru/master/docs/mailru.svg?sanitize=true\" align=\"left\"\u003e @idio/mailru\n\n[![npm version](https://badge.fury.io/js/%40idio%2Fmailru.svg)](https://npmjs.org/package/@idio/mailru)\n\n`@idio/mailru` is Mail.Ru OAuth Routes For Idio Web Server.\n\n```sh\nyarn add -E @idio/mailru\n```\n\n## Table Of Contents\n\n- [Table Of Contents](#table-of-contents)\n- [API](#api)\n- [`mailru(router: Router, config: Config)`](#mailrurouter-routerconfig-config-void)\n  * [`Config`](#type-config)\n- [Copyright](#copyright)\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/0.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## API\n\nThe package is available by importing its default function:\n\n```js\nimport mailru from '@idio/mailru'\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/1.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## `mailru(`\u003cbr/\u003e\u0026nbsp;\u0026nbsp;`router: Router,`\u003cbr/\u003e\u0026nbsp;\u0026nbsp;`config: Config,`\u003cbr/\u003e`): void`\n\nSets up the router to accept the `auth/mailru` and `auth/mailru/redirect` routes. Protects against man-in-the-middle attacks using a unique code for each session. Gets user details upon successful login.\n\n`import('koa').Middleware` __\u003ca name=\"type-middleware\"\u003e`Middleware`\u003c/a\u003e__\n\n__\u003ca name=\"type-config\"\u003e`Config`\u003c/a\u003e__: Options for the program.\n\n|        Name        |                       Type                       |                                                                         Description                                                                          |         Default         |\n| ------------------ | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------- |\n| __client_id*__     | _string_                                         | The app's client id.                                                                                                                                         | -                       |\n| __client_secret*__ | _string_                                         | The app's client secret.                                                                                                                                     | -                       |\n| path               | _string_                                         | The server path to start the login flaw and use for redirect (`${path}/redirect`).                                                                           | `/auth/mailru`          |\n| scope              | _string_                                         | The scope to ask permissions for. See https://api.mail.ru/docs/guides/restapi/#permissions.                                                                  | -                       |\n| finish             | _(ctx, token, user) =\u0026gt; {}_                    | The function to complete the authentication that receives the token and the data about the user, such as name and id. The default function redirects to `/`. | `setSession; redirect;` |\n| error              | _(ctx, error, error_description, next) =\u0026gt; {}_ | The function to be called in case of error. If not specified, the middleware will throw an internal server error.                                            | `throw;`                |\n| session            | _[Middleware](#type-middleware)_                 | The configured session middleware in case the `session` property is not globally available on the context.                                                   | -                       |\n\n```js\n/* yarn example/ */\nimport dotenv from '@demimonde/dotenv'\nimport core from '@idio/core'\nimport mailru from '@idio/mailru'\ndotenv()\n\n;(async () =\u003e {\n  const { url, router, app, middleware: {\n    session,\n  } } = await core({\n    session: { use: true, keys: [process.env.SESSION_KEY] },\n  })\n  mailru(router, {\n    client_id: process.env.CLIENT_ID,\n    client_secret: process.env.CLIENT_SECRET,\n    session,\n  })\n  app.use(router.routes())\n  console.log(`${url}/auth/mailru`)\n})()\n```\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/2.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e\n\n## Copyright\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://artd.eco\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/wrote/wrote/master/images/artdeco.png\" alt=\"Art Deco\" /\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e\n      © \u003ca href=\"https://artd.eco\"\u003eArt Deco\u003c/a\u003e for \u003ca href=\"https://idio.cc\"\u003eIdio\u003c/a\u003e\n      2019\n    \u003c/th\u003e\u003cth\u003e\n        \u003ca href=\"https://idio.cc\"\u003e\n          \u003cimg src=\"https://avatars3.githubusercontent.com/u/40834161?s=100\" width=\"100\" alt=\"Idio\" /\u003e\n        \u003c/a\u003e\n      \u003c/th\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://www.technation.sucks\" title=\"Tech Nation Visa\"\u003e\n        \u003cimg src=\"https://raw.githubusercontent.com/artdecoweb/www.technation.sucks/master/anim.gif\" alt=\"Tech Nation Visa\" /\u003e\n      \u003c/a\u003e\n    \u003c/th\u003e\n    \u003cth\u003e\n      \u003ca href=\"https://www.technation.sucks\"\u003eTech Nation Visa Sucks\u003c/a\u003e\n    \u003c/th\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003cp align=\"center\"\u003e\u003ca href=\"#table-of-contents\"\u003e\u003cimg src=\".documentary/section-breaks/-1.svg?sanitize=true\"\u003e\u003c/a\u003e\u003c/p\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiocc%2Fmailru","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidiocc%2Fmailru","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidiocc%2Fmailru/lists"}