@ddd-ts-kit/auth 0.0.0-stage → 0.1.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/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,13 @@
|
|
|
1
|
+
import type { Grant } from '../permissions/grant.js';
|
|
2
|
+
import type { Condition } from './condition.js';
|
|
3
|
+
export interface AttributePolicy {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly effect: 'permit' | 'forbid';
|
|
6
|
+
readonly grants: readonly string[];
|
|
7
|
+
readonly when: Condition;
|
|
8
|
+
}
|
|
9
|
+
/** Allows the permissions when the condition holds, unless a `forbid` policy applies. */
|
|
10
|
+
export declare function permit(name: string, permissions: readonly Grant[], when?: Condition): AttributePolicy;
|
|
11
|
+
/** Refuses the permissions when the condition holds, whatever the `permit` policies say. */
|
|
12
|
+
export declare function forbid(name: string, permissions: readonly Grant[], when?: Condition): AttributePolicy;
|
|
13
|
+
//# sourceMappingURL=attribute-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute-policy.d.ts","sourceRoot":"","sources":["../../src/abac/attribute-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B;AAED,yFAAyF;AACzF,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,KAAK,EAAE,EAAE,IAAI,GAAE,SAAsB,GAAG,eAAe,CAEjH;AAED,4FAA4F;AAC5F,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,KAAK,EAAE,EAAE,IAAI,GAAE,SAAsB,GAAG,eAAe,CAEjH"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { grantPattern } from '../permissions/grant-pattern.js';
|
|
2
|
+
/** Allows the permissions when the condition holds, unless a `forbid` policy applies. */
|
|
3
|
+
export function permit(name, permissions, when = () => true) {
|
|
4
|
+
return { name, effect: 'permit', grants: permissions.map(grantPattern), when };
|
|
5
|
+
}
|
|
6
|
+
/** Refuses the permissions when the condition holds, whatever the `permit` policies say. */
|
|
7
|
+
export function forbid(name, permissions, when = () => true) {
|
|
8
|
+
return { name, effect: 'forbid', grants: permissions.map(grantPattern), when };
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=attribute-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute-policy.js","sourceRoot":"","sources":["../../src/abac/attribute-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAU/D,yFAAyF;AACzF,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,WAA6B,EAAE,IAAI,GAAc,GAAG,EAAE,CAAC,IAAI;IAC9F,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC;AACjF,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,WAA6B,EAAE,IAAI,GAAc,GAAG,EAAE,CAAC,IAAI;IAC9F,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC;AACjF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PolicyInput } from './policy-input.js';
|
|
2
|
+
export type Condition = (input: PolicyInput) => boolean;
|
|
3
|
+
export declare function anyOf(...conditions: readonly Condition[]): Condition;
|
|
4
|
+
export declare function allOf(...conditions: readonly Condition[]): Condition;
|
|
5
|
+
export declare function not(condition: Condition): Condition;
|
|
6
|
+
//# sourceMappingURL=condition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.d.ts","sourceRoot":"","sources":["../../src/abac/condition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC;AAExD,wBAAgB,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAEpE;AAED,wBAAgB,KAAK,CAAC,GAAG,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,CAEpE;AAED,wBAAgB,GAAG,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAEnD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function anyOf(...conditions) {
|
|
2
|
+
return (input) => conditions.some((condition) => condition(input));
|
|
3
|
+
}
|
|
4
|
+
export function allOf(...conditions) {
|
|
5
|
+
return (input) => conditions.every((condition) => condition(input));
|
|
6
|
+
}
|
|
7
|
+
export function not(condition) {
|
|
8
|
+
return (input) => !condition(input);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=condition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"condition.js","sourceRoot":"","sources":["../../src/abac/condition.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,KAAK,CAAC,GAAG,UAAgC;IACvD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACrE,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,GAAG,UAAgC;IACvD,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,GAAG,CAAC,SAAoB;IACtC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Clock } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import type { Authorizer } from '../authorization/authorizer.js';
|
|
3
|
+
import type { CheckRequest } from '../authorization/check-request.js';
|
|
4
|
+
import { type Decision } from '../authorization/decision.js';
|
|
5
|
+
import type { AttributePolicy } from './attribute-policy.js';
|
|
6
|
+
import type { ResourceAttributes } from './resource-attributes.js';
|
|
7
|
+
export interface PolicyBasedAuthorizerOptions {
|
|
8
|
+
readonly policies: readonly AttributePolicy[];
|
|
9
|
+
readonly clock: Clock;
|
|
10
|
+
readonly attributes?: ResourceAttributes;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* ABAC: rules over the attributes of the actor, of the resource and of the moment. A matching
|
|
14
|
+
* `forbid` wins over every `permit`; with no matching `permit` the answer is no. It does not
|
|
15
|
+
* implement `listAccessible`: an arbitrary predicate cannot be turned into a query.
|
|
16
|
+
*/
|
|
17
|
+
export declare class PolicyBasedAuthorizer implements Authorizer {
|
|
18
|
+
private readonly options;
|
|
19
|
+
constructor(options: PolicyBasedAuthorizerOptions);
|
|
20
|
+
check(request: CheckRequest): Promise<Decision>;
|
|
21
|
+
private inputOf;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=policy-based-authorizer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-based-authorizer.d.ts","sourceRoot":"","sources":["../../src/abac/policy-based-authorizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAiB,KAAK,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAG5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,SAAS,eAAe,EAAE,CAAC;IAC9C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,kBAAkB,CAAC;CAC1C;AAED;;;;GAIG;AACH,qBAAa,qBAAsB,YAAW,UAAU;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAApC,YAA6B,OAAO,EAAE,4BAA4B,EAAI;IAEhE,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,CAAC,CAgBpD;YAEa,OAAO;CAatB"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isAnonymous } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { ALLOWED, deny } from '../authorization/decision.js';
|
|
3
|
+
import { DenialReason } from '../authorization/denial-reason.js';
|
|
4
|
+
import { grantCovers } from '../permissions/grant-covers.js';
|
|
5
|
+
/**
|
|
6
|
+
* ABAC: rules over the attributes of the actor, of the resource and of the moment. A matching
|
|
7
|
+
* `forbid` wins over every `permit`; with no matching `permit` the answer is no. It does not
|
|
8
|
+
* implement `listAccessible`: an arbitrary predicate cannot be turned into a query.
|
|
9
|
+
*/
|
|
10
|
+
export class PolicyBasedAuthorizer {
|
|
11
|
+
options;
|
|
12
|
+
constructor(options) {
|
|
13
|
+
this.options = options;
|
|
14
|
+
}
|
|
15
|
+
async check(request) {
|
|
16
|
+
if (isAnonymous(request.actor)) {
|
|
17
|
+
return deny(DenialReason.anonymous);
|
|
18
|
+
}
|
|
19
|
+
const input = await this.inputOf(request);
|
|
20
|
+
const applying = this.options.policies.filter((policy) => policy.grants.some((pattern) => grantCovers(pattern, request.permission)) && policy.when(input));
|
|
21
|
+
if (applying.some((policy) => policy.effect === 'forbid')) {
|
|
22
|
+
return deny(DenialReason.explicitDeny);
|
|
23
|
+
}
|
|
24
|
+
return applying.length > 0 ? ALLOWED : deny(DenialReason.noMatchingPolicy);
|
|
25
|
+
}
|
|
26
|
+
async inputOf(request) {
|
|
27
|
+
const { resource } = request;
|
|
28
|
+
const attributes = resource === undefined ? undefined : await this.options.attributes?.of(resource);
|
|
29
|
+
return {
|
|
30
|
+
actor: request.actor,
|
|
31
|
+
permission: request.permission,
|
|
32
|
+
...(resource === undefined ? {} : { resource }),
|
|
33
|
+
attributes: attributes ?? {},
|
|
34
|
+
context: request.context ?? {},
|
|
35
|
+
now: this.options.clock.now(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=policy-based-authorizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-based-authorizer.js","sourceRoot":"","sources":["../../src/abac/policy-based-authorizer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,oBAAoB,CAAC;AAG7D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAiB,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAW7D;;;;GAIG;AACH,MAAM,OAAO,qBAAqB;IACH,OAAO;IAApC,YAA6B,OAAqC;uBAArC,OAAO;IAAiC,CAAC;IAEtE,KAAK,CAAC,KAAK,CAAC,OAAqB;QAC/B,IAAI,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;QAED,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAE1C,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAC3C,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAC5G,CAAC;QAEF,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,QAAQ,CAAC,EAAE,CAAC;YAC1D,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACzC,CAAC;QAED,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;IAC7E,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,OAAqB;QACzC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAC7B,MAAM,UAAU,GAAG,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;QAEpG,OAAO;YACL,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;YAC/C,UAAU,EAAE,UAAU,IAAI,EAAE;YAC5B,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;YAC9B,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE;SAC9B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Actor } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import type { AuthorizationContext } from '../authorization/authorization-context.js';
|
|
3
|
+
import type { ResourceRef } from '../authorization/resource-ref.js';
|
|
4
|
+
import type { Permission } from '../permissions/permission.js';
|
|
5
|
+
import type { ResourceAttributeValues } from './resource-attribute-values.js';
|
|
6
|
+
/** Everything a rule may look at. */
|
|
7
|
+
export interface PolicyInput {
|
|
8
|
+
readonly actor: Actor;
|
|
9
|
+
readonly permission: Permission;
|
|
10
|
+
readonly resource?: ResourceRef;
|
|
11
|
+
/** Empty when the request names no resource or the port knows nothing about it. */
|
|
12
|
+
readonly attributes: ResourceAttributeValues;
|
|
13
|
+
readonly context: AuthorizationContext;
|
|
14
|
+
/** From the `Clock` port. */
|
|
15
|
+
readonly now: Date;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=policy-input.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-input.d.ts","sourceRoot":"","sources":["../../src/abac/policy-input.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,qCAAqC;AACrC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC;IAChC,mFAAmF;IACnF,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;IAC7C,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAAC;IACvC,6BAA6B;IAC7B,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy-input.js","sourceRoot":"","sources":["../../src/abac/policy-input.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-attribute-values.d.ts","sourceRoot":"","sources":["../../src/abac/resource-attribute-values.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-attribute-values.js","sourceRoot":"","sources":["../../src/abac/resource-attribute-values.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ResourceRef } from '../authorization/resource-ref.js';
|
|
2
|
+
import type { ResourceAttributeValues } from './resource-attribute-values.js';
|
|
3
|
+
/** Where the attributes of an element come from: a projection, a cache, the owning context. */
|
|
4
|
+
export declare abstract class ResourceAttributes {
|
|
5
|
+
static readonly tokenKey = "auth.ResourceAttributes";
|
|
6
|
+
abstract of(resource: ResourceRef): Promise<ResourceAttributeValues | undefined>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=resource-attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-attributes.d.ts","sourceRoot":"","sources":["../../src/abac/resource-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,+FAA+F;AAC/F,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,QAAQ,CAAC,QAAQ,6BAA6B;IAErD,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAAC,uBAAuB,GAAG,SAAS,CAAC,CAAC;CAClF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-attributes.js","sourceRoot":"","sources":["../../src/abac/resource-attributes.ts"],"names":[],"mappings":"AAGA,+FAA+F;AAC/F,MAAM,OAAgB,kBAAkB;IACtC,MAAM,CAAU,QAAQ,GAAG,yBAAyB,CAAC;CAGtD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Actor } from '@ddd-ts-kit/kernel';
|
|
2
|
+
/**
|
|
3
|
+
* The actor a boundary received, anonymous when there is none. Takes the principal (a session
|
|
4
|
+
* or an actor) or the request context that holds it.
|
|
5
|
+
*/
|
|
6
|
+
export declare function actorOf(source: unknown): Actor;
|
|
7
|
+
//# sourceMappingURL=actor-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor-of.d.ts","sourceRoot":"","sources":["../../src/authentication/actor-of.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAGhD;;;GAGG;AACH,wBAAgB,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,KAAK,CAE9C"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { sessionOf } from './session-of.js';
|
|
2
|
+
/**
|
|
3
|
+
* The actor a boundary received, anonymous when there is none. Takes the principal (a session
|
|
4
|
+
* or an actor) or the request context that holds it.
|
|
5
|
+
*/
|
|
6
|
+
export function actorOf(source) {
|
|
7
|
+
return sessionOf(source).actor;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=actor-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actor-of.js","sourceRoot":"","sources":["../../src/authentication/actor-of.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,MAAe;IACrC,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Actor } from '@ddd-ts-kit/kernel';
|
|
2
|
+
/**
|
|
3
|
+
* Who is calling. A platform concern at the boundary: an adapter verifies the credential and
|
|
4
|
+
* produces an actor. Answers the anonymous actor when there is no credential, and raises
|
|
5
|
+
* `InvalidCredentialError` when one is presented and not acceptable.
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class Authenticator {
|
|
8
|
+
static readonly tokenKey: string;
|
|
9
|
+
abstract authenticate(credential: string | undefined): Promise<Actor>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=authenticator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticator.d.ts","sourceRoot":"","sources":["../../src/authentication/authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;;GAIG;AACH,8BAAsB,aAAa;IACjC,MAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAwB;IAExD,QAAQ,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;CACvE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who is calling. A platform concern at the boundary: an adapter verifies the credential and
|
|
3
|
+
* produces an actor. Answers the anonymous actor when there is no credential, and raises
|
|
4
|
+
* `InvalidCredentialError` when one is presented and not acceptable.
|
|
5
|
+
*/
|
|
6
|
+
export class Authenticator {
|
|
7
|
+
static tokenKey = 'auth.Authenticator';
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=authenticator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authenticator.js","sourceRoot":"","sources":["../../src/authentication/authenticator.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAgB,aAAa;IACjC,MAAM,CAAU,QAAQ,GAAW,oBAAoB,CAAC;CAGzD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { HeaderValues } from './header-values.js';
|
|
2
|
+
/**
|
|
3
|
+
* The token of `Authorization: Bearer <token>`, or `undefined` without the header. A header
|
|
4
|
+
* that is there and is not a well-formed bearer credential is refused, never ignored.
|
|
5
|
+
*/
|
|
6
|
+
export declare function bearerCredential(headers: HeaderValues): string | undefined;
|
|
7
|
+
//# sourceMappingURL=bearer-credential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bearer-credential.d.ts","sourceRoot":"","sources":["../../src/authentication/bearer-credential.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIvD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAe1E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InvalidCredentialError } from '../errors/invalid-credential-error.js';
|
|
2
|
+
const BEARER = /^Bearer +([A-Za-z0-9._~+/-]+=*)$/i;
|
|
3
|
+
/**
|
|
4
|
+
* The token of `Authorization: Bearer <token>`, or `undefined` without the header. A header
|
|
5
|
+
* that is there and is not a well-formed bearer credential is refused, never ignored.
|
|
6
|
+
*/
|
|
7
|
+
export function bearerCredential(headers) {
|
|
8
|
+
const name = Object.keys(headers).find((header) => header.toLowerCase() === 'authorization');
|
|
9
|
+
const value = name === undefined ? undefined : headers[name];
|
|
10
|
+
if (value === undefined) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const token = typeof value === 'string' ? BEARER.exec(value)?.[1] : undefined;
|
|
14
|
+
if (token === undefined) {
|
|
15
|
+
throw new InvalidCredentialError('MALFORMED_AUTHORIZATION_HEADER');
|
|
16
|
+
}
|
|
17
|
+
return token;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=bearer-credential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bearer-credential.js","sourceRoot":"","sources":["../../src/authentication/bearer-credential.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uCAAuC,CAAC;AAG/E,MAAM,MAAM,GAAG,mCAAmC,CAAC;AAEnD;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAqB;IACpD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,eAAe,CAAC,CAAC;IAC7F,MAAM,KAAK,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7D,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,sBAAsB,CAAC,gCAAgC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-values.d.ts","sourceRoot":"","sources":["../../src/authentication/header-values.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"header-values.js","sourceRoot":"","sources":["../../src/authentication/header-values.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ActorContext } from '@ddd-ts-kit/kernel';
|
|
2
|
+
interface WithPrincipal {
|
|
3
|
+
readonly context: {
|
|
4
|
+
readonly principal?: unknown;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Wraps a route handler so that everything it calls sees the actor through `ActorContext`:
|
|
9
|
+
* repositories stamping audit columns, tenant scoping. Use cases still get it in the message.
|
|
10
|
+
* Not needed when the adapter of @ddd-ts-kit/http is given an `executionScope` and the actor
|
|
11
|
+
* context is a `ScopedActorContext` over it, as `kernelModule()` binds them.
|
|
12
|
+
*/
|
|
13
|
+
export declare function inActorContext<Input extends WithPrincipal, Output>(actorContext: ActorContext, handle: (input: Input) => Output): (input: Input) => Output;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=in-actor-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-actor-context.d.ts","sourceRoot":"","sources":["../../src/authentication/in-actor-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,UAAU,aAAa;IACrB,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACpD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,SAAS,aAAa,EAAE,MAAM,EAChE,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,GAC/B,CAAC,KAAK,EAAE,KAAK,KAAK,MAAM,CAE1B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { actorOf } from './actor-of.js';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a route handler so that everything it calls sees the actor through `ActorContext`:
|
|
4
|
+
* repositories stamping audit columns, tenant scoping. Use cases still get it in the message.
|
|
5
|
+
* Not needed when the adapter of @ddd-ts-kit/http is given an `executionScope` and the actor
|
|
6
|
+
* context is a `ScopedActorContext` over it, as `kernelModule()` binds them.
|
|
7
|
+
*/
|
|
8
|
+
export function inActorContext(actorContext, handle) {
|
|
9
|
+
return (input) => actorContext.run(actorOf(input.context.principal), () => handle(input));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=in-actor-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"in-actor-context.js","sourceRoot":"","sources":["../../src/authentication/in-actor-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAMxC;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,YAA0B,EAC1B,MAAgC;IAEhC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5F,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Session } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import type { Authenticator } from './authenticator.js';
|
|
3
|
+
import type { SessionAuthenticator } from './session-authenticator.js';
|
|
4
|
+
/**
|
|
5
|
+
* The `resolvePrincipal` option of @ddd-ts-kit/http: takes the framework request, answers the
|
|
6
|
+
* session. The pipeline puts it, with its actor, in the execution context of the request;
|
|
7
|
+
* routes read `actorOf(context.principal)` and `sessionOf(context)`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function principalResolver(authenticator: Authenticator | SessionAuthenticator): (raw: unknown) => Promise<Session>;
|
|
10
|
+
//# sourceMappingURL=principal-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal-resolver.d.ts","sourceRoot":"","sources":["../../src/authentication/principal-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,GAAG,oBAAoB,GAClD,CAAC,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAEpC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { bearerCredential } from './bearer-credential.js';
|
|
2
|
+
import { resolveSession } from './resolve-session.js';
|
|
3
|
+
/**
|
|
4
|
+
* The `resolvePrincipal` option of @ddd-ts-kit/http: takes the framework request, answers the
|
|
5
|
+
* session. The pipeline puts it, with its actor, in the execution context of the request;
|
|
6
|
+
* routes read `actorOf(context.principal)` and `sessionOf(context)`.
|
|
7
|
+
*/
|
|
8
|
+
export function principalResolver(authenticator) {
|
|
9
|
+
return (raw) => resolveSession(authenticator, bearerCredential(headersOf(raw)));
|
|
10
|
+
}
|
|
11
|
+
function headersOf(raw) {
|
|
12
|
+
if (typeof raw !== 'object' || raw === null || !('headers' in raw)) {
|
|
13
|
+
return {};
|
|
14
|
+
}
|
|
15
|
+
const { headers } = raw;
|
|
16
|
+
if (typeof headers !== 'object' || headers === null) {
|
|
17
|
+
return {};
|
|
18
|
+
}
|
|
19
|
+
return Object.fromEntries(Object.entries(headers).filter(isHeader));
|
|
20
|
+
}
|
|
21
|
+
function isHeader(entry) {
|
|
22
|
+
const [, value] = entry;
|
|
23
|
+
return typeof value === 'string' || (Array.isArray(value) && value.every((item) => typeof item === 'string'));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=principal-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"principal-resolver.js","sourceRoot":"","sources":["../../src/authentication/principal-resolver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAC/B,aAAmD;IAEnD,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,CAAC,aAAa,EAAE,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC;AAED,SAAS,SAAS,CAAC,GAAY;IAC7B,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,EAAE,CAAC;QACnE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;IAExB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACpD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAwB;IACxC,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;IAExB,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC;AAChH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Session } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import type { Authenticator } from './authenticator.js';
|
|
3
|
+
import type { SessionAuthenticator } from './session-authenticator.js';
|
|
4
|
+
/**
|
|
5
|
+
* The session of a credential, whatever the authenticator: its own when it is a
|
|
6
|
+
* `SessionAuthenticator`, otherwise one derived from the actor (see `sessionOf`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveSession(authenticator: Authenticator | SessionAuthenticator, credential: string | undefined): Promise<Session>;
|
|
9
|
+
//# sourceMappingURL=resolve-session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-session.d.ts","sourceRoot":"","sources":["../../src/authentication/resolve-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAGvE;;;GAGG;AACH,wBAAsB,cAAc,CAClC,aAAa,EAAE,aAAa,GAAG,oBAAoB,EACnD,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAAC,OAAO,CAAC,CAMlB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { sessionOf } from './session-of.js';
|
|
2
|
+
/**
|
|
3
|
+
* The session of a credential, whatever the authenticator: its own when it is a
|
|
4
|
+
* `SessionAuthenticator`, otherwise one derived from the actor (see `sessionOf`).
|
|
5
|
+
*/
|
|
6
|
+
export async function resolveSession(authenticator, credential) {
|
|
7
|
+
if ('authenticateSession' in authenticator) {
|
|
8
|
+
return authenticator.authenticateSession(credential);
|
|
9
|
+
}
|
|
10
|
+
return sessionOf(await authenticator.authenticate(credential));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=resolve-session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-session.js","sourceRoot":"","sources":["../../src/authentication/resolve-session.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,aAAmD,EACnD,UAA8B;IAE9B,IAAI,qBAAqB,IAAI,aAAa,EAAE,CAAC;QAC3C,OAAO,aAAa,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,SAAS,CAAC,MAAM,aAAa,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Session } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import { Authenticator } from './authenticator.js';
|
|
3
|
+
/**
|
|
4
|
+
* An authenticator that also knows the session the credential stands for: since when, until
|
|
5
|
+
* when, how it was authenticated, on whose behalf. Answers the anonymous session without
|
|
6
|
+
* credential. `resolveSession` works with either port, so an adapter implements this one only
|
|
7
|
+
* when its credential carries that knowledge.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class SessionAuthenticator extends Authenticator {
|
|
10
|
+
static readonly tokenKey = "auth.SessionAuthenticator";
|
|
11
|
+
abstract authenticateSession(credential: string | undefined): Promise<Session>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=session-authenticator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-authenticator.d.ts","sourceRoot":"","sources":["../../src/authentication/session-authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;GAKG;AACH,8BAAsB,oBAAqB,SAAQ,aAAa;IAC9D,gBAAyB,QAAQ,+BAA+B;IAEhE,QAAQ,CAAC,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAChF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Authenticator } from './authenticator.js';
|
|
2
|
+
/**
|
|
3
|
+
* An authenticator that also knows the session the credential stands for: since when, until
|
|
4
|
+
* when, how it was authenticated, on whose behalf. Answers the anonymous session without
|
|
5
|
+
* credential. `resolveSession` works with either port, so an adapter implements this one only
|
|
6
|
+
* when its credential carries that knowledge.
|
|
7
|
+
*/
|
|
8
|
+
export class SessionAuthenticator extends Authenticator {
|
|
9
|
+
static tokenKey = 'auth.SessionAuthenticator';
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=session-authenticator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-authenticator.js","sourceRoot":"","sources":["../../src/authentication/session-authenticator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,OAAgB,oBAAqB,SAAQ,aAAa;IAC9D,MAAM,CAAmB,QAAQ,GAAG,2BAA2B,CAAC;CAGjE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Session } from '@ddd-ts-kit/kernel';
|
|
2
|
+
/**
|
|
3
|
+
* The session a boundary received, anonymous when there is none. Takes the request context
|
|
4
|
+
* (`sessionOf(context)`), or a principal: a session is answered as it is, and an actor alone
|
|
5
|
+
* gets a session that says only what is known, its id as session id, no issue instant, no
|
|
6
|
+
* expiry, authenticated by `token`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sessionOf(source: unknown): Session;
|
|
9
|
+
//# sourceMappingURL=session-of.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-of.d.ts","sourceRoot":"","sources":["../../src/authentication/session-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAIjH;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAUlD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { anonymousSession, isActor, isAnonymous, isSession } from '@ddd-ts-kit/kernel';
|
|
2
|
+
const NEVER_ISSUED = new Date(0);
|
|
3
|
+
/**
|
|
4
|
+
* The session a boundary received, anonymous when there is none. Takes the request context
|
|
5
|
+
* (`sessionOf(context)`), or a principal: a session is answered as it is, and an actor alone
|
|
6
|
+
* gets a session that says only what is known, its id as session id, no issue instant, no
|
|
7
|
+
* expiry, authenticated by `token`.
|
|
8
|
+
*/
|
|
9
|
+
export function sessionOf(source) {
|
|
10
|
+
if (isSession(source)) {
|
|
11
|
+
return source;
|
|
12
|
+
}
|
|
13
|
+
if (isActor(source)) {
|
|
14
|
+
return sessionOfActor(source);
|
|
15
|
+
}
|
|
16
|
+
return hasPrincipal(source) ? sessionOf(source.principal) : anonymousSession();
|
|
17
|
+
}
|
|
18
|
+
function sessionOfActor(actor) {
|
|
19
|
+
if (isAnonymous(actor)) {
|
|
20
|
+
return anonymousSession();
|
|
21
|
+
}
|
|
22
|
+
return { id: actor.id, actor, issuedAt: NEVER_ISSUED, authenticationMethod: 'token', extensions: {} };
|
|
23
|
+
}
|
|
24
|
+
function hasPrincipal(source) {
|
|
25
|
+
return typeof source === 'object' && source !== null && 'principal' in source;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=session-of.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-of.js","sourceRoot":"","sources":["../../src/authentication/session-of.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAA4B,MAAM,oBAAoB,CAAC;AAEjH,MAAM,YAAY,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC;AAEjC;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAC,MAAe;IACvC,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACpB,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACjF,CAAC;AAED,SAAS,cAAc,CAAC,KAAY;IAClC,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,gBAAgB,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;AACxG,CAAC;AAED,SAAS,YAAY,CAAC,MAAe;IACnC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,IAAI,WAAW,IAAI,MAAM,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an actor may read of one resource type, in a form a read port turns into a `WHERE`
|
|
3
|
+
* clause. A list is filtered by the query, never in memory after loading.
|
|
4
|
+
*/
|
|
5
|
+
export type AccessScope = {
|
|
6
|
+
readonly kind: 'all';
|
|
7
|
+
} | {
|
|
8
|
+
readonly kind: 'none';
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'ids';
|
|
11
|
+
readonly ids: readonly string[];
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'filter';
|
|
14
|
+
readonly filter: Readonly<Record<string, string | number | boolean>>;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=access-scope.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-scope.d.ts","sourceRoot":"","sources":["../../src/authorization/access-scope.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,WAAW,GACnB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAA;CAAE,GACxB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-scope.js","sourceRoot":"","sources":["../../src/authorization/access-scope.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Actor } from '@ddd-ts-kit/kernel';
|
|
2
|
+
import type { Permission } from '../permissions/permission.js';
|
|
3
|
+
import type { AccessScope } from './access-scope.js';
|
|
4
|
+
import type { Decision } from './decision.js';
|
|
5
|
+
/**
|
|
6
|
+
* What a handler asks once it has loaded the element:
|
|
7
|
+
* `await this.access.authorize(command.actor, permissions.edit, article)`.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class Access {
|
|
10
|
+
static readonly tokenKey = "auth.Access";
|
|
11
|
+
/** Raises `ForbiddenError`, or `UnauthenticatedError` for the anonymous actor. */
|
|
12
|
+
abstract authorize(actor: Actor, permission: Permission, subject: unknown): Promise<void>;
|
|
13
|
+
abstract decide(actor: Actor, permission: Permission, subject: unknown): Promise<Decision>;
|
|
14
|
+
/** What the actor may list of one resource type, to hand to a read port. */
|
|
15
|
+
abstract scope(actor: Actor, permission: Permission, resourceType: string): Promise<AccessScope>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=access.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.d.ts","sourceRoot":"","sources":["../../src/authorization/access.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C;;;GAGG;AACH,8BAAsB,MAAM;IAC1B,MAAM,CAAC,QAAQ,CAAC,QAAQ,iBAAiB;IAEzC,kFAAkF;IAClF,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1F,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE3F,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CAClG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access.js","sourceRoot":"","sources":["../../src/authorization/access.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,OAAgB,MAAM;IAC1B,MAAM,CAAU,QAAQ,GAAG,aAAa,CAAC;CAS1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-context.d.ts","sourceRoot":"","sources":["../../src/authorization/authorization-context.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC"}
|