identityscope 0.28.3 → 0.28.5

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.
Files changed (91) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +914 -917
  3. package/SECURITY.md +56 -56
  4. package/dist/node/cli.js +26 -26
  5. package/dist/node/monthly.js +17 -17
  6. package/package.json +2 -2
  7. package/reports/access-profile-members.yaml +29 -29
  8. package/reports/access-profile-membership-counts.yaml +17 -17
  9. package/reports/access-profiles-without-owner.yaml +16 -16
  10. package/reports/access-request-audit-trail.yaml +36 -36
  11. package/reports/accounts-by-source.yaml +19 -19
  12. package/reports/active-identities-without-manager.yaml +22 -22
  13. package/reports/aggregation-failures.yaml +29 -29
  14. package/reports/aggregation-history.yaml +27 -27
  15. package/reports/all-sources.yaml +16 -16
  16. package/reports/application-accounts.yaml +32 -32
  17. package/reports/application-entitlements.yaml +31 -31
  18. package/reports/campaign-progress.yaml +23 -23
  19. package/reports/certification-decisions.yaml +31 -31
  20. package/reports/direct-reports-per-manager.yaml +20 -20
  21. package/reports/disabled-accounts-of-active-people.yaml +33 -33
  22. package/reports/duplicate-emails.yaml +16 -16
  23. package/reports/entitlement-holders.yaml +35 -35
  24. package/reports/entitlements-held-by-inactive-identities.yaml +31 -31
  25. package/reports/entitlements-without-owner.yaml +28 -28
  26. package/reports/identities-by-lifecycle-state.yaml +15 -15
  27. package/reports/identities-missing-key-attributes.yaml +27 -27
  28. package/reports/identities-with-processing-errors.yaml +19 -19
  29. package/reports/identity-attribute-mappings.yaml +27 -27
  30. package/reports/machine-accounts.yaml +28 -28
  31. package/reports/managers-and-direct-reports.yaml +23 -23
  32. package/reports/most-access.yaml +18 -18
  33. package/reports/new-identities.yaml +24 -24
  34. package/reports/old-passwords.yaml +35 -35
  35. package/reports/pending-reviews-by-reviewer.yaml +20 -20
  36. package/reports/person-access.yaml +31 -31
  37. package/reports/privileged-access.yaml +29 -29
  38. package/reports/provisioning-error-causes.yaml +27 -27
  39. package/reports/provisioning-errors.yaml +32 -32
  40. package/reports/provisioning-failures.yaml +28 -28
  41. package/reports/recent-access-requests.yaml +22 -22
  42. package/reports/recent-activity.yaml +32 -32
  43. package/reports/recent-leavers.yaml +34 -34
  44. package/reports/role-members.yaml +29 -29
  45. package/reports/role-membership-counts.yaml +18 -18
  46. package/reports/roles-without-owner.yaml +17 -17
  47. package/reports/sources-needing-attention.yaml +23 -23
  48. package/reports/stuck-access-requests.yaml +29 -29
  49. package/reports/team-access.yaml +30 -30
  50. package/reports/terminated-users-with-active-accounts.yaml +46 -46
  51. package/reports/uncorrelated-accounts.yaml +38 -38
  52. package/ui/js/00-setup.js +6 -6
  53. package/ui/js/01-small-helpers.js +143 -143
  54. package/ui/js/02-connection.js +150 -150
  55. package/ui/js/03-health-check.js +17 -17
  56. package/ui/js/04-library.js +135 -135
  57. package/ui/js/05-pickers.js +163 -163
  58. package/ui/js/06-report-view.js +157 -157
  59. package/ui/js/07-fields.js +85 -85
  60. package/ui/js/08-designer.js +360 -360
  61. package/ui/js/09-yaml.js +22 -22
  62. package/ui/js/10-instant-check.js +171 -171
  63. package/ui/js/11-lookup.js +161 -161
  64. package/ui/js/12-tenant.js +115 -115
  65. package/ui/js/13-source-configuration-and-diagnostics.js +64 -64
  66. package/ui/js/14-certifications.js +68 -68
  67. package/ui/js/15-monthly-report.js +24 -24
  68. package/ui/js/16-ownership.js +39 -39
  69. package/ui/js/17-compare-tenants.js +102 -102
  70. package/ui/js/18-audit.js +181 -181
  71. package/ui/js/19-insights.js +108 -108
  72. package/ui/js/20-role-mining.js +35 -35
  73. package/ui/js/21-share-reports.js +45 -45
  74. package/ui/js/22-partner-overview-all-customer-tenants.js +228 -228
  75. package/ui/js/23-in-app-guidance.js +217 -217
  76. package/ui/js/24-role-tools.js +220 -220
  77. package/ui/js/25-schedules.js +264 -264
  78. package/ui/js/26-start.js +7 -7
  79. package/ui/js/27-warnings.js +224 -224
  80. package/ui/js/28-audit-readiness.js +99 -99
  81. package/ui/js/29-lifecycle.js +182 -182
  82. package/ui/js/30-labs.js +265 -265
  83. package/ui/js/31-build.js +203 -203
  84. package/ui/js/32-lab-examples.js +148 -148
  85. package/ui/js/33-finder.js +89 -89
  86. package/ui/js/34-governance.js +129 -129
  87. package/ui/js/35-watch.js +266 -266
  88. package/ui/js/36-model.js +247 -247
  89. package/ui/js/37-logs-and-watch.js +224 -224
  90. package/ui/shell.html +112 -112
  91. package/ui/style.css +350 -350
@@ -1,228 +1,228 @@
1
- // ---------- partner overview: all customer tenants ----------
2
- state.pt = { only: false, form: null, sel: null };
3
- var ST_WORD = { ok: 'OK', warn: 'Attention', bad: 'Problem', error: 'Could not check', off: 'Off' };
4
- var ST_CLS = { ok: 'ok', warn: 'warn', bad: 'bad', error: 'err', off: 'off' };
5
- function showPartner() {
6
- state.page = 'partner';
7
- $('connect').classList.add('hidden');
8
- $('app').classList.add('hidden');
9
- ['schedules', 'roles', 'checks', 'lookup', 'tenant-page', 'certs', 'monthly', 'warnings', 'nerm', 'logs', 'build'].forEach(function (p) { $(p).classList.add('hidden'); });
10
- ['nav-reports', 'nav-schedules', 'nav-roles', 'nav-checks', 'nav-lookup', 'nav-tenant', 'nav-build', 'nav-certs', 'nav-monthly', 'nav-warnings', 'nav-nerm', 'nav-logs'].forEach(function (n) { $(n).classList.remove('active'); });
11
- $('partner').classList.remove('hidden');
12
- $('btn-help').classList.remove('hidden');
13
- renderPartner();
14
- }
15
- function hidePartner() { $('partner').classList.add('hidden'); }
16
- function loadPartner() {
17
- return api('/api/tenants').then(function (d) { state.pt.data = d; state.pt.count = d.tenants.length; $('btn-partner-nav').classList.toggle('hidden', !d.tenants.length || $('nav').classList.contains('hidden')); return d; });
18
- }
19
- function renderPartner() {
20
- var P = state.pt;
21
- var outer = $('partner');
22
- outer.textContent = '';
23
- var w = el('div', { className: 'wrap', style: 'max-width:1500px' });
24
- outer.appendChild(w);
25
- var back = $('nav').classList.contains('hidden')
26
- ? el('button', { className: 'btn', onclick: function () { hidePartner(); api('/api/state').then(showConnect); } }, icon('logout'), 'Back to sign-in')
27
- : el('button', { className: 'btn', onclick: function () { hidePartner(); showPage('reports'); } }, 'Back to ' + ($('tenant').textContent || 'the tenant'));
28
- pageHead(w, 'db', '#0e7c66', '#e3f5f0', 'All tenants', 'The instant check of all your tenants in one place: sandbox, QA and production of one company, or the tenants of every customer a partner looks after. Read-only: each tenant uses its own credentials, kept only on this computer.', back);
29
- if (!P.data) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadPartner().then(renderPartner).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); }); return; }
30
- var d = P.data;
31
- var R = state.ptRun;
32
- var runBtn = el('button', { className: 'btn primary', disabled: !!R.busy || !d.tenants.length, onclick: function () { partnerRun({}); } }, icon('play'), d.lastRun ? 'Check all again' : 'Check all tenants');
33
- var only = el('input', { type: 'checkbox', checked: P.only });
34
- only.addEventListener('change', function () { P.only = only.checked; renderPartner(); });
35
- w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },
36
- el('button', { className: 'btn', onclick: function () { P.form = { isNew: true }; renderPartner(); } }, icon('plus'), 'Add a tenant'),
37
- el('label', { className: 'inline small' }, only, 'Only tenants that need attention'),
38
- el('span', { style: 'flex:1' }),
39
- el('button', { className: 'btn', 'aria-expanded': String(!!P.pick), onclick: function () { P.pick = P.pick ? null : d.checks.map(function (c) { return c.id; }); renderPartner(); } }, icon('cols'), 'Checks (' + d.checks.length + ' of ' + (d.allChecks || d.checks).length + ')'), runBtn));
40
- if (P.pick) {
41
- var boxes = el('div', { style: 'display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:6px 18px;margin:10px 0' });
42
- (d.allChecks || []).forEach(function (c) {
43
- var cb = el('input', { type: 'checkbox', checked: P.pick.indexOf(c.id) >= 0 });
44
- cb.addEventListener('change', function () { P.pick = cb.checked ? P.pick.concat([c.id]) : P.pick.filter(function (x) { return x !== c.id; }); });
45
- boxes.appendChild(el('label', { className: 'inline small' }, cb, c.label, c.quick ? null : el('span', { className: 'muted', text: ' (reads every identity or account; slow on large tenants)' })));
46
- });
47
- var savePick = function (ids) {
48
- api('/api/tenants/checks', 'PUT', { ids: ids }).then(function () { P.pick = null; P.data = null; renderPartner(); }, function (e) { toast(errorText(e)); });
49
- };
50
- w.appendChild(el('div', { className: 'card', style: 'padding:14px 16px' },
51
- el('b', { text: 'Checks on this page' }),
52
- el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'The quick checks show whether each tenant is running. The others stay on each tenant\u2019s own Instant check; tick one here only if you want it across all tenants. This also applies to the scheduled All tenants summary.' }),
53
- boxes,
54
- el('div', { className: 'bar' }, el('button', { className: 'btn primary', onclick: function () { savePick(P.pick); } }, 'Save'),
55
- el('button', { className: 'btn', onclick: function () { savePick((d.allChecks || []).filter(function (c) { return c.quick; }).map(function (c) { return c.id; })); } }, 'Back to the quick checks'),
56
- el('button', { className: 'btn', onclick: function () { P.pick = null; renderPartner(); } }, 'Cancel'))));
57
- }
58
- if (P.form) w.appendChild(partnerForm(P));
59
- if (R.busy) w.appendChild(busyBox(R.busy));
60
- if (R.error) w.appendChild(el('div', { className: 'error', text: R.error }));
61
- if (!d.tenants.length) {
62
- w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'No tenants yet' }), 'Add each tenant (your sandbox, QA and production, or each customer) with a read-only personal access token or API client from that tenant. Then check all of them with one click, or schedule "All tenants" daily for one summary by email or Teams.'));
63
- return;
64
- }
65
- var run = P.data.lastRun;
66
- var byId = {};
67
- if (run) run.results.forEach(function (r) { byId[r.id] = r; });
68
- var known = {};
69
- d.lastKnown.forEach(function (k) { known[k.id] = k; });
70
- if (run) w.appendChild(el('div', { className: 'banner ' + (/problem/.test(run.headline) ? 'bad' : /look at/.test(run.headline) ? 'warn' : 'ok') }, el('b', { text: run.headline }), el('span', { className: 'muted', text: 'checked ' + fmtWhen(run.at) }), el('span', { style: 'flex:1' }), R.job && R.data ? downloads(R.job) : null));
71
- else w.appendChild(el('div', { className: 'note', text: 'Showing the last results kept on this computer. Check all tenants for fresh numbers.' }));
72
- var order = { error: 0, bad: 1, warn: 2, ok: 3, off: 4, none: 5 };
73
- var rows = d.tenants.map(function (t) {
74
- var r = byId[t.id];
75
- var k = known[t.id] || { status: {}, values: {} };
76
- var overall = r ? r.status : worstOf(d.checks.map(function (c) { return k.status[c.id]; }).filter(Boolean));
77
- return { t: t, r: r, k: k, overall: overall || 'none' };
78
- }).filter(function (x) { return !P.only || x.overall === 'warn' || x.overall === 'bad' || x.overall === 'error'; })
79
- .sort(function (a, b) { return order[a.overall] - order[b.overall] || a.t.name.localeCompare(b.t.name); });
80
- var table = el('table', { className: 'grid-table ptable' });
81
- var head = el('tr', {}, el('th', { text: 'Tenant' }), el('th', { text: 'Overall' }), d.checks.map(function (c) { return el('th', { className: 'pcol', title: c.label, text: c.label }); }), el('th', {}, el('span', { className: 'sr-only', text: 'Actions' })));
82
- table.appendChild(el('thead', {}, head));
83
- var body = el('tbody');
84
- rows.forEach(function (x) {
85
- var t = x.t;
86
- var tr = el('tr', { className: P.sel && P.sel.id === t.id ? 'sel' : '' });
87
- tr.appendChild(el('td', {}, el('b', { text: t.name }), el('div', { className: 'muted small', text: new URL(t.baseUrl).host }), t.hasSecret ? null : el('div', { className: 'error small', text: 'No secret saved' }), tokenNote(x.r)));
88
- tr.appendChild(el('td', {}, x.overall === 'none' ? el('span', { className: 'muted small', text: 'Not checked yet' }) : el('span', { className: 'pstat ' + ST_CLS[x.overall], text: x.r && x.r.error ? 'Could not check' : ST_WORD[x.overall] })));
89
- if (x.r && x.r.error) {
90
- tr.appendChild(el('td', { colSpan: String(d.checks.length), className: 'small' }, el('span', { className: 'error', style: 'display:inline-block;margin:0', text: x.r.error })));
91
- } else d.checks.forEach(function (c) {
92
- var res = x.r ? x.r.results.filter(function (y) { return y.id === c.id; })[0] : null;
93
- var st = res ? res.status : x.k.status[c.id];
94
- var v = res ? res.value : x.k.values[c.id];
95
- var cell = el('td', { className: 'pcell' });
96
- if (st && st !== 'off') {
97
- var b = el('button', { className: 'pval ' + ST_CLS[st], title: c.label + ': ' + (res ? res.summary : ST_WORD[st]), text: st === 'error' ? '!' : (v === null || v === undefined ? '—' : fmtNum(v)), onclick: function () { P.sel = { id: t.id, check: c.id }; renderPartner(); } });
98
- if (res && x.r.worse.indexOf(c.id) >= 0) b.appendChild(el('span', { className: 'pnew', text: 'new' }));
99
- cell.appendChild(b);
100
- } else cell.appendChild(el('span', { className: 'muted', text: st === 'off' ? 'off' : '' }));
101
- tr.appendChild(cell);
102
- });
103
- tr.appendChild(el('td', { style: 'white-space:nowrap' },
104
- el('button', { className: 'btn sm primary', title: 'Open this tenant with all pages', disabled: !t.hasSecret, onclick: function () { openTenant(t); } }, 'Open'),
105
- el('button', { className: 'btn sm ghost', title: 'Edit', onclick: function () { P.form = { id: t.id, name: t.name, baseUrl: t.baseUrl, clientId: t.clientId, notes: t.notes || '' }; renderPartner(); } }, icon('sliders')),
106
- el('button', { className: 'btn sm ghost', title: 'Check only this tenant', disabled: !!R.busy, onclick: function () { partnerRun({ ids: [t.id] }); } }, icon('play'))));
107
- body.appendChild(tr);
108
- if (P.sel && P.sel.id === t.id) {
109
- var res = x.r ? x.r.results.filter(function (y) { return y.id === P.sel.check; })[0] : null;
110
- var c = d.checks.filter(function (y) { return y.id === P.sel.check; })[0];
111
- var inner = el('div', { className: 'pdetail' }, el('b', { text: t.name + ' · ' + (c ? c.label : '') }));
112
- if (res) {
113
- inner.appendChild(el('div', { text: res.summary }));
114
- if (res.error) inner.appendChild(el('div', { className: 'error small', text: res.error }));
115
- if (res.top && res.top.length) inner.appendChild(el('div', { className: 'muted small', text: res.top.slice(0, 5).map(function (y) { return y.label + ' (' + y.count + ')'; }).join(' · ') }));
116
- if (FIX && FIX[res.id]) inner.appendChild(el('div', { className: 'small', style: 'margin-top:6px' }, el('b', { text: 'How to fix: ' }), FIX[res.id][0]));
117
- } else inner.appendChild(el('div', { className: 'muted', text: 'From the last check kept on this computer. Check this tenant for details.' }));
118
- var go = CHECK_GOTO[P.sel.check];
119
- inner.appendChild(el('div', { className: 'bar', style: 'margin-top:8px' },
120
- el('button', { className: 'btn sm primary', disabled: !t.hasSecret, title: go ? 'Opens ' + t.name + ' on ' + go[2] : 'Opens ' + t.name, onclick: function () { openTenant(t, null, P.sel.check); } }, icon('play'), go ? 'Open ' + go[2] : 'Open in this tenant'),
121
- el('button', { className: 'btn sm ghost', onclick: function () { P.sel = null; renderPartner(); } }, 'Close')));
122
- body.appendChild(el('tr', {}, el('td', { colSpan: String(d.checks.length + 3) }, inner)));
123
- }
124
- });
125
- table.appendChild(body);
126
- w.appendChild(el('div', { className: 'card', style: 'padding:0;overflow-x:auto' }, table));
127
- w.appendChild(el('p', { className: 'muted small', text: 'Click a number for details and a link to the report or page behind it. "new" means new or worse since that tenant\'s previous check. Limits are the ones set on the Instant check page. Schedule "All tenants" on the Schedules page for one daily summary of every tenant.' }));
128
- }
129
- state.ptRun = {};
130
- function partnerRun(body) {
131
- runJobInto(state.ptRun, '/api/tenants/run', body, function () {
132
- if (state.ptRun.data && state.pt.data) state.pt.data.lastRun = state.ptRun.data;
133
- if (state.page === 'partner') renderPartner();
134
- });
135
- }
136
- function worstOf(list) {
137
- var rank = { error: 4, bad: 3, warn: 2, ok: 1, off: 0 };
138
- var best = null;
139
- list.forEach(function (s) { if (s && (best === null || rank[s] > rank[best])) best = s; });
140
- return best;
141
- }
142
- function fmtWhen(iso) { try { return new Date(iso).toLocaleString(); } catch (e) { return iso; } }
143
- // Where each check's details are: a report (run as soon as it opens) or a page and tab.
144
- var CHECK_GOTO = {
145
- 'provisioning-errors': ['report', 'provisioning-errors', 'the Provisioning errors report'],
146
- 'aggregation-failures': ['report', 'aggregation-failures', 'the Aggregation failures report'],
147
- 'stale-sources': ['report', 'aggregation-history', 'the Aggregations by source report'],
148
- 'sources-in-error': ['report', 'sources-needing-attention', 'the Sources needing attention report'],
149
- 'identity-errors': ['report', 'identities-with-processing-errors', 'the Identities with processing errors report'],
150
- 'stuck-requests': ['report', 'stuck-access-requests', 'the Stuck access requests report'],
151
- 'leavers-with-access': ['report', 'terminated-users-with-active-accounts', 'the Terminated users with active accounts report'],
152
- 'uncorrelated-growth': ['report', 'uncorrelated-accounts', 'the Uncorrelated accounts report'],
153
- 'campaigns-at-risk': ['report', 'campaign-progress', 'the Campaign progress report'],
154
- 'va-clusters': ['tenant', 'clusters', 'Tenant > Virtual Appliances'],
155
- 'api-credentials': ['tenant', 'credentials', 'Tenant > API credentials'],
156
- 'workflow-failures': ['tenant', 'workflows', 'Tenant > Workflows'],
157
- 'access-ending': ['warnings', 'ending', 'Warnings > Access ending'],
158
- 'stuck-on-leavers': ['warnings', 'stuck', 'Warnings > Waiting on leavers'],
159
- 'admins-left': ['warnings', 'admins', 'Warnings > ISC admins'],
160
- 'past-end-date': ['warnings', 'people', 'Warnings > End dates'],
161
- 'lifecycle-gaps': ['warnings', 'joiners', 'Warnings > Missed joiners'],
162
- 'slow-removals': ['certs', 'speed', 'Audit > Provisioning speed'],
163
- };
164
- function goToCheck(id) {
165
- var g = CHECK_GOTO[id];
166
- if (!g) { showPage('checks'); return; }
167
- if (g[0] === 'report') {
168
- showPage('reports');
169
- loadLibrary(g[1]).then(function () { if (state.current && state.current.def.id === g[1]) run(false); });
170
- return;
171
- }
172
- if (g[0] === 'tenant') state.tn.tab = g[1];
173
- if (g[0] === 'build') state.bt.tab = g[1];
174
- if (g[0] === 'warnings') wnState().tab = g[1];
175
- if (g[0] === 'certs') state.au.tab = g[1];
176
- showPage(g[0]);
177
- }
178
- function openTenant(t, page, check) {
179
- toast('Opening ' + t.name + '...');
180
- api('/api/tenants/' + t.id + '/open', 'POST', {}).then(function (r) {
181
- hidePartner();
182
- state.signedIn = false;
183
- showApp(r.tenant);
184
- $('tenant').textContent = t.name + ' · ' + r.tenant;
185
- $('tenant-chip').title = t.name + ' · ' + r.tenant;
186
- $('btn-partner-nav').classList.remove('hidden');
187
- if (check) goToCheck(check);
188
- else if (page) showPage(page);
189
- }).catch(function (e) { toast(errorText(e)); });
190
- }
191
- function partnerForm(P) {
192
- var F = P.form;
193
- var msg = el('div');
194
- var inp = function (key, ph, type) { var i = el('input', { className: 'input', value: F[key] || '', placeholder: ph || '', type: type || 'text', autocomplete: 'off' }); i.addEventListener('input', function () { F[key] = i.value; }); return i; };
195
- var save = el('button', { className: 'btn primary', onclick: function () {
196
- msg.textContent = '';
197
- save.disabled = true;
198
- var body = { name: F.name, baseUrl: F.baseUrl, clientId: F.clientId, clientSecret: F.clientSecret || '', notes: F.notes };
199
- (F.isNew ? api('/api/tenants', 'POST', body) : api('/api/tenants/' + F.id, 'PUT', body)).then(function (r) {
200
- P.form = null; P.data = null;
201
- toast((F.isNew ? 'Added ' : 'Saved ') + r.tenant.name + (r.note ? ' · ' + r.note : ''));
202
- renderPartner();
203
- }).catch(function (e) { save.disabled = false; msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });
204
- } }, icon('save'), F.isNew ? 'Test and add' : 'Save');
205
- var remove = F.isNew ? null : el('button', { className: 'btn ghost', onclick: function () {
206
- remove.replaceWith(el('span', { className: 'inline' }, el('span', { text: 'Remove ' + F.name + ' and its saved secret from this computer?' }),
207
- el('button', { className: 'btn sm', onclick: function () { api('/api/tenants/' + F.id, 'DELETE').then(function () { P.form = null; P.data = null; P.sel = null; toast('Removed'); renderPartner(); }); } }, 'Yes, remove'),
208
- el('button', { className: 'btn sm ghost', onclick: function () { renderPartner(); } }, 'No')));
209
- } }, icon('trash'), 'Remove');
210
- return el('section', { className: 'card', style: 'margin-bottom:14px' },
211
- el('h3', { style: 'margin-top:0', text: F.isNew ? 'Add a tenant' : 'Edit ' + F.name }),
212
- el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr' },
213
- el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Customer name' }), inp('name', 'e.g. Acme Corp')),
214
- el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Tenant' }), inp('baseUrl', 'acme, or paste the ISC address from your browser')),
215
- el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Client ID' }), inp('clientId')),
216
- el('label', { className: 'field' }, el('span', { className: 'lbl', text: F.isNew ? 'Client secret' : 'Client secret (leave empty to keep the saved one)' }), inp('clientSecret', '', 'password'))),
217
- el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Notes (optional)' }), inp('notes', 'e.g. contract ends June, contact: J. Smith')),
218
- el('p', { className: 'muted small', text: 'Use a personal access token or API client of a read-only identity in that tenant (for a customer\u2019s tenant, ask the customer for one). The secret is kept only in the owner-only secrets file on this computer and is never shown again. IdentityScope tests the connection before saving.' }),
219
- el('div', { className: 'bar' }, save, el('button', { className: 'btn ghost', onclick: function () { P.form = null; renderPartner(); } }, 'Cancel'), el('span', { style: 'flex:1' }), remove),
220
- msg);
221
- }
222
-
223
-
224
- function tokenNote(r) {
225
- var d = r && r.token ? r.token.daysToExpiry : null;
226
- if (d === null || d === undefined || d > 30) return null;
227
- return el('div', { className: 'small', style: 'margin-top:2px;white-space:nowrap;font-weight:600;color:' + (d <= 14 ? 'var(--danger)' : 'var(--warn)'), title: 'The personal access token IdentityScope uses for this tenant', text: d < 0 ? 'Token expired' : d === 0 ? 'Token expires today' : 'Token: ' + d + ' day' + (d === 1 ? '' : 's') + ' left' });
228
- }
1
+ // ---------- partner overview: all customer tenants ----------
2
+ state.pt = { only: false, form: null, sel: null };
3
+ var ST_WORD = { ok: 'OK', warn: 'Attention', bad: 'Problem', error: 'Could not check', off: 'Off' };
4
+ var ST_CLS = { ok: 'ok', warn: 'warn', bad: 'bad', error: 'err', off: 'off' };
5
+ function showPartner() {
6
+ state.page = 'partner';
7
+ $('connect').classList.add('hidden');
8
+ $('app').classList.add('hidden');
9
+ ['schedules', 'roles', 'checks', 'lookup', 'tenant-page', 'certs', 'monthly', 'warnings', 'nerm', 'logs', 'build'].forEach(function (p) { $(p).classList.add('hidden'); });
10
+ ['nav-reports', 'nav-schedules', 'nav-roles', 'nav-checks', 'nav-lookup', 'nav-tenant', 'nav-build', 'nav-certs', 'nav-monthly', 'nav-warnings', 'nav-nerm', 'nav-logs'].forEach(function (n) { $(n).classList.remove('active'); });
11
+ $('partner').classList.remove('hidden');
12
+ $('btn-help').classList.remove('hidden');
13
+ renderPartner();
14
+ }
15
+ function hidePartner() { $('partner').classList.add('hidden'); }
16
+ function loadPartner() {
17
+ return api('/api/tenants').then(function (d) { state.pt.data = d; state.pt.count = d.tenants.length; $('btn-partner-nav').classList.toggle('hidden', !d.tenants.length || $('nav').classList.contains('hidden')); return d; });
18
+ }
19
+ function renderPartner() {
20
+ var P = state.pt;
21
+ var outer = $('partner');
22
+ outer.textContent = '';
23
+ var w = el('div', { className: 'wrap', style: 'max-width:1500px' });
24
+ outer.appendChild(w);
25
+ var back = $('nav').classList.contains('hidden')
26
+ ? el('button', { className: 'btn', onclick: function () { hidePartner(); api('/api/state').then(showConnect); } }, icon('logout'), 'Back to sign-in')
27
+ : el('button', { className: 'btn', onclick: function () { hidePartner(); showPage('reports'); } }, 'Back to ' + ($('tenant').textContent || 'the tenant'));
28
+ pageHead(w, 'db', '#0e7c66', '#e3f5f0', 'All tenants', 'The instant check of all your tenants in one place: sandbox, QA and production of one company, or the tenants of every customer a partner looks after. Read-only: each tenant uses its own credentials, kept only on this computer.', back);
29
+ if (!P.data) { w.appendChild(el('div', { className: 'progress' }, el('span', { className: 'spinner' }), 'Loading...')); loadPartner().then(renderPartner).catch(function (e) { w.appendChild(el('div', { className: 'error', text: errorText(e) })); }); return; }
30
+ var d = P.data;
31
+ var R = state.ptRun;
32
+ var runBtn = el('button', { className: 'btn primary', disabled: !!R.busy || !d.tenants.length, onclick: function () { partnerRun({}); } }, icon('play'), d.lastRun ? 'Check all again' : 'Check all tenants');
33
+ var only = el('input', { type: 'checkbox', checked: P.only });
34
+ only.addEventListener('change', function () { P.only = only.checked; renderPartner(); });
35
+ w.appendChild(el('div', { className: 'bar', style: 'margin-bottom:14px' },
36
+ el('button', { className: 'btn', onclick: function () { P.form = { isNew: true }; renderPartner(); } }, icon('plus'), 'Add a tenant'),
37
+ el('label', { className: 'inline small' }, only, 'Only tenants that need attention'),
38
+ el('span', { style: 'flex:1' }),
39
+ el('button', { className: 'btn', 'aria-expanded': String(!!P.pick), onclick: function () { P.pick = P.pick ? null : d.checks.map(function (c) { return c.id; }); renderPartner(); } }, icon('cols'), 'Checks (' + d.checks.length + ' of ' + (d.allChecks || d.checks).length + ')'), runBtn));
40
+ if (P.pick) {
41
+ var boxes = el('div', { style: 'display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:6px 18px;margin:10px 0' });
42
+ (d.allChecks || []).forEach(function (c) {
43
+ var cb = el('input', { type: 'checkbox', checked: P.pick.indexOf(c.id) >= 0 });
44
+ cb.addEventListener('change', function () { P.pick = cb.checked ? P.pick.concat([c.id]) : P.pick.filter(function (x) { return x !== c.id; }); });
45
+ boxes.appendChild(el('label', { className: 'inline small' }, cb, c.label, c.quick ? null : el('span', { className: 'muted', text: ' (reads every identity or account; slow on large tenants)' })));
46
+ });
47
+ var savePick = function (ids) {
48
+ api('/api/tenants/checks', 'PUT', { ids: ids }).then(function () { P.pick = null; P.data = null; renderPartner(); }, function (e) { toast(errorText(e)); });
49
+ };
50
+ w.appendChild(el('div', { className: 'card', style: 'padding:14px 16px' },
51
+ el('b', { text: 'Checks on this page' }),
52
+ el('p', { className: 'muted small', style: 'margin:4px 0 0', text: 'The quick checks show whether each tenant is running. The others stay on each tenant\u2019s own Instant check; tick one here only if you want it across all tenants. This also applies to the scheduled All tenants summary.' }),
53
+ boxes,
54
+ el('div', { className: 'bar' }, el('button', { className: 'btn primary', onclick: function () { savePick(P.pick); } }, 'Save'),
55
+ el('button', { className: 'btn', onclick: function () { savePick((d.allChecks || []).filter(function (c) { return c.quick; }).map(function (c) { return c.id; })); } }, 'Back to the quick checks'),
56
+ el('button', { className: 'btn', onclick: function () { P.pick = null; renderPartner(); } }, 'Cancel'))));
57
+ }
58
+ if (P.form) w.appendChild(partnerForm(P));
59
+ if (R.busy) w.appendChild(busyBox(R.busy));
60
+ if (R.error) w.appendChild(el('div', { className: 'error', text: R.error }));
61
+ if (!d.tenants.length) {
62
+ w.appendChild(el('div', { className: 'empty' }, el('b', { text: 'No tenants yet' }), 'Add each tenant (your sandbox, QA and production, or each customer) with a read-only personal access token or API client from that tenant. Then check all of them with one click, or schedule "All tenants" daily for one summary by email or Teams.'));
63
+ return;
64
+ }
65
+ var run = P.data.lastRun;
66
+ var byId = {};
67
+ if (run) run.results.forEach(function (r) { byId[r.id] = r; });
68
+ var known = {};
69
+ d.lastKnown.forEach(function (k) { known[k.id] = k; });
70
+ if (run) w.appendChild(el('div', { className: 'banner ' + (/problem/.test(run.headline) ? 'bad' : /look at/.test(run.headline) ? 'warn' : 'ok') }, el('b', { text: run.headline }), el('span', { className: 'muted', text: 'checked ' + fmtWhen(run.at) }), el('span', { style: 'flex:1' }), R.job && R.data ? downloads(R.job) : null));
71
+ else w.appendChild(el('div', { className: 'note', text: 'Showing the last results kept on this computer. Check all tenants for fresh numbers.' }));
72
+ var order = { error: 0, bad: 1, warn: 2, ok: 3, off: 4, none: 5 };
73
+ var rows = d.tenants.map(function (t) {
74
+ var r = byId[t.id];
75
+ var k = known[t.id] || { status: {}, values: {} };
76
+ var overall = r ? r.status : worstOf(d.checks.map(function (c) { return k.status[c.id]; }).filter(Boolean));
77
+ return { t: t, r: r, k: k, overall: overall || 'none' };
78
+ }).filter(function (x) { return !P.only || x.overall === 'warn' || x.overall === 'bad' || x.overall === 'error'; })
79
+ .sort(function (a, b) { return order[a.overall] - order[b.overall] || a.t.name.localeCompare(b.t.name); });
80
+ var table = el('table', { className: 'grid-table ptable' });
81
+ var head = el('tr', {}, el('th', { text: 'Tenant' }), el('th', { text: 'Overall' }), d.checks.map(function (c) { return el('th', { className: 'pcol', title: c.label, text: c.label }); }), el('th', {}, el('span', { className: 'sr-only', text: 'Actions' })));
82
+ table.appendChild(el('thead', {}, head));
83
+ var body = el('tbody');
84
+ rows.forEach(function (x) {
85
+ var t = x.t;
86
+ var tr = el('tr', { className: P.sel && P.sel.id === t.id ? 'sel' : '' });
87
+ tr.appendChild(el('td', {}, el('b', { text: t.name }), el('div', { className: 'muted small', text: new URL(t.baseUrl).host }), t.hasSecret ? null : el('div', { className: 'error small', text: 'No secret saved' }), tokenNote(x.r)));
88
+ tr.appendChild(el('td', {}, x.overall === 'none' ? el('span', { className: 'muted small', text: 'Not checked yet' }) : el('span', { className: 'pstat ' + ST_CLS[x.overall], text: x.r && x.r.error ? 'Could not check' : ST_WORD[x.overall] })));
89
+ if (x.r && x.r.error) {
90
+ tr.appendChild(el('td', { colSpan: String(d.checks.length), className: 'small' }, el('span', { className: 'error', style: 'display:inline-block;margin:0', text: x.r.error })));
91
+ } else d.checks.forEach(function (c) {
92
+ var res = x.r ? x.r.results.filter(function (y) { return y.id === c.id; })[0] : null;
93
+ var st = res ? res.status : x.k.status[c.id];
94
+ var v = res ? res.value : x.k.values[c.id];
95
+ var cell = el('td', { className: 'pcell' });
96
+ if (st && st !== 'off') {
97
+ var b = el('button', { className: 'pval ' + ST_CLS[st], title: c.label + ': ' + (res ? res.summary : ST_WORD[st]), text: st === 'error' ? '!' : (v === null || v === undefined ? '—' : fmtNum(v)), onclick: function () { P.sel = { id: t.id, check: c.id }; renderPartner(); } });
98
+ if (res && x.r.worse.indexOf(c.id) >= 0) b.appendChild(el('span', { className: 'pnew', text: 'new' }));
99
+ cell.appendChild(b);
100
+ } else cell.appendChild(el('span', { className: 'muted', text: st === 'off' ? 'off' : '' }));
101
+ tr.appendChild(cell);
102
+ });
103
+ tr.appendChild(el('td', { style: 'white-space:nowrap' },
104
+ el('button', { className: 'btn sm primary', title: 'Open this tenant with all pages', disabled: !t.hasSecret, onclick: function () { openTenant(t); } }, 'Open'),
105
+ el('button', { className: 'btn sm ghost', title: 'Edit', onclick: function () { P.form = { id: t.id, name: t.name, baseUrl: t.baseUrl, clientId: t.clientId, notes: t.notes || '' }; renderPartner(); } }, icon('sliders')),
106
+ el('button', { className: 'btn sm ghost', title: 'Check only this tenant', disabled: !!R.busy, onclick: function () { partnerRun({ ids: [t.id] }); } }, icon('play'))));
107
+ body.appendChild(tr);
108
+ if (P.sel && P.sel.id === t.id) {
109
+ var res = x.r ? x.r.results.filter(function (y) { return y.id === P.sel.check; })[0] : null;
110
+ var c = d.checks.filter(function (y) { return y.id === P.sel.check; })[0];
111
+ var inner = el('div', { className: 'pdetail' }, el('b', { text: t.name + ' · ' + (c ? c.label : '') }));
112
+ if (res) {
113
+ inner.appendChild(el('div', { text: res.summary }));
114
+ if (res.error) inner.appendChild(el('div', { className: 'error small', text: res.error }));
115
+ if (res.top && res.top.length) inner.appendChild(el('div', { className: 'muted small', text: res.top.slice(0, 5).map(function (y) { return y.label + ' (' + y.count + ')'; }).join(' · ') }));
116
+ if (FIX && FIX[res.id]) inner.appendChild(el('div', { className: 'small', style: 'margin-top:6px' }, el('b', { text: 'How to fix: ' }), FIX[res.id][0]));
117
+ } else inner.appendChild(el('div', { className: 'muted', text: 'From the last check kept on this computer. Check this tenant for details.' }));
118
+ var go = CHECK_GOTO[P.sel.check];
119
+ inner.appendChild(el('div', { className: 'bar', style: 'margin-top:8px' },
120
+ el('button', { className: 'btn sm primary', disabled: !t.hasSecret, title: go ? 'Opens ' + t.name + ' on ' + go[2] : 'Opens ' + t.name, onclick: function () { openTenant(t, null, P.sel.check); } }, icon('play'), go ? 'Open ' + go[2] : 'Open in this tenant'),
121
+ el('button', { className: 'btn sm ghost', onclick: function () { P.sel = null; renderPartner(); } }, 'Close')));
122
+ body.appendChild(el('tr', {}, el('td', { colSpan: String(d.checks.length + 3) }, inner)));
123
+ }
124
+ });
125
+ table.appendChild(body);
126
+ w.appendChild(el('div', { className: 'card', style: 'padding:0;overflow-x:auto' }, table));
127
+ w.appendChild(el('p', { className: 'muted small', text: 'Click a number for details and a link to the report or page behind it. "new" means new or worse since that tenant\'s previous check. Limits are the ones set on the Instant check page. Schedule "All tenants" on the Schedules page for one daily summary of every tenant.' }));
128
+ }
129
+ state.ptRun = {};
130
+ function partnerRun(body) {
131
+ runJobInto(state.ptRun, '/api/tenants/run', body, function () {
132
+ if (state.ptRun.data && state.pt.data) state.pt.data.lastRun = state.ptRun.data;
133
+ if (state.page === 'partner') renderPartner();
134
+ });
135
+ }
136
+ function worstOf(list) {
137
+ var rank = { error: 4, bad: 3, warn: 2, ok: 1, off: 0 };
138
+ var best = null;
139
+ list.forEach(function (s) { if (s && (best === null || rank[s] > rank[best])) best = s; });
140
+ return best;
141
+ }
142
+ function fmtWhen(iso) { try { return new Date(iso).toLocaleString(); } catch (e) { return iso; } }
143
+ // Where each check's details are: a report (run as soon as it opens) or a page and tab.
144
+ var CHECK_GOTO = {
145
+ 'provisioning-errors': ['report', 'provisioning-errors', 'the Provisioning errors report'],
146
+ 'aggregation-failures': ['report', 'aggregation-failures', 'the Aggregation failures report'],
147
+ 'stale-sources': ['report', 'aggregation-history', 'the Aggregations by source report'],
148
+ 'sources-in-error': ['report', 'sources-needing-attention', 'the Sources needing attention report'],
149
+ 'identity-errors': ['report', 'identities-with-processing-errors', 'the Identities with processing errors report'],
150
+ 'stuck-requests': ['report', 'stuck-access-requests', 'the Stuck access requests report'],
151
+ 'leavers-with-access': ['report', 'terminated-users-with-active-accounts', 'the Terminated users with active accounts report'],
152
+ 'uncorrelated-growth': ['report', 'uncorrelated-accounts', 'the Uncorrelated accounts report'],
153
+ 'campaigns-at-risk': ['report', 'campaign-progress', 'the Campaign progress report'],
154
+ 'va-clusters': ['tenant', 'clusters', 'Tenant > Virtual Appliances'],
155
+ 'api-credentials': ['tenant', 'credentials', 'Tenant > API credentials'],
156
+ 'workflow-failures': ['tenant', 'workflows', 'Tenant > Workflows'],
157
+ 'access-ending': ['warnings', 'ending', 'Warnings > Access ending'],
158
+ 'stuck-on-leavers': ['warnings', 'stuck', 'Warnings > Waiting on leavers'],
159
+ 'admins-left': ['warnings', 'admins', 'Warnings > ISC admins'],
160
+ 'past-end-date': ['warnings', 'people', 'Warnings > End dates'],
161
+ 'lifecycle-gaps': ['warnings', 'joiners', 'Warnings > Missed joiners'],
162
+ 'slow-removals': ['certs', 'speed', 'Audit > Provisioning speed'],
163
+ };
164
+ function goToCheck(id) {
165
+ var g = CHECK_GOTO[id];
166
+ if (!g) { showPage('checks'); return; }
167
+ if (g[0] === 'report') {
168
+ showPage('reports');
169
+ loadLibrary(g[1]).then(function () { if (state.current && state.current.def.id === g[1]) run(false); });
170
+ return;
171
+ }
172
+ if (g[0] === 'tenant') state.tn.tab = g[1];
173
+ if (g[0] === 'build') state.bt.tab = g[1];
174
+ if (g[0] === 'warnings') wnState().tab = g[1];
175
+ if (g[0] === 'certs') state.au.tab = g[1];
176
+ showPage(g[0]);
177
+ }
178
+ function openTenant(t, page, check) {
179
+ toast('Opening ' + t.name + '...');
180
+ api('/api/tenants/' + t.id + '/open', 'POST', {}).then(function (r) {
181
+ hidePartner();
182
+ state.signedIn = false;
183
+ showApp(r.tenant);
184
+ $('tenant').textContent = t.name + ' · ' + r.tenant;
185
+ $('tenant-chip').title = t.name + ' · ' + r.tenant;
186
+ $('btn-partner-nav').classList.remove('hidden');
187
+ if (check) goToCheck(check);
188
+ else if (page) showPage(page);
189
+ }).catch(function (e) { toast(errorText(e)); });
190
+ }
191
+ function partnerForm(P) {
192
+ var F = P.form;
193
+ var msg = el('div');
194
+ var inp = function (key, ph, type) { var i = el('input', { className: 'input', value: F[key] || '', placeholder: ph || '', type: type || 'text', autocomplete: 'off' }); i.addEventListener('input', function () { F[key] = i.value; }); return i; };
195
+ var save = el('button', { className: 'btn primary', onclick: function () {
196
+ msg.textContent = '';
197
+ save.disabled = true;
198
+ var body = { name: F.name, baseUrl: F.baseUrl, clientId: F.clientId, clientSecret: F.clientSecret || '', notes: F.notes };
199
+ (F.isNew ? api('/api/tenants', 'POST', body) : api('/api/tenants/' + F.id, 'PUT', body)).then(function (r) {
200
+ P.form = null; P.data = null;
201
+ toast((F.isNew ? 'Added ' : 'Saved ') + r.tenant.name + (r.note ? ' · ' + r.note : ''));
202
+ renderPartner();
203
+ }).catch(function (e) { save.disabled = false; msg.appendChild(el('div', { className: 'error', text: errorText(e) })); });
204
+ } }, icon('save'), F.isNew ? 'Test and add' : 'Save');
205
+ var remove = F.isNew ? null : el('button', { className: 'btn ghost', onclick: function () {
206
+ remove.replaceWith(el('span', { className: 'inline' }, el('span', { text: 'Remove ' + F.name + ' and its saved secret from this computer?' }),
207
+ el('button', { className: 'btn sm', onclick: function () { api('/api/tenants/' + F.id, 'DELETE').then(function () { P.form = null; P.data = null; P.sel = null; toast('Removed'); renderPartner(); }); } }, 'Yes, remove'),
208
+ el('button', { className: 'btn sm ghost', onclick: function () { renderPartner(); } }, 'No')));
209
+ } }, icon('trash'), 'Remove');
210
+ return el('section', { className: 'card', style: 'margin-bottom:14px' },
211
+ el('h3', { style: 'margin-top:0', text: F.isNew ? 'Add a tenant' : 'Edit ' + F.name }),
212
+ el('div', { className: 'grid', style: 'grid-template-columns:1fr 1fr' },
213
+ el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Customer name' }), inp('name', 'e.g. Acme Corp')),
214
+ el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Tenant' }), inp('baseUrl', 'acme, or paste the ISC address from your browser')),
215
+ el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Client ID' }), inp('clientId')),
216
+ el('label', { className: 'field' }, el('span', { className: 'lbl', text: F.isNew ? 'Client secret' : 'Client secret (leave empty to keep the saved one)' }), inp('clientSecret', '', 'password'))),
217
+ el('label', { className: 'field' }, el('span', { className: 'lbl', text: 'Notes (optional)' }), inp('notes', 'e.g. contract ends June, contact: J. Smith')),
218
+ el('p', { className: 'muted small', text: 'Use a personal access token or API client of a read-only identity in that tenant (for a customer\u2019s tenant, ask the customer for one). The secret is kept only in the owner-only secrets file on this computer and is never shown again. IdentityScope tests the connection before saving.' }),
219
+ el('div', { className: 'bar' }, save, el('button', { className: 'btn ghost', onclick: function () { P.form = null; renderPartner(); } }, 'Cancel'), el('span', { style: 'flex:1' }), remove),
220
+ msg);
221
+ }
222
+
223
+
224
+ function tokenNote(r) {
225
+ var d = r && r.token ? r.token.daysToExpiry : null;
226
+ if (d === null || d === undefined || d > 30) return null;
227
+ return el('div', { className: 'small', style: 'margin-top:2px;white-space:nowrap;font-weight:600;color:' + (d <= 14 ? 'var(--danger)' : 'var(--warn)'), title: 'The personal access token IdentityScope uses for this tenant', text: d < 0 ? 'Token expired' : d === 0 ? 'Token expires today' : 'Token: ' + d + ' day' + (d === 1 ? '' : 's') + ' left' });
228
+ }