@owlmeans/auth 0.1.19-rc.0 → 0.1.20-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -14,7 +14,7 @@ shared auth protocols and organization-entity resolution (`makeEntityScope(req)`
14
14
  ## Installation
15
15
 
16
16
  ```bash
17
- bun add @owlmeans/auth@^0.1.19-rc.0
17
+ bun add @owlmeans/auth@^0.1.20-rc.1
18
18
  ```
19
19
 
20
20
  `ajv` is a **peer** dependency — install it alongside, or `authHelper.verifyAuth` /
@@ -332,7 +332,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
332
332
  your project's skill store (`.agents/skills/`):
333
333
 
334
334
  ```sh
335
- npx @owlmeans/agent-skills@^0.1.19-rc.0
335
+ npx @owlmeans/agent-skills@^0.1.20-rc.1
336
336
  ```
337
337
 
338
338
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 3,
3
3
  "package": "@owlmeans/auth",
4
- "version": "0.1.19-rc.0",
5
- "generatedAt": "2026-10-31T12:13:02.352Z",
4
+ "version": "0.1.20-rc.1",
5
+ "generatedAt": "2026-11-04T18:40:59.845Z",
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.19-rc.0"` in `dependencies`
11
+ **Install:** `"@owlmeans/auth": "^0.1.20-rc.1"` 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
@@ -63,6 +63,7 @@ it.
63
63
  | `AuthManagerError` | The auth manager itself failed |
64
64
  | `AuthManagerUnsupported` | The manager cannot serve this request shape |
65
65
  | `AuthenFailed` | Authentication was attempted and rejected (bad challenge, bad code, bad signature) |
66
+ | `AuthRefused` | A sign-in understood and refused for THIS person — a banned account (`account:disabled`), the app's access blocked (`profile:disabled`), a deployment's own refusal (`new AuthRefused('operator:refused')`). Extends `AuthenFailed` with the same message (`auth:manager:authen:<code>`); declares `httpStatus = 403`, and `@owlmeans/server-api` marks it `X-OwlMeans-Denial: access-denied`, production exposure included |
66
67
  | `AuthenExists` | The identity being registered already exists |
67
68
  | `AuthenPayloadError` | A required credential field is missing |
68
69
  | `AuthPluginError` / `TypeMissmatchError` | A plugin misbehaved / was handed the wrong type |
@@ -145,7 +146,9 @@ Rules of thumb:
145
146
 
146
147
  - A gate that decides "not allowed" throws `AuthForbidden` (403); a handler that finds no identity
147
148
  to act on, or a sign-in naming a method nobody serves, throws `AuthUnknown` (400); a failed
148
- credential check throws `AuthenFailed`. `@owlmeans/server-api` maps the authorization family to
149
+ credential check throws `AuthenFailed`; a sign-in refused for who the person is (retrying with the
150
+ same account changes nothing) throws `AuthRefused`, so a browser can tell it from a failed attempt
151
+ (`loginFailureHelper`, `@owlmeans/client-auth`). `@owlmeans/server-api` maps the authorization family to
149
152
  401/403 before reading a class's declared `httpStatus`, so `AuthUnknown`'s 400 never masks them.
150
153
  - Keep ownership rules out of this package. Downstream apps compose `@owlmeans/entrypoint` gates or
151
154
  handler-level checks around these types.
package/build/errors.d.ts CHANGED
@@ -34,6 +34,23 @@ export declare class AuthenFailed extends AuthManagerError {
34
34
  static typeName: string;
35
35
  constructor(message?: string);
36
36
  }
37
+ /**
38
+ * A sign-in that was understood and is refused for this person — a banned account
39
+ * (`account:disabled`), the app's own access blocked (`profile:disabled`), or a deployment's own
40
+ * refusal (an operator area that admits only its staff). Trying again with the same account changes
41
+ * nothing, which is what a browser has to be able to tell from a failed attempt.
42
+ *
43
+ * Still an {@link AuthenFailed}, with the same message (`auth:manager:authen:<code>`), so every
44
+ * caller that catches or matches a failed sign-in keeps working. It answers 403 (`httpStatus`, read
45
+ * by `@owlmeans/server-api`), and the HTTP boundary marks it `X-OwlMeans-Denial: access-denied`,
46
+ * which survives production exposure where the body is only an incident id. A deployment throws it
47
+ * for its own sign-in refusals: `throw new AuthRefused('operator:refused')`.
48
+ */
49
+ export declare class AuthRefused extends AuthenFailed {
50
+ static typeName: string;
51
+ static httpStatus: number;
52
+ constructor(message?: string);
53
+ }
37
54
  export declare class AuthenExists extends AuthenFailed {
38
55
  static typeName: string;
39
56
  constructor(message?: string);
@@ -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;IAErD,YAAY,OAAO,GAAE,MAAgB,EAEpC;CACF;AAED;;;;;;GAMG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC,OAAuB,QAAQ,EAAE,MAAM,CAAiC;IACxE,OAAc,UAAU,SAAM;IAE9B,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,gBAAiB,SAAQ,SAAS;IAC7C,OAAuB,QAAQ,EAAE,MAAM,CAAqB;IAE5D,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,sFAAsF;AACtF,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,OAAuB,QAAQ,EAAE,MAAM,CAAqC;IAC5E,OAAc,UAAU,SAAM;IAC9B,OAAc,sBAAsB,UAAO;IAE3C,YAAY,OAAO,GAAE,MAAsB,EAG1C;CACF;AAED,qBAAa,sBAAuB,SAAQ,gBAAgB;IAC1D,OAAuB,QAAQ,EAAE,MAAM,CAA4C;IAEnF,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,OAAuB,QAAQ,EAAE,MAAM,CAA6C;IAEpF,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,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YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,kBAAmB,SAAQ,SAAS;IAC/C,OAAuB,QAAQ,EAAE,MAAM,CAAuB;IAE9D,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,aAAc,SAAQ,kBAAkB;IACnD,OAAuB,QAAQ,EAAE,MAAM,CAA4C;IAEnF,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,YAAa,SAAQ,SAAS;IACzC,OAAuB,QAAQ,EAAE,MAAM,CAAiB;IAExD,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF;AAED,qBAAa,uBAAwB,SAAQ,YAAY;IACvD,OAAuB,QAAQ,EAAE,MAAM,CAAwC;IAE/E,YAAY,OAAO,GAAE,MAAgB,EAGpC;CACF"}
package/build/errors.js CHANGED
@@ -51,6 +51,26 @@ export class AuthenFailed extends AuthManagerError {
51
51
  this.type = AuthenFailed.typeName;
52
52
  }
53
53
  }
54
+ /**
55
+ * A sign-in that was understood and is refused for this person — a banned account
56
+ * (`account:disabled`), the app's own access blocked (`profile:disabled`), or a deployment's own
57
+ * refusal (an operator area that admits only its staff). Trying again with the same account changes
58
+ * nothing, which is what a browser has to be able to tell from a failed attempt.
59
+ *
60
+ * Still an {@link AuthenFailed}, with the same message (`auth:manager:authen:<code>`), so every
61
+ * caller that catches or matches a failed sign-in keeps working. It answers 403 (`httpStatus`, read
62
+ * by `@owlmeans/server-api`), and the HTTP boundary marks it `X-OwlMeans-Denial: access-denied`,
63
+ * which survives production exposure where the body is only an incident id. A deployment throws it
64
+ * for its own sign-in refusals: `throw new AuthRefused('operator:refused')`.
65
+ */
66
+ export class AuthRefused extends AuthenFailed {
67
+ static typeName = `${AuthenFailed.typeName}Refused`;
68
+ static httpStatus = 403;
69
+ constructor(message = 'refused') {
70
+ super(message);
71
+ this.type = AuthRefused.typeName;
72
+ }
73
+ }
54
74
  export class AuthenExists extends AuthenFailed {
55
75
  static typeName = `${AuthenFailed.typeName}Exists`;
56
76
  constructor(message = 'error') {
@@ -113,6 +133,7 @@ ResilientError.registerErrorClass(AuthManagerError);
113
133
  ResilientError.registerErrorClass(AuthUnavailable);
114
134
  ResilientError.registerErrorClass(AuthManagerUnsupported);
115
135
  ResilientError.registerErrorClass(AuthenFailed);
136
+ ResilientError.registerErrorClass(AuthRefused);
116
137
  ResilientError.registerErrorClass(AuthenExists);
117
138
  ResilientError.registerErrorClass(AuthenPayloadError);
118
139
  ResilientError.registerErrorClass(AuthPluginError);
@@ -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,OAAO,GAAW,OAAO;QACnC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,OAAO,EAAE,CAAC,CAAA;IAC9C,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,OAAO,WAAY,SAAQ,SAAS;IACjC,MAAM,CAAU,QAAQ,GAAW,GAAG,SAAS,CAAC,QAAQ,SAAS,CAAA;IACjE,MAAM,CAAC,UAAU,GAAG,GAAG,CAAA;IAE9B,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,sFAAsF;AACtF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- "version": "0.1.19-rc.0",
3
+ "version": "0.1.20-rc.1",
4
4
  "license": "MIT",
5
+ "homepage": "https://owlmeans.com/docs/",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/owlmeans/common.git",
9
+ "directory": "packages/auth"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/owlmeans/common/issues"
13
+ },
14
+ "author": "Igor Tkachenko <igor.tkachenko@owlmeans.com> (https://owlmeans.com)",
5
15
  "type": "module",
6
16
  "scripts": {
7
17
  "build": "tsc -b",
@@ -22,14 +32,14 @@
22
32
  }
23
33
  },
24
34
  "dependencies": {
25
- "@owlmeans/error": "^0.1.18",
35
+ "@owlmeans/error": "^0.1.20-rc.1",
26
36
  "ajv-formats": "^3.0.1"
27
37
  },
28
38
  "peerDependencies": {
29
39
  "ajv": "*"
30
40
  },
31
41
  "devDependencies": {
32
- "@owlmeans/dep-config": "^0.1.18",
42
+ "@owlmeans/dep-config": "^0.1.20-rc.1",
33
43
  "@types/bun": "^1.4.4",
34
44
  "nodemon": "^3.1.14",
35
45
  "typescript": "^7.0.2"
package/src/errors.ts CHANGED
@@ -65,6 +65,28 @@ export class AuthenFailed extends AuthManagerError {
65
65
  }
66
66
  }
67
67
 
68
+ /**
69
+ * A sign-in that was understood and is refused for this person — a banned account
70
+ * (`account:disabled`), the app's own access blocked (`profile:disabled`), or a deployment's own
71
+ * refusal (an operator area that admits only its staff). Trying again with the same account changes
72
+ * nothing, which is what a browser has to be able to tell from a failed attempt.
73
+ *
74
+ * Still an {@link AuthenFailed}, with the same message (`auth:manager:authen:<code>`), so every
75
+ * caller that catches or matches a failed sign-in keeps working. It answers 403 (`httpStatus`, read
76
+ * by `@owlmeans/server-api`), and the HTTP boundary marks it `X-OwlMeans-Denial: access-denied`,
77
+ * which survives production exposure where the body is only an incident id. A deployment throws it
78
+ * for its own sign-in refusals: `throw new AuthRefused('operator:refused')`.
79
+ */
80
+ export class AuthRefused extends AuthenFailed {
81
+ public static override typeName: string = `${AuthenFailed.typeName}Refused`
82
+ public static httpStatus = 403
83
+
84
+ constructor(message: string = 'refused') {
85
+ super(message)
86
+ this.type = AuthRefused.typeName
87
+ }
88
+ }
89
+
68
90
  export class AuthenExists extends AuthenFailed {
69
91
  public static override typeName: string = `${AuthenFailed.typeName}Exists`
70
92
 
@@ -143,6 +165,7 @@ ResilientError.registerErrorClass(AuthManagerError)
143
165
  ResilientError.registerErrorClass(AuthUnavailable)
144
166
  ResilientError.registerErrorClass(AuthManagerUnsupported)
145
167
  ResilientError.registerErrorClass(AuthenFailed)
168
+ ResilientError.registerErrorClass(AuthRefused)
146
169
  ResilientError.registerErrorClass(AuthenExists)
147
170
  ResilientError.registerErrorClass(AuthenPayloadError)
148
171
  ResilientError.registerErrorClass(AuthPluginError)
@@ -5,8 +5,10 @@ import {
5
5
  AuthorizationError,
6
6
  AuthenFailed,
7
7
  AuthenPayloadError,
8
+ AuthRefused,
8
9
  AuthUnknown,
9
10
  } from '@owlmeans/auth'
11
+ import { ResilientError } from '@owlmeans/error'
10
12
 
11
13
  describe('@owlmeans/auth — error inheritance chain', () => {
12
14
  // Matches viable-agent/packages/template/packages/backend/src/utils/auth-guard.ts
@@ -68,3 +70,27 @@ describe('@owlmeans/auth — declared HTTP statuses', () => {
68
70
  }
69
71
  })
70
72
  })
73
+
74
+ describe('@owlmeans/auth — AuthRefused', () => {
75
+ // A refused sign-in is still a failed one: every catch and message match keeps working.
76
+ test('is an AuthenFailed with the same `auth:manager:authen:<code>` message', () => {
77
+ const refused = new AuthRefused('account:disabled')
78
+ expect(refused).toBeInstanceOf(AuthRefused)
79
+ expect(refused).toBeInstanceOf(AuthenFailed)
80
+ expect(refused).not.toBeInstanceOf(AuthorizationError)
81
+ expect(refused.message).toBe('auth:manager:authen:account:disabled')
82
+ expect(refused.message).toBe(new AuthenFailed('account:disabled').message)
83
+ expect(refused.type).toBe(AuthRefused.typeName)
84
+ expect(new AuthRefused().message).toBe('auth:manager:authen:refused')
85
+ })
86
+
87
+ // The browser tells a refusal from a failure by its status: 403, never the 500 of a fault.
88
+ test('declares 403 and survives a marshal hop as its own class', () => {
89
+ expect(AuthRefused.httpStatus).toBe(403)
90
+ expect((new AuthenFailed('x').constructor as { httpStatus?: unknown }).httpStatus).toBeUndefined()
91
+
92
+ const back = ResilientError.ensure(ResilientError.marshal(new AuthRefused('operator:refused')))
93
+ expect(back).toBeInstanceOf(AuthRefused)
94
+ expect(back.message).toBe('auth:manager:authen:operator:refused')
95
+ })
96
+ })