@verdocs/js-sdk 1.0.8 → 1.0.12

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 (381) hide show
  1. package/.gitignore +4 -0
  2. package/.idea/.gitignore +8 -0
  3. package/.idea/inspectionProfiles/Project_Default.xml +12 -0
  4. package/.idea/js-sdk.iml +11 -0
  5. package/.idea/misc.xml +6 -0
  6. package/.idea/modules.xml +8 -0
  7. package/.idea/vcs.xml +6 -0
  8. package/.prettierrc.js +11 -0
  9. package/LICENSE +21 -0
  10. package/README.md +8 -5
  11. package/__mocks__/axios.ts +3 -0
  12. package/dist/.npmignore +5 -0
  13. package/{Documents → dist/Documents}/Documents.d.ts +9 -0
  14. package/{Documents → dist/Documents}/Documents.js +24 -7
  15. package/{Documents → dist/Documents}/Stars.d.ts +0 -0
  16. package/{Documents → dist/Documents}/Stars.js +2 -2
  17. package/{Documents → dist/Documents}/Templates.d.ts +0 -0
  18. package/{Documents → dist/Documents}/Templates.js +22 -10
  19. package/{Documents → dist/Documents}/Types.d.ts +0 -0
  20. package/{Api → dist/Documents}/Types.js +0 -0
  21. package/{Documents → dist/Documents}/index.d.ts +0 -0
  22. package/{Documents → dist/Documents}/index.js +0 -0
  23. package/dist/HTTP/Transport.d.ts +51 -0
  24. package/dist/HTTP/Transport.js +88 -0
  25. package/{HTTP → dist/HTTP}/Types.d.ts +0 -0
  26. package/{Documents → dist/HTTP}/Types.js +0 -0
  27. package/{HTTP → dist/HTTP}/index.d.ts +0 -0
  28. package/{HTTP → dist/HTTP}/index.js +0 -0
  29. package/{Organizations → dist/Organizations}/ApiKeys.d.ts +0 -0
  30. package/{Organizations → dist/Organizations}/ApiKeys.js +16 -6
  31. package/{Organizations → dist/Organizations}/Groups.d.ts +0 -0
  32. package/{Organizations → dist/Organizations}/Groups.js +22 -8
  33. package/{Organizations → dist/Organizations}/Invitations.d.ts +0 -0
  34. package/dist/Organizations/Invitations.js +36 -0
  35. package/{Organizations → dist/Organizations}/Members.d.ts +0 -0
  36. package/dist/Organizations/Members.js +26 -0
  37. package/{Organizations → dist/Organizations}/Organizations.d.ts +0 -0
  38. package/dist/Organizations/Organizations.js +31 -0
  39. package/{Organizations → dist/Organizations}/Types.d.ts +0 -0
  40. package/{HTTP → dist/Organizations}/Types.js +0 -0
  41. package/{Organizations → dist/Organizations}/Webhooks.d.ts +0 -0
  42. package/dist/Organizations/Webhooks.js +11 -0
  43. package/{Organizations → dist/Organizations}/index.d.ts +0 -0
  44. package/{Organizations → dist/Organizations}/index.js +0 -0
  45. package/dist/README.md +68 -0
  46. package/{Search → dist/Search}/Content.d.ts +0 -0
  47. package/{Search → dist/Search}/Content.js +22 -10
  48. package/{Search → dist/Search}/Types.d.ts +0 -0
  49. package/{Organizations → dist/Search}/Types.js +0 -0
  50. package/{Search → dist/Search}/index.d.ts +0 -0
  51. package/{Search → dist/Search}/index.js +0 -0
  52. package/{Signatures.d.ts → dist/Signatures.d.ts} +0 -0
  53. package/dist/Signatures.js +21 -0
  54. package/{Tags.d.ts → dist/Tags.d.ts} +0 -0
  55. package/dist/Tags.js +16 -0
  56. package/{Templates → dist/Templates}/Documents.d.ts +0 -0
  57. package/{Templates → dist/Templates}/Documents.js +13 -5
  58. package/{Templates → dist/Templates}/Fields.d.ts +0 -0
  59. package/dist/Templates/Fields.js +16 -0
  60. package/{Templates → dist/Templates}/Pages.d.ts +0 -0
  61. package/dist/Templates/Pages.js +21 -0
  62. package/{Templates → dist/Templates}/Reminders.d.ts +0 -0
  63. package/dist/Templates/Reminders.js +21 -0
  64. package/{Templates → dist/Templates}/Roles.d.ts +0 -0
  65. package/dist/Templates/Roles.js +36 -0
  66. package/{Templates → dist/Templates}/Stars.d.ts +0 -0
  67. package/dist/Templates/Stars.js +11 -0
  68. package/{Templates → dist/Templates}/Tags.d.ts +0 -0
  69. package/dist/Templates/Tags.js +16 -0
  70. package/{Templates → dist/Templates}/Templates.d.ts +0 -0
  71. package/{Templates → dist/Templates}/Templates.js +33 -11
  72. package/{Templates → dist/Templates}/Types.d.ts +0 -0
  73. package/{Templates → dist/Templates}/Types.js +0 -0
  74. package/{Templates → dist/Templates}/index.d.ts +0 -0
  75. package/{Templates → dist/Templates}/index.js +0 -0
  76. package/{Users → dist/Users}/Auth.d.ts +6 -6
  77. package/{Users → dist/Users}/Auth.js +27 -13
  78. package/{Users → dist/Users}/Billing.d.ts +0 -0
  79. package/{Users → dist/Users}/Billing.js +0 -0
  80. package/{Api → dist/Users}/Notifications.d.ts +0 -0
  81. package/{Api → dist/Users}/Notifications.js +8 -4
  82. package/{Users → dist/Users}/Profiles.d.ts +0 -0
  83. package/{Users → dist/Users}/Profiles.js +41 -11
  84. package/{Users → dist/Users}/Types.d.ts +13 -0
  85. package/{Search → dist/Users}/Types.js +0 -0
  86. package/{Users → dist/Users}/index.d.ts +0 -0
  87. package/{Users → dist/Users}/index.js +0 -0
  88. package/{Utils → dist/Utils}/DateTime.d.ts +0 -0
  89. package/{Utils → dist/Utils}/DateTime.js +0 -0
  90. package/{Utils → dist/Utils}/index.d.ts +0 -0
  91. package/{Utils → dist/Utils}/index.js +0 -0
  92. package/{Validators.d.ts → dist/Validators.d.ts} +0 -0
  93. package/dist/Validators.js +11 -0
  94. package/{Whitelabel.d.ts → dist/Whitelabel.d.ts} +0 -0
  95. package/dist/Whitelabel.js +11 -0
  96. package/{index.d.ts → dist/index.d.ts} +0 -0
  97. package/{index.js → dist/index.js} +0 -0
  98. package/dist/package.json +64 -0
  99. package/docs/.nojekyll +1 -0
  100. package/docs/README.md +70 -0
  101. package/docs/enums/Templates.Types.SortOptions.md +76 -0
  102. package/docs/enums/Templates.Types.Template.md +153 -0
  103. package/docs/enums/Templates.Types.TemplatePermissions.md +109 -0
  104. package/docs/enums/Templates.Types.TemplateSenderTypes.md +65 -0
  105. package/docs/interfaces/Documents.Documents-1.IActivityEntry.md +120 -0
  106. package/docs/interfaces/Documents.Documents-1.IDocument.md +175 -0
  107. package/docs/interfaces/Documents.Documents-1.IDocumentSearchOptions.md +98 -0
  108. package/docs/interfaces/Documents.Documents-1.IDocumentsSearchResult.md +43 -0
  109. package/docs/interfaces/Documents.Documents-1.IDocumentsSearchResultEntry.md +131 -0
  110. package/docs/interfaces/Documents.Documents-1.IDocumentsSummary.md +67 -0
  111. package/docs/interfaces/Documents.Documents-1.IHistory.md +76 -0
  112. package/docs/interfaces/Documents.Documents-1.IRecipient.md +208 -0
  113. package/docs/interfaces/Documents.Types.ITemplateSummaryEntry.md +186 -0
  114. package/docs/interfaces/Documents.Types.ITemplatesSummary.md +43 -0
  115. package/docs/interfaces/Organizations.Types.IApiKey.md +60 -0
  116. package/docs/interfaces/Organizations.Types.IApiKeyWithSecret.md +87 -0
  117. package/docs/interfaces/Organizations.Types.ICreateApiKeyRequest.md +32 -0
  118. package/docs/interfaces/Organizations.Types.IGroup.md +101 -0
  119. package/docs/interfaces/Organizations.Types.IGroupDetail.md +129 -0
  120. package/docs/interfaces/Organizations.Types.IOrganization.md +128 -0
  121. package/docs/interfaces/Organizations.Types.IUpdateApiKeyRequest.md +32 -0
  122. package/docs/interfaces/Signatures.ISignature.md +65 -0
  123. package/docs/interfaces/Tags.ITags.md +43 -0
  124. package/docs/interfaces/Templates.Types.IDocument.md +109 -0
  125. package/docs/interfaces/Templates.Types.IField.md +109 -0
  126. package/docs/interfaces/Templates.Types.IPage.md +87 -0
  127. package/docs/interfaces/Templates.Types.IReminder.md +109 -0
  128. package/docs/interfaces/Templates.Types.IRole.md +120 -0
  129. package/docs/interfaces/Templates.Types.ISetting.md +98 -0
  130. package/docs/interfaces/Templates.Types.IStar.md +32 -0
  131. package/docs/interfaces/Templates.Types.ITag.md +32 -0
  132. package/docs/interfaces/Templates.Types.ITemplate.md +219 -0
  133. package/docs/interfaces/Templates.Types.ITemplateSearchParams.md +197 -0
  134. package/docs/interfaces/Templates.Types.ITemplateSummaryEntry.md +186 -0
  135. package/docs/interfaces/Templates.Types.ITemplatesSearchResult.md +43 -0
  136. package/docs/interfaces/Templates.Types.ITemplatesSummary.md +43 -0
  137. package/docs/interfaces/Templates.Types.ITimePeriod.md +32 -0
  138. package/docs/interfaces/Users.Types.IActiveSession.md +131 -0
  139. package/docs/interfaces/Users.Types.IAuthenticateAppRequest.md +32 -0
  140. package/docs/interfaces/Users.Types.IAuthenticateResponse.md +43 -0
  141. package/docs/interfaces/Users.Types.IAuthenticateUserRequest.md +32 -0
  142. package/docs/interfaces/Users.Types.ICreateProfileRequest.md +54 -0
  143. package/docs/interfaces/Users.Types.IPermission.md +36 -0
  144. package/docs/interfaces/Users.Types.IProfile.md +173 -0
  145. package/docs/interfaces/Users.Types.IRole.md +36 -0
  146. package/docs/interfaces/Users.Types.ISwitchProfileResponse.md +54 -0
  147. package/docs/interfaces/Users.Types.IUpdateProfileRequest.md +43 -0
  148. package/docs/interfaces/Users.Types.TokenValidationRequest.md +21 -0
  149. package/docs/interfaces/Users.Types.TokenValidationResponse.md +36 -0
  150. package/docs/interfaces/Users.Types.UpdateEmailRequest.md +21 -0
  151. package/docs/interfaces/Users.Types.UpdateEmailResponse.md +21 -0
  152. package/docs/interfaces/Users.Types.UpdatePasswordRequest.md +43 -0
  153. package/docs/interfaces/Users.Types.UpdatePasswordResponse.md +34 -0
  154. package/docs/interfaces/Validators.IValidator.md +32 -0
  155. package/docs/modules/Documents.Documents-1.md +137 -0
  156. package/docs/modules/Documents.Stars.md +31 -0
  157. package/docs/modules/Documents.Templates.md +61 -0
  158. package/docs/modules/Documents.Types.md +12 -0
  159. package/docs/modules/Documents.md +12 -0
  160. package/docs/modules/HTTP.Transport.md +150 -0
  161. package/docs/modules/HTTP.Types.md +21 -0
  162. package/docs/modules/HTTP.md +10 -0
  163. package/docs/modules/Organizations.ApiKeys.md +169 -0
  164. package/docs/modules/Organizations.Groups.md +190 -0
  165. package/docs/modules/Organizations.Invitations.md +166 -0
  166. package/docs/modules/Organizations.Members.md +121 -0
  167. package/docs/modules/Organizations.Organizations-1.md +119 -0
  168. package/docs/modules/Organizations.Types.md +17 -0
  169. package/docs/modules/Organizations.Webhooks.md +53 -0
  170. package/docs/modules/Organizations.md +20 -0
  171. package/docs/modules/Signatures.md +90 -0
  172. package/docs/modules/Tags.md +75 -0
  173. package/docs/modules/Templates.Documents.md +129 -0
  174. package/docs/modules/Templates.Fields.md +77 -0
  175. package/docs/modules/Templates.Pages.md +98 -0
  176. package/docs/modules/Templates.Reminders.md +98 -0
  177. package/docs/modules/Templates.Roles.md +163 -0
  178. package/docs/modules/Templates.Stars.md +52 -0
  179. package/docs/modules/Templates.Tags.md +75 -0
  180. package/docs/modules/Templates.Templates-1.md +139 -0
  181. package/docs/modules/Templates.Types.md +31 -0
  182. package/docs/modules/Templates.md +17 -0
  183. package/docs/modules/Users.Auth.md +196 -0
  184. package/docs/modules/Users.Billing.md +5 -0
  185. package/docs/modules/Users.Notifications.md +25 -0
  186. package/docs/modules/Users.Profiles.md +286 -0
  187. package/docs/modules/Users.Types.md +62 -0
  188. package/docs/modules/Users.md +13 -0
  189. package/docs/modules/Utils.DateTime.md +31 -0
  190. package/docs/modules/Utils.md +9 -0
  191. package/docs/modules/Validators.md +48 -0
  192. package/docs/modules/Whitelabel.md +38 -0
  193. package/docs/modules.md +27 -0
  194. package/docs-html/.nojekyll +1 -0
  195. package/docs-html/assets/highlight.css +85 -0
  196. package/docs-html/assets/icons.css +1043 -0
  197. package/docs-html/assets/icons.png +0 -0
  198. package/docs-html/assets/icons@2x.png +0 -0
  199. package/docs-html/assets/main.js +52 -0
  200. package/docs-html/assets/search.js +1 -0
  201. package/docs-html/assets/style.css +1384 -0
  202. package/docs-html/assets/widgets.png +0 -0
  203. package/docs-html/assets/widgets@2x.png +0 -0
  204. package/docs-html/enums/Templates.Types.SortOptions.html +1 -0
  205. package/docs-html/enums/Templates.Types.Template.html +1 -0
  206. package/docs-html/enums/Templates.Types.TemplatePermissions.html +1 -0
  207. package/docs-html/enums/Templates.Types.TemplateSenderTypes.html +1 -0
  208. package/docs-html/index.html +64 -0
  209. package/docs-html/interfaces/Documents.Documents-1.IActivityEntry.html +1 -0
  210. package/docs-html/interfaces/Documents.Documents-1.IDocument.html +1 -0
  211. package/docs-html/interfaces/Documents.Documents-1.IDocumentSearchOptions.html +1 -0
  212. package/docs-html/interfaces/Documents.Documents-1.IDocumentsSearchResult.html +1 -0
  213. package/docs-html/interfaces/Documents.Documents-1.IDocumentsSearchResultEntry.html +1 -0
  214. package/docs-html/interfaces/Documents.Documents-1.IDocumentsSummary.html +1 -0
  215. package/docs-html/interfaces/Documents.Documents-1.IHistory.html +1 -0
  216. package/docs-html/interfaces/Documents.Documents-1.IRecipient.html +1 -0
  217. package/docs-html/interfaces/Documents.Types.ITemplateSummaryEntry.html +1 -0
  218. package/docs-html/interfaces/Documents.Types.ITemplatesSummary.html +1 -0
  219. package/docs-html/interfaces/Organizations.Types.IApiKey.html +1 -0
  220. package/docs-html/interfaces/Organizations.Types.IApiKeyWithSecret.html +1 -0
  221. package/docs-html/interfaces/Organizations.Types.ICreateApiKeyRequest.html +1 -0
  222. package/docs-html/interfaces/Organizations.Types.IGroup.html +9 -0
  223. package/docs-html/interfaces/Organizations.Types.IGroupDetail.html +9 -0
  224. package/docs-html/interfaces/Organizations.Types.IOrganization.html +9 -0
  225. package/docs-html/interfaces/Organizations.Types.IUpdateApiKeyRequest.html +1 -0
  226. package/docs-html/interfaces/Signatures.ISignature.html +1 -0
  227. package/docs-html/interfaces/Tags.ITags.html +1 -0
  228. package/docs-html/interfaces/Templates.Types.IDocument.html +1 -0
  229. package/docs-html/interfaces/Templates.Types.IField.html +1 -0
  230. package/docs-html/interfaces/Templates.Types.IPage.html +1 -0
  231. package/docs-html/interfaces/Templates.Types.IReminder.html +1 -0
  232. package/docs-html/interfaces/Templates.Types.IRole.html +1 -0
  233. package/docs-html/interfaces/Templates.Types.ISetting.html +1 -0
  234. package/docs-html/interfaces/Templates.Types.IStar.html +1 -0
  235. package/docs-html/interfaces/Templates.Types.ITag.html +1 -0
  236. package/docs-html/interfaces/Templates.Types.ITemplate.html +1 -0
  237. package/docs-html/interfaces/Templates.Types.ITemplateSearchParams.html +1 -0
  238. package/docs-html/interfaces/Templates.Types.ITemplateSummaryEntry.html +1 -0
  239. package/docs-html/interfaces/Templates.Types.ITemplatesSearchResult.html +1 -0
  240. package/docs-html/interfaces/Templates.Types.ITemplatesSummary.html +1 -0
  241. package/docs-html/interfaces/Templates.Types.ITimePeriod.html +1 -0
  242. package/docs-html/interfaces/Users.Types.IActiveSession.html +1 -0
  243. package/docs-html/interfaces/Users.Types.IAuthenticateAppRequest.html +1 -0
  244. package/docs-html/interfaces/Users.Types.IAuthenticateResponse.html +1 -0
  245. package/docs-html/interfaces/Users.Types.IAuthenticateUserRequest.html +1 -0
  246. package/docs-html/interfaces/Users.Types.ICreateProfileRequest.html +1 -0
  247. package/docs-html/interfaces/Users.Types.IPermission.html +5 -0
  248. package/docs-html/interfaces/Users.Types.IProfile.html +21 -0
  249. package/docs-html/interfaces/Users.Types.IRole.html +5 -0
  250. package/docs-html/interfaces/Users.Types.ISwitchProfileResponse.html +1 -0
  251. package/docs-html/interfaces/Users.Types.IUpdateProfileRequest.html +1 -0
  252. package/docs-html/interfaces/Users.Types.TokenValidationRequest.html +1 -0
  253. package/docs-html/interfaces/Users.Types.TokenValidationResponse.html +5 -0
  254. package/docs-html/interfaces/Users.Types.UpdateEmailRequest.html +1 -0
  255. package/docs-html/interfaces/Users.Types.UpdateEmailResponse.html +1 -0
  256. package/docs-html/interfaces/Users.Types.UpdatePasswordRequest.html +1 -0
  257. package/docs-html/interfaces/Users.Types.UpdatePasswordResponse.html +3 -0
  258. package/docs-html/interfaces/Validators.IValidator.html +1 -0
  259. package/docs-html/modules/Documents.Documents-1.html +9 -0
  260. package/docs-html/modules/Documents.Stars.html +1 -0
  261. package/docs-html/modules/Documents.Templates.html +1 -0
  262. package/docs-html/modules/Documents.Types.html +1 -0
  263. package/docs-html/modules/Documents.html +1 -0
  264. package/docs-html/modules/HTTP.Transport.html +22 -0
  265. package/docs-html/modules/HTTP.Types.html +1 -0
  266. package/docs-html/modules/HTTP.html +1 -0
  267. package/docs-html/modules/Organizations.ApiKeys.html +29 -0
  268. package/docs-html/modules/Organizations.Groups.html +15 -0
  269. package/docs-html/modules/Organizations.Invitations.html +1 -0
  270. package/docs-html/modules/Organizations.Members.html +1 -0
  271. package/docs-html/modules/Organizations.Organizations-1.html +1 -0
  272. package/docs-html/modules/Organizations.Types.html +1 -0
  273. package/docs-html/modules/Organizations.Webhooks.html +1 -0
  274. package/docs-html/modules/Organizations.html +6 -0
  275. package/docs-html/modules/Signatures.html +1 -0
  276. package/docs-html/modules/Tags.html +1 -0
  277. package/docs-html/modules/Templates.Documents.html +17 -0
  278. package/docs-html/modules/Templates.Fields.html +1 -0
  279. package/docs-html/modules/Templates.Pages.html +1 -0
  280. package/docs-html/modules/Templates.Reminders.html +1 -0
  281. package/docs-html/modules/Templates.Roles.html +1 -0
  282. package/docs-html/modules/Templates.Stars.html +1 -0
  283. package/docs-html/modules/Templates.Tags.html +1 -0
  284. package/docs-html/modules/Templates.Templates-1.html +5 -0
  285. package/docs-html/modules/Templates.Types.html +1 -0
  286. package/docs-html/modules/Templates.html +1 -0
  287. package/docs-html/modules/Users.Auth.html +31 -0
  288. package/docs-html/modules/Users.Billing.html +1 -0
  289. package/docs-html/modules/Users.Notifications.html +1 -0
  290. package/docs-html/modules/Users.Profiles.html +44 -0
  291. package/docs-html/modules/Users.Types.html +1 -0
  292. package/docs-html/modules/Users.html +1 -0
  293. package/docs-html/modules/Utils.DateTime.html +1 -0
  294. package/docs-html/modules/Utils.html +1 -0
  295. package/docs-html/modules/Validators.html +1 -0
  296. package/docs-html/modules/Whitelabel.html +1 -0
  297. package/docs-html/modules.html +11 -0
  298. package/jestconfig.json +11 -0
  299. package/package-lock.json +3421 -0
  300. package/package.json +6 -3
  301. package/src/Documents/Documents.ts +166 -0
  302. package/src/Documents/Stars.ts +5 -0
  303. package/src/Documents/Templates.ts +17 -0
  304. package/src/Documents/Types.ts +24 -0
  305. package/src/Documents/index.ts +4 -0
  306. package/src/HTTP/Transport.ts +95 -0
  307. package/src/HTTP/Types.ts +1 -0
  308. package/src/HTTP/index.ts +2 -0
  309. package/src/Organizations/ApiKeys.ts +85 -0
  310. package/src/Organizations/Groups.ts +65 -0
  311. package/src/Organizations/Invitations.ts +36 -0
  312. package/src/Organizations/Members.ts +26 -0
  313. package/src/Organizations/Organizations.ts +32 -0
  314. package/src/Organizations/Types.ts +63 -0
  315. package/src/Organizations/Webhooks.ts +11 -0
  316. package/src/Organizations/index.ts +16 -0
  317. package/src/Search/Content.ts +45 -0
  318. package/src/Search/Types.ts +83 -0
  319. package/src/Search/index.ts +2 -0
  320. package/src/Signatures.ts +29 -0
  321. package/src/Tags.ts +22 -0
  322. package/src/Templates/Documents.ts +58 -0
  323. package/src/Templates/Fields.ts +17 -0
  324. package/src/Templates/Pages.ts +22 -0
  325. package/src/Templates/Reminders.ts +22 -0
  326. package/src/Templates/Roles.ts +37 -0
  327. package/src/Templates/Stars.ts +12 -0
  328. package/src/Templates/Tags.ts +17 -0
  329. package/src/Templates/Templates.ts +42 -0
  330. package/src/Templates/Types.ts +201 -0
  331. package/src/Templates/index.ts +9 -0
  332. package/src/Users/Auth.ts +114 -0
  333. package/src/Users/Billing.ts +3 -0
  334. package/src/Users/Notifications.ts +6 -0
  335. package/src/Users/Profiles.ts +153 -0
  336. package/src/Users/Types.ts +156 -0
  337. package/src/Users/index.ts +5 -0
  338. package/src/Utils/DateTime.ts +43 -0
  339. package/src/Utils/index.ts +1 -0
  340. package/src/Validators.ts +16 -0
  341. package/src/Whitelabel.ts +11 -0
  342. package/src/__tests__/Organizations/Apikeys.spec.ts +84 -0
  343. package/src/__tests__/Users/Auth.spec.ts +89 -0
  344. package/src/__tests__/Users/Profiles.spec.ts +162 -0
  345. package/src/index.ts +23 -0
  346. package/tsconfig.json +20 -0
  347. package/tslint.json +3 -0
  348. package/Api/Auth.d.ts +0 -71
  349. package/Api/Auth.js +0 -24
  350. package/Api/Documents.d.ts +0 -124
  351. package/Api/Documents.js +0 -47
  352. package/Api/Endpoint.d.ts +0 -2
  353. package/Api/Endpoint.js +0 -9
  354. package/Api/Templates.d.ts +0 -33
  355. package/Api/Templates.js +0 -55
  356. package/Api/Types.d.ts +0 -182
  357. package/Api/index.d.ts +0 -2
  358. package/Api/index.js +0 -2
  359. package/AuthManager.d.ts +0 -14
  360. package/AuthManager.js +0 -53
  361. package/HTTP/Endpoint.d.ts +0 -4
  362. package/HTTP/Endpoint.js +0 -12
  363. package/HTTP/Transport.d.ts +0 -3
  364. package/HTTP/Transport.js +0 -12
  365. package/Organizations/Invitations.js +0 -22
  366. package/Organizations/Members.js +0 -16
  367. package/Organizations/Organizations.js +0 -13
  368. package/Organizations/Webhooks.js +0 -7
  369. package/Signatures.js +0 -7
  370. package/Tags.js +0 -4
  371. package/Templates/Fields.js +0 -10
  372. package/Templates/Pages.js +0 -13
  373. package/Templates/Reminders.js +0 -13
  374. package/Templates/Roles.js +0 -22
  375. package/Templates/Stars.js +0 -7
  376. package/Templates/Tags.js +0 -10
  377. package/Users/Notifications.d.ts +0 -1
  378. package/Users/Notifications.js +0 -40
  379. package/Users/Types.js +0 -1
  380. package/Validators.js +0 -5
  381. package/Whitelabel.js +0 -3
@@ -0,0 +1,114 @@
1
+ import {getEndpoint} from '../HTTP/Transport';
2
+ import {
3
+ IAuthenticateAppRequest,
4
+ IAuthenticateResponse,
5
+ IAuthenticateUserRequest,
6
+ TokenValidationRequest,
7
+ TokenValidationResponse,
8
+ UpdateEmailRequest,
9
+ UpdateEmailResponse,
10
+ UpdatePasswordRequest,
11
+ UpdatePasswordResponse,
12
+ } from './Types';
13
+
14
+ /**
15
+ * Authenticate to Verdocs via user/password authentication
16
+ *
17
+ * ```typescript
18
+ * import {Auth} from '@verdocs/js-sdk/Auth';
19
+ * import {Transport} from '@verdocs/js-sdk/HTTP';
20
+ *
21
+ * const {accessToken} = await Auth.authenticateUser({ username: 'test@test.com', password: 'PASSWORD' });
22
+ * Transport.setAuthToken(accessToken);
23
+ * ```
24
+ */
25
+ export const authenticateUser = (params: IAuthenticateUserRequest) =>
26
+ getEndpoint()
27
+ .post<IAuthenticateResponse>('/authentication/login', params)
28
+ .then((r) => r.data);
29
+
30
+ /**
31
+ * Authenticate to Verdocs via client ID / Secret authentication. **NOTE: This is only suitable for
32
+ * NodeJS server-side applications. Never expose your Client Secret in a Web or Mobile app!** Also note
33
+ * that access tokens may be cached by server-side apps (and this is recommended) but do expire after 2
34
+ * hours. This expiration may change based on future security needs. Application developers are encouraged
35
+ * to check the `exp` expiration field in the response accessToken and renew tokens after they expire.
36
+ *
37
+ * ```typescript
38
+ * import {Auth} from '@verdocs/js-sdk/Auth';
39
+ * import {Transport} from '@verdocs/js-sdk/HTTP';
40
+ *
41
+ * const {accessToken} = await Auth.authenticateApp({ client_id: 'CLIENTID', client_secret: 'SECRET' });
42
+ * Transport.setAuthToken(accessToken);
43
+ * ```
44
+ */
45
+ export const authenticateApp = (params: IAuthenticateAppRequest): Promise<IAuthenticateResponse> =>
46
+ getEndpoint()
47
+ .post('/authentication/login_client', {}, {headers: params})
48
+ .then((r) => r.data);
49
+
50
+ /**
51
+ * Validate a token. Only Verdocs tokens will be accepted. Most applications can decode tokens locally,
52
+ * because tokens will be validated when API calls are made anyway. However, high-security applications
53
+ * may use this endpoint to check if a token has been revoked.
54
+ *
55
+ * ```typescript
56
+ * import {Auth} from '@verdocs/js-sdk/Auth';
57
+ *
58
+ * const {valid} = await Auth.validateToken({ token });
59
+ * if (!valid) {
60
+ * window.alert('Session invalid or expired. Please re-authenticate.');
61
+ * }
62
+ * ```
63
+ */
64
+ export const validateToken = (params: TokenValidationRequest): Promise<TokenValidationResponse> =>
65
+ getEndpoint()
66
+ .post('/token/isValid', params)
67
+ .then((r) => r.data);
68
+
69
+ /**
70
+ * If called before the session expires, this will refresh the caller's session and tokens.
71
+ *
72
+ * ```typescript
73
+ * import {Auth} from '@verdocs/js-sdk/Auth';
74
+ * import {Transport} from '@verdocs/js-sdk/HTTP';
75
+ *
76
+ * const {accessToken} = await Auth.refreshTokens();
77
+ * Transport.setAuthToken(accessToken);
78
+ * ```
79
+ */
80
+ export const refreshTokens = (): Promise<IAuthenticateResponse> =>
81
+ getEndpoint()
82
+ .get('/token')
83
+ .then((r) => r.data);
84
+
85
+ /**
86
+ * Update the caller's password. To help prevent CSRF attack vectors, the user's old password and email address are required.
87
+ *
88
+ * ```typescript
89
+ * import {Auth} from '@verdocs/js-sdk/Auth';
90
+ *
91
+ * const {status, message} = await Auth.updatePassword({ email, oldPassword, newPassword });
92
+ * if (status !== 'OK') {
93
+ * window.alert(`Password reset error: ${message}`);
94
+ * }
95
+ * ```
96
+ */
97
+ export const updatePassword = (params: UpdatePasswordRequest): Promise<UpdatePasswordResponse> =>
98
+ getEndpoint()
99
+ .put('/user/update_password', params)
100
+ .then((r) => r.data);
101
+
102
+ /**
103
+ * Update the caller's email address.
104
+ *
105
+ * ```typescript
106
+ * import {Auth} from '@verdocs/js-sdk/Auth';
107
+ *
108
+ * const {profiles} = await Auth.updateEmail({ email: newEmail });
109
+ * ```
110
+ */
111
+ export const updateEmail = (params: UpdateEmailRequest): Promise<UpdateEmailResponse> =>
112
+ getEndpoint()
113
+ .put('/user/update_email', params)
114
+ .then((r) => r.data);
@@ -0,0 +1,3 @@
1
+ import {getEndpoint} from '../HTTP/Transport';
2
+
3
+ // TODO
@@ -0,0 +1,6 @@
1
+ import {getEndpoint} from '../HTTP/Transport';
2
+
3
+ export const getNotifications = async () =>
4
+ getEndpoint()
5
+ .get('/notifications')
6
+ .then((r) => r.data);
@@ -0,0 +1,153 @@
1
+ import {getEndpoint} from '../HTTP/Transport';
2
+ import {
3
+ ICreateProfileRequest,
4
+ IPermission,
5
+ IProfile,
6
+ IRole,
7
+ ISwitchProfileResponse,
8
+ IUpdateProfileRequest,
9
+ } from './Types';
10
+ import {IGroup} from '../Organizations/Types';
11
+
12
+ /**
13
+ * Get the user's available profiles. The current profile will be marked with `current: true`.
14
+ *
15
+ * ```typescript
16
+ * import {Profiles} from '@verdocs/js-sdk/Users';
17
+ *
18
+ * const profiles = await Profiles.getProfiles()
19
+ * ```
20
+ */
21
+ export const getProfiles = () =>
22
+ getEndpoint()
23
+ .get<IProfile[]>('/profiles')
24
+ .then((r) => r.data);
25
+
26
+ /**
27
+ * Get a list of system roles.
28
+ *
29
+ * ```typescript
30
+ * import {Profiles} from '@verdocs/js-sdk/Users';
31
+ *
32
+ * const roles = await Profiles.getRoles();
33
+ * ```
34
+ */
35
+ export const getRoles = () =>
36
+ getEndpoint()
37
+ .get<IRole[]>('/roles')
38
+ .then((r) => r.data);
39
+
40
+ /**
41
+ * Get a list of system roles.
42
+ *
43
+ * ```typescript
44
+ * import {Profiles} from '@verdocs/js-sdk/Users';
45
+ *
46
+ * const permissions = await Profiles.getPermissions();
47
+ * ```
48
+ */
49
+ export const getPermissions = () =>
50
+ getEndpoint()
51
+ .get<IPermission[]>('/permissions')
52
+ .then((r) => r.data);
53
+
54
+ /**
55
+ * Create a profile. If the caller does not have a "current" profile set, the new profile will be made current.
56
+ *
57
+ * ```typescript
58
+ * import {Profiles} from '@verdocs/js-sdk/Users';
59
+ *
60
+ * const newProfile = await Profiles.createProfile({ first_name: 'FIRST', last_name: 'LAST', email: 'EMAIL' });
61
+ * ```
62
+ */
63
+ export const createProfile = (params: ICreateProfileRequest) =>
64
+ getEndpoint()
65
+ .post<IProfile>('/profiles', params)
66
+ .then((r) => r.data);
67
+
68
+ /**
69
+ * Get a profile. The caller must have admin access to the given profile.
70
+ * TODO: Add a "public" profile endpoint for public pages
71
+ *
72
+ * ```typescript
73
+ * import {Profiles} from '@verdocs/js-sdk/Users';
74
+ *
75
+ * const profile = await Profiles.getProfile('PROFILEID');
76
+ * ```
77
+ */
78
+ export const getProfile = (profileId: string) =>
79
+ getEndpoint()
80
+ .get<IProfile>(`/profiles/${profileId}`)
81
+ .then((r) => r.data);
82
+
83
+ /**
84
+ * Get a profile's permissions. The caller must have admin access to the given profile.
85
+ *
86
+ * ```typescript
87
+ * import {Profiles} from '@verdocs/js-sdk/Users';
88
+ *
89
+ * const permissions = await Profiles.getProfilePermissions('PROFILEID');
90
+ * ```
91
+ */
92
+ export const getProfilePermissions = (profileId: string) =>
93
+ getEndpoint()
94
+ .get<IPermission[]>(`/profiles/${profileId}/permissions`)
95
+ .then((r) => r.data);
96
+
97
+ /**
98
+ * Get a profile's groups.
99
+ *
100
+ * ```typescript
101
+ * import {Profiles} from '@verdocs/js-sdk/Users';
102
+ *
103
+ * const groups = await Profiles.getProfileGroups('PROFILEID');
104
+ * ```
105
+ */
106
+ export const getProfileGroups = (profileId: string) =>
107
+ getEndpoint()
108
+ .get<IGroup[]>(`/profiles/${profileId}/groups`)
109
+ .then((r) => r.data);
110
+
111
+ /**
112
+ * Switch the caller's "current" profile. The current profile is used for permissions checking and profile_id field settings
113
+ * for most operations in Verdocs. It is important to select the appropropriate profile before calling other API functions.
114
+ *
115
+ * ```typescript
116
+ * import {Profiles} from '@verdocs/js-sdk/Users';
117
+ *
118
+ * const newProfile = await Profiles.switchProfile('PROFILEID');
119
+ * ```
120
+ */
121
+ export const switchProfile = (profileId: string) =>
122
+ getEndpoint()
123
+ .post<ISwitchProfileResponse>(`/profiles/${profileId}/switch`)
124
+ .then((r) => r.data);
125
+
126
+ /**
127
+ * Update a profile. For future expansion, the profile ID to update is required, but currently this must also be the
128
+ * "current" profile for the caller.
129
+ *
130
+ * ```typescript
131
+ * import {Profiles} from '@verdocs/js-sdk/Users';
132
+ *
133
+ * const newProfile = await Profiles.updateProfile('PROFILEID');
134
+ * ```
135
+ */
136
+ export const updateProfile = (profileId: string, params: IUpdateProfileRequest) =>
137
+ getEndpoint()
138
+ .put<IProfile>(`/profiles/${profileId}`, params)
139
+ .then((r) => r.data);
140
+
141
+ /**
142
+ * Delete a profile. If the requested profile is the caller's curent profile, the next available profile will be selected.
143
+ *
144
+ * ```typescript
145
+ * import {Profiles} from '@verdocs/js-sdk/Users';
146
+ *
147
+ * await Profiles.deleteProfile('PROFILEID');
148
+ * ```
149
+ */
150
+ export const deleteProfile = (profileId: string) =>
151
+ getEndpoint()
152
+ .delete(`/profiles/${profileId}`)
153
+ .then((r) => r.data);
@@ -0,0 +1,156 @@
1
+ import {IGroup, IOrganization} from '../Organizations/Types';
2
+ import {TRequestStatus} from '../HTTP/Types';
3
+
4
+ export type TPermission =
5
+ | 'org:view'
6
+ | 'member:view'
7
+ | 'org:update'
8
+ | 'member:add'
9
+ | 'member:remove'
10
+ | 'admin:add'
11
+ | 'admin:remove'
12
+ | 'org:delete'
13
+ | 'org:transfer'
14
+ | 'owner:add'
15
+ | 'owner:remove'
16
+ | 'template:creator:create:personal'
17
+ | 'template:creator:visibility'
18
+ | 'template:creator:create:org'
19
+ | 'template:member:read'
20
+ | 'template:member:write'
21
+ | 'template:member:visibility'
22
+ | 'template:creator:delete'
23
+ | 'template:member:delete'
24
+ | 'template:creator:create:public'
25
+ | 'rform:access'
26
+ | 'rcommon:access'
27
+ | 'org:list'
28
+ | 'org:create';
29
+
30
+ export type TPlan = 'env:essential' | 'org:standard';
31
+
32
+ export type TRole = 'owner' | 'basic_user' | 'member';
33
+
34
+ export interface IProfile {
35
+ /** The unique ID of the profile */
36
+ id: string;
37
+ /**
38
+ * The Verdocs back-end currently uses Auth0 for authentication. This value is a unique ID assigned by Auth0 to the
39
+ * user. This is typically used to identify multiple profiles owned by a single user, but its implementation may
40
+ * change in the future and developers should not develop code based on this field at this time.
41
+ */
42
+ user_id: string;
43
+ /** The profile's organization ID, or a global "Realster" organization that all personal profiles are members of. */
44
+ organization_id: string;
45
+ first_name: string;
46
+ last_name: string;
47
+ email: string;
48
+ phone: string | null;
49
+ /** If true, this is the caller's "currently selected" profile. All operations will performed "as" this profile. */
50
+ current: boolean;
51
+ /** The organization */
52
+ organization: IOrganization;
53
+ /** The permissions assigned to the profilel _NOTE: Only present in the "current" profile._ */
54
+ permissions?: TPermission[];
55
+ /** The roles assigned to the profilel _NOTE: Only present in the "current" profile._ */
56
+ roles?: TRole[];
57
+ /** The plans assigned to the profilel _NOTE: Only present in the "current" profile._ */
58
+ plans?: TPlan[];
59
+ /** The plans assigned to the profilel _NOTE: Only present in the "current" profile._ */
60
+ groups?: IGroup[];
61
+ }
62
+
63
+ export interface IActiveSession {
64
+ sub: string;
65
+ email: string;
66
+ email_verified: boolean;
67
+ iat: number;
68
+ exp: number;
69
+ permissions: IPermission[];
70
+ roles: IRole[];
71
+ profile: IProfile;
72
+ profile_id: string;
73
+ organization_id: string;
74
+ plans?: TPlan[];
75
+ }
76
+
77
+ export interface IRole {
78
+ /** Unique identifier for the role. */
79
+ id: string;
80
+ /** Display name for the role. */
81
+ name: string;
82
+ }
83
+
84
+ export interface IPermission {
85
+ /** Unique identifier for the permission. */
86
+ id: string;
87
+ /** Display name for the permission. */
88
+ name: string;
89
+ }
90
+
91
+ export interface ICreateProfileRequest {
92
+ first_name: string;
93
+ last_name: string;
94
+ email: string;
95
+ phone?: string;
96
+ }
97
+
98
+ export interface ISwitchProfileResponse {
99
+ profile: IProfile;
100
+ idToken: string;
101
+ accessToken: string;
102
+ refreshToken: string;
103
+ }
104
+
105
+ export interface IUpdateProfileRequest {
106
+ first_name?: string;
107
+ last_name?: string;
108
+ phone?: string;
109
+ }
110
+
111
+ export interface IAuthenticateUserRequest {
112
+ username: string;
113
+ password: string;
114
+ }
115
+
116
+ export interface IAuthenticateAppRequest {
117
+ client_id: string;
118
+ client_secret: string;
119
+ }
120
+
121
+ export interface IAuthenticateResponse {
122
+ idToken: string;
123
+ accessToken: string;
124
+ refreshToken: string;
125
+ }
126
+
127
+ export interface TokenValidationRequest {
128
+ token: string;
129
+ }
130
+
131
+ export interface TokenValidationResponse {
132
+ /** True if the token is valid */
133
+ valid: boolean;
134
+ /** The decoded and validated body of the JWT */
135
+ payload: any;
136
+ }
137
+
138
+ export interface UpdatePasswordRequest {
139
+ email: string;
140
+ oldPassword: string;
141
+ newPassword: string;
142
+ }
143
+
144
+ export interface UpdatePasswordResponse {
145
+ status: TRequestStatus;
146
+ /** Success or failure message */
147
+ message: string;
148
+ }
149
+
150
+ export interface UpdateEmailRequest {
151
+ email: string;
152
+ }
153
+
154
+ export interface UpdateEmailResponse {
155
+ profiles: IProfile[];
156
+ }
@@ -0,0 +1,5 @@
1
+ export * as Auth from './Auth';
2
+ export * as Billing from './Billing';
3
+ export * as Notifications from './Notifications';
4
+ export * as Profiles from './Profiles';
5
+ export * as Types from './Types';
@@ -0,0 +1,43 @@
1
+ const YEAR = 365 * 24 * 60 * 60;
2
+ const MONTH = 30 * 24 * 60 * 60;
3
+ const WEEK = 7 * 24 * 60 * 60;
4
+ const DAY = 24 * 60 * 60;
5
+ const HOUR = 60 * 60;
6
+ const MINUTE = 60;
7
+
8
+ export const formatShortTimeAgo = (val: any) => {
9
+ if (val === undefined || val === null) {
10
+ return '';
11
+ }
12
+
13
+ let dateInput;
14
+ if (typeof val === 'string' || typeof val === 'number') {
15
+ dateInput = new Date(val);
16
+ } else if (typeof val === 'object') {
17
+ dateInput = val;
18
+ } else {
19
+ return '';
20
+ }
21
+
22
+ const timeDiff = Math.floor((new Date().getTime() - dateInput.getTime()) / 1000);
23
+ if (timeDiff >= YEAR) {
24
+ return Math.floor(timeDiff / YEAR) + 'Y';
25
+ }
26
+ if (timeDiff >= MONTH) {
27
+ return Math.floor(timeDiff / MONTH) + 'M';
28
+ }
29
+ if (timeDiff >= WEEK) {
30
+ return Math.floor(timeDiff / WEEK) + 'W';
31
+ }
32
+ if (timeDiff >= DAY) {
33
+ return Math.floor(timeDiff / DAY) + 'Y';
34
+ }
35
+ if (timeDiff >= HOUR) {
36
+ return Math.floor(timeDiff / HOUR) + 'Y';
37
+ }
38
+ if (timeDiff >= MINUTE) {
39
+ return Math.floor(timeDiff / MINUTE) + 'Y';
40
+ }
41
+
42
+ return `${timeDiff}S`;
43
+ };
@@ -0,0 +1 @@
1
+ export * as DateTime from './DateTime';
@@ -0,0 +1,16 @@
1
+ import {getEndpoint} from './HTTP/Transport';
2
+
3
+ export interface IValidator {
4
+ name: string;
5
+ regex: string;
6
+ }
7
+
8
+ export const getValidators = () =>
9
+ getEndpoint()
10
+ .get<IValidator[]>('/validators')
11
+ .then((r) => r.data);
12
+
13
+ export const getValidator = (validatorName: string) =>
14
+ getEndpoint()
15
+ .get<IValidator>(`/validators/${validatorName}`)
16
+ .then((r) => r.data);
@@ -0,0 +1,11 @@
1
+ import {getEndpoint} from './HTTP/Transport';
2
+
3
+ export const createWhitelabel = () =>
4
+ getEndpoint()
5
+ .post('/whitelabel')
6
+ .then((r) => r.data);
7
+
8
+ export const getWhitelabel = () =>
9
+ getEndpoint()
10
+ .get('/whitelabel')
11
+ .then((r) => r.data);
@@ -0,0 +1,84 @@
1
+ import mockAxios from 'jest-mock-axios';
2
+ import {ApiKeys} from '../../Organizations';
3
+ import {IApiKey, IApiKeyWithSecret} from '../../Organizations/Types';
4
+
5
+ afterEach(() => {
6
+ mockAxios.reset();
7
+ });
8
+
9
+ const MockKey = {
10
+ client_id: 'TEST',
11
+ name: 'TEST',
12
+ profile_id: 'TEST',
13
+ organization_id: 'TEST',
14
+ } as IApiKey;
15
+
16
+ const MockKeyWithSecret = {
17
+ client_id: 'TEST',
18
+ client_secret: 'TEST',
19
+ name: 'TEST',
20
+ profile_id: 'TEST',
21
+ organization_id: 'TEST',
22
+ } as IApiKeyWithSecret;
23
+
24
+ it('getKeys should return a list of keys for an organization', () => {
25
+ const catchFn = jest.fn();
26
+ const thenFn = jest.fn();
27
+
28
+ ApiKeys.getKeys('TEST').then(thenFn).catch(catchFn);
29
+ expect(mockAxios.get).toBeCalledWith('/organizations/TEST/api_key');
30
+
31
+ mockAxios.mockResponse({data: [MockKeyWithSecret]});
32
+ expect(thenFn).toBeCalledWith([MockKeyWithSecret]);
33
+ expect(catchFn).not.toBeCalled();
34
+ });
35
+
36
+ it('createKey should return a newly created key', () => {
37
+ const catchFn = jest.fn();
38
+ const thenFn = jest.fn();
39
+
40
+ const request = {name: 'TEST', profile_id: 'TEST'};
41
+ ApiKeys.createKey('TEST', request).then(thenFn).catch(catchFn);
42
+ expect(mockAxios.post).toBeCalledWith('/organizations/TEST/api_key', request);
43
+
44
+ mockAxios.mockResponse({data: MockKeyWithSecret});
45
+ expect(thenFn).toBeCalledWith(MockKeyWithSecret);
46
+ expect(catchFn).not.toBeCalled();
47
+ });
48
+
49
+ it('rotateKey should return an updated key with secret', () => {
50
+ const catchFn = jest.fn();
51
+ const thenFn = jest.fn();
52
+
53
+ ApiKeys.rotateKey('TEST', 'TEST').then(thenFn).catch(catchFn);
54
+ expect(mockAxios.put).toBeCalledWith('/organizations/TEST/api_key/TEST/rotate');
55
+
56
+ mockAxios.mockResponse({data: MockKeyWithSecret});
57
+ expect(thenFn).toBeCalledWith(MockKeyWithSecret);
58
+ expect(catchFn).not.toBeCalled();
59
+ });
60
+
61
+ it('updateKey should return an updated key without secret', () => {
62
+ const catchFn = jest.fn();
63
+ const thenFn = jest.fn();
64
+
65
+ const params = {name: 'TEST'};
66
+ ApiKeys.updateKey('TEST', 'TEST', params).then(thenFn).catch(catchFn);
67
+ expect(mockAxios.patch).toBeCalledWith('/organizations/TEST/api_key/TEST', params);
68
+
69
+ mockAxios.mockResponse({data: MockKey});
70
+ expect(thenFn).toBeCalledWith(MockKey);
71
+ expect(catchFn).not.toBeCalled();
72
+ });
73
+
74
+ it('deleteKey should succeed', () => {
75
+ const catchFn = jest.fn();
76
+ const thenFn = jest.fn();
77
+
78
+ ApiKeys.deleteKey('TEST', 'TEST').then(thenFn).catch(catchFn);
79
+ expect(mockAxios.delete).toBeCalledWith('/organizations/TEST/api_key/TEST');
80
+
81
+ mockAxios.mockResponse();
82
+ expect(thenFn).toBeCalled();
83
+ expect(catchFn).not.toBeCalled();
84
+ });
@@ -0,0 +1,89 @@
1
+ import mockAxios from 'jest-mock-axios';
2
+ import {Auth} from '../../Users';
3
+
4
+ afterEach(() => {
5
+ mockAxios.reset();
6
+ });
7
+
8
+ it('authenticateUser should return access tokens', () => {
9
+ const catchFn = jest.fn();
10
+ const thenFn = jest.fn();
11
+
12
+ const request = {username: 'test@test.com', password: 'PASSWORD'};
13
+ Auth.authenticateUser(request).then(thenFn).catch(catchFn);
14
+ expect(mockAxios.post).toBeCalledWith('/authentication/login', request);
15
+
16
+ const response = {accessToken: 'A', idToken: 'B', refreshToken: 'C'};
17
+ mockAxios.mockResponse({data: response});
18
+ expect(thenFn).toBeCalledWith(response);
19
+ expect(catchFn).not.toBeCalled();
20
+ });
21
+
22
+ it('authenticateApp should return access tokens', () => {
23
+ const catchFn = jest.fn();
24
+ const thenFn = jest.fn();
25
+
26
+ const headers = {client_id: 'CLIENTID', client_secret: 'SECRET'};
27
+ Auth.authenticateApp(headers).then(thenFn).catch(catchFn);
28
+ expect(mockAxios.post).toBeCalledWith('/authentication/login_client', {}, {headers});
29
+
30
+ const response = {accessToken: 'A', idToken: 'B', refreshToken: 'C'};
31
+ mockAxios.mockResponse({data: response});
32
+ expect(thenFn).toBeCalledWith(response);
33
+ expect(catchFn).not.toBeCalled();
34
+ });
35
+
36
+ it('validateToken should return access tokens', () => {
37
+ const catchFn = jest.fn();
38
+ const thenFn = jest.fn();
39
+
40
+ const request = {token: 'TOKEN'};
41
+ Auth.validateToken(request).then(thenFn).catch(catchFn);
42
+ expect(mockAxios.post).toBeCalledWith('/token/isValid', request);
43
+
44
+ const response = {valid: true};
45
+ mockAxios.mockResponse({data: response});
46
+ expect(thenFn).toBeCalledWith(response);
47
+ expect(catchFn).not.toBeCalled();
48
+ });
49
+
50
+ it('refreshTokens should return access tokens', () => {
51
+ const catchFn = jest.fn();
52
+ const thenFn = jest.fn();
53
+
54
+ Auth.refreshTokens().then(thenFn).catch(catchFn);
55
+ expect(mockAxios.get).toBeCalledWith('/token');
56
+
57
+ const response = {accessToken: 'A', idToken: 'B', refreshToken: 'C'};
58
+ mockAxios.mockResponse({data: response});
59
+ expect(thenFn).toBeCalledWith(response);
60
+ expect(catchFn).not.toBeCalled();
61
+ });
62
+
63
+ it('updatePassword should return a success message', () => {
64
+ const catchFn = jest.fn();
65
+ const thenFn = jest.fn();
66
+
67
+ const request = {email: 'EMAIL', oldPassword: 'OLD', newPassword: 'NEW'};
68
+ Auth.updatePassword(request).then(thenFn).catch(catchFn);
69
+ expect(mockAxios.put).toBeCalledWith('/user/update_password', request);
70
+
71
+ const response = {status: 'OK', message: 'Password has been updated.'};
72
+ mockAxios.mockResponse({data: response});
73
+ expect(thenFn).toBeCalledWith(response);
74
+ expect(catchFn).not.toBeCalled();
75
+ });
76
+
77
+ it("updateEmail should return the user's profiles", () => {
78
+ const catchFn = jest.fn();
79
+ const thenFn = jest.fn();
80
+
81
+ const request = {email: 'EMAIL'};
82
+ Auth.updateEmail(request).then(thenFn).catch(catchFn);
83
+ expect(mockAxios.put).toBeCalledWith('/user/update_email', request);
84
+
85
+ const response = {profiles: []};
86
+ mockAxios.mockResponse({data: response});
87
+ expect(thenFn).toBeCalledWith(response);
88
+ expect(catchFn).not.toBeCalled();
89
+ });