@eudiplo/cli 7.6.1-main.8bbb627 → 7.6.1-main.c7b1bd8
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/commands/config/portability/action.d.ts +1 -1
- package/dist/commands/config/portability/action.d.ts.map +1 -1
- package/dist/commands/config/portability/action.js +49 -95
- package/dist/commands/config/portability/action.js.map +1 -1
- package/dist/commands/config/portability/index.d.ts.map +1 -1
- package/dist/commands/config/portability/index.js +37 -5
- package/dist/commands/config/portability/index.js.map +1 -1
- package/dist/commands/config/portability/migrations.d.ts +3 -21
- package/dist/commands/config/portability/migrations.d.ts.map +1 -1
- package/dist/commands/config/portability/migrations.js +4 -92
- package/dist/commands/config/portability/migrations.js.map +1 -1
- package/dist/commands/config/portability/migrations.spec.js +12 -14
- package/dist/commands/config/portability/migrations.spec.js.map +1 -1
- package/dist/commands/config/portability/upgrade.d.ts +3 -0
- package/dist/commands/config/portability/upgrade.d.ts.map +1 -0
- package/dist/commands/config/portability/upgrade.js +199 -0
- package/dist/commands/config/portability/upgrade.js.map +1 -0
- package/dist/commands/config/tenant/action.js +3 -4
- package/dist/commands/config/tenant/action.js.map +1 -1
- package/dist/commands/config/validate/validator.d.ts.map +1 -1
- package/dist/commands/config/validate/validator.js +50 -30
- package/dist/commands/config/validate/validator.js.map +1 -1
- package/package.json +2 -1
- package/templates/demo-config/attribute-providers/claims-provider.json +8 -2
- package/templates/demo-config/clients/presentation-test.json +8 -2
- package/templates/demo-config/clients/test.json +12 -6
- package/templates/demo-config/info.json +7 -1
- package/templates/demo-config/issuance/credentials/citizen.json +43 -37
- package/templates/demo-config/issuance/credentials/pid-key.json +371 -365
- package/templates/demo-config/issuance/credentials/pid-mdoc.json +444 -438
- package/templates/demo-config/issuance/credentials/pid.json +472 -466
- package/templates/demo-config/issuance/issuance.json +1 -3
- package/templates/demo-config/issuance/status-lists/pid.json +12 -6
- package/templates/demo-config/key-chains/access.json +2 -4
- package/templates/demo-config/key-chains/attestation.json +2 -4
- package/templates/demo-config/key-chains/status-list.json +1 -3
- package/templates/demo-config/key-chains/trust-list.json +1 -3
- package/templates/demo-config/presentation/age-over-18.json +20 -7
- package/templates/demo-config/presentation/pid.json +1 -3
- package/templates/demo-config/trust-lists/trustlist-580831bc-ef11-43f4-a3be-a2b6bf1b29a3-config.json +96 -90
- package/templates/demo-config/webhook-endpoints/notification.json +8 -2
- package/templates/schemas/AttributeProviderConfigFile.schema.json +38 -15
- package/templates/schemas/ClientConfigFile.schema.json +38 -15
- package/templates/schemas/CredentialConfigFile.schema.json +38 -15
- package/templates/schemas/IssuanceConfigFile.schema.json +24 -12
- package/templates/schemas/KeyChainConfigFile.schema.json +373 -19
- package/templates/schemas/KmsConfigFile.schema.json +21 -14
- package/templates/schemas/PresentationConfigFile.schema.json +41 -13
- package/templates/schemas/RegistrarConfigFile.schema.json +21 -14
- package/templates/schemas/StatusListConfigFile.schema.json +38 -15
- package/templates/schemas/TenantConfigFile.schema.json +136 -20
- package/templates/schemas/TrustListConfigFile.schema.json +38 -15
- package/templates/schemas/WebhookEndpointConfigFile.schema.json +38 -15
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CliConfig, CommandContext, ParsedArgs } from "../../../types.js";
|
|
2
|
-
type Action = "export" | "plan" | "import" | "upgrade";
|
|
2
|
+
type Action = "export" | "plan" | "import" | "upgrade" | "operations" | "recover";
|
|
3
3
|
export declare function runPortabilityCommand(action: Action, config: CliConfig, parsed: ParsedArgs, context: CommandContext): Promise<number>;
|
|
4
4
|
export {};
|
|
5
5
|
//# sourceMappingURL=action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/commands/config/portability/action.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../src/commands/config/portability/action.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/E,KAAK,MAAM,GACL,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,SAAS,GACT,YAAY,GACZ,SAAS,CAAC;AAEhB,wBAAsB,qBAAqB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,cAAc,GACxB,OAAO,CAAC,MAAM,CAAC,CAgJjB"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { readFile
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
3
2
|
import { basename, extname, isAbsolute, join } from "node:path";
|
|
4
|
-
import {
|
|
3
|
+
import { atomicWriteFile } from "@eudiplo/config-format/config-io.js";
|
|
4
|
+
import { upgradeFile } from "./upgrade.js";
|
|
5
5
|
import { readStringFlag } from "../../../options.js";
|
|
6
6
|
import { resolveInstance } from "../../../services/instance-selection.js";
|
|
7
|
-
import { upgradeDocument } from "./migrations.js";
|
|
8
7
|
export async function runPortabilityCommand(action, config, parsed, context) {
|
|
9
8
|
if (action === "upgrade")
|
|
10
9
|
return upgradeFile(parsed, context);
|
|
@@ -17,6 +16,20 @@ export async function runPortabilityCommand(action, config, parsed, context) {
|
|
|
17
16
|
authorization: `Bearer ${token}`,
|
|
18
17
|
};
|
|
19
18
|
const baseUrl = instance.url.replace(/\/$/, "");
|
|
19
|
+
if (action === "operations" || action === "recover") {
|
|
20
|
+
const id = parsed.positionals[0];
|
|
21
|
+
if (action === "recover" &&
|
|
22
|
+
(!id || parsed.flags["confirm-worker-stopped"] !== true))
|
|
23
|
+
throw new Error("Recovery requires an operation ID and --confirm-worker-stopped after stopping the original worker");
|
|
24
|
+
const path = id ? `/${encodeURIComponent(id)}` : "";
|
|
25
|
+
const response = await context.fetch(`${baseUrl}/api/config-bundles/operations${path}${action === "recover" ? "/acknowledge-interruption?confirmWorkerStopped=true" : ""}`, {
|
|
26
|
+
method: action === "recover" ? "POST" : "GET",
|
|
27
|
+
headers: authHeaders,
|
|
28
|
+
});
|
|
29
|
+
await assertOk(response);
|
|
30
|
+
context.stdout.write(`${JSON.stringify(await response.json(), null, 2)}\n`);
|
|
31
|
+
return 0;
|
|
32
|
+
}
|
|
20
33
|
if (action === "export") {
|
|
21
34
|
const output = resolvePath(readStringFlag(parsed.flags, "output") ??
|
|
22
35
|
"eudiplo-config-bundle.zip", context);
|
|
@@ -26,7 +39,7 @@ export async function runPortabilityCommand(action, config, parsed, context) {
|
|
|
26
39
|
const data = format === "zip"
|
|
27
40
|
? Buffer.from(await response.arrayBuffer())
|
|
28
41
|
: `${JSON.stringify(await response.json(), null, 2)}\n`;
|
|
29
|
-
await
|
|
42
|
+
await atomicWriteFile(output, data);
|
|
30
43
|
context.stdout.write(`Exported configuration bundle to ${output}\n`);
|
|
31
44
|
return 0;
|
|
32
45
|
}
|
|
@@ -37,6 +50,17 @@ export async function runPortabilityCommand(action, config, parsed, context) {
|
|
|
37
50
|
const archive = extname(bundlePath).toLowerCase() === ".zip";
|
|
38
51
|
const mode = readStringFlag(parsed.flags, "mode") ?? "upsert";
|
|
39
52
|
const query = new URLSearchParams({ mode });
|
|
53
|
+
if (action === "import") {
|
|
54
|
+
const planFile = readStringFlag(parsed.flags, "plan");
|
|
55
|
+
const fingerprint = planFile
|
|
56
|
+
? JSON.parse(await readFile(resolvePath(planFile, context), "utf8"))
|
|
57
|
+
.planFingerprint
|
|
58
|
+
: readStringFlag(parsed.flags, "plan-fingerprint");
|
|
59
|
+
if (typeof fingerprint !== "string" ||
|
|
60
|
+
!/^[a-f0-9]{64}$/.test(fingerprint))
|
|
61
|
+
throw new Error("Import requires --plan <saved-plan.json> or --plan-fingerprint from a reviewed plan");
|
|
62
|
+
query.set("planFingerprint", fingerprint);
|
|
63
|
+
}
|
|
40
64
|
if (parsed.flags["confirm-replace"] === true) {
|
|
41
65
|
query.set("confirmReplace", "true");
|
|
42
66
|
}
|
|
@@ -57,100 +81,30 @@ export async function runPortabilityCommand(action, config, parsed, context) {
|
|
|
57
81
|
const response = await context.fetch(`${baseUrl}/api/config-bundles/${endpoint}?${query}`, { method: "POST", headers, body });
|
|
58
82
|
await assertOk(response);
|
|
59
83
|
const result = await response.json();
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const file = parsed.positionals[0];
|
|
65
|
-
if (!file)
|
|
66
|
-
throw new Error("Usage: eudiplo config upgrade <bundle-or-document>");
|
|
67
|
-
const inputPath = resolvePath(file, context);
|
|
68
|
-
if (extname(inputPath).toLowerCase() === ".zip") {
|
|
69
|
-
return upgradeArchive(inputPath, file, parsed, context);
|
|
70
|
-
}
|
|
71
|
-
const input = JSON.parse(await readFile(inputPath, "utf8"));
|
|
72
|
-
const results = Array.isArray(input.documents)
|
|
73
|
-
? input.documents.map((document) => upgradeDocument(document))
|
|
74
|
-
: [upgradeDocument(input)];
|
|
75
|
-
const output = Array.isArray(input.documents)
|
|
76
|
-
? upgradeJsonBundle(input, results)
|
|
77
|
-
: results[0].document;
|
|
78
|
-
const report = results.flatMap((result) => result.issues);
|
|
79
|
-
const outputPath = resolvePath(readStringFlag(parsed.flags, "output") ?? `${file}.upgraded.json`, context);
|
|
80
|
-
if (parsed.flags["dry-run"] !== true) {
|
|
81
|
-
await writeFile(outputPath, `${JSON.stringify(output, null, 2)}\n`, {
|
|
82
|
-
mode: 0o600,
|
|
83
|
-
});
|
|
84
|
-
context.stdout.write(`Wrote upgraded configuration to ${outputPath}\n`);
|
|
84
|
+
if (action === "plan") {
|
|
85
|
+
const output = readStringFlag(parsed.flags, "output");
|
|
86
|
+
if (output)
|
|
87
|
+
await atomicWriteFile(resolvePath(output, context), `${JSON.stringify(result, null, 2)}\n`);
|
|
85
88
|
}
|
|
86
|
-
|
|
87
|
-
for (const
|
|
88
|
-
context.stdout.write(
|
|
89
|
+
if (action === "plan" && parsed.flags.diff === true) {
|
|
90
|
+
for (const item of result.items ?? []) {
|
|
91
|
+
context.stdout.write(`${item.kind}/${item.id}: ${item.action}${item.action === "unchanged" && item.metadataChanged ? " (ownership update)" : ""}\n`);
|
|
92
|
+
for (const change of item.changes ?? [])
|
|
93
|
+
context.stdout.write(` ${change.path}: ${JSON.stringify(change.before) ?? "(absent)"} -> ${JSON.stringify(change.after) ?? "(absent)"}\n`);
|
|
94
|
+
for (const issue of item.issues ?? [])
|
|
95
|
+
context.stderr.write(`${item.kind}/${item.id}${issue.path}: ${issue.message}\n`);
|
|
89
96
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
context.stderr.write(`${issue.severity} ${issue.code} ${issue.path}: ${issue.message}\n`);
|
|
93
|
-
}
|
|
94
|
-
return report.some((issue) => issue.severity !== "warning") ? 1 : 0;
|
|
95
|
-
}
|
|
96
|
-
function upgradeJsonBundle(input, results) {
|
|
97
|
-
const documents = results.map((result) => result.document);
|
|
98
|
-
const resources = (input.manifest?.resources ?? []).map((resource) => {
|
|
99
|
-
const document = documents.find((candidate) => candidate.kind === resource.kind &&
|
|
100
|
-
candidate.metadata.id === resource.id);
|
|
101
|
-
if (!document)
|
|
102
|
-
return resource;
|
|
103
|
-
return {
|
|
104
|
-
...resource,
|
|
105
|
-
apiVersion: document.apiVersion,
|
|
106
|
-
sha256: createHash("sha256")
|
|
107
|
-
.update(JSON.stringify(document))
|
|
108
|
-
.digest("hex"),
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
return {
|
|
112
|
-
...input,
|
|
113
|
-
manifest: { ...input.manifest, resources },
|
|
114
|
-
documents,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
async function upgradeArchive(inputPath, displayPath, parsed, context) {
|
|
118
|
-
const entries = unzipSync(new Uint8Array(await readFile(inputPath)));
|
|
119
|
-
const manifestBytes = entries["manifest.json"];
|
|
120
|
-
if (!manifestBytes)
|
|
121
|
-
throw new Error("Configuration ZIP has no manifest.json");
|
|
122
|
-
const manifest = JSON.parse(strFromU8(manifestBytes));
|
|
123
|
-
const reports = [];
|
|
124
|
-
for (const resource of manifest.resources ?? []) {
|
|
125
|
-
const bytes = entries[resource.path];
|
|
126
|
-
if (!bytes)
|
|
127
|
-
throw new Error(`Configuration ZIP is missing ${resource.path}`);
|
|
128
|
-
const result = upgradeDocument(JSON.parse(strFromU8(bytes)));
|
|
129
|
-
reports.push(result);
|
|
130
|
-
const output = strToU8(JSON.stringify(result.document));
|
|
131
|
-
entries[resource.path] = output;
|
|
132
|
-
resource.apiVersion = result.document.apiVersion;
|
|
133
|
-
resource.sha256 = createHash("sha256").update(output).digest("hex");
|
|
134
|
-
}
|
|
135
|
-
entries["manifest.json"] = strToU8(JSON.stringify(manifest, null, 2));
|
|
136
|
-
const outputPath = resolvePath(readStringFlag(parsed.flags, "output") ?? `${displayPath}.upgraded.zip`, context);
|
|
137
|
-
if (parsed.flags["dry-run"] !== true) {
|
|
138
|
-
await writeFile(outputPath, Buffer.from(zipSync(entries, { level: 6 })), {
|
|
139
|
-
mode: 0o600,
|
|
140
|
-
});
|
|
141
|
-
context.stdout.write(`Wrote upgraded configuration to ${outputPath}\n`);
|
|
142
|
-
}
|
|
143
|
-
for (const result of reports) {
|
|
144
|
-
for (const migration of result.migrations) {
|
|
145
|
-
context.stdout.write(`Applied ${migration}\n`);
|
|
146
|
-
}
|
|
147
|
-
for (const issue of result.issues) {
|
|
148
|
-
context.stderr.write(`${issue.severity} ${issue.code} ${issue.path}: ${issue.message}\n`);
|
|
97
|
+
for (const issue of result.issues ?? []) {
|
|
98
|
+
context.stderr.write(`${issue.code ?? "CONFIG_ISSUE"}${issue.path ?? ""}: ${issue.message}\n`);
|
|
149
99
|
}
|
|
100
|
+
for (const asset of result.assets ?? [])
|
|
101
|
+
context.stdout.write(`${asset.path}: ${asset.action}\n`);
|
|
102
|
+
context.stdout.write(`Plan fingerprint: ${result.planFingerprint}\n`);
|
|
103
|
+
context.stdout.write(`Applicable: ${result.applicable ? "yes" : "no"}\n`);
|
|
150
104
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
105
|
+
else
|
|
106
|
+
context.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
107
|
+
return result.applicable === false ? 1 : 0;
|
|
154
108
|
}
|
|
155
109
|
function resolvePath(value, context) {
|
|
156
110
|
return isAbsolute(value) ? value : join(context.cwd, value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../../src/commands/config/portability/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../../src/commands/config/portability/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAW1E,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACvC,MAAc,EACd,MAAiB,EACjB,MAAkB,EAClB,OAAuB;IAEvB,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9D,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrD,MAAM,KAAK,GACP,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,OAAO,CAAC,GAAG,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AC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACpE,OAAQ,MAAc,CAAC,UAAU,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,WAAW,CAAC,KAAa,EAAE,OAAuB;IACvD,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAChE,CAAC;AAED,KAAK,UAAU,QAAQ,CAAC,QAAkB;IACtC,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO;IACxB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACnC,MAAM,IAAI,KAAK,CAAC,wBAAwB,QAAQ,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/config/portability/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7E,wBAAgB,yBAAyB,CACrC,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,WAAW,GACzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/config/portability/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAA4B,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG7E,wBAAgB,yBAAyB,CACrC,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,WAAW,GACzB,OAAO,EAAE,CA8HX"}
|
|
@@ -19,9 +19,16 @@ export function createPortabilityCommands(context, setExitCode) {
|
|
|
19
19
|
.choices(["create", "upsert", "replace"])
|
|
20
20
|
.default("upsert"));
|
|
21
21
|
if (name === "import") {
|
|
22
|
-
command
|
|
22
|
+
command
|
|
23
|
+
.option("--confirm-replace", "confirm deletion semantics for replace mode")
|
|
24
|
+
.option("--plan <path>", "saved JSON plan reviewed before applying")
|
|
25
|
+
.option("--plan-fingerprint <fingerprint>", "fingerprint from the reviewed plan");
|
|
23
26
|
}
|
|
24
27
|
}
|
|
28
|
+
if (name === "plan")
|
|
29
|
+
command
|
|
30
|
+
.option("--diff", "show a readable plan with redacted field changes")
|
|
31
|
+
.option("--output <path>", "save the plan for a later import");
|
|
25
32
|
command.action(async (...args) => {
|
|
26
33
|
const options = args.at(-2);
|
|
27
34
|
const positionals = name === "export" ? [] : [String(args[0])];
|
|
@@ -31,14 +38,39 @@ export function createPortabilityCommands(context, setExitCode) {
|
|
|
31
38
|
return command;
|
|
32
39
|
};
|
|
33
40
|
const upgrade = new Command("upgrade")
|
|
34
|
-
.description("Upgrade a local configuration
|
|
35
|
-
.argument("<file>")
|
|
36
|
-
.option("--output <path>", "write upgraded
|
|
41
|
+
.description("Upgrade a local configuration file, folder, or bundle")
|
|
42
|
+
.argument("<file-or-folder>")
|
|
43
|
+
.option("--output <path>", "write upgraded configuration to this separate path")
|
|
44
|
+
.option("--check", "exit with status 1 if an upgrade is needed; never write output")
|
|
45
|
+
.option("--diff", "show changes with sensitive values redacted")
|
|
37
46
|
.option("--dry-run", "report migrations without writing output")
|
|
38
47
|
.action(async (file, options) => {
|
|
39
48
|
const { config } = await loadCliState(context);
|
|
40
49
|
setExitCode(await runPortabilityCommand("upgrade", config, parsedArgs("config", "upgrade", [file], options), context));
|
|
41
50
|
});
|
|
42
|
-
|
|
51
|
+
const operations = new Command("operations")
|
|
52
|
+
.description("List recent configuration operations or inspect one durable report")
|
|
53
|
+
.argument("[operation-id]")
|
|
54
|
+
.option("--instance <name>", "select a configured instance")
|
|
55
|
+
.option("--token <token>", "management API access token");
|
|
56
|
+
const recover = new Command("recover")
|
|
57
|
+
.description("Acknowledge an interrupted config operation after stopping its worker")
|
|
58
|
+
.argument("<operation-id>")
|
|
59
|
+
.option("--confirm-worker-stopped", "confirm the original worker has been stopped")
|
|
60
|
+
.option("--instance <name>", "select a configured instance")
|
|
61
|
+
.option("--token <token>", "management API access token");
|
|
62
|
+
for (const command of [operations, recover])
|
|
63
|
+
command.action(async (id, options) => {
|
|
64
|
+
const { config } = await loadCliState(context);
|
|
65
|
+
setExitCode(await runPortabilityCommand(command.name(), config, parsedArgs("config", command.name(), id ? [id] : [], options), context));
|
|
66
|
+
});
|
|
67
|
+
return [
|
|
68
|
+
remote("export"),
|
|
69
|
+
remote("plan"),
|
|
70
|
+
remote("import"),
|
|
71
|
+
upgrade,
|
|
72
|
+
operations,
|
|
73
|
+
recover,
|
|
74
|
+
];
|
|
43
75
|
}
|
|
44
76
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/commands/config/portability/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAoB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,UAAU,yBAAyB,CACrC,OAAuB,EACvB,WAAwB;IAExB,MAAM,MAAM,GAAG,CAAC,IAAkC,EAAE,EAAE;QAClD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;aAC5B,WAAW,CACR,IAAI,KAAK,QAAQ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6B,CAAC,CAAC;IAC9D,KAAK,MAAM,OAAO,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC;QACvC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE;YACjC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,CAAC;YAC/C,WAAW,CACP,MAAM,qBAAqB,CACvB,OAAO,CAAC,IAAI,EAA8B,EAC1C,MAAM,EACN,UAAU,CACN,QAAQ,EACR,OAAO,CAAC,IAAI,EAAE,EACd,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EACd,OAAO,CACV,EACD,OAAO,CACV,CACJ,CAAC;QACN,CAAC,CAAC,CAAC;IACP,OAAO;QACH,MAAM,CAAC,QAAQ,CAAC;QAChB,MAAM,CAAC,MAAM,CAAC;QACd,MAAM,CAAC,QAAQ,CAAC;QAChB,OAAO;QACP,UAAU;QACV,OAAO;KACV,CAAC;AACN,CAAC"}
|
|
@@ -1,24 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export interface PortableDocument {
|
|
3
|
-
apiVersion: string;
|
|
4
|
-
kind: Kind;
|
|
5
|
-
metadata: {
|
|
6
|
-
id: string;
|
|
7
|
-
generation?: number;
|
|
8
|
-
ownership?: string;
|
|
9
|
-
};
|
|
10
|
-
spec: Record<string, any>;
|
|
11
|
-
}
|
|
12
|
-
export interface UpgradeIssue {
|
|
13
|
-
severity: "warning" | "required-input" | "error";
|
|
14
|
-
code: string;
|
|
15
|
-
path: string;
|
|
16
|
-
message: string;
|
|
17
|
-
}
|
|
18
|
-
export declare function upgradeDocument(input: PortableDocument): {
|
|
19
|
-
document: PortableDocument;
|
|
1
|
+
export declare function upgradeDocument(input: unknown): {
|
|
20
2
|
migrations: string[];
|
|
21
|
-
issues:
|
|
3
|
+
issues: import("@eudiplo/config-format/config-format.js").ConfigMigrationIssue[];
|
|
4
|
+
document: import("@eudiplo/config-format/config-format.js").SchemaConfigFile<Record<string, unknown>>;
|
|
22
5
|
};
|
|
23
|
-
export {};
|
|
24
6
|
//# sourceMappingURL=migrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../../src/commands/config/portability/migrations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../../src/commands/config/portability/migrations.ts"],"names":[],"mappings":"AAMA,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO;;;;EAG7C"}
|
|
@@ -1,95 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Client: { slug: "client", version: 1 },
|
|
4
|
-
KmsConfig: { slug: "kms-config", version: 1 },
|
|
5
|
-
KeyChain: { slug: "key-chain", version: 2 },
|
|
6
|
-
RegistrarConfig: { slug: "registrar-config", version: 1 },
|
|
7
|
-
IssuanceConfig: { slug: "issuance-config", version: 2 },
|
|
8
|
-
CredentialConfig: { slug: "credential-config", version: 1 },
|
|
9
|
-
PresentationConfig: { slug: "presentation-config", version: 2 },
|
|
10
|
-
AttributeProvider: { slug: "attribute-provider", version: 1 },
|
|
11
|
-
WebhookEndpoint: { slug: "webhook-endpoint", version: 1 },
|
|
12
|
-
TrustList: { slug: "trust-list", version: 1 },
|
|
13
|
-
StatusList: { slug: "status-list", version: 1 },
|
|
14
|
-
};
|
|
1
|
+
import { migrateDocument, serializeDocument, } from "@eudiplo/config-format/config-format.js";
|
|
2
|
+
import { validateConfigDocument } from "@eudiplo/config-format/config-validator.js";
|
|
15
3
|
export function upgradeDocument(input) {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
throw new Error(`Unsupported resource kind: ${input.kind}`);
|
|
19
|
-
const match = new RegExp(`^eudiplo\\.io/${target.slug}/v([1-9][0-9]*)$`).exec(input.apiVersion);
|
|
20
|
-
if (!match) {
|
|
21
|
-
throw new Error(`Invalid apiVersion for ${input.kind}: ${input.apiVersion}`);
|
|
22
|
-
}
|
|
23
|
-
let version = Number(match[1]);
|
|
24
|
-
if (version > target.version) {
|
|
25
|
-
throw new Error(`${input.kind} v${version} is newer than supported v${target.version}`);
|
|
26
|
-
}
|
|
27
|
-
const document = structuredClone(input);
|
|
28
|
-
const migrations = [];
|
|
29
|
-
const issues = [];
|
|
30
|
-
if (input.kind === "KeyChain" && version === 1) {
|
|
31
|
-
const key = document.spec.key;
|
|
32
|
-
delete document.spec.key;
|
|
33
|
-
document.spec.keySource = { type: "private-jwk", jwk: key };
|
|
34
|
-
migrations.push("KeyChain/1-to-2");
|
|
35
|
-
version = 2;
|
|
36
|
-
}
|
|
37
|
-
if (input.kind === "IssuanceConfig" && version === 1) {
|
|
38
|
-
const values = document.spec.walletProviderTrustLists;
|
|
39
|
-
if (Array.isArray(values)) {
|
|
40
|
-
document.spec.walletProviderTrustLists = values.map((value, index) => {
|
|
41
|
-
if (typeof value !== "string")
|
|
42
|
-
return value;
|
|
43
|
-
issues.push({
|
|
44
|
-
severity: "required-input",
|
|
45
|
-
code: "TRUST_LIST_VERIFIER_REQUIRED",
|
|
46
|
-
path: `/spec/walletProviderTrustLists/${index}`,
|
|
47
|
-
message: "Provide verifierKey or verifierX509Der before import.",
|
|
48
|
-
});
|
|
49
|
-
return { url: value };
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
migrations.push("IssuanceConfig/1-to-2");
|
|
53
|
-
version = 2;
|
|
54
|
-
}
|
|
55
|
-
if (input.kind === "PresentationConfig" && version === 1) {
|
|
56
|
-
if (document.spec.webhook !== undefined) {
|
|
57
|
-
issues.push({
|
|
58
|
-
severity: "required-input",
|
|
59
|
-
code: "WEBHOOK_ENDPOINT_REFERENCE_REQUIRED",
|
|
60
|
-
path: "/spec/webhook",
|
|
61
|
-
message: "Create or select a webhook endpoint, set webhookEndpointId, and remove webhook.",
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
const credentials = document.spec.dcql_query?.credentials;
|
|
65
|
-
if (Array.isArray(credentials)) {
|
|
66
|
-
credentials.forEach((credential, credentialIndex) => {
|
|
67
|
-
credential.trusted_authorities?.forEach((authority, authorityIndex) => {
|
|
68
|
-
if (authority?.type !== "etsi_tl" ||
|
|
69
|
-
!Array.isArray(authority.values)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
authority.values = authority.values.map((value, valueIndex) => {
|
|
73
|
-
if (typeof value !== "string")
|
|
74
|
-
return value;
|
|
75
|
-
issues.push({
|
|
76
|
-
severity: "required-input",
|
|
77
|
-
code: "TRUST_LIST_VERIFIER_REQUIRED",
|
|
78
|
-
path: `/spec/dcql_query/credentials/${credentialIndex}/trusted_authorities/${authorityIndex}/values/${valueIndex}`,
|
|
79
|
-
message: "Provide verifierKey, verifierX509Der, or trustListId before import.",
|
|
80
|
-
});
|
|
81
|
-
return { url: value };
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
migrations.push("PresentationConfig/1-to-2");
|
|
87
|
-
version = 2;
|
|
88
|
-
}
|
|
89
|
-
if (version !== target.version) {
|
|
90
|
-
throw new Error(`No migration path for ${input.kind} v${version} to v${target.version}`);
|
|
91
|
-
}
|
|
92
|
-
document.apiVersion = `eudiplo.io/${target.slug}/v${target.version}`;
|
|
93
|
-
return { document, migrations, issues };
|
|
4
|
+
const result = migrateDocument(input, validateConfigDocument);
|
|
5
|
+
return { ...result, document: serializeDocument(result.document) };
|
|
94
6
|
}
|
|
95
7
|
//# sourceMappingURL=migrations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../../src/commands/config/portability/migrations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migrations.js","sourceRoot":"","sources":["../../../../src/commands/config/portability/migrations.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EACf,iBAAiB,GACpB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AAEpF,MAAM,UAAU,eAAe,CAAC,KAAc;IAC1C,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC;IAC9D,OAAO,EAAE,GAAG,MAAM,EAAE,QAAQ,EAAE,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;AACvE,CAAC"}
|
|
@@ -1,30 +1,28 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import { upgradeDocument } from "./migrations.js";
|
|
3
3
|
describe("offline configuration migrations", () => {
|
|
4
|
-
it("
|
|
4
|
+
it("upgrades a v1 document without retaining metadata.id", () => {
|
|
5
5
|
const result = upgradeDocument({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
metadata: { id: "issuance", generation: 1 },
|
|
6
|
+
$schema: "https://eudiplo.dev/schemas/v1/IssuanceConfigFile.schema.json",
|
|
7
|
+
metadata: { generation: 1 },
|
|
9
8
|
spec: {
|
|
10
|
-
|
|
9
|
+
authorizationServers: [{ id: "issuer", type: "built-in" }],
|
|
10
|
+
walletProviderTrustLists: [
|
|
11
|
+
{ url: "https://example.com/trust-list" },
|
|
12
|
+
],
|
|
11
13
|
},
|
|
12
14
|
});
|
|
13
|
-
expect(result.document
|
|
15
|
+
expect(result.document.$schema).toBe("https://eudiplo.dev/schemas/v1/IssuanceConfigFile.schema.json");
|
|
14
16
|
expect(result.document.spec.walletProviderTrustLists).toEqual([
|
|
15
17
|
{ url: "https://example.com/trust-list" },
|
|
16
18
|
]);
|
|
17
|
-
expect(result.migrations).toEqual([
|
|
18
|
-
expect(result.issues[
|
|
19
|
-
severity: "required-input",
|
|
20
|
-
code: "TRUST_LIST_VERIFIER_REQUIRED",
|
|
21
|
-
});
|
|
19
|
+
expect(result.migrations).toEqual([]);
|
|
20
|
+
expect(result.issues).toEqual([]);
|
|
22
21
|
});
|
|
23
22
|
it("refuses to guess when a document is newer than the CLI", () => {
|
|
24
23
|
expect(() => upgradeDocument({
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
metadata: { id: "future" },
|
|
24
|
+
$schema: "https://eudiplo.dev/schemas/v99/PresentationConfigFile.schema.json",
|
|
25
|
+
metadata: {},
|
|
28
26
|
spec: {},
|
|
29
27
|
})).toThrow("newer than supported");
|
|
30
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrations.spec.js","sourceRoot":"","sources":["../../../../src/commands/config/portability/migrations.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAC9C,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"migrations.spec.js","sourceRoot":"","sources":["../../../../src/commands/config/portability/migrations.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,QAAQ,CAAC,kCAAkC,EAAE,GAAG,EAAE;IAC9C,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;QAC5D,MAAM,MAAM,GAAG,eAAe,CAAC;YAC3B,OAAO,EACH,+DAA+D;YACnE,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;YAC3B,IAAI,EAAE;gBACF,oBAAoB,EAAE,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;gBAC1D,wBAAwB,EAAE;oBACtB,EAAE,GAAG,EAAE,gCAAgC,EAAE;iBAC5C;aACJ;SACJ,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,OAA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