generated from PrismarineJS/prismarine-template
-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.d.ts
147 lines (132 loc) · 4.55 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/// <reference types="node" />
import { KeyObject } from 'crypto'
declare module 'prismarine-auth' {
export class Authflow {
/**
* Creates a new Authflow instance, which holds its own token cache
* @param username A unique identifier. If using password auth, this should be an email.
* @param cache Where to place token cache or a cache factory function.
* @param options Options
* @param codeCallback Optional callback to recieve token information using device code auth
*/
constructor(username?: string, cache?: string | CacheFactory, options?: MicrosoftAuthFlowOptions, codeCallback?: (res: ServerDeviceCodeResponse) => void)
// Returns a Microsoft Oauth access token -- https://docs.microsoft.com/en-us/azure/active-directory/develop/access-tokens
getMsaToken(): Promise<string>
// Returns an XSTS token -- https://docs.microsoft.com/en-us/gaming/xbox-live/api-ref/xbox-live-rest/additional/edsauthorization
getXboxToken(relyingParty?: string): Promise<{
userXUID: string,
userHash: string,
XSTSToken: string,
expiresOn: number
}>
// Returns a Minecraft Java Edition auth token
getMinecraftJavaToken(options?: {
fetchCertificates?: boolean,
fetchEntitlements?: boolean
fetchProfile?: boolean
}): 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
}
export interface MinecraftJavaProfile {
id: string
name: string
skins: MinecraftJavaProfileSkin[]
capes: MinecraftJavaProfileCape[]
}
export interface MinecraftJavaProfileSkin {
id: string,
state: string,
url: string,
variant: 'CLASSIC'|'SLIM'
}
export interface MinecraftJavaProfileCape {
id: string,
state: string,
url: string,
alias: string
}
export interface MinecraftJavaCertificatesRaw {
keyPair: {
privateKey: string
publicKey: string
}
publicKeySignature: string
publicKeySignatureV2: string
expiresAt: string
refreshedAfter: string
}
export interface MinecraftJavaCertificates {
profileKeys: {
public: KeyObject
private: KeyObject
// PEM encoded keys from server
publicPEM: string
privatePEM: string
// DER transformed keys
publicDER: string,
privateDER: string
},
expiresOn: string
refreshAfter: string
}
export interface MicrosoftAuthFlowOptions {
// If using Azure auth, specify an custom object to pass to MSAL
msalConfig?: object
authTitle?: Titles
deviceType?: string
deviceVersion?: string
password?: string
flow: 'live' | 'msal' | 'sisu'
// Reset the cache and obtain fresh tokens for everything
forceRefresh?: boolean
}
export enum Titles {
MinecraftNintendoSwitch = '00000000441cc96b',
MinecraftPlaystation = '000000004827c78e',
MinecraftAndroid = '0000000048183522',
MinecraftJava = '00000000402b5328',
MinecraftIOS = '000000004c17c01a',
XboxAppIOS = '000000004c12ae6f',
XboxGamepassIOS = '000000004c20a908'
}
export enum RelyingParty {
PCXSTSRelyingParty = 'rp://api.minecraftservices.com/',
BedrockXSTSRelyingParty = 'https://multiplayer.minecraft.net/',
XboxAuthRelyingParty = 'http://auth.xboxlive.com/',
XboxRelyingParty = 'http://xboxlive.com'
}
type ServerDeviceCodeResponse = {
user_code: string
device_code: string
verification_uri: string
expires_in: number
interval: number
message: string
}
export interface Cache {
reset(): Promise<void>
getCached(): Promise<any>
setCached(value: any): Promise<void>
setCachedPartial(value: any): Promise<void>
}
export type CacheFactory = (options: { username: string, cacheName: string }) => Cache
}