Last commit GitHub Repo stars Issues Open Issues Bug Issues

🦊 MiAuth.js

the wrapper for MiAuth on Deno/Node.js

πŸ”English 🍑ζ—₯本θͺž

Note for node.js exsample, comeing soon...✨

πŸš€ How to use

  • Deno
// See exsample.ts

import { MiAuth, Permissions, UrlParam } from "./mod.ts";
import { generate } from "./src/deps.ts";

const origin = "https://misskey.io";
const permission = [Permissions.AccountRead];

const session = generate() as string;

const param: UrlParam = {
  name: "MyApp",
  permission: permission,
};
const miauth = new MiAuth(origin, param, session);

// accses to the this url, do authentication
console.log(miauth.authUrl());

// call when done authentication
// console.log(await miauth.getToken())

This module keeps in mind on alignment with misskey.js. like this

  • Deno
// this snippets omit module imports
const origin = "https://misskey.io";
const permission: Array<string> = [Permissions.AccountRead];

const param: UrlParam = {
  name: "MyApp",
  permission: permission,
};

const miauth = quickAuth(origin, param);

console.log("Let's authentication to this URL✨\n", miauth.authUrl());

// wait for press enter
console.log("\nβ˜• Push enter for restart process");
for await (const line of readLines(Deno.stdin)) {
  if (line == "") {
    break;
  }
}

const token = await miauth.getToken();

const cli = new Misskey.api.APIClient({
  origin: origin,
  credential: token,
});

const i = await cli.request("i", {});

console.log(`Show your profile\n${i.name}@${i.username}\n${i.description}`);

⬇️ Install

  • Deno
import { MiAuth, Permissions, UrlParam } from "./mod.ts";

const origin = "https://misskey.io";
const permission: Array<string> = [
  Permissions.AccountRead,
  Permissions.NotesRead,
];

const param: UrlParam = {
  name: "MyApp",
  permission: permission,
};

const miauth = new MiAuth(origin, param, session);
const token = miauth.getToken();

const apiParam = {
  origin: origin,
  credential: token,
};
const cli = new Misskey.api.APIClient(apiParam);

const meta = await cli.request("meta", { detail: true });
console.log(meta);
  • Node.js

⛏️ Development

this project use velociraptor

# See all task
vr

# use deno vender
deno vender mod.ts

# running on vender
vr dev

# run testing
vr dev-test

πŸ“œ License

MIT

See LICENSE

🧩 Modules

πŸ’• Special Thanks