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

feat(Authorization): AuthorizationManager enhancements. #310

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

jbottigliero
Copy link
Collaborator

feat: Adds prompt method to AuthorizationManager - allows prompting for consent without reseting configured authorization context.
feat: Tokens managed by an AuthorizationManager will now be stored as a StoredToken type, which will include a __metadata property in addition to the raw Token. The __metadata will contain information about the creation and expiration time of the token allowing for improved refresh functionality.
feat: Adds isTokenExpired method for determining whether or not a stored token is expired.

@jbottigliero jbottigliero force-pushed the feat-AuthorizationManager-prompt branch 3 times, most recently from 9a7e437 to de296a9 Compare September 23, 2024 15:13
Copy link

codecov bot commented Sep 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.06%. Comparing base (7fcebbe) to head (f69bad3).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #310      +/-   ##
==========================================
+ Coverage   99.05%   99.06%   +0.01%     
==========================================
  Files          70       70              
  Lines        1168     1182      +14     
  Branches      179      181       +2     
==========================================
+ Hits         1157     1171      +14     
  Misses         11       11              
Flag Coverage Δ
99.06% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jbottigliero jbottigliero force-pushed the feat-AuthorizationManager-prompt branch 2 times, most recently from 3605d65 to bd0ce30 Compare September 23, 2024 16:16
@jbottigliero jbottigliero changed the title wip:feat(Authorization): AuthorizationManager enhancements. feat(Authorization): AuthorizationManager enhancements. Sep 23, 2024
feat: Adds `prompt` method to `AuthorizationManager` - allows prompting for consent **without** reseting configured authorization context.
feat: Tokens managed by an `AuthorizationManager` will now be stored as a `StoredToken` type, which will include a `__metadata` property in addition to the raw `Token`. The `__metadata` will contain information about the creation and expiration time of the token allowing for improved refresh functionality.
feat: Adds `isTokenExpired` method for determining whether or not a stored token is expired.
/* eslint-disable no-underscore-dangle */
return token && token.__metadata?.expires
? Date.now() + augment >= token.__metadata.expires
: true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the idea of having a fallback to true here to replace any old tokens that didn't get set with an expires value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, although thinking about it a bit more, I think I'm going to change the signature to true | false | undefined and just let the caller decide what to do; In our applications, we'll likely do a refresh in that case.

@jbottigliero jbottigliero merged commit 644c263 into main Sep 24, 2024
9 checks passed
@jbottigliero jbottigliero deleted the feat-AuthorizationManager-prompt branch September 24, 2024 13:45
jbottigliero pushed a commit that referenced this pull request Sep 24, 2024
🤖 I have created a release *beep* *boop*
---


##
[4.3.0](v4.2.0...v4.3.0)
(2024-09-24)


### Features

* **Authorization:** `AuthorizationManager` enhancements.
([#310](#310))
([644c263](644c263))


### Bug Fixes

* **Search, Typescript:** updates return type for `search.index.getAll`
and exports service types.
([#306](#306))
([7fcebbe](7fcebbe))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants