@kne/fastify-app-manager 0.1.38 → 0.1.40

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.
@@ -131,8 +131,9 @@ const filenameOf = (url, mimetype) => {
131
131
  };
132
132
 
133
133
  /**
134
- * 从远程应用前端站点获取图标:首页 <link rel=icon/apple-touch-icon>、web manifest icons、/favicon.ico 全部作为候选,
135
- * 逐个下载后读真实像素尺寸,取最大的一张(站点没声明 sizes 也能比出大小);尺寸相同按 touch > icon > manifest > favicon.ico,普通图优先于 maskable。
134
+ * 从远程应用前端站点获取图标:首页 <link rel=icon/apple-touch-icon>、web manifest icons(首页没声明时探测 /manifest.json)、
135
+ * /apple-touch-icon.png、/favicon.ico 全部作为候选,
136
+ * 逐个下载后读真实像素尺寸,取最大的一张(站点没声明 sizes 也能比出大小);尺寸相同按 touch > icon > manifest > 约定路径 > favicon.ico,普通图优先于 maskable。
136
137
  * 只接受 image/* 且不超过 1MB 的响应(SPA 对未知路径回落 HTML 的会被丢弃)。
137
138
  * 失败返回 null,不抛错。
138
139
  */
@@ -148,24 +149,26 @@ const discoverRemoteIcon = async ({ baseUrl, timeoutMs = 5000, fetchImpl = fetch
148
149
 
149
150
  const candidates = [];
150
151
  const pageUrl = `${base}/`;
152
+ let declaredManifestUrl = null;
151
153
  try {
152
154
  const page = await request(pageUrl, 'text/html');
153
155
  if (page) {
154
156
  const { icons, manifestUrl } = parseHtmlIcons(await page.text(), pageUrl);
155
157
  candidates.push(...icons);
156
- if (manifestUrl) {
157
- try {
158
- const manifestRes = await request(manifestUrl, 'application/manifest+json,application/json');
159
- candidates.push(...parseManifestIcons(manifestRes ? await manifestRes.json() : null, manifestUrl));
160
- } catch (e) {
161
- // manifest 取不到不影响后续候选
162
- }
163
- }
158
+ declaredManifestUrl = manifestUrl;
164
159
  }
165
160
  } catch (e) {
166
- // 首页取不到,退回 /favicon.ico
161
+ // 首页取不到,仍按约定路径探测
162
+ }
163
+ // 首页没声明 manifest(老页面、或首页取不到)时按约定路径 /manifest.json 探测:站点常把 manifest 放在根路径却没在 HTML 里引用
164
+ const manifestUrl = declaredManifestUrl || `${base}/manifest.json`;
165
+ try {
166
+ const manifestRes = await request(manifestUrl, 'application/manifest+json,application/json');
167
+ candidates.push(...parseManifestIcons(manifestRes ? await manifestRes.json() : null, manifestUrl));
168
+ } catch (e) {
169
+ // manifest 取不到、或被 SPA 回落成 HTML 无法解析,不影响后续候选
167
170
  }
168
- candidates.push({ url: `${base}/favicon.ico`, size: 0 });
171
+ candidates.push({ url: `${base}/apple-touch-icon.png`, size: 0 }, { url: `${base}/favicon.ico`, size: 0 });
169
172
 
170
173
  const unique = [...new Map(candidates.map(item => [item.url, item])).values()].slice(0, MAX_CANDIDATES);
171
174
  const fetched = await Promise.all(
package/oidc.js CHANGED
@@ -292,6 +292,11 @@ const createAppOidc = (fastify, { origin, issuer, serviceAudience, pathPrefix =
292
292
  }
293
293
  const { models, services } = oidc();
294
294
  await oidc().whenReady();
295
+ // 关联应用登记在 OIDC 应用注册表里:标记删除后通知远程关闭由宿主同步过去的托管租户
296
+ const registered = app.name && services.app?.findByCode?.(app.name);
297
+ if (registered && registered.status !== 'removed' && registered.serviceClientId === serviceClientId) {
298
+ await services.app.remove({ id: registered.id });
299
+ }
295
300
  for (const id of [clientId, serviceClientId].filter(Boolean)) {
296
301
  const item = await models.client.findOne({ where: { clientId: id } });
297
302
  if (item) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kne/fastify-app-manager",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "Fastify 单机应用市场插件:版本上传、PM2 托管、路径/域名反代与日志 SSE",
5
5
  "main": "index.js",
6
6
  "scripts": {