spec-3nweb-server 1.8.4 → 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/3nstorage/routes/owner/archive-obj-version.js +2 -2
- package/build/3nstorage/routes/owner/cancel-trans.js +2 -2
- package/build/3nstorage/routes/owner/delete-obj.js +2 -2
- package/build/3nstorage/routes/owner/get-current-obj.js +3 -4
- package/build/3nstorage/routes/owner/param-setter.js +2 -6
- package/build/asmail/routes/config/param-setter.js +2 -2
- package/build/asmail/routes/delivery/finalize-delivery.js +2 -2
- package/build/asmail/routes/delivery/put-obj.js +2 -2
- package/build/asmail/routes/delivery/sender-authorization.js +2 -2
- package/build/asmail/routes/retrieval/remove-message.js +2 -2
- package/build/cli/signup-cmd.js +0 -1
- package/build/lib-server/routes/sessions/close.js +2 -2
- package/build/lib-server/routes/sessions/mid-auth.js +2 -5
- package/build/main.js +12 -15
- package/build/mock/tls-options.js +46 -44
- package/build/signup/routes/add.js +4 -4
- 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,200 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 2019 - 2020 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.StorageComponent = void 0;
|
|
20
|
+
const component_1 = require("./component");
|
|
21
|
+
const mailerid_1 = require("./mailerid");
|
|
22
|
+
const url_1 = require("url");
|
|
23
|
+
const _3nstorage_1 = require("../3nstorage");
|
|
24
|
+
const fs = require("../../../lib-common/async-fs-node");
|
|
25
|
+
const bytes_equal_1 = require("../bytes-equal");
|
|
26
|
+
const obj_file_1 = require("../../../lib-common/objs-on-disk/obj-file");
|
|
27
|
+
const path_1 = require("path");
|
|
28
|
+
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
29
|
+
const server_data_folders_1 = require("../../../lib-server/resources/server-data-folders");
|
|
30
|
+
async function rmFolderContent(folder) {
|
|
31
|
+
await fs.rmDirWithContent(folder);
|
|
32
|
+
await fs.mkdir(folder);
|
|
33
|
+
}
|
|
34
|
+
class StorageComponent extends component_1.Component {
|
|
35
|
+
constructor(signupDomains, midServiceDomain) {
|
|
36
|
+
super({
|
|
37
|
+
rootFolder: null,
|
|
38
|
+
domain: midServiceDomain,
|
|
39
|
+
signup: {},
|
|
40
|
+
enabledServices: {
|
|
41
|
+
mailerId: true,
|
|
42
|
+
storage: true
|
|
43
|
+
},
|
|
44
|
+
mailerId: {
|
|
45
|
+
certs: null
|
|
46
|
+
}
|
|
47
|
+
}, signupDomains);
|
|
48
|
+
this.midServiceDomain = midServiceDomain;
|
|
49
|
+
Object.seal(this);
|
|
50
|
+
}
|
|
51
|
+
async addUser(userId, configureDNS = true) {
|
|
52
|
+
if (configureDNS) {
|
|
53
|
+
this.dns.configureFor(userId);
|
|
54
|
+
}
|
|
55
|
+
let user = await (0, mailerid_1.addUserIn)(this.url, userId);
|
|
56
|
+
user.midUrl = this.midUrl;
|
|
57
|
+
user.storageOwnerUrl = await this.getStorageOwnerUrl();
|
|
58
|
+
return user;
|
|
59
|
+
}
|
|
60
|
+
get midUrl() {
|
|
61
|
+
return (0, url_1.resolve)(this.url, 'mailerid/');
|
|
62
|
+
}
|
|
63
|
+
get storageUrl() {
|
|
64
|
+
return (0, url_1.resolve)(this.url, '3nstorage/');
|
|
65
|
+
}
|
|
66
|
+
async getStorageOwnerUrl() {
|
|
67
|
+
let storageOwnerUrl = await (0, _3nstorage_1.get3NStorageServiceUrl)(this.storageUrl, 'owner');
|
|
68
|
+
if (!storageOwnerUrl.endsWith('/')) {
|
|
69
|
+
storageOwnerUrl += '/';
|
|
70
|
+
}
|
|
71
|
+
return storageOwnerUrl;
|
|
72
|
+
}
|
|
73
|
+
storeFolder(userId) {
|
|
74
|
+
return (0, path_1.join)((0, server_data_folders_1.userDataInRootFolder)(this.conf.rootFolder, userId), 'store');
|
|
75
|
+
}
|
|
76
|
+
async checkTransactionPresence(transFolder, transactionId) {
|
|
77
|
+
const transFile = 'transaction';
|
|
78
|
+
try {
|
|
79
|
+
const lst = await fs.readdir(transFolder);
|
|
80
|
+
expect(lst).toContain(transFile);
|
|
81
|
+
}
|
|
82
|
+
catch (exc) {
|
|
83
|
+
if (exc.notFound) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
throw exc;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (transactionId) {
|
|
91
|
+
const trans = JSON.parse(await fs.readFile((0, path_1.join)(transFolder, transFile), { encoding: 'utf8' }));
|
|
92
|
+
return (trans.transactionId === transactionId);
|
|
93
|
+
}
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
rootTransactionExists(userId, transactionId) {
|
|
97
|
+
return this.checkTransactionPresence((0, path_1.join)(this.storeFolder(userId), 'root', 'transaction'), transactionId);
|
|
98
|
+
}
|
|
99
|
+
transactionExists(userId, objId, transactionId) {
|
|
100
|
+
return this.checkTransactionPresence((0, path_1.join)(this.storeFolder(userId), 'transactions', objId), transactionId);
|
|
101
|
+
}
|
|
102
|
+
async checkCurrentObjPresence(objFolder, ver, obj) {
|
|
103
|
+
let status;
|
|
104
|
+
try {
|
|
105
|
+
status = JSON.parse(await fs.readFile(objFolder + '/status', { encoding: 'utf8' }));
|
|
106
|
+
}
|
|
107
|
+
catch (exc) {
|
|
108
|
+
if (exc.notFound) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
throw exc;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (status.state !== 'current') {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
const currVer = status.currentVersion;
|
|
119
|
+
if ((ver !== undefined) && (currVer !== ver)) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
if (obj) {
|
|
123
|
+
const filePath = (0, path_1.join)(objFolder, `${currVer}.v`);
|
|
124
|
+
const file = await obj_file_1.ObjVersionFile.forExisting(filePath)
|
|
125
|
+
.catch((exc) => {
|
|
126
|
+
if (exc.notFound) {
|
|
127
|
+
return undefined;
|
|
128
|
+
}
|
|
129
|
+
throw exc;
|
|
130
|
+
});
|
|
131
|
+
if (!file) {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
const headerInFile = await file.readHeader();
|
|
135
|
+
if (!headerInFile
|
|
136
|
+
|| !(0, bytes_equal_1.bytesEqual)(headerInFile, obj.header)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
const diff = obj.diff;
|
|
140
|
+
if (file.getBaseVersion() === undefined) {
|
|
141
|
+
if (diff) {
|
|
142
|
+
return false;
|
|
143
|
+
}
|
|
144
|
+
const segsInFile = (0, buffer_utils_1.joinByteArrs)(await file.readSegs(0, file.getTotalSegsLen()));
|
|
145
|
+
if (!(0, bytes_equal_1.bytesEqual)(segsInFile, obj.segs)) {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
if (!diff) {
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
if (file.getBaseVersion() !== diff.baseVersion) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
if (file.getTotalSegsLen() !== diff.segsSize) {
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
159
|
+
let ofs = 0;
|
|
160
|
+
for (const [isNew, dsOfs, len] of diff.sections) {
|
|
161
|
+
if (isNew === 0) {
|
|
162
|
+
const sections = await file.segsLocations(ofs, len);
|
|
163
|
+
for (const section of sections) {
|
|
164
|
+
if (section.type !== 'base') {
|
|
165
|
+
return false;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
if (!(0, bytes_equal_1.bytesEqual)((0, buffer_utils_1.joinByteArrs)(await file.readSegs(ofs, len)), obj.segs.subarray(dsOfs, dsOfs + len))) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
ofs += len;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
currentRootObjExists(userId, ver, obj) {
|
|
181
|
+
return this.checkCurrentObjPresence((0, path_1.join)(this.storeFolder(userId), 'root'), ver, obj);
|
|
182
|
+
}
|
|
183
|
+
currentObjExists(userId, objId, ver, obj) {
|
|
184
|
+
return this.checkCurrentObjPresence((0, path_1.join)(this.storeFolder(userId), 'objects', objId), ver, obj);
|
|
185
|
+
}
|
|
186
|
+
async clearStorage(userId) {
|
|
187
|
+
let storeFolder = this.storeFolder(userId);
|
|
188
|
+
await rmFolderContent((0, path_1.join)(storeFolder, 'transactions'));
|
|
189
|
+
await rmFolderContent((0, path_1.join)(storeFolder, 'objects'));
|
|
190
|
+
await rmFolderContent((0, path_1.join)(storeFolder, 'root'));
|
|
191
|
+
}
|
|
192
|
+
async restartAndClearStorageFor(userId) {
|
|
193
|
+
await this.clearStorage(userId);
|
|
194
|
+
await this.restart();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.StorageComponent = StorageComponent;
|
|
198
|
+
Object.freeze(StorageComponent.prototype);
|
|
199
|
+
Object.freeze(StorageComponent);
|
|
200
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 2020 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.AdminComponent = void 0;
|
|
20
|
+
const component_1 = require("./component");
|
|
21
|
+
const url_1 = require("url");
|
|
22
|
+
const lib_1 = require("../../../lib");
|
|
23
|
+
class AdminComponent extends component_1.Component {
|
|
24
|
+
constructor(signupDomains) {
|
|
25
|
+
super({
|
|
26
|
+
rootFolder: null,
|
|
27
|
+
domain: null,
|
|
28
|
+
signup: {},
|
|
29
|
+
enabledServices: {}
|
|
30
|
+
}, signupDomains);
|
|
31
|
+
Object.seal(this);
|
|
32
|
+
}
|
|
33
|
+
get signupUrl() {
|
|
34
|
+
return (0, url_1.resolve)(this.url, 'signup/');
|
|
35
|
+
}
|
|
36
|
+
createSingleUserSignupTokenFor(userId) {
|
|
37
|
+
return (0, lib_1.addSingleUserSignup)(this.dataFolder, userId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.AdminComponent = AdminComponent;
|
|
41
|
+
Object.freeze(AdminComponent.prototype);
|
|
42
|
+
Object.freeze(AdminComponent);
|
|
43
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Component } from './component';
|
|
2
|
+
import { User } from '../pkl';
|
|
3
|
+
import { Msg } from '../asmail';
|
|
4
|
+
export declare class ASMailComponent extends Component {
|
|
5
|
+
midServiceDomain: string;
|
|
6
|
+
constructor(signupDomains: string[], midServiceDomain: string);
|
|
7
|
+
addUser(userId: string, configureDNS?: boolean): Promise<User>;
|
|
8
|
+
get midUrl(): string;
|
|
9
|
+
get asmailUrl(): string;
|
|
10
|
+
getConfUrl(): Promise<string>;
|
|
11
|
+
getDeliveryUrl(): Promise<string>;
|
|
12
|
+
getRetrievalUrl(): Promise<string>;
|
|
13
|
+
private inboxFolder;
|
|
14
|
+
private msgFolder;
|
|
15
|
+
msgExists(userId: string, msgId: string, deliveryComplete: boolean, msg?: Msg): Promise<boolean>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 - 2017, 2019 - 2020, 2025 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.ASMailComponent = void 0;
|
|
20
|
+
const component_1 = require("./component");
|
|
21
|
+
const mailerid_1 = require("./mailerid");
|
|
22
|
+
const url_1 = require("url");
|
|
23
|
+
const asmail_1 = require("../asmail");
|
|
24
|
+
const fs = require("../../../lib-common/async-fs-node");
|
|
25
|
+
const bytes_equal_1 = require("../bytes-equal");
|
|
26
|
+
const path_1 = require("path");
|
|
27
|
+
const obj_file_1 = require("../../../lib-common/objs-on-disk/obj-file");
|
|
28
|
+
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
29
|
+
const server_data_folders_1 = require("../../../lib-server/resources/server-data-folders");
|
|
30
|
+
class ASMailComponent extends component_1.Component {
|
|
31
|
+
constructor(signupDomains, midServiceDomain) {
|
|
32
|
+
super({
|
|
33
|
+
rootFolder: null,
|
|
34
|
+
domain: midServiceDomain,
|
|
35
|
+
signup: {},
|
|
36
|
+
enabledServices: {
|
|
37
|
+
mailerId: true,
|
|
38
|
+
asmail: true
|
|
39
|
+
},
|
|
40
|
+
mailerId: {
|
|
41
|
+
certs: null
|
|
42
|
+
}
|
|
43
|
+
}, signupDomains);
|
|
44
|
+
this.midServiceDomain = midServiceDomain;
|
|
45
|
+
Object.seal(this);
|
|
46
|
+
}
|
|
47
|
+
async addUser(userId, configureDNS = true) {
|
|
48
|
+
if (configureDNS) {
|
|
49
|
+
this.dns.configureFor(userId);
|
|
50
|
+
}
|
|
51
|
+
let user = await (0, mailerid_1.addUserIn)(this.url, userId);
|
|
52
|
+
user.midUrl = this.midUrl;
|
|
53
|
+
return user;
|
|
54
|
+
}
|
|
55
|
+
get midUrl() {
|
|
56
|
+
return (0, url_1.resolve)(this.url, 'mailerid/');
|
|
57
|
+
}
|
|
58
|
+
get asmailUrl() {
|
|
59
|
+
return (0, url_1.resolve)(this.url, 'asmail/');
|
|
60
|
+
}
|
|
61
|
+
getConfUrl() {
|
|
62
|
+
return (0, asmail_1.getASMailServiceUrl)(this.asmailUrl, 'config');
|
|
63
|
+
}
|
|
64
|
+
getDeliveryUrl() {
|
|
65
|
+
return (0, asmail_1.getASMailServiceUrl)(this.asmailUrl, 'delivery');
|
|
66
|
+
}
|
|
67
|
+
getRetrievalUrl() {
|
|
68
|
+
return (0, asmail_1.getASMailServiceUrl)(this.asmailUrl, 'retrieval');
|
|
69
|
+
}
|
|
70
|
+
inboxFolder(userId) {
|
|
71
|
+
return (0, path_1.join)((0, server_data_folders_1.userDataInRootFolder)(this.conf.rootFolder, userId), 'mail');
|
|
72
|
+
}
|
|
73
|
+
msgFolder(userId, msgId, deliveryComplete) {
|
|
74
|
+
return (0, path_1.join)(this.inboxFolder(userId), (deliveryComplete ? 'messages' : 'delivery'), msgId);
|
|
75
|
+
}
|
|
76
|
+
// XXX adopt new file access
|
|
77
|
+
async msgExists(userId, msgId, deliveryComplete, msg) {
|
|
78
|
+
let meta;
|
|
79
|
+
let msgFolder = this.msgFolder(userId, msgId, deliveryComplete);
|
|
80
|
+
try {
|
|
81
|
+
let metaFile = (0, path_1.join)(msgFolder, 'meta.json');
|
|
82
|
+
meta = JSON.parse(await fs.readFile(metaFile, { encoding: 'utf8' }));
|
|
83
|
+
}
|
|
84
|
+
catch (exc) {
|
|
85
|
+
if (exc.notFound) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
throw exc;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
let extMeta = meta.extMeta;
|
|
93
|
+
if (!deliveryComplete || !msg) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
// check meta
|
|
97
|
+
if (msg.cryptoMeta.pid) {
|
|
98
|
+
expect(extMeta.pid).withContext('correct key-pair id in meta').toBe(msg.cryptoMeta.pid);
|
|
99
|
+
}
|
|
100
|
+
if (msg.cryptoMeta.recipientKid) {
|
|
101
|
+
expect(extMeta.recipientKid).withContext('correct recipient key id in meta').toBe(msg.cryptoMeta.recipientKid);
|
|
102
|
+
}
|
|
103
|
+
if (msg.cryptoMeta.senderPKey) {
|
|
104
|
+
expect(extMeta.senderPKey).withContext('correct sender\'s public key').toBe(msg.cryptoMeta.senderPKey);
|
|
105
|
+
}
|
|
106
|
+
expect(extMeta.objIds.length).withContext('correct number of message objects in meta').toBe(msg.msgObjs.length);
|
|
107
|
+
expect(Object.keys(meta.objs).length).withContext('correct number of message object sizes in meta').toBe(msg.msgObjs.length);
|
|
108
|
+
for (let i = 0; i < msg.msgObjs.length; i += 1) {
|
|
109
|
+
// check meta info for each object
|
|
110
|
+
let obj = msg.msgObjs[i];
|
|
111
|
+
let objId = obj.objId;
|
|
112
|
+
expect(extMeta.objIds[i]).toBe(objId);
|
|
113
|
+
expect(meta.objs[objId].size.header).withContext('header length of a message object').toBe(obj.header.length);
|
|
114
|
+
expect(meta.objs[objId].size.segments).withContext('segments length of a message object').toBe(obj.segs.length);
|
|
115
|
+
expect(meta.objs[objId].completed).withContext('completness flag of a message object').toBe(true);
|
|
116
|
+
// check object file
|
|
117
|
+
const filePath = (0, path_1.join)(msgFolder, objId);
|
|
118
|
+
const file = await obj_file_1.ObjVersionFile.forExisting(filePath)
|
|
119
|
+
.catch((exc) => {
|
|
120
|
+
if (exc.notFound) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
throw exc;
|
|
124
|
+
});
|
|
125
|
+
if (!file) {
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
const headerInFile = await file.readHeader();
|
|
129
|
+
if (!headerInFile
|
|
130
|
+
|| !(0, bytes_equal_1.bytesEqual)(headerInFile, obj.header)) {
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
const segsInFile = (0, buffer_utils_1.joinByteArrs)(await file.readSegs(0, file.getTotalSegsLen()));
|
|
134
|
+
if (!(0, bytes_equal_1.bytesEqual)(segsInFile, obj.segs)) {
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return true;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.ASMailComponent = ASMailComponent;
|
|
142
|
+
Object.freeze(ASMailComponent.prototype);
|
|
143
|
+
Object.freeze(ASMailComponent);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ServerRunner } from '../server-runner';
|
|
2
|
+
import { Configurations } from '../../../services';
|
|
3
|
+
import { DNSMock } from '../../../mock/dns';
|
|
4
|
+
import { AppWithWSs } from '../../../lib-server/web-sockets/app';
|
|
5
|
+
export declare abstract class Component extends ServerRunner {
|
|
6
|
+
protected conf: Configurations;
|
|
7
|
+
private signupDomains;
|
|
8
|
+
protected dataFolder: string;
|
|
9
|
+
dns: DNSMock;
|
|
10
|
+
constructor(conf: Configurations, signupDomains: string[], servicePort?: number, dataFolder?: string);
|
|
11
|
+
prepToRun(): Promise<AppWithWSs>;
|
|
12
|
+
clean(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 2020 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.Component = void 0;
|
|
20
|
+
const server_runner_1 = require("../server-runner");
|
|
21
|
+
const async_fs_node_1 = require("../../../lib-common/async-fs-node");
|
|
22
|
+
const services_1 = require("../../../services");
|
|
23
|
+
const dns_1 = require("../../../mock/dns");
|
|
24
|
+
const dns = require("dns");
|
|
25
|
+
const app_1 = require("../../../lib-server/web-sockets/app");
|
|
26
|
+
const path_1 = require("path");
|
|
27
|
+
const signup_tokens_1 = require("../../../signup/signup-tokens");
|
|
28
|
+
const DEFAULT_SERVICE_PORT = 8088;
|
|
29
|
+
const DEFAULT_DATA_FOLDER = (0, path_1.join)(__dirname, '/../../../../test-data');
|
|
30
|
+
class Component extends server_runner_1.ServerRunner {
|
|
31
|
+
constructor(conf, signupDomains, servicePort = DEFAULT_SERVICE_PORT, dataFolder = DEFAULT_DATA_FOLDER) {
|
|
32
|
+
super(servicePort);
|
|
33
|
+
this.conf = conf;
|
|
34
|
+
this.signupDomains = signupDomains;
|
|
35
|
+
this.dataFolder = dataFolder;
|
|
36
|
+
this.conf.rootFolder = this.dataFolder;
|
|
37
|
+
this.conf.signup.noTokenFile = (0, path_1.join)(this.dataFolder, 'no-tokens-signup.json');
|
|
38
|
+
if (this.conf.mailerId) {
|
|
39
|
+
const certs = this.conf.mailerId.certs;
|
|
40
|
+
this.conf.mailerId.certs = (0, path_1.join)(this.dataFolder, (certs ? certs : 'mid-certs.json'));
|
|
41
|
+
}
|
|
42
|
+
const urlWithoutProto = this.url.substring(this.url.indexOf('://') + 3);
|
|
43
|
+
this.dns = new dns_1.DNSMock(urlWithoutProto + 'mailerid/');
|
|
44
|
+
}
|
|
45
|
+
async prepToRun() {
|
|
46
|
+
// prepare data folders
|
|
47
|
+
try {
|
|
48
|
+
await (0, async_fs_node_1.mkdir)(this.dataFolder);
|
|
49
|
+
// write to-tokens signup file
|
|
50
|
+
const noTokenCtx = (0, signup_tokens_1.makeMultiDomainSignupCtx)(this.signupDomains);
|
|
51
|
+
await (0, async_fs_node_1.writeFile)(this.conf.signup.noTokenFile, JSON.stringify(noTokenCtx), { encoding: 'utf8' });
|
|
52
|
+
}
|
|
53
|
+
catch (exc) {
|
|
54
|
+
if (!exc.alreadyExists) {
|
|
55
|
+
throw exc;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// inject dns mock
|
|
59
|
+
dns.resolveTxt = this.dns.resolveTxt;
|
|
60
|
+
// setup servers
|
|
61
|
+
const app = new app_1.AppWithWSs();
|
|
62
|
+
app.use((0, services_1.accountsApp)(this.conf));
|
|
63
|
+
app.use((0, services_1.servicesApp)(this.conf));
|
|
64
|
+
return app;
|
|
65
|
+
}
|
|
66
|
+
async clean() {
|
|
67
|
+
await (0, async_fs_node_1.rmDirWithContent)(this.dataFolder).catch((exc) => {
|
|
68
|
+
if (!exc.notFound) {
|
|
69
|
+
throw exc;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.Component = Component;
|
|
75
|
+
Object.freeze(Component.prototype);
|
|
76
|
+
Object.freeze(Component);
|
|
77
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Component } from './component';
|
|
2
|
+
import { User } from '../pkl';
|
|
3
|
+
export declare function addUserIn(rootServerUrl: string, userId: string): Promise<User>;
|
|
4
|
+
export declare class MailerIdComponent extends Component {
|
|
5
|
+
midServiceDomain: string;
|
|
6
|
+
constructor(signupDomains: string[], midServiceDomain: string);
|
|
7
|
+
addUser(userId: string): Promise<User>;
|
|
8
|
+
get midUrl(): string;
|
|
9
|
+
getProvUrl(): Promise<string>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 2020 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.MailerIdComponent = exports.addUserIn = void 0;
|
|
20
|
+
const component_1 = require("./component");
|
|
21
|
+
const url_1 = require("url");
|
|
22
|
+
const xhr_utils_1 = require("../xhr-utils");
|
|
23
|
+
const signup = require("../../../lib-common/admin-api/signup");
|
|
24
|
+
const random = require("../../../lib-common/random-node");
|
|
25
|
+
const ecma_nacl_1 = require("ecma-nacl");
|
|
26
|
+
const jwkeys_1 = require("../../../lib-common/jwkeys");
|
|
27
|
+
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
28
|
+
const mailerid_1 = require("../mailerid");
|
|
29
|
+
async function addUserIn(rootServerUrl, userId) {
|
|
30
|
+
let reqOpts = {
|
|
31
|
+
url: (0, url_1.resolve)((0, url_1.resolve)(rootServerUrl, 'signup/'), signup.addUser.URL_END),
|
|
32
|
+
method: 'POST'
|
|
33
|
+
};
|
|
34
|
+
let user = {
|
|
35
|
+
id: userId,
|
|
36
|
+
loginDefaultSKey: await random.bytes(ecma_nacl_1.box.KEY_LENGTH),
|
|
37
|
+
loginLabeledSKey: {
|
|
38
|
+
k: await random.bytes(ecma_nacl_1.box.KEY_LENGTH),
|
|
39
|
+
kid: await random.stringOfB64Chars(12)
|
|
40
|
+
},
|
|
41
|
+
midUrl: undefined,
|
|
42
|
+
storageOwnerUrl: undefined
|
|
43
|
+
};
|
|
44
|
+
let req = {
|
|
45
|
+
userId: user.id,
|
|
46
|
+
storage: {
|
|
47
|
+
kdParams: {}
|
|
48
|
+
},
|
|
49
|
+
mailerId: {
|
|
50
|
+
defaultPKey: {
|
|
51
|
+
pkey: {
|
|
52
|
+
alg: ecma_nacl_1.box.JWK_ALG_NAME,
|
|
53
|
+
kid: '_',
|
|
54
|
+
use: jwkeys_1.use.MID_PKLOGIN,
|
|
55
|
+
k: buffer_utils_1.base64.pack(ecma_nacl_1.box.generate_pubkey(user.loginDefaultSKey))
|
|
56
|
+
},
|
|
57
|
+
kdParams: {}
|
|
58
|
+
},
|
|
59
|
+
otherPKeys: [{
|
|
60
|
+
alg: ecma_nacl_1.box.JWK_ALG_NAME,
|
|
61
|
+
kid: user.loginLabeledSKey.kid,
|
|
62
|
+
use: jwkeys_1.use.MID_PKLOGIN,
|
|
63
|
+
k: buffer_utils_1.base64.pack(ecma_nacl_1.box.generate_pubkey(user.loginLabeledSKey.k))
|
|
64
|
+
}]
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
68
|
+
if (rep.status !== signup.addUser.SC.ok) {
|
|
69
|
+
throw new Error(`Fail to add user ${userId}`);
|
|
70
|
+
}
|
|
71
|
+
return user;
|
|
72
|
+
}
|
|
73
|
+
exports.addUserIn = addUserIn;
|
|
74
|
+
class MailerIdComponent extends component_1.Component {
|
|
75
|
+
constructor(signupDomains, midServiceDomain) {
|
|
76
|
+
super({
|
|
77
|
+
rootFolder: null,
|
|
78
|
+
domain: midServiceDomain,
|
|
79
|
+
signup: {},
|
|
80
|
+
enabledServices: {
|
|
81
|
+
mailerId: true
|
|
82
|
+
},
|
|
83
|
+
mailerId: {
|
|
84
|
+
certs: null
|
|
85
|
+
}
|
|
86
|
+
}, signupDomains);
|
|
87
|
+
this.midServiceDomain = midServiceDomain;
|
|
88
|
+
Object.seal(this);
|
|
89
|
+
}
|
|
90
|
+
addUser(userId) {
|
|
91
|
+
return addUserIn(this.url, userId);
|
|
92
|
+
}
|
|
93
|
+
get midUrl() {
|
|
94
|
+
return (0, url_1.resolve)(this.url, 'mailerid/');
|
|
95
|
+
}
|
|
96
|
+
getProvUrl() {
|
|
97
|
+
return (0, mailerid_1.getProvPath)(this.midUrl);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.MailerIdComponent = MailerIdComponent;
|
|
101
|
+
Object.freeze(MailerIdComponent.prototype);
|
|
102
|
+
Object.freeze(MailerIdComponent);
|
|
103
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AppWithWSs } from '../../lib-server/web-sockets/app';
|
|
2
|
+
export type ServerState = 'stopped' | 'starting' | 'running' | 'stopping';
|
|
3
|
+
export declare abstract class ServerRunner {
|
|
4
|
+
protected servicePort: number;
|
|
5
|
+
protected state: ServerState;
|
|
6
|
+
protected app: AppWithWSs;
|
|
7
|
+
constructor(servicePort: number);
|
|
8
|
+
abstract prepToRun(): Promise<AppWithWSs>;
|
|
9
|
+
abstract clean(): Promise<void>;
|
|
10
|
+
isRunning(): boolean;
|
|
11
|
+
start(): Promise<void>;
|
|
12
|
+
stop(doCleanup?: boolean): Promise<void>;
|
|
13
|
+
restart(): Promise<void>;
|
|
14
|
+
protected get url(): string;
|
|
15
|
+
}
|