@ddd-ts-kit/auth 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +834 -2
- package/dist/abac/attribute-policy.d.ts +13 -0
- package/dist/abac/attribute-policy.d.ts.map +1 -0
- package/dist/abac/attribute-policy.js +10 -0
- package/dist/abac/attribute-policy.js.map +1 -0
- package/dist/abac/condition.d.ts +6 -0
- package/dist/abac/condition.d.ts.map +1 -0
- package/dist/abac/condition.js +10 -0
- package/dist/abac/condition.js.map +1 -0
- package/dist/abac/policy-based-authorizer.d.ts +23 -0
- package/dist/abac/policy-based-authorizer.d.ts.map +1 -0
- package/dist/abac/policy-based-authorizer.js +39 -0
- package/dist/abac/policy-based-authorizer.js.map +1 -0
- package/dist/abac/policy-input.d.ts +17 -0
- package/dist/abac/policy-input.d.ts.map +1 -0
- package/dist/abac/policy-input.js +2 -0
- package/dist/abac/policy-input.js.map +1 -0
- package/dist/abac/resource-attribute-values.d.ts +3 -0
- package/dist/abac/resource-attribute-values.d.ts.map +1 -0
- package/dist/abac/resource-attribute-values.js +2 -0
- package/dist/abac/resource-attribute-values.js.map +1 -0
- package/dist/abac/resource-attributes.d.ts +8 -0
- package/dist/abac/resource-attributes.d.ts.map +1 -0
- package/dist/abac/resource-attributes.js +5 -0
- package/dist/abac/resource-attributes.js.map +1 -0
- package/dist/authentication/actor-of.d.ts +7 -0
- package/dist/authentication/actor-of.d.ts.map +1 -0
- package/dist/authentication/actor-of.js +9 -0
- package/dist/authentication/actor-of.js.map +1 -0
- package/dist/authentication/authenticator.d.ts +11 -0
- package/dist/authentication/authenticator.d.ts.map +1 -0
- package/dist/authentication/authenticator.js +9 -0
- package/dist/authentication/authenticator.js.map +1 -0
- package/dist/authentication/bearer-credential.d.ts +7 -0
- package/dist/authentication/bearer-credential.d.ts.map +1 -0
- package/dist/authentication/bearer-credential.js +19 -0
- package/dist/authentication/bearer-credential.js.map +1 -0
- package/dist/authentication/header-values.d.ts +2 -0
- package/dist/authentication/header-values.d.ts.map +1 -0
- package/dist/authentication/header-values.js +2 -0
- package/dist/authentication/header-values.js.map +1 -0
- package/dist/authentication/in-actor-context.d.ts +15 -0
- package/dist/authentication/in-actor-context.d.ts.map +1 -0
- package/dist/authentication/in-actor-context.js +11 -0
- package/dist/authentication/in-actor-context.js.map +1 -0
- package/dist/authentication/principal-resolver.d.ts +10 -0
- package/dist/authentication/principal-resolver.d.ts.map +1 -0
- package/dist/authentication/principal-resolver.js +25 -0
- package/dist/authentication/principal-resolver.js.map +1 -0
- package/dist/authentication/resolve-session.d.ts +9 -0
- package/dist/authentication/resolve-session.d.ts.map +1 -0
- package/dist/authentication/resolve-session.js +12 -0
- package/dist/authentication/resolve-session.js.map +1 -0
- package/dist/authentication/session-authenticator.d.ts +13 -0
- package/dist/authentication/session-authenticator.d.ts.map +1 -0
- package/dist/authentication/session-authenticator.js +11 -0
- package/dist/authentication/session-authenticator.js.map +1 -0
- package/dist/authentication/session-of.d.ts +9 -0
- package/dist/authentication/session-of.d.ts.map +1 -0
- package/dist/authentication/session-of.js +27 -0
- package/dist/authentication/session-of.js.map +1 -0
- package/dist/authorization/access-scope.d.ts +16 -0
- package/dist/authorization/access-scope.d.ts.map +1 -0
- package/dist/authorization/access-scope.js +2 -0
- package/dist/authorization/access-scope.js.map +1 -0
- package/dist/authorization/access.d.ts +17 -0
- package/dist/authorization/access.d.ts.map +1 -0
- package/dist/authorization/access.js +8 -0
- package/dist/authorization/access.js.map +1 -0
- package/dist/authorization/authorization-context.d.ts +3 -0
- package/dist/authorization/authorization-context.d.ts.map +1 -0
- package/dist/authorization/authorization-context.js +2 -0
- package/dist/authorization/authorization-context.js.map +1 -0
- package/dist/authorization/authorizer.d.ts +15 -0
- package/dist/authorization/authorizer.d.ts.map +1 -0
- package/dist/authorization/authorizer.js +8 -0
- package/dist/authorization/authorizer.js.map +1 -0
- package/dist/authorization/check-request.d.ts +11 -0
- package/dist/authorization/check-request.d.ts.map +1 -0
- package/dist/authorization/check-request.js +2 -0
- package/dist/authorization/check-request.js.map +1 -0
- package/dist/authorization/decision-record-of.d.ts +7 -0
- package/dist/authorization/decision-record-of.d.ts.map +1 -0
- package/dist/authorization/decision-record-of.js +11 -0
- package/dist/authorization/decision-record-of.js.map +1 -0
- package/dist/authorization/decision-record.d.ts +15 -0
- package/dist/authorization/decision-record.d.ts.map +1 -0
- package/dist/authorization/decision-record.js +2 -0
- package/dist/authorization/decision-record.js.map +1 -0
- package/dist/authorization/decision.d.ts +10 -0
- package/dist/authorization/decision.d.ts.map +1 -0
- package/dist/authorization/decision.js +5 -0
- package/dist/authorization/decision.js.map +1 -0
- package/dist/authorization/denial-reason.d.ts +14 -0
- package/dist/authorization/denial-reason.d.ts.map +1 -0
- package/dist/authorization/denial-reason.js +14 -0
- package/dist/authorization/denial-reason.js.map +1 -0
- package/dist/authorization/is-resource-ref.d.ts +4 -0
- package/dist/authorization/is-resource-ref.d.ts.map +1 -0
- package/dist/authorization/is-resource-ref.js +11 -0
- package/dist/authorization/is-resource-ref.js.map +1 -0
- package/dist/authorization/list-request.d.ts +8 -0
- package/dist/authorization/list-request.d.ts.map +1 -0
- package/dist/authorization/list-request.js +2 -0
- package/dist/authorization/list-request.js.map +1 -0
- package/dist/authorization/on-decision.d.ts +3 -0
- package/dist/authorization/on-decision.d.ts.map +1 -0
- package/dist/authorization/on-decision.js +2 -0
- package/dist/authorization/on-decision.js.map +1 -0
- package/dist/authorization/resource-ref.d.ts +6 -0
- package/dist/authorization/resource-ref.d.ts.map +1 -0
- package/dist/authorization/resource-ref.js +2 -0
- package/dist/authorization/resource-ref.js.map +1 -0
- package/dist/di/authorization-map-of.d.ts +5 -0
- package/dist/di/authorization-map-of.d.ts.map +1 -0
- package/dist/di/authorization-map-of.js +30 -0
- package/dist/di/authorization-map-of.js.map +1 -0
- package/dist/di/authorization-module.d.ts +24 -0
- package/dist/di/authorization-module.d.ts.map +1 -0
- package/dist/di/authorization-module.js +75 -0
- package/dist/di/authorization-module.js.map +1 -0
- package/dist/di.d.ts +7 -0
- package/dist/di.d.ts.map +1 -0
- package/dist/di.js +7 -0
- package/dist/di.js.map +1 -0
- package/dist/errors/authorization-setup-error.d.ts +5 -0
- package/dist/errors/authorization-setup-error.d.ts.map +1 -0
- package/dist/errors/authorization-setup-error.js +8 -0
- package/dist/errors/authorization-setup-error.js.map +1 -0
- package/dist/errors/forbidden-error.d.ts +14 -0
- package/dist/errors/forbidden-error.d.ts.map +1 -0
- package/dist/errors/forbidden-error.js +18 -0
- package/dist/errors/forbidden-error.js.map +1 -0
- package/dist/errors/invalid-credential-error.d.ts +8 -0
- package/dist/errors/invalid-credential-error.d.ts.map +1 -0
- package/dist/errors/invalid-credential-error.js +12 -0
- package/dist/errors/invalid-credential-error.js.map +1 -0
- package/dist/errors/listing-not-supported-error.d.ts +5 -0
- package/dist/errors/listing-not-supported-error.d.ts.map +1 -0
- package/dist/errors/listing-not-supported-error.js +8 -0
- package/dist/errors/listing-not-supported-error.js.map +1 -0
- package/dist/errors/missing-actor-error.d.ts +6 -0
- package/dist/errors/missing-actor-error.d.ts.map +1 -0
- package/dist/errors/missing-actor-error.js +8 -0
- package/dist/errors/missing-actor-error.js.map +1 -0
- package/dist/errors/unauthenticated-error.d.ts +12 -0
- package/dist/errors/unauthenticated-error.d.ts.map +1 -0
- package/dist/errors/unauthenticated-error.js +14 -0
- package/dist/errors/unauthenticated-error.js.map +1 -0
- package/dist/errors/undeclared-use-case-error.d.ts +9 -0
- package/dist/errors/undeclared-use-case-error.d.ts.map +1 -0
- package/dist/errors/undeclared-use-case-error.js +11 -0
- package/dist/errors/undeclared-use-case-error.js.map +1 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/jwt/claims.d.ts +3 -0
- package/dist/jwt/claims.d.ts.map +1 -0
- package/dist/jwt/claims.js +2 -0
- package/dist/jwt/claims.js.map +1 -0
- package/dist/jwt/is-service-account.d.ts +3 -0
- package/dist/jwt/is-service-account.d.ts.map +1 -0
- package/dist/jwt/is-service-account.js +7 -0
- package/dist/jwt/is-service-account.js.map +1 -0
- package/dist/jwt/jwt-authenticator.d.ts +45 -0
- package/dist/jwt/jwt-authenticator.d.ts.map +1 -0
- package/dist/jwt/jwt-authenticator.js +109 -0
- package/dist/jwt/jwt-authenticator.js.map +1 -0
- package/dist/jwt/keycloak-actor-of.d.ts +6 -0
- package/dist/jwt/keycloak-actor-of.d.ts.map +1 -0
- package/dist/jwt/keycloak-actor-of.js +56 -0
- package/dist/jwt/keycloak-actor-of.js.map +1 -0
- package/dist/jwt/keycloak-authentication-method.d.ts +5 -0
- package/dist/jwt/keycloak-authentication-method.d.ts.map +1 -0
- package/dist/jwt/keycloak-authentication-method.js +6 -0
- package/dist/jwt/keycloak-authentication-method.js.map +1 -0
- package/dist/jwt/keycloak-authenticator.d.ts +23 -0
- package/dist/jwt/keycloak-authenticator.d.ts.map +1 -0
- package/dist/jwt/keycloak-authenticator.js +25 -0
- package/dist/jwt/keycloak-authenticator.js.map +1 -0
- package/dist/jwt/keycloak-claim-options.d.ts +9 -0
- package/dist/jwt/keycloak-claim-options.d.ts.map +1 -0
- package/dist/jwt/keycloak-claim-options.js +2 -0
- package/dist/jwt/keycloak-claim-options.js.map +1 -0
- package/dist/jwt/session-of-claims.d.ts +13 -0
- package/dist/jwt/session-of-claims.d.ts.map +1 -0
- package/dist/jwt/session-of-claims.js +71 -0
- package/dist/jwt/session-of-claims.js.map +1 -0
- package/dist/jwt/without-trailing-slashes.d.ts +3 -0
- package/dist/jwt/without-trailing-slashes.d.ts.map +1 -0
- package/dist/jwt/without-trailing-slashes.js +9 -0
- package/dist/jwt/without-trailing-slashes.js.map +1 -0
- package/dist/jwt.d.ts +3 -0
- package/dist/jwt.d.ts.map +1 -0
- package/dist/jwt.js +3 -0
- package/dist/jwt.js.map +1 -0
- package/dist/permissions/define-permissions.d.ts +13 -0
- package/dist/permissions/define-permissions.d.ts.map +1 -0
- package/dist/permissions/define-permissions.js +23 -0
- package/dist/permissions/define-permissions.js.map +1 -0
- package/dist/permissions/grant-covers.d.ts +3 -0
- package/dist/permissions/grant-covers.d.ts.map +1 -0
- package/dist/permissions/grant-covers.js +5 -0
- package/dist/permissions/grant-covers.js.map +1 -0
- package/dist/permissions/grant-pattern.d.ts +5 -0
- package/dist/permissions/grant-pattern.d.ts.map +1 -0
- package/dist/permissions/grant-pattern.js +12 -0
- package/dist/permissions/grant-pattern.js.map +1 -0
- package/dist/permissions/grant.d.ts +4 -0
- package/dist/permissions/grant.d.ts.map +1 -0
- package/dist/permissions/grant.js +2 -0
- package/dist/permissions/grant.js.map +1 -0
- package/dist/permissions/is-permission.d.ts +3 -0
- package/dist/permissions/is-permission.d.ts.map +1 -0
- package/dist/permissions/is-permission.js +10 -0
- package/dist/permissions/is-permission.js.map +1 -0
- package/dist/permissions/permission-registry.d.ts +12 -0
- package/dist/permissions/permission-registry.d.ts.map +1 -0
- package/dist/permissions/permission-registry.js +31 -0
- package/dist/permissions/permission-registry.js.map +1 -0
- package/dist/permissions/permission.d.ts +9 -0
- package/dist/permissions/permission.d.ts.map +1 -0
- package/dist/permissions/permission.js +2 -0
- package/dist/permissions/permission.js.map +1 -0
- package/dist/policies/define-policy.d.ts +4 -0
- package/dist/policies/define-policy.d.ts.map +1 -0
- package/dist/policies/define-policy.js +10 -0
- package/dist/policies/define-policy.js.map +1 -0
- package/dist/policies/policy-access.d.ts +32 -0
- package/dist/policies/policy-access.d.ts.map +1 -0
- package/dist/policies/policy-access.js +78 -0
- package/dist/policies/policy-access.js.map +1 -0
- package/dist/policies/policy-context.d.ts +5 -0
- package/dist/policies/policy-context.d.ts.map +1 -0
- package/dist/policies/policy-context.js +2 -0
- package/dist/policies/policy-context.js.map +1 -0
- package/dist/policies/policy.d.ts +18 -0
- package/dist/policies/policy.d.ts.map +1 -0
- package/dist/policies/policy.js +2 -0
- package/dist/policies/policy.js.map +1 -0
- package/dist/rbac/role-based-authorizer.d.ts +35 -0
- package/dist/rbac/role-based-authorizer.d.ts.map +1 -0
- package/dist/rbac/role-based-authorizer.js +68 -0
- package/dist/rbac/role-based-authorizer.js.map +1 -0
- package/dist/rbac/tenant-of-context.d.ts +4 -0
- package/dist/rbac/tenant-of-context.d.ts.map +1 -0
- package/dist/rbac/tenant-of-context.js +6 -0
- package/dist/rbac/tenant-of-context.js.map +1 -0
- package/dist/rebac/define-schema.d.ts +8 -0
- package/dist/rebac/define-schema.d.ts.map +1 -0
- package/dist/rebac/define-schema.js +99 -0
- package/dist/rebac/define-schema.js.map +1 -0
- package/dist/rebac/evaluation.d.ts +31 -0
- package/dist/rebac/evaluation.d.ts.map +1 -0
- package/dist/rebac/evaluation.js +94 -0
- package/dist/rebac/evaluation.js.map +1 -0
- package/dist/rebac/expand-node.d.ts +13 -0
- package/dist/rebac/expand-node.d.ts.map +1 -0
- package/dist/rebac/expand-node.js +2 -0
- package/dist/rebac/expand-node.js.map +1 -0
- package/dist/rebac/in-memory-relation-tuple-store.d.ts +12 -0
- package/dist/rebac/in-memory-relation-tuple-store.d.ts.map +1 -0
- package/dist/rebac/in-memory-relation-tuple-store.js +25 -0
- package/dist/rebac/in-memory-relation-tuple-store.js.map +1 -0
- package/dist/rebac/invalid-tuple-error.d.ts +5 -0
- package/dist/rebac/invalid-tuple-error.d.ts.map +1 -0
- package/dist/rebac/invalid-tuple-error.js +8 -0
- package/dist/rebac/invalid-tuple-error.js.map +1 -0
- package/dist/rebac/object-of.d.ts +3 -0
- package/dist/rebac/object-of.d.ts.map +1 -0
- package/dist/rebac/object-of.js +4 -0
- package/dist/rebac/object-of.js.map +1 -0
- package/dist/rebac/parse-object.d.ts +3 -0
- package/dist/rebac/parse-object.d.ts.map +1 -0
- package/dist/rebac/parse-object.js +10 -0
- package/dist/rebac/parse-object.js.map +1 -0
- package/dist/rebac/parse-subject.d.ts +3 -0
- package/dist/rebac/parse-subject.d.ts.map +1 -0
- package/dist/rebac/parse-subject.js +11 -0
- package/dist/rebac/parse-subject.js.map +1 -0
- package/dist/rebac/permission-mapping.d.ts +3 -0
- package/dist/rebac/permission-mapping.d.ts.map +1 -0
- package/dist/rebac/permission-mapping.js +2 -0
- package/dist/rebac/permission-mapping.js.map +1 -0
- package/dist/rebac/relation-based-authorizer.d.ts +45 -0
- package/dist/rebac/relation-based-authorizer.d.ts.map +1 -0
- package/dist/rebac/relation-based-authorizer.js +113 -0
- package/dist/rebac/relation-based-authorizer.js.map +1 -0
- package/dist/rebac/relation-tuple-store.d.ts +16 -0
- package/dist/rebac/relation-tuple-store.d.ts.map +1 -0
- package/dist/rebac/relation-tuple-store.js +8 -0
- package/dist/rebac/relation-tuple-store.js.map +1 -0
- package/dist/rebac/relation-tuple.d.ts +12 -0
- package/dist/rebac/relation-tuple.d.ts.map +1 -0
- package/dist/rebac/relation-tuple.js +2 -0
- package/dist/rebac/relation-tuple.js.map +1 -0
- package/dist/rebac/resolution.d.ts +9 -0
- package/dist/rebac/resolution.d.ts.map +1 -0
- package/dist/rebac/resolution.js +2 -0
- package/dist/rebac/resolution.js.map +1 -0
- package/dist/rebac/reverse-expansion-limit-error.d.ts +5 -0
- package/dist/rebac/reverse-expansion-limit-error.d.ts.map +1 -0
- package/dist/rebac/reverse-expansion-limit-error.js +8 -0
- package/dist/rebac/reverse-expansion-limit-error.js.map +1 -0
- package/dist/rebac/rewrite.d.ts +24 -0
- package/dist/rebac/rewrite.d.ts.map +1 -0
- package/dist/rebac/rewrite.js +15 -0
- package/dist/rebac/rewrite.js.map +1 -0
- package/dist/rebac/schema-checked-tuple-store.d.ts +14 -0
- package/dist/rebac/schema-checked-tuple-store.d.ts.map +1 -0
- package/dist/rebac/schema-checked-tuple-store.js +25 -0
- package/dist/rebac/schema-checked-tuple-store.js.map +1 -0
- package/dist/rebac/schema-definition.d.ts +3 -0
- package/dist/rebac/schema-definition.d.ts.map +1 -0
- package/dist/rebac/schema-definition.js +2 -0
- package/dist/rebac/schema-definition.js.map +1 -0
- package/dist/rebac/schema-error.d.ts +5 -0
- package/dist/rebac/schema-error.d.ts.map +1 -0
- package/dist/rebac/schema-error.js +8 -0
- package/dist/rebac/schema-error.js.map +1 -0
- package/dist/rebac/schema.d.ts +18 -0
- package/dist/rebac/schema.d.ts.map +1 -0
- package/dist/rebac/schema.js +49 -0
- package/dist/rebac/schema.js.map +1 -0
- package/dist/rebac/subject-ref.d.ts +6 -0
- package/dist/rebac/subject-ref.d.ts.map +1 -0
- package/dist/rebac/subject-ref.js +2 -0
- package/dist/rebac/subject-ref.js.map +1 -0
- package/dist/rebac/tuple-key.d.ts +3 -0
- package/dist/rebac/tuple-key.d.ts.map +1 -0
- package/dist/rebac/tuple-key.js +4 -0
- package/dist/rebac/tuple-key.js.map +1 -0
- package/dist/rebac/type-definition.d.ts +7 -0
- package/dist/rebac/type-definition.d.ts.map +1 -0
- package/dist/rebac/type-definition.js +2 -0
- package/dist/rebac/type-definition.js.map +1 -0
- package/dist/rebac.d.ts +22 -0
- package/dist/rebac.d.ts.map +1 -0
- package/dist/rebac.js +15 -0
- package/dist/rebac.js.map +1 -0
- package/dist/testing/actor-builder.d.ts +21 -0
- package/dist/testing/actor-builder.d.ts.map +1 -0
- package/dist/testing/actor-builder.js +26 -0
- package/dist/testing/actor-builder.js.map +1 -0
- package/dist/testing/allow-all.d.ts +9 -0
- package/dist/testing/allow-all.d.ts.map +1 -0
- package/dist/testing/allow-all.js +11 -0
- package/dist/testing/allow-all.js.map +1 -0
- package/dist/testing/an-actor.d.ts +4 -0
- package/dist/testing/an-actor.d.ts.map +1 -0
- package/dist/testing/an-actor.js +7 -0
- package/dist/testing/an-actor.js.map +1 -0
- package/dist/testing/authorizer-contract.d.ts +18 -0
- package/dist/testing/authorizer-contract.d.ts.map +1 -0
- package/dist/testing/authorizer-contract.js +102 -0
- package/dist/testing/authorizer-contract.js.map +1 -0
- package/dist/testing/deny-all.d.ts +10 -0
- package/dist/testing/deny-all.d.ts.map +1 -0
- package/dist/testing/deny-all.js +14 -0
- package/dist/testing/deny-all.js.map +1 -0
- package/dist/testing/fake-authenticator.d.ts +13 -0
- package/dist/testing/fake-authenticator.d.ts.map +1 -0
- package/dist/testing/fake-authenticator.js +26 -0
- package/dist/testing/fake-authenticator.js.map +1 -0
- package/dist/testing/recording-authorizer.d.ts +15 -0
- package/dist/testing/recording-authorizer.d.ts.map +1 -0
- package/dist/testing/recording-authorizer.js +19 -0
- package/dist/testing/recording-authorizer.js.map +1 -0
- package/dist/testing/relation-tuple-store-contract.d.ts +10 -0
- package/dist/testing/relation-tuple-store-contract.d.ts.map +1 -0
- package/dist/testing/relation-tuple-store-contract.js +68 -0
- package/dist/testing/relation-tuple-store-contract.js.map +1 -0
- package/dist/testing.d.ts +9 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +9 -0
- package/dist/testing.js.map +1 -0
- package/dist/use-cases/authorization-map.d.ts +18 -0
- package/dist/use-cases/authorization-map.d.ts.map +1 -0
- package/dist/use-cases/authorization-map.js +32 -0
- package/dist/use-cases/authorization-map.js.map +1 -0
- package/dist/use-cases/authorization-middleware.d.ts +17 -0
- package/dist/use-cases/authorization-middleware.d.ts.map +1 -0
- package/dist/use-cases/authorization-middleware.js +49 -0
- package/dist/use-cases/authorization-middleware.js.map +1 -0
- package/dist/use-cases/public-use-case.d.ts +5 -0
- package/dist/use-cases/public-use-case.d.ts.map +1 -0
- package/dist/use-cases/public-use-case.js +5 -0
- package/dist/use-cases/public-use-case.js.map +1 -0
- package/dist/use-cases/requires.d.ts +17 -0
- package/dist/use-cases/requires.d.ts.map +1 -0
- package/dist/use-cases/requires.js +14 -0
- package/dist/use-cases/requires.js.map +1 -0
- package/dist/use-cases/use-case-declaration.d.ts +17 -0
- package/dist/use-cases/use-case-declaration.d.ts.map +1 -0
- package/dist/use-cases/use-case-declaration.js +2 -0
- package/dist/use-cases/use-case-declaration.js.map +1 -0
- package/package.json +67 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** A protected command or query was sent without its actor. A programming error, not a refusal. */
|
|
2
|
+
export class MissingActorError extends Error {
|
|
3
|
+
constructor(info) {
|
|
4
|
+
super(`The ${info.kind} ${info.name} requires a permission but carries no actor. Extend AuthorizedCommand or AuthorizedQuery.`);
|
|
5
|
+
this.name = 'MissingActorError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=missing-actor-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing-actor-error.js","sourceRoot":"","sources":["../../src/errors/missing-actor-error.ts"],"names":[],"mappings":"AAEA,mGAAmG;AACnG,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,IAAiB;QAC3B,KAAK,CACH,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,2FAA2F,CACzH,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DomainError } from '@ddd-ts-kit/kernel';
|
|
2
|
+
/**
|
|
3
|
+
* The code `UnauthorizedError` of @ddd-ts-kit/http carries, so its default error mapping
|
|
4
|
+
* answers 401 for the errors of this package with no extra wiring.
|
|
5
|
+
*/
|
|
6
|
+
export declare const UNAUTHORIZED = "UNAUTHORIZED";
|
|
7
|
+
/** Nobody is authenticated and the use case is not public. */
|
|
8
|
+
export declare class UnauthenticatedError extends DomainError {
|
|
9
|
+
readonly code = "UNAUTHORIZED";
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=unauthenticated-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unauthenticated-error.d.ts","sourceRoot":"","sources":["../../src/errors/unauthenticated-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAE3C,8DAA8D;AAC9D,qBAAa,oBAAqB,SAAQ,WAAW;IACnD,QAAQ,CAAC,IAAI,kBAAgB;IAE7B,cAEC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DomainError } from '@ddd-ts-kit/kernel';
|
|
2
|
+
/**
|
|
3
|
+
* The code `UnauthorizedError` of @ddd-ts-kit/http carries, so its default error mapping
|
|
4
|
+
* answers 401 for the errors of this package with no extra wiring.
|
|
5
|
+
*/
|
|
6
|
+
export const UNAUTHORIZED = 'UNAUTHORIZED';
|
|
7
|
+
/** Nobody is authenticated and the use case is not public. */
|
|
8
|
+
export class UnauthenticatedError extends DomainError {
|
|
9
|
+
code = UNAUTHORIZED;
|
|
10
|
+
constructor() {
|
|
11
|
+
super('Authentication is required');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=unauthenticated-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unauthenticated-error.js","sourceRoot":"","sources":["../../src/errors/unauthenticated-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,8DAA8D;AAC9D,MAAM,OAAO,oBAAqB,SAAQ,WAAW;IAC1C,IAAI,GAAG,YAAY,CAAC;IAE7B;QACE,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MessageInfo } from '@ddd-ts-kit/kernel';
|
|
2
|
+
/**
|
|
3
|
+
* A command or query reached the bus without `requires` or `publicUseCase`. A programming
|
|
4
|
+
* error, not a refusal: it must fail a test, never be answered as a 403.
|
|
5
|
+
*/
|
|
6
|
+
export declare class UndeclaredUseCaseError extends Error {
|
|
7
|
+
constructor(info: MessageInfo);
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=undeclared-use-case-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undeclared-use-case-error.d.ts","sourceRoot":"","sources":["../../src/errors/undeclared-use-case-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;GAGG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,IAAI,EAAE,WAAW,EAM5B;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A command or query reached the bus without `requires` or `publicUseCase`. A programming
|
|
3
|
+
* error, not a refusal: it must fail a test, never be answered as a 403.
|
|
4
|
+
*/
|
|
5
|
+
export class UndeclaredUseCaseError extends Error {
|
|
6
|
+
constructor(info) {
|
|
7
|
+
super(`The ${info.kind} ${info.name} declares no access. Declare it with requires(${info.name}, permission) or publicUseCase(${info.name}).`);
|
|
8
|
+
this.name = 'UndeclaredUseCaseError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=undeclared-use-case-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"undeclared-use-case-error.js","sourceRoot":"","sources":["../../src/errors/undeclared-use-case-error.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,IAAiB;QAC3B,KAAK,CACH,OAAO,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,iDAAiD,IAAI,CAAC,IAAI,kCAAkC,IAAI,CAAC,IAAI,IAAI,CACvI,CAAC;QAEF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export { AuthorizationSetupError } from './errors/authorization-setup-error.js';
|
|
2
|
+
export { FORBIDDEN, ForbiddenError } from './errors/forbidden-error.js';
|
|
3
|
+
export { InvalidCredentialError } from './errors/invalid-credential-error.js';
|
|
4
|
+
export { ListingNotSupportedError } from './errors/listing-not-supported-error.js';
|
|
5
|
+
export { MissingActorError } from './errors/missing-actor-error.js';
|
|
6
|
+
export { UNAUTHORIZED, UnauthenticatedError } from './errors/unauthenticated-error.js';
|
|
7
|
+
export { UndeclaredUseCaseError } from './errors/undeclared-use-case-error.js';
|
|
8
|
+
export { definePermissions, type PermissionDeclaration, type PermissionSet } from './permissions/define-permissions.js';
|
|
9
|
+
export type { Grant } from './permissions/grant.js';
|
|
10
|
+
export { isPermission } from './permissions/is-permission.js';
|
|
11
|
+
export type { Permission } from './permissions/permission.js';
|
|
12
|
+
export { PermissionRegistry } from './permissions/permission-registry.js';
|
|
13
|
+
export { Access } from './authorization/access.js';
|
|
14
|
+
export type { AccessScope } from './authorization/access-scope.js';
|
|
15
|
+
export type { AuthorizationContext } from './authorization/authorization-context.js';
|
|
16
|
+
export { Authorizer } from './authorization/authorizer.js';
|
|
17
|
+
export type { CheckRequest } from './authorization/check-request.js';
|
|
18
|
+
export { ALLOWED, deny, type Decision } from './authorization/decision.js';
|
|
19
|
+
export type { DecisionRecord } from './authorization/decision-record.js';
|
|
20
|
+
export { DenialReason } from './authorization/denial-reason.js';
|
|
21
|
+
export { isResourceRef } from './authorization/is-resource-ref.js';
|
|
22
|
+
export type { ListRequest } from './authorization/list-request.js';
|
|
23
|
+
export type { OnDecision } from './authorization/on-decision.js';
|
|
24
|
+
export type { ResourceRef } from './authorization/resource-ref.js';
|
|
25
|
+
export { AuthorizationMap } from './use-cases/authorization-map.js';
|
|
26
|
+
export { authorizationMiddleware, type AuthorizationMiddlewareOptions } from './use-cases/authorization-middleware.js';
|
|
27
|
+
export { publicUseCase } from './use-cases/public-use-case.js';
|
|
28
|
+
export { requires, type RequirementOptions } from './use-cases/requires.js';
|
|
29
|
+
export type { ProtectedUseCase, PublicUseCase, UseCaseDeclaration } from './use-cases/use-case-declaration.js';
|
|
30
|
+
export { definePolicy } from './policies/define-policy.js';
|
|
31
|
+
export type { Policy } from './policies/policy.js';
|
|
32
|
+
export { NO_POLICY, PolicyAccess, type PolicyAccessOptions } from './policies/policy-access.js';
|
|
33
|
+
export type { PolicyContext } from './policies/policy-context.js';
|
|
34
|
+
export { RoleBasedAuthorizer, type RoleBasedAuthorizerOptions } from './rbac/role-based-authorizer.js';
|
|
35
|
+
export { tenantOfContext } from './rbac/tenant-of-context.js';
|
|
36
|
+
export { forbid, permit, type AttributePolicy } from './abac/attribute-policy.js';
|
|
37
|
+
export { allOf, anyOf, not, type Condition } from './abac/condition.js';
|
|
38
|
+
export { PolicyBasedAuthorizer, type PolicyBasedAuthorizerOptions } from './abac/policy-based-authorizer.js';
|
|
39
|
+
export type { PolicyInput } from './abac/policy-input.js';
|
|
40
|
+
export type { ResourceAttributeValues } from './abac/resource-attribute-values.js';
|
|
41
|
+
export { ResourceAttributes } from './abac/resource-attributes.js';
|
|
42
|
+
export { actorOf } from './authentication/actor-of.js';
|
|
43
|
+
export { Authenticator } from './authentication/authenticator.js';
|
|
44
|
+
export { bearerCredential } from './authentication/bearer-credential.js';
|
|
45
|
+
export type { HeaderValues } from './authentication/header-values.js';
|
|
46
|
+
export { inActorContext } from './authentication/in-actor-context.js';
|
|
47
|
+
export { principalResolver } from './authentication/principal-resolver.js';
|
|
48
|
+
export { resolveSession } from './authentication/resolve-session.js';
|
|
49
|
+
export { SessionAuthenticator } from './authentication/session-authenticator.js';
|
|
50
|
+
export { sessionOf } from './authentication/session-of.js';
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC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,CAAC;AACzE,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export { AuthorizationSetupError } from './errors/authorization-setup-error.js';
|
|
2
|
+
export { FORBIDDEN, ForbiddenError } from './errors/forbidden-error.js';
|
|
3
|
+
export { InvalidCredentialError } from './errors/invalid-credential-error.js';
|
|
4
|
+
export { ListingNotSupportedError } from './errors/listing-not-supported-error.js';
|
|
5
|
+
export { MissingActorError } from './errors/missing-actor-error.js';
|
|
6
|
+
export { UNAUTHORIZED, UnauthenticatedError } from './errors/unauthenticated-error.js';
|
|
7
|
+
export { UndeclaredUseCaseError } from './errors/undeclared-use-case-error.js';
|
|
8
|
+
export { definePermissions } from './permissions/define-permissions.js';
|
|
9
|
+
export { isPermission } from './permissions/is-permission.js';
|
|
10
|
+
export { PermissionRegistry } from './permissions/permission-registry.js';
|
|
11
|
+
export { Access } from './authorization/access.js';
|
|
12
|
+
export { Authorizer } from './authorization/authorizer.js';
|
|
13
|
+
export { ALLOWED, deny } from './authorization/decision.js';
|
|
14
|
+
export { DenialReason } from './authorization/denial-reason.js';
|
|
15
|
+
export { isResourceRef } from './authorization/is-resource-ref.js';
|
|
16
|
+
export { AuthorizationMap } from './use-cases/authorization-map.js';
|
|
17
|
+
export { authorizationMiddleware } from './use-cases/authorization-middleware.js';
|
|
18
|
+
export { publicUseCase } from './use-cases/public-use-case.js';
|
|
19
|
+
export { requires } from './use-cases/requires.js';
|
|
20
|
+
export { definePolicy } from './policies/define-policy.js';
|
|
21
|
+
export { NO_POLICY, PolicyAccess } from './policies/policy-access.js';
|
|
22
|
+
export { RoleBasedAuthorizer } from './rbac/role-based-authorizer.js';
|
|
23
|
+
export { tenantOfContext } from './rbac/tenant-of-context.js';
|
|
24
|
+
export { forbid, permit } from './abac/attribute-policy.js';
|
|
25
|
+
export { allOf, anyOf, not } from './abac/condition.js';
|
|
26
|
+
export { PolicyBasedAuthorizer } from './abac/policy-based-authorizer.js';
|
|
27
|
+
export { ResourceAttributes } from './abac/resource-attributes.js';
|
|
28
|
+
export { actorOf } from './authentication/actor-of.js';
|
|
29
|
+
export { Authenticator } from './authentication/authenticator.js';
|
|
30
|
+
export { bearerCredential } from './authentication/bearer-credential.js';
|
|
31
|
+
export { inActorContext } from './authentication/in-actor-context.js';
|
|
32
|
+
export { principalResolver } from './authentication/principal-resolver.js';
|
|
33
|
+
export { resolveSession } from './authentication/resolve-session.js';
|
|
34
|
+
export { SessionAuthenticator } from './authentication/session-authenticator.js';
|
|
35
|
+
export { sessionOf } from './authentication/session-of.js';
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACvF,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAkD,MAAM,qCAAqC,CAAC;AAExH,OAA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E,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claims.d.ts","sourceRoot":"","sources":["../../src/jwt/claims.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,MAAM,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claims.js","sourceRoot":"","sources":["../../src/jwt/claims.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-service-account.d.ts","sourceRoot":"","sources":["../../src/jwt/is-service-account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAK1C,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAIxD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Keycloak names the user that stands for a client `service-account-<client id>`. */
|
|
2
|
+
const SERVICE_ACCOUNT_PREFIX = 'service-account-';
|
|
3
|
+
export function isServiceAccount(claims) {
|
|
4
|
+
const username = claims['preferred_username'];
|
|
5
|
+
return typeof username === 'string' && username.startsWith(SERVICE_ACCOUNT_PREFIX);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=is-service-account.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-service-account.js","sourceRoot":"","sources":["../../src/jwt/is-service-account.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAElD,MAAM,UAAU,gBAAgB,CAAC,MAAc;IAC7C,MAAM,QAAQ,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;IAE9C,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Actor, type AuthenticationMethod, type Session, type SessionExtensionValues } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { type JWTPayload, type KeyInput } from 'jose';
|
|
3
|
+
import type { SessionAuthenticator } from '../authentication/session-authenticator.js';
|
|
4
|
+
interface CommonOptions {
|
|
5
|
+
readonly issuer: string;
|
|
6
|
+
readonly audience: string | readonly string[];
|
|
7
|
+
/** Default: the asymmetric families RS256, PS256, ES256 and EdDSA. A shared secret needs HS256 said. */
|
|
8
|
+
readonly algorithms?: readonly string[];
|
|
9
|
+
/** Seconds of clock difference tolerated on `exp` and `nbf`. Default 0. */
|
|
10
|
+
readonly clockTolerance?: number;
|
|
11
|
+
/** The claim holding the tenant of the default mapping. Default `tenant_id`. */
|
|
12
|
+
readonly tenantClaim?: string;
|
|
13
|
+
/** Replaces the default mapping. Must not keep the token: an actor is plain, loggable data. */
|
|
14
|
+
readonly toActor?: (claims: JWTPayload) => Actor;
|
|
15
|
+
/**
|
|
16
|
+
* The claim naming who acts as the subject: the id itself, or an object holding it under
|
|
17
|
+
* `sub` or `id`. Default `act`, the actor claim of RFC 8693.
|
|
18
|
+
*/
|
|
19
|
+
readonly impersonatorClaim?: string;
|
|
20
|
+
/** Default: `password` when `amr` lists `pwd`, `token` otherwise. */
|
|
21
|
+
readonly authenticationMethod?: AuthenticationMethod | ((claims: JWTPayload) => AuthenticationMethod);
|
|
22
|
+
/** The fields of the project under `session.extensions`. Must not keep the token either. */
|
|
23
|
+
readonly toSessionExtensions?: (claims: JWTPayload) => SessionExtensionValues;
|
|
24
|
+
}
|
|
25
|
+
export type JwtAuthenticatorOptions = CommonOptions & ({
|
|
26
|
+
readonly jwksUri: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly key: KeyInput;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Verifies a signed JWT (signature, issuer, audience, expiry, algorithm allow-list) and maps
|
|
32
|
+
* its claims to an actor and to its session. An unsigned token (`alg: none`) is always refused.
|
|
33
|
+
*
|
|
34
|
+
* The session reads registered claims: id from `sid`, else `jti`, else the subject and issue
|
|
35
|
+
* instant; `issuedAt` and `expiresAt` from `iat` and `exp`; the method and strength from `amr`
|
|
36
|
+
* and `acr`; `impersonatedBy` from `act`; `locale` and `timeZone` from `locale` and `zoneinfo`.
|
|
37
|
+
*/
|
|
38
|
+
export declare class JwtAuthenticator implements SessionAuthenticator {
|
|
39
|
+
private readonly sessionOfToken;
|
|
40
|
+
constructor(options: JwtAuthenticatorOptions);
|
|
41
|
+
authenticate(credential: string | undefined): Promise<Actor>;
|
|
42
|
+
authenticateSession(credential: string | undefined): Promise<Session>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=jwt-authenticator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-authenticator.d.ts","sourceRoot":"","sources":["../../src/jwt/jwt-authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EACV,KAAK,oBAAoB,EACzB,KAAK,OAAO,EACZ,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAyC,KAAK,UAAU,EAAwB,KAAK,QAAQ,EAAE,MAAM,MAAM,CAAC;AACnH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAIvF,UAAU,aAAa;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAC9C,wGAAw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invalid-credential-error.js';
|
|
4
|
+
import { sessionOfClaims } from './session-of-claims.js';
|
|
5
|
+
/**
|
|
6
|
+
* Verifies a signed JWT (signature, issuer, audience, expiry, algorithm allow-list) and maps
|
|
7
|
+
* its claims to an actor and to its session. An unsigned token (`alg: none`) is always refused.
|
|
8
|
+
*
|
|
9
|
+
* The session reads registered claims: id from `sid`, else `jti`, else the subject and issue
|
|
10
|
+
* instant; `issuedAt` and `expiresAt` from `iat` and `exp`; the method and strength from `amr`
|
|
11
|
+
* and `acr`; `impersonatedBy` from `act`; `locale` and `timeZone` from `locale` and `zoneinfo`.
|
|
12
|
+
*/
|
|
13
|
+
export class JwtAuthenticator {
|
|
14
|
+
/*
|
|
15
|
+
* The verification key, which may be a shared secret, is held by this function and by
|
|
16
|
+
* nothing else: an authenticator that is logged, spread or serialized shows no key.
|
|
17
|
+
*/
|
|
18
|
+
sessionOfToken;
|
|
19
|
+
constructor(options) {
|
|
20
|
+
this.sessionOfToken = sessionReaderOf(options);
|
|
21
|
+
}
|
|
22
|
+
async authenticate(credential) {
|
|
23
|
+
return (await this.authenticateSession(credential)).actor;
|
|
24
|
+
}
|
|
25
|
+
async authenticateSession(credential) {
|
|
26
|
+
return credential === undefined ? anonymousSession() : this.sessionOfToken(credential);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const DEFAULT_TENANT_CLAIM = 'tenant_id';
|
|
30
|
+
function sessionReaderOf(options) {
|
|
31
|
+
const key = 'jwksUri' in options ? createRemoteJWKSet(new URL(options.jwksUri)) : options.key;
|
|
32
|
+
const tenantClaim = options.tenantClaim ?? DEFAULT_TENANT_CLAIM;
|
|
33
|
+
const toActor = options.toActor ?? ((claims) => actorOfClaims(claims, tenantClaim));
|
|
34
|
+
return async (token) => {
|
|
35
|
+
const claims = await verifiedClaims(token, key, options);
|
|
36
|
+
return sessionOfClaims(claims, toActor(claims), options);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const DEFAULT_ALGORITHMS = ['RS256', 'PS256', 'ES256', 'EdDSA'];
|
|
40
|
+
async function verifiedClaims(token, key, options) {
|
|
41
|
+
const { issuer, audience, algorithms = DEFAULT_ALGORITHMS, clockTolerance = 0 } = options;
|
|
42
|
+
try {
|
|
43
|
+
const { payload } = await jwtVerify(token, key, {
|
|
44
|
+
issuer,
|
|
45
|
+
audience: [...[audience].flat()],
|
|
46
|
+
algorithms: [...algorithms],
|
|
47
|
+
clockTolerance,
|
|
48
|
+
});
|
|
49
|
+
return payload;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw refusalOf(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Why a token was refused, by error code of the verification library. */
|
|
56
|
+
const REASONS = {
|
|
57
|
+
ERR_JWT_EXPIRED: 'TOKEN_EXPIRED',
|
|
58
|
+
ERR_JWT_CLAIM_VALIDATION_FAILED: 'CLAIM_MISMATCH',
|
|
59
|
+
ERR_JWS_SIGNATURE_VERIFICATION_FAILED: 'BAD_SIGNATURE',
|
|
60
|
+
ERR_JOSE_ALG_NOT_ALLOWED: 'ALGORITHM_NOT_ALLOWED',
|
|
61
|
+
ERR_JOSE_NOT_SUPPORTED: 'UNSUPPORTED_TOKEN',
|
|
62
|
+
ERR_JWKS_NO_MATCHING_KEY: 'UNKNOWN_KEY',
|
|
63
|
+
ERR_JWS_INVALID: 'MALFORMED_TOKEN',
|
|
64
|
+
ERR_JWT_INVALID: 'MALFORMED_TOKEN',
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* A refused token is an `InvalidCredentialError`; anything else (the key set cannot be fetched)
|
|
68
|
+
* is an infrastructure fault and stays what it is, to be answered as a 5xx.
|
|
69
|
+
*/
|
|
70
|
+
function refusalOf(error) {
|
|
71
|
+
if (!(error instanceof errors.JOSEError)) {
|
|
72
|
+
return error;
|
|
73
|
+
}
|
|
74
|
+
const reason = REASONS[error.code];
|
|
75
|
+
return reason === undefined ? error : new InvalidCredentialError(reason);
|
|
76
|
+
}
|
|
77
|
+
function actorOfClaims(claims, tenantClaim) {
|
|
78
|
+
if (claims.sub === undefined || claims.sub === '') {
|
|
79
|
+
throw new InvalidCredentialError('NO_SUBJECT');
|
|
80
|
+
}
|
|
81
|
+
const tenantId = claims[tenantClaim];
|
|
82
|
+
return {
|
|
83
|
+
id: claims.sub,
|
|
84
|
+
type: 'user',
|
|
85
|
+
...(typeof tenantId === 'string' ? { tenantId } : {}),
|
|
86
|
+
roles: rolesOf(claims),
|
|
87
|
+
attributes: {},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The first claim present wins, in the order realm roles (`realm_access.roles`), a `roles`
|
|
92
|
+
* claim, OAuth scopes. They are never merged: a scope a client asked for must not pass for a role.
|
|
93
|
+
*/
|
|
94
|
+
function rolesOf(claims) {
|
|
95
|
+
const realmAccess = claims['realm_access'];
|
|
96
|
+
const realmRoles = typeof realmAccess === 'object' && realmAccess !== null && 'roles' in realmAccess ? realmAccess.roles : undefined;
|
|
97
|
+
const candidates = [stringsOf(realmRoles), stringsOf(claims['roles']), stringsOf(claims['scope'])];
|
|
98
|
+
return candidates.find((roles) => roles !== undefined) ?? [];
|
|
99
|
+
}
|
|
100
|
+
function stringsOf(claim) {
|
|
101
|
+
if (typeof claim === 'string') {
|
|
102
|
+
return claim.split(' ').filter((item) => item !== '');
|
|
103
|
+
}
|
|
104
|
+
if (!Array.isArray(claim)) {
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
107
|
+
return claim.filter((item) => typeof item === 'string');
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=jwt-authenticator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jwt-authenticator.js","sourceRoot":"","sources":["../../src/jwt/jwt-authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAKjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,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Q,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Actor } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import type { Claims } from './claims.js';
|
|
3
|
+
import type { KeycloakClaimOptions } from './keycloak-claim-options.js';
|
|
4
|
+
/** The actor of an access token issued by Keycloak. The token itself is never kept. */
|
|
5
|
+
export declare function keycloakActorOf(claims: Claims, options: KeycloakClaimOptions): Actor;
|
|
6
|
+
//# sourceMappingURL=keycloak-actor-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-actor-of.d.ts","sourceRoot":"","sources":["../../src/jwt/keycloak-actor-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAkB,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAKxE,uFAAuF;AACvF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,KAAK,CAgBpF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { InvalidCredentialError } from '../errors/invalid-credential-error.js';
|
|
2
|
+
import { isServiceAccount } from './is-service-account.js';
|
|
3
|
+
const DEFAULT_TENANT_CLAIM = 'tenant_id';
|
|
4
|
+
const DEFAULT_GROUPS_CLAIM = 'groups';
|
|
5
|
+
/** The actor of an access token issued by Keycloak. The token itself is never kept. */
|
|
6
|
+
export function keycloakActorOf(claims, options) {
|
|
7
|
+
const id = claims['sub'];
|
|
8
|
+
if (typeof id !== 'string' || id === '') {
|
|
9
|
+
throw new InvalidCredentialError('NO_SUBJECT');
|
|
10
|
+
}
|
|
11
|
+
const tenantId = tenantOf(claims[options.tenantClaim ?? DEFAULT_TENANT_CLAIM]);
|
|
12
|
+
return {
|
|
13
|
+
id,
|
|
14
|
+
type: isServiceAccount(claims) ? 'service' : 'user',
|
|
15
|
+
...(tenantId === undefined ? {} : { tenantId }),
|
|
16
|
+
roles: rolesOf(claims, options.clientId),
|
|
17
|
+
attributes: attributesOf(claims, options.groupsClaim ?? DEFAULT_GROUPS_CLAIM),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A text claim is the tenant. The `organization` claim lists the organizations of the user, as
|
|
22
|
+
* a list of aliases or as an object keyed by alias: it names a tenant only when there is
|
|
23
|
+
* exactly one, since choosing among several is a decision of the project.
|
|
24
|
+
*/
|
|
25
|
+
function tenantOf(claim) {
|
|
26
|
+
if (typeof claim === 'string') {
|
|
27
|
+
return claim === '' ? undefined : claim;
|
|
28
|
+
}
|
|
29
|
+
if (typeof claim !== 'object' || claim === null) {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
const candidates = Array.isArray(claim) ? claim : Object.keys(claim);
|
|
33
|
+
const [only] = candidates;
|
|
34
|
+
return candidates.length === 1 && typeof only === 'string' ? only : undefined;
|
|
35
|
+
}
|
|
36
|
+
function rolesOf(claims, clientId) {
|
|
37
|
+
const realmRoles = stringsOf(recordOf(claims['realm_access'])['roles']);
|
|
38
|
+
const access = clientId === undefined ? {} : recordOf(recordOf(claims['resource_access'])[clientId]);
|
|
39
|
+
return [...new Set([...realmRoles, ...stringsOf(access['roles'])])];
|
|
40
|
+
}
|
|
41
|
+
function stringsOf(claim) {
|
|
42
|
+
return Array.isArray(claim) ? claim.filter((item) => typeof item === 'string') : [];
|
|
43
|
+
}
|
|
44
|
+
function recordOf(claim) {
|
|
45
|
+
return typeof claim === 'object' && claim !== null ? { ...claim } : {};
|
|
46
|
+
}
|
|
47
|
+
function attributesOf(claims, groupsClaim) {
|
|
48
|
+
const username = claims['preferred_username'];
|
|
49
|
+
const email = claims['email'];
|
|
50
|
+
return {
|
|
51
|
+
...(typeof username === 'string' ? { username } : {}),
|
|
52
|
+
...(typeof email === 'string' ? { email } : {}),
|
|
53
|
+
...(groupsClaim in claims ? { groups: stringsOf(claims[groupsClaim]) } : {}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=keycloak-actor-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-actor-of.js","sourceRoot":"","sources":["../../src/jwt/keycloak-actor-of.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAE/E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,MAAM,oBAAoB,GAAG,WAAW,CAAC;AACzC,MAAM,oBAAoB,GAAG,QAAQ,CAAC;AAEtC,uFAAuF;AACvF,MAAM,UAAU,eAAe,CAAC,MAAc,EAAE,OAA6B;IAC3E,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAEzB,IAAI,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACxC,MAAM,IAAI,sBAAsB,CAAC,YAAY,CAAC,CAAC;IACjD,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,IAAI,oBAAoB,CAAC,CAAC,CAAC;IAE/E,OAAO;QACL,EAAE;QACF,IAAI,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CA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it/kernel';
|
|
2
|
+
import type { Claims } from './claims.js';
|
|
3
|
+
/** A person signs in through the single sign-on of the realm; a client presents its own secret. */
|
|
4
|
+
export declare function keycloakAuthenticationMethod(claims: Claims): AuthenticationMethod;
|
|
5
|
+
//# sourceMappingURL=keycloak-authentication-method.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-authentication-method.d.ts","sourceRoot":"","sources":["../../src/jwt/keycloak-authentication-method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAG1C,mGAAmG;AACnG,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAEjF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { isServiceAccount } from './is-service-account.js';
|
|
2
|
+
/** A person signs in through the single sign-on of the realm; a client presents its own secret. */
|
|
3
|
+
export function keycloakAuthenticationMethod(claims) {
|
|
4
|
+
return isServiceAccount(claims) ? 'service' : 'sso';
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=keycloak-authentication-method.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-authentication-method.js","sourceRoot":"","sources":["../../src/jwt/keycloak-authentication-method.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,mGAAmG;AACnG,MAAM,UAAU,4BAA4B,CAAC,MAAc;IACzD,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SessionExtensionValues } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import type { JWTPayload } from 'jose';
|
|
3
|
+
import { JwtAuthenticator } from './jwt-authenticator.js';
|
|
4
|
+
import type { KeycloakClaimOptions } from './keycloak-claim-options.js';
|
|
5
|
+
export interface KeycloakAuthenticatorOptions extends KeycloakClaimOptions {
|
|
6
|
+
/** Where Keycloak is served, without the realm: `https://id.example.com`. */
|
|
7
|
+
readonly baseUrl: string;
|
|
8
|
+
readonly realm: string;
|
|
9
|
+
/** What the `aud` claim must name: this API, as the audience mapper of the realm writes it. */
|
|
10
|
+
readonly audience: string | readonly string[];
|
|
11
|
+
readonly algorithms?: readonly string[];
|
|
12
|
+
readonly clockTolerance?: number;
|
|
13
|
+
/** Default `act`. See the README for the session note of an administrator impersonating a user. */
|
|
14
|
+
readonly impersonatorClaim?: string;
|
|
15
|
+
readonly toSessionExtensions?: (claims: JWTPayload) => SessionExtensionValues;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A `JwtAuthenticator` for the access tokens of a Keycloak realm: issuer and key set derived
|
|
19
|
+
* from the realm, realm roles and the roles of `clientId` as `roles`, `preferred_username`,
|
|
20
|
+
* `email` and `groups` as attributes, `sid` as session id.
|
|
21
|
+
*/
|
|
22
|
+
export declare function keycloakAuthenticator(options: KeycloakAuthenticatorOptions): JwtAuthenticator;
|
|
23
|
+
//# sourceMappingURL=keycloak-authenticator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-authenticator.d.ts","sourceRoot":"","sources":["../../src/jwt/keycloak-authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAGxE,MAAM,WAAW,4BAA6B,SAAQ,oBAAoB;IACxE,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+FAA+F;IAC/F,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,mGAAmG;IACnG,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,sBAAsB,CAAC;CAC/E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,gBAAgB,CAe7F"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { JwtAuthenticator } from './jwt-authenticator.js';
|
|
2
|
+
import { keycloakActorOf } from './keycloak-actor-of.js';
|
|
3
|
+
import { keycloakAuthenticationMethod } from './keycloak-authentication-method.js';
|
|
4
|
+
import { withoutTrailingSlashes } from './without-trailing-slashes.js';
|
|
5
|
+
/**
|
|
6
|
+
* A `JwtAuthenticator` for the access tokens of a Keycloak realm: issuer and key set derived
|
|
7
|
+
* from the realm, realm roles and the roles of `clientId` as `roles`, `preferred_username`,
|
|
8
|
+
* `email` and `groups` as attributes, `sid` as session id.
|
|
9
|
+
*/
|
|
10
|
+
export function keycloakAuthenticator(options) {
|
|
11
|
+
const { baseUrl, realm, audience, algorithms, clockTolerance, impersonatorClaim, toSessionExtensions } = options;
|
|
12
|
+
const issuer = `${withoutTrailingSlashes(baseUrl)}/realms/${encodeURIComponent(realm)}`;
|
|
13
|
+
return new JwtAuthenticator({
|
|
14
|
+
issuer,
|
|
15
|
+
audience,
|
|
16
|
+
jwksUri: `${issuer}/protocol/openid-connect/certs`,
|
|
17
|
+
toActor: (claims) => keycloakActorOf(claims, options),
|
|
18
|
+
authenticationMethod: keycloakAuthenticationMethod,
|
|
19
|
+
...(algorithms === undefined ? {} : { algorithms }),
|
|
20
|
+
...(clockTolerance === undefined ? {} : { clockTolerance }),
|
|
21
|
+
...(impersonatorClaim === undefined ? {} : { impersonatorClaim }),
|
|
22
|
+
...(toSessionExtensions === undefined ? {} : { toSessionExtensions }),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=keycloak-authenticator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-authenticator.js","sourceRoot":"","sources":["../../src/jwt/keycloak-authenticator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAEnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAevE;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAqC;IACzE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,cAAc,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,GAAG,OAAO,CAAC;IACjH,MAAM,MAAM,GAAG,GAAG,sBAAsB,CAAC,OAAO,CAAC,WAAW,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;IAExF,OAAO,IAAI,gBAAgB,CAAC;QAC1B,MAAM;QACN,QAAQ;QACR,OAAO,EAAE,GAAG,MAAM,gCAAgC;QAClD,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC;QACrD,oBAAoB,EAAE,4BAA4B;QAClD,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC;QACnD,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC;QAC3D,GAAG,CAAC,iBAAiB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,CAAC;QACjE,GAAG,CAAC,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC;KACtE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface KeycloakClaimOptions {
|
|
2
|
+
/** The client whose roles (`resource_access.<clientId>.roles`) join the realm roles. */
|
|
3
|
+
readonly clientId?: string;
|
|
4
|
+
/** The claim holding the tenant. Default `tenant_id`; `organization` reads the organization of the user. */
|
|
5
|
+
readonly tenantClaim?: string;
|
|
6
|
+
/** The claim written by the group membership mapper. Default `groups`. */
|
|
7
|
+
readonly groupsClaim?: string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=keycloak-claim-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-claim-options.d.ts","sourceRoot":"","sources":["../../src/jwt/keycloak-claim-options.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,4GAA4G;IAC5G,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keycloak-claim-options.js","sourceRoot":"","sources":["../../src/jwt/keycloak-claim-options.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Actor, AuthenticationMethod, Session, SessionExtensionValues } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import type { Claims } from './claims.js';
|
|
3
|
+
export interface SessionClaimOptions<C extends Claims> {
|
|
4
|
+
readonly impersonatorClaim?: string;
|
|
5
|
+
readonly authenticationMethod?: AuthenticationMethod | ((claims: C) => AuthenticationMethod);
|
|
6
|
+
readonly toSessionExtensions?: (claims: C) => SessionExtensionValues;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The session a verified token stands for. Registered claims only (RFC 7519, OpenID Connect
|
|
10
|
+
* Core, RFC 8176, RFC 8693): the identity provider decides what they say.
|
|
11
|
+
*/
|
|
12
|
+
export declare function sessionOfClaims<C extends Claims>(claims: C, actor: Actor, options: SessionClaimOptions<C>): Session;
|
|
13
|
+
//# sourceMappingURL=session-of-claims.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-of-claims.d.ts","sourceRoot":"","sources":["../../src/jwt/session-of-claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EAEpB,OAAO,EACP,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,mBAAmB,CAAC,CAAC,SAAS,MAAM;IACnD,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,oBAAoB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,oBAAoB,CAAC,CAAC;IAC7F,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,sBAAsB,CAAC;CACtE;AAMD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,CAenH"}
|