mirror of
https://github.com/chinchang/web-maker.git
synced 2025-06-11 20:20:50 +02:00
WIP
This commit is contained in:
74
src/auth.js
74
src/auth.js
@ -5,8 +5,9 @@ import {
|
|||||||
TwitterAuthProvider,
|
TwitterAuthProvider,
|
||||||
GoogleAuthProvider,
|
GoogleAuthProvider,
|
||||||
signInWithPopup,
|
signInWithPopup,
|
||||||
|
signInWithCredential,
|
||||||
signOut
|
signOut
|
||||||
} from 'firebase/auth';
|
} from 'firebase/auth/web-extension';
|
||||||
import { log } from './utils';
|
import { log } from './utils';
|
||||||
|
|
||||||
export const authh = {
|
export const authh = {
|
||||||
@ -14,6 +15,77 @@ export const authh = {
|
|||||||
signOut();
|
signOut();
|
||||||
},
|
},
|
||||||
login(providerName) {
|
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;
|
var provider;
|
||||||
if (providerName === 'facebook') {
|
if (providerName === 'facebook') {
|
||||||
provider = new FacebookAuthProvider();
|
provider = new FacebookAuthProvider();
|
||||||
|
@ -234,13 +234,13 @@ export default class CodeEditor extends Component {
|
|||||||
async loadDeps() {
|
async loadDeps() {
|
||||||
if (this.props.type === 'monaco') {
|
if (this.props.type === 'monaco') {
|
||||||
if (!monacoDepsDeferred) {
|
if (!monacoDepsDeferred) {
|
||||||
monacoDepsDeferred = deferred();
|
// monacoDepsDeferred = deferred();
|
||||||
loadCss({ url: 'lib/monaco/monaco.css', id: 'monaco-css' });
|
// loadCss({ url: 'lib/monaco/monaco.css', id: 'monaco-css' });
|
||||||
import(
|
// import(
|
||||||
/* webpackChunkName: "monaco" */ '/lib/monaco/monaco.bundle.js'
|
// /* webpackChunkName: "monaco" */ '/lib/monaco/monaco.bundle.js'
|
||||||
).then(() => {
|
// ).then(() => {
|
||||||
monacoDepsDeferred.resolve();
|
// monacoDepsDeferred.resolve();
|
||||||
});
|
// });
|
||||||
}
|
}
|
||||||
return monacoDepsDeferred.promise;
|
return monacoDepsDeferred.promise;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,16 @@ const config = {
|
|||||||
messagingSenderId: '560473480645'
|
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 { app };
|
||||||
|
|
||||||
export const auth = getAuth(app);
|
export const auth = getAuth(app);
|
||||||
|
@ -11,11 +11,8 @@
|
|||||||
rel="manifest"
|
rel="manifest"
|
||||||
href="<%= htmlWebpackPlugin.files.publicPath %>manifest.json"
|
href="<%= htmlWebpackPlugin.files.publicPath %>manifest.json"
|
||||||
/>
|
/>
|
||||||
<% if (cli.env.isProd) { %>
|
|
||||||
<base href="/create/" />
|
<% if (cli.manifest.theme_color) { %>
|
||||||
<% } else { %>
|
|
||||||
<base href="/" />
|
|
||||||
<% } %> <% if (cli.manifest.theme_color) { %>
|
|
||||||
<meta name="theme-color" content="<%= cli.manifest.theme_color %>" />
|
<meta name="theme-color" content="<%= cli.manifest.theme_color %>" />
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"description": "Blazing fast & offline playground for your web experiments",
|
"description": "Blazing fast & offline playground for your web experiments",
|
||||||
"homepage_url": "https://webmaker.app",
|
"homepage_url": "https://webmaker.app",
|
||||||
"permissions": ["storage", "tabs"],
|
"permissions": ["storage", "tabs", "identity"],
|
||||||
"optional_permissions": ["downloads"],
|
"optional_permissions": ["downloads"],
|
||||||
"host_permissions": ["<all_urls>"],
|
"host_permissions": ["<all_urls>"],
|
||||||
"content_security_policy": {
|
"content_security_policy": {
|
||||||
@ -29,5 +29,14 @@
|
|||||||
"icons": {
|
"icons": {
|
||||||
"16": "icon-16.png",
|
"16": "icon-16.png",
|
||||||
"48": "icon-48.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"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user