@nxgt/janus-telemetry 0.1.1 → 0.2.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 +19 -11
- package/dist/flows.d.ts +5 -3
- package/dist/flows.d.ts.map +1 -1
- package/dist/index.js +40 -2
- package/dist/index.js.map +4 -4
- package/dist/traced.d.ts.map +1 -1
- package/docs/README.md +1 -1
- package/docs/guide/tracing.md +55 -5
- package/docs/roadmap.md +7 -0
- package/docs/troubleshooting.md +9 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
[`@nxgt/janus`](https://www.npmjs.com/package/@nxgt/janus) on
|
|
4
4
|
[`@nxgt/telemetry`](https://www.npmjs.com/package/@nxgt/telemetry): a span per
|
|
5
5
|
flow and per permission check, and the security events an audit reads — who
|
|
6
|
-
signed up, in and out, why a sign-in was refused,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
session
|
|
6
|
+
signed up, in and out, why a sign-in was refused, who was asked for a second
|
|
7
|
+
factor and who enrolled, activated or disabled one, which users were deleted
|
|
8
|
+
or deactivated, whose password changed, and who was granted what. **Never a
|
|
9
|
+
login, an e-mail, a password, a session token, a one-time token, a
|
|
10
|
+
challenge, a code, a TOTP secret or a session id.**
|
|
10
11
|
|
|
11
12
|
```ts
|
|
12
13
|
import { janus } from '@nxgt/janus';
|
|
@@ -31,7 +32,7 @@ bun add @nxgt/janus-telemetry @nxgt/janus @nxgt/telemetry
|
|
|
31
32
|
bun add -d typescript
|
|
32
33
|
```
|
|
33
34
|
|
|
34
|
-
Every peer is required: `@nxgt/janus` (0.
|
|
35
|
+
Every peer is required: `@nxgt/janus` (0.5, the release with the second factor), `@nxgt/telemetry` (0.2.1 or later) and
|
|
35
36
|
`typescript` (6). `@nxgt/janus` and `@nxgt/telemetry` are **peers**: one copy of `@nxgt/janus`, so
|
|
36
37
|
`instanceof JanusError` holds, and one of `@nxgt/telemetry`, so there is one
|
|
37
38
|
current span. Like `@nxgt/janus`, it expects `"moduleResolution": "bundler"`.
|
|
@@ -50,7 +51,7 @@ current span. Like `@nxgt/janus`, it expects `"moduleResolution": "bundler"`.
|
|
|
50
51
|
|
|
51
52
|
| Span | Attributes |
|
|
52
53
|
| --- | --- |
|
|
53
|
-
| `janus.<flow>`, `janus.<type>.<flow>` | `janus.user.type`; `user.id` once the answer names a user; `janus.session.renewed` for `authenticate` |
|
|
54
|
+
| `janus.<flow>`, `janus.<type>.<flow>` — `janus.secondFactor.confirm` included | `janus.user.type`; `user.id` once the answer names a user; `janus.session.renewed` for `authenticate`; `janus.signIn.status` for `signIn` — `signedIn`, or `secondFactor` when it answered a challenge |
|
|
54
55
|
| `janus.can` | `janus.subject.type`, `janus.subject.id`, `janus.permission`, `janus.object.type`, `janus.object.id`, and the answer, `janus.allowed` |
|
|
55
56
|
| `janus.list` | the subject, `janus.permission`, `janus.object.type`, and `janus.page.items`, how many it found |
|
|
56
57
|
| `janus.grant`, `janus.revoke` | the object, `janus.relation`, and the subject — `janus.subject.relation` for a subject set, read as `permissions()` reads it: a user with a field named `relation` is that user, and a set on a user type is one only when `setOf()` made it |
|
|
@@ -70,8 +71,10 @@ when the flow knows them — `janus.signOut` carries neither:
|
|
|
70
71
|
| Event | Severity | When |
|
|
71
72
|
| --- | --- | --- |
|
|
72
73
|
| `janus.signUp` | info | a user signed up |
|
|
73
|
-
| `janus.signIn` | info | a user signed in |
|
|
74
|
-
| `janus.signIn.
|
|
74
|
+
| `janus.signIn` | info | a user signed in — by `signIn`, or by `secondFactor.confirm`, which adds `janus.signIn.secondFactor: true` |
|
|
75
|
+
| `janus.signIn.secondFactor` | info | the password was right and a code was asked for: `signIn` answered a challenge. `janus.user.type` only — the answer names no user; the `janus.signIn` of the `confirm` that follows does |
|
|
76
|
+
| `janus.signIn.refused` | **warn** | a sign-in was refused, with `janus.refusal` — `CREDENTIALS_INVALID` with `janus.refusal.reason` (`unknownLogin`, `noPassword`, `wrongPassword`), `USER_INACTIVE` with the `user.id` of the deactivated user, or a refused `secondFactor.confirm`: `CODE_INVALID` with `user.id` and `janus.secondFactor.attemptsLeft`, a `TOKEN_*` code, `SECOND_FACTOR_NOT_ENROLLED`, or `VERSION_CONFLICT` for one code sent twice at once |
|
|
77
|
+
| `janus.secondFactor.enrolled`, `janus.secondFactor.activated`, `janus.secondFactor.disabled` | info | `enroll`, `activate` and `disable`, with the `user.id` they were called for |
|
|
75
78
|
| `janus.signOut` | info | a session was signed out |
|
|
76
79
|
| `janus.signOutEverywhere` | info | every session of a user was revoked |
|
|
77
80
|
| `janus.user.deleted` | info | a user was deleted |
|
|
@@ -93,15 +96,20 @@ when the flow knows them — `janus.signOut` carries neither:
|
|
|
93
96
|
- **A refused sign-in for bad credentials names no user.** `janus.signIn.refused`
|
|
94
97
|
with `CREDENTIALS_INVALID` carries the reason and the user type, never the
|
|
95
98
|
login that was tried: rate limiting per login is the application's, from the
|
|
96
|
-
request. Only
|
|
97
|
-
|
|
99
|
+
request. Only a refusal after the password was right carries `user.id`:
|
|
100
|
+
`USER_INACTIVE`, and a second factor's `CODE_INVALID` or
|
|
101
|
+
`SECOND_FACTOR_NOT_ENROLLED`.
|
|
102
|
+
- **A wrong second-factor code is a warning, not a failure.** `CODE_INVALID`
|
|
103
|
+
leaves the `janus.secondFactor.confirm` span `ok`, and writes
|
|
104
|
+
`janus.signIn.refused` with `janus.secondFactor.attemptsLeft`: alert on a
|
|
105
|
+
user whose count reaches `0` again and again, not on the span.
|
|
98
106
|
- **One copy of `@nxgt/janus`.** A refusal is told from a failure by
|
|
99
107
|
`instanceof JanusError`: with a second copy installed, every wrong password
|
|
100
108
|
fails its span.
|
|
101
109
|
|
|
102
110
|
## Documentation
|
|
103
111
|
|
|
104
|
-
- [Tracing Janus](docs/guide/tracing.md) — wiring it with a Hono app, reading the spans and events, the audit trail
|
|
112
|
+
- [Tracing Janus](docs/guide/tracing.md) — wiring it with a Hono app, reading the spans and events, the audit trail, a sign-in with a second factor
|
|
105
113
|
- [Troubleshooting](docs/troubleshooting.md) — what you see, why, and the fix
|
|
106
114
|
- [Roadmap](docs/roadmap.md) — what is next, and what is not planned
|
|
107
115
|
|
package/dist/flows.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ export interface JanusLike {
|
|
|
7
7
|
* The same `janus()` instance, with every flow traced — a span per call,
|
|
8
8
|
* named `janus.signIn` or `janus.patient.signIn` — and the events a security
|
|
9
9
|
* review reads written as logs: sign-ups, sign-ins and the reason one was
|
|
10
|
-
* refused,
|
|
10
|
+
* refused, a second factor asked for, enrolled, activated or disabled,
|
|
11
|
+
* sign-outs, deleted and deactivated users, changed passwords.
|
|
11
12
|
*
|
|
12
13
|
* ```ts
|
|
13
14
|
* const auth = instrumentJanus(janus({ users, store, hasher }));
|
|
@@ -17,8 +18,9 @@ export interface JanusLike {
|
|
|
17
18
|
* `janus.refusal` set, and is a `janus.signIn.refused` warning — never a
|
|
18
19
|
* failed span. A store that cannot answer is one, with `janus.store.slot`.
|
|
19
20
|
*
|
|
20
|
-
* Nothing written carries a login, an e-mail, a password, a token
|
|
21
|
-
* session id: user types, user ids,
|
|
21
|
+
* Nothing written carries a login, an e-mail, a password, a token, a
|
|
22
|
+
* challenge, a code, a TOTP secret or a session id: user types, user ids,
|
|
23
|
+
* codes and reasons only.
|
|
22
24
|
*/
|
|
23
25
|
export declare function instrumentJanus<A extends JanusLike>(auth: A): A;
|
|
24
26
|
//# sourceMappingURL=flows.d.ts.map
|
package/dist/flows.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../src/flows.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"flows.d.ts","sourceRoot":"","sources":["../src/flows.ts"],"names":[],"mappings":"AAiCA,kFAAkF;AAClF,MAAM,WAAW,SAAS;IACzB,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D;AAuJD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAQ/D"}
|
package/dist/index.js
CHANGED
|
@@ -22,6 +22,9 @@ function kindOf(code) {
|
|
|
22
22
|
case "TOKEN_SPENT":
|
|
23
23
|
case "TOKEN_EXPIRED":
|
|
24
24
|
case "TOKEN_STALE":
|
|
25
|
+
case "CODE_INVALID":
|
|
26
|
+
case "SECOND_FACTOR_NOT_ENROLLED":
|
|
27
|
+
case "SECOND_FACTOR_ACTIVE":
|
|
25
28
|
case "INVALID_CURSOR":
|
|
26
29
|
return "refusal";
|
|
27
30
|
}
|
|
@@ -90,6 +93,10 @@ var events = {
|
|
|
90
93
|
signedUp: event("janus.signUp"),
|
|
91
94
|
signedIn: event("janus.signIn"),
|
|
92
95
|
signInRefused: event("janus.signIn.refused"),
|
|
96
|
+
secondFactorAsked: event("janus.signIn.secondFactor"),
|
|
97
|
+
secondFactorEnrolled: event("janus.secondFactor.enrolled"),
|
|
98
|
+
secondFactorActivated: event("janus.secondFactor.activated"),
|
|
99
|
+
secondFactorDisabled: event("janus.secondFactor.disabled"),
|
|
93
100
|
signedOut: event("janus.signOut"),
|
|
94
101
|
signedOutEverywhere: event("janus.signOutEverywhere"),
|
|
95
102
|
userDeleted: event("janus.user.deleted"),
|
|
@@ -106,12 +113,36 @@ var WRITTEN = {
|
|
|
106
113
|
log.info(events.signedUp(userFields(call, outcome.value)));
|
|
107
114
|
},
|
|
108
115
|
signIn: (call, outcome) => {
|
|
109
|
-
if (outcome.ok) {
|
|
116
|
+
if (!outcome.ok) {
|
|
117
|
+
log.warn(events.signInRefused(refusalFields(call, outcome.refusal)));
|
|
118
|
+
} else if (statusOf(outcome.value) === "secondFactor") {
|
|
119
|
+
log.info(events.secondFactorAsked(fieldsOf({ "janus.user.type": call.userType })));
|
|
120
|
+
} else {
|
|
110
121
|
log.info(events.signedIn(userFields(call, outcome.value)));
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
"secondFactor.confirm": (call, outcome) => {
|
|
125
|
+
if (outcome.ok) {
|
|
126
|
+
log.info(events.signedIn({
|
|
127
|
+
...userFields(call, outcome.value),
|
|
128
|
+
"janus.signIn.secondFactor": true
|
|
129
|
+
}));
|
|
111
130
|
} else {
|
|
112
131
|
log.warn(events.signInRefused(refusalFields(call, outcome.refusal)));
|
|
113
132
|
}
|
|
114
133
|
},
|
|
134
|
+
"secondFactor.enroll": (call, outcome) => {
|
|
135
|
+
if (outcome.ok)
|
|
136
|
+
log.info(events.secondFactorEnrolled(argumentUser(call)));
|
|
137
|
+
},
|
|
138
|
+
"secondFactor.activate": (call, outcome) => {
|
|
139
|
+
if (outcome.ok)
|
|
140
|
+
log.info(events.secondFactorActivated(argumentUser(call)));
|
|
141
|
+
},
|
|
142
|
+
"secondFactor.disable": (call, outcome) => {
|
|
143
|
+
if (outcome.ok)
|
|
144
|
+
log.info(events.secondFactorDisabled(argumentUser(call)));
|
|
145
|
+
},
|
|
115
146
|
signOut: (_call, outcome) => {
|
|
116
147
|
if (outcome.ok && outcome.value === true)
|
|
117
148
|
log.info(events.signedOut());
|
|
@@ -166,9 +197,13 @@ function refusalFields(call, refusal) {
|
|
|
166
197
|
"janus.user.type": refusal.userType ?? call.userType,
|
|
167
198
|
"janus.refusal": refusal.code,
|
|
168
199
|
"janus.refusal.reason": refusal.reason,
|
|
200
|
+
"janus.secondFactor.attemptsLeft": refusal.attemptsLeft,
|
|
169
201
|
"user.id": refusal.userId
|
|
170
202
|
});
|
|
171
203
|
}
|
|
204
|
+
function statusOf(value) {
|
|
205
|
+
return typeof value === "object" && value !== null && "status" in value && typeof value.status === "string" ? value.status : undefined;
|
|
206
|
+
}
|
|
172
207
|
function answered(scope, call, outcome) {
|
|
173
208
|
if (outcome.ok) {
|
|
174
209
|
const fields = userFields(call, outcome.value);
|
|
@@ -178,6 +213,9 @@ function answered(scope, call, outcome) {
|
|
|
178
213
|
if (typeof value === "object" && value !== null && "renewed" in value) {
|
|
179
214
|
scope.attribute("janus.session.renewed", value.renewed === true);
|
|
180
215
|
}
|
|
216
|
+
const status = call.flow === "signIn" ? statusOf(value) : undefined;
|
|
217
|
+
if (status !== undefined)
|
|
218
|
+
scope.attribute("janus.signIn.status", status);
|
|
181
219
|
}
|
|
182
220
|
WRITTEN[call.flow]?.(call, outcome);
|
|
183
221
|
}
|
|
@@ -286,5 +324,5 @@ export {
|
|
|
286
324
|
instrumentPermissions
|
|
287
325
|
};
|
|
288
326
|
|
|
289
|
-
//# debugId=
|
|
327
|
+
//# debugId=1F91222C283742CE64756E2164756E21
|
|
290
328
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/flows.ts", "../src/traced.ts", "../src/permissions.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { JanusError } from '@nxgt/janus';\nimport { createLogger, event, type SpanScope } from '@nxgt/telemetry';\nimport {\n\ttype Fields,\n\tfieldsOf,\n\tidOf,\n\ttype Outcome,\n\ttraced,\n\ttypeOf,\n} from './traced';\n\nconst log = createLogger('@nxgt/janus');\n\n/** The events a security review reads: who signed in, out, up, and what changed. */\nconst events = {\n\tsignedUp: event('janus.signUp'),\n\tsignedIn: event('janus.signIn'),\n\tsignInRefused: event('janus.signIn.refused'),\n\tsignedOut: event('janus.signOut'),\n\tsignedOutEverywhere: event('janus.signOutEverywhere'),\n\tuserDeleted: event('janus.user.deleted'),\n\tuserActivated: event('janus.user.activated'),\n\tuserDeactivated: event('janus.user.deactivated'),\n\tpasswordChanged: event('janus.password.changed'),\n\tpasswordSet: event('janus.password.set'),\n\tpasswordReset: event('janus.password.reset'),\n\temailVerified: event('janus.email.verified'),\n};\n\n/** What `janus()` answers, as far as it is read: its user types and its flows. */\nexport interface JanusLike {\n\treadonly types: readonly string[];\n\treadonly authenticate: (...args: never[]) => Promise<unknown>;\n}\n\n/** One call of a flow, as the events read it. */\ninterface Call {\n\t/** `signIn`, `verifyEmail.confirm`: the flow without the user type. */\n\treadonly flow: string;\n\treadonly userType: string | undefined;\n\treadonly args: readonly unknown[];\n}\n\n/**\n * What each flow writes once it answered. Nothing here reads a login, an\n * e-mail, a password or a token: only user types, ids, codes and reasons.\n */\nconst WRITTEN: Readonly<\n\tRecord<string, (call: Call, outcome: Outcome) => void>\n> = {\n\tsignUp: (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.signedUp(userFields(call, outcome.value)));\n\t},\n\tsignIn: (call, outcome) => {\n\t\tif (outcome.ok) {\n\t\t\tlog.info(events.signedIn(userFields(call, outcome.value)));\n\t\t} else {\n\t\t\tlog.warn(events.signInRefused(refusalFields(call, outcome.refusal)));\n\t\t}\n\t},\n\tsignOut: (_call, outcome) => {\n\t\tif (outcome.ok && outcome.value === true) log.info(events.signedOut());\n\t},\n\tsignOutEverywhere: (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.signedOutEverywhere(argumentUser(call)));\n\t},\n\tdelete: (call, outcome) => {\n\t\tif (outcome.ok && outcome.value === true) {\n\t\t\tlog.info(events.userDeleted(argumentUser(call)));\n\t\t}\n\t},\n\tsetActive: (call, outcome) => {\n\t\tif (!outcome.ok) return;\n\t\tconst written =\n\t\t\tcall.args[1] === true ? events.userActivated : events.userDeactivated;\n\t\tlog.info(written(argumentUser(call)));\n\t},\n\tchangePassword: (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.passwordChanged(argumentUser(call)));\n\t},\n\tsetPassword: (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.passwordSet(argumentUser(call)));\n\t},\n\t'resetPassword.confirm': (call, outcome) => {\n\t\tif (outcome.ok)\n\t\t\tlog.info(events.passwordReset(userFields(call, outcome.value)));\n\t},\n\t'verifyEmail.confirm': (call, outcome) => {\n\t\tif (outcome.ok)\n\t\t\tlog.info(events.emailVerified(userFields(call, outcome.value)));\n\t},\n};\n\n/** The user an answer names — `{ user }` or the user itself — as fields. */\nfunction userFields(call: Call, value: unknown): Fields {\n\tconst user =\n\t\ttypeof value === 'object' && value !== null && 'user' in value\n\t\t\t? value.user\n\t\t\t: value;\n\treturn fieldsOf({\n\t\t'janus.user.type': typeOf(user) ?? call.userType,\n\t\t'user.id': idOf(user),\n\t});\n}\n\n/** The user a flow was called for: its first argument. */\nfunction argumentUser(call: Call): Fields {\n\treturn fieldsOf({\n\t\t'janus.user.type': call.userType,\n\t\t'user.id': idOf(call.args[0]),\n\t});\n}\n\n
|
|
6
|
-
"import { JanusError, type JanusErrorCode } from '@nxgt/janus';\nimport { type SpanScope, span } from '@nxgt/telemetry';\n\n/**\n * What each code is. A **failure** is the server's to fix, and fails its span;\n * a **refusal** — a wrong password, a taken login, a spent token — is an\n * answer, and leaves it `ok`. Exhaustive, so a new code does not compile until\n * it is classified.\n */\nfunction kindOf(code: JanusErrorCode): 'failure' | 'refusal' {\n\tswitch (code) {\n\t\tcase 'STORE_FAILED':\n\t\tcase 'UNSUPPORTED':\n\t\tcase 'PERMISSION_DEPTH':\n\t\tcase 'HASH_UNSUPPORTED':\n\t\t\treturn 'failure';\n\t\tcase 'NOT_FOUND':\n\t\tcase 'LOGIN_TAKEN':\n\t\tcase 'VERSION_CONFLICT':\n\t\tcase 'USER_INVALID':\n\t\tcase 'PASSWORD_TOO_SHORT':\n\t\tcase 'CREDENTIALS_INVALID':\n\t\tcase 'USER_INACTIVE':\n\t\tcase 'TOKEN_UNKNOWN':\n\t\tcase 'TOKEN_SPENT':\n\t\tcase 'TOKEN_EXPIRED':\n\t\tcase 'TOKEN_STALE':\n\t\tcase 'INVALID_CURSOR':\n\t\t\treturn 'refusal';\n\t}\n}\n\n/** A `JanusError` the caller caused; anything else, or a failure code, is not. */\nexport function isRefusal(error: unknown): error is JanusError {\n\treturn error instanceof JanusError && kindOf(error.code) === 'refusal';\n}\n\n/** What a span or an event carries: scalars only, and never an absent one. */\nexport type Fields = Readonly<Record<string, string | number | boolean>>;\n\n/** `fields` without its `undefined` values. */\nexport function fieldsOf(\n\tfields: Readonly<Record<string, string | number | boolean | undefined>>,\n): Fields {\n\tconst kept: Record<string, string | number | boolean> = {};\n\tfor (const [key, value] of Object.entries(fields)) {\n\t\tif (value !== undefined) kept[key] = value;\n\t}\n\treturn kept;\n}\n\n/** The `id` of a user reference, a subject or an object — or nothing. */\nexport function idOf(value: unknown): string | undefined {\n\tif (typeof value === 'string') return value;\n\tif (typeof value === 'object' && value !== null && 'id' in value) {\n\t\tconst id: unknown = value.id;\n\t\tif (typeof id === 'string') return id;\n\t}\n\treturn undefined;\n}\n\n/** The `type` of a subject or an object — or nothing. */\nexport function typeOf(value: unknown): string | undefined {\n\tif (typeof value === 'object' && value !== null && 'type' in value) {\n\t\tconst type: unknown = value.type;\n\t\tif (typeof type === 'string') return type;\n\t}\n\treturn undefined;\n}\n\n/** How a traced call ended, for what is written after it. */\nexport type Outcome =\n\t| { readonly ok: true; readonly value: unknown }\n\t| { readonly ok: false; readonly refusal: JanusError };\n\n/**\n * Runs `call` in a span. **A refusal is an answer**: the span ends `ok`, with\n * `janus.refusal` set to its code, and the error is rethrown once the span is\n * over. A failure is rethrown inside it, so the span is `error`, with the\n * store slot and operation a `StoreFailure` names.\n *\n * `after` sees the outcome inside the span, outside the flow's `try`, and a\n * throw from it is dropped: telemetry never changes what a flow answers.\n */\nexport async function traced<T>(\n\tname: string,\n\tfields: Fields,\n\tcall: () => Promise<T>,\n\tafter: (scope: SpanScope, outcome: Outcome) => void,\n): Promise<T> {\n\tconst ended = await span(name, { attributes: fields }, async (scope) => {\n\t\tlet outcome: { ok: true; value: T } | { ok: false; refusal: JanusError };\n\t\ttry {\n\t\t\toutcome = { ok: true, value: await call() };\n\t\t} catch (error) {\n\t\t\tif (error instanceof JanusError) {\n\t\t\t\tscope.attribute('janus.error.code', error.code);\n\t\t\t\tif (error.slot !== undefined)\n\t\t\t\t\tscope.attribute('janus.store.slot', error.slot);\n\t\t\t\tif (error.operation !== undefined) {\n\t\t\t\t\tscope.attribute('janus.store.operation', error.operation);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!isRefusal(error)) throw error;\n\t\t\tscope.attribute('janus.refusal', error.code);\n\t\t\toutcome = { ok: false, refusal: error };\n\t\t}\n\t\ttry {\n\t\t\tafter(scope, outcome);\n\t\t} catch {\n\t\t\t// A signal is never worth a flow's answer.\n\t\t}\n\t\treturn outcome;\n\t});\n\tif (!ended.ok) throw ended.refusal;\n\treturn ended.value;\n}\n",
|
|
5
|
+
"import type { JanusError } from '@nxgt/janus';\nimport { createLogger, event, type SpanScope } from '@nxgt/telemetry';\nimport {\n\ttype Fields,\n\tfieldsOf,\n\tidOf,\n\ttype Outcome,\n\ttraced,\n\ttypeOf,\n} from './traced';\n\nconst log = createLogger('@nxgt/janus');\n\n/** The events a security review reads: who signed in, out, up, and what changed. */\nconst events = {\n\tsignedUp: event('janus.signUp'),\n\tsignedIn: event('janus.signIn'),\n\tsignInRefused: event('janus.signIn.refused'),\n\tsecondFactorAsked: event('janus.signIn.secondFactor'),\n\tsecondFactorEnrolled: event('janus.secondFactor.enrolled'),\n\tsecondFactorActivated: event('janus.secondFactor.activated'),\n\tsecondFactorDisabled: event('janus.secondFactor.disabled'),\n\tsignedOut: event('janus.signOut'),\n\tsignedOutEverywhere: event('janus.signOutEverywhere'),\n\tuserDeleted: event('janus.user.deleted'),\n\tuserActivated: event('janus.user.activated'),\n\tuserDeactivated: event('janus.user.deactivated'),\n\tpasswordChanged: event('janus.password.changed'),\n\tpasswordSet: event('janus.password.set'),\n\tpasswordReset: event('janus.password.reset'),\n\temailVerified: event('janus.email.verified'),\n};\n\n/** What `janus()` answers, as far as it is read: its user types and its flows. */\nexport interface JanusLike {\n\treadonly types: readonly string[];\n\treadonly authenticate: (...args: never[]) => Promise<unknown>;\n}\n\n/** One call of a flow, as the events read it. */\ninterface Call {\n\t/** `signIn`, `verifyEmail.confirm`: the flow without the user type. */\n\treadonly flow: string;\n\treadonly userType: string | undefined;\n\treadonly args: readonly unknown[];\n}\n\n/**\n * What each flow writes once it answered. Nothing here reads a login, an\n * e-mail, a password or a token: only user types, ids, codes and reasons.\n */\nconst WRITTEN: Readonly<\n\tRecord<string, (call: Call, outcome: Outcome) => void>\n> = {\n\tsignUp: (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.signedUp(userFields(call, outcome.value)));\n\t},\n\tsignIn: (call, outcome) => {\n\t\tif (!outcome.ok) {\n\t\t\tlog.warn(events.signInRefused(refusalFields(call, outcome.refusal)));\n\t\t} else if (statusOf(outcome.value) === 'secondFactor') {\n\t\t\t// The password was right; the session waits for a code.\n\t\t\tlog.info(\n\t\t\t\tevents.secondFactorAsked(\n\t\t\t\t\tfieldsOf({ 'janus.user.type': call.userType }),\n\t\t\t\t),\n\t\t\t);\n\t\t} else {\n\t\t\tlog.info(events.signedIn(userFields(call, outcome.value)));\n\t\t}\n\t},\n\t'secondFactor.confirm': (call, outcome) => {\n\t\tif (outcome.ok) {\n\t\t\tlog.info(\n\t\t\t\tevents.signedIn({\n\t\t\t\t\t...userFields(call, outcome.value),\n\t\t\t\t\t'janus.signIn.secondFactor': true,\n\t\t\t\t}),\n\t\t\t);\n\t\t} else {\n\t\t\tlog.warn(events.signInRefused(refusalFields(call, outcome.refusal)));\n\t\t}\n\t},\n\t'secondFactor.enroll': (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.secondFactorEnrolled(argumentUser(call)));\n\t},\n\t'secondFactor.activate': (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.secondFactorActivated(argumentUser(call)));\n\t},\n\t'secondFactor.disable': (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.secondFactorDisabled(argumentUser(call)));\n\t},\n\tsignOut: (_call, outcome) => {\n\t\tif (outcome.ok && outcome.value === true) log.info(events.signedOut());\n\t},\n\tsignOutEverywhere: (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.signedOutEverywhere(argumentUser(call)));\n\t},\n\tdelete: (call, outcome) => {\n\t\tif (outcome.ok && outcome.value === true) {\n\t\t\tlog.info(events.userDeleted(argumentUser(call)));\n\t\t}\n\t},\n\tsetActive: (call, outcome) => {\n\t\tif (!outcome.ok) return;\n\t\tconst written =\n\t\t\tcall.args[1] === true ? events.userActivated : events.userDeactivated;\n\t\tlog.info(written(argumentUser(call)));\n\t},\n\tchangePassword: (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.passwordChanged(argumentUser(call)));\n\t},\n\tsetPassword: (call, outcome) => {\n\t\tif (outcome.ok) log.info(events.passwordSet(argumentUser(call)));\n\t},\n\t'resetPassword.confirm': (call, outcome) => {\n\t\tif (outcome.ok)\n\t\t\tlog.info(events.passwordReset(userFields(call, outcome.value)));\n\t},\n\t'verifyEmail.confirm': (call, outcome) => {\n\t\tif (outcome.ok)\n\t\t\tlog.info(events.emailVerified(userFields(call, outcome.value)));\n\t},\n};\n\n/** The user an answer names — `{ user }` or the user itself — as fields. */\nfunction userFields(call: Call, value: unknown): Fields {\n\tconst user =\n\t\ttypeof value === 'object' && value !== null && 'user' in value\n\t\t\t? value.user\n\t\t\t: value;\n\treturn fieldsOf({\n\t\t'janus.user.type': typeOf(user) ?? call.userType,\n\t\t'user.id': idOf(user),\n\t});\n}\n\n/** The user a flow was called for: its first argument. */\nfunction argumentUser(call: Call): Fields {\n\treturn fieldsOf({\n\t\t'janus.user.type': call.userType,\n\t\t'user.id': idOf(call.args[0]),\n\t});\n}\n\n/**\n * Why a sign-in was refused: the code, the reason, the user when one holds\n * the login, and what a challenge has left of its attempts.\n */\nfunction refusalFields(call: Call, refusal: JanusError): Fields {\n\treturn fieldsOf({\n\t\t'janus.user.type': refusal.userType ?? call.userType,\n\t\t'janus.refusal': refusal.code,\n\t\t'janus.refusal.reason': refusal.reason,\n\t\t'janus.secondFactor.attemptsLeft': refusal.attemptsLeft,\n\t\t'user.id': refusal.userId,\n\t});\n}\n\n/** `signIn`'s `status`, when the answer has one. */\nfunction statusOf(value: unknown): string | undefined {\n\treturn typeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'status' in value &&\n\t\ttypeof value.status === 'string'\n\t\t? value.status\n\t\t: undefined;\n}\n\n/** What a span learns from an answer: whose it is, never what it holds. */\nfunction answered(scope: SpanScope, call: Call, outcome: Outcome): void {\n\tif (outcome.ok) {\n\t\tconst fields = userFields(call, outcome.value);\n\t\tfor (const [key, value] of Object.entries(fields))\n\t\t\tscope.attribute(key, value);\n\t\tconst value = outcome.value;\n\t\tif (typeof value === 'object' && value !== null && 'renewed' in value) {\n\t\t\tscope.attribute('janus.session.renewed', value.renewed === true);\n\t\t}\n\t\tconst status = call.flow === 'signIn' ? statusOf(value) : undefined;\n\t\tif (status !== undefined) scope.attribute('janus.signIn.status', status);\n\t}\n\tWRITTEN[call.flow]?.(call, outcome);\n}\n\n/** `cookie` answers synchronously: it is the one part of `janus()` not traced. */\nconst UNTRACED = new Set(['cookie']);\n\n/**\n * The same `janus()` instance, with every flow traced — a span per call,\n * named `janus.signIn` or `janus.patient.signIn` — and the events a security\n * review reads written as logs: sign-ups, sign-ins and the reason one was\n * refused, a second factor asked for, enrolled, activated or disabled,\n * sign-outs, deleted and deactivated users, changed passwords.\n *\n * ```ts\n * const auth = instrumentJanus(janus({ users, store, hasher }));\n * ```\n *\n * **A refusal is an answer**: a wrong password leaves its span `ok`, with\n * `janus.refusal` set, and is a `janus.signIn.refused` warning — never a\n * failed span. A store that cannot answer is one, with `janus.store.slot`.\n *\n * Nothing written carries a login, an e-mail, a password, a token, a\n * challenge, a code, a TOTP secret or a session id: user types, user ids,\n * codes and reasons only.\n */\nexport function instrumentJanus<A extends JanusLike>(auth: A): A {\n\tconst types = auth.types.filter((type) => typeof type === 'string');\n\tconst only = types.length === 1 ? types[0] : undefined;\n\treturn traceObject(auth, [], (path) =>\n\t\tpath[0] !== undefined && types.includes(path[0])\n\t\t\t? { userType: path[0], flow: path.slice(1) }\n\t\t\t: { userType: only, flow: path },\n\t);\n}\n\ntype Split = (path: readonly string[]) => {\n\treadonly userType: string | undefined;\n\treadonly flow: readonly string[];\n};\n\n/**\n * A traced copy of `target`, frozen: its functions traced, its plain objects —\n * a user type's flows, `verifyEmail` — copied the same way. A copy rather\n * than a Proxy, which may not answer differently for a frozen property.\n */\nfunction traceObject<O extends object>(\n\ttarget: O,\n\tpath: readonly string[],\n\tsplit: Split,\n): O {\n\tconst copy: Record<string, unknown> = {};\n\tfor (const [key, value] of Object.entries(target)) {\n\t\tif (UNTRACED.has(key)) {\n\t\t\tcopy[key] = value;\n\t\t} else if (typeof value === 'function') {\n\t\t\tcopy[key] = traceFunction(\n\t\t\t\tvalue as (...args: unknown[]) => unknown,\n\t\t\t\ttarget,\n\t\t\t\t[...path, key],\n\t\t\t\tsplit,\n\t\t\t);\n\t\t} else if (\n\t\t\ttypeof value === 'object' &&\n\t\t\tvalue !== null &&\n\t\t\t!Array.isArray(value)\n\t\t) {\n\t\t\tcopy[key] = traceObject(value, [...path, key], split);\n\t\t} else {\n\t\t\tcopy[key] = value;\n\t\t}\n\t}\n\treturn Object.freeze(copy) as O;\n}\n\nfunction traceFunction(\n\tfn: (...args: unknown[]) => unknown,\n\tself: object,\n\tpath: readonly string[],\n\tsplit: Split,\n): (...args: unknown[]) => Promise<unknown> {\n\tconst { userType, flow } = split(path);\n\tconst name = `janus.${path.join('.')}`;\n\tconst fields = fieldsOf({ 'janus.user.type': userType });\n\treturn (...args) => {\n\t\tconst call: Call = { flow: flow.join('.'), userType, args };\n\t\treturn traced(\n\t\t\tname,\n\t\t\tfields,\n\t\t\t() => Promise.resolve(fn.apply(self, args)),\n\t\t\t(scope, outcome) => answered(scope, call, outcome),\n\t\t);\n\t};\n}\n",
|
|
6
|
+
"import { JanusError, type JanusErrorCode } from '@nxgt/janus';\nimport { type SpanScope, span } from '@nxgt/telemetry';\n\n/**\n * What each code is. A **failure** is the server's to fix, and fails its span;\n * a **refusal** — a wrong password, a taken login, a spent token — is an\n * answer, and leaves it `ok`. Exhaustive, so a new code does not compile until\n * it is classified.\n */\nfunction kindOf(code: JanusErrorCode): 'failure' | 'refusal' {\n\tswitch (code) {\n\t\tcase 'STORE_FAILED':\n\t\tcase 'UNSUPPORTED':\n\t\tcase 'PERMISSION_DEPTH':\n\t\tcase 'HASH_UNSUPPORTED':\n\t\t\treturn 'failure';\n\t\tcase 'NOT_FOUND':\n\t\tcase 'LOGIN_TAKEN':\n\t\tcase 'VERSION_CONFLICT':\n\t\tcase 'USER_INVALID':\n\t\tcase 'PASSWORD_TOO_SHORT':\n\t\tcase 'CREDENTIALS_INVALID':\n\t\tcase 'USER_INACTIVE':\n\t\tcase 'TOKEN_UNKNOWN':\n\t\tcase 'TOKEN_SPENT':\n\t\tcase 'TOKEN_EXPIRED':\n\t\tcase 'TOKEN_STALE':\n\t\tcase 'CODE_INVALID':\n\t\tcase 'SECOND_FACTOR_NOT_ENROLLED':\n\t\tcase 'SECOND_FACTOR_ACTIVE':\n\t\tcase 'INVALID_CURSOR':\n\t\t\treturn 'refusal';\n\t}\n}\n\n/** A `JanusError` the caller caused; anything else, or a failure code, is not. */\nexport function isRefusal(error: unknown): error is JanusError {\n\treturn error instanceof JanusError && kindOf(error.code) === 'refusal';\n}\n\n/** What a span or an event carries: scalars only, and never an absent one. */\nexport type Fields = Readonly<Record<string, string | number | boolean>>;\n\n/** `fields` without its `undefined` values. */\nexport function fieldsOf(\n\tfields: Readonly<Record<string, string | number | boolean | undefined>>,\n): Fields {\n\tconst kept: Record<string, string | number | boolean> = {};\n\tfor (const [key, value] of Object.entries(fields)) {\n\t\tif (value !== undefined) kept[key] = value;\n\t}\n\treturn kept;\n}\n\n/** The `id` of a user reference, a subject or an object — or nothing. */\nexport function idOf(value: unknown): string | undefined {\n\tif (typeof value === 'string') return value;\n\tif (typeof value === 'object' && value !== null && 'id' in value) {\n\t\tconst id: unknown = value.id;\n\t\tif (typeof id === 'string') return id;\n\t}\n\treturn undefined;\n}\n\n/** The `type` of a subject or an object — or nothing. */\nexport function typeOf(value: unknown): string | undefined {\n\tif (typeof value === 'object' && value !== null && 'type' in value) {\n\t\tconst type: unknown = value.type;\n\t\tif (typeof type === 'string') return type;\n\t}\n\treturn undefined;\n}\n\n/** How a traced call ended, for what is written after it. */\nexport type Outcome =\n\t| { readonly ok: true; readonly value: unknown }\n\t| { readonly ok: false; readonly refusal: JanusError };\n\n/**\n * Runs `call` in a span. **A refusal is an answer**: the span ends `ok`, with\n * `janus.refusal` set to its code, and the error is rethrown once the span is\n * over. A failure is rethrown inside it, so the span is `error`, with the\n * store slot and operation a `StoreFailure` names.\n *\n * `after` sees the outcome inside the span, outside the flow's `try`, and a\n * throw from it is dropped: telemetry never changes what a flow answers.\n */\nexport async function traced<T>(\n\tname: string,\n\tfields: Fields,\n\tcall: () => Promise<T>,\n\tafter: (scope: SpanScope, outcome: Outcome) => void,\n): Promise<T> {\n\tconst ended = await span(name, { attributes: fields }, async (scope) => {\n\t\tlet outcome: { ok: true; value: T } | { ok: false; refusal: JanusError };\n\t\ttry {\n\t\t\toutcome = { ok: true, value: await call() };\n\t\t} catch (error) {\n\t\t\tif (error instanceof JanusError) {\n\t\t\t\tscope.attribute('janus.error.code', error.code);\n\t\t\t\tif (error.slot !== undefined)\n\t\t\t\t\tscope.attribute('janus.store.slot', error.slot);\n\t\t\t\tif (error.operation !== undefined) {\n\t\t\t\t\tscope.attribute('janus.store.operation', error.operation);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!isRefusal(error)) throw error;\n\t\t\tscope.attribute('janus.refusal', error.code);\n\t\t\toutcome = { ok: false, refusal: error };\n\t\t}\n\t\ttry {\n\t\t\tafter(scope, outcome);\n\t\t} catch {\n\t\t\t// A signal is never worth a flow's answer.\n\t\t}\n\t\treturn outcome;\n\t});\n\tif (!ended.ok) throw ended.refusal;\n\treturn ended.value;\n}\n",
|
|
7
7
|
"import { isSetOf } from '@nxgt/janus';\nimport { createLogger, event, type TelemetryEvent } from '@nxgt/telemetry';\nimport { type Fields, fieldsOf, idOf, traced, typeOf } from './traced';\n\nconst log = createLogger('@nxgt/janus');\n\n/** The audit trail of who was given what: one event per tuple written. */\nconst granted = event('janus.tuple.granted');\nconst revoked = event('janus.tuple.revoked');\n\n/**\n * A subject — a user, an object, or a subject set — as fields, read as\n * `permissions()` reads it: a value of a user type is that user, even with a\n * field named `relation`, unless `setOf()` made it.\n */\nfunction subjectFields(\n\tsubject: unknown,\n\tuserTypes: ReadonlySet<string>,\n): Fields {\n\tconst type = typeOf(subject);\n\tconst relation =\n\t\ttypeof subject === 'object' && subject !== null && 'relation' in subject\n\t\t\t? subject.relation\n\t\t\t: undefined;\n\tconst isSet =\n\t\ttypeof relation === 'string' &&\n\t\t(isSetOf(subject) || type === undefined || !userTypes.has(type));\n\treturn fieldsOf({\n\t\t'janus.subject.type': type,\n\t\t'janus.subject.id': idOf(subject),\n\t\t'janus.subject.relation': isSet ? relation : undefined,\n\t});\n}\n\nfunction objectFields(object: unknown): Fields {\n\treturn fieldsOf({\n\t\t'janus.object.type': typeOf(object),\n\t\t'janus.object.id': idOf(object),\n\t});\n}\n\n/** What `permissions()` answers, as far as it is traced. */\nexport interface PermissionsLike {\n\t/** Its user types tell a user from a subject set of the same shape. */\n\treadonly model?: { readonly subjects: readonly string[] };\n\treadonly can: (...args: never[]) => Promise<boolean>;\n\treadonly list: (...args: never[]) => Promise<unknown>;\n\treadonly grant: (...args: never[]) => Promise<unknown>;\n\treadonly revoke: (...args: never[]) => Promise<unknown>;\n}\n\ntype Traced = (...args: unknown[]) => Promise<unknown>;\n\n/** How each method of `permissions()` is traced. */\nconst tracersFor = (\n\tuserTypes: ReadonlySet<string>,\n): Readonly<Record<string, (fn: Traced) => Traced>> => ({\n\tcan:\n\t\t(fn) =>\n\t\t(...args) =>\n\t\t\ttraced(\n\t\t\t\t'janus.can',\n\t\t\t\tfieldsOf({\n\t\t\t\t\t...subjectFields(args[0], userTypes),\n\t\t\t\t\t'janus.permission': typeof args[1] === 'string' ? args[1] : undefined,\n\t\t\t\t\t...objectFields(args[2]),\n\t\t\t\t}),\n\t\t\t\t() => fn(...args),\n\t\t\t\t(scope, outcome) => {\n\t\t\t\t\tif (outcome.ok)\n\t\t\t\t\t\tscope.attribute('janus.allowed', outcome.value === true);\n\t\t\t\t},\n\t\t\t),\n\tlist:\n\t\t(fn) =>\n\t\t(...args) =>\n\t\t\ttraced(\n\t\t\t\t'janus.list',\n\t\t\t\tfieldsOf({\n\t\t\t\t\t...subjectFields(args[0], userTypes),\n\t\t\t\t\t'janus.permission': typeof args[1] === 'string' ? args[1] : undefined,\n\t\t\t\t\t'janus.object.type':\n\t\t\t\t\t\ttypeof args[2] === 'string' ? args[2] : undefined,\n\t\t\t\t}),\n\t\t\t\t() => fn(...args),\n\t\t\t\t(scope, outcome) => {\n\t\t\t\t\tconst page = outcome.ok ? outcome.value : undefined;\n\t\t\t\t\tif (typeof page === 'object' && page !== null && 'items' in page) {\n\t\t\t\t\t\tconst items = page.items;\n\t\t\t\t\t\tif (Array.isArray(items))\n\t\t\t\t\t\t\tscope.attribute('janus.page.items', items.length);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t),\n\tgrant: (fn) => tupleWrite('janus.grant', granted, fn, userTypes),\n\trevoke: (fn) => tupleWrite('janus.revoke', revoked, fn, userTypes),\n});\n\nfunction tupleWrite(\n\tname: string,\n\twritten: (fields: Fields) => TelemetryEvent,\n\tfn: Traced,\n\tuserTypes: ReadonlySet<string>,\n): Traced {\n\treturn (...args) => {\n\t\tconst fields = fieldsOf({\n\t\t\t...objectFields(args[0]),\n\t\t\t'janus.relation': typeof args[1] === 'string' ? args[1] : undefined,\n\t\t\t...subjectFields(args[2], userTypes),\n\t\t});\n\t\treturn traced(\n\t\t\tname,\n\t\t\tfields,\n\t\t\t() => fn(...args),\n\t\t\t(_scope, outcome) => {\n\t\t\t\tif (outcome.ok) log.info(written(fields));\n\t\t\t},\n\t\t);\n\t};\n}\n\n/**\n * The same `permissions()` instance, traced: a span per `can` — its subject,\n * permission, object and whether it was allowed — and per `list`, and a\n * `janus.tuple.granted` or `janus.tuple.revoked` event for every tuple\n * written, the audit trail of who was given what.\n *\n * ```ts\n * const access = instrumentPermissions(permissions({ model, store }));\n * ```\n *\n * A denial is an answer, not a failure: `janus.allowed` is `false` and the\n * span is `ok`. A relation store that cannot answer fails the span.\n */\nexport function instrumentPermissions<A extends PermissionsLike>(access: A): A {\n\t// `permissions()` answers a frozen object, which a Proxy may not answer\n\t// differently for: the traced methods go on a copy, frozen in turn.\n\tconst copy: Record<string, unknown> = Object.fromEntries(\n\t\tObject.entries(access),\n\t);\n\tconst userTypes = new Set(access.model?.subjects ?? []);\n\tfor (const [key, tracer] of Object.entries(tracersFor(userTypes))) {\n\t\tconst method: unknown = copy[key];\n\t\tif (typeof method !== 'function') continue;\n\t\tcopy[key] = tracer((...args) =>\n\t\t\tPromise.resolve(method.apply(access, args)),\n\t\t);\n\t}\n\treturn Object.freeze(copy) as A;\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";AACA;;;ACDA;AACA;AAQA,SAAS,MAAM,CAAC,MAA6C;AAAA,EAC5D,QAAQ;AAAA,SACF;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,MACJ,OAAO;AAAA,SACH;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,SACA;AAAA,MACJ,OAAO;AAAA;AAAA;AAKH,SAAS,SAAS,CAAC,OAAqC;AAAA,EAC9D,OAAO,iBAAiB,cAAc,OAAO,MAAM,IAAI,MAAM;AAAA;AAOvD,SAAS,QAAQ,CACvB,QACS;AAAA,EACT,MAAM,OAAkD,CAAC;AAAA,EACzD,YAAY,KAAK,UAAU,OAAO,QAAQ,MAAM,GAAG;AAAA,IAClD,I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A,MACpB,IAAI,QAAQ;AAAA,QAAI,KAAI,KAAK,QAAQ,MAAM,CAAC;AAAA,KAE1C;AAAA;AAAA;AAiBK,SAAS,qBAAgD,CAAC,QAAc;AAAA,EAG9E,MAAM,OAAgC,OAAO,YAC5C,OAAO,QAAQ,MAAM,CACtB;AAAA,EACA,MAAM,YAAY,IAAI,IAAI,OAAO,OAAO,YAAY,CAAC,CAAC;AAAA,EACtD,YAAY,KAAK,WAAW,OAAO,QAAQ,WAAW,SAAS,CAAC,GAAG;AAAA,IAClE,MAAM,SAAkB,KAAK;AAAA,IAC7B,IAAI,OAAO,WAAW;AAAA,MAAY;AAAA,IAClC,KAAK,OAAO,OAAO,IAAI,SACtB,QAAQ,QAAQ,OAAO,MAAM,QAAQ,IAAI,CAAC,CAC3C;AAAA,EACD;AAAA,EACA,OAAO,OAAO,OAAO,IAAI;AAAA;",
|
|
10
|
+
"debugId": "1F91222C283742CE64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/traced.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traced.d.ts","sourceRoot":"","sources":["../src/traced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,KAAK,SAAS,EAAQ,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"traced.d.ts","sourceRoot":"","sources":["../src/traced.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuB,MAAM,aAAa,CAAC;AAC9D,OAAO,EAAE,KAAK,SAAS,EAAQ,MAAM,iBAAiB,CAAC;AAkCvD,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAE7D;AAED,8EAA8E;AAC9E,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;AAEzE,+CAA+C;AAC/C,wBAAgB,QAAQ,CACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC,GACrE,MAAM,CAMR;AAED,yEAAyE;AACzE,wBAAgB,IAAI,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAOvD;AAED,yDAAyD;AACzD,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAMzD;AAED,6DAA6D;AAC7D,MAAM,MAAM,OAAO,GAChB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC;AAExD;;;;;;;;GAQG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAC7B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,GACjD,OAAO,CAAC,CAAC,CAAC,CA2BZ"}
|
package/docs/README.md
CHANGED
|
@@ -5,7 +5,7 @@ detail.
|
|
|
5
5
|
|
|
6
6
|
| Page | Read it when |
|
|
7
7
|
| --- | --- |
|
|
8
|
-
| [Tracing Janus](guide/tracing.md) | You are wiring it into an application,
|
|
8
|
+
| [Tracing Janus](guide/tracing.md) | You are wiring it into an application, reading what it wrote, or following a sign-in with a second factor |
|
|
9
9
|
| [Troubleshooting](troubleshooting.md) | A span or an event is missing, or says something you did not expect |
|
|
10
10
|
| [Roadmap](roadmap.md) | You want to know what is coming, what shipped, and what is deliberately not planned |
|
|
11
11
|
|
package/docs/guide/tracing.md
CHANGED
|
@@ -85,14 +85,64 @@ given what:
|
|
|
85
85
|
janus.tuple.granted janus.object.type=record janus.object.id=r1 janus.relation=owners janus.subject.type=patient janus.subject.id=u1
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
## A second factor
|
|
89
|
+
|
|
90
|
+
With `janus({ secondFactor })`, a sign-in with a code is two calls, and so
|
|
91
|
+
two spans and two events. The `signIn` span says which answer it gave, in
|
|
92
|
+
`janus.signIn.status`:
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
POST /sign-in server
|
|
96
|
+
└─ janus.signIn janus.user.type=user janus.signIn.status=secondFactor
|
|
97
|
+
log janus.signIn.secondFactor janus.user.type=user
|
|
98
|
+
|
|
99
|
+
POST /sign-in/code server
|
|
100
|
+
└─ janus.secondFactor.confirm janus.user.type=user user.id=0199…
|
|
101
|
+
log janus.signIn user.id=0199… janus.signIn.secondFactor=true
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The first event carries the user type alone: a challenge names no user, and
|
|
105
|
+
the log would otherwise need the login to say whose it is. The `janus.signIn`
|
|
106
|
+
written by `confirm` names the user, and `janus.signIn.secondFactor: true`
|
|
107
|
+
tells it from a sign-in by password alone.
|
|
108
|
+
|
|
109
|
+
A wrong code is a refusal, so the span stays `ok`, and a warning names the
|
|
110
|
+
user and what the challenge has left:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
janus.signIn.refused janus.refusal=CODE_INVALID janus.secondFactor.attemptsLeft=3 user.id=0199…
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
At `0` the challenge is spent. A user whose count reaches `0` challenge after
|
|
117
|
+
challenge is someone who has their password and not their phone — the
|
|
118
|
+
signal worth an alert:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
// name = 'janus.signIn.refused' AND janus.refusal = 'CODE_INVALID'
|
|
122
|
+
// AND janus.secondFactor.attemptsLeft = 0, grouped by user.id
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
A lapsed, spent or unknown challenge is a `janus.signIn.refused` with its
|
|
126
|
+
`TOKEN_*` code and no `user.id`: it is refused before the user is read.
|
|
127
|
+
|
|
128
|
+
`enroll`, `activate` and `disable` each write one event once they answered,
|
|
129
|
+
with the `user.id` they were called for — `janus.secondFactor.enrolled`,
|
|
130
|
+
`janus.secondFactor.activated`, `janus.secondFactor.disabled`. A refused one
|
|
131
|
+
(`SECOND_FACTOR_ACTIVE`, a wrong first code) writes no event: its span
|
|
132
|
+
carries `janus.refusal`, like any refusal.
|
|
133
|
+
|
|
88
134
|
## What is never written
|
|
89
135
|
|
|
90
|
-
A login, an e-mail, a password, a session token, a one-time token, a
|
|
91
|
-
|
|
136
|
+
A login, an e-mail, a password, a session token, a one-time token, a
|
|
137
|
+
second factor's challenge, a code or its TOTP secret, the
|
|
138
|
+
`otpauth://` URI that holds it, a session id: nothing a log reader could
|
|
139
|
+
sign in with, or use to tell who holds an account. A refused sign-in by
|
|
92
140
|
an unknown login says `janus.refusal.reason: 'unknownLogin'`, not which login
|
|
93
|
-
was tried; only
|
|
94
|
-
|
|
95
|
-
|
|
141
|
+
was tried; only a refusal after the password was right — `USER_INACTIVE`, a second
|
|
142
|
+
factor's `CODE_INVALID` or `SECOND_FACTOR_NOT_ENROLLED` — names the user.
|
|
143
|
+
The spec that holds this runs every flow — `enroll`, `activate`, a refused
|
|
144
|
+
and an accepted `confirm` among them — and searches every signal for each of
|
|
145
|
+
them.
|
|
96
146
|
|
|
97
147
|
## In a test
|
|
98
148
|
|
package/docs/roadmap.md
CHANGED
|
@@ -30,6 +30,13 @@ Nothing yet.
|
|
|
30
30
|
|
|
31
31
|
## Shipped
|
|
32
32
|
|
|
33
|
+
Newest first; the [CHANGELOG](../CHANGELOG.md) holds every release.
|
|
34
|
+
|
|
35
|
+
- **The second factor in the audit trail, v0.2.0** — `janus.signIn` records
|
|
36
|
+
`janus.signIn.status`; the events `janus.signIn.secondFactor`,
|
|
37
|
+
`janus.secondFactor.enrolled`, `.activated` and `.disabled`; and a refused
|
|
38
|
+
code warns with `janus.secondFactor.attemptsLeft`. No secret, challenge or
|
|
39
|
+
code is ever written. Needs `@nxgt/janus` 0.5.0.
|
|
33
40
|
- **The audit trail reads subjects as `permissions()` does, v0.1.1** — a user
|
|
34
41
|
with a field named `relation` is recorded as that user, and a subject set on
|
|
35
42
|
a user type only when `setOf()` made it. Needs `@nxgt/janus` 0.3.0.
|
package/docs/troubleshooting.md
CHANGED
|
@@ -51,14 +51,20 @@ extensible.`
|
|
|
51
51
|
### A wrong password does not fail the span
|
|
52
52
|
|
|
53
53
|
**When:** a `janus.signIn` span is `ok` although the sign-in threw
|
|
54
|
-
`CREDENTIALS_INVALID
|
|
54
|
+
`CREDENTIALS_INVALID` — or a `janus.secondFactor.confirm` span is `ok` although the
|
|
55
|
+
code was refused with `CODE_INVALID`.
|
|
55
56
|
|
|
56
57
|
**Why:** a refusal is an answer — Janus worked. The span carries
|
|
57
|
-
`janus.refusal`, and the `janus.signIn.refused` warning says why
|
|
58
|
-
|
|
58
|
+
`janus.refusal`, and the `janus.signIn.refused` warning says why; for a
|
|
59
|
+
refused code, the warning also carries `janus.secondFactor.attemptsLeft`. Only
|
|
60
|
+
a failure, such as `STORE_FAILED`, fails a span.
|
|
59
61
|
|
|
60
62
|
**Fix:** nothing. Query `janus.refusal` or the warning to count refusals.
|
|
61
63
|
|
|
64
|
+
```text
|
|
65
|
+
janus.refusal = "CODE_INVALID" AND janus.secondFactor.attemptsLeft = 0 -- challenges burnt by wrong codes
|
|
66
|
+
```
|
|
67
|
+
|
|
62
68
|
### `janus.signIn.refused` has no `user.id`
|
|
63
69
|
|
|
64
70
|
**When:** a sign-in refused with `CREDENTIALS_INVALID` carries the reason and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nxgt/janus-telemetry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Observability for @nxgt/janus on @nxgt/telemetry: a span per flow and per permission check, and the security events worth an audit trail — never a login, an e-mail, a password, a session token, a one-time token or a session id",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
]
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@nxgt/janus": "^0.
|
|
52
|
+
"@nxgt/janus": "^0.5.0",
|
|
53
53
|
"@nxgt/telemetry": "0.2.1",
|
|
54
54
|
"@types/bun": "^1.4.2",
|
|
55
55
|
"zod": "^4.6.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@nxgt/janus": "^0.
|
|
58
|
+
"@nxgt/janus": "^0.5.0",
|
|
59
59
|
"@nxgt/telemetry": "^0.2.1",
|
|
60
60
|
"typescript": "^6.0.3"
|
|
61
61
|
}
|