Skip to content

Commit a4c212e

Browse files
rob9315rob9315
andauthored
Release 1.5.2 (#58)
* fix for npm publish * add dry-run publish test * bump version * new version * publish all files * change ci actions Co-authored-by: rob9315 <9315.rob@gmail.com>
1 parent 81f5b44 commit a4c212e

File tree

8 files changed

+84
-67
lines changed

8 files changed

+84
-67
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ jobs:
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424
- run: npm install
25-
- run: npm test
25+
- run: npm run test
26+
- run: npm publish --dry-run

.github/workflows/publish.yml

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,35 @@
1-
name: npm-publish
2-
on:
3-
push:
4-
branches:
5-
- master # Change this to your default branch
6-
jobs:
7-
npm-publish:
8-
name: npm-publish
9-
runs-on: ubuntu-latest
10-
steps:
11-
- name: Checkout repository
12-
uses: actions/checkout@master
13-
- name: Set up Node.js
14-
uses: actions/setup-node@master
15-
with:
16-
node-version: 14.0.0
17-
- name: Install
18-
run: npm install
19-
- id: publish
20-
uses: JS-DevTools/npm-publish@v1
21-
with:
22-
token: ${{ secrets.NPM_AUTH_TOKEN }}
23-
- name: Create Release
24-
if: steps.publish.outputs.type != 'none'
25-
id: create_release
26-
uses: actions/create-release@v1
27-
env:
28-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29-
with:
30-
tag_name: ${{ steps.publish.outputs.version }}
31-
release_name: Release ${{ steps.publish.outputs.version }}
32-
body: ${{ steps.publish.outputs.version }}
33-
draft: false
34-
prerelease: false
1+
name: npm-publish
2+
on:
3+
push:
4+
branches:
5+
- master # Change this to your default branch
6+
jobs:
7+
npm-publish:
8+
name: npm-publish
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@master
13+
- name: Set up Node.js
14+
uses: actions/setup-node@master
15+
with:
16+
node-version: 14.0.0
17+
- name: Install
18+
run: npm install && npm run build
19+
- id: publish
20+
uses: JS-DevTools/npm-publish@v1
21+
with:
22+
token: ${{ secrets.NPM_AUTH_TOKEN }}
23+
- name: Create Release
24+
if: steps.publish.outputs.type != 'none'
25+
id: create_release
26+
uses: actions/create-release@v1
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
with:
30+
tag_name: ${{ steps.publish.outputs.version }}
31+
release_name: Release ${{ steps.publish.outputs.version }}
32+
body: ${{ steps.publish.outputs.version }}
33+
draft: false
34+
prerelease: false
35+

.npmignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/*
2+
npm-debug.log
3+
package-lock.json
4+
yarn.lock

HISTORY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
## History
22

3-
## 1.5.1
3+
## 1.5.2
44
* Fix the release
55

66
## 1.5.0
7-
* Add async support and typings with typescript and convert to node-fetch (thanks @Rob9315)
7+
* Add async support and typings with typescript and convert to node-fetch (thanks @Rob9315)
88

99
## 1.4.0
1010
* Add ability to request user from token refresh (thanks @ph0t0shop)

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"name": "yggdrasil",
3-
"version": "1.5.1",
3+
"version": "1.5.2",
44
"author": "Zeke Sonxx <zeke@zekesonxx.com>",
55
"description": "Mojang authentication (Yggdrasil) client",
66
"scripts": {
7+
"build": "tsc",
78
"test": "mocha -R spec",
89
"pretest": "npm run lint && npm run build",
9-
"prepublish": "npm run lint && npm run build",
1010
"lint": "ts-standard",
11-
"fix": "ts-standard --fix",
12-
"build": "npx tsc"
11+
"fix": "ts-standard --fix"
1312
},
14-
"main": "./lib/index",
13+
"main": "./lib/index.js",
14+
"types": "./lib/index.d.ts",
1515
"repository": {
1616
"type": "git",
1717
"url": "https://github.com/PrismarineJS/node-yggdrasil.git"

src/Client.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import uuid from 'uuid'
22
import * as utils from './utils.js'
3+
import type { Agent } from 'http'
34

45
const defaultHost = 'https://authserver.mojang.com'
56

@@ -16,7 +17,7 @@ const Client = {
1617
options.agent = options.agent ?? 'Minecraft'
1718

1819
return await utils.call(
19-
this?.host ?? defaultHost,
20+
(this as any)?.host as string ?? defaultHost,
2021
'authenticate',
2122
{
2223
agent: {
@@ -28,7 +29,7 @@ const Client = {
2829
clientToken: options.token,
2930
requestUser: options.requestUser === true
3031
},
31-
this?.agent
32+
(this as any)?.agent as Agent
3233
)
3334
},
3435
/**
@@ -39,7 +40,7 @@ const Client = {
3940
* @param {Function} cb (err, new token, full response body)
4041
*/
4142
refresh: async function (accessToken: string, clientToken: string, requestUser?: boolean) {
42-
const data = await utils.call(this?.host as string ?? defaultHost, 'refresh', { accessToken, clientToken, requestUser: requestUser ?? false }, this?.agent)
43+
const data = await utils.call((this as any)?.host as string ?? defaultHost, 'refresh', { accessToken, clientToken, requestUser: requestUser ?? false }, (this as any)?.agent as Agent)
4344
if (data.clientToken !== clientToken) throw new Error('clientToken assertion failed')
4445
return [data.accessToken, data]
4546
},
@@ -49,7 +50,7 @@ const Client = {
4950
* @param {Function} cb (error)
5051
*/
5152
validate: async function (accessToken: string) {
52-
return await utils.call(this?.host as string ?? defaultHost, 'validate', { accessToken }, this?.agent)
53+
return await utils.call((this as any)?.host as string ?? defaultHost, 'validate', { accessToken }, (this as any)?.agent as Agent)
5354
},
5455

5556
/**
@@ -59,7 +60,7 @@ const Client = {
5960
* @param {Function} cb (error)
6061
*/
6162
signout: async function (username: string, password: string) {
62-
return await utils.call(this?.host as string ?? defaultHost, 'signout', { username, password }, this?.agent)
63+
return await utils.call((this as any)?.host as string ?? defaultHost, 'signout', { username, password }, (this as any)?.agent as Agent)
6364
}
6465
}
6566

src/Server.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import crypto from 'crypto'
1+
import { createHash } from 'crypto'
22
import utils from './utils.js'
33
import nf from 'node-fetch'
4+
import type { Agent } from 'http'
45

56
const defaultHost = 'https://sessionserver.mojang.com'
67

@@ -18,14 +19,15 @@ const Server = {
1819
*/
1920
join: async function (accessToken: string, selectedProfile: string, serverid: string, sharedsecret: string, serverkey: string) {
2021
return await utils.call(
21-
this?.host as string ?? defaultHost,
22+
(this as any)?.host as string ??
23+
defaultHost,
2224
'session/minecraft/join',
2325
{
2426
accessToken,
2527
selectedProfile,
26-
serverId: utils.mcHexDigest(crypto.createHash('sha1').update(serverid).update(sharedsecret).update(serverkey).digest())
28+
serverId: utils.mcHexDigest(createHash('sha1').update(serverid).update(sharedsecret).update(serverkey).digest())
2729
},
28-
this?.agent
30+
(this as any)?.agent as Agent
2931
)
3032
},
3133

@@ -39,9 +41,9 @@ const Server = {
3941
* @async
4042
*/
4143
hasJoined: async function (username: string, serverid: string, sharedsecret: string, serverkey: string) {
42-
const host: string = this?.host as string ?? defaultHost
43-
const hash: string = utils.mcHexDigest(crypto.createHash('sha1').update(serverid).update(sharedsecret).update(serverkey).digest())
44-
const data = await nf(`${host}/session/minecraft/hasJoined?username=${username}&serverId=${hash}`, { agent: this?.agent, method: 'GET' })
44+
const host: string = (this as any)?.host as string ?? defaultHost
45+
const hash: string = utils.mcHexDigest(createHash('sha1').update(serverid).update(sharedsecret).update(serverkey).digest())
46+
const data = await nf(`${host}/session/minecraft/hasJoined?username=${username}&serverId=${hash}`, { agent: (this as any)?.agent as Agent, method: 'GET' })
4547
const body = JSON.parse(await data.text())
4648
if (body.id !== undefined) return body
4749
else throw new Error('Failed to verify username!')

tsconfig.json

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
{
22
"compilerOptions": {
3-
"target": "es2019",
4-
"module": "CommonJS",
5-
"strict": true,
3+
"target": "ES2020",
4+
"module": "commonjs",
5+
"sourceMap": true,
66
"declaration": true,
7-
// "resolveJsonModule": true, because of ts-standard had to disable...
7+
"strict": true,
88
"moduleResolution": "node",
9+
"resolveJsonModule": true,
910
"esModuleInterop": true,
11+
"types": ["node"],
1012
"outDir": "lib",
11-
"noImplicitThis": false
12-
},
13-
"include": [
14-
"src"
15-
],
16-
"exclude": [
17-
"lib","node_modules"
18-
]
19-
}
13+
"removeComments": false
14+
},
15+
"compileOnSave": true,
16+
"include": [
17+
"./src/**/*",
18+
"./test/**/*"
19+
],
20+
"exclude": [
21+
"lib",
22+
"node_modules",
23+
"bin",
24+
"examples",
25+
"scripts"
26+
],
27+
}

0 commit comments

Comments
 (0)