halo-infinite-api 5.3.3 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authentication/halo-authentication-client.js +15 -7
- package/dist/authentication/halo-authentication-client.js.map +1 -1
- package/dist/authentication/xbox-authentication-client.js +29 -14
- package/dist/authentication/xbox-authentication-client.js.map +1 -1
- package/dist/core/halo-infinite-client.d.ts +7 -0
- package/dist/core/halo-infinite-client.js +46 -12
- package/dist/core/halo-infinite-client.js.map +1 -1
- package/dist/core/xbox-client.js +8 -2
- package/dist/core/xbox-client.js.map +1 -1
- package/dist/endpoints/halo-core-endpoints.d.ts +1 -0
- package/dist/endpoints/halo-core-endpoints.js +1 -0
- package/dist/endpoints/halo-core-endpoints.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/models/halo-infinite/matches-privacy.d.ts +8 -0
- package/dist/models/halo-infinite/matches-privacy.js +6 -0
- package/dist/models/halo-infinite/matches-privacy.js.map +1 -0
- package/dist/util/fetch-function.d.ts +2 -2
- package/dist/util/fetch-function.js +1 -4
- package/dist/util/fetch-function.js.map +1 -1
- package/dist/util/request-error.d.ts +6 -0
- package/dist/util/request-error.js +21 -0
- package/dist/util/request-error.js.map +1 -0
- package/package.json +1 -1
- package/src/authentication/halo-authentication-client.ts +22 -18
- package/src/authentication/xbox-authentication-client.ts +62 -51
- package/src/core/halo-infinite-client.ts +69 -8
- package/src/core/xbox-client.ts +7 -2
- package/src/endpoints/halo-core-endpoints.ts +1 -0
- package/src/index.ts +5 -0
- package/src/models/halo-infinite/matches-privacy.ts +9 -0
- package/src/util/fetch-function.ts +4 -7
- package/src/util/request-error.ts +23 -0
- package/dist/core/spartan-token-fetchers/auto-xsts-sartan-token-provider.d.ts +0 -11
- package/dist/core/spartan-token-fetchers/auto-xsts-sartan-token-provider.js +0 -43
- package/dist/core/spartan-token-fetchers/auto-xsts-sartan-token-provider.js.map +0 -1
- package/dist/core/spartan-token-fetchers/index.d.ts +0 -3
- package/dist/core/spartan-token-fetchers/index.js +0 -2
- package/dist/core/spartan-token-fetchers/index.js.map +0 -1
- package/dist/core/spartan-token-fetchers/static-xsts-ticket-token-spartan-token-provider.d.ts +0 -12
- package/dist/core/spartan-token-fetchers/static-xsts-ticket-token-spartan-token-provider.js +0 -26
- package/dist/core/spartan-token-fetchers/static-xsts-ticket-token-spartan-token-provider.js.map +0 -1
- package/dist/core/spartan-token-providers/auto-xsts-spartan-token-provider.d.ts +0 -11
- package/dist/core/spartan-token-providers/auto-xsts-spartan-token-provider.js +0 -29
- package/dist/core/spartan-token-providers/auto-xsts-spartan-token-provider.js.map +0 -1
- package/dist/core/spartan-token-providers/index.d.ts +0 -3
- package/dist/core/spartan-token-providers/index.js +0 -2
- package/dist/core/spartan-token-providers/index.js.map +0 -1
- package/dist/core/spartan-token-providers/static-xsts-ticket-token-spartan-token-provider.d.ts +0 -12
- package/dist/core/spartan-token-providers/static-xsts-ticket-token-spartan-token-provider.js +0 -25
- package/dist/core/spartan-token-providers/static-xsts-ticket-token-spartan-token-provider.js.map +0 -1
- package/dist/core/token-persister.d.ts +0 -4
- package/dist/core/token-persister.js +0 -2
- package/dist/core/token-persister.js.map +0 -1
- package/dist/core/token-providers/spartan-token-providers/auto-xsts-spartan-token-provider.d.ts +0 -11
- package/dist/core/token-providers/spartan-token-providers/auto-xsts-spartan-token-provider.js +0 -29
- package/dist/core/token-providers/spartan-token-providers/auto-xsts-spartan-token-provider.js.map +0 -1
- package/dist/models/halo-infinite/authoring-asset.d.ts +0 -56
- package/dist/models/halo-infinite/authoring-asset.js +0 -2
- package/dist/models/halo-infinite/authoring-asset.js.map +0 -1
|
@@ -4,6 +4,7 @@ import { XboxTicket } from "../models/xbox-ticket";
|
|
|
4
4
|
import { KeyedExpiryTokenCache } from "../util/keyed-expiry-token-cache";
|
|
5
5
|
import { ExpiryTokenCache } from "../util/expiry-token-cache";
|
|
6
6
|
import { FetchFunction, defaultFetch } from "../util/fetch-function";
|
|
7
|
+
import { RequestError } from "../util/request-error";
|
|
7
8
|
|
|
8
9
|
export enum RelyingParty {
|
|
9
10
|
Xbox = "http://xboxlive.com",
|
|
@@ -19,33 +20,39 @@ export interface XboxAuthenticationToken {
|
|
|
19
20
|
export class XboxAuthenticationClient {
|
|
20
21
|
private userTokenCache = new ExpiryTokenCache(
|
|
21
22
|
async (accessToken: string) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
const url = "https://user.auth.xboxlive.com/user/authenticate";
|
|
24
|
+
const response = await this.fetchFn(url, {
|
|
25
|
+
method: "POST",
|
|
26
|
+
headers: {
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
Accept: "application/json",
|
|
29
|
+
"x-xbl-contract-version": "1",
|
|
30
|
+
},
|
|
31
|
+
body: JSON.stringify({
|
|
32
|
+
RelyingParty: "http://auth.xboxlive.com",
|
|
33
|
+
TokenType: "JWT",
|
|
34
|
+
Properties: {
|
|
35
|
+
AuthMethod: "RPS",
|
|
36
|
+
SiteName: "user.auth.xboxlive.com",
|
|
37
|
+
RpsTicket: `d=${accessToken}`,
|
|
30
38
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
SiteName: "user.auth.xboxlive.com",
|
|
37
|
-
RpsTicket: `d=${accessToken}`,
|
|
38
|
-
},
|
|
39
|
-
}),
|
|
40
|
-
}
|
|
41
|
-
);
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (response.status >= 200 && response.status < 300) {
|
|
43
|
+
const result = (await response.json()) as XboxTicket;
|
|
42
44
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const token = {
|
|
46
|
+
...result,
|
|
47
|
+
expiresAt: DateTime.fromISO(result.NotAfter),
|
|
48
|
+
};
|
|
49
|
+
await (
|
|
50
|
+
await this.tokenPersisterOrPromise
|
|
51
|
+
)?.save("xbox.userToken", token);
|
|
52
|
+
return token;
|
|
53
|
+
} else {
|
|
54
|
+
throw new RequestError(url, response);
|
|
55
|
+
}
|
|
49
56
|
},
|
|
50
57
|
async () => {
|
|
51
58
|
const tokenPersister = await this.tokenPersisterOrPromise;
|
|
@@ -58,34 +65,38 @@ export class XboxAuthenticationClient {
|
|
|
58
65
|
);
|
|
59
66
|
private xstsTicketCache = new KeyedExpiryTokenCache(
|
|
60
67
|
async (relyingParty: RelyingParty, userToken: string) => {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
const url = "https://xsts.auth.xboxlive.com/xsts/authorize";
|
|
69
|
+
const response = await this.fetchFn(url, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
headers: {
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
Accept: "application/json",
|
|
74
|
+
"x-xbl-contract-version": "1",
|
|
75
|
+
},
|
|
76
|
+
body: JSON.stringify({
|
|
77
|
+
RelyingParty: relyingParty,
|
|
78
|
+
TokenType: "JWT",
|
|
79
|
+
Properties: {
|
|
80
|
+
SandboxId: "RETAIL",
|
|
81
|
+
UserTokens: [userToken],
|
|
69
82
|
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
TokenType: "JWT",
|
|
73
|
-
Properties: {
|
|
74
|
-
SandboxId: "RETAIL",
|
|
75
|
-
UserTokens: [userToken],
|
|
76
|
-
},
|
|
77
|
-
}),
|
|
78
|
-
}
|
|
79
|
-
);
|
|
83
|
+
}),
|
|
84
|
+
});
|
|
80
85
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
if (response.status >= 200 && response.status < 300) {
|
|
87
|
+
const result = (await response.json()) as XboxTicket;
|
|
88
|
+
|
|
89
|
+
const token = {
|
|
90
|
+
...result,
|
|
91
|
+
expiresAt: DateTime.fromISO(result.NotAfter),
|
|
92
|
+
};
|
|
93
|
+
await (
|
|
94
|
+
await this.tokenPersisterOrPromise
|
|
95
|
+
)?.save("xbox.xstsTicket." + relyingParty, token);
|
|
96
|
+
return token;
|
|
97
|
+
} else {
|
|
98
|
+
throw new RequestError(url, response);
|
|
99
|
+
}
|
|
89
100
|
},
|
|
90
101
|
async (relyingParty) =>
|
|
91
102
|
(await (
|
|
@@ -16,6 +16,8 @@ import { ServiceRecord } from "../models/halo-infinite/service-record";
|
|
|
16
16
|
import { UserInfo } from "../models/halo-infinite/user-info";
|
|
17
17
|
import { GlobalConstants } from "../util/global-contants";
|
|
18
18
|
import { SpartanTokenProvider } from "./token-providers/spartan-token-providers";
|
|
19
|
+
import { RequestError } from "../util/request-error";
|
|
20
|
+
import { MatchesPrivacy } from "src/models/halo-infinite/matches-privacy";
|
|
19
21
|
|
|
20
22
|
export interface ResultContainer<TValue> {
|
|
21
23
|
Id: string;
|
|
@@ -85,20 +87,35 @@ export class HaloInfiniteClient {
|
|
|
85
87
|
await this.spartanTokenProvider.getSpartanToken()
|
|
86
88
|
);
|
|
87
89
|
|
|
88
|
-
const
|
|
90
|
+
const response = await this.fetchFn(url, {
|
|
89
91
|
...init,
|
|
90
92
|
headers,
|
|
91
93
|
});
|
|
92
94
|
|
|
93
|
-
|
|
95
|
+
if (response.status >= 200 && response.status < 300) {
|
|
96
|
+
return (await response.json()) as T;
|
|
97
|
+
} else {
|
|
98
|
+
throw new RequestError(url, response);
|
|
99
|
+
}
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
private async executeResultsRequest<T>(
|
|
97
103
|
...args: Parameters<HaloInfiniteClient["executeRequest"]>
|
|
98
104
|
) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
105
|
+
let resultsContainer: ResultsContainer<T>;
|
|
106
|
+
try {
|
|
107
|
+
resultsContainer = await this.executeRequest<ResultsContainer<T>>(
|
|
108
|
+
...args
|
|
109
|
+
);
|
|
110
|
+
} catch (e) {
|
|
111
|
+
if (e instanceof RequestError && e.response.status === 404) {
|
|
112
|
+
// 404s if even one of the xuids is invalid
|
|
113
|
+
resultsContainer = (await e.response.json()) as ResultsContainer<T>;
|
|
114
|
+
} else {
|
|
115
|
+
throw e;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return resultsContainer.Value;
|
|
102
119
|
}
|
|
103
120
|
|
|
104
121
|
private async executePaginationRequest<T>(
|
|
@@ -265,8 +282,8 @@ export class HaloInfiniteClient {
|
|
|
265
282
|
matchId: string,
|
|
266
283
|
playerIds: string[],
|
|
267
284
|
init?: Omit<RequestInit, "body" | "method">
|
|
268
|
-
) =>
|
|
269
|
-
|
|
285
|
+
) =>
|
|
286
|
+
await this.executeResultsRequest<MatchSkill>(
|
|
270
287
|
`https://${HaloCoreEndpoints.SkillOrigin}.${
|
|
271
288
|
HaloCoreEndpoints.ServiceDomain
|
|
272
289
|
}/hi/matches/${matchId}/skill?players=${playerIds
|
|
@@ -277,7 +294,6 @@ export class HaloInfiniteClient {
|
|
|
277
294
|
method: "get",
|
|
278
295
|
}
|
|
279
296
|
);
|
|
280
|
-
};
|
|
281
297
|
|
|
282
298
|
/** Gets authoring metadata about a specific asset. */
|
|
283
299
|
public getAsset = <TAssetType extends keyof AssetKindTypeMap>(
|
|
@@ -307,4 +323,49 @@ export class HaloInfiniteClient {
|
|
|
307
323
|
method: "get",
|
|
308
324
|
}
|
|
309
325
|
);
|
|
326
|
+
|
|
327
|
+
public getCurrentUser = (
|
|
328
|
+
init?: Omit<RequestInit, "body" | "method">
|
|
329
|
+
): Promise<{ xuid: string; notificationsReadDate: string }> =>
|
|
330
|
+
this.executeRequest(
|
|
331
|
+
`https://${HaloCoreEndpoints.CommsOrigin}.${HaloCoreEndpoints.ServiceDomain}/users/me`,
|
|
332
|
+
{
|
|
333
|
+
...init,
|
|
334
|
+
method: "get",
|
|
335
|
+
}
|
|
336
|
+
);
|
|
337
|
+
|
|
338
|
+
public getMatchesPrivacy = (
|
|
339
|
+
playerXuid: string,
|
|
340
|
+
init?: Omit<RequestInit, "body" | "method">
|
|
341
|
+
): Promise<MatchesPrivacy> =>
|
|
342
|
+
this.executeRequest(
|
|
343
|
+
`https://${HaloCoreEndpoints.StatsOrigin}.${
|
|
344
|
+
HaloCoreEndpoints.ServiceDomain
|
|
345
|
+
}/hi/players/${wrapPlayerId(playerXuid)}/matches-privacy`,
|
|
346
|
+
{
|
|
347
|
+
...init,
|
|
348
|
+
method: "get",
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
|
|
352
|
+
public updateMatchesPrivacy = (
|
|
353
|
+
playerXuid: string,
|
|
354
|
+
matchesPrivacy: MatchesPrivacy,
|
|
355
|
+
init?: Omit<RequestInit, "body" | "method">
|
|
356
|
+
): Promise<MatchesPrivacy> => {
|
|
357
|
+
const headers = new Headers(init?.headers);
|
|
358
|
+
headers.set("Content-Type", "application/json");
|
|
359
|
+
return this.executeRequest(
|
|
360
|
+
`https://${HaloCoreEndpoints.StatsOrigin}.${
|
|
361
|
+
HaloCoreEndpoints.ServiceDomain
|
|
362
|
+
}/hi/players/${wrapPlayerId(playerXuid)}/matches-privacy`,
|
|
363
|
+
{
|
|
364
|
+
...init,
|
|
365
|
+
method: "put",
|
|
366
|
+
headers,
|
|
367
|
+
body: JSON.stringify({ matchesPrivacy }),
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
};
|
|
310
371
|
}
|
package/src/core/xbox-client.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RequestError } from "../util/request-error";
|
|
1
2
|
import { FetchFunction, defaultFetch } from "../util/fetch-function";
|
|
2
3
|
import { XboxTokenProvider } from "./token-providers/xbox-token-provider";
|
|
3
4
|
|
|
@@ -21,12 +22,16 @@ export class XboxClient {
|
|
|
21
22
|
if (!headers.has("x-xbl-contract-version")) {
|
|
22
23
|
headers.set("x-xbl-contract-version", "1");
|
|
23
24
|
}
|
|
24
|
-
const
|
|
25
|
+
const response = await this.fetchFn(url, {
|
|
25
26
|
...init,
|
|
26
27
|
headers,
|
|
27
28
|
});
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
if (response.status >= 200 && response.status < 300) {
|
|
31
|
+
return (await response.json()) as T;
|
|
32
|
+
} else {
|
|
33
|
+
throw new RequestError(url, response);
|
|
34
|
+
}
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
public async searchUsers(
|
package/src/index.ts
CHANGED
|
@@ -31,6 +31,10 @@ export { MatchOutcome } from "./models/halo-infinite/match-outcome";
|
|
|
31
31
|
export { MatchSkill } from "./models/halo-infinite/match-skill";
|
|
32
32
|
export { MatchStats } from "./models/halo-infinite/match-stats";
|
|
33
33
|
export { MatchType } from "./models/halo-infinite/match-type";
|
|
34
|
+
export {
|
|
35
|
+
MatchesPrivacy,
|
|
36
|
+
Privacy,
|
|
37
|
+
} from "./models/halo-infinite/matches-privacy";
|
|
34
38
|
export { PlayerMatchHistory } from "./models/halo-infinite/player-match-history";
|
|
35
39
|
export { Playlist } from "./models/halo-infinite/playlist";
|
|
36
40
|
export { PlaylistCsr } from "./models/halo-infinite/playlist-csr";
|
|
@@ -40,3 +44,4 @@ export { ServiceRecord } from "./models/halo-infinite/service-record";
|
|
|
40
44
|
export { Stats } from "./models/halo-infinite/stats";
|
|
41
45
|
export { UserInfo } from "./models/halo-infinite/user-info";
|
|
42
46
|
export { FetchFunction } from "./util/fetch-function";
|
|
47
|
+
export { RequestError } from "./util/request-error";
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
export type FetchFunction =
|
|
1
|
+
export type FetchFunction = (
|
|
2
2
|
input: RequestInfo | URL,
|
|
3
3
|
init?: RequestInit
|
|
4
|
-
) => Promise<
|
|
4
|
+
) => Promise<Response>;
|
|
5
5
|
|
|
6
|
-
export const defaultFetch = async
|
|
6
|
+
export const defaultFetch = async (
|
|
7
7
|
input: RequestInfo | URL,
|
|
8
8
|
init?: RequestInit
|
|
9
|
-
): Promise<
|
|
10
|
-
const response = await fetch(input, init);
|
|
11
|
-
return response.json();
|
|
12
|
-
};
|
|
9
|
+
): Promise<Response> => fetch(input, init);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export class RequestError extends Error {
|
|
2
|
+
public readonly url: string;
|
|
3
|
+
constructor(
|
|
4
|
+
public readonly request: RequestInfo | URL,
|
|
5
|
+
public readonly response: Response
|
|
6
|
+
) {
|
|
7
|
+
super(
|
|
8
|
+
`${
|
|
9
|
+
typeof request === "object" && "url" in request
|
|
10
|
+
? request.url
|
|
11
|
+
: typeof request === "string"
|
|
12
|
+
? request
|
|
13
|
+
: request.href
|
|
14
|
+
} ${response.status} ${response.statusText}`
|
|
15
|
+
);
|
|
16
|
+
this.url =
|
|
17
|
+
typeof request === "object" && "url" in request
|
|
18
|
+
? request.url
|
|
19
|
+
: typeof request === "string"
|
|
20
|
+
? request
|
|
21
|
+
: request.href;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TokenPersister } from "../token-persister";
|
|
2
|
-
import { SpartanTokenProvider } from ".";
|
|
3
|
-
/**
|
|
4
|
-
* A SpartanTokenProvider that fetches both the Xbox and Halo tokens in the same
|
|
5
|
-
* process. This is useful for applications that do not need to contend with
|
|
6
|
-
* CORS restrictions.
|
|
7
|
-
*/
|
|
8
|
-
export declare class AutoXstsSpartanTokenProvider implements SpartanTokenProvider {
|
|
9
|
-
readonly getSpartanToken: () => Promise<string>;
|
|
10
|
-
constructor(clientId: string, redirectUri: string, getAuthCode: (authorizeUrl: string) => Promise<string>, tokenPersister?: TokenPersister);
|
|
11
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { RelyingParty, XboxAuthenticationClient, } from "../../authentication/xbox-authentication-client";
|
|
2
|
-
import { HaloAuthenticationClient } from "../../authentication/halo-authentication-client";
|
|
3
|
-
/**
|
|
4
|
-
* A SpartanTokenProvider that fetches both the Xbox and Halo tokens in the same
|
|
5
|
-
* process. This is useful for applications that do not need to contend with
|
|
6
|
-
* CORS restrictions.
|
|
7
|
-
*/
|
|
8
|
-
export class AutoXstsSpartanTokenProvider {
|
|
9
|
-
getSpartanToken;
|
|
10
|
-
constructor(clientId, redirectUri, getAuthCode, tokenPersister) {
|
|
11
|
-
const xboxAuthClient = new XboxAuthenticationClient(clientId, redirectUri, getAuthCode, async () => {
|
|
12
|
-
if (tokenPersister) {
|
|
13
|
-
return await tokenPersister.load("xbox.authToken");
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
}, async (token) => {
|
|
19
|
-
if (tokenPersister) {
|
|
20
|
-
await tokenPersister.save("xbox.authToken", token);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
const haloAuthClient = new HaloAuthenticationClient(async () => {
|
|
24
|
-
const accessToken = await xboxAuthClient.getAccessToken();
|
|
25
|
-
const userToken = await xboxAuthClient.getUserToken(accessToken);
|
|
26
|
-
const xstsTicket = await xboxAuthClient.getXstsTicket(userToken, RelyingParty.Halo);
|
|
27
|
-
return xstsTicket.Token;
|
|
28
|
-
}, async () => {
|
|
29
|
-
if (tokenPersister) {
|
|
30
|
-
return await tokenPersister.load("halo.authToken");
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}, async (token) => {
|
|
36
|
-
if (tokenPersister) {
|
|
37
|
-
await tokenPersister.save("halo.authToken", token);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
this.getSpartanToken = () => haloAuthClient.getSpartanToken();
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=auto-xsts-sartan-token-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-xsts-sartan-token-provider.js","sourceRoot":"","sources":["../../../src/core/spartan-token-fetchers/auto-xsts-sartan-token-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,wBAAwB,GACzB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAG3F;;;;GAIG;AACH,MAAM,OAAO,4BAA4B;IACvB,eAAe,CAAwB;IAEvD,YACE,QAAgB,EAChB,WAAmB,EACnB,WAAsD,EACtD,cAA+B;QAE/B,MAAM,cAAc,GAAG,IAAI,wBAAwB,CACjD,QAAQ,EACR,WAAW,EACX,WAAW,EACX,KAAK,IAAI,EAAE;YACT,IAAI,cAAc,EAAE;gBAClB,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;aACpD;iBAAM;gBACL,OAAO,IAAI,CAAC;aACb;QACH,CAAC,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACd,IAAI,cAAc,EAAE;gBAClB,MAAM,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;aACpD;QACH,CAAC,CACF,CAAC;QACF,MAAM,cAAc,GAAG,IAAI,wBAAwB,CACjD,KAAK,IAAI,EAAE;YACT,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,cAAc,EAAE,CAAC;YAC1D,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;YACjE,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,CACnD,SAAS,EACT,YAAY,CAAC,IAAI,CAClB,CAAC;YACF,OAAO,UAAU,CAAC,KAAK,CAAC;QAC1B,CAAC,EACD,KAAK,IAAI,EAAE;YACT,IAAI,cAAc,EAAE;gBAClB,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;aACpD;iBAAM;gBACL,OAAO,IAAI,CAAC;aACb;QACH,CAAC,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACd,IAAI,cAAc,EAAE;gBAClB,MAAM,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;aACpD;QACH,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,eAAe,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/spartan-token-fetchers/index.ts"],"names":[],"mappings":""}
|
package/dist/core/spartan-token-fetchers/static-xsts-ticket-token-spartan-token-provider.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TokenPersister } from "../token-persister";
|
|
2
|
-
import { SpartanTokenProvider } from ".";
|
|
3
|
-
/**
|
|
4
|
-
* A SpartanTokenProvider that fetches uses a pre-fetched XSTS ticket token.
|
|
5
|
-
* Since requests to the Halo API are subject to CORS restrictions a
|
|
6
|
-
* HaloAuthenticationClient can be instantitated with a pre-fetched XSTS ticket
|
|
7
|
-
* and run on a server (such as one provided by the user).
|
|
8
|
-
*/
|
|
9
|
-
export declare class StaticXstsTicketTokenSpartanTokenProvider implements SpartanTokenProvider {
|
|
10
|
-
readonly getSpartanToken: () => Promise<string>;
|
|
11
|
-
constructor(xstsTicketToken: string, tokenPersister?: TokenPersister);
|
|
12
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { HaloAuthenticationClient } from "../../authentication/halo-authentication-client";
|
|
2
|
-
/**
|
|
3
|
-
* A SpartanTokenProvider that fetches uses a pre-fetched XSTS ticket token.
|
|
4
|
-
* Since requests to the Halo API are subject to CORS restrictions a
|
|
5
|
-
* HaloAuthenticationClient can be instantitated with a pre-fetched XSTS ticket
|
|
6
|
-
* and run on a server (such as one provided by the user).
|
|
7
|
-
*/
|
|
8
|
-
export class StaticXstsTicketTokenSpartanTokenProvider {
|
|
9
|
-
getSpartanToken;
|
|
10
|
-
constructor(xstsTicketToken, tokenPersister) {
|
|
11
|
-
const haloAuthClient = new HaloAuthenticationClient(() => xstsTicketToken, async () => {
|
|
12
|
-
if (tokenPersister) {
|
|
13
|
-
return await tokenPersister.load("halo.authToken");
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
}, async (token) => {
|
|
19
|
-
if (tokenPersister) {
|
|
20
|
-
await tokenPersister.save("halo.authToken", token);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
this.getSpartanToken = () => haloAuthClient.getSpartanToken();
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=static-xsts-ticket-token-spartan-token-provider.js.map
|
package/dist/core/spartan-token-fetchers/static-xsts-ticket-token-spartan-token-provider.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"static-xsts-ticket-token-spartan-token-provider.js","sourceRoot":"","sources":["../../../src/core/spartan-token-fetchers/static-xsts-ticket-token-spartan-token-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAG3F;;;;;GAKG;AAEH,MAAM,OAAO,yCAAyC;IAGpC,eAAe,CAAwB;IAEvD,YAAY,eAAuB,EAAE,cAA+B;QAClE,MAAM,cAAc,GAAG,IAAI,wBAAwB,CACjD,GAAG,EAAE,CAAC,eAAe,EACrB,KAAK,IAAI,EAAE;YACT,IAAI,cAAc,EAAE;gBAClB,OAAO,MAAM,cAAc,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;aACpD;iBAAM;gBACL,OAAO,IAAI,CAAC;aACb;QACH,CAAC,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACd,IAAI,cAAc,EAAE;gBAClB,MAAM,cAAc,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;aACpD;QACH,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,eAAe,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TokenPersister } from "../token-persisters";
|
|
2
|
-
import { SpartanTokenProvider } from ".";
|
|
3
|
-
/**
|
|
4
|
-
* A SpartanTokenProvider that fetches both the Xbox and Halo tokens in the same
|
|
5
|
-
* process. This is useful for applications that do not need to contend with
|
|
6
|
-
* CORS restrictions.
|
|
7
|
-
*/
|
|
8
|
-
export declare class AutoXstsSpartanTokenProvider implements SpartanTokenProvider {
|
|
9
|
-
readonly getSpartanToken: () => Promise<string>;
|
|
10
|
-
constructor(getOauth2AccessToken: () => Promise<string>, tokenPersister?: TokenPersister);
|
|
11
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { XboxAuthenticationClient, } from "../../authentication/xbox-authentication-client";
|
|
2
|
-
import { HaloAuthenticationClient } from "../../authentication/halo-authentication-client";
|
|
3
|
-
import { inMemoryTokenPersister } from "../token-persisters/in-memory-token-persister";
|
|
4
|
-
/**
|
|
5
|
-
* A SpartanTokenProvider that fetches both the Xbox and Halo tokens in the same
|
|
6
|
-
* process. This is useful for applications that do not need to contend with
|
|
7
|
-
* CORS restrictions.
|
|
8
|
-
*/
|
|
9
|
-
export class AutoXstsSpartanTokenProvider {
|
|
10
|
-
getSpartanToken;
|
|
11
|
-
constructor(getOauth2AccessToken, tokenPersister) {
|
|
12
|
-
let actualTokenPersister;
|
|
13
|
-
if (tokenPersister) {
|
|
14
|
-
actualTokenPersister = tokenPersister;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
actualTokenPersister = inMemoryTokenPersister;
|
|
18
|
-
}
|
|
19
|
-
const xboxAuthClient = new XboxAuthenticationClient(tokenPersister);
|
|
20
|
-
const haloAuthClient = new HaloAuthenticationClient(async () => {
|
|
21
|
-
const xstsTicket = await xboxAuthClient.getXstsTicket(getOauth2AccessToken);
|
|
22
|
-
return xstsTicket.Token;
|
|
23
|
-
}, async () => await actualTokenPersister.load("halo.authToken"), async (token) => {
|
|
24
|
-
await actualTokenPersister.save("halo.authToken", token);
|
|
25
|
-
});
|
|
26
|
-
this.getSpartanToken = () => haloAuthClient.getSpartanToken();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=auto-xsts-spartan-token-provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-xsts-spartan-token-provider.js","sourceRoot":"","sources":["../../../src/core/spartan-token-providers/auto-xsts-spartan-token-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,GACzB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAE3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF;;;;GAIG;AACH,MAAM,OAAO,4BAA4B;IACvB,eAAe,CAAwB;IAEvD,YACE,oBAA2C,EAC3C,cAA+B;QAE/B,IAAI,oBAAoC,CAAC;QACzC,IAAI,cAAc,EAAE;YAClB,oBAAoB,GAAG,cAAc,CAAC;SACvC;aAAM;YACL,oBAAoB,GAAG,sBAAsB,CAAC;SAC/C;QACD,MAAM,cAAc,GAAG,IAAI,wBAAwB,CAAC,cAAc,CAAC,CAAC;QACpE,MAAM,cAAc,GAAG,IAAI,wBAAwB,CACjD,KAAK,IAAI,EAAE;YACT,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,CACnD,oBAAoB,CACrB,CAAC;YACF,OAAO,UAAU,CAAC,KAAK,CAAC;QAC1B,CAAC,EACD,KAAK,IAAI,EAAE,CAAC,MAAM,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAC7D,KAAK,EAAE,KAAK,EAAE,EAAE;YACd,MAAM,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,eAAe,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/spartan-token-providers/index.ts"],"names":[],"mappings":""}
|
package/dist/core/spartan-token-providers/static-xsts-ticket-token-spartan-token-provider.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TokenPersister } from "../token-persisters";
|
|
2
|
-
import { SpartanTokenProvider } from ".";
|
|
3
|
-
/**
|
|
4
|
-
* A SpartanTokenProvider that fetches uses a pre-fetched XSTS ticket token.
|
|
5
|
-
* Since requests to the Halo API are subject to CORS restrictions a
|
|
6
|
-
* HaloAuthenticationClient can be instantitated with a pre-fetched XSTS ticket
|
|
7
|
-
* and run on a server (such as one provided by the user).
|
|
8
|
-
*/
|
|
9
|
-
export declare class StaticXstsTicketTokenSpartanTokenProvider implements SpartanTokenProvider {
|
|
10
|
-
readonly getSpartanToken: () => Promise<string>;
|
|
11
|
-
constructor(xstsTicketToken: string, tokenPersister?: TokenPersister);
|
|
12
|
-
}
|
package/dist/core/spartan-token-providers/static-xsts-ticket-token-spartan-token-provider.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { HaloAuthenticationClient } from "../../authentication/halo-authentication-client";
|
|
2
|
-
import { inMemoryTokenPersister } from "../token-persisters/in-memory-token-persister";
|
|
3
|
-
/**
|
|
4
|
-
* A SpartanTokenProvider that fetches uses a pre-fetched XSTS ticket token.
|
|
5
|
-
* Since requests to the Halo API are subject to CORS restrictions a
|
|
6
|
-
* HaloAuthenticationClient can be instantitated with a pre-fetched XSTS ticket
|
|
7
|
-
* and run on a server (such as one provided by the user).
|
|
8
|
-
*/
|
|
9
|
-
export class StaticXstsTicketTokenSpartanTokenProvider {
|
|
10
|
-
getSpartanToken;
|
|
11
|
-
constructor(xstsTicketToken, tokenPersister) {
|
|
12
|
-
let actualTokenPersister;
|
|
13
|
-
if (tokenPersister) {
|
|
14
|
-
actualTokenPersister = tokenPersister;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
actualTokenPersister = inMemoryTokenPersister;
|
|
18
|
-
}
|
|
19
|
-
const haloAuthClient = new HaloAuthenticationClient(() => xstsTicketToken, async () => await actualTokenPersister.load("halo.authToken"), async (token) => {
|
|
20
|
-
await actualTokenPersister.save("halo.authToken", token);
|
|
21
|
-
});
|
|
22
|
-
this.getSpartanToken = () => haloAuthClient.getSpartanToken();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
//# sourceMappingURL=static-xsts-ticket-token-spartan-token-provider.js.map
|
package/dist/core/spartan-token-providers/static-xsts-ticket-token-spartan-token-provider.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"static-xsts-ticket-token-spartan-token-provider.js","sourceRoot":"","sources":["../../../src/core/spartan-token-providers/static-xsts-ticket-token-spartan-token-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAE3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;AAEvF;;;;;GAKG;AACH,MAAM,OAAO,yCAAyC;IAGpC,eAAe,CAAwB;IAEvD,YAAY,eAAuB,EAAE,cAA+B;QAClE,IAAI,oBAAoC,CAAC;QACzC,IAAI,cAAc,EAAE;YAClB,oBAAoB,GAAG,cAAc,CAAC;SACvC;aAAM;YACL,oBAAoB,GAAG,sBAAsB,CAAC;SAC/C;QAED,MAAM,cAAc,GAAG,IAAI,wBAAwB,CACjD,GAAG,EAAE,CAAC,eAAe,EACrB,KAAK,IAAI,EAAE,CAAC,MAAM,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAC7D,KAAK,EAAE,KAAK,EAAE,EAAE;YACd,MAAM,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,eAAe,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token-persister.js","sourceRoot":"","sources":["../../src/core/token-persister.ts"],"names":[],"mappings":""}
|
package/dist/core/token-providers/spartan-token-providers/auto-xsts-spartan-token-provider.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TokenPersister } from "../../token-persisters";
|
|
2
|
-
import { SpartanTokenProvider } from ".";
|
|
3
|
-
/**
|
|
4
|
-
* A SpartanTokenProvider that fetches both the Xbox and Halo tokens in the same
|
|
5
|
-
* process. This is useful for applications that do not need to contend with
|
|
6
|
-
* CORS restrictions.
|
|
7
|
-
*/
|
|
8
|
-
export declare class AutoXstsSpartanTokenProvider implements SpartanTokenProvider {
|
|
9
|
-
readonly getSpartanToken: () => Promise<string>;
|
|
10
|
-
constructor(getOauth2AccessToken: () => Promise<string>, tokenPersister?: TokenPersister);
|
|
11
|
-
}
|
package/dist/core/token-providers/spartan-token-providers/auto-xsts-spartan-token-provider.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { XboxAuthenticationClient, } from "../../../authentication/xbox-authentication-client";
|
|
2
|
-
import { HaloAuthenticationClient } from "../../../authentication/halo-authentication-client";
|
|
3
|
-
import { inMemoryTokenPersister } from "../../token-persisters/in-memory-token-persister";
|
|
4
|
-
/**
|
|
5
|
-
* A SpartanTokenProvider that fetches both the Xbox and Halo tokens in the same
|
|
6
|
-
* process. This is useful for applications that do not need to contend with
|
|
7
|
-
* CORS restrictions.
|
|
8
|
-
*/
|
|
9
|
-
export class AutoXstsSpartanTokenProvider {
|
|
10
|
-
getSpartanToken;
|
|
11
|
-
constructor(getOauth2AccessToken, tokenPersister) {
|
|
12
|
-
let actualTokenPersister;
|
|
13
|
-
if (tokenPersister) {
|
|
14
|
-
actualTokenPersister = tokenPersister;
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
actualTokenPersister = inMemoryTokenPersister;
|
|
18
|
-
}
|
|
19
|
-
const xboxAuthClient = new XboxAuthenticationClient(tokenPersister);
|
|
20
|
-
const haloAuthClient = new HaloAuthenticationClient(async () => {
|
|
21
|
-
const xstsTicket = await xboxAuthClient.getXstsTicket(getOauth2AccessToken);
|
|
22
|
-
return xstsTicket.Token;
|
|
23
|
-
}, async () => await actualTokenPersister.load("halo.authToken"), async (token) => {
|
|
24
|
-
await actualTokenPersister.save("halo.authToken", token);
|
|
25
|
-
});
|
|
26
|
-
this.getSpartanToken = () => haloAuthClient.getSpartanToken();
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=auto-xsts-spartan-token-provider.js.map
|
package/dist/core/token-providers/spartan-token-providers/auto-xsts-spartan-token-provider.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-xsts-spartan-token-provider.js","sourceRoot":"","sources":["../../../../src/core/token-providers/spartan-token-providers/auto-xsts-spartan-token-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,wBAAwB,GACzB,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAE9F,OAAO,EAAE,sBAAsB,EAAE,MAAM,kDAAkD,CAAC;AAE1F;;;;GAIG;AACH,MAAM,OAAO,4BAA4B;IACvB,eAAe,CAAwB;IAEvD,YACE,oBAA2C,EAC3C,cAA+B;QAE/B,IAAI,oBAAoC,CAAC;QACzC,IAAI,cAAc,EAAE;YAClB,oBAAoB,GAAG,cAAc,CAAC;SACvC;aAAM;YACL,oBAAoB,GAAG,sBAAsB,CAAC;SAC/C;QACD,MAAM,cAAc,GAAG,IAAI,wBAAwB,CAAC,cAAc,CAAC,CAAC;QACpE,MAAM,cAAc,GAAG,IAAI,wBAAwB,CACjD,KAAK,IAAI,EAAE;YACT,MAAM,UAAU,GAAG,MAAM,cAAc,CAAC,aAAa,CACnD,oBAAoB,CACrB,CAAC;YACF,OAAO,UAAU,CAAC,KAAK,CAAC;QAC1B,CAAC,EACD,KAAK,IAAI,EAAE,CAAC,MAAM,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,EAC7D,KAAK,EAAE,KAAK,EAAE,EAAE;YACd,MAAM,oBAAoB,CAAC,IAAI,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QAC3D,CAAC,CACF,CAAC;QAEF,IAAI,CAAC,eAAe,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;IAChE,CAAC;CACF"}
|