@blocklet/meta 1.8.33 → 1.8.35
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 +27 -0
- package/lib/channel.js +32 -32
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +6 -3
- package/lib/did.d.ts +10 -0
- package/lib/did.js +18 -24
- package/lib/engine.d.ts +7 -0
- package/lib/engine.js +21 -25
- package/lib/entry.d.ts +3 -0
- package/lib/entry.js +51 -64
- package/lib/extension.d.ts +10 -0
- package/lib/extension.js +78 -77
- package/lib/file.d.ts +21 -0
- package/lib/file.js +44 -39
- package/lib/fix.d.ts +33 -0
- package/lib/fix.js +218 -208
- package/lib/get-component-process-id.d.ts +5 -0
- package/lib/get-component-process-id.js +13 -14
- package/lib/has-reserved-key.d.ts +3 -0
- package/lib/has-reserved-key.js +10 -9
- package/lib/index.d.ts +82 -0
- package/lib/index.js +51 -34
- package/lib/info.d.ts +13 -0
- package/lib/info.js +58 -60
- package/lib/name.d.ts +5 -0
- package/lib/name.js +14 -7
- package/lib/nft-templates.d.ts +86 -0
- package/lib/nft-templates.js +47 -42
- package/lib/parse-navigation.d.ts +3 -0
- package/lib/parse-navigation.js +168 -209
- package/lib/parse.d.ts +22 -0
- package/lib/parse.js +71 -82
- package/lib/payment/index.d.ts +254 -0
- package/lib/payment/index.js +13 -6
- package/lib/payment/v1.d.ts +185 -0
- package/lib/payment/v1.js +80 -81
- package/lib/payment/v2.d.ts +242 -0
- package/lib/payment/v2.js +453 -531
- package/lib/schema.d.ts +50 -0
- package/lib/schema.js +405 -397
- package/lib/service-configs/auth.json +61 -61
- package/lib/service.d.ts +26 -0
- package/lib/service.js +69 -85
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +18 -0
- package/lib/types/schema.d.ts +241 -0
- package/lib/types/schema.js +3 -0
- package/lib/util-meta.d.ts +42 -0
- package/lib/util-meta.js +138 -158
- package/lib/util.d.ts +185 -0
- package/lib/util.js +359 -414
- package/lib/validate.d.ts +10 -0
- package/lib/validate.js +28 -34
- package/lib/verify-multi-sig.d.ts +3 -0
- package/lib/verify-multi-sig.js +94 -101
- package/lib/wallet.d.ts +9 -0
- package/lib/wallet.js +17 -27
- package/package.json +41 -18
package/lib/fix.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { fixAndValidateService } from './validate';
|
|
2
|
+
declare const fixRequired: (data: any, dir: string) => void;
|
|
3
|
+
declare const fixRepository: (data: any) => void;
|
|
4
|
+
declare const fixFiles: (data: any) => void;
|
|
5
|
+
declare const fixKeywords: (data: any) => void;
|
|
6
|
+
declare const fixTags: (data: any) => void;
|
|
7
|
+
declare const formatPerson: (person: string | Record<string, any>) => string;
|
|
8
|
+
declare const parsePerson: (person: string) => any;
|
|
9
|
+
declare const fixPerson: (data: any) => any;
|
|
10
|
+
declare const fixInterfaces: (meta: any, removeMerged?: boolean) => any;
|
|
11
|
+
export { fixRequired };
|
|
12
|
+
export { fixRepository };
|
|
13
|
+
export { fixFiles };
|
|
14
|
+
export { fixKeywords };
|
|
15
|
+
export { fixPerson };
|
|
16
|
+
export { fixTags };
|
|
17
|
+
export { formatPerson };
|
|
18
|
+
export { parsePerson };
|
|
19
|
+
export { fixInterfaces };
|
|
20
|
+
export { fixAndValidateService as fixService };
|
|
21
|
+
declare const _default: {
|
|
22
|
+
fixRequired: (data: any, dir: string) => void;
|
|
23
|
+
fixRepository: (data: any) => void;
|
|
24
|
+
fixFiles: (data: any) => void;
|
|
25
|
+
fixKeywords: (data: any) => void;
|
|
26
|
+
fixPerson: (data: any) => any;
|
|
27
|
+
fixTags: (data: any) => void;
|
|
28
|
+
formatPerson: (person: string | Record<string, any>) => string;
|
|
29
|
+
parsePerson: (person: string) => any;
|
|
30
|
+
fixInterfaces: (meta: any, removeMerged?: boolean) => any;
|
|
31
|
+
fixService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
package/lib/fix.js
CHANGED
|
@@ -1,235 +1,245 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.fixService = exports.fixInterfaces = exports.parsePerson = exports.formatPerson = exports.fixTags = exports.fixPerson = exports.fixKeywords = exports.fixFiles = exports.fixRepository = exports.fixRequired = void 0;
|
|
30
|
+
const fs_1 = __importDefault(require("fs"));
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
33
|
+
const gitInfo = __importStar(require("hosted-git-info"));
|
|
34
|
+
const debug_1 = __importDefault(require("debug"));
|
|
35
|
+
const validate_1 = require("./validate");
|
|
36
|
+
Object.defineProperty(exports, "fixService", { enumerable: true, get: function () { return validate_1.fixAndValidateService; } });
|
|
37
|
+
const constants_1 = __importDefault(require("./constants"));
|
|
38
|
+
const debug = (0, debug_1.default)('@blocklet/meta:fix');
|
|
39
|
+
const { BLOCKLET_DEFAULT_VERSION, BLOCKLET_DEFAULT_PORT_NAME, BLOCKLET_DYNAMIC_PATH_PREFIX, BLOCKLET_INTERFACE_TYPE_WEB, BLOCKLET_INTERFACE_PUBLIC, } = constants_1.default;
|
|
17
40
|
// Assign sensible defaults: name/description/main/group/version/public_url
|
|
18
41
|
const fixRequired = (data, dir) => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
data.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!data.main && !data.group) {
|
|
32
|
-
debug('guess main and group', dir);
|
|
33
|
-
data.group = 'static';
|
|
34
|
-
|
|
35
|
-
const items = ['.'].concat(fs.readdirSync(dir));
|
|
36
|
-
const item = items.find(
|
|
37
|
-
(x) => fs.existsSync(path.resolve(dir, x, 'index.html')) || fs.existsSync(path.resolve(dir, x, 'index.htm'))
|
|
38
|
-
);
|
|
39
|
-
if (item) {
|
|
40
|
-
data.main = item;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (!data.group) {
|
|
45
|
-
const main = path.join(dir, data.main);
|
|
46
|
-
try {
|
|
47
|
-
const stat = fs.statSync(main);
|
|
48
|
-
if (stat.isDirectory()) {
|
|
42
|
+
if (!data.name) {
|
|
43
|
+
data.name = path_1.default.basename(dir);
|
|
44
|
+
}
|
|
45
|
+
if (!data.description) {
|
|
46
|
+
data.description = `Blocklet from ${dir}`;
|
|
47
|
+
}
|
|
48
|
+
if (!data.version) {
|
|
49
|
+
data.version = BLOCKLET_DEFAULT_VERSION;
|
|
50
|
+
}
|
|
51
|
+
if (!data.main && !data.group) {
|
|
52
|
+
debug('guess main and group', dir);
|
|
49
53
|
data.group = 'static';
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
const items = ['.'].concat(fs_1.default.readdirSync(dir));
|
|
55
|
+
const item = items.find((x) => fs_1.default.existsSync(path_1.default.resolve(dir, x, 'index.html')) || fs_1.default.existsSync(path_1.default.resolve(dir, x, 'index.htm')));
|
|
56
|
+
if (item) {
|
|
57
|
+
data.main = item;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!data.group) {
|
|
61
|
+
const main = path_1.default.join(dir, data.main);
|
|
62
|
+
try {
|
|
63
|
+
const stat = fs_1.default.statSync(main);
|
|
64
|
+
if (stat.isDirectory()) {
|
|
65
|
+
data.group = 'static';
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
data.group = 'dapp';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
data.group = 'static';
|
|
73
|
+
}
|
|
55
74
|
}
|
|
56
|
-
}
|
|
57
75
|
};
|
|
58
|
-
|
|
76
|
+
exports.fixRequired = fixRequired;
|
|
59
77
|
const fixRepository = (data) => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
data.repository
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
if (!data.repository)
|
|
79
|
+
return;
|
|
80
|
+
if (typeof data.repository === 'string') {
|
|
81
|
+
data.repository = {
|
|
82
|
+
type: 'git',
|
|
83
|
+
url: data.repository,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (data.repository.url) {
|
|
87
|
+
const info = gitInfo.fromUrl(data.repository.url);
|
|
88
|
+
if (info) {
|
|
89
|
+
data.repository.url = info.getDefaultRepresentation() === 'shortcut' ? info.https() : info.toString();
|
|
90
|
+
}
|
|
71
91
|
}
|
|
72
|
-
}
|
|
73
92
|
};
|
|
74
|
-
|
|
93
|
+
exports.fixRepository = fixRepository;
|
|
75
94
|
const fixFiles = (data) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
if (!Array.isArray(data.files)) {
|
|
96
|
+
delete data.files;
|
|
97
|
+
}
|
|
98
|
+
else if (data.files) {
|
|
99
|
+
data.files = data.files.filter((file) => {
|
|
100
|
+
return !(!file || typeof file !== 'string');
|
|
101
|
+
});
|
|
102
|
+
}
|
|
83
103
|
};
|
|
84
|
-
|
|
104
|
+
exports.fixFiles = fixFiles;
|
|
85
105
|
const fixKeywords = (data) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
if (typeof data.keywords === 'string') {
|
|
107
|
+
data.keywords = data.keywords.split(/,\s+/);
|
|
108
|
+
}
|
|
109
|
+
if (data.keywords && !Array.isArray(data.keywords)) {
|
|
110
|
+
delete data.keywords;
|
|
111
|
+
}
|
|
112
|
+
else if (data.keywords) {
|
|
113
|
+
data.keywords = data.keywords.filter((kw) => {
|
|
114
|
+
return !(typeof kw !== 'string' || !kw);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
96
117
|
};
|
|
97
|
-
|
|
118
|
+
exports.fixKeywords = fixKeywords;
|
|
98
119
|
const fixTags = (data) => {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
120
|
+
if (typeof data.tags === 'string') {
|
|
121
|
+
data.tags = data.tags.split(/,\s+/);
|
|
122
|
+
}
|
|
123
|
+
if (data.tags && !Array.isArray(data.tags)) {
|
|
124
|
+
delete data.tags;
|
|
125
|
+
}
|
|
126
|
+
else if (data.tags) {
|
|
127
|
+
data.tags = data.tags.filter((t) => {
|
|
128
|
+
return !(typeof t !== 'string' || !t);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
109
131
|
};
|
|
110
|
-
|
|
132
|
+
exports.fixTags = fixTags;
|
|
111
133
|
const updatePerson = (data, fn) => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
134
|
+
if (data.author)
|
|
135
|
+
data.author = fn(data.author);
|
|
136
|
+
['maintainers', 'contributors'].forEach((key) => {
|
|
137
|
+
if (!Array.isArray(data[key])) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
data[key] = data[key].map(fn);
|
|
141
|
+
});
|
|
142
|
+
return data;
|
|
121
143
|
};
|
|
122
|
-
|
|
123
144
|
const formatPerson = (person) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
145
|
+
if (!person) {
|
|
146
|
+
return '';
|
|
147
|
+
}
|
|
148
|
+
if (typeof person === 'string') {
|
|
149
|
+
return person;
|
|
150
|
+
}
|
|
151
|
+
const name = person.name || '';
|
|
152
|
+
const u = person.url || person.web;
|
|
153
|
+
const url = u ? ` (${u})` : '';
|
|
154
|
+
const e = person.email || person.mail;
|
|
155
|
+
const email = e ? ` <${e}>` : '';
|
|
156
|
+
return name + email + url;
|
|
136
157
|
};
|
|
137
|
-
|
|
158
|
+
exports.formatPerson = formatPerson;
|
|
138
159
|
const parsePerson = (person) => {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
160
|
+
if (typeof person !== 'string') {
|
|
161
|
+
return person;
|
|
162
|
+
}
|
|
163
|
+
const name = person.match(/^([^(<]+)/);
|
|
164
|
+
const url = person.match(/\(([^)]+)\)/);
|
|
165
|
+
const email = person.match(/<([^>]+)>/);
|
|
166
|
+
const obj = {};
|
|
167
|
+
if (name && name[0].trim())
|
|
168
|
+
obj.name = name[0].trim();
|
|
169
|
+
if (email) {
|
|
170
|
+
[, obj.email] = email;
|
|
171
|
+
}
|
|
172
|
+
if (url) {
|
|
173
|
+
[, obj.url] = url;
|
|
174
|
+
}
|
|
175
|
+
return obj;
|
|
154
176
|
};
|
|
155
|
-
|
|
177
|
+
exports.parsePerson = parsePerson;
|
|
156
178
|
const fixPerson = (data) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
179
|
+
updatePerson(data, formatPerson);
|
|
180
|
+
updatePerson(data, parsePerson);
|
|
181
|
+
return data;
|
|
160
182
|
};
|
|
161
|
-
|
|
183
|
+
exports.fixPerson = fixPerson;
|
|
162
184
|
const fixInterfaces = (meta, removeMerged = true) => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
185
|
+
if (!Array.isArray(meta.interfaces)) {
|
|
186
|
+
meta.interfaces = [];
|
|
187
|
+
}
|
|
188
|
+
if (meta.interfaces.length) {
|
|
189
|
+
// Web interfaces should always use http protocol
|
|
190
|
+
meta.interfaces.forEach((x) => {
|
|
191
|
+
if (x.type === BLOCKLET_INTERFACE_TYPE_WEB) {
|
|
192
|
+
x.protocol = 'http';
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
return meta;
|
|
196
|
+
}
|
|
197
|
+
const supportDynamicPathPrefix = (0, get_1.default)(meta, 'capabilities.dynamicPathPrefix', true);
|
|
198
|
+
const prefix = supportDynamicPathPrefix ? BLOCKLET_DYNAMIC_PATH_PREFIX : '/';
|
|
199
|
+
const addInterface = ({ type = 'web', name, path: _path = '/', // eslint-disable-line no-shadow
|
|
200
|
+
protocol = 'http', port = BLOCKLET_DEFAULT_PORT_NAME, }) => {
|
|
201
|
+
meta.interfaces.push({ type, name, path: _path, prefix, port, protocol });
|
|
202
|
+
};
|
|
203
|
+
[BLOCKLET_INTERFACE_PUBLIC].forEach((x) => {
|
|
204
|
+
if (meta[x]) {
|
|
205
|
+
addInterface({ name: x, path: meta[x] });
|
|
206
|
+
}
|
|
173
207
|
});
|
|
208
|
+
if (Array.isArray(meta.exposeServices)) {
|
|
209
|
+
meta.exposeServices.forEach((x) => {
|
|
210
|
+
addInterface({
|
|
211
|
+
type: 'service',
|
|
212
|
+
name: x.protocol,
|
|
213
|
+
protocol: x.protocol,
|
|
214
|
+
port: {
|
|
215
|
+
internal: `BLOCKLET_${x.protocol}_PORT`.toUpperCase(),
|
|
216
|
+
external: x.port,
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
if (removeMerged) {
|
|
222
|
+
delete meta.publicUrl;
|
|
223
|
+
delete meta.adminUrl;
|
|
224
|
+
delete meta.configUrl;
|
|
225
|
+
delete meta.docUrl;
|
|
226
|
+
delete meta.exposeServices;
|
|
227
|
+
if (meta.capabilities) {
|
|
228
|
+
delete meta.capabilities.dynamicPathPrefix;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
174
231
|
return meta;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
const supportDynamicPathPrefix = get(meta, 'capabilities.dynamicPathPrefix', true);
|
|
178
|
-
const prefix = supportDynamicPathPrefix ? BLOCKLET_DYNAMIC_PATH_PREFIX : '/';
|
|
179
|
-
|
|
180
|
-
const addInterface = ({
|
|
181
|
-
type = 'web',
|
|
182
|
-
name,
|
|
183
|
-
path = '/', // eslint-disable-line no-shadow
|
|
184
|
-
protocol = 'http',
|
|
185
|
-
port = BLOCKLET_DEFAULT_PORT_NAME,
|
|
186
|
-
}) => {
|
|
187
|
-
meta.interfaces.push({ type, name, path, prefix, port, protocol });
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
[BLOCKLET_INTERFACE_PUBLIC].forEach((x) => {
|
|
191
|
-
if (meta[x]) {
|
|
192
|
-
addInterface({ name: x, path: meta[x] });
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
if (Array.isArray(meta.exposeServices)) {
|
|
197
|
-
meta.exposeServices.forEach((x) => {
|
|
198
|
-
addInterface({
|
|
199
|
-
type: 'service',
|
|
200
|
-
name: x.protocol,
|
|
201
|
-
protocol: x.protocol,
|
|
202
|
-
port: {
|
|
203
|
-
internal: `BLOCKLET_${x.protocol}_PORT`.toUpperCase(),
|
|
204
|
-
external: x.port,
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (removeMerged) {
|
|
211
|
-
delete meta.publicUrl;
|
|
212
|
-
delete meta.adminUrl;
|
|
213
|
-
delete meta.configUrl;
|
|
214
|
-
delete meta.docUrl;
|
|
215
|
-
delete meta.exposeServices;
|
|
216
|
-
if (meta.capabilities) {
|
|
217
|
-
delete meta.capabilities.dynamicPathPrefix;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return meta;
|
|
222
232
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
233
|
+
exports.fixInterfaces = fixInterfaces;
|
|
234
|
+
exports.default = {
|
|
235
|
+
fixRequired,
|
|
236
|
+
fixRepository,
|
|
237
|
+
fixFiles,
|
|
238
|
+
fixKeywords,
|
|
239
|
+
fixPerson,
|
|
240
|
+
fixTags,
|
|
241
|
+
formatPerson,
|
|
242
|
+
parsePerson,
|
|
243
|
+
fixInterfaces,
|
|
244
|
+
fixService: validate_1.fixAndValidateService,
|
|
235
245
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
6
|
+
const md5 = (str) => crypto_1.default.createHash('md5').update(str).digest('hex');
|
|
5
7
|
const getComponentProcessId = (component, ancestors = []) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return md5(name);
|
|
8
|
+
const name = !ancestors.length
|
|
9
|
+
? component.meta.name
|
|
10
|
+
: `${ancestors.map((x) => encodeURIComponent(x.meta.name)).join('/')}/${encodeURIComponent(component.meta.name)}`;
|
|
11
|
+
if (name.length < 240) {
|
|
12
|
+
return name;
|
|
13
|
+
}
|
|
14
|
+
return md5(name);
|
|
15
15
|
};
|
|
16
|
-
|
|
17
16
|
module.exports = getComponentProcessId;
|
package/lib/has-reserved-key.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const constants_1 = __importDefault(require("./constants"));
|
|
6
|
+
const { BLOCKLET_CONFIGURABLE_KEY } = constants_1.default;
|
|
7
|
+
const hasReservedKey = (environments) => environments.some((x) => {
|
|
8
|
+
// @ts-ignore
|
|
5
9
|
const key = (x.key || x.name || '').toString();
|
|
6
|
-
|
|
7
10
|
if (key.startsWith('ABT_NODE_')) {
|
|
8
|
-
|
|
11
|
+
return true;
|
|
9
12
|
}
|
|
10
|
-
|
|
11
13
|
return !!(key.startsWith('BLOCKLET_') && !BLOCKLET_CONFIGURABLE_KEY[key]);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
});
|
|
14
15
|
module.exports = hasReservedKey;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import constants from './constants';
|
|
3
|
+
import parse from './parse';
|
|
4
|
+
import toBlockletDid from './did';
|
|
5
|
+
import getBlockletWallet from './wallet';
|
|
6
|
+
import getBlockletInfo from './info';
|
|
7
|
+
import getBlockletEngine from './engine';
|
|
8
|
+
import { validateMeta, fixAndValidateService } from './validate';
|
|
9
|
+
import { formatPerson, parsePerson, fixPerson, fixInterfaces, fixService } from './fix';
|
|
10
|
+
import { list, select, update } from './file';
|
|
11
|
+
import verifyMultiSig from './verify-multi-sig';
|
|
12
|
+
export { constants };
|
|
13
|
+
export { list };
|
|
14
|
+
export { select };
|
|
15
|
+
export { update };
|
|
16
|
+
export { parse };
|
|
17
|
+
export { validateMeta };
|
|
18
|
+
export { fixAndValidateService };
|
|
19
|
+
export { formatPerson };
|
|
20
|
+
export { parsePerson };
|
|
21
|
+
export { fixPerson };
|
|
22
|
+
export { fixInterfaces };
|
|
23
|
+
export { fixService };
|
|
24
|
+
export { toBlockletDid };
|
|
25
|
+
export { getBlockletWallet };
|
|
26
|
+
export { getBlockletInfo };
|
|
27
|
+
export { getBlockletEngine };
|
|
28
|
+
export { verifyMultiSig };
|
|
29
|
+
declare const _default: {
|
|
30
|
+
constants: any;
|
|
31
|
+
list: any[];
|
|
32
|
+
select: (dir: string, { throwOnError }?: {
|
|
33
|
+
throwOnError?: boolean;
|
|
34
|
+
}) => string;
|
|
35
|
+
update: (file: string, meta: import("./types").TBlockletMeta, { fix }?: {
|
|
36
|
+
fix?: boolean;
|
|
37
|
+
}) => void;
|
|
38
|
+
parse: (dir: string, { ensureMain, ensureFiles, ensureDist, extraRawAttrs, serviceMetas, schemaOptions, fix, }?: {
|
|
39
|
+
ensureMain?: boolean;
|
|
40
|
+
ensureFiles?: boolean;
|
|
41
|
+
ensureDist?: boolean;
|
|
42
|
+
extraRawAttrs?: any;
|
|
43
|
+
serviceMetas?: any;
|
|
44
|
+
schemaOptions?: any;
|
|
45
|
+
enableDefaults?: boolean;
|
|
46
|
+
extraAttrSpec?: any;
|
|
47
|
+
fix?: boolean;
|
|
48
|
+
}) => import("./types").TBlockletMeta;
|
|
49
|
+
validateMeta: (meta: any, { ensureMain, ensureFiles, ensureDist, schemaOptions, }?: {
|
|
50
|
+
ensureMain?: boolean;
|
|
51
|
+
ensureFiles?: boolean;
|
|
52
|
+
ensureDist?: boolean;
|
|
53
|
+
schemaOptions?: any;
|
|
54
|
+
}) => import("./types").TBlockletMeta;
|
|
55
|
+
fixAndValidateService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
|
|
56
|
+
formatPerson: (person: string | Record<string, any>) => string;
|
|
57
|
+
parsePerson: (person: string) => any;
|
|
58
|
+
fixPerson: (data: any) => any;
|
|
59
|
+
fixInterfaces: (meta: any, removeMerged?: boolean) => any;
|
|
60
|
+
fixService: (meta: import("./types").TBlockletMeta) => import("./types").TBlockletMeta;
|
|
61
|
+
toBlockletDid: {
|
|
62
|
+
(name: string | Buffer): string;
|
|
63
|
+
toExternalBlocklet(name: string, userDid: string, { didOnly, nameOnly }?: {
|
|
64
|
+
didOnly?: boolean;
|
|
65
|
+
nameOnly?: boolean;
|
|
66
|
+
}): string | Pick<import("./types").TBlockletMeta, "name" | "did">;
|
|
67
|
+
};
|
|
68
|
+
getBlockletWallet: (blockletDid: string, nodeSk?: string, type?: import("@arcblock/did").DIDType, index?: number) => import("@ocap/wallet").WalletObject<string>;
|
|
69
|
+
getBlockletInfo: (state: import("@abtnode/client").BlockletState, nodeSk?: string, { returnWallet }?: {
|
|
70
|
+
returnWallet?: boolean;
|
|
71
|
+
}) => {
|
|
72
|
+
did: string;
|
|
73
|
+
name: string;
|
|
74
|
+
description: string;
|
|
75
|
+
passportColor?: string;
|
|
76
|
+
appUrl: string;
|
|
77
|
+
wallet?: import("@ocap/wallet").WalletObject<string>;
|
|
78
|
+
};
|
|
79
|
+
getBlockletEngine: (meta: import("./types").TBlockletMeta) => import("./types").TEngine;
|
|
80
|
+
verifyMultiSig: (blockletMeta: import("./types").TBlockletMeta) => boolean;
|
|
81
|
+
};
|
|
82
|
+
export default _default;
|