@owlmeans/auth 0.1.18-rc.1 → 0.1.18-rc.11
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 +5 -5
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/auth/SKILL.md +129 -32
- package/agent-meta/skills/auth-protocol/SKILL.md +100 -45
- package/build/allowance/model.js +2 -2
- package/build/allowance/model.js.map +1 -1
- package/build/auth/model.js +2 -2
- package/build/auth/model.js.map +1 -1
- package/build/consts.d.ts +11 -1
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +12 -2
- package/build/consts.js.map +1 -1
- package/build/entity/profile.js +2 -2
- package/build/entity/profile.js.map +1 -1
- package/build/helper.d.ts +11 -1
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +10 -0
- package/build/helper.js.map +1 -1
- package/build/types.d.ts +11 -1
- package/build/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/allowance/model.ts +2 -2
- package/src/auth/model.ts +2 -2
- package/src/consts.ts +14 -2
- package/src/entity/profile.ts +2 -2
- package/src/helper.ts +13 -1
- package/src/types.ts +17 -7
- package/build/.gitkeep +0 -0
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Core authentication types, schemas, and constants for OwlMeans fullstack applica
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
bun add @owlmeans/auth
|
|
15
|
+
bun add @owlmeans/auth@^0.1.18-rc.8
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -66,9 +66,9 @@ enum AuthenticationStage { /* connection auth lifecycle */ }
|
|
|
66
66
|
- Manager API handlers use `AuthUnknown('entity')` when `request.auth?.entityId` is missing.
|
|
67
67
|
- WebSocket helpers use `Auth`, `AuthToken`, and `AuthenticationStage` to authenticate token-bearing connections.
|
|
68
68
|
- Google/OIDC login is normalized into an `AuthPayload` with `userId`, `profileId`, `entityId`, and `scopes`; the local identity store lives in `@owlmeans/server-auth-identity`.
|
|
69
|
-
- Gate denial should use `AuthForbidden`; product ownership checks should stay in
|
|
69
|
+
- Gate denial should use `AuthForbidden`; product ownership checks should stay in entrypoint gates or handlers, not in this core package.
|
|
70
70
|
|
|
71
|
-
### AJV Schemas (for
|
|
71
|
+
### AJV Schemas (for entrypoint filter definitions)
|
|
72
72
|
|
|
73
73
|
- `AuthCredentialsSchema` — validates an auth credential request body
|
|
74
74
|
- `AllowanceRequestSchema` — validates an allowance/init request body
|
|
@@ -76,7 +76,7 @@ enum AuthenticationStage { /* connection auth lifecycle */ }
|
|
|
76
76
|
|
|
77
77
|
## Related Packages
|
|
78
78
|
|
|
79
|
-
- [`@owlmeans/auth-common`](../auth-common) — auth
|
|
79
|
+
- [`@owlmeans/auth-common`](../auth-common) — auth entrypoints, guards, and middleware
|
|
80
80
|
- [`@owlmeans/server-auth`](../server-auth) — server-side auth service implementation
|
|
81
81
|
- [`@owlmeans/client-auth`](../client-auth) — client-side auth service
|
|
82
82
|
|
|
@@ -88,7 +88,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
88
88
|
your project's skill store (`.agents/skills/`):
|
|
89
89
|
|
|
90
90
|
```sh
|
|
91
|
-
npx @owlmeans/agent-skills
|
|
91
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.14
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/auth",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-
|
|
4
|
+
"version": "0.1.18-rc.11",
|
|
5
|
+
"generatedAt": "2026-09-10T23:12:07.501Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: auth
|
|
3
|
-
description: How to use @owlmeans/auth — core authentication types,
|
|
3
|
+
description: How to use @owlmeans/auth — the core authentication and authorization vocabulary shared by server and client, covering the Auth / AuthPayload / AuthCredentials types, the AuthRole and AuthenticationType enums, the error hierarchy (AuthUnknown, AuthenFailed, AuthForbidden …), the request JSON schemas, the entrypoint aliases, and entitySlugOf for reading the organization entity off a token. Auto-invoked when importing auth types, errors, schemas or constants, or when working with request authentication.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
@@ -8,58 +8,155 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/auth
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/auth": "^0.1.18-rc.
|
|
11
|
+
**Install:** `"@owlmeans/auth": "^0.1.18-rc.11"` in `dependencies`
|
|
12
|
+
|
|
13
|
+
Types, enums, errors and schemas only — no services, no wiring. Every other auth package builds on
|
|
14
|
+
this vocabulary, so a symbol belongs here exactly when both a server and a browser need to agree on
|
|
15
|
+
it.
|
|
12
16
|
|
|
13
17
|
## Key Exports
|
|
14
18
|
|
|
19
|
+
### Identity types
|
|
20
|
+
|
|
15
21
|
| Export | Description |
|
|
16
22
|
|--------|-------------|
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
+
| `Authorization` | RBAC base: `entitySlug?`, `scopes`, `permissions?`, `attributes?`, `permissioned?`, `denormalized?` |
|
|
24
|
+
| `ProfilePayload` | `Authorization` + `groups?` |
|
|
25
|
+
| `AuthPayload` | `ProfilePayload` + `type`, `role`, `userId`, `source?`, `profileId?`, `expiresAt?` |
|
|
26
|
+
| `AuthCredentials` | `AuthPayload` + `challenge`, `credential`, `publicKey?` — what a client posts to authenticate |
|
|
27
|
+
| `Auth` | `AuthPayload` + `token`, `isUser`, `createdAt` — the authenticated identity a guard resolves |
|
|
28
|
+
| `Profile` | `ProfilePayload` + `id`, `name`, `credential?`, `secret?` — a stored identity record |
|
|
29
|
+
| `Group` | `Authorization` + `id`, `name` |
|
|
30
|
+
| `AllowanceRequest` | `Partial<AuthPayload>` with a required `type` — asks for a challenge |
|
|
31
|
+
| `AllowanceResponse` | `{ challenge }` |
|
|
32
|
+
| `AuthToken` | `{ token }` — the bearer envelope on the wire |
|
|
33
|
+
| `PermissionSet` / `Capabilties` / `AttributeSet` | Scope-bound capability shapes |
|
|
34
|
+
| `RelyToken` | The rely-handshake token used by wallet/provider flows |
|
|
35
|
+
|
|
36
|
+
### Enums and constants
|
|
23
37
|
|
|
24
|
-
|
|
38
|
+
| Export | Description |
|
|
39
|
+
|--------|-------------|
|
|
40
|
+
| `AuthRole` | **String** enum: `User`, `Guest`, `Service`, `System`, `Admin`, `Superuser`, `Blocked` |
|
|
41
|
+
| `AuthenticationType` | How identity is proven: `BasicEd25519`, `OneTimeToken`, `ReCaptcha`, `WalletDid`, `RelyHandshake`, `WalletConsumer`, `WalletProvider`, `Google` (`'google-oauth'`), `Supervisor` (`'pk-supervisor'`) |
|
|
42
|
+
| `AuthroizationType` (sic) | How a request carries authorization: `AuthToken`, `Ed25519BasicToken`, `Ed25519BasicSignature` |
|
|
43
|
+
| `AuthenticationStage` | Client-side flow stage: `Error`, `Init`, `Allowence`, `Authenticate`, `Authentication`, `Authenticated` |
|
|
44
|
+
| `AUTH_HEADER` / `AUTH_QUERY` | `'authorization'` / `'token'` |
|
|
45
|
+
| `ENTITY_QUERY` / `PROFILE_QUERY` | `'entitySlug'` / `'profile'` |
|
|
46
|
+
| `ALL_SCOPES` / `AUTH_SCOPE` | `'*'` / `'__auth'` |
|
|
47
|
+
| `INCLUDE`, `EXCLUDE`, `WILDCARD`, `DELIMITER` | Permission-string grammar |
|
|
48
|
+
| `GUEST_ID`, `RELY_3RD` | Reserved ids |
|
|
49
|
+
| `AUTHEN`, `AUTHEN_INIT`, `AUTHEN_AUTHEN`, `AUTHEN_RELY` | Backend entrypoint aliases |
|
|
50
|
+
| `CAUTHEN`, `CAUTHEN_AUTHEN`, `CAUTHEN_AUTHEN_DEFAULT`, `CAUTHEN_AUTHEN_TYPED`, `CAUTHEN_FLOW_ENTER` | Front-end entrypoint aliases |
|
|
51
|
+
| `DISPATCHER`, `DISPATCHER_AUTHEN`, `DISPATCHER_SURROGATE` | Dispatcher and surrogate-window entrypoint aliases |
|
|
52
|
+
| `MOD_RECAPTCHA`, `CMOD_RECAPTCHA` | reCAPTCHA entrypoint aliases |
|
|
53
|
+
|
|
54
|
+
### Errors
|
|
55
|
+
|
|
56
|
+
`AuthError` is the root; everything below is a subclass and every class is i18n-aware through
|
|
57
|
+
`@owlmeans/error`.
|
|
58
|
+
|
|
59
|
+
| Error | Raise it when |
|
|
60
|
+
|-------|---------------|
|
|
61
|
+
| `AuthUnknown` | The thing being authenticated is not known at all — an unregistered plugin type, a request whose auth state is missing |
|
|
62
|
+
| `AuthManagerError` | The auth manager itself failed |
|
|
63
|
+
| `AuthManagerUnsupported` | The manager cannot serve this request shape |
|
|
64
|
+
| `AuthenFailed` | Authentication was attempted and rejected (bad challenge, bad code, bad signature) |
|
|
65
|
+
| `AuthenExists` | The identity being registered already exists |
|
|
66
|
+
| `AuthenPayloadError` | A required credential field is missing |
|
|
67
|
+
| `AuthPluginError` / `TypeMissmatchError` | A plugin misbehaved / was handed the wrong type |
|
|
68
|
+
| `AuthorizationError` | Authenticated, but the request carries no usable authorization |
|
|
69
|
+
| `AuthForbidden` | Authenticated and understood — and not allowed |
|
|
70
|
+
| `ProfileError` / `ProfileConsistencyError` | A profile is missing or internally inconsistent |
|
|
71
|
+
|
|
72
|
+
### Schemas and helpers
|
|
25
73
|
|
|
26
|
-
|
|
74
|
+
| Export | Description |
|
|
75
|
+
|--------|-------------|
|
|
76
|
+
| `AuthorizationSchema`, `ProfilePayloadSchema`, `AuthPayloadSchema` | Payload validation; `AuthPayloadSchema.required` is `['scopes', 'role', 'type']` |
|
|
77
|
+
| `PartialAuthPayloadSchema`, `AllowanceRequestSchema` | The `/authentication/init` body |
|
|
78
|
+
| `AuthCredentialsSchema` | The `/authentication/authenticate` body — spreads `AuthPayloadSchema.required`, so `type`, `role` and `scopes` are mandatory on every authenticate call |
|
|
79
|
+
| `AuthSchema`, `AuthTokenSchema`, `OptionalAuthTokenSchema` | Resolved auth and bearer-token bodies |
|
|
80
|
+
| `ProfileSchema`, `RelyChallengeSchema`, `PermissionSetSchema`, `AttributeSetSchema`, `CapabiltiesSchema` | Record and permission schemas |
|
|
81
|
+
| `ScopeValueSchema`, `PermissionValueSchema`, `ResourceValueSchema`, `AttributeValueSchema`, `EntitySlugValueSchema`, `GroupValueSchema`, `TypeNameSchema`, `EnumValueSchema`, `IdValueSchema`, `DateSchema`, `AuthRoleSchema` | Reusable scalar schemas |
|
|
82
|
+
| `entitySlugOf(payload)` | The organization entity carried by an auth payload — its `entitySlug`, falling back to an `entityId` the payload may carry instead — see below |
|
|
83
|
+
| `verifyAuth`, `verifyAuthCredentials` | Validate against `AuthSchema` / `AuthCredentialsSchema` |
|
|
84
|
+
| `isAuth`, `isAuthCredentials`, `isAuthToken` | Type guards |
|
|
85
|
+
| `buildSupervisorPayload`, `SupervisorCredentialPayload` | The payload the PK supervisor login signs — see the `supervisor-auth` skill |
|
|
86
|
+
|
|
87
|
+
`AuthTokenSchema` caps `token` at 1024 characters. A route that accepts a token wrapping a full
|
|
88
|
+
credential envelope needs its own wider schema.
|
|
89
|
+
|
|
90
|
+
## The organization entity on a token
|
|
91
|
+
|
|
92
|
+
`entitySlug` is the organization-entity value this package declares: `Authorization.entitySlug`,
|
|
93
|
+
the renameable, human-readable name of the customer organization, and what travels in tokens, URLs,
|
|
94
|
+
query params and request bodies. No `entityId` is declared on any type here — the stable record id
|
|
95
|
+
an implementation stores its rows against belongs to whichever package owns the organization
|
|
96
|
+
registry, and is resolved from the slug at the server boundary.
|
|
97
|
+
|
|
98
|
+
Read the value through `entitySlugOf()` rather than off the field. A token is signed once and then
|
|
99
|
+
read for as long as it lives, across deployments, and the helper absorbs that spread: when
|
|
100
|
+
`entitySlug` is absent it returns an `entityId` the payload carries instead, so a payload that names
|
|
101
|
+
the organization under either field resolves through one code path. That fallback is why the helper
|
|
102
|
+
is the only supported way to get the value out of a payload:
|
|
27
103
|
|
|
28
104
|
```typescript
|
|
29
|
-
import {
|
|
30
|
-
import { handleRequest } from '@owlmeans/server-app'
|
|
105
|
+
import { entitySlugOf } from '@owlmeans/auth'
|
|
31
106
|
|
|
32
|
-
|
|
33
|
-
if (req.auth?.entityId == null) throw new AuthUnknown('entity')
|
|
34
|
-
return await (context as Context).project().list({ entityId: req.auth.entityId })
|
|
35
|
-
})
|
|
107
|
+
const slug = entitySlugOf(req.auth) // string | undefined
|
|
36
108
|
```
|
|
37
109
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- Authorization failures in gates should use `AuthForbidden`, while missing handler auth/entity state usually uses `AuthUnknown`.
|
|
44
|
-
- Keep product ownership rules outside `@owlmeans/auth`; downstream apps compose `@owlmeans/entrypoint` gates or handler-level entity checks around these core types.
|
|
110
|
+
Because of that fallback the result is not guaranteed to be a slug: a payload carrying only
|
|
111
|
+
`entityId` yields that id. Treat it as an opaque organization key, never as a name to compose from
|
|
112
|
+
and never as a database key written directly — `@owlmeans/auth-common` exports `entityKeyOf` /
|
|
113
|
+
`requireEntityKey` for storage keys, and they prefer the resolved id; a user-facing name wants the
|
|
114
|
+
resolved entity's current slug.
|
|
45
115
|
|
|
46
|
-
## AuthRole enum
|
|
116
|
+
## AuthRole is a string enum
|
|
47
117
|
|
|
48
|
-
|
|
118
|
+
Always use the members; a numeric literal does not compile.
|
|
49
119
|
|
|
50
120
|
```typescript
|
|
51
121
|
import { AuthRole } from '@owlmeans/auth'
|
|
122
|
+
import type { AuthCredentials } from '@owlmeans/auth'
|
|
52
123
|
|
|
53
|
-
|
|
54
|
-
|
|
124
|
+
const creds: AuthCredentials = { role: AuthRole.User, /* … */ } as AuthCredentials
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Usage
|
|
55
128
|
|
|
56
|
-
|
|
57
|
-
|
|
129
|
+
Throw from a handler when the request is missing the identity it needs:
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
import { AuthUnknown, entitySlugOf } from '@owlmeans/auth'
|
|
133
|
+
import { handleRequest } from '@owlmeans/server-app'
|
|
134
|
+
|
|
135
|
+
export const list = handleRequest(async (req, context) => {
|
|
136
|
+
const slug = entitySlugOf(req.auth)
|
|
137
|
+
if (slug == null) throw new AuthUnknown('entity')
|
|
138
|
+
|
|
139
|
+
return await listProjects(context, slug)
|
|
140
|
+
})
|
|
58
141
|
```
|
|
59
142
|
|
|
60
|
-
|
|
143
|
+
Rules of thumb:
|
|
144
|
+
|
|
145
|
+
- A gate that decides "not allowed" throws `AuthForbidden`; a handler that finds no identity to act
|
|
146
|
+
on throws `AuthUnknown`; a failed credential check throws `AuthenFailed`.
|
|
147
|
+
- Keep ownership rules out of this package. Downstream apps compose `@owlmeans/entrypoint` gates or
|
|
148
|
+
handler-level checks around these types.
|
|
149
|
+
- WebSocket wiring uses `Auth`, `AuthToken` and `AuthenticationStage` to move a token-bearing
|
|
150
|
+
connection into an authenticated state.
|
|
151
|
+
- A provider login (Google/OIDC, OTP, supervisor) ultimately produces an ordinary `AuthPayload` with
|
|
152
|
+
`userId`, `profileId`, `entitySlug` and `scopes`; `@owlmeans/server-auth-identity` stores the local
|
|
153
|
+
identity behind it and returns that payload.
|
|
61
154
|
|
|
62
155
|
## Depends On
|
|
63
156
|
|
|
64
|
-
- `@owlmeans/error` —
|
|
65
|
-
|
|
157
|
+
- `@owlmeans/error` — every error class extends `ResilientError`, which is what makes the messages
|
|
158
|
+
translatable and re-throwable across the wire
|
|
159
|
+
- `ajv-formats` — date/time formats for the `verify*` helpers
|
|
160
|
+
- `ajv` — a **peer** dependency (`"*"`), not a direct one: `verifyAuth` / `verifyAuthCredentials`
|
|
161
|
+
construct `new Ajv({ strict: false })`. Install it alongside this package, or those two helpers
|
|
162
|
+
fail to resolve.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: auth-protocol
|
|
3
|
-
description: Comprehensive reference for the OwlMeans authentication and authorization protocol — Ed25519
|
|
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.
|
|
4
4
|
---
|
|
5
5
|
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
6
6
|
|
|
@@ -18,18 +18,21 @@ Use case: service-to-service, wallet provider, backend clients, high-security br
|
|
|
18
18
|
|
|
19
19
|
1. **Allowance**: client posts `AllowanceRequest` (a partial `AuthPayload`) to `/authentication/init`. Server returns `AllowanceResponse { challenge }`.
|
|
20
20
|
2. **Credential generation**: client builds `AuthCredentials` (challenge + ephemeral payload), signs the canonicalized payload with its Ed25519 keypair via `packAuthCredentials()` (`@owlmeans/basic-keys`), posts to `/authentication/authenticate`.
|
|
21
|
-
3. **
|
|
22
|
-
4. **
|
|
23
|
-
5. **
|
|
21
|
+
3. **Credential envelope**: the auth manager opens the signed challenge with the `AUTH_SRV_KEY` record it loads from the `TRUSTED` config resource via `trust()` (`@owlmeans/auth-common/utils`), burns the decoded challenge into `AUTH_CACHE` (create-once, so one challenge is spent once), then hands the credential to the plugin for its type. The basic-ed25519 plugin loads the caller's own `TRUSTED` record by `userId` and verifies the signature over the challenge, then rewrites the credential's `type` to `AuthenticationType.OneTimeToken` with a fresh one-time token as its challenge. The manager canonicalizes `entitySlug` through `ENTITY_RESOLVER` where one is registered, stamps its own trusted id onto `credential.credential`, and answers with an `EnvelopeModel<AuthCredentials>` of the credential's own type, signed with `AUTH_SRV_KEY`.
|
|
22
|
+
4. **Token exchange**: the client posts that envelope as an `AuthToken` to the consuming service's `DISPATCHER_AUTHEN` entrypoint (`/authenticate`). `makeAuthService.authenticate()` (`@owlmeans/server-auth`) verifies it against `AUTH_SRV_KEY`, burns the one-time token into its own `AUTH_CACHE`, checks that `credential.credential` names the auth manager, builds the `Auth` from the credential's `userId` / `scopes` / `role` / `profileId` / `entitySlug`, and returns it as an envelope of type `ed25519-basic-token` signed with that service's own key.
|
|
23
|
+
5. **Bearer**: client sends `Authorization: ED25519-BASIC-TOKEN <encoded>`.
|
|
24
|
+
6. **Server verification**: incoming requests hit `makeAuthService` (`@owlmeans/server-auth`), whose `match` looks for the `ED25519-BASIC-TOKEN` bearer, whose `handle` verifies the envelope against the service key and resolves the carried `Auth` into the response, and whose `unpack(token)` returns the same `Auth` outside a request.
|
|
25
|
+
|
|
26
|
+
`makeBasicEd25519Guard` (`@owlmeans/auth-common`) is a **different** mechanism on the same key material: it matches `ED25519-BASIC-SIGNATURE`, where the caller signs body + timestamp/nonce headers per request instead of presenting a bearer. See the `auth-common` skill.
|
|
24
27
|
|
|
25
28
|
### OIDC (delegated)
|
|
26
29
|
|
|
27
30
|
Use case: browser clients, third-party IdP integration, multi-tenant SaaS.
|
|
28
31
|
|
|
29
|
-
1. Standard OAuth2 code flow
|
|
30
|
-
2. Server
|
|
31
|
-
3. Subsequent requests
|
|
32
|
-
4. Refresh: `
|
|
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>`.
|
|
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` entrypoint that `setupAuthServiceEntrypoints` registers at `/<prefix>/auth/update`.
|
|
33
36
|
|
|
34
37
|
### Provider-Backed Local Identity
|
|
35
38
|
|
|
@@ -38,40 +41,69 @@ Use case: apps such as `product-viable` that use Google/OIDC as login bootstrap
|
|
|
38
41
|
1. Browser imports `@owlmeans/web-oidc-rp/auth/plugins`, which registers OIDC and Google plugins in `@owlmeans/client-auth`.
|
|
39
42
|
2. The plugin persists auth control state, redirects to the provider, restores state on return, and submits code/query params as `AuthCredentials`.
|
|
40
43
|
3. Server exchanges the provider code through `@owlmeans/server-oidc-rp` and maps `ProviderProfileDetails` through `@owlmeans/server-auth-identity`.
|
|
41
|
-
4. `AUTH_IDENTITY_ACCOUNT`, `AUTH_IDENTITY_PROFILE
|
|
42
|
-
5. Server returns a normal OwlMeans bearer token
|
|
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`.
|
|
46
|
+
|
|
47
|
+
### Email one-time code
|
|
48
|
+
|
|
49
|
+
Use case: passwordless sign-in where no external IdP is wanted.
|
|
50
|
+
|
|
51
|
+
1. Client posts `{ type: 'email-otp', userId: <email> }` to `/authentication/init`.
|
|
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.
|
|
54
|
+
|
|
55
|
+
### PK supervisor (development only)
|
|
56
|
+
|
|
57
|
+
Use case: deterministic end-to-end tests, and operator access to a development or stage environment.
|
|
58
|
+
|
|
59
|
+
1. Client posts `{ type: 'pk-supervisor', userId }` to `/authentication/init`, receiving a single-use challenge.
|
|
60
|
+
2. It signs `buildSupervisorPayload(challenge, userId, salt)` (`@owlmeans/auth`) with one of the project's TRUSTED private keys and posts `{ salt, signature }` as the credential.
|
|
61
|
+
3. The server plugin verifies the signature against the allowlisted TRUSTED records, resolves or registers the target user, and the ordinary envelope exchange finishes the flow.
|
|
62
|
+
|
|
63
|
+
Never enabled in real production — see the `supervisor-auth` skill.
|
|
43
64
|
|
|
44
65
|
## Core types
|
|
45
66
|
|
|
46
67
|
Exported from `@owlmeans/auth`:
|
|
47
68
|
|
|
48
|
-
- `
|
|
49
|
-
- `
|
|
50
|
-
- `
|
|
51
|
-
- `
|
|
52
|
-
- `
|
|
53
|
-
- `
|
|
54
|
-
- `
|
|
55
|
-
- `
|
|
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.
|
|
56
84
|
|
|
57
85
|
## Enums and constants
|
|
58
86
|
|
|
59
87
|
`@owlmeans/auth` constants:
|
|
60
88
|
|
|
61
89
|
- `AuthRole` — **string** enum: `User`, `Guest`, `Service`, `System`, `Admin`, `Superuser`, `Blocked`. Never use numeric literals for `role` fields — always use `AuthRole.User` etc.
|
|
62
|
-
- `AuthenticationType` — `BasicEd25519`, `OneTimeToken`, `ReCaptcha`, `WalletDid`, `RelyHandshake`, `WalletConsumer`, `WalletProvider
|
|
63
|
-
- `AuthroizationType` (sic) — `AuthToken`, `Ed25519BasicToken`, `Ed25519BasicSignature`.
|
|
64
|
-
- `
|
|
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.
|
|
65
95
|
|
|
66
96
|
`@owlmeans/auth-common` constants:
|
|
67
97
|
|
|
68
98
|
- `DEF_AUTH_SRV = 'auth'` and its alias `DEFAULT_GUARD = 'auth'`.
|
|
99
|
+
- `GUARD_ED25519 = 'guard:ed25519-basic-signature'`.
|
|
69
100
|
- `TOKEN_UPDATE = 'auth-token-refresh'`.
|
|
70
|
-
- `DISPATCHER_PATH = '/dispatcher'
|
|
101
|
+
- `DISPATCHER_PATH = '/dispatcher'` and `SURROGATE_PATH = '/surrogate'` — both reserved paths.
|
|
102
|
+
- `ENTITY_RESOLVER = 'entity-resolver'` and `ENTITY_SLUG_PATTERN` — the organization-entity contract.
|
|
71
103
|
|
|
72
104
|
`@owlmeans/oidc` constants:
|
|
73
105
|
|
|
74
|
-
- `OIDC_GATE = 'oidc-gate'` — the `gate(...)` value to attach OIDC enforcement to
|
|
106
|
+
- `OIDC_GATE = 'oidc-gate'` — the `gate(...)` value to attach OIDC enforcement to an entrypoint.
|
|
75
107
|
- `GOOGLE_CLIENT_AUTH = 'google-oauth'` — browser plugin type for Google OAuth.
|
|
76
108
|
- `GOOGLE_SERVICE = 'google'` — provider service key used by backend config and identity linking.
|
|
77
109
|
|
|
@@ -79,7 +111,7 @@ For apps that use OIDC/Google only as a login provider and then authorize agains
|
|
|
79
111
|
|
|
80
112
|
## Errors
|
|
81
113
|
|
|
82
|
-
`@owlmeans/auth` exports: `AuthError
|
|
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`.
|
|
83
115
|
|
|
84
116
|
## Guard interface
|
|
85
117
|
|
|
@@ -100,16 +132,20 @@ Guards are services registered on the context under their alias (`DEFAULT_GUARD`
|
|
|
100
132
|
|
|
101
133
|
## Trust resource
|
|
102
134
|
|
|
103
|
-
`trust()`
|
|
135
|
+
`trust()` lives on the `@owlmeans/auth-common/utils` subpath, not the package root:
|
|
104
136
|
|
|
105
137
|
```ts
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
138
|
+
import { trust } from '@owlmeans/auth-common/utils'
|
|
139
|
+
import { TRUSTED } from '@owlmeans/config'
|
|
140
|
+
|
|
141
|
+
// { user: TrustedRecord, key: KeyPairModel }
|
|
142
|
+
const { user, key } = await trust(context, TRUSTED, context.cfg.alias ?? context.cfg.service)
|
|
110
143
|
```
|
|
111
144
|
|
|
112
|
-
|
|
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.
|
|
113
149
|
|
|
114
150
|
## Envelope shape
|
|
115
151
|
|
|
@@ -147,21 +183,39 @@ export interface KeyPairModel {
|
|
|
147
183
|
## Setup wiring
|
|
148
184
|
|
|
149
185
|
Server-side:
|
|
150
|
-
- `
|
|
151
|
-
- `
|
|
152
|
-
- `makeOidcWrappingService`, `makeOidcGate` — wire OIDC into a server context (`@owlmeans/server-oidc-rp`).
|
|
186
|
+
- `makeAuthService(alias?)` / `appendAuthService(ctx, alias?)` (`@owlmeans/server-auth`) — the bearer guard.
|
|
187
|
+
- `setupAuthServiceEntrypoints(entrypoints, serviceAlias, prefix = 'oidc-api')` (`@owlmeans/server-oidc-rp`) — registers the `external-auth:provider:list` and `external-auth:auth:update` routes, both behind `GUARD_ED25519`.
|
|
188
|
+
- `makeOidcWrappingService`, `makeOidcGate`, `makeOidcClientService`, `appendOidcGuard`, `setupOidcGuard` — wire OIDC into a server context (`@owlmeans/server-oidc-rp`).
|
|
153
189
|
|
|
154
190
|
Client-side:
|
|
155
|
-
- `
|
|
156
|
-
- `
|
|
191
|
+
- `appendAuthService(ctx, alias?)` (`@owlmeans/client-auth`) — the client auth service with persistent storage.
|
|
192
|
+
- `setupExternalAuthentication(service)` (`@owlmeans/client-auth`) — point `CAUTHEN_FLOW_ENTER` at the service an external provider redirects into.
|
|
193
|
+
- `appendLogin(ctx)` (`@owlmeans/client-auth/login`) — the login-plugin host; `@owlmeans/web-client`'s `makeContext` already calls it.
|
|
157
194
|
- `appendOidcGuard()`, `setupOidcGuard()` — `@owlmeans/web-oidc-rp` for browser-side.
|
|
158
195
|
|
|
159
|
-
Local identity:
|
|
160
|
-
- `appendAuthIdentityResources(context)` — registers
|
|
161
|
-
- `AUTH_IDENTITY_LINKING` — service that maps provider profile details
|
|
162
|
-
- `AUTH_IDENTITY_PROFILE` — durable authorization profile
|
|
196
|
+
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.
|
|
200
|
+
- `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
|
+
|
|
202
|
+
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.
|
|
203
|
+
|
|
204
|
+
## Entity resolution is part of the protocol
|
|
205
|
+
|
|
206
|
+
Two places resolve the organization entity, and both are required:
|
|
207
|
+
|
|
208
|
+
1. **At the auth manager**, before the credential envelope is signed. Whatever slug a plugin left on
|
|
209
|
+
`credential.entitySlug` is resolved and rewritten to the current one, so a token is canonical for
|
|
210
|
+
as long as it lives. An unresolvable value throws `AuthenFailed('entity')`.
|
|
211
|
+
2. **At every server boundary that establishes authentication** — the HTTP boundary, and any socket
|
|
212
|
+
that authenticates after its connection is open — via `attachEntity(context, request)`
|
|
213
|
+
(`@owlmeans/auth-common`), which sets `request.entity` and canonicalizes a retired slug.
|
|
163
214
|
|
|
164
|
-
|
|
215
|
+
Handlers then key their records on `entityKeyOf(req)` / `requireEntityKey(req)`, which prefer the
|
|
216
|
+
resolved id and fall back to the slug where no resolver is registered. A boundary that skips step 2
|
|
217
|
+
leaves `request.entity` empty and its handlers silently compare a slug against stored ids — which
|
|
218
|
+
surfaces as "this record does not exist", not as a missing resolution.
|
|
165
219
|
|
|
166
220
|
## Mocking points (for category-B tests)
|
|
167
221
|
|
|
@@ -177,8 +231,9 @@ The protocol does **not** ship a fake JWKS server. For OIDC-end-to-end tests, ex
|
|
|
177
231
|
|
|
178
232
|
The OIDC packages wrap four upstream libraries. **No upstream type from those libraries is re-exported** through any `@owlmeans/*` package's public index. All public contracts use OwlMeans-owned types; the mapping layer is confined to each package's `src/service.ts`.
|
|
179
233
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
- `
|
|
183
|
-
- `
|
|
184
|
-
- `
|
|
234
|
+
Each is pinned to an exact version, and [[oidc-versions]] owns those numbers plus the upgrade
|
|
235
|
+
checklist — read them there rather than duplicating them here:
|
|
236
|
+
- `oidc-provider` — in `@owlmeans/server-oidc-provider`
|
|
237
|
+
- `jose` — in `@owlmeans/server-oidc-provider` and `@owlmeans/server-oidc-rp`
|
|
238
|
+
- `openid-client` — in `@owlmeans/server-oidc-rp`
|
|
239
|
+
- `oidc-client-ts` — in `@owlmeans/web-oidc-rp` and `@owlmeans/mui-oidc-rp`
|
package/build/allowance/model.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthRoleSchema,
|
|
1
|
+
import { AuthRoleSchema, EntitySlugValueSchema, GroupValueSchema, IdValueSchema, DateSchema, ScopeValueSchema, TypeNameSchema } from '../consts.js';
|
|
2
2
|
import { AuthPayloadSchema } from '../auth/model.js';
|
|
3
3
|
import { AttributeSetSchema, PermissionSetSchema } from '../permission/model.js';
|
|
4
4
|
export const PartialAuthPayloadSchema = {
|
|
@@ -10,7 +10,7 @@ export const PartialAuthPayloadSchema = {
|
|
|
10
10
|
profileId: { ...IdValueSchema, nullable: true },
|
|
11
11
|
expiresAt: { ...DateSchema, nullable: true },
|
|
12
12
|
groups: { type: 'array', items: GroupValueSchema, nullable: true },
|
|
13
|
-
|
|
13
|
+
entitySlug: { ...EntitySlugValueSchema, nullable: true },
|
|
14
14
|
scopes: { type: 'array', items: ScopeValueSchema, nullable: true },
|
|
15
15
|
permissions: { type: 'array', nullable: true, items: PermissionSetSchema },
|
|
16
16
|
attributes: { type: 'array', nullable: true, items: AttributeSetSchema },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/allowance/model.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/allowance/model.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,aAAa,EAAE,UAAU,EAClF,gBAAgB,EAAE,cAAc,EACjC,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,iBAAiB,EAAE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EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ;KACzD;IACD,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
|
package/build/auth/model.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EntitySlugValueSchema, EnumValueSchema, GroupValueSchema, IdValueSchema, DateSchema, ScopeValueSchema, TypeNameSchema } from '../consts.js';
|
|
2
2
|
import { AttributeSetSchema, PermissionSetSchema } from '../permission/model.js';
|
|
3
3
|
export const AuthorizationSchema = {
|
|
4
4
|
type: 'object',
|
|
5
5
|
properties: {
|
|
6
|
-
|
|
6
|
+
entitySlug: { ...EntitySlugValueSchema, nullable: true },
|
|
7
7
|
scopes: { type: 'array', items: ScopeValueSchema },
|
|
8
8
|
permissions: { type: 'array', nullable: true, items: PermissionSetSchema },
|
|
9
9
|
attributes: { type: 'array', nullable: true, items: AttributeSetSchema },
|
package/build/auth/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/auth/model.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../src/auth/model.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EACrG,cAAc,EACf,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAEhF,MAAM,CAAC,MAAM,mBAAmB,GAAkC;IAChE,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,UAAU,EAAE,EAAE,GAAG,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxD,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE;QAClD,WAAW,EAAE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Q,EAAE,MAAM,EAAE,MAAM,CAAC;IACpC,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAA8B;IACxD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;KAC1D;IACD,QAAQ,EAAE,CAAC,OAAO,CAAC;IACnB,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAuC;IACzE,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC1E;IACD,QAAQ,EAAE,EAAE;IACZ,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
|
package/build/consts.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export declare const ScopeValueSchema: JSONSchemaType<string>;
|
|
|
50
50
|
export declare const PermissionValueSchema: JSONSchemaType<string>;
|
|
51
51
|
export declare const ResourceValueSchema: JSONSchemaType<string>;
|
|
52
52
|
export declare const AttributeValueSchema: JSONSchemaType<string>;
|
|
53
|
+
export declare const EntitySlugValueSchema: JSONSchemaType<string>;
|
|
54
|
+
/** @deprecated The organization value on the wire is a slug — use {@link EntitySlugValueSchema}. */
|
|
53
55
|
export declare const EntityValueSchema: JSONSchemaType<string>;
|
|
54
56
|
export declare const GroupValueSchema: JSONSchemaType<string>;
|
|
55
57
|
export declare const TypeNameSchema: JSONSchemaType<string>;
|
|
@@ -59,10 +61,18 @@ export declare const DateSchema: JSONSchemaType<Date>;
|
|
|
59
61
|
export declare const AuthRoleSchema: JSONSchemaType<AuthRole>;
|
|
60
62
|
export declare const DISPATCHER = "dispatcher";
|
|
61
63
|
export declare const DISPATCHER_AUTHEN = "dispatcher:authentication";
|
|
64
|
+
/**
|
|
65
|
+
* The login window opened one level up by an application that cannot complete the flow where it is.
|
|
66
|
+
*
|
|
67
|
+
* A separate entrypoint from {@link DISPATCHER} because it is never a `redirect_uri` — the provider
|
|
68
|
+
* always returns to the dispatcher, whatever page opened the window — and because a logout has to
|
|
69
|
+
* run somewhere that does not start the authorization machine.
|
|
70
|
+
*/
|
|
71
|
+
export declare const DISPATCHER_SURROGATE = "dispatcher:surrogate";
|
|
62
72
|
export declare const AUTHEN_RELY = "authentication-rely";
|
|
63
73
|
export declare const AUTH_HEADER = "authorization";
|
|
64
74
|
export declare const AUTH_QUERY = "token";
|
|
65
|
-
export declare const ENTITY_QUERY = "
|
|
75
|
+
export declare const ENTITY_QUERY = "entitySlug";
|
|
66
76
|
export declare const PROFILE_QUERY = "profile";
|
|
67
77
|
export declare const MOD_RECAPTCHA = "_external:re-captcha";
|
|
68
78
|
export declare const CMOD_RECAPTCHA: string;
|
package/build/consts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAEzC,eAAO,MAAM,OAAO,MAAM,CAAA;AAC1B,eAAO,MAAM,OAAO,MAAM,CAAA;AAC1B,eAAO,MAAM,QAAQ,MAAM,CAAA;AAC3B,eAAO,MAAM,SAAS,MAAM,CAAA;AAE5B,eAAO,MAAM,UAAU,MAAM,CAAA;AAC7B,eAAO,MAAM,UAAU,WAAW,CAAA;AAElC,oBAAY,QAAQ;IAClB,IAAI,SAAS;IACb,KAAK,UAAU;IACf,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,OAAO,YAAY;CACpB;AAED,oBAAY,kBAAkB;IAC5B,YAAY,kBAAkB;IAC9B,YAAY,mBAAmB;IAC/B,SAAS,eAAe;IAQx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cAAc,CAAC,MAAM,CAAoD,CAAA;AAE5G,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,MAAM,CAAoD,CAAA;AAE7G,oGAAoG;AACpG,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,MAAM,CAAyB,CAAA;AAE9E,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,MAAM,CAAoD,CAAA;AAExG,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,MAAM,CAAmD,CAAA;AAErG,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,MAAM,CAAmD,CAAA;AAEtG,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,MAAM,CAAoD,CAAA;AAErG,eAAO,MAAM,UAAU,EAAE,cAAc,CAAC,IAAI,CAA8E,CAAA;AAE1H,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,QAAQ,CAAqD,CAAA;AAEzG,eAAO,MAAM,UAAU,eAAe,CAAA;AACtC,eAAO,MAAM,iBAAiB,8BAAiC,CAAA;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,yBAA4B,CAAA;AAE7D,eAAO,MAAM,WAAW,wBAAmB,CAAA;AAE3C,eAAO,MAAM,WAAW,kBAAkB,CAAA;AAC1C,eAAO,MAAM,UAAU,UAAU,CAAA;AACjC,eAAO,MAAM,YAAY,eAAe,CAAA;AACxC,eAAO,MAAM,aAAa,YAAY,CAAA;AAEtC,eAAO,MAAM,aAAa,yBAAyB,CAAA;AACnD,eAAO,MAAM,cAAc,QAAsC,CAAA;AAEjE,eAAO,MAAM,QAAQ,YAAY,CAAA;AACjC,eAAO,MAAM,QAAQ,SAAS,CAAA"}
|
package/build/consts.js
CHANGED
|
@@ -87,7 +87,9 @@ export const ScopeValueSchema = { type: 'string', minLength: 1, maxLength: 32 };
|
|
|
87
87
|
export const PermissionValueSchema = { type: 'string', minLength: 8, maxLength: 128 };
|
|
88
88
|
export const ResourceValueSchema = { type: 'string', minLength: 8, maxLength: 128 };
|
|
89
89
|
export const AttributeValueSchema = { type: 'string', minLength: 8, maxLength: 128 };
|
|
90
|
-
export const
|
|
90
|
+
export const EntitySlugValueSchema = { type: 'string', minLength: 3, maxLength: 256 };
|
|
91
|
+
/** @deprecated The organization value on the wire is a slug — use {@link EntitySlugValueSchema}. */
|
|
92
|
+
export const EntityValueSchema = EntitySlugValueSchema;
|
|
91
93
|
export const GroupValueSchema = { type: 'string', minLength: 1, maxLength: 128 };
|
|
92
94
|
export const TypeNameSchema = { type: 'string', minLength: 1, maxLength: 64 };
|
|
93
95
|
export const EnumValueSchema = { type: 'string', minLength: 1, maxLength: 32 };
|
|
@@ -96,10 +98,18 @@ export const DateSchema = { type: 'object', format: 'date-time' };
|
|
|
96
98
|
export const AuthRoleSchema = { type: 'string', enum: Object.values(AuthRole) };
|
|
97
99
|
export const DISPATCHER = 'dispatcher';
|
|
98
100
|
export const DISPATCHER_AUTHEN = `${DISPATCHER}:authentication`;
|
|
101
|
+
/**
|
|
102
|
+
* The login window opened one level up by an application that cannot complete the flow where it is.
|
|
103
|
+
*
|
|
104
|
+
* A separate entrypoint from {@link DISPATCHER} because it is never a `redirect_uri` — the provider
|
|
105
|
+
* always returns to the dispatcher, whatever page opened the window — and because a logout has to
|
|
106
|
+
* run somewhere that does not start the authorization machine.
|
|
107
|
+
*/
|
|
108
|
+
export const DISPATCHER_SURROGATE = `${DISPATCHER}:surrogate`;
|
|
99
109
|
export const AUTHEN_RELY = `${AUTHEN}-rely`;
|
|
100
110
|
export const AUTH_HEADER = 'authorization';
|
|
101
111
|
export const AUTH_QUERY = 'token';
|
|
102
|
-
export const ENTITY_QUERY = '
|
|
112
|
+
export const ENTITY_QUERY = 'entitySlug';
|
|
103
113
|
export const PROFILE_QUERY = 'profile';
|
|
104
114
|
export const MOD_RECAPTCHA = '_external:re-captcha';
|
|
105
115
|
export const CMOD_RECAPTCHA = `_client-${MOD_RECAPTCHA.slice(1)}`;
|
package/build/consts.js.map
CHANGED
|
@@ -1 +1 @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AAa,GAA2B,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE,CAAA;AAErG,MAAM,CAAC,MAAM,UAAU,GAAyB,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAqC,CAAA;AAE1H,MAAM,CAAC,MAAM,cAAc,GAA6B,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAA;AAEzG,MAAM,CAAC,MAAM,UAAU,GAAG,YAAY,CAAA;AACtC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,UAAU,iBAAiB,CAAA;AAE/D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,UAAU,YAAY,CAAA;AAE7D,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,MAAM,OAAO,CAAA;AAE3C,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAA;AAC1C,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAA;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,YAAY,CAAA;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAA;AAEtC,MAAM,CAAC,MAAM,aAAa,GAAG,sBAAsB,CAAA;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;AAEjE,MAAM,CAAC,MAAM,QAAQ,GAAG,SAAS,CAAA;AACjC,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAA"}
|
package/build/entity/profile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EntitySlugValueSchema, IdValueSchema } from '../consts.js';
|
|
2
2
|
import { PermissionSetSchema, AttributeSetSchema } from '../permission/model.js';
|
|
3
3
|
export const ProfileSchema = {
|
|
4
4
|
type: 'object',
|
|
@@ -8,7 +8,7 @@ export const ProfileSchema = {
|
|
|
8
8
|
credential: { type: 'string', nullable: true },
|
|
9
9
|
secret: { type: 'string', nullable: true },
|
|
10
10
|
groups: { type: 'array', items: { type: 'string' }, nullable: true },
|
|
11
|
-
|
|
11
|
+
entitySlug: { ...EntitySlugValueSchema, nullable: true },
|
|
12
12
|
scopes: { type: 'array', items: { type: 'string' } },
|
|
13
13
|
permissions: { type: 'array', items: PermissionSetSchema, nullable: true },
|
|
14
14
|
attributes: { type: 'array', items: AttributeSetSchema, nullable: true },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/entity/profile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/entity/profile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACnE,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAEhF,MAAM,CAAC,MAAM,aAAa,GAA4B;IACpD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,EAAE,EAAE,aAAa;QACjB,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG,EAAE;QACtD,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC9C,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1C,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;QACpE,UAAU,EAAE,EAAC,GAAG,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAC;QACtD,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;QACpD,WAAW,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC1E,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxE,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;QACjD,YAAY,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE;KAClD;IACD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC;IAClC,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
|
package/build/helper.d.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
import type { Auth, AuthCredentials, AuthToken } from './types.js';
|
|
1
|
+
import type { Auth, AuthCredentials, AuthToken, Authorization } from './types.js';
|
|
2
2
|
export declare const verifyAuth: (auth: Auth) => boolean;
|
|
3
3
|
export declare const verifyAuthCredentials: (auth: AuthCredentials) => boolean;
|
|
4
4
|
export declare const isAuth: (auth: unknown) => auth is Auth;
|
|
5
5
|
export declare const isAuthCredentials: (auth: unknown) => auth is AuthCredentials;
|
|
6
6
|
export declare const isAuthToken: (auth: unknown) => auth is AuthToken;
|
|
7
|
+
/**
|
|
8
|
+
* The organization slug carried by an auth payload, tolerating tokens minted before the field
|
|
9
|
+
* was named.
|
|
10
|
+
*
|
|
11
|
+
* Tokens outlive deployments: one signed with the previous release still arrives with the value
|
|
12
|
+
* under `entityId`, and it stays valid until it expires. Everything that reads the organization
|
|
13
|
+
* off a payload goes through here so that window needs no second code path — and so the day the
|
|
14
|
+
* fallback can be deleted is a single-line change rather than an audit.
|
|
15
|
+
*/
|
|
16
|
+
export declare const entitySlugOf: (payload?: Partial<Authorization> | null) => string | undefined;
|
|
7
17
|
//# sourceMappingURL=helper.d.ts.map
|
package/build/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AASjF,eAAO,MAAM,UAAU,SAAU,IAAI,KAAG,OAIvC,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAU,eAAe,KAAG,OAI7D,CAAA;AAED,eAAO,MAAM,MAAM,SAAU,OAAO,KAAG,IAAI,IAAI,IAEH,CAAA;AAE5C,eAAO,MAAM,iBAAiB,SAAU,OAAO,KAAG,IAAI,IAAI,eAEN,CAAA;AAEpD,eAAO,MAAM,WAAW,SAAU,OAAO,KAAG,IAAI,IAAI,SAEI,CAAA;AAExD;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,aAAc,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,KAAG,MAAM,GAAG,SACQ,CAAA"}
|
package/build/helper.js
CHANGED
|
@@ -18,4 +18,14 @@ export const isAuthCredentials = (auth) => typeof auth === 'object' && auth != n
|
|
|
18
18
|
&& ("challenge" in auth) && ("credential" in auth);
|
|
19
19
|
export const isAuthToken = (auth) => typeof auth === 'object' && auth != null
|
|
20
20
|
&& ("token" in auth) && typeof auth.token === 'string';
|
|
21
|
+
/**
|
|
22
|
+
* The organization slug carried by an auth payload, tolerating tokens minted before the field
|
|
23
|
+
* was named.
|
|
24
|
+
*
|
|
25
|
+
* Tokens outlive deployments: one signed with the previous release still arrives with the value
|
|
26
|
+
* under `entityId`, and it stays valid until it expires. Everything that reads the organization
|
|
27
|
+
* off a payload goes through here so that window needs no second code path — and so the day the
|
|
28
|
+
* fallback can be deleted is a single-line change rather than an audit.
|
|
29
|
+
*/
|
|
30
|
+
export const entitySlugOf = (payload) => payload?.entitySlug ?? payload?.entityId;
|
|
21
31
|
//# sourceMappingURL=helper.js.map
|
package/build/helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACzB,OAAO,aAAa,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAExE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAA;AACtC,0FAA0F;AAC1F,aAAa,CAAC,GAAU,CAAC,CAAA;AAEzB,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAU,EAAW,EAAE;IAChD,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,CAAA;IAExC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,IAAqB,EAAW,EAAE;IACtE,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAA;IAEnD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAA;AACvB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAa,EAAgB,EAAE,CACpD,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,IAAI;OACrC,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAA;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAA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AAC,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAA;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAAa,EAA2B,EAAE,CAC1E,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,IAAI;OACrC,CAAC,WAAW,IAAI,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,CAAA;AAEpD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAa,EAAqB,EAAE,CAC9D,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,IAAI;OACrC,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAA;AAExD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAuC,EAAsB,EAAE,CAC1F,OAAO,EAAE,UAAU,IAAK,OAAoD,EAAE,QAAQ,CAAA"}
|
package/build/types.d.ts
CHANGED
|
@@ -32,7 +32,17 @@ export interface ProfilePayload extends Authorization {
|
|
|
32
32
|
groups?: string[];
|
|
33
33
|
}
|
|
34
34
|
export interface Authorization {
|
|
35
|
-
|
|
35
|
+
/**
|
|
36
|
+
* The organization entity's slug — renameable, and the ONLY entity value that travels on the
|
|
37
|
+
* wire: in tokens, in URLs and in request bodies.
|
|
38
|
+
*
|
|
39
|
+
* It is deliberately NOT a database key. An implementation that stores things per organization
|
|
40
|
+
* keeps its own stable `entityId` on its records and resolves this slug to it at the boundary,
|
|
41
|
+
* so a rename costs one registry write instead of a migration of every collection, object name
|
|
42
|
+
* and third-party record that ever referenced the organization. Basic auth knows nothing about
|
|
43
|
+
* that id — see `@owlmeans/auth-common`'s entity resolver for the contract that does.
|
|
44
|
+
*/
|
|
45
|
+
entitySlug?: string;
|
|
36
46
|
scopes: string[];
|
|
37
47
|
permissions?: PermissionSet[];
|
|
38
48
|
attributes?: AttributeSet[];
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CAmBnB;AAED,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,CAAA;IACd;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,IAAI,CAAA;CAYjB;AAED,MAAM,WAAW,KAAM,SAAQ,aAAa;IAC1C,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CAUlB;AAED,MAAM,WAAW,aAAa;IAC5B,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAClD,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CAmBnB;AAED,MAAM,WAAW,WAAY,SAAQ,cAAc;IACjD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,QAAQ,CAAA;IACd;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;I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AE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,MAAM,WAAW,gBAAiB,SAAQ,OAAO,CAAC,WAAW,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAA;CAmBb;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAA;CACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/auth",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.11",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@owlmeans/error": "^0.1.18-rc.
|
|
25
|
+
"@owlmeans/error": "^0.1.18-rc.10",
|
|
26
26
|
"ajv-formats": "^3.0.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@owlmeans/dep-config": "workspace:*",
|
|
33
|
-
"@types/bun": "^1.
|
|
33
|
+
"@types/bun": "^1.4.0",
|
|
34
34
|
"nodemon": "^3.1.14",
|
|
35
35
|
"typescript": "^7.0.2"
|
|
36
36
|
},
|
package/src/allowance/model.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { JSONSchemaType } from 'ajv'
|
|
2
2
|
import type { AllowanceRequest, Auth, AuthCredentials, AuthPayload } from '../types.js'
|
|
3
3
|
import {
|
|
4
|
-
AuthRoleSchema,
|
|
4
|
+
AuthRoleSchema, EntitySlugValueSchema, GroupValueSchema, IdValueSchema, DateSchema,
|
|
5
5
|
ScopeValueSchema, TypeNameSchema
|
|
6
6
|
} from '../consts.js'
|
|
7
7
|
import { AuthPayloadSchema } from '../auth/model.js'
|
|
@@ -16,7 +16,7 @@ export const PartialAuthPayloadSchema: JSONSchemaType<Omit<Partial<AuthPayload>,
|
|
|
16
16
|
profileId: { ...IdValueSchema, nullable: true },
|
|
17
17
|
expiresAt: { ...DateSchema, nullable: true },
|
|
18
18
|
groups: { type: 'array', items: GroupValueSchema, nullable: true },
|
|
19
|
-
|
|
19
|
+
entitySlug: { ...EntitySlugValueSchema, nullable: true },
|
|
20
20
|
scopes: { type: 'array', items: ScopeValueSchema, nullable: true },
|
|
21
21
|
permissions: { type: 'array', nullable: true, items: PermissionSetSchema },
|
|
22
22
|
attributes: { type: 'array', nullable: true, items: AttributeSetSchema },
|
package/src/auth/model.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { JSONSchemaType } from 'ajv'
|
|
2
2
|
import type { AuthPayload, AuthToken, Authorization, ProfilePayload } from '../types.js'
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
EntitySlugValueSchema, EnumValueSchema, GroupValueSchema, IdValueSchema, DateSchema, ScopeValueSchema,
|
|
5
5
|
TypeNameSchema
|
|
6
6
|
} from '../consts.js'
|
|
7
7
|
import { AttributeSetSchema, PermissionSetSchema } from '../permission/model.js'
|
|
@@ -9,7 +9,7 @@ import { AttributeSetSchema, PermissionSetSchema } from '../permission/model.js'
|
|
|
9
9
|
export const AuthorizationSchema: JSONSchemaType<Authorization> = {
|
|
10
10
|
type: 'object',
|
|
11
11
|
properties: {
|
|
12
|
-
|
|
12
|
+
entitySlug: { ...EntitySlugValueSchema, nullable: true },
|
|
13
13
|
scopes: { type: 'array', items: ScopeValueSchema },
|
|
14
14
|
permissions: { type: 'array', nullable: true, items: PermissionSetSchema },
|
|
15
15
|
attributes: { type: 'array', nullable: true, items: AttributeSetSchema },
|
package/src/consts.ts
CHANGED
|
@@ -98,7 +98,10 @@ export const ResourceValueSchema: JSONSchemaType<string> = { type: 'string', min
|
|
|
98
98
|
|
|
99
99
|
export const AttributeValueSchema: JSONSchemaType<string> = { type: 'string', minLength: 8, maxLength: 128 }
|
|
100
100
|
|
|
101
|
-
export const
|
|
101
|
+
export const EntitySlugValueSchema: JSONSchemaType<string> = { type: 'string', minLength: 3, maxLength: 256 }
|
|
102
|
+
|
|
103
|
+
/** @deprecated The organization value on the wire is a slug — use {@link EntitySlugValueSchema}. */
|
|
104
|
+
export const EntityValueSchema: JSONSchemaType<string> = EntitySlugValueSchema
|
|
102
105
|
|
|
103
106
|
export const GroupValueSchema: JSONSchemaType<string> = { type: 'string', minLength: 1, maxLength: 128 }
|
|
104
107
|
|
|
@@ -115,11 +118,20 @@ export const AuthRoleSchema: JSONSchemaType<AuthRole> = { type: 'string', enum:
|
|
|
115
118
|
export const DISPATCHER = 'dispatcher'
|
|
116
119
|
export const DISPATCHER_AUTHEN = `${DISPATCHER}:authentication`
|
|
117
120
|
|
|
121
|
+
/**
|
|
122
|
+
* The login window opened one level up by an application that cannot complete the flow where it is.
|
|
123
|
+
*
|
|
124
|
+
* A separate entrypoint from {@link DISPATCHER} because it is never a `redirect_uri` — the provider
|
|
125
|
+
* always returns to the dispatcher, whatever page opened the window — and because a logout has to
|
|
126
|
+
* run somewhere that does not start the authorization machine.
|
|
127
|
+
*/
|
|
128
|
+
export const DISPATCHER_SURROGATE = `${DISPATCHER}:surrogate`
|
|
129
|
+
|
|
118
130
|
export const AUTHEN_RELY = `${AUTHEN}-rely`
|
|
119
131
|
|
|
120
132
|
export const AUTH_HEADER = 'authorization'
|
|
121
133
|
export const AUTH_QUERY = 'token'
|
|
122
|
-
export const ENTITY_QUERY = '
|
|
134
|
+
export const ENTITY_QUERY = 'entitySlug'
|
|
123
135
|
export const PROFILE_QUERY = 'profile'
|
|
124
136
|
|
|
125
137
|
export const MOD_RECAPTCHA = '_external:re-captcha'
|
package/src/entity/profile.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import type { JSONSchemaType } from 'ajv'
|
|
3
3
|
import type { Profile } from '../types.js'
|
|
4
|
-
import {
|
|
4
|
+
import { EntitySlugValueSchema, IdValueSchema } from '../consts.js'
|
|
5
5
|
import { PermissionSetSchema, AttributeSetSchema } from '../permission/model.js'
|
|
6
6
|
|
|
7
7
|
export const ProfileSchema: JSONSchemaType<Profile> = {
|
|
@@ -12,7 +12,7 @@ export const ProfileSchema: JSONSchemaType<Profile> = {
|
|
|
12
12
|
credential: { type: 'string', nullable: true },
|
|
13
13
|
secret: { type: 'string', nullable: true },
|
|
14
14
|
groups: { type: 'array', items: { type: 'string' }, nullable: true },
|
|
15
|
-
|
|
15
|
+
entitySlug: {...EntitySlugValueSchema, nullable: true},
|
|
16
16
|
scopes: { type: 'array', items: { type: 'string' } },
|
|
17
17
|
permissions: { type: 'array', items: PermissionSetSchema, nullable: true },
|
|
18
18
|
attributes: { type: 'array', items: AttributeSetSchema, nullable: true },
|
package/src/helper.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Auth, AuthCredentials, AuthToken } from './types.js'
|
|
1
|
+
import type { Auth, AuthCredentials, AuthToken, Authorization } from './types.js'
|
|
2
2
|
import { Ajv } from 'ajv'
|
|
3
3
|
import formatsPlugin from 'ajv-formats'
|
|
4
4
|
import { AuthCredentialsSchema, AuthSchema } from './allowance/model.js'
|
|
@@ -30,3 +30,15 @@ export const isAuthCredentials = (auth: unknown): auth is AuthCredentials =>
|
|
|
30
30
|
export const isAuthToken = (auth: unknown): auth is AuthToken =>
|
|
31
31
|
typeof auth === 'object' && auth != null
|
|
32
32
|
&& ("token" in auth) && typeof auth.token === 'string'
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The organization slug carried by an auth payload, tolerating tokens minted before the field
|
|
36
|
+
* was named.
|
|
37
|
+
*
|
|
38
|
+
* Tokens outlive deployments: one signed with the previous release still arrives with the value
|
|
39
|
+
* under `entityId`, and it stays valid until it expires. Everything that reads the organization
|
|
40
|
+
* off a payload goes through here so that window needs no second code path — and so the day the
|
|
41
|
+
* fallback can be deleted is a single-line change rather than an audit.
|
|
42
|
+
*/
|
|
43
|
+
export const entitySlugOf = (payload?: Partial<Authorization> | null): string | undefined =>
|
|
44
|
+
payload?.entitySlug ?? (payload as { entityId?: string } | null | undefined)?.entityId
|
package/src/types.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface AuthCredentials extends AuthPayload {
|
|
|
15
15
|
ProfilePayload:
|
|
16
16
|
groups?: string[]
|
|
17
17
|
Authorization:
|
|
18
|
-
|
|
18
|
+
entitySlug?: string
|
|
19
19
|
scopes: string[]
|
|
20
20
|
permissions?: PermissionSet[]
|
|
21
21
|
attributes?: AttributeSet[]
|
|
@@ -47,7 +47,7 @@ export interface AuthPayload extends ProfilePayload {
|
|
|
47
47
|
ProfilePayload:
|
|
48
48
|
groups?: string[]
|
|
49
49
|
Authorization:
|
|
50
|
-
|
|
50
|
+
entitySlug?: string
|
|
51
51
|
scopes: string[]
|
|
52
52
|
permissions?: PermissionSet[]
|
|
53
53
|
attributes?: AttributeSet[]
|
|
@@ -65,7 +65,7 @@ export interface ProfilePayload extends Authorization {
|
|
|
65
65
|
groups?: string[]
|
|
66
66
|
/**
|
|
67
67
|
Authorization:
|
|
68
|
-
|
|
68
|
+
entitySlug?: string
|
|
69
69
|
scopes: string[]
|
|
70
70
|
permissions?: PermissionSet[]
|
|
71
71
|
attributes?: AttributeSet[]
|
|
@@ -75,7 +75,17 @@ export interface ProfilePayload extends Authorization {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export interface Authorization {
|
|
78
|
-
|
|
78
|
+
/**
|
|
79
|
+
* The organization entity's slug — renameable, and the ONLY entity value that travels on the
|
|
80
|
+
* wire: in tokens, in URLs and in request bodies.
|
|
81
|
+
*
|
|
82
|
+
* It is deliberately NOT a database key. An implementation that stores things per organization
|
|
83
|
+
* keeps its own stable `entityId` on its records and resolves this slug to it at the boundary,
|
|
84
|
+
* so a rename costs one registry write instead of a migration of every collection, object name
|
|
85
|
+
* and third-party record that ever referenced the organization. Basic auth knows nothing about
|
|
86
|
+
* that id — see `@owlmeans/auth-common`'s entity resolver for the contract that does.
|
|
87
|
+
*/
|
|
88
|
+
entitySlug?: string
|
|
79
89
|
scopes: string[]
|
|
80
90
|
permissions?: PermissionSet[]
|
|
81
91
|
attributes?: AttributeSet[]
|
|
@@ -98,7 +108,7 @@ export interface Profile extends ProfilePayload {
|
|
|
98
108
|
ProfilePayload:
|
|
99
109
|
groups?: string[]
|
|
100
110
|
Authorization:
|
|
101
|
-
|
|
111
|
+
entitySlug?: string
|
|
102
112
|
scopes: string[]
|
|
103
113
|
permissions?: PermissionSet[]
|
|
104
114
|
attributes?: AttributeSet[]
|
|
@@ -122,7 +132,7 @@ export interface Auth extends AuthPayload {
|
|
|
122
132
|
ProfilePayload:
|
|
123
133
|
groups?: string[]
|
|
124
134
|
Authorization:
|
|
125
|
-
|
|
135
|
+
entitySlug?: string
|
|
126
136
|
scopes: string[]
|
|
127
137
|
permissions?: PermissionSet[]
|
|
128
138
|
attributes?: AttributeSet[]
|
|
@@ -160,7 +170,7 @@ export interface AllowanceRequest extends Partial<AuthPayload> {
|
|
|
160
170
|
ProfilePayload:
|
|
161
171
|
groups?: string[]
|
|
162
172
|
Authorization:
|
|
163
|
-
|
|
173
|
+
entitySlug?: string
|
|
164
174
|
scopes?: string[]
|
|
165
175
|
permissions?: PermissionSet[]
|
|
166
176
|
attributes?: AttributeSet[]
|
package/build/.gitkeep
DELETED
|
File without changes
|