@mindexec/cli 0.2.210 → 0.2.211
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/package.json +1 -1
- package/scripts/auth-session-smoke.mjs +44 -1
- package/server.js +39 -0
- package/wwwroot/_framework/{MindExecution.Web.aj117i28hy.dll → MindExecution.Web.7axuoygrwi.dll} +0 -0
- package/wwwroot/_framework/blazor.boot.json +3 -3
- package/wwwroot/service-worker-assets.js +4 -4
- package/wwwroot/service-worker.js +1 -1
package/package.json
CHANGED
|
@@ -138,11 +138,25 @@ try {
|
|
|
138
138
|
const sessionPayload = JSON.stringify({
|
|
139
139
|
access_token: 'access-token-a',
|
|
140
140
|
refresh_token: 'refresh-token-a',
|
|
141
|
+
expires_at: Math.floor(Date.now() / 1000) + 600,
|
|
141
142
|
user: {
|
|
142
143
|
id: 'user-a',
|
|
143
144
|
email: 'auth-smoke@example.com'
|
|
144
145
|
}
|
|
145
146
|
});
|
|
147
|
+
let expectedStablePayload = sessionPayload;
|
|
148
|
+
|
|
149
|
+
function makeTimedSessionPayload(accessToken, refreshToken, expiresInSeconds) {
|
|
150
|
+
return JSON.stringify({
|
|
151
|
+
access_token: accessToken,
|
|
152
|
+
refresh_token: refreshToken,
|
|
153
|
+
expires_at: Math.floor(Date.now() / 1000) + expiresInSeconds,
|
|
154
|
+
user: {
|
|
155
|
+
id: 'user-a',
|
|
156
|
+
email: 'auth-smoke@example.com'
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
146
160
|
|
|
147
161
|
await withBridge({ workspacePath: workspaceA, authDataRoot }, async (baseUrl) => {
|
|
148
162
|
const unauthorized = await fetchJson(`${baseUrl}/api/auth/session`);
|
|
@@ -170,12 +184,41 @@ try {
|
|
|
170
184
|
assert.equal(loaded.status, 200);
|
|
171
185
|
assert.equal(loaded.payload?.content, sessionPayload);
|
|
172
186
|
assert.equal(loaded.payload?.source, 'stable');
|
|
187
|
+
|
|
188
|
+
const newerPayload = makeTimedSessionPayload('access-token-newer', 'refresh-token-newer', 3600);
|
|
189
|
+
const newerSaved = await fetchJson(`${baseUrl}/api/auth/session`, {
|
|
190
|
+
method: 'POST',
|
|
191
|
+
token: BRIDGE_TOKEN,
|
|
192
|
+
body: JSON.stringify({ content: newerPayload })
|
|
193
|
+
});
|
|
194
|
+
assert.equal(newerSaved.status, 200);
|
|
195
|
+
|
|
196
|
+
const staleBrowserPayload = makeTimedSessionPayload('access-token-stale-browser', 'refresh-token-stale-browser', 120);
|
|
197
|
+
const staleSaved = await fetchJson(`${baseUrl}/api/auth/session`, {
|
|
198
|
+
method: 'POST',
|
|
199
|
+
token: BRIDGE_TOKEN,
|
|
200
|
+
body: JSON.stringify({ content: staleBrowserPayload })
|
|
201
|
+
});
|
|
202
|
+
assert.equal(staleSaved.status, 200);
|
|
203
|
+
|
|
204
|
+
const afterStale = await fetchJson(`${baseUrl}/api/auth/session`, { token: BRIDGE_TOKEN });
|
|
205
|
+
assert.equal(afterStale.status, 200);
|
|
206
|
+
assert.equal(JSON.parse(afterStale.payload?.content || '{}').access_token, 'access-token-newer');
|
|
207
|
+
|
|
208
|
+
const newestPayload = makeTimedSessionPayload('access-token-newest', 'refresh-token-newest', 7200);
|
|
209
|
+
const newestSaved = await fetchJson(`${baseUrl}/api/auth/session`, {
|
|
210
|
+
method: 'POST',
|
|
211
|
+
token: BRIDGE_TOKEN,
|
|
212
|
+
body: JSON.stringify({ content: newestPayload })
|
|
213
|
+
});
|
|
214
|
+
assert.equal(newestSaved.status, 200);
|
|
215
|
+
expectedStablePayload = newestPayload;
|
|
173
216
|
});
|
|
174
217
|
|
|
175
218
|
await withBridge({ workspacePath: workspaceB, authDataRoot }, async (baseUrl) => {
|
|
176
219
|
const loaded = await fetchJson(`${baseUrl}/api/auth/session`, { token: BRIDGE_TOKEN });
|
|
177
220
|
assert.equal(loaded.status, 200);
|
|
178
|
-
assert.equal(loaded.payload?.content,
|
|
221
|
+
assert.equal(loaded.payload?.content, expectedStablePayload);
|
|
179
222
|
assert.equal(loaded.payload?.source, 'stable');
|
|
180
223
|
|
|
181
224
|
const deleted = await fetchJson(`${baseUrl}/api/auth/session`, {
|
package/server.js
CHANGED
|
@@ -669,10 +669,49 @@ async function readStableAuthSessionPayload() {
|
|
|
669
669
|
async function writeStableAuthSessionPayload(content) {
|
|
670
670
|
const payload = validateAuthSessionPayload(content);
|
|
671
671
|
const stablePath = getStableSupabaseSessionPath();
|
|
672
|
+
const existingPayload = await tryReadTextFile(stablePath);
|
|
673
|
+
if (shouldKeepExistingAuthSessionPayload(existingPayload, payload)) {
|
|
674
|
+
return stablePath;
|
|
675
|
+
}
|
|
676
|
+
|
|
672
677
|
await writePrivateTextFile(stablePath, payload);
|
|
673
678
|
return stablePath;
|
|
674
679
|
}
|
|
675
680
|
|
|
681
|
+
function shouldKeepExistingAuthSessionPayload(existingContent, incomingContent) {
|
|
682
|
+
if (!existingContent || !String(existingContent).trim()) {
|
|
683
|
+
return false;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
const existing = parseSupabaseSessionForRegistry(existingContent);
|
|
687
|
+
const incoming = parseSupabaseSessionForRegistry(incomingContent);
|
|
688
|
+
if (!existing || !incoming) {
|
|
689
|
+
return false;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
if (!existing.userId || !incoming.userId || existing.userId !== incoming.userId) {
|
|
693
|
+
return false;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
if (!Number.isFinite(existing.expiresAtMs) || !Number.isFinite(incoming.expiresAtMs)) {
|
|
697
|
+
return false;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const now = Date.now();
|
|
701
|
+
const existingRemainingMs = existing.expiresAtMs - now;
|
|
702
|
+
const incomingRemainingMs = incoming.expiresAtMs - now;
|
|
703
|
+
const staleSkewMs = 30_000;
|
|
704
|
+
if (existingRemainingMs <= staleSkewMs || incoming.expiresAtMs + staleSkewMs >= existing.expiresAtMs) {
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
logEvent(
|
|
709
|
+
'remote',
|
|
710
|
+
`auth session write ignored stale payload ${formatKeyValue('existingMs', Math.max(0, existingRemainingMs))} ${formatKeyValue('incomingMs', Math.max(0, incomingRemainingMs))}`,
|
|
711
|
+
'remote');
|
|
712
|
+
return true;
|
|
713
|
+
}
|
|
714
|
+
|
|
676
715
|
async function deleteStableAuthSessionPayload() {
|
|
677
716
|
const paths = [
|
|
678
717
|
getStableSupabaseSessionPath(),
|
package/wwwroot/_framework/{MindExecution.Web.aj117i28hy.dll → MindExecution.Web.7axuoygrwi.dll}
RENAMED
|
Binary file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"mainAssemblyName": "MindExecution.Web",
|
|
3
3
|
"resources": {
|
|
4
|
-
"hash": "sha256-
|
|
4
|
+
"hash": "sha256-iiSeCvB5NpvqIW1+MQgzzc+UStFn80YeJUyFtdiuER8=",
|
|
5
5
|
"fingerprinting": {
|
|
6
6
|
"Google.Protobuf.9h59ukbel7.dll": "Google.Protobuf.dll",
|
|
7
7
|
"Markdig.d1j7v41cl1.dll": "Markdig.dll",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"MindExecution.Plugins.PlanMaster.kibqg6rvqh.dll": "MindExecution.Plugins.PlanMaster.dll",
|
|
133
133
|
"MindExecution.Plugins.YouTube.089r64n2hv.dll": "MindExecution.Plugins.YouTube.dll",
|
|
134
134
|
"MindExecution.Shared.p86iw1fhns.dll": "MindExecution.Shared.dll",
|
|
135
|
-
"MindExecution.Web.
|
|
135
|
+
"MindExecution.Web.7axuoygrwi.dll": "MindExecution.Web.dll",
|
|
136
136
|
"dotnet.js": "dotnet.js",
|
|
137
137
|
"dotnet.native.qc8g39g30v.js": "dotnet.native.js",
|
|
138
138
|
"dotnet.native.boem75ye5i.wasm": "dotnet.native.wasm",
|
|
@@ -284,7 +284,7 @@
|
|
|
284
284
|
"MindExecution.Plugins.Concept.u9kzsgf64o.dll": "sha256-Yp38m6zHe8EBxtm480N4LfcHRpzFZRhYpr1RsCgnlK8=",
|
|
285
285
|
"MindExecution.Plugins.PlanMaster.kibqg6rvqh.dll": "sha256-NOtEHR8Y0rO8BguFvD1soa8jfB4YVQFydten0SzqBEg=",
|
|
286
286
|
"MindExecution.Shared.p86iw1fhns.dll": "sha256-GeQGsY17FMYu6beNS1RDR7yJ/nNgfiix6rjORzhXnCY=",
|
|
287
|
-
"MindExecution.Web.
|
|
287
|
+
"MindExecution.Web.7axuoygrwi.dll": "sha256-/6NQ8z9E7ixNwgYD71eh6M6YCGzctKodTWcZNJcNF8E="
|
|
288
288
|
},
|
|
289
289
|
"lazyAssembly": {
|
|
290
290
|
"MindExecution.Plugins.Admin.29mytzdaun.dll": "sha256-2mHPbTPcHCi1xPuk3dNMVWxn42xZFUZ3QFhm3xIV/6E=",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
self.assetsManifest = {
|
|
2
|
-
"version": "
|
|
2
|
+
"version": "YLV1KsFI",
|
|
3
3
|
"assets": [
|
|
4
4
|
{
|
|
5
5
|
"hash": "sha256-+CSYMcqLNTsq3VnH11jgYyOCCdxvHzL74CBmo4sCmMU=",
|
|
@@ -446,8 +446,8 @@
|
|
|
446
446
|
"url": "_framework/MindExecution.Shared.p86iw1fhns.dll"
|
|
447
447
|
},
|
|
448
448
|
{
|
|
449
|
-
"hash": "sha256
|
|
450
|
-
"url": "_framework/MindExecution.Web.
|
|
449
|
+
"hash": "sha256-/6NQ8z9E7ixNwgYD71eh6M6YCGzctKodTWcZNJcNF8E=",
|
|
450
|
+
"url": "_framework/MindExecution.Web.7axuoygrwi.dll"
|
|
451
451
|
},
|
|
452
452
|
{
|
|
453
453
|
"hash": "sha256-IsZJ91/OW+fHzNqIgEc7Y072ns8z9dGritiSyvR9Wgc=",
|
|
@@ -770,7 +770,7 @@
|
|
|
770
770
|
"url": "_framework/Websocket.Client.vapounvmnl.dll"
|
|
771
771
|
},
|
|
772
772
|
{
|
|
773
|
-
"hash": "sha256-
|
|
773
|
+
"hash": "sha256-xLiOU/vuEmRFIqaJXh1WMyuEaWcsagGwx5Uq71HsjkY=",
|
|
774
774
|
"url": "_framework/blazor.boot.json"
|
|
775
775
|
},
|
|
776
776
|
{
|