halo-infinite-api 14.2.1 → 14.2.2

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.
Files changed (89) hide show
  1. package/coverage/lcov-report/authentication/halo-authentication-client.ts.html +1 -1
  2. package/coverage/lcov-report/authentication/index.html +1 -1
  3. package/coverage/lcov-report/authentication/xbox-authentication-client.ts.html +1 -1
  4. package/coverage/lcov-report/core/halo-infinite-client.ts.html +57 -9
  5. package/coverage/lcov-report/core/index.html +14 -14
  6. package/coverage/lcov-report/core/request-policy.ts.html +1 -1
  7. package/coverage/lcov-report/core/token-persisters/in-memory-token-persister.ts.html +1 -1
  8. package/coverage/lcov-report/core/token-persisters/index.html +18 -18
  9. package/coverage/lcov-report/core/token-persisters/local-storage-token-persister.ts.html +1 -1
  10. package/coverage/lcov-report/core/token-persisters/node-fs-token-persister.ts.html +42 -15
  11. package/coverage/lcov-report/core/token-persisters/token-persister.ts.html +1 -1
  12. package/coverage/lcov-report/core/token-providers/auto-token-provider.ts.html +1 -1
  13. package/coverage/lcov-report/core/token-providers/index.html +1 -1
  14. package/coverage/lcov-report/core/token-providers/spartan-token-provider.ts.html +1 -1
  15. package/coverage/lcov-report/core/token-providers/static-xsts-ticket-token-spartan-token-provider.ts.html +1 -1
  16. package/coverage/lcov-report/core/token-providers/xbox-token-provider.ts.html +1 -1
  17. package/coverage/lcov-report/core/xbox-client.ts.html +1 -1
  18. package/coverage/lcov-report/endpoints/halo-core-endpoints.ts.html +2 -2
  19. package/coverage/lcov-report/endpoints/index.html +1 -1
  20. package/coverage/lcov-report/index.html +60 -45
  21. package/coverage/lcov-report/models/halo-infinite/api-formatted-date.ts.html +1 -1
  22. package/coverage/lcov-report/models/halo-infinite/asset-kind.ts.html +1 -1
  23. package/coverage/lcov-report/models/halo-infinite/asset-version-link.ts.html +1 -1
  24. package/coverage/lcov-report/models/halo-infinite/asset.ts.html +1 -1
  25. package/coverage/lcov-report/models/halo-infinite/ban-message.ts.html +97 -0
  26. package/coverage/lcov-report/models/halo-infinite/ban-summary.ts.html +28 -4
  27. package/coverage/lcov-report/models/halo-infinite/game-variant-category.ts.html +1 -1
  28. package/coverage/lcov-report/models/halo-infinite/index.html +25 -10
  29. package/coverage/lcov-report/models/halo-infinite/match-count.ts.html +1 -1
  30. package/coverage/lcov-report/models/halo-infinite/match-info.ts.html +1 -1
  31. package/coverage/lcov-report/models/halo-infinite/match-outcome.ts.html +1 -1
  32. package/coverage/lcov-report/models/halo-infinite/match-skill.ts.html +1 -1
  33. package/coverage/lcov-report/models/halo-infinite/match-stats.ts.html +1 -1
  34. package/coverage/lcov-report/models/halo-infinite/match-type.ts.html +1 -1
  35. package/coverage/lcov-report/models/halo-infinite/matches-privacy.ts.html +1 -1
  36. package/coverage/lcov-report/models/halo-infinite/medals-metadata-file.ts.html +1 -1
  37. package/coverage/lcov-report/models/halo-infinite/player-match-history.ts.html +1 -1
  38. package/coverage/lcov-report/models/halo-infinite/playlist-csr-container.ts.html +1 -1
  39. package/coverage/lcov-report/models/halo-infinite/playlist-csr.ts.html +1 -1
  40. package/coverage/lcov-report/models/halo-infinite/playlist-experience.ts.html +1 -1
  41. package/coverage/lcov-report/models/halo-infinite/playlist.ts.html +1 -1
  42. package/coverage/lcov-report/models/halo-infinite/progression-file.ts.html +1 -1
  43. package/coverage/lcov-report/models/halo-infinite/season.ts.html +1 -1
  44. package/coverage/lcov-report/models/halo-infinite/service-record.ts.html +1 -1
  45. package/coverage/lcov-report/models/halo-infinite/settings.ts.html +1 -1
  46. package/coverage/lcov-report/models/halo-infinite/skill-result.ts.html +1 -1
  47. package/coverage/lcov-report/models/halo-infinite/stats.ts.html +1 -1
  48. package/coverage/lcov-report/models/halo-infinite/user-info.ts.html +1 -1
  49. package/coverage/lcov-report/models/index.html +1 -1
  50. package/coverage/lcov-report/models/spartan-token-proof.ts.html +1 -1
  51. package/coverage/lcov-report/models/spartan-token-request.ts.html +1 -1
  52. package/coverage/lcov-report/models/spartan-token.ts.html +1 -1
  53. package/coverage/lcov-report/models/xbox-ticket.ts.html +1 -1
  54. package/coverage/lcov-report/types/import-meta.d.ts.html +100 -0
  55. package/coverage/lcov-report/types/index.html +116 -0
  56. package/coverage/lcov-report/util/date-time.ts.html +21 -21
  57. package/coverage/lcov-report/util/expiry-token-cache.ts.html +2 -2
  58. package/coverage/lcov-report/util/fetch-function.ts.html +1 -1
  59. package/coverage/lcov-report/util/global-contants.ts.html +1 -1
  60. package/coverage/lcov-report/util/index.html +20 -20
  61. package/coverage/lcov-report/util/keyed-expiry-token-cache.ts.html +27 -27
  62. package/coverage/lcov-report/util/request-error.ts.html +2 -2
  63. package/coverage/lcov-report/util/resolvable-promise.ts.html +32 -32
  64. package/coverage/lcov-report/util/xuid.ts.html +3 -3
  65. package/coverage/lcov.info +337 -272
  66. package/dist/core/token-persisters/index.cjs +12 -6
  67. package/dist/core/token-persisters/index.cjs.map +1 -1
  68. package/dist/core/token-persisters/index.js +12 -6
  69. package/dist/core/token-persisters/index.js.map +1 -1
  70. package/dist/index.cjs +22 -1
  71. package/dist/index.cjs.map +1 -1
  72. package/dist/index.d.cts +13 -1
  73. package/dist/index.d.ts +13 -1
  74. package/dist/index.js +21 -2
  75. package/dist/index.js.map +1 -1
  76. package/jest.config.ts +1 -0
  77. package/jest.setup.ts +5 -0
  78. package/package.json +2 -2
  79. package/scripts/jest-runner.mjs +31 -0
  80. package/src/core/halo-infinite-client.ts +17 -1
  81. package/src/core/token-persisters/node-fs-token-persister.ts +15 -6
  82. package/src/endpoints/halo-core-endpoints.ts +1 -1
  83. package/src/index.ts +7 -2
  84. package/src/models/halo-infinite/ban-message.ts +4 -0
  85. package/src/models/halo-infinite/ban-summary.ts +8 -0
  86. package/src/types/import-meta.d.ts +5 -0
  87. package/tests/types/import-meta.d.ts +5 -0
  88. package/tsconfig.app.json +1 -6
  89. package/tsconfig.json +9 -10
@@ -32,6 +32,7 @@ import { wrapPlayerId, unwrapPlayerId } from "../util/xuid";
32
32
  import { SeasonCalendarContainer } from "../models/halo-infinite/season";
33
33
  import { Settings } from "../models/halo-infinite/settings";
34
34
  import { MatchCount } from "src/models/halo-infinite/match-count";
35
+ import { BanMessage } from "../models/halo-infinite/ban-message";
35
36
 
36
37
  export interface ResultContainer<TValue> {
37
38
  Id: string;
@@ -337,7 +338,9 @@ export class HaloInfiniteClient {
337
338
  init?: Omit<RequestInit, "body" | "method">
338
339
  ) =>
339
340
  this.executeJsonRequest<MatchCount>(
340
- `https://${HaloCoreEndpoints.StatsOrigin}.${HaloCoreEndpoints.ServiceDomain}/hi/players/${wrapPlayerId(playerXuid)}/matches/count`,
341
+ `https://${HaloCoreEndpoints.StatsOrigin}.${
342
+ HaloCoreEndpoints.ServiceDomain
343
+ }/hi/players/${wrapPlayerId(playerXuid)}/matches/count`,
341
344
  {
342
345
  ...init,
343
346
  method: "get",
@@ -488,6 +491,19 @@ export class HaloInfiniteClient {
488
491
  }
489
492
  );
490
493
 
494
+ public getBanMessage(
495
+ banPath: string,
496
+ init?: Omit<RequestInit, "body" | "method">
497
+ ): Promise<BanMessage> {
498
+ return this.executeJsonRequest(
499
+ `https://${HaloCoreEndpoints.GameCmsOrigin}.${HaloCoreEndpoints.ServiceDomain}/hi/banning/file/${banPath}`,
500
+ {
501
+ ...init,
502
+ method: "get",
503
+ }
504
+ );
505
+ }
506
+
491
507
  public getSeasonCalendar = (
492
508
  init?: Omit<RequestInit, "body" | "method">
493
509
  ): Promise<SeasonCalendarContainer> =>
@@ -1,14 +1,18 @@
1
1
  import type { TokenPersister } from ".";
2
2
 
3
+ function escapeTokenNameForFilesystem(tokenName: string): string {
4
+ return tokenName.replace(/[^a-zA-Z0-9-_]/g, "_");
5
+ }
6
+
3
7
  export const nodeFsTokenPersister: TokenPersister = {
4
8
  load: async (tokenName) => {
5
9
  const tokenDir =
6
10
  process.env.TOKEN_ROOT ||
7
- (await import("path")).join(__dirname, "./tokens");
11
+ (await import("path")).join(import.meta.dirname, "./tokens");
8
12
  try {
9
13
  const json = await (
10
14
  await import("fs/promises")
11
- ).readFile(`${tokenDir}/${tokenName}`, {
15
+ ).readFile(`${tokenDir}/${escapeTokenNameForFilesystem(tokenName)}`, {
12
16
  encoding: "utf-8",
13
17
  });
14
18
  return JSON.parse(json);
@@ -23,16 +27,21 @@ export const nodeFsTokenPersister: TokenPersister = {
23
27
  save: async (tokenName, token) => {
24
28
  const tokenDir =
25
29
  process.env.TOKEN_ROOT ||
26
- (await import("path")).join(__dirname, "./tokens");
30
+ (await import("path")).join(import.meta.dirname, "./tokens");
27
31
  await (await import("fs/promises")).mkdir(tokenDir, { recursive: true });
28
32
  await (
29
33
  await import("fs/promises")
30
- ).writeFile(`${tokenDir}/${tokenName}`, JSON.stringify(token));
34
+ ).writeFile(
35
+ `${tokenDir}/${escapeTokenNameForFilesystem(tokenName)}`,
36
+ JSON.stringify(token)
37
+ );
31
38
  },
32
39
  clear: async (tokenName) => {
33
40
  const tokenDir =
34
41
  process.env.TOKEN_ROOT ||
35
- (await import("path")).join(__dirname, "./tokens");
36
- await (await import("fs/promises")).unlink(`${tokenDir}/${tokenName}`);
42
+ (await import("path")).join(import.meta.dirname, "./tokens");
43
+ await (
44
+ await import("fs/promises")
45
+ ).unlink(`${tokenDir}/${escapeTokenNameForFilesystem(tokenName)}`);
37
46
  },
38
47
  };
@@ -10,7 +10,7 @@ export const HaloCoreEndpoints = {
10
10
  /** Discovery origin */
11
11
  DiscoveryOrigin: "discovery-infiniteugc",
12
12
 
13
- CommsOrigin: "wpcomms",
13
+ CommsOrigin: "comms",
14
14
  BanProcessorOrigin: "banprocessor",
15
15
  SettingsOrigin: "settings",
16
16
 
package/src/index.ts CHANGED
@@ -26,9 +26,14 @@ export {
26
26
  } from "./models/halo-infinite/asset";
27
27
  export { AssetKind } from "./models/halo-infinite/asset-kind";
28
28
  export { AssetVersionLink } from "./models/halo-infinite/asset-version-link";
29
- export { BanSummary } from "./models/halo-infinite/ban-summary";
29
+ export {
30
+ BanSummary,
31
+ BanScope,
32
+ BanType,
33
+ } from "./models/halo-infinite/ban-summary";
34
+ export { BanMessage } from "./models/halo-infinite/ban-message";
30
35
  export { GameVariantCategory } from "./models/halo-infinite/game-variant-category";
31
- export { MatchCount } from './models/halo-infinite/match-count';
36
+ export { MatchCount } from "./models/halo-infinite/match-count";
32
37
  export { MatchInfo } from "./models/halo-infinite/match-info";
33
38
  export { MatchOutcome } from "./models/halo-infinite/match-outcome";
34
39
  export { MatchSkill } from "./models/halo-infinite/match-skill";
@@ -0,0 +1,4 @@
1
+ export interface BanMessage {
2
+ Title: string;
3
+ Body: string;
4
+ }
@@ -1,6 +1,14 @@
1
1
  import { ResultContainer } from "src";
2
2
  import { ApiFormattedDate } from "./api-formatted-date";
3
3
 
4
+ export enum BanType {
5
+ Matchmaking = 1,
6
+ }
7
+
8
+ export enum BanScope {
9
+ Global = 1,
10
+ }
11
+
4
12
  export interface BanSummary {
5
13
  Results: ResultContainer<{
6
14
  BansInEffect: {
@@ -0,0 +1,5 @@
1
+ // Build-time ambient type for non-standard import.meta.dirname used by our Node ESM runtime
2
+ // This file is only for typing; it does not change runtime behavior.
3
+ interface ImportMeta {
4
+ dirname: string;
5
+ }
@@ -0,0 +1,5 @@
1
+ // Test-only augmentation to match Node ESM runtime conveniences
2
+ // Do not ship with production typings
3
+ interface ImportMeta {
4
+ dirname: string;
5
+ }
package/tsconfig.app.json CHANGED
@@ -17,10 +17,5 @@
17
17
  "src/**/*.spec.jsx",
18
18
  "src/**/*.test.jsx"
19
19
  ],
20
- "include": [
21
- "src/**/*.js",
22
- "src/**/*.jsx",
23
- "src/**/*.ts",
24
- "src/**/*.tsx"
25
- ]
20
+ "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
26
21
  }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "files": [],
2
+ "files": ["src/types/import-meta.d.ts"],
3
3
  "include": [],
4
4
  "compilerOptions": {
5
5
  "forceConsistentCasingInFileNames": true,
@@ -19,14 +19,13 @@
19
19
  "esModuleInterop": false,
20
20
  "allowSyntheticDefaultImports": true,
21
21
  "strict": true,
22
- "resolveJsonModule": true
22
+ "resolveJsonModule": true,
23
+ "typeRoots": [
24
+ "./src/types",
25
+ "./node_modules/@types",
26
+ "../../node_modules/@types"
27
+ ],
28
+ "types": ["node"]
23
29
  },
24
- "references": [
25
- {
26
- "path": "./tsconfig.app.json"
27
- },
28
- {
29
- "path": "./tsconfig.spec.json"
30
- }
31
- ]
30
+ "references": []
32
31
  }