@opencrvs/toolkit 2.0.1-rc.0afe065 → 2.0.1-rc.15524b3
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/create-countryconfig/index.js +96 -9
- package/dist/application-config/index.js +4 -2
- package/dist/cli.js +332 -5
- package/dist/commons/api/router.d.ts +6 -2
- package/dist/commons/conditionals/conditionals.d.ts +3 -3
- package/dist/commons/events/ActionConfig.d.ts +4 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
- package/dist/commons/events/FieldConfig.d.ts +5 -0
- package/dist/commons/events/FormConfig.d.ts +6 -0
- package/dist/commons/events/PageConfig.d.ts +4 -0
- package/dist/commons/events/utils.d.ts +4 -0
- package/dist/commons/notification/UserNotifications.d.ts +1 -6
- package/dist/conditionals/index.js +4 -2
- package/dist/events/index.js +22 -2
- package/dist/migrations/v2.0/index.js +4 -2
- package/dist/notification/index.js +8 -2
- package/dist/scopes/index.d.ts +65 -0
- package/dist/scopes/index.js +4 -2
- package/dist/verify/endpoints.d.ts +2 -0
- package/dist/verify/endpoints.d.ts.map +1 -0
- package/dist/verify/endpoints.js +345 -0
- package/opencrvs-toolkit-2.0.1-rc.15524b3.tgz +0 -0
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/opencrvs-toolkit-2.0.1-rc.0afe065.tgz +0 -0
|
@@ -37,11 +37,87 @@ function tagExists(repoUrl, tag) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
function branchExists(repoUrl, branch) {
|
|
41
|
+
try {
|
|
42
|
+
execSync(
|
|
43
|
+
'git ls-remote --exit-code --heads ' + repoUrl + ' refs/heads/' + branch,
|
|
44
|
+
{
|
|
45
|
+
stdio: 'pipe'
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
return true
|
|
49
|
+
} catch (err) {
|
|
50
|
+
return false
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Release tags (e.g. "v2.1.0"), highest first. Delegates the version-aware
|
|
56
|
+
* ordering to git itself rather than hand-parsing semver, then filters down
|
|
57
|
+
* to strict "vX.Y.Z" tags - `--sort=-version:refname` alone still leaves in
|
|
58
|
+
* non-release refs (e.g. "vtesting", "v2.0.0-beta") and peeled annotated-tag
|
|
59
|
+
* lines ("refs/tags/v2.0.0^{}").
|
|
60
|
+
*/
|
|
61
|
+
function listReleaseTags(repoUrl) {
|
|
62
|
+
const output = execSync(
|
|
63
|
+
'git ls-remote --tags --sort=-version:refname ' + repoUrl,
|
|
64
|
+
{ encoding: 'utf-8' }
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
return output
|
|
68
|
+
.split('\n')
|
|
69
|
+
.map((line) => line.split('\t')[1])
|
|
70
|
+
.filter(Boolean)
|
|
71
|
+
.map((ref) => ref.replace('refs/tags/', ''))
|
|
72
|
+
.filter((tag) => /^v\d+\.\d+\.\d+$/.test(tag))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The highest release tag present in *both* repositories - used as the
|
|
77
|
+
* fallback when the version-specific tag can't be found in one or both, so
|
|
78
|
+
* scaffolding still lands on a real, matched release rather than develop.
|
|
79
|
+
*/
|
|
80
|
+
function getLatestCommonReleaseTag() {
|
|
81
|
+
const infrastructureTags = new Set(listReleaseTags(INFRASTRUCTURE_REPO_URL))
|
|
82
|
+
return (
|
|
83
|
+
listReleaseTags(COUNTRYCONFIG_REPO_URL).find((tag) =>
|
|
84
|
+
infrastructureTags.has(tag)
|
|
85
|
+
) || null
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* A prerelease-shaped own version (e.g. "2.1.0-rc.f5ea803", what npm resolves
|
|
91
|
+
* `@next` to - a build published from every push to a branch) never has a
|
|
92
|
+
* matching release tag, so it's resolved as a branch instead. Its base
|
|
93
|
+
* version (stripped of the "-rc.<sha>" suffix) tells apart two different
|
|
94
|
+
* situations: an RC for a version already being stabilized on its own
|
|
95
|
+
* "release/X.Y.Z" branch (e.g. "2.0.1-rc.*" while a patch release is in
|
|
96
|
+
* progress) versus an RC for a version that hasn't been branched off yet and
|
|
97
|
+
* only exists on develop (e.g. "2.1.0-rc.*" while that release branch hasn't
|
|
98
|
+
* been cut). Scaffold from the release branch when it exists in both
|
|
99
|
+
* repositories, otherwise fall back to develop.
|
|
100
|
+
*
|
|
101
|
+
* Otherwise, the own "X.Y.Z" version - whether resolved via npm's `latest`
|
|
102
|
+
* dist-tag (bare invocation) or an explicit `@X.Y.Z` pin - scaffolds from the
|
|
103
|
+
* matching "vX.Y.Z" tag when it exists in both repositories. If it doesn't
|
|
104
|
+
* (e.g. `latest` lagging behind the repos, or a pin that predates one repo's
|
|
105
|
+
* tagging), fall back to the highest release tag common to both, rather than
|
|
106
|
+
* a mismatched pairing of one tagged repo at that version and another repo
|
|
107
|
+
* at a different release. Exits with an error if no matching release tag
|
|
108
|
+
* exists in both repositories.
|
|
109
|
+
*/
|
|
40
110
|
function resolveRef() {
|
|
41
|
-
|
|
42
|
-
|
|
111
|
+
if (version.includes('-')) {
|
|
112
|
+
const releaseBranch = 'release/' + version.split('-')[0]
|
|
113
|
+
if (
|
|
114
|
+
branchExists(COUNTRYCONFIG_REPO_URL, releaseBranch) &&
|
|
115
|
+
branchExists(INFRASTRUCTURE_REPO_URL, releaseBranch)
|
|
116
|
+
) {
|
|
117
|
+
return releaseBranch
|
|
118
|
+
}
|
|
43
119
|
return 'develop'
|
|
44
|
-
}
|
|
120
|
+
}
|
|
45
121
|
|
|
46
122
|
const tag = 'v' + version
|
|
47
123
|
if (
|
|
@@ -51,13 +127,24 @@ function resolveRef() {
|
|
|
51
127
|
return tag
|
|
52
128
|
}
|
|
53
129
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
'
|
|
58
|
-
|
|
130
|
+
const latestCommonTag = getLatestCommonReleaseTag()
|
|
131
|
+
if (latestCommonTag) {
|
|
132
|
+
console.warn(
|
|
133
|
+
'\nWarning: tag "' +
|
|
134
|
+
tag +
|
|
135
|
+
'" was not found in both repositories; falling back to the latest ' +
|
|
136
|
+
'available release, ' +
|
|
137
|
+
latestCommonTag +
|
|
138
|
+
'.'
|
|
139
|
+
)
|
|
140
|
+
return latestCommonTag
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
console.error(
|
|
144
|
+
'\nError: no matching release tag was found in both the country config and ' +
|
|
145
|
+
'infrastructure repositories.'
|
|
59
146
|
)
|
|
60
|
-
|
|
147
|
+
process.exit(1)
|
|
61
148
|
}
|
|
62
149
|
|
|
63
150
|
function cloneRepository(repoUrl, ref, targetDir) {
|
|
@@ -664,7 +664,8 @@ var userRole = z11.preprocess(
|
|
|
664
664
|
var scopeOptionsPlaceEvent = z11.object({
|
|
665
665
|
event: scopeByEvent,
|
|
666
666
|
placeOfEvent: JurisdictionFilter.optional(),
|
|
667
|
-
createdBy: UserFilter.optional()
|
|
667
|
+
createdBy: UserFilter.optional(),
|
|
668
|
+
createdIn: JurisdictionFilter.optional()
|
|
668
669
|
}).describe("Options applicable to all record scopes.");
|
|
669
670
|
var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
|
|
670
671
|
declaredIn: JurisdictionFilter.optional(),
|
|
@@ -704,7 +705,8 @@ var ScopeOptionKey = AllScopeOptions.keyof();
|
|
|
704
705
|
var ResolvedScopeOptionsPlaceEvent = z11.object({
|
|
705
706
|
event: scopeByEvent,
|
|
706
707
|
placeOfEvent: UUID.nullish(),
|
|
707
|
-
createdBy: z11.string().optional()
|
|
708
|
+
createdBy: z11.string().optional(),
|
|
709
|
+
createdIn: UUID.nullish()
|
|
708
710
|
}).describe(
|
|
709
711
|
"Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
|
|
710
712
|
);
|
package/dist/cli.js
CHANGED
|
@@ -2191,7 +2191,8 @@ var userRole = z3.preprocess(
|
|
|
2191
2191
|
var scopeOptionsPlaceEvent = z3.object({
|
|
2192
2192
|
event: scopeByEvent,
|
|
2193
2193
|
placeOfEvent: JurisdictionFilter.optional(),
|
|
2194
|
-
createdBy: UserFilter.optional()
|
|
2194
|
+
createdBy: UserFilter.optional(),
|
|
2195
|
+
createdIn: JurisdictionFilter.optional()
|
|
2195
2196
|
}).describe("Options applicable to all record scopes.");
|
|
2196
2197
|
var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
|
|
2197
2198
|
declaredIn: JurisdictionFilter.optional(),
|
|
@@ -2231,7 +2232,8 @@ var ScopeOptionKey = AllScopeOptions.keyof();
|
|
|
2231
2232
|
var ResolvedScopeOptionsPlaceEvent = z3.object({
|
|
2232
2233
|
event: scopeByEvent,
|
|
2233
2234
|
placeOfEvent: UUID.nullish(),
|
|
2234
|
-
createdBy: z3.string().optional()
|
|
2235
|
+
createdBy: z3.string().optional(),
|
|
2236
|
+
createdIn: UUID.nullish()
|
|
2235
2237
|
}).describe(
|
|
2236
2238
|
"Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
|
|
2237
2239
|
);
|
|
@@ -3251,7 +3253,7 @@ Saving ${modifiedFiles.length} modified file(s)...`);
|
|
|
3251
3253
|
console.warn(
|
|
3252
3254
|
`
|
|
3253
3255
|
WARNING: Some '${FHIR_IMPORT}' usages remain and need manual cleanup:
|
|
3254
|
-
` + warnings.map((
|
|
3256
|
+
` + warnings.map((line2) => ` - ${line2}`).join("\n")
|
|
3255
3257
|
);
|
|
3256
3258
|
}
|
|
3257
3259
|
console.log(
|
|
@@ -3353,12 +3355,12 @@ function processFile11(sourceFile) {
|
|
|
3353
3355
|
}
|
|
3354
3356
|
if (inRewrittenAncestor) continue;
|
|
3355
3357
|
const start = fn.getStart();
|
|
3356
|
-
const
|
|
3358
|
+
const line2 = sourceFile.getLineAndColumnAtPos(start).line;
|
|
3357
3359
|
const name = describeFunction(fn);
|
|
3358
3360
|
if (import_ts_morph15.Node.isFunctionDeclaration(fn) || import_ts_morph15.Node.isFunctionExpression(fn) || import_ts_morph15.Node.isMethodDeclaration(fn) || import_ts_morph15.Node.isArrowFunction(fn)) {
|
|
3359
3361
|
fn.setBodyText(`return ${REPLACEMENT_IDENTIFIER}`);
|
|
3360
3362
|
}
|
|
3361
|
-
rewrittenFunctions.push({ name, line });
|
|
3363
|
+
rewrittenFunctions.push({ name, line: line2 });
|
|
3362
3364
|
rewrittenSet.add(fn);
|
|
3363
3365
|
}
|
|
3364
3366
|
for (const decl of importsWithTarget) {
|
|
@@ -5143,6 +5145,282 @@ async function runUpgrade(dockerSwarm) {
|
|
|
5143
5145
|
}
|
|
5144
5146
|
}
|
|
5145
5147
|
|
|
5148
|
+
// src/verify/endpoints.ts
|
|
5149
|
+
var useColor = Boolean(process.stdout.isTTY) && !process.env.NO_COLOR;
|
|
5150
|
+
var wrap = (code) => (text) => useColor ? `\x1B[${code}m${text}\x1B[0m` : text;
|
|
5151
|
+
var bold = wrap(1);
|
|
5152
|
+
var dim = wrap(2);
|
|
5153
|
+
var red = wrap(31);
|
|
5154
|
+
var green = wrap(32);
|
|
5155
|
+
var yellow = wrap(33);
|
|
5156
|
+
var REQUEST_TIMEOUT_MS = 15e3;
|
|
5157
|
+
var DEFAULT_TARGET_URL = "http://localhost:3040";
|
|
5158
|
+
var REQUIRED_PUBLIC_ENDPOINTS = [
|
|
5159
|
+
{ method: "GET", path: "/client-config.js" },
|
|
5160
|
+
{ method: "GET", path: "/login-config.js" },
|
|
5161
|
+
{ method: "GET", path: "/handlebars.js" },
|
|
5162
|
+
{ method: "GET", path: "/content/client" },
|
|
5163
|
+
{ method: "GET", path: "/content/login" },
|
|
5164
|
+
{ method: "GET", path: "/content/map.geojson" },
|
|
5165
|
+
{ method: "GET", path: "/content/country-logo" },
|
|
5166
|
+
{ method: "GET", path: "/config/application" },
|
|
5167
|
+
{ method: "GET", path: "/config/workqueues" },
|
|
5168
|
+
{ method: "GET", path: "/config/locations" },
|
|
5169
|
+
{ method: "GET", path: "/config/roles" },
|
|
5170
|
+
{ method: "GET", path: "/config/events" }
|
|
5171
|
+
];
|
|
5172
|
+
var PROBE_SEGMENT = "verify-endpoints-probe";
|
|
5173
|
+
var SECURED_TRIGGER_USER_EVENTS = [
|
|
5174
|
+
"user-created",
|
|
5175
|
+
"user-updated",
|
|
5176
|
+
"username-reminder",
|
|
5177
|
+
"reset-password",
|
|
5178
|
+
"reset-password-by-admin",
|
|
5179
|
+
"resend-invite",
|
|
5180
|
+
"2fa",
|
|
5181
|
+
"all-user-notification",
|
|
5182
|
+
"change-phone-number",
|
|
5183
|
+
"change-email-address"
|
|
5184
|
+
];
|
|
5185
|
+
var SECURED_ENDPOINTS = [
|
|
5186
|
+
...SECURED_TRIGGER_USER_EVENTS.map(
|
|
5187
|
+
(event) => ({
|
|
5188
|
+
method: "POST",
|
|
5189
|
+
path: `/triggers/user/${event}`
|
|
5190
|
+
})
|
|
5191
|
+
),
|
|
5192
|
+
{ method: "POST", path: "/trigger/telemetry" },
|
|
5193
|
+
{ method: "GET", path: "/triggers/system/ready" },
|
|
5194
|
+
{
|
|
5195
|
+
method: "GET",
|
|
5196
|
+
path: `/certificates/${PROBE_SEGMENT}`,
|
|
5197
|
+
label: "/certificates/{id}"
|
|
5198
|
+
},
|
|
5199
|
+
{ method: "GET", path: "/certificates" },
|
|
5200
|
+
{ method: "GET", path: "/config/users" }
|
|
5201
|
+
];
|
|
5202
|
+
var FALLBACK_EVENT_TRIGGERS = [
|
|
5203
|
+
{
|
|
5204
|
+
method: "POST",
|
|
5205
|
+
path: `/trigger/events/${PROBE_SEGMENT}/actions/${PROBE_SEGMENT}`,
|
|
5206
|
+
label: "/trigger/events/{event}/actions/{action}"
|
|
5207
|
+
},
|
|
5208
|
+
{
|
|
5209
|
+
method: "POST",
|
|
5210
|
+
path: `/trigger/events/birth/actions/${PROBE_SEGMENT}`,
|
|
5211
|
+
label: "/trigger/events/birth/actions/{action}"
|
|
5212
|
+
},
|
|
5213
|
+
{
|
|
5214
|
+
method: "POST",
|
|
5215
|
+
path: `/trigger/events/death/actions/${PROBE_SEGMENT}`,
|
|
5216
|
+
label: "/trigger/events/death/actions/{action}"
|
|
5217
|
+
}
|
|
5218
|
+
];
|
|
5219
|
+
var isSuccess = (status) => status !== "error" && status >= 200 && status < 300;
|
|
5220
|
+
var requiresAuthOrAbsent = (status) => status === 401 || status === 403 || status === 404;
|
|
5221
|
+
async function requestStatus(url, method) {
|
|
5222
|
+
const controller = new AbortController();
|
|
5223
|
+
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
5224
|
+
try {
|
|
5225
|
+
const response = await fetch(url, {
|
|
5226
|
+
method,
|
|
5227
|
+
signal: controller.signal,
|
|
5228
|
+
// Sent without an Authorization header on purpose. A secured route
|
|
5229
|
+
// rejects with 401/403 before ever reading the body.
|
|
5230
|
+
headers: method === "POST" ? { "Content-Type": "application/json" } : void 0,
|
|
5231
|
+
body: method === "POST" ? "{}" : void 0
|
|
5232
|
+
});
|
|
5233
|
+
return response.status;
|
|
5234
|
+
} catch {
|
|
5235
|
+
return "error";
|
|
5236
|
+
} finally {
|
|
5237
|
+
clearTimeout(timer);
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5240
|
+
function toEventTriggerConfig(value) {
|
|
5241
|
+
if (typeof value !== "object" || value === null) {
|
|
5242
|
+
return null;
|
|
5243
|
+
}
|
|
5244
|
+
const record = value;
|
|
5245
|
+
if (typeof record.id !== "string") {
|
|
5246
|
+
return null;
|
|
5247
|
+
}
|
|
5248
|
+
const actions = Array.isArray(record.actions) ? Array.from(
|
|
5249
|
+
new Set(
|
|
5250
|
+
record.actions.map((action) => {
|
|
5251
|
+
if (typeof action !== "object" || action === null) {
|
|
5252
|
+
return null;
|
|
5253
|
+
}
|
|
5254
|
+
const type = action.type;
|
|
5255
|
+
return typeof type === "string" ? type : null;
|
|
5256
|
+
}).filter((type) => type !== null)
|
|
5257
|
+
)
|
|
5258
|
+
) : [];
|
|
5259
|
+
return { id: record.id, actions };
|
|
5260
|
+
}
|
|
5261
|
+
async function fetchEventConfigs(baseUrl) {
|
|
5262
|
+
const controller = new AbortController();
|
|
5263
|
+
const timer = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS);
|
|
5264
|
+
try {
|
|
5265
|
+
const response = await fetch(`${baseUrl}/config/events`, {
|
|
5266
|
+
signal: controller.signal
|
|
5267
|
+
});
|
|
5268
|
+
if (!response.ok) {
|
|
5269
|
+
return null;
|
|
5270
|
+
}
|
|
5271
|
+
const body = await response.json();
|
|
5272
|
+
if (!Array.isArray(body)) {
|
|
5273
|
+
return null;
|
|
5274
|
+
}
|
|
5275
|
+
return body.map(toEventTriggerConfig).filter((config) => config !== null);
|
|
5276
|
+
} catch {
|
|
5277
|
+
return null;
|
|
5278
|
+
} finally {
|
|
5279
|
+
clearTimeout(timer);
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
function resolveBaseUrl(input) {
|
|
5283
|
+
const withProtocol = /^https?:\/\//i.test(input) ? input : `https://${input}`;
|
|
5284
|
+
return withProtocol.replace(/\/+$/, "");
|
|
5285
|
+
}
|
|
5286
|
+
function describeStatus(status) {
|
|
5287
|
+
return status === "error" ? "no response" : `HTTP ${status}`;
|
|
5288
|
+
}
|
|
5289
|
+
function endpointLabel(check) {
|
|
5290
|
+
const shown = check.label ?? check.path;
|
|
5291
|
+
const suffix = check.label ? dim(` \u2192 ${check.path}`) : "";
|
|
5292
|
+
return `${check.method} ${shown}${suffix}`;
|
|
5293
|
+
}
|
|
5294
|
+
function line(ok, label, detail) {
|
|
5295
|
+
const mark = ok ? green("\u2713") : red("\u2717");
|
|
5296
|
+
return ` ${mark} ${label} ${dim(`(${detail})`)}`;
|
|
5297
|
+
}
|
|
5298
|
+
function securedDetail(status) {
|
|
5299
|
+
if (status === 401 || status === 403) {
|
|
5300
|
+
return `${describeStatus(status)} \u2014 auth required`;
|
|
5301
|
+
}
|
|
5302
|
+
if (status === 404) {
|
|
5303
|
+
return `${describeStatus(status)} \u2014 not implemented`;
|
|
5304
|
+
}
|
|
5305
|
+
if (status === "error") {
|
|
5306
|
+
return `${describeStatus(status)} \u2014 request failed`;
|
|
5307
|
+
}
|
|
5308
|
+
return `${describeStatus(status)} \u2014 INSECURE: processed without a token`;
|
|
5309
|
+
}
|
|
5310
|
+
async function runVerifyEndpoints(target = DEFAULT_TARGET_URL) {
|
|
5311
|
+
const baseUrl = resolveBaseUrl(target);
|
|
5312
|
+
console.log(bold(`Verifying country config endpoints at ${baseUrl}
|
|
5313
|
+
`));
|
|
5314
|
+
let failures = 0;
|
|
5315
|
+
console.log(bold("Required public endpoints (must respond 2xx):"));
|
|
5316
|
+
for (const check of REQUIRED_PUBLIC_ENDPOINTS) {
|
|
5317
|
+
const status = await requestStatus(`${baseUrl}${check.path}`, check.method);
|
|
5318
|
+
const ok = isSuccess(status);
|
|
5319
|
+
if (!ok) {
|
|
5320
|
+
failures++;
|
|
5321
|
+
}
|
|
5322
|
+
const detail = status === 404 ? `${describeStatus(status)} \u2014 missing` : ok ? describeStatus(status) : `${describeStatus(status)} \u2014 unexpected`;
|
|
5323
|
+
console.log(line(ok, endpointLabel(check), detail));
|
|
5324
|
+
}
|
|
5325
|
+
{
|
|
5326
|
+
const path24 = `/fonts/${PROBE_SEGMENT}.ttf`;
|
|
5327
|
+
const status = await requestStatus(`${baseUrl}${path24}`, "GET");
|
|
5328
|
+
const ok = status === 200 || status === 404;
|
|
5329
|
+
if (!ok) {
|
|
5330
|
+
failures++;
|
|
5331
|
+
}
|
|
5332
|
+
let detail;
|
|
5333
|
+
if (status === 404) {
|
|
5334
|
+
detail = `${describeStatus(status)} \u2014 reachable (made-up filename)`;
|
|
5335
|
+
} else if (status === 200) {
|
|
5336
|
+
detail = describeStatus(status);
|
|
5337
|
+
} else if (status === 401 || status === 403) {
|
|
5338
|
+
detail = `${describeStatus(status)} \u2014 must be public`;
|
|
5339
|
+
} else {
|
|
5340
|
+
detail = `${describeStatus(status)} \u2014 unexpected`;
|
|
5341
|
+
}
|
|
5342
|
+
console.log(line(ok, `GET /fonts/{filename}${dim(` \u2192 ${path24}`)}`, detail));
|
|
5343
|
+
}
|
|
5344
|
+
console.log();
|
|
5345
|
+
console.log(bold("Secured endpoints (must be absent or require auth):"));
|
|
5346
|
+
for (const check of SECURED_ENDPOINTS) {
|
|
5347
|
+
const status = await requestStatus(`${baseUrl}${check.path}`, check.method);
|
|
5348
|
+
const ok = requiresAuthOrAbsent(status);
|
|
5349
|
+
if (!ok) {
|
|
5350
|
+
failures++;
|
|
5351
|
+
}
|
|
5352
|
+
console.log(line(ok, endpointLabel(check), securedDetail(status)));
|
|
5353
|
+
}
|
|
5354
|
+
console.log();
|
|
5355
|
+
console.log(bold("Event action triggers (must be absent or require auth):"));
|
|
5356
|
+
const events = await fetchEventConfigs(baseUrl);
|
|
5357
|
+
if (!events) {
|
|
5358
|
+
console.log(
|
|
5359
|
+
" " + yellow(
|
|
5360
|
+
"Could not read /config/events; falling back to route-pattern checks."
|
|
5361
|
+
)
|
|
5362
|
+
);
|
|
5363
|
+
for (const check of FALLBACK_EVENT_TRIGGERS) {
|
|
5364
|
+
const status = await requestStatus(
|
|
5365
|
+
`${baseUrl}${check.path}`,
|
|
5366
|
+
check.method
|
|
5367
|
+
);
|
|
5368
|
+
const ok = requiresAuthOrAbsent(status);
|
|
5369
|
+
if (!ok) {
|
|
5370
|
+
failures++;
|
|
5371
|
+
}
|
|
5372
|
+
console.log(line(ok, endpointLabel(check), securedDetail(status)));
|
|
5373
|
+
}
|
|
5374
|
+
} else if (events.length === 0) {
|
|
5375
|
+
console.log(" " + yellow("No events configured."));
|
|
5376
|
+
} else {
|
|
5377
|
+
for (const event of events) {
|
|
5378
|
+
const actions = event.actions.length ? event.actions : [PROBE_SEGMENT];
|
|
5379
|
+
const failed = [];
|
|
5380
|
+
for (const action of actions) {
|
|
5381
|
+
const status = await requestStatus(
|
|
5382
|
+
`${baseUrl}/trigger/events/${event.id}/actions/${action}`,
|
|
5383
|
+
"POST"
|
|
5384
|
+
);
|
|
5385
|
+
if (!requiresAuthOrAbsent(status)) {
|
|
5386
|
+
failed.push({ action, status });
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5389
|
+
const pattern = `POST /trigger/events/${event.id}/actions/{action}`;
|
|
5390
|
+
if (failed.length === 0) {
|
|
5391
|
+
console.log(
|
|
5392
|
+
line(true, pattern, `${actions.length} action(s) \u2014 all require auth`)
|
|
5393
|
+
);
|
|
5394
|
+
} else {
|
|
5395
|
+
for (const failure of failed) {
|
|
5396
|
+
failures++;
|
|
5397
|
+
console.log(
|
|
5398
|
+
line(
|
|
5399
|
+
false,
|
|
5400
|
+
`POST /trigger/events/${event.id}/actions/${failure.action}`,
|
|
5401
|
+
securedDetail(failure.status)
|
|
5402
|
+
)
|
|
5403
|
+
);
|
|
5404
|
+
}
|
|
5405
|
+
const okCount = actions.length - failed.length;
|
|
5406
|
+
if (okCount > 0) {
|
|
5407
|
+
console.log(
|
|
5408
|
+
line(true, pattern, `${okCount} other action(s) require auth`)
|
|
5409
|
+
);
|
|
5410
|
+
}
|
|
5411
|
+
}
|
|
5412
|
+
}
|
|
5413
|
+
}
|
|
5414
|
+
console.log();
|
|
5415
|
+
if (failures > 0) {
|
|
5416
|
+
console.log(
|
|
5417
|
+
red(bold(`\u2717 ${failures} check(s) failed.`)) + yellow(" See the lines marked \u2717 above.")
|
|
5418
|
+
);
|
|
5419
|
+
process.exit(1);
|
|
5420
|
+
}
|
|
5421
|
+
console.log(green(bold("\u2713 All endpoint checks passed.")));
|
|
5422
|
+
}
|
|
5423
|
+
|
|
5146
5424
|
// src/cli.ts
|
|
5147
5425
|
var args = process.argv.slice(2);
|
|
5148
5426
|
var USAGE = `
|
|
@@ -5152,9 +5430,31 @@ Commands:
|
|
|
5152
5430
|
environment init Initialise a new environment
|
|
5153
5431
|
upgrade Upgrade an existing environment
|
|
5154
5432
|
check-translations Check translation files for completeness
|
|
5433
|
+
verify-endpoints Verify the locally-running country config exposes the
|
|
5434
|
+
expected endpoints and keeps secured ones locked down
|
|
5155
5435
|
|
|
5156
5436
|
Run 'opencrvs <command> --help' for more information on a command.
|
|
5157
5437
|
`.trim();
|
|
5438
|
+
var VERIFY_ENDPOINTS_USAGE = `
|
|
5439
|
+
Usage: opencrvs verify-endpoints [country-config-url]
|
|
5440
|
+
|
|
5441
|
+
Run this after 'opencrvs upgrade', with the upgraded country config running
|
|
5442
|
+
locally, to confirm it still behaves correctly. It checks over HTTP that:
|
|
5443
|
+
- required public endpoints exist (respond 2xx), and
|
|
5444
|
+
- user-notification trigger endpoints are either absent or reject
|
|
5445
|
+
unauthenticated requests (never processed without a token).
|
|
5446
|
+
|
|
5447
|
+
Arguments:
|
|
5448
|
+
[country-config-url] Optional. Domain or URL of the country config
|
|
5449
|
+
service. Defaults to 'http://localhost:3040', the
|
|
5450
|
+
port country config listens on locally. A bare
|
|
5451
|
+
domain is assumed to use https.
|
|
5452
|
+
|
|
5453
|
+
Options:
|
|
5454
|
+
-h, --help Show this message.
|
|
5455
|
+
|
|
5456
|
+
Exits with a non-zero status if any check fails.
|
|
5457
|
+
`.trim();
|
|
5158
5458
|
var UPGRADE_USAGE = `
|
|
5159
5459
|
Usage: opencrvs upgrade [options]
|
|
5160
5460
|
|
|
@@ -5181,6 +5481,8 @@ function main28() {
|
|
|
5181
5481
|
return handleUpgrade();
|
|
5182
5482
|
case "check-translations":
|
|
5183
5483
|
return handleCheckTranslations();
|
|
5484
|
+
case "verify-endpoints":
|
|
5485
|
+
return handleVerifyEndpoints();
|
|
5184
5486
|
default:
|
|
5185
5487
|
console.error(`Unknown command: ${command}
|
|
5186
5488
|
`);
|
|
@@ -5243,4 +5545,29 @@ function handleCheckTranslations() {
|
|
|
5243
5545
|
console.warn("This command is not implemented yet!");
|
|
5244
5546
|
process.exit(1);
|
|
5245
5547
|
}
|
|
5548
|
+
async function handleVerifyEndpoints() {
|
|
5549
|
+
const verifyArgs = args.slice(1);
|
|
5550
|
+
if (verifyArgs.includes("--help") || verifyArgs.includes("-h")) {
|
|
5551
|
+
console.log(VERIFY_ENDPOINTS_USAGE);
|
|
5552
|
+
process.exit(0);
|
|
5553
|
+
}
|
|
5554
|
+
const positional = verifyArgs.filter((arg) => !arg.startsWith("-"));
|
|
5555
|
+
if (positional.length > 1) {
|
|
5556
|
+
console.error(
|
|
5557
|
+
`Unexpected extra argument(s): ${positional.slice(1).join(", ")}
|
|
5558
|
+
`
|
|
5559
|
+
);
|
|
5560
|
+
console.log(VERIFY_ENDPOINTS_USAGE);
|
|
5561
|
+
process.exit(1);
|
|
5562
|
+
}
|
|
5563
|
+
try {
|
|
5564
|
+
await runVerifyEndpoints(positional[0]);
|
|
5565
|
+
} catch (error) {
|
|
5566
|
+
console.error(
|
|
5567
|
+
"Endpoint verification failed:",
|
|
5568
|
+
error instanceof Error ? error.message : error
|
|
5569
|
+
);
|
|
5570
|
+
process.exit(1);
|
|
5571
|
+
}
|
|
5572
|
+
}
|
|
5246
5573
|
main28();
|
|
@@ -8284,6 +8284,10 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8284
8284
|
input: {
|
|
8285
8285
|
name: string;
|
|
8286
8286
|
scopes: string[];
|
|
8287
|
+
credentials?: {
|
|
8288
|
+
clientId: string;
|
|
8289
|
+
clientSecret: string;
|
|
8290
|
+
} | undefined;
|
|
8287
8291
|
};
|
|
8288
8292
|
output: {
|
|
8289
8293
|
clientId: string;
|
|
@@ -8314,7 +8318,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8314
8318
|
scopes: string[];
|
|
8315
8319
|
status: string;
|
|
8316
8320
|
createdAt: string;
|
|
8317
|
-
createdBy: string & import("zod").$brand<"UUID"
|
|
8321
|
+
createdBy: (string & import("zod").$brand<"UUID">) | null;
|
|
8318
8322
|
}[];
|
|
8319
8323
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
8320
8324
|
}>;
|
|
@@ -8329,7 +8333,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
|
|
|
8329
8333
|
status: string;
|
|
8330
8334
|
shaSecret: string | null;
|
|
8331
8335
|
createdAt: string;
|
|
8332
|
-
createdBy: string & import("zod").$brand<"UUID"
|
|
8336
|
+
createdBy: (string & import("zod").$brand<"UUID">) | null;
|
|
8333
8337
|
};
|
|
8334
8338
|
meta: import("trpc-to-openapi").OpenApiMeta;
|
|
8335
8339
|
}>;
|
|
@@ -94,16 +94,16 @@ export declare const user: typeof userSerializer & {
|
|
|
94
94
|
scope: (scope: import("../scopes").ScopeType) => {
|
|
95
95
|
attribute: (option: import("../scopes").ScopeOptionKey) => {
|
|
96
96
|
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
|
|
97
|
-
$option: "role" | "event" | "placeOfEvent" | "createdBy" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
97
|
+
$option: "role" | "event" | "placeOfEvent" | "createdBy" | "createdIn" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
jurisdiction: (jurisdiction: import("../scopes").JurisdictionFilter | {
|
|
101
101
|
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
|
|
102
|
-
$option: "role" | "event" | "placeOfEvent" | "createdBy" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
102
|
+
$option: "role" | "event" | "placeOfEvent" | "createdBy" | "createdIn" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
103
103
|
}) => {
|
|
104
104
|
$jurisdiction: "administrativeArea" | "location" | "all" | {
|
|
105
105
|
$scope: "record.search" | "record.create" | "record.read" | "record.declare" | "record.notify" | "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register" | "record.print-certified-copies" | "record.request-correction" | "record.correct" | "record.unassign-others" | "record.custom-action" | "bypassratelimit" | "record.reindex" | "user.data-seeding" | "integration.create" | "record.import" | "config.update-all" | "attachment.upload" | "profile.electronic-signature" | "user.read-only-my-audit" | "performance.read" | "performance.read-dashboards" | "performance.vital-statistics-export" | "record.confirm-registration" | "record.reject-registration" | "organisation.read-locations" | "user.read" | "user.create" | "user.edit" | "user.search" | "workqueue" | "dashboard.view";
|
|
106
|
-
$option: "role" | "event" | "placeOfEvent" | "createdBy" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
106
|
+
$option: "role" | "event" | "placeOfEvent" | "createdBy" | "createdIn" | "declaredIn" | "declaredBy" | "registeredIn" | "registeredBy" | "accessLevel" | "ids";
|
|
107
107
|
};
|
|
108
108
|
};
|
|
109
109
|
};
|
|
@@ -214,6 +214,7 @@ export declare const ActionConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
214
214
|
id: z.ZodString;
|
|
215
215
|
title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
|
|
216
216
|
requireCompletionToContinue: z.ZodDefault<z.ZodBoolean>;
|
|
217
|
+
showClearButton: z.ZodOptional<z.ZodBoolean>;
|
|
217
218
|
fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
|
|
218
219
|
conditional: z.ZodOptional<z.ZodAny>;
|
|
219
220
|
type: z.ZodDefault<z.ZodLiteral<"FORM">>;
|
|
@@ -221,6 +222,7 @@ export declare const ActionConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
221
222
|
id: z.ZodString;
|
|
222
223
|
title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
|
|
223
224
|
requireCompletionToContinue: z.ZodDefault<z.ZodBoolean>;
|
|
225
|
+
showClearButton: z.ZodOptional<z.ZodBoolean>;
|
|
224
226
|
fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
|
|
225
227
|
conditional: z.ZodOptional<z.ZodAny>;
|
|
226
228
|
type: z.ZodLiteral<"VERIFICATION">;
|
|
@@ -270,6 +272,7 @@ export declare const ActionConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
270
272
|
id: z.ZodString;
|
|
271
273
|
title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
|
|
272
274
|
requireCompletionToContinue: z.ZodDefault<z.ZodBoolean>;
|
|
275
|
+
showClearButton: z.ZodOptional<z.ZodBoolean>;
|
|
273
276
|
fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
|
|
274
277
|
conditional: z.ZodOptional<z.ZodAny>;
|
|
275
278
|
type: z.ZodDefault<z.ZodLiteral<"FORM">>;
|
|
@@ -277,6 +280,7 @@ export declare const ActionConfig: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
277
280
|
id: z.ZodString;
|
|
278
281
|
title: z.ZodObject<import("./TranslationConfig").MessageDescriptorZod, z.core.$strip>;
|
|
279
282
|
requireCompletionToContinue: z.ZodDefault<z.ZodBoolean>;
|
|
283
|
+
showClearButton: z.ZodOptional<z.ZodBoolean>;
|
|
280
284
|
fields: z.ZodArray<z.ZodType<FieldConfig, import("./FieldConfig").FieldConfigInput, z.core.$ZodTypeInternals<FieldConfig, import("./FieldConfig").FieldConfigInput>>>;
|
|
281
285
|
conditional: z.ZodOptional<z.ZodAny>;
|
|
282
286
|
type: z.ZodLiteral<"VERIFICATION">;
|
|
@@ -140,6 +140,7 @@ export declare const FieldConfigSchema: z.ZodObject<{
|
|
|
140
140
|
event: "event";
|
|
141
141
|
placeOfEvent: "placeOfEvent";
|
|
142
142
|
createdBy: "createdBy";
|
|
143
|
+
createdIn: "createdIn";
|
|
143
144
|
declaredIn: "declaredIn";
|
|
144
145
|
declaredBy: "declaredBy";
|
|
145
146
|
registeredIn: "registeredIn";
|
|
@@ -318,6 +319,7 @@ export declare const EventFieldConfigSchema: z.ZodObject<{
|
|
|
318
319
|
event: "event";
|
|
319
320
|
placeOfEvent: "placeOfEvent";
|
|
320
321
|
createdBy: "createdBy";
|
|
322
|
+
createdIn: "createdIn";
|
|
321
323
|
declaredIn: "declaredIn";
|
|
322
324
|
declaredBy: "declaredBy";
|
|
323
325
|
registeredIn: "registeredIn";
|
|
@@ -472,6 +474,7 @@ export declare const AdvancedSearchField: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
472
474
|
event: "event";
|
|
473
475
|
placeOfEvent: "placeOfEvent";
|
|
474
476
|
createdBy: "createdBy";
|
|
477
|
+
createdIn: "createdIn";
|
|
475
478
|
declaredIn: "declaredIn";
|
|
476
479
|
declaredBy: "declaredBy";
|
|
477
480
|
registeredIn: "registeredIn";
|
|
@@ -618,6 +621,7 @@ export declare const AdvancedSearchField: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
618
621
|
event: "event";
|
|
619
622
|
placeOfEvent: "placeOfEvent";
|
|
620
623
|
createdBy: "createdBy";
|
|
624
|
+
createdIn: "createdIn";
|
|
621
625
|
declaredIn: "declaredIn";
|
|
622
626
|
declaredBy: "declaredBy";
|
|
623
627
|
registeredIn: "registeredIn";
|
|
@@ -775,6 +779,7 @@ export declare const AdvancedSearchConfig: z.ZodObject<{
|
|
|
775
779
|
event: "event";
|
|
776
780
|
placeOfEvent: "placeOfEvent";
|
|
777
781
|
createdBy: "createdBy";
|
|
782
|
+
createdIn: "createdIn";
|
|
778
783
|
declaredIn: "declaredIn";
|
|
779
784
|
declaredBy: "declaredBy";
|
|
780
785
|
registeredIn: "registeredIn";
|
|
@@ -921,6 +926,7 @@ export declare const AdvancedSearchConfig: z.ZodObject<{
|
|
|
921
926
|
event: "event";
|
|
922
927
|
placeOfEvent: "placeOfEvent";
|
|
923
928
|
createdBy: "createdBy";
|
|
929
|
+
createdIn: "createdIn";
|
|
924
930
|
declaredIn: "declaredIn";
|
|
925
931
|
declaredBy: "declaredBy";
|
|
926
932
|
registeredIn: "registeredIn";
|