@webiny/api-core 0.0.0-unstable.9f53ea597d → 0.0.0-unstable.a85ef555b2
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/ApiCoreFeature.d.ts +2 -2
- package/ApiCoreFeature.js +35 -5
- package/ApiCoreFeature.js.map +1 -1
- package/exports/api/tasks.d.ts +1 -0
- package/exports/api/tasks.js +1 -1
- package/exports/api.d.ts +2 -1
- package/exports/api.js +2 -1
- package/features/ai/Ai.d.ts +3 -1
- package/features/ai/Ai.js +36 -28
- package/features/ai/Ai.js.map +1 -1
- package/features/ai/AiModelRegistry.d.ts +14 -0
- package/features/ai/AiModelRegistry.js +39 -0
- package/features/ai/AiModelRegistry.js.map +1 -0
- package/features/ai/AiSdkToolHandlerResolver.d.ts +11 -0
- package/features/ai/AiSdkToolHandlerResolver.js +19 -0
- package/features/ai/AiSdkToolHandlerResolver.js.map +1 -0
- package/features/ai/AiSdkTools.d.ts +4 -3
- package/features/ai/AiSdkTools.js +11 -9
- package/features/ai/AiSdkTools.js.map +1 -1
- package/features/ai/AnthropicSdkFactory.js +24 -4
- package/features/ai/AnthropicSdkFactory.js.map +1 -1
- package/features/ai/DEVELOPERS.md +183 -0
- package/features/ai/GoogleSdkFactory.d.ts +10 -0
- package/features/ai/GoogleSdkFactory.js +65 -0
- package/features/ai/GoogleSdkFactory.js.map +1 -0
- package/features/ai/OpenAiSdkFactory.js +67 -11
- package/features/ai/OpenAiSdkFactory.js.map +1 -1
- package/features/ai/OpenRouterSdkFactory.d.ts +10 -0
- package/features/ai/OpenRouterSdkFactory.js +112 -0
- package/features/ai/OpenRouterSdkFactory.js.map +1 -0
- package/features/ai/RemoteAiModelCatalog.d.ts +13 -0
- package/features/ai/RemoteAiModelCatalog.js +74 -0
- package/features/ai/RemoteAiModelCatalog.js.map +1 -0
- package/features/ai/abstractions.d.ts +102 -7
- package/features/ai/abstractions.js +6 -2
- package/features/ai/abstractions.js.map +1 -1
- package/features/ai/feature.js +10 -0
- package/features/ai/feature.js.map +1 -1
- package/features/ai/index.d.ts +2 -4
- package/features/ai/index.js +1 -1
- package/features/dateFormatter/DefaultDateFormatter.d.ts +15 -0
- package/features/dateFormatter/DefaultDateFormatter.js +20 -0
- package/features/dateFormatter/DefaultDateFormatter.js.map +1 -0
- package/features/dateFormatter/abstractions.d.ts +13 -0
- package/features/dateFormatter/abstractions.js +5 -0
- package/features/dateFormatter/abstractions.js.map +1 -0
- package/features/dateFormatter/feature.d.ts +4 -0
- package/features/dateFormatter/feature.js +11 -0
- package/features/dateFormatter/feature.js.map +1 -0
- package/features/dateFormatter/index.d.ts +3 -0
- package/features/dateFormatter/index.js +2 -0
- package/features/debugger/Debugger.d.ts +30 -0
- package/features/debugger/Debugger.js +142 -0
- package/features/debugger/Debugger.js.map +1 -0
- package/features/debugger/DebuggerRouteDecorator.d.ts +45 -0
- package/features/debugger/DebuggerRouteDecorator.js +107 -0
- package/features/debugger/DebuggerRouteDecorator.js.map +1 -0
- package/features/debugger/GraphQLDebuggerTransport.d.ts +28 -0
- package/features/debugger/GraphQLDebuggerTransport.js +45 -0
- package/features/debugger/GraphQLDebuggerTransport.js.map +1 -0
- package/features/debugger/__tests__/matchNamespace.test.d.ts +1 -0
- package/features/debugger/__tests__/matchNamespace.test.js +68 -0
- package/features/debugger/__tests__/matchNamespace.test.js.map +1 -0
- package/features/debugger/__tests__/serialize.test.d.ts +1 -0
- package/features/debugger/__tests__/serialize.test.js +220 -0
- package/features/debugger/__tests__/serialize.test.js.map +1 -0
- package/features/debugger/abstractions.d.ts +100 -0
- package/features/debugger/abstractions.js +6 -0
- package/features/debugger/abstractions.js.map +1 -0
- package/features/debugger/feature.d.ts +5 -0
- package/features/debugger/feature.js +15 -0
- package/features/debugger/feature.js.map +1 -0
- package/features/debugger/index.d.ts +12 -0
- package/features/debugger/index.js +7 -0
- package/features/debugger/limits.d.ts +18 -0
- package/features/debugger/limits.js +11 -0
- package/features/debugger/limits.js.map +1 -0
- package/features/debugger/matchNamespace.d.ts +14 -0
- package/features/debugger/matchNamespace.js +35 -0
- package/features/debugger/matchNamespace.js.map +1 -0
- package/features/debugger/parseNamespaceHeader.d.ts +7 -0
- package/features/debugger/parseNamespaceHeader.js +16 -0
- package/features/debugger/parseNamespaceHeader.js.map +1 -0
- package/features/debugger/permissions.d.ts +14 -0
- package/features/debugger/permissions.js +8 -0
- package/features/debugger/permissions.js.map +1 -0
- package/features/debugger/permissionsSchema.d.ts +17 -0
- package/features/debugger/permissionsSchema.js +18 -0
- package/features/debugger/permissionsSchema.js.map +1 -0
- package/features/debugger/serialize.d.ts +11 -0
- package/features/debugger/serialize.js +121 -0
- package/features/debugger/serialize.js.map +1 -0
- package/features/encryption/EncryptionKeyCacheFeature.d.ts +8 -0
- package/features/encryption/EncryptionKeyCacheFeature.js +11 -0
- package/features/encryption/EncryptionKeyCacheFeature.js.map +1 -0
- package/features/encryption/EncryptionService.d.ts +2 -1
- package/features/encryption/EncryptionService.js +11 -4
- package/features/encryption/EncryptionService.js.map +1 -1
- package/features/encryption/MemoryEncryptionKeyCache.d.ts +13 -0
- package/features/encryption/MemoryEncryptionKeyCache.js +26 -0
- package/features/encryption/MemoryEncryptionKeyCache.js.map +1 -0
- package/features/encryption/abstractions.d.ts +11 -0
- package/features/encryption/abstractions.js +2 -1
- package/features/encryption/abstractions.js.map +1 -1
- package/features/encryption/index.d.ts +1 -0
- package/features/encryption/index.js +1 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.d.ts +13 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js +62 -0
- package/features/featureFlags/decorators/FeatureFlagsWithLicenseDecorator.js.map +1 -0
- package/features/hashing/ScryptHasher.d.ts +11 -0
- package/features/hashing/ScryptHasher.js +74 -0
- package/features/hashing/ScryptHasher.js.map +1 -0
- package/features/hashing/abstractions.d.ts +18 -0
- package/features/hashing/abstractions.js +5 -0
- package/features/hashing/abstractions.js.map +1 -0
- package/features/hashing/feature.d.ts +4 -0
- package/features/hashing/feature.js +11 -0
- package/features/hashing/feature.js.map +1 -0
- package/features/hashing/index.d.ts +2 -0
- package/features/hashing/index.js +1 -0
- package/features/httpClient/HttpClient.d.ts +7 -0
- package/features/httpClient/HttpClient.js +72 -0
- package/features/httpClient/HttpClient.js.map +1 -0
- package/features/httpClient/HttpRequestError.d.ts +10 -0
- package/features/httpClient/HttpRequestError.js +13 -0
- package/features/httpClient/HttpRequestError.js.map +1 -0
- package/features/httpClient/HttpStatusError.d.ts +12 -0
- package/features/httpClient/HttpStatusError.js +12 -0
- package/features/httpClient/HttpStatusError.js.map +1 -0
- package/features/httpClient/abstractions.d.ts +32 -0
- package/features/httpClient/abstractions.js +5 -0
- package/features/httpClient/abstractions.js.map +1 -0
- package/features/httpClient/feature.d.ts +4 -0
- package/features/httpClient/feature.js +11 -0
- package/features/httpClient/feature.js.map +1 -0
- package/features/httpClient/index.d.ts +3 -0
- package/features/httpClient/index.js +3 -0
- package/features/keyValueStore/GlobalKeyValueStore.d.ts +9 -3
- package/features/keyValueStore/GlobalKeyValueStore.js +12 -2
- package/features/keyValueStore/GlobalKeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStore.d.ts +6 -2
- package/features/keyValueStore/KeyValueStore.js +13 -3
- package/features/keyValueStore/KeyValueStore.js.map +1 -1
- package/features/keyValueStore/KeyValueStoreRepository.d.ts +8 -2
- package/features/keyValueStore/KeyValueStoreRepository.js +82 -4
- package/features/keyValueStore/KeyValueStoreRepository.js.map +1 -1
- package/features/keyValueStore/abstractions.d.ts +132 -14
- package/features/keyValueStore/abstractions.js.map +1 -1
- package/features/keyValueStore/errors.d.ts +29 -0
- package/features/keyValueStore/errors.js +49 -1
- package/features/keyValueStore/errors.js.map +1 -1
- package/features/keyValueStore/index.d.ts +4 -1
- package/features/keyValueStore/index.js +1 -1
- package/features/publicUrls/NullPublicUrls.d.ts +11 -0
- package/features/publicUrls/NullPublicUrls.js +17 -0
- package/features/publicUrls/NullPublicUrls.js.map +1 -0
- package/features/publicUrls/PublicUrl.d.ts +24 -0
- package/features/publicUrls/PublicUrl.js +43 -0
- package/features/publicUrls/PublicUrl.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js +38 -0
- package/features/publicUrls/__tests__/PublicUrl.test.js.map +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.d.ts +1 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js +14 -0
- package/features/publicUrls/__tests__/PublicUrls.test.js.map +1 -0
- package/features/publicUrls/abstractions.d.ts +27 -0
- package/features/publicUrls/abstractions.js +5 -0
- package/features/publicUrls/abstractions.js.map +1 -0
- package/features/publicUrls/feature.d.ts +8 -0
- package/features/publicUrls/feature.js +11 -0
- package/features/publicUrls/feature.js.map +1 -0
- package/features/publicUrls/index.d.ts +3 -0
- package/features/publicUrls/index.js +3 -0
- package/features/requestContext/RawAssumePermissions.d.ts +14 -0
- package/features/requestContext/RawAssumePermissions.js +19 -0
- package/features/requestContext/RawAssumePermissions.js.map +1 -0
- package/features/requestContext/RawAuthToken.d.ts +14 -0
- package/features/requestContext/RawAuthToken.js +19 -0
- package/features/requestContext/RawAuthToken.js.map +1 -0
- package/features/requestContext/RawTenantId.d.ts +14 -0
- package/features/requestContext/RawTenantId.js +19 -0
- package/features/requestContext/RawTenantId.js.map +1 -0
- package/features/requestContext/RequestIdentityLoader.d.ts +19 -0
- package/features/requestContext/RequestIdentityLoader.js +26 -0
- package/features/requestContext/RequestIdentityLoader.js.map +1 -0
- package/features/requestContext/RequestTenantLoader.d.ts +18 -0
- package/features/requestContext/RequestTenantLoader.js +52 -0
- package/features/requestContext/RequestTenantLoader.js.map +1 -0
- package/features/requestContext/abstractions.d.ts +75 -0
- package/features/requestContext/abstractions.js +9 -0
- package/features/requestContext/abstractions.js.map +1 -0
- package/features/requestContext/extractAssumePermissions.d.ts +14 -0
- package/features/requestContext/extractAssumePermissions.js +32 -0
- package/features/requestContext/extractAssumePermissions.js.map +1 -0
- package/features/requestContext/feature.d.ts +12 -0
- package/features/requestContext/feature.js +19 -0
- package/features/requestContext/feature.js.map +1 -0
- package/features/requestContext/index.d.ts +4 -0
- package/features/requestContext/index.js +3 -0
- package/features/security/IdentityContext/IdentityContext.d.ts +4 -3
- package/features/security/IdentityContext/IdentityContext.js +9 -6
- package/features/security/IdentityContext/IdentityContext.js.map +1 -1
- package/features/security/IdentityContext/abstractions.d.ts +5 -0
- package/features/security/IdentityContext/abstractions.js.map +1 -1
- package/features/security/apiKeys/ApiKeyAuthenticator.d.ts +14 -0
- package/features/security/apiKeys/ApiKeyAuthenticator.js +36 -0
- package/features/security/apiKeys/ApiKeyAuthenticator.js.map +1 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.d.ts +10 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js +15 -0
- package/features/security/apiKeys/ApiKeyAuthorizer.js.map +1 -0
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js +11 -6
- package/features/security/apiKeys/CreateApiKey/CreateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/GetApiKeyBySlug/GetApiKeyBySlugUseCase.d.ts +1 -1
- package/features/security/apiKeys/GetApiKeyByToken/GetApiKeyByTokenUseCase.d.ts +1 -1
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js +9 -3
- package/features/security/apiKeys/UpdateApiKey/UpdateApiKeyUseCase.js.map +1 -1
- package/features/security/apiKeys/feature.js +4 -0
- package/features/security/apiKeys/feature.js.map +1 -1
- package/features/security/apiKeys/shared/schemas.d.ts +2 -2
- package/features/security/apiKeys/shared/schemas.js +2 -2
- package/features/security/apiKeys/shared/schemas.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.d.ts +12 -3
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js +31 -18
- package/features/security/authorization/AuthorizationContext/AuthorizationContext.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/abstractions.d.ts +2 -0
- package/features/security/authorization/AuthorizationContext/abstractions.js.map +1 -1
- package/features/security/authorization/AuthorizationContext/feature.js +6 -1
- package/features/security/authorization/AuthorizationContext/feature.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.d.ts +30 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js +60 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/AssumedPermissions.js.map +1 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.d.ts +3 -3
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js +5 -5
- package/features/security/authorization/GroupsTeamsAuthorizer/GetPermissionsFromIdentity.js.map +1 -1
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js +2 -0
- package/features/security/authorization/GroupsTeamsAuthorizer/feature.js.map +1 -1
- package/features/security/roles/CreateRole/CreateRoleUseCase.js +11 -6
- package/features/security/roles/CreateRole/CreateRoleUseCase.js.map +1 -1
- package/features/security/roles/CreateRole/schema.d.ts +1 -1
- package/features/security/roles/CreateRole/schema.js +1 -1
- package/features/security/roles/CreateRole/schema.js.map +1 -1
- package/features/security/roles/Installer/RolesInstaller.js +1 -0
- package/features/security/roles/Installer/RolesInstaller.js.map +1 -1
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js +9 -3
- package/features/security/roles/UpdateRole/UpdateRoleUseCase.js.map +1 -1
- package/features/security/roles/UpdateRole/schema.d.ts +1 -1
- package/features/security/roles/UpdateRole/schema.js +1 -1
- package/features/security/roles/UpdateRole/schema.js.map +1 -1
- package/features/security/shared/description.d.ts +4 -0
- package/features/security/shared/description.js +7 -0
- package/features/security/shared/description.js.map +1 -0
- package/features/security/shared/index.d.ts +1 -0
- package/features/security/shared/index.js +1 -0
- package/features/security/teams/CreateTeam/CreateTeamUseCase.d.ts +3 -1
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js +20 -8
- package/features/security/teams/CreateTeam/CreateTeamUseCase.js.map +1 -1
- package/features/security/teams/CreateTeam/schema.d.ts +1 -1
- package/features/security/teams/CreateTeam/schema.js +1 -1
- package/features/security/teams/CreateTeam/schema.js.map +1 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.d.ts +3 -1
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js +20 -5
- package/features/security/teams/UpdateTeam/UpdateTeamUseCase.js.map +1 -1
- package/features/security/teams/UpdateTeam/schema.d.ts +1 -1
- package/features/security/teams/UpdateTeam/schema.js +1 -1
- package/features/security/teams/UpdateTeam/schema.js.map +1 -1
- package/features/security/teams/shared/resolveRoleIdentifiers.d.ts +17 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js +32 -0
- package/features/security/teams/shared/resolveRoleIdentifiers.js.map +1 -0
- package/features/slugify/DefaultSlugify.d.ts +8 -0
- package/features/slugify/DefaultSlugify.js +20 -0
- package/features/slugify/DefaultSlugify.js.map +1 -0
- package/features/slugify/abstractions.d.ts +12 -0
- package/features/slugify/abstractions.js +5 -0
- package/features/slugify/abstractions.js.map +1 -0
- package/features/slugify/feature.d.ts +4 -0
- package/features/slugify/feature.js +11 -0
- package/features/slugify/feature.js.map +1 -0
- package/features/slugify/index.d.ts +3 -0
- package/features/slugify/index.js +2 -0
- package/features/storageOperations/abstractions.d.ts +21 -0
- package/features/storageOperations/abstractions.js +10 -0
- package/features/storageOperations/abstractions.js.map +1 -0
- package/features/stringFormatter/DefaultStringFormatter.d.ts +17 -0
- package/features/stringFormatter/DefaultStringFormatter.js +19 -0
- package/features/stringFormatter/DefaultStringFormatter.js.map +1 -0
- package/features/stringFormatter/abstractions.d.ts +11 -0
- package/features/stringFormatter/abstractions.js +5 -0
- package/features/stringFormatter/abstractions.js.map +1 -0
- package/features/stringFormatter/feature.d.ts +4 -0
- package/features/stringFormatter/feature.js +13 -0
- package/features/stringFormatter/feature.js.map +1 -0
- package/features/stringFormatter/index.d.ts +3 -0
- package/features/stringFormatter/index.js +2 -0
- package/features/task/TaskDefinition/abstractions.d.ts +69 -4
- package/features/task/TaskDefinition/abstractions.js +2 -1
- package/features/task/TaskDefinition/abstractions.js.map +1 -1
- package/features/tenancy/TenantContext/TenantContext.d.ts +1 -0
- package/features/tenancy/TenantContext/TenantContext.js +13 -8
- package/features/tenancy/TenantContext/TenantContext.js.map +1 -1
- package/features/users/shared/types.d.ts +9 -7
- package/features/wcp/WcpContext/WcpContext.d.ts +11 -5
- package/features/wcp/WcpContext/WcpContext.js +26 -2
- package/features/wcp/WcpContext/WcpContext.js.map +1 -1
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.d.ts +10 -69
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js +66 -35
- package/features/wcp/WcpContext/decorators/WcpContextWithFeatureFlagsDecorator.js.map +1 -1
- package/features/wcp/WcpContext/feature.d.ts +1 -2
- package/features/wcp/WcpContext/feature.js +2 -2
- package/features/wcp/WcpContext/feature.js.map +1 -1
- package/features/wcp/WcpContext/index.d.ts +0 -1
- package/features/wcp/WcpContext/types.d.ts +0 -4
- package/features/wcp/WcpFeature.d.ts +1 -1
- package/features/wcp/WcpFeature.js +7 -2
- package/features/wcp/WcpFeature.js.map +1 -1
- package/features/wcp/WcpLicenseLoader.d.ts +25 -0
- package/features/wcp/WcpLicenseLoader.js +58 -0
- package/features/wcp/WcpLicenseLoader.js.map +1 -0
- package/features/wcp/WcpLicenseProvider.d.ts +21 -0
- package/features/wcp/WcpLicenseProvider.js +14 -0
- package/features/wcp/WcpLicenseProvider.js.map +1 -0
- package/features/wcp/resolveWcpProjectEnvironment.d.ts +9 -0
- package/features/wcp/resolveWcpProjectEnvironment.js +23 -0
- package/features/wcp/resolveWcpProjectEnvironment.js.map +1 -0
- package/graphql/ApiCoreSchemaFactory.d.ts +16 -0
- package/graphql/ApiCoreSchemaFactory.js +58 -0
- package/graphql/ApiCoreSchemaFactory.js.map +1 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.d.ts +10 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js +53 -0
- package/graphql/featureFlags/FeatureFlagsSchemaFactory.js.map +1 -0
- package/graphql/security/NotAuthorizedResponse.d.ts +1 -1
- package/graphql/security/NotAuthorizedResponse.js +1 -1
- package/graphql/security/NotAuthorizedResponse.js.map +1 -1
- package/graphql/security/SecuritySchemaFactory.d.ts +15 -0
- package/graphql/security/SecuritySchemaFactory.js +27 -0
- package/graphql/security/SecuritySchemaFactory.js.map +1 -0
- package/graphql/security/addApiKeySchema.d.ts +2 -0
- package/graphql/security/{apiKey.gql.js → addApiKeySchema.js} +45 -27
- package/graphql/security/addApiKeySchema.js.map +1 -0
- package/graphql/security/addIdentitySchema.d.ts +2 -0
- package/graphql/security/{identity.gql.js → addIdentitySchema.js} +52 -35
- package/graphql/security/addIdentitySchema.js.map +1 -0
- package/graphql/security/addRoleSchema.d.ts +2 -0
- package/graphql/security/addRoleSchema.js +137 -0
- package/graphql/security/addRoleSchema.js.map +1 -0
- package/graphql/security/addSecurityBaseSchema.d.ts +2 -0
- package/graphql/security/{base.gql.js → addSecurityBaseSchema.js} +14 -16
- package/graphql/security/addSecurityBaseSchema.js.map +1 -0
- package/graphql/security/addTeamSchema.d.ts +2 -0
- package/graphql/security/addTeamSchema.js +157 -0
- package/graphql/security/addTeamSchema.js.map +1 -0
- package/graphql/system/SystemSchemaFactory.d.ts +10 -0
- package/graphql/system/SystemSchemaFactory.js +70 -0
- package/graphql/system/SystemSchemaFactory.js.map +1 -0
- package/graphql/users/UsersSchemaFactory.d.ts +10 -0
- package/graphql/users/UsersSchemaFactory.js +195 -0
- package/graphql/users/UsersSchemaFactory.js.map +1 -0
- package/graphql/wcp/WcpSchemaFactory.d.ts +10 -0
- package/graphql/wcp/{graphql.js → WcpSchemaFactory.js} +31 -18
- package/graphql/wcp/WcpSchemaFactory.js.map +1 -0
- package/idp/JwksCache.d.ts +14 -3
- package/idp/JwksCache.js +97 -17
- package/idp/JwksCache.js.map +1 -1
- package/idp/JwksStoreFeature.d.ts +8 -0
- package/idp/JwksStoreFeature.js +11 -0
- package/idp/JwksStoreFeature.js.map +1 -0
- package/idp/MemoryJwksStore.d.ts +14 -0
- package/idp/MemoryJwksStore.js +21 -0
- package/idp/MemoryJwksStore.js.map +1 -0
- package/idp/OidcJwtIdentityProvider.js +5 -1
- package/idp/OidcJwtIdentityProvider.js.map +1 -1
- package/idp/abstractions.d.ts +24 -0
- package/idp/abstractions.js +2 -1
- package/idp/abstractions.js.map +1 -1
- package/idp/feature.js +1 -2
- package/idp/feature.js.map +1 -1
- package/idp/index.d.ts +1 -0
- package/idp/index.js +1 -0
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/package.json +22 -21
- package/testing/environment.d.ts +14 -0
- package/testing/environment.js +18 -0
- package/testing/environment.js.map +1 -0
- package/types/core.d.ts +17 -5
- package/types/security.d.ts +0 -6
- package/types/tenancy.d.ts +0 -17
- package/types/users.d.ts +2 -16
- package/createApiCore.d.ts +0 -7
- package/createApiCore.js +0 -26
- package/createApiCore.js.map +0 -1
- package/graphql/security/apiKey.gql.d.ts +0 -4
- package/graphql/security/apiKey.gql.js.map +0 -1
- package/graphql/security/base.gql.d.ts +0 -4
- package/graphql/security/base.gql.js.map +0 -1
- package/graphql/security/identity.gql.d.ts +0 -4
- package/graphql/security/identity.gql.js.map +0 -1
- package/graphql/security/index.d.ts +0 -1
- package/graphql/security/index.js +0 -15
- package/graphql/security/index.js.map +0 -1
- package/graphql/security/role.gql.d.ts +0 -4
- package/graphql/security/role.gql.js +0 -106
- package/graphql/security/role.gql.js.map +0 -1
- package/graphql/security/team.gql.d.ts +0 -4
- package/graphql/security/team.gql.js +0 -119
- package/graphql/security/team.gql.js.map +0 -1
- package/graphql/system/createSystemGraphQL.d.ts +0 -2
- package/graphql/system/createSystemGraphQL.js +0 -54
- package/graphql/system/createSystemGraphQL.js.map +0 -1
- package/graphql/users/user.gql.d.ts +0 -3
- package/graphql/users/user.gql.js +0 -167
- package/graphql/users/user.gql.js.map +0 -1
- package/graphql/wcp/graphql.d.ts +0 -2
- package/graphql/wcp/graphql.js.map +0 -1
- package/legacy/security/LegacyContext.d.ts +0 -36
- package/legacy/security/LegacyContext.js +0 -152
- package/legacy/security/LegacyContext.js.map +0 -1
- package/legacy/security/createSecurityContext.d.ts +0 -3
- package/legacy/security/createSecurityContext.js +0 -10
- package/legacy/security/createSecurityContext.js.map +0 -1
- package/legacy/security/plugins/apiKeyAuthentication.d.ts +0 -7
- package/legacy/security/plugins/apiKeyAuthentication.js +0 -20
- package/legacy/security/plugins/apiKeyAuthentication.js.map +0 -1
- package/legacy/security/plugins/apiKeyAuthorization.d.ts +0 -6
- package/legacy/security/plugins/apiKeyAuthorization.js +0 -13
- package/legacy/security/plugins/apiKeyAuthorization.js.map +0 -1
- package/legacy/security/plugins/authenticateUsingCookie.d.ts +0 -5
- package/legacy/security/plugins/authenticateUsingCookie.js +0 -23
- package/legacy/security/plugins/authenticateUsingCookie.js.map +0 -1
- package/legacy/security/plugins/authenticateUsingHttpHeader.d.ts +0 -5
- package/legacy/security/plugins/authenticateUsingHttpHeader.js +0 -20
- package/legacy/security/plugins/authenticateUsingHttpHeader.js.map +0 -1
- package/legacy/security/plugins/secureHeaders.d.ts +0 -1
- package/legacy/security/plugins/secureHeaders.js +0 -30
- package/legacy/security/plugins/secureHeaders.js.map +0 -1
- package/legacy/tenancy/LegacyContext.d.ts +0 -15
- package/legacy/tenancy/LegacyContext.js +0 -57
- package/legacy/tenancy/LegacyContext.js.map +0 -1
- package/legacy/tenancy/createTenancyContext.d.ts +0 -3
- package/legacy/tenancy/createTenancyContext.js +0 -31
- package/legacy/tenancy/createTenancyContext.js.map +0 -1
- package/legacy/users/LegacyContext.d.ts +0 -13
- package/legacy/users/LegacyContext.js +0 -55
- package/legacy/users/LegacyContext.js.map +0 -1
- package/legacy/users/createAdminUsersContext.d.ts +0 -3
- package/legacy/users/createAdminUsersContext.js +0 -12
- package/legacy/users/createAdminUsersContext.js.map +0 -1
- package/legacy/wcp/LegacyWcpContext.d.ts +0 -38
- package/legacy/wcp/LegacyWcpContext.js +0 -99
- package/legacy/wcp/LegacyWcpContext.js.map +0 -1
- package/legacy/wcp/context.d.ts +0 -5
- package/legacy/wcp/context.js +0 -46
- package/legacy/wcp/context.js.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
class PublicUrl {
|
|
2
|
+
constructor(url){
|
|
3
|
+
this.url = url;
|
|
4
|
+
}
|
|
5
|
+
static from(value) {
|
|
6
|
+
if ("string" != typeof value || !value.trim()) return PublicUrl.unknown();
|
|
7
|
+
const trimmed = value.trim();
|
|
8
|
+
let url;
|
|
9
|
+
try {
|
|
10
|
+
url = new URL(trimmed);
|
|
11
|
+
} catch {
|
|
12
|
+
return PublicUrl.unknown();
|
|
13
|
+
}
|
|
14
|
+
if ("https:" !== url.protocol && "http:" !== url.protocol) return PublicUrl.unknown();
|
|
15
|
+
url.pathname = url.pathname.replace(/\/+$/, "");
|
|
16
|
+
url.search = "";
|
|
17
|
+
url.hash = "";
|
|
18
|
+
return new PublicUrl(url);
|
|
19
|
+
}
|
|
20
|
+
static unknown() {
|
|
21
|
+
return new PublicUrl(null);
|
|
22
|
+
}
|
|
23
|
+
isKnown() {
|
|
24
|
+
return null !== this.url;
|
|
25
|
+
}
|
|
26
|
+
get host() {
|
|
27
|
+
return this.url?.host ?? "";
|
|
28
|
+
}
|
|
29
|
+
join(path) {
|
|
30
|
+
if (!this.url) return "";
|
|
31
|
+
return this.toString() + "/" + path.replace(/^\/+/, "");
|
|
32
|
+
}
|
|
33
|
+
orElse(fallback) {
|
|
34
|
+
return this.url ? this.toString() : fallback;
|
|
35
|
+
}
|
|
36
|
+
toString() {
|
|
37
|
+
if (!this.url) return "";
|
|
38
|
+
return this.url.origin + this.url.pathname.replace(/\/+$/, "");
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export { PublicUrl };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=PublicUrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/publicUrls/PublicUrl.js","sources":["../../../src/features/publicUrls/PublicUrl.ts"],"sourcesContent":["/**\n * A public URL of the API or the Admin app. Usually an origin (https://api.example.com), but it can\n * carry a path when the app is served under a prefix (the standalone dev proxy serves the API at\n * http://localhost:3001/api). Never has a trailing slash.\n *\n * Always an object, never `null`: a URL the deployment doesn't know is an \"unknown\" `PublicUrl`\n * whose string forms are empty. Check `isKnown()` only where unknown needs different output.\n */\nexport class PublicUrl {\n private constructor(private readonly url: URL | null) {}\n\n /** Unknown for anything that isn't an absolute http(s) URL. */\n static from(value: unknown): PublicUrl {\n if (typeof value !== \"string\" || !value.trim()) {\n return PublicUrl.unknown();\n }\n\n const trimmed = value.trim();\n let url: URL;\n try {\n url = new URL(trimmed);\n } catch {\n return PublicUrl.unknown();\n }\n\n if (url.protocol !== \"https:\" && url.protocol !== \"http:\") {\n return PublicUrl.unknown();\n }\n\n url.pathname = url.pathname.replace(/\\/+$/, \"\");\n url.search = \"\";\n url.hash = \"\";\n\n return new PublicUrl(url);\n }\n\n static unknown(): PublicUrl {\n return new PublicUrl(null);\n }\n\n isKnown(): boolean {\n return this.url !== null;\n }\n\n /** Hostname plus port, e.g. `api.example.com` or `localhost:3001`. Empty when unknown. */\n get host(): string {\n return this.url?.host ?? \"\";\n }\n\n /** Appends a path, e.g. `join(\"/files/\")` gives `https://api.example.com/files/`. Empty when unknown. */\n join(path: string): string {\n if (!this.url) {\n return \"\";\n }\n\n return this.toString() + \"/\" + path.replace(/^\\/+/, \"\");\n }\n\n /** The URL, or `fallback` when unknown, e.g. a placeholder in generated config. */\n orElse(fallback: string): string {\n return this.url ? this.toString() : fallback;\n }\n\n /** Empty when unknown. */\n toString(): string {\n if (!this.url) {\n return \"\";\n }\n\n return this.url.origin + this.url.pathname.replace(/\\/+$/, \"\");\n }\n}\n"],"names":["PublicUrl","url","value","trimmed","URL","path","fallback"],"mappings":"AAQO,MAAMA;IACT,YAAqCC,GAAe,CAAE;aAAjBA,GAAG,GAAHA;IAAkB;IAGvD,OAAO,KAAKC,KAAc,EAAa;QACnC,IAAI,AAAiB,YAAjB,OAAOA,SAAsB,CAACA,MAAM,IAAI,IACxC,OAAOF,UAAU,OAAO;QAG5B,MAAMG,UAAUD,MAAM,IAAI;QAC1B,IAAID;QACJ,IAAI;YACAA,MAAM,IAAIG,IAAID;QAClB,EAAE,OAAM;YACJ,OAAOH,UAAU,OAAO;QAC5B;QAEA,IAAIC,AAAiB,aAAjBA,IAAI,QAAQ,IAAiBA,AAAiB,YAAjBA,IAAI,QAAQ,EACzC,OAAOD,UAAU,OAAO;QAG5BC,IAAI,QAAQ,GAAGA,IAAI,QAAQ,CAAC,OAAO,CAAC,QAAQ;QAC5CA,IAAI,MAAM,GAAG;QACbA,IAAI,IAAI,GAAG;QAEX,OAAO,IAAID,UAAUC;IACzB;IAEA,OAAO,UAAqB;QACxB,OAAO,IAAID,UAAU;IACzB;IAEA,UAAmB;QACf,OAAO,AAAa,SAAb,IAAI,CAAC,GAAG;IACnB;IAGA,IAAI,OAAe;QACf,OAAO,IAAI,CAAC,GAAG,EAAE,QAAQ;IAC7B;IAGA,KAAKK,IAAY,EAAU;QACvB,IAAI,CAAC,IAAI,CAAC,GAAG,EACT,OAAO;QAGX,OAAO,IAAI,CAAC,QAAQ,KAAK,MAAMA,KAAK,OAAO,CAAC,QAAQ;IACxD;IAGA,OAAOC,QAAgB,EAAU;QAC7B,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,KAAKA;IACxC;IAGA,WAAmB;QACf,IAAI,CAAC,IAAI,CAAC,GAAG,EACT,OAAO;QAGX,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ;IAC/D;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { PublicUrl } from "../PublicUrl.js";
|
|
3
|
+
describe("PublicUrl", ()=>{
|
|
4
|
+
it.each([
|
|
5
|
+
void 0,
|
|
6
|
+
null,
|
|
7
|
+
42,
|
|
8
|
+
"",
|
|
9
|
+
" ",
|
|
10
|
+
"not a url",
|
|
11
|
+
"api.example.com",
|
|
12
|
+
"ftp://example.com"
|
|
13
|
+
])("is unknown for %j", (value)=>{
|
|
14
|
+
const url = PublicUrl.from(value);
|
|
15
|
+
expect(url.isKnown()).toBe(false);
|
|
16
|
+
expect(url.toString()).toBe("");
|
|
17
|
+
expect(url.host).toBe("");
|
|
18
|
+
expect(url.join("/files/")).toBe("");
|
|
19
|
+
expect(url.orElse("{API_HOST_URL}")).toBe("{API_HOST_URL}");
|
|
20
|
+
});
|
|
21
|
+
it("drops trailing slashes, query and hash", ()=>{
|
|
22
|
+
const url = PublicUrl.from(" https://api.example.com//?a=1#x ");
|
|
23
|
+
expect(url.toString()).toBe("https://api.example.com");
|
|
24
|
+
expect(url.isKnown()).toBe(true);
|
|
25
|
+
expect(url.orElse("{API_HOST_URL}")).toBe("https://api.example.com");
|
|
26
|
+
});
|
|
27
|
+
it("keeps a path prefix", ()=>{
|
|
28
|
+
const url = PublicUrl.from("http://localhost:3001/api/");
|
|
29
|
+
expect(url.toString()).toBe("http://localhost:3001/api");
|
|
30
|
+
expect(url.host).toBe("localhost:3001");
|
|
31
|
+
});
|
|
32
|
+
it("joins paths with exactly one slash", ()=>{
|
|
33
|
+
expect(PublicUrl.from("https://api.example.com/").join("/files/")).toBe("https://api.example.com/files/");
|
|
34
|
+
expect(PublicUrl.from("http://localhost:3001/api").join("files")).toBe("http://localhost:3001/api/files");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=PublicUrl.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/publicUrls/__tests__/PublicUrl.test.js","sources":["../../../../src/features/publicUrls/__tests__/PublicUrl.test.ts"],"sourcesContent":["import { describe } from \"vitest\";\nimport { it } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { PublicUrl } from \"../PublicUrl.js\";\n\ndescribe(\"PublicUrl\", () => {\n it.each([undefined, null, 42, \"\", \" \", \"not a url\", \"api.example.com\", \"ftp://example.com\"])(\n \"is unknown for %j\",\n value => {\n const url = PublicUrl.from(value);\n\n expect(url.isKnown()).toBe(false);\n expect(url.toString()).toBe(\"\");\n expect(url.host).toBe(\"\");\n expect(url.join(\"/files/\")).toBe(\"\");\n expect(url.orElse(\"{API_HOST_URL}\")).toBe(\"{API_HOST_URL}\");\n }\n );\n\n it(\"drops trailing slashes, query and hash\", () => {\n const url = PublicUrl.from(\" https://api.example.com//?a=1#x \");\n\n expect(url.toString()).toBe(\"https://api.example.com\");\n expect(url.isKnown()).toBe(true);\n expect(url.orElse(\"{API_HOST_URL}\")).toBe(\"https://api.example.com\");\n });\n\n it(\"keeps a path prefix\", () => {\n const url = PublicUrl.from(\"http://localhost:3001/api/\");\n\n expect(url.toString()).toBe(\"http://localhost:3001/api\");\n expect(url.host).toBe(\"localhost:3001\");\n });\n\n it(\"joins paths with exactly one slash\", () => {\n expect(PublicUrl.from(\"https://api.example.com/\").join(\"/files/\")).toBe(\n \"https://api.example.com/files/\"\n );\n expect(PublicUrl.from(\"http://localhost:3001/api\").join(\"files\")).toBe(\n \"http://localhost:3001/api/files\"\n );\n });\n});\n"],"names":["describe","it","undefined","value","url","PublicUrl","expect"],"mappings":";;AAKAA,SAAS,aAAa;IAClBC,GAAG,IAAI,CAAC;QAACC;QAAW;QAAM;QAAI;QAAI;QAAO;QAAa;QAAmB;KAAoB,EACzF,qBACAC,CAAAA;QACI,MAAMC,MAAMC,UAAU,IAAI,CAACF;QAE3BG,OAAOF,IAAI,OAAO,IAAI,IAAI,CAAC;QAC3BE,OAAOF,IAAI,QAAQ,IAAI,IAAI,CAAC;QAC5BE,OAAOF,IAAI,IAAI,EAAE,IAAI,CAAC;QACtBE,OAAOF,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC;QACjCE,OAAOF,IAAI,MAAM,CAAC,mBAAmB,IAAI,CAAC;IAC9C;IAGJH,GAAG,0CAA0C;QACzC,MAAMG,MAAMC,UAAU,IAAI,CAAC;QAE3BC,OAAOF,IAAI,QAAQ,IAAI,IAAI,CAAC;QAC5BE,OAAOF,IAAI,OAAO,IAAI,IAAI,CAAC;QAC3BE,OAAOF,IAAI,MAAM,CAAC,mBAAmB,IAAI,CAAC;IAC9C;IAEAH,GAAG,uBAAuB;QACtB,MAAMG,MAAMC,UAAU,IAAI,CAAC;QAE3BC,OAAOF,IAAI,QAAQ,IAAI,IAAI,CAAC;QAC5BE,OAAOF,IAAI,IAAI,EAAE,IAAI,CAAC;IAC1B;IAEAH,GAAG,sCAAsC;QACrCK,OAAOD,UAAU,IAAI,CAAC,4BAA4B,IAAI,CAAC,YAAY,IAAI,CACnE;QAEJC,OAAOD,UAAU,IAAI,CAAC,6BAA6B,IAAI,CAAC,UAAU,IAAI,CAClE;IAER;AACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { Container } from "@webiny/feature/api";
|
|
3
|
+
import { PublicUrls, PublicUrlsFeature } from "../index.js";
|
|
4
|
+
describe("PublicUrls", ()=>{
|
|
5
|
+
it("returns unknown URLs by default", async ()=>{
|
|
6
|
+
const container = new Container();
|
|
7
|
+
PublicUrlsFeature.register(container);
|
|
8
|
+
const publicUrls = container.resolve(PublicUrls);
|
|
9
|
+
expect((await publicUrls.getApiUrl()).isKnown()).toBe(false);
|
|
10
|
+
expect((await publicUrls.getAdminUrl()).isKnown()).toBe(false);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=PublicUrls.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/publicUrls/__tests__/PublicUrls.test.js","sources":["../../../../src/features/publicUrls/__tests__/PublicUrls.test.ts"],"sourcesContent":["import { describe } from \"vitest\";\nimport { it } from \"vitest\";\nimport { expect } from \"vitest\";\nimport { Container } from \"@webiny/feature/api\";\nimport { PublicUrls } from \"../index.js\";\nimport { PublicUrlsFeature } from \"../index.js\";\n\ndescribe(\"PublicUrls\", () => {\n it(\"returns unknown URLs by default\", async () => {\n const container = new Container();\n PublicUrlsFeature.register(container);\n\n const publicUrls = container.resolve(PublicUrls);\n\n expect((await publicUrls.getApiUrl()).isKnown()).toBe(false);\n expect((await publicUrls.getAdminUrl()).isKnown()).toBe(false);\n });\n});\n"],"names":["describe","it","container","Container","PublicUrlsFeature","publicUrls","PublicUrls","expect"],"mappings":";;;AAOAA,SAAS,cAAc;IACnBC,GAAG,mCAAmC;QAClC,MAAMC,YAAY,IAAIC;QACtBC,kBAAkB,QAAQ,CAACF;QAE3B,MAAMG,aAAaH,UAAU,OAAO,CAACI;QAErCC,OAAQ,OAAMF,WAAW,SAAS,EAAC,EAAG,OAAO,IAAI,IAAI,CAAC;QACtDE,OAAQ,OAAMF,WAAW,WAAW,EAAC,EAAG,OAAO,IAAI,IAAI,CAAC;IAC5D;AACJ"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PublicUrl } from "./PublicUrl.js";
|
|
2
|
+
export interface IPublicUrls {
|
|
3
|
+
/**
|
|
4
|
+
* Public URL of the API for the current tenant, e.g. https://api.example.com. Uses the custom
|
|
5
|
+
* domain when one is configured. Unknown (see `PublicUrl.isKnown()`) when the deployment doesn't
|
|
6
|
+
* know it.
|
|
7
|
+
*/
|
|
8
|
+
getApiUrl(): Promise<PublicUrl>;
|
|
9
|
+
/**
|
|
10
|
+
* Public URL of the Admin app for the current tenant, e.g. https://admin.example.com. Uses the
|
|
11
|
+
* custom domain when one is configured. Unknown when the deployment doesn't know it (e.g. the
|
|
12
|
+
* API is deployed but the Admin app isn't yet).
|
|
13
|
+
*/
|
|
14
|
+
getAdminUrl(): Promise<PublicUrl>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Public URLs of this deployment's API and Admin app. Each hosting type supplies its own
|
|
18
|
+
* implementation: AWS reads the service manifest written at deploy time
|
|
19
|
+
* (`@webiny/api-event-handler-aws`), standalone reads the `WEBINY_API_URL` / `WEBINY_ADMIN_URL`
|
|
20
|
+
* build params (`@webiny/api-event-handler-standalone`).
|
|
21
|
+
*
|
|
22
|
+
* Resolve per request and don't cache the result globally: values are "for the current tenant".
|
|
23
|
+
*/
|
|
24
|
+
export declare const PublicUrls: import("@webiny/di").Abstraction<IPublicUrls>;
|
|
25
|
+
export declare namespace PublicUrls {
|
|
26
|
+
type Interface = IPublicUrls;
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/publicUrls/abstractions.js","sources":["../../../src/features/publicUrls/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\nimport type { PublicUrl } from \"./PublicUrl.js\";\n\nexport interface IPublicUrls {\n /**\n * Public URL of the API for the current tenant, e.g. https://api.example.com. Uses the custom\n * domain when one is configured. Unknown (see `PublicUrl.isKnown()`) when the deployment doesn't\n * know it.\n */\n getApiUrl(): Promise<PublicUrl>;\n /**\n * Public URL of the Admin app for the current tenant, e.g. https://admin.example.com. Uses the\n * custom domain when one is configured. Unknown when the deployment doesn't know it (e.g. the\n * API is deployed but the Admin app isn't yet).\n */\n getAdminUrl(): Promise<PublicUrl>;\n}\n\n/**\n * Public URLs of this deployment's API and Admin app. Each hosting type supplies its own\n * implementation: AWS reads the service manifest written at deploy time\n * (`@webiny/api-event-handler-aws`), standalone reads the `WEBINY_API_URL` / `WEBINY_ADMIN_URL`\n * build params (`@webiny/api-event-handler-standalone`).\n *\n * Resolve per request and don't cache the result globally: values are \"for the current tenant\".\n */\nexport const PublicUrls = createAbstraction<IPublicUrls>(\"Core/PublicUrls\");\n\nexport namespace PublicUrls {\n export type Interface = IPublicUrls;\n}\n"],"names":["PublicUrls","createAbstraction"],"mappings":";AA0BO,MAAMA,aAAaC,kBAA+B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the default, which knows no URLs. Each hosting type overrides it through the
|
|
3
|
+
* `publicUrls` hook of `registerApiRequestStack`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const PublicUrlsFeature: {
|
|
6
|
+
name: string;
|
|
7
|
+
register(container: import("@webiny/di").Container): void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/api";
|
|
2
|
+
import { NullPublicUrls } from "./NullPublicUrls.js";
|
|
3
|
+
const PublicUrlsFeature = createFeature({
|
|
4
|
+
name: "PublicUrlsFeature",
|
|
5
|
+
register (container) {
|
|
6
|
+
container.register(NullPublicUrls);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
export { PublicUrlsFeature };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/publicUrls/feature.js","sources":["../../../src/features/publicUrls/feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { NullPublicUrls } from \"./NullPublicUrls.js\";\n\n/**\n * Registers the default, which knows no URLs. Each hosting type overrides it through the\n * `publicUrls` hook of `registerApiRequestStack`.\n */\nexport const PublicUrlsFeature = createFeature({\n name: \"PublicUrlsFeature\",\n register(container) {\n container.register(NullPublicUrls);\n }\n});\n"],"names":["PublicUrlsFeature","createFeature","container","NullPublicUrls"],"mappings":";;AAOO,MAAMA,oBAAoBC,cAAc;IAC3C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;IACvB;AACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RawAssumePermissions as Abstraction } from "./abstractions.js";
|
|
2
|
+
/**
|
|
3
|
+
* Per-request holder for the transport-extracted preview target. Registered per request, so a
|
|
4
|
+
* fresh instance holds the value for the current request only.
|
|
5
|
+
*/
|
|
6
|
+
declare class RawAssumePermissionsImpl implements Abstraction.Interface {
|
|
7
|
+
private value;
|
|
8
|
+
get(): Abstraction.Target | null;
|
|
9
|
+
set(value: Abstraction.Target | null): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const RawAssumePermissions: typeof RawAssumePermissionsImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRawAssumePermissions>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RawAssumePermissions } from "./abstractions.js";
|
|
2
|
+
class RawAssumePermissionsImpl {
|
|
3
|
+
get() {
|
|
4
|
+
return this.value;
|
|
5
|
+
}
|
|
6
|
+
set(value) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
}
|
|
9
|
+
constructor(){
|
|
10
|
+
this.value = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const RawAssumePermissions_RawAssumePermissions = RawAssumePermissions.createImplementation({
|
|
14
|
+
implementation: RawAssumePermissionsImpl,
|
|
15
|
+
dependencies: []
|
|
16
|
+
});
|
|
17
|
+
export { RawAssumePermissions_RawAssumePermissions as RawAssumePermissions };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=RawAssumePermissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/requestContext/RawAssumePermissions.js","sources":["../../../src/features/requestContext/RawAssumePermissions.ts"],"sourcesContent":["import { RawAssumePermissions as Abstraction } from \"./abstractions.js\";\n\n/**\n * Per-request holder for the transport-extracted preview target. Registered per request, so a\n * fresh instance holds the value for the current request only.\n */\nclass RawAssumePermissionsImpl implements Abstraction.Interface {\n private value: Abstraction.Target | null = null;\n\n get(): Abstraction.Target | null {\n return this.value;\n }\n\n set(value: Abstraction.Target | null): void {\n this.value = value;\n }\n}\n\nexport const RawAssumePermissions = Abstraction.createImplementation({\n implementation: RawAssumePermissionsImpl,\n dependencies: []\n});\n"],"names":["RawAssumePermissionsImpl","value","RawAssumePermissions","Abstraction"],"mappings":";AAMA,MAAMA;IAGF,MAAiC;QAC7B,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAIC,KAAgC,EAAQ;QACxC,IAAI,CAAC,KAAK,GAAGA;IACjB;;aARQ,KAAK,GAA8B;;AAS/C;AAEO,MAAMC,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IRawAuthToken } from "./abstractions.js";
|
|
2
|
+
/**
|
|
3
|
+
* Per-request holder for the transport-extracted raw auth token. Registered per request, so a fresh
|
|
4
|
+
* instance holds the value for the current request only.
|
|
5
|
+
*/
|
|
6
|
+
declare class RawAuthTokenImpl implements IRawAuthToken {
|
|
7
|
+
private value;
|
|
8
|
+
get(): string | null;
|
|
9
|
+
set(token: string | null): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const RawAuthToken: typeof RawAuthTokenImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<IRawAuthToken>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RawAuthToken } from "./abstractions.js";
|
|
2
|
+
class RawAuthTokenImpl {
|
|
3
|
+
get() {
|
|
4
|
+
return this.value;
|
|
5
|
+
}
|
|
6
|
+
set(token) {
|
|
7
|
+
this.value = token;
|
|
8
|
+
}
|
|
9
|
+
constructor(){
|
|
10
|
+
this.value = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const RawAuthToken_RawAuthToken = RawAuthToken.createImplementation({
|
|
14
|
+
implementation: RawAuthTokenImpl,
|
|
15
|
+
dependencies: []
|
|
16
|
+
});
|
|
17
|
+
export { RawAuthToken_RawAuthToken as RawAuthToken };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=RawAuthToken.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/requestContext/RawAuthToken.js","sources":["../../../src/features/requestContext/RawAuthToken.ts"],"sourcesContent":["import { RawAuthToken as Abstraction } from \"./abstractions.js\";\nimport type { IRawAuthToken } from \"./abstractions.js\";\n\n/**\n * Per-request holder for the transport-extracted raw auth token. Registered per request, so a fresh\n * instance holds the value for the current request only.\n */\nclass RawAuthTokenImpl implements IRawAuthToken {\n private value: string | null = null;\n\n get(): string | null {\n return this.value;\n }\n\n set(token: string | null): void {\n this.value = token;\n }\n}\n\nexport const RawAuthToken = Abstraction.createImplementation({\n implementation: RawAuthTokenImpl,\n dependencies: []\n});\n"],"names":["RawAuthTokenImpl","token","RawAuthToken","Abstraction"],"mappings":";AAOA,MAAMA;IAGF,MAAqB;QACjB,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAIC,KAAoB,EAAQ;QAC5B,IAAI,CAAC,KAAK,GAAGA;IACjB;;aARQ,KAAK,GAAkB;;AASnC;AAEO,MAAMC,4BAAeC,aAAAA,oBAAgC,CAAC;IACzD,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IRawTenantId } from "./abstractions.js";
|
|
2
|
+
/**
|
|
3
|
+
* Per-request holder for the transport-extracted raw tenant id. Registered per request, so a fresh
|
|
4
|
+
* instance holds the value for the current request only.
|
|
5
|
+
*/
|
|
6
|
+
declare class RawTenantIdImpl implements IRawTenantId {
|
|
7
|
+
private value;
|
|
8
|
+
get(): string | null;
|
|
9
|
+
set(id: string | null): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const RawTenantId: typeof RawTenantIdImpl & {
|
|
12
|
+
__abstraction: import("@webiny/di").Abstraction<IRawTenantId>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RawTenantId } from "./abstractions.js";
|
|
2
|
+
class RawTenantIdImpl {
|
|
3
|
+
get() {
|
|
4
|
+
return this.value;
|
|
5
|
+
}
|
|
6
|
+
set(id) {
|
|
7
|
+
this.value = id;
|
|
8
|
+
}
|
|
9
|
+
constructor(){
|
|
10
|
+
this.value = null;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const RawTenantId_RawTenantId = RawTenantId.createImplementation({
|
|
14
|
+
implementation: RawTenantIdImpl,
|
|
15
|
+
dependencies: []
|
|
16
|
+
});
|
|
17
|
+
export { RawTenantId_RawTenantId as RawTenantId };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=RawTenantId.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/requestContext/RawTenantId.js","sources":["../../../src/features/requestContext/RawTenantId.ts"],"sourcesContent":["import { RawTenantId as Abstraction } from \"./abstractions.js\";\nimport type { IRawTenantId } from \"./abstractions.js\";\n\n/**\n * Per-request holder for the transport-extracted raw tenant id. Registered per request, so a fresh\n * instance holds the value for the current request only.\n */\nclass RawTenantIdImpl implements IRawTenantId {\n private value: string | null = null;\n\n get(): string | null {\n return this.value;\n }\n\n set(id: string | null): void {\n this.value = id;\n }\n}\n\nexport const RawTenantId = Abstraction.createImplementation({\n implementation: RawTenantIdImpl,\n dependencies: []\n});\n"],"names":["RawTenantIdImpl","id","RawTenantId","Abstraction"],"mappings":";AAOA,MAAMA;IAGF,MAAqB;QACjB,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAIC,EAAiB,EAAQ;QACzB,IAAI,CAAC,KAAK,GAAGA;IACjB;;aARQ,KAAK,GAAkB;;AASnC;AAEO,MAAMC,0BAAcC,YAAAA,oBAAgC,CAAC;IACxD,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestIdentityLoader as Abstraction } from "./abstractions.js";
|
|
2
|
+
import type { IRawAuthToken } from "./abstractions.js";
|
|
3
|
+
import type { IAuthenticationContext } from "../../features/security/authentication/AuthenticationContext/index.js";
|
|
4
|
+
import type { IIdentityContext } from "../../features/security/IdentityContext/abstractions.js";
|
|
5
|
+
/**
|
|
6
|
+
* LOAD step: authenticates the token set by the transport's EXTRACT step into RawAuthToken and sets
|
|
7
|
+
* IdentityContext. A null/absent token authenticates as anonymous (preserves the previous
|
|
8
|
+
* always-authenticate-the-header behavior). Transport-agnostic.
|
|
9
|
+
*/
|
|
10
|
+
export declare class RequestIdentityLoaderImpl implements Abstraction.Interface {
|
|
11
|
+
private authentication;
|
|
12
|
+
private identityContext;
|
|
13
|
+
private rawAuthToken;
|
|
14
|
+
constructor(authentication: IAuthenticationContext, identityContext: IIdentityContext, rawAuthToken: IRawAuthToken);
|
|
15
|
+
establish(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const RequestIdentityLoader: typeof RequestIdentityLoaderImpl & {
|
|
18
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRequestIdentityLoader>;
|
|
19
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { RawAuthToken, RequestIdentityLoader } from "./abstractions.js";
|
|
2
|
+
import { AuthenticationContext } from "../security/authentication/AuthenticationContext/index.js";
|
|
3
|
+
import { IdentityContext } from "../security/IdentityContext/index.js";
|
|
4
|
+
class RequestIdentityLoaderImpl {
|
|
5
|
+
constructor(authentication, identityContext, rawAuthToken){
|
|
6
|
+
this.authentication = authentication;
|
|
7
|
+
this.identityContext = identityContext;
|
|
8
|
+
this.rawAuthToken = rawAuthToken;
|
|
9
|
+
}
|
|
10
|
+
async establish() {
|
|
11
|
+
const token = this.rawAuthToken.get() ?? "";
|
|
12
|
+
const identity = await this.authentication.authenticate(token);
|
|
13
|
+
this.identityContext.setIdentity(identity);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const RequestIdentityLoader_RequestIdentityLoader = RequestIdentityLoader.createImplementation({
|
|
17
|
+
implementation: RequestIdentityLoaderImpl,
|
|
18
|
+
dependencies: [
|
|
19
|
+
AuthenticationContext,
|
|
20
|
+
IdentityContext,
|
|
21
|
+
RawAuthToken
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
export { RequestIdentityLoaderImpl, RequestIdentityLoader_RequestIdentityLoader as RequestIdentityLoader };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=RequestIdentityLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/requestContext/RequestIdentityLoader.js","sources":["../../../src/features/requestContext/RequestIdentityLoader.ts"],"sourcesContent":["import { RequestIdentityLoader as Abstraction, RawAuthToken } from \"./abstractions.js\";\nimport type { IRawAuthToken } from \"./abstractions.js\";\nimport { AuthenticationContext } from \"~/features/security/authentication/AuthenticationContext/index.js\";\nimport type { IAuthenticationContext } from \"~/features/security/authentication/AuthenticationContext/index.js\";\nimport { IdentityContext } from \"~/features/security/IdentityContext/index.js\";\nimport type { IIdentityContext } from \"~/features/security/IdentityContext/abstractions.js\";\n\n/**\n * LOAD step: authenticates the token set by the transport's EXTRACT step into RawAuthToken and sets\n * IdentityContext. A null/absent token authenticates as anonymous (preserves the previous\n * always-authenticate-the-header behavior). Transport-agnostic.\n */\nexport class RequestIdentityLoaderImpl implements Abstraction.Interface {\n constructor(\n private authentication: IAuthenticationContext,\n private identityContext: IIdentityContext,\n private rawAuthToken: IRawAuthToken\n ) {}\n\n async establish(): Promise<void> {\n const token = this.rawAuthToken.get() ?? \"\";\n const identity = await this.authentication.authenticate(token);\n this.identityContext.setIdentity(identity);\n }\n}\n\nexport const RequestIdentityLoader = Abstraction.createImplementation({\n implementation: RequestIdentityLoaderImpl,\n dependencies: [AuthenticationContext, IdentityContext, RawAuthToken]\n});\n"],"names":["RequestIdentityLoaderImpl","authentication","identityContext","rawAuthToken","token","identity","RequestIdentityLoader","Abstraction","AuthenticationContext","IdentityContext","RawAuthToken"],"mappings":";;;AAYO,MAAMA;IACT,YACYC,cAAsC,EACtCC,eAAiC,EACjCC,YAA2B,CACrC;aAHUF,cAAc,GAAdA;aACAC,eAAe,GAAfA;aACAC,YAAY,GAAZA;IACT;IAEH,MAAM,YAA2B;QAC7B,MAAMC,QAAQ,IAAI,CAAC,YAAY,CAAC,GAAG,MAAM;QACzC,MAAMC,WAAW,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAACD;QACxD,IAAI,CAAC,eAAe,CAAC,WAAW,CAACC;IACrC;AACJ;AAEO,MAAMC,8CAAwBC,sBAAAA,oBAAgC,CAAC;IAClE,gBAAgBP;IAChB,cAAc;QAACQ;QAAuBC;QAAiBC;KAAa;AACxE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RequestTenantLoader as Abstraction } from "./abstractions.js";
|
|
2
|
+
import type { IRawTenantId } from "./abstractions.js";
|
|
3
|
+
import type { ITenantContext } from "../../features/tenancy/TenantContext/abstractions.js";
|
|
4
|
+
import type { IGetTenantByIdUseCase } from "../../features/tenancy/GetTenantById/abstractions.js";
|
|
5
|
+
/**
|
|
6
|
+
* LOAD step: reads the raw tenant id (set by the transport's EXTRACT step into RawTenantId),
|
|
7
|
+
* resolves the Tenant, and sets TenantContext. Transport-agnostic.
|
|
8
|
+
*/
|
|
9
|
+
export declare class RequestTenantLoaderImpl implements Abstraction.Interface {
|
|
10
|
+
private tenantContext;
|
|
11
|
+
private getTenantById;
|
|
12
|
+
private rawTenantId;
|
|
13
|
+
constructor(tenantContext: ITenantContext, getTenantById: IGetTenantByIdUseCase, rawTenantId: IRawTenantId);
|
|
14
|
+
establish(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare const RequestTenantLoader: typeof RequestTenantLoaderImpl & {
|
|
17
|
+
__abstraction: import("@webiny/di").Abstraction<import("./abstractions.js").IRequestTenantLoader>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { RawTenantId, RequestTenantLoader } from "./abstractions.js";
|
|
2
|
+
import { TenantContext } from "../tenancy/TenantContext/index.js";
|
|
3
|
+
import { GetTenantByIdUseCase } from "../tenancy/GetTenantById/index.js";
|
|
4
|
+
const DEFAULT_TENANT_ID = "root";
|
|
5
|
+
const createBootstrapRootTenant = ()=>{
|
|
6
|
+
const now = new Date().toISOString();
|
|
7
|
+
return {
|
|
8
|
+
id: DEFAULT_TENANT_ID,
|
|
9
|
+
name: "Root",
|
|
10
|
+
description: "",
|
|
11
|
+
status: "enabled",
|
|
12
|
+
isInstalled: false,
|
|
13
|
+
settings: {
|
|
14
|
+
name: {
|
|
15
|
+
full: "Root",
|
|
16
|
+
slug: "root"
|
|
17
|
+
},
|
|
18
|
+
social: {},
|
|
19
|
+
favicon: {},
|
|
20
|
+
logo: {}
|
|
21
|
+
},
|
|
22
|
+
tags: [],
|
|
23
|
+
parent: null,
|
|
24
|
+
createdOn: now,
|
|
25
|
+
savedOn: now
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
class RequestTenantLoaderImpl {
|
|
29
|
+
constructor(tenantContext, getTenantById, rawTenantId){
|
|
30
|
+
this.tenantContext = tenantContext;
|
|
31
|
+
this.getTenantById = getTenantById;
|
|
32
|
+
this.rawTenantId = rawTenantId;
|
|
33
|
+
}
|
|
34
|
+
async establish() {
|
|
35
|
+
const resolvedId = this.rawTenantId.get() || DEFAULT_TENANT_ID;
|
|
36
|
+
const result = await this.getTenantById.execute(resolvedId);
|
|
37
|
+
if (result.isOk()) return void this.tenantContext.setTenant(result.value);
|
|
38
|
+
if (resolvedId === DEFAULT_TENANT_ID) return void this.tenantContext.setTenant(createBootstrapRootTenant());
|
|
39
|
+
console.warn(`[RequestTenantLoader] Tenant "${resolvedId}" not found.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const RequestTenantLoader_RequestTenantLoader = RequestTenantLoader.createImplementation({
|
|
43
|
+
implementation: RequestTenantLoaderImpl,
|
|
44
|
+
dependencies: [
|
|
45
|
+
TenantContext,
|
|
46
|
+
GetTenantByIdUseCase,
|
|
47
|
+
RawTenantId
|
|
48
|
+
]
|
|
49
|
+
});
|
|
50
|
+
export { RequestTenantLoaderImpl, RequestTenantLoader_RequestTenantLoader as RequestTenantLoader };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=RequestTenantLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/requestContext/RequestTenantLoader.js","sources":["../../../src/features/requestContext/RequestTenantLoader.ts"],"sourcesContent":["import { RequestTenantLoader as Abstraction, RawTenantId } from \"./abstractions.js\";\nimport type { IRawTenantId } from \"./abstractions.js\";\nimport { TenantContext } from \"~/features/tenancy/TenantContext/index.js\";\nimport type { ITenantContext } from \"~/features/tenancy/TenantContext/abstractions.js\";\nimport { GetTenantByIdUseCase } from \"~/features/tenancy/GetTenantById/index.js\";\nimport type { IGetTenantByIdUseCase } from \"~/features/tenancy/GetTenantById/abstractions.js\";\nimport type { Tenant } from \"~/types/tenancy.js\";\n\nconst DEFAULT_TENANT_ID = \"root\";\n\n/**\n * A minimal in-memory root tenant used only before the system is installed, when the real root\n * tenant record doesn't exist yet. It keeps the request pipeline + GraphQL schema build functional\n * (nothing dereferences a null tenant) so the install mutation can run and create the real root.\n * Once installed, getTenantById returns the persisted record and this is never used.\n */\nconst createBootstrapRootTenant = (): Tenant => {\n const now = new Date().toISOString();\n return {\n id: DEFAULT_TENANT_ID,\n name: \"Root\",\n description: \"\",\n status: \"enabled\",\n isInstalled: false,\n settings: {\n name: { full: \"Root\", slug: \"root\" },\n social: {},\n favicon: {},\n logo: {}\n } as any,\n tags: [],\n parent: null,\n createdOn: now,\n savedOn: now\n };\n};\n\n/**\n * LOAD step: reads the raw tenant id (set by the transport's EXTRACT step into RawTenantId),\n * resolves the Tenant, and sets TenantContext. Transport-agnostic.\n */\nexport class RequestTenantLoaderImpl implements Abstraction.Interface {\n constructor(\n private tenantContext: ITenantContext,\n private getTenantById: IGetTenantByIdUseCase,\n private rawTenantId: IRawTenantId\n ) {}\n\n async establish(): Promise<void> {\n const resolvedId = this.rawTenantId.get() || DEFAULT_TENANT_ID;\n const result = await this.getTenantById.execute(resolvedId);\n if (result.isOk()) {\n this.tenantContext.setTenant(result.value);\n return;\n }\n\n // Fresh, not-yet-installed environment: the root tenant record doesn't exist yet. Establish a\n // bootstrap root so the request pipeline + GraphQL schema build work and the install mutation\n // can create the real root tenant. Only ever taken for the root tenant pre-install.\n if (resolvedId === DEFAULT_TENANT_ID) {\n this.tenantContext.setTenant(createBootstrapRootTenant());\n return;\n }\n\n console.warn(`[RequestTenantLoader] Tenant \"${resolvedId}\" not found.`);\n }\n}\n\nexport const RequestTenantLoader = Abstraction.createImplementation({\n implementation: RequestTenantLoaderImpl,\n dependencies: [TenantContext, GetTenantByIdUseCase, RawTenantId]\n});\n"],"names":["DEFAULT_TENANT_ID","createBootstrapRootTenant","now","Date","RequestTenantLoaderImpl","tenantContext","getTenantById","rawTenantId","resolvedId","result","console","RequestTenantLoader","Abstraction","TenantContext","GetTenantByIdUseCase","RawTenantId"],"mappings":";;;AAQA,MAAMA,oBAAoB;AAQ1B,MAAMC,4BAA4B;IAC9B,MAAMC,MAAM,IAAIC,OAAO,WAAW;IAClC,OAAO;QACH,IAAIH;QACJ,MAAM;QACN,aAAa;QACb,QAAQ;QACR,aAAa;QACb,UAAU;YACN,MAAM;gBAAE,MAAM;gBAAQ,MAAM;YAAO;YACnC,QAAQ,CAAC;YACT,SAAS,CAAC;YACV,MAAM,CAAC;QACX;QACA,MAAM,EAAE;QACR,QAAQ;QACR,WAAWE;QACX,SAASA;IACb;AACJ;AAMO,MAAME;IACT,YACYC,aAA6B,EAC7BC,aAAoC,EACpCC,WAAyB,CACnC;aAHUF,aAAa,GAAbA;aACAC,aAAa,GAAbA;aACAC,WAAW,GAAXA;IACT;IAEH,MAAM,YAA2B;QAC7B,MAAMC,aAAa,IAAI,CAAC,WAAW,CAAC,GAAG,MAAMR;QAC7C,MAAMS,SAAS,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAACD;QAChD,IAAIC,OAAO,IAAI,IAAI,YACf,IAAI,CAAC,aAAa,CAAC,SAAS,CAACA,OAAO,KAAK;QAO7C,IAAID,eAAeR,mBAAmB,YAClC,IAAI,CAAC,aAAa,CAAC,SAAS,CAACC;QAIjCS,QAAQ,IAAI,CAAC,CAAC,8BAA8B,EAAEF,WAAW,YAAY,CAAC;IAC1E;AACJ;AAEO,MAAMG,0CAAsBC,oBAAAA,oBAAgC,CAAC;IAChE,gBAAgBR;IAChB,cAAc;QAACS;QAAeC;QAAsBC;KAAY;AACpE"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-request holder for the raw tenant id EXTRACTED by the transport (e.g. the `x-tenant` header
|
|
3
|
+
* of an API Gateway event, the bucket name of an S3 event, or `payload.tenant` of a background
|
|
4
|
+
* task). The transport-specific EXTRACT step sets this; the transport-agnostic LOAD step
|
|
5
|
+
* (RequestTenantLoader) reads it, resolves the Tenant, and sets TenantContext.
|
|
6
|
+
*/
|
|
7
|
+
export interface IRawTenantId {
|
|
8
|
+
get(): string | null;
|
|
9
|
+
set(id: string | null): void;
|
|
10
|
+
}
|
|
11
|
+
export declare const RawTenantId: import("@webiny/di").Abstraction<IRawTenantId>;
|
|
12
|
+
export declare namespace RawTenantId {
|
|
13
|
+
type Interface = IRawTenantId;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Per-request holder for the raw auth token EXTRACTED by the transport (e.g. the `Authorization`
|
|
17
|
+
* bearer header or an auth cookie of an API Gateway event). Only token-based transports set this;
|
|
18
|
+
* the transport-agnostic LOAD step (RequestIdentityLoader) reads it, authenticates it, and
|
|
19
|
+
* sets IdentityContext. A null/absent value authenticates as anonymous.
|
|
20
|
+
*
|
|
21
|
+
* Note: non-token transports (S3, background tasks) never set this — S3 has no user identity, and
|
|
22
|
+
* background-task identity is derived from `task.createdBy` after the task is fetched.
|
|
23
|
+
*/
|
|
24
|
+
export interface IRawAuthToken {
|
|
25
|
+
get(): string | null;
|
|
26
|
+
set(token: string | null): void;
|
|
27
|
+
}
|
|
28
|
+
export declare const RawAuthToken: import("@webiny/di").Abstraction<IRawAuthToken>;
|
|
29
|
+
export declare namespace RawAuthToken {
|
|
30
|
+
type Interface = IRawAuthToken;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Per-request holder for the role or team the caller asked to be evaluated as, EXTRACTED by the
|
|
34
|
+
* transport from the `x-webiny-assume-permissions` header. This is a preview mechanism: it can
|
|
35
|
+
* only ever narrow what a caller may do, never widen it. AssumedPermissions reads this holder and
|
|
36
|
+
* substitutes the permission set, but only after confirming the caller's own permissions grant
|
|
37
|
+
* full access.
|
|
38
|
+
*
|
|
39
|
+
* Note: only the HTTP transports set this. S3 and background tasks have no caller to preview as.
|
|
40
|
+
*/
|
|
41
|
+
export interface IAssumePermissionsTarget {
|
|
42
|
+
type: "role" | "team";
|
|
43
|
+
id: string;
|
|
44
|
+
}
|
|
45
|
+
export interface IRawAssumePermissions {
|
|
46
|
+
get(): IAssumePermissionsTarget | null;
|
|
47
|
+
set(value: IAssumePermissionsTarget | null): void;
|
|
48
|
+
}
|
|
49
|
+
export declare const RawAssumePermissions: import("@webiny/di").Abstraction<IRawAssumePermissions>;
|
|
50
|
+
export declare namespace RawAssumePermissions {
|
|
51
|
+
type Interface = IRawAssumePermissions;
|
|
52
|
+
type Target = IAssumePermissionsTarget;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* LOAD step: authenticates the token held by RawAuthToken and sets IdentityContext. Fully
|
|
56
|
+
* transport-agnostic — transports only EXTRACT the token into RawAuthToken.
|
|
57
|
+
*/
|
|
58
|
+
export interface IRequestIdentityLoader {
|
|
59
|
+
establish(): Promise<void>;
|
|
60
|
+
}
|
|
61
|
+
export declare const RequestIdentityLoader: import("@webiny/di").Abstraction<IRequestIdentityLoader>;
|
|
62
|
+
export declare namespace RequestIdentityLoader {
|
|
63
|
+
type Interface = IRequestIdentityLoader;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* LOAD step: resolves the Tenant for the id held by RawTenantId and sets TenantContext. Fully
|
|
67
|
+
* transport-agnostic — transports only EXTRACT the id into RawTenantId.
|
|
68
|
+
*/
|
|
69
|
+
export interface IRequestTenantLoader {
|
|
70
|
+
establish(): Promise<void>;
|
|
71
|
+
}
|
|
72
|
+
export declare const RequestTenantLoader: import("@webiny/di").Abstraction<IRequestTenantLoader>;
|
|
73
|
+
export declare namespace RequestTenantLoader {
|
|
74
|
+
type Interface = IRequestTenantLoader;
|
|
75
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/api";
|
|
2
|
+
const RawTenantId = createAbstraction("RequestContext/RawTenantId");
|
|
3
|
+
const RawAuthToken = createAbstraction("RequestContext/RawAuthToken");
|
|
4
|
+
const RawAssumePermissions = createAbstraction("RequestContext/RawAssumePermissions");
|
|
5
|
+
const RequestIdentityLoader = createAbstraction("RequestContext/RequestIdentityLoader");
|
|
6
|
+
const RequestTenantLoader = createAbstraction("RequestContext/RequestTenantLoader");
|
|
7
|
+
export { RawAssumePermissions, RawAuthToken, RawTenantId, RequestIdentityLoader, RequestTenantLoader };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"features/requestContext/abstractions.js","sources":["../../../src/features/requestContext/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/api\";\n\n/**\n * Per-request holder for the raw tenant id EXTRACTED by the transport (e.g. the `x-tenant` header\n * of an API Gateway event, the bucket name of an S3 event, or `payload.tenant` of a background\n * task). The transport-specific EXTRACT step sets this; the transport-agnostic LOAD step\n * (RequestTenantLoader) reads it, resolves the Tenant, and sets TenantContext.\n */\nexport interface IRawTenantId {\n get(): string | null;\n set(id: string | null): void;\n}\n\nexport const RawTenantId = createAbstraction<IRawTenantId>(\"RequestContext/RawTenantId\");\n\nexport namespace RawTenantId {\n export type Interface = IRawTenantId;\n}\n\n/**\n * Per-request holder for the raw auth token EXTRACTED by the transport (e.g. the `Authorization`\n * bearer header or an auth cookie of an API Gateway event). Only token-based transports set this;\n * the transport-agnostic LOAD step (RequestIdentityLoader) reads it, authenticates it, and\n * sets IdentityContext. A null/absent value authenticates as anonymous.\n *\n * Note: non-token transports (S3, background tasks) never set this — S3 has no user identity, and\n * background-task identity is derived from `task.createdBy` after the task is fetched.\n */\nexport interface IRawAuthToken {\n get(): string | null;\n set(token: string | null): void;\n}\n\nexport const RawAuthToken = createAbstraction<IRawAuthToken>(\"RequestContext/RawAuthToken\");\n\nexport namespace RawAuthToken {\n export type Interface = IRawAuthToken;\n}\n\n/**\n * Per-request holder for the role or team the caller asked to be evaluated as, EXTRACTED by the\n * transport from the `x-webiny-assume-permissions` header. This is a preview mechanism: it can\n * only ever narrow what a caller may do, never widen it. AssumedPermissions reads this holder and\n * substitutes the permission set, but only after confirming the caller's own permissions grant\n * full access.\n *\n * Note: only the HTTP transports set this. S3 and background tasks have no caller to preview as.\n */\nexport interface IAssumePermissionsTarget {\n /*\n * Whose permissions to assume. A team is a set of roles, so assuming one means the union of its\n * roles' permissions. Assuming a user's permissions would be another type here, resolved to\n * that user's roles and teams the same way.\n */\n type: \"role\" | \"team\";\n id: string;\n}\n\nexport interface IRawAssumePermissions {\n get(): IAssumePermissionsTarget | null;\n set(value: IAssumePermissionsTarget | null): void;\n}\n\nexport const RawAssumePermissions = createAbstraction<IRawAssumePermissions>(\n \"RequestContext/RawAssumePermissions\"\n);\n\nexport namespace RawAssumePermissions {\n export type Interface = IRawAssumePermissions;\n export type Target = IAssumePermissionsTarget;\n}\n\n/**\n * LOAD step: authenticates the token held by RawAuthToken and sets IdentityContext. Fully\n * transport-agnostic — transports only EXTRACT the token into RawAuthToken.\n */\nexport interface IRequestIdentityLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestIdentityLoader = createAbstraction<IRequestIdentityLoader>(\n \"RequestContext/RequestIdentityLoader\"\n);\n\nexport namespace RequestIdentityLoader {\n export type Interface = IRequestIdentityLoader;\n}\n\n/**\n * LOAD step: resolves the Tenant for the id held by RawTenantId and sets TenantContext. Fully\n * transport-agnostic — transports only EXTRACT the id into RawTenantId.\n */\nexport interface IRequestTenantLoader {\n establish(): Promise<void>;\n}\n\nexport const RequestTenantLoader = createAbstraction<IRequestTenantLoader>(\n \"RequestContext/RequestTenantLoader\"\n);\n\nexport namespace RequestTenantLoader {\n export type Interface = IRequestTenantLoader;\n}\n"],"names":["RawTenantId","createAbstraction","RawAuthToken","RawAssumePermissions","RequestIdentityLoader","RequestTenantLoader"],"mappings":";AAaO,MAAMA,cAAcC,kBAAgC;AAoBpD,MAAMC,eAAeD,kBAAiC;AA8BtD,MAAME,uBAAuBF,kBAChC;AAgBG,MAAMG,wBAAwBH,kBACjC;AAeG,MAAMI,sBAAsBJ,kBAC/B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RawAssumePermissions } from "./abstractions.js";
|
|
2
|
+
export declare const ASSUME_PERMISSIONS_HEADER = "x-webiny-assume-permissions";
|
|
3
|
+
type HeaderValue = string | string[] | undefined;
|
|
4
|
+
type Headers = Record<string, HeaderValue> | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Reads the `x-webiny-assume-permissions` header and parses it into the role or team whose
|
|
7
|
+
* permissions should be previewed. The value is `role:<id>` or `team:<id>`.
|
|
8
|
+
*
|
|
9
|
+
* Anything else parses to null, which leaves the caller's own permissions untouched. Lives in
|
|
10
|
+
* api-core rather than in a transport package so the HTTP transports cannot drift on the format or
|
|
11
|
+
* on header casing.
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractAssumePermissions(headers: Headers): RawAssumePermissions.Target | null;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const ASSUME_PERMISSIONS_HEADER = "x-webiny-assume-permissions";
|
|
2
|
+
function readHeader(headers, name) {
|
|
3
|
+
if (!headers) return null;
|
|
4
|
+
for (const key of Object.keys(headers)){
|
|
5
|
+
if (key.toLowerCase() !== name) continue;
|
|
6
|
+
const value = headers[key];
|
|
7
|
+
if (Array.isArray(value)) return value[0] ?? null;
|
|
8
|
+
return value ?? null;
|
|
9
|
+
}
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
function extractAssumePermissions(headers) {
|
|
13
|
+
const value = readHeader(headers, ASSUME_PERMISSIONS_HEADER);
|
|
14
|
+
if (!value) return null;
|
|
15
|
+
const separatorIndex = value.indexOf(":");
|
|
16
|
+
if (separatorIndex < 1) return null;
|
|
17
|
+
const type = value.slice(0, separatorIndex).trim();
|
|
18
|
+
const id = value.slice(separatorIndex + 1).trim();
|
|
19
|
+
if ("" === id) return null;
|
|
20
|
+
if ("role" === type) return {
|
|
21
|
+
type: "role",
|
|
22
|
+
id
|
|
23
|
+
};
|
|
24
|
+
if ("team" === type) return {
|
|
25
|
+
type: "team",
|
|
26
|
+
id
|
|
27
|
+
};
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
export { ASSUME_PERMISSIONS_HEADER, extractAssumePermissions };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=extractAssumePermissions.js.map
|