From f4c8ef8e4e1e7c81cfd8f08cc2f54eef555c7b90 Mon Sep 17 00:00:00 2001 From: Ibrahim Ansari Date: Sun, 24 Dec 2023 20:01:19 +0530 Subject: [PATCH] 1.0.2 + Remove incorrect type, update docs --- README.md | 9 ++++++--- package.json | 2 +- src/dummy-service.ts | 5 +++-- src/index.ts | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f8479b6..f53cb9a 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,11 @@ yarn add @mythicmc/auth ```js import MythicAuth from '@mythicmc/auth'; // or @mythicmc/auth/standalone.js -const client = new MythicAuth('redis://localhost:6379'); // or MySQL URL or options if using standalone -// Connecting is not required on standalone, but is required on the Redis client. +const client = new MythicAuth('redis://localhost:6379'); +// or MySQL URL/options + LuckPerms HTTP API URL if using standalone, e.g. +const client = new MythicAuth('mysql://localhost:3306', 'http://localhost:8080'); + +// This step is only required with the Redis client, whereas standalone connects automatically. await client.connect('app.*') // The permission namespace within which you check perms, e.g. app.use (if only checking 1 perm), app.* or even * // The service will check if the user has the permission *and* if the password matches the user's. @@ -28,5 +31,5 @@ console.log(await client.check('username', 'permission', 'password')) This package also comes with a dummy version of the Redis service, which can be used for testing purposes. ```bash -npx -- @mythicmc/auth dummy-service # optionally, Redis URL can be passed as arg +npx @mythicmc/auth # optionally, Redis URL can be passed as arg ``` diff --git a/package.json b/package.json index a7aca79..36fd3c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mythicmc/auth", - "version": "1.0.1", + "version": "1.0.2", "description": "Node.js client for MythicAuthService.", "repository": { "type": "git", diff --git a/src/dummy-service.ts b/src/dummy-service.ts index 30d5ba1..9c612cd 100755 --- a/src/dummy-service.ts +++ b/src/dummy-service.ts @@ -1,8 +1,9 @@ #!/usr/bin/env node import { Redis } from 'ioredis' -const url = process.argv[2] ?? 'redis://localhost:6379' -if (!process.argv[2]) { +const arg = process.argv[2] === 'dummy-service' ? process.argv[3] : process.argv[2] +const url = arg ?? 'redis://localhost:6379' +if (!arg) { console.log('No URL passed as parameter, using default redis://localhost:6379') } diff --git a/src/index.ts b/src/index.ts index fce609a..a07d65b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,7 +35,7 @@ export default class MythicAuth { async check( username: string, - permission: string | null, + permission: string, password?: string | null, ): Promise { if (password === '') return false // Return false if empty, undefined is a different case