"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "extensions/github-authentication/src/github.ts" between
vscode-1.50.0.tar.gz and vscode-1.50.1.tar.gz

About: Visual Studio Code is a source code editor (available for Windows, macOS and Linux). It comes with built-in support for JavaScript, TypeScript and Node.js and has extensions for other languages (such as C++, C#, Java, Python, PHP, Go). Source code.

github.ts  (vscode-1.50.0):github.ts  (vscode-1.50.1)
skipping to change at line 29 skipping to change at line 29
id: string; id: string;
} }
scopes: string[]; scopes: string[];
accessToken: string; accessToken: string;
} }
export class GitHubAuthenticationProvider { export class GitHubAuthenticationProvider {
private _sessions: vscode.AuthenticationSession[] = []; private _sessions: vscode.AuthenticationSession[] = [];
private _githubServer = new GitHubServer(); private _githubServer = new GitHubServer();
public async initialize(): Promise<void> { public async initialize(context: vscode.ExtensionContext): Promise<void> {
try { try {
this._sessions = await this.readSessions(); this._sessions = await this.readSessions();
} catch (e) { } catch (e) {
// Ignore, network request failed // Ignore, network request failed
} }
this.pollForChange(); context.subscriptions.push(vscode.authentication.onDidChangePassw ord(() => this.checkForUpdates()));
} }
private pollForChange() { private async checkForUpdates() {
setTimeout(async () => { let storedSessions: vscode.AuthenticationSession[];
let storedSessions: vscode.AuthenticationSession[]; try {
try { storedSessions = await this.readSessions();
storedSessions = await this.readSessions(); } catch (e) {
} catch (e) { // Ignore, network request failed
// Ignore, network request failed return;
return; }
}
const added: string[] = [];
const removed: string[] = [];
storedSessions.forEach(session => { const added: string[] = [];
const matchesExisting = this._sessions.some(s => const removed: string[] = [];
s.id === session.id);
// Another window added a session to the keychain
, add it to our state as well
if (!matchesExisting) {
Logger.info('Adding session found in keyc
hain');
this._sessions.push(session);
added.push(session.id);
}
});
this._sessions.map(session => { storedSessions.forEach(session => {
const matchesExisting = storedSessions.some(s => const matchesExisting = this._sessions.some(s => s.id ===
s.id === session.id); session.id);
// Another window has logged out, remove from our // Another window added a session to the keychain, add it
state to our state as well
if (!matchesExisting) { if (!matchesExisting) {
Logger.info('Removing session no longer f Logger.info('Adding session found in keychain');
ound in keychain'); this._sessions.push(session);
const sessionIndex = this._sessions.findI added.push(session.id);
ndex(s => s.id === session.id); }
if (sessionIndex > -1) { });
this._sessions.splice(sessionInde
x, 1);
}
removed.push(session.id); this._sessions.map(session => {
const matchesExisting = storedSessions.some(s => s.id ===
session.id);
// Another window has logged out, remove from our state
if (!matchesExisting) {
Logger.info('Removing session no longer found in
keychain');
const sessionIndex = this._sessions.findIndex(s =
> s.id === session.id);
if (sessionIndex > -1) {
this._sessions.splice(sessionIndex, 1);
} }
});
if (added.length || removed.length) { removed.push(session.id);
onDidChangeSessions.fire({ added, removed, change
d: [] });
} }
});
this.pollForChange(); if (added.length || removed.length) {
}, 1000 * 30); onDidChangeSessions.fire({ added, removed, changed: [] })
;
}
} }
private async readSessions(): Promise<vscode.AuthenticationSession[]> { private async readSessions(): Promise<vscode.AuthenticationSession[]> {
const storedSessions = await keychain.getToken(); const storedSessions = await keychain.getToken();
if (storedSessions) { if (storedSessions) {
try { try {
const sessionData: SessionData[] = JSON.parse(sto redSessions); const sessionData: SessionData[] = JSON.parse(sto redSessions);
const sessionPromises = sessionData.map(async (se ssion: SessionData): Promise<vscode.AuthenticationSession> => { const sessionPromises = sessionData.map(async (se ssion: SessionData): Promise<vscode.AuthenticationSession> => {
const needsUserInfo = !session.account; const needsUserInfo = !session.account;
let userInfo: { id: string, accountName: string }; let userInfo: { id: string, accountName: string };
 End of changes. 10 change blocks. 
47 lines changed or deleted 40 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)