npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

electron-mc-auth

v0.2.2-1

Published

<div align="center"> Display an electronJs window to authenticate Minecraft accounts through Xbox Live.

Downloads

7

Readme

electron-mc-auth



Getting started | MCLC | Contribuittions

Getting started

Start by installing the package with your preffered package manager for node.

yarn add electron-mc-auth

or

npm install electron-mc-auth

Setup

First of all, prefer to run the package code on the back-end side of the electron. So the documentation will only refer directly to the main.ts file.

useMcuseMcAuth()

To use the package authentication system, you need to instatiate the Auth function.

import { Auth } from 'electron-mc-auth'

const mcAuth = useMcuseMcAuth()

This function should return an object containing all package functions with the predefined configuration passed on it initialization.

There are some functions that you can import directly, but, to start the auth flow, you should use launch() function that is returned by the useMcuseMcAuth() function.

Starting the auth flow

It's pretty straightfoward, just use the launch() function provided by the useMcuseMcAuth() function and it will handle the Window creation and network requests to get you authenticated and reuturn the MinecraftProfile object.

Here's an example on the main file of electron.

// /main.ts

app.whenReady().then(() => {
  createWindow()
  const authenticate = async () => {
    const { launch, refresh } = useMcAuth({...})
    const auth = await launch()

    if (!auth) return

    const refreshData = await refresh(auth)

    if (!refresh) return

    dialog.showMessageBox({
      message: `
      Logged as: ${auth.name}
    `
    })

    return true
  }
  authenticate()
})

The Minecraft profile object

This is the most important part of the package.

If the login is succesful, you should recieve an object like this;

export interface MinecraftProfileTypes {
  id: string
  name: string
  skins: {
    id: string
    state: string
    url: string
    variant: string
  }[]
  capes: {
    id: string
    state: string
    url: string
    alias: string
  }[]
  access_token: string
  refresh_token: string
  client_token: string
  expires_in: number
}

MCLC

Also, the package can convert its object to be compatible with MCLC package.

To do this, just pass your Minecraft Profile object to the getMCLC() function.

function getMCLC(profile: MinecraftProfileTypes): MCLCAuthTypes

Logging

You can pass your preffered callback for onError, onInfo, onWarn, onLog events

Example using default useMcAuth() function.

const { launch, getLink, login, getMCLC, refresh, validate, getMinecraft } =
  useMcAuth({
    onError: (msg) => {
      return msg
    }
  })

Here's the type definition for the callback;

export type LogFunctionTypes = (message: string) => void

export interface LoggerCallBackTypes {
  onError?: LogFunctionTypes
  onInfo?: LogFunctionTypes
  onWarn?: LogFunctionTypes
  onLog?: LogFunctionTypes
}