@owlmeans/auth 0.1.18-rc.16 → 0.1.18-rc.18
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 +287 -49
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/auth/SKILL.md +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,88 +1,326 @@
|
|
|
1
1
|
# @owlmeans/auth
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
The core authentication and authorization vocabulary shared by server and client: the `Auth` /
|
|
4
|
+
`AuthPayload` / `AuthCredentials` types, the `AuthRole` and `AuthenticationType` enums, the auth
|
|
5
|
+
error hierarchy, AJV schemas for request bodies and record fields, the auth entrypoint aliases, and
|
|
6
|
+
`entitySlugOf()` for reading the organization entity off a token. An app imports it whenever code
|
|
7
|
+
on either side of the wire needs to name an identity, throw an auth error, or reuse a scalar schema
|
|
8
|
+
(`IdValueSchema`, `DateSchema`). It contains no services and no wiring: guards, the Ed25519 guard,
|
|
9
|
+
shared auth protocols and organization-entity resolution (`entityKeyOf`, `requireEntityKey`,
|
|
10
|
+
`attachEntity`) live in [`@owlmeans/auth-common`](../auth-common); the server auth service in
|
|
11
|
+
[`@owlmeans/server-auth`](../server-auth); the browser auth service in
|
|
12
|
+
[`@owlmeans/client-auth`](../client-auth).
|
|
11
13
|
|
|
12
14
|
## Installation
|
|
13
15
|
|
|
14
16
|
```bash
|
|
15
|
-
bun add @owlmeans/auth@^0.1.18-rc.
|
|
17
|
+
bun add @owlmeans/auth@^0.1.18-rc.18
|
|
16
18
|
```
|
|
17
19
|
|
|
20
|
+
`ajv` is a **peer** dependency — install it alongside, or `verifyAuth` / `verifyAuthCredentials`
|
|
21
|
+
fail to resolve.
|
|
22
|
+
|
|
23
|
+
## Concepts
|
|
24
|
+
|
|
25
|
+
- **Authorization** — the RBAC base every identity shape extends: `entitySlug?`, `scopes`,
|
|
26
|
+
`permissions?` (`PermissionSet[]`), `attributes?`, `permissioned?`, `denormalized?`.
|
|
27
|
+
- **AuthPayload / Auth** — `AuthPayload` adds `type`, `role`, `userId`, `profileId?`,
|
|
28
|
+
`expiresAt?`; `Auth` is the resolved identity a guard puts on `request.auth` (adds `token`,
|
|
29
|
+
`isUser`, `createdAt`).
|
|
30
|
+
- **Allowance / credentials** — the two-step handshake: a client posts an `AllowanceRequest` to get
|
|
31
|
+
a `challenge`, then posts `AuthCredentials` (`challenge` + `credential`) to authenticate.
|
|
32
|
+
- **Organization entity** — `entitySlug` is the renameable organization name and the only
|
|
33
|
+
organization value on the wire. Read it with `entitySlugOf(payload)`. The stable `entityId` is
|
|
34
|
+
never on the wire and is not declared here; server handlers get it from `requireEntityKey(req)` /
|
|
35
|
+
`requireEntity(req)` in `@owlmeans/auth-common`.
|
|
36
|
+
- **Error hierarchy** — `AuthError` is the root of i18n-aware `ResilientError` subclasses that
|
|
37
|
+
survive marshalling across a service boundary: `AuthUnknown` (no identity), `AuthenFailed`
|
|
38
|
+
(credential rejected), `AuthForbidden` (authenticated, not allowed).
|
|
39
|
+
- **Authentication stage** — `AuthenticationStage` tracks a client or socket flow from `Init` to
|
|
40
|
+
`Authenticated` (or `Error`).
|
|
41
|
+
|
|
18
42
|
## Usage
|
|
19
43
|
|
|
20
|
-
|
|
44
|
+
### Reuse scalar schemas in shared contracts
|
|
45
|
+
|
|
46
|
+
Field schemas keep ids, dates and scopes consistent across every app model.
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import type { JSONSchemaType } from 'ajv'
|
|
50
|
+
import { DateSchema, IdValueSchema } from '@owlmeans/auth'
|
|
51
|
+
|
|
52
|
+
export interface Invoice {
|
|
53
|
+
id?: string
|
|
54
|
+
projectId: string
|
|
55
|
+
total: number
|
|
56
|
+
createdAt: Date
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const InvoiceSchema: JSONSchemaType<Invoice> = {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
id: { ...IdValueSchema, nullable: true },
|
|
63
|
+
projectId: IdValueSchema,
|
|
64
|
+
total: { type: 'number', minimum: 0 },
|
|
65
|
+
createdAt: DateSchema,
|
|
66
|
+
},
|
|
67
|
+
required: ['projectId', 'total', 'createdAt'],
|
|
68
|
+
additionalProperties: false,
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Throw typed errors from a handler
|
|
21
73
|
|
|
22
|
-
|
|
74
|
+
A handler that finds no identity throws `AuthUnknown`; one that finds an identity without the right
|
|
75
|
+
to act throws `AuthForbidden`. Organization-scoped records are keyed by the resolved id from
|
|
76
|
+
`requireEntityKey`, never by the slug on the token.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { AuthForbidden, AuthUnknown } from '@owlmeans/auth'
|
|
80
|
+
import { requireEntityKey } from '@owlmeans/auth-common'
|
|
23
81
|
import { handlers } from '@owlmeans/server-api'
|
|
24
|
-
import {
|
|
25
|
-
import type {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export const
|
|
30
|
-
if (
|
|
31
|
-
throw new AuthUnknown('
|
|
82
|
+
import { invoiceProtocols } from 'my-app-common'
|
|
83
|
+
import type { AppContext } from '../types.js'
|
|
84
|
+
|
|
85
|
+
const api = handlers<AppContext>()
|
|
86
|
+
|
|
87
|
+
export const listInvoices = api.request(invoiceProtocols.list, async (req, context) => {
|
|
88
|
+
if (req.auth?.profileId == null) {
|
|
89
|
+
throw new AuthUnknown('profile')
|
|
90
|
+
}
|
|
91
|
+
const entityId = requireEntityKey(req) // stable record id, never from the token
|
|
92
|
+
|
|
93
|
+
return await loadInvoices(context, entityId, req.params.projectId)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
export const archiveInvoice = api.request(invoiceProtocols.archive, async (req, context) => {
|
|
97
|
+
const entityId = requireEntityKey(req)
|
|
98
|
+
if (!req.auth!.scopes.includes('invoice-admin')) {
|
|
99
|
+
throw new AuthForbidden('permission')
|
|
32
100
|
}
|
|
33
|
-
|
|
101
|
+
|
|
102
|
+
return await archive(context, entityId, req.params.id)
|
|
34
103
|
})
|
|
35
104
|
```
|
|
36
105
|
|
|
37
|
-
|
|
106
|
+
### Deny access in a gate
|
|
107
|
+
|
|
108
|
+
A gate service declared on a protocol (`gate: { alias, params }`) asserts scopes and throws
|
|
109
|
+
`AuthForbidden` on denial.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
import { createLazyService } from '@owlmeans/context'
|
|
113
|
+
import type { GateService } from '@owlmeans/entrypoint'
|
|
114
|
+
import { ALL_SCOPES, AuthForbidden } from '@owlmeans/auth'
|
|
115
|
+
import { entityKeyOf } from '@owlmeans/auth-common'
|
|
116
|
+
|
|
117
|
+
export const makeProjectGate = (alias: string = 'my-app:project-gate'): GateService =>
|
|
118
|
+
createLazyService<GateService>(alias, {
|
|
119
|
+
assert: async (req, _, params) => {
|
|
120
|
+
if (req.auth == null) throw new AuthForbidden('auth')
|
|
121
|
+
|
|
122
|
+
const entityId = entityKeyOf(req)
|
|
123
|
+
if (entityId == null) throw new AuthForbidden('entity')
|
|
124
|
+
|
|
125
|
+
// Params name the organization by its stable id, matching how grants are stored.
|
|
126
|
+
const required = params.map(p => p.replace(/\{entity\}/g, entityId))
|
|
127
|
+
const scopes = req.auth.scopes ?? []
|
|
128
|
+
if (!required.every(p => scopes.includes(ALL_SCOPES) || scopes.includes(p))) {
|
|
129
|
+
throw new AuthForbidden('permission')
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
})
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Authenticate a socket connection
|
|
136
|
+
|
|
137
|
+
A socket authenticates after its connection is open, so it moves through `AuthenticationStage`
|
|
138
|
+
itself, sets the bearer token under `AUTH_HEADER`, and must call `attachEntity`.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import type { Auth, AuthToken } from '@owlmeans/auth'
|
|
142
|
+
import { AUTH_HEADER, AuthenFailed, AuthenticationStage, AuthUnknown } from '@owlmeans/auth'
|
|
143
|
+
import { attachEntity, DEFAULT_GUARD } from '@owlmeans/auth-common'
|
|
144
|
+
import type { AbstractRequest, AbstractResponse, GuardService } from '@owlmeans/entrypoint'
|
|
145
|
+
import { provideResponse } from '@owlmeans/entrypoint'
|
|
146
|
+
import type { AppContext } from '../types.js'
|
|
147
|
+
|
|
148
|
+
export const authenticateSocket = (context: AppContext, req: AbstractRequest) =>
|
|
149
|
+
async (stage: AuthenticationStage, token: AuthToken) => {
|
|
150
|
+
if (stage !== AuthenticationStage.Authenticate) throw new AuthUnknown('stage')
|
|
151
|
+
|
|
152
|
+
req.headers ??= {}
|
|
153
|
+
req.headers[AUTH_HEADER] ??= token.token
|
|
154
|
+
|
|
155
|
+
const res: AbstractResponse<Auth> = provideResponse({ header: () => void 0 })
|
|
156
|
+
if (!await context.service<GuardService>(DEFAULT_GUARD).handle(req, res) || res.value == null) {
|
|
157
|
+
throw new AuthenFailed('guard')
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
req.auth = res.value
|
|
161
|
+
await attachEntity(context, req)
|
|
162
|
+
|
|
163
|
+
return [AuthenticationStage.Authenticated, true]
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Build payloads, read the organization, widen a token schema
|
|
38
168
|
|
|
39
|
-
|
|
40
|
-
|
|
169
|
+
`AuthRole` is a string enum, `entitySlugOf` is the only supported way to read the organization off a
|
|
170
|
+
payload, and `AuthTokenSchema` caps `token` at 1024 characters — a route carrying a wrapped
|
|
171
|
+
credential envelope declares its own wider schema.
|
|
41
172
|
|
|
42
|
-
|
|
43
|
-
|
|
173
|
+
```ts
|
|
174
|
+
import type { JSONSchemaType } from 'ajv'
|
|
175
|
+
import type { AuthPayload, AuthToken } from '@owlmeans/auth'
|
|
176
|
+
import { AuthRole, AuthenticationType, entitySlugOf, isAuthToken } from '@owlmeans/auth'
|
|
177
|
+
|
|
178
|
+
const payload: AuthPayload = {
|
|
179
|
+
type: AuthenticationType.OneTimeToken,
|
|
180
|
+
role: AuthRole.User,
|
|
181
|
+
userId: 'account-1',
|
|
182
|
+
profileId: 'profile-1',
|
|
183
|
+
entitySlug: 'acme-studio',
|
|
184
|
+
scopes: ['my-app-project'],
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const orgLabel = entitySlugOf(payload) // string | undefined — opaque, never a database key
|
|
188
|
+
|
|
189
|
+
export const WrappedTokenSchema: JSONSchemaType<AuthToken> = {
|
|
190
|
+
type: 'object',
|
|
191
|
+
properties: { token: { type: 'string', minLength: 32, maxLength: 8192 } },
|
|
192
|
+
required: ['token'],
|
|
193
|
+
additionalProperties: false,
|
|
44
194
|
}
|
|
195
|
+
|
|
196
|
+
export const tokenOf = (body: unknown): string | undefined =>
|
|
197
|
+
isAuthToken(body) ? body.token : undefined
|
|
45
198
|
```
|
|
46
199
|
|
|
47
200
|
## API
|
|
48
201
|
|
|
202
|
+
All symbols are exported from the package root (`@owlmeans/auth`); there are no subpath exports.
|
|
203
|
+
|
|
49
204
|
### Types
|
|
50
205
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
206
|
+
| Symbol | Kind | Purpose |
|
|
207
|
+
|--------|------|---------|
|
|
208
|
+
| `Authorization` | interface | RBAC base: `entitySlug?`, `scopes`, `permissions?`, `attributes?`, `permissioned?`, `denormalized?` |
|
|
209
|
+
| `ProfilePayload` | interface | `Authorization` + `groups?` |
|
|
210
|
+
| `AuthPayload` | interface | `ProfilePayload` + `type`, `role`, `userId`, `source?`, `profileId?`, `expiresAt?` |
|
|
211
|
+
| `AuthCredentials` | interface | `AuthPayload` + `challenge`, `credential`, `publicKey?` — the authenticate body |
|
|
212
|
+
| `Auth` | interface | `AuthPayload` + `token`, `isUser`, `createdAt` — the identity on `request.auth` |
|
|
213
|
+
| `Profile` | interface | `ProfilePayload` + `id`, `name`, `credential?`, `secret?` — a stored identity record |
|
|
214
|
+
| `Group` | interface | `Authorization` + `id`, `name` |
|
|
215
|
+
| `AllowanceRequest` | interface | `Partial<AuthPayload>` with required `type` — asks for a challenge |
|
|
216
|
+
| `AllowanceResponse` | interface | `{ challenge }` |
|
|
217
|
+
| `AuthToken` | interface | `{ token }` — the bearer envelope on the wire |
|
|
218
|
+
| `PermissionSet` | interface | `scope`, `title?`, `permissions: Capabilties`, `resources?` |
|
|
219
|
+
| `Capabilties` | interface | Map of capability name to `boolean \| number \| null` |
|
|
220
|
+
| `AttributeSet` | interface | `scope`, `attributes: string[]` |
|
|
221
|
+
| `RelyToken` | interface | Rely-handshake token: `nonce`, `pin?`, `token?`, `check?` |
|
|
222
|
+
| `SupervisorCredentialPayload` | interface | `{ salt, signature }` packed into a supervisor credential |
|
|
55
223
|
|
|
56
224
|
### Enums
|
|
57
225
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
enum
|
|
61
|
-
enum
|
|
62
|
-
|
|
226
|
+
| Symbol | Kind | Purpose |
|
|
227
|
+
|--------|------|---------|
|
|
228
|
+
| `AuthRole` | string enum | `User`, `Guest`, `Service`, `System`, `Admin`, `Superuser`, `Blocked` |
|
|
229
|
+
| `AuthenticationType` | string enum | How identity is proven: `BasicEd25519`, `OneTimeToken`, `ReCaptcha`, `WalletDid`, `RelyHandshake`, `WalletConsumer`, `WalletProvider`, `Google` (`'google-oauth'`), `Supervisor` (`'pk-supervisor'`) |
|
|
230
|
+
| `AuthroizationType` (sic) | string enum | How a request carries authorization: `AuthToken`, `Ed25519BasicToken`, `Ed25519BasicSignature` |
|
|
231
|
+
| `AuthenticationStage` | string enum | Flow stage: `Error`, `Init`, `Allowence`, `Authenticate`, `Authentication`, `Authenticated` |
|
|
232
|
+
|
|
233
|
+
### Constants
|
|
234
|
+
|
|
235
|
+
| Symbol | Kind | Purpose |
|
|
236
|
+
|--------|------|---------|
|
|
237
|
+
| `AUTH_HEADER` / `AUTH_QUERY` | const | `'authorization'` / `'token'` |
|
|
238
|
+
| `ENTITY_QUERY` / `PROFILE_QUERY` | const | `'entitySlug'` / `'profile'` query parameter names |
|
|
239
|
+
| `ALL_SCOPES` / `AUTH_SCOPE` | const | `'*'` / `'__auth'` |
|
|
240
|
+
| `INCLUDE`, `EXCLUDE`, `WILDCARD`, `DELIMITER` | const | Permission-string grammar: `'+'`, `'-'`, `'*'`, `':'` |
|
|
241
|
+
| `GUEST_ID`, `RELY_3RD` | const | Reserved ids: `'__guest'`, `'rely'` |
|
|
242
|
+
| `AUTHEN`, `AUTHEN_INIT`, `AUTHEN_AUTHEN`, `AUTHEN_RELY` | const | Backend authentication entrypoint aliases |
|
|
243
|
+
| `CAUTHEN`, `CAUTHEN_AUTHEN`, `CAUTHEN_AUTHEN_DEFAULT`, `CAUTHEN_AUTHEN_TYPED`, `CAUTHEN_FLOW_ENTER` | const | Front-end authentication entrypoint aliases |
|
|
244
|
+
| `DISPATCHER`, `DISPATCHER_AUTHEN`, `DISPATCHER_SURROGATE` | const | Dispatcher and surrogate login-window entrypoint aliases |
|
|
245
|
+
| `MOD_RECAPTCHA`, `CMOD_RECAPTCHA` | const | reCAPTCHA entrypoint aliases |
|
|
63
246
|
|
|
64
247
|
### Errors
|
|
65
248
|
|
|
66
|
-
|
|
249
|
+
Every class extends `ResilientError` (`@owlmeans/error`), is registered for marshalling, and takes
|
|
250
|
+
an optional message suffix (default `'error'`).
|
|
251
|
+
|
|
252
|
+
| Symbol | Kind | Purpose |
|
|
253
|
+
|--------|------|---------|
|
|
254
|
+
| `AuthError` | class | Root of the hierarchy |
|
|
255
|
+
| `AuthUnknown` | class | The subject is not known — missing auth state, unregistered plugin type |
|
|
256
|
+
| `AuthManagerError` | class | The auth manager itself failed |
|
|
257
|
+
| `AuthManagerUnsupported` | class | The manager cannot serve this request shape |
|
|
258
|
+
| `AuthenFailed` | class | Authentication attempted and rejected (bad challenge, code, signature) |
|
|
259
|
+
| `AuthenExists` | class | The identity being registered already exists |
|
|
260
|
+
| `AuthenPayloadError` | class | A required credential field is missing |
|
|
261
|
+
| `AuthPluginError` | class | An auth plugin misbehaved |
|
|
262
|
+
| `TypeMissmatchError` | class | A plugin was handed the wrong authentication type |
|
|
263
|
+
| `AuthorizationError` | class | Authenticated, but no usable authorization |
|
|
264
|
+
| `AuthForbidden` | class | Authenticated and understood — and not allowed |
|
|
265
|
+
| `ProfileError` / `ProfileConsistencyError` | class | A profile is missing / internally inconsistent |
|
|
266
|
+
|
|
267
|
+
### Schemas
|
|
268
|
+
|
|
269
|
+
| Symbol | Kind | Purpose |
|
|
270
|
+
|--------|------|---------|
|
|
271
|
+
| `AuthorizationSchema`, `ProfilePayloadSchema`, `AuthPayloadSchema` | JSON schema | Payload validation; `AuthPayloadSchema` requires `scopes`, `role`, `type` |
|
|
272
|
+
| `PartialAuthPayloadSchema`, `AllowanceRequestSchema` | JSON schema | The `authentication:init` body |
|
|
273
|
+
| `AuthCredentialsSchema` | JSON schema | The `authentication:authenticate` body; requires `challenge`, `credential`, `scopes`, `role`, `type` |
|
|
274
|
+
| `AuthSchema` | JSON schema | A resolved `Auth` |
|
|
275
|
+
| `AuthTokenSchema`, `OptionalAuthTokenSchema` | JSON schema | Bearer-token bodies; `token` is 32–1024 characters |
|
|
276
|
+
| `ProfileSchema` | JSON schema | A stored `Profile` |
|
|
277
|
+
| `PermissionSetSchema`, `AttributeSetSchema`, `CapabiltiesSchema` | JSON schema | Permission and attribute shapes |
|
|
278
|
+
| `RelyChallengeSchema` | JSON schema | A `RelyToken` |
|
|
279
|
+
| `ScopeValueSchema`, `PermissionValueSchema`, `ResourceValueSchema`, `AttributeValueSchema`, `GroupValueSchema`, `TypeNameSchema`, `EnumValueSchema`, `IdValueSchema` | JSON schema | Reusable string field schemas with length bounds |
|
|
280
|
+
| `EntitySlugValueSchema` | JSON schema | Organization slug field (3–256 characters) |
|
|
281
|
+
| `EntityValueSchema` | JSON schema | Deprecated alias of `EntitySlugValueSchema` |
|
|
282
|
+
| `DateSchema` | JSON schema | `date-time` formatted `Date` field |
|
|
283
|
+
| `AuthRoleSchema` | JSON schema | Enum of `AuthRole` values |
|
|
67
284
|
|
|
68
|
-
|
|
285
|
+
### Helpers
|
|
69
286
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
287
|
+
| Symbol | Kind | Purpose |
|
|
288
|
+
|--------|------|---------|
|
|
289
|
+
| `entitySlugOf(payload?)` | function | The organization carried by a payload: `entitySlug`, falling back to a legacy `entityId` |
|
|
290
|
+
| `verifyAuth(auth)` | function | Validate against `AuthSchema` (AJV with formats) |
|
|
291
|
+
| `verifyAuthCredentials(auth)` | function | Validate against `AuthCredentialsSchema` |
|
|
292
|
+
| `isAuth(value)` | type guard | Has `token` and `isUser` |
|
|
293
|
+
| `isAuthCredentials(value)` | type guard | Has `challenge` and `credential` |
|
|
294
|
+
| `isAuthToken(value)` | type guard | Has a string `token` |
|
|
295
|
+
| `buildSupervisorPayload(challenge, userId, salt)` | function | The canonical payload the PK supervisor login signs and verifies |
|
|
74
296
|
|
|
75
|
-
|
|
297
|
+
## Common pitfalls
|
|
76
298
|
|
|
77
|
-
- `
|
|
78
|
-
- `
|
|
79
|
-
|
|
299
|
+
- `AuthRole` is a **string** enum — use the members; numeric literals do not compile.
|
|
300
|
+
- Read the organization with `entitySlugOf()`, never `payload.entitySlug` directly. Its result may
|
|
301
|
+
be a legacy `entityId`, so treat it as an opaque key: never compose names from it and never write
|
|
302
|
+
it as a database key — use `requireEntityKey` / `requireEntity` from `@owlmeans/auth-common`.
|
|
303
|
+
- Never put `entityId` on the wire (tokens, URLs, query params, forms) — only `entitySlug`.
|
|
304
|
+
- Any code path that establishes authentication outside the HTTP boundary (sockets) must call
|
|
305
|
+
`attachEntity(context, request)`, or `request.entity` stays empty.
|
|
306
|
+
- Pick the right error: a gate denial is `AuthForbidden`, a missing identity is `AuthUnknown`, a
|
|
307
|
+
failed credential check is `AuthenFailed`.
|
|
308
|
+
- `AuthCredentialsSchema` requires `type`, `role` and `scopes` on every authenticate call.
|
|
309
|
+
- `AuthTokenSchema` caps `token` at 1024 characters; a route accepting a wrapped credential envelope
|
|
310
|
+
needs its own wider schema.
|
|
311
|
+
- Keep ownership and permission rules out of this package — compose them in entrypoint gates or
|
|
312
|
+
handlers around these types.
|
|
313
|
+
- `ajv` is a peer dependency; without it the `verify*` helpers fail to resolve.
|
|
80
314
|
|
|
81
|
-
## Related
|
|
315
|
+
## Related packages
|
|
82
316
|
|
|
83
|
-
- [`@owlmeans/auth-common`](../auth-common) — auth
|
|
84
|
-
- [`@owlmeans/server-auth`](../server-auth) — server-side auth service
|
|
85
|
-
- [`@owlmeans/
|
|
317
|
+
- [`@owlmeans/auth-common`](../auth-common) — guards, shared auth protocols, organization-entity resolution
|
|
318
|
+
- [`@owlmeans/server-auth`](../server-auth) — server-side auth service and plugins
|
|
319
|
+
- [`@owlmeans/server-auth-identity`](../server-auth-identity) — local identity store behind provider logins
|
|
320
|
+
- [`@owlmeans/client-auth`](../client-auth) — browser auth service and login hooks
|
|
321
|
+
- [`@owlmeans/entrypoint`](../entrypoint) — protocols, guards and gates that consume these types
|
|
322
|
+
- [`@owlmeans/error`](../error) — `ResilientError`, the base of every auth error
|
|
323
|
+
- [`@owlmeans/socket`](../socket) — socket connections that authenticate through `AuthenticationStage`
|
|
86
324
|
|
|
87
325
|
<!-- owlmeans:agent-guidance:start -->
|
|
88
326
|
## Agent guidance
|
|
@@ -92,7 +330,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
92
330
|
your project's skill store (`.agents/skills/`):
|
|
93
331
|
|
|
94
332
|
```sh
|
|
95
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
333
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.21
|
|
96
334
|
```
|
|
97
335
|
|
|
98
336
|
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-09-
|
|
4
|
+
"version": "0.1.18-rc.18",
|
|
5
|
+
"generatedAt": "2026-09-15T12:21:31.879Z",
|
|
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.
|
|
11
|
+
**Install:** `"@owlmeans/auth": "^0.1.18-rc.18"` 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
|
|
@@ -132,7 +132,7 @@ Throw from a handler when the request is missing the identity it needs:
|
|
|
132
132
|
import { AuthUnknown, entitySlugOf } from '@owlmeans/auth'
|
|
133
133
|
import { handlers } from '@owlmeans/server-app'
|
|
134
134
|
|
|
135
|
-
export const list = handlers<Context>().request(
|
|
135
|
+
export const list = handlers<Context>().request(projectProtocols.list, async (req, context) => {
|
|
136
136
|
const slug = entitySlugOf(req.auth)
|
|
137
137
|
if (slug == null) throw new AuthUnknown('entity')
|
|
138
138
|
|
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.18",
|
|
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.17",
|
|
26
26
|
"ajv-formats": "^3.0.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|