@abtnode/util 1.16.22-beta-5bf86cd3 → 1.16.22-beta-87e027a7
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/did-domain.js +28 -0
- package/package.json +6 -6
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const joinURL = require('url-join');
|
|
2
|
+
|
|
3
|
+
const axios = require('./axios');
|
|
4
|
+
|
|
5
|
+
const DID_DOMAIN_SERVICE_DID = 'z2qaGosS3rZ7m5ttP3Nd4V4qczR9TryTcRV4p';
|
|
6
|
+
|
|
7
|
+
const getDidDomainServiceURL = async (url) => {
|
|
8
|
+
if (!url || !url?.trim()) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const urlObj = new URL(url);
|
|
13
|
+
urlObj.pathname = '__blocklet__.js';
|
|
14
|
+
urlObj.searchParams.set('type', 'json');
|
|
15
|
+
const { data } = await axios.get(urlObj.toString());
|
|
16
|
+
|
|
17
|
+
const component = data?.componentMountPoints?.find((x) => x.did === DID_DOMAIN_SERVICE_DID);
|
|
18
|
+
|
|
19
|
+
const resultUrlObj = new URL(url);
|
|
20
|
+
resultUrlObj.pathname = component?.mountPoint;
|
|
21
|
+
|
|
22
|
+
const baseURL = resultUrlObj.toString();
|
|
23
|
+
const apiURL = joinURL(baseURL, '/api');
|
|
24
|
+
|
|
25
|
+
return { base: baseURL, api: apiURL, domain: joinURL(apiURL, '/domains') };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = { DID_DOMAIN_SERVICE_DID, getDidDomainServiceURL };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.22-beta-
|
|
6
|
+
"version": "1.16.22-beta-87e027a7",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.16.22-beta-
|
|
22
|
-
"@abtnode/logger": "1.16.22-beta-
|
|
23
|
-
"@blocklet/constant": "1.16.22-beta-
|
|
24
|
-
"@blocklet/meta": "1.16.22-beta-
|
|
21
|
+
"@abtnode/constant": "1.16.22-beta-87e027a7",
|
|
22
|
+
"@abtnode/logger": "1.16.22-beta-87e027a7",
|
|
23
|
+
"@blocklet/constant": "1.16.22-beta-87e027a7",
|
|
24
|
+
"@blocklet/meta": "1.16.22-beta-87e027a7",
|
|
25
25
|
"@ocap/client": "1.18.108",
|
|
26
26
|
"@ocap/mcrypto": "1.18.108",
|
|
27
27
|
"@ocap/util": "1.18.108",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"fs-extra": "^10.1.0",
|
|
77
77
|
"jest": "^27.5.1"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "c1b0c1d0b1d2504d4738cd5981e6e52872e4e1ce"
|
|
80
80
|
}
|