spec-3nweb-server 1.7.0 → 1.7.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/3nstorage/resources/sessions.d.ts +2 -2
- package/build/3nstorage/resources/store.d.ts +1 -1
- package/build/3nstorage/resources/users.d.ts +15 -15
- package/build/admin/resources/users.d.ts +3 -3
- package/build/admin/signup-tokens.d.ts +1 -1
- package/build/asmail/resources/delivery-sessions.d.ts +3 -3
- package/build/asmail/resources/inbox.d.ts +9 -9
- package/build/asmail/resources/recipients.d.ts +18 -18
- package/build/asmail/resources/sessions.d.ts +2 -2
- package/build/asmail/routes/delivery/sender-authorization.d.ts +1 -1
- package/build/asmail/routes/delivery/start-session.d.ts +1 -1
- package/build/config/letsencrypt.d.ts +1 -1
- package/build/config/signup.js +1 -0
- package/build/lib-common/byte-streaming/common.d.ts +2 -2
- package/build/lib-common/byte-streaming/common.js +5 -5
- package/build/lib-common/exceptions/file.d.ts +1 -1
- package/build/lib-common/ipc/generic-ipc.d.ts +7 -7
- package/build/lib-common/ipc/generic-ipc.js +6 -6
- package/build/lib-common/objs-on-disk/file-layout.d.ts +4 -4
- package/build/lib-common/objs-on-disk/utils.d.ts +3 -3
- package/build/lib-common/processes.d.ts +1 -1
- package/build/lib-common/service-api/ipc-api.d.ts +6 -6
- package/build/lib-common/service-api/web-socket-base.d.ts +1 -1
- package/build/lib-server/middleware/error-handler.d.ts +1 -1
- package/build/lib-server/resources/dns.d.ts +1 -1
- package/build/lib-server/resources/sessions.d.ts +2 -2
- package/build/lib-server/resources/user-files.d.ts +1 -1
- package/build/lib-server/routes/pub-key-login/start-exchange.d.ts +4 -4
- package/build/lib-server/routes/sessions/mid-auth.d.ts +1 -1
- package/build/lib-server/routes/sessions/start.d.ts +4 -4
- package/build/lib-server/web-sockets/app.d.ts +1 -1
- package/build/lib-server/web-sockets/app.js +6 -6
- package/build/lib-server/web-sockets/server-events.d.ts +1 -1
- package/build/lib.d.ts +0 -1
- package/build/lib.js +1 -4
- package/build/mailerId/resources/certifier.d.ts +1 -1
- package/build/mailerId/resources/sessions.d.ts +1 -1
- package/build/mock/node-child-ipc.d.ts +2 -2
- package/package.json +3 -3
- package/build/config/from-env.d.ts +0 -9
- package/build/config/from-env.js +0 -117
- package/build/run.d.ts +0 -1
- package/build/run.js +0 -45
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request as Req, SessionParams, Factory } from '../../lib-server/resources/sessions';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type SessionsFactory = Factory<SessionParams>;
|
|
3
|
+
export type Request = Req<SessionParams>;
|
|
4
4
|
/**
|
|
5
5
|
* This returns factory, that works properly in a single process application,
|
|
6
6
|
* clearing up sessions that past given timeout.
|
|
@@ -5,7 +5,7 @@ import { UserFiles, ObjReader } from '../../lib-server/resources/user-files';
|
|
|
5
5
|
import { DiffInfo, events, ObjStatus } from '../../lib-common/service-api/3nstorage/owner';
|
|
6
6
|
export { DiffInfo } from '../../lib-common/service-api/3nstorage/owner';
|
|
7
7
|
export { ObjPipe, ObjReader } from '../../lib-server/resources/user-files';
|
|
8
|
-
export
|
|
8
|
+
export type StorageEventsSink = (userId: string, channel: events.EventNameType, event: events.AllTypes) => void;
|
|
9
9
|
export declare const SC: {
|
|
10
10
|
USER_UNKNOWN: string;
|
|
11
11
|
OBJ_EXIST: string;
|
|
@@ -8,24 +8,24 @@ import { Readable as ReadableStream } from 'stream';
|
|
|
8
8
|
import { ObjReader, StorageEventsSink } from './store';
|
|
9
9
|
import { PutObjFirstQueryOpts, PutObjSecondQueryOpts, DiffInfo, ObjStatus } from '../../lib-common/service-api/3nstorage/owner';
|
|
10
10
|
export { SC, ObjReader, MismatchedObjVerException } from './store';
|
|
11
|
-
export
|
|
12
|
-
export
|
|
11
|
+
export type UserExists = (userId: string) => Promise<boolean>;
|
|
12
|
+
export type GetCurrentObj = (userId: string, objId: string | null, header: boolean, segsOffset: number, segsLimit: number | undefined) => Promise<{
|
|
13
13
|
version: number;
|
|
14
14
|
reader: ObjReader;
|
|
15
15
|
}>;
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
export
|
|
21
|
-
export
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
16
|
+
export type SaveNewObjVersion = (userId: string, objId: string | null, fstReq: PutObjFirstQueryOpts | undefined, diff: DiffInfo | undefined, sndReq: PutObjSecondQueryOpts | undefined, bytesLen: number, bytes: ReadableStream) => Promise<string | undefined>;
|
|
17
|
+
export type GetArchivedObjVersion = (userId: string, objId: string | null, version: number, header: boolean, segsOffset: number, segsLimit: number | undefined) => Promise<ObjReader>;
|
|
18
|
+
export type CancelTransaction = (userId: string, objId: string, transactionId?: string) => Promise<void>;
|
|
19
|
+
export type ArchiveObjCurrentVersion = (userId: string, objId: string, version: number) => Promise<void>;
|
|
20
|
+
export type GetObjStatus = (userId: string, objId: string) => Promise<ObjStatus>;
|
|
21
|
+
export type DeleteCurrentObjVersion = (userId: string, objId: string, version?: number) => Promise<void>;
|
|
22
|
+
export type DeleteArchivedObjVersion = (userId: string, objId: string | null, version: number) => Promise<void>;
|
|
23
|
+
type GetParam<T> = (userId: string) => Promise<T>;
|
|
24
|
+
type SetParam<T> = (userId: string, param: T) => Promise<boolean>;
|
|
25
|
+
export type GetSpaceQuota = GetParam<number>;
|
|
26
|
+
export type GetKeyDerivParams = GetParam<any>;
|
|
27
|
+
export type SetKeyDerivParams = SetParam<any>;
|
|
28
|
+
export type EventsSink = StorageEventsSink;
|
|
29
29
|
/**
|
|
30
30
|
* This is an external interface, behind which all storage machinery is hidding.
|
|
31
31
|
*/
|
|
@@ -13,7 +13,7 @@ export declare function validateUserStorageParams(params: UserStorageParams): bo
|
|
|
13
13
|
* @return a promise, resolvable to available addresses for a given name.
|
|
14
14
|
* If array is empty, there are no available addresses for a given name.
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export type IAvailableDomains = (signupToken: string | undefined) => Promise<string[]>;
|
|
17
17
|
/**
|
|
18
18
|
* This returns a promise, resolvable to an array of addresses, that are
|
|
19
19
|
* available for a given string. Array may be empty, when there are no
|
|
@@ -23,7 +23,7 @@ export declare type IAvailableDomains = (signupToken: string | undefined) => Pro
|
|
|
23
23
|
* @return a promise, resolvable to available addresses for a given name.
|
|
24
24
|
* If array is empty, there are no available addresses for a given name.
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export type IAvailableAddressesForName = (name: string, signupToken: string | undefined) => Promise<string[]>;
|
|
27
27
|
/**
|
|
28
28
|
* This creates a user, returning a promise, resolvable when a new account has
|
|
29
29
|
* been created for a given user id.
|
|
@@ -35,7 +35,7 @@ export declare type IAvailableAddressesForName = (name: string, signupToken: str
|
|
|
35
35
|
* @return a promise, resolvable, when user is added, and all parameters are
|
|
36
36
|
* saved.
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
38
|
+
export type IAdd = (userId: string, midParams: UserMidParams, storeParams: any, signupToken: string | undefined) => Promise<void>;
|
|
39
39
|
export interface Factory {
|
|
40
40
|
getAvailableDomains: IAvailableDomains;
|
|
41
41
|
getAvailableAddresses: IAvailableAddressesForName;
|
|
@@ -11,9 +11,9 @@ export interface SessionParams {
|
|
|
11
11
|
currentMsgLength: number;
|
|
12
12
|
msgId: string;
|
|
13
13
|
}
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
14
|
+
export type Request = Req<SessionParams>;
|
|
15
|
+
export type GenerateSession = GenSession<SessionParams>;
|
|
16
|
+
export type GetSessionForMsg = (recipient: string, msgId: string) => Promise<Session<SessionParams> | undefined>;
|
|
17
17
|
export interface SessionsFactory extends Factory<SessionParams> {
|
|
18
18
|
getSessionForMsg: GetSessionForMsg;
|
|
19
19
|
}
|
|
@@ -5,15 +5,15 @@ import * as configApi from '../../lib-common/service-api/asmail/config';
|
|
|
5
5
|
import * as retrievalApi from '../../lib-common/service-api/asmail/retrieval';
|
|
6
6
|
import { UserFiles, ObjReader } from '../../lib-server/resources/user-files';
|
|
7
7
|
export { ObjPipe, ObjReader } from '../../lib-server/resources/user-files';
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
export
|
|
8
|
+
type AnonSenderPolicy = configApi.p.anonSenderPolicy.Policy;
|
|
9
|
+
export type AuthSenderPolicy = configApi.p.authSenderPolicy.Policy;
|
|
10
|
+
type Whitelist = configApi.p.authSenderWhitelist.List;
|
|
11
|
+
type Blacklist = configApi.p.authSenderBlacklist.List;
|
|
12
|
+
type AuthSenderInvites = configApi.p.authSenderInvites.List;
|
|
13
|
+
type AnonSenderInvites = configApi.p.anonSenderInvites.List;
|
|
14
|
+
type MsgMeta = retrievalApi.MsgMeta;
|
|
15
|
+
export type MsgEvents = retrievalApi.msgMainObjRecieved.Event | retrievalApi.msgRecievedCompletely.Event;
|
|
16
|
+
export type MailEventsSink = (userId: string, channel: string, event: MsgEvents) => void;
|
|
17
17
|
export declare const SC: {
|
|
18
18
|
OBJ_EXIST: string;
|
|
19
19
|
USER_UNKNOWN: string;
|
|
@@ -10,7 +10,7 @@ export declare const BIN_TYPE = "application/octet-stream";
|
|
|
10
10
|
* This checks existence of a given user, returning a promise, resolvable
|
|
11
11
|
* either to true, when given user id is known, or to false, when it is not.
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type UserExists = (userId: string) => Promise<boolean>;
|
|
14
14
|
/**
|
|
15
15
|
* This tells what is an allowable maximum message size for a given recipient,
|
|
16
16
|
* for a given sender and/or under a given invitation token.
|
|
@@ -20,46 +20,46 @@ export declare type UserExists = (userId: string) => Promise<boolean>;
|
|
|
20
20
|
* (3) -1 (less than zero), if mail cannot be accepted due to full mail
|
|
21
21
|
* box.
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export type AllowedMaxMsgSize = (recipient: string, sender: string | undefined, invitation: string | undefined) => Promise<number>;
|
|
24
24
|
/**
|
|
25
25
|
* This allocates storage for a message returning a promise, resolvable to
|
|
26
26
|
* (1) message id, when a folder for new message has been created,
|
|
27
27
|
* (2) undefined, if recipient is unknown.
|
|
28
28
|
*/
|
|
29
|
-
export
|
|
29
|
+
export type SetMsgStorage = (recipient: string, msgMeta: deliveryApi.msgMeta.Request, authSender: string | undefined, invite: string | undefined, maxMsgLength: number) => Promise<string>;
|
|
30
30
|
/**
|
|
31
31
|
* This saves object's bytes, returning a promise, resolvable when saving
|
|
32
32
|
* is OK, otherwise, promise rejects with string error code from SC.
|
|
33
33
|
*/
|
|
34
|
-
export
|
|
34
|
+
export type SaveObj = (recipient: string, msgId: string, objId: string, fstReq: deliveryApi.PutObjFirstQueryOpts | undefined, sndReq: deliveryApi.PutObjSecondQueryOpts | undefined, bytesLen: number, bytes: Readable) => Promise<void>;
|
|
35
35
|
/**
|
|
36
36
|
* This finalizes delivery of a message, returning a promise.
|
|
37
37
|
* Rejected promise may have a string error code from SC.
|
|
38
38
|
*/
|
|
39
|
-
export
|
|
39
|
+
export type FinalizeDelivery = (recipient: string, msgId: string) => Promise<void>;
|
|
40
40
|
/**
|
|
41
41
|
* This returns a promise, resolvable to array with ids of available messages.
|
|
42
42
|
* Rejected promise may have a string error code from SC.
|
|
43
43
|
*/
|
|
44
|
-
export
|
|
44
|
+
export type GetMsgIds = (userId: string) => Promise<retrievalApi.listMsgs.Reply>;
|
|
45
45
|
/**
|
|
46
46
|
* This returns a promise, resolvable to message meta.
|
|
47
47
|
* Rejected promise may have a string error code from SC.
|
|
48
48
|
*/
|
|
49
|
-
export
|
|
49
|
+
export type GetMsgMeta = (userId: string, msgId: string) => Promise<retrievalApi.MsgMeta>;
|
|
50
50
|
/**
|
|
51
51
|
* This deletes a message returning a promise, resolvable when message is
|
|
52
52
|
* removed.
|
|
53
53
|
* Rejected promise may have a string error code from SC.
|
|
54
54
|
*/
|
|
55
|
-
export
|
|
55
|
+
export type DeleteMsg = (userId: string, msgId: string) => Promise<void>;
|
|
56
56
|
/**
|
|
57
57
|
* This returns parameter of a message that is still in delivery, identified
|
|
58
58
|
* by given recipient and message id. If message is unknown, or if it has
|
|
59
59
|
* already been delivered, error code is thrown.
|
|
60
60
|
* Rejected promise may have a string error code from SC.
|
|
61
61
|
*/
|
|
62
|
-
export
|
|
62
|
+
export type IncompleteMsgDeliveryParams = (recipient: string, msgId: string) => Promise<{
|
|
63
63
|
maxMsgLength: number;
|
|
64
64
|
currentMsgLength: number;
|
|
65
65
|
}>;
|
|
@@ -67,14 +67,14 @@ export declare type IncompleteMsgDeliveryParams = (recipient: string, msgId: str
|
|
|
67
67
|
* This returns a promise, resolvable to readable stream of object bytes.
|
|
68
68
|
* Rejected promise may be passing string error code from SC.
|
|
69
69
|
*/
|
|
70
|
-
export
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
export
|
|
74
|
-
export
|
|
75
|
-
export
|
|
76
|
-
export
|
|
77
|
-
export
|
|
70
|
+
export type GetObj = (userId: string, msgId: string, objId: string, header: boolean, segsOffset: number, segsLimit: number | undefined) => Promise<ObjReader>;
|
|
71
|
+
type GetParam<T> = (userId: string) => Promise<T>;
|
|
72
|
+
type SetParam<T> = (userId: string, param: T) => Promise<boolean>;
|
|
73
|
+
export type GetPubKey = GetParam<configApi.p.initPubKey.Certs>;
|
|
74
|
+
export type SetPubKey = SetParam<configApi.p.initPubKey.Certs>;
|
|
75
|
+
export type GetAnonSenderInvites = GetParam<configApi.p.anonSenderInvites.List>;
|
|
76
|
+
export type SetAnonSenderInvites = SetParam<configApi.p.anonSenderInvites.List>;
|
|
77
|
+
export type EventsSink = MailEventsSink;
|
|
78
78
|
export interface Factory {
|
|
79
79
|
exists: UserExists;
|
|
80
80
|
allowedMaxMsgSize: AllowedMaxMsgSize;
|
|
@@ -92,5 +92,5 @@ export interface Factory {
|
|
|
92
92
|
setAnonSenderInvites: SetAnonSenderInvites;
|
|
93
93
|
setMailEventsSink(sink: EventsSink): void;
|
|
94
94
|
}
|
|
95
|
-
export
|
|
95
|
+
export type StaticSetter<T> = (inbox: Inbox, param: T, setDefault: boolean) => Promise<boolean>;
|
|
96
96
|
export declare function makeFactory(rootFolder: string, writeBufferSize?: string | number, readBufferSize?: string | number): Factory;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request as Req, SessionParams, Factory } from '../../lib-server/resources/sessions';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type SessionsFactory = Factory<SessionParams>;
|
|
3
|
+
export type Request = Req<SessionParams>;
|
|
4
4
|
/**
|
|
5
5
|
* This returns factory, that works properly in a single process application,
|
|
6
6
|
* clearing up sessions that past given timeout.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestHandler } from 'express';
|
|
2
2
|
import { SignedLoad } from '../../../lib-common/jwkeys';
|
|
3
|
-
export
|
|
3
|
+
export type IMidAuthorizer = (rpDomain: string, sessionId: string, userId: string, mailerIdAssertion: SignedLoad, userCert: SignedLoad, provCert: SignedLoad) => Promise<boolean>;
|
|
4
4
|
/**
|
|
5
5
|
* This creates an authorize-sender route handler.
|
|
6
6
|
* @param relyingPartyDomain at which this service operates, as seen by client
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RequestHandler } from 'express';
|
|
2
2
|
import { GenerateSession } from '../../resources/delivery-sessions';
|
|
3
3
|
import { AllowedMaxMsgSize } from '../../resources/recipients';
|
|
4
|
-
export
|
|
4
|
+
export type Redirect = (userId: string) => Promise<string>;
|
|
5
5
|
/**
|
|
6
6
|
* This creates a start-session route handler.
|
|
7
7
|
* @param allowedMsgSizeFunc is a function returning promises, that may resolve to
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ServerOptions } from "https";
|
|
3
|
-
export
|
|
3
|
+
export type CertsUpdateListener = (newOpts: ServerOptions, originalOpts: ServerOptions) => Promise<void>;
|
|
4
4
|
export declare function sslOptsFromConfig(letsencrypt: string | undefined, sslOpts: ServerOptions | undefined, skipReloadOnCertsChange: boolean | undefined): {
|
|
5
5
|
sslOpts: ServerOptions;
|
|
6
6
|
onCertsUpdate?: (listener: CertsUpdateListener) => (() => void);
|
package/build/config/signup.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ByteSource = web3n.ByteSource;
|
|
2
2
|
export declare function wrapByteSourceImplementation(src: ByteSource): ByteSource;
|
|
3
|
-
export
|
|
3
|
+
export type ByteSink = web3n.ByteSink;
|
|
4
4
|
export declare function wrapByteSinkImplementation(sink: ByteSink): ByteSink;
|
|
5
5
|
export declare class BytesFIFOBuffer {
|
|
6
6
|
private queue;
|
|
@@ -45,17 +45,17 @@ function wrapByteSinkImplementation(sink) {
|
|
|
45
45
|
}
|
|
46
46
|
exports.wrapByteSinkImplementation = wrapByteSinkImplementation;
|
|
47
47
|
class BytesFIFOBuffer {
|
|
48
|
-
constructor() {
|
|
49
|
-
this.queue = [];
|
|
50
|
-
this.bytesLen = 0;
|
|
51
|
-
Object.seal(this);
|
|
52
|
-
}
|
|
53
48
|
get length() {
|
|
54
49
|
return this.bytesLen;
|
|
55
50
|
}
|
|
56
51
|
get queueLength() {
|
|
57
52
|
return this.queue.length;
|
|
58
53
|
}
|
|
54
|
+
constructor() {
|
|
55
|
+
this.queue = [];
|
|
56
|
+
this.bytesLen = 0;
|
|
57
|
+
Object.seal(this);
|
|
58
|
+
}
|
|
59
59
|
clear() {
|
|
60
60
|
this.queue = [];
|
|
61
61
|
this.bytesLen = 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const fileExceptionType = "file";
|
|
2
2
|
export declare const Code: web3n.files.exceptionCode;
|
|
3
|
-
export
|
|
3
|
+
export type FileException = web3n.files.FileException;
|
|
4
4
|
export declare function makeFileException(code: string | undefined, path: string, cause?: any): FileException;
|
|
5
5
|
export declare function maskPathInExc(pathPrefixMaskLen: number, exc: any): FileException;
|
|
6
6
|
export declare function ensureCorrectFS(fs: web3n.files.FS, type: web3n.files.FSType, writable: boolean): void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Envelope } from '../service-api/ipc-api';
|
|
2
2
|
export { Envelope, EventEnvelope, EventEndEnvelope, EventException, RequestEnvelope, ReplyEnvelope } from '../service-api/ipc-api';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
3
|
+
export type RequestHandler<TReq, TRes> = web3n.ipc.RequestHandler<TReq, TRes>;
|
|
4
|
+
export type RequestingClient = web3n.ipc.RequestingClient;
|
|
5
|
+
export type RequestServer = web3n.ipc.RequestServer;
|
|
6
|
+
export type EventfulServer = web3n.ipc.EventfulServer;
|
|
7
|
+
export type SubscribingClient = web3n.ipc.SubscribingClient;
|
|
8
|
+
export type Observer<T> = web3n.Observer<T>;
|
|
9
|
+
export type RawDuplex<T> = web3n.ipc.RawDuplex<T>;
|
|
10
10
|
export declare function makeRequestingClient(channel: string | undefined, comm: RawDuplex<Envelope>): RequestingClient;
|
|
11
11
|
export declare function makeRequestServer(channel: string | undefined, comm: RawDuplex<Envelope>): RequestServer;
|
|
12
12
|
export declare function makeEventfulServer(channel: string | undefined, comm: RawDuplex<Envelope>): EventfulServer;
|
|
@@ -586,14 +586,14 @@ function makeSubscribingClient(channel, comm) {
|
|
|
586
586
|
}
|
|
587
587
|
exports.makeSubscribingClient = makeSubscribingClient;
|
|
588
588
|
class MultiObserverWrap {
|
|
589
|
+
get done() {
|
|
590
|
+
return this.isDone;
|
|
591
|
+
}
|
|
589
592
|
constructor() {
|
|
590
593
|
this.isDone = false;
|
|
591
594
|
this.obs = new Set();
|
|
592
595
|
Object.seal(this);
|
|
593
596
|
}
|
|
594
|
-
get done() {
|
|
595
|
-
return this.isDone;
|
|
596
|
-
}
|
|
597
597
|
add(obs) {
|
|
598
598
|
if (this.isDone) {
|
|
599
599
|
throw new Error(`Cannot add observer, as this source is already done`);
|
|
@@ -645,15 +645,15 @@ exports.MultiObserverWrap = MultiObserverWrap;
|
|
|
645
645
|
Object.freeze(MultiObserverWrap.prototype);
|
|
646
646
|
Object.freeze(MultiObserverWrap);
|
|
647
647
|
class SingleObserverWrap {
|
|
648
|
+
get done() {
|
|
649
|
+
return this.isDone;
|
|
650
|
+
}
|
|
648
651
|
constructor() {
|
|
649
652
|
this.isDone = false;
|
|
650
653
|
this.obs = undefined;
|
|
651
654
|
this.detach = () => this.setDone();
|
|
652
655
|
Object.seal(this);
|
|
653
656
|
}
|
|
654
|
-
get done() {
|
|
655
|
-
return this.isDone;
|
|
656
|
-
}
|
|
657
657
|
set(obs) {
|
|
658
658
|
if (this.isDone) {
|
|
659
659
|
throw new Error(`Cannot add observer, as this source is already done`);
|
|
@@ -4,10 +4,10 @@ export interface HeaderChunkInfo {
|
|
|
4
4
|
len: number;
|
|
5
5
|
fileOfs: number;
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
7
|
+
export type NotOnDiskFiniteChunk = NewSegsChunk | BaseSegsChunk;
|
|
8
|
+
export type OnDiskChunk = NewSegsChunkOnDisk | BaseSegsChunkOnDisk;
|
|
9
|
+
export type FiniteSegsChunk = OnDiskChunk | NotOnDiskFiniteChunk;
|
|
10
|
+
export type SegsChunk = OnDiskChunk | NotOnDiskFiniteChunk | NewEndlessSegsChunk;
|
|
11
11
|
export interface FiniteChunk {
|
|
12
12
|
thisVerOfs: number;
|
|
13
13
|
len: number;
|
|
@@ -14,10 +14,10 @@ export interface ChunkWithSegs {
|
|
|
14
14
|
len: number;
|
|
15
15
|
segsOfs: number;
|
|
16
16
|
}
|
|
17
|
-
export
|
|
17
|
+
export type Chunk = ChunkWithHeader | ChunkWithSegs;
|
|
18
18
|
export declare function streamToObjFile(file: ObjVersionFile, content: Chunk[], src: Readable, maxBufferLen: number): Promise<void>;
|
|
19
19
|
export declare function chunksInOrderedStream(len: number, headerLen: undefined | number, segsOfs: number): Chunk[];
|
|
20
|
-
export
|
|
21
|
-
export
|
|
20
|
+
export type ObjPipe = (outStream: NodeJS.WritableStream) => Promise<void>;
|
|
21
|
+
export type GetObjFile = (objId: string | null, version: number) => Promise<ObjVersionFile>;
|
|
22
22
|
export declare function makeObjPipe(file: ObjVersionFile, header: boolean, segsOfs: number, segsLen: number, objId: string | null, getObjFile: GetObjFile): ObjPipe;
|
|
23
23
|
export declare function makeNoBaseObjPipe(file: ObjVersionFile, header: boolean, segsOfs: number, segsLen: number): ObjPipe;
|
|
@@ -29,7 +29,7 @@ export declare function finalizeAsync<T>(promise: Promise<T>, fin: () => Promise
|
|
|
29
29
|
* later time. Scheduler needs a not-yet-started activity, as scheduler has
|
|
30
30
|
* control action's start.
|
|
31
31
|
*/
|
|
32
|
-
export
|
|
32
|
+
export type Action<T> = () => Promise<T>;
|
|
33
33
|
/**
|
|
34
34
|
* This is a container of processes, labeled by some ids. It allows to track if
|
|
35
35
|
* there is a process already in progress with a given id. And, it allows to
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
1
|
+
export type Envelope = web3n.ipc.Envelope;
|
|
2
|
+
export type EventEnvelope<T> = web3n.ipc.EventEnvelope<T>;
|
|
3
|
+
export type EventEndEnvelope = web3n.ipc.EventEndEnvelope;
|
|
4
|
+
export type EventException = web3n.ipc.EventException;
|
|
5
|
+
export type RequestEnvelope<T> = web3n.ipc.RequestEnvelope<T>;
|
|
6
|
+
export type ReplyEnvelope<T> = web3n.ipc.ReplyEnvelope<T>;
|
|
7
7
|
export declare namespace events {
|
|
8
8
|
namespace subscribe {
|
|
9
9
|
const REQ_NAME = "subscribe";
|
|
@@ -16,7 +16,7 @@ export interface EventEnvelope<T> {
|
|
|
16
16
|
eventChannel: string;
|
|
17
17
|
eventPayload: T;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
19
|
+
export type Envelope = RequestEnvelope<any> | ReplyEnvelope<any> | EventEnvelope<any>;
|
|
20
20
|
export declare namespace events {
|
|
21
21
|
const MISSED_EVENTS_CHANNEL = "missed-events";
|
|
22
22
|
const SUBSCRIBE_REQ_NAME = "subscribe";
|
|
@@ -11,6 +11,6 @@ export interface HttpError extends ErrorWithCause {
|
|
|
11
11
|
* @param cause
|
|
12
12
|
*/
|
|
13
13
|
export declare function makeErr(code: number, msg: string, cause?: any): HttpError;
|
|
14
|
-
export
|
|
14
|
+
export type ErrLogger = (err: any, req: Request) => void;
|
|
15
15
|
export declare function makeErrHandler(log?: ErrLogger): ErrorRequestHandler;
|
|
16
16
|
export declare function makeErrLoggerToConsole(srvName: string): ErrLogger;
|
|
@@ -2,5 +2,5 @@ export declare const SC: {
|
|
|
2
2
|
RECORDS_MISSING: string;
|
|
3
3
|
DOMAIN_NOT_FOUND: string;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
5
|
+
export type ServiceLabel = 'asmail' | 'mailerid' | '3nstorage';
|
|
6
6
|
export declare function get3NWebRecords(address: string, serviceLabel: ServiceLabel): Promise<string>;
|
|
@@ -22,8 +22,8 @@ export interface Request<T> extends express.Request {
|
|
|
22
22
|
export interface BaseRequest<T> extends http.IncomingMessage {
|
|
23
23
|
session: Session<T>;
|
|
24
24
|
}
|
|
25
|
-
export
|
|
26
|
-
export
|
|
25
|
+
export type CheckSession<T> = (req: BaseRequest<T>) => Promise<boolean>;
|
|
26
|
+
export type GenerateSession<T> = () => Promise<Session<T>>;
|
|
27
27
|
export interface Factory<T> {
|
|
28
28
|
generate: GenerateSession<T>;
|
|
29
29
|
ensureAuthorizedSession(): express.RequestHandler;
|
|
@@ -15,7 +15,7 @@ export declare abstract class UserFiles {
|
|
|
15
15
|
getParam<T>(paramFileName: string): Promise<T>;
|
|
16
16
|
setParam<T>(paramFileName: string, param: T): Promise<void>;
|
|
17
17
|
}
|
|
18
|
-
export
|
|
18
|
+
export type ObjPipe = (outStream: NodeJS.WritableStream) => Promise<void>;
|
|
19
19
|
export interface ObjReader {
|
|
20
20
|
len: number;
|
|
21
21
|
/**
|
|
@@ -10,7 +10,7 @@ export interface SessionParams extends UserParams {
|
|
|
10
10
|
sessionKey: Uint8Array;
|
|
11
11
|
serverVerificationBytes: Uint8Array;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
13
|
+
export type Request = SessReq<SessionParams>;
|
|
14
14
|
export interface UserPKeyAndKeyGenParams {
|
|
15
15
|
pkey: Uint8Array;
|
|
16
16
|
params?: any;
|
|
@@ -22,7 +22,7 @@ export interface UserPKeyAndKeyGenParams {
|
|
|
22
22
|
* Else, if incoming id is not ok, undefined is returned.
|
|
23
23
|
* @params initUserId is a an incoming string, that should be an id
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export type CheckAndTransformUserId = (initUserId: string) => string | undefined;
|
|
26
26
|
/**
|
|
27
27
|
* This returns a promise of user public key and related parameters.
|
|
28
28
|
* If user is not found, undefined is returned.
|
|
@@ -30,8 +30,8 @@ export declare type CheckAndTransformUserId = (initUserId: string) => string | u
|
|
|
30
30
|
* @param kid is a key id that should be used at login. Undefined value
|
|
31
31
|
* indicates that default key should be used.
|
|
32
32
|
*/
|
|
33
|
-
export
|
|
34
|
-
export
|
|
33
|
+
export type GetUserPKeyAndKeyGenParams = (userId: string, kid: string | undefined) => Promise<UserPKeyAndKeyGenParams | undefined>;
|
|
34
|
+
export type ComputeDHSharedKey = (userKey: Uint8Array) => {
|
|
35
35
|
dhsharedKey: Uint8Array;
|
|
36
36
|
serverPubKey: Uint8Array;
|
|
37
37
|
};
|
|
@@ -6,7 +6,7 @@ import { SignedLoad } from '../../../lib-common/jwkeys';
|
|
|
6
6
|
* Autherization failure may be due to either, invalid MailerId credentials, or
|
|
7
7
|
* due to other service's restriction(s) on users.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type MidAuthorizer = (rpDomain: string, sessionId: string, userId: string, mailerIdAssertion: SignedLoad, userCert: SignedLoad, provCert: SignedLoad) => Promise<boolean>;
|
|
10
10
|
/**
|
|
11
11
|
* @param relyingPartyDomain is a domain of service, for which this assertion
|
|
12
12
|
* check is done. Usually, it is this site's domain, which we set explicitly.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RequestHandler } from 'express';
|
|
2
2
|
import { GenerateSession, Request as SessionReq, SessionParams } from '../../resources/sessions';
|
|
3
|
-
export
|
|
3
|
+
export type Request = SessionReq<SessionParams>;
|
|
4
4
|
/**
|
|
5
5
|
* This function checks overall shape of a given user id, possibly
|
|
6
6
|
* transforming it to some canonical form, used by the service.
|
|
@@ -8,9 +8,9 @@ export declare type Request = SessionReq<SessionParams>;
|
|
|
8
8
|
* Else, if incoming id is not ok, undefined is returned.
|
|
9
9
|
* @params initUserId is a an incoming string, that should be an id
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
11
|
+
export type CheckAndTransformUserId = (initUserId: string) => string | undefined;
|
|
12
|
+
export type UserExists = (userId: string) => Promise<boolean>;
|
|
13
|
+
export type Redirect = (userId: string) => Promise<string>;
|
|
14
14
|
/**
|
|
15
15
|
* This returns route handler that creates sessions for a given userId, with
|
|
16
16
|
* potential redirect for a named user.
|
|
@@ -5,7 +5,7 @@ import * as https from 'https';
|
|
|
5
5
|
import * as express from 'express';
|
|
6
6
|
import * as WebSocket from 'ws';
|
|
7
7
|
import { CheckSession, SessionParams } from '../resources/sessions';
|
|
8
|
-
export
|
|
8
|
+
export type HttpServer = http.Server | https.Server;
|
|
9
9
|
export declare class UserSockets {
|
|
10
10
|
checkSession: CheckSession<SessionParams>;
|
|
11
11
|
/**
|
|
@@ -209,6 +209,12 @@ class PingSender {
|
|
|
209
209
|
Object.freeze(PingSender.prototype);
|
|
210
210
|
Object.freeze(PingSender);
|
|
211
211
|
class AppWithWSs {
|
|
212
|
+
get sockServer() {
|
|
213
|
+
if (!this.socks) {
|
|
214
|
+
this.socks = new UserSocketsServer();
|
|
215
|
+
}
|
|
216
|
+
return this.socks;
|
|
217
|
+
}
|
|
212
218
|
constructor(httpApp) {
|
|
213
219
|
this.server = undefined;
|
|
214
220
|
this.closingProc = undefined;
|
|
@@ -216,12 +222,6 @@ class AppWithWSs {
|
|
|
216
222
|
this.http = (httpApp ? httpApp : express());
|
|
217
223
|
Object.seal(this);
|
|
218
224
|
}
|
|
219
|
-
get sockServer() {
|
|
220
|
-
if (!this.socks) {
|
|
221
|
-
this.socks = new UserSocketsServer();
|
|
222
|
-
}
|
|
223
|
-
return this.socks;
|
|
224
|
-
}
|
|
225
225
|
addWS(path, socks) {
|
|
226
226
|
if (typeof path === 'string') {
|
|
227
227
|
socks.path = ensureSlashesOnFront(path);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as WebSocket from 'ws';
|
|
2
2
|
import { SocketIPCs } from './app';
|
|
3
|
-
export
|
|
3
|
+
export type EventsSink<T> = (userId: string, channel: string, event: T) => void;
|
|
4
4
|
export declare class ServerEvents<T> implements SocketIPCs {
|
|
5
5
|
ipcChannel: string | undefined;
|
|
6
6
|
private eventChannels;
|
package/build/lib.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { AppWithWSs } from './lib-server/web-sockets/app';
|
|
2
2
|
export { Configurations, servicesApp, adminApp } from './services';
|
|
3
|
-
export { getConfsFromEnv, getBindParamsFromEnv } from './config/from-env';
|
|
4
3
|
export { addSingleUserSignup } from './config/signup';
|
|
5
4
|
export import errors = require('./lib-server/middleware/error-handler');
|
|
6
5
|
export * as mock from './mock/run-in-proc';
|
package/build/lib.js
CHANGED
|
@@ -16,15 +16,12 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.mock = exports.addSingleUserSignup = exports.
|
|
19
|
+
exports.mock = exports.addSingleUserSignup = exports.adminApp = exports.servicesApp = exports.AppWithWSs = void 0;
|
|
20
20
|
var app_1 = require("./lib-server/web-sockets/app");
|
|
21
21
|
Object.defineProperty(exports, "AppWithWSs", { enumerable: true, get: function () { return app_1.AppWithWSs; } });
|
|
22
22
|
var services_1 = require("./services");
|
|
23
23
|
Object.defineProperty(exports, "servicesApp", { enumerable: true, get: function () { return services_1.servicesApp; } });
|
|
24
24
|
Object.defineProperty(exports, "adminApp", { enumerable: true, get: function () { return services_1.adminApp; } });
|
|
25
|
-
var from_env_1 = require("./config/from-env");
|
|
26
|
-
Object.defineProperty(exports, "getConfsFromEnv", { enumerable: true, get: function () { return from_env_1.getConfsFromEnv; } });
|
|
27
|
-
Object.defineProperty(exports, "getBindParamsFromEnv", { enumerable: true, get: function () { return from_env_1.getBindParamsFromEnv; } });
|
|
28
25
|
var signup_1 = require("./config/signup");
|
|
29
26
|
Object.defineProperty(exports, "addSingleUserSignup", { enumerable: true, get: function () { return signup_1.addSingleUserSignup; } });
|
|
30
27
|
exports.errors = require("./lib-server/middleware/error-handler");
|
|
@@ -6,7 +6,7 @@ export interface RootCerts {
|
|
|
6
6
|
current: SignedLoad;
|
|
7
7
|
previous: SignedLoad[];
|
|
8
8
|
}
|
|
9
|
-
export
|
|
9
|
+
export type ICertify = (userPKey: JsonKey, address: string, validFor?: number) => {
|
|
10
10
|
userCert: SignedLoad;
|
|
11
11
|
provCert: SignedLoad;
|
|
12
12
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Factory } from '../../lib-server/resources/sessions';
|
|
2
2
|
import { SessionParams } from '../../lib-server/routes/pub-key-login/start-exchange';
|
|
3
3
|
export { Request } from '../../lib-server/routes/pub-key-login/start-exchange';
|
|
4
|
-
export
|
|
4
|
+
export type SessionsFactory = Factory<SessionParams>;
|
|
5
5
|
/**
|
|
6
6
|
* This returns factory, that works properly in a single process application,
|
|
7
7
|
* clearing up sessions that past given timeout.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as cProcs from 'child_process';
|
|
3
3
|
import { RequestServer, RequestingClient } from '../lib-common/ipc/generic-ipc';
|
|
4
4
|
export { RequestEnvelope, RequestHandler } from '../lib-common/ipc/generic-ipc';
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type IPCToChild = RequestingClient;
|
|
6
|
+
export type IPCToParent = RequestServer;
|
|
7
7
|
export declare function commToChild(channel: string, child: cProcs.ChildProcess): IPCToChild;
|
|
8
8
|
export declare function commToParent(channel: string): IPCToParent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-3nweb-server",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "3NWeb spec server.",
|
|
5
5
|
"main": "build/lib.js",
|
|
6
6
|
"types": "build/lib.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"clear-for-packing": "npm prune --production && bash -c \"rm -rf build/mock build/tests 'node_modules/ecma-nacl/c sources'\"",
|
|
11
11
|
"clear-for-packing-mock": "npm prune --production && bash -c \"rm -rf build/tests 'node_modules/ecma-nacl/c sources'\"",
|
|
12
12
|
"pack": "pkg --config package.json build/main.js",
|
|
13
|
-
"pack-deb": "npm run pack && bash packing/
|
|
13
|
+
"pack-deb": "npm run pack && bash packing/create-deb.sh",
|
|
14
14
|
"postinstall": "node -e \"try{require('./postinstall')}catch(e){}\""
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"command-line-args": "^5.2.1",
|
|
35
35
|
"command-line-usage": "^7.0.1",
|
|
36
36
|
"ecma-nacl": "^2.4.0",
|
|
37
|
-
"express": "^4.
|
|
37
|
+
"express": "^4.19.2",
|
|
38
38
|
"js-yaml": "^4.1.0",
|
|
39
39
|
"prompts": "^2.4.2",
|
|
40
40
|
"punycode": "^2.1.1",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Configurations } from "../services";
|
|
3
|
-
import { ServerOptions } from "https";
|
|
4
|
-
export declare function getConfsFromEnv(): Configurations;
|
|
5
|
-
export declare function getBindParamsFromEnv(): {
|
|
6
|
-
address?: string;
|
|
7
|
-
port: number;
|
|
8
|
-
sslOpts?: ServerOptions;
|
|
9
|
-
};
|
package/build/config/from-env.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (C) 2019 - 2020 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.getBindParamsFromEnv = exports.getConfsFromEnv = void 0;
|
|
20
|
-
const async_fs_node_1 = require("../lib-common/async-fs-node");
|
|
21
|
-
const path_1 = require("path");
|
|
22
|
-
const fs_1 = require("fs");
|
|
23
|
-
const DOMAIN_VAR = 'W3N_DOMAIN';
|
|
24
|
-
const DATA_DIR_VAR = 'W3N_DATA_DIR';
|
|
25
|
-
const NO_TOKENS_FILE = 'NO_TOKENS_FILE';
|
|
26
|
-
const CERTS_FILE_VAR = 'W3N_MID_CERTS_FILE';
|
|
27
|
-
const ADDRESS_VAR = 'W3N_SERICE_ADDRESS';
|
|
28
|
-
const PORT_VAR = 'W3N_SERICE_PORT';
|
|
29
|
-
const TLS_KEY_VAR = 'W3N_SERICE_TLS_KEY';
|
|
30
|
-
const TLS_CERT_VAR = 'W3N_SERICE_TLS_CERT';
|
|
31
|
-
const TLS_PFX_VAR = 'W3N_SERICE_TLS_PFX';
|
|
32
|
-
const DEFAULT_PORT = 8080;
|
|
33
|
-
function makeConf(domain, rootFolder, midCertsFile, noTokenFile) {
|
|
34
|
-
return {
|
|
35
|
-
enabledServices: {
|
|
36
|
-
asmail: true,
|
|
37
|
-
storage: true,
|
|
38
|
-
mailerId: true
|
|
39
|
-
},
|
|
40
|
-
rootFolder,
|
|
41
|
-
domain,
|
|
42
|
-
mailerId: {
|
|
43
|
-
certs: midCertsFile
|
|
44
|
-
},
|
|
45
|
-
signup: {
|
|
46
|
-
noTokenFile
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function getConfsFromEnv() {
|
|
51
|
-
const domain = process.env[DOMAIN_VAR];
|
|
52
|
-
if (!domain) {
|
|
53
|
-
throw new Error(`Environment variable ${DOMAIN_VAR} is not set with domain name, for which 3NWeb processes are served.`);
|
|
54
|
-
}
|
|
55
|
-
let dataDir = process.env[DATA_DIR_VAR];
|
|
56
|
-
if (!dataDir) {
|
|
57
|
-
dataDir = '/var/local/3nweb';
|
|
58
|
-
}
|
|
59
|
-
// Make data folders
|
|
60
|
-
ensureFolderPresence(dataDir, true);
|
|
61
|
-
dataDir = (0, fs_1.realpathSync)(dataDir);
|
|
62
|
-
let midCerts = process.env[CERTS_FILE_VAR];
|
|
63
|
-
if (!midCerts) {
|
|
64
|
-
midCerts = (0, path_1.join)(dataDir, 'mid-certs.json');
|
|
65
|
-
}
|
|
66
|
-
const noTokenFile = process.env[NO_TOKENS_FILE];
|
|
67
|
-
return makeConf(domain, dataDir, midCerts, noTokenFile);
|
|
68
|
-
}
|
|
69
|
-
exports.getConfsFromEnv = getConfsFromEnv;
|
|
70
|
-
function ensureFolderPresence(path, doLog) {
|
|
71
|
-
if ((0, async_fs_node_1.existsFolderSync)(path)) {
|
|
72
|
-
if (doLog) {
|
|
73
|
-
console.log(`Using existing data folder ${path}`);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
(0, fs_1.mkdirSync)(path);
|
|
78
|
-
if (doLog) {
|
|
79
|
-
console.log(`Created ${(0, fs_1.realpathSync)(path)}`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function getBindParamsFromEnv() {
|
|
84
|
-
const address = process.env[ADDRESS_VAR];
|
|
85
|
-
const portStr = process.env[PORT_VAR];
|
|
86
|
-
let port;
|
|
87
|
-
if (portStr) {
|
|
88
|
-
port = Number.parseInt(portStr);
|
|
89
|
-
if (!Number.isInteger(port)) {
|
|
90
|
-
port = DEFAULT_PORT;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
port = DEFAULT_PORT;
|
|
95
|
-
}
|
|
96
|
-
const sslOpts = getTLSParamsFromEnv();
|
|
97
|
-
return { address, port, sslOpts };
|
|
98
|
-
}
|
|
99
|
-
exports.getBindParamsFromEnv = getBindParamsFromEnv;
|
|
100
|
-
function getTLSParamsFromEnv() {
|
|
101
|
-
const pfx = process.env[TLS_PFX_VAR];
|
|
102
|
-
if (pfx) {
|
|
103
|
-
return { pfx };
|
|
104
|
-
}
|
|
105
|
-
const cert = process.env[TLS_CERT_VAR];
|
|
106
|
-
const key = process.env[TLS_KEY_VAR];
|
|
107
|
-
if (cert && key) {
|
|
108
|
-
return { cert, key };
|
|
109
|
-
}
|
|
110
|
-
else if (!cert && !key) {
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
throw new Error(`Both ${TLS_CERT_VAR} and ${TLS_KEY_VAR} environment parameters should be present, but one is missing.`);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
Object.freeze(exports);
|
package/build/run.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/build/run.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (C) 2015 - 2019 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
|
-
const lib_1 = require("./lib");
|
|
20
|
-
(async () => {
|
|
21
|
-
let app = undefined;
|
|
22
|
-
async function stopProcess() {
|
|
23
|
-
if (!app) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
app.stop().then(err => console.log(err));
|
|
27
|
-
app = undefined;
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
const conf = (0, lib_1.getConfsFromEnv)();
|
|
31
|
-
app = new lib_1.AppWithWSs();
|
|
32
|
-
app.use((0, lib_1.servicesApp)(conf));
|
|
33
|
-
app.use((0, lib_1.adminApp)(conf));
|
|
34
|
-
const { address, port, sslOpts } = (0, lib_1.getBindParamsFromEnv)();
|
|
35
|
-
await app.start(sslOpts, port, address);
|
|
36
|
-
console.log(`Started 3NWeb server at address ${address}, port ${port}, ${sslOpts ? 'via TLS' : 'without TLS, and requiring TLS reverse proxy infront.'}`);
|
|
37
|
-
process.on('SIGINT', stopProcess);
|
|
38
|
-
process.on('SIGTERM', stopProcess);
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
stopProcess();
|
|
42
|
-
console.error(err);
|
|
43
|
-
process.exit(-500);
|
|
44
|
-
}
|
|
45
|
-
})();
|