dexie-cloud-addon 4.0.1-beta.53 → 4.0.1-beta.55

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,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.0.1-beta.53, Sat Dec 02 2023
11
+ * Version 4.0.1-beta.55, Tue Jan 02 2024
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -2019,7 +2019,28 @@
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
+ // Regular expression for email validation
2023
+ // ^[\w-+.]+@([\w-]+\.)+[\w-]{2,10}(\sas\s[\w-+.]+@([\w-]+\.)+[\w-]{2,10})?$
2024
+ //
2025
+ // ^[\w-+.]+ : Matches the start of the string. Allows one or more word characters
2026
+ // (a-z, A-Z, 0-9, and underscore), hyphen, plus, or dot.
2027
+ //
2028
+ // @ : Matches the @ symbol.
2029
+ // ([\w-]+\.)+ : Matches one or more word characters or hyphens followed by a dot.
2030
+ // The plus sign outside the parentheses means this pattern can repeat one or more times,
2031
+ // allowing for subdomains.
2032
+ // [\w-]{2,10} : Matches between 2 and 10 word characters or hyphens. This is typically for
2033
+ // the domain extension like .com, .net, etc.
2034
+ // (\sas\s[\w-+.]+@([\w-]+\.)+[\w-]{2,10})?$ : This part is optional (due to the ? at the end).
2035
+ // If present, it matches " as " followed by another valid email address. This allows for the
2036
+ // input to be either a single email address or two email addresses separated by " as ".
2037
+ //
2038
+ // The use case for "<email1> as <email2>"" is for when a database owner with full access to the
2039
+ // database needs to impersonate another user in the database in order to troubleshoot. This
2040
+ // format will only be possible to use when email1 is the owner of an API client with GLOBAL_READ
2041
+ // and GLOBAL_WRITE permissions on the database. The email will be checked on the server before
2042
+ // allowing it and giving out a token for email2, using the OTP sent to email1.
2043
+ while (!email || !/^[\w-+.]+@([\w-]+\.)+[\w-]{2,10}(\sas\s[\w-+.]+@([\w-]+\.)+[\w-]{2,10})?$/.test(email)) {
2023
2044
  email = (yield interactWithUser(userInteraction, {
2024
2045
  type: 'email',
2025
2046
  title,
@@ -4640,6 +4661,21 @@
4640
4661
  const trans = req.trans;
4641
4662
  if ((_b = (_a = db.cloud.schema) === null || _a === void 0 ? void 0 : _a[tableName]) === null || _b === void 0 ? void 0 : _b.markedForSync) {
4642
4663
  if (req.type === 'add' || req.type === 'put') {
4664
+ if (tableName === 'members') {
4665
+ for (const member of req.values) {
4666
+ if (typeof member.email === 'string') {
4667
+ // Resolve https://github.com/dexie/dexie-cloud/issues/4
4668
+ // If adding a member, make sure email is lowercase and trimmed.
4669
+ // This is to avoid issues where the APP does not check this
4670
+ // and just allows the user to enter an email address that might
4671
+ // have been pasted by the user from a source that had a trailing
4672
+ // space or was in uppercase. We want to avoid that the user
4673
+ // creates a new member with a different email address than
4674
+ // the one he/she intended to create.
4675
+ member.email = member.email.trim().toLowerCase();
4676
+ }
4677
+ }
4678
+ }
4643
4679
  // No matter if user is logged in or not, make sure "owner" and "realmId" props are set properly.
4644
4680
  // If not logged in, this will be changed upon syncification of the tables (next sync after login),
4645
4681
  // however, application code will work better if we can always rely on that the properties realmId
@@ -6220,7 +6256,7 @@
6220
6256
  const syncComplete = new rxjs.Subject();
6221
6257
  dexie.cloud = {
6222
6258
  // @ts-ignore
6223
- version: "4.0.1-beta.53",
6259
+ version: "4.0.1-beta.55",
6224
6260
  options: Object.assign({}, DEFAULT_OPTIONS),
6225
6261
  schema: null,
6226
6262
  get currentUserId() {
@@ -6497,7 +6533,7 @@
6497
6533
  }
6498
6534
  }
6499
6535
  // @ts-ignore
6500
- dexieCloud.version = "4.0.1-beta.53";
6536
+ dexieCloud.version = "4.0.1-beta.55";
6501
6537
  Dexie.Cloud = dexieCloud;
6502
6538
 
6503
6539
  exports.default = dexieCloud;