@edgedev/firebase 1.0.18 → 1.0.20

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.
Files changed (2) hide show
  1. package/index.ts +19 -2
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -15,6 +15,8 @@ import {
15
15
  where
16
16
  } from "firebase/firestore";
17
17
 
18
+ import { getAuth, signInWithEmailAndPassword } from "firebase/auth";
19
+
18
20
  const firebaseConfig = {
19
21
  apiKey: import.meta.env.VITE_FIREBASE_API_KEY as string,
20
22
  authDomain: import.meta.env.VITE_FIREBASE_AUTH_DOMAIN as string,
@@ -29,10 +31,21 @@ const firebaseConfig = {
29
31
  const app = initializeApp(firebaseConfig);
30
32
  const db = getFirestore(app);
31
33
 
34
+ export const signIn = async (credentials: Credentials): Promise<object> => {
35
+ const auth = getAuth(app);
36
+ const user = await signInWithEmailAndPassword(
37
+ auth,
38
+ credentials.email,
39
+ credentials.password
40
+ );
41
+ console.log(user);
42
+ return user;
43
+ };
44
+
32
45
  // Simple Store Items (add matching key per firebase collection)
33
46
  export const data: CollectionDataObject = reactive({});
34
47
  export const unsubscibe: CollectionUnsubscribeObject = reactive({});
35
- export const user: UserDataObject = reactive({ uid: null, email: "" });
48
+ export const user = ref<UserDataObject>({ uid: "", email: "" });
36
49
 
37
50
  // Composable to start snapshot listener and set unsubscribe function
38
51
  export const startSnapshot = (
@@ -62,7 +75,7 @@ export const storeDoc = (collectionPath: string, item: object): void => {
62
75
  const cloneItem = JSON.parse(JSON.stringify(item));
63
76
  const current_time = new Date().getTime();
64
77
  cloneItem.last_updated = current_time;
65
- cloneItem.uid = user.uid;
78
+ cloneItem.uid = user["uid"];
66
79
  if (!Object.prototype.hasOwnProperty.call(cloneItem, "doc_created_at")) {
67
80
  cloneItem.doc_created_at = current_time;
68
81
  }
@@ -90,6 +103,10 @@ export const stopSnapshot = (collectionPath: string): void => {
90
103
  }
91
104
  };
92
105
 
106
+ interface Credentials {
107
+ email: string;
108
+ password: string;
109
+ }
93
110
  interface FirestoreQuery {
94
111
  field: string;
95
112
  operator: WhereFilterOp; // '==' | '<' | '<=' | '>' | '>=' | 'array-contains' | 'in' | 'array-contains-any';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgedev/firebase",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "Composables and stores for firebase",
5
5
  "main": "index.ts",
6
6
  "author": "Seth Fischer",