spec-3nweb-server 1.8.5 → 1.8.7
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/3nstorage/resources/store.d.ts +2 -2
- package/build/3nstorage/resources/store.js +1 -1
- package/build/3nstorage/resources/users.d.ts +3 -3
- package/build/3nstorage/resources/users.js +1 -1
- package/build/3nstorage/resources/utils.d.ts +6 -0
- package/build/3nstorage/resources/utils.js +41 -0
- package/build/3nstorage/routes/owner/archive-obj-version.js +8 -10
- package/build/3nstorage/routes/owner/cancel-trans.js +5 -4
- package/build/3nstorage/routes/owner/delete-obj.js +7 -8
- package/build/3nstorage/routes/owner/get-archived-obj-ver.js +11 -13
- package/build/3nstorage/routes/owner/get-current-obj.js +7 -6
- package/build/3nstorage/routes/owner/get-obj-status.js +8 -8
- package/build/3nstorage/routes/owner/put-current-obj.js +25 -55
- package/build/3nstorage/routes/owner/session-params.js +2 -0
- package/build/asmail/resources/utils.d.ts +6 -0
- package/build/asmail/resources/utils.js +36 -0
- package/build/asmail/routes/delivery/finalize-delivery.js +3 -2
- package/build/asmail/routes/delivery/pre-flight.js +9 -26
- package/build/asmail/routes/delivery/provide-recipient-pubkey.js +4 -3
- package/build/asmail/routes/delivery/put-metadata.js +13 -21
- package/build/asmail/routes/delivery/put-obj.js +19 -25
- package/build/asmail/routes/delivery/restart-session.d.ts +4 -8
- package/build/asmail/routes/delivery/restart-session.js +10 -23
- package/build/asmail/routes/delivery/sender-authorization.js +5 -5
- package/build/asmail/routes/delivery/start-session.js +9 -24
- package/build/asmail/routes/retrieval/get-message-meta.js +4 -7
- package/build/asmail/routes/retrieval/get-message-obj.js +10 -7
- package/build/asmail/routes/retrieval/list-messages.js +4 -4
- package/build/asmail/routes/retrieval/remove-message.js +3 -2
- 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/resources/utils.ts +45 -0
- package/ts-code/3nstorage/routes/owner/archive-obj-version.ts +71 -0
- package/ts-code/3nstorage/routes/owner/cancel-trans.ts +60 -0
- package/ts-code/3nstorage/routes/owner/delete-obj.ts +99 -0
- package/ts-code/3nstorage/routes/owner/get-archived-obj-ver.ts +109 -0
- package/ts-code/3nstorage/routes/owner/get-current-obj.ts +124 -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 +257 -0
- package/ts-code/3nstorage/routes/owner/session-params.ts +50 -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/resources/utils.ts +41 -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 +51 -0
- package/ts-code/asmail/routes/delivery/pre-flight.ts +118 -0
- package/ts-code/asmail/routes/delivery/provide-recipient-pubkey.ts +58 -0
- package/ts-code/asmail/routes/delivery/put-metadata.ts +85 -0
- package/ts-code/asmail/routes/delivery/put-obj.ts +152 -0
- package/ts-code/asmail/routes/delivery/restart-session.ts +117 -0
- package/ts-code/asmail/routes/delivery/sender-authorization.ts +81 -0
- package/ts-code/asmail/routes/delivery/start-session.ts +136 -0
- package/ts-code/asmail/routes/retrieval/get-message-meta.ts +50 -0
- package/ts-code/asmail/routes/retrieval/get-message-obj.ts +106 -0
- package/ts-code/asmail/routes/retrieval/list-messages.ts +68 -0
- package/ts-code/asmail/routes/retrieval/remove-message.ts +48 -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,78 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 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
|
+
import { CommandDef } from "./utils";
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export const showSampleConfigCmd: CommandDef<'show-sample-config'> = {
|
|
22
|
+
name: 'show-sample-config',
|
|
23
|
+
summary: 'prints out a template configuration yaml file with comments'
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const sampleConfig = `
|
|
27
|
+
# This is a sample configuration yaml file.
|
|
28
|
+
# Uncomment and set required values.
|
|
29
|
+
# Default path of this file is /etc/3nweb/conf.yaml
|
|
30
|
+
|
|
31
|
+
# Uncomment to enable service
|
|
32
|
+
enabledServices:
|
|
33
|
+
# asmail: true
|
|
34
|
+
# storage: true
|
|
35
|
+
# mailerId: true
|
|
36
|
+
|
|
37
|
+
# Data root folder. Set non-default value, if required.
|
|
38
|
+
# rootFolder: /var/3nweb
|
|
39
|
+
|
|
40
|
+
# Customize domain at which clients reach this server from an outside.
|
|
41
|
+
# This value is used by users' MailerId-based login: assertion challenges
|
|
42
|
+
# cryptographically imprint this domain to assure client that there is no
|
|
43
|
+
# missuse.
|
|
44
|
+
domain: service-for.example.com
|
|
45
|
+
|
|
46
|
+
# If MailerId provider service is enabled, this is its configuration
|
|
47
|
+
mailerId:
|
|
48
|
+
certs: /etc/3nweb/mailerid/certs
|
|
49
|
+
|
|
50
|
+
# Customize servicesConnect before starting this server.
|
|
51
|
+
servicesConnect:
|
|
52
|
+
|
|
53
|
+
port: 7070
|
|
54
|
+
# Hostname allows to restrict on which address service is listening for incoming connections
|
|
55
|
+
# hostname: "1.2.3.4"
|
|
56
|
+
|
|
57
|
+
# Uncomment path to Let's Encrypt folder, if it is used. This implicitly tells
|
|
58
|
+
# server to HTTPS with given certificates.
|
|
59
|
+
# letsencrypt: /etc/letsencrypt/live/service-for.example.com
|
|
60
|
+
|
|
61
|
+
# By default HTTPS service reloads when certificates change. Skip, if required.
|
|
62
|
+
# skipReloadOnCertsChange: false
|
|
63
|
+
|
|
64
|
+
# Set TLS cert and key to do HTTPS. Use either this, or letsencrypt, but not both.
|
|
65
|
+
# sslOpts: {
|
|
66
|
+
# It is Node's https.ServerOptions. Follow https://nodejs.org/docs/latest/api/https.html
|
|
67
|
+
# }
|
|
68
|
+
|
|
69
|
+
# Configuration for signup service that creates new accounts on this server.
|
|
70
|
+
# Comment out to disable signup service completely.
|
|
71
|
+
# Note that signup cli commands should be used to create token, without which
|
|
72
|
+
# signup doesn't happen, unless a no-token configuration file is provided.
|
|
73
|
+
signup: {
|
|
74
|
+
# noTokenFile: /some/path/to/json
|
|
75
|
+
}
|
|
76
|
+
`;
|
|
77
|
+
|
|
78
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 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 { CliUsageDisplay, CommandDef, HelpArg, OptionDef, UsageSection, helpOpt, parseArgv, toErrorUsage, toUsageDisplay } from "./utils";
|
|
19
|
+
|
|
20
|
+
export const signupCmd: CommandDef<'signup'> = {
|
|
21
|
+
name: 'signup',
|
|
22
|
+
summary: 'controls adding new users to this instance'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function signupUsage(execName: string): UsageSection[] {
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
content: `This command controls parameters of adding new users to this instance.`
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
header: 'Usage:',
|
|
32
|
+
content: `${execName} ${signupCmd.name} [command] [options] [config_file]`
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
header: 'Available commands:',
|
|
36
|
+
content: [
|
|
37
|
+
infoCmd,
|
|
38
|
+
listTokensCmd,
|
|
39
|
+
showTokenCmd,
|
|
40
|
+
createTokenCmd
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
header: `${infoCmd.name} options:`,
|
|
45
|
+
optionList: infoOpts
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
header: `${listTokensCmd.name} options:`,
|
|
49
|
+
optionList: listTokensOpts
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
header: `${showTokenCmd.name} options:`,
|
|
53
|
+
optionList: showTokenOpts
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
header: `${createTokenCmd.name} options:`,
|
|
57
|
+
optionList: createTokenOpts
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const configOpt: OptionDef = {
|
|
63
|
+
name: 'config',
|
|
64
|
+
alias: 'c',
|
|
65
|
+
type: String,
|
|
66
|
+
typeLabel: '{underline <file>}',
|
|
67
|
+
description: `path of a configuration yaml file`
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const infoCmd: CommandDef<'info'> = {
|
|
71
|
+
name: 'info',
|
|
72
|
+
summary: 'shows state of signup subsystem'
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const infoOpts: OptionDef[] = [
|
|
76
|
+
configOpt
|
|
77
|
+
];
|
|
78
|
+
|
|
79
|
+
const listTokensCmd: CommandDef<'list-tokens'> = {
|
|
80
|
+
name: 'list-tokens',
|
|
81
|
+
summary: 'lists signup tokens'
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const listTokensOpts: OptionDef[] = [
|
|
85
|
+
configOpt
|
|
86
|
+
];
|
|
87
|
+
|
|
88
|
+
const showTokenCmd: CommandDef<'show-token'> = {
|
|
89
|
+
name: 'show-token',
|
|
90
|
+
summary: 'shows signup token with complete value'
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const showTokenOpts: OptionDef[] = [
|
|
94
|
+
configOpt,
|
|
95
|
+
{
|
|
96
|
+
name: 'token',
|
|
97
|
+
alias: 't',
|
|
98
|
+
type: String,
|
|
99
|
+
typeLabel: '{underline <token_id>}',
|
|
100
|
+
description: `token id`
|
|
101
|
+
}
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
const createTokenCmd: CommandDef<'create-token'> = {
|
|
105
|
+
name: 'create-token',
|
|
106
|
+
summary: 'creates signup token for single user, when user id is given, and for many users, when domain(s) are given'
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const createTokenOpts: OptionDef[] = [
|
|
110
|
+
configOpt,
|
|
111
|
+
{
|
|
112
|
+
name: 'domain',
|
|
113
|
+
alias: 'd',
|
|
114
|
+
type: String,
|
|
115
|
+
typeLabel: '{underline <domain>}',
|
|
116
|
+
multiple: true,
|
|
117
|
+
description: `domain for new users. Several domain options will attach all domains to same token.`
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
name: 'user',
|
|
121
|
+
alias: 'u',
|
|
122
|
+
type: String,
|
|
123
|
+
typeLabel: '{underline <user_address>}',
|
|
124
|
+
description: `address of a single user`
|
|
125
|
+
}
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
export interface ParsedSignupArgs {
|
|
129
|
+
info?: boolean;
|
|
130
|
+
config?: string;
|
|
131
|
+
help?: boolean;
|
|
132
|
+
listTokens?: boolean;
|
|
133
|
+
showToken?: boolean;
|
|
134
|
+
token?: string;
|
|
135
|
+
createToken?: boolean;
|
|
136
|
+
domain?: string[];
|
|
137
|
+
user?: string;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function parseWithConfFile(
|
|
141
|
+
args: string[], optList: OptionDef[]
|
|
142
|
+
): ParsedSignupArgs|undefined {
|
|
143
|
+
const opts = parseArgv<ParsedSignupArgs>(args, optList, { partial: true });
|
|
144
|
+
if (opts.config) {
|
|
145
|
+
return opts;
|
|
146
|
+
} else if (opts._unknown) {
|
|
147
|
+
opts.config = opts._unknown[0];
|
|
148
|
+
return opts;
|
|
149
|
+
} else {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function cmdUsageErr(
|
|
155
|
+
execName: string, cmd: string, errTxt = `missing configuration file`
|
|
156
|
+
): {
|
|
157
|
+
showUsage: CliUsageDisplay;
|
|
158
|
+
} {
|
|
159
|
+
return toUsageDisplay(-1, toErrorUsage(
|
|
160
|
+
signupUsage(execName),
|
|
161
|
+
`Incorrect options for command '${signupCmd.name} ${cmd}': ${errTxt}`
|
|
162
|
+
));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function parseSignupArgs(
|
|
166
|
+
args: string[], execName: string
|
|
167
|
+
): {
|
|
168
|
+
signupCmd?: ParsedSignupArgs;
|
|
169
|
+
showUsage?: CliUsageDisplay;
|
|
170
|
+
} {
|
|
171
|
+
if (args.length === 0) {
|
|
172
|
+
return toUsageDisplay(0, signupUsage(execName));
|
|
173
|
+
}
|
|
174
|
+
if (args[0] === infoCmd.name) {
|
|
175
|
+
const signupCmd = parseWithConfFile(args.slice(1), infoOpts);
|
|
176
|
+
if (signupCmd) {
|
|
177
|
+
signupCmd.info = true;
|
|
178
|
+
return { signupCmd };
|
|
179
|
+
} else {
|
|
180
|
+
return cmdUsageErr(execName, infoCmd.name);
|
|
181
|
+
}
|
|
182
|
+
} else if (args[0] === listTokensCmd.name) {
|
|
183
|
+
const signupCmd = parseWithConfFile(args.slice(1), listTokensOpts);
|
|
184
|
+
if (signupCmd) {
|
|
185
|
+
signupCmd.listTokens = true;
|
|
186
|
+
return { signupCmd };
|
|
187
|
+
} else {
|
|
188
|
+
return cmdUsageErr(execName, listTokensCmd.name);
|
|
189
|
+
}
|
|
190
|
+
} else if (args[0] === showTokenCmd.name) {
|
|
191
|
+
const signupCmd = parseWithConfFile(args.slice(1), showTokenOpts);
|
|
192
|
+
if (signupCmd) {
|
|
193
|
+
if (!signupCmd.token) {
|
|
194
|
+
return cmdUsageErr(
|
|
195
|
+
execName, showTokenCmd.name, `missing token`
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
signupCmd.showToken = true;
|
|
199
|
+
return { signupCmd };
|
|
200
|
+
} else {
|
|
201
|
+
return cmdUsageErr(execName, showTokenCmd.name);
|
|
202
|
+
}
|
|
203
|
+
} else if (args[0] === createTokenCmd.name) {
|
|
204
|
+
const signupCmd = parseWithConfFile(args.slice(1), createTokenOpts);
|
|
205
|
+
if (signupCmd) {
|
|
206
|
+
if (!signupCmd.domain && !signupCmd.user) {
|
|
207
|
+
return cmdUsageErr(
|
|
208
|
+
execName, createTokenCmd.name, `either user address, or domain(s) should be given`
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
signupCmd.createToken = true;
|
|
212
|
+
return { signupCmd };
|
|
213
|
+
} else {
|
|
214
|
+
return cmdUsageErr(execName, createTokenCmd.name);
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
const opts = parseArgv<HelpArg>(args, [ helpOpt ], { partial: true });
|
|
218
|
+
if (opts.help) {
|
|
219
|
+
return toUsageDisplay(0, signupUsage(execName));
|
|
220
|
+
}
|
|
221
|
+
return toUsageDisplay(-1, toErrorUsage(
|
|
222
|
+
signupUsage(execName),
|
|
223
|
+
`Unknown command '${args[0]}'`
|
|
224
|
+
));
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 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 { CliUsageDisplay, CommandDef, UsageSection, toUsageDisplay } from "./utils";
|
|
19
|
+
|
|
20
|
+
export const userCmd: CommandDef<'user'> = {
|
|
21
|
+
name: 'user',
|
|
22
|
+
summary: 'provides information about existing users'
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const listCmd: CommandDef<'list'> = {
|
|
26
|
+
name: 'list',
|
|
27
|
+
summary: `lists users`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface ParsedUserArgs {
|
|
31
|
+
listAll?: true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function userUsage(execName: string): UsageSection[] {
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
header: execName,
|
|
38
|
+
content: `Server of all 3NWeb utilities: MailerId, ASMail, 3NStorage.`
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
header: `Usage:`,
|
|
42
|
+
content: `${execName} user [command]`
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
header: 'Available commands:',
|
|
46
|
+
content: []
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
content: `Use "${execName} user [command] --help" for more information about a command.`
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function parseSignupArgs(
|
|
55
|
+
args: string[], execName: string
|
|
56
|
+
): {
|
|
57
|
+
userCmd?: ParsedUserArgs;
|
|
58
|
+
showUsage?: CliUsageDisplay;
|
|
59
|
+
} {
|
|
60
|
+
if (args.length === 0) {
|
|
61
|
+
return toUsageDisplay(0, userUsage(execName));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// XXX
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
return {};
|
|
68
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 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 commandLineArgs from "command-line-args";
|
|
19
|
+
import * as commandLineUsage from "command-line-usage";
|
|
20
|
+
|
|
21
|
+
export interface CommandDef<T extends string> {
|
|
22
|
+
name: T;
|
|
23
|
+
summary: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface OptionDef {
|
|
27
|
+
name: string;
|
|
28
|
+
type: (typeof Boolean) | (typeof String) | (typeof Number) |
|
|
29
|
+
((value: string) => any);
|
|
30
|
+
alias?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
typeLabel?: string;
|
|
33
|
+
multiple?: boolean;
|
|
34
|
+
defaultOption?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface UsageSection {
|
|
38
|
+
header?: string;
|
|
39
|
+
summary?: string;
|
|
40
|
+
optionList?: OptionDef[];
|
|
41
|
+
content?: string | UsageSectionContent | (string | UsageSection)[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface UsageSectionContent {
|
|
45
|
+
options: any;
|
|
46
|
+
data: any
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ParseOptions {
|
|
50
|
+
argv?: string[];
|
|
51
|
+
partial?: boolean;
|
|
52
|
+
stopAtFirstUnknown?: boolean;
|
|
53
|
+
camelCase?: boolean;
|
|
54
|
+
caseInsensitive?: boolean;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface CliUsageDisplay {
|
|
58
|
+
txtToDisplay: string;
|
|
59
|
+
exitStatus: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export const helpOpt: OptionDef = {
|
|
63
|
+
name: 'help',
|
|
64
|
+
alias: 'h',
|
|
65
|
+
type: Boolean,
|
|
66
|
+
description: 'shows help'
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export interface HelpArg {
|
|
70
|
+
help?: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function toUsageDisplay(
|
|
74
|
+
exitStatus: number, usage: UsageSection[]
|
|
75
|
+
): {
|
|
76
|
+
showUsage: CliUsageDisplay;
|
|
77
|
+
} {
|
|
78
|
+
return {
|
|
79
|
+
showUsage: {
|
|
80
|
+
txtToDisplay: commandLineUsage(usage),
|
|
81
|
+
exitStatus
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function parseArgv<T>(
|
|
87
|
+
argv: string[], argOpts: OptionDef[], opts?: ParseOptions
|
|
88
|
+
): T & { _unknown?: string[]; } {
|
|
89
|
+
if (opts) {
|
|
90
|
+
opts.argv = argv;
|
|
91
|
+
} else {
|
|
92
|
+
opts = { argv };
|
|
93
|
+
}
|
|
94
|
+
return commandLineArgs(argOpts, opts);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function toErrorUsage(
|
|
98
|
+
usage: UsageSection[], errTxt: string
|
|
99
|
+
): UsageSection[] {
|
|
100
|
+
usage[0] = { content: errTxt };
|
|
101
|
+
return usage;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 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
|
+
export const EXECUTABLE_NAME = '3nweb';
|
|
19
|
+
|
|
20
|
+
export const DEFAULT_DATA_ROOT_PATH = '/var/3nweb';
|
|
21
|
+
|
|
22
|
+
export const DEFAULT_CONFIG_PATH = `/etc/3nweb/conf.yaml`;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2023, 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
|
+
import { readFileSync } from 'fs';
|
|
19
|
+
import * as yaml from 'js-yaml';
|
|
20
|
+
import { Configurations } from '../services';
|
|
21
|
+
import { DEFAULT_DATA_ROOT_PATH } from './default-confs';
|
|
22
|
+
|
|
23
|
+
export function readYamlConfFile(path: string): Configurations {
|
|
24
|
+
const txt = readFileSync(path, 'utf8');
|
|
25
|
+
const conf = yaml.load(txt) as Configurations;
|
|
26
|
+
|
|
27
|
+
if (conf.rootFolder) {
|
|
28
|
+
conf.rootFolder = DEFAULT_DATA_ROOT_PATH;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return conf;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2023, 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
|
+
import { readFileSync } from "fs";
|
|
19
|
+
import { ServerOptions } from "https";
|
|
20
|
+
import { join } from "path";
|
|
21
|
+
|
|
22
|
+
export type CertsUpdateListener = (
|
|
23
|
+
newOpts: ServerOptions, originalOpts: ServerOptions
|
|
24
|
+
) => Promise<void>;
|
|
25
|
+
|
|
26
|
+
const LETSENCRYPT_CERT_FILE = 'fullchain.pem';
|
|
27
|
+
const LETSENCRYPT_KEY_FILE = 'privkey.pem';
|
|
28
|
+
|
|
29
|
+
export function sslOptsFromConfig(
|
|
30
|
+
letsencrypt: string|undefined, sslOpts: ServerOptions|undefined,
|
|
31
|
+
skipReloadOnCertsChange: boolean|undefined
|
|
32
|
+
): {
|
|
33
|
+
sslOpts: ServerOptions;
|
|
34
|
+
onCertsUpdate?: (listener: CertsUpdateListener) => (() => void);
|
|
35
|
+
}|undefined {
|
|
36
|
+
if (!sslOpts) {
|
|
37
|
+
sslOpts = {};
|
|
38
|
+
}
|
|
39
|
+
if (letsencrypt) {
|
|
40
|
+
sslOpts.cert = readFileSync(join(letsencrypt, LETSENCRYPT_CERT_FILE));
|
|
41
|
+
sslOpts.key = readFileSync(join(letsencrypt, LETSENCRYPT_KEY_FILE));
|
|
42
|
+
if (skipReloadOnCertsChange) {
|
|
43
|
+
return { sslOpts };
|
|
44
|
+
}
|
|
45
|
+
const onCertsUpdate = makeCertsUpdatesWatch();
|
|
46
|
+
return { sslOpts, onCertsUpdate };
|
|
47
|
+
} else if (sslOpts.cert && sslOpts.key) {
|
|
48
|
+
sslOpts.cert = readFileSync(sslOpts.cert as string);
|
|
49
|
+
sslOpts.key = readFileSync(sslOpts.key as string);
|
|
50
|
+
if (skipReloadOnCertsChange) {
|
|
51
|
+
return { sslOpts };
|
|
52
|
+
}
|
|
53
|
+
const onCertsUpdate = makeCertsUpdatesWatch();
|
|
54
|
+
return { sslOpts, onCertsUpdate };
|
|
55
|
+
} else if ((!sslOpts.cert && sslOpts.key)
|
|
56
|
+
|| (sslOpts.cert && !sslOpts.key)) {
|
|
57
|
+
throw new Error(`servicesConnect.sslOpts section must have both key and cert fields pointing to respective files.`);
|
|
58
|
+
} else {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function makeCertsUpdatesWatch(
|
|
64
|
+
// XXX pass locations, or some fs watching object
|
|
65
|
+
): (listener: CertsUpdateListener) => (() => void) {
|
|
66
|
+
return listener => {
|
|
67
|
+
|
|
68
|
+
// XXX start watching a signal
|
|
69
|
+
|
|
70
|
+
const stopWatching = () => {};
|
|
71
|
+
return stopWatching;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
Object.freeze(exports);
|