Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0cfb3e4

Browse files
committed
Add token refresh and revocation
1 parentd8779cd commit0cfb3e4

File tree

3 files changed

+331
-24
lines changed

3 files changed

+331
-24
lines changed

‎package.json‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,13 @@
257257
"icon":"$(search)"
258258
},
259259
{
260-
"command":"coder.oauth.testAuth",
261-
"title":"Test OAuth Auth",
260+
"command":"coder.oauth.login",
261+
"title":"OAuth Login",
262+
"category":"Coder"
263+
},
264+
{
265+
"command":"coder.oauth.logout",
266+
"title":"OAuth Logout",
262267
"category":"Coder"
263268
}
264269
],

‎src/core/secretsManager.ts‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import{typeClientRegistrationResponse}from"../oauth/types";
1+
import{
2+
typeTokenResponse,
3+
typeClientRegistrationResponse,
4+
}from"../oauth/types";
25

36
importtype{SecretStorage,Disposable}from"vscode";
47

@@ -8,6 +11,12 @@ const LOGIN_STATE_KEY = "loginState";
811

912
constOAUTH_CLIENT_REGISTRATION_KEY="oauthClientRegistration";
1013

14+
constOAUTH_TOKENS_KEY="oauthTokens";
15+
16+
exporttypeStoredOAuthTokens=Omit<TokenResponse,"expires_in">&{
17+
expiry_timestamp:number;
18+
};
19+
1120
exportenumAuthAction{
1221
LOGIN,
1322
LOGOUT,
@@ -109,4 +118,39 @@ export class SecretsManager {
109118
}
110119
returnundefined;
111120
}
121+
122+
/**
123+
* Store OAuth token data including expiry timestamp.
124+
*/
125+
publicasyncsetOAuthTokens(
126+
tokens:StoredOAuthTokens|undefined,
127+
):Promise<void>{
128+
if(tokens){
129+
awaitthis.secrets.store(OAUTH_TOKENS_KEY,JSON.stringify(tokens));
130+
}else{
131+
awaitthis.secrets.delete(OAUTH_TOKENS_KEY);
132+
}
133+
}
134+
135+
/**
136+
* Get stored OAuth token data.
137+
*/
138+
publicasyncgetOAuthTokens():Promise<StoredOAuthTokens|undefined>{
139+
try{
140+
conststringifiedTokens=awaitthis.secrets.get(OAUTH_TOKENS_KEY);
141+
if(stringifiedTokens){
142+
returnJSON.parse(stringifiedTokens)asStoredOAuthTokens;
143+
}
144+
}catch{
145+
// Do nothing
146+
}
147+
returnundefined;
148+
}
149+
150+
/**
151+
* Clear OAuth token data.
152+
*/
153+
publicasyncclearOAuthTokens():Promise<void>{
154+
awaitthis.secrets.delete(OAUTH_TOKENS_KEY);
155+
}
112156
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp