edmaxlabs-core 2.6.9 → 2.7.2
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/dist/index.cjs +64 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +64 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -119,7 +119,7 @@ var _Authentication = class _Authentication {
|
|
|
119
119
|
this.eUser = void 0;
|
|
120
120
|
this.saveCredentials(null);
|
|
121
121
|
const app = this.app?.getDatabase;
|
|
122
|
-
const data = await app?.collection("
|
|
122
|
+
const data = await app?.collection("authentication").query.where({
|
|
123
123
|
key: "email",
|
|
124
124
|
op: "===",
|
|
125
125
|
value: email
|
|
@@ -127,7 +127,7 @@ var _Authentication = class _Authentication {
|
|
|
127
127
|
if (data.length > 0) {
|
|
128
128
|
throw new Error("Email Already In Use.");
|
|
129
129
|
}
|
|
130
|
-
const userRef = await app?.collection("
|
|
130
|
+
const userRef = await app?.collection("authentication").add({
|
|
131
131
|
email,
|
|
132
132
|
password,
|
|
133
133
|
logged: true,
|
|
@@ -153,7 +153,7 @@ var _Authentication = class _Authentication {
|
|
|
153
153
|
password
|
|
154
154
|
}) => {
|
|
155
155
|
const app = this.app?.getDatabase;
|
|
156
|
-
const data = await app?.collection("
|
|
156
|
+
const data = await app?.collection("authentication").query.where({
|
|
157
157
|
key: "email",
|
|
158
158
|
op: "===",
|
|
159
159
|
value: email
|
|
@@ -162,6 +162,7 @@ var _Authentication = class _Authentication {
|
|
|
162
162
|
op: "===",
|
|
163
163
|
value: password
|
|
164
164
|
}).get();
|
|
165
|
+
console.log("Auth Data:", data);
|
|
165
166
|
if (data === void 0) {
|
|
166
167
|
throw new Error("Auth Failed.");
|
|
167
168
|
}
|
|
@@ -169,7 +170,7 @@ var _Authentication = class _Authentication {
|
|
|
169
170
|
throw new Error("User Not Found.");
|
|
170
171
|
}
|
|
171
172
|
const _data = data[0];
|
|
172
|
-
await app?.collection("
|
|
173
|
+
await app?.collection("authentication").doc(_data.id).update({
|
|
173
174
|
logged: true,
|
|
174
175
|
lastLogged: Date.now()
|
|
175
176
|
});
|
|
@@ -182,7 +183,7 @@ var _Authentication = class _Authentication {
|
|
|
182
183
|
throw new Error("No User Signed in");
|
|
183
184
|
}
|
|
184
185
|
const app = this.app?.getDatabase;
|
|
185
|
-
const userRef = await app?.collection("
|
|
186
|
+
const userRef = await app?.collection("authentication").doc(this.eUser.uid).delete();
|
|
186
187
|
if (userRef) {
|
|
187
188
|
throw new Error("Something went wrong try Again.");
|
|
188
189
|
}
|
|
@@ -195,7 +196,7 @@ var _Authentication = class _Authentication {
|
|
|
195
196
|
this.eUser = void 0;
|
|
196
197
|
this.saveCredentials(null);
|
|
197
198
|
if (luid)
|
|
198
|
-
await app?.collection("
|
|
199
|
+
await app?.collection("authentication").doc(luid?.uid).update({
|
|
199
200
|
logged: false,
|
|
200
201
|
lastLogged: Date.now()
|
|
201
202
|
});
|
|
@@ -235,7 +236,7 @@ var _Authentication = class _Authentication {
|
|
|
235
236
|
this.client = EdmaxLabs.instance;
|
|
236
237
|
this.app = new EdmaxLabs({
|
|
237
238
|
token: "auth",
|
|
238
|
-
project: "
|
|
239
|
+
project: "698457c2f7448550b9e166c4"
|
|
239
240
|
});
|
|
240
241
|
_Authentication.instance = this;
|
|
241
242
|
this.restoreSession();
|
|
@@ -309,7 +310,7 @@ var _Authentication = class _Authentication {
|
|
|
309
310
|
onSignOut?.();
|
|
310
311
|
return;
|
|
311
312
|
}
|
|
312
|
-
const userRef = this.app?.getDatabase.collection("
|
|
313
|
+
const userRef = this.app?.getDatabase.collection("authentication").doc(creds.uid);
|
|
313
314
|
if (!userRef)
|
|
314
315
|
return;
|
|
315
316
|
userDocUnsubscribe = userRef.onSnapshot(
|
|
@@ -428,7 +429,8 @@ var DocumentRef = class {
|
|
|
428
429
|
endpoint: `${this.app.getBaseUrl()}/db/update`,
|
|
429
430
|
headers: {
|
|
430
431
|
authorization: this.app.getConfig().token,
|
|
431
|
-
"x-project": this.app.getConfig().project
|
|
432
|
+
"x-project": this.app.getConfig().project,
|
|
433
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
432
434
|
},
|
|
433
435
|
body: { collection: this.collection, id: this.id, data }
|
|
434
436
|
}).sendRequest();
|
|
@@ -474,7 +476,8 @@ var DocumentRef = class {
|
|
|
474
476
|
endpoint: `${this.app.getBaseUrl()}/db/create`,
|
|
475
477
|
headers: {
|
|
476
478
|
authorization: this.app.getConfig().token,
|
|
477
|
-
"x-project": this.app.getConfig().project
|
|
479
|
+
"x-project": this.app.getConfig().project,
|
|
480
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
478
481
|
},
|
|
479
482
|
body: { collection: this.collection, data: { ...data, id: this.id } }
|
|
480
483
|
}).sendRequest();
|
|
@@ -530,7 +533,8 @@ var DocumentRef = class {
|
|
|
530
533
|
endpoint: `${this.app.getBaseUrl()}/db/delete`,
|
|
531
534
|
headers: {
|
|
532
535
|
authorization: this.app.getConfig().token,
|
|
533
|
-
"x-project": this.app.getConfig().project
|
|
536
|
+
"x-project": this.app.getConfig().project,
|
|
537
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
534
538
|
},
|
|
535
539
|
body: { collection: this.collection, id: this.id }
|
|
536
540
|
}).sendRequest();
|
|
@@ -563,7 +567,8 @@ var DocumentRef = class {
|
|
|
563
567
|
endpoint: `${this.app.getBaseUrl()}/db/read`,
|
|
564
568
|
headers: {
|
|
565
569
|
authorization: this.app.getConfig().token,
|
|
566
|
-
"x-project": this.app.getConfig().project
|
|
570
|
+
"x-project": this.app.getConfig().project,
|
|
571
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
567
572
|
},
|
|
568
573
|
body: {
|
|
569
574
|
collection: this.collection,
|
|
@@ -701,7 +706,7 @@ var Query = class {
|
|
|
701
706
|
return new HttpsRequest({
|
|
702
707
|
method: "POST" /* POST */,
|
|
703
708
|
endpoint: `${this.app.getBaseUrl()}/db/update`,
|
|
704
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
709
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
705
710
|
body: {
|
|
706
711
|
collection: this.collection,
|
|
707
712
|
filter: genfilter,
|
|
@@ -841,7 +846,11 @@ var Query = class {
|
|
|
841
846
|
const res = await new HttpsRequest({
|
|
842
847
|
method: "POST" /* POST */,
|
|
843
848
|
endpoint: `${this.app.getBaseUrl()}/db/read`,
|
|
844
|
-
headers: {
|
|
849
|
+
headers: {
|
|
850
|
+
authorization: this.app.getConfig().token,
|
|
851
|
+
"x-project": this.app.getConfig().project,
|
|
852
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
853
|
+
},
|
|
845
854
|
body: {
|
|
846
855
|
collection: this.collection,
|
|
847
856
|
filter: genfilter
|
|
@@ -944,6 +953,7 @@ var socketURI = "https://api.edmaxlabs.com";
|
|
|
944
953
|
var CollectionRef = class {
|
|
945
954
|
constructor(app, collection) {
|
|
946
955
|
this.app = app;
|
|
956
|
+
this.authentication = app.getAuthentication;
|
|
947
957
|
this.collection = collection;
|
|
948
958
|
this.persistence = app.offline().persistence;
|
|
949
959
|
this.syncEngine = app.offline().syncEngine;
|
|
@@ -996,9 +1006,13 @@ var CollectionRef = class {
|
|
|
996
1006
|
endpoint: `${this.app.getBaseUrl()}/db/create`,
|
|
997
1007
|
headers: {
|
|
998
1008
|
authorization: this.app.getConfig().token,
|
|
999
|
-
"x-project": this.app.getConfig().project
|
|
1009
|
+
"x-project": this.app.getConfig().project,
|
|
1010
|
+
user: JSON.stringify(this.authentication.currentUser()?.toMap())
|
|
1000
1011
|
},
|
|
1001
|
-
body: {
|
|
1012
|
+
body: {
|
|
1013
|
+
collection: this.collection,
|
|
1014
|
+
data: { ...data, id: "" }
|
|
1015
|
+
}
|
|
1002
1016
|
}).sendRequest();
|
|
1003
1017
|
if (!res?.success || !res.document)
|
|
1004
1018
|
return null;
|
|
@@ -1053,7 +1067,9 @@ var CollectionRef = class {
|
|
|
1053
1067
|
endpoint: `${serverURI}/db/read`,
|
|
1054
1068
|
headers: {
|
|
1055
1069
|
authorization: this.app.getConfig().token,
|
|
1056
|
-
"x-project": this.app.getConfig().project
|
|
1070
|
+
"x-project": this.app.getConfig().project,
|
|
1071
|
+
user: JSON.stringify(this.authentication.currentUser()?.toMap()),
|
|
1072
|
+
"x-user": JSON.stringify(this.authentication.currentUser()?.toMap())
|
|
1057
1073
|
},
|
|
1058
1074
|
body: {
|
|
1059
1075
|
collection: this.collection,
|
|
@@ -1088,7 +1104,9 @@ var CollectionRef = class {
|
|
|
1088
1104
|
endpoint: `${serverURI}/db/read`,
|
|
1089
1105
|
headers: {
|
|
1090
1106
|
authorization: this.app.getConfig().token,
|
|
1091
|
-
"x-project": this.app.getConfig().project
|
|
1107
|
+
"x-project": this.app.getConfig().project,
|
|
1108
|
+
user: JSON.stringify(this.authentication.currentUser()?.toMap()),
|
|
1109
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
1092
1110
|
},
|
|
1093
1111
|
body: {
|
|
1094
1112
|
collection: this.collection,
|
|
@@ -1260,7 +1278,11 @@ var Batch = class {
|
|
|
1260
1278
|
const res = await new HttpsRequest({
|
|
1261
1279
|
method: "POST" /* POST */,
|
|
1262
1280
|
endpoint: `${serverURI}/db/batch`,
|
|
1263
|
-
headers: {
|
|
1281
|
+
headers: {
|
|
1282
|
+
authorization: this.app.getConfig().token,
|
|
1283
|
+
"x-project": this.app.getConfig().project,
|
|
1284
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
1285
|
+
},
|
|
1264
1286
|
body: { ops: this.ops }
|
|
1265
1287
|
}).sendRequest();
|
|
1266
1288
|
if (res?.error) {
|
|
@@ -1374,7 +1396,13 @@ var Realtime = class {
|
|
|
1374
1396
|
}
|
|
1375
1397
|
this.socket = io(this.app.getSocketUrl(), {
|
|
1376
1398
|
transports: ["websocket"],
|
|
1377
|
-
auth: {
|
|
1399
|
+
auth: {
|
|
1400
|
+
token: this.app.getConfig().token,
|
|
1401
|
+
"x-project": this.app.getConfig().project,
|
|
1402
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()),
|
|
1403
|
+
user: this.app.getAuthentication.currentUser()
|
|
1404
|
+
// Pass user info for personalized permissions
|
|
1405
|
+
},
|
|
1378
1406
|
autoConnect: true,
|
|
1379
1407
|
reconnection: true,
|
|
1380
1408
|
reconnectionAttempts: Infinity,
|
|
@@ -1511,7 +1539,7 @@ var Functions = class {
|
|
|
1511
1539
|
const res = await new HttpsRequest({
|
|
1512
1540
|
method: "POST" /* POST */,
|
|
1513
1541
|
endpoint: serverURI + "/functions/call/" + functionName,
|
|
1514
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
1542
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, "user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()), "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
1515
1543
|
body: data
|
|
1516
1544
|
}).sendRequest();
|
|
1517
1545
|
return res;
|
|
@@ -2476,7 +2504,7 @@ var SyncEngine = class {
|
|
|
2476
2504
|
const res = await new HttpsRequest({
|
|
2477
2505
|
method: "POST" /* POST */,
|
|
2478
2506
|
endpoint: `${this.app.getBaseUrl()}/db/create`,
|
|
2479
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
2507
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, user: JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()), "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
2480
2508
|
body: {
|
|
2481
2509
|
collection: mutation.collection,
|
|
2482
2510
|
data: mutation.payload
|
|
@@ -2502,7 +2530,12 @@ var SyncEngine = class {
|
|
|
2502
2530
|
const res = await new HttpsRequest({
|
|
2503
2531
|
method: "POST" /* POST */,
|
|
2504
2532
|
endpoint: `${this.app.getBaseUrl()}/db/update`,
|
|
2505
|
-
headers: {
|
|
2533
|
+
headers: {
|
|
2534
|
+
authorization: this.app.getConfig().token,
|
|
2535
|
+
"x-project": this.app.getConfig().project,
|
|
2536
|
+
user: JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()),
|
|
2537
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
2538
|
+
},
|
|
2506
2539
|
body: {
|
|
2507
2540
|
collection: mutation.collection,
|
|
2508
2541
|
document: mutation.documentId,
|
|
@@ -2534,7 +2567,12 @@ var SyncEngine = class {
|
|
|
2534
2567
|
const res = await new HttpsRequest({
|
|
2535
2568
|
method: "POST" /* POST */,
|
|
2536
2569
|
endpoint: `${this.app.getBaseUrl()}/db/delete`,
|
|
2537
|
-
headers: {
|
|
2570
|
+
headers: {
|
|
2571
|
+
authorization: this.app.getConfig().token,
|
|
2572
|
+
"x-project": this.app.getConfig().project,
|
|
2573
|
+
user: JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()),
|
|
2574
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
2575
|
+
},
|
|
2538
2576
|
body: {
|
|
2539
2577
|
collection: mutation.collection,
|
|
2540
2578
|
document: mutation.documentId
|
|
@@ -2675,11 +2713,10 @@ var StorageRef = class {
|
|
|
2675
2713
|
if (!srcFile) {
|
|
2676
2714
|
throw new Error("Invalid File");
|
|
2677
2715
|
}
|
|
2678
|
-
console.log("SRCF");
|
|
2679
2716
|
const res = await new HttpsRequest({
|
|
2680
2717
|
method: "POST" /* POST */,
|
|
2681
2718
|
endpoint: serverURI + "/storage/file/upload",
|
|
2682
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
2719
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()), "user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
2683
2720
|
file: srcFile,
|
|
2684
2721
|
isMultipart: true
|
|
2685
2722
|
}).sendRequest();
|
|
@@ -2696,7 +2733,7 @@ var StorageRef = class {
|
|
|
2696
2733
|
const res = await new HttpsRequest({
|
|
2697
2734
|
method: "POST" /* POST */,
|
|
2698
2735
|
endpoint: serverURI + "/storage/file/delete",
|
|
2699
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
2736
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()), "user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
2700
2737
|
body: {
|
|
2701
2738
|
file_id: id
|
|
2702
2739
|
}
|