Skip to main content

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 example, coming soon…✨

🚀 How to use

  • Deno
// See example.ts

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

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

const session = crypto.randomUUID();

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

// access 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, UrlParam, Permissions  } 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