@venizia/ignis-kernel 0.4.8-0 → 0.4.8-2
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 +5 -4
- package/dist/esm/base/applications/abstract.d.ts +1 -0
- package/dist/esm/base/applications/abstract.js +1 -0
- package/dist/esm/base/applications/abstract.js.map +1 -1
- package/dist/esm/base/applications/boot-sequence.d.ts +2 -0
- package/dist/esm/base/applications/boot-sequence.js.map +1 -1
- package/dist/esm/base/applications/common/constants.d.ts +2 -0
- package/dist/esm/base/applications/common/constants.js +1 -0
- package/dist/esm/base/applications/common/constants.js.map +1 -1
- package/dist/esm/base/applications/common/types/application.d.ts +30 -8
- package/dist/esm/base/applications/common/types/application.js.map +1 -1
- package/dist/esm/base/applications/common/types/middlewares.d.ts +16 -1
- package/dist/esm/base/applications/common/types/middlewares.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/codecs.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/common/codecs.js +1 -0
- package/dist/esm/base/auth/authenticate/common/codecs.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/constants/authentication.d.ts +6 -0
- package/dist/esm/base/auth/authenticate/common/constants/authentication.js +4 -0
- package/dist/esm/base/auth/authenticate/common/constants/authentication.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/constants/jose.d.ts +8 -0
- package/dist/esm/base/auth/authenticate/common/constants/jose.js +4 -0
- package/dist/esm/base/auth/authenticate/common/constants/jose.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/keys.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/common/keys.js +1 -0
- package/dist/esm/base/auth/authenticate/common/keys.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/basic.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/common/types/basic.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/jwt.d.ts +42 -0
- package/dist/esm/base/auth/authenticate/common/types/jwt.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/rest.d.ts +2 -0
- package/dist/esm/base/auth/authenticate/common/types/rest.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/service.d.ts +10 -1
- package/dist/esm/base/auth/authenticate/common/types/service.js.map +1 -1
- package/dist/esm/base/auth/authenticate/common/types/strategy.d.ts +5 -0
- package/dist/esm/base/auth/authenticate/common/types/strategy.js.map +1 -1
- package/dist/esm/base/auth/authenticate/middlewares/authenticate.middleware.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/middlewares/authenticate.middleware.js +1 -0
- package/dist/esm/base/auth/authenticate/middlewares/authenticate.middleware.js.map +1 -1
- package/dist/esm/base/auth/authenticate/providers/authentication.provider.d.ts +5 -0
- package/dist/esm/base/auth/authenticate/providers/authentication.provider.js +5 -0
- package/dist/esm/base/auth/authenticate/providers/authentication.provider.js.map +1 -1
- package/dist/esm/base/auth/authenticate/strategies/strategy-registry.d.ts +1 -0
- package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js +1 -0
- package/dist/esm/base/auth/authenticate/strategies/strategy-registry.js.map +1 -1
- package/dist/esm/base/auth/authorize/builders/grant.builder.d.ts +1 -0
- package/dist/esm/base/auth/authorize/builders/grant.builder.js +1 -0
- package/dist/esm/base/auth/authorize/builders/grant.builder.js.map +1 -1
- package/dist/esm/base/auth/authorize/builders/policy.builder.d.ts +1 -0
- package/dist/esm/base/auth/authorize/builders/policy.builder.js +1 -0
- package/dist/esm/base/auth/authorize/builders/policy.builder.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/authorization.d.ts +8 -0
- package/dist/esm/base/auth/authorize/common/constants/authorization.js +5 -0
- package/dist/esm/base/auth/authorize/common/constants/authorization.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/binding-keys.d.ts +1 -0
- package/dist/esm/base/auth/authorize/common/constants/binding-keys.js +1 -0
- package/dist/esm/base/auth/authorize/common/constants/binding-keys.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/constants/enforcer.d.ts +9 -0
- package/dist/esm/base/auth/authorize/common/constants/enforcer.js +4 -0
- package/dist/esm/base/auth/authorize/common/constants/enforcer.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/types/enforcer.d.ts +21 -3
- package/dist/esm/base/auth/authorize/common/types/enforcer.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/types/grant.d.ts +1 -0
- package/dist/esm/base/auth/authorize/common/types/grant.js.map +1 -1
- package/dist/esm/base/auth/authorize/common/types/request.d.ts +3 -0
- package/dist/esm/base/auth/authorize/common/types/request.js.map +1 -1
- package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.d.ts +1 -0
- package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.js +1 -0
- package/dist/esm/base/auth/authorize/enforcers/enforcer-registry.js.map +1 -1
- package/dist/esm/base/auth/authorize/middlewares/authorize.middleware.d.ts +1 -0
- package/dist/esm/base/auth/authorize/middlewares/authorize.middleware.js +1 -0
- package/dist/esm/base/auth/authorize/middlewares/authorize.middleware.js.map +1 -1
- package/dist/esm/base/auth/authorize/models/authorization-role.model.d.ts +6 -0
- package/dist/esm/base/auth/authorize/models/authorization-role.model.js +1 -0
- package/dist/esm/base/auth/authorize/models/authorization-role.model.js.map +1 -1
- package/dist/esm/base/auth/authorize/providers/authorization.provider.d.ts +1 -0
- package/dist/esm/base/auth/authorize/providers/authorization.provider.js +1 -0
- package/dist/esm/base/auth/authorize/providers/authorization.provider.js.map +1 -1
- package/dist/esm/base/auth/base/abstract-auth-registry.d.ts +2 -0
- package/dist/esm/base/auth/base/abstract-auth-registry.js +1 -0
- package/dist/esm/base/auth/base/abstract-auth-registry.js.map +1 -1
- package/dist/esm/base/auth/models/requests/change-password.schema.d.ts +2 -0
- package/dist/esm/base/auth/models/requests/change-password.schema.js +1 -0
- package/dist/esm/base/auth/models/requests/change-password.schema.js.map +1 -1
- package/dist/esm/base/auth/models/requests/sign-in.schema.d.ts +2 -0
- package/dist/esm/base/auth/models/requests/sign-in.schema.js +1 -0
- package/dist/esm/base/auth/models/requests/sign-in.schema.js.map +1 -1
- package/dist/esm/base/auth/models/requests/sign-up.schema.d.ts +2 -0
- package/dist/esm/base/auth/models/requests/sign-up.schema.js +1 -0
- package/dist/esm/base/auth/models/requests/sign-up.schema.js.map +1 -1
- package/dist/esm/base/components/base.d.ts +1 -0
- package/dist/esm/base/components/base.js +1 -0
- package/dist/esm/base/components/base.js.map +1 -1
- package/dist/esm/base/components/controller/rest/common/types.d.ts +2 -0
- package/dist/esm/base/components/controller/rest/common/types.js +1 -0
- package/dist/esm/base/components/controller/rest/common/types.js.map +1 -1
- package/dist/esm/base/configurations/base.d.ts +1 -0
- package/dist/esm/base/configurations/base.js +1 -0
- package/dist/esm/base/configurations/base.js.map +1 -1
- package/dist/esm/base/configurations/common/types.d.ts +1 -0
- package/dist/esm/base/configurations/common/types.js.map +1 -1
- package/dist/esm/base/controllers/common/constants.d.ts +4 -0
- package/dist/esm/base/controllers/common/constants.js +2 -0
- package/dist/esm/base/controllers/common/constants.js.map +1 -1
- package/dist/esm/base/controllers/common/schema-builders.d.ts +3 -0
- package/dist/esm/base/controllers/common/schema-builders.js +1 -0
- package/dist/esm/base/controllers/common/schema-builders.js.map +1 -1
- package/dist/esm/base/controllers/common/schemas.d.ts +2 -0
- package/dist/esm/base/controllers/common/schemas.js +2 -0
- package/dist/esm/base/controllers/common/schemas.js.map +1 -1
- package/dist/esm/base/controllers/common/types/context.d.ts +2 -0
- package/dist/esm/base/controllers/common/types/context.js.map +1 -1
- package/dist/esm/base/controllers/common/types/controller.d.ts +5 -1
- package/dist/esm/base/controllers/common/types/controller.js.map +1 -1
- package/dist/esm/base/controllers/common/types/route.d.ts +7 -1
- package/dist/esm/base/controllers/common/types/route.js.map +1 -1
- package/dist/esm/base/datasources/common/types.d.ts +5 -0
- package/dist/esm/base/datasources/common/types.js +1 -0
- package/dist/esm/base/datasources/common/types.js.map +1 -1
- package/dist/esm/base/events/common/constants.d.ts +4 -0
- package/dist/esm/base/events/common/constants.js +3 -0
- package/dist/esm/base/events/common/constants.js.map +1 -1
- package/dist/esm/base/events/common/types.d.ts +10 -2
- package/dist/esm/base/events/common/types.js.map +1 -1
- package/dist/esm/base/metadata/injectable.d.ts +46 -0
- package/dist/esm/base/metadata/injectable.js +46 -0
- package/dist/esm/base/metadata/injectable.js.map +1 -1
- package/dist/esm/base/metadata/persistents.d.ts +47 -2
- package/dist/esm/base/metadata/persistents.js +47 -2
- package/dist/esm/base/metadata/persistents.js.map +1 -1
- package/dist/esm/base/metadata/routes/controller.d.ts +17 -0
- package/dist/esm/base/metadata/routes/controller.js +17 -0
- package/dist/esm/base/metadata/routes/controller.js.map +1 -1
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.d.ts +1 -0
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.js +1 -0
- package/dist/esm/base/middlewares/emoji-favicon/emoji-favicon.middleware.js.map +1 -1
- package/dist/esm/base/middlewares/not-found/not-found.middleware.d.ts +1 -0
- package/dist/esm/base/middlewares/not-found/not-found.middleware.js +1 -0
- package/dist/esm/base/middlewares/not-found/not-found.middleware.js.map +1 -1
- package/dist/esm/base/mixins/common/types.d.ts +14 -1
- package/dist/esm/base/mixins/common/types.js.map +1 -1
- package/dist/esm/base/models/common/constants.d.ts +2 -0
- package/dist/esm/base/models/common/constants.js +1 -0
- package/dist/esm/base/models/common/constants.js.map +1 -1
- package/dist/esm/base/models/common/schemas.d.ts +1 -0
- package/dist/esm/base/models/common/schemas.js.map +1 -1
- package/dist/esm/base/models/common/types/id.d.ts +4 -0
- package/dist/esm/base/models/common/types/id.js.map +1 -1
- package/dist/esm/base/providers/base.d.ts +1 -0
- package/dist/esm/base/providers/base.js +1 -0
- package/dist/esm/base/providers/base.js.map +1 -1
- package/dist/esm/base/repositories/common/constants.d.ts +2 -2
- package/dist/esm/base/repositories/common/constants.js +2 -2
- package/dist/esm/base/repositories/common/constants.js.map +1 -1
- package/dist/esm/base/repositories/common/scope-through.d.ts +18 -1
- package/dist/esm/base/repositories/common/scope-through.js +18 -1
- package/dist/esm/base/repositories/common/scope-through.js.map +1 -1
- package/dist/esm/base/repositories/common/types/options.d.ts +10 -4
- package/dist/esm/base/repositories/common/types/options.js.map +1 -1
- package/dist/esm/base/repositories/query-schemas/index.d.ts +18 -3
- package/dist/esm/base/repositories/query-schemas/index.js +17 -1
- package/dist/esm/base/repositories/query-schemas/index.js.map +1 -1
- package/dist/esm/base/request-context/registry.d.ts +1 -0
- package/dist/esm/base/request-context/registry.js +1 -0
- package/dist/esm/base/request-context/registry.js.map +1 -1
- package/dist/esm/base/services/base.d.ts +1 -0
- package/dist/esm/base/services/base.js +1 -0
- package/dist/esm/base/services/base.js.map +1 -1
- package/dist/esm/base/services/common/types.d.ts +1 -0
- package/dist/esm/base/services/common/types.js.map +1 -1
- package/dist/esm/common/bindings.d.ts +1 -0
- package/dist/esm/common/bindings.js.map +1 -1
- package/dist/esm/common/error-codes.d.ts +2 -0
- package/dist/esm/common/error-codes.js.map +1 -1
- package/dist/esm/helpers/inversion/common/keys.d.ts +1 -0
- package/dist/esm/helpers/inversion/common/keys.js +1 -0
- package/dist/esm/helpers/inversion/common/keys.js.map +1 -1
- package/dist/esm/helpers/inversion/common/relation-builder.d.ts +1 -0
- package/dist/esm/helpers/inversion/common/relation-builder.js +1 -0
- package/dist/esm/helpers/inversion/common/relation-builder.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/artifact.d.ts +9 -2
- package/dist/esm/helpers/inversion/common/types/artifact.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/controller.d.ts +4 -0
- package/dist/esm/helpers/inversion/common/types/controller.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/model.d.ts +80 -8
- package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/persistence.d.ts +9 -1
- package/dist/esm/helpers/inversion/common/types/persistence.js.map +1 -1
- package/dist/esm/helpers/inversion/container.d.ts +1 -0
- package/dist/esm/helpers/inversion/container.js +1 -0
- package/dist/esm/helpers/inversion/container.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -82,10 +82,11 @@ Use `./repository` to put another transport behind the repository contract. The
|
|
|
82
82
|
|
|
83
83
|
## Logging
|
|
84
84
|
|
|
85
|
-
With the kernel alone, loggers write to the console. To
|
|
86
|
-
`LoggerFactory
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
With the kernel alone, loggers write to the console. To choose another provider, call
|
|
86
|
+
`LoggerFactory.use({ provider })` once at startup (`PinoLogger` from `@venizia/ignis-helpers/pino`,
|
|
87
|
+
`WinstonLogger` from `@venizia/ignis-helpers/winston`). A logger created before that call switches to
|
|
88
|
+
the chosen provider on its next call - nothing needs rebuilding. `@venizia/ignis` selects Winston at
|
|
89
|
+
start when no provider was chosen and `winston` is installed.
|
|
89
90
|
|
|
90
91
|
## Where it sits
|
|
91
92
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Container } from '../../helpers/inversion/container.js';
|
|
2
2
|
import type { ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
3
3
|
import type { IApplicationConfigs, IApplicationInfo } from './common/index.js';
|
|
4
|
+
/** Runtime-neutral base of every application: a DI container that holds the configs, the post-start and post-stop hooks and the core bindings. Server hosting lives in the `@venizia/ignis` subclass. */
|
|
4
5
|
export declare abstract class AbstractApplication extends Container {
|
|
5
6
|
protected configs: IApplicationConfigs;
|
|
6
7
|
protected projectRoot: string;
|
|
@@ -2,6 +2,7 @@ import { CoreBindings } from '../../common/bindings.js';
|
|
|
2
2
|
import { Container } from '../../helpers/inversion/container.js';
|
|
3
3
|
import { getError } from '@venizia/ignis-helpers/core';
|
|
4
4
|
import { HTTP } from '@venizia/ignis-helpers/common';
|
|
5
|
+
/** Runtime-neutral base of every application: a DI container that holds the configs, the post-start and post-stop hooks and the core bindings. Server hosting lives in the `@venizia/ignis` subclass. */
|
|
5
6
|
export class AbstractApplication extends Container {
|
|
6
7
|
constructor(opts) {
|
|
7
8
|
const { scope, config } = opts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../src/base/applications/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAGrD,MAAM,OAAgB,mBAAoB,SAAQ,SAAS;IAOzD,YAAY,IAAoD;QAC9D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAC/B,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QALX,mBAAc,GAAoE,EAAE,CAAC;QACrF,kBAAa,GAAoE,EAAE,CAAC;QAM1F,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE;YACvC,YAAY,EAAE;gBACZ,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,IAAI,IAAI,CAAC,6BAA6B,EAAE;aAC7E;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAC5E,CAAC;IAoBS,6BAA6B;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,cAAc;QACZ,MAAM,WAAW,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,CAAS,EAAE,GAAG,EAAE,YAAY,CAAC,wBAAwB,EAAE,CAAC,CAAC,O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["import { CoreBindings } from '@/common/bindings';\nimport { Container } from '@/helpers/inversion/container';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport type { IApplicationConfigs, IApplicationInfo } from './common';\n\nexport abstract class AbstractApplication extends Container {\n protected configs: IApplicationConfigs;\n protected projectRoot: string;\n\n private postStartHooks: Array<{ identifier: string; hook: () => ValueOrPromise<void> }> = [];\n private postStopHooks: Array<{ identifier: string; hook: () => ValueOrPromise<void> }> = [];\n\n constructor(opts: { scope: string; config: IApplicationConfigs }) {\n const { scope, config } = opts;\n super({ scope });\n\n this.configs = Object.assign({}, config, {\n asyncContext: {\n enable: config?.asyncContext?.enable ?? this.getDefaultAsyncContextEnabled(),\n },\n });\n\n this.projectRoot = this.getProjectRoot();\n this.logger.for('constructor').info('Project root: %s', this.projectRoot);\n }\n\n abstract getAppInfo(): ValueOrPromise<IApplicationInfo>;\n abstract preConfigure(): ValueOrPromise<void>;\n\n /**\n * Runs after every registration sweep (datasources, components, controllers) has already\n * completed. Registering a new one here is not auto-registered and silently does nothing -\n * call `configure()` manually instead.\n */\n abstract postConfigure(): ValueOrPromise<void>;\n\n abstract staticConfigure(): void;\n\n abstract setupMiddlewares(opts?: {\n middlewares?: Record<string | symbol, any>;\n }): ValueOrPromise<void>;\n\n abstract initialize(): Promise<void>;\n\n protected getDefaultAsyncContextEnabled(): boolean {\n return false;\n }\n\n getProjectConfigs(): IApplicationConfigs {\n return this.configs;\n }\n\n getProjectRoot(): string {\n const projectRoot = '';\n this.bind<string>({ key: CoreBindings.APPLICATION_PROJECT_ROOT }).toValue(projectRoot);\n\n return projectRoot;\n }\n\n registerPostStartHook(opts: { identifier: string; hook: () => ValueOrPromise<void> }) {\n this.postStartHooks.push(opts);\n this.logger\n .for(this.registerPostStartHook.name)\n .debug('Registered post-start hook | identifier: %s', opts.identifier);\n }\n\n /** Runs every post-start hook in isolation - the server is already listening, so a throwing hook must not cancel the ones behind it; failures are collected and reported as one error at the end. */\n protected async executePostStartHooks() {\n if (this.postStartHooks.length === 0) {\n return;\n }\n\n const logger = this.logger.for(this.executePostStartHooks.name);\n logger.info('Executing %s post-start hook(s)...', this.postStartHooks.length);\n\n const failures: Array<{ identifier: string; error: unknown }> = [];\n\n for (const { identifier, hook } of this.postStartHooks) {\n const t = performance.now();\n\n try {\n await hook();\n } catch (error) {\n logger.error('Failed to execute hook | identifier: %s | error: %s', identifier, error);\n failures.push({ identifier, error });\n continue;\n }\n\n logger.info(\n 'Executed hook | identifier: %s | took: %s (ms)',\n identifier,\n performance.now() - t,\n );\n }\n\n if (failures.length === 0) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[executePostStartHooks] Failed post-start hook(s): ${failures\n .map((failure) => `${failure.identifier} (${failure.error})`)\n .join(', ')}`,\n });\n }\n\n registerPostStopHook(opts: { identifier: string; hook: () => ValueOrPromise<void> }) {\n this.postStopHooks.push(opts);\n this.logger\n .for(this.registerPostStopHook.name)\n .debug('Registered post-stop hook | identifier: %s', opts.identifier);\n }\n\n protected async executePostStopHooks() {\n const logger = this.logger.for(this.executePostStopHooks.name);\n\n for (const { identifier, hook } of this.postStopHooks) {\n try {\n await hook();\n } catch (error) {\n logger.error('Post-stop hook failed | identifier: %s | error: %s', identifier, error);\n }\n }\n }\n\n protected registerCoreBindings() {\n this.bind<typeof this>({\n key: CoreBindings.APPLICATION_INSTANCE,\n }).toProvider((_) => this);\n }\n\n init() {\n this.registerCoreBindings();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../../src/base/applications/abstract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD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E;SAChB,CAAC,CAAC;IACL,CAAC;IAED,oBAAoB,CAAC,IAA8D;QACjF,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM;aACR,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC;aACnC,KAAK,CAAC,4CAA4C,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1E,CAAC;IAES,KAAK,CAAC,oBAAoB;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAE/D,KAAK,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;YACtD,IAAI,CAAC;gBACH,MAAM,IAAI,EAAE,CAAC;YACf,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,oDAAoD,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;YACxF,CAAC;QACH,CAAC;IACH,CAAC;IAES,oBAAoB;QAC5B,IAAI,CAAC,IAAI,CAAc;YACrB,GAAG,EAAE,YAAY,CAAC,oBAAoB;SACvC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI;QACF,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import { CoreBindings } from '@/common/bindings';\nimport { Container } from '@/helpers/inversion/container';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport type { IApplicationConfigs, IApplicationInfo } from './common';\n\n/** Runtime-neutral base of every application: a DI container that holds the configs, the post-start and post-stop hooks and the core bindings. Server hosting lives in the `@venizia/ignis` subclass. */\nexport abstract class AbstractApplication extends Container {\n protected configs: IApplicationConfigs;\n protected projectRoot: string;\n\n private postStartHooks: Array<{ identifier: string; hook: () => ValueOrPromise<void> }> = [];\n private postStopHooks: Array<{ identifier: string; hook: () => ValueOrPromise<void> }> = [];\n\n constructor(opts: { scope: string; config: IApplicationConfigs }) {\n const { scope, config } = opts;\n super({ scope });\n\n this.configs = Object.assign({}, config, {\n asyncContext: {\n enable: config?.asyncContext?.enable ?? this.getDefaultAsyncContextEnabled(),\n },\n });\n\n this.projectRoot = this.getProjectRoot();\n this.logger.for('constructor').info('Project root: %s', this.projectRoot);\n }\n\n abstract getAppInfo(): ValueOrPromise<IApplicationInfo>;\n abstract preConfigure(): ValueOrPromise<void>;\n\n /**\n * Runs after every registration sweep (datasources, components, controllers) has already\n * completed. Registering a new one here is not auto-registered and silently does nothing -\n * call `configure()` manually instead.\n */\n abstract postConfigure(): ValueOrPromise<void>;\n\n abstract staticConfigure(): void;\n\n abstract setupMiddlewares(opts?: {\n middlewares?: Record<string | symbol, any>;\n }): ValueOrPromise<void>;\n\n abstract initialize(): Promise<void>;\n\n protected getDefaultAsyncContextEnabled(): boolean {\n return false;\n }\n\n getProjectConfigs(): IApplicationConfigs {\n return this.configs;\n }\n\n getProjectRoot(): string {\n const projectRoot = '';\n this.bind<string>({ key: CoreBindings.APPLICATION_PROJECT_ROOT }).toValue(projectRoot);\n\n return projectRoot;\n }\n\n registerPostStartHook(opts: { identifier: string; hook: () => ValueOrPromise<void> }) {\n this.postStartHooks.push(opts);\n this.logger\n .for(this.registerPostStartHook.name)\n .debug('Registered post-start hook | identifier: %s', opts.identifier);\n }\n\n /** Runs every post-start hook in isolation - the server is already listening, so a throwing hook must not cancel the ones behind it; failures are collected and reported as one error at the end. */\n protected async executePostStartHooks() {\n if (this.postStartHooks.length === 0) {\n return;\n }\n\n const logger = this.logger.for(this.executePostStartHooks.name);\n logger.info('Executing %s post-start hook(s)...', this.postStartHooks.length);\n\n const failures: Array<{ identifier: string; error: unknown }> = [];\n\n for (const { identifier, hook } of this.postStartHooks) {\n const t = performance.now();\n\n try {\n await hook();\n } catch (error) {\n logger.error('Failed to execute hook | identifier: %s | error: %s', identifier, error);\n failures.push({ identifier, error });\n continue;\n }\n\n logger.info(\n 'Executed hook | identifier: %s | took: %s (ms)',\n identifier,\n performance.now() - t,\n );\n }\n\n if (failures.length === 0) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[executePostStartHooks] Failed post-start hook(s): ${failures\n .map((failure) => `${failure.identifier} (${failure.error})`)\n .join(', ')}`,\n });\n }\n\n registerPostStopHook(opts: { identifier: string; hook: () => ValueOrPromise<void> }) {\n this.postStopHooks.push(opts);\n this.logger\n .for(this.registerPostStopHook.name)\n .debug('Registered post-stop hook | identifier: %s', opts.identifier);\n }\n\n protected async executePostStopHooks() {\n const logger = this.logger.for(this.executePostStopHooks.name);\n\n for (const { identifier, hook } of this.postStopHooks) {\n try {\n await hook();\n } catch (error) {\n logger.error('Post-stop hook failed | identifier: %s | error: %s', identifier, error);\n }\n }\n }\n\n protected registerCoreBindings() {\n this.bind<typeof this>({\n key: CoreBindings.APPLICATION_INSTANCE,\n }).toProvider((_) => this);\n }\n\n init() {\n this.registerCoreBindings();\n }\n}\n"]}
|
|
@@ -15,7 +15,9 @@ export declare class BootSteps {
|
|
|
15
15
|
static readonly SCHEME_SET: Set<string>;
|
|
16
16
|
static isValid(value: string): boolean;
|
|
17
17
|
}
|
|
18
|
+
/** Union of the step names in `BootSteps`. */
|
|
18
19
|
export type TBootStep = TConstValue<typeof BootSteps>;
|
|
20
|
+
/** One named step of a boot sequence. `name` is what `BootSequence.insertAfter` targets; `run` is the work done when the sequence reaches the step. */
|
|
19
21
|
export interface IBootSequenceStep {
|
|
20
22
|
name: string;
|
|
21
23
|
run: () => ValueOrPromise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot-sequence.js","sourceRoot":"","sources":["../../../../src/base/applications/boot-sequence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,+LAA+L;AAC/L,MAAM,OAAO,SAAS;aACJ,qBAAgB,GAAG,iBAAiB,CAAC;aACrC,uBAAkB,GAAG,mBAAmB,CAAC;aACzC,kBAAa,GAAG,cAAc,CAAC;aAC/B,iCAA4B,GAAG,4BAA4B,CAAC;aAC5D,4BAAuB,GAAG,wBAAwB,CAAC;aACnD,0BAAqB,GAAG,qBAAqB,CAAC;aAC9C,wBAAmB,GAAG,oBAAoB,CAAC;aAC3C,sCAAiC,GAAG,gCAAgC,CAAC;aACrE,yBAAoB,GAAG,qBAAqB,CAAC;aAC7C,mBAAc,GAAG,eAAe,CAAC;aACjC,oBAAe,GAAG,gBAAgB,CAAC;aACnC,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,gBAAgB;QACrB,IAAI,CAAC,kBAAkB;QACvB,IAAI,CAAC,aAAa;QAClB,IAAI,CAAC,4BAA4B;QACjC,IAAI,CAAC,uBAAuB;QAC5B,IAAI,CAAC,qBAAqB;QAC1B,IAAI,CAAC,mBAAmB;QACxB,IAAI,CAAC,iCAAiC;QACtC,IAAI,CAAC,oBAAoB;QACzB,IAAI,CAAC,cAAc;QACnB,IAAI,CAAC,eAAe;KACrB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;
|
|
1
|
+
{"version":3,"file":"boot-sequence.js","sourceRoot":"","sources":["../../../../src/base/applications/boot-sequence.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,+LAA+L;AAC/L,MAAM,OAAO,SAAS;aACJ,qBAAgB,GAAG,iBAAiB,CAAC;aACrC,uBAAkB,GAAG,mBAAmB,CAAC;aACzC,kBAAa,GAAG,cAAc,CAAC;aAC/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ExD,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;YACvB,KAAK,CAAC,CAAC,CAAC,CAAC;gBACP,MAAM,QAAQ,CAAC;oBACb,OAAO,EAAE,iCAAiC,MAAM,oBAAoB,KAAK,EAAE;iBAC5E,CAAC,CAAC;YACL,CAAC;YACD,KAAK,CAAC,CAAC,CAAC,CAAC;gBACP,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,QAAQ,CAAC;oBACb,OAAO,EAAE,mCAAmC,MAAM,aAAa,OAAO,CAAC,MAAM,yBAAyB,KAAK,EAAE;iBAC9G,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,IAIlB;QACC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;QACrC,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QAEtD,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC;IACzE,CAAC;CACF","sourcesContent":["import type { TConstValue, ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\n\n/** The step names the kernel defines - the vocabulary a subclass targets with `BootSequence.insertAfter`. A server application adds its own on top (`ServerBootSteps` in `@venizia/ignis`). */\nexport class BootSteps {\n static readonly STATIC_CONFIGURE = 'staticConfigure';\n static readonly REGISTER_ARTIFACTS = 'registerArtifacts';\n static readonly PRE_CONFIGURE = 'preConfigure';\n static readonly REGISTER_DEFAULT_MIDDLEWARES = 'registerDefaultMiddlewares';\n static readonly REGISTER_CONFIGURATIONS = 'registerConfigurations';\n static readonly REGISTER_DATA_SOURCES = 'registerDataSources';\n static readonly REGISTER_COMPONENTS = 'registerComponents';\n static readonly REGISTER_CONTRIBUTED_DATA_SOURCES = 'registerContributedDataSources';\n static readonly REGISTER_CONTROLLERS = 'registerControllers';\n static readonly POST_CONFIGURE = 'postConfigure';\n static readonly VERIFY_BINDINGS = 'verifyBindings';\n static readonly SCHEME_SET = new Set<string>([\n this.STATIC_CONFIGURE,\n this.REGISTER_ARTIFACTS,\n this.PRE_CONFIGURE,\n this.REGISTER_DEFAULT_MIDDLEWARES,\n this.REGISTER_CONFIGURATIONS,\n this.REGISTER_DATA_SOURCES,\n this.REGISTER_COMPONENTS,\n this.REGISTER_CONTRIBUTED_DATA_SOURCES,\n this.REGISTER_CONTROLLERS,\n this.POST_CONFIGURE,\n this.VERIFY_BINDINGS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Union of the step names in `BootSteps`. */\nexport type TBootStep = TConstValue<typeof BootSteps>;\n\n/** One named step of a boot sequence. `name` is what `BootSequence.insertAfter` targets; `run` is the work done when the sequence reaches the step. */\nexport interface IBootSequenceStep {\n name: string;\n run: () => ValueOrPromise<void>;\n}\n\n/** Composes a boot sequence by name instead of copying the array - a subclass reads exactly what it adds by reading its own override, without diffing two files by eye. */\nexport class BootSequence {\n /** A duplicated name is refused as loudly as a missing one - picking the first match would splice a step into the wrong place silently. */\n private static indexOf(opts: { steps: IBootSequenceStep[]; target: string }): number {\n const { steps, target } = opts;\n const matches = steps.flatMap((step, index) => (step.name === target ? [index] : []));\n const known = steps.map((step) => step.name).join(', ');\n\n switch (matches.length) {\n case 0: {\n throw getError({\n message: `[BootSequence] Unknown step: '${target}' | Known steps: ${known}`,\n });\n }\n case 1: {\n return matches[0];\n }\n default: {\n throw getError({\n message: `[BootSequence] Ambiguous step: '${target}' appears ${matches.length} times | Known steps: ${known}`,\n });\n }\n }\n }\n\n static insertAfter(opts: {\n steps: IBootSequenceStep[];\n target: string;\n step: IBootSequenceStep;\n }): IBootSequenceStep[] {\n const { steps, target, step } = opts;\n const index = BootSequence.indexOf({ steps, target });\n\n return [...steps.slice(0, index + 1), step, ...steps.slice(index + 1)];\n }\n}\n"]}
|
|
@@ -10,7 +10,9 @@ export declare class ArtifactIndexFields {
|
|
|
10
10
|
static readonly SCHEME_SET: Set<string>;
|
|
11
11
|
static isValid(value: string): boolean;
|
|
12
12
|
}
|
|
13
|
+
/** Union of the `ArtifactIndexFields` values. */
|
|
13
14
|
export type TArtifactIndexField = TConstValue<typeof ArtifactIndexFields>;
|
|
15
|
+
/** The values of the `Sec-Fetch-Site` request header, the vocabulary of `TSecFetchSite`. */
|
|
14
16
|
export declare const SecFetchSiteValues: readonly ["same-origin", "same-site", "none", "cross-site"];
|
|
15
17
|
/** The `encoding` of `ICompressOptions`. */
|
|
16
18
|
export declare class CompressEncodings {
|
|
@@ -18,6 +18,7 @@ export class ArtifactIndexFields {
|
|
|
18
18
|
return this.SCHEME_SET.has(value);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
+
/** The values of the `Sec-Fetch-Site` request header, the vocabulary of `TSecFetchSite`. */
|
|
21
22
|
export const SecFetchSiteValues = ['same-origin', 'same-site', 'none', 'cross-site'];
|
|
22
23
|
/** The `encoding` of `ICompressOptions`. */
|
|
23
24
|
export class CompressEncodings {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/base/applications/common/constants.ts"],"names":[],"mappings":"AAEA,2KAA2K;AAC3K,MAAM,OAAO,mBAAmB;aACd,mBAAc,GAAG,gBAAgB,CAAC;aAClC,iBAAY,GAAG,aAAa,CAAC;aAC7B,eAAU,GAAG,YAAY,CAAC;aAC1B,iBAAY,GAAG,cAAc,CAAC;aAC9B,aAAQ,GAAG,UAAU,CAAC;aACtB,gBAAW,GAAG,aAAa,CAAC;aAE5B,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,cAAc;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,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\n\n/** The `IArtifactIndex` field names, in registration order. `@venizia/ignis-boot` mirrors these values in its own `ArtifactIndexFields` - boot cannot depend on kernel. */\nexport class ArtifactIndexFields {\n static readonly CONFIGURATIONS = 'configurations';\n static readonly DATA_SOURCES = 'dataSources';\n static readonly COMPONENTS = 'components';\n static readonly REPOSITORIES = 'repositories';\n static readonly SERVICES = 'services';\n static readonly CONTROLLERS = 'controllers';\n\n static readonly SCHEME_SET = new Set<string>([\n this.CONFIGURATIONS,\n this.DATA_SOURCES,\n this.COMPONENTS,\n this.REPOSITORIES,\n this.SERVICES,\n this.CONTROLLERS,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Union of the `ArtifactIndexFields` values. */\nexport type TArtifactIndexField = TConstValue<typeof ArtifactIndexFields>;\n\n/** The values of the `Sec-Fetch-Site` request header, the vocabulary of `TSecFetchSite`. */\nexport const SecFetchSiteValues = ['same-origin', 'same-site', 'none', 'cross-site'] as const;\n\n/** The `encoding` of `ICompressOptions`. */\nexport class CompressEncodings {\n static readonly GZIP = 'gzip';\n static readonly DEFLATE = 'deflate';\n\n static readonly SCHEME_SET = new Set<string>([this.GZIP, this.DEFLATE]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid compress encoding values. */\nexport type TCompressEncoding = TConstValue<typeof CompressEncodings>;\n"]}
|
|
@@ -7,13 +7,15 @@ import type { TArtifactIndexInput } from './artifacts.js';
|
|
|
7
7
|
import type { IMiddlewareConfigs } from './middlewares.js';
|
|
8
8
|
/** No `host`/`port`: a browser Worker has neither, and carrying them here made one silently configured with `localhost:3000`. `@venizia/ignis` widens this shape with both - see its `IServerApplicationConfigs`. */
|
|
9
9
|
export interface IApplicationConfigs {
|
|
10
|
-
/**
|
|
11
|
-
* `isStrict` (default `true`) makes `/users` and `/users/` different routes; `false` answers both.
|
|
12
|
-
* Under `false`, declare routes without a trailing slash: a route declared as `/users/` answers
|
|
13
|
-
* neither `/users` nor `/users/`.
|
|
14
|
-
*/
|
|
15
10
|
path: {
|
|
16
11
|
base: string;
|
|
12
|
+
/**
|
|
13
|
+
* Whether `/users` and `/users/` are different routes; `false` answers both. Under `false`,
|
|
14
|
+
* declare routes without a trailing slash: a route declared as `/users/` answers neither
|
|
15
|
+
* `/users` nor `/users/`. The type requires it; omitting it at run time means `true`.
|
|
16
|
+
*
|
|
17
|
+
* @default true
|
|
18
|
+
*/
|
|
17
19
|
isStrict: boolean;
|
|
18
20
|
};
|
|
19
21
|
requestId?: {
|
|
@@ -27,13 +29,21 @@ export interface IApplicationConfigs {
|
|
|
27
29
|
};
|
|
28
30
|
/** Generated indexes to register before `preConfigure` - one, or an array composed from several packages. */
|
|
29
31
|
artifacts?: TArtifactIndexInput;
|
|
30
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* Registers every class a stereotype decorated, so an application lists none of its own. An absent
|
|
34
|
+
* `artifacts` keeps meaning "register nothing", never "register everything". Both together
|
|
35
|
+
* register the union, de-duplicated - which is how an application discovers its own classes and
|
|
36
|
+
* still composes a library index.
|
|
37
|
+
*
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
31
40
|
discoverArtifacts?: boolean;
|
|
32
41
|
/** Boot-time checks. Without `binding`, nothing is verified, and hand registration and same-key override stay allowed. */
|
|
33
42
|
bootChecks?: {
|
|
34
43
|
binding?: {
|
|
35
44
|
doVerify: boolean;
|
|
36
45
|
allowManual: boolean;
|
|
46
|
+
/** @default true */
|
|
37
47
|
allowOverride: boolean;
|
|
38
48
|
};
|
|
39
49
|
/**
|
|
@@ -44,20 +54,31 @@ export interface IApplicationConfigs {
|
|
|
44
54
|
*/
|
|
45
55
|
allowDerivedKeyCollision?: boolean;
|
|
46
56
|
};
|
|
47
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* Controller transports to enable.
|
|
59
|
+
*
|
|
60
|
+
* @default ['rest']
|
|
61
|
+
*/
|
|
48
62
|
transports?: TControllerTransport[];
|
|
49
63
|
asyncContext?: {
|
|
50
64
|
enable: boolean;
|
|
51
65
|
};
|
|
52
66
|
debug?: {
|
|
67
|
+
/** @default false */
|
|
53
68
|
shouldShowRoutes?: boolean;
|
|
54
69
|
};
|
|
55
70
|
/** The framework installs `cors` (first) and `bodyLimit` (right after the request id). Every other key is typed only: wire it in `setupMiddlewares()`. */
|
|
56
71
|
middlewares?: IMiddlewareConfigs;
|
|
57
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* How long `stop()` waits, in ms, for one datasource's `close()` before it logs and moves on; `0`
|
|
74
|
+
* waits without limit.
|
|
75
|
+
*
|
|
76
|
+
* @default 10_000
|
|
77
|
+
*/
|
|
58
78
|
dataSourceCloseTimeoutMs?: number;
|
|
59
79
|
[key: string]: any;
|
|
60
80
|
}
|
|
81
|
+
/** Identity of an application, returned by `getAppInfo()`. Extra keys are allowed. */
|
|
61
82
|
export interface IApplicationInfo {
|
|
62
83
|
name: string;
|
|
63
84
|
version: string;
|
|
@@ -78,6 +99,7 @@ export interface IApplication<AppEnv extends Env = Env, AppSchema extends Schema
|
|
|
78
99
|
setupMiddlewares(): ValueOrPromise<void>;
|
|
79
100
|
initialize(): ValueOrPromise<void>;
|
|
80
101
|
}
|
|
102
|
+
/** The REST application contract: `IApplication` plus the component, controller, repository, service and static-serve registration mixins. */
|
|
81
103
|
export interface IRestApplication extends IApplication, IComponentMixin, IControllerMixin, IRepositoryMixin, IServiceMixin, IStaticServeMixin {
|
|
82
104
|
}
|
|
83
105
|
//# sourceMappingURL=application.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../../../src/base/applications/common/types/application.ts"],"names":[],"mappings":"","sourcesContent":["import type { OpenAPIHono } from '@hono/zod-openapi';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { Env, Schema } from 'hono';\nimport type { TControllerTransport } from '../../../controllers/common/constants';\nimport type {\n IComponentMixin,\n IControllerMixin,\n IRepositoryMixin,\n IServiceMixin,\n IStaticServeMixin,\n} from '../../../mixins/common';\nimport type { TArtifactIndexInput } from './artifacts';\nimport type { IMiddlewareConfigs } from './middlewares';\n\n/** No `host`/`port`: a browser Worker has neither, and carrying them here made one silently configured with `localhost:3000`. `@venizia/ignis` widens this shape with both - see its `IServerApplicationConfigs`. */\nexport interface IApplicationConfigs {\n /**\n
|
|
1
|
+
{"version":3,"file":"application.js","sourceRoot":"","sources":["../../../../../../src/base/applications/common/types/application.ts"],"names":[],"mappings":"","sourcesContent":["import type { OpenAPIHono } from '@hono/zod-openapi';\nimport type { ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport type { Env, Schema } from 'hono';\nimport type { TControllerTransport } from '../../../controllers/common/constants';\nimport type {\n IComponentMixin,\n IControllerMixin,\n IRepositoryMixin,\n IServiceMixin,\n IStaticServeMixin,\n} from '../../../mixins/common';\nimport type { TArtifactIndexInput } from './artifacts';\nimport type { IMiddlewareConfigs } from './middlewares';\n\n/** No `host`/`port`: a browser Worker has neither, and carrying them here made one silently configured with `localhost:3000`. `@venizia/ignis` widens this shape with both - see its `IServerApplicationConfigs`. */\nexport interface IApplicationConfigs {\n path: {\n base: string;\n\n /**\n * Whether `/users` and `/users/` are different routes; `false` answers both. Under `false`,\n * declare routes without a trailing slash: a route declared as `/users/` answers neither\n * `/users` nor `/users/`. The type requires it; omitting it at run time means `true`.\n *\n * @default true\n */\n isStrict: boolean;\n };\n requestId?: { isStrict: boolean };\n favicon?: string;\n\n /** `environment` is the host's ambient environment name. Set it where there is none to read - a browser Worker - so the error middleware can tell \"no ambient environment\" from \"misconfigured\". Absent on a server, which reads `process.env.NODE_ENV`. */\n error?: { rootKey?: string; environment?: string };\n\n /** Generated indexes to register before `preConfigure` - one, or an array composed from several packages. */\n artifacts?: TArtifactIndexInput;\n\n /**\n * Registers every class a stereotype decorated, so an application lists none of its own. An absent\n * `artifacts` keeps meaning \"register nothing\", never \"register everything\". Both together\n * register the union, de-duplicated - which is how an application discovers its own classes and\n * still composes a library index.\n *\n * @default false\n */\n discoverArtifacts?: boolean;\n\n /** Boot-time checks. Without `binding`, nothing is verified, and hand registration and same-key override stay allowed. */\n bootChecks?: {\n binding?: {\n doVerify: boolean;\n allowManual: boolean;\n\n /** @default true */\n allowOverride: boolean;\n };\n\n /**\n * Two different classes deriving one binding key from their class name fail registration: in a\n * minified build the second would silently replace the first. A development setup that\n * re-registers after a hot reload re-evaluates modules, which looks the same; `true` there turns\n * the failure into a warning.\n */\n allowDerivedKeyCollision?: boolean;\n };\n\n /**\n * Controller transports to enable.\n *\n * @default ['rest']\n */\n transports?: TControllerTransport[];\n\n asyncContext?: { enable: boolean };\n debug?: {\n /** @default false */\n shouldShowRoutes?: boolean;\n };\n\n /** The framework installs `cors` (first) and `bodyLimit` (right after the request id). Every other key is typed only: wire it in `setupMiddlewares()`. */\n middlewares?: IMiddlewareConfigs;\n\n /**\n * How long `stop()` waits, in ms, for one datasource's `close()` before it logs and moves on; `0`\n * waits without limit.\n *\n * @default 10_000\n */\n dataSourceCloseTimeoutMs?: number;\n [key: string]: any;\n}\n\n/** Identity of an application, returned by `getAppInfo()`. Extra keys are allowed. */\nexport interface IApplicationInfo {\n name: string;\n version: string;\n description: string;\n author?: { name: string; email: string; url?: string };\n [extra: string | symbol]: any;\n}\n\n/** Exactly what EVERY host implements. `getServerHost`/`getServerPort`/`getServerAddress`/`start`/`stop` are not here on purpose - a browser Worker can implement none of them; they live on `@venizia/ignis`'s `IServerApplication`. */\nexport interface IApplication<\n AppEnv extends Env = Env,\n AppSchema extends Schema = Schema,\n BasePath extends string = '/',\n> {\n getProjectRoot(): string;\n getProjectConfigs(): IApplicationConfigs;\n getServer(): OpenAPIHono<AppEnv, AppSchema, BasePath>;\n getRootRouter(): OpenAPIHono<AppEnv, AppSchema, BasePath>;\n\n setupMiddlewares(): ValueOrPromise<void>;\n\n initialize(): ValueOrPromise<void>;\n}\n\n/** The REST application contract: `IApplication` plus the component, controller, repository, service and static-serve registration mixins. */\nexport interface IRestApplication\n extends\n IApplication,\n IComponentMixin,\n IControllerMixin,\n IRepositoryMixin,\n IServiceMixin,\n IStaticServeMixin {}\n"]}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import type { Context } from 'hono';
|
|
2
2
|
import type { IPRestrictionRules as IIPRestrictionRules } from 'hono/ip-restriction';
|
|
3
3
|
import { type SecFetchSiteValues, type TCompressEncoding } from '../constants.js';
|
|
4
|
+
/** Options shared by every configurable middleware. Extra keys are allowed. */
|
|
4
5
|
export interface IBaseMiddlewareOptions {
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Only `false` switches the middleware off.
|
|
8
|
+
*
|
|
9
|
+
* @default true
|
|
10
|
+
*/
|
|
6
11
|
enable?: boolean;
|
|
7
12
|
path?: string;
|
|
8
13
|
[extra: string | symbol]: any;
|
|
9
14
|
}
|
|
15
|
+
/** Options of the compress middleware. Typed only: the framework does not install it. */
|
|
10
16
|
export interface ICompressOptions extends IBaseMiddlewareOptions {
|
|
11
17
|
encoding: TCompressEncoding;
|
|
12
18
|
threshold?: number;
|
|
13
19
|
}
|
|
20
|
+
/** Allowed origin for CORS: one origin, a list of origins, or a function that returns the origin to echo (or nothing to reject). */
|
|
14
21
|
export type TOrigin = string | string[] | ((origin: string, c: Context) => Promise<string | undefined | null> | string | undefined | null);
|
|
22
|
+
/** Options of the CORS middleware the framework installs first. `origin` is required. */
|
|
15
23
|
export interface ICORSOptions extends IBaseMiddlewareOptions {
|
|
16
24
|
origin: TOrigin;
|
|
17
25
|
allowMethods?: string[] | ((origin: string, c: Context) => Promise<string[]> | string[]);
|
|
@@ -20,19 +28,26 @@ export interface ICORSOptions extends IBaseMiddlewareOptions {
|
|
|
20
28
|
credentials?: boolean;
|
|
21
29
|
exposeHeaders?: string[];
|
|
22
30
|
}
|
|
31
|
+
/** Decides whether the request `Origin` is allowed for the CSRF check. */
|
|
23
32
|
export type TIsAllowedOriginHandler = (origin: string, context: Context) => boolean;
|
|
33
|
+
/** One value of the `Sec-Fetch-Site` header, taken from `SecFetchSiteValues`. */
|
|
24
34
|
export type TSecFetchSite = (typeof SecFetchSiteValues)[number];
|
|
35
|
+
/** Decides whether the request `Sec-Fetch-Site` value is allowed for the CSRF check. */
|
|
25
36
|
export type TIsAllowedSecFetchSiteHandler = (secFetchSite: TSecFetchSite, context: Context) => boolean;
|
|
37
|
+
/** Options of the CSRF middleware. Typed only: the framework does not install it. */
|
|
26
38
|
export interface ICSRFOptions extends IBaseMiddlewareOptions {
|
|
27
39
|
origin?: string | string[] | TIsAllowedOriginHandler;
|
|
28
40
|
secFetchSite?: TSecFetchSite | TSecFetchSite[] | TIsAllowedSecFetchSiteHandler;
|
|
29
41
|
}
|
|
42
|
+
/** Options of the body limit middleware the framework installs right after the request id. `maxSize` is in bytes. */
|
|
30
43
|
export interface IBodyLimitOptions extends IBaseMiddlewareOptions {
|
|
31
44
|
maxSize: number;
|
|
32
45
|
onError?: (c: Context) => Response | Promise<Response>;
|
|
33
46
|
}
|
|
47
|
+
/** Options of the request id middleware. Only the shared options apply. */
|
|
34
48
|
export interface IRequestIdOptions extends IBaseMiddlewareOptions {
|
|
35
49
|
}
|
|
50
|
+
/** The `configs.middlewares` shape: which framework middleware to switch off or configure. Extra keys are allowed. */
|
|
36
51
|
export interface IMiddlewareConfigs {
|
|
37
52
|
requestId?: IRequestIdOptions;
|
|
38
53
|
/** Typed only: the framework installs no compress middleware. Wire it in `setupMiddlewares()`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../../../../../../src/base/applications/common/types/middlewares.ts"],"names":[],"mappings":"","sourcesContent":["import type { Context } from 'hono';\nimport type { IPRestrictionRules as IIPRestrictionRules } from 'hono/ip-restriction';\nimport { type SecFetchSiteValues, type TCompressEncoding } from '../constants';\n\nexport interface IBaseMiddlewareOptions {\n
|
|
1
|
+
{"version":3,"file":"middlewares.js","sourceRoot":"","sources":["../../../../../../src/base/applications/common/types/middlewares.ts"],"names":[],"mappings":"","sourcesContent":["import type { Context } from 'hono';\nimport type { IPRestrictionRules as IIPRestrictionRules } from 'hono/ip-restriction';\nimport { type SecFetchSiteValues, type TCompressEncoding } from '../constants';\n\n/** Options shared by every configurable middleware. Extra keys are allowed. */\nexport interface IBaseMiddlewareOptions {\n /**\n * Only `false` switches the middleware off.\n *\n * @default true\n */\n enable?: boolean;\n path?: string;\n [extra: string | symbol]: any;\n}\n\n/** Options of the compress middleware. Typed only: the framework does not install it. */\nexport interface ICompressOptions extends IBaseMiddlewareOptions {\n encoding: TCompressEncoding;\n threshold?: number;\n}\n\n/** Allowed origin for CORS: one origin, a list of origins, or a function that returns the origin to echo (or nothing to reject). */\nexport type TOrigin =\n | string\n | string[]\n | ((\n origin: string,\n c: Context,\n ) => Promise<string | undefined | null> | string | undefined | null);\n/** Options of the CORS middleware the framework installs first. `origin` is required. */\nexport interface ICORSOptions extends IBaseMiddlewareOptions {\n origin: TOrigin;\n allowMethods?: string[] | ((origin: string, c: Context) => Promise<string[]> | string[]);\n allowHeaders?: string[];\n maxAge?: number;\n credentials?: boolean;\n exposeHeaders?: string[];\n}\n\n/** Decides whether the request `Origin` is allowed for the CSRF check. */\nexport type TIsAllowedOriginHandler = (origin: string, context: Context) => boolean;\n/** One value of the `Sec-Fetch-Site` header, taken from `SecFetchSiteValues`. */\nexport type TSecFetchSite = (typeof SecFetchSiteValues)[number];\n/** Decides whether the request `Sec-Fetch-Site` value is allowed for the CSRF check. */\nexport type TIsAllowedSecFetchSiteHandler = (\n secFetchSite: TSecFetchSite,\n context: Context,\n) => boolean;\n\n/** Options of the CSRF middleware. Typed only: the framework does not install it. */\nexport interface ICSRFOptions extends IBaseMiddlewareOptions {\n origin?: string | string[] | TIsAllowedOriginHandler;\n secFetchSite?: TSecFetchSite | TSecFetchSite[] | TIsAllowedSecFetchSiteHandler;\n}\n\n/** Options of the body limit middleware the framework installs right after the request id. `maxSize` is in bytes. */\nexport interface IBodyLimitOptions extends IBaseMiddlewareOptions {\n maxSize: number;\n onError?: (c: Context) => Response | Promise<Response>;\n}\n\n/** Options of the request id middleware. Only the shared options apply. */\nexport interface IRequestIdOptions extends IBaseMiddlewareOptions {}\n\n/** The `configs.middlewares` shape: which framework middleware to switch off or configure. Extra keys are allowed. */\nexport interface IMiddlewareConfigs {\n requestId?: IRequestIdOptions;\n /** Typed only: the framework installs no compress middleware. Wire it in `setupMiddlewares()`. */\n compress?: ICompressOptions;\n /** Installed first, before the request id and the body limit, so early framework responses carry its headers. */\n cors?: ICORSOptions;\n /** Typed only: the framework installs no csrf middleware. Wire it in `setupMiddlewares()`. */\n csrf?: ICSRFOptions;\n /** Installed right after the request id, ahead of every other middleware, so none of them reads a body over it. */\n bodyLimit?: IBodyLimitOptions;\n /** Typed only: the framework installs no ip restriction. Wire it in `setupMiddlewares()`. */\n ipRestriction?: IBaseMiddlewareOptions & IIPRestrictionRules;\n [extra: string | symbol]: any;\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { IPayloadFieldCodec, TJWTTokenRole } from './types/index.js';
|
|
2
|
+
/** Ready-made payload field codecs, plus `build` to define one. A codec turns one JWT payload field into a string and back so it can ride through the encrypted payload envelope. */
|
|
2
3
|
export declare class AuthenticationFieldCodecs {
|
|
3
4
|
static readonly ROLES_CODEC: IPayloadFieldCodec<TJWTTokenRole[]>;
|
|
4
5
|
/** Builds a single payload field codec. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ParseUtility } from '@venizia/ignis-helpers/core';
|
|
2
|
+
/** Ready-made payload field codecs, plus `build` to define one. A codec turns one JWT payload field into a string and back so it can ride through the encrypted payload envelope. */
|
|
2
3
|
export class AuthenticationFieldCodecs {
|
|
3
4
|
static { this.ROLES_CODEC = {
|
|
4
5
|
key: 'roles',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authenticate/common/codecs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,MAAM,OAAO,yBAAyB;aACpB,gBAAW,GAAwC;QACjE,GAAG,EAAE,OAAO;QACZ,SAAS,CAAC,IAAI;YACZ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC5F,CAAC;QACD,WAAW,CAAC,IAAI;YACd,OAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;gBACnD,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAEjD,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;YAC/E,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IAEF,2CAA2C;IAC3C,MAAM,CAAC,KAAK,CAAc,IAIzB;QACC,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;IACJ,CAAC","sourcesContent":["import { ParseUtility } from '@venizia/ignis-helpers/core';\nimport type { IPayloadFieldCodec, TJWTTokenRole } from './types';\n\nexport class AuthenticationFieldCodecs {\n static readonly ROLES_CODEC: IPayloadFieldCodec<TJWTTokenRole[]> = {\n key: 'roles',\n serialize(opts) {\n return JSON.stringify(opts.value.map((el) => `${el.id}|${el.identifier}|${el.priority}`));\n },\n deserialize(opts) {\n return (JSON.parse(opts.raw) as string[]).map((el) => {\n const [id, identifier, priority] = el.split('|');\n\n return { id, identifier, priority: ParseUtility.toInt({ input: priority }) };\n });\n },\n };\n\n /** Builds a single payload field codec. */\n static build<T = unknown>(opts: {\n key: string;\n serialize: IPayloadFieldCodec<T>['serialize'];\n deserialize: IPayloadFieldCodec<T>['deserialize'];\n }): IPayloadFieldCodec<T> {\n return {\n key: opts.key,\n serialize: opts.serialize,\n deserialize: opts.deserialize,\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"codecs.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authenticate/common/codecs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,qLAAqL;AACrL,MAAM,OAAO,yBAAyB;aACpB,gBAAW,GAAwC;QACjE,GAAG,EAAE,OAAO;QACZ,SAAS,CAAC,IAAI;YACZ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,UAAU,IAAI,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC5F,CAAC;QACD,WAAW,CAAC,IAAI;YACd,OAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAc,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE;gBACnD,MAAM,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBAEjD,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;YAC/E,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;IAEF,2CAA2C;IAC3C,MAAM,CAAC,KAAK,CAAc,IAIzB;QACC,OAAO;YACL,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;IACJ,CAAC","sourcesContent":["import { ParseUtility } from '@venizia/ignis-helpers/core';\nimport type { IPayloadFieldCodec, TJWTTokenRole } from './types';\n\n/** Ready-made payload field codecs, plus `build` to define one. A codec turns one JWT payload field into a string and back so it can ride through the encrypted payload envelope. */\nexport class AuthenticationFieldCodecs {\n static readonly ROLES_CODEC: IPayloadFieldCodec<TJWTTokenRole[]> = {\n key: 'roles',\n serialize(opts) {\n return JSON.stringify(opts.value.map((el) => `${el.id}|${el.identifier}|${el.priority}`));\n },\n deserialize(opts) {\n return (JSON.parse(opts.raw) as string[]).map((el) => {\n const [id, identifier, priority] = el.split('|');\n\n return { id, identifier, priority: ParseUtility.toInt({ input: priority }) };\n });\n },\n };\n\n /** Builds a single payload field codec. */\n static build<T = unknown>(opts: {\n key: string;\n serialize: IPayloadFieldCodec<T>['serialize'];\n deserialize: IPayloadFieldCodec<T>['deserialize'];\n }): IPayloadFieldCodec<T> {\n return {\n key: opts.key,\n serialize: opts.serialize,\n deserialize: opts.deserialize,\n };\n }\n}\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TConstValue } from '@venizia/ignis-helpers/common';
|
|
2
|
+
/** Names of the strategies the framework ships: `basic`, `jwt` and `service`. */
|
|
2
3
|
export declare class AuthenticateStrategy {
|
|
3
4
|
static readonly BASIC = "basic";
|
|
4
5
|
static readonly JWT = "jwt";
|
|
@@ -7,7 +8,9 @@ export declare class AuthenticateStrategy {
|
|
|
7
8
|
static readonly SCHEME_SET: Set<string>;
|
|
8
9
|
static isValid(input: string): boolean;
|
|
9
10
|
}
|
|
11
|
+
/** A strategy name: a built-in from `AuthenticateStrategy` or any name an application registers. */
|
|
10
12
|
export type TAuthStrategy = TConstValue<typeof AuthenticateStrategy> | (string & {});
|
|
13
|
+
/** Shared auth string constants: strategy names, `Authorization` header token types, and the request-context keys the authentication middleware reads and writes. */
|
|
11
14
|
export declare class Authentication {
|
|
12
15
|
static readonly STRATEGY_BASIC = "basic";
|
|
13
16
|
static readonly STRATEGY_JWT = "jwt";
|
|
@@ -19,16 +22,19 @@ export declare class Authentication {
|
|
|
19
22
|
static readonly CURRENT_USER = "auth.current.user";
|
|
20
23
|
static readonly AUDIT_USER_ID = "audit.user.id";
|
|
21
24
|
}
|
|
25
|
+
/** Token type tags, each prefixed with a number: authorization code, access token, refresh token. */
|
|
22
26
|
export declare class AuthenticationTokenTypes {
|
|
23
27
|
static readonly TYPE_AUTHORIZATION_CODE = "000_AUTHORIZATION_CODE";
|
|
24
28
|
static readonly TYPE_ACCESS_TOKEN = "100_ACCESS_TOKEN";
|
|
25
29
|
static readonly TYPE_REFRESH_TOKEN = "200_REFRESH_TOKEN";
|
|
26
30
|
}
|
|
31
|
+
/** How the `authenticate` middleware combines several strategies: `any` passes when one succeeds, `all` requires every one to succeed. */
|
|
27
32
|
export declare class AuthenticationModes {
|
|
28
33
|
static readonly ANY = "any";
|
|
29
34
|
static readonly ALL = "all";
|
|
30
35
|
static readonly SCHEME_SET: Set<string>;
|
|
31
36
|
static isValid(input: string): boolean;
|
|
32
37
|
}
|
|
38
|
+
/** A valid value of `AuthenticationModes`. */
|
|
33
39
|
export type TAuthMode = TConstValue<typeof AuthenticationModes>;
|
|
34
40
|
//# sourceMappingURL=authentication.d.ts.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Names of the strategies the framework ships: `basic`, `jwt` and `service`. */
|
|
1
2
|
export class AuthenticateStrategy {
|
|
2
3
|
static { this.BASIC = 'basic'; }
|
|
3
4
|
static { this.JWT = 'jwt'; }
|
|
@@ -8,6 +9,7 @@ export class AuthenticateStrategy {
|
|
|
8
9
|
return this.SCHEME_SET.has(input);
|
|
9
10
|
}
|
|
10
11
|
}
|
|
12
|
+
/** Shared auth string constants: strategy names, `Authorization` header token types, and the request-context keys the authentication middleware reads and writes. */
|
|
11
13
|
export class Authentication {
|
|
12
14
|
// Strategy
|
|
13
15
|
static { this.STRATEGY_BASIC = AuthenticateStrategy.BASIC; }
|
|
@@ -21,11 +23,13 @@ export class Authentication {
|
|
|
21
23
|
static { this.CURRENT_USER = 'auth.current.user'; }
|
|
22
24
|
static { this.AUDIT_USER_ID = 'audit.user.id'; }
|
|
23
25
|
}
|
|
26
|
+
/** Token type tags, each prefixed with a number: authorization code, access token, refresh token. */
|
|
24
27
|
export class AuthenticationTokenTypes {
|
|
25
28
|
static { this.TYPE_AUTHORIZATION_CODE = '000_AUTHORIZATION_CODE'; }
|
|
26
29
|
static { this.TYPE_ACCESS_TOKEN = '100_ACCESS_TOKEN'; }
|
|
27
30
|
static { this.TYPE_REFRESH_TOKEN = '200_REFRESH_TOKEN'; }
|
|
28
31
|
}
|
|
32
|
+
/** How the `authenticate` middleware combines several strategies: `any` passes when one succeeds, `all` requires every one to succeed. */
|
|
29
33
|
export class AuthenticationModes {
|
|
30
34
|
static { this.ANY = 'any'; }
|
|
31
35
|
static { this.ALL = 'all'; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/constants/authentication.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,oBAAoB;aACf,UAAK,GAAG,OAAO,CAAC;aAChB,QAAG,GAAG,KAAK,CAAC;aACZ,YAAO,GAAG,SAAS,CAAC;IAEpC,yFAAyF;aACzE,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3E,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;
|
|
1
|
+
{"version":3,"file":"authentication.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/constants/authentication.ts"],"names":[],"mappings":"AAEA,iFAAiF;AACjF,MAAM,OAAO,oBAAoB;aACf,UAAK,GAAG,OAAO,CAAC;aAChB,QAAG,GAAG,KAAK,CAAC;aACZ,YAAO,GAAG,SAAS,CAAC;IAEpC,yFAAyF;aACzE,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3E,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAQH,qKAAqK;AACrK,MAAM,OAAO,cAAc;IACzB,WAAW;aACK,mBAAc,GAAG,oBAAoB,CAAC,KAAK,CAAC;aAC5C,iBAAY,GAAG,oBAAoB,CAAC,GAAG,CAAC;aACxC,qBAAgB,GAAG,oBAAoB,CAAC,OAAO,CAAC;IAEhE,aAAa;aACG,eAAU,GAAG,OAAO,CAAC;aACrB,gBAAW,GAAG,QAAQ,CAAC;aAEvB,4BAAuB,GAAG,yBAAyB,CAAC;aACpD,wBAAmB,GAAG,qBAAqB,CAAC;aAE5C,iBAAY,GAAG,mBAAmB,CAAC;aACnC,kBAAa,GAAG,eAAe,CAAC;;AAGlD,qGAAqG;AACrG,MAAM,OAAO,wBAAwB;aACnB,4BAAuB,GAAG,wBAAwB,CAAC;aACnD,sBAAiB,GAAG,kBAAkB,CAAC;aACvC,uBAAkB,GAAG,mBAAmB,CAAC;;AAG3D,0IAA0I;AAC1I,MAAM,OAAO,mBAAmB;aACd,QAAG,GAAG,KAAK,CAAC;aACZ,QAAG,GAAG,KAAK,CAAC;aAEZ,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAE3D,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["import type { TConstValue } from '@venizia/ignis-helpers/common';\n\n/** Names of the strategies the framework ships: `basic`, `jwt` and `service`. */\nexport class AuthenticateStrategy {\n static readonly BASIC = 'basic';\n static readonly JWT = 'jwt';\n static readonly SERVICE = 'service';\n\n /** The strategies the FRAMEWORK ships. An application registers its own beyond these. */\n static readonly SCHEME_SET = new Set([this.BASIC, this.JWT, this.SERVICE]);\n\n static isValid(input: string): boolean {\n return this.SCHEME_SET.has(input);\n }\n}\n\n// `(string & {})` keeps autocomplete for the built-in values while still accepting any name an\n// application registers with `AuthenticationStrategyRegistry`. Same idiom as `TDataSourceDriver`.\n/** A strategy name: a built-in from `AuthenticateStrategy` or any name an application registers. */\nexport type TAuthStrategy = TConstValue<typeof AuthenticateStrategy> | (string & {});\n\n/** Shared auth string constants: strategy names, `Authorization` header token types, and the request-context keys the authentication middleware reads and writes. */\nexport class Authentication {\n // Strategy\n static readonly STRATEGY_BASIC = AuthenticateStrategy.BASIC;\n static readonly STRATEGY_JWT = AuthenticateStrategy.JWT;\n static readonly STRATEGY_SERVICE = AuthenticateStrategy.SERVICE;\n\n // Token type\n static readonly TYPE_BASIC = 'Basic';\n static readonly TYPE_BEARER = 'Bearer';\n\n static readonly AUTHENTICATION_STRATEGY = 'authentication.strategy';\n static readonly SKIP_AUTHENTICATION = 'authentication.skip';\n\n static readonly CURRENT_USER = 'auth.current.user';\n static readonly AUDIT_USER_ID = 'audit.user.id';\n}\n\n/** Token type tags, each prefixed with a number: authorization code, access token, refresh token. */\nexport class AuthenticationTokenTypes {\n static readonly TYPE_AUTHORIZATION_CODE = '000_AUTHORIZATION_CODE';\n static readonly TYPE_ACCESS_TOKEN = '100_ACCESS_TOKEN';\n static readonly TYPE_REFRESH_TOKEN = '200_REFRESH_TOKEN';\n}\n\n/** How the `authenticate` middleware combines several strategies: `any` passes when one succeeds, `all` requires every one to succeed. */\nexport class AuthenticationModes {\n static readonly ANY = 'any';\n static readonly ALL = 'all';\n\n static readonly SCHEME_SET = new Set([this.ANY, this.ALL]);\n\n static isValid(input: string): boolean {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** A valid value of `AuthenticationModes`. */\nexport type TAuthMode = TConstValue<typeof AuthenticationModes>;\n"]}
|
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
import type { TConstValue } from '@venizia/ignis-helpers/common';
|
|
2
|
+
/** The token standards the JWT service can use: `JWS` (shared-secret signing) or `JWKS` (key-pair signing, published or fetched as a key set). */
|
|
2
3
|
export declare class JOSEStandards {
|
|
3
4
|
static readonly JWS = "JWS";
|
|
4
5
|
static readonly JWKS = "JWKS";
|
|
5
6
|
static readonly SCHEME_SET: Set<string>;
|
|
6
7
|
static isValid(input: string): boolean;
|
|
7
8
|
}
|
|
9
|
+
/** A valid value of `JOSEStandards`. */
|
|
8
10
|
export type TJOSEStandard = TConstValue<typeof JOSEStandards>;
|
|
11
|
+
/** The role a JWKS setup plays: `issuer` signs tokens, `verifier` checks them against a remote key set. */
|
|
9
12
|
export declare class JWKSModes {
|
|
10
13
|
static readonly ISSUER = "issuer";
|
|
11
14
|
static readonly VERIFIER = "verifier";
|
|
12
15
|
static readonly SCHEME_SET: Set<string>;
|
|
13
16
|
static isValid(input: string): boolean;
|
|
14
17
|
}
|
|
18
|
+
/** A valid value of `JWKSModes`. */
|
|
15
19
|
export type TJWKSMode = TConstValue<typeof JWKSModes>;
|
|
20
|
+
/** Where JWKS key material comes from: inline `text` content or a `file` path. */
|
|
16
21
|
export declare class JWKSKeyDrivers {
|
|
17
22
|
static readonly TEXT = "text";
|
|
18
23
|
static readonly FILE = "file";
|
|
19
24
|
static readonly SCHEME_SET: Set<string>;
|
|
20
25
|
static isValid(input: string): boolean;
|
|
21
26
|
}
|
|
27
|
+
/** A valid value of `JWKSKeyDrivers`. */
|
|
22
28
|
export type TJWKSKeyDriver = TConstValue<typeof JWKSKeyDrivers>;
|
|
29
|
+
/** Encoding of JWKS key material: `pem` or `jwk`. */
|
|
23
30
|
export declare class JWKSKeyFormats {
|
|
24
31
|
static readonly PEM = "pem";
|
|
25
32
|
static readonly JWK = "jwk";
|
|
26
33
|
static readonly SCHEME_SET: Set<string>;
|
|
27
34
|
static isValid(input: string): boolean;
|
|
28
35
|
}
|
|
36
|
+
/** A valid value of `JWKSKeyFormats`. */
|
|
29
37
|
export type TJWKSKeyFormat = TConstValue<typeof JWKSKeyFormats>;
|
|
30
38
|
/** The signing algorithms a JWKS issuer supports. */
|
|
31
39
|
export declare class JWKSAlgorithms {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** The token standards the JWT service can use: `JWS` (shared-secret signing) or `JWKS` (key-pair signing, published or fetched as a key set). */
|
|
1
2
|
export class JOSEStandards {
|
|
2
3
|
static { this.JWS = 'JWS'; }
|
|
3
4
|
static { this.JWKS = 'JWKS'; }
|
|
@@ -6,6 +7,7 @@ export class JOSEStandards {
|
|
|
6
7
|
return this.SCHEME_SET.has(input);
|
|
7
8
|
}
|
|
8
9
|
}
|
|
10
|
+
/** The role a JWKS setup plays: `issuer` signs tokens, `verifier` checks them against a remote key set. */
|
|
9
11
|
export class JWKSModes {
|
|
10
12
|
static { this.ISSUER = 'issuer'; }
|
|
11
13
|
static { this.VERIFIER = 'verifier'; }
|
|
@@ -14,6 +16,7 @@ export class JWKSModes {
|
|
|
14
16
|
return this.SCHEME_SET.has(input);
|
|
15
17
|
}
|
|
16
18
|
}
|
|
19
|
+
/** Where JWKS key material comes from: inline `text` content or a `file` path. */
|
|
17
20
|
export class JWKSKeyDrivers {
|
|
18
21
|
static { this.TEXT = 'text'; }
|
|
19
22
|
static { this.FILE = 'file'; }
|
|
@@ -22,6 +25,7 @@ export class JWKSKeyDrivers {
|
|
|
22
25
|
return this.SCHEME_SET.has(input);
|
|
23
26
|
}
|
|
24
27
|
}
|
|
28
|
+
/** Encoding of JWKS key material: `pem` or `jwk`. */
|
|
25
29
|
export class JWKSKeyFormats {
|
|
26
30
|
static { this.PEM = 'pem'; }
|
|
27
31
|
static { this.JWK = 'jwk'; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jose.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/constants/jose.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;aACR,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5D,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;
|
|
1
|
+
{"version":3,"file":"jose.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/constants/jose.ts"],"names":[],"mappings":"AAEA,kJAAkJ;AAClJ,MAAM,OAAO,aAAa;aACR,QAAG,GAAG,KAAK,CAAC;aACZ,SAAI,GAAG,MAAM,CAAC;aAEd,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAE5D,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAMH,2GAA2G;AAC3G,MAAM,OAAO,SAAS;aACJ,WAAM,GAAG,QAAQ,CAAC;aAClB,aAAQ,GAAG,UAAU,CAAC;aAEtB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI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standards the JWT service can use: `JWS` (shared-secret signing) or `JWKS` (key-pair signing, published or fetched as a key set). */\nexport class JOSEStandards {\n static readonly JWS = 'JWS';\n static readonly JWKS = 'JWKS';\n\n static readonly SCHEME_SET = new Set([this.JWS, this.JWKS]);\n\n static isValid(input: string): boolean {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** A valid value of `JOSEStandards`. */\nexport type TJOSEStandard = TConstValue<typeof JOSEStandards>;\n\n/** The role a JWKS setup plays: `issuer` signs tokens, `verifier` checks them against a remote key set. */\nexport class JWKSModes {\n static readonly ISSUER = 'issuer';\n static readonly VERIFIER = 'verifier';\n\n static readonly SCHEME_SET = new Set([this.ISSUER, this.VERIFIER]);\n\n static isValid(input: string): boolean {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** A valid value of `JWKSModes`. */\nexport type TJWKSMode = TConstValue<typeof JWKSModes>;\n\n/** Where JWKS key material comes from: inline `text` content or a `file` path. */\nexport class JWKSKeyDrivers {\n static readonly TEXT = 'text';\n static readonly FILE = 'file';\n\n static readonly SCHEME_SET = new Set([this.TEXT, this.FILE]);\n\n static isValid(input: string): boolean {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** A valid value of `JWKSKeyDrivers`. */\nexport type TJWKSKeyDriver = TConstValue<typeof JWKSKeyDrivers>;\n\n/** Encoding of JWKS key material: `pem` or `jwk`. */\nexport class JWKSKeyFormats {\n static readonly PEM = 'pem';\n static readonly JWK = 'jwk';\n\n static readonly SCHEME_SET = new Set([this.PEM, this.JWK]);\n\n static isValid(input: string): boolean {\n return this.SCHEME_SET.has(input);\n }\n}\n\n/** A valid value of `JWKSKeyFormats`. */\nexport type TJWKSKeyFormat = TConstValue<typeof JWKSKeyFormats>;\n\n/** The signing algorithms a JWKS issuer supports. */\nexport class JWKSAlgorithms {\n static readonly ES256 = 'ES256';\n static readonly RS256 = 'RS256';\n static readonly EDDSA = 'EdDSA';\n\n static readonly SCHEME_SET = new Set<string>([this.ES256, this.RS256, this.EDDSA]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** Valid JWKS algorithm values. */\nexport type TJWKSAlgorithm = TConstValue<typeof JWKSAlgorithms>;\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Container binding keys under which the authenticate component stores each strategy's options and the service-certs controller path. */
|
|
1
2
|
export declare class AuthenticateBindingKeys {
|
|
2
3
|
static readonly REST_OPTIONS = "@app/authenticate/rest-options";
|
|
3
4
|
static readonly JWT_OPTIONS = "@app/authenticate/jwt-options";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** Container binding keys under which the authenticate component stores each strategy's options and the service-certs controller path. */
|
|
1
2
|
export class AuthenticateBindingKeys {
|
|
2
3
|
static { this.REST_OPTIONS = '@app/authenticate/rest-options'; }
|
|
3
4
|
static { this.JWT_OPTIONS = '@app/authenticate/jwt-options'; }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authenticate/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAuB;aAClB,iBAAY,GAAG,gCAAgC,CAAC;aAChD,gBAAW,GAAG,+BAA+B,CAAC;aAC9C,iBAAY,GAAG,gCAAgC,CAAC;aAChD,kBAAa,GAAG,iCAAiC,CAAC;aAClD,oBAAe,GAAG,mCAAmC,CAAC;aACtD,uBAAkB,GAAG,sCAAsC,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../../src/base/auth/authenticate/common/keys.ts"],"names":[],"mappings":"AAAA,0IAA0I;AAC1I,MAAM,OAAO,uBAAuB;aAClB,iBAAY,GAAG,gCAAgC,CAAC;aAChD,gBAAW,GAAG,+BAA+B,CAAC;aAC9C,iBAAY,GAAG,gCAAgC,CAAC;aAChD,kBAAa,GAAG,iCAAiC,CAAC;aAClD,oBAAe,GAAG,mCAAmC,CAAC;aACtD,uBAAkB,GAAG,sCAAsC,CAAC","sourcesContent":["/** Container binding keys under which the authenticate component stores each strategy's options and the service-certs controller path. */\nexport class AuthenticateBindingKeys {\n static readonly REST_OPTIONS = '@app/authenticate/rest-options';\n static readonly JWT_OPTIONS = '@app/authenticate/jwt-options';\n static readonly JWKS_OPTIONS = '@app/authenticate/jwks-options';\n static readonly BASIC_OPTIONS = '@app/authenticate/basic-options';\n static readonly SERVICE_OPTIONS = '@app/authenticate/service-options';\n static readonly SERVICE_CERTS_PATH = '@app/authenticate/service-certs-path';\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { TContext } from '../../../../controllers/common/types/index.js';
|
|
2
2
|
import type { Env } from 'hono';
|
|
3
3
|
import type { IAuthUser } from './strategy.js';
|
|
4
|
+
/** Options of the `basic` strategy. */
|
|
4
5
|
export type TBasicTokenServiceOptions<E extends Env = Env> = {
|
|
5
6
|
/** Callback to verify basic auth credentials. Returns IAuthUser if valid, null otherwise. */
|
|
6
7
|
verifyCredentials: (opts: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/basic.ts"],"names":[],"mappings":"","sourcesContent":["import type { TContext } from '@/base/controllers/common/types';\nimport type { Env } from 'hono';\nimport type { IAuthUser } from './strategy';\n\nexport type TBasicTokenServiceOptions<E extends Env = Env> = {\n /** Callback to verify basic auth credentials. Returns IAuthUser if valid, null otherwise. */\n verifyCredentials: (opts: {\n credentials: { username: string; password: string };\n context: TContext<E, string>;\n }) => Promise<IAuthUser | null>;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"basic.js","sourceRoot":"","sources":["../../../../../../../src/base/auth/authenticate/common/types/basic.ts"],"names":[],"mappings":"","sourcesContent":["import type { TContext } from '@/base/controllers/common/types';\nimport type { Env } from 'hono';\nimport type { IAuthUser } from './strategy';\n\n/** Options of the `basic` strategy. */\nexport type TBasicTokenServiceOptions<E extends Env = Env> = {\n /** Callback to verify basic auth credentials. Returns IAuthUser if valid, null otherwise. */\n verifyCredentials: (opts: {\n credentials: { username: string; password: string };\n context: TContext<E, string>;\n }) => Promise<IAuthUser | null>;\n};\n"]}
|