@owlmeans/auth 0.1.18-rc.37 → 0.1.18-rc.38

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
@@ -14,7 +14,7 @@ shared auth protocols and organization-entity resolution (`entityKeyOf`, `requir
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
- bun add @owlmeans/auth@^0.1.18-rc.37
17
+ bun add @owlmeans/auth@^0.1.18-rc.38
18
18
  ```
19
19
 
20
20
  `ajv` is a **peer** dependency — install it alongside, or `verifyAuth` / `verifyAuthCredentials`
@@ -330,7 +330,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
330
330
  your project's skill store (`.agents/skills/`):
331
331
 
332
332
  ```sh
333
- npx @owlmeans/agent-skills@^0.1.18-rc.45
333
+ npx @owlmeans/agent-skills@^0.1.18-rc.46
334
334
  ```
335
335
 
336
336
  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/auth",
4
- "version": "0.1.18-rc.37",
5
- "generatedAt": "2026-10-01T23:27:48.720Z",
4
+ "version": "0.1.18-rc.38",
5
+ "generatedAt": "2026-10-03T11:19:50.769Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -8,7 +8,7 @@ user-invocable: false
8
8
  # @owlmeans/auth
9
9
 
10
10
  **Layer:** Core
11
- **Install:** `"@owlmeans/auth": "^0.1.18-rc.37"` in `dependencies`
11
+ **Install:** `"@owlmeans/auth": "^0.1.18-rc.38"` in `dependencies`
12
12
 
13
13
  Types, enums, errors and schemas only — no services, no wiring. Every other auth package builds on
14
14
  this vocabulary, so a symbol belongs here exactly when both a server and a browser need to agree on
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: auth-protocol
3
- description: Comprehensive reference for the OwlMeans authentication and authorization protocol — the Ed25519, OIDC, provider-backed local identity, email-OTP and PK-supervisor paths, the core types and error hierarchy, guards and gates, the trust resource, the envelope shape, organization-entity resolution, the refresh flow, and the mocking points. Auto-invoked when files under auth*, *oidc*, server-auth-identity, did*, wled or client-payment are touched.
3
+ description: Comprehensive reference for the OwlMeans authentication and authorization protocol — the Ed25519, OIDC, provider-backed local identity, email-OTP, hosted-app (integrated provider) and PK-supervisor paths, the identity model (one account per e-mail, credentials on the account, profile rows per app and organization, organizations with groups), pairwise subjects, the acting organization as session state and its switch, the four permission kinds, the core types and error hierarchy, guards and gates, the trust resource, the envelope shape, organization-entity resolution, the refresh flow, and the mocking points. Auto-invoked when files under auth*, *oidc*, *iam*, server-auth-identity, did*, wled or client-payment are touched.
4
4
  ---
5
5
  <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
6
6
 
@@ -30,19 +30,19 @@ Use case: service-to-service, wallet provider, backend clients, high-security br
30
30
  Use case: browser clients, third-party IdP integration, multi-tenant SaaS.
31
31
 
32
32
  1. Standard OAuth2 authorization-code flow. The relying party redirects to the provider and the return leg exchanges the code: `makeOidcClientService` (`@owlmeans/server-oidc-rp`) replays the stored PKCE verifier and grants the token set.
33
- 2. Server decodes the ID token, builds an `Auth` from its claims, and wraps it in an envelope of type `oidc-wrapped-token` signed with the service key — the bearer is `OIDC-WRAPPED-TOKEN <encoded>`.
33
+ 2. Server decodes the ID token — only the id_token; an access token's format is provider-private — builds an `Auth` from its claims, and wraps it in an envelope of type `oidc-wrapped-token` signed with the service key — the bearer is `OIDC-WRAPPED-TOKEN <encoded>`. The token set and, for a tenanted client, the organizations stay in the server-side session record ("Organizations and the session").
34
34
  3. Subsequent requests are matched and handled by `makeOidcGuard` (`@owlmeans/oidc`), which verifies the envelope signature against the service key and delegates freshness to the `WRAPPED_OIDC` service.
35
- 4. Refresh: `makeOidcWrappingService` (`@owlmeans/server-oidc-rp`) re-validates the stored token set — introspection, or a refresh grant once `expires_at` has passed — and re-signs the wrapped token. When the value changes, the guard returns it in the **`TOKEN_UPDATE` response header** (`'auth-token-refresh'`, `@owlmeans/auth-common`); an empty value means the session is over. It is a header, not a route: `@owlmeans/server-api` lists it in `exposedHeaders` and `@owlmeans/api`'s client service feeds it back into `AuthService.update()`. Where the deployment has a separate auth manager, the wrapper reaches it over the `external-auth:auth:update` declaration from `makeAuthServiceEntrypoints`, bound at `/<prefix>/auth/update`.
35
+ 4. Refresh: `makeOidcWrappingService` (`@owlmeans/server-oidc-rp`) re-validates the stored token set — introspection, or a refresh grant once `expires_at` has passed; current userinfo on every request under `sessionValidation: 'required'` — and re-signs the wrapped token. When the value changes, the guard returns it in the **`TOKEN_UPDATE` response header** (`'auth-token-refresh'`, `@owlmeans/auth-common`); an empty value means the session is over. It is a header, not a route: `@owlmeans/server-api` lists it in `exposedHeaders` and `@owlmeans/api`'s client service feeds it back into `AuthService.update()`. Where the deployment has a separate auth manager, the wrapper reaches it over the `external-auth:auth:update` declaration from `makeAuthServiceEntrypoints`, bound at `/<prefix>/auth/update`.
36
36
 
37
- ### Provider-Backed Local Identity
37
+ ### Provider-backed local identity
38
38
 
39
- Use case: apps such as `product-viable` that use Google/OIDC as login bootstrap but authorize against local product identity.
39
+ Use case: a deployment that signs its own people in through Google, OIDC or an e-mail code and authorizes against its own identity store (`@owlmeans/server-auth-identity`).
40
40
 
41
41
  1. Browser imports `@owlmeans/web-oidc-rp/auth/plugins`, which registers OIDC and Google plugins in `@owlmeans/client-auth`.
42
42
  2. The plugin persists auth control state, redirects to the provider, restores state on return, and submits code/query params as `AuthCredentials`.
43
- 3. Server exchanges the provider code through `@owlmeans/server-oidc-rp` and maps `ProviderProfileDetails` through `@owlmeans/server-auth-identity`.
44
- 4. `AUTH_IDENTITY_ORG_ENTITY`, `AUTH_IDENTITY_ACCOUNT`, `AUTH_IDENTITY_PROFILE` and `AUTH_IDENTITY_CREDENTIALS` store the organization entity and the local account/profile/provider-link data. A second login method on the same email adds a CREDENTIAL to the person's existing profile — it never mints a second identity or a second organization.
45
- 5. Server returns a normal OwlMeans bearer token carrying the organization's `entitySlug`. Downstream product gates authorize against local profile scopes, not against `OIDC_GATE`.
43
+ 3. Server exchanges the provider code through `@owlmeans/server-oidc-rp`. The Google plugin refuses a userinfo whose `email_verified` is not `true` (`AuthenFailed('email-verified')`): the address is what links the sign-in to an account.
44
+ 4. The linking service (`AUTH_IDENTITY_LINKING`) maps `ProviderProfileDetails` onto the identity model ("The identity model"): `getLinkedProfile` follows the method's credential to its account and answers the row of THIS deployment's app in the account's main organization; otherwise `linkProfile(details, { username: verifiedEmail })` runs `ensureAccount` — a further method of a known address becomes another credential on the same account, a new address registers an account with a personal organization — and `ensureProfile` for the deployment's own app there (`owner: true`, `scopes: ['*']`).
45
+ 5. Server returns a normal OwlMeans bearer token carrying the organization's `entitySlug` and the row's `profileId`. Downstream product gates authorize against that row — requiring its `service` to be the deployment's own app, because the same organization holds hosted apps' rows — not against `OIDC_GATE`.
46
46
 
47
47
  ### Email one-time code
48
48
 
@@ -50,7 +50,19 @@ Use case: passwordless sign-in where no external IdP is wanted.
50
50
 
51
51
  1. Client posts `{ type: 'email-otp', userId: <email> }` to `/authentication/init`.
52
52
  2. `@owlmeans/server-auth-otp` mails a six-digit code, stores it in Redis under a TTL, and answers with a challenge of `"<email>::<nonce>"` — the nonce is what keeps two independent attempts for one address from colliding in the manager's anti-replay cache.
53
- 3. Client posts the code as `AuthCredentials.credential`; the plugin verifies and consumes it, resolves the identity through `AUTH_IDENTITY_LINKING`, and the manager signs the credential envelope as usual.
53
+ 3. Client posts the code as `AuthCredentials.credential`; the plugin verifies and consumes it, resolves the identity through the linking service `cfg.otp.identityAlias` names (default `AUTH_IDENTITY_LINKING`), and the manager signs the credential envelope as usual. An integrated provider's end-user login names the e-mail proof linking service there instead (next path).
54
+
55
+ ### Hosted-app sign-in through the integrated provider
56
+
57
+ Use case: an application a deployment hosts (a generated target) signs its end users in against the deployment's own OIDC provider (`@owlmeans/server-oidc-provider` with `@owlmeans/iam-integrated`), over the same identity store.
58
+
59
+ 1. The application's server relying party (`appendIam` of `@owlmeans/server-iam`) sends the browser to the provider with the base scopes plus `permissions` (and `organizations` for a tenanted client); a provisioned client's allowlist is a superset of everything a relying party asks for.
60
+ 2. The provider's login screen runs the e-mail code against the deployment's auth manager with the e-mail proof linking service (`makeEmailProofLinkingService`). Its payload proves the address and identifies nobody: `profileId: IAM_EMAIL_PROOF` (`'proof:email'`), `userId` = the address, one narrow end-user scope, no `entitySlug` — and it writes nothing.
61
+ 3. The provider's interaction finalizer verifies that proof, loads the interaction's client and calls `subjects.signIn(clientId, { email })`: the account (one per address; the e-mail code a credential on it), its primary row of the app as owner of the personal organization, and — for staff of the client's owning organization — the staff row there. The provider grant and session name the ACCOUNT id.
62
+ 4. `findAccount` asks `subjects.resolve(clientId, accountId)` for the claims. `null` (no row of the app, a disabled or expired primary row) refuses the account, and the provider's `account_refused` login check sends the browser back to the login screen instead of failing the consent.
63
+ 5. The claims: `sub` = the pairwise subject, `email`, `permissions`, and `organizations` under its scope. The account's record id never leaves the provider.
64
+
65
+ **Pairwise subjects.** Every client sees its own subject for one account: `profileIdOf(clientId, accountId)` (`subjects.identify`) — the very `profileId` of the account's rows of that app — the same in the id_token, userinfo and introspection, and different for every other client, so two apps cannot correlate their users. The provider configuration that produces it (pairwise-only, the sector URI, `claims()` answering the account id) is governed by `server-oidc-provider` → "Pairwise subjects".
54
66
 
55
67
  ### PK supervisor (development only)
56
68
 
@@ -62,56 +74,65 @@ Use case: deterministic end-to-end tests, and operator access to a development o
62
74
 
63
75
  Never enabled in real production — see the `supervisor-auth` skill.
64
76
 
65
- ## Core types
66
-
67
- Exported from `@owlmeans/auth`:
68
-
69
- - `Authorization` — RBAC primitive: `entitySlug?`, `scopes`, `permissions?`, `attributes?`, `permissioned?`, `denormalized?`.
70
- - `ProfilePayload` — `Authorization` plus `groups?`.
71
- - `AuthPayload` — `ProfilePayload` plus `type`, `role`, `userId`, `source?`, `profileId?`, `expiresAt?`.
72
- - `AuthCredentials` — `AuthPayload` plus `challenge`, `credential`, `publicKey?`: the challenge/response pair signed during authentication.
73
- - `Auth` — `AuthPayload` plus `token`, `isUser`, `createdAt`: the full authenticated identity a guard resolves.
74
- - `Profile` — a stored identity record: `ProfilePayload` plus `id`, `name`, `credential?`, `secret?`.
75
- - `AllowanceRequest` — partial `AuthPayload` with a required `type`, triggering challenge generation.
76
- - `AllowanceResponse` — `{ challenge }`.
77
- - `AuthToken` — `{ token }`, used in entrypoint query auth.
78
- - `PermissionSet` / `Capabilties` / `AttributeSet` — scope-bound capability shapes.
79
-
80
- **`entitySlug` is the only organization-entity value on the wire.** It is the customer
81
- organization's renameable, human-readable name; the stable `entityId` an implementation keys its
82
- rows on never appears in a token, a URL or a body. Read the slug with `entitySlugOf(payload)`
83
- (`@owlmeans/auth`) rather than off the field.
84
-
85
- ## Enums and constants
86
-
87
- `@owlmeans/auth` constants:
88
-
89
- - `AuthRole` — **string** enum: `User`, `Guest`, `Service`, `System`, `Admin`, `Superuser`, `Blocked`. Never use numeric literals for `role` fields — always use `AuthRole.User` etc.
90
- - `AuthenticationType` — how identity is proven: `BasicEd25519`, `OneTimeToken`, `ReCaptcha`, `WalletDid`, `RelyHandshake`, `WalletConsumer`, `WalletProvider`, `Google` (`'google-oauth'`), `Supervisor` (`'pk-supervisor'`).
91
- - `AuthroizationType` (sic) — how a request carries authorization: `AuthToken`, `Ed25519BasicToken`, `Ed25519BasicSignature`.
92
- - `AuthenticationStage` — the client flow's stage: `Error`, `Init`, `Allowence`, `Authenticate`, `Authentication`, `Authenticated`.
93
- - `AUTH_HEADER = 'authorization'`, `AUTH_QUERY = 'token'`, `ENTITY_QUERY = 'entitySlug'`, `PROFILE_QUERY = 'profile'`.
94
- - `DISPATCHER`, `DISPATCHER_AUTHEN`, `DISPATCHER_SURROGATE` — the return-leg and login-window entrypoint aliases.
95
-
96
- `@owlmeans/auth-common` constants:
97
-
98
- - `DEF_AUTH_SRV = 'auth'` and its alias `DEFAULT_GUARD = 'auth'`.
99
- - `GUARD_ED25519 = 'guard:ed25519-basic-signature'`.
100
- - `TOKEN_UPDATE = 'auth-token-refresh'`.
101
- - `DISPATCHER_PATH = '/dispatcher'` and `SURROGATE_PATH = '/surrogate'` — both reserved paths.
102
- - `ENTITY_RESOLVER = 'entity-resolver'` and `ENTITY_SLUG_PATTERN` — the organization-entity contract.
103
-
104
- `@owlmeans/oidc` constants:
105
-
106
- - `OIDC_GATE = 'oidc-gate'` — the gate alias to put in a protocol's `gate` option for OIDC enforcement.
107
- - `GOOGLE_CLIENT_AUTH = 'google-oauth'` — browser plugin type for Google OAuth.
108
- - `GOOGLE_SERVICE = 'google'` — provider service key used by backend config and identity linking.
109
-
110
- For apps that use OIDC/Google only as a login provider and then authorize against local identity resources, declare a product-specific gate alias instead of reusing `OIDC_GATE`.
111
-
112
- ## Errors
113
-
114
- `@owlmeans/auth` exports, root first: `AuthError` → `AuthUnknown`, `AuthorizationError` → `AuthForbidden`, `ProfileError` → `ProfileConsistencyError`, and `AuthManagerError` → `AuthManagerUnsupported`, `AuthenFailed` (→ `AuthenExists`, `AuthenPayloadError`) and `AuthPluginError` (→ `TypeMissmatchError`). Each is i18n-aware via `@owlmeans/error`.
77
+ ## The identity model
78
+
79
+ One store (`@owlmeans/server-auth-identity`) serves a deployment's own app and every app it hosts.
80
+ Its records, fields, indexes, races and events are governed by the `server-auth-identity` skill;
81
+ the protocol relies on these rules:
82
+
83
+ - **Account** — the person, ONE per e-mail; `entityId` = its personal organization. Every sign-in
84
+ method (e-mail code, Google, PK supervisor) is a **credential** on the account, never on a row.
85
+ - **Profile row** — one per (account, app, organization); `service` = the app (the deployment's own
86
+ key, or a hosted app's client id); `profileId = profileIdOf(service, accountId)` is computed, the
87
+ same on every row of one (account, app), and is the pairwise subject that app's client sees. The
88
+ PRIMARY row (in the personal organization) carries `home` and `disabled`.
89
+ - **Organization** (`OrgEntity`) — `slug` (the wire `entitySlug`, renameable), `iamKey` (frozen,
90
+ claimed as `entityKey`, server-side only) and the organization's **groups** inside the document.
91
+ - Registration anywhere creates the account, its personal organization and an owner row of the app
92
+ signing in. The address IS the identity: every caller of `ensureAccount` must have verified it.
93
+
94
+ ## Organizations and the session
95
+
96
+ Tenancy is a property of the hosted app's client (`IamClientConfig.users` / `.operators`,
97
+ `iam` skill): with neither flag every subject acts in the client's owning organization; with either,
98
+ the client asks for `ORGANIZATIONS_SCOPE` and each subject acts in organizations of its own.
99
+
100
+ - **The acting organization is session state of the relying party**, never a request parameter.
101
+ The exchange picks it, every validation re-picks it by `entityKey`, and only the switch moves it —
102
+ governed by `server-oidc-rp` → "Organizations" (claims, session record, browser-token contents,
103
+ the switch handlers).
104
+ - **The request entity** on such a relying party is `{ id: entityKey, slug, iamKey: entityKey }`,
105
+ attached by the OIDC guard; `requireEntityKey(req)` answers the `entityKey` — the tenant key a
106
+ hosted app stores its records by (`auth-common` → "The organization entity").
107
+ - **Browser**: `listOrganizations` / `switchOrganization` (`client-iam`). **Server**:
108
+ `organizationsOf` / `organizationOf` and the runtime IAM client `iamRuntime` (`server-iam`) over the
109
+ provider's runtime IAM API (`makeIamRuntimeProtocols`, `iam` skill), advertised as the discovery
110
+ field `owlmeans_iam_api`.
111
+
112
+ ## Permission kinds
113
+
114
+ What a grant binds to — nothing, an organization (`entityScoped`), resource ids (`resourceScoped`) or
115
+ both — is a property of its DEFINITION, and `defaultClass` (`none` / `user` / `member` / `owner`)
116
+ says who holds it without a grant. `hasPermission(auth, name, { scope?, resourceId?, entitySlug? })`
117
+ is fail-closed on a bound set. The model is governed by the `iam` skill ("Permission kinds",
118
+ "Default classes"); the gate that asserts it by `server-iam` ("How the gate decides").
119
+
120
+ ## Types, constants and errors
121
+
122
+ The payload chain is `Authorization` (`entitySlug?`, `scopes`, `permissions?`, …) → `ProfilePayload`
123
+ (+ `groups?`) → `AuthPayload` (+ `type`, `role`, `userId`, `profileId?`, …) → `AuthCredentials`
124
+ (+ `challenge`, `credential`) for authentication and `Auth` (+ `token`, `isUser`, `createdAt`) for a
125
+ resolved identity. **`entitySlug` is the only organization-entity value on the wire**; read it with
126
+ `entitySlugOf(payload)`, never off the field. Where each name is governed:
127
+
128
+ - types, `AuthRole` (a **string** enum), `AuthenticationType`, query/header constants, the error
129
+ hierarchy (`AuthError` root; `AuthUnknown` 400, `AuthorizationError` → `AuthForbidden`,
130
+ `AuthenFailed` …) — the `auth` skill;
131
+ - guard aliases (`DEFAULT_GUARD`, `GUARD_ED25519`), `TOKEN_UPDATE`, reserved paths, `ENTITY_RESOLVER`
132
+ — the `auth-common` skill;
133
+ - `OIDC_GATE`, the Google plugin/service names, the `permissions` / `organizations` scopes and their
134
+ refusal reasons, `IAM_API_METADATA` — the `oidc` skill. An app that uses a provider only to sign in
135
+ and authorizes against local identity declares its own gate alias (`server-oidc-rp` → Rules).
115
136
 
116
137
  ## Guard interface
117
138
 
@@ -142,10 +163,10 @@ import { TRUSTED } from '@owlmeans/config'
142
163
  const { user, key } = await trust(context, TRUSTED, context.cfg.alias ?? context.cfg.service)
143
164
  ```
144
165
 
145
- It loads the record by `name` (pass a fourth argument to match on another field) and throws
146
- `SyntaxError` when there is none.
147
-
148
- `TrustedRecord` (`@owlmeans/auth-common`) is a `ConfigRecord` with an `id`, carrying `Profile` minus `permissions` / `attributes` — in practice a `name`, a `credential` (the public key) and, for identities this deployment signs as, a `secret`. `trust()` returns a signing key pair when the record has a secret and a verify-only one otherwise. The `TRUSTED` config resource (`@owlmeans/config`) is the system's source of truth for known signing identities — the auth service, peer services, wallet providers, supervisors.
166
+ It loads the record by `name` (a fourth argument matches another field), throws `SyntaxError` when
167
+ there is none, and answers a signing key pair when the `TrustedRecord` carries a `secret`, a
168
+ verify-only one otherwise. The `TRUSTED` config resource is the source of truth for known signing
169
+ identities — the auth service, peer services, wallet providers, supervisors (`auth-common`).
149
170
 
150
171
  ## Envelope shape
151
172
 
@@ -165,20 +186,10 @@ It loads the record by `name` (pass a fourth argument to match on another field)
165
186
 
166
187
  ## Key model
167
188
 
168
- `KeyPairModel` (`@owlmeans/basic-keys`):
169
-
170
- ```ts
171
- export interface KeyPairModel {
172
- sign: (data) => Promise<string>
173
- verify: (data, signature) => Promise<boolean>
174
- export: () => string // private, "ed25519:<base64>"
175
- exportPublic: () => string // public, "ed25519:<base64>"
176
- exportAddress: () => string
177
- encrypt / decrypt / dcrpt
178
- }
179
- ```
180
-
181
- `makeKeyPairModel(input?)` (`@owlmeans/basic-keys`) accepts a `KeyPair`, an `ed25519:<base64>` string, or `undefined` for random. `fromPubKey(credential)` builds a public-only model. `packAuthCredentials(auth, extra, signer)` signs an `AuthCredentials` for the Ed25519 path.
189
+ `KeyPairModel` (`@owlmeans/basic-keys`, `basic-keys` skill) signs, verifies and exports
190
+ `ed25519:<base64>` keys; `makeKeyPairModel(input?)` builds one, `fromPubKey(credential)` a
191
+ verify-only one, and `packAuthCredentials(auth, extra, signer)` signs an `AuthCredentials` for the
192
+ Ed25519 path.
182
193
 
183
194
  ## Setup wiring
184
195
 
@@ -186,17 +197,19 @@ Server-side:
186
197
  - `makeAuthService(alias?)` / `appendAuthService(ctx, alias?)` (`@owlmeans/server-auth`) — the bearer guard.
187
198
  - `makeAuthServiceEntrypoints(serviceAlias, prefix = 'oidc-api')` (`@owlmeans/server-oidc-rp`) — returns `external-auth:provider:list` and `external-auth:auth:update` declarations, both behind `GUARD_ED25519`; bind them in the serving app.
188
199
  - `makeOidcWrappingService`, `makeOidcGate`, `makeOidcClientService`, `appendOidcGuard`, `oidcEntrypoints` — wire OIDC services and server-local bindings into a server context (`@owlmeans/server-oidc-rp`). Decorate the app protocol tree with `withOidcGuard` from `@owlmeans/oidc` before binding it.
200
+ - `appendIam(context)` (`@owlmeans/server-iam`) — the same four registrations with the IAM gate in place of `makeOidcGate()`, for an application signing in against an IAM provider.
189
201
 
190
202
  Client-side:
191
203
  - `appendAuthService(ctx, alias?)` (`@owlmeans/client-auth`) — the client auth service with persistent storage.
192
204
  - `setupExternalAuthentication(service)` (`@owlmeans/client-auth`) — point `CAUTHEN_FLOW_ENTER` at the service an external provider redirects into.
193
205
  - `appendLogin(ctx)` (`@owlmeans/client-auth/login`) — the login-plugin host; `@owlmeans/web-client`'s `makeContext` already calls it.
194
206
  - `appendOidcGuard()`, `oidcEntrypoints()` — `@owlmeans/web-oidc-rp` for browser-side bindings; `withOidcGuard` decorates the shared protocol tree.
207
+ - `appendIam(context, opts?)`, `withIamGuard`, `iamEntrypoints()` (`@owlmeans/client-iam`) — the same in one import, plus the consent-before-sign-in precondition and the organization switch.
195
208
 
196
209
  Local identity and the organization entity:
197
- - `appendAuthIdentityResources(context)` (`@owlmeans/server-auth-identity`) — registers the org-entity registry, the account/profile/credentials resources, the linking service and the entity resolver.
198
- - `AUTH_IDENTITY_LINKING` — the service that maps provider profile details onto an `AuthPayload`.
199
- - `AUTH_IDENTITY_PROFILE` — the durable authorization profile: `entityId`, `role`, `scopes`, optional expiry.
210
+ - `appendAuthIdentityResources(context, dbAlias?, { service? })` (`@owlmeans/server-auth-identity`) — registers the org-entity registry, the account/profile/credentials resources, the linking service for the deployment's own app key `service`, the entity resolver and the identity-events seam.
211
+ - `AUTH_IDENTITY_LINKING` — the service that maps provider profile details onto an `AuthPayload` of the deployment's own app.
212
+ - `AUTH_IDENTITY_PROFILE` — the profile rows: one per (account, app, organization), the record authorization reads (`role`, `scopes`, `permissions`, `groups`, optional expiry).
200
213
  - `ENTITY_RESOLVER` — turns the token's `entitySlug` (current, retired, or the frozen `iamKey`) into a stable `OrgEntityRef`. Registering it is what tells the boundary this deployment has organizations.
201
214
 
202
215
  Read identity records with `load()` or `list()`. Never use `take()` in an authorization lookup — it is delete-and-return, so it consumes the record it answers with.
@@ -217,6 +230,10 @@ resolved id and fall back to the slug where no resolver is registered. A boundar
217
230
  leaves `request.entity` empty and its handlers silently compare a slug against stored ids — which
218
231
  surfaces as "this record does not exist", not as a missing resolution.
219
232
 
233
+ A relying party of a tenanted client has no registry to resolve from: there the OIDC guard attaches
234
+ the session's acting organization itself, and `attachEntity` keeps it only while its slug is exactly
235
+ the token's (`auth-common` → "The organization entity").
236
+
220
237
  ## Mocking points (for category-B tests)
221
238
 
222
239
  The protocol exposes three natural mocking boundaries. The only allowed implementation lives in `@owlmeans/test-auth`:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@owlmeans/auth",
3
- "version": "0.1.18-rc.37",
3
+ "version": "0.1.18-rc.38",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {