Skip to content

Commit

Permalink
fix: add appcheck for vanilla js (#262)
Browse files Browse the repository at this point in the history
* fix: add appcheck for vanilla js

* Update index.html
  • Loading branch information
HYACCCINT authored Oct 19, 2023
1 parent 1eb300f commit facbeeb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions vanilla-js/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ <h2 id="my-mdc-dialog-label" class="mdc-dialog__header__title">
<script src="/__/firebase/9.22.1/firebase-app-compat.js"></script>
<script src="/__/firebase/9.22.1/firebase-auth-compat.js"></script>
<script src="/__/firebase/9.22.1/firebase-firestore-compat.js"></script>
<script src="/__/firebase/9.22.1/firebase-app-check-compat.js"></script>
<script src="/__/firebase/init.js"></script>

<script src="//unpkg.com/navigo@6"></script>
Expand Down
6 changes: 6 additions & 0 deletions vanilla-js/scripts/FriendlyEats.View.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,9 @@ FriendlyEats.prototype.replaceElement = function(parent, content) {
FriendlyEats.prototype.rerender = function() {
this.router.navigate(document.location.pathname + '?' + new Date().getTime());
};

FriendlyEats.prototype.initAppCheck = function() {
/*
TODO: Initialize and activate App Check
*/
};
17 changes: 17 additions & 0 deletions vanilla-js/scripts/FriendlyEats.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@
* Initializes the FriendlyEats app.
*/
function FriendlyEats() {
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
if(isLocalhost) {
/*
TODO: Set up local debug token
*/
}

this.filters = {
city: '',
price: '',
Expand All @@ -29,6 +44,8 @@ function FriendlyEats() {
this.dialogs = {};

var that = this;
that.initAppCheck();

firebase.auth().signInAnonymously().then(function() {
that.initTemplates();
that.initRouter();
Expand Down

0 comments on commit facbeeb

Please sign in to comment.