generated from PrismarineJS/prismarine-template
-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathindex.d.ts
222 lines (199 loc) · 6.45 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/// <reference types="node" />
import { KeyObject } from 'crypto'
declare module 'prismarine-auth' {
export class Authflow {
username: string
options: MicrosoftAuthFlowOptions
/**
* 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, forceRefresh?: boolean): 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>
getMinecraftBedrockServicesToken(config: { version: string }): Promise<GetMinecraftBedrockServicesResponse>
getPlayfabLogin(): Promise<GetPlayfabLoginResponse>
}
// 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
export type GetMinecraftBedrockServicesResponse = {
mcToken: string
validUntil: string
treatments: string[]
treatmentContext: string
configurations: object
}
export type GetPlayfabLoginResponse = {
SessionTicket: string;
PlayFabId: string;
NewlyCreated: boolean;
SettingsForUser: {
NeedsAttribution: boolean;
GatherDeviceInfo: boolean;
GatherFocusInfo: boolean;
};
LastLoginTime: string;
InfoResultPayload: {
AccountInfo: {
PlayFabId: string;
Created: string;
TitleInfo: {
Origination: string;
Created: string;
LastLogin: string;
FirstLogin: string;
isBanned: boolean;
TitlePlayerAccount: {
Id: string;
Type: string;
TypeString: string;
};
};
PrivateInfo: Record<string, unknown>;
XboxInfo: {
XboxUserId: string;
XboxUserSandbox: string;
};
};
UserInventory: any[];
UserDataVersion: number;
UserReadOnlyDataVersion: number;
CharacterInventories: any[];
PlayerProfile: {
PublisherId: string;
TitleId: string;
PlayerId: string;
};
};
EntityToken: {
EntityToken: string;
TokenExpiration: string;
Entity: {
Id: string;
Type: string;
TypeString: string;
};
};
TreatmentAssignment: {
Variants: any[];
Variables: any[];
};
}
}