@authup/errors 1.0.0-beta.50 → 1.0.0-beta.52
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/dist/constants.d.ts +5 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +6 -22
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -21,9 +21,14 @@ export declare enum ErrorCode {
|
|
|
21
21
|
JWT_EXPIRED = "expired_token",
|
|
22
22
|
OAUTH_REDIRECT_URI_MISMATCH = "redirect_uri_mismatch",
|
|
23
23
|
OAUTH_CLIENT_INVALID = "invalid_client",
|
|
24
|
+
OAUTH_CLIENT_UNAUTHORIZED = "unauthorized_client",
|
|
24
25
|
OAUTH_GRANT_INVALID = "invalid_grant",
|
|
25
26
|
OAUTH_GRANT_TYPE_UNSUPPORTED = "unsupported_token_grant_type",
|
|
26
27
|
OAUTH_REQUEST_INVALID = "invalid_request",
|
|
28
|
+
OAUTH_LOGIN_REQUIRED = "login_required",
|
|
29
|
+
OAUTH_INTERACTION_REQUIRED = "interaction_required",
|
|
30
|
+
OAUTH_ACCOUNT_SELECTION_REQUIRED = "account_selection_required",
|
|
31
|
+
OAUTH_CONSENT_REQUIRED = "consent_required",
|
|
27
32
|
OAUTH_RESPONSE_TYPE_UNSUPPORTED = "unsupported_response_type",
|
|
28
33
|
OAUTH_SCOPE_INVALID = "invalid_scope",
|
|
29
34
|
OAUTH_SCOPE_INSUFFICIENT = "insufficient_scope",
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAOA,oBAAY,SAAS;IAEjB,WAAW,gBAAgB;IAC3B,cAAc,mBAAmB;IAGjC,iCAAiC,iCAAiC;IAClE,2BAA2B,2BAA2B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AAW,kBAAkB;IAG7B,2BAA2B,0BAA0B;IACrD,oBAAoB,mBAAmB;IACvC,yBAAyB,wBAAwB;IACjD,mBAAmB,kBAAkB;IACrC,4BAA4B,iCAAiC;IAC7D,qBAAqB,oBAAoB;IACzC,oBAAoB,mBAAmB;IACvC,0BAA0B,yBAAyB;IACnD,gCAAgC,+BAA+B;IAC/D,sBAAsB,qBAAqB;IAC3C,+BAA+B,8BAA8B;IAC7D,mBAAmB,kBAAkB;IACrC,wBAAwB,uBAAuB;IAG/C,oBAAoB,yBAAyB;IAC7C,iBAAiB,sBAAsB;IACvC,4BAA4B,iCAAiC;IAG7D,0BAA0B,+BAA+B;IACzD,gCAAgC,qCAAqC;IACrE,gCAAgC,qCAAqC;CACxE"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BASE_ERROR_INSTANCE, BaseError, ErrorOptions, INSTANCEOF_PROPERTY, hasInstanceof, markInstanceof } from "@ebec/core";
|
|
2
2
|
import { Issue } from "validup";
|
|
3
|
-
|
|
4
3
|
//#region src/types.d.ts
|
|
5
4
|
type AuthupErrorOptions = ErrorOptions & {
|
|
6
5
|
data?: Record<string, any>;
|
|
@@ -141,9 +140,14 @@ declare enum ErrorCode {
|
|
|
141
140
|
JWT_EXPIRED = "expired_token",
|
|
142
141
|
OAUTH_REDIRECT_URI_MISMATCH = "redirect_uri_mismatch",
|
|
143
142
|
OAUTH_CLIENT_INVALID = "invalid_client",
|
|
143
|
+
OAUTH_CLIENT_UNAUTHORIZED = "unauthorized_client",
|
|
144
144
|
OAUTH_GRANT_INVALID = "invalid_grant",
|
|
145
145
|
OAUTH_GRANT_TYPE_UNSUPPORTED = "unsupported_token_grant_type",
|
|
146
146
|
OAUTH_REQUEST_INVALID = "invalid_request",
|
|
147
|
+
OAUTH_LOGIN_REQUIRED = "login_required",
|
|
148
|
+
OAUTH_INTERACTION_REQUIRED = "interaction_required",
|
|
149
|
+
OAUTH_ACCOUNT_SELECTION_REQUIRED = "account_selection_required",
|
|
150
|
+
OAUTH_CONSENT_REQUIRED = "consent_required",
|
|
147
151
|
OAUTH_RESPONSE_TYPE_UNSUPPORTED = "unsupported_response_type",
|
|
148
152
|
OAUTH_SCOPE_INVALID = "invalid_scope",
|
|
149
153
|
OAUTH_SCOPE_INSUFFICIENT = "insufficient_scope",
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/module.ts","../src/built-in/unauthorized.ts","../src/built-in/auth-header.ts","../src/built-in/bad-request.ts","../src/built-in/bearer-token.ts","../src/built-in/entity-conflict.ts","../src/built-in/entity-credentials-invalid.ts","../src/built-in/entity-inactive.ts","../src/built-in/entity-not-found.ts","../src/built-in/internal.ts","../src/built-in/check.ts","../src/check.ts","../src/constants.ts","../src/normalize.ts","../src/serialize.ts","../src/status.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/module.ts","../src/built-in/unauthorized.ts","../src/built-in/auth-header.ts","../src/built-in/bad-request.ts","../src/built-in/bearer-token.ts","../src/built-in/entity-conflict.ts","../src/built-in/entity-credentials-invalid.ts","../src/built-in/entity-inactive.ts","../src/built-in/entity-not-found.ts","../src/built-in/internal.ts","../src/built-in/check.ts","../src/check.ts","../src/constants.ts","../src/normalize.ts","../src/serialize.ts","../src/status.ts"],"mappings":";;;KASY,qBAAqB;EAC7B,OAAO;;KAGC,4BAA4B;KAE5B,2BAA2B;EACnC;;KAGQ,kCAAkC;;;cCRjC;cAEA,oBAAoB;WACb,QAAQ;WAER,OAAO;cAEX,QAAQ;EAWX;;;;;;;;;;;cCjBA;cAEA,0BAA0B;cACvB,iBAAiB;;;;cCJpB;cAEA,wBAAwB;cACrB;SAQL,gBAAgB,eAAY;;;;cCV1B;cAEA,wBAAwB;cACrB,iBAAiB;;;;cCJpB;cAEA,kCAAkC;cAC/B;;;;cCFH;cAEA,4BAA4B;cACzB,iBAAiB;;;;cCHpB;cAEA,sCAAsC;cACnC,iBAAiB;;;;cCHpB;cAEA,4BAA4B;cACzB,iBAAiB;;;;cCHpB;cAEA,4BAA4B;cACzB,iBAAiB;;;;cCHpB;cAEA,sBAAsB;cACnB,iBAAiB;;;;iBCKjB,kBAAkB,iBAAiB,SAAS;iBAM5C,4BAA4B,iBAAiB,SAAS;iBAMtD,kBAAkB,iBAAiB,SAAS;iBAM5C,oBAAoB,iBAAiB,SAAS;iBAM9C,sBAAsB,iBAAiB,SAAS;iBAMhD,sBAAsB,iBAAiB,SAAS;iBAMhD,sBAAsB,iBAAiB,SAAS;iBAMhD,gCAAgC,iBAAiB,SAAS;iBAM1D,gBAAgB,iBAAiB,SAAS;;;;;;;;;;;;iBC3C1C,QAAQ,iBAAiB,SAAS;;;;;;;;;;;;iBAelC,cAAc,iBAAiB,SAAS;;;aCjC5C;EAER;EACA;EAGA;EACA;EAGA;EAGA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EACA;EAGA;EAGA;EACA;EAGA;EACA;EACA;EAGA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EACA;EAGA;EACA;EACA;;;;;;;;;;;;;iBCjDY,eAAe,iBAAiB;;;;;;;;;;;;;;;;iBCIhC,eAAe,OAAO,QAAQ;;;;;;;;;;;;;;;;cCAjC,sBAAsB,SAAS,QAAQ,UAAU;;;;;iBA8B9C,mBAAmB,cAAc;;;;;;;;;;;iBAcjC,mBAAmB,iBAAiB"}
|
package/dist/index.mjs
CHANGED
|
@@ -23,9 +23,14 @@ let ErrorCode = /* @__PURE__ */ function(ErrorCode) {
|
|
|
23
23
|
ErrorCode["JWT_EXPIRED"] = "expired_token";
|
|
24
24
|
ErrorCode["OAUTH_REDIRECT_URI_MISMATCH"] = "redirect_uri_mismatch";
|
|
25
25
|
ErrorCode["OAUTH_CLIENT_INVALID"] = "invalid_client";
|
|
26
|
+
ErrorCode["OAUTH_CLIENT_UNAUTHORIZED"] = "unauthorized_client";
|
|
26
27
|
ErrorCode["OAUTH_GRANT_INVALID"] = "invalid_grant";
|
|
27
28
|
ErrorCode["OAUTH_GRANT_TYPE_UNSUPPORTED"] = "unsupported_token_grant_type";
|
|
28
29
|
ErrorCode["OAUTH_REQUEST_INVALID"] = "invalid_request";
|
|
30
|
+
ErrorCode["OAUTH_LOGIN_REQUIRED"] = "login_required";
|
|
31
|
+
ErrorCode["OAUTH_INTERACTION_REQUIRED"] = "interaction_required";
|
|
32
|
+
ErrorCode["OAUTH_ACCOUNT_SELECTION_REQUIRED"] = "account_selection_required";
|
|
33
|
+
ErrorCode["OAUTH_CONSENT_REQUIRED"] = "consent_required";
|
|
29
34
|
ErrorCode["OAUTH_RESPONSE_TYPE_UNSUPPORTED"] = "unsupported_response_type";
|
|
30
35
|
ErrorCode["OAUTH_SCOPE_INVALID"] = "invalid_scope";
|
|
31
36
|
ErrorCode["OAUTH_SCOPE_INSUFFICIENT"] = "insufficient_scope";
|
|
@@ -272,27 +277,6 @@ function normalizeError(input) {
|
|
|
272
277
|
if (typeof input === "string") return new Error(input);
|
|
273
278
|
return new Error(String(input));
|
|
274
279
|
}
|
|
275
|
-
[
|
|
276
|
-
"agile amber ancient autumn azure blithe bold brave bright brisk calm clever",
|
|
277
|
-
"cobalt cosmic crimson crystal curious daring dapper eager electric elegant",
|
|
278
|
-
"fancy fearless fluffy gentle gilded golden happy hidden jolly keen lively",
|
|
279
|
-
"lucid lunar mellow merry mighty nimble noble polished proud quiet quick rapid",
|
|
280
|
-
"royal rustic serene shiny silent silver sleek smooth solar spry stellar",
|
|
281
|
-
"sturdy sunny swift tidy vivid witty zesty zealous"
|
|
282
|
-
].join(" ").split(" ");
|
|
283
|
-
[
|
|
284
|
-
"otter falcon willow comet harbor meadow cipher lynx maple heron cedar badger",
|
|
285
|
-
"finch glacier canyon beacon pebble ember birch raven sparrow marten walrus",
|
|
286
|
-
"puffin orchid cypress juniper aspen lotus quartz basalt tundra lagoon reef",
|
|
287
|
-
"delta fjord summit ridge grove thicket mantis cricket beetle newt gecko koala",
|
|
288
|
-
"panda bison moose osprey kestrel magpie robin wren salmon marlin coral kelp",
|
|
289
|
-
"fern moss lichen clover"
|
|
290
|
-
].join(" ").split(" ");
|
|
291
|
-
//#endregion
|
|
292
|
-
//#region ../kit/src/object.ts
|
|
293
|
-
function isObject$1(input) {
|
|
294
|
-
return !!input && typeof input === "object" && !Array.isArray(input);
|
|
295
|
-
}
|
|
296
280
|
//#endregion
|
|
297
281
|
//#region src/serialize.ts
|
|
298
282
|
/**
|
|
@@ -311,7 +295,7 @@ function isObject$1(input) {
|
|
|
311
295
|
function serializeError(input) {
|
|
312
296
|
if ("toJSON" in input && typeof input.toJSON === "function") {
|
|
313
297
|
const output = input.toJSON();
|
|
314
|
-
if (isObject
|
|
298
|
+
if (isObject(output)) return output;
|
|
315
299
|
}
|
|
316
300
|
return {
|
|
317
301
|
...input,
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["isRawError","hasInstanceof","hasInstanceof","isObject","isObject"],"sources":["../src/constants.ts","../src/module.ts","../src/built-in/unauthorized.ts","../src/built-in/auth-header.ts","../src/built-in/bad-request.ts","../src/built-in/bearer-token.ts","../src/check.ts","../src/built-in/entity-conflict.ts","../src/built-in/entity-credentials-invalid.ts","../src/built-in/entity-inactive.ts","../src/built-in/entity-not-found.ts","../src/built-in/internal.ts","../src/built-in/check.ts","../src/normalize.ts","../../kit/src/generate-name.ts","../../kit/src/object.ts","../src/serialize.ts","../src/status.ts"],"sourcesContent":["/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum ErrorCode {\n // Generic\n BAD_REQUEST = 'bad_request',\n INTERNAL_ERROR = 'internal_error',\n\n // HTTP Codes\n HTTP_HEADER_AUTH_TYPE_UNSUPPORTED = 'unsupported_auth_header_type',\n HTTP_BEARER_TOKEN_MALFORMED = 'bearer_token_malformed',\n\n // Identity Auth\n IDENTITY_UNAUTHORIZED = 'identity_unauthorized',\n\n // Entity Codes\n ENTITY_CREDENTIALS_INVALID = 'invalid_credentials',\n ENTITY_INACTIVE = 'entity_inactive',\n ENTITY_NOT_FOUND = 'entity_not_found',\n ENTITY_CONFLICT = 'entity_conflict',\n ENTITY_RELATION_INVALID = 'entity_relation_invalid',\n\n // Identity Codes\n REGISTRATION_DISABLED = 'registration_disabled',\n PASSWORD_RECOVERY_DISABLED = 'password_recovery_disabled',\n EMAIL_VERIFICATION_REQUIRED = 'email_verification_required',\n RESET_TOKEN_EXPIRED = 'reset_token_expired',\n\n // Storage Codes\n STORAGE_INSUFFICIENT = 'storage_insufficient',\n\n // JWK Codes\n JWK_INVALID = 'jwk_invalid',\n JWK_NOT_FOUND = 'jwk_not_found',\n\n // JWT Codes\n JWT_INVALID = 'invalid_token',\n JWT_INACTIVE = 'inactive_token',\n JWT_EXPIRED = 'expired_token',\n\n // Oauth2 Codes\n OAUTH_REDIRECT_URI_MISMATCH = 'redirect_uri_mismatch',\n OAUTH_CLIENT_INVALID = 'invalid_client',\n OAUTH_GRANT_INVALID = 'invalid_grant',\n OAUTH_GRANT_TYPE_UNSUPPORTED = 'unsupported_token_grant_type',\n OAUTH_REQUEST_INVALID = 'invalid_request',\n OAUTH_RESPONSE_TYPE_UNSUPPORTED = 'unsupported_response_type',\n OAUTH_SCOPE_INVALID = 'invalid_scope',\n OAUTH_SCOPE_INSUFFICIENT = 'insufficient_scope',\n\n // Permission Codes\n PERMISSION_NOT_FOUND = 'permission_not_found',\n PERMISSION_DENIED = 'permission_denied',\n PERMISSION_EVALUATION_FAILED = 'permission_evaluation_failed',\n\n // Policy Codes\n POLICY_EVALUATOR_NOT_FOUND = 'policy_evaluator_not_found',\n POLICY_EVALUATOR_NOT_PROCESSABLE = 'policy_evaluator_not_processable',\n POLICY_EVALUATOR_CONTEXT_INVALID = 'policy_evaluator_context_invalid',\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { AuthupErrorInput } from './types.ts';\nimport { BaseError, markInstanceof } from '@ebec/core';\nimport type { Issue } from 'validup';\n\nexport const AUTHUP_ERROR_INSTANCE = Symbol.for('@authup/errors/AuthupError');\n\nexport class AuthupError extends BaseError {\n public readonly issues: Issue[];\n\n public readonly data?: Record<string, any>;\n\n constructor(input?: AuthupErrorInput) {\n super(input);\n markInstanceof(this, AUTHUP_ERROR_INSTANCE);\n\n this.issues = [];\n\n if (input && typeof input !== 'string' && input.data) {\n this.data = input.data;\n }\n }\n\n override toJSON() {\n return {\n ...super.toJSON(),\n issues: this.issues,\n ...(this.data ?? {}),\n };\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupErrorOptions } from '../types.ts';\n\nexport const UNAUTHORIZED_ERROR_INSTANCE = Symbol.for('@authup/errors/UnauthorizedError');\n\nexport class UnauthorizedError extends AuthupError {\n constructor(input?: string | AuthupErrorOptions) {\n const options: AuthupErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n super({\n code: ErrorCode.IDENTITY_UNAUTHORIZED,\n message: 'Authentication required.',\n ...options,\n });\n markInstanceof(this, UNAUTHORIZED_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2022-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { UnauthorizedError } from './unauthorized.ts';\n\nexport const AUTH_HEADER_ERROR_INSTANCE = Symbol.for('@authup/errors/AuthHeaderError');\n\nexport class AuthHeaderError extends UnauthorizedError {\n constructor(message: string) {\n super({\n code: ErrorCode.HTTP_HEADER_AUTH_TYPE_UNSUPPORTED,\n message,\n });\n markInstanceof(this, AUTH_HEADER_ERROR_INSTANCE);\n }\n\n static unsupportedType(type: string) {\n return new AuthHeaderError(`The authorization header type ${type} is not supported.`);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupErrorOptions } from '../types.ts';\n\nexport const BAD_REQUEST_ERROR_INSTANCE = Symbol.for('@authup/errors/BadRequestError');\n\nexport class BadRequestError extends AuthupError {\n constructor(input?: string | AuthupErrorOptions) {\n const options: AuthupErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n super({\n code: ErrorCode.BAD_REQUEST,\n ...options,\n });\n markInstanceof(this, BAD_REQUEST_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2022-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { UnauthorizedError } from './unauthorized.ts';\n\nexport const BEARER_TOKEN_MALFORMED_ERROR_INSTANCE = Symbol.for('@authup/errors/BearerTokenMalformedError');\n\nexport class BearerTokenMalformedError extends UnauthorizedError {\n constructor(message?: string) {\n super({\n code: ErrorCode.HTTP_BEARER_TOKEN_MALFORMED,\n message: message ?? 'The Authorization header is malformed.',\n });\n markInstanceof(this, BEARER_TOKEN_MALFORMED_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n hasInstanceof,\n isBaseError,\n isObject,\n isError as isRawError,\n} from '@ebec/core';\nimport type { AuthupError } from './module.ts';\nimport { AUTHUP_ERROR_INSTANCE } from './module.ts';\n\n/**\n * Duck-type guard for `Error`.\n *\n * Re-exports `@ebec/core`'s shape-based check: `input` matches when it\n * carries the standard `name` / `message` / `stack` triplet, regardless\n * of which realm or class hierarchy produced it. Use this instead of\n * `instanceof Error` for cross-realm boundaries (worker threads,\n * duplicate-module copies) where `instanceof` can yield false negatives.\n */\nexport function isError(input: unknown): input is Error {\n return isRawError(input);\n}\n\n/**\n * Duck-type guard for AuthupError.\n *\n * Fast path: input has the AuthupError marker in its `@instanceof` chain.\n * Subclass instances also accumulate this marker, so this guard matches any\n * AuthupError subclass (`OAuth2Error`, `JWTError`, etc.).\n *\n * Slow path: input is shape-compatible with AuthupError (BaseError + has\n * `issues: Issue[]`). Catches cases where the marker is missing — plain\n * objects rehydrated from JSON, older builds without the marker.\n */\nexport function isAuthupError(input: unknown): input is AuthupError {\n if (hasInstanceof(input, AUTHUP_ERROR_INSTANCE)) {\n return true;\n }\n\n if (!isBaseError(input)) {\n return false;\n }\n\n if (!isObject(input)) {\n return false;\n }\n\n return Array.isArray(input.issues);\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { markInstanceof } from '@ebec/core';\nimport { ErrorCode } from '../constants.ts';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupEntityErrorOptions } from '../types.ts';\n\nexport const ENTITY_CONFLICT_ERROR_INSTANCE = Symbol.for('@authup/errors/EntityConflictError');\n\nexport class EntityConflictError extends AuthupError {\n constructor(input?: string | AuthupEntityErrorOptions) {\n const options: AuthupEntityErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n const { entity, ...rest } = options;\n super({\n code: ErrorCode.ENTITY_CONFLICT,\n message: entity ? `The ${entity} already exists.` : 'Entity already exists.',\n ...rest,\n });\n markInstanceof(this, ENTITY_CONFLICT_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { markInstanceof } from '@ebec/core';\nimport { ErrorCode } from '../constants.ts';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupEntityErrorOptions } from '../types.ts';\n\nexport const ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE = Symbol.for('@authup/errors/EntityCredentialsInvalidError');\n\nexport class EntityCredentialsInvalidError extends AuthupError {\n constructor(input?: string | AuthupEntityErrorOptions) {\n const options: AuthupEntityErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n const { entity, ...rest } = options;\n super({\n code: ErrorCode.ENTITY_CREDENTIALS_INVALID,\n message: entity ? `The ${entity} credentials are invalid.` : 'Credentials are invalid.',\n ...rest,\n });\n markInstanceof(this, ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { markInstanceof } from '@ebec/core';\nimport { ErrorCode } from '../constants.ts';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupEntityErrorOptions } from '../types.ts';\n\nexport const ENTITY_INACTIVE_ERROR_INSTANCE = Symbol.for('@authup/errors/EntityInactiveError');\n\nexport class EntityInactiveError extends AuthupError {\n constructor(input?: string | AuthupEntityErrorOptions) {\n const options: AuthupEntityErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n const { entity, ...rest } = options;\n super({\n code: ErrorCode.ENTITY_INACTIVE,\n message: entity ? `The ${entity} is inactive.` : 'Entity is inactive.',\n ...rest,\n });\n markInstanceof(this, ENTITY_INACTIVE_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { markInstanceof } from '@ebec/core';\nimport { ErrorCode } from '../constants.ts';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupEntityErrorOptions } from '../types.ts';\n\nexport const ENTITY_NOT_FOUND_ERROR_INSTANCE = Symbol.for('@authup/errors/EntityNotFoundError');\n\nexport class EntityNotFoundError extends AuthupError {\n constructor(input?: string | AuthupEntityErrorOptions) {\n const options: AuthupEntityErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n const { entity, ...rest } = options;\n super({\n code: ErrorCode.ENTITY_NOT_FOUND,\n message: entity ? `The ${entity} was not found.` : 'Entity not found.',\n ...rest,\n });\n markInstanceof(this, ENTITY_NOT_FOUND_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupErrorOptions } from '../types.ts';\n\nexport const INTERNAL_ERROR_INSTANCE = Symbol.for('@authup/errors/InternalError');\n\nexport class InternalError extends AuthupError {\n constructor(input?: string | AuthupErrorOptions) {\n const options: AuthupErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n super({\n code: ErrorCode.INTERNAL_ERROR,\n message: 'An internal error occurred.',\n ...options,\n });\n markInstanceof(this, INTERNAL_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isAuthupError } from '../check.ts';\nimport { ErrorCode } from '../constants.ts';\nimport { hasInstanceof } from '@ebec/core';\nimport { AUTH_HEADER_ERROR_INSTANCE, type AuthHeaderError } from './auth-header.ts';\nimport { BAD_REQUEST_ERROR_INSTANCE, type BadRequestError } from './bad-request.ts';\nimport { BEARER_TOKEN_MALFORMED_ERROR_INSTANCE, type BearerTokenMalformedError } from './bearer-token.ts';\nimport { ENTITY_CONFLICT_ERROR_INSTANCE, type EntityConflictError } from './entity-conflict.ts';\nimport { ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE, type EntityCredentialsInvalidError } from './entity-credentials-invalid.ts';\nimport { ENTITY_INACTIVE_ERROR_INSTANCE, type EntityInactiveError } from './entity-inactive.ts';\nimport { ENTITY_NOT_FOUND_ERROR_INSTANCE, type EntityNotFoundError } from './entity-not-found.ts';\nimport { INTERNAL_ERROR_INSTANCE, type InternalError } from './internal.ts';\nimport { UNAUTHORIZED_ERROR_INSTANCE, type UnauthorizedError } from './unauthorized.ts';\n\nexport function isAuthHeaderError(input: unknown): input is AuthHeaderError {\n if (hasInstanceof(input, AUTH_HEADER_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.HTTP_HEADER_AUTH_TYPE_UNSUPPORTED;\n}\n\nexport function isBearerTokenMalformedError(input: unknown): input is BearerTokenMalformedError {\n if (hasInstanceof(input, BEARER_TOKEN_MALFORMED_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.HTTP_BEARER_TOKEN_MALFORMED;\n}\n\nexport function isBadRequestError(input: unknown): input is BadRequestError {\n if (hasInstanceof(input, BAD_REQUEST_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.BAD_REQUEST;\n}\n\nexport function isUnauthorizedError(input: unknown): input is UnauthorizedError {\n if (hasInstanceof(input, UNAUTHORIZED_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.IDENTITY_UNAUTHORIZED;\n}\n\nexport function isEntityNotFoundError(input: unknown): input is EntityNotFoundError {\n if (hasInstanceof(input, ENTITY_NOT_FOUND_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.ENTITY_NOT_FOUND;\n}\n\nexport function isEntityConflictError(input: unknown): input is EntityConflictError {\n if (hasInstanceof(input, ENTITY_CONFLICT_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.ENTITY_CONFLICT;\n}\n\nexport function isEntityInactiveError(input: unknown): input is EntityInactiveError {\n if (hasInstanceof(input, ENTITY_INACTIVE_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.ENTITY_INACTIVE;\n}\n\nexport function isEntityCredentialsInvalidError(input: unknown): input is EntityCredentialsInvalidError {\n if (hasInstanceof(input, ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.ENTITY_CREDENTIALS_INVALID;\n}\n\nexport function isInternalError(input: unknown): input is InternalError {\n if (hasInstanceof(input, INTERNAL_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.INTERNAL_ERROR;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isError } from './check.ts';\n\n/**\n * Normalize an arbitrary thrown value into an `Error` instance.\n *\n * Useful at error-pipeline boundaries (catch blocks, error middleware,\n * fallbacks) where TypeScript hands you `unknown` but downstream code\n * wants a real `Error` to inspect or rethrow. Duck-typed: any value\n * passing `isError` is returned as-is. Strings become `new Error(str)`;\n * any other value is stringified.\n */\nexport function normalizeError(input: unknown): Error {\n if (isError(input)) {\n return input;\n }\n\n if (typeof input === 'string') {\n return new Error(input);\n }\n\n return new Error(String(input));\n}\n\n","/*\n * Copyright (c) 2021-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { slugify } from './slugify';\n\nconst ADJECTIVES = [\n 'agile amber ancient autumn azure blithe bold brave bright brisk calm clever',\n 'cobalt cosmic crimson crystal curious daring dapper eager electric elegant',\n 'fancy fearless fluffy gentle gilded golden happy hidden jolly keen lively',\n 'lucid lunar mellow merry mighty nimble noble polished proud quiet quick rapid',\n 'royal rustic serene shiny silent silver sleek smooth solar spry stellar',\n 'sturdy sunny swift tidy vivid witty zesty zealous',\n].join(' ').split(' ');\n\nconst NOUNS = [\n 'otter falcon willow comet harbor meadow cipher lynx maple heron cedar badger',\n 'finch glacier canyon beacon pebble ember birch raven sparrow marten walrus',\n 'puffin orchid cypress juniper aspen lotus quartz basalt tundra lagoon reef',\n 'delta fjord summit ridge grove thicket mantis cricket beetle newt gecko koala',\n 'panda bison moose osprey kestrel magpie robin wren salmon marlin coral kelp',\n 'fern moss lichen clover',\n].join(' ').split(' ');\n\nfunction pick(list: readonly string[], rand: () => number): string {\n return list[Math.floor(rand() * list.length)] ?? '';\n}\n\nfunction hashSeed(seed: string): number {\n let h = 0x811c9dc5;\n for (let i = 0; i < seed.length; i++) {\n h ^= seed.charCodeAt(i);\n h = Math.imul(h, 0x01000193);\n }\n return h >>> 0;\n}\n\nfunction mulberry32(seed: number): () => number {\n let state = seed;\n return () => {\n state |= 0;\n state = (state + 0x6d2b79f5) | 0;\n let t = Math.imul(state ^ (state >>> 15), 1 | state);\n t ^= t + Math.imul(t ^ (t >>> 7), 61 | t);\n return ((t ^ (t >>> 14)) >>> 0) / 0x100000000;\n };\n}\n\n/**\n * Generate a human-friendly, URL-friendly name, e.g. `brave-otter-1a2b3c`.\n *\n * The trailing random hex suffix keeps generated names readable while making\n * collisions practically irrelevant. The result always satisfies the slug\n * charset (`[a-z0-9-]`) and stays within 128 characters.\n *\n * Passing a `seed` makes the result deterministic for that seed — feed a\n * hydration-stable value (e.g. Vue's `useId()`) to produce the same name on\n * the SSR and client render passes and avoid a hydration mismatch.\n */\nexport function generateName(seed?: string): string {\n const rand = typeof seed === 'undefined' ?\n Math.random :\n mulberry32(hashSeed(seed));\n\n const suffix = Math.floor(rand() * 0x1000000)\n .toString(16)\n .padStart(6, '0');\n\n return slugify(`${pick(ADJECTIVES, rand)}-${pick(NOUNS, rand)}-${suffix}`).slice(0, 128);\n}\n","/*\n * Copyright (c) 2023-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { ObjectLiteral } from './types';\n\nexport function isObject(input: unknown) : input is Record<string, any> {\n return !!input &&\n typeof input === 'object' &&\n !Array.isArray(input);\n}\n\nexport function extendObject<T extends Record<string, any>>(\n target: T,\n source: Partial<T>,\n) : T {\n const keys = Object.keys(source);\n for (const key of keys) {\n target[key as keyof T] = source[key] as T[keyof T];\n }\n\n return target;\n}\n\nexport function flattenObject(input: Record<string, any>) : Record<string, any> {\n const output : Record<string, any> = {};\n\n const keys = Object.keys(input);\n for (const key of keys) {\n const value = input[key];\n if (isObject(value)) {\n const childAttributes = flattenObject(value);\n const childAttributeKeys = Object.keys(childAttributes);\n for (const childAttributeKey of childAttributeKeys) {\n output[`${key}.${childAttributeKey}`] = childAttributes[childAttributeKey];\n }\n\n continue;\n }\n\n output[key] = input[key];\n }\n\n return output;\n}\n\nexport function removeObjectProperty<T extends ObjectLiteral>(input: Partial<T>, key: keyof T) {\n delete input[key];\n}\n\nexport function omitObjectProperties<\n T extends ObjectLiteral,\n>(input: Record<string, any>, excludeKeys: (keyof T)[]): T {\n const output : T = {} as T;\n const keys = Object.keys(input);\n\n for (const key of keys) {\n if (excludeKeys.includes(key)) {\n continue;\n }\n\n output[key as keyof T] = input[key] as T[keyof T];\n }\n\n return output;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '@authup/kit';\n\n/**\n * Convert an `Error` (or any value with a `toJSON()` method) into a\n * plain object suitable for embedding in a JSON response body.\n *\n * Calls `input.toJSON()` if present — preserves every attribute the\n * error chose to surface (`code`, `cause`, `errors`, `issues`, `data`,\n * AuthupError sub-class fields, ...). Falls back to spreading the\n * Error's enumerable own properties alongside the standard\n * `name` / `message` pair, so caller-attached fields survive.\n *\n * Pair with `normalizeError` to handle arbitrary thrown values:\n * `serializeError(normalizeError(e))`.\n */\nexport function serializeError(input: Error): Record<string, any> {\n if ('toJSON' in input && typeof input.toJSON === 'function') {\n const output = input.toJSON();\n if (isObject(output)) {\n return output;\n }\n }\n\n return {\n ...input,\n name: input.name,\n message: input.message,\n };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from './constants.ts';\n\n/**\n * Default mapping from `ErrorCode` to HTTP status. Adapters apply this and\n * may layer their own overrides on top. Codes not listed here fall back\n * to 400 (Bad Request) — which is the right default for \"validation /\n * malformed-request\" style errors.\n *\n * The mapping mirrors the HTTP statuses produced by the pre-refactor\n * `@ebec/http`-coupled error classes, with one intentional change:\n *\n * - `OAUTH_CLIENT_INVALID`: 400 → **401**, per RFC 6749 §5.2 (`invalid_client`\n * responses should use 401). Surfaces as a behavior change in HTTP-level\n * tests asserting `status: 400, code: OAUTH_CLIENT_INVALID`.\n */\nexport const ERROR_CODE_TO_STATUS: Readonly<Partial<Record<`${ErrorCode}`, number>>> = {\n // 401\n [ErrorCode.OAUTH_CLIENT_INVALID]: 401,\n [ErrorCode.HTTP_BEARER_TOKEN_MALFORMED]: 401,\n [ErrorCode.HTTP_HEADER_AUTH_TYPE_UNSUPPORTED]: 401,\n [ErrorCode.IDENTITY_UNAUTHORIZED]: 401,\n\n // 403\n [ErrorCode.PERMISSION_NOT_FOUND]: 403,\n [ErrorCode.PERMISSION_DENIED]: 403,\n [ErrorCode.PERMISSION_EVALUATION_FAILED]: 403,\n\n // 404\n [ErrorCode.ENTITY_NOT_FOUND]: 404,\n [ErrorCode.JWK_NOT_FOUND]: 404,\n\n // 409\n [ErrorCode.ENTITY_CONFLICT]: 409,\n\n // 500\n [ErrorCode.INTERNAL_ERROR]: 500,\n\n // 507\n [ErrorCode.STORAGE_INSUFFICIENT]: 507,\n};\n\n/**\n * Resolve an HTTP status for a given error code. Unknown codes fall back\n * to `fallback` (default 400).\n */\nexport function httpStatusFromCode(code: string, fallback = 400): number {\n return ERROR_CODE_TO_STATUS[code as `${ErrorCode}`] ?? fallback;\n}\n\n/**\n * Resolve a semantic `ErrorCode` for a foreign HTTP status. Used at the\n * boundary where a non-AuthupError (e.g. `@ebec/http` HTTPError thrown by\n * the framework, or a foreign service response) enters our system and\n * needs to be normalized into an `AuthupError` with an authup-vocabulary\n * code. Status is the only stable handshake across the two vocabularies.\n *\n * Default mapping covers the common HTTP statuses. Anything 5xx\n * collapses to `INTERNAL_ERROR`; unknown 4xx collapses to `BAD_REQUEST`.\n */\nexport function codeFromHttpStatus(status: number): ErrorCode {\n if (status === 404) return ErrorCode.ENTITY_NOT_FOUND;\n if (status === 409) return ErrorCode.ENTITY_CONFLICT;\n if (status === 401) return ErrorCode.IDENTITY_UNAUTHORIZED;\n if (status === 403) return ErrorCode.PERMISSION_DENIED;\n if (status === 507) return ErrorCode.STORAGE_INSUFFICIENT;\n if (status >= 500) return ErrorCode.INTERNAL_ERROR;\n return ErrorCode.BAD_REQUEST;\n}\n"],"mappings":";;AAOA,IAAY,YAAL,yBAAA,WAAA;CAEH,UAAA,iBAAA;CACA,UAAA,oBAAA;CAGA,UAAA,uCAAA;CACA,UAAA,iCAAA;CAGA,UAAA,2BAAA;CAGA,UAAA,gCAAA;CACA,UAAA,qBAAA;CACA,UAAA,sBAAA;CACA,UAAA,qBAAA;CACA,UAAA,6BAAA;CAGA,UAAA,2BAAA;CACA,UAAA,gCAAA;CACA,UAAA,iCAAA;CACA,UAAA,yBAAA;CAGA,UAAA,0BAAA;CAGA,UAAA,iBAAA;CACA,UAAA,mBAAA;CAGA,UAAA,iBAAA;CACA,UAAA,kBAAA;CACA,UAAA,iBAAA;CAGA,UAAA,iCAAA;CACA,UAAA,0BAAA;CACA,UAAA,yBAAA;CACA,UAAA,kCAAA;CACA,UAAA,2BAAA;CACA,UAAA,qCAAA;CACA,UAAA,y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AAK,GAAG,CAAC,CAAC,MAAM,GAAG;;;AChBrB,SAAgBC,WAAS,OAA+C;CACpE,OAAO,CAAC,CAAC,SACL,OAAO,UAAU,YACjB,CAAC,MAAM,QAAQ,KAAK;AAC5B;;;;;;;;;;;;;;;;ACSA,SAAgB,eAAe,OAAmC;CAC9D,IAAI,YAAY,SAAS,OAAO,MAAM,WAAW,YAAY;EACzD,MAAM,SAAS,MAAM,OAAO;EAC5B,IAAIC,WAAS,MAAM,GACf,OAAO;CAEf;CAEA,OAAO;EACH,GAAG;EACH,MAAM,MAAM;EACZ,SAAS,MAAM;CACnB;AACJ;;;;;;;;;;;;;;;;ACbA,MAAa,uBAA0E;qBAEjD;6BACO;mCACM;4BACZ;2BAGD;wBACH;mCACW;uBAGZ;oBACH;sBAGE;qBAGD;2BAGM;AACtC;;;;;AAMA,SAAgB,mBAAmB,MAAc,WAAW,KAAa;CACrE,OAAO,qBAAqB,SAA2B;AAC3D;;;;;;;;;;;AAYA,SAAgB,mBAAmB,QAA2B;CAC1D,IAAI,WAAW,KAAK,OAAA;CACpB,IAAI,WAAW,KAAK,OAAA;CACpB,IAAI,WAAW,KAAK,OAAA;CACpB,IAAI,WAAW,KAAK,OAAA;CACpB,IAAI,WAAW,KAAK,OAAA;CACpB,IAAI,UAAU,KAAK,OAAA;CACnB,OAAA;AACJ"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["isRawError","hasInstanceof","hasInstanceof"],"sources":["../src/constants.ts","../src/module.ts","../src/built-in/unauthorized.ts","../src/built-in/auth-header.ts","../src/built-in/bad-request.ts","../src/built-in/bearer-token.ts","../src/check.ts","../src/built-in/entity-conflict.ts","../src/built-in/entity-credentials-invalid.ts","../src/built-in/entity-inactive.ts","../src/built-in/entity-not-found.ts","../src/built-in/internal.ts","../src/built-in/check.ts","../src/normalize.ts","../src/serialize.ts","../src/status.ts"],"sourcesContent":["/*\n * Copyright (c) 2022-2024.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum ErrorCode {\n // Generic\n BAD_REQUEST = 'bad_request',\n INTERNAL_ERROR = 'internal_error',\n\n // HTTP Codes\n HTTP_HEADER_AUTH_TYPE_UNSUPPORTED = 'unsupported_auth_header_type',\n HTTP_BEARER_TOKEN_MALFORMED = 'bearer_token_malformed',\n\n // Identity Auth\n IDENTITY_UNAUTHORIZED = 'identity_unauthorized',\n\n // Entity Codes\n ENTITY_CREDENTIALS_INVALID = 'invalid_credentials',\n ENTITY_INACTIVE = 'entity_inactive',\n ENTITY_NOT_FOUND = 'entity_not_found',\n ENTITY_CONFLICT = 'entity_conflict',\n ENTITY_RELATION_INVALID = 'entity_relation_invalid',\n\n // Identity Codes\n REGISTRATION_DISABLED = 'registration_disabled',\n PASSWORD_RECOVERY_DISABLED = 'password_recovery_disabled',\n EMAIL_VERIFICATION_REQUIRED = 'email_verification_required',\n RESET_TOKEN_EXPIRED = 'reset_token_expired',\n\n // Storage Codes\n STORAGE_INSUFFICIENT = 'storage_insufficient',\n\n // JWK Codes\n JWK_INVALID = 'jwk_invalid',\n JWK_NOT_FOUND = 'jwk_not_found',\n\n // JWT Codes\n JWT_INVALID = 'invalid_token',\n JWT_INACTIVE = 'inactive_token',\n JWT_EXPIRED = 'expired_token',\n\n // Oauth2 Codes\n OAUTH_REDIRECT_URI_MISMATCH = 'redirect_uri_mismatch',\n OAUTH_CLIENT_INVALID = 'invalid_client',\n OAUTH_CLIENT_UNAUTHORIZED = 'unauthorized_client',\n OAUTH_GRANT_INVALID = 'invalid_grant',\n OAUTH_GRANT_TYPE_UNSUPPORTED = 'unsupported_token_grant_type',\n OAUTH_REQUEST_INVALID = 'invalid_request',\n OAUTH_LOGIN_REQUIRED = 'login_required',\n OAUTH_INTERACTION_REQUIRED = 'interaction_required',\n OAUTH_ACCOUNT_SELECTION_REQUIRED = 'account_selection_required',\n OAUTH_CONSENT_REQUIRED = 'consent_required',\n OAUTH_RESPONSE_TYPE_UNSUPPORTED = 'unsupported_response_type',\n OAUTH_SCOPE_INVALID = 'invalid_scope',\n OAUTH_SCOPE_INSUFFICIENT = 'insufficient_scope',\n\n // Permission Codes\n PERMISSION_NOT_FOUND = 'permission_not_found',\n PERMISSION_DENIED = 'permission_denied',\n PERMISSION_EVALUATION_FAILED = 'permission_evaluation_failed',\n\n // Policy Codes\n POLICY_EVALUATOR_NOT_FOUND = 'policy_evaluator_not_found',\n POLICY_EVALUATOR_NOT_PROCESSABLE = 'policy_evaluator_not_processable',\n POLICY_EVALUATOR_CONTEXT_INVALID = 'policy_evaluator_context_invalid',\n}\n","/*\n * Copyright (c) 2024-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { AuthupErrorInput } from './types.ts';\nimport { BaseError, markInstanceof } from '@ebec/core';\nimport type { Issue } from 'validup';\n\nexport const AUTHUP_ERROR_INSTANCE = Symbol.for('@authup/errors/AuthupError');\n\nexport class AuthupError extends BaseError {\n public readonly issues: Issue[];\n\n public readonly data?: Record<string, any>;\n\n constructor(input?: AuthupErrorInput) {\n super(input);\n markInstanceof(this, AUTHUP_ERROR_INSTANCE);\n\n this.issues = [];\n\n if (input && typeof input !== 'string' && input.data) {\n this.data = input.data;\n }\n }\n\n override toJSON() {\n return {\n ...super.toJSON(),\n issues: this.issues,\n ...(this.data ?? {}),\n };\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupErrorOptions } from '../types.ts';\n\nexport const UNAUTHORIZED_ERROR_INSTANCE = Symbol.for('@authup/errors/UnauthorizedError');\n\nexport class UnauthorizedError extends AuthupError {\n constructor(input?: string | AuthupErrorOptions) {\n const options: AuthupErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n super({\n code: ErrorCode.IDENTITY_UNAUTHORIZED,\n message: 'Authentication required.',\n ...options,\n });\n markInstanceof(this, UNAUTHORIZED_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2022-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { UnauthorizedError } from './unauthorized.ts';\n\nexport const AUTH_HEADER_ERROR_INSTANCE = Symbol.for('@authup/errors/AuthHeaderError');\n\nexport class AuthHeaderError extends UnauthorizedError {\n constructor(message: string) {\n super({\n code: ErrorCode.HTTP_HEADER_AUTH_TYPE_UNSUPPORTED,\n message,\n });\n markInstanceof(this, AUTH_HEADER_ERROR_INSTANCE);\n }\n\n static unsupportedType(type: string) {\n return new AuthHeaderError(`The authorization header type ${type} is not supported.`);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupErrorOptions } from '../types.ts';\n\nexport const BAD_REQUEST_ERROR_INSTANCE = Symbol.for('@authup/errors/BadRequestError');\n\nexport class BadRequestError extends AuthupError {\n constructor(input?: string | AuthupErrorOptions) {\n const options: AuthupErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n super({\n code: ErrorCode.BAD_REQUEST,\n ...options,\n });\n markInstanceof(this, BAD_REQUEST_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2022-2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { UnauthorizedError } from './unauthorized.ts';\n\nexport const BEARER_TOKEN_MALFORMED_ERROR_INSTANCE = Symbol.for('@authup/errors/BearerTokenMalformedError');\n\nexport class BearerTokenMalformedError extends UnauthorizedError {\n constructor(message?: string) {\n super({\n code: ErrorCode.HTTP_BEARER_TOKEN_MALFORMED,\n message: message ?? 'The Authorization header is malformed.',\n });\n markInstanceof(this, BEARER_TOKEN_MALFORMED_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport {\n hasInstanceof,\n isBaseError,\n isObject,\n isError as isRawError,\n} from '@ebec/core';\nimport type { AuthupError } from './module.ts';\nimport { AUTHUP_ERROR_INSTANCE } from './module.ts';\n\n/**\n * Duck-type guard for `Error`.\n *\n * Re-exports `@ebec/core`'s shape-based check: `input` matches when it\n * carries the standard `name` / `message` / `stack` triplet, regardless\n * of which realm or class hierarchy produced it. Use this instead of\n * `instanceof Error` for cross-realm boundaries (worker threads,\n * duplicate-module copies) where `instanceof` can yield false negatives.\n */\nexport function isError(input: unknown): input is Error {\n return isRawError(input);\n}\n\n/**\n * Duck-type guard for AuthupError.\n *\n * Fast path: input has the AuthupError marker in its `@instanceof` chain.\n * Subclass instances also accumulate this marker, so this guard matches any\n * AuthupError subclass (`OAuth2Error`, `JWTError`, etc.).\n *\n * Slow path: input is shape-compatible with AuthupError (BaseError + has\n * `issues: Issue[]`). Catches cases where the marker is missing — plain\n * objects rehydrated from JSON, older builds without the marker.\n */\nexport function isAuthupError(input: unknown): input is AuthupError {\n if (hasInstanceof(input, AUTHUP_ERROR_INSTANCE)) {\n return true;\n }\n\n if (!isBaseError(input)) {\n return false;\n }\n\n if (!isObject(input)) {\n return false;\n }\n\n return Array.isArray(input.issues);\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { markInstanceof } from '@ebec/core';\nimport { ErrorCode } from '../constants.ts';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupEntityErrorOptions } from '../types.ts';\n\nexport const ENTITY_CONFLICT_ERROR_INSTANCE = Symbol.for('@authup/errors/EntityConflictError');\n\nexport class EntityConflictError extends AuthupError {\n constructor(input?: string | AuthupEntityErrorOptions) {\n const options: AuthupEntityErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n const { entity, ...rest } = options;\n super({\n code: ErrorCode.ENTITY_CONFLICT,\n message: entity ? `The ${entity} already exists.` : 'Entity already exists.',\n ...rest,\n });\n markInstanceof(this, ENTITY_CONFLICT_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { markInstanceof } from '@ebec/core';\nimport { ErrorCode } from '../constants.ts';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupEntityErrorOptions } from '../types.ts';\n\nexport const ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE = Symbol.for('@authup/errors/EntityCredentialsInvalidError');\n\nexport class EntityCredentialsInvalidError extends AuthupError {\n constructor(input?: string | AuthupEntityErrorOptions) {\n const options: AuthupEntityErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n const { entity, ...rest } = options;\n super({\n code: ErrorCode.ENTITY_CREDENTIALS_INVALID,\n message: entity ? `The ${entity} credentials are invalid.` : 'Credentials are invalid.',\n ...rest,\n });\n markInstanceof(this, ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { markInstanceof } from '@ebec/core';\nimport { ErrorCode } from '../constants.ts';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupEntityErrorOptions } from '../types.ts';\n\nexport const ENTITY_INACTIVE_ERROR_INSTANCE = Symbol.for('@authup/errors/EntityInactiveError');\n\nexport class EntityInactiveError extends AuthupError {\n constructor(input?: string | AuthupEntityErrorOptions) {\n const options: AuthupEntityErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n const { entity, ...rest } = options;\n super({\n code: ErrorCode.ENTITY_INACTIVE,\n message: entity ? `The ${entity} is inactive.` : 'Entity is inactive.',\n ...rest,\n });\n markInstanceof(this, ENTITY_INACTIVE_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { markInstanceof } from '@ebec/core';\nimport { ErrorCode } from '../constants.ts';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupEntityErrorOptions } from '../types.ts';\n\nexport const ENTITY_NOT_FOUND_ERROR_INSTANCE = Symbol.for('@authup/errors/EntityNotFoundError');\n\nexport class EntityNotFoundError extends AuthupError {\n constructor(input?: string | AuthupEntityErrorOptions) {\n const options: AuthupEntityErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n const { entity, ...rest } = options;\n super({\n code: ErrorCode.ENTITY_NOT_FOUND,\n message: entity ? `The ${entity} was not found.` : 'Entity not found.',\n ...rest,\n });\n markInstanceof(this, ENTITY_NOT_FOUND_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from '../constants.ts';\nimport { markInstanceof } from '@ebec/core';\nimport { AuthupError } from '../module.ts';\nimport type { AuthupErrorOptions } from '../types.ts';\n\nexport const INTERNAL_ERROR_INSTANCE = Symbol.for('@authup/errors/InternalError');\n\nexport class InternalError extends AuthupError {\n constructor(input?: string | AuthupErrorOptions) {\n const options: AuthupErrorOptions = typeof input === 'string' ? { message: input } : (input ?? {});\n super({\n code: ErrorCode.INTERNAL_ERROR,\n message: 'An internal error occurred.',\n ...options,\n });\n markInstanceof(this, INTERNAL_ERROR_INSTANCE);\n }\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isAuthupError } from '../check.ts';\nimport { ErrorCode } from '../constants.ts';\nimport { hasInstanceof } from '@ebec/core';\nimport { AUTH_HEADER_ERROR_INSTANCE, type AuthHeaderError } from './auth-header.ts';\nimport { BAD_REQUEST_ERROR_INSTANCE, type BadRequestError } from './bad-request.ts';\nimport { BEARER_TOKEN_MALFORMED_ERROR_INSTANCE, type BearerTokenMalformedError } from './bearer-token.ts';\nimport { ENTITY_CONFLICT_ERROR_INSTANCE, type EntityConflictError } from './entity-conflict.ts';\nimport { ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE, type EntityCredentialsInvalidError } from './entity-credentials-invalid.ts';\nimport { ENTITY_INACTIVE_ERROR_INSTANCE, type EntityInactiveError } from './entity-inactive.ts';\nimport { ENTITY_NOT_FOUND_ERROR_INSTANCE, type EntityNotFoundError } from './entity-not-found.ts';\nimport { INTERNAL_ERROR_INSTANCE, type InternalError } from './internal.ts';\nimport { UNAUTHORIZED_ERROR_INSTANCE, type UnauthorizedError } from './unauthorized.ts';\n\nexport function isAuthHeaderError(input: unknown): input is AuthHeaderError {\n if (hasInstanceof(input, AUTH_HEADER_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.HTTP_HEADER_AUTH_TYPE_UNSUPPORTED;\n}\n\nexport function isBearerTokenMalformedError(input: unknown): input is BearerTokenMalformedError {\n if (hasInstanceof(input, BEARER_TOKEN_MALFORMED_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.HTTP_BEARER_TOKEN_MALFORMED;\n}\n\nexport function isBadRequestError(input: unknown): input is BadRequestError {\n if (hasInstanceof(input, BAD_REQUEST_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.BAD_REQUEST;\n}\n\nexport function isUnauthorizedError(input: unknown): input is UnauthorizedError {\n if (hasInstanceof(input, UNAUTHORIZED_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.IDENTITY_UNAUTHORIZED;\n}\n\nexport function isEntityNotFoundError(input: unknown): input is EntityNotFoundError {\n if (hasInstanceof(input, ENTITY_NOT_FOUND_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.ENTITY_NOT_FOUND;\n}\n\nexport function isEntityConflictError(input: unknown): input is EntityConflictError {\n if (hasInstanceof(input, ENTITY_CONFLICT_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.ENTITY_CONFLICT;\n}\n\nexport function isEntityInactiveError(input: unknown): input is EntityInactiveError {\n if (hasInstanceof(input, ENTITY_INACTIVE_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.ENTITY_INACTIVE;\n}\n\nexport function isEntityCredentialsInvalidError(input: unknown): input is EntityCredentialsInvalidError {\n if (hasInstanceof(input, ENTITY_CREDENTIALS_INVALID_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.ENTITY_CREDENTIALS_INVALID;\n}\n\nexport function isInternalError(input: unknown): input is InternalError {\n if (hasInstanceof(input, INTERNAL_ERROR_INSTANCE)) return true;\n if (!isAuthupError(input)) return false;\n return input.code === ErrorCode.INTERNAL_ERROR;\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isError } from './check.ts';\n\n/**\n * Normalize an arbitrary thrown value into an `Error` instance.\n *\n * Useful at error-pipeline boundaries (catch blocks, error middleware,\n * fallbacks) where TypeScript hands you `unknown` but downstream code\n * wants a real `Error` to inspect or rethrow. Duck-typed: any value\n * passing `isError` is returned as-is. Strings become `new Error(str)`;\n * any other value is stringified.\n */\nexport function normalizeError(input: unknown): Error {\n if (isError(input)) {\n return input;\n }\n\n if (typeof input === 'string') {\n return new Error(input);\n }\n\n return new Error(String(input));\n}\n\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { isObject } from '@ebec/core';\n\n/**\n * Convert an `Error` (or any value with a `toJSON()` method) into a\n * plain object suitable for embedding in a JSON response body.\n *\n * Calls `input.toJSON()` if present — preserves every attribute the\n * error chose to surface (`code`, `cause`, `errors`, `issues`, `data`,\n * AuthupError sub-class fields, ...). Falls back to spreading the\n * Error's enumerable own properties alongside the standard\n * `name` / `message` pair, so caller-attached fields survive.\n *\n * Pair with `normalizeError` to handle arbitrary thrown values:\n * `serializeError(normalizeError(e))`.\n */\nexport function serializeError(input: Error): Record<string, any> {\n if ('toJSON' in input && typeof input.toJSON === 'function') {\n const output = input.toJSON();\n if (isObject(output)) {\n return output;\n }\n }\n\n return {\n ...input,\n name: input.name,\n message: input.message,\n };\n}\n","/*\n * Copyright (c) 2026.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { ErrorCode } from './constants.ts';\n\n/**\n * Default mapping from `ErrorCode` to HTTP status. Adapters apply this and\n * may layer their own overrides on top. Codes not listed here fall back\n * to 400 (Bad Request) — which is the right default for \"validation /\n * malformed-request\" style errors.\n *\n * The mapping mirrors the HTTP statuses produced by the pre-refactor\n * `@ebec/http`-coupled error classes, with one intentional change:\n *\n * - `OAUTH_CLIENT_INVALID`: 400 → **401**, per RFC 6749 §5.2 (`invalid_client`\n * responses should use 401). Surfaces as a behavior change in HTTP-level\n * tests asserting `status: 400, code: OAUTH_CLIENT_INVALID`.\n */\nexport const ERROR_CODE_TO_STATUS: Readonly<Partial<Record<`${ErrorCode}`, number>>> = {\n // 401\n [ErrorCode.OAUTH_CLIENT_INVALID]: 401,\n [ErrorCode.HTTP_BEARER_TOKEN_MALFORMED]: 401,\n [ErrorCode.HTTP_HEADER_AUTH_TYPE_UNSUPPORTED]: 401,\n [ErrorCode.IDENTITY_UNAUTHORIZED]: 401,\n\n // 403\n [ErrorCode.PERMISSION_NOT_FOUND]: 403,\n [ErrorCode.PERMISSION_DENIED]: 403,\n [ErrorCode.PERMISSION_EVALUATION_FAILED]: 403,\n\n // 404\n [ErrorCode.ENTITY_NOT_FOUND]: 404,\n [ErrorCode.JWK_NOT_FOUND]: 404,\n\n // 409\n [ErrorCode.ENTITY_CONFLICT]: 409,\n\n // 500\n [ErrorCode.INTERNAL_ERROR]: 500,\n\n // 507\n [ErrorCode.STORAGE_INSUFFICIENT]: 507,\n};\n\n/**\n * Resolve an HTTP status for a given error code. Unknown codes fall back\n * to `fallback` (default 400).\n */\nexport function httpStatusFromCode(code: string, fallback = 400): number {\n return ERROR_CODE_TO_STATUS[code as `${ErrorCode}`] ?? fallback;\n}\n\n/**\n * Resolve a semantic `ErrorCode` for a foreign HTTP status. Used at the\n * boundary where a non-AuthupError (e.g. `@ebec/http` HTTPError thrown by\n * the framework, or a foreign service response) enters our system and\n * needs to be normalized into an `AuthupError` with an authup-vocabulary\n * code. Status is the only stable handshake across the two vocabularies.\n *\n * Default mapping covers the common HTTP statuses. Anything 5xx\n * collapses to `INTERNAL_ERROR`; unknown 4xx collapses to `BAD_REQUEST`.\n */\nexport function codeFromHttpStatus(status: number): ErrorCode {\n if (status === 404) return ErrorCode.ENTITY_NOT_FOUND;\n if (status === 409) return ErrorCode.ENTITY_CONFLICT;\n if (status === 401) return ErrorCode.IDENTITY_UNAUTHORIZED;\n if (status === 403) return ErrorCode.PERMISSION_DENIED;\n if (status === 507) return ErrorCode.STORAGE_INSUFFICIENT;\n if (status >= 500) return ErrorCode.INTERNAL_ERROR;\n return ErrorCode.BAD_REQUEST;\n}\n"],"mappings":";;AAOA,IAAY,YAAL,yBAAA,WAAA;CAEH,UAAA,iBAAA;CACA,UAAA,oBAAA;CAGA,UAAA,uCAAA;CACA,UAAA,iCAAA;CAGA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