spec-3nweb-server 1.6.4 → 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/README.md +0 -1
- 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/admin-app.d.ts +1 -1
- package/build/admin/admin-app.js +4 -1
- 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/cli/index.d.ts +9 -0
- package/build/config/cli/index.js +68 -0
- package/build/config/cli/run-cmd.d.ts +10 -0
- package/build/config/cli/run-cmd.js +69 -0
- package/build/config/cli/signup-cmd.d.ts +17 -0
- package/build/config/cli/signup-cmd.js +194 -0
- package/build/config/cli/user-cmd.d.ts +9 -0
- package/build/config/cli/user-cmd.js +55 -0
- package/build/config/cli/utils.d.ts +45 -0
- package/build/config/cli/utils.js +52 -0
- package/build/config/from-yaml.d.ts +2 -0
- package/build/config/from-yaml.js +28 -0
- package/build/config/letsencrypt.d.ts +7 -0
- package/build/config/letsencrypt.js +62 -0
- package/build/config/signup.d.ts +15 -0
- package/build/config/signup.js +133 -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/dns.js +48 -10
- 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 +1 -1
- package/build/lib.js +3 -5
- package/build/mailerId/resources/certifier.d.ts +1 -1
- package/build/mailerId/resources/sessions.d.ts +1 -1
- package/build/main.js +196 -45
- package/build/mock/node-child-ipc.d.ts +2 -2
- package/build/mock/run-in-proc.js +6 -3
- package/build/services.d.ts +4 -2
- package/build/services.js +15 -6
- package/package.json +16 -3
- package/postinstall.js +25 -0
- package/build/run-config.d.ts +0 -10
- package/build/run-config.js +0 -146
- package/build/run.d.ts +0 -1
- package/build/run.js +0 -45
package/README.md
CHANGED
|
@@ -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
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
2
|
import { ErrLogger } from '../lib-server/middleware/error-handler';
|
|
3
3
|
import { Configurations } from '../services';
|
|
4
|
-
export declare function makeApp(conf: Configurations, errLogger?: ErrLogger): express.Express;
|
|
4
|
+
export declare function makeApp(conf: Configurations, errLogger?: ErrLogger, logSetup?: 'console'): express.Express;
|
package/build/admin/admin-app.js
CHANGED
|
@@ -33,12 +33,15 @@ function apiPart(users) {
|
|
|
33
33
|
app.post('/' + signupApi.addUser.URL_END, (0, body_parsers_1.json)('4kb'), (0, add_1.addUser)(users.add));
|
|
34
34
|
return app;
|
|
35
35
|
}
|
|
36
|
-
function makeApp(conf, errLogger) {
|
|
36
|
+
function makeApp(conf, errLogger, logSetup) {
|
|
37
37
|
const app = express();
|
|
38
38
|
const noTokenFile = (conf.signup ? conf.signup.noTokenFile : undefined);
|
|
39
39
|
const users = (0, users_1.makeFactory)(conf.rootFolder, noTokenFile);
|
|
40
40
|
if (conf.signup) {
|
|
41
41
|
app.use('/signup', apiPart(users));
|
|
42
|
+
if (logSetup === 'console') {
|
|
43
|
+
console.log(`Enabled signup service.`);
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
46
|
app.use((0, error_handler_1.makeErrHandler)(errLogger));
|
|
44
47
|
return app;
|
|
@@ -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
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ParsedRunArgs } from "./run-cmd";
|
|
2
|
+
import { ParsedSignupArgs } from "./signup-cmd";
|
|
3
|
+
import { CliUsageDisplay } from "./utils";
|
|
4
|
+
export { CliUsageDisplay } from "./utils";
|
|
5
|
+
export declare function parseProcessArgv(): {
|
|
6
|
+
runCmd?: ParsedRunArgs;
|
|
7
|
+
signupCmd?: ParsedSignupArgs;
|
|
8
|
+
showUsage?: CliUsageDisplay;
|
|
9
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2023 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.parseProcessArgv = void 0;
|
|
20
|
+
const path_1 = require("path");
|
|
21
|
+
const run_cmd_1 = require("./run-cmd");
|
|
22
|
+
const signup_cmd_1 = require("./signup-cmd");
|
|
23
|
+
const utils_1 = require("./utils");
|
|
24
|
+
function mainUsage(execName) {
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
header: execName,
|
|
28
|
+
content: `Server of all 3NWeb utilities: MailerId, ASMail, 3NStorage.`
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
header: `Usage:`,
|
|
32
|
+
content: `${execName} [command]`
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
header: 'Available commands:',
|
|
36
|
+
content: [
|
|
37
|
+
run_cmd_1.runCmd,
|
|
38
|
+
signup_cmd_1.signupCmd
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
header: '',
|
|
43
|
+
content: `Use "${execName} [command] --help" for more information about a command.`
|
|
44
|
+
}
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
function parseProcessArgv() {
|
|
48
|
+
const args = process.argv.slice(2);
|
|
49
|
+
const execName = (0, path_1.basename)(process.argv0);
|
|
50
|
+
if (args.length === 0) {
|
|
51
|
+
return (0, utils_1.toUsageDisplay)(0, mainUsage(execName));
|
|
52
|
+
}
|
|
53
|
+
if (args[0] === run_cmd_1.runCmd.name) {
|
|
54
|
+
return (0, run_cmd_1.parseRunArgs)(args.slice(1), execName);
|
|
55
|
+
}
|
|
56
|
+
else if (args[0] === signup_cmd_1.signupCmd.name) {
|
|
57
|
+
return (0, signup_cmd_1.parseSignupArgs)(args.slice(1), execName);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const opts = (0, utils_1.parseArgv)(args, [utils_1.helpOpt], { partial: true });
|
|
61
|
+
if (opts.help) {
|
|
62
|
+
return (0, utils_1.toUsageDisplay)(0, mainUsage(execName));
|
|
63
|
+
}
|
|
64
|
+
return (0, utils_1.toUsageDisplay)(-1, (0, utils_1.toErrorUsage)(mainUsage(execName), `Unknown command '${args[0]}'`));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.parseProcessArgv = parseProcessArgv;
|
|
68
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CliUsageDisplay, CommandDef } from "./utils";
|
|
2
|
+
export declare const runCmd: CommandDef<'run'>;
|
|
3
|
+
export interface ParsedRunArgs {
|
|
4
|
+
config?: string;
|
|
5
|
+
help?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseRunArgs(args: string[], execName: string): {
|
|
8
|
+
runCmd?: ParsedRunArgs;
|
|
9
|
+
showUsage?: CliUsageDisplay;
|
|
10
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2023 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.parseRunArgs = exports.runCmd = void 0;
|
|
20
|
+
const utils_1 = require("./utils");
|
|
21
|
+
exports.runCmd = {
|
|
22
|
+
name: 'run',
|
|
23
|
+
summary: 'runs 3NWeb services'
|
|
24
|
+
};
|
|
25
|
+
function runUsage(execName) {
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
content: `This command runs some or all 3NWeb services. Configuration is read from a yaml file.`
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
header: 'Usage:',
|
|
32
|
+
content: `${execName} ${exports.runCmd.name} [options] [config_file]`
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
header: 'Options:',
|
|
36
|
+
optionList: runOpts
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
const runOpts = [
|
|
41
|
+
{
|
|
42
|
+
name: 'config',
|
|
43
|
+
alias: 'c',
|
|
44
|
+
type: String,
|
|
45
|
+
typeLabel: '{underline <file>}',
|
|
46
|
+
description: `path of a configuration yaml file`
|
|
47
|
+
},
|
|
48
|
+
utils_1.helpOpt
|
|
49
|
+
];
|
|
50
|
+
function parseRunArgs(args, execName) {
|
|
51
|
+
if (args.length === 0) {
|
|
52
|
+
return (0, utils_1.toUsageDisplay)(0, runUsage(execName));
|
|
53
|
+
}
|
|
54
|
+
const runArgs = (0, utils_1.parseArgv)(args, runOpts, { partial: true });
|
|
55
|
+
if (runArgs.help) {
|
|
56
|
+
return (0, utils_1.toUsageDisplay)(0, runUsage(execName));
|
|
57
|
+
}
|
|
58
|
+
else if (runArgs.config) {
|
|
59
|
+
return { runCmd: runArgs };
|
|
60
|
+
}
|
|
61
|
+
else if (runArgs._unknown) {
|
|
62
|
+
return { runCmd: { config: runArgs._unknown[0] } };
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
return (0, utils_1.toUsageDisplay)(-1, (0, utils_1.toErrorUsage)(runUsage(execName), `Missing configuration file path.`));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.parseRunArgs = parseRunArgs;
|
|
69
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CliUsageDisplay, CommandDef } from "./utils";
|
|
2
|
+
export declare const signupCmd: CommandDef<'signup'>;
|
|
3
|
+
export interface ParsedSignupArgs {
|
|
4
|
+
info?: boolean;
|
|
5
|
+
config?: string;
|
|
6
|
+
help?: boolean;
|
|
7
|
+
listTokens?: boolean;
|
|
8
|
+
showToken?: boolean;
|
|
9
|
+
token?: string;
|
|
10
|
+
createToken?: boolean;
|
|
11
|
+
domain?: string[];
|
|
12
|
+
user?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function parseSignupArgs(args: string[], execName: string): {
|
|
15
|
+
signupCmd?: ParsedSignupArgs;
|
|
16
|
+
showUsage?: CliUsageDisplay;
|
|
17
|
+
};
|