dsh-plugin-update-doctor 0.5.0 → 0.5.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/README.md +65 -65
- package/client.js +337 -32
- package/docs/DETAIL.md +65 -22
- package/docs/PUBLICATION.md +36 -15
- package/docs/RELEASE_NOTES_0_5_1.md +80 -0
- package/docs/RELEASE_REVIEW_0_5_1.md +54 -0
- package/docs/SELF_UPDATE.md +7 -1
- package/docs/UNION_GENERATION_0_5_2.md +32 -0
- package/docs/V0_3_DESIGN.md +2 -0
- package/docs/VERIFICATION.md +168 -81
- package/docs/WINDOWS_REQUIREMENTS.md +48 -0
- package/docs/WINDOWS_SUPPORT.md +82 -0
- package/docs/WSL_STRUCTURAL_0_5_3.md +30 -0
- package/index.js +15 -2
- package/lib/dependency-policy.js +89 -0
- package/lib/history.js +2 -2
- package/lib/http.js +5 -1
- package/lib/identity.js +22 -3
- package/lib/online.js +44 -18
- package/lib/self-update-policy.js +90 -25
- package/lib/self-update-store.js +25 -9
- package/lib/self-update.js +92 -29
- package/lib/service.js +437 -58
- package/lib/source.js +29 -0
- package/lib/staging.js +128 -30
- package/lib/union-generation.js +376 -0
- package/lib/union-service.js +83 -0
- package/lib/union-staging.js +325 -0
- package/lib/wsl-outcome.js +15 -0
- package/lib/wsl-policy.js +71 -5
- package/lib/wsl-proof.js +85 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
package/lib/self-update.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { PUBLIC_MIRROR, approvedPublicRegistry, registryOrigin, readRegistryVersions } from './source.js';
|
|
3
|
+
import { versionDiscovery } from './online.js';
|
|
4
|
+
import { verifySelfRegistryPlan, selfRegistrySourceMode } from './self-update-policy.js';
|
|
3
5
|
import { SelfUpdateStore } from './self-update-store.js';
|
|
4
6
|
import { parseSelfGithubSource } from './self-update-github.js';
|
|
5
7
|
|
|
@@ -40,47 +42,93 @@ export class SelfUpdateCoordinator {
|
|
|
40
42
|
}
|
|
41
43
|
if (typeof this.manager.updateBundle !== 'function' || !this.taskGate || !this.preflight) throw failure('self-update-handoff-unavailable', 'Independent Host update support is unavailable.');
|
|
42
44
|
}
|
|
43
|
-
async
|
|
44
|
-
const { bundle, rows } = await this.current(); this.assertBundle(bundle, rows);
|
|
45
|
+
async discoverVersions(bundle, signal) {
|
|
45
46
|
if (bundle.update === 'git') {
|
|
46
47
|
let offered;
|
|
47
48
|
try { offered = await this.githubPreflight.discover({ bundle, signal }); }
|
|
48
49
|
catch (error) { if (error.code !== 'self-github-no-newer-version') throw error; return { status: 'listed', sourceKind: 'git', repository: parseSelfGithubSource(bundle.source).repository, versions: [] }; }
|
|
49
50
|
return { status: 'listed', sourceKind: 'git', repository: offered.repository, versions: offered.version ? [{ ...offered, bundle: true }] : [] };
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
return readRegistryVersions(this.manager, SELF_UPDATE_PACKAGE, signal);
|
|
53
|
+
}
|
|
54
|
+
async versions(signal) {
|
|
55
|
+
const { bundle, rows } = await this.current(); this.assertBundle(bundle, rows);
|
|
56
|
+
const answer = await this.discoverVersions(bundle, signal);
|
|
57
|
+
if (bundle.update !== 'git' && (answer.status !== 'listed' || !approvedPublicRegistry(answer.registry) || answer.queryReasons?.length)) throw failure('self-update-public-origin-required', 'Self-update version discovery requires verified official npm or the fixed public mirror; other sources are not migrated.');
|
|
58
|
+
if (versionDiscovery(answer).versionStatus === 'unknown') throw failure('version-metadata-incomplete', 'The version metadata is incomplete; prepare no update from it.');
|
|
53
59
|
return answer;
|
|
54
60
|
}
|
|
55
61
|
async checkOffer(bundle, offer, query, signal) {
|
|
56
62
|
const common = { bundle, currentDirectory: await this.resolvePackage(SELF_UPDATE_PACKAGE), targetVersion: offer.version, resolvedYamlVersion: await this.resolveYamlVersion(), signal };
|
|
57
63
|
if (bundle.update === 'git') return this.githubPreflight.check({ ...common, targetCommit: offer.commit });
|
|
58
|
-
|
|
64
|
+
const selectedRegistry = registryOrigin(query.registry);
|
|
65
|
+
const expectedPlan = verifySelfRegistryPlan(await this.manager.registries(), selectedRegistry);
|
|
66
|
+
const checked = await this.preflight.check({ ...common, registries: await this.manager.registries(), queryRegistry: query.registry });
|
|
67
|
+
const expectedMode = selfRegistrySourceMode(expectedPlan);
|
|
68
|
+
if (expectedMode !== 'official' && (checked.registry !== selectedRegistry || checked.sourceMode !== expectedMode
|
|
69
|
+
|| expectedMode === 'public-mirror' && checked.publicMirror !== true || expectedMode === 'public-fallback' && checked.publicFallback !== true
|
|
70
|
+
|| !checked.hostRegistryPlan)) throw failure('self-public-mirror-preflight-unverified', 'Canonical public archive verification and the bound registry/fallback plan were not provided.');
|
|
71
|
+
if (checked.hostRegistryPlan && JSON.stringify(checked.hostRegistryPlan) !== JSON.stringify(expectedPlan)) throw failure('self-registry-plan-changed', 'The registry/fallback plan changed during archive inspection.');
|
|
72
|
+
await this.checkRegistryPlan(selectedRegistry, signal, expectedPlan);
|
|
73
|
+
return { ...checked, registry: selectedRegistry, hostRegistryPlan: expectedPlan };
|
|
74
|
+
}
|
|
75
|
+
async checkRegistryPlan(registry, signal, expectedPlan) {
|
|
76
|
+
const actual = verifySelfRegistryPlan(await this.manager.registries(), registry);
|
|
77
|
+
if (expectedPlan && JSON.stringify(actual) !== JSON.stringify(expectedPlan)) throw failure('self-registry-plan-changed', 'The confirmed public registry/fallback plan changed.');
|
|
78
|
+
signal?.throwIfAborted();
|
|
79
|
+
return actual;
|
|
80
|
+
}
|
|
81
|
+
offeredVersion(query) {
|
|
82
|
+
const discovery = versionDiscovery(query);
|
|
83
|
+
if (discovery.versionStatus !== 'available') throw failure('version-not-admitted', 'A complete compatible newer version offer is required.');
|
|
84
|
+
return query.versions.find(item => item.version === discovery.latestVersion);
|
|
59
85
|
}
|
|
60
86
|
assertPrepared(actual, prepared) {
|
|
61
87
|
if (actual.previous.sha256 !== prepared.previous.sha256 || actual.next.sha256 !== prepared.next.sha256
|
|
62
88
|
|| actual.sourceKind !== prepared.sourceKind || actual.fromCommit !== prepared.fromCommit || actual.toCommit !== prepared.toCommit
|
|
89
|
+
|| actual.registry !== prepared.registry || actual.sourceMode !== prepared.sourceMode || actual.publicMirror !== prepared.publicMirror || actual.publicFallback !== prepared.publicFallback
|
|
90
|
+
|| JSON.stringify(actual.hostRegistryPlan) !== JSON.stringify(prepared.hostRegistryPlan)
|
|
63
91
|
|| actual.nextSpec !== prepared.nextSpec) throw failure('self-update-archive-changed', 'Prepared source identities or package bytes changed; prepare a new confirmation.');
|
|
64
92
|
}
|
|
65
93
|
async scan(signal) {
|
|
94
|
+
let discovery = { versionStatus:'not-checked', latestVersion:null, latestPublishedVersion:null }, registry = null, sourceMode = null;
|
|
66
95
|
try {
|
|
67
96
|
const { bundle, rows } = await this.current(); this.assertBundle(bundle, rows);
|
|
68
|
-
const query = await this.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
97
|
+
const query = await this.discoverVersions(bundle, signal);
|
|
98
|
+
discovery = versionDiscovery(query); registry = query?.registry ?? null;
|
|
99
|
+
const reasons = [...query?.queryReasons ?? []];
|
|
100
|
+
if (discovery.versionStatus === 'error') reasons.push('version-query-failed');
|
|
101
|
+
if (discovery.versionStatus === 'unknown') reasons.push('version-metadata-incomplete');
|
|
102
|
+
if (bundle.update !== 'git') {
|
|
103
|
+
if (!approvedPublicRegistry(registry)) reasons.push(registry ? 'self-update-public-origin-required' : 'self-query-origin-unverified');
|
|
104
|
+
else {
|
|
105
|
+
try { sourceMode = selfRegistrySourceMode(verifySelfRegistryPlan(await this.manager.registries(), registry)); }
|
|
106
|
+
catch (error) { if (signal?.aborted) throw error; reasons.push(error.code ?? 'self-query-origin-unverified'); }
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
try { await this.assertAvailable(); } catch (error) { reasons.push(error.code ?? 'busy'); }
|
|
110
|
+
const offered = query?.versions?.find(item => item.version === discovery.latestVersion);
|
|
111
|
+
if (!reasons.length && offered) {
|
|
112
|
+
try { await this.checkOffer(bundle, offered, query, signal); }
|
|
113
|
+
catch (error) { if (signal?.aborted) throw error; reasons.push(error.code ?? 'self-update-check-failed'); }
|
|
114
|
+
}
|
|
115
|
+
const canUpdate = !reasons.length && discovery.versionStatus === 'available';
|
|
116
|
+
const updateStatus = canUpdate ? 'available' : reasons.length ? 'blocked' : 'no-update';
|
|
117
|
+
return { name:SELF_UPDATE_PACKAGE, version:bundle.version, ...discovery, versionChecked:discovery.versionStatus !== 'error',
|
|
118
|
+
...(bundle.update === 'git' ? { sourceKind:'git', repository:query.repository, branch:'main', sourceLabel:'GitHub main HEAD (not a release)', latestCommit:offered?.commit ?? null, currentCommit:parseSelfGithubSource(bundle.source).commit } : { sourceKind:'registry', registry,
|
|
119
|
+
...(sourceMode === 'public-mirror' ? { sourceMode, publicMirror:true, mirrorRiskRequiresAcknowledgement:true, infoWarnings:['public-mirror-may-lag'] }
|
|
120
|
+
: sourceMode === 'public-fallback' ? { sourceMode, publicFallback:true, mirrorRiskRequiresAcknowledgement:true, infoWarnings:['public-fallback-may-use-mirror'] } : {}) }),
|
|
121
|
+
canUpdate, updateStatus, status:updateStatus === 'blocked' ? 'blocked' : discovery.versionStatus, mode:'host-self-update', reasons:[...new Set(reasons)] };
|
|
75
122
|
} catch (error) {
|
|
76
|
-
|
|
123
|
+
if (signal?.aborted) throw error;
|
|
124
|
+
return { name:SELF_UPDATE_PACKAGE, ...discovery, registry, canUpdate:false, updateStatus:'blocked', status:'blocked', versionChecked:false, mode:'host-self-update', reasons:[error.code ?? 'self-update-check-failed'] };
|
|
77
125
|
}
|
|
78
126
|
}
|
|
79
127
|
async validateTarget(version, signal, targetCommit) {
|
|
80
128
|
await this.assertAvailable();
|
|
81
129
|
const { bundle, rows } = await this.current(); this.assertBundle(bundle, rows);
|
|
82
130
|
const versions = await this.versions(signal);
|
|
83
|
-
const offered =
|
|
131
|
+
const offered = this.offeredVersion(versions);
|
|
84
132
|
if (offered?.version !== version || bundle.update === 'git' && targetCommit !== undefined && offered.commit !== targetCommit
|
|
85
133
|
|| bundle.update !== 'git' && targetCommit !== undefined) throw failure('version-not-admitted', 'Choose the exact offered version and commit from the latest check.');
|
|
86
134
|
const checked = await this.checkOffer(bundle, offered, versions, signal);
|
|
@@ -89,25 +137,30 @@ export class SelfUpdateCoordinator {
|
|
|
89
137
|
async prepare(version, signal, { issueTicket = true, targetCommit } = {}) {
|
|
90
138
|
if (!stable(version)) throw failure('invalid-version', 'An exact stable version is required.');
|
|
91
139
|
const { bundle, checked, fingerprint } = await this.validateTarget(version, signal, targetCommit);
|
|
92
|
-
const git = bundle.update === 'git';
|
|
93
|
-
const
|
|
140
|
+
const git = bundle.update === 'git', publicMirror = !git && checked.sourceMode === 'public-mirror', publicFallback = !git && checked.sourceMode === 'public-fallback';
|
|
141
|
+
const mirrorFields = publicMirror || publicFallback ? { registry: checked.registry, sourceMode:checked.sourceMode,
|
|
142
|
+
...(publicMirror ? { publicMirror:true } : { publicFallback:true }), mirrorRiskRequiresAcknowledgement:true, hostRegistryPlan:checked.hostRegistryPlan } : {};
|
|
143
|
+
const plan = { id: randomUUID(), operation: 'host-self-update', profile: this.profile.name, ...mirrorFields,
|
|
94
144
|
items: [{ name: SELF_UPDATE_PACKAGE, from: bundle.version, to: version, version, mode: 'host-self-update', highImpact: true,
|
|
95
|
-
...(git ? { sourceKind: 'git', repository: checked.repository, fromCommit: checked.fromCommit, toCommit: checked.toCommit } : { sourceKind: 'registry' }) }],
|
|
145
|
+
...(git ? { sourceKind: 'git', repository: checked.repository, fromCommit: checked.fromCommit, toCommit: checked.toCommit } : { sourceKind: 'registry', registry: checked.registry, ...mirrorFields }) }],
|
|
96
146
|
expiresAt: new Date(this.now() + 120000).toISOString(), taskPolicy: 'wait-for-idle', taskPolicies: ['wait-for-idle', 'cancel-active'],
|
|
97
147
|
warnings: ['This is a separate self-update, not a normal batch. The independent official Host manager performs installation and its own rollback.',
|
|
98
148
|
'Current Agent tasks are coordinated before handoff. The old gate is released when the updater unloads; new tasks are not frozen throughout Host replacement.',
|
|
99
149
|
git ? 'GitHub main HEAD is discovery, not a signed release. The confirmed full commit pins the target. The Host fetches it again; preflight is not an atomic byte replacement.' : 'Downloaded old/new archives are preflight evidence only. The Host downloads registry packages again; it has no exact-archive replacement or atomic compare-and-swap API.',
|
|
100
150
|
...(git ? ['GitHub package dependencies use the existing Host registry configuration. No registry migration or build-script approval is granted; Host restoration uses the old saved commit and is verified separately.'] : []),
|
|
151
|
+
...(publicMirror ? ['The fixed public mirror may lag. Its prepared updater bytes must match canonical official npm archives, but the Host downloads again and may use existing known-public fallback/dependency sources. This is not a public-only atomic archive replacement or a guarantee of successful installation/recovery. Confirm this mirror risk separately; no source configuration is changed.'] : []),
|
|
152
|
+
...(publicFallback ? ['Official npm is the query source, while the displayed existing public plan permits fallback. Potential mirror updater archives are compared with canonical npm before confirmation. The Host refetches and may use those public fallbacks; no global source is changed, no exact-byte transaction is promised, and fallback risk requires separate consent.'] : []),
|
|
101
153
|
'The panel may disappear and reload. Missing final evidence remains unknown and is never automatically retried. If both installation and Host recovery fail, use the official manager.'] };
|
|
102
154
|
if (!issueTicket) return this.redact(plan);
|
|
103
155
|
const ticket = randomUUID(); this.tickets.clear(); this.tickets.set(ticket, { plan, checked, fingerprint });
|
|
104
156
|
return this.redact({ ...plan, ticket });
|
|
105
157
|
}
|
|
106
158
|
hasTicket(ticket) { return this.tickets.has(ticket); }
|
|
107
|
-
async commit(ticket, { taskPolicy = 'wait-for-idle', confirmCancel = false } = {}) {
|
|
159
|
+
async commit(ticket, { taskPolicy = 'wait-for-idle', confirmCancel = false, confirmPublicMirror = false } = {}) {
|
|
108
160
|
const prepared = this.tickets.get(ticket); this.tickets.delete(ticket);
|
|
109
161
|
if (!prepared || this.now() >= Date.parse(prepared.plan.expiresAt)) throw failure('stale-confirmation', 'Self-update confirmation expired; prepare again.');
|
|
110
162
|
if (!['wait-for-idle', 'cancel-active'].includes(taskPolicy) || taskPolicy === 'cancel-active' && confirmCancel !== true) throw failure('task-confirmation-required', 'Stopping tasks requires separate explicit consent.');
|
|
163
|
+
if (['public-mirror','public-fallback'].includes(prepared.checked.sourceMode) && confirmPublicMirror !== true) throw failure('self-public-mirror-confirmation-required', 'The public mirror/fallback risk requires separate explicit consent.');
|
|
111
164
|
await this.assertAvailable();
|
|
112
165
|
const { bundle, rows } = await this.current(); this.assertBundle(bundle, rows);
|
|
113
166
|
if (this.fingerprint(bundle) !== prepared.fingerprint) throw failure('state-changed', 'The updater changed since confirmation preparation.');
|
|
@@ -118,22 +171,26 @@ export class SelfUpdateCoordinator {
|
|
|
118
171
|
try {
|
|
119
172
|
const source = prepared.checked.sourceKind === 'git'
|
|
120
173
|
? { sourceKind: 'git', repository: prepared.checked.repository, fromCommit: prepared.checked.fromCommit, toCommit: prepared.checked.toCommit }
|
|
121
|
-
: { registry:
|
|
174
|
+
: { registry: prepared.checked.registry, ...(prepared.checked.sourceMode === 'public-mirror'
|
|
175
|
+
? { sourceMode:'public-mirror', publicMirror:true, confirmPublicMirror:true, hostRegistryPlan:prepared.checked.hostRegistryPlan }
|
|
176
|
+
: prepared.checked.sourceMode === 'public-fallback'
|
|
177
|
+
? { sourceMode:'public-fallback', publicFallback:true, confirmPublicMirror:true, hostRegistryPlan:prepared.checked.hostRegistryPlan } : {}) };
|
|
122
178
|
await this.store.start({ id, name: SELF_UPDATE_PACKAGE, from: bundle.version, to: prepared.plan.items[0].to, ...source, startedAt: new Date(this.now()).toISOString(), taskPolicy, confirmCancel: taskPolicy === 'cancel-active', previousSha256: prepared.checked.previous.sha256, nextSha256: prepared.checked.next.sha256,
|
|
123
179
|
...(prepared.checked.previous.files ? { previousFiles: prepared.checked.previous.files } : {}), ...(prepared.checked.next.files ? { nextFiles: prepared.checked.next.files } : {}) });
|
|
124
180
|
} catch (error) { this.job = null; throw error; }
|
|
125
|
-
job.work = this.run(job, { taskPolicy, confirmCancel }).finally(() => { if (this.job === job) this.job = null; });
|
|
181
|
+
job.work = this.run(job, { taskPolicy, confirmCancel, confirmPublicMirror }).finally(() => { if (this.job === job) this.job = null; });
|
|
126
182
|
job.work.catch(() => {});
|
|
127
183
|
return { operationId: id, operation: 'host-self-update', phase: 'waiting' };
|
|
128
184
|
}
|
|
129
185
|
async run(job, policy) {
|
|
130
186
|
try {
|
|
131
187
|
// Recheck source, bytes and state before task cancellation and before any mutation.
|
|
188
|
+
if (['public-mirror','public-fallback'].includes(job.prepared.checked.sourceMode) && policy.confirmPublicMirror !== true) throw failure('self-public-mirror-confirmation-required', 'The confirmed public mirror/fallback risk consent is missing.');
|
|
132
189
|
const target = job.prepared.plan.items[0].to;
|
|
133
190
|
const { bundle, rows } = await this.current(); this.assertBundle(bundle, rows);
|
|
134
191
|
if (this.fingerprint(bundle) !== job.prepared.fingerprint || this.unavailable()) throw failure('state-changed', 'Updater state changed before handoff.');
|
|
135
192
|
const query = await this.versions(job.controller.signal);
|
|
136
|
-
const offeredBeforeTasks =
|
|
193
|
+
const offeredBeforeTasks = this.offeredVersion(query);
|
|
137
194
|
if (offeredBeforeTasks?.version !== target || offeredBeforeTasks?.commit !== job.prepared.checked.toCommit) throw failure('version-not-admitted', 'Self-update offer changed before task handling.');
|
|
138
195
|
const checked = await this.checkOffer(bundle, offeredBeforeTasks, query, job.controller.signal);
|
|
139
196
|
this.assertPrepared(checked, job.prepared.checked);
|
|
@@ -143,7 +200,7 @@ export class SelfUpdateCoordinator {
|
|
|
143
200
|
const current = await this.current(); this.assertBundle(current.bundle, current.rows);
|
|
144
201
|
if (this.fingerprint(current.bundle) !== job.prepared.fingerprint || this.unavailable() || this.closed) throw failure('state-changed', 'Updater changed while waiting.');
|
|
145
202
|
const refreshedQuery = await this.versions(gateSignal);
|
|
146
|
-
const refreshedOffered =
|
|
203
|
+
const refreshedOffered = this.offeredVersion(refreshedQuery);
|
|
147
204
|
if (refreshedOffered?.version !== target || refreshedOffered?.commit !== job.prepared.checked.toCommit) throw failure('version-not-admitted', 'Self-update offer changed while waiting.');
|
|
148
205
|
const refreshed = await this.checkOffer(current.bundle, refreshedOffered, refreshedQuery, gateSignal);
|
|
149
206
|
this.assertPrepared(refreshed, job.prepared.checked);
|
|
@@ -153,10 +210,13 @@ export class SelfUpdateCoordinator {
|
|
|
153
210
|
await this.store.markHandedOff(job.id);
|
|
154
211
|
gateSignal.throwIfAborted();
|
|
155
212
|
if (this.closed || this.unavailable()) throw failure('state-changed', 'Updater unloaded during handoff.');
|
|
213
|
+
if (refreshed.sourceKind !== 'git') await this.checkRegistryPlan(refreshedQuery.registry, gateSignal, job.prepared.checked.hostRegistryPlan);
|
|
214
|
+
gateSignal.throwIfAborted();
|
|
215
|
+
if (this.closed || this.unavailable()) throw failure('state-changed', 'Updater changed during the final source check.');
|
|
156
216
|
job.phase = 'handed-off'; job.dispatched = true;
|
|
157
217
|
// Capture the public manager method once. Its own ownerContext performs the package flow.
|
|
158
218
|
const manager = this.manager;
|
|
159
|
-
const options = refreshed.sourceKind === 'git' ? { spec: refreshed.nextSpec, requestId: job.id } : { registry:
|
|
219
|
+
const options = refreshed.sourceKind === 'git' ? { spec: refreshed.nextSpec, requestId: job.id } : { registry: job.prepared.checked.registry, requestId: job.id };
|
|
160
220
|
const result = await manager.updateBundle(SELF_UPDATE_PACKAGE, target, options);
|
|
161
221
|
// The sole post-unload work is bounded sanitized evidence persistence.
|
|
162
222
|
await this.store.finish(job.id, result);
|
|
@@ -175,12 +235,13 @@ export class SelfUpdateCoordinator {
|
|
|
175
235
|
const entry = id ? await this.store.read(id) : await this.store.latest();
|
|
176
236
|
if (!entry?.attempt) return entry;
|
|
177
237
|
const current = await this.current();
|
|
178
|
-
const git = entry.attempt.sourceKind === 'git';
|
|
238
|
+
const git = entry.attempt.sourceKind === 'git', publicMirror = ['public-mirror','public-fallback'].includes(entry.attempt.sourceMode);
|
|
179
239
|
const verify = async (version, files, expectedCommit) => {
|
|
180
|
-
let packageStatus = 'unknown', sourceStatus = git ? 'unknown' : undefined;
|
|
240
|
+
let packageStatus = 'unknown', sourceStatus = git || publicMirror ? 'unknown' : undefined;
|
|
181
241
|
if (git) {
|
|
182
242
|
try { sourceStatus = current.bundle?.update === 'git' && parseSelfGithubSource(current.bundle.source).commit === expectedCommit ? 'verified' : 'failed'; } catch { sourceStatus = 'failed'; }
|
|
183
|
-
}
|
|
243
|
+
} else if(publicMirror) sourceStatus=current.bundle?.installed===true && current.bundle.update==='registry'
|
|
244
|
+
&& current.bundle.version===version && current.bundle.source===`${SELF_UPDATE_PACKAGE}@${version}`?'verified':'failed';
|
|
184
245
|
const verifier = git ? this.githubPreflight : this.preflight;
|
|
185
246
|
if (current.bundle?.version === version && files && typeof verifier?.verifyInstalled === 'function') {
|
|
186
247
|
try {
|
|
@@ -192,11 +253,13 @@ export class SelfUpdateCoordinator {
|
|
|
192
253
|
const expectedRows = current.rows.length === 1 && current.rows[0].moduleName === SELF_UPDATE_PACKAGE && (current.rows[0].patchId === 'plugin-update-doctor' || current.rows[0].entryId === 'include:plugin-update-doctor');
|
|
193
254
|
const hostStatus = current.bundle?.version === version && expectedRows && current.rows.every(row => row.enabled && row.fiberPhase === 'active') ? 'active' : 'unknown';
|
|
194
255
|
return { package: { status: packageStatus, version: current.bundle?.version ?? null, expectedVersion: version }, host: { status: hostStatus, activeRows: current.rows.filter(row => row.enabled && row.fiberPhase === 'active').length, totalRows: current.rows.length },
|
|
195
|
-
...(git ? { source: { status: sourceStatus, repository: entry.attempt.repository, expectedCommit } } :
|
|
256
|
+
...(git ? { source: { status: sourceStatus, repository: entry.attempt.repository, expectedCommit } } : publicMirror ?
|
|
257
|
+
{ source:{status:sourceStatus,expectedKind:'registry',kind:current.bundle?.update??'unknown',confirmedRegistry:entry.attempt.registry,sourceMode:entry.attempt.sourceMode,
|
|
258
|
+
...(entry.attempt.sourceMode === 'public-mirror' ? {publicMirror:true} : {publicFallback:true}),transportVerified:false} } : {}) };
|
|
196
259
|
};
|
|
197
260
|
const verification = await verify(entry.attempt.to, entry.attempt.nextFiles, entry.attempt.toCommit);
|
|
198
261
|
const restoreVerification = entry.result?.restore ? await verify(entry.attempt.from, entry.attempt.previousFiles, entry.attempt.fromCommit) : undefined;
|
|
199
|
-
const verifiedApplied = entry.result?.result?.application === 'applied' && verification.package.status === 'verified' && verification.host.status === 'active' && (!git || verification.source.status === 'verified');
|
|
262
|
+
const verifiedApplied = entry.result?.result?.application === 'applied' && verification.package.status === 'verified' && verification.host.status === 'active' && (!(git || publicMirror) || verification.source.status === 'verified');
|
|
200
263
|
return { ...entry, verification, restoreVerification, verifiedApplied };
|
|
201
264
|
}
|
|
202
265
|
async dispose() {
|