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,1068 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2016 - 2017 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
|
+
|
|
19
|
+
declare namespace web3n {
|
|
20
|
+
|
|
21
|
+
interface RuntimeException {
|
|
22
|
+
runtimeException: true;
|
|
23
|
+
type?: string;
|
|
24
|
+
cause?: any;
|
|
25
|
+
message?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface EncryptionException {
|
|
29
|
+
failedCipherVerification: true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* This is an input byte stream, in classical lingo.
|
|
34
|
+
* Its read method provides greater expectation for consumer, than common
|
|
35
|
+
* streams.
|
|
36
|
+
* All methods should be usable when called separately from the object, i.e.
|
|
37
|
+
* all methods must be functions, already bound to some state/closure.
|
|
38
|
+
*/
|
|
39
|
+
interface ByteSource {
|
|
40
|
+
|
|
41
|
+
// XXX we should add informative method prepareBytes, which sets an
|
|
42
|
+
// expectation about possible number of bytes that will be read from
|
|
43
|
+
// this source.
|
|
44
|
+
// Piped source like decrypting one, may relay respective suggestion to
|
|
45
|
+
// underlying source.
|
|
46
|
+
// For sources like file on a disk, it shall be a noop.
|
|
47
|
+
// This will allow consumer to signal info, which can help upstream
|
|
48
|
+
// to choose best behaviour, like asking network resource to send bytes
|
|
49
|
+
// with less of round trips.
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* This returns a promise of byte array, resolvable when bytes are ready.
|
|
53
|
+
* There will be less bytes than ordered, when there is no more bytes.
|
|
54
|
+
* When the source has already reached its end before this call, promise
|
|
55
|
+
* resolves to undefined.
|
|
56
|
+
* @param len is a number of bytes, which should be read from the source.
|
|
57
|
+
* If source's end comes earlier, number of returned bytes can be less.
|
|
58
|
+
* If undefined is given, all bytes to source end must be returned.
|
|
59
|
+
*/
|
|
60
|
+
read(len: number|undefined): Promise<Uint8Array|undefined>;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* This returns total number of bytes that come from this byte source.
|
|
64
|
+
* Returned value can be undefined, if a byte source does not know its
|
|
65
|
+
* overall size, yet.
|
|
66
|
+
*/
|
|
67
|
+
getSize(): Promise<number|undefined>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* This method sets an offset for the next read.
|
|
71
|
+
* One may re-read bytes, by seeking back, or skip bytes, by moving
|
|
72
|
+
* forward.
|
|
73
|
+
* The method is optional, and its presence depends on implementation.
|
|
74
|
+
* @param offset is a new internal pointer position, counting from
|
|
75
|
+
* stream's absolute beginning.
|
|
76
|
+
*/
|
|
77
|
+
seek?(offset: number): Promise<void>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The method is optional, and it is present when seek method is present.
|
|
81
|
+
* This returns current position in a seekable source.
|
|
82
|
+
*/
|
|
83
|
+
getPosition?(): Promise<number>;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* This is an output byte stream, in classical lingo.
|
|
89
|
+
* Sink sounds simple, as one writes, or dumps bytes into it.
|
|
90
|
+
* All methods should be usable when called separately from the object, i.e.
|
|
91
|
+
* all methods must be functions, already bound to some state/closure.
|
|
92
|
+
*/
|
|
93
|
+
interface ByteSink {
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* This returns a promise, resolvable when write is done.
|
|
97
|
+
* @param bytes to be dumped into this sink.
|
|
98
|
+
* When total size has not been set, or was set as unknown, null must be
|
|
99
|
+
* given to indicate an end of byte stream.
|
|
100
|
+
* When size is set, it is an error to give more bytes, or to give null,
|
|
101
|
+
* before giving all bytes.
|
|
102
|
+
* @param err is an optional parameter, that pushes error along a pipe if
|
|
103
|
+
* such is setup.
|
|
104
|
+
*/
|
|
105
|
+
write(bytes: Uint8Array|null, err?: any): Promise<void>;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* This returns total number of bytes in a bucket where this sink pumps
|
|
109
|
+
* bytes. Returned value can be undefined, if a byte sink does not know
|
|
110
|
+
* its overall size, yet.
|
|
111
|
+
*/
|
|
112
|
+
getSize(): Promise<number|undefined>;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* This function can be called only once. Other calls will throw
|
|
116
|
+
* exceptions.
|
|
117
|
+
* It returns a promise, resolvable when total sink size is set.
|
|
118
|
+
* @param size is a total number of bytes, that will be dumped into this
|
|
119
|
+
* sink. If size is undefined, we explicitly state that size will not be
|
|
120
|
+
* known till end of stream.
|
|
121
|
+
*/
|
|
122
|
+
setSize(size: number|undefined): Promise<void>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* This method sets an offset for the next write.
|
|
126
|
+
* One may write bytes at random places, by seeking back to proper
|
|
127
|
+
* position, together with adjusting total size.
|
|
128
|
+
* The method is optional, and its presence depends on implementation.
|
|
129
|
+
* @param offset is a new internal pointer position, counting from sink's
|
|
130
|
+
* absolute beginning.
|
|
131
|
+
*/
|
|
132
|
+
seek?(offset: number): Promise<void>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The method is optional, and it is present when seek method is present.
|
|
136
|
+
* This returns current position in a seekable sink.
|
|
137
|
+
*/
|
|
138
|
+
getPosition?(): Promise<number>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
interface Observer<T> {
|
|
142
|
+
next?: (value: T) => void;
|
|
143
|
+
error?: (err: any) => void;
|
|
144
|
+
complete?: () => void;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
declare namespace web3n.files {
|
|
150
|
+
|
|
151
|
+
interface FileException extends RuntimeException {
|
|
152
|
+
code: string|undefined;
|
|
153
|
+
path: string;
|
|
154
|
+
notFound?: true;
|
|
155
|
+
alreadyExists?: true;
|
|
156
|
+
notDirectory?: true;
|
|
157
|
+
notFile?: true;
|
|
158
|
+
notLink?: true;
|
|
159
|
+
isDirectory?: true;
|
|
160
|
+
notEmpty?: true;
|
|
161
|
+
endOfFile?: true;
|
|
162
|
+
inconsistentStateOfFS?: true;
|
|
163
|
+
concurrentUpdate?: true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface exceptionCode {
|
|
167
|
+
notFound: 'ENOENT';
|
|
168
|
+
alreadyExists: 'EEXIST';
|
|
169
|
+
notDirectory: 'ENOTDIR';
|
|
170
|
+
notFile: 'ENOTFILE';
|
|
171
|
+
notLink: 'not-link';
|
|
172
|
+
isDirectory: 'EISDIR';
|
|
173
|
+
notEmpty: 'ENOTEMPTY';
|
|
174
|
+
endOfFile: 'EEOF';
|
|
175
|
+
concurrentUpdate: 'concurrent-update';
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Instances of this interface are produced by folder listing method(s).
|
|
180
|
+
*/
|
|
181
|
+
interface ListingEntry {
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* This is name of an entity in its parent folder.
|
|
185
|
+
*/
|
|
186
|
+
name: string;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* When present with true value, it indicates that an entity is a folder.
|
|
190
|
+
*/
|
|
191
|
+
isFolder?: boolean;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* When present with true value, it indicates that an entity is a file.
|
|
195
|
+
*/
|
|
196
|
+
isFile?: boolean;
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* When present with true value, it indicates that an entity is a link.
|
|
200
|
+
*/
|
|
201
|
+
isLink?: boolean;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
interface FileStats {
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* File size in bytes.
|
|
208
|
+
*/
|
|
209
|
+
size: number | undefined;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Last modification time stamp.
|
|
213
|
+
* If such information cannot be provided, this field will be absent.
|
|
214
|
+
*/
|
|
215
|
+
mtime?: Date;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* This tells object's version.
|
|
219
|
+
* If such information cannot be provided, this field will be absent.
|
|
220
|
+
*/
|
|
221
|
+
version?: number;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
type Linkable = File | FS;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* This is an interface for a symbolic link.
|
|
228
|
+
* In unix file systems there are both symbolic and hard links. We do not
|
|
229
|
+
* have hard links here, but we need to highlight that nature of links here
|
|
230
|
+
* is symbolic. For example, when a target is deleted, symbolic link becomes
|
|
231
|
+
* broken.
|
|
232
|
+
*/
|
|
233
|
+
interface SymLink {
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Flag that indicates if access to link's target is readonly (true), or
|
|
237
|
+
* can be writable (false value).
|
|
238
|
+
*/
|
|
239
|
+
readonly: boolean;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Indicates with true value if target is a file
|
|
243
|
+
*/
|
|
244
|
+
isFile?: boolean;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Indicates with true value if target is a folder
|
|
248
|
+
*/
|
|
249
|
+
isFolder?: boolean;
|
|
250
|
+
|
|
251
|
+
target(): Promise<Linkable>;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
type File = ReadonlyFile | ReadonlyVersionedFile |
|
|
255
|
+
WritableFile | WritableVersionedFile;
|
|
256
|
+
|
|
257
|
+
interface BaseFile {
|
|
258
|
+
|
|
259
|
+
writable: boolean;
|
|
260
|
+
|
|
261
|
+
versioned: boolean;
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Is a file name, given by the outside to this file. It may, or may not,
|
|
265
|
+
* be the same as an actual file name in the file system. It may also be
|
|
266
|
+
* null.
|
|
267
|
+
*/
|
|
268
|
+
name: string;
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* Is a flag that says, whether file existed at the moment of this
|
|
272
|
+
* object's creation.
|
|
273
|
+
*/
|
|
274
|
+
isNew: boolean;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* This returns a promise, resolvable to file stats.
|
|
278
|
+
*/
|
|
279
|
+
stat(): Promise<FileStats>;
|
|
280
|
+
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
interface ReadonlyFile extends BaseFile {
|
|
284
|
+
|
|
285
|
+
versioned: false;
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* This returns a promise, resolvable to either non-empty byte array, or
|
|
289
|
+
* undefined.
|
|
290
|
+
* @param start optional parameter, setting a beginning of read. If
|
|
291
|
+
* missing, read will be done as if neither start, nor end parameters
|
|
292
|
+
* are given.
|
|
293
|
+
* @param end optional parameter, setting an end of read. If end is
|
|
294
|
+
* greater than file length, all available bytes are read. If parameter
|
|
295
|
+
* is missing, read will be done to file's end.
|
|
296
|
+
*/
|
|
297
|
+
readBytes(start?: number, end?: number): Promise<Uint8Array|undefined>;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* This returns a promise, resolvable to text, read from file, assuming
|
|
301
|
+
* utf8 encoding.
|
|
302
|
+
*/
|
|
303
|
+
readTxt(): Promise<string>;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* This returns a promise, resolvable to json, read from file
|
|
307
|
+
*/
|
|
308
|
+
readJSON<T>(): Promise<T>;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* This returns a promise, resolvable to bytes source with seek, which
|
|
312
|
+
* allows random reads.
|
|
313
|
+
*/
|
|
314
|
+
getByteSource(): Promise<web3n.ByteSource>;
|
|
315
|
+
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
interface WritableFile extends ReadonlyFile {
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* This returns a promise, resolvable when file is written
|
|
322
|
+
* @param bytes is a complete file content to write
|
|
323
|
+
*/
|
|
324
|
+
writeBytes(bytes: Uint8Array): Promise<void>;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* This returns a promise, resolvable when file is written
|
|
328
|
+
* @param txt to write to file, using utf8 encoding
|
|
329
|
+
*/
|
|
330
|
+
writeTxt(txt: string): Promise<void>;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* This returns a promise, resolvable when file is written
|
|
334
|
+
* @param json
|
|
335
|
+
*/
|
|
336
|
+
writeJSON(json: any): Promise<void>;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* This returns a promise, resolvable to byte sink with seek
|
|
340
|
+
*/
|
|
341
|
+
getByteSink(): Promise<web3n.ByteSink>;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* This returns a promise, resolvable when copying is done.
|
|
345
|
+
* @param file which content will be copied into this file
|
|
346
|
+
*/
|
|
347
|
+
copy(file: File): Promise<void>;
|
|
348
|
+
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
interface ReadonlyVersionedFile extends BaseFile {
|
|
352
|
+
|
|
353
|
+
versioned: true;
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* This returns a promise, resolvable to either non-empty byte array, or
|
|
357
|
+
* undefined.
|
|
358
|
+
* @param start optional parameter, setting a beginning of read. If
|
|
359
|
+
* missing, read will be done as if neither start, nor end parameters
|
|
360
|
+
* are given.
|
|
361
|
+
* @param end optional parameter, setting an end of read. If end is
|
|
362
|
+
* greater than file length, all available bytes are read. If parameter
|
|
363
|
+
* is missing, read will be done to file's end.
|
|
364
|
+
*/
|
|
365
|
+
readBytes(start?: number, end?: number):
|
|
366
|
+
Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* This returns a promise, resolvable to text, read from file, assuming
|
|
370
|
+
* utf8 encoding.
|
|
371
|
+
*/
|
|
372
|
+
readTxt(): Promise<{ txt: string; version: number; }>;
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* This returns a promise, resolvable to json, read from file
|
|
376
|
+
*/
|
|
377
|
+
readJSON<T>(): Promise<{ json: T; version: number; }>;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* This returns a promise, resolvable to bytes source with seek, which
|
|
381
|
+
* allows random reads, and a file version
|
|
382
|
+
*/
|
|
383
|
+
getByteSource(): Promise<{ src: web3n.ByteSource; version: number; }>;
|
|
384
|
+
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
interface WritableVersionedFile extends ReadonlyVersionedFile {
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
391
|
+
* written
|
|
392
|
+
* @param bytes is a complete file content to write
|
|
393
|
+
*/
|
|
394
|
+
writeBytes(bytes: Uint8Array): Promise<number>;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
398
|
+
* written
|
|
399
|
+
* @param txt to write to file, using utf8 encoding
|
|
400
|
+
*/
|
|
401
|
+
writeTxt(txt: string): Promise<number>;
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
405
|
+
* written
|
|
406
|
+
* @param json
|
|
407
|
+
*/
|
|
408
|
+
writeJSON(json: any): Promise<number>;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* This returns a promise, resolvable to byte sink with seek, and a file
|
|
412
|
+
* version
|
|
413
|
+
*/
|
|
414
|
+
getByteSink(): Promise<{ sink: web3n.ByteSink; version: number; }>;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* This returns a promise, resolvable to new file's version when copying
|
|
418
|
+
* is done.
|
|
419
|
+
* @param file which content will be copied into this file
|
|
420
|
+
*/
|
|
421
|
+
copy(file: File): Promise<number>;
|
|
422
|
+
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
type FSType = 'device' | 'synced' | 'local' | 'share' | 'asmail-msg';
|
|
426
|
+
|
|
427
|
+
type FS = ReadonlyFS | ReadonlyVersionedFS |
|
|
428
|
+
WritableFS | WritableVersionedFS;
|
|
429
|
+
|
|
430
|
+
interface BaseFS {
|
|
431
|
+
|
|
432
|
+
type: FSType;
|
|
433
|
+
|
|
434
|
+
versioned: boolean;
|
|
435
|
+
|
|
436
|
+
writable: boolean;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Is a folder name, given by the outside to this file system. It may, or
|
|
440
|
+
* may not, be the same as an actual folder name. It may also be null.
|
|
441
|
+
*/
|
|
442
|
+
name: string;
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* This returns a promise, resolvable to true, if folder exists, and to
|
|
446
|
+
* false, if folder is not found.
|
|
447
|
+
* @param path of a folder, which presence we want to check
|
|
448
|
+
* @param throwIfMissing is an optional flag, which forces with true value
|
|
449
|
+
* throwing of an exception, when folder does not exist. Default value is
|
|
450
|
+
* false.
|
|
451
|
+
*/
|
|
452
|
+
checkFolderPresence(path: string, throwIfMissing?: boolean):
|
|
453
|
+
Promise<boolean>;
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* This returns a promise, resolvable to true, if file exists, and to
|
|
457
|
+
* false, if file is not found.
|
|
458
|
+
* @param path of a file, which presence we want to check
|
|
459
|
+
* @param throwIfMissing is an optional flag, which forces with true value
|
|
460
|
+
* throwing of an exception, when file does not exist. Default value is
|
|
461
|
+
* false.
|
|
462
|
+
*/
|
|
463
|
+
checkFilePresence(path: string, throwIfMissing?: boolean):
|
|
464
|
+
Promise<boolean>;
|
|
465
|
+
|
|
466
|
+
/**
|
|
467
|
+
* This returns a promise, resolvable to true, if link exists, and to
|
|
468
|
+
* false, if link is not found.
|
|
469
|
+
* @param path of a link, which presence we want to check
|
|
470
|
+
* @param throwIfMissing is an optional flag, which forces with true value
|
|
471
|
+
* throwing of an exception, when link does not exist. Default value is
|
|
472
|
+
* false.
|
|
473
|
+
*/
|
|
474
|
+
checkLinkPresence(path: string, throwIfMissing?: boolean):
|
|
475
|
+
Promise<boolean>;
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* @param path of a file
|
|
479
|
+
* This returns a promise, resolvable to file stats.
|
|
480
|
+
*/
|
|
481
|
+
statFile(path: string): Promise<FileStats>;
|
|
482
|
+
|
|
483
|
+
readLink(path: string): Promise<SymLink>;
|
|
484
|
+
|
|
485
|
+
watchFolder(path: string, observer: Observer<FolderEvent>): () => void;
|
|
486
|
+
|
|
487
|
+
close(): Promise<void>;
|
|
488
|
+
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
interface ReadonlyFS extends BaseFS {
|
|
492
|
+
|
|
493
|
+
versioned: false;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* This returns a promise, resolvable to a file system object, rooted to a
|
|
497
|
+
* given folder.
|
|
498
|
+
* @param folder is a path of a root folder.
|
|
499
|
+
*/
|
|
500
|
+
readonlySubRoot(folder: string): Promise<ReadonlyFS>;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* This returns a promise, resolvable to a list of informational objects
|
|
504
|
+
* for entries in the folder.
|
|
505
|
+
* @param path of a folder that should be listed
|
|
506
|
+
*/
|
|
507
|
+
listFolder(folder: string): Promise<ListingEntry[]>;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* This returns a promise, resolvable to json, read from file
|
|
511
|
+
* @param path of a file from which to read json
|
|
512
|
+
*/
|
|
513
|
+
readJSONFile<T>(path: string): Promise<T>;
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* This returns a promise, resolvable to text, read from file, assuming
|
|
517
|
+
* utf8 encoding.
|
|
518
|
+
* @param path of a file from which to read text
|
|
519
|
+
*/
|
|
520
|
+
readTxtFile(path: string): Promise<string>;
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* This returns a promise, resolvable to either non-empty byte array, or
|
|
524
|
+
* undefined.
|
|
525
|
+
* @param path of a file from which to read bytes
|
|
526
|
+
* @param start optional parameter, setting a beginning of read. If
|
|
527
|
+
* missing, read will be done as if neither start, nor end parameters
|
|
528
|
+
* are given.
|
|
529
|
+
* @param end optional parameter, setting an end of read. If end is
|
|
530
|
+
* greater than file length, all available bytes are read. If parameter
|
|
531
|
+
* is missing, read will be done to file's end.
|
|
532
|
+
*/
|
|
533
|
+
readBytes(path: string, start?: number, end?: number):
|
|
534
|
+
Promise<Uint8Array|undefined>;
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* This returns a promise, resolvable to bytes source with seek, which
|
|
538
|
+
* allows random reads.
|
|
539
|
+
* @param path of a file from which to read bytes
|
|
540
|
+
*/
|
|
541
|
+
getByteSource(path: string): Promise<web3n.ByteSource>;
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* This returns a promise, resolvable to readonly file object.
|
|
545
|
+
* @param path
|
|
546
|
+
*/
|
|
547
|
+
readonlyFile(path: string): Promise<ReadonlyFile>;
|
|
548
|
+
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
interface BaseWritableFS {
|
|
552
|
+
|
|
553
|
+
/**
|
|
554
|
+
* This either finds existing, or creates new folder, asynchronously.
|
|
555
|
+
* @param path of a folder that should be created
|
|
556
|
+
* @param exclusive is an optional flag, which when set to true, throws
|
|
557
|
+
* if folder already exists. Default value is false, i.e. if folder
|
|
558
|
+
* exists, nothing happens.
|
|
559
|
+
*/
|
|
560
|
+
makeFolder(path: string, exclusive?: boolean): Promise<void>;
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* This returns a promise, resolvable when folder has been removed
|
|
564
|
+
* @param path of a folder that should be removed
|
|
565
|
+
* @param removeContent is an optional flag, which true values forces
|
|
566
|
+
* recursive removal of all content in the folder. Default value is false.
|
|
567
|
+
* If folder is not empty, and content removal flag is not set, then an
|
|
568
|
+
* error is thrown.
|
|
569
|
+
*/
|
|
570
|
+
deleteFolder(path: string, removeContent?: boolean): Promise<void>;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* This returns a promise, resolvable when file has been removed
|
|
574
|
+
* @param path of a file that should be removed
|
|
575
|
+
*/
|
|
576
|
+
deleteFile(path: string): Promise<void>;
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* This returns a promise, resolvable when file (or folder) has been
|
|
580
|
+
* moved.
|
|
581
|
+
* @param src is an initial path of a file (or folder)
|
|
582
|
+
* @param dst is a new path of a file (or folder)
|
|
583
|
+
*/
|
|
584
|
+
move(src: string, dst: string): Promise<void>;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* This returns a promise, resolvable when file has been copied.
|
|
588
|
+
* @param src is an initial path of a file
|
|
589
|
+
* @param dst is a path of a file
|
|
590
|
+
* @param overwrite is a flag that with a true value allows
|
|
591
|
+
* overwrite of existing dst file. Default value is false.
|
|
592
|
+
*/
|
|
593
|
+
copyFile(src: string, dst: string, overwrite?: boolean):
|
|
594
|
+
Promise<void>;
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* This returns a promise, resolvable when folder has been recursively
|
|
598
|
+
* copied.
|
|
599
|
+
* @param src is an initial path of a folder
|
|
600
|
+
* @param dst is a path of a folder
|
|
601
|
+
* @param mergeAndOverwrite is a flag that with true value allows
|
|
602
|
+
* merge into existing folder and files overwriting inside. Default
|
|
603
|
+
* value is false.
|
|
604
|
+
*/
|
|
605
|
+
copyFolder(src: string, dst: string, mergeAndOverwrite?: boolean):
|
|
606
|
+
Promise<void>;
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* This returns a promise, resolvable when file has been saved.
|
|
610
|
+
* @param file is a file to save
|
|
611
|
+
* @param dst is a path where to save given file
|
|
612
|
+
* @param overwrite is a flag that with a true value allows
|
|
613
|
+
* overwrite of existing dst file. Default value is false.
|
|
614
|
+
*/
|
|
615
|
+
saveFile(file: File, dst: string, overwrite?: boolean): Promise<void>;
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* This returns a promise, resolvable when folder has been recursively
|
|
619
|
+
* saved.
|
|
620
|
+
* @param folder is a folder to save
|
|
621
|
+
* @param dst is a path where to save given folder
|
|
622
|
+
* @param mergeAndOverwrite is a flag that with true value allows
|
|
623
|
+
* merge into existing folder and files overwriting inside. Default
|
|
624
|
+
* value is false.
|
|
625
|
+
*/
|
|
626
|
+
saveFolder(folder: FS, dst: string, mergeAndOverwrite?: boolean):
|
|
627
|
+
Promise<void>;
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* This returns a promise, resolvable when file has been removed
|
|
631
|
+
* @param path of a link that should be removed
|
|
632
|
+
*/
|
|
633
|
+
deleteLink(path: string): Promise<void>;
|
|
634
|
+
|
|
635
|
+
link(path: string, target: File | FS):
|
|
636
|
+
Promise<void>;
|
|
637
|
+
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
interface WritableFS extends ReadonlyFS, BaseWritableFS {
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* This returns a promise, resolvable to a file system object, rooted to a
|
|
644
|
+
* given folder.
|
|
645
|
+
* @param folder is a path of a root folder.
|
|
646
|
+
* @param create is a flag, which, with default value true, allows
|
|
647
|
+
* creation of sub-root folder, if it does not exist
|
|
648
|
+
* @param exclusive is a flag, that ensures exclusive creation of file
|
|
649
|
+
* with true value, while default value is false.
|
|
650
|
+
*/
|
|
651
|
+
writableSubRoot(folder: string, create?: boolean, exclusive?: boolean):
|
|
652
|
+
Promise<WritableFS>;
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* This returns a promise, resolvable when file is written
|
|
656
|
+
* @param path of a file to write given json
|
|
657
|
+
* @param json
|
|
658
|
+
* @param create is a flag, which, with default value true, allows
|
|
659
|
+
* creation of file, if it does not exist
|
|
660
|
+
* @param exclusive is a flag, which, with value true, throws up if file
|
|
661
|
+
* should be create and already exists. Default flag's value is false.
|
|
662
|
+
*/
|
|
663
|
+
writeJSONFile(path: string, json: any, create?: boolean,
|
|
664
|
+
exclusive?: boolean): Promise<void>;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* This returns a promise, resolvable when file is written
|
|
668
|
+
* @param path of a file to write given text
|
|
669
|
+
* @param txt to write to file, using utf8 encoding
|
|
670
|
+
* @param create is a flag, which, with default value true, allows
|
|
671
|
+
* creation of file, if it does not exist
|
|
672
|
+
* @param exclusive is a flag, which, with value true, throws up if file
|
|
673
|
+
* should be create and already exists. Default flag's value is false.
|
|
674
|
+
*/
|
|
675
|
+
writeTxtFile(path: string, txt: string, create?: boolean,
|
|
676
|
+
exclusive?: boolean): Promise<void>;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* This returns a promise, resolvable when file is written
|
|
680
|
+
* @param path of a file to write
|
|
681
|
+
* @param bytes to write to file. This is a whole of file content.
|
|
682
|
+
* @param create is a flag, which, with default value true, allows
|
|
683
|
+
* creation of file, if it does not exist
|
|
684
|
+
* @param exclusive is a flag, which, with value true, throws up if file
|
|
685
|
+
* should be create and already exists. Default flag's value is false.
|
|
686
|
+
*/
|
|
687
|
+
writeBytes(path: string, bytes: Uint8Array, create?: boolean,
|
|
688
|
+
exclusive?: boolean): Promise<void>;
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
* This returns a promise, resolvable to byte sink with seek
|
|
692
|
+
* @param path of a file for which we want to get a writable byte sink
|
|
693
|
+
* @param create is a flag, which, with default value true, allows
|
|
694
|
+
* creation of file, if it does not exist
|
|
695
|
+
* @param exclusive is a flag, that ensures exclusive creation of file
|
|
696
|
+
* with true value, while default value is false.
|
|
697
|
+
*/
|
|
698
|
+
getByteSink(path: string, create?: boolean, exclusive?: boolean):
|
|
699
|
+
Promise<web3n.ByteSink>;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* This returns a promise, resolvable to file object.
|
|
703
|
+
* @param path
|
|
704
|
+
* @param create is a flag, which, with default value true, allows
|
|
705
|
+
* creation of file, if it does not exist
|
|
706
|
+
* @param exclusive is a flag, that ensures exclusive creation of file
|
|
707
|
+
* with true value, while default value is false.
|
|
708
|
+
*/
|
|
709
|
+
writableFile(path: string, create?: boolean, exclusive?: boolean):
|
|
710
|
+
Promise<WritableFile>;
|
|
711
|
+
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
interface ReadonlyVersionedFS extends BaseFS {
|
|
715
|
+
|
|
716
|
+
versioned: true;
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* This returns a promise, resolvable to a file system object, rooted to a
|
|
720
|
+
* given folder.
|
|
721
|
+
* @param folder is a path of a root folder.
|
|
722
|
+
*/
|
|
723
|
+
readonlySubRoot(folder: string): Promise<ReadonlyVersionedFS>;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* This returns a promise, resolvable to a list of informational objects
|
|
727
|
+
* for entries in the folder, and a folder's version.
|
|
728
|
+
* @param path of a folder that should be listed
|
|
729
|
+
*/
|
|
730
|
+
listFolder(path: string):
|
|
731
|
+
Promise<{ lst: ListingEntry[]; version: number; }>;
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* This returns a promise, resolvable to json, read from file, and a
|
|
735
|
+
* version of file.
|
|
736
|
+
* @param path of a file from which to read json
|
|
737
|
+
*/
|
|
738
|
+
readJSONFile<T>(path: string): Promise<{ json: T; version: number; }>;
|
|
739
|
+
|
|
740
|
+
/**
|
|
741
|
+
* This returns a promise, resolvable to text, read from file, assuming
|
|
742
|
+
* utf8 encoding, and version of file.
|
|
743
|
+
* @param path of a file from which to read text
|
|
744
|
+
*/
|
|
745
|
+
readTxtFile(path: string): Promise<{ txt: string; version: number; }>;
|
|
746
|
+
|
|
747
|
+
/**
|
|
748
|
+
* This returns a promise, resolvable to bytes, that is either non-empty
|
|
749
|
+
* byte array, or an undefined, and version of file.
|
|
750
|
+
* @param path of a file from which to read bytes
|
|
751
|
+
* @param start optional parameter, setting a beginning of read. If
|
|
752
|
+
* missing, read will be done as if neither start, nor end parameters
|
|
753
|
+
* are given.
|
|
754
|
+
* @param end optional parameter, setting an end of read. If end is
|
|
755
|
+
* greater than file length, all available bytes are read. If parameter
|
|
756
|
+
* is missing, read will be done to file's end.
|
|
757
|
+
*/
|
|
758
|
+
readBytes(path: string, start?: number, end?: number):
|
|
759
|
+
Promise<{ bytes: Uint8Array|undefined; version: number; }>;
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* This returns a promise, resolvable to bytes source with seek, which
|
|
763
|
+
* allows random reads, and a file version
|
|
764
|
+
* @param path of a file from which to read bytes
|
|
765
|
+
*/
|
|
766
|
+
getByteSource(path: string):
|
|
767
|
+
Promise<{ src: web3n.ByteSource; version: number; }>;
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* This returns a promise, resolvable to readonly file object.
|
|
771
|
+
* @param path
|
|
772
|
+
*/
|
|
773
|
+
readonlyFile(path: string): Promise<ReadonlyVersionedFile>;
|
|
774
|
+
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
interface WritableVersionedFS extends ReadonlyVersionedFS, BaseWritableFS {
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* This returns a promise, resolvable to a file system object, rooted to a
|
|
781
|
+
* given folder.
|
|
782
|
+
* @param folder is a path of a root folder.
|
|
783
|
+
* @param create is a flag, which, with default value true, allows
|
|
784
|
+
* creation of sub-root folder, if it does not exist
|
|
785
|
+
* @param exclusive is a flag, that ensures exclusive creation of file
|
|
786
|
+
* with true value, while default value is false.
|
|
787
|
+
*/
|
|
788
|
+
writableSubRoot(folder: string, create?: boolean, exclusive?: boolean):
|
|
789
|
+
Promise<WritableVersionedFS>;
|
|
790
|
+
|
|
791
|
+
/**
|
|
792
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
793
|
+
* written.
|
|
794
|
+
* @param path of a file to write given json
|
|
795
|
+
* @param json
|
|
796
|
+
* @param create is a flag, which, with default value true, allows
|
|
797
|
+
* creation of file, if it does not exist
|
|
798
|
+
* @param exclusive is a flag, which, with value true, throws up if file
|
|
799
|
+
* should be create and already exists. Default flag's value is false.
|
|
800
|
+
*/
|
|
801
|
+
writeJSONFile(path: string, json: any, create?: boolean,
|
|
802
|
+
exclusive?: boolean): Promise<number>;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
806
|
+
* written
|
|
807
|
+
* @param path of a file to write given text
|
|
808
|
+
* @param txt to write to file, using utf8 encoding
|
|
809
|
+
* @param create is a flag, which, with default value true, allows
|
|
810
|
+
* creation of file, if it does not exist
|
|
811
|
+
* @param exclusive is a flag, which, with value true, throws up if file
|
|
812
|
+
* should be create and already exists. Default flag's value is false.
|
|
813
|
+
*/
|
|
814
|
+
writeTxtFile(path: string, txt: string, create?: boolean,
|
|
815
|
+
exclusive?: boolean): Promise<number>;
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* This returns a promise, resolvable to new file's version when file is
|
|
819
|
+
* written
|
|
820
|
+
* @param path of a file to write
|
|
821
|
+
* @param bytes to write to file. This is a whole of file content.
|
|
822
|
+
* @param create is a flag, which, with default value true, allows
|
|
823
|
+
* creation of file, if it does not exist
|
|
824
|
+
* @param exclusive is a flag, which, with value true, throws up if file
|
|
825
|
+
* should be create and already exists. Default flag's value is false.
|
|
826
|
+
*/
|
|
827
|
+
writeBytes(path: string, bytes: Uint8Array, create?: boolean,
|
|
828
|
+
exclusive?: boolean): Promise<number>;
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* This returns a promise, resolvable to byte sink with seek, and a file
|
|
832
|
+
* version
|
|
833
|
+
* @param path of a file for which we want to get a writable byte sink
|
|
834
|
+
* @param create is a flag, which, with default value true, allows
|
|
835
|
+
* creation of file, if it does not exist
|
|
836
|
+
* @param exclusive is a flag, that ensures exclusive creation of file
|
|
837
|
+
* with true value, while default value is false.
|
|
838
|
+
*/
|
|
839
|
+
getByteSink(path: string, create?: boolean, exclusive?: boolean):
|
|
840
|
+
Promise<{ sink: web3n.ByteSink; version: number; }>;
|
|
841
|
+
|
|
842
|
+
/**
|
|
843
|
+
* This returns a promise, resolvable to file object.
|
|
844
|
+
* @param path
|
|
845
|
+
* @param create is a flag, which, with default value true, allows
|
|
846
|
+
* creation of file, if it does not exist
|
|
847
|
+
* @param exclusive is a flag, that ensures exclusive creation of file
|
|
848
|
+
* with true value, while default value is false.
|
|
849
|
+
*/
|
|
850
|
+
writableFile(path: string, create?: boolean, exclusive?: boolean):
|
|
851
|
+
Promise<WritableVersionedFile>;
|
|
852
|
+
|
|
853
|
+
tryUnblock(path: string, exc: FileException): Promise<number>;
|
|
854
|
+
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
interface FSEvent {
|
|
858
|
+
type: string;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
type FolderEvent = EntryRemovalEvent | EntryAdditionEvent;
|
|
862
|
+
|
|
863
|
+
interface EntryRemovalEvent extends FSEvent {
|
|
864
|
+
type: 'entry-removal';
|
|
865
|
+
name: string;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
interface EntryAdditionEvent extends FSEvent {
|
|
869
|
+
type: 'entry-addition';
|
|
870
|
+
entry: ListingEntry;
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
declare namespace web3n.ipc {
|
|
876
|
+
|
|
877
|
+
interface Duplex {
|
|
878
|
+
|
|
879
|
+
/**
|
|
880
|
+
* This functionality actually does sending/receiving of message
|
|
881
|
+
* envelopes of this duplex.
|
|
882
|
+
*/
|
|
883
|
+
raw: RawDuplex<Envelope>;
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* This function creates a more convenient functionality for this side to
|
|
887
|
+
* act as a client, viewing/using other side as a server.
|
|
888
|
+
* Note that communication still goes through this duplex's raw duplex.
|
|
889
|
+
*/
|
|
890
|
+
makeClient(channel: string): SubscribingClient;
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* This function creates a more convenient functionality for this side to
|
|
894
|
+
* act as a server, viewing/serving other side as a client.
|
|
895
|
+
* Note that communication still goes through this duplex's raw duplex.
|
|
896
|
+
*/
|
|
897
|
+
makeServer(channel: string): EventfulServer;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
interface RawDuplex<T> {
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* This function triggers sending of a given message to the other side.
|
|
904
|
+
* Implementation may throw an error, if duplex is already disconnected.
|
|
905
|
+
* @param m
|
|
906
|
+
*/
|
|
907
|
+
postMessage(m: T): void;
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* This function subscribes given observer to receive message that come
|
|
911
|
+
* from the other side.
|
|
912
|
+
* @param observer
|
|
913
|
+
*/
|
|
914
|
+
subscribe(observer: Observer<T>): () => void;
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
interface RequestEnvelope<T> {
|
|
918
|
+
type: 'request';
|
|
919
|
+
name: string;
|
|
920
|
+
count: number;
|
|
921
|
+
req: T;
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
interface ReplyEnvelope<T> {
|
|
925
|
+
type: 'reply';
|
|
926
|
+
reqName: string;
|
|
927
|
+
reqCount: number;
|
|
928
|
+
isInProgress?: boolean;
|
|
929
|
+
rep: T|null;
|
|
930
|
+
err?: any;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
interface EventEnvelope<T> {
|
|
934
|
+
type: 'event';
|
|
935
|
+
channel: string;
|
|
936
|
+
event: T;
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
interface EventEndEnvelope {
|
|
940
|
+
type: 'event-end';
|
|
941
|
+
channel: string;
|
|
942
|
+
err?: any;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
type Envelope = RequestEnvelope<any> | ReplyEnvelope<any> |
|
|
946
|
+
EventEnvelope<any> | EventEndEnvelope;
|
|
947
|
+
|
|
948
|
+
interface EventException extends web3n.RuntimeException {
|
|
949
|
+
type: 'events';
|
|
950
|
+
unknownEvent?: true;
|
|
951
|
+
channel?: string;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
interface RequestServer extends Closable {
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* @param reqName is a name of request, to be handled by a given handler
|
|
958
|
+
* @param handler handles requests that come from the other side
|
|
959
|
+
*/
|
|
960
|
+
addHandler(reqName: string, handler: RequestHandler<any, any>): void;
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* This method sends a notification of a progress on a given request.
|
|
964
|
+
* @param env is a request to which notification should be maid
|
|
965
|
+
* @param rep is a notification object
|
|
966
|
+
*/
|
|
967
|
+
notifyOfProgressOnRequest<T>(env: RequestEnvelope<any>, rep: T): void;
|
|
968
|
+
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
type RequestHandler<TReq, TRes> =
|
|
972
|
+
(env: RequestEnvelope<TReq>) => Promise<TRes>|void;
|
|
973
|
+
|
|
974
|
+
interface RequestingClient extends Closable {
|
|
975
|
+
|
|
976
|
+
/**
|
|
977
|
+
* This returns a promise, resolvable to a reply that other side sends back,
|
|
978
|
+
* when it completes a request.
|
|
979
|
+
* This is a generic method with type T being a type of a final reply.
|
|
980
|
+
* @param reqName is a name of this request, sort of like a function name
|
|
981
|
+
* @param req is a request object that is sent to worker in the message
|
|
982
|
+
*/
|
|
983
|
+
makeRequest<T>(reqName: string, req: any,
|
|
984
|
+
notifyCallback?: (progress: any) => void): Promise<T>;
|
|
985
|
+
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
/**
|
|
989
|
+
* Eventful server is a side of an ipc channel. As a request server, it serves
|
|
990
|
+
* requests that come from another side of an ipc channel. This server also
|
|
991
|
+
* sends events to another side, but only if the other side subscribed to a
|
|
992
|
+
* particular event channels.
|
|
993
|
+
*/
|
|
994
|
+
interface EventfulServer extends RequestServer {
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* This function adds available event group. For some events event group is
|
|
998
|
+
* exactly the same as an event channel. For other events group is a prefix
|
|
999
|
+
* for an actual event.
|
|
1000
|
+
* @param eventGroup is either a complete event channel, or a prefix
|
|
1001
|
+
* that defines events' group
|
|
1002
|
+
* @param subscriptionHandler is an async function that checks if a given
|
|
1003
|
+
* event channel can be subscribed to. If subscription cannot be done, an
|
|
1004
|
+
* error should be thrown with respective reason.
|
|
1005
|
+
* @param unsubscriptionHandler is a function, if given, is called when
|
|
1006
|
+
* last consumer is unsubscribed from a given group of events.
|
|
1007
|
+
*/
|
|
1008
|
+
addEventGroup(eventGroup: string,
|
|
1009
|
+
subscriptionHandler: (eventChannel: string) => Promise<void>|void,
|
|
1010
|
+
unsubscriptionHandler?: (eventChannel: string) => void): void;
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* This function sends an event, if another side have subscribed to it, else
|
|
1014
|
+
* it is a noop.
|
|
1015
|
+
* @param channel
|
|
1016
|
+
* @param event
|
|
1017
|
+
*/
|
|
1018
|
+
sendEvent<T>(channel: string, event: T): void;
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* This function sends an event end notification, unsubscribing the other
|
|
1022
|
+
* side from a given event channel.
|
|
1023
|
+
* @param channel
|
|
1024
|
+
* @param err is should be given to make it a completion on error
|
|
1025
|
+
*/
|
|
1026
|
+
endEvent(channel: string, err?: any): void;
|
|
1027
|
+
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* Subscribing client is a side of an ipc channel. As a requesting client, it
|
|
1032
|
+
* makes request-reply style calls to the other side of the ipc channel.
|
|
1033
|
+
* Subscribing functionality allows to subscribe to particular event channels,
|
|
1034
|
+
* for events coming from the other side.
|
|
1035
|
+
*/
|
|
1036
|
+
interface SubscribingClient extends RequestingClient {
|
|
1037
|
+
|
|
1038
|
+
/**
|
|
1039
|
+
* This function subscribes given in observer callbacks to an event channel,
|
|
1040
|
+
* returning a function that detaches the observer, when called.
|
|
1041
|
+
* Due to immediate subscription, given in observer callbacks become hot.
|
|
1042
|
+
* @param channel
|
|
1043
|
+
* @param observer is an object with at least one of three methods: next,
|
|
1044
|
+
* completed, and error.
|
|
1045
|
+
* Method next it is an on-event callback, called every time there is an
|
|
1046
|
+
* event, which can be zero or more times. This is never called after either
|
|
1047
|
+
* completion, error, or detachment.
|
|
1048
|
+
* Method completed is a callback that is called only once, when event
|
|
1049
|
+
* source says that there will be no more events, i.e. when a normal
|
|
1050
|
+
* completion occurs. Note that this function is not called when detacher
|
|
1051
|
+
* is triggered.
|
|
1052
|
+
* Method error is a callback that is called on error, either coming from
|
|
1053
|
+
* event source, or if onNext throws something, although it must handle its
|
|
1054
|
+
* own stuff.
|
|
1055
|
+
*/
|
|
1056
|
+
subscribe<T>(channel: string, observer: Observer<T>): () => void;
|
|
1057
|
+
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
interface Closable {
|
|
1061
|
+
|
|
1062
|
+
close(): void;
|
|
1063
|
+
|
|
1064
|
+
on(event: 'end', cb: (err?: any) => void): void;
|
|
1065
|
+
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
}
|