Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor cache handling and code callbacks #129

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

extremeheat
Copy link
Member

@extremeheat extremeheat commented Feb 27, 2025

  • Breaking : Replace cache factory function with factory object
  • Breaking : Code callback function outputs are now standardized on all flows (previously, different on MSAL vs Live auth)
  • Better accounting for cache when using default file system caching (fix List cached accounts #74)
  • Support AbortController signal for request cancellation (fix Support aborting requests #128)
  • Support passing custom scopes when getting token

Migration

Cache

function cache ({ cacheName,  username }) {
  return new Cache()
}
const authflow = new Authflow(userIdentifier = 'test', cache)

to

class CacheImpl implements Cache {
  // see index.d.ts
}
const cacheFactory = {
  createCache ({ cacheName,  username }) {
    return new Cache()
  }
}
const authflow = new Authflow(userIdentifier = 'test', cacheFactory)

codeCallback

See index.d.ts for new object returned on

const codeCallback = (data) => console.log(data)
const authflow = new Authflow(userIdentifier = 'test', cacheFactory, null, codeCallback)

@extremeheat
Copy link
Member Author

Cc @LucienHH

@extremeheat extremeheat changed the title Refactor cache handling Refactor cache handling and code callbacks Feb 27, 2025
@extremeheat extremeheat marked this pull request as ready for review February 27, 2025 19:40
@extremeheat
Copy link
Member Author

extremeheat commented Feb 27, 2025

For consideration, I think it could be a good idea to rename authTitle to client ID (in another PR). The name authTitle is confusing as the tokens are oauth client IDs and not necessarily Xbox title IDs.

@extremeheat extremeheat requested a review from rom1504 March 5, 2025 05:14
@LucienHH
Copy link
Contributor

Seems to be an issue with the caching of xbl tokens, each token is getting nested when being added to the cache so when the XSTS token expires all tokens stored to the xbl cache are then refreshed which isn't always needed.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support aborting requests List cached accounts
2 participants