Skip to content

Commit

Permalink
Rename getMinecraftServicesToken to getMinecraftBedrockServicesToken
Browse files Browse the repository at this point in the history
  • Loading branch information
LucienHH committed Jan 20, 2025
1 parent 5f3d079 commit 33e575f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ flow.getMinecraftJavaToken({ fetchProfile: true }).then(console.log)
### getMinecraftBedrockToken
See [docs/API.md](docs/API.md) and [example](examples).

### getMinecraftServicesToken
### getMinecraftBedrockServicesToken
```js
const { Authflow, Titles } = require('prismarine-auth')

const userIdentifier = 'any unique identifier'
const cacheDir = './' // You can leave this as undefined unless you want to specify a caching directory
const flow = new Authflow(userIdentifier, cacheDir)
// Get a Minecraft Services token, then log it
flow.getMinecraftServicesToken().then(console.log)
flow.getMinecraftBedrockServicesToken().then(console.log)
```

### Expected Response
Expand Down
2 changes: 1 addition & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Returns a Playfab login response which can be used to authenticate to the Playfa

[Returns ServerLoginResult](https://learn.microsoft.com/en-us/rest/api/playfab/server/authentication/login-with-xbox?view=playfab-rest#serverloginresult)

### getMinecraftServicesToken (): Promise<GetMinecraftServicesResponse>
### getMinecraftBedrockServicesToken (): Promise<GetMinecraftBedrockServicesResponse>

Returns an mctoken which can be used to query the minecraft-services.net/api and is also used to authenticate the WebSocket connection for the NetherNet WebRTC signalling channel.

Expand Down
2 changes: 1 addition & 1 deletion examples/services/deviceCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (!username) {
async function doAuth () {
const flow = new Authflow(username, cacheDir, { authTitle: Titles.MinecraftNintendoSwitch, deviceType: 'Nintendo', flow: 'live' })

const response = await flow.getMinecraftServicesToken()
const response = await flow.getMinecraftBedrockServicesToken({ version: '1.21.50' })

console.log(response)
}
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ declare module 'prismarine-auth' {
// Returns a Minecraft Bedrock Edition auth token. Public key parameter must be a KeyLike object.
getMinecraftBedrockToken(publicKey: KeyObject): Promise<string>

getMinecraftServicesToken(): Promise<GetMinecraftServicesResponse>
getMinecraftBedrockServicesToken(): Promise<GetMinecraftBedrockServicesResponse>

getPlayfabLogin(): Promise<GetPlayfabLoginResponse>

Expand Down Expand Up @@ -155,7 +155,7 @@ declare module 'prismarine-auth' {

export type CacheFactory = (options: { username: string, cacheName: string }) => Cache

export type GetMinecraftServicesResponse = {
export type GetMinecraftBedrockServicesResponse = {
mcToken: string
validUntil: string
treatments: string[]
Expand Down
6 changes: 3 additions & 3 deletions src/MicrosoftAuthFlow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const XboxTokenManager = require('./TokenManagers/XboxTokenManager')
const MsaTokenManager = require('./TokenManagers/MsaTokenManager')
const BedrockTokenManager = require('./TokenManagers/MinecraftBedrockTokenManager')
const PlayfabTokenManager = require('./TokenManagers/PlayfabTokenManager')
const MinecraftServicesTokenManager = require('./TokenManagers/MinecraftServicesManager')
const MinecraftServicesTokenManager = require('./TokenManagers/MinecraftBedrockServicesManager')

async function retry (methodFn, beforeRetry, times) {
while (times--) {
Expand Down Expand Up @@ -131,7 +131,7 @@ class MicrosoftAuthFlow {
return playfab
}

async getMinecraftServicesToken () {
async getMinecraftBedrockServicesToken ({ verison }) {
const cache = await this.mcs.getCachedAccessToken()

if (cache.valid) {
Expand All @@ -140,7 +140,7 @@ class MicrosoftAuthFlow {

const playfab = await this.getPlayfabLogin()

const mcs = await this.mcs.getAccessToken(playfab.SessionTicket)
const mcs = await this.mcs.getAccessToken(playfab.SessionTicket, { verison })

return mcs
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fetch = require('node-fetch')
const { Endpoints } = require('../common/Constants')
const { checkStatus } = require('../common/Util')

class MinecraftServicesTokenManager {
class MinecraftBedrockServicesTokenManager {
constructor (cache) {
this.cache = cache
}
Expand Down Expand Up @@ -63,4 +63,4 @@ class MinecraftServicesTokenManager {
}
}

module.exports = MinecraftServicesTokenManager
module.exports = MinecraftBedrockServicesTokenManager

0 comments on commit 33e575f

Please sign in to comment.