@blocklet/sdk 1.16.13-next-49f83c002 → 1.16.13
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 -5
- package/lib/config.js +1 -1
- package/lib/index.d.ts +6 -1
- package/lib/service/auth.d.ts +8 -0
- package/lib/service/auth.js +20 -0
- package/lib/service/notification.js +5 -2
- package/package.json +8 -7
package/lib/component/index.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.getParentWebEndpoint = exports.getChildWebEndpoint = exports.getComponen
|
|
|
7
7
|
const util_1 = require("@blocklet/meta/lib/util");
|
|
8
8
|
const axios_1 = __importDefault(require("axios"));
|
|
9
9
|
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
+
const omit_1 = __importDefault(require("lodash/omit"));
|
|
10
11
|
const url_join_1 = __importDefault(require("url-join"));
|
|
11
12
|
const constant_1 = require("@blocklet/constant");
|
|
12
13
|
const config_1 = require("../config");
|
|
@@ -25,16 +26,13 @@ const doCall = async ({ url, ...options }) => {
|
|
|
25
26
|
return resp;
|
|
26
27
|
}
|
|
27
28
|
catch (error) {
|
|
28
|
-
delete error.config;
|
|
29
|
-
delete error.request;
|
|
30
|
-
delete error.response;
|
|
31
29
|
config_1.logger.error(`call ${url} api failed`, {
|
|
32
30
|
url,
|
|
33
31
|
responseStatus: (0, get_1.default)(error, 'response.status'),
|
|
34
32
|
responseData: (0, get_1.default)(error, 'response.data'),
|
|
35
|
-
error,
|
|
33
|
+
error: (0, omit_1.default)(error, 'response'),
|
|
36
34
|
});
|
|
37
|
-
throw
|
|
35
|
+
throw error;
|
|
38
36
|
}
|
|
39
37
|
};
|
|
40
38
|
const parsePorts = () => JSON.parse(process.env.BLOCKLET_WEB_PORTS);
|
package/lib/config.js
CHANGED
|
@@ -84,7 +84,7 @@ const handleConfigUpdate = (data) => {
|
|
|
84
84
|
};
|
|
85
85
|
exports.handleConfigUpdate = handleConfigUpdate;
|
|
86
86
|
const inRuntimeEnv = !!process.env.BLOCKLET_APP_SK;
|
|
87
|
-
if (inRuntimeEnv) {
|
|
87
|
+
if (inRuntimeEnv && !process.env.BLOCKLET_HOOK_NAME) {
|
|
88
88
|
notification_1.default.on(constant_1.BlockletInternalEvents.componentsUpdated, handleComponentUpdate);
|
|
89
89
|
notification_1.default.on(constant_1.BlockletInternalEvents.appConfigChanged, handleConfigUpdate);
|
|
90
90
|
}
|
package/lib/index.d.ts
CHANGED
|
@@ -43,10 +43,15 @@ declare global {
|
|
|
43
43
|
isComponent: boolean;
|
|
44
44
|
prefix: string;
|
|
45
45
|
groupPrefix: string;
|
|
46
|
+
pageGroup: string;
|
|
46
47
|
version: string;
|
|
47
48
|
theme: TTheme;
|
|
48
49
|
navigation: TNavigation[];
|
|
49
|
-
preferences: any
|
|
50
|
+
preferences: Record<string, any>;
|
|
51
|
+
languages: {
|
|
52
|
+
code: string;
|
|
53
|
+
name: string;
|
|
54
|
+
}[];
|
|
50
55
|
componentMountPoints: MountPoint[];
|
|
51
56
|
alsoKnownAs: string[];
|
|
52
57
|
trustedFactories: string[];
|
package/lib/service/auth.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ interface AuthService {
|
|
|
10
10
|
login: (params: object) => Promise<{
|
|
11
11
|
user: Object;
|
|
12
12
|
token: string;
|
|
13
|
+
refreshToken: string;
|
|
14
|
+
}>;
|
|
15
|
+
refreshSession: (params: {
|
|
16
|
+
refreshToken: string;
|
|
17
|
+
}) => Promise<{
|
|
18
|
+
user: Object;
|
|
19
|
+
token: string;
|
|
20
|
+
refreshToken: string;
|
|
13
21
|
}>;
|
|
14
22
|
getUser(did: string, options?: {
|
|
15
23
|
enableConnectedAccount?: boolean;
|
package/lib/service/auth.js
CHANGED
|
@@ -64,6 +64,7 @@ class AuthService {
|
|
|
64
64
|
const apiList = [
|
|
65
65
|
// user
|
|
66
66
|
'login',
|
|
67
|
+
'refreshSession',
|
|
67
68
|
'getUsers',
|
|
68
69
|
'getUser',
|
|
69
70
|
'getOwner',
|
|
@@ -146,6 +147,25 @@ class AuthService {
|
|
|
146
147
|
throw new Error(err.response ? err.response.data : err.message);
|
|
147
148
|
}
|
|
148
149
|
};
|
|
150
|
+
this.refreshSession = async (data) => {
|
|
151
|
+
try {
|
|
152
|
+
const { data: resData } = await service_api_1.default.post('/api/did/refreshSession', {
|
|
153
|
+
refresh_token: data.refreshToken,
|
|
154
|
+
});
|
|
155
|
+
if (resData?.user) {
|
|
156
|
+
fixAvatar(resData.user);
|
|
157
|
+
}
|
|
158
|
+
return {
|
|
159
|
+
user: resData.user,
|
|
160
|
+
token: resData.nextToken,
|
|
161
|
+
refreshToken: resData?.nextRefreshToken,
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
console.error(err.response ? err.response.data : err);
|
|
166
|
+
throw new Error(err.response ? err.response.data : err.message);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
149
169
|
// eslint-disable-next-line no-constructor-return
|
|
150
170
|
return new Proxy(this, {
|
|
151
171
|
get(target, propKey) {
|
|
@@ -88,15 +88,18 @@ exports.broadcast = broadcast;
|
|
|
88
88
|
const noop = () => { };
|
|
89
89
|
const emitter = new events_1.default();
|
|
90
90
|
const messageEmitter = new events_1.default();
|
|
91
|
-
emitter.on('error', noop);
|
|
92
|
-
messageEmitter.on('error', noop);
|
|
93
91
|
const emitError = (error) => {
|
|
94
92
|
messageEmitter.emit('error', error);
|
|
95
93
|
emitter.emit('error', error);
|
|
96
94
|
};
|
|
95
|
+
const ensureErrorListener = () => {
|
|
96
|
+
emitter.on('error', noop);
|
|
97
|
+
messageEmitter.on('error', noop);
|
|
98
|
+
};
|
|
97
99
|
let client = null;
|
|
98
100
|
const initClient = () => {
|
|
99
101
|
if (!client) {
|
|
102
|
+
ensureErrorListener();
|
|
100
103
|
const wallet = (0, wallet_1.getPermanentWallet)();
|
|
101
104
|
const { address: did, publicKey: pk, secretKey: sk } = wallet;
|
|
102
105
|
const url = `ws://127.0.0.1:${process.env.ABT_NODE_SERVICE_PORT}${constants_1.SERVICE_PREFIX}`;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.13
|
|
6
|
+
"version": "1.16.13",
|
|
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",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@abtnode/client": "1.16.
|
|
30
|
-
"@abtnode/constant": "1.16.
|
|
29
|
+
"@abtnode/client": "1.16.13",
|
|
30
|
+
"@abtnode/constant": "1.16.13",
|
|
31
31
|
"@arcblock/did": "1.18.84",
|
|
32
32
|
"@arcblock/did-auth": "1.18.84",
|
|
33
33
|
"@arcblock/jwt": "1.18.84",
|
|
34
34
|
"@arcblock/ws": "1.18.84",
|
|
35
|
-
"@blocklet/constant": "1.16.
|
|
36
|
-
"@blocklet/env": "1.16.
|
|
37
|
-
"@blocklet/meta": "1.16.
|
|
35
|
+
"@blocklet/constant": "1.16.13",
|
|
36
|
+
"@blocklet/env": "1.16.13",
|
|
37
|
+
"@blocklet/meta": "1.16.13",
|
|
38
38
|
"@did-connect/authenticator": "^2.1.59",
|
|
39
39
|
"@did-connect/handler": "^2.1.59",
|
|
40
40
|
"@nedb/core": "^2.1.5",
|
|
@@ -72,5 +72,6 @@
|
|
|
72
72
|
"ts-jest": "^27.1.5",
|
|
73
73
|
"ts-node": "^10.9.1",
|
|
74
74
|
"typescript": "^5.0.4"
|
|
75
|
-
}
|
|
75
|
+
},
|
|
76
|
+
"gitHead": "0f07f6617a8cf53a4fa693d6ca227f6f6bd90af2"
|
|
76
77
|
}
|