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

Update mcpc endpoint for entitlements check #101

Merged
Merged
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
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
Loading