@blocklet/sdk 1.6.21 → 1.6.22-beta

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.
@@ -5,6 +5,8 @@ const getWallet = require('./wallet');
5
5
  const checkBlockletEnv = require('./util/check-blocklet-env');
6
6
  const { AUTH_SERVICE_PREFIX } = require('./util/constants');
7
7
 
8
+ const env = require('./env');
9
+
8
10
  // wraps value in closure or returns closure
9
11
  const closure = (value) => (typeof value === 'function' ? value : () => value);
10
12
 
@@ -26,17 +28,26 @@ class WalletAuthenticator extends Authenticator {
26
28
  const info = await closure(options.appInfo)(...args);
27
29
 
28
30
  const { request, baseUrl } = args[0];
29
- const groupPathPrefix = request.headers['x-group-path-prefix'] || '/';
31
+ const rootPath = '/';
32
+ const pathPrefix = request.headers['x-path-prefix'] || rootPath;
33
+ const groupPathPrefix = request.headers['x-group-path-prefix'] || rootPath;
30
34
  const blockletDid = request.headers['x-blocklet-did'];
31
35
 
36
+ let appUrl = baseUrl;
37
+ let subscriptionPath = joinUrl(groupPathPrefix, AUTH_SERVICE_PREFIX, 'websocket');
38
+ if (env.isComponent && pathPrefix !== rootPath) {
39
+ appUrl = joinUrl(appUrl, rootPath).replace(pathPrefix, rootPath);
40
+ subscriptionPath = joinUrl(pathPrefix, subscriptionPath);
41
+ }
42
+
32
43
  return {
33
44
  name: process.env.BLOCKLET_APP_NAME,
34
45
  description: process.env.BLOCKLET_APP_DESCRIPTION,
35
46
  ...(info || {}),
36
- link: baseUrl,
47
+ link: appUrl,
37
48
  icon: joinUrl(baseUrl, AUTH_SERVICE_PREFIX, `/blocklet/logo/${blockletDid}`),
38
49
  updateSubEndpoint: true,
39
- subscriptionEndpoint: joinUrl(groupPathPrefix, AUTH_SERVICE_PREFIX, 'websocket'),
50
+ subscriptionEndpoint: subscriptionPath,
40
51
  nodeDid: process.env.ABT_NODE_DID,
41
52
  };
42
53
  },
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.6.21",
6
+ "version": "1.6.22-beta",
7
7
  "description": "graphql client to read/write data on abt node",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,15 +19,15 @@
19
19
  "author": "linchen1987 <linchen.1987@foxmail.com> (http://github.com/linchen1987)",
20
20
  "license": "MIT",
21
21
  "dependencies": {
22
- "@abtnode/client": "1.6.21",
23
- "@abtnode/constant": "1.6.21",
24
- "@arcblock/did-auth": "^1.14.13",
25
- "@arcblock/jwt": "^1.14.13",
26
- "@arcblock/ws": "^1.14.13",
27
- "@blocklet/meta": "1.6.21",
22
+ "@abtnode/client": "1.6.22",
23
+ "@abtnode/constant": "1.6.22",
24
+ "@arcblock/did-auth": "^1.14.17",
25
+ "@arcblock/jwt": "^1.14.17",
26
+ "@arcblock/ws": "^1.14.17",
27
+ "@blocklet/meta": "1.6.22",
28
28
  "@nedb/core": "^1.2.2",
29
- "@ocap/mcrypto": "^1.14.13",
30
- "@ocap/wallet": "^1.14.13",
29
+ "@ocap/mcrypto": "^1.14.17",
30
+ "@ocap/wallet": "^1.14.17",
31
31
  "axios": "^0.25.0",
32
32
  "fs-extra": "^10.0.0",
33
33
  "joi": "^17.6.0",
@@ -38,6 +38,5 @@
38
38
  "devDependencies": {
39
39
  "detect-port": "^1.3.0",
40
40
  "jest": "^27.4.5"
41
- },
42
- "gitHead": "864ae21711c119948475057a1f634fd7d16ae91a"
41
+ }
43
42
  }