@owlmeans/client-iam 0.1.18-rc.59 → 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 ADDED
@@ -0,0 +1,15 @@
1
+ <!-- owlmeans:agent-guidance:start -->
2
+ ## Agent guidance
3
+
4
+ This package ships embedded agent skills under `agent-meta/`. After installing your
5
+ `@owlmeans/*` packages, run the OwlMeans agent-skills installer to place them into
6
+ your project's skill store (`.agents/skills/`):
7
+
8
+ ```sh
9
+ npx @owlmeans/agent-skills@^0.1.18-rc.46
10
+ ```
11
+
12
+ The embedded files are version-matched to this package release. Do not edit them
13
+ directly — they are regenerated on each publish. To contribute guidance edits,
14
+ open a PR against the source monorepo.
15
+ <!-- owlmeans:agent-guidance:end -->
@@ -0,0 +1,16 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "package": "@owlmeans/client-iam",
4
+ "version": "0.1.18-rc.60",
5
+ "generatedAt": "2026-10-03T11:19:50.796Z",
6
+ "canonicalRepo": "https://github.com/owlmeans/common",
7
+ "entries": [
8
+ {
9
+ "kind": "skill",
10
+ "name": "client-iam",
11
+ "category": "package-specific",
12
+ "file": "skills/client-iam/SKILL.md",
13
+ "canonicalPath": ".agents/skills/client-iam/SKILL.md"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,127 @@
1
+ ---
2
+ name: client-iam
3
+ description: "How to use @owlmeans/client-iam — the browser half of the OwlMeans IAM in one import: appendIam (OIDC guard plus the consent-before-sign-in precondition), withIamGuard / iamEntrypoints, the re-exported sign-in surface (useLogin, useLogout), the session's organizations (listOrganizations) and the organization switch (switchOrganization, which adopts the re-signed token), hasPermission for showing or hiding a control, and the refusal reasons ORGANIZATION_REFUSAL / ORGANIZATION_OWNER_REFUSAL. Auto-invoked when wiring sign-in into a web app, rendering an organization switcher, or reading permissions in a screen."
4
+ user-invocable: false
5
+ ---
6
+ <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
7
+
8
+ # @owlmeans/client-iam
9
+
10
+ **Layer:** Client (browser-only — it depends on `@owlmeans/web-client` and `@owlmeans/web-oidc-rp`)
11
+ **Install:** `"@owlmeans/client-iam": "^0.1.18-rc.60"` in `dependencies`
12
+
13
+ The browser side of the IAM for an application that signs its people in through an OwlMeans OIDC
14
+ provider. One import wires the relying party, puts the consent precondition in front of every
15
+ sign-in, lists the organizations of the session and moves the session between them. It decides
16
+ nothing: every permission is enforced by the application's server (`@owlmeans/server-iam`); a screen
17
+ reads permissions only to show or hide a control.
18
+
19
+ ## Key Exports
20
+
21
+ | Export | Description |
22
+ |--------|-------------|
23
+ | `appendIam(context, opts?)` | `appendOidcGuard` of `@owlmeans/web-oidc-rp` plus `requireConsentForLogin`. `opts.consent` is `ConsentLoginOptions` — `{ disabled: true }` for an application that sets no cookie at all |
24
+ | `withIamGuard(tree, coguards?)` | `withOidcGuard` of `@owlmeans/oidc`: a decorated copy of an immutable protocol tree with `OIDC_GUARD` ahead of each selected guard (default `DEFAULT_GUARD`) |
25
+ | `iamEntrypoints(dispatcherProps?)` | `oidcEntrypoints` of `@owlmeans/web-oidc-rp`: the browser bindings of the four shared OIDC protocols (sign-in pair and organization switch) and the dispatcher screen |
26
+ | `listOrganizations(ctx)` | `OidcOrganizationItem[]` of the session — `{ entitySlug, title?, owner, groups?, home?, acting }` |
27
+ | `switchOrganization(ctx, entitySlug)` | Moves the session into another of its organizations and adopts the re-signed token with `adoptToken` |
28
+ | `requireConsentForLogin(ctx, opts?)`, `CONSENT_LOGIN_PRECONDITION`, `ConsentLoginOptions` | The consent precondition on its own (`'consent-before-login'`, priority 100), for a context wired another way |
29
+ | `useLogin` / `useLogout`, `LoginOutcome`, `LoginIntent` and the login types | Re-exported from `@owlmeans/client-auth/login`, so an application has one IAM import |
30
+ | `hasPermission(auth, permission, { scope?, resourceId?, entitySlug? }?)` | Re-exported from `@owlmeans/iam` — the same check the server gate runs |
31
+ | `ORGANIZATION_REFUSAL`, `ORGANIZATION_OWNER_REFUSAL` | `'organization'` / `'organization:owner'` — the `AuthForbidden` reasons of a non-member and of a non-owner |
32
+ | `OidcOrganizationItem` and every `@owlmeans/iam` type | Re-exported types |
33
+ | `CLIENT_IAM_SERVICE` | `'client-iam-service'` — an alias constant nothing registers |
34
+
35
+ ## Wiring
36
+
37
+ ```typescript
38
+ import { bindAll } from '@owlmeans/client-entrypoint'
39
+ import { appendIam, iamEntrypoints, withIamGuard } from '@owlmeans/client-iam'
40
+
41
+ appendIam(context) // guard + consent precondition
42
+
43
+ export const protocols = withIamGuard(appProtocols) // decorate the tree once
44
+ export const bindings = [
45
+ ...bindAll(protocols.api),
46
+ ...iamEntrypoints(), // spread once
47
+ ]
48
+ ```
49
+
50
+ `appendIam` reads the provider list from `cfg.oidc.providers`; an application whose browser is given
51
+ none still offers one generic sign-in method, and its server's default provider decides the issuer
52
+ (`web-oidc-rp`). Decorate the tree before binding it — the helpers never append declarations to a
53
+ flattened entrypoint list.
54
+
55
+ The consent precondition sits on `LoginService.begin`, the one funnel every sign-in mechanic passes
56
+ through and the place the user's gesture is still live: a refusal resolves as
57
+ `LoginOutcome.Gesture` and opens the consent dialog in the same gesture, and the person presses
58
+ "Log in" again after accepting (`login-plugins`, `web-consent`).
59
+
60
+ ## Organizations of the session
61
+
62
+ A person is one account; an application sees it through its rows, one per organization the person
63
+ belongs to in that application. With the provider's `organizations` scope the session acts in ONE
64
+ of them at a time, and that is session state held by the application's server — never a parameter
65
+ of a request:
66
+
67
+ ```typescript
68
+ import { listOrganizations, switchOrganization, ORGANIZATION_REFUSAL } from '@owlmeans/client-iam'
69
+
70
+ const items = await listOrganizations(context) // the acting one carries `acting: true`
71
+ try {
72
+ await switchOrganization(context, 'hiking-club')
73
+ // every request from here on, and every screen reading `auth`, acts in hiking-club
74
+ } catch (error) {
75
+ // AuthForbidden(ORGANIZATION_REFUSAL): not one of the person's organizations — the token stays
76
+ }
77
+ ```
78
+
79
+ - Both calls go to the application's OWN server (`GET /authenticate/oidc/organizations`,
80
+ `POST /authenticate/oidc/organization`), behind `OIDC_GUARD`, so they need the bindings
81
+ `iamEntrypoints()` spreads. The server side — the session record, re-picking, refusals — is
82
+ governed by `server-oidc-rp` → "Organizations".
83
+ - The re-signed token carries the new organization's `entitySlug`, its groups and only its
84
+ permission sets. Re-read `auth` after a switch; nothing else needs resetting.
85
+ - There is no per-request organization selector: a screen offering "act in another organization"
86
+ calls `switchOrganization`. A client without the `organizations` scope lists none and refuses
87
+ every switch.
88
+
89
+ Managing organizations — creating one, inviting members, granting in it — is the server's job
90
+ through `iamRuntime` (`@owlmeans/server-iam`); the browser calls the application's own endpoints
91
+ for it, never the provider.
92
+
93
+ ## Permissions in a screen
94
+
95
+ ```typescript
96
+ import { hasPermission } from '@owlmeans/client-iam'
97
+
98
+ const canApprove = hasPermission(context.auth().user(), 'loan--approve', { resourceId: loanId })
99
+ ```
100
+
101
+ The browser token holds the unbound sets plus the acting organization's sets with their binding
102
+ already stripped, so a screen needs no `entitySlug`. A set without `resources` covers every id. Use
103
+ the answer to hide or show a control only — the server gate decides.
104
+
105
+ ## Rules
106
+
107
+ - One IAM import: take sign-in, organizations and permission checks from here, not from
108
+ `@owlmeans/web-oidc-rp`, `@owlmeans/client-auth/login` and `@owlmeans/iam` separately.
109
+ - Adopt a token only through `adoptToken` / `context.login().adopt(token)` — `switchOrganization`
110
+ already does; never write `auth` or the stored token by hand.
111
+ - Phrase `ORGANIZATION_REFUSAL` and `ORGANIZATION_OWNER_REFUSAL` as sentences for the person; they
112
+ are reasons, not messages.
113
+ - Never send an organization id from the browser: organizations travel by `entitySlug` only.
114
+
115
+ ## Depends On
116
+
117
+ - `@owlmeans/web-oidc-rp`, `@owlmeans/oidc` — the guard, the bindings and the switch protocols
118
+ - `@owlmeans/client-auth` — the login host and `adoptToken`
119
+ - `@owlmeans/consent` — the consent store the precondition reads
120
+ - `@owlmeans/iam` — types and `hasPermission`
121
+ - `@owlmeans/context`, `@owlmeans/entrypoint`, `@owlmeans/web-client`
122
+
123
+ ## Related
124
+
125
+ - `server-iam` — the gate, the session's organizations on the server, the runtime IAM client
126
+ - `iam` — the permission model (kinds, default classes) and the `IamService`
127
+ - `web-oidc-rp`, `login-plugins`, `login-methods` — the sign-in machinery underneath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/client-iam",
3
- "version": "0.1.18-rc.59",
3
+ "version": "0.1.18-rc.60",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -22,14 +22,14 @@
22
22
  }
23
23
  },
24
24
  "dependencies": {
25
- "@owlmeans/client-auth": "^0.1.18-rc.54",
25
+ "@owlmeans/client-auth": "^0.1.18-rc.55",
26
26
  "@owlmeans/consent": "^0.1.18-rc.9",
27
27
  "@owlmeans/context": "^0.1.18-rc.32",
28
- "@owlmeans/entrypoint": "^0.1.18-rc.38",
29
- "@owlmeans/iam": "^0.1.18-rc.46",
30
- "@owlmeans/oidc": "^0.1.18-rc.51",
31
- "@owlmeans/web-client": "^0.1.18-rc.57",
32
- "@owlmeans/web-oidc-rp": "^0.1.18-rc.60"
28
+ "@owlmeans/entrypoint": "^0.1.18-rc.39",
29
+ "@owlmeans/iam": "^0.1.18-rc.47",
30
+ "@owlmeans/oidc": "^0.1.18-rc.52",
31
+ "@owlmeans/web-client": "^0.1.18-rc.58",
32
+ "@owlmeans/web-oidc-rp": "^0.1.18-rc.61"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@owlmeans/dep-config": "workspace:*",