@venizia/ignis 0.4.7 → 0.4.8-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/base/applications/base.d.ts +19 -0
- package/dist/esm/base/applications/base.js +22 -1
- package/dist/esm/base/applications/base.js.map +1 -1
- package/dist/esm/base/applications/boot-steps.d.ts +1 -0
- package/dist/esm/base/applications/boot-steps.js.map +1 -1
- package/dist/esm/base/applications/common/types.d.ts +21 -4
- package/dist/esm/base/applications/common/types.js.map +1 -1
- package/dist/esm/base/applications/server.js.map +1 -1
- package/dist/esm/base/controllers/grpc/abstract.js.map +1 -1
- package/dist/esm/base/controllers/grpc/adapter.js.map +1 -1
- package/dist/esm/base/controllers/grpc/base.js.map +1 -1
- package/dist/esm/base/metadata/request-context.d.ts +1 -0
- package/dist/esm/base/metadata/request-context.js +1 -0
- package/dist/esm/base/metadata/request-context.js.map +1 -1
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.js.map +1 -1
- package/dist/esm/components/api-reference/common/constants.d.ts +1 -0
- package/dist/esm/components/api-reference/common/constants.js +1 -0
- package/dist/esm/components/api-reference/common/constants.js.map +1 -1
- package/dist/esm/components/api-reference/common/keys.d.ts +1 -0
- package/dist/esm/components/api-reference/common/keys.js +1 -0
- package/dist/esm/components/api-reference/common/keys.js.map +1 -1
- package/dist/esm/components/api-reference/common/types.d.ts +18 -1
- package/dist/esm/components/api-reference/common/types.js.map +1 -1
- package/dist/esm/components/api-reference/component.d.ts +14 -0
- package/dist/esm/components/api-reference/component.js +14 -0
- package/dist/esm/components/api-reference/component.js.map +1 -1
- package/dist/esm/components/api-reference/ui/factory.d.ts +1 -0
- package/dist/esm/components/api-reference/ui/factory.js +1 -0
- package/dist/esm/components/api-reference/ui/factory.js.map +1 -1
- package/dist/esm/components/api-reference/ui/scalar.d.ts +1 -0
- package/dist/esm/components/api-reference/ui/scalar.js +1 -0
- package/dist/esm/components/api-reference/ui/scalar.js.map +1 -1
- package/dist/esm/components/api-reference/ui/swagger.d.ts +1 -0
- package/dist/esm/components/api-reference/ui/swagger.js +1 -0
- package/dist/esm/components/api-reference/ui/swagger.js.map +1 -1
- package/dist/esm/components/auth/authenticate/component.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/component.js +1 -0
- package/dist/esm/components/auth/authenticate/component.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/controllers/factory.js +1 -0
- package/dist/esm/components/auth/authenticate/controllers/factory.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js +1 -0
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.js.map +1 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/basic/service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js +1 -0
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/jose-loader.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/service/signer.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/basic.strategy.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.d.ts +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js +1 -0
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.js.map +1 -1
- package/dist/esm/components/auth/authenticate/strategies/service.strategy.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/base-filtered.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.d.ts +2 -0
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.js.map +1 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.d.ts +1 -0
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js +1 -0
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.js.map +1 -1
- package/dist/esm/components/auth/authorize/component.d.ts +1 -0
- package/dist/esm/components/auth/authorize/component.js +1 -0
- package/dist/esm/components/auth/authorize/component.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin-module.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts +1 -0
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js +1 -0
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/policy-line-codec.js.map +1 -1
- package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.js.map +1 -1
- package/dist/esm/components/auth/authorize/role-managers/base.js.map +1 -1
- package/dist/esm/components/auth/authorize/role-managers/domain-hierarchy.js.map +1 -1
- package/dist/esm/components/auth/authorize/role-managers/membership.js.map +1 -1
- package/dist/esm/components/auth/authorize/role-managers/resource.js.map +1 -1
- package/dist/esm/components/auth/models/entities/columns.d.ts +1 -0
- package/dist/esm/components/auth/models/entities/columns.js.map +1 -1
- package/dist/esm/components/auth/models/entities/permission.model.d.ts +2 -0
- package/dist/esm/components/auth/models/entities/permission.model.js.map +1 -1
- package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts +1 -0
- package/dist/esm/components/auth/models/entities/policy-definition.model.js.map +1 -1
- package/dist/esm/components/controller/grpc/common/types.d.ts +2 -0
- package/dist/esm/components/controller/grpc/common/types.js +1 -0
- package/dist/esm/components/controller/grpc/common/types.js.map +1 -1
- package/dist/esm/components/controller/grpc/grpc.component.d.ts +1 -0
- package/dist/esm/components/controller/grpc/grpc.component.js +1 -0
- package/dist/esm/components/controller/grpc/grpc.component.js.map +1 -1
- package/dist/esm/components/health-check/common/constants.d.ts +1 -0
- package/dist/esm/components/health-check/common/constants.js +1 -0
- package/dist/esm/components/health-check/common/constants.js.map +1 -1
- package/dist/esm/components/health-check/common/keys.d.ts +1 -0
- package/dist/esm/components/health-check/common/keys.js +1 -0
- package/dist/esm/components/health-check/common/keys.js.map +1 -1
- package/dist/esm/components/health-check/common/rest-paths.d.ts +1 -0
- package/dist/esm/components/health-check/common/rest-paths.js +1 -0
- package/dist/esm/components/health-check/common/rest-paths.js.map +1 -1
- package/dist/esm/components/health-check/common/types.d.ts +24 -3
- package/dist/esm/components/health-check/common/types.js.map +1 -1
- package/dist/esm/components/health-check/component.d.ts +15 -0
- package/dist/esm/components/health-check/component.js +15 -0
- package/dist/esm/components/health-check/component.js.map +1 -1
- package/dist/esm/components/health-check/controller.d.ts +1 -0
- package/dist/esm/components/health-check/controller.js +1 -0
- package/dist/esm/components/health-check/controller.js.map +1 -1
- package/dist/esm/components/health-check/reporter.js.map +1 -1
- package/dist/esm/components/mail/common/constants.d.ts +6 -0
- package/dist/esm/components/mail/common/constants.js +5 -0
- package/dist/esm/components/mail/common/constants.js.map +1 -1
- package/dist/esm/components/mail/common/keys.d.ts +1 -0
- package/dist/esm/components/mail/common/keys.js +1 -0
- package/dist/esm/components/mail/common/keys.js.map +1 -1
- package/dist/esm/components/mail/common/types/message.d.ts +10 -0
- package/dist/esm/components/mail/common/types/message.js.map +1 -1
- package/dist/esm/components/mail/common/types/options.d.ts +22 -1
- package/dist/esm/components/mail/common/types/options.js.map +1 -1
- package/dist/esm/components/mail/common/types/queue.d.ts +7 -0
- package/dist/esm/components/mail/common/types/queue.js.map +1 -1
- package/dist/esm/components/mail/common/types/template.d.ts +2 -0
- package/dist/esm/components/mail/common/types/template.js.map +1 -1
- package/dist/esm/components/mail/common/types/verification.d.ts +5 -0
- package/dist/esm/components/mail/common/types/verification.js.map +1 -1
- package/dist/esm/components/mail/component.d.ts +1 -0
- package/dist/esm/components/mail/component.js +1 -0
- package/dist/esm/components/mail/component.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js +1 -0
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js +1 -0
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js +1 -0
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js +1 -0
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js +1 -0
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts +1 -0
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js +1 -0
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.js.map +1 -1
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts +2 -0
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.js +1 -0
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.js.map +1 -1
- package/dist/esm/components/mail/providers/mail-transporter.provider.d.ts +2 -0
- package/dist/esm/components/mail/providers/mail-transporter.provider.js +1 -0
- package/dist/esm/components/mail/providers/mail-transporter.provider.js.map +1 -1
- package/dist/esm/components/mail/services/generators/numeric-code.d.ts +1 -0
- package/dist/esm/components/mail/services/generators/numeric-code.js +1 -0
- package/dist/esm/components/mail/services/generators/numeric-code.js.map +1 -1
- package/dist/esm/components/mail/services/generators/random-token.d.ts +1 -0
- package/dist/esm/components/mail/services/generators/random-token.js +1 -0
- package/dist/esm/components/mail/services/generators/random-token.js.map +1 -1
- package/dist/esm/components/mail/services/generators/verification-data.d.ts +1 -0
- package/dist/esm/components/mail/services/generators/verification-data.js +1 -0
- package/dist/esm/components/mail/services/generators/verification-data.js.map +1 -1
- package/dist/esm/components/mail/services/mail.service.d.ts +1 -0
- package/dist/esm/components/mail/services/mail.service.js +1 -0
- package/dist/esm/components/mail/services/mail.service.js.map +1 -1
- package/dist/esm/components/mail/services/template.service.d.ts +1 -0
- package/dist/esm/components/mail/services/template.service.js +1 -0
- package/dist/esm/components/mail/services/template.service.js.map +1 -1
- package/dist/esm/components/mail/utilities/address.utility.d.ts +1 -0
- package/dist/esm/components/mail/utilities/address.utility.js +1 -0
- package/dist/esm/components/mail/utilities/address.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/attachment.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/mime.utility.d.ts +1 -0
- package/dist/esm/components/mail/utilities/mime.utility.js +1 -0
- package/dist/esm/components/mail/utilities/mime.utility.js.map +1 -1
- package/dist/esm/components/mail/utilities/verification.utility.d.ts +1 -0
- package/dist/esm/components/mail/utilities/verification.utility.js +1 -0
- package/dist/esm/components/mail/utilities/verification.utility.js.map +1 -1
- package/dist/esm/components/request-tracker/component.d.ts +1 -0
- package/dist/esm/components/request-tracker/component.js +1 -0
- package/dist/esm/components/request-tracker/component.js.map +1 -1
- package/dist/esm/components/socket-io/common/keys.d.ts +1 -0
- package/dist/esm/components/socket-io/common/keys.js +1 -0
- package/dist/esm/components/socket-io/common/keys.js.map +1 -1
- package/dist/esm/components/socket-io/component.d.ts +1 -0
- package/dist/esm/components/socket-io/component.js +1 -0
- package/dist/esm/components/socket-io/component.js.map +1 -1
- package/dist/esm/components/static-asset/common/commit-token.js.map +1 -1
- package/dist/esm/components/static-asset/common/constants.d.ts +3 -0
- package/dist/esm/components/static-asset/common/constants.js +1 -0
- package/dist/esm/components/static-asset/common/constants.js.map +1 -1
- package/dist/esm/components/static-asset/common/keys.d.ts +1 -0
- package/dist/esm/components/static-asset/common/keys.js +1 -0
- package/dist/esm/components/static-asset/common/keys.js.map +1 -1
- package/dist/esm/components/static-asset/common/types.d.ts +42 -6
- package/dist/esm/components/static-asset/common/types.js.map +1 -1
- package/dist/esm/components/static-asset/component.js.map +1 -1
- package/dist/esm/components/static-asset/controller/factory.d.ts +2 -0
- package/dist/esm/components/static-asset/controller/factory.js +1 -0
- package/dist/esm/components/static-asset/controller/factory.js.map +1 -1
- package/dist/esm/components/static-asset/controller/meta-link.js.map +1 -1
- package/dist/esm/components/static-asset/controller/route-options.js.map +1 -1
- package/dist/esm/components/static-asset/ingest.d.ts +5 -1
- package/dist/esm/components/static-asset/ingest.js.map +1 -1
- package/dist/esm/components/static-asset/models/base.model.d.ts +2 -0
- package/dist/esm/components/static-asset/models/base.model.js.map +1 -1
- package/dist/esm/components/websocket/common/keys.d.ts +1 -0
- package/dist/esm/components/websocket/common/keys.js +1 -0
- package/dist/esm/components/websocket/common/keys.js.map +1 -1
- package/dist/esm/components/websocket/component.d.ts +1 -0
- package/dist/esm/components/websocket/component.js +1 -0
- package/dist/esm/components/websocket/component.js.map +1 -1
- package/dist/esm/testing/assert-application-boots.d.ts +39 -8
- package/dist/esm/testing/assert-application-boots.js +14 -0
- package/dist/esm/testing/assert-application-boots.js.map +1 -1
- package/dist/esm/utilities/drizzle-result.utility.d.ts +1 -0
- package/dist/esm/utilities/drizzle-result.utility.js +1 -0
- package/dist/esm/utilities/drizzle-result.utility.js.map +1 -1
- package/dist/presets/app/files/.configs/builders/compile.ts +3 -1
- package/dist/presets/app/files/_env.example +1 -1
- package/dist/presets/app/files/src/smoke.test.ts +14 -8
- package/dist/presets/app/preset.json +4 -4
- package/dist/presets/lib/preset.json +3 -3
- package/dist/presets/shared/preset.json +1 -1
- package/package.json +10 -10
- package/dist/esm/base/applications/base.d.ts.map +0 -1
- package/dist/esm/base/applications/boot-steps.d.ts.map +0 -1
- package/dist/esm/base/applications/common/index.d.ts.map +0 -1
- package/dist/esm/base/applications/common/logger-startup.d.ts.map +0 -1
- package/dist/esm/base/applications/common/types.d.ts.map +0 -1
- package/dist/esm/base/applications/index.d.ts.map +0 -1
- package/dist/esm/base/applications/server.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/abstract.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/adapter.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/base.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/common/index.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/common/types.d.ts.map +0 -1
- package/dist/esm/base/controllers/grpc/index.d.ts.map +0 -1
- package/dist/esm/base/controllers/index.d.ts.map +0 -1
- package/dist/esm/base/index.d.ts.map +0 -1
- package/dist/esm/base/metadata/index.d.ts.map +0 -1
- package/dist/esm/base/metadata/request-context.d.ts.map +0 -1
- package/dist/esm/base/middlewares/app-error/app-error.middleware.d.ts.map +0 -1
- package/dist/esm/base/middlewares/app-error/index.d.ts.map +0 -1
- package/dist/esm/base/middlewares/index.d.ts.map +0 -1
- package/dist/esm/base/middlewares/request-spy/index.d.ts.map +0 -1
- package/dist/esm/base/middlewares/request-spy/request-spy.middleware.d.ts.map +0 -1
- package/dist/esm/common/environments.d.ts.map +0 -1
- package/dist/esm/common/index.d.ts.map +0 -1
- package/dist/esm/components/api-reference/common/constants.d.ts.map +0 -1
- package/dist/esm/components/api-reference/common/index.d.ts.map +0 -1
- package/dist/esm/components/api-reference/common/keys.d.ts.map +0 -1
- package/dist/esm/components/api-reference/common/types.d.ts.map +0 -1
- package/dist/esm/components/api-reference/component.d.ts.map +0 -1
- package/dist/esm/components/api-reference/index.d.ts.map +0 -1
- package/dist/esm/components/api-reference/ui/factory.d.ts.map +0 -1
- package/dist/esm/components/api-reference/ui/index.d.ts.map +0 -1
- package/dist/esm/components/api-reference/ui/scalar.d.ts.map +0 -1
- package/dist/esm/components/api-reference/ui/swagger.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/component.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/factory.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/controller.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/definitions.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/jwks/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/controller.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/definitions.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/controllers/service-certs/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/basic/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/basic/service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/abstract.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/abstract.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/issuer.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jwks/verifier.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/bearer/jws.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/jose-loader.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/service/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/service/signer.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/services/service/verifier.service.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/basic.strategy.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/issuer.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/jwks/verifier.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/jws.strategy.d.ts.map +0 -1
- package/dist/esm/components/auth/authenticate/strategies/service.strategy.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/base-filtered.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/common/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/common/types.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/connector.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/custom-grant-expander.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/adapter.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/constants.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/common/types.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/adapters/scoped-casbin/policy-edges.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/component.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin-module.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/casbin.enforcer.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/models/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/models/rbac-domain.model.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/policy-line-codec.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/enforcers/user-policy-line-cache.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/base.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/domain-hierarchy.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/index.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/membership.d.ts.map +0 -1
- package/dist/esm/components/auth/authorize/role-managers/resource.d.ts.map +0 -1
- package/dist/esm/components/auth/index.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/columns.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/index.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/permission.model.d.ts.map +0 -1
- package/dist/esm/components/auth/models/entities/policy-definition.model.d.ts.map +0 -1
- package/dist/esm/components/auth/models/index.d.ts.map +0 -1
- package/dist/esm/components/controller/grpc/common/index.d.ts.map +0 -1
- package/dist/esm/components/controller/grpc/common/types.d.ts.map +0 -1
- package/dist/esm/components/controller/grpc/grpc.component.d.ts.map +0 -1
- package/dist/esm/components/controller/grpc/index.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/constants.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/index.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/keys.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/rest-paths.d.ts.map +0 -1
- package/dist/esm/components/health-check/common/types.d.ts.map +0 -1
- package/dist/esm/components/health-check/component.d.ts.map +0 -1
- package/dist/esm/components/health-check/controller.d.ts.map +0 -1
- package/dist/esm/components/health-check/index.d.ts.map +0 -1
- package/dist/esm/components/health-check/reporter.d.ts.map +0 -1
- package/dist/esm/components/index.d.ts.map +0 -1
- package/dist/esm/components/mail/common/constants.d.ts.map +0 -1
- package/dist/esm/components/mail/common/errors.d.ts.map +0 -1
- package/dist/esm/components/mail/common/index.d.ts.map +0 -1
- package/dist/esm/components/mail/common/keys.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/index.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/message.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/options.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/queue.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/template.d.ts.map +0 -1
- package/dist/esm/components/mail/common/types/verification.d.ts.map +0 -1
- package/dist/esm/components/mail/component.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/executors/bull-mq-executor.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/executors/direct-executor.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/executors/index.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/executors/internal-queue-executor.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/index.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/transporters/amazon-ses-transporter.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/transporters/index.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/transporters/mailgun-transporter.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/helpers/transporters/nodemail-transporter.helper.d.ts.map +0 -1
- package/dist/esm/components/mail/index.d.ts.map +0 -1
- package/dist/esm/components/mail/providers/index.d.ts.map +0 -1
- package/dist/esm/components/mail/providers/mail-queue-executor.provider.d.ts.map +0 -1
- package/dist/esm/components/mail/providers/mail-transporter.provider.d.ts.map +0 -1
- package/dist/esm/components/mail/services/generators/index.d.ts.map +0 -1
- package/dist/esm/components/mail/services/generators/numeric-code.d.ts.map +0 -1
- package/dist/esm/components/mail/services/generators/random-token.d.ts.map +0 -1
- package/dist/esm/components/mail/services/generators/verification-data.d.ts.map +0 -1
- package/dist/esm/components/mail/services/index.d.ts.map +0 -1
- package/dist/esm/components/mail/services/mail.service.d.ts.map +0 -1
- package/dist/esm/components/mail/services/template.service.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/address.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/attachment.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/body.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/index.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/mime.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/type.utility.d.ts.map +0 -1
- package/dist/esm/components/mail/utilities/verification.utility.d.ts.map +0 -1
- package/dist/esm/components/request-tracker/component.d.ts.map +0 -1
- package/dist/esm/components/request-tracker/index.d.ts.map +0 -1
- package/dist/esm/components/socket-io/common/index.d.ts.map +0 -1
- package/dist/esm/components/socket-io/common/keys.d.ts.map +0 -1
- package/dist/esm/components/socket-io/common/types.d.ts.map +0 -1
- package/dist/esm/components/socket-io/component.d.ts.map +0 -1
- package/dist/esm/components/socket-io/handlers/bun.handler.d.ts.map +0 -1
- package/dist/esm/components/socket-io/handlers/index.d.ts.map +0 -1
- package/dist/esm/components/socket-io/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/commit-token.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/constants.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/errors.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/keys.d.ts.map +0 -1
- package/dist/esm/components/static-asset/common/types.d.ts.map +0 -1
- package/dist/esm/components/static-asset/component.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/base.definition.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/factory.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/key-scope.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/meta-link.d.ts.map +0 -1
- package/dist/esm/components/static-asset/controller/route-options.d.ts.map +0 -1
- package/dist/esm/components/static-asset/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/ingest.d.ts.map +0 -1
- package/dist/esm/components/static-asset/models/base.model.d.ts.map +0 -1
- package/dist/esm/components/static-asset/models/index.d.ts.map +0 -1
- package/dist/esm/components/static-asset/repositories/base.repository.d.ts.map +0 -1
- package/dist/esm/components/static-asset/repositories/index.d.ts.map +0 -1
- package/dist/esm/components/websocket/common/index.d.ts.map +0 -1
- package/dist/esm/components/websocket/common/keys.d.ts.map +0 -1
- package/dist/esm/components/websocket/common/types.d.ts.map +0 -1
- package/dist/esm/components/websocket/component.d.ts.map +0 -1
- package/dist/esm/components/websocket/handlers/bun.handler.d.ts.map +0 -1
- package/dist/esm/components/websocket/handlers/index.d.ts.map +0 -1
- package/dist/esm/components/websocket/index.d.ts.map +0 -1
- package/dist/esm/connectors/index.d.ts.map +0 -1
- package/dist/esm/helpers/base-helper.d.ts.map +0 -1
- package/dist/esm/helpers/index.d.ts.map +0 -1
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/testing/assert-application-boots.d.ts.map +0 -1
- package/dist/esm/testing/index.d.ts.map +0 -1
- package/dist/esm/utilities/drizzle-result.utility.d.ts.map +0 -1
- package/dist/esm/utilities/index.d.ts.map +0 -1
- package/dist/esm/utilities/network.utility.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-spy.middleware.js","sourceRoot":"","sources":["../../../../../src/base/middlewares/request-spy/request-spy.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAiB,MAAM,uBAAuB,CAAC;AAErF,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,mPAAmP;AACnP,MAAM,OAAO,oBAAqB,SAAQ,UAAU;aAClC,mBAAc,GAAG,cAAc,CAAC;IAIhD;;;;;;;;;OASG;IACH;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAC1B,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,8PAA8P;IAC9P,KAAK,CAAC,SAAS,CAAC,IAA8B;QAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAE/D,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,yMAAyM;QACzM,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"request-spy.middleware.js","sourceRoot":"","sources":["../../../../../src/base/middlewares/request-spy/request-spy.middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACrF,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAiB,MAAM,uBAAuB,CAAC;AAErF,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAEzC,mPAAmP;AACnP,MAAM,OAAO,oBAAqB,SAAQ,UAAU;aAClC,mBAAc,GAAG,cAAc,CAAC;IAIhD;;;;;;;;;OASG;IACH;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QAC1B,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,CAAC;QAC/C,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,GAAG,IAAI,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,8PAA8P;IAC9P,KAAK,CAAC,SAAS,CAAC,IAA8B;QAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,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AG,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;gBAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,2CAA2C,EAC3C,SAAS,EACT,QAAQ,EACR,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,EACrB,IAAI,EACJ,KAAK,EACL,IAAI,CACL,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,4FAA4F;gBAC5F,yFAAyF;gBACzF,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,EAAE,CAAC;oBACxF,MAAM,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;gBAChC,CAAC;gBAED,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,gCAAgC,EAChC,SAAS,EACT,QAAQ,EACR,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,EACrB,IAAI,EACJ,KAAK,CACN,CAAC;YACJ,CAAC;YAED,MAAM,IAAI,EAAE,CAAC;YAEb,MAAM,QAAQ,GAAG,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,oCAAoC,EACpC,SAAS,EACT,QAAQ,EACR,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,EACrB,IAAI,EACJ,QAAQ,CACT,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { NetworkUtility } from '@/utilities/network.utility';\nimport { Environment } from '@venizia/ignis-helpers';\nimport { BaseHelper, EnvironmentNames, getError } from '@venizia/ignis-helpers/core';\nimport { HTTP } from '@venizia/ignis-helpers/common';\nimport type { IProvider } from '@venizia/ignis-inversion';\nimport { createMiddleware } from 'hono/factory';\nimport type { MiddlewareHandler } from 'hono/types';\nimport { REQUEST_ID_KEY, RequestErrors, type TContext } from '@venizia/ignis-kernel';\n\nconst TEXT_CONTENT_TYPE_PREFIX = 'text/';\n\n/** Logs incoming/outgoing request details. The BODY is parsed and logged only in a recognised development environment - see the constructor for why that test is fail-closed; elsewhere only a JSON body is parsed, for its malformed-body 400. */\nexport class RequestSpyMiddleware extends BaseHelper implements IProvider<MiddlewareHandler> {\n static readonly REQUEST_ID_KEY = REQUEST_ID_KEY;\n\n private isDebugMode: boolean;\n\n /**\n * Fail-CLOSED, matching {@link BaseAppErrorMiddleware.isProduction}: only an environment this\n * framework recognises as a development one enables body logging.\n *\n * The previous test was `env !== 'production'`, which enabled it for an unset `NODE_ENV` and for\n * every pre-production name that carries real user data - `staging`, `uat`, `alpha`, `beta`, and\n * the abbreviation `prod`. `development-envs.test.ts` pins those as NOT development for exactly\n * that reason. Redaction is no defence here: it masks secret-SHAPED keys, so `nationalId`,\n * `cardNumber` and `ssn` were written verbatim.\n */\n constructor() {\n super({ scope: 'SpyMW' });\n const env = Environment.ambient?.toLowerCase();\n this.isDebugMode = !!env && EnvironmentNames.DEVELOPMENT_ENVS.has(env);\n }\n\n /** Parses the body by Content-Type without draining it for the handler: JSON and form bodies go through the request cache, `text/*` is read from a clone (from the cache once something read it), and any other type is described by its size, never read. */\n async parseBody(opts: { req: TContext['req'] }): Promise<unknown> {\n const contentType = opts.req.header(HTTP.Headers.CONTENT_TYPE);\n\n if (!contentType) {\n return null;\n }\n\n // Only an explicit zero short-circuits: a CHUNKED request carries no Content-Length, so gating on the header's presence would skip every streamed body and let a malformed one detonate deeper as a 500.\n const contentLength = opts.req.header(HTTP.Headers.CONTENT_LENGTH);\n\n if (contentLength === '0' || !opts.req.raw.body) {\n return null;\n }\n\n try {\n if (contentType.includes(HTTP.HeaderValues.APPLICATION_JSON)) {\n const rs = await opts.req.json();\n\n return rs;\n }\n\n if (\n contentType.includes(HTTP.HeaderValues.MULTIPART_FORM_DATA) ||\n contentType.includes(HTTP.HeaderValues.APPLICATION_FORM_URLENCODED)\n ) {\n const rs = await opts.req.parseBody();\n\n return rs;\n }\n\n if (contentType === HTTP.HeaderValues.APPLICATION_OCTET_STREAM) {\n return opts.req.raw.body;\n }\n\n // Anything else is read, if at all, from a clone: a handler may stream `req.raw.body` on (an upload proxy), and reading the request itself would drain it and mangle binary bytes.\n // A body an earlier middleware read cannot be cloned; Hono's cache serves it instead.\n if (contentType.startsWith(TEXT_CONTENT_TYPE_PREFIX)) {\n let rs: string;\n\n if (opts.req.raw.bodyUsed) {\n const cached = await opts.req.text();\n rs = cached;\n } else {\n const cloned = await opts.req.raw.clone().text();\n rs = cloned;\n }\n\n return rs;\n }\n\n return `<${contentLength ?? 'unknown'} bytes, ${contentType}>`;\n } catch {\n throw getError({\n error: RequestErrors.BODY_MALFORMED,\n message: 'Malformed Body Payload',\n });\n }\n }\n\n /** Returns a Hono middleware that logs request details and duration. */\n value() {\n return createMiddleware(async (context, next) => {\n const t = performance.now();\n const { req } = context;\n\n const requestId = context.get(RequestSpyMiddleware.REQUEST_ID_KEY);\n const incomingIp = NetworkUtility.getIncomingIp(context);\n const forwardedIp = req.header('x-real-ip') ?? req.header('x-forwarded-for') ?? null;\n\n const method = req.method;\n const path = req.path ?? '/';\n\n // Best-effort, never fatal: a unix socket, some proxies and any in-process call yield no connection info - refusing to serve because the client IP is unknown turns a logging gap into an outage.\n const clientIp = incomingIp ?? forwardedIp ?? 'unknown';\n const query = req.query() ?? {};\n\n if (this.isDebugMode) {\n const body = await this.parseBody({ req });\n this.logger.info(\n '[%s][%s][=>] %s %s | query: %j | body: %j',\n requestId,\n clientIp,\n method.padEnd(8, ' '),\n path,\n query,\n body,\n );\n } else {\n // Only JSON is parsed here: its clean 400 on a malformed body is a contract. Any other body\n // would be read for a log line that never prints it, before the route's own size checks.\n if (req.header(HTTP.Headers.CONTENT_TYPE)?.includes(HTTP.HeaderValues.APPLICATION_JSON)) {\n await this.parseBody({ req });\n }\n\n this.logger.info(\n '[%s][%s][=>] %s %s | query: %j',\n requestId,\n clientIp,\n method.padEnd(8, ' '),\n path,\n query,\n );\n }\n\n await next();\n\n const duration = (performance.now() - t).toFixed(2);\n this.logger.info(\n '[%s][%s][<=] %s %s | Took: %s (ms)',\n requestId,\n clientIp,\n method.padEnd(8, ' '),\n path,\n duration,\n );\n });\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/constants.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,eAAe;aACV,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAElE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/constants.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,MAAM,OAAO,eAAe;aACV,YAAO,GAAG,SAAS,CAAC;aACpB,WAAM,GAAG,QAAQ,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAElE,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC","sourcesContent":["/** The document UI implementations the API reference can render. `isValid` checks a string against them. */\nexport class DocumentUITypes {\n static readonly SWAGGER = 'swagger';\n static readonly SCALAR = 'scalar';\n\n static readonly SCHEME_SET = new Set([this.SWAGGER, this.SCALAR]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/keys.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,uBAAuB;aAClB,0BAAqB,GAAG,4BAA4B,CAAC","sourcesContent":["
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/keys.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,MAAM,OAAO,uBAAuB;aAClB,0BAAqB,GAAG,4BAA4B,CAAC","sourcesContent":["/** Container keys of the API reference component. */\nexport class ApiReferenceBindingKeys {\n static readonly API_REFERENCE_OPTIONS = '@app/api-reference/options';\n}\n"]}
|
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
import type { Context, Next } from 'hono';
|
|
2
2
|
import type { DocumentUITypes } from './constants.js';
|
|
3
3
|
import type { TConstValue } from '@venizia/ignis-helpers/common';
|
|
4
|
+
/** One of the `DocumentUITypes` values. */
|
|
4
5
|
export type TDocumentUIType = TConstValue<typeof DocumentUITypes>;
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Every field is optional: a partially-filled binding falls back to the component defaults.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { ApiReferenceBindingKeys, type BaseApplication, type IApiReferenceOptions } from '@venizia/ignis';
|
|
12
|
+
*
|
|
13
|
+
* export const bindApiReference = (application: BaseApplication) => {
|
|
14
|
+
* application
|
|
15
|
+
* .bind<IApiReferenceOptions>({ key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS })
|
|
16
|
+
* .toValue({ restOptions: { base: { path: '/docs' }, ui: { type: 'swagger' } } });
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
6
20
|
export interface IApiReferenceOptions {
|
|
7
21
|
restOptions?: {
|
|
8
22
|
base?: {
|
|
@@ -35,14 +49,17 @@ export interface IApiReferenceOptions {
|
|
|
35
49
|
uiConfig?: Record<string, any>;
|
|
36
50
|
securitySchemes?: Record<string, Record<string, any>>;
|
|
37
51
|
}
|
|
52
|
+
/** Renders the interactive API documentation page for the OpenAPI document. Register an implementation on `UIProviderFactory` to serve a custom UI. */
|
|
38
53
|
export interface IUIProvider {
|
|
39
54
|
render(context: Context, config: IUIConfig, next: Next): Promise<Response | void>;
|
|
40
55
|
}
|
|
56
|
+
/** Input of `IUIProvider.render`. Fields beyond `title` and `url` are passed through to the underlying UI library. */
|
|
41
57
|
export interface IUIConfig {
|
|
42
58
|
title: string;
|
|
43
59
|
url: string;
|
|
44
60
|
[key: string]: any;
|
|
45
61
|
}
|
|
62
|
+
/** Selects a registered UI provider by its type name. */
|
|
46
63
|
export interface IGetProviderParams {
|
|
47
64
|
type: string;
|
|
48
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { DocumentUITypes } from './constants';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\n\nexport type TDocumentUIType = TConstValue<typeof DocumentUITypes>;\n\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { DocumentUITypes } from './constants';\nimport type { TConstValue } from '@venizia/ignis-helpers/common';\n\n/** One of the `DocumentUITypes` values. */\nexport type TDocumentUIType = TConstValue<typeof DocumentUITypes>;\n\n/**\n * Every field is optional: a partially-filled binding falls back to the component defaults.\n *\n * @example\n * ```typescript\n * import { ApiReferenceBindingKeys, type BaseApplication, type IApiReferenceOptions } from '@venizia/ignis';\n *\n * export const bindApiReference = (application: BaseApplication) => {\n * application\n * .bind<IApiReferenceOptions>({ key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS })\n * .toValue({ restOptions: { base: { path: '/docs' }, ui: { type: 'swagger' } } });\n * };\n * ```\n */\nexport interface IApiReferenceOptions {\n restOptions?: {\n base?: { path?: string };\n doc?: { path?: string };\n ui?: { path?: string; type?: TDocumentUIType };\n };\n explorer?: {\n openapi?: string;\n info?: {\n title: string;\n version: string;\n description: string;\n contact?: { name: string; email: string };\n };\n servers?: Array<{\n url: string;\n description?: string;\n }>;\n };\n uiConfig?: Record<string, any>;\n securitySchemes?: Record<string, Record<string, any>>;\n}\n\n/** Renders the interactive API documentation page for the OpenAPI document. Register an implementation on `UIProviderFactory` to serve a custom UI. */\nexport interface IUIProvider {\n render(context: Context, config: IUIConfig, next: Next): Promise<Response | void>;\n}\n\n/** Input of `IUIProvider.render`. Fields beyond `title` and `url` are passed through to the underlying UI library. */\nexport interface IUIConfig {\n title: string;\n url: string;\n [key: string]: any;\n}\n\n/** Selects a registered UI provider by its type name. */\nexport interface IGetProviderParams {\n type: string;\n}\n"]}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import { type BaseApplication } from '../../base/applications/index.js';
|
|
2
2
|
import { BaseComponent } from '@venizia/ignis-kernel';
|
|
3
|
+
/**
|
|
4
|
+
* Serves the OpenAPI document and an interactive UI for it. Paths and UI type come from `IApiReferenceOptions` bound at `ApiReferenceBindingKeys.API_REFERENCE_OPTIONS`; `info` is always taken from the application info.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { ApiReferenceComponent, BaseApplication } from '@venizia/ignis';
|
|
9
|
+
*
|
|
10
|
+
* abstract class App extends BaseApplication {
|
|
11
|
+
* preConfigure(): void {
|
|
12
|
+
* this.component(ApiReferenceComponent);
|
|
13
|
+
* }
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
3
17
|
export declare class ApiReferenceComponent extends BaseComponent {
|
|
4
18
|
private application;
|
|
5
19
|
constructor(application: BaseApplication);
|
|
@@ -42,6 +42,20 @@ const joinRestPath = (segments) => {
|
|
|
42
42
|
.replace(/\/$/, '');
|
|
43
43
|
return joined.startsWith('/') ? joined : `/${joined}`;
|
|
44
44
|
};
|
|
45
|
+
/**
|
|
46
|
+
* Serves the OpenAPI document and an interactive UI for it. Paths and UI type come from `IApiReferenceOptions` bound at `ApiReferenceBindingKeys.API_REFERENCE_OPTIONS`; `info` is always taken from the application info.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* import { ApiReferenceComponent, BaseApplication } from '@venizia/ignis';
|
|
51
|
+
*
|
|
52
|
+
* abstract class App extends BaseApplication {
|
|
53
|
+
* preConfigure(): void {
|
|
54
|
+
* this.component(ApiReferenceComponent);
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
45
59
|
let ApiReferenceComponent = ApiReferenceComponent_1 = class ApiReferenceComponent extends BaseComponent {
|
|
46
60
|
constructor(application) {
|
|
47
61
|
super({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/api-reference/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAA6B,MAAM,UAAU,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEzC,MAAM,6BAA6B,GAAyB;IAC1D,WAAW,EAAE;QACX,IAAI,EAAE,EAAE,IAAI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port { inject } from '@/base/metadata';\nimport { type OpenAPIObjectConfigure } from '@hono/zod-openapi';\nimport type { AnyType } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { BaseComponent, Binding, CoreBindings } from '@venizia/ignis-kernel';\nimport type { Context, Next } from 'hono';\nimport { Authentication } from '../auth';\nimport { ServiceAssertion } from '@venizia/ignis-kernel';\nimport { ApiReferenceBindingKeys, DocumentUITypes, type IApiReferenceOptions } from './common';\nimport { UIProviderFactory } from './ui';\n\nconst DEFAULT_API_REFERENCE_OPTIONS: IApiReferenceOptions = {\n restOptions: {\n base: { path: '/doc' },\n doc: { path: '/openapi.json' },\n ui: { path: '/explorer', type: 'scalar' },\n },\n explorer: {\n openapi: '3.0.0',\n info: {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'API documentation for your service',\n },\n },\n};\n\n/** Joins rest path segments into a single absolute path (no empty or duplicated separators). */\nconst joinRestPath = (segments: Array<string | undefined>): string => {\n const joined = segments\n .filter((segment): segment is string => Boolean(segment))\n .join('/')\n .replace(/\\/+/g, '/')\n .replace(/\\/$/, '');\n\n return joined.startsWith('/') ? joined : `/${joined}`;\n};\n\nexport class ApiReferenceComponent extends BaseComponent {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: ApiReferenceComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [ApiReferenceBindingKeys.API_REFERENCE_OPTIONS]: Binding.bind<IApiReferenceOptions>({\n key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS,\n }).toValue(DEFAULT_API_REFERENCE_OPTIONS),\n },\n });\n }\n\n override async binding() {\n const boundOptions = this.application.get<IApiReferenceOptions>({\n key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS,\n isOptional: true,\n });\n\n const defaultRestOptions = DEFAULT_API_REFERENCE_OPTIONS.restOptions!;\n const restOptions = {\n base: { ...defaultRestOptions.base, ...boundOptions?.restOptions?.base },\n doc: { ...defaultRestOptions.doc, ...boundOptions?.restOptions?.doc },\n ui: { ...defaultRestOptions.ui, ...boundOptions?.restOptions?.ui },\n };\n\n // A fresh explorer object per application: mutating the bound one (or the module default) leaks this application's info/servers into every later application in the process.\n const explorer: NonNullable<IApiReferenceOptions['explorer']> = {\n ...DEFAULT_API_REFERENCE_OPTIONS.explorer,\n ...boundOptions?.explorer,\n };\n\n const rootRouter = this.application.getRootRouter();\n const configs = this.application.getProjectConfigs();\n\n const appInfo = await this.application.getAppInfo();\n explorer.info = {\n title: appInfo.name,\n version: appInfo.version,\n description: appInfo.description,\n contact: appInfo.author,\n };\n\n if (!explorer.servers?.length) {\n explorer.servers = [\n {\n url: ['http://', this.application.getServerAddress(), configs.path.base ?? ''].join(''),\n description: 'Local Application Server URL',\n },\n ];\n }\n\n const docPath = joinRestPath([restOptions.base.path, restOptions.doc.path]);\n const uiPath = joinRestPath([restOptions.base.path, restOptions.ui.path]);\n\n rootRouter.doc(docPath, explorer as OpenAPIObjectConfigure<any, string>);\n\n const uiType = restOptions.ui.type ?? DocumentUITypes.SWAGGER;\n const uiProviderFactory = UIProviderFactory.getInstance();\n\n // A custom provider registered on the factory is honoured; only unknown types are rejected.\n if (!uiProviderFactory.isBound(uiType)) {\n if (!DocumentUITypes.isValid(uiType)) {\n throw getError({\n message: `[binding] Invalid document UI Type | uiType: ${uiType} | valids: ${[...DocumentUITypes.SCHEME_SET]}`,\n });\n }\n\n uiProviderFactory.register({ type: uiType });\n }\n\n const docUrl = joinRestPath([configs.path.base, docPath]);\n const uiProvider = uiProviderFactory.getProvider({ type: uiType });\n\n rootRouter.get(uiPath, async (context: Context, next: Next) => {\n return uiProvider.render(\n context,\n {\n title: appInfo.name,\n url: docUrl,\n ...(boundOptions?.uiConfig ?? {}),\n },\n next,\n );\n });\n\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', Authentication.STRATEGY_JWT, {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n });\n\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', Authentication.STRATEGY_BASIC, {\n type: 'http',\n scheme: 'basic',\n });\n\n rootRouter.openAPIRegistry.registerComponent(\n 'securitySchemes',\n Authentication.STRATEGY_SERVICE,\n { type: 'apiKey', in: 'header', name: ServiceAssertion.HEADER },\n );\n\n const securitySchemes = boundOptions?.securitySchemes ?? {};\n const securitySchemesEntries = Object.entries(securitySchemes);\n for (const [name, scheme] of securitySchemesEntries) {\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', name, scheme as AnyType);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/components/api-reference/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAA6B,MAAM,UAAU,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAEzC,MAAM,6BAA6B,GAAyB;IAC1D,WAAW,EAAE;QACX,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;QACtB,GAAG,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;QAC9B,EAAE,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC1C;IACD,QAAQ,EAAE;QACR,OAAO,EAAE,OAAO;QAChB,IAAI,EAAE;YACJ,KAAK,EAAE,mBAAmB;YAC1B,OAAO,EAAE,OAAO;YAChB,WAAW,EAAE,oCAAoC;SAClD;KACF;CACF,CAAC;AA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,CAAC,YAAY,EAAE;YAC3F,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,QAAQ;YAChB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;QAEH,UAAU,CAAC,eAAe,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,cAAc,CAAC,cAAc,EAAE;YAC7F,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE,OAAO;SAChB,CAAC,CAAC;QAEH,UAAU,CAAC,eAAe,CAAC,iBAAiB,CAC1C,iBAAiB,EACjB,cAAc,CAAC,gBAAgB,EAC/B,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAChE,CAAC;QAEF,MAAM,eAAe,GAAG,YAAY,EAAE,eAAe,IAAI,EAAE,CAAC;QAC5D,MAAM,sBAAsB,GAAG,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QAE/D,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,sBAAsB,EAAE,CAAC;YACpD,UAAU,CAAC,eAAe,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,IAAI,EAAE,MAAiB,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;CACF,CAAA;AAhHY,qBAAqB;IAE7B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,qBAAqB,CAgHjC","sourcesContent":["import { type BaseApplication } from '@/base/applications';\nimport { inject } from '@/base/metadata';\nimport { type OpenAPIObjectConfigure } from '@hono/zod-openapi';\nimport type { AnyType } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { BaseComponent, Binding, CoreBindings } from '@venizia/ignis-kernel';\nimport type { Context, Next } from 'hono';\nimport { Authentication } from '../auth';\nimport { ServiceAssertion } from '@venizia/ignis-kernel';\nimport { ApiReferenceBindingKeys, DocumentUITypes, type IApiReferenceOptions } from './common';\nimport { UIProviderFactory } from './ui';\n\nconst DEFAULT_API_REFERENCE_OPTIONS: IApiReferenceOptions = {\n restOptions: {\n base: { path: '/doc' },\n doc: { path: '/openapi.json' },\n ui: { path: '/explorer', type: 'scalar' },\n },\n explorer: {\n openapi: '3.0.0',\n info: {\n title: 'API Documentation',\n version: '1.0.0',\n description: 'API documentation for your service',\n },\n },\n};\n\n/** Joins rest path segments into a single absolute path (no empty or duplicated separators). */\nconst joinRestPath = (segments: Array<string | undefined>): string => {\n const joined = segments\n .filter((segment): segment is string => Boolean(segment))\n .join('/')\n .replace(/\\/+/g, '/')\n .replace(/\\/$/, '');\n\n return joined.startsWith('/') ? joined : `/${joined}`;\n};\n\n/**\n * Serves the OpenAPI document and an interactive UI for it. Paths and UI type come from `IApiReferenceOptions` bound at `ApiReferenceBindingKeys.API_REFERENCE_OPTIONS`; `info` is always taken from the application info.\n *\n * @example\n * ```typescript\n * import { ApiReferenceComponent, BaseApplication } from '@venizia/ignis';\n *\n * abstract class App extends BaseApplication {\n * preConfigure(): void {\n * this.component(ApiReferenceComponent);\n * }\n * }\n * ```\n */\nexport class ApiReferenceComponent extends BaseComponent {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: ApiReferenceComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [ApiReferenceBindingKeys.API_REFERENCE_OPTIONS]: Binding.bind<IApiReferenceOptions>({\n key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS,\n }).toValue(DEFAULT_API_REFERENCE_OPTIONS),\n },\n });\n }\n\n override async binding() {\n const boundOptions = this.application.get<IApiReferenceOptions>({\n key: ApiReferenceBindingKeys.API_REFERENCE_OPTIONS,\n isOptional: true,\n });\n\n const defaultRestOptions = DEFAULT_API_REFERENCE_OPTIONS.restOptions!;\n const restOptions = {\n base: { ...defaultRestOptions.base, ...boundOptions?.restOptions?.base },\n doc: { ...defaultRestOptions.doc, ...boundOptions?.restOptions?.doc },\n ui: { ...defaultRestOptions.ui, ...boundOptions?.restOptions?.ui },\n };\n\n // A fresh explorer object per application: mutating the bound one (or the module default) leaks this application's info/servers into every later application in the process.\n const explorer: NonNullable<IApiReferenceOptions['explorer']> = {\n ...DEFAULT_API_REFERENCE_OPTIONS.explorer,\n ...boundOptions?.explorer,\n };\n\n const rootRouter = this.application.getRootRouter();\n const configs = this.application.getProjectConfigs();\n\n const appInfo = await this.application.getAppInfo();\n explorer.info = {\n title: appInfo.name,\n version: appInfo.version,\n description: appInfo.description,\n contact: appInfo.author,\n };\n\n if (!explorer.servers?.length) {\n explorer.servers = [\n {\n url: ['http://', this.application.getServerAddress(), configs.path.base ?? ''].join(''),\n description: 'Local Application Server URL',\n },\n ];\n }\n\n const docPath = joinRestPath([restOptions.base.path, restOptions.doc.path]);\n const uiPath = joinRestPath([restOptions.base.path, restOptions.ui.path]);\n\n rootRouter.doc(docPath, explorer as OpenAPIObjectConfigure<any, string>);\n\n const uiType = restOptions.ui.type ?? DocumentUITypes.SWAGGER;\n const uiProviderFactory = UIProviderFactory.getInstance();\n\n // A custom provider registered on the factory is honoured; only unknown types are rejected.\n if (!uiProviderFactory.isBound(uiType)) {\n if (!DocumentUITypes.isValid(uiType)) {\n throw getError({\n message: `[binding] Invalid document UI Type | uiType: ${uiType} | valids: ${[...DocumentUITypes.SCHEME_SET]}`,\n });\n }\n\n uiProviderFactory.register({ type: uiType });\n }\n\n const docUrl = joinRestPath([configs.path.base, docPath]);\n const uiProvider = uiProviderFactory.getProvider({ type: uiType });\n\n rootRouter.get(uiPath, async (context: Context, next: Next) => {\n return uiProvider.render(\n context,\n {\n title: appInfo.name,\n url: docUrl,\n ...(boundOptions?.uiConfig ?? {}),\n },\n next,\n );\n });\n\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', Authentication.STRATEGY_JWT, {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n });\n\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', Authentication.STRATEGY_BASIC, {\n type: 'http',\n scheme: 'basic',\n });\n\n rootRouter.openAPIRegistry.registerComponent(\n 'securitySchemes',\n Authentication.STRATEGY_SERVICE,\n { type: 'apiKey', in: 'header', name: ServiceAssertion.HEADER },\n );\n\n const securitySchemes = boundOptions?.securitySchemes ?? {};\n const securitySchemesEntries = Object.entries(securitySchemes);\n\n for (const [name, scheme] of securitySchemesEntries) {\n rootRouter.openAPIRegistry.registerComponent('securitySchemes', name, scheme as AnyType);\n }\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IGetProviderParams, IUIProvider } from '../common/index.js';
|
|
2
2
|
import { MemoryStorageHelper } from '@venizia/ignis-helpers';
|
|
3
|
+
/** Process-wide registry of UI providers by type; obtain it with `getInstance()`. `register` creates the built-in `swagger` and `scalar` providers and throws for any other type. */
|
|
3
4
|
export declare class UIProviderFactory extends MemoryStorageHelper<{
|
|
4
5
|
[key: string | symbol]: IUIProvider;
|
|
5
6
|
}> {
|
|
@@ -3,6 +3,7 @@ import { getError } from '@venizia/ignis-helpers/core';
|
|
|
3
3
|
import { MemoryStorageHelper } from '@venizia/ignis-helpers';
|
|
4
4
|
import { ScalarUIProvider } from './scalar.js';
|
|
5
5
|
import { SwaggerUIProvider } from './swagger.js';
|
|
6
|
+
/** Process-wide registry of UI providers by type; obtain it with `getInstance()`. `register` creates the built-in `swagger` and `scalar` providers and throws for any other type. */
|
|
6
7
|
export class UIProviderFactory extends MemoryStorageHelper {
|
|
7
8
|
static getInstance() {
|
|
8
9
|
if (!UIProviderFactory.instance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/ui/factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,M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AAI,EAAE,IAAI,gBAAgB,EAAE,CAAC,CAAC;gBAE5C,OAAO;YACT,CAAC;YACD,OAAO,CAAC,CAAC,CAAC;gBACR,MAAM,QAAQ,CAAC;oBACb,OAAO,EAAE,iDAAiD,IAAI,CAAC,IAAI,cAAc,CAAC,GAAG,eAAe,CAAC,UAAU,CAAC,EAAE;iBACnH,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IAED,sBAAsB;QACpB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,CAAC;CACF","sourcesContent":["import type { IGetProviderParams, IUIProvider } from '../common';\nimport { DocumentUITypes } from '../common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { MemoryStorageHelper } from '@venizia/ignis-helpers';\nimport { ScalarUIProvider } from './scalar';\nimport { SwaggerUIProvider } from './swagger';\n\n/** Process-wide registry of UI providers by type; obtain it with `getInstance()`. `register` creates the built-in `swagger` and `scalar` providers and throws for any other type. */\nexport class UIProviderFactory extends MemoryStorageHelper<{\n [key: string | symbol]: IUIProvider;\n}> {\n private static instance: UIProviderFactory;\n\n static getInstance() {\n if (!UIProviderFactory.instance) {\n UIProviderFactory.instance = new UIProviderFactory();\n }\n\n return UIProviderFactory.instance;\n }\n\n // One lookup, not a `isBound` probe followed by a second `get` of the same key.\n getProvider({ type }: IGetProviderParams): IUIProvider {\n const provider = this.get(type);\n\n if (!provider) {\n throw getError({\n message: `[UIProviderFactory][getProvider] Unknown UI Provider | type: ${type} | available: ${this.keys().join(', ')}`,\n });\n }\n\n return provider;\n }\n\n register(opts: { type: string }): void {\n if (this.isBound(opts.type)) {\n this.logger\n .for(this.register.name)\n .warn('Skip registering BOUNDED Document UI | type: %s', opts.type);\n\n return;\n }\n\n switch (opts.type) {\n case DocumentUITypes.SWAGGER: {\n this.set(opts.type, new SwaggerUIProvider());\n\n return;\n }\n case DocumentUITypes.SCALAR: {\n this.set(opts.type, new ScalarUIProvider());\n\n return;\n }\n default: {\n throw getError({\n message: `[register] Invalid document UI Type | uiType: ${opts.type} | valids: ${[...DocumentUITypes.SCHEME_SET]}`,\n });\n }\n }\n }\n\n getRegisteredProviders() {\n return this.keys();\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Context, Next } from 'hono';
|
|
2
2
|
import type { IUIConfig, IUIProvider } from '../common/index.js';
|
|
3
3
|
import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
4
|
+
/** Renders the Scalar UI. Needs the optional `@scalar/hono-api-reference` package, and throws on render when it is not installed. */
|
|
4
5
|
export declare class ScalarUIProvider extends BaseHelper implements IUIProvider {
|
|
5
6
|
constructor();
|
|
6
7
|
render(context: Context, config: IUIConfig, next: Next): Promise<Response | void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
|
|
2
|
+
/** Renders the Scalar UI. Needs the optional `@scalar/hono-api-reference` package, and throws on render when it is not installed. */
|
|
2
3
|
export class ScalarUIProvider extends BaseHelper {
|
|
3
4
|
constructor() {
|
|
4
5
|
super({ scope: ScalarUIProvider.name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/ui/scalar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,OAAO,gBAAiB,SAAQ,UAAU;IAC9C;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,MAAiB,EAAE,IAAU;QAC1D,IAAI,YAAyD,CAAC;QAE9D,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,4BAA4B,CAAC,CAAC;YAC1D,YAAY,GAAG,MAAM,CAAC;QACxB,CAAC;QAAC,OAAO,KAAK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/C,OAAO,MAAM,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { IUIConfig, IUIProvider } from '../common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\n/** Renders the Scalar UI. Needs the optional `@scalar/hono-api-reference` package, and throws on render when it is not installed. */\nexport class ScalarUIProvider extends BaseHelper implements IUIProvider {\n constructor() {\n super({ scope: ScalarUIProvider.name });\n }\n\n async render(context: Context, config: IUIConfig, next: Next): Promise<Response | void> {\n let scalarModule: typeof import('@scalar/hono-api-reference');\n\n try {\n const result = await import('@scalar/hono-api-reference');\n scalarModule = result;\n } catch (error) {\n this.logger\n .for(this.render.name)\n .error(\"Failed to load '@scalar/hono-api-reference' | Error: %s\", error);\n\n throw getError({\n message:\n \"[ScalarUIProvider][render] '@scalar/hono-api-reference' is required to render the Scalar UI. Please install it\",\n });\n }\n\n const { Scalar } = scalarModule;\n const { title, url, ...customConfig } = config;\n\n return Scalar({ url, pageTitle: title, ...customConfig })(context, next);\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Context, Next } from 'hono';
|
|
2
2
|
import type { IUIConfig, IUIProvider } from '../common/index.js';
|
|
3
3
|
import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
4
|
+
/** Renders the Swagger UI. Needs the optional `@hono/swagger-ui` package, and throws on render when it is not installed. */
|
|
4
5
|
export declare class SwaggerUIProvider extends BaseHelper implements IUIProvider {
|
|
5
6
|
constructor();
|
|
6
7
|
render(context: Context, config: IUIConfig, next: Next): Promise<Response | void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseHelper, getError } from '@venizia/ignis-helpers/core';
|
|
2
|
+
/** Renders the Swagger UI. Needs the optional `@hono/swagger-ui` package, and throws on render when it is not installed. */
|
|
2
3
|
export class SwaggerUIProvider extends BaseHelper {
|
|
3
4
|
constructor() {
|
|
4
5
|
super({ scope: SwaggerUIProvider.name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/ui/swagger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAC/C;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,MAAiB,EAAE,IAAU;QAC1D,IAAI,aAAgD,CAAC;QAErD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;YAChD,aAAa,GAAG,MAAM,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;iBACrB,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;YAEjE,MAAM,QAAQ,CAAC;gBACb,OAAO,EACL,wGAAwG;aAC3G,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;QACpC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../../../../src/components/api-reference/ui/swagger.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEnE,4HAA4H;AAC5H,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAC/C;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAgB,EAAE,MAAiB,EAAE,IAAU;QAC1D,IAAI,aAAgD,CAAC;QAErD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;YAChD,aAAa,GAAG,MAAM,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;iBACrB,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAC;YAEjE,MAAM,QAAQ,CAAC;gBACb,OAAO,EACL,wGAAwG;aAC3G,CAAC,CAAC;QACL,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,aAAa,CAAC;QACpC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,GAAG,MAAM,CAAC;QAE/C,OAAO,SAAS,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;CACF","sourcesContent":["import type { Context, Next } from 'hono';\nimport type { IUIConfig, IUIProvider } from '../common';\nimport { BaseHelper, getError } from '@venizia/ignis-helpers/core';\n\n/** Renders the Swagger UI. Needs the optional `@hono/swagger-ui` package, and throws on render when it is not installed. */\nexport class SwaggerUIProvider extends BaseHelper implements IUIProvider {\n constructor() {\n super({ scope: SwaggerUIProvider.name });\n }\n\n async render(context: Context, config: IUIConfig, next: Next): Promise<Response | void> {\n let swaggerModule: typeof import('@hono/swagger-ui');\n\n try {\n const result = await import('@hono/swagger-ui');\n swaggerModule = result;\n } catch (error) {\n this.logger\n .for(this.render.name)\n .error(\"Failed to load '@hono/swagger-ui' | Error: %s\", error);\n\n throw getError({\n message:\n \"[SwaggerUIProvider][render] '@hono/swagger-ui' is required to render the Swagger UI. Please install it\",\n });\n }\n\n const { swaggerUI } = swaggerModule;\n const { title, url, ...customConfig } = config;\n\n return swaggerUI({ title, url, ...customConfig })(context, next);\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BaseApplication } from '../../../base/applications/base.js';
|
|
2
2
|
import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
3
3
|
import { BaseComponent } from '@venizia/ignis-kernel';
|
|
4
|
+
/** Registers the authentication services and strategies from the options bound under `AuthenticateBindingKeys`. Throws at binding time unless JWT, basic or service options are provided. */
|
|
4
5
|
export declare class AuthenticateComponent extends BaseComponent {
|
|
5
6
|
private application;
|
|
6
7
|
constructor(application: BaseApplication);
|
|
@@ -22,6 +22,7 @@ import { ServiceAssertionSignerService } from './services/service/signer.service
|
|
|
22
22
|
import { ServiceAssertionVerifierService } from './services/service/verifier.service.js';
|
|
23
23
|
import { ServiceAuthenticationStrategy } from './strategies/service.strategy.js';
|
|
24
24
|
const DEFAULT_SECRET = 'unknown_secret';
|
|
25
|
+
/** Registers the authentication services and strategies from the options bound under `AuthenticateBindingKeys`. Throws at binding time unless JWT, basic or service options are provided. */
|
|
25
26
|
let AuthenticateComponent = AuthenticateComponent_1 = class AuthenticateComponent extends BaseComponent {
|
|
26
27
|
constructor(application) {
|
|
27
28
|
super({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../../src/components/auth/authenticate/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,8BAA8B,EAC9B,aAAa,EACb,UAAU,EACV,YAAY,EAKZ,MAAM,EAEN,aAAa,EACb,cAAc,EACd,SAAS,EACT,gBAAgB,GAKjB,MAAM,uBAAuB,CAAC;AAC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CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IACrF,CAAC;IAEO,iBAAiB,CAAC,IAAuC;QAC/D,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAEjD,IAAI,CAAC,WAAW,EAAE,iBAAiB,EAAE,CAAC;YACpC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAC/E,OAAO;QACT,CAAC;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,0EAA0E;aACpF,CAAC,CAAC;QACL,CAAC;QAED,MAAM,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAChF,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAClF,CAAC;IAED,YAAY;QACV,wBAAwB;IAC1B,CAAC;CACF,CAAA;AA/SY,qBAAqB;IAE7B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,qBAAqB,CA+SjC","sourcesContent":["import type { BaseApplication } from '@/base/applications/base';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { Binding } from '@venizia/ignis-inversion';\nimport {\n AuthenticateBindingKeys,\n Authentication,\n AuthenticationStrategyRegistry,\n BaseComponent,\n controller,\n CoreBindings,\n type IAuthenticateOptions,\n type IJWKSIssuerOptions,\n type IJWKSVerifierOptions,\n type IJWSTokenServiceOptions,\n inject,\n type IServiceAuthOptions,\n JOSEStandards,\n JWKSKeyFormats,\n JWKSModes,\n ServiceAssertion,\n type TAuthenticationRestOptions,\n type TBasicTokenServiceOptions,\n type TJWKSTokenServiceOptions,\n type TJWTTokenServiceOptions,\n} from '@venizia/ignis-kernel';\nimport { AuthControllerFactory, JWKSController } from './controllers';\nimport { ServiceCertsController } from './controllers/service-certs';\nimport {\n BasicTokenService,\n JWKSIssuerTokenService,\n JWKSVerifierTokenService,\n JWSTokenService,\n} from './services';\nimport { JoseLoader } from './services/jose-loader';\nimport { ServiceAssertionSignerService } from './services/service/signer.service';\nimport { ServiceAssertionVerifierService } from './services/service/verifier.service';\nimport { ServiceAuthenticationStrategy } from './strategies/service.strategy';\n\nconst DEFAULT_SECRET = 'unknown_secret';\n\nexport class AuthenticateComponent extends BaseComponent {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: AuthenticateComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [AuthenticateBindingKeys.REST_OPTIONS]: Binding.bind<TAuthenticationRestOptions>({\n key: AuthenticateBindingKeys.REST_OPTIONS,\n }).toValue({ useAuthController: false }),\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n const jwtOptions = this.application.get<TJWTTokenServiceOptions>({\n key: AuthenticateBindingKeys.JWT_OPTIONS,\n isOptional: true,\n });\n const basicOptions = this.application.get<TBasicTokenServiceOptions>({\n key: AuthenticateBindingKeys.BASIC_OPTIONS,\n isOptional: true,\n });\n const restOptions = this.application.get<TAuthenticationRestOptions>({\n key: AuthenticateBindingKeys.REST_OPTIONS,\n isOptional: true,\n });\n const serviceOptions = this.application.get<IServiceAuthOptions>({\n key: AuthenticateBindingKeys.SERVICE_OPTIONS,\n isOptional: true,\n });\n\n // A service that only VERIFIES assertions needs neither jwt nor basic - and that application,\n // an IGNIS app consuming no user tokens at all, is exactly what the service strategy is for.\n if (!jwtOptions && !basicOptions && !serviceOptions) {\n throw getError({\n message:\n '[AuthenticateComponent] At least one of jwtOptions, basicOptions or serviceOptions must be provided',\n });\n }\n\n const options: IAuthenticateOptions = { restOptions, jwtOptions, basicOptions, serviceOptions };\n\n if (jwtOptions) {\n switch (jwtOptions.standard) {\n case JOSEStandards.JWS: {\n this.defineJWSAuth({ options: jwtOptions.options });\n break;\n }\n case JOSEStandards.JWKS: {\n this.defineJWKSAuth({ options: jwtOptions.options });\n break;\n }\n default: {\n throw getError({\n message: `[AuthenticateComponent] Unknown JOSE standard: ${(jwtOptions as any).standard}`,\n });\n }\n }\n }\n\n this.defineBasicAuth({ basicOptions });\n this.defineServiceAuth({ serviceOptions });\n\n this.defineControllers({ options });\n\n this.defineOAuth2();\n\n return this.preloadJose({ options });\n }\n\n /**\n * Loads `jose` at boot when a configured service signs or verifies with it, so a missing or broken\n * install fails the boot instead of answering every token check with a 401.\n */\n private async preloadJose(opts: { options: IAuthenticateOptions }): Promise<void> {\n const { jwtOptions, serviceOptions } = opts.options;\n if (!jwtOptions && !serviceOptions) {\n return;\n }\n\n try {\n await JoseLoader.load();\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n this.logger.for(this.preloadJose.name).error(\"Failed to load 'jose' | Error: %s\", reason);\n\n throw getError({\n message: `[AuthenticateComponent] Cannot load 'jose', which JWT and service authentication need. Please install it | Error: ${reason}`,\n cause: error,\n });\n }\n }\n\n private defineJWSAuth(opts: { options: IJWSTokenServiceOptions }): void {\n const { options: jwsOptions } = opts;\n\n const { jwtSecret, getTokenExpiresFn } = jwsOptions;\n\n if (!jwtSecret || jwtSecret === DEFAULT_SECRET) {\n throw getError({\n message: `[defineJWSAuth] Invalid jwtSecret | Provided: ${jwtSecret}`,\n });\n }\n\n if (!getTokenExpiresFn) {\n throw getError({\n message: '[defineJWSAuth] getTokenExpiresFn is required',\n });\n }\n\n this.application\n .bind<IJWSTokenServiceOptions>({ key: AuthenticateBindingKeys.JWT_OPTIONS })\n .toValue(jwsOptions);\n this.application.service(JWSTokenService);\n\n this.logger.for(this.defineJWSAuth.name).info('JWS authentication configured');\n }\n\n private defineJWKSAuth(opts: { options: TJWKSTokenServiceOptions }): void {\n const { options: jwksOptions } = opts;\n\n switch (jwksOptions.mode) {\n case JWKSModes.ISSUER: {\n const issuerOpts = jwksOptions;\n\n if (!issuerOpts.keys?.private || !issuerOpts.keys?.public) {\n throw getError({\n message: '[defineJWKSAuth] keys.private and keys.public are required for issuer mode',\n });\n }\n\n if (!issuerOpts.keys?.format || !JWKSKeyFormats.isValid(issuerOpts.keys.format)) {\n throw getError({\n message: `[defineJWKSAuth] keys.format is required and must be one of: ${[...JWKSKeyFormats.SCHEME_SET].join(', ')}`,\n });\n }\n\n if (!issuerOpts.kid) {\n throw getError({ message: '[defineJWKSAuth] kid is required for issuer mode' });\n }\n\n if (!issuerOpts.getTokenExpiresFn) {\n throw getError({\n message: '[defineJWKSAuth] getTokenExpiresFn is required for issuer mode',\n });\n }\n\n this.application\n .bind<IJWKSIssuerOptions>({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n .toValue(issuerOpts);\n this.application.service(JWKSIssuerTokenService);\n\n // Path depends on a runtime option, so @controller can't be applied statically — decorate here instead.\n Reflect.decorate(\n [controller({ path: issuerOpts?.rest?.path ?? '/certs' })],\n JWKSController,\n );\n this.application.controller(JWKSController);\n\n this.logger\n .for(this.defineJWKSAuth.name)\n .info('JWKS issuer configured with /certs endpoint');\n break;\n }\n\n case JWKSModes.VERIFIER: {\n const verifierOpts = jwksOptions;\n\n if (!verifierOpts.jwksUrl) {\n throw getError({ message: '[defineJWKSAuth] jwksUrl is required for verifier mode' });\n }\n\n this.application\n .bind<IJWKSVerifierOptions>({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n .toValue(verifierOpts);\n this.application.service(JWKSVerifierTokenService);\n\n this.logger.for(this.defineJWKSAuth.name).info('JWKS verifier configured');\n break;\n }\n\n default: {\n // Same exhaustive-switch-narrows-to-never situation as the JOSE standard default above.\n throw getError({\n message: `[defineJWKSAuth] Invalid JWKS mode: ${(jwksOptions as { mode?: unknown }).mode}`,\n });\n }\n }\n }\n\n /**\n * Service-to-service authentication. Absent options mean no strategy is registered and no route is\n * mounted, so an application that never sets them is byte-identical to today.\n *\n * The certs route is mounted only when SIGNING keys are present. Most services are called and\n * never call; publishing a key set for a service that signs nothing advertises a capability it\n * does not have.\n */\n private defineServiceAuth(opts: { serviceOptions?: IServiceAuthOptions }): void {\n const { serviceOptions } = opts;\n\n if (!serviceOptions) {\n this.logger\n .for(this.defineServiceAuth.name)\n .debug('serviceOptions not provided, skipping service authentication');\n return;\n }\n\n if (!serviceOptions.name) {\n throw getError({\n message:\n '[defineServiceAuth] name is required | it is the issuer this service stamps and the audience it demands',\n });\n }\n\n if (!serviceOptions.resolvePrincipal) {\n throw getError({\n message:\n '[defineServiceAuth] resolvePrincipal is required | the framework proves WHICH SERVICE called, the application decides who that acts as',\n });\n }\n\n this.application.service(ServiceAssertionVerifierService);\n\n if (serviceOptions.keys) {\n this.application.service(ServiceAssertionSignerService);\n\n const restPath = serviceOptions.rest?.path ?? ServiceAssertion.DEFAULT_REST_PATH;\n this.application\n .bind<string>({ key: AuthenticateBindingKeys.SERVICE_CERTS_PATH })\n .toValue(restPath);\n\n // Path depends on a runtime option, so @controller cannot be applied statically.\n Reflect.decorate([controller({ path: restPath })], ServiceCertsController);\n this.application.controller(ServiceCertsController);\n }\n\n AuthenticationStrategyRegistry.getInstance().register({\n container: this.application,\n strategies: [\n { name: Authentication.STRATEGY_SERVICE, strategy: ServiceAuthenticationStrategy },\n ],\n });\n\n this.logger\n .for(this.defineServiceAuth.name)\n .info(\n 'Service authentication configured | name: %s | signs: %s | callers: %s',\n serviceOptions.name,\n Boolean(serviceOptions.keys),\n Object.keys(serviceOptions.callers ?? {}).join(', ') || 'none',\n );\n }\n\n private defineBasicAuth(opts: { basicOptions?: TBasicTokenServiceOptions }): void {\n const { basicOptions } = opts;\n\n if (!basicOptions) {\n this.logger\n .for(this.defineBasicAuth.name)\n .debug('basicOptions not provided, skipping Basic configuration');\n return;\n }\n\n if (!basicOptions.verifyCredentials) {\n throw getError({\n message: '[defineBasicAuth] verifyCredentials function is required',\n });\n }\n\n this.application\n .bind<TBasicTokenServiceOptions>({ key: AuthenticateBindingKeys.BASIC_OPTIONS })\n .toValue(basicOptions);\n this.application.service(BasicTokenService);\n\n this.logger.for(this.defineBasicAuth.name).info('Basic authentication configured');\n }\n\n private defineControllers(opts: { options: IAuthenticateOptions }): void {\n const { restOptions, jwtOptions } = opts.options;\n\n if (!restOptions?.useAuthController) {\n this.logger.for(this.defineControllers.name).debug('Auth controller disabled');\n return;\n }\n\n if (!jwtOptions) {\n throw getError({\n message: '[defineControllers] Auth controller requires jwtOptions to be configured',\n });\n }\n\n const AuthController = AuthControllerFactory.define(restOptions.controllerOpts);\n this.application.controller(AuthController);\n\n this.logger.for(this.defineControllers.name).info('Auth controller registered');\n }\n\n defineOAuth2() {\n // TODO Implement OAuth2\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../../src/components/auth/authenticate/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,cAAc,EACd,8BAA8B,EAC9B,aAAa,EACb,UAAU,EACV,YAAY,EAKZ,MAAM,EAEN,aAAa,EACb,cAAc,EACd,SAAS,EACT,gBAAgB,GAKjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,6B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C,iBAAiB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAE/E,OAAO;QACT,CAAC;QAED,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,0EAA0E;aACpF,CAAC,CAAC;QACL,CAAC;QAED,MAAM,cAAc,GAAG,qBAAqB,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;QAChF,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;IAClF,CAAC;IAED,YAAY;QACV,wBAAwB;IAC1B,CAAC;CACF,CAAA;AAnTY,qBAAqB;IAE7B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,YAAY,CAAC,oBAAoB,EAAE,CAAC,CAAA;;GAF1C,qBAAqB,CAmTjC","sourcesContent":["import type { BaseApplication } from '@/base/applications/base';\nimport { type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { Binding } from '@venizia/ignis-inversion';\nimport {\n AuthenticateBindingKeys,\n Authentication,\n AuthenticationStrategyRegistry,\n BaseComponent,\n controller,\n CoreBindings,\n type IAuthenticateOptions,\n type IJWKSIssuerOptions,\n type IJWKSVerifierOptions,\n type IJWSTokenServiceOptions,\n inject,\n type IServiceAuthOptions,\n JOSEStandards,\n JWKSKeyFormats,\n JWKSModes,\n ServiceAssertion,\n type TAuthenticationRestOptions,\n type TBasicTokenServiceOptions,\n type TJWKSTokenServiceOptions,\n type TJWTTokenServiceOptions,\n} from '@venizia/ignis-kernel';\nimport { AuthControllerFactory, JWKSController } from './controllers';\nimport { ServiceCertsController } from './controllers/service-certs';\nimport {\n BasicTokenService,\n JWKSIssuerTokenService,\n JWKSVerifierTokenService,\n JWSTokenService,\n} from './services';\nimport { JoseLoader } from './services/jose-loader';\nimport { ServiceAssertionSignerService } from './services/service/signer.service';\nimport { ServiceAssertionVerifierService } from './services/service/verifier.service';\nimport { ServiceAuthenticationStrategy } from './strategies/service.strategy';\n\nconst DEFAULT_SECRET = 'unknown_secret';\n\n/** Registers the authentication services and strategies from the options bound under `AuthenticateBindingKeys`. Throws at binding time unless JWT, basic or service options are provided. */\nexport class AuthenticateComponent extends BaseComponent {\n constructor(\n @inject({ key: CoreBindings.APPLICATION_INSTANCE }) private application: BaseApplication,\n ) {\n super({\n scope: AuthenticateComponent.name,\n initDefault: { enable: true, container: application },\n bindings: {\n [AuthenticateBindingKeys.REST_OPTIONS]: Binding.bind<TAuthenticationRestOptions>({\n key: AuthenticateBindingKeys.REST_OPTIONS,\n }).toValue({ useAuthController: false }),\n },\n });\n }\n\n override binding(): ValueOrPromise<void> {\n const jwtOptions = this.application.get<TJWTTokenServiceOptions>({\n key: AuthenticateBindingKeys.JWT_OPTIONS,\n isOptional: true,\n });\n const basicOptions = this.application.get<TBasicTokenServiceOptions>({\n key: AuthenticateBindingKeys.BASIC_OPTIONS,\n isOptional: true,\n });\n const restOptions = this.application.get<TAuthenticationRestOptions>({\n key: AuthenticateBindingKeys.REST_OPTIONS,\n isOptional: true,\n });\n const serviceOptions = this.application.get<IServiceAuthOptions>({\n key: AuthenticateBindingKeys.SERVICE_OPTIONS,\n isOptional: true,\n });\n\n // A service that only VERIFIES assertions needs neither jwt nor basic - and that application,\n // an IGNIS app consuming no user tokens at all, is exactly what the service strategy is for.\n if (!jwtOptions && !basicOptions && !serviceOptions) {\n throw getError({\n message:\n '[AuthenticateComponent] At least one of jwtOptions, basicOptions or serviceOptions must be provided',\n });\n }\n\n const options: IAuthenticateOptions = { restOptions, jwtOptions, basicOptions, serviceOptions };\n\n if (jwtOptions) {\n switch (jwtOptions.standard) {\n case JOSEStandards.JWS: {\n this.defineJWSAuth({ options: jwtOptions.options });\n break;\n }\n case JOSEStandards.JWKS: {\n this.defineJWKSAuth({ options: jwtOptions.options });\n break;\n }\n default: {\n throw getError({\n message: `[AuthenticateComponent] Unknown JOSE standard: ${(jwtOptions as any).standard}`,\n });\n }\n }\n }\n\n this.defineBasicAuth({ basicOptions });\n this.defineServiceAuth({ serviceOptions });\n\n this.defineControllers({ options });\n\n this.defineOAuth2();\n\n return this.preloadJose({ options });\n }\n\n /**\n * Loads `jose` at boot when a configured service signs or verifies with it, so a missing or broken\n * install fails the boot instead of answering every token check with a 401.\n */\n private async preloadJose(opts: { options: IAuthenticateOptions }): Promise<void> {\n const { jwtOptions, serviceOptions } = opts.options;\n\n if (!jwtOptions && !serviceOptions) {\n return;\n }\n\n try {\n await JoseLoader.load();\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n this.logger.for(this.preloadJose.name).error(\"Failed to load 'jose' | Error: %s\", reason);\n\n throw getError({\n message: `[AuthenticateComponent] Cannot load 'jose', which JWT and service authentication need. Please install it | Error: ${reason}`,\n cause: error,\n });\n }\n }\n\n private defineJWSAuth(opts: { options: IJWSTokenServiceOptions }): void {\n const { options: jwsOptions } = opts;\n\n const { jwtSecret, getTokenExpiresFn } = jwsOptions;\n\n if (!jwtSecret || jwtSecret === DEFAULT_SECRET) {\n throw getError({\n message: `[defineJWSAuth] Invalid jwtSecret | Provided: ${jwtSecret}`,\n });\n }\n\n if (!getTokenExpiresFn) {\n throw getError({\n message: '[defineJWSAuth] getTokenExpiresFn is required',\n });\n }\n\n this.application\n .bind<IJWSTokenServiceOptions>({ key: AuthenticateBindingKeys.JWT_OPTIONS })\n .toValue(jwsOptions);\n this.application.service(JWSTokenService);\n\n this.logger.for(this.defineJWSAuth.name).info('JWS authentication configured');\n }\n\n private defineJWKSAuth(opts: { options: TJWKSTokenServiceOptions }): void {\n const { options: jwksOptions } = opts;\n\n switch (jwksOptions.mode) {\n case JWKSModes.ISSUER: {\n const issuerOpts = jwksOptions;\n\n if (!issuerOpts.keys?.private || !issuerOpts.keys?.public) {\n throw getError({\n message: '[defineJWKSAuth] keys.private and keys.public are required for issuer mode',\n });\n }\n\n if (!issuerOpts.keys?.format || !JWKSKeyFormats.isValid(issuerOpts.keys.format)) {\n throw getError({\n message: `[defineJWKSAuth] keys.format is required and must be one of: ${[...JWKSKeyFormats.SCHEME_SET].join(', ')}`,\n });\n }\n\n if (!issuerOpts.kid) {\n throw getError({ message: '[defineJWKSAuth] kid is required for issuer mode' });\n }\n\n if (!issuerOpts.getTokenExpiresFn) {\n throw getError({\n message: '[defineJWKSAuth] getTokenExpiresFn is required for issuer mode',\n });\n }\n\n this.application\n .bind<IJWKSIssuerOptions>({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n .toValue(issuerOpts);\n this.application.service(JWKSIssuerTokenService);\n\n // Path depends on a runtime option, so @controller can't be applied statically — decorate here instead.\n Reflect.decorate(\n [controller({ path: issuerOpts?.rest?.path ?? '/certs' })],\n JWKSController,\n );\n this.application.controller(JWKSController);\n\n this.logger\n .for(this.defineJWKSAuth.name)\n .info('JWKS issuer configured with /certs endpoint');\n break;\n }\n\n case JWKSModes.VERIFIER: {\n const verifierOpts = jwksOptions;\n\n if (!verifierOpts.jwksUrl) {\n throw getError({ message: '[defineJWKSAuth] jwksUrl is required for verifier mode' });\n }\n\n this.application\n .bind<IJWKSVerifierOptions>({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n .toValue(verifierOpts);\n this.application.service(JWKSVerifierTokenService);\n\n this.logger.for(this.defineJWKSAuth.name).info('JWKS verifier configured');\n break;\n }\n\n default: {\n // Same exhaustive-switch-narrows-to-never situation as the JOSE standard default above.\n throw getError({\n message: `[defineJWKSAuth] Invalid JWKS mode: ${(jwksOptions as { mode?: unknown }).mode}`,\n });\n }\n }\n }\n\n /**\n * Service-to-service authentication. Absent options mean no strategy is registered and no route is\n * mounted, so an application that never sets them is byte-identical to today.\n *\n * The certs route is mounted only when SIGNING keys are present. Most services are called and\n * never call; publishing a key set for a service that signs nothing advertises a capability it\n * does not have.\n */\n private defineServiceAuth(opts: { serviceOptions?: IServiceAuthOptions }): void {\n const { serviceOptions } = opts;\n\n if (!serviceOptions) {\n this.logger\n .for(this.defineServiceAuth.name)\n .debug('serviceOptions not provided, skipping service authentication');\n\n return;\n }\n\n if (!serviceOptions.name) {\n throw getError({\n message:\n '[defineServiceAuth] name is required | it is the issuer this service stamps and the audience it demands',\n });\n }\n\n if (!serviceOptions.resolvePrincipal) {\n throw getError({\n message:\n '[defineServiceAuth] resolvePrincipal is required | the framework proves WHICH SERVICE called, the application decides who that acts as',\n });\n }\n\n this.application.service(ServiceAssertionVerifierService);\n\n if (serviceOptions.keys) {\n this.application.service(ServiceAssertionSignerService);\n\n const restPath = serviceOptions.rest?.path ?? ServiceAssertion.DEFAULT_REST_PATH;\n this.application\n .bind<string>({ key: AuthenticateBindingKeys.SERVICE_CERTS_PATH })\n .toValue(restPath);\n\n // Path depends on a runtime option, so @controller cannot be applied statically.\n Reflect.decorate([controller({ path: restPath })], ServiceCertsController);\n this.application.controller(ServiceCertsController);\n }\n\n AuthenticationStrategyRegistry.getInstance().register({\n container: this.application,\n strategies: [\n { name: Authentication.STRATEGY_SERVICE, strategy: ServiceAuthenticationStrategy },\n ],\n });\n\n this.logger\n .for(this.defineServiceAuth.name)\n .info(\n 'Service authentication configured | name: %s | signs: %s | callers: %s',\n serviceOptions.name,\n Boolean(serviceOptions.keys),\n Object.keys(serviceOptions.callers ?? {}).join(', ') || 'none',\n );\n }\n\n private defineBasicAuth(opts: { basicOptions?: TBasicTokenServiceOptions }): void {\n const { basicOptions } = opts;\n\n if (!basicOptions) {\n this.logger\n .for(this.defineBasicAuth.name)\n .debug('basicOptions not provided, skipping Basic configuration');\n\n return;\n }\n\n if (!basicOptions.verifyCredentials) {\n throw getError({\n message: '[defineBasicAuth] verifyCredentials function is required',\n });\n }\n\n this.application\n .bind<TBasicTokenServiceOptions>({ key: AuthenticateBindingKeys.BASIC_OPTIONS })\n .toValue(basicOptions);\n this.application.service(BasicTokenService);\n\n this.logger.for(this.defineBasicAuth.name).info('Basic authentication configured');\n }\n\n private defineControllers(opts: { options: IAuthenticateOptions }): void {\n const { restOptions, jwtOptions } = opts.options;\n\n if (!restOptions?.useAuthController) {\n this.logger.for(this.defineControllers.name).debug('Auth controller disabled');\n\n return;\n }\n\n if (!jwtOptions) {\n throw getError({\n message: '[defineControllers] Auth controller requires jwtOptions to be configured',\n });\n }\n\n const AuthController = AuthControllerFactory.define(restOptions.controllerOpts);\n this.application.controller(AuthController);\n\n this.logger.for(this.defineControllers.name).info('Auth controller registered');\n }\n\n defineOAuth2() {\n // TODO Implement OAuth2\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from '@hono/zod-openapi';
|
|
2
2
|
import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
3
3
|
import { type IAuthService, type TDefineAuthControllerOpts } from '@venizia/ignis-kernel';
|
|
4
|
+
/** Zod schema of the JWT payload: `userId`, the `roles` (id, identifier, integer priority) and optional `clientId`, `provider` and `email`. */
|
|
4
5
|
export declare const JWTTokenPayloadSchema: z.ZodObject<{
|
|
5
6
|
userId: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
6
7
|
roles: z.ZodArray<z.ZodObject<{
|
|
@@ -19,6 +19,7 @@ import { getError } from '@venizia/ignis-helpers/core';
|
|
|
19
19
|
import { HTTP } from '@venizia/ignis-helpers/common';
|
|
20
20
|
import { ChangePasswordRequestSchema, SignInRequestSchema, SignUpRequestSchema, } from '@venizia/ignis-kernel';
|
|
21
21
|
import { Authentication, } from '@venizia/ignis-kernel';
|
|
22
|
+
/** Zod schema of the JWT payload: `userId`, the `roles` (id, identifier, integer priority) and optional `clientId`, `provider` and `email`. */
|
|
22
23
|
export const JWTTokenPayloadSchema = z.object({
|
|
23
24
|
userId: z.string().or(z.number()),
|
|
24
25
|
roles: z.array(z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","source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AE,SAAS,EAAE,CAAC,CAAC,CAAC;QAE1D,OAAO,cAAc,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { BaseRestController } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { controller } from '@venizia/ignis-kernel';\nimport { OpenApiResponses } from '@venizia/ignis-kernel';\nimport { NotSupportedUtility } from '@venizia/ignis-kernel';\nimport { AnyObjectSchema } from '@venizia/ignis-kernel';\nimport { z } from '@hono/zod-openapi';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport {\n ChangePasswordRequestSchema,\n SignInRequestSchema,\n SignUpRequestSchema,\n} from '@venizia/ignis-kernel';\nimport {\n Authentication,\n type IAuthService,\n type TDefineAuthControllerOpts,\n} from '@venizia/ignis-kernel';\n\nexport const JWTTokenPayloadSchema = z.object({\n userId: z.string().or(z.number()),\n roles: z.array(\n z.object({\n id: z.string().or(z.number()),\n identifier: z.string(),\n priority: z.number().int(),\n }),\n ),\n clientId: z.string().optional(),\n provider: z.string().optional(),\n email: z.email().optional(),\n});\n\n/** Builds the decorated REST controller of the authentication routes (sign-in, sign-up, change-password, who-am-i). */\nexport class AuthControllerFactory {\n static define(opts: TDefineAuthControllerOpts) {\n const {\n restPath = '/auth',\n serviceKey,\n requireAuthenticatedSignUp = false,\n payload = {},\n } = opts;\n\n @controller({ path: restPath })\n class AuthController extends BaseRestController {\n service: IAuthService;\n\n constructor(authService: IAuthService) {\n super({\n scope: AuthController.name,\n path: restPath,\n isStrict: true,\n });\n\n if (!authService) {\n throw getError({\n message:\n '[AuthController] Failed to init auth controller | Invalid injectable authentication service!',\n });\n }\n\n this.service = authService;\n }\n\n override binding(): ValueOrPromise<void> {\n this.defineRoute({\n configs: {\n description: 'Sign In',\n path: '/sign-in',\n method: HTTP.Methods.POST,\n request: {\n body: OpenApiResponses.jsonContent({\n description: 'Sign-in request body',\n required: true,\n schema: payload?.signIn?.request?.schema ?? SignInRequestSchema,\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.signIn?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n },\n handler: async (context) => {\n const body = await context.req.json();\n const rs = await this.service.signIn(context, body);\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n this.defineRoute({\n configs: {\n description: 'Sign Up',\n path: '/sign-up',\n method: HTTP.Methods.POST,\n authenticate: {\n strategies: !requireAuthenticatedSignUp ? [] : [Authentication.STRATEGY_JWT],\n },\n request: {\n body: OpenApiResponses.jsonContent({\n description: 'Sign-up request body',\n required: true,\n schema: payload?.signUp?.request?.schema ?? SignUpRequestSchema,\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.signUp?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n },\n handler: async (context) => {\n const body = await context.req.json();\n const rs = await this.service.signUp(context, body);\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n this.defineRoute({\n configs: {\n description: 'Change password',\n path: '/change-password',\n method: HTTP.Methods.POST,\n request: {\n body: OpenApiResponses.jsonContent({\n description: 'Change password request body',\n required: true,\n schema: payload?.changePassword?.request?.schema ?? ChangePasswordRequestSchema,\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.changePassword?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n authenticate: { strategies: [Authentication.STRATEGY_JWT] },\n },\n handler: async (context) => {\n const body = await context.req.json();\n const rs = await this.service.changePassword(context, body);\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n // Re-issues an access token using the caller's currently valid JWT — no separate refresh token. Implementers must enforce their own rotation/revocation policy if needed.\n this.defineRoute({\n configs: {\n description: 'Refresh access token',\n path: '/token/refresh',\n method: HTTP.Methods.POST,\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.refreshToken?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n authenticate: { strategies: [Authentication.STRATEGY_JWT] },\n },\n handler: async (context) => {\n if (!this.service.refreshToken) {\n return NotSupportedUtility.throwNotSupported({\n scope: AuthController.name,\n feature: 'refreshToken',\n logger: this.logger,\n });\n }\n\n const rs = await this.service.refreshToken(context);\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n this.defineRoute({\n configs: {\n path: '/who-am-i',\n method: HTTP.Methods.GET,\n request: {\n query: z.object({\n withUserInformation: z\n .enum(['true', 'false', '1', '0'])\n .transform((value) => value === 'true' || value === '1')\n .optional()\n .openapi({\n description: 'Whether to attach user information to currentUser',\n }),\n }),\n },\n responses: {\n [HTTP.ResultCodes.RS_2.Ok]: OpenApiResponses.jsonContent({\n description: 'Success Response',\n schema: JWTTokenPayloadSchema.extend({\n userInformation: (\n payload?.getUserInformation?.response?.schema ?? AnyObjectSchema\n )\n .optional()\n .openapi({\n description: 'Attached when withUserInformation is truthy',\n }),\n }),\n }),\n },\n authenticate: { strategies: [Authentication.STRATEGY_JWT] },\n },\n handler: async (context) => {\n const { withUserInformation = false } = context.req.valid<{\n withUserInformation?: boolean;\n }>('query');\n\n const currentUser = context.get(Authentication.CURRENT_USER);\n let rs = currentUser;\n\n if (withUserInformation) {\n if (!this.service.getUserInformation) {\n return NotSupportedUtility.throwNotSupported({\n scope: AuthController.name,\n feature: 'getUserInformation',\n logger: this.logger,\n });\n }\n\n const userInformation = await this.service.getUserInformation(context, {});\n rs = Object.assign({}, currentUser, { userInformation });\n }\n\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n this.defineRoute({\n configs: {\n description: 'Get current user information',\n path: '/me',\n method: HTTP.Methods.GET,\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.getUserInformation?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n authenticate: { strategies: [Authentication.STRATEGY_JWT] },\n },\n handler: async (context) => {\n if (!this.service.getUserInformation) {\n return NotSupportedUtility.throwNotSupported({\n scope: AuthController.name,\n feature: 'getUserInformation',\n logger: this.logger,\n });\n }\n\n const rs = await this.service.getUserInformation(context, {});\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n }\n\n inject({ key: serviceKey })(AuthController, undefined, 0);\n\n return AuthController;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authenticate/controllers/factory.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,IAAI,EAAuB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,GAGf,MAAM,uBAAuB,CAAC;AAE/B,+IAA+I;AAC/I,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,KAAK,EAAE,CAAC,CAAC,KAAK,CACZ,CAAC,CAAC,MAAM,CAAC;QACP,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAC7B,UAAU,EA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I,CAAC,EAAE,CAAC,CAAC;oBACpD,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAA;QAjNK,cAAc;YADnB,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;;WACzB,cAAc,CAiNnB;QAED,MAAM,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,CAAC,CAAC,cAAc,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QAE1D,OAAO,cAAc,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { BaseRestController } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { controller } from '@venizia/ignis-kernel';\nimport { OpenApiResponses } from '@venizia/ignis-kernel';\nimport { NotSupportedUtility } from '@venizia/ignis-kernel';\nimport { AnyObjectSchema } from '@venizia/ignis-kernel';\nimport { z } from '@hono/zod-openapi';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport {\n ChangePasswordRequestSchema,\n SignInRequestSchema,\n SignUpRequestSchema,\n} from '@venizia/ignis-kernel';\nimport {\n Authentication,\n type IAuthService,\n type TDefineAuthControllerOpts,\n} from '@venizia/ignis-kernel';\n\n/** Zod schema of the JWT payload: `userId`, the `roles` (id, identifier, integer priority) and optional `clientId`, `provider` and `email`. */\nexport const JWTTokenPayloadSchema = z.object({\n userId: z.string().or(z.number()),\n roles: z.array(\n z.object({\n id: z.string().or(z.number()),\n identifier: z.string(),\n priority: z.number().int(),\n }),\n ),\n clientId: z.string().optional(),\n provider: z.string().optional(),\n email: z.email().optional(),\n});\n\n/** Builds the decorated REST controller of the authentication routes (sign-in, sign-up, change-password, who-am-i). */\nexport class AuthControllerFactory {\n static define(opts: TDefineAuthControllerOpts) {\n const {\n restPath = '/auth',\n serviceKey,\n requireAuthenticatedSignUp = false,\n payload = {},\n } = opts;\n\n @controller({ path: restPath })\n class AuthController extends BaseRestController {\n service: IAuthService;\n\n constructor(authService: IAuthService) {\n super({\n scope: AuthController.name,\n path: restPath,\n isStrict: true,\n });\n\n if (!authService) {\n throw getError({\n message:\n '[AuthController] Failed to init auth controller | Invalid injectable authentication service!',\n });\n }\n\n this.service = authService;\n }\n\n override binding(): ValueOrPromise<void> {\n this.defineRoute({\n configs: {\n description: 'Sign In',\n path: '/sign-in',\n method: HTTP.Methods.POST,\n request: {\n body: OpenApiResponses.jsonContent({\n description: 'Sign-in request body',\n required: true,\n schema: payload?.signIn?.request?.schema ?? SignInRequestSchema,\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.signIn?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n },\n handler: async (context) => {\n const body = await context.req.json();\n const rs = await this.service.signIn(context, body);\n\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n this.defineRoute({\n configs: {\n description: 'Sign Up',\n path: '/sign-up',\n method: HTTP.Methods.POST,\n authenticate: {\n strategies: !requireAuthenticatedSignUp ? [] : [Authentication.STRATEGY_JWT],\n },\n request: {\n body: OpenApiResponses.jsonContent({\n description: 'Sign-up request body',\n required: true,\n schema: payload?.signUp?.request?.schema ?? SignUpRequestSchema,\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.signUp?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n },\n handler: async (context) => {\n const body = await context.req.json();\n const rs = await this.service.signUp(context, body);\n\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n this.defineRoute({\n configs: {\n description: 'Change password',\n path: '/change-password',\n method: HTTP.Methods.POST,\n request: {\n body: OpenApiResponses.jsonContent({\n description: 'Change password request body',\n required: true,\n schema: payload?.changePassword?.request?.schema ?? ChangePasswordRequestSchema,\n }),\n },\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.changePassword?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n authenticate: { strategies: [Authentication.STRATEGY_JWT] },\n },\n handler: async (context) => {\n const body = await context.req.json();\n const rs = await this.service.changePassword(context, body);\n\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n // Re-issues an access token using the caller's currently valid JWT — no separate refresh token. Implementers must enforce their own rotation/revocation policy if needed.\n this.defineRoute({\n configs: {\n description: 'Refresh access token',\n path: '/token/refresh',\n method: HTTP.Methods.POST,\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.refreshToken?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n authenticate: { strategies: [Authentication.STRATEGY_JWT] },\n },\n handler: async (context) => {\n if (!this.service.refreshToken) {\n return NotSupportedUtility.throwNotSupported({\n scope: AuthController.name,\n feature: 'refreshToken',\n logger: this.logger,\n });\n }\n\n const rs = await this.service.refreshToken(context);\n\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n this.defineRoute({\n configs: {\n path: '/who-am-i',\n method: HTTP.Methods.GET,\n request: {\n query: z.object({\n withUserInformation: z\n .enum(['true', 'false', '1', '0'])\n .transform((value) => value === 'true' || value === '1')\n .optional()\n .openapi({\n description: 'Whether to attach user information to currentUser',\n }),\n }),\n },\n responses: {\n [HTTP.ResultCodes.RS_2.Ok]: OpenApiResponses.jsonContent({\n description: 'Success Response',\n schema: JWTTokenPayloadSchema.extend({\n userInformation: (\n payload?.getUserInformation?.response?.schema ?? AnyObjectSchema\n )\n .optional()\n .openapi({\n description: 'Attached when withUserInformation is truthy',\n }),\n }),\n }),\n },\n authenticate: { strategies: [Authentication.STRATEGY_JWT] },\n },\n handler: async (context) => {\n const { withUserInformation = false } = context.req.valid<{\n withUserInformation?: boolean;\n }>('query');\n\n const currentUser = context.get(Authentication.CURRENT_USER);\n let rs = currentUser;\n\n if (withUserInformation) {\n if (!this.service.getUserInformation) {\n return NotSupportedUtility.throwNotSupported({\n scope: AuthController.name,\n feature: 'getUserInformation',\n logger: this.logger,\n });\n }\n\n const userInformation = await this.service.getUserInformation(context, {});\n rs = Object.assign({}, currentUser, { userInformation });\n }\n\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n\n this.defineRoute({\n configs: {\n description: 'Get current user information',\n path: '/me',\n method: HTTP.Methods.GET,\n responses: OpenApiResponses.jsonResponse({\n schema: payload?.getUserInformation?.response?.schema ?? AnyObjectSchema,\n description: 'Success Response',\n }),\n authenticate: { strategies: [Authentication.STRATEGY_JWT] },\n },\n handler: async (context) => {\n if (!this.service.getUserInformation) {\n return NotSupportedUtility.throwNotSupported({\n scope: AuthController.name,\n feature: 'getUserInformation',\n logger: this.logger,\n });\n }\n\n const rs = await this.service.getUserInformation(context, {});\n\n return context.json(rs, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n }\n\n inject({ key: serviceKey })(AuthController, undefined, 0);\n\n return AuthController;\n }\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BaseRestController } from '@venizia/ignis-kernel';
|
|
2
2
|
import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
3
3
|
import { JWKSIssuerTokenService } from '../../services/index.js';
|
|
4
|
+
/** Serves the public JWKS from `JWKSIssuerTokenService` for external verifiers, with a one-hour `Cache-Control` max-age. Mounted at `/certs` unless the issuer options set `rest.path`. */
|
|
4
5
|
export declare class JWKSController extends BaseRestController {
|
|
5
6
|
private jwksService;
|
|
6
7
|
constructor(jwksService: JWKSIssuerTokenService);
|
|
@@ -18,6 +18,7 @@ import { HTTP } from '@venizia/ignis-helpers/common';
|
|
|
18
18
|
import { BindingKeys } from '@venizia/ignis-inversion';
|
|
19
19
|
import { JWKSIssuerTokenService } from '../../services/index.js';
|
|
20
20
|
import { RouteConfigs } from './definitions.js';
|
|
21
|
+
/** Serves the public JWKS from `JWKSIssuerTokenService` for external verifiers, with a one-hour `Cache-Control` max-age. Mounted at `/certs` unless the issuer options set `rest.path`. */
|
|
21
22
|
let JWKSController = JWKSController_1 = class JWKSController extends BaseRestController {
|
|
22
23
|
constructor(jwksService) {
|
|
23
24
|
super({
|