spec-3nweb-server 1.8.4 → 1.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci-linux.yml +50 -0
- package/.gitlab-ci-mac.yml +29 -0
- package/.gitlab-ci-windows.yml +29 -0
- package/.gitlab-ci.yml +63 -0
- package/build/3nstorage/routes/owner/archive-obj-version.js +2 -2
- package/build/3nstorage/routes/owner/cancel-trans.js +2 -2
- package/build/3nstorage/routes/owner/delete-obj.js +2 -2
- package/build/3nstorage/routes/owner/get-current-obj.js +3 -4
- package/build/3nstorage/routes/owner/param-setter.js +2 -6
- package/build/asmail/routes/config/param-setter.js +2 -2
- package/build/asmail/routes/delivery/finalize-delivery.js +2 -2
- package/build/asmail/routes/delivery/put-obj.js +2 -2
- package/build/asmail/routes/delivery/sender-authorization.js +2 -2
- package/build/asmail/routes/retrieval/remove-message.js +2 -2
- package/build/cli/signup-cmd.js +0 -1
- package/build/lib-server/routes/sessions/close.js +2 -2
- package/build/lib-server/routes/sessions/mid-auth.js +2 -5
- package/build/main.js +12 -15
- package/build/mock/tls-options.js +46 -44
- package/build/signup/routes/add.js +4 -4
- package/build/tests/admin-proto/signup.d.ts +1 -0
- package/build/tests/admin-proto/signup.js +235 -0
- package/build/tests/jasmine.d.ts +1 -0
- package/build/tests/jasmine.js +32 -0
- package/build/tests/libs-for-tests/3nstorage.d.ts +22 -0
- package/build/tests/libs-for-tests/3nstorage.js +123 -0
- package/build/tests/libs-for-tests/asmail.d.ts +22 -0
- package/build/tests/libs-for-tests/asmail.js +179 -0
- package/build/tests/libs-for-tests/assert.d.ts +1 -0
- package/build/tests/libs-for-tests/assert.js +26 -0
- package/build/tests/libs-for-tests/async-jasmine.d.ts +7 -0
- package/build/tests/libs-for-tests/async-jasmine.js +77 -0
- package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/bytes-equal.js +34 -0
- package/build/tests/libs-for-tests/json-copy.d.ts +1 -0
- package/build/tests/libs-for-tests/json-copy.js +45 -0
- package/build/tests/libs-for-tests/json-equal.d.ts +4 -0
- package/build/tests/libs-for-tests/json-equal.js +67 -0
- package/build/tests/libs-for-tests/mailerid.d.ts +13 -0
- package/build/tests/libs-for-tests/mailerid.js +114 -0
- package/build/tests/libs-for-tests/pkl.d.ts +28 -0
- package/build/tests/libs-for-tests/pkl.js +89 -0
- package/build/tests/libs-for-tests/server-components/3nstorage.d.ts +20 -0
- package/build/tests/libs-for-tests/server-components/3nstorage.js +200 -0
- package/build/tests/libs-for-tests/server-components/admin.d.ts +6 -0
- package/build/tests/libs-for-tests/server-components/admin.js +43 -0
- package/build/tests/libs-for-tests/server-components/asmail.d.ts +16 -0
- package/build/tests/libs-for-tests/server-components/asmail.js +143 -0
- package/build/tests/libs-for-tests/server-components/component.d.ts +13 -0
- package/build/tests/libs-for-tests/server-components/component.js +77 -0
- package/build/tests/libs-for-tests/server-components/mailerid.d.ts +10 -0
- package/build/tests/libs-for-tests/server-components/mailerid.js +103 -0
- package/build/tests/libs-for-tests/server-runner.d.ts +15 -0
- package/build/tests/libs-for-tests/server-runner.js +69 -0
- package/build/tests/libs-for-tests/spec-assembly.d.ts +6 -0
- package/build/tests/libs-for-tests/spec-assembly.js +55 -0
- package/build/tests/libs-for-tests/ws-utils.d.ts +3 -0
- package/build/tests/libs-for-tests/ws-utils.js +59 -0
- package/build/tests/libs-for-tests/xhr-utils.d.ts +61 -0
- package/build/tests/libs-for-tests/xhr-utils.js +154 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.js +84 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.js +78 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.js +83 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.js +77 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/delete-obj.js +75 -0
- package/build/tests/protocols/3nstorage/owner/specs/events.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/events.js +91 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.js +269 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-current-root.js +262 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.js +79 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-root-status.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/get-root-status.js +72 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.js +287 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/put-current-root.js +274 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.js +73 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.d.ts +2 -0
- package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.js +72 -0
- package/build/tests/protocols/3nstorage/owner/test-utils.d.ts +14 -0
- package/build/tests/protocols/3nstorage/owner/test-utils.js +54 -0
- package/build/tests/protocols/3nstorage/owner.d.ts +1 -0
- package/build/tests/protocols/3nstorage/owner.js +138 -0
- package/build/tests/protocols/asmail/config.d.ts +1 -0
- package/build/tests/protocols/asmail/config.js +117 -0
- package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.js +60 -0
- package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.js +68 -0
- package/build/tests/protocols/asmail/delivery/specs/put-metadata.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/put-metadata.js +83 -0
- package/build/tests/protocols/asmail/delivery/specs/put-obj.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/put-obj.js +123 -0
- package/build/tests/protocols/asmail/delivery/specs/restart-session.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/restart-session.js +79 -0
- package/build/tests/protocols/asmail/delivery/specs/start-session.d.ts +2 -0
- package/build/tests/protocols/asmail/delivery/specs/start-session.js +64 -0
- package/build/tests/protocols/asmail/delivery/test-utils.d.ts +16 -0
- package/build/tests/protocols/asmail/delivery/test-utils.js +46 -0
- package/build/tests/protocols/asmail/delivery.d.ts +1 -0
- package/build/tests/protocols/asmail/delivery.js +46 -0
- package/build/tests/protocols/asmail/retrieval/specs/events.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/events.js +62 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.js +70 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.js +166 -0
- package/build/tests/protocols/asmail/retrieval/specs/list-messages.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/list-messages.js +96 -0
- package/build/tests/protocols/asmail/retrieval/specs/remove-message.d.ts +2 -0
- package/build/tests/protocols/asmail/retrieval/specs/remove-message.js +66 -0
- package/build/tests/protocols/asmail/retrieval/test-utils.d.ts +17 -0
- package/build/tests/protocols/asmail/retrieval/test-utils.js +46 -0
- package/build/tests/protocols/asmail/retrieval.d.ts +1 -0
- package/build/tests/protocols/asmail/retrieval.js +92 -0
- package/build/tests/protocols/mailerid.d.ts +1 -0
- package/build/tests/protocols/mailerid.js +210 -0
- package/build/tests/shared-checks/check-mid-login.d.ts +2 -0
- package/build/tests/shared-checks/check-mid-login.js +131 -0
- package/build/tests/shared-checks/requests.d.ts +20 -0
- package/build/tests/shared-checks/requests.js +123 -0
- package/package.json +1 -1
- package/packing/create-deb.sh +57 -0
- package/packing/deb/lib/systemd/system/3nweb.service +11 -0
- package/packing/deb/postinst +44 -0
- package/packing/deb/usr/share/doc/3nweb-server/conf-for-postinstall.yaml +19 -0
- package/packing/deb/usr/share/doc/3nweb-server/copyright +22 -0
- package/publish-task.sh +10 -0
- package/push-to-github.sh +105 -0
- package/ts-code/3nstorage/3nstorage-app.ts +99 -0
- package/ts-code/3nstorage/owner.ts +178 -0
- package/ts-code/3nstorage/resources/sessions.ts +37 -0
- package/ts-code/3nstorage/resources/store.ts +896 -0
- package/ts-code/3nstorage/resources/users.ts +258 -0
- package/ts-code/3nstorage/routes/owner/archive-obj-version.ts +73 -0
- package/ts-code/3nstorage/routes/owner/cancel-trans.ts +58 -0
- package/ts-code/3nstorage/routes/owner/delete-obj.ts +103 -0
- package/ts-code/3nstorage/routes/owner/get-archived-obj-ver.ts +111 -0
- package/ts-code/3nstorage/routes/owner/get-current-obj.ts +122 -0
- package/ts-code/3nstorage/routes/owner/get-obj-status.ts +55 -0
- package/ts-code/3nstorage/routes/owner/param-getter.ts +51 -0
- package/ts-code/3nstorage/routes/owner/param-setter.ts +50 -0
- package/ts-code/3nstorage/routes/owner/put-current-obj.ts +284 -0
- package/ts-code/3nstorage/routes/owner/session-params.ts +49 -0
- package/ts-code/3nstorage/shared.ts +43 -0
- package/ts-code/asmail/asmail-app.ts +91 -0
- package/ts-code/asmail/config.ts +96 -0
- package/ts-code/asmail/delivery.ts +94 -0
- package/ts-code/asmail/resources/delivery-sessions.ts +118 -0
- package/ts-code/asmail/resources/inbox.ts +696 -0
- package/ts-code/asmail/resources/recipients.ts +495 -0
- package/ts-code/asmail/resources/sessions.ts +37 -0
- package/ts-code/asmail/retrieval.ts +96 -0
- package/ts-code/asmail/routes/config/param-getter.ts +49 -0
- package/ts-code/asmail/routes/config/param-setter.ts +49 -0
- package/ts-code/asmail/routes/delivery/finalize-delivery.ts +50 -0
- package/ts-code/asmail/routes/delivery/pre-flight.ts +132 -0
- package/ts-code/asmail/routes/delivery/provide-recipient-pubkey.ts +58 -0
- package/ts-code/asmail/routes/delivery/put-metadata.ts +94 -0
- package/ts-code/asmail/routes/delivery/put-obj.ts +166 -0
- package/ts-code/asmail/routes/delivery/restart-session.ts +130 -0
- package/ts-code/asmail/routes/delivery/sender-authorization.ts +81 -0
- package/ts-code/asmail/routes/delivery/start-session.ts +151 -0
- package/ts-code/asmail/routes/retrieval/get-message-meta.ts +53 -0
- package/ts-code/asmail/routes/retrieval/get-message-obj.ts +109 -0
- package/ts-code/asmail/routes/retrieval/list-messages.ts +70 -0
- package/ts-code/asmail/routes/retrieval/remove-message.ts +47 -0
- package/ts-code/cli/index.ts +82 -0
- package/ts-code/cli/run-cmd.ts +81 -0
- package/ts-code/cli/show-sample-config.ts +78 -0
- package/ts-code/cli/signup-cmd.ts +229 -0
- package/ts-code/cli/user-cmd.ts +68 -0
- package/ts-code/cli/utils.ts +105 -0
- package/ts-code/config/default-confs.ts +22 -0
- package/ts-code/config/from-yaml.ts +35 -0
- package/ts-code/config/letsencrypt.ts +77 -0
- package/ts-code/config/signup.ts +137 -0
- package/ts-code/lib-common/admin-api/signup.ts +120 -0
- package/ts-code/lib-common/assert.ts +22 -0
- package/ts-code/lib-common/async-fs-node.ts +656 -0
- package/ts-code/lib-common/buffer-utils.ts +124 -0
- package/ts-code/lib-common/byte-streaming/common.ts +166 -0
- package/ts-code/lib-common/bytes-equal.ts +25 -0
- package/ts-code/lib-common/canonical-address.ts +92 -0
- package/ts-code/lib-common/exceptions/error.ts +44 -0
- package/ts-code/lib-common/exceptions/file.ts +84 -0
- package/ts-code/lib-common/exceptions/http.ts +69 -0
- package/ts-code/lib-common/ipc/generic-ipc.ts +750 -0
- package/ts-code/lib-common/ipc/ws-ipc.ts +117 -0
- package/ts-code/lib-common/json-equal.ts +55 -0
- package/ts-code/lib-common/json-utils.ts +130 -0
- package/ts-code/lib-common/jwkeys.ts +246 -0
- package/ts-code/lib-common/map-of-sets.ts +60 -0
- package/ts-code/lib-common/mid-sigs-NaCl-Ed.ts +677 -0
- package/ts-code/lib-common/objs-on-disk/file-layout.ts +480 -0
- package/ts-code/lib-common/objs-on-disk/obj-file.ts +325 -0
- package/ts-code/lib-common/objs-on-disk/utils.ts +201 -0
- package/ts-code/lib-common/objs-on-disk/v1-obj-file-format.ts +329 -0
- package/ts-code/lib-common/processes.ts +501 -0
- package/ts-code/lib-common/random-node.ts +79 -0
- package/ts-code/lib-common/service-api/3nstorage/owner.ts +559 -0
- package/ts-code/lib-common/service-api/3nstorage/root-route.ts +22 -0
- package/ts-code/lib-common/service-api/asmail/config.ts +144 -0
- package/ts-code/lib-common/service-api/asmail/delivery.ts +250 -0
- package/ts-code/lib-common/service-api/asmail/retrieval.ts +238 -0
- package/ts-code/lib-common/service-api/asmail/root-route.ts +22 -0
- package/ts-code/lib-common/service-api/ipc-api.ts +44 -0
- package/ts-code/lib-common/service-api/locker.ts +44 -0
- package/ts-code/lib-common/service-api/mailer-id/login.ts +80 -0
- package/ts-code/lib-common/service-api/mailer-id/provisioning.ts +64 -0
- package/ts-code/lib-common/service-api/mailer-id/root-route.ts +25 -0
- package/ts-code/lib-common/service-api/pub-key-login.ts +75 -0
- package/ts-code/lib-common/service-api/web-socket-base.ts +87 -0
- package/ts-code/lib-common/session-encryptor.ts +54 -0
- package/ts-code/lib-common/time-window-cache.ts +74 -0
- package/ts-code/lib-common/transferable.d.ts +30 -0
- package/ts-code/lib-server/conf-util.ts +35 -0
- package/ts-code/lib-server/mid-access.ts +45 -0
- package/ts-code/lib-server/middleware/body-parsers.ts +248 -0
- package/ts-code/lib-server/middleware/error-handler.ts +79 -0
- package/ts-code/lib-server/pkl-access.ts +46 -0
- package/ts-code/lib-server/resources/dns.ts +151 -0
- package/ts-code/lib-server/resources/mailerid-authorizer.ts +115 -0
- package/ts-code/lib-server/resources/mem-backed-sessions-factory.ts +132 -0
- package/ts-code/lib-server/resources/server-data-folders.ts +160 -0
- package/ts-code/lib-server/resources/server-key-for-pkl-challenge.ts +41 -0
- package/ts-code/lib-server/resources/sessions.ts +232 -0
- package/ts-code/lib-server/resources/user-files.ts +147 -0
- package/ts-code/lib-server/routes/pub-key-login/complete-exchange.ts +63 -0
- package/ts-code/lib-server/routes/pub-key-login/start-exchange.ts +189 -0
- package/ts-code/lib-server/routes/sessions/close.ts +27 -0
- package/ts-code/lib-server/routes/sessions/mid-auth.ts +77 -0
- package/ts-code/lib-server/routes/sessions/start.ts +116 -0
- package/ts-code/lib-server/web-sockets/app.ts +339 -0
- package/ts-code/lib-server/web-sockets/server-events.ts +63 -0
- package/ts-code/lib.ts +29 -0
- package/ts-code/locker/locker-app.ts +60 -0
- package/ts-code/locker/resources/lockers.ts +17 -0
- package/ts-code/locker/resources/sessions.ts +37 -0
- package/ts-code/locker/routes/create-locker.ts +47 -0
- package/ts-code/mailerId/mailerId-app.ts +107 -0
- package/ts-code/mailerId/resources/certifier.ts +181 -0
- package/ts-code/mailerId/resources/sessions.ts +44 -0
- package/ts-code/mailerId/resources/users.ts +88 -0
- package/ts-code/mailerId/routes/certify.ts +68 -0
- package/ts-code/main.ts +304 -0
- package/ts-code/mock/dns.ts +106 -0
- package/ts-code/mock/mock-as-child-proc.ts +130 -0
- package/ts-code/mock/node-child-ipc.ts +69 -0
- package/ts-code/mock/run-in-proc.ts +111 -0
- package/ts-code/mock/tls-options.ts +73 -0
- package/ts-code/services.ts +138 -0
- package/ts-code/signup/resources/users.ts +429 -0
- package/ts-code/signup/routes/add.ts +65 -0
- package/ts-code/signup/routes/get-available-addresses.ts +49 -0
- package/ts-code/signup/routes/get-available-domains.ts +45 -0
- package/ts-code/signup/signup-app.ts +54 -0
- package/ts-code/signup/signup-tokens.ts +148 -0
- package/ts-code/tests/admin-proto/signup.ts +277 -0
- package/ts-code/tests/jasmine.ts +37 -0
- package/ts-code/tests/libs-for-tests/3nstorage.ts +144 -0
- package/ts-code/tests/libs-for-tests/asmail.ts +220 -0
- package/ts-code/tests/libs-for-tests/assert.ts +22 -0
- package/ts-code/tests/libs-for-tests/async-jasmine.ts +89 -0
- package/ts-code/tests/libs-for-tests/bytes-equal.ts +25 -0
- package/ts-code/tests/libs-for-tests/json-copy.ts +38 -0
- package/ts-code/tests/libs-for-tests/json-equal.ts +55 -0
- package/ts-code/tests/libs-for-tests/mailerid.ts +123 -0
- package/ts-code/tests/libs-for-tests/pkl.ts +127 -0
- package/ts-code/tests/libs-for-tests/server-components/3nstorage.ts +206 -0
- package/ts-code/tests/libs-for-tests/server-components/admin.ts +49 -0
- package/ts-code/tests/libs-for-tests/server-components/asmail.ts +152 -0
- package/ts-code/tests/libs-for-tests/server-components/component.ts +90 -0
- package/ts-code/tests/libs-for-tests/server-components/mailerid.ts +114 -0
- package/ts-code/tests/libs-for-tests/server-runner.ts +82 -0
- package/ts-code/tests/libs-for-tests/spec-assembly.ts +60 -0
- package/ts-code/tests/libs-for-tests/ws-utils.ts +61 -0
- package/ts-code/tests/libs-for-tests/xhr-utils.ts +179 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/archive-obj-ver.ts +100 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/archive-root-ver.ts +91 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.ts +99 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.ts +90 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/delete-obj.ts +84 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/events.ts +125 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-obj.ts +298 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-root.ts +290 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-obj-status.ts +88 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/get-root-status.ts +80 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-obj.ts +366 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-root.ts +329 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel-root.ts +86 -0
- package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel.ts +86 -0
- package/ts-code/tests/protocols/3nstorage/owner/test-utils.ts +72 -0
- package/ts-code/tests/protocols/3nstorage/owner.ts +198 -0
- package/ts-code/tests/protocols/asmail/config.ts +172 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/finalize-delivery.ts +69 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.ts +88 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/put-metadata.ts +102 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/put-obj.ts +156 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/restart-session.ts +97 -0
- package/ts-code/tests/protocols/asmail/delivery/specs/start-session.ts +79 -0
- package/ts-code/tests/protocols/asmail/delivery/test-utils.ts +64 -0
- package/ts-code/tests/protocols/asmail/delivery.ts +56 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/events.ts +78 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-meta.ts +80 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-obj.ts +197 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/list-messages.ts +110 -0
- package/ts-code/tests/protocols/asmail/retrieval/specs/remove-message.ts +74 -0
- package/ts-code/tests/protocols/asmail/retrieval/test-utils.ts +60 -0
- package/ts-code/tests/protocols/asmail/retrieval.ts +115 -0
- package/ts-code/tests/protocols/mailerid.ts +271 -0
- package/ts-code/tests/shared-checks/check-mid-login.ts +164 -0
- package/ts-code/tests/shared-checks/requests.ts +135 -0
- package/ts-code/tsconfig.json +11 -0
- package/ts-code/web3n.d.ts +1068 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 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
|
+
const async_jasmine_1 = require("../libs-for-tests/async-jasmine");
|
|
20
|
+
const mailerid_1 = require("../libs-for-tests/server-components/mailerid");
|
|
21
|
+
const mailerid_2 = require("../libs-for-tests/mailerid");
|
|
22
|
+
const xhr_utils_1 = require("../libs-for-tests/xhr-utils");
|
|
23
|
+
const provisioning_1 = require("../../lib-common/service-api/mailer-id/provisioning");
|
|
24
|
+
const pklApi = require("../../lib-common/service-api/pub-key-login");
|
|
25
|
+
const jwkeys_1 = require("../../lib-common/jwkeys");
|
|
26
|
+
const requests_1 = require("../shared-checks/requests");
|
|
27
|
+
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
28
|
+
const ecma_nacl_1 = require("ecma-nacl");
|
|
29
|
+
const pkl_1 = require("../libs-for-tests/pkl");
|
|
30
|
+
const mid_sigs_NaCl_Ed_1 = require("../../lib-common/mid-sigs-NaCl-Ed");
|
|
31
|
+
const random_node_1 = require("../../lib-common/random-node");
|
|
32
|
+
const canonical_address_1 = require("../../lib-common/canonical-address");
|
|
33
|
+
const json_equal_1 = require("../libs-for-tests/json-equal");
|
|
34
|
+
const bytes_equal_1 = require("../libs-for-tests/bytes-equal");
|
|
35
|
+
describe('MailerId', () => {
|
|
36
|
+
let midServer;
|
|
37
|
+
const midServiceDomain = 'mailerid.service.domain';
|
|
38
|
+
const signupDomains = ['company.inc', 'personal.net'];
|
|
39
|
+
let user1;
|
|
40
|
+
let user2;
|
|
41
|
+
(0, async_jasmine_1.beforeAllAsync)(async () => {
|
|
42
|
+
midServer = new mailerid_1.MailerIdComponent(signupDomains, midServiceDomain);
|
|
43
|
+
await midServer.start();
|
|
44
|
+
user1 = await midServer.addUser(`Bob Johnson @${signupDomains[0]}`);
|
|
45
|
+
user2 = await midServer.addUser(`William Young @${signupDomains[1]}`);
|
|
46
|
+
});
|
|
47
|
+
(0, async_jasmine_1.afterAllAsync)(async () => {
|
|
48
|
+
await midServer.stop();
|
|
49
|
+
midServer = undefined;
|
|
50
|
+
});
|
|
51
|
+
(0, async_jasmine_1.itAsync)('provides root certificates', async () => {
|
|
52
|
+
let reqOpts = {
|
|
53
|
+
url: midServer.midUrl,
|
|
54
|
+
method: 'GET',
|
|
55
|
+
responseType: 'json'
|
|
56
|
+
};
|
|
57
|
+
let rep = await (0, xhr_utils_1.doBodylessRequest)(reqOpts);
|
|
58
|
+
expect(rep.status).withContext('status code for OK reply').toBe(200);
|
|
59
|
+
expect(Array.isArray(rep.data["previous-certs"])).toBe(true);
|
|
60
|
+
expect((0, jwkeys_1.isLikeSignedKeyCert)(rep.data["current-cert"])).toBe(true);
|
|
61
|
+
expect(typeof rep.data["provisioning"]).toBe('string');
|
|
62
|
+
});
|
|
63
|
+
describe('provisioning stage', () => {
|
|
64
|
+
let provUrl;
|
|
65
|
+
(0, async_jasmine_1.beforeAllAsync)(async () => {
|
|
66
|
+
provUrl = await midServer.getProvUrl();
|
|
67
|
+
});
|
|
68
|
+
// TODO refactor Public Key Login into shared-checks spec, similarly to
|
|
69
|
+
// MailerId login, so as to reuse it where PKL is used.
|
|
70
|
+
async function testFirstReqFor(useDefaultKey) {
|
|
71
|
+
let reqOpts = {
|
|
72
|
+
url: provUrl + pklApi.start.URL_END,
|
|
73
|
+
method: 'POST',
|
|
74
|
+
responseType: 'json'
|
|
75
|
+
};
|
|
76
|
+
// request with known user id
|
|
77
|
+
let req = (useDefaultKey ?
|
|
78
|
+
{ userId: user1.id } :
|
|
79
|
+
{ userId: user1.id, kid: user1.loginLabeledSKey.kid });
|
|
80
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
81
|
+
expect(rep.status).withContext('status code for OK reply').toBe(pklApi.start.SC.ok);
|
|
82
|
+
expect(typeof rep.data).toBe('object');
|
|
83
|
+
expect(typeof rep.data.sessionId).toBe('string');
|
|
84
|
+
expect(() => {
|
|
85
|
+
// note that this user uses NaCl's box (Curve25519)
|
|
86
|
+
(0, pkl_1.decryptSessionParamsForCurve25519)(rep.data, user1.loginDefaultSKey);
|
|
87
|
+
}).not.toThrow();
|
|
88
|
+
// duplicating request, with session id now in a header
|
|
89
|
+
reqOpts.sessionId = rep.data.sessionId;
|
|
90
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
91
|
+
expect(rep.status).withContext('reaction to duplicate request').toBe(pklApi.ERR_SC.duplicate);
|
|
92
|
+
delete reqOpts.sessionId;
|
|
93
|
+
// when user id is unknown
|
|
94
|
+
req = { userId: 'unknown user @some.domain' };
|
|
95
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
96
|
+
expect(rep.status).withContext('status code for an unknown user id').toBe(pklApi.start.SC.unknownUser);
|
|
97
|
+
req = { userId: 'unknown user @' + signupDomains[0] };
|
|
98
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
99
|
+
expect(rep.status).withContext('status code for an unknown user id').toBe(pklApi.start.SC.unknownUser);
|
|
100
|
+
// requests with bad user ids and with bad json's
|
|
101
|
+
let badIds = ['', ' ', '\t', '\n',
|
|
102
|
+
5, null, undefined, {}]; // non-strings
|
|
103
|
+
let badJSONs = ['bar', 5, null, undefined, ['blah'],
|
|
104
|
+
{ a: 1 }];
|
|
105
|
+
for (let id of badIds) {
|
|
106
|
+
req = { userId: id };
|
|
107
|
+
badJSONs.push(req);
|
|
108
|
+
}
|
|
109
|
+
const REQ_SIZE_LIMIT = 1024;
|
|
110
|
+
await (0, requests_1.expectNonAcceptanceOfBadJsonRequest)(reqOpts, REQ_SIZE_LIMIT, badJSONs);
|
|
111
|
+
}
|
|
112
|
+
(0, async_jasmine_1.itAsync)('starts with Public Key Login, using default key', () => testFirstReqFor(true));
|
|
113
|
+
(0, async_jasmine_1.itAsync)('starts with Public Key Login, using non-default (labeled) key', () => testFirstReqFor(false));
|
|
114
|
+
async function testSecondReqFor(useDefaultKey) {
|
|
115
|
+
let exchangeParams = await (0, pkl_1.startPKLSession)(provUrl, user1, useDefaultKey);
|
|
116
|
+
let reqOpts = {
|
|
117
|
+
url: provUrl + pklApi.complete.URL_END,
|
|
118
|
+
method: 'POST',
|
|
119
|
+
sessionId: exchangeParams.sessionId,
|
|
120
|
+
responseType: 'arraybuffer'
|
|
121
|
+
};
|
|
122
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, exchangeParams.crypto.encResponse);
|
|
123
|
+
expect(rep.status).withContext('status code for successful login completion').toBe(pklApi.complete.SC.ok);
|
|
124
|
+
expect(rep.data.length).toBe(ecma_nacl_1.secret_box.POLY_LENGTH);
|
|
125
|
+
expect((0, bytes_equal_1.bytesEqual)(rep.data, exchangeParams.crypto.serverVerificationBytes)).withContext('returned bytes must be a missing poly part from the challenge, to verify to client, that server knows user\'s public key').toBe(true);
|
|
126
|
+
// repeating request is not ok
|
|
127
|
+
rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, exchangeParams.crypto.encResponse);
|
|
128
|
+
expect(rep.status).withContext('reaction to duplicate request').toBe(pklApi.ERR_SC.duplicate);
|
|
129
|
+
// send incorrect challenge response
|
|
130
|
+
for (let i = 0; i < exchangeParams.crypto.encResponse.length; i += 1) {
|
|
131
|
+
let exchange2 = await (0, pkl_1.startPKLSession)(provUrl, user2, useDefaultKey);
|
|
132
|
+
let badReply = exchange2.crypto.encResponse;
|
|
133
|
+
badReply[i] ^= 1;
|
|
134
|
+
reqOpts.sessionId = exchange2.sessionId;
|
|
135
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, badReply);
|
|
136
|
+
expect(rep.status).toBe(pklApi.complete.SC.authFailed);
|
|
137
|
+
}
|
|
138
|
+
let exchange2 = await (0, pkl_1.startPKLSession)(provUrl, user2, useDefaultKey);
|
|
139
|
+
let badReply = exchange2.crypto.encResponse.subarray(5);
|
|
140
|
+
reqOpts.sessionId = exchange2.sessionId;
|
|
141
|
+
rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, badReply);
|
|
142
|
+
expect(rep.status).toBe(pklApi.complete.SC.authFailed);
|
|
143
|
+
// bad session id
|
|
144
|
+
await (0, requests_1.expectNonAcceptanceOfBadSessionId)(reqOpts);
|
|
145
|
+
// too long
|
|
146
|
+
const REQ_SIZE_LIMIT = 1024;
|
|
147
|
+
exchange2 = await (0, pkl_1.startPKLSession)(provUrl, user2, useDefaultKey);
|
|
148
|
+
reqOpts.sessionId = exchange2.sessionId;
|
|
149
|
+
await (0, requests_1.expectNonAcceptanceOfLongBody)(reqOpts, 'application/octet-stream', REQ_SIZE_LIMIT);
|
|
150
|
+
// wrong type
|
|
151
|
+
await (0, requests_1.expectNonAcceptanceOfBadType)(reqOpts, 'application/octet-stream', exchange2.crypto.encResponse);
|
|
152
|
+
}
|
|
153
|
+
(0, async_jasmine_1.itAsync)('second request completes Public Key Login, using default key', () => testSecondReqFor(true));
|
|
154
|
+
(0, async_jasmine_1.itAsync)('second request completes Public Key Login, with non-default key', () => testSecondReqFor(true));
|
|
155
|
+
(0, async_jasmine_1.itAsync)('certifies user\'s MailerId public key', async () => {
|
|
156
|
+
let midSigningPair = mid_sigs_NaCl_Ed_1.user.generateSigningKeyPair(random_node_1.bytesSync);
|
|
157
|
+
let reqData = {
|
|
158
|
+
pkey: midSigningPair.pkey,
|
|
159
|
+
duration: 12 * 60 * 60
|
|
160
|
+
};
|
|
161
|
+
let sessParams = await (0, pkl_1.doPubKeyLogin)(provUrl, user1);
|
|
162
|
+
let reqOpts = {
|
|
163
|
+
url: provUrl + provisioning_1.certify.URL_END,
|
|
164
|
+
method: 'POST',
|
|
165
|
+
sessionId: sessParams.sessionId,
|
|
166
|
+
responseType: 'arraybuffer'
|
|
167
|
+
};
|
|
168
|
+
let encrBody = sessParams.sessEncr.packJSON(reqData);
|
|
169
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, encrBody);
|
|
170
|
+
expect(rep.status).withContext('status code for OK reply').toBe(provisioning_1.certify.SC.ok);
|
|
171
|
+
let repData = sessParams.sessEncr.openJSON(rep.data);
|
|
172
|
+
let pkeyAndAddress = mid_sigs_NaCl_Ed_1.relyingParty.verifyChainAndGetUserKey({
|
|
173
|
+
root: await (0, mailerid_2.getMidRoot)(midServer.midUrl),
|
|
174
|
+
prov: repData.provCert,
|
|
175
|
+
user: repData.userCert
|
|
176
|
+
}, midServer.midServiceDomain, Date.now() / 1000);
|
|
177
|
+
expect(pkeyAndAddress.address).withContext('certificate must be issued for session\'s user canonical address.').toBe((0, canonical_address_1.toCanonicalAddress)(user1.id));
|
|
178
|
+
let pkeyFromCert = {
|
|
179
|
+
alg: pkeyAndAddress.pkey.alg,
|
|
180
|
+
kid: pkeyAndAddress.pkey.kid,
|
|
181
|
+
use: pkeyAndAddress.pkey.use,
|
|
182
|
+
k: buffer_utils_1.base64.pack(pkeyAndAddress.pkey.k)
|
|
183
|
+
};
|
|
184
|
+
expect((0, json_equal_1.deepEqual)(pkeyFromCert, midSigningPair.pkey)).withContext('public key should be exactly the same as given one.').toBe(true);
|
|
185
|
+
// session is closed at this request
|
|
186
|
+
rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, sessParams.sessEncr.packJSON(reqData));
|
|
187
|
+
expect(rep.status).withContext('session should be closed.').toBe(requests_1.UNAUTHORIZED_STATUS);
|
|
188
|
+
// messed up cipher body
|
|
189
|
+
sessParams = await (0, pkl_1.doPubKeyLogin)(provUrl, user1);
|
|
190
|
+
reqOpts.sessionId = sessParams.sessionId;
|
|
191
|
+
encrBody[20] ^= 1;
|
|
192
|
+
rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, encrBody);
|
|
193
|
+
expect(rep.status).toBe(provisioning_1.certify.SC.cryptoVerifFail);
|
|
194
|
+
// empty body
|
|
195
|
+
sessParams = await (0, pkl_1.doPubKeyLogin)(provUrl, user1);
|
|
196
|
+
reqOpts.sessionId = sessParams.sessionId;
|
|
197
|
+
rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, new Uint8Array(0));
|
|
198
|
+
expect(rep.status).toBe(provisioning_1.certify.SC.cryptoVerifFail);
|
|
199
|
+
// set session for fuzzing below
|
|
200
|
+
sessParams = await (0, pkl_1.doPubKeyLogin)(provUrl, user1);
|
|
201
|
+
reqOpts.sessionId = sessParams.sessionId;
|
|
202
|
+
// too long
|
|
203
|
+
const REQ_SIZE_LIMIT = 16 * 1024;
|
|
204
|
+
await (0, requests_1.expectNonAcceptanceOfLongBody)(reqOpts, 'application/octet-stream', REQ_SIZE_LIMIT);
|
|
205
|
+
// wrong type
|
|
206
|
+
encrBody = sessParams.sessEncr.packJSON(reqData);
|
|
207
|
+
await (0, requests_1.expectNonAcceptanceOfBadType)(reqOpts, 'application/octet-stream', encrBody);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
});
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 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.midLoginSpecs = void 0;
|
|
20
|
+
const async_jasmine_1 = require("../libs-for-tests/async-jasmine");
|
|
21
|
+
const login_1 = require("../../lib-common/service-api/mailer-id/login");
|
|
22
|
+
const xhr_utils_1 = require("../libs-for-tests/xhr-utils");
|
|
23
|
+
const mailerid_1 = require("../libs-for-tests/mailerid");
|
|
24
|
+
const requests_1 = require("./requests");
|
|
25
|
+
const mid = require("../../lib-common/mid-sigs-NaCl-Ed");
|
|
26
|
+
const random_node_1 = require("../../lib-common/random-node");
|
|
27
|
+
const url_1 = require("url");
|
|
28
|
+
function midLoginSpecs(loginUrl, user) {
|
|
29
|
+
return () => {
|
|
30
|
+
(0, async_jasmine_1.itAsync)('first request starts session', async () => {
|
|
31
|
+
const reqOpts = {
|
|
32
|
+
url: (0, url_1.resolve)(loginUrl(), login_1.startSession.URL_END),
|
|
33
|
+
method: 'POST',
|
|
34
|
+
responseType: 'json'
|
|
35
|
+
};
|
|
36
|
+
// request with known user id
|
|
37
|
+
let req = { userId: user().id };
|
|
38
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
39
|
+
expect(rep.status).withContext('status for ok reply').toBe(login_1.startSession.SC.ok);
|
|
40
|
+
expect(typeof rep.data).toBe('object');
|
|
41
|
+
expect(typeof rep.data.sessionId).withContext('session id be in reply').toBe('string');
|
|
42
|
+
// duplicating request, with session id now in a header
|
|
43
|
+
reqOpts.sessionId = rep.data.sessionId;
|
|
44
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
45
|
+
expect(rep.status).withContext('reaction to duplicate request').toBe(login_1.ERR_SC.duplicate);
|
|
46
|
+
delete reqOpts.sessionId;
|
|
47
|
+
// when user id is unknown
|
|
48
|
+
req = { userId: 'unknown user @some.domain' };
|
|
49
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
50
|
+
expect(rep.status).withContext('status code for an unknown user id').toBe(login_1.startSession.SC.unknownUser);
|
|
51
|
+
// requests with bad json's
|
|
52
|
+
const badIds = ['', ' ', '\t', '\n',
|
|
53
|
+
5, null, undefined, {}]; // non-strings
|
|
54
|
+
const badJSONs = ['bar', 5, null, undefined, ['blah'],
|
|
55
|
+
{ a: 1 }];
|
|
56
|
+
for (const id of badIds) {
|
|
57
|
+
req = { userId: id };
|
|
58
|
+
badJSONs.push(req);
|
|
59
|
+
}
|
|
60
|
+
const REQ_SIZE_LIMIT = 1024;
|
|
61
|
+
await (0, requests_1.expectNonAcceptanceOfBadJsonRequest)(reqOpts, REQ_SIZE_LIMIT, badJSONs);
|
|
62
|
+
});
|
|
63
|
+
(0, async_jasmine_1.itAsync)('second request authenticates session', async () => {
|
|
64
|
+
const url = loginUrl();
|
|
65
|
+
let sessionId = await (0, mailerid_1.startMidSession)(url, user().id);
|
|
66
|
+
const uInfo = user();
|
|
67
|
+
let midSigner = await (0, mailerid_1.provisionMidSigner)(uInfo.midUrl, uInfo);
|
|
68
|
+
const reqOpts = {
|
|
69
|
+
url: (0, url_1.resolve)(loginUrl(), login_1.authSession.URL_END),
|
|
70
|
+
method: 'POST',
|
|
71
|
+
responseType: 'json',
|
|
72
|
+
sessionId
|
|
73
|
+
};
|
|
74
|
+
const serviceDomain = (0, url_1.parse)(loginUrl()).hostname;
|
|
75
|
+
if (!serviceDomain) {
|
|
76
|
+
throw new Error(`Cannot get hostname from ${loginUrl()}`);
|
|
77
|
+
}
|
|
78
|
+
const req = {
|
|
79
|
+
assertion: midSigner.generateAssertionFor(serviceDomain, sessionId),
|
|
80
|
+
provCert: midSigner.providerCert,
|
|
81
|
+
userCert: midSigner.userCert
|
|
82
|
+
};
|
|
83
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
84
|
+
expect(rep.status).withContext('status for ok reply').toBe(login_1.authSession.SC.ok);
|
|
85
|
+
// repeating request is not ok
|
|
86
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
87
|
+
expect(rep.status).withContext('reaction to duplicate request').toBe(login_1.ERR_SC.duplicate);
|
|
88
|
+
// wrong assertion is from a different session
|
|
89
|
+
sessionId = await (0, mailerid_1.startMidSession)(url, user().id);
|
|
90
|
+
reqOpts.sessionId = sessionId;
|
|
91
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
92
|
+
expect(rep.status).withContext('status for autherization failure').toBe(login_1.authSession.SC.authFailed);
|
|
93
|
+
// wrong domain in assertion
|
|
94
|
+
sessionId = await (0, mailerid_1.startMidSession)(url, user().id);
|
|
95
|
+
reqOpts.sessionId = sessionId;
|
|
96
|
+
req.assertion = midSigner.generateAssertionFor('other.domain', sessionId);
|
|
97
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
98
|
+
expect(rep.status).withContext('status for autherization failure').toBe(login_1.authSession.SC.authFailed);
|
|
99
|
+
// fake certs
|
|
100
|
+
const fakeRoot = mid.idProvider.generateRootKey(uInfo.midUrl, 365 * 12 * 60 * 60, random_node_1.bytesSync);
|
|
101
|
+
const fakeProvider = mid.idProvider.generateProviderKey(uInfo.midUrl, 30 * 12 * 60 * 60, fakeRoot.skey, random_node_1.bytesSync);
|
|
102
|
+
const fakeIdCertifier = mid.idProvider.makeIdProviderCertifier(uInfo.midUrl, 24 * 60 * 60, fakeProvider.skey);
|
|
103
|
+
const fakeUserKeys = mid.user.generateSigningKeyPair(random_node_1.bytesSync);
|
|
104
|
+
const fakeUserCert = fakeIdCertifier.certify(fakeUserKeys.pkey, user().id);
|
|
105
|
+
midSigner = mid.user.makeMailerIdSigner(fakeUserKeys.skey, fakeUserCert, fakeProvider.cert);
|
|
106
|
+
sessionId = await (0, mailerid_1.startMidSession)(url, user().id);
|
|
107
|
+
reqOpts.sessionId = sessionId;
|
|
108
|
+
req.assertion = midSigner.generateAssertionFor(serviceDomain, sessionId);
|
|
109
|
+
req.userCert = fakeUserCert; // keep unrelated provCert
|
|
110
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
111
|
+
expect(rep.status).withContext('status for autherization failure').toBe(login_1.authSession.SC.authFailed);
|
|
112
|
+
sessionId = await (0, mailerid_1.startMidSession)(url, user().id);
|
|
113
|
+
reqOpts.sessionId = sessionId;
|
|
114
|
+
req.assertion = midSigner.generateAssertionFor(serviceDomain, sessionId);
|
|
115
|
+
req.provCert = fakeProvider.cert;
|
|
116
|
+
req.userCert = fakeUserCert;
|
|
117
|
+
rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
118
|
+
expect(rep.status).withContext('status for autherization failure').toBe(login_1.authSession.SC.authFailed);
|
|
119
|
+
// bad json
|
|
120
|
+
const REQ_SIZE_LIMIT = 4 * 1024;
|
|
121
|
+
sessionId = await (0, mailerid_1.startMidSession)(url, user().id);
|
|
122
|
+
reqOpts.sessionId = sessionId;
|
|
123
|
+
const badJSONs = [1, null, undefined, 'string'];
|
|
124
|
+
await (0, requests_1.expectNonAcceptanceOfBadJsonRequest)(reqOpts, REQ_SIZE_LIMIT, badJSONs);
|
|
125
|
+
// bad session id
|
|
126
|
+
await (0, requests_1.expectNonAcceptanceOfBadSessionId)(reqOpts);
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
exports.midLoginSpecs = midLoginSpecs;
|
|
131
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RequestOpts } from '../libs-for-tests/xhr-utils';
|
|
2
|
+
export declare const UNAUTHORIZED_STATUS = 401;
|
|
3
|
+
/**
|
|
4
|
+
* This function should test json-expecting routes.
|
|
5
|
+
* @param opts
|
|
6
|
+
* @param maxBodyLen
|
|
7
|
+
* @param badJSONs
|
|
8
|
+
* @return a promise, resolvable when all checks are done.
|
|
9
|
+
*/
|
|
10
|
+
export declare function expectNonAcceptanceOfBadJsonRequest(opts: RequestOpts, maxBodyLen: number, badJSONs: any[]): Promise<void>;
|
|
11
|
+
export declare type BodyType = 'application/octet-stream' | 'text/plain' | 'application/json';
|
|
12
|
+
export declare function expectNonAcceptanceOfBadType(opts: RequestOpts, correctType: BodyType, body: Uint8Array): Promise<void>;
|
|
13
|
+
export declare function expectNonAcceptanceOfLongBody(opts: RequestOpts, bodyType: BodyType, maxBodyLen: number): Promise<void>;
|
|
14
|
+
export declare function expectNonAcceptanceOfNonEmptyBody(opts: RequestOpts): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* @param opts
|
|
17
|
+
* @param hasBody is a flag, telling if body should be sent with the request.
|
|
18
|
+
* Default value is false, for no body in request.
|
|
19
|
+
*/
|
|
20
|
+
export declare function expectNonAcceptanceOfBadSessionId(opts: RequestOpts, hasBody?: boolean): Promise<void>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 2019, 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.expectNonAcceptanceOfBadSessionId = exports.expectNonAcceptanceOfNonEmptyBody = exports.expectNonAcceptanceOfLongBody = exports.expectNonAcceptanceOfBadType = exports.expectNonAcceptanceOfBadJsonRequest = exports.UNAUTHORIZED_STATUS = void 0;
|
|
20
|
+
const xhr_utils_1 = require("../libs-for-tests/xhr-utils");
|
|
21
|
+
const crypto_1 = require("crypto");
|
|
22
|
+
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
23
|
+
const json_copy_1 = require("../libs-for-tests/json-copy");
|
|
24
|
+
const LONG_BODY_STATUS = 413;
|
|
25
|
+
const MALFORMED_BODY_STATUS = 400;
|
|
26
|
+
const WRONG_CONTENT_TYPE_STATUS = 415;
|
|
27
|
+
exports.UNAUTHORIZED_STATUS = 401;
|
|
28
|
+
/**
|
|
29
|
+
* This function should test json-expecting routes.
|
|
30
|
+
* @param opts
|
|
31
|
+
* @param maxBodyLen
|
|
32
|
+
* @param badJSONs
|
|
33
|
+
* @return a promise, resolvable when all checks are done.
|
|
34
|
+
*/
|
|
35
|
+
async function expectNonAcceptanceOfBadJsonRequest(opts, maxBodyLen, badJSONs) {
|
|
36
|
+
// bad json
|
|
37
|
+
for (const badReq of badJSONs) {
|
|
38
|
+
const rep = await (0, xhr_utils_1.doJsonRequest)(opts, badReq);
|
|
39
|
+
expect(rep.status).withContext(`status code for malformed request: ${JSON.stringify(badReq)}`).toBe(MALFORMED_BODY_STATUS);
|
|
40
|
+
}
|
|
41
|
+
// bad non-json bodies
|
|
42
|
+
const badBodies = [Buffer.alloc(0), (0, crypto_1.randomBytes)(Math.floor(maxBodyLen / 2))];
|
|
43
|
+
for (const bytes of badBodies) {
|
|
44
|
+
const req = (0, xhr_utils_1.request)('application/json', opts);
|
|
45
|
+
req.xhr.send(bytes);
|
|
46
|
+
const rep = await req.promise;
|
|
47
|
+
expect(rep.status).withContext('status code for malformed request').toBe(MALFORMED_BODY_STATUS);
|
|
48
|
+
}
|
|
49
|
+
// wrong content type
|
|
50
|
+
await expectNonAcceptanceOfBadType(opts, 'application/json', buffer_utils_1.utf8.pack(JSON.stringify({})));
|
|
51
|
+
// request that is too long (>maxBodyLen)
|
|
52
|
+
await expectNonAcceptanceOfLongBody(opts, 'application/json', maxBodyLen);
|
|
53
|
+
}
|
|
54
|
+
exports.expectNonAcceptanceOfBadJsonRequest = expectNonAcceptanceOfBadJsonRequest;
|
|
55
|
+
const bodyTypes = ['application/octet-stream',
|
|
56
|
+
'text/plain', 'application/json', undefined];
|
|
57
|
+
async function expectNonAcceptanceOfBadType(opts, correctType, body) {
|
|
58
|
+
for (const bt of bodyTypes) {
|
|
59
|
+
if (correctType === bt) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const req = (0, xhr_utils_1.request)(bt, opts);
|
|
63
|
+
req.xhr.send(body);
|
|
64
|
+
const rep = await req.promise;
|
|
65
|
+
expect(rep.status).withContext('status code for wrong content type request').toBe(WRONG_CONTENT_TYPE_STATUS);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.expectNonAcceptanceOfBadType = expectNonAcceptanceOfBadType;
|
|
69
|
+
async function expectNonAcceptanceOfLongBody(opts, bodyType, maxBodyLen) {
|
|
70
|
+
const badReq = (0, crypto_1.randomBytes)(maxBodyLen + 1);
|
|
71
|
+
const req = (0, xhr_utils_1.request)(bodyType, opts);
|
|
72
|
+
req.xhr.send(badReq);
|
|
73
|
+
try {
|
|
74
|
+
const rep = await req.promise;
|
|
75
|
+
expect(rep.status).withContext('status code for long request').toBe(LONG_BODY_STATUS);
|
|
76
|
+
}
|
|
77
|
+
catch (exc) {
|
|
78
|
+
const cantConnect = exc.runtimeException &&
|
|
79
|
+
(exc.type === 'http-connect');
|
|
80
|
+
expect(cantConnect).withContext(`server can close connection on a long reply, resulting in a can't connect error on a client side`).toBe(true);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.expectNonAcceptanceOfLongBody = expectNonAcceptanceOfLongBody;
|
|
84
|
+
async function expectNonAcceptanceOfNonEmptyBody(opts) {
|
|
85
|
+
const badReq = (0, crypto_1.randomBytes)(1);
|
|
86
|
+
const req = (0, xhr_utils_1.request)(undefined, opts);
|
|
87
|
+
req.xhr.send(badReq);
|
|
88
|
+
const rep = await req.promise;
|
|
89
|
+
expect(rep.status).withContext('status code for long request').toBe(LONG_BODY_STATUS);
|
|
90
|
+
}
|
|
91
|
+
exports.expectNonAcceptanceOfNonEmptyBody = expectNonAcceptanceOfNonEmptyBody;
|
|
92
|
+
/**
|
|
93
|
+
* @param opts
|
|
94
|
+
* @param hasBody is a flag, telling if body should be sent with the request.
|
|
95
|
+
* Default value is false, for no body in request.
|
|
96
|
+
*/
|
|
97
|
+
async function expectNonAcceptanceOfBadSessionId(opts, hasBody = false) {
|
|
98
|
+
opts = (0, json_copy_1.copy)(opts);
|
|
99
|
+
// missing session id
|
|
100
|
+
delete opts.sessionId;
|
|
101
|
+
let req = (0, xhr_utils_1.request)(undefined, opts);
|
|
102
|
+
if (hasBody) {
|
|
103
|
+
req.xhr.send((0, crypto_1.randomBytes)(5));
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
req.xhr.send();
|
|
107
|
+
}
|
|
108
|
+
let rep = await req.promise;
|
|
109
|
+
expect(rep.status).withContext('status code when required session id is missing').toBe(exports.UNAUTHORIZED_STATUS);
|
|
110
|
+
// invalid session id
|
|
111
|
+
opts.sessionId = 'bogus session id';
|
|
112
|
+
req = (0, xhr_utils_1.request)(undefined, opts);
|
|
113
|
+
if (hasBody) {
|
|
114
|
+
req.xhr.send((0, crypto_1.randomBytes)(5));
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
req.xhr.send();
|
|
118
|
+
}
|
|
119
|
+
rep = await req.promise;
|
|
120
|
+
expect(rep.status).withContext('status code for an invalid session id').toBe(exports.UNAUTHORIZED_STATUS);
|
|
121
|
+
}
|
|
122
|
+
exports.expectNonAcceptanceOfBadSessionId = expectNonAcceptanceOfBadSessionId;
|
|
123
|
+
Object.freeze(exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
version_from_npm() {
|
|
3
|
+
node -e "
|
|
4
|
+
const packageInfo = JSON.parse(fs.readFileSync(
|
|
5
|
+
'package.json', { encoding: 'utf8' }
|
|
6
|
+
));
|
|
7
|
+
console.log(packageInfo.version);
|
|
8
|
+
" || return $?
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
src_dir="packing/deb"
|
|
12
|
+
temp_dir="deb-bin"
|
|
13
|
+
DEBIAN="$temp_dir/DEBIAN"
|
|
14
|
+
lib_dir="$temp_dir/usr/lib/3nweb"
|
|
15
|
+
conf_yaml="/etc/3nweb/conf.yaml"
|
|
16
|
+
dist_dir="dist"
|
|
17
|
+
|
|
18
|
+
mkdir -p $DEBIAN
|
|
19
|
+
# cp -r $src_dir/etc $src_dir/lib $src_dir/usr $temp_dir/
|
|
20
|
+
cp -r $src_dir/lib $src_dir/usr $temp_dir/
|
|
21
|
+
mkdir -p $lib_dir
|
|
22
|
+
cp $dist_dir/spec-3nweb-server $lib_dir/
|
|
23
|
+
chmod 755 $lib_dir/*
|
|
24
|
+
|
|
25
|
+
cd $temp_dir
|
|
26
|
+
find . -type f | xargs md5sum > DEBIAN/md5sums
|
|
27
|
+
cd ..
|
|
28
|
+
|
|
29
|
+
cp $src_dir/postinst $DEBIAN/
|
|
30
|
+
chmod 755 $DEBIAN/postinst
|
|
31
|
+
|
|
32
|
+
# echo $conf_yaml > $DEBIAN/conffiles
|
|
33
|
+
|
|
34
|
+
package_name="3nweb-server"
|
|
35
|
+
deb_version=$(version_from_npm)-1
|
|
36
|
+
size_kb=$(du -ksc $temp_dir/usr | grep total | cut -f1)
|
|
37
|
+
|
|
38
|
+
echo "
|
|
39
|
+
Package: $package_name
|
|
40
|
+
Version: $deb_version
|
|
41
|
+
Architecture: all
|
|
42
|
+
Section: web
|
|
43
|
+
Maintainer: 3NSoft Inc <hq@3nsoft.com>
|
|
44
|
+
Installed-Size: $size_kb
|
|
45
|
+
Homepage: https://3nweb.com
|
|
46
|
+
Description: Provides messaging, storage and indentity services for 3NWeb
|
|
47
|
+
$package_name provides all 3NWeb services: ASMail messaging, 3NStorage and
|
|
48
|
+
MailerId identity.
|
|
49
|
+
" > $DEBIAN/control
|
|
50
|
+
|
|
51
|
+
echo ""
|
|
52
|
+
|
|
53
|
+
dpkg --build $temp_dir $dist_dir/${package_name}_${deb_version}.deb
|
|
54
|
+
|
|
55
|
+
dpkg_res=$?
|
|
56
|
+
rm -rf $temp_dir
|
|
57
|
+
exit $pkg_res
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
var_dir=/var/3nweb
|
|
4
|
+
bin_link=/usr/bin/3nweb
|
|
5
|
+
lib_bin=/usr/lib/3nweb/spec-3nweb-server
|
|
6
|
+
|
|
7
|
+
if [ ! -d $var_dir ]
|
|
8
|
+
then
|
|
9
|
+
mkdir -p $var_dir
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
if [ ! -e $bin_link ]
|
|
13
|
+
then
|
|
14
|
+
ln -s $lib_bin $bin_link
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
etc=/etc/3nweb
|
|
18
|
+
etc_conf=$etc/conf.yaml
|
|
19
|
+
conf_template=/usr/share/doc/3nweb-server/conf-for-postinstall.yaml
|
|
20
|
+
etc_mid=$etc/mailerid
|
|
21
|
+
|
|
22
|
+
if [ ! -e $etc_conf ]
|
|
23
|
+
then
|
|
24
|
+
echo "Writing out template configuration into $etc"
|
|
25
|
+
mkdir -p $etc_mid
|
|
26
|
+
cat $conf_template > $etc_conf
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
if [ -n "$(which systemctl)" ]
|
|
30
|
+
then
|
|
31
|
+
echo "Reloading systemd daemon and enabling 3nweb service."
|
|
32
|
+
systemctl daemon-reload
|
|
33
|
+
systemctl enable 3nweb
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
echo "
|
|
37
|
+
####################
|
|
38
|
+
# 3NWeb server #
|
|
39
|
+
####################
|
|
40
|
+
|
|
41
|
+
1. Customize 3NWeb settings in $etc_conf
|
|
42
|
+
|
|
43
|
+
2. Start systemd service \"sudo systemctl start 3nweb\"
|
|
44
|
+
"
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
enabledServices:
|
|
2
|
+
asmail: true
|
|
3
|
+
storage: true
|
|
4
|
+
mailerId: true
|
|
5
|
+
|
|
6
|
+
rootFolder: /var/3nweb
|
|
7
|
+
|
|
8
|
+
# Customize domain at which clients reach this server from an outside.
|
|
9
|
+
# domain: example.com
|
|
10
|
+
|
|
11
|
+
mailerId:
|
|
12
|
+
certs: /etc/3nweb/mailerid/certs
|
|
13
|
+
|
|
14
|
+
# Customize servicesConnect before starting this server
|
|
15
|
+
# servicesConnect:
|
|
16
|
+
# port: 443
|
|
17
|
+
# letsencrypt: /etc/letsencrypt/live/example.com
|
|
18
|
+
|
|
19
|
+
signup: {}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
|
2
|
+
Upstream-Name: 3nweb-server
|
|
3
|
+
Upstream-Contact: hg@3nsoft.com
|
|
4
|
+
Source: https://github.com/3nsoft/spec-server
|
|
5
|
+
|
|
6
|
+
Files: *
|
|
7
|
+
Copyright: 2015 - 2023 3NSoft Inc.
|
|
8
|
+
License: GPL-3+
|
|
9
|
+
|
|
10
|
+
License: GPL-3+
|
|
11
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
12
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
13
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
14
|
+
version.
|
|
15
|
+
.
|
|
16
|
+
This program is distributed in the hope that it will be useful, but
|
|
17
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
19
|
+
See the GNU General Public License for more details.
|
|
20
|
+
.
|
|
21
|
+
You should have received a copy of the GNU General Public License along with
|
|
22
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|