Skip to content

Commit

Permalink
chore: prepare for release
Browse files Browse the repository at this point in the history
  • Loading branch information
LwveMike committed Apr 16, 2024
1 parent c2ea866 commit bed81fe
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 28 deletions.
90 changes: 86 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,94 @@
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
[![License][license-src]][license-href]

Description
# Description

Node.js Tacacs+ client.

## Install

***npm***
```bash
npm i @noction/vue-highcharts
```

***yarn***
```bash
yarn add @noction/vue-highcharts
```

***pnpm***
```bash
pnpm add @noction/vue-highcharts
```

## Usage
```js
import type { AuthenType } from '@noction/tacacs-plus'
import { AUTHEN_TYPES, Client } from '@noction/tacacs-plus'

const client = new Client({
host: '127.0.0.1',
port: 49,
secret: 'tac_test',
// Your application logger (Optional)
logger: {
log: console.log,
// If you provide a debug logger, it will log the sent and received packets
debug: console.debug,
error: console.error,
warn: console.warn,
},
})

// Example Authentication

try {
const res = await client.authenticate({
username: 'test_login',
password: 'test_login_password',
authenType: AUTHEN_TYPES.TAC_PLUS_AUTHEN_TYPE_ASCII,
})

console.log(res)
}
// Every status, except PASS will be thrown as an Error
catch (err) {
console.log(err)
}

// Example Authorization

try {
const res = await client.authorize({
username: 'test_login',
services: ['idk'],
})

console.log(res)
}
// Every status, except PASS_ADD will be thrown as an Error
catch (err) {
console.log(err)
}
```

## Supporting

1. Authentication
2. Authorization

## Authentication types supported

- TAC_PLUS_AUTHEN_TYPE_ASCII
- TAC_PLUS_AUTHEN_TYPE_PAP
- TAC_PLUS_AUTHEN_TYPE_CHAP

## Not supporting

1. Accounting

## License

Expand All @@ -20,5 +104,3 @@ Description
[bundle-href]: https://bundlephobia.com/result?p=@noction/tacacs-plus
[license-src]: https://img.shields.io/github/license/Noction/@noction/tacacs-plus.svg?style=flat&colorA=080f12&colorB=1fa669
[license-href]: https://github.com/Noction/tacacs-plus/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
[jsdocs-href]: https://www.jsdocs.io/package/@noction/tacacs-plus
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
"version": "0.0.0",
"packageManager": "[email protected]",
"description": "",
"author": "",
"author": "Noction",
"license": "MIT",
"keywords": [],
"sideEffects": false,
"main": "index.js",
"scripts": {
"lint": "pnpm -P -r \"/^lint/\"",
"typecheck": "pnpm -P -r \"/^typecheck/\"",
Expand Down
8 changes: 4 additions & 4 deletions packages/playground/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "playground",
"version": "0.0.0",
"description": "",
"author": "",
"author": "Noction",
"license": "MIT",
"keywords": [],
"scripts": {
"lint": "eslint .",
"start": "esno src/index",
"up:server": "docker compose -f server/docker-compose.yaml up -d",
"down:server": "docker compose -f server/docker-compose.yaml down"
},
"dependencies": {
"@noction/tacacs-plus": "workspace:",
"@noction/tacacs-plus": "workspace:"
},
"devDependencies": {
"eslint": "^8.56.0",
"typescript": "5.3.3"
}
Expand Down
7 changes: 2 additions & 5 deletions packages/tacacs-plus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "module",
"version": "0.0.0",
"packageManager": "[email protected]",
"description": "Description",
"description": "Node.js Tacacs+ client",
"author": "Noction",
"license": "MIT",
"homepage": "https://github.com/Noction/@noction/tacacs-plus#readme",
Expand All @@ -12,7 +12,7 @@
"url": "git+https://github.com/Noction/@noction/tacacs-plus.git"
},
"bugs": "https://github.com/Noction/@noction/tacacs-plus/issues",
"keywords": [],
"keywords": ["node", "tacacs-plus", "tacacs-client", "tacacs-plus-authentication", "tacacs-plus-authorization"],
"sideEffects": false,
"exports": {
".": {
Expand Down Expand Up @@ -47,11 +47,9 @@
"start": "esno src/index.ts",
"test": "vitest",
"typecheck": "tsc --noEmit"

},
"devDependencies": {
"@antfu/ni": "^0.21.12",
"@antfu/utils": "^0.7.7",
"@types/node": "^20.11.19",
"bumpp": "^9.3.0",
"eslint": "^8.56.0",
Expand All @@ -60,7 +58,6 @@
"rimraf": "^5.0.5",
"typescript": "5.3.3",
"unbuild": "^2.0.0",
"vite": "^5.2.8",
"vitest": "^1.3.1"
}
}
2 changes: 1 addition & 1 deletion packages/tacacs-plus/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class Client {
return socket
}

async authenticate({ username, password, privLvl, authenType }: AuthenticateArgs): Promise<true> {
async authenticate({ username, password, authenType, privLvl = PRIVILEGE_LEVELS.TAC_PLUS_PRIV_LVL_MIN }: AuthenticateArgs): Promise<true> {
return new Promise((resolve, reject) => {
const socket = this.createSocket()

Expand Down
1 change: 1 addition & 0 deletions packages/tacacs-plus/src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Secret } from '../types'

export interface Logger {
log: (message: string) => void
// If you provide the debug logger, the packets will be logged
debug: (message: string) => void
error: (message: string) => void
warn: (message: string) => void
Expand Down
10 changes: 0 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bed81fe

Please sign in to comment.