spec-3nweb-server 1.8.5 → 1.8.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/.gitlab-ci-linux.yml +50 -0
  2. package/.gitlab-ci-mac.yml +29 -0
  3. package/.gitlab-ci-windows.yml +29 -0
  4. package/.gitlab-ci.yml +63 -0
  5. package/build/3nstorage/resources/store.d.ts +2 -2
  6. package/build/3nstorage/resources/store.js +1 -1
  7. package/build/3nstorage/resources/users.d.ts +3 -3
  8. package/build/3nstorage/resources/users.js +1 -1
  9. package/build/3nstorage/resources/utils.d.ts +6 -0
  10. package/build/3nstorage/resources/utils.js +41 -0
  11. package/build/3nstorage/routes/owner/archive-obj-version.js +8 -10
  12. package/build/3nstorage/routes/owner/cancel-trans.js +5 -4
  13. package/build/3nstorage/routes/owner/delete-obj.js +7 -8
  14. package/build/3nstorage/routes/owner/get-archived-obj-ver.js +11 -13
  15. package/build/3nstorage/routes/owner/get-current-obj.js +7 -6
  16. package/build/3nstorage/routes/owner/get-obj-status.js +8 -8
  17. package/build/3nstorage/routes/owner/put-current-obj.js +25 -55
  18. package/build/3nstorage/routes/owner/session-params.js +2 -0
  19. package/build/asmail/resources/utils.d.ts +6 -0
  20. package/build/asmail/resources/utils.js +36 -0
  21. package/build/asmail/routes/delivery/finalize-delivery.js +3 -2
  22. package/build/asmail/routes/delivery/pre-flight.js +9 -26
  23. package/build/asmail/routes/delivery/provide-recipient-pubkey.js +4 -3
  24. package/build/asmail/routes/delivery/put-metadata.js +13 -21
  25. package/build/asmail/routes/delivery/put-obj.js +19 -25
  26. package/build/asmail/routes/delivery/restart-session.d.ts +4 -8
  27. package/build/asmail/routes/delivery/restart-session.js +10 -23
  28. package/build/asmail/routes/delivery/sender-authorization.js +5 -5
  29. package/build/asmail/routes/delivery/start-session.js +9 -24
  30. package/build/asmail/routes/retrieval/get-message-meta.js +4 -7
  31. package/build/asmail/routes/retrieval/get-message-obj.js +10 -7
  32. package/build/asmail/routes/retrieval/list-messages.js +4 -4
  33. package/build/asmail/routes/retrieval/remove-message.js +3 -2
  34. package/build/mock/tls-options.js +46 -44
  35. package/build/tests/admin-proto/signup.d.ts +1 -0
  36. package/build/tests/admin-proto/signup.js +235 -0
  37. package/build/tests/jasmine.d.ts +1 -0
  38. package/build/tests/jasmine.js +32 -0
  39. package/build/tests/libs-for-tests/3nstorage.d.ts +22 -0
  40. package/build/tests/libs-for-tests/3nstorage.js +123 -0
  41. package/build/tests/libs-for-tests/asmail.d.ts +22 -0
  42. package/build/tests/libs-for-tests/asmail.js +179 -0
  43. package/build/tests/libs-for-tests/assert.d.ts +1 -0
  44. package/build/tests/libs-for-tests/assert.js +26 -0
  45. package/build/tests/libs-for-tests/async-jasmine.d.ts +7 -0
  46. package/build/tests/libs-for-tests/async-jasmine.js +77 -0
  47. package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
  48. package/build/tests/libs-for-tests/bytes-equal.js +34 -0
  49. package/build/tests/libs-for-tests/json-copy.d.ts +1 -0
  50. package/build/tests/libs-for-tests/json-copy.js +45 -0
  51. package/build/tests/libs-for-tests/json-equal.d.ts +4 -0
  52. package/build/tests/libs-for-tests/json-equal.js +67 -0
  53. package/build/tests/libs-for-tests/mailerid.d.ts +13 -0
  54. package/build/tests/libs-for-tests/mailerid.js +114 -0
  55. package/build/tests/libs-for-tests/pkl.d.ts +28 -0
  56. package/build/tests/libs-for-tests/pkl.js +89 -0
  57. package/build/tests/libs-for-tests/server-components/3nstorage.d.ts +20 -0
  58. package/build/tests/libs-for-tests/server-components/3nstorage.js +200 -0
  59. package/build/tests/libs-for-tests/server-components/admin.d.ts +6 -0
  60. package/build/tests/libs-for-tests/server-components/admin.js +43 -0
  61. package/build/tests/libs-for-tests/server-components/asmail.d.ts +16 -0
  62. package/build/tests/libs-for-tests/server-components/asmail.js +143 -0
  63. package/build/tests/libs-for-tests/server-components/component.d.ts +13 -0
  64. package/build/tests/libs-for-tests/server-components/component.js +77 -0
  65. package/build/tests/libs-for-tests/server-components/mailerid.d.ts +10 -0
  66. package/build/tests/libs-for-tests/server-components/mailerid.js +103 -0
  67. package/build/tests/libs-for-tests/server-runner.d.ts +15 -0
  68. package/build/tests/libs-for-tests/server-runner.js +69 -0
  69. package/build/tests/libs-for-tests/spec-assembly.d.ts +6 -0
  70. package/build/tests/libs-for-tests/spec-assembly.js +55 -0
  71. package/build/tests/libs-for-tests/ws-utils.d.ts +3 -0
  72. package/build/tests/libs-for-tests/ws-utils.js +59 -0
  73. package/build/tests/libs-for-tests/xhr-utils.d.ts +61 -0
  74. package/build/tests/libs-for-tests/xhr-utils.js +154 -0
  75. package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.d.ts +2 -0
  76. package/build/tests/protocols/3nstorage/owner/specs/archive-obj-ver.js +84 -0
  77. package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.d.ts +2 -0
  78. package/build/tests/protocols/3nstorage/owner/specs/archive-root-ver.js +78 -0
  79. package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.d.ts +2 -0
  80. package/build/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.js +83 -0
  81. package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.d.ts +2 -0
  82. package/build/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.js +77 -0
  83. package/build/tests/protocols/3nstorage/owner/specs/delete-obj.d.ts +2 -0
  84. package/build/tests/protocols/3nstorage/owner/specs/delete-obj.js +75 -0
  85. package/build/tests/protocols/3nstorage/owner/specs/events.d.ts +2 -0
  86. package/build/tests/protocols/3nstorage/owner/specs/events.js +91 -0
  87. package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.d.ts +2 -0
  88. package/build/tests/protocols/3nstorage/owner/specs/get-current-obj.js +269 -0
  89. package/build/tests/protocols/3nstorage/owner/specs/get-current-root.d.ts +2 -0
  90. package/build/tests/protocols/3nstorage/owner/specs/get-current-root.js +262 -0
  91. package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.d.ts +2 -0
  92. package/build/tests/protocols/3nstorage/owner/specs/get-obj-status.js +79 -0
  93. package/build/tests/protocols/3nstorage/owner/specs/get-root-status.d.ts +2 -0
  94. package/build/tests/protocols/3nstorage/owner/specs/get-root-status.js +72 -0
  95. package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.d.ts +2 -0
  96. package/build/tests/protocols/3nstorage/owner/specs/put-current-obj.js +287 -0
  97. package/build/tests/protocols/3nstorage/owner/specs/put-current-root.d.ts +2 -0
  98. package/build/tests/protocols/3nstorage/owner/specs/put-current-root.js +274 -0
  99. package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.d.ts +2 -0
  100. package/build/tests/protocols/3nstorage/owner/specs/trans-cancel-root.js +73 -0
  101. package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.d.ts +2 -0
  102. package/build/tests/protocols/3nstorage/owner/specs/trans-cancel.js +72 -0
  103. package/build/tests/protocols/3nstorage/owner/test-utils.d.ts +14 -0
  104. package/build/tests/protocols/3nstorage/owner/test-utils.js +54 -0
  105. package/build/tests/protocols/3nstorage/owner.d.ts +1 -0
  106. package/build/tests/protocols/3nstorage/owner.js +138 -0
  107. package/build/tests/protocols/asmail/config.d.ts +1 -0
  108. package/build/tests/protocols/asmail/config.js +117 -0
  109. package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.d.ts +2 -0
  110. package/build/tests/protocols/asmail/delivery/specs/finalize-delivery.js +60 -0
  111. package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.d.ts +2 -0
  112. package/build/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.js +68 -0
  113. package/build/tests/protocols/asmail/delivery/specs/put-metadata.d.ts +2 -0
  114. package/build/tests/protocols/asmail/delivery/specs/put-metadata.js +83 -0
  115. package/build/tests/protocols/asmail/delivery/specs/put-obj.d.ts +2 -0
  116. package/build/tests/protocols/asmail/delivery/specs/put-obj.js +123 -0
  117. package/build/tests/protocols/asmail/delivery/specs/restart-session.d.ts +2 -0
  118. package/build/tests/protocols/asmail/delivery/specs/restart-session.js +79 -0
  119. package/build/tests/protocols/asmail/delivery/specs/start-session.d.ts +2 -0
  120. package/build/tests/protocols/asmail/delivery/specs/start-session.js +64 -0
  121. package/build/tests/protocols/asmail/delivery/test-utils.d.ts +16 -0
  122. package/build/tests/protocols/asmail/delivery/test-utils.js +46 -0
  123. package/build/tests/protocols/asmail/delivery.d.ts +1 -0
  124. package/build/tests/protocols/asmail/delivery.js +46 -0
  125. package/build/tests/protocols/asmail/retrieval/specs/events.d.ts +2 -0
  126. package/build/tests/protocols/asmail/retrieval/specs/events.js +62 -0
  127. package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.d.ts +2 -0
  128. package/build/tests/protocols/asmail/retrieval/specs/get-message-meta.js +70 -0
  129. package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.d.ts +2 -0
  130. package/build/tests/protocols/asmail/retrieval/specs/get-message-obj.js +166 -0
  131. package/build/tests/protocols/asmail/retrieval/specs/list-messages.d.ts +2 -0
  132. package/build/tests/protocols/asmail/retrieval/specs/list-messages.js +96 -0
  133. package/build/tests/protocols/asmail/retrieval/specs/remove-message.d.ts +2 -0
  134. package/build/tests/protocols/asmail/retrieval/specs/remove-message.js +66 -0
  135. package/build/tests/protocols/asmail/retrieval/test-utils.d.ts +17 -0
  136. package/build/tests/protocols/asmail/retrieval/test-utils.js +46 -0
  137. package/build/tests/protocols/asmail/retrieval.d.ts +1 -0
  138. package/build/tests/protocols/asmail/retrieval.js +92 -0
  139. package/build/tests/protocols/mailerid.d.ts +1 -0
  140. package/build/tests/protocols/mailerid.js +210 -0
  141. package/build/tests/shared-checks/check-mid-login.d.ts +2 -0
  142. package/build/tests/shared-checks/check-mid-login.js +131 -0
  143. package/build/tests/shared-checks/requests.d.ts +20 -0
  144. package/build/tests/shared-checks/requests.js +123 -0
  145. package/package.json +1 -1
  146. package/packing/create-deb.sh +57 -0
  147. package/packing/deb/lib/systemd/system/3nweb.service +11 -0
  148. package/packing/deb/postinst +44 -0
  149. package/packing/deb/usr/share/doc/3nweb-server/conf-for-postinstall.yaml +19 -0
  150. package/packing/deb/usr/share/doc/3nweb-server/copyright +22 -0
  151. package/publish-task.sh +10 -0
  152. package/push-to-github.sh +105 -0
  153. package/ts-code/3nstorage/3nstorage-app.ts +99 -0
  154. package/ts-code/3nstorage/owner.ts +178 -0
  155. package/ts-code/3nstorage/resources/sessions.ts +37 -0
  156. package/ts-code/3nstorage/resources/store.ts +896 -0
  157. package/ts-code/3nstorage/resources/users.ts +258 -0
  158. package/ts-code/3nstorage/resources/utils.ts +45 -0
  159. package/ts-code/3nstorage/routes/owner/archive-obj-version.ts +71 -0
  160. package/ts-code/3nstorage/routes/owner/cancel-trans.ts +60 -0
  161. package/ts-code/3nstorage/routes/owner/delete-obj.ts +99 -0
  162. package/ts-code/3nstorage/routes/owner/get-archived-obj-ver.ts +109 -0
  163. package/ts-code/3nstorage/routes/owner/get-current-obj.ts +124 -0
  164. package/ts-code/3nstorage/routes/owner/get-obj-status.ts +55 -0
  165. package/ts-code/3nstorage/routes/owner/param-getter.ts +51 -0
  166. package/ts-code/3nstorage/routes/owner/param-setter.ts +50 -0
  167. package/ts-code/3nstorage/routes/owner/put-current-obj.ts +257 -0
  168. package/ts-code/3nstorage/routes/owner/session-params.ts +50 -0
  169. package/ts-code/3nstorage/shared.ts +43 -0
  170. package/ts-code/asmail/asmail-app.ts +91 -0
  171. package/ts-code/asmail/config.ts +96 -0
  172. package/ts-code/asmail/delivery.ts +94 -0
  173. package/ts-code/asmail/resources/delivery-sessions.ts +118 -0
  174. package/ts-code/asmail/resources/inbox.ts +696 -0
  175. package/ts-code/asmail/resources/recipients.ts +495 -0
  176. package/ts-code/asmail/resources/sessions.ts +37 -0
  177. package/ts-code/asmail/resources/utils.ts +41 -0
  178. package/ts-code/asmail/retrieval.ts +96 -0
  179. package/ts-code/asmail/routes/config/param-getter.ts +49 -0
  180. package/ts-code/asmail/routes/config/param-setter.ts +49 -0
  181. package/ts-code/asmail/routes/delivery/finalize-delivery.ts +51 -0
  182. package/ts-code/asmail/routes/delivery/pre-flight.ts +118 -0
  183. package/ts-code/asmail/routes/delivery/provide-recipient-pubkey.ts +58 -0
  184. package/ts-code/asmail/routes/delivery/put-metadata.ts +85 -0
  185. package/ts-code/asmail/routes/delivery/put-obj.ts +152 -0
  186. package/ts-code/asmail/routes/delivery/restart-session.ts +117 -0
  187. package/ts-code/asmail/routes/delivery/sender-authorization.ts +81 -0
  188. package/ts-code/asmail/routes/delivery/start-session.ts +136 -0
  189. package/ts-code/asmail/routes/retrieval/get-message-meta.ts +50 -0
  190. package/ts-code/asmail/routes/retrieval/get-message-obj.ts +106 -0
  191. package/ts-code/asmail/routes/retrieval/list-messages.ts +68 -0
  192. package/ts-code/asmail/routes/retrieval/remove-message.ts +48 -0
  193. package/ts-code/cli/index.ts +82 -0
  194. package/ts-code/cli/run-cmd.ts +81 -0
  195. package/ts-code/cli/show-sample-config.ts +78 -0
  196. package/ts-code/cli/signup-cmd.ts +229 -0
  197. package/ts-code/cli/user-cmd.ts +68 -0
  198. package/ts-code/cli/utils.ts +105 -0
  199. package/ts-code/config/default-confs.ts +22 -0
  200. package/ts-code/config/from-yaml.ts +35 -0
  201. package/ts-code/config/letsencrypt.ts +77 -0
  202. package/ts-code/config/signup.ts +137 -0
  203. package/ts-code/lib-common/admin-api/signup.ts +120 -0
  204. package/ts-code/lib-common/assert.ts +22 -0
  205. package/ts-code/lib-common/async-fs-node.ts +656 -0
  206. package/ts-code/lib-common/buffer-utils.ts +124 -0
  207. package/ts-code/lib-common/byte-streaming/common.ts +166 -0
  208. package/ts-code/lib-common/bytes-equal.ts +25 -0
  209. package/ts-code/lib-common/canonical-address.ts +92 -0
  210. package/ts-code/lib-common/exceptions/error.ts +44 -0
  211. package/ts-code/lib-common/exceptions/file.ts +84 -0
  212. package/ts-code/lib-common/exceptions/http.ts +69 -0
  213. package/ts-code/lib-common/ipc/generic-ipc.ts +750 -0
  214. package/ts-code/lib-common/ipc/ws-ipc.ts +117 -0
  215. package/ts-code/lib-common/json-equal.ts +55 -0
  216. package/ts-code/lib-common/json-utils.ts +130 -0
  217. package/ts-code/lib-common/jwkeys.ts +246 -0
  218. package/ts-code/lib-common/map-of-sets.ts +60 -0
  219. package/ts-code/lib-common/mid-sigs-NaCl-Ed.ts +677 -0
  220. package/ts-code/lib-common/objs-on-disk/file-layout.ts +480 -0
  221. package/ts-code/lib-common/objs-on-disk/obj-file.ts +325 -0
  222. package/ts-code/lib-common/objs-on-disk/utils.ts +201 -0
  223. package/ts-code/lib-common/objs-on-disk/v1-obj-file-format.ts +329 -0
  224. package/ts-code/lib-common/processes.ts +501 -0
  225. package/ts-code/lib-common/random-node.ts +79 -0
  226. package/ts-code/lib-common/service-api/3nstorage/owner.ts +559 -0
  227. package/ts-code/lib-common/service-api/3nstorage/root-route.ts +22 -0
  228. package/ts-code/lib-common/service-api/asmail/config.ts +144 -0
  229. package/ts-code/lib-common/service-api/asmail/delivery.ts +250 -0
  230. package/ts-code/lib-common/service-api/asmail/retrieval.ts +238 -0
  231. package/ts-code/lib-common/service-api/asmail/root-route.ts +22 -0
  232. package/ts-code/lib-common/service-api/ipc-api.ts +44 -0
  233. package/ts-code/lib-common/service-api/locker.ts +44 -0
  234. package/ts-code/lib-common/service-api/mailer-id/login.ts +80 -0
  235. package/ts-code/lib-common/service-api/mailer-id/provisioning.ts +64 -0
  236. package/ts-code/lib-common/service-api/mailer-id/root-route.ts +25 -0
  237. package/ts-code/lib-common/service-api/pub-key-login.ts +75 -0
  238. package/ts-code/lib-common/service-api/web-socket-base.ts +87 -0
  239. package/ts-code/lib-common/session-encryptor.ts +54 -0
  240. package/ts-code/lib-common/time-window-cache.ts +74 -0
  241. package/ts-code/lib-common/transferable.d.ts +30 -0
  242. package/ts-code/lib-server/conf-util.ts +35 -0
  243. package/ts-code/lib-server/mid-access.ts +45 -0
  244. package/ts-code/lib-server/middleware/body-parsers.ts +248 -0
  245. package/ts-code/lib-server/middleware/error-handler.ts +79 -0
  246. package/ts-code/lib-server/pkl-access.ts +46 -0
  247. package/ts-code/lib-server/resources/dns.ts +151 -0
  248. package/ts-code/lib-server/resources/mailerid-authorizer.ts +115 -0
  249. package/ts-code/lib-server/resources/mem-backed-sessions-factory.ts +132 -0
  250. package/ts-code/lib-server/resources/server-data-folders.ts +160 -0
  251. package/ts-code/lib-server/resources/server-key-for-pkl-challenge.ts +41 -0
  252. package/ts-code/lib-server/resources/sessions.ts +232 -0
  253. package/ts-code/lib-server/resources/user-files.ts +147 -0
  254. package/ts-code/lib-server/routes/pub-key-login/complete-exchange.ts +63 -0
  255. package/ts-code/lib-server/routes/pub-key-login/start-exchange.ts +189 -0
  256. package/ts-code/lib-server/routes/sessions/close.ts +27 -0
  257. package/ts-code/lib-server/routes/sessions/mid-auth.ts +77 -0
  258. package/ts-code/lib-server/routes/sessions/start.ts +116 -0
  259. package/ts-code/lib-server/web-sockets/app.ts +339 -0
  260. package/ts-code/lib-server/web-sockets/server-events.ts +63 -0
  261. package/ts-code/lib.ts +29 -0
  262. package/ts-code/locker/locker-app.ts +60 -0
  263. package/ts-code/locker/resources/lockers.ts +17 -0
  264. package/ts-code/locker/resources/sessions.ts +37 -0
  265. package/ts-code/locker/routes/create-locker.ts +47 -0
  266. package/ts-code/mailerId/mailerId-app.ts +107 -0
  267. package/ts-code/mailerId/resources/certifier.ts +181 -0
  268. package/ts-code/mailerId/resources/sessions.ts +44 -0
  269. package/ts-code/mailerId/resources/users.ts +88 -0
  270. package/ts-code/mailerId/routes/certify.ts +68 -0
  271. package/ts-code/main.ts +304 -0
  272. package/ts-code/mock/dns.ts +106 -0
  273. package/ts-code/mock/mock-as-child-proc.ts +130 -0
  274. package/ts-code/mock/node-child-ipc.ts +69 -0
  275. package/ts-code/mock/run-in-proc.ts +111 -0
  276. package/ts-code/mock/tls-options.ts +73 -0
  277. package/ts-code/services.ts +138 -0
  278. package/ts-code/signup/resources/users.ts +429 -0
  279. package/ts-code/signup/routes/add.ts +65 -0
  280. package/ts-code/signup/routes/get-available-addresses.ts +49 -0
  281. package/ts-code/signup/routes/get-available-domains.ts +45 -0
  282. package/ts-code/signup/signup-app.ts +54 -0
  283. package/ts-code/signup/signup-tokens.ts +148 -0
  284. package/ts-code/tests/admin-proto/signup.ts +277 -0
  285. package/ts-code/tests/jasmine.ts +37 -0
  286. package/ts-code/tests/libs-for-tests/3nstorage.ts +144 -0
  287. package/ts-code/tests/libs-for-tests/asmail.ts +220 -0
  288. package/ts-code/tests/libs-for-tests/assert.ts +22 -0
  289. package/ts-code/tests/libs-for-tests/async-jasmine.ts +89 -0
  290. package/ts-code/tests/libs-for-tests/bytes-equal.ts +25 -0
  291. package/ts-code/tests/libs-for-tests/json-copy.ts +38 -0
  292. package/ts-code/tests/libs-for-tests/json-equal.ts +55 -0
  293. package/ts-code/tests/libs-for-tests/mailerid.ts +123 -0
  294. package/ts-code/tests/libs-for-tests/pkl.ts +127 -0
  295. package/ts-code/tests/libs-for-tests/server-components/3nstorage.ts +206 -0
  296. package/ts-code/tests/libs-for-tests/server-components/admin.ts +49 -0
  297. package/ts-code/tests/libs-for-tests/server-components/asmail.ts +152 -0
  298. package/ts-code/tests/libs-for-tests/server-components/component.ts +90 -0
  299. package/ts-code/tests/libs-for-tests/server-components/mailerid.ts +114 -0
  300. package/ts-code/tests/libs-for-tests/server-runner.ts +82 -0
  301. package/ts-code/tests/libs-for-tests/spec-assembly.ts +60 -0
  302. package/ts-code/tests/libs-for-tests/ws-utils.ts +61 -0
  303. package/ts-code/tests/libs-for-tests/xhr-utils.ts +179 -0
  304. package/ts-code/tests/protocols/3nstorage/owner/specs/archive-obj-ver.ts +100 -0
  305. package/ts-code/tests/protocols/3nstorage/owner/specs/archive-root-ver.ts +91 -0
  306. package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-obj-ver.ts +99 -0
  307. package/ts-code/tests/protocols/3nstorage/owner/specs/delete-archive-root-ver.ts +90 -0
  308. package/ts-code/tests/protocols/3nstorage/owner/specs/delete-obj.ts +84 -0
  309. package/ts-code/tests/protocols/3nstorage/owner/specs/events.ts +125 -0
  310. package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-obj.ts +298 -0
  311. package/ts-code/tests/protocols/3nstorage/owner/specs/get-current-root.ts +290 -0
  312. package/ts-code/tests/protocols/3nstorage/owner/specs/get-obj-status.ts +88 -0
  313. package/ts-code/tests/protocols/3nstorage/owner/specs/get-root-status.ts +80 -0
  314. package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-obj.ts +366 -0
  315. package/ts-code/tests/protocols/3nstorage/owner/specs/put-current-root.ts +329 -0
  316. package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel-root.ts +86 -0
  317. package/ts-code/tests/protocols/3nstorage/owner/specs/trans-cancel.ts +86 -0
  318. package/ts-code/tests/protocols/3nstorage/owner/test-utils.ts +72 -0
  319. package/ts-code/tests/protocols/3nstorage/owner.ts +198 -0
  320. package/ts-code/tests/protocols/asmail/config.ts +172 -0
  321. package/ts-code/tests/protocols/asmail/delivery/specs/finalize-delivery.ts +69 -0
  322. package/ts-code/tests/protocols/asmail/delivery/specs/provide-recipient-pubkey.ts +88 -0
  323. package/ts-code/tests/protocols/asmail/delivery/specs/put-metadata.ts +102 -0
  324. package/ts-code/tests/protocols/asmail/delivery/specs/put-obj.ts +156 -0
  325. package/ts-code/tests/protocols/asmail/delivery/specs/restart-session.ts +97 -0
  326. package/ts-code/tests/protocols/asmail/delivery/specs/start-session.ts +79 -0
  327. package/ts-code/tests/protocols/asmail/delivery/test-utils.ts +64 -0
  328. package/ts-code/tests/protocols/asmail/delivery.ts +56 -0
  329. package/ts-code/tests/protocols/asmail/retrieval/specs/events.ts +78 -0
  330. package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-meta.ts +80 -0
  331. package/ts-code/tests/protocols/asmail/retrieval/specs/get-message-obj.ts +197 -0
  332. package/ts-code/tests/protocols/asmail/retrieval/specs/list-messages.ts +110 -0
  333. package/ts-code/tests/protocols/asmail/retrieval/specs/remove-message.ts +74 -0
  334. package/ts-code/tests/protocols/asmail/retrieval/test-utils.ts +60 -0
  335. package/ts-code/tests/protocols/asmail/retrieval.ts +115 -0
  336. package/ts-code/tests/protocols/mailerid.ts +271 -0
  337. package/ts-code/tests/shared-checks/check-mid-login.ts +164 -0
  338. package/ts-code/tests/shared-checks/requests.ts +135 -0
  339. package/ts-code/tsconfig.json +11 -0
  340. package/ts-code/web3n.d.ts +1068 -0
@@ -18,6 +18,7 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.authorize = void 0;
20
20
  const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
21
+ const utils_1 = require("../../resources/utils");
21
22
  /**
22
23
  * This creates an authorize-sender route handler.
23
24
  * @param relyingPartyDomain at which this service operates, as seen by client
@@ -28,8 +29,7 @@ const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
28
29
  function authorize(relyingPartyDomain, midAuthorizingFunc) {
29
30
  return async (req, res, next) => {
30
31
  if (req.session.isAuthorized) {
31
- res.status(delivery_1.ERR_SC.duplicateReq).send("This protocol request has already been served.");
32
- return;
32
+ return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.duplicateReq, "This protocol request has already been served.", res);
33
33
  }
34
34
  const rb = req.body;
35
35
  const sender = req.session.params.sender;
@@ -37,12 +37,12 @@ function authorize(relyingPartyDomain, midAuthorizingFunc) {
37
37
  if (!sender) {
38
38
  // This case must be rejected, because place for authorizing
39
39
  // anonymous connection is at the session start.
40
- res.status(delivery_1.authSender.SC.authFailed).send("Server is not accepting provided credentials.");
40
+ (0, utils_1.replyWithErr)(delivery_1.authSender.SC.authFailed, "Server is not accepting provided credentials.", res);
41
41
  req.session.close();
42
42
  return;
43
43
  }
44
44
  if (!rb.assertion || !rb.userCert || !rb.provCert) {
45
- res.status(delivery_1.ERR_SC.malformed).send("No credentials given.");
45
+ (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "No credentials given.", res);
46
46
  req.session.close();
47
47
  return;
48
48
  }
@@ -53,7 +53,7 @@ function authorize(relyingPartyDomain, midAuthorizingFunc) {
53
53
  res.status(delivery_1.authSender.SC.ok).send();
54
54
  }
55
55
  else {
56
- res.status(delivery_1.authSender.SC.authFailed).send("Server is not accepting provided credentials.");
56
+ (0, utils_1.replyWithErr)(delivery_1.authSender.SC.authFailed, "Server is not accepting provided credentials.", res);
57
57
  req.session.close();
58
58
  }
59
59
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016, 2025 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2025 - 2026 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -20,6 +20,7 @@ exports.startSession = void 0;
20
20
  const recipients_1 = require("../../resources/recipients");
21
21
  const delivery_1 = require("../../../lib-common/service-api/asmail/delivery");
22
22
  const canonical_address_1 = require("../../../lib-common/canonical-address");
23
+ const utils_1 = require("../../resources/utils");
23
24
  /**
24
25
  * This creates a start-session route handler.
25
26
  * @param allowedMsgSizeFunc is a function returning promises, that
@@ -55,14 +56,10 @@ function startSession(allowedMsgSizeFunc, sessionGenFunc, redirectFunc) {
55
56
  });
56
57
  }
57
58
  else if (msgSize === 0) {
58
- res.status(delivery_1.sessionStart.SC.senderNotAllowed).json({
59
- error: `${sender ? sender : "Anonymous sender "} is not allowed to leave mail for ${recipient}`
60
- });
59
+ (0, utils_1.replyWithErr)(delivery_1.sessionStart.SC.senderNotAllowed, `${sender ? sender : "Anonymous sender "} is not allowed to leave mail for ${recipient}`, res);
61
60
  }
62
61
  else if (msgSize === -1) {
63
- res.status(delivery_1.sessionStart.SC.inboxFull).json({
64
- error: `Mail box for ${recipient} is full.`
65
- });
62
+ (0, utils_1.replyWithErr)(delivery_1.sessionStart.SC.inboxFull, `Mail box for ${recipient} is full.`, res);
66
63
  }
67
64
  else {
68
65
  throw new Error(`Unrecognized code ${msgSize} for message size limits.`);
@@ -76,34 +73,24 @@ function startSession(allowedMsgSizeFunc, sessionGenFunc, redirectFunc) {
76
73
  const session = req.session;
77
74
  // already existing session indicates repeated call, which should be bounced off
78
75
  if (session) {
79
- res.status(delivery_1.ERR_SC.duplicateReq).json({
80
- error: "This protocol request has already been served."
81
- });
76
+ (0, utils_1.replyWithErr)(delivery_1.ERR_SC.duplicateReq, "This protocol request has already been served.", res);
82
77
  return;
83
78
  }
84
79
  // missing recipient makes a bad request
85
80
  if (!recipient) {
86
- res.status(delivery_1.ERR_SC.malformed).json({
87
- error: "Recipient is either missing in the request, or is malformed"
88
- });
81
+ (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Recipient is either missing in the request, or is malformed", res);
89
82
  return;
90
83
  }
91
84
  // if sender is given, we canonicalize the address
92
85
  if (sender) {
93
86
  sender = (0, canonical_address_1.checkAndTransformAddress)(sender);
94
87
  if (!sender) {
95
- res.status(delivery_1.ERR_SC.malformed).json({
96
- error: "Sender field is malformed"
97
- });
98
- return;
88
+ return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Sender field is malformed", res);
99
89
  }
100
90
  }
101
91
  // check invitation field
102
92
  if ((invitation !== undefined) && (typeof invitation !== 'string')) {
103
- res.status(delivery_1.ERR_SC.malformed).json({
104
- error: "Inviation field is malformed"
105
- });
106
- return;
93
+ return (0, utils_1.replyWithErr)(delivery_1.ERR_SC.malformed, "Inviation field is malformed", res);
107
94
  }
108
95
  try {
109
96
  if (redirectFunc) {
@@ -123,9 +110,7 @@ function startSession(allowedMsgSizeFunc, sessionGenFunc, redirectFunc) {
123
110
  }
124
111
  catch (err) {
125
112
  if (err === recipients_1.SC.USER_UNKNOWN) {
126
- res.status(delivery_1.sessionStart.SC.unknownRecipient).json({
127
- error: `Recipient ${recipient} is unknown.`
128
- });
113
+ (0, utils_1.replyWithErr)(delivery_1.sessionStart.SC.unknownRecipient, `Recipient ${recipient} is unknown.`, res);
129
114
  }
130
115
  else {
131
116
  next(err);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016, 2025 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2025 - 2026 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.getMsgMeta = void 0;
20
20
  const recipients_1 = require("../../resources/recipients");
21
21
  const retrieval_1 = require("../../../lib-common/service-api/asmail/retrieval");
22
+ const utils_1 = require("../../resources/utils");
22
23
  function getMsgMeta(getMsgMetaFunc) {
23
24
  return async (req, res, next) => {
24
25
  const userId = req.session.params.userId;
@@ -32,14 +33,10 @@ function getMsgMeta(getMsgMetaFunc) {
32
33
  next(err);
33
34
  }
34
35
  else if (err === recipients_1.SC.MSG_UNKNOWN) {
35
- res.status(retrieval_1.msgMetadata.SC.unknownMsg).json({
36
- error: "Message " + msgId + " is unknown."
37
- });
36
+ (0, utils_1.replyWithErr)(retrieval_1.msgMetadata.SC.unknownMsg, "Message " + msgId + " is unknown.", res);
38
37
  }
39
38
  else if (err === recipients_1.SC.USER_UNKNOWN) {
40
- res.status(retrieval_1.ERR_SC.server).json({
41
- error: "Recipient disappeared from the system."
42
- });
39
+ (0, utils_1.replyWithErr)(retrieval_1.ERR_SC.server, "Recipient disappeared from the system.", res);
43
40
  req.session.close();
44
41
  }
45
42
  else {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2017, 2025 3NSoft Inc.
3
+ Copyright (C) 2015 - 2017, 2025 - 2026 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -21,6 +21,7 @@ const recipients_1 = require("../../resources/recipients");
21
21
  const retrieval_1 = require("../../../lib-common/service-api/asmail/retrieval");
22
22
  const error_1 = require("../../../lib-common/exceptions/error");
23
23
  const buffer_utils_1 = require("../../../lib-common/buffer-utils");
24
+ const utils_1 = require("../../resources/utils");
24
25
  function extractQueryOptions(req) {
25
26
  // query fields are string or undefined, yet, type info helps the show
26
27
  const query = req.query;
@@ -41,11 +42,13 @@ function getMsgObj(getMsgObjFunc) {
41
42
  return async (req, res, next) => {
42
43
  const userId = req.session.params.userId;
43
44
  const msgId = req.params.msgId;
44
- const objId = req.params.objId;
45
+ const { objId, objIdParseErr } = (0, utils_1.getObjIdFromParams)(req);
46
+ if (objIdParseErr) {
47
+ return (0, utils_1.replyWithErr)(retrieval_1.ERR_SC.malformed, objIdParseErr, res);
48
+ }
45
49
  const opts = extractQueryOptions(req);
46
50
  if (!opts) {
47
- res.status(retrieval_1.ERR_SC.malformed).send("Bad query parameters");
48
- return;
51
+ return (0, utils_1.replyWithErr)(retrieval_1.ERR_SC.malformed, "Bad query parameters", res);
49
52
  }
50
53
  try {
51
54
  const reader = await getMsgObjFunc(userId, msgId, objId, opts.header, opts.ofs, opts.limit);
@@ -76,13 +79,13 @@ function getMsgObj(getMsgObjFunc) {
76
79
  next(err);
77
80
  }
78
81
  else if (err === recipients_1.SC.OBJ_UNKNOWN) {
79
- res.status(retrieval_1.msgObj.SC.unknownMsgOrObj).send(`Object ${objId} is unknown.`);
82
+ (0, utils_1.replyWithErr)(retrieval_1.msgObj.SC.unknownMsgOrObj, `Object ${objId} is unknown.`, res);
80
83
  }
81
84
  else if (err === recipients_1.SC.MSG_UNKNOWN) {
82
- res.status(retrieval_1.msgObj.SC.unknownMsgOrObj).send(`Message ${msgId} is unknown.`);
85
+ (0, utils_1.replyWithErr)(retrieval_1.msgObj.SC.unknownMsgOrObj, `Message ${msgId} is unknown.`, res);
83
86
  }
84
87
  else if (err === recipients_1.SC.USER_UNKNOWN) {
85
- res.status(retrieval_1.ERR_SC.server).send(`Recipient disappeared from the system.`);
88
+ (0, utils_1.replyWithErr)(retrieval_1.ERR_SC.server, `Recipient disappeared from the system.`, res);
86
89
  req.session.close();
87
90
  }
88
91
  else {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2016, 2025 3NSoft Inc.
3
+ Copyright (C) 2015 - 2016, 2025 - 2026 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -19,13 +19,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.listMsgIds = void 0;
20
20
  const recipients_1 = require("../../resources/recipients");
21
21
  const retrieval_1 = require("../../../lib-common/service-api/asmail/retrieval");
22
+ const utils_1 = require("../../resources/utils");
22
23
  function listMsgIds(listMsgIdsFunc) {
23
24
  return async (req, res, next) => {
24
25
  const userId = req.session.params.userId;
25
26
  const opts = extractQueryOptions(req);
26
27
  if (!opts) {
27
- res.status(retrieval_1.ERR_SC.malformed).send("Bad query parameters");
28
- return;
28
+ return (0, utils_1.replyWithErr)(retrieval_1.ERR_SC.malformed, "Bad query parameters", res);
29
29
  }
30
30
  try {
31
31
  const { from, to } = opts;
@@ -37,7 +37,7 @@ function listMsgIds(listMsgIdsFunc) {
37
37
  next(err);
38
38
  }
39
39
  else if (err === recipients_1.SC.USER_UNKNOWN) {
40
- res.status(retrieval_1.ERR_SC.server).send("Recipient disappeared from the system.");
40
+ (0, utils_1.replyWithErr)(retrieval_1.ERR_SC.server, "Recipient disappeared from the system.", res);
41
41
  req.session.close();
42
42
  }
43
43
  else {
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.deleteMsg = void 0;
20
20
  const recipients_1 = require("../../resources/recipients");
21
21
  const retrieval_1 = require("../../../lib-common/service-api/asmail/retrieval");
22
+ const utils_1 = require("../../resources/utils");
22
23
  function deleteMsg(delMsgFunc) {
23
24
  return async (req, res, next) => {
24
25
  const userId = req.session.params.userId;
@@ -32,10 +33,10 @@ function deleteMsg(delMsgFunc) {
32
33
  next(err);
33
34
  }
34
35
  else if (err === recipients_1.SC.MSG_UNKNOWN) {
35
- res.status(retrieval_1.rmMsg.SC.unknownMsg).send("Message " + msgId + " is unknown.");
36
+ (0, utils_1.replyWithErr)(retrieval_1.rmMsg.SC.unknownMsg, "Message " + msgId + " is unknown.", res);
36
37
  }
37
38
  else if (err === recipients_1.SC.USER_UNKNOWN) {
38
- res.status(retrieval_1.ERR_SC.server).send("Recipient disappeared from the system.");
39
+ (0, utils_1.replyWithErr)(retrieval_1.ERR_SC.server, "Recipient disappeared from the system.", res);
39
40
  req.session.close();
40
41
  }
41
42
  else {
@@ -19,52 +19,54 @@ Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.sslOpts = void 0;
20
20
  exports.sslOpts = {
21
21
  key: `-----BEGIN PRIVATE KEY-----
22
- MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDNSnmGLUwA7Qf9
23
- D2cqOq4fvhRcO07/C5PLjbEzIg311caqfU7bUlit90vBFB7TvHg/cKORTXPJb/SQ
24
- D9pR+Sq2zXKjweScUwdza0f+12D3bAbD1ntHQD+4Fh2QaR34LRP1yaPKI5u2kBwb
25
- 6R0qaAuaj3VQ1ttVz7zEwERBtSWJD8r8kj9TGKqNC82LPdcGsFeNsobNE30K/3z8
26
- uqEyLm+AN6FJ1u9ahLxdA3Fn9kLVtOrmskpFcZY9ECauK+DUwWVYI7t9+37EwCcl
27
- ENsw+i2dPUHoPVPsOqsW2aXAH2meSx0jE2sjdccgFA86nHfuBdx+0o3MoIe12ZbF
28
- /v64nvS9AgMBAAECggEAV0hK0tl/bwVYWCesXTAFyEkwruYoeBecBvd/V5YrCVKS
29
- 3PnaBTXFrnFuK/E6ChwfpBln8edUS1jmSjnzQNcHaiF/lFBjunMyv8flHFzGRWwQ
30
- lEMktu6CKOp+N1/59gJ0chQBJ3hsQ/qReOxsEhOam2RTJMO1DY79W0nDu4whIVxp
31
-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vjRq8LlceJh3952ov
68
+ EEuI+hxj/ikVBSjQX8aFhX8kx4p4q/mKCOA5q3DCbmrr3Cn8fl0zRZZegrk9kfpV
69
+ QGCnHRJ0yQ==
68
70
  -----END CERTIFICATE-----`
69
71
  };
70
72
  Object.freeze(exports);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2016, 2020 - 2021, 2025 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ const async_jasmine_1 = require("../libs-for-tests/async-jasmine");
20
+ const admin_1 = require("../libs-for-tests/server-components/admin");
21
+ const xhr_utils_1 = require("../libs-for-tests/xhr-utils");
22
+ const signupApi = require("../../lib-common/admin-api/signup");
23
+ const requests_1 = require("../shared-checks/requests");
24
+ const jwkeys_1 = require("../../lib-common/jwkeys");
25
+ const ecma_nacl_1 = require("ecma-nacl");
26
+ describe('Admin', () => {
27
+ describe('signup subsystem', () => {
28
+ let admin;
29
+ const signupDomains = ['first.org', 'second.org'];
30
+ (0, async_jasmine_1.beforeEachAsync)(async () => {
31
+ admin = new admin_1.AdminComponent(signupDomains);
32
+ await admin.start();
33
+ });
34
+ (0, async_jasmine_1.afterEachAsync)(async () => {
35
+ await admin.stop();
36
+ admin = undefined;
37
+ });
38
+ (0, async_jasmine_1.itAsync)('tells available addresses for a given name', async () => {
39
+ const REQ_SIZE_LIMIT = 1024;
40
+ const name = 'Bob Marley ';
41
+ const reqOpts = {
42
+ url: admin.signupUrl + signupApi.availableAddressesForName.URL_END,
43
+ method: 'POST',
44
+ responseType: 'json'
45
+ };
46
+ // request with ok name
47
+ let req = { name };
48
+ const rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
49
+ expect(rep.status).withContext('status code for OK reply').toBe(signupApi.availableAddressesForName.SC.ok);
50
+ expect(Array.isArray(rep.data)).withContext('OK reply is an array').toBe(true);
51
+ expect(rep.data.length).withContext('with no users, all domains should used as options for available addresses').toBe(signupDomains.length);
52
+ for (const domain of signupDomains) {
53
+ expect(rep.data).toContain(name + '@' + domain);
54
+ }
55
+ // requests with bad names and with bad json's
56
+ const badNames = [name + '@something',
57
+ 5, null, undefined, {}]; // non-strings
58
+ const badJSONs = [name, 5, null, undefined, [name],
59
+ { a: 1 }];
60
+ for (const badName of badNames) {
61
+ req = { name: badName };
62
+ badJSONs.push(req);
63
+ }
64
+ await (0, requests_1.expectNonAcceptanceOfBadJsonRequest)(reqOpts, REQ_SIZE_LIMIT, badJSONs);
65
+ });
66
+ (0, async_jasmine_1.itAsync)('tells available domains', async () => {
67
+ const REQ_SIZE_LIMIT = 1024;
68
+ const reqOpts = {
69
+ url: admin.signupUrl + signupApi.availableDomains.URL_END,
70
+ method: 'POST',
71
+ responseType: 'json'
72
+ };
73
+ const req = {};
74
+ const rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
75
+ expect(rep.status).withContext('status code for OK reply').toBe(signupApi.availableDomains.SC.ok);
76
+ expect(Array.isArray(rep.data)).withContext('OK reply is an array').toBe(true);
77
+ expect(rep.data.length).withContext('with no token, all domains should be given as options').toBe(signupDomains.length);
78
+ for (const domain of signupDomains) {
79
+ expect(rep.data).toContain(domain);
80
+ }
81
+ // requests with bad json's
82
+ const badJSONs = [{ signupToken: 4 }];
83
+ await (0, requests_1.expectNonAcceptanceOfBadJsonRequest)(reqOpts, REQ_SIZE_LIMIT, badJSONs);
84
+ });
85
+ async function getAvailableAddressesFor(name) {
86
+ const reqOpts = {
87
+ url: admin.signupUrl + signupApi.availableAddressesForName.URL_END,
88
+ method: 'POST',
89
+ responseType: 'json'
90
+ };
91
+ const req = { name };
92
+ const rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
93
+ expect(rep.status).toBe(signupApi.availableAddressesForName.SC.ok);
94
+ return rep.data;
95
+ }
96
+ function makeAddUserReq(userId, signupToken) {
97
+ return {
98
+ userId,
99
+ storage: {
100
+ kdParams: {}
101
+ },
102
+ mailerId: {
103
+ defaultPKey: {
104
+ pkey: {
105
+ alg: ecma_nacl_1.box.JWK_ALG_NAME,
106
+ kid: (Buffer.alloc(12)).toString('base64'),
107
+ use: jwkeys_1.use.MID_PKLOGIN,
108
+ k: (Buffer.alloc(ecma_nacl_1.box.KEY_LENGTH)).toString('base64')
109
+ },
110
+ kdParams: {}
111
+ },
112
+ otherPKeys: [{
113
+ alg: ecma_nacl_1.box.JWK_ALG_NAME,
114
+ kid: (Buffer.alloc(12)).toString('base64'),
115
+ use: jwkeys_1.use.MID_PKLOGIN,
116
+ k: (Buffer.alloc(ecma_nacl_1.box.KEY_LENGTH)).toString('base64')
117
+ }]
118
+ },
119
+ signupToken
120
+ };
121
+ }
122
+ function makeBadAddUserReq(goodId) {
123
+ const name = 'Bob Marley';
124
+ const badJSONs = [name, 5, null, undefined, [name],
125
+ { a: 1 }];
126
+ const badIds = ['bad domain str',
127
+ '', ' ', '\t', '\n',
128
+ 5, null, undefined, {}]; // non-strings
129
+ for (const id of badIds) {
130
+ const req = makeAddUserReq(id);
131
+ badJSONs.push(req);
132
+ }
133
+ let req = makeAddUserReq(goodId);
134
+ delete req.userId;
135
+ badJSONs.push(req);
136
+ req = makeAddUserReq(goodId);
137
+ delete req.storage;
138
+ badJSONs.push(req);
139
+ req = makeAddUserReq(goodId);
140
+ delete req.storage.kdParams;
141
+ badJSONs.push(req);
142
+ req = makeAddUserReq(goodId);
143
+ delete req.mailerId;
144
+ badJSONs.push(req);
145
+ req = makeAddUserReq(goodId);
146
+ delete req.mailerId.defaultPKey;
147
+ badJSONs.push(req);
148
+ req = makeAddUserReq(goodId);
149
+ delete req.mailerId.defaultPKey.pkey.alg;
150
+ badJSONs.push(req);
151
+ req = makeAddUserReq(goodId);
152
+ delete req.mailerId.defaultPKey.pkey.k;
153
+ badJSONs.push(req);
154
+ req = makeAddUserReq(goodId);
155
+ delete req.mailerId.defaultPKey.pkey.kid;
156
+ badJSONs.push(req);
157
+ req = makeAddUserReq(goodId);
158
+ delete req.mailerId.defaultPKey.pkey.use;
159
+ badJSONs.push(req);
160
+ req = makeAddUserReq(goodId);
161
+ delete req.mailerId.defaultPKey.kdParams;
162
+ badJSONs.push(req);
163
+ req = makeAddUserReq(goodId);
164
+ delete req.mailerId.otherPKeys;
165
+ badJSONs.push(req);
166
+ req = makeAddUserReq(goodId);
167
+ req.mailerId.otherPKeys.shift();
168
+ badJSONs.push(req);
169
+ req = makeAddUserReq(goodId);
170
+ delete req.mailerId.otherPKeys[0].alg;
171
+ badJSONs.push(req);
172
+ req = makeAddUserReq(goodId);
173
+ delete req.mailerId.otherPKeys[0].k;
174
+ badJSONs.push(req);
175
+ req = makeAddUserReq(goodId);
176
+ delete req.mailerId.otherPKeys[0].kid;
177
+ badJSONs.push(req);
178
+ req = makeAddUserReq(goodId);
179
+ delete req.mailerId.otherPKeys[0].use;
180
+ badJSONs.push(req);
181
+ return badJSONs;
182
+ }
183
+ async function addNewUser(userId, signupToken) {
184
+ const reqOpts = {
185
+ url: admin.signupUrl + signupApi.addUser.URL_END,
186
+ method: 'POST'
187
+ };
188
+ const req = makeAddUserReq(userId, signupToken);
189
+ let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
190
+ expect(rep.status).withContext('status when user is added').toBe(signupApi.addUser.SC.ok);
191
+ rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
192
+ expect(rep.status).withContext('status when user already exists').toBe(signupApi.addUser.SC.userAlreadyExists);
193
+ }
194
+ (0, async_jasmine_1.itAsync)('adds new user', async () => {
195
+ const REQ_SIZE_LIMIT = 4 * 1024;
196
+ const reqOpts = {
197
+ url: admin.signupUrl + signupApi.addUser.URL_END,
198
+ method: 'POST'
199
+ };
200
+ const name = 'Bob Marley ';
201
+ let addresses = await getAvailableAddressesFor(name);
202
+ let numOfAvailableAddresses = addresses.length;
203
+ expect(numOfAvailableAddresses).toBe(signupDomains.length);
204
+ // requests with bad json's
205
+ const badJSONs = makeBadAddUserReq(addresses[0]);
206
+ await (0, requests_1.expectNonAcceptanceOfBadJsonRequest)(reqOpts, REQ_SIZE_LIMIT, badJSONs);
207
+ // normal adding users
208
+ for (const userId of addresses) {
209
+ expect(addresses).toContain(userId);
210
+ await addNewUser(userId);
211
+ numOfAvailableAddresses -= 1;
212
+ addresses = await getAvailableAddressesFor(name);
213
+ expect(addresses.length).toBe(numOfAvailableAddresses);
214
+ expect(addresses).not.toContain(userId);
215
+ }
216
+ });
217
+ (0, async_jasmine_1.itAsync)(`adds new user with token`, async () => {
218
+ const reqOpts = {
219
+ url: admin.signupUrl + signupApi.addUser.URL_END,
220
+ method: 'POST'
221
+ };
222
+ // note that new id has other domain that isn't set anywhere
223
+ const userId = 'Pink Floyd @home.town';
224
+ // let's try to do this without any token
225
+ let req = makeAddUserReq(userId);
226
+ let rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
227
+ expect(rep.status).withContext('status when no token given').toBe(signupApi.addUser.SC.unauthorized);
228
+ // create token, here setup code uses spec-server specific code
229
+ const token = await admin.createSingleUserSignupTokenFor(userId);
230
+ req = makeAddUserReq(userId, token);
231
+ rep = await (0, xhr_utils_1.doJsonRequest)(reqOpts, req);
232
+ expect(rep.status).withContext('status when user is added').toBe(signupApi.addUser.SC.ok);
233
+ });
234
+ });
235
+ });
@@ -0,0 +1 @@
1
+ declare const jas: any;
@@ -0,0 +1,32 @@
1
+ /*
2
+ Copyright (C) 2016 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
+ // NOTE: due to bad definition file, typescript below is not very type-strict.
18
+ const jas = new (require('jasmine'))();
19
+ jas.loadConfig({
20
+ spec_dir: 'build/tests',
21
+ spec_files: [
22
+ 'admin-proto/**/*.js',
23
+ 'protocols/mailerid.js',
24
+ 'protocols/3nstorage/*.js',
25
+ 'protocols/asmail/*.js',
26
+ ],
27
+ random: false
28
+ });
29
+ jas.configureDefaultReporter({
30
+ showColors: true
31
+ });
32
+ jas.execute();