1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-06-08 18:54:49 +02:00
This commit is contained in:
Kushagra Gour 2024-05-07 17:04:14 +05:30
parent 2289af6a0b
commit 4ad8621137
5 changed files with 102 additions and 15 deletions

View File

@ -5,8 +5,9 @@ import {
TwitterAuthProvider,
GoogleAuthProvider,
signInWithPopup,
signInWithCredential,
signOut
} from 'firebase/auth';
} from 'firebase/auth/web-extension';
import { log } from './utils';
export const authh = {
@ -14,6 +15,77 @@ export const authh = {
signOut();
},
login(providerName) {
const ru = chrome.identity.getRedirectURL('');
console.log(111, ru);
chrome.identity.launchWebAuthFlow(
{
interactive: true,
url: `https://github.com/login/oauth/authorize?client_id=5d26b6d331c0e1a66656&redirect_uri=${ru}&scope=user:email&response_type=token`
},
function (responseUrl) {
const tokenMatch = responseUrl.match(/code=(.*)/);
console.log({ responseUrl }, tokenMatch[1]);
const token = tokenMatch ? tokenMatch[1] : null;
if (!token) {
console.error('No token found');
return;
}
const credential = GithubAuthProvider.credential('');
signInWithCredential(auth, credential)
.then(result => {
console.log('Success!!!');
console.log(result);
})
.catch(error => {
// You can handle errors here
console.log(88, error);
});
}
);
return;
chrome.identity.getAuthToken({ interactive: true }, function (token) {
//Token: This requests an OAuth token from the Chrome Identity API.
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError);
} else if (token) {
console.error(222, token);
// Follows: https://firebase.google.com/docs/auth/web/google-signin
// Authorize Firebase with the OAuth Access Token.
// console.log("TOKEN:")
// console.log(token)
// Builds Firebase credential with the Google ID token.
const credential = GoogleAuthProvider.credential(null, token);
signInWithCredential(auth, credential)
.then(result => {
console.log('Success!!!');
console.log(result);
})
.catch(error => {
// You can handle errors here
console.log(error);
});
} else {
console.error('The OAuth token was null');
}
});
// chrome.identity.getAuthToken({}, token => {
// console.log(7777, token);
// let credential = GoogleAuthProvider.credential(null, token);
// console.log(277, credential);
// signInWithCredential(credential)
// .then(userCredential => {
// console.log(999, userCredential);
// })
// .catch(error => {
// console.error(error);
// });
// });
return;
var provider;
if (providerName === 'facebook') {
provider = new FacebookAuthProvider();

View File

@ -234,13 +234,13 @@ export default class CodeEditor extends Component {
async loadDeps() {
if (this.props.type === 'monaco') {
if (!monacoDepsDeferred) {
monacoDepsDeferred = deferred();
loadCss({ url: 'lib/monaco/monaco.css', id: 'monaco-css' });
import(
/* webpackChunkName: "monaco" */ '/lib/monaco/monaco.bundle.js'
).then(() => {
monacoDepsDeferred.resolve();
});
// monacoDepsDeferred = deferred();
// loadCss({ url: 'lib/monaco/monaco.css', id: 'monaco-css' });
// import(
// /* webpackChunkName: "monaco" */ '/lib/monaco/monaco.bundle.js'
// ).then(() => {
// monacoDepsDeferred.resolve();
// });
}
return monacoDepsDeferred.promise;
}

View File

@ -11,7 +11,16 @@ const config = {
messagingSenderId: '560473480645'
};
const app = initializeApp(config);
const configStaging = {
apiKey: 'AIzaSyCU3X3p0MJHF7PUIGUJV2ipfuFx3-d9Y1I',
authDomain: 'web-maker-staging.firebaseapp.com',
projectId: 'web-maker-staging',
storageBucket: 'web-maker-staging.appspot.com',
messagingSenderId: '365859090303',
appId: '1:365859090303:web:1becf81ce3374e5f97b44a'
};
const app = initializeApp(configStaging);
export { app };
export const auth = getAuth(app);

View File

@ -11,11 +11,8 @@
rel="manifest"
href="<%= htmlWebpackPlugin.files.publicPath %>manifest.json"
/>
<% if (cli.env.isProd) { %>
<base href="/create/" />
<% } else { %>
<base href="/" />
<% } %> <% if (cli.manifest.theme_color) { %>
<% if (cli.manifest.theme_color) { %>
<meta name="theme-color" content="<%= cli.manifest.theme_color %>" />
<% } %>

View File

@ -4,7 +4,7 @@
"manifest_version": 3,
"description": "Blazing fast & offline playground for your web experiments",
"homepage_url": "https://webmaker.app",
"permissions": ["storage", "tabs"],
"permissions": ["storage", "tabs", "identity"],
"optional_permissions": ["downloads"],
"host_permissions": ["<all_urls>"],
"content_security_policy": {
@ -29,5 +29,14 @@
"icons": {
"16": "icon-16.png",
"48": "icon-48.png"
},
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp4s9naKH2y92qItJCcj3deRGjjqhDfgUR2WDe34IEYEB4PGtmx/9IO4PaO49gMr82DBRuwxCg/vr9SyiVlG1/j0TApJlkaHVsRZE4EME2rbL1vzIQRE8gNB+b5L6rPl4GPX/eFqIuUe/UgQPZAadLBVxdwBdOv5ou8OY0jrLx/h0wcLVvk9d8/ELpk28Hb2LArCBd+vIngHK55Db1GMEGAyNUVzFCTg/MZ7w5fKLpA94mF2X0/Bv9sCjj7vDir24Mp5Z/Y3obTHvpzddppAE6ZEQ3fmpRkOJ3MbuaKYm9hNHs4az6XLW6Sdlv2YcIcCfvsev/WEKUZeD8KIRtRyyPQIDAQAB",
"oauth2": {
"client_id": "560473480645-f7l1mbbjhhs5vh5gqvgeqe0g3vv557l8.apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
]
}
}