@blocklet/meta 1.16.33-beta-20241024-064549-2c1ad302 → 1.16.33-beta-20241028-005826-60afb7c4
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/lib/util-meta.js +4 -1
- package/lib/util.d.ts +5 -11
- package/lib/util.js +43 -43
- package/package.json +5 -5
package/lib/util-meta.js
CHANGED
|
@@ -18,7 +18,10 @@ const { BLOCKLET_STORE_API_BLOCKLET_PREFIX } = constant_1.default;
|
|
|
18
18
|
// HACK: copy from core/state/lib/util/request.js
|
|
19
19
|
const api = axios_1.default.create({
|
|
20
20
|
timeout: 10 * 1000,
|
|
21
|
-
headers: {
|
|
21
|
+
headers: {
|
|
22
|
+
'User-Agent': `ABTNode/${package_json_1.version}`,
|
|
23
|
+
'x-blocklet-server-version': package_json_1.version,
|
|
24
|
+
},
|
|
22
25
|
});
|
|
23
26
|
const validateUrl = async (url, expectedHttpResTypes = ['application/json', 'text/plain']) => {
|
|
24
27
|
const parsed = new URL(url);
|
package/lib/util.d.ts
CHANGED
|
@@ -119,8 +119,6 @@ declare const findWebInterface: (blocklet?: BlockletState | TBlockletMeta) => an
|
|
|
119
119
|
declare const findDockerInterface: (blocklet?: BlockletState | TBlockletMeta) => any;
|
|
120
120
|
declare const findWebInterfacePort: (blocklet?: BlockletState) => any;
|
|
121
121
|
declare const findServiceFromMeta: (meta?: TBlockletMeta, ServiceName?: string) => any;
|
|
122
|
-
declare const getWhoCanAccess: (blocklet?: BlockletState) => any;
|
|
123
|
-
declare const getComponentWhoCanAccess: (component: TComponent, app?: BlockletState) => string;
|
|
124
122
|
declare const getConnectAppUrl: ({ request, baseUrl }: {
|
|
125
123
|
request: Partial<Request>;
|
|
126
124
|
baseUrl: string;
|
|
@@ -134,9 +132,6 @@ type ChainInfo = {
|
|
|
134
132
|
declare const getChainInfo: (env: Record<string, string>) => ChainInfo;
|
|
135
133
|
declare const getBlockletChainInfo: (blocklet?: TComponentPro) => ChainInfo;
|
|
136
134
|
declare const isExternalBlocklet: (blocklet?: BlockletState) => boolean;
|
|
137
|
-
declare const getRolesFromAuthConfig: (config: {
|
|
138
|
-
whoCanAccess: string;
|
|
139
|
-
}) => Array<string>;
|
|
140
135
|
declare const getBlockletAppIdList: (blocklet: Partial<BlockletState>) => string[];
|
|
141
136
|
declare const getBlockletServices: (blocklet: Partial<BlockletState>) => Array<{
|
|
142
137
|
name: string;
|
|
@@ -152,7 +147,9 @@ declare const hasResourceType: (component: ComponentState, { type, did }?: {
|
|
|
152
147
|
type: string;
|
|
153
148
|
did: string;
|
|
154
149
|
}) => boolean;
|
|
155
|
-
|
|
150
|
+
declare const getMountPoints: (blocklet: any) => any[];
|
|
151
|
+
declare const checkPublicAccess: (securityConfig: any) => boolean;
|
|
152
|
+
export { isFreeBlocklet, isFreeComponent, forEachBlocklet, forEachBlockletSync, forEachChild, forEachChildSync, forEachComponentV2, forEachComponentV2Sync, isDeletableBlocklet, getSharedConfigObj, getAppMissingConfigs, getComponentMissingConfigs, isEnvShareableToClient, isEnvShareable, wipeSensitiveData, hasRunnableComponent, getAppName, getAppName as getDisplayName, getAppDescription, fixBlockletStatus, findWebInterface, findWebInterfacePort, findDockerInterface, findServiceFromMeta, checkPublicAccess, replaceSlotToIp, getComponentId, getComponentName, getComponentBundleId, findComponent, findComponentById, findComponentV2, findComponentByIdV2, filterComponentsV2, getParentComponentName, getConnectAppUrl, getChainInfo, getBlockletChainInfo, isExternalBlocklet, isPreferenceKey, getBlockletAppIdList, getBlockletServices, isInProgress, isBeforeInstalled, isRunning, isAccessible, isGatewayBlocklet, isPackBlocklet, hasStartEngine, hasResourceType, getMountPoints, };
|
|
156
153
|
declare const _default: {
|
|
157
154
|
isFreeBlocklet: (meta: TBlockletMeta) => boolean;
|
|
158
155
|
isFreeComponent: (meta: TBlockletMeta) => boolean;
|
|
@@ -194,8 +191,7 @@ declare const _default: {
|
|
|
194
191
|
findWebInterfacePort: (blocklet?: BlockletState) => any;
|
|
195
192
|
findDockerInterface: (blocklet?: BlockletState | TBlockletMeta) => any;
|
|
196
193
|
findServiceFromMeta: (meta?: TBlockletMeta, ServiceName?: string) => any;
|
|
197
|
-
|
|
198
|
-
getComponentWhoCanAccess: (component: TComponent, app?: BlockletState) => string;
|
|
194
|
+
checkPublicAccess: (securityConfig: any) => boolean;
|
|
199
195
|
replaceSlotToIp: (url?: string, ip?: string) => string;
|
|
200
196
|
getComponentId: (component?: {
|
|
201
197
|
meta?: {
|
|
@@ -248,9 +244,6 @@ declare const _default: {
|
|
|
248
244
|
getBlockletChainInfo: (blocklet?: TComponentPro) => ChainInfo;
|
|
249
245
|
isExternalBlocklet: (blocklet?: BlockletState) => boolean;
|
|
250
246
|
isPreferenceKey: (x: Partial<TConfig>) => Boolean;
|
|
251
|
-
getRolesFromAuthConfig: (config: {
|
|
252
|
-
whoCanAccess: string;
|
|
253
|
-
}) => Array<string>;
|
|
254
247
|
getBlockletServices: (blocklet: Partial<BlockletState>) => Array<{
|
|
255
248
|
name: string;
|
|
256
249
|
protocol: string;
|
|
@@ -268,5 +261,6 @@ declare const _default: {
|
|
|
268
261
|
type: string;
|
|
269
262
|
did: string;
|
|
270
263
|
}) => boolean;
|
|
264
|
+
getMountPoints: (blocklet: any) => any[];
|
|
271
265
|
};
|
|
272
266
|
export default _default;
|
package/lib/util.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isPackBlocklet = exports.isGatewayBlocklet = exports.isAccessible = exports.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = exports.
|
|
7
|
-
exports.
|
|
6
|
+
exports.hasResourceType = exports.hasStartEngine = exports.isPackBlocklet = exports.isGatewayBlocklet = exports.isAccessible = exports.isRunning = exports.isBeforeInstalled = exports.isInProgress = exports.getBlockletServices = exports.getBlockletAppIdList = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getBlockletChainInfo = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.filterComponentsV2 = exports.findComponentByIdV2 = exports.findComponentV2 = exports.findComponentById = exports.findComponent = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.checkPublicAccess = exports.findServiceFromMeta = exports.findDockerInterface = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getAppDescription = exports.getDisplayName = exports.getAppName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.isEnvShareableToClient = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachComponentV2Sync = exports.forEachComponentV2 = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
|
|
7
|
+
exports.getMountPoints = void 0;
|
|
8
8
|
exports.getAppUrl = getAppUrl;
|
|
9
9
|
/* eslint-disable no-await-in-loop */
|
|
10
10
|
const get_1 = __importDefault(require("lodash/get"));
|
|
@@ -17,7 +17,7 @@ const engine_1 = require("./engine");
|
|
|
17
17
|
Object.defineProperty(exports, "hasStartEngine", { enumerable: true, get: function () { return engine_1.hasStartEngine; } });
|
|
18
18
|
Object.defineProperty(exports, "isGatewayBlocklet", { enumerable: true, get: function () { return engine_1.isGatewayBlocklet; } });
|
|
19
19
|
Object.defineProperty(exports, "isPackBlocklet", { enumerable: true, get: function () { return engine_1.isPackBlocklet; } });
|
|
20
|
-
const {
|
|
20
|
+
const { SLOT_FOR_IP_DNS_SITE } = constant_1.default;
|
|
21
21
|
const getComponentId = (component, ancestors = []) => `${ancestors.map((x) => (x && x.meta ? x.meta.did : '')).join('/')}${ancestors.length ? '/' : ''}${component && component.meta ? component.meta.did : ''}`;
|
|
22
22
|
exports.getComponentId = getComponentId;
|
|
23
23
|
const getComponentName = (component, ancestors = []) => `${ancestors.map((x) => (x && x.meta ? x.meta.name : '')).join('/')}${ancestors.length ? '/' : ''}${component && component.meta ? component.meta.name : ''}`;
|
|
@@ -580,36 +580,6 @@ const findServiceFromMeta = (meta, ServiceName) => {
|
|
|
580
580
|
return (webInterface.services || []).find((x) => names.includes(x.name));
|
|
581
581
|
};
|
|
582
582
|
exports.findServiceFromMeta = findServiceFromMeta;
|
|
583
|
-
const getWhoCanAccess = (blocklet) => {
|
|
584
|
-
if (!blocklet) {
|
|
585
|
-
return WHO_CAN_ACCESS.ALL;
|
|
586
|
-
}
|
|
587
|
-
if ((0, get_1.default)(blocklet, 'settings.whoCanAccess')) {
|
|
588
|
-
return blocklet.settings.whoCanAccess;
|
|
589
|
-
}
|
|
590
|
-
// @ts-ignore
|
|
591
|
-
const service = findServiceFromMeta(blocklet.meta, NODE_SERVICES.AUTH);
|
|
592
|
-
if ((0, get_1.default)(service, 'config.whoCanAccess')) {
|
|
593
|
-
return service.config.whoCanAccess;
|
|
594
|
-
}
|
|
595
|
-
return WHO_CAN_ACCESS.ALL;
|
|
596
|
-
};
|
|
597
|
-
exports.getWhoCanAccess = getWhoCanAccess;
|
|
598
|
-
const getComponentWhoCanAccess = (component, app) => {
|
|
599
|
-
const access = (component.configs || []).find((x) => x.key === constant_2.BLOCKLET_CONFIGURABLE_KEY.COMPONENT_ACCESS_WHO);
|
|
600
|
-
if (access) {
|
|
601
|
-
return access.value;
|
|
602
|
-
}
|
|
603
|
-
if (app && (0, get_1.default)(app, 'settings.whoCanAccess') && (0, get_1.default)(app, 'settings.whoCanAccess') !== WHO_CAN_ACCESS.ALL) {
|
|
604
|
-
return (0, get_1.default)(app, 'settings.whoCanAccess');
|
|
605
|
-
}
|
|
606
|
-
const service = findServiceFromMeta(component.meta, NODE_SERVICES.AUTH);
|
|
607
|
-
if ((0, get_1.default)(service, 'config.whoCanAccess')) {
|
|
608
|
-
return service.config.whoCanAccess;
|
|
609
|
-
}
|
|
610
|
-
return WHO_CAN_ACCESS.ALL;
|
|
611
|
-
};
|
|
612
|
-
exports.getComponentWhoCanAccess = getComponentWhoCanAccess;
|
|
613
583
|
const getConnectAppUrl = ({ request, baseUrl }) => {
|
|
614
584
|
const blockletDid = request.headers['x-blocklet-did'] || '';
|
|
615
585
|
const blockletRealDid = request.headers['x-blocklet-real-did'] || '';
|
|
@@ -665,13 +635,6 @@ const getBlockletChainInfo = (blocklet) => {
|
|
|
665
635
|
exports.getBlockletChainInfo = getBlockletChainInfo;
|
|
666
636
|
const isExternalBlocklet = (blocklet) => !!blocklet?.controller;
|
|
667
637
|
exports.isExternalBlocklet = isExternalBlocklet;
|
|
668
|
-
const getRolesFromAuthConfig = (config) => {
|
|
669
|
-
if (!config.whoCanAccess.startsWith(WHO_CAN_ACCESS_PREFIX_ROLES)) {
|
|
670
|
-
return [];
|
|
671
|
-
}
|
|
672
|
-
return config.whoCanAccess.substring(WHO_CAN_ACCESS_PREFIX_ROLES.length).split(',');
|
|
673
|
-
};
|
|
674
|
-
exports.getRolesFromAuthConfig = getRolesFromAuthConfig;
|
|
675
638
|
const getBlockletAppIdList = (blocklet) => {
|
|
676
639
|
const migratedFrom = Array.isArray(blocklet.migratedFrom) ? blocklet.migratedFrom.map((x) => x.appDid) : [];
|
|
677
640
|
return (0, uniq_1.default)([blocklet.appDid, blocklet.appPid, ...migratedFrom].filter(Boolean));
|
|
@@ -746,6 +709,44 @@ const hasResourceType = (component, { type, did } = { type: '', did: '' }) => {
|
|
|
746
709
|
(component.meta.resource.bundles || []).some((y) => y.type === type && y.did === did));
|
|
747
710
|
};
|
|
748
711
|
exports.hasResourceType = hasResourceType;
|
|
712
|
+
const getMountPoints = (blocklet) => {
|
|
713
|
+
const mountPoints = [];
|
|
714
|
+
forEachBlockletSync(blocklet, (component, { level, params: children }) => {
|
|
715
|
+
if ((0, engine_1.hasMountPoint)(component.meta) === false) {
|
|
716
|
+
return null;
|
|
717
|
+
}
|
|
718
|
+
const list = level > 1 ? children : mountPoints;
|
|
719
|
+
if (!list) {
|
|
720
|
+
return null;
|
|
721
|
+
}
|
|
722
|
+
const arr = [];
|
|
723
|
+
list.push({
|
|
724
|
+
title: component.meta?.title || '',
|
|
725
|
+
name: component.meta?.bundleName || '',
|
|
726
|
+
did: component.meta?.bundleDid || '',
|
|
727
|
+
version: component.meta?.version || '',
|
|
728
|
+
status: (0, constant_2.fromBlockletStatus)(component.status),
|
|
729
|
+
mountPoint: (0, ufo_1.joinURL)('/', component.mountPoint || ''),
|
|
730
|
+
components: arr,
|
|
731
|
+
capabilities: component.meta?.capabilities || {},
|
|
732
|
+
});
|
|
733
|
+
return arr;
|
|
734
|
+
});
|
|
735
|
+
return mountPoints;
|
|
736
|
+
};
|
|
737
|
+
exports.getMountPoints = getMountPoints;
|
|
738
|
+
const checkPublicAccess = (securityConfig) => {
|
|
739
|
+
if (!securityConfig) {
|
|
740
|
+
return true;
|
|
741
|
+
}
|
|
742
|
+
const accessRoles = securityConfig?.accessPolicy?.roles ?? null;
|
|
743
|
+
const accessRevert = securityConfig?.accessPolicy?.revert ?? false;
|
|
744
|
+
if (accessRoles === null && accessRevert === false) {
|
|
745
|
+
return true;
|
|
746
|
+
}
|
|
747
|
+
return false;
|
|
748
|
+
};
|
|
749
|
+
exports.checkPublicAccess = checkPublicAccess;
|
|
749
750
|
exports.default = {
|
|
750
751
|
isFreeBlocklet,
|
|
751
752
|
isFreeComponent,
|
|
@@ -772,8 +773,7 @@ exports.default = {
|
|
|
772
773
|
findWebInterfacePort,
|
|
773
774
|
findDockerInterface,
|
|
774
775
|
findServiceFromMeta,
|
|
775
|
-
|
|
776
|
-
getComponentWhoCanAccess,
|
|
776
|
+
checkPublicAccess,
|
|
777
777
|
replaceSlotToIp,
|
|
778
778
|
getComponentId,
|
|
779
779
|
getComponentName,
|
|
@@ -789,7 +789,6 @@ exports.default = {
|
|
|
789
789
|
getBlockletChainInfo,
|
|
790
790
|
isExternalBlocklet,
|
|
791
791
|
isPreferenceKey,
|
|
792
|
-
getRolesFromAuthConfig,
|
|
793
792
|
getBlockletServices,
|
|
794
793
|
isInProgress,
|
|
795
794
|
isBeforeInstalled,
|
|
@@ -799,4 +798,5 @@ exports.default = {
|
|
|
799
798
|
isPackBlocklet: engine_1.isPackBlocklet,
|
|
800
799
|
hasStartEngine: engine_1.hasStartEngine,
|
|
801
800
|
hasResourceType,
|
|
801
|
+
getMountPoints,
|
|
802
802
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.33-beta-
|
|
6
|
+
"version": "1.16.33-beta-20241028-005826-60afb7c4",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
26
26
|
"license": "Apache-2.0",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@abtnode/constant": "1.16.33-beta-
|
|
28
|
+
"@abtnode/constant": "1.16.33-beta-20241028-005826-60afb7c4",
|
|
29
29
|
"@arcblock/did": "1.18.136",
|
|
30
30
|
"@arcblock/did-ext": "1.18.136",
|
|
31
31
|
"@arcblock/did-util": "1.18.136",
|
|
32
32
|
"@arcblock/jwt": "1.18.136",
|
|
33
|
-
"@blocklet/constant": "1.16.33-beta-
|
|
33
|
+
"@blocklet/constant": "1.16.33-beta-20241028-005826-60afb7c4",
|
|
34
34
|
"@ocap/asset": "1.18.136",
|
|
35
35
|
"@ocap/mcrypto": "1.18.136",
|
|
36
36
|
"@ocap/types": "1.18.136",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"validate-npm-package-name": "^3.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@arcblock/eslint-config-ts": "^0.3.
|
|
62
|
+
"@arcblock/eslint-config-ts": "^0.3.3",
|
|
63
63
|
"@types/express": "^5.0.0",
|
|
64
64
|
"@types/jest": "^29.5.13",
|
|
65
65
|
"@types/joi": "^17.2.3",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"ts-node": "^10.9.1",
|
|
80
80
|
"typescript": "^5.6.3"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "12b595141a023fe3c3fdb2d7083b3f11624601e8"
|
|
83
83
|
}
|