Skip to content

Commit

Permalink
fix: gitlab private repo auth
Browse files Browse the repository at this point in the history
  • Loading branch information
conwnet committed Feb 23, 2024
1 parent 0800739 commit e2d1635
Show file tree
Hide file tree
Showing 19 changed files with 1,238 additions and 510 deletions.
4 changes: 2 additions & 2 deletions api/github-auth-callback/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "github-auth-callback",
"version": "0.0.0",
"main": "index.js",
"main": "index.ts",
"license": "MIT",
"private": true,
"dependencies": {
"got": "^11.8.5"
},
"devDependencies": {
"@vercel/node": "^2.9.10"
"@vercel/node": "^3.0.20"
}
}
592 changes: 518 additions & 74 deletions api/github-auth-callback/yarn.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions api/gitlab-auth-callback/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "vscode-unpkg",
"version": "1.0.0",
"main": "index.js",
"name": "gitlab-auth-callback",
"version": "0.0.0",
"main": "index.ts",
"license": "MIT",
"private": true,
"dependencies": {
"got": "^11.8.5"
},
"devDependencies": {
"@vercel/node": "^2.5.7"
"@vercel/node": "^3.0.20"
}
}
692 changes: 592 additions & 100 deletions api/gitlab-auth-callback/yarn.lock

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions extensions/github1s/assets/pages/assets/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions extensions/github1s/assets/pages/assets/gitlab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 0 additions & 8 deletions extensions/github1s/assets/pages/github1s-authentication.css
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,6 @@
margin-right: 8px;
}

.github-logo {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" height="32" width="32"><path d="M8 0c4.42 0 8 3.58 8 8a8.013 8.013 0 0 1-5.45 7.59c-.4.08-.55-.17-.55-.38 0-.27.01-1.13.01-2.2 0-.75-.25-1.23-.54-1.48 1.78-.2 3.65-.88 3.65-3.95 0-.88-.31-1.59-.82-2.15.08-.2.36-1.02-.08-2.12 0 0-.67-.22-2.2.82-.64-.18-1.32-.27-2-.27-.68 0-1.36.09-2 .27-1.53-1.03-2.2-.82-2.2-.82-.44 1.1-.16 1.92-.08 2.12-.51.56-.82 1.28-.82 2.15 0 3.06 1.86 3.75 3.64 3.95-.23.2-.44.55-.51 1.07-.46.21-1.61.55-2.33-.66-.15-.24-.6-.83-1.23-.82-.67.01-.27.38.01.53.34.19.73.9.82 1.13.16.45.68 1.31 2.69.94 0 .67.01 1.3.01 1.49 0 .21-.15.45-.55.38A7.995 7.995 0 0 1 0 8c0-4.42 3.58-8 8-8Z"></path></svg>');
}

.gitlab-logo {
background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 24" height="24" width="25"><path fill="%23E24329" d="m24.507 9.5-.034-.09L21.082.562a.896.896 0 0 0-1.694.091l-2.29 7.01H7.825L5.535.653a.898.898 0 0 0-1.694-.09L.451 9.411.416 9.5a6.297 6.297 0 0 0 2.09 7.278l.012.01.03.022 5.16 3.867 2.56 1.935 1.554 1.176a1.051 1.051 0 0 0 1.268 0l1.555-1.176 2.56-1.935 5.197-3.89.014-.01A6.297 6.297 0 0 0 24.507 9.5Z"></path><path fill="%23FC6D26" d="m24.507 9.5-.034-.09a11.44 11.44 0 0 0-4.56 2.051l-7.447 5.632 4.742 3.584 5.197-3.89.014-.01A6.297 6.297 0 0 0 24.507 9.5Z"></path><path fill="%23FCA326" d="m7.707 20.677 2.56 1.935 1.555 1.176a1.051 1.051 0 0 0 1.268 0l1.555-1.176 2.56-1.935-4.743-3.584-4.755 3.584Z"></path><path fill="%23FC6D26" d="M5.01 11.461a11.43 11.43 0 0 0-4.56-2.05L.416 9.5a6.297 6.297 0 0 0 2.09 7.278l.012.01.03.022 5.16 3.867 4.745-3.584-7.444-5.632Z"></path></svg>');
}

.authentication-detail {
display: flex;
flex-direction: column;
Expand Down
3 changes: 2 additions & 1 deletion extensions/github1s/assets/pages/github1s-authentication.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ const AuthenticationButton = (props) => {
bridgeCommands.OAuthAuthenticate().then(() => setAuthenticating(false));
}, []);

const buttonLogoUrl = encodeURI(`${pageConfig.extensionUri}/${pageConfig.OAuthButtonLogo}`);
return html`
<button class="authentication-button" disabled="${authenticating}" onClick=${handleButtonClick} ...${props}>
<span class=${'auth-button-logo ' + pageConfig.OAuthButtonLogoClass}></span>
<span class=${'auth-button-logo'} style=${`background-image: url("${buttonLogoUrl}")`}></span>
<span>${pageConfig.OAuthButtonText}</span>
</button>
`;
Expand Down
10 changes: 10 additions & 0 deletions extensions/github1s/assets/pages/github1s-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ const PageFooter = () => {
[updateSgApiFirst]
);

useEffect(() => {
const handler = ({ data }) => {
if (data.type === 'use-sourcegraph-api-first-changed') {
setSgApiFirst(data.value);
}
};
window.addEventListener('message', handler);
return () => window.removeEventListener('message', handler);
}, []);

useEffect(() => {
updateSgApiFirst();
}, [updateSgApiFirst]);
Expand Down
228 changes: 0 additions & 228 deletions extensions/github1s/assets/pages/gitlab1s-authentication.js

This file was deleted.

5 changes: 3 additions & 2 deletions extensions/github1s/src/adapters/github1s/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export class GitHub1sAuthenticationView {
protected OAuthCommand = 'github1s.commands.vscode.connectToGitHub';
protected pageConfig: Record<string, unknown> = {
authenticationFormTitle: 'Authenticating to GitHub',
OAuthButtonLogoClass: 'github-logo',
OAuthButtonText: 'Connect to GitHub',
OAuthButtonLogo: 'assets/pages/assets/github.svg',
createTokenLink: 'https://github.com/settings/tokens/new?scopes=repo&description=GitHub1s',
rateLimitDocLink: 'https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting',
rateLimitDocLinkText: 'GitHub Rate limiting Documentation',
Expand Down Expand Up @@ -122,9 +122,10 @@ export class GitHub1sAuthenticationView {
vscode.Uri.joinPath(extensionContext.extensionUri, 'assets/pages/components.css').toString(),
vscode.Uri.joinPath(extensionContext.extensionUri, 'assets/pages/github1s-authentication.css').toString(),
];
const globalPageConfig = { ...this.pageConfig, extensionUri: extensionContext.extensionUri.toString() };
const scripts = [
'data:text/javascript;base64,' +
Buffer.from(`window.pageConfig=${JSON.stringify(this.pageConfig)};`).toString('base64'),
Buffer.from(`window.pageConfig=${JSON.stringify(globalPageConfig)};`).toString('base64'),
vscode.Uri.joinPath(extensionContext.extensionUri, 'assets/pages/github1s-authentication.js').toString(),
];

Expand Down
1 change: 0 additions & 1 deletion extensions/github1s/src/adapters/github1s/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ export class GitHub1sDataSource extends DataSource {
const { owner, repo } = parseRepoFullName(repoFullName);
const requestParams = { owner, repo, ref, path };
const { data } = await fetcher.request('GET /repos/{owner}/{repo}/contents/{path}', requestParams);
// fetcher.request('GET /user')
return { content: toUint8Array((data as any).content) };
}

Expand Down
Loading

0 comments on commit e2d1635

Please sign in to comment.