Skip to content

Commit

Permalink
feat: expries_in is not required in OAuth2Response (AnWeber/vscode-ht…
Browse files Browse the repository at this point in the history
  • Loading branch information
AnWeber committed Nov 13, 2023
1 parent d4ff585 commit 9907dd6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 7 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [6.10.0] (2023-11-13)

### Feature

- add support for dynamic `# @ref` (#585)

### Fix

- device code flow uses correct interval
- `expires_in` is not required in OAuth2Response (AnWeber/vscode-httpyac#240



## [6.9.3] (2023-11-05)

### Fix
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"publisher": "AnWeber",
"description": "HTTP/REST CLI Client for *.http files",
"version": "6.9.3",
"version": "6.10.0",
"homepage": "https://github.com/AnWeber/httpyac",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/models/openIdInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export interface OpenIdInformation extends UserSession {
time: number;
config: OpenIdConfiguration;
accessToken: string;
expiresIn: number;
expiresIn?: number;
timeSkew: number;
refreshToken?: string;
refreshExpiresIn?: number;
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/oauth2/flow/requestOpenIdInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function toOpenIdInformation(
type: 'OAuth2',
time,
accessToken: jwtToken.access_token,
expiresIn: jwtToken.expires_in,
expiresIn: jwtToken.expires_in ?? parsedToken?.exp,
refreshToken: jwtToken.refresh_token,
refreshExpiresIn: jwtToken.refresh_expires_in,
timeSkew: parsedToken?.iat ? Math.floor(time / 1000) - parsedToken.iat : 0,
Expand All @@ -81,12 +81,12 @@ export function toOpenIdInformation(

export function isAuthToken(obj: unknown): obj is AuthToken {
const guard = obj as AuthToken;
return guard && !!guard.access_token && !!guard.expires_in;
return guard && !!guard.access_token;
}

interface AuthToken {
access_token: string;
expires_in: number;
expires_in?: number;
refresh_token?: string;
refresh_expires_in?: number;
}
1 change: 1 addition & 0 deletions src/plugins/oauth2/oauth2VariableReplacer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function keepAlive(cacheKey: string, variables: models.Variables) {
const openIdInformation = userSessionStore.userSessions.find(obj => obj.id === cacheKey);
if (
utils.isOpenIdInformation(openIdInformation) &&
openIdInformation.expiresIn &&
openIdInformation.refreshToken &&
openIdInformation.config.keepAlive
) {
Expand Down

0 comments on commit 9907dd6

Please sign in to comment.