@blocklet/launcher-util 2.3.80 → 2.3.82
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/es/constant.js +6 -0
- package/es/middleware.js +0 -27
- package/es/util.js +6 -6
- package/lib/constant.js +6 -0
- package/lib/middleware.js +0 -27
- package/lib/util.js +6 -6
- package/package.json +2 -2
package/es/constant.js
CHANGED
|
@@ -168,10 +168,16 @@ const APP_CHARGE_TYPE = {
|
|
|
168
168
|
instant: "instant"
|
|
169
169
|
// 立即付费
|
|
170
170
|
};
|
|
171
|
+
const CONFIG_DATA_TYPE = {
|
|
172
|
+
ami: "ami",
|
|
173
|
+
syncNFT: "syncNFT",
|
|
174
|
+
nftFactories: "nftFactories"
|
|
175
|
+
};
|
|
171
176
|
export {
|
|
172
177
|
APP_CHARGE_TYPE,
|
|
173
178
|
APP_RECORD_TYPE,
|
|
174
179
|
APP_TYPE,
|
|
180
|
+
CONFIG_DATA_TYPE,
|
|
175
181
|
CURRENCY_TYPE,
|
|
176
182
|
DID_DOMAIN_SUFFIX,
|
|
177
183
|
INSTANCE_MAX_DESC_LENGTH,
|
package/es/middleware.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import pick from "lodash/pick";
|
|
2
1
|
import { getSort } from "./util";
|
|
3
2
|
const MAX_PAGING_SIZE = 100;
|
|
4
3
|
const DEFAULT_PAGING_SIZE = MAX_PAGING_SIZE;
|
|
@@ -32,36 +31,10 @@ const validate = (schema, option = {}) => (req, res, next) => {
|
|
|
32
31
|
req.data = value;
|
|
33
32
|
next();
|
|
34
33
|
};
|
|
35
|
-
const createAuditMiddleware = ({ baseURL, writer, formatterMap }) => (req, res, next) => {
|
|
36
|
-
if (["PUT", "POST", "PATCH", "DELETE"].includes(req.method)) {
|
|
37
|
-
const originalResponse = res.end.bind(res);
|
|
38
|
-
const wrappedResponse = (...args) => {
|
|
39
|
-
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
40
|
-
const key = `${req.baseUrl}${req.route.path}`.replace(baseURL, req.method.toLowerCase());
|
|
41
|
-
const formater = formatterMap[key];
|
|
42
|
-
if (formater) {
|
|
43
|
-
const data = {
|
|
44
|
-
user: { ...pick(req.user, ["did", "role", "fullName"]) },
|
|
45
|
-
id: formater.id,
|
|
46
|
-
resource: formater.resource,
|
|
47
|
-
payload: formater.format({ req, res }),
|
|
48
|
-
ip: req.get("x-Real-ip", ""),
|
|
49
|
-
ua: req.get("user-agent", "")
|
|
50
|
-
};
|
|
51
|
-
writer(data);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return originalResponse(...args);
|
|
55
|
-
};
|
|
56
|
-
res.end = wrappedResponse;
|
|
57
|
-
}
|
|
58
|
-
next();
|
|
59
|
-
};
|
|
60
34
|
export {
|
|
61
35
|
DEFAULT_PAGE,
|
|
62
36
|
DEFAULT_PAGING_SIZE,
|
|
63
37
|
MAX_PAGING_SIZE,
|
|
64
|
-
createAuditMiddleware,
|
|
65
38
|
pagination,
|
|
66
39
|
validate
|
|
67
40
|
};
|
package/es/util.js
CHANGED
|
@@ -65,23 +65,23 @@ const getExplorerUrl = ({ address, type = "txs", chainHost }) => {
|
|
|
65
65
|
return `https://explorer.abtnetwork.io/explorer/${type}/${address}?host=${chainHost}`;
|
|
66
66
|
};
|
|
67
67
|
const getBlockletDisplayName = (blocklet) => get(blocklet, "title") || get(blocklet, "name") || "";
|
|
68
|
-
const getBlockletAdminURL = (
|
|
69
|
-
if (!
|
|
68
|
+
const getBlockletAdminURL = (appUrl) => {
|
|
69
|
+
if (!appUrl) {
|
|
70
70
|
return "#";
|
|
71
71
|
}
|
|
72
|
-
return joinURL(
|
|
72
|
+
return joinURL(appUrl, "/.well-known/service/admin/overview");
|
|
73
73
|
};
|
|
74
74
|
const isDateExpired = (expirationDate) => !!expirationDate && new Date(expirationDate).getTime() <= Date.now();
|
|
75
75
|
const getContinueLaunchURL = ({ baseURL, launch }) => {
|
|
76
76
|
const urlObject = new URL(baseURL);
|
|
77
77
|
if (launch.status < LAUNCH_STATUS.paid) {
|
|
78
|
-
urlObject.searchParams.set("sessionId", launch.
|
|
78
|
+
urlObject.searchParams.set("sessionId", launch.id);
|
|
79
79
|
urlObject.searchParams.set("blocklet_meta_url", launch.blockletMetaUrl);
|
|
80
80
|
return urlObject.href;
|
|
81
81
|
}
|
|
82
82
|
if (launch.status >= LAUNCH_STATUS.paid && launch.status < LAUNCH_STATUS.consuming) {
|
|
83
|
-
urlObject.pathname = joinURL(urlObject.pathname, `/launch/${launch.
|
|
84
|
-
urlObject.searchParams.set("sessionId", launch.
|
|
83
|
+
urlObject.pathname = joinURL(urlObject.pathname, `/launch/${launch.id}`);
|
|
84
|
+
urlObject.searchParams.set("sessionId", launch.id);
|
|
85
85
|
urlObject.searchParams.set("blocklet_meta_url", launch.blockletMetaUrl);
|
|
86
86
|
urlObject.searchParams.set("launchType", launch.type);
|
|
87
87
|
if (launch.from) {
|
package/lib/constant.js
CHANGED
|
@@ -170,9 +170,15 @@ const APP_CHARGE_TYPE = {
|
|
|
170
170
|
instant: "instant"
|
|
171
171
|
// 立即付费
|
|
172
172
|
};
|
|
173
|
+
const CONFIG_DATA_TYPE = {
|
|
174
|
+
ami: "ami",
|
|
175
|
+
syncNFT: "syncNFT",
|
|
176
|
+
nftFactories: "nftFactories"
|
|
177
|
+
};
|
|
173
178
|
exports.APP_CHARGE_TYPE = APP_CHARGE_TYPE;
|
|
174
179
|
exports.APP_RECORD_TYPE = APP_RECORD_TYPE;
|
|
175
180
|
exports.APP_TYPE = APP_TYPE;
|
|
181
|
+
exports.CONFIG_DATA_TYPE = CONFIG_DATA_TYPE;
|
|
176
182
|
exports.CURRENCY_TYPE = CURRENCY_TYPE;
|
|
177
183
|
exports.DID_DOMAIN_SUFFIX = DID_DOMAIN_SUFFIX;
|
|
178
184
|
exports.INSTANCE_MAX_DESC_LENGTH = INSTANCE_MAX_DESC_LENGTH;
|
package/lib/middleware.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const pick = require("lodash/pick");
|
|
4
3
|
const util = require("./util");
|
|
5
4
|
const MAX_PAGING_SIZE = 100;
|
|
6
5
|
const DEFAULT_PAGING_SIZE = MAX_PAGING_SIZE;
|
|
@@ -34,34 +33,8 @@ const validate = (schema, option = {}) => (req, res, next) => {
|
|
|
34
33
|
req.data = value;
|
|
35
34
|
next();
|
|
36
35
|
};
|
|
37
|
-
const createAuditMiddleware = ({ baseURL, writer, formatterMap }) => (req, res, next) => {
|
|
38
|
-
if (["PUT", "POST", "PATCH", "DELETE"].includes(req.method)) {
|
|
39
|
-
const originalResponse = res.end.bind(res);
|
|
40
|
-
const wrappedResponse = (...args) => {
|
|
41
|
-
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
42
|
-
const key = `${req.baseUrl}${req.route.path}`.replace(baseURL, req.method.toLowerCase());
|
|
43
|
-
const formater = formatterMap[key];
|
|
44
|
-
if (formater) {
|
|
45
|
-
const data = {
|
|
46
|
-
user: { ...pick(req.user, ["did", "role", "fullName"]) },
|
|
47
|
-
id: formater.id,
|
|
48
|
-
resource: formater.resource,
|
|
49
|
-
payload: formater.format({ req, res }),
|
|
50
|
-
ip: req.get("x-Real-ip", ""),
|
|
51
|
-
ua: req.get("user-agent", "")
|
|
52
|
-
};
|
|
53
|
-
writer(data);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return originalResponse(...args);
|
|
57
|
-
};
|
|
58
|
-
res.end = wrappedResponse;
|
|
59
|
-
}
|
|
60
|
-
next();
|
|
61
|
-
};
|
|
62
36
|
exports.DEFAULT_PAGE = DEFAULT_PAGE;
|
|
63
37
|
exports.DEFAULT_PAGING_SIZE = DEFAULT_PAGING_SIZE;
|
|
64
38
|
exports.MAX_PAGING_SIZE = MAX_PAGING_SIZE;
|
|
65
|
-
exports.createAuditMiddleware = createAuditMiddleware;
|
|
66
39
|
exports.pagination = pagination;
|
|
67
40
|
exports.validate = validate;
|
package/lib/util.js
CHANGED
|
@@ -67,23 +67,23 @@ const getExplorerUrl = ({ address, type = "txs", chainHost }) => {
|
|
|
67
67
|
return `https://explorer.abtnetwork.io/explorer/${type}/${address}?host=${chainHost}`;
|
|
68
68
|
};
|
|
69
69
|
const getBlockletDisplayName = (blocklet) => get(blocklet, "title") || get(blocklet, "name") || "";
|
|
70
|
-
const getBlockletAdminURL = (
|
|
71
|
-
if (!
|
|
70
|
+
const getBlockletAdminURL = (appUrl) => {
|
|
71
|
+
if (!appUrl) {
|
|
72
72
|
return "#";
|
|
73
73
|
}
|
|
74
|
-
return joinURL(
|
|
74
|
+
return joinURL(appUrl, "/.well-known/service/admin/overview");
|
|
75
75
|
};
|
|
76
76
|
const isDateExpired = (expirationDate) => !!expirationDate && new Date(expirationDate).getTime() <= Date.now();
|
|
77
77
|
const getContinueLaunchURL = ({ baseURL, launch }) => {
|
|
78
78
|
const urlObject = new URL(baseURL);
|
|
79
79
|
if (launch.status < constant.LAUNCH_STATUS.paid) {
|
|
80
|
-
urlObject.searchParams.set("sessionId", launch.
|
|
80
|
+
urlObject.searchParams.set("sessionId", launch.id);
|
|
81
81
|
urlObject.searchParams.set("blocklet_meta_url", launch.blockletMetaUrl);
|
|
82
82
|
return urlObject.href;
|
|
83
83
|
}
|
|
84
84
|
if (launch.status >= constant.LAUNCH_STATUS.paid && launch.status < constant.LAUNCH_STATUS.consuming) {
|
|
85
|
-
urlObject.pathname = joinURL(urlObject.pathname, `/launch/${launch.
|
|
86
|
-
urlObject.searchParams.set("sessionId", launch.
|
|
85
|
+
urlObject.pathname = joinURL(urlObject.pathname, `/launch/${launch.id}`);
|
|
86
|
+
urlObject.searchParams.set("sessionId", launch.id);
|
|
87
87
|
urlObject.searchParams.set("blocklet_meta_url", launch.blockletMetaUrl);
|
|
88
88
|
urlObject.searchParams.set("launchType", launch.type);
|
|
89
89
|
if (launch.from) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/launcher-util",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.82",
|
|
4
4
|
"description": "Common constants",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"constant"
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"vite": "^5.4.11",
|
|
50
50
|
"vite-plugin-build": "^0.10.0"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "f77c63e44cd30b05b0552a8e46fcbe232e784329"
|
|
53
53
|
}
|