Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump undici from 6.0.1 to 6.6.1 in /packages/nat-api #303

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions docs/.vitepress/config.ts

This file was deleted.

30 changes: 0 additions & 30 deletions docs/.vitepress/theme/common.css

This file was deleted.

3 changes: 0 additions & 3 deletions docs/.vitepress/theme/index.ts

This file was deleted.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"version": "7.5.0",
"scripts": {
"build:docs": "tsx scripts/docs.ts",
"preview:docs": "vitepress preview docs",
"dev:docs": "vitepress dev docs",
"lint": "eslint packages --ext .ts",
"lint:fix": "eslint packages --ext .ts --fix",
"test": "vitest",
Expand All @@ -13,7 +11,6 @@
"packageManager": "[email protected]",
"devDependencies": {
"tsx": "^3.12.6",
"vitepress": "^1.0.0-beta.2",
"typedoc": "^0.24.8",
"typescript": "^5.0.3",
"@vitest/coverage-c8": "^0.30.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/nat-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dependencies": {
"default-gateway": "^6.0.3",
"fast-xml-parser": "^4.3.2",
"undici": "6.0.1"
"undici": "6.6.1"
},
"devDependencies": {
"@types/node": "^18.15.11",
Expand Down
14 changes: 12 additions & 2 deletions packages/user/offline.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { v3, v4 } from 'uuid'
import { createHash } from 'crypto'
import { v4 } from 'uuid'

/**
* Random generate a new token by uuid v4. It can be client or auth token.
Expand All @@ -8,13 +9,22 @@ export function newToken() {
return v4().replace(/-/g, '')
}

export function getUUIDOfOfflinePlayer(username: string) {
const md5Bytes = createHash('md5').update(`OfflinePlayer:${username}`).digest()
md5Bytes[6] &= 0x0f /* clear version */
md5Bytes[6] |= 0x30 /* set to version 3 */
md5Bytes[8] &= 0x3f /* clear variant */
md5Bytes[8] |= 0x80 /* set to IETF variant */
return md5Bytes.toString('hex')
}

/**
* Create an offline auth. It'll ensure the user game profile's `uuid` is the same for the same `username`.
*
* @param username The username you want to have in-game.
*/
export function offline(username: string, uuid?: string) {
const id = (uuid || v3(username, '00000000-0000-0000-0000-000000000000')).replace(/-/g, '')
const id = (uuid || getUUIDOfOfflinePlayer(username))
const prof = {
id,
name: username,
Expand Down
Loading
Loading