@abtnode/util 1.16.14-beta-08abf537 → 1.16.14-beta-c775fe49
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-document.js +33 -11
- package/lib/url-evaluation/index.js +12 -2
- package/package.json +5 -5
package/lib/did-document.js
CHANGED
|
@@ -76,19 +76,30 @@ const getServerServices = ({ ips, wallet, domain }) => {
|
|
|
76
76
|
return services;
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
const getBlockletServices = ({ appPid, daemonDidDomain, domain }) => {
|
|
79
|
+
const getBlockletServices = ({ appPid, slpDid, daemonDidDomain, domain, slpDomain }) => {
|
|
80
|
+
const records = [
|
|
81
|
+
{
|
|
82
|
+
type: 'CNAME',
|
|
83
|
+
rr: encodeBase32(appPid),
|
|
84
|
+
value: daemonDidDomain,
|
|
85
|
+
domain,
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
|
|
89
|
+
if (slpDid) {
|
|
90
|
+
records.push({
|
|
91
|
+
type: 'CNAME',
|
|
92
|
+
rr: encodeBase32(slpDid),
|
|
93
|
+
value: daemonDidDomain,
|
|
94
|
+
domain: slpDomain,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
80
98
|
return [
|
|
81
99
|
{
|
|
82
100
|
id: getDID(appPid),
|
|
83
101
|
type: 'DNSRecords',
|
|
84
|
-
records
|
|
85
|
-
{
|
|
86
|
-
type: 'CNAME',
|
|
87
|
-
rr: encodeBase32(appPid),
|
|
88
|
-
value: daemonDidDomain,
|
|
89
|
-
domain,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
102
|
+
records,
|
|
92
103
|
},
|
|
93
104
|
];
|
|
94
105
|
};
|
|
@@ -105,8 +116,19 @@ const updateServerDocument = async ({ ips, wallet, didRegistryUrl, domain }) =>
|
|
|
105
116
|
return updateWithRetry({ id: getDID(wallet.address), services, didRegistryUrl, wallet });
|
|
106
117
|
};
|
|
107
118
|
|
|
108
|
-
const updateBlockletDocument = ({
|
|
109
|
-
|
|
119
|
+
const updateBlockletDocument = ({
|
|
120
|
+
blocklet,
|
|
121
|
+
slpDid,
|
|
122
|
+
wallet,
|
|
123
|
+
didRegistryUrl,
|
|
124
|
+
domain,
|
|
125
|
+
slpDomain,
|
|
126
|
+
daemonDidDomain,
|
|
127
|
+
alsoKnownAs = [],
|
|
128
|
+
}) => {
|
|
129
|
+
const { appPid } = blocklet;
|
|
130
|
+
|
|
131
|
+
const services = getBlockletServices({ appPid, slpDid, daemonDidDomain, domain, slpDomain });
|
|
110
132
|
return updateWithRetry({ id: appPid, services, didRegistryUrl, alsoKnownAs, wallet });
|
|
111
133
|
};
|
|
112
134
|
|
|
@@ -12,8 +12,12 @@ const isDidDomain = (hostname) => {
|
|
|
12
12
|
return hostname.endsWith('.did.abtnet.io');
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
const isSlpDomain = (hostname) => {
|
|
16
|
+
return hostname.endsWith('.slp.abtnet.io');
|
|
17
|
+
};
|
|
18
|
+
|
|
15
19
|
const isCustomDomain = (domain) => {
|
|
16
|
-
return !isIpEcho(domain) && !isDidDomain(domain) && !isIpAddress(domain);
|
|
20
|
+
return !isIpEcho(domain) && !isDidDomain(domain) && !isSlpDomain(domain) && !isIpAddress(domain);
|
|
17
21
|
};
|
|
18
22
|
|
|
19
23
|
/**
|
|
@@ -30,7 +34,12 @@ const evaluateURL = async (url, options = {}) => {
|
|
|
30
34
|
// 子层越多越靠后
|
|
31
35
|
score -= hostname.split('.').length;
|
|
32
36
|
} else {
|
|
33
|
-
//
|
|
37
|
+
// slp 地址优先级高于 did 地址
|
|
38
|
+
if (isSlpDomain(hostname)) {
|
|
39
|
+
score += 22;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// did 地址优先级高于 ip echo 地址
|
|
34
43
|
if (isDidDomain(hostname)) {
|
|
35
44
|
score += 21;
|
|
36
45
|
}
|
|
@@ -83,6 +92,7 @@ const evaluateURLs = async (urls, options = {}) => {
|
|
|
83
92
|
module.exports = {
|
|
84
93
|
isIpEcho,
|
|
85
94
|
isDidDomain,
|
|
95
|
+
isSlpDomain,
|
|
86
96
|
evaluateURL,
|
|
87
97
|
evaluateURLs,
|
|
88
98
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.14-beta-
|
|
6
|
+
"version": "1.16.14-beta-c775fe49",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,9 +18,9 @@
|
|
|
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.14-beta-
|
|
22
|
-
"@abtnode/logger": "1.16.14-beta-
|
|
23
|
-
"@blocklet/constant": "1.16.14-beta-
|
|
21
|
+
"@abtnode/constant": "1.16.14-beta-c775fe49",
|
|
22
|
+
"@abtnode/logger": "1.16.14-beta-c775fe49",
|
|
23
|
+
"@blocklet/constant": "1.16.14-beta-c775fe49",
|
|
24
24
|
"@ocap/client": "1.18.88",
|
|
25
25
|
"@ocap/mcrypto": "1.18.88",
|
|
26
26
|
"@ocap/util": "1.18.88",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"fs-extra": "^10.1.0",
|
|
72
72
|
"jest": "^27.5.1"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "8a87fffd7e47a2573d3fec7b8b23559b204726f5"
|
|
75
75
|
}
|