I've been trying to do some CRUD operations to a local drive using chrome extensions.
I understand i won't be able to access the local file system directly, a sandboxed environment will do.
LocalStorage worked for data upto 5 mb. I'll be needing more.
I've found that setting "unlimitedStorage" won't grant more to the LocalStorage.
"unlimitedStorage"
Provides an unlimited quota for storing HTML5 client-side data, such as databases and local storage files. Without this permission, the extension or app is limited to 5 MB of local storage.
Note: This permission applies only to Web SQL Database and application cache (see issue 58985). Also, it doesn't currently work with wildcard subdomains such as http://*.example.com.
see chrome extension docs
I've then tried to use the FileSystemApi.
But it turned out that only chrome apps can use this api.
As far as i know I'm left with 4 other options:
WebSQL, which is deprecated.
IndexedDB, which looks promising
Application cache, referenced in the notes of the unlimitedStorage description.
Storage api, Which seems to be available for both extensions and apps
I've got a hunch that indexedDb will allow some form of CRUD. I'm reluctant to use WebSQL as it's deprecated and i've yet to find information about the Application cache, although i doubt that storing data for extensions is within the boundaries of its intended purpose.
Is it possible for chrome extensions to save, load and delete files on the local file system?
Am i misinformed about the LocalStorage Limitations or the use of the fileSystem Api in chrome extensions?
Will IndexedDB fulfill my needs?
Try with Cordova, Capacitor or similars.
In the browser, run the code in your test area, if you want to use your sandbox you need to run the application on the device (iOS, Android, Windows, Linux, etc.) and use native resources inside the sandbox, dont forget request permission.
If you work with ionic v4 you can use capacitor and mostest important is you can build for native app from web components to have your sandbox into native device!
Capacitor:
https://capacitor.ionicframework.com/docs/apis/filesystem/
Cordova:
https://cordova.apache.org/docs/en/latest/cordova/storage/storage.html
Related
I need to create an application which will be ran on the browser (local only, not hosted online). I will need to use a lightweight database which has a physical file (eg SQLite3, so I can have a .db file).
Also, just to mention:
I cant use IndexedDB alone to save the data because clearing browser data would clear the entire "database".
I also wouldn't be able to use electron since the bundle is too big. I need the browser for its portability
Also cant use PouchDB, since due to security constraints, online sync (CouchDB, etc) is not possible. Then it would be 100% stored in IndexedDB, which brings me back to my point on bullet 1
My question is - is there a way to create an offline web application build with VueJS frontend + NodeJS backend? I only need NodeJS because SQLite only works on the Node environment.
Deployment is preferably in .html only (is there any way that is possible, and access only using the file protocol file://)? Otherwise, I may consider using a local web server (localhost) - I'm not sure though if it is possible to serve an html file without any installations (node, python, etc), so I would still have to check all my options about this.
Any thoughts?
I am still new to this so please bear with me! There is very limited info online that talks about a 100% offline web application. Thanks a lot!
I been working on a React project using firebase auth and cloud firestore as the database and I been reading the official documents. But I am grappling with the idea of whether to use mobile/web SDKs and server client libraries and I am afraid I might have some misconceptions about Cloud Firestore Security Rules.
I read this page https://firebase.google.com/docs/firestore/client/libraries several times and it is about SDKs and client libraries for firestore. It seems to me that it suggests there are two ways of using firestore: one is through Mobile and web SDKs and one is through Server client libraries. And if I am using Mobile and web SDKs then my project would be classified as serverless since I am only building the front end and let Goole to handle the database and user authentication. The other way to use firestore, which is Server client libraries, it seems like it is meant to be used with your own server. It then refers to this as client libraries in the section, But the thing I don't quite understand is, what does client mean here? I'm sure it doesn't mean the same thing as in "the mobile and web SDKs support serverless app architectures where clients connect directly to your Cloud Firestore database.", where I assume a client is an end user who is browsing your website or web app. So what does this the client mean as in Server client libraries?
Since I am only able to build front end app or the client side app, I guess I should go with Mobile and web SDKs option to start using the firebase. Here comes the second question, when selecting a starting mode for my Cloud Firestore Security Rules, there are two modes: Test mode
and Locked mode. For Test mode, it says "Good for getting started with the mobile and web client libraries, but allows anyone to read and overwrite your data. After testing, make sure to review the Secure your data section.". My first confusion is, does client libraries refer to the Server client libraries previously I mentioned? If so, as a serverless project without a server I cannot technically I cannot choose this mode? Then for Locked mode it says, "Denies all reads and writes from mobile and web clients. Your authenticated application servers (C#, Go, Java, Node.js, PHP, Python, or Ruby) can still access your database." Again this option seems like it is not for me since it mentioned Your authenticated application servers, and for my project I don't have a server, or the server is on the google cloud platform. So can someone please correct me if I am understanding this wrong. Also, if I opt-in the Test mode, I suppose it allows anyone to read and overwrite my data. But I feel like there needs more explanation on the word anyone here. I think at least the person needs to have the exact firebase configuration as my project has. something like this
const config = {
apiKey: "myapikey",
authDomain: "my-auth-domain.firebaseapp.com",
databaseURL: "my-db-url.com",
projectId: "my-pid",
storageBucket: "my-storage-bucket",
messagingSenderId: "my-sender-id",
};
to access my database. I think by anyone, here it means anyone with this config file and doesn't need to log in to my project in order to mess with my database. This is my understanding, can someone please correct me? Finally, in my case, I just want that anyone who can log in to my project can have access to the database(both read and write). Which mode(test or locked) should I go with? Or I need more configuration for this?
Is it true that whether I choose web SDKs or Server client libraries to start my firestore project, I all need to use firebase-admin? But do I need to use Firebase CLI to init my project as a firebase project with the automatically generated firebase.json?
The official documents constantly use the word web and node.js, such as this image. . I actually don't know what they exactly mean. If I am writing React, should I go with web or node.js? If it belongs to web, I am importing stuff like import firebase from "firebase/app"; in my react project, these are also modules for Node.js. Again I am confused here.
I know this might be too long to read and the questions might be a bit trivial but I really appreciate if someone could clear up my confusion about firebase.
As far as I know, Here are the answers to your questions:
1) So what does this the client mean as in Server client libraries?
Server client libraries are used to access Firebase from servers which run on Java, Python, Go etc.
2) Which mode(test or locked) should I go with? Or I need more
configuration for this?
Test mode opens your database to the public which means any user can access your database without authenication.
Locked mode keeps your database locked down by default. You can then add rules to grant access to certain read or writes.
I would recommend to start out the project with this and later configure firestore security rules to open up access to your database according to your application's requirements. You can find references here : https://fireship.io/snippets/firestore-rules-recipes/
3) Is it true that whether I choose web SDKs or Server client libraries
to start my firestore project, I need to use firebase-admin? But do I
need to use Firebase CLI to init my project as a firebase project with
the automatically generated firebase.json?
firebase-admin available on npm is the Firebase Admin Node.js SDK to access your firebase database with admin privileges. This can be useful when you initialize/access the application specific configurations and parameters in your database.
You don't need Firebase command-line to initialize your firebase project and generate the firebase config file. You can access it through Firebase console of your project once you create your project in firebase. Reference : https://support.google.com/firebase/answer/7015592?hl=en
4) If I am writing React, should I go with web or node.js?
You should go with Web because node.js SDK is used for access to your Firebase services from privileged environments (such as servers or cloud) in Node.js.
Reference: https://www.npmjs.com/package/firebase
Additional Point: Found this for React in the Google's documentation for FIrebase SDKs. https://github.com/tylermcginnis/re-base
Hope its clearer now.
Our app is composed of several custom plugins. We would want our app to still work offline so our users will be able to navigate within the app even without internet connection.
The problem is when offline, we cannot switch to another plugin. It doesn't load and only displays the image below.
What's the best approach to this?
Assuming your app configuration has offline mode turned on
The builtin offline support is for the Datastore and ImageLib.
so if you use datastore to save your content then it should work in offline mode.
As for ImageLib as long as you use buildfire.imageLib.local that should support offline mode as well see docs here https://github.com/BuildFire/sdk/wiki/How-to-use-ImageLib
With the latest node SDK, I'm unable to programmatically create users as I had done with older versions of firebase. I need this in order to create a pre-populated database for testing purposes. The node SDK does not support createUserWithEmailAndPassword. Any idea how to programmatically create users or get the uids of users from the db or programmtically sign in as a user with the web client's signinWithEmailAndPassword?
Are you doing your testing with a live firebase instance? It might be better to use firebase-server to do this type of testing: https://firebase.googleblog.com/2015/04/end-to-end-testing-with-firebase-server_16.html
This should make your tests run faster and you won't be reliant on an internet connection.
Most of the client-side auth and user management methods (including creating users) are available in the Node.js environment since the 3.3.0 release of the Firebase JavaScript SDK. The SDK should now be mostly isomorphic, but see my message on another thread here for the full details. Full release notes for that release are here.
Using the Application Cache I can easily make my web application available offline and it works perfectly. The problem I am encountering is that I have recently started using a .htaccess file to rewrite urls from
http://www.example.com/?/page
to
http://www.example.com/page
After loading the 'homepage' in principal everything still works (as all pages are loaded through Ajax), but local bookmarks and the like do not work. Is there any way to add this functionality with a simple service worker, whilst still relying on the Application Cache for the rest of the offline functionality (thus allowing Firefox and Safari to fall back on the Application Cache, whilst Chrome and Opera would work perfectly offline).
Browsers that support service workers* use the presence of a service worker as a trigger to disable App Cache functionality for pages under the service worker's scope. See Is Service Worker intended to replace or coexist with Appcache?
I understand how using a service worker for something like rewriting URLs is independent from the offline use case, and therefore shouldn't interfere with App Cache, but there's no flag that you can use to say "Hey, this is a service worker that plays nicely with App Cache, so let me use both."
* This applies to Google Chrome. As other browsers add support for service workers, they might have different policies with regard to App Cache.