@kne/fastify-oidc 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +216 -8
- package/index.js +40 -2
- package/libs/controllers/admin.js +30 -0
- package/libs/controllers/service.js +141 -18
- package/libs/controllers/tenant-apps.js +31 -0
- package/libs/controllers/tenant-proxy.js +64 -0
- package/libs/controllers/tenant-sync.js +59 -0
- package/libs/idp/adapters/sequelize.js +19 -1
- package/libs/idp/create-provider.js +13 -5
- package/libs/idp/identity.js +151 -20
- package/libs/idp/index.js +20 -1
- package/libs/locale/en-US.js +9 -1
- package/libs/locale/zh-CN.js +9 -1
- package/libs/models/app.js +65 -0
- package/libs/resource/app-registry.js +76 -0
- package/libs/resource/authenticate.js +41 -3
- package/libs/resource/remote-tenant.js +7 -0
- package/libs/resource/service-client.js +25 -8
- package/libs/resource/tenant-sync.js +171 -0
- package/libs/resource/verify-token.js +16 -1
- package/libs/services/app.js +178 -0
- package/libs/services/interaction.js +3 -2
- package/libs/services/resource-server.js +13 -2
- package/libs/services/tenant-push.js +133 -0
- package/libs/utils/app-permissions.js +52 -0
- package/libs/utils/resolve-options.js +30 -0
- package/libs/utils/tenant-images.js +34 -0
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const COMPANY_FIELDS = ['name', 'fullName', 'logo', 'industry', 'scale', 'address', 'phone', 'email', 'foundedDate', 'companyTags', 'website', 'description', 'banners', 'teamDescription', 'developmentHistory', 'contact'];
|
|
2
|
+
|
|
3
|
+
const isFileId = value => typeof value === 'string' && value !== '';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 租户快照里引用宿主文件库的图片:租户 logo、公司 logo / banner / 团队头像 / 发展历程图片。
|
|
7
|
+
* mapper 收到宿主文件 id,返回替换后的值
|
|
8
|
+
*/
|
|
9
|
+
const mapTenantImages = (tenant, mapper) => {
|
|
10
|
+
const map = value => (isFileId(value) ? mapper(value) : value);
|
|
11
|
+
const mapList = list => (Array.isArray(list) ? list.map(map) : list);
|
|
12
|
+
const result = Object.assign({}, tenant);
|
|
13
|
+
if ('logo' in tenant) {
|
|
14
|
+
result.logo = map(tenant.logo);
|
|
15
|
+
}
|
|
16
|
+
const { company } = tenant;
|
|
17
|
+
if (company) {
|
|
18
|
+
result.company = Object.assign({}, company, {
|
|
19
|
+
logo: map(company.logo),
|
|
20
|
+
banners: mapList(company.banners),
|
|
21
|
+
teamDescription: Array.isArray(company.teamDescription) ? company.teamDescription.map(item => (item ? Object.assign({}, item, { avatar: map(item.avatar) }) : item)) : company.teamDescription,
|
|
22
|
+
developmentHistory: Array.isArray(company.developmentHistory) ? company.developmentHistory.map(item => (item ? Object.assign({}, item, { images: mapList(item.images) }) : item)) : company.developmentHistory
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const collectTenantImages = tenant => {
|
|
29
|
+
const ids = new Set();
|
|
30
|
+
mapTenantImages(tenant, id => ids.add(id) && id);
|
|
31
|
+
return [...ids];
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
module.exports = { COMPANY_FIELDS, mapTenantImages, collectTenantImages };
|