halo-infinite-api 12.0.1 → 12.0.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 (146) hide show
  1. package/.editorconfig +13 -13
  2. package/.github/workflows/ci.yml +45 -0
  3. package/.github/workflows/npm-publish.yml +22 -22
  4. package/.github/workflows/publish.yml +77 -0
  5. package/.vscode/settings.json +6 -3
  6. package/README.md +93 -67
  7. package/coverage/lcov-report/authentication/halo-authentication-client.ts.html +364 -0
  8. package/coverage/lcov-report/authentication/index.html +131 -0
  9. package/coverage/lcov-report/authentication/xbox-authentication-client.ts.html +568 -0
  10. package/coverage/lcov-report/base.css +224 -0
  11. package/coverage/lcov-report/block-navigation.js +87 -0
  12. package/coverage/lcov-report/core/halo-infinite-client.ts.html +1513 -0
  13. package/coverage/lcov-report/core/index.html +146 -0
  14. package/coverage/lcov-report/core/request-policy.ts.html +106 -0
  15. package/coverage/lcov-report/core/token-persisters/in-memory-token-persister.ts.html +130 -0
  16. package/coverage/lcov-report/core/token-persisters/index.html +161 -0
  17. package/coverage/lcov-report/core/token-persisters/local-storage-token-persister.ts.html +139 -0
  18. package/coverage/lcov-report/core/token-persisters/node-fs-token-persister.ts.html +199 -0
  19. package/coverage/lcov-report/core/token-persisters/token-persister.ts.html +100 -0
  20. package/coverage/lcov-report/core/token-providers/auto-token-provider.ts.html +319 -0
  21. package/coverage/lcov-report/core/token-providers/index.html +131 -0
  22. package/coverage/lcov-report/core/token-providers/spartan-token-providers/index.html +116 -0
  23. package/coverage/lcov-report/core/token-providers/spartan-token-providers/static-xsts-ticket-token-spartan-token-provider.ts.html +232 -0
  24. package/coverage/lcov-report/core/token-providers/xbox-token-provider.ts.html +97 -0
  25. package/coverage/lcov-report/core/xbox-client.ts.html +400 -0
  26. package/coverage/lcov-report/endpoints/halo-core-endpoints.ts.html +142 -0
  27. package/coverage/lcov-report/endpoints/index.html +116 -0
  28. package/coverage/lcov-report/favicon.png +0 -0
  29. package/coverage/lcov-report/index.html +236 -0
  30. package/coverage/lcov-report/models/halo-infinite/api-formatted-date.ts.html +94 -0
  31. package/coverage/lcov-report/models/halo-infinite/asset-kind.ts.html +121 -0
  32. package/coverage/lcov-report/models/halo-infinite/asset-version-link.ts.html +106 -0
  33. package/coverage/lcov-report/models/halo-infinite/asset.ts.html +367 -0
  34. package/coverage/lcov-report/models/halo-infinite/ban-summary.ts.html +166 -0
  35. package/coverage/lcov-report/models/halo-infinite/game-variant-category.ts.html +145 -0
  36. package/coverage/lcov-report/models/halo-infinite/index.html +461 -0
  37. package/coverage/lcov-report/models/halo-infinite/match-info.ts.html +157 -0
  38. package/coverage/lcov-report/models/halo-infinite/match-outcome.ts.html +103 -0
  39. package/coverage/lcov-report/models/halo-infinite/match-skill.ts.html +214 -0
  40. package/coverage/lcov-report/models/halo-infinite/match-stats.ts.html +202 -0
  41. package/coverage/lcov-report/models/halo-infinite/match-type.ts.html +103 -0
  42. package/coverage/lcov-report/models/halo-infinite/matches-privacy.ts.html +112 -0
  43. package/coverage/lcov-report/models/halo-infinite/medals-metadata-file.ts.html +172 -0
  44. package/coverage/lcov-report/models/halo-infinite/player-match-history.ts.html +118 -0
  45. package/coverage/lcov-report/models/halo-infinite/playlist-csr-container.ts.html +106 -0
  46. package/coverage/lcov-report/models/halo-infinite/playlist-csr.ts.html +124 -0
  47. package/coverage/lcov-report/models/halo-infinite/playlist-experience.ts.html +100 -0
  48. package/coverage/lcov-report/models/halo-infinite/playlist.ts.html +121 -0
  49. package/coverage/lcov-report/models/halo-infinite/progression-file.ts.html +247 -0
  50. package/coverage/lcov-report/models/halo-infinite/season.ts.html +142 -0
  51. package/coverage/lcov-report/models/halo-infinite/service-record.ts.html +448 -0
  52. package/coverage/lcov-report/models/halo-infinite/skill-result.ts.html +94 -0
  53. package/coverage/lcov-report/models/halo-infinite/stats.ts.html +694 -0
  54. package/coverage/lcov-report/models/halo-infinite/user-info.ts.html +115 -0
  55. package/coverage/lcov-report/models/index.html +161 -0
  56. package/coverage/lcov-report/models/spartan-token-proof.ts.html +97 -0
  57. package/coverage/lcov-report/models/spartan-token-request.ts.html +106 -0
  58. package/coverage/lcov-report/models/spartan-token.ts.html +106 -0
  59. package/coverage/lcov-report/models/xbox-ticket.ts.html +139 -0
  60. package/coverage/lcov-report/prettify.css +1 -0
  61. package/coverage/lcov-report/prettify.js +2 -0
  62. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  63. package/coverage/lcov-report/sorter.js +196 -0
  64. package/coverage/lcov-report/util/date-time.ts.html +121 -0
  65. package/coverage/lcov-report/util/expiry-token-cache.ts.html +358 -0
  66. package/coverage/lcov-report/util/fetch-function.ts.html +112 -0
  67. package/coverage/lcov-report/util/global-contants.ts.html +103 -0
  68. package/coverage/lcov-report/util/index.html +221 -0
  69. package/coverage/lcov-report/util/keyed-expiry-token-cache.ts.html +367 -0
  70. package/coverage/lcov-report/util/request-error.ts.html +157 -0
  71. package/coverage/lcov-report/util/resolvable-promise.ts.html +181 -0
  72. package/coverage/lcov-report/util/xuid.ts.html +136 -0
  73. package/coverage/lcov.info +2901 -0
  74. package/dist/core/token-persisters/index.cjs.map +1 -1
  75. package/dist/core/token-persisters/index.js.map +1 -1
  76. package/dist/index.cjs +1 -1
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.cts +9 -11
  79. package/dist/index.d.ts +9 -11
  80. package/dist/index.js +1 -1
  81. package/dist/index.js.map +1 -1
  82. package/jest.config.ts +29 -19
  83. package/package.json +68 -68
  84. package/src/authentication/halo-authentication-client.ts +93 -93
  85. package/src/authentication/xbox-authentication-client.ts +161 -161
  86. package/src/core/halo-infinite-client.test.ts +33 -32
  87. package/src/core/halo-infinite-client.ts +476 -476
  88. package/src/core/request-policy.ts +7 -7
  89. package/src/core/token-persisters/in-memory-token-persister.ts +15 -15
  90. package/src/core/token-persisters/index.ts +4 -4
  91. package/src/core/token-persisters/local-storage-token-persister.ts +18 -18
  92. package/src/core/token-persisters/node-fs-token-persister.ts +38 -38
  93. package/src/core/token-persisters/token-persister.ts +5 -5
  94. package/src/core/token-persisters/token-persisters.test.ts +49 -0
  95. package/src/core/token-providers/auto-token-provider.ts +78 -78
  96. package/src/core/token-providers/spartan-token-providers/index.ts +4 -4
  97. package/src/core/token-providers/spartan-token-providers/static-xsts-ticket-token-spartan-token-provider.ts +49 -49
  98. package/src/core/token-providers/xbox-token-provider.ts +4 -4
  99. package/src/core/xbox-client.ts +105 -105
  100. package/src/endpoints/halo-core-endpoints.ts +19 -19
  101. package/src/index.ts +57 -56
  102. package/src/models/halo-infinite/api-formatted-date.ts +3 -3
  103. package/src/models/halo-infinite/asset-kind.ts +12 -12
  104. package/src/models/halo-infinite/asset-version-link.ts +7 -7
  105. package/src/models/halo-infinite/asset.ts +94 -94
  106. package/src/models/halo-infinite/ban-summary.ts +27 -29
  107. package/src/models/halo-infinite/game-variant-category.ts +20 -20
  108. package/src/models/halo-infinite/match-info.ts +24 -24
  109. package/src/models/halo-infinite/match-outcome.ts +6 -6
  110. package/src/models/halo-infinite/match-skill.ts +43 -43
  111. package/src/models/halo-infinite/match-stats.ts +39 -39
  112. package/src/models/halo-infinite/match-type.ts +6 -6
  113. package/src/models/halo-infinite/matches-privacy.ts +9 -9
  114. package/src/models/halo-infinite/medals-metadata-file.ts +29 -29
  115. package/src/models/halo-infinite/player-match-history.ts +11 -11
  116. package/src/models/halo-infinite/playlist-csr-container.ts +7 -7
  117. package/src/models/halo-infinite/playlist-csr.ts +13 -13
  118. package/src/models/halo-infinite/playlist-experience.ts +5 -5
  119. package/src/models/halo-infinite/playlist.ts +12 -12
  120. package/src/models/halo-infinite/progression-file.ts +54 -54
  121. package/src/models/halo-infinite/season.ts +19 -19
  122. package/src/models/halo-infinite/service-record.ts +121 -121
  123. package/src/models/halo-infinite/skill-result.ts +3 -3
  124. package/src/models/halo-infinite/stats.ts +203 -203
  125. package/src/models/halo-infinite/user-info.ts +10 -10
  126. package/src/models/spartan-token-proof.ts +4 -4
  127. package/src/models/spartan-token-request.ts +7 -7
  128. package/src/models/spartan-token.ts +7 -7
  129. package/src/models/xbox-ticket.ts +18 -18
  130. package/src/util/date-time.test.ts +22 -0
  131. package/src/util/date-time.ts +12 -12
  132. package/src/util/expiry-token-cache.test.ts +111 -0
  133. package/src/util/expiry-token-cache.ts +91 -91
  134. package/src/util/fetch-function.ts +9 -9
  135. package/src/util/global-contants.ts +6 -6
  136. package/src/util/keyed-expiry-token-cache.test.ts +114 -0
  137. package/src/util/keyed-expiry-token-cache.ts +94 -94
  138. package/src/util/request-error.test.ts +18 -0
  139. package/src/util/request-error.ts +24 -24
  140. package/src/util/resolvable-promise.test.ts +26 -0
  141. package/src/util/resolvable-promise.ts +32 -32
  142. package/src/util/xuid.test.ts +16 -0
  143. package/src/util/xuid.ts +17 -17
  144. package/tsconfig.app.json +26 -26
  145. package/tsconfig.json +32 -32
  146. package/tsup.config.ts +21 -21
package/.editorconfig CHANGED
@@ -1,13 +1,13 @@
1
- # Editor configuration, see http://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- charset = utf-8
6
- indent_style = space
7
- indent_size = 2
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
10
-
11
- [*.md]
12
- max_line_length = off
13
- trim_trailing_whitespace = false
1
+ # Editor configuration, see http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ indent_size = 2
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
10
+
11
+ [*.md]
12
+ max_line_length = off
13
+ trim_trailing_whitespace = false
@@ -0,0 +1,45 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [master]
6
+ push:
7
+ branches: [master]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ build-test:
14
+ name: Build & Test
15
+ runs-on: ubuntu-latest
16
+ timeout-minutes: 15
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Use Node.js 20
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version: 20
25
+ cache: "npm"
26
+
27
+ - name: Install dependencies
28
+ run: npm ci
29
+
30
+ - name: Run tests
31
+ run: npm test --ignore-scripts --if-present -- --ci --reporters=default --errorOnDeprecated
32
+
33
+ - name: Build
34
+ run: npm run build
35
+
36
+ - name: Verify no uncommitted changes after build
37
+ run: |
38
+ if [ -n "$(git status --porcelain)" ]; then
39
+ echo '::error::Build generated uncommitted changes. Please commit build artifacts or adjust build.'
40
+ git diff --name-only
41
+ exit 1
42
+ fi
43
+
44
+ # Optionally only run build on PRs from forks if necessary secrets are not required
45
+ # strategy: {}
@@ -1,22 +1,22 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- release:
8
- types: [published]
9
-
10
- jobs:
11
- publish-npm:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
16
- with:
17
- node-version: 20
18
- registry-url: https://registry.npmjs.org/
19
- - run: npm ci
20
- - run: npm publish
21
- env:
22
- NODE_AUTH_TOKEN: ${{secrets.npm_token}}
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [published]
9
+
10
+ jobs:
11
+ publish-npm:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-node@v3
16
+ with:
17
+ node-version: 20
18
+ registry-url: https://registry.npmjs.org/
19
+ - run: npm ci
20
+ - run: npm publish
21
+ env:
22
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
@@ -0,0 +1,77 @@
1
+ name: Publish Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "[0-9]+.[0-9]+.[0-9]+"
7
+
8
+ permissions:
9
+ contents: write # for creating a release
10
+ packages: write
11
+
12
+ jobs:
13
+ publish:
14
+ name: Build, Test, Publish & Release
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v4
19
+ with:
20
+ fetch-depth: 0
21
+
22
+ - name: Use Node.js 20
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: 20
26
+ registry-url: https://registry.npmjs.org
27
+ cache: "npm"
28
+
29
+ - name: Install dependencies
30
+ run: npm ci
31
+
32
+ - name: Run tests
33
+ run: npm test --ignore-scripts --if-present
34
+
35
+ - name: Build
36
+ run: npm run build
37
+
38
+ - name: Derive version from tag
39
+ id: version
40
+ run: |
41
+ TAG_REF="${GITHUB_REF##*/}"
42
+ echo "tag=$TAG_REF" >> $GITHUB_OUTPUT
43
+ # Optional: verify package.json version matches tag
44
+ PKG_VERSION=$(node -p "require('./package.json').version")
45
+ if [ "$PKG_VERSION" != "$TAG_REF" ]; then
46
+ echo "::warning::Tag ($TAG_REF) does not match package.json version ($PKG_VERSION). Continuing, but consider publishing a matching version.";
47
+ fi
48
+
49
+ - name: Publish to npm
50
+ env:
51
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
52
+ run: |
53
+ npm publish --access public
54
+
55
+ - name: Generate release notes
56
+ id: notes
57
+ run: |
58
+ PREV_TAG=$(git describe --tags --abbrev=0 --match "[0-9]*.[0-9]*.[0-9]*" $(git rev-list --tags --max-count=2) | tail -n1 || echo "")
59
+ if [ -z "$PREV_TAG" ]; then
60
+ COMMITS=$(git log --pretty=format:'- %s')
61
+ else
62
+ COMMITS=$(git log "$PREV_TAG..HEAD" --pretty=format:'- %s')
63
+ fi
64
+ echo "commits<<'EOF'" >> $GITHUB_OUTPUT
65
+ echo "$COMMITS" >> $GITHUB_OUTPUT
66
+ echo 'EOF' >> $GITHUB_OUTPUT
67
+
68
+ - name: Create GitHub Release
69
+ uses: actions/create-release@v1
70
+ env:
71
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
72
+ with:
73
+ tag_name: ${{ steps.version.outputs.tag }}
74
+ release_name: v${{ steps.version.outputs.tag }}
75
+ body: ${{ steps.notes.outputs.commits }}
76
+ draft: false
77
+ prerelease: false
@@ -1,3 +1,6 @@
1
- {
2
- "javascript.preferences.importModuleSpecifier": "relative"
3
- }
1
+ {
2
+ "javascript.preferences.importModuleSpecifier": "relative",
3
+ "explorer.fileNesting.patterns": {
4
+ "*.ts": "${capture}.test.ts"
5
+ }
6
+ }
package/README.md CHANGED
@@ -1,67 +1,93 @@
1
- # Halo Infinite API
2
-
3
- This is a simple typescript wrapper around 343's official Halo Infinite API (the same API that powers both the game and [halowaypoint.com](https://www.halowaypoint.com/)). I based it off the work of the now mysteriously deleted C# Grunt API (a defunct fork of which remains [here](https://github.com/seth-skocelas/grunt/)).
4
-
5
- The package is currently limited to the endpoints I've needed to use in other projects, however I do take requests (create an [issue](/issues)) and I welcome [PRs to extend the functionality](/pulls).
6
-
7
- ### Currently Supported Endpoints
8
-
9
- - GET https://profile.svc.halowaypoint.com/users/{gamerTag}
10
- - GET https://profile.svc.halowaypoint.com/users?xuids={xuids}
11
- - GET https://skill.svc.halowaypoint.com/hi/playlist/{playlistId}/csrs?players={playerIds}
12
- - GET https://skill.svc.halowaypoint.com/hi/matches/{matchId}/skill
13
- - GET https://gamecms-hacs.svc.halowaypoint.com/hi/multiplayer/file/playlists/assets/{playlistId}.json
14
- - GET https://gamecms-hacs.svc.halowaypoint.com/hi/Progression/file/{filename}.json
15
- - GET https://halostats.svc.halowaypoint.com/hi/playlist/{playlistId}/csrs?players={playerIds}
16
- - GET https://halostats.svc.halowaypoint.com/hi/players/xuid({playerId})/matches
17
- - GET https://halostats.svc.halowaypoint.com/hi/players/{gamerTagOrWrappedXuid}/Matchmade/servicerecord
18
- - GET https://halostats.svc.halowaypoint.com/hi/matches/{matchId}/stats
19
- - GET https://discovery-infiniteugc.svc.halowaypoint.com/hi/{assetType}/{assetId}
20
- - GET https://discovery-infiniteugc.svc.halowaypoint.com/hi/{assetType}/{assetId}/versions/{versionId}
21
-
22
- ### Getting Started
23
-
24
- The core requirement to use the endpoints in the library is to have a Spartan token, that is provided by the Halo Infinite service.
25
-
26
- > **⚠️ WARNING**
27
- >
28
- > The Spartan token is associated with _your identity_ and _your account_. **Do not share it** with anyone, under any circumstances. The API wrapper does not explicitly store it anywhere (though you can configure it to store it somewhere of your choosing). It's your responsibility to make sure that it's secure and not available to anyone else.
29
-
30
- This library does not provide a way to perform the first step of generating a spartan token, which is to get an Oauth2 access token from Microsoft. Microsoft provides a great set of npm packages for this purpose, [@azure/msal-node](https://www.npmjs.com/package/@azure/msal-node), [@azure/msal-browser](https://www.npmjs.com/package/@azure/msal-browser), [@azure/msal-react](https://www.npmjs.com/package/@azure/msal-react), etc. depending on the flavor of your application.
31
-
32
- Make sure that you [register an Azure Active Directory application](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app), as that is how you will make use of the @azure/msal packages.
33
-
34
- Below is a simple example of how this library might be used in a console application to get a user's profile:
35
-
36
- ```typescript
37
- import open from "open"; // An npm package that opens a browser window
38
- import * as msal from "@azure/msal-node";
39
- import { HaloInfiniteClient, AutoXstsSpartanTokenProvider } from "halo-infinite-api";
40
-
41
- const oauthApplication = new msal.PublicClientApplication({
42
- auth: {
43
- clientId: "00000000-0000-0000-0000-000000000000",
44
- authority: "https://login.live.com", // Override the default authority with the xbox one
45
- knownAuthorities: ["login.live.com"],
46
- protocolMode: "OIDC", // Shit, I actually have no idea what this does, but Microsoft says I need it
47
- },
48
- });
49
-
50
- const client = new HaloInfiniteClient(
51
- // Another choice for token providers is the StaticXstsTicketTokenSpartanTokenProvider,
52
- // which uses a preset spartan token
53
- new AutoTokenProvider(async () => {
54
- const token = await oauthApplication.acquireTokenInteractive({
55
- // offline_access gives us a refresh token which we can use to continually
56
- // get new credentials from Microsoft as the old ones expire.
57
- scopes: ["Xboxlive.signin", "Xboxlive.offline_access"],
58
- openBrowser: async (url) => {
59
- await open(url);
60
- },
61
- });
62
- return token.accessToken;
63
- })
64
- );
65
-
66
- const user = await client.getUser("GravlLift");
67
- ```
1
+ # Halo Infinite API
2
+
3
+ This is a simple typescript wrapper around 343's official Halo Infinite API (the same API that powers both the game and [halowaypoint.com](https://www.halowaypoint.com/)). I based it off the work of the now mysteriously deleted C# Grunt API (a defunct fork of which remains [here](https://github.com/seth-skocelas/grunt/)).
4
+
5
+ The package is currently limited to the endpoints I've needed to use in other projects, however I do take requests (create an [issue](/issues)) and I welcome [PRs to extend the functionality](/pulls).
6
+
7
+ ### Currently Supported Endpoints
8
+
9
+ - GET https://profile.svc.halowaypoint.com/users/{gamerTag}
10
+ - GET https://profile.svc.halowaypoint.com/users?xuids={xuids}
11
+ - GET https://skill.svc.halowaypoint.com/hi/playlist/{playlistId}/csrs?players={playerIds}
12
+ - GET https://skill.svc.halowaypoint.com/hi/matches/{matchId}/skill
13
+ - GET https://gamecms-hacs.svc.halowaypoint.com/hi/multiplayer/file/playlists/assets/{playlistId}.json
14
+ - GET https://gamecms-hacs.svc.halowaypoint.com/hi/Progression/file/{filename}.json
15
+ - GET https://halostats.svc.halowaypoint.com/hi/playlist/{playlistId}/csrs?players={playerIds}
16
+ - GET https://halostats.svc.halowaypoint.com/hi/players/xuid({playerId})/matches
17
+ - GET https://halostats.svc.halowaypoint.com/hi/players/{gamerTagOrWrappedXuid}/Matchmade/servicerecord
18
+ - GET https://halostats.svc.halowaypoint.com/hi/matches/{matchId}/stats
19
+ - GET https://discovery-infiniteugc.svc.halowaypoint.com/hi/{assetType}/{assetId}
20
+ - GET https://discovery-infiniteugc.svc.halowaypoint.com/hi/{assetType}/{assetId}/versions/{versionId}
21
+
22
+ ### Getting Started
23
+
24
+ The core requirement to use the endpoints in the library is to have a Spartan token, that is provided by the Halo Infinite service.
25
+
26
+ > **⚠️ WARNING**
27
+ >
28
+ > The Spartan token is associated with _your identity_ and _your account_. **Do not share it** with anyone, under any circumstances. The API wrapper does not explicitly store it anywhere (though you can configure it to store it somewhere of your choosing). It's your responsibility to make sure that it's secure and not available to anyone else.
29
+
30
+ This library does not provide a way to perform the first step of generating a spartan token, which is to get an Oauth2 access token from Microsoft. Microsoft provides a great set of npm packages for this purpose, [@azure/msal-node](https://www.npmjs.com/package/@azure/msal-node), [@azure/msal-browser](https://www.npmjs.com/package/@azure/msal-browser), [@azure/msal-react](https://www.npmjs.com/package/@azure/msal-react), etc. depending on the flavor of your application.
31
+
32
+ Make sure that you [register an Azure Active Directory application](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app), as that is how you will make use of the @azure/msal packages.
33
+
34
+ Below is a simple example of how this library might be used in a console application to get a user's profile:
35
+
36
+ ```typescript
37
+ import open from "open"; // An npm package that opens a browser window
38
+ import * as msal from "@azure/msal-node";
39
+ import { HaloInfiniteClient, AutoXstsSpartanTokenProvider } from "halo-infinite-api";
40
+
41
+ const oauthApplication = new msal.PublicClientApplication({
42
+ auth: {
43
+ clientId: "00000000-0000-0000-0000-000000000000",
44
+ authority: "https://login.live.com", // Override the default authority with the xbox one
45
+ knownAuthorities: ["login.live.com"],
46
+ protocolMode: "OIDC", // Shit, I actually have no idea what this does, but Microsoft says I need it
47
+ },
48
+ });
49
+
50
+ const client = new HaloInfiniteClient(
51
+ // Another choice for token providers is the StaticXstsTicketTokenSpartanTokenProvider,
52
+ // which uses a preset spartan token
53
+ new AutoTokenProvider(async () => {
54
+ const token = await oauthApplication.acquireTokenInteractive({
55
+ // offline_access gives us a refresh token which we can use to continually
56
+ // get new credentials from Microsoft as the old ones expire.
57
+ scopes: ["Xboxlive.signin", "Xboxlive.offline_access"],
58
+ openBrowser: async (url) => {
59
+ await open(url);
60
+ },
61
+ });
62
+ return token.accessToken;
63
+ })
64
+ );
65
+
66
+ const user = await client.getUser("GravlLift");
67
+ ```
68
+
69
+ ### Releasing / Publishing
70
+
71
+ A GitHub Action automatically publishes the package to npm and creates a GitHub Release whenever you push a semantic version tag (format: `<major>.<minor>.<patch>`, e.g. `12.0.2`).
72
+
73
+ Steps to cut a release:
74
+
75
+ 1. Update the version in `package.json` according to semver rules.
76
+ 2. Commit the change (e.g. `git commit -am "chore: release 12.0.2"`).
77
+ 3. Create and push the tag:
78
+ ```bash
79
+ git tag 12.0.2
80
+ git push origin 12.0.2
81
+ ```
82
+ 4. The workflow will:
83
+ - Install dependencies, run tests, and build
84
+ - Publish to npm (using the `NPM_TOKEN` secret)
85
+ - Create a GitHub Release with commit messages since the previous tag
86
+
87
+ Required repository secrets:
88
+
89
+ - `NPM_TOKEN` – An npm access token with `publish` permission.
90
+
91
+ If the tag version doesn't match `package.json` the workflow will warn, but will still publish using the `package.json` version.
92
+
93
+ Ensure the package has the correct access level (public) on npm before the first automated publish.