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,329 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2019 3NSoft Inc.
|
|
3
|
+
|
|
4
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
5
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
7
|
+
version.
|
|
8
|
+
|
|
9
|
+
This program is distributed in the hope that it will be useful, but
|
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
12
|
+
See the GNU General Public License for more details.
|
|
13
|
+
|
|
14
|
+
You should have received a copy of the GNU General Public License along with
|
|
15
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { HeaderChunkInfo, SegsChunk } from "./file-layout";
|
|
19
|
+
|
|
20
|
+
export const V1_FILE_START = Buffer.from('1xsp', 'utf8');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @param u is an unsigned integer up to 32-bits to be stored big-endian way in
|
|
24
|
+
* 4 bytes.
|
|
25
|
+
* @return a byte array with number stored in it.
|
|
26
|
+
*/
|
|
27
|
+
function uintTo4Bytes(u: number): Buffer {
|
|
28
|
+
if (u >= 0x100000000) { throw new Error(
|
|
29
|
+
'Cannot store number bigger than 2^32-1'); }
|
|
30
|
+
const x = Buffer.allocUnsafe(4);
|
|
31
|
+
x[0] = u >>> 24;
|
|
32
|
+
x[1] = u >>> 16;
|
|
33
|
+
x[2] = u >>> 8;
|
|
34
|
+
x[3] = u;
|
|
35
|
+
return x;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param x
|
|
40
|
+
* @param i
|
|
41
|
+
* @return unsigned integer (up to 32 bits), stored big-endian way
|
|
42
|
+
* in 4 bytes of x, starting at index i.
|
|
43
|
+
*/
|
|
44
|
+
function uintFrom4Bytes(x: Uint8Array, i = 0): number {
|
|
45
|
+
if (x.length < i+4) { throw new Error(
|
|
46
|
+
'Given array has less than 4 bytes, starting with a given index.'); }
|
|
47
|
+
return ((x[i] << 24) | (x[i+1] << 16) | (x[i+2] << 8) | x[i+3]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @param u is an unsigned integer up to 53-bits to be stored big-endian way in
|
|
52
|
+
* 8 bytes.
|
|
53
|
+
* @return a byte array with number stored in it.
|
|
54
|
+
*/
|
|
55
|
+
export function uintTo8Bytes(u: number): Buffer {
|
|
56
|
+
if (u > Number.MAX_SAFE_INTEGER) { throw new Error(
|
|
57
|
+
'Cannot store number bigger than 2^53-1'); }
|
|
58
|
+
const x = Buffer.allocUnsafe(8);
|
|
59
|
+
const h = Math.floor(u / 0x100000000);
|
|
60
|
+
const l = u % 0x100000000;
|
|
61
|
+
x[0] = h >>> 24;
|
|
62
|
+
x[1] = h >>> 16;
|
|
63
|
+
x[2] = h >>> 8;
|
|
64
|
+
x[3] = h;
|
|
65
|
+
x[4] = l >>> 24;
|
|
66
|
+
x[5] = l >>> 16;
|
|
67
|
+
x[6] = l >>> 8;
|
|
68
|
+
x[7] = l;
|
|
69
|
+
return x;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param x
|
|
74
|
+
* @param i
|
|
75
|
+
* @return unsigned integer (up to 53 bits), stored big-endian way
|
|
76
|
+
* in 8 bytes of x, starting at index i.
|
|
77
|
+
*/
|
|
78
|
+
export function uintFrom8Bytes(x: Uint8Array, i = 0): number {
|
|
79
|
+
if (x.length < i+8) { throw new Error(
|
|
80
|
+
'Given array has less than 8 bytes, starting with a given index.'); }
|
|
81
|
+
const h = (x[i] << 24) | (x[i+1] << 16) | (x[i+2] << 8) | x[i+3];
|
|
82
|
+
const l = (x[i+4] << 24) | (x[i+5] << 16) | (x[i+6] << 8) | x[i+7];
|
|
83
|
+
return (h*0x100000000 + l);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
namespace headerChunkInfo {
|
|
87
|
+
|
|
88
|
+
export function toBytes(hInfo: HeaderChunkInfo): Buffer {
|
|
89
|
+
const buf = Buffer.allocUnsafe(12);
|
|
90
|
+
buf.set(uintTo4Bytes(hInfo.len));
|
|
91
|
+
buf.set(uintTo8Bytes(hInfo.fileOfs), 4);
|
|
92
|
+
return buf;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function fromBytes(b: Uint8Array, i: number):
|
|
96
|
+
{ hInfo: HeaderChunkInfo; bytesRead: number; } {
|
|
97
|
+
let bytesRead = 0;
|
|
98
|
+
const len = uintFrom4Bytes(b, i + bytesRead);
|
|
99
|
+
bytesRead += 4;
|
|
100
|
+
const fileOfs = uintFrom8Bytes(b, i + bytesRead);
|
|
101
|
+
bytesRead += 8;
|
|
102
|
+
const hInfo: HeaderChunkInfo = { len, fileOfs };
|
|
103
|
+
return { hInfo: Object.freeze(hInfo), bytesRead };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
Object.freeze(headerChunkInfo);
|
|
108
|
+
|
|
109
|
+
namespace segsChunkInfo {
|
|
110
|
+
|
|
111
|
+
const IS_ENDLESS_BITMASK = 0b00000001;
|
|
112
|
+
const FILE_OFS_PRESENT_BITMASK = 0b00000010;
|
|
113
|
+
const BASE_VER_OFS_PRESENT_BITMASK = 0b00000100;
|
|
114
|
+
|
|
115
|
+
export function toBytes(sInfo: SegsChunk): Buffer {
|
|
116
|
+
let flag = 0;
|
|
117
|
+
let bufSize = 17;
|
|
118
|
+
if ((sInfo.type === 'new-on-disk') || (sInfo.type === 'base-on-disk')) {
|
|
119
|
+
flag |= FILE_OFS_PRESENT_BITMASK;
|
|
120
|
+
bufSize += 8;
|
|
121
|
+
}
|
|
122
|
+
if ((sInfo.type === 'base') || (sInfo.type === 'base-on-disk')) {
|
|
123
|
+
flag |= BASE_VER_OFS_PRESENT_BITMASK;
|
|
124
|
+
bufSize += 8;
|
|
125
|
+
}
|
|
126
|
+
const buf = Buffer.allocUnsafe(bufSize);
|
|
127
|
+
let i = 0;
|
|
128
|
+
buf[i] = flag;
|
|
129
|
+
i += 1;
|
|
130
|
+
buf.set(uintTo8Bytes(sInfo.thisVerOfs), i);
|
|
131
|
+
i += 8;
|
|
132
|
+
if (sInfo.type !== 'new-endless') {
|
|
133
|
+
buf.set(uintTo8Bytes(sInfo.len), 9);
|
|
134
|
+
i += 8;
|
|
135
|
+
}
|
|
136
|
+
if ((sInfo.type === 'new-on-disk') || (sInfo.type === 'base-on-disk')) {
|
|
137
|
+
buf.set(uintTo8Bytes(sInfo.fileOfs), i);
|
|
138
|
+
i += 8;
|
|
139
|
+
}
|
|
140
|
+
if ((sInfo.type === 'base') || (sInfo.type === 'base-on-disk')) {
|
|
141
|
+
buf.set(uintTo8Bytes(sInfo.baseVerOfs), i);
|
|
142
|
+
}
|
|
143
|
+
return buf;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function fromBytes(b: Uint8Array, i: number):
|
|
147
|
+
{ sInfo: SegsChunk; bytesRead: number; } {
|
|
148
|
+
let bytesRead = 0
|
|
149
|
+
const flag = b[i + bytesRead];
|
|
150
|
+
bytesRead += 1;
|
|
151
|
+
const thisVerOfs = uintFrom8Bytes(b, i + bytesRead);
|
|
152
|
+
bytesRead += 8;
|
|
153
|
+
let len: number|undefined = undefined;
|
|
154
|
+
if ((flag & IS_ENDLESS_BITMASK) === 0) {
|
|
155
|
+
len = uintFrom8Bytes(b, i + bytesRead);
|
|
156
|
+
bytesRead += 8;
|
|
157
|
+
}
|
|
158
|
+
let fileOfs: number|undefined = undefined;
|
|
159
|
+
if (flag & FILE_OFS_PRESENT_BITMASK) {
|
|
160
|
+
fileOfs = uintFrom8Bytes(b, i + bytesRead);
|
|
161
|
+
bytesRead += 8;
|
|
162
|
+
}
|
|
163
|
+
let baseVerOfs: number|undefined = undefined;
|
|
164
|
+
if (flag & BASE_VER_OFS_PRESENT_BITMASK) {
|
|
165
|
+
baseVerOfs = uintFrom8Bytes(b, i + bytesRead);
|
|
166
|
+
bytesRead += 8;
|
|
167
|
+
}
|
|
168
|
+
const isOnDisk = (fileOfs !== undefined);
|
|
169
|
+
const isBase = (baseVerOfs !== undefined);
|
|
170
|
+
const isFinite = (len !== undefined);
|
|
171
|
+
let sInfo: SegsChunk;
|
|
172
|
+
if (isOnDisk) {
|
|
173
|
+
if (!isFinite) { throw new Error(`Obj file segments chunk flag says that bytes are on disk, when chunk is infinite`); }
|
|
174
|
+
if (isBase) {
|
|
175
|
+
sInfo = {
|
|
176
|
+
type: 'base-on-disk',
|
|
177
|
+
thisVerOfs,
|
|
178
|
+
len: len!,
|
|
179
|
+
fileOfs: fileOfs!,
|
|
180
|
+
baseVerOfs: baseVerOfs!
|
|
181
|
+
};
|
|
182
|
+
} else {
|
|
183
|
+
sInfo = {
|
|
184
|
+
type: 'new-on-disk',
|
|
185
|
+
thisVerOfs,
|
|
186
|
+
len: len!,
|
|
187
|
+
fileOfs: fileOfs!
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
} else {
|
|
191
|
+
if (isBase) {
|
|
192
|
+
sInfo = {
|
|
193
|
+
type: 'base',
|
|
194
|
+
thisVerOfs,
|
|
195
|
+
len: len!,
|
|
196
|
+
baseVerOfs: baseVerOfs!
|
|
197
|
+
};
|
|
198
|
+
} else if (isFinite) {
|
|
199
|
+
sInfo = {
|
|
200
|
+
type: 'new',
|
|
201
|
+
thisVerOfs,
|
|
202
|
+
len: len!
|
|
203
|
+
};
|
|
204
|
+
} else {
|
|
205
|
+
sInfo = {
|
|
206
|
+
type: 'new-endless',
|
|
207
|
+
thisVerOfs
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return { sInfo, bytesRead };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
}
|
|
215
|
+
Object.freeze(segsChunkInfo);
|
|
216
|
+
|
|
217
|
+
export namespace layoutV1 {
|
|
218
|
+
|
|
219
|
+
const HEADER_PRESENT_BITMASK = 0b00000001;
|
|
220
|
+
const BASE_PRESENT_BITMASK = 0b00000010;
|
|
221
|
+
const SEGS_LAYOUT_FROZEN_BITMASK = 0b00000100;
|
|
222
|
+
const TOTAL_SIZE_NOT_SET_BITMASK = 0b00001000;
|
|
223
|
+
const VERSION_FILE_COMPLETE_BITMASK = 0b00010000;
|
|
224
|
+
const ALL_BASE_BYTES_IN_FILE_BITMASK = 0b00100000;
|
|
225
|
+
|
|
226
|
+
export interface Attrs {
|
|
227
|
+
fileComplete: boolean;
|
|
228
|
+
segsChunks: SegsChunk[];
|
|
229
|
+
headerChunk?: HeaderChunkInfo;
|
|
230
|
+
segsLayoutFrozen: boolean;
|
|
231
|
+
baseVersion?: number;
|
|
232
|
+
sizeUnknown: boolean;
|
|
233
|
+
allBaseBytesInFile: boolean;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function validateAttrs(attrs: Attrs): void {
|
|
237
|
+
// XXX check consistency of attrs
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function toBytes(a: Attrs): Buffer {
|
|
242
|
+
let flag = 0;
|
|
243
|
+
let baseBytes: Buffer|undefined = undefined;
|
|
244
|
+
if (a.baseVersion !== undefined) {
|
|
245
|
+
flag |= BASE_PRESENT_BITMASK;
|
|
246
|
+
baseBytes = uintTo8Bytes(a.baseVersion);
|
|
247
|
+
if (a.allBaseBytesInFile) {
|
|
248
|
+
flag |= ALL_BASE_BYTES_IN_FILE_BITMASK;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
let headerInfoBytes: Buffer|undefined = undefined;
|
|
252
|
+
if (a.headerChunk) {
|
|
253
|
+
flag |= HEADER_PRESENT_BITMASK;
|
|
254
|
+
headerInfoBytes = headerChunkInfo.toBytes(a.headerChunk);
|
|
255
|
+
if (a.fileComplete) {
|
|
256
|
+
flag |= VERSION_FILE_COMPLETE_BITMASK;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (a.segsLayoutFrozen) {
|
|
260
|
+
flag |= SEGS_LAYOUT_FROZEN_BITMASK;
|
|
261
|
+
}
|
|
262
|
+
if (a.sizeUnknown) {
|
|
263
|
+
flag |= TOTAL_SIZE_NOT_SET_BITMASK;
|
|
264
|
+
}
|
|
265
|
+
const segsInfoBytes = a.segsChunks.map(s => segsChunkInfo.toBytes(s));
|
|
266
|
+
const buf = Buffer.allocUnsafe(1 +
|
|
267
|
+
(baseBytes ? 8 : 0) +
|
|
268
|
+
(headerInfoBytes ? headerInfoBytes.length : 0) +
|
|
269
|
+
totalLenOf(segsInfoBytes));
|
|
270
|
+
buf[0] = flag;
|
|
271
|
+
let i = 1;
|
|
272
|
+
if (baseBytes) {
|
|
273
|
+
buf.set(baseBytes, i);
|
|
274
|
+
i += 8;
|
|
275
|
+
}
|
|
276
|
+
if (headerInfoBytes) {
|
|
277
|
+
buf.set(headerInfoBytes, i);
|
|
278
|
+
i += headerInfoBytes.length;
|
|
279
|
+
}
|
|
280
|
+
for (const chunk of segsInfoBytes) {
|
|
281
|
+
buf.set(chunk, i);
|
|
282
|
+
i += chunk.length;
|
|
283
|
+
}
|
|
284
|
+
return buf;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export function fromBytes(b: Uint8Array, i: number): Attrs {
|
|
288
|
+
const flag = b[i];
|
|
289
|
+
i += 1;
|
|
290
|
+
let baseVersion: number|undefined = undefined;
|
|
291
|
+
if (flag & BASE_PRESENT_BITMASK) {
|
|
292
|
+
baseVersion = uintFrom8Bytes(b, i);
|
|
293
|
+
i += 8;
|
|
294
|
+
}
|
|
295
|
+
let headerChunk: HeaderChunkInfo|undefined = undefined;
|
|
296
|
+
if (flag & HEADER_PRESENT_BITMASK) {
|
|
297
|
+
const { hInfo, bytesRead } = headerChunkInfo.fromBytes(b, i);
|
|
298
|
+
headerChunk = hInfo;
|
|
299
|
+
i += bytesRead;
|
|
300
|
+
}
|
|
301
|
+
const fileComplete = !!(flag & VERSION_FILE_COMPLETE_BITMASK);
|
|
302
|
+
const segsLayoutFrozen = !!(flag & SEGS_LAYOUT_FROZEN_BITMASK);
|
|
303
|
+
const sizeUnknown = !!(flag & TOTAL_SIZE_NOT_SET_BITMASK);
|
|
304
|
+
const allBaseBytesInFile = !!(flag && ALL_BASE_BYTES_IN_FILE_BITMASK);
|
|
305
|
+
const segsChunks: SegsChunk[] = [];
|
|
306
|
+
while (i < b.length) {
|
|
307
|
+
const { sInfo, bytesRead } = segsChunkInfo.fromBytes(b, i);
|
|
308
|
+
segsChunks.push(sInfo);
|
|
309
|
+
i += bytesRead;
|
|
310
|
+
}
|
|
311
|
+
const attrs = { fileComplete, segsChunks, headerChunk, segsLayoutFrozen,
|
|
312
|
+
baseVersion, sizeUnknown, allBaseBytesInFile };
|
|
313
|
+
validateAttrs(attrs);
|
|
314
|
+
return attrs;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
}
|
|
318
|
+
Object.freeze(layoutV1);
|
|
319
|
+
|
|
320
|
+
function totalLenOf(arrs: Uint8Array[]): number {
|
|
321
|
+
let totalLen = 0;
|
|
322
|
+
for (const arr of arrs) {
|
|
323
|
+
totalLen += arr.length;
|
|
324
|
+
}
|
|
325
|
+
return totalLen;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
Object.freeze(exports);
|