expose in-memory copy of userManager
exposes a copy of userManager that can be used in static contexts - for example to get an access_token or to call logout directly outside of a React component/hook.
Closes/fixes https://github.com/authts/react-oidc-context/issues/313 https://github.com/authts/react-oidc-context/issues/331
Checklist
- [x] This PR makes changes to the public API
- [x] I have included links for closing relevant issue numbers
@pamapa / @kherock pls review when you get a chance
@pamapa / @kherock any update?
This implementation works against the existing design, see e.g. how events are exposed. I am not 100% sure if it makes sense to expose the userManager, maybe for unseen use cases like access the metadata (see #465)
@kherock Should we expose the userManager?
This implementation works against the existing design, see e.g. how events are exposed. I am not 100% sure if it makes sense to expose the userManager, maybe for unseen use cases like access the metadata (see #465)
@kherock Should we expose the userManager?
the reason it doesn't follow the existing design is that this is a unique case of getting a static handle on the userManager outside of the paradigm of React / React Context - ultimately its up to you if you think its an acceptable part of the design, but if not I'm curious how else it could be implemented.
An alternative idea is to simply add the functionality to pass in the userManager and expect adopters of the library to create and manage the lifetime of it
An alternative idea is to simply add the functionality to pass in the
userManagerand expect adopters of the library to create and manage the lifetime of it
optional passing an instance of the userManager would be acceptable.
@pamapa changes are ready for review
Codecov Report
Merging #466 (134c8a5) into main (8345d0c) will increase coverage by
0.09%. The diff coverage is100.00%.
@@ Coverage Diff @@
## main #466 +/- ##
==========================================
+ Coverage 88.52% 88.61% +0.09%
==========================================
Files 9 9
Lines 122 123 +1
Branches 18 19 +1
==========================================
+ Hits 108 109 +1
Misses 11 11
Partials 3 3
| Flag | Coverage Δ | |
|---|---|---|
| unittests | 88.61% <100.00%> (+0.09%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/AuthProvider.tsx | 89.06% <100.00%> (+0.17%) |
:arrow_up: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
pipeline fails with:
npm pack --dry-run
> [email protected] prepack
> npm run build
> [email protected] build
> node scripts/build.js && npm run build-types
> [email protected] build-types
> tsc --emitDeclarationOnly && api-extractor run
api-extractor 7.28.0 - https://api-extractor.com/
Using configuration from ./api-extractor.json
Analysis will use the bundled TypeScript version 4.6.4
Warning: src/AuthProvider.tsx:17:1 - (ae-missing-release-tag) "AuthProviderPropsBase" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
Warning: src/AuthProvider.tsx:86:1 - (ae-missing-release-tag) "AuthProviderUserManagerProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
Warning: src/AuthProvider.tsx:92:1 - (ae-missing-release-tag) "AuthProviderNoUserManagerProps" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
API Extractor completed with warnings
npm ERR! code 1
npm ERR! path /home/runner/work/react-oidc-context/react-oidc-context
npm ERR! command failed
npm ERR! command sh /tmp/prepack-4890cec5.sh
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2022-09-12T11_31_35_189Z-debug-0.log
Error: Process completed with exit code 1.
You will need to add @public to those too
Nice work, thanks for taking care and thanks for your contribution!
@pamapa can you pls publish a new version of the package with the changes?
will do so