dexie-cloud-addon 4.3.2 → 4.3.4
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.
- package/dist/modern/DexieCloudAPI.d.ts +12 -1
- package/dist/modern/dexie-cloud-addon.js +68 -10
- package/dist/modern/dexie-cloud-addon.js.map +1 -1
- package/dist/modern/dexie-cloud-addon.min.js +1 -1
- package/dist/modern/dexie-cloud-addon.min.js.map +1 -1
- package/dist/modern/dexie-cloud-client.d.ts +1 -1
- package/dist/modern/errors/OAuthRedirectError.d.ts +11 -0
- package/dist/modern/service-worker.js +68 -10
- package/dist/modern/service-worker.js.map +1 -1
- package/dist/modern/service-worker.min.js +1 -1
- package/dist/modern/service-worker.min.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.js +69 -11
- package/dist/umd/dexie-cloud-addon.js.map +1 -1
- package/dist/umd/dexie-cloud-addon.min.js +1 -1
- package/dist/umd/dexie-cloud-addon.min.js.map +1 -1
- package/dist/umd/service-worker.js +69 -11
- package/dist/umd/service-worker.js.map +1 -1
- package/dist/umd/service-worker.min.js +1 -1
- package/dist/umd/service-worker.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ import { DXCWebSocketStatus } from './DXCWebSocketStatus';
|
|
|
6
6
|
import { UserLogin } from './db/entities/UserLogin';
|
|
7
7
|
export { DexieCloudTable } from './DexieCloudTable';
|
|
8
8
|
export * from './getTiedRealmId';
|
|
9
|
-
export { DBRealm, DBRealmMember, DBRealmRole, DBSyncedObject, DBPermissionSet, } from 'dexie-cloud-common';
|
|
9
|
+
export { DBRealm, DBRealmMember, DBRealmRole, DBSyncedObject, DBPermissionSet, AuthProvidersResponse, OAuthProviderInfo, } from 'dexie-cloud-common';
|
|
10
10
|
export { resolveText } from './helpers/resolveText';
|
|
11
11
|
export { Invite } from './Invite';
|
|
12
12
|
export type { UserLogin, DXCWebSocketStatus, SyncState };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown when initiating an OAuth redirect.
|
|
3
|
+
*
|
|
4
|
+
* This is not a real error - it's used to signal that the page is
|
|
5
|
+
* navigating away to an OAuth provider. It should be caught and
|
|
6
|
+
* silently ignored at the appropriate level.
|
|
7
|
+
*/
|
|
8
|
+
export declare class OAuthRedirectError extends Error {
|
|
9
|
+
readonly provider: string;
|
|
10
|
+
constructor(provider: string);
|
|
11
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* ==========================================================================
|
|
10
10
|
*
|
|
11
|
-
* Version 4.3.
|
|
11
|
+
* Version 4.3.4, Fri Jan 23 2026
|
|
12
12
|
*
|
|
13
13
|
* https://dexie.org
|
|
14
14
|
*
|
|
@@ -1409,6 +1409,21 @@ function promptForProvider(userInteraction_1, providers_1, otpEnabled_1) {
|
|
|
1409
1409
|
});
|
|
1410
1410
|
}
|
|
1411
1411
|
|
|
1412
|
+
/**
|
|
1413
|
+
* Error thrown when initiating an OAuth redirect.
|
|
1414
|
+
*
|
|
1415
|
+
* This is not a real error - it's used to signal that the page is
|
|
1416
|
+
* navigating away to an OAuth provider. It should be caught and
|
|
1417
|
+
* silently ignored at the appropriate level.
|
|
1418
|
+
*/
|
|
1419
|
+
class OAuthRedirectError extends Error {
|
|
1420
|
+
constructor(provider) {
|
|
1421
|
+
super(`OAuth redirect initiated for provider: ${provider}`);
|
|
1422
|
+
this.name = 'OAuthRedirectError';
|
|
1423
|
+
this.provider = provider;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1412
1427
|
function loadAccessToken(db) {
|
|
1413
1428
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1414
1429
|
var _a, _b, _c;
|
|
@@ -1576,6 +1591,10 @@ function userAuthenticate(context, fetchToken, userInteraction, hints) {
|
|
|
1576
1591
|
return context;
|
|
1577
1592
|
}
|
|
1578
1593
|
catch (error) {
|
|
1594
|
+
// OAuth redirect is not an error - page is navigating away
|
|
1595
|
+
if (error instanceof OAuthRedirectError || (error === null || error === void 0 ? void 0 : error.name) === 'OAuthRedirectError') {
|
|
1596
|
+
throw error; // Re-throw without logging
|
|
1597
|
+
}
|
|
1579
1598
|
if (error instanceof TokenErrorResponseError) {
|
|
1580
1599
|
yield alertUser(userInteraction, error.title, {
|
|
1581
1600
|
type: 'error',
|
|
@@ -3878,7 +3897,7 @@ function otpFetchTokenCallback(db) {
|
|
|
3878
3897
|
if (hints === null || hints === void 0 ? void 0 : hints.provider) {
|
|
3879
3898
|
initiateOAuthRedirect(db, hints.provider);
|
|
3880
3899
|
// This function never returns - page navigates away
|
|
3881
|
-
throw new
|
|
3900
|
+
throw new OAuthRedirectError(hints.provider);
|
|
3882
3901
|
}
|
|
3883
3902
|
if ((hints === null || hints === void 0 ? void 0 : hints.grant_type) === 'demo') {
|
|
3884
3903
|
const demo_user = yield promptForEmail(userInteraction, 'Enter a demo user email', (hints === null || hints === void 0 ? void 0 : hints.email) || (hints === null || hints === void 0 ? void 0 : hints.userId));
|
|
@@ -3913,7 +3932,7 @@ function otpFetchTokenCallback(db) {
|
|
|
3913
3932
|
// User selected an OAuth provider - initiate redirect
|
|
3914
3933
|
initiateOAuthRedirect(db, selection.provider);
|
|
3915
3934
|
// This function never returns - page navigates away
|
|
3916
|
-
throw new
|
|
3935
|
+
throw new OAuthRedirectError(selection.provider);
|
|
3917
3936
|
}
|
|
3918
3937
|
// User chose OTP - continue with email prompt below
|
|
3919
3938
|
}
|
|
@@ -4102,7 +4121,15 @@ function login(db, hints) {
|
|
|
4102
4121
|
claims: {},
|
|
4103
4122
|
lastLogin: new Date(0),
|
|
4104
4123
|
});
|
|
4105
|
-
|
|
4124
|
+
try {
|
|
4125
|
+
yield authenticate(db.cloud.options.databaseUrl, context, db.cloud.options.fetchTokens || otpFetchTokenCallback(db), db.cloud.userInteraction, hints);
|
|
4126
|
+
}
|
|
4127
|
+
catch (err) {
|
|
4128
|
+
if (err.name === 'OAuthRedirectError') {
|
|
4129
|
+
return false; // Page is redirecting for OAuth login
|
|
4130
|
+
}
|
|
4131
|
+
throw err;
|
|
4132
|
+
}
|
|
4106
4133
|
if (origUserId !== UNAUTHORIZED_USER.userId &&
|
|
4107
4134
|
context.userId !== origUserId) {
|
|
4108
4135
|
// User was logged in before, but now logged in as another user.
|
|
@@ -6004,7 +6031,7 @@ function LoginDialog({ title, alerts, fields, options, submitLabel, cancelLabel,
|
|
|
6004
6031
|
} }))))))),
|
|
6005
6032
|
_$1("div", { style: Styles.ButtonsDiv },
|
|
6006
6033
|
_$1(k$1, null,
|
|
6007
|
-
hasFields &&
|
|
6034
|
+
submitLabel && (hasFields || (!hasOptions && !hasFields)) && (_$1("button", { type: "submit", style: Styles.PrimaryButton, onClick: () => onSubmit(params) }, submitLabel)),
|
|
6008
6035
|
cancelLabel && (_$1("button", { style: Styles.Button, onClick: onCancel }, cancelLabel))))));
|
|
6009
6036
|
}
|
|
6010
6037
|
function valueTransformer(type, value) {
|
|
@@ -6686,6 +6713,8 @@ function dexieCloud(dexie) {
|
|
|
6686
6713
|
let configuredProgramatically = false;
|
|
6687
6714
|
// Pending OAuth auth code from dxc-auth redirect (detected in configure())
|
|
6688
6715
|
let pendingOAuthCode = null;
|
|
6716
|
+
// Pending OAuth error from dxc-auth redirect (detected in configure())
|
|
6717
|
+
let pendingOAuthError = null;
|
|
6689
6718
|
// local sync worker - used when there's no service worker.
|
|
6690
6719
|
let localSyncWorker = null;
|
|
6691
6720
|
dexie.on('ready', (dexie) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -6715,7 +6744,7 @@ function dexieCloud(dexie) {
|
|
|
6715
6744
|
const syncComplete = new Subject();
|
|
6716
6745
|
dexie.cloud = {
|
|
6717
6746
|
// @ts-ignore
|
|
6718
|
-
version: "4.3.
|
|
6747
|
+
version: "4.3.4",
|
|
6719
6748
|
options: Object.assign({}, DEFAULT_OPTIONS),
|
|
6720
6749
|
schema: null,
|
|
6721
6750
|
get currentUserId() {
|
|
@@ -6765,9 +6794,14 @@ function dexieCloud(dexie) {
|
|
|
6765
6794
|
}
|
|
6766
6795
|
catch (error) {
|
|
6767
6796
|
// parseOAuthCallback throws OAuthError on error callbacks
|
|
6768
|
-
// Store null for code but log the error
|
|
6769
|
-
console.warn('[dexie-cloud] OAuth callback error:', error);
|
|
6770
6797
|
cleanupOAuthUrl();
|
|
6798
|
+
if (error instanceof OAuthError) {
|
|
6799
|
+
pendingOAuthError = error;
|
|
6800
|
+
console.error('[dexie-cloud] OAuth callback error:', error.message);
|
|
6801
|
+
}
|
|
6802
|
+
else {
|
|
6803
|
+
console.error('[dexie-cloud] OAuth callback error:', error);
|
|
6804
|
+
}
|
|
6771
6805
|
}
|
|
6772
6806
|
}
|
|
6773
6807
|
},
|
|
@@ -6778,6 +6812,16 @@ function dexieCloud(dexie) {
|
|
|
6778
6812
|
: yield logout(DexieCloudDB(dexie));
|
|
6779
6813
|
});
|
|
6780
6814
|
},
|
|
6815
|
+
getAuthProviders() {
|
|
6816
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6817
|
+
const options = dexie.cloud.options;
|
|
6818
|
+
if (!(options === null || options === void 0 ? void 0 : options.databaseUrl)) {
|
|
6819
|
+
throw new Error('Dexie Cloud not configured. Call db.cloud.configure() first.');
|
|
6820
|
+
}
|
|
6821
|
+
const socialAuthEnabled = options.socialAuth !== false;
|
|
6822
|
+
return fetchAuthProviders(options.databaseUrl, socialAuthEnabled);
|
|
6823
|
+
});
|
|
6824
|
+
},
|
|
6781
6825
|
sync() {
|
|
6782
6826
|
return __awaiter(this, arguments, void 0, function* ({ wait, purpose } = { wait: true, purpose: 'push' }) {
|
|
6783
6827
|
var _a;
|
|
@@ -6963,7 +7007,20 @@ function dexieCloud(dexie) {
|
|
|
6963
7007
|
}
|
|
6964
7008
|
// HERE: If requireAuth, do athentication now.
|
|
6965
7009
|
let changedUser = false;
|
|
6966
|
-
|
|
7010
|
+
let user = yield db.getCurrentUser();
|
|
7011
|
+
// Show pending OAuth error if present (from dxc-auth redirect)
|
|
7012
|
+
if (pendingOAuthError && !db.cloud.isServiceWorkerDB) {
|
|
7013
|
+
const error = pendingOAuthError;
|
|
7014
|
+
pendingOAuthError = null; // Clear pending error
|
|
7015
|
+
console.debug('[dexie-cloud] Showing OAuth error:', error.message);
|
|
7016
|
+
// Show alert to user about the OAuth error
|
|
7017
|
+
yield alertUser(db.cloud.userInteraction, 'Authentication Error', {
|
|
7018
|
+
type: 'error',
|
|
7019
|
+
messageCode: 'GENERIC_ERROR',
|
|
7020
|
+
message: error.message,
|
|
7021
|
+
messageParams: { provider: error.provider || 'unknown' }
|
|
7022
|
+
});
|
|
7023
|
+
}
|
|
6967
7024
|
// Process pending OAuth callback if present (from dxc-auth redirect)
|
|
6968
7025
|
if (pendingOAuthCode && !db.cloud.isServiceWorkerDB) {
|
|
6969
7026
|
const { code, provider } = pendingOAuthCode;
|
|
@@ -6971,6 +7028,7 @@ function dexieCloud(dexie) {
|
|
|
6971
7028
|
console.debug('[dexie-cloud] Processing OAuth callback, provider:', provider);
|
|
6972
7029
|
try {
|
|
6973
7030
|
changedUser = yield login(db, { oauthCode: code, provider });
|
|
7031
|
+
user = yield db.getCurrentUser();
|
|
6974
7032
|
}
|
|
6975
7033
|
catch (error) {
|
|
6976
7034
|
console.error('[dexie-cloud] OAuth login failed:', error);
|
|
@@ -7065,7 +7123,7 @@ function dexieCloud(dexie) {
|
|
|
7065
7123
|
}
|
|
7066
7124
|
}
|
|
7067
7125
|
// @ts-ignore
|
|
7068
|
-
dexieCloud.version = "4.3.
|
|
7126
|
+
dexieCloud.version = "4.3.4";
|
|
7069
7127
|
Dexie.Cloud = dexieCloud;
|
|
7070
7128
|
|
|
7071
7129
|
// In case the SW lives for a while, let it reuse already opened connections:
|