package-registry-manager 0.25.0 → 0.26.0
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 +5 -0
- package/package.json +3 -3
- package/src/audit-config.mjs +96 -0
- package/src/bootstrap-recovery.mjs +163 -0
- package/src/cpp-distribution.mjs +164 -0
- package/src/credential-cycle.mjs +8 -3
- package/src/credential-requirements.mjs +105 -0
- package/src/default-browser.mjs +1 -1
- package/src/default-scope.mjs +1 -1
- package/src/discovery.mjs +289 -24
- package/src/distribution-channel.mjs +87 -0
- package/src/exec.mjs +20 -0
- package/src/extra-flows.mjs +122 -2
- package/src/flows.mjs +19 -3
- package/src/generated-artifact.mjs +48 -0
- package/src/github.mjs +4 -0
- package/src/identity-conflicts.mjs +130 -0
- package/src/manifest-proposal.mjs +1 -1
- package/src/model.mjs +6 -0
- package/src/npm-release.mjs +68 -0
- package/src/nuget-ci.mjs +238 -0
- package/src/nuget-migration.mjs +275 -0
- package/src/nuget-page.mjs +100 -0
- package/src/nuget-policy.mjs +198 -0
- package/src/nuget-publish.py +145 -0
- package/src/nuget-setup.mjs +169 -0
- package/src/nuget-workflow.mjs +54 -0
- package/src/organization-scan.mjs +41 -2
- package/src/pack-review.mjs +122 -0
- package/src/package-coverage.mjs +33 -9
- package/src/plan.mjs +35 -9
- package/src/prerequisites.mjs +1 -1
- package/src/profile.mjs +1 -1
- package/src/publication-state.mjs +299 -0
- package/src/publishers.mjs +78 -12
- package/src/publishing-policy.mjs +7 -1
- package/src/publishing-state.mjs +74 -1
- package/src/python.mjs +1 -1
- package/src/registry-state.mjs +118 -3
- package/src/release-runs.mjs +3 -4
- package/src/setup-batch.mjs +48 -2
- package/src/setup.mjs +82 -120
- package/src/sign-in-import.mjs +132 -40
- package/src/skips.mjs +9 -1
- package/src/source-code.mjs +1 -1
- package/src/tokens.mjs +32 -4
- package/src/workflow-migration.mjs +15 -2
- package/src/workflow-proposal.mjs +6 -2
package/src/setup.mjs
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
recordPack,
|
|
3
|
+
reportPackWarnings,
|
|
4
|
+
binEntries,
|
|
5
|
+
readManifest,
|
|
6
|
+
} from "./pack-review.mjs";
|
|
7
|
+
export {
|
|
8
|
+
packedEntry,
|
|
9
|
+
packWarnings,
|
|
10
|
+
developmentDirectories,
|
|
11
|
+
} from "./pack-review.mjs";
|
|
12
|
+
import { prepareGeneratedArtifact } from "./generated-artifact.mjs";
|
|
13
|
+
import { bootstrapNames, recoverBootstrap } from "./bootstrap-recovery.mjs";
|
|
14
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
2
15
|
import os from "node:os";
|
|
3
16
|
import path from "node:path";
|
|
4
17
|
import { createInterface } from "node:readline/promises";
|
|
5
18
|
import { stdin, stdout, stderr } from "node:process";
|
|
6
19
|
|
|
7
|
-
import { exec } from "
|
|
20
|
+
import { exec } from "./exec.mjs";
|
|
8
21
|
|
|
9
22
|
import {
|
|
10
23
|
ANSI,
|
|
@@ -81,6 +94,17 @@ export class SetupSession {
|
|
|
81
94
|
for (const step of this.plan.steps) {
|
|
82
95
|
if (CLEANUP_CONDITIONS.has(step.when)) {
|
|
83
96
|
// cleanup() runs these, even after a failed step.
|
|
97
|
+
} else if (
|
|
98
|
+
this.recoveryQueued &&
|
|
99
|
+
[
|
|
100
|
+
"trigger-release",
|
|
101
|
+
"find-release-run",
|
|
102
|
+
"watch-release",
|
|
103
|
+
"wait-for-release",
|
|
104
|
+
].includes(step.id)
|
|
105
|
+
) {
|
|
106
|
+
this.pendingReleaseSteps ??= [];
|
|
107
|
+
this.pendingReleaseSteps.push(step);
|
|
84
108
|
} else if (!step.when || this.conditions.has(step.when)) {
|
|
85
109
|
this.log(`==> ${step.title}`);
|
|
86
110
|
await this.runStep(step);
|
|
@@ -136,7 +160,11 @@ export class SetupSession {
|
|
|
136
160
|
if (this.automation && closeBrowser) {
|
|
137
161
|
await this.automation.close();
|
|
138
162
|
}
|
|
139
|
-
for (const directory of [
|
|
163
|
+
for (const directory of [
|
|
164
|
+
this.temporary,
|
|
165
|
+
this.shim?.directory,
|
|
166
|
+
...(closeBrowser ? (this.importProfiles ?? []) : []),
|
|
167
|
+
]) {
|
|
140
168
|
if (directory) {
|
|
141
169
|
await rm(directory, { recursive: true, force: true });
|
|
142
170
|
}
|
|
@@ -156,6 +184,23 @@ export class SetupSession {
|
|
|
156
184
|
}
|
|
157
185
|
|
|
158
186
|
async runStep(step) {
|
|
187
|
+
if (step.id === "audit-distribution-channel") {
|
|
188
|
+
const { auditDistributionChannel } =
|
|
189
|
+
await import("./distribution-channel.mjs");
|
|
190
|
+
return auditDistributionChannel(this);
|
|
191
|
+
}
|
|
192
|
+
if (step.id === "verify-nuget-release") {
|
|
193
|
+
if (this.options.nugetQueue) {
|
|
194
|
+
this.options.nugetQueue.push(this);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const { verifyNugetRelease } = await import("./nuget-ci.mjs");
|
|
198
|
+
return verifyNugetRelease(this);
|
|
199
|
+
}
|
|
200
|
+
if (step.id === "configure-nuget-policy") {
|
|
201
|
+
const { configureNuget } = await import("./nuget-setup.mjs");
|
|
202
|
+
return configureNuget(this);
|
|
203
|
+
}
|
|
159
204
|
if (step.id === "rotate-crates-token") {
|
|
160
205
|
return rotateCratesToken(this);
|
|
161
206
|
}
|
|
@@ -175,6 +220,9 @@ export class SetupSession {
|
|
|
175
220
|
}
|
|
176
221
|
switch (step.kind) {
|
|
177
222
|
case "check":
|
|
223
|
+
if (step.id === "prepare-generated-artifact") {
|
|
224
|
+
return prepareGeneratedArtifact(this);
|
|
225
|
+
}
|
|
178
226
|
if (step.id === "build-package" && this.plan.registry === "pypi") {
|
|
179
227
|
return buildPythonDistribution(
|
|
180
228
|
step.command.program,
|
|
@@ -296,6 +344,12 @@ export class SetupSession {
|
|
|
296
344
|
case "read-release-failure":
|
|
297
345
|
if (result.code !== 0) {
|
|
298
346
|
console.error("warning: could not read the failed release log");
|
|
347
|
+
} else if (bootstrapNames(output).length) {
|
|
348
|
+
this.bootstrapNames = bootstrapNames(output);
|
|
349
|
+
this.conditions.add("release-failed-publish");
|
|
350
|
+
console.log(
|
|
351
|
+
` Bootstrap preflight requires ${this.bootstrapNames.join(", ")}; fresh existence and publisher checks are required before retry.`,
|
|
352
|
+
);
|
|
299
353
|
} else if (PUBLISH_REJECTED.test(output)) {
|
|
300
354
|
console.log(
|
|
301
355
|
" It failed at publish: the registry rejected the workflow's trusted publishing identity (OIDC/E404/invalid-publisher). After attaching trust, its failed jobs can be re-run.",
|
|
@@ -512,6 +566,14 @@ export class SetupSession {
|
|
|
512
566
|
this.values.pack_destination = this.temporary;
|
|
513
567
|
}
|
|
514
568
|
if (step.id === "rerun-release" && this.releaseSelection?.run) {
|
|
569
|
+
if (this.bootstrapNames?.length) {
|
|
570
|
+
if (this.options.recoveryQueue) {
|
|
571
|
+
this.recoveryQueued = true;
|
|
572
|
+
this.options.recoveryQueue.push({ session: this, step });
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
return recoverBootstrap(this);
|
|
576
|
+
}
|
|
515
577
|
console.log(
|
|
516
578
|
` Re-running failed release jobs: ${this.releaseSelection.run.url}`,
|
|
517
579
|
);
|
|
@@ -564,6 +626,9 @@ export class SetupSession {
|
|
|
564
626
|
`${step.command.program} exited with status ${result.code}`,
|
|
565
627
|
);
|
|
566
628
|
}
|
|
629
|
+
if (step.id === "first-publish") {
|
|
630
|
+
this.recordRecoveryChange();
|
|
631
|
+
}
|
|
567
632
|
if (step.id === "attach-trusted-publisher") {
|
|
568
633
|
this.confirmTrustCreated(result.stdout);
|
|
569
634
|
} else if (step.id === "sign-in") {
|
|
@@ -584,41 +649,27 @@ export class SetupSession {
|
|
|
584
649
|
* npm prints the stored configuration once `npm trust github` succeeds, so
|
|
585
650
|
* that answer verifies it without a second 2FA-gated `npm trust list`.
|
|
586
651
|
*/
|
|
652
|
+
recordRecoveryChange() {
|
|
653
|
+
const publisher = this.plan.trusted_publisher;
|
|
654
|
+
if (!publisher || !this.options.recoveryChanges) {
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
const key = `${publisher.organization}/${publisher.repository}:${publisher.workflow}`;
|
|
658
|
+
const changes = this.options.recoveryChanges.get(key) ?? [];
|
|
659
|
+
changes.push(this.plan.package.name);
|
|
660
|
+
this.options.recoveryChanges.set(key, changes);
|
|
661
|
+
}
|
|
662
|
+
|
|
587
663
|
confirmTrustCreated(output) {
|
|
588
664
|
if (TRUST_CREATED.test(stripAnsi(output))) {
|
|
665
|
+
this.recordRecoveryChange();
|
|
589
666
|
console.log(" npm stored the trusted publisher.");
|
|
590
667
|
this.conditions.delete("trust-missing");
|
|
591
668
|
}
|
|
592
669
|
}
|
|
593
670
|
|
|
594
671
|
recordPack(output) {
|
|
595
|
-
|
|
596
|
-
if (
|
|
597
|
-
packed.name !== this.plan.package.name ||
|
|
598
|
-
(this.plan.package.version &&
|
|
599
|
-
packed.version !== this.plan.package.version)
|
|
600
|
-
) {
|
|
601
|
-
throw new Error(
|
|
602
|
-
"bootstrap ref package identity/version differs from inspection; inspect the selected ref again before publication",
|
|
603
|
-
);
|
|
604
|
-
}
|
|
605
|
-
for (const file of packed.files ?? []) {
|
|
606
|
-
console.log(` ${String(file.size).padStart(8)} ${file.path}`);
|
|
607
|
-
}
|
|
608
|
-
console.log(
|
|
609
|
-
` ${packed.filename}: ${packed.size} bytes packed, ${packed.unpackedSize} bytes unpacked, ${packed.entryCount} files`,
|
|
610
|
-
);
|
|
611
|
-
const development = developmentDirectories(packed);
|
|
612
|
-
if (development.length > 0) {
|
|
613
|
-
throw new Error(
|
|
614
|
-
`the package would publish repository development files (${development.join(", ")}); add a "files" allowlist to package.json, commit it to the published ref, and re-run. Nothing was published.`,
|
|
615
|
-
);
|
|
616
|
-
}
|
|
617
|
-
this.values.tarball = path.join(
|
|
618
|
-
this.values.pack_destination,
|
|
619
|
-
packed.filename,
|
|
620
|
-
);
|
|
621
|
-
this.values.version = packed.version;
|
|
672
|
+
recordPack(this, output);
|
|
622
673
|
}
|
|
623
674
|
|
|
624
675
|
async wait(step) {
|
|
@@ -714,7 +765,7 @@ export class SetupSession {
|
|
|
714
765
|
this.options.connectAutomation ?? connectAutomation
|
|
715
766
|
)({
|
|
716
767
|
browser: await launchBrowser(browser, domains, {
|
|
717
|
-
deferred:
|
|
768
|
+
deferred: ["crates-io", "nuget"].includes(this.plan.registry),
|
|
718
769
|
verbose: quiet ? false : this.options.verbose,
|
|
719
770
|
...this.options.importDiscovery,
|
|
720
771
|
}),
|
|
@@ -875,95 +926,6 @@ function stripAnsi(text) {
|
|
|
875
926
|
return String(text ?? "").replaceAll(ANSI, "");
|
|
876
927
|
}
|
|
877
928
|
|
|
878
|
-
/**
|
|
879
|
-
* npm's warnings from `npm pack`, such as fields it auto-corrected or removed
|
|
880
|
-
* from the packed package.json, without npm's advice to run its fixer, which
|
|
881
|
-
* rewrites package.json in place.
|
|
882
|
-
*/
|
|
883
|
-
export function packWarnings(stderr) {
|
|
884
|
-
return String(stderr ?? "")
|
|
885
|
-
.split(/\r?\n/)
|
|
886
|
-
.map((line) => line.replaceAll(ANSI, "").trim())
|
|
887
|
-
.filter((line) => /^npm warn/i.test(line))
|
|
888
|
-
.map((line) =>
|
|
889
|
-
line.replace(/\s*Please run "npm pkg fix"[^.]*\.?/i, "").trim(),
|
|
890
|
-
)
|
|
891
|
-
.filter((line) => !/npm pkg fix/i.test(line));
|
|
892
|
-
}
|
|
893
|
-
|
|
894
|
-
/**
|
|
895
|
-
* The first package in `npm pack --json` output: an array before npm 12, an
|
|
896
|
-
* object keyed by package name since.
|
|
897
|
-
*/
|
|
898
|
-
export function packedEntry(output) {
|
|
899
|
-
const parsed = JSON.parse(output);
|
|
900
|
-
const [packed] = Array.isArray(parsed) ? parsed : Object.values(parsed ?? {});
|
|
901
|
-
if (!packed) {
|
|
902
|
-
throw new Error("npm pack printed no package");
|
|
903
|
-
}
|
|
904
|
-
return packed;
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
/**
|
|
908
|
-
* Top-level repository directories of development files: CI, tests, and
|
|
909
|
-
* editor and build state, which belong in no published package.
|
|
910
|
-
*/
|
|
911
|
-
const DEVELOPMENT_DIRECTORIES = new Set([
|
|
912
|
-
".changeset",
|
|
913
|
-
".github",
|
|
914
|
-
".husky",
|
|
915
|
-
".idea",
|
|
916
|
-
".vscode",
|
|
917
|
-
"__tests__",
|
|
918
|
-
"coverage",
|
|
919
|
-
"experiments",
|
|
920
|
-
"target",
|
|
921
|
-
"test",
|
|
922
|
-
"tests",
|
|
923
|
-
]);
|
|
924
|
-
|
|
925
|
-
/**
|
|
926
|
-
* The development directories a packed tarball contains, as `name/`, which
|
|
927
|
-
* a package.json without a `files` allowlist lets in.
|
|
928
|
-
*/
|
|
929
|
-
export function developmentDirectories(packed) {
|
|
930
|
-
const found = new Set();
|
|
931
|
-
for (const file of packed.files ?? []) {
|
|
932
|
-
const [top, ...rest] = String(file.path).split("/");
|
|
933
|
-
if (rest.length > 0 && DEVELOPMENT_DIRECTORIES.has(top)) {
|
|
934
|
-
found.add(`${top}/`);
|
|
935
|
-
}
|
|
936
|
-
}
|
|
937
|
-
return [...found].sort();
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
function reportPackWarnings(stderr) {
|
|
941
|
-
const warnings = packWarnings(stderr);
|
|
942
|
-
if (warnings.length === 0) {
|
|
943
|
-
return;
|
|
944
|
-
}
|
|
945
|
-
console.log(" npm warned while packing:");
|
|
946
|
-
for (const line of warnings) {
|
|
947
|
-
console.log(` ${line}`);
|
|
948
|
-
}
|
|
949
|
-
if (warnings.some((line) => /corrected|invalid and removed/i.test(line))) {
|
|
950
|
-
console.log(
|
|
951
|
-
" npm changed the packed package.json; correct these fields in package.json itself.",
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
function binEntries(manifest) {
|
|
957
|
-
if (typeof manifest.bin === "string") {
|
|
958
|
-
return { [String(manifest.name).replace(/^@[^/]+\//, "")]: manifest.bin };
|
|
959
|
-
}
|
|
960
|
-
return manifest.bin && typeof manifest.bin === "object" ? manifest.bin : {};
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
async function readManifest(file) {
|
|
964
|
-
return JSON.parse(await readFile(file, "utf8"));
|
|
965
|
-
}
|
|
966
|
-
|
|
967
929
|
function isTrustedRelease(document, values) {
|
|
968
930
|
return (
|
|
969
931
|
Boolean(document._npmUser?.trustedPublisher) &&
|
package/src/sign-in-import.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// saved logins when no cookies exist. Credential values are never logged;
|
|
5
5
|
// discovery counts them through Browser Commander.
|
|
6
6
|
import * as commander from "browser-commander";
|
|
7
|
-
import { mkdtemp, rm } from "node:fs/promises";
|
|
7
|
+
import { mkdtemp, rm, realpath } from "node:fs/promises";
|
|
8
8
|
import os from "node:os";
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { detachedRunner } from "./browser.mjs";
|
|
@@ -38,7 +38,17 @@ export function importSources() {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/** The sign-in domains of a registry, or none. */
|
|
41
|
-
export function signInDomains(registry) {
|
|
41
|
+
export function signInDomains(registry, route = "work") {
|
|
42
|
+
if (registry === "nuget") {
|
|
43
|
+
return [
|
|
44
|
+
"nuget.org",
|
|
45
|
+
route === "personal"
|
|
46
|
+
? "login.live.com"
|
|
47
|
+
: route === "github"
|
|
48
|
+
? "github.com"
|
|
49
|
+
: "login.microsoftonline.com",
|
|
50
|
+
];
|
|
51
|
+
}
|
|
42
52
|
return SIGN_IN_DOMAINS[registry] ?? [];
|
|
43
53
|
}
|
|
44
54
|
|
|
@@ -83,6 +93,7 @@ export async function findSignInSources(domains, options = {}) {
|
|
|
83
93
|
(left, right) => Number(right === preferred) - Number(left === preferred),
|
|
84
94
|
);
|
|
85
95
|
const found = [];
|
|
96
|
+
const physical = new Set();
|
|
86
97
|
let accessReported = false;
|
|
87
98
|
const report = async (browser, error) => {
|
|
88
99
|
if (
|
|
@@ -114,11 +125,28 @@ export async function findSignInSources(domains, options = {}) {
|
|
|
114
125
|
return [];
|
|
115
126
|
});
|
|
116
127
|
for (const profile of profiles) {
|
|
128
|
+
const location = profile.path
|
|
129
|
+
? await realpath(profile.path).catch(() => path.resolve(profile.path))
|
|
130
|
+
: `${browser}:${profile.name}`;
|
|
131
|
+
if (physical.has(location)) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
physical.add(location);
|
|
117
135
|
if (profile.error) {
|
|
136
|
+
options.diagnostic?.({
|
|
137
|
+
browser,
|
|
138
|
+
profile: profile.name,
|
|
139
|
+
cookies: "unreadable",
|
|
140
|
+
passkey_presence: "unknown",
|
|
141
|
+
provider_availability: "unknown",
|
|
142
|
+
passkey_export: "unsupported",
|
|
143
|
+
authentication: "not-yet-verified",
|
|
144
|
+
});
|
|
118
145
|
await report(browser, new Error(profile.error));
|
|
119
146
|
continue;
|
|
120
147
|
}
|
|
121
148
|
const matched = [];
|
|
149
|
+
let unreadable = false;
|
|
122
150
|
for (const domain of domains) {
|
|
123
151
|
const cookies = await read({
|
|
124
152
|
browser,
|
|
@@ -127,6 +155,7 @@ export async function findSignInSources(domains, options = {}) {
|
|
|
127
155
|
ignoreDecryptionErrors: true,
|
|
128
156
|
cache: false,
|
|
129
157
|
}).catch(async (error) => {
|
|
158
|
+
unreadable = true;
|
|
130
159
|
await report(browser, error);
|
|
131
160
|
return [];
|
|
132
161
|
});
|
|
@@ -134,6 +163,19 @@ export async function findSignInSources(domains, options = {}) {
|
|
|
134
163
|
matched.push(domain);
|
|
135
164
|
}
|
|
136
165
|
}
|
|
166
|
+
options.diagnostic?.({
|
|
167
|
+
browser,
|
|
168
|
+
profile: profile.name,
|
|
169
|
+
cookies: unreadable
|
|
170
|
+
? "unreadable"
|
|
171
|
+
: matched.length
|
|
172
|
+
? "present"
|
|
173
|
+
: "not-found",
|
|
174
|
+
passkey_presence: "unknown",
|
|
175
|
+
provider_availability: "unknown",
|
|
176
|
+
passkey_export: "unsupported",
|
|
177
|
+
authentication: "not-yet-verified",
|
|
178
|
+
});
|
|
137
179
|
if (matched.length > 0) {
|
|
138
180
|
const name = profile.displayName ?? profile.name;
|
|
139
181
|
found.push({
|
|
@@ -169,6 +211,7 @@ export async function findSavedLoginSources(domains, options = {}) {
|
|
|
169
211
|
Number(b === options.defaultSource) - Number(a === options.defaultSource),
|
|
170
212
|
);
|
|
171
213
|
const found = [];
|
|
214
|
+
const physical = new Set();
|
|
172
215
|
const installed = [];
|
|
173
216
|
for (const browser of browsers) {
|
|
174
217
|
const profiles = await list({ browser }).catch(() => []);
|
|
@@ -176,6 +219,13 @@ export async function findSavedLoginSources(domains, options = {}) {
|
|
|
176
219
|
installed.push(sourceName(browser));
|
|
177
220
|
}
|
|
178
221
|
for (const profile of profiles) {
|
|
222
|
+
const location = profile.path
|
|
223
|
+
? await realpath(profile.path).catch(() => path.resolve(profile.path))
|
|
224
|
+
: `${browser}:${profile.name}`;
|
|
225
|
+
if (physical.has(location)) {
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
physical.add(location);
|
|
179
229
|
const directory = await mkdtemp(
|
|
180
230
|
path.join(os.tmpdir(), "prm-login-probe-"),
|
|
181
231
|
);
|
|
@@ -187,6 +237,17 @@ export async function findSavedLoginSources(domains, options = {}) {
|
|
|
187
237
|
domains,
|
|
188
238
|
targetBrowser: options.targetBrowser ?? "chrome",
|
|
189
239
|
});
|
|
240
|
+
options.diagnostic?.({
|
|
241
|
+
browser,
|
|
242
|
+
profile: profile.name,
|
|
243
|
+
saved_passwords:
|
|
244
|
+
report.migrated.passwords > 0 ? "present" : "unknown",
|
|
245
|
+
passkey_presence:
|
|
246
|
+
report.migrated.passkeys > 0 ? "present" : "unknown",
|
|
247
|
+
provider_availability: "unknown",
|
|
248
|
+
passkey_export: "unsupported",
|
|
249
|
+
authentication: "not-yet-verified",
|
|
250
|
+
});
|
|
190
251
|
if (report.migrated.passwords > 0 || report.migrated.passkeys > 0) {
|
|
191
252
|
found.push({
|
|
192
253
|
browser,
|
|
@@ -197,6 +258,15 @@ export async function findSavedLoginSources(domains, options = {}) {
|
|
|
197
258
|
});
|
|
198
259
|
}
|
|
199
260
|
} catch {
|
|
261
|
+
options.diagnostic?.({
|
|
262
|
+
browser,
|
|
263
|
+
profile: profile.name,
|
|
264
|
+
saved_passwords: "unreadable",
|
|
265
|
+
passkey_presence: "unknown",
|
|
266
|
+
provider_availability: "unknown",
|
|
267
|
+
passkey_export: "unsupported",
|
|
268
|
+
authentication: "not-yet-verified",
|
|
269
|
+
});
|
|
200
270
|
if (options.verbose) {
|
|
201
271
|
console.error(
|
|
202
272
|
`saved-login import unavailable from ${sourceName(browser)}`,
|
|
@@ -209,7 +279,7 @@ export async function findSavedLoginSources(domains, options = {}) {
|
|
|
209
279
|
}
|
|
210
280
|
if (!found.length) {
|
|
211
281
|
(options.warn ?? console.error)(
|
|
212
|
-
`
|
|
282
|
+
`Saved-login export did not produce a usable credential for ${domains.join(", ")} in ${installed.join(", ") || "installed browsers"}. Presence may be unknown or unreadable. Safari saved passwords require an export; passkey metadata presence, provider availability, export support and authentication success are separate. The installed Browser Commander cannot export passkeys. Sign in in the browser.`,
|
|
213
283
|
);
|
|
214
284
|
}
|
|
215
285
|
return found;
|
|
@@ -323,7 +393,7 @@ export async function launchBrowser(browser, domains, options = {}) {
|
|
|
323
393
|
* `--browser-import`, which already migrated at launch. Returns whether the
|
|
324
394
|
* sign-in was imported.
|
|
325
395
|
*/
|
|
326
|
-
export async function offerSignInImport(session, domains) {
|
|
396
|
+
export async function offerSignInImport(session, domains, verifySession) {
|
|
327
397
|
const browser = session.options.browserOptions;
|
|
328
398
|
const choice = browser?.import?.browser;
|
|
329
399
|
if (
|
|
@@ -336,47 +406,69 @@ export async function offerSignInImport(session, domains) {
|
|
|
336
406
|
const options = {
|
|
337
407
|
targetBrowser: browser.channel,
|
|
338
408
|
verbose: session.options.verbose,
|
|
409
|
+
diagnostic: (item) => {
|
|
410
|
+
(session.signInEvidence ??= []).push(item);
|
|
411
|
+
(session.options.log ?? console.log)(
|
|
412
|
+
JSON.stringify({ local_credential: item }),
|
|
413
|
+
);
|
|
414
|
+
},
|
|
339
415
|
...session.options.importDiscovery,
|
|
340
416
|
};
|
|
341
417
|
const preferred = await defaultSource(options);
|
|
342
|
-
let sources =
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
418
|
+
let sources = await findSignInSources(domains, {
|
|
419
|
+
...options,
|
|
420
|
+
defaultSource: preferred,
|
|
421
|
+
});
|
|
422
|
+
const attempt = async (candidates) => {
|
|
423
|
+
const selected = await chooseSignInSource(
|
|
424
|
+
candidates,
|
|
425
|
+
domains,
|
|
426
|
+
(message) => session.prompt(message),
|
|
427
|
+
Boolean(choice),
|
|
428
|
+
session.options.log ?? console.log,
|
|
429
|
+
);
|
|
430
|
+
if (!selected) {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
for (const source of [
|
|
434
|
+
selected,
|
|
435
|
+
...candidates.filter((candidate) => candidate !== selected),
|
|
436
|
+
]) {
|
|
437
|
+
// Browser Commander #189: password import replaces Login Data. Never import
|
|
438
|
+
// into a successful or caller-selected target; each attempt gets a fresh one.
|
|
439
|
+
const profile = await mkdtemp(path.join(os.tmpdir(), "prm-signin-"));
|
|
440
|
+
(session.importProfiles ??= []).push(profile);
|
|
441
|
+
session.options.browserProfile = profile;
|
|
442
|
+
try {
|
|
443
|
+
await session.reconnect({
|
|
444
|
+
...browser,
|
|
445
|
+
import: {
|
|
446
|
+
browser: source.browser,
|
|
447
|
+
profile: source.profile,
|
|
448
|
+
...(source.savedLogins ? { savedLogins: true } : {}),
|
|
449
|
+
},
|
|
353
450
|
});
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (!source) {
|
|
451
|
+
} catch {
|
|
452
|
+
(session.options.log ?? console.log)(
|
|
453
|
+
`Import from ${source.label} was unavailable; trying another candidate.`,
|
|
454
|
+
);
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (!verifySession || (await verifySession())) {
|
|
458
|
+
(session.options.log ?? console.log)(
|
|
459
|
+
` Imported ${domains.join(" / ")} from ${source.label}${verifySession ? "; signed-in identity verified" : "; authentication remains unverified"}.`,
|
|
460
|
+
);
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
368
464
|
return false;
|
|
465
|
+
};
|
|
466
|
+
if (await attempt(sources)) {
|
|
467
|
+
return true;
|
|
369
468
|
}
|
|
370
|
-
await
|
|
371
|
-
...
|
|
372
|
-
|
|
373
|
-
browser: source.browser,
|
|
374
|
-
profile: source.profile,
|
|
375
|
-
...(source.savedLogins ? { savedLogins: true } : {}),
|
|
376
|
-
},
|
|
469
|
+
sources = await findSavedLoginSources(domains, {
|
|
470
|
+
...options,
|
|
471
|
+
defaultSource: preferred,
|
|
377
472
|
});
|
|
378
|
-
(
|
|
379
|
-
` Imported the ${domains.join(" / ")} sign-in from ${source.label}.`,
|
|
380
|
-
);
|
|
381
|
-
return true;
|
|
473
|
+
return attempt(sources);
|
|
382
474
|
}
|
package/src/skips.mjs
CHANGED
|
@@ -65,6 +65,9 @@ export function ignoredBy(ignore, manifest) {
|
|
|
65
65
|
|
|
66
66
|
/** Returns the test or example directory that holds a path, if any. */
|
|
67
67
|
export function testDirectory(manifest) {
|
|
68
|
+
if (/(?:^|\/)dev\/log\//.test(manifest)) {
|
|
69
|
+
return "dev/log";
|
|
70
|
+
}
|
|
68
71
|
return (
|
|
69
72
|
manifest
|
|
70
73
|
.split("/")
|
|
@@ -79,7 +82,12 @@ export function referencedByWorkflow(workflows, manifest) {
|
|
|
79
82
|
return workflows.some((workflow) =>
|
|
80
83
|
workflow.contents
|
|
81
84
|
.split(/\r?\n/)
|
|
82
|
-
.some(
|
|
85
|
+
.some(
|
|
86
|
+
(line) =>
|
|
87
|
+
!/^\s*#/.test(line) &&
|
|
88
|
+
line.includes(directory) &&
|
|
89
|
+
/publish|push|pack|release/.test(workflow.contents),
|
|
90
|
+
),
|
|
83
91
|
);
|
|
84
92
|
}
|
|
85
93
|
|
package/src/source-code.mjs
CHANGED
|
@@ -50,7 +50,7 @@ export function stripComments(contents, language = "shell") {
|
|
|
50
50
|
export function commandPosition(prefix) {
|
|
51
51
|
const segment = prefix.split(/[;&|]/).at(-1).trimStart();
|
|
52
52
|
return (
|
|
53
|
-
/^(?:(?:npx|bunx|exec|sudo|env|time|command|pnpm\s+exec|yarn|\w+=\S*)\s+)*$/.test(
|
|
53
|
+
/^(?:(?:if|elif|then|else|do|while|until|!|npx|bunx|exec|sudo|env|time|command|pnpm\s+exec|yarn|\w+=\S*)\s+)*$/.test(
|
|
54
54
|
segment,
|
|
55
55
|
) ||
|
|
56
56
|
/(?:\$|shell)\s*`\s*$/.test(segment) ||
|
package/src/tokens.mjs
CHANGED
|
@@ -16,7 +16,28 @@ export const CRATES_TOKENS_URL = "https://crates.io/settings/tokens";
|
|
|
16
16
|
* registry tokens trusted publishing makes unnecessary, one confirmation each.
|
|
17
17
|
*/
|
|
18
18
|
export function tokenSecretSteps(packageInfo, slug) {
|
|
19
|
-
const names =
|
|
19
|
+
const names = [
|
|
20
|
+
...new Set([
|
|
21
|
+
...registryTokenSecrets(packageInfo.registry),
|
|
22
|
+
...(packageInfo.token_secrets ?? []),
|
|
23
|
+
]),
|
|
24
|
+
];
|
|
25
|
+
if (packageInfo.registry === "nuget") {
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
id: "audit-token-secrets",
|
|
29
|
+
title: "Retain NuGet authentication fallbacks",
|
|
30
|
+
kind: "check",
|
|
31
|
+
description:
|
|
32
|
+
"Retain designated repository and organization fallback secrets, including custom names, after OIDC success. Cleanup requires a separate complete consumer audit and explicit decision.",
|
|
33
|
+
command: {
|
|
34
|
+
program: "gh",
|
|
35
|
+
args: ["secret", "list", "--repo", slug, "--json", "name"],
|
|
36
|
+
},
|
|
37
|
+
cwd: ".",
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
}
|
|
20
41
|
return [
|
|
21
42
|
{
|
|
22
43
|
id: "audit-token-secrets",
|
|
@@ -63,10 +84,17 @@ export function auditRegistryTokens(output, packageInfo) {
|
|
|
63
84
|
const listed = new Set(
|
|
64
85
|
JSON.parse(String(output || "[]")).map((item) => item.name),
|
|
65
86
|
);
|
|
66
|
-
const present =
|
|
67
|
-
|
|
87
|
+
const present = [
|
|
88
|
+
...new Set([
|
|
89
|
+
...registryTokenSecrets(packageInfo.registry),
|
|
90
|
+
...(packageInfo.token_secrets ?? []),
|
|
91
|
+
]),
|
|
92
|
+
].filter((name) => listed.has(name));
|
|
93
|
+
const read = new Set(
|
|
94
|
+
packageInfo.registry === "nuget"
|
|
95
|
+
? present
|
|
96
|
+
: (packageInfo.token_secrets ?? []),
|
|
68
97
|
);
|
|
69
|
-
const read = new Set(packageInfo.token_secrets ?? []);
|
|
70
98
|
return {
|
|
71
99
|
inUse: present.filter((name) => read.has(name)),
|
|
72
100
|
leftover: present.filter((name) => !read.has(name)),
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { convertNugetStep } from "./nuget-migration.mjs";
|
|
1
2
|
import { publishingPolicy } from "./publishing-state.mjs";
|
|
2
3
|
import { fallbackSteps } from "./workflow-fallback.mjs";
|
|
3
4
|
import {
|
|
@@ -12,7 +13,7 @@ export const CRATES_AUTH_ACTION =
|
|
|
12
13
|
"rust-lang/crates-io-auth-action@c6f97d42243bad5fab37ca0427f495c86d5b1a18";
|
|
13
14
|
const LOCAL = /^\s*uses:\s*["']?\.\/\.github\/workflows\/([\w.-]+\.ya?ml)/;
|
|
14
15
|
const indent = (line) => line.search(/\S/);
|
|
15
|
-
const supported = new Set(["crates-io", "npm", "pypi"]);
|
|
16
|
+
const supported = new Set(["crates-io", "npm", "pypi", "nuget"]);
|
|
16
17
|
const keys = (registry) => [
|
|
17
18
|
...registryTokenSecrets(registry),
|
|
18
19
|
...(registry === "npm"
|
|
@@ -129,7 +130,7 @@ function grantJob(lines, level, parsed) {
|
|
|
129
130
|
return grant(lines, level);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
async function convertJob(root, parsed, lines, registry) {
|
|
133
|
+
async function convertJob(root, parsed, lines, registry, packages) {
|
|
133
134
|
if (
|
|
134
135
|
publishingPolicy([...parsed.header, ...lines], registry) ===
|
|
135
136
|
"oidc-with-token-fallback"
|
|
@@ -196,6 +197,17 @@ async function convertJob(root, parsed, lines, registry) {
|
|
|
196
197
|
[...names].some((name) => line.includes(name)) ||
|
|
197
198
|
/preflight.*(?:crates|cargo)|(?:crates|cargo).*preflight/.test(line),
|
|
198
199
|
);
|
|
200
|
+
if (registry === "nuget" && publishes) {
|
|
201
|
+
first = first < 0 ? index : first;
|
|
202
|
+
edits.push(
|
|
203
|
+
convertNugetStep(
|
|
204
|
+
step,
|
|
205
|
+
packages.filter((item) => item.registry === "nuget"),
|
|
206
|
+
index,
|
|
207
|
+
),
|
|
208
|
+
);
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
199
211
|
let updated = [...step];
|
|
200
212
|
if (publishes || consumer) {
|
|
201
213
|
if (first < 0) {
|
|
@@ -410,6 +422,7 @@ export async function workflowMigrationProposal(root, packages, workflows) {
|
|
|
410
422
|
parsed.get(workflow.name),
|
|
411
423
|
content,
|
|
412
424
|
registry,
|
|
425
|
+
packages,
|
|
413
426
|
);
|
|
414
427
|
}
|
|
415
428
|
body.push(lines[position], ...content);
|