@huaqiu/dsh-auth 0.2.0 → 0.2.1
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/lib/index.mjs +9 -3
- package/package.json +1 -1
- package/src/service.ts +13 -3
package/lib/index.mjs
CHANGED
|
@@ -325,13 +325,19 @@ var InMemoryHuaqiuAuthService = class {
|
|
|
325
325
|
};
|
|
326
326
|
/**
|
|
327
327
|
* Spec §6.2 resolution order: host → pushed → persisted → null.
|
|
328
|
-
*
|
|
329
|
-
*
|
|
328
|
+
*
|
|
329
|
+
* Host mode is STRICT: an enabled host is the single source of truth. If the
|
|
330
|
+
* host yields no credential, the operator is unauthenticated — we must NOT
|
|
331
|
+
* fall back to a pushed/persisted credential left behind by an earlier
|
|
332
|
+
* standalone (auth.eda.cn) login. Otherwise a stale `~/.dsh/auth/session.json`
|
|
333
|
+
* would let the DSH plugins keep calling the backend while hq-edge itself has
|
|
334
|
+
* no auth info. The standalone fallbacks only apply when no host is configured.
|
|
330
335
|
*/
|
|
331
336
|
async resolve() {
|
|
332
337
|
if (this.host.enabled) {
|
|
333
338
|
const host = await this.host.resolve();
|
|
334
339
|
if (host) return toUserInfo(host);
|
|
340
|
+
return null;
|
|
335
341
|
}
|
|
336
342
|
if (this.current) return this.current;
|
|
337
343
|
return readPersisted();
|
|
@@ -368,7 +374,7 @@ var InMemoryHuaqiuAuthService = class {
|
|
|
368
374
|
this.current = info;
|
|
369
375
|
this.stale = false;
|
|
370
376
|
this.validator.invalidate();
|
|
371
|
-
writePersisted(info);
|
|
377
|
+
if (!this.hostMode) writePersisted(info);
|
|
372
378
|
this.emit();
|
|
373
379
|
}
|
|
374
380
|
invalidate() {
|
package/package.json
CHANGED
package/src/service.ts
CHANGED
|
@@ -192,13 +192,19 @@ export class InMemoryHuaqiuAuthService implements HuaqiuAuthService {
|
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
* Spec §6.2 resolution order: host → pushed → persisted → null.
|
|
195
|
-
*
|
|
196
|
-
*
|
|
195
|
+
*
|
|
196
|
+
* Host mode is STRICT: an enabled host is the single source of truth. If the
|
|
197
|
+
* host yields no credential, the operator is unauthenticated — we must NOT
|
|
198
|
+
* fall back to a pushed/persisted credential left behind by an earlier
|
|
199
|
+
* standalone (auth.eda.cn) login. Otherwise a stale `~/.dsh/auth/session.json`
|
|
200
|
+
* would let the DSH plugins keep calling the backend while hq-edge itself has
|
|
201
|
+
* no auth info. The standalone fallbacks only apply when no host is configured.
|
|
197
202
|
*/
|
|
198
203
|
private async resolve(): Promise<HuaqiuUserInfo | null> {
|
|
199
204
|
if (this.host.enabled) {
|
|
200
205
|
const host = await this.host.resolve()
|
|
201
206
|
if (host) return toUserInfo(host)
|
|
207
|
+
return null
|
|
202
208
|
}
|
|
203
209
|
if (this.current) return this.current
|
|
204
210
|
return readPersisted()
|
|
@@ -235,7 +241,11 @@ export class InMemoryHuaqiuAuthService implements HuaqiuAuthService {
|
|
|
235
241
|
this.current = info
|
|
236
242
|
this.stale = false
|
|
237
243
|
this.validator.invalidate()
|
|
238
|
-
|
|
244
|
+
// Never persist to the standalone store while running under a host: the
|
|
245
|
+
// host (hq-edge) owns the credential in host mode, and a stale standalone
|
|
246
|
+
// session must not leak across modes. Persistence is only meaningful in
|
|
247
|
+
// standalone (silent-login restore).
|
|
248
|
+
if (!this.hostMode) void writePersisted(info)
|
|
239
249
|
this.emit()
|
|
240
250
|
}
|
|
241
251
|
|