@authup/errors 1.0.0-beta.40 → 1.0.0-beta.42

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.
Files changed (45) hide show
  1. package/dist/built-in/auth-header.d.ts +7 -0
  2. package/dist/built-in/auth-header.d.ts.map +1 -0
  3. package/dist/built-in/bad-request.d.ts +7 -0
  4. package/dist/built-in/bad-request.d.ts.map +1 -0
  5. package/dist/built-in/bearer-token.d.ts +6 -0
  6. package/dist/built-in/bearer-token.d.ts.map +1 -0
  7. package/dist/built-in/check.d.ts +19 -0
  8. package/dist/built-in/check.d.ts.map +1 -0
  9. package/dist/built-in/entity-conflict.d.ts +7 -0
  10. package/dist/built-in/entity-conflict.d.ts.map +1 -0
  11. package/dist/built-in/entity-credentials-invalid.d.ts +7 -0
  12. package/dist/built-in/entity-credentials-invalid.d.ts.map +1 -0
  13. package/dist/built-in/entity-inactive.d.ts +7 -0
  14. package/dist/built-in/entity-inactive.d.ts.map +1 -0
  15. package/dist/built-in/entity-not-found.d.ts +7 -0
  16. package/dist/built-in/entity-not-found.d.ts.map +1 -0
  17. package/dist/built-in/index.d.ts +10 -1
  18. package/dist/built-in/index.d.ts.map +1 -1
  19. package/dist/built-in/internal.d.ts +7 -0
  20. package/dist/built-in/internal.d.ts.map +1 -0
  21. package/dist/built-in/unauthorized.d.ts +7 -0
  22. package/dist/built-in/unauthorized.d.ts.map +1 -0
  23. package/dist/check.d.ts +24 -0
  24. package/dist/check.d.ts.map +1 -0
  25. package/dist/constants.d.ts +11 -0
  26. package/dist/constants.d.ts.map +1 -1
  27. package/dist/index.d.mts +178 -842
  28. package/dist/index.d.mts.map +1 -1
  29. package/dist/index.d.ts +6 -1
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.mjs +323 -10
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/module.d.ts +14 -4
  34. package/dist/module.d.ts.map +1 -1
  35. package/dist/normalize.d.ts +11 -0
  36. package/dist/normalize.d.ts.map +1 -0
  37. package/dist/serialize.d.ts +15 -0
  38. package/dist/serialize.d.ts.map +1 -0
  39. package/dist/status.d.ts +32 -0
  40. package/dist/status.d.ts.map +1 -0
  41. package/dist/types.d.ts +8 -4
  42. package/dist/types.d.ts.map +1 -1
  43. package/package.json +2 -2
  44. package/dist/built-in/http.d.ts +0 -6
  45. package/dist/built-in/http.d.ts.map +0 -1
@@ -0,0 +1,32 @@
1
+ import { ErrorCode } from './constants.ts';
2
+ /**
3
+ * Default mapping from `ErrorCode` to HTTP status. Adapters apply this and
4
+ * may layer their own overrides on top. Codes not listed here fall back
5
+ * to 400 (Bad Request) — which is the right default for "validation /
6
+ * malformed-request" style errors.
7
+ *
8
+ * The mapping mirrors the HTTP statuses produced by the pre-refactor
9
+ * `@ebec/http`-coupled error classes, with one intentional change:
10
+ *
11
+ * - `OAUTH_CLIENT_INVALID`: 400 → **401**, per RFC 6749 §5.2 (`invalid_client`
12
+ * responses should use 401). Surfaces as a behavior change in HTTP-level
13
+ * tests asserting `status: 400, code: OAUTH_CLIENT_INVALID`.
14
+ */
15
+ export declare const ERROR_CODE_TO_STATUS: Readonly<Partial<Record<`${ErrorCode}`, number>>>;
16
+ /**
17
+ * Resolve an HTTP status for a given error code. Unknown codes fall back
18
+ * to `fallback` (default 400).
19
+ */
20
+ export declare function httpStatusFromCode(code: string, fallback?: number): number;
21
+ /**
22
+ * Resolve a semantic `ErrorCode` for a foreign HTTP status. Used at the
23
+ * boundary where a non-AuthupError (e.g. `@ebec/http` HTTPError thrown by
24
+ * the framework, or a foreign service response) enters our system and
25
+ * needs to be normalized into an `AuthupError` with an authup-vocabulary
26
+ * code. Status is the only stable handshake across the two vocabularies.
27
+ *
28
+ * Default mapping covers the common HTTP statuses. Anything 5xx
29
+ * collapses to `INTERNAL_ERROR`; unknown 4xx collapses to `BAD_REQUEST`.
30
+ */
31
+ export declare function codeFromHttpStatus(status: number): ErrorCode;
32
+ //# sourceMappingURL=status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC,CAwBlF,CAAC;AAEF;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAM,GAAG,MAAM,CAEvE;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAQ5D"}
package/dist/types.d.ts CHANGED
@@ -1,6 +1,10 @@
1
- import type { Options } from '@ebec/http';
2
- export type AuthupErrorOptions = Options & {
3
- codePrefix?: string;
1
+ import type { ErrorOptions } from '@ebec/core';
2
+ export type AuthupErrorOptions = ErrorOptions & {
3
+ data?: Record<string, any>;
4
4
  };
5
- export type AuthupErrorOptionsInput = AuthupErrorOptions | string | Error;
5
+ export type AuthupErrorInput = string | AuthupErrorOptions;
6
+ export type AuthupEntityErrorOptions = AuthupErrorOptions & {
7
+ entity?: string;
8
+ };
9
+ export type AuthupEntityErrorInput = string | AuthupEntityErrorOptions;
6
10
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG;IACvC,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,kBAAkB,GACxD,MAAM,GACN,KAAK,CAAC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,kBAAkB,CAAC;AAE3D,MAAM,MAAM,wBAAwB,GAAG,kBAAkB,GAAG;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,MAAM,GAAG,wBAAwB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@authup/errors",
3
3
  "type": "module",
4
- "version": "1.0.0-beta.40",
4
+ "version": "1.0.0-beta.42",
5
5
  "description": "Package containing error codes and basic error classes.",
6
6
  "license": "Apache-2.0",
7
7
  "exports": {
@@ -49,7 +49,7 @@
49
49
  },
50
50
  "homepage": "https://github.com/authup/authup#readme",
51
51
  "dependencies": {
52
- "@ebec/http": "^2.3.0",
52
+ "@ebec/core": "^1.1.0",
53
53
  "validup": "^0.2.1"
54
54
  },
55
55
  "publishConfig": {
@@ -1,6 +0,0 @@
1
- import type { AuthorizationHeaderType } from 'hapic';
2
- import { AuthupError } from '../module';
3
- export declare class HTTPError extends AuthupError {
4
- static unsupportedHeaderType(type: `${AuthorizationHeaderType}`): HTTPError;
5
- }
6
- //# sourceMappingURL=http.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/built-in/http.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,qBAAa,SAAU,SAAQ,WAAW;IACtC,MAAM,CAAC,qBAAqB,CAAC,IAAI,EAAE,GAAG,uBAAuB,EAAE;CAMlE"}