@edgedev/firebase 1.5.11 → 1.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,7 +32,8 @@ const config = {
32
32
  messagingSenderId: "your-messagingSenderId",
33
33
  appId: "your-appId"
34
34
  };
35
- const edgeFirebase = new EdgeFirebase(config);
35
+ const isPersistant = true // If "persistence" is true, login will be saved locally, they can close their browser and when they open they will be logged in automatically. If "persistence" is false login saved only for the session.
36
+ const edgeFirebase = new EdgeFirebase(config, isPersistant);
36
37
  export { edgeFirebase };
37
38
  ```
38
39
 
@@ -50,6 +51,7 @@ import App from "./App.vue";
50
51
 
51
52
  //edgeFirebase Plugin
52
53
  import eFb from "@edgedev/firebase";
54
+ const isPersistant = true // If "persistence" is true, login will be saved locally, they can close their browser and when they open they will be logged in automatically. If "persistence" is false login saved only for the session.
53
55
  app.use(eFb, {
54
56
  apiKey: "your-apiKey",
55
57
  authDomain: "your-authDomain",
@@ -57,7 +59,7 @@ app.use(eFb, {
57
59
  storageBucket: "your-storageBucket",
58
60
  messagingSenderId: "your-messagingSenderId",
59
61
  appId: "your-appId"
60
- })
62
+ }, isPersistant)
61
63
  //end edgeFirebase
62
64
 
63
65
  app.mount("#app");
@@ -69,6 +71,7 @@ Add a file (whatever.client.ts) to your "plugins" folder with the following code
69
71
  ***-Note the ".client" in the file name. If the file doesn't have that in the name you must disabled SSR in the nuxt config.***
70
72
  ```javascript
71
73
  import eFb from "@edgedev/firebase";
74
+ const isPersistant = true // If "persistence" is true, login will be saved locally, they can close their browser and when they open they will be logged in automatically. If "persistence" is false login saved only for the session.
72
75
  export default defineNuxtPlugin((nuxtApp) => {
73
76
  nuxtApp.vueApp.use(eFb, {
74
77
  apiKey: "your-apiKey",
@@ -77,7 +80,7 @@ export default defineNuxtPlugin((nuxtApp) => {
77
80
  storageBucket: "your-storageBucket",
78
81
  messagingSenderId: "your-messagingSenderId",
79
82
  appId: "your-appId"
80
- });
83
+ }, isPersistant);
81
84
  });
82
85
  ```
83
86
  ***-Alternatively you can disable SSR for your entire Nuxt project instead of naming the plugin with ".client", update the nuxt.config.ts file:***
@@ -318,14 +321,12 @@ interface permissions {
318
321
 
319
322
  (currently only sign in with email and password is supported)
320
323
 
321
- If "persistence" is true, login will be saved locally, they can close their browser and when they open they will be logged in automatically. If "persistence" is false login saved only for the session.
322
324
  ```javascript
323
325
  edgeFirebase.logIn(
324
326
  {
325
327
  email: "devs@edgemarketing.com",
326
328
  password: "pasword"
327
- },
328
- true // : persistence
329
+ }
329
330
  );
330
331
  ```
331
332
 
package/edgeFirebase.ts CHANGED
@@ -26,7 +26,6 @@ import {
26
26
 
27
27
  import {
28
28
  initializeAuth,
29
- setPersistence,
30
29
  browserSessionPersistence,
31
30
  browserLocalPersistence,
32
31
  Persistence,
@@ -165,11 +164,16 @@ export const EdgeFirebase = class {
165
164
  storageBucket: "",
166
165
  messagingSenderId: "",
167
166
  appId: ""
168
- }
167
+ },
168
+ isPersistant: false
169
169
  ) {
170
170
  this.firebaseConfig = firebaseConfig;
171
171
  this.app = initializeApp(this.firebaseConfig);
172
- this.auth = initializeAuth(this.app);
172
+ let persistence: Persistence = browserSessionPersistence;
173
+ if (isPersistant) {
174
+ persistence = browserLocalPersistence;
175
+ }
176
+ this.auth = initializeAuth(this.app, { persistence });
173
177
  this.db = getFirestore(this.app);
174
178
  this.setOnAuthStateChanged();
175
179
  }
@@ -688,39 +692,24 @@ export const EdgeFirebase = class {
688
692
  };
689
693
 
690
694
  // Composable to login and set persistence
691
- public logIn = (credentials: Credentials, isPersistant = false): void => {
695
+ public logIn = (credentials: Credentials): void => {
692
696
  this.logOut();
693
- let persistence: Persistence = browserSessionPersistence;
694
- if (isPersistant) {
695
- persistence = browserLocalPersistence;
696
- }
697
- setPersistence(this.auth, persistence)
698
- .then(() => {
699
- signInWithEmailAndPassword(
700
- this.auth,
701
- credentials.email,
702
- credentials.password
703
- )
704
- .then(() => {
705
- // do nothing
706
- })
707
- .catch((error) => {
708
- this.user.email = "";
709
- this.user.uid = null;
710
-
711
- this.user.loggedIn = false;
712
- this.user.logInError = true;
713
- this.user.logInErrorMessage = error.code + ": " + error.message;
714
- });
715
- })
716
- .catch((error) => {
717
- this.user.email = "";
718
- this.user.uid = null;
719
-
720
- this.user.loggedIn = false;
721
- this.user.logInError = true;
722
- this.user.logInErrorMessage = error.code + ": " + error.message;
723
- });
697
+ signInWithEmailAndPassword(
698
+ this.auth,
699
+ credentials.email,
700
+ credentials.password
701
+ )
702
+ .then(() => {
703
+ // do nothing
704
+ })
705
+ .catch((error) => {
706
+ this.user.email = "";
707
+ this.user.uid = null;
708
+
709
+ this.user.loggedIn = false;
710
+ this.user.logInError = true;
711
+ this.user.logInErrorMessage = error.code + ": " + error.message;
712
+ });
724
713
  };
725
714
 
726
715
  // Keeping this for reference on how to Type a Ref.
package/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { EdgeFirebase } from "./edgeFirebase";
2
2
  export default {
3
- install: (app, options) => {
4
- const eFb = new EdgeFirebase(options);
3
+ install: (app, options, isPersistant) => {
4
+ const eFb = new EdgeFirebase(options, isPersistant);
5
5
  app.provide("edgeFirebase", eFb);
6
6
  }
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgedev/firebase",
3
- "version": "1.5.11",
3
+ "version": "1.5.13",
4
4
  "description": "Vue 3 / Nuxt 3 Plugin or Nuxt 3 global composable for firebase authentication and firestore.",
5
5
  "main": "index.ts",
6
6
  "scripts": {