@owlmeans/web-auth 0.1.18-rc.6 → 0.1.18-rc.60

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 CHANGED
@@ -6,7 +6,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
6
6
  your project's skill store (`.agents/skills/`):
7
7
 
8
8
  ```sh
9
- npx @owlmeans/agent-skills
9
+ npx @owlmeans/agent-skills@^0.1.18-rc.47
10
10
  ```
11
11
 
12
12
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/web-auth",
4
- "version": "0.1.18-rc.6",
5
- "generatedAt": "2026-08-18T14:48:00.517Z",
4
+ "version": "0.1.18-rc.60",
5
+ "generatedAt": "2026-10-03T20:05:07.592Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: web-auth
3
- description: How to use @owlmeans/web-auth — web client auth plugins that register into @owlmeans/client-auth/manager. Currently ships the development-only PK-based supervisor login form (appendSupervisorAuth). Auto-invoked when importing @owlmeans/web-auth.
3
+ description: How to use @owlmeans/web-auth — web-side authentication-plugin package that registers into the shared @owlmeans/client-auth/manager registry. It ships the development-only PK supervisor login form (appendSupervisorAuth, supervisorClientPlugin, SUPERVISOR_LOGIN_PATH). Auto-invoked when importing @owlmeans/web-auth or wiring the supervisor login into a web client.
4
4
  user-invocable: false
5
5
  ---
6
6
  <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
@@ -8,35 +8,64 @@ user-invocable: false
8
8
  # @owlmeans/web-auth
9
9
 
10
10
  **Layer:** Web
11
- **Install:** `"@owlmeans/web-auth": "^0.1.18-rc.6"` in `dependencies`
11
+ **Install:** `"@owlmeans/web-auth": "^0.1.18-rc.60"` in `dependencies`
12
12
 
13
- Web-side auth UI plugins that register into the shared `@owlmeans/client-auth/manager` plugin registry
14
- (mirrors `@owlmeans/web-oidc-rp`). Currently ships the **PK-based supervisor** login form.
13
+ Web-side auth UI plugins registering into the shared `@owlmeans/client-auth/manager` plugin registry
14
+ (mirroring `@owlmeans/web-oidc-rp`). It ships the **PK supervisor** login form.
15
15
 
16
16
  ## Key Exports
17
17
 
18
18
  | Export | Description |
19
19
  |--------|-------------|
20
- | `appendSupervisorAuth(context, opts?)` | Dev-only: register the supervisor login form plugin |
21
- | `SUPERVISOR_LOGIN_PATH` | `/authentication/login/pk-supervisor` (the typed-route path) |
22
- | `supervisorClientPlugin` | The client `AuthenticationPlugin` (self-contained form) |
20
+ | `appendSupervisorAuth(context, opts?)` | Register the supervisor login plugin and, unless told otherwise, offer it on the sign-in screen |
21
+ | `WebSupervisorAuthOptions` | `{ enabled?, offer? }` |
22
+ | `SUPERVISOR_LOGIN_PATH` | `/authentication/login/pk-supervisor` — the typed-route path |
23
+ | `supervisorClientPlugin` | The client `AuthenticationPlugin`: a self-contained form that signs the server challenge and hands the packed credential to the standard auth control |
23
24
 
24
25
  ## Subpath Exports
25
- - `./auth/plugins` — side-effect import that always-registers the supervisor plugin
26
- (`import '@owlmeans/web-auth/auth/plugins'`). Prefer the dev-gated `appendSupervisorAuth`.
26
+
27
+ - `./auth/plugins` — a side-effect import that always registers the supervisor plugin
28
+ (`import '@owlmeans/web-auth/auth/plugins'`). Prefer the gated `appendSupervisorAuth`.
27
29
 
28
30
  ## Usage
31
+
29
32
  ```ts
30
33
  import { appendSupervisorAuth } from '@owlmeans/web-auth'
31
- // in your web client makeContext():
32
- appendSupervisorAuth(context) // enabled in development only (cfg.debug)
34
+
35
+ // in the web client's makeContext():
36
+ appendSupervisorAuth(context)
33
37
  ```
34
- The form renders at `SUPERVISOR_LOGIN_PATH` via the standard `CAUTHEN_AUTHEN_TYPED` route — no extra
35
- route registration needed. Test ids: `supervisor-auth-form`, `supervisor-user-id`, `supervisor-pk`,
36
- `supervisor-submit`, `supervisor-error`.
37
38
 
38
- See the **supervisor-auth** skill for the full feature (server append, options, security, test helpers).
39
+ **It reads `cfg.debug.supervisor`, and deliberately NOT `cfg.debug.all`.** Whole families of
40
+ OwlMeans applications set `debug.all` for reasons that have nothing to do with authentication — a
41
+ Viable-generated target sets it for itself — so gating on it would put an operator login on every
42
+ one of them, in production, reachable by anyone who typed the URL. Pass `{ enabled: true }` to force
43
+ it on regardless of the debug flags.
44
+
45
+ Registering the plugin is not enough to make it OFFERED: `supervisorClientPlugin` carries
46
+ `restricted: true`, so the sign-in screen shows it only where the configuration names it. That is
47
+ what `appendSupervisorAuth` writes into `cfg.security.auth.login.overrides` (and
48
+ `login.secretKey`) when it enables the plugin — pass `{ offer: false }` to register it without
49
+ advertising it.
50
+
51
+ The form renders at `SUPERVISOR_LOGIN_PATH` through the standard `CAUTHEN_AUTHEN_TYPED` route, so
52
+ no extra route registration is needed. It orders itself last (`order: 900`) and renders as a link,
53
+ because it is a tool rather than a way in. Test ids: `supervisor-auth-form`, `supervisor-user-id`,
54
+ `supervisor-pk`, `supervisor-submit`, `supervisor-error`.
55
+
56
+ On submit the form requests a fresh allowance, signs `buildSupervisorPayload(challenge, userId,
57
+ salt)` with the entered private key, packs `{ salt, signature }` as the credential, exchanges the
58
+ resulting token through the client `AuthService`, and navigates via `landAfterLogin` +
59
+ `landingUrl` (`@owlmeans/client-auth/login`) — a pending post-login step, then a screen suspended
60
+ in `@owlmeans/client-flow` (an OAuth consent screen reached signed out, say), else `HOME`. It no
61
+ longer imports `@owlmeans/client-flow` or `@owlmeans/web-client` directly; `landAfterLogin` is the
62
+ whole decision.
63
+
64
+ See the **supervisor-auth** skill for the whole feature — the server append, its options, the
65
+ security boundary and the `@owlmeans/test-ui` helpers.
39
66
 
40
67
  ## Depends On
41
- - `@owlmeans/client-auth`, `@owlmeans/web-client`, `@owlmeans/client`
42
- - `@owlmeans/auth` (type + `buildSupervisorPayload`), `@owlmeans/basic-keys`, `@owlmeans/basic-ids`
68
+ - `@owlmeans/client-auth` (the manager plugin registry), `@owlmeans/web-client`, `@owlmeans/client`
69
+ - `@owlmeans/auth` — `AuthenticationType.Supervisor`, `buildSupervisorPayload`
70
+ - `@owlmeans/auth-common` — the client `AuthService` type
71
+ - `@owlmeans/basic-keys` (signing), `@owlmeans/basic-ids` (the salt), `@owlmeans/config`
package/build/append.d.ts CHANGED
@@ -1,19 +1,28 @@
1
+ import type { CommonConfig } from '@owlmeans/config';
1
2
  export interface WebSupervisorAuthOptions {
2
- /** Force enable/disable. Default: development only (cfg.debug.all || cfg.debug.supervisor). */
3
+ /** Force enable/disable. Default: `cfg.debug.supervisor === true`. */
3
4
  enabled?: boolean;
5
+ /**
6
+ * Also offer it on the sign-in screen. Defaults to true — an operator login that is registered
7
+ * but reachable only by typing its URL is a login nobody finds and an exposure nobody sees.
8
+ */
9
+ offer?: boolean;
4
10
  }
5
- /**
6
- * Unified, explicit append for the PK-based supervisor login UI. Call it once on
7
- * the web client context. Development-only by default. It registers the
8
- * supervisor client plugin so the form is rendered by the standard typed
9
- * authentication route at {@link SUPERVISOR_LOGIN_PATH}.
10
- */
11
- export declare const appendSupervisorAuth: <T extends {
11
+ interface DebugCarrier {
12
12
  cfg: {
13
13
  debug?: {
14
14
  all?: boolean;
15
15
  supervisor?: boolean;
16
16
  };
17
+ security?: CommonConfig['security'];
17
18
  };
18
- }>(context: T, opts?: WebSupervisorAuthOptions) => T;
19
+ }
20
+ /**
21
+ * Unified, explicit append for the PK-based supervisor login UI. Call it once on the web client
22
+ * context. It registers the supervisor client plugin so the form is rendered by the standard typed
23
+ * authentication route at {@link SUPERVISOR_LOGIN_PATH}, and enables it in the sign-in screen's
24
+ * configuration — which is what turns a `restricted` method from registered into offerable.
25
+ */
26
+ export declare const appendSupervisorAuth: <T extends DebugCarrier>(context: T, opts?: WebSupervisorAuthOptions) => T;
27
+ export {};
19
28
  //# sourceMappingURL=append.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../src/append.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,wBAAwB;IACvC,+FAA+F;IAC/F,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAKD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS;IAAE,GAAG,EAAE;QAAE,KAAK,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,OAAO,CAAC;YAAC,UAAU,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,WAChG,CAAC,SAAS,wBAAwB,KAC1C,CASF,CAAA"}
1
+ {"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../src/append.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAGpD,MAAM,WAAW,wBAAwB;IACvC,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,UAAU,YAAY;IACpB,GAAG,EAAE;QACH,KAAK,CAAC,EAAE;YAAE,GAAG,CAAC,EAAE,OAAO,CAAC;YAAC,UAAU,CAAC,EAAE,OAAO,CAAA;SAAE,CAAA;QAC/C,QAAQ,CAAC,EAAE,YAAY,CAAC,UAAU,CAAC,CAAA;KACpC,CAAA;CACF;AAcD;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,YAAY,WAChD,CAAC,SAAS,wBAAwB,KAC1C,CAoBF,CAAA"}
package/build/append.js CHANGED
@@ -1,19 +1,38 @@
1
1
  import { AuthenticationType } from '@owlmeans/auth';
2
2
  import { plugins as authPlugins } from '@owlmeans/client-auth/manager';
3
3
  import { supervisorClientPlugin } from './auth/plugins/supervisor.js';
4
- const isDevelopment = (context) => context.cfg.debug?.all === true || context.cfg.debug?.supervisor === true;
5
4
  /**
6
- * Unified, explicit append for the PK-based supervisor login UI. Call it once on
7
- * the web client context. Development-only by default. It registers the
8
- * supervisor client plugin so the form is rendered by the standard typed
9
- * authentication route at {@link SUPERVISOR_LOGIN_PATH}.
5
+ * Whether this deployment wants the PK supervisor login.
6
+ *
7
+ * Reads `debug.supervisor` and deliberately NOT `debug.all`. `debug.all` is set by whole families
8
+ * of applications for reasons that have nothing to do with authentication — a generated target
9
+ * application sets it for itself — so gating on it hands an operator login to every one of them,
10
+ * in production, reachable by anyone who types the URL. `debug.supervisor` is a deployment saying
11
+ * this specific thing on purpose.
12
+ */
13
+ const isSupervised = (context) => context.cfg.debug?.supervisor === true;
14
+ /**
15
+ * Unified, explicit append for the PK-based supervisor login UI. Call it once on the web client
16
+ * context. It registers the supervisor client plugin so the form is rendered by the standard typed
17
+ * authentication route at {@link SUPERVISOR_LOGIN_PATH}, and enables it in the sign-in screen's
18
+ * configuration — which is what turns a `restricted` method from registered into offerable.
10
19
  */
11
20
  export const appendSupervisorAuth = (context, opts) => {
12
- const enabled = opts?.enabled ?? isDevelopment(context);
21
+ const enabled = opts?.enabled ?? isSupervised(context);
13
22
  if (!enabled) {
14
23
  return context;
15
24
  }
16
25
  authPlugins[AuthenticationType.Supervisor] = supervisorClientPlugin;
26
+ if (opts?.offer ?? true) {
27
+ const cfg = context.cfg;
28
+ cfg.security ??= {};
29
+ cfg.security.auth ??= {};
30
+ cfg.security.auth.login ??= {};
31
+ const login = cfg.security.auth.login;
32
+ login.secretKey ??= true;
33
+ login.overrides ??= {};
34
+ login.overrides[AuthenticationType.Supervisor] ??= { enabled: true };
35
+ }
17
36
  return context;
18
37
  };
19
38
  //# sourceMappingURL=append.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"append.js","sourceRoot":"","sources":["../src/append.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAOrE,MA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EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAmB,CAAA;QACvC,GAAG,CAAC,QAAQ,KAAK,EAAE,CAAA;QACnB,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,EAAE,CAAA;QACxB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,KAAK,EAAE,CAAA;QAC9B,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAA;QACrC,KAAK,CAAC,SAAS,KAAK,IAAI,CAAA;QACxB,KAAK,CAAC,SAAS,KAAK,EAAE,CAAA;QACtB,KAAK,CAAC,SAAS,CAAC,kBAAkB,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;IACtE,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../../src/auth/plugins/supervisor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAWjF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,oBAsEpC,CAAA"}
1
+ {"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../../../src/auth/plugins/supervisor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAA;AAUjF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,EAAE,oBA8EpC,CAAA"}
@@ -3,7 +3,7 @@ import { useState } from 'react';
3
3
  import { AuthenticationType, buildSupervisorPayload } from '@owlmeans/auth';
4
4
  import { DEFAULT_ALIAS as AUTH_SERVICE } from '@owlmeans/client-auth';
5
5
  import { useContext } from '@owlmeans/client';
6
- import { HOME } from '@owlmeans/web-client';
6
+ import { landAfterLogin, landingUrl } from '@owlmeans/client-auth/login';
7
7
  import { makeKeyPairModel } from '@owlmeans/basic-keys';
8
8
  import { createIdOfLength } from '@owlmeans/basic-ids';
9
9
  /**
@@ -20,6 +20,10 @@ import { createIdOfLength } from '@owlmeans/basic-ids';
20
20
  */
21
21
  export const supervisorClientPlugin = {
22
22
  type: AuthenticationType.Supervisor,
23
+ // `restricted`, so registering the plugin is not enough to put an operator login on the sign-in
24
+ // screen of a production application — the configuration has to name it. Last in the order and
25
+ // rendered as a link, because it is a tool, not a way in.
26
+ method: { order: 900, icon: 'key', emphasis: 'link', restricted: true },
23
27
  Implementation: () => ({ type, control }) => {
24
28
  const context = useContext();
25
29
  const [userId, setUserId] = useState('');
@@ -39,8 +43,11 @@ export const supervisorClientPlugin = {
39
43
  const authService = context.service(AUTH_SERVICE);
40
44
  await authService.authenticate(token);
41
45
  }
42
- const [homeUrl] = await context.module(HOME).call({ full: true }) ?? [];
43
- window.location.href = homeUrl ?? window.location.origin;
46
+ // A registered step (marketing consent, say) or a device/authorization-code consent
47
+ // screen that suspended itself here before sending the browser to sign in both take
48
+ // priority over the app's own home — `landAfterLogin` is the whole decision.
49
+ const landing = await landAfterLogin(context);
50
+ window.location.href = await landingUrl(context, landing);
44
51
  }
45
52
  catch (e) {
46
53
  setError(e instanceof Error ? e.message : String(e));
@@ -1 +1 @@
1
- {"version":3,"file":"supervisor.js","sourceRoot":"","sources":["../../../src/auth/plugins/supervisor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGhC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAE3E,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAErE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAA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C,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;QAC/G,WAAW,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;QAE5D,8EAA8E;QAC9E,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;IACtB,CAAC;CACF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/web-auth",
3
- "version": "0.1.18-rc.6",
3
+ "version": "0.1.18-rc.60",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -29,21 +29,23 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@owlmeans/auth": "^0.1.18-rc.6",
33
- "@owlmeans/auth-common": "^0.1.18-rc.6",
34
- "@owlmeans/basic-ids": "^0.1.18-rc.6",
35
- "@owlmeans/basic-keys": "^0.1.18-rc.6",
36
- "@owlmeans/client": "^0.1.18-rc.6",
37
- "@owlmeans/client-auth": "^0.1.18-rc.6",
38
- "@owlmeans/context": "^0.1.18-rc.6",
39
- "@owlmeans/web-client": "^0.1.18-rc.6"
32
+ "@owlmeans/auth": "^0.1.18-rc.38",
33
+ "@owlmeans/auth-common": "^0.1.18-rc.45",
34
+ "@owlmeans/basic-ids": "^0.1.18-rc.35",
35
+ "@owlmeans/basic-keys": "^0.1.18-rc.46",
36
+ "@owlmeans/client": "^0.1.18-rc.49",
37
+ "@owlmeans/client-auth": "^0.1.18-rc.56",
38
+ "@owlmeans/client-flow": "^0.1.18-rc.52",
39
+ "@owlmeans/config": "^0.1.18-rc.42",
40
+ "@owlmeans/context": "^0.1.18-rc.32",
41
+ "@owlmeans/web-client": "^0.1.18-rc.59"
40
42
  },
41
43
  "peerDependencies": {
42
44
  "react": "*"
43
45
  },
44
46
  "devDependencies": {
45
47
  "@owlmeans/dep-config": "workspace:*",
46
- "@types/bun": "^1.3.14",
48
+ "@types/bun": "^1.4.0",
47
49
  "@types/react": "^19.2.17",
48
50
  "nodemon": "^3.1.14",
49
51
  "typescript": "^7.0.2"
package/src/append.ts CHANGED
@@ -1,30 +1,63 @@
1
1
  import { AuthenticationType } from '@owlmeans/auth'
2
2
  import { plugins as authPlugins } from '@owlmeans/client-auth/manager'
3
+ import type { CommonConfig } from '@owlmeans/config'
3
4
  import { supervisorClientPlugin } from './auth/plugins/supervisor.js'
4
5
 
5
6
  export interface WebSupervisorAuthOptions {
6
- /** Force enable/disable. Default: development only (cfg.debug.all || cfg.debug.supervisor). */
7
+ /** Force enable/disable. Default: `cfg.debug.supervisor === true`. */
7
8
  enabled?: boolean
9
+ /**
10
+ * Also offer it on the sign-in screen. Defaults to true — an operator login that is registered
11
+ * but reachable only by typing its URL is a login nobody finds and an exposure nobody sees.
12
+ */
13
+ offer?: boolean
8
14
  }
9
15
 
10
- const isDevelopment = (context: { cfg: { debug?: { all?: boolean, supervisor?: boolean } } }): boolean =>
11
- context.cfg.debug?.all === true || context.cfg.debug?.supervisor === true
16
+ interface DebugCarrier {
17
+ cfg: {
18
+ debug?: { all?: boolean, supervisor?: boolean }
19
+ security?: CommonConfig['security']
20
+ }
21
+ }
12
22
 
13
23
  /**
14
- * Unified, explicit append for the PK-based supervisor login UI. Call it once on
15
- * the web client context. Development-only by default. It registers the
16
- * supervisor client plugin so the form is rendered by the standard typed
17
- * authentication route at {@link SUPERVISOR_LOGIN_PATH}.
24
+ * Whether this deployment wants the PK supervisor login.
25
+ *
26
+ * Reads `debug.supervisor` and deliberately NOT `debug.all`. `debug.all` is set by whole families
27
+ * of applications for reasons that have nothing to do with authentication — a generated target
28
+ * application sets it for itself — so gating on it hands an operator login to every one of them,
29
+ * in production, reachable by anyone who types the URL. `debug.supervisor` is a deployment saying
30
+ * this specific thing on purpose.
18
31
  */
19
- export const appendSupervisorAuth = <T extends { cfg: { debug?: { all?: boolean, supervisor?: boolean } } }>(
32
+ const isSupervised = (context: DebugCarrier): boolean =>
33
+ context.cfg.debug?.supervisor === true
34
+
35
+ /**
36
+ * Unified, explicit append for the PK-based supervisor login UI. Call it once on the web client
37
+ * context. It registers the supervisor client plugin so the form is rendered by the standard typed
38
+ * authentication route at {@link SUPERVISOR_LOGIN_PATH}, and enables it in the sign-in screen's
39
+ * configuration — which is what turns a `restricted` method from registered into offerable.
40
+ */
41
+ export const appendSupervisorAuth = <T extends DebugCarrier>(
20
42
  context: T, opts?: WebSupervisorAuthOptions
21
43
  ): T => {
22
- const enabled = opts?.enabled ?? isDevelopment(context)
44
+ const enabled = opts?.enabled ?? isSupervised(context)
23
45
  if (!enabled) {
24
46
  return context
25
47
  }
26
48
 
27
49
  authPlugins[AuthenticationType.Supervisor] = supervisorClientPlugin
28
50
 
51
+ if (opts?.offer ?? true) {
52
+ const cfg = context.cfg as CommonConfig
53
+ cfg.security ??= {}
54
+ cfg.security.auth ??= {}
55
+ cfg.security.auth.login ??= {}
56
+ const login = cfg.security.auth.login
57
+ login.secretKey ??= true
58
+ login.overrides ??= {}
59
+ login.overrides[AuthenticationType.Supervisor] ??= { enabled: true }
60
+ }
61
+
29
62
  return context
30
63
  }
@@ -6,8 +6,7 @@ import type { AuthToken } from '@owlmeans/auth'
6
6
  import { DEFAULT_ALIAS as AUTH_SERVICE } from '@owlmeans/client-auth'
7
7
  import type { AuthService } from '@owlmeans/auth-common'
8
8
  import { useContext } from '@owlmeans/client'
9
- import { HOME } from '@owlmeans/web-client'
10
- import type { Module } from '@owlmeans/web-client'
9
+ import { landAfterLogin, landingUrl } from '@owlmeans/client-auth/login'
11
10
  import { makeKeyPairModel } from '@owlmeans/basic-keys'
12
11
  import { createIdOfLength } from '@owlmeans/basic-ids'
13
12
 
@@ -26,6 +25,11 @@ import { createIdOfLength } from '@owlmeans/basic-ids'
26
25
  export const supervisorClientPlugin: AuthenticationPlugin = {
27
26
  type: AuthenticationType.Supervisor,
28
27
 
28
+ // `restricted`, so registering the plugin is not enough to put an operator login on the sign-in
29
+ // screen of a production application — the configuration has to name it. Last in the order and
30
+ // rendered as a link, because it is a tool, not a way in.
31
+ method: { order: 900, icon: 'key', emphasis: 'link', restricted: true },
32
+
29
33
  Implementation: () => ({ type, control }) => {
30
34
  const context = useContext()
31
35
  const [userId, setUserId] = useState('')
@@ -49,8 +53,11 @@ export const supervisorClientPlugin: AuthenticationPlugin = {
49
53
  await authService.authenticate(token)
50
54
  }
51
55
 
52
- const [homeUrl] = await context.module<Module<string>>(HOME).call({ full: true }) ?? []
53
- window.location.href = homeUrl ?? window.location.origin
56
+ // A registered step (marketing consent, say) or a device/authorization-code consent
57
+ // screen that suspended itself here before sending the browser to sign in both take
58
+ // priority over the app's own home — `landAfterLogin` is the whole decision.
59
+ const landing = await landAfterLogin(context)
60
+ window.location.href = await landingUrl(context, landing)
54
61
  } catch (e) {
55
62
  setError(e instanceof Error ? e.message : String(e))
56
63
  setBusy(false)