Skip to content

Commit

Permalink
Update mcpc endpoint for entitlements check (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
extremeheat authored May 29, 2024
1 parent 01c8266 commit d7ac3de
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
13 changes: 11 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,26 @@ declare module 'prismarine-auth' {
fetchCertificates?: boolean,
fetchEntitlements?: boolean
fetchProfile?: boolean
}): Promise<{ token: string, entitlements: MinecraftJavaEntitlements, profile: MinecraftJavaProfile, certificates: MinecraftJavaCertificates }>
}): Promise<{ token: string, entitlements: MinecraftJavaLicenses, profile: MinecraftJavaProfile, certificates: MinecraftJavaCertificates }>
// Returns a Minecraft Bedrock Edition auth token. Public key parameter must be a KeyLike object.
getMinecraftBedrockToken(publicKey: KeyObject): Promise<string>
}

// via request to https://api.minecraftservices.com/entitlements/license, a list of licenses the player has
// which includes available access via Xbox Game Pass subscriptions
export interface MinecraftJavaLicenses {
items: { name: string, source: string }[]
signature: string
keyId: string
errors?: unknown[]
}

// via https://api.minecraftservices.com/entitlements/mcstore
export interface MinecraftJavaEntitlements {
items: MinecraftJavaEntitlementsItem[]
signature: string
keyId: string
}

export interface MinecraftJavaEntitlementsItem {
name: string
signature: string
Expand Down
2 changes: 1 addition & 1 deletion src/TokenManagers/MinecraftJavaTokenManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class MinecraftJavaTokenManager {
async fetchEntitlements (accessToken) {
debug(`[mc] fetching entitlements with ${accessToken.slice(0, 16)}`)
const headers = { ...fetchOptions.headers, Authorization: `Bearer ${accessToken}` }
const entitlements = await fetch(Endpoints.MinecraftServicesEntitlement, { headers }).then(checkStatus)
const entitlements = await fetch(Endpoints.MinecraftServicesLicense + `?requestId=${crypto.randomUUID()}`, { headers }).then(checkStatus)
debug(`[mc] got entitlement response: ${entitlements}`)
return entitlements
}
Expand Down
1 change: 1 addition & 0 deletions src/common/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
MinecraftServicesLogWithXbox: 'https://api.minecraftservices.com/authentication/login_with_xbox',
MinecraftServicesCertificate: 'https://api.minecraftservices.com/player/certificates',
MinecraftServicesEntitlement: 'https://api.minecraftservices.com/entitlements/mcstore',
MinecraftServicesLicense: 'https://api.minecraftservices.com/entitlements/license',
MinecraftServicesProfile: 'https://api.minecraftservices.com/minecraft/profile',
MinecraftServicesReport: 'https://api.minecraftservices.com/player/report',
LiveDeviceCodeRequest: 'https://login.live.com/oauth20_connect.srf',
Expand Down

0 comments on commit d7ac3de

Please sign in to comment.