@stamhoofd/models 2.39.0 → 2.40.0

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 (352) hide show
  1. package/dist/src/factories/AddressFactory.d.ts +3 -4
  2. package/dist/src/factories/AddressFactory.d.ts.map +1 -1
  3. package/dist/src/factories/AddressFactory.js +13 -13
  4. package/dist/src/factories/EmergencyContactFactory.d.ts +3 -4
  5. package/dist/src/factories/EmergencyContactFactory.d.ts.map +1 -1
  6. package/dist/src/factories/EmergencyContactFactory.js +27 -27
  7. package/dist/src/factories/EmergencyContactFactory.js.map +1 -1
  8. package/dist/src/factories/GroupFactory.d.ts +4 -4
  9. package/dist/src/factories/GroupFactory.d.ts.map +1 -1
  10. package/dist/src/factories/GroupFactory.js +8 -8
  11. package/dist/src/factories/GroupFactory.js.map +1 -1
  12. package/dist/src/factories/MemberFactory.d.ts +4 -4
  13. package/dist/src/factories/MemberFactory.d.ts.map +1 -1
  14. package/dist/src/factories/MemberFactory.js +17 -17
  15. package/dist/src/factories/MemberFactory.js.map +1 -1
  16. package/dist/src/factories/OrganizationFactory.d.ts +4 -4
  17. package/dist/src/factories/OrganizationFactory.js +8 -8
  18. package/dist/src/factories/OrganizationFactory.js.map +1 -1
  19. package/dist/src/factories/ParentFactory.d.ts +1 -1
  20. package/dist/src/factories/ParentFactory.js +19 -19
  21. package/dist/src/factories/ParentFactory.js.map +1 -1
  22. package/dist/src/factories/RecordFactory.d.ts +2 -3
  23. package/dist/src/factories/RecordFactory.d.ts.map +1 -1
  24. package/dist/src/factories/RecordFactory.js +1 -1
  25. package/dist/src/factories/RecordFactory.js.map +1 -1
  26. package/dist/src/factories/RegisterCodeFactory.d.ts +2 -2
  27. package/dist/src/factories/RegisterCodeFactory.d.ts.map +1 -1
  28. package/dist/src/factories/RegisterCodeFactory.js +2 -2
  29. package/dist/src/factories/RegistrationFactory.d.ts +3 -3
  30. package/dist/src/factories/RegistrationFactory.d.ts.map +1 -1
  31. package/dist/src/factories/RegistrationFactory.js.map +1 -1
  32. package/dist/src/factories/RegistrationPeriodFactory.d.ts +2 -2
  33. package/dist/src/factories/RegistrationPeriodFactory.js.map +1 -1
  34. package/dist/src/factories/UserFactory.d.ts +3 -3
  35. package/dist/src/factories/UserFactory.d.ts.map +1 -1
  36. package/dist/src/factories/UserFactory.js +3 -3
  37. package/dist/src/factories/UserFactory.js.map +1 -1
  38. package/dist/src/factories/WebshopFactory.d.ts +4 -4
  39. package/dist/src/factories/WebshopFactory.d.ts.map +1 -1
  40. package/dist/src/factories/WebshopFactory.js +1 -1
  41. package/dist/src/factories/WebshopFactory.js.map +1 -1
  42. package/dist/src/helpers/DNSValidator.d.ts +1 -1
  43. package/dist/src/helpers/DNSValidator.d.ts.map +1 -1
  44. package/dist/src/helpers/DNSValidator.js +33 -33
  45. package/dist/src/helpers/DNSValidator.js.map +1 -1
  46. package/dist/src/helpers/EmailBuilder.d.ts +10 -10
  47. package/dist/src/helpers/EmailBuilder.d.ts.map +1 -1
  48. package/dist/src/helpers/EmailBuilder.js +34 -34
  49. package/dist/src/helpers/EmailBuilder.js.map +1 -1
  50. package/dist/src/helpers/GroupBuilder.d.ts.map +1 -1
  51. package/dist/src/helpers/GroupBuilder.js +57 -57
  52. package/dist/src/helpers/GroupBuilder.js.map +1 -1
  53. package/dist/src/helpers/Handlebars.d.ts.map +1 -1
  54. package/dist/src/helpers/Handlebars.js +29 -29
  55. package/dist/src/helpers/Handlebars.js.map +1 -1
  56. package/dist/src/helpers/MemberMerger.d.ts +1 -1
  57. package/dist/src/helpers/MemberMerger.d.ts.map +1 -1
  58. package/dist/src/helpers/MemberMerger.js +33 -33
  59. package/dist/src/helpers/MemberMerger.js.map +1 -1
  60. package/dist/src/helpers/MemberMerger.test.js +194 -194
  61. package/dist/src/helpers/MemberMerger.test.js.map +1 -1
  62. package/dist/src/helpers/RateLimiter.d.ts.map +1 -1
  63. package/dist/src/helpers/RateLimiter.js +2 -2
  64. package/dist/src/helpers/RateLimiter.js.map +1 -1
  65. package/dist/src/helpers/SetupStepsUpdater.d.ts +22 -0
  66. package/dist/src/helpers/SetupStepsUpdater.d.ts.map +1 -0
  67. package/dist/src/helpers/SetupStepsUpdater.js +255 -0
  68. package/dist/src/helpers/SetupStepsUpdater.js.map +1 -0
  69. package/dist/src/helpers/WebshopCounter.d.ts +1 -1
  70. package/dist/src/helpers/WebshopCounter.d.ts.map +1 -1
  71. package/dist/src/helpers/WebshopCounter.js +1 -1
  72. package/dist/src/helpers/WebshopCounter.js.map +1 -1
  73. package/dist/src/helpers/WebshopCounter.test.js +6 -6
  74. package/dist/src/helpers/WebshopCounter.test.js.map +1 -1
  75. package/dist/src/index.d.ts +20 -19
  76. package/dist/src/index.d.ts.map +1 -1
  77. package/dist/src/index.js +1 -0
  78. package/dist/src/index.js.map +1 -1
  79. package/dist/src/migrations/1605262045-import-postcodes.js +12 -12
  80. package/dist/src/migrations/1605262046-import-postcodes-nl.js +10 -10
  81. package/dist/src/models/BalanceItem.d.ts.map +1 -1
  82. package/dist/src/models/BalanceItem.js +37 -37
  83. package/dist/src/models/BalanceItem.js.map +1 -1
  84. package/dist/src/models/BalanceItemPayment.d.ts.map +1 -1
  85. package/dist/src/models/BalanceItemPayment.js +13 -13
  86. package/dist/src/models/BalanceItemPayment.js.map +1 -1
  87. package/dist/src/models/BuckarooPayment.d.ts +1 -1
  88. package/dist/src/models/BuckarooPayment.d.ts.map +1 -1
  89. package/dist/src/models/BuckarooPayment.js +5 -5
  90. package/dist/src/models/BuckarooPayment.js.map +1 -1
  91. package/dist/src/models/CachedOutstandingBalance.d.ts.map +1 -1
  92. package/dist/src/models/CachedOutstandingBalance.js +37 -37
  93. package/dist/src/models/CachedOutstandingBalance.js.map +1 -1
  94. package/dist/src/models/Document.d.ts +4 -4
  95. package/dist/src/models/Document.d.ts.map +1 -1
  96. package/dist/src/models/Document.js +27 -27
  97. package/dist/src/models/Document.js.map +1 -1
  98. package/dist/src/models/DocumentTemplate.d.ts +4 -4
  99. package/dist/src/models/DocumentTemplate.d.ts.map +1 -1
  100. package/dist/src/models/DocumentTemplate.js +72 -72
  101. package/dist/src/models/DocumentTemplate.js.map +1 -1
  102. package/dist/src/models/Email.d.ts.map +1 -1
  103. package/dist/src/models/Email.js +63 -64
  104. package/dist/src/models/Email.js.map +1 -1
  105. package/dist/src/models/EmailRecipient.d.ts.map +1 -1
  106. package/dist/src/models/EmailRecipient.js +20 -20
  107. package/dist/src/models/EmailRecipient.js.map +1 -1
  108. package/dist/src/models/EmailTemplate.d.ts +3 -3
  109. package/dist/src/models/EmailTemplate.d.ts.map +1 -1
  110. package/dist/src/models/EmailTemplate.js +16 -16
  111. package/dist/src/models/EmailTemplate.js.map +1 -1
  112. package/dist/src/models/EmailVerificationCode.d.ts +2 -2
  113. package/dist/src/models/EmailVerificationCode.d.ts.map +1 -1
  114. package/dist/src/models/EmailVerificationCode.js +57 -55
  115. package/dist/src/models/EmailVerificationCode.js.map +1 -1
  116. package/dist/src/models/Event.d.ts +2 -2
  117. package/dist/src/models/Event.d.ts.map +1 -1
  118. package/dist/src/models/Event.js +15 -15
  119. package/dist/src/models/Event.js.map +1 -1
  120. package/dist/src/models/Group.d.ts +3 -1
  121. package/dist/src/models/Group.d.ts.map +1 -1
  122. package/dist/src/models/Group.js +46 -35
  123. package/dist/src/models/Group.js.map +1 -1
  124. package/dist/src/models/Image.d.ts +1 -1
  125. package/dist/src/models/Image.d.ts.map +1 -1
  126. package/dist/src/models/Image.js +26 -26
  127. package/dist/src/models/Image.js.map +1 -1
  128. package/dist/src/models/Member.d.ts +8 -8
  129. package/dist/src/models/Member.d.ts.map +1 -1
  130. package/dist/src/models/Member.js +60 -60
  131. package/dist/src/models/Member.js.map +1 -1
  132. package/dist/src/models/MemberPlatformMembership.d.ts +3 -3
  133. package/dist/src/models/MemberPlatformMembership.d.ts.map +1 -1
  134. package/dist/src/models/MemberPlatformMembership.js +26 -26
  135. package/dist/src/models/MemberPlatformMembership.js.map +1 -1
  136. package/dist/src/models/MemberResponsibilityRecord.d.ts.map +1 -1
  137. package/dist/src/models/MemberResponsibilityRecord.js +13 -13
  138. package/dist/src/models/MemberResponsibilityRecord.js.map +1 -1
  139. package/dist/src/models/MergedMember.d.ts +3 -3
  140. package/dist/src/models/MergedMember.d.ts.map +1 -1
  141. package/dist/src/models/MergedMember.js +19 -19
  142. package/dist/src/models/MergedMember.js.map +1 -1
  143. package/dist/src/models/MolliePayment.d.ts +1 -1
  144. package/dist/src/models/MolliePayment.d.ts.map +1 -1
  145. package/dist/src/models/MolliePayment.js +5 -5
  146. package/dist/src/models/MolliePayment.js.map +1 -1
  147. package/dist/src/models/MollieToken.d.ts.map +1 -1
  148. package/dist/src/models/MollieToken.js +60 -60
  149. package/dist/src/models/MollieToken.js.map +1 -1
  150. package/dist/src/models/OneTimeToken.d.ts +2 -2
  151. package/dist/src/models/OneTimeToken.d.ts.map +1 -1
  152. package/dist/src/models/OneTimeToken.js +13 -13
  153. package/dist/src/models/OneTimeToken.js.map +1 -1
  154. package/dist/src/models/Order.d.ts +1 -1
  155. package/dist/src/models/Order.d.ts.map +1 -1
  156. package/dist/src/models/Order.js +70 -70
  157. package/dist/src/models/Order.js.map +1 -1
  158. package/dist/src/models/Organization.d.ts +5 -5
  159. package/dist/src/models/Organization.d.ts.map +1 -1
  160. package/dist/src/models/Organization.js +127 -127
  161. package/dist/src/models/Organization.js.map +1 -1
  162. package/dist/src/models/OrganizationRegistrationPeriod.d.ts.map +1 -1
  163. package/dist/src/models/OrganizationRegistrationPeriod.js +15 -15
  164. package/dist/src/models/OrganizationRegistrationPeriod.js.map +1 -1
  165. package/dist/src/models/PasswordToken.d.ts +3 -3
  166. package/dist/src/models/PasswordToken.d.ts.map +1 -1
  167. package/dist/src/models/PasswordToken.js +17 -17
  168. package/dist/src/models/PasswordToken.js.map +1 -1
  169. package/dist/src/models/PayconiqPayment.d.ts +1 -1
  170. package/dist/src/models/PayconiqPayment.d.ts.map +1 -1
  171. package/dist/src/models/PayconiqPayment.js +49 -49
  172. package/dist/src/models/PayconiqPayment.js.map +1 -1
  173. package/dist/src/models/Payment.d.ts +3 -3
  174. package/dist/src/models/Payment.d.ts.map +1 -1
  175. package/dist/src/models/Payment.js +36 -36
  176. package/dist/src/models/Payment.js.map +1 -1
  177. package/dist/src/models/Platform.d.ts +2 -2
  178. package/dist/src/models/Platform.d.ts.map +1 -1
  179. package/dist/src/models/Platform.js +8 -8
  180. package/dist/src/models/Platform.js.map +1 -1
  181. package/dist/src/models/RegisterCode.d.ts +1 -1
  182. package/dist/src/models/RegisterCode.d.ts.map +1 -1
  183. package/dist/src/models/RegisterCode.js +11 -11
  184. package/dist/src/models/RegisterCode.js.map +1 -1
  185. package/dist/src/models/Registration.d.ts +1 -1
  186. package/dist/src/models/Registration.d.ts.map +1 -1
  187. package/dist/src/models/Registration.js +88 -88
  188. package/dist/src/models/Registration.js.map +1 -1
  189. package/dist/src/models/RegistrationPeriod.d.ts.map +1 -1
  190. package/dist/src/models/RegistrationPeriod.js +12 -12
  191. package/dist/src/models/RegistrationPeriod.js.map +1 -1
  192. package/dist/src/models/STCredit.d.ts +1 -1
  193. package/dist/src/models/STCredit.d.ts.map +1 -1
  194. package/dist/src/models/STCredit.js +12 -12
  195. package/dist/src/models/STCredit.js.map +1 -1
  196. package/dist/src/models/STInvoice.d.ts +1 -1
  197. package/dist/src/models/STInvoice.d.ts.map +1 -1
  198. package/dist/src/models/STInvoice.js +16 -16
  199. package/dist/src/models/STInvoice.js.map +1 -1
  200. package/dist/src/models/STPackage.d.ts +1 -1
  201. package/dist/src/models/STPackage.d.ts.map +1 -1
  202. package/dist/src/models/STPackage.js +39 -39
  203. package/dist/src/models/STPackage.js.map +1 -1
  204. package/dist/src/models/STPendingInvoice.d.ts +1 -1
  205. package/dist/src/models/STPendingInvoice.d.ts.map +1 -1
  206. package/dist/src/models/STPendingInvoice.js +11 -11
  207. package/dist/src/models/STPendingInvoice.js.map +1 -1
  208. package/dist/src/models/StripeAccount.d.ts.map +1 -1
  209. package/dist/src/models/StripeAccount.js +13 -13
  210. package/dist/src/models/StripeAccount.js.map +1 -1
  211. package/dist/src/models/StripeCheckoutSession.d.ts +1 -1
  212. package/dist/src/models/StripeCheckoutSession.d.ts.map +1 -1
  213. package/dist/src/models/StripeCheckoutSession.js +7 -7
  214. package/dist/src/models/StripeCheckoutSession.js.map +1 -1
  215. package/dist/src/models/StripePaymentIntent.d.ts +1 -1
  216. package/dist/src/models/StripePaymentIntent.d.ts.map +1 -1
  217. package/dist/src/models/StripePaymentIntent.js +7 -7
  218. package/dist/src/models/StripePaymentIntent.js.map +1 -1
  219. package/dist/src/models/Ticket.d.ts +2 -2
  220. package/dist/src/models/Ticket.d.ts.map +1 -1
  221. package/dist/src/models/Ticket.js +23 -23
  222. package/dist/src/models/Ticket.js.map +1 -1
  223. package/dist/src/models/Token.d.ts +3 -3
  224. package/dist/src/models/Token.d.ts.map +1 -1
  225. package/dist/src/models/Token.js +27 -27
  226. package/dist/src/models/Token.js.map +1 -1
  227. package/dist/src/models/Token.test.js +11 -11
  228. package/dist/src/models/UsedRegisterCode.d.ts +1 -1
  229. package/dist/src/models/UsedRegisterCode.d.ts.map +1 -1
  230. package/dist/src/models/UsedRegisterCode.js +10 -10
  231. package/dist/src/models/UsedRegisterCode.js.map +1 -1
  232. package/dist/src/models/User.d.ts +4 -4
  233. package/dist/src/models/User.d.ts.map +1 -1
  234. package/dist/src/models/User.js +53 -51
  235. package/dist/src/models/User.js.map +1 -1
  236. package/dist/src/models/UserPermissions.d.ts +3 -3
  237. package/dist/src/models/UserPermissions.d.ts.map +1 -1
  238. package/dist/src/models/UserPermissions.js +12 -12
  239. package/dist/src/models/UserPermissions.js.map +1 -1
  240. package/dist/src/models/Webshop.d.ts +1 -1
  241. package/dist/src/models/Webshop.d.ts.map +1 -1
  242. package/dist/src/models/Webshop.js +23 -23
  243. package/dist/src/models/Webshop.js.map +1 -1
  244. package/dist/src/models/WebshopDiscountCode.d.ts +1 -1
  245. package/dist/src/models/WebshopDiscountCode.d.ts.map +1 -1
  246. package/dist/src/models/WebshopDiscountCode.js +16 -16
  247. package/dist/src/models/WebshopDiscountCode.js.map +1 -1
  248. package/dist/src/models/addresses/City.d.ts.map +1 -1
  249. package/dist/src/models/addresses/City.js +9 -9
  250. package/dist/src/models/addresses/City.js.map +1 -1
  251. package/dist/src/models/addresses/PostalCode.d.ts.map +1 -1
  252. package/dist/src/models/addresses/PostalCode.js +11 -11
  253. package/dist/src/models/addresses/PostalCode.js.map +1 -1
  254. package/dist/src/models/addresses/PostalCode.test.js +22 -22
  255. package/dist/src/models/addresses/PostalCode.test.js.map +1 -1
  256. package/dist/src/models/addresses/Province.d.ts.map +1 -1
  257. package/dist/src/models/addresses/Province.js +5 -5
  258. package/dist/src/models/addresses/Province.js.map +1 -1
  259. package/dist/src/models/addresses/Street.d.ts.map +1 -1
  260. package/dist/src/models/addresses/Street.js +6 -6
  261. package/dist/src/models/addresses/Street.js.map +1 -1
  262. package/dist/src/models/index.d.ts +46 -46
  263. package/dist/src/models/index.d.ts.map +1 -1
  264. package/dist/src/models/index.js +0 -1
  265. package/dist/src/models/index.js.map +1 -1
  266. package/dist/src/structures/OrganizationServerMetaData.d.ts.map +1 -1
  267. package/dist/src/structures/OrganizationServerMetaData.js +4 -4
  268. package/dist/src/structures/OrganizationServerMetaData.js.map +1 -1
  269. package/dist/tests/jest.global.setup.d.ts.map +1 -1
  270. package/dist/tests/jest.global.setup.js +15 -13
  271. package/dist/tests/jest.global.setup.js.map +1 -1
  272. package/dist/tests/jest.setup.js +3 -1
  273. package/dist/tests/jest.setup.js.map +1 -1
  274. package/dist/tsconfig.tsbuildinfo +1 -0
  275. package/package.json +3 -3
  276. package/src/factories/AddressFactory.ts +17 -17
  277. package/src/factories/EmergencyContactFactory.ts +30 -31
  278. package/src/factories/GroupFactory.ts +30 -30
  279. package/src/factories/MemberFactory.ts +41 -38
  280. package/src/factories/OrganizationFactory.ts +15 -15
  281. package/src/factories/ParentFactory.ts +24 -24
  282. package/src/factories/RecordFactory.ts +5 -4
  283. package/src/factories/RegisterCodeFactory.ts +7 -7
  284. package/src/factories/RegistrationFactory.ts +16 -16
  285. package/src/factories/RegistrationPeriodFactory.ts +5 -5
  286. package/src/factories/UserFactory.ts +20 -19
  287. package/src/factories/WebshopFactory.ts +14 -14
  288. package/src/helpers/DNSValidator.ts +89 -84
  289. package/src/helpers/EmailBuilder.ts +141 -135
  290. package/src/helpers/GroupBuilder.ts +181 -181
  291. package/src/helpers/Handlebars.ts +57 -54
  292. package/src/helpers/MemberMerger.test.ts +702 -702
  293. package/src/helpers/MemberMerger.ts +83 -77
  294. package/src/helpers/RateLimiter.ts +25 -27
  295. package/src/helpers/SetupStepsUpdater.ts +402 -0
  296. package/src/helpers/WebshopCounter.test.ts +12 -12
  297. package/src/helpers/WebshopCounter.ts +20 -19
  298. package/src/index.ts +20 -19
  299. package/src/migrations/1605262045-import-postcodes.ts +59 -63
  300. package/src/migrations/1605262046-import-postcodes-nl.ts +41 -43
  301. package/src/models/BalanceItem.ts +173 -172
  302. package/src/models/BalanceItemPayment.ts +32 -33
  303. package/src/models/BuckarooPayment.ts +7 -7
  304. package/src/models/CachedOutstandingBalance.ts +98 -99
  305. package/src/models/Document.ts +90 -87
  306. package/src/models/DocumentTemplate.ts +207 -198
  307. package/src/models/Email.ts +198 -200
  308. package/src/models/EmailRecipient.ts +38 -39
  309. package/src/models/EmailTemplate.ts +36 -37
  310. package/src/models/EmailVerificationCode.ts +146 -142
  311. package/src/models/Event.ts +53 -53
  312. package/src/models/Group.ts +136 -123
  313. package/src/models/Image.ts +48 -48
  314. package/src/models/Member.ts +277 -275
  315. package/src/models/MemberPlatformMembership.ts +71 -71
  316. package/src/models/MemberResponsibilityRecord.ts +32 -32
  317. package/src/models/MergedMember.ts +77 -77
  318. package/src/models/MolliePayment.ts +7 -7
  319. package/src/models/MollieToken.ts +131 -126
  320. package/src/models/OneTimeToken.ts +40 -39
  321. package/src/models/Order.ts +379 -372
  322. package/src/models/Organization.ts +332 -325
  323. package/src/models/OrganizationRegistrationPeriod.ts +50 -50
  324. package/src/models/PasswordToken.ts +42 -42
  325. package/src/models/PayconiqPayment.ts +80 -76
  326. package/src/models/Payment.ts +86 -86
  327. package/src/models/Platform.ts +21 -22
  328. package/src/models/RegisterCode.ts +26 -26
  329. package/src/models/Registration.ts +167 -168
  330. package/src/models/RegistrationPeriod.ts +29 -29
  331. package/src/models/STCredit.ts +24 -25
  332. package/src/models/STInvoice.ts +34 -34
  333. package/src/models/STPackage.ts +143 -136
  334. package/src/models/STPendingInvoice.ts +26 -26
  335. package/src/models/StripeAccount.ts +27 -27
  336. package/src/models/StripeCheckoutSession.ts +10 -10
  337. package/src/models/StripePaymentIntent.ts +10 -10
  338. package/src/models/Ticket.ts +51 -52
  339. package/src/models/Token.test.ts +13 -13
  340. package/src/models/Token.ts +64 -63
  341. package/src/models/UsedRegisterCode.ts +20 -21
  342. package/src/models/User.ts +148 -144
  343. package/src/models/UserPermissions.ts +25 -28
  344. package/src/models/Webshop.ts +53 -53
  345. package/src/models/WebshopDiscountCode.ts +33 -33
  346. package/src/models/addresses/City.ts +12 -12
  347. package/src/models/addresses/PostalCode.test.ts +68 -69
  348. package/src/models/addresses/PostalCode.ts +57 -57
  349. package/src/models/addresses/Province.ts +8 -8
  350. package/src/models/addresses/Street.ts +10 -12
  351. package/src/models/index.ts +54 -55
  352. package/src/structures/OrganizationServerMetaData.ts +36 -36
@@ -1,9 +1,9 @@
1
- import { column,Model } from '@simonbackx/simple-database';
1
+ import { column, Model } from '@simonbackx/simple-database';
2
2
  import { PartialWithoutMethods, PlainObject } from '@simonbackx/simple-encoding';
3
3
  import { SimpleError } from '@simonbackx/simple-errors';
4
- import { MollieOnboarding,MollieProfile, MollieStatus } from '@stamhoofd/structures';
5
- import { IncomingMessage } from "http";
6
- import https from "https";
4
+ import { MollieOnboarding, MollieProfile, MollieStatus } from '@stamhoofd/structures';
5
+ import { IncomingMessage } from 'http';
6
+ import https from 'https';
7
7
 
8
8
  import { Organization } from './Organization';
9
9
 
@@ -12,117 +12,119 @@ function sleep(ms: number) {
12
12
  }
13
13
 
14
14
  export class MollieToken extends Model {
15
- static table = "mollie_tokens"
15
+ static table = 'mollie_tokens';
16
16
 
17
- @column({ primary: true, type: "string" })
17
+ @column({ primary: true, type: 'string' })
18
18
  organizationId!: string;
19
19
 
20
- @column({ type: "string" })
20
+ @column({ type: 'string' })
21
21
  accessToken: string;
22
22
 
23
- @column({ type: "string" })
23
+ @column({ type: 'string' })
24
24
  refreshToken: string;
25
25
 
26
- @column({ type: "datetime" })
26
+ @column({ type: 'datetime' })
27
27
  expiresOn: Date;
28
28
 
29
29
  @column({
30
- type: "datetime", beforeSave(old?: any) {
30
+ type: 'datetime', beforeSave(old?: any) {
31
31
  if (old !== undefined) {
32
32
  return old;
33
33
  }
34
- const date = new Date()
35
- date.setMilliseconds(0)
36
- return date
37
- }
34
+ const date = new Date();
35
+ date.setMilliseconds(0);
36
+ return date;
37
+ },
38
38
  })
39
- createdAt: Date
39
+ createdAt: Date;
40
40
 
41
- static verbose = true
41
+ static verbose = true;
42
42
 
43
- static knownTokens: Map<string, MollieToken> = new Map()
43
+ static knownTokens: Map<string, MollieToken> = new Map();
44
44
 
45
45
  static async getTokenFor(organizationId: string) {
46
- const existing = this.knownTokens.get(organizationId)
46
+ const existing = this.knownTokens.get(organizationId);
47
47
  if (existing) {
48
- return existing
48
+ return existing;
49
49
  }
50
- const tokens = await MollieToken.where({ organizationId })
50
+ const tokens = await MollieToken.where({ organizationId });
51
51
  if (tokens.length == 0) {
52
- return undefined
52
+ return undefined;
53
53
  }
54
- this.knownTokens.set(organizationId, tokens[0])
55
- return tokens[0]
54
+ this.knownTokens.set(organizationId, tokens[0]);
55
+ return tokens[0];
56
56
  }
57
57
 
58
58
  async delete() {
59
- await super.delete()
60
- MollieToken.knownTokens.delete(this.organizationId)
59
+ await super.delete();
60
+ MollieToken.knownTokens.delete(this.organizationId);
61
61
  }
62
62
 
63
63
  private static objectToQueryString(obj: Record<string, string>) {
64
64
  const str: string[] = [];
65
- // eslint-disable-next-line no-prototype-builtins
65
+
66
66
  for (const p in obj)
67
67
  // eslint-disable-next-line no-prototype-builtins
68
68
  if (obj.hasOwnProperty(p)) {
69
- str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
69
+ str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
70
70
  }
71
- return str.join("&");
71
+ return str.join('&');
72
72
  }
73
73
 
74
74
  async getAccessToken() {
75
75
  if (this.expiresOn < new Date()) {
76
- await this.refresh()
77
- await sleep(200)
76
+ await this.refresh();
77
+ await sleep(200);
78
78
  }
79
- return this.accessToken
79
+ return this.accessToken;
80
80
  }
81
81
 
82
82
  async refreshIfNeeded() {
83
83
  if (this.expiresOn < new Date()) {
84
- await this.refresh()
85
- await sleep(200)
84
+ await this.refresh();
85
+ await sleep(200);
86
86
  }
87
87
  }
88
88
 
89
89
  async authRequest(method: string, path: string, data: PlainObject = {}) {
90
90
  if (this.expiresOn < new Date()) {
91
- await this.refresh()
92
- await sleep(200)
91
+ await this.refresh();
92
+ await sleep(200);
93
93
  }
94
94
 
95
- return await MollieToken.request(method, path, data, "json", this.accessToken);
95
+ return await MollieToken.request(method, path, data, 'json', this.accessToken);
96
96
  }
97
97
 
98
98
  /**
99
99
  * Do a post request on the API.
100
100
  */
101
- private static request(method: string, path: string, data: PlainObject = {}, type = "json", auth: string | null = null): Promise<any> {
101
+ private static request(method: string, path: string, data: PlainObject = {}, type = 'json', auth: string | null = null): Promise<any> {
102
102
  return new Promise((resolve, reject) => {
103
103
  let jsonData: string;
104
- if (type == "json") {
104
+ if (type == 'json') {
105
105
  jsonData = JSON.stringify(data);
106
- } else {
106
+ }
107
+ else {
107
108
  jsonData = this.objectToQueryString(data as Record<string, string>);
108
109
  }
109
110
 
110
111
  if (this.verbose) {
111
- console.log(method+" https://api.mollie.com"+path+"\n"+jsonData);
112
+ console.log(method + ' https://api.mollie.com' + path + '\n' + jsonData);
112
113
  }
113
114
  const req = https.request(
114
115
  {
115
- hostname: "api.mollie.com",
116
+ hostname: 'api.mollie.com',
116
117
  path: path,
117
118
  method: method,
118
- headers: method === 'GET' ?
119
- {
120
- "Authorization": auth ? "Bearer "+auth : "Basic "+Buffer.from((STAMHOOFD.MOLLIE_CLIENT_ID ?? "")+":"+(STAMHOOFD.MOLLIE_SECRET ?? ""), "ascii").toString("base64")
121
- } : {
122
- "Content-Type": type == "json" ? "application/json" : "application/x-www-form-urlencoded",
123
- "Content-Length": Buffer.byteLength(jsonData),
124
- "Authorization": auth ? "Bearer "+auth : "Basic "+Buffer.from((STAMHOOFD.MOLLIE_CLIENT_ID ?? "")+":"+(STAMHOOFD.MOLLIE_SECRET ?? ""), "ascii").toString("base64")
125
- },
119
+ headers: method === 'GET'
120
+ ? {
121
+ Authorization: auth ? 'Bearer ' + auth : 'Basic ' + Buffer.from((STAMHOOFD.MOLLIE_CLIENT_ID ?? '') + ':' + (STAMHOOFD.MOLLIE_SECRET ?? ''), 'ascii').toString('base64'),
122
+ }
123
+ : {
124
+ 'Content-Type': type == 'json' ? 'application/json' : 'application/x-www-form-urlencoded',
125
+ 'Content-Length': Buffer.byteLength(jsonData),
126
+ 'Authorization': auth ? 'Bearer ' + auth : 'Basic ' + Buffer.from((STAMHOOFD.MOLLIE_CLIENT_ID ?? '') + ':' + (STAMHOOFD.MOLLIE_SECRET ?? ''), 'ascii').toString('base64'),
127
+ },
126
128
  timeout: 10000,
127
129
  },
128
130
  (response: IncomingMessage) => {
@@ -133,14 +135,14 @@ export class MollieToken extends Model {
133
135
 
134
136
  const chunks: any[] = [];
135
137
 
136
- response.on("data", (chunk) => {
138
+ response.on('data', (chunk) => {
137
139
  chunks.push(chunk);
138
140
  });
139
141
 
140
- response.on("end", () => {
142
+ response.on('end', () => {
141
143
  try {
142
144
  if (!response.statusCode) {
143
- reject(new Error("Unexpected order of events"));
145
+ reject(new Error('Unexpected order of events'));
144
146
  return;
145
147
  }
146
148
  const body = Buffer.concat(chunks).toString();
@@ -151,26 +153,28 @@ export class MollieToken extends Model {
151
153
 
152
154
  if (response.statusCode == 204) {
153
155
  resolve(undefined);
154
- return
156
+ return;
155
157
  }
156
158
 
157
159
  let json: any;
158
160
  try {
159
161
  json = JSON.parse(body);
160
- } catch (error) {
162
+ }
163
+ catch (error) {
161
164
  console.error(error);
162
-
165
+
163
166
  // invalid json
164
167
  if (response.statusCode < 200 || response.statusCode >= 300) {
165
168
  if (body.length == 0) {
166
169
  console.error(response.statusCode);
167
- reject(new Error("Status " + response.statusCode));
170
+ reject(new Error('Status ' + response.statusCode));
168
171
  return;
169
172
  }
170
- console.error(response.statusCode + " " + body);
173
+ console.error(response.statusCode + ' ' + body);
171
174
  reject(new Error(body));
172
175
  return;
173
- } else {
176
+ }
177
+ else {
174
178
  // something wrong: throw parse error
175
179
  reject(error);
176
180
  return;
@@ -179,27 +183,28 @@ export class MollieToken extends Model {
179
183
 
180
184
  if (response.statusCode < 200 || response.statusCode >= 300) {
181
185
  console.error(body);
182
- reject(new Error(response.statusCode + " " + response.statusMessage));
186
+ reject(new Error(response.statusCode + ' ' + response.statusMessage));
183
187
  return;
184
188
  }
185
189
 
186
190
  resolve(json);
187
- } catch (error) {
191
+ }
192
+ catch (error) {
188
193
  if (this.verbose) {
189
194
  console.error(error);
190
195
  }
191
196
  reject(error);
192
197
  }
193
198
  });
194
- }
199
+ },
195
200
  );
196
201
 
197
202
  // use its "timeout" event to abort the request
198
- req.on("timeout", () => {
203
+ req.on('timeout', () => {
199
204
  req.abort();
200
205
  });
201
206
 
202
- req.on("error", (error) => {
207
+ req.on('error', (error) => {
203
208
  if (this.verbose) {
204
209
  console.error(error);
205
210
  }
@@ -217,24 +222,23 @@ export class MollieToken extends Model {
217
222
  * Refresh the token itself, without generating a new token. Everyone who had the token has a new token now
218
223
  */
219
224
  async refresh(): Promise<void> {
220
- const data = await MollieToken.request("POST", "/oauth2/tokens", {
221
- grant_type: "refresh_token",
225
+ const data = await MollieToken.request('POST', '/oauth2/tokens', {
226
+ grant_type: 'refresh_token',
222
227
  refresh_token: this.refreshToken,
223
- }, "urlencoded")
228
+ }, 'urlencoded');
224
229
 
225
230
  if (data && data.access_token && data.refresh_token) {
226
231
  // Delete token if exisitng
227
- this.refreshToken = data.refresh_token
228
- this.accessToken = data.access_token
229
- this.expiresOn = new Date(new Date().getTime() + 3600 * 1000 - 60*1000)
230
- await this.save()
232
+ this.refreshToken = data.refresh_token;
233
+ this.accessToken = data.access_token;
234
+ this.expiresOn = new Date(new Date().getTime() + 3600 * 1000 - 60 * 1000);
235
+ await this.save();
231
236
 
232
237
  // Update shared tokens if this object was fetched directly
233
- MollieToken.knownTokens.set(this.organizationId, this)
234
- return
238
+ MollieToken.knownTokens.set(this.organizationId, this);
239
+ return;
235
240
  }
236
- throw new SimpleError({ code: "", message: "Something went wrong in the response"})
237
-
241
+ throw new SimpleError({ code: '', message: 'Something went wrong in the response' });
238
242
  }
239
243
 
240
244
  /**
@@ -242,100 +246,101 @@ export class MollieToken extends Model {
242
246
  */
243
247
  async revoke(): Promise<void> {
244
248
  try {
245
- await MollieToken.request("DELETE", "/oauth2/tokens", {
246
- token_type_hint: "refresh_token",
249
+ await MollieToken.request('DELETE', '/oauth2/tokens', {
250
+ token_type_hint: 'refresh_token',
247
251
  token: this.refreshToken,
248
- }, "urlencoded")
249
- } catch (e) {
250
- console.error("Failed to revoke token", this.organizationId, e)
252
+ }, 'urlencoded');
253
+ }
254
+ catch (e) {
255
+ console.error('Failed to revoke token', this.organizationId, e);
251
256
  }
252
- await this.delete()
257
+ await this.delete();
253
258
  }
254
259
 
255
260
  /**
256
261
  * Refresh the token itself, without generating a new token. Everyone who had the token has a new token now
257
262
  */
258
263
  static async create(organization: Organization, code: string): Promise<MollieToken> {
259
- const data = await MollieToken.request("POST", "/oauth2/tokens", {
260
- grant_type: "authorization_code",
261
- code: code
262
- }, "urlencoded")
264
+ const data = await MollieToken.request('POST', '/oauth2/tokens', {
265
+ grant_type: 'authorization_code',
266
+ code: code,
267
+ }, 'urlencoded');
263
268
 
264
269
  if (data && data.access_token && data.refresh_token) {
265
270
  // Delete token if exisitng
266
- const existing = await MollieToken.where({ organizationId: organization.id })
267
- const token = existing[0] ?? new MollieToken()
268
- token.organizationId = organization.id
269
- token.refreshToken = data.refresh_token
270
- token.accessToken = data.access_token
271
- token.expiresOn = new Date(new Date().getTime() + 3600 * 1000 - 60*1000)
272
- await token.save()
271
+ const existing = await MollieToken.where({ organizationId: organization.id });
272
+ const token = existing[0] ?? new MollieToken();
273
+ token.organizationId = organization.id;
274
+ token.refreshToken = data.refresh_token;
275
+ token.accessToken = data.access_token;
276
+ token.expiresOn = new Date(new Date().getTime() + 3600 * 1000 - 60 * 1000);
277
+ await token.save();
273
278
 
274
- this.knownTokens.set(organization.id, token)
279
+ this.knownTokens.set(organization.id, token);
275
280
 
276
- organization.privateMeta.mollieOnboarding = await token.getOnboardingStatus()
277
- await token.setup(organization)
281
+ organization.privateMeta.mollieOnboarding = await token.getOnboardingStatus();
282
+ await token.setup(organization);
278
283
 
279
- await organization.save()
280
- return token
284
+ await organization.save();
285
+ return token;
281
286
  }
282
- throw new SimpleError({ code: "", message: "Something went wrong in the response"})
283
-
287
+ throw new SimpleError({ code: '', message: 'Something went wrong in the response' });
284
288
  }
285
289
 
286
290
  async getOnboardingStatus() {
287
291
  try {
288
- const response = await this.authRequest("GET", "/v2/onboarding/me")
292
+ const response = await this.authRequest('GET', '/v2/onboarding/me');
289
293
  return MollieOnboarding.create({
290
294
  canReceivePayments: !!response.canReceivePayments,
291
295
  canReceiveSettlements: !!response.canReceiveSettlements,
292
- status: response.status === "needs-data" ? MollieStatus.NeedsData : (response.status === "in-review" ? MollieStatus.InReview : (MollieStatus.Completed))
296
+ status: response.status === 'needs-data' ? MollieStatus.NeedsData : (response.status === 'in-review' ? MollieStatus.InReview : (MollieStatus.Completed)),
293
297
  });
294
- } catch (e) {
295
- console.error("Error when requesting Mollie onboarding status:")
296
- console.error(e)
298
+ }
299
+ catch (e) {
300
+ console.error('Error when requesting Mollie onboarding status:');
301
+ console.error(e);
297
302
  return null;
298
303
  }
299
304
  }
300
305
 
301
306
  async getProfiles(): Promise<MollieProfile[]> {
302
307
  try {
303
- const response = await this.authRequest("GET", "/v2/profiles?limit=250")
308
+ const response = await this.authRequest('GET', '/v2/profiles?limit=250');
304
309
  const profiles = response._embedded.profiles as PartialWithoutMethods<MollieProfile>[];
305
- return profiles.map(p => MollieProfile.create(p))
306
- } catch(e) {
307
- console.error('Failed to parse mollie profiles', e)
310
+ return profiles.map(p => MollieProfile.create(p));
311
+ }
312
+ catch (e) {
313
+ console.error('Failed to parse mollie profiles', e);
308
314
  return [];
309
315
  }
310
316
  }
311
317
 
312
318
  async getProfileId(website?: string): Promise<string | null> {
313
- const response = await this.authRequest("GET", "/v2/profiles?limit=250")
319
+ const response = await this.authRequest('GET', '/v2/profiles?limit=250');
314
320
  const profiles = response._embedded.profiles;
315
321
 
316
322
  // Search profile with Stamhoofd as name
317
323
  if (website) {
318
324
  for (const profile of profiles) {
319
325
  if (profile.website.toLowerCase().includes(website)) {
320
- return profile.id
326
+ return profile.id;
321
327
  }
322
328
  }
323
329
  }
324
330
 
325
331
  // Search profile with Stamhoofd as name
326
332
  for (const profile of profiles) {
327
- if (profile.name.toLowerCase().includes("stamhoofd")) {
328
- return profile.id
333
+ if (profile.name.toLowerCase().includes('stamhoofd')) {
334
+ return profile.id;
329
335
  }
330
336
  }
331
337
 
332
- return response._embedded.profiles[0]?.id ?? null
333
-
338
+ return response._embedded.profiles[0]?.id ?? null;
334
339
  }
335
340
 
336
341
  async getOnboardingLink() {
337
- const response = await this.authRequest("GET", "/v2/onboarding/me")
338
- return response._links.dashboard.href ?? ""
342
+ const response = await this.authRequest('GET', '/v2/onboarding/me');
343
+ return response._links.dashboard.href ?? '';
339
344
  }
340
345
 
341
346
  /**
@@ -345,25 +350,25 @@ export class MollieToken extends Model {
345
350
  // Submit onboarding data
346
351
 
347
352
  if (organization.privateMeta.mollieOnboarding && organization.privateMeta.mollieOnboarding.status == MollieStatus.NeedsData) {
348
- await this.authRequest("POST", "/v2/onboarding/me", {
353
+ await this.authRequest('POST', '/v2/onboarding/me', {
349
354
  organization: {
350
355
  name: organization.name,
351
356
  address: {
352
- streetAndNumber: organization.address.street + " "+organization.address.number,
357
+ streetAndNumber: organization.address.street + ' ' + organization.address.number,
353
358
  postalCode: organization.address.postalCode,
354
359
  city: organization.address.city,
355
360
  country: organization.address.country,
356
361
  },
357
-
358
- vatRegulation: "shifted"
362
+
363
+ vatRegulation: 'shifted',
359
364
  },
360
365
  profile: {
361
- name: organization.name+" - Stamhoofd",
362
- //url: "https://"+organization.getHost(),
363
- description: "Betalen van inschrijvingsgelden of webshops voor een vereniging via Stamhoofd (partner).",
364
- categoryCode: 8398
365
- }
366
- })
366
+ name: organization.name + ' - Stamhoofd',
367
+ // url: "https://"+organization.getHost(),
368
+ description: 'Betalen van inschrijvingsgelden of webshops voor een vereniging via Stamhoofd (partner).',
369
+ categoryCode: 8398,
370
+ },
371
+ });
367
372
  }
368
373
  }
369
- }
374
+ }
@@ -1,13 +1,12 @@
1
+ import { column, Model } from '@simonbackx/simple-database';
2
+ import { AnyDecoder } from '@simonbackx/simple-encoding';
3
+ import basex from 'base-x';
4
+ import crypto from 'crypto';
1
5
 
2
- import { column, Model } from "@simonbackx/simple-database";
3
- import { AnyDecoder } from "@simonbackx/simple-encoding";
4
- import basex from "base-x";
5
- import crypto from "crypto";
6
+ import { Organization } from './Organization';
6
7
 
7
- import { Organization } from "./Organization";
8
-
9
- const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
10
- const bs58 = basex(ALPHABET)
8
+ const ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
9
+ const bs58 = basex(ALPHABET);
11
10
 
12
11
  async function randomBytes(size: number): Promise<Buffer> {
13
12
  return new Promise((resolve, reject) => {
@@ -22,57 +21,57 @@ async function randomBytes(size: number): Promise<Buffer> {
22
21
  }
23
22
 
24
23
  enum OneTimeTokenType {
25
- WebshopNotificationEmailVerification = "WebshopNotificationEmailVerification",
26
- WebshopNotificationEmailUnsubscribe = "WebshopNotificationEmailUnsubscribe"
24
+ WebshopNotificationEmailVerification = 'WebshopNotificationEmailVerification',
25
+ WebshopNotificationEmailUnsubscribe = 'WebshopNotificationEmailUnsubscribe',
27
26
  }
28
27
 
29
28
  /**
30
29
  * Token that saves some information and can execute an action if you have access to the token (e.g. in an email)
31
30
  */
32
31
  export class OneTimeToken extends Model {
33
- static table = "one_time_tokens";
34
-
32
+ static table = 'one_time_tokens';
33
+
35
34
  // Columns
36
- @column({ primary: true, type: "string" })
35
+ @column({ primary: true, type: 'string' })
37
36
  token: string;
38
37
 
39
- @column({ type: "string" })
38
+ @column({ type: 'string' })
40
39
  organizationId: string;
41
40
 
42
- @column({ type: "datetime", nullable: true })
41
+ @column({ type: 'datetime', nullable: true })
43
42
  validUntil: Date | null = null;
44
43
 
45
44
  @column({
46
- type: "datetime", beforeSave(old?: any) {
45
+ type: 'datetime', beforeSave(old?: any) {
47
46
  if (old !== undefined) {
48
47
  return old;
49
48
  }
50
- const date = new Date()
51
- date.setMilliseconds(0)
52
- return date
53
- }
49
+ const date = new Date();
50
+ date.setMilliseconds(0);
51
+ return date;
52
+ },
54
53
  })
55
- createdAt: Date
54
+ createdAt: Date;
56
55
 
57
56
  // Columns
58
- @column({ type: "string" })
59
- type: OneTimeTokenType
57
+ @column({ type: 'string' })
58
+ type: OneTimeTokenType;
60
59
 
61
60
  // Columns
62
- @column({ type: "json", decoder: AnyDecoder })
61
+ @column({ type: 'json', decoder: AnyDecoder })
63
62
  data: any = {};
64
63
 
65
64
  isExpired(): boolean {
66
- return !!this.validUntil && this.validUntil < new Date()
65
+ return !!this.validUntil && this.validUntil < new Date();
67
66
  }
68
-
67
+
69
68
  /**
70
69
  * Get a token
71
- * @param token
70
+ * @param token
72
71
  * @param ignoreExpireDate: do not return if it is expired
73
72
  */
74
73
  static async getToken(token: string, organizationId: string, ignoreExpireDate = false): Promise<OneTimeToken | undefined> {
75
- const [oneTimeToken] = await this.where({token, organizationId}, {limit: 1})
74
+ const [oneTimeToken] = await this.where({ token, organizationId }, { limit: 1 });
76
75
 
77
76
  if (!oneTimeToken) {
78
77
  return undefined;
@@ -80,7 +79,7 @@ export class OneTimeToken extends Model {
80
79
 
81
80
  if (!ignoreExpireDate && oneTimeToken.isExpired()) {
82
81
  // If the refresh token is invalid, do not return it
83
- return undefined
82
+ return undefined;
84
83
  }
85
84
 
86
85
  return oneTimeToken;
@@ -89,16 +88,17 @@ export class OneTimeToken extends Model {
89
88
  /***
90
89
  * Create a token without saving it
91
90
  */
92
- static async createToken(organizationId: string, type: OneTimeTokenType, data: any, options?: {validUntil?: Date, expireIn?: number}): Promise<OneTimeToken> {
91
+ static async createToken(organizationId: string, type: OneTimeTokenType, data: any, options?: { validUntil?: Date; expireIn?: number }): Promise<OneTimeToken> {
93
92
  const token = new OneTimeToken();
94
93
  token.type = type;
95
94
  token.data = data;
96
- token.organizationId = organizationId
95
+ token.organizationId = organizationId;
97
96
 
98
97
  if (options?.validUntil) {
99
- token.validUntil = new Date(options?.validUntil)
98
+ token.validUntil = new Date(options?.validUntil);
100
99
  token.validUntil.setMilliseconds(0);
101
- } else if (options?.expireIn) {
100
+ }
101
+ else if (options?.expireIn) {
102
102
  token.validUntil = new Date();
103
103
  token.validUntil.setTime(token.validUntil.getTime() + options?.expireIn);
104
104
  token.validUntil.setMilliseconds(0);
@@ -117,15 +117,16 @@ export class OneTimeToken extends Model {
117
117
 
118
118
  let host: string;
119
119
  if (dashboard) {
120
- host = "https://"+(STAMHOOFD.domains.dashboard ?? "stamhoofd.app")+"/"+i18n.locale
121
- } else {
122
- host = "https://"+organization.getHost()
120
+ host = 'https://' + (STAMHOOFD.domains.dashboard ?? 'stamhoofd.app') + '/' + i18n.locale;
121
+ }
122
+ else {
123
+ host = 'https://' + organization.getHost();
123
124
 
124
- if (i18n.language != organization.i18n.language) {
125
- host += "/"+i18n.language
125
+ if (i18n.language !== organization.i18n.language) {
126
+ host += '/' + i18n.language;
126
127
  }
127
128
  }
128
129
 
129
- return host+"/ott"+(dashboard ? "/"+encodeURIComponent(organization.id) : "")+"?token="+encodeURIComponent(this.token);
130
+ return host + '/ott' + (dashboard ? '/' + encodeURIComponent(organization.id) : '') + '?token=' + encodeURIComponent(this.token);
130
131
  }
131
132
  }