dexie-cloud-addon 4.0.1-beta.52 → 4.0.1-beta.54

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.
@@ -8,9 +8,7 @@ export interface Realm {
8
8
  */
9
9
  name?: string;
10
10
  /** Contains the user-ID of the owner. An owner has implicit full write-access to the realm
11
- * and all obejcts connected to it. Ownership does not imply read (sync) access though,
12
- * so realm owners still needs to add themself as a member if they are going to use the realm
13
- * themselves.
11
+ * and all obejcts connected to it.
14
12
  */
15
13
  owner?: string;
16
14
  }
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.0.1-beta.52, Mon Oct 30 2023
11
+ * Version 4.0.1-beta.54, Mon Dec 18 2023
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -2019,7 +2019,7 @@
2019
2019
  function promptForEmail(userInteraction, title, emailHint) {
2020
2020
  return __awaiter(this, void 0, void 0, function* () {
2021
2021
  let email = emailHint || '';
2022
- while (!email || !/^[\w-\.]+@([\w-]+\.)+[\w-]{2,10}$/.test(email)) {
2022
+ while (!email || !/^[\w-+.]+@([\w-]+\.)+[\w-]{2,10}$/.test(email)) {
2023
2023
  email = (yield interactWithUser(userInteraction, {
2024
2024
  type: 'email',
2025
2025
  title,
@@ -4640,6 +4640,21 @@
4640
4640
  const trans = req.trans;
4641
4641
  if ((_b = (_a = db.cloud.schema) === null || _a === void 0 ? void 0 : _a[tableName]) === null || _b === void 0 ? void 0 : _b.markedForSync) {
4642
4642
  if (req.type === 'add' || req.type === 'put') {
4643
+ if (tableName === 'members') {
4644
+ for (const member of req.values) {
4645
+ if (typeof member.email === 'string') {
4646
+ // Resolve https://github.com/dexie/dexie-cloud/issues/4
4647
+ // If adding a member, make sure email is lowercase and trimmed.
4648
+ // This is to avoid issues where the APP does not check this
4649
+ // and just allows the user to enter an email address that might
4650
+ // have been pasted by the user from a source that had a trailing
4651
+ // space or was in uppercase. We want to avoid that the user
4652
+ // creates a new member with a different email address than
4653
+ // the one he/she intended to create.
4654
+ member.email = member.email.trim().toLowerCase();
4655
+ }
4656
+ }
4657
+ }
4643
4658
  // No matter if user is logged in or not, make sure "owner" and "realmId" props are set properly.
4644
4659
  // If not logged in, this will be changed upon syncification of the tables (next sync after login),
4645
4660
  // however, application code will work better if we can always rely on that the properties realmId
@@ -4707,7 +4722,7 @@
4707
4722
  const numWriters = writers.length;
4708
4723
  const promise = (numWriters > 0
4709
4724
  ? writers[numWriters - 1].then(() => fn(req), () => fn(req))
4710
- : fn(req)).finally(() => readers.splice(readers.indexOf(promise)));
4725
+ : fn(req)).finally(() => { readers.splice(readers.indexOf(promise)); });
4711
4726
  readers.push(promise);
4712
4727
  return promise;
4713
4728
  };
@@ -4719,7 +4734,7 @@
4719
4734
  ? writers[writers.length - 1].then(() => fn(req), () => fn(req))
4720
4735
  : readers.length > 0
4721
4736
  ? allSettled(readers).then(() => fn(req))
4722
- : fn(req)).finally(() => writers.shift());
4737
+ : fn(req)).finally(() => { writers.shift(); });
4723
4738
  writers.push(promise);
4724
4739
  return promise;
4725
4740
  };
@@ -6220,7 +6235,7 @@
6220
6235
  const syncComplete = new rxjs.Subject();
6221
6236
  dexie.cloud = {
6222
6237
  // @ts-ignore
6223
- version: "4.0.1-beta.52",
6238
+ version: "4.0.1-beta.54",
6224
6239
  options: Object.assign({}, DEFAULT_OPTIONS),
6225
6240
  schema: null,
6226
6241
  get currentUserId() {
@@ -6497,7 +6512,7 @@
6497
6512
  }
6498
6513
  }
6499
6514
  // @ts-ignore
6500
- dexieCloud.version = "4.0.1-beta.52";
6515
+ dexieCloud.version = "4.0.1-beta.54";
6501
6516
  Dexie.Cloud = dexieCloud;
6502
6517
 
6503
6518
  exports.default = dexieCloud;