@htilabs/platform-common-models 0.47.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/authz/index.cjs +243 -16
- package/dist/authz/index.cjs.map +1 -1
- package/dist/authz/index.d.cts +164 -1
- package/dist/authz/index.d.ts +164 -1
- package/dist/authz/index.js +241 -16
- package/dist/authz/index.js.map +1 -1
- package/dist/index.cjs +243 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +241 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
- package/src/__tests__/authz-function-door.test.ts +461 -0
- package/src/__tests__/authz-resolve.test.ts +46 -0
- package/src/authz/functionDoor.ts +229 -0
- package/src/authz/index.ts +2 -0
- package/src/authz/resolveEffectiveFunctions.ts +17 -52
- package/src/authz/roleCodes.ts +59 -0
- package/src/authz/storedReads.ts +92 -0
- package/src/generated/authzBrowserTables.ts +151 -0
package/dist/index.cjs
CHANGED
|
@@ -591,6 +591,7 @@ __export(src_exports, {
|
|
|
591
591
|
calendarDateOf: () => calendarDateOf,
|
|
592
592
|
canonicalCoreIndicator: () => canonicalCoreIndicator,
|
|
593
593
|
canonicalIncidentParticipationRole: () => canonicalIncidentParticipationRole,
|
|
594
|
+
canonicalRoleCode: () => canonicalRoleCode,
|
|
594
595
|
canonicalServiceState: () => canonicalServiceState,
|
|
595
596
|
carCorrectionReasonSot: () => carCorrectionReason_v2_1_0_default,
|
|
596
597
|
cascadeExclusions: () => cascadeExclusions,
|
|
@@ -661,6 +662,7 @@ __export(src_exports, {
|
|
|
661
662
|
formSchemaOptions: () => formSchemaOptions,
|
|
662
663
|
formSectionRefSchema: () => formSectionRefSchema,
|
|
663
664
|
frequencyCadenceSot: () => frequencyCadence_v1_0_0_default,
|
|
665
|
+
functionDoor: () => functionDoor,
|
|
664
666
|
funderSot: () => funder_v1_0_0_default,
|
|
665
667
|
genderIdentitySot: () => genderIdentity_v1_0_0_default,
|
|
666
668
|
genderReportingSot: () => genderReporting_v1_0_0_default,
|
|
@@ -16096,13 +16098,7 @@ var CORE_FUNCTIONS_EVALUABLE_KEYS = [
|
|
|
16096
16098
|
"viewing_level_3_components"
|
|
16097
16099
|
];
|
|
16098
16100
|
|
|
16099
|
-
// src/authz/
|
|
16100
|
-
var CANON_EVALUABLE = new Set(
|
|
16101
|
-
CORE_FUNCTIONS_EVALUABLE_KEYS.filter((k) => Object.hasOwn(CoreFunctionsKeys, k))
|
|
16102
|
-
);
|
|
16103
|
-
function isCanonEvaluableFunction(code) {
|
|
16104
|
-
return CANON_EVALUABLE.has(code);
|
|
16105
|
-
}
|
|
16101
|
+
// src/authz/storedReads.ts
|
|
16106
16102
|
var ABSENT = { kind: "absent" };
|
|
16107
16103
|
var MALFORMED = { kind: "malformed" };
|
|
16108
16104
|
function isPlainObject(v) {
|
|
@@ -16124,6 +16120,27 @@ function readState(map, code) {
|
|
|
16124
16120
|
if (v === DEFAULT_BOUND_STATE.NA) return PERMISSION_STATE.NEVER;
|
|
16125
16121
|
return typeof v === "string" && STATES.has(v) ? v : "malformed";
|
|
16126
16122
|
}
|
|
16123
|
+
function tier1State(roleFunctions, code) {
|
|
16124
|
+
const listed = roleFunctions.kind === "map" ? readState(roleFunctions.map, code) : void 0;
|
|
16125
|
+
if (listed === void 0) return void 0;
|
|
16126
|
+
return listed === "malformed" ? PERMISSION_STATE.NEVER : listed;
|
|
16127
|
+
}
|
|
16128
|
+
function catalogRowCode(row) {
|
|
16129
|
+
if (!isPlainObject(row)) return null;
|
|
16130
|
+
const code = own(row, "code");
|
|
16131
|
+
const retired = own(row, "retired");
|
|
16132
|
+
if (typeof code !== "string") return null;
|
|
16133
|
+
if (retired !== void 0 && retired !== false) return null;
|
|
16134
|
+
return code;
|
|
16135
|
+
}
|
|
16136
|
+
|
|
16137
|
+
// src/authz/resolveEffectiveFunctions.ts
|
|
16138
|
+
var CANON_EVALUABLE = new Set(
|
|
16139
|
+
CORE_FUNCTIONS_EVALUABLE_KEYS.filter((k) => Object.hasOwn(CoreFunctionsKeys, k))
|
|
16140
|
+
);
|
|
16141
|
+
function isCanonEvaluableFunction(code) {
|
|
16142
|
+
return CANON_EVALUABLE.has(code);
|
|
16143
|
+
}
|
|
16127
16144
|
function teamValueRestricts(map, code) {
|
|
16128
16145
|
const gate = readState(map, code);
|
|
16129
16146
|
return gate !== void 0 && gate !== PERMISSION_STATE.PREF_YES && gate !== PERMISSION_STATE.ALWAYS;
|
|
@@ -16191,12 +16208,8 @@ function resolveEffectiveFunctions(input) {
|
|
|
16191
16208
|
if (heldCodes.length === 0) return [];
|
|
16192
16209
|
const vocabulary = [];
|
|
16193
16210
|
for (const fn of catalog) {
|
|
16194
|
-
|
|
16195
|
-
|
|
16196
|
-
const retired = own(fn, "retired");
|
|
16197
|
-
if (typeof code !== "string" || !isCanonEvaluableFunction(code)) continue;
|
|
16198
|
-
if (retired !== void 0 && retired !== false) continue;
|
|
16199
|
-
vocabulary.push(code);
|
|
16211
|
+
const code = catalogRowCode(fn);
|
|
16212
|
+
if (code !== null && isCanonEvaluableFunction(code)) vocabulary.push(code);
|
|
16200
16213
|
}
|
|
16201
16214
|
const agencyAll = readContainer(input.agencyOverrides);
|
|
16202
16215
|
const team = compileTeamGate(input.teamPolicy);
|
|
@@ -16208,9 +16221,8 @@ function resolveEffectiveFunctions(input) {
|
|
|
16208
16221
|
const agency = agencyAll.kind === "map" ? readContainer(own(agencyAll.map, roleCode)) : agencyAll;
|
|
16209
16222
|
for (const fn of vocabulary) {
|
|
16210
16223
|
if (granted.has(fn)) continue;
|
|
16211
|
-
const
|
|
16212
|
-
if (
|
|
16213
|
-
const tier1 = listed === "malformed" ? PERMISSION_STATE.NEVER : listed;
|
|
16224
|
+
const tier1 = tier1State(roleFunctions, fn);
|
|
16225
|
+
if (tier1 === void 0) continue;
|
|
16214
16226
|
let state = tier1;
|
|
16215
16227
|
if (tier1 !== PERMISSION_STATE.ALWAYS && tier1 !== PERMISSION_STATE.NEVER) {
|
|
16216
16228
|
const override = agency.kind === "malformed" ? "malformed" : agency.kind === "map" ? readState(agency.map, fn) : void 0;
|
|
@@ -16341,6 +16353,219 @@ function codebookDefaultBound(functionCode, roleCode) {
|
|
|
16341
16353
|
return Object.hasOwn(roles, roleCode) ? roles[roleCode] : null;
|
|
16342
16354
|
}
|
|
16343
16355
|
|
|
16356
|
+
// src/generated/authzBrowserTables.ts
|
|
16357
|
+
var CORE_FUNCTION_TITLES = {
|
|
16358
|
+
"agency_info_manage": "Edit own agency's profile",
|
|
16359
|
+
"announcement_publish": "Publish announcements",
|
|
16360
|
+
"api_key_manage": "Manage API keys",
|
|
16361
|
+
"assessments_conduct": "Conduct Assessments",
|
|
16362
|
+
"auth_model_manage_platform": "Manage platform authorization model",
|
|
16363
|
+
"case_assign_reassign": "Assign / reassign case ownership",
|
|
16364
|
+
"case_claim": "Claim inbound share (PAVE)",
|
|
16365
|
+
"case_close": "Close case",
|
|
16366
|
+
"case_collaborator_add": "Share / Add Users to a case",
|
|
16367
|
+
"case_edit": "Edit Cases (add intake, case notes, goals, services)",
|
|
16368
|
+
"case_needs_action_flag_manage": "Manage case escalation / needs-action flags",
|
|
16369
|
+
"case_reopen": "Case Re-open",
|
|
16370
|
+
"case_side_panel_use": "Utilize side panel for comments/notes and uploads",
|
|
16371
|
+
"case_status_manage": "Change case status",
|
|
16372
|
+
"case_transfer_bulk": "Bulk transfer cases (turnover)",
|
|
16373
|
+
"case_view": "View (agency) Cases",
|
|
16374
|
+
"case_visibility_manage": "Go dark / restore case visibility",
|
|
16375
|
+
"ci_periodic_review": "Review criminal intelligence record (periodic)",
|
|
16376
|
+
"ci_record_purge_or_retire": "Retire or purge criminal intelligence record",
|
|
16377
|
+
"ci_record_validate": "Validate criminal intelligence record",
|
|
16378
|
+
"ci_to_evidence_export_authorize": "Authorize criminal intelligence \u2192 evidence export",
|
|
16379
|
+
"deconfliction_alert_acknowledge": "Accept a deconfliction alert",
|
|
16380
|
+
"deconfliction_unmask": "Unmask a deconfliction",
|
|
16381
|
+
"determination_perform": "Perform Determinations",
|
|
16382
|
+
"disclose_external_request": "Request External Disclosure",
|
|
16383
|
+
"enrollment_manage": "Manage program enrollments",
|
|
16384
|
+
"exit_discharge_conduct": "Conduct program exit / discharge",
|
|
16385
|
+
"export_deidentified": "Export de-identified reports/datasets",
|
|
16386
|
+
"goals_plan_manage": "Create and manage plans, goals, action steps",
|
|
16387
|
+
"idb_record_create": "Create IDB record",
|
|
16388
|
+
"indicator_manual_add": "Add a manual indicator",
|
|
16389
|
+
"investigation_create_claim": "Create Investigation + Claim a Tip / Lead",
|
|
16390
|
+
"investigation_session_run": "Run an investigation session",
|
|
16391
|
+
"investigative_database_search": "Search account IDB",
|
|
16392
|
+
"investigative_request_send": "Submit an investigative request (Ask HTI)",
|
|
16393
|
+
"lead_create": "Create a Tip / Lead",
|
|
16394
|
+
"lead_publish": "Publish a Tip / Lead",
|
|
16395
|
+
"lead_route_assign": "Route / assign a lead to an agency",
|
|
16396
|
+
"lead_triage_manage": "Triage leads",
|
|
16397
|
+
"magic_link_share_send": "Send Magic Link Shares",
|
|
16398
|
+
"mandatory_report_send": "Send mandatory report",
|
|
16399
|
+
"member_account_report_generate": "Member Account Report generation",
|
|
16400
|
+
"member_onboarding_support": "Assist member onboarding (support)",
|
|
16401
|
+
"message_moderate": "Moderate messages",
|
|
16402
|
+
"message_send": "Send platform messages",
|
|
16403
|
+
"milestone_log": "Log investigative milestones",
|
|
16404
|
+
"needs_priorities_conduct": "Conduct needs assessment and immediate priorities",
|
|
16405
|
+
"network_corpus_access": "Access raw/worked machine-network corpus",
|
|
16406
|
+
"note_open_departed_author": "Open a deactivated author's private notes",
|
|
16407
|
+
"onboarding_config_sign_off": "Approve the configuration summary (Phase III sign-off)",
|
|
16408
|
+
"open_source_search": "Search across all open source information",
|
|
16409
|
+
"person_association_update": "Assign or update person\u2019s role, relationships, phone numbers or social media associations",
|
|
16410
|
+
"person_merge_manage": "Manage person identity merges",
|
|
16411
|
+
"platform_perm_modify": "Modify Platform Permissions",
|
|
16412
|
+
"profile_domain_edit": "Edit subject profile domains",
|
|
16413
|
+
"record_activity_view": "View a record's activity log",
|
|
16414
|
+
"record_print": "Export/Print",
|
|
16415
|
+
"referral_receive_external": "Receive External Referrals",
|
|
16416
|
+
"referral_receive_internal": "Receive Internal Referrals",
|
|
16417
|
+
"referral_send_external": "Refer External (Excluding VSP to LE)",
|
|
16418
|
+
"referral_send_internal": "Refer Internal",
|
|
16419
|
+
"roi_submit_manage": "Upload/Edit/Submit ROI",
|
|
16420
|
+
"role_assign": "Role Assignment",
|
|
16421
|
+
"roles_accounts_toggle": "Toggle Roles / Accounts",
|
|
16422
|
+
"sandbox_environment_manage": "Manage sandbox and testing environments",
|
|
16423
|
+
"screening_conduct": "Conduct Screenings",
|
|
16424
|
+
"screening_view": "View Victim/Abuse Screening Responses",
|
|
16425
|
+
"service_log_manage": "Log and manage service instances",
|
|
16426
|
+
"session_create": "Record creation (sessions, cases, etc.)",
|
|
16427
|
+
"share_config": "Sharing Configuration",
|
|
16428
|
+
"share_revoke": "Revoke an active share / ROI",
|
|
16429
|
+
"share_rule_approve_cross_agency": "Approve cross-agency sharing rules",
|
|
16430
|
+
"share_vsp_to_le": "VSP to LE Share",
|
|
16431
|
+
"srl_manage": "Manage the agency's Service Registry (SRL)",
|
|
16432
|
+
"supervisee_thread_view": "View supervisee threads",
|
|
16433
|
+
"support_ticket_triage": "Triage support tickets / bug reports",
|
|
16434
|
+
"system_diagnostics_view": "View system diagnostics and logs (support)",
|
|
16435
|
+
"team_config_manage": "Team structure & admin scoping (account-level)",
|
|
16436
|
+
"team_membership_manage": "Manage team membership",
|
|
16437
|
+
"team_share_narrowing": "Narrow a team's sharing",
|
|
16438
|
+
"team_workflow_config_manage": "Manage team workflow configuration",
|
|
16439
|
+
"training_gate_manage": "Manage training/certification gates (i.e. required modules for roles + teams)",
|
|
16440
|
+
"usr_manage": "User Management",
|
|
16441
|
+
"viewing_config_manage": "Configure internal viewing (Type A)",
|
|
16442
|
+
"viewing_level_1_search": "Non-owned case identity on search",
|
|
16443
|
+
"viewing_level_2_autocomplete": "Non-owned case identity in autocomplete",
|
|
16444
|
+
"viewing_level_3_components": "Non-owned case component access"
|
|
16445
|
+
};
|
|
16446
|
+
var CANON_ROLE_CODE_LIST = [
|
|
16447
|
+
"case_nav",
|
|
16448
|
+
"healthcare_provider_medical",
|
|
16449
|
+
"behavioral_health_provider",
|
|
16450
|
+
"crisis_response",
|
|
16451
|
+
"intel_analyst",
|
|
16452
|
+
"investigator",
|
|
16453
|
+
"le_liaison_vsp",
|
|
16454
|
+
"legal_advocate",
|
|
16455
|
+
"mandatory_reporter",
|
|
16456
|
+
"mdt_participant",
|
|
16457
|
+
"prosecutor_review",
|
|
16458
|
+
"public_reporter",
|
|
16459
|
+
"research_analytics",
|
|
16460
|
+
"screener",
|
|
16461
|
+
"volunteer",
|
|
16462
|
+
"PLT-ADM",
|
|
16463
|
+
"PLT-SUP",
|
|
16464
|
+
"MEM-ADM",
|
|
16465
|
+
"TEAM-ADM",
|
|
16466
|
+
"AUD",
|
|
16467
|
+
"DATA-ADM",
|
|
16468
|
+
"GOV-AUD",
|
|
16469
|
+
"CIRO",
|
|
16470
|
+
"SUP",
|
|
16471
|
+
"TRAIN-ADM"
|
|
16472
|
+
];
|
|
16473
|
+
var ROLE_CODE_RE_KEYS = {
|
|
16474
|
+
"missingness_root": null,
|
|
16475
|
+
"unknown": null,
|
|
16476
|
+
"anonymous": null,
|
|
16477
|
+
"data_not_collected": null,
|
|
16478
|
+
"hotline_op": "crisis_response",
|
|
16479
|
+
"case_advocate": "case_nav",
|
|
16480
|
+
"leads_investigator": "investigator",
|
|
16481
|
+
"MISSINGNESS-ROOT": null,
|
|
16482
|
+
"UNKNOWN": null,
|
|
16483
|
+
"ANONYMOUS": null,
|
|
16484
|
+
"DATA-NOT-COLLECTED": null,
|
|
16485
|
+
"acct_adm": "MEM-ADM",
|
|
16486
|
+
"ACCT-ADM": "MEM-ADM"
|
|
16487
|
+
};
|
|
16488
|
+
|
|
16489
|
+
// src/authz/roleCodes.ts
|
|
16490
|
+
var CANON_ROLE_CODES = new Set(CANON_ROLE_CODE_LIST);
|
|
16491
|
+
var SOURCES = new Map(Object.entries(ROLE_CODE_RE_KEYS));
|
|
16492
|
+
function canonicalRoleCode(code) {
|
|
16493
|
+
if (typeof code !== "string") return null;
|
|
16494
|
+
if (CANON_ROLE_CODES.has(code)) return code;
|
|
16495
|
+
return SOURCES.has(code) ? SOURCES.get(code) ?? null : null;
|
|
16496
|
+
}
|
|
16497
|
+
|
|
16498
|
+
// src/authz/functionDoor.ts
|
|
16499
|
+
var NOT_OFFERED = Object.freeze({
|
|
16500
|
+
offered: false,
|
|
16501
|
+
allowed: false,
|
|
16502
|
+
reason: null
|
|
16503
|
+
});
|
|
16504
|
+
function labelFor(functionKey, lookup2) {
|
|
16505
|
+
let label;
|
|
16506
|
+
if (typeof lookup2 === "function") label = lookup2(functionKey);
|
|
16507
|
+
else if (lookup2 && Object.hasOwn(lookup2, functionKey)) label = lookup2[functionKey];
|
|
16508
|
+
if (typeof label === "string" && label.trim()) return label;
|
|
16509
|
+
return Object.hasOwn(CORE_FUNCTION_TITLES, functionKey) ? CORE_FUNCTION_TITLES[functionKey] : functionKey;
|
|
16510
|
+
}
|
|
16511
|
+
function drawsControl(state) {
|
|
16512
|
+
return state === PERMISSION_STATE.ALWAYS || state === PERMISSION_STATE.PREF_YES || state === PERMISSION_STATE.PREF_NO;
|
|
16513
|
+
}
|
|
16514
|
+
function indexRoleRows(rows) {
|
|
16515
|
+
const byCode = /* @__PURE__ */ new Map();
|
|
16516
|
+
if (!Array.isArray(rows)) return byCode;
|
|
16517
|
+
for (const r of rows) {
|
|
16518
|
+
const code = isPlainObject(r) ? own(r, "code") : void 0;
|
|
16519
|
+
if (isPlainObject(r) && typeof code === "string") byCode.set(code, r);
|
|
16520
|
+
}
|
|
16521
|
+
return byCode;
|
|
16522
|
+
}
|
|
16523
|
+
function liveRoleBound(rows, roleCode, functionKey) {
|
|
16524
|
+
const row = rows.get(roleCode);
|
|
16525
|
+
if (row === void 0) return false;
|
|
16526
|
+
const container = readContainer(own(row, "functions"));
|
|
16527
|
+
if (container.kind === "malformed") return false;
|
|
16528
|
+
return drawsControl(tier1State(container, functionKey));
|
|
16529
|
+
}
|
|
16530
|
+
function codebookRoleBound(roleCode, functionKey) {
|
|
16531
|
+
const bound = codebookDefaultBound(functionKey, roleCode);
|
|
16532
|
+
return bound !== DEFAULT_BOUND_STATE.NA && drawsControl(bound);
|
|
16533
|
+
}
|
|
16534
|
+
function functionDoor(input) {
|
|
16535
|
+
const { functionKey } = input;
|
|
16536
|
+
if (typeof functionKey !== "string" || !isCanonEvaluableFunction(functionKey)) {
|
|
16537
|
+
return { ...NOT_OFFERED };
|
|
16538
|
+
}
|
|
16539
|
+
let granted = false;
|
|
16540
|
+
for (const fn of input.effectiveFunctions) {
|
|
16541
|
+
if (fn === functionKey) {
|
|
16542
|
+
granted = true;
|
|
16543
|
+
break;
|
|
16544
|
+
}
|
|
16545
|
+
}
|
|
16546
|
+
if (granted) return { offered: true, allowed: true, reason: null };
|
|
16547
|
+
const functions = input.functions;
|
|
16548
|
+
if (functions !== void 0 && functions !== null) {
|
|
16549
|
+
const kept = Array.isArray(functions) && functions.some((row) => catalogRowCode(row) === functionKey);
|
|
16550
|
+
if (!kept) return { ...NOT_OFFERED };
|
|
16551
|
+
}
|
|
16552
|
+
const liveRows = input.roles;
|
|
16553
|
+
const live = liveRows !== void 0 && liveRows !== null ? indexRoleRows(liveRows) : null;
|
|
16554
|
+
const roleCodes = input.roleCodes;
|
|
16555
|
+
const bound = (Array.isArray(roleCodes) ? roleCodes : []).some((code) => {
|
|
16556
|
+
const canon = canonicalRoleCode(code);
|
|
16557
|
+
if (canon === null) return false;
|
|
16558
|
+
if (live === null) return codebookRoleBound(canon, functionKey);
|
|
16559
|
+
return liveRoleBound(live, canon, functionKey) || typeof code === "string" && code !== canon && liveRoleBound(live, code, functionKey);
|
|
16560
|
+
});
|
|
16561
|
+
if (!bound) return { ...NOT_OFFERED };
|
|
16562
|
+
return {
|
|
16563
|
+
offered: true,
|
|
16564
|
+
allowed: false,
|
|
16565
|
+
reason: `${labelFor(functionKey, input.label)} is not part of your roles`
|
|
16566
|
+
};
|
|
16567
|
+
}
|
|
16568
|
+
|
|
16344
16569
|
// src/generated/sharingPlatformStarter.ts
|
|
16345
16570
|
var SHARING_PLATFORM_STARTER_SOURCE = {
|
|
16346
16571
|
"monolith": {
|
|
@@ -72372,6 +72597,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
72372
72597
|
calendarDateOf,
|
|
72373
72598
|
canonicalCoreIndicator,
|
|
72374
72599
|
canonicalIncidentParticipationRole,
|
|
72600
|
+
canonicalRoleCode,
|
|
72375
72601
|
canonicalServiceState,
|
|
72376
72602
|
carCorrectionReasonSot,
|
|
72377
72603
|
cascadeExclusions,
|
|
@@ -72442,6 +72668,7 @@ var CVC_197_VALUES = selectableCodes(
|
|
|
72442
72668
|
formSchemaOptions,
|
|
72443
72669
|
formSectionRefSchema,
|
|
72444
72670
|
frequencyCadenceSot,
|
|
72671
|
+
functionDoor,
|
|
72445
72672
|
funderSot,
|
|
72446
72673
|
genderIdentitySot,
|
|
72447
72674
|
genderReportingSot,
|