programmatically create users in firebase node - node.js

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.

Related

Using Azure SDK for JS to create .NET 4.x App Service

I'm starting to wonder whether this is the right tool for the job, still here goes.
I'm attempting to automate the creation of our Azure Test environment using Azure SDK for JS. The environment spans many services (as you can imagine), including Classic ASP.NET app services.
Node is my safe space, so that is why I started with the JS SDK.
I have started scripting the creation of an app service using WebSiteManagementClient.webApps.createOrUpdate. I'm confused though, there is seemingly no way to configure any of the following:
Which app service plan the app service should be connected to. This feels fundamental.
The operating system, Windows or Linux.
The stack version, .NET 4.8, .NET Core, or whatever.
Is it possible to configure the above using the JS SDK, or am I going to have find another approach?
Update 23/03/21
Untested, but these are my findings so far:
App Service Plan - The plan is set using the serverFarmId property of the Site interface.
Operating system - Assuming Windows as the default, if you want a Linux app service, you change the kind property of Site from app, to app,linux.
Stack & version - In the SiteConfig interface, you have linuxFxVersion and windowsFxVersion. Again, I think the assumption is 'latest .NET' (e.g. .NET 4.8). For .NET Core 3.1, the setting looks to be DOTNETCORE|3.1.
It can be achieved using js SDK. I checked the source code and it is ok. But I don't recommend to use js sdk to do this.
Because you need to call the SDK, there are many internal logics that you need to code. This will waste a lot of your time. So I recommend you to use restapi.
The restapi method name is similar to the naming in the SDK, mainly because you can test api interfaces online to achieve the functions you want. So you can selectively choose the method you want to achieve the function you want.
Official doc
Web Apps - Create Or Update
As for your concerns, you only need to write all the configuration in json format and put it in the request body.
Tips:
First use the online interface, encode the json format, create a webapp according to your needs, and then integrate it into your code.

confusions about firebase / cloud firestore

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.

Update user properties in Active Directory using NodeJS

I am tring to make CRUD operations on Active Directory via nodejs.
The only package that handle CRUD operation in node that i have found is ad-
https://www.npmjs.com/package/ad.
Are you familiar with other packages?
Is this the only one for update operations?
It seems that integration with Active Directory in nodejs is not popular and mature. Am I wrong? should I implement such integration in Java or .Net core?
Thanks!
The right way is the way that works :) If you are already using NodeJS, then do it in NodeJS if at all possible.
Communication with AD would happen through LDAP, so you can look for NodeJS packages for LDAP. Here are a couple I found:
ldapjs
ldap-client
But that one you linked to is more specific to AD (and AD does have its own flavor of LDAP) so I would choose that as long as it works for you.
If it doesn't work for whatever reason, either ask a new question here to get specific help, or you can start looking into making a separate Java or .NET app to do it. But I wouldn't consider a separate app just for AD queries unless you absolutely couldn't do it in NodeJS.

Is it possible to update node-weblit based application without new installation?

I'm plan to release my web application under node-webkit platform and allow users to install it on their local machine. But before, I need to understand how will I update this application?
I see the following two approaches:
Download a new version of new application and replace older one
Autoupdate node-webkit application like Google Chrome does (so users don't need to do anything except rebooting application).
I'm very interested how should I do the second approach? Could you share your experience with maintaining of your node-webkit based applications?
Thanks!

CRUD files on local (sandboxed) filesystem with chrome-extensions

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

Resources