Path: blob/main/src/vs/workbench/services/authentication/common/dynamicAuthenticationProviderStorage.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';6import { IAuthorizationTokenResponse } from '../../../../base/common/oauth.js';7import { Event } from '../../../../base/common/event.js';89export const IDynamicAuthenticationProviderStorageService = createDecorator<IDynamicAuthenticationProviderStorageService>('dynamicAuthenticationProviderStorageService');1011export interface DynamicAuthenticationProviderInfo {12readonly providerId: string;13readonly label: string;14/**15* @deprecated in favor of authorizationServer16*/17readonly issuer?: string;18readonly authorizationServer: string;19readonly clientId: string;20}2122export interface DynamicAuthenticationProviderTokensChangeEvent {23readonly authProviderId: string;24readonly clientId: string;25readonly tokens: (IAuthorizationTokenResponse & { created_at: number })[] | undefined;26}2728/**29* Service for managing storage of dynamic authentication provider data.30*/31export interface IDynamicAuthenticationProviderStorageService {32readonly _serviceBrand: undefined;3334/**35* Event fired when tokens for a dynamic authentication provider change.36*/37readonly onDidChangeTokens: Event<DynamicAuthenticationProviderTokensChangeEvent>;3839/**40* Get the client details (ID and secret) for a dynamic authentication provider.41* @param providerId The provider ID or authorization server URL.42* @returns The client details if they exist, undefined otherwise.43*/44getClientRegistration(providerId: string): Promise<{ clientId?: string; clientSecret?: string } | undefined>;4546/**47* Store both client ID and client secret for a dynamic authentication provider.48* @param providerId The provider ID or authorization server URL.49* @param authorizationServer The authorization server URL for the provider.50* @param clientId The client ID to store.51* @param clientSecret Optional client secret to store.52* @param label Optional label for the provider.53*/54storeClientRegistration(providerId: string, authorizationServer: string, clientId: string, clientSecret?: string, label?: string): Promise<void>;5556/**57* Get all dynamic authentication providers that have been interacted with.58* @returns Array of provider information.59*/60getInteractedProviders(): ReadonlyArray<DynamicAuthenticationProviderInfo>;6162/**63* Remove a dynamic authentication provider and its stored data.64* @param providerId The provider ID to remove.65*/66removeDynamicProvider(providerId: string): Promise<void>;6768/**69* Get sessions for a dynamic authentication provider from secret storage.70* @param authProviderId The authentication provider ID.71* @param clientId The client ID.72* @returns Array of authorization tokens with creation timestamps, or undefined if none exist.73*/74getSessionsForDynamicAuthProvider(authProviderId: string, clientId: string): Promise<(IAuthorizationTokenResponse & { created_at: number })[] | undefined>;7576/**77* Set sessions for a dynamic authentication provider in secret storage.78* @param authProviderId The authentication provider ID.79* @param clientId The client ID.80* @param sessions Array of authorization tokens with creation timestamps.81*/82setSessionsForDynamicAuthProvider(authProviderId: string, clientId: string, sessions: (IAuthorizationTokenResponse & { created_at: number })[]): Promise<void>;83}848586