|
1 | | -import type { Disposable, Event } from 'vscode'; |
2 | | -import type { Sources } from '../../../constants.telemetry'; |
3 | | -import { configuration } from '../../../system/-webview/configuration'; |
4 | | -import type { |
5 | | - IntegrationAuthenticationProvider, |
6 | | - IntegrationAuthenticationSessionDescriptor, |
7 | | -} from './integrationAuthenticationProvider'; |
8 | | -import type { ProviderAuthenticationSession } from './models'; |
| 1 | +import { IssuesCloudHostIntegrationId } from '../../../constants.integrations'; |
| 2 | +import { CloudIntegrationAuthenticationProvider } from './integrationAuthenticationProvider'; |
9 | 3 |
|
10 | | -export class LinearAuthenticationProvider implements IntegrationAuthenticationProvider { |
11 | | - // I want to read the token from the config "ololo-linear-config": |
12 | | - private currentToken: string | undefined = (configuration.get('ololo-linear-token') as string) ?? undefined; |
13 | | - |
14 | | - deleteSession(_descriptor: IntegrationAuthenticationSessionDescriptor): Promise<void> { |
15 | | - //throw new Error('Method not implemented.'); |
16 | | - this.currentToken = undefined; |
17 | | - return Promise.resolve(); |
18 | | - } |
19 | | - deleteAllSessions(): Promise<void> { |
20 | | - //throw new Error('Method not implemented.'); |
21 | | - this.currentToken = undefined; |
22 | | - return Promise.resolve(); |
23 | | - } |
24 | | - getSession( |
25 | | - _descriptor: IntegrationAuthenticationSessionDescriptor, |
26 | | - _options?: |
27 | | - | { createIfNeeded?: boolean; forceNewSession?: boolean; sync?: never; source?: Sources } |
28 | | - | { createIfNeeded?: never; forceNewSession?: never; sync: boolean; source?: Sources }, |
29 | | - ): Promise<ProviderAuthenticationSession | undefined> { |
30 | | - return Promise.resolve( |
31 | | - this.currentToken |
32 | | - ? { |
33 | | - accessToken: this.currentToken, |
34 | | - id: 'linear', |
35 | | - account: { |
36 | | - id: 'linear', |
37 | | - label: 'Linear', |
38 | | - }, |
39 | | - scopes: ['read'], |
40 | | - cloud: true, |
41 | | - expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365), |
42 | | - domain: 'linear.app', |
43 | | - } |
44 | | - : undefined, |
45 | | - ); |
46 | | - } |
47 | | - get onDidChange(): Event<void> { |
48 | | - return (_listener: (e: void) => any, _thisArgs?: any, _disposables?: Disposable[]): Disposable => { |
49 | | - return { dispose: () => {} }; |
50 | | - }; |
| 4 | +export class LinearAuthenticationProvider extends CloudIntegrationAuthenticationProvider<IssuesCloudHostIntegrationId.Linear> { |
| 5 | + protected override get authProviderId(): IssuesCloudHostIntegrationId.Linear { |
| 6 | + return IssuesCloudHostIntegrationId.Linear; |
51 | 7 | } |
52 | | - dispose(): void {} |
53 | 8 | } |
0 commit comments