mirror of
https://github.com/IvarK/AntimatterDimensionsSourceCode.git
synced 2024-11-23 20:52:08 +00:00
Implement Firebase config management via GitHub Actions secrets
This commit is contained in:
parent
a0b9e36ed4
commit
0b1fa8723a
3
.github/workflows/deploy-master.yml
vendored
3
.github/workflows/deploy-master.yml
vendored
@ -1,5 +1,8 @@
|
||||
name: Deploy master
|
||||
|
||||
env:
|
||||
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
|
3
.github/workflows/deploy-release.yml
vendored
3
.github/workflows/deploy-release.yml
vendored
@ -1,5 +1,8 @@
|
||||
name: Deploy release
|
||||
|
||||
env:
|
||||
FIREBASE_CONFIG: ${{ secrets.FIREBASE_CONFIG }}
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
|
@ -5,3 +5,11 @@ const browserslist = require("browserslist-useragent-regexp");
|
||||
const userAgentRegExp = browserslist.getUserAgentRegExp({ allowHigherVersions: true });
|
||||
const checkFunction = `export const supportedBrowsers = ${userAgentRegExp};`;
|
||||
fs.writeFileSync(path.resolve(__dirname, "../src/supported-browsers.js"), checkFunction);
|
||||
|
||||
const firebaseConfig = process.env.FIREBASE_CONFIG;
|
||||
if (firebaseConfig) {
|
||||
fs.writeFileSync(
|
||||
path.resolve(__dirname, "../src/core/storage/firebase-config.js"),
|
||||
`export const firebaseConfig = ${firebaseConfig};`
|
||||
);
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
cloudAvailable: false,
|
||||
cloudEnabled: false,
|
||||
forceCloudOverwrite: false,
|
||||
showCloudModal: false,
|
||||
@ -70,6 +71,7 @@ export default {
|
||||
methods: {
|
||||
update() {
|
||||
const options = player.options;
|
||||
this.cloudAvailable = Cloud.isAvailable;
|
||||
this.cloudEnabled = options.cloudEnabled;
|
||||
this.forceCloudOverwrite = options.forceCloudOverwrite;
|
||||
this.showCloudModal = options.showCloudModal;
|
||||
@ -209,7 +211,10 @@ export default {
|
||||
</div>
|
||||
<OpenModalHotkeysButton />
|
||||
</div>
|
||||
<h2 class="c-cloud-options-header">
|
||||
<h2
|
||||
v-if="cloudAvailable"
|
||||
class="c-cloud-options-header"
|
||||
>
|
||||
<span v-if="hideGoogleName">Logged in to Google <i>(name hidden)</i></span>
|
||||
<span v-else-if="loggedIn">Logged in as {{ userName }}</span>
|
||||
<span v-else>Not logged in</span>
|
||||
@ -218,7 +223,10 @@ export default {
|
||||
<span v-if="cloudEnabled">Cloud Saving will occur automatically every 10 minutes.</span>
|
||||
<span v-else>Cloud Saving has been disabled on this save.</span>
|
||||
</div>
|
||||
<div class="l-options-grid">
|
||||
<div
|
||||
v-if="cloudAvailable"
|
||||
class="l-options-grid"
|
||||
>
|
||||
<div
|
||||
v-if="!STEAM"
|
||||
class="l-options-grid__row"
|
||||
|
@ -485,6 +485,7 @@ GameDatabase.tabs = [
|
||||
name: "Shop",
|
||||
newUIClass: "shop",
|
||||
hideAt: 1.5,
|
||||
condition: () => Cloud.isAvailable,
|
||||
id: 10,
|
||||
hidable: true,
|
||||
subtabs: [
|
||||
|
@ -17,28 +17,26 @@ import { sha512_256 } from "js-sha512";
|
||||
import { STEAM } from "@/env";
|
||||
|
||||
import { decodeBase64Binary } from "./base64-binary";
|
||||
import { firebaseConfig } from "./firebase-config";
|
||||
import { ProgressChecker } from "./progress-checker";
|
||||
import { SteamRuntime } from "@/steam";
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyDuRTTluAFufmvw1zxGH6fsyEHmmbu8IHI",
|
||||
authDomain: "antimatter-dimensions-a00f2.firebaseapp.com",
|
||||
databaseURL: "https://antimatter-dimensions-a00f2.firebaseio.com",
|
||||
projectId: "antimatter-dimensions-a00f2",
|
||||
storageBucket: "antimatter-dimensions-a00f2.appspot.com",
|
||||
messagingSenderId: "904798020003",
|
||||
appId: "1:904798020003:web:d1448dcb2dedd8b5",
|
||||
};
|
||||
|
||||
initializeApp(firebaseConfig);
|
||||
const hasFirebaseConfig = firebaseConfig.apiKey !== null;
|
||||
if (hasFirebaseConfig) {
|
||||
initializeApp(firebaseConfig);
|
||||
}
|
||||
|
||||
export const Cloud = {
|
||||
provider: new GoogleAuthProvider(),
|
||||
auth: getAuth(),
|
||||
db: getDatabase(),
|
||||
provider: hasFirebaseConfig ? new GoogleAuthProvider() : null,
|
||||
auth: hasFirebaseConfig ? getAuth() : null,
|
||||
db: hasFirebaseConfig ? getDatabase() : null,
|
||||
user: null,
|
||||
lastCloudHash: null,
|
||||
|
||||
get isAvailable() {
|
||||
return hasFirebaseConfig;
|
||||
},
|
||||
|
||||
resetTempState() {
|
||||
this.lastCloudHash = null;
|
||||
GameStorage.lastCloudSave = Date.now();
|
||||
@ -50,6 +48,10 @@ export const Cloud = {
|
||||
},
|
||||
|
||||
async login() {
|
||||
if (!this.isAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await signInWithPopup(this.auth, this.provider);
|
||||
ShopPurchaseData.syncSTD();
|
||||
@ -61,6 +63,10 @@ export const Cloud = {
|
||||
},
|
||||
|
||||
async loginWithSteam(accountId, staticAccountId, screenName) {
|
||||
if (!this.isAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.loggedIn) {
|
||||
Cloud.user.displayName = screenName;
|
||||
return;
|
||||
@ -115,6 +121,10 @@ export const Cloud = {
|
||||
},
|
||||
|
||||
async saveCheck(forceModal = false) {
|
||||
if (!this.isAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
const saveId = GameStorage.currentSlot;
|
||||
const cloudSave = await this.load();
|
||||
if (cloudSave === null) {
|
||||
@ -173,6 +183,10 @@ export const Cloud = {
|
||||
},
|
||||
|
||||
async loadCheck() {
|
||||
if (!this.isAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
const save = await this.load();
|
||||
if (save === null) {
|
||||
if (player.options.hideGoogleName) GameUI.notify.info(`No cloud save for current Google Account`);
|
||||
@ -258,11 +272,19 @@ export const Cloud = {
|
||||
},
|
||||
|
||||
logout() {
|
||||
if (!this.isAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
signOut(this.auth);
|
||||
ShopPurchaseData.clearLocalSTD();
|
||||
},
|
||||
|
||||
init() {
|
||||
if (!this.isAvailable) {
|
||||
return;
|
||||
}
|
||||
|
||||
getAuth().onAuthStateChanged(user => {
|
||||
if (user) {
|
||||
this.user = {
|
||||
|
11
src/core/storage/firebase-config.js
Normal file
11
src/core/storage/firebase-config.js
Normal file
@ -0,0 +1,11 @@
|
||||
// Replace the following with your app's Firebase project configuration
|
||||
// See: https://firebase.google.com/docs/web/learn-more#config-object
|
||||
export const firebaseConfig = {
|
||||
"apiKey": null,
|
||||
"authDomain": null,
|
||||
"databaseURL": null,
|
||||
"projectId": null,
|
||||
"storageBucket": null,
|
||||
"messagingSenderId": null,
|
||||
"appId": null,
|
||||
};
|
Loading…
Reference in New Issue
Block a user