@toa.io/extensions.exposition 1.0.0-alpha.9 → 1.0.0-alpha.90
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/components/context.toa.yaml +2 -2
- package/components/identity.bans/manifest.toa.yaml +14 -6
- package/components/identity.bans/operations/transit.d.ts +14 -0
- package/components/identity.bans/operations/transit.js +11 -0
- package/components/identity.bans/operations/transit.js.map +1 -0
- package/components/identity.bans/operations/tsconfig.tsbuildinfo +1 -0
- package/components/identity.bans/source/transit.ts +21 -0
- package/components/identity.bans/tsconfig.json +9 -0
- package/components/identity.basic/manifest.toa.yaml +20 -10
- package/components/identity.basic/operations/authenticate.d.ts +5 -1
- package/components/identity.basic/operations/authenticate.js +5 -2
- package/components/identity.basic/operations/authenticate.js.map +1 -1
- package/components/identity.basic/operations/incept.d.ts +12 -0
- package/components/identity.basic/operations/incept.js +26 -0
- package/components/identity.basic/operations/incept.js.map +1 -0
- package/components/identity.basic/operations/transit.d.ts +4 -4
- package/components/identity.basic/operations/transit.js +8 -6
- package/components/identity.basic/operations/transit.js.map +1 -1
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/types.d.ts +8 -4
- package/components/identity.basic/source/authenticate.ts +16 -5
- package/components/identity.basic/source/incept.ts +38 -0
- package/components/identity.basic/source/transit.ts +11 -9
- package/components/identity.basic/source/types.ts +8 -4
- package/components/identity.federation/manifest.toa.yaml +32 -15
- package/components/identity.federation/operations/authenticate.d.ts +2 -2
- package/components/identity.federation/operations/authenticate.js +4 -11
- package/components/identity.federation/operations/authenticate.js.map +1 -1
- package/components/identity.federation/operations/incept.d.ts +11 -0
- package/components/identity.federation/operations/{create.js → incept.js} +6 -7
- package/components/identity.federation/operations/incept.js.map +1 -0
- package/components/identity.federation/operations/lib/assertions-as-values.js +4 -2
- package/components/identity.federation/operations/lib/assertions-as-values.js.map +1 -1
- package/components/identity.federation/operations/lib/jwt.d.ts +5 -5
- package/components/identity.federation/operations/lib/jwt.js +25 -12
- package/components/identity.federation/operations/lib/jwt.js.map +1 -1
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/types/configuration.d.ts +14 -0
- package/components/identity.federation/operations/types/configuration.js +3 -0
- package/components/identity.federation/operations/types/configuration.js.map +1 -0
- package/components/identity.federation/operations/{types.d.ts → types/context.d.ts} +15 -7
- package/components/identity.federation/operations/types/context.js +3 -0
- package/components/identity.federation/operations/types/context.js.map +1 -0
- package/components/identity.federation/operations/types/entity.d.ts +6 -0
- package/components/identity.federation/operations/types/entity.js +3 -0
- package/components/identity.federation/operations/types/entity.js.map +1 -0
- package/components/identity.federation/operations/types/index.d.ts +3 -0
- package/components/identity.federation/operations/types/index.js +20 -0
- package/components/identity.federation/operations/types/index.js.map +1 -0
- package/components/identity.federation/source/authenticate.ts +6 -19
- package/components/identity.federation/source/{create.ts → incept.ts} +10 -9
- package/components/identity.federation/source/lib/assertions-as-values.ts +5 -2
- package/components/identity.federation/source/lib/jwt.test.ts +123 -4
- package/components/identity.federation/source/lib/jwt.ts +36 -16
- package/components/identity.federation/source/types/configuration.ts +15 -0
- package/components/identity.federation/source/{types.ts → types/context.ts} +17 -6
- package/components/identity.federation/source/types/entity.ts +6 -0
- package/components/identity.federation/source/types/index.ts +3 -0
- package/components/identity.federation/tsconfig.json +5 -4
- package/components/identity.roles/manifest.toa.yaml +16 -6
- package/components/identity.roles/operations/grant.d.ts +10 -0
- package/components/identity.roles/operations/grant.js +21 -0
- package/components/identity.roles/operations/grant.js.map +1 -0
- package/components/identity.roles/operations/lib/Entity.d.ts +5 -0
- package/components/identity.roles/operations/lib/Entity.js +3 -0
- package/components/identity.roles/operations/lib/Entity.js.map +1 -0
- package/components/identity.roles/operations/list.d.ts +1 -4
- package/components/identity.roles/operations/list.js.map +1 -1
- package/components/identity.roles/operations/principal.d.ts +4 -6
- package/components/identity.roles/operations/principal.js +6 -1
- package/components/identity.roles/operations/principal.js.map +1 -1
- package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.roles/source/grant.ts +32 -0
- package/components/identity.roles/source/lib/Entity.ts +5 -0
- package/components/identity.roles/source/list.ts +2 -4
- package/components/identity.roles/source/principal.ts +10 -8
- package/components/identity.tokens/manifest.toa.yaml +19 -4
- package/components/identity.tokens/operations/authenticate.d.ts +2 -2
- package/components/identity.tokens/operations/authenticate.js +12 -5
- package/components/identity.tokens/operations/authenticate.js.map +1 -1
- package/components/identity.tokens/operations/decrypt.js +1 -0
- package/components/identity.tokens/operations/decrypt.js.map +1 -1
- package/components/identity.tokens/operations/encrypt.js +5 -1
- package/components/identity.tokens/operations/encrypt.js.map +1 -1
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/operations/types.d.ts +8 -2
- package/components/identity.tokens/receivers/identity.bans.created.js +3 -0
- package/components/identity.tokens/source/authenticate.test.ts +11 -4
- package/components/identity.tokens/source/authenticate.ts +14 -6
- package/components/identity.tokens/source/decrypt.test.ts +5 -3
- package/components/identity.tokens/source/decrypt.ts +9 -8
- package/components/identity.tokens/source/encrypt.test.ts +26 -2
- package/components/identity.tokens/source/encrypt.ts +5 -1
- package/components/identity.tokens/source/types.ts +9 -2
- package/components/octets.storage/manifest.toa.yaml +9 -11
- package/components/octets.storage/operations/get.js +3 -3
- package/components/octets.storage/operations/head.js +7 -0
- package/components/octets.storage/operations/put.js +121 -0
- package/documentation/access.md +75 -38
- package/documentation/authorities.md +49 -0
- package/documentation/cache.md +8 -1
- package/documentation/components.md +61 -22
- package/documentation/flow.md +31 -0
- package/documentation/identity.md +17 -22
- package/documentation/introspection.md +82 -0
- package/documentation/octets.md +95 -67
- package/documentation/protocol.md +13 -3
- package/documentation/query.md +29 -4
- package/documentation/require.md +15 -0
- package/documentation/tree.md +13 -0
- package/documentation/vary.md +14 -14
- package/features/access.feature +77 -46
- package/features/annotation.feature +1 -0
- package/features/auth.claim.feature +170 -0
- package/features/authorities.basic.feature +141 -0
- package/features/authorities.feature +32 -0
- package/features/authorities.federation.feature +100 -0
- package/features/authorities.tokens.feature +117 -0
- package/features/body.feature +2 -0
- package/features/cache.feature +109 -5
- package/features/cors.feature +6 -1
- package/features/debug.feature +34 -0
- package/features/directives.feature +3 -0
- package/features/dynamic.feature +48 -0
- package/features/errors.feature +32 -7
- package/features/etag.feature +108 -0
- package/features/flow.feature +45 -0
- package/features/identity.bans.feature +137 -0
- package/features/identity.basic.feature +97 -26
- package/features/identity.feature +18 -6
- package/features/identity.federation.feature +66 -11
- package/features/identity.roles.feature +250 -7
- package/features/identity.tokens.feature +54 -4
- package/features/introspection.feature +153 -0
- package/features/io.feature +38 -1
- package/features/methods.feature +47 -0
- package/features/{octets.meta.feature → octets.attributes.feature} +16 -12
- package/features/octets.cloudinary.feature +68 -0
- package/features/octets.download.feature +189 -0
- package/features/octets.entries.feature +13 -55
- package/features/octets.feature +83 -107
- package/features/octets.workflows.feature +242 -58
- package/features/probes.feature +14 -0
- package/features/{queries.feature → query.feature} +77 -2
- package/features/realtime.feature +34 -0
- package/features/require.feature +67 -0
- package/features/response.feature +38 -3
- package/features/routes.feature +93 -2
- package/features/server.feature +21 -0
- package/features/steps/.env.example +3 -0
- package/features/steps/Database.ts +16 -9
- package/features/steps/Gateway.ts +23 -6
- package/features/steps/IdP.ts +30 -25
- package/features/steps/Parameters.ts +45 -3
- package/features/steps/Realtime.ts +151 -0
- package/features/steps/components/echo/manifest.toa.yaml +14 -1
- package/features/steps/components/echo/operations/identity.js +7 -0
- package/features/steps/components/echo/operations/parameters.js +7 -0
- package/features/steps/components/echo.beacon/manifest.toa.yaml +2 -0
- package/features/steps/components/echo.beacon/operations/hello.js +5 -0
- package/features/steps/components/octets.tester/manifest.toa.yaml +22 -2
- package/features/steps/components/octets.tester/operations/authority.js +7 -0
- package/features/steps/components/octets.tester/operations/bar.js +0 -1
- package/features/steps/components/octets.tester/operations/baz.js +0 -2
- package/features/steps/components/octets.tester/operations/foo.js +1 -2
- package/features/steps/components/octets.tester/operations/redirect.js +12 -0
- package/features/steps/components/octets.tester/operations/yex.js +16 -0
- package/features/steps/components/octets.tester/operations/yield.js +13 -0
- package/features/steps/components/pots/manifest.toa.yaml +14 -3
- package/features/steps/components/users/manifest.toa.yaml +0 -1
- package/features/steps/components/users.properties/manifest.toa.yaml +1 -1
- package/features/streams.feature +5 -0
- package/features/timing.feature +4 -1
- package/features/vary.feature +71 -0
- package/package.json +23 -14
- package/readme.md +19 -14
- package/schemas/annotation.cos.yaml +1 -1
- package/schemas/method.cos.yaml +1 -1
- package/schemas/node.cos.yaml +2 -0
- package/schemas/octets/put.cos.yaml +25 -0
- package/schemas/query.cos.yaml +4 -10
- package/source/Annotation.ts +3 -3
- package/source/Branch.ts +1 -0
- package/source/Composition.ts +0 -6
- package/source/Context.ts +1 -0
- package/source/Directive.ts +4 -5
- package/source/Endpoint.ts +59 -17
- package/source/Factory.ts +22 -13
- package/source/Gateway.ts +64 -17
- package/source/HTTP/Context.ts +25 -2
- package/source/HTTP/Server.ts +57 -43
- package/source/HTTP/exceptions.ts +13 -1
- package/source/HTTP/formats/index.ts +3 -3
- package/source/HTTP/messages.test.ts +45 -2
- package/source/HTTP/messages.ts +29 -5
- package/source/Introspection.ts +11 -0
- package/source/Mapping.ts +68 -21
- package/source/Query.test.ts +3 -3
- package/source/Query.ts +123 -33
- package/source/RTD/Context.ts +1 -1
- package/source/RTD/Endpoint.ts +3 -0
- package/source/RTD/Method.ts +16 -0
- package/source/RTD/Node.ts +29 -13
- package/source/RTD/Route.ts +5 -4
- package/source/RTD/Tree.ts +2 -2
- package/source/RTD/factory.ts +5 -2
- package/source/RTD/syntax/parse.test.ts +1 -1
- package/source/RTD/syntax/parse.ts +37 -24
- package/source/RTD/syntax/types.ts +6 -4
- package/source/Remotes.ts +7 -6
- package/source/Tenant.ts +6 -20
- package/source/deployment.ts +33 -23
- package/source/directives/auth/Authorization.ts +44 -21
- package/source/directives/auth/Delegate.ts +42 -0
- package/source/directives/auth/Echo.ts +19 -5
- package/source/directives/auth/Federation.ts +84 -0
- package/source/directives/auth/Incept.ts +4 -3
- package/source/directives/auth/Role.test.ts +53 -6
- package/source/directives/auth/Role.ts +22 -14
- package/source/directives/auth/Scheme.ts +1 -1
- package/source/directives/auth/split.ts +1 -1
- package/source/directives/auth/types.ts +2 -2
- package/source/directives/cache/Cache.ts +13 -6
- package/source/directives/cache/Control.ts +42 -16
- package/source/directives/cors/CORS.ts +1 -1
- package/source/directives/dev/Development.ts +1 -1
- package/source/directives/flow/Fetch.ts +88 -0
- package/source/directives/flow/Flow.ts +34 -0
- package/source/directives/flow/index.ts +3 -0
- package/source/directives/flow/types.ts +6 -0
- package/source/directives/index.ts +3 -1
- package/source/directives/io/Input.ts +4 -4
- package/source/directives/io/Output.ts +5 -4
- package/source/directives/octets/Context.ts +3 -2
- package/source/directives/octets/Delete.ts +11 -11
- package/source/directives/octets/Get.ts +84 -0
- package/source/directives/octets/Octets.ts +7 -11
- package/source/directives/octets/{Store.ts → Put.ts} +36 -21
- package/source/directives/octets/Workflow.ts +1 -1
- package/source/directives/octets/bytes.test.ts +30 -0
- package/source/directives/octets/bytes.ts +18 -0
- package/source/directives/octets/schemas.ts +4 -8
- package/source/directives/octets/workflows/Execution.ts +60 -8
- package/source/directives/octets/workflows/Workflow.ts +4 -4
- package/source/directives/require/Directive.ts +5 -0
- package/source/directives/require/Headers.ts +20 -0
- package/source/directives/require/Require.ts +28 -0
- package/source/directives/require/index.ts +3 -0
- package/source/directives/vary/Directive.ts +2 -1
- package/source/directives/vary/Embed.ts +14 -8
- package/source/directives/vary/Vary.ts +6 -4
- package/source/directives/vary/embeddings/Authority.ts +8 -0
- package/source/directives/vary/embeddings/Embedding.ts +2 -1
- package/source/directives/vary/embeddings/Language.ts +2 -2
- package/source/directives/vary/embeddings/Parameter.ts +14 -0
- package/source/directives/vary/embeddings/index.ts +6 -4
- package/source/exceptions.ts +17 -11
- package/source/manifest.ts +10 -11
- package/source/root.ts +5 -5
- package/source/schemas.ts +1 -1
- package/transpiled/Annotation.d.ts +3 -3
- package/transpiled/Branch.d.ts +1 -0
- package/transpiled/Composition.d.ts +0 -1
- package/transpiled/Composition.js +0 -4
- package/transpiled/Composition.js.map +1 -1
- package/transpiled/Context.d.ts +1 -0
- package/transpiled/Directive.js +4 -4
- package/transpiled/Directive.js.map +1 -1
- package/transpiled/Endpoint.d.ts +6 -4
- package/transpiled/Endpoint.js +39 -9
- package/transpiled/Endpoint.js.map +1 -1
- package/transpiled/Factory.d.ts +3 -2
- package/transpiled/Factory.js +18 -10
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Gateway.d.ts +3 -0
- package/transpiled/Gateway.js +49 -10
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Context.d.ts +8 -1
- package/transpiled/HTTP/Context.js +16 -2
- package/transpiled/HTTP/Context.js.map +1 -1
- package/transpiled/HTTP/Server.d.ts +13 -2
- package/transpiled/HTTP/Server.js +43 -36
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/exceptions.d.ts +7 -1
- package/transpiled/HTTP/exceptions.js +13 -1
- package/transpiled/HTTP/exceptions.js.map +1 -1
- package/transpiled/HTTP/formats/index.js +3 -3
- package/transpiled/HTTP/formats/index.js.map +1 -1
- package/transpiled/HTTP/messages.d.ts +1 -0
- package/transpiled/HTTP/messages.js +28 -5
- package/transpiled/HTTP/messages.js.map +1 -1
- package/transpiled/Introspection.d.ts +9 -0
- package/transpiled/Introspection.js +3 -0
- package/transpiled/Introspection.js.map +1 -0
- package/transpiled/Mapping.d.ts +11 -2
- package/transpiled/Mapping.js +50 -19
- package/transpiled/Mapping.js.map +1 -1
- package/transpiled/Query.d.ts +10 -1
- package/transpiled/Query.js +87 -30
- package/transpiled/Query.js.map +1 -1
- package/transpiled/RTD/Context.d.ts +1 -1
- package/transpiled/RTD/Endpoint.d.ts +1 -0
- package/transpiled/RTD/Method.d.ts +4 -0
- package/transpiled/RTD/Method.js +11 -0
- package/transpiled/RTD/Method.js.map +1 -1
- package/transpiled/RTD/Node.d.ts +4 -1
- package/transpiled/RTD/Node.js +23 -12
- package/transpiled/RTD/Node.js.map +1 -1
- package/transpiled/RTD/Route.d.ts +1 -1
- package/transpiled/RTD/Route.js +0 -1
- package/transpiled/RTD/Route.js.map +1 -1
- package/transpiled/RTD/Tree.d.ts +1 -1
- package/transpiled/RTD/Tree.js.map +1 -1
- package/transpiled/RTD/factory.js +5 -2
- package/transpiled/RTD/factory.js.map +1 -1
- package/transpiled/RTD/syntax/parse.js +34 -22
- package/transpiled/RTD/syntax/parse.js.map +1 -1
- package/transpiled/RTD/syntax/types.d.ts +5 -3
- package/transpiled/RTD/syntax/types.js +1 -1
- package/transpiled/RTD/syntax/types.js.map +1 -1
- package/transpiled/Remotes.d.ts +4 -4
- package/transpiled/Remotes.js +6 -5
- package/transpiled/Remotes.js.map +1 -1
- package/transpiled/Tenant.d.ts +5 -5
- package/transpiled/Tenant.js +2 -13
- package/transpiled/Tenant.js.map +1 -1
- package/transpiled/deployment.d.ts +1 -1
- package/transpiled/deployment.js +28 -20
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/directives/auth/Authorization.d.ts +1 -1
- package/transpiled/directives/auth/Authorization.js +32 -18
- package/transpiled/directives/auth/Authorization.js.map +1 -1
- package/transpiled/directives/auth/Delegate.d.ts +10 -0
- package/transpiled/directives/auth/Delegate.js +34 -0
- package/transpiled/directives/auth/Delegate.js.map +1 -0
- package/transpiled/directives/auth/Echo.d.ts +4 -3
- package/transpiled/directives/auth/Echo.js +13 -3
- package/transpiled/directives/auth/Echo.js.map +1 -1
- package/transpiled/directives/auth/Federation.d.ts +16 -0
- package/transpiled/directives/auth/Federation.js +57 -0
- package/transpiled/directives/auth/Federation.js.map +1 -0
- package/transpiled/directives/auth/Incept.js +4 -3
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/directives/auth/Role.d.ts +4 -1
- package/transpiled/directives/auth/Role.js +20 -14
- package/transpiled/directives/auth/Role.js.map +1 -1
- package/transpiled/directives/auth/Scheme.js +1 -1
- package/transpiled/directives/auth/Scheme.js.map +1 -1
- package/transpiled/directives/auth/split.js +1 -1
- package/transpiled/directives/auth/split.js.map +1 -1
- package/transpiled/directives/auth/types.d.ts +1 -1
- package/transpiled/directives/cache/Cache.d.ts +3 -3
- package/transpiled/directives/cache/Cache.js +10 -4
- package/transpiled/directives/cache/Cache.js.map +1 -1
- package/transpiled/directives/cache/Control.d.ts +2 -1
- package/transpiled/directives/cache/Control.js +29 -12
- package/transpiled/directives/cache/Control.js.map +1 -1
- package/transpiled/directives/cors/CORS.js +1 -1
- package/transpiled/directives/cors/CORS.js.map +1 -1
- package/transpiled/directives/dev/Development.js +1 -1
- package/transpiled/directives/dev/Development.js.map +1 -1
- package/transpiled/directives/flow/Fetch.d.ts +13 -0
- package/transpiled/directives/flow/Fetch.js +59 -0
- package/transpiled/directives/flow/Fetch.js.map +1 -0
- package/transpiled/directives/flow/Flow.d.ts +10 -0
- package/transpiled/directives/flow/Flow.js +27 -0
- package/transpiled/directives/flow/Flow.js.map +1 -0
- package/transpiled/directives/flow/index.d.ts +2 -0
- package/transpiled/directives/flow/index.js +6 -0
- package/transpiled/directives/flow/index.js.map +1 -0
- package/transpiled/directives/flow/types.d.ts +5 -0
- package/transpiled/directives/flow/types.js.map +1 -0
- package/transpiled/directives/index.js +3 -1
- package/transpiled/directives/index.js.map +1 -1
- package/transpiled/directives/io/Input.js +2 -2
- package/transpiled/directives/io/Input.js.map +1 -1
- package/transpiled/directives/io/Output.js +2 -2
- package/transpiled/directives/io/Output.js.map +1 -1
- package/transpiled/directives/octets/Context.js +4 -24
- package/transpiled/directives/octets/Context.js.map +1 -1
- package/transpiled/directives/octets/Delete.js +8 -8
- package/transpiled/directives/octets/Delete.js.map +1 -1
- package/transpiled/directives/octets/{Fetch.d.ts → Get.d.ts} +5 -6
- package/transpiled/directives/octets/{Fetch.js → Get.js} +24 -29
- package/transpiled/directives/octets/Get.js.map +1 -0
- package/transpiled/directives/octets/Octets.js +7 -11
- package/transpiled/directives/octets/Octets.js.map +1 -1
- package/transpiled/directives/octets/{Store.d.ts → Put.d.ts} +7 -2
- package/transpiled/directives/octets/{Store.js → Put.js} +26 -19
- package/transpiled/directives/octets/Put.js.map +1 -0
- package/transpiled/directives/octets/Workflow.js +1 -1
- package/transpiled/directives/octets/Workflow.js.map +1 -1
- package/transpiled/directives/octets/bytes.d.ts +1 -0
- package/transpiled/directives/octets/bytes.js +21 -0
- package/transpiled/directives/octets/bytes.js.map +1 -0
- package/transpiled/directives/octets/schemas.d.ts +4 -8
- package/transpiled/directives/octets/schemas.js +3 -6
- package/transpiled/directives/octets/schemas.js.map +1 -1
- package/transpiled/directives/octets/workflows/Execution.d.ts +5 -1
- package/transpiled/directives/octets/workflows/Execution.js +44 -9
- package/transpiled/directives/octets/workflows/Execution.js.map +1 -1
- package/transpiled/directives/octets/workflows/Workflow.d.ts +1 -1
- package/transpiled/directives/octets/workflows/Workflow.js +2 -1
- package/transpiled/directives/octets/workflows/Workflow.js.map +1 -1
- package/transpiled/directives/require/Directive.d.ts +4 -0
- package/transpiled/directives/require/Directive.js +3 -0
- package/transpiled/directives/require/Directive.js.map +1 -0
- package/transpiled/directives/require/Headers.d.ts +7 -0
- package/transpiled/directives/require/Headers.js +19 -0
- package/transpiled/directives/require/Headers.js.map +1 -0
- package/transpiled/directives/require/Require.d.ts +9 -0
- package/transpiled/directives/require/Require.js +27 -0
- package/transpiled/directives/require/Require.js.map +1 -0
- package/transpiled/directives/require/index.d.ts +2 -0
- package/transpiled/directives/require/index.js +6 -0
- package/transpiled/directives/require/index.js.map +1 -0
- package/transpiled/directives/vary/Directive.d.ts +2 -1
- package/transpiled/directives/vary/Embed.d.ts +2 -1
- package/transpiled/directives/vary/Embed.js +8 -6
- package/transpiled/directives/vary/Embed.js.map +1 -1
- package/transpiled/directives/vary/Vary.d.ts +2 -2
- package/transpiled/directives/vary/Vary.js +3 -3
- package/transpiled/directives/vary/Vary.js.map +1 -1
- package/transpiled/directives/vary/embeddings/Authority.d.ts +5 -0
- package/transpiled/directives/vary/embeddings/Authority.js +10 -0
- package/transpiled/directives/vary/embeddings/Authority.js.map +1 -0
- package/transpiled/directives/vary/embeddings/Embedding.d.ts +2 -1
- package/transpiled/directives/vary/embeddings/Language.js +2 -2
- package/transpiled/directives/vary/embeddings/Language.js.map +1 -1
- package/transpiled/directives/vary/embeddings/Parameter.d.ts +7 -0
- package/transpiled/directives/vary/embeddings/Parameter.js +14 -0
- package/transpiled/directives/vary/embeddings/Parameter.js.map +1 -0
- package/transpiled/directives/vary/embeddings/index.d.ts +2 -2
- package/transpiled/directives/vary/embeddings/index.js +8 -4
- package/transpiled/directives/vary/embeddings/index.js.map +1 -1
- package/transpiled/exceptions.d.ts +3 -2
- package/transpiled/exceptions.js +10 -5
- package/transpiled/exceptions.js.map +1 -1
- package/transpiled/manifest.js +10 -11
- package/transpiled/manifest.js.map +1 -1
- package/transpiled/root.js +5 -5
- package/transpiled/root.js.map +1 -1
- package/transpiled/schemas.d.ts +1 -1
- package/transpiled/schemas.js +2 -2
- package/transpiled/schemas.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
- package/tsconfig.json +8 -2
- package/components/identity.basic/operations/create.d.ts +0 -10
- package/components/identity.basic/operations/create.js +0 -10
- package/components/identity.basic/operations/create.js.map +0 -1
- package/components/identity.basic/source/create.ts +0 -18
- package/components/identity.federation/operations/create.d.ts +0 -10
- package/components/identity.federation/operations/create.js.map +0 -1
- package/components/identity.federation/operations/schemas.d.ts +0 -59
- package/components/identity.federation/operations/schemas.js +0 -9
- package/components/identity.federation/operations/schemas.js.map +0 -1
- package/components/identity.federation/operations/types.js.map +0 -1
- package/components/identity.federation/source/schemas.ts +0 -61
- package/components/octets.storage/operations/fetch.js +0 -46
- package/components/octets.storage/operations/list.js +0 -7
- package/components/octets.storage/operations/permute.js +0 -7
- package/components/octets.storage/operations/store.js +0 -11
- package/features/steps/components/octets.tester/operations/diversify.js +0 -14
- package/schemas/octets/context.cos.yaml +0 -1
- package/schemas/octets/fetch.cos.yaml +0 -3
- package/schemas/octets/permute.cos.yaml +0 -1
- package/schemas/octets/store.cos.yaml +0 -3
- package/source/HTTP/Server.test.ts +0 -126
- package/source/directives/octets/Fetch.ts +0 -100
- package/source/directives/octets/List.ts +0 -72
- package/source/directives/octets/Permute.ts +0 -44
- package/transpiled/directives/octets/Fetch.js.map +0 -1
- package/transpiled/directives/octets/List.d.ts +0 -16
- package/transpiled/directives/octets/List.js +0 -74
- package/transpiled/directives/octets/List.js.map +0 -1
- package/transpiled/directives/octets/Permute.d.ts +0 -11
- package/transpiled/directives/octets/Permute.js +0 -58
- package/transpiled/directives/octets/Permute.js.map +0 -1
- package/transpiled/directives/octets/Store.js.map +0 -1
- /package/schemas/octets/{list.cos.yaml → get.cos.yaml} +0 -0
- /package/{components/identity.federation/operations → transpiled/directives/flow}/types.js +0 -0
|
@@ -36,8 +36,10 @@ const Role_1 = require("./Role");
|
|
|
36
36
|
const Rule_1 = require("./Rule");
|
|
37
37
|
const Incept_1 = require("./Incept");
|
|
38
38
|
const Echo_1 = require("./Echo");
|
|
39
|
-
const split_1 = require("./split");
|
|
40
39
|
const Scheme_1 = require("./Scheme");
|
|
40
|
+
const Delegate_1 = require("./Delegate");
|
|
41
|
+
const Federation_1 = require("./Federation");
|
|
42
|
+
const split_1 = require("./split");
|
|
41
43
|
const schemes_1 = require("./schemes");
|
|
42
44
|
class Authorization {
|
|
43
45
|
depends = ['Vary'];
|
|
@@ -48,29 +50,35 @@ class Authorization {
|
|
|
48
50
|
tokens = null;
|
|
49
51
|
bans = null;
|
|
50
52
|
create(name, value, remotes) {
|
|
51
|
-
node_assert_1.default.ok(name in constructors, `Directive '
|
|
53
|
+
node_assert_1.default.ok(name in constructors, `Directive 'auth:${name}' is not implemented.`);
|
|
52
54
|
const Class = constructors[name];
|
|
53
55
|
for (const name of REMOTES)
|
|
54
56
|
this.discovery[name] ??= remotes.discover('identity', name);
|
|
55
|
-
return (0, matchacho_1.match)(Class, Role_1.Role, () => new Role_1.Role(value, this.discovery.roles), Rule_1.Rule, () => new Rule_1.Rule(value, this.create.bind(this)), Incept_1.Incept, () => new Incept_1.Incept(value, this.discovery), () => new Class(value));
|
|
57
|
+
return (0, matchacho_1.match)(Class, Role_1.Role, () => new Role_1.Role(value, this.discovery.roles), Rule_1.Rule, () => new Rule_1.Rule(value, this.create.bind(this)), Incept_1.Incept, () => new Incept_1.Incept(value, this.discovery), Delegate_1.Delegate, () => new Delegate_1.Delegate(value, this.discovery.roles), () => new Class(value));
|
|
56
58
|
}
|
|
57
59
|
async preflight(directives, input, parameters) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Some authentication scheme providers may create identity during authentication;
|
|
62
|
+
* therefore, we need to skip the authentication process if the Incept directive is present.
|
|
63
|
+
*
|
|
64
|
+
* If the provided credentials already exist,
|
|
65
|
+
* the inception will cause a unique constraint violation on the settle stage.
|
|
66
|
+
*/
|
|
67
|
+
const inception = directives.reduce((yes, directive) => yes || directive instanceof Incept_1.Incept, false);
|
|
68
|
+
input.identity = inception ? null : await this.resolve(input.authority, input.request.headers.authorization);
|
|
60
69
|
for (const directive of directives) {
|
|
61
|
-
const allow = await directive.authorize(identity, input, parameters);
|
|
70
|
+
const allow = await directive.authorize(input.identity, input, parameters);
|
|
62
71
|
if (allow)
|
|
63
|
-
return directive.reply?.(identity) ?? null;
|
|
72
|
+
return directive.reply?.(input.identity) ?? null;
|
|
64
73
|
}
|
|
65
|
-
if (identity === null)
|
|
74
|
+
if (input.identity === null)
|
|
66
75
|
throw new http.Unauthorized();
|
|
67
76
|
else
|
|
68
77
|
throw new http.Forbidden();
|
|
69
78
|
}
|
|
70
|
-
async settle(directives,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const identity = request.identity;
|
|
79
|
+
async settle(directives, input, response) {
|
|
80
|
+
await Promise.all(directives.map(async (directive) => directive.settle?.(input, response)));
|
|
81
|
+
const identity = input.identity;
|
|
74
82
|
if (identity === null)
|
|
75
83
|
return;
|
|
76
84
|
if (identity.scheme === schemes_1.PRIMARY && !identity.refresh)
|
|
@@ -79,13 +87,14 @@ class Authorization {
|
|
|
79
87
|
if (identity.roles === undefined)
|
|
80
88
|
await Role_1.Role.set(identity, this.discovery.roles);
|
|
81
89
|
this.tokens ??= await this.discovery.tokens;
|
|
82
|
-
const token = await this.tokens.invoke('encrypt', {
|
|
90
|
+
const token = await this.tokens.invoke('encrypt', {
|
|
91
|
+
input: { authority: input.authority, identity }
|
|
92
|
+
});
|
|
83
93
|
const authorization = `Token ${token}`;
|
|
84
|
-
|
|
85
|
-
response.headers = new Headers();
|
|
94
|
+
response.headers ??= new Headers();
|
|
86
95
|
response.headers.set('authorization', authorization);
|
|
87
96
|
}
|
|
88
|
-
async resolve(authorization) {
|
|
97
|
+
async resolve(authority, authorization) {
|
|
89
98
|
if (authorization === undefined)
|
|
90
99
|
return null;
|
|
91
100
|
const [scheme, credentials] = (0, split_1.split)(authorization);
|
|
@@ -94,7 +103,10 @@ class Authorization {
|
|
|
94
103
|
throw new http.Unauthorized(`Unknown authentication scheme '${scheme}'.`);
|
|
95
104
|
this.schemes[scheme] ??= await this.discovery[provider];
|
|
96
105
|
const result = await this.schemes[scheme].invoke('authenticate', {
|
|
97
|
-
input:
|
|
106
|
+
input: {
|
|
107
|
+
authority,
|
|
108
|
+
credentials
|
|
109
|
+
}
|
|
98
110
|
});
|
|
99
111
|
if (result instanceof Error)
|
|
100
112
|
return null;
|
|
@@ -119,7 +131,9 @@ const constructors = {
|
|
|
119
131
|
rule: Rule_1.Rule,
|
|
120
132
|
incept: Incept_1.Incept,
|
|
121
133
|
scheme: Scheme_1.Scheme,
|
|
122
|
-
echo: Echo_1.Echo
|
|
134
|
+
echo: Echo_1.Echo,
|
|
135
|
+
delegate: Delegate_1.Delegate,
|
|
136
|
+
claim: Federation_1.Federation
|
|
123
137
|
};
|
|
124
138
|
const REMOTES = ['basic', 'federation', 'tokens', 'roles', 'bans'];
|
|
125
139
|
//# sourceMappingURL=Authorization.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Authorization.js","sourceRoot":"","sources":["../../../source/directives/auth/Authorization.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgC;AAChC,yCAAiC;AACjC,iDAAkC;AAClC,2CAAuC;AACvC,6BAAyB;AACzB,iCAA6B;AAC7B,iCAA6B;AAC7B,qCAAiC;AACjC,iCAA6B;AAC7B,mCAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"Authorization.js","sourceRoot":"","sources":["../../../source/directives/auth/Authorization.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgC;AAChC,yCAAiC;AACjC,iDAAkC;AAClC,2CAAuC;AACvC,6BAAyB;AACzB,iCAA6B;AAC7B,iCAA6B;AAC7B,qCAAiC;AACjC,iCAA6B;AAC7B,qCAAiC;AACjC,yCAAqC;AACrC,6CAAyC;AACzC,mCAA+B;AAC/B,uCAA8C;AAiB9C,MAAa,aAAa;IACR,OAAO,GAAa,CAAC,MAAM,CAAC,CAAA;IAC5B,IAAI,GAAW,MAAM,CAAA;IACrB,SAAS,GAAY,IAAI,CAAA;IAExB,OAAO,GAAG,EAAwB,CAAA;IAClC,SAAS,GAAG,EAA0B,CAAA;IAC/C,MAAM,GAAqB,IAAI,CAAA;IAC/B,IAAI,GAAqB,IAAI,CAAA;IAE9B,MAAM,CAAE,IAAY,EAAE,KAAU,EAAE,OAAgB;QACvD,qBAAM,CAAC,EAAE,CAAC,IAAI,IAAI,YAAY,EAC5B,mBAAmB,IAAI,uBAAuB,CAAC,CAAA;QAEjD,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QAEhC,KAAK,MAAM,IAAI,IAAI,OAAO;YACxB,IAAI,CAAC,SAAS,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EAAE,EAAE,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;QAElF,OAAO,GAAG,CAAC,MAAM,CAAA;IACnB,CAAC;CACF;AA3HD,sCA2HC;AAED,MAAM,YAAY,GAAkE;IAClF,SAAS,EAAE,qBAAS;IACpB,EAAE,EAAE,OAAE;IACN,IAAI,EAAE,WAAI;IACV,IAAI,EAAE,WAAI;IACV,MAAM,EAAE,eAAM;IACd,MAAM,EAAE,eAAM;IACd,IAAI,EAAE,WAAI;IACV,QAAQ,EAAE,mBAAQ;IAClB,KAAK,EAAE,uBAAU;CAClB,CAAA;AAED,MAAM,OAAO,GAAa,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Directive, type Identity } from './types';
|
|
2
|
+
import type { Component } from '@toa.io/core';
|
|
3
|
+
import type { Input } from '../../io';
|
|
4
|
+
export declare class Delegate implements Directive {
|
|
5
|
+
private readonly property;
|
|
6
|
+
private readonly discovery;
|
|
7
|
+
constructor(property: string, discovery: Promise<Component>);
|
|
8
|
+
authorize(identity: Identity | null, context: Input): Promise<boolean>;
|
|
9
|
+
private embed;
|
|
10
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Delegate = void 0;
|
|
4
|
+
const HTTP_1 = require("../../HTTP");
|
|
5
|
+
const Role_1 = require("./Role");
|
|
6
|
+
class Delegate {
|
|
7
|
+
property;
|
|
8
|
+
discovery;
|
|
9
|
+
constructor(property, discovery) {
|
|
10
|
+
this.property = property;
|
|
11
|
+
this.discovery = discovery;
|
|
12
|
+
}
|
|
13
|
+
async authorize(identity, context) {
|
|
14
|
+
if (identity === null)
|
|
15
|
+
return false;
|
|
16
|
+
if (identity.roles === undefined)
|
|
17
|
+
await Role_1.Role.set(identity, this.discovery);
|
|
18
|
+
context.pipelines.body.push((body) => this.embed(body, identity));
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
embed(body, identity) {
|
|
22
|
+
if (body === undefined)
|
|
23
|
+
body = {};
|
|
24
|
+
check(body);
|
|
25
|
+
body[this.property] = structuredClone(identity);
|
|
26
|
+
return body;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.Delegate = Delegate;
|
|
30
|
+
function check(body) {
|
|
31
|
+
if (typeof body !== 'object' || body === null)
|
|
32
|
+
throw new HTTP_1.BadRequest('Invalid request body');
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=Delegate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Delegate.js","sourceRoot":"","sources":["../../../source/directives/auth/Delegate.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,iCAA6B;AAI7B,MAAa,QAAQ;IACF,QAAQ,CAAQ;IAChB,SAAS,CAAoB;IAE9C,YAAoB,QAAgB,EAAE,SAA6B;QACjE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,QAAyB,EAAE,OAAc;QAC/D,IAAI,QAAQ,KAAK,IAAI;YACnB,OAAO,KAAK,CAAA;QAEd,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS;YAC9B,MAAM,WAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;QAE1C,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;QAEjE,OAAO,IAAI,CAAA;IACb,CAAC;IAEO,KAAK,CAAE,IAAa,EAAE,QAAkB;QAC9C,IAAI,IAAI,KAAK,SAAS;YACpB,IAAI,GAAG,EAAE,CAAA;QAEX,KAAK,CAAC,IAAI,CAAC,CAAA;QACX,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;QAE/C,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AA9BD,4BA8BC;AAED,SAAS,KAAK,CAAE,IAAa;IAC3B,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAC3C,MAAM,IAAI,iBAAU,CAAC,sBAAsB,CAAC,CAAA;AAChD,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { OutgoingMessage } from '../../HTTP';
|
|
2
|
+
import type { Directive, Identity, Input } from './types';
|
|
3
3
|
export declare class Echo implements Directive {
|
|
4
|
-
authorize(identity: Identity | null): boolean;
|
|
4
|
+
authorize(identity: Identity | null, input: Input): boolean;
|
|
5
5
|
reply(identity: Identity | null): OutgoingMessage;
|
|
6
|
+
private create;
|
|
6
7
|
}
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Echo = void 0;
|
|
4
|
+
const generic_1 = require("@toa.io/generic");
|
|
4
5
|
class Echo {
|
|
5
|
-
authorize(identity) {
|
|
6
|
-
|
|
6
|
+
authorize(identity, input) {
|
|
7
|
+
if (identity === null && 'authorization' in input.request.headers)
|
|
8
|
+
return false;
|
|
9
|
+
input.identity ??= this.create();
|
|
10
|
+
return true;
|
|
7
11
|
}
|
|
8
12
|
reply(identity) {
|
|
9
|
-
|
|
13
|
+
const body = identity;
|
|
14
|
+
return body.scheme === null
|
|
15
|
+
? { status: 201, body }
|
|
16
|
+
: { body };
|
|
17
|
+
}
|
|
18
|
+
create() {
|
|
19
|
+
return { id: (0, generic_1.newid)(), scheme: null, refresh: false, roles: [] };
|
|
10
20
|
}
|
|
11
21
|
}
|
|
12
22
|
exports.Echo = Echo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Echo.js","sourceRoot":"","sources":["../../../source/directives/auth/Echo.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Echo.js","sourceRoot":"","sources":["../../../source/directives/auth/Echo.ts"],"names":[],"mappings":";;;AAAA,6CAAuC;AAIvC,MAAa,IAAI;IACR,SAAS,CAAE,QAAyB,EAAE,KAAY;QACvD,IAAI,QAAQ,KAAK,IAAI,IAAI,eAAe,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO;YAC/D,OAAO,KAAK,CAAA;QAEd,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC,MAAM,EAAE,CAAA;QAEhC,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK,CAAE,QAAyB;QACrC,MAAM,IAAI,GAAG,QAAS,CAAA;QAEtB,OAAO,IAAI,CAAC,MAAM,KAAK,IAAI;YACzB,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE;YACvB,CAAC,CAAC,EAAE,IAAI,EAAE,CAAA;IACd,CAAC;IAEO,MAAM;QACZ,OAAO,EAAE,EAAE,EAAE,IAAA,eAAK,GAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;IACjE,CAAC;CACF;AArBD,oBAqBC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Directive, Identity, Input } from './types';
|
|
2
|
+
import type { Parameter } from '../../RTD';
|
|
3
|
+
export declare class Federation implements Directive {
|
|
4
|
+
private readonly matchers;
|
|
5
|
+
constructor(options: Options);
|
|
6
|
+
authorize(identity: Identity | null, context: Input, parameters: Parameter[]): boolean;
|
|
7
|
+
}
|
|
8
|
+
interface Claim {
|
|
9
|
+
iss: string;
|
|
10
|
+
sub: string;
|
|
11
|
+
aud: string | string[];
|
|
12
|
+
}
|
|
13
|
+
interface Options extends Partial<Claim> {
|
|
14
|
+
iss: string;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Federation = void 0;
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
class Federation {
|
|
9
|
+
matchers;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.matchers = Object.entries(options)
|
|
12
|
+
.map(([key, value]) => [key, toMatcher(value)]);
|
|
13
|
+
node_assert_1.default.ok(this.matchers.length > 0, 'auth:claim requires at least one property defined');
|
|
14
|
+
}
|
|
15
|
+
authorize(identity, context, parameters) {
|
|
16
|
+
if (identity === null || !('claim' in identity))
|
|
17
|
+
return false;
|
|
18
|
+
const claim = identity.claim;
|
|
19
|
+
for (const [key, match] of this.matchers)
|
|
20
|
+
if (!match(claim[key], context, parameters))
|
|
21
|
+
return false;
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.Federation = Federation;
|
|
26
|
+
function toMatcher(expression) {
|
|
27
|
+
if (expression.startsWith(':')) {
|
|
28
|
+
const key = expression.slice(1);
|
|
29
|
+
if (key === 'authority')
|
|
30
|
+
return (value, context) => matches(value, context[key]);
|
|
31
|
+
if (key === 'domain')
|
|
32
|
+
return (value, context) => {
|
|
33
|
+
return Array.isArray(value)
|
|
34
|
+
? value.some((iss) => codomain(iss, context))
|
|
35
|
+
: codomain(value, context);
|
|
36
|
+
};
|
|
37
|
+
throw new Error(`Unknown 'auth:claim' syntax: ${expression}`);
|
|
38
|
+
}
|
|
39
|
+
if (expression.startsWith('/:')) {
|
|
40
|
+
const name = expression.slice(2);
|
|
41
|
+
return (value, _, parameters) => parameters
|
|
42
|
+
.some((parameter) => parameter.name === name && matches(value, parameter.value));
|
|
43
|
+
}
|
|
44
|
+
return (value) => matches(value, expression);
|
|
45
|
+
}
|
|
46
|
+
function matches(value, reference) {
|
|
47
|
+
return Array.isArray(value)
|
|
48
|
+
? value.includes(reference)
|
|
49
|
+
: value === reference;
|
|
50
|
+
}
|
|
51
|
+
function codomain(iss, context) {
|
|
52
|
+
const hostname = new URL(iss).hostname;
|
|
53
|
+
const dot = hostname.indexOf('.');
|
|
54
|
+
const basename = dot === -1 ? hostname : hostname.slice(dot);
|
|
55
|
+
return context.authority.slice(-basename.length) === basename;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=Federation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Federation.js","sourceRoot":"","sources":["../../../source/directives/auth/Federation.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAIhC,MAAa,UAAU;IACJ,QAAQ,CAA+B;IAExD,YAAoB,OAAgB;QAClC,IAAI,CAAC,QAAQ,GAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAkC;aACtE,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAEjD,qBAAM,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,mDAAmD,CAAC,CAAA;IAC1F,CAAC;IAEM,SAAS,CAAE,QAAyB,EAAE,OAAc,EAAE,UAAuB;QAClF,IAAI,QAAQ,KAAK,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,QAAQ,CAAC;YAC7C,OAAO,KAAK,CAAA;QAEd,MAAM,KAAK,GAAI,QAA8B,CAAC,KAAK,CAAA;QAEnD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ;YACtC,IAAI,CA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,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,OAAO,CAAE,KAAwB,EAAE,SAAiB;IAC3D,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACzB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC3B,CAAC,CAAC,KAAK,KAAK,SAAS,CAAA;AACzB,CAAC;AAED,SAAS,QAAQ,CAAE,GAAW,EAAE,OAAc;IAC5C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAA;IACtC,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC,MAAM,QAAQ,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IAE5D,OAAO,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAA;AAC/D,CAAC"}
|
|
@@ -42,19 +42,20 @@ class Incept {
|
|
|
42
42
|
const id = response.body?.[this.property];
|
|
43
43
|
if (id === undefined)
|
|
44
44
|
throw new http.Conflict('Identity inception has failed as the response body ' +
|
|
45
|
-
`
|
|
45
|
+
`does not contain the '${this.property}' property.`);
|
|
46
46
|
const [scheme, credentials] = (0, split_1.split)(input.request.headers.authorization);
|
|
47
47
|
const provider = schemes_1.PROVIDERS[scheme];
|
|
48
48
|
this.schemes[scheme] ??= await this.discovery[provider];
|
|
49
49
|
const identity = await this.schemes[scheme]
|
|
50
|
-
.invoke('
|
|
50
|
+
.invoke('incept', {
|
|
51
51
|
input: {
|
|
52
|
+
authority: input.authority,
|
|
52
53
|
id,
|
|
53
54
|
credentials
|
|
54
55
|
}
|
|
55
56
|
});
|
|
56
57
|
if (identity instanceof Error)
|
|
57
|
-
throw new http.
|
|
58
|
+
throw new http.UnprocessableEntity(identity);
|
|
58
59
|
input.identity = identity;
|
|
59
60
|
input.identity.scheme = scheme;
|
|
60
61
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Incept.js","sourceRoot":"","sources":["../../../source/directives/auth/Incept.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAkC;AAElC,mCAA+B;AAC/B,uCAAqC;AAErC,MAAa,MAAM;IACA,QAAQ,CAAQ;IAChB,SAAS,CAAW;IACpB,OAAO,GAAY,EAAwB,CAAA;IAE5D,YAAoB,QAAgB,EAAE,SAAoB;QACxD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAEM,SAAS,CAAE,QAAyB,EAAE,KAAY;QACvD,OAAO,QAAQ,KAAK,IAAI,IAAI,eAAe,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAA;IACtE,CAAC;IAEM,KAAK,CAAC,MAAM,CAAE,KAAY,EAAE,QAA8B;QAC/D,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEzC,IAAI,EAAE,KAAK,SAAS;YAClB,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,qDAAqD;gBAC3E,
|
|
1
|
+
{"version":3,"file":"Incept.js","sourceRoot":"","sources":["../../../source/directives/auth/Incept.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,iDAAkC;AAElC,mCAA+B;AAC/B,uCAAqC;AAErC,MAAa,MAAM;IACA,QAAQ,CAAQ;IAChB,SAAS,CAAW;IACpB,OAAO,GAAY,EAAwB,CAAA;IAE5D,YAAoB,QAAgB,EAAE,SAAoB;QACxD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,SAAS,G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identity } from './types';
|
|
3
|
+
import type { Parameter } from '../../RTD';
|
|
3
4
|
export declare class Role implements Directive {
|
|
4
5
|
static remote: Component | null;
|
|
5
6
|
private readonly roles;
|
|
6
7
|
private readonly discovery;
|
|
8
|
+
private readonly dynamic;
|
|
7
9
|
constructor(roles: string | string[], discovery: Promise<Component>);
|
|
8
10
|
static set(identity: Identity, discovery: Promise<Component>): Promise<void>;
|
|
9
|
-
authorize(identity: Identity | null): Promise<boolean>;
|
|
11
|
+
authorize(identity: Identity | null, _: unknown, parameters: Parameter[]): Promise<boolean>;
|
|
10
12
|
private match;
|
|
13
|
+
private substitute;
|
|
11
14
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.Role = void 0;
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
4
8
|
class Role {
|
|
5
9
|
static remote = null;
|
|
6
10
|
roles;
|
|
7
11
|
discovery;
|
|
12
|
+
dynamic;
|
|
8
13
|
constructor(roles, discovery) {
|
|
9
14
|
this.roles = typeof roles === 'string' ? [roles] : roles;
|
|
10
15
|
this.discovery = discovery;
|
|
16
|
+
this.dynamic = this.roles.some((role) => role.includes('{'));
|
|
11
17
|
}
|
|
12
18
|
static async set(identity, discovery) {
|
|
13
19
|
this.remote ??= await discovery;
|
|
@@ -17,30 +23,30 @@ class Role {
|
|
|
17
23
|
};
|
|
18
24
|
identity.roles = await this.remote.invoke('list', { query });
|
|
19
25
|
}
|
|
20
|
-
async authorize(identity) {
|
|
26
|
+
async authorize(identity, _, parameters) {
|
|
21
27
|
if (identity === null)
|
|
22
28
|
return false;
|
|
23
29
|
await Role.set(identity, this.discovery);
|
|
24
|
-
if (identity.roles ===
|
|
30
|
+
if (identity.roles.length === 0) // Role.set()
|
|
25
31
|
return false;
|
|
26
|
-
return this.match(identity.roles);
|
|
32
|
+
return this.match(identity.roles, parameters);
|
|
27
33
|
}
|
|
28
|
-
match(roles) {
|
|
34
|
+
match(roles, parameters) {
|
|
35
|
+
const required = this.dynamic ? this.substitute(parameters) : this.roles;
|
|
29
36
|
for (const role of roles) {
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
37
|
+
const ok = required.some((expected) => expected === role || expected.startsWith(role + ':'));
|
|
38
|
+
if (ok)
|
|
32
39
|
return true;
|
|
33
40
|
}
|
|
34
41
|
return false;
|
|
35
42
|
}
|
|
43
|
+
substitute(parameters) {
|
|
44
|
+
return this.roles.map((role) => role.replaceAll(/{(\w+)}/g, (_, key) => {
|
|
45
|
+
const value = parameters.find((parameter) => parameter.name === key)?.value;
|
|
46
|
+
node_assert_1.default.ok(value !== undefined, `Role '${role}' requires '${key}' route parameter.`);
|
|
47
|
+
return value;
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
36
50
|
}
|
|
37
51
|
exports.Role = Role;
|
|
38
|
-
function compare(expected, actual) {
|
|
39
|
-
const exp = expected.split(':');
|
|
40
|
-
const act = actual.split(':');
|
|
41
|
-
for (let i = 0; i < act.length; i++)
|
|
42
|
-
if (exp[i] !== act[i])
|
|
43
|
-
return false;
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
52
|
//# sourceMappingURL=Role.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Role.js","sourceRoot":"","sources":["../../../source/directives/auth/Role.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Role.js","sourceRoot":"","sources":["../../../source/directives/auth/Role.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAKhC,MAAa,IAAI;IACR,MAAM,CAAC,MAAM,GAAqB,IAAI,CAAA;IAC5B,KAAK,CAAU;IACf,SAAS,CAAoB;IAC7B,OAAO,CAAS;IAEjC,YAAoB,KAAwB,EAAE,SAA6B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A;QAExE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC,CAAA;YAE5F,IAAI,EAAE;gBACJ,OAAO,IAAI,CAAA;QACf,CAAC;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,UAAU,CAAE,UAAuB;QACzC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;YACrE,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,CAAA;YAE3E,qBAAM,CAAC,EAAE,CAAC,KAAK,KAAK,SAAS,EAC3B,SAAS,IAAI,eAAe,GAAG,oBAAoB,CAAC,CAAA;YAEtD,OAAO,KAAK,CAAA;QACd,CAAC,CAAC,CAAC,CAAA;IACL,CAAC;;AA3DH,oBA4DC"}
|
|
@@ -39,7 +39,7 @@ class Scheme {
|
|
|
39
39
|
const [scheme] = (0, split_1.split)(input.request.headers.authorization);
|
|
40
40
|
if (scheme !== this.scheme)
|
|
41
41
|
throw new http.Forbidden(this.Scheme +
|
|
42
|
-
' authentication scheme is required to access this resource
|
|
42
|
+
' authentication scheme is required to access this resource');
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheme.js","sourceRoot":"","sources":["../../../source/directives/auth/Scheme.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkC;AAElC,mCAA+B;AAE/B,MAAa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AAC,aAAa,CAAC,CAAA;QAE3D,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM;YACxB,MAAM,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM;gBAClC,4DAA4D,CAAC,CAAA;QAEjE,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AArBD,wBAqBC"}
|
|
@@ -28,7 +28,7 @@ const http = __importStar(require("../../HTTP"));
|
|
|
28
28
|
function split(authorization) {
|
|
29
29
|
const space = authorization.indexOf(' ');
|
|
30
30
|
if (space === -1)
|
|
31
|
-
throw new http.Unauthorized('Malformed authorization header
|
|
31
|
+
throw new http.Unauthorized('Malformed authorization header');
|
|
32
32
|
const Scheme = authorization.slice(0, space);
|
|
33
33
|
const scheme = Scheme.toLowerCase();
|
|
34
34
|
const value = authorization.slice(space + 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../../source/directives/auth/split.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkC;AAGlC,SAAgB,KAAK,CAAE,aAAqB;IAC1C,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAExC,IAAI,KAAK,KAAK,CAAC,CAAC;QACd,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"split.js","sourceRoot":"","sources":["../../../source/directives/auth/split.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAkC;AAGlC,SAAgB,KAAK,CAAE,aAAqB;IAC1C,MAAM,KAAK,GAAG,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;IAExC,IAAI,KAAK,KAAK,CAAC,CAAC;QACd,MAAM,IAAI,IAAI,CAAC,YAAY,CAAC,gCAAgC,CAAC,CAAA;IAE/D,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,EAAY,CAAA;IAC7C,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;IAE5C,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AACxB,CAAC;AAXD,sBAWC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Directive } from './types';
|
|
1
|
+
import type { Output } from '../../io';
|
|
2
|
+
import type { AuthenticatedContext, Directive } from './types';
|
|
3
3
|
import type { DirectiveFamily } from '../../RTD';
|
|
4
4
|
import type * as http from '../../HTTP';
|
|
5
5
|
export declare class Cache implements DirectiveFamily<Directive> {
|
|
@@ -7,5 +7,5 @@ export declare class Cache implements DirectiveFamily<Directive> {
|
|
|
7
7
|
readonly mandatory: boolean;
|
|
8
8
|
create(name: string, value: any): Directive;
|
|
9
9
|
preflight(): Output;
|
|
10
|
-
settle(directives: Directive[],
|
|
10
|
+
settle(directives: Directive[], context: AuthenticatedContext, response: http.OutgoingMessage): Promise<void>;
|
|
11
11
|
}
|
|
@@ -5,19 +5,25 @@ const Control_1 = require("./Control");
|
|
|
5
5
|
const Exact_1 = require("./Exact");
|
|
6
6
|
class Cache {
|
|
7
7
|
name = 'cache';
|
|
8
|
-
mandatory =
|
|
8
|
+
mandatory = true;
|
|
9
9
|
create(name, value) {
|
|
10
10
|
const Class = constructors[name];
|
|
11
11
|
if (Class === undefined)
|
|
12
|
-
throw new Error(`Directive '
|
|
12
|
+
throw new Error(`Directive 'cache:${name}' is not implemented.`);
|
|
13
13
|
return new Class(value);
|
|
14
14
|
}
|
|
15
15
|
preflight() {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
async settle(directives,
|
|
18
|
+
async settle(directives, context, response) {
|
|
19
|
+
const directive = directives[0];
|
|
19
20
|
response.headers ??= new Headers();
|
|
20
|
-
|
|
21
|
+
if (directive === undefined) {
|
|
22
|
+
if (context.identity !== null && !Control_1.Control.disabled(response.headers))
|
|
23
|
+
response.headers.set('cache-control', 'private');
|
|
24
|
+
}
|
|
25
|
+
else
|
|
26
|
+
directive.set(context, response.headers);
|
|
21
27
|
}
|
|
22
28
|
}
|
|
23
29
|
exports.Cache = Cache;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../source/directives/cache/Cache.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,mCAA+B;AAM/B,MAAa,KAAK;IACA,IAAI,GAAW,OAAO,CAAA;IACtB,SAAS,GAAY,
|
|
1
|
+
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../../source/directives/cache/Cache.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,mCAA+B;AAM/B,MAAa,KAAK;IACA,IAAI,GAAW,OAAO,CAAA;IACtB,SAAS,GAAY,IAAI,CAAA;IAElC,MAAM,CAAE,IAAY,EAAE,KAAU;QACrC,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;QAEhC,IAAI,KAAK,KAAK,SAAS;YACrB,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,uBAAuB,CAAC,CAAA;QAElE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;IACzB,CAAC;IAEM,SAAS;QACd,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,KAAK,CAAC,MAAM,CAClB,UAAuB,EAAE,OAA6B,EAAE,QAA8B;QACrF,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;QAE/B,QAAQ,CAAC,OAAO,KAAK,IAAI,OAAO,EAAE,CAAA;QAElC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,IAAI,OAAO,CAAC,QAAQ,KAAK,IAAI,IAAI,CAAC,iBAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAClE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,SAAS,CAAC,CAAA;QACpD,CAAC;;YACC,SAAS,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAC5C,CAAC;CACF;AA7BD,sBA6BC;AAED,MAAM,YAAY,GAAkD;IAClE,OAAO,EAAE,iBAAO;IAChB,KAAK,EAAE,aAAK;CACb,CAAA"}
|
|
@@ -2,8 +2,9 @@ import type { AuthenticatedContext, Directive } from './types';
|
|
|
2
2
|
export declare class Control implements Directive {
|
|
3
3
|
protected readonly value: string;
|
|
4
4
|
private cache;
|
|
5
|
+
private vary;
|
|
5
6
|
constructor(value: string);
|
|
7
|
+
static disabled(headers: Headers): boolean;
|
|
6
8
|
set(context: AuthenticatedContext, headers: Headers): void;
|
|
7
9
|
protected resolve(request: AuthenticatedContext): string;
|
|
8
|
-
private mask;
|
|
9
10
|
}
|
|
@@ -5,38 +5,55 @@ const matchacho_1 = require("matchacho");
|
|
|
5
5
|
class Control {
|
|
6
6
|
value;
|
|
7
7
|
cache = null;
|
|
8
|
+
vary = false;
|
|
8
9
|
constructor(value) {
|
|
9
10
|
this.value = value;
|
|
10
11
|
}
|
|
12
|
+
static disabled(headers) {
|
|
13
|
+
const value = headers.get('cache-control');
|
|
14
|
+
if (value === null)
|
|
15
|
+
return false;
|
|
16
|
+
const directives = mask(value);
|
|
17
|
+
return (directives & NO_STORE) === NO_STORE;
|
|
18
|
+
}
|
|
11
19
|
set(context, headers) {
|
|
12
20
|
if (!['GET', 'HEAD', 'OPTIONS'].includes(context.request.method))
|
|
13
21
|
return;
|
|
14
22
|
this.cache ??= this.resolve(context);
|
|
23
|
+
if (Control.disabled(headers))
|
|
24
|
+
return;
|
|
15
25
|
headers.set('cache-control', this.cache);
|
|
26
|
+
if (this.vary !== null)
|
|
27
|
+
headers.append('vary', 'authorization');
|
|
16
28
|
}
|
|
17
29
|
resolve(request) {
|
|
18
30
|
if (request.identity === null)
|
|
19
31
|
return this.value;
|
|
20
|
-
const directives = this.
|
|
32
|
+
const directives = mask(this.value);
|
|
33
|
+
if ((directives & PRIVATE) === PRIVATE)
|
|
34
|
+
this.vary = true;
|
|
21
35
|
if ((directives & (PUBLIC | NO_CACHE)) === PUBLIC)
|
|
22
36
|
return 'no-cache, ' + this.value;
|
|
23
|
-
if ((directives & (PUBLIC | PRIVATE)) === 0)
|
|
37
|
+
if ((directives & (PUBLIC | PRIVATE)) === 0) {
|
|
38
|
+
this.vary = true;
|
|
24
39
|
return 'private, ' + this.value;
|
|
40
|
+
}
|
|
25
41
|
return this.value;
|
|
26
42
|
}
|
|
27
|
-
mask() {
|
|
28
|
-
const directives = this.value.match(DIRECTIVES_RX);
|
|
29
|
-
if (directives === null)
|
|
30
|
-
return 0;
|
|
31
|
-
let mask = 0;
|
|
32
|
-
for (const directive of directives)
|
|
33
|
-
mask |= (0, matchacho_1.match)(directive, 'private', PRIVATE, 'public', PUBLIC, 'no-cache', NO_CACHE, 0);
|
|
34
|
-
return mask;
|
|
35
|
-
}
|
|
36
43
|
}
|
|
37
44
|
exports.Control = Control;
|
|
38
|
-
|
|
45
|
+
function mask(value) {
|
|
46
|
+
const directives = value.match(DIRECTIVES_RX);
|
|
47
|
+
if (directives === null)
|
|
48
|
+
return 0;
|
|
49
|
+
let mask = 0;
|
|
50
|
+
for (const directive of directives)
|
|
51
|
+
mask |= (0, matchacho_1.match)(directive, 'private', PRIVATE, 'public', PUBLIC, 'no-cache', NO_CACHE, 'no-store', NO_STORE, 0);
|
|
52
|
+
return mask;
|
|
53
|
+
}
|
|
54
|
+
const DIRECTIVES_RX = /\b(private|public|no-cache|no-store)\b/ig;
|
|
39
55
|
const PUBLIC = 1;
|
|
40
56
|
const PRIVATE = 2;
|
|
41
57
|
const NO_CACHE = 4;
|
|
58
|
+
const NO_STORE = 8;
|
|
42
59
|
//# sourceMappingURL=Control.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Control.js","sourceRoot":"","sources":["../../../source/directives/cache/Control.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,MAAa,OAAO;IACC,KAAK,CAAQ;IACxB,KAAK,GAAkB,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"Control.js","sourceRoot":"","sources":["../../../source/directives/cache/Control.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,MAAa,OAAO;IACC,KAAK,CAAQ;IACxB,KAAK,GAAkB,IAAI,CAAA;IAC3B,IAAI,GAAY,KAAK,CAAA;IAE7B,YAAoB,KAAa;QAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAEM,MAAM,CAAC,QAAQ,CAAE,OAAgB;QACtC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;QAE1C,IAAI,KAAK,KAAK,IAAI;YAChB,OAAO,KAAK,CAAA;QAEd,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAA;QAE9B,OAAO,CAAC,UAAU,GAAG,QAAQ,CAAC,KAAK,QAAQ,CAAA;IAC7C,CAAC;IAEM,GAAG,CAAE,OAA6B,EAAE,OAAgB;QACzD,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;YAC9D,OAAM;QAER,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAEpC,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;YAC3B,OAAM;QAER,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;QAExC,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YACpB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;IAC3C,CAAC;IAES,OAAO,CAAE,OAA6B;QAC9C,IAAI,OAAO,CAAC,QAAQ,KAAK,I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