spec-3nweb-server 1.8.5 → 1.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci-linux.yml +50 -0
- package/.gitlab-ci-mac.yml +29 -0
- package/.gitlab-ci-windows.yml +29 -0
- package/.gitlab-ci.yml +63 -0
- package/build/3nstorage/resources/store.d.ts +2 -2
- package/build/3nstorage/resources/store.js +1 -1
- package/build/3nstorage/resources/users.d.ts +3 -3
- package/build/3nstorage/resources/users.js +1 -1
- package/build/3nstorage/resources/utils.d.ts +6 -0
- package/build/3nstorage/resources/utils.js +41 -0
- package/build/3nstorage/routes/owner/archive-obj-version.js +8 -10
- package/build/3nstorage/routes/owner/cancel-trans.js +5 -4
- package/build/3nstorage/routes/owner/delete-obj.js +7 -8
- package/build/3nstorage/routes/owner/get-archived-obj-ver.js +11 -13
- package/build/3nstorage/routes/owner/get-current-obj.js +7 -6
- package/build/3nstorage/routes/owner/get-obj-status.js +8 -8
- package/build/3nstorage/routes/owner/put-current-obj.js +25 -55
- package/build/3nstorage/routes/owner/session-params.js +2 -0
- package/build/asmail/resources/utils.d.ts +6 -0
- package/build/asmail/resources/utils.js +36 -0
- package/build/asmail/routes/delivery/finalize-delivery.js +3 -2
- package/build/asmail/routes/delivery/pre-flight.js +9 -26
- package/build/asmail/routes/delivery/provide-recipient-pubkey.js +4 -3
- package/build/asmail/routes/delivery/put-metadata.js +13 -21
- package/build/asmail/routes/delivery/put-obj.js +19 -25
- package/build/asmail/routes/delivery/restart-session.d.ts +4 -8
- package/build/asmail/routes/delivery/restart-session.js +10 -23
- package/build/asmail/routes/delivery/sender-authorization.js +5 -5
- package/build/asmail/routes/delivery/start-session.js +9 -24
- package/build/asmail/routes/retrieval/get-message-meta.js +4 -7
- package/build/asmail/routes/retrieval/get-message-obj.js +10 -7
- package/build/asmail/routes/retrieval/list-messages.js +4 -4
- package/build/asmail/routes/retrieval/remove-message.js +3 -2
- package/build/mock/tls-options.js +46 -44
- package/build/tests/admin-proto/signup.d.ts +1 -0
- package/build/tests/admin-proto/signup.js +235 -0
- package/build/tests/jasmine.d.ts +1 -0
- package/build/tests/jasmine.js +32 -0
- package/build/tests/libs-for-tests/3nstorage.d.ts +22 -0
- package/build/tests/libs-for-tests/3nstorage.js +123 -0
- package/build/tests/libs-for-tests/asmail.d.ts +22 -0
- package/build/tests/libs-for-tests/asmail.js +179 -0
- package/build/tests/libs-for-tests/assert.d.ts +1 -0
- package/build/tests/libs-for-tests/assert.js +26 -0
- package/build/tests/libs-for-tests/async-jasmine.d.ts +7 -0
- package/build/tests/libs-for-tests/async-jasmine.js +77 -0
- package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/bytes-equal.js +34 -0
- package/build/tests/libs-for-tests/json-copy.d.ts +1 -0
- package/build/tests/libs-for-tests/json-copy.js +45 -0
- package/build/tests/libs-for-tests/json-equal.d.ts +4 -0
- package/build/tests/libs-for-tests/json-equal.js +67 -0
- package/build/tests/libs-for-tests/mailerid.d.ts +13 -0
- package/build/tests/libs-for-tests/mailerid.js +114 -0
- package/build/tests/libs-for-tests/pkl.d.ts +28 -0
- package/build/tests/libs-for-tests/pkl.js +89 -0
- package/build/tests/libs-for-tests/server-components/3nstorage.d.ts +20 -0
- package/build/tests/libs-for-tests/server-components/3nstorage.js +200 -0
- package/build/tests/libs-for-tests/server-components/admin.d.ts +6 -0
- package/build/tests/libs-for-tests/server-components/admin.js +43 -0
- package/build/tests/libs-for-tests/server-components/asmail.d.ts +16 -0
- package/build/tests/libs-for-tests/server-components/asmail.js +143 -0
- package/build/tests/libs-for-tests/server-components/component.d.ts +13 -0
- package/build/tests/libs-for-tests/server-components/component.js +77 -0
- package/build/tests/libs-for-tests/server-components/mailerid.d.ts +10 -0
- package/build/tests/libs-for-tests/server-components/mailerid.js +103 -0
- package/build/tests/libs-for-tests/server-runner.d.ts +15 -0
- package/build/tests/libs-for-tests/server-runner.js +69 -0
- package/build/tests/libs-for-tests/spec-assembly.d.ts +6 -0
- package/build/tests/libs-for-tests/spec-assembly.js +55 -0
- package/build/tests/libs-for-tests/ws-utils.d.ts +3 -0
- package/build/tests/libs-for-tests/ws-utils.js +59 -0
- package/build/tests/libs-for-tests/xhr-utils.d.ts +61 -0
- package/build/tests/libs-for-tests/xhr-utils.js +154 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.js +84 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.js +78 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.js +83 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.js +77 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-obj.js +75 -0
- package/build/tests/protocols/3nstorage/owner/specs/events.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/events.js +91 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.js +269 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-root.js +262 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.js +79 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-root-status.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-root-status.js +72 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.js +287 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-root.js +274 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.js +73 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.js +72 -0
- package/build/tests/protocols/3nstorage/owner/test-utils.d.ts +14 -0
- package/build/tests/protocols/3nstorage/owner/test-utils.js +54 -0
- package/build/tests/protocols/3nstorage/owner.d.ts +1 -0
- package/build/tests/protocols/3nstorage/owner.js +138 -0
- package/build/tests/protocols/asmail/config.d.ts +1 -0
- package/build/tests/protocols/asmail/config.js +117 -0
- package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.js +60 -0
- package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.js +68 -0
- package/build/tests/protocols/asmail/delivery/specs/put-metadata.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/put-metadata.js +83 -0
- package/build/tests/protocols/asmail/delivery/specs/put-obj.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/put-obj.js +123 -0
- package/build/tests/protocols/asmail/delivery/specs/restart-session.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/restart-session.js +79 -0
- package/build/tests/protocols/asmail/delivery/specs/start-session.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/start-session.js +64 -0
- package/build/tests/protocols/asmail/delivery/test-utils.d.ts +16 -0
- package/build/tests/protocols/asmail/delivery/test-utils.js +46 -0
- package/build/tests/protocols/asmail/delivery.d.ts +1 -0
- package/build/tests/protocols/asmail/delivery.js +46 -0
- package/build/tests/protocols/asmail/retrieval/specs/events.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/events.js +62 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.js +70 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.js +166 -0
- package/build/tests/protocols/asmail/retrieval/specs/list-messages.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/list-messages.js +96 -0
- package/build/tests/protocols/asmail/retrieval/specs/remove-message.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/remove-message.js +66 -0
- package/build/tests/protocols/asmail/retrieval/test-utils.d.ts +17 -0
- package/build/tests/protocols/asmail/retrieval/test-utils.js +46 -0
- package/build/tests/protocols/asmail/retrieval.d.ts +1 -0
- package/build/tests/protocols/asmail/retrieval.js +92 -0
- package/build/tests/protocols/mailerid.d.ts +1 -0
- package/build/tests/protocols/mailerid.js +210 -0
- package/build/tests/shared-checks/check-mid-login.d.ts +2 -0
- package/build/tests/shared-checks/check-mid-login.js +131 -0
- package/build/tests/shared-checks/requests.d.ts +20 -0
- package/build/tests/shared-checks/requests.js +123 -0
- package/package.json +1 -1
- package/packing/create-deb.sh +57 -0
- package/packing/deb/lib/systemd/system/3nweb.service +11 -0
- package/packing/deb/postinst +44 -0
- package/packing/deb/usr/share/doc/3nweb-server/conf-for-postinstall.yaml +19 -0
- package/packing/deb/usr/share/doc/3nweb-server/copyright +22 -0
- package/publish-task.sh +10 -0
- package/push-to-github.sh +105 -0
- package/ts-code/3nstorage/3nstorage-app.ts +99 -0
- package/ts-code/3nstorage/owner.ts +178 -0
- package/ts-code/3nstorage/resources/sessions.ts +37 -0
- package/ts-code/3nstorage/resources/store.ts +896 -0
- package/ts-code/3nstorage/resources/users.ts +258 -0
- package/ts-code/3nstorage/resources/utils.ts +45 -0
- package/ts-code/3nstorage/routes/owner/archive-obj-version.ts +71 -0
- package/ts-code/3nstorage/routes/owner/cancel-trans.ts +60 -0
- package/ts-code/3nstorage/routes/owner/delete-obj.ts +99 -0
- package/ts-code/3nstorage/routes/owner/get-archived-obj-ver.ts +109 -0
- package/ts-code/3nstorage/routes/owner/get-current-obj.ts +124 -0
- package/ts-code/3nstorage/routes/owner/get-obj-status.ts +55 -0
- package/ts-code/3nstorage/routes/owner/param-getter.ts +51 -0
- package/ts-code/3nstorage/routes/owner/param-setter.ts +50 -0
- package/ts-code/3nstorage/routes/owner/put-current-obj.ts +257 -0
- package/ts-code/3nstorage/routes/owner/session-params.ts +50 -0
- package/ts-code/3nstorage/shared.ts +43 -0
- package/ts-code/asmail/asmail-app.ts +91 -0
- package/ts-code/asmail/config.ts +96 -0
- package/ts-code/asmail/delivery.ts +94 -0
- package/ts-code/asmail/resources/delivery-sessions.ts +118 -0
- package/ts-code/asmail/resources/inbox.ts +696 -0
- package/ts-code/asmail/resources/recipients.ts +495 -0
- package/ts-code/asmail/resources/sessions.ts +37 -0
- package/ts-code/asmail/resources/utils.ts +41 -0
- package/ts-code/asmail/retrieval.ts +96 -0
- package/ts-code/asmail/routes/config/param-getter.ts +49 -0
- package/ts-code/asmail/routes/config/param-setter.ts +49 -0
- package/ts-code/asmail/routes/delivery/finalize-delivery.ts +51 -0
- package/ts-code/asmail/routes/delivery/pre-flight.ts +118 -0
- package/ts-code/asmail/routes/delivery/provide-recipient-pubkey.ts +58 -0
- package/ts-code/asmail/routes/delivery/put-metadata.ts +85 -0
- package/ts-code/asmail/routes/delivery/put-obj.ts +152 -0
- package/ts-code/asmail/routes/delivery/restart-session.ts +117 -0
- package/ts-code/asmail/routes/delivery/sender-authorization.ts +81 -0
- package/ts-code/asmail/routes/delivery/start-session.ts +136 -0
- package/ts-code/asmail/routes/retrieval/get-message-meta.ts +50 -0
- package/ts-code/asmail/routes/retrieval/get-message-obj.ts +106 -0
- package/ts-code/asmail/routes/retrieval/list-messages.ts +68 -0
- package/ts-code/asmail/routes/retrieval/remove-message.ts +48 -0
- package/ts-code/cli/index.ts +82 -0
- package/ts-code/cli/run-cmd.ts +81 -0
- package/ts-code/cli/show-sample-config.ts +78 -0
- package/ts-code/cli/signup-cmd.ts +229 -0
- package/ts-code/cli/user-cmd.ts +68 -0
- package/ts-code/cli/utils.ts +105 -0
- package/ts-code/config/default-confs.ts +22 -0
- package/ts-code/config/from-yaml.ts +35 -0
- package/ts-code/config/letsencrypt.ts +77 -0
- package/ts-code/config/signup.ts +137 -0
- package/ts-code/lib-common/admin-api/signup.ts +120 -0
- package/ts-code/lib-common/assert.ts +22 -0
- package/ts-code/lib-common/async-fs-node.ts +656 -0
- package/ts-code/lib-common/buffer-utils.ts +124 -0
- package/ts-code/lib-common/byte-streaming/common.ts +166 -0
- package/ts-code/lib-common/bytes-equal.ts +25 -0
- package/ts-code/lib-common/canonical-address.ts +92 -0
- package/ts-code/lib-common/exceptions/error.ts +44 -0
- package/ts-code/lib-common/exceptions/file.ts +84 -0
- package/ts-code/lib-common/exceptions/http.ts +69 -0
- package/ts-code/lib-common/ipc/generic-ipc.ts +750 -0
- package/ts-code/lib-common/ipc/ws-ipc.ts +117 -0
- package/ts-code/lib-common/json-equal.ts +55 -0
- package/ts-code/lib-common/json-utils.ts +130 -0
- package/ts-code/lib-common/jwkeys.ts +246 -0
- package/ts-code/lib-common/map-of-sets.ts +60 -0
- package/ts-code/lib-common/mid-sigs-NaCl-Ed.ts +677 -0
- package/ts-code/lib-common/objs-on-disk/file-layout.ts +480 -0
- package/ts-code/lib-common/objs-on-disk/obj-file.ts +325 -0
- package/ts-code/lib-common/objs-on-disk/utils.ts +201 -0
- package/ts-code/lib-common/objs-on-disk/v1-obj-file-format.ts +329 -0
- package/ts-code/lib-common/processes.ts +501 -0
- package/ts-code/lib-common/random-node.ts +79 -0
- package/ts-code/lib-common/service-api/3nstorage/owner.ts +559 -0
- package/ts-code/lib-common/service-api/3nstorage/root-route.ts +22 -0
- package/ts-code/lib-common/service-api/asmail/config.ts +144 -0
- package/ts-code/lib-common/service-api/asmail/delivery.ts +250 -0
- package/ts-code/lib-common/service-api/asmail/retrieval.ts +238 -0
- package/ts-code/lib-common/service-api/asmail/root-route.ts +22 -0
- package/ts-code/lib-common/service-api/ipc-api.ts +44 -0
- package/ts-code/lib-common/service-api/locker.ts +44 -0
- package/ts-code/lib-common/service-api/mailer-id/login.ts +80 -0
- package/ts-code/lib-common/service-api/mailer-id/provisioning.ts +64 -0
- package/ts-code/lib-common/service-api/mailer-id/root-route.ts +25 -0
- package/ts-code/lib-common/service-api/pub-key-login.ts +75 -0
- package/ts-code/lib-common/service-api/web-socket-base.ts +87 -0
- package/ts-code/lib-common/session-encryptor.ts +54 -0
- package/ts-code/lib-common/time-window-cache.ts +74 -0
- package/ts-code/lib-common/transferable.d.ts +30 -0
- package/ts-code/lib-server/conf-util.ts +35 -0
- package/ts-code/lib-server/mid-access.ts +45 -0
- package/ts-code/lib-server/middleware/body-parsers.ts +248 -0
- package/ts-code/lib-server/middleware/error-handler.ts +79 -0
- package/ts-code/lib-server/pkl-access.ts +46 -0
- package/ts-code/lib-server/resources/dns.ts +151 -0
- package/ts-code/lib-server/resources/mailerid-authorizer.ts +115 -0
- package/ts-code/lib-server/resources/mem-backed-sessions-factory.ts +132 -0
- package/ts-code/lib-server/resources/server-data-folders.ts +160 -0
- package/ts-code/lib-server/resources/server-key-for-pkl-challenge.ts +41 -0
- package/ts-code/lib-server/resources/sessions.ts +232 -0
- package/ts-code/lib-server/resources/user-files.ts +147 -0
- package/ts-code/lib-server/routes/pub-key-login/complete-exchange.ts +63 -0
- package/ts-code/lib-server/routes/pub-key-login/start-exchange.ts +189 -0
- package/ts-code/lib-server/routes/sessions/close.ts +27 -0
- package/ts-code/lib-server/routes/sessions/mid-auth.ts +77 -0
- package/ts-code/lib-server/routes/sessions/start.ts +116 -0
- package/ts-code/lib-server/web-sockets/app.ts +339 -0
- package/ts-code/lib-server/web-sockets/server-events.ts +63 -0
- package/ts-code/lib.ts +29 -0
- package/ts-code/locker/locker-app.ts +60 -0
- package/ts-code/locker/resources/lockers.ts +17 -0
- package/ts-code/locker/resources/sessions.ts +37 -0
- package/ts-code/locker/routes/create-locker.ts +47 -0
- package/ts-code/mailerId/mailerId-app.ts +107 -0
- package/ts-code/mailerId/resources/certifier.ts +181 -0
- package/ts-code/mailerId/resources/sessions.ts +44 -0
- package/ts-code/mailerId/resources/users.ts +88 -0
- package/ts-code/mailerId/routes/certify.ts +68 -0
- package/ts-code/main.ts +304 -0
- package/ts-code/mock/dns.ts +106 -0
- package/ts-code/mock/mock-as-child-proc.ts +130 -0
- package/ts-code/mock/node-child-ipc.ts +69 -0
- package/ts-code/mock/run-in-proc.ts +111 -0
- package/ts-code/mock/tls-options.ts +73 -0
- package/ts-code/services.ts +138 -0
- package/ts-code/signup/resources/users.ts +429 -0
- package/ts-code/signup/routes/add.ts +65 -0
- package/ts-code/signup/routes/get-available-addresses.ts +49 -0
- package/ts-code/signup/routes/get-available-domains.ts +45 -0
- package/ts-code/signup/signup-app.ts +54 -0
- package/ts-code/signup/signup-tokens.ts +148 -0
- package/ts-code/tests/admin-proto/signup.ts +277 -0
- package/ts-code/tests/jasmine.ts +37 -0
- package/ts-code/tests/libs-for-tests/3nstorage.ts +144 -0
- package/ts-code/tests/libs-for-tests/asmail.ts +220 -0
- package/ts-code/tests/libs-for-tests/assert.ts +22 -0
- package/ts-code/tests/libs-for-tests/async-jasmine.ts +89 -0
- package/ts-code/tests/libs-for-tests/bytes-equal.ts +25 -0
- package/ts-code/tests/libs-for-tests/json-copy.ts +38 -0
- package/ts-code/tests/libs-for-tests/json-equal.ts +55 -0
- package/ts-code/tests/libs-for-tests/mailerid.ts +123 -0
- package/ts-code/tests/libs-for-tests/pkl.ts +127 -0
- package/ts-code/tests/libs-for-tests/server-components/3nstorage.ts +206 -0
- package/ts-code/tests/libs-for-tests/server-components/admin.ts +49 -0
- package/ts-code/tests/libs-for-tests/server-components/asmail.ts +152 -0
- package/ts-code/tests/libs-for-tests/server-components/component.ts +90 -0
- package/ts-code/tests/libs-for-tests/server-components/mailerid.ts +114 -0
- package/ts-code/tests/libs-for-tests/server-runner.ts +82 -0
- package/ts-code/tests/libs-for-tests/spec-assembly.ts +60 -0
- package/ts-code/tests/libs-for-tests/ws-utils.ts +61 -0
- package/ts-code/tests/libs-for-tests/xhr-utils.ts +179 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/archive-obj-ver.ts +100 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/archive-root-ver.ts +91 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.ts +99 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.ts +90 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-obj.ts +84 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/events.ts +125 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-obj.ts +298 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-root.ts +290 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-obj-status.ts +88 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-root-status.ts +80 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-obj.ts +366 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-root.ts +329 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel-root.ts +86 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel.ts +86 -0
- package/ts-code/tests/protocols/3nstorage/owner/test-utils.ts +72 -0
- package/ts-code/tests/protocols/3nstorage/owner.ts +198 -0
- package/ts-code/tests/protocols/asmail/config.ts +172 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/finalize-delivery.ts +69 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.ts +88 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/put-metadata.ts +102 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/put-obj.ts +156 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/restart-session.ts +97 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/start-session.ts +79 -0
- package/ts-code/tests/protocols/asmail/delivery/test-utils.ts +64 -0
- package/ts-code/tests/protocols/asmail/delivery.ts +56 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/events.ts +78 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-meta.ts +80 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-obj.ts +197 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/list-messages.ts +110 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/remove-message.ts +74 -0
- package/ts-code/tests/protocols/asmail/retrieval/test-utils.ts +60 -0
- package/ts-code/tests/protocols/asmail/retrieval.ts +115 -0
- package/ts-code/tests/protocols/mailerid.ts +271 -0
- package/ts-code/tests/shared-checks/check-mid-login.ts +164 -0
- package/ts-code/tests/shared-checks/requests.ts +135 -0
- package/ts-code/tsconfig.json +11 -0
- package/ts-code/web3n.d.ts +1068 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 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.doMailerIdLogin = exports.provisionMidSigner = exports.startMidSession = exports.getMidRoot = exports.getProvPath = void 0;
|
|
20
|
+
const jwkeys_1 = require("../../lib-common/jwkeys");
|
|
21
|
+
const xhr_utils_1 = require("./xhr-utils");
|
|
22
|
+
const login_1 = require("../../lib-common/service-api/mailer-id/login");
|
|
23
|
+
const provisioning_1 = require("../../lib-common/service-api/mailer-id/provisioning");
|
|
24
|
+
const mid_sigs_NaCl_Ed_1 = require("../../lib-common/mid-sigs-NaCl-Ed");
|
|
25
|
+
const pkl_1 = require("./pkl");
|
|
26
|
+
const random_node_1 = require("../../lib-common/random-node");
|
|
27
|
+
const url_1 = require("url");
|
|
28
|
+
async function getMidData(midUrl) {
|
|
29
|
+
let reqOpts = {
|
|
30
|
+
url: midUrl,
|
|
31
|
+
method: 'GET',
|
|
32
|
+
responseType: 'json'
|
|
33
|
+
};
|
|
34
|
+
let rep = await (0, xhr_utils_1.doBodylessRequest)(reqOpts);
|
|
35
|
+
expect(rep.status).toBe(200);
|
|
36
|
+
return rep.data;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @param midUrl
|
|
40
|
+
* @return a promise, resolvable to MailerId service's provisioning url.
|
|
41
|
+
*/
|
|
42
|
+
async function getProvPath(midUrl) {
|
|
43
|
+
let midData = await getMidData(midUrl);
|
|
44
|
+
let prov = midData['provisioning'];
|
|
45
|
+
expect(typeof prov).toBe('string');
|
|
46
|
+
// return url with provision path
|
|
47
|
+
let pathStarts = midUrl.indexOf('/', midUrl.indexOf('://') + 3);
|
|
48
|
+
return midUrl.substring(0, pathStarts) + prov;
|
|
49
|
+
}
|
|
50
|
+
exports.getProvPath = getProvPath;
|
|
51
|
+
async function getMidRoot(midUrl) {
|
|
52
|
+
let midData = await getMidData(midUrl);
|
|
53
|
+
let rootCert = midData["current-cert"];
|
|
54
|
+
expect((0, jwkeys_1.isLikeSignedKeyCert)(rootCert)).toBe(true);
|
|
55
|
+
return rootCert;
|
|
56
|
+
}
|
|
57
|
+
exports.getMidRoot = getMidRoot;
|
|
58
|
+
async function startMidSession(loginUrl, userId) {
|
|
59
|
+
let reqOpts = {
|
|
60
|
+
url: loginUrl + login_1.startSession.URL_END,
|
|
61
|
+
method: 'POST',
|
|
62
|
+
responseType: 'json'
|
|
63
|
+
};
|
|
64
|
+
let req = { userId };
|
|
65
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
66
|
+
expect(rep.status).toBe(login_1.startSession.SC.ok);
|
|
67
|
+
return rep.data.sessionId;
|
|
68
|
+
}
|
|
69
|
+
exports.startMidSession = startMidSession;
|
|
70
|
+
async function provisionMidSigner(midServiceUrl, user) {
|
|
71
|
+
let provUrl = await getProvPath(midServiceUrl);
|
|
72
|
+
let sessParams = await (0, pkl_1.doPubKeyLogin)(provUrl, user);
|
|
73
|
+
let reqOpts = {
|
|
74
|
+
url: provUrl + provisioning_1.certify.URL_END,
|
|
75
|
+
method: 'POST',
|
|
76
|
+
sessionId: sessParams.sessionId,
|
|
77
|
+
responseType: 'arraybuffer'
|
|
78
|
+
};
|
|
79
|
+
let midSigningPair = mid_sigs_NaCl_Ed_1.user.generateSigningKeyPair(random_node_1.bytesSync);
|
|
80
|
+
let reqData = {
|
|
81
|
+
pkey: midSigningPair.pkey,
|
|
82
|
+
duration: 12 * 60 * 60
|
|
83
|
+
};
|
|
84
|
+
let encrBody = sessParams.sessEncr.packJSON(reqData);
|
|
85
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, encrBody);
|
|
86
|
+
expect(rep.status).toBe(provisioning_1.certify.SC.ok);
|
|
87
|
+
let repData = sessParams.sessEncr.openJSON(rep.data);
|
|
88
|
+
return mid_sigs_NaCl_Ed_1.user.makeMailerIdSigner(midSigningPair.skey, repData.userCert, repData.provCert);
|
|
89
|
+
}
|
|
90
|
+
exports.provisionMidSigner = provisionMidSigner;
|
|
91
|
+
async function doMailerIdLogin(loginUrl, user) {
|
|
92
|
+
let sessionId = await startMidSession(loginUrl, user.id);
|
|
93
|
+
let midSigner = await provisionMidSigner(user.midUrl, user);
|
|
94
|
+
let reqOpts = {
|
|
95
|
+
url: loginUrl + login_1.authSession.URL_END,
|
|
96
|
+
method: 'POST',
|
|
97
|
+
responseType: 'json',
|
|
98
|
+
sessionId
|
|
99
|
+
};
|
|
100
|
+
let serviceDomain = (0, url_1.parse)(loginUrl).hostname;
|
|
101
|
+
if (!serviceDomain) {
|
|
102
|
+
throw new Error(`Cannot parse hostname from login url ${loginUrl}`);
|
|
103
|
+
}
|
|
104
|
+
let req = {
|
|
105
|
+
assertion: midSigner.generateAssertionFor(serviceDomain, sessionId),
|
|
106
|
+
provCert: midSigner.providerCert,
|
|
107
|
+
userCert: midSigner.userCert
|
|
108
|
+
};
|
|
109
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
110
|
+
expect(rep.status).toBe(login_1.authSession.SC.ok);
|
|
111
|
+
return sessionId;
|
|
112
|
+
}
|
|
113
|
+
exports.doMailerIdLogin = doMailerIdLogin;
|
|
114
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as pklApi from '../../lib-common/service-api/pub-key-login';
|
|
2
|
+
import { SessionEncryptor } from '../../lib-common/session-encryptor';
|
|
3
|
+
export interface User {
|
|
4
|
+
id: string;
|
|
5
|
+
loginDefaultSKey: Uint8Array;
|
|
6
|
+
loginLabeledSKey: {
|
|
7
|
+
kid: string;
|
|
8
|
+
k: Uint8Array;
|
|
9
|
+
};
|
|
10
|
+
midUrl: string;
|
|
11
|
+
storageOwnerUrl: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ExchangeCrypto {
|
|
14
|
+
sessEncr: SessionEncryptor;
|
|
15
|
+
serverVerificationBytes: Uint8Array;
|
|
16
|
+
encResponse: Uint8Array;
|
|
17
|
+
}
|
|
18
|
+
export declare function decryptSessionParamsForCurve25519(r: pklApi.start.Reply, loginSKey: Uint8Array): ExchangeCrypto;
|
|
19
|
+
export interface ExchangeParams {
|
|
20
|
+
crypto: ExchangeCrypto;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function startPKLSession(loginUrl: string, user: User, useDefaultKey: boolean): Promise<ExchangeParams>;
|
|
24
|
+
export interface SessionParams {
|
|
25
|
+
sessEncr: SessionEncryptor;
|
|
26
|
+
sessionId: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function doPubKeyLogin(loginUrl: string, user: User): Promise<SessionParams>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 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.doPubKeyLogin = exports.startPKLSession = exports.decryptSessionParamsForCurve25519 = void 0;
|
|
20
|
+
const pklApi = require("../../lib-common/service-api/pub-key-login");
|
|
21
|
+
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
22
|
+
const ecma_nacl_1 = require("ecma-nacl");
|
|
23
|
+
const session_encryptor_1 = require("../../lib-common/session-encryptor");
|
|
24
|
+
const xhr_utils_1 = require("./xhr-utils");
|
|
25
|
+
const url_1 = require("url");
|
|
26
|
+
const bytes_equal_1 = require("./bytes-equal");
|
|
27
|
+
function decryptSessionParamsForCurve25519(r, loginSKey) {
|
|
28
|
+
let serverPKey = buffer_utils_1.base64.open(r.serverPubKey);
|
|
29
|
+
expect(serverPKey.length).toBe(ecma_nacl_1.box.KEY_LENGTH);
|
|
30
|
+
let sharedKey = ecma_nacl_1.box.calc_dhshared_key(serverPKey, loginSKey);
|
|
31
|
+
let encChallenge = buffer_utils_1.base64.open(r.sessionKey);
|
|
32
|
+
expect(encChallenge.length).toBe(ecma_nacl_1.secret_box.NONCE_LENGTH + ecma_nacl_1.secret_box.KEY_LENGTH);
|
|
33
|
+
let nonce = encChallenge.subarray(0, ecma_nacl_1.secret_box.NONCE_LENGTH);
|
|
34
|
+
let zeros = new Uint8Array(ecma_nacl_1.secret_box.KEY_LENGTH);
|
|
35
|
+
let stream = ecma_nacl_1.secret_box.pack(zeros, nonce, sharedKey).subarray(ecma_nacl_1.secret_box.POLY_LENGTH);
|
|
36
|
+
let sessionKey = new Uint8Array(encChallenge.subarray(ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
37
|
+
for (var i = 0; i < ecma_nacl_1.secret_box.KEY_LENGTH; i += 1) {
|
|
38
|
+
sessionKey[i] ^= stream[i];
|
|
39
|
+
}
|
|
40
|
+
let serverVerificationBytes = ecma_nacl_1.secret_box.pack(sessionKey, nonce, sharedKey)
|
|
41
|
+
.subarray(0, ecma_nacl_1.secret_box.POLY_LENGTH);
|
|
42
|
+
ecma_nacl_1.nonce.advanceOddly(nonce);
|
|
43
|
+
let sessEncr = (0, session_encryptor_1.makeSessionEncryptor)(sessionKey, nonce);
|
|
44
|
+
let encResponse = sessEncr.pack(sessionKey);
|
|
45
|
+
ecma_nacl_1.arrays.wipe(sessionKey);
|
|
46
|
+
return { sessEncr, serverVerificationBytes, encResponse };
|
|
47
|
+
}
|
|
48
|
+
exports.decryptSessionParamsForCurve25519 = decryptSessionParamsForCurve25519;
|
|
49
|
+
async function startPKLSession(loginUrl, user, useDefaultKey) {
|
|
50
|
+
let reqOpts = {
|
|
51
|
+
url: (0, url_1.resolve)(loginUrl, pklApi.start.URL_END),
|
|
52
|
+
method: 'POST',
|
|
53
|
+
responseType: 'json'
|
|
54
|
+
};
|
|
55
|
+
let req = (useDefaultKey ?
|
|
56
|
+
{ userId: user.id } :
|
|
57
|
+
{ userId: user.id, kid: user.loginLabeledSKey.kid });
|
|
58
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
59
|
+
expect(rep.status).toBe(pklApi.start.SC.ok);
|
|
60
|
+
let skey = (useDefaultKey ? user.loginDefaultSKey : user.loginLabeledSKey.k);
|
|
61
|
+
return {
|
|
62
|
+
sessionId: rep.data.sessionId,
|
|
63
|
+
crypto: decryptSessionParamsForCurve25519(rep.data, skey)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
exports.startPKLSession = startPKLSession;
|
|
67
|
+
async function validatePKLSession(loginUrl, exchangeParams) {
|
|
68
|
+
let reqOpts = {
|
|
69
|
+
url: (0, url_1.resolve)(loginUrl, pklApi.complete.URL_END),
|
|
70
|
+
method: 'POST',
|
|
71
|
+
sessionId: exchangeParams.sessionId,
|
|
72
|
+
responseType: 'arraybuffer'
|
|
73
|
+
};
|
|
74
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, exchangeParams.crypto.encResponse);
|
|
75
|
+
expect(rep.status).toBe(pklApi.complete.SC.ok);
|
|
76
|
+
expect(rep.data.length).toBe(ecma_nacl_1.secret_box.POLY_LENGTH);
|
|
77
|
+
expect((0, bytes_equal_1.bytesEqual)(rep.data, exchangeParams.crypto.serverVerificationBytes))
|
|
78
|
+
.toBe(true);
|
|
79
|
+
return {
|
|
80
|
+
sessionId: exchangeParams.sessionId,
|
|
81
|
+
sessEncr: exchangeParams.crypto.sessEncr
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async function doPubKeyLogin(loginUrl, user) {
|
|
85
|
+
let exchangeParams = await startPKLSession(loginUrl, user, false);
|
|
86
|
+
return validatePKLSession(loginUrl, exchangeParams);
|
|
87
|
+
}
|
|
88
|
+
exports.doPubKeyLogin = doPubKeyLogin;
|
|
89
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component } from './component';
|
|
2
|
+
import { User } from '../pkl';
|
|
3
|
+
import { Obj } from '../3nstorage';
|
|
4
|
+
export declare class StorageComponent 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 storageUrl(): string;
|
|
10
|
+
getStorageOwnerUrl(): Promise<string>;
|
|
11
|
+
private storeFolder;
|
|
12
|
+
private checkTransactionPresence;
|
|
13
|
+
rootTransactionExists(userId: string, transactionId?: string): Promise<boolean>;
|
|
14
|
+
transactionExists(userId: string, objId: string, transactionId?: string): Promise<boolean>;
|
|
15
|
+
private checkCurrentObjPresence;
|
|
16
|
+
currentRootObjExists(userId: string, ver?: number, obj?: Obj): Promise<boolean>;
|
|
17
|
+
currentObjExists(userId: string, objId: string, ver?: number, obj?: Obj): Promise<boolean>;
|
|
18
|
+
clearStorage(userId: string): Promise<void>;
|
|
19
|
+
restartAndClearStorageFor(userId: string): Promise<void>;
|
|
20
|
+
}
|
|
@@ -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
|
+
}
|