mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 18:28:58 +00:00
Bring in branding when built (#251451)
* Bring in branding when built Since we shouldn't have "Visual Studio Code" in this OSS repo. * fix test
This commit is contained in:
committed by
GitHub
parent
35c4aeb69d
commit
9cbcaa893f
File diff suppressed because one or more lines are too long
1
extensions/github-authentication/media/code-icon.svg
Normal file
1
extensions/github-authentication/media/code-icon.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024"><style>.st0{fill:#f6f6f6;fill-opacity:0}.st1{fill:#fff}.st2{fill:#167abf}</style><path class="st0" d="M1024 1024H0V0h1024v1024z"/><path class="st1" d="M1024 85.333v853.333H0V85.333h1024z"/><path class="st2" d="M0 85.333h298.667v853.333H0V85.333zm1024 0v853.333H384V85.333h640zm-554.667 160h341.333v-64H469.333v64zm341.334 533.334H469.333v64h341.333l.001-64zm128-149.334H597.333v64h341.333l.001-64zm0-149.333H597.333v64h341.333l.001-64zm0-149.333H597.333v64h341.333l.001-64z"/></svg>
|
||||
|
After Width: | Height: | Size: 559 B |
Binary file not shown.
|
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
@@ -10,12 +10,12 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a class="branding" href="https://code.visualstudio.com/">
|
||||
Visual Studio Code
|
||||
</a>
|
||||
<a class="branding app-name" href="https://code.visualstudio.com/"></a>
|
||||
<div class="message-container">
|
||||
<div class="message">
|
||||
You are signed in now and can close this page.
|
||||
Sign-in successful! Returning to <span class="app-name"></span>...
|
||||
<br><br>
|
||||
If you're not redirected automatically, <a href="#" id="fallback-link" style="color: #85CEFF;">click here</a> or close this page.
|
||||
</div>
|
||||
<div class="error-message">
|
||||
An error occurred while signing in:
|
||||
@@ -23,14 +23,23 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var urlParams = new URLSearchParams(window.location.search);
|
||||
var error = urlParams.get('error');
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const error = urlParams.get('error');
|
||||
const redirectUri = urlParams.get('redirect_uri');
|
||||
|
||||
if (error) {
|
||||
document.querySelector('.error-text')
|
||||
.textContent = error;
|
||||
document.querySelector('body')
|
||||
.classList.add('error');
|
||||
} else if (urlParams.get('redirect_uri')) {
|
||||
} else if (redirectUri) {
|
||||
// Set up the fallback link
|
||||
const fallbackLink = document.getElementById('fallback-link');
|
||||
if (fallbackLink) {
|
||||
fallbackLink.href = redirectUri;
|
||||
}
|
||||
|
||||
// Redirect after a delay
|
||||
setTimeout(() => {
|
||||
window.location = urlParams.get('redirect_uri');
|
||||
}, 1000);
|
||||
|
||||
@@ -7,17 +7,22 @@ import { URL } from 'url';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { randomBytes } from 'crypto';
|
||||
import { env } from 'vscode';
|
||||
|
||||
function sendFile(res: http.ServerResponse, filepath: string) {
|
||||
const isSvg = filepath.endsWith('.svg');
|
||||
fs.readFile(filepath, (err, body) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
res.writeHead(404);
|
||||
res.end();
|
||||
} else {
|
||||
res.writeHead(200, {
|
||||
'content-length': body.length,
|
||||
});
|
||||
if (isSvg) {
|
||||
// SVGs need to be served with the correct content type
|
||||
res.setHeader('Content-Type', 'image/svg+xml');
|
||||
}
|
||||
res.setHeader('content-length', body.length);
|
||||
res.writeHead(200);
|
||||
res.end(body);
|
||||
}
|
||||
});
|
||||
@@ -93,13 +98,14 @@ export class LoopbackAuthServer implements ILoopbackServer {
|
||||
let deferred: { resolve: (result: IOAuthResult) => void; reject: (reason: any) => void };
|
||||
this._resultPromise = new Promise<IOAuthResult>((resolve, reject) => deferred = { resolve, reject });
|
||||
|
||||
const appNameQueryParam = `&app_name=${encodeURIComponent(env.appName)}`;
|
||||
this._server = http.createServer((req, res) => {
|
||||
const reqUrl = new URL(req.url!, `http://${req.headers.host}`);
|
||||
switch (reqUrl.pathname) {
|
||||
case '/signin': {
|
||||
const receivedNonce = (reqUrl.searchParams.get('nonce') ?? '').replace(/ /g, '+');
|
||||
if (receivedNonce !== this.nonce) {
|
||||
res.writeHead(302, { location: `/?error=${encodeURIComponent('Nonce does not match.')}` });
|
||||
res.writeHead(302, { location: `/?error=${encodeURIComponent('Nonce does not match.')}${appNameQueryParam}` });
|
||||
res.end();
|
||||
}
|
||||
res.writeHead(302, { location: this._startingRedirect.toString() });
|
||||
@@ -116,17 +122,17 @@ export class LoopbackAuthServer implements ILoopbackServer {
|
||||
return;
|
||||
}
|
||||
if (this.state !== state) {
|
||||
res.writeHead(302, { location: `/?error=${encodeURIComponent('State does not match.')}` });
|
||||
res.writeHead(302, { location: `/?error=${encodeURIComponent('State does not match.')}${appNameQueryParam}` });
|
||||
res.end();
|
||||
throw new Error('State does not match.');
|
||||
}
|
||||
if (this.nonce !== nonce) {
|
||||
res.writeHead(302, { location: `/?error=${encodeURIComponent('Nonce does not match.')}` });
|
||||
res.writeHead(302, { location: `/?error=${encodeURIComponent('Nonce does not match.')}${appNameQueryParam}` });
|
||||
res.end();
|
||||
throw new Error('Nonce does not match.');
|
||||
}
|
||||
deferred.resolve({ code, state });
|
||||
res.writeHead(302, { location: `/?redirect_uri=${encodeURIComponent(callbackUri)}` });
|
||||
res.writeHead(302, { location: `/?redirect_uri=${encodeURIComponent(callbackUri)}${appNameQueryParam}` });
|
||||
res.end();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { LoopbackAuthServer } from '../../node/authServer';
|
||||
import { env } from 'vscode';
|
||||
|
||||
suite('LoopbackAuthServer', () => {
|
||||
let server: LoopbackAuthServer;
|
||||
@@ -53,7 +54,7 @@ suite('LoopbackAuthServer', () => {
|
||||
{ redirect: 'manual' }
|
||||
);
|
||||
assert.strictEqual(response.status, 302);
|
||||
assert.strictEqual(response.headers.get('location'), '/?redirect_uri=https%3A%2F%2Fcode.visualstudio.com');
|
||||
assert.strictEqual(response.headers.get('location'), `/?redirect_uri=https%3A%2F%2Fcode.visualstudio.com&app_name=${encodeURIComponent(env.appName)}`);
|
||||
await Promise.race([
|
||||
server.waitForOAuthResponse().then(result => {
|
||||
assert.strictEqual(result.code, 'valid-code');
|
||||
|
||||
Reference in New Issue
Block a user