core-3nweb-client-lib 0.29.2 → 0.30.1
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/api-defs/startup.d.ts +14 -2
- package/build/core/startup/sign-up.d.ts +0 -1
- package/build/core/startup/sign-up.js +5 -6
- package/build/core/startup/startup-cap.js +43 -0
- package/build/lib-client/3nweb-signup.d.ts +1 -0
- package/build/lib-client/3nweb-signup.js +22 -2
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-common/user-admin-api/signup.d.ts +10 -0
- package/build/lib-common/user-admin-api/signup.js +12 -2
- package/build/protos/startup.proto.js +411 -0
- package/package.json +1 -1
- package/protos/startup.proto +10 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright (C) 2016 - 2017, 2020 3NSoft Inc.
|
|
2
|
+
Copyright (C) 2016 - 2017, 2020, 2023 3NSoft Inc.
|
|
3
3
|
|
|
4
4
|
This program is free software: you can redistribute it and/or modify it under
|
|
5
5
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -23,7 +23,19 @@ declare namespace web3n.startup {
|
|
|
23
23
|
* functionality, when user creates new account in 3NWeb domains.
|
|
24
24
|
*/
|
|
25
25
|
interface SignUpService {
|
|
26
|
-
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param serviceUrl of 3NWeb signup service url.
|
|
29
|
+
*/
|
|
30
|
+
setSignUpServer(serviceUrl: string): Promise<void>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param signupToken
|
|
34
|
+
* @return a promise, resolvable to an array of available domains for
|
|
35
|
+
* creation of a new account.
|
|
36
|
+
*/
|
|
37
|
+
getAvailableDomains(signupToken?: string): Promise<string[]>;
|
|
38
|
+
|
|
27
39
|
/**
|
|
28
40
|
* @param name is a part of address that comes before @domain
|
|
29
41
|
* @param signupToken
|
|
@@ -24,7 +24,6 @@ export declare class SignUp {
|
|
|
24
24
|
constructor(serviceURL: string, cryptor: Cryptor, makeNet: () => NetClient, getUsersOnDisk: GetUsersOnDisk, logError: LogError);
|
|
25
25
|
private setServiceURL;
|
|
26
26
|
exposedService(): SignUpService;
|
|
27
|
-
private getAvailableAddresses;
|
|
28
27
|
private createUserParams;
|
|
29
28
|
private genStorageParams;
|
|
30
29
|
private genMidParams;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2020, 2022 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2020, 2022 - 2023 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -64,11 +64,8 @@ class SignUp {
|
|
|
64
64
|
this.logError = logError;
|
|
65
65
|
this.mid = undefined;
|
|
66
66
|
this.store = undefined;
|
|
67
|
+
this.serviceURL = undefined;
|
|
67
68
|
this.netLazyInit = undefined;
|
|
68
|
-
this.getAvailableAddresses = async (name, signupToken) => {
|
|
69
|
-
const addresses = await (0, _3nweb_signup_1.checkAvailableAddressesForName)(this.net, this.serviceURL, name, signupToken);
|
|
70
|
-
return addresses;
|
|
71
|
-
};
|
|
72
69
|
this.createUserParams = async (pass, progressCB) => {
|
|
73
70
|
await this.genMidParams(pass, 0, 50, progressCB);
|
|
74
71
|
await this.genStorageParams(pass, 51, 100, progressCB);
|
|
@@ -125,9 +122,11 @@ class SignUp {
|
|
|
125
122
|
}
|
|
126
123
|
exposedService() {
|
|
127
124
|
const service = {
|
|
125
|
+
setSignUpServer: async (srvUrl) => this.setServiceURL(srvUrl),
|
|
126
|
+
getAvailableDomains: signupToken => (0, _3nweb_signup_1.checkAvailableDomains)(this.net, this.serviceURL, signupToken),
|
|
128
127
|
addUser: this.addUser,
|
|
129
128
|
createUserParams: this.createUserParams,
|
|
130
|
-
getAvailableAddresses: this.
|
|
129
|
+
getAvailableAddresses: (name, signupToken) => (0, _3nweb_signup_1.checkAvailableAddressesForName)(this.net, this.serviceURL, name, signupToken),
|
|
131
130
|
isActivated: async () => { throw new Error(`Not implemented, yet`); }
|
|
132
131
|
};
|
|
133
132
|
return Object.freeze(service);
|
|
@@ -43,6 +43,8 @@ function makeSignInCaller(caller, objPath) {
|
|
|
43
43
|
exports.makeSignInCaller = makeSignInCaller;
|
|
44
44
|
function wrapSignUpCAP(cap) {
|
|
45
45
|
return {
|
|
46
|
+
setSignUpServer: setSignUpServer.wrapService(cap.setSignUpServer),
|
|
47
|
+
getAvailableDomains: getAvailableDomains.wrapService(cap.getAvailableDomains),
|
|
46
48
|
getAvailableAddresses: getAvailableAddresses.wrapService(cap.getAvailableAddresses),
|
|
47
49
|
addUser: addUser.wrapService(cap.addUser),
|
|
48
50
|
createUserParams: createUserParams.wrapService(cap.createUserParams),
|
|
@@ -52,6 +54,8 @@ function wrapSignUpCAP(cap) {
|
|
|
52
54
|
exports.wrapSignUpCAP = wrapSignUpCAP;
|
|
53
55
|
function makeSignUpCaller(caller, objPath) {
|
|
54
56
|
return {
|
|
57
|
+
setSignUpServer: setSignUpServer.makeCaller(caller, objPath),
|
|
58
|
+
getAvailableDomains: getAvailableDomains.makeCaller(caller, objPath),
|
|
55
59
|
getAvailableAddresses: getAvailableAddresses.makeCaller(caller, objPath),
|
|
56
60
|
addUser: addUser.makeCaller(caller, objPath),
|
|
57
61
|
createUserParams: createUserParams.makeCaller(caller, objPath),
|
|
@@ -59,6 +63,45 @@ function makeSignUpCaller(caller, objPath) {
|
|
|
59
63
|
};
|
|
60
64
|
}
|
|
61
65
|
exports.makeSignUpCaller = makeSignUpCaller;
|
|
66
|
+
var setSignUpServer;
|
|
67
|
+
(function (setSignUpServer) {
|
|
68
|
+
const requestType = protobuf_type_1.ProtoType.for(startup_proto_1.startup.SetSignUpServerRequestBody);
|
|
69
|
+
function wrapService(fn) {
|
|
70
|
+
return buf => {
|
|
71
|
+
const { serviceUrl } = requestType.unpack(buf);
|
|
72
|
+
const promise = fn(serviceUrl);
|
|
73
|
+
return { promise };
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
setSignUpServer.wrapService = wrapService;
|
|
77
|
+
function makeCaller(caller, objPath) {
|
|
78
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'setSignUpServer');
|
|
79
|
+
return serviceUrl => caller
|
|
80
|
+
.startPromiseCall(path, requestType.pack({ serviceUrl }));
|
|
81
|
+
}
|
|
82
|
+
setSignUpServer.makeCaller = makeCaller;
|
|
83
|
+
})(setSignUpServer || (setSignUpServer = {}));
|
|
84
|
+
Object.freeze(getAvailableAddresses);
|
|
85
|
+
var getAvailableDomains;
|
|
86
|
+
(function (getAvailableDomains) {
|
|
87
|
+
const requestType = protobuf_type_1.ProtoType.for(startup_proto_1.startup.GetAvailableDomainsRequestBody);
|
|
88
|
+
function wrapService(fn) {
|
|
89
|
+
return buf => {
|
|
90
|
+
const { token } = requestType.unpack(buf);
|
|
91
|
+
const promise = fn((0, protobuf_msg_1.valOfOpt)(token))
|
|
92
|
+
.then(domains => protobuf_msg_1.strArrValType.pack({ values: domains }));
|
|
93
|
+
return { promise };
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
getAvailableDomains.wrapService = wrapService;
|
|
97
|
+
function makeCaller(caller, objPath) {
|
|
98
|
+
const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'getAvailableDomains');
|
|
99
|
+
return token => caller
|
|
100
|
+
.startPromiseCall(path, requestType.pack({ token: (0, protobuf_msg_1.toOptVal)(token) }))
|
|
101
|
+
.then(buf => (0, protobuf_msg_1.fixArray)(protobuf_msg_1.strArrValType.unpack(buf).values));
|
|
102
|
+
}
|
|
103
|
+
getAvailableDomains.makeCaller = makeCaller;
|
|
104
|
+
})(getAvailableDomains || (getAvailableDomains = {}));
|
|
62
105
|
var getAvailableAddresses;
|
|
63
106
|
(function (getAvailableAddresses) {
|
|
64
107
|
const requestType = protobuf_type_1.ProtoType.for(startup_proto_1.startup.GetAvailableAddressesRequestBody);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NetClient } from './request-utils';
|
|
2
2
|
import * as api from '../lib-common/user-admin-api/signup';
|
|
3
|
+
export declare function checkAvailableDomains(client: NetClient, serviceUrl: string, signupToken: string | undefined): Promise<string[]>;
|
|
3
4
|
export declare function checkAvailableAddressesForName(client: NetClient, serviceUrl: string, name: string, signupToken: string | undefined): Promise<string[]>;
|
|
4
5
|
export declare function addUser(client: NetClient, serviceUrl: string, userParams: api.addUser.Request): Promise<boolean>;
|
|
5
6
|
export declare function sendActivationCheckRequest(client: NetClient, serviceUrl: string, userId: string): Promise<boolean>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015, 2017, 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015, 2017, 2020, 2023 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -16,9 +16,29 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.sendActivationCheckRequest = exports.addUser = exports.checkAvailableAddressesForName = void 0;
|
|
19
|
+
exports.sendActivationCheckRequest = exports.addUser = exports.checkAvailableAddressesForName = exports.checkAvailableDomains = void 0;
|
|
20
20
|
const request_utils_1 = require("./request-utils");
|
|
21
21
|
const api = require("../lib-common/user-admin-api/signup");
|
|
22
|
+
async function checkAvailableDomains(client, serviceUrl, signupToken) {
|
|
23
|
+
const reqData = { signupToken };
|
|
24
|
+
const rep = await client.doJsonRequest({
|
|
25
|
+
method: api.availableDomains.method,
|
|
26
|
+
url: serviceUrl + api.availableDomains.URL_END,
|
|
27
|
+
responseType: 'json'
|
|
28
|
+
}, reqData);
|
|
29
|
+
if (rep.status === api.availableDomains.SC.ok) {
|
|
30
|
+
if (Array.isArray(rep.data)) {
|
|
31
|
+
return rep.data;
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
throw (0, request_utils_1.makeException)(rep, 'Reply is malformed');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.checkAvailableDomains = checkAvailableDomains;
|
|
22
42
|
async function checkAvailableAddressesForName(client, serviceUrl, name, signupToken) {
|
|
23
43
|
const reqData = {
|
|
24
44
|
name, signupToken
|