@eudiplo/cli 10.1.0-main.1c527a3 → 10.1.0-main.28055
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.map +1 -1
- package/dist/commands/config/portability/action.js +25 -1
- package/dist/commands/config/portability/action.js.map +1 -1
- package/dist/commands/config/portability/folder-bundle.d.ts +3 -1
- package/dist/commands/config/portability/folder-bundle.d.ts.map +1 -1
- package/dist/commands/config/portability/folder-bundle.js +18 -7
- package/dist/commands/config/portability/folder-bundle.js.map +1 -1
- package/dist/commands/config/portability/migrations.d.ts +4 -0
- package/dist/commands/config/portability/migrations.d.ts.map +1 -1
- package/dist/commands/config/portability/migrations.js +6 -2
- package/dist/commands/config/portability/migrations.js.map +1 -1
- package/dist/commands/config/validate/action.d.ts.map +1 -1
- package/dist/commands/config/validate/action.js +6 -2
- package/dist/commands/config/validate/action.js.map +1 -1
- package/dist/commands/config/validate/validator.d.ts +17 -1
- package/dist/commands/config/validate/validator.d.ts.map +1 -1
- package/dist/commands/config/validate/validator.js +101 -15
- package/dist/commands/config/validate/validator.js.map +1 -1
- package/dist/index.js +598 -219
- package/dist/services/backend-checks.d.ts +10 -1
- package/dist/services/backend-checks.d.ts.map +1 -1
- package/dist/services/backend-checks.js +38 -1
- package/dist/services/backend-checks.js.map +1 -1
- package/dist/services/diagnostics.js +1 -1
- package/dist/services/diagnostics.js.map +1 -1
- package/package.json +1 -1
- package/templates/demo-config/clients/presentation-test.json +1 -2
- package/templates/demo-config/clients/test.json +1 -1
- package/templates/docker-compose.yml +1 -1
- package/templates/schemas/ClientConfigFile.schema.json +138 -1
- package/templates/schemas/CreateClientDto.schema.json +4 -1
- package/templates/schemas/CreateTenantDto.schema.json +5 -2
- package/templates/schemas/UpdateClientDto.schema.json +4 -1
package/dist/index.js
CHANGED
|
@@ -7515,8 +7515,8 @@ var require_formats = __commonJS({
|
|
|
7515
7515
|
"use strict";
|
|
7516
7516
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7517
7517
|
exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
|
|
7518
|
-
function fmtDef(validate,
|
|
7519
|
-
return { validate, compare };
|
|
7518
|
+
function fmtDef(validate, compare2) {
|
|
7519
|
+
return { validate, compare: compare2 };
|
|
7520
7520
|
}
|
|
7521
7521
|
exports.fullFormats = {
|
|
7522
7522
|
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
@@ -20824,10 +20824,42 @@ function isTrustListEmail(value) {
|
|
|
20824
20824
|
return EMAIL.test(value);
|
|
20825
20825
|
}
|
|
20826
20826
|
|
|
20827
|
+
// ../../packages/eudiplo-config-format/dist/client-roles.js
|
|
20828
|
+
var ADMIN_ROLES = ["tenant:admin", "tenants:manage"];
|
|
20829
|
+
var ADDED_ROLES = [
|
|
20830
|
+
{ role: "audit:read", for: ["clients:manage"] },
|
|
20831
|
+
{ role: "keys:manage", for: ["issuance:manage", "presentation:manage"] }
|
|
20832
|
+
];
|
|
20833
|
+
var NARROWED_ROLES = ADDED_ROLES.flatMap((added) => added.for);
|
|
20834
|
+
function upgradeRolesToRoleModel11(roles) {
|
|
20835
|
+
if (roles.some((role) => ADMIN_ROLES.includes(role)))
|
|
20836
|
+
return [...roles];
|
|
20837
|
+
const result = [...roles];
|
|
20838
|
+
for (const added of ADDED_ROLES) {
|
|
20839
|
+
if (!result.includes(added.role) && added.for.some((role) => result.includes(role))) {
|
|
20840
|
+
result.push(added.role);
|
|
20841
|
+
}
|
|
20842
|
+
}
|
|
20843
|
+
return result;
|
|
20844
|
+
}
|
|
20845
|
+
function rolesBeforeRoleModel11(roles) {
|
|
20846
|
+
const candidates = [];
|
|
20847
|
+
const trailing = ADDED_ROLES.map((added) => added.role).reverse();
|
|
20848
|
+
let current = [...roles];
|
|
20849
|
+
for (const role of trailing) {
|
|
20850
|
+
if (current.at(-1) === role) {
|
|
20851
|
+
current = current.slice(0, -1);
|
|
20852
|
+
candidates.push(current);
|
|
20853
|
+
}
|
|
20854
|
+
}
|
|
20855
|
+
const same = (a, b) => a.length === b.length && a.every((role, index) => role === b[index]);
|
|
20856
|
+
return candidates.filter((candidate) => same(upgradeRolesToRoleModel11(candidate), roles));
|
|
20857
|
+
}
|
|
20858
|
+
|
|
20827
20859
|
// ../../packages/eudiplo-config-format/dist/config-format.js
|
|
20828
20860
|
var CONFIG_FORMATS = {
|
|
20829
20861
|
Tenant: { slug: "tenant", file: "TenantConfigFile", version: 4 },
|
|
20830
|
-
Client: { slug: "client", file: "ClientConfigFile", version:
|
|
20862
|
+
Client: { slug: "client", file: "ClientConfigFile", version: 3 },
|
|
20831
20863
|
KmsConfig: { slug: "kms-config", file: "KmsConfigFile", version: 2 },
|
|
20832
20864
|
KeyChain: { slug: "key-chain", file: "KeyChainConfigFile", version: 4 },
|
|
20833
20865
|
KeyChainDefaults: {
|
|
@@ -21415,6 +21447,35 @@ var CONFIG_MIGRATIONS = [
|
|
|
21415
21447
|
// and keys:manage: a v1 spec is a valid v2 spec.
|
|
21416
21448
|
migrate: (spec) => ({ spec })
|
|
21417
21449
|
},
|
|
21450
|
+
{
|
|
21451
|
+
id: "client-v3-role-model",
|
|
21452
|
+
kind: "Client",
|
|
21453
|
+
from: 2,
|
|
21454
|
+
to: 3,
|
|
21455
|
+
// 11.0 narrowed clients:manage and the issuance and presentation
|
|
21456
|
+
// manage roles; the client gets the roles that now hold their rights.
|
|
21457
|
+
migrate: (spec) => {
|
|
21458
|
+
if (!Array.isArray(spec.roles))
|
|
21459
|
+
return { spec };
|
|
21460
|
+
const before = spec.roles;
|
|
21461
|
+
const roles = upgradeRolesToRoleModel11(before);
|
|
21462
|
+
const added = roles.slice(before.length);
|
|
21463
|
+
if (added.length === 0)
|
|
21464
|
+
return { spec };
|
|
21465
|
+
return {
|
|
21466
|
+
spec: { ...spec, roles },
|
|
21467
|
+
issues: [
|
|
21468
|
+
{
|
|
21469
|
+
severity: "warning",
|
|
21470
|
+
code: "CLIENT_ROLES_ADDED",
|
|
21471
|
+
path: "/spec/roles",
|
|
21472
|
+
message: `Added ${added.join(" and ")} so the client keeps its access: clients:manage no longer reads the audit log, and issuance:manage and presentation:manage no longer change key chains. Remove them if the client does not need them.`
|
|
21473
|
+
}
|
|
21474
|
+
]
|
|
21475
|
+
};
|
|
21476
|
+
},
|
|
21477
|
+
earlierSpecs: (spec) => Array.isArray(spec.roles) ? rolesBeforeRoleModel11(spec.roles).map((roles) => ({ ...spec, roles })) : []
|
|
21478
|
+
},
|
|
21418
21479
|
{
|
|
21419
21480
|
id: "kms-config-v2-algorithms",
|
|
21420
21481
|
kind: "KmsConfig",
|
|
@@ -23315,6 +23376,120 @@ async function atomicWriteFile(path2, data) {
|
|
|
23315
23376
|
}
|
|
23316
23377
|
}
|
|
23317
23378
|
|
|
23379
|
+
// src/services/backend-checks.ts
|
|
23380
|
+
function compareVersions(cliVersion, backendVersion2) {
|
|
23381
|
+
const name = "version compatibility";
|
|
23382
|
+
const cli = parse3(cliVersion);
|
|
23383
|
+
const backend = parse3(backendVersion2);
|
|
23384
|
+
if (!cli || !backend) {
|
|
23385
|
+
return {
|
|
23386
|
+
name,
|
|
23387
|
+
status: "warn",
|
|
23388
|
+
message: `CLI ${cliVersion} and backend ${backendVersion2} cannot be compared as versions.`
|
|
23389
|
+
};
|
|
23390
|
+
}
|
|
23391
|
+
if (cli.major !== backend.major) {
|
|
23392
|
+
return {
|
|
23393
|
+
name,
|
|
23394
|
+
status: "fail",
|
|
23395
|
+
message: `CLI ${cliVersion} and backend ${backendVersion2} are different major versions. Install a matching CLI with npm install -g @eudiplo/cli@${backend.major}.`
|
|
23396
|
+
};
|
|
23397
|
+
}
|
|
23398
|
+
if (cli.minor !== backend.minor) {
|
|
23399
|
+
return {
|
|
23400
|
+
name,
|
|
23401
|
+
status: "warn",
|
|
23402
|
+
message: `CLI ${cliVersion} and backend ${backendVersion2} differ in minor version; some commands may not be supported.`
|
|
23403
|
+
};
|
|
23404
|
+
}
|
|
23405
|
+
if (compare(cli, LAST_RELEASE_WITHOUT_ESCAPED_FORM) > 0 && compare(backend, LAST_RELEASE_WITHOUT_ESCAPED_FORM) <= 0) {
|
|
23406
|
+
return {
|
|
23407
|
+
name,
|
|
23408
|
+
status: "warn",
|
|
23409
|
+
message: `CLI ${cliVersion} and backend ${backendVersion2} read the escaped form $\${ of configuration files differently; config plan and import of a tenant folder store values containing \${ or $\${ differently. Upgrade the backend to match the CLI.`
|
|
23410
|
+
};
|
|
23411
|
+
}
|
|
23412
|
+
return {
|
|
23413
|
+
name,
|
|
23414
|
+
status: "pass",
|
|
23415
|
+
message: `CLI ${cliVersion} matches backend ${backendVersion2}.`
|
|
23416
|
+
};
|
|
23417
|
+
}
|
|
23418
|
+
var LAST_RELEASE_WITHOUT_ESCAPED_FORM = {
|
|
23419
|
+
major: 10,
|
|
23420
|
+
minor: 1,
|
|
23421
|
+
patch: 0
|
|
23422
|
+
};
|
|
23423
|
+
function escapedFormWarning(backendVersion2) {
|
|
23424
|
+
const backend = backendVersion2 ? parse3(backendVersion2) : void 0;
|
|
23425
|
+
if (!backend || compare(backend, LAST_RELEASE_WITHOUT_ESCAPED_FORM) > 0)
|
|
23426
|
+
return void 0;
|
|
23427
|
+
return `Warning: the backend (${backendVersion2}) does not read the escaped form $\${ of configuration files, which this CLI sends: values containing \${ or $\${ will be stored differently from what the files say. Upgrade the CLI and the backend together.`;
|
|
23428
|
+
}
|
|
23429
|
+
function compare(left, right) {
|
|
23430
|
+
return left.major - right.major || left.minor - right.minor || left.patch - right.patch;
|
|
23431
|
+
}
|
|
23432
|
+
function readBackendVersion(body) {
|
|
23433
|
+
if (typeof body === "object" && body !== null && "version" in body) {
|
|
23434
|
+
const version = body.version;
|
|
23435
|
+
return typeof version === "string" && version ? version : void 0;
|
|
23436
|
+
}
|
|
23437
|
+
return void 0;
|
|
23438
|
+
}
|
|
23439
|
+
function readProviderHealth(body) {
|
|
23440
|
+
if (!Array.isArray(body)) {
|
|
23441
|
+
throw new Error("the provider health response was not a list");
|
|
23442
|
+
}
|
|
23443
|
+
return body.map((entry) => {
|
|
23444
|
+
const record = entry;
|
|
23445
|
+
return {
|
|
23446
|
+
providerId: String(record.providerId ?? "unknown"),
|
|
23447
|
+
type: String(record.type ?? "unknown"),
|
|
23448
|
+
ok: record.ok === true,
|
|
23449
|
+
latencyMs: typeof record.latencyMs === "number" ? record.latencyMs : void 0,
|
|
23450
|
+
error: typeof record.error === "string" ? record.error : void 0
|
|
23451
|
+
};
|
|
23452
|
+
});
|
|
23453
|
+
}
|
|
23454
|
+
function summarizeProviderHealth(providers) {
|
|
23455
|
+
const name = "KMS providers";
|
|
23456
|
+
if (providers.length === 0) {
|
|
23457
|
+
return {
|
|
23458
|
+
name,
|
|
23459
|
+
status: "warn",
|
|
23460
|
+
message: "No KMS providers are registered for this tenant."
|
|
23461
|
+
};
|
|
23462
|
+
}
|
|
23463
|
+
const failing = providers.filter((provider) => !provider.ok);
|
|
23464
|
+
if (failing.length > 0) {
|
|
23465
|
+
return {
|
|
23466
|
+
name,
|
|
23467
|
+
status: "fail",
|
|
23468
|
+
message: `${failing.length}/${providers.length} provider(s) unhealthy: ${failing.map(
|
|
23469
|
+
(provider) => `${provider.providerId} (${provider.type})${provider.error ? ", health check reported an error" : ""}`
|
|
23470
|
+
).join(", ")}`
|
|
23471
|
+
};
|
|
23472
|
+
}
|
|
23473
|
+
return {
|
|
23474
|
+
name,
|
|
23475
|
+
status: "pass",
|
|
23476
|
+
message: `${providers.length} provider(s) healthy: ${providers.map(
|
|
23477
|
+
(provider) => `${provider.providerId} (${provider.type}${provider.latencyMs === void 0 ? "" : `, ${provider.latencyMs}ms`})`
|
|
23478
|
+
).join(", ")}`
|
|
23479
|
+
};
|
|
23480
|
+
}
|
|
23481
|
+
function parse3(version) {
|
|
23482
|
+
const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
|
|
23483
|
+
if (!match) {
|
|
23484
|
+
return void 0;
|
|
23485
|
+
}
|
|
23486
|
+
return {
|
|
23487
|
+
major: Number(match[1]),
|
|
23488
|
+
minor: Number(match[2]),
|
|
23489
|
+
patch: Number(match[3])
|
|
23490
|
+
};
|
|
23491
|
+
}
|
|
23492
|
+
|
|
23318
23493
|
// src/services/instance-selection.ts
|
|
23319
23494
|
function resolveInstance(config, parsed) {
|
|
23320
23495
|
const name = readStringFlag(parsed.flags, "instance") ?? config.defaultInstance;
|
|
@@ -33112,6 +33287,146 @@ var CONFIG_SCHEMAS = [
|
|
|
33112
33287
|
}
|
|
33113
33288
|
}
|
|
33114
33289
|
},
|
|
33290
|
+
{
|
|
33291
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
33292
|
+
"$id": "https://eudiplo.dev/schemas/v3/ClientConfigFile.schema.json",
|
|
33293
|
+
"title": "ClientConfigFile",
|
|
33294
|
+
"type": "object",
|
|
33295
|
+
"properties": {
|
|
33296
|
+
"$schema": {
|
|
33297
|
+
"type": "string",
|
|
33298
|
+
"const": "https://eudiplo.dev/schemas/v3/ClientConfigFile.schema.json"
|
|
33299
|
+
},
|
|
33300
|
+
"metadata": {
|
|
33301
|
+
"type": "object",
|
|
33302
|
+
"properties": {
|
|
33303
|
+
"generation": {
|
|
33304
|
+
"type": "integer",
|
|
33305
|
+
"minimum": 1,
|
|
33306
|
+
"description": "Monotonically increasing configuration generation."
|
|
33307
|
+
},
|
|
33308
|
+
"ownership": {
|
|
33309
|
+
"type": "string",
|
|
33310
|
+
"enum": [
|
|
33311
|
+
"unmanaged",
|
|
33312
|
+
"file-managed"
|
|
33313
|
+
],
|
|
33314
|
+
"description": "Requested ownership recorded when the document is applied."
|
|
33315
|
+
}
|
|
33316
|
+
},
|
|
33317
|
+
"additionalProperties": false
|
|
33318
|
+
},
|
|
33319
|
+
"spec": {
|
|
33320
|
+
"allOf": [
|
|
33321
|
+
{
|
|
33322
|
+
"$ref": "#/$defs/CreateClientDto"
|
|
33323
|
+
},
|
|
33324
|
+
{
|
|
33325
|
+
"type": "object",
|
|
33326
|
+
"required": [
|
|
33327
|
+
"clientId"
|
|
33328
|
+
],
|
|
33329
|
+
"properties": {
|
|
33330
|
+
"clientId": {
|
|
33331
|
+
"type": "string",
|
|
33332
|
+
"minLength": 1
|
|
33333
|
+
}
|
|
33334
|
+
}
|
|
33335
|
+
}
|
|
33336
|
+
]
|
|
33337
|
+
}
|
|
33338
|
+
},
|
|
33339
|
+
"required": [
|
|
33340
|
+
"$schema",
|
|
33341
|
+
"spec"
|
|
33342
|
+
],
|
|
33343
|
+
"additionalProperties": false,
|
|
33344
|
+
"$defs": {
|
|
33345
|
+
"CreateClientDto": {
|
|
33346
|
+
"type": "object",
|
|
33347
|
+
"properties": {
|
|
33348
|
+
"clientId": {
|
|
33349
|
+
"type": "string",
|
|
33350
|
+
"minLength": 1,
|
|
33351
|
+
"pattern": "^[A-Za-z0-9._:-]+$",
|
|
33352
|
+
"description": "Unique client identifier."
|
|
33353
|
+
},
|
|
33354
|
+
"secret": {
|
|
33355
|
+
"description": "Optional client secret for confidential clients.",
|
|
33356
|
+
"type": "string",
|
|
33357
|
+
"minLength": 1
|
|
33358
|
+
},
|
|
33359
|
+
"description": {
|
|
33360
|
+
"description": "Optional human-readable client description.",
|
|
33361
|
+
"type": "string",
|
|
33362
|
+
"minLength": 1
|
|
33363
|
+
},
|
|
33364
|
+
"roles": {
|
|
33365
|
+
"minItems": 1,
|
|
33366
|
+
"type": "array",
|
|
33367
|
+
"items": {
|
|
33368
|
+
"type": "string",
|
|
33369
|
+
"enum": [
|
|
33370
|
+
"presentation:manage",
|
|
33371
|
+
"presentation:request",
|
|
33372
|
+
"presentation:read",
|
|
33373
|
+
"issuance:manage",
|
|
33374
|
+
"issuance:offer",
|
|
33375
|
+
"issuance:read",
|
|
33376
|
+
"clients:manage",
|
|
33377
|
+
"users:manage",
|
|
33378
|
+
"tenants:manage",
|
|
33379
|
+
"tenant:admin",
|
|
33380
|
+
"registrar:manage",
|
|
33381
|
+
"audit:read",
|
|
33382
|
+
"sessions:read",
|
|
33383
|
+
"credentials:status",
|
|
33384
|
+
"keys:manage",
|
|
33385
|
+
"keys:export"
|
|
33386
|
+
]
|
|
33387
|
+
},
|
|
33388
|
+
"description": "Roles assigned to the client. At least one role is required."
|
|
33389
|
+
},
|
|
33390
|
+
"allowedPresentationConfigs": {
|
|
33391
|
+
"description": "Optional allow-list of presentation config ids this client can use.",
|
|
33392
|
+
"anyOf": [
|
|
33393
|
+
{
|
|
33394
|
+
"type": "array",
|
|
33395
|
+
"items": {
|
|
33396
|
+
"type": "string",
|
|
33397
|
+
"minLength": 1
|
|
33398
|
+
}
|
|
33399
|
+
},
|
|
33400
|
+
{
|
|
33401
|
+
"type": "null"
|
|
33402
|
+
}
|
|
33403
|
+
]
|
|
33404
|
+
},
|
|
33405
|
+
"allowedIssuanceConfigs": {
|
|
33406
|
+
"description": "Optional allow-list of issuance config ids this client can use.",
|
|
33407
|
+
"anyOf": [
|
|
33408
|
+
{
|
|
33409
|
+
"type": "array",
|
|
33410
|
+
"items": {
|
|
33411
|
+
"type": "string",
|
|
33412
|
+
"minLength": 1
|
|
33413
|
+
}
|
|
33414
|
+
},
|
|
33415
|
+
{
|
|
33416
|
+
"type": "null"
|
|
33417
|
+
}
|
|
33418
|
+
]
|
|
33419
|
+
}
|
|
33420
|
+
},
|
|
33421
|
+
"required": [
|
|
33422
|
+
"clientId",
|
|
33423
|
+
"roles"
|
|
33424
|
+
],
|
|
33425
|
+
"additionalProperties": false,
|
|
33426
|
+
"title": "CreateClientDto"
|
|
33427
|
+
}
|
|
33428
|
+
}
|
|
33429
|
+
},
|
|
33115
33430
|
{
|
|
33116
33431
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
33117
33432
|
"$id": "https://eudiplo.dev/schemas/v3/CredentialConfigFile.schema.json",
|
|
@@ -43494,104 +43809,99 @@ var CONFIG_SCHEMAS = [
|
|
|
43494
43809
|
}
|
|
43495
43810
|
];
|
|
43496
43811
|
|
|
43497
|
-
// ../../packages/eudiplo-config-format/dist/config-validator.js
|
|
43498
|
-
var DISPLAY_COLOR_PATH = /^\/spec\/config\/display\/\d+\/(?:background|text)_color$/;
|
|
43499
|
-
var ajv = new import__.Ajv2020({
|
|
43500
|
-
allErrors: true,
|
|
43501
|
-
strict: false,
|
|
43502
|
-
validateFormats: false
|
|
43503
|
-
});
|
|
43504
|
-
for (const schema of CONFIG_SCHEMAS)
|
|
43505
|
-
ajv.addSchema(schema);
|
|
43506
|
-
function validateConfigDocument(document) {
|
|
43507
|
-
const file = serializeDocument(document);
|
|
43508
|
-
const validate = ajv.getSchema(file.$schema);
|
|
43509
|
-
if (!validate)
|
|
43510
|
-
throw new Error(`No bundled validator for ${file.$schema}`);
|
|
43511
|
-
const issues = [];
|
|
43512
|
-
if (!validate(file)) {
|
|
43513
|
-
for (const issue of validate.errors ?? [])
|
|
43514
|
-
issues.push({
|
|
43515
|
-
severity: "error",
|
|
43516
|
-
code: "CONFIG_SCHEMA_VALIDATION_FAILED",
|
|
43517
|
-
path: issue.instancePath || "/",
|
|
43518
|
-
message: issue.keyword === "additionalProperties" ? `Unknown property: ${String(issue.params.additionalProperty)}` : issue.keyword === "pattern" && DISPLAY_COLOR_PATH.test(issue.instancePath) ? DISPLAY_COLOR_MESSAGE : issue.message ?? "Invalid configuration",
|
|
43519
|
-
resource: { kind: document.kind, id: resourceId(document) }
|
|
43520
|
-
});
|
|
43521
|
-
}
|
|
43522
|
-
const id = document.kind === "Client" ? document.spec.clientId : document.spec.id;
|
|
43523
|
-
if (id !== void 0 && id !== resourceId(document))
|
|
43524
|
-
issues.push({
|
|
43525
|
-
severity: "error",
|
|
43526
|
-
code: "RESOURCE_ID_MISMATCH",
|
|
43527
|
-
path: document.kind === "Client" ? "/spec/clientId" : "/spec/id",
|
|
43528
|
-
message: "Resource identifier does not match metadata.id"
|
|
43529
|
-
});
|
|
43530
|
-
issues.push(...configRuleIssues(document));
|
|
43531
|
-
return issues;
|
|
43532
|
-
}
|
|
43533
|
-
function configRuleIssues(document) {
|
|
43534
|
-
const display = document.spec.config?.display;
|
|
43535
|
-
if (document.kind !== "CredentialConfig" || resolveConfigIdentity(serializeDocument(document)).version < 4 || !Array.isArray(display))
|
|
43536
|
-
return [];
|
|
43537
|
-
return findDuplicateDisplayLocales(display).map((duplicate) => ({
|
|
43538
|
-
severity: "error",
|
|
43539
|
-
code: "DISPLAY_LOCALE_DUPLICATE",
|
|
43540
|
-
path: `/spec/config/display/${duplicate.index}/locale`,
|
|
43541
|
-
message: duplicateDisplayLocaleMessage(duplicate),
|
|
43542
|
-
resource: { kind: document.kind, id: resourceId(document) }
|
|
43543
|
-
}));
|
|
43544
|
-
}
|
|
43545
|
-
|
|
43546
43812
|
// ../../packages/eudiplo-config-format/dist/config-values.js
|
|
43547
43813
|
var isVariableChar = (char) => char >= "A" && char <= "Z" || char >= "0" && char <= "9" || char === "_";
|
|
43548
|
-
|
|
43814
|
+
var isLower = (char) => char >= "a" && char <= "z";
|
|
43815
|
+
var isSourceChar = (char) => isLower(char) || char >= "0" && char <= "9" || char === "-";
|
|
43816
|
+
var LOCATOR_CHARS = new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._~/:@+=,#-");
|
|
43817
|
+
var escapeText = (text) => text.replaceAll("${", () => "$${");
|
|
43818
|
+
function replacePlaceholders(input, replace, escapes = "resolve") {
|
|
43549
43819
|
let output = "";
|
|
43820
|
+
let text = "";
|
|
43821
|
+
const flush = () => {
|
|
43822
|
+
output += escapes === "keep" ? escapeText(text) : text;
|
|
43823
|
+
text = "";
|
|
43824
|
+
};
|
|
43550
43825
|
let copied = 0;
|
|
43826
|
+
let noClosingBrace = false;
|
|
43551
43827
|
let start = input.indexOf("${");
|
|
43552
43828
|
while (start !== -1) {
|
|
43553
|
-
|
|
43554
|
-
|
|
43555
|
-
|
|
43556
|
-
|
|
43829
|
+
if (escapes !== "none" && start > copied && input[start - 1] === "$") {
|
|
43830
|
+
text += `${input.slice(copied, start - 1)}\${`;
|
|
43831
|
+
copied = start + 2;
|
|
43832
|
+
start = input.indexOf("${", copied);
|
|
43833
|
+
continue;
|
|
43834
|
+
}
|
|
43835
|
+
let token;
|
|
43557
43836
|
let end = -1;
|
|
43558
|
-
let
|
|
43559
|
-
if (
|
|
43560
|
-
|
|
43561
|
-
|
|
43562
|
-
|
|
43563
|
-
if (
|
|
43564
|
-
|
|
43565
|
-
|
|
43837
|
+
let cursor = start + 2;
|
|
43838
|
+
if (isLower(input[cursor] ?? "")) {
|
|
43839
|
+
while (cursor < input.length && isSourceChar(input[cursor]))
|
|
43840
|
+
cursor++;
|
|
43841
|
+
const source = input.slice(start + 2, cursor);
|
|
43842
|
+
if (input[cursor] === ":") {
|
|
43843
|
+
const locatorStart = cursor + 1;
|
|
43844
|
+
cursor = locatorStart;
|
|
43845
|
+
while (cursor < input.length && LOCATOR_CHARS.has(input[cursor]))
|
|
43846
|
+
cursor++;
|
|
43847
|
+
if (cursor > locatorStart && input[cursor] === "}") {
|
|
43848
|
+
end = cursor;
|
|
43849
|
+
token = {
|
|
43850
|
+
type: "reference",
|
|
43851
|
+
match: input.slice(start, end + 1),
|
|
43852
|
+
source,
|
|
43853
|
+
locator: input.slice(locatorStart, end)
|
|
43854
|
+
};
|
|
43855
|
+
}
|
|
43856
|
+
}
|
|
43857
|
+
} else {
|
|
43858
|
+
while (cursor < input.length && isVariableChar(input[cursor]))
|
|
43859
|
+
cursor++;
|
|
43860
|
+
const variable = input.slice(start + 2, cursor);
|
|
43861
|
+
let fallback;
|
|
43862
|
+
if (variable && input[cursor] === "}")
|
|
43863
|
+
end = cursor;
|
|
43864
|
+
else if (variable && input[cursor] === ":" && !noClosingBrace) {
|
|
43865
|
+
end = input.indexOf("}", cursor + 1);
|
|
43866
|
+
if (end === -1)
|
|
43867
|
+
noClosingBrace = true;
|
|
43868
|
+
else
|
|
43869
|
+
fallback = input.slice(cursor + 1, end);
|
|
43870
|
+
}
|
|
43871
|
+
if (end !== -1)
|
|
43872
|
+
token = {
|
|
43873
|
+
type: "variable",
|
|
43874
|
+
match: input.slice(start, end + 1),
|
|
43875
|
+
variable,
|
|
43876
|
+
fallback
|
|
43877
|
+
};
|
|
43566
43878
|
}
|
|
43567
|
-
if (
|
|
43879
|
+
if (!token) {
|
|
43568
43880
|
start = input.indexOf("${", start + 2);
|
|
43569
43881
|
continue;
|
|
43570
43882
|
}
|
|
43571
|
-
|
|
43572
|
-
|
|
43883
|
+
const { match } = token;
|
|
43884
|
+
const replacement = replace(token);
|
|
43885
|
+
text += input.slice(copied, start);
|
|
43886
|
+
if (replacement !== void 0)
|
|
43887
|
+
text += replacement;
|
|
43888
|
+
else if (escapes === "keep") {
|
|
43889
|
+
flush();
|
|
43890
|
+
output += match;
|
|
43891
|
+
} else
|
|
43892
|
+
text += match;
|
|
43573
43893
|
copied = end + 1;
|
|
43574
43894
|
start = input.indexOf("${", copied);
|
|
43575
43895
|
}
|
|
43576
|
-
|
|
43896
|
+
text += input.slice(copied);
|
|
43897
|
+
flush();
|
|
43898
|
+
return output;
|
|
43577
43899
|
}
|
|
43578
|
-
function
|
|
43579
|
-
const issues = [];
|
|
43900
|
+
function mapStrings(input, change) {
|
|
43580
43901
|
const seen = /* @__PURE__ */ new WeakMap();
|
|
43581
43902
|
function visit2(value, path2) {
|
|
43582
43903
|
if (typeof value === "string")
|
|
43583
|
-
return
|
|
43584
|
-
if (env[variable] !== void 0 && env[variable] !== "")
|
|
43585
|
-
return env[variable];
|
|
43586
|
-
if (fallback !== void 0)
|
|
43587
|
-
return fallback;
|
|
43588
|
-
issues.push({
|
|
43589
|
-
path: path2 || "/",
|
|
43590
|
-
variable,
|
|
43591
|
-
message: `Unresolved placeholder \${${variable}}: no environment value or default is available`
|
|
43592
|
-
});
|
|
43593
|
-
return match;
|
|
43594
|
-
});
|
|
43904
|
+
return change(value, path2 || "/");
|
|
43595
43905
|
if (!value || typeof value !== "object" || value instanceof Uint8Array)
|
|
43596
43906
|
return value;
|
|
43597
43907
|
if (seen.has(value))
|
|
@@ -43607,7 +43917,43 @@ function resolveConfigVariables(input, env) {
|
|
|
43607
43917
|
});
|
|
43608
43918
|
return output;
|
|
43609
43919
|
}
|
|
43610
|
-
return
|
|
43920
|
+
return visit2(input, "");
|
|
43921
|
+
}
|
|
43922
|
+
function resolveConfigVariables(input, env, escapes = "resolve") {
|
|
43923
|
+
const issues = [];
|
|
43924
|
+
const value = mapStrings(input, (text, path2) => replacePlaceholders(text, (token) => {
|
|
43925
|
+
if (token.type === "reference")
|
|
43926
|
+
return void 0;
|
|
43927
|
+
const { variable, fallback } = token;
|
|
43928
|
+
const found = env[variable];
|
|
43929
|
+
if (found !== void 0 && found !== "")
|
|
43930
|
+
return found;
|
|
43931
|
+
if (fallback !== void 0)
|
|
43932
|
+
return fallback;
|
|
43933
|
+
issues.push({
|
|
43934
|
+
path: path2,
|
|
43935
|
+
variable,
|
|
43936
|
+
message: `Unresolved placeholder \${${variable}}: no environment value or default is available`
|
|
43937
|
+
});
|
|
43938
|
+
return void 0;
|
|
43939
|
+
}, escapes));
|
|
43940
|
+
return { value, issues };
|
|
43941
|
+
}
|
|
43942
|
+
function escapeConfigPlaceholders(input) {
|
|
43943
|
+
return mapStrings(input, escapeText);
|
|
43944
|
+
}
|
|
43945
|
+
function readConfigFileValues(input, escapes = "resolve") {
|
|
43946
|
+
const placeholders = [];
|
|
43947
|
+
const references = [];
|
|
43948
|
+
const value = mapStrings(input, (text, path2) => replacePlaceholders(text, ({ type, match }) => {
|
|
43949
|
+
const whole = match === text;
|
|
43950
|
+
if (type === "reference")
|
|
43951
|
+
references.push({ path: path2, reference: match, whole });
|
|
43952
|
+
else
|
|
43953
|
+
placeholders.push({ path: path2, placeholder: match, whole });
|
|
43954
|
+
return void 0;
|
|
43955
|
+
}, escapes));
|
|
43956
|
+
return { value, placeholders, references };
|
|
43611
43957
|
}
|
|
43612
43958
|
function stableConfigJson(value) {
|
|
43613
43959
|
function sort(item) {
|
|
@@ -43673,6 +44019,58 @@ function configChanges(before, after, sensitivePaths = [], prefix = "") {
|
|
|
43673
44019
|
return changes;
|
|
43674
44020
|
}
|
|
43675
44021
|
|
|
44022
|
+
// ../../packages/eudiplo-config-format/dist/config-validator.js
|
|
44023
|
+
var DISPLAY_COLOR_PATH = /^\/spec\/config\/display\/\d+\/(?:background|text)_color$/;
|
|
44024
|
+
var ajv = new import__.Ajv2020({
|
|
44025
|
+
allErrors: true,
|
|
44026
|
+
strict: false,
|
|
44027
|
+
validateFormats: false
|
|
44028
|
+
});
|
|
44029
|
+
for (const schema of CONFIG_SCHEMAS)
|
|
44030
|
+
ajv.addSchema(schema);
|
|
44031
|
+
function validateConfigDocument(document) {
|
|
44032
|
+
const file = serializeDocument(document);
|
|
44033
|
+
const validate = ajv.getSchema(file.$schema);
|
|
44034
|
+
if (!validate)
|
|
44035
|
+
throw new Error(`No bundled validator for ${file.$schema}`);
|
|
44036
|
+
const issues = [];
|
|
44037
|
+
if (!validate(file)) {
|
|
44038
|
+
for (const issue of validate.errors ?? [])
|
|
44039
|
+
issues.push({
|
|
44040
|
+
severity: "error",
|
|
44041
|
+
code: "CONFIG_SCHEMA_VALIDATION_FAILED",
|
|
44042
|
+
path: issue.instancePath || "/",
|
|
44043
|
+
message: issue.keyword === "additionalProperties" ? `Unknown property: ${String(issue.params.additionalProperty)}` : issue.keyword === "pattern" && DISPLAY_COLOR_PATH.test(issue.instancePath) ? DISPLAY_COLOR_MESSAGE : issue.message ?? "Invalid configuration",
|
|
44044
|
+
resource: { kind: document.kind, id: resourceId(document) }
|
|
44045
|
+
});
|
|
44046
|
+
}
|
|
44047
|
+
const id = document.kind === "Client" ? document.spec.clientId : document.spec.id;
|
|
44048
|
+
if (id !== void 0 && id !== resourceId(document))
|
|
44049
|
+
issues.push({
|
|
44050
|
+
severity: "error",
|
|
44051
|
+
code: "RESOURCE_ID_MISMATCH",
|
|
44052
|
+
path: document.kind === "Client" ? "/spec/clientId" : "/spec/id",
|
|
44053
|
+
message: "Resource identifier does not match metadata.id"
|
|
44054
|
+
});
|
|
44055
|
+
issues.push(...configRuleIssues(document));
|
|
44056
|
+
return issues;
|
|
44057
|
+
}
|
|
44058
|
+
function validateConfigFile(document) {
|
|
44059
|
+
return validateConfigDocument(document.kind === "KmsConfig" ? document : { ...document, spec: readConfigFileValues(document.spec).value });
|
|
44060
|
+
}
|
|
44061
|
+
function configRuleIssues(document) {
|
|
44062
|
+
const display = document.spec.config?.display;
|
|
44063
|
+
if (document.kind !== "CredentialConfig" || resolveConfigIdentity(serializeDocument(document)).version < 4 || !Array.isArray(display))
|
|
44064
|
+
return [];
|
|
44065
|
+
return findDuplicateDisplayLocales(display).map((duplicate) => ({
|
|
44066
|
+
severity: "error",
|
|
44067
|
+
code: "DISPLAY_LOCALE_DUPLICATE",
|
|
44068
|
+
path: `/spec/config/display/${duplicate.index}/locale`,
|
|
44069
|
+
message: duplicateDisplayLocaleMessage(duplicate),
|
|
44070
|
+
resource: { kind: document.kind, id: resourceId(document) }
|
|
44071
|
+
}));
|
|
44072
|
+
}
|
|
44073
|
+
|
|
43676
44074
|
// ../../packages/eudiplo-config-format/dist/tenant-folder.js
|
|
43677
44075
|
var TENANT_FOLDER_IMAGES = "images";
|
|
43678
44076
|
var IMAGE_CONTENT_TYPES = {
|
|
@@ -43705,7 +44103,7 @@ async function discoverTenantDirectories(rootPath) {
|
|
|
43705
44103
|
const entries = await readdir(rootPath, { withFileTypes: true });
|
|
43706
44104
|
return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort(compareCodePoints);
|
|
43707
44105
|
}
|
|
43708
|
-
async function validateTenantsRoot(rootPath, schemas, env) {
|
|
44106
|
+
async function validateTenantsRoot(rootPath, schemas, env, options = {}) {
|
|
43709
44107
|
if (!existsSync(rootPath)) {
|
|
43710
44108
|
throw new Error(`Configuration root not found: ${rootPath}`);
|
|
43711
44109
|
}
|
|
@@ -43717,7 +44115,8 @@ async function validateTenantsRoot(rootPath, schemas, env) {
|
|
|
43717
44115
|
join4(rootPath, tenantId),
|
|
43718
44116
|
tenantId,
|
|
43719
44117
|
schemas,
|
|
43720
|
-
env
|
|
44118
|
+
env,
|
|
44119
|
+
options
|
|
43721
44120
|
)
|
|
43722
44121
|
);
|
|
43723
44122
|
}
|
|
@@ -43732,7 +44131,9 @@ async function validateTenantDirectory(tenantPath, tenantId, schemas, env, optio
|
|
|
43732
44131
|
env,
|
|
43733
44132
|
errors: [],
|
|
43734
44133
|
unresolved: [],
|
|
44134
|
+
warnings: [],
|
|
43735
44135
|
allowUnresolvedPlaceholders: options.allowUnresolvedPlaceholders,
|
|
44136
|
+
folderVariablePolicy: options.folderVariablePolicy,
|
|
43736
44137
|
resourceCounts: {},
|
|
43737
44138
|
files: 0
|
|
43738
44139
|
};
|
|
@@ -43743,9 +44144,12 @@ async function validateTenantDirectory(tenantPath, tenantId, schemas, env, optio
|
|
|
43743
44144
|
await validateDirectoryEntry(tenantPath, entry, state);
|
|
43744
44145
|
}
|
|
43745
44146
|
}
|
|
43746
|
-
const warnings =
|
|
43747
|
-
(
|
|
43748
|
-
|
|
44147
|
+
const warnings = [
|
|
44148
|
+
...RETIRED_TENANT_FOLDER_FILES.filter(
|
|
44149
|
+
({ file }) => existsSync(join4(tenantPath, file))
|
|
44150
|
+
).map(({ file, issue }) => ({ file, message: issue.message })),
|
|
44151
|
+
...state.warnings
|
|
44152
|
+
];
|
|
43749
44153
|
return {
|
|
43750
44154
|
id: tenantId,
|
|
43751
44155
|
valid: state.errors.length === 0,
|
|
@@ -43826,16 +44230,15 @@ async function recordValidationOutcome(filePath, relativeFile, resourceType, sch
|
|
|
43826
44230
|
filePath,
|
|
43827
44231
|
relativeFile,
|
|
43828
44232
|
schemaFile,
|
|
43829
|
-
state
|
|
43830
|
-
state.env,
|
|
43831
|
-
state.errors,
|
|
43832
|
-
state.allowUnresolvedPlaceholders ? state.unresolved : state.errors
|
|
44233
|
+
state
|
|
43833
44234
|
);
|
|
43834
44235
|
if (isValid) {
|
|
43835
44236
|
state.resourceCounts[resourceType] = (state.resourceCounts[resourceType] ?? 0) + 1;
|
|
43836
44237
|
}
|
|
43837
44238
|
}
|
|
43838
|
-
async function validateResourceFile(filePath, relativeFile, schemaFile,
|
|
44239
|
+
async function validateResourceFile(filePath, relativeFile, schemaFile, state) {
|
|
44240
|
+
const { errors, getValidator } = state;
|
|
44241
|
+
const kind = kindForSchemaFile(schemaFile);
|
|
43839
44242
|
let raw;
|
|
43840
44243
|
try {
|
|
43841
44244
|
raw = await readFile4(filePath, "utf8");
|
|
@@ -43854,12 +44257,7 @@ async function validateResourceFile(filePath, relativeFile, schemaFile, getValid
|
|
|
43854
44257
|
return false;
|
|
43855
44258
|
}
|
|
43856
44259
|
const errorsBefore = errors.length;
|
|
43857
|
-
let resolved = resolvePlaceholders(
|
|
43858
|
-
payload,
|
|
43859
|
-
env,
|
|
43860
|
-
relativeFile,
|
|
43861
|
-
placeholderIssues
|
|
43862
|
-
);
|
|
44260
|
+
let resolved = resolvePlaceholders(payload, relativeFile, kind, state);
|
|
43863
44261
|
if (errors.length > errorsBefore) {
|
|
43864
44262
|
return false;
|
|
43865
44263
|
}
|
|
@@ -43887,7 +44285,6 @@ async function validateResourceFile(filePath, relativeFile, schemaFile, getValid
|
|
|
43887
44285
|
return false;
|
|
43888
44286
|
}
|
|
43889
44287
|
} else {
|
|
43890
|
-
const kind = kindForSchemaFile(schemaFile);
|
|
43891
44288
|
if (kind && resolved && typeof resolved === "object" && !Array.isArray(resolved)) {
|
|
43892
44289
|
const spec = structuredClone(resolved);
|
|
43893
44290
|
if (kind === "KeyChain" && spec.key && !spec.keySource) {
|
|
@@ -43948,17 +44345,62 @@ function formatErrorPath(issue) {
|
|
|
43948
44345
|
const missingProperty = issue.params?.missingProperty;
|
|
43949
44346
|
return missingProperty;
|
|
43950
44347
|
}
|
|
43951
|
-
function resolvePlaceholders(value,
|
|
43952
|
-
const
|
|
44348
|
+
function resolvePlaceholders(value, file, kind, state) {
|
|
44349
|
+
const kms = kind === "KmsConfig";
|
|
44350
|
+
const named = /* @__PURE__ */ new Set();
|
|
44351
|
+
const env = new Proxy(state.env, {
|
|
44352
|
+
get: (target, name) => {
|
|
44353
|
+
if (typeof name !== "string") return void 0;
|
|
44354
|
+
named.add(name);
|
|
44355
|
+
return target[name];
|
|
44356
|
+
}
|
|
44357
|
+
});
|
|
44358
|
+
const result = resolveConfigVariables(value, env, kms ? "none" : "resolve");
|
|
44359
|
+
const refused = /* @__PURE__ */ new Set();
|
|
44360
|
+
if (state.folderVariablePolicy)
|
|
44361
|
+
for (const variable of [...named].sort(compareCodePoints)) {
|
|
44362
|
+
const check = checkFolderVariable(variable, kms);
|
|
44363
|
+
if (check?.refused) {
|
|
44364
|
+
refused.add(variable);
|
|
44365
|
+
state.errors.push({ file, message: check.message, variable });
|
|
44366
|
+
} else if (check)
|
|
44367
|
+
state.warnings.push({ file, message: check.message, variable });
|
|
44368
|
+
}
|
|
44369
|
+
const placeholderIssues = state.allowUnresolvedPlaceholders ? state.unresolved : state.errors;
|
|
43953
44370
|
for (const issue of result.issues)
|
|
43954
|
-
|
|
43955
|
-
|
|
43956
|
-
|
|
43957
|
-
|
|
43958
|
-
|
|
43959
|
-
|
|
44371
|
+
if (!refused.has(issue.variable))
|
|
44372
|
+
placeholderIssues.push({
|
|
44373
|
+
file,
|
|
44374
|
+
path: issue.path,
|
|
44375
|
+
message: issue.message,
|
|
44376
|
+
variable: issue.variable
|
|
44377
|
+
});
|
|
43960
44378
|
return result.value;
|
|
43961
44379
|
}
|
|
44380
|
+
var CLOUD_CREDENTIAL_VARIABLES = /* @__PURE__ */ new Map([
|
|
44381
|
+
["AWS_ACCESS_KEY_ID", "AWS"],
|
|
44382
|
+
["AWS_SECRET_ACCESS_KEY", "AWS"],
|
|
44383
|
+
["AWS_SESSION_TOKEN", "AWS"],
|
|
44384
|
+
["AWS_CONTAINER_AUTHORIZATION_TOKEN", "AWS"],
|
|
44385
|
+
["AZURE_CLIENT_SECRET", "Azure"],
|
|
44386
|
+
["AZURE_CLIENT_CERTIFICATE_PASSWORD", "Azure"],
|
|
44387
|
+
["AZURE_PASSWORD", "Azure"]
|
|
44388
|
+
]);
|
|
44389
|
+
function checkFolderVariable(variable, kms) {
|
|
44390
|
+
if (variable === "PUBLIC_URL") return void 0;
|
|
44391
|
+
if (kms)
|
|
44392
|
+
return {
|
|
44393
|
+
refused: false,
|
|
44394
|
+
message: `\${${variable}} is resolved only if the instance lists ${variable} in KMS_TENANT_VARIABLES, which cannot name a setting of EUDIPLO itself`
|
|
44395
|
+
};
|
|
44396
|
+
const provider = CLOUD_CREDENTIAL_VARIABLES.get(variable);
|
|
44397
|
+
if (provider)
|
|
44398
|
+
return {
|
|
44399
|
+
refused: true,
|
|
44400
|
+
message: `\${${variable}} holds the ${provider} credentials of the instance, which a file of a tenant folder cannot use`
|
|
44401
|
+
};
|
|
44402
|
+
return void 0;
|
|
44403
|
+
}
|
|
43962
44404
|
|
|
43963
44405
|
// src/commands/config/portability/folder-bundle.ts
|
|
43964
44406
|
import { createHash as createHash3 } from "node:crypto";
|
|
@@ -43990,13 +44432,13 @@ import {
|
|
|
43990
44432
|
|
|
43991
44433
|
// src/commands/config/portability/migrations.ts
|
|
43992
44434
|
function upgradeDocument(input) {
|
|
43993
|
-
const result = migrateDocument(input,
|
|
44435
|
+
const result = migrateDocument(input, validateConfigFile);
|
|
43994
44436
|
return { ...result, document: serializeDocument(result.document) };
|
|
43995
44437
|
}
|
|
43996
44438
|
|
|
43997
44439
|
// src/commands/config/portability/upgrade.ts
|
|
43998
44440
|
var codec = new ConfigBundleCodec();
|
|
43999
|
-
function
|
|
44441
|
+
function parse4(text, path2) {
|
|
44000
44442
|
try {
|
|
44001
44443
|
return JSON.parse(text);
|
|
44002
44444
|
} catch {
|
|
@@ -44129,7 +44571,7 @@ async function upgradeFolder(source, parsed, context) {
|
|
|
44129
44571
|
for (const file of await folderFiles(source)) {
|
|
44130
44572
|
if (extname(file) !== ".json" || relative2(source, file).split(sep2).includes("images"))
|
|
44131
44573
|
continue;
|
|
44132
|
-
const input =
|
|
44574
|
+
const input = parse4(await readFile5(file, "utf8"), file);
|
|
44133
44575
|
const path2 = relative2(source, file).split(sep2).join("/");
|
|
44134
44576
|
const retired = RETIRED_TENANT_FOLDER_FILES.find(
|
|
44135
44577
|
(entry) => path2 === entry.file || path2.endsWith(`/${entry.file}`)
|
|
@@ -44219,7 +44661,7 @@ async function upgradeFile(parsed, context) {
|
|
|
44219
44661
|
);
|
|
44220
44662
|
if (info.isDirectory()) return upgradeFolder(source, parsed, context);
|
|
44221
44663
|
const zipped = extname(source).toLowerCase() === ".zip";
|
|
44222
|
-
const input = zipped ? codec.decode(await readFile5(source)) :
|
|
44664
|
+
const input = zipped ? codec.decode(await readFile5(source)) : parse4(await readFile5(source, "utf8"), source);
|
|
44223
44665
|
const output = upgradeJson(input, source, context);
|
|
44224
44666
|
const changed = report(input, output, name, parsed, context);
|
|
44225
44667
|
if (parsed.flags.check === true) return changed ? 1 : 0;
|
|
@@ -44270,10 +44712,14 @@ function folderEnvironment(allowList, source) {
|
|
|
44270
44712
|
}
|
|
44271
44713
|
var VALUE_KEYS = /* @__PURE__ */ new Set(["before", "after", "message"]);
|
|
44272
44714
|
function maskFilledText(text, filled) {
|
|
44273
|
-
const secrets = [...filled].
|
|
44274
|
-
|
|
44275
|
-
|
|
44276
|
-
|
|
44715
|
+
const secrets = [...filled].flatMap(([variable, secret]) => {
|
|
44716
|
+
const placeholder = `\${${variable}}`;
|
|
44717
|
+
const escaped = escapeConfigPlaceholders(secret);
|
|
44718
|
+
return escaped === secret ? [{ secret, placeholder }] : [
|
|
44719
|
+
{ secret, placeholder },
|
|
44720
|
+
{ secret: escaped, placeholder }
|
|
44721
|
+
];
|
|
44722
|
+
}).sort((left, right) => right.secret.length - left.secret.length);
|
|
44277
44723
|
for (const { secret, placeholder } of secrets) {
|
|
44278
44724
|
if (text === secret) return placeholder;
|
|
44279
44725
|
if (secret.length >= MIN_MASKED_LENGTH)
|
|
@@ -44402,7 +44848,11 @@ async function resourceFiles(tenantRoot, resource) {
|
|
|
44402
44848
|
}
|
|
44403
44849
|
async function loadDocument(tenantRoot, file, kind, env) {
|
|
44404
44850
|
const payload = JSON.parse(await readFile6(join6(tenantRoot, file), "utf8"));
|
|
44405
|
-
const resolved = resolveConfigVariables(
|
|
44851
|
+
const resolved = resolveConfigVariables(
|
|
44852
|
+
payload,
|
|
44853
|
+
env,
|
|
44854
|
+
kind === "KmsConfig" ? "none" : "keep"
|
|
44855
|
+
).value;
|
|
44406
44856
|
const document = normalizeDocument(
|
|
44407
44857
|
isConfigDocument(resolved) ? resolved : wrapBare(kind, resolved, file)
|
|
44408
44858
|
);
|
|
@@ -44622,7 +45072,7 @@ async function runPortabilityCommand(action, config, parsed, context) {
|
|
|
44622
45072
|
const allowEnv = readStringFlag(parsed.flags, "allow-env");
|
|
44623
45073
|
if (allowEnv !== void 0 && !folder)
|
|
44624
45074
|
throw new Error(
|
|
44625
|
-
"--allow-env applies to a tenant folder only;
|
|
45075
|
+
"--allow-env applies to a tenant folder only; replace the placeholders of a bundle with their values."
|
|
44626
45076
|
);
|
|
44627
45077
|
const folderEnv = folderEnvironment(allowEnv, context.env);
|
|
44628
45078
|
if (folder) {
|
|
@@ -44695,6 +45145,13 @@ async function runPortabilityCommand(action, config, parsed, context) {
|
|
|
44695
45145
|
body = JSON.stringify(bundle);
|
|
44696
45146
|
headers = { ...headers, "content-type": "application/json" };
|
|
44697
45147
|
}
|
|
45148
|
+
if (folder) {
|
|
45149
|
+
const warning = escapedFormWarning(
|
|
45150
|
+
await backendVersion(baseUrl, authHeaders, context)
|
|
45151
|
+
);
|
|
45152
|
+
if (warning) context.stderr.write(`${warning}
|
|
45153
|
+
`);
|
|
45154
|
+
}
|
|
44698
45155
|
const response = await context.fetch(
|
|
44699
45156
|
`${baseUrl}/api/config-bundles/${endpoint}?${query}`,
|
|
44700
45157
|
{ method: "POST", headers, body }
|
|
@@ -44756,6 +45213,17 @@ async function runPortabilityCommand(action, config, parsed, context) {
|
|
|
44756
45213
|
`);
|
|
44757
45214
|
return result.applicable === false ? 1 : 0;
|
|
44758
45215
|
}
|
|
45216
|
+
async function backendVersion(baseUrl, headers, context) {
|
|
45217
|
+
try {
|
|
45218
|
+
const response = await context.fetch(`${baseUrl}/api/version`, {
|
|
45219
|
+
headers
|
|
45220
|
+
});
|
|
45221
|
+
if (!response.ok) return void 0;
|
|
45222
|
+
return readBackendVersion(await response.json());
|
|
45223
|
+
} catch {
|
|
45224
|
+
return void 0;
|
|
45225
|
+
}
|
|
45226
|
+
}
|
|
44759
45227
|
async function exportFolder(baseUrl, headers, output, context) {
|
|
44760
45228
|
const response = await context.fetch(
|
|
44761
45229
|
`${baseUrl}/api/config-bundles/export?format=zip`,
|
|
@@ -45272,9 +45740,13 @@ async function validateTenantConfig(scope, parsed, context) {
|
|
|
45272
45740
|
rootPath,
|
|
45273
45741
|
basename6(rootPath),
|
|
45274
45742
|
schemas,
|
|
45275
|
-
context.env
|
|
45743
|
+
context.env,
|
|
45744
|
+
// As the backend loads the folder from CONFIG_FOLDER.
|
|
45745
|
+
{ folderVariablePolicy: true }
|
|
45276
45746
|
)
|
|
45277
|
-
] : await validateTenantsRoot(rootPath, schemas, context.env
|
|
45747
|
+
] : await validateTenantsRoot(rootPath, schemas, context.env, {
|
|
45748
|
+
folderVariablePolicy: true
|
|
45749
|
+
});
|
|
45278
45750
|
context.stdout.write(
|
|
45279
45751
|
format2 === "json" ? `${JSON.stringify(buildJsonReport(results), null, 2)}
|
|
45280
45752
|
` : formatTextReport(scope, rootPath, results)
|
|
@@ -46946,7 +47418,7 @@ function createDeploymentCommands(context, setExitCode) {
|
|
|
46946
47418
|
// package.json
|
|
46947
47419
|
var package_default = {
|
|
46948
47420
|
name: "@eudiplo/cli",
|
|
46949
|
-
version: "10.1.0-main.
|
|
47421
|
+
version: "10.1.0-main.0028055",
|
|
46950
47422
|
description: "Deployment-aware command line tools for EUDIPLO",
|
|
46951
47423
|
private: false,
|
|
46952
47424
|
type: "module",
|
|
@@ -47084,99 +47556,6 @@ function withTrailingSlash(url) {
|
|
|
47084
47556
|
return url.href.endsWith("/") ? url : new URL(`${url.href}/`);
|
|
47085
47557
|
}
|
|
47086
47558
|
|
|
47087
|
-
// src/services/backend-checks.ts
|
|
47088
|
-
function compareVersions(cliVersion, backendVersion) {
|
|
47089
|
-
const name = "version compatibility";
|
|
47090
|
-
const cli = parse4(cliVersion);
|
|
47091
|
-
const backend = parse4(backendVersion);
|
|
47092
|
-
if (!cli || !backend) {
|
|
47093
|
-
return {
|
|
47094
|
-
name,
|
|
47095
|
-
status: "warn",
|
|
47096
|
-
message: `CLI ${cliVersion} and backend ${backendVersion} cannot be compared as versions.`
|
|
47097
|
-
};
|
|
47098
|
-
}
|
|
47099
|
-
if (cli.major !== backend.major) {
|
|
47100
|
-
return {
|
|
47101
|
-
name,
|
|
47102
|
-
status: "fail",
|
|
47103
|
-
message: `CLI ${cliVersion} and backend ${backendVersion} are different major versions. Install a matching CLI with npm install -g @eudiplo/cli@${backend.major}.`
|
|
47104
|
-
};
|
|
47105
|
-
}
|
|
47106
|
-
if (cli.minor !== backend.minor) {
|
|
47107
|
-
return {
|
|
47108
|
-
name,
|
|
47109
|
-
status: "warn",
|
|
47110
|
-
message: `CLI ${cliVersion} and backend ${backendVersion} differ in minor version; some commands may not be supported.`
|
|
47111
|
-
};
|
|
47112
|
-
}
|
|
47113
|
-
return {
|
|
47114
|
-
name,
|
|
47115
|
-
status: "pass",
|
|
47116
|
-
message: `CLI ${cliVersion} matches backend ${backendVersion}.`
|
|
47117
|
-
};
|
|
47118
|
-
}
|
|
47119
|
-
function readBackendVersion(body) {
|
|
47120
|
-
if (typeof body === "object" && body !== null && "version" in body) {
|
|
47121
|
-
const version = body.version;
|
|
47122
|
-
return typeof version === "string" && version ? version : void 0;
|
|
47123
|
-
}
|
|
47124
|
-
return void 0;
|
|
47125
|
-
}
|
|
47126
|
-
function readProviderHealth(body) {
|
|
47127
|
-
if (!Array.isArray(body)) {
|
|
47128
|
-
throw new Error("the provider health response was not a list");
|
|
47129
|
-
}
|
|
47130
|
-
return body.map((entry) => {
|
|
47131
|
-
const record = entry;
|
|
47132
|
-
return {
|
|
47133
|
-
providerId: String(record.providerId ?? "unknown"),
|
|
47134
|
-
type: String(record.type ?? "unknown"),
|
|
47135
|
-
ok: record.ok === true,
|
|
47136
|
-
latencyMs: typeof record.latencyMs === "number" ? record.latencyMs : void 0,
|
|
47137
|
-
error: typeof record.error === "string" ? record.error : void 0
|
|
47138
|
-
};
|
|
47139
|
-
});
|
|
47140
|
-
}
|
|
47141
|
-
function summarizeProviderHealth(providers) {
|
|
47142
|
-
const name = "KMS providers";
|
|
47143
|
-
if (providers.length === 0) {
|
|
47144
|
-
return {
|
|
47145
|
-
name,
|
|
47146
|
-
status: "warn",
|
|
47147
|
-
message: "No KMS providers are registered for this tenant."
|
|
47148
|
-
};
|
|
47149
|
-
}
|
|
47150
|
-
const failing = providers.filter((provider) => !provider.ok);
|
|
47151
|
-
if (failing.length > 0) {
|
|
47152
|
-
return {
|
|
47153
|
-
name,
|
|
47154
|
-
status: "fail",
|
|
47155
|
-
message: `${failing.length}/${providers.length} provider(s) unhealthy: ${failing.map(
|
|
47156
|
-
(provider) => `${provider.providerId} (${provider.type})${provider.error ? ", health check reported an error" : ""}`
|
|
47157
|
-
).join(", ")}`
|
|
47158
|
-
};
|
|
47159
|
-
}
|
|
47160
|
-
return {
|
|
47161
|
-
name,
|
|
47162
|
-
status: "pass",
|
|
47163
|
-
message: `${providers.length} provider(s) healthy: ${providers.map(
|
|
47164
|
-
(provider) => `${provider.providerId} (${provider.type}${provider.latencyMs === void 0 ? "" : `, ${provider.latencyMs}ms`})`
|
|
47165
|
-
).join(", ")}`
|
|
47166
|
-
};
|
|
47167
|
-
}
|
|
47168
|
-
function parse4(version) {
|
|
47169
|
-
const match = /^v?(\d+)\.(\d+)\.(\d+)/.exec(version.trim());
|
|
47170
|
-
if (!match) {
|
|
47171
|
-
return void 0;
|
|
47172
|
-
}
|
|
47173
|
-
return {
|
|
47174
|
-
major: Number(match[1]),
|
|
47175
|
-
minor: Number(match[2]),
|
|
47176
|
-
patch: Number(match[3])
|
|
47177
|
-
};
|
|
47178
|
-
}
|
|
47179
|
-
|
|
47180
47559
|
// src/services/tls-expiry.ts
|
|
47181
47560
|
import { connect } from "node:tls";
|
|
47182
47561
|
var defaultExpiryWarningDays = 30;
|
|
@@ -47356,15 +47735,15 @@ var versionCompatibilityCheck = {
|
|
|
47356
47735
|
message: `The backend version could not be read: ${response.reason}`
|
|
47357
47736
|
};
|
|
47358
47737
|
}
|
|
47359
|
-
const
|
|
47360
|
-
if (!
|
|
47738
|
+
const backendVersion2 = readBackendVersion(response.body);
|
|
47739
|
+
if (!backendVersion2) {
|
|
47361
47740
|
return {
|
|
47362
47741
|
name: "version compatibility",
|
|
47363
47742
|
status: "warn",
|
|
47364
47743
|
message: "The backend did not report a version."
|
|
47365
47744
|
};
|
|
47366
47745
|
}
|
|
47367
|
-
return compareVersions(package_default.version,
|
|
47746
|
+
return compareVersions(package_default.version, backendVersion2);
|
|
47368
47747
|
})
|
|
47369
47748
|
};
|
|
47370
47749
|
var kmsHealthCheck = {
|
|
@@ -47394,7 +47773,7 @@ var kmsHealthCheck = {
|
|
|
47394
47773
|
return {
|
|
47395
47774
|
name: "KMS providers",
|
|
47396
47775
|
status: "skip",
|
|
47397
|
-
message: `Needs a tenant client with issuance:
|
|
47776
|
+
message: `Needs a tenant client with issuance:read, presentation:read or keys:manage, or a role that includes one of them (${response.reason}).`
|
|
47398
47777
|
};
|
|
47399
47778
|
}
|
|
47400
47779
|
return {
|