@spooky-sync/core 0.0.1-canary.362 → 0.0.1-canary.364
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/index.js
CHANGED
|
@@ -3650,8 +3650,8 @@ function trimHistory(history, cap) {
|
|
|
3650
3650
|
|
|
3651
3651
|
//#endregion
|
|
3652
3652
|
//#region src/modules/devtools/index.ts
|
|
3653
|
-
const CORE_VERSION = "0.0.1-canary.
|
|
3654
|
-
const WASM_VERSION = "0.0.1-canary.
|
|
3653
|
+
const CORE_VERSION = "0.0.1-canary.364";
|
|
3654
|
+
const WASM_VERSION = "0.0.1-canary.364";
|
|
3655
3655
|
const SURREAL_VERSION = "3.1.0";
|
|
3656
3656
|
var DevToolsService = class DevToolsService {
|
|
3657
3657
|
version = CORE_VERSION;
|
|
@@ -14018,7 +14018,7 @@ var AuthService = class {
|
|
|
14018
14018
|
const info = this.impersonation;
|
|
14019
14019
|
if (!info) return;
|
|
14020
14020
|
if (!opts.serverEnded) try {
|
|
14021
|
-
await this.remote.query("RETURN fn::_00_impersonate::stop($
|
|
14021
|
+
await this.remote.query("RETURN fn::_00_impersonate::stop($sid)", { sid: info.session });
|
|
14022
14022
|
} catch (error) {
|
|
14023
14023
|
this.logger.warn({
|
|
14024
14024
|
error,
|
|
@@ -14228,7 +14228,7 @@ var AuthService = class {
|
|
|
14228
14228
|
if (impersonating) {
|
|
14229
14229
|
this.endedImpersonationTarget = impersonating.target;
|
|
14230
14230
|
try {
|
|
14231
|
-
await this.remote.query("RETURN fn::_00_impersonate::stop($
|
|
14231
|
+
await this.remote.query("RETURN fn::_00_impersonate::stop($sid)", { sid: impersonating.session });
|
|
14232
14232
|
} catch (_e) {}
|
|
14233
14233
|
}
|
|
14234
14234
|
await this.persistenceClient.remove(ORIGIN_TOKEN_KEY);
|
|
@@ -17609,7 +17609,7 @@ function createTabsCoordinator(config, s, host) {
|
|
|
17609
17609
|
return new TabsCoordinator({
|
|
17610
17610
|
tabId: s.tabId,
|
|
17611
17611
|
fingerprint: computeTabsFingerprint({
|
|
17612
|
-
coreVersion: "0.0.1-canary.
|
|
17612
|
+
coreVersion: "0.0.1-canary.364",
|
|
17613
17613
|
schemaHash: hash53(config.schemaSurql),
|
|
17614
17614
|
endpoint: config.database.endpoint ?? "",
|
|
17615
17615
|
namespace: config.database.namespace,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spooky-sync/core",
|
|
3
|
-
"version": "0.0.1-canary.
|
|
3
|
+
"version": "0.0.1-canary.364",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@spooky-sync/query-builder": "0.0.1-canary.
|
|
79
|
-
"@spooky-sync/ssp-wasm": "0.0.1-canary.
|
|
78
|
+
"@spooky-sync/query-builder": "0.0.1-canary.364",
|
|
79
|
+
"@spooky-sync/ssp-wasm": "0.0.1-canary.364",
|
|
80
80
|
"@sqlite.org/sqlite-wasm": "3.53.0-build1",
|
|
81
81
|
"@surrealdb/wasm": "^3.1.0",
|
|
82
82
|
"@surrealdb/wasm-native": "^3.3.4",
|
|
@@ -64,8 +64,8 @@ DEFINE FUNCTION fn::_00_impersonate::start($target: string, $reason: string) {
|
|
|
64
64
|
UPSERT _00_impersonation:s1 SET target = type::record($target), admin = $auth.id, reason = $reason, ended_at = NONE;
|
|
65
65
|
RETURN { token: $test_imp_token, session: '_00_impersonation:s1' };
|
|
66
66
|
} PERMISSIONS FULL;
|
|
67
|
-
DEFINE FUNCTION fn::_00_impersonate::stop($
|
|
68
|
-
UPDATE type::record($
|
|
67
|
+
DEFINE FUNCTION fn::_00_impersonate::stop($session_id: string) {
|
|
68
|
+
UPDATE type::record($session_id) SET ended_at = time::now();
|
|
69
69
|
RETURN NONE;
|
|
70
70
|
} PERMISSIONS FULL;
|
|
71
71
|
DEFINE FUNCTION fn::_00_impersonate::renew() {
|
|
@@ -149,6 +149,10 @@ describe('impersonation on the SurrealDB-WASM engine', () => {
|
|
|
149
149
|
expect(String(auth.currentUser.id)).toBe('user:alice');
|
|
150
150
|
expect(store.get('sp00ky_auth_token')).toBe(adminToken);
|
|
151
151
|
expect(store.has(ORIGIN_TOKEN_KEY)).toBe(false);
|
|
152
|
+
// The server session ended too. Binding the id as `session` (a protected
|
|
153
|
+
// variable) failed silently here, and only the token's expiry ended it.
|
|
154
|
+
const [ended] = await db.query<[unknown]>('SELECT VALUE ended_at FROM ONLY _00_impersonation:s1');
|
|
155
|
+
expect(ended).toBeTruthy();
|
|
152
156
|
});
|
|
153
157
|
|
|
154
158
|
it('an explicit stop racing a server-ended stop still returns to the admin', async () => {
|
|
@@ -49,7 +49,7 @@ function makeServer(opts: { refuse?: Set<string>; unreachable?: boolean } = {})
|
|
|
49
49
|
}
|
|
50
50
|
if (sql.includes('fn::_00_impersonate::current')) return [state.ended ? null : { session: '_00_impersonation:s1' }];
|
|
51
51
|
if (sql.includes('fn::_00_impersonate::stop')) {
|
|
52
|
-
state.stops.push(vars?.
|
|
52
|
+
state.stops.push(vars?.sid);
|
|
53
53
|
state.ended = true;
|
|
54
54
|
return [null];
|
|
55
55
|
}
|
|
@@ -382,7 +382,7 @@ export class AuthService<S extends SchemaStructure> {
|
|
|
382
382
|
if (!info) return;
|
|
383
383
|
if (!opts.serverEnded) {
|
|
384
384
|
try {
|
|
385
|
-
await this.remote.query('RETURN fn::_00_impersonate::stop($
|
|
385
|
+
await this.remote.query('RETURN fn::_00_impersonate::stop($sid)', { sid: info.session });
|
|
386
386
|
} catch (error) {
|
|
387
387
|
// The token expires on its own; the local switch below is what matters.
|
|
388
388
|
this.logger.warn(
|
|
@@ -659,8 +659,8 @@ export class AuthService<S extends SchemaStructure> {
|
|
|
659
659
|
if (impersonating) {
|
|
660
660
|
this.endedImpersonationTarget = impersonating.target;
|
|
661
661
|
try {
|
|
662
|
-
await this.remote.query('RETURN fn::_00_impersonate::stop($
|
|
663
|
-
|
|
662
|
+
await this.remote.query('RETURN fn::_00_impersonate::stop($sid)', {
|
|
663
|
+
sid: impersonating.session,
|
|
664
664
|
});
|
|
665
665
|
} catch (_e) {
|
|
666
666
|
// The token expires on its own.
|