Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add appcheck for vanilla js #262

Merged
merged 2 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading