@blocklet/meta 1.8.66 → 1.8.67-beta-794a8082
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/channel.d.ts +9 -4
- package/lib/channel.js +19 -4
- package/lib/did.js +3 -0
- package/lib/extension.d.ts +4 -0
- package/lib/extension.js +4 -0
- package/lib/file.d.ts +2 -0
- package/lib/file.js +6 -1
- package/lib/fix.d.ts +3 -0
- package/lib/fix.js +15 -1
- package/lib/index.d.ts +6 -2
- package/lib/index.js +5 -1
- package/lib/name.d.ts +6 -0
- package/lib/name.js +28 -4
- package/lib/parse-navigation-from-blocklet.js +29 -25
- package/lib/parse-navigation.js +13 -6
- package/lib/parse.js +8 -5
- package/lib/payment/v2.js +52 -60
- package/lib/schema.d.ts +3 -1
- package/lib/schema.js +79 -32
- package/lib/service.js +7 -1
- package/lib/types/schema.d.ts +2 -1
- package/lib/url-friendly.d.ts +2 -0
- package/lib/url-friendly.js +7 -1
- package/lib/util-meta.js +14 -23
- package/lib/util.d.ts +32 -6
- package/lib/util.js +37 -23
- package/lib/validate.js +5 -2
- package/lib/verify-multi-sig.js +3 -14
- package/package.json +17 -16
package/lib/util-meta.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -22,7 +13,7 @@ const constant_1 = __importDefault(require("@abtnode/constant"));
|
|
|
22
13
|
const did_1 = __importDefault(require("./did"));
|
|
23
14
|
const validate_1 = require("./validate");
|
|
24
15
|
const { BLOCKLET_STORE_API_BLOCKLET_PREFIX } = constant_1.default;
|
|
25
|
-
const validateUrl = (url, expectedHttpResTypes = ['application/json', 'text/plain']) =>
|
|
16
|
+
const validateUrl = async (url, expectedHttpResTypes = ['application/json', 'text/plain']) => {
|
|
26
17
|
const parsed = new URL(url);
|
|
27
18
|
const { protocol } = parsed;
|
|
28
19
|
// file
|
|
@@ -37,7 +28,7 @@ const validateUrl = (url, expectedHttpResTypes = ['application/json', 'text/plai
|
|
|
37
28
|
if (protocol.startsWith('http')) {
|
|
38
29
|
let res;
|
|
39
30
|
try {
|
|
40
|
-
res =
|
|
31
|
+
res = await (0, axios_1.default)({ url, method: 'HEAD', timeout: 1000 * 10 });
|
|
41
32
|
}
|
|
42
33
|
catch (err) {
|
|
43
34
|
throw new Error(`Cannot get content-type from ${url}: ${err.message}`);
|
|
@@ -49,36 +40,36 @@ const validateUrl = (url, expectedHttpResTypes = ['application/json', 'text/plai
|
|
|
49
40
|
return true;
|
|
50
41
|
}
|
|
51
42
|
throw new Error(`Invalid url protocol: ${protocol.replace(/:$/, '')}`);
|
|
52
|
-
}
|
|
43
|
+
};
|
|
53
44
|
exports.validateUrl = validateUrl;
|
|
54
45
|
const validateBlockletMeta = (meta, opts = {}) => {
|
|
55
46
|
(0, validate_1.fixAndValidateService)(meta);
|
|
56
47
|
return (0, validate_1.validateMeta)(meta, opts);
|
|
57
48
|
};
|
|
58
|
-
const getBlockletMetaByUrl = (url) =>
|
|
49
|
+
const getBlockletMetaByUrl = async (url) => {
|
|
59
50
|
const { protocol } = new URL(url);
|
|
60
51
|
if (protocol.startsWith('file')) {
|
|
61
52
|
const decoded = decodeURIComponent((0, url_1.fileURLToPath)(url));
|
|
62
53
|
if (!fs_1.default.existsSync(decoded)) {
|
|
63
54
|
throw new Error(`File does not exist: ${decoded}`);
|
|
64
55
|
}
|
|
65
|
-
const d =
|
|
56
|
+
const d = await fs_1.default.promises.readFile(decoded);
|
|
66
57
|
// @ts-expect-error TS(2345) FIXME: Argument of type 'Buffer' is not assignable to par... Remove this comment to see the full error message
|
|
67
58
|
const meta = JSON.parse(d);
|
|
68
59
|
return meta;
|
|
69
60
|
}
|
|
70
61
|
if (protocol.startsWith('http')) {
|
|
71
|
-
const { data: meta } =
|
|
62
|
+
const { data: meta } = await (0, axios_1.default)({ url, method: 'GET', timeout: 1000 * 20 });
|
|
72
63
|
if (Object.prototype.toString.call(meta) !== '[object Object]') {
|
|
73
64
|
throw new Error('Url is not valid');
|
|
74
65
|
}
|
|
75
66
|
return meta;
|
|
76
67
|
}
|
|
77
68
|
throw new Error(`Invalid url protocol: ${protocol.replace(/:$/, '')}`);
|
|
78
|
-
}
|
|
69
|
+
};
|
|
79
70
|
exports.getBlockletMetaByUrl = getBlockletMetaByUrl;
|
|
80
|
-
const getBlockletMetaFromUrl = (url, { validateFn = validateBlockletMeta, returnUrl = false, ensureTarball = true, logger, } = {}) =>
|
|
81
|
-
const meta =
|
|
71
|
+
const getBlockletMetaFromUrl = async (url, { validateFn = validateBlockletMeta, returnUrl = false, ensureTarball = true, logger, } = {}) => {
|
|
72
|
+
const meta = await getBlockletMetaByUrl(url);
|
|
82
73
|
delete meta.htmlAst;
|
|
83
74
|
const newMeta = validateFn(meta, { ensureDist: true });
|
|
84
75
|
if (ensureTarball) {
|
|
@@ -86,7 +77,7 @@ const getBlockletMetaFromUrl = (url, { validateFn = validateBlockletMeta, return
|
|
|
86
77
|
const { href } = new URL(newMeta.dist.tarball, url);
|
|
87
78
|
const tarball = decodeURIComponent(href);
|
|
88
79
|
try {
|
|
89
|
-
|
|
80
|
+
await validateUrl(tarball, ['application/octet-stream', 'application/x-gzip']);
|
|
90
81
|
}
|
|
91
82
|
catch (error) {
|
|
92
83
|
if (!error.message.startsWith('Cannot get content-type')) {
|
|
@@ -107,11 +98,11 @@ const getBlockletMetaFromUrl = (url, { validateFn = validateBlockletMeta, return
|
|
|
107
98
|
return { meta: newMeta, url };
|
|
108
99
|
}
|
|
109
100
|
return newMeta;
|
|
110
|
-
}
|
|
101
|
+
};
|
|
111
102
|
exports.getBlockletMetaFromUrl = getBlockletMetaFromUrl;
|
|
112
|
-
const getBlockletMetaFromUrls = (urls, { validateFn, returnUrl = false, ensureTarball = true, logger, } = {}) =>
|
|
103
|
+
const getBlockletMetaFromUrls = async (urls, { validateFn, returnUrl = false, ensureTarball = true, logger, } = {}) => {
|
|
113
104
|
try {
|
|
114
|
-
const res =
|
|
105
|
+
const res = await (0, promise_any_1.default)(urls.map((url) => getBlockletMetaFromUrl(url, { validateFn, returnUrl, ensureTarball, logger })));
|
|
115
106
|
return res;
|
|
116
107
|
}
|
|
117
108
|
catch (err) {
|
|
@@ -124,7 +115,7 @@ const getBlockletMetaFromUrls = (urls, { validateFn, returnUrl = false, ensureTa
|
|
|
124
115
|
}
|
|
125
116
|
throw new Error(message);
|
|
126
117
|
}
|
|
127
|
-
}
|
|
118
|
+
};
|
|
128
119
|
exports.getBlockletMetaFromUrls = getBlockletMetaFromUrls;
|
|
129
120
|
/**
|
|
130
121
|
* @param {*} config defined in componentSchema in blocklet meta schema
|
package/lib/util.d.ts
CHANGED
|
@@ -54,10 +54,21 @@ declare const forEachBlocklet: (blocklet: BlockletState | ComponentState, cb: Fu
|
|
|
54
54
|
declare const forEachBlockletSync: (blocklet: any, cb: Function) => Promise<unknown>;
|
|
55
55
|
declare const forEachChild: (blocklet: any, cb: Function, params?: any) => Promise<any>;
|
|
56
56
|
declare const forEachChildSync: (blocklet: BlockletState, cb: Function) => Promise<any>;
|
|
57
|
-
declare const
|
|
58
|
-
|
|
57
|
+
declare const findComponent: (blocklet: BlockletState | ComponentState, isEqualFn: (component: ComponentState, context: {
|
|
58
|
+
ancestors: Array<ComponentState>;
|
|
59
|
+
}) => boolean, { _ancestors, returnAncestors, }?: {
|
|
60
|
+
_ancestors?: Array<ComponentState>;
|
|
61
|
+
returnAncestors?: boolean;
|
|
62
|
+
}) => ComponentState | {
|
|
63
|
+
component: ComponentState;
|
|
64
|
+
ancestors: Array<ComponentState>;
|
|
65
|
+
};
|
|
66
|
+
declare const findComponentById: (blocklet: BlockletState | ComponentState, componentId: string | Array<string>, { returnAncestors, }?: {
|
|
59
67
|
returnAncestors?: boolean;
|
|
60
|
-
}) =>
|
|
68
|
+
}) => ComponentState | {
|
|
69
|
+
component: ComponentState;
|
|
70
|
+
ancestors: Array<ComponentState>;
|
|
71
|
+
};
|
|
61
72
|
declare const isEnvShareable: (env?: TConfig) => boolean;
|
|
62
73
|
declare const getSharedConfigObj: (component: BlockletState, ancestors?: any[]) => any;
|
|
63
74
|
declare const isPreferenceKey: (x: TConfig) => Boolean;
|
|
@@ -78,6 +89,7 @@ declare const hasRunnableComponent: (blocklet: BlockletState) => boolean;
|
|
|
78
89
|
declare const getDisplayName: (blocklet: BlockletState, onlyUseMeta?: boolean) => string;
|
|
79
90
|
declare const fixBlockletStatus: (blocklet?: BlockletState) => void;
|
|
80
91
|
declare const findWebInterface: (blocklet?: BlockletState | TBlockletMeta) => any;
|
|
92
|
+
declare const findWebInterfacePort: (blocklet?: BlockletState) => any;
|
|
81
93
|
declare const findServiceFromMeta: (meta?: TBlockletMeta, ServiceName?: string) => any;
|
|
82
94
|
declare const getWhoCanAccess: (blocklet?: BlockletState) => any;
|
|
83
95
|
declare const getConnectAppUrl: ({ request, baseUrl }: {
|
|
@@ -107,12 +119,14 @@ export { hasRunnableComponent };
|
|
|
107
119
|
export { getDisplayName };
|
|
108
120
|
export { fixBlockletStatus };
|
|
109
121
|
export { findWebInterface };
|
|
122
|
+
export { findWebInterfacePort };
|
|
110
123
|
export { findServiceFromMeta };
|
|
111
124
|
export { getWhoCanAccess };
|
|
112
125
|
export { replaceSlotToIp };
|
|
113
126
|
export { getComponentId };
|
|
114
127
|
export { getComponentName };
|
|
115
128
|
export { getComponentBundleId };
|
|
129
|
+
export { findComponent };
|
|
116
130
|
export { findComponentById };
|
|
117
131
|
export { getParentComponentName };
|
|
118
132
|
export { getConnectAppUrl };
|
|
@@ -149,6 +163,7 @@ declare const _default: {
|
|
|
149
163
|
getDisplayName: (blocklet: BlockletState, onlyUseMeta?: boolean) => string;
|
|
150
164
|
fixBlockletStatus: (blocklet?: BlockletState) => void;
|
|
151
165
|
findWebInterface: (blocklet?: TBlockletMeta | BlockletState) => any;
|
|
166
|
+
findWebInterfacePort: (blocklet?: BlockletState) => any;
|
|
152
167
|
findServiceFromMeta: (meta?: TBlockletMeta, ServiceName?: string) => any;
|
|
153
168
|
getWhoCanAccess: (blocklet?: BlockletState) => any;
|
|
154
169
|
replaceSlotToIp: (url?: string, ip?: string) => string;
|
|
@@ -176,10 +191,21 @@ declare const _default: {
|
|
|
176
191
|
version: string;
|
|
177
192
|
};
|
|
178
193
|
}) => string;
|
|
179
|
-
|
|
180
|
-
|
|
194
|
+
findComponent: (blocklet: BlockletState | ComponentState, isEqualFn: (component: ComponentState, context: {
|
|
195
|
+
ancestors: ComponentState[];
|
|
196
|
+
}) => boolean, { _ancestors, returnAncestors, }?: {
|
|
197
|
+
_ancestors?: ComponentState[];
|
|
198
|
+
returnAncestors?: boolean;
|
|
199
|
+
}) => ComponentState | {
|
|
200
|
+
component: ComponentState;
|
|
201
|
+
ancestors: ComponentState[];
|
|
202
|
+
};
|
|
203
|
+
findComponentById: (blocklet: BlockletState | ComponentState, componentId: string | string[], { returnAncestors, }?: {
|
|
181
204
|
returnAncestors?: boolean;
|
|
182
|
-
}) =>
|
|
205
|
+
}) => ComponentState | {
|
|
206
|
+
component: ComponentState;
|
|
207
|
+
ancestors: ComponentState[];
|
|
208
|
+
};
|
|
183
209
|
getParentComponentName: (name?: string) => string;
|
|
184
210
|
getConnectAppUrl: ({ request, baseUrl }: {
|
|
185
211
|
request: Partial<Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>>;
|
package/lib/util.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.findComponentById = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterface = exports.fixBlockletStatus = exports.getDisplayName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
|
|
6
|
+
exports.getRolesFromAuthConfig = exports.isPreferenceKey = exports.isExternalBlocklet = exports.getChainInfo = exports.getConnectAppUrl = exports.getParentComponentName = exports.findComponentById = exports.findComponent = exports.getComponentBundleId = exports.getComponentName = exports.getComponentId = exports.replaceSlotToIp = exports.getWhoCanAccess = exports.findServiceFromMeta = exports.findWebInterfacePort = exports.findWebInterface = exports.fixBlockletStatus = exports.getDisplayName = exports.hasRunnableComponent = exports.wipeSensitiveData = exports.isEnvShareable = exports.getComponentMissingConfigs = exports.getAppMissingConfigs = exports.getSharedConfigObj = exports.isDeletableBlocklet = exports.forEachChildSync = exports.forEachChild = exports.forEachBlockletSync = exports.forEachBlocklet = exports.isComponentBlocklet = exports.isFreeComponent = exports.isFreeBlocklet = void 0;
|
|
16
7
|
/* eslint-disable no-await-in-loop */
|
|
17
8
|
const get_1 = __importDefault(require("lodash/get"));
|
|
18
9
|
const url_join_1 = __importDefault(require("url-join"));
|
|
@@ -87,9 +78,9 @@ const forEachBlocklet = (blocklet, cb, { parallel = false, concurrencyLimit = 5,
|
|
|
87
78
|
// serial
|
|
88
79
|
if (!parallel) {
|
|
89
80
|
// eslint-disable-next-line no-async-promise-executor
|
|
90
|
-
return new Promise((resolve, reject) =>
|
|
81
|
+
return new Promise(async (resolve, reject) => {
|
|
91
82
|
try {
|
|
92
|
-
const params =
|
|
83
|
+
const params = await cb(blocklet, {
|
|
93
84
|
parent: _parent,
|
|
94
85
|
root,
|
|
95
86
|
level: _level,
|
|
@@ -99,7 +90,7 @@ const forEachBlocklet = (blocklet, cb, { parallel = false, concurrencyLimit = 5,
|
|
|
99
90
|
});
|
|
100
91
|
if (blocklet.children) {
|
|
101
92
|
for (const child of blocklet.children) {
|
|
102
|
-
|
|
93
|
+
await forEachBlocklet(child, cb, {
|
|
103
94
|
params,
|
|
104
95
|
_parent: blocklet,
|
|
105
96
|
_root: root,
|
|
@@ -113,7 +104,7 @@ const forEachBlocklet = (blocklet, cb, { parallel = false, concurrencyLimit = 5,
|
|
|
113
104
|
catch (err) {
|
|
114
105
|
reject(err);
|
|
115
106
|
}
|
|
116
|
-
})
|
|
107
|
+
});
|
|
117
108
|
}
|
|
118
109
|
// parallel
|
|
119
110
|
const limit = _limit || (0, p_limit_1.default)(concurrencyLimit);
|
|
@@ -152,13 +143,11 @@ exports.forEachChild = forEachChild;
|
|
|
152
143
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
153
144
|
const forEachChildSync = (blocklet, cb) => forEachChild(blocklet, cb, { sync: true });
|
|
154
145
|
exports.forEachChildSync = forEachChildSync;
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
|
|
158
|
-
componentId = componentId.join('/');
|
|
146
|
+
const findComponent = (blocklet, isEqualFn, { _ancestors = [], returnAncestors = false, } = {}) => {
|
|
147
|
+
if (!isEqualFn) {
|
|
148
|
+
return null;
|
|
159
149
|
}
|
|
160
|
-
|
|
161
|
-
if (componentId === id) {
|
|
150
|
+
if (isEqualFn(blocklet, { ancestors: _ancestors })) {
|
|
162
151
|
if (returnAncestors) {
|
|
163
152
|
return {
|
|
164
153
|
component: blocklet,
|
|
@@ -169,13 +158,24 @@ const findComponentById = (blocklet, componentId, { _ancestors = [], returnAnces
|
|
|
169
158
|
}
|
|
170
159
|
for (const child of blocklet.children || []) {
|
|
171
160
|
const ancestors = _ancestors.concat(blocklet);
|
|
172
|
-
const component =
|
|
161
|
+
const component = findComponent(child, isEqualFn, { _ancestors: ancestors, returnAncestors });
|
|
173
162
|
if (component) {
|
|
174
163
|
return component;
|
|
175
164
|
}
|
|
176
165
|
}
|
|
177
166
|
return null;
|
|
178
167
|
};
|
|
168
|
+
exports.findComponent = findComponent;
|
|
169
|
+
const findComponentById = (blocklet, componentId, { returnAncestors = false, } = {}) => {
|
|
170
|
+
if (Array.isArray(componentId)) {
|
|
171
|
+
// eslint-disable-next-line no-param-reassign
|
|
172
|
+
componentId = componentId.join('/');
|
|
173
|
+
}
|
|
174
|
+
return findComponent(blocklet, (component, { ancestors }) => {
|
|
175
|
+
const id = getComponentId(component, ancestors);
|
|
176
|
+
return componentId === id;
|
|
177
|
+
}, { returnAncestors });
|
|
178
|
+
};
|
|
179
179
|
exports.findComponentById = findComponentById;
|
|
180
180
|
const isEnvShareable = (env) => {
|
|
181
181
|
return (!!env &&
|
|
@@ -204,7 +204,7 @@ const getSharedConfigObj = (component, ancestors) => {
|
|
|
204
204
|
if (config && config.value) {
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
res[key] = value;
|
|
207
|
+
res[key] = (0, get_1.default)(ancestor, `configObj.${key}`) || value;
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
}
|
|
@@ -364,6 +364,18 @@ const findWebInterface = (blocklet) => {
|
|
|
364
364
|
return interfaces.find((x) => x.type === BLOCKLET_INTERFACE_TYPE_WEB);
|
|
365
365
|
};
|
|
366
366
|
exports.findWebInterface = findWebInterface;
|
|
367
|
+
const findWebInterfacePort = (blocklet) => {
|
|
368
|
+
if (!blocklet) {
|
|
369
|
+
return null;
|
|
370
|
+
}
|
|
371
|
+
const webInterface = findWebInterface(blocklet);
|
|
372
|
+
const { ports } = blocklet;
|
|
373
|
+
if (!webInterface || !ports) {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
return ports[webInterface.port];
|
|
377
|
+
};
|
|
378
|
+
exports.findWebInterfacePort = findWebInterfacePort;
|
|
367
379
|
const findServiceFromMeta = (meta, ServiceName) => {
|
|
368
380
|
const names = [ServiceName];
|
|
369
381
|
// backward compatible
|
|
@@ -415,7 +427,7 @@ const getChainInfo = (env) => Object.entries(CHAIN_INFO_CONFIG).reduce((info, x)
|
|
|
415
427
|
return info;
|
|
416
428
|
}, {});
|
|
417
429
|
exports.getChainInfo = getChainInfo;
|
|
418
|
-
const isExternalBlocklet = (blocklet) => !!
|
|
430
|
+
const isExternalBlocklet = (blocklet) => !!blocklet?.controller;
|
|
419
431
|
exports.isExternalBlocklet = isExternalBlocklet;
|
|
420
432
|
const getRolesFromAuthConfig = (config) => {
|
|
421
433
|
if (!config.whoCanAccess.startsWith(WHO_CAN_ACCESS_PREFIX_ROLES)) {
|
|
@@ -442,12 +454,14 @@ exports.default = {
|
|
|
442
454
|
getDisplayName,
|
|
443
455
|
fixBlockletStatus,
|
|
444
456
|
findWebInterface,
|
|
457
|
+
findWebInterfacePort,
|
|
445
458
|
findServiceFromMeta,
|
|
446
459
|
getWhoCanAccess,
|
|
447
460
|
replaceSlotToIp,
|
|
448
461
|
getComponentId,
|
|
449
462
|
getComponentName,
|
|
450
463
|
getComponentBundleId,
|
|
464
|
+
findComponent,
|
|
451
465
|
findComponentById,
|
|
452
466
|
getParentComponentName,
|
|
453
467
|
getConnectAppUrl,
|
package/lib/validate.js
CHANGED
|
@@ -21,10 +21,13 @@ const fixAndValidateService = (meta) => {
|
|
|
21
21
|
};
|
|
22
22
|
exports.fixAndValidateService = fixAndValidateService;
|
|
23
23
|
const validateMeta = (meta, { ensureMain = false, ensureFiles = false, ensureDist = false, ensureComponentStore = true, schemaOptions = {}, } = {}) => {
|
|
24
|
-
const schema = (0, schema_1.createBlockletSchema)(null,
|
|
24
|
+
const schema = (0, schema_1.createBlockletSchema)(null, {
|
|
25
|
+
ensureMain,
|
|
25
26
|
ensureFiles,
|
|
26
27
|
ensureDist,
|
|
27
|
-
ensureComponentStore
|
|
28
|
+
ensureComponentStore,
|
|
29
|
+
...schemaOptions,
|
|
30
|
+
});
|
|
28
31
|
const { value, error } = schema.validate(meta);
|
|
29
32
|
if (error) {
|
|
30
33
|
throw new Error(`Invalid blocklet meta: ${error.details.map((x) => x.message).join(', ')}`);
|
package/lib/verify-multi-sig.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
@@ -49,7 +38,7 @@ function verifyDelegationToken(signature) {
|
|
|
49
38
|
return true;
|
|
50
39
|
}
|
|
51
40
|
const verifyMultiSig = (blockletMeta) => {
|
|
52
|
-
const { signatures: tmpSignatures
|
|
41
|
+
const { signatures: tmpSignatures, ...meta } = blockletMeta;
|
|
53
42
|
const signatures = (0, cloneDeep_1.default)(tmpSignatures);
|
|
54
43
|
if (!Array.isArray(signatures)) {
|
|
55
44
|
throw new Error('Invalid signatures, signatures should be an array');
|
|
@@ -74,7 +63,7 @@ const verifyMultiSig = (blockletMeta) => {
|
|
|
74
63
|
: signature;
|
|
75
64
|
delete signature.sig;
|
|
76
65
|
debug('verify', { signer });
|
|
77
|
-
let toBeVerifiedMeta =
|
|
66
|
+
let toBeVerifiedMeta = { ...meta };
|
|
78
67
|
if (lastSignature && lastSignature.appended) {
|
|
79
68
|
debug('appended fields', { signer, appended: lastSignature.appended });
|
|
80
69
|
lastSignature.appended.forEach((field) => {
|
|
@@ -89,7 +78,7 @@ const verifyMultiSig = (blockletMeta) => {
|
|
|
89
78
|
}
|
|
90
79
|
const type = (0, did_1.toTypeInfo)(signer);
|
|
91
80
|
const wallet = (0, wallet_1.fromPublicKey)(pk, type);
|
|
92
|
-
const verifyRes = wallet.verify((0, json_stable_stringify_1.default)(
|
|
81
|
+
const verifyRes = wallet.verify((0, json_stable_stringify_1.default)({ ...toBeVerifiedMeta, signatures: [signature, ...signatures] }), sig);
|
|
93
82
|
if (verifyRes !== true) {
|
|
94
83
|
debug('verify failed', { signer });
|
|
95
84
|
return verifyRes;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.8.
|
|
6
|
+
"version": "1.8.67-beta-794a8082",
|
|
7
7
|
"description": "Library to parse/validate/fix blocklet meta",
|
|
8
8
|
"main": "./lib/index.js",
|
|
9
9
|
"typings": "./lib/index.d.ts",
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
"author": "wangshijun <wangshijun2020@gmail.com> (http://github.com/wangshijun)",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@abtnode/client": "1.8.
|
|
28
|
-
"@abtnode/constant": "1.8.
|
|
29
|
-
"@abtnode/util": "1.8.
|
|
30
|
-
"@arcblock/did": "1.18.
|
|
31
|
-
"@arcblock/did-ext": "1.18.
|
|
32
|
-
"@arcblock/did-util": "1.18.
|
|
33
|
-
"@arcblock/jwt": "1.18.
|
|
34
|
-
"@blocklet/constant": "1.8.
|
|
35
|
-
"@ocap/asset": "1.18.
|
|
36
|
-
"@ocap/mcrypto": "1.18.
|
|
37
|
-
"@ocap/types": "1.18.
|
|
38
|
-
"@ocap/util": "1.18.
|
|
39
|
-
"@ocap/wallet": "1.18.
|
|
27
|
+
"@abtnode/client": "1.8.67-beta-794a8082",
|
|
28
|
+
"@abtnode/constant": "1.8.67-beta-794a8082",
|
|
29
|
+
"@abtnode/util": "1.8.67-beta-794a8082",
|
|
30
|
+
"@arcblock/did": "1.18.54",
|
|
31
|
+
"@arcblock/did-ext": "1.18.54",
|
|
32
|
+
"@arcblock/did-util": "1.18.54",
|
|
33
|
+
"@arcblock/jwt": "1.18.54",
|
|
34
|
+
"@blocklet/constant": "1.8.67-beta-794a8082",
|
|
35
|
+
"@ocap/asset": "1.18.54",
|
|
36
|
+
"@ocap/mcrypto": "1.18.54",
|
|
37
|
+
"@ocap/types": "1.18.54",
|
|
38
|
+
"@ocap/util": "1.18.54",
|
|
39
|
+
"@ocap/wallet": "1.18.54",
|
|
40
40
|
"ajv": "^8.11.0",
|
|
41
41
|
"axios": "^0.27.2",
|
|
42
42
|
"cjk-length": "^1.0.0",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"validate-npm-package-name": "^3.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@abtnode/client": "^1.8.
|
|
62
|
+
"@abtnode/client": "^1.8.66",
|
|
63
63
|
"@arcblock/eslint-config-ts": "^0.2.3",
|
|
64
64
|
"@types/express": "^4.17.14",
|
|
65
65
|
"@types/jest": "^29.2.2",
|
|
@@ -75,10 +75,11 @@
|
|
|
75
75
|
"expand-tilde": "^2.0.2",
|
|
76
76
|
"express": "^4.18.2",
|
|
77
77
|
"jest": "^29.3.0",
|
|
78
|
+
"joi-to-typescript": "^4.0.7",
|
|
78
79
|
"prettier": "^2.7.1",
|
|
79
80
|
"ts-jest": "^29.0.3",
|
|
80
81
|
"ts-node": "^10.9.1",
|
|
81
82
|
"typescript": "^4.8.4"
|
|
82
83
|
},
|
|
83
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "f4ad32bea4d80b12971fb6bef941bdbe2af6a834"
|
|
84
85
|
}
|