@vue-skuilder/db 0.2.25 → 0.2.26
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/{SyncStrategy-CCU1H81I.d.cts → SyncStrategy-BXliog1m.d.cts} +14 -1
- package/dist/{SyncStrategy-CCU1H81I.d.ts → SyncStrategy-BXliog1m.d.ts} +14 -1
- package/dist/{contentSource-CrRnbjBx.d.cts → contentSource-D3c1fMAk.d.cts} +11 -0
- package/dist/{contentSource-kD35o65m.d.ts → contentSource-LPf044hY.d.ts} +11 -0
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +34 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +34 -0
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-IecbidDO.d.cts → dataLayerProvider-CeLiFbHv.d.cts} +1 -1
- package/dist/{dataLayerProvider-CtzddVdy.d.ts → dataLayerProvider-DaAootVV.d.ts} +1 -1
- package/dist/impl/couch/index.d.cts +4 -3
- package/dist/impl/couch/index.d.ts +4 -3
- package/dist/impl/couch/index.js +50 -0
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +50 -0
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +3 -3
- package/dist/impl/static/index.d.ts +3 -3
- package/dist/impl/static/index.js +34 -0
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +34 -0
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +51 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/userDB.ts +10 -0
- package/src/impl/common/BaseUserDB.ts +40 -0
- package/src/impl/common/SyncStrategy.ts +11 -1
- package/src/impl/common/index.ts +1 -0
- package/src/impl/common/types.ts +5 -0
- package/src/impl/couch/CouchDBSyncStrategy.ts +25 -1
- package/src/study/SessionController.ts +6 -2
package/dist/core/index.mjs
CHANGED
|
@@ -9200,6 +9200,40 @@ Currently logged-in as ${this._username}.`
|
|
|
9200
9200
|
}
|
|
9201
9201
|
return loginResult;
|
|
9202
9202
|
}
|
|
9203
|
+
/**
|
|
9204
|
+
* Adopt a remote session that was established outside this client — e.g. a
|
|
9205
|
+
* backend verified a third-party sign-in (Google) and set the session cookie
|
|
9206
|
+
* on its response. Afterwards the user is logged in exactly as after
|
|
9207
|
+
* login(): username switched, guest pointer cleared, init() re-run.
|
|
9208
|
+
*
|
|
9209
|
+
* @param opts.migrateGuestData Carry the current guest account's local data
|
|
9210
|
+
* into the adopted account. Pass true for a freshly created account (as
|
|
9211
|
+
* createAccount() does), false for an existing one (as login() does).
|
|
9212
|
+
*/
|
|
9213
|
+
async adoptSession(opts) {
|
|
9214
|
+
if (!this.syncStrategy.canAuthenticate() || !this.syncStrategy.adoptSession) {
|
|
9215
|
+
throw new Error("Session adoption not supported by current sync strategy");
|
|
9216
|
+
}
|
|
9217
|
+
const guestUsername = this._username.startsWith(GuestUsername) ? this._username : void 0;
|
|
9218
|
+
if (!guestUsername) {
|
|
9219
|
+
throw new Error(`Cannot adopt a session while logged in.
|
|
9220
|
+
Log out of account ${this.getUsername()} first.`);
|
|
9221
|
+
}
|
|
9222
|
+
const result = await this.syncStrategy.adoptSession(
|
|
9223
|
+
opts.migrateGuestData ? guestUsername : void 0
|
|
9224
|
+
);
|
|
9225
|
+
if (result.ok && result.username) {
|
|
9226
|
+
log3(`Adopted session for ${result.username}`);
|
|
9227
|
+
this._username = result.username;
|
|
9228
|
+
try {
|
|
9229
|
+
localStorage.removeItem("sk-guest-uuid");
|
|
9230
|
+
} catch (e) {
|
|
9231
|
+
logger.warn("localStorage not available (Node.js environment):", e);
|
|
9232
|
+
}
|
|
9233
|
+
await this.init();
|
|
9234
|
+
}
|
|
9235
|
+
return result;
|
|
9236
|
+
}
|
|
9203
9237
|
async resetUserData() {
|
|
9204
9238
|
if (this.syncStrategy.canAuthenticate()) {
|
|
9205
9239
|
return {
|