dexie-cloud-addon 4.4.7 → 4.4.9

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.
@@ -25,9 +25,12 @@ export declare class BlobDownloadTracker {
25
25
  /**
26
26
  * Download blob data from server via proxy endpoint.
27
27
  * Uses auth header for authentication (same as sync).
28
+ * When accessToken is null, the request is made without Authorization header —
29
+ * this allows downloading blobs from public realms (rlm-public) for
30
+ * unauthenticated users.
28
31
  *
29
32
  * @param blobRef - The BlobRef to download
30
33
  * @param dbUrl - Base URL for the database (e.g., 'https://mydb.dexie.cloud')
31
- * @param accessToken - Access token for authentication
34
+ * @param accessToken - Access token for authentication, or null for anonymous access
32
35
  */
33
- export declare function downloadBlob(blobRef: BlobRef, dbUrl: string, accessToken: string): Promise<Uint8Array>;
36
+ export declare function downloadBlob(blobRef: BlobRef, dbUrl: string, accessToken: string | null): Promise<Uint8Array>;
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * ==========================================================================
10
10
  *
11
- * Version 4.4.7, Fri Mar 27 2026
11
+ * Version 4.4.9, Tue Mar 31 2026
12
12
  *
13
13
  * https://dexie.org
14
14
  *
@@ -14493,7 +14493,7 @@
14493
14493
  *
14494
14494
  * ==========================================================================
14495
14495
  *
14496
- * Version 4.4.0, Fri Mar 27 2026
14496
+ * Version 4.4.0, Tue Mar 31 2026
14497
14497
  *
14498
14498
  * https://dexie.org
14499
14499
  *
@@ -15537,6 +15537,14 @@
15537
15537
  });
15538
15538
  return Promise.resolve(currentUser.accessToken);
15539
15539
  }
15540
+ // If the current user is not logged in (no isLoggedIn flag), there's no
15541
+ // token to load from the database — skip the Dexie.ignoreTransaction() call.
15542
+ // This avoids a crash in service worker context where Dexie's Promise zone
15543
+ // (PSD.transless.env) may be undefined when called from within an active
15544
+ // rw transaction (e.g. during applyServerChanges).
15545
+ if (!(currentUser === null || currentUser === void 0 ? void 0 : currentUser.isLoggedIn)) {
15546
+ return Promise.resolve(null);
15547
+ }
15540
15548
  return Dexie.ignoreTransaction(() => loadAccessToken(db).then((user) => {
15541
15549
  var _a, _b;
15542
15550
  if (user === null || user === void 0 ? void 0 : user.accessToken) {
@@ -15598,7 +15606,7 @@
15598
15606
  return __awaiter(this, arguments, void 0, function* (db, options, schema, { isInitialSync, cancelToken, justCheckIfNeeded, purpose } = {
15599
15607
  isInitialSync: false,
15600
15608
  }) {
15601
- var _a, _b, _c;
15609
+ var _a, _b, _c, _d, _e;
15602
15610
  if (!justCheckIfNeeded) {
15603
15611
  console.debug('SYNC STARTED', { isInitialSync, purpose });
15604
15612
  }
@@ -15672,7 +15680,7 @@
15672
15680
  // Offload large blobs to blob storage before sync
15673
15681
  //
15674
15682
  let processedChangeSet = clientChangeSet;
15675
- const maxStringLength = (_c = (_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.maxStringLength) !== null && _c !== void 0 ? _c : 32768;
15683
+ const maxStringLength = (_e = (_c = (_b = db.cloud.options) === null || _b === void 0 ? void 0 : _b.largeStringThreshold) !== null && _c !== void 0 ? _c : (_d = db.cloud.options) === null || _d === void 0 ? void 0 : _d.maxStringLength) !== null && _e !== void 0 ? _e : 32768;
15676
15684
  const hasLargeBlobs = hasLargeBlobsInOperations(clientChangeSet, maxStringLength);
15677
15685
  if (hasLargeBlobs) {
15678
15686
  processedChangeSet = yield offloadBlobsInOperations(clientChangeSet, databaseUrl, () => loadCachedAccessToken(db), maxStringLength);
@@ -16118,8 +16126,9 @@
16118
16126
  if (!promise) {
16119
16127
  promise = loadCachedAccessToken(this.db)
16120
16128
  .then((accessToken) => {
16121
- if (!accessToken)
16122
- throw new Error('No access token available for blob download');
16129
+ // accessToken may be null for anonymous/unauthenticated users.
16130
+ // Public realm blobs (rlm-public) are accessible without auth.
16131
+ // downloadBlob will omit the Authorization header when token is null.
16123
16132
  return downloadBlob(blobRef, dbUrl, accessToken);
16124
16133
  })
16125
16134
  .finally(() => this.inFlight.delete(blobRef.ref));
@@ -16132,19 +16141,22 @@
16132
16141
  /**
16133
16142
  * Download blob data from server via proxy endpoint.
16134
16143
  * Uses auth header for authentication (same as sync).
16144
+ * When accessToken is null, the request is made without Authorization header —
16145
+ * this allows downloading blobs from public realms (rlm-public) for
16146
+ * unauthenticated users.
16135
16147
  *
16136
16148
  * @param blobRef - The BlobRef to download
16137
16149
  * @param dbUrl - Base URL for the database (e.g., 'https://mydb.dexie.cloud')
16138
- * @param accessToken - Access token for authentication
16150
+ * @param accessToken - Access token for authentication, or null for anonymous access
16139
16151
  */
16140
16152
  function downloadBlob(blobRef, dbUrl, accessToken) {
16141
16153
  return __awaiter(this, void 0, void 0, function* () {
16142
16154
  const downloadUrl = `${dbUrl}/blob/${blobRef.ref}`;
16143
- const response = yield fetch(downloadUrl, {
16144
- headers: {
16145
- Authorization: `Bearer ${accessToken}`,
16146
- },
16147
- });
16155
+ const headers = {};
16156
+ if (accessToken) {
16157
+ headers['Authorization'] = `Bearer ${accessToken}`;
16158
+ }
16159
+ const response = yield fetch(downloadUrl, { headers });
16148
16160
  if (!response.ok) {
16149
16161
  throw new Error(`Failed to download blob ${blobRef.ref}: ${response.status} ${response.statusText}`);
16150
16162
  }
@@ -19718,7 +19730,7 @@
19718
19730
  const downloading$ = createDownloadingState();
19719
19731
  dexie.cloud = {
19720
19732
  // @ts-ignore
19721
- version: "4.4.7",
19733
+ version: "4.4.9",
19722
19734
  options: Object.assign({}, DEFAULT_OPTIONS),
19723
19735
  schema: null,
19724
19736
  get currentUserId() {
@@ -19746,18 +19758,27 @@
19746
19758
  invites: getInvitesObservable(dexie),
19747
19759
  roles: getGlobalRolesObservable(dexie),
19748
19760
  configure(options) {
19749
- // Validate maxStringLength Infinity disables offloading, otherwise must be
19750
- // a finite number between 100 and the server limit (32768).
19761
+ // Validate largeStringThreshold (preferred) or maxStringLength (deprecated)
19762
+ // Infinity disables offloading, otherwise must be a finite number between 100
19763
+ // and the server limit (32768).
19751
19764
  // Minimum 100 prevents accidental offloading of primary keys and short strings
19752
19765
  // that would break sync.
19753
19766
  const MIN_STRING_LENGTH = 100;
19754
19767
  const MAX_SERVER_STRING_LENGTH = 32768;
19755
- if (options.maxStringLength !== undefined &&
19756
- options.maxStringLength !== Infinity &&
19757
- (!Number.isFinite(options.maxStringLength) ||
19758
- options.maxStringLength < MIN_STRING_LENGTH ||
19759
- options.maxStringLength > MAX_SERVER_STRING_LENGTH)) {
19760
- throw new Error(`maxStringLength must be Infinity or a finite number in [${MIN_STRING_LENGTH}, ${MAX_SERVER_STRING_LENGTH}]. Got: ${options.maxStringLength}`);
19768
+ if (options.maxStringLength !== undefined) {
19769
+ console.warn('maxStringLength is deprecated, use largeStringThreshold instead');
19770
+ // If largeStringThreshold is not explicitly set, migrate to new name
19771
+ if (options.largeStringThreshold === undefined) {
19772
+ options = Object.assign(Object.assign({}, options), { largeStringThreshold: options.maxStringLength });
19773
+ }
19774
+ }
19775
+ const thresholdValue = options.largeStringThreshold;
19776
+ if (thresholdValue !== undefined &&
19777
+ thresholdValue !== Infinity &&
19778
+ (!Number.isFinite(thresholdValue) ||
19779
+ thresholdValue < MIN_STRING_LENGTH ||
19780
+ thresholdValue > MAX_SERVER_STRING_LENGTH)) {
19781
+ throw new Error(`largeStringThreshold must be Infinity or a finite number in [${MIN_STRING_LENGTH}, ${MAX_SERVER_STRING_LENGTH}]. Got: ${thresholdValue}`);
19761
19782
  }
19762
19783
  options = dexie.cloud.options = Object.assign(Object.assign({}, dexie.cloud.options), options);
19763
19784
  configuredProgramatically = true;
@@ -20154,7 +20175,7 @@
20154
20175
  }
20155
20176
  }
20156
20177
  // @ts-ignore
20157
- dexieCloud.version = "4.4.7";
20178
+ dexieCloud.version = "4.4.9";
20158
20179
  Dexie.Cloud = dexieCloud;
20159
20180
 
20160
20181
  exports.default = dexieCloud;