spec-3nweb-server 1.8.5 → 1.8.6
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/.gitlab-ci-linux.yml +50 -0
- package/.gitlab-ci-mac.yml +29 -0
- package/.gitlab-ci-windows.yml +29 -0
- package/.gitlab-ci.yml +63 -0
- package/build/mock/tls-options.js +46 -44
- package/build/tests/admin-proto/signup.d.ts +1 -0
- package/build/tests/admin-proto/signup.js +235 -0
- package/build/tests/jasmine.d.ts +1 -0
- package/build/tests/jasmine.js +32 -0
- package/build/tests/libs-for-tests/3nstorage.d.ts +22 -0
- package/build/tests/libs-for-tests/3nstorage.js +123 -0
- package/build/tests/libs-for-tests/asmail.d.ts +22 -0
- package/build/tests/libs-for-tests/asmail.js +179 -0
- package/build/tests/libs-for-tests/assert.d.ts +1 -0
- package/build/tests/libs-for-tests/assert.js +26 -0
- package/build/tests/libs-for-tests/async-jasmine.d.ts +7 -0
- package/build/tests/libs-for-tests/async-jasmine.js +77 -0
- package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/bytes-equal.js +34 -0
- package/build/tests/libs-for-tests/json-copy.d.ts +1 -0
- package/build/tests/libs-for-tests/json-copy.js +45 -0
- package/build/tests/libs-for-tests/json-equal.d.ts +4 -0
- package/build/tests/libs-for-tests/json-equal.js +67 -0
- package/build/tests/libs-for-tests/mailerid.d.ts +13 -0
- package/build/tests/libs-for-tests/mailerid.js +114 -0
- package/build/tests/libs-for-tests/pkl.d.ts +28 -0
- package/build/tests/libs-for-tests/pkl.js +89 -0
- package/build/tests/libs-for-tests/server-components/3nstorage.d.ts +20 -0
- package/build/tests/libs-for-tests/server-components/3nstorage.js +200 -0
- package/build/tests/libs-for-tests/server-components/admin.d.ts +6 -0
- package/build/tests/libs-for-tests/server-components/admin.js +43 -0
- package/build/tests/libs-for-tests/server-components/asmail.d.ts +16 -0
- package/build/tests/libs-for-tests/server-components/asmail.js +143 -0
- package/build/tests/libs-for-tests/server-components/component.d.ts +13 -0
- package/build/tests/libs-for-tests/server-components/component.js +77 -0
- package/build/tests/libs-for-tests/server-components/mailerid.d.ts +10 -0
- package/build/tests/libs-for-tests/server-components/mailerid.js +103 -0
- package/build/tests/libs-for-tests/server-runner.d.ts +15 -0
- package/build/tests/libs-for-tests/server-runner.js +69 -0
- package/build/tests/libs-for-tests/spec-assembly.d.ts +6 -0
- package/build/tests/libs-for-tests/spec-assembly.js +55 -0
- package/build/tests/libs-for-tests/ws-utils.d.ts +3 -0
- package/build/tests/libs-for-tests/ws-utils.js +59 -0
- package/build/tests/libs-for-tests/xhr-utils.d.ts +61 -0
- package/build/tests/libs-for-tests/xhr-utils.js +154 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.js +84 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.js +78 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.js +83 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.js +77 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-obj.js +75 -0
- package/build/tests/protocols/3nstorage/owner/specs/events.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/events.js +91 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.js +269 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-root.js +262 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.js +79 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-root-status.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-root-status.js +72 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.js +287 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-root.js +274 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.js +73 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.js +72 -0
- package/build/tests/protocols/3nstorage/owner/test-utils.d.ts +14 -0
- package/build/tests/protocols/3nstorage/owner/test-utils.js +54 -0
- package/build/tests/protocols/3nstorage/owner.d.ts +1 -0
- package/build/tests/protocols/3nstorage/owner.js +138 -0
- package/build/tests/protocols/asmail/config.d.ts +1 -0
- package/build/tests/protocols/asmail/config.js +117 -0
- package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.js +60 -0
- package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.js +68 -0
- package/build/tests/protocols/asmail/delivery/specs/put-metadata.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/put-metadata.js +83 -0
- package/build/tests/protocols/asmail/delivery/specs/put-obj.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/put-obj.js +123 -0
- package/build/tests/protocols/asmail/delivery/specs/restart-session.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/restart-session.js +79 -0
- package/build/tests/protocols/asmail/delivery/specs/start-session.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/start-session.js +64 -0
- package/build/tests/protocols/asmail/delivery/test-utils.d.ts +16 -0
- package/build/tests/protocols/asmail/delivery/test-utils.js +46 -0
- package/build/tests/protocols/asmail/delivery.d.ts +1 -0
- package/build/tests/protocols/asmail/delivery.js +46 -0
- package/build/tests/protocols/asmail/retrieval/specs/events.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/events.js +62 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.js +70 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.js +166 -0
- package/build/tests/protocols/asmail/retrieval/specs/list-messages.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/list-messages.js +96 -0
- package/build/tests/protocols/asmail/retrieval/specs/remove-message.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/remove-message.js +66 -0
- package/build/tests/protocols/asmail/retrieval/test-utils.d.ts +17 -0
- package/build/tests/protocols/asmail/retrieval/test-utils.js +46 -0
- package/build/tests/protocols/asmail/retrieval.d.ts +1 -0
- package/build/tests/protocols/asmail/retrieval.js +92 -0
- package/build/tests/protocols/mailerid.d.ts +1 -0
- package/build/tests/protocols/mailerid.js +210 -0
- package/build/tests/shared-checks/check-mid-login.d.ts +2 -0
- package/build/tests/shared-checks/check-mid-login.js +131 -0
- package/build/tests/shared-checks/requests.d.ts +20 -0
- package/build/tests/shared-checks/requests.js +123 -0
- package/package.json +1 -1
- package/packing/create-deb.sh +57 -0
- package/packing/deb/lib/systemd/system/3nweb.service +11 -0
- package/packing/deb/postinst +44 -0
- package/packing/deb/usr/share/doc/3nweb-server/conf-for-postinstall.yaml +19 -0
- package/packing/deb/usr/share/doc/3nweb-server/copyright +22 -0
- package/publish-task.sh +10 -0
- package/push-to-github.sh +105 -0
- package/ts-code/3nstorage/3nstorage-app.ts +99 -0
- package/ts-code/3nstorage/owner.ts +178 -0
- package/ts-code/3nstorage/resources/sessions.ts +37 -0
- package/ts-code/3nstorage/resources/store.ts +896 -0
- package/ts-code/3nstorage/resources/users.ts +258 -0
- package/ts-code/3nstorage/routes/owner/archive-obj-version.ts +73 -0
- package/ts-code/3nstorage/routes/owner/cancel-trans.ts +58 -0
- package/ts-code/3nstorage/routes/owner/delete-obj.ts +103 -0
- package/ts-code/3nstorage/routes/owner/get-archived-obj-ver.ts +111 -0
- package/ts-code/3nstorage/routes/owner/get-current-obj.ts +122 -0
- package/ts-code/3nstorage/routes/owner/get-obj-status.ts +55 -0
- package/ts-code/3nstorage/routes/owner/param-getter.ts +51 -0
- package/ts-code/3nstorage/routes/owner/param-setter.ts +50 -0
- package/ts-code/3nstorage/routes/owner/put-current-obj.ts +284 -0
- package/ts-code/3nstorage/routes/owner/session-params.ts +49 -0
- package/ts-code/3nstorage/shared.ts +43 -0
- package/ts-code/asmail/asmail-app.ts +91 -0
- package/ts-code/asmail/config.ts +96 -0
- package/ts-code/asmail/delivery.ts +94 -0
- package/ts-code/asmail/resources/delivery-sessions.ts +118 -0
- package/ts-code/asmail/resources/inbox.ts +696 -0
- package/ts-code/asmail/resources/recipients.ts +495 -0
- package/ts-code/asmail/resources/sessions.ts +37 -0
- package/ts-code/asmail/retrieval.ts +96 -0
- package/ts-code/asmail/routes/config/param-getter.ts +49 -0
- package/ts-code/asmail/routes/config/param-setter.ts +49 -0
- package/ts-code/asmail/routes/delivery/finalize-delivery.ts +50 -0
- package/ts-code/asmail/routes/delivery/pre-flight.ts +132 -0
- package/ts-code/asmail/routes/delivery/provide-recipient-pubkey.ts +58 -0
- package/ts-code/asmail/routes/delivery/put-metadata.ts +94 -0
- package/ts-code/asmail/routes/delivery/put-obj.ts +166 -0
- package/ts-code/asmail/routes/delivery/restart-session.ts +130 -0
- package/ts-code/asmail/routes/delivery/sender-authorization.ts +81 -0
- package/ts-code/asmail/routes/delivery/start-session.ts +151 -0
- package/ts-code/asmail/routes/retrieval/get-message-meta.ts +53 -0
- package/ts-code/asmail/routes/retrieval/get-message-obj.ts +109 -0
- package/ts-code/asmail/routes/retrieval/list-messages.ts +70 -0
- package/ts-code/asmail/routes/retrieval/remove-message.ts +47 -0
- package/ts-code/cli/index.ts +82 -0
- package/ts-code/cli/run-cmd.ts +81 -0
- package/ts-code/cli/show-sample-config.ts +78 -0
- package/ts-code/cli/signup-cmd.ts +229 -0
- package/ts-code/cli/user-cmd.ts +68 -0
- package/ts-code/cli/utils.ts +105 -0
- package/ts-code/config/default-confs.ts +22 -0
- package/ts-code/config/from-yaml.ts +35 -0
- package/ts-code/config/letsencrypt.ts +77 -0
- package/ts-code/config/signup.ts +137 -0
- package/ts-code/lib-common/admin-api/signup.ts +120 -0
- package/ts-code/lib-common/assert.ts +22 -0
- package/ts-code/lib-common/async-fs-node.ts +656 -0
- package/ts-code/lib-common/buffer-utils.ts +124 -0
- package/ts-code/lib-common/byte-streaming/common.ts +166 -0
- package/ts-code/lib-common/bytes-equal.ts +25 -0
- package/ts-code/lib-common/canonical-address.ts +92 -0
- package/ts-code/lib-common/exceptions/error.ts +44 -0
- package/ts-code/lib-common/exceptions/file.ts +84 -0
- package/ts-code/lib-common/exceptions/http.ts +69 -0
- package/ts-code/lib-common/ipc/generic-ipc.ts +750 -0
- package/ts-code/lib-common/ipc/ws-ipc.ts +117 -0
- package/ts-code/lib-common/json-equal.ts +55 -0
- package/ts-code/lib-common/json-utils.ts +130 -0
- package/ts-code/lib-common/jwkeys.ts +246 -0
- package/ts-code/lib-common/map-of-sets.ts +60 -0
- package/ts-code/lib-common/mid-sigs-NaCl-Ed.ts +677 -0
- package/ts-code/lib-common/objs-on-disk/file-layout.ts +480 -0
- package/ts-code/lib-common/objs-on-disk/obj-file.ts +325 -0
- package/ts-code/lib-common/objs-on-disk/utils.ts +201 -0
- package/ts-code/lib-common/objs-on-disk/v1-obj-file-format.ts +329 -0
- package/ts-code/lib-common/processes.ts +501 -0
- package/ts-code/lib-common/random-node.ts +79 -0
- package/ts-code/lib-common/service-api/3nstorage/owner.ts +559 -0
- package/ts-code/lib-common/service-api/3nstorage/root-route.ts +22 -0
- package/ts-code/lib-common/service-api/asmail/config.ts +144 -0
- package/ts-code/lib-common/service-api/asmail/delivery.ts +250 -0
- package/ts-code/lib-common/service-api/asmail/retrieval.ts +238 -0
- package/ts-code/lib-common/service-api/asmail/root-route.ts +22 -0
- package/ts-code/lib-common/service-api/ipc-api.ts +44 -0
- package/ts-code/lib-common/service-api/locker.ts +44 -0
- package/ts-code/lib-common/service-api/mailer-id/login.ts +80 -0
- package/ts-code/lib-common/service-api/mailer-id/provisioning.ts +64 -0
- package/ts-code/lib-common/service-api/mailer-id/root-route.ts +25 -0
- package/ts-code/lib-common/service-api/pub-key-login.ts +75 -0
- package/ts-code/lib-common/service-api/web-socket-base.ts +87 -0
- package/ts-code/lib-common/session-encryptor.ts +54 -0
- package/ts-code/lib-common/time-window-cache.ts +74 -0
- package/ts-code/lib-common/transferable.d.ts +30 -0
- package/ts-code/lib-server/conf-util.ts +35 -0
- package/ts-code/lib-server/mid-access.ts +45 -0
- package/ts-code/lib-server/middleware/body-parsers.ts +248 -0
- package/ts-code/lib-server/middleware/error-handler.ts +79 -0
- package/ts-code/lib-server/pkl-access.ts +46 -0
- package/ts-code/lib-server/resources/dns.ts +151 -0
- package/ts-code/lib-server/resources/mailerid-authorizer.ts +115 -0
- package/ts-code/lib-server/resources/mem-backed-sessions-factory.ts +132 -0
- package/ts-code/lib-server/resources/server-data-folders.ts +160 -0
- package/ts-code/lib-server/resources/server-key-for-pkl-challenge.ts +41 -0
- package/ts-code/lib-server/resources/sessions.ts +232 -0
- package/ts-code/lib-server/resources/user-files.ts +147 -0
- package/ts-code/lib-server/routes/pub-key-login/complete-exchange.ts +63 -0
- package/ts-code/lib-server/routes/pub-key-login/start-exchange.ts +189 -0
- package/ts-code/lib-server/routes/sessions/close.ts +27 -0
- package/ts-code/lib-server/routes/sessions/mid-auth.ts +77 -0
- package/ts-code/lib-server/routes/sessions/start.ts +116 -0
- package/ts-code/lib-server/web-sockets/app.ts +339 -0
- package/ts-code/lib-server/web-sockets/server-events.ts +63 -0
- package/ts-code/lib.ts +29 -0
- package/ts-code/locker/locker-app.ts +60 -0
- package/ts-code/locker/resources/lockers.ts +17 -0
- package/ts-code/locker/resources/sessions.ts +37 -0
- package/ts-code/locker/routes/create-locker.ts +47 -0
- package/ts-code/mailerId/mailerId-app.ts +107 -0
- package/ts-code/mailerId/resources/certifier.ts +181 -0
- package/ts-code/mailerId/resources/sessions.ts +44 -0
- package/ts-code/mailerId/resources/users.ts +88 -0
- package/ts-code/mailerId/routes/certify.ts +68 -0
- package/ts-code/main.ts +304 -0
- package/ts-code/mock/dns.ts +106 -0
- package/ts-code/mock/mock-as-child-proc.ts +130 -0
- package/ts-code/mock/node-child-ipc.ts +69 -0
- package/ts-code/mock/run-in-proc.ts +111 -0
- package/ts-code/mock/tls-options.ts +73 -0
- package/ts-code/services.ts +138 -0
- package/ts-code/signup/resources/users.ts +429 -0
- package/ts-code/signup/routes/add.ts +65 -0
- package/ts-code/signup/routes/get-available-addresses.ts +49 -0
- package/ts-code/signup/routes/get-available-domains.ts +45 -0
- package/ts-code/signup/signup-app.ts +54 -0
- package/ts-code/signup/signup-tokens.ts +148 -0
- package/ts-code/tests/admin-proto/signup.ts +277 -0
- package/ts-code/tests/jasmine.ts +37 -0
- package/ts-code/tests/libs-for-tests/3nstorage.ts +144 -0
- package/ts-code/tests/libs-for-tests/asmail.ts +220 -0
- package/ts-code/tests/libs-for-tests/assert.ts +22 -0
- package/ts-code/tests/libs-for-tests/async-jasmine.ts +89 -0
- package/ts-code/tests/libs-for-tests/bytes-equal.ts +25 -0
- package/ts-code/tests/libs-for-tests/json-copy.ts +38 -0
- package/ts-code/tests/libs-for-tests/json-equal.ts +55 -0
- package/ts-code/tests/libs-for-tests/mailerid.ts +123 -0
- package/ts-code/tests/libs-for-tests/pkl.ts +127 -0
- package/ts-code/tests/libs-for-tests/server-components/3nstorage.ts +206 -0
- package/ts-code/tests/libs-for-tests/server-components/admin.ts +49 -0
- package/ts-code/tests/libs-for-tests/server-components/asmail.ts +152 -0
- package/ts-code/tests/libs-for-tests/server-components/component.ts +90 -0
- package/ts-code/tests/libs-for-tests/server-components/mailerid.ts +114 -0
- package/ts-code/tests/libs-for-tests/server-runner.ts +82 -0
- package/ts-code/tests/libs-for-tests/spec-assembly.ts +60 -0
- package/ts-code/tests/libs-for-tests/ws-utils.ts +61 -0
- package/ts-code/tests/libs-for-tests/xhr-utils.ts +179 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/archive-obj-ver.ts +100 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/archive-root-ver.ts +91 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.ts +99 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.ts +90 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-obj.ts +84 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/events.ts +125 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-obj.ts +298 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-root.ts +290 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-obj-status.ts +88 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-root-status.ts +80 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-obj.ts +366 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-root.ts +329 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel-root.ts +86 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel.ts +86 -0
- package/ts-code/tests/protocols/3nstorage/owner/test-utils.ts +72 -0
- package/ts-code/tests/protocols/3nstorage/owner.ts +198 -0
- package/ts-code/tests/protocols/asmail/config.ts +172 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/finalize-delivery.ts +69 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.ts +88 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/put-metadata.ts +102 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/put-obj.ts +156 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/restart-session.ts +97 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/start-session.ts +79 -0
- package/ts-code/tests/protocols/asmail/delivery/test-utils.ts +64 -0
- package/ts-code/tests/protocols/asmail/delivery.ts +56 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/events.ts +78 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-meta.ts +80 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-obj.ts +197 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/list-messages.ts +110 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/remove-message.ts +74 -0
- package/ts-code/tests/protocols/asmail/retrieval/test-utils.ts +60 -0
- package/ts-code/tests/protocols/asmail/retrieval.ts +115 -0
- package/ts-code/tests/protocols/mailerid.ts +271 -0
- package/ts-code/tests/shared-checks/check-mid-login.ts +164 -0
- package/ts-code/tests/shared-checks/requests.ts +135 -0
- package/ts-code/tsconfig.json +11 -0
- package/ts-code/web3n.d.ts +1068 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const DNS_ERR_CODE = {
|
|
20
|
+
NODATA: 'ENODATA',
|
|
21
|
+
NOTFOUND: 'ENOTFOUND'
|
|
22
|
+
};
|
|
23
|
+
Object.freeze(DNS_ERR_CODE);
|
|
24
|
+
|
|
25
|
+
interface DnsError extends Error {
|
|
26
|
+
code: string;
|
|
27
|
+
hostname: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function makeDnsError(code: string, hostname: string): DnsError {
|
|
31
|
+
const e = <DnsError> new Error(`Mocked DNS error with code ${code}`);
|
|
32
|
+
e.code = code;
|
|
33
|
+
e.hostname = hostname;
|
|
34
|
+
return e;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @param address
|
|
39
|
+
* @return domain string, extracted from a given address
|
|
40
|
+
*/
|
|
41
|
+
function domainOfAddress(address: string): string {
|
|
42
|
+
address = address.trim();
|
|
43
|
+
const indOfAt = address.lastIndexOf('@');
|
|
44
|
+
const domain = ((indOfAt < 0) ? address : address.substring(indOfAt+1));
|
|
45
|
+
return domain;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface DnsTxtRecords {
|
|
49
|
+
[ domain: string ]: string[][];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class DNSMock {
|
|
53
|
+
|
|
54
|
+
resolveTxt: (
|
|
55
|
+
domain: string,
|
|
56
|
+
callback: (err: Error, txt: string[][]) =>void
|
|
57
|
+
) => void;
|
|
58
|
+
|
|
59
|
+
private domains = new Map<string, string[][]>();
|
|
60
|
+
private mailerIdRec: string;
|
|
61
|
+
|
|
62
|
+
constructor(midUrlOrBulkRecs: string | DnsTxtRecords) {
|
|
63
|
+
if (typeof midUrlOrBulkRecs === 'string') {
|
|
64
|
+
if (midUrlOrBulkRecs.indexOf('://') >= 0) {
|
|
65
|
+
this.mailerIdRec = midUrlOrBulkRecs.substring(
|
|
66
|
+
midUrlOrBulkRecs.indexOf('://')+3);
|
|
67
|
+
} else {
|
|
68
|
+
this.mailerIdRec = midUrlOrBulkRecs;
|
|
69
|
+
}
|
|
70
|
+
} else {
|
|
71
|
+
const domains = Object.keys(midUrlOrBulkRecs);
|
|
72
|
+
for (const d of domains) {
|
|
73
|
+
this.domains.set(d, midUrlOrBulkRecs[d]);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
this.resolveTxt = this.mockResolve.bind(this);
|
|
77
|
+
Object.freeze(this);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private mockResolve(
|
|
81
|
+
domain: string,
|
|
82
|
+
callback: (err: any, txt: string[][]) => void
|
|
83
|
+
): void {
|
|
84
|
+
const d = domainOfAddress(domain);
|
|
85
|
+
const txt = this.domains.get(d);
|
|
86
|
+
if (txt) {
|
|
87
|
+
callback(null, txt);
|
|
88
|
+
} else {
|
|
89
|
+
callback(makeDnsError(DNS_ERR_CODE.NOTFOUND, d), null as any);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// TODO at this moment only mailerid record is added.
|
|
94
|
+
// May be this method should take a more detailed options object.
|
|
95
|
+
configureFor(userId: string): void {
|
|
96
|
+
if (!this.mailerIdRec) { throw new Error(
|
|
97
|
+
'DNS mock is not set to configure individial entries'); }
|
|
98
|
+
this.domains.set(domainOfAddress(userId),
|
|
99
|
+
[ [ `mailerid=${this.mailerIdRec}` ] ]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
Object.freeze(DNSMock.prototype);
|
|
104
|
+
Object.freeze(DNSMock);
|
|
105
|
+
|
|
106
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016, 2020 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { commToParent, RequestEnvelope } from './node-child-ipc';
|
|
19
|
+
import { Configurations, servicesApp as makeServicesApp, accountsApp } from '../services';
|
|
20
|
+
import * as dns from 'dns';
|
|
21
|
+
import { DNSMock, DnsTxtRecords } from './dns';
|
|
22
|
+
import { mkdir, rmDirWithContent, writeFile } from '../lib-common/async-fs-node';
|
|
23
|
+
import { FileException } from '../lib-common/exceptions/file';
|
|
24
|
+
import * as https from "https";
|
|
25
|
+
import { sslOpts } from './tls-options';
|
|
26
|
+
import { AppWithWSs } from '../lib-server/web-sockets/app';
|
|
27
|
+
import { join } from 'path';
|
|
28
|
+
import { makeMultiDomainSignupCtx } from '../signup/signup-tokens';
|
|
29
|
+
|
|
30
|
+
const SERVER_MOCK_CHANNEL = 'server-mock';
|
|
31
|
+
|
|
32
|
+
const parent = commToParent(SERVER_MOCK_CHANNEL);
|
|
33
|
+
|
|
34
|
+
const DEFAULT_SERVICE_PORT = 8088;
|
|
35
|
+
const DEFAULT_DATA_FOLDER = join(__dirname, '/../../mock-data');
|
|
36
|
+
|
|
37
|
+
let dnsMock: DNSMock;
|
|
38
|
+
let app: AppWithWSs|undefined;
|
|
39
|
+
|
|
40
|
+
parent.addHandler('set-dns-mock', setDnsMock);
|
|
41
|
+
async function setDnsMock(env: RequestEnvelope<DnsTxtRecords>) {
|
|
42
|
+
dnsMock = new DNSMock(env.req);
|
|
43
|
+
(dns as any).resolveTxt = dnsMock.resolveTxt;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface ServiceUrls {
|
|
47
|
+
mailerId: string;
|
|
48
|
+
asmail: string;
|
|
49
|
+
storage: string;
|
|
50
|
+
signup: string;
|
|
51
|
+
tlsCert: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface MockConfAtStart {
|
|
55
|
+
port?: number;
|
|
56
|
+
dataFolder?: string;
|
|
57
|
+
midServiceDomain: string;
|
|
58
|
+
signupDomains: string[];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function cleanDataFolder(): Promise<void> {
|
|
62
|
+
await rmDirWithContent(DEFAULT_DATA_FOLDER).catch((exc: FileException) => {
|
|
63
|
+
if (!exc.notFound) { throw exc; }
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
parent.addHandler('start', start);
|
|
68
|
+
async function start(
|
|
69
|
+
env: RequestEnvelope<MockConfAtStart>
|
|
70
|
+
): Promise<ServiceUrls> {
|
|
71
|
+
|
|
72
|
+
// get configurations to start services
|
|
73
|
+
const servicePort = (env.req.port ? env.req.port : DEFAULT_SERVICE_PORT);
|
|
74
|
+
const dataFolder = (env.req.dataFolder ?
|
|
75
|
+
env.req.dataFolder : DEFAULT_DATA_FOLDER);
|
|
76
|
+
const noTokensFilePath = join(dataFolder, 'no-tokens-signup.json');
|
|
77
|
+
const conf: Configurations = {
|
|
78
|
+
rootFolder: dataFolder,
|
|
79
|
+
domain: env.req.midServiceDomain,
|
|
80
|
+
signup: {
|
|
81
|
+
noTokenFile: noTokensFilePath
|
|
82
|
+
},
|
|
83
|
+
enabledServices: {
|
|
84
|
+
mailerId: true,
|
|
85
|
+
asmail: true,
|
|
86
|
+
storage: true
|
|
87
|
+
},
|
|
88
|
+
mailerId: {
|
|
89
|
+
certs: join(dataFolder, 'mid-certs.json')
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// prepare data folders
|
|
94
|
+
await cleanDataFolder();
|
|
95
|
+
await mkdir(dataFolder);
|
|
96
|
+
// write to-tokens signup file
|
|
97
|
+
const noTokenCtx = makeMultiDomainSignupCtx(env.req.signupDomains);
|
|
98
|
+
await writeFile(
|
|
99
|
+
noTokensFilePath, JSON.stringify(noTokenCtx), { encoding: 'utf8' }
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// setup app
|
|
103
|
+
app = new AppWithWSs();
|
|
104
|
+
app.use(accountsApp(conf));
|
|
105
|
+
app.use(makeServicesApp(conf));
|
|
106
|
+
|
|
107
|
+
// start app
|
|
108
|
+
await app.start(sslOpts, servicePort);
|
|
109
|
+
|
|
110
|
+
// set client https to trust the cert (MailerId checks need this)
|
|
111
|
+
(<any> https.globalAgent).options.ca = sslOpts.cert;
|
|
112
|
+
|
|
113
|
+
// return services' urls
|
|
114
|
+
const urls: ServiceUrls = {
|
|
115
|
+
mailerId: `${conf.domain}:${servicePort}/mailerid/`,
|
|
116
|
+
asmail: `${conf.domain}:${servicePort}/asmail/`,
|
|
117
|
+
storage: `${conf.domain}:${servicePort}/3nstorage/`,
|
|
118
|
+
signup: `${conf.domain}:${servicePort}/signup/`,
|
|
119
|
+
tlsCert: sslOpts.cert as string
|
|
120
|
+
};
|
|
121
|
+
return urls;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
parent.addHandler('stop', stop);
|
|
125
|
+
async function stop(env: RequestEnvelope<void>): Promise<void> {
|
|
126
|
+
if (!app) { return; }
|
|
127
|
+
await app.stop();
|
|
128
|
+
app = undefined;
|
|
129
|
+
await cleanDataFolder();
|
|
130
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 - 2017 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
import * as cProcs from 'child_process';
|
|
20
|
+
import { RawDuplex, RequestServer, makeRequestServer, RequestingClient, makeRequestingClient, Envelope, Observer, SingleObserverWrap } from '../lib-common/ipc/generic-ipc';
|
|
21
|
+
|
|
22
|
+
export { RequestEnvelope, RequestHandler } from '../lib-common/ipc/generic-ipc';
|
|
23
|
+
|
|
24
|
+
export type IPCToChild = RequestingClient;
|
|
25
|
+
export type IPCToParent = RequestServer;
|
|
26
|
+
|
|
27
|
+
export function commToChild(channel: string, child: cProcs.ChildProcess):
|
|
28
|
+
IPCToChild {
|
|
29
|
+
const observer = new SingleObserverWrap<Envelope>();
|
|
30
|
+
const nodeListener = (env: Envelope) => observer.next(env);
|
|
31
|
+
const rawDuplex: RawDuplex<Envelope> = {
|
|
32
|
+
subscribe(obs: Observer<Envelope>): () => void {
|
|
33
|
+
observer.set(obs);
|
|
34
|
+
child.on('message', nodeListener);
|
|
35
|
+
child.once('disconnet', () => observer.complete());
|
|
36
|
+
return () => {
|
|
37
|
+
observer.detach();
|
|
38
|
+
child.removeListener('message', nodeListener);
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
postMessage(env: any): void {
|
|
42
|
+
child.send(env);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return makeRequestingClient(channel, rawDuplex);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function commToParent(channel: string): IPCToParent {
|
|
49
|
+
const observer = new SingleObserverWrap<Envelope>();
|
|
50
|
+
const nodeListener = (env: Envelope) => {
|
|
51
|
+
if (observer && observer.next) { observer.next(env); }
|
|
52
|
+
};
|
|
53
|
+
const commPoint: RawDuplex<Envelope> = {
|
|
54
|
+
subscribe(obs: Observer<Envelope>): () => void {
|
|
55
|
+
observer.set(obs);
|
|
56
|
+
process.on('message', nodeListener);
|
|
57
|
+
return () => {
|
|
58
|
+
observer.detach();
|
|
59
|
+
process.removeListener('message', nodeListener);
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
postMessage(env: any): void {
|
|
63
|
+
process.send!(env);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
return makeRequestServer(channel, commPoint);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2020, 2023 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import * as https from "https";
|
|
19
|
+
import { sslOpts } from './tls-options';
|
|
20
|
+
import { AppWithWSs } from '../lib-server/web-sockets/app';
|
|
21
|
+
import { mkdir, writeFile } from '../lib-common/async-fs-node';
|
|
22
|
+
import { FileException } from '../lib-common/exceptions/file';
|
|
23
|
+
import { accountsApp, Configurations, servicesApp } from '../services';
|
|
24
|
+
import * as dns from 'dns';
|
|
25
|
+
import { DNSMock, DnsTxtRecords } from './dns';
|
|
26
|
+
import { join } from 'path';
|
|
27
|
+
import { makeMultiDomainSignupCtx } from "../signup/signup-tokens";
|
|
28
|
+
|
|
29
|
+
export function setTestCertsAndDNS(
|
|
30
|
+
domains: string[], thisSrvLoc: string
|
|
31
|
+
): DNSMock {
|
|
32
|
+
if (thisSrvLoc.endsWith('/')) { throw new Error(
|
|
33
|
+
`Location value shouldn't have trailing slash`); }
|
|
34
|
+
|
|
35
|
+
// allow client test calls to trust above self-signed cert
|
|
36
|
+
https.globalAgent.options.ca = sslOpts.cert;
|
|
37
|
+
|
|
38
|
+
// inject dns mock
|
|
39
|
+
const dnsRecs: DnsTxtRecords = {};
|
|
40
|
+
for (const domain of domains) {
|
|
41
|
+
dnsRecs[domain] = [
|
|
42
|
+
[ 'asmail', '=', `${thisSrvLoc}/asmail` ], // one record in DNS TXT
|
|
43
|
+
[
|
|
44
|
+
'mailerid=', `${thisSrvLoc}/mailerid`,
|
|
45
|
+
`3nstorage=${thisSrvLoc}/3nstorage`
|
|
46
|
+
] // two 3NWeb records in one DNS TXT record
|
|
47
|
+
// XXX add other life-like records
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
const dnsMock = new DNSMock(dnsRecs);
|
|
51
|
+
(dns as any).resolveTxt = dnsMock.resolveTxt;
|
|
52
|
+
|
|
53
|
+
return dnsMock;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function startOn(
|
|
57
|
+
srvDomain: string, dataDir: string, port: number,
|
|
58
|
+
domains: { noTokenSignup: string[]; other: string[]; }
|
|
59
|
+
): Promise<{ stop: () => Promise<void>; dnsMock: DNSMock; }> {
|
|
60
|
+
|
|
61
|
+
const noTokensFilePath = join(dataDir, 'no-tokens-signup.json');
|
|
62
|
+
const conf: Configurations = {
|
|
63
|
+
rootFolder: dataDir,
|
|
64
|
+
domain: srvDomain,
|
|
65
|
+
enabledServices: {
|
|
66
|
+
asmail: true,
|
|
67
|
+
mailerId: true,
|
|
68
|
+
storage: true
|
|
69
|
+
},
|
|
70
|
+
signup: {
|
|
71
|
+
noTokenFile: noTokensFilePath
|
|
72
|
+
},
|
|
73
|
+
mailerId: {
|
|
74
|
+
certs: join(dataDir, 'mid-certs.json')
|
|
75
|
+
},
|
|
76
|
+
servicesConnect: {
|
|
77
|
+
port,
|
|
78
|
+
sslOpts
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// prepare data folders
|
|
83
|
+
await mkdir(dataDir)
|
|
84
|
+
.catch((exc: FileException) => {
|
|
85
|
+
if (!exc.alreadyExists) { throw exc; }
|
|
86
|
+
});
|
|
87
|
+
// write to-tokens signup file
|
|
88
|
+
const noTokenCtx = makeMultiDomainSignupCtx(domains.noTokenSignup);
|
|
89
|
+
await writeFile(
|
|
90
|
+
noTokensFilePath, JSON.stringify(noTokenCtx), { encoding: 'utf8' }
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// certs and DNS
|
|
94
|
+
const allDomains = domains.noTokenSignup.concat(domains.other);
|
|
95
|
+
const dnsMock = setTestCertsAndDNS(allDomains, `${srvDomain}:${port}`);
|
|
96
|
+
|
|
97
|
+
// setup services and start
|
|
98
|
+
const app = new AppWithWSs();
|
|
99
|
+
app.use(accountsApp(conf));
|
|
100
|
+
app.use(servicesApp(conf));
|
|
101
|
+
await app.start(conf.servicesConnect!.sslOpts, conf.servicesConnect!.port);
|
|
102
|
+
|
|
103
|
+
return { dnsMock, stop: () => app.stop() };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function startOnLocalhost(
|
|
107
|
+
dataDir: string, port: number,
|
|
108
|
+
domains: { noTokenSignup: string[]; other: string[]; }
|
|
109
|
+
): Promise<{ stop: () => Promise<void>; dnsMock: DNSMock; }> {
|
|
110
|
+
return startOn('localhost', dataDir, port, domains);
|
|
111
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { ServerOptions } from "https";
|
|
19
|
+
|
|
20
|
+
export const sslOpts: ServerOptions = {
|
|
21
|
+
key: `-----BEGIN PRIVATE KEY-----
|
|
22
|
+
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCggRGeSSbXoPby
|
|
23
|
+
CI943Lg80+0XFoJxbinkH+SEbNZ3IpuSQyaoaWTIGqjXH2tIO7D7Htr7XVsqIsQW
|
|
24
|
+
33K9ZxAGwowuDXduRD/TM2Fnt7OHKbQIOJehD6JZg/pg7IwJvUPRoLHfT7f3Obs9
|
|
25
|
+
i63CQhITxXimDR1MCw/+mwXJabTTibpsdIT74N+V193SRDKS/qcmLld+lLhpR7ya
|
|
26
|
+
8alY0Hdgpy/8ahmTVdCazQJ69HuOi32mCZevIK/VuWO4bIBAJ9Q0CuL8g3G1/v/F
|
|
27
|
+
7KRW7893HolkBxbNhQ/sSBfA06jR3JYww/MzUCHTLQ2Si9LuBQDekzcMX2FTthde
|
|
28
|
+
heO54yL/AgMBAAECggEAHOB72f2RRnRIWa1emsEjSJZcbq33FA9c7BUs2QJ354FL
|
|
29
|
+
ehoox14G6tWZEPMvKxTKN7QKc/UM5NzSaMcU7qyvPngcHmD/3s/ap9XzrWRooWXI
|
|
30
|
+
ZT5BUZHthKtxDaUhYNMzc3C079d44rr5TA5oWa3ncLUzirSLU9Ydr5IWjXE+Plyd
|
|
31
|
+
RDgA/JmUOSdZAViXXckujIKoyz0viMRaWT58qIWCItUJouI/CGQiBbC3yyNa36s/
|
|
32
|
+
gQQJnJY6PuCDnh3gAm4Qi5IyxWWiYFUodPZhhrGX8uvDg/GJvvRv0GkcaPaZKxJ4
|
|
33
|
+
2Ir9Ex2YdAIB7MsD2x9XgNyEy9LCmpcRDlqqo/mo0QKBgQDLAIuu3R0YOs7B3/gb
|
|
34
|
+
+WF/4j6WSJ9XvyHh50qifEaX7wi2pUhhT2TLrKdIkqiB7Hrc9rrNDRQTnmIGDZQR
|
|
35
|
+
NJ/YV6USOkYfGTog71Oh/TRacIqXE4ql+DNHOMmIO+e0dE0CvjkCUI36wFxgnzBc
|
|
36
|
+
9SjqKdylM67zfiDppy9DAHTyxwKBgQDKaDZzUeIMYdcw55orQt1Y0VEwcNy34XMO
|
|
37
|
+
y91Dobfztwbf0fpQtaQQl9mS1HMDGUevKR592QEmc2wRYZoY7kMz0b4yCPHsdepk
|
|
38
|
+
eEPNgM9wf6ApHto9trlaTTaXSlJ+t9hPqfQ6a5deYZiYp5tzwSpd3yibFo4HXsjh
|
|
39
|
+
m7o37kqWCQKBgQCLF0yd+5K7z09rN3JgeHZ9kR8hCZFkJempRzi0LEKSR43I12bI
|
|
40
|
+
hgWiKCJWb2ZV3xov3D4R0Sw4ZQT08MjLISuEqEjKPHNfS4Gwn0rGax87+HB9Iz6U
|
|
41
|
+
iYNZAWfUmHciBa3ee0fEdj1R2gtxiKEykCgAib5M0yTEYV9buNmBJwb6cQKBgQDJ
|
|
42
|
+
Ueg+wYYF7NceBG6acvI4YlHPzaIrnylS4UDeAR83YKeMvYys9E4QVwkIexk+Tsm3
|
|
43
|
+
Fj4GzG3RceJeU2bzPyFGjGsR10XRfOM7NUezQliRu89wtwg5c+JeSAhxaHIvKesU
|
|
44
|
+
KaYK6XLwZEBkLel3s/zQy6LWxxNTj1pc1AjfkrtLCQKBgQCKW6+tzHMeqksOIuiP
|
|
45
|
+
VOZq0qEpJVutcEt01q1ii0fcq//LlnkWuZnSglc9TpWuUlBuqDSBOsQLMmGPV7mc
|
|
46
|
+
dOov2W7xEXGiQaRSnI4st11y7WDwQRQcy89fGMrmunrblRBbLEbel+bnJAuJLcm5
|
|
47
|
+
WzcbPdutJ6h5LEcAWw/M/T8d0A==
|
|
48
|
+
-----END PRIVATE KEY-----`,
|
|
49
|
+
cert: `-----BEGIN CERTIFICATE-----
|
|
50
|
+
MIIDkzCCAnugAwIBAgIUW1eK6qpqDdf8KNVKEQNWToGnYxUwDQYJKoZIhvcNAQEL
|
|
51
|
+
BQAwWTELMAkGA1UEBhMCQ0ExEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
|
|
52
|
+
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDESMBAGA1UEAwwJbG9jYWxob3N0MB4X
|
|
53
|
+
DTI2MDYxMDAxMzUzMloXDTM2MDYwNzAxMzUzMlowWTELMAkGA1UEBhMCQ0ExEzAR
|
|
54
|
+
BgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5
|
|
55
|
+
IEx0ZDESMBAGA1UEAwwJbG9jYWxob3N0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
|
|
56
|
+
MIIBCgKCAQEAoIERnkkm16D28giPeNy4PNPtFxaCcW4p5B/khGzWdyKbkkMmqGlk
|
|
57
|
+
yBqo1x9rSDuw+x7a+11bKiLEFt9yvWcQBsKMLg13bkQ/0zNhZ7ezhym0CDiXoQ+i
|
|
58
|
+
WYP6YOyMCb1D0aCx30+39zm7PYutwkISE8V4pg0dTAsP/psFyWm004m6bHSE++Df
|
|
59
|
+
ldfd0kQykv6nJi5XfpS4aUe8mvGpWNB3YKcv/GoZk1XQms0CevR7jot9pgmXryCv
|
|
60
|
+
1bljuGyAQCfUNAri/INxtf7/xeykVu/Pdx6JZAcWzYUP7EgXwNOo0dyWMMPzM1Ah
|
|
61
|
+
0y0NkovS7gUA3pM3DF9hU7YXXoXjueMi/wIDAQABo1MwUTAdBgNVHQ4EFgQUK9jG
|
|
62
|
+
K/xw9TJGdYq6u8hYdjqcPvowHwYDVR0jBBgwFoAUK9jGK/xw9TJGdYq6u8hYdjqc
|
|
63
|
+
PvowDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEALe20I+WMlcMW
|
|
64
|
+
GBoryo2OXvJ5Uu4AiImP5RbhgpDXry9FXiARwR/kx/oAY5o1flJ3jY3yO8fETDcD
|
|
65
|
+
G6F6Tf/PKPlMDrWoFv7Vz/s4GjAyPFWPQJe3EiSjarah7x+hbRNPo7Xf+aCYI/p1
|
|
66
|
+
MLsCVUreTeqA8qno2qbdtwUM3FcTEL/mdkA/d2/H0HIHwGV0A2hpyG8d+RpP2na+
|
|
67
|
+
uwDNifryUwZd8bW2n3UoRtsralEW657sReywAa6iunk8220vjRq8LlceJh3952ov
|
|
68
|
+
EEuI+hxj/ikVBSjQX8aFhX8kx4p4q/mKCOA5q3DCbmrr3Cn8fl0zRZZegrk9kfpV
|
|
69
|
+
QGCnHRJ0yQ==
|
|
70
|
+
-----END CERTIFICATE-----`
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2015 - 2017, 2020, 2024 - 2025 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
* This puts together two express servers: one serves 3NWeb services, another
|
|
20
|
+
* one is an administration interface.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import * as https from "https";
|
|
24
|
+
import { validator } from './lib-server/resources/mailerid-authorizer';
|
|
25
|
+
import { AppWithWSs } from './lib-server/web-sockets/app';
|
|
26
|
+
import { makeMailerIdApp } from './mailerId/mailerId-app';
|
|
27
|
+
import { makeASMailApp } from './asmail/asmail-app';
|
|
28
|
+
import { makeStorageApp } from './3nstorage/3nstorage-app';
|
|
29
|
+
import { makeSignupApp } from './signup/signup-app';
|
|
30
|
+
import { ErrLogger, makeErrLoggerToConsole } from "./lib-server/middleware/error-handler";
|
|
31
|
+
import { makeLockerApp } from "./locker/locker-app";
|
|
32
|
+
import { MidAuthorizer } from "./lib-server/routes/sessions/mid-auth";
|
|
33
|
+
|
|
34
|
+
export interface Configurations {
|
|
35
|
+
enabledServices: {
|
|
36
|
+
asmail?: boolean;
|
|
37
|
+
storage?: boolean;
|
|
38
|
+
mailerId?: boolean;
|
|
39
|
+
};
|
|
40
|
+
auxiliaryServices?: {
|
|
41
|
+
locker?: boolean;
|
|
42
|
+
};
|
|
43
|
+
servicesConnect?: {
|
|
44
|
+
hostname?: string;
|
|
45
|
+
port: number;
|
|
46
|
+
sslOpts?: https.ServerOptions;
|
|
47
|
+
letsencrypt?: string;
|
|
48
|
+
skipReloadOnCertsChange?: boolean;
|
|
49
|
+
};
|
|
50
|
+
rootFolder: string;
|
|
51
|
+
domain: string;
|
|
52
|
+
mailerId?: {
|
|
53
|
+
certs: string;
|
|
54
|
+
};
|
|
55
|
+
signup?: {
|
|
56
|
+
noTokenFile?: string;
|
|
57
|
+
serviceUrl?: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function servicesApp(
|
|
62
|
+
conf: Configurations, errLogger?: ErrLogger|'console', logSetup?: 'console'
|
|
63
|
+
): AppWithWSs {
|
|
64
|
+
|
|
65
|
+
if (!conf.enabledServices || (typeof conf.enabledServices !== 'object')) {
|
|
66
|
+
throw new Error('Missing enabled-services sections in confs.');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const app = new AppWithWSs();
|
|
70
|
+
let midAuthorizer: MidAuthorizer; // share, allowing for caching of certs
|
|
71
|
+
|
|
72
|
+
if (conf.enabledServices.mailerId) {
|
|
73
|
+
const { app: midApp, ownService } = makeMailerIdApp(
|
|
74
|
+
conf.rootFolder, conf.domain, conf.mailerId!.certs,
|
|
75
|
+
(errLogger === 'console') ? makeErrLoggerToConsole('MailerId') : errLogger
|
|
76
|
+
);
|
|
77
|
+
app.http.use('/mailerid', midApp);
|
|
78
|
+
if (logSetup === 'console') {
|
|
79
|
+
console.log(`Enabled MailerId service with provider domain ${conf.domain}`);
|
|
80
|
+
}
|
|
81
|
+
midAuthorizer = validator(ownService);
|
|
82
|
+
} else {
|
|
83
|
+
midAuthorizer = validator(undefined);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (conf.enabledServices.asmail) {
|
|
87
|
+
app.use('/asmail', makeASMailApp(
|
|
88
|
+
conf.rootFolder, conf.domain, midAuthorizer,
|
|
89
|
+
(errLogger === 'console') ? makeErrLoggerToConsole('ASMail') : errLogger
|
|
90
|
+
));
|
|
91
|
+
if (logSetup === 'console') {
|
|
92
|
+
console.log(`Enabled ASMail service with provider domain ${conf.domain}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (conf.enabledServices.storage) {
|
|
97
|
+
app.use('/3nstorage', makeStorageApp(
|
|
98
|
+
conf.rootFolder, conf.domain, midAuthorizer,
|
|
99
|
+
(errLogger === 'console') ? makeErrLoggerToConsole('3NStorage') : errLogger
|
|
100
|
+
));
|
|
101
|
+
if (logSetup === 'console') {
|
|
102
|
+
console.log(`Enabled 3NStorage service with provider domain ${conf.domain}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (conf.auxiliaryServices?.locker) {
|
|
107
|
+
app.use('/locker', makeLockerApp(
|
|
108
|
+
conf.rootFolder,
|
|
109
|
+
(errLogger === 'console') ? makeErrLoggerToConsole('Locker') : errLogger
|
|
110
|
+
));
|
|
111
|
+
if (logSetup === 'console') {
|
|
112
|
+
console.log(`Enabled Locker service`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return app;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export function accountsApp(
|
|
120
|
+
conf: Configurations, errLogger?: ErrLogger|'console', logSetup?: 'console'
|
|
121
|
+
): AppWithWSs {
|
|
122
|
+
|
|
123
|
+
const app = new AppWithWSs();
|
|
124
|
+
|
|
125
|
+
if (conf.signup) {
|
|
126
|
+
app.http.use('/signup', makeSignupApp(
|
|
127
|
+
conf,
|
|
128
|
+
(errLogger === 'console') ? makeErrLoggerToConsole('Signup') : errLogger
|
|
129
|
+
));
|
|
130
|
+
if (logSetup === 'console') {
|
|
131
|
+
console.log(`Enabled signup service.`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return app;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
Object.freeze(exports);
|