core-3nweb-client-lib 0.42.12 → 0.42.14
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/build/core/index.js +9 -9
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/service-checks.d.ts +18 -0
- package/build/lib-client/service-checks.js +177 -0
- package/build/lib-index.d.ts +1 -0
- package/build/lib-index.js +3 -1
- package/package.json +1 -1
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NetClient } from "./request-utils";
|
|
2
|
+
export interface Check {
|
|
3
|
+
service: 'signup' | 'asmail' | '3nstorage' | 'mailerid';
|
|
4
|
+
}
|
|
5
|
+
export interface CheckStart extends Check {
|
|
6
|
+
start: true;
|
|
7
|
+
userDomain?: string;
|
|
8
|
+
serviceUrl?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CheckResult extends Check {
|
|
11
|
+
isOk: boolean;
|
|
12
|
+
userDomains?: string[];
|
|
13
|
+
userDomain?: string;
|
|
14
|
+
serviceUrl?: string;
|
|
15
|
+
message: string;
|
|
16
|
+
err?: any;
|
|
17
|
+
}
|
|
18
|
+
export declare function checkServicesStartingFromSignup(client: NetClient, signupUrl: string, signupToken: string | undefined, progress?: (result: CheckResult | CheckStart) => void): Promise<CheckResult[]>;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2025 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.checkServicesStartingFromSignup = checkServicesStartingFromSignup;
|
|
20
|
+
const _3nweb_signup_1 = require("./3nweb-signup");
|
|
21
|
+
const service_locator_1 = require("./service-locator");
|
|
22
|
+
const dns_1 = require("dns");
|
|
23
|
+
async function checkServicesStartingFromSignup(client, signupUrl, signupToken, progress) {
|
|
24
|
+
const results = [];
|
|
25
|
+
function recordResult(r) {
|
|
26
|
+
progress === null || progress === void 0 ? void 0 : progress(r);
|
|
27
|
+
results.push(r);
|
|
28
|
+
}
|
|
29
|
+
progress === null || progress === void 0 ? void 0 : progress({ start: true, service: 'signup', serviceUrl: signupUrl });
|
|
30
|
+
const signupCheck = await checkSignup(client, signupUrl, signupToken);
|
|
31
|
+
recordResult(signupCheck);
|
|
32
|
+
if (!signupCheck.isOk) {
|
|
33
|
+
return results;
|
|
34
|
+
}
|
|
35
|
+
async function checkService(service, userDomain) {
|
|
36
|
+
progress === null || progress === void 0 ? void 0 : progress({ start: true, service, userDomain });
|
|
37
|
+
const check = await checkUserDomainDNS(service, userDomain);
|
|
38
|
+
recordResult(check);
|
|
39
|
+
if (check.isOk) {
|
|
40
|
+
await checkFstServiceEndpoint(service, check.serviceUrl);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function checkFstServiceEndpoint(service, serviceUrl) {
|
|
44
|
+
progress === null || progress === void 0 ? void 0 : progress({ start: true, service: 'mailerid', serviceUrl });
|
|
45
|
+
try {
|
|
46
|
+
if (service === 'mailerid') {
|
|
47
|
+
await (0, service_locator_1.mailerIdInfoAt)(client, serviceUrl);
|
|
48
|
+
}
|
|
49
|
+
else if (service === 'asmail') {
|
|
50
|
+
await (0, service_locator_1.asmailInfoAt)(client, serviceUrl);
|
|
51
|
+
}
|
|
52
|
+
else if (service === '3nstorage') {
|
|
53
|
+
await (0, service_locator_1.storageInfoAt)(client, serviceUrl);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw new Error(`Unknown service ${service}`);
|
|
57
|
+
}
|
|
58
|
+
recordResult({
|
|
59
|
+
isOk: true, service, serviceUrl,
|
|
60
|
+
message: `Main ${service} entrypoint at ${serviceUrl} works.`
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
let message = '';
|
|
65
|
+
if (err.type === 'connect') {
|
|
66
|
+
message = `Fail to connect to ${service} service as ${serviceUrl}:
|
|
67
|
+
- there may be no connection,
|
|
68
|
+
- service might be not up or misconfigured.`;
|
|
69
|
+
}
|
|
70
|
+
recordResult({ service, isOk: false, serviceUrl, err, message });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (const domain of signupCheck.userDomains) {
|
|
74
|
+
await checkService('mailerid', domain);
|
|
75
|
+
await checkService('asmail', domain);
|
|
76
|
+
await checkService('3nstorage', domain);
|
|
77
|
+
}
|
|
78
|
+
return results;
|
|
79
|
+
}
|
|
80
|
+
async function checkSignup(client, signupURL, signupToken) {
|
|
81
|
+
try {
|
|
82
|
+
const domains = await (0, _3nweb_signup_1.checkAvailableDomains)(client, signupURL, signupToken);
|
|
83
|
+
if (domains.length === 0) {
|
|
84
|
+
return {
|
|
85
|
+
service: 'signup',
|
|
86
|
+
isOk: false,
|
|
87
|
+
message: `Signup service responds but gives no domains:
|
|
88
|
+
- token can be incorrect/missing,
|
|
89
|
+
- service might have no user domains set up for signup.`
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return {
|
|
94
|
+
service: 'signup',
|
|
95
|
+
isOk: true,
|
|
96
|
+
userDomains: domains,
|
|
97
|
+
message: `Signup service returns domain(s) for users: ${domains.join(', ')}.`
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
let message = '';
|
|
103
|
+
if (err.type === 'http-request') {
|
|
104
|
+
if (err.status === 404) {
|
|
105
|
+
message = `Server doesn't recognize path in url:
|
|
106
|
+
- service url might be incorrect,
|
|
107
|
+
- signup service might be not set up on given url.`;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
message = `Server produces non-ok response, ${err.status}:
|
|
111
|
+
- service url might be incorrect,
|
|
112
|
+
- signup service might be not set up on given url.`;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
else if (err.type === 'connect') {
|
|
116
|
+
message = `Fail to connect to signup service:
|
|
117
|
+
- there may be no connection,
|
|
118
|
+
- service url might be incorrect,
|
|
119
|
+
- server might be not set up, or not connected.`;
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
service: 'signup',
|
|
123
|
+
isOk: false,
|
|
124
|
+
err,
|
|
125
|
+
message
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const srvLocator = (0, service_locator_1.makeServiceLocator)({
|
|
130
|
+
resolveTxt: domain => new Promise((resolve, reject) => (0, dns_1.resolveTxt)(domain, (err, texts) => {
|
|
131
|
+
if (err) {
|
|
132
|
+
reject(err);
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
resolve(texts);
|
|
136
|
+
}
|
|
137
|
+
}))
|
|
138
|
+
});
|
|
139
|
+
async function checkUserDomainDNS(service, domain) {
|
|
140
|
+
try {
|
|
141
|
+
const serviceUrl = await (srvLocator(service))(`u@${domain}`);
|
|
142
|
+
return {
|
|
143
|
+
service,
|
|
144
|
+
isOk: true,
|
|
145
|
+
serviceUrl,
|
|
146
|
+
message: `DNS record for domain ${domain} says that ${service} service is expected to be at ${serviceUrl}`
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
let message = '';
|
|
151
|
+
if (err.type === 'connect') {
|
|
152
|
+
message = `Fail to connect to get DNS record:
|
|
153
|
+
- there may be no connection,
|
|
154
|
+
- there may be DNS misconfiguration.`;
|
|
155
|
+
}
|
|
156
|
+
else if (err.type === 'service-locating') {
|
|
157
|
+
if (err.domainNotFound) {
|
|
158
|
+
message = `User domain ${domain} not found:
|
|
159
|
+
- domain might be incorrect
|
|
160
|
+
- there may be DNS misconfiguration.`;
|
|
161
|
+
}
|
|
162
|
+
else if (err.noServiceRecord) {
|
|
163
|
+
message = `User domain ${domain} doesn't have record for ${service} service:
|
|
164
|
+
- domain might be incorrect
|
|
165
|
+
- there may be DNS misconfiguration.`;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return {
|
|
169
|
+
service,
|
|
170
|
+
isOk: false,
|
|
171
|
+
userDomain: domain,
|
|
172
|
+
err,
|
|
173
|
+
message
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
Object.freeze(exports);
|
package/build/lib-index.d.ts
CHANGED
|
@@ -12,3 +12,4 @@ export { sysFolders } from "./core/storage/system-folders";
|
|
|
12
12
|
export { DeviceFS } from './lib-client/local-files/device-fs';
|
|
13
13
|
export { makeLogger } from './lib-client/logging/log-to-file';
|
|
14
14
|
export declare const SYSTEM_DOMAIN = "3nweb.computer";
|
|
15
|
+
export { checkServicesStartingFromSignup } from './lib-client/service-checks';
|
package/build/lib-index.js
CHANGED
|
@@ -30,7 +30,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
30
30
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.SYSTEM_DOMAIN = exports.makeLogger = exports.DeviceFS = exports.sysFolders = exports.appDirs = exports.makeNetClient = exports.makeServiceLocator = exports.ASMail = exports.SignIn = exports.reverseDomain = exports.Storages = exports.IdManager = exports.SignUp = void 0;
|
|
33
|
+
exports.checkServicesStartingFromSignup = exports.SYSTEM_DOMAIN = exports.makeLogger = exports.DeviceFS = exports.sysFolders = exports.appDirs = exports.makeNetClient = exports.makeServiceLocator = exports.ASMail = exports.SignIn = exports.reverseDomain = exports.Storages = exports.IdManager = exports.SignUp = void 0;
|
|
34
34
|
__exportStar(require("./core"), exports);
|
|
35
35
|
var sign_up_1 = require("./core/startup/sign-up");
|
|
36
36
|
Object.defineProperty(exports, "SignUp", { enumerable: true, get: function () { return sign_up_1.SignUp; } });
|
|
@@ -56,4 +56,6 @@ Object.defineProperty(exports, "DeviceFS", { enumerable: true, get: function ()
|
|
|
56
56
|
var log_to_file_1 = require("./lib-client/logging/log-to-file");
|
|
57
57
|
Object.defineProperty(exports, "makeLogger", { enumerable: true, get: function () { return log_to_file_1.makeLogger; } });
|
|
58
58
|
exports.SYSTEM_DOMAIN = '3nweb.computer';
|
|
59
|
+
var service_checks_1 = require("./lib-client/service-checks");
|
|
60
|
+
Object.defineProperty(exports, "checkServicesStartingFromSignup", { enumerable: true, get: function () { return service_checks_1.checkServicesStartingFromSignup; } });
|
|
59
61
|
Object.freeze(exports);
|