This commit is contained in:
2026-06-23 05:02:15 +08:00
commit e6f1776d4f
264 changed files with 54215 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
/**
* Helpers around VS Code's SecretStorage for storing per-host Gitea personal
* access tokens.
*
* Tokens are keyed by host so the user can connect to multiple Gitea instances
* without the extension confusing their credentials.
*/
import type { ExtensionContext } from 'vscode'
export function tokenKey(host: string): string {
return `gitea-token:${host}`
}
export async function getToken(ctx: ExtensionContext, host: string): Promise<string | undefined> {
return ctx.secrets.get(tokenKey(host))
}
export async function setToken(ctx: ExtensionContext, host: string, token: string): Promise<void> {
await ctx.secrets.store(tokenKey(host), token)
}
export async function deleteToken(ctx: ExtensionContext, host: string): Promise<void> {
await ctx.secrets.delete(tokenKey(host))
}
/** YouTrack permanent tokens, keyed by host so they never collide with the
* gitea token of the same host. */
export function youtrackTokenKey(host: string): string {
return `youtrack-token:${host}`
}
export async function getYouTrackToken(ctx: ExtensionContext, host: string): Promise<string | undefined> {
return ctx.secrets.get(youtrackTokenKey(host))
}
export async function setYouTrackToken(ctx: ExtensionContext, host: string, token: string): Promise<void> {
await ctx.secrets.store(youtrackTokenKey(host), token)
}
export async function deleteYouTrackToken(ctx: ExtensionContext, host: string): Promise<void> {
await ctx.secrets.delete(youtrackTokenKey(host))
}