core-3nweb-client-lib 0.53.2 → 0.53.3
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.
|
@@ -79,7 +79,7 @@ class SignUp {
|
|
|
79
79
|
}
|
|
80
80
|
async setServiceURL(serviceURL) {
|
|
81
81
|
const url = new URL(serviceURL);
|
|
82
|
-
if (url.protocol !== 'https:') {
|
|
82
|
+
if ((url.protocol !== 'https:') && !url.hostname.endsWith('.onion')) {
|
|
83
83
|
throw new Error("Url protocol must be https.");
|
|
84
84
|
}
|
|
85
85
|
this.serviceURL = serviceURL;
|
|
@@ -283,10 +283,12 @@ function checkAndPrepareURLfromDNS(value, address) {
|
|
|
283
283
|
const wellKnownPath = '/.well-known/3nweb.json';
|
|
284
284
|
async function locateInWellKnown(request, address, serviceLabel) {
|
|
285
285
|
const host = domainOfAddress(address);
|
|
286
|
+
const protocol = (host.endsWith('.onion') ? 'http' : 'https');
|
|
286
287
|
try {
|
|
287
288
|
const reply = await request({
|
|
288
289
|
method: 'GET',
|
|
289
|
-
url:
|
|
290
|
+
url: `${protocol}://${host}${wellKnownPath}`,
|
|
291
|
+
responseType: 'json'
|
|
290
292
|
});
|
|
291
293
|
if (reply.status === 200) {
|
|
292
294
|
const recValue = reply.data[serviceLabel];
|
|
@@ -33,7 +33,7 @@ async function checkServicesStartingFromSignup(srvLocator, client, signupUrl, si
|
|
|
33
33
|
}
|
|
34
34
|
async function checkService(service, userDomain) {
|
|
35
35
|
progress === null || progress === void 0 ? void 0 : progress({ start: true, service, userDomain });
|
|
36
|
-
const check = await
|
|
36
|
+
const check = await checkUserDomainNames(srvLocator, service, userDomain);
|
|
37
37
|
recordResult(check);
|
|
38
38
|
if (check.isOk) {
|
|
39
39
|
await checkFstServiceEndpoint(service, check.serviceUrl);
|
|
@@ -125,12 +125,7 @@ async function checkSignup(client, signupURL, signupToken) {
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
// { resolveTxt: dns.resolveTxt },
|
|
130
|
-
// dohAt(`https://cloudflare-dns.com/dns-query`),
|
|
131
|
-
// dohAt(`https://dns.google/resolve`)
|
|
132
|
-
// );
|
|
133
|
-
async function checkUserDomainDNS(srvLocator, service, domain) {
|
|
128
|
+
async function checkUserDomainNames(srvLocator, service, domain) {
|
|
134
129
|
try {
|
|
135
130
|
const serviceUrl = await (srvLocator(service, noop))(`u@${domain}`);
|
|
136
131
|
return {
|
|
@@ -23,7 +23,8 @@ exports.getMailerIdInfoFor = getMailerIdInfoFor;
|
|
|
23
23
|
const jwkeys_1 = require("../lib-common/jwkeys");
|
|
24
24
|
const http_1 = require("../lib-common/exceptions/http");
|
|
25
25
|
async function readJSONLocatedAt(client, url) {
|
|
26
|
-
|
|
26
|
+
const u = new URL(url);
|
|
27
|
+
if (u.protocol !== 'https:' && !u.hostname.endsWith('.onion')) {
|
|
27
28
|
throw new Error("Url protocol must be https.");
|
|
28
29
|
}
|
|
29
30
|
const rep = await client.doBodylessRequest({
|
|
@@ -18,15 +18,18 @@
|
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.makeRequestFromNode = makeRequestFromNode;
|
|
20
20
|
const https = require("https");
|
|
21
|
+
const http = require("http");
|
|
21
22
|
const request_utils_1 = require("../lib-client/request-utils");
|
|
22
23
|
function makeRequestFromNode(getAgent) {
|
|
23
|
-
const
|
|
24
|
+
const nodeHttpsRequest = (opts) => https.request(opts);
|
|
25
|
+
const nodeHttpRequest = (opts) => http.request(opts);
|
|
24
26
|
return (opts, reqContentType, reqBody) => {
|
|
25
|
-
const
|
|
27
|
+
const reqOpts = (0, request_utils_1.formHttpsReqOpts)(opts, reqContentType, reqBody);
|
|
26
28
|
const agent = getAgent === null || getAgent === void 0 ? void 0 : getAgent();
|
|
27
29
|
if (agent) {
|
|
28
|
-
|
|
30
|
+
reqOpts.agent = agent;
|
|
29
31
|
}
|
|
30
|
-
|
|
32
|
+
const requestFn = ((reqOpts.protocol === 'http:') ? nodeHttpRequest : nodeHttpsRequest);
|
|
33
|
+
return (0, request_utils_1.processRequest)(requestFn, reqOpts, opts, reqBody);
|
|
31
34
|
};
|
|
32
35
|
}
|