dexie-cloud-addon 4.0.1 → 4.0.3

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.
@@ -19,4 +19,5 @@ export interface UserLogin {
19
19
  nonExportablePrivateKey?: CryptoKey;
20
20
  publicKey?: CryptoKey;
21
21
  isLoggedIn?: boolean;
22
+ data?: any;
22
23
  }
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.0.1, Tue Mar 26 2024
11
+ * Version 4.0.3, Sat Apr 13 2024
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -2220,6 +2220,9 @@ function refreshAccessToken(url, login) {
2220
2220
  if (response.userValidUntil != null) {
2221
2221
  login.license.validUntil = new Date(response.userValidUntil);
2222
2222
  }
2223
+ if (response.data) {
2224
+ login.data = response.data;
2225
+ }
2223
2226
  return login;
2224
2227
  });
2225
2228
  }
@@ -2274,6 +2277,7 @@ function userAuthenticate(context, fetchToken, userInteraction, hints) {
2274
2277
  type: response2.userType,
2275
2278
  status: response2.claims.license || 'ok',
2276
2279
  };
2280
+ context.data = response2.data;
2277
2281
  if (response2.evalDaysLeft != null) {
2278
2282
  context.license.evalDaysLeft = response2.evalDaysLeft;
2279
2283
  }
@@ -2479,11 +2483,21 @@ function otpFetchTokenCallback(db) {
2479
2483
  }
2480
2484
  else {
2481
2485
  const email = yield promptForEmail(userInteraction, 'Enter email address', hints === null || hints === void 0 ? void 0 : hints.email);
2482
- tokenRequest = {
2483
- email,
2484
- grant_type: 'otp',
2485
- scopes: ['ACCESS_DB'],
2486
- };
2486
+ if (/@demo.local$/.test(email)) {
2487
+ tokenRequest = {
2488
+ demo_user: email,
2489
+ grant_type: 'demo',
2490
+ scopes: ['ACCESS_DB'],
2491
+ public_key
2492
+ };
2493
+ }
2494
+ else {
2495
+ tokenRequest = {
2496
+ email,
2497
+ grant_type: 'otp',
2498
+ scopes: ['ACCESS_DB'],
2499
+ };
2500
+ }
2487
2501
  }
2488
2502
  const res1 = yield fetch(`${url}/token`, {
2489
2503
  body: JSON.stringify(tokenRequest),
@@ -4209,6 +4223,7 @@ function MessagesFromServerConsumer(db) {
4209
4223
  accessTokenExpiration: refreshedLogin.accessTokenExpiration,
4210
4224
  claims: refreshedLogin.claims,
4211
4225
  license: refreshedLogin.license,
4226
+ data: refreshedLogin.data,
4212
4227
  });
4213
4228
  // Updating $logins will trigger emission of db.cloud.currentUser observable, which
4214
4229
  // in turn will lead to that connectWebSocket.ts will reconnect the socket with the
@@ -5457,6 +5472,7 @@ function connectWebSocket(db) {
5457
5472
  accessTokenExpiration: refreshedLogin.accessTokenExpiration,
5458
5473
  claims: refreshedLogin.claims,
5459
5474
  license: refreshedLogin.license,
5475
+ data: refreshedLogin.data
5460
5476
  });
5461
5477
  })), switchMap(() => createObservable()));
5462
5478
  }
@@ -6290,7 +6306,7 @@ function dexieCloud(dexie) {
6290
6306
  const syncComplete = new Subject();
6291
6307
  dexie.cloud = {
6292
6308
  // @ts-ignore
6293
- version: "4.0.1",
6309
+ version: "4.0.3",
6294
6310
  options: Object.assign({}, DEFAULT_OPTIONS),
6295
6311
  schema: null,
6296
6312
  get currentUserId() {
@@ -6567,7 +6583,7 @@ function dexieCloud(dexie) {
6567
6583
  }
6568
6584
  }
6569
6585
  // @ts-ignore
6570
- dexieCloud.version = "4.0.1";
6586
+ dexieCloud.version = "4.0.3";
6571
6587
  Dexie.Cloud = dexieCloud;
6572
6588
 
6573
6589
  export { dexieCloud as default, dexieCloud, getTiedObjectId, getTiedRealmId, resolveText };