@owlmeans/auth 0.1.16-rc.0 → 0.1.17
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 +3 -4
- package/agent-meta/manifest.json +5 -19
- package/agent-meta/skills/auth/SKILL.md +1 -1
- package/build/errors.d.ts.map +1 -1
- package/build/errors.js.map +1 -1
- package/build/helper.d.ts.map +1 -1
- package/build/supervisor.d.ts.map +1 -1
- package/package.json +3 -3
- package/agent-meta/instructions/auth-protocol.instructions.md +0 -31
- package/agent-meta/instructions/auth.instructions.md +0 -59
package/README.md
CHANGED
|
@@ -83,10 +83,9 @@ enum AuthenticationStage { /* connection auth lifecycle */ }
|
|
|
83
83
|
<!-- owlmeans:agent-guidance:start -->
|
|
84
84
|
## Agent guidance
|
|
85
85
|
|
|
86
|
-
This package ships embedded
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(`.claude/skills/` and `.github/instructions/`):
|
|
86
|
+
This package ships embedded agent skills under `agent-meta/`. After installing your
|
|
87
|
+
`@owlmeans/*` packages, run the OwlMeans agent-skills installer to place them into
|
|
88
|
+
your project's skill store (`.agents/skills/`):
|
|
90
89
|
|
|
91
90
|
```sh
|
|
92
91
|
npx @owlmeans/agent-skills
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schemaVersion":
|
|
2
|
+
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/auth",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"generatedAt": "2026-08-
|
|
4
|
+
"version": "0.1.17",
|
|
5
|
+
"generatedAt": "2026-08-15T13:01:19.926Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -10,28 +10,14 @@
|
|
|
10
10
|
"name": "auth",
|
|
11
11
|
"category": "package-specific",
|
|
12
12
|
"file": "skills/auth/SKILL.md",
|
|
13
|
-
"canonicalPath": ".
|
|
13
|
+
"canonicalPath": ".agents/skills/auth/SKILL.md"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"kind": "skill",
|
|
17
17
|
"name": "auth-protocol",
|
|
18
18
|
"category": "multi-package",
|
|
19
19
|
"file": "skills/auth-protocol/SKILL.md",
|
|
20
|
-
"canonicalPath": ".
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"kind": "instruction",
|
|
24
|
-
"name": "auth-protocol",
|
|
25
|
-
"category": "multi-package",
|
|
26
|
-
"file": "instructions/auth-protocol.instructions.md",
|
|
27
|
-
"canonicalPath": ".github/instructions/auth-protocol.instructions.md"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"kind": "instruction",
|
|
31
|
-
"name": "auth",
|
|
32
|
-
"category": "package-specific",
|
|
33
|
-
"file": "instructions/auth.instructions.md",
|
|
34
|
-
"canonicalPath": ".github/instructions/auth.instructions.md"
|
|
20
|
+
"canonicalPath": ".agents/skills/auth-protocol/SKILL.md"
|
|
35
21
|
}
|
|
36
22
|
]
|
|
37
23
|
}
|
package/build/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,qBAAa,SAAU,SAAQ,cAAc;IAC3C,OAAuB,QAAQ,EAAE,MAAM,CAAc;
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,qBAAa,SAAU,SAAQ,cAAc;IAC3C,OAAuB,QAAQ,EAAE,MAAM,CAAc;IAErD,YAAY,OAAO,GAAE,MAAgB,EAEpC;CACF;AAED,qBAAa,WAAY,SAAQ,SAAS;IACxC,OAAuB,QAAQ,EAAE,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;CACF;AAED,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAuB,QAAQ,EAAE,MAAM,CAAwC;IAE/E,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF"}
|
package/build/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,OAAO,SAAU,SAAQ,cAAc;IACpC,MAAM,CAAU,QAAQ,GAAW,WAAW,CAAA;IAErD,YAAY,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,OAAO,SAAU,SAAQ,cAAc;IACpC,MAAM,CAAU,QAAQ,GAAW,WAAW,CAAA;IAErD,YAAY,OAAO,GAAW,OAAO;QACnC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,OAAO,EAAE,CAAC,CAAA;IAC9C,CAAC;CACF;AAED,MAAM,OAAO,WAAY,SAAQ,SAAS;IACjC,MAAM,CAAU,QAAQ,GAAW,GAAG,SAAS,CAAC,QAAQ,SAAS,CAAA;IAExE,YAAY,OAAO,GAAW,OAAO;QACnC,KAAK,CAAC,WAAW,OAAO,EAAE,CAAC,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,QAAQ,CAAA;IAClC,CAAC;CACF;AAED,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IACtC,MAAM,CAAU,QAAQ,GAAW,kBAAkB,CAAA;IAE5D,YAAY,OAAO,GAAW,OAAO;QACnC,KAAK,CAAC,WAAW,OAAO,EAAE,CAAC,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAA;IACvC,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SA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CAAC,CAAA;QAC/B,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC,QAAQ,CAAA;IAC9C,CAAC;CACF;AAED,cAAc,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAA;AAC5C,cAAc,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;AAC9C,cAAc,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA;AACnD,cAAc,CAAC,kBAAkB,CAAC,sBAAsB,CAAC,CAAA;AACzD,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAA;AACrD,cAAc,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAA;AAClD,cAAc,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAA;AACrD,cAAc,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAA;AACrD,aAAa,CAAC,kBAAkB,CAAC,aAAa,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,CAAA"}
|
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;AASlE,eAAO,MAAM,UAAU,
|
|
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;AASlE,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,
|
|
1
|
+
{"version":3,"file":"supervisor.d.ts","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,sBAAsB,cACtB,MAAM,UAAU,MAAM,QAAQ,MAAM,KAC9C;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAmC,CAAA;AAEvF;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
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.
|
|
25
|
+
"@owlmeans/error": "^0.1.17",
|
|
26
26
|
"ajv-formats": "^3.0.1"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@owlmeans/dep-config": "workspace:*",
|
|
33
33
|
"@types/bun": "^1.3.14",
|
|
34
34
|
"nodemon": "^3.1.14",
|
|
35
|
-
"typescript": "^
|
|
35
|
+
"typescript": "^7.0.2"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: "OwlMeans auth protocol rules for Ed25519, OIDC, provider-backed local identity, guards, gates, errors, trust records, and auth test mocking. Use for auth*, *oidc*, server-auth-identity, did, wled, and client-payment package work."
|
|
3
|
-
applyTo: "**/*.ts, **/*.tsx"
|
|
4
|
-
---
|
|
5
|
-
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
6
|
-
|
|
7
|
-
# OwlMeans Auth Protocol — Code Rules
|
|
8
|
-
|
|
9
|
-
Two paths share the same `Auth`, `Authorization`, envelope shape and aliases:
|
|
10
|
-
|
|
11
|
-
- **Ed25519** (self-signed): allowance → credential → token-exchange → bearer `ED25519-BASIC-TOKEN <encoded>` → server-side `makeBasicEd25519Guard` verifies via `trust()` against the `TRUSTED` resource.
|
|
12
|
-
- **OIDC** (delegated): `makeOidcGuard` exchanges OAuth2 code, wraps the result in an `oidc-wrapped-token` envelope.
|
|
13
|
-
- **Provider-backed local identity** (used by product-viable): browser Google/OIDC plugin → server provider exchange → `@owlmeans/server-auth-identity` account/profile/credentials link → normal bearer token → product `GateService` authorizes against local profile scopes.
|
|
14
|
-
|
|
15
|
-
Aliases: `DEFAULT_GUARD = 'auth'`, `GUARD_ED25519 = 'guard:ed25519-basic-signature'`, `OIDC_GATE = 'oidc-gate'`, `AUTH_HEADER = 'authorization'`, `TOKEN_UPDATE = 'auth-token-refresh'`.
|
|
16
|
-
|
|
17
|
-
`AuthRole` is a **string** enum (`User`, `Guest`, `Service`, `System`, `Admin`, `Superuser`, `Blocked`). Never use numeric literals like `role: 0` — always use `AuthRole.User` etc.
|
|
18
|
-
|
|
19
|
-
Guard interface lives in `@owlmeans/entrypoint` (`GuardService` extends `InitializedService`, has `match`, `handle`, `authenticated`). Auth service extends it with `authenticate`, `update`, `user`, `store` (`@owlmeans/auth-common/types.ts`).
|
|
20
|
-
|
|
21
|
-
Envelope shape `{t, msg, sig?, dt, ttl}` from `@owlmeans/basic-envelope`. KeyPairModel `sign/verify/export/exportPublic` from `@owlmeans/basic-keys`.
|
|
22
|
-
|
|
23
|
-
When refactoring:
|
|
24
|
-
|
|
25
|
-
- Don't break the `match`/`handle`/`authenticated`/`unpack` contract — multiple guards rely on it.
|
|
26
|
-
- Trust-record lookups go through `trust(context, resource, userName, field?)`. Don't hard-code resource lookups.
|
|
27
|
-
- Errors must derive from the `@owlmeans/auth/errors` hierarchy (`AuthError`, `AuthenFailed`, `AuthenPayloadError`, `AuthorizationError`, `AuthForbidden`, …) so i18n + normalisation work.
|
|
28
|
-
- Local identity reads must be non-destructive. `Resource.pick()` deletes records; use `load()` or `list()` when checking `AUTH_IDENTITY_PROFILE` in authorization gates.
|
|
29
|
-
- New auth-related test mocks belong in `@owlmeans/test-auth` — not in a per-package `tests/` directory.
|
|
30
|
-
|
|
31
|
-
For the full protocol reference see `.claude/skills/auth-protocol/SKILL.md`.
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: "How to use @owlmeans/auth — core authentication types, errors (AuthUnknown, AuthError), permissions, allowance, rely, and entity primitives. Use when working with request authentication in handlers."
|
|
3
|
-
applyTo: "**/*.ts, **/*.tsx"
|
|
4
|
-
---
|
|
5
|
-
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
6
|
-
|
|
7
|
-
# @owlmeans/auth
|
|
8
|
-
|
|
9
|
-
**Layer:** Core
|
|
10
|
-
**Install:** `"@owlmeans/auth": "^0.1.16-rc.0"` in `dependencies`
|
|
11
|
-
|
|
12
|
-
## Key Exports
|
|
13
|
-
|
|
14
|
-
| Export | Description |
|
|
15
|
-
|--------|-------------|
|
|
16
|
-
| `AuthUnknown` | Error thrown when expected entity/auth is missing on a request |
|
|
17
|
-
| `AuthError` and subclasses | Typed auth errors mapping to HTTP 401/403 |
|
|
18
|
-
| `Auth` types | Request auth payload shape (entityId, scopes, profile) |
|
|
19
|
-
| `Permission` helpers | Check scopes/permissions on a request |
|
|
20
|
-
| `Allowance` helpers | Inspect/grant allowances |
|
|
21
|
-
| `Entity`, `Rely` types | Shared entity-relationship primitives |
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
import { AuthUnknown } from '@owlmeans/auth'
|
|
27
|
-
import { handleRequest } from '@owlmeans/server-app'
|
|
28
|
-
|
|
29
|
-
export const list = handleRequest(async (req, context) => {
|
|
30
|
-
if (req.auth?.entityId == null) throw new AuthUnknown('entity')
|
|
31
|
-
return await (context as Context).project().list({ entityId: req.auth.entityId })
|
|
32
|
-
})
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Product-Viable Usage Notes
|
|
36
|
-
|
|
37
|
-
- `product-viable` handlers use `AuthUnknown('entity')` when a request should be authenticated but lacks `req.auth.entityId`.
|
|
38
|
-
- WebSocket helpers use `Auth`, `AuthToken`, and `AuthenticationStage` to move token-bearing connections into authenticated state.
|
|
39
|
-
- Google/OIDC login ultimately produces a normal `AuthPayload` with `userId`, `profileId`, `entityId`, and `scopes`; `@owlmeans/server-auth-identity` stores that local identity and returns the payload.
|
|
40
|
-
- Authorization failures in gates should use `AuthForbidden`, while missing handler auth/entity state usually uses `AuthUnknown`.
|
|
41
|
-
- Do not put product ownership rules in `@owlmeans/auth`; downstream apps compose `@owlmeans/entrypoint` gates or handler-level entity checks around these core types.
|
|
42
|
-
|
|
43
|
-
## AuthRole enum
|
|
44
|
-
|
|
45
|
-
`AuthRole` is a **string** enum (not numeric). Always use enum members — never assign a number literal to `role`:
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
import { AuthRole } from '@owlmeans/auth'
|
|
49
|
-
|
|
50
|
-
const creds: AuthCredentials = { role: AuthRole.User, ... }
|
|
51
|
-
// WRONG: role: 0
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
Members: `User`, `Guest`, `Service`, `System`, `Admin`, `Superuser`, `Blocked`.
|
|
55
|
-
|
|
56
|
-
## Depends On
|
|
57
|
-
|
|
58
|
-
- `@owlmeans/error` — base error class
|
|
59
|
-
- `@owlmeans/i18n` — translatable error messages
|