core-3nweb-client-lib 0.30.1 → 0.30.2
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.
|
@@ -172,19 +172,57 @@ function noServiceRecordExc(address) {
|
|
|
172
172
|
*/
|
|
173
173
|
function extractPair(txtRecords, serviceLabel) {
|
|
174
174
|
for (const txtRecord of txtRecords) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
175
|
+
let joinedTXTstanzas = txtRecord.join('');
|
|
176
|
+
let record = getRecordAtStartOf(joinedTXTstanzas);
|
|
177
|
+
while (record) {
|
|
178
|
+
if (record.service === serviceLabel) {
|
|
179
|
+
const value = record.value.trim();
|
|
180
|
+
if (value.length > 0) {
|
|
181
|
+
return value;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (record.txtTail) {
|
|
185
|
+
record = getRecordAtStartOf(record.txtTail);
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
184
190
|
}
|
|
185
191
|
}
|
|
186
192
|
return;
|
|
187
193
|
}
|
|
194
|
+
const recordsStarts = {
|
|
195
|
+
"3nstorage": '3nstorage=',
|
|
196
|
+
asmail: 'asmail=',
|
|
197
|
+
mailerid: 'mailerid='
|
|
198
|
+
};
|
|
199
|
+
function getRecordAtStartOf(txt) {
|
|
200
|
+
let service = undefined;
|
|
201
|
+
for (const [label, startSeq] of Object.entries(recordsStarts)) {
|
|
202
|
+
if (txt.startsWith(startSeq)) {
|
|
203
|
+
service = label;
|
|
204
|
+
txt = txt.substring(startSeq.length);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (!service) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
for (const delimiter of Object.values(recordsStarts)) {
|
|
212
|
+
const endPos = txt.indexOf(delimiter);
|
|
213
|
+
if (endPos >= 0) {
|
|
214
|
+
return {
|
|
215
|
+
service,
|
|
216
|
+
value: txt.substring(0, endPos),
|
|
217
|
+
txtTail: txt.substring(endPos)
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return {
|
|
222
|
+
service,
|
|
223
|
+
value: txt
|
|
224
|
+
};
|
|
225
|
+
}
|
|
188
226
|
const DNS_ERR_CODE = {
|
|
189
227
|
NODATA: 'ENODATA',
|
|
190
228
|
NOTFOUND: 'ENOTFOUND'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-3nweb-client-lib",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.2",
|
|
4
4
|
"description": "3NWeb client core library, embeddable into different environments",
|
|
5
5
|
"main": "build/lib-index.js",
|
|
6
6
|
"types": "build/lib-index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/ws": "^7.4.7",
|
|
42
42
|
"jasmine": "^3.9.0",
|
|
43
43
|
"protobufjs-cli": "^1.0.2",
|
|
44
|
-
"spec-3nweb-server": "^1.
|
|
44
|
+
"spec-3nweb-server": "^1.7.0",
|
|
45
45
|
"tsuml2": "^0.6.1",
|
|
46
46
|
"typescript": "^4.7.4"
|
|
47
47
|
}
|