Skip to content

Commit

Permalink
Bun compatibility layer for XboxTokenManager
Browse files Browse the repository at this point in the history
  • Loading branch information
GustavoWidman committed Apr 8, 2024
1 parent fcc959b commit 2858b54
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/TokenManagers/XboxTokenManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const crypto = require('crypto')
const XboxLiveAuth = require('@xboxreplay/xboxlive-auth')
const debug = require('debug')('prismarine-auth')
const { SmartBuffer } = require('smart-buffer')
const { exportJWK } = require('jose')
const { exportJWK, importSPKI } = require('jose')
const fetch = require('node-fetch')

const { Endpoints, xboxLiveErrors } = require('../common/Constants')
Expand All @@ -22,9 +22,13 @@ const checkIfValid = (expires) => {
class XboxTokenManager {
constructor (ecKey, cache) {
this.key = ecKey
exportJWK(ecKey.publicKey).then(jwk => {
this.jwk = { ...jwk, alg: 'ES256', use: 'sig' }

importSPKI(ecKey.publicKey.export({ type: 'spki', format: 'pem' }), 'ES256', { extractable: true }).then(pubKey => {
exportJWK(pubKey).then(jwk => {
this.jwk = { ...jwk, alg: 'ES256', use: 'sig' }
})
})

this.cache = cache

this.headers = { 'Cache-Control': 'no-store, must-revalidate, no-cache', 'x-xbl-contract-version': 1 }
Expand Down

0 comments on commit 2858b54

Please sign in to comment.