@blocklet/sdk 1.8.26 → 1.8.28

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.
@@ -1,15 +1,12 @@
1
1
  const joinUrl = require('url-join');
2
- const { getConnectAppUrl } = require('@blocklet/meta/lib/util');
2
+ const { getConnectAppUrl, getChainInfo } = require('@blocklet/meta/lib/util');
3
3
  const { SERVICE_PREFIX } = require('../util/constants');
4
4
 
5
5
  // wraps value in closure or returns closure
6
6
  const closure = (value) => (typeof value === 'function' ? value : () => value);
7
7
 
8
8
  module.exports = (options = {}) => ({
9
- chainInfo: () => {
10
- const chainHost = process.env.CHAIN_HOST;
11
- return chainHost ? { host: chainHost, id: 'chain' } : { host: 'none', id: 'none' };
12
- },
9
+ chainInfo: () => getChainInfo(process.env),
13
10
 
14
11
  ...options,
15
12
 
@@ -25,7 +22,7 @@ module.exports = (options = {}) => ({
25
22
  description: process.env.BLOCKLET_APP_DESCRIPTION,
26
23
  ...(info || {}),
27
24
  link: getConnectAppUrl(args[0]),
28
- icon: joinUrl(baseUrl, SERVICE_PREFIX, `/blocklet/logo/${blockletDid}`),
25
+ icon: process.env.BLOCKLET_APP_LOGO || joinUrl(baseUrl, SERVICE_PREFIX, `/blocklet/logo/${blockletDid}`),
29
26
  updateSubEndpoint: true,
30
27
  subscriptionEndpoint: joinUrl(groupPathPrefix, SERVICE_PREFIX, 'websocket'),
31
28
  nodeDid: process.env.ABT_NODE_DID,
@@ -1,8 +1,14 @@
1
1
  const pickBy = require('lodash/pickBy');
2
+ const joinUrl = require('url-join');
2
3
  const Client = require('@abtnode/client');
3
4
  const { types } = require('@ocap/mcrypto');
4
5
  const { WalletType } = require('@ocap/wallet');
5
- const { NODE_SERVICES } = require('@abtnode/constant');
6
+ const {
7
+ NODE_SERVICES,
8
+ WELLKNOWN_SERVICE_PATH_PREFIX,
9
+ USER_AVATAR_URL_PREFIX,
10
+ USER_AVATAR_PATH_PREFIX,
11
+ } = require('@abtnode/constant');
6
12
 
7
13
  const VERSION = require('../../package.json').version; // version of notification sdk
8
14
  const checkBlockletEnv = require('../util/check-blocklet-env');
@@ -87,7 +93,21 @@ class AuthService extends Client {
87
93
  const apiConvertDid = (fn) => (did) => fn({ input: { user: { did }, teamDid } });
88
94
 
89
95
  const apiFnMap = {
90
- getUser: apiConvertDid,
96
+ getUser: (fn) => async (did) => {
97
+ const res = await fn({ input: { user: { did }, teamDid } });
98
+
99
+ // convert avatar
100
+ const avatar = res?.user?.avatar;
101
+ if (avatar && avatar.startsWith(USER_AVATAR_URL_PREFIX)) {
102
+ res.user.avatar = joinUrl(
103
+ WELLKNOWN_SERVICE_PATH_PREFIX,
104
+ USER_AVATAR_PATH_PREFIX,
105
+ avatar.replace(USER_AVATAR_URL_PREFIX, '')
106
+ );
107
+ }
108
+
109
+ return res;
110
+ },
91
111
  removeUser: apiConvertDid,
92
112
  updateUserRole: (fn) => (did, role) => fn({ input: { user: { did, role }, teamDid } }),
93
113
  updateUserApproval: (fn) => (did, approved) => fn({ input: { user: { did, approved }, teamDid } }),
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.8.26",
6
+ "version": "1.8.28",
7
7
  "description": "graphql client to read/write data on abt node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,20 +19,21 @@
19
19
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@abtnode/client": "1.8.26",
23
- "@abtnode/constant": "1.8.26",
24
- "@arcblock/did-auth": "1.17.19",
25
- "@arcblock/jwt": "1.17.19",
26
- "@arcblock/ws": "1.17.19",
27
- "@blocklet/meta": "1.8.26",
28
- "@did-connect/authenticator": "^2.1.20",
29
- "@did-connect/handler": "^2.1.20",
22
+ "@abtnode/client": "1.8.28",
23
+ "@abtnode/constant": "1.8.28",
24
+ "@arcblock/did-auth": "1.17.23",
25
+ "@arcblock/jwt": "1.17.23",
26
+ "@arcblock/ws": "1.17.23",
27
+ "@blocklet/constant": "1.8.28",
28
+ "@blocklet/meta": "1.8.28",
29
+ "@did-connect/authenticator": "^2.1.23",
30
+ "@did-connect/handler": "^2.1.23",
30
31
  "@nedb/core": "^2.0.4",
31
- "@ocap/mcrypto": "1.17.19",
32
- "@ocap/wallet": "1.17.19",
32
+ "@ocap/mcrypto": "1.17.23",
33
+ "@ocap/wallet": "1.17.23",
33
34
  "axios": "^0.27.2",
34
35
  "fs-extra": "^10.1.0",
35
- "joi": "^17.6.0",
36
+ "joi": "^17.6.2",
36
37
  "json-stable-stringify": "^1.0.1",
37
38
  "lodash": "^4.17.21",
38
39
  "lru-cache": "^6.0.0",
@@ -42,8 +43,8 @@
42
43
  "@nedb/core": "^2.0.4"
43
44
  },
44
45
  "devDependencies": {
45
- "detect-port": "^1.3.0",
46
+ "detect-port": "^1.5.1",
46
47
  "jest": "^27.5.1"
47
48
  },
48
- "gitHead": "71937dabc196a98a1bb514789bc32aee44a1e8c4"
49
+ "gitHead": "af7aacf5507177600ae563ab597cb42d7223b113"
49
50
  }