@mjhls/mjh-framework 1.0.850-affiliatefix-v1 → 1.0.850-beta.1

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 (318) hide show
  1. package/README.md +168 -168
  2. package/dist/cjs/AD.js +9 -10
  3. package/dist/cjs/AD300x250.js +30 -31
  4. package/dist/cjs/AD300x250x600.js +30 -31
  5. package/dist/cjs/AD728x90.js +33 -34
  6. package/dist/cjs/ADFloatingFooter.js +32 -33
  7. package/dist/cjs/ADFooter.js +14 -15
  8. package/dist/cjs/ADGutter.js +32 -33
  9. package/dist/cjs/{ADInfeed-859820d9.js → ADInfeed-98c71bcd.js} +13 -15
  10. package/dist/cjs/ADSkyscraper.js +32 -33
  11. package/dist/cjs/ADSponsoredResources.js +32 -33
  12. package/dist/cjs/ADWebcast.js +32 -33
  13. package/dist/cjs/ADWelcome.js +33 -34
  14. package/dist/cjs/{ADlgInfeed-da3a36a6.js → ADlgInfeed-9de32585.js} +10 -11
  15. package/dist/cjs/AccordionPanel.js +29 -31
  16. package/dist/cjs/AdSlot.js +101 -34
  17. package/dist/cjs/AdSlotsProvider.js +33 -25
  18. package/dist/cjs/AlgoliaSearch.js +1080 -1076
  19. package/dist/cjs/AlphabeticList.js +25 -26
  20. package/dist/cjs/ArticleCarousel.js +23 -24
  21. package/dist/cjs/ArticleProgramLandingPage.js +58 -60
  22. package/dist/cjs/ArticleSeriesLandingPage.js +40 -41
  23. package/dist/cjs/ArticleSeriesListing.js +61 -62
  24. package/dist/cjs/AuthWrapper.js +423 -1739
  25. package/dist/cjs/{AuthorComponent-c21aac7f.js → AuthorComponent-bb831b74.js} +13 -14
  26. package/dist/cjs/Beam.js +8 -8
  27. package/dist/cjs/{BlockContent-36e54d77.js → BlockContent-091a991f.js} +55 -56
  28. package/dist/cjs/Breadcrumbs.js +27 -29
  29. package/dist/cjs/CMEDeck.js +83 -83
  30. package/dist/cjs/Column1.js +11 -14
  31. package/dist/cjs/Column2.js +33 -36
  32. package/dist/cjs/Column3.js +59 -62
  33. package/dist/cjs/ConferenceArticleCard.js +37 -38
  34. package/dist/cjs/ConferenceBanner-4a16fddc.js +23 -0
  35. package/dist/cjs/DeckContent.js +103 -107
  36. package/dist/cjs/DeckQueue.js +90 -94
  37. package/dist/cjs/{Dfp-93399f8c.js → Dfp-26baccf1.js} +34 -35
  38. package/dist/cjs/EventsDeck.js +152 -159
  39. package/dist/cjs/ExternalResources.js +79 -81
  40. package/dist/cjs/Feature.js +24 -26
  41. package/dist/cjs/ForbesHero.js +42 -43
  42. package/dist/cjs/GridContent.js +304 -190
  43. package/dist/cjs/GridHero.js +44 -45
  44. package/dist/cjs/GroupDeck.js +59 -60
  45. package/dist/cjs/HamMagazine.js +141 -146
  46. package/dist/cjs/Header.js +12 -14
  47. package/dist/cjs/Hero.js +12 -13
  48. package/dist/cjs/HighlightenVideo.js +17 -18
  49. package/dist/cjs/HorizontalArticleListing.js +71 -73
  50. package/dist/cjs/HorizontalHero.js +25 -26
  51. package/dist/cjs/IssueContentDeck.js +73 -78
  52. package/dist/cjs/IssueDeck.js +72 -77
  53. package/dist/cjs/IssueLanding.js +92 -96
  54. package/dist/cjs/KMTracker.js +15 -15
  55. package/dist/cjs/LeftNav.js +39 -41
  56. package/dist/cjs/MasterDeck.js +80 -81
  57. package/dist/cjs/MediaSeriesLanding.js +1138 -1230
  58. package/dist/cjs/NavDvm.js +74 -79
  59. package/dist/cjs/{NavFooter-3dcd99a8.js → NavFooter-76c913e3.js} +14 -15
  60. package/dist/cjs/NavMagazine.js +148 -153
  61. package/dist/cjs/NavNative.js +145 -153
  62. package/dist/cjs/OncliveHero.js +19 -19
  63. package/dist/cjs/OncliveLargeHero.js +72 -73
  64. package/dist/cjs/PageFilter.js +14 -15
  65. package/dist/cjs/PartnerDetailListing.js +106 -115
  66. package/dist/cjs/PdfDownload.js +9 -10
  67. package/dist/cjs/PopUpModal.js +19 -21
  68. package/dist/cjs/PubSection.js +40 -43
  69. package/dist/cjs/PubToc.js +15 -16
  70. package/dist/cjs/PublicationDeck.js +62 -67
  71. package/dist/cjs/PublicationLanding.js +135 -139
  72. package/dist/cjs/QueueDeckExpanded.js +2172 -1167
  73. package/dist/cjs/RecentNews.js +22 -23
  74. package/dist/cjs/RelatedContent.js +54 -55
  75. package/dist/cjs/RelatedTopicsDropdown.js +29 -32
  76. package/dist/cjs/RolesDeck.js +27 -32
  77. package/dist/cjs/Search.js +18 -22
  78. package/dist/cjs/Segment.js +368 -343
  79. package/dist/cjs/SeriesListingDeck.js +38 -38
  80. package/dist/cjs/{SeriesSlider-34c6cc2b.js → SeriesSlider-8bbc989f.js} +39 -40
  81. package/dist/cjs/SetCookie.js +1 -1
  82. package/dist/cjs/SideFooter.js +38 -39
  83. package/dist/cjs/SocialIcons.js +9 -10
  84. package/dist/cjs/{SocialSearchComponent-948138c7.js → SocialSearchComponent-cea213aa.js} +36 -40
  85. package/dist/cjs/SocialShare.js +29 -31
  86. package/dist/cjs/TaxonomyCard.js +59 -64
  87. package/dist/cjs/TaxonomyDescription.js +54 -56
  88. package/dist/cjs/TemplateNormal.js +74 -75
  89. package/dist/cjs/ThumbnailCard.js +21 -23
  90. package/dist/cjs/Ustream.js +30 -31
  91. package/dist/cjs/VerticalHero.js +16 -17
  92. package/dist/cjs/VideoProgramLandingPage.js +73 -78
  93. package/dist/cjs/VideoSeriesCard.js +33 -34
  94. package/dist/cjs/VideoSeriesFilter.js +18 -18
  95. package/dist/cjs/VideoSeriesLandingPage.js +50 -51
  96. package/dist/cjs/VideoSeriesListing.js +82 -81
  97. package/dist/cjs/View.js +342 -266
  98. package/dist/cjs/YahooHero.js +41 -42
  99. package/dist/cjs/YoutubeGroup.js +66 -67
  100. package/dist/cjs/{_is-array-6128bd56.js → _is-array-754e012d.js} +6 -6
  101. package/dist/cjs/{_iter-detect-55a5657a.js → _iter-detect-60b2f026.js} +8 -8
  102. package/dist/cjs/{_object-pie-083f2dd6.js → _object-pie-68c5bcbc.js} +4 -4
  103. package/dist/cjs/{_object-sap-a175b4a9.js → _object-sap-5e74ba08.js} +1 -1
  104. package/dist/cjs/{_object-to-array-8fe5a54f.js → _object-to-array-5762f850.js} +2 -2
  105. package/dist/cjs/{_to-object-6de10e57.js → _to-object-329a650b.js} +8 -8
  106. package/dist/cjs/{asyncToGenerator-58c289d9.js → asyncToGenerator-140e5f89.js} +32 -32
  107. package/dist/cjs/{brightcove-react-player-loader.es-a195642e.js → brightcove-react-player-loader.es-156bd4d6.js} +9 -11
  108. package/dist/cjs/{core.get-iterator-method-f474eacc.js → core.get-iterator-method-f62321d4.js} +2 -2
  109. package/dist/cjs/{debounce-d4a2369b.js → debounce-529c8d06.js} +2 -2
  110. package/dist/cjs/{define-property-c88be878.js → define-property-f4d12f4e.js} +6 -6
  111. package/dist/cjs/{defineProperty-0cb76d99.js → defineProperty-55548b25.js} +1 -1
  112. package/dist/cjs/{entities-3f9d0f2f.js → entities-310b46ee.js} +1 -1
  113. package/dist/cjs/{eq-5fc26c07.js → eq-bb2843ed.js} +1 -1
  114. package/dist/cjs/{es6.string.iterator-c2573ffd.js → es6.string.iterator-cc0bbaa4.js} +6 -6
  115. package/dist/cjs/{extends-29bdbc6d.js → extends-0a918631.js} +7 -7
  116. package/dist/cjs/faundadb.js +327 -10
  117. package/dist/cjs/{get-5839e5b5.js → get-adbb11e3.js} +21 -21
  118. package/dist/cjs/getQuery.js +2 -2
  119. package/dist/cjs/getRelatedArticle.js +28 -445
  120. package/dist/cjs/getRootDocGroup.js +6 -6
  121. package/dist/cjs/getSerializers.js +44 -45
  122. package/dist/cjs/{getTargeting-be6168ad.js → getTargeting-f1821260.js} +26 -17
  123. package/dist/cjs/getTargeting.js +8 -8
  124. package/dist/{esm/iconBase-ccc56b97.js → cjs/iconBase-68959171.js} +8 -2
  125. package/dist/cjs/{index-f86bb269.js → index-3294d3bc.js} +45 -44
  126. package/dist/cjs/{index-060c5d65.js → index-4151deb3.js} +1615 -1009
  127. package/dist/cjs/{index-eadd5035.js → index-96b3db50.js} +15 -17
  128. package/dist/cjs/{index-fc2f1ca2.js → index-98e01cb9.js} +12 -13
  129. package/dist/cjs/{index-efca863c.js → index-be0c82be.js} +30 -36
  130. package/dist/cjs/{index-50be6759.js → index-e2e62963.js} +10 -26
  131. package/dist/cjs/{index.es-f3e47207.js → index.es-9110add6.js} +12 -31
  132. package/dist/cjs/{index.esm-2bb721c8.js → index.esm-4d410430.js} +21 -21
  133. package/dist/cjs/{index.esm-00a6aade.js → index.esm-90433435.js} +16 -7
  134. package/dist/cjs/{index.esm-c1e16606.js → index.esm-e32d3e8e.js} +7 -4
  135. package/dist/cjs/{index.esm-f27f80d9.js → index.esm-ff47db6f.js} +13 -6
  136. package/dist/cjs/index.js +158 -170
  137. package/dist/cjs/{inherits-c2065b95.js → inherits-9953db94.js} +22 -22
  138. package/dist/cjs/{isSymbol-03abbdf0.js → isSymbol-04666465.js} +15 -15
  139. package/dist/cjs/keys-a586b7a0.js +25 -0
  140. package/dist/cjs/{lodash-f0783643.js → lodash-fc2922d0.js} +31 -128
  141. package/dist/cjs/main-02daeefe.js +862 -0
  142. package/dist/cjs/{moment-aca40de1.js → moment-575fe24c.js} +9 -11
  143. package/dist/cjs/{react-social-icons-af932527.js → react-social-icons-f7f48f71.js} +27 -28
  144. package/dist/cjs/{slicedToArray-5d1bc3b3.js → slicedToArray-8f385299.js} +14 -14
  145. package/dist/cjs/{smoothscroll-99df7f93.js → smoothscroll-5054361f.js} +1 -1
  146. package/dist/cjs/stringify-7c5aff47.js +17 -0
  147. package/dist/cjs/timeDifferenceCalc.js +1 -1
  148. package/dist/cjs/{toConsumableArray-ddb70795.js → toConsumableArray-9a3476fe.js} +9 -9
  149. package/dist/cjs/{toNumber-5e1fac58.js → toNumber-36d1e7e5.js} +5 -40
  150. package/dist/cjs/{typeof-88a668c5.js → typeof-725500bc.js} +36 -36
  151. package/dist/cjs/urlFor.js +3 -3
  152. package/dist/cjs/{ustream-api-b2b9092f.js → ustream-api-d092dc31.js} +4 -4
  153. package/dist/cjs/{visibility-sensor-eb2c5b69.js → visibility-sensor-ad5e3116.js} +5 -7
  154. package/dist/cjs/{web.dom.iterable-46657b5c.js → web.dom.iterable-a0e279c1.js} +3 -3
  155. package/dist/esm/AD.js +1 -1
  156. package/dist/esm/AD300x250.js +24 -24
  157. package/dist/esm/AD300x250x600.js +24 -24
  158. package/dist/esm/AD728x90.js +27 -27
  159. package/dist/esm/ADFloatingFooter.js +23 -23
  160. package/dist/esm/ADFooter.js +6 -6
  161. package/dist/esm/ADGutter.js +23 -23
  162. package/dist/esm/{ADInfeed-4bf3b2f9.js → ADInfeed-bbdd5398.js} +6 -6
  163. package/dist/esm/ADSkyscraper.js +23 -23
  164. package/dist/esm/ADSponsoredResources.js +23 -23
  165. package/dist/esm/ADWebcast.js +23 -23
  166. package/dist/esm/ADWelcome.js +20 -20
  167. package/dist/esm/{ADlgInfeed-a3377c4a.js → ADlgInfeed-4473ee3b.js} +4 -4
  168. package/dist/esm/AccordionPanel.js +8 -8
  169. package/dist/esm/AdSlot.js +92 -24
  170. package/dist/esm/AdSlotsProvider.js +27 -17
  171. package/dist/esm/AlgoliaSearch.js +530 -525
  172. package/dist/esm/AlphabeticList.js +10 -10
  173. package/dist/esm/ArticleCarousel.js +17 -17
  174. package/dist/esm/ArticleProgramLandingPage.js +49 -50
  175. package/dist/esm/ArticleSeriesLandingPage.js +32 -32
  176. package/dist/esm/ArticleSeriesListing.js +34 -34
  177. package/dist/esm/AuthWrapper.js +396 -1711
  178. package/dist/esm/{AuthorComponent-30aeba69.js → AuthorComponent-34b16174.js} +1 -1
  179. package/dist/esm/Beam.js +8 -8
  180. package/dist/esm/{BlockContent-c99c9a8d.js → BlockContent-e9b4ddcf.js} +34 -34
  181. package/dist/esm/Breadcrumbs.js +7 -7
  182. package/dist/esm/CMEDeck.js +24 -24
  183. package/dist/esm/Column1.js +4 -4
  184. package/dist/esm/Column2.js +21 -21
  185. package/dist/esm/Column3.js +39 -39
  186. package/dist/esm/ConferenceArticleCard.js +22 -22
  187. package/dist/esm/DeckContent.js +57 -57
  188. package/dist/esm/DeckQueue.js +50 -50
  189. package/dist/esm/{Dfp-2c43d2a0.js → Dfp-b7236041.js} +15 -15
  190. package/dist/esm/EventsDeck.js +67 -67
  191. package/dist/esm/ExternalResources.js +47 -48
  192. package/dist/esm/Feature.js +4 -4
  193. package/dist/esm/ForbesHero.js +12 -12
  194. package/dist/esm/GridContent.js +200 -82
  195. package/dist/esm/GridHero.js +13 -13
  196. package/dist/esm/GroupDeck.js +14 -14
  197. package/dist/esm/HamMagazine.js +39 -39
  198. package/dist/esm/Hero.js +4 -4
  199. package/dist/esm/HighlightenVideo.js +2 -2
  200. package/dist/esm/HorizontalArticleListing.js +46 -47
  201. package/dist/esm/HorizontalHero.js +5 -5
  202. package/dist/esm/IssueContentDeck.js +27 -27
  203. package/dist/esm/IssueDeck.js +37 -37
  204. package/dist/esm/IssueLanding.js +81 -84
  205. package/dist/esm/KMTracker.js +15 -15
  206. package/dist/esm/LeftNav.js +22 -22
  207. package/dist/esm/MasterDeck.js +45 -45
  208. package/dist/esm/MediaSeriesLanding.js +662 -751
  209. package/dist/esm/NavDvm.js +16 -16
  210. package/dist/esm/NavMagazine.js +44 -44
  211. package/dist/esm/NavNative.js +49 -49
  212. package/dist/esm/OncliveHero.js +5 -4
  213. package/dist/esm/OncliveLargeHero.js +13 -13
  214. package/dist/esm/PageFilter.js +6 -6
  215. package/dist/esm/PartnerDetailListing.js +55 -63
  216. package/dist/esm/PdfDownload.js +2 -2
  217. package/dist/esm/PopUpModal.js +6 -6
  218. package/dist/esm/PubSection.js +32 -34
  219. package/dist/esm/PubToc.js +8 -8
  220. package/dist/esm/PublicationDeck.js +24 -24
  221. package/dist/esm/PublicationLanding.js +76 -76
  222. package/dist/esm/QueueDeckExpanded.js +2102 -1097
  223. package/dist/esm/RecentNews.js +4 -4
  224. package/dist/esm/RelatedContent.js +35 -35
  225. package/dist/esm/RelatedTopicsDropdown.js +10 -10
  226. package/dist/esm/RolesDeck.js +12 -12
  227. package/dist/esm/Search.js +8 -8
  228. package/dist/esm/Segment.js +368 -343
  229. package/dist/esm/SeriesListingDeck.js +20 -20
  230. package/dist/esm/{SeriesSlider-5d5c08f4.js → SeriesSlider-a866bb21.js} +14 -14
  231. package/dist/esm/SetCookie.js +1 -1
  232. package/dist/esm/SideFooter.js +17 -17
  233. package/dist/esm/{SocialSearchComponent-db963c3e.js → SocialSearchComponent-03c3e869.js} +12 -12
  234. package/dist/esm/TaxonomyCard.js +25 -25
  235. package/dist/esm/TaxonomyDescription.js +45 -46
  236. package/dist/esm/TemplateNormal.js +50 -50
  237. package/dist/esm/ThumbnailCard.js +7 -7
  238. package/dist/esm/Ustream.js +14 -14
  239. package/dist/esm/VerticalHero.js +3 -3
  240. package/dist/esm/VideoProgramLandingPage.js +53 -54
  241. package/dist/esm/VideoSeriesCard.js +14 -14
  242. package/dist/esm/VideoSeriesFilter.js +9 -9
  243. package/dist/esm/VideoSeriesLandingPage.js +38 -38
  244. package/dist/esm/VideoSeriesListing.js +39 -37
  245. package/dist/esm/View.js +173 -93
  246. package/dist/esm/YahooHero.js +15 -15
  247. package/dist/esm/YoutubeGroup.js +26 -26
  248. package/dist/esm/{_is-array-3e99e06e.js → _is-array-58e95429.js} +6 -6
  249. package/dist/esm/{_iter-detect-7e5e5ce2.js → _iter-detect-5d49a330.js} +8 -8
  250. package/dist/esm/{_object-pie-133f504a.js → _object-pie-33c40e79.js} +4 -4
  251. package/dist/esm/{_object-sap-f353c2a9.js → _object-sap-964b6feb.js} +1 -1
  252. package/dist/esm/{_object-to-array-0f197f89.js → _object-to-array-7e804fce.js} +2 -2
  253. package/dist/esm/{_to-object-b50e61c3.js → _to-object-a4107da3.js} +9 -9
  254. package/dist/esm/{asyncToGenerator-7f8f9219.js → asyncToGenerator-4877b617.js} +33 -33
  255. package/dist/esm/{brightcove-react-player-loader.es-57a70a56.js → brightcove-react-player-loader.es-83f53e4e.js} +4 -5
  256. package/dist/esm/{core.get-iterator-method-133dfacd.js → core.get-iterator-method-e1de7503.js} +2 -2
  257. package/dist/esm/{debounce-533d9748.js → debounce-9207d8ee.js} +2 -2
  258. package/dist/esm/{define-property-fe54dc9f.js → define-property-8af5f002.js} +6 -6
  259. package/dist/esm/{defineProperty-f5ff6f5a.js → defineProperty-94fd8bfc.js} +1 -1
  260. package/dist/esm/{entities-932b50cf.js → entities-7cc3bf45.js} +1 -1
  261. package/dist/esm/{eq-bdcbf886.js → eq-b470f743.js} +1 -1
  262. package/dist/esm/{es6.string.iterator-bc33758b.js → es6.string.iterator-c990c18c.js} +7 -7
  263. package/dist/esm/{extends-60e0e1c6.js → extends-6f2fcc99.js} +7 -7
  264. package/dist/esm/faundadb.js +325 -8
  265. package/dist/esm/{get-3c308da4.js → get-1e515072.js} +21 -21
  266. package/dist/esm/getQuery.js +2 -2
  267. package/dist/esm/getRelatedArticle.js +28 -445
  268. package/dist/esm/getRootDocGroup.js +6 -6
  269. package/dist/esm/getSerializers.js +44 -45
  270. package/dist/esm/{getTargeting-68291ce9.js → getTargeting-bd800589.js} +25 -16
  271. package/dist/esm/getTargeting.js +8 -8
  272. package/dist/{cjs/iconBase-be4097c0.js → esm/iconBase-602d52fe.js} +8 -33
  273. package/dist/esm/{index-f0fc23eb.js → index-41a678ea.js} +4 -4
  274. package/dist/esm/{index-755f2cc2.js → index-5f7e79e7.js} +6 -6
  275. package/dist/esm/{index-0dbff1d1.js → index-73819142.js} +30 -36
  276. package/dist/esm/{index-98ca9cec.js → index-aaa2dae0.js} +11 -26
  277. package/dist/esm/{index-01d53c17.js → index-d6dc592a.js} +1261 -648
  278. package/dist/esm/{index-79cfd25c.js → index-ef6d5dcf.js} +45 -44
  279. package/dist/esm/{index.es-a6137319.js → index.es-29c1cef5.js} +5 -23
  280. package/dist/esm/{index.esm-f6156a57.js → index.esm-29e48d38.js} +16 -7
  281. package/dist/esm/{index.esm-d4932dea.js → index.esm-cf08bf18.js} +13 -6
  282. package/dist/esm/{index.esm-9b042655.js → index.esm-f8aaeeeb.js} +7 -4
  283. package/dist/esm/{index.esm-37268dca.js → index.esm-fd746768.js} +5 -4
  284. package/dist/esm/index.js +117 -125
  285. package/dist/esm/{inherits-a41fe93f.js → inherits-cf8dde54.js} +19 -19
  286. package/dist/esm/{isSymbol-a7e9aafe.js → isSymbol-1981418f.js} +15 -15
  287. package/dist/esm/{keys-7a3adabf.js → keys-8eda7a5c.js} +6 -6
  288. package/dist/esm/{lodash-f97fd99a.js → lodash-17fdfebb.js} +31 -128
  289. package/dist/esm/main-e4a934b2.js +851 -0
  290. package/dist/esm/{moment-bc12cb97.js → moment-e2f9b20c.js} +9 -11
  291. package/dist/esm/{react-social-icons-9be47857.js → react-social-icons-a7d5c5c7.js} +16 -16
  292. package/dist/esm/{slicedToArray-be2f7a22.js → slicedToArray-641f241f.js} +14 -14
  293. package/dist/esm/{smoothscroll-fa4e3f8c.js → smoothscroll-0cd4c7a6.js} +1 -1
  294. package/dist/esm/stringify-4330ccdc.js +15 -0
  295. package/dist/esm/timeDifferenceCalc.js +1 -1
  296. package/dist/esm/{toConsumableArray-6d9a4616.js → toConsumableArray-43aa614d.js} +9 -9
  297. package/dist/esm/{toNumber-5aeba6e7.js → toNumber-2f7a84cd.js} +5 -40
  298. package/dist/esm/{typeof-a286cf0c.js → typeof-6435ba1c.js} +36 -36
  299. package/dist/esm/urlFor.js +1 -1
  300. package/dist/esm/{ustream-api-33a866b6.js → ustream-api-9a50644d.js} +4 -4
  301. package/dist/esm/{web.dom.iterable-4109ff68.js → web.dom.iterable-4439f05a.js} +3 -3
  302. package/package.json +116 -110
  303. package/dist/cjs/Auth.js +0 -3652
  304. package/dist/cjs/ConferenceBanner-6c9e718a.js +0 -24
  305. package/dist/cjs/index-bd6c9f56.js +0 -211
  306. package/dist/cjs/keys-7f2c2108.js +0 -25
  307. package/dist/cjs/main-f1c77adb.js +0 -973
  308. package/dist/cjs/md5-e1ca5797.js +0 -323
  309. package/dist/cjs/stringify-c9ac1214.js +0 -17
  310. package/dist/cjs/typeof-1358762e.js +0 -33
  311. package/dist/cjs/util-6f784d85.js +0 -576
  312. package/dist/esm/Auth.js +0 -3632
  313. package/dist/esm/index-db3bb315.js +0 -207
  314. package/dist/esm/main-d4165069.js +0 -961
  315. package/dist/esm/md5-4e42248e.js +0 -321
  316. package/dist/esm/stringify-59c8f690.js +0 -15
  317. package/dist/esm/typeof-2f07d0e8.js +0 -30
  318. package/dist/esm/util-3ab476bf.js +0 -574
package/dist/esm/Auth.js DELETED
@@ -1,3632 +0,0 @@
1
- import { a as _asyncToGenerator, r as regenerator } from './asyncToGenerator-7f8f9219.js';
2
- import { _ as _JSON$stringify } from './stringify-59c8f690.js';
3
- import { _ as _slicedToArray, a as _getIterator } from './slicedToArray-be2f7a22.js';
4
- import React__default, { useEffect, useState } from 'react';
5
- import Router from 'next/router';
6
- import { _ as _extends } from './extends-60e0e1c6.js';
7
- import { Col, Form, Button, Spinner } from 'react-bootstrap';
8
- import useSWR from 'swr';
9
- import { s as serialize_1, p as parse_1 } from './index-db3bb315.js';
10
- import Local from 'passport-local';
11
- import mysql from 'mysql';
12
- import { u as util } from './util-3ab476bf.js';
13
- import { c as createCommonjsModule } from './_commonjsHelpers-0c4b6f40.js';
14
- import { m as md5 } from './md5-4e42248e.js';
15
- import './es6.string.iterator-bc33758b.js';
16
- import './_to-object-b50e61c3.js';
17
- import './web.dom.iterable-4109ff68.js';
18
- import './_library-528f1934.js';
19
- import './core.get-iterator-method-133dfacd.js';
20
- import './_iter-detect-7e5e5ce2.js';
21
- import './_object-pie-133f504a.js';
22
-
23
- var returnFormField = function returnFormField(_ref) {
24
- var name = _ref.name,
25
- label = _ref.label,
26
- type = _ref.type,
27
- _ref$required = _ref.required,
28
- required = _ref$required === undefined ? false : _ref$required,
29
- _ref$readonly = _ref.readonly,
30
- readonly = _ref$readonly === undefined ? false : _ref$readonly,
31
- _ref$options = _ref.options,
32
- options = _ref$options === undefined ? null : _ref$options,
33
- _ref$groupType = _ref.groupType,
34
- groupType = _ref$groupType === undefined ? '' : _ref$groupType,
35
- _ref$errors = _ref.errors,
36
- errors = _ref$errors === undefined ? {} : _ref$errors,
37
- _ref$handleChanged = _ref.handleChanged,
38
- handleChanged = _ref$handleChanged === undefined ? null : _ref$handleChanged,
39
- _ref$default_value = _ref.default_value,
40
- default_value = _ref$default_value === undefined ? null : _ref$default_value;
41
-
42
- var opts = [];
43
- if (groupType) {
44
- opts['as'] = groupType;
45
- if (groupType === Col) {
46
- opts['xs'] = 12;
47
- opts['md'] = 6;
48
- }
49
- }
50
-
51
- if (handleChanged) {
52
- opts['onChange'] = handleChanged;
53
- }
54
-
55
- if (readonly) {
56
- opts['readOnly'] = readonly;
57
- }
58
-
59
- if (type == 'text' || type == 'email' || type == 'password' || type == 'number') {
60
- return React__default.createElement(
61
- Form.Group,
62
- _extends({}, opts, { controlId: name }),
63
- React__default.createElement(
64
- Form.Label,
65
- { kye: name + '_label' },
66
- label,
67
- required && React__default.createElement(
68
- 'span',
69
- { style: { color: 'red' } },
70
- '*'
71
- )
72
- ),
73
- React__default.createElement(Form.Control, { key: name + '_' + type, type: type, readOnly: readonly, name: name, placeholder: '', defaultValue: default_value, required: required }),
74
- React__default.createElement(
75
- Form.Control.Feedback,
76
- { key: name + '_feedback', type: 'invalid' },
77
- errors[name]
78
- )
79
- );
80
- }
81
- if (type == 'select') {
82
- return React__default.createElement(
83
- Form.Group,
84
- _extends({}, opts, { key: name, controlId: name }),
85
- React__default.createElement(
86
- Form.Label,
87
- { key: name + '_' + label },
88
- label,
89
- required && React__default.createElement(
90
- 'span',
91
- { key: name + '_required_span', style: { color: 'red' } },
92
- '*'
93
- )
94
- ),
95
- React__default.createElement(
96
- Form.Control,
97
- { key: name + '_select', as: 'select', name: name, required: required, defaultValue: default_value },
98
- React__default.createElement('option', { value: '', key: name + '_options_empty' }),
99
- options.map(function (option, index) {
100
- var value = option.value ? option.value : option;
101
- var label = option.label ? option.label : option;
102
- var key = name + '_options_' + index;
103
- return React__default.createElement(
104
- 'option',
105
- { key: key, value: value },
106
- label
107
- );
108
- })
109
- )
110
- );
111
- }
112
-
113
- if (type == 'radio' || type == 'checkbox') {
114
- return React__default.createElement(
115
- Form.Group,
116
- opts,
117
- React__default.createElement(
118
- Form.Label,
119
- null,
120
- label,
121
- required && React__default.createElement(
122
- 'span',
123
- { style: { color: 'red' } },
124
- '*'
125
- )
126
- ),
127
- options.map(function (option, index) {
128
- return React__default.createElement(
129
- Form.Check,
130
- { type: type, key: index, required: required },
131
- React__default.createElement(Form.Check.Input, { type: type, key: type + '_' + index + '_input', defaultChecked: default_value ? default_value === option.value : false, name: name, id: name + '_' + index, value: option.value, required: required }),
132
- React__default.createElement(Form.Check.Label, { style: { cursor: 'pointer' }, 'for': name + '_' + index, key: type + '_' + index + '_label', dangerouslySetInnerHTML: { __html: option.label } })
133
- );
134
- })
135
- );
136
- }
137
- };
138
-
139
- var _this$4 = undefined;
140
-
141
- var dataHandler = function () {
142
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(api_url, body) {
143
- var res, result;
144
- return regenerator.wrap(function _callee$(_context) {
145
- while (1) {
146
- switch (_context.prev = _context.next) {
147
- case 0:
148
- _context.prev = 0;
149
- _context.next = 3;
150
- return fetch(api_url, {
151
- method: 'POST',
152
- headers: { 'Content-Type': 'application/json' },
153
- body: _JSON$stringify(body)
154
- });
155
-
156
- case 3:
157
- res = _context.sent;
158
-
159
- if (!(res.status === 200)) {
160
- _context.next = 13;
161
- break;
162
- }
163
-
164
- _context.next = 7;
165
- return res.json();
166
-
167
- case 7:
168
- result = _context.sent;
169
-
170
- if (!result.error) {
171
- _context.next = 10;
172
- break;
173
- }
174
-
175
- throw new Error(result.error);
176
-
177
- case 10:
178
- return _context.abrupt('return', result.data);
179
-
180
- case 13:
181
- _context.t0 = Error;
182
- _context.next = 16;
183
- return res.text();
184
-
185
- case 16:
186
- _context.t1 = _context.sent;
187
- throw new _context.t0(_context.t1);
188
-
189
- case 18:
190
- _context.next = 24;
191
- break;
192
-
193
- case 20:
194
- _context.prev = 20;
195
- _context.t2 = _context['catch'](0);
196
-
197
- console.error('data handler failed : ' + api_url, _context.t2);
198
- return _context.abrupt('return', null);
199
-
200
- case 24:
201
- case 'end':
202
- return _context.stop();
203
- }
204
- }
205
- }, _callee, _this$4, [[0, 20]]);
206
- }));
207
-
208
- return function dataHandler(_x, _x2) {
209
- return _ref.apply(this, arguments);
210
- };
211
- }();
212
-
213
- function useUser() {
214
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
215
- redirectTo = _ref.redirectTo,
216
- redirectIfFound = _ref.redirectIfFound;
217
-
218
- var _useSWR = useSWR('/api/auth/user', dataHandler),
219
- data = _useSWR.data,
220
- error = _useSWR.error;
221
-
222
- var user = data;
223
- var finished = Boolean(data);
224
- var hasUser = Boolean(user);
225
-
226
- useEffect(function () {
227
- if (!redirectTo || !finished) return;
228
- if (
229
- // If redirectTo is set, redirect if the user was not found.
230
- redirectTo && !redirectIfFound && !hasUser ||
231
- // If redirectIfFound is also set, redirect if the user was found
232
- redirectIfFound && hasUser) {
233
- Router.push(redirectTo);
234
- }
235
- }, [redirectTo, redirectIfFound, finished, hasUser]);
236
-
237
- return error ? null : user;
238
- }
239
-
240
- var hooks = /*#__PURE__*/Object.freeze({
241
- __proto__: null,
242
- useUser: useUser
243
- });
244
-
245
- var LoginForm = function LoginForm(props) {
246
- var handleSubmit = function () {
247
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(e) {
248
- var body, res;
249
- return regenerator.wrap(function _callee$(_context) {
250
- while (1) {
251
- switch (_context.prev = _context.next) {
252
- case 0:
253
- event.preventDefault();
254
-
255
- if (errorMsg) setErrorMsg('');
256
- setLoading(true);
257
-
258
- body = {
259
- email: e.currentTarget.email.value,
260
- password: e.currentTarget.password.value
261
- };
262
- _context.prev = 4;
263
- _context.next = 7;
264
- return fetch('/api/auth/login', {
265
- method: 'POST',
266
- headers: { 'Content-Type': 'application/json' },
267
- body: _JSON$stringify(body)
268
- });
269
-
270
- case 7:
271
- res = _context.sent;
272
-
273
- setLoading(false);
274
-
275
- if (!(res.status === 200)) {
276
- _context.next = 13;
277
- break;
278
- }
279
-
280
- // here, Router.push() does not carry new cookie value.
281
- // so need hard redirect
282
- window.location.href = callbackUrl;
283
- _context.next = 18;
284
- break;
285
-
286
- case 13:
287
- _context.t0 = Error;
288
- _context.next = 16;
289
- return res.text();
290
-
291
- case 16:
292
- _context.t1 = _context.sent;
293
- throw new _context.t0(_context.t1);
294
-
295
- case 18:
296
- _context.next = 23;
297
- break;
298
-
299
- case 20:
300
- _context.prev = 20;
301
- _context.t2 = _context['catch'](4);
302
-
303
- setErrorMsg(_context.t2.message);
304
-
305
- case 23:
306
- case 'end':
307
- return _context.stop();
308
- }
309
- }
310
- }, _callee, this, [[4, 20]]);
311
- }));
312
-
313
- return function handleSubmit(_x) {
314
- return _ref.apply(this, arguments);
315
- };
316
- }();
317
-
318
- var _props$callbackUrl = props.callbackUrl,
319
- callbackUrl = _props$callbackUrl === undefined ? '/' : _props$callbackUrl;
320
-
321
-
322
- useEffect(function () {
323
- if (props.user) {
324
- window.location.href = '/auth/profile';
325
- }
326
- }, []);
327
- useUser('/auth/profile', true);
328
-
329
- var _useState = useState(''),
330
- _useState2 = _slicedToArray(_useState, 2),
331
- errorMsg = _useState2[0],
332
- setErrorMsg = _useState2[1];
333
-
334
- var _useState3 = useState(false),
335
- _useState4 = _slicedToArray(_useState3, 2),
336
- loading = _useState4[0],
337
- setLoading = _useState4[1];
338
-
339
- return React__default.createElement(
340
- Form,
341
- { className: 'login', onSubmit: handleSubmit },
342
- React__default.createElement(
343
- 'h1',
344
- null,
345
- 'Login'
346
- ),
347
- React__default.createElement('hr', null),
348
- returnFormField({ name: 'email', label: 'Email', type: 'email', required: true }),
349
- returnFormField({ name: 'password', label: 'Password', type: 'password', required: true }),
350
- React__default.createElement('hr', null),
351
- React__default.createElement(
352
- Form.Row,
353
- null,
354
- React__default.createElement(
355
- Form.Group,
356
- { as: Col },
357
- React__default.createElement(
358
- 'a',
359
- { href: '/auth/signup' },
360
- 'I don\'t have an account'
361
- )
362
- ),
363
- React__default.createElement(
364
- Form.Group,
365
- { as: Col, className: 'text-right' },
366
- !loading && React__default.createElement(
367
- Button,
368
- { type: 'submit' },
369
- 'Login'
370
- ),
371
- loading && React__default.createElement(
372
- Button,
373
- { variant: 'primary', disabled: true },
374
- React__default.createElement(Spinner, { as: 'span', animation: 'border', role: 'status', 'aria-hidden': 'true', size: 'sm' }),
375
- React__default.createElement(
376
- 'span',
377
- { className: 'sr-only' },
378
- 'Loading...'
379
- )
380
- )
381
- )
382
- ),
383
- errorMsg && React__default.createElement(
384
- 'p',
385
- { className: 'error' },
386
- errorMsg
387
- ),
388
- React__default.createElement(
389
- 'style',
390
- { jsx: 'true'.toString() },
391
- '\n .login {\n margin: 0 auto;\n padding: 1rem;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n .error {\n color: red;\n margin: 1rem 0 0;\n }\n '
392
- )
393
- );
394
- };
395
-
396
- // get country & state options
397
- var countries = ["United States", "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas (the)", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia (Plurinational State of)", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory (the)", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cabo Verde", "Cambodia", "Cameroon", "Canada", "Cayman Islands (the)", "Central African Republic (the)", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands (the)", "Colombia", "Comoros (the)", "Congo (the Democratic Republic of the)", "Congo (the)", "Cook Islands (the)", "Costa Rica", "Croatia", "Cuba", "Curaçao", "Cyprus", "Czechia", "Côte d'Ivoire", "Denmark", "Djibouti", "Dominica", "Dominican Republic (the)", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Eswatini", "Ethiopia", "Falkland Islands (the) [Malvinas]", "Faroe Islands (the)", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories (the)", "Gabon", "Gambia (the)", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (the)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran (Islamic Republic of)", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Korea (the Democratic People's Republic of)", "Korea (the Republic of)", "Kuwait", "Kyrgyzstan", "Lao People's Democratic Republic (the)", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands (the)", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia (Federated States of)", "Moldova (the Republic of)", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands (the)", "New Caledonia", "New Zealand", "Nicaragua", "Niger (the)", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands (the)", "Norway", "Oman", "Pakistan", "Palau", "Palestine, State of", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines (the)", "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Republic of North Macedonia", "Romania", "Russian Federation (the)", "Rwanda", "Réunion", "Saint Barthélemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten (Dutch part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Sudan", "Spain", "Sri Lanka", "Sudan (the)", "Suriname", "Svalbard and Jan Mayen", "Sweden", "Switzerland", "Syrian Arab Republic", "Taiwan (Province of China)", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands (the)", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates (the)", "United Kingdom of Great Britain and Northern Ireland (the)", "United States Minor Outlying Islands (the)", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela (Bolivarian Republic of)", "Viet Nam", "Virgin Islands (British)", "Virgin Islands (U.S.)", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe", "Åland Islands"];
398
-
399
- var states = ['AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM', 'FL', 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI', 'VA', 'WA', 'WV', 'WI', 'WY'];
400
-
401
- var _this$3 = undefined;
402
-
403
- var SignupForm$1 = function SignupForm(props) {
404
- var handleSubmit = function () {
405
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
406
- var formData, body, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, res;
407
-
408
- return regenerator.wrap(function _callee3$(_context3) {
409
- while (1) {
410
- switch (_context3.prev = _context3.next) {
411
- case 0:
412
- event.preventDefault();
413
- setLoading(true);
414
- if (errorMsg) setErrorMsg('');
415
-
416
- formData = new FormData(e.currentTarget);
417
- body = {};
418
- _iteratorNormalCompletion = true;
419
- _didIteratorError = false;
420
- _iteratorError = undefined;
421
- _context3.prev = 8;
422
-
423
- for (_iterator = _getIterator(formData.keys()); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
424
- key = _step.value;
425
-
426
- body[key] = formData.get(key);
427
- }
428
-
429
- _context3.next = 16;
430
- break;
431
-
432
- case 12:
433
- _context3.prev = 12;
434
- _context3.t0 = _context3['catch'](8);
435
- _didIteratorError = true;
436
- _iteratorError = _context3.t0;
437
-
438
- case 16:
439
- _context3.prev = 16;
440
- _context3.prev = 17;
441
-
442
- if (!_iteratorNormalCompletion && _iterator.return) {
443
- _iterator.return();
444
- }
445
-
446
- case 19:
447
- _context3.prev = 19;
448
-
449
- if (!_didIteratorError) {
450
- _context3.next = 22;
451
- break;
452
- }
453
-
454
- throw _iteratorError;
455
-
456
- case 22:
457
- return _context3.finish(19);
458
-
459
- case 23:
460
- return _context3.finish(16);
461
-
462
- case 24:
463
- _context3.prev = 24;
464
- _context3.next = 27;
465
- return fetch('/api/auth/signup', {
466
- method: 'POST',
467
- headers: { 'Content-Type': 'application/json' },
468
- body: _JSON$stringify(body)
469
- });
470
-
471
- case 27:
472
- res = _context3.sent;
473
-
474
- setLoading(false);
475
-
476
- if (!(res.status === 200)) {
477
- _context3.next = 33;
478
- break;
479
- }
480
-
481
- window.location.href = '/';
482
- _context3.next = 38;
483
- break;
484
-
485
- case 33:
486
- _context3.t1 = Error;
487
- _context3.next = 36;
488
- return res.text();
489
-
490
- case 36:
491
- _context3.t2 = _context3.sent;
492
- throw new _context3.t1(_context3.t2);
493
-
494
- case 38:
495
- _context3.next = 43;
496
- break;
497
-
498
- case 40:
499
- _context3.prev = 40;
500
- _context3.t3 = _context3['catch'](24);
501
-
502
- setErrorMsg(_context3.t3.message);
503
-
504
- case 43:
505
- case 'end':
506
- return _context3.stop();
507
- }
508
- }
509
- }, _callee3, this, [[8, 12, 16, 24], [17,, 19, 23], [24, 40]]);
510
- }));
511
-
512
- return function handleSubmit(_x2) {
513
- return _ref3.apply(this, arguments);
514
- };
515
- }();
516
-
517
- var _useState = useState(''),
518
- _useState2 = _slicedToArray(_useState, 2),
519
- errorMsg = _useState2[0],
520
- setErrorMsg = _useState2[1];
521
-
522
- var _useState3 = useState(false),
523
- _useState4 = _slicedToArray(_useState3, 2),
524
- countryUS = _useState4[0],
525
- setCountryUS = _useState4[1];
526
-
527
- var _useState5 = useState([]),
528
- _useState6 = _slicedToArray(_useState5, 2),
529
- healthcareOccupation = _useState6[0],
530
- setHealthcareOccupation = _useState6[1];
531
-
532
- var _useState7 = useState([]),
533
- _useState8 = _slicedToArray(_useState7, 2),
534
- nonHealthcareOccupation = _useState8[0],
535
- setNonHealthcareOccupation = _useState8[1];
536
-
537
- var loadInitData = function () {
538
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
539
- var healthcare_occupation, non_healthcare_occupation;
540
- return regenerator.wrap(function _callee$(_context) {
541
- while (1) {
542
- switch (_context.prev = _context.next) {
543
- case 0:
544
- _context.next = 2;
545
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Healthcare' });
546
-
547
- case 2:
548
- healthcare_occupation = _context.sent;
549
- _context.next = 5;
550
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Non-Healthcare' });
551
-
552
- case 5:
553
- non_healthcare_occupation = _context.sent;
554
-
555
-
556
- setHealthcareOccupation(healthcare_occupation);
557
- setNonHealthcareOccupation(non_healthcare_occupation);
558
-
559
- case 8:
560
- case 'end':
561
- return _context.stop();
562
- }
563
- }
564
- }, _callee, _this$3);
565
- }));
566
-
567
- return function loadInitData() {
568
- return _ref.apply(this, arguments);
569
- };
570
- }();
571
-
572
- useEffect(function () {
573
- if (props.user) {
574
- window.location.href = '/auth/profile';
575
- } else {
576
- loadInitData();
577
- }
578
- }, []);
579
-
580
- // make it to change layout based on radio buton
581
- var handleCountryChanged = function handleCountryChanged(e) {
582
- if (e.target.value === 'United States') {
583
- setCountryUS(true);
584
- } else {
585
- setCountryUS(false);
586
- }
587
- };
588
-
589
- var _useState9 = useState(true),
590
- _useState10 = _slicedToArray(_useState9, 2),
591
- healcareProfessional = _useState10[0],
592
- setHealthcareProfessional = _useState10[1];
593
-
594
- var handleHealthcareProfessionalChanged = function handleHealthcareProfessionalChanged(e) {
595
-
596
- if (e.target.value === 'Y') {
597
- setHealthcareProfessional(true);
598
- } else {
599
- setHealthcareProfessional(false);
600
- }
601
- document.getElementById('occupation').value = '';
602
- setOccupationFields(null);
603
- };
604
-
605
- var _useState11 = useState(null),
606
- _useState12 = _slicedToArray(_useState11, 2),
607
- occupationFields = _useState12[0],
608
- setOccupationFields = _useState12[1];
609
-
610
- var handleOccupationChanged = function () {
611
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
612
- var occupation, fields;
613
- return regenerator.wrap(function _callee2$(_context2) {
614
- while (1) {
615
- switch (_context2.prev = _context2.next) {
616
- case 0:
617
- occupation = e.target.value;
618
- _context2.next = 3;
619
- return dataHandler('/api/auth/data', { action: 'get-fields', occupation: occupation });
620
-
621
- case 3:
622
- fields = _context2.sent;
623
-
624
- setOccupationFields(fields);
625
-
626
- case 5:
627
- case 'end':
628
- return _context2.stop();
629
- }
630
- }
631
- }, _callee2, _this$3);
632
- }));
633
-
634
- return function handleOccupationChanged(_x) {
635
- return _ref2.apply(this, arguments);
636
- };
637
- }();
638
-
639
- var _useState13 = useState(false),
640
- _useState14 = _slicedToArray(_useState13, 2),
641
- loading = _useState14[0],
642
- setLoading = _useState14[1];
643
-
644
- return React__default.createElement(
645
- Form,
646
- { className: 'login', id: 'signupForm', onSubmit: handleSubmit },
647
- React__default.createElement(
648
- 'h1',
649
- null,
650
- 'Sign Up'
651
- ),
652
- React__default.createElement('hr', null),
653
- returnFormField({ name: 'email', label: 'Email', type: 'email', required: true }),
654
- React__default.createElement(
655
- Form.Row,
656
- null,
657
- returnFormField({ name: 'password', label: 'Password', type: 'password', groupType: Col, required: true }),
658
- returnFormField({ name: 'rpassword', label: 'Retype Password', type: 'password', groupType: Col, required: true })
659
- ),
660
- React__default.createElement(
661
- Form.Row,
662
- null,
663
- returnFormField({ name: 'first_name', label: 'First Name', type: 'text', groupType: Col, required: true }),
664
- returnFormField({ name: 'last_name', label: 'Last Name', type: 'text', groupType: Col, required: true })
665
- ),
666
- React__default.createElement(
667
- Form.Row,
668
- null,
669
- returnFormField({
670
- name: 'country',
671
- label: 'Country',
672
- type: 'select',
673
- required: true,
674
- groupType: Col,
675
- options: countries,
676
- handleChanged: handleCountryChanged
677
- }),
678
- countryUS && returnFormField({ name: 'state', label: 'State', type: 'select', required: true, groupType: Col, options: states })
679
- ),
680
- React__default.createElement(
681
- Form.Row,
682
- null,
683
- countryUS && returnFormField({ name: 'zip', label: 'Working Zip Code', type: 'text', required: true, groupType: Col }),
684
- countryUS && returnFormField({ name: 'phone', label: 'Phone', type: 'text', required: true, groupType: Col })
685
- ),
686
- returnFormField({
687
- name: 'healthcare_professional',
688
- label: 'Are You a Health Care Professional?',
689
- type: 'radio',
690
- required: true,
691
- options: [{ value: 'Y', label: 'Yes', checked: true }, { value: 'N', label: 'No', checked: false }],
692
- handleChanged: handleHealthcareProfessionalChanged,
693
- default_value: 'Y'
694
- }),
695
- healcareProfessional && returnFormField({
696
- name: 'occupation',
697
- label: 'Occupation',
698
- type: 'select',
699
- required: true,
700
- options: healthcareOccupation,
701
- handleChanged: handleOccupationChanged
702
- }),
703
- !healcareProfessional && returnFormField({
704
- name: 'occupation',
705
- label: 'Non Provider Role',
706
- type: 'select',
707
- required: true,
708
- options: nonHealthcareOccupation,
709
- handleChanged: handleOccupationChanged
710
- }),
711
- occupationFields && occupationFields.map(function (field) {
712
- return returnFormField({
713
- name: field.name,
714
- label: field.label,
715
- type: field.type,
716
- required: field.required === 1,
717
- options: field.options
718
- });
719
- }),
720
- returnFormField({
721
- name: 'agree',
722
- label: 'Terms & Conditions | Privacy Policy',
723
- type: 'checkbox',
724
- required: true,
725
- options: [{ label: 'By registering you agree to our <a href="/terms" style="color:blue">Terms and Conditions</a> and <a href="/privacy" style="color:blue">Privacy Policy</a> and understand that you will be receiving email communications', value: 'Y' }]
726
- }),
727
- React__default.createElement('hr', null),
728
- React__default.createElement(
729
- Form.Row,
730
- null,
731
- React__default.createElement(
732
- Form.Group,
733
- { as: Col },
734
- React__default.createElement(
735
- 'a',
736
- { href: '/auth/login' },
737
- 'I already have an account'
738
- )
739
- ),
740
- React__default.createElement(
741
- Form.Group,
742
- { as: Col, className: 'text-right' },
743
- !loading && React__default.createElement(
744
- Button,
745
- { type: 'submit' },
746
- 'Sign Up'
747
- ),
748
- loading && React__default.createElement(
749
- Button,
750
- { variant: 'primary', disabled: true },
751
- React__default.createElement(Spinner, {
752
- as: 'span',
753
- animation: 'border',
754
- role: 'status',
755
- 'aria-hidden': 'true',
756
- size: 'sm'
757
- }),
758
- React__default.createElement(
759
- 'span',
760
- { className: 'sr-only' },
761
- 'Loading...'
762
- )
763
- )
764
- )
765
- ),
766
- errorMsg && React__default.createElement(
767
- 'p',
768
- { className: 'error' },
769
- errorMsg
770
- ),
771
- React__default.createElement(
772
- 'style',
773
- { jsx: 'true'.toString() },
774
- ' \n .login {\n margin: 0 auto;\n padding: 1rem;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n .error {\n color: red;\n margin: 1rem 0 0;\n }\n '
775
- )
776
- );
777
- };
778
-
779
- var _this$2 = undefined;
780
-
781
- var SignupForm = function SignupForm(props) {
782
- var handleSubmit = function () {
783
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(e) {
784
- var formData, body, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, key, res;
785
-
786
- return regenerator.wrap(function _callee3$(_context3) {
787
- while (1) {
788
- switch (_context3.prev = _context3.next) {
789
- case 0:
790
- event.preventDefault();
791
-
792
- setErrorMsg('');
793
- setSuccessMsg('');
794
- setLoading(true);
795
-
796
- formData = new FormData(e.currentTarget);
797
- body = {};
798
- _iteratorNormalCompletion = true;
799
- _didIteratorError = false;
800
- _iteratorError = undefined;
801
- _context3.prev = 9;
802
-
803
- for (_iterator = _getIterator(formData.keys()); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
804
- key = _step.value;
805
-
806
- body[key] = formData.get(key);
807
- }
808
-
809
- _context3.next = 17;
810
- break;
811
-
812
- case 13:
813
- _context3.prev = 13;
814
- _context3.t0 = _context3['catch'](9);
815
- _didIteratorError = true;
816
- _iteratorError = _context3.t0;
817
-
818
- case 17:
819
- _context3.prev = 17;
820
- _context3.prev = 18;
821
-
822
- if (!_iteratorNormalCompletion && _iterator.return) {
823
- _iterator.return();
824
- }
825
-
826
- case 20:
827
- _context3.prev = 20;
828
-
829
- if (!_didIteratorError) {
830
- _context3.next = 23;
831
- break;
832
- }
833
-
834
- throw _iteratorError;
835
-
836
- case 23:
837
- return _context3.finish(20);
838
-
839
- case 24:
840
- return _context3.finish(17);
841
-
842
- case 25:
843
- body['user_id'] = userData.id;
844
-
845
- _context3.prev = 26;
846
- _context3.next = 29;
847
- return fetch('/api/auth/profile', {
848
- method: 'POST',
849
- headers: { 'Content-Type': 'application/json' },
850
- body: _JSON$stringify(body)
851
- });
852
-
853
- case 29:
854
- res = _context3.sent;
855
-
856
- setLoading(false);
857
-
858
- if (!(res.status === 200)) {
859
- _context3.next = 35;
860
- break;
861
- }
862
-
863
- setSuccessMsg('Your request has been processed successfully!');
864
- _context3.next = 40;
865
- break;
866
-
867
- case 35:
868
- _context3.t1 = Error;
869
- _context3.next = 38;
870
- return res.text();
871
-
872
- case 38:
873
- _context3.t2 = _context3.sent;
874
- throw new _context3.t1(_context3.t2);
875
-
876
- case 40:
877
- _context3.next = 45;
878
- break;
879
-
880
- case 42:
881
- _context3.prev = 42;
882
- _context3.t3 = _context3['catch'](26);
883
-
884
- setErrorMsg(_context3.t3.message);
885
-
886
- case 45:
887
- case 'end':
888
- return _context3.stop();
889
- }
890
- }
891
- }, _callee3, this, [[9, 13, 17, 25], [18,, 20, 24], [26, 42]]);
892
- }));
893
-
894
- return function handleSubmit(_x2) {
895
- return _ref3.apply(this, arguments);
896
- };
897
- }();
898
-
899
- var _useState = useState(''),
900
- _useState2 = _slicedToArray(_useState, 2),
901
- errorMsg = _useState2[0],
902
- setErrorMsg = _useState2[1];
903
-
904
- var _useState3 = useState(false),
905
- _useState4 = _slicedToArray(_useState3, 2),
906
- countryUS = _useState4[0],
907
- setCountryUS = _useState4[1];
908
-
909
- var _useState5 = useState([]),
910
- _useState6 = _slicedToArray(_useState5, 2),
911
- healthcareOccupation = _useState6[0],
912
- setHealthcareOccupation = _useState6[1];
913
-
914
- var _useState7 = useState([]),
915
- _useState8 = _slicedToArray(_useState7, 2),
916
- nonHealthcareOccupation = _useState8[0],
917
- setNonHealthcareOccupation = _useState8[1];
918
-
919
- var _useState9 = useState(null),
920
- _useState10 = _slicedToArray(_useState9, 2),
921
- userData = _useState10[0],
922
- setUserData = _useState10[1];
923
-
924
- var user = props.user;
925
-
926
- var loadInitData = function () {
927
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
928
- var healthcare_occupation, non_healthcare_occupation, foundOccupation, fields;
929
- return regenerator.wrap(function _callee$(_context) {
930
- while (1) {
931
- switch (_context.prev = _context.next) {
932
- case 0:
933
- _context.next = 2;
934
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Healthcare' });
935
-
936
- case 2:
937
- healthcare_occupation = _context.sent;
938
- _context.next = 5;
939
- return dataHandler('/api/auth/data', { action: 'get-occupation', type: 'Non-Healthcare' });
940
-
941
- case 5:
942
- non_healthcare_occupation = _context.sent;
943
- foundOccupation = healthcare_occupation.find(function (item) {
944
- return item.value === user.shared.occupation_id;
945
- });
946
-
947
- if (foundOccupation) {
948
- user.shared.healthcare_professional = 'Y';
949
- } else {
950
- user.shared.healthcare_professional = 'N';
951
- }
952
-
953
- setHealthcareOccupation(healthcare_occupation);
954
- setNonHealthcareOccupation(non_healthcare_occupation);
955
- setUserData(user);
956
-
957
- if (user.shared.country === 'United States') {
958
- setCountryUS(true);
959
- } else {
960
- setCountryUS(false);
961
- }
962
-
963
- _context.next = 14;
964
- return dataHandler('/api/auth/data', { action: 'get-fields', occupation: user.shared.occupation_id });
965
-
966
- case 14:
967
- fields = _context.sent;
968
-
969
- setOccupationFields(fields);
970
-
971
- case 16:
972
- case 'end':
973
- return _context.stop();
974
- }
975
- }
976
- }, _callee, _this$2);
977
- }));
978
-
979
- return function loadInitData() {
980
- return _ref.apply(this, arguments);
981
- };
982
- }();
983
-
984
- useEffect(function () {
985
- if (!user) {
986
- window.location.href = '/auth/login';
987
- } else {
988
- loadInitData();
989
- }
990
- }, []);
991
-
992
- // make it to change layout based on radio buton
993
- var handleCountryChanged = function handleCountryChanged(e) {
994
- if (e.target.value === 'United States') {
995
- setCountryUS(true);
996
- } else {
997
- setCountryUS(false);
998
- }
999
- };
1000
-
1001
- var _useState11 = useState(true),
1002
- _useState12 = _slicedToArray(_useState11, 2),
1003
- healcareProfessional = _useState12[0],
1004
- setHealthcareProfessional = _useState12[1];
1005
-
1006
- var handleHealthcareProfessionalChanged = function handleHealthcareProfessionalChanged(e) {
1007
-
1008
- if (e.target.value === 'Y') {
1009
- setHealthcareProfessional(true);
1010
- } else {
1011
- setHealthcareProfessional(false);
1012
- }
1013
- document.getElementById('occupation').value = '';
1014
- setOccupationFields(null);
1015
- };
1016
-
1017
- var _useState13 = useState(null),
1018
- _useState14 = _slicedToArray(_useState13, 2),
1019
- occupationFields = _useState14[0],
1020
- setOccupationFields = _useState14[1];
1021
-
1022
- var handleOccupationChanged = function () {
1023
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(e) {
1024
- var occupation, fields;
1025
- return regenerator.wrap(function _callee2$(_context2) {
1026
- while (1) {
1027
- switch (_context2.prev = _context2.next) {
1028
- case 0:
1029
- occupation = e.target.value;
1030
- _context2.next = 3;
1031
- return dataHandler('/api/auth/data', { action: 'get-fields', occupation: occupation });
1032
-
1033
- case 3:
1034
- fields = _context2.sent;
1035
-
1036
- setOccupationFields(fields);
1037
-
1038
- case 5:
1039
- case 'end':
1040
- return _context2.stop();
1041
- }
1042
- }
1043
- }, _callee2, _this$2);
1044
- }));
1045
-
1046
- return function handleOccupationChanged(_x) {
1047
- return _ref2.apply(this, arguments);
1048
- };
1049
- }();
1050
-
1051
- var _useState15 = useState(''),
1052
- _useState16 = _slicedToArray(_useState15, 2),
1053
- successMsg = _useState16[0],
1054
- setSuccessMsg = _useState16[1];
1055
-
1056
- var _useState17 = useState(false),
1057
- _useState18 = _slicedToArray(_useState17, 2),
1058
- loading = _useState18[0],
1059
- setLoading = _useState18[1];
1060
-
1061
- return React__default.createElement(
1062
- Form,
1063
- { className: 'login', id: 'signupForm', onSubmit: handleSubmit },
1064
- React__default.createElement(
1065
- 'h1',
1066
- null,
1067
- 'Profile'
1068
- ),
1069
- React__default.createElement('hr', null),
1070
- userData ? React__default.createElement(
1071
- React__default.Fragment,
1072
- null,
1073
- returnFormField({ name: 'email', label: 'Email', type: 'email', required: true, readonly: true, default_value: userData.email }),
1074
- React__default.createElement(
1075
- Form.Row,
1076
- null,
1077
- returnFormField({ name: 'password', label: 'Password', type: 'password', groupType: Col, required: false }),
1078
- returnFormField({ name: 'rpassword', label: 'Retype Password', type: 'password', groupType: Col, required: false })
1079
- ),
1080
- React__default.createElement(
1081
- Form.Row,
1082
- null,
1083
- returnFormField({ name: 'first_name', label: 'First Name', type: 'text', groupType: Col, required: true, default_value: userData.shared.first_name }),
1084
- returnFormField({ name: 'last_name', label: 'Last Name', type: 'text', groupType: Col, required: true, default_value: userData.shared.last_name })
1085
- ),
1086
- React__default.createElement(
1087
- Form.Row,
1088
- null,
1089
- returnFormField({
1090
- name: 'country',
1091
- label: 'Country',
1092
- type: 'select',
1093
- required: true,
1094
- groupType: Col,
1095
- options: countries,
1096
- handleChanged: handleCountryChanged,
1097
- default_value: userData.shared.country
1098
- }),
1099
- countryUS && returnFormField({ name: 'state', label: 'State', type: 'select', required: true, groupType: Col, options: states, default_value: userData.shared.state })
1100
- ),
1101
- React__default.createElement(
1102
- Form.Row,
1103
- null,
1104
- countryUS && returnFormField({ name: 'zip', label: 'Working Zip Code', type: 'text', required: true, groupType: Col, default_value: userData.shared.zip }),
1105
- countryUS && returnFormField({ name: 'phone', label: 'Phone', type: 'text', required: true, groupType: Col, default_value: userData.shared.phone })
1106
- ),
1107
- returnFormField({
1108
- name: 'healthcare_professional',
1109
- label: 'Are You a Health Care Professional?',
1110
- type: 'radio',
1111
- required: true,
1112
- options: [{ value: 'Y', label: 'Yes', checked: true }, { value: 'N', label: 'No', checked: false }],
1113
- default_value: userData.shared.healthcare_professional,
1114
- handleChanged: handleHealthcareProfessionalChanged
1115
- }),
1116
- healcareProfessional && returnFormField({
1117
- name: 'occupation',
1118
- label: 'Occupation',
1119
- type: 'select',
1120
- required: true,
1121
- options: healthcareOccupation,
1122
- handleChanged: handleOccupationChanged,
1123
- default_value: userData.shared.occupation_id
1124
- }),
1125
- !healcareProfessional && returnFormField({
1126
- name: 'occupation',
1127
- label: 'Non Provider Role',
1128
- type: 'select',
1129
- required: true,
1130
- options: nonHealthcareOccupation,
1131
- handleChanged: handleOccupationChanged,
1132
- default_value: userData.shared.occupation_id
1133
- }),
1134
- occupationFields && occupationFields.map(function (field) {
1135
- return returnFormField({
1136
- name: field.name,
1137
- label: field.label,
1138
- type: field.type,
1139
- required: field.required === 1,
1140
- options: field.options,
1141
- default_value: userData.shared[field.name]
1142
- });
1143
- }),
1144
- returnFormField({
1145
- name: 'agree',
1146
- label: 'Terms & Conditions | Privacy Policy',
1147
- type: 'checkbox',
1148
- required: true,
1149
- options: [{ label: 'By registering you agree to our <a href="/terms">Terms and Conditions</a> and <a href="/privacy">Privacy Policy</a> and understand that you will be receiving email communications', value: 'Y' }]
1150
- }),
1151
- React__default.createElement('hr', null),
1152
- React__default.createElement(
1153
- Form.Row,
1154
- null,
1155
- React__default.createElement(
1156
- Form.Group,
1157
- { as: Col },
1158
- !loading && React__default.createElement(
1159
- Button,
1160
- { type: 'submit' },
1161
- 'Update'
1162
- ),
1163
- loading && React__default.createElement(
1164
- Button,
1165
- { variant: 'primary', disabled: true },
1166
- React__default.createElement(Spinner, {
1167
- as: 'span',
1168
- animation: 'border',
1169
- role: 'status',
1170
- 'aria-hidden': 'true',
1171
- size: 'sm'
1172
- }),
1173
- React__default.createElement(
1174
- 'span',
1175
- { className: 'sr-only' },
1176
- 'Loading...'
1177
- )
1178
- )
1179
- )
1180
- )
1181
- ) : React__default.createElement(Spinner, {
1182
- as: 'span',
1183
- animation: 'border',
1184
- role: 'status',
1185
- 'aria-hidden': 'true',
1186
- size: 'sm'
1187
- }),
1188
- errorMsg && React__default.createElement(
1189
- 'p',
1190
- { className: 'error' },
1191
- errorMsg
1192
- ),
1193
- successMsg && React__default.createElement(
1194
- 'p',
1195
- { className: 'success' },
1196
- successMsg
1197
- ),
1198
- React__default.createElement(
1199
- 'style',
1200
- { jsx: 'true'.toString() },
1201
- ' \n .login {\n margin: 0 auto;\n padding: 1rem;\n border: 1px solid #ccc;\n border-radius: 4px;\n }\n .error {\n color: red;\n margin: 1rem 0 0;\n }\n .success {\n color: green;\n margin: 1rem 0 0;\n }\n '
1202
- )
1203
- );
1204
- };
1205
-
1206
- var TOKEN_NAME = 'token';
1207
- var MAX_AGE = 60 * 60 * 8; // 8 hours
1208
-
1209
- function setTokenCookie(res, token, eKey) {
1210
- var cookies_serailized = [];
1211
- cookies_serailized.push(serialize_1(TOKEN_NAME, token, {
1212
- //maxAge: MAX_AGE, // we want login cookie to expire when browser
1213
- //expires: new Date(Date.now() + MAX_AGE * 1000),
1214
- //httpOnly: true,
1215
- //secure: process.env.NODE_ENV === 'production',
1216
- path: '/'
1217
- //sameSite: 'lax',
1218
- }));
1219
-
1220
- cookies_serailized.push(serialize_1('eKey', eKey, {
1221
- //maxAge: MAX_AGE, // we want login cookie to expire when browser
1222
- //expires: new Date(Date.now() + MAX_AGE * 1000),
1223
- //httpOnly: true,
1224
- //secure: process.env.NODE_ENV === 'production',
1225
- path: '/'
1226
- //sameSite: 'lax',
1227
- }));
1228
-
1229
- res.setHeader('Set-Cookie', cookies_serailized);
1230
- }
1231
-
1232
- function removeTokenCookie(res) {
1233
- var cookies_serailized = [];
1234
- cookies_serailized.push(serialize_1(TOKEN_NAME, '', {
1235
- maxAge: -1,
1236
- expires: new Date(Date.now() - MAX_AGE * 1000),
1237
- path: '/'
1238
- }));
1239
- cookies_serailized.push(serialize_1('eKey', '', {
1240
- maxAge: -1,
1241
- expires: new Date(Date.now() - MAX_AGE * 1000),
1242
- path: '/'
1243
- }));
1244
-
1245
- res.setHeader('Set-Cookie', cookies_serailized);
1246
- }
1247
-
1248
- function parseCookies(req) {
1249
- // For API Routes we don't need to parse the cookies.
1250
- if (req.cookies) return req.cookies;
1251
-
1252
- // For pages we do need to parse the cookies.
1253
- var cookie = req.headers ? req.headers.cookie : null;
1254
- return parse_1(cookie || '');
1255
- }
1256
-
1257
- function getTokenCookie(req) {
1258
- var cookies = parseCookies(req);
1259
- return cookies[TOKEN_NAME];
1260
- }
1261
-
1262
- var authCookies = /*#__PURE__*/Object.freeze({
1263
- __proto__: null,
1264
- setTokenCookie: setTokenCookie,
1265
- removeTokenCookie: removeTokenCookie,
1266
- parseCookies: parseCookies,
1267
- getTokenCookie: getTokenCookie
1268
- });
1269
-
1270
- function encryptSession(session) {
1271
- var buffer = new Buffer(_JSON$stringify(session));
1272
- return buffer.toString('base64');
1273
- //return jwt.sign(session, TOKEN_SECRET)
1274
- //return Iron.seal(session, TOKEN_SECRET, Iron.defaults)
1275
- }
1276
-
1277
- var getSession = function () {
1278
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(req) {
1279
- var token, buff;
1280
- return regenerator.wrap(function _callee$(_context) {
1281
- while (1) {
1282
- switch (_context.prev = _context.next) {
1283
- case 0:
1284
- token = getTokenCookie(req);
1285
-
1286
- if (!token) {
1287
- _context.next = 4;
1288
- break;
1289
- }
1290
-
1291
- buff = new Buffer(token, 'base64');
1292
- return _context.abrupt('return', JSON.parse(buff.toString('utf8')));
1293
-
1294
- case 4:
1295
- return _context.abrupt('return', null);
1296
-
1297
- case 5:
1298
- case 'end':
1299
- return _context.stop();
1300
- }
1301
- }
1302
- }, _callee, this);
1303
- }));
1304
-
1305
- return function getSession(_x) {
1306
- return _ref.apply(this, arguments);
1307
- };
1308
- }();
1309
-
1310
- var iron = /*#__PURE__*/Object.freeze({
1311
- __proto__: null,
1312
- encryptSession: encryptSession,
1313
- getSession: getSession
1314
- });
1315
-
1316
- var toStr$5 = Object.prototype.toString;
1317
-
1318
- var isArguments = function isArguments(value) {
1319
- var str = toStr$5.call(value);
1320
- var isArgs = str === '[object Arguments]';
1321
- if (!isArgs) {
1322
- isArgs = str !== '[object Array]' &&
1323
- value !== null &&
1324
- typeof value === 'object' &&
1325
- typeof value.length === 'number' &&
1326
- value.length >= 0 &&
1327
- toStr$5.call(value.callee) === '[object Function]';
1328
- }
1329
- return isArgs;
1330
- };
1331
-
1332
- var keysShim$1;
1333
- if (!Object.keys) {
1334
- // modified from https://github.com/es-shims/es5-shim
1335
- var has$1 = Object.prototype.hasOwnProperty;
1336
- var toStr$4 = Object.prototype.toString;
1337
- var isArgs = isArguments; // eslint-disable-line global-require
1338
- var isEnumerable = Object.prototype.propertyIsEnumerable;
1339
- var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString');
1340
- var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype');
1341
- var dontEnums = [
1342
- 'toString',
1343
- 'toLocaleString',
1344
- 'valueOf',
1345
- 'hasOwnProperty',
1346
- 'isPrototypeOf',
1347
- 'propertyIsEnumerable',
1348
- 'constructor'
1349
- ];
1350
- var equalsConstructorPrototype = function (o) {
1351
- var ctor = o.constructor;
1352
- return ctor && ctor.prototype === o;
1353
- };
1354
- var excludedKeys = {
1355
- $applicationCache: true,
1356
- $console: true,
1357
- $external: true,
1358
- $frame: true,
1359
- $frameElement: true,
1360
- $frames: true,
1361
- $innerHeight: true,
1362
- $innerWidth: true,
1363
- $onmozfullscreenchange: true,
1364
- $onmozfullscreenerror: true,
1365
- $outerHeight: true,
1366
- $outerWidth: true,
1367
- $pageXOffset: true,
1368
- $pageYOffset: true,
1369
- $parent: true,
1370
- $scrollLeft: true,
1371
- $scrollTop: true,
1372
- $scrollX: true,
1373
- $scrollY: true,
1374
- $self: true,
1375
- $webkitIndexedDB: true,
1376
- $webkitStorageInfo: true,
1377
- $window: true
1378
- };
1379
- var hasAutomationEqualityBug = (function () {
1380
- /* global window */
1381
- if (typeof window === 'undefined') { return false; }
1382
- for (var k in window) {
1383
- try {
1384
- if (!excludedKeys['$' + k] && has$1.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
1385
- try {
1386
- equalsConstructorPrototype(window[k]);
1387
- } catch (e) {
1388
- return true;
1389
- }
1390
- }
1391
- } catch (e) {
1392
- return true;
1393
- }
1394
- }
1395
- return false;
1396
- }());
1397
- var equalsConstructorPrototypeIfNotBuggy = function (o) {
1398
- /* global window */
1399
- if (typeof window === 'undefined' || !hasAutomationEqualityBug) {
1400
- return equalsConstructorPrototype(o);
1401
- }
1402
- try {
1403
- return equalsConstructorPrototype(o);
1404
- } catch (e) {
1405
- return false;
1406
- }
1407
- };
1408
-
1409
- keysShim$1 = function keys(object) {
1410
- var isObject = object !== null && typeof object === 'object';
1411
- var isFunction = toStr$4.call(object) === '[object Function]';
1412
- var isArguments = isArgs(object);
1413
- var isString = isObject && toStr$4.call(object) === '[object String]';
1414
- var theKeys = [];
1415
-
1416
- if (!isObject && !isFunction && !isArguments) {
1417
- throw new TypeError('Object.keys called on a non-object');
1418
- }
1419
-
1420
- var skipProto = hasProtoEnumBug && isFunction;
1421
- if (isString && object.length > 0 && !has$1.call(object, 0)) {
1422
- for (var i = 0; i < object.length; ++i) {
1423
- theKeys.push(String(i));
1424
- }
1425
- }
1426
-
1427
- if (isArguments && object.length > 0) {
1428
- for (var j = 0; j < object.length; ++j) {
1429
- theKeys.push(String(j));
1430
- }
1431
- } else {
1432
- for (var name in object) {
1433
- if (!(skipProto && name === 'prototype') && has$1.call(object, name)) {
1434
- theKeys.push(String(name));
1435
- }
1436
- }
1437
- }
1438
-
1439
- if (hasDontEnumBug) {
1440
- var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);
1441
-
1442
- for (var k = 0; k < dontEnums.length; ++k) {
1443
- if (!(skipConstructor && dontEnums[k] === 'constructor') && has$1.call(object, dontEnums[k])) {
1444
- theKeys.push(dontEnums[k]);
1445
- }
1446
- }
1447
- }
1448
- return theKeys;
1449
- };
1450
- }
1451
- var implementation$3 = keysShim$1;
1452
-
1453
- var slice$1 = Array.prototype.slice;
1454
-
1455
-
1456
- var origKeys = Object.keys;
1457
- var keysShim = origKeys ? function keys(o) { return origKeys(o); } : implementation$3;
1458
-
1459
- var originalKeys = Object.keys;
1460
-
1461
- keysShim.shim = function shimObjectKeys() {
1462
- if (Object.keys) {
1463
- var keysWorksWithArguments = (function () {
1464
- // Safari 5.0 bug
1465
- var args = Object.keys(arguments);
1466
- return args && args.length === arguments.length;
1467
- }(1, 2));
1468
- if (!keysWorksWithArguments) {
1469
- Object.keys = function keys(object) { // eslint-disable-line func-name-matching
1470
- if (isArguments(object)) {
1471
- return originalKeys(slice$1.call(object));
1472
- }
1473
- return originalKeys(object);
1474
- };
1475
- }
1476
- } else {
1477
- Object.keys = keysShim;
1478
- }
1479
- return Object.keys || keysShim;
1480
- };
1481
-
1482
- var objectKeys = keysShim;
1483
-
1484
- var hasSymbols$4 = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol';
1485
-
1486
- var toStr$3 = Object.prototype.toString;
1487
- var concat = Array.prototype.concat;
1488
- var origDefineProperty = Object.defineProperty;
1489
-
1490
- var isFunction = function (fn) {
1491
- return typeof fn === 'function' && toStr$3.call(fn) === '[object Function]';
1492
- };
1493
-
1494
- var arePropertyDescriptorsSupported = function () {
1495
- var obj = {};
1496
- try {
1497
- origDefineProperty(obj, 'x', { enumerable: false, value: obj });
1498
- // eslint-disable-next-line no-unused-vars, no-restricted-syntax
1499
- for (var _ in obj) { // jscs:ignore disallowUnusedVariables
1500
- return false;
1501
- }
1502
- return obj.x === obj;
1503
- } catch (e) { /* this is IE 8. */
1504
- return false;
1505
- }
1506
- };
1507
- var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
1508
-
1509
- var defineProperty = function (object, name, value, predicate) {
1510
- if (name in object && (!isFunction(predicate) || !predicate())) {
1511
- return;
1512
- }
1513
- if (supportsDescriptors) {
1514
- origDefineProperty(object, name, {
1515
- configurable: true,
1516
- enumerable: false,
1517
- value: value,
1518
- writable: true
1519
- });
1520
- } else {
1521
- object[name] = value;
1522
- }
1523
- };
1524
-
1525
- var defineProperties = function (object, map) {
1526
- var predicates = arguments.length > 2 ? arguments[2] : {};
1527
- var props = objectKeys(map);
1528
- if (hasSymbols$4) {
1529
- props = concat.call(props, Object.getOwnPropertySymbols(map));
1530
- }
1531
- for (var i = 0; i < props.length; i += 1) {
1532
- defineProperty(object, props[i], map[props[i]], predicates[props[i]]);
1533
- }
1534
- };
1535
-
1536
- defineProperties.supportsDescriptors = !!supportsDescriptors;
1537
-
1538
- var defineProperties_1 = defineProperties;
1539
-
1540
- /* eslint no-invalid-this: 1 */
1541
-
1542
- var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
1543
- var slice = Array.prototype.slice;
1544
- var toStr$2 = Object.prototype.toString;
1545
- var funcType = '[object Function]';
1546
-
1547
- var implementation$2 = function bind(that) {
1548
- var target = this;
1549
- if (typeof target !== 'function' || toStr$2.call(target) !== funcType) {
1550
- throw new TypeError(ERROR_MESSAGE + target);
1551
- }
1552
- var args = slice.call(arguments, 1);
1553
-
1554
- var bound;
1555
- var binder = function () {
1556
- if (this instanceof bound) {
1557
- var result = target.apply(
1558
- this,
1559
- args.concat(slice.call(arguments))
1560
- );
1561
- if (Object(result) === result) {
1562
- return result;
1563
- }
1564
- return this;
1565
- } else {
1566
- return target.apply(
1567
- that,
1568
- args.concat(slice.call(arguments))
1569
- );
1570
- }
1571
- };
1572
-
1573
- var boundLength = Math.max(0, target.length - args.length);
1574
- var boundArgs = [];
1575
- for (var i = 0; i < boundLength; i++) {
1576
- boundArgs.push('$' + i);
1577
- }
1578
-
1579
- bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
1580
-
1581
- if (target.prototype) {
1582
- var Empty = function Empty() {};
1583
- Empty.prototype = target.prototype;
1584
- bound.prototype = new Empty();
1585
- Empty.prototype = null;
1586
- }
1587
-
1588
- return bound;
1589
- };
1590
-
1591
- var functionBind = Function.prototype.bind || implementation$2;
1592
-
1593
- /* eslint complexity: [2, 18], max-statements: [2, 33] */
1594
- var shams = function hasSymbols() {
1595
- if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
1596
- if (typeof Symbol.iterator === 'symbol') { return true; }
1597
-
1598
- var obj = {};
1599
- var sym = Symbol('test');
1600
- var symObj = Object(sym);
1601
- if (typeof sym === 'string') { return false; }
1602
-
1603
- if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
1604
- if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }
1605
-
1606
- // temp disabled per https://github.com/ljharb/object.assign/issues/17
1607
- // if (sym instanceof Symbol) { return false; }
1608
- // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4
1609
- // if (!(symObj instanceof Symbol)) { return false; }
1610
-
1611
- // if (typeof Symbol.prototype.toString !== 'function') { return false; }
1612
- // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; }
1613
-
1614
- var symVal = 42;
1615
- obj[sym] = symVal;
1616
- for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop
1617
- if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }
1618
-
1619
- if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }
1620
-
1621
- var syms = Object.getOwnPropertySymbols(obj);
1622
- if (syms.length !== 1 || syms[0] !== sym) { return false; }
1623
-
1624
- if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }
1625
-
1626
- if (typeof Object.getOwnPropertyDescriptor === 'function') {
1627
- var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
1628
- if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
1629
- }
1630
-
1631
- return true;
1632
- };
1633
-
1634
- var origSymbol = typeof Symbol !== 'undefined' && Symbol;
1635
-
1636
-
1637
- var hasSymbols$3 = function hasNativeSymbols() {
1638
- if (typeof origSymbol !== 'function') { return false; }
1639
- if (typeof Symbol !== 'function') { return false; }
1640
- if (typeof origSymbol('foo') !== 'symbol') { return false; }
1641
- if (typeof Symbol('bar') !== 'symbol') { return false; }
1642
-
1643
- return shams();
1644
- };
1645
-
1646
- var src = functionBind.call(Function.call, Object.prototype.hasOwnProperty);
1647
-
1648
- var undefined$1;
1649
-
1650
- var $SyntaxError$1 = SyntaxError;
1651
- var $Function = Function;
1652
- var $TypeError$5 = TypeError;
1653
-
1654
- // eslint-disable-next-line consistent-return
1655
- var getEvalledConstructor = function (expressionSyntax) {
1656
- try {
1657
- return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')();
1658
- } catch (e) {}
1659
- };
1660
-
1661
- var $gOPD$2 = Object.getOwnPropertyDescriptor;
1662
- if ($gOPD$2) {
1663
- try {
1664
- $gOPD$2({}, '');
1665
- } catch (e) {
1666
- $gOPD$2 = null; // this is IE 8, which has a broken gOPD
1667
- }
1668
- }
1669
-
1670
- var throwTypeError = function () {
1671
- throw new $TypeError$5();
1672
- };
1673
- var ThrowTypeError = $gOPD$2
1674
- ? (function () {
1675
- try {
1676
- // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties
1677
- arguments.callee; // IE 8 does not throw here
1678
- return throwTypeError;
1679
- } catch (calleeThrows) {
1680
- try {
1681
- // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '')
1682
- return $gOPD$2(arguments, 'callee').get;
1683
- } catch (gOPDthrows) {
1684
- return throwTypeError;
1685
- }
1686
- }
1687
- }())
1688
- : throwTypeError;
1689
-
1690
- var hasSymbols$2 = hasSymbols$3();
1691
-
1692
- var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto
1693
-
1694
- var needsEval = {};
1695
-
1696
- var TypedArray = typeof Uint8Array === 'undefined' ? undefined$1 : getProto(Uint8Array);
1697
-
1698
- var INTRINSICS = {
1699
- '%AggregateError%': typeof AggregateError === 'undefined' ? undefined$1 : AggregateError,
1700
- '%Array%': Array,
1701
- '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined$1 : ArrayBuffer,
1702
- '%ArrayIteratorPrototype%': hasSymbols$2 ? getProto([][Symbol.iterator]()) : undefined$1,
1703
- '%AsyncFromSyncIteratorPrototype%': undefined$1,
1704
- '%AsyncFunction%': needsEval,
1705
- '%AsyncGenerator%': needsEval,
1706
- '%AsyncGeneratorFunction%': needsEval,
1707
- '%AsyncIteratorPrototype%': needsEval,
1708
- '%Atomics%': typeof Atomics === 'undefined' ? undefined$1 : Atomics,
1709
- '%BigInt%': typeof BigInt === 'undefined' ? undefined$1 : BigInt,
1710
- '%Boolean%': Boolean,
1711
- '%DataView%': typeof DataView === 'undefined' ? undefined$1 : DataView,
1712
- '%Date%': Date,
1713
- '%decodeURI%': decodeURI,
1714
- '%decodeURIComponent%': decodeURIComponent,
1715
- '%encodeURI%': encodeURI,
1716
- '%encodeURIComponent%': encodeURIComponent,
1717
- '%Error%': Error,
1718
- '%eval%': eval, // eslint-disable-line no-eval
1719
- '%EvalError%': EvalError,
1720
- '%Float32Array%': typeof Float32Array === 'undefined' ? undefined$1 : Float32Array,
1721
- '%Float64Array%': typeof Float64Array === 'undefined' ? undefined$1 : Float64Array,
1722
- '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined$1 : FinalizationRegistry,
1723
- '%Function%': $Function,
1724
- '%GeneratorFunction%': needsEval,
1725
- '%Int8Array%': typeof Int8Array === 'undefined' ? undefined$1 : Int8Array,
1726
- '%Int16Array%': typeof Int16Array === 'undefined' ? undefined$1 : Int16Array,
1727
- '%Int32Array%': typeof Int32Array === 'undefined' ? undefined$1 : Int32Array,
1728
- '%isFinite%': isFinite,
1729
- '%isNaN%': isNaN,
1730
- '%IteratorPrototype%': hasSymbols$2 ? getProto(getProto([][Symbol.iterator]())) : undefined$1,
1731
- '%JSON%': typeof JSON === 'object' ? JSON : undefined$1,
1732
- '%Map%': typeof Map === 'undefined' ? undefined$1 : Map,
1733
- '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Map()[Symbol.iterator]()),
1734
- '%Math%': Math,
1735
- '%Number%': Number,
1736
- '%Object%': Object,
1737
- '%parseFloat%': parseFloat,
1738
- '%parseInt%': parseInt,
1739
- '%Promise%': typeof Promise === 'undefined' ? undefined$1 : Promise,
1740
- '%Proxy%': typeof Proxy === 'undefined' ? undefined$1 : Proxy,
1741
- '%RangeError%': RangeError,
1742
- '%ReferenceError%': ReferenceError,
1743
- '%Reflect%': typeof Reflect === 'undefined' ? undefined$1 : Reflect,
1744
- '%RegExp%': RegExp,
1745
- '%Set%': typeof Set === 'undefined' ? undefined$1 : Set,
1746
- '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols$2 ? undefined$1 : getProto(new Set()[Symbol.iterator]()),
1747
- '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined$1 : SharedArrayBuffer,
1748
- '%String%': String,
1749
- '%StringIteratorPrototype%': hasSymbols$2 ? getProto(''[Symbol.iterator]()) : undefined$1,
1750
- '%Symbol%': hasSymbols$2 ? Symbol : undefined$1,
1751
- '%SyntaxError%': $SyntaxError$1,
1752
- '%ThrowTypeError%': ThrowTypeError,
1753
- '%TypedArray%': TypedArray,
1754
- '%TypeError%': $TypeError$5,
1755
- '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined$1 : Uint8Array,
1756
- '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined$1 : Uint8ClampedArray,
1757
- '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined$1 : Uint16Array,
1758
- '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined$1 : Uint32Array,
1759
- '%URIError%': URIError,
1760
- '%WeakMap%': typeof WeakMap === 'undefined' ? undefined$1 : WeakMap,
1761
- '%WeakRef%': typeof WeakRef === 'undefined' ? undefined$1 : WeakRef,
1762
- '%WeakSet%': typeof WeakSet === 'undefined' ? undefined$1 : WeakSet
1763
- };
1764
-
1765
- var doEval = function doEval(name) {
1766
- var value;
1767
- if (name === '%AsyncFunction%') {
1768
- value = getEvalledConstructor('async function () {}');
1769
- } else if (name === '%GeneratorFunction%') {
1770
- value = getEvalledConstructor('function* () {}');
1771
- } else if (name === '%AsyncGeneratorFunction%') {
1772
- value = getEvalledConstructor('async function* () {}');
1773
- } else if (name === '%AsyncGenerator%') {
1774
- var fn = doEval('%AsyncGeneratorFunction%');
1775
- if (fn) {
1776
- value = fn.prototype;
1777
- }
1778
- } else if (name === '%AsyncIteratorPrototype%') {
1779
- var gen = doEval('%AsyncGenerator%');
1780
- if (gen) {
1781
- value = getProto(gen.prototype);
1782
- }
1783
- }
1784
-
1785
- INTRINSICS[name] = value;
1786
-
1787
- return value;
1788
- };
1789
-
1790
- var LEGACY_ALIASES = {
1791
- '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'],
1792
- '%ArrayPrototype%': ['Array', 'prototype'],
1793
- '%ArrayProto_entries%': ['Array', 'prototype', 'entries'],
1794
- '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'],
1795
- '%ArrayProto_keys%': ['Array', 'prototype', 'keys'],
1796
- '%ArrayProto_values%': ['Array', 'prototype', 'values'],
1797
- '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'],
1798
- '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'],
1799
- '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'],
1800
- '%BooleanPrototype%': ['Boolean', 'prototype'],
1801
- '%DataViewPrototype%': ['DataView', 'prototype'],
1802
- '%DatePrototype%': ['Date', 'prototype'],
1803
- '%ErrorPrototype%': ['Error', 'prototype'],
1804
- '%EvalErrorPrototype%': ['EvalError', 'prototype'],
1805
- '%Float32ArrayPrototype%': ['Float32Array', 'prototype'],
1806
- '%Float64ArrayPrototype%': ['Float64Array', 'prototype'],
1807
- '%FunctionPrototype%': ['Function', 'prototype'],
1808
- '%Generator%': ['GeneratorFunction', 'prototype'],
1809
- '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'],
1810
- '%Int8ArrayPrototype%': ['Int8Array', 'prototype'],
1811
- '%Int16ArrayPrototype%': ['Int16Array', 'prototype'],
1812
- '%Int32ArrayPrototype%': ['Int32Array', 'prototype'],
1813
- '%JSONParse%': ['JSON', 'parse'],
1814
- '%JSONStringify%': ['JSON', 'stringify'],
1815
- '%MapPrototype%': ['Map', 'prototype'],
1816
- '%NumberPrototype%': ['Number', 'prototype'],
1817
- '%ObjectPrototype%': ['Object', 'prototype'],
1818
- '%ObjProto_toString%': ['Object', 'prototype', 'toString'],
1819
- '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'],
1820
- '%PromisePrototype%': ['Promise', 'prototype'],
1821
- '%PromiseProto_then%': ['Promise', 'prototype', 'then'],
1822
- '%Promise_all%': ['Promise', 'all'],
1823
- '%Promise_reject%': ['Promise', 'reject'],
1824
- '%Promise_resolve%': ['Promise', 'resolve'],
1825
- '%RangeErrorPrototype%': ['RangeError', 'prototype'],
1826
- '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'],
1827
- '%RegExpPrototype%': ['RegExp', 'prototype'],
1828
- '%SetPrototype%': ['Set', 'prototype'],
1829
- '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'],
1830
- '%StringPrototype%': ['String', 'prototype'],
1831
- '%SymbolPrototype%': ['Symbol', 'prototype'],
1832
- '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'],
1833
- '%TypedArrayPrototype%': ['TypedArray', 'prototype'],
1834
- '%TypeErrorPrototype%': ['TypeError', 'prototype'],
1835
- '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'],
1836
- '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'],
1837
- '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'],
1838
- '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'],
1839
- '%URIErrorPrototype%': ['URIError', 'prototype'],
1840
- '%WeakMapPrototype%': ['WeakMap', 'prototype'],
1841
- '%WeakSetPrototype%': ['WeakSet', 'prototype']
1842
- };
1843
-
1844
-
1845
-
1846
- var $concat$2 = functionBind.call(Function.call, Array.prototype.concat);
1847
- var $spliceApply = functionBind.call(Function.apply, Array.prototype.splice);
1848
- var $replace = functionBind.call(Function.call, String.prototype.replace);
1849
- var $strSlice = functionBind.call(Function.call, String.prototype.slice);
1850
-
1851
- /* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */
1852
- var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
1853
- var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */
1854
- var stringToPath = function stringToPath(string) {
1855
- var first = $strSlice(string, 0, 1);
1856
- var last = $strSlice(string, -1);
1857
- if (first === '%' && last !== '%') {
1858
- throw new $SyntaxError$1('invalid intrinsic syntax, expected closing `%`');
1859
- } else if (last === '%' && first !== '%') {
1860
- throw new $SyntaxError$1('invalid intrinsic syntax, expected opening `%`');
1861
- }
1862
- var result = [];
1863
- $replace(string, rePropName, function (match, number, quote, subString) {
1864
- result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match;
1865
- });
1866
- return result;
1867
- };
1868
- /* end adaptation */
1869
-
1870
- var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) {
1871
- var intrinsicName = name;
1872
- var alias;
1873
- if (src(LEGACY_ALIASES, intrinsicName)) {
1874
- alias = LEGACY_ALIASES[intrinsicName];
1875
- intrinsicName = '%' + alias[0] + '%';
1876
- }
1877
-
1878
- if (src(INTRINSICS, intrinsicName)) {
1879
- var value = INTRINSICS[intrinsicName];
1880
- if (value === needsEval) {
1881
- value = doEval(intrinsicName);
1882
- }
1883
- if (typeof value === 'undefined' && !allowMissing) {
1884
- throw new $TypeError$5('intrinsic ' + name + ' exists, but is not available. Please file an issue!');
1885
- }
1886
-
1887
- return {
1888
- alias: alias,
1889
- name: intrinsicName,
1890
- value: value
1891
- };
1892
- }
1893
-
1894
- throw new $SyntaxError$1('intrinsic ' + name + ' does not exist!');
1895
- };
1896
-
1897
- var getIntrinsic = function GetIntrinsic(name, allowMissing) {
1898
- if (typeof name !== 'string' || name.length === 0) {
1899
- throw new $TypeError$5('intrinsic name must be a non-empty string');
1900
- }
1901
- if (arguments.length > 1 && typeof allowMissing !== 'boolean') {
1902
- throw new $TypeError$5('"allowMissing" argument must be a boolean');
1903
- }
1904
-
1905
- var parts = stringToPath(name);
1906
- var intrinsicBaseName = parts.length > 0 ? parts[0] : '';
1907
-
1908
- var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing);
1909
- var intrinsicRealName = intrinsic.name;
1910
- var value = intrinsic.value;
1911
- var skipFurtherCaching = false;
1912
-
1913
- var alias = intrinsic.alias;
1914
- if (alias) {
1915
- intrinsicBaseName = alias[0];
1916
- $spliceApply(parts, $concat$2([0, 1], alias));
1917
- }
1918
-
1919
- for (var i = 1, isOwn = true; i < parts.length; i += 1) {
1920
- var part = parts[i];
1921
- var first = $strSlice(part, 0, 1);
1922
- var last = $strSlice(part, -1);
1923
- if (
1924
- (
1925
- (first === '"' || first === "'" || first === '`')
1926
- || (last === '"' || last === "'" || last === '`')
1927
- )
1928
- && first !== last
1929
- ) {
1930
- throw new $SyntaxError$1('property names with quotes must have matching quotes');
1931
- }
1932
- if (part === 'constructor' || !isOwn) {
1933
- skipFurtherCaching = true;
1934
- }
1935
-
1936
- intrinsicBaseName += '.' + part;
1937
- intrinsicRealName = '%' + intrinsicBaseName + '%';
1938
-
1939
- if (src(INTRINSICS, intrinsicRealName)) {
1940
- value = INTRINSICS[intrinsicRealName];
1941
- } else if (value != null) {
1942
- if (!(part in value)) {
1943
- if (!allowMissing) {
1944
- throw new $TypeError$5('base intrinsic for ' + name + ' exists, but the property is not available.');
1945
- }
1946
- return void undefined$1;
1947
- }
1948
- if ($gOPD$2 && (i + 1) >= parts.length) {
1949
- var desc = $gOPD$2(value, part);
1950
- isOwn = !!desc;
1951
-
1952
- // By convention, when a data property is converted to an accessor
1953
- // property to emulate a data property that does not suffer from
1954
- // the override mistake, that accessor's getter is marked with
1955
- // an `originalValue` property. Here, when we detect this, we
1956
- // uphold the illusion by pretending to see that original data
1957
- // property, i.e., returning the value rather than the getter
1958
- // itself.
1959
- if (isOwn && 'get' in desc && !('originalValue' in desc.get)) {
1960
- value = desc.get;
1961
- } else {
1962
- value = value[part];
1963
- }
1964
- } else {
1965
- isOwn = src(value, part);
1966
- value = value[part];
1967
- }
1968
-
1969
- if (isOwn && !skipFurtherCaching) {
1970
- INTRINSICS[intrinsicRealName] = value;
1971
- }
1972
- }
1973
- }
1974
- return value;
1975
- };
1976
-
1977
- var callBind = createCommonjsModule(function (module) {
1978
-
1979
-
1980
-
1981
-
1982
- var $apply = getIntrinsic('%Function.prototype.apply%');
1983
- var $call = getIntrinsic('%Function.prototype.call%');
1984
- var $reflectApply = getIntrinsic('%Reflect.apply%', true) || functionBind.call($call, $apply);
1985
-
1986
- var $gOPD = getIntrinsic('%Object.getOwnPropertyDescriptor%', true);
1987
- var $defineProperty = getIntrinsic('%Object.defineProperty%', true);
1988
- var $max = getIntrinsic('%Math.max%');
1989
-
1990
- if ($defineProperty) {
1991
- try {
1992
- $defineProperty({}, 'a', { value: 1 });
1993
- } catch (e) {
1994
- // IE 8 has a broken defineProperty
1995
- $defineProperty = null;
1996
- }
1997
- }
1998
-
1999
- module.exports = function callBind(originalFunction) {
2000
- var func = $reflectApply(functionBind, $call, arguments);
2001
- if ($gOPD && $defineProperty) {
2002
- var desc = $gOPD(func, 'length');
2003
- if (desc.configurable) {
2004
- // original length, plus the receiver, minus any additional arguments (after the receiver)
2005
- $defineProperty(
2006
- func,
2007
- 'length',
2008
- { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) }
2009
- );
2010
- }
2011
- }
2012
- return func;
2013
- };
2014
-
2015
- var applyBind = function applyBind() {
2016
- return $reflectApply(functionBind, $apply, arguments);
2017
- };
2018
-
2019
- if ($defineProperty) {
2020
- $defineProperty(module.exports, 'apply', { value: applyBind });
2021
- } else {
2022
- module.exports.apply = applyBind;
2023
- }
2024
- });
2025
- callBind.apply;
2026
-
2027
- var $indexOf = callBind(getIntrinsic('String.prototype.indexOf'));
2028
-
2029
- var callBound$1 = function callBoundIntrinsic(name, allowMissing) {
2030
- var intrinsic = getIntrinsic(name, !!allowMissing);
2031
- if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) {
2032
- return callBind(intrinsic);
2033
- }
2034
- return intrinsic;
2035
- };
2036
-
2037
- var $defineProperty = getIntrinsic('%Object.defineProperty%', true);
2038
-
2039
- if ($defineProperty) {
2040
- try {
2041
- $defineProperty({}, 'a', { value: 1 });
2042
- } catch (e) {
2043
- // IE 8 has a broken defineProperty
2044
- $defineProperty = null;
2045
- }
2046
- }
2047
-
2048
-
2049
-
2050
- var $isEnumerable$1 = callBound$1('Object.prototype.propertyIsEnumerable');
2051
-
2052
- // eslint-disable-next-line max-params
2053
- var DefineOwnProperty = function DefineOwnProperty(IsDataDescriptor, SameValue, FromPropertyDescriptor, O, P, desc) {
2054
- if (!$defineProperty) {
2055
- if (!IsDataDescriptor(desc)) {
2056
- // ES3 does not support getters/setters
2057
- return false;
2058
- }
2059
- if (!desc['[[Configurable]]'] || !desc['[[Writable]]']) {
2060
- return false;
2061
- }
2062
-
2063
- // fallback for ES3
2064
- if (P in O && $isEnumerable$1(O, P) !== !!desc['[[Enumerable]]']) {
2065
- // a non-enumerable existing property
2066
- return false;
2067
- }
2068
-
2069
- // property does not exist at all, or exists but is enumerable
2070
- var V = desc['[[Value]]'];
2071
- // eslint-disable-next-line no-param-reassign
2072
- O[P] = V; // will use [[Define]]
2073
- return SameValue(O[P], V);
2074
- }
2075
- $defineProperty(O, P, FromPropertyDescriptor(desc));
2076
- return true;
2077
- };
2078
-
2079
- var $TypeError$4 = getIntrinsic('%TypeError%');
2080
- var $SyntaxError = getIntrinsic('%SyntaxError%');
2081
-
2082
-
2083
-
2084
- var predicates = {
2085
- // https://262.ecma-international.org/6.0/#sec-property-descriptor-specification-type
2086
- 'Property Descriptor': function isPropertyDescriptor(Type, Desc) {
2087
- if (Type(Desc) !== 'Object') {
2088
- return false;
2089
- }
2090
- var allowed = {
2091
- '[[Configurable]]': true,
2092
- '[[Enumerable]]': true,
2093
- '[[Get]]': true,
2094
- '[[Set]]': true,
2095
- '[[Value]]': true,
2096
- '[[Writable]]': true
2097
- };
2098
-
2099
- for (var key in Desc) { // eslint-disable-line
2100
- if (src(Desc, key) && !allowed[key]) {
2101
- return false;
2102
- }
2103
- }
2104
-
2105
- var isData = src(Desc, '[[Value]]');
2106
- var IsAccessor = src(Desc, '[[Get]]') || src(Desc, '[[Set]]');
2107
- if (isData && IsAccessor) {
2108
- throw new $TypeError$4('Property Descriptors may not be both accessor and data descriptors');
2109
- }
2110
- return true;
2111
- }
2112
- };
2113
-
2114
- var assertRecord = function assertRecord(Type, recordType, argumentName, value) {
2115
- var predicate = predicates[recordType];
2116
- if (typeof predicate !== 'function') {
2117
- throw new $SyntaxError('unknown record type: ' + recordType);
2118
- }
2119
- if (!predicate(Type, value)) {
2120
- throw new $TypeError$4(argumentName + ' must be a ' + recordType);
2121
- }
2122
- };
2123
-
2124
- // https://262.ecma-international.org/5.1/#sec-8
2125
-
2126
- var Type$1 = function Type(x) {
2127
- if (x === null) {
2128
- return 'Null';
2129
- }
2130
- if (typeof x === 'undefined') {
2131
- return 'Undefined';
2132
- }
2133
- if (typeof x === 'function' || typeof x === 'object') {
2134
- return 'Object';
2135
- }
2136
- if (typeof x === 'number') {
2137
- return 'Number';
2138
- }
2139
- if (typeof x === 'boolean') {
2140
- return 'Boolean';
2141
- }
2142
- if (typeof x === 'string') {
2143
- return 'String';
2144
- }
2145
- };
2146
-
2147
- // https://262.ecma-international.org/11.0/#sec-ecmascript-data-types-and-values
2148
-
2149
- var Type = function Type(x) {
2150
- if (typeof x === 'symbol') {
2151
- return 'Symbol';
2152
- }
2153
- if (typeof x === 'bigint') {
2154
- return 'BigInt';
2155
- }
2156
- return Type$1(x);
2157
- };
2158
-
2159
- // https://ecma-international.org/ecma-262/6.0/#sec-frompropertydescriptor
2160
-
2161
- var FromPropertyDescriptor = function FromPropertyDescriptor(Desc) {
2162
- if (typeof Desc === 'undefined') {
2163
- return Desc;
2164
- }
2165
-
2166
- assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
2167
-
2168
- var obj = {};
2169
- if ('[[Value]]' in Desc) {
2170
- obj.value = Desc['[[Value]]'];
2171
- }
2172
- if ('[[Writable]]' in Desc) {
2173
- obj.writable = Desc['[[Writable]]'];
2174
- }
2175
- if ('[[Get]]' in Desc) {
2176
- obj.get = Desc['[[Get]]'];
2177
- }
2178
- if ('[[Set]]' in Desc) {
2179
- obj.set = Desc['[[Set]]'];
2180
- }
2181
- if ('[[Enumerable]]' in Desc) {
2182
- obj.enumerable = Desc['[[Enumerable]]'];
2183
- }
2184
- if ('[[Configurable]]' in Desc) {
2185
- obj.configurable = Desc['[[Configurable]]'];
2186
- }
2187
- return obj;
2188
- };
2189
-
2190
- var $gOPD$1 = getIntrinsic('%Object.getOwnPropertyDescriptor%');
2191
- if ($gOPD$1) {
2192
- try {
2193
- $gOPD$1([], 'length');
2194
- } catch (e) {
2195
- // IE 8 has a broken gOPD
2196
- $gOPD$1 = null;
2197
- }
2198
- }
2199
-
2200
- var getOwnPropertyDescriptor = $gOPD$1;
2201
-
2202
- var $Array = getIntrinsic('%Array%');
2203
-
2204
- // eslint-disable-next-line global-require
2205
- var toStr$1 = !$Array.isArray && callBound$1('Object.prototype.toString');
2206
-
2207
- // https://ecma-international.org/ecma-262/6.0/#sec-isarray
2208
-
2209
- var IsArray = $Array.isArray || function IsArray(argument) {
2210
- return toStr$1(argument) === '[object Array]';
2211
- };
2212
-
2213
- // https://ecma-international.org/ecma-262/6.0/#sec-ispropertykey
2214
-
2215
- var IsPropertyKey = function IsPropertyKey(argument) {
2216
- return typeof argument === 'string' || typeof argument === 'symbol';
2217
- };
2218
-
2219
- var hasSymbols$1 = shams();
2220
- var hasToStringTag$1 = hasSymbols$1 && !!Symbol.toStringTag;
2221
- var has;
2222
- var $exec;
2223
- var isRegexMarker;
2224
- var badStringifier;
2225
-
2226
- if (hasToStringTag$1) {
2227
- has = callBound$1('Object.prototype.hasOwnProperty');
2228
- $exec = callBound$1('RegExp.prototype.exec');
2229
- isRegexMarker = {};
2230
-
2231
- var throwRegexMarker = function () {
2232
- throw isRegexMarker;
2233
- };
2234
- badStringifier = {
2235
- toString: throwRegexMarker,
2236
- valueOf: throwRegexMarker
2237
- };
2238
-
2239
- if (typeof Symbol.toPrimitive === 'symbol') {
2240
- badStringifier[Symbol.toPrimitive] = throwRegexMarker;
2241
- }
2242
- }
2243
-
2244
- var $toString = callBound$1('Object.prototype.toString');
2245
- var gOPD = Object.getOwnPropertyDescriptor;
2246
- var regexClass = '[object RegExp]';
2247
-
2248
- var isRegex = hasToStringTag$1
2249
- // eslint-disable-next-line consistent-return
2250
- ? function isRegex(value) {
2251
- if (!value || typeof value !== 'object') {
2252
- return false;
2253
- }
2254
-
2255
- var descriptor = gOPD(value, 'lastIndex');
2256
- var hasLastIndexDataProperty = descriptor && has(descriptor, 'value');
2257
- if (!hasLastIndexDataProperty) {
2258
- return false;
2259
- }
2260
-
2261
- try {
2262
- $exec(value, badStringifier);
2263
- } catch (e) {
2264
- return e === isRegexMarker;
2265
- }
2266
- }
2267
- : function isRegex(value) {
2268
- // In older browsers, typeof regex incorrectly returns 'function'
2269
- if (!value || (typeof value !== 'object' && typeof value !== 'function')) {
2270
- return false;
2271
- }
2272
-
2273
- return $toString(value) === regexClass;
2274
- };
2275
-
2276
- // http://262.ecma-international.org/5.1/#sec-9.2
2277
-
2278
- var ToBoolean = function ToBoolean(value) { return !!value; };
2279
-
2280
- var $match = getIntrinsic('%Symbol.match%', true);
2281
-
2282
-
2283
-
2284
-
2285
-
2286
- // https://ecma-international.org/ecma-262/6.0/#sec-isregexp
2287
-
2288
- var IsRegExp = function IsRegExp(argument) {
2289
- if (!argument || typeof argument !== 'object') {
2290
- return false;
2291
- }
2292
- if ($match) {
2293
- var isRegExp = argument[$match];
2294
- if (typeof isRegExp !== 'undefined') {
2295
- return ToBoolean(isRegExp);
2296
- }
2297
- }
2298
- return isRegex(argument);
2299
- };
2300
-
2301
- var fnToStr = Function.prototype.toString;
2302
- var reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply;
2303
- var badArrayLike;
2304
- var isCallableMarker;
2305
- if (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') {
2306
- try {
2307
- badArrayLike = Object.defineProperty({}, 'length', {
2308
- get: function () {
2309
- throw isCallableMarker;
2310
- }
2311
- });
2312
- isCallableMarker = {};
2313
- // eslint-disable-next-line no-throw-literal
2314
- reflectApply(function () { throw 42; }, null, badArrayLike);
2315
- } catch (_) {
2316
- if (_ !== isCallableMarker) {
2317
- reflectApply = null;
2318
- }
2319
- }
2320
- } else {
2321
- reflectApply = null;
2322
- }
2323
-
2324
- var constructorRegex = /^\s*class\b/;
2325
- var isES6ClassFn = function isES6ClassFunction(value) {
2326
- try {
2327
- var fnStr = fnToStr.call(value);
2328
- return constructorRegex.test(fnStr);
2329
- } catch (e) {
2330
- return false; // not a function
2331
- }
2332
- };
2333
-
2334
- var tryFunctionObject = function tryFunctionToStr(value) {
2335
- try {
2336
- if (isES6ClassFn(value)) { return false; }
2337
- fnToStr.call(value);
2338
- return true;
2339
- } catch (e) {
2340
- return false;
2341
- }
2342
- };
2343
- var toStr = Object.prototype.toString;
2344
- var fnClass = '[object Function]';
2345
- var genClass = '[object GeneratorFunction]';
2346
- var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol';
2347
- /* globals document: false */
2348
- var documentDotAll = typeof document === 'object' && typeof document.all === 'undefined' && document.all !== undefined ? document.all : {};
2349
-
2350
- var isCallable = reflectApply
2351
- ? function isCallable(value) {
2352
- if (value === documentDotAll) { return true; }
2353
- if (!value) { return false; }
2354
- if (typeof value !== 'function' && typeof value !== 'object') { return false; }
2355
- if (typeof value === 'function' && !value.prototype) { return true; }
2356
- try {
2357
- reflectApply(value, null, badArrayLike);
2358
- } catch (e) {
2359
- if (e !== isCallableMarker) { return false; }
2360
- }
2361
- return !isES6ClassFn(value);
2362
- }
2363
- : function isCallable(value) {
2364
- if (value === documentDotAll) { return true; }
2365
- if (!value) { return false; }
2366
- if (typeof value !== 'function' && typeof value !== 'object') { return false; }
2367
- if (typeof value === 'function' && !value.prototype) { return true; }
2368
- if (hasToStringTag) { return tryFunctionObject(value); }
2369
- if (isES6ClassFn(value)) { return false; }
2370
- var strClass = toStr.call(value);
2371
- return strClass === fnClass || strClass === genClass;
2372
- };
2373
-
2374
- // http://262.ecma-international.org/5.1/#sec-9.11
2375
-
2376
- var IsCallable = isCallable;
2377
-
2378
- var $TypeError$3 = getIntrinsic('%TypeError%');
2379
-
2380
-
2381
-
2382
-
2383
-
2384
- // https://262.ecma-international.org/5.1/#sec-8.10.5
2385
-
2386
- var ToPropertyDescriptor = function ToPropertyDescriptor(Obj) {
2387
- if (Type(Obj) !== 'Object') {
2388
- throw new $TypeError$3('ToPropertyDescriptor requires an object');
2389
- }
2390
-
2391
- var desc = {};
2392
- if (src(Obj, 'enumerable')) {
2393
- desc['[[Enumerable]]'] = ToBoolean(Obj.enumerable);
2394
- }
2395
- if (src(Obj, 'configurable')) {
2396
- desc['[[Configurable]]'] = ToBoolean(Obj.configurable);
2397
- }
2398
- if (src(Obj, 'value')) {
2399
- desc['[[Value]]'] = Obj.value;
2400
- }
2401
- if (src(Obj, 'writable')) {
2402
- desc['[[Writable]]'] = ToBoolean(Obj.writable);
2403
- }
2404
- if (src(Obj, 'get')) {
2405
- var getter = Obj.get;
2406
- if (typeof getter !== 'undefined' && !IsCallable(getter)) {
2407
- throw new $TypeError$3('getter must be a function');
2408
- }
2409
- desc['[[Get]]'] = getter;
2410
- }
2411
- if (src(Obj, 'set')) {
2412
- var setter = Obj.set;
2413
- if (typeof setter !== 'undefined' && !IsCallable(setter)) {
2414
- throw new $TypeError$3('setter must be a function');
2415
- }
2416
- desc['[[Set]]'] = setter;
2417
- }
2418
-
2419
- if ((src(desc, '[[Get]]') || src(desc, '[[Set]]')) && (src(desc, '[[Value]]') || src(desc, '[[Writable]]'))) {
2420
- throw new $TypeError$3('Invalid property descriptor. Cannot both specify accessors and a value or writable attribute');
2421
- }
2422
- return desc;
2423
- };
2424
-
2425
- var $TypeError$2 = getIntrinsic('%TypeError%');
2426
-
2427
-
2428
-
2429
- var $isEnumerable = callBound$1('Object.prototype.propertyIsEnumerable');
2430
-
2431
-
2432
-
2433
-
2434
-
2435
-
2436
-
2437
-
2438
-
2439
- // https://ecma-international.org/ecma-262/6.0/#sec-ordinarygetownproperty
2440
-
2441
- var OrdinaryGetOwnProperty = function OrdinaryGetOwnProperty(O, P) {
2442
- if (Type(O) !== 'Object') {
2443
- throw new $TypeError$2('Assertion failed: O must be an Object');
2444
- }
2445
- if (!IsPropertyKey(P)) {
2446
- throw new $TypeError$2('Assertion failed: P must be a Property Key');
2447
- }
2448
- if (!src(O, P)) {
2449
- return void 0;
2450
- }
2451
- if (!getOwnPropertyDescriptor) {
2452
- // ES3 / IE 8 fallback
2453
- var arrayLength = IsArray(O) && P === 'length';
2454
- var regexLastIndex = IsRegExp(O) && P === 'lastIndex';
2455
- return {
2456
- '[[Configurable]]': !(arrayLength || regexLastIndex),
2457
- '[[Enumerable]]': $isEnumerable(O, P),
2458
- '[[Value]]': O[P],
2459
- '[[Writable]]': true
2460
- };
2461
- }
2462
- return ToPropertyDescriptor(getOwnPropertyDescriptor(O, P));
2463
- };
2464
-
2465
- // https://ecma-international.org/ecma-262/6.0/#sec-isdatadescriptor
2466
-
2467
- var IsDataDescriptor = function IsDataDescriptor(Desc) {
2468
- if (typeof Desc === 'undefined') {
2469
- return false;
2470
- }
2471
-
2472
- assertRecord(Type, 'Property Descriptor', 'Desc', Desc);
2473
-
2474
- if (!src(Desc, '[[Value]]') && !src(Desc, '[[Writable]]')) {
2475
- return false;
2476
- }
2477
-
2478
- return true;
2479
- };
2480
-
2481
- var isPrimitive = function isPrimitive(value) {
2482
- return value === null || (typeof value !== 'function' && typeof value !== 'object');
2483
- };
2484
-
2485
- var $Object$1 = getIntrinsic('%Object%');
2486
-
2487
-
2488
-
2489
- var $preventExtensions = $Object$1.preventExtensions;
2490
- var $isExtensible = $Object$1.isExtensible;
2491
-
2492
- // https://ecma-international.org/ecma-262/6.0/#sec-isextensible-o
2493
-
2494
- var IsExtensible = $preventExtensions
2495
- ? function IsExtensible(obj) {
2496
- return !isPrimitive(obj) && $isExtensible(obj);
2497
- }
2498
- : function IsExtensible(obj) {
2499
- return !isPrimitive(obj);
2500
- };
2501
-
2502
- var _isNaN = Number.isNaN || function isNaN(a) {
2503
- return a !== a;
2504
- };
2505
-
2506
- // http://262.ecma-international.org/5.1/#sec-9.12
2507
-
2508
- var SameValue = function SameValue(x, y) {
2509
- if (x === y) { // 0 === -0, but they are not identical.
2510
- if (x === 0) { return 1 / x === 1 / y; }
2511
- return true;
2512
- }
2513
- return _isNaN(x) && _isNaN(y);
2514
- };
2515
-
2516
- var $TypeError$1 = getIntrinsic('%TypeError%');
2517
-
2518
-
2519
-
2520
-
2521
-
2522
-
2523
-
2524
-
2525
-
2526
-
2527
-
2528
- // https://ecma-international.org/ecma-262/6.0/#sec-createdataproperty
2529
-
2530
- var CreateDataProperty = function CreateDataProperty(O, P, V) {
2531
- if (Type(O) !== 'Object') {
2532
- throw new $TypeError$1('Assertion failed: Type(O) is not Object');
2533
- }
2534
- if (!IsPropertyKey(P)) {
2535
- throw new $TypeError$1('Assertion failed: IsPropertyKey(P) is not true');
2536
- }
2537
- var oldDesc = OrdinaryGetOwnProperty(O, P);
2538
- var extensible = !oldDesc || IsExtensible(O);
2539
- var immutable = oldDesc && (!oldDesc['[[Writable]]'] || !oldDesc['[[Configurable]]']);
2540
- if (immutable || !extensible) {
2541
- return false;
2542
- }
2543
- return DefineOwnProperty(
2544
- IsDataDescriptor,
2545
- SameValue,
2546
- FromPropertyDescriptor,
2547
- O,
2548
- P,
2549
- {
2550
- '[[Configurable]]': true,
2551
- '[[Enumerable]]': true,
2552
- '[[Value]]': V,
2553
- '[[Writable]]': true
2554
- }
2555
- );
2556
- };
2557
-
2558
- var $TypeError = getIntrinsic('%TypeError%');
2559
-
2560
- // http://262.ecma-international.org/5.1/#sec-9.10
2561
-
2562
- var CheckObjectCoercible = function CheckObjectCoercible(value, optMessage) {
2563
- if (value == null) {
2564
- throw new $TypeError(optMessage || ('Cannot call method on ' + value));
2565
- }
2566
- return value;
2567
- };
2568
-
2569
- var RequireObjectCoercible = CheckObjectCoercible;
2570
-
2571
- var $Object = getIntrinsic('%Object%');
2572
-
2573
-
2574
-
2575
- // https://ecma-international.org/ecma-262/6.0/#sec-toobject
2576
-
2577
- var ToObject = function ToObject(value) {
2578
- RequireObjectCoercible(value);
2579
- return $Object(value);
2580
- };
2581
-
2582
- var $gOPD = Object.getOwnPropertyDescriptor;
2583
- var $getOwnNames = Object.getOwnPropertyNames;
2584
- var $getSymbols = Object.getOwnPropertySymbols;
2585
- var $concat$1 = callBound$1('Array.prototype.concat');
2586
- var $reduce = callBound$1('Array.prototype.reduce');
2587
- var getAll = $getSymbols ? function (obj) {
2588
- return $concat$1($getOwnNames(obj), $getSymbols(obj));
2589
- } : $getOwnNames;
2590
-
2591
- var isES5$1 = IsCallable($gOPD) && IsCallable($getOwnNames);
2592
-
2593
- var implementation$1 = function getOwnPropertyDescriptors(value) {
2594
- RequireObjectCoercible(value);
2595
- if (!isES5$1) {
2596
- throw new TypeError('getOwnPropertyDescriptors requires Object.getOwnPropertyDescriptor');
2597
- }
2598
-
2599
- var O = ToObject(value);
2600
- return $reduce(
2601
- getAll(O),
2602
- function (acc, key) {
2603
- var descriptor = $gOPD(O, key);
2604
- if (typeof descriptor !== 'undefined') {
2605
- CreateDataProperty(acc, key, descriptor);
2606
- }
2607
- return acc;
2608
- },
2609
- {}
2610
- );
2611
- };
2612
-
2613
- var polyfill$2 = function getPolyfill() {
2614
- return typeof Object.getOwnPropertyDescriptors === 'function' ? Object.getOwnPropertyDescriptors : implementation$1;
2615
- };
2616
-
2617
- var shim$1 = function shimGetOwnPropertyDescriptors() {
2618
- var polyfill = polyfill$2();
2619
- defineProperties_1(
2620
- Object,
2621
- { getOwnPropertyDescriptors: polyfill },
2622
- { getOwnPropertyDescriptors: function () { return Object.getOwnPropertyDescriptors !== polyfill; } }
2623
- );
2624
- return polyfill;
2625
- };
2626
-
2627
- var bound = callBind(polyfill$2(), Object);
2628
-
2629
- defineProperties_1(bound, {
2630
- getPolyfill: polyfill$2,
2631
- implementation: implementation$1,
2632
- shim: shim$1
2633
- });
2634
-
2635
- var object_getownpropertydescriptors = bound;
2636
-
2637
- // TODO; semver-major: remove
2638
-
2639
- var callBound = callBound$1;
2640
-
2641
- var isES5 = typeof Object.defineProperty === 'function'
2642
- && typeof Object.defineProperties === 'function';
2643
-
2644
- var hasProto = [].__proto__ === Array.prototype; // eslint-disable-line no-proto
2645
-
2646
- if (!isES5 || !hasProto) {
2647
- throw new TypeError('util.promisify requires a true ES5 environment, that also supports `__proto__`');
2648
- }
2649
-
2650
-
2651
-
2652
- if (typeof Promise !== 'function') {
2653
- throw new TypeError('`Promise` must be globally available for util.promisify to work.');
2654
- }
2655
-
2656
-
2657
-
2658
- var $slice = callBound('Array.prototype.slice');
2659
- var $concat = callBound('Array.prototype.concat');
2660
- var $forEach = callBound('Array.prototype.forEach');
2661
-
2662
- var hasSymbols = hasSymbols$3();
2663
-
2664
- var kCustomPromisifiedSymbol = hasSymbols ? Symbol('util.promisify.custom') : null;
2665
- var kCustomPromisifyArgsSymbol = hasSymbols ? Symbol('customPromisifyArgs') : null;
2666
-
2667
- var implementation = function promisify(orig) {
2668
- if (typeof orig !== 'function') {
2669
- var error = new TypeError('The "original" argument must be of type function');
2670
- error.name = 'TypeError [ERR_INVALID_ARG_TYPE]';
2671
- error.code = 'ERR_INVALID_ARG_TYPE';
2672
- throw error;
2673
- }
2674
-
2675
- if (hasSymbols && orig[kCustomPromisifiedSymbol]) {
2676
- var customFunction = orig[kCustomPromisifiedSymbol];
2677
- if (typeof customFunction !== 'function') {
2678
- throw new TypeError('The [util.promisify.custom] property must be a function');
2679
- }
2680
- Object.defineProperty(customFunction, kCustomPromisifiedSymbol, {
2681
- configurable: true,
2682
- enumerable: false,
2683
- value: customFunction,
2684
- writable: false
2685
- });
2686
- return customFunction;
2687
- }
2688
-
2689
- // Names to create an object from in case the callback receives multiple
2690
- // arguments, e.g. ['stdout', 'stderr'] for child_process.exec.
2691
- var argumentNames = orig[kCustomPromisifyArgsSymbol];
2692
-
2693
- var promisified = function fn() {
2694
- var args = $slice(arguments);
2695
- var self = this; // eslint-disable-line no-invalid-this
2696
- return new Promise(function (resolve, reject) {
2697
- orig.apply(self, $concat(args, function (err) {
2698
- var values = arguments.length > 1 ? $slice(arguments, 1) : [];
2699
- if (err) {
2700
- reject(err);
2701
- } else if (typeof argumentNames !== 'undefined' && values.length > 1) {
2702
- var obj = {};
2703
- $forEach(argumentNames, function (name, index) {
2704
- obj[name] = values[index];
2705
- });
2706
- resolve(obj);
2707
- } else {
2708
- resolve(values[0]);
2709
- }
2710
- }));
2711
- });
2712
- };
2713
-
2714
- promisified.__proto__ = orig.__proto__; // eslint-disable-line no-proto
2715
-
2716
- Object.defineProperty(promisified, kCustomPromisifiedSymbol, {
2717
- configurable: true,
2718
- enumerable: false,
2719
- value: promisified,
2720
- writable: false
2721
- });
2722
- return Object.defineProperties(promisified, object_getownpropertydescriptors(orig));
2723
- };
2724
-
2725
- var custom = kCustomPromisifiedSymbol;
2726
- var customPromisifyArgs = kCustomPromisifyArgsSymbol;
2727
- implementation.custom = custom;
2728
- implementation.customPromisifyArgs = customPromisifyArgs;
2729
-
2730
- var polyfill$1 = function getPolyfill() {
2731
- if (typeof util.promisify === 'function') {
2732
- return util.promisify;
2733
- }
2734
- return implementation;
2735
- };
2736
-
2737
- var shim = function shimUtilPromisify() {
2738
- var polyfill = polyfill$1();
2739
- if (polyfill !== util.promisify) {
2740
- Object.defineProperty(util, 'promisify', {
2741
- configurable: true,
2742
- enumerable: true,
2743
- value: polyfill,
2744
- writable: true
2745
- });
2746
- }
2747
- return polyfill;
2748
- };
2749
-
2750
- var polyfill = polyfill$1();
2751
-
2752
-
2753
- /* eslint-disable no-unused-vars */
2754
- var boundPromisify = function promisify(orig) {
2755
- /* eslint-enable no-unused-vars */
2756
- return polyfill.apply(util, arguments);
2757
- };
2758
- defineProperties_1(boundPromisify, {
2759
- custom: polyfill.custom,
2760
- customPromisifyArgs: polyfill.customPromisifyArgs,
2761
- getPolyfill: polyfill$1,
2762
- implementation: implementation,
2763
- shim: shim
2764
- });
2765
-
2766
- var util_promisify = boundPromisify;
2767
-
2768
- util_promisify.shim();
2769
-
2770
- function connect() {
2771
- var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2772
-
2773
- if (!config) {
2774
- config = {
2775
- host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
2776
- user: 'nasp',
2777
- password: 'uRNkF9SkfXQs6AKK',
2778
- database: 'user'
2779
- };
2780
- }
2781
-
2782
- var connection = mysql.createConnection(config);
2783
- return {
2784
- query: function query(sql, args) {
2785
- return util.promisify(connection.query).call(connection, sql, args);
2786
- },
2787
- beginTransaction: function beginTransaction() {
2788
- return util.promisify(connection.beginTransaction).call(connection);
2789
- },
2790
- commit: function commit() {
2791
- return util.promisify(connection.commit).call(connection);
2792
- },
2793
- rollback: function rollback() {
2794
- return util.promisify(connection.rollback).call(connection);
2795
- },
2796
- close: function close() {
2797
- return util.promisify(connection.end).call(connection);
2798
- }
2799
- };
2800
- }
2801
-
2802
- var db = connect;
2803
-
2804
- var _this$1 = undefined;
2805
-
2806
- var config$1 = {
2807
- host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
2808
- user: 'nasp',
2809
- password: 'uRNkF9SkfXQs6AKK',
2810
- database: 'user'
2811
- };
2812
-
2813
- var findUser$1 = function () {
2814
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(email) {
2815
- var password = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
2816
- var db$1, query, res, user, hash, passwordsMatch, user_shared, occupation_id;
2817
- return regenerator.wrap(function _callee$(_context) {
2818
- while (1) {
2819
- switch (_context.prev = _context.next) {
2820
- case 0:
2821
- db$1 = null;
2822
- _context.prev = 1;
2823
-
2824
-
2825
- db$1 = db(config$1);
2826
-
2827
- query = '\n select * \n from user \n where trim(lower(email)) = ?\n ';
2828
- _context.next = 6;
2829
- return db$1.query(query, [email.toLowerCase().trim()]);
2830
-
2831
- case 6:
2832
- res = _context.sent;
2833
- user = res.length > 0 ? res[0] : null;
2834
-
2835
- if (user) {
2836
- _context.next = 10;
2837
- break;
2838
- }
2839
-
2840
- throw new Error('Invalid credential provided');
2841
-
2842
- case 10:
2843
- if (!password) {
2844
- _context.next = 15;
2845
- break;
2846
- }
2847
-
2848
- hash = md5(password);
2849
- passwordsMatch = hash === user.password;
2850
-
2851
- if (passwordsMatch) {
2852
- _context.next = 15;
2853
- break;
2854
- }
2855
-
2856
- throw new Error('Password doesn\'t match');
2857
-
2858
- case 15:
2859
-
2860
- query = '\n select * \n from user_shared \n where user_id = ?\n ';
2861
- _context.next = 18;
2862
- return db$1.query(query, [user.id]);
2863
-
2864
- case 18:
2865
- res = _context.sent;
2866
- user_shared = res.length > 0 ? res[0] : null;
2867
-
2868
- user.shared = user_shared;
2869
-
2870
- // occupation
2871
- query = '\n select id \n from occupation \n where name = ?\n ';
2872
- _context.next = 24;
2873
- return db$1.query(query, [user_shared.occupation]);
2874
-
2875
- case 24:
2876
- res = _context.sent;
2877
- occupation_id = res.length > 0 ? res[0].id : '';
2878
-
2879
- user.shared.occupation_id = occupation_id;
2880
-
2881
- _context.next = 29;
2882
- return db$1.close();
2883
-
2884
- case 29:
2885
- return _context.abrupt('return', {
2886
- error: '',
2887
- user: user
2888
- });
2889
-
2890
- case 32:
2891
- _context.prev = 32;
2892
- _context.t0 = _context['catch'](1);
2893
-
2894
- if (!db$1) {
2895
- _context.next = 37;
2896
- break;
2897
- }
2898
-
2899
- _context.next = 37;
2900
- return db$1.close();
2901
-
2902
- case 37:
2903
- return _context.abrupt('return', {
2904
- error: _context.t0.message,
2905
- user: null
2906
- });
2907
-
2908
- case 38:
2909
- case 'end':
2910
- return _context.stop();
2911
- }
2912
- }
2913
- }, _callee, this, [[1, 32]]);
2914
- }));
2915
-
2916
- return function findUser(_x) {
2917
- return _ref.apply(this, arguments);
2918
- };
2919
- }();
2920
-
2921
- var updateUser$1 = function () {
2922
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(data) {
2923
- var db$1, query, res, hash, columns, i, column, occupation_name;
2924
- return regenerator.wrap(function _callee2$(_context2) {
2925
- while (1) {
2926
- switch (_context2.prev = _context2.next) {
2927
- case 0:
2928
- db$1 = null;
2929
- _context2.prev = 1;
2930
-
2931
-
2932
- validateUserData(data);
2933
-
2934
- db$1 = db(config$1);
2935
-
2936
- _context2.next = 6;
2937
- return db$1.beginTransaction();
2938
-
2939
- case 6:
2940
- if (data.user_id) {
2941
- _context2.next = 8;
2942
- break;
2943
- }
2944
-
2945
- throw new Error('Please provide user ID');
2946
-
2947
- case 8:
2948
-
2949
- data.email = data.email.toLowerCase().trim();
2950
-
2951
- // check if new email is taken
2952
- query = '\n select * \n from user \n where lower(trim(email)) = ?\n and id != ?\n ';
2953
- _context2.next = 12;
2954
- return db$1.query(query, [data.email, data.user_id]);
2955
-
2956
- case 12:
2957
- res = _context2.sent;
2958
-
2959
- if (!(res && res.length > 0)) {
2960
- _context2.next = 15;
2961
- break;
2962
- }
2963
-
2964
- throw new Error('Email already taken');
2965
-
2966
- case 15:
2967
- if (!data.password) {
2968
- _context2.next = 23;
2969
- break;
2970
- }
2971
-
2972
- hash = md5(data.password);
2973
-
2974
- query = '\n update user \n set password = ?\n where user_id = ?\n ';
2975
- _context2.next = 20;
2976
- return db$1.query(query, [hash, data.user_id]);
2977
-
2978
- case 20:
2979
- res = _context2.sent;
2980
-
2981
- if (!(!res || res.affectedRows < 1)) {
2982
- _context2.next = 23;
2983
- break;
2984
- }
2985
-
2986
- throw new Error('Failed to update password');
2987
-
2988
- case 23:
2989
-
2990
- query = 'show columns from user_shared';
2991
- _context2.next = 26;
2992
- return db$1.query(query);
2993
-
2994
- case 26:
2995
- columns = _context2.sent;
2996
-
2997
-
2998
- for (i = 0; i < columns.length; i++) {
2999
- column = columns[i].Field;
3000
-
3001
- if (typeof data[column] === 'undefined') {
3002
- data[column] = '';
3003
- }
3004
- }
3005
-
3006
- // user_shared
3007
- query = '\n update user_shared\n set \n first_name = ?,\n last_name = ?,\n country = ?,\n city = ?,\n state = ?,\n zip = ?,\n phone = ?,\n occupation = ?,\n primary_specialty = ?,\n area_of_practice = ?,\n work_place = ?,\n graduation_year = ?,\n medical_school = ?,\n npi = ?,\n role = ?,\n updated = current_timestamp\n where user_id = ?\n ';
3008
-
3009
- _context2.next = 31;
3010
- return getOccupationNameById(db$1, data.occupation);
3011
-
3012
- case 31:
3013
- occupation_name = _context2.sent;
3014
- _context2.next = 34;
3015
- return db$1.query(query, [data.first_name, data.last_name, data.country, data.city, data.state, data.zip, data.phone, occupation_name, data.primary_specialty, data.area_of_practice, data.work_place, data.graduation_year, data.medical_school, data.npi, data.role, data.user_id]);
3016
-
3017
- case 34:
3018
- res = _context2.sent;
3019
-
3020
- if (!(!res || res.affectedRows < 1)) {
3021
- _context2.next = 37;
3022
- break;
3023
- }
3024
-
3025
- throw new Error('Failed to update user shared information record');
3026
-
3027
- case 37:
3028
- _context2.next = 39;
3029
- return db$1.commit();
3030
-
3031
- case 39:
3032
- _context2.next = 41;
3033
- return db$1.close();
3034
-
3035
- case 41:
3036
-
3037
- db$1 = null;
3038
-
3039
- return _context2.abrupt('return', {
3040
- error: '',
3041
- user: findUser$1(data.email)
3042
- });
3043
-
3044
- case 45:
3045
- _context2.prev = 45;
3046
- _context2.t0 = _context2['catch'](1);
3047
-
3048
-
3049
- console.log('error:', _context2.t0);
3050
-
3051
- if (!db$1) {
3052
- _context2.next = 53;
3053
- break;
3054
- }
3055
-
3056
- _context2.next = 51;
3057
- return db$1.rollback();
3058
-
3059
- case 51:
3060
- _context2.next = 53;
3061
- return db$1.close();
3062
-
3063
- case 53:
3064
- return _context2.abrupt('return', {
3065
- error: _context2.t0.message,
3066
- user: null
3067
- });
3068
-
3069
- case 54:
3070
- case 'end':
3071
- return _context2.stop();
3072
- }
3073
- }
3074
- }, _callee2, this, [[1, 45]]);
3075
- }));
3076
-
3077
- return function updateUser(_x3) {
3078
- return _ref2.apply(this, arguments);
3079
- };
3080
- }();
3081
-
3082
- var validateUserData = function validateUserData(data) {
3083
- var requirePassword = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3084
-
3085
- if (!data.email) {
3086
- throw new Error('Email is required');
3087
- }
3088
-
3089
- if (requirePassword && !data.password) {
3090
- throw new Error('Password is required');
3091
- }
3092
-
3093
- if (data.password && data.password !== data.rpassword) {
3094
- throw new Error('Password does not match');
3095
- }
3096
-
3097
- if (!data.first_name) {
3098
- throw new Error('First name is required');
3099
- }
3100
-
3101
- if (!data.last_name) {
3102
- throw new Error('Last name is required');
3103
- }
3104
-
3105
- if (!data.country) {
3106
- throw new Error('Country is required');
3107
- }
3108
-
3109
- if (data.country === 'United States') {
3110
- if (!data.state) {
3111
- throw new Error('State is required');
3112
- }
3113
-
3114
- if (!data.zip) {
3115
- throw new Error('Zip code is required');
3116
- }
3117
-
3118
- if (!data.phone) {
3119
- throw new Error('Phone is required');
3120
- }
3121
- }
3122
- };
3123
-
3124
- var getOccupationNameById = function () {
3125
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(db, occupation_id) {
3126
- var query, res;
3127
- return regenerator.wrap(function _callee3$(_context3) {
3128
- while (1) {
3129
- switch (_context3.prev = _context3.next) {
3130
- case 0:
3131
- query = '\n select name\n from occupation \n where id = ?\n ';
3132
- _context3.next = 3;
3133
- return db.query(query, [occupation_id]);
3134
-
3135
- case 3:
3136
- res = _context3.sent;
3137
-
3138
- if (!(res && res.length > 0)) {
3139
- _context3.next = 6;
3140
- break;
3141
- }
3142
-
3143
- return _context3.abrupt('return', res[0].name);
3144
-
3145
- case 6:
3146
- throw new Error('Failed to get occupation name by ID: ' + occupation_id);
3147
-
3148
- case 7:
3149
- case 'end':
3150
- return _context3.stop();
3151
- }
3152
- }
3153
- }, _callee3, _this$1);
3154
- }));
3155
-
3156
- return function getOccupationNameById(_x5, _x6) {
3157
- return _ref3.apply(this, arguments);
3158
- };
3159
- }();
3160
-
3161
- var createUser$1 = function () {
3162
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee4(data) {
3163
- var db$1, query, res, hash, columns, i, column, user_id, occupation_name;
3164
- return regenerator.wrap(function _callee4$(_context4) {
3165
- while (1) {
3166
- switch (_context4.prev = _context4.next) {
3167
- case 0:
3168
- db$1 = null;
3169
- _context4.prev = 1;
3170
-
3171
-
3172
- validateUserData(data, true);
3173
-
3174
- db$1 = db(config$1);
3175
-
3176
- _context4.next = 6;
3177
- return db$1.beginTransaction();
3178
-
3179
- case 6:
3180
-
3181
- data.email = data.email.toLowerCase().trim();
3182
-
3183
- // check if user exists
3184
- query = '\n select * \n from user \n where lower(trim(email)) = ?\n ';
3185
- _context4.next = 10;
3186
- return db$1.query(query, [data.email]);
3187
-
3188
- case 10:
3189
- res = _context4.sent;
3190
-
3191
- if (!(res && res.length > 0)) {
3192
- _context4.next = 13;
3193
- break;
3194
- }
3195
-
3196
- throw new Error('User already exists');
3197
-
3198
- case 13:
3199
- hash = md5(data.password);
3200
-
3201
- // basic user info
3202
-
3203
- query = '\n insert into user ( \n email, password, created\n ) values (\n ?, ?, current_timestamp\n )\n ';
3204
- _context4.next = 17;
3205
- return db$1.query(query, [data.email, hash]);
3206
-
3207
- case 17:
3208
- res = _context4.sent;
3209
-
3210
- if (!(!res || res.insertId < 1)) {
3211
- _context4.next = 20;
3212
- break;
3213
- }
3214
-
3215
- throw new Error('Failed to create user');
3216
-
3217
- case 20:
3218
-
3219
- query = 'show columns from user_shared';
3220
- _context4.next = 23;
3221
- return db$1.query(query);
3222
-
3223
- case 23:
3224
- columns = _context4.sent;
3225
-
3226
-
3227
- for (i = 0; i < columns.length; i++) {
3228
- column = columns[i].Field;
3229
-
3230
- if (typeof data[column] === 'undefined') {
3231
- data[column] = '';
3232
- }
3233
- }
3234
-
3235
- user_id = res.insertId;
3236
-
3237
- // user_shared
3238
-
3239
- query = '\n insert into user_shared (\n user_id, first_name, last_name, country, city, state, zip, phone, \n occupation, primary_specialty, area_of_practice, work_place, graduation_year, medical_school, \n npi, role, updated \n ) values (\n ?, ?, ?, ?, ?, ?, ?, ?,\n ?, ?, ?, ?, ?, ?,\n ?, ?, current_timestamp\n )\n ';
3240
-
3241
- _context4.next = 29;
3242
- return getOccupationNameById(db$1, data.occupation);
3243
-
3244
- case 29:
3245
- occupation_name = _context4.sent;
3246
- _context4.next = 32;
3247
- return db$1.query(query, [user_id, data.first_name, data.last_name, data.country, data.city, data.state, data.zip, data.phone, occupation_name, data.primary_specialty, data.area_of_practice, data.work_place, data.graduation_year, data.medical_school, data.npi, data.role]);
3248
-
3249
- case 32:
3250
- res = _context4.sent;
3251
-
3252
- if (!(!res || res.affectedRows < 1)) {
3253
- _context4.next = 35;
3254
- break;
3255
- }
3256
-
3257
- throw new Error('Failed to create user shared information record');
3258
-
3259
- case 35:
3260
- _context4.next = 37;
3261
- return db$1.commit();
3262
-
3263
- case 37:
3264
- _context4.next = 39;
3265
- return db$1.close();
3266
-
3267
- case 39:
3268
- return _context4.abrupt('return', {
3269
- error: '',
3270
- user: findUser$1(data.email)
3271
- });
3272
-
3273
- case 42:
3274
- _context4.prev = 42;
3275
- _context4.t0 = _context4['catch'](1);
3276
-
3277
- if (!db$1) {
3278
- _context4.next = 49;
3279
- break;
3280
- }
3281
-
3282
- _context4.next = 47;
3283
- return db$1.rollback();
3284
-
3285
- case 47:
3286
- _context4.next = 49;
3287
- return db$1.close();
3288
-
3289
- case 49:
3290
- return _context4.abrupt('return', {
3291
- error: _context4.t0.message,
3292
- user: null
3293
- });
3294
-
3295
- case 50:
3296
- case 'end':
3297
- return _context4.stop();
3298
- }
3299
- }
3300
- }, _callee4, this, [[1, 42]]);
3301
- }));
3302
-
3303
- return function createUser(_x7) {
3304
- return _ref4.apply(this, arguments);
3305
- };
3306
- }();
3307
-
3308
- var createUser = function () {
3309
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(data) {
3310
- var res;
3311
- return regenerator.wrap(function _callee$(_context) {
3312
- while (1) {
3313
- switch (_context.prev = _context.next) {
3314
- case 0:
3315
- _context.next = 2;
3316
- return createUser$1(data);
3317
-
3318
- case 2:
3319
- res = _context.sent;
3320
-
3321
- if (!res.error) {
3322
- _context.next = 5;
3323
- break;
3324
- }
3325
-
3326
- throw new Error(res.error);
3327
-
3328
- case 5:
3329
- return _context.abrupt('return', res.user);
3330
-
3331
- case 6:
3332
- case 'end':
3333
- return _context.stop();
3334
- }
3335
- }
3336
- }, _callee, this);
3337
- }));
3338
-
3339
- return function createUser(_x) {
3340
- return _ref.apply(this, arguments);
3341
- };
3342
- }();
3343
-
3344
- var updateUser = function () {
3345
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(data) {
3346
- var res;
3347
- return regenerator.wrap(function _callee2$(_context2) {
3348
- while (1) {
3349
- switch (_context2.prev = _context2.next) {
3350
- case 0:
3351
- _context2.next = 2;
3352
- return updateUser$1(data);
3353
-
3354
- case 2:
3355
- res = _context2.sent;
3356
-
3357
- if (!res.error) {
3358
- _context2.next = 5;
3359
- break;
3360
- }
3361
-
3362
- throw new Error(res.error);
3363
-
3364
- case 5:
3365
- return _context2.abrupt('return', res.user);
3366
-
3367
- case 6:
3368
- case 'end':
3369
- return _context2.stop();
3370
- }
3371
- }
3372
- }, _callee2, this);
3373
- }));
3374
-
3375
- return function updateUser(_x2) {
3376
- return _ref2.apply(this, arguments);
3377
- };
3378
- }();
3379
-
3380
- var findUser = function () {
3381
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(_ref4) {
3382
- var email = _ref4.email,
3383
- password = _ref4.password;
3384
- var res;
3385
- return regenerator.wrap(function _callee3$(_context3) {
3386
- while (1) {
3387
- switch (_context3.prev = _context3.next) {
3388
- case 0:
3389
- _context3.next = 2;
3390
- return findUser$1(email, password);
3391
-
3392
- case 2:
3393
- res = _context3.sent;
3394
-
3395
- if (!res.error) {
3396
- _context3.next = 5;
3397
- break;
3398
- }
3399
-
3400
- throw new Error(res.error);
3401
-
3402
- case 5:
3403
- return _context3.abrupt('return', res.user);
3404
-
3405
- case 6:
3406
- case 'end':
3407
- return _context3.stop();
3408
- }
3409
- }
3410
- }, _callee3, this);
3411
- }));
3412
-
3413
- return function findUser(_x3) {
3414
- return _ref3.apply(this, arguments);
3415
- };
3416
- }();
3417
-
3418
- var user = /*#__PURE__*/Object.freeze({
3419
- __proto__: null,
3420
- createUser: createUser,
3421
- updateUser: updateUser,
3422
- findUser: findUser
3423
- });
3424
-
3425
- var localStrategy = new Local.Strategy({
3426
- usernameField: 'email',
3427
- passwordField: 'password'
3428
- }, function (email, password, done) {
3429
-
3430
- findUser({ email: email, password: password }).then(function (user) {
3431
- done(null, user);
3432
- }).catch(function (error) {
3433
- done(error);
3434
- });
3435
- });
3436
-
3437
- var passportLocal = /*#__PURE__*/Object.freeze({
3438
- __proto__: null,
3439
- localStrategy: localStrategy
3440
- });
3441
-
3442
- var _this = undefined;
3443
-
3444
- var config = {
3445
- host: 'sanity-datasource.cluster-crao688bsrdh.us-east-1.rds.amazonaws.com',
3446
- user: 'nasp',
3447
- password: 'uRNkF9SkfXQs6AKK',
3448
- database: 'user'
3449
- };
3450
-
3451
- var getOccupation = function () {
3452
- var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(type) {
3453
- var db$1, query, result;
3454
- return regenerator.wrap(function _callee$(_context) {
3455
- while (1) {
3456
- switch (_context.prev = _context.next) {
3457
- case 0:
3458
- db$1 = db(config);
3459
- query = '\n select name as label, id as value\n from occupation\n where type = ?\n ';
3460
- _context.next = 4;
3461
- return db$1.query(query, [type]);
3462
-
3463
- case 4:
3464
- result = _context.sent;
3465
- _context.next = 7;
3466
- return db$1.close();
3467
-
3468
- case 7:
3469
- return _context.abrupt('return', result);
3470
-
3471
- case 8:
3472
- case 'end':
3473
- return _context.stop();
3474
- }
3475
- }
3476
- }, _callee, _this);
3477
- }));
3478
-
3479
- return function getOccupation(_x) {
3480
- return _ref.apply(this, arguments);
3481
- };
3482
- }();
3483
-
3484
- var getFieldsAndOptions = function () {
3485
- var _ref2 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee2(occupation) {
3486
- var db$1, query, result, i, field, optionQuery, options;
3487
- return regenerator.wrap(function _callee2$(_context2) {
3488
- while (1) {
3489
- switch (_context2.prev = _context2.next) {
3490
- case 0:
3491
- db$1 = db(config);
3492
- query = '\n select * \n from field\n where occupation_id = ?\n order by sorting\n ';
3493
- _context2.next = 4;
3494
- return db$1.query(query, [occupation]);
3495
-
3496
- case 4:
3497
- result = _context2.sent;
3498
- i = 0;
3499
-
3500
- case 6:
3501
- if (!(i < result.length)) {
3502
- _context2.next = 17;
3503
- break;
3504
- }
3505
-
3506
- field = result[i];
3507
-
3508
- if (!(field.type === 'select')) {
3509
- _context2.next = 14;
3510
- break;
3511
- }
3512
-
3513
- optionQuery = '\n select * \n from options\n where list_id = ?\n order by sorting\n ';
3514
- _context2.next = 12;
3515
- return db$1.query(optionQuery, [field.list_id]);
3516
-
3517
- case 12:
3518
- options = _context2.sent;
3519
-
3520
- field.options = options ? options : [];
3521
-
3522
- case 14:
3523
- i++;
3524
- _context2.next = 6;
3525
- break;
3526
-
3527
- case 17:
3528
- _context2.next = 19;
3529
- return db$1.close();
3530
-
3531
- case 19:
3532
- return _context2.abrupt('return', result);
3533
-
3534
- case 20:
3535
- case 'end':
3536
- return _context2.stop();
3537
- }
3538
- }
3539
- }, _callee2, _this);
3540
- }));
3541
-
3542
- return function getFieldsAndOptions(_x2) {
3543
- return _ref2.apply(this, arguments);
3544
- };
3545
- }();
3546
-
3547
- var ProcessData = (function () {
3548
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3(req, res) {
3549
- var action, data, type, occupation;
3550
- return regenerator.wrap(function _callee3$(_context3) {
3551
- while (1) {
3552
- switch (_context3.prev = _context3.next) {
3553
- case 0:
3554
- _context3.prev = 0;
3555
- action = req.body.action;
3556
- data = null;
3557
- _context3.t0 = action;
3558
- _context3.next = _context3.t0 === 'get-occupation' ? 6 : _context3.t0 === 'get-fields' ? 11 : 16;
3559
- break;
3560
-
3561
- case 6:
3562
- type = req.body.type;
3563
- _context3.next = 9;
3564
- return getOccupation(type);
3565
-
3566
- case 9:
3567
- data = _context3.sent;
3568
- return _context3.abrupt('break', 17);
3569
-
3570
- case 11:
3571
- occupation = req.body.occupation;
3572
- _context3.next = 14;
3573
- return getFieldsAndOptions(occupation);
3574
-
3575
- case 14:
3576
- data = _context3.sent;
3577
- return _context3.abrupt('break', 17);
3578
-
3579
- case 16:
3580
- throw new Error('Invalid action: ' + action);
3581
-
3582
- case 17:
3583
- return _context3.abrupt('return', res.json({
3584
- error: '',
3585
- data: data
3586
- }));
3587
-
3588
- case 20:
3589
- _context3.prev = 20;
3590
- _context3.t1 = _context3['catch'](0);
3591
- return _context3.abrupt('return', res.json({
3592
- error: _context3.t1.message,
3593
- data: null
3594
- }));
3595
-
3596
- case 23:
3597
- case 'end':
3598
- return _context3.stop();
3599
- }
3600
- }
3601
- }, _callee3, this, [[0, 20]]);
3602
- }));
3603
-
3604
- return function (_x3, _x4) {
3605
- return _ref3.apply(this, arguments);
3606
- };
3607
- })();
3608
-
3609
- var LoginForm_1 = LoginForm;
3610
- var SignupForm_1 = SignupForm$1;
3611
- var ProfileForm_1 = SignupForm;
3612
- var AuthCookies_1 = authCookies;
3613
- var AuthHooks_1 = hooks;
3614
- var Iron_1 = iron;
3615
- var PassportLocal_1 = passportLocal;
3616
- var User_1 = user;
3617
- var ProcessData_1 = ProcessData;
3618
-
3619
- var auth = {
3620
- LoginForm: LoginForm_1,
3621
- SignupForm: SignupForm_1,
3622
- ProfileForm: ProfileForm_1,
3623
- AuthCookies: AuthCookies_1,
3624
- AuthHooks: AuthHooks_1,
3625
- Iron: Iron_1,
3626
- PassportLocal: PassportLocal_1,
3627
- User: User_1,
3628
- ProcessData: ProcessData_1
3629
- };
3630
-
3631
- export default auth;
3632
- export { AuthCookies_1 as AuthCookies, AuthHooks_1 as AuthHooks, Iron_1 as Iron, LoginForm_1 as LoginForm, PassportLocal_1 as PassportLocal, ProcessData_1 as ProcessData, ProfileForm_1 as ProfileForm, SignupForm_1 as SignupForm, User_1 as User };