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,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 - 2017 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.afterEachAsync = exports.beforeEachAsync = exports.afterAllAsync = exports.beforeAllAsync = exports.fitAsync = exports.xitAsync = exports.itAsync = void 0;
|
|
20
|
+
function itAsync(expectation, assertion, timeout) {
|
|
21
|
+
if (assertion) {
|
|
22
|
+
it(expectation, done => {
|
|
23
|
+
assertion().then(() => done(), err => done.fail(err));
|
|
24
|
+
}, timeout);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
it(expectation);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.itAsync = itAsync;
|
|
31
|
+
function xitAsync(expectation, assertion, timeout) {
|
|
32
|
+
if (assertion) {
|
|
33
|
+
xit(expectation, done => {
|
|
34
|
+
assertion().then(() => done(), err => done.fail(err));
|
|
35
|
+
}, timeout);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
xit(expectation);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.xitAsync = xitAsync;
|
|
42
|
+
function fitAsync(expectation, assertion, timeout) {
|
|
43
|
+
if (assertion) {
|
|
44
|
+
fit(expectation, done => {
|
|
45
|
+
assertion().then(() => done(), err => done.fail(err));
|
|
46
|
+
}, timeout);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
fit(expectation);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.fitAsync = fitAsync;
|
|
53
|
+
function beforeAllAsync(action, timeout) {
|
|
54
|
+
beforeAll(done => {
|
|
55
|
+
action().then(() => done(), err => done.fail(err));
|
|
56
|
+
}, timeout);
|
|
57
|
+
}
|
|
58
|
+
exports.beforeAllAsync = beforeAllAsync;
|
|
59
|
+
function afterAllAsync(action, timeout) {
|
|
60
|
+
afterAll(done => {
|
|
61
|
+
action().then(() => done(), err => done.fail(err));
|
|
62
|
+
}, timeout);
|
|
63
|
+
}
|
|
64
|
+
exports.afterAllAsync = afterAllAsync;
|
|
65
|
+
function beforeEachAsync(action, timeout) {
|
|
66
|
+
beforeEach(done => {
|
|
67
|
+
action().then(() => done(), err => done.fail(err));
|
|
68
|
+
}, timeout);
|
|
69
|
+
}
|
|
70
|
+
exports.beforeEachAsync = beforeEachAsync;
|
|
71
|
+
function afterEachAsync(action, timeout) {
|
|
72
|
+
afterEach(done => {
|
|
73
|
+
action().then(() => done(), err => done.fail(err));
|
|
74
|
+
}, timeout);
|
|
75
|
+
}
|
|
76
|
+
exports.afterEachAsync = afterEachAsync;
|
|
77
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function bytesEqual(a: Uint8Array, b: Uint8Array): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.bytesEqual = void 0;
|
|
20
|
+
function bytesEqual(a, b) {
|
|
21
|
+
if (a.BYTES_PER_ELEMENT !== b.BYTES_PER_ELEMENT) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
if (a.length !== b.length) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
for (let i = 0; i < a.length; i += 1) {
|
|
28
|
+
if (a[i] !== b[i]) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
exports.bytesEqual = bytesEqual;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copy<T>(orig: T): T;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.copy = void 0;
|
|
20
|
+
function copy(orig) {
|
|
21
|
+
if (typeof orig !== 'object') {
|
|
22
|
+
return orig;
|
|
23
|
+
}
|
|
24
|
+
if (orig === null) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (Array.isArray(orig)) {
|
|
28
|
+
let arr = orig;
|
|
29
|
+
let c = [];
|
|
30
|
+
for (let i = 0; i < arr.length; i += 1) {
|
|
31
|
+
c[i] = copy(arr[i]);
|
|
32
|
+
}
|
|
33
|
+
return c;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
let c = {};
|
|
37
|
+
let fields = Object.keys(orig);
|
|
38
|
+
for (let f of fields) {
|
|
39
|
+
c[f] = copy(orig[f]);
|
|
40
|
+
}
|
|
41
|
+
return c;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.copy = copy;
|
|
45
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2015 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.deepEqual = void 0;
|
|
20
|
+
/**
|
|
21
|
+
* This module provides hex encoding of binary array into a string.
|
|
22
|
+
*/
|
|
23
|
+
function deepEqual(a, b) {
|
|
24
|
+
let t = typeof a;
|
|
25
|
+
if (t !== typeof b) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
if (t !== 'object') {
|
|
29
|
+
return (a === b);
|
|
30
|
+
}
|
|
31
|
+
if (a === b) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
if ((a === null) || (b === null)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(a)) {
|
|
38
|
+
if (!Array.isArray(b)) {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
let aArr = a;
|
|
42
|
+
let bArr = b;
|
|
43
|
+
if (aArr.length !== bArr.length) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
for (let i = 0; i < aArr.length; i += 1) {
|
|
47
|
+
if (!deepEqual(aArr[i], bArr[i])) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
let keys = Object.keys(a);
|
|
54
|
+
if (keys.length !== Object.keys(b).length) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
for (let i = 0; i < keys.length; i += 1) {
|
|
58
|
+
let key = keys[i];
|
|
59
|
+
if (!deepEqual(a[key], b[key])) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
exports.deepEqual = deepEqual;
|
|
67
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SignedLoad } from '../../lib-common/jwkeys';
|
|
2
|
+
import { user as midUser } from '../../lib-common/mid-sigs-NaCl-Ed';
|
|
3
|
+
import { User } from './pkl';
|
|
4
|
+
export { User } from './pkl';
|
|
5
|
+
/**
|
|
6
|
+
* @param midUrl
|
|
7
|
+
* @return a promise, resolvable to MailerId service's provisioning url.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getProvPath(midUrl: string): Promise<any>;
|
|
10
|
+
export declare function getMidRoot(midUrl: string): Promise<SignedLoad>;
|
|
11
|
+
export declare function startMidSession(loginUrl: string, userId: string): Promise<string>;
|
|
12
|
+
export declare function provisionMidSigner(midServiceUrl: string, user: User): Promise<midUser.MailerIdSigner>;
|
|
13
|
+
export declare function doMailerIdLogin(loginUrl: string, user: User): Promise<string>;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.doMailerIdLogin = exports.provisionMidSigner = exports.startMidSession = exports.getMidRoot = exports.getProvPath = void 0;
|
|
20
|
+
const jwkeys_1 = require("../../lib-common/jwkeys");
|
|
21
|
+
const xhr_utils_1 = require("./xhr-utils");
|
|
22
|
+
const login_1 = require("../../lib-common/service-api/mailer-id/login");
|
|
23
|
+
const provisioning_1 = require("../../lib-common/service-api/mailer-id/provisioning");
|
|
24
|
+
const mid_sigs_NaCl_Ed_1 = require("../../lib-common/mid-sigs-NaCl-Ed");
|
|
25
|
+
const pkl_1 = require("./pkl");
|
|
26
|
+
const random_node_1 = require("../../lib-common/random-node");
|
|
27
|
+
const url_1 = require("url");
|
|
28
|
+
async function getMidData(midUrl) {
|
|
29
|
+
let reqOpts = {
|
|
30
|
+
url: midUrl,
|
|
31
|
+
method: 'GET',
|
|
32
|
+
responseType: 'json'
|
|
33
|
+
};
|
|
34
|
+
let rep = await (0, xhr_utils_1.doBodylessRequest)(reqOpts);
|
|
35
|
+
expect(rep.status).toBe(200);
|
|
36
|
+
return rep.data;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @param midUrl
|
|
40
|
+
* @return a promise, resolvable to MailerId service's provisioning url.
|
|
41
|
+
*/
|
|
42
|
+
async function getProvPath(midUrl) {
|
|
43
|
+
let midData = await getMidData(midUrl);
|
|
44
|
+
let prov = midData['provisioning'];
|
|
45
|
+
expect(typeof prov).toBe('string');
|
|
46
|
+
// return url with provision path
|
|
47
|
+
let pathStarts = midUrl.indexOf('/', midUrl.indexOf('://') + 3);
|
|
48
|
+
return midUrl.substring(0, pathStarts) + prov;
|
|
49
|
+
}
|
|
50
|
+
exports.getProvPath = getProvPath;
|
|
51
|
+
async function getMidRoot(midUrl) {
|
|
52
|
+
let midData = await getMidData(midUrl);
|
|
53
|
+
let rootCert = midData["current-cert"];
|
|
54
|
+
expect((0, jwkeys_1.isLikeSignedKeyCert)(rootCert)).toBe(true);
|
|
55
|
+
return rootCert;
|
|
56
|
+
}
|
|
57
|
+
exports.getMidRoot = getMidRoot;
|
|
58
|
+
async function startMidSession(loginUrl, userId) {
|
|
59
|
+
let reqOpts = {
|
|
60
|
+
url: loginUrl + login_1.startSession.URL_END,
|
|
61
|
+
method: 'POST',
|
|
62
|
+
responseType: 'json'
|
|
63
|
+
};
|
|
64
|
+
let req = { userId };
|
|
65
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
66
|
+
expect(rep.status).toBe(login_1.startSession.SC.ok);
|
|
67
|
+
return rep.data.sessionId;
|
|
68
|
+
}
|
|
69
|
+
exports.startMidSession = startMidSession;
|
|
70
|
+
async function provisionMidSigner(midServiceUrl, user) {
|
|
71
|
+
let provUrl = await getProvPath(midServiceUrl);
|
|
72
|
+
let sessParams = await (0, pkl_1.doPubKeyLogin)(provUrl, user);
|
|
73
|
+
let reqOpts = {
|
|
74
|
+
url: provUrl + provisioning_1.certify.URL_END,
|
|
75
|
+
method: 'POST',
|
|
76
|
+
sessionId: sessParams.sessionId,
|
|
77
|
+
responseType: 'arraybuffer'
|
|
78
|
+
};
|
|
79
|
+
let midSigningPair = mid_sigs_NaCl_Ed_1.user.generateSigningKeyPair(random_node_1.bytesSync);
|
|
80
|
+
let reqData = {
|
|
81
|
+
pkey: midSigningPair.pkey,
|
|
82
|
+
duration: 12 * 60 * 60
|
|
83
|
+
};
|
|
84
|
+
let encrBody = sessParams.sessEncr.packJSON(reqData);
|
|
85
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, encrBody);
|
|
86
|
+
expect(rep.status).toBe(provisioning_1.certify.SC.ok);
|
|
87
|
+
let repData = sessParams.sessEncr.openJSON(rep.data);
|
|
88
|
+
return mid_sigs_NaCl_Ed_1.user.makeMailerIdSigner(midSigningPair.skey, repData.userCert, repData.provCert);
|
|
89
|
+
}
|
|
90
|
+
exports.provisionMidSigner = provisionMidSigner;
|
|
91
|
+
async function doMailerIdLogin(loginUrl, user) {
|
|
92
|
+
let sessionId = await startMidSession(loginUrl, user.id);
|
|
93
|
+
let midSigner = await provisionMidSigner(user.midUrl, user);
|
|
94
|
+
let reqOpts = {
|
|
95
|
+
url: loginUrl + login_1.authSession.URL_END,
|
|
96
|
+
method: 'POST',
|
|
97
|
+
responseType: 'json',
|
|
98
|
+
sessionId
|
|
99
|
+
};
|
|
100
|
+
let serviceDomain = (0, url_1.parse)(loginUrl).hostname;
|
|
101
|
+
if (!serviceDomain) {
|
|
102
|
+
throw new Error(`Cannot parse hostname from login url ${loginUrl}`);
|
|
103
|
+
}
|
|
104
|
+
let req = {
|
|
105
|
+
assertion: midSigner.generateAssertionFor(serviceDomain, sessionId),
|
|
106
|
+
provCert: midSigner.providerCert,
|
|
107
|
+
userCert: midSigner.userCert
|
|
108
|
+
};
|
|
109
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
110
|
+
expect(rep.status).toBe(login_1.authSession.SC.ok);
|
|
111
|
+
return sessionId;
|
|
112
|
+
}
|
|
113
|
+
exports.doMailerIdLogin = doMailerIdLogin;
|
|
114
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as pklApi from '../../lib-common/service-api/pub-key-login';
|
|
2
|
+
import { SessionEncryptor } from '../../lib-common/session-encryptor';
|
|
3
|
+
export interface User {
|
|
4
|
+
id: string;
|
|
5
|
+
loginDefaultSKey: Uint8Array;
|
|
6
|
+
loginLabeledSKey: {
|
|
7
|
+
kid: string;
|
|
8
|
+
k: Uint8Array;
|
|
9
|
+
};
|
|
10
|
+
midUrl: string;
|
|
11
|
+
storageOwnerUrl: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ExchangeCrypto {
|
|
14
|
+
sessEncr: SessionEncryptor;
|
|
15
|
+
serverVerificationBytes: Uint8Array;
|
|
16
|
+
encResponse: Uint8Array;
|
|
17
|
+
}
|
|
18
|
+
export declare function decryptSessionParamsForCurve25519(r: pklApi.start.Reply, loginSKey: Uint8Array): ExchangeCrypto;
|
|
19
|
+
export interface ExchangeParams {
|
|
20
|
+
crypto: ExchangeCrypto;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function startPKLSession(loginUrl: string, user: User, useDefaultKey: boolean): Promise<ExchangeParams>;
|
|
24
|
+
export interface SessionParams {
|
|
25
|
+
sessEncr: SessionEncryptor;
|
|
26
|
+
sessionId: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function doPubKeyLogin(loginUrl: string, user: User): Promise<SessionParams>;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.doPubKeyLogin = exports.startPKLSession = exports.decryptSessionParamsForCurve25519 = void 0;
|
|
20
|
+
const pklApi = require("../../lib-common/service-api/pub-key-login");
|
|
21
|
+
const buffer_utils_1 = require("../../lib-common/buffer-utils");
|
|
22
|
+
const ecma_nacl_1 = require("ecma-nacl");
|
|
23
|
+
const session_encryptor_1 = require("../../lib-common/session-encryptor");
|
|
24
|
+
const xhr_utils_1 = require("./xhr-utils");
|
|
25
|
+
const url_1 = require("url");
|
|
26
|
+
const bytes_equal_1 = require("./bytes-equal");
|
|
27
|
+
function decryptSessionParamsForCurve25519(r, loginSKey) {
|
|
28
|
+
let serverPKey = buffer_utils_1.base64.open(r.serverPubKey);
|
|
29
|
+
expect(serverPKey.length).toBe(ecma_nacl_1.box.KEY_LENGTH);
|
|
30
|
+
let sharedKey = ecma_nacl_1.box.calc_dhshared_key(serverPKey, loginSKey);
|
|
31
|
+
let encChallenge = buffer_utils_1.base64.open(r.sessionKey);
|
|
32
|
+
expect(encChallenge.length).toBe(ecma_nacl_1.secret_box.NONCE_LENGTH + ecma_nacl_1.secret_box.KEY_LENGTH);
|
|
33
|
+
let nonce = encChallenge.subarray(0, ecma_nacl_1.secret_box.NONCE_LENGTH);
|
|
34
|
+
let zeros = new Uint8Array(ecma_nacl_1.secret_box.KEY_LENGTH);
|
|
35
|
+
let stream = ecma_nacl_1.secret_box.pack(zeros, nonce, sharedKey).subarray(ecma_nacl_1.secret_box.POLY_LENGTH);
|
|
36
|
+
let sessionKey = new Uint8Array(encChallenge.subarray(ecma_nacl_1.secret_box.NONCE_LENGTH));
|
|
37
|
+
for (var i = 0; i < ecma_nacl_1.secret_box.KEY_LENGTH; i += 1) {
|
|
38
|
+
sessionKey[i] ^= stream[i];
|
|
39
|
+
}
|
|
40
|
+
let serverVerificationBytes = ecma_nacl_1.secret_box.pack(sessionKey, nonce, sharedKey)
|
|
41
|
+
.subarray(0, ecma_nacl_1.secret_box.POLY_LENGTH);
|
|
42
|
+
ecma_nacl_1.nonce.advanceOddly(nonce);
|
|
43
|
+
let sessEncr = (0, session_encryptor_1.makeSessionEncryptor)(sessionKey, nonce);
|
|
44
|
+
let encResponse = sessEncr.pack(sessionKey);
|
|
45
|
+
ecma_nacl_1.arrays.wipe(sessionKey);
|
|
46
|
+
return { sessEncr, serverVerificationBytes, encResponse };
|
|
47
|
+
}
|
|
48
|
+
exports.decryptSessionParamsForCurve25519 = decryptSessionParamsForCurve25519;
|
|
49
|
+
async function startPKLSession(loginUrl, user, useDefaultKey) {
|
|
50
|
+
let reqOpts = {
|
|
51
|
+
url: (0, url_1.resolve)(loginUrl, pklApi.start.URL_END),
|
|
52
|
+
method: 'POST',
|
|
53
|
+
responseType: 'json'
|
|
54
|
+
};
|
|
55
|
+
let req = (useDefaultKey ?
|
|
56
|
+
{ userId: user.id } :
|
|
57
|
+
{ userId: user.id, kid: user.loginLabeledSKey.kid });
|
|
58
|
+
let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
|
|
59
|
+
expect(rep.status).toBe(pklApi.start.SC.ok);
|
|
60
|
+
let skey = (useDefaultKey ? user.loginDefaultSKey : user.loginLabeledSKey.k);
|
|
61
|
+
return {
|
|
62
|
+
sessionId: rep.data.sessionId,
|
|
63
|
+
crypto: decryptSessionParamsForCurve25519(rep.data, skey)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
exports.startPKLSession = startPKLSession;
|
|
67
|
+
async function validatePKLSession(loginUrl, exchangeParams) {
|
|
68
|
+
let reqOpts = {
|
|
69
|
+
url: (0, url_1.resolve)(loginUrl, pklApi.complete.URL_END),
|
|
70
|
+
method: 'POST',
|
|
71
|
+
sessionId: exchangeParams.sessionId,
|
|
72
|
+
responseType: 'arraybuffer'
|
|
73
|
+
};
|
|
74
|
+
let rep = await (0, xhr_utils_1.doBinaryRequest)(reqOpts, exchangeParams.crypto.encResponse);
|
|
75
|
+
expect(rep.status).toBe(pklApi.complete.SC.ok);
|
|
76
|
+
expect(rep.data.length).toBe(ecma_nacl_1.secret_box.POLY_LENGTH);
|
|
77
|
+
expect((0, bytes_equal_1.bytesEqual)(rep.data, exchangeParams.crypto.serverVerificationBytes))
|
|
78
|
+
.toBe(true);
|
|
79
|
+
return {
|
|
80
|
+
sessionId: exchangeParams.sessionId,
|
|
81
|
+
sessEncr: exchangeParams.crypto.sessEncr
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
async function doPubKeyLogin(loginUrl, user) {
|
|
85
|
+
let exchangeParams = await startPKLSession(loginUrl, user, false);
|
|
86
|
+
return validatePKLSession(loginUrl, exchangeParams);
|
|
87
|
+
}
|
|
88
|
+
exports.doPubKeyLogin = doPubKeyLogin;
|
|
89
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Component } from './component';
|
|
2
|
+
import { User } from '../pkl';
|
|
3
|
+
import { Obj } from '../3nstorage';
|
|
4
|
+
export declare class StorageComponent extends Component {
|
|
5
|
+
midServiceDomain: string;
|
|
6
|
+
constructor(signupDomains: string[], midServiceDomain: string);
|
|
7
|
+
addUser(userId: string, configureDNS?: boolean): Promise<User>;
|
|
8
|
+
get midUrl(): string;
|
|
9
|
+
get storageUrl(): string;
|
|
10
|
+
getStorageOwnerUrl(): Promise<string>;
|
|
11
|
+
private storeFolder;
|
|
12
|
+
private checkTransactionPresence;
|
|
13
|
+
rootTransactionExists(userId: string, transactionId?: string): Promise<boolean>;
|
|
14
|
+
transactionExists(userId: string, objId: string, transactionId?: string): Promise<boolean>;
|
|
15
|
+
private checkCurrentObjPresence;
|
|
16
|
+
currentRootObjExists(userId: string, ver?: number, obj?: Obj): Promise<boolean>;
|
|
17
|
+
currentObjExists(userId: string, objId: string, ver?: number, obj?: Obj): Promise<boolean>;
|
|
18
|
+
clearStorage(userId: string): Promise<void>;
|
|
19
|
+
restartAndClearStorageFor(userId: string): Promise<void>;
|
|
20
|
+
}
|