@blocklet/sdk 1.16.38-beta-20250206-084543-4d7b4331 → 1.16.38-beta-20250207-102532-5be12f2c
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/component/index.js +3 -3
- package/lib/config.d.ts +4 -2
- package/lib/config.js +8 -2
- package/lib/connect/handler.js +2 -3
- package/lib/middlewares/blocklet.js +6 -3
- package/lib/middlewares/component.js +6 -3
- package/lib/middlewares/csrf.js +2 -2
- package/package.json +15 -15
package/lib/component/index.js
CHANGED
|
@@ -44,7 +44,7 @@ const ufo_1 = require("ufo");
|
|
|
44
44
|
const p_retry_1 = __importDefault(require("p-retry"));
|
|
45
45
|
const wait_port_1 = __importDefault(require("wait-port"));
|
|
46
46
|
const constant_1 = require("@blocklet/constant");
|
|
47
|
-
const config_1 = require("../config");
|
|
47
|
+
const config_1 = __importStar(require("../config"));
|
|
48
48
|
const Util = __importStar(require("./util"));
|
|
49
49
|
const component_api_1 = __importDefault(require("../util/component-api"));
|
|
50
50
|
const parse_docker_endpoint_1 = require("../util/parse-docker-endpoint");
|
|
@@ -59,12 +59,12 @@ const doCall = async ({ url, headers = {}, ...options }, retryOptions = {}) => (
|
|
|
59
59
|
headers,
|
|
60
60
|
});
|
|
61
61
|
const duration = Date.now() - startTime;
|
|
62
|
-
config_1.logger.info(`component.call succeed in ${duration}ms: ${url} `);
|
|
62
|
+
config_1.default.logger.info(`component.call succeed in ${duration}ms: ${url} `);
|
|
63
63
|
return res;
|
|
64
64
|
}
|
|
65
65
|
catch (error) {
|
|
66
66
|
const duration = Date.now() - startTime;
|
|
67
|
-
config_1.logger.error(`component.call failed in ${duration}ms`, {
|
|
67
|
+
config_1.default.logger.error(`component.call failed in ${duration}ms`, {
|
|
68
68
|
url,
|
|
69
69
|
responseStatus: (0, get_1.default)(error, 'response.status'),
|
|
70
70
|
responseData: (0, get_1.default)(error, 'response.data'),
|
package/lib/config.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare const Events: {
|
|
|
9
9
|
componentRemoved: string;
|
|
10
10
|
envUpdate: string;
|
|
11
11
|
};
|
|
12
|
-
declare
|
|
12
|
+
declare let logger: {
|
|
13
13
|
info: {
|
|
14
14
|
(...data: any[]): void;
|
|
15
15
|
(message?: any, ...optionalParams: any[]): void;
|
|
@@ -24,6 +24,7 @@ declare const logger: {
|
|
|
24
24
|
(message?: any, ...optionalParams: any[]): void;
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
+
declare const setLogger: (newLogger: typeof logger) => void;
|
|
27
28
|
declare const env: {
|
|
28
29
|
appId: string;
|
|
29
30
|
appPid: string;
|
|
@@ -76,7 +77,7 @@ declare const _handleComponentInstalled: (data: {
|
|
|
76
77
|
declare const _handleConfigUpdate: (data: any) => void;
|
|
77
78
|
declare const _handleComponentConfigUpdate: (data: any) => void;
|
|
78
79
|
declare const getBlockletJs: (pageGroup?: string, pathPrefix?: string, source?: string) => string;
|
|
79
|
-
export { logger, env, componentStore as components, MountPoint, // @deprecated, for backward compatibility
|
|
80
|
+
export { logger, setLogger, env, componentStore as components, MountPoint, // @deprecated, for backward compatibility
|
|
80
81
|
TComponent, events, Events, getBlockletJs, _handleComponentUpdateOld, _handleConfigUpdate, _handleComponentInstalled, _handleComponentUpdated, _handleComponentStarted, _handleComponentStopped, _handleComponentRemoved, _handleComponentConfigUpdate, };
|
|
81
82
|
declare const _default: {
|
|
82
83
|
logger: {
|
|
@@ -94,6 +95,7 @@ declare const _default: {
|
|
|
94
95
|
(message?: any, ...optionalParams: any[]): void;
|
|
95
96
|
};
|
|
96
97
|
};
|
|
98
|
+
setLogger: (newLogger: typeof logger) => void;
|
|
97
99
|
env: {
|
|
98
100
|
[key: string]: any;
|
|
99
101
|
appId: string;
|
package/lib/config.js
CHANGED
|
@@ -3,7 +3,7 @@ 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._handleComponentConfigUpdate = exports._handleComponentRemoved = exports._handleComponentStopped = exports._handleComponentStarted = exports._handleComponentUpdated = exports._handleComponentInstalled = exports._handleConfigUpdate = exports._handleComponentUpdateOld = exports.getBlockletJs = exports.Events = exports.events = exports.components = exports.env = exports.logger = void 0;
|
|
6
|
+
exports._handleComponentConfigUpdate = exports._handleComponentRemoved = exports._handleComponentStopped = exports._handleComponentStarted = exports._handleComponentUpdated = exports._handleComponentInstalled = exports._handleConfigUpdate = exports._handleComponentUpdateOld = exports.getBlockletJs = exports.Events = exports.events = exports.components = exports.env = exports.setLogger = exports.logger = void 0;
|
|
7
7
|
/* eslint-disable prettier/prettier */
|
|
8
8
|
/* eslint-disable no-console */
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
@@ -48,7 +48,8 @@ const AppConfigKeyMap = {
|
|
|
48
48
|
ABT_NODE_VERSION: 'serverVersion',
|
|
49
49
|
ABT_NODE: 'serverVersion', // for backup compatibility
|
|
50
50
|
};
|
|
51
|
-
|
|
51
|
+
// eslint-disable-next-line import/no-mutable-exports
|
|
52
|
+
let logger = {
|
|
52
53
|
info: console.info,
|
|
53
54
|
debug: (...args) => {
|
|
54
55
|
if (process.env.NODE_ENV === 'development') {
|
|
@@ -59,6 +60,10 @@ const logger = {
|
|
|
59
60
|
error: console.error,
|
|
60
61
|
};
|
|
61
62
|
exports.logger = logger;
|
|
63
|
+
const setLogger = (newLogger) => {
|
|
64
|
+
exports.logger = logger = newLogger;
|
|
65
|
+
};
|
|
66
|
+
exports.setLogger = setLogger;
|
|
62
67
|
const appDataDir = process.env.BLOCKLET_APP_DATA_DIR;
|
|
63
68
|
let appEnvFromDisk = {};
|
|
64
69
|
let envFromDisk = {};
|
|
@@ -336,6 +341,7 @@ if (inRuntimeEnv && !process.env.BLOCKLET_HOOK_NAME && process.env.BLOCKLET_MODE
|
|
|
336
341
|
}
|
|
337
342
|
exports.default = {
|
|
338
343
|
logger,
|
|
344
|
+
setLogger,
|
|
339
345
|
env,
|
|
340
346
|
components: componentStore,
|
|
341
347
|
events,
|
package/lib/connect/handler.js
CHANGED
|
@@ -38,12 +38,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
const get_1 = __importDefault(require("lodash/get"));
|
|
39
39
|
const handler_1 = require("@did-connect/handler");
|
|
40
40
|
const notification_1 = __importStar(require("../service/notification"));
|
|
41
|
-
const
|
|
41
|
+
const config_1 = __importDefault(require("../config"));
|
|
42
42
|
// whether app web page is in mobile DID wallet
|
|
43
43
|
const inMobileWallet = (didwallet) => {
|
|
44
44
|
return didwallet && ['ios', 'android'].includes(didwallet.os);
|
|
45
45
|
};
|
|
46
|
-
const consoleLogger = { info: noop, error: console.error, warn: console.warn, debug: noop };
|
|
47
46
|
const getConnectedDid = (session) => {
|
|
48
47
|
if (session.autoConnect === false) {
|
|
49
48
|
return '';
|
|
@@ -53,7 +52,7 @@ const getConnectedDid = (session) => {
|
|
|
53
52
|
}
|
|
54
53
|
return (0, get_1.default)(session, 'previousConnected.userDid', '');
|
|
55
54
|
};
|
|
56
|
-
const createConnectHandlers = ({ authenticator, storage, logger =
|
|
55
|
+
const createConnectHandlers = ({ authenticator, storage, logger = config_1.default.logger, socketPathname, sendNotificationFn, }) => {
|
|
57
56
|
const handlers = (0, handler_1.createHandlers)({
|
|
58
57
|
storage,
|
|
59
58
|
authenticator,
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.verifyBlockletSig = void 0;
|
|
4
|
-
const config_1 = require("../config");
|
|
7
|
+
const config_1 = __importDefault(require("../config"));
|
|
5
8
|
const verify_sign_1 = require("../util/verify-sign");
|
|
6
9
|
const verifyBlockletSig = (req, res, next) => {
|
|
7
10
|
try {
|
|
@@ -11,12 +14,12 @@ const verifyBlockletSig = (req, res, next) => {
|
|
|
11
14
|
}
|
|
12
15
|
const verified = (0, verify_sign_1.verify)(data, sig);
|
|
13
16
|
if (!verified) {
|
|
14
|
-
config_1.logger.error('verify blocklet sig failed', { data, sig });
|
|
17
|
+
config_1.default.logger.error('verify blocklet sig failed', { data, sig });
|
|
15
18
|
return res.status(401).json({ error: 'verify sig failed' });
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
catch (error) {
|
|
19
|
-
config_1.logger.error('verify blocklet sig failed', { error });
|
|
22
|
+
config_1.default.logger.error('verify blocklet sig failed', { error });
|
|
20
23
|
return res.status(401).json({ error: 'verify sig failed' });
|
|
21
24
|
}
|
|
22
25
|
return next();
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.verifySig = void 0;
|
|
4
|
-
const config_1 = require("../config");
|
|
7
|
+
const config_1 = __importDefault(require("../config"));
|
|
5
8
|
const verify_sign_1 = require("../util/verify-sign");
|
|
6
9
|
const verifySig = async (req, res, next) => {
|
|
7
10
|
try {
|
|
@@ -11,12 +14,12 @@ const verifySig = async (req, res, next) => {
|
|
|
11
14
|
}
|
|
12
15
|
const verified = await (0, verify_sign_1.verify)(data, sig);
|
|
13
16
|
if (!verified) {
|
|
14
|
-
config_1.logger.error('verify component sig failed', { data, sig });
|
|
17
|
+
config_1.default.logger.error('verify component sig failed', { data, sig });
|
|
15
18
|
return res.status(401).json({ error: 'verify sig failed' });
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
catch (error) {
|
|
19
|
-
config_1.logger.error('verify component sig failed', { error });
|
|
22
|
+
config_1.default.logger.error('verify component sig failed', { error });
|
|
20
23
|
return res.status(401).json({ error: 'verify sig failed' });
|
|
21
24
|
}
|
|
22
25
|
return next();
|
package/lib/middlewares/csrf.js
CHANGED
|
@@ -8,9 +8,9 @@ const isEmpty_1 = __importDefault(require("lodash/isEmpty"));
|
|
|
8
8
|
const joi_1 = __importDefault(require("joi"));
|
|
9
9
|
const digest_1 = require("../util/digest");
|
|
10
10
|
const wallet_1 = require("../util/wallet");
|
|
11
|
-
const config_1 = require("../config");
|
|
11
|
+
const config_1 = __importDefault(require("../config"));
|
|
12
12
|
function printCookieParserNotInstalledWarning() {
|
|
13
|
-
config_1.logger.warn('cookie-parser middleware is required for the csrf middleware to work properly.');
|
|
13
|
+
config_1.default.logger.warn('cookie-parser middleware is required for the csrf middleware to work properly.');
|
|
14
14
|
}
|
|
15
15
|
function defaultGenerateToken(req, res) {
|
|
16
16
|
if (!req.cookies) {
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.38-beta-
|
|
6
|
+
"version": "1.16.38-beta-20250207-102532-5be12f2c",
|
|
7
7
|
"description": "graphql client to read/write data on abt node",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"typings": "lib/index.d.ts",
|
|
@@ -27,22 +27,22 @@
|
|
|
27
27
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@abtnode/client": "1.16.38-beta-
|
|
31
|
-
"@abtnode/constant": "1.16.38-beta-
|
|
32
|
-
"@abtnode/util": "1.16.38-beta-
|
|
33
|
-
"@arcblock/did": "1.19.
|
|
34
|
-
"@arcblock/did-auth": "1.19.
|
|
35
|
-
"@arcblock/jwt": "1.19.
|
|
36
|
-
"@arcblock/ws": "1.19.
|
|
37
|
-
"@blocklet/constant": "1.16.38-beta-
|
|
38
|
-
"@blocklet/env": "1.16.38-beta-
|
|
39
|
-
"@blocklet/meta": "1.16.38-beta-
|
|
30
|
+
"@abtnode/client": "1.16.38-beta-20250207-102532-5be12f2c",
|
|
31
|
+
"@abtnode/constant": "1.16.38-beta-20250207-102532-5be12f2c",
|
|
32
|
+
"@abtnode/util": "1.16.38-beta-20250207-102532-5be12f2c",
|
|
33
|
+
"@arcblock/did": "1.19.9",
|
|
34
|
+
"@arcblock/did-auth": "1.19.9",
|
|
35
|
+
"@arcblock/jwt": "1.19.9",
|
|
36
|
+
"@arcblock/ws": "1.19.9",
|
|
37
|
+
"@blocklet/constant": "1.16.38-beta-20250207-102532-5be12f2c",
|
|
38
|
+
"@blocklet/env": "1.16.38-beta-20250207-102532-5be12f2c",
|
|
39
|
+
"@blocklet/meta": "1.16.38-beta-20250207-102532-5be12f2c",
|
|
40
40
|
"@did-connect/authenticator": "^2.2.7",
|
|
41
41
|
"@did-connect/handler": "^2.2.7",
|
|
42
42
|
"@nedb/core": "^2.1.5",
|
|
43
|
-
"@ocap/mcrypto": "1.19.
|
|
44
|
-
"@ocap/util": "1.19.
|
|
45
|
-
"@ocap/wallet": "1.19.
|
|
43
|
+
"@ocap/mcrypto": "1.19.9",
|
|
44
|
+
"@ocap/util": "1.19.9",
|
|
45
|
+
"@ocap/wallet": "1.19.9",
|
|
46
46
|
"axios": "^1.7.9",
|
|
47
47
|
"cheerio": "1.0.0-rc.12",
|
|
48
48
|
"debug": "^4.3.7",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"ts-node": "^10.9.1",
|
|
83
83
|
"typescript": "^5.6.3"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "bb8ce42b8f2c2f02ce3b3074e50d5c70d066d5b0"
|
|
86
86
|
}
|