@venizia/ignis 0.4.8-0 → 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 +19 -0
- 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/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/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/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/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/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.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/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/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/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/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/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/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/preset.json +4 -4
- package/dist/presets/lib/preset.json +3 -3
- package/dist/presets/shared/preset.json +1 -1
- package/package.json +8 -8
|
@@ -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/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,6BAA6B,EAAE,MAAM,mCAAmC,CAAC;AAClF,OAAO,EAAE,+BAA+B,EAAE,MAAM,qCAAqC,CAAC;AACtF,OAAO,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAE9E,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,IAAa,qBAAqB,6BAAlC,MAAa,qBAAsB,SAAQ,aAAa;IACtD,YAC8D,WAA4B;QAExF,KAAK,CAAC;YACJ,KAAK,EAAE,uBAAqB,CAAC,IAAI;YACjC,WAAW,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;YACrD,QAAQ,EAAE;gBACR,CAAC,uBAAuB,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,IAAI,CAA6B;oBAC/E,GAAG,EAAE,uBAAuB,CAAC,YAAY;iBAC1C,CAAC,CAAC,OAAO,C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AAM,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\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
|
+
{"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,uBAA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E,OAAO,CAAC,YAAY,CAAC,CAAC;QACzB,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAE5C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,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;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","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,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC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,CAAC;wBACL,CAAC;wBAED,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;wBAE9D,OAAO,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,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\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
|
+
{"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,EAC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EAAE,OAAO,EAAE,EAAE;wBACzB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC;4BACrC,OAAO,mBAAmB,CAAC,iBAAiB,CAAC;gCAC3C,KAAK,EAAE,gBAAc,CAAC,IAAI;gCAC1B,OAAO,EAAE,oBAAoB;gCAC7B,MAAM,EAAE,IAAI,CAAC,MAAM;6BACpB,CAAC,CAAC;wBACL,CAAC;wBAED,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;wBAE9D,OAAO,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,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({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/controllers/jwks/controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAuB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,IAAa,cAAc,sBAA3B,MAAa,cAAe,SAAQ,kBAAkB;IACpD,YAOU,WAAmC;QAE3C,KAAK,CAAC;YACJ,KAAK,EAAE,gBAAc,CAAC,IAAI;YAC1B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QANK,gBAAW,GAAX,WAAW,CAAwB;IAO7C,CAAC;IAEQ,OAAO;QACd,IAAI,CAAC,WAAW,CAAC;YACf,OAAO,EAAE,YAAY,CAAC,cAAc;YACpC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBACzB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;gBACnD,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,oDAAoD,CAAC,CAAC;gBAEtF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA5BY,cAAc;IAEtB,WAAA,MAAM,CAAC;QACN,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC;YACrB,SAAS,EAAE,iBAAiB,CAAC,OAAO;YACpC,GAAG,EAAE,sBAAsB,CAAC,IAAI;SACjC,CAAC;KACH,CAAC,CAAA;qCACmB,sBAAsB;GARlC,cAAc,CA4B1B","sourcesContent":["import { BaseRestController } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { BindingKeys } from '@venizia/ignis-inversion';\nimport { JWKSIssuerTokenService } from '../../services';\nimport { RouteConfigs } from './definitions';\n\nexport class JWKSController extends BaseRestController {\n constructor(\n @inject({\n key: BindingKeys.build({\n namespace: BindingNamespaces.SERVICE,\n key: JWKSIssuerTokenService.name,\n }),\n })\n private jwksService: JWKSIssuerTokenService,\n ) {\n super({\n scope: JWKSController.name,\n path: '/certs',\n isStrict: true,\n });\n }\n\n override binding(): ValueOrPromise<void> {\n this.defineRoute({\n configs: RouteConfigs.GET_JWKS_CERTS,\n handler: async (context) => {\n const jwks = await this.jwksService.getJWKSAsync();\n context.header('Cache-Control', 'public, max-age=3600, stale-while-revalidate=86400');\n\n return context.json(jwks, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/controllers/jwks/controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAuB,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,2LAA2L;AAC3L,IAAa,cAAc,sBAA3B,MAAa,cAAe,SAAQ,kBAAkB;IACpD,YAOU,WAAmC;QAE3C,KAAK,CAAC;YACJ,KAAK,EAAE,gBAAc,CAAC,IAAI;YAC1B,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QANK,gBAAW,GAAX,WAAW,CAAwB;IAO7C,CAAC;IAEQ,OAAO;QACd,IAAI,CAAC,WAAW,CAAC;YACf,OAAO,EAAE,YAAY,CAAC,cAAc;YACpC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;gBACzB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;gBACnD,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,oDAAoD,CAAC,CAAC;gBAEtF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YACtD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA5BY,cAAc;IAEtB,WAAA,MAAM,CAAC;QACN,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC;YACrB,SAAS,EAAE,iBAAiB,CAAC,OAAO;YACpC,GAAG,EAAE,sBAAsB,CAAC,IAAI;SACjC,CAAC;KACH,CAAC,CAAA;qCACmB,sBAAsB;GARlC,cAAc,CA4B1B","sourcesContent":["import { BaseRestController } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { HTTP, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { BindingKeys } from '@venizia/ignis-inversion';\nimport { JWKSIssuerTokenService } from '../../services';\nimport { RouteConfigs } from './definitions';\n\n/** 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`. */\nexport class JWKSController extends BaseRestController {\n constructor(\n @inject({\n key: BindingKeys.build({\n namespace: BindingNamespaces.SERVICE,\n key: JWKSIssuerTokenService.name,\n }),\n })\n private jwksService: JWKSIssuerTokenService,\n ) {\n super({\n scope: JWKSController.name,\n path: '/certs',\n isStrict: true,\n });\n }\n\n override binding(): ValueOrPromise<void> {\n this.defineRoute({\n configs: RouteConfigs.GET_JWKS_CERTS,\n handler: async (context) => {\n const jwks = await this.jwksService.getJWKSAsync();\n context.header('Cache-Control', 'public, max-age=3600, stale-while-revalidate=86400');\n\n return context.json(jwks, HTTP.ResultCodes.RS_2.Ok);\n },\n });\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { type IJWKSIssuerOptions, type IJWTIssueClaims, type IJWTTokenPayload, t
|
|
|
3
3
|
import { type Env } from 'hono';
|
|
4
4
|
import type { CryptoKey, JWK } from 'jose';
|
|
5
5
|
import { AbstractJWKSTokenService } from './abstract.service.js';
|
|
6
|
+
/** Signs tokens with a private key loaded from `IJWKSIssuerOptions` and exposes the matching public keys as a JWKS via `getJWKSAsync()`. */
|
|
6
7
|
export declare class JWKSIssuerTokenService<E extends Env = Env> extends AbstractJWKSTokenService<E> {
|
|
7
8
|
protected options: IJWKSIssuerOptions;
|
|
8
9
|
protected privateKey: TNullable<CryptoKey | Uint8Array>;
|
|
@@ -17,6 +17,7 @@ import { AuthenticateBindingKeys, inject, JWKSKeyDrivers, JWKSKeyFormats, } from
|
|
|
17
17
|
import { readFile } from 'node:fs/promises';
|
|
18
18
|
import { JoseLoader } from '../../jose-loader.js';
|
|
19
19
|
import { AbstractJWKSTokenService } from './abstract.service.js';
|
|
20
|
+
/** Signs tokens with a private key loaded from `IJWKSIssuerOptions` and exposes the matching public keys as a JWKS via `getJWKSAsync()`. */
|
|
20
21
|
let JWKSIssuerTokenService = JWKSIssuerTokenService_1 = class JWKSIssuerTokenService extends AbstractJWKSTokenService {
|
|
21
22
|
constructor(options) {
|
|
22
23
|
super({ scope: JWKSIssuerTokenService_1.name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issuer.service.js","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/issuer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAuC,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,uBAAuB,EAIvB,MAAM,EACN,cAAc,EACd,cAAc,GAEf,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,IAAa,sBAAsB,8BAAnC,MAAa,sBAA4C,SAAQ,wBAA2B;IAK1F,YAEE,OAAqC;QAErC,KAAK,CAAC,EAAE,KAAK,EAAE,wBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC;QAFpC,YAAO,GAAP,OAAO,CAAoB;QAN7B,eAAU,GAAsC,IAAI,CAAC;QACrD,cAAS,GAA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C;YACrB,MAAM,QAAQ,CAAC,EAAE,OAAO,EAAE,qCAAqC,EAAE,CAAC,CAAC;QACrE,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEkB,wBAAwB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,iBAAiB,CAAC;IACxC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,QAAQ,CAAC;gBACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;gBACrD,OAAO,EAAE,iFAAiF;aAC3F,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAE/B,OAAO,IAAI,CAAC,IAAK,CAAC;IACpB,CAAC;CACF,CAAA;AArOY,sBAAsB;IAM9B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAA;;GAN7C,sBAAsB,CAqOlC","sourcesContent":["import { HTTP, type TNullable, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthenticateBindingKeys,\n type IJWKSIssuerOptions,\n type IJWTIssueClaims,\n type IJWTTokenPayload,\n inject,\n JWKSKeyDrivers,\n JWKSKeyFormats,\n type TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { type Env } from 'hono';\nimport type { CryptoKey, JWK } from 'jose';\nimport { readFile } from 'node:fs/promises';\nimport { JoseLoader } from '../../jose-loader';\nimport { AbstractJWKSTokenService } from './abstract.service';\n\nexport class JWKSIssuerTokenService<E extends Env = Env> extends AbstractJWKSTokenService<E> {\n protected privateKey: TNullable<CryptoKey | Uint8Array> = null;\n protected publicKey: TNullable<CryptoKey | Uint8Array> = null;\n protected jwks: { keys: JWK[] } | null = null;\n\n constructor(\n @inject({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n protected options: IJWKSIssuerOptions,\n ) {\n super({ scope: JWKSIssuerTokenService.name });\n\n this.configurePayloadEncryption({\n aesAlgorithm: this.options.aesAlgorithm,\n applicationSecret: this.options.applicationSecret,\n fieldCodecs: this.options.fieldCodecs,\n sign: this.options.sign,\n });\n }\n\n protected override async initialize(): Promise<void> {\n const { keys, algorithm } = this.options;\n\n const raw = await this.resolveKeyContent({ keys });\n const built = await this.parseKeyMaterial({ raw, algorithm, keys });\n\n this.privateKey = built.priv;\n this.publicKey = built.pub;\n\n const { exportJWK } = await JoseLoader.load();\n const publicJWK = await exportJWK(this.publicKey!);\n\n // Belt and braces. `assertPublicJWK` already refused a private JWK on the way IN, but this is\n // the exact object an unauthenticated `/certs` serves - the last place to notice a signing key\n // about to be published, whatever route the material took to get here.\n this.assertPublicJWK({ jwk: publicJWK });\n\n publicJWK.kid = this.options.kid;\n publicJWK.alg = algorithm;\n publicJWK.use = 'sig';\n\n this.jwks = { keys: [publicJWK] };\n\n this.initialized = true;\n\n this.logger\n .for(this.initialize.name)\n .info(\n 'JWKS issuer initialized | driver: %s | format: %s | kid: %s',\n keys.driver,\n keys.format,\n this.options.kid,\n );\n }\n\n protected async resolveKeyContent(opts: { keys: IJWKSIssuerOptions['keys'] }) {\n const { keys } = opts;\n\n switch (keys.driver) {\n case JWKSKeyDrivers.FILE: {\n const [priv, pub] = await Promise.all([\n readFile(keys.private, 'utf-8'),\n readFile(keys.public, 'utf-8'),\n ]);\n\n return { priv, pub };\n }\n case JWKSKeyDrivers.TEXT: {\n return {\n priv: keys.private,\n pub: keys.public,\n };\n }\n default: {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] Unknown key driver: ${keys.driver}`,\n });\n }\n }\n }\n\n /**\n * Refuses a JWK carrying private material where a PUBLIC key is expected.\n *\n * The `pem` format cannot reach this state - `importSPKI` rejects a private PEM outright. The\n * `jwk` format can: `importJWK` imports whatever it is handed, and a private JWK marked\n * `\"ext\": true` yields an EXTRACTABLE key, so `exportJWK` then carries `d` straight into the\n * document `/certs` serves without authentication. Measured on jose 6.2.3: with `ext: true` the\n * round trip returns `d`; without it, export throws. So the only thing standing between a\n * mis-pasted key and a published signing key was an optional flag on attacker-irrelevant input.\n *\n * Named members, not a blanket scan: `d` covers EC/OKP and RSA's private exponent, and the CRT\n * members are the rest of an RSA private key.\n */\n protected assertPublicJWK(opts: { jwk: JWK }): void {\n const PRIVATE_MEMBERS = ['d', 'p', 'q', 'dp', 'dq', 'qi', 'k'] as const;\n\n const present = PRIVATE_MEMBERS.filter((member) => opts.jwk[member] !== undefined);\n\n if (present.length === 0) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] The public key material carries PRIVATE members (${present.join(', ')}) | this key would be published at the JWKS endpoint | pass the public half in keys.public`,\n });\n }\n\n protected async parseKeyMaterial(opts: {\n raw: { priv: string; pub: string };\n algorithm: IJWKSIssuerOptions['algorithm'];\n keys: IJWKSIssuerOptions['keys'];\n }) {\n const { raw, algorithm, keys } = opts;\n\n if (!raw.priv) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid raw.priv key!',\n });\n }\n\n if (!raw.pub) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid raw.pub key!',\n });\n }\n\n const { importJWK, importPKCS8, importSPKI } = await JoseLoader.load();\n\n switch (keys.format) {\n case JWKSKeyFormats.PEM: {\n const priv = await importPKCS8(raw.priv, algorithm);\n const pub = await importSPKI(raw.pub, algorithm);\n\n return { priv, pub };\n }\n case JWKSKeyFormats.JWK: {\n try {\n const parsed = {\n priv: JSON.parse(raw.priv) as JWK,\n pub: JSON.parse(raw.pub) as JWK,\n };\n\n this.assertPublicJWK({ jwk: parsed.pub });\n\n const priv = await importJWK(parsed.priv, algorithm);\n const pub = await importJWK(parsed.pub, algorithm);\n\n return { priv, pub };\n } catch (error) {\n this.logger\n .for(this.parseKeyMaterial.name)\n .error('Invalid JWK key material | Error: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid JWK key material',\n });\n }\n }\n default: {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] Unknown key format: ${keys.format}`,\n });\n }\n }\n }\n\n protected override async doVerify(token: string): Promise<IJWTTokenPayload> {\n await this.ensureInitialized();\n const { jwtVerify } = await JoseLoader.load();\n const result = await jwtVerify<IJWTTokenPayload>(token, this.publicKey!, this.options.verify);\n\n return this.decryptPayload({ result });\n }\n\n override async getSigner(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n claims?: IJWTIssueClaims;\n }) {\n await this.ensureInitialized();\n const { SignJWT } = await JoseLoader.load();\n\n const now = Math.floor(Date.now() / 1000);\n const expiresIn = await opts.getTokenExpiresFn();\n\n const encryptedPayload = await this.encryptPayload(opts.payload);\n\n const signer = new SignJWT({ ...encryptedPayload })\n .setProtectedHeader({ alg: this.options.algorithm, kid: this.options.kid })\n .setIssuedAt()\n .setExpirationTime(now + expiresIn)\n .setNotBefore(now);\n\n return this.applySignClaims({ signer, payload: encryptedPayload, claims: opts.claims });\n }\n\n protected override getSigningKey(): ValueOrPromise<Uint8Array | CryptoKey> {\n if (!this.privateKey) {\n throw getError({ message: '[getSigningKey] Invalid privateKey!' });\n }\n\n return this.privateKey;\n }\n\n protected override getDefaultTokenExpiresFn(): TGetTokenExpiresFn {\n return this.options.getTokenExpiresFn;\n }\n\n getJWKS(): { keys: JWK[] } {\n if (!this.jwks) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] JWKS not initialized yet. Call getJWKSAsync() instead.',\n });\n }\n\n return this.jwks;\n }\n\n async getJWKSAsync(): Promise<{ keys: JWK[] }> {\n await this.ensureInitialized();\n\n return this.jwks!;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"issuer.service.js","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/issuer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAuC,MAAM,+BAA+B,CAAC;AAC1F,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,uBAAuB,EAIvB,MAAM,EACN,cAAc,EACd,cAAc,GAEf,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,4IAA4I;AAC5I,IAAa,sBAAsB,8BAAnC,MAAa,sBAA4C,SAAQ,wBAA2B;IAK1F,YAEE,OAAqC;QAErC,KAAK,CAAC,EAAE,KAAK,EAAE,wBAAsB,CAAC,IAAI,EAAE,CAAC,CAAC;QAFpC,YAAO,GAAP,OAAO,CAAoB;QAN7B,eAAU,GAAsC,IAAI,CAAC;QACrD,cAAS,GAAsC,IAAI,CAAC;QACpD,SAAI,GAA2B,IAAI,CAAC;QAQ5C,IAAI,CAAC,0BAA0B,CAAC;YAC9B,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY;YACvC,iBAAiB,EAAE,IAAI,CAAC,OAAO,CAAC,iBAAiB;YACjD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;YACrC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;SACxB,CAAC,CAAC;IACL,CAAC;IAEkB,KAAK,CAAC,UAAU;QACjC,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,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CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,YAAY;QAChB,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAE/B,OAAO,IAAI,CAAC,IAAK,CAAC;IACpB,CAAC;CACF,CAAA;AArOY,sBAAsB;IAM9B,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAA;;GAN7C,sBAAsB,CAqOlC","sourcesContent":["import { HTTP, type TNullable, type ValueOrPromise } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthenticateBindingKeys,\n type IJWKSIssuerOptions,\n type IJWTIssueClaims,\n type IJWTTokenPayload,\n inject,\n JWKSKeyDrivers,\n JWKSKeyFormats,\n type TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { type Env } from 'hono';\nimport type { CryptoKey, JWK } from 'jose';\nimport { readFile } from 'node:fs/promises';\nimport { JoseLoader } from '../../jose-loader';\nimport { AbstractJWKSTokenService } from './abstract.service';\n\n/** Signs tokens with a private key loaded from `IJWKSIssuerOptions` and exposes the matching public keys as a JWKS via `getJWKSAsync()`. */\nexport class JWKSIssuerTokenService<E extends Env = Env> extends AbstractJWKSTokenService<E> {\n protected privateKey: TNullable<CryptoKey | Uint8Array> = null;\n protected publicKey: TNullable<CryptoKey | Uint8Array> = null;\n protected jwks: { keys: JWK[] } | null = null;\n\n constructor(\n @inject({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n protected options: IJWKSIssuerOptions,\n ) {\n super({ scope: JWKSIssuerTokenService.name });\n\n this.configurePayloadEncryption({\n aesAlgorithm: this.options.aesAlgorithm,\n applicationSecret: this.options.applicationSecret,\n fieldCodecs: this.options.fieldCodecs,\n sign: this.options.sign,\n });\n }\n\n protected override async initialize(): Promise<void> {\n const { keys, algorithm } = this.options;\n\n const raw = await this.resolveKeyContent({ keys });\n const built = await this.parseKeyMaterial({ raw, algorithm, keys });\n\n this.privateKey = built.priv;\n this.publicKey = built.pub;\n\n const { exportJWK } = await JoseLoader.load();\n const publicJWK = await exportJWK(this.publicKey!);\n\n // Belt and braces. `assertPublicJWK` already refused a private JWK on the way IN, but this is\n // the exact object an unauthenticated `/certs` serves - the last place to notice a signing key\n // about to be published, whatever route the material took to get here.\n this.assertPublicJWK({ jwk: publicJWK });\n\n publicJWK.kid = this.options.kid;\n publicJWK.alg = algorithm;\n publicJWK.use = 'sig';\n\n this.jwks = { keys: [publicJWK] };\n\n this.initialized = true;\n\n this.logger\n .for(this.initialize.name)\n .info(\n 'JWKS issuer initialized | driver: %s | format: %s | kid: %s',\n keys.driver,\n keys.format,\n this.options.kid,\n );\n }\n\n protected async resolveKeyContent(opts: { keys: IJWKSIssuerOptions['keys'] }) {\n const { keys } = opts;\n\n switch (keys.driver) {\n case JWKSKeyDrivers.FILE: {\n const [priv, pub] = await Promise.all([\n readFile(keys.private, 'utf-8'),\n readFile(keys.public, 'utf-8'),\n ]);\n\n return { priv, pub };\n }\n case JWKSKeyDrivers.TEXT: {\n return {\n priv: keys.private,\n pub: keys.public,\n };\n }\n default: {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] Unknown key driver: ${keys.driver}`,\n });\n }\n }\n }\n\n /**\n * Refuses a JWK carrying private material where a PUBLIC key is expected.\n *\n * The `pem` format cannot reach this state - `importSPKI` rejects a private PEM outright. The\n * `jwk` format can: `importJWK` imports whatever it is handed, and a private JWK marked\n * `\"ext\": true` yields an EXTRACTABLE key, so `exportJWK` then carries `d` straight into the\n * document `/certs` serves without authentication. Measured on jose 6.2.3: with `ext: true` the\n * round trip returns `d`; without it, export throws. So the only thing standing between a\n * mis-pasted key and a published signing key was an optional flag on attacker-irrelevant input.\n *\n * Named members, not a blanket scan: `d` covers EC/OKP and RSA's private exponent, and the CRT\n * members are the rest of an RSA private key.\n */\n protected assertPublicJWK(opts: { jwk: JWK }): void {\n const PRIVATE_MEMBERS = ['d', 'p', 'q', 'dp', 'dq', 'qi', 'k'] as const;\n\n const present = PRIVATE_MEMBERS.filter((member) => opts.jwk[member] !== undefined);\n\n if (present.length === 0) {\n return;\n }\n\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] The public key material carries PRIVATE members (${present.join(', ')}) | this key would be published at the JWKS endpoint | pass the public half in keys.public`,\n });\n }\n\n protected async parseKeyMaterial(opts: {\n raw: { priv: string; pub: string };\n algorithm: IJWKSIssuerOptions['algorithm'];\n keys: IJWKSIssuerOptions['keys'];\n }) {\n const { raw, algorithm, keys } = opts;\n\n if (!raw.priv) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid raw.priv key!',\n });\n }\n\n if (!raw.pub) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid raw.pub key!',\n });\n }\n\n const { importJWK, importPKCS8, importSPKI } = await JoseLoader.load();\n\n switch (keys.format) {\n case JWKSKeyFormats.PEM: {\n const priv = await importPKCS8(raw.priv, algorithm);\n const pub = await importSPKI(raw.pub, algorithm);\n\n return { priv, pub };\n }\n case JWKSKeyFormats.JWK: {\n try {\n const parsed = {\n priv: JSON.parse(raw.priv) as JWK,\n pub: JSON.parse(raw.pub) as JWK,\n };\n\n this.assertPublicJWK({ jwk: parsed.pub });\n\n const priv = await importJWK(parsed.priv, algorithm);\n const pub = await importJWK(parsed.pub, algorithm);\n\n return { priv, pub };\n } catch (error) {\n this.logger\n .for(this.parseKeyMaterial.name)\n .error('Invalid JWK key material | Error: %s', error);\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] Invalid JWK key material',\n });\n }\n }\n default: {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: `[JWKSIssuerTokenService] Unknown key format: ${keys.format}`,\n });\n }\n }\n }\n\n protected override async doVerify(token: string): Promise<IJWTTokenPayload> {\n await this.ensureInitialized();\n const { jwtVerify } = await JoseLoader.load();\n const result = await jwtVerify<IJWTTokenPayload>(token, this.publicKey!, this.options.verify);\n\n return this.decryptPayload({ result });\n }\n\n override async getSigner(opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n claims?: IJWTIssueClaims;\n }) {\n await this.ensureInitialized();\n const { SignJWT } = await JoseLoader.load();\n\n const now = Math.floor(Date.now() / 1000);\n const expiresIn = await opts.getTokenExpiresFn();\n\n const encryptedPayload = await this.encryptPayload(opts.payload);\n\n const signer = new SignJWT({ ...encryptedPayload })\n .setProtectedHeader({ alg: this.options.algorithm, kid: this.options.kid })\n .setIssuedAt()\n .setExpirationTime(now + expiresIn)\n .setNotBefore(now);\n\n return this.applySignClaims({ signer, payload: encryptedPayload, claims: opts.claims });\n }\n\n protected override getSigningKey(): ValueOrPromise<Uint8Array | CryptoKey> {\n if (!this.privateKey) {\n throw getError({ message: '[getSigningKey] Invalid privateKey!' });\n }\n\n return this.privateKey;\n }\n\n protected override getDefaultTokenExpiresFn(): TGetTokenExpiresFn {\n return this.options.getTokenExpiresFn;\n }\n\n getJWKS(): { keys: JWK[] } {\n if (!this.jwks) {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSIssuerTokenService] JWKS not initialized yet. Call getJWKSAsync() instead.',\n });\n }\n\n return this.jwks;\n }\n\n async getJWKSAsync(): Promise<{ keys: JWK[] }> {\n await this.ensureInitialized();\n\n return this.jwks!;\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { type IJWKSVerifierOptions, type IJWTTokenPayload, type TGetTokenExpires
|
|
|
2
2
|
import { type Env } from 'hono';
|
|
3
3
|
import type { createRemoteJWKSet, SignJWT } from 'jose';
|
|
4
4
|
import { AbstractJWKSTokenService } from './abstract.service.js';
|
|
5
|
+
/** Verifies tokens against a remote JWKS fetched from `jwksUrl`. The key set is cached for `cacheTtlMs` (default 43_200_000 ms) with a `cooldownMs` refetch cooldown (default 30_000 ms). */
|
|
5
6
|
export declare class JWKSVerifierTokenService<E extends Env = Env> extends AbstractJWKSTokenService<E> {
|
|
6
7
|
protected options: IJWKSVerifierOptions;
|
|
7
8
|
protected jwksVerifier: ReturnType<typeof createRemoteJWKSet> | null;
|
|
@@ -16,6 +16,7 @@ import { getError } from '@venizia/ignis-helpers/core';
|
|
|
16
16
|
import { AuthenticateBindingKeys, inject, } from '@venizia/ignis-kernel';
|
|
17
17
|
import { JoseLoader } from '../../jose-loader.js';
|
|
18
18
|
import { AbstractJWKSTokenService } from './abstract.service.js';
|
|
19
|
+
/** Verifies tokens against a remote JWKS fetched from `jwksUrl`. The key set is cached for `cacheTtlMs` (default 43_200_000 ms) with a `cooldownMs` refetch cooldown (default 30_000 ms). */
|
|
19
20
|
let JWKSVerifierTokenService = JWKSVerifierTokenService_1 = class JWKSVerifierTokenService extends AbstractJWKSTokenService {
|
|
20
21
|
constructor(options) {
|
|
21
22
|
super({ scope: JWKSVerifierTokenService_1.name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifier.service.js","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/verifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,uBAAuB,EAGvB,MAAM,GAEP,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,IAAa,wBAAwB,gCAArC,MAAa,wBAA8C,SAAQ,wBAA2B;IAG5F,YAEE,OAAuC;QAEvC,KAAK,CAA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cAAc,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAEQ,KAAK,CAAC,SAAS,CAAC,KAGxB;QACC,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,OAAO,EAAE,6DAA6D;SACvE,CAAC,CAAC;IACL,CAAC;IAEkB,aAAa;QAC9B,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,OAAO,EAAE,6DAA6D;SACvE,CAAC,CAAC;IACL,CAAC;IAEkB,wBAAwB;QACzC,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,OAAO,EAAE,8DAA8D;SACxE,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjEY,wBAAwB;IAIhC,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAA;;GAJ7C,wBAAwB,CAiEpC","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthenticateBindingKeys,\n type IJWKSVerifierOptions,\n type IJWTTokenPayload,\n inject,\n type TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { type Env } from 'hono';\nimport type { createRemoteJWKSet, SignJWT } from 'jose';\nimport { JoseLoader } from '../../jose-loader';\nimport { AbstractJWKSTokenService } from './abstract.service';\n\nexport class JWKSVerifierTokenService<E extends Env = Env> extends AbstractJWKSTokenService<E> {\n protected jwksVerifier: ReturnType<typeof createRemoteJWKSet> | null = null;\n\n constructor(\n @inject({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n protected options: IJWKSVerifierOptions,\n ) {\n super({ scope: JWKSVerifierTokenService.name });\n this.configurePayloadEncryption({\n aesAlgorithm: this.options.aesAlgorithm,\n applicationSecret: this.options.applicationSecret,\n fieldCodecs: this.options.fieldCodecs,\n });\n }\n\n protected override async initialize(): Promise<void> {\n const { createRemoteJWKSet } = await JoseLoader.load();\n const jwksUrl = new URL(this.options.jwksUrl);\n this.jwksVerifier = createRemoteJWKSet(jwksUrl, {\n cacheMaxAge: this.options.cacheTtlMs ?? 43_200_000,\n cooldownDuration: this.options.cooldownMs ?? 30_000,\n });\n\n this.initialized = true;\n\n this.logger\n .for(this.initialize.name)\n .info('JWKS verifier initialized | url: %s', this.options.jwksUrl);\n }\n\n protected override async doVerify(token: string): Promise<IJWTTokenPayload> {\n await this.ensureInitialized();\n const { jwtVerify } = await JoseLoader.load();\n const result = await jwtVerify<IJWTTokenPayload>(\n token,\n this.jwksVerifier!,\n this.options.verify,\n );\n\n return this.decryptPayload({ result });\n }\n\n override async getSigner(_opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n }): Promise<SignJWT> {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSVerifierTokenService] Verifier mode cannot sign tokens',\n });\n }\n\n protected override getSigningKey(): never {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSVerifierTokenService] Verifier mode cannot sign tokens',\n });\n }\n\n protected override getDefaultTokenExpiresFn(): never {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSVerifierTokenService] Verifier mode has no token expiry',\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"verifier.service.js","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authenticate/services/bearer/jwks/verifier.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EACL,uBAAuB,EAGvB,MAAM,GAEP,MAAM,uBAAuB,CAAC;AAG/B,OA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M,EAAE,SAAS,EAAE,GAAG,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,MAAM,SAAS,CAC5B,KAAK,EACL,IAAI,CAAC,YAAa,EAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CACpB,CAAC;QAEF,OAAO,IAAI,CAAC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;IAEQ,KAAK,CAAC,SAAS,CAAC,KAGxB;QACC,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,OAAO,EAAE,6DAA6D;SACvE,CAAC,CAAC;IACL,CAAC;IAEkB,aAAa;QAC9B,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,OAAO,EAAE,6DAA6D;SACvE,CAAC,CAAC;IACL,CAAC;IAEkB,wBAAwB;QACzC,MAAM,QAAQ,CAAC;YACb,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB;YACrD,OAAO,EAAE,8DAA8D;SACxE,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAjEY,wBAAwB;IAIhC,WAAA,MAAM,CAAC,EAAE,GAAG,EAAE,uBAAuB,CAAC,YAAY,EAAE,CAAC,CAAA;;GAJ7C,wBAAwB,CAiEpC","sourcesContent":["import { HTTP } from '@venizia/ignis-helpers/common';\nimport { getError } from '@venizia/ignis-helpers/core';\nimport {\n AuthenticateBindingKeys,\n type IJWKSVerifierOptions,\n type IJWTTokenPayload,\n inject,\n type TGetTokenExpiresFn,\n} from '@venizia/ignis-kernel';\nimport { type Env } from 'hono';\nimport type { createRemoteJWKSet, SignJWT } from 'jose';\nimport { JoseLoader } from '../../jose-loader';\nimport { AbstractJWKSTokenService } from './abstract.service';\n\n/** Verifies tokens against a remote JWKS fetched from `jwksUrl`. The key set is cached for `cacheTtlMs` (default 43_200_000 ms) with a `cooldownMs` refetch cooldown (default 30_000 ms). */\nexport class JWKSVerifierTokenService<E extends Env = Env> extends AbstractJWKSTokenService<E> {\n protected jwksVerifier: ReturnType<typeof createRemoteJWKSet> | null = null;\n\n constructor(\n @inject({ key: AuthenticateBindingKeys.JWKS_OPTIONS })\n protected options: IJWKSVerifierOptions,\n ) {\n super({ scope: JWKSVerifierTokenService.name });\n this.configurePayloadEncryption({\n aesAlgorithm: this.options.aesAlgorithm,\n applicationSecret: this.options.applicationSecret,\n fieldCodecs: this.options.fieldCodecs,\n });\n }\n\n protected override async initialize(): Promise<void> {\n const { createRemoteJWKSet } = await JoseLoader.load();\n const jwksUrl = new URL(this.options.jwksUrl);\n this.jwksVerifier = createRemoteJWKSet(jwksUrl, {\n cacheMaxAge: this.options.cacheTtlMs ?? 43_200_000,\n cooldownDuration: this.options.cooldownMs ?? 30_000,\n });\n\n this.initialized = true;\n\n this.logger\n .for(this.initialize.name)\n .info('JWKS verifier initialized | url: %s', this.options.jwksUrl);\n }\n\n protected override async doVerify(token: string): Promise<IJWTTokenPayload> {\n await this.ensureInitialized();\n const { jwtVerify } = await JoseLoader.load();\n const result = await jwtVerify<IJWTTokenPayload>(\n token,\n this.jwksVerifier!,\n this.options.verify,\n );\n\n return this.decryptPayload({ result });\n }\n\n override async getSigner(_opts: {\n payload: IJWTTokenPayload;\n getTokenExpiresFn: TGetTokenExpiresFn;\n }): Promise<SignJWT> {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSVerifierTokenService] Verifier mode cannot sign tokens',\n });\n }\n\n protected override getSigningKey(): never {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSVerifierTokenService] Verifier mode cannot sign tokens',\n });\n }\n\n protected override getDefaultTokenExpiresFn(): never {\n throw getError({\n statusCode: HTTP.ResultCodes.RS_5.InternalServerError,\n message: '[JWKSVerifierTokenService] Verifier mode has no token expiry',\n });\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
|
3
3
|
import { type Env } from 'hono';
|
|
4
4
|
import { type IAuthUser, type IAuthenticationStrategy } from '@venizia/ignis-kernel';
|
|
5
5
|
import { JWKSIssuerTokenService } from '../../services/index.js';
|
|
6
|
+
/** JWT authentication strategy that verifies the bearer token with `JWKSIssuerTokenService`, for an application that issues its own tokens. */
|
|
6
7
|
export declare class JWKSIssuerAuthenticationStrategy<E extends Env = Env> extends BaseHelper implements IAuthenticationStrategy<E> {
|
|
7
8
|
private service;
|
|
8
9
|
name: string;
|
|
@@ -17,6 +17,7 @@ import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
|
17
17
|
import { BindingKeys } from '@venizia/ignis-inversion';
|
|
18
18
|
import { Authentication, JOSEStandards, } from '@venizia/ignis-kernel';
|
|
19
19
|
import { JWKSIssuerTokenService } from '../../services/index.js';
|
|
20
|
+
/** JWT authentication strategy that verifies the bearer token with `JWKSIssuerTokenService`, for an application that issues its own tokens. */
|
|
20
21
|
let JWKSIssuerAuthenticationStrategy = JWKSIssuerAuthenticationStrategy_1 = class JWKSIssuerAuthenticationStrategy extends BaseHelper {
|
|
21
22
|
constructor(service) {
|
|
22
23
|
super({ scope: JWKSIssuerAuthenticationStrategy_1.name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issuer.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/strategies/jwks/issuer.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,cAAc,EAGd,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,IAAa,gCAAgC,wCAA7C,MAAa,gCACX,SAAQ,UAAU;IAMlB,YAOE,OAA0C;QAE1C,KAAK,CAAC,EAAE,KAAK,EAAE,kCAAgC,CAAC,IAAI,EAAE,CAAC,CAAC;QAFhD,YAAO,GAAP,OAAO,CAA2B;QAV5C,SAAI,GAAG,cAAc,CAAC,YAAY,CAAC;QACnC,aAAQ,GAAG,aAAa,CAAC,IAAI,CAAC;IAY9B,CAAC;IAED,YAAY,CAAC,OAA4B;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAEvD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AAxBY,gCAAgC;IAQxC,WAAA,MAAM,CAAC;QACN,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC;YACrB,SAAS,EAAE,iBAAiB,CAAC,OAAO;YACpC,GAAG,EAAE,sBAAsB,CAAC,IAAI;SACjC,CAAC;KACH,CAAC,CAAA;qCACe,sBAAsB;GAd9B,gCAAgC,CAwB5C","sourcesContent":["import { type TContext } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\nimport { BindingKeys } from '@venizia/ignis-inversion';\nimport { type Env } from 'hono';\nimport {\n Authentication,\n type IAuthUser,\n type IAuthenticationStrategy,\n JOSEStandards,\n} from '@venizia/ignis-kernel';\nimport { JWKSIssuerTokenService } from '../../services';\n\nexport class JWKSIssuerAuthenticationStrategy<E extends Env = Env>\n extends BaseHelper\n implements IAuthenticationStrategy<E>\n{\n name = Authentication.STRATEGY_JWT;\n standard = JOSEStandards.JWKS;\n\n constructor(\n @inject({\n key: BindingKeys.build({\n namespace: BindingNamespaces.SERVICE,\n key: JWKSIssuerTokenService.name,\n }),\n })\n private service: JWKSIssuerTokenService<E>,\n ) {\n super({ scope: JWKSIssuerAuthenticationStrategy.name });\n }\n\n authenticate(context: TContext<E, string>): Promise<IAuthUser> {\n const token = this.service.extractCredentials(context);\n\n return this.service.verify(token);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"issuer.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/strategies/jwks/issuer.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,cAAc,EAGd,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAExD,+IAA+I;AAC/I,IAAa,gCAAgC,wCAA7C,MAAa,gCACX,SAAQ,UAAU;IAMlB,YAOE,OAA0C;QAE1C,KAAK,CAAC,EAAE,KAAK,EAAE,kCAAgC,CAAC,IAAI,EAAE,CAAC,CAAC;QAFhD,YAAO,GAAP,OAAO,CAA2B;QAV5C,SAAI,GAAG,cAAc,CAAC,YAAY,CAAC;QACnC,aAAQ,GAAG,aAAa,CAAC,IAAI,CAAC;IAY9B,CAAC;IAED,YAAY,CAAC,OAA4B;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAEvD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AAxBY,gCAAgC;IAQxC,WAAA,MAAM,CAAC;QACN,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC;YACrB,SAAS,EAAE,iBAAiB,CAAC,OAAO;YACpC,GAAG,EAAE,sBAAsB,CAAC,IAAI;SACjC,CAAC;KACH,CAAC,CAAA;qCACe,sBAAsB;GAd9B,gCAAgC,CAwB5C","sourcesContent":["import { type TContext } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\nimport { BindingKeys } from '@venizia/ignis-inversion';\nimport { type Env } from 'hono';\nimport {\n Authentication,\n type IAuthUser,\n type IAuthenticationStrategy,\n JOSEStandards,\n} from '@venizia/ignis-kernel';\nimport { JWKSIssuerTokenService } from '../../services';\n\n/** JWT authentication strategy that verifies the bearer token with `JWKSIssuerTokenService`, for an application that issues its own tokens. */\nexport class JWKSIssuerAuthenticationStrategy<E extends Env = Env>\n extends BaseHelper\n implements IAuthenticationStrategy<E>\n{\n name = Authentication.STRATEGY_JWT;\n standard = JOSEStandards.JWKS;\n\n constructor(\n @inject({\n key: BindingKeys.build({\n namespace: BindingNamespaces.SERVICE,\n key: JWKSIssuerTokenService.name,\n }),\n })\n private service: JWKSIssuerTokenService<E>,\n ) {\n super({ scope: JWKSIssuerAuthenticationStrategy.name });\n }\n\n authenticate(context: TContext<E, string>): Promise<IAuthUser> {\n const token = this.service.extractCredentials(context);\n\n return this.service.verify(token);\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
|
3
3
|
import { type Env } from 'hono';
|
|
4
4
|
import { type IAuthUser, type IAuthenticationStrategy } from '@venizia/ignis-kernel';
|
|
5
5
|
import { JWKSVerifierTokenService } from '../../services/index.js';
|
|
6
|
+
/** JWT authentication strategy that verifies the bearer token with `JWKSVerifierTokenService`, for an application that trusts a remote JWKS. */
|
|
6
7
|
export declare class JWKSVerifierAuthenticationStrategy<E extends Env = Env> extends BaseHelper implements IAuthenticationStrategy<E> {
|
|
7
8
|
private service;
|
|
8
9
|
name: string;
|
|
@@ -17,6 +17,7 @@ import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
|
17
17
|
import { BindingKeys } from '@venizia/ignis-inversion';
|
|
18
18
|
import { Authentication, JOSEStandards, } from '@venizia/ignis-kernel';
|
|
19
19
|
import { JWKSVerifierTokenService } from '../../services/index.js';
|
|
20
|
+
/** JWT authentication strategy that verifies the bearer token with `JWKSVerifierTokenService`, for an application that trusts a remote JWKS. */
|
|
20
21
|
let JWKSVerifierAuthenticationStrategy = JWKSVerifierAuthenticationStrategy_1 = class JWKSVerifierAuthenticationStrategy extends BaseHelper {
|
|
21
22
|
constructor(service) {
|
|
22
23
|
super({ scope: JWKSVerifierAuthenticationStrategy_1.name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verifier.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/strategies/jwks/verifier.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,cAAc,EAGd,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,IAAa,kCAAkC,0CAA/C,MAAa,kCACX,SAAQ,UAAU;IAMlB,YAOE,OAA4C;QAE5C,KAAK,CAAC,EAAE,KAAK,EAAE,oCAAkC,CAAC,IAAI,EAAE,CAAC,CAAC;QAFlD,YAAO,GAAP,OAAO,CAA6B;QAV9C,SAAI,GAAG,cAAc,CAAC,YAAY,CAAC;QACnC,aAAQ,GAAG,aAAa,CAAC,IAAI,CAAC;IAY9B,CAAC;IAED,YAAY,CAAC,OAA4B;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAEvD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AAxBY,kCAAkC;IAQ1C,WAAA,MAAM,CAAC;QACN,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC;YACrB,SAAS,EAAE,iBAAiB,CAAC,OAAO;YACpC,GAAG,EAAE,wBAAwB,CAAC,IAAI;SACnC,CAAC;KACH,CAAC,CAAA;qCACe,wBAAwB;GAdhC,kCAAkC,CAwB9C","sourcesContent":["import { type TContext } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\nimport { BindingKeys } from '@venizia/ignis-inversion';\nimport { type Env } from 'hono';\nimport {\n Authentication,\n type IAuthUser,\n type IAuthenticationStrategy,\n JOSEStandards,\n} from '@venizia/ignis-kernel';\nimport { JWKSVerifierTokenService } from '../../services';\n\nexport class JWKSVerifierAuthenticationStrategy<E extends Env = Env>\n extends BaseHelper\n implements IAuthenticationStrategy<E>\n{\n name = Authentication.STRATEGY_JWT;\n standard = JOSEStandards.JWKS;\n\n constructor(\n @inject({\n key: BindingKeys.build({\n namespace: BindingNamespaces.SERVICE,\n key: JWKSVerifierTokenService.name,\n }),\n })\n private service: JWKSVerifierTokenService<E>,\n ) {\n super({ scope: JWKSVerifierAuthenticationStrategy.name });\n }\n\n authenticate(context: TContext<E, string>): Promise<IAuthUser> {\n const token = this.service.extractCredentials(context);\n\n return this.service.verify(token);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"verifier.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authenticate/strategies/jwks/verifier.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,cAAc,EAGd,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,gJAAgJ;AAChJ,IAAa,kCAAkC,0CAA/C,MAAa,kCACX,SAAQ,UAAU;IAMlB,YAOE,OAA4C;QAE5C,KAAK,CAAC,EAAE,KAAK,EAAE,oCAAkC,CAAC,IAAI,EAAE,CAAC,CAAC;QAFlD,YAAO,GAAP,OAAO,CAA6B;QAV9C,SAAI,GAAG,cAAc,CAAC,YAAY,CAAC;QACnC,aAAQ,GAAG,aAAa,CAAC,IAAI,CAAC;IAY9B,CAAC;IAED,YAAY,CAAC,OAA4B;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAEvD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AAxBY,kCAAkC;IAQ1C,WAAA,MAAM,CAAC;QACN,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC;YACrB,SAAS,EAAE,iBAAiB,CAAC,OAAO;YACpC,GAAG,EAAE,wBAAwB,CAAC,IAAI;SACnC,CAAC;KACH,CAAC,CAAA;qCACe,wBAAwB;GAdhC,kCAAkC,CAwB9C","sourcesContent":["import { type TContext } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\nimport { BindingKeys } from '@venizia/ignis-inversion';\nimport { type Env } from 'hono';\nimport {\n Authentication,\n type IAuthUser,\n type IAuthenticationStrategy,\n JOSEStandards,\n} from '@venizia/ignis-kernel';\nimport { JWKSVerifierTokenService } from '../../services';\n\n/** JWT authentication strategy that verifies the bearer token with `JWKSVerifierTokenService`, for an application that trusts a remote JWKS. */\nexport class JWKSVerifierAuthenticationStrategy<E extends Env = Env>\n extends BaseHelper\n implements IAuthenticationStrategy<E>\n{\n name = Authentication.STRATEGY_JWT;\n standard = JOSEStandards.JWKS;\n\n constructor(\n @inject({\n key: BindingKeys.build({\n namespace: BindingNamespaces.SERVICE,\n key: JWKSVerifierTokenService.name,\n }),\n })\n private service: JWKSVerifierTokenService<E>,\n ) {\n super({ scope: JWKSVerifierAuthenticationStrategy.name });\n }\n\n authenticate(context: TContext<E, string>): Promise<IAuthUser> {\n const token = this.service.extractCredentials(context);\n\n return this.service.verify(token);\n }\n}\n"]}
|
|
@@ -3,6 +3,7 @@ import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
|
3
3
|
import { type Env } from 'hono';
|
|
4
4
|
import { type IAuthUser, type IAuthenticationStrategy } from '@venizia/ignis-kernel';
|
|
5
5
|
import { JWSTokenService } from '../services/index.js';
|
|
6
|
+
/** JWT authentication strategy that verifies the bearer token with `JWSTokenService` (JWS, HS256 by default). */
|
|
6
7
|
export declare class JWSAuthenticationStrategy<E extends Env = Env> extends BaseHelper implements IAuthenticationStrategy<E> {
|
|
7
8
|
private service;
|
|
8
9
|
name: string;
|
|
@@ -17,6 +17,7 @@ import { BaseHelper } from '@venizia/ignis-helpers/core';
|
|
|
17
17
|
import { BindingKeys } from '@venizia/ignis-inversion';
|
|
18
18
|
import { Authentication, JOSEStandards, } from '@venizia/ignis-kernel';
|
|
19
19
|
import { JWSTokenService } from '../services/index.js';
|
|
20
|
+
/** JWT authentication strategy that verifies the bearer token with `JWSTokenService` (JWS, HS256 by default). */
|
|
20
21
|
let JWSAuthenticationStrategy = JWSAuthenticationStrategy_1 = class JWSAuthenticationStrategy extends BaseHelper {
|
|
21
22
|
constructor(service) {
|
|
22
23
|
super({ scope: JWSAuthenticationStrategy_1.name });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jws.strategy.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authenticate/strategies/jws.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,cAAc,EAGd,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,IAAa,yBAAyB,iCAAtC,MAAa,yBACX,SAAQ,UAAU;IAMlB,YAOE,OAAmC;QAEnC,KAAK,CAAC,EAAE,KAAK,EAAE,2BAAyB,CAAC,IAAI,EAAE,CAAC,CAAC;QAFzC,YAAO,GAAP,OAAO,CAAoB;QAVrC,SAAI,GAAG,cAAc,CAAC,YAAY,CAAC;QACnC,aAAQ,GAAG,aAAa,CAAC,GAAG,CAAC;IAY7B,CAAC;IAED,YAAY,CAAC,OAA4B;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAEvD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AAxBY,yBAAyB;IAQjC,WAAA,MAAM,CAAC;QACN,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC;YACrB,SAAS,EAAE,iBAAiB,CAAC,OAAO;YACpC,GAAG,EAAE,eAAe,CAAC,IAAI;SAC1B,CAAC;KACH,CAAC,CAAA;qCACe,eAAe;GAdvB,yBAAyB,CAwBrC","sourcesContent":["import { type TContext } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\nimport { BindingKeys } from '@venizia/ignis-inversion';\nimport { type Env } from 'hono';\nimport {\n Authentication,\n type IAuthUser,\n type IAuthenticationStrategy,\n JOSEStandards,\n} from '@venizia/ignis-kernel';\nimport { JWSTokenService } from '../services';\n\nexport class JWSAuthenticationStrategy<E extends Env = Env>\n extends BaseHelper\n implements IAuthenticationStrategy<E>\n{\n name = Authentication.STRATEGY_JWT;\n standard = JOSEStandards.JWS;\n\n constructor(\n @inject({\n key: BindingKeys.build({\n namespace: BindingNamespaces.SERVICE,\n key: JWSTokenService.name,\n }),\n })\n private service: JWSTokenService<E>,\n ) {\n super({ scope: JWSAuthenticationStrategy.name });\n }\n\n authenticate(context: TContext<E, string>): Promise<IAuthUser> {\n const token = this.service.extractCredentials(context);\n\n return this.service.verify(token);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"jws.strategy.js","sourceRoot":"","sources":["../../../../../../src/components/auth/authenticate/strategies/jws.strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACL,cAAc,EAGd,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,iHAAiH;AACjH,IAAa,yBAAyB,iCAAtC,MAAa,yBACX,SAAQ,UAAU;IAMlB,YAOE,OAAmC;QAEnC,KAAK,CAAC,EAAE,KAAK,EAAE,2BAAyB,CAAC,IAAI,EAAE,CAAC,CAAC;QAFzC,YAAO,GAAP,OAAO,CAAoB;QAVrC,SAAI,GAAG,cAAc,CAAC,YAAY,CAAC;QACnC,aAAQ,GAAG,aAAa,CAAC,GAAG,CAAC;IAY7B,CAAC;IAED,YAAY,CAAC,OAA4B;QACvC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAEvD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CACF,CAAA;AAxBY,yBAAyB;IAQjC,WAAA,MAAM,CAAC;QACN,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC;YACrB,SAAS,EAAE,iBAAiB,CAAC,OAAO;YACpC,GAAG,EAAE,eAAe,CAAC,IAAI;SAC1B,CAAC;KACH,CAAC,CAAA;qCACe,eAAe;GAdvB,yBAAyB,CAwBrC","sourcesContent":["import { type TContext } from '@venizia/ignis-kernel';\nimport { inject } from '@venizia/ignis-kernel';\nimport { BindingNamespaces } from '@venizia/ignis-kernel';\nimport { BaseHelper } from '@venizia/ignis-helpers/core';\nimport { BindingKeys } from '@venizia/ignis-inversion';\nimport { type Env } from 'hono';\nimport {\n Authentication,\n type IAuthUser,\n type IAuthenticationStrategy,\n JOSEStandards,\n} from '@venizia/ignis-kernel';\nimport { JWSTokenService } from '../services';\n\n/** JWT authentication strategy that verifies the bearer token with `JWSTokenService` (JWS, HS256 by default). */\nexport class JWSAuthenticationStrategy<E extends Env = Env>\n extends BaseHelper\n implements IAuthenticationStrategy<E>\n{\n name = Authentication.STRATEGY_JWT;\n standard = JOSEStandards.JWS;\n\n constructor(\n @inject({\n key: BindingKeys.build({\n namespace: BindingNamespaces.SERVICE,\n key: JWSTokenService.name,\n }),\n })\n private service: JWSTokenService<E>,\n ) {\n super({ scope: JWSAuthenticationStrategy.name });\n }\n\n authenticate(context: TContext<E, string>): Promise<IAuthUser> {\n const token = this.service.extractCredentials(context);\n\n return this.service.verify(token);\n }\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { IdType } from '../../../../../../base/index.js';
|
|
2
2
|
import type { TNullable } from '@venizia/ignis-helpers/common';
|
|
3
|
+
/** A parent-child edge between two domain tokens, in the `<Type>_<id>` form, as returned by `TResolveDomainEdgesFn`. */
|
|
3
4
|
export type TDomainHierarchyEdge = {
|
|
4
5
|
child: string;
|
|
5
6
|
parent: string;
|
|
6
7
|
};
|
|
8
|
+
/** Filter passed to `ScopedCasbinAdapter.loadFilteredPolicy`: the one principal whose policy lines are loaded. */
|
|
7
9
|
export interface IScopedCasbinPolicyFilter {
|
|
8
10
|
principal: {
|
|
9
11
|
type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authorize/adapters/scoped-casbin/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IdType } from '@/base';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\n\nexport type TDomainHierarchyEdge = { child: string; parent: string };\n\nexport interface IScopedCasbinPolicyFilter {\n principal: { type: string; id: IdType };\n}\n\n/** A grant row as fetched, before it becomes casbin lines. Permission columns are null when the join misses. */\nexport type TGrantRow = {\n subjectId: IdType;\n objectCode: TNullable<string>;\n objectSubject: TNullable<string>;\n objectMethod: TNullable<string>;\n action: TNullable<string>;\n effect: TNullable<string>;\n domain: TNullable<string>;\n metadata?: unknown;\n};\n\n/**\n * Per-principal domain edges sourced from business data the app already owns (e.g. a tenant\n * foreign key) - read live on every cache miss, never duplicated into `domain_inherits`. An app\n * whose hierarchy genuinely lives in `domain_inherits` rows does not need this hook at all: the\n * DOMAIN_EDGE branch above already emits those as `g3` lines. `domains` is the principal's own\n * domain closure, already `<Type>_<id>` tokens; the returned edges must be too - neither side\n * re-formats them.\n *\n * `domains` is the principal's **membership closure** - built from `join_domain` rows plus both\n * ends of every `domainEdge` row. It is NOT the set of domains the principal holds a role in via\n * `assign_role`: a principal can carry `assign_role` at a domain it never joined. A hook ported\n * from a mechanism that derived its domains from `assign_role` will silently lose access for\n * exactly those principals - no error, no log, just fewer edges reaching `g`/`g2`/`g3` than before.\n *\n * More than one hierarchy axis (e.g. an organizer tree and a separate region tree)? Write one\n * function per axis and concatenate their results here - this hook deliberately takes a single\n * function, so composition stays visible in the application, not hidden inside the framework:\n * `resolveDomainEdges: async opts => [...(await organizerEdges(opts)), ...(await regionEdges(opts))]`.\n */\nexport type TResolveDomainEdgesFn = (opts: {\n principal: { type: string; id: IdType };\n domains: string[];\n}) => Promise<TDomainHierarchyEdge[]>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../src/components/auth/authorize/adapters/scoped-casbin/common/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { IdType } from '@/base';\nimport type { TNullable } from '@venizia/ignis-helpers/common';\n\n/** A parent-child edge between two domain tokens, in the `<Type>_<id>` form, as returned by `TResolveDomainEdgesFn`. */\nexport type TDomainHierarchyEdge = { child: string; parent: string };\n\n/** Filter passed to `ScopedCasbinAdapter.loadFilteredPolicy`: the one principal whose policy lines are loaded. */\nexport interface IScopedCasbinPolicyFilter {\n principal: { type: string; id: IdType };\n}\n\n/** A grant row as fetched, before it becomes casbin lines. Permission columns are null when the join misses. */\nexport type TGrantRow = {\n subjectId: IdType;\n objectCode: TNullable<string>;\n objectSubject: TNullable<string>;\n objectMethod: TNullable<string>;\n action: TNullable<string>;\n effect: TNullable<string>;\n domain: TNullable<string>;\n metadata?: unknown;\n};\n\n/**\n * Per-principal domain edges sourced from business data the app already owns (e.g. a tenant\n * foreign key) - read live on every cache miss, never duplicated into `domain_inherits`. An app\n * whose hierarchy genuinely lives in `domain_inherits` rows does not need this hook at all: the\n * DOMAIN_EDGE branch above already emits those as `g3` lines. `domains` is the principal's own\n * domain closure, already `<Type>_<id>` tokens; the returned edges must be too - neither side\n * re-formats them.\n *\n * `domains` is the principal's **membership closure** - built from `join_domain` rows plus both\n * ends of every `domainEdge` row. It is NOT the set of domains the principal holds a role in via\n * `assign_role`: a principal can carry `assign_role` at a domain it never joined. A hook ported\n * from a mechanism that derived its domains from `assign_role` will silently lose access for\n * exactly those principals - no error, no log, just fewer edges reaching `g`/`g2`/`g3` than before.\n *\n * More than one hierarchy axis (e.g. an organizer tree and a separate region tree)? Write one\n * function per axis and concatenate their results here - this hook deliberately takes a single\n * function, so composition stays visible in the application, not hidden inside the framework:\n * `resolveDomainEdges: async opts => [...(await organizerEdges(opts)), ...(await regionEdges(opts))]`.\n */\nexport type TResolveDomainEdgesFn = (opts: {\n principal: { type: string; id: IdType };\n domains: string[];\n}) => Promise<TDomainHierarchyEdge[]>;\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IdType } from '../../../../../base/index.js';
|
|
2
2
|
import type { TConstValue, TNullable } from '@venizia/ignis-helpers/common';
|
|
3
3
|
import type { TGrantRow } from './common/index.js';
|
|
4
|
+
/** The `kind` values of a `TPrincipalPolicyRow`: which branch of the principal-policy statement produced the row. */
|
|
4
5
|
export declare class PrincipalPolicyEdges {
|
|
5
6
|
static readonly DIRECT = "direct";
|
|
6
7
|
static readonly ROLE_EDGE = "roleEdge";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"policy-edges.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authorize/adapters/scoped-casbin/policy-edges.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,oBAAoB;aACf,WAAM,GAAG,QAAQ,CAAC;aAClB,cAAS,GAAG,UAAU,CAAC;aACvB,eAAU,GAAG,WAAW,CAAC;aACzB,gBAAW,GAAG,YAAY,CAAC","sourcesContent":["import type { IdType } from '@/base';\nimport type { TConstValue, TNullable } from '@venizia/ignis-helpers/common';\nimport type { TGrantRow } from './common';\n\nexport class PrincipalPolicyEdges {\n static readonly DIRECT = 'direct';\n static readonly ROLE_EDGE = 'roleEdge';\n static readonly ROLE_GRANT = 'roleGrant';\n static readonly DOMAIN_EDGE = 'domainEdge';\n}\n\n/** A row from the single principal-policy statement; `kind` says which branch produced it. */\nexport type TPrincipalPolicyRow = TGrantRow & {\n kind: TConstValue<typeof PrincipalPolicyEdges>;\n variant: string;\n targetType: TNullable<string>;\n targetId: IdType;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"policy-edges.js","sourceRoot":"","sources":["../../../../../../../src/components/auth/authorize/adapters/scoped-casbin/policy-edges.ts"],"names":[],"mappings":"AAIA,qHAAqH;AACrH,MAAM,OAAO,oBAAoB;aACf,WAAM,GAAG,QAAQ,CAAC;aAClB,cAAS,GAAG,UAAU,CAAC;aACvB,eAAU,GAAG,WAAW,CAAC;aACzB,gBAAW,GAAG,YAAY,CAAC","sourcesContent":["import type { IdType } from '@/base';\nimport type { TConstValue, TNullable } from '@venizia/ignis-helpers/common';\nimport type { TGrantRow } from './common';\n\n/** The `kind` values of a `TPrincipalPolicyRow`: which branch of the principal-policy statement produced the row. */\nexport class PrincipalPolicyEdges {\n static readonly DIRECT = 'direct';\n static readonly ROLE_EDGE = 'roleEdge';\n static readonly ROLE_GRANT = 'roleGrant';\n static readonly DOMAIN_EDGE = 'domainEdge';\n}\n\n/** A row from the single principal-policy statement; `kind` says which branch produced it. */\nexport type TPrincipalPolicyRow = TGrantRow & {\n kind: TConstValue<typeof PrincipalPolicyEdges>;\n variant: string;\n targetType: TNullable<string>;\n targetId: IdType;\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BaseApplication } from '../../../base/applications/base.js';
|
|
2
2
|
import { BaseComponent } from '@venizia/ignis-kernel';
|
|
3
3
|
import { type ValueOrPromise } from '@venizia/ignis-helpers/common';
|
|
4
|
+
/** Registers authorization from the options bound under `AuthorizeBindingKeys.OPTIONS`. Throws at binding time when no options are bound. */
|
|
4
5
|
export declare class AuthorizeComponent extends BaseComponent {
|
|
5
6
|
private application;
|
|
6
7
|
constructor(application: BaseApplication);
|
|
@@ -16,6 +16,7 @@ import { inject } from '@venizia/ignis-kernel';
|
|
|
16
16
|
import { CoreBindings } from '@venizia/ignis-kernel';
|
|
17
17
|
import { getError } from '@venizia/ignis-helpers/core';
|
|
18
18
|
import { AuthorizationEnforcerRegistry, AuthorizeBindingKeys, } from '@venizia/ignis-kernel';
|
|
19
|
+
/** Registers authorization from the options bound under `AuthorizeBindingKeys.OPTIONS`. Throws at binding time when no options are bound. */
|
|
19
20
|
let AuthorizeComponent = AuthorizeComponent_1 = class AuthorizeComponent extends BaseComponent {
|
|
20
21
|
constructor(application) {
|
|
21
22
|
super({
|