dexie-cloud-addon 4.4.7 → 4.4.8

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.4.7, Fri Mar 27 2026
11
+ * Version 4.4.8, Tue Mar 31 2026
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -13623,7 +13623,7 @@
13623
13623
  *
13624
13624
  * ==========================================================================
13625
13625
  *
13626
- * Version 4.4.0, Fri Mar 27 2026
13626
+ * Version 4.4.0, Tue Mar 31 2026
13627
13627
  *
13628
13628
  * https://dexie.org
13629
13629
  *
@@ -14667,6 +14667,14 @@
14667
14667
  });
14668
14668
  return Promise.resolve(currentUser.accessToken);
14669
14669
  }
14670
+ // If the current user is not logged in (no isLoggedIn flag), there's no
14671
+ // token to load from the database — skip the Dexie.ignoreTransaction() call.
14672
+ // This avoids a crash in service worker context where Dexie's Promise zone
14673
+ // (PSD.transless.env) may be undefined when called from within an active
14674
+ // rw transaction (e.g. during applyServerChanges).
14675
+ if (!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.isLoggedIn)) {
14676
+ return Promise.resolve(null);
14677
+ }
14670
14678
  return Dexie.ignoreTransaction(() => loadAccessToken(db).then((user) => {
14671
14679
  var _a, _b;
14672
14680
  if (user === null || user === void 0 ? void 0 : user.accessToken) {
@@ -15248,8 +15256,9 @@
15248
15256
  if (!promise) {
15249
15257
  promise = loadCachedAccessToken(this.db)
15250
15258
  .then((accessToken) => {
15251
- if (!accessToken)
15252
- throw new Error('No access token available for blob download');
15259
+ // accessToken may be null for anonymous/unauthenticated users.
15260
+ // Public realm blobs (rlm-public) are accessible without auth.
15261
+ // downloadBlob will omit the Authorization header when token is null.
15253
15262
  return downloadBlob(blobRef, dbUrl, accessToken);
15254
15263
  })
15255
15264
  .finally(() => this.inFlight.delete(blobRef.ref));
@@ -15262,19 +15271,22 @@
15262
15271
  /**
15263
15272
  * Download blob data from server via proxy endpoint.
15264
15273
  * Uses auth header for authentication (same as sync).
15274
+ * When accessToken is null, the request is made without Authorization header —
15275
+ * this allows downloading blobs from public realms (rlm-public) for
15276
+ * unauthenticated users.
15265
15277
  *
15266
15278
  * @param blobRef - The BlobRef to download
15267
15279
  * @param dbUrl - Base URL for the database (e.g., 'https://mydb.dexie.cloud')
15268
- * @param accessToken - Access token for authentication
15280
+ * @param accessToken - Access token for authentication, or null for anonymous access
15269
15281
  */
15270
15282
  function downloadBlob(blobRef, dbUrl, accessToken) {
15271
15283
  return __awaiter(this, void 0, void 0, function* () {
15272
15284
  const downloadUrl = `${dbUrl}/blob/${blobRef.ref}`;
15273
- const response = yield fetch(downloadUrl, {
15274
- headers: {
15275
- Authorization: `Bearer ${accessToken}`,
15276
- },
15277
- });
15285
+ const headers = {};
15286
+ if (accessToken) {
15287
+ headers['Authorization'] = `Bearer ${accessToken}`;
15288
+ }
15289
+ const response = yield fetch(downloadUrl, { headers });
15278
15290
  if (!response.ok) {
15279
15291
  throw new Error(`Failed to download blob ${blobRef.ref}: ${response.status} ${response.statusText}`);
15280
15292
  }
@@ -19547,7 +19559,7 @@
19547
19559
  const downloading$ = createDownloadingState();
19548
19560
  dexie.cloud = {
19549
19561
  // @ts-ignore
19550
- version: "4.4.7",
19562
+ version: "4.4.8",
19551
19563
  options: Object.assign({}, DEFAULT_OPTIONS),
19552
19564
  schema: null,
19553
19565
  get currentUserId() {
@@ -19983,7 +19995,7 @@
19983
19995
  }
19984
19996
  }
19985
19997
  // @ts-ignore
19986
- dexieCloud.version = "4.4.7";
19998
+ dexieCloud.version = "4.4.8";
19987
19999
  Dexie.Cloud = dexieCloud;
19988
20000
 
19989
20001
  // In case the SW lives for a while, let it reuse already opened connections: