edmaxlabs-core 2.6.8 → 2.7.1
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 +71 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.mjs +71 -20
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -194,6 +194,7 @@ var _Authentication = class _Authentication {
|
|
|
194
194
|
op: "===",
|
|
195
195
|
value: password
|
|
196
196
|
}).get();
|
|
197
|
+
console.log("Auth Data:", data);
|
|
197
198
|
if (data === void 0) {
|
|
198
199
|
throw new Error("Auth Failed.");
|
|
199
200
|
}
|
|
@@ -233,6 +234,20 @@ var _Authentication = class _Authentication {
|
|
|
233
234
|
});
|
|
234
235
|
return;
|
|
235
236
|
};
|
|
237
|
+
this.resetPassword = async () => {
|
|
238
|
+
const app = this.app?.getDatabase;
|
|
239
|
+
const luid = this.currentUser();
|
|
240
|
+
const payload = {
|
|
241
|
+
uid: luid?.uid,
|
|
242
|
+
ttl: 3
|
|
243
|
+
//minutes
|
|
244
|
+
};
|
|
245
|
+
const id = await app?.collection("_auth_tokens").add(payload);
|
|
246
|
+
if (id) {
|
|
247
|
+
return `https://auth.edmaxlabs.com/reset/${id}`;
|
|
248
|
+
}
|
|
249
|
+
throw new Error("Failed to request reset tokens. Try Again");
|
|
250
|
+
};
|
|
236
251
|
this.rules = async (path, context) => {
|
|
237
252
|
const res = await new HttpsRequest({
|
|
238
253
|
method: "POST" /* POST */,
|
|
@@ -253,7 +268,7 @@ var _Authentication = class _Authentication {
|
|
|
253
268
|
this.client = EdmaxLabs.instance;
|
|
254
269
|
this.app = new EdmaxLabs({
|
|
255
270
|
token: "auth",
|
|
256
|
-
project: "
|
|
271
|
+
project: "698457c2f7448550b9e166c4"
|
|
257
272
|
});
|
|
258
273
|
_Authentication.instance = this;
|
|
259
274
|
this.restoreSession();
|
|
@@ -446,7 +461,8 @@ var DocumentRef = class {
|
|
|
446
461
|
endpoint: `${this.app.getBaseUrl()}/db/update`,
|
|
447
462
|
headers: {
|
|
448
463
|
authorization: this.app.getConfig().token,
|
|
449
|
-
"x-project": this.app.getConfig().project
|
|
464
|
+
"x-project": this.app.getConfig().project,
|
|
465
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
450
466
|
},
|
|
451
467
|
body: { collection: this.collection, id: this.id, data }
|
|
452
468
|
}).sendRequest();
|
|
@@ -492,7 +508,8 @@ var DocumentRef = class {
|
|
|
492
508
|
endpoint: `${this.app.getBaseUrl()}/db/create`,
|
|
493
509
|
headers: {
|
|
494
510
|
authorization: this.app.getConfig().token,
|
|
495
|
-
"x-project": this.app.getConfig().project
|
|
511
|
+
"x-project": this.app.getConfig().project,
|
|
512
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
496
513
|
},
|
|
497
514
|
body: { collection: this.collection, data: { ...data, id: this.id } }
|
|
498
515
|
}).sendRequest();
|
|
@@ -548,7 +565,8 @@ var DocumentRef = class {
|
|
|
548
565
|
endpoint: `${this.app.getBaseUrl()}/db/delete`,
|
|
549
566
|
headers: {
|
|
550
567
|
authorization: this.app.getConfig().token,
|
|
551
|
-
"x-project": this.app.getConfig().project
|
|
568
|
+
"x-project": this.app.getConfig().project,
|
|
569
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
552
570
|
},
|
|
553
571
|
body: { collection: this.collection, id: this.id }
|
|
554
572
|
}).sendRequest();
|
|
@@ -581,7 +599,8 @@ var DocumentRef = class {
|
|
|
581
599
|
endpoint: `${this.app.getBaseUrl()}/db/read`,
|
|
582
600
|
headers: {
|
|
583
601
|
authorization: this.app.getConfig().token,
|
|
584
|
-
"x-project": this.app.getConfig().project
|
|
602
|
+
"x-project": this.app.getConfig().project,
|
|
603
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
585
604
|
},
|
|
586
605
|
body: {
|
|
587
606
|
collection: this.collection,
|
|
@@ -719,7 +738,7 @@ var Query = class {
|
|
|
719
738
|
return new HttpsRequest({
|
|
720
739
|
method: "POST" /* POST */,
|
|
721
740
|
endpoint: `${this.app.getBaseUrl()}/db/update`,
|
|
722
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
741
|
+
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project, "x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()) },
|
|
723
742
|
body: {
|
|
724
743
|
collection: this.collection,
|
|
725
744
|
filter: genfilter,
|
|
@@ -859,7 +878,11 @@ var Query = class {
|
|
|
859
878
|
const res = await new HttpsRequest({
|
|
860
879
|
method: "POST" /* POST */,
|
|
861
880
|
endpoint: `${this.app.getBaseUrl()}/db/read`,
|
|
862
|
-
headers: {
|
|
881
|
+
headers: {
|
|
882
|
+
authorization: this.app.getConfig().token,
|
|
883
|
+
"x-project": this.app.getConfig().project,
|
|
884
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
885
|
+
},
|
|
863
886
|
body: {
|
|
864
887
|
collection: this.collection,
|
|
865
888
|
filter: genfilter
|
|
@@ -962,6 +985,7 @@ var socketURI = "https://api.edmaxlabs.com";
|
|
|
962
985
|
var CollectionRef = class {
|
|
963
986
|
constructor(app, collection) {
|
|
964
987
|
this.app = app;
|
|
988
|
+
this.authentication = app.getAuthentication;
|
|
965
989
|
this.collection = collection;
|
|
966
990
|
this.persistence = app.offline().persistence;
|
|
967
991
|
this.syncEngine = app.offline().syncEngine;
|
|
@@ -1014,9 +1038,13 @@ var CollectionRef = class {
|
|
|
1014
1038
|
endpoint: `${this.app.getBaseUrl()}/db/create`,
|
|
1015
1039
|
headers: {
|
|
1016
1040
|
authorization: this.app.getConfig().token,
|
|
1017
|
-
"x-project": this.app.getConfig().project
|
|
1041
|
+
"x-project": this.app.getConfig().project,
|
|
1042
|
+
user: JSON.stringify(this.authentication.currentUser()?.toMap())
|
|
1018
1043
|
},
|
|
1019
|
-
body: {
|
|
1044
|
+
body: {
|
|
1045
|
+
collection: this.collection,
|
|
1046
|
+
data: { ...data, id: "" }
|
|
1047
|
+
}
|
|
1020
1048
|
}).sendRequest();
|
|
1021
1049
|
if (!res?.success || !res.document)
|
|
1022
1050
|
return null;
|
|
@@ -1071,7 +1099,9 @@ var CollectionRef = class {
|
|
|
1071
1099
|
endpoint: `${serverURI}/db/read`,
|
|
1072
1100
|
headers: {
|
|
1073
1101
|
authorization: this.app.getConfig().token,
|
|
1074
|
-
"x-project": this.app.getConfig().project
|
|
1102
|
+
"x-project": this.app.getConfig().project,
|
|
1103
|
+
user: JSON.stringify(this.authentication.currentUser()?.toMap()),
|
|
1104
|
+
"x-user": JSON.stringify(this.authentication.currentUser()?.toMap())
|
|
1075
1105
|
},
|
|
1076
1106
|
body: {
|
|
1077
1107
|
collection: this.collection,
|
|
@@ -1106,7 +1136,9 @@ var CollectionRef = class {
|
|
|
1106
1136
|
endpoint: `${serverURI}/db/read`,
|
|
1107
1137
|
headers: {
|
|
1108
1138
|
authorization: this.app.getConfig().token,
|
|
1109
|
-
"x-project": this.app.getConfig().project
|
|
1139
|
+
"x-project": this.app.getConfig().project,
|
|
1140
|
+
user: JSON.stringify(this.authentication.currentUser()?.toMap()),
|
|
1141
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
1110
1142
|
},
|
|
1111
1143
|
body: {
|
|
1112
1144
|
collection: this.collection,
|
|
@@ -1278,7 +1310,11 @@ var Batch = class {
|
|
|
1278
1310
|
const res = await new HttpsRequest({
|
|
1279
1311
|
method: "POST" /* POST */,
|
|
1280
1312
|
endpoint: `${serverURI}/db/batch`,
|
|
1281
|
-
headers: {
|
|
1313
|
+
headers: {
|
|
1314
|
+
authorization: this.app.getConfig().token,
|
|
1315
|
+
"x-project": this.app.getConfig().project,
|
|
1316
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
1317
|
+
},
|
|
1282
1318
|
body: { ops: this.ops }
|
|
1283
1319
|
}).sendRequest();
|
|
1284
1320
|
if (res?.error) {
|
|
@@ -1392,7 +1428,13 @@ var Realtime = class {
|
|
|
1392
1428
|
}
|
|
1393
1429
|
this.socket = (0, import_socket.io)(this.app.getSocketUrl(), {
|
|
1394
1430
|
transports: ["websocket"],
|
|
1395
|
-
auth: {
|
|
1431
|
+
auth: {
|
|
1432
|
+
token: this.app.getConfig().token,
|
|
1433
|
+
"x-project": this.app.getConfig().project,
|
|
1434
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()),
|
|
1435
|
+
user: this.app.getAuthentication.currentUser()
|
|
1436
|
+
// Pass user info for personalized permissions
|
|
1437
|
+
},
|
|
1396
1438
|
autoConnect: true,
|
|
1397
1439
|
reconnection: true,
|
|
1398
1440
|
reconnectionAttempts: Infinity,
|
|
@@ -1529,7 +1571,7 @@ var Functions = class {
|
|
|
1529
1571
|
const res = await new HttpsRequest({
|
|
1530
1572
|
method: "POST" /* POST */,
|
|
1531
1573
|
endpoint: serverURI + "/functions/call/" + functionName,
|
|
1532
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
1574
|
+
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()) },
|
|
1533
1575
|
body: data
|
|
1534
1576
|
}).sendRequest();
|
|
1535
1577
|
return res;
|
|
@@ -2494,7 +2536,7 @@ var SyncEngine = class {
|
|
|
2494
2536
|
const res = await new HttpsRequest({
|
|
2495
2537
|
method: "POST" /* POST */,
|
|
2496
2538
|
endpoint: `${this.app.getBaseUrl()}/db/create`,
|
|
2497
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
2539
|
+
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()) },
|
|
2498
2540
|
body: {
|
|
2499
2541
|
collection: mutation.collection,
|
|
2500
2542
|
data: mutation.payload
|
|
@@ -2520,7 +2562,12 @@ var SyncEngine = class {
|
|
|
2520
2562
|
const res = await new HttpsRequest({
|
|
2521
2563
|
method: "POST" /* POST */,
|
|
2522
2564
|
endpoint: `${this.app.getBaseUrl()}/db/update`,
|
|
2523
|
-
headers: {
|
|
2565
|
+
headers: {
|
|
2566
|
+
authorization: this.app.getConfig().token,
|
|
2567
|
+
"x-project": this.app.getConfig().project,
|
|
2568
|
+
user: JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()),
|
|
2569
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
2570
|
+
},
|
|
2524
2571
|
body: {
|
|
2525
2572
|
collection: mutation.collection,
|
|
2526
2573
|
document: mutation.documentId,
|
|
@@ -2552,7 +2599,12 @@ var SyncEngine = class {
|
|
|
2552
2599
|
const res = await new HttpsRequest({
|
|
2553
2600
|
method: "POST" /* POST */,
|
|
2554
2601
|
endpoint: `${this.app.getBaseUrl()}/db/delete`,
|
|
2555
|
-
headers: {
|
|
2602
|
+
headers: {
|
|
2603
|
+
authorization: this.app.getConfig().token,
|
|
2604
|
+
"x-project": this.app.getConfig().project,
|
|
2605
|
+
user: JSON.stringify(this.app.getAuthentication.currentUser()?.toMap()),
|
|
2606
|
+
"x-user": JSON.stringify(this.app.getAuthentication.currentUser()?.toMap())
|
|
2607
|
+
},
|
|
2556
2608
|
body: {
|
|
2557
2609
|
collection: mutation.collection,
|
|
2558
2610
|
document: mutation.documentId
|
|
@@ -2693,11 +2745,10 @@ var StorageRef = class {
|
|
|
2693
2745
|
if (!srcFile) {
|
|
2694
2746
|
throw new Error("Invalid File");
|
|
2695
2747
|
}
|
|
2696
|
-
console.log("SRCF");
|
|
2697
2748
|
const res = await new HttpsRequest({
|
|
2698
2749
|
method: "POST" /* POST */,
|
|
2699
2750
|
endpoint: serverURI + "/storage/file/upload",
|
|
2700
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
2751
|
+
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()) },
|
|
2701
2752
|
file: srcFile,
|
|
2702
2753
|
isMultipart: true
|
|
2703
2754
|
}).sendRequest();
|
|
@@ -2714,7 +2765,7 @@ var StorageRef = class {
|
|
|
2714
2765
|
const res = await new HttpsRequest({
|
|
2715
2766
|
method: "POST" /* POST */,
|
|
2716
2767
|
endpoint: serverURI + "/storage/file/delete",
|
|
2717
|
-
headers: { authorization: this.app.getConfig().token, "x-project": this.app.getConfig().project },
|
|
2768
|
+
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()) },
|
|
2718
2769
|
body: {
|
|
2719
2770
|
file_id: id
|
|
2720
2771
|
}
|