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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2017, 2019 - 2020 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2017, 2019 - 2020, 2026 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -20,10 +20,10 @@ exports.saveCurrentObj = void 0;
|
|
|
20
20
|
const users_1 = require("../../resources/users");
|
|
21
21
|
const owner_1 = require("../../../lib-common/service-api/3nstorage/owner");
|
|
22
22
|
const conf_util_1 = require("../../../lib-server/conf-util");
|
|
23
|
-
const body_parsers_1 = require("../../../lib-server/middleware/body-parsers");
|
|
24
23
|
const common_1 = require("../../../lib-common/byte-streaming/common");
|
|
25
24
|
const processes_1 = require("../../../lib-common/processes");
|
|
26
25
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
26
|
+
const utils_1 = require("../../resources/utils");
|
|
27
27
|
function saveCurrentObj(root, saveObjFunc, chunkLimit) {
|
|
28
28
|
if ('function' !== typeof saveObjFunc) {
|
|
29
29
|
throw new TypeError("Given argument 'saveObjFunc' must be function, but is not.");
|
|
@@ -31,38 +31,30 @@ function saveCurrentObj(root, saveObjFunc, chunkLimit) {
|
|
|
31
31
|
const maxChunkSize = (0, conf_util_1.stringToNumOfBytes)(chunkLimit);
|
|
32
32
|
return async (req, res, next) => {
|
|
33
33
|
if (!req.is(owner_1.BIN_TYPE)) {
|
|
34
|
-
(0,
|
|
35
|
-
res.status(owner_1.ERR_SC.wrongContentType).json({
|
|
36
|
-
error: `Content-Type must be ${owner_1.BIN_TYPE} for this call.`
|
|
37
|
-
});
|
|
38
|
-
return;
|
|
34
|
+
return (0, utils_1.replyWithErr)(owner_1.ERR_SC.wrongContentType, `Content-Type must be ${owner_1.BIN_TYPE} for this call.`, res, req);
|
|
39
35
|
}
|
|
40
|
-
const userId = req.session.params.userId;
|
|
41
|
-
const objId = (root ? null : req.params.objId);
|
|
42
36
|
// get and check Content-Length, implicitly sending replies for bad length
|
|
43
37
|
let len = getContentLenOrSendError(req, res, maxChunkSize);
|
|
44
38
|
if (len === undefined) {
|
|
45
|
-
(0, body_parsers_1.attachByteDrainToRequest)(req);
|
|
46
39
|
return;
|
|
47
40
|
}
|
|
41
|
+
const userId = req.session.params.userId;
|
|
42
|
+
const { objId, objIdParseErr } = (0, utils_1.getObjIdFromParams)(root, req);
|
|
43
|
+
if (objIdParseErr) {
|
|
44
|
+
return (0, utils_1.replyWithErr)(owner_1.ERR_SC.malformed, objIdParseErr, res, req);
|
|
45
|
+
}
|
|
48
46
|
// extract and check query parameters
|
|
49
47
|
const opts = extractQueryOptions(req);
|
|
50
48
|
if (!opts) {
|
|
51
|
-
return
|
|
49
|
+
return (0, utils_1.replyWithErr)(owner_1.ERR_SC.malformed, "Bad query parameters", res, req);
|
|
52
50
|
}
|
|
53
51
|
const { fstReq, sndReq } = opts;
|
|
54
52
|
let diff;
|
|
55
53
|
if (fstReq) {
|
|
56
|
-
if (!root && objId) {
|
|
57
|
-
if (!buffer_utils_1.base64urlSafe.allCharsFromAlphabet(objId)) {
|
|
58
|
-
return replyToMalformed(req, "Bad object id", res);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
54
|
// cross-check given lengths
|
|
62
|
-
const diffAndHeader = fstReq.header +
|
|
63
|
-
(fstReq.diff ? fstReq.diff : 0);
|
|
55
|
+
const diffAndHeader = fstReq.header + (fstReq.diff ? fstReq.diff : 0);
|
|
64
56
|
if (diffAndHeader > len) {
|
|
65
|
-
return
|
|
57
|
+
return (0, utils_1.replyWithErr)(owner_1.ERR_SC.malformed, "Bad query parameters", res, req);
|
|
66
58
|
}
|
|
67
59
|
// read diff, if it is expected
|
|
68
60
|
if (fstReq.diff) {
|
|
@@ -71,23 +63,23 @@ function saveCurrentObj(root, saveObjFunc, chunkLimit) {
|
|
|
71
63
|
len -= fstReq.diff;
|
|
72
64
|
}
|
|
73
65
|
else {
|
|
74
|
-
return
|
|
66
|
+
return (0, utils_1.replyWithErr)(owner_1.ERR_SC.malformed, "Cannot read diff bytes", res, req);
|
|
75
67
|
}
|
|
76
68
|
try {
|
|
77
69
|
const diffFromReq = JSON.parse(buffer_utils_1.utf8.open(diffBytes));
|
|
78
70
|
diff = (0, owner_1.sanitizedDiff)(diffFromReq, fstReq.ver);
|
|
79
71
|
if (!diff) {
|
|
80
|
-
return
|
|
72
|
+
return (0, utils_1.replyWithErr)(owner_1.ERR_SC.malformed, "Malformed diff info", res, req);
|
|
81
73
|
}
|
|
82
74
|
}
|
|
83
75
|
catch (err) {
|
|
84
|
-
return
|
|
76
|
+
return (0, utils_1.replyWithErr)(owner_1.ERR_SC.malformed, "Malformed diff info", res, req);
|
|
85
77
|
}
|
|
86
78
|
}
|
|
87
79
|
}
|
|
88
80
|
else if (sndReq) {
|
|
89
81
|
if ((len === 0) && !sndReq.last) {
|
|
90
|
-
return
|
|
82
|
+
return (0, utils_1.replyWithErr)(owner_1.ERR_SC.malformed, "No segment bytes", res, req);
|
|
91
83
|
}
|
|
92
84
|
}
|
|
93
85
|
try {
|
|
@@ -102,7 +94,7 @@ function saveCurrentObj(root, saveObjFunc, chunkLimit) {
|
|
|
102
94
|
error: "Current object version doesn't match assumed one.",
|
|
103
95
|
current_version: err.current_version
|
|
104
96
|
};
|
|
105
|
-
res.set(owner_1.HTTP_HEADER.objVersion, `${
|
|
97
|
+
res.set(owner_1.HTTP_HEADER.objVersion, `${rep.current_version}`);
|
|
106
98
|
res.status(owner_1.currentObj.SC.mismatchedObjVer).json(rep);
|
|
107
99
|
}
|
|
108
100
|
else {
|
|
@@ -111,41 +103,27 @@ function saveCurrentObj(root, saveObjFunc, chunkLimit) {
|
|
|
111
103
|
}
|
|
112
104
|
else if ((err === users_1.SC.OBJ_UNKNOWN)
|
|
113
105
|
|| (err === users_1.SC.OBJ_VER_UNKNOWN)) {
|
|
114
|
-
|
|
115
|
-
error: `Unknown object ${objId}.`
|
|
116
|
-
});
|
|
106
|
+
(0, utils_1.replyWithErr)(owner_1.currentObj.SC.unknownObj, `Unknown object ${objId}.`, res);
|
|
117
107
|
}
|
|
118
108
|
else if (err === users_1.SC.TRANSACTION_UNKNOWN) {
|
|
119
|
-
|
|
120
|
-
error: "Unknown transaction."
|
|
121
|
-
});
|
|
109
|
+
(0, utils_1.replyWithErr)(owner_1.currentObj.SC.unknownTransaction, "Unknown transaction.", res);
|
|
122
110
|
}
|
|
123
111
|
else if ((err === users_1.SC.OBJ_EXIST)
|
|
124
112
|
|| (err === users_1.SC.OBJ_VER_EXIST)) {
|
|
125
|
-
|
|
126
|
-
error: "Object already exists."
|
|
127
|
-
});
|
|
113
|
+
(0, utils_1.replyWithErr)(owner_1.currentObj.SC.objAlreadyExists, "Object already exists.", res);
|
|
128
114
|
}
|
|
129
115
|
else if (err === users_1.SC.CONCURRENT_TRANSACTION) {
|
|
130
|
-
|
|
131
|
-
error: `Object ${objId} is currently under a transaction.`
|
|
132
|
-
});
|
|
116
|
+
(0, utils_1.replyWithErr)(owner_1.currentObj.SC.concurrentTransaction, `Object ${objId} is currently under a transaction.`, res);
|
|
133
117
|
}
|
|
134
118
|
else if (err === users_1.SC.USER_UNKNOWN) {
|
|
135
|
-
|
|
136
|
-
error: "Recipient disappeared from the system."
|
|
137
|
-
});
|
|
119
|
+
(0, utils_1.replyWithErr)(owner_1.ERR_SC.server, "Recipient disappeared from the system.", res);
|
|
138
120
|
req.session.close();
|
|
139
121
|
}
|
|
140
122
|
else if (err === users_1.SC.NOT_ENOUGH_SPACE) {
|
|
141
|
-
|
|
142
|
-
error: "Reached storage limits."
|
|
143
|
-
});
|
|
123
|
+
(0, utils_1.replyWithErr)(owner_1.ERR_SC.noSpace, "Reached storage limits.", res);
|
|
144
124
|
}
|
|
145
125
|
else if (err === users_1.SC.OBJ_FILE_INCOMPLETE) {
|
|
146
|
-
|
|
147
|
-
error: "Object version file is incomplete."
|
|
148
|
-
});
|
|
126
|
+
(0, utils_1.replyWithErr)(owner_1.currentObj.SC.objIncomplete, "Object version file is incomplete.", res);
|
|
149
127
|
}
|
|
150
128
|
else {
|
|
151
129
|
next(new Error(`Unhandled storage error code: ${err}`));
|
|
@@ -192,14 +170,10 @@ function extractQueryOptions(req) {
|
|
|
192
170
|
function getContentLenOrSendError(req, res, maxChunkSize) {
|
|
193
171
|
const contentLength = parseInt(req.get(owner_1.HTTP_HEADER.contentLength));
|
|
194
172
|
if (isNaN(contentLength)) {
|
|
195
|
-
|
|
196
|
-
error: "Content-Length header is required with proper number."
|
|
197
|
-
});
|
|
173
|
+
(0, utils_1.replyWithErr)(owner_1.ERR_SC.contentLenMissing, "Content-Length header is required with proper number.", res, req);
|
|
198
174
|
}
|
|
199
175
|
else if (contentLength > maxChunkSize) {
|
|
200
|
-
|
|
201
|
-
error: "Request body is too long."
|
|
202
|
-
});
|
|
176
|
+
(0, utils_1.replyWithErr)(owner_1.ERR_SC.contentTooLong, "Request body is too long.", res, req);
|
|
203
177
|
}
|
|
204
178
|
else {
|
|
205
179
|
return contentLength;
|
|
@@ -269,9 +243,5 @@ function readChunkFrom(stream, bytesToRead) {
|
|
|
269
243
|
stream.on('end', onEnd);
|
|
270
244
|
return deferred.promise;
|
|
271
245
|
}
|
|
272
|
-
function replyToMalformed(req, msg, res) {
|
|
273
|
-
(0, body_parsers_1.attachByteDrainToRequest)(req);
|
|
274
|
-
res.status(owner_1.ERR_SC.malformed).json({ error: msg });
|
|
275
|
-
}
|
|
276
246
|
function noop() { }
|
|
277
247
|
Object.freeze(exports);
|
|
@@ -23,6 +23,8 @@ const conf_util_1 = require("../../../lib-server/conf-util");
|
|
|
23
23
|
function sessionParams(maxChunk) {
|
|
24
24
|
const maxChunkSize = (0, conf_util_1.stringToNumOfBytes)(maxChunk);
|
|
25
25
|
return async (req, res, next) => {
|
|
26
|
+
// XXX currently session params are same for all, hence, userId is unused, but, this whole
|
|
27
|
+
// thing must be within a session
|
|
26
28
|
const userId = req.session.params.userId;
|
|
27
29
|
try {
|
|
28
30
|
const reply = { maxChunkSize };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Response, Request } from 'express';
|
|
2
|
+
export declare function getObjIdFromParams(req: Request): {
|
|
3
|
+
objId: string;
|
|
4
|
+
objIdParseErr?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function replyWithErr(status: number, msg: string, res: Response, reqToDrainBytesFrom?: Request): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2026 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.replyWithErr = exports.getObjIdFromParams = void 0;
|
|
20
|
+
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
21
|
+
const body_parsers_1 = require("../../lib-server/middleware/body-parsers");
|
|
22
|
+
function getObjIdFromParams(req) {
|
|
23
|
+
const objId = req.params.objId;
|
|
24
|
+
return ((!!objId && buffer_utils_1.base64urlSafe.allCharsFromAlphabet(objId)) ?
|
|
25
|
+
{ objId } :
|
|
26
|
+
{ objId: undefined, objIdParseErr: "Bad object id" });
|
|
27
|
+
}
|
|
28
|
+
exports.getObjIdFromParams = getObjIdFromParams;
|
|
29
|
+
function replyWithErr(status, msg, res, reqToDrainBytesFrom) {
|
|
30
|
+
if (reqToDrainBytesFrom) {
|
|
31
|
+
(0, body_parsers_1.attachByteDrainToRequest)(reqToDrainBytesFrom);
|
|
32
|
+
}
|
|
33
|
+
res.status(status).json({ error: msg });
|
|
34
|
+
}
|
|
35
|
+
exports.replyWithErr = replyWithErr;
|
|
36
|
+
Object.freeze(exports);
|
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.finalizeDelivery = void 0;
|
|
20
20
|
const recipients_1 = require("../../resources/recipients");
|
|
21
21
|
const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
|
|
22
|
+
const utils_1 = require("../../resources/utils");
|
|
22
23
|
function finalizeDelivery(finDelivFunc) {
|
|
23
24
|
return async (req, res, next) => {
|
|
24
25
|
const session = req.session;
|
|
@@ -35,11 +36,11 @@ function finalizeDelivery(finDelivFunc) {
|
|
|
35
36
|
}
|
|
36
37
|
else if (err === recipients_1.SC.USER_UNKNOWN) {
|
|
37
38
|
session.close();
|
|
38
|
-
|
|
39
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.server, "Recipient disappeared from the system.", res);
|
|
39
40
|
}
|
|
40
41
|
else if (err === recipients_1.SC.MSG_UNKNOWN) {
|
|
41
42
|
session.close();
|
|
42
|
-
|
|
43
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.server, "Message disappeared from the system.", res);
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
next(new Error("Unhandled storage error code: " + err));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2017, 2025 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2017, 2025 - 2026 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -20,6 +20,7 @@ exports.preFlight = void 0;
|
|
|
20
20
|
const recipients_1 = require("../../resources/recipients");
|
|
21
21
|
const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
|
|
22
22
|
const canonical_address_1 = require("../../../lib-common/canonical-address");
|
|
23
|
+
const utils_1 = require("../../resources/utils");
|
|
23
24
|
/**
|
|
24
25
|
* This creates a pre-flight route handler.
|
|
25
26
|
* @param allowedMsgSizeFunc is a function returning promises, that may resolve to
|
|
@@ -41,14 +42,10 @@ function preFlight(allowedMsgSizeFunc, redirectFunc) {
|
|
|
41
42
|
});
|
|
42
43
|
}
|
|
43
44
|
else if (msgSize === 0) {
|
|
44
|
-
|
|
45
|
-
error: `${sender ? sender : "Anonymous sender "} is not allowed to leave mail for ${recipient}`
|
|
46
|
-
});
|
|
45
|
+
(0, utils_1.replyWithErr)(delivery_1.preFlight.SC.senderNotAllowed, `${sender ? sender : "Anonymous sender "} is not allowed to leave mail for ${recipient}`, res);
|
|
47
46
|
}
|
|
48
47
|
else if (msgSize === -1) {
|
|
49
|
-
|
|
50
|
-
error: `Mail box for ${recipient} is full.`
|
|
51
|
-
});
|
|
48
|
+
(0, utils_1.replyWithErr)(delivery_1.preFlight.SC.inboxFull, `Mail box for ${recipient} is full.`, res);
|
|
52
49
|
}
|
|
53
50
|
else {
|
|
54
51
|
throw new Error(`Unrecognized code ${msgSize} for message size limits.`);
|
|
@@ -62,34 +59,22 @@ function preFlight(allowedMsgSizeFunc, redirectFunc) {
|
|
|
62
59
|
const session = req.session;
|
|
63
60
|
// already existing session indicates repeated call, which should be bounced off
|
|
64
61
|
if (session) {
|
|
65
|
-
|
|
66
|
-
error: "This protocol request has already been served."
|
|
67
|
-
});
|
|
68
|
-
return;
|
|
62
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.duplicateReq, "This protocol request has already been served.", res);
|
|
69
63
|
}
|
|
70
64
|
// missing recipient makes a bad request
|
|
71
65
|
if (!recipient) {
|
|
72
|
-
|
|
73
|
-
error: "Recipient is either missing in the request, or is malformed"
|
|
74
|
-
});
|
|
75
|
-
return;
|
|
66
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Recipient is either missing in the request, or is malformed", res);
|
|
76
67
|
}
|
|
77
68
|
// if sender is given, we canonicalize the address
|
|
78
69
|
if (sender) {
|
|
79
70
|
sender = (0, canonical_address_1.checkAndTransformAddress)(sender);
|
|
80
71
|
if (!sender) {
|
|
81
|
-
|
|
82
|
-
error: "Sender field is malformed"
|
|
83
|
-
});
|
|
84
|
-
return;
|
|
72
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Sender field is malformed", res);
|
|
85
73
|
}
|
|
86
74
|
}
|
|
87
75
|
// check invitation field
|
|
88
76
|
if ((invitation !== undefined) && (typeof invitation !== 'string')) {
|
|
89
|
-
|
|
90
|
-
error: "Inviation field is malformed"
|
|
91
|
-
});
|
|
92
|
-
return;
|
|
77
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Inviation field is malformed", res);
|
|
93
78
|
}
|
|
94
79
|
try {
|
|
95
80
|
if (redirectFunc) {
|
|
@@ -109,9 +94,7 @@ function preFlight(allowedMsgSizeFunc, redirectFunc) {
|
|
|
109
94
|
}
|
|
110
95
|
catch (err) {
|
|
111
96
|
if (err === recipients_1.SC.USER_UNKNOWN) {
|
|
112
|
-
|
|
113
|
-
error: `Recipient ${recipient} is unknown.`
|
|
114
|
-
});
|
|
97
|
+
(0, utils_1.replyWithErr)(delivery_1.preFlight.SC.unknownRecipient, `Recipient ${recipient} is unknown.`, res);
|
|
115
98
|
}
|
|
116
99
|
else {
|
|
117
100
|
next(err);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2016, 2025 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2016, 2025 - 2026 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
exports.getRecipientPubKey = void 0;
|
|
20
20
|
const recipients_1 = require("../../resources/recipients");
|
|
21
21
|
const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
|
|
22
|
+
const utils_1 = require("../../resources/utils");
|
|
22
23
|
/**
|
|
23
24
|
* This creates a get-init-pub-key route handler.
|
|
24
25
|
* @param pkeyProvidingFunc is a function that provides recipient's public key
|
|
@@ -33,7 +34,7 @@ function getRecipientPubKey(pkeyProvidingFunc) {
|
|
|
33
34
|
res.status(delivery_1.initPubKey.SC.ok).json(certs);
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
|
-
|
|
37
|
+
(0, utils_1.replyWithErr)(delivery_1.initPubKey.SC.pkeyNotRegistered, 'No public key registered for the recipient.', res);
|
|
37
38
|
session.close();
|
|
38
39
|
}
|
|
39
40
|
}
|
|
@@ -42,7 +43,7 @@ function getRecipientPubKey(pkeyProvidingFunc) {
|
|
|
42
43
|
next(err);
|
|
43
44
|
}
|
|
44
45
|
else if (err === recipients_1.SC.USER_UNKNOWN) {
|
|
45
|
-
|
|
46
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.server, "Recipient disappeared from the system.", res);
|
|
46
47
|
session.close();
|
|
47
48
|
}
|
|
48
49
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2015 - 2016, 2025 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2015 - 2016, 2025 - 2026 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -21,23 +21,18 @@ const recipients_1 = require("../../resources/recipients");
|
|
|
21
21
|
const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
|
|
22
22
|
const confUtil = require("../../../lib-server/conf-util");
|
|
23
23
|
const buffer_utils_1 = require("../../../lib-common/buffer-utils");
|
|
24
|
+
const utils_1 = require("../../resources/utils");
|
|
24
25
|
function findProblemWithObjIds(ids) {
|
|
25
26
|
if (!Array.isArray(ids)) {
|
|
26
|
-
return
|
|
27
|
-
error: "Object ids are missing."
|
|
28
|
-
};
|
|
27
|
+
return "Object ids are missing.";
|
|
29
28
|
}
|
|
30
29
|
const checkedIds = new Set();
|
|
31
30
|
for (const objId of ids) {
|
|
32
31
|
if (checkedIds.has(objId)) {
|
|
33
|
-
return
|
|
34
|
-
error: "Duplication of object ids."
|
|
35
|
-
};
|
|
32
|
+
return "Duplication of object ids.";
|
|
36
33
|
}
|
|
37
34
|
if (!buffer_utils_1.base64urlSafe.allCharsFromAlphabet(objId)) {
|
|
38
|
-
return
|
|
39
|
-
error: "Object id is invalid."
|
|
40
|
-
};
|
|
35
|
+
return "Object id is invalid.";
|
|
41
36
|
}
|
|
42
37
|
checkedIds.add(objId);
|
|
43
38
|
}
|
|
@@ -47,18 +42,15 @@ function saveMetadata(setMsgStorageFunc, maxChunk) {
|
|
|
47
42
|
const maxChunkSize = confUtil.stringToNumOfBytes(maxChunk);
|
|
48
43
|
return async (req, res, next) => {
|
|
49
44
|
const session = req.session;
|
|
50
|
-
const msgMeta = req.body;
|
|
51
|
-
const recipient = session.params.recipient;
|
|
52
|
-
const objIds = msgMeta.objIds;
|
|
53
45
|
if (session.params.msgId) {
|
|
54
|
-
|
|
55
|
-
error: "This protocol request has already been served."
|
|
56
|
-
});
|
|
57
|
-
return;
|
|
46
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.duplicateReq, "This protocol request has already been served.", res);
|
|
58
47
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
const recipient = session.params.recipient;
|
|
49
|
+
const msgMeta = req.body;
|
|
50
|
+
const objIds = msgMeta.objIds;
|
|
51
|
+
const errWithWithObjIds = findProblemWithObjIds(objIds);
|
|
52
|
+
if (errWithWithObjIds) {
|
|
53
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, errWithWithObjIds, res);
|
|
62
54
|
}
|
|
63
55
|
try {
|
|
64
56
|
const msgId = await setMsgStorageFunc(recipient, msgMeta, session.params.sender, session.params.invite, session.params.maxMsgLength);
|
|
@@ -73,7 +65,7 @@ function saveMetadata(setMsgStorageFunc, maxChunk) {
|
|
|
73
65
|
next(err);
|
|
74
66
|
}
|
|
75
67
|
else if (err === recipients_1.SC.USER_UNKNOWN) {
|
|
76
|
-
|
|
68
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.server, "Recipient disappeared from the system.", res);
|
|
77
69
|
session.close();
|
|
78
70
|
}
|
|
79
71
|
}
|
|
@@ -20,44 +20,43 @@ exports.saveMsgObj = void 0;
|
|
|
20
20
|
const recipients_1 = require("../../resources/recipients");
|
|
21
21
|
const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
|
|
22
22
|
const confUtil = require("../../../lib-server/conf-util");
|
|
23
|
-
const
|
|
23
|
+
const utils_1 = require("../../resources/utils");
|
|
24
24
|
function saveMsgObj(saveObjFunc, chunkLimit) {
|
|
25
25
|
const maxChunkSize = confUtil.stringToNumOfBytes(chunkLimit);
|
|
26
26
|
return async (req, res, next) => {
|
|
27
27
|
if (!req.is(recipients_1.BIN_TYPE)) {
|
|
28
|
-
(0,
|
|
29
|
-
res.status(delivery_1.ERR_SC.wrongContentType).send(`Content-Type must be ${recipients_1.BIN_TYPE} for this call.`);
|
|
30
|
-
return;
|
|
28
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.wrongContentType, `Content-Type must be ${recipients_1.BIN_TYPE} for this call.`, res, req);
|
|
31
29
|
}
|
|
32
30
|
const session = req.session;
|
|
33
31
|
const recipient = session.params.recipient;
|
|
34
32
|
const msgId = session.params.msgId;
|
|
35
33
|
if (!msgId) {
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.earlyReq, "Metadata has not been sent, yet.", res, req);
|
|
35
|
+
}
|
|
36
|
+
const { objId, objIdParseErr } = (0, utils_1.getObjIdFromParams)(req);
|
|
37
|
+
if (objIdParseErr) {
|
|
38
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, objIdParseErr, res);
|
|
38
39
|
}
|
|
39
|
-
const objId = req.params.objId;
|
|
40
40
|
// get and check Content-Length, implicitly sending replies for bad length
|
|
41
41
|
let len = getContentLenOrSendError(req, res, maxChunkSize);
|
|
42
42
|
if (len === undefined) {
|
|
43
|
-
(0, body_parsers_1.attachByteDrainToRequest)(req);
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
45
|
// extract and check query parameters
|
|
47
46
|
const opts = extractQueryOptions(req);
|
|
48
47
|
if (!opts) {
|
|
49
|
-
return
|
|
48
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Bad query parameters", res, req);
|
|
50
49
|
}
|
|
51
50
|
if (opts.fstReq) {
|
|
52
51
|
// check options versus chunk length
|
|
53
52
|
if (opts.fstReq.header > len) {
|
|
54
|
-
return
|
|
53
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Bad query parameters", res, req);
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
56
|
else if (opts.sndReq) {
|
|
58
57
|
// check options versus chunk length
|
|
59
58
|
if ((len === 0) && !opts.sndReq.last) {
|
|
60
|
-
return
|
|
59
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "No segment bytes", res, req);
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
else {
|
|
@@ -69,8 +68,7 @@ function saveMsgObj(saveObjFunc, chunkLimit) {
|
|
|
69
68
|
session.params.currentMsgLength += len;
|
|
70
69
|
}
|
|
71
70
|
else {
|
|
72
|
-
|
|
73
|
-
return;
|
|
71
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.contentTooLong, "This request goes over the message limit.", res, req);
|
|
74
72
|
}
|
|
75
73
|
try {
|
|
76
74
|
await saveObjFunc(recipient, msgId, objId, opts.fstReq, opts.sndReq, len, req);
|
|
@@ -82,24 +80,24 @@ function saveMsgObj(saveObjFunc, chunkLimit) {
|
|
|
82
80
|
next(err);
|
|
83
81
|
}
|
|
84
82
|
else if (err === recipients_1.SC.USER_UNKNOWN) {
|
|
85
|
-
|
|
83
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.server, "Recipient disappeared from the system.", res);
|
|
86
84
|
session.close();
|
|
87
85
|
}
|
|
88
86
|
else if (err === recipients_1.SC.OBJ_EXIST) {
|
|
89
|
-
|
|
87
|
+
(0, utils_1.replyWithErr)(delivery_1.msgObj.SC.objAlreadyExists, `Object ${objId} already exists.`, res);
|
|
90
88
|
}
|
|
91
89
|
else if (err === recipients_1.SC.MSG_UNKNOWN) {
|
|
92
|
-
|
|
90
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.server, "Message disappeared from the system.", res);
|
|
93
91
|
session.close();
|
|
94
92
|
}
|
|
95
93
|
else if (err === recipients_1.SC.OBJ_UNKNOWN) {
|
|
96
|
-
|
|
94
|
+
(0, utils_1.replyWithErr)(delivery_1.msgObj.SC.unknownObj, `Object ${objId} is unknown.`, res);
|
|
97
95
|
}
|
|
98
96
|
else if (err === recipients_1.SC.WRONG_OBJ_STATE) {
|
|
99
|
-
|
|
97
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, `Object ${objId} is not in a different state.`, res);
|
|
100
98
|
}
|
|
101
99
|
else if (err === recipients_1.SC.OBJ_FILE_INCOMPLETE) {
|
|
102
|
-
|
|
100
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.objIncomplete, `Object ${objId} is not complete.`, res);
|
|
103
101
|
}
|
|
104
102
|
else {
|
|
105
103
|
next(new Error(`Unhandled storage error code: ${err}`));
|
|
@@ -135,18 +133,14 @@ function extractQueryOptions(req) {
|
|
|
135
133
|
function getContentLenOrSendError(req, res, maxChunkSize) {
|
|
136
134
|
const contentLength = parseInt(req.get(delivery_1.HTTP_HEADER.contentLength));
|
|
137
135
|
if (isNaN(contentLength)) {
|
|
138
|
-
|
|
136
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.contentLenMissing, "Content-Length header is required with proper number.", res, req);
|
|
139
137
|
}
|
|
140
138
|
else if (contentLength > maxChunkSize) {
|
|
141
|
-
|
|
139
|
+
(0, utils_1.replyWithErr)(delivery_1.ERR_SC.contentTooLong, "Request body is too long.", res, req);
|
|
142
140
|
}
|
|
143
141
|
else {
|
|
144
142
|
return contentLength;
|
|
145
143
|
}
|
|
146
144
|
return;
|
|
147
145
|
}
|
|
148
|
-
function replyToMalformed(req, msg, res) {
|
|
149
|
-
(0, body_parsers_1.attachByteDrainToRequest)(req);
|
|
150
|
-
res.status(delivery_1.ERR_SC.malformed).send(msg);
|
|
151
|
-
}
|
|
152
146
|
Object.freeze(exports);
|
|
@@ -4,14 +4,10 @@ import { GenerateSession, GetSessionForMsg } from '../../resources/delivery-sess
|
|
|
4
4
|
import { Redirect } from './start-session';
|
|
5
5
|
/**
|
|
6
6
|
* This creates a session restart route handler.
|
|
7
|
-
* @param sessionGenFunc is a promise returning function that generates new
|
|
8
|
-
* session
|
|
9
|
-
* @param
|
|
10
|
-
* a
|
|
11
|
-
* @param incompleteMsgFunc is a function that promises parameters of a message
|
|
12
|
-
* that is still in delivery.
|
|
13
|
-
* @param redirectFunc is an optional function that returns a promise,
|
|
14
|
-
* resolvable to
|
|
7
|
+
* @param sessionGenFunc is a promise returning function that generates new session objects.
|
|
8
|
+
* @param sessionForMsgFunc is a function that promises existing session for a known message in delivery.
|
|
9
|
+
* @param incompleteMsgFunc is a function that promises parameters of a message that is still in delivery.
|
|
10
|
+
* @param redirectFunc is an optional function that returns a promise, resolvable to
|
|
15
11
|
* (1) string with URI for ASMail service, which is serving given recipient,
|
|
16
12
|
* (2) undefined, if it is this server should service given recipient.
|
|
17
13
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2017, 2025 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2017, 2025 - 2026 3NSoft Inc.
|
|
4
4
|
|
|
5
5
|
This program is free software: you can redistribute it and/or modify it under
|
|
6
6
|
the terms of the GNU General Public License as published by the Free Software
|
|
@@ -21,16 +21,13 @@ const recipients_1 = require("../../resources/recipients");
|
|
|
21
21
|
const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
|
|
22
22
|
const canonical_address_1 = require("../../../lib-common/canonical-address");
|
|
23
23
|
const confUtil = require("../../../lib-server/conf-util");
|
|
24
|
+
const utils_1 = require("../../resources/utils");
|
|
24
25
|
/**
|
|
25
26
|
* This creates a session restart route handler.
|
|
26
|
-
* @param sessionGenFunc is a promise returning function that generates new
|
|
27
|
-
* session
|
|
28
|
-
* @param
|
|
29
|
-
* a
|
|
30
|
-
* @param incompleteMsgFunc is a function that promises parameters of a message
|
|
31
|
-
* that is still in delivery.
|
|
32
|
-
* @param redirectFunc is an optional function that returns a promise,
|
|
33
|
-
* resolvable to
|
|
27
|
+
* @param sessionGenFunc is a promise returning function that generates new session objects.
|
|
28
|
+
* @param sessionForMsgFunc is a function that promises existing session for a known message in delivery.
|
|
29
|
+
* @param incompleteMsgFunc is a function that promises parameters of a message that is still in delivery.
|
|
30
|
+
* @param redirectFunc is an optional function that returns a promise, resolvable to
|
|
34
31
|
* (1) string with URI for ASMail service, which is serving given recipient,
|
|
35
32
|
* (2) undefined, if it is this server should service given recipient.
|
|
36
33
|
*/
|
|
@@ -69,17 +66,11 @@ function restartSession(sessionGenFunc, sessionForMsgFunc, incompleteMsgFunc, ma
|
|
|
69
66
|
}
|
|
70
67
|
// missing recipient makes a bad request
|
|
71
68
|
if (!recipient) {
|
|
72
|
-
|
|
73
|
-
error: "Recipient is either missing in the request, or is malformed"
|
|
74
|
-
});
|
|
75
|
-
return;
|
|
69
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Recipient is either missing in the request, or is malformed", res);
|
|
76
70
|
}
|
|
77
71
|
// check message id
|
|
78
72
|
if (typeof msgId !== 'string') {
|
|
79
|
-
|
|
80
|
-
error: "Message id is either missing, or is malformed"
|
|
81
|
-
});
|
|
82
|
-
return;
|
|
73
|
+
return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Message id is either missing, or is malformed", res);
|
|
83
74
|
}
|
|
84
75
|
try {
|
|
85
76
|
if (redirectFunc) {
|
|
@@ -99,14 +90,10 @@ function restartSession(sessionGenFunc, sessionForMsgFunc, incompleteMsgFunc, ma
|
|
|
99
90
|
}
|
|
100
91
|
catch (err) {
|
|
101
92
|
if (err === recipients_1.SC.USER_UNKNOWN) {
|
|
102
|
-
|
|
103
|
-
error: `Recipient ${recipient} is unknown.`
|
|
104
|
-
});
|
|
93
|
+
(0, utils_1.replyWithErr)(delivery_1.sessionRestart.SC.unknownRecipient, `Recipient ${recipient} is unknown.`, res);
|
|
105
94
|
}
|
|
106
95
|
else if (err === recipients_1.SC.MSG_UNKNOWN) {
|
|
107
|
-
|
|
108
|
-
error: `Recipient ${recipient} is unknown.`
|
|
109
|
-
});
|
|
96
|
+
(0, utils_1.replyWithErr)(delivery_1.sessionRestart.SC.unknownMsg, `Recipient ${recipient} is unknown.`, res);
|
|
110
97
|
}
|
|
111
98
|
else {
|
|
112
99
|
next(err);
|